@telepath-computer/television 0.1.177 → 0.1.179

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.
Files changed (38) hide show
  1. package/dist/canonical/v1/components.js +25 -7
  2. package/dist/canonical/v1/styles.css +17 -1
  3. package/dist/cli.cjs +1187 -392
  4. package/dist/onboarding/README.md +35 -0
  5. package/dist/onboarding/business-ops/about.html +150 -0
  6. package/dist/onboarding/business-ops/retention-vs-releases.html +572 -0
  7. package/dist/onboarding/business-ops/revenue-vs-goals.html +621 -0
  8. package/dist/onboarding/onboarding-screens.json +167 -0
  9. package/dist/onboarding/productivity/about.html +149 -0
  10. package/dist/onboarding/productivity/company-todos/index.html +121 -0
  11. package/dist/onboarding/productivity/company-todos/task.css +205 -0
  12. package/dist/onboarding/productivity/company-todos/task.js +307 -0
  13. package/dist/onboarding/productivity/meeting-prep.html +440 -0
  14. package/dist/onboarding/productivity/priorities-today.html +409 -0
  15. package/dist/onboarding/productivity/todays-calendar/calendar.css +1 -0
  16. package/dist/onboarding/productivity/todays-calendar/calendar.js +716 -0
  17. package/dist/onboarding/productivity/todays-calendar/index.html +52 -0
  18. package/dist/onboarding/research/about.html +152 -0
  19. package/dist/onboarding/research/draft-blog-post.md +30 -0
  20. package/dist/onboarding/research/open-model-research.html +542 -0
  21. package/dist/onboarding/research/todays-news.html +503 -0
  22. package/dist/onboarding/{television-onboarding → tv-guide/welcome}/index.html +5 -5
  23. package/dist/skills/television/SKILL.md +44 -0
  24. package/dist/skills/tv-tasks/SKILL.md +241 -0
  25. package/dist/skills/tv-tasks/task.css +205 -0
  26. package/dist/skills/tv-tasks/task.js +307 -0
  27. package/dist/views/markdown/index.html +1 -1
  28. package/dist/web/assets/calendar-DToAnkzj.png +0 -0
  29. package/dist/web/assets/main-5017mprd.css +1 -0
  30. package/dist/web/assets/main-C-OjKUzX.js +865 -0
  31. package/dist/web/assets/markdown-DdDrJuVK.png +0 -0
  32. package/dist/web/assets/table-oeG9uAN1.png +0 -0
  33. package/dist/web/assets/tasks-D4xqXFPl.png +0 -0
  34. package/dist/web/index.html +2 -2
  35. package/package.json +1 -1
  36. package/dist/web/assets/main-BSAIRhnY.js +0 -768
  37. package/dist/web/assets/main-o9Z-XUYA.css +0 -1
  38. /package/dist/onboarding/{television-onboarding → tv-guide/welcome}/assets/television.svg +0 -0
@@ -1,768 +0,0 @@
1
- var _S=Object.defineProperty;var Jp=n=>{throw TypeError(n)};var kS=(n,t,e)=>t in n?_S(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var g=(n,t,e)=>kS(n,typeof t!="symbol"?t+"":t,e),ru=(n,t,e)=>t.has(n)||Jp("Cannot "+e);var l=(n,t,e)=>(ru(n,t,"read from private field"),e?e.call(n):t.get(n)),w=(n,t,e)=>t.has(n)?Jp("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),b=(n,t,e,r)=>(ru(n,t,"write to private field"),r?r.call(n,e):t.set(n,e),e),p=(n,t,e)=>(ru(n,t,"access private method"),e);var iu=(n,t,e,r)=>({set _(i){b(n,t,i,e)},get _(){return l(n,t,r)}});import{i as Xp,a as su,b as Qp,c as ef,d as tf,e as xS,U as ES,f as nf,g as rf,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 xr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function PS(n){if(n.__esModule)return n;var t=n.default;if(typeof t=="function"){var e=function r(){return this instanceof r?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(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}),e}var sf=Object.prototype.toString,hv=function(t){var e=sf.call(t),r=e==="[object Arguments]";return r||(r=e!=="[object Array]"&&t!==null&&typeof t=="object"&&typeof t.length=="number"&&t.length>=0&&sf.call(t.callee)==="[object Function]"),r},ou,of;function LS(){if(of)return ou;of=1;var n;if(!Object.keys){var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,r=hv,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}};n=function(m){var E=m!==null&&typeof m=="object",x=e.call(m)==="[object Function]",I=r(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=n,ou}var DS=Array.prototype.slice,zS=hv,af=Object.keys,gl=af?function(t){return af(t)}:LS(),lf=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(r){return zS(r)?lf(DS.call(r)):lf(r)})}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,Dn=SyntaxError,K=TypeError,MS=Object.getOwnPropertyDescriptor,vl=MS;if(vl)try{vl([],"length")}catch{vl=null}var ws=vl,cf=Ta,NS=Dn,mi=K,uf=ws,dv=function(t,e,r){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=!!uf&&uf(t,e);if(cf)cf(t,e,{configurable:o===null&&c?c.configurable:!o,enumerable:i===null&&c?c.enumerable:!i,value:r,writable:s===null&&c?c.writable:!s});else if(a||!i&&!s&&!o)t[e]=r;else throw new NS("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},rh=Ta,pv=function(){return!!rh};pv.hasArrayLengthDefineBug=function(){if(!rh)return null;try{return rh([],"length",{value:1}).length!==1}catch{return!0}};var kc=pv,US=OS,FS=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",HS=Object.prototype.toString,ZS=Array.prototype.concat,hf=dv,WS=function(n){return typeof n=="function"&&HS.call(n)==="[object Function]"},fv=kc(),VS=function(n,t,e,r){if(t in n){if(r===!0){if(n[t]===e)return}else if(!WS(r)||!r())return}fv?hf(n,t,e,!0):hf(n,t,e)},gv=function(n,t){var e=arguments.length>2?arguments[2]:{},r=US(t);FS&&(r=ZS.call(r,Object.getOwnPropertySymbols(t)));for(var i=0;i<r.length;i+=1)VS(n,r[i],t[r[i]],e[r[i]])};gv.supportsDescriptors=!!fv;var oi=gv,yl={exports:{}};typeof self<"u"?yl.exports=self:typeof window<"u"?yl.exports=window:yl.exports=Function("return this")();var mv=yl.exports,BS=mv,vv=function(){return typeof xr!="object"||!xr||xr.Math!==Math||xr.Array!==Array?BS:xr},jS=oi,GS=ws,qS=vv,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=mv,yv=vv,XS=YS,QS=yv(),bv=function(){return QS};KS(bv,{getPolyfill:yv,implementation:JS,shim:XS});var kd=bv,zn=function(t){return!!t&&(typeof t=="function"||typeof t=="object")},xd=Object,wv=Error,e_=EvalError,t_=RangeError,Ed=ReferenceError,n_=URIError,r_=Math.abs,i_=Math.floor,s_=Math.max,o_=Math.min,a_=Math.pow,l_=Math.round,Ad=Number.isNaN||function(t){return t!==t},c_=Ad,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"),r=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[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},df=typeof Symbol<"u"&&Symbol,h_=Ss,Td=function(){return typeof df!="function"||typeof Symbol!="function"||typeof df("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:h_()},Sv=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,d_=xd,_v=d_.getPrototypeOf||null,p_="Function.prototype.bind called on incompatible ",f_=Object.prototype.toString,g_=Math.max,m_="[object Function]",pf=function(t,e){for(var r=[],i=0;i<t.length;i+=1)r[i]=t[i];for(var s=0;s<e.length;s+=1)r[s+t.length]=e[s];return r},v_=function(t,e){for(var r=[],i=e,s=0;i<t.length;i+=1,s+=1)r[s]=t[i];return r},y_=function(n,t){for(var e="",r=0;r<n.length;r+=1)e+=n[r],r+1<n.length&&(e+=t);return e},b_=function(t){var e=this;if(typeof e!="function"||f_.apply(e)!==m_)throw new TypeError(p_+e);for(var r=v_(arguments,1),i,s=function(){if(this instanceof i){var h=e.apply(this,pf(r,arguments));return Object(h)===h?h:this}return e.apply(t,pf(r,arguments))},o=g_(0,e.length-r.length),a=[],c=0;c<o;c++)a[c]="$"+c;if(i=Function("binder","return function ("+y_(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},w_=b_,$a=Function.prototype.bind||w_,$d=Function.prototype.call,Id=Function.prototype.apply,S_=typeof Reflect<"u"&&Reflect&&Reflect.apply,__=$a,k_=Id,x_=$d,E_=S_,kv=E_||__.call(x_,k_),A_=$a,T_=K,$_=$d,I_=kv,xc=function(t){if(t.length<1||typeof t[0]!="function")throw new T_("a function is required");return I_(A_,$_,t)},C_=xc,ff=ws,xv;try{xv=[].__proto__===Array.prototype}catch(n){if(!n||typeof n!="object"||!("code"in n)||n.code!=="ERR_PROTO_ACCESS")throw n}var au=!!xv&&ff&&ff(Object.prototype,"__proto__"),Ev=Object,gf=Ev.getPrototypeOf,R_=au&&typeof au.get=="function"?C_([au.get]):typeof gf=="function"?function(t){return gf(t==null?t:Ev(t))}:!1,mf=Sv,vf=_v,yf=R_,Av=mf?function(t){return mf(t)}:vf?function(t){if(!t||typeof t!="object"&&typeof t!="function")throw new TypeError("getProto: not an object");return vf(t)}:yf?function(t){return yf(t)}:null,P_=Function.prototype.call,L_=Object.prototype.hasOwnProperty,D_=$a,On=D_.call(P_,L_),q,z_=xd,O_=wv,M_=e_,N_=t_,U_=Ed,ps=Dn,Mi=K,F_=n_,H_=r_,Z_=i_,W_=s_,V_=o_,B_=a_,j_=l_,G_=u_,Tv=Function,lu=function(n){try{return Tv('"use strict"; return ('+n+").constructor;")()}catch{}},go=ws,q_=Ta,cu=function(){throw new Mi},Y_=go?function(){try{return arguments.callee,cu}catch{try{return go(arguments,"callee").get}catch{return cu}}}():cu,vi=Td(),Le=Av,K_=_v,J_=Sv,$v=Id,Ia=$d,ki={},X_=typeof Uint8Array>"u"||!Le?q:Le(Uint8Array),Xr={__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%":O_,"%eval%":eval,"%EvalError%":M_,"%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%":z_,"%Object.getOwnPropertyDescriptor%":go,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?q:Promise,"%Proxy%":typeof Proxy>"u"?q:Proxy,"%RangeError%":N_,"%ReferenceError%":U_,"%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%":Y_,"%TypedArray%":X_,"%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%":F_,"%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%":q_,"%Object.getPrototypeOf%":K_,"%Math.abs%":H_,"%Math.floor%":Z_,"%Math.max%":W_,"%Math.min%":V_,"%Math.pow%":B_,"%Math.round%":j_,"%Math.sign%":G_,"%Reflect.getPrototypeOf%":J_};if(Le)try{null.error}catch(n){var Q_=Le(Le(n));Xr["%Error.prototype%"]=Q_}var ek=function n(t){var e;if(t==="%AsyncFunction%")e=lu("async function () {}");else if(t==="%GeneratorFunction%")e=lu("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=lu("async function* () {}");else if(t==="%AsyncGenerator%"){var r=n("%AsyncGeneratorFunction%");r&&(e=r.prototype)}else if(t==="%AsyncIteratorPrototype%"){var i=n("%AsyncGenerator%");i&&Le&&(e=Le(i.prototype))}return Xr[t]=e,e},bf={__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=On,tk=Ca.call(Ia,Array.prototype.concat),nk=Ca.call($v,Array.prototype.splice),wf=Ca.call(Ia,String.prototype.replace),Fl=Ca.call(Ia,String.prototype.slice),rk=Ca.call(Ia,RegExp.prototype.exec),ik=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,sk=/\\(\\)?/g,ok=function(t){var e=Fl(t,0,1),r=Fl(t,-1);if(e==="%"&&r!=="%")throw new ps("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&e!=="%")throw new ps("invalid intrinsic syntax, expected opening `%`");var i=[];return wf(t,ik,function(s,o,a,c){i[i.length]=a?wf(c,sk,"$1"):o||s}),i},ak=function(t,e){var r=t,i;if(Ul(bf,r)&&(i=bf[r],r="%"+i[0]+"%"),Ul(Xr,r)){var s=Xr[r];if(s===ki&&(s=ek(r)),typeof s>"u"&&!e)throw new Mi("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:i,name:r,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(rk(/^%?[^%]*%?$/,t)===null)throw new ps("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=ok(t),i=r.length>0?r[0]:"",s=ak("%"+i+"%",e),o=s.name,a=s.value,c=!1,u=s.alias;u&&(i=u[0],nk(r,tk([0,1],u)));for(var h=1,f=!0;h<r.length;h+=1){var y=r[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(Xr,o))a=Xr[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>=r.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&&(Xr[o]=a)}}return a},uu,Sf;function cr(){if(Sf)return uu;Sf=1;var n=xt,t=xc,e=t([n("%String.prototype.indexOf%")]);return uu=function(i,s){var o=n(i,!!s);return typeof o=="function"&&e(i,".prototype.")>-1?t([o]):o},uu}var hu,_f;function Cd(){if(_f)return hu;_f=1;var n=xt,t=n("%Array%"),e=!t.isArray&&cr()("Object.prototype.toString");return hu=t.isArray||function(i){return e(i)==="[object Array]"},hu}var lk=kc,kf=Ta,Iv=lk.hasArrayLengthDefineBug(),ck=Iv&&Cd(),uk=cr(),hk=uk("Object.prototype.propertyIsEnumerable"),Rd=function(t,e,r,i,s,o){if(!kf){if(!t(o)||!o["[[Configurable]]"]||!o["[[Writable]]"]||s in i&&hk(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&&ck(i)&&i.length!==o["[[Value]]"]?(i.length=o["[[Value]]"],i.length===o["[[Value]]"]):(kf(i,s,r(o)),!0)},dk=K,zs=On,pk={__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)&&!pk[e])return!1;var r=zs(t,"[[Value]]")||zs(t,"[[Writable]]"),i=zs(t,"[[Get]]")||zs(t,"[[Set]]");if(r&&i)throw new dk("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},fk=K,gk=_s,mk=Cv,Rv=function(t){if(typeof t<"u"&&!gk(t))throw new fk("Assertion failed: `Desc` must be a Property Descriptor");return mk(t)},vk=K,xf=On,yk=_s,Pv=function(t){if(typeof t>"u")return!1;if(!yk(t))throw new vk("Assertion failed: `Desc` must be a Property Descriptor");return!(!xf(t,"[[Value]]")&&!xf(t,"[[Writable]]"))},ks=function(t){return typeof t=="string"||typeof t=="symbol"},Ef=Ad,Lv=function(t,e){return t===e?t===0?1/t===1/e:!0:Ef(t)&&Ef(e)},Af=K,bk=zn,wk=Rd,Sk=Rv,_k=Pv,kk=ks,xk=Lv,Pd=function(t,e,r){if(!bk(t))throw new Af("Assertion failed: Type(O) is not Object");if(!kk(e))throw new Af("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return wk(_k,xk,Sk,t,e,i)},Dv=Function.prototype.toString,Pi=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,ih,bl;if(typeof Pi=="function"&&typeof Object.defineProperty=="function")try{ih=Object.defineProperty({},"length",{get:function(){throw bl}}),bl={},Pi(function(){throw 42},null,ih)}catch(n){n!==bl&&(Pi=null)}else Pi=null;var Ek=/^\s*class\b/,sh=function(t){try{var e=Dv.call(t);return Ek.test(e)}catch{return!1}},du=function(t){try{return sh(t)?!1:(Dv.call(t),!0)}catch{return!1}},wl=Object.prototype.toString,Ak="[object Object]",Tk="[object Function]",$k="[object GeneratorFunction]",Ik="[object HTMLAllCollection]",Ck="[object HTML document.all class]",Rk="[object HTMLCollection]",Pk=typeof Symbol=="function"&&!!Symbol.toStringTag,Lk=!(0 in[,]),oh=function(){return!1};if(typeof document=="object"){var Dk=document.all;wl.call(Dk)===wl.call(document.all)&&(oh=function(t){if((Lk||!t)&&(typeof t>"u"||typeof t=="object"))try{var e=wl.call(t);return(e===Ik||e===Ck||e===Rk||e===Ak)&&t("")==null}catch{}return!1})}var zv=Pi?function(t){if(oh(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;try{Pi(t,null,ih)}catch(e){if(e!==bl)return!1}return!sh(t)&&du(t)}:function(t){if(oh(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;if(Pk)return du(t);if(sh(t))return!1;var e=wl.call(t);return e!==Tk&&e!==$k&&!/^\[object HTML/.test(e)?!1:du(t)},zk=zv,Ok=function(t){return!!t},Zt=On,Ka=K,Mk=zn,Tf=zk,pu=Ok,Nk=function(t){if(!Mk(t))throw new Ka("ToPropertyDescriptor requires an object");var e={};if(Zt(t,"enumerable")&&(e["[[Enumerable]]"]=pu(t.enumerable)),Zt(t,"configurable")&&(e["[[Configurable]]"]=pu(t.configurable)),Zt(t,"value")&&(e["[[Value]]"]=t.value),Zt(t,"writable")&&(e["[[Writable]]"]=pu(t.writable)),Zt(t,"get")){var r=t.get;if(typeof r<"u"&&!Tf(r))throw new Ka("getter must be a function");e["[[Get]]"]=r}if(Zt(t,"set")){var i=t.set;if(typeof i<"u"&&!Tf(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},fu=K,Uk=zn,$f=_s,Fk=Rd,Hk=Rv,Zk=Pv,Wk=ks,Vk=Lv,Bk=Nk,jk=function(t,e,r){if(!Uk(t))throw new fu("Assertion failed: Type(O) is not Object");if(!Wk(e))throw new fu("Assertion failed: P is not a Property Key");var i=$f(r)?r:Bk(r);if(!$f(i))throw new fu("Assertion failed: Desc is not a valid Property Descriptor");return Fk(Zk,Vk,Hk,t,e,i)},If=K,Gk=zn,qk=jk,Yk=ks,Kk=function(t,e,r){if(!Gk(t))throw new If("Assertion failed: Type(O) is not Object");if(!Yk(e))throw new If("Assertion failed: P is not a Property Key");var i={"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Value]]":r,"[[Writable]]":!0};return qk(t,e,i)},Jk=typeof Reflect<"u"&&Reflect.setPrototypeOf||null,Xk=xd,Qk=Xk.setPrototypeOf||null,ex=xc,Cf=ws,tx=K,Ov={};try{Ov.__proto__=null}catch(n){if(!n||typeof n!="object"||!("code"in n)||n.code!=="ERR_PROTO_ACCESS")throw n}var nx=!("toString"in Ov),gu=Cf&&Cf(Object.prototype,"__proto__"),rx=nx&&(!!gu&&typeof gu.set=="function"&&ex([gu.set])||function(t,e){if(t==null)throw new tx("set Object.prototype.__proto__ called on null or undefined");return t.__proto__=e,e}),Rf=Jk,ix=Qk,Pf=rx,sx=K,ox=Rf?function(t,e){if(Rf(t,e))return t;throw new sx("Reflect.setPrototypeOf: failed to set [[Prototype]]")}:ix||(Pf?function(t,e){return Pf(t,e),t}:null),Lf=K,ax=zn,Df=Av,lx=function(t){if(!ax(t))throw new Lf("Assertion failed: O must be an Object");if(!Df)throw new Lf("This environment does not support fetching prototypes.");return Df(t)},cx=K,ux=ox,hx=zn,dx=lx,px=function(t,e){if(e!==null&&!hx(e))throw new cx("Assertion failed: V must be Object or Null");try{ux(t,e)}catch{return!1}return dx(t)===e},mu=Pd,zf=Kk,Mv=px,fx=kc(),Ld=wv;function Ra(n,t,e){var r=new Ld(e);return Mv(r,Sl),delete r.constructor,zf(r,"error",n),zf(r,"suppressed",t),r}fx&&Object.defineProperty(Ra,"prototype",{writable:!1});var Sl=Ra.prototype;if(!mu(Sl,"constructor",Ra)||!mu(Sl,"message","")||!mu(Sl,"name","SuppressedError"))throw new Ld("unable to install SuppressedError.prototype properties; please report this!");Mv(Ra.prototype,Ld.prototype);var gx=Ra,mx=gx,Nv=function(){return typeof SuppressedError=="function"?SuppressedError:mx},vx=oi,Of=kd(),yx=Nv,bx=function(){var t=yx();return vx(Of,{SuppressedError:t},{SuppressedError:function(){return Of.SuppressedError!==t}}),t};bx();var wx=K,Sx=_s,_x=Cv,kx=function(t){if(typeof t<"u"&&!Sx(t))throw new wx("Assertion failed: `Desc` must be a Property Descriptor");return _x(t)},xx=K,Mf=On,Ex=_s,Ax=function(t){if(typeof t>"u")return!1;if(!Ex(t))throw new xx("Assertion failed: `Desc` must be a Property Descriptor");return!(!Mf(t,"[[Value]]")&&!Mf(t,"[[Writable]]"))},Nf=Ad,Tx=function(t,e){return t===e?t===0?1/t===1/e:!0:Nf(t)&&Nf(e)},xs=zv,$x=function(t){return!!t},Wt=On,Ja=K,Ix=zn,Uf=xs,vu=$x,Cx=function(t){if(!Ix(t))throw new Ja("ToPropertyDescriptor requires an object");var e={};if(Wt(t,"enumerable")&&(e["[[Enumerable]]"]=vu(t.enumerable)),Wt(t,"configurable")&&(e["[[Configurable]]"]=vu(t.configurable)),Wt(t,"value")&&(e["[[Value]]"]=t.value),Wt(t,"writable")&&(e["[[Writable]]"]=vu(t.writable)),Wt(t,"get")){var r=t.get;if(typeof r<"u"&&!Uf(r))throw new Ja("getter must be a function");e["[[Get]]"]=r}if(Wt(t,"set")){var i=t.set;if(typeof i<"u"&&!Uf(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},yu=K,Rx=zn,Ff=_s,Px=Rd,Lx=kx,Dx=Ax,zx=ks,Ox=Tx,Mx=Cx,Pa=function(t,e,r){if(!Rx(t))throw new yu("Assertion failed: Type(O) is not Object");if(!zx(e))throw new yu("Assertion failed: P is not a Property Key");var i=Ff(r)?r:Mx(r);if(!Ff(i))throw new yu("Assertion failed: Desc is not a valid Property Descriptor");return Px(Dx,Ox,Lx,t,e,i)},Nx=Ss(),Ux=Nx?Symbol.dispose||Symbol("Symbol.dispose"):null,Fx=Ss,Hx=Ux,Dd=function(){return Fx()&&Symbol.dispose||Hx},Zx=Td,Wx=Pa,Vx=Dd,Bx=function(){var t=Vx();return Zx()&&Wx(Symbol,"dispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":t}),t},jx=Ss(),Gx=jx?Symbol.asyncDispose||Symbol("Symbol.asyncDispose"):null,qx=Ss,Yx=Gx,zd=function(){return qx()&&Symbol.asyncDispose||Yx},Kx=Td,Jx=Pa,Xx=zd,Qx=function(){var t=Xx();return Kx()&&Jx(Symbol,"asyncDispose",{"[[Configurable]]":!1,"[[Enumerable]]":!1,"[[Writable]]":!1,"[[Value]]":t}),t},eE=Cd(),tE=xt,nE=cr(),rE=K,iE=eE,sE=tE("%Reflect.apply%",!0)||nE("Function.prototype.apply"),Ec=function(t,e){var r=arguments.length>2?arguments[2]:[];if(!iE(r))throw new rE("Assertion failed: optional `argumentsList`, if provided, must be a List");return sE(t,e,r)};const oE={},aE=Object.freeze(Object.defineProperty({__proto__:null,default:oE},Symbol.toStringTag,{value:"Module"})),lE=PS(aE);var Od=typeof Map=="function"&&Map.prototype,bu=Object.getOwnPropertyDescriptor&&Od?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Hl=Od&&bu&&typeof bu.get=="function"?bu.get:null,Hf=Od&&Map.prototype.forEach,Md=typeof Set=="function"&&Set.prototype,wu=Object.getOwnPropertyDescriptor&&Md?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Zl=Md&&wu&&typeof wu.get=="function"?wu.get:null,Zf=Md&&Set.prototype.forEach,cE=typeof WeakMap=="function"&&WeakMap.prototype,lo=cE?WeakMap.prototype.has:null,uE=typeof WeakSet=="function"&&WeakSet.prototype,co=uE?WeakSet.prototype.has:null,hE=typeof WeakRef=="function"&&WeakRef.prototype,Wf=hE?WeakRef.prototype.deref:null,dE=Boolean.prototype.valueOf,pE=Object.prototype.toString,fE=Function.prototype.toString,gE=String.prototype.match,Nd=String.prototype.slice,tr=String.prototype.replace,mE=String.prototype.toUpperCase,Vf=String.prototype.toLowerCase,Uv=RegExp.prototype.test,Bf=Array.prototype.concat,cn=Array.prototype.join,vE=Array.prototype.slice,jf=Math.floor,ah=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Su=Object.getOwnPropertySymbols,lh=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,Gf=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(n){return n.__proto__}:null);function qf(n,t){if(n===1/0||n===-1/0||n!==n||n&&n>-1e3&&n<1e3||Uv.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof n=="number"){var r=n<0?-jf(-n):jf(n);if(r!==n){var i=String(r),s=Nd.call(t,i.length+1);return tr.call(i,e,"$&_")+"."+tr.call(tr.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return tr.call(t,e,"$&_")}var ch=lE,Yf=ch.custom,Kf=Wv(Yf)?Yf:null,Hv={__proto__:null,double:'"',single:"'"},yE={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},Es=function n(t,e,r,i){var s=e||{};if(Sn(s,"quoteStyle")&&!Sn(Hv,s.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Sn(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=Sn(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(Sn(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(Sn(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?qf(t,c):c}if(typeof t=="bigint"){var u=String(t)+"n";return a?qf(t,u):u}var h=typeof s.depth>"u"?5:s.depth;if(typeof r>"u"&&(r=0),r>=h&&h>0&&typeof t=="object")return uh(t)?"[Array]":"[Object]";var f=OE(s,r);if(typeof i>"u")i=[];else if(Vv(i,t)>=0)return"[Circular]";function y(Ut,Mn,Bc){if(Mn&&(i=vE.call(i),i.push(Mn)),Bc){var Ha={depth:s.depth};return Sn(s,"quoteStyle")&&(Ha.quoteStyle=s.quoteStyle),n(Ut,Ha,r+1,i)}return n(Ut,s,r+1,i)}if(typeof t=="function"&&!Jf(t)){var m=TE(t),E=Xa(t,y);return"[Function"+(m?": "+m:" (anonymous)")+"]"+(E.length>0?" { "+cn.call(E,", ")+" }":"")}if(Wv(t)){var x=fs?tr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):lh.call(t);return typeof t=="object"&&!fs?Os(x):x}if(LE(t)){for(var I="<"+Vf.call(String(t.nodeName)),L=t.attributes||[],R=0;R<L.length;R++)I+=" "+L[R].name+"="+Zv(bE(L[R].value),"double",s);return I+=">",t.childNodes&&t.childNodes.length&&(I+="..."),I+="</"+Vf.call(String(t.nodeName))+">",I}if(uh(t)){if(t.length===0)return"[]";var V=Xa(t,y);return f&&!zE(V)?"["+hh(V,f)+"]":"[ "+cn.call(V,", ")+" ]"}if(SE(t)){var N=Xa(t,y);return!("cause"in Error.prototype)&&"cause"in t&&!Fv.call(t,"cause")?"{ ["+String(t)+"] "+cn.call(Bf.call("[cause]: "+y(t.cause),N),", ")+" }":N.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+cn.call(N,", ")+" }"}if(typeof t=="object"&&o){if(Kf&&typeof t[Kf]=="function"&&ch)return ch(t,{depth:h-r});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if($E(t)){var H=[];return Hf&&Hf.call(t,function(Ut,Mn){H.push(y(Mn,t,!0)+" => "+y(Ut,t))}),Xf("Map",Hl.call(t),H,f)}if(RE(t)){var Y=[];return Zf&&Zf.call(t,function(Ut){Y.push(y(Ut,t))}),Xf("Set",Zl.call(t),Y,f)}if(IE(t))return _u("WeakMap");if(PE(t))return _u("WeakSet");if(CE(t))return _u("WeakRef");if(kE(t))return Os(y(Number(t)));if(EE(t))return Os(y(ah.call(t)));if(xE(t))return Os(dE.call(t));if(_E(t))return Os(y(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(typeof globalThis<"u"&&t===globalThis||typeof xr<"u"&&t===xr)return"{ [object globalThis] }";if(!wE(t)&&!Jf(t)){var j=Xa(t,y),ce=Gf?Gf(t)===Object.prototype:t instanceof Object||t.constructor===Object,Tt=t instanceof Object?"":"null prototype",pr=!ce&&uo&&Object(t)===t&&uo in t?Nd.call(ur(t),8,-1):Tt?"Object":"",ze=ce||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",fr=ze+(pr||Tt?"["+cn.call(Bf.call([],pr||[],Tt||[]),": ")+"] ":"");return j.length===0?fr+"{}":f?fr+"{"+hh(j,f)+"}":fr+"{ "+cn.call(j,", ")+" }"}return String(t)};function Zv(n,t,e){var r=e.quoteStyle||t,i=Hv[r];return i+n+i}function bE(n){return tr.call(String(n),/"/g,"&quot;")}function ai(n){return!uo||!(typeof n=="object"&&(uo in n||typeof n[uo]<"u"))}function uh(n){return ur(n)==="[object Array]"&&ai(n)}function wE(n){return ur(n)==="[object Date]"&&ai(n)}function Jf(n){return ur(n)==="[object RegExp]"&&ai(n)}function SE(n){return ur(n)==="[object Error]"&&ai(n)}function _E(n){return ur(n)==="[object String]"&&ai(n)}function kE(n){return ur(n)==="[object Number]"&&ai(n)}function xE(n){return ur(n)==="[object Boolean]"&&ai(n)}function Wv(n){if(fs)return n&&typeof n=="object"&&n instanceof Symbol;if(typeof n=="symbol")return!0;if(!n||typeof n!="object"||!lh)return!1;try{return lh.call(n),!0}catch{}return!1}function EE(n){if(!n||typeof n!="object"||!ah)return!1;try{return ah.call(n),!0}catch{}return!1}var AE=Object.prototype.hasOwnProperty||function(n){return n in this};function Sn(n,t){return AE.call(n,t)}function ur(n){return pE.call(n)}function TE(n){if(n.name)return n.name;var t=gE.call(fE.call(n),/^function\s*([\w$]+)/);return t?t[1]:null}function Vv(n,t){if(n.indexOf)return n.indexOf(t);for(var e=0,r=n.length;e<r;e++)if(n[e]===t)return e;return-1}function $E(n){if(!Hl||!n||typeof n!="object")return!1;try{Hl.call(n);try{Zl.call(n)}catch{return!0}return n instanceof Map}catch{}return!1}function IE(n){if(!lo||!n||typeof n!="object")return!1;try{lo.call(n,lo);try{co.call(n,co)}catch{return!0}return n instanceof WeakMap}catch{}return!1}function CE(n){if(!Wf||!n||typeof n!="object")return!1;try{return Wf.call(n),!0}catch{}return!1}function RE(n){if(!Zl||!n||typeof n!="object")return!1;try{Zl.call(n);try{Hl.call(n)}catch{return!0}return n instanceof Set}catch{}return!1}function PE(n){if(!co||!n||typeof n!="object")return!1;try{co.call(n,co);try{lo.call(n,lo)}catch{return!0}return n instanceof WeakSet}catch{}return!1}function LE(n){return!n||typeof n!="object"?!1:typeof HTMLElement<"u"&&n instanceof HTMLElement?!0:typeof n.nodeName=="string"&&typeof n.getAttribute=="function"}function Bv(n,t){if(n.length>t.maxStringLength){var e=n.length-t.maxStringLength,r="... "+e+" more character"+(e>1?"s":"");return Bv(Nd.call(n,0,t.maxStringLength),t)+r}var i=yE[t.quoteStyle||"single"];i.lastIndex=0;var s=tr.call(tr.call(n,i,"\\$1"),/[\x00-\x1f]/g,DE);return Zv(s,"single",t)}function DE(n){var t=n.charCodeAt(0),e={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return e?"\\"+e:"\\x"+(t<16?"0":"")+mE.call(t.toString(16))}function Os(n){return"Object("+n+")"}function _u(n){return n+" { ? }"}function Xf(n,t,e,r){var i=r?hh(e,r):cn.call(e,", ");return n+" ("+t+") {"+i+"}"}function zE(n){for(var t=0;t<n.length;t++)if(Vv(n[t],`
2
- `)>=0)return!1;return!0}function OE(n,t){var e;if(n.indent===" ")e=" ";else if(typeof n.indent=="number"&&n.indent>0)e=cn.call(Array(n.indent+1)," ");else return null;return{base:e,prev:cn.call(Array(t+1),e)}}function hh(n,t){if(n.length===0)return"";var e=`
3
- `+t.prev+t.base;return e+cn.call(n,","+e)+`
4
- `+t.prev}function Xa(n,t){var e=uh(n),r=[];if(e){r.length=n.length;for(var i=0;i<n.length;i++)r[i]=Sn(n,i)?t(n[i],n):""}var s=typeof Su=="function"?Su(n):[],o;if(fs){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var c in n)Sn(n,c)&&(e&&String(Number(c))===c&&c<n.length||fs&&o["$"+c]instanceof Symbol||(Uv.call(/[^\w$]/,c)?r.push(t(c,n)+": "+t(n[c],n)):r.push(c+": "+t(n[c],n))));if(typeof Su=="function")for(var u=0;u<s.length;u++)Fv.call(n,s[u])&&r.push("["+t(s[u])+"]: "+t(n[s[u]],n));return r}var ME=Es,NE=K,Ac=function(n,t,e){for(var r=n,i;(i=r.next)!=null;r=i)if(i.key===t)return r.next=i.next,e||(i.next=n.next,n.next=i),i},UE=function(n,t){if(n){var e=Ac(n,t);return e&&e.value}},FE=function(n,t,e){var r=Ac(n,t);r?r.value=e:n.next={key:t,next:n.next,value:e}},HE=function(n,t){return n?!!Ac(n,t):!1},ZE=function(n,t){if(n)return Ac(n,t,!0)},WE=function(){var t,e={assert:function(r){if(!e.has(r))throw new NE("Side channel does not contain "+ME(r))},delete:function(r){var i=t&&t.next,s=ZE(t,r);return s&&i&&i===s&&(t=void 0),!!s},get:function(r){return UE(t,r)},has:function(r){return HE(t,r)},set:function(r,i){t||(t={next:void 0}),FE(t,r,i)}};return e},VE=xt,La=cr(),BE=Es,jE=K,Qf=VE("%Map%",!0),GE=La("Map.prototype.get",!0),qE=La("Map.prototype.set",!0),YE=La("Map.prototype.has",!0),KE=La("Map.prototype.delete",!0),JE=La("Map.prototype.size",!0),jv=!!Qf&&function(){var t,e={assert:function(r){if(!e.has(r))throw new jE("Side channel does not contain "+BE(r))},delete:function(r){if(t){var i=KE(t,r);return JE(t)===0&&(t=void 0),i}return!1},get:function(r){if(t)return GE(t,r)},has:function(r){return t?YE(t,r):!1},set:function(r,i){t||(t=new Qf),qE(t,r,i)}};return e},XE=xt,Tc=cr(),QE=Es,Qa=jv,eA=K,yi=XE("%WeakMap%",!0),tA=Tc("WeakMap.prototype.get",!0),nA=Tc("WeakMap.prototype.set",!0),rA=Tc("WeakMap.prototype.has",!0),iA=Tc("WeakMap.prototype.delete",!0),sA=yi?function(){var t,e,r={assert:function(i){if(!r.has(i))throw new eA("Side channel does not contain "+QE(i))},delete:function(i){if(yi&&i&&(typeof i=="object"||typeof i=="function")){if(t)return iA(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?tA(t,i):e&&e.get(i)},has:function(i){return yi&&i&&(typeof i=="object"||typeof i=="function")&&t?rA(t,i):!!e&&e.has(i)},set:function(i,s){yi&&i&&(typeof i=="object"||typeof i=="function")?(t||(t=new yi),nA(t,i,s)):Qa&&(e||(e=Qa()),e.set(i,s))}};return r}:Qa,oA=K,aA=Es,lA=WE,cA=jv,uA=sA,hA=uA||cA||lA,dA=function(){var t,e={assert:function(r){if(!e.has(r))throw new oA("Side channel does not contain "+aA(r))},delete:function(r){return!!t&&t.delete(r)},get:function(r){return t&&t.get(r)},has:function(r){return!!t&&t.has(r)},set:function(r,i){t||(t=hA()),t.set(r,i)}};return e},pA=On,Ms=dA(),mn=K,Ud={assert:function(n,t){if(!n||typeof n!="object"&&typeof n!="function")throw new mn("`O` is not an object");if(typeof t!="string")throw new mn("`slot` must be a string");if(Ms.assert(n),!Ud.has(n,t))throw new mn("`"+t+"` is not present on `O`")},get:function(n,t){if(!n||typeof n!="object"&&typeof n!="function")throw new mn("`O` is not an object");if(typeof t!="string")throw new mn("`slot` must be a string");var e=Ms.get(n);return e&&e["$"+t]},has:function(n,t){if(!n||typeof n!="object"&&typeof n!="function")throw new mn("`O` is not an object");if(typeof t!="string")throw new mn("`slot` must be a string");var e=Ms.get(n);return!!e&&pA(e,"$"+t)},set:function(n,t,e){if(!n||typeof n!="object"&&typeof n!="function")throw new mn("`O` is not an object");if(typeof t!="string")throw new mn("`slot` must be a string");var r=Ms.get(n);r||(r={},Ms.set(n,r)),r["$"+t]=e}};Object.freeze&&Object.freeze(Ud);var Fd=Ud,Gv=Dn,rr=Fd,Da=function n(t,e){if(!(this instanceof n))return new n(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"');rr.set(this,"[[Type]]",t),rr.set(this,"[[Value]]",e)};Da.prototype.type=function(){return rr.get(this,"[[Type]]")};Da.prototype.value=function(){return rr.get(this,"[[Value]]")};Da.prototype["?"]=function(){var t=rr.get(this,"[[Type]]"),e=rr.get(this,"[[Value]]");if(t==="throw")throw e;return e};Da.prototype["!"]=function(){var t=rr.get(this,"[[Type]]");if(t!=="normal")throw new Gv('Assertion failed: Completion Record is not of type "normal"');return rr.get(this,"[[Value]]")};var Hd=Da,fA=Hd,Zd=function(t){return new fA("normal",t)},ku,eg;function gA(){if(eg)return ku;eg=1;var n=Ss;return ku=function(){return n()&&!!Symbol.toStringTag},ku}var mA=xt,tg=mA("%Object.defineProperty%",!0),vA=gA()(),yA=On,bA=K,el=vA?Symbol.toStringTag:null,qv=function(t,e){var r=arguments.length>2&&!!arguments[2]&&arguments[2].force,i=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof r<"u"&&typeof r!="boolean"||typeof i<"u"&&typeof i!="boolean")throw new bA("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");el&&(r||!yA(t,el))&&(tg?tg(t,el,{configurable:!i,enumerable:!1,value:e,writable:!1}):t[el]=e)},Yv={exports:{}},wA=xt,ng=dv,SA=kc(),rg=ws,ig=K,_A=wA("%Math.floor%"),kA=function(t,e){if(typeof t!="function")throw new ig("`fn` is not a function");if(typeof e!="number"||e<0||e>4294967295||_A(e)!==e)throw new ig("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in t&&rg){var o=rg(t,"length");o&&!o.configurable&&(i=!1),o&&!o.writable&&(s=!1)}return(i||s||!r)&&(SA?ng(t,"length",e,!0,!0):ng(t,"length",e)),t},xA=$a,EA=Id,AA=kv,TA=function(){return AA(xA,EA,arguments)};(function(n){var t=kA,e=Ta,r=xc,i=TA;n.exports=function(o){var a=r(arguments),c=1+o.length-(arguments.length-1);return t(a,c>0?c:0,!0)},e?e(n.exports,"apply",{value:i}):n.exports.apply=i})(Yv);var Wd=Yv.exports,$A=function(t,e){for(var r=0;r<t.length;r+=1)if(!e(t[r],r,t))return!1;return!0},IA=Object,CA=function(t){return t&&typeof t=="object"&&(typeof t["[[ResourceValue]]"]>"u"||IA(t["[[ResourceValue]]"])===t["[[ResourceValue]]"])&&(t["[[Hint]]"]==="SYNC-DISPOSE"||t["[[Hint]]"]==="ASYNC-DISPOSE")&&(typeof t["[[DisposeMethod]]"]=="function"||typeof t["[[DisposeMethod]]"]>"u")},RA=On,PA=Cd(),LA=$A,DA=CA,zA=function(t){return t&&typeof t=="object"&&RA(t,"[[DisposableResourceStack]]")&&PA(t["[[DisposableResourceStack]]"])&&(t["[[DisposableResourceStack]]"].length===0||LA(t["[[DisposableResourceStack]]"],DA))},OA=zn,MA=function(t){if(t===null)return"Null";if(typeof t>"u")return"Undefined";if(OA(t))return"Object";if(typeof t=="number")return"Number";if(typeof t=="boolean")return"Boolean";if(typeof t=="string")return"String"},NA=MA,Vd=function(t){return typeof t=="symbol"?"Symbol":typeof t=="bigint"?"BigInt":NA(t)},UA=K,FA=Es,HA=ks,ZA=function(t,e){if(!HA(e))throw new UA("Assertion failed: P is not a Property Key, got "+FA(e));return t[e]},sg=K,WA=ZA,VA=xs,BA=ks,og=Es,jA=function(t,e){if(!BA(e))throw new sg("Assertion failed: P is not a Property Key");var r=WA(t,e);if(r!=null){if(!VA(r))throw new sg(og(e)+" is not a function: "+og(r));return r}},dh={exports:{}},GA=xt,qA=GA,ag=qA("%Reflect.construct%",!0),Wl=Pa;try{Wl({},"",{"[[Get]]":function(){}})}catch{Wl=null}if(Wl&&ag){var lg={},cg={};Wl(cg,"length",{"[[Get]]":function(){throw lg},"[[Enumerable]]":!0}),dh.exports=function(t){try{ag(t,cg)}catch(e){return e===lg}}}else dh.exports=function(t){return typeof t=="function"&&!!t.prototype};var YA=dh.exports,xu=K,ug=xs,KA=YA,JA=function(t){if(!KA(t))throw new xu("C must be a constructor");var e={"[[Resolve]]":void 0,"[[Reject]]":void 0},r=new t(function(i,s){if(typeof e["[[Resolve]]"]<"u"||typeof e["[[Reject]]"]<"u")throw new xu("executor has already been called");e["[[Resolve]]"]=i,e["[[Reject]]"]=s});if(!ug(e["[[Resolve]]"])||!ug(e["[[Reject]]"]))throw new xu("executor must provide valid resolve and reject functions");return{"[[Promise]]":r,"[[Resolve]]":e["[[Resolve]]"],"[[Reject]]":e["[[Reject]]"]}},hg=Dn,XA=K,Eu=Ec,dg=jA,QA=JA,e1=Vd,pg=Dd(),fg=zd(),t1=function(t,e){if(e1(t)!=="Object")throw new XA("`V` must be an Object");if(e!=="SYNC-DISPOSE"&&e!=="ASYNC-DISPOSE")throw new hg("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(e==="ASYNC-DISPOSE"&&fg&&(r=dg(t,fg)),!r){if(!pg)throw new hg("`Symbol.dispose` is not supported");if(r=dg(t,pg),typeof r<"u")return function(){var i=this;if(e==="ASYNC-DISPOSE"){var s=QA(Promise);try{Eu(r,i),Eu(s["[[Resolve]]"],void 0,[void 0])}catch(o){s["[[Reject]]"](o)}return s["[[Promise]]"]}Eu(r,i)}}return r},n1=Dn,Au=K,r1=xs,i1=Vd,s1=t1,o1=function(t,e){if(e!=="SYNC-DISPOSE"&&e!=="ASYNC-DISPOSE")throw new n1("Assertion failed: `hint` must be `~SYNC-DISPOSE~` or `~ASYNC-DISPOSE~`");var r;if(arguments.length<3)if(t==null)t=void 0,r=void 0;else{if(typeof t<"u"&&i1(t)!=="Object")throw new Au("`V` must be an Object, or `null` or `undefined`");if(r=s1(t,e),typeof r>"u")throw new Au("dispose method must not be `undefined` on `V` when an object `V` is provided")}else if(r=arguments[2],!r1(r))throw new Au("`method`, when provided, must be a function");return{"[[ResourceValue]]":t,"[[Hint]]":e,"[[DisposeMethod]]":r}},a1=Dn,tl=K,l1=zA,gg=o1,c1=cr(),u1=c1("Array.prototype.push"),Kv=function(t,e,r){if(!l1(t))throw new tl("Assertion failed: `disposeCapability` must be a DisposeCapability Record");if(r!=="SYNC-DISPOSE"&&r!=="ASYNC-DISPOSE")throw new a1("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&&r==="SYNC_DISPOSE")return"UNUSED";s=gg(e,r)}else{if(typeof e<"u")throw new tl("Assertion failed: `V` must be undefined when `method` is present");s=gg(void 0,r,i)}return u1(t["[[DisposableResourceStack]]"],s),"UNUSED"},Tu,mg;function Bd(){if(mg)return Tu;mg=1;var n=xt,t=Wd,e=Dn,r=n("%Promise.resolve%",!0),i=r&&t(r);return Tu=function(o,a){if(!i)throw new e("This environment does not support Promises.");return i(o,a)},Tu}var $u,vg;function h1(){if(vg)return $u;vg=1;var n=xt,t=Dn,e=n("%Promise%",!0),r=Ec,i=Bd(),s=Vd;return $u=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:r(u,a);if(c==="ASYNC-DISPOSE")return i(e,h)},$u}var Iu,yg;function d1(){if(yg)return Iu;yg=1;var n=Hd;return Iu=function(e){return new n("throw",e)},Iu}var p1=xt,Cu=Dn,bg=K,f1=p1("%Promise%",!0),g1=cr(),wg=g1("Promise.prototype.then",!0),m1=Hd,Sg=h1(),v1=Zd,y1=Bd(),_g=d1(),b1=Nv(),Jv=function(t,e){if(!(e instanceof m1))throw new bg("`completion` must be a Completion Record");var r=t["[[DisposableResourceStack]]"];if(!r)throw new bg("Assertion failed: `disposeCapability.[[DisposableResourceStack]]` must not be ~EMPTY~");for(var i,s=r.length-1;s>=0;s-=1)if(!i)i=r[s]["[[Hint]]"];else if(i!==r[s]["[[Hint]]"])throw new Cu("mixed hint stacks are not supported");for(var o=i==="ASYNC-DISPOSE"&&y1(f1,e),a=function(y){if(e.type()==="throw"){var m=e.value(),E=new b1(y,m);e=_g(E)}else e=_g(y)},c=i==="ASYNC-DISPOSE"&&function(m){return wg(o,function(){var E=Sg(m["[[ResourceValue]]"],m["[[Hint]]"],m["[[DisposeMethod]]"]);if(!E)throw new Cu("Assertion failed: non-`~ASYNC-DISPOSE~` resource returned a promise from Dispose");return wg(E,v1)},a)},u=r.length-1;u>=0;u-=1)if(i==="ASYNC-DISPOSE")o=c(r[u]);else{var h=r[u];try{var f=Sg(h["[[ResourceValue]]"],h["[[Hint]]"],h["[[DisposeMethod]]"]);if(f)throw new Cu("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=Ed,jd=K,w1=Ec,As=Pd,S1=Pa,Qv=xs,_1=Zd,lt=Fd,k1=qv,ey=oi.supportsDescriptors,x1=Wd,Gd=Kv,E1=Jv,ty=Xv,kg=Dd(),wt=function n(){if(!(this instanceof n)||lt.has(this,"[[DisposableState]]")||lt.has(this,"[[DisposeCapability]]"))throw new jd("can only be used with new");lt.set(this,"[[DisposableState]]","PENDING"),lt.set(this,"[[DisposeCapability]]",ty())},ny=function(){var t=this;return lt.assert(t,"[[DisposableState]]"),lt.get(t,"[[DisposableState]]")==="DISPOSED"},za=x1(ny);ey?S1(wt.prototype,"disposed",{"[[Configurable]]":!0,"[[Enumerable]]":!1,"[[Get]]":ny}):wt.prototype.disposed=!1;var ry=function(t){lt.set(t,"[[DisposableState]]","DISPOSED"),ey||(t.disposed=!0)};As(wt.prototype,"dispose",function(){var t=this;if(!za(t))return ry(t),E1(lt.get(t,"[[DisposeCapability]]"),_1())["?"]()});As(wt.prototype,"use",function(t){var e=this;if(za(e))throw new $c("a disposed stack can not use anything new");return Gd(lt.get(e,"[[DisposeCapability]]"),t,"SYNC-DISPOSE"),t});As(wt.prototype,"adopt",function(t,e){var r=this;if(za(r))throw new $c("a disposed stack can not use anything new");if(!Qv(e))throw new jd("`onDispose` must be a function");var i=function(){return w1(e,void 0,[t])};return Gd(lt.get(r,"[[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 jd("`onDispose` must be a function");Gd(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()),ry(t),e});kg&&As(wt.prototype,kg,wt.prototype.dispose);k1(wt.prototype,"DisposableStack");var A1=wt,T1=A1,$1=function(){return typeof DisposableStack=="function"?DisposableStack:T1},I1=oi,C1=kd(),R1=$1,P1=function(){var t=R1();return I1(C1,{DisposableStack:t},{DisposableStack:!0}),t},L1=xt,Ic=Ed,qd=K,xg=L1("%Promise%",!0),Yd=Kv,D1=Ec,Ts=Pd,z1=Pa,O1=Jv,iy=xs,sy=Xv,M1=Zd,Eg=Bd(),ct=Fd,N1=qv,oy=oi.supportsDescriptors,U1=Wd,F1=cr(),H1=F1("Promise.prototype.then",!0),Ag=zd(),St=function n(){if(!(this instanceof n)||ct.has(this,"[[AsyncDisposableState]]")||ct.has(this,"[[DisposeCapability]]"))throw new qd("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=U1(ay);oy?z1(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)?Eg(xg):(ly(t),H1(Eg(xg,O1(ct.get(t,"[[DisposeCapability]]"),M1())),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 Yd(ct.get(e,"[[DisposeCapability]]"),t,"ASYNC-DISPOSE"),t});Ts(St.prototype,"adopt",function(t,e){var r=this;if(Oa(r))throw new Ic("a disposed stack can not use anything new");if(!iy(e))throw new qd("`onDisposeAsync` must be a function");var i=function(){return D1(e,void 0,[t])};return i.value=t,Yd(ct.get(r,"[[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 qd("`onDispose` must be a function");Yd(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});Ag&&Ts(St.prototype,Ag,St.prototype.disposeAsync);N1(St.prototype,"AsyncDisposableStack");var Z1=St,W1=Z1,V1=function(){return typeof AsyncDisposableStack=="function"?AsyncDisposableStack:W1},B1=oi,j1=kd(),G1=V1,q1=function(){var t=G1();return B1(j1,{AsyncDisposableStack:t},{AsyncDisposableStack:!0}),t},Y1=Bx,K1=Qx,J1=P1,X1=q1,Q1=function(){Y1(),K1(),J1(),X1()};Q1();const Tg=new WeakMap;function eT(n){return(typeof n=="object"||typeof n=="function")&&n!==null&&"then"in n&&typeof n.then=="function"}function bi(n){return typeof n=="string"?n:typeof n=="symbol"?n.description??n.toString():n.name||"(anonymous class)"}function $g(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function tT(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class nT{constructor(){g(this,"entries",new Map);g(this,"constructionStack",[])}register(t,e){if(e===void 0){if(typeof t!="function")throw $g();this.validateClassRegistration(t),this.storeFactory(t,()=>this.instantiateClass(t));return}if(typeof e!="function")throw $g();if(e.constructor.name==="AsyncFunction")throw tT();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 r=this.getOrCreateEntry(t);r.factory=e,r.instance=void 0,r.error=void 0}validateClassRegistration(t){const e=Tg.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=Tg.get(t);if(!e)return new t;const r=e.map(i=>this.resolveAny(i));return new t(...r)}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,r)=>{if(r==="then")return;const i=this.getInstance(t),s=Reflect.get(i,r,i);return typeof s=="function"?s.bind(i):s},set:(e,r,i)=>{const s=this.getInstance(t);return Reflect.set(s,r,i,s)},has:(e,r)=>{const i=this.getInstance(t);return r 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 r=[...this.constructionStack.slice(e),t.key].map(i=>bi(i)).join(" -> ");throw new Error(`Circular dependency detected: ${r}`)}this.constructionStack.push(t.key);try{const r=t.factory();if(eT(r))throw new Error(`Factory for ${bi(t.key)} returned a Promise. Await setup before registering.`);if(typeof r!="object"||r===null)throw new Error(`Factory for ${bi(t.key)} returned a non-object value. Wrap primitives in an object.`);return t.instance=r,r}catch(r){throw t.error=r,r}finally{this.constructionStack.pop()}}}const dn=new nT,rT=.5,Ig=.1,Cg=8,iT=4,cy=3,uy=3,sT=4,Tr=255,hy=.2126,dy=.7152,py=.0722;async function fy(n){const t=oT(n);if(!t)return"light";try{return await cT(n,t)>=rT?"light":"dark"}catch{return"light"}}function oT(n){if(typeof document.elementsFromPoint!="function")return null;const t=n.getBoundingClientRect(),e=t.left+t.width/2,r=t.top+t.height/2,i=document.elementsFromPoint(e,r);for(const s of i){if(!(s instanceof HTMLElement)||s===n||n.contains(s))continue;const o=window.getComputedStyle(s);if(aT(o))return s}return null}function aT(n){return gy(n.backgroundImage)?!0:lT(n.backgroundColor)>0}function lT(n){if(!n)return 0;const t=n.match(/rgba?\(([^)]+)\)/);if(!t)return 0;const e=t[1].split(/[\s,/]+/).filter(Boolean);return e.length===sT?parseFloat(e[cy]):e.length===uy?1:0}async function cT(n,t){const e=n.getBoundingClientRect(),r=t.getBoundingClientRect(),i={x:nl((e.left-r.left)/r.width),y:nl((e.top-r.top)/r.height),width:nl(e.width/r.width),height:nl(e.height/r.height)},s=window.getComputedStyle(t),o=gy(s.backgroundImage);return o?hT({url:o,surfaceWidth:r.width,surfaceHeight:r.height,region:i}):dT(s.backgroundColor)}function gy(n){const t=n.match(/url\(\s*["']?([^"')]+)["']?\s*\)/);return t?t[1]:null}const Rg=new Map;function uT(n){let t=Rg.get(n);return t||(t=new Promise((e,r)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=()=>e(i),i.onerror=()=>r(new Error(`Failed to load ${n}`)),i.src=n}),Rg.set(n,t),t)}async function hT(n){const t=await uT(n.url),e=Math.max(Cg,Math.ceil(n.surfaceWidth*Ig)),r=Math.max(Cg,Math.ceil(n.surfaceHeight*Ig)),i=document.createElement("canvas");i.width=e,i.height=r;const s=i.getContext("2d",{willReadFrequently:!0});if(!s)return 1;const o=n.surfaceWidth/n.surfaceHeight,a=t.naturalWidth/t.naturalHeight;let c,u;a>o?(u=r,c=r*a):(c=e,u=e/a);const h=(e-c)/2,f=(r-u)/2;s.drawImage(t,h,f,c,u);const y=Math.max(0,Math.floor(n.region.x*e)),m=Math.max(0,Math.floor(n.region.y*r)),E=Math.max(1,Math.min(e-y,Math.floor(n.region.width*e))),x=Math.max(1,Math.min(r-m,Math.floor(n.region.height*r))),I=s.getImageData(y,m,E,x).data;let L=0,R=0;for(let V=0;V<I.length;V+=iT){const N=I[V]/Tr,H=I[V+1]/Tr,Y=I[V+2]/Tr,j=I[V+cy]/Tr;L+=j*(hy*N+dy*H+py*Y),R+=1}return R>0?L/R:1}function dT(n){const t=n.match(/rgba?\(([^)]+)\)/);if(!t)return 1;const e=t[1].split(/[\s,/]+/).filter(Boolean).map(parseFloat);if(e.length<uy)return 1;const r=e[0]/Tr,i=e[1]/Tr,s=e[2]/Tr;return hy*r+dy*i+py*s}function nl(n){return n<0?0:n>1?1:n}const pT=["ghost","glass"],mo=[...pT.map(n=>`[variant="${n}"]`),'[material="glass"]'].join(", "),rl=new WeakSet,Pg=new WeakSet;function my(n){if(Pg.has(n))return;Pg.add(n);for(const e of n.querySelectorAll(mo))Ru(e);if(typeof MutationObserver!="function")return;new MutationObserver(e=>{for(const r of e)if(r.type==="childList")for(const i of r.addedNodes)fT(i,Ru);else r.type==="attributes"&&r.target instanceof HTMLElement&&r.target.matches(mo)&&Ru(r.target)}).observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["variant","material"]})}function fT(n,t){if(n instanceof Element){n instanceof HTMLElement&&n.matches(mo)&&t(n);for(const e of n.querySelectorAll(mo))t(e)}}async function Ru(n){var e,r;if(rl.has(n)||n.hasAttribute("tone")||(e=n.parentElement)!=null&&e.closest("[tone]"))return;rl.add(n);const t=await fy(n);if(!n.matches(mo)){rl.delete(n);return}if(n.hasAttribute("tone")||(r=n.parentElement)!=null&&r.closest("[tone]")){rl.delete(n);return}n.setAttribute("tone",t)}const gT="*,*: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)}',Kd=new CSSStyleSheet;Kd.replaceSync(gT);const Jd=new CSSStyleSheet;try{document.adoptedStyleSheets=[...document.adoptedStyleSheets,Kd,Jd]}catch{}my(document);function vy(n){Jd.replaceSync(n)}function Vl(){vy("")}function Xd(n){try{n.adoptedStyleSheets=[...n.adoptedStyleSheets,Kd,Jd]}catch{}my(n)}const mT=new Set(["target","currentTarget","eventPhase","defaultPrevented","isTrusted","timeStamp","srcElement","returnValue","cancelBubble","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","composedPath","stopPropagation","stopImmediatePropagation","preventDefault","initEvent"]);function vT(n){for(const t of Object.keys(n))if(mT.has(t))throw new Error(`Event payload key "${t}" is reserved; choose a different property name`)}function yT(n,t){vT(t);for(const e of Object.keys(t))Object.defineProperty(n,e,{value:t[e],writable:!0,enumerable:!0,configurable:!0})}function Be(){class n extends Event{constructor(e,r){const{type:i,bubbles:s,cancelable:o,composed:a,...c}=r??{};if(i!==void 0)throw new Error('Do not pass "type" in init; use the constructor argument instead');super(e,{bubbles:s,cancelable:o,composed:a}),yT(this,c)}}return n}class Nt extends globalThis.EventTarget{}function bT(n,t,e){const r=n.dispose.bind(n);n.dispose=()=>{if(!t())return e(),r()}}function Ma(n){var e;class t extends n{constructor(...s){super(...s);w(this,e,!1);bT(this,()=>l(this,e),()=>{b(this,e,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return l(this,e)}}return e=new WeakMap,t}const wT=Be(),ST=Be(),_T=Be(),qs=Be(),yy=Be(),kT=Be(),Pu=Be(),Ye=4,ft=6,vo=2,ph=2,Qd=8,xT=ft,ep="auto",ir="auto",Hn=128,Lg=50,ae=16,Qr=Hn*Ye+ae*(Ye-1),yo=Hn*ft+ae*(ft-1),ET=Qr+ae*2,AT=200,TT=4,il=150,$T=10,Dg=2,zg=8,IT=300,CT=4;function by(n){return _y(n)}function wy(n,t){return _y(n.flatMap(e=>xy(e,t)))}function Sy(n){const t=[],e=new Set;for(const r of n){if(r.type==="row"){t.push(`Top-level rows are invalid: ${r.id}`);continue}Ey(r,"strip",t,e)}return{valid:t.length===0,errors:t}}function $r(n){const t=by(n),e=Sy(t);if(!e.valid)throw new Error(`Invalid layout: ${e.errors.join("; ")}`);return{totalNodes:t.length,nodes:t.filter(r=>r.type!=="row").map(DT)}}function _y(n){const t=[];for(const e of n){const r=ky(e);for(const i of r){if(i.type==="row"){t.push(...i.children.map(Pn));continue}t.push(i)}}return t}function ky(n){switch(n.type){case"card":return[Pn(n)];case"row":{const t=n.children.map(Pn);return t.length===0?[]:t.length===1?[t[0]]:[{...n,children:t}]}case"stack":{const t=[];for(const e of n.children){const r=ky(e);for(const i of r){if(i.type==="stack"){t.push(...i.children.map(fh));continue}if(i.type==="row"){t.push({...i,children:i.children.map(Pn)});continue}t.push(Pn(i))}}return t.length===0?[]:t.length===1?[fh(t[0])]:[{...n,children:t}]}}}function xy(n,t){switch(n.type){case"card":return n.artifactID===t?[]:[Pn(n)];case"row":{const e=n.children.filter(r=>r.artifactID!==t).map(Pn);return e.length===0?[]:e.length===1?[e[0]]:[{...n,children:e}]}case"stack":{const e=n.children.flatMap(r=>xy(r,t).filter(s=>s.type!=="stack"));return e.length===0?[]:e.length===1?[fh(e[0])]:[{...n,children:e}]}}}function Ey(n,t,e,r){switch(n.type){case"card":Ay(n,t,e,r);return;case"row":RT(n,t,e,r);return;case"stack":PT(n,t,e,r);return}}function Ay(n,t,e,r){"id"in n&&e.push(`Card ${Ns(n)} must not include id`),typeof n.artifactID!="string"||n.artifactID.length===0?e.push("Card is missing artifactID"):r.has(n.artifactID)?e.push(`Duplicate artifactID in layout: ${n.artifactID}`):r.add(n.artifactID),LT(n.width)||e.push(`Card ${Ns(n)} width must be an integer in the range ${vo}-${Qd}`),$y(n.height)||e.push(`Card ${Ns(n)} height must be an integer in the range 2-6 or "auto"`);const i=Li(n.width);t==="stack"&&i!==Ye&&e.push(`Stack child ${Ns(n)} width must be ${Ye}`),t==="row"&&i<vo&&e.push(`Row child ${Ns(n)} must be at least 2 columns wide`)}function Ns(n){return typeof n.artifactID=="string"&&n.artifactID.length>0?n.artifactID:"<missing artifactID>"}function RT(n,t,e,r){if(Ty(n.id,e),t!=="stack"&&e.push(`Row ${n.id} may only appear inside a stack`),$y(n.height,CT)||e.push(`Row ${n.id} height must be an integer in the range 2-4 or "auto"`),!Array.isArray(n.children)||n.children.length===0){e.push(`Row ${n.id} must contain card nodes`);return}let i=0;for(const s of n.children){if(s.type!=="card"){e.push(`Row ${n.id} must contain only card nodes`);continue}Ay(s,"row",e,r),i+=Li(s.width)}i!==Ye&&e.push(`Row ${n.id} children must sum to 4 columns`)}function PT(n,t,e,r){if(Ty(n.id,e),t!=="strip"&&e.push(`Invalid nested stack at ${n.id}; stack children cannot contain another nested stack`),!Array.isArray(n.children)||n.children.length===0){e.push(`Stack ${n.id} must contain at least one child`);return}let i=0,s=0;for(const a of n.children){if(a.type==="stack"){e.push(`Stack ${n.id} cannot contain another nested stack`);continue}if(Ey(a,"stack",e,r),a.height===ir){s+=1;continue}i+=a.height}if(i>ft&&e.push(`Stack ${n.id} exceeds the 6-row budget`),s===0)return;const o=ft-i;if(o<s*ph||o%s!==0){e.push(`Stack ${n.id} has auto-height children that cannot resolve to whole height >= 2`);return}o/s<ph&&e.push(`Stack ${n.id} has auto-height children below the minimum row size`)}function Ty(n,t){(typeof n!="string"||n.length===0)&&t.push(`Node id must be a non-empty string: ${String(n)}`)}function LT(n){return n===ep||Number.isInteger(n)&&n>=vo&&n<=Qd}function $y(n,t=xT){return n===ir||Number.isInteger(n)&&n>=ph&&n<=t}function Li(n){return n===ep?Ye:n}function DT(n){if(n.type==="card")return{id:n.artifactID,type:"card",width:Li(n.width),cards:[{id:n.artifactID,artifactID:n.artifactID,col:1,row:1,width:Li(n.width),height:Iy(n.height,ft)}]};const t=zT(n.children),e=[];let r=1;for(let i=0;i<n.children.length;i+=1){const s=n.children[i],o=t[i];if(s.type==="card")e.push({id:s.artifactID,artifactID:s.artifactID,col:1,row:r,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:r,width:Li(c.width),height:o}),a+=Li(c.width)}r+=o}return{id:n.id,type:"stack",width:e.reduce((i,s)=>Math.max(i,s.col+s.width-1),1),cards:e}}function zT(n){let t=0,e=0;for(const i of n)i.height===ir?e+=1:t+=i.height;const r=e>0?(ft-t)/e:0;return n.map(i=>Iy(i.height,r))}function Iy(n,t){return n===ir?t:n}function Pn(n){return{...n}}function fh(n){return n.type==="card"?Pn(n):{...n,children:n.children.map(Pn)}}const OT="X-Television-Client-Meta",MT="telemetry-activity";function Cy(n,t={}){return{type:"card",artifactID:n,width:t.width??ep,height:t.height??ir}}function _l(n){return n.layout.flatMap(Ry)}function Ry(n){switch(n.type){case"card":return[n.artifactID];case"row":return n.children.map(t=>t.artifactID);case"stack":return n.children.flatMap(Ry)}}const oe=Be(),gh=Be(),wi=Be(),Og=Be();function NT(n){class t extends Error{constructor(r,i){super(r),this.name=n,i&&Object.assign(this,i)}}return t}const tp=NT("RequestError"),UT=200,FT=300,sl=401;class HT{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,r){var o;const i=await this.request(t,e,r!==void 0?JSON.stringify(r):void 0,r!==void 0?{"content-type":"application/json"}:void 0),s=await ZT(i);if(!i.ok||i.status<UT||i.status>=FT)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,r){var s;const i=await this.request(t,e,r!==void 0?JSON.stringify(r):void 0,r!==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 Lu(i,i.statusText),i.status)}async requestText(t,e){var i;const r=await this.request(t,e);if(!r.ok)throw r.status===sl&&((i=this.onUnauthorized)==null||i.call(this)),this.createError(await Lu(r,r.statusText),r.status);return r.text()}async requestRawVoid(t,e,r){var s;const i=await this.request(t,e,r,{"content-type":"text/markdown; charset=utf-8"});if(!i.ok)throw i.status===sl&&((s=this.onUnauthorized)==null||s.call(this)),this.createError(await Lu(i,i.statusText),i.status)}createError(t,e){const r={serverURL:this.serverURL};return e!==void 0&&(r.status=e),new tp(t,r)}async request(t,e,r,i){const s=`${this.serverURL}${e}`;try{return await fetch(s,{method:t,headers:this.buildHeaders(i),body:r})}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[OT]=JSON.stringify(this.telemetryMeta)),Object.keys(e).length>0?e:void 0}}async function ZT(n){try{return await n.json()}catch{const t=await n.text().catch(()=>"");return t?{message:t}:{}}}async function Lu(n,t){try{const e=await n.json();if(typeof e.error=="string")return e.error;if(typeof e.message=="string")return e.message}catch{}return t}function WT(n){return n.map(t=>`${t.name} (${t.id})`).join(", ")}var jt,ic,Py;class VT{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,...r}=t;return l(this,jt).requestJSON("PATCH",`/screens/${encodeURIComponent(e)}`,r)}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: ${WT(e)}`)};var _n;class BT{constructor(t){w(this,_n);b(this,_n,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,_n).requestJSON("POST","/artifacts",e)}list(t={}){const e=new URLSearchParams;t.screenID!==void 0&&e.set("screenID",t.screenID);const r=e.toString();return l(this,_n).requestJSON("GET",r?`/artifacts?${r}`:"/artifacts")}get(t){return l(this,_n).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,_n).requestJSON("PATCH",`/artifacts/${encodeURIComponent(t.artifactID)}`,e)}delete(t){return l(this,_n).requestJSON("DELETE",`/artifacts/${encodeURIComponent(t.artifactID)}`)}}_n=new WeakMap;var Hi;class jT{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 Rr;class GT{constructor(t){w(this,Rr);b(this,Rr,t)}status(){return l(this,Rr).requestJSON("GET","/telemetry")}enable(){return l(this,Rr).requestJSON("POST","/telemetry/enable")}disable(){return l(this,Rr).requestJSON("POST","/telemetry/disable")}}Rr=new WeakMap;var Pr;class qT{constructor(t){w(this,Pr);b(this,Pr,t)}get(){return l(this,Pr).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,Pr).requestVoid("PATCH","/display",e)}focus(t){return l(this,Pr).requestJSON("POST","/display/focus",{artifactID:t.artifactID})}}Pr=new WeakMap;var Gt;class YT{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 HT(t,e)),this.screens=new VT(l(this,Gt)),this.artifacts=new BT(l(this,Gt)),this.display=new qT(l(this,Gt)),this.markdown=new jT(l(this,Gt)),this.telemetry=new GT(l(this,Gt))}health(){return l(this,Gt).requestJSON("GET","/health")}}Gt=new WeakMap;const KT={focusCommandInput:{label:"Focus Command Input",trigger:{key:"k",meta:!0}}},JT="Local",XT="store-";function he(n){return new URL(n).origin}function QT(n){return{servers:[{url:he(n),name:JT}],activeServerURL:null,activeScreenID:null,tabs:{},screens:{},authTokens:{}}}function e$(n,t){return[...n.tabs[he(t)]??[]]}function t$(n,t,e){const r=he(t),i=n.tabs[r]??[];return i.includes(e)?n:{...n,tabs:{...n.tabs,[r]:[...i,e]}}}function n$(n,t,e){const r=he(t),i=n.tabs[r]??[],s=i.filter(a=>a!==e);if(s.length===i.length)return n;const o={...n.tabs};return s.length===0?delete o[r]:o[r]=s,{...n,tabs:o}}function r$(n,t,e=Date.now()){const r=n.screens[t]??{scrollPosition:0};return{...n,screens:{...n.screens,[t]:{...r,lastActivatedAt:e}}}}var Lr,Dr,zr;class i$ extends Nt{constructor(e,r,i={}){super();w(this,Lr);w(this,Dr);w(this,zr);b(this,Lr,`${XT}${e}`),b(this,Dr,i.storage??a$());const s=l(this,Dr).getItem(l(this,Lr));s===null?(b(this,zr,r),l(this,Dr).setItem(l(this,Lr),JSON.stringify(r))):b(this,zr,l$(JSON.parse(s),r))}get(){return l(this,zr)}set(e){b(this,zr,e),l(this,Dr).setItem(l(this,Lr),JSON.stringify(e)),this.dispatchEvent(new oe("change"))}}Lr=new WeakMap,Dr=new WeakMap,zr=new WeakMap;function Du(n,t){return n.authTokens[he(t)]??null}function s$(n,t,e){return{...n,authTokens:{...n.authTokens,[he(t)]:e}}}function o$(n,t){const e=he(t);if(!(e in n.authTokens))return n;const r={...n.authTokens};return delete r[e],{...n,authTokens:r}}function a$(){const n=globalThis.localStorage;if(!n)throw new Error("LocalStore: no storage adapter supplied and window.localStorage is unavailable");return n}function l$(n,t){return{servers:Array.isArray(n.servers)?n.servers:t.servers,activeServerURL:typeof n.activeServerURL=="string"||n.activeServerURL===null?n.activeServerURL:t.activeServerURL,activeScreenID:typeof n.activeScreenID=="string"||n.activeScreenID===null?n.activeScreenID:t.activeScreenID,tabs:n.tabs&&typeof n.tabs=="object"?n.tabs:t.tabs,screens:n.screens&&typeof n.screens=="object"?n.screens:t.screens,authTokens:n.authTokens&&typeof n.authTokens=="object"?n.authTokens:t.authTokens}}class c$ extends Event{constructor(){super("theme-changed")}}const u$=Ma(Nt);var Or,Ne,Wn,Ge,Vn,kn,Eo,ee,Sr,Ly,Ao,Dy,zy,Oy,My,mh,vh,yh,Ny;class h$ extends u${constructor(e){var i;super();w(this,ee);g(this,"id");g(this,"server");w(this,Or);w(this,Ne,new Map);w(this,Wn);w(this,Ge);w(this,Vn);w(this,kn,null);w(this,Eo,0);w(this,Ao,e=>{if(this.disposed)return;const r=e.event;switch(r.type){case"screen-updated":r.screen.id===this.id&&p(this,ee,Dy).call(this,r.screen);break;case"artifact-created":r.screenID===this.id&&p(this,ee,zy).call(this,r.artifact);break;case"artifact-updated":p(this,ee,Oy).call(this,r.artifact);break;case"artifact-removed":r.screenID===this.id&&p(this,ee,My).call(this,r.artifactID);break;case"artifact-content-changed":l(this,Ne).has(r.artifactID)&&this.dispatchEvent(new Og("artifact-content-changed",{artifactID:r.artifactID}));break;case"theme-changed":this.dispatchEvent(new c$);break}});this.id=e.screen.id,this.server=e.server,b(this,Or,e.localStore),b(this,Wn,e.screen.name),b(this,Ge,structuredClone(e.screen.layout));const r=((i=l(this,Or).get().screens[this.id])==null?void 0:i.scrollPosition)??0;b(this,Vn,Math.max(0,r)),this.server.addEventListener("server-event",l(this,Ao)),p(this,ee,Ly).call(this)}get name(){return l(this,Wn)}get layout(){return l(this,Ge)}get scrollPosition(){return l(this,Vn)}get artifacts(){return l(this,Ne)}setScrollPosition(e){p(this,ee,Sr).call(this);const r=Math.max(0,e);r!==l(this,Vn)&&(b(this,Vn,r),p(this,ee,Ny).call(this),this.dispatchEvent(new oe("change")))}setLayout(e){p(this,ee,Sr).call(this);const r=by(e);if(!Sy(r).valid)return;const s=p(this,ee,vh).call(this);b(this,Ge,r),b(this,kn,{layout:r,snapshot:s}),this.dispatchEvent(new oe("change")),this.server.client.screens.update({screenID:this.id,layout:r.map(o=>structuredClone(o))}).catch(()=>{var o;this.disposed||((o=l(this,kn))==null?void 0:o.layout)===r&&(b(this,kn,null),p(this,ee,yh).call(this,s),this.dispatchEvent(new oe("change")))})}rename(e){p(this,ee,Sr).call(this),b(this,Wn,e),this.dispatchEvent(new oe("change")),this.server.client.screens.update({screenID:this.id,name:e}).catch(()=>{})}async remove(){p(this,ee,Sr).call(this),await this.server.client.screens.remove({screenID:this.id})}removeArtifact(e){if(p(this,ee,Sr).call(this),!l(this,Ne).has(e))return;const r=p(this,ee,vh).call(this);p(this,ee,mh).call(this,e),this.dispatchEvent(new oe("change")),this.server.client.artifacts.delete({artifactID:e}).catch(()=>{this.disposed||(p(this,ee,yh).call(this,r),this.dispatchEvent(new oe("change")))})}async refreshFromServer(){p(this,ee,Sr).call(this);const e=++iu(this,Eo)._;let r;try{r=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,kn,null),b(this,Wn,r.screen.name),b(this,Ge,structuredClone(r.screen.layout)),l(this,Ne).clear();for(const s of r.artifacts)l(this,Ne).set(s.id,s);this.dispatchEvent(new oe("change"));for(const s of r.artifacts)s.kind==="path"&&i.has(s.id)&&this.dispatchEvent(new Og("artifact-content-changed",{artifactID:s.id}))}dispose(){this.server.removeEventListener("server-event",l(this,Ao))}}Or=new WeakMap,Ne=new WeakMap,Wn=new WeakMap,Ge=new WeakMap,Vn=new WeakMap,kn=new WeakMap,Eo=new WeakMap,ee=new WeakSet,Sr=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 r of e.artifacts)l(this,Ne).set(r.id,r);this.dispatchEvent(new oe("change"))}catch{}},Ao=new WeakMap,Dy=function(e){l(this,kn)&&b(this,kn,null),b(this,Wn,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 r=l(this,Ne).get(e.id);r&&(l(this,Ne).set(e.id,{...r,...e}),this.dispatchEvent(new oe("change")))},My=function(e){p(this,ee,mh).call(this,e)&&this.dispatchEvent(new oe("change"))},mh=function(e){const r=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),r||i!==o},vh=function(){return{layout:structuredClone(l(this,Ge)),artifacts:new Map([...l(this,Ne).entries()].map(([e,r])=>[e,structuredClone(r)]))}},yh=function(e){b(this,Ge,structuredClone(e.layout)),l(this,Ne).clear();for(const[r,i]of e.artifacts)l(this,Ne).set(r,structuredClone(i))},Ny=function(){const e=l(this,Or).get();l(this,Or).set({...e,screens:{...e.screens,[this.id]:{...e.screens[this.id],scrollPosition:l(this,Vn)}}})};const d$=Ma(Nt);var Pe,Ue,$t,To,$o,Io,Co,Qe,kl,bh,xi;class p$ extends d${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 r=e.event;if(r.type==="screen-removed"){this.removeTab(e.serverURL,r.screenID);const i=l(this,Pe).get();i.activeServerURL===he(e.serverURL)&&i.activeScreenID===r.screenID&&p(this,Qe,xi).call(this,e.serverURL,null);return}if(r.type==="screen-changed"){if(r.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(r.screenID))return;this.addTab(e.serverURL,r.screenID),p(this,Qe,xi).call(this,e.serverURL,r.screenID)}});w(this,Co,e=>{if(this.disposed)return;const r=l(this,$t);r&&he(e.serverURL)===he(r.server.url)&&r.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,r=[];let i=0;for(const s of l(this,Ue).servers.values())for(const o of s.screens.values())r.push({server:s,screen:o,local:e[o.id]??{scrollPosition:0},index:i}),i+=1;return r.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 r=he(e),i=e$(l(this,Pe).get(),r),s=l(this,Ue).servers.get(r);return s?i.filter(o=>s.screens.has(o)):i}hasTab(e,r){return this.getTabs(e).includes(r)}addTab(e,r){const i=he(e),s=l(this,Ue).servers.get(i);s&&!s.screens.has(r)||p(this,Qe,bh).call(this,t$(l(this,Pe).get(),i,r))}removeTab(e,r){p(this,Qe,bh).call(this,n$(l(this,Pe).get(),e,r))}setActive(e,r){const i=he(e),s=l(this,Ue).servers.get(i);!s||!s.screens.has(r)||p(this,Qe,xi).call(this,i,r)&&s.client.display.patch({activeScreenID:r}).catch(()=>{})}clearActive(){const e=l(this,Pe).get().activeServerURL;if(!e||!p(this,Qe,xi).call(this,e,null))return;const r=l(this,Ue).servers.get(e);r==null||r.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:r}=l(this,Pe).get(),i=e?l(this,Ue).servers.get(e)??null:null,s=i&&r?i.screens.get(r)??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 h$({screen:s,server:i,localStore:l(this,Pe)}):null),i&&i.acpClient.setScreenContext(s?{screenID:s.id,screenName:s.name}:null),this.dispatchEvent(new wT("active-screen-changed")))},bh=function(e){e!==l(this,Pe).get()&&(l(this,Pe).set(e),this.dispatchEvent(new ST("tabs-changed")))},xi=function(e,r){const i=he(e),s=l(this,Pe).get();if(s.activeServerURL===i&&s.activeScreenID===r)return!1;const o=r===null?{...s,activeServerURL:i,activeScreenID:r}:r$({...s,activeServerURL:i,activeScreenID:r},r);return l(this,Pe).set(o),!0};const Uy="0123456789ABCDEFGHJKMNPQRSTVWXYZ",Bl=32,f$=16,Fy=10,Mg=0xffffffffffff;var Ir;(function(n){n.Base32IncorrectEncoding="B32_ENC_INVALID",n.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",n.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",n.EncodeTimeNegative="ENC_TIME_NEG",n.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",n.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",n.PRNGDetectFailure="PRNG_DETECT",n.ULIDInvalid="ULID_INVALID",n.Unexpected="UNEXPECTED",n.UUIDInvalid="UUID_INVALID"})(Ir||(Ir={}));class Ys extends Error{constructor(t,e){super(`${e} (${t})`),this.name="ULIDError",this.code=t}}function g$(n){const t=Math.floor(n()*Bl)%Bl;return Uy.charAt(t)}function m$(n){const t=v$(),e=t&&(t.crypto||t.msCrypto)||null;if(typeof(e==null?void 0:e.getRandomValues)=="function")return()=>{const r=new Uint8Array(1);return e.getRandomValues(r),r[0]/256};if(typeof(e==null?void 0:e.randomBytes)=="function")return()=>e.randomBytes(1).readUInt8()/256;throw new Ys(Ir.PRNGDetectFailure,"Failed to find a reliable PRNG")}function v$(){return w$()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function y$(n,t){let e="";for(;n>0;n--)e=g$(t)+e;return e}function b$(n,t=Fy){if(isNaN(n))throw new Ys(Ir.EncodeTimeValueMalformed,`Time must be a number: ${n}`);if(n>Mg)throw new Ys(Ir.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${Mg}: ${n}`);if(n<0)throw new Ys(Ir.EncodeTimeNegative,`Time must be positive: ${n}`);if(Number.isInteger(n)===!1)throw new Ys(Ir.EncodeTimeValueMalformed,`Time must be an integer: ${n}`);let e,r="";for(let i=t;i>0;i--)e=n%Bl,r=Uy.charAt(e)+r,n=(n-e)/Bl;return r}function w$(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Cc(n,t){const e=m$(),r=Date.now();return b$(r,Fy)+y$(f$,e)}function A(n,t,e){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(n))return;a._zod.traits.add(n),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:n});function o(a){var c;const u=e!=null&&e.Parent?new s:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const h of u._zod.deferred)h();return u}return Object.defineProperty(o,"init",{value:r}),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(n)}}),Object.defineProperty(o,"name",{value:n}),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 sr(n){return Zy}function Wy(n){const t=Object.values(n).filter(r=>typeof r=="number");return Object.entries(n).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function wh(n,t){return typeof t=="bigint"?t.toString():t}function Rc(n){return{get value(){{const t=n();return Object.defineProperty(this,"value",{value:t}),t}}}}function np(n){return n==null}function rp(n){const t=n.startsWith("^")?1:0,e=n.endsWith("$")?n.length-1:n.length;return n.slice(t,e)}function S$(n,t){const e=(n.toString().split(".")[1]||"").length,r=t.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c!=null&&c[1]&&(i=Number.parseInt(c[1]))}const s=e>i?e:i,o=Number.parseInt(n.toFixed(s).replace(".","")),a=Number.parseInt(t.toFixed(s).replace(".",""));return o%a/10**s}const Ng=Symbol("evaluating");function te(n,t,e){let r;Object.defineProperty(n,t,{get(){if(r!==Ng)return r===void 0&&(r=Ng,r=e()),r},set(i){Object.defineProperty(n,t,{value:i})},configurable:!0})}function li(n,t,e){Object.defineProperty(n,t,{value:e,writable:!0,enumerable:!0,configurable:!0})}function hr(...n){const t={};for(const e of n){const r=Object.getOwnPropertyDescriptors(e);Object.assign(t,r)}return Object.defineProperties({},t)}function Ug(n){return JSON.stringify(n)}function _$(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Vy="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function bo(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const k$=Rc(()=>{var n;if(typeof navigator<"u"&&((n=navigator==null?void 0:navigator.userAgent)!=null&&n.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function gs(n){if(bo(n)===!1)return!1;const t=n.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(n){return gs(n)?{...n}:Array.isArray(n)?[...n]:n}const x$=new Set(["string","number","symbol"]);function ms(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function dr(n,t,e){const r=new n._zod.constr(t??n._zod.def);return(!t||e!=null&&e.parent)&&(r._zod.parent=n),r}function O(n){const t=n;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 E$(n){return Object.keys(n).filter(t=>n[t]._zod.optin==="optional"&&n[t]._zod.optout==="optional")}const A$={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 T$(n,t){const e=n._zod.def,r=e.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=hr(n._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 dr(n,s)}function $$(n,t){const e=n._zod.def,r=e.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=hr(n._zod.def,{get shape(){const o={...n._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 dr(n,s)}function I$(n,t){if(!gs(t))throw new Error("Invalid input to extend: expected a plain object");const e=n._zod.def.checks;if(e&&e.length>0){const s=n._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=hr(n._zod.def,{get shape(){const s={...n._zod.def.shape,...t};return li(this,"shape",s),s}});return dr(n,i)}function C$(n,t){if(!gs(t))throw new Error("Invalid input to safeExtend: expected a plain object");const e=hr(n._zod.def,{get shape(){const r={...n._zod.def.shape,...t};return li(this,"shape",r),r}});return dr(n,e)}function R$(n,t){const e=hr(n._zod.def,{get shape(){const r={...n._zod.def.shape,...t._zod.def.shape};return li(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return dr(n,e)}function P$(n,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=hr(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]=n?new n({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=n?new n({type:"optional",innerType:a[u]}):a[u];return li(this,"shape",c),c},checks:[]});return dr(t,o)}function L$(n,t,e){const r=hr(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 n({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new n({type:"nonoptional",innerType:i[o]});return li(this,"shape",s),s}});return dr(t,r)}function Di(n,t=0){var e;if(n.aborted===!0)return!0;for(let r=t;r<n.issues.length;r++)if(((e=n.issues[r])==null?void 0:e.continue)!==!0)return!0;return!1}function zi(n,t){return t.map(e=>{var r;return(r=e).path??(r.path=[]),e.path.unshift(n),e})}function ol(n){return typeof n=="string"?n:n==null?void 0:n.message}function or(n,t,e){var i,s,o,a,c,u;const r={...n,path:n.path??[]};if(!n.message){const h=ol((o=(s=(i=n.inst)==null?void 0:i._zod.def)==null?void 0:s.error)==null?void 0:o.call(s,n))??ol((a=t==null?void 0:t.error)==null?void 0:a.call(t,n))??ol((c=e.customError)==null?void 0:c.call(e,n))??ol((u=e.localeError)==null?void 0:u.call(e,n))??"Invalid input";r.message=h}return delete r.inst,delete r.continue,t!=null&&t.reportInput||delete r.input,r}function ip(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function wo(...n){const[t,e,r]=n;return typeof t=="string"?{message:t,code:"custom",input:e,inst:r}:{...t}}const jy=(n,t)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:t,enumerable:!1}),n.message=JSON.stringify(t,wh,2),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},Gy=A("$ZodError",jy),qy=A("$ZodError",jy,{Parent:Error});function D$(n,t=e=>e.message){const e={},r=[];for(const i of n.issues)i.path.length>0?(e[i.path[0]]=e[i.path[0]]||[],e[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:e}}function z$(n,t=e=>e.message){const e={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>r({issues:o}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)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 r(n),e}const sp=n=>(t,e,r,i)=>{const s=r?Object.assign(r,{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)??n)(o.issues.map(c=>or(c,s,sr())));throw Vy(a,i==null?void 0:i.callee),a}return o.value},op=n=>async(t,e,r,i)=>{const s=r?Object.assign(r,{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)??n)(o.issues.map(c=>or(c,s,sr())));throw Vy(a,i==null?void 0:i.callee),a}return o.value},Pc=n=>(t,e,r)=>{const i=r?{...r,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(n??Gy)(s.issues.map(o=>or(o,i,sr())))}:{success:!0,data:s.value}},O$=Pc(qy),Lc=n=>async(t,e,r)=>{const i=r?Object.assign(r,{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 n(s.issues.map(o=>or(o,i,sr())))}:{success:!0,data:s.value}},M$=Lc(qy),N$=n=>(t,e,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return sp(n)(t,e,i)},U$=n=>(t,e,r)=>sp(n)(t,e,r),F$=n=>async(t,e,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return op(n)(t,e,i)},H$=n=>async(t,e,r)=>op(n)(t,e,r),Z$=n=>(t,e,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Pc(n)(t,e,i)},W$=n=>(t,e,r)=>Pc(n)(t,e,r),V$=n=>async(t,e,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Lc(n)(t,e,i)},B$=n=>async(t,e,r)=>Lc(n)(t,e,r),j$=/^[cC][^\s-]{8,}$/,G$=/^[0-9a-z]+$/,q$=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Y$=/^[0-9a-vA-V]{20}$/,K$=/^[A-Za-z0-9]{27}$/,J$=/^[a-zA-Z0-9_-]{21}$/,X$=/^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})$/,Fg=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,eI=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,tI="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function nI(){return new RegExp(tI,"u")}const rI=/^(?:(?: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])$/,iI=/^(([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}|:))$/,sI=/^((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])$/,oI=/^(([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])$/,aI=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Yy=/^[A-Za-z0-9_-]*$/,lI=/^\+[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])))",cI=new RegExp(`^${Ky}$`);function Jy(n){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${t}`:n.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${n.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function uI(n){return new RegExp(`^${Jy(n)}$`)}function hI(n){const t=Jy({precision:n.precision}),e=["Z"];n.local&&e.push(""),n.offset&&e.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${e.join("|")})`;return new RegExp(`^${Ky}T(?:${r})$`)}const dI=n=>{const t=n?`[\\s\\S]{${(n==null?void 0:n.minimum)??0},${(n==null?void 0:n.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},pI=/^-?\d+$/,Xy=/^-?\d+(?:\.\d+)?$/,fI=/^(?:true|false)$/i,gI=/^[^A-Z]*$/,mI=/^[^a-z]*$/,ut=A("$ZodCheck",(n,t)=>{var e;n._zod??(n._zod={}),n._zod.def=t,(e=n._zod).onattach??(e.onattach=[])}),Qy={number:"number",bigint:"bigint",object:"date"},eb=A("$ZodCheckLessThan",(n,t)=>{ut.init(n,t);const e=Qy[typeof t.value];n._zod.onattach.push(r=>{const i=r._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)}),n._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:e,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:n,continue:!t.abort})}}),tb=A("$ZodCheckGreaterThan",(n,t)=>{ut.init(n,t);const e=Qy[typeof t.value];n._zod.onattach.push(r=>{const i=r._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)}),n._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:e,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:n,continue:!t.abort})}}),vI=A("$ZodCheckMultipleOf",(n,t)=>{ut.init(n,t),n._zod.onattach.push(e=>{var r;(r=e._zod.bag).multipleOf??(r.multipleOf=t.value)}),n._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):S$(e.value,t.value)===0)||e.issues.push({origin:typeof e.value,code:"not_multiple_of",divisor:t.value,input:e.value,inst:n,continue:!t.abort})}}),yI=A("$ZodCheckNumberFormat",(n,t)=>{var o;ut.init(n,t),t.format=t.format||"float64";const e=(o=t.format)==null?void 0:o.includes("int"),r=e?"int":"number",[i,s]=A$[t.format];n._zod.onattach.push(a=>{const c=a._zod.bag;c.format=t.format,c.minimum=i,c.maximum=s,e&&(c.pattern=pI)}),n._zod.check=a=>{const c=a.value;if(e){if(!Number.isInteger(c)){a.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:n});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:r,inclusive:!0,continue:!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:n,origin:r,inclusive:!0,continue:!t.abort});return}}c<i&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:n,continue:!t.abort}),c>s&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:n,continue:!t.abort})}}),bI=A("$ZodCheckMaxLength",(n,t)=>{var e;ut.init(n,t),(e=n._zod.def).when??(e.when=r=>{const i=r.value;return!np(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(r._zod.bag.maximum=t.maximum)}),n._zod.check=r=>{const i=r.value;if(i.length<=t.maximum)return;const o=ip(i);r.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),wI=A("$ZodCheckMinLength",(n,t)=>{var e;ut.init(n,t),(e=n._zod.def).when??(e.when=r=>{const i=r.value;return!np(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(r._zod.bag.minimum=t.minimum)}),n._zod.check=r=>{const i=r.value;if(i.length>=t.minimum)return;const o=ip(i);r.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),SI=A("$ZodCheckLengthEquals",(n,t)=>{var e;ut.init(n,t),(e=n._zod.def).when??(e.when=r=>{const i=r.value;return!np(i)&&i.length!==void 0}),n._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),n._zod.check=r=>{const i=r.value,s=i.length;if(s===t.length)return;const o=ip(i),a=s>t.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:n,continue:!t.abort})}}),Dc=A("$ZodCheckStringFormat",(n,t)=>{var e,r;ut.init(n,t),n._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=n._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:n,continue:!t.abort})}):(r=n._zod).check??(r.check=()=>{})}),_I=A("$ZodCheckRegex",(n,t)=>{Dc.init(n,t),n._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:n,continue:!t.abort})}}),kI=A("$ZodCheckLowerCase",(n,t)=>{t.pattern??(t.pattern=gI),Dc.init(n,t)}),xI=A("$ZodCheckUpperCase",(n,t)=>{t.pattern??(t.pattern=mI),Dc.init(n,t)}),EI=A("$ZodCheckIncludes",(n,t)=>{ut.init(n,t);const e=ms(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${e}`:e);t.pattern=r,n._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),n._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:n,continue:!t.abort})}}),AI=A("$ZodCheckStartsWith",(n,t)=>{ut.init(n,t);const e=new RegExp(`^${ms(t.prefix)}.*`);t.pattern??(t.pattern=e),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(e)}),n._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:n,continue:!t.abort})}}),TI=A("$ZodCheckEndsWith",(n,t)=>{ut.init(n,t);const e=new RegExp(`.*${ms(t.suffix)}$`);t.pattern??(t.pattern=e),n._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(e)}),n._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:n,continue:!t.abort})}}),$I=A("$ZodCheckOverwrite",(n,t)=>{ut.init(n,t),n._zod.check=e=>{e.value=t.tx(e.value)}});class II{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 r=t.split(`
5
- `).filter(o=>o),i=Math.min(...r.map(o=>o.length-o.trimStart().length)),s=r.map(o=>o.slice(i)).map(o=>" ".repeat(this.indent*2)+o);for(const o of s)this.content.push(o)}compile(){const 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 CI={major:4,minor:3,patch:6},ve=A("$ZodType",(n,t)=>{var i;var e;n??(n={}),n._zod.def=t,n._zod.bag=n._zod.bag||{},n._zod.version=CI;const r=[...n._zod.def.checks??[]];n._zod.traits.has("$ZodCheck")&&r.unshift(n);for(const s of r)for(const o of s._zod.onattach)o(n);if(r.length===0)(e=n._zod).deferred??(e.deferred=[]),(i=n._zod.deferred)==null||i.push(()=>{n._zod.run=n._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,r,u);if(h instanceof Promise){if(u.async===!1)throw new Ni;return h.then(f=>n._zod.parse(f,u))}return n._zod.parse(h,u)};n._zod.run=(a,c)=>{if(c.skipChecks)return n._zod.parse(a,c);if(c.direction==="backward"){const h=n._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=n._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new Ni;return u.then(h=>s(h,r,c))}return s(u,r,c)}}te(n,"~standard",()=>({validate:s=>{var o;try{const a=O$(n,s);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return M$(n,s).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),ap=A("$ZodString",(n,t)=>{var e;ve.init(n,t),n._zod.pattern=[...((e=n==null?void 0:n._zod.bag)==null?void 0:e.patterns)??[]].pop()??dI(n._zod.bag),n._zod.parse=(r,i)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:n}),r}}),ge=A("$ZodStringFormat",(n,t)=>{Dc.init(n,t),ap.init(n,t)}),RI=A("$ZodGUID",(n,t)=>{t.pattern??(t.pattern=Q$),ge.init(n,t)}),PI=A("$ZodUUID",(n,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Fg(r))}else t.pattern??(t.pattern=Fg());ge.init(n,t)}),LI=A("$ZodEmail",(n,t)=>{t.pattern??(t.pattern=eI),ge.init(n,t)}),DI=A("$ZodURL",(n,t)=>{ge.init(n,t),n._zod.check=e=>{try{const r=e.value.trim(),i=new URL(r);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:n,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:n,continue:!t.abort})),t.normalize?e.value=i.href:e.value=r;return}catch{e.issues.push({code:"invalid_format",format:"url",input:e.value,inst:n,continue:!t.abort})}}}),zI=A("$ZodEmoji",(n,t)=>{t.pattern??(t.pattern=nI()),ge.init(n,t)}),OI=A("$ZodNanoID",(n,t)=>{t.pattern??(t.pattern=J$),ge.init(n,t)}),MI=A("$ZodCUID",(n,t)=>{t.pattern??(t.pattern=j$),ge.init(n,t)}),NI=A("$ZodCUID2",(n,t)=>{t.pattern??(t.pattern=G$),ge.init(n,t)}),UI=A("$ZodULID",(n,t)=>{t.pattern??(t.pattern=q$),ge.init(n,t)}),FI=A("$ZodXID",(n,t)=>{t.pattern??(t.pattern=Y$),ge.init(n,t)}),HI=A("$ZodKSUID",(n,t)=>{t.pattern??(t.pattern=K$),ge.init(n,t)}),ZI=A("$ZodISODateTime",(n,t)=>{t.pattern??(t.pattern=hI(t)),ge.init(n,t)}),WI=A("$ZodISODate",(n,t)=>{t.pattern??(t.pattern=cI),ge.init(n,t)}),VI=A("$ZodISOTime",(n,t)=>{t.pattern??(t.pattern=uI(t)),ge.init(n,t)}),BI=A("$ZodISODuration",(n,t)=>{t.pattern??(t.pattern=X$),ge.init(n,t)}),jI=A("$ZodIPv4",(n,t)=>{t.pattern??(t.pattern=rI),ge.init(n,t),n._zod.bag.format="ipv4"}),GI=A("$ZodIPv6",(n,t)=>{t.pattern??(t.pattern=iI),ge.init(n,t),n._zod.bag.format="ipv6",n._zod.check=e=>{try{new URL(`http://[${e.value}]`)}catch{e.issues.push({code:"invalid_format",format:"ipv6",input:e.value,inst:n,continue:!t.abort})}}}),qI=A("$ZodCIDRv4",(n,t)=>{t.pattern??(t.pattern=sI),ge.init(n,t)}),YI=A("$ZodCIDRv6",(n,t)=>{t.pattern??(t.pattern=oI),ge.init(n,t),n._zod.check=e=>{const r=e.value.split("/");try{if(r.length!==2)throw new Error;const[i,s]=r;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${i}]`)}catch{e.issues.push({code:"invalid_format",format:"cidrv6",input:e.value,inst:n,continue:!t.abort})}}});function nb(n){if(n==="")return!0;if(n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}const KI=A("$ZodBase64",(n,t)=>{t.pattern??(t.pattern=aI),ge.init(n,t),n._zod.bag.contentEncoding="base64",n._zod.check=e=>{nb(e.value)||e.issues.push({code:"invalid_format",format:"base64",input:e.value,inst:n,continue:!t.abort})}});function JI(n){if(!Yy.test(n))return!1;const t=n.replace(/[-_]/g,r=>r==="-"?"+":"/"),e=t.padEnd(Math.ceil(t.length/4)*4,"=");return nb(e)}const XI=A("$ZodBase64URL",(n,t)=>{t.pattern??(t.pattern=Yy),ge.init(n,t),n._zod.bag.contentEncoding="base64url",n._zod.check=e=>{JI(e.value)||e.issues.push({code:"invalid_format",format:"base64url",input:e.value,inst:n,continue:!t.abort})}}),QI=A("$ZodE164",(n,t)=>{t.pattern??(t.pattern=lI),ge.init(n,t)});function eC(n,t=null){try{const e=n.split(".");if(e.length!==3)return!1;const[r]=e;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const tC=A("$ZodJWT",(n,t)=>{ge.init(n,t),n._zod.check=e=>{eC(e.value,t.alg)||e.issues.push({code:"invalid_format",format:"jwt",input:e.value,inst:n,continue:!t.abort})}}),rb=A("$ZodNumber",(n,t)=>{ve.init(n,t),n._zod.pattern=n._zod.bag.pattern??Xy,n._zod.parse=(e,r)=>{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:n,...s?{received:s}:{}}),e}}),nC=A("$ZodNumberFormat",(n,t)=>{yI.init(n,t),rb.init(n,t)}),rC=A("$ZodBoolean",(n,t)=>{ve.init(n,t),n._zod.pattern=fI,n._zod.parse=(e,r)=>{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:n}),e}}),iC=A("$ZodUnknown",(n,t)=>{ve.init(n,t),n._zod.parse=e=>e}),sC=A("$ZodNever",(n,t)=>{ve.init(n,t),n._zod.parse=(e,r)=>(e.issues.push({expected:"never",code:"invalid_type",input:e.value,inst:n}),e)});function Hg(n,t,e){n.issues.length&&t.issues.push(...zi(e,n.issues)),t.value[e]=n.value}const oC=A("$ZodArray",(n,t)=>{ve.init(n,t),n._zod.parse=(e,r)=>{const i=e.value;if(!Array.isArray(i))return e.issues.push({expected:"array",code:"invalid_type",input:i,inst:n}),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:[]},r);c instanceof Promise?s.push(c.then(u=>Hg(u,e,o))):Hg(c,e,o)}return s.length?Promise.all(s).then(()=>e):e}});function jl(n,t,e,r,i){if(n.issues.length){if(i&&!(e in r))return;t.issues.push(...zi(e,n.issues))}n.value===void 0?e in r&&(t.value[e]=void 0):t.value[e]=n.value}function ib(n){var r,i,s,o;const t=Object.keys(n.shape);for(const a of t)if(!((o=(s=(i=(r=n.shape)==null?void 0:r[a])==null?void 0:i._zod)==null?void 0:s.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const e=E$(n.shape);return{...n,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(e)}}function sb(n,t,e,r,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:[]},r);y instanceof Promise?n.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}),n.length?Promise.all(n).then(()=>e):e}const aC=A("$ZodObject",(n,t)=>{ve.init(n,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 r=Rc(()=>ib(t));te(n._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;n._zod.parse=(a,c)=>{o??(o=r.value);const u=a.value;if(!i(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:n}),a;a.value={};const 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,r.value,n):h.length?Promise.all(h).then(()=>a):a}}),lC=A("$ZodObjectJIT",(n,t)=>{aC.init(n,t);const e=n._zod.parse,r=Rc(()=>ib(t)),i=y=>{var V;const m=new II(["shape","payload","ctx"]),E=r.value,x=N=>{const H=Ug(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=Ug(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
- if (${Y} in input) {
9
- payload.issues = payload.issues.concat(${H}.issues.map(iss => ({
10
- ...iss,
11
- path: iss.path ? [${Y}, ...iss.path] : [${Y}]
12
- })));
13
- }
14
- }
15
-
16
- if (${H}.value === undefined) {
17
- if (${Y} in input) {
18
- newResult[${Y}] = undefined;
19
- }
20
- } else {
21
- newResult[${Y}] = ${H}.value;
22
- }
23
-
24
- `):m.write(`
25
- if (${H}.issues.length) {
26
- payload.issues = payload.issues.concat(${H}.issues.map(iss => ({
27
- ...iss,
28
- path: iss.path ? [${Y}, ...iss.path] : [${Y}]
29
- })));
30
- }
31
-
32
- if (${H}.value === undefined) {
33
- if (${Y} in input) {
34
- newResult[${Y}] = undefined;
35
- }
36
- } else {
37
- newResult[${Y}] = ${H}.value;
38
- }
39
-
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&&k$.value,h=t.catchall;let f;n._zod.parse=(y,m)=>{f??(f=r.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,n):y):e(y,m):(y.issues.push({expected:"object",code:"invalid_type",input:E,inst:n}),y)}});function Zg(n,t,e,r){for(const s of n)if(s.issues.length===0)return t.value=s.value,t;const i=n.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:n.map(s=>s.issues.map(o=>or(o,r,sr())))}),t)}const ob=A("$ZodUnion",(n,t)=>{ve.init(n,t),te(n._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),te(n._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),te(n._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),te(n._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=>rp(s.source)).join("|")})$`)}});const e=t.options.length===1,r=t.options[0]._zod.run;n._zod.parse=(i,s)=>{if(e)return r(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=>Zg(c,i,n,s)):Zg(a,i,n,s)}}),cC=A("$ZodDiscriminatedUnion",(n,t)=>{t.inclusive=!1,ob.init(n,t);const e=n._zod.parse;te(n._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 r=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});n._zod.parse=(i,s)=>{const o=i.value;if(!bo(o))return i.issues.push({code:"invalid_type",expected:"object",input:o,inst:n}),i;const a=r.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:n}),i)}}),uC=A("$ZodIntersection",(n,t)=>{ve.init(n,t),n._zod.parse=(e,r)=>{const i=e.value,s=t.left._zod.run({value:i,issues:[]},r),o=t.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([c,u])=>Wg(e,c,u)):Wg(e,s,o)}});function Sh(n,t){if(n===t)return{valid:!0,data:n};if(n instanceof Date&&t instanceof Date&&+n==+t)return{valid:!0,data:n};if(gs(n)&&gs(t)){const e=Object.keys(t),r=Object.keys(n).filter(s=>e.indexOf(s)!==-1),i={...n,...t};for(const s of r){const o=Sh(n[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(n)&&Array.isArray(t)){if(n.length!==t.length)return{valid:!1,mergeErrorPath:[]};const e=[];for(let r=0;r<n.length;r++){const i=n[r],s=t[r],o=Sh(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};e.push(o.data)}return{valid:!0,data:e}}return{valid:!1,mergeErrorPath:[]}}function Wg(n,t,e){const r=new Map;let i;for(const a of t.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else n.issues.push(a);for(const a of e.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else n.issues.push(a);const s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&i&&n.issues.push({...i,keys:s}),Di(n))return n;const o=Sh(t.value,e.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return n.value=o.data,n}const hC=A("$ZodRecord",(n,t)=>{ve.init(n,t),n._zod.parse=(e,r)=>{const i=e.value;if(!gs(i))return e.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),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:[]},r);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:n,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:[]},r);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:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(c=f)}if(c.issues.length){t.mode==="loose"?e.value[a]=i[a]:e.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(f=>or(f,r,sr())),input:a,path:[a],inst:n});continue}const h=t.valueType._zod.run({value:i[a],issues:[]},r);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}}),dC=A("$ZodEnum",(n,t)=>{ve.init(n,t);const e=Wy(t.entries),r=new Set(e);n._zod.values=r,n._zod.pattern=new RegExp(`^(${e.filter(i=>x$.has(typeof i)).map(i=>typeof i=="string"?ms(i):i.toString()).join("|")})$`),n._zod.parse=(i,s)=>{const o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:e,input:o,inst:n}),i}}),pC=A("$ZodLiteral",(n,t)=>{if(ve.init(n,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const e=new Set(t.values);n._zod.values=e,n._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?ms(r):r?ms(r.toString()):String(r)).join("|")})$`),n._zod.parse=(r,i)=>{const s=r.value;return e.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:n}),r}}),fC=A("$ZodTransform",(n,t)=>{ve.init(n,t),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new Hy(n.constructor.name);const i=t.transform(e.value,e);if(r.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 Vg(n,t){return n.issues.length&&t===void 0?{issues:[],value:void 0}:n}const ab=A("$ZodOptional",(n,t)=>{ve.init(n,t),n._zod.optin="optional",n._zod.optout="optional",te(n._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),te(n._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${rp(e.source)})?$`):void 0}),n._zod.parse=(e,r)=>{if(t.innerType._zod.optin==="optional"){const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>Vg(s,e.value)):Vg(i,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,r)}}),gC=A("$ZodExactOptional",(n,t)=>{ab.init(n,t),te(n._zod,"values",()=>t.innerType._zod.values),te(n._zod,"pattern",()=>t.innerType._zod.pattern),n._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),mC=A("$ZodNullable",(n,t)=>{ve.init(n,t),te(n._zod,"optin",()=>t.innerType._zod.optin),te(n._zod,"optout",()=>t.innerType._zod.optout),te(n._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${rp(e.source)}|null)$`):void 0}),te(n._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),n._zod.parse=(e,r)=>e.value===null?e:t.innerType._zod.run(e,r)}),vC=A("$ZodDefault",(n,t)=>{ve.init(n,t),n._zod.optin="optional",te(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);if(e.value===void 0)return e.value=t.defaultValue,e;const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>Bg(s,t)):Bg(i,t)}});function Bg(n,t){return n.value===void 0&&(n.value=t.defaultValue),n}const yC=A("$ZodPrefault",(n,t)=>{ve.init(n,t),n._zod.optin="optional",te(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>(r.direction==="backward"||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,r))}),bC=A("$ZodNonOptional",(n,t)=>{ve.init(n,t),te(n._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(r=>r!==void 0)):void 0}),n._zod.parse=(e,r)=>{const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(s=>jg(s,n)):jg(i,n)}});function jg(n,t){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:t}),n}const wC=A("$ZodCatch",(n,t)=>{ve.init(n,t),te(n._zod,"optin",()=>t.innerType._zod.optin),te(n._zod,"optout",()=>t.innerType._zod.optout),te(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);const i=t.innerType._zod.run(e,r);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=>or(o,r,sr()))},input:e.value}),e.issues=[]),e)):(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(s=>or(s,r,sr()))},input:e.value}),e.issues=[]),e)}}),SC=A("$ZodPipe",(n,t)=>{ve.init(n,t),te(n._zod,"values",()=>t.in._zod.values),te(n._zod,"optin",()=>t.in._zod.optin),te(n._zod,"optout",()=>t.out._zod.optout),te(n._zod,"propValues",()=>t.in._zod.propValues),n._zod.parse=(e,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(e,r);return s instanceof Promise?s.then(o=>al(o,t.in,r)):al(s,t.in,r)}const i=t.in._zod.run(e,r);return i instanceof Promise?i.then(s=>al(s,t.out,r)):al(i,t.out,r)}});function al(n,t,e){return n.issues.length?(n.aborted=!0,n):t._zod.run({value:n.value,issues:n.issues},e)}const _C=A("$ZodReadonly",(n,t)=>{ve.init(n,t),te(n._zod,"propValues",()=>t.innerType._zod.propValues),te(n._zod,"values",()=>t.innerType._zod.values),te(n._zod,"optin",()=>{var e,r;return(r=(e=t.innerType)==null?void 0:e._zod)==null?void 0:r.optin}),te(n._zod,"optout",()=>{var e,r;return(r=(e=t.innerType)==null?void 0:e._zod)==null?void 0:r.optout}),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(Gg):Gg(i)}});function Gg(n){return n.value=Object.freeze(n.value),n}const kC=A("$ZodCustom",(n,t)=>{ut.init(n,t),ve.init(n,t),n._zod.parse=(e,r)=>e,n._zod.check=e=>{const r=e.value,i=t.fn(r);if(i instanceof Promise)return i.then(s=>qg(s,e,r,n));qg(i,e,r,n)}});function qg(n,t,e,r){if(!n){const i={code:"custom",input:e,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),t.issues.push(wo(i))}}var Yg;class xC{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...e){const r=e[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.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 r={...this.get(e)??{}};delete r.id;const i={...r,...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 EC(){return new xC}(Yg=globalThis).__zod_globalRegistry??(Yg.__zod_globalRegistry=EC());const Ks=globalThis.__zod_globalRegistry;function AC(n,t){return new n({type:"string",...O(t)})}function TC(n,t){return new n({type:"string",format:"email",check:"string_format",abort:!1,...O(t)})}function Kg(n,t){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...O(t)})}function $C(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...O(t)})}function IC(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(t)})}function CC(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(t)})}function RC(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(t)})}function PC(n,t){return new n({type:"string",format:"url",check:"string_format",abort:!1,...O(t)})}function LC(n,t){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...O(t)})}function DC(n,t){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(t)})}function zC(n,t){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...O(t)})}function OC(n,t){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(t)})}function MC(n,t){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...O(t)})}function NC(n,t){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...O(t)})}function UC(n,t){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(t)})}function FC(n,t){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(t)})}function HC(n,t){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(t)})}function ZC(n,t){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(t)})}function WC(n,t){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(t)})}function VC(n,t){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...O(t)})}function BC(n,t){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...O(t)})}function jC(n,t){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...O(t)})}function GC(n,t){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...O(t)})}function qC(n,t){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(t)})}function YC(n,t){return new n({type:"string",format:"date",check:"string_format",...O(t)})}function KC(n,t){return new n({type:"string",format:"time",check:"string_format",precision:null,...O(t)})}function JC(n,t){return new n({type:"string",format:"duration",check:"string_format",...O(t)})}function XC(n,t){return new n({type:"number",checks:[],...O(t)})}function QC(n,t){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...O(t)})}function eR(n,t){return new n({type:"boolean",...O(t)})}function tR(n){return new n({type:"unknown"})}function nR(n,t){return new n({type:"never",...O(t)})}function Jg(n,t){return new eb({check:"less_than",...O(t),value:n,inclusive:!1})}function zu(n,t){return new eb({check:"less_than",...O(t),value:n,inclusive:!0})}function Xg(n,t){return new tb({check:"greater_than",...O(t),value:n,inclusive:!1})}function Ou(n,t){return new tb({check:"greater_than",...O(t),value:n,inclusive:!0})}function Qg(n,t){return new vI({check:"multiple_of",...O(t),value:n})}function lb(n,t){return new bI({check:"max_length",...O(t),maximum:n})}function Gl(n,t){return new wI({check:"min_length",...O(t),minimum:n})}function cb(n,t){return new SI({check:"length_equals",...O(t),length:n})}function rR(n,t){return new _I({check:"string_format",format:"regex",...O(t),pattern:n})}function iR(n){return new kI({check:"string_format",format:"lowercase",...O(n)})}function sR(n){return new xI({check:"string_format",format:"uppercase",...O(n)})}function oR(n,t){return new EI({check:"string_format",format:"includes",...O(t),includes:n})}function aR(n,t){return new AI({check:"string_format",format:"starts_with",...O(t),prefix:n})}function lR(n,t){return new TI({check:"string_format",format:"ends_with",...O(t),suffix:n})}function $s(n){return new $I({check:"overwrite",tx:n})}function cR(n){return $s(t=>t.normalize(n))}function uR(){return $s(n=>n.trim())}function hR(){return $s(n=>n.toLowerCase())}function dR(){return $s(n=>n.toUpperCase())}function pR(){return $s(n=>_$(n))}function fR(n,t,e){return new n({type:"array",element:t,...O(e)})}function gR(n,t,e){return new n({type:"custom",check:"custom",fn:t,...O(e)})}function mR(n){const t=vR(e=>(e.addIssue=r=>{if(typeof r=="string")e.issues.push(wo(r,e.value,t._zod.def));else{const i=r;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))}},n(e.value,e)));return t}function vR(n,t){const e=new ut({check:"custom",...O(t)});return e._zod.check=n,e}function ub(n){let t=(n==null?void 0:n.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:n.processors??{},metadataRegistry:(n==null?void 0:n.metadata)??Ks,target:t,unrepresentable:(n==null?void 0:n.unrepresentable)??"throw",override:(n==null?void 0:n.override)??(()=>{}),io:(n==null?void 0:n.io)??"output",counter:0,seen:new Map,cycles:(n==null?void 0:n.cycles)??"ref",reused:(n==null?void 0:n.reused)??"inline",external:(n==null?void 0:n.external)??void 0}}function Ee(n,t,e={path:[],schemaPath:[]}){var h,f;var r;const i=n._zod.def,s=t.seen.get(n);if(s)return s.count++,e.schemaPath.includes(n)&&(s.cycle=e.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:e.path};t.seen.set(n,o);const a=(f=(h=n._zod).toJSONSchema)==null?void 0:f.call(h);if(a)o.schema=a;else{const y={...e,schemaPath:[...e.schemaPath,n],path:e.path};if(n._zod.processJSONSchema)n._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(n,t,E,y)}const m=n._zod.parent;m&&(o.ref||(o.ref=m),Ee(m,t,y),t.seen.get(m).isParent=!0)}const c=t.metadataRegistry.get(n);return c&&Object.assign(o.schema,c),t.io==="input"&&Je(n)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(n).schema}function hb(n,t){var o,a,c,u;const e=n.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const h of n.seen.entries()){const f=(o=n.metadataRegistry.get(h[0]))==null?void 0:o.id;if(f){const y=r.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.`);r.set(f,h[0])}}const i=h=>{var x;const f=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const I=(x=n.external.registry.get(h[0]))==null?void 0:x.id,L=n.external.uri??(V=>V);if(I)return{ref:L(I)};const R=h[1].defId??h[1].schema.id??`schema${n.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${n.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(n.cycles==="throw")for(const h of n.seen.entries()){const f=h[1];if(f.cycle)throw new Error(`Cycle detected: #/${(a=f.cycle)==null?void 0:a.join("/")}/<root>
41
-
42
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const h of n.seen.entries()){const f=h[1];if(t===h[0]){s(h);continue}if(n.external){const m=(c=n.external.registry.get(h[0]))==null?void 0:c.id;if(t!==h[0]&&m){s(h);continue}}if((u=n.metadataRegistry.get(h[0]))==null?void 0:u.id){s(h);continue}if(f.cycle){s(h);continue}if(f.count>1&&n.reused==="ref"){s(h);continue}}}function db(n,t){var o,a,c;const e=n.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=u=>{const h=n.seen.get(u);if(h.ref===null)return;const f=h.def??h.schema,y={...f},m=h.ref;if(h.ref=null,m){r(m);const x=n.seen.get(m),I=x.schema;if(I.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(I)):Object.assign(f,I),Object.assign(f,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){r(E);const x=n.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]}n.override({zodSchema:u,jsonSchema:f,path:h.path??[]})};for(const u of[...n.seen.entries()].reverse())r(u[0]);const i={};if(n.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":n.target,(o=n.external)!=null&&o.uri){const u=(a=n.external.registry.get(t))==null?void 0:a.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=n.external.uri(u)}Object.assign(i,e.def??e.schema);const s=((c=n.external)==null?void 0:c.defs)??{};for(const u of n.seen.entries()){const h=u[1];h.def&&h.defId&&(s[h.defId]=h.def)}n.external||Object.keys(s).length>0&&(n.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...t["~standard"],jsonSchema:{input:ql(t,"input",n.processors),output:ql(t,"output",n.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function Je(n,t){const e=t??{seen:new Set};if(e.seen.has(n))return!1;e.seen.add(n);const r=n._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Je(r.element,e);if(r.type==="set")return Je(r.valueType,e);if(r.type==="lazy")return Je(r.getter(),e);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return Je(r.innerType,e);if(r.type==="intersection")return Je(r.left,e)||Je(r.right,e);if(r.type==="record"||r.type==="map")return Je(r.keyType,e)||Je(r.valueType,e);if(r.type==="pipe")return Je(r.in,e)||Je(r.out,e);if(r.type==="object"){for(const i in r.shape)if(Je(r.shape[i],e))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(Je(i,e))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(Je(i,e))return!0;return!!(r.rest&&Je(r.rest,e))}return!1}const yR=(n,t={})=>e=>{const r=ub({...e,processors:t});return Ee(n,r),hb(r,n),db(r,n)},ql=(n,t,e={})=>r=>{const{libraryOptions:i,target:s}=r??{},o=ub({...i??{},target:s,io:t,processors:e});return Ee(n,o),hb(o,n),db(o,n)},bR={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},wR=(n,t,e,r)=>{const i=e;i.type="string";const{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:u}=n._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=bR[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}))])}},SR=(n,t,e,r)=>{const i=e,{minimum:s,maximum:o,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:h}=n._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)},_R=(n,t,e,r)=>{e.type="boolean"},kR=(n,t,e,r)=>{e.not={}},xR=(n,t,e,r)=>{},ER=(n,t,e,r)=>{const i=n._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},AR=(n,t,e,r)=>{const i=n._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},TR=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},$R=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},IR=(n,t,e,r)=>{const i=e,s=n._zod.def,{minimum:o,maximum:a}=n._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=Ee(s.element,t,{...r,path:[...r.path,"items"]})},CR=(n,t,e,r)=>{var u;const i=e,s=n._zod.def;i.type="object",i.properties={};const o=s.shape;for(const h in o)i.properties[h]=Ee(o[h],t,{...r,path:[...r.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,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},RR=(n,t,e,r)=>{const i=n._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>Ee(a,t,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?e.oneOf=o:e.anyOf=o},PR=(n,t,e,r)=>{const i=n._zod.def,s=Ee(i.left,t,{...r,path:[...r.path,"allOf",0]}),o=Ee(i.right,t,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];e.allOf=c},LR=(n,t,e,r)=>{const i=e,s=n._zod.def;i.type="object";const o=s.keyType,a=o._zod.bag,c=a==null?void 0:a.patterns;if(s.mode==="loose"&&c&&c.size>0){const h=Ee(s.valueType,t,{...r,path:[...r.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,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=Ee(s.valueType,t,{...r,path:[...r.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)}},DR=(n,t,e,r)=>{const i=n._zod.def,s=Ee(i.innerType,t,r),o=t.seen.get(n);t.target==="openapi-3.0"?(o.ref=i.innerType,e.nullable=!0):e.anyOf=[s,{type:"null"}]},zR=(n,t,e,r)=>{const i=n._zod.def;Ee(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType},OR=(n,t,e,r)=>{const i=n._zod.def;Ee(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,e.default=JSON.parse(JSON.stringify(i.defaultValue))},MR=(n,t,e,r)=>{const i=n._zod.def;Ee(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,t.io==="input"&&(e._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},NR=(n,t,e,r)=>{const i=n._zod.def;Ee(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}e.default=o},UR=(n,t,e,r)=>{const i=n._zod.def,s=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;Ee(s,t,r);const o=t.seen.get(n);o.ref=s},FR=(n,t,e,r)=>{const i=n._zod.def;Ee(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,e.readOnly=!0},pb=(n,t,e,r)=>{const i=n._zod.def;Ee(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType},HR=A("ZodISODateTime",(n,t)=>{ZI.init(n,t),be.init(n,t)});function ZR(n){return qC(HR,n)}const WR=A("ZodISODate",(n,t)=>{WI.init(n,t),be.init(n,t)});function VR(n){return YC(WR,n)}const BR=A("ZodISOTime",(n,t)=>{VI.init(n,t),be.init(n,t)});function jR(n){return KC(BR,n)}const GR=A("ZodISODuration",(n,t)=>{BI.init(n,t),be.init(n,t)});function qR(n){return JC(GR,n)}const fb=(n,t)=>{Gy.init(n,t),n.name="ZodError",Object.defineProperties(n,{format:{value:e=>z$(n,e)},flatten:{value:e=>D$(n,e)},addIssue:{value:e=>{n.issues.push(e),n.message=JSON.stringify(n.issues,wh,2)}},addIssues:{value:e=>{n.issues.push(...e),n.message=JSON.stringify(n.issues,wh,2)}},isEmpty:{get(){return n.issues.length===0}}})},em=A("ZodError",fb),Et=A("ZodError",fb,{Parent:Error}),YR=sp(Et),KR=op(Et),JR=Pc(Et),XR=Lc(Et),QR=N$(Et),eP=U$(Et),tP=F$(Et),nP=H$(Et),rP=Z$(Et),iP=W$(Et),sP=V$(Et),oP=B$(Et),ye=A("ZodType",(n,t)=>(ve.init(n,t),Object.assign(n["~standard"],{jsonSchema:{input:ql(n,"input"),output:ql(n,"output")}}),n.toJSONSchema=yR(n,{}),n.def=t,n.type=t.type,Object.defineProperty(n,"_def",{value:t}),n.check=(...e)=>n.clone(hr(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),n.with=n.check,n.clone=(e,r)=>dr(n,e,r),n.brand=()=>n,n.register=(e,r)=>(e.add(n,r),n),n.parse=(e,r)=>YR(n,e,r,{callee:n.parse}),n.safeParse=(e,r)=>JR(n,e,r),n.parseAsync=async(e,r)=>KR(n,e,r,{callee:n.parseAsync}),n.safeParseAsync=async(e,r)=>XR(n,e,r),n.spa=n.safeParseAsync,n.encode=(e,r)=>QR(n,e,r),n.decode=(e,r)=>eP(n,e,r),n.encodeAsync=async(e,r)=>tP(n,e,r),n.decodeAsync=async(e,r)=>nP(n,e,r),n.safeEncode=(e,r)=>rP(n,e,r),n.safeDecode=(e,r)=>iP(n,e,r),n.safeEncodeAsync=async(e,r)=>sP(n,e,r),n.safeDecodeAsync=async(e,r)=>oP(n,e,r),n.refine=(e,r)=>n.check(XP(e,r)),n.superRefine=e=>n.check(QP(e)),n.overwrite=e=>n.check($s(e)),n.optional=()=>rm(n),n.exactOptional=()=>UP(n),n.nullable=()=>im(n),n.nullish=()=>rm(im(n)),n.nonoptional=e=>BP(n,e),n.array=()=>z(n),n.or=e=>B([n,e]),n.and=e=>zc(n,e),n.transform=e=>sm(n,MP(e)),n.default=e=>ZP(n,e),n.prefault=e=>VP(n,e),n.catch=e=>GP(n,e),n.pipe=e=>sm(n,e),n.readonly=()=>KP(n),n.describe=e=>{const r=n.clone();return Ks.add(r,{description:e}),r},Object.defineProperty(n,"description",{get(){var e;return(e=Ks.get(n))==null?void 0:e.description},configurable:!0}),n.meta=(...e)=>{if(e.length===0)return Ks.get(n);const r=n.clone();return Ks.add(r,e[0]),r},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n.apply=e=>e(n),n)),gb=A("_ZodString",(n,t)=>{ap.init(n,t),ye.init(n,t),n._zod.processJSONSchema=(r,i,s)=>wR(n,r,i);const e=n._zod.bag;n.format=e.format??null,n.minLength=e.minimum??null,n.maxLength=e.maximum??null,n.regex=(...r)=>n.check(rR(...r)),n.includes=(...r)=>n.check(oR(...r)),n.startsWith=(...r)=>n.check(aR(...r)),n.endsWith=(...r)=>n.check(lR(...r)),n.min=(...r)=>n.check(Gl(...r)),n.max=(...r)=>n.check(lb(...r)),n.length=(...r)=>n.check(cb(...r)),n.nonempty=(...r)=>n.check(Gl(1,...r)),n.lowercase=r=>n.check(iR(r)),n.uppercase=r=>n.check(sR(r)),n.trim=()=>n.check(uR()),n.normalize=(...r)=>n.check(cR(...r)),n.toLowerCase=()=>n.check(hR()),n.toUpperCase=()=>n.check(dR()),n.slugify=()=>n.check(pR())}),aP=A("ZodString",(n,t)=>{ap.init(n,t),gb.init(n,t),n.email=e=>n.check(TC(lP,e)),n.url=e=>n.check(PC(cP,e)),n.jwt=e=>n.check(GC(xP,e)),n.emoji=e=>n.check(LC(uP,e)),n.guid=e=>n.check(Kg(tm,e)),n.uuid=e=>n.check($C(ll,e)),n.uuidv4=e=>n.check(IC(ll,e)),n.uuidv6=e=>n.check(CC(ll,e)),n.uuidv7=e=>n.check(RC(ll,e)),n.nanoid=e=>n.check(DC(hP,e)),n.guid=e=>n.check(Kg(tm,e)),n.cuid=e=>n.check(zC(dP,e)),n.cuid2=e=>n.check(OC(pP,e)),n.ulid=e=>n.check(MC(fP,e)),n.base64=e=>n.check(VC(SP,e)),n.base64url=e=>n.check(BC(_P,e)),n.xid=e=>n.check(NC(gP,e)),n.ksuid=e=>n.check(UC(mP,e)),n.ipv4=e=>n.check(FC(vP,e)),n.ipv6=e=>n.check(HC(yP,e)),n.cidrv4=e=>n.check(ZC(bP,e)),n.cidrv6=e=>n.check(WC(wP,e)),n.e164=e=>n.check(jC(kP,e)),n.datetime=e=>n.check(ZR(e)),n.date=e=>n.check(VR(e)),n.time=e=>n.check(jR(e)),n.duration=e=>n.check(qR(e))});function d(n){return AC(aP,n)}const be=A("ZodStringFormat",(n,t)=>{ge.init(n,t),gb.init(n,t)}),lP=A("ZodEmail",(n,t)=>{LI.init(n,t),be.init(n,t)}),tm=A("ZodGUID",(n,t)=>{RI.init(n,t),be.init(n,t)}),ll=A("ZodUUID",(n,t)=>{PI.init(n,t),be.init(n,t)}),cP=A("ZodURL",(n,t)=>{DI.init(n,t),be.init(n,t)}),uP=A("ZodEmoji",(n,t)=>{zI.init(n,t),be.init(n,t)}),hP=A("ZodNanoID",(n,t)=>{OI.init(n,t),be.init(n,t)}),dP=A("ZodCUID",(n,t)=>{MI.init(n,t),be.init(n,t)}),pP=A("ZodCUID2",(n,t)=>{NI.init(n,t),be.init(n,t)}),fP=A("ZodULID",(n,t)=>{UI.init(n,t),be.init(n,t)}),gP=A("ZodXID",(n,t)=>{FI.init(n,t),be.init(n,t)}),mP=A("ZodKSUID",(n,t)=>{HI.init(n,t),be.init(n,t)}),vP=A("ZodIPv4",(n,t)=>{jI.init(n,t),be.init(n,t)}),yP=A("ZodIPv6",(n,t)=>{GI.init(n,t),be.init(n,t)}),bP=A("ZodCIDRv4",(n,t)=>{qI.init(n,t),be.init(n,t)}),wP=A("ZodCIDRv6",(n,t)=>{YI.init(n,t),be.init(n,t)}),SP=A("ZodBase64",(n,t)=>{KI.init(n,t),be.init(n,t)}),_P=A("ZodBase64URL",(n,t)=>{XI.init(n,t),be.init(n,t)}),kP=A("ZodE164",(n,t)=>{QI.init(n,t),be.init(n,t)}),xP=A("ZodJWT",(n,t)=>{tC.init(n,t),be.init(n,t)}),mb=A("ZodNumber",(n,t)=>{rb.init(n,t),ye.init(n,t),n._zod.processJSONSchema=(r,i,s)=>SR(n,r,i),n.gt=(r,i)=>n.check(Xg(r,i)),n.gte=(r,i)=>n.check(Ou(r,i)),n.min=(r,i)=>n.check(Ou(r,i)),n.lt=(r,i)=>n.check(Jg(r,i)),n.lte=(r,i)=>n.check(zu(r,i)),n.max=(r,i)=>n.check(zu(r,i)),n.int=r=>n.check(nm(r)),n.safe=r=>n.check(nm(r)),n.positive=r=>n.check(Xg(0,r)),n.nonnegative=r=>n.check(Ou(0,r)),n.negative=r=>n.check(Jg(0,r)),n.nonpositive=r=>n.check(zu(0,r)),n.multipleOf=(r,i)=>n.check(Qg(r,i)),n.step=(r,i)=>n.check(Qg(r,i)),n.finite=()=>n;const e=n._zod.bag;n.minValue=Math.max(e.minimum??Number.NEGATIVE_INFINITY,e.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(e.maximum??Number.POSITIVE_INFINITY,e.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(e.format??"").includes("int")||Number.isSafeInteger(e.multipleOf??.5),n.isFinite=!0,n.format=e.format??null});function Z(n){return XC(mb,n)}const EP=A("ZodNumberFormat",(n,t)=>{nC.init(n,t),mb.init(n,t)});function nm(n){return QC(EP,n)}const AP=A("ZodBoolean",(n,t)=>{rC.init(n,t),ye.init(n,t),n._zod.processJSONSchema=(e,r,i)=>_R(n,e,r)});function De(n){return eR(AP,n)}const TP=A("ZodUnknown",(n,t)=>{iC.init(n,t),ye.init(n,t),n._zod.processJSONSchema=(e,r,i)=>xR()});function _(){return tR(TP)}const $P=A("ZodNever",(n,t)=>{sC.init(n,t),ye.init(n,t),n._zod.processJSONSchema=(e,r,i)=>kR(n,e,r)});function IP(n){return nR($P,n)}const CP=A("ZodArray",(n,t)=>{oC.init(n,t),ye.init(n,t),n._zod.processJSONSchema=(e,r,i)=>IR(n,e,r,i),n.element=t.element,n.min=(e,r)=>n.check(Gl(e,r)),n.nonempty=e=>n.check(Gl(1,e)),n.max=(e,r)=>n.check(lb(e,r)),n.length=(e,r)=>n.check(cb(e,r)),n.unwrap=()=>n.element});function z(n,t){return fR(CP,n,t)}const vb=A("ZodObject",(n,t)=>{lC.init(n,t),ye.init(n,t),n._zod.processJSONSchema=(e,r,i)=>CR(n,e,r,i),te(n,"shape",()=>t.shape),n.keyof=()=>wb(Object.keys(n._zod.def.shape)),n.catchall=e=>n.clone({...n._zod.def,catchall:e}),n.passthrough=()=>n.clone({...n._zod.def,catchall:_()}),n.loose=()=>n.clone({...n._zod.def,catchall:_()}),n.strict=()=>n.clone({...n._zod.def,catchall:IP()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=e=>I$(n,e),n.safeExtend=e=>C$(n,e),n.merge=e=>R$(n,e),n.pick=e=>T$(n,e),n.omit=e=>$$(n,e),n.partial=(...e)=>P$(Sb,n,e[0]),n.required=(...e)=>L$(_b,n,e[0])});function yb(n,t){const e={type:"object",shape:n??{},...O(t)};return new vb(e)}function v(n,t){return new vb({type:"object",shape:n,catchall:_(),...O(t)})}const bb=A("ZodUnion",(n,t)=>{ob.init(n,t),ye.init(n,t),n._zod.processJSONSchema=(e,r,i)=>RR(n,e,r,i),n.options=t.options});function B(n,t){return new bb({type:"union",options:n,...O(t)})}const RP=A("ZodDiscriminatedUnion",(n,t)=>{bb.init(n,t),cC.init(n,t)});function PP(n,t,e){return new RP({type:"union",options:t,discriminator:n,...O(e)})}const LP=A("ZodIntersection",(n,t)=>{uC.init(n,t),ye.init(n,t),n._zod.processJSONSchema=(e,r,i)=>PR(n,e,r,i)});function zc(n,t){return new LP({type:"intersection",left:n,right:t})}const DP=A("ZodRecord",(n,t)=>{hC.init(n,t),ye.init(n,t),n._zod.processJSONSchema=(e,r,i)=>LR(n,e,r,i),n.keyType=t.keyType,n.valueType=t.valueType});function k(n,t,e){return new DP({type:"record",keyType:n,valueType:t,...O(e)})}const _h=A("ZodEnum",(n,t)=>{dC.init(n,t),ye.init(n,t),n._zod.processJSONSchema=(r,i,s)=>ER(n,r,i),n.enum=t.entries,n.options=Object.values(t.entries);const e=new Set(Object.keys(t.entries));n.extract=(r,i)=>{const s={};for(const o of r)if(e.has(o))s[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new _h({...t,checks:[],...O(i),entries:s})},n.exclude=(r,i)=>{const s={...t.entries};for(const o of r)if(e.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new _h({...t,checks:[],...O(i),entries:s})}});function wb(n,t){const e=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new _h({type:"enum",entries:e,...O(t)})}const zP=A("ZodLiteral",(n,t)=>{pC.init(n,t),ye.init(n,t),n._zod.processJSONSchema=(e,r,i)=>AR(n,e,r),n.values=new Set(t.values),Object.defineProperty(n,"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(n,t){return new zP({type:"literal",values:Array.isArray(n)?n:[n],...O(t)})}const OP=A("ZodTransform",(n,t)=>{fC.init(n,t),ye.init(n,t),n._zod.processJSONSchema=(e,r,i)=>$R(n,e),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new Hy(n.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=n),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 MP(n){return new OP({type:"transform",transform:n})}const Sb=A("ZodOptional",(n,t)=>{ab.init(n,t),ye.init(n,t),n._zod.processJSONSchema=(e,r,i)=>pb(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function rm(n){return new Sb({type:"optional",innerType:n})}const NP=A("ZodExactOptional",(n,t)=>{gC.init(n,t),ye.init(n,t),n._zod.processJSONSchema=(e,r,i)=>pb(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function UP(n){return new NP({type:"optional",innerType:n})}const FP=A("ZodNullable",(n,t)=>{mC.init(n,t),ye.init(n,t),n._zod.processJSONSchema=(e,r,i)=>DR(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function im(n){return new FP({type:"nullable",innerType:n})}const HP=A("ZodDefault",(n,t)=>{vC.init(n,t),ye.init(n,t),n._zod.processJSONSchema=(e,r,i)=>OR(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function ZP(n,t){return new HP({type:"default",innerType:n,get defaultValue(){return typeof t=="function"?t():By(t)}})}const WP=A("ZodPrefault",(n,t)=>{yC.init(n,t),ye.init(n,t),n._zod.processJSONSchema=(e,r,i)=>MR(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function VP(n,t){return new WP({type:"prefault",innerType:n,get defaultValue(){return typeof t=="function"?t():By(t)}})}const _b=A("ZodNonOptional",(n,t)=>{bC.init(n,t),ye.init(n,t),n._zod.processJSONSchema=(e,r,i)=>zR(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function BP(n,t){return new _b({type:"nonoptional",innerType:n,...O(t)})}const jP=A("ZodCatch",(n,t)=>{wC.init(n,t),ye.init(n,t),n._zod.processJSONSchema=(e,r,i)=>NR(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function GP(n,t){return new jP({type:"catch",innerType:n,catchValue:typeof t=="function"?t:()=>t})}const qP=A("ZodPipe",(n,t)=>{SC.init(n,t),ye.init(n,t),n._zod.processJSONSchema=(e,r,i)=>UR(n,e,r,i),n.in=t.in,n.out=t.out});function sm(n,t){return new qP({type:"pipe",in:n,out:t})}const YP=A("ZodReadonly",(n,t)=>{_C.init(n,t),ye.init(n,t),n._zod.processJSONSchema=(e,r,i)=>FR(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function KP(n){return new YP({type:"readonly",innerType:n})}const JP=A("ZodCustom",(n,t)=>{kC.init(n,t),ye.init(n,t),n._zod.processJSONSchema=(e,r,i)=>TR(n,e)});function XP(n,t={}){return gR(JP,n,t)}function QP(n){return mR(n)}const eL=[".md",".markdown"];function kb(n){if(n.length===0)return!1;const t=n.at(-1);return t==="/"||t==="\\"}function xb(n){const t=n.lastIndexOf("/"),e=n.lastIndexOf("\\");return n.slice(Math.max(t,e)+1)}function tL(n){return xb(n).toLowerCase()}function nL(n,t){const e=tL(n);return t.some(r=>e.endsWith(r))}function Eb(n){return!kb(n)&&nL(n,eL)}function rL(n){let t;try{t=new URL(n)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"}function yn(n){try{const{pathname:t}=new URL(n);return/^\/artifact\/[0-9A-Za-z]{26}(\/|$)/.test(t)}catch{return!1}}const iL=yb({id:d().min(1),kind:T("path"),title:d(),path:d()}).strict(),sL=yb({id:d().min(1),kind:T("url"),title:d(),url:d().refine(rL,{message:"url must be an http(s) URL"})}).strict();PP("kind",[iL,sL]);function Ab(n){return typeof n=="object"&&n!==null}function Tb(n){return!Ab(n)||n.type!=="ready"?!1:!("id"in n)}function $b(n){return!(!Ab(n)||n.type!=="update-content"||typeof n.id!="string"||typeof n.content!="string")}const oL="/views/markdown/",aL="/views/url-unsupported/";function Ib(n){return`/artifact/${encodeURIComponent(n)}`}function lL(n,t){return`${Ib(n)}/${encodeURIComponent(t)}`}function cL(n){return`/markdown/${encodeURIComponent(n)}`}function Yl(n,t={electron:!1}){if(n.kind==="url")return t.electron?{renderer:"url-webview",viewURL:n.url,contentURL:null}:yn(n.url)?{renderer:"proxy-iframe",viewURL:n.url,contentURL:null}:{renderer:"url-unsupported",viewURL:aL,contentURL:null};if(Eb(n.path)){const r={viewURL:oL,contentURL:cL(n.id)};return t.electron?{renderer:"url-webview",...r}:{renderer:"markdown",...r}}const e=kb(n.path)?`${Ib(n.id)}/`:lL(n.id,xb(n.path));return t.electron?{renderer:"url-webview",viewURL:e,contentURL:null}:{renderer:"proxy-iframe",viewURL:e,contentURL:null}}const uL="serverURL",hL="token",dL="mode",pL="desktopAppVersion",fL="electron";function Cb(n=window.location.search,t=window.location.origin){const r=new URLSearchParams(n).get(uL);return r?new URL(r).origin:new URL(t).origin}function gL(n=window.location.search){return new URLSearchParams(n).get(hL)}function un(n=typeof window>"u"?"":window.location.search){return new URLSearchParams(n).get(dL)===fL}function mL(n=typeof window>"u"?"":window.location.search){return new URLSearchParams(n).get(pL)}const om="tv.telemetry.clientId",vL=5,yL=60,bL=1e3,wL=vL*yL*bL,am=["pointerdown","scroll","keydown"],lm=["focus"],cm=["visibilitychange"],SL="hidden";function _L(n,t=TL){const e=n.getItem(om);if(e)return e;const r=t();return n.setItem(om,r),r}function kL(n){return{clientId:_L(n.storage,n.idFactory),userAgent:n.userAgent??(typeof navigator>"u"?"":navigator.userAgent),clientApp:n.clientApp,...n.desktopAppVersion?{desktopAppVersion:n.desktopAppVersion}:{}}}function xL(n){const t=new URLSearchParams;return t.set("clientId",n.clientId),t.set("userAgent",n.userAgent),t.set("clientApp",n.clientApp),n.desktopAppVersion&&t.set("desktopAppVersion",n.desktopAppVersion),t}function EL(n){return new AL(n)}var Ro,xn,Bn,Po,Lo,gt,Mr,Do,sc,Rb;class AL{constructor(t){w(this,sc);w(this,Ro);w(this,xn);w(this,Bn);w(this,Po);w(this,Lo);w(this,gt);w(this,Mr,!1);w(this,Do,Number.NEGATIVE_INFINITY);b(this,Ro,t.meta),b(this,xn,t.documentTarget),b(this,Bn,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,Mr)){b(this,Mr,!0);for(const t of am)l(this,Bn).addEventListener(t,l(this,gt)),l(this,xn).addEventListener(t,l(this,gt));for(const t of lm)l(this,Bn).addEventListener(t,l(this,gt));for(const t of cm)l(this,xn).addEventListener(t,l(this,gt))}}stop(){if(l(this,Mr)){b(this,Mr,!1);for(const t of am)l(this,Bn).removeEventListener(t,l(this,gt)),l(this,xn).removeEventListener(t,l(this,gt));for(const t of lm)l(this,Bn).removeEventListener(t,l(this,gt));for(const t of cm)l(this,xn).removeEventListener(t,l(this,gt))}}}Ro=new WeakMap,xn=new WeakMap,Bn=new WeakMap,Po=new WeakMap,Lo=new WeakMap,gt=new WeakMap,Mr=new WeakMap,Do=new WeakMap,sc=new WeakSet,Rb=function(){if(l(this,xn).visibilityState===SL)return;const t=l(this,Lo).call(this);t-l(this,Do)<wL||(b(this,Do,t),l(this,Po).call(this,{type:MT,clientId:l(this,Ro).clientId}))};function TL(){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"},vn={fs_read_text_file:"fs/read_text_file",fs_write_text_file:"fs/write_text_file",session_request_permission:"session/request_permission",session_update:"session/update",terminal_create:"terminal/create",terminal_kill:"terminal/kill",terminal_output:"terminal/output",terminal_release:"terminal/release",terminal_wait_for_exit:"terminal/wait_for_exit"},$L=1,IL=v({_meta:k(d(),_()).nullish(),terminal:De().optional().default(!1)}),CL=v({_meta:k(d(),_()).nullish(),label:d().nullish(),name:d(),optional:De().optional().default(!1),secret:De().optional().default(!0)}),RL=v({_meta:k(d(),_()).nullish(),description:d().nullish(),id:d(),name:d()}),PL=v({_meta:k(d(),_()).nullish(),description:d().nullish(),id:d(),link:d().nullish(),name:d(),vars:z(CL)}),LL=v({_meta:k(d(),_()).nullish(),args:z(d()).optional(),description:d().nullish(),env:k(d(),d()).optional(),id:d(),name:d()}),DL=B([PL.and(v({type:T("env_var")})),LL.and(v({type:T("terminal")})),RL]),zL=v({_meta:k(d(),_()).nullish(),methodId:d()}),OL=v({_meta:k(d(),_()).nullish()}),ML=v({_meta:k(d(),_()).nullish(),blob:d(),mimeType:d().nullish(),uri:d()}),NL=v({default:De().nullish(),description:d().nullish(),title:d().nullish()}),UL=v({_meta:k(d(),_()).nullish()}),FL=v({_meta:k(d(),_()).nullish()}),HL=v({amount:Z(),currency:d()}),ZL=v({_meta:k(d(),_()).nullish(),terminalId:d()}),WL=v({_meta:k(d(),_()).nullish(),newText:d(),oldText:d().nullish(),path:d()}),VL=B([d(),Z(),Z(),De(),z(d())]),BL=v({content:k(d(),VL).nullish()}),jL=B([BL.and(v({action:T("accept")})),v({action:T("decline")}),v({action:T("cancel")})]),GL=v({_meta:k(d(),_()).nullish()}),Pb=d(),qL=v({_meta:k(d(),_()).nullish(),elicitationId:Pb}),YL=v({_meta:k(d(),_()).nullish(),action:jL}),KL=T("object"),JL=T("string"),XL=v({_meta:k(d(),_()).nullish()}),QL=v({_meta:k(d(),_()).nullish(),form:GL.nullish(),url:XL.nullish()}),eD=v({elicitationId:Pb,url:d().url()}),Lb=v({const:d(),title:d()}),Db=v({_meta:k(d(),_()).nullish(),name:d(),value:d()}),tD=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:tD,data:_().optional(),message:d()}),Ob=_(),Mb=_(),Nb=_(),nD=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()}),rD=v({default:Z().nullish(),description:d().nullish(),maximum:Z().nullish(),minimum:Z().nullish(),title:d().nullish()}),iD=v({_meta:k(d(),_()).nullish()}),sD=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cursor:d().nullish(),cwd:d().nullish()}),oD=v({_meta:k(d(),_()).nullish()}),aD=v({_meta:k(d(),_()).nullish(),logout:oD.nullish()}),lD=v({_meta:k(d(),_()).nullish()}),cD=v({_meta:k(d(),_()).nullish()}),uD=v({_meta:k(d(),_()).nullish(),http:De().optional().default(!1),sse:De().optional().default(!1)}),hD=v({_meta:k(d(),_()).nullish(),headers:z(Ub),name:d(),url:d()}),dD=v({_meta:k(d(),_()).nullish(),headers:z(Ub),name:d(),url:d()}),pD=v({_meta:k(d(),_()).nullish(),args:z(d()),command:d(),env:z(Db),name:d()}),Oc=B([hD.and(v({type:T("http")})),dD.and(v({type:T("sse")})),pD]),lp=d(),fD=v({_meta:k(d(),_()).nullish(),description:d().nullish(),modelId:lp,name:d()}),gD=B([T("error"),T("warning"),T("information"),T("hint")]),mD=v({_meta:k(d(),_()).nullish()}),vD=v({_meta:k(d(),_()).nullish()}),yD=v({_meta:k(d(),_()).nullish()}),bD=v({_meta:k(d(),_()).nullish()}),wD=v({_meta:k(d(),_()).nullish()}),SD=v({_meta:k(d(),_()).nullish(),maxCount:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),_D=v({diff:d(),uri:d()}),kD=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()}),xD=v({_meta:k(d(),_()).nullish()}),ED=v({_meta:k(d(),_()).nullish()}),AD=v({languageId:d(),text:d(),uri:d()}),TD=v({_meta:k(d(),_()).nullish(),maxCount:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),$D=B([T("rejected"),T("ignored"),T("replaced"),T("cancelled")]),ID=v({excerpts:z(kD),uri:d()}),CD=v({_meta:k(d(),_()).nullish()}),RD=v({_meta:k(d(),_()).nullish()}),PD=v({name:d(),owner:d(),remoteUrl:d()}),LD=v({_meta:k(d(),_()).nullish()}),DD=v({_meta:k(d(),_()).nullish(),jump:xD.nullish(),rename:RD.nullish(),searchAndReplace:LD.nullish()}),zD=v({id:d(),isRegex:De().nullish(),replace:d(),search:d(),uri:d()}),OD=B([T("automatic"),T("diagnostic"),T("manual")]),MD=v({_meta:k(d(),_()).nullish(),maxCount:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),ND=v({_meta:k(d(),_()).nullish(),diagnostics:mD.nullish(),editHistory:SD.nullish(),openFiles:ED.nullish(),recentFiles:TD.nullish(),relatedSnippets:CD.nullish(),userActions:MD.nullish()}),UD=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cwd:d(),mcpServers:z(Oc)}),FD=v({default:Z().nullish(),description:d().nullish(),maximum:Z().nullish(),minimum:Z().nullish(),title:d().nullish()}),Hb=d(),HD=B([T("allow_once"),T("allow_always"),T("reject_once"),T("reject_always")]),ZD=v({_meta:k(d(),_()).nullish(),kind:HD,name:d(),optionId:Hb}),WD=B([T("high"),T("medium"),T("low")]),VD=B([T("pending"),T("in_progress"),T("completed")]),BD=v({_meta:k(d(),_()).nullish(),content:d(),priority:WD,status:VD}),jD=v({_meta:k(d(),_()).nullish(),entries:z(BD)}),ar=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"})}),GD=v({id:d(),position:ar,uri:d()}),qD=v({id:d(),newName:d(),position:ar,uri:d()}),YD=v({action:d(),position:ar,timestampMs:Z(),uri:d()}),Zb=B([T("utf-16"),T("utf-32"),T("utf-8")]),KD=v({_meta:k(d(),_()).nullish(),auth:IL.optional().default({terminal:!1}),elicitation:QL.nullish(),fs:nD.optional().default({readTextFile:!1,writeTextFile:!1}),nes:DD.nullish(),positionEncodings:z(Zb).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)}),Wb=Z().int().gte(0).lte(65535),XD=v({_meta:k(d(),_()).nullish(),clientCapabilities:KD.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Fb.nullish(),protocolVersion:Wb}),Is=v({end:ar,start:ar}),QD=v({message:d(),range:Is,severity:gD,uri:d()}),e2=v({languageId:d(),lastFocusedMs:Z().nullish(),uri:d(),visibleRange:Is.nullish()}),t2=v({_meta:k(d(),_()).nullish(),diagnostics:z(QD).nullish(),editHistory:z(_D).nullish(),openFiles:z(e2).nullish(),recentFiles:z(AD).nullish(),relatedSnippets:z(ID).nullish(),userActions:z(YD).nullish()}),n2=v({newText:d(),range:Is}),r2=v({cursorPosition:ar.nullish(),edits:z(n2),id:d(),uri:d()}),i2=B([r2.and(v({kind:T("edit")})),GD.and(v({kind:T("jump")})),qD.and(v({kind:T("rename")})),zD.and(v({kind:T("searchAndReplace")}))]),s2=v({_meta:k(d(),_()).nullish(),content:d()}),o2=v({_meta:k(d(),_()).nullish()}),ei=B([Z(),d()]).nullable();v({_meta:k(d(),_()).nullish(),requestId:ei});const a2=wb(["assistant","user"]),Na=v({_meta:k(d(),_()).nullish(),audience:z(a2).nullish(),lastModified:d().nullish(),priority:Z().nullish()}),l2=v({_meta:k(d(),_()).nullish(),annotations:Na.nullish(),data:d(),mimeType:d()}),c2=v({_meta:k(d(),_()).nullish(),annotations:Na.nullish(),data:d(),mimeType:d(),uri:d().nullish()}),u2=v({_meta:k(d(),_()).nullish(),annotations:Na.nullish(),description:d().nullish(),mimeType:d().nullish(),name:d(),size:Z().nullish(),title:d().nullish(),uri:d()}),h2=v({_meta:k(d(),_()).nullish(),optionId:Hb}),d2=B([v({outcome:T("cancelled")}),h2.and(v({outcome:T("selected")}))]),p2=v({_meta:k(d(),_()).nullish(),outcome:d2}),f2=v({_meta:k(d(),_()).nullish()}),g2=v({_meta:k(d(),_()).nullish()}),m2=v({currentValue:De()}),v2=d(),Vb=d(),y2=B([T("mode"),T("model"),T("thought_level"),d()]),cp=d(),Bb=v({_meta:k(d(),_()).nullish(),description:d().nullish(),name:d(),value:cp}),b2=v({_meta:k(d(),_()).nullish(),group:v2,name:d(),options:z(Bb)}),w2=B([z(Bb),z(b2)]),S2=v({currentValue:cp,options:w2}),Cs=zc(B([S2.and(v({type:T("select")})),m2.and(v({type:T("boolean")}))]),v({_meta:k(d(),_()).nullish(),category:y2.nullish(),description:d().nullish(),id:Vb,name:d()})),_2=v({_meta:k(d(),_()).nullish(),configOptions:z(Cs)}),k2=v({_meta:k(d(),_()).nullish()}),Q=d(),x2=v({_meta:k(d(),_()).nullish(),id:d(),sessionId:Q}),E2=v({_meta:k(d(),_()).nullish(),sessionId:Q}),A2=v({_meta:k(d(),_()).nullish(),sessionId:Q}),T2=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}),$2=v({_meta:k(d(),_()).nullish(),sessionId:Q,uri:d()}),I2=v({_meta:k(d(),_()).nullish(),position:ar,sessionId:Q,uri:d(),version:Z(),visibleRange:Is}),C2=v({_meta:k(d(),_()).nullish(),languageId:d(),sessionId:Q,text:d(),uri:d(),version:Z()}),R2=v({_meta:k(d(),_()).nullish(),sessionId:Q,uri:d()}),P2=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()}),L2=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}),D2=v({_meta:k(d(),_()).nullish(),id:d(),reason:$D.nullish(),sessionId:Q}),Yb=v({_meta:k(d(),_()).nullish(),sessionId:Q,terminalId:d()}),z2=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cwd:d(),mcpServers:z(Oc).optional(),sessionId:Q}),O2=v({_meta:k(d(),_()).nullish(),additionalDirectories:z(d()).optional(),cwd:d(),sessionId:Q,title:d().nullish(),updatedAt:d().nullish()}),M2=v({_meta:k(d(),_()).nullish(),nextCursor:d().nullish(),sessions:z(O2)}),N2=v({_meta:k(d(),_()).nullish(),title:d().nullish(),updatedAt:d().nullish()}),U2=v({_meta:k(d(),_()).nullish()}),Mc=d(),F2=v({_meta:k(d(),_()).nullish(),currentModeId:Mc}),H2=v({_meta:k(d(),_()).nullish(),description:d().nullish(),id:Mc,name:d()}),Nc=v({_meta:k(d(),_()).nullish(),availableModes:z(H2),currentModeId:Mc}),Uc=v({_meta:k(d(),_()).nullish(),availableModels:z(fD),currentModelId:lp}),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(),configOptions:z(Cs).nullish(),models:Uc.nullish(),modes:Nc.nullish(),sessionId:Q}),B2=v({_meta:k(d(),_()).nullish(),configOptions:z(Cs).nullish(),models:Uc.nullish(),modes:Nc.nullish()}),j2=v({_meta:k(d(),_()).nullish()}),G2=v({_meta:k(d(),_()).nullish(),additionalDirectories:f2.nullish(),close:g2.nullish(),fork:k2.nullish(),list:U2.nullish(),resume:j2.nullish()}),q2=zc(B([v({type:T("boolean"),value:De()}),v({value:cp})]),v({_meta:k(d(),_()).nullish(),configId:Vb,sessionId:Q})),Y2=v({_meta:k(d(),_()).nullish(),configOptions:z(Cs)}),K2=v({_meta:k(d(),_()).nullish(),modeId:Mc,sessionId:Q}),J2=v({_meta:k(d(),_()).nullish()}),X2=v({_meta:k(d(),_()).nullish(),modelId:lp,sessionId:Q}),Q2=v({_meta:k(d(),_()).nullish()}),ez=v({_meta:k(d(),_()).nullish(),sessionId:Q}),tz=B([T("end_turn"),T("max_tokens"),T("max_turn_requests"),T("refusal"),T("cancelled")]),nz=B([T("email"),T("uri"),T("date"),T("date-time")]),rz=v({default:d().nullish(),description:d().nullish(),enum:z(d()).nullish(),format:nz.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()}),iz=v({_meta:k(d(),_()).nullish(),context:t2.nullish(),position:ar,selection:Is.nullish(),sessionId:Q,triggerKind:OD,uri:d(),version:Z()}),sz=v({_meta:k(d(),_()).nullish(),suggestions:z(i2)}),oz=v({_meta:k(d(),_()).nullish(),terminalId:d()}),az=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()}),lz=v({_meta:k(d(),_()).nullish(),exitStatus:az.nullish(),output:d(),truncated:De()}),cz=v({_meta:k(d(),_()).nullish(),annotations:Na.nullish(),text:d()}),uz=v({range:Is.nullish(),text:d()}),hz=v({_meta:k(d(),_()).nullish(),contentChanges:z(uz),sessionId:Q,uri:d(),version:Z()});v({method:d(),params:B([E2,C2,hz,$2,R2,I2,x2,D2,Ob]).nullish()});const dz=B([T("full"),T("incremental")]),pz=v({_meta:k(d(),_()).nullish(),syncKind:dz}),fz=v({_meta:k(d(),_()).nullish(),didChange:pz.nullish(),didClose:vD.nullish(),didFocus:yD.nullish(),didOpen:bD.nullish(),didSave:wD.nullish()}),gz=v({_meta:k(d(),_()).nullish(),document:fz.nullish()}),mz=v({_meta:k(d(),_()).nullish(),context:ND.nullish(),events:gz.nullish()}),vz=v({_meta:k(d(),_()).nullish(),auth:aD.optional().default({}),loadSession:De().optional().default(!1),mcpCapabilities:uD.optional().default({http:!1,sse:!1}),nes:mz.nullish(),positionEncoding:Zb.nullish(),promptCapabilities:JD.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:G2.optional().default({})}),yz=v({_meta:k(d(),_()).nullish(),agentCapabilities:vz.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Fb.nullish(),authMethods:z(DL).optional().default([]),protocolVersion:Wb}),bz=v({_meta:k(d(),_()).nullish(),mimeType:d().nullish(),text:d(),uri:d()}),wz=B([bz,ML]),Sz=v({_meta:k(d(),_()).nullish(),annotations:Na.nullish(),resource:wz}),up=B([cz.and(v({type:T("text")})),c2.and(v({type:T("image")})),l2.and(v({type:T("audio")})),u2.and(v({type:T("resource_link")})),Sz.and(v({type:T("resource")}))]),_z=v({_meta:k(d(),_()).nullish(),content:up}),Mu=v({_meta:k(d(),_()).nullish(),content:up,messageId:d().nullish()}),kz=v({_meta:k(d(),_()).nullish(),messageId:d().nullish(),prompt:z(up),sessionId:Q}),xz=v({anyOf:z(Lb)}),Jb=B([_z.and(v({type:T("content")})),WL.and(v({type:T("diff")})),oz.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")]),Ez=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}),nw=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}),rw=v({_meta:k(d(),_()).nullish(),options:z(ZD),sessionId:Q,toolCall:nw}),Az=v({_meta:k(d(),_()).nullish(),hint:d()}),Tz=Az,$z=v({_meta:k(d(),_()).nullish(),description:d(),input:Tz.nullish(),name:d()}),Iz=v({_meta:k(d(),_()).nullish(),availableCommands:z($z)}),Cz=v({enum:z(d()),type:JL}),Rz=B([Cz,xz]),Pz=v({default:z(d()).nullish(),description:d().nullish(),items:Rz,maxItems:Z().nullish(),minItems:Z().nullish(),title:d().nullish()}),Lz=B([rz.and(v({type:T("string")})),FD.and(v({type:T("number")})),rD.and(v({type:T("integer")})),NL.and(v({type:T("boolean")})),Pz.and(v({type:T("array")}))]),Dz=v({description:d().nullish(),properties:k(d(),Lz).optional().default({}),required:z(d()).nullish(),title:d().nullish(),type:KL.optional().default("object")}),zz=v({requestedSchema:Dz}),Oz=zc(B([zz.and(v({mode:T("form")})),eD.and(v({mode:T("url")}))]),v({_meta:k(d(),_()).nullish(),message:d(),sessionId:Q})),Mz=v({cachedReadTokens:Z().nullish(),cachedWriteTokens:Z().nullish(),inputTokens:Z(),outputTokens:Z(),thoughtTokens:Z().nullish(),totalTokens:Z()}),Nz=v({_meta:k(d(),_()).nullish(),stopReason:tz,usage:Mz.nullish(),userMessageId:d().nullish()});B([v({id:ei,result:B([yz,OL,cD,V2,W2,M2,Z2,B2,FL,J2,Y2,Nz,Q2,ez,sz,UL,Nb])}),v({error:zb,id:ei})]);const Uz=v({_meta:k(d(),_()).nullish(),cost:HL.nullish(),size:Z(),used:Z()}),Fz=B([Mu.and(v({sessionUpdate:T("user_message_chunk")})),Mu.and(v({sessionUpdate:T("agent_message_chunk")})),Mu.and(v({sessionUpdate:T("agent_thought_chunk")})),Ez.and(v({sessionUpdate:T("tool_call")})),nw.and(v({sessionUpdate:T("tool_call_update")})),jD.and(v({sessionUpdate:T("plan")})),Iz.and(v({sessionUpdate:T("available_commands_update")})),F2.and(v({sessionUpdate:T("current_mode_update")})),_2.and(v({sessionUpdate:T("config_option_update")})),N2.and(v({sessionUpdate:T("session_info_update")})),Uz.and(v({sessionUpdate:T("usage_update")}))]),iw=v({_meta:k(d(),_()).nullish(),sessionId:Q,update:Fz});v({method:d(),params:B([iw,qL,Ob]).nullish()});const sw=v({_meta:k(d(),_()).nullish(),sessionId:Q,terminalId:d()}),Hz=v({_meta:k(d(),_()).nullish(),exitCode:Z().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:d().nullish()}),Zz=v({name:d(),uri:d()}),Wz=v({_meta:k(d(),_()).nullish(),repository:PD.nullish(),workspaceFolders:z(Zz).nullish(),workspaceUri:d().nullish()});v({id:ei,method:d(),params:B([XD,zL,lD,UD,L2,sD,P2,z2,T2,K2,q2,kz,X2,Wz,iz,A2,Mb]).nullish()});const ow=v({_meta:k(d(),_()).nullish(),content:d(),path:d(),sessionId:Q});v({id:ei,method:d(),params:B([ow,qb,rw,jb,Kb,Yb,sw,Gb,Oz,Mb]).nullish()});const Vz=v({_meta:k(d(),_()).nullish()});B([v({id:ei,result:B([Vz,s2,p2,ZL,lz,o2,Hz,iD,YL,Nb])}),v({error:zb,id:ei})]);var X;class Bz{constructor(t,e){w(this,X);const r=t(this),i=async(o,a)=>{var c,u,h,f,y,m,E;switch(o){case vn.fs_write_text_file:{const x=ow.parse(a);return(c=r.writeTextFile)==null?void 0:c.call(r,x)}case vn.fs_read_text_file:{const x=qb.parse(a);return(u=r.readTextFile)==null?void 0:u.call(r,x)}case vn.session_request_permission:{const x=rw.parse(a);return r.requestPermission(x)}case vn.terminal_create:{const x=jb.parse(a);return(h=r.createTerminal)==null?void 0:h.call(r,x)}case vn.terminal_output:{const x=Kb.parse(a);return(f=r.terminalOutput)==null?void 0:f.call(r,x)}case vn.terminal_release:{const x=Yb.parse(a);return await((y=r.releaseTerminal)==null?void 0:y.call(r,x))??{}}case vn.terminal_wait_for_exit:{const x=sw.parse(a);return(m=r.waitForTerminalExit)==null?void 0:m.call(r,x)}case vn.terminal_kill:{const x=Gb.parse(a);return await((E=r.killTerminal)==null?void 0:E.call(r,x))??{}}default:if(r.extMethod)return r.extMethod(o,a);throw Ce.methodNotFound(o)}},s=async(o,a)=>{switch(o){case vn.session_update:{const c=iw.parse(a);return r.sessionUpdate(c)}default:if(r.extNotification)return r.extNotification(o,a);throw Ce.methodNotFound(o)}};b(this,X,new jz(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 jn,oc,zo,Oo,Zi,Wi,qt,Mo,me,aw,kh,lw,cw,uw,hw,xh,Js;class jz{constructor(t,e,r){w(this,me);w(this,jn,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,r),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,xh).call(this);const r=iu(this,oc)._++,i=new Promise((s,o)=>{l(this,jn).set(r,{resolve:s,reject:o})});return await p(this,me,Js).call(this,{jsonrpc:"2.0",id:r,method:t,params:e}),i}async sendNotification(t,e){p(this,me,xh).call(this),await p(this,me,Js).call(this,{jsonrpc:"2.0",method:t,params:e})}}jn=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:r,done:i}=await e.read();if(i)break;if(r)try{p(this,me,lw).call(this,r)}catch(s){console.error("Unexpected error during message processing:",r,s),"id"in r&&r.id!==void 0&&p(this,me,Js).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{e.releaseLock()}}catch(e){t=e}finally{p(this,me,kh).call(this,t)}},kh=function(t){if(l(this,qt).signal.aborted)return;const e=t??new Error("ACP connection closed");for(const r of l(this,jn).values())r.reject(e);l(this,jn).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(r){if(r instanceof Ce)return r.toResult();if(r instanceof em)return Ce.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return 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(r){if(r instanceof Ce)return r.toResult();if(r instanceof em)return Ce.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return Ce.internalError(i?JSON.parse(i):{}).toResult()}catch{return Ce.internalError({details:i}).toResult()}}},hw=function(t){const e=l(this,jn).get(t.id);if(e){if("result"in t)e.resolve(t.result);else if("error"in t){const{code:r,message:i,data:s}=t.error;e.reject(new Ce(r,i,s))}l(this,jn).delete(t.id)}else console.error("Got response to unknown request",t.id)},xh=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,kh).call(this,e)})),l(this,Wi)};class Ce extends Error{constructor(e,r,i){super(r);g(this,"code");g(this,"data");this.code=e,this.name="RequestError",this.data=i}static parseError(e,r){return new Ce(-32700,`Parse error${r?`: ${r}`:""}`,e)}static invalidRequest(e,r){return new Ce(-32600,`Invalid request${r?`: ${r}`:""}`,e)}static methodNotFound(e){return new Ce(-32601,`"Method not found": ${e}`,{method:e})}static invalidParams(e,r){return new Ce(-32602,`Invalid params${r?`: ${r}`:""}`,e)}static internalError(e,r){return new Ce(-32603,`Internal error${r?`: ${r}`:""}`,e)}static authRequired(e,r){return new Ce(-32e3,`Authentication required${r?`: ${r}`:""}`,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 Gz=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,qz=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,Yz=/\[Television screen context\][\s\S]*?\[\/Television screen context\]\n*/,Kz=/\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,Xz="single_session",Qz={name:"television-acp-client",version:"0.0.0"},dw="agent:main:television",eO=Ma(Nt);var Vi,Yt,dt,Kt,Gn,It,En,Jt,Xt,qn,Ct,Bi,ji,Qt,Xe,An,Gi,Nr,Tn,Yn,No,Rt,en,ac,tn,$,Eh,pw,fw,gw,xl,mw,vw,yw,bw,ww,Sw,_w,_r,Ei,Ai,bn,kw,Ti,Ah,Th,El,xw,Al,$h,Ih,Uo,Fo,Tl,$i,Ch,Ew;class tO extends eO{constructor(e){super();w(this,$);w(this,Vi,"disconnected");w(this,Yt,null);w(this,dt,new Map);w(this,Kt,null);w(this,Gn,null);w(this,It,null);w(this,En,null);w(this,Jt,null);w(this,Xt,null);w(this,qn);w(this,Ct,null);w(this,Bi,0);w(this,ji,1);w(this,Qt,null);w(this,Xe,null);w(this,An,!1);w(this,Gi,!1);w(this,Nr,!1);w(this,Tn,null);w(this,Yn,new Set);w(this,No);w(this,Rt);w(this,en);w(this,ac,e=>{p(this,$,fw).call(this,e)});w(this,tn,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,en,e.sessionMode??Xz),b(this,qn,e.mappedSessionStore??nO()),b(this,No,e.createSocket??(r=>new WebSocket(r)))}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,$,bn).call(this,"disconnected"))}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(this.enabled&&this.status==="disconnected"){l(this,Gn)===null&&(b(this,Yt,null),b(this,Gn,p(this,$,pw).call(this)));try{await l(this,Gn),await p(this,$,xl).call(this)}catch(e){throw p(this,$,$i).call(this,Nu(e)),e}}}dispose(){p(this,$,Tl).call(this),b(this,Yt,null),p(this,$,bn).call(this,"disposed")}async sendMessage(e){if(await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await p(this,$,Eh).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 r=e.text.trim();if(!r)throw new Error("Cannot send an empty message");p(this,$,Ei).call(this,{id:p(this,$,Ti).call(this,"user"),kind:"user",text:r,status:"final"}),p(this,$,bn).call(this,"running");try{const i=await p(this,$,El).call(this).prompt({sessionId:p(this,$,Th).call(this),prompt:[{type:"text",text:p(this,$,kw).call(this,r)}]});p(this,$,_r).call(this,i.stopReason==="cancelled"?"cancelled":"final"),p(this,$,bn).call(this,"ready")}catch(i){throw p(this,$,Ew).call(this)||(p(this,$,_r).call(this,"error"),p(this,$,bn).call(this,"ready")),i}}async startNewSession(){var r;await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await p(this,$,Eh).call(this,"ready"));const e=p(this,$,Al).call(this);((r=l(this,Xt))==null?void 0:r.sessionIdStrategy)==="mapped"?l(this,qn).clearActualSessionId(e):b(this,Bi,l(this,Bi)+1),b(this,It,null),b(this,En,null),b(this,Jt,null),b(this,Ct,null),p(this,$,Ch).call(this)}async cancel(){this.status==="running"&&(p(this,$,bn).call(this,"cancelling"),await p(this,$,El).call(this).cancel({sessionId:p(this,$,Th).call(this)}))}setScreenContext(e){var s,o,a;if(e===null){if(l(this,Xe)===null)return;b(this,Xe,null),b(this,An,!1);return}const r={screenID:e.screenID,screenName:e.screenName};if(((s=l(this,Xe))==null?void 0:s.screenID)===r.screenID&&((o=l(this,Xe))==null?void 0:o.screenName)===r.screenName)return;const i=((a=l(this,Xe))==null?void 0:a.screenID)??null;if(b(this,Xe,r),l(this,en)==="single_session"){(!l(this,Ct)||i!==r.screenID)&&b(this,An,!0);return}l(this,Ct)!==p(this,$,$h).call(this,r.screenID)&&(b(this,It,null),b(this,En,null),l(this,Kt)&&this.status==="ready"&&p(this,$,xl).call(this).catch(c=>{p(this,$,$i).call(this,Nu(c))}))}}Vi=new WeakMap,Yt=new WeakMap,dt=new WeakMap,Kt=new WeakMap,Gn=new WeakMap,It=new WeakMap,En=new WeakMap,Jt=new WeakMap,Xt=new WeakMap,qn=new WeakMap,Ct=new WeakMap,Bi=new WeakMap,ji=new WeakMap,Qt=new WeakMap,Xe=new WeakMap,An=new WeakMap,Gi=new WeakMap,Nr=new WeakMap,Tn=new WeakMap,Yn=new WeakMap,No=new WeakMap,Rt=new WeakMap,en=new WeakMap,ac=new WeakMap,tn=new WeakMap,$=new WeakSet,Eh=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((r,i)=>{const s=()=>{this.removeEventListener("status-changed",o)},o=()=>{if(this.status===e){s(),r();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:r,metadata:i}=await oO({serverURL:l(this,Rt).serverURL,token:l(this,Rt).token,createSocket:l(this,No),onDisconnect:l(this,ac)});b(this,Xt,i),b(this,tn,r),r.addEventListener("close",l(this,Uo)),r.addEventListener("error",l(this,Fo)),b(this,Kt,new Bz(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:$L,clientCapabilities:{},clientInfo:Qz})}catch(e){throw e}},fw=function(e){p(this,$,$i).call(this,Nu(e))},gw=function(e){const r=e==null?void 0:e.models;if(!(r!=null&&r.currentModelId))return;const i=r.availableModels.find(s=>s.modelId===r.currentModelId);console.info("[ACPClient] Current model:",(i==null?void 0:i.name)??r.currentModelId,`(${r.currentModelId})`)},xl=async function(){const e=p(this,$,Al).call(this);if(l(this,It)&&l(this,En)===e){await l(this,It);return}b(this,En,e),b(this,It,p(this,$,mw).call(this,e)),await l(this,It)},mw=async function(e){var c;const r=p(this,$,El).call(this);p(this,$,Ch).call(this);let i,s=!1,o=null;const a={cwd:p(this,$,xw).call(this),mcpServers:[],_meta:{sessionKey:e}};try{if(b(this,Nr,!0),b(this,Tn,null),((c=l(this,Xt))==null?void 0:c.sessionIdStrategy)==="mapped"){const u=l(this,qn).getActualSessionId(e);if(u)try{const h=await r.loadSession({...a,sessionId:u});if(rO(h))throw new Error("Mapped ACP session was not found");o=h,i=u,s=!0}catch{const h=await r.newSession(a);o=h,i=h.sessionId,l(this,qn).setActualSessionId(e,i),s=!1}else{const h=await r.newSession(a);o=h,i=h.sessionId,l(this,qn).setActualSessionId(e,i),s=!1}}else try{o=await r.loadSession({...a,sessionId:e}),i=e,s=l(this,dt).size>0}catch{const u=await r.newSession(a);o=u,i=u.sessionId,s=!1}}finally{b(this,Nr,!1),b(this,Tn,null),p(this,$,_r).call(this,"final")}p(this,$,gw).call(this,o),await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),b(this,Jt,i),b(this,Ct,e),b(this,Gi,!0),s?(l(this,Yn).add(e),l(this,en)==="single_session"&&b(this,An,!1)):(l(this,Yn).delete(e),b(this,An,l(this,en)==="single_session")),b(this,Yt,null),p(this,$,bn).call(this,"ready")},vw=async function(e){const r=e.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&p(this,$,_w).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&p(this,$,bw).call(this,r.content.text);return;case"tool_call":p(this,$,ww).call(this,r);return;case"tool_call_update":p(this,$,Sw).call(this,r);return;case"agent_thought_chunk":return;default:return}},yw=async function(e){return{outcome:{outcome:"cancelled"}}},bw=function(e){b(this,Tn,null);const r=sO(e);if(!r)return;if(!l(this,Qt)){const s={id:p(this,$,Ti).call(this,"assistant"),kind:"assistant",text:r,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}${r}`,status:"streaming"})},ww=function(e){p(this,$,_r).call(this,"final");const r=p(this,$,Ah).call(this,e.toolCallId),i=hm("content"in e?e.content:void 0),s={id:(r==null?void 0:r.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:(r==null?void 0:r.text)??i,locations:e.locations??(r==null?void 0:r.locations)};if(r){p(this,$,Ai).call(this,s);return}p(this,$,Ei).call(this,s)},Sw=function(e){const r=p(this,$,Ah).call(this,e.toolCallId),i=(r==null?void 0:r.text)??"",s=hm(e.content),o=s?`${i}${s}`:i,a={id:(r==null?void 0:r.id)??p(this,$,Ti).call(this,"tool"),kind:"tool_call",toolCallId:e.toolCallId,title:(r==null?void 0:r.title)??e.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:e.status==="failed"?"failed":e.status==="completed"?"completed":"in_progress",text:o,locations:e.locations??(r==null?void 0:r.locations)};if(r){p(this,$,Ai).call(this,a);return}p(this,$,Ei).call(this,a)},_w=function(e){if(p(this,$,_r).call(this,"final"),!e)return;const r=l(this,Nr)?l(this,Tn):null;if(!r){const s=um(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,Nr)&&b(this,Tn,o.id);return}const i=l(this,dt).get(r);if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");p(this,$,Ai).call(this,{...i,text:um(`${i.text}${e}`)})},_r=function(e){if(!l(this,Qt))return;const r=l(this,dt).get(l(this,Qt));(r==null?void 0:r.kind)==="assistant"&&p(this,$,Ai).call(this,{...r,status:e}),b(this,Qt,null)},Ei=function(e){l(this,dt).set(e.id,e),this.dispatchEvent(new Pu("messages-changed"))},Ai=function(e){l(this,dt).set(e.id,e),this.dispatchEvent(new Pu("messages-changed"))},bn=function(e){l(this,Vi)!==e&&(b(this,Vi,e),this.dispatchEvent(new kT("status-changed")))},kw=function(e){const r=l(this,Ct);if(!r)return e;const i=l(this,Xe)?l(this,en)==="single_session"?l(this,An)||!l(this,Yn).has(r):!l(this,Yn).has(r):!1,s=l(this,Gi)&&(l(this,Xe)!==null||Kz.test(e));if(!(s||i))return e;s&&b(this,Gi,!1),i&&(b(this,An,!1),l(this,Yn).add(r));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 r=`${e}-${l(this,ji)}`;return b(this,ji,l(this,ji)+1),r},Ah=function(e){for(const r of l(this,dt).values())if((r==null?void 0:r.kind)==="tool_call"&&r.toolCallId===e)return r;return null},Th=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 r;const e=(r=l(this,Xt))==null?void 0:r.sessionCwd;if(!e)throw new Error("ACP bridge session cwd is not ready");return e},Al=function(){var r;if(l(this,en)==="single_session")return p(this,$,Ih).call(this,`${dw}-${(l(this,Rt).clientGUID??"default-client").toLowerCase()}`);const e=(r=l(this,Xe))==null?void 0:r.screenID;if(!e)throw new Error("Screen context is required for per-screen session mode");return p(this,$,$h).call(this,e)},$h=function(e){return p(this,$,Ih).call(this,iO(l(this,en),e,l(this,Rt).clientGUID??"default-client"))},Ih=function(e){var r;return((r=l(this,Xt))==null?void 0:r.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,Gn,null),b(this,It,null),b(this,En,null),b(this,Jt,null),b(this,Ct,null),b(this,Xt,null),l(this,tn)&&(l(this,tn).removeEventListener("close",l(this,Uo)),l(this,tn).removeEventListener("error",l(this,Fo)),l(this,tn).close(),b(this,tn,null))},$i=function(e){const r=l(this,Kt)!==null||l(this,Gn)!==null||l(this,It)!==null||l(this,En)!==null||l(this,Jt)!==null||l(this,Ct)!==null||l(this,Xt)!==null||l(this,tn)!==null;this.disposed||this.status==="disconnected"&&!r||(p(this,$,_r).call(this,"error"),p(this,$,Tl).call(this),b(this,Yt,e??null),p(this,$,bn).call(this,"disconnected"))},Ch=function(){const e=l(this,dt).size>0;b(this,Qt,null),b(this,Tn,null),b(this,ji,1),l(this,dt).clear(),e&&this.dispatchEvent(new Pu("messages-changed"))},Ew=function(){return this.status==="disconnected"};function nO(){const n=new Map;return{getActualSessionId(t){return n.get(t)??null},setActualSessionId(t,e){n.set(t,e)},clearActualSessionId(t){n.delete(t)}}}function rO(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function iO(n,t,e){return n==="single_session"?`${dw}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function Aw(n){return n.replace(/^(?:\s*\n)+/,"")}function um(n){let t=n;return t=t.replace(Gz,""),t=t.replace(qz,""),t=t.replace(Yz,""),t=Aw(t),t}function sO(n){let t=n;return t=t.replace(Jz,""),t=Aw(t),t}function hm(n){return!n||n.length===0?"":n.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function oO(n){const t=n.createSocket(cO(n.serverURL,n.token));let e=!1,r,i;const s=new Promise((u,h)=>{r=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=lO(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=aO(L)}catch(V){const N=V instanceof Error?V:new Error(String(V));e||i(N),u.error(N);return}e||(e=!0,r(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=n.onDisconnect)==null||I.call(n,x),u.close()},E=()=>{var I;if(h)return;h=!0;const x=new Error("ACP bridge websocket error");e||i(x),(I=n.onDisconnect)==null||I.call(n,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 aO(n){const{agent:t,sessionIdStrategy:e,sessionCwd:r}=n;if((t==="openclaw"||t==="hermes")&&(e==="deterministic"||e==="mapped")&&typeof r=="string"&&r.length>0)return{agent:t,sessionIdStrategy:e,sessionCwd:r};throw new Error("ACP bridge ready status missing bootstrap metadata")}function lO(n){if(typeof n=="string")return n;if(n instanceof Uint8Array)return new TextDecoder().decode(n);if(typeof Buffer<"u"&&n instanceof Buffer)return n.toString("utf8");if(typeof n=="object"&&n!==null&&"data"in n){const t=n.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 cO(n,t){const e=new URL(n);return e.protocol=e.protocol==="https:"?"wss:":"ws:",e.pathname="/acp",e.search="",e.searchParams.set("token",t),e.hash="",e.toString()}function Nu(n){return n instanceof Error?n.message:String(n)}const dm="television.acpClientGUID",pm="television.acpMappedSessions",fm=1;var qi;class uO{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,Rh;class hO{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 r=p(this,pt,Il).call(this);r[p(this,pt,$l).call(this,t)]=e,p(this,pt,Rh).call(this,r)}clearActualSessionId(t){const e=p(this,pt,Il).call(this);delete e[p(this,pt,$l).call(this,t)],p(this,pt,Rh).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(pm);if(!t)return{};let e;try{e=JSON.parse(t)}catch{return{}}if(typeof e!="object"||e===null||Array.isArray(e))return{};const r=e;return r.version!==fm?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},Rh=function(t){const e={version:fm,entries:t};l(this,Yi).setItem(pm,JSON.stringify(e))};function Tw(){return typeof window>"u"?null:window.localStorage}function dO(n){const t=n.getItem(dm);if(t)return t;const e=Cc().toLowerCase();return n.setItem(dm,e),e}const gm=4401,pO=401,cl=1e3,fO=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 YT(c,{token:u??void 0,onUnauthorized:()=>this.handleAuthRejected(),...h?{telemetryMeta:h}:{}})),this.client=this.createClient(this.url,this._token,this.telemetryMeta);const r=e.mappedSessionStore??(e.acpStorage?new hO(e.acpStorage,this.url):new uO);this.acpClient=new tO({serverURL:this.url,token:this._token??"",...e.createACPSocket?{createSocket:e.createACPSocket}:e.createSocket?{createSocket:e.createSocket}:{},...e.clientGUID?{clientGUID:e.clientGUID}:{},mappedSessionStore:r}),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?EL({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,r,i,s;this.autoReconnect=!1,this.connectAttempt+=1,this.cancelRetryTimer(),(e=this.socket)==null||e.close(),this.socket=null,this.setStatus("unauthorized"),(r=this.visibilityEventTarget)==null||r.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 r=Yl(e,{electron:un()});return un()?new URL(r.viewURL,this.url).toString():r.renderer==="proxy-iframe"?new URL(r.viewURL,this.url).toString():r.viewURL}getContentURL(e){const r=Yl(e,{electron:un()}).contentURL;return r===null?null:new URL(r,this.url).toString()}async createScreen(e){const{screen:r}=await this.client.screens.create({name:e});return this.screens.set(r.id,structuredClone(r)),r}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 r=this.screens.get(e.screenID);r&&!_l(r).includes(e.artifact.id)&&(r.layout=[...r.layout,Cy(e.artifact.id)]);break}case"artifact-removed":{const r=this.screens.get(e.screenID);r&&(r.layout=wy(r.layout,e.artifactID));break}case"artifact-updated":case"artifact-content-changed":case"screen-changed":case"theme-changed":case"artifact-focus":break;default:return gO(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 r=this.createSocket(mO(this.url,this._token,this.telemetryMeta));return this.socket=r,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 gh("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(bO(y)){u(new ho);return}u(y instanceof Error?y:new Error(String(y)))}};r.addEventListener("open",()=>{h()}),r.addEventListener("message",f=>{const y=yO(f);y&&(this.applyServerEvent(y),this.dispatchEvent(new gh("server-event",{serverURL:this.url,event:y})))}),r.addEventListener("close",f=>{if(this.connectAttempt!==e)return;this.socket=null;const y=vO(f);if(!a){u(y===gm?new ho:new Error("Connection closed before initialization"));return}if(y===gm){this.handleAuthRejected();return}this.handleTransportFailure(new Error("Connection closed"))}),r.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,fO),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 r;this.status==="connected"&&((r=this.socket)==null||r.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 gO(n,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(n)}`)}function mO(n,t,e=null){const r=new URL(n);if(r.protocol=r.protocol==="https:"?"wss:":"ws:",r.pathname="/events",r.search="",t&&r.searchParams.set("token",t),e)for(const[i,s]of xL(e))r.searchParams.set(i,s);return r.hash="",r.toString()}function vO(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}function yO(n){const t=typeof n=="string"?n:typeof n=="object"&&n!==null&&"data"in n&&typeof n.data=="string"?n.data:"";if(!t)return null;try{return JSON.parse(t)}catch{return null}}function bO(n){return n instanceof tp&&n.status===pO}const wO="Local";var Zo,Ph;class SO 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 r=e.acpStorage===void 0?Tw():e.acpStorage;this.acpStorage=r,this.clientGUID=e.clientGUID??(r?dO(r):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 r=he(e.url);this.servers.get(r)&&this.remove(r),this.servers.set(r,e);const s=()=>{this.dispatchEvent(new oe("change"))},o=u=>{this.dispatchEvent(new gh("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(r,{onServerChange:s,onServerEvent:o,onScreensChanged:a,onServerReconnected:c}),this.dispatchEvent(new oe("change"))}remove(e){const r=he(e);if(this.localServerURL&&r===this.localServerURL)return;const i=this.servers.get(r);if(!i)return;const s=this.serverListeners.get(r);s&&(i.removeEventListener("change",s.onServerChange),i.removeEventListener("server-event",s.onServerEvent),i.removeEventListener("screens-changed",s.onScreensChanged),i.removeEventListener("server-reconnected",s.onServerReconnected),this.serverListeners.delete(r)),i.dispose(),this.servers.delete(r);const o=this.localStore.get(),a=o.activeServerURL===r;this.localStore.set({...o,servers:o.servers.filter(c=>c.url!==r),activeServerURL:a?null:o.activeServerURL}),this.dispatchEvent(new oe("change"))}getStoredAuthToken(e){return Du(this.localStore.get(),e)}setStoredAuthToken(e,r){this.localStore.set(s$(this.localStore.get(),e,r))}clearStoredAuthToken(e){const r=this.localStore.get(),i=o$(r,e);i!==r&&this.localStore.set(i)}setActive(e){const r=this.localStore.get(),i=e?he(e.url):null;r.activeServerURL!==i&&this.localStore.set({...r,activeServerURL:i})}connectConfiguredServers(e,r){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:wO}]})}const s=this.localStore.get().servers;for(const a of s){const c=he(a.url),h=i!==null&&c===i?r??Du(this.localStore.get(),c):Du(this.localStore.get(),c),f=p(this,Zo,Ph).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,r){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:r}]});const o=p(this,Zo,Ph).call(this,{url:i,name:r,token:this.getStoredAuthToken(i)});this.add(o),this.setActive(o),o.connect(o.token).catch(()=>{})}removeServer(e){this.remove(e)}}Zo=new WeakSet,Ph=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 _O extends Nt{constructor(){super();w(this,Wo,e=>{const r=kO(e);r!==null&&(e.preventDefault(),this.dispatchEvent(new _T("shortcut-triggered",{shortcut:r})))});document.addEventListener("keydown",l(this,Wo))}dispose(){document.removeEventListener("keydown",l(this,Wo))}}Wo=new WeakMap;function kO(n){for(const[t,e]of Object.entries(KT))if(xO(n,e.trigger))return t;return null}function xO(n,t){return!(n.key.toLowerCase()!==t.key.toLowerCase()||n.metaKey!==!!t.meta||n.ctrlKey!==!!t.ctrl||n.shiftKey!==!!t.shift||n.altKey!==!!t.alt)}const Lh="tv-nav:",vs="tv-reload",mm=100,EO=1e3,AO=60,TO=60,$O=24,IO=30,CO=IO*$O*TO*AO*EO;function Ln(n){try{const t=new URL(n,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():n}catch{return n}}var Vo,Ki,ue,re,Ur,ke,Iw,Fn,Cw,Dh,zh;class RO extends Nt{constructor(e,r){super();w(this,ke);w(this,Vo);w(this,Ki);w(this,ue,[]);w(this,re,-1);w(this,Ur,0);b(this,Vo,e),b(this,Ki,Ln(r)),p(this,ke,Iw).call(this)}get currentURL(){var e;return l(this,re)===-1?null:((e=l(this,ue)[l(this,re)])==null?void 0:e.url)??null}get canGoBack(){return l(this,re)>-1}get canGoForward(){return l(this,re)<l(this,ue).length-1}get entries(){return l(this,ue).map(e=>({...e}))}get cursor(){return l(this,re)}navigate(e){const r=Ln(e);if(r===l(this,Ki)){if(l(this,re)===-1)return;b(this,re,-1),p(this,ke,Fn).call(this);return}l(this,re)<l(this,ue).length-1&&b(this,ue,l(this,ue).slice(0,l(this,re)+1)),l(this,ue).push({url:r}),b(this,re,l(this,ue).length-1),p(this,ke,Dh).call(this),p(this,ke,Fn).call(this)}replace(e){var i;if(l(this,re)===-1){this.navigate(e);return}const r=Ln(e);if(r===l(this,Ki)){b(this,ue,l(this,ue).filter((s,o)=>o!==l(this,re))),b(this,re,-1),p(this,ke,Fn).call(this);return}((i=l(this,ue)[l(this,re)])==null?void 0:i.url)!==r&&(b(this,ue,l(this,ue).map((s,o)=>o===l(this,re)?{url:r}:s)),p(this,ke,Fn).call(this))}back(){l(this,re)!==-1&&(b(this,re,l(this,re)-1),p(this,ke,Fn).call(this))}forward(){this.canGoForward&&(b(this,re,l(this,re)+1),p(this,ke,Fn).call(this))}reset(){l(this,re)===-1&&l(this,ue).length===0||(b(this,ue,[]),b(this,re,-1),p(this,ke,Fn).call(this))}}Vo=new WeakMap,Ki=new WeakMap,ue=new WeakMap,re=new WeakMap,Ur=new WeakMap,ke=new WeakSet,Iw=function(){const e=localStorage.getItem(l(this,ke,zh));if(e!==null)try{const r=JSON.parse(e);if(!Rw(r))return;b(this,ue,r.entries.map(i=>({url:i.url}))),b(this,re,r.cursor),b(this,Ur,r.lastWritten),p(this,ke,Dh).call(this)}catch{b(this,ue,[]),b(this,re,-1),b(this,Ur,0)}},Fn=function(){b(this,Ur,Date.now());try{localStorage.setItem(l(this,ke,zh),JSON.stringify(p(this,ke,Cw).call(this)))}catch(e){if(!DO(e))throw e}this.dispatchEvent(new oe("change"))},Cw=function(){return{v:1,entries:l(this,ue).map(e=>({...e})),cursor:l(this,re),lastWritten:l(this,Ur)}},Dh=function(){if(l(this,ue).length<=mm)return;const e=l(this,ue).length-mm;b(this,ue,l(this,ue).slice(e)),b(this,re,Math.max(-1,l(this,re)-e))},zh=function(){return PO(l(this,Vo))};function PO(n){return`${Lh}${n}`}function LO(n){const t=Date.now()-CO,e=[];for(let r=0;r<localStorage.length;r+=1){const i=localStorage.key(r);if(!(i!=null&&i.startsWith(Lh)))continue;const s=i.slice(Lh.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}!n.has(s)&&a.lastWritten<t&&e.push(i)}for(const r of e)localStorage.removeItem(r)}function DO(n){return n instanceof DOMException&&n.name==="QuotaExceededError"}function Rw(n){if(typeof n!="object"||n===null)return!1;const t=n;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(r=>typeof r=="object"&&r!==null&&typeof r.url=="string")}let Un=null;async function Pw(n,t){if(Un==null||Un.abort(),n===null){Un=null,Vl();return}const e=new AbortController;Un=e;try{const r=t.token?{Authorization:`Bearer ${t.token}`}:void 0,i=new URL(`/themes/${n}/theme.css`,t.url).toString(),s=await fetch(i,{signal:e.signal,...r?{headers:r}:{}});if(!s.ok)throw new Error(`Theme fetch failed: ${s.status}`);const o=await s.text();if(Un!==e)return;vy(o)}catch(r){if(r.name==="AbortError")return;Vl();const i=r instanceof Error?r.message:String(r);console.warn(`applyTheme: ${i}`)}finally{Un===e&&(Un=null)}}/**
44
- * @license
45
- * Copyright 2017 Google LLC
46
- * SPDX-License-Identifier: BSD-3-Clause
47
- */const po=globalThis,vm=n=>n,Kl=po.trustedTypes,ym=Kl?Kl.createPolicy("lit-html",{createHTML:n=>n}):void 0,Lw="$lit$",Zn=`lit$${Math.random().toFixed(9).slice(2)}$`,Dw="?"+Zn,zO=`<${Dw}>`,ti=document,So=()=>ti.createComment(""),_o=n=>n===null||typeof n!="object"&&typeof n!="function",hp=Array.isArray,OO=n=>hp(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",Uu=`[
48
- \f\r]`,Us=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,bm=/-->/g,wm=/>/g,vr=RegExp(`>|${Uu}(?:([^\\s"'>=/]+)(${Uu}*=${Uu}*(?:[^
49
- \f\r"'\`<>=]|("|')|))|$)`,"g"),Sm=/'/g,_m=/"/g,zw=/^(?:script|style|textarea|title)$/i,MO=n=>(t,...e)=>({_$litType$:n,strings:t,values:e}),P=MO(1),ni=Symbol.for("lit-noChange"),le=Symbol.for("lit-nothing"),km=new WeakMap,Cr=ti.createTreeWalker(ti,129);function Ow(n,t){if(!hp(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return ym!==void 0?ym.createHTML(t):t}const NO=(n,t)=>{const e=n.length-1,r=[];let i,s=t===2?"<svg>":t===3?"<math>":"",o=Us;for(let a=0;a<e;a++){const c=n[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=bm:h[1]!==void 0?o=wm:h[2]!==void 0?(zw.test(h[2])&&(i=RegExp("</"+h[2],"g")),o=vr):h[3]!==void 0&&(o=vr):o===vr?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?vr:h[3]==='"'?_m:Sm):o===_m||o===Sm?o=vr:o===bm||o===wm?o=Us:(o=vr,i=void 0);const m=o===vr&&n[a+1].startsWith("/>")?" ":"";s+=o===Us?c+zO:f>=0?(r.push(u),c.slice(0,f)+Lw+c.slice(f)+Zn+m):c+Zn+(f===-2?a:m)}return[Ow(n,s+(n[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),r]};class ko{constructor({strings:t,_$litType$:e},r){let i;this.parts=[];let s=0,o=0;const a=t.length-1,c=this.parts,[u,h]=NO(t,e);if(this.el=ko.createElement(u,r),Cr.currentNode=this.el.content,e===2||e===3){const f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(i=Cr.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(Zn),E=/([.?@])?(.*)/.exec(y);c.push({type:1,index:s,name:E[2],strings:m,ctor:E[1]==="."?FO:E[1]==="?"?HO:E[1]==="@"?ZO:Hc}),i.removeAttribute(f)}else f.startsWith(Zn)&&(c.push({type:6,index:s}),i.removeAttribute(f));if(zw.test(i.tagName)){const f=i.textContent.split(Zn),y=f.length-1;if(y>0){i.textContent=Kl?Kl.emptyScript:"";for(let m=0;m<y;m++)i.append(f[m],So()),Cr.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(Zn,f+1))!==-1;)c.push({type:7,index:s}),f+=Zn.length-1}s++}}static createElement(t,e){const r=ti.createElement("template");return r.innerHTML=t,r}}function ys(n,t,e=n,r){var o,a;if(t===ni)return t;let i=r!==void 0?(o=e._$Co)==null?void 0:o[r]: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(n),i._$AT(n,e,r)),r!==void 0?(e._$Co??(e._$Co=[]))[r]=i:e._$Cl=i),i!==void 0&&(t=ys(n,i._$AS(n,t.values),i,r)),t}class UO{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:r}=this._$AD,i=((t==null?void 0:t.creationScope)??ti).importNode(e,!0);Cr.currentNode=i;let s=Cr.nextNode(),o=0,a=0,c=r[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 WO(s,this,t)),this._$AV.push(u),c=r[++a]}o!==(c==null?void 0:c.index)&&(s=Cr.nextNode(),o++)}return Cr.currentNode=ti,i}p(t){let e=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(t,r,e),e+=r.strings.length-2):r._$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,r,i){this.type=2,this._$AH=le,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=r,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!==ni&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):OO(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$:r}=t,i=typeof r=="number"?this._$AC(t):(r.el===void 0&&(r.el=ko.createElement(Ow(r.h,r.h[0]),this.options)),r);if(((s=this._$AH)==null?void 0:s._$AD)===i)this._$AH.p(e);else{const o=new UO(i,this),a=o.u(this.options);o.p(e),this.T(a),this._$AH=o}}_$AC(t){let e=km.get(t.strings);return e===void 0&&km.set(t.strings,e=new ko(t)),e}k(t){hp(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let r,i=0;for(const s of t)i===e.length?e.push(r=new Mw(this.O(So()),this.O(So()),this,this.options)):r=e[i],r._$AI(s),i++;i<e.length&&(this._$AR(r&&r._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,e);t!==this._$AB;){const i=vm(t).nextSibling;vm(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,r,i,s){this.type=1,this._$AH=le,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=s,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=le}_$AI(t,e=this,r,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!==ni,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[r+c],e,c),u===ni&&(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??"")}},FO=class extends Hc{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===le?void 0:t}},HO=class extends Hc{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==le)}},ZO=class extends Hc{constructor(t,e,r,i,s){super(t,e,r,i,s),this.type=5}_$AI(t,e=this){if((t=ys(this,t,e,0)??le)===ni)return;const r=this._$AH,i=t===le&&r!==le||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,s=t!==le&&(r===le||i);i&&this.element.removeEventListener(this.name,this,r),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 WO{constructor(t,e,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){ys(this,t)}}const VO={I:Fc},Fu=po.litHtmlPolyfillSupport;Fu==null||Fu(ko,Fc),(po.litHtmlVersions??(po.litHtmlVersions=[])).push("3.3.2");const Ve=(n,t,e)=>{const r=t;let i=r._$litPart$;return i===void 0&&(r._$litPart$=i=new Fc(t.insertBefore(So(),null),null,void 0,{})),i._$AI(n),i};/**
50
- * @license
51
- * Copyright 2017 Google LLC
52
- * SPDX-License-Identifier: BSD-3-Clause
53
- */const dp={CHILD:2},Zc=n=>(...t)=>({_$litDirective$:n,values:t});let pp=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,r){this._$Ct=t,this._$AM=e,this._$Ci=r}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};/**
54
- * @license
55
- * Copyright 2017 Google LLC
56
- * SPDX-License-Identifier: BSD-3-Clause
57
- */let Jl=class extends pp{constructor(t){if(super(t),this.it=le,t.type!==dp.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===ni)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 BO=Zc(Jl);/**
58
- * @license
59
- * Copyright 2017 Google LLC
60
- * SPDX-License-Identifier: BSD-3-Clause
61
- */let Oh=class extends Jl{};Oh.directiveName="unsafeSVG",Oh.resultType=2;const Nw=Zc(Oh),jO={size:16,color:"currentColor",weight:"regular"};function GO(n){return typeof n=="string"?{regular:n}:n}function At(n,t="0 0 256 256"){const e=GO(n);return r=>{const{size:i,color:s,weight:o}={...jO,...r},a=e[o]??e.regular;return P`<svg
62
- xmlns="http://www.w3.org/2000/svg"
63
- data-ui-icon=""
64
- width="${i}"
65
- height="${i}"
66
- viewBox="${t}"
67
- fill="${s}"
68
- >${Nw(a)}</svg>`}}/**
69
- * @license
70
- * Copyright 2020 Google LLC
71
- * SPDX-License-Identifier: BSD-3-Clause
72
- */const{I:qO}=VO,xm=n=>n,YO=n=>n.strings===void 0,Em=()=>document.createComment(""),Fs=(n,t,e)=>{var s;const r=n._$AA.parentNode,i=t===void 0?n._$AB:t._$AA;if(e===void 0){const o=r.insertBefore(Em(),i),a=r.insertBefore(Em(),i);e=new qO(o,a,n,n.options)}else{const o=e._$AB.nextSibling,a=e._$AM,c=a!==n;if(c){let u;(s=e._$AQ)==null||s.call(e,n),e._$AM=n,e._$AP!==void 0&&(u=n._$AU)!==a._$AU&&e._$AP(u)}if(o!==i||c){let u=e._$AA;for(;u!==o;){const h=xm(u).nextSibling;xm(r).insertBefore(u,i),u=h}}}return e},yr=(n,t,e=n)=>(n._$AI(t,e),n),KO={},JO=(n,t=KO)=>n._$AH=t,XO=n=>n._$AH,Hu=n=>{n._$AR(),n._$AA.remove()};/**
73
- * @license
74
- * Copyright 2017 Google LLC
75
- * SPDX-License-Identifier: BSD-3-Clause
76
- */const fo=(n,t)=>{var r;const e=n._$AN;if(e===void 0)return!1;for(const i of e)(r=i._$AO)==null||r.call(i,t,!1),fo(i,t);return!0},Xl=n=>{let t,e;do{if((t=n._$AM)===void 0)break;e=t._$AN,e.delete(n),n=t}while((e==null?void 0:e.size)===0)},Uw=n=>{for(let t;t=n._$AM;n=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(n))break;e.add(n),tM(t)}};function QO(n){this._$AN!==void 0?(Xl(this),this._$AM=n,Uw(this)):this._$AM=n}function eM(n,t=!1,e=0){const r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(t)if(Array.isArray(r))for(let s=e;s<r.length;s++)fo(r[s],!1),Xl(r[s]);else r!=null&&(fo(r,!1),Xl(r));else fo(this,n)}const tM=n=>{n.type==dp.CHILD&&(n._$AP??(n._$AP=eM),n._$AQ??(n._$AQ=QO))};class nM extends pp{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,r){super._$AT(t,e,r),Uw(this),this.isConnected=t._$AU}_$AO(t,e=!0){var r,i;t!==this.isConnected&&(this.isConnected=t,t?(r=this.reconnected)==null||r.call(this):(i=this.disconnected)==null||i.call(this)),e&&(fo(this,t),Xl(this))}setValue(t){if(YO(this._$Ct))this._$Ct._$AI(t,this);else{const e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}}/**
77
- * @license
78
- * Copyright 2020 Google LLC
79
- * SPDX-License-Identifier: BSD-3-Clause
80
- */const Xs=()=>new rM;class rM{}const Zu=new WeakMap,Qs=Zc(class extends nM{render(n){return le}update(n,[t]){var r;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=(r=n.options)==null?void 0:r.host,this.rt(this.ct=n.element)),le}rt(n){if(this.isConnected||(n=void 0),typeof this.G=="function"){const t=this.ht??globalThis;let e=Zu.get(t);e===void 0&&(e=new WeakMap,Zu.set(t,e)),e.get(this.G)!==void 0&&this.G.call(this.ht,void 0),e.set(this.G,n),n!==void 0&&this.G.call(this.ht,n)}else this.G.value=n}get lt(){var n,t;return typeof this.G=="function"?(n=Zu.get(this.ht??globalThis))==null?void 0:n.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)}}),fp=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"/>'),iM=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"/>'),sM=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"/>'),oM=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"/>'),aM=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"/>'}),lM=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"/>'}),cM=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"/>'}),uM=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"/>'),hM=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"/>'}),dM=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 pM extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}const Am='a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])',Wu=4;var Fe,st,Fr,ot,Bo,Ji,Xi,W,Mh,Nh,Zw,Cl,Ww,Uh,Fh,jo,Go,Hr,Vw,Hh,Bw,jw,Rl,Ii;class Hw extends HTMLElement{constructor(){super();w(this,W);w(this,Fe,!1);w(this,st,null);w(this,Fr);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,Hr,()=>{l(this,Fe)&&p(this,W,Rl).call(this)});b(this,Fr,this.attachShadow({mode:"open"})),Xd(l(this,Fr)),p(this,W,Nh).call(this,"anchor")}connectedCallback(){this.removeAttribute("popover"),this.hasAttribute("tone")||this.setAttribute("tone","light"),p(this,W,Nh).call(this,"open"),p(this,W,Ii).call(this),l(this,Fe)&&(p(this,W,Uh).call(this),p(this,W,Cl).call(this))}disconnectedCallback(){var e;p(this,W,Fh).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,Mh).call(this),l(this,Fe)&&p(this,W,Rl).call(this))}}Fe=new WeakMap,st=new WeakMap,Fr=new WeakMap,ot=new WeakMap,Bo=new WeakMap,Ji=new WeakMap,Xi=new WeakMap,W=new WeakSet,Mh=function(){l(this,st)&&l(this,st).setAttribute("aria-expanded",l(this,Fe)?"true":"false")},Nh=function(e){if(!Object.prototype.hasOwnProperty.call(this,e))return;const r=this,i=r[e];delete r[e],r[e]=i},Zw=function(e){var r,i,s;if(l(this,Fe)!==e){if(b(this,Fe,e),p(this,W,Mh).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,Uh).call(this),p(this,W,Cl).call(this)):(p(this,W,Fh).call(this),(i=(r=l(this,ot))==null?void 0:r.hidePopover)==null||i.call(r),p(this,W,Ii).call(this),(s=l(this,st))==null||s.focus(),this.dispatchEvent(new pM))}},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,r;if(l(this,ot)){try{(r=(e=l(this,ot)).showPopover)==null||r.call(e)}catch{}p(this,W,Rl).call(this)}},Uh=function(){document.addEventListener("click",l(this,jo)),document.addEventListener("keydown",l(this,Go),!0),window.addEventListener("resize",l(this,Hr)),window.addEventListener("scroll",l(this,Hr),!0)},Fh=function(){document.removeEventListener("click",l(this,jo)),document.removeEventListener("keydown",l(this,Go),!0),window.removeEventListener("resize",l(this,Hr)),window.removeEventListener("scroll",l(this,Hr),!0)},jo=new WeakMap,Go=new WeakMap,Hr=new WeakMap,Vw=function(e){const r=p(this,W,Hh).call(this);if(r.length===0){e.preventDefault();return}const i=r[0],s=r[r.length-1],o=p(this,W,Bw).call(this),a=o instanceof HTMLElement&&r.includes(o);e.shiftKey?(!a||o===i)&&(e.preventDefault(),s.focus()):(!a||o===s)&&(e.preventDefault(),i.focus())},Hh=function(){if(!l(this,ot))return[];const e=l(this,ot).querySelector("slot");if(!(e instanceof HTMLSlotElement))return[];const r=[];for(const i of e.assignedElements({flatten:!0}))if(i instanceof HTMLElement){i.matches(Am)&&r.push(i);for(const s of i.querySelectorAll(Am))r.push(s)}return r},Bw=function(){var r;let e=document.activeElement;for(;e&&((r=e.shadowRoot)!=null&&r.activeElement);)e=e.shadowRoot.activeElement;return e},jw=function(){var r;const e=p(this,W,Hh).call(this);e.length>0?e[0].focus():(r=l(this,ot))==null||r.focus()},Rl=function(){if(!l(this,Fe)||!l(this,st)||!l(this,ot))return;const e=l(this,st).getBoundingClientRect(),r=l(this,ot).getBoundingClientRect(),s=window.innerHeight-e.bottom,o=r.height+Wu,a=s<o&&e.top>o?"top-start":"bottom-start";b(this,Bo,a);const c=a==="bottom-start"?e.bottom+Wu:e.top-r.height-Wu,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
- class="panel"
82
- part="panel"
83
- popover="manual"
84
- data-placement=${l(this,Bo)}
85
- tabindex="-1"
86
- role="dialog"
87
- material=${e}
88
- level="1"
89
- >
90
- <slot></slot>
91
- </div>`:le,l(this,Fr)),b(this,ot,l(this,Fr).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 fM extends Event{constructor(e){super("select",{bubbles:!0,composed:!0});g(this,"value");this.value=e}}var at,Pt,Kn,Jn,se,qo,Yo,M,Yw,eo,Kw,Jw,Zh,Xw,to,kr,Zr,Ko,lc,Jo,cc,Qw,e0,Wh,no,Vh,Bh,wn;class qw extends HTMLElement{constructor(){super();w(this,M);w(this,at,!1);w(this,Pt,null);w(this,Kn,null);w(this,Jn);w(this,se,null);w(this,qo,Xs());w(this,Yo,new MutationObserver(e=>p(this,M,Qw).call(this,e)));w(this,Zr,()=>{p(this,M,to).call(this,!l(this,at))});w(this,Ko,e=>{e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),l(this,Zr).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,wn).call(this),this.dispatchEvent(new fM(e.value)))});w(this,cc,()=>{p(this,M,Wh).call(this)});b(this,Jn,this.attachShadow({mode:"open"})),Xd(l(this,Jn))}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,wn).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",l(this,Jo)),l(this,Yo).disconnect(),p(this,M,Bh).call(this)}attributeChangedCallback(e){if(e==="open"){p(this,M,to).call(this,this.hasAttribute("open"));return}p(this,M,wn).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,kr).call(this,null,null),p(this,M,Kw).call(this)):p(this,M,eo).call(this,e),p(this,M,wn).call(this)}close(){p(this,M,to).call(this,!1)}}at=new WeakMap,Pt=new WeakMap,Kn=new WeakMap,Jn=new WeakMap,se=new WeakMap,qo=new WeakMap,Yo=new WeakMap,M=new WeakSet,Yw=function(){var r;const e=this.querySelector("dropdown-item[selected]");e&&p(this,M,kr).call(this,e.value,((r=e.textContent)==null?void 0:r.trim())??null)},eo=function(e){var r;for(const i of l(this,M,Zh))i.value===e?(p(this,M,kr).call(this,e,((r=i.textContent)==null?void 0:r.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 r of e)r.removeAttribute("selected")},Jw=function(e){for(const r of l(this,M,Zh))if(r.value===e)return r;return null},Zh=function(){return this.querySelectorAll("dropdown-item")},Xw=function(){return l(this,Kn)??this.title},to=function(e){l(this,at)!==e&&(b(this,at,e),p(this,M,wn).call(this))},kr=function(e,r){b(this,Pt,e),b(this,Kn,r)},Zr=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 r,i;const e=this.querySelector("dropdown-item[selected]");if(e){const s=e.value,o=((r=e.textContent)==null?void 0:r.trim())??null,a=l(this,Pt)!==s||l(this,Kn)!==o;p(this,M,kr).call(this,s,o),p(this,M,eo).call(this,s),a?p(this,M,wn).call(this):p(this,M,no).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,Kn)!==o;p(this,M,kr).call(this,l(this,Pt),o),p(this,M,eo).call(this,l(this,Pt)),a?p(this,M,wn).call(this):p(this,M,no).call(this);return}}if(l(this,Pt)!==null||l(this,Kn)!==null){p(this,M,kr).call(this,null,null),p(this,M,wn).call(this);return}p(this,M,no).call(this)},Wh=function(){const e=l(this,Jn).querySelector('slot[name="trigger"]'),r=e instanceof HTMLSlotElement?e.assignedElements()[0]??null:null;l(this,se)!==r&&(p(this,M,Bh).call(this),b(this,se,r),l(this,se)&&(l(this,se).addEventListener("click",l(this,Zr)),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,no).call(this),p(this,M,Vh).call(this)},no=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"))},Vh=function(){const e=l(this,qo).value;if(!e)return;const r=l(this,Jn).querySelector("button.fallback-trigger");e.anchor=l(this,se)??r??null},Bh=function(){l(this,se)&&(l(this,se).removeEventListener("click",l(this,Zr)),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))},wn=function(){this.toggleAttribute("open",l(this,at)),Ve(P`
92
- <slot name="trigger" @slotchange=${l(this,cc)}>
93
- <button
94
- class="fallback-trigger"
95
- part="trigger"
96
- type="button"
97
- aria-haspopup="listbox"
98
- aria-expanded=${l(this,at)?"true":"false"}
99
- @click=${l(this,Zr)}
100
- >
101
- <span class="trigger-label" part="trigger-label">${l(this,M,Xw)}</span>
102
- <span class="trigger-icon" part="trigger-icon" aria-hidden="true">
103
- ${Ql({size:16})}
104
- </span>
105
- </button>
106
- </slot>
107
- <ui-popover
108
- class="dropdown-popover"
109
- material="glass-frosted"
110
- ?open=${l(this,at)}
111
- @close=${l(this,lc)}
112
- ${Qs(l(this,qo))}
113
- >
114
- ${l(this,at)?P`<div class="dropdown-list" part="list" role="listbox">
115
- <slot></slot>
116
- </div>`:le}
117
- </ui-popover>
118
- `,l(this,Jn)),p(this,M,Vh).call(this),queueMicrotask(()=>p(this,M,Wh).call(this))},g(qw,"observedAttributes",["title","open"]);class gM extends HTMLElement{}class mM extends HTMLElement{}class vM extends HTMLElement{}var si,jh,n0,Xo,Qo;class t0 extends HTMLElement{constructor(){super(...arguments);w(this,si);w(this,Xo,()=>{this.action||p(this,si,n0).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,jh).call(this)}disconnectedCallback(){this.removeEventListener("click",l(this,Xo)),this.removeEventListener("keydown",l(this,Qo))}attributeChangedCallback(){p(this,si,jh).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}}si=new WeakSet,jh=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")},n0=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",gM);customElements.get("dropdown-label")||customElements.define("dropdown-label",mM);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",vM);customElements.get("dropdown-item")||customElements.define("dropdown-item",t0);class yM extends Event{constructor(e){super("rename",{bubbles:!0,composed:!0});g(this,"value");this.value=e}}var nn,Lt,ie,He,ro,ea,Gh,Pl,qh,ta,na,ra;class r0 extends HTMLElement{constructor(){super(...arguments);w(this,He);w(this,nn,"");w(this,Lt,!1);w(this,ie,null);w(this,ea,e=>{l(this,Lt)||(e.preventDefault(),p(this,He,Gh).call(this))});w(this,ta,e=>{e.stopPropagation()});w(this,na,e=>{var r,i;e.key==="Enter"?(e.preventDefault(),p(this,He,Pl).call(this,!0),(r=l(this,ie))==null||r.blur()):e.key==="Escape"&&(e.preventDefault(),p(this,He,Pl).call(this,!1),(i=l(this,ie))==null||i.blur())});w(this,ra,()=>{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,nn,e),p(this,He,ro).call(this),this.addEventListener("dblclick",l(this,ea))}disconnectedCallback(){this.removeEventListener("dblclick",l(this,ea)),l(this,Lt)&&p(this,He,qh).call(this)}attributeChangedCallback(e){if(e==="value"){const r=this.getAttribute("value")??"";b(this,nn,r),l(this,Lt)||p(this,He,ro).call(this)}}get value(){return l(this,nn)}set value(e){b(this,nn,e),l(this,Lt)||p(this,He,ro).call(this)}startEditing(){l(this,Lt)||p(this,He,Gh).call(this)}}nn=new WeakMap,Lt=new WeakMap,ie=new WeakMap,He=new WeakSet,ro=function(){l(this,ie)&&(l(this,ie).textContent=l(this,nn),l(this,ie).scrollLeft=0)},ea=new WeakMap,Gh=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,na)),l(this,ie).addEventListener("blur",l(this,ra)),l(this,ie).addEventListener("mousedown",l(this,ta)),this.toggleAttribute("data-editing",!0),queueMicrotask(()=>{var r;if(!l(this,ie))return;l(this,ie).focus();const e=(r=this.ownerDocument.defaultView)==null?void 0:r.getSelection();e==null||e.selectAllChildren(l(this,ie))}))},Pl=function(e){if(!l(this,Lt)||!l(this,ie))return;const r=(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,qh).call(this),e&&r.length>0&&r!==l(this,nn)&&(b(this,nn,r),this.dispatchEvent(new yM(r))),p(this,He,ro).call(this)},qh=function(){var e,r,i;(e=l(this,ie))==null||e.removeEventListener("keydown",l(this,na)),(r=l(this,ie))==null||r.removeEventListener("blur",l(this,ra)),(i=l(this,ie))==null||i.removeEventListener("mousedown",l(this,ta))},ta=new WeakMap,na=new WeakMap,ra=new WeakMap,g(r0,"observedAttributes",["value"]);customElements.get("editable-text")||customElements.define("editable-text",r0);class bM extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var ia,lr,Yh,uc,sa,Kh;class i0 extends HTMLElement{constructor(){super();w(this,lr);w(this,ia);w(this,uc,e=>{e.target===e.currentTarget&&p(this,lr,Yh).call(this)});w(this,sa,e=>{this.open&&e.key==="Escape"&&p(this,lr,Yh).call(this)});b(this,ia,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",l(this,sa)),p(this,lr,Kh).call(this)}disconnectedCallback(){document.removeEventListener("keydown",l(this,sa))}attributeChangedCallback(){p(this,lr,Kh).call(this)}get open(){return this.hasAttribute("open")}}ia=new WeakMap,lr=new WeakSet,Yh=function(){this.dispatchEvent(new bM)},uc=new WeakMap,sa=new WeakMap,Kh=function(){Ve(P`
119
- ${this.open?P`
120
- <div class="backdrop" part="backdrop" @click=${l(this,uc)}>
121
- <slot></slot>
122
- </div>
123
- `:null}
124
- `,l(this,ia))},g(i0,"observedAttributes",["open"]);customElements.get("modal-overlay")||customElements.define("modal-overlay",i0);const wM=16,Vu=24,SM=32;var Qi;class s0 extends HTMLElement{constructor(){super();w(this,Qi);b(this,Qi,this.attachShadow({mode:"open"})),Xd(l(this,Qi))}connectedCallback(){this.render()}attributeChangedCallback(){this.render()}getSize(){const e=this.getAttribute("size");if(e===null)return Vu;const r=Number(e);return r===wM||r===Vu||r===SM?r:Vu}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 _M extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class kM extends HTMLElement{}var oa,aa,Jh;class o0 extends HTMLElement{constructor(){super();w(this,aa);w(this,oa);b(this,oa,this.attachShadow({mode:"open"}))}connectedCallback(){p(this,aa,Jh).call(this)}attributeChangedCallback(){p(this,aa,Jh).call(this)}get closable(){return this.hasAttribute("closable")}}oa=new WeakMap,aa=new WeakSet,Jh=function(){const e=this.querySelector("panel-page");Ve(P`
125
- <section class="panel" part="panel">
126
- <header class="title-bar" part="header">
127
- <h2 class="title" part="title">${(e==null?void 0:e.getAttribute("title"))??""}</h2>
128
- ${this.closable?P`
129
- <button
130
- type="button"
131
- class="title-button"
132
- part="button close-button"
133
- aria-label="Close"
134
- @click=${()=>this.dispatchEvent(new _M)}
135
- >
136
- <span class="close-icon" part="icon close-icon">${fp({size:16})}</span>
137
- </button>
138
- `:null}
139
- </header>
140
- <slot></slot>
141
- </section>
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",kM);const xM=`
143
- <svg viewBox="0 0 12 12" aria-hidden="true" focusable="false">
144
- <path d="M10.2 3.1 5.1 8.2 2.4 5.5" />
145
- </svg>
146
- `,EM=`
147
- :host {
148
- display: block;
149
- margin: var(--checkbox-list-margin, var(--space-12) 0);
150
- }
151
-
152
- [part~="list"] {
153
- display: grid;
154
- gap: var(--checkbox-list-gap, var(--space-6));
155
- }
156
- `,AM=`
157
- :host {
158
- display: block;
159
- --checkbox-size: 1em;
160
- --checkbox-gap: var(--space-8);
161
- --checkbox-color: var(--color-primary);
162
- --checkbox-border-color: var(--color-border);
163
- --checkbox-bg: transparent;
164
- --checkbox-check-color: var(--color-bg);
165
- --checkbox-checked-content-color: var(--color-text-muted);
166
- --checkbox-checked-decoration: line-through;
167
- --checkbox-checked-decoration-thickness: 0.08em;
168
- }
169
-
170
- [part~="label"] {
171
- display: grid;
172
- grid-template-columns: var(--checkbox-size) minmax(0, 1fr);
173
- gap: var(--checkbox-gap);
174
- align-items: baseline;
175
- }
176
-
177
- input {
178
- position: absolute;
179
- opacity: 0;
180
- pointer-events: none;
181
- width: 1px;
182
- height: 1px;
183
- }
184
-
185
- [part~="box"] {
186
- display: inline-grid;
187
- place-items: center;
188
- width: var(--checkbox-size);
189
- height: var(--checkbox-size);
190
- border: 1px solid var(--checkbox-border-color);
191
- border-radius: var(--checkbox-radius, var(--radius-4));
192
- background: var(--checkbox-bg);
193
- color: var(--checkbox-check-color);
194
- transform: translateY(0.12em);
195
- cursor: not-allowed;
196
- }
197
-
198
- [part~="check"] {
199
- display: block;
200
- width: calc(var(--checkbox-size) * 0.72);
201
- height: calc(var(--checkbox-size) * 0.72);
202
- opacity: 0;
203
- }
204
-
205
- [part~="check"] svg {
206
- display: block;
207
- width: 100%;
208
- height: 100%;
209
- }
210
-
211
- [part~="check"] path {
212
- fill: none;
213
- stroke: currentColor;
214
- stroke-width: 2;
215
- stroke-linecap: round;
216
- stroke-linejoin: round;
217
- }
218
-
219
- [part~="content"] {
220
- min-width: 0;
221
- }
222
-
223
- :host([checked]) [part~="box"] {
224
- border-color: var(--checkbox-color);
225
- background: var(--checkbox-color);
226
- }
227
-
228
- :host([checked]) [part~="check"] {
229
- opacity: 1;
230
- }
231
-
232
- :host([checked]) [part~="content"] {
233
- color: var(--checkbox-checked-content-color);
234
- text-decoration-line: var(--checkbox-checked-decoration);
235
- text-decoration-thickness: var(--checkbox-checked-decoration-thickness);
236
- }
237
- `;var la;class TM extends HTMLElement{constructor(){super();w(this,la);b(this,la,this.attachShadow({mode:"open"})),l(this,la).innerHTML=`<style>${EM}</style><div part="list"><slot></slot></div>`}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","list")}}la=new WeakMap;var es,ca,ua,Xh;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>${AM}</style>
239
- <label part="label">
240
- <input type="checkbox" disabled tabindex="-1">
241
- <span part="box"><span part="check">${xM}</span></span>
242
- <span part="content"><slot></slot></span>
243
- </label>
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,Xh).call(this)}attributeChangedCallback(){p(this,ua,Xh).call(this)}}es=new WeakMap,ca=new WeakMap,ua=new WeakSet,Xh=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",TM);customElements.get("checkbox-item")||customElements.define("checkbox-item",a0);const l0=Be(),c0="No handler registered for update-content",u0="handleUpdateContent: handler already registered",Tm="television-artifact-bridge";function h0(n){return n instanceof Error&&typeof n.message=="string"?n.message:String(n)}const d0=Ma(Nt);var ts,ns,rs,Wr,Vr,ha,Ze,Qh,p0,f0,io,ed,uv;let $M=(uv=class extends d0{constructor(e){super();w(this,Ze);w(this,ts);w(this,ns);w(this,rs);w(this,Wr,null);w(this,Vr,null);w(this,ha,!1);b(this,ts,e);const r=e.ownerDocument.defaultView;if(!r)throw new Error("ArtifactView: iframe has no owner window");b(this,ns,r),b(this,rs,i=>p(this,Ze,p0).call(this,i)),l(this,ns).addEventListener("message",l(this,rs))}get content(){return l(this,Vr)}set content(e){p(this,Ze,ed).call(this),b(this,Vr,e),l(this,ha)&&p(this,Ze,Qh).call(this,e)}handleUpdateContent(e){if(p(this,Ze,ed).call(this),l(this,Wr)!==null)throw new Error(u0);b(this,Wr,e)}dispose(){l(this,ns).removeEventListener("message",l(this,rs)),b(this,Wr,null)}},ts=new WeakMap,ns=new WeakMap,rs=new WeakMap,Wr=new WeakMap,Vr=new WeakMap,ha=new WeakMap,Ze=new WeakSet,Qh=function(e){const r={type:"content-updated",content:e};p(this,Ze,io).call(this,r)},p0=function(e){if(this.disposed||e.source!==l(this,ts).contentWindow)return;const r=e.data;if(Tb(r)){b(this,ha,!0),this.dispatchEvent(new l0("ready")),l(this,Vr)!==null&&p(this,Ze,Qh).call(this,l(this,Vr));return}if($b(r)){p(this,Ze,f0).call(this,r);return}},f0=async function(e){const r=l(this,Wr);if(r===null){p(this,Ze,io).call(this,{type:"response",id:e.id,error:{message:c0}});return}try{await r(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 r=l(this,ts).contentWindow;r&&r.postMessage(e,"*")},ed=function(){if(this.disposed)throw new Error("ArtifactView is disposed")},uv);var Br,is,jr,Gr,da,We,td,g0,m0,so,nd;class IM extends d0{constructor(e){super();w(this,We);w(this,Br);w(this,is);w(this,jr,null);w(this,Gr,null);w(this,da,!1);b(this,Br,e),b(this,is,r=>p(this,We,g0).call(this,r)),l(this,Br).addEventListener("ipc-message",l(this,is))}get content(){return l(this,Gr)}set content(e){p(this,We,nd).call(this),b(this,Gr,e),l(this,da)&&p(this,We,td).call(this,e)}handleUpdateContent(e){if(p(this,We,nd).call(this),l(this,jr)!==null)throw new Error(u0);b(this,jr,e)}dispose(){l(this,Br).removeEventListener("ipc-message",l(this,is)),b(this,jr,null)}}Br=new WeakMap,is=new WeakMap,jr=new WeakMap,Gr=new WeakMap,da=new WeakMap,We=new WeakSet,td=function(e){const r={type:"content-updated",content:e};p(this,We,so).call(this,r)},g0=function(e){var s;if(this.disposed)return;const r=e.detail??e;if(!r||r.channel!==Tm)return;const i=(s=r.args)==null?void 0:s[0];if(Tb(i)){b(this,da,!0),this.dispatchEvent(new l0("ready")),l(this,Gr)!==null&&p(this,We,td).call(this,l(this,Gr));return}if($b(i)){p(this,We,m0).call(this,i);return}},m0=async function(e){const r=l(this,jr);if(r===null){p(this,We,so).call(this,{type:"response",id:e.id,error:{message:c0}});return}try{await r(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 r,i;(i=(r=l(this,Br)).send)==null||i.call(r,Tm,e)},nd=function(){if(this.disposed)throw new Error("WebviewArtifactViewRuntime is disposed")};const $m="television-artifact-bridge",Im="/views/url-unsupported/",CM=404,v0=Be(),RM=Be(),PM=Be();class LM 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 r=this.querySelector("iframe.artifact-frame");if(!r)return;const i=Xp(e.data),s=su(e.data)&&e.data.native===!0&&e.data.sameDocument!==!0,o=r.contentWindow===e.source,a=(i||s)&&this._bridgeLifecycleWindow!==null&&this._bridgeLifecycleWindow===e.source,c=i&&this.isArtifactFrameMessageOrigin(r,e.origin);if(!(!o&&!a&&!c)){if(Qp(e.data)){this.handleBridgeReady(e.data,r);return}if(i){this.handleBridgeLeaving(e.data.guid);return}if(ef(e.data)){this.dispatchArtifactWheel({deltaX:e.data.deltaX,shiftKey:e.data.shiftKey});return}if(tf(e.data)){this.markLegacyBridgeProofOfLife(e.data,r),this.dispatchArtifactFilmstripKey(e.data.direction);return}if(xS(e.data)){this.markLegacyBridgeProofOfLife(e.data,r),(u=r.contentWindow)==null||u.postMessage({type:ES,url:this.currentExternalTargetURL()},"*");return}if(nf(e.data)){this.markLegacyBridgeProofOfLife(e.data,r),(h=r.contentWindow)==null||h.postMessage(this.currentMissingArtifactMessage(),"*");return}if(rf(e.data)){this.markLegacyBridgeProofOfLife(e.data,r),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,r);return}}});g(this,"handleNavigationChange",()=>{const e=this._preserveFrameSrcOnNavigationRender,r=!e;r&&this.closeBridgeGate({render:!1}),this.render({preserveFrameSrc:e}),this._preserveFrameSrcOnNavigationRender=!1,r&&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"&&yn(this._artifact.url)||this.reloadProxyFrame()});g(this,"handleWebviewIpcMessage",e=>{var o,a;const r=e.detail??e;if(!r||r.channel!==$m)return;const i=(o=r.args)==null?void 0:o[0];if(!i)return;const s=this._subscribedWebview;if(s){if(Qp(i)){this.handleBridgeReady(i,s);return}if(Xp(i)){this.handleBridgeLeaving(i.guid);return}if(nf(i)){this.markLegacyBridgeProofOfLife(i,s);const c=this.currentMissingArtifactMessage();c&&((a=s.send)==null||a.call(s,$m,c));return}if(su(i)){this.handleNavigationRequest(i);return}if(ef(i)){this.markLegacyBridgeProofOfLife(i,s),this.dispatchArtifactWheel({deltaX:i.deltaX,shiftKey:i.shiftKey});return}if(tf(i)){this.markLegacyBridgeProofOfLife(i,s),this.dispatchArtifactFilmstripKey(i.direction);return}rf(i)&&(this.markLegacyBridgeProofOfLife(i,s),this.handleProxyContentChanged())}});g(this,"handleWebviewDidStartNavigation",e=>{const r=e.detail??e;r.isMainFrame===!0&&r.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 r=this._artifact,i=r?!DM(r,e):!0;((r==null?void 0:r.id)!==e.id||r.kind==="path"&&e.kind==="path"&&r.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 r,i;const e=((r=this._navigationState)==null?void 0:r.currentURL)??null;return e&&Bu(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,r=this.querySelector(".artifact-frame")){if(this.isArtifactFrame(r)){if(typeof e.guid=="string"){(e.guid!==this._bridgeCurrentGuid||this._bridgePending)&&(this._bridgeCurrentGuid=e.guid,this._bridgeLifecycleWindow=r.tagName.toLowerCase()==="iframe"?r.contentWindow:null,this._bridgePending=!1,this.render({preserveFrameSrc:!0}));return}this.markLegacyBridgeProofOfLife(e,r)}}handleBridgeLeaving(e){e===this._bridgeCurrentGuid&&this.closeBridgeGate()}markLegacyBridgeProofOfLife(e,r=this.querySelector(".artifact-frame")){this.isArtifactFrame(r)&&(!this._bridgePending||zM(e)||(this._bridgePending=!1,this.render({preserveFrameSrc:!0})))}closeBridgeGate(e={}){const r=!this._bridgePending||this._bridgeCurrentGuid!==null;this._bridgePending=!0,this._bridgeCurrentGuid=null,this._bridgeLifecycleWindow=null,r&&e.render!==!1&&this.render({preserveFrameSrc:!0})}isArtifactFrame(e){if(!e)return!1;const r=e.tagName.toLowerCase();return r==="iframe"||r==="webview"}isArtifactFrameMessageOrigin(e,r){try{return new URL(e.getAttribute("src")??e.src,window.location.href).origin===r}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"||!yn(this._artifact.url)||this.reloadProxyFrame()}handleNavigationRequest(e){this.syncNavigationState();const r=this._navigationState;if(!r)return;const i=this.convertIframeNavigationURL(e.url);if(i===Im||i===r.currentURL)return;const s=e.native===!0;(e.sameDocument||s)&&(this._preserveFrameSrcOnNavigationRender=!0),s&&e.sameDocument!==!0&&this.closeBridgeGate({render:!1}),e.replace?r.replace(i):r.navigate(i)}dispatchArtifactFilmstripKey(e){this._standaloneScroll||this.dispatchEvent(new PM("artifact-filmstrip-key",{bubbles:!0,composed:!0,direction:e}))}dispatchArtifactWheel(e){this._standaloneScroll||this.dispatchEvent(new RM("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 RO(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 r=Yl(e,{electron:un()}),i=this._viewURL??r.viewURL;return e.kind==="url"&&yn(e.url)||r.renderer==="url-webview"?Ln(i):Cm(i,i)}convertIframeNavigationURL(e){var i,s;if(((i=this._artifact)==null?void 0:i.kind)==="url"&&yn(this._artifact.url)&&yn(e))return Ln(e);const r=(s=this.querySelector(".artifact-frame"))==null?void 0:s.getAttribute("src");return Cm(e,r??this._viewURL??null)}handleWebviewNavigationEvent(e){const r=e.url;if(typeof r!="string")return!1;this.syncNavigationState();const i=this._navigationState;if(!i)return!1;const s=Ln(r);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"),r=e?`${e.tagName.toLowerCase()}:${e.getAttribute("src")??""}:${e.dataset.contentUrl??""}`:null;if(e&&e===this._embedLoadFrame&&r===this._embedLoadKey||(this.unsubscribeFromEmbedLoad(),this.removeAttribute("data-embed-loaded"),!e||!r))return;if(this._embedLoadFrame=e,this._embedLoadKey=r,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 r=e.getAttribute("sandbox")??"";if(!new Set(r.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]"),r=(e==null?void 0:e.dataset.contentUrl)??null,i=((s=this._artifact)==null?void 0:s.id)??null;if(!e||!r||!i){this.disposeMarkdownHost({clearContent:!0});return}if(e!==this._markdownFrame||i!==this._markdownArtifactID){this.disposeMarkdownHost(),this._markdownFrame=e,this._markdownContentURL=r,this._markdownArtifactID=i;const o=e.tagName.toLowerCase()==="webview"?new IM(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=r;this.ensureMarkdownContentFetched()}ensureMarkdownContentFetched(){const e=this._artifact,r=this._screen;!e||!r||!this._markdownHost||this._markdownFetchedArtifactID===e.id&&this._markdownFetchedScreen===r||(this._markdownFetchedArtifactID=e.id,this._markdownFetchedScreen=r,this.fetchMarkdownContent())}async fetchMarkdownContent(){var s,o;const e=this._artifact,r=this._screen;if(!e||!r)return;const i=e.id;try{const a=await r.server.client.markdown.get({artifactID:i});if(((s=this._artifact)==null?void 0:s.id)!==i||this._screen!==r)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!==r)return;if(a instanceof tp&&a.status===CM){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
- <section class="artifact-missing artifact-content" role="status" aria-label="Artifact file not found">
246
- <div class="artifact-missing-wrapper">
247
- <h1>${IS()}</h1>
248
- <p>${CS()}</p>
249
- <section class="artifact-missing-path" aria-label="Missing artifact path">
250
- <p class="artifact-missing-path-label">Registered path:</p>
251
- <p><code>${e.path}</code></p>
252
- </section>
253
- <p>${RS()}</p>
254
- </div>
255
- </section>
256
- `}disposeMarkdownHost(e={}){var r;(r=this._markdownHost)==null||r.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"&&yn(this._artifact.url)))return;const r=((c=this._artifact)==null?void 0:c.kind)==="url"&&yn(this._artifact.url)?((u=this._navigationState)==null?void 0:u.currentURL)??e.getAttribute("src"):e.getAttribute("src");if(r===null)return;this.closeBridgeGate({render:!1});const i=new URL(r,window.location.href);i.searchParams.set(vs,String(++this._proxyReloadVersion));const s=r.startsWith("/")?`${i.pathname}${i.search}${i.hash}`:i.href;this._activeReloadFrameSrc=s,this.removeAttribute("data-embed-loaded"),this.render({frameSrcOverride:s})}contentTemplate(e,r){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&&(OM(this._activeReloadFrameSrc,i.viewURL)?o=this._activeReloadFrameSrc:this._activeReloadFrameSrc=null);const a=r.frameSrcOverride??o??(r.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 r=Yl(e,{electron:un()}),i=((s=this._navigationState)==null?void 0:s.currentURL)??null;if(i===null){const o=this._viewURL??r.viewURL;return r.renderer==="markdown"?{renderer:"markdown",viewURL:o,contentURL:this._contentURL??r.contentURL}:{...r,viewURL:o}}return Bu(i)&&!un()?yn(i)?{renderer:"proxy-iframe",viewURL:i,contentURL:null}:{renderer:"proxy-iframe",viewURL:Im,contentURL:null}:Bu(i)&&un()?{renderer:"url-webview",viewURL:i,contentURL:null}:un()?{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 r=this.querySelector("iframe.artifact-frame");if(r){this.closeBridgeGate(),this._activeReloadFrameSrc=null,this.removeAttribute("data-embed-loaded");try{r.contentWindow&&(r.contentWindow.location.href=e.viewURL)}catch{r.src=e.viewURL}r.src=e.viewURL,r.setAttribute("src",e.viewURL),this.syncEmbedLoadState()}}titleIconTemplate(){const e=this._navigationState;return e!=null&&e.canGoBack?P`
257
- <button
258
- icon-only
259
- size="sm"
260
- variant="ghost"
261
- class="artifact-title-icon artifact-history-back"
262
- @click=${()=>e.back()}
263
- aria-label="Back"
264
- >
265
- ${iM({size:16})}
266
- </button>
267
- `:P`
268
- <button
269
- icon-only
270
- size="sm"
271
- variant="ghost"
272
- class="artifact-title-icon"
273
- disabled
274
- aria-label="No history"
275
- >
276
- ${lM({size:16,weight:"duotone"})}
277
- </button>
278
- `}template(e={preserveFrameSrc:!1}){const r=this._artifact;return P`
279
- ${this.contentTemplate(r,e)}
280
- <footer class="artifact-title-bar" drag-handle material="glass-frosted">
281
- <div class="artifact-title-group">
282
- ${this.titleIconTemplate()}
283
- <span class="artifact-title">${r.title}</span>
284
- </div>
285
- <div class="artifact-title-actions">
286
- <button
287
- icon-only
288
- size="sm"
289
- variant="ghost"
290
- class="artifact-close-btn"
291
- @click=${()=>this.handleClose()}
292
- aria-label="Close"
293
- >
294
- ${fp({size:16})}
295
- </button>
296
- </div>
297
- </footer>
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 Bu(n){return n.startsWith("http://")||n.startsWith("https://")}function DM(n,t){return n.id!==t.id||n.kind!==t.kind?!1:n.kind==="path"&&t.kind==="path"?n.path===t.path:n.kind==="url"&&t.kind==="url"?n.url===t.url:!0}function zM(n){return typeof n=="object"&&n!==null&&"guid"in n}function OM(n,t){try{const e=new URL(n,window.location.href),r=new URL(t,window.location.href);return e.searchParams.delete(vs),r.searchParams.delete(vs),e.origin===r.origin&&e.pathname===r.pathname&&e.search===r.search}catch{return!1}}function Cm(n,t){try{const e=new URL(n,window.location.href);if(t){const r=new URL(t,window.location.href);if(e.origin===r.origin)return e.searchParams.delete(vs),`${e.pathname}${e.search}${e.hash}`}}catch{return Ln(n)}return Ln(n)}customElements.define("artifact-view",LM);/**
299
- * @license
300
- * Copyright 2017 Google LLC
301
- * SPDX-License-Identifier: BSD-3-Clause
302
- */const Rm=(n,t,e)=>{const r=new Map;for(let i=t;i<=e;i++)r.set(n[i],i);return r},Pm=Zc(class extends pp{constructor(n){if(super(n),n.type!==dp.CHILD)throw Error("repeat() can only be used in text expressions")}dt(n,t,e){let r;e===void 0?e=t:t!==void 0&&(r=t);const i=[],s=[];let o=0;for(const a of n)i[o]=r?r(a,o):o,s[o]=e(a,o),o++;return{values:s,keys:i}}render(n,t,e){return this.dt(n,t,e).values}update(n,[t,e,r]){const i=XO(n),{values:s,keys:o}=this.dt(t,e,r);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]=yr(i[f],s[m]),f++,m++;else if(a[y]===o[E])c[E]=yr(i[y],s[E]),y--,E--;else if(a[f]===o[E])c[E]=yr(i[f],s[E]),Fs(n,c[E+1],i[f]),f++,E--;else if(a[y]===o[m])c[m]=yr(i[y],s[m]),Fs(n,i[f],i[y]),y--,m++;else if(u===void 0&&(u=Rm(o,m,E),h=Rm(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(n,i[f]);yr(L,s[m]),c[m]=L}else c[m]=yr(I,s[m]),Fs(n,i[f],I),i[x]=null;m++}else Hu(i[y]),y--;else Hu(i[f]),f++;for(;m<=E;){const x=Fs(n,c[E+1]);yr(x,s[m]),c[m++]=x}for(;f<=y;){const x=i[f++];x!==null&&Hu(x)}return this.ut=o,JO(n,c),ni}}),Ie=n=>({type:"px",...n}),$e=n=>({type:"unit",...n}),ul=2;class MM{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??Qr,r=this._viewport.y??yo,i=this._gap.x??ae,s=this._gap.y??ae,o=e<=ET,a=o?e-i*ul:Math.min(Qr,e-i*ul),c=o?r-s*ul:Math.min(yo,r-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,r=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*r+Math.max(0,t.y-1)*s;return Ie({x:o,y:a})}}const ri=1e-4,zt=1e-6,NM=40,UM=24;function y0(n,t){return Math.max(0,n-t*2)}function b0(n){const t=[0];for(const e of n)t.push((t[t.length-1]??0)+e);return t}function w0(n){const t=[0];for(let e=0;e<n.length;e+=1){const r=t[e]??0;t.push(r+n[e]+ae)}return t}function S0(n,t,e){if(t<0||t>=n.length)return 0;let r=0,i=0;for(let s=t;s<n.length;s+=1){const o=n[s],a=i===0?o:r+ae+o;if(a>e+ri)break;r=a,i+=1}return Math.max(1,i)}function FM(n,t,e){if(t<0||t>=n.length)return 0;let r=0,i=0;for(let s=t;s>=0;s-=1){const o=n[s],a=i===0?o:r+ae+o;if(a>e+ri)break;r=a,i+=1}return Math.max(1,i)}function HM(n,t){if(n.length===0)return 0;let e=0,r=0;for(let i=n.length-1;i>=0;i-=1){const s=n[i],o=r===0?s:e+ae+s;if(o>t+ri)break;e=o,r+=1}return Math.max(1,r)}function gp(n,t){if(n.length===0)return 0;const e=HM(n,t);return Math.max(0,n.length-e)}function Lm(n,t,e){if(n.length===0)return 0;const r=S0(n,t,e),i=Math.min(n.length,t+r);if(i<=t)return 0;const s=n.slice(t,i);return s.reduce((o,a)=>o+a,0)+Math.max(0,s.length-1)*ae}function rd(n,t,e){const r=n[t]??0;return e-r}function Ci(n,t,e,r,i){if(n.length===0)return 0;const s=gp(n,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+ri){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,ri),m=u===c?0:(a-h)/y,E=w0(n),x=Lm(n,c,i),I=Lm(n,u,i),L=(r-x)/2,R=(r-I)/2,V=rd(E,c,L),N=rd(E,u,R);return V+(N-V)*m}function ZM(n,t,e,r,i){const s=gp(n,r),o=t[s]??0;let a=0,c=o;for(let u=0;u<NM;u+=1){const h=(a+c)/2;Ci(n,t,h,e,r)>i?a=h:c=h}return(a+c)/2}function WM(n,t,e){const r=w0(n),[i,s]=t,o=n.slice(i,s+1),a=o.reduce((u,h)=>u+h,0)+Math.max(0,o.length-1)*ae,c=(e-a)/2;return rd(r,i,c)}function VM(n,t,e){const r=S0(n,t,e);return[t,Math.min(n.length-1,t+r-1)]}function BM(n,t,e){const r=FM(n,t,e);return[Math.max(0,t-r+1),t]}function jM(n,t){return n[0]===t[0]&&n[1]===t[1]}function GM(n){const{nodeCols:t,nodeWidthsPx:e,viewportWidthPx:r}=n;if(t.length===0||e.length===0)return{viewspans:[],minScroll:0,maxScroll:0};const i=e.length,s=n.gapPx??ae,o=y0(r,s),a=b0(t),c=gp(e,o),u=a[c]??0;function h(I){const L=WM(e,I,r),R=ZM(e,a,r,o,L);return{nodeRange:I,anchor:Math.max(0,Math.min(u,R))}}const f=[];for(let I=0;I<i;){const L=VM(e,I,o);f.push(h(L)),I=L[1]+1}const y=h(BM(e,i-1,o)),m=f.filter(I=>I.nodeRange[0]<y.nodeRange[0]),E=m[m.length-1];return{viewspans:E&&jM(E.nodeRange,y.nodeRange)?m:[...m,y],minScroll:0,maxScroll:u}}function Si(n,t){var i;let e=0,r=Number.POSITIVE_INFINITY;for(let s=0;s<n.length;s+=1){const o=Math.abs((((i=n[s])==null?void 0:i.anchor)??0)-t);if(o+zt<r){r=o,e=s;continue}Math.abs(o-r)<=zt&&s<e&&(e=s)}return e}function qM(n,t,e){return e<=0?0:Math.max(0,Math.min(e-1,n+t))}function br(n,t,e){return Math.max(t,Math.min(e,n))}function YM(n,t){var e;for(let r=0;r<n.length;r+=1)if(Math.abs((((e=n[r])==null?void 0:e.anchor)??0)-t)<=zt)return r;return-1}function KM(n,t,e){var i,s;if(n.length===0)return t;const r=YM(n,t);if(r>=0){const o=n[r+e];return(o==null?void 0:o.anchor)??n[e>0?n.length-1:0].anchor}if(e>0){for(const o of n)if(o.anchor>t+zt)return o.anchor;return((i=n[n.length-1])==null?void 0:i.anchor)??t}for(let o=n.length-1;o>=0;o-=1){const a=n[o];if(a&&a.anchor<t-zt)return a.anchor}return((s=n[0])==null?void 0:s.anchor)??t}class JM 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 r=br(e.x??this._scroll,this._minScroll,this._maxScroll);Math.abs(r-this._scroll)<=zt||(this._scroll=r,this._activeViewspanIndex=Si(this._viewspans,this._scroll),this.dispatchEvent(new wi("layout-scroll",{scroll:this.scroll})))}rebuild(e){var y;const r=e.nodeWidths.map(m=>Math.max(0,m.x??0)),i=r.map(m=>e.grid.toPixels($e({x:m})).x??0),s=e.grid.viewport.x??0,o=e.grid.gap.x??ae,a=GM({nodeCols:r,nodeWidthsPx:i,viewportWidthPx:s,gapPx:o});this._nodeWidthsPx=i,this._boundaryCols=b0(r),this._viewportWidthPx=s,this._framedViewportWidthPx=y0(s,o),this._viewspans=a.viewspans,this._minScroll=a.minScroll,this._maxScroll=a.maxScroll;const c=br(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=br(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 r=qM(this._activeViewspanIndex,e,this._viewspans.length),i=((o=this._viewspans[r])==null?void 0:o.anchor)??this._scroll,s=br(i,this._minScroll,this._maxScroll);this._activeViewspanIndex=r,!(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 r=e===void 0?((s=this._viewspans[Si(this._viewspans,this._scroll)])==null?void 0:s.anchor)??this._scroll:KM(this._viewspans,this._scroll,e),i=br(r,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 r=br(this._scroll+(e.x??0),this._minScroll,this._maxScroll);Math.abs(r-this._scroll)<=zt||(this._scroll=r,this._activeViewspanIndex=Si(this._viewspans,this._scroll),this.dispatchEvent(new wi("layout-scroll",{scroll:this.scroll})))}wheelPixels(e){const r=e.x??0;if(Math.abs(r)<=ri)return;const i=Ci(this._nodeWidthsPx,this._boundaryCols,this._scroll,this._viewportWidthPx,this._framedViewportWidthPx),s=i-r,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)<=ri)return;let u=this._minScroll,h=this._maxScroll;for(let y=0;y<UM;y+=1){const m=(u+h)/2;Ci(this._nodeWidthsPx,this._boundaryCols,m,this._viewportWidthPx,this._framedViewportWidthPx)>c?u=m:h=m}const f=br((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 ju={"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}},XM=["stack-above","stack-below","reorder-before","reorder-after"];function Gu(n,t){return{left:n.left+n.width*t.left,top:n.top+n.height*t.top,width:n.width*t.width,height:n.height*t.height}}function wr(n,t,e){return n>=e.left&&n<e.left+e.width&&t>=e.top&&t<e.top+e.height}function Ui(n){return n.artifactID}function id(n){return Number.isFinite(n)?Math.max(vo,Math.min(Qd,Math.round(n))):vo}function QM(n,t,e){const r=n.findIndex(a=>a.type==="card"&&Ui(a)===t);if(r===-1)return n;const i=n[r];if(!i||i.type!=="card")return n;const s=id(e);if(i.width===s)return n;const o=[...n];return o[r]={...i,width:s},o}function _0(n,t){for(const e of n){if(e.type==="card"&&Ui(e)===t)return e;if(e.type==="stack")for(const r of e.children){if(r.type==="card"&&Ui(r)===t)return r;if(r.type==="row"){for(const i of r.children)if(Ui(i)===t)return i}}}return null}function sd(n){const t=n.height===ft||n.height===ir?ir:n.height;return n.width===Ye&&n.height===t?n:{...n,width:Ye,height:t}}function od(n){return n.height===ir?{...n,height:ft}:n}function eN(n,t,e,r){const i=n.findIndex(h=>h.type==="stack"&&h.id===t);if(i===-1)return n;const s=n[i];if(!s||s.type!=="stack")return n;const o=s.children.find(h=>h.type==="card"&&Ui(h)===e);if(!o||o.type!=="card")return n;const a=s.children.filter(h=>h.type!=="card"||Ui(h)!==e);if(a.length===s.children.length||a.length<1)return n;const c=[...n];if(a.length===1){const[h]=a;c[i]=h.type==="card"?od(h):h}else c[i]={...s,children:a};const u=Math.max(0,Math.min(r,c.length));return c.splice(u,0,od(o)),c}const tN=Be(),nN=Be(),rN=50;function iN(n,t){if(n.type!==t.type)return!1;switch(n.type){case"reorder":return t.index===n.index;case"stack":return t.targetCardId===n.targetCardId&&t.position===n.position;case"stack-child-noop":return!0;case"stack-child-extract":return t.toIndex===n.toIndex;case"stack-child-reorder":return t.position===n.position;default:return!1}}function et(n){return n.artifactID}function Dm(n){return n.type==="card"?et(n):n.id}function Ua(n){return{id:et(n),type:"drop-target",width:n.width,height:n.height}}function zm(n){return n.map(oN)}function sN(n){return n.type==="drop-target"?{type:"card",artifactID:n.id,width:n.width,height:n.height}:n}function oN(n){return n.type==="drop-target"?{type:"card",artifactID:n.id,width:n.width,height:n.height}:n.type==="stack"?{...n,children:n.children.map(sN)}:n}function k0(n,t){return n.find(r=>r.type==="card"&&et(r)===t)??null}function Om(n,t){return n.find(r=>r.type==="stack"&&r.id===t)??null}function aN(n,t){const e=[...t],r=e.findIndex(a=>a.type==="card"&&et(a)===n.nodeId);if(r===-1)return null;const i=e[r];if(!i||i.type!=="card")return null;e.splice(r,1);const s=Math.max(0,Math.min(n.lastReorderIndex,e.length));e.splice(s,0,i);const o=e.findIndex(a=>a.type==="card"&&et(a)===n.nodeId);return o===-1?null:{base:e,visualDraggedIndex:o}}function lN(n,t,e,r){const i=[...n.base];i.splice(n.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(r,t.nodeId);if(!a)return null;const c=sd(a),u=sd(o),h=Ua(c),f=e.position==="above"?[h,u]:[u,h];return i[s]={id:et(o),type:"stack",children:f},i}function qu(n,t){return n.parentStackId?uN(n,t):cN(n,t)}function cN(n,t){const e=n.hitTarget;if(e.type==="reorder"){const r=t[n.sourceIndex];if(!r||r.type!=="card")return[...t];const i=[...t];return i.splice(n.sourceIndex,1),i.splice(e.index,0,Ua(r)),i}if(e.type==="stack"){const r=aN(n,t);return r?lN(r,n,e,t)??[...t]:[...t]}return[...t]}function uN(n,t){const e=n.hitTarget;switch(e.type){case"stack-child-reorder":return hN(n,t,e.position);case"stack-child-extract":return dN(n,t,e.toIndex);case"stack-child-noop":return pN(n,t);default:return[...t]}}function hN(n,t,e){const r=t.findIndex(y=>y.type==="stack"&&y.id===n.parentStackId);if(r===-1)return[...t];const i=t[r];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)===n.nodeId);if(o===-1)return[...t];const a=s[o],c=s.filter(y=>et(y)!==n.nodeId),u=Ua(a),h=e==="above"?[u,...c]:[...c,u],f=[...t];return f[r]={...i,children:h},f}function dN(n,t,e){if(!n.parentStackId)return[...t];const r=eN(t,n.parentStackId,n.nodeId,e);if(r===t)return[...t];const i=r.findIndex(a=>a.type==="card"&&et(a)===n.nodeId);if(i===-1)return[...t];const s=r[i];if(!s||s.type!=="card")return[...t];const o=[...r];return o[i]=Ua(s),o}function pN(n,t){const e=t.findIndex(c=>c.type==="stack"&&c.id===n.parentStackId);if(e===-1)return[...t];const r=t[e];if(!r||r.type!=="stack")return[...t];const i=r.children.findIndex(c=>c.type==="card"&&et(c)===n.nodeId);if(i===-1)return[...t];const s=r.children[i];if(!s||s.type!=="card")return[...t];const o=[...t],a=[...r.children];return a[i]=Ua(s),o[e]={...r,children:a},o}function fN(n,t){return t.find(r=>r.type==="stack"&&r.id===n.id)?n.id:Cc()}function gN(n,t,e){if(n.type==="drop-target"){const r=_0(t,e);if(!r)throw new Error(`finalize: missing dragged card ${e}`);return sd(r)}return n}function mN(n,t,e){const r=n.children.map(s=>gN(s,t,e));return{id:fN(n,t),type:"stack",children:r}}function vN(n,t,e){if(n.type==="drop-target"){const r=_0(t,e);if(!r)throw new Error(`finalize: missing dragged card ${e}`);return k0(t,e)!==null?r:od(r)}return n.type==="card"||n.type==="row"?n:mN(n,t,e)}function yN(n,t,e){return n.map(r=>vN(r,t,e))}function bN(n,t){return JSON.stringify(n)===JSON.stringify(t)}const wN=Ma(Nt);class SN extends wN{constructor(e={}){super();g(this,"pending",null);g(this,"active",null)}start(e){if(this.pending||this.active)return;const r=e.pointer.x??0,i=e.pointer.y??0;this.pending={startX:r,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 r=e.pointer.x??0,i=e.pointer.y??0,s=this.pending;if(s){const u=r-s.startX,h=i-s.startY;Math.hypot(u,h)>=TT&&(this.pending=null,this.active={...s,pointerX:r,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=qu(this.active,this.active.baseLayout),a=this.getHitTargetForPointer(r,i,e,o),c=a.type==="reorder"?a.index:this.active.lastReorderIndex;this.active.pointerX===r&&this.active.pointerY===i&&iN(this.active.hitTarget,a)&&this.active.lastReorderIndex===c||(this.active={...this.active,pointerX:r,pointerY:i,hitTarget:a,lastReorderIndex:c},this.emitDrag(),this.dispatchEvent(new oe("change")))}drop(){if(this.pending){this.cancel();return}if(!this.active)return;const e=this.active.baseLayout;let r=null;try{const i=qu(this.active,e),s=yN(i,e,this.active.nodeId);bN(s,e)||(r=s)}catch{r=null}this.reset(),r&&this.dispatchEvent(new nN("drop",{layout:r})),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=qu(this.active,this.active.baseLayout);this.dispatchEvent(new tN("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,r,i,s){return this.active?this.isPointerInsideDragBounds(e,r,i.viewport)?this.active.parentStackId?this.getStackChildHitTarget(e,r,i,s):this.getTopLevelCardHitTarget(e,r,i,s):{type:"reorder",index:this.active.sourceIndex}:{type:"reorder",index:0}}getStackChildHitTarget(e,r,i,s){var u;if(!((u=this.active)!=null&&u.parentStackId))return{type:"stack-child-noop"};const o=this.getSourceStackInteractionRect(i.geometry);if(o&&wr(e,r,o)){const h=o.top+o.height/2;return{type:"stack-child-reorder",position:r<h?"above":"below"}}const a=this.getSourceRemainingSiblingRect(i.geometry);if(a&&wr(e,r,a)){const h=a.top+a.height/2;return{type:"stack-child-reorder",position:r<h?"above":"below"}}return{type:"stack-child-extract",toIndex:this.getTopLevelReorderIndexForPointer(e,r,i,s)}}getSourceRemainingSiblingRect(e){var s,o;if(!((s=this.active)!=null&&s.parentStackId))return;const r=Om(this.active.baseLayout,this.active.parentStackId);if(!r)return;const i=r.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 r=e.find(a=>{var c;return a.id===((c=this.active)==null?void 0:c.parentStackId)});if(r)return this.active.sourceStackRect=r.rect,r.rect;const i=Om(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,r,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)<=rN;for(const I of o){const L=I.rect;if(!wr(e,r,L))continue;const R=this.resolveTopLevelTargetForCard(e,r,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,r,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,r,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(!wr(e,r,f.rect))continue;const y=Gu(f.rect,ju["reorder-before"]);if(wr(e,r,y))return f.logicalIndex;const m=Gu(f.rect,ju["reorder-after"]);if(wr(e,r,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,r){const i=new Map(r.map(a=>[Dm(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:Dm(c),rect:a.rect,logicalIndex:o}),o+=1)}return s}resolveTopLevelTargetForCard(e,r,i,s,o){const a=i.rect;for(const c of XM){if(!o&&(c==="stack-above"||c==="stack-below"))continue;const u=ju[c],h=Gu(a,u);if(wr(e,r,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,r){let i=null,s=Number.POSITIVE_INFINITY;for(const o of r){const a=o.rect.left,c=o.rect.left+o.rect.width,u=e<a?a-e:e>c?e-c:0;u<s&&(s=u,i=o)}return i}isPointerInsideDragBounds(e,r,i){return e>=i.left&&e<=i.left+i.width&&r>=i.top&&r<=i.top+i.height}}const _N=100,kN=1e3;class xN{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)<IT?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-_N;let r=0;for(let i=0;i<this.samples.length;i+=1){if(this.samples[i].time>=e){r=i;break}r=i+1}if(r>0){const i=Math.max(0,r-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],r=e.time-t.time;return r<=0?0:(e.offset-t.offset)/r*kN}}function Oi(n){return n.artifactID}function EN(n){return n.type==="card"?Oi(n):n.id}function AN({baseLayout:n,visibleLayout:t,resolved:e,cardsByID:r,grid:i,dragState:s,isForeground:o}){var E;const a=new Map(t.map(x=>[EN(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=r.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=r.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=TN(n,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=r.get(s.nodeId);if(!u)return c;const h=s.source.parentId??s.nodeId,f=((E=$r(n).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 Mm(n){if(!n)return null;const t=n.projectedLayout,e=n.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 r=t.findIndex(i=>i.type==="drop-target");return r===-1?"none":e?`stack-child-extract:${r}`:`reorder:${r}`}function TN(n,t,e){const r=n.find(i=>i.type==="stack"&&i.id===t);return!r||r.type!=="stack"?-1:r.children.findIndex(i=>i.type==="card"&&Oi(i)===e)}const $N=2,Nm=1e3,_i=1e-4,IN=120,Um=!1;function Fm(n){return n.replace(/["\\]/g,"\\$&")}function we(n){return n.artifactID}function Fi(n){return n.type==="card"?we(n):n.id}function Hm(n,t,e){if(n===0)return 0;const r=t.toPixels($e({y:ft})).y??0;return(e-r)/$N}function Yu(n){const t=n.clientWidth>0?n.clientWidth:Qr,e=n.clientHeight>0?n.clientHeight:yo;let r=0,i=0;if(n.isConnected){const u=getComputedStyle(n);r=parseFloat(u.paddingTop)||0,i=parseFloat(u.paddingBottom)||0}const s=Math.max(1,e-r-i),o=n.isConnected&&parseFloat(getComputedStyle(n).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:r}}function CN(n){return n.shiftKey&&n.deltaX===0&&n.deltaY!==0?n.deltaY:n.deltaX}function RN(n){var e;if(!(n instanceof Element))return!1;const t=n.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 PN 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 LN extends HTMLElement{constructor(){super();g(this,"_layout",[]);g(this,"_scrollPosition",0);g(this,"layoutGrid",null);g(this,"layoutScroll",new JM($e({x:0})));g(this,"scrollModelKey","");g(this,"resizeObserver",null);g(this,"renderPending",!1);g(this,"animateNextRender",!0);g(this,"swipeGesture",new xN(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 SN);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 r=JSON.stringify(e.projectedLayout),i=Mm(e),s=zN(e.projectedLayout);if(r!==this.lastProjectedDragLayoutSignature||i!==this.lastDragDropIntent||s!==this.lastActivePlaceholderId){const u=zm(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=r,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"&&(RN(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 r=CN(e);Math.abs(r)<_i||(e.preventDefault(),this.applyHorizontalWheel(r))});g(this,"handleWindowMessage",e=>{if(this._layout.length===0)return;const r=this.findManagedArtifactFrame(e.source);if(r&&this.isTrustedArtifactFrameMessage(e,r)){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 r=e.target;if(!(r instanceof Element))return;const i=r.closest("[data-resize-handle]");if(i){this.beginResize(e,i);return}const s=r.closest("[drag-handle]")!==null,o=r.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=r.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=r.closest(".card-slot");if(!a)return;const c=a.getAttribute("data-layout-card-id");if(!c)return;const u=ON(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 r=this.resizeState;if(!r||e.pointerId!==r.pointerId)return;const i=this.layoutGrid,s=((i==null?void 0:i.unit.x)??Hn)+ae;if(s<=0)return;const o=e.clientX-r.startClientX,a=id(r.startWidth+o/s);a!==r.currentWidth&&(r.currentWidth=a,this.scheduleRender())});g(this,"handleResizePointerUp",e=>{const r=this.resizeState;if(!r||e.pointerId!==r.pointerId)return;const i=r.currentWidth,s=r.startWidth,o=r.cardId;this.endResize(e.pointerId),i!==s?this.commitLayout(QM(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<zg&&a<zg)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 r=e.clientX-this.swipeLastX;this.swipeLastX=e.clientX,this.swipeGesture.move(e.timeStamp,r),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 r=Math.max(0,e-this.lastDragFrameTime)/Nm;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,r);this.scrollVelocityPxPerSec=r>_i?Math.abs(o)/r: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 r=[...e];this.dragController.status!=="idle"&&JSON.stringify(r)===JSON.stringify(this._layout)||(this._layout=r,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 r=$r(this._layout),i=r.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+=r.nodes[o].width;this.scrollPosition=s,queueMicrotask(()=>{const o=this.querySelector(`.card-slot[data-layout-card-id="${Fm(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,r){return new MM({basis:Ie({x:Hn,y:Hn}),min:Ie({x:Lg,y:Lg}),viewport:Ie({x:e,y:r}),gap:Ie({x:ae,y:ae})})}syncScrollModel(){const e=Yu(this),i=$r(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:Um}))}emitScrollPositionChanged(e){this.dispatchEvent(new PN(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 r=this.layoutGrid;if(!r)return;this.animateNextRender=!1;const i=r.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()},IN)}clearWheelIdleSnap(){this.wheelIdleSnapTimer!==null&&(clearTimeout(this.wheelIdleSnapTimer),this.wheelIdleSnapTimer=null)}findViewspanContainingNode(e){const r=this.layoutScroll.viewspans,i=this._scrollPosition;let s=null,o=Number.POSITIVE_INFINITY;for(const a of r)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 r=this.querySelectorAll("iframe.artifact-frame");for(const i of r)if(i.contentWindow===e)return i;return null}isTrustedArtifactFrameMessage(e,r){if(e.origin==="null")return!0;const i=this.getArtifactFrameOrigin(r);return i===null||e.origin===i}getArtifactFrameOrigin(e){const r=e.getAttribute("src")??e.src;if(!r)return null;try{return new URL(r,window.location.href).origin}catch{return null}}beginResize(e,r){const i=r.getAttribute("data-resize-handle");if(!i)return;const s=this._layout.find(a=>a.type==="card"&&we(a)===i);if(!s)return;const o=id(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):zm(this.dragState.projectedLayout)}applyResizeOverride(e){const r=this.resizeState;if(!r)return e;const i=e.findIndex(a=>a.type==="card"&&we(a)===r.cardId);if(i===-1)return e;const s=e[i];if(!s||s.type!=="card"||s.width===r.currentWidth)return e;const o=[...e];return o[i]={...s,width:r.currentWidth},o}getGridSlotStyle(e){return`grid-column: ${e.col} / span ${e.width}; grid-row: ${e.row} / span ${e.height};`}findContainingBlock(e){let r=e.parentElement;for(;r;){const i=getComputedStyle(r);if(i.transform!=="none"||i.perspective!=="none"||i.filter!=="none")return r;const s=i.willChange;if(s.includes("transform")||s.includes("perspective")||s.includes("filter"))return r;const o=i.contain;if(o.includes("layout")||o.includes("paint")||o.includes("strict"))return r;r=r.parentElement}return document.documentElement}getDraggedSlotStyle(e){const r=this.currentDragPreviewSize??{width:e.size.x??0,height:e.size.y??0};return["position: fixed;",`width: ${r.width}px;`,`height: ${r.height}px;`,"pointer-events: none;","z-index: 10;"].join(" ")}writeDraggedSlotPosition(e,r){(!this.draggedSlotContainingBlock||!this.draggedSlotContainingBlock.isConnected||!this.draggedSlotContainingBlock.contains(e))&&(this.draggedSlotContainingBlock=this.findContainingBlock(e));const i=this.draggedSlotContainingBlock.getBoundingClientRect(),s=r.pointer.x??0,o=r.pointer.y??0,a=r.grabOffset.x??0,c=r.grabOffset.y??0,u=this.currentDragPreviewSize??{width:r.size.x??0,height:r.size.y??0},h=r.size.x??0,f=r.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,r){var o,a;if(e.kind==="placeholder")return e.placement?P`
303
- <div
304
- class="card-slot card-placeholder"
305
- data-layout-placeholder-for=${(r==null?void 0:r.nodeId)??""}
306
- data-layout-placeholder-ghost="false"
307
- data-layout-source-stack=${e.sourceStackId??""}
308
- style=${this.getGridSlotStyle(e.placement)}
309
- ></div>
310
- `:null;const i=e.card;if(!i)return null;const s=e.isDragged&&r?this.getDraggedSlotStyle(r):e.placement?this.getGridSlotStyle(e.placement):"";return P`
311
- <div
312
- class="card-slot"
313
- data-layout-card-id=${we(i)}
314
- data-layout-drag-source=${String(e.isDragged)}
315
- layout-cols=${String(((o=e.placement)==null?void 0:o.width)??"")}
316
- layout-rows=${String(((a=e.placement)==null?void 0:a.height)??"")}
317
- style=${s}
318
- >
319
- <div class="card-content-mount" data-mount-for=${we(i)}></div>
320
- ${e.isTopLevelCard&&!e.isDragged?P`<div
321
- class="resize-handle"
322
- data-resize-handle=${we(i)}
323
- data-test-resize-handle=${we(i)}
324
- ></div>`:null}
325
- </div>
326
- `}renderNode(e,r){return P`
327
- <div
328
- class=${e.kind==="ghost"?"drag-source-node":"node"}
329
- layout-node=${String(e.layoutIndex??"")}
330
- data-layout-node-id=${e.nodeId}
331
- data-layout-placeholder=${String(e.kind==="visible"&&e.isPlaceholder)}
332
- layout-node-cols=${String(e.widthUnits)}
333
- ?data-foreground=${e.kind==="visible"&&e.isForeground}
334
- style=${e.kind==="visible"?`width: ${e.widthPx}px; --card-width-px: ${e.widthPx};`:""}
335
- >
336
- <div class="node-inner" style=${`grid-template-columns: repeat(${e.widthUnits}, var(--layout-unit-x));`}>
337
- ${Pm(e.slots,i=>i.key,i=>this.renderSlot(i,r))}
338
- </div>
339
- </div>
340
- `}render(){var Y;const e=Yu(this),r=this.createGrid(e.width,e.height);this.layoutGrid=r;const i=this.getVisibleLayout(),s=this.dragController.status==="active",o=$r(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:r,nodeWidths:a.map(j=>$e({x:j})),snap:Um}),this._scrollPosition=this.layoutScroll.scroll.x??this._scrollPosition);const u=DN(this._layout),h=r.unit.x??Hn,f=r.unit.y??Hn,y=s?this.dragTrackOffsetXPx:0,m=(this.layoutScroll.translate.x??0)+y,E=Hm(o.nodes.length,r,e.height),x=this.animateNextRender&&!s,I=[`transform: translate(${m}px, ${E}px);`,`transition-duration: ${x?AT: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=r.toPixels($e({x:o.nodes[ce].width})).x??0,pr=j+Tt;j>=-1&&pr<=e.width+1&&R.add(ce),j=pr+ae}}const V=j=>R.has(j),N=AN({baseLayout:this._layout,visibleLayout:i,resolved:o,cardsByID:u,grid:r,dragState:this.dragState,isForeground:V}),H=Mm(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:r.toPixels($e({x:Tt.width})).x??0,height:r.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
- <div class="track" style=${I}>
342
- ${Pm(N,j=>j.key,j=>this.renderNode(j,L))}
343
- </div>
344
- `,this),this.syncCardElements(u,L?((Y=u.get(L.nodeId))==null?void 0:Y.artifactID)??null:null),this.syncDraggedSlotElement(L)}syncCardElements(e,r){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===r)}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 r=this.clampPointerToViewport(this.lastPointerX,this.lastPointerY,e);(r.x!==this.lastPointerX||r.y!==this.lastPointerY)&&this.syncDragTarget(r.x,r.y,e)}syncDragTarget(e,r,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:r}),viewport:{left:i.left,top:i.top,width:i.width,height:i.height},geometry:a,effectiveVelocity:Math.max(this.pointerVelocityPxPerSec,this.scrollVelocityPxPerSec)})}resetMotionTracking(e,r){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=performance.now(),this.motionSampleX=e,this.motionSampleY=r}clearMotionTracking(){this.pointerVelocityPxPerSec=0,this.scrollVelocityPxPerSec=0,this.motionSampleTime=0}updatePointerVelocity(e,r){this.samplePointerVelocityAt(performance.now(),e,r)}samplePointerVelocityAt(e,r,i){if(this.motionSampleTime===0){this.motionSampleTime=e,this.motionSampleX=r,this.motionSampleY=i,this.pointerVelocityPxPerSec=0;return}const s=e-this.motionSampleTime;if(s<100)return;const o=r-this.motionSampleX;this.pointerVelocityPxPerSec=Math.abs(o)/s*Nm,this.motionSampleTime=e,this.motionSampleX=r,this.motionSampleY=i}clampPointerToViewport(e,r,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,r))}}getDragEdgeScrollDeltaPixels(e,r,i){var u;const s=r.left+il,o=r.left+r.width-il,a=((u=this.layoutGrid)==null?void 0:u.unit.x)??Hn,c=$T*a;if(e<s){const h=Math.max(0,Math.min(1,(s-e)/il));return-(c*h**Dg)*i}if(e>o){const h=Math.max(0,Math.min(1,(e-o)/il));return c*h**Dg*i}return 0}measureLayoutGeometry(e,r=0){const i=this.layoutGrid;if(!i)return[];const s=$r(e),o=new Map(s.nodes.map(E=>[E.id,E.width])),a=i.toPixels($e({y:ft})).y??yo,c=Yu(this),u=(this.layoutScroll.translate.x??0)+r,h=Hm(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??Qr,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 r;return(r=this.draggedSlotElement)!=null&&r.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="${Fm(e)}"][data-layout-drag-source="true"]`),this.draggedSlotElement)}syncDraggedSlotElement(e){if(!e||this.dragController.status!=="active"){this.draggedSlotElement=null;return}const r=this.getCachedDraggedSlotElement(e.nodeId);r&&this.writeDraggedSlotPosition(r,e)}shouldApplyTrackOffset(e,r){if(r)return!0;for(const i of e){if(i.type!=="stack")continue;if(i.children.some(o=>o.type==="drop-target")&&r!==i.id)return!0}return!1}computeDragTrackOffset(e,r,i,s,o,a){if(!e)return a;const c=s?o??this.getStableAnchorCardId(e,r,i):this.getStableAnchorNodeId(e,r,i);if(!c)return a;const u=s?Wm(e,c,this.layoutGrid):Vm(e,c,this.layoutGrid),h=s?Wm(r,c,this.layoutGrid):Vm(r,c,this.layoutGrid);return u===null||h===null?a:a+(u-h)}getStableAnchorCardId(e,r,i){const s=Zm(e),o=new Set(Zm(r));for(const a of s)if(a!==i&&o.has(a))return a;return null}getStableAnchorNodeId(e,r,i){const s=new Set(r.map(Fi));for(const o of e){const a=Fi(o);if(a!==i&&s.has(a))return a}return null}getStackChildAnchorCardId(e,r){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)!==r);return s?we(s):null}}function DN(n){const t=new Map;for(const e of n){if(e.type==="card"){t.set(we(e),e);continue}for(const r of e.children)if(r.type==="card")t.set(we(r),r);else for(const i of r.children)t.set(we(i),i)}return t}function zN(n){for(const t of n)if(t.type==="drop-target"||t.type==="stack"&&t.children.some(e=>e.type==="drop-target"))return t.id;return null}function ON(n,t){const e=n.findIndex(r=>r.type==="card"&&we(r)===t);if(e!==-1)return{topLevelIndex:e};for(let r=0;r<n.length;r+=1){const i=n[r];if(!(!i||i.type!=="stack")&&i.children.some(s=>s.type==="card"&&we(s)===t))return{topLevelIndex:r,sourceStackId:i.id}}return null}function Zm(n){const t=[];for(const e of n){if(e.type==="card"){t.push(we(e));continue}if(e.type==="stack"){const r=e.children.find(i=>i.type==="card");r&&t.push(we(r))}}return t}function Wm(n,t,e){if(!e)return null;const r=$r(n),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of n){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??Qr;s+=c+ae}return null}function Vm(n,t,e){if(!e)return null;const r=$r(n),i=new Map(r.nodes.map(o=>[o.id,o.width]));let s=0;for(const o of n){if(Fi(o)===t)return s;const a=i.get(Fi(o))??Ye,c=e.toPixels($e({x:a})).x??Qr;s+=c+ae}return null}customElements.get("layout-view")||customElements.define("layout-view",LN);class MN extends HTMLElement{constructor(){super(...arguments);g(this,"screenManager",dn.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 r=e;typeof r.scrollPosition=="number"&&Number.isFinite(r.scrollPosition)&&this.screenManager.activeScreen&&this.screenManager.activeScreen.setScrollPosition(r.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 r=e.target;if(r instanceof Node&&((s=this.querySelector("layout-view"))!=null&&s.contains(r)))return;const i=this.querySelector("layout-view");i&&(e.preventDefault(),i.stepFilmstrip(e.key==="ArrowRight"?1:-1))});g(this,"handleServerEvent",e=>{const r=e.event;if(r.type!=="artifact-focus"||!this.boundModel||r.screenID!==this.boundModel.id)return;const i=this.querySelector("layout-view");i&&i.focusArtifact(r.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 r=e.closest("input, textarea, select, [contenteditable], [role='textbox'], [role='searchbox'], [role='combobox'], [role='spinbutton'], [role='slider']");return r?r.hasAttribute("contenteditable")?((i=r.getAttribute("contenteditable"))==null?void 0:i.toLowerCase())!=="false":!0:!1}buildCards(e){if(!e)return this.disposeCardElements(),new Map;const r=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),r.set(i.id,s)}for(const[i,s]of this.cardEls)r.has(i)||(s.remove(),this.cardEls.delete(i));return r}disposeCardElements(){for(const e of this.cardEls.values())e.remove();this.cardEls.clear()}render(){const e=this.screenManager.activeScreen,r=(e==null?void 0:e.layout)??[],i=this.buildCards(e);if(r.length===0){Ve(P``,this);return}Ve(P`
345
- <layout-view
346
- .layout=${r}
347
- .cards=${i}
348
- .scrollPosition=${(e==null?void 0:e.scrollPosition)??0}
349
- @scroll=${this.handleScrollPositionChanged}
350
- @layout-change=${this.handleLayoutChanged}
351
- @close-artifact=${this.handleCloseArtifact}
352
- ></layout-view>
353
- `,this)}}customElements.define("screen-view",MN);function ec(n){return typeof n=="object"&&n!==null}const Ku=new WeakMap,Bm=Object.prototype.hasOwnProperty,NN=(()=>{const n=new Set;let t=HTMLElement.prototype;for(;t;){for(const e of Object.getOwnPropertyNames(t))n.add(e);if(t===Node.prototype)break;t=Object.getPrototypeOf(t)}return n})();function UN(n,t){if(ec(n))return t===null?void 0:n.parse(t);if(n===Boolean)return t!==null;if(t!==null)return n===Number?Number(t):t}function FN(n,t){return ec(n)?t==null?null:n.serialize(t):n===Boolean?t?"":null:t==null?null:String(t)}var pa,ad,qr,mt,rn,ss,Yr,os,xe,Ri,E0,A0,T0,$0,Ll;const Ar=class Ar extends HTMLElement{constructor(){var i;super();w(this,xe);w(this,qr,new Map);w(this,mt,new Map);w(this,rn,new Map);w(this,ss,!1);w(this,Yr,!1);w(this,os,!1);const e=p(i=Ar,pa,ad).call(i,this.constructor),r=this;for(const s of e.properties)Bm.call(r,s)&&(l(this,rn).set(s,r[s]),delete r[s])}static get observedAttributes(){var e;return p(e=Ar,pa,ad).call(e,this).observedAttributes}connected(){}disconnected(){}changed(e){}connectedCallback(){if(p(this,xe,$0).call(this),!l(this,Yr))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,r,i){if(r===i)return;const s=p(this,xe,Ri).call(this).byAttr.get(e);s&&(l(this,rn).has(s.property)||(this[s.property]=UN(s.type,i)))}};pa=new WeakSet,ad=function(e){const r=Ku.get(e);if(r)return r;const i=[...e.properties??[]],s=e.attributes??{},o=new Map,a=new Map;for(const u of i)if(NN.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,qr).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 Ku.set(e,c),c},qr=new WeakMap,mt=new WeakMap,rn=new WeakMap,ss=new WeakMap,Yr=new WeakMap,os=new WeakMap,xe=new WeakSet,Ri=function(){return Ku.get(this.constructor)},E0=function(e,r){if(!l(this,os)&&l(this,rn).has(e))return;const i=l(this,qr).get(e);p(this,xe,A0).call(this,e,i,r)||(l(this,mt).has(e)||l(this,mt).set(e,i),l(this,qr).set(e,r),l(this,rn).delete(e),p(this,xe,T0).call(this,e,r),this.isConnected&&p(this,xe,Ll).call(this))},A0=function(e,r,i){if(Object.is(r,i))return!0;const s=p(this,xe,Ri).call(this).byProp.get(e);if(!s||!ec(s.type))return!1;const o=r==null,a=i==null;if(o||a)return o&&a;try{return s.type.serialize(r)===s.type.serialize(i)}catch{return!1}},T0=function(e,r){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);r&&!c?this.setAttribute(s,""):!r&&c&&this.removeAttribute(s);return}const a=FN(o,r);if(a===null){this.hasAttribute(s)&&this.removeAttribute(s);return}this.getAttribute(s)!==a&&this.setAttribute(s,a)},$0=function(){const e=this,r=p(this,xe,Ri).call(this);for(const i of r.properties){if(!Bm.call(e,i))continue;const s=e[i];delete e[i],!(l(this,rn).has(i)||l(this,qr).has(i))&&(e[i]=s)}b(this,os,!0);try{for(const[i,s]of l(this,rn))e[i]=s;l(this,rn).clear()}finally{b(this,os,!1)}},Ll=function(){l(this,ss)||!this.isConnected||l(this,Yr)&&l(this,mt).size===0||(b(this,ss,!0),queueMicrotask(()=>{if(b(this,ss,!1),!this.isConnected||l(this,Yr)&&l(this,mt).size===0)return;const e=new Map(l(this,mt));l(this,mt).clear(),b(this,Yr,!0);try{this.changed(e)}catch(r){console.error(r)}this.isConnected&&l(this,mt).size>0&&p(this,xe,Ll).call(this)}))},w(Ar,pa),g(Ar,"properties"),g(Ar,"attributes");let bs=Ar;var fe,$n,Xn,as,Qn,In,fa,ga,Te,ls,Cn,sn,F,I0,ma,va,ya,ba,ld,cd,ud,C0,R0,P0,L0,hc,dc,pc,fc,hd,D0,Dl,z0,wa,gc,mc,oo,vc,O0,M0,N0,U0,F0,H0,qe;class HN extends bs{constructor(){super(...arguments);w(this,F);w(this,fe,dn.resolve("ScreenManager"));w(this,$n,dn.resolve("ServerManager"));w(this,Xn,null);w(this,as,new DisposableStack);w(this,Qn,Xs());w(this,In,Xs());w(this,fa,Xs());w(this,ga,Xs());w(this,Te,{kind:"none"});w(this,ls,!1);w(this,Cn,null);w(this,sn,[]);w(this,ma,()=>{p(this,F,ld).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,sn,p(this,F,D0).call(this));const e=((i=l(this,fe).activeScreen)==null?void 0:i.id)??null,r=e&&l(this,sn).some(o=>o.screenID===e)?e:((s=l(this,sn)[0])==null?void 0:s.screenID)??null;b(this,Te,{kind:"picker",filter:"",highlightedID:r}),l(this,qe).call(this),queueMicrotask(()=>{var o;(o=l(this,fa).value)==null||o.focus()})});w(this,dc,e=>{var u;const r=l(this,Te);if(r.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,sn),s),c=r.highlightedID!==null&&o.some(h=>h.screenID===r.highlightedID)?r.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 r=l(this,Te);if(r.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,Qn).value)==null||s.focus();return}const i=p(this,F,Dl).call(this,l(this,sn),r.filter);if(e.key==="ArrowDown"||e.key==="ArrowUp"){if(e.preventDefault(),i.length===0)return;const o=i.findIndex(u=>u.screenID===r.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:r.filter,highlightedID:i[c].screenID}),l(this,qe).call(this);return}if(e.key==="Enter"){e.preventDefault();const o=i.find(a=>a.screenID===r.highlightedID);o&&p(this,F,hd).call(this,o)}});w(this,fc,e=>{p(this,F,hd).call(this,e)});w(this,wa,()=>{var e;l(this,Cn)!==null&&(b(this,Cn,null),l(this,qe).call(this),(e=l(this,Qn).value)==null||e.focus())});w(this,gc,()=>{var i;const e=l(this,Cn);if(e===null)return;b(this,Cn,null),l(this,qe).call(this);const r=l(this,$n).servers.get(e.serverURL);r==null||r.client.screens.remove({screenID:e.screenID}).catch(()=>{}),(i=l(this,Qn).value)==null||i.focus()});w(this,mc,e=>{l(this,Te).kind==="picker"&&e.target===l(this,In).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 r=await e.createScreen(ZN(new Date));l(this,fe).addTab(e.url,r.id),l(this,fe).setActive(e.url,r.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
- <div class="pills" role="group" aria-label="Open tabs">
356
- ${e.map(r=>p(this,F,N0).call(this,r))}
357
- </div>
358
- ${p(this,F,U0).call(this)}
359
- ${p(this,F,H0).call(this)}
360
- `,this),l(this,In).value&&(l(this,In).value.anchor=l(this,Qn).value??null)})}connected(){l(this,fe).addEventListener("active-screen-changed",l(this,ma)),l(this,fe).addEventListener("tabs-changed",l(this,va)),l(this,$n).addEventListener("screens-changed",l(this,ya)),p(this,F,ld).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,$n).removeEventListener("screens-changed",l(this,ya)),p(this,F,cd).call(this)})}disconnected(){l(this,as).dispose(),b(this,as,new DisposableStack)}}fe=new WeakMap,$n=new WeakMap,Xn=new WeakMap,as=new WeakMap,Qn=new WeakMap,In=new WeakMap,fa=new WeakMap,ga=new WeakMap,Te=new WeakMap,ls=new WeakMap,Cn=new WeakMap,sn=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,ld=function(){var r;const e=l(this,fe).activeScreen;l(this,Xn)!==e&&(p(this,F,cd).call(this),b(this,Xn,e),(r=l(this,Xn))==null||r.addEventListener("change",l(this,ba)))},cd=function(){var e;(e=l(this,Xn))==null||e.removeEventListener("change",l(this,ba)),b(this,Xn,null)},ud=function(e,r){l(this,fe).setActive(e,r)},C0=function(e,r,i){i.stopPropagation();const s=l(this,fe).getTabs(e),o=p(this,F,L0).call(this,s,r),a=l(this,fe).activeScreen,c=(a==null?void 0:a.id)===r&&a.server.url===e;l(this,fe).removeTab(e,r),c&&(o?l(this,fe).setActive(e,o):l(this,fe).clearActive())},R0=function(e,r,i){const s=l(this,fe).activeScreen;if((s==null?void 0:s.id)===r){s.rename(i.value);return}const o=l(this,$n).servers.get(e),a=o==null?void 0:o.screens.get(r);!o||!a||o.client.screens.update({screenID:r,name:i.value}).catch(()=>{})},P0=function(){const e=l(this,fe).activeScreen,r=[];for(const i of l(this,$n).servers.values())for(const s of l(this,fe).getTabs(i.url)){const o=i.screens.get(s);o&&r.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 r},L0=function(e,r){const i=e.indexOf(r);if(i<0)return null;const s=e.filter(a=>a!==r);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,hd=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,r){const i=r.trim().toLowerCase();return i.length===0?e:e.filter(s=>s.name.toLowerCase().includes(i))},z0=function(e,r){r.stopPropagation(),p(this,F,oo).call(this),b(this,Cn,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,In).value&&(l(this,In).value.open=!1),b(this,Te,{kind:"none"}),l(this,qe).call(this))},vc=new WeakMap,O0=function(){for(const e of l(this,$n).servers.values())return e;return null},M0=function(){return P`
361
- <segmented-control variant="glass" role="group" aria-label="Screens">
362
- <button
363
- type="button"
364
- ?icon-only=${!0}
365
- aria-label="Choose screen"
366
- @click=${l(this,hc)}
367
- ${Qs(l(this,Qn))}
368
- >
369
- ${cM({size:16,weight:"regular"})}
370
- </button>
371
- <button
372
- type="button"
373
- ?icon-only=${!0}
374
- aria-label="New screen"
375
- @click=${l(this,vc)}
376
- >
377
- ${uM({size:16,weight:"regular"})}
378
- </button>
379
- </segmented-control>
380
- `},N0=function(e){return P`
381
- <span class="tab" ?data-active=${e.isActive}>
382
- <button
383
- type="button"
384
- variant="glass"
385
- class="screen-name tab-body"
386
- aria-pressed=${e.isActive?"true":"false"}
387
- aria-current=${e.isActive?"page":le}
388
- aria-label=${e.isActive?`Current tab: ${e.name}`:`Switch to ${e.name}`}
389
- @mousedown=${r=>{r.button===0&&p(this,F,ud).call(this,e.serverURL,e.screenID)}}
390
- @click=${()=>p(this,F,ud).call(this,e.serverURL,e.screenID)}
391
- >
392
- <span class="tab-leading">
393
- ${aM({weight:"bold"})}
394
- </span>
395
- <editable-text
396
- class="tab-name"
397
- .value=${e.name}
398
- @rename=${r=>p(this,F,R0).call(this,e.serverURL,e.screenID,r)}
399
- ></editable-text>
400
- </button>
401
- <button
402
- type="button"
403
- variant="ghost"
404
- size="xs"
405
- icon-only
406
- class="tab-close"
407
- aria-label=${`Close ${e.name}`}
408
- @click=${r=>p(this,F,C0).call(this,e.serverURL,e.screenID,r)}
409
- >
410
- ${fp({weight:"bold"})}
411
- </button>
412
- </span>
413
- `},U0=function(){var o;const e=l(this,Te).kind==="picker"?l(this,Te).filter:"",r=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,sn),e);return P`
414
- <ui-popover
415
- class="picker-popover"
416
- material="glass-frosted"
417
- ?open=${l(this,Te).kind==="picker"}
418
- @close=${l(this,mc)}
419
- @keydown=${l(this,pc)}
420
- ${Qs(l(this,In))}
421
- >
422
- <div class="picker">
423
- <input
424
- type="text"
425
- class="picker-filter"
426
- placeholder="Filter screens"
427
- aria-label="Filter screens"
428
- .value=${e}
429
- @input=${l(this,dc)}
430
- ${Qs(l(this,fa))}
431
- />
432
- ${s.length===0?P`<p class="picker-empty">
433
- ${l(this,sn).length===0?"No screens":"No matches"}
434
- </p>`:p(this,F,F0).call(this,s,r,i)}
435
- </div>
436
- </ui-popover>
437
- `},F0=function(e,r,i){return P`
438
- <ul class="picker-list" role="listbox">
439
- <li class="picker-section-label" role="presentation">Recent</li>
440
- ${e.map(s=>{const o=s.screenID===i;return P`
441
- <li
442
- class="picker-row"
443
- role="option"
444
- aria-selected=${s.screenID===r}
445
- aria-current=${o?"true":le}
446
- ?data-highlighted=${s.screenID===r}
447
- ?data-active=${o}
448
- @click=${()=>l(this,fc).call(this,s)}
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
- ${hM({size:16,weight:"regular"})}
461
- </button>
462
- </li>
463
- `})}
464
- </ul>
465
- `},H0=function(){const e=l(this,Cn);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",HN);function ZN(n){const t=n.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),e=12,r=n.getHours(),i=r%e===0?e:r%e,s=n.getMinutes().toString().padStart(2,"0"),o=r>=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:jm,isFrozen:WN,getPrototypeOf:VN,getOwnPropertyDescriptor:BN}=Object;let{freeze:nt,seal:_t,create:zl}=Object,{apply:dd,construct:pd}=typeof Reflect<"u"&&Reflect;nt||(nt=function(t){return t});_t||(_t=function(t){return t});dd||(dd=function(t,e){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];return t.apply(e,i)});pd||(pd=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return new t(...r)});const hl=rt(Array.prototype.forEach),jN=rt(Array.prototype.lastIndexOf),Gm=rt(Array.prototype.pop),Hs=rt(Array.prototype.push),GN=rt(Array.prototype.splice),Ol=rt(String.prototype.toLowerCase),Ju=rt(String.prototype.toString),Xu=rt(String.prototype.match),Zs=rt(String.prototype.replace),qN=rt(String.prototype.indexOf),YN=rt(String.prototype.trim),ht=rt(Object.prototype.hasOwnProperty),Ke=rt(RegExp.prototype.test),Ws=KN(TypeError);function rt(n){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return dd(n,t,r)}}function KN(n){return function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return pd(n,e)}}function G(n,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ol;jm&&jm(n,null);let r=t.length;for(;r--;){let i=t[r];if(typeof i=="string"){const s=e(i);s!==i&&(WN(t)||(t[r]=s),i=s)}n[i]=!0}return n}function JN(n){for(let t=0;t<n.length;t++)ht(n,t)||(n[t]=null);return n}function Vt(n){const t=zl(null);for(const[e,r]of Z0(n))ht(n,e)&&(Array.isArray(r)?t[e]=JN(r):r&&typeof r=="object"&&r.constructor===Object?t[e]=Vt(r):t[e]=r);return t}function Vs(n,t){for(;n!==null;){const r=BN(n,t);if(r){if(r.get)return rt(r.get);if(typeof r.value=="function")return rt(r.value)}n=VN(n)}function e(){return null}return e}const qm=nt(["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"]),Qu=nt(["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"]),eh=nt(["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"]),XN=nt(["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"]),th=nt(["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"]),QN=nt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Ym=nt(["#text"]),Km=nt(["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"]),nh=nt(["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"]),Jm=nt(["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=nt(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),e6=_t(/\{\{[\w\W]*|[\w\W]*\}\}/gm),t6=_t(/<%[\w\W]*|[\w\W]*%>/gm),n6=_t(/\$\{[\w\W]*/gm),r6=_t(/^data-[\-\w.\u00B7-\uFFFF]+$/),i6=_t(/^aria-[\-\w]+$/),W0=_t(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),s6=_t(/^(?:\w+script|data):/i),o6=_t(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),V0=_t(/^html$/i),a6=_t(/^[a-z][.\w]*(-[.\w]+)+$/i);var Xm=Object.freeze({__proto__:null,ARIA_ATTR:i6,ATTR_WHITESPACE:o6,CUSTOM_ELEMENT:a6,DATA_ATTR:r6,DOCTYPE_NAME:V0,ERB_EXPR:t6,IS_ALLOWED_URI:W0,IS_SCRIPT_OR_DATA:s6,MUSTACHE_EXPR:e6,TMPLIT_EXPR:n6});const Bs={element:1,text:3,progressingInstruction:7,comment:8,document:9},l6=function(){return typeof window>"u"?null:window},c6=function(t,e){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";e&&e.hasAttribute(i)&&(r=e.getAttribute(i));const s="dompurify"+(r?"#"+r:"");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}},Qm=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function B0(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:l6();const t=U=>B0(U);if(t.version="3.3.3",t.removed=[],!n||!n.document||n.document.nodeType!==Bs.document||!n.Element)return t.isSupported=!1,t;let{document:e}=n;const r=e,i=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:a,Element:c,NodeFilter:u,NamedNodeMap:h=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:f,DOMParser:y,trustedTypes:m}=n,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:pr}=r;let ze=Qm();t.isSupported=typeof Z0=="function"&&typeof V=="function"&&Y&&Y.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:fr,ERB_EXPR:Ut,TMPLIT_EXPR:Mn,DATA_ATTR:Bc,ARIA_ATTR:Ha,IS_SCRIPT_OR_DATA:dS,ATTR_WHITESPACE:Tp,CUSTOM_ELEMENT:pS}=Xm;let{IS_ALLOWED_URI:$p}=Xm,Re=null;const Ip=G({},[...qm,...Qu,...eh,...th,...Ym]);let Oe=null;const Cp=G({},[...Km,...nh,...Jm,...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 Nn=Object.seal(zl(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Rp=!0,jc=!0,Pp=!1,Lp=!0,ui=!1,Wa=!0,gr=!1,Gc=!1,qc=!1,hi=!1,Va=!1,Ba=!1,Dp=!0,zp=!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 Op=null;const Mp=G({},["audio","video","img","source","image","track"]);let Jc=null;const Np=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",pn="http://www.w3.org/1999/xhtml";let pi=pn,Xc=!1,Qc=null;const gS=G({},[ja,Ga,pn],Ju);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"),Up=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"?Ju:Ol,Re=ht(S,"ALLOWED_TAGS")?G({},S.ALLOWED_TAGS,Ae):Ip,Oe=ht(S,"ALLOWED_ATTR")?G({},S.ALLOWED_ATTR,Ae):Cp,Qc=ht(S,"ALLOWED_NAMESPACES")?G({},S.ALLOWED_NAMESPACES,Ju):gS,Jc=ht(S,"ADD_URI_SAFE_ATTR")?G(Vt(Np),S.ADD_URI_SAFE_ATTR,Ae):Np,Op=ht(S,"ADD_DATA_URI_TAGS")?G(Vt(Mp),S.ADD_DATA_URI_TAGS,Ae):Mp,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,Rp=S.ALLOW_ARIA_ATTR!==!1,jc=S.ALLOW_DATA_ATTR!==!1,Pp=S.ALLOW_UNKNOWN_PROTOCOLS||!1,Lp=S.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ui=S.SAFE_FOR_TEMPLATES||!1,Wa=S.SAFE_FOR_XML!==!1,gr=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,Dp=S.SANITIZE_DOM!==!1,zp=S.SANITIZE_NAMED_PROPS||!1,Yc=S.KEEP_CONTENT!==!1,Ls=S.IN_PLACE||!1,$p=S.ALLOWED_URI_REGEXP||W0,pi=S.NAMESPACE||pn,qa=S.MATHML_TEXT_INTEGRATION_POINTS||qa,Ya=S.HTML_INTEGRATION_POINTS||Ya,Se=S.CUSTOM_ELEMENT_HANDLING||{},S.CUSTOM_ELEMENT_HANDLING&&Up(S.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Se.tagNameCheck=S.CUSTOM_ELEMENT_HANDLING.tagNameCheck),S.CUSTOM_ELEMENT_HANDLING&&Up(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({},Ym),Oe=zl(null),di.html===!0&&(G(Re,qm),G(Oe,Km)),di.svg===!0&&(G(Re,Qu),G(Oe,nh),G(Oe,dl)),di.svgFilters===!0&&(G(Re,eh),G(Oe,nh),G(Oe,dl)),di.mathMl===!0&&(G(Re,th),G(Oe,Jm),G(Oe,dl))),ht(S,"ADD_TAGS")||(Nn.tagCheck=null),ht(S,"ADD_ATTR")||(Nn.attributeCheck=null),S.ADD_TAGS&&(typeof S.ADD_TAGS=="function"?Nn.tagCheck=S.ADD_TAGS:(Re===Ip&&(Re=Vt(Re)),G(Re,S.ADD_TAGS,Ae))),S.ADD_ATTR&&(typeof S.ADD_ATTR=="function"?Nn.attributeCheck=S.ADD_ATTR:(Oe===Cp&&(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),gr&&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=c6(m,i)),N!==null&&typeof H=="string"&&(H=N.createHTML(""));nt&&nt(S),fi=S}},Fp=G({},[...Qu,...eh,...XN]),Hp=G({},[...th,...QN]),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===pn?D==="svg":C.namespaceURI===ja?D==="svg"&&(de==="annotation-xml"||qa[de]):!!Fp[D]:S.namespaceURI===ja?C.namespaceURI===pn?D==="math":C.namespaceURI===Ga?D==="math"&&Ya[de]:!!Hp[D]:S.namespaceURI===pn?C.namespaceURI===Ga&&!Ya[de]||C.namespaceURI===ja&&!qa[de]?!1:!Hp[D]&&(mS[D]||!Fp[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)}},mr=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{}},Zp=function(S){let C=null,D=null;if(qc)S="<remove></remove>"+S;else{const _e=Xu(S,/^[\r\n\t ]+/);D=_e&&_e[0]}Ds==="application/xhtml+xml"&&pi===pn&&(S='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+S+"</body></html>");const de=N?N.createHTML(S):S;if(pi===pn)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===pn?Tt.call(C,gr?"html":"body")[0]:gr?C.documentElement:je},Wp=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")},Vp=function(S){return typeof a=="function"&&S instanceof a};function fn(U,S,C){hl(U,D=>{D.call(t,S,C,fi)})}const Bp=function(S){let C=null;if(fn(ze.beforeSanitizeElements,S,null),tu(S))return Ht(S),!0;const D=Ae(S.nodeName);if(fn(ze.uponSanitizeElement,S,{tagName:D,allowedTags:Re}),Wa&&S.hasChildNodes()&&!Vp(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(!(Nn.tagCheck instanceof Function&&Nn.tagCheck(D))&&(!Re[D]||Ps[D])){if(!Ps[D]&&Gp(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 gn=x(je[it],!0);gn.__removalCount=(S.__removalCount||0)+1,de.insertBefore(gn,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([fr,Ut,Mn],de=>{C=Zs(C,de," ")}),S.textContent!==C&&(Hs(t.removed,{element:S.cloneNode()}),S.textContent=C)),fn(ze.afterSanitizeElements,S,null),!1)},jp=function(S,C,D){if(Za[C]||Dp&&(C==="id"||C==="name")&&(D in e||D in bS))return!1;if(!(jc&&!Za[C]&&Ke(Bc,C))){if(!(Rp&&Ke(Ha,C))){if(!(Nn.attributeCheck instanceof Function&&Nn.attributeCheck(C,S))){if(!Oe[C]||Za[C]){if(!(Gp(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($p,Zs(D,Tp,""))){if(!((C==="src"||C==="xlink:href"||C==="href")&&S!=="script"&&qN(D,"data:")===0&&Op[S])){if(!(Pp&&!Ke(dS,Zs(D,Tp,"")))){if(D)return!1}}}}}}}return!0},Gp=function(S){return S!=="annotation-xml"&&Xu(S,pS)},qp=function(S){fn(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:gn}=je,gi=Ae(_e),nu=gn;let Me=_e==="value"?nu:YN(nu);if(D.attrName=gi,D.attrValue=Me,D.keepAttr=!0,D.forceKeepAttr=void 0,fn(ze.uponSanitizeAttribute,S,D),Me=D.attrValue,zp&&(gi==="id"||gi==="name")&&(mr(_e,S),Me=fS+Me),Wa&&Ke(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Me)){mr(_e,S);continue}if(gi==="attributename"&&Xu(Me,"href")){mr(_e,S);continue}if(D.forceKeepAttr)continue;if(!D.keepAttr){mr(_e,S);continue}if(!Lp&&Ke(/\/>/i,Me)){mr(_e,S);continue}ui&&hl([fr,Ut,Mn],Kp=>{Me=Zs(Me,Kp," ")});const Yp=Ae(S.nodeName);if(!jp(Yp,gi,Me)){mr(_e,S);continue}if(N&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!it)switch(m.getAttributeType(Yp,gi)){case"TrustedHTML":{Me=N.createHTML(Me);break}case"TrustedScriptURL":{Me=N.createScriptURL(Me);break}}if(Me!==nu)try{it?S.setAttributeNS(it,_e,Me):S.setAttribute(_e,Me),tu(S)?Ht(S):Gm(t.removed)}catch{mr(_e,S)}}fn(ze.afterSanitizeAttributes,S,null)},SS=function U(S){let C=null;const D=Wp(S);for(fn(ze.beforeSanitizeShadowDOM,S,null);C=D.nextNode();)fn(ze.uponSanitizeShadowNode,C,null),Bp(C),qp(C),C.content instanceof s&&U(C.content);fn(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"&&!Vp(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 gn=Ae(U.nodeName);if(!Re[gn]||Ps[gn])throw Ws("root node is forbidden and cannot be sanitized in-place")}}else if(U instanceof a)C=Zp("<!---->"),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&&!gr&&U.indexOf("<")===-1)return N&&Ba?N.createHTML(U):U;if(C=Zp(U),!C)return hi?null:Ba?H:""}C&&qc&&Ht(C.firstChild);const _e=Wp(Ls?U:C);for(;de=_e.nextNode();)Bp(de),qp(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=pr.call(r,je,!0)),je}let it=gr?C.outerHTML:C.innerHTML;return gr&&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([fr,Ut,Mn],gn=>{it=Zs(it,gn," ")}),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 jp(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=jN(ze[U],S);return C===-1?void 0:GN(ze[U],C,1)[0]}return Gm(ze[U])},t.removeHooks=function(U){ze[U]=[]},t.removeAllHooks=function(){ze=Qm()},t}var j0=B0();function mp(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ci=mp();function G0(n){ci=n}var Er={exec:()=>null};function J(n,t=""){let e=typeof n=="string"?n:n.source,r={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(tt.caret,"$1"),e=e.replace(i,o),r},getRegex:()=>new RegExp(e,t)};return r}var u6=(()=>{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:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),htmlBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}>`)},h6=/^(?:[ \t]*(?:\n|$))+/,d6=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,p6=/^ {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+|$)/,f6=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,vp=/ {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,vp).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(),g6=J(q0).replace(/bull/g,vp).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(),yp=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,m6=/^[^\n]+/,bp=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,v6=J(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",bp).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),y6=J(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,vp).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",wp=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,b6=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",wp).replace("tag",Wc).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),K0=J(yp).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(),w6=J(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",K0).getRegex(),Sp={blockquote:w6,code:d6,def:v6,fences:p6,heading:f6,hr:Fa,html:b6,lheading:Y0,list:y6,newline:h6,paragraph:K0,table:Er,text:m6},ev=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(),S6={...Sp,lheading:g6,table:ev,paragraph:J(yp).replace("hr",Fa).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ev).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()},_6={...Sp,html:J(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",wp).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:Er,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:J(yp).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()},k6=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,x6=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,J0=/^( {2,}|\\)\n(?!\s*$)/,E6=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Rs=/[\p{P}\p{S}]/u,Vc=/[\s\p{P}\p{S}]/u,_p=/[^\s\p{P}\p{S}]/u,A6=J(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Vc).getRegex(),X0=/(?!~)[\p{P}\p{S}]/u,T6=/(?!~)[\s\p{P}\p{S}]/u,$6=/(?:[^\s\p{P}\p{S}]|~)/u,I6=J(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",u6?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Q0=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,C6=J(Q0,"u").replace(/punct/g,Rs).getRegex(),R6=J(Q0,"u").replace(/punct/g,X0).getRegex(),eS="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",P6=J(eS,"gu").replace(/notPunctSpace/g,_p).replace(/punctSpace/g,Vc).replace(/punct/g,Rs).getRegex(),L6=J(eS,"gu").replace(/notPunctSpace/g,$6).replace(/punctSpace/g,T6).replace(/punct/g,X0).getRegex(),D6=J("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,_p).replace(/punctSpace/g,Vc).replace(/punct/g,Rs).getRegex(),z6=J(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Rs).getRegex(),O6="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",M6=J(O6,"gu").replace(/notPunctSpace/g,_p).replace(/punctSpace/g,Vc).replace(/punct/g,Rs).getRegex(),N6=J(/\\(punct)/,"gu").replace(/punct/g,Rs).getRegex(),U6=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(),F6=J(wp).replace("(?:-->|$)","-->").getRegex(),H6=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",F6).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),tc=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Z6=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",bp).getRegex(),nS=J(/^!?\[(ref)\](?:\[\])?/).replace("ref",bp).getRegex(),W6=J("reflink|nolink(?!\\()","g").replace("reflink",tS).replace("nolink",nS).getRegex(),tv=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,kp={_backpedal:Er,anyPunctuation:N6,autolink:U6,blockSkip:I6,br:J0,code:x6,del:Er,delLDelim:Er,delRDelim:Er,emStrongLDelim:C6,emStrongRDelimAst:P6,emStrongRDelimUnd:D6,escape:k6,link:Z6,nolink:nS,punctuation:A6,reflink:tS,reflinkSearch:W6,tag:H6,text:E6,url:Er},V6={...kp,link:J(/^!?\[(label)\]\((.*?)\)/).replace("label",tc).getRegex(),reflink:J(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",tc).getRegex()},fd={...kp,emStrongRDelimAst:L6,emStrongLDelim:R6,delLDelim:z6,delRDelim:M6,url:J(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",tv).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",tv).getRegex()},B6={...fd,br:J(J0).replace("{2,}","*").getRegex(),text:J(fd.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},pl={normal:Sp,gfm:S6,pedantic:_6},js={normal:kp,gfm:fd,breaks:B6,pedantic:V6},j6={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},nv=n=>j6[n];function Bt(n,t){if(t){if(tt.escapeTest.test(n))return n.replace(tt.escapeReplace,nv)}else if(tt.escapeTestNoEncode.test(n))return n.replace(tt.escapeReplaceNoEncode,nv);return n}function rv(n){try{n=encodeURI(n).replace(tt.percentDecode,"%")}catch{return null}return n}function iv(n,t){var s;let e=n.replace(tt.findPipe,(o,a,c)=>{let u=!1,h=a;for(;--h>=0&&c[h]==="\\";)u=!u;return u?"|":" |"}),r=e.split(tt.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!((s=r.at(-1))!=null&&s.trim())&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(tt.slashPipe,"|");return r}function Gs(n,t,e){let r=n.length;if(r===0)return"";let i=0;for(;i<r&&n.charAt(r-i-1)===t;)i++;return n.slice(0,r-i)}function G6(n,t){if(n.indexOf(t[1])===-1)return-1;let e=0;for(let r=0;r<n.length;r++)if(n[r]==="\\")r++;else if(n[r]===t[0])e++;else if(n[r]===t[1]&&(e--,e<0))return r;return e>0?-2:-1}function q6(n,t=0){let e=t,r="";for(let i of n)if(i===" "){let s=4-e%4;r+=" ".repeat(s),e+=s}else r+=i,e++;return r}function sv(n,t,e,r,i){let s=t.href,o=t.title||null,a=n[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let c={type:n[0].charAt(0)==="!"?"image":"link",raw:e,href:s,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,c}function Y6(n,t,e){let r=n.match(e.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
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(`
507
- `)}var nc=class{constructor(n){g(this,"options");g(this,"rules");g(this,"lexer");this.options=n||ci}space(n){let t=this.rules.block.newline.exec(n);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(n){let t=this.rules.block.code.exec(n);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(n){let t=this.rules.block.fences.exec(n);if(t){let e=t[0],r=Y6(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:r}}}heading(n){let t=this.rules.block.heading.exec(n);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let r=Gs(e,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(e=r.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(n){let t=this.rules.block.hr.exec(n);if(t)return{type:"hr",raw:Gs(t[0],`
509
- `)}}blockquote(n){let t=this.rules.block.blockquote.exec(n);if(t){let e=Gs(t[0],`
510
- `).split(`
511
- `),r="",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(`
512
- `),h=u.replace(this.rules.other.blockquoteSetextReplace,`
513
- $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
514
- ${u}`:u,i=i?`${i}
515
- ${h}`:h;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,s,!0),this.lexer.state.top=f,e.length===0)break;let y=s.at(-1);if((y==null?void 0:y.type)==="code")break;if((y==null?void 0:y.type)==="blockquote"){let m=y,E=m.raw+`
516
- `+e.join(`
517
- `),x=this.blockquote(E);s[s.length-1]=x,r=r.substring(0,r.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+`
518
- `+e.join(`
519
- `),x=this.list(E);s[s.length-1]=x,r=r.substring(0,r.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(`
520
- `);continue}}return{type:"blockquote",raw:r,tokens:s,text:i}}}list(n){var e,r;let t=this.rules.block.list.exec(n);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(;n;){let h=!1,f="",y="";if(!(t=a.exec(n))||this.rules.block.hr.test(n))break;f=t[0],n=n.substring(f.length);let m=q6(t[2].split(`
521
- `,1)[0],t[1].length),E=n.split(`
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+`
523
- `,n=n.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(;n;){let j=n.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+=`
526
- `+E}x=!E.trim(),f+=j+`
527
- `,n=n.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"||((r=h.tokens[0])==null?void 0:r.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(n){let t=this.rules.block.html.exec(n);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(n){let t=this.rules.block.def.exec(n);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=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:r,title:i}}}table(n){var o;let t=this.rules.block.table.exec(n);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let e=iv(t[1]),r=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===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?s.align.push("right"):this.rules.other.tableAlignCenter.test(a)?s.align.push("center"):this.rules.other.tableAlignLeft.test(a)?s.align.push("left"):s.align.push(null);for(let a=0;a<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(iv(a,s.header.length).map((c,u)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:s.align[u]})));return s}}lheading(n){let t=this.rules.block.lheading.exec(n);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(n){let t=this.rules.block.paragraph.exec(n);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(n){let t=this.rules.block.text.exec(n);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(n){let t=this.rules.inline.escape.exec(n);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(n){let t=this.rules.inline.tag.exec(n);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(n){let t=this.rules.inline.link.exec(n);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=G6(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 r=t[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3])}else i=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?r=r.slice(1):r=r.slice(1,-1)),sv(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(n,t){let e;if((e=this.rules.inline.reflink.exec(n))||(e=this.rules.inline.nolink.exec(n))){let r=(e[2]||e[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[r.toLowerCase()];if(!i){let s=e[0].charAt(0);return{type:"text",raw:s,text:s}}return sv(e,i,e[0],this.lexer,this.rules)}}emStrong(n,t,e=""){let r=this.rules.inline.emStrongLDelim.exec(n);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&e.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!e||this.rules.inline.punctuation.exec(e))){let i=[...r[0]].length-1,s,o,a=i,c=0,u=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,t=t.slice(-1*n.length+i);(r=u.exec(t))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(o=[...s].length,r[3]||r[4]){a+=o;continue}else if((r[5]||r[6])&&i%3&&!((i+o)%3)){c+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+c);let h=[...r[0]][0].length,f=n.slice(0,i+r.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(n){let t=this.rules.inline.code.exec(n);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(e),i=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return r&&i&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(n){let t=this.rules.inline.br.exec(n);if(t)return{type:"br",raw:t[0]}}del(n,t,e=""){let r=this.rules.inline.delLDelim.exec(n);if(r&&(!r[1]||!e||this.rules.inline.punctuation.exec(e))){let i=[...r[0]].length-1,s,o,a=i,c=this.rules.inline.delRDelim;for(c.lastIndex=0,t=t.slice(-1*n.length+i);(r=c.exec(t))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s||(o=[...s].length,o!==i))continue;if(r[3]||r[4]){a+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a);let u=[...r[0]][0].length,h=n.slice(0,i+r.index+u+o),f=h.slice(i,-i);return{type:"del",raw:h,text:f,tokens:this.lexer.inlineTokens(f)}}}}autolink(n){let t=this.rules.inline.autolink.exec(n);if(t){let e,r;return t[2]==="@"?(e=t[1],r="mailto:"+e):(e=t[1],r=e),{type:"link",raw:t[0],text:e,href:r,tokens:[{type:"text",raw:e,text:e}]}}}url(n){var e;let t;if(t=this.rules.inline.url.exec(n)){let r,i;if(t[2]==="@")r=t[0],i="mailto:"+r;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]);r=t[0],t[1]==="www."?i="http://"+t[0]:i=t[0]}return{type:"link",raw:t[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(n){let t=this.rules.inline.text.exec(n);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},Ot=class gd{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 nc,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 gd(e).lex(t)}static lexInline(t,e){return new gd(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 r=this.inlineQueue[e];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,e=[],r=!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+=`
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(`
532
- `)?"":`
533
- `)+a.raw,u.text+=`
534
- `+a.text,this.inlineQueue.at(-1).src=u.text):e.push(a);continue}if(a=this.tokenizer.fences(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.heading(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.hr(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.blockquote(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.list(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.html(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.def(t)){t=t.substring(a.raw.length);let u=e.at(-1);(u==null?void 0:u.type)==="paragraph"||(u==null?void 0:u.type)==="text"?(u.raw+=(u.raw.endsWith(`
535
- `)?"":`
536
- `)+a.raw,u.text+=`
537
- `+a.raw,this.inlineQueue.at(-1).src=u.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title},e.push(a));continue}if(a=this.tokenizer.table(t)){t=t.substring(a.raw.length),e.push(a);continue}if(a=this.tokenizer.lheading(t)){t=t.substring(a.raw.length),e.push(a);continue}let c=t;if((o=this.options.extensions)!=null&&o.startBlock){let u=1/0,h=t.slice(1),f;this.options.extensions.startBlock.forEach(y=>{f=y.call({lexer:this},h),typeof f=="number"&&f>=0&&(u=Math.min(u,f))}),u<1/0&&u>=0&&(c=t.substring(0,u+1))}if(this.state.top&&(a=this.tokenizer.paragraph(c))){let u=e.at(-1);r&&(u==null?void 0:u.type)==="paragraph"?(u.raw+=(u.raw.endsWith(`
538
- `)?"":`
539
- `)+a.raw,u.text+=`
540
- `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):e.push(a),r=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(`
541
- `)?"":`
542
- `)+a.raw,u.text+=`
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 r=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(r))!=null;)m.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)s=i[2]?i[2].length:0,r=r.slice(0,i.index+s)+"["+"a".repeat(i[0].length-s-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=((u=(c=this.options.hooks)==null?void 0:c.emStrongMask)==null?void 0:u.call({lexer:this},r))??r;let o=!1,a="";for(;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,r,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,r,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}},rc=class{constructor(n){g(this,"options");g(this,"parser");this.options=n||ci}space(n){return""}code({text:n,lang:t,escaped:e}){var s;let r=(s=(t||"").match(tt.notSpaceStart))==null?void 0:s[0],i=n.replace(tt.endingNewline,"")+`
544
- `;return r?'<pre><code class="language-'+Bt(r)+'">'+(e?i:Bt(i,!0))+`</code></pre>
545
- `:"<pre><code>"+(e?i:Bt(i,!0))+`</code></pre>
546
- `}blockquote({tokens:n}){return`<blockquote>
547
- ${this.parser.parse(n)}</blockquote>
548
- `}html({text:n}){return n}def(n){return""}heading({tokens:n,depth:t}){return`<h${t}>${this.parser.parseInline(n)}</h${t}>
549
- `}hr(n){return`<hr>
550
- `}list(n){let t=n.ordered,e=n.start,r="";for(let o=0;o<n.items.length;o++){let a=n.items[o];r+=this.listitem(a)}let i=t?"ol":"ul",s=t&&e!==1?' start="'+e+'"':"";return"<"+i+s+`>
551
- `+r+"</"+i+`>
552
- `}listitem(n){return`<li>${this.parser.parse(n.tokens)}</li>
553
- `}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
554
- `}table(n){let t="",e="";for(let i=0;i<n.header.length;i++)e+=this.tablecell(n.header[i]);t+=this.tablerow({text:e});let r="";for(let i=0;i<n.rows.length;i++){let s=n.rows[i];e="";for(let o=0;o<s.length;o++)e+=this.tablecell(s[o]);r+=this.tablerow({text:e})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
555
- <thead>
556
- `+t+`</thead>
557
- `+r+`</table>
558
- `}tablerow({text:n}){return`<tr>
559
- ${n}</tr>
560
- `}tablecell(n){let t=this.parser.parseInline(n.tokens),e=n.header?"th":"td";return(n.align?`<${e} align="${n.align}">`:`<${e}>`)+t+`</${e}>
561
- `}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${Bt(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:t,tokens:e}){let r=this.parser.parseInline(e),i=rv(n);if(i===null)return r;n=i;let s='<a href="'+n+'"';return t&&(s+=' title="'+Bt(t)+'"'),s+=">"+r+"</a>",s}image({href:n,title:t,text:e,tokens:r}){r&&(e=this.parser.parseInline(r,this.parser.textRenderer));let i=rv(n);if(i===null)return Bt(e);n=i;let s=`<img src="${n}" alt="${Bt(e)}"`;return t&&(s+=` title="${Bt(t)}"`),s+=">",s}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:Bt(n.text)}},xp=class{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}checkbox({raw:n}){return n}},Mt=class md{constructor(t){g(this,"options");g(this,"renderer");g(this,"textRenderer");this.options=t||ci,this.options.renderer=this.options.renderer||new rc,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new xp}static parse(t,e){return new md(e).parse(t)}static parseInline(t,e){return new md(e).parseInline(t)}parse(t){var r,i;this.renderer.parser=this;let e="";for(let s=0;s<t.length;s++){let o=t[s];if((i=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&i[o.type]){let c=o,u=this.options.extensions.renderers[c.type].call({parser:this},c);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(c.type)){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 r="";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)){r+=u||"";continue}}let c=a;switch(c.type){case"escape":{r+=e.text(c);break}case"html":{r+=e.html(c);break}case"link":{r+=e.link(c);break}case"image":{r+=e.image(c);break}case"checkbox":{r+=e.checkbox(c);break}case"strong":{r+=e.strong(c);break}case"em":{r+=e.em(c);break}case"codespan":{r+=e.codespan(c);break}case"br":{r+=e.br(c);break}case"del":{r+=e.del(c);break}case"text":{r+=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 r}},fl,ao=(fl=class{constructor(n){g(this,"options");g(this,"block");this.options=n||ci}preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}emStrongMask(n){return n}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),K6=class{constructor(...n){g(this,"defaults",mp());g(this,"options",this.setOptions);g(this,"parse",this.parseMarkdown(!0));g(this,"parseInline",this.parseMarkdown(!1));g(this,"Parser",Mt);g(this,"Renderer",rc);g(this,"TextRenderer",xp);g(this,"Lexer",Ot);g(this,"Tokenizer",nc);g(this,"Hooks",ao);this.use(...n)}walkTokens(n,t){var r,i;let e=[];for(let s of n)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=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&i[o.type]?this.defaults.extensions.childTokens[o.type].forEach(a=>{let c=o[a].flat(1/0);e=e.concat(this.walkTokens(c,t))}):o.tokens&&(e=e.concat(this.walkTokens(o.tokens,t)))}}return e}use(...n){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(e=>{let r={...e};if(r.async=this.defaults.async||r.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)}),r.extensions=t),e.renderer){let i=this.defaults.renderer||new rc(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||""}}r.renderer=i}if(e.tokenizer){let i=this.defaults.tokenizer||new nc(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}}r.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}}r.hooks=i}if(e.walkTokens){let i=this.defaults.walkTokens,s=e.walkTokens;r.walkTokens=function(o){let a=[];return a.push(s.call(this,o)),i&&(a=a.concat(i.call(this,o))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,t){return Ot.lex(n,t??this.defaults)}parser(n,t){return Mt.parse(n,t??this.defaults)}parseMarkdown(n){return(t,e)=>{let r={...e},i={...this.defaults,...r},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof 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=n),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(t):t,a=await(i.hooks?await i.hooks.provideLexer():n?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():n?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():n?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():n?Mt.parse:Mt.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return s(o)}}}onError(n,t){return e=>{if(e.message+=`
562
- Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error occurred:</p><pre>"+Bt(e.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(e);throw e}}},ii=new K6;function ne(n,t){return ii.parse(n,t)}ne.options=ne.setOptions=function(n){return ii.setOptions(n),ne.defaults=ii.defaults,G0(ne.defaults),ne};ne.getDefaults=mp;ne.defaults=ci;ne.use=function(...n){return ii.use(...n),ne.defaults=ii.defaults,G0(ne.defaults),ne};ne.walkTokens=function(n,t){return ii.walkTokens(n,t)};ne.parseInline=ii.parseInline;ne.Parser=Mt;ne.parser=Mt.parse;ne.Renderer=rc;ne.TextRenderer=xp;ne.Lexer=Ot;ne.lexer=Ot.lex;ne.Tokenizer=nc;ne.Hooks=ao;ne.parse=ne;ne.options;ne.setOptions;ne.use;ne.walkTokens;ne.parseInline;Mt.parse;Ot.lex;j0.addHook("afterSanitizeAttributes",n=>{n.tagName==="A"&&(n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer"))});function J6(n){const t=ne.parse(n,{async:!1});return j0.sanitize(t,{USE_PROFILES:{html:!0}})}var Sa,Rn,on,an,nr,rS,Ml;class vd extends bs{constructor(){super(...arguments);w(this,nr);g(this,"phase","thinking");g(this,"toolCalls",[]);g(this,"expanded",!1);g(this,"expandedTexts",new Set);w(this,Sa,`agent-activity-panel-${++e4}`);g(this,"overflowingTexts",new Set);w(this,Rn,null);w(this,on,null);w(this,an,null);g(this,"handleToggle",()=>{this.toolCalls.length!==0&&(this.expanded=!this.expanded)})}changed(e){Ve(this.template(),this),p(this,nr,rS).call(this),l(this,on)!==null&&cancelAnimationFrame(l(this,on)),b(this,on,requestAnimationFrame(()=>{b(this,on,null),p(this,nr,Ml).call(this)})),e.has("expanded")&&(l(this,an)!==null&&clearTimeout(l(this,an)),b(this,an,window.setTimeout(()=>{b(this,an,null),p(this,nr,Ml).call(this)},Q6)))}disconnected(){var e;(e=l(this,Rn))==null||e.disconnect(),b(this,Rn,null),l(this,on)!==null&&(cancelAnimationFrame(l(this,on)),b(this,on,null)),l(this,an)!==null&&(clearTimeout(l(this,an)),b(this,an,null))}template(){const e=this.toolCalls.length>0;return P`
563
- ${this.barTemplate()}
564
- ${e?this.panelTemplate():null}
565
- `}barTemplate(){return this.phase==="thinking"?P`<div class="bar bar-static" unselectable>${this.indicator()}${this.label({expanded:this.expanded})}</div>`:P`
566
- <button
567
- type="button"
568
- variant="ghost"
569
- class="bar"
570
- unselectable
571
- aria-expanded=${this.expanded?"true":"false"}
572
- aria-controls=${l(this,Sa)}
573
- @click=${this.handleToggle}
574
- >
575
- ${this.indicator()}${this.label({expanded:this.expanded})}
576
- </button>
577
- `}panelTemplate(){return P`
578
- <div
579
- class="panel"
580
- id=${l(this,Sa)}
581
- role="region"
582
- ?inert=${!this.expanded}
583
- aria-hidden=${this.expanded?"false":"true"}
584
- >
585
- <div class="panel-inner">
586
- <ol class="tool-list">
587
- ${this.toolCalls.map(e=>this.toolItemTemplate(e))}
588
- </ol>
589
- </div>
590
- </div>
591
- `}toolItemTemplate(e){const r=this.expandedTexts.has(e.toolCallId),i=this.overflowingTexts.has(e.toolCallId),s=r?"Show less":"Show more";return P`
592
- <li class="tool-item">
593
- <span
594
- class="tool-dot"
595
- data-status=${e.status}
596
- role="img"
597
- aria-label=${t4(e.status)}
598
- ></span>
599
- <span class="tool-title">${e.title}</span>
600
- ${e.text?P`
601
- <div class="tool-output">
602
- <pre
603
- class="tool-text"
604
- data-tool-call-id=${e.toolCallId}
605
- ?data-expanded=${r}
606
- >${e.text}</pre>
607
- ${i?P`<button
608
- type="button"
609
- variant="ghost"
610
- class="tool-text-toggle"
611
- @click=${()=>this.toggleTextExpand(e.toolCallId)}
612
- >
613
- <span>${s}</span>
614
- ${r?oM({size:16}):Ql({size:16})}
615
- </button>`:null}
616
- </div>
617
- `:null}
618
- </li>
619
- `}toggleTextExpand(e){const r=new Set(this.expandedTexts);r.has(e)?r.delete(e):r.add(e),this.expandedTexts=r}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}):dM({size:16})}</span>`}label(e){var s;if(this.phase==="thinking")return"Thinking…";const r=this.toolCalls.length;if(this.phase==="using"){if(e.expanded)return`Using ${r} ${r===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 X6(a)}return`${e.expanded?"Showing":"Used"} ${r} ${r===1?"tool":"tools"}`}}Sa=new WeakMap,Rn=new WeakMap,on=new WeakMap,an=new WeakMap,nr=new WeakSet,rS=function(){if(!(typeof ResizeObserver>"u")){l(this,Rn)||b(this,Rn,new ResizeObserver(()=>p(this,nr,Ml).call(this))),l(this,Rn).disconnect();for(const e of this.querySelectorAll(".tool-text"))l(this,Rn).observe(e)}},Ml=function(){const e=new Set;for(const r of this.querySelectorAll(".tool-text")){const i=r.dataset.toolCallId;if(i){if(this.expandedTexts.has(i)){e.add(i);continue}r.scrollHeight>r.clientHeight+1&&e.add(i)}}n4(this.overflowingTexts,e)||(this.overflowingTexts=e)},g(vd,"properties",["phase","toolCalls","expanded","expandedTexts","overflowingTexts"]),g(vd,"attributes",{expanded:{type:Boolean}});function X6(n){switch(n){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 Q6=160;let e4=0;function t4(n){switch(n){case"completed":return"Completed";case"failed":return"Failed";case"in_progress":return"In progress";default:return"Pending"}}function n4(n,t){if(n.size!==t.size)return!1;for(const e of n)if(!t.has(e))return!1;return!0}customElements.define("agent-activity",vd);function r4(n){const t=[];let e=0;for(;e<n.length;)if(n[e].kind==="tool_call"){const i=[];for(;e<n.length&&n[e].kind==="tool_call";)i.push(n[e]),e+=1;const s=e>=n.length;t.push({kind:"tool-run",toolCalls:i,live:s})}else t.push({kind:"message",message:n[e]}),e+=1;const r=n[n.length-1];return r&&r.kind==="user"&&t.push({kind:"thinking"}),t}const ov=8,av=new WeakMap;function i4(n){const t=av.get(n);if(t&&t.text===n.text)return t.html;const e=J6(n.text);return av.set(n,{text:n.text,html:e}),e}function lv(n){for(let t=n.length-1;t>=0;t-=1){const e=n[t];if(e&&e.kind==="user")return e.id}return null}var vt,yt,Kr,Jr,er,kt,sS,yd,oS,yc,bc,bd;class iS extends bs{constructor(){super(...arguments);w(this,kt);g(this,"messages",[]);w(this,vt,!0);w(this,yt,null);w(this,Kr,null);w(this,Jr,null);w(this,er,!1);w(this,yc,()=>{if(l(this,er))return;const e=l(this,yt);if(!e)return;const i=e.scrollHeight-e.clientHeight-e.scrollTop<=ov;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,bd).call(this,!0)})}changed(e){let r=!1;if(e.has("messages")){const i=e.get("messages")??[],s=lv(this.messages);r=s!==null&&s!==lv(i),r&&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,yd).call(this),p(this,kt,bd).call(this,r)}disconnected(){var e,r;(e=l(this,Kr))==null||e.disconnect(),b(this,Kr,null),(r=l(this,Jr))==null||r.disconnect(),b(this,Jr,null)}template(){const e=r4(this.messages);return P`
621
- <div class="history-scroll" @scroll=${l(this,yc)}>
622
- ${e.map(r=>{if(r.kind==="tool-run")return P`<agent-activity
623
- .phase=${r.live?"using":"final"}
624
- .toolCalls=${r.toolCalls}
625
- ></agent-activity>`;if(r.kind==="thinking")return P`<agent-activity
626
- .phase=${"thinking"}
627
- .toolCalls=${[]}
628
- ></agent-activity>`;const i=r.message,s=i.kind==="assistant"?BO(i4(i)):i.text;return P`<div
629
- class="message message-${i.kind}"
630
- data-message-id=${i.id}
631
- >${s}</div>`})}
632
- </div>
633
- <button
634
- type="button"
635
- class="history-jump"
636
- aria-label="Jump to latest message"
637
- @click=${l(this,bc)}
638
- >
639
- ${Ql({size:16})}
640
- </button>
641
- `}}vt=new WeakMap,yt=new WeakMap,Kr=new WeakMap,Jr=new WeakMap,er=new WeakMap,kt=new WeakSet,sS=function(){l(this,yt)&&(typeof ResizeObserver>"u"||(b(this,Kr,new ResizeObserver(()=>p(this,kt,oS).call(this))),b(this,Jr,new MutationObserver(()=>p(this,kt,yd).call(this))),l(this,Jr).observe(l(this,yt),{childList:!0})))},yd=function(){const e=l(this,yt),r=l(this,Kr);if(!(!e||!r)){r.disconnect();for(const i of Array.from(e.children))r.observe(i)}},oS=function(){const e=l(this,yt);if(!e)return;if(l(this,vt)){b(this,er,!0),e.scrollTop=e.scrollHeight-e.clientHeight,requestAnimationFrame(()=>{b(this,er,!1)});return}const i=e.scrollHeight-e.clientHeight-e.scrollTop<=ov;i!==l(this,vt)&&(b(this,vt,i),this.toggleAttribute("data-pinned",i))},yc=new WeakMap,bc=new WeakMap,bd=function(e){requestAnimationFrame(()=>{const r=l(this,yt);r&&(!l(this,vt)&&!e||(b(this,er,!0),r.scrollTop=r.scrollHeight-r.clientHeight,requestAnimationFrame(()=>{b(this,er,!1)})))})},g(iS,"properties",["messages"]);customElements.define("message-history",iS);var Dt,_a,cs,ln,us,hs,ka,ds,wc,Sc,_c,bt,Nl,xa,Sd,_d,Ea,Aa;class wd 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,dn.resolve("ServerManager"));w(this,_a,dn.resolve("ShortcutService"));w(this,cs,null);w(this,ln,null);w(this,us,()=>{var e;this.status=((e=l(this,ln))==null?void 0:e.status)??"disconnected"});w(this,hs,()=>{var e;this.messages=((e=l(this,ln))==null?void 0:e.messages)??[]});w(this,ka,()=>{var e,r;(e=l(this,ln))==null||e.removeEventListener("status-changed",l(this,us)),(r=l(this,ln))==null||r.removeEventListener("messages-changed",l(this,hs)),b(this,ln,null)});w(this,ds,()=>{var r;const e=((r=l(this,Dt).activeServer)==null?void 0:r.acpClient)??null;e!==l(this,ln)&&(l(this,ka).call(this),b(this,ln,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 r;const e=(r=l(this,Dt).activeServer)==null?void 0:r.acpClient;e&&!e.enabled||(this.open=!0)});g(this,"handleKeydown",e=>{var o;if(e.key!=="Enter"||e.shiftKey)return;const r=e.currentTarget,i=r.value.trim();if(e.preventDefault(),!i)return;r.value="",p(this,bt,Nl).call(this,r);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 r=(i=l(this,Dt).activeServer)==null?void 0:i.acpClient;r&&r.cancel().catch(s=>{console.error("ACPClient.cancel() failed",s)})});w(this,_c,e=>{if(e.target instanceof HTMLTextAreaElement)return;const r=e.currentTarget.querySelector("textarea");r==null||r.focus()});w(this,xa,e=>{var s;if(e.shortcut!=="focusCommandInput")return;const r=(s=l(this,Dt).activeServer)==null?void 0:s.acpClient;if(r&&!r.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,Sd).call(this)}disconnected(){var e;(e=l(this,cs))==null||e.dispose(),b(this,cs,null),p(this,bt,_d).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,Sd).call(this);const r=this.querySelector("textarea");r&&(p(this,bt,Nl).call(this,r),r.focus())}else p(this,bt,_d).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`
642
- <div class="connecting" aria-disabled="true">
643
- <ui-spinner size="16" weight="bold"></ui-spinner>
644
- <span class="label">Connecting<span class="dots" aria-hidden="true"></span></span>
645
- </div>
646
- `;if(this.open){const s=this.status==="running"||this.status==="cancelling",o=this.status==="cancelling";return P`
647
- <div class="open">
648
- <div
649
- class="chat"
650
- material="paper"
651
- tone="dark"
652
- level="overlay"
653
- >
654
- <message-history selectable .messages=${this.messages}></message-history>
655
- </div>
656
- <div
657
- class="input"
658
- material="paper"
659
- tone="dark"
660
- level="overlay"
661
- @click=${l(this,_c)}
662
- >
663
- <textarea
664
- class="textarea"
665
- rows="1"
666
- @keydown=${this.handleKeydown}
667
- @input=${l(this,wc)}
668
- ></textarea>
669
- ${s?P`
670
- <button
671
- type="button"
672
- icon-only
673
- variant="ghost"
674
- aria-label=${o?"Cancelling…":"Stop generating"}
675
- ?disabled=${o}
676
- @click=${l(this,Sc)}
677
- >
678
- ${o?P`<ui-spinner size="16" weight="bold"></ui-spinner>`:sM({size:16})}
679
- </button>
680
- `:null}
681
- </div>
682
- </div>
683
- `}return P`
684
- <div
685
- class="trigger"
686
- tabindex="0"
687
- role="button"
688
- @click=${this.handleTriggerActivate}
689
- @focus=${this.handleTriggerActivate}
690
- >
691
- <span class="label">${this.placeholder}</span>
692
- <span class="kbd" aria-hidden="true">⌘K</span>
693
- </div>
694
- `}}Dt=new WeakMap,_a=new WeakMap,cs=new WeakMap,ln=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,Sd=function(){document.addEventListener("mousedown",l(this,Ea)),document.addEventListener("keydown",l(this,Aa))},_d=function(){document.removeEventListener("mousedown",l(this,Ea)),document.removeEventListener("keydown",l(this,Aa))},Ea=new WeakMap,Aa=new WeakMap,g(wd,"properties",["placeholder","open","messages","status"]),g(wd,"attributes",{placeholder:{type:String},open:{type:Boolean}});customElements.define("command-panel",wd);const s4='<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 o4 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 r=e.currentTarget;this._tokenValue=r.value}handleSubmit(e){e.preventDefault();const r=this._tokenValue.trim();r&&this.dispatchEvent(new aS(r))}render(){Ve(P`
695
- <modal-overlay open>
696
- <system-modal material="glass-frosted" level="1" class="auth-modal">
697
- <form class="auth-form" @submit=${r=>this.handleSubmit(r)}>
698
- <header>
699
- <span class="auth-modal-icon" aria-hidden="true">
700
- <svg width="32" height="32" viewBox="0 0 256 256" fill="currentColor">${Nw(s4)}</svg>
701
- </span>
702
- <hgroup>
703
- <h2>Enter access token</h2>
704
- <p>${"This server requires an access token to connect."}</p>
705
- </hgroup>
706
- </header>
707
- <div class="auth-input-row">
708
- <input
709
- class=${this.invalid?"auth-token-input auth-token-input-invalid":"auth-token-input"}
710
- type="password"
711
- name="token"
712
- placeholder="paste token here"
713
- aria-label="Access token"
714
- .value=${this.tokenValue}
715
- @input=${r=>this.handleInput(r)}
716
- autofocus
717
- required
718
- />
719
- ${this.invalid?P`<p class="auth-modal-error" role="alert">
720
- The previous token was rejected. Try again.
721
- </p>`:null}
722
- </div>
723
- <button variant="primary" class="auth-submit">
724
- Connect
725
- </button>
726
- </form>
727
- </system-modal>
728
- </modal-overlay>
729
- `,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",o4);const a4=250,l4=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,r,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()},a4))}stopTicker(){this.tickHandle!==null&&(clearInterval(this.tickHandle),this.tickHandle=null)}render(){const e=this._hasEverConnected,r=e?"Disconnected":"Connecting",i=this._nextRetryAt!==null?this.formatCountdown(this._nextRetryAt):"Reattempting now…";Ve(P`
730
- <modal-overlay open role="status" aria-live="polite">
731
- <system-modal material="glass-frosted" level="1" class="connecting-overlay-panel">
732
- <header>
733
- <ui-spinner size="32"></ui-spinner>
734
- <hgroup>
735
- <h2>${r}</h2>
736
- ${e?P`<p>${i}</p>`:null}
737
- </hgroup>
738
- </header>
739
- </system-modal>
740
- </modal-overlay>
741
- `,this)}formatCountdown(e){const r=e-Date.now();return r<=0?"Reattempting now…":`Reattempting in ${Math.ceil(r/l4)}s…`}}g(lS,"observedAttributes",["next-retry-at","has-ever-connected"]);customElements.get("connecting-overlay")||customElements.define("connecting-overlay",lS);class c4 extends HTMLElement{constructor(){super(...arguments);g(this,"runtimeServerURL",Cb());g(this,"electronMode",un());g(this,"serverManager",dn.resolve("ServerManager"));g(this,"screenManager",dn.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 r=e instanceof aS?e.token:e instanceof CustomEvent&&typeof((i=e.detail)==null?void 0:i.token)=="string"?e.detail.token:null;r&&this.handleAuthSubmit(r)}),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=gL();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 r=e??this.serverManager.getStoredAuthToken(this.runtimeServerURL),i=new $w({url:this.runtimeServerURL,name:"Server",token:r,telemetryMeta:this.serverManager.telemetryMeta});this.serverManager.add(i),this.serverManager.setActive(i);try{await i.connect(r),this.connectError=null}catch(s){this.connectError=s instanceof Error&&!(s instanceof ho)?s.message:null}this.render()}async handleAuthSubmit(e){const r=this.serverManager.activeServer;if(r){this.connectError=null,this.serverManager.setStoredAuthToken(r.url,e);try{await r.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,r=(e==null?void 0:e.status)??null,i=this.screenManager.activeScreen,s=!!(e&&i&&this.screenManager.hasTab(e.url,i.id));if(r==="unauthorized"){const h=e;if(!h)return;Ve(P`
742
- <main class="auth-gate">
743
- <auth-modal
744
- .invalid=${!!h.token}
745
- .tokenValue=${h.token??""}
746
- ></auth-modal>
747
- </main>
748
- `,this),this.updateLayoutChromeBalance();return}const o=r==="disconnected",a=(e==null?void 0:e.hasEverConnected)??!1,u=r==="connected"||o&&a;Ve(P`
749
- <main>
750
- ${this.connectError?P`<p data-testid="auth-error">${this.connectError}</p>`:P`
751
- ${u?P`
752
- <div class="top-row" electron-draggable>
753
- <screen-select></screen-select>
754
- </div>
755
- `:null}
756
- ${s?P`<screen-view></screen-view>`:null}
757
- ${u&&(e!=null&&e.acpClient.enabled)?P`
758
- <div class="command-panel-region">
759
- <command-panel></command-panel>
760
- </div>
761
- `:null}
762
- `}
763
- ${o?P`<connecting-overlay
764
- .nextRetryAt=${(e==null?void 0:e.nextRetryAt)??null}
765
- .hasEverConnected=${(e==null?void 0:e.hasEverConnected)??!1}
766
- ></connecting-overlay>`:null}
767
- </main>
768
- `,this),this.updateLayoutChromeBalance()}updateLayoutChromeBalance(){var o;const e=this.querySelector("main"),r=this.querySelector(".top-row"),i=this.querySelector(".command-panel-region"),s=r&&!i?r.getBoundingClientRect().height:0;e==null||e.style.setProperty("--layout-virtual-bottom-balance",`${s}px`),r!==this.observedTopRow&&((o=this.topRowResizeObserver)==null||o.disconnect(),this.observedTopRow=r,r&&typeof ResizeObserver<"u"?(this.topRowResizeObserver=new ResizeObserver(()=>this.updateLayoutChromeBalance()),this.topRowResizeObserver.observe(r)):this.topRowResizeObserver=null)}}customElements.get("television-app")||customElements.define("television-app",c4);const xo=un(),Ep=Cb(),cS=new i$(xo?"television-electron":"television-browser",QT(Ep)),cv=Tw(),u4=cv?kL({storage:cv,clientApp:xo?"desktop":"browser",desktopAppVersion:xo?mL():null}):null,hn=new SO({localStore:cS,localServerURL:Ep,telemetryMeta:u4}),uS=new p$({localStore:cS,serverManager:hn}),h4=new _O,d4=()=>{const n=[...hn.servers.values()].filter(t=>t.status==="connected");n.length!==0&&Promise.all(n.map(t=>t.client.artifacts.list())).then(t=>{const e=new Set(t.flatMap(({artifacts:r})=>r.map(i=>i.id)));LO(e)}).catch(()=>{})},hS=()=>{const n=hn.activeServer;if(!n||n.status!=="connected"){Vl();return}d4(),n.client.display.get().then(t=>{if(!(hn.activeServer!==n||n.status!=="connected"))return Pw(t.activeThemeName,n)}).catch(()=>{hn.activeServer===n&&Vl()})};hS();hn.addEventListener("change",hS);hn.addEventListener("server-event",n=>{if(n.event.type!=="theme-changed")return;const t=hn.activeServer;!t||t.url!==n.serverURL||Pw(n.event.themeName,t)});dn.register("ServerManager",()=>hn);dn.register("ScreenManager",()=>uS);dn.register("ShortcutService",()=>h4);globalThis.__telepath={screenManager:uS,serverManager:hn};const Ap=document.createElement("television-app");Ap.runtimeServerURL=Ep;Ap.electronMode=xo;xo&&document.body.classList.add("electron");document.body.appendChild(Ap);