piclaw 0.0.4 → 0.0.6

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 (185) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/assets/dist-D51xeTP2.js +12 -0
  3. package/.output/public/assets/index-B3x2_en6.css +1 -0
  4. package/.output/public/assets/index-SfjxJZSD.js +38 -0
  5. package/.output/public/assets/md4x-CNLJ57xO.wasm +0 -0
  6. package/.output/public/assets/md4x-CyfQToGJ.js +1 -0
  7. package/.output/public/assets/wasm-Cm7RZrwg.js +1 -0
  8. package/.output/public/icon.svg +25 -0
  9. package/.output/public/index.html +3 -2
  10. package/.output/public/manifest.json +1 -1
  11. package/.output/server/_chunks/bun.mjs +49 -0
  12. package/.output/server/_chunks/commands.mjs +280 -0
  13. package/.output/server/_chunks/config.mjs +2 -4
  14. package/.output/server/_chunks/db.mjs +11 -5
  15. package/.output/server/_chunks/logger.mjs +1 -1
  16. package/.output/server/_chunks/node.mjs +31 -0
  17. package/.output/server/_chunks/ntfy.mjs +45 -0
  18. package/.output/server/_chunks/pi.mjs +33 -1
  19. package/.output/server/_chunks/renderer-template.mjs +1 -1
  20. package/.output/server/_chunks/{bootstrap.mjs → server.mjs} +203 -205
  21. package/.output/server/_chunks/session.mjs +249 -40
  22. package/.output/server/_chunks/settings.mjs +1 -1
  23. package/.output/server/_chunks/terminal.mjs +35 -20
  24. package/.output/server/_chunks/virtual.mjs +129 -0
  25. package/.output/server/_jid_.delete.mjs +2 -2
  26. package/.output/server/_jid_.patch.mjs +30 -3
  27. package/.output/server/_jid_2.delete.mjs +2 -2
  28. package/.output/server/_libs/@aws-sdk/client-bedrock-runtime+[...].mjs +13148 -13149
  29. package/.output/server/_libs/@aws-sdk/credential-provider-http+[...].mjs +1 -1
  30. package/.output/server/_libs/@aws-sdk/credential-provider-ini+[...].mjs +2 -2
  31. package/.output/server/_libs/@aws-sdk/credential-provider-process+[...].mjs +1 -1
  32. package/.output/server/_libs/@aws-sdk/credential-provider-sso+[...].mjs +1 -1
  33. package/.output/server/_libs/@aws-sdk/credential-provider-web-identity+[...].mjs +1 -1
  34. package/.output/server/_libs/@google/genai.mjs +2 -2
  35. package/.output/server/_libs/@mariozechner/pi-agent-core+[...].mjs +40 -74
  36. package/.output/server/_libs/@mariozechner/pi-coding-agent+[...].mjs +1315 -1210
  37. package/.output/server/_libs/@smithy/credential-provider-imds+[...].mjs +3 -3
  38. package/.output/server/_libs/_.mjs +3 -2
  39. package/.output/server/_libs/_100.mjs +3 -0
  40. package/.output/server/_libs/_101.mjs +2 -0
  41. package/.output/server/_libs/_102.mjs +3 -0
  42. package/.output/server/_libs/_103.mjs +2 -0
  43. package/.output/server/_libs/_16.mjs +2 -5
  44. package/.output/server/_libs/_17.mjs +2 -3
  45. package/.output/server/_libs/_18.mjs +2 -3
  46. package/.output/server/_libs/_19.mjs +2 -4
  47. package/.output/server/_libs/_2.mjs +2 -3
  48. package/.output/server/_libs/_20.mjs +2 -2
  49. package/.output/server/_libs/_21.mjs +2 -0
  50. package/.output/server/_libs/_22.mjs +2 -0
  51. package/.output/server/_libs/_23.mjs +2 -0
  52. package/.output/server/_libs/_24.mjs +2 -0
  53. package/.output/server/_libs/_25.mjs +2 -0
  54. package/.output/server/_libs/_26.mjs +2 -0
  55. package/.output/server/_libs/_27.mjs +2 -0
  56. package/.output/server/_libs/_28.mjs +2 -0
  57. package/.output/server/_libs/_29.mjs +2 -0
  58. package/.output/server/_libs/_30.mjs +2 -0
  59. package/.output/server/_libs/_31.mjs +2 -0
  60. package/.output/server/_libs/_32.mjs +2 -0
  61. package/.output/server/_libs/_33.mjs +2 -0
  62. package/.output/server/_libs/_34.mjs +2 -0
  63. package/.output/server/_libs/_35.mjs +2 -0
  64. package/.output/server/_libs/_36.mjs +2 -0
  65. package/.output/server/_libs/_37.mjs +2 -0
  66. package/.output/server/_libs/_38.mjs +2 -0
  67. package/.output/server/_libs/_39.mjs +2 -0
  68. package/.output/server/_libs/_40.mjs +2 -0
  69. package/.output/server/_libs/_41.mjs +2 -0
  70. package/.output/server/_libs/_42.mjs +2 -0
  71. package/.output/server/_libs/_43.mjs +2 -0
  72. package/.output/server/_libs/_44.mjs +2 -0
  73. package/.output/server/_libs/_45.mjs +2 -0
  74. package/.output/server/_libs/_46.mjs +2 -0
  75. package/.output/server/_libs/_47.mjs +2 -0
  76. package/.output/server/_libs/_48.mjs +2 -0
  77. package/.output/server/_libs/_49.mjs +2 -0
  78. package/.output/server/_libs/_50.mjs +2 -0
  79. package/.output/server/_libs/_51.mjs +2 -0
  80. package/.output/server/_libs/_52.mjs +2 -0
  81. package/.output/server/_libs/_53.mjs +2 -0
  82. package/.output/server/_libs/_54.mjs +2 -0
  83. package/.output/server/_libs/_55.mjs +2 -0
  84. package/.output/server/_libs/_56.mjs +2 -0
  85. package/.output/server/_libs/_57.mjs +2 -0
  86. package/.output/server/_libs/_58.mjs +2 -0
  87. package/.output/server/_libs/_59.mjs +2 -0
  88. package/.output/server/_libs/_60.mjs +2 -0
  89. package/.output/server/_libs/_61.mjs +2 -0
  90. package/.output/server/_libs/_62.mjs +2 -0
  91. package/.output/server/_libs/_63.mjs +2 -0
  92. package/.output/server/_libs/_64.mjs +2 -0
  93. package/.output/server/_libs/_65.mjs +2 -0
  94. package/.output/server/_libs/_66.mjs +2 -0
  95. package/.output/server/_libs/_67.mjs +2 -0
  96. package/.output/server/_libs/_68.mjs +2 -0
  97. package/.output/server/_libs/_69.mjs +2 -0
  98. package/.output/server/_libs/_70.mjs +2 -0
  99. package/.output/server/_libs/_71.mjs +2 -0
  100. package/.output/server/_libs/_72.mjs +2 -0
  101. package/.output/server/_libs/_73.mjs +2 -0
  102. package/.output/server/_libs/_74.mjs +2 -0
  103. package/.output/server/_libs/_75.mjs +2 -0
  104. package/.output/server/_libs/_76.mjs +2 -0
  105. package/.output/server/_libs/_77.mjs +2 -0
  106. package/.output/server/_libs/_78.mjs +2 -0
  107. package/.output/server/_libs/_79.mjs +2 -0
  108. package/.output/server/_libs/_80.mjs +2 -0
  109. package/.output/server/_libs/_81.mjs +2 -0
  110. package/.output/server/_libs/_82.mjs +2 -0
  111. package/.output/server/_libs/_83.mjs +2 -0
  112. package/.output/server/_libs/_84.mjs +2 -0
  113. package/.output/server/_libs/_85.mjs +2 -0
  114. package/.output/server/_libs/_86.mjs +2 -0
  115. package/.output/server/_libs/_87.mjs +2 -0
  116. package/.output/server/_libs/_88.mjs +2 -0
  117. package/.output/server/_libs/_89.mjs +2 -0
  118. package/.output/server/_libs/_90.mjs +2 -0
  119. package/.output/server/_libs/_91.mjs +2 -0
  120. package/.output/server/_libs/_92.mjs +2 -0
  121. package/.output/server/_libs/_93.mjs +2 -0
  122. package/.output/server/_libs/_94.mjs +2 -0
  123. package/.output/server/_libs/_95.mjs +2 -0
  124. package/.output/server/_libs/_96.mjs +2 -0
  125. package/.output/server/_libs/_97.mjs +2 -0
  126. package/.output/server/_libs/_98.mjs +2 -0
  127. package/.output/server/_libs/_99.mjs +5 -0
  128. package/.output/server/_libs/amdefine.mjs +188 -0
  129. package/.output/server/_libs/aws-sdk__nested-clients.mjs +1 -1
  130. package/.output/server/_libs/compressjs.mjs +50 -0
  131. package/.output/server/_libs/diff.mjs +137 -0
  132. package/.output/server/_libs/get-uri.mjs +1 -1
  133. package/.output/server/_libs/http-proxy-agent.mjs +1 -1
  134. package/.output/server/_libs/https-proxy-agent.mjs +1 -1
  135. package/.output/server/_libs/just-bash+[...].mjs +80359 -0
  136. package/.output/server/_libs/md4x.mjs +73 -0
  137. package/.output/server/_libs/mixmark-io__domino.mjs +14801 -0
  138. package/.output/server/_libs/node-fetch.mjs +1 -1
  139. package/.output/server/_libs/node-liblzma.mjs +1107 -0
  140. package/.output/server/_libs/pac-proxy-agent+[...].mjs +1 -1
  141. package/.output/server/_libs/proxy-agent+proxy-from-env.mjs +1 -1
  142. package/.output/server/_libs/smithy__core.mjs +1 -1
  143. package/.output/server/_routes/api/files/delete.mjs +2 -2
  144. package/.output/server/_routes/api/files/groups.mjs +14 -0
  145. package/.output/server/_routes/api/files/raw.mjs +1 -1
  146. package/.output/server/_routes/api/files/read.mjs +1 -1
  147. package/.output/server/_routes/api/files/watch.mjs +1 -1
  148. package/.output/server/_routes/api/files/write.mjs +3 -2
  149. package/.output/server/_routes/api/files.mjs +1 -1
  150. package/.output/server/_routes/api/groups.mjs +2 -2
  151. package/.output/server/_routes/api/groups2.mjs +3 -2
  152. package/.output/server/_routes/api/health.mjs +2 -2
  153. package/.output/server/_routes/api/logs.mjs +4 -2
  154. package/.output/server/_routes/api/ntfy/setup.mjs +54 -0
  155. package/.output/server/_routes/api/ntfy/status.mjs +12 -0
  156. package/.output/server/_routes/api/pi/apikey.mjs +1 -1
  157. package/.output/server/_routes/api/pi/apikey_providers.mjs +1 -1
  158. package/.output/server/_routes/api/pi/commands.mjs +6 -0
  159. package/.output/server/_routes/api/pi/login/events.mjs +1 -1
  160. package/.output/server/_routes/api/pi/login/respond.mjs +1 -1
  161. package/.output/server/_routes/api/pi/login.mjs +1 -1
  162. package/.output/server/_routes/api/pi/logout.mjs +1 -1
  163. package/.output/server/_routes/api/pi/models.mjs +1 -1
  164. package/.output/server/_routes/api/pi/status.mjs +1 -1
  165. package/.output/server/_routes/api/send.mjs +22 -3
  166. package/.output/server/_routes/api/status.mjs +9 -7
  167. package/.output/server/_routes/api/tasks2.mjs +2 -2
  168. package/.output/server/_routes/api/telegram/setup.mjs +2 -2
  169. package/.output/server/_routes/api/telegram/status.mjs +2 -2
  170. package/.output/server/_routes/api/terminal2.mjs +3 -2
  171. package/.output/server/_utils.mjs +12 -4
  172. package/.output/server/build/md4x.wasm +0 -0
  173. package/.output/server/index.mjs +223 -149
  174. package/.output/server/node_modules/@mongodb-js/zstd/lib/index.js +55 -0
  175. package/.output/server/node_modules/@mongodb-js/zstd/package.json +51 -0
  176. package/.output/server/package.json +1 -0
  177. package/README.md +118 -24
  178. package/bin/piclaw.mjs +39 -1
  179. package/package.json +16 -13
  180. package/.output/public/assets/client-TIs-Ghqj.js +0 -9
  181. package/.output/public/assets/dist-BVjfG3ok.js +0 -12
  182. package/.output/public/assets/dist-DJh8l6yS.js +0 -1
  183. package/.output/public/assets/index-BNNEMkNV.js +0 -39
  184. package/.output/public/assets/index-CdWBxO5V.css +0 -1
  185. package/.output/public/assets/react-DFP7nCmh.js +0 -1
@@ -0,0 +1,38 @@
1
+ (function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function e(e){let t=Object.create(null);for(let n of e.split(`,`))t[n]=1;return e=>e in t}var t={},n=[],r=()=>{},i=()=>!1,a=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),o=e=>e.startsWith(`onUpdate:`),s=Object.assign,c=(e,t)=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)},l=Object.prototype.hasOwnProperty,u=(e,t)=>l.call(e,t),d=Array.isArray,f=e=>x(e)===`[object Map]`,p=e=>x(e)===`[object Set]`,m=e=>x(e)===`[object Date]`,h=e=>typeof e==`function`,g=e=>typeof e==`string`,_=e=>typeof e==`symbol`,v=e=>typeof e==`object`&&!!e,y=e=>(v(e)||h(e))&&h(e.then)&&h(e.catch),b=Object.prototype.toString,x=e=>b.call(e),S=e=>x(e).slice(8,-1),C=e=>x(e)===`[object Object]`,w=e=>g(e)&&e!==`NaN`&&e[0]!==`-`&&``+parseInt(e,10)===e,T=e(`,key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted`),ee=e=>{let t=Object.create(null);return(n=>t[n]||(t[n]=e(n)))},E=/-\w/g,D=ee(e=>e.replace(E,e=>e.slice(1).toUpperCase())),O=/\B([A-Z])/g,k=ee(e=>e.replace(O,`-$1`).toLowerCase()),te=ee(e=>e.charAt(0).toUpperCase()+e.slice(1)),ne=ee(e=>e?`on${te(e)}`:``),A=(e,t)=>!Object.is(e,t),re=(e,...t)=>{for(let n=0;n<e.length;n++)e[n](...t)},j=(e,t,n,r=!1)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:r,value:n})},ie=e=>{let t=parseFloat(e);return isNaN(t)?e:t},ae=e=>{let t=g(e)?Number(e):NaN;return isNaN(t)?e:t},oe,se=()=>oe||=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{};function M(e){if(d(e)){let t={};for(let n=0;n<e.length;n++){let r=e[n],i=g(r)?de(r):M(r);if(i)for(let e in i)t[e]=i[e]}return t}else if(g(e)||v(e))return e}var ce=/;(?![^(]*\))/g,le=/:([^]+)/,ue=/\/\*[^]*?\*\//g;function de(e){let t={};return e.replace(ue,``).split(ce).forEach(e=>{if(e){let n=e.split(le);n.length>1&&(t[n[0].trim()]=n[1].trim())}}),t}function N(e){let t=``;if(g(e))t=e;else if(d(e))for(let n=0;n<e.length;n++){let r=N(e[n]);r&&(t+=r+` `)}else if(v(e))for(let n in e)e[n]&&(t+=n+` `);return t.trim()}var fe=`itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`,pe=e(fe);e(fe+`,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`);function me(e){return!!e||e===``}function he(e,t){if(e.length!==t.length)return!1;let n=!0;for(let r=0;n&&r<e.length;r++)n=ge(e[r],t[r]);return n}function ge(e,t){if(e===t)return!0;let n=m(e),r=m(t);if(n||r)return n&&r?e.getTime()===t.getTime():!1;if(n=_(e),r=_(t),n||r)return e===t;if(n=d(e),r=d(t),n||r)return n&&r?he(e,t):!1;if(n=v(e),r=v(t),n||r){if(!n||!r||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e){let r=e.hasOwnProperty(n),i=t.hasOwnProperty(n);if(r&&!i||!r&&i||!ge(e[n],t[n]))return!1}}return String(e)===String(t)}function _e(e,t){return e.findIndex(e=>ge(e,t))}var ve=e=>!!(e&&e.__v_isRef===!0),P=e=>g(e)?e:e==null?``:d(e)||v(e)&&(e.toString===b||!h(e.toString))?ve(e)?P(e.value):JSON.stringify(e,ye,2):String(e),ye=(e,t)=>ve(t)?ye(e,t.value):f(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((e,[t,n],r)=>(e[be(t,r)+` =>`]=n,e),{})}:p(t)?{[`Set(${t.size})`]:[...t.values()].map(e=>be(e))}:_(t)?be(t):v(t)&&!d(t)&&!C(t)?String(t):t,be=(e,t=``)=>_(e)?`Symbol(${e.description??t})`:e,xe,Se=class{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this.__v_skip=!0,this.parent=xe,!e&&xe&&(this.index=(xe.scopes||=[]).push(this)-1)}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let e,t;if(this.scopes)for(e=0,t=this.scopes.length;e<t;e++)this.scopes[e].pause();for(e=0,t=this.effects.length;e<t;e++)this.effects[e].pause()}}resume(){if(this._active&&this._isPaused){this._isPaused=!1;let e,t;if(this.scopes)for(e=0,t=this.scopes.length;e<t;e++)this.scopes[e].resume();for(e=0,t=this.effects.length;e<t;e++)this.effects[e].resume()}}run(e){if(this._active){let t=xe;try{return xe=this,e()}finally{xe=t}}}on(){++this._on===1&&(this.prevScope=xe,xe=this)}off(){this._on>0&&--this._on===0&&(xe=this.prevScope,this.prevScope=void 0)}stop(e){if(this._active){this._active=!1;let t,n;for(t=0,n=this.effects.length;t<n;t++)this.effects[t].stop();for(this.effects.length=0,t=0,n=this.cleanups.length;t<n;t++)this.cleanups[t]();if(this.cleanups.length=0,this.scopes){for(t=0,n=this.scopes.length;t<n;t++)this.scopes[t].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!e){let e=this.parent.scopes.pop();e&&e!==this&&(this.parent.scopes[this.index]=e,e.index=this.index)}this.parent=void 0}}};function Ce(){return xe}function we(e,t=!1){xe&&xe.cleanups.push(e)}var Te,Ee=new WeakSet,De=class{constructor(e){this.fn=e,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.next=void 0,this.cleanup=void 0,this.scheduler=void 0,xe&&xe.active&&xe.effects.push(this)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,Ee.has(this)&&(Ee.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||je(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,We(this),Pe(this);let e=Te,t=Be;Te=this,Be=!0;try{return this.fn()}finally{Fe(this),Te=e,Be=t,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)Re(e);this.deps=this.depsTail=void 0,We(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?Ee.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){Ie(this)&&this.run()}get dirty(){return Ie(this)}},Oe=0,ke,Ae;function je(e,t=!1){if(e.flags|=8,t){e.next=Ae,Ae=e;return}e.next=ke,ke=e}function Me(){Oe++}function Ne(){if(--Oe>0)return;if(Ae){let e=Ae;for(Ae=void 0;e;){let t=e.next;e.next=void 0,e.flags&=-9,e=t}}let e;for(;ke;){let t=ke;for(ke=void 0;t;){let n=t.next;if(t.next=void 0,t.flags&=-9,t.flags&1)try{t.trigger()}catch(t){e||=t}t=n}}if(e)throw e}function Pe(e){for(let t=e.deps;t;t=t.nextDep)t.version=-1,t.prevActiveLink=t.dep.activeLink,t.dep.activeLink=t}function Fe(e){let t,n=e.depsTail,r=n;for(;r;){let e=r.prevDep;r.version===-1?(r===n&&(n=e),Re(r),ze(r)):t=r,r.dep.activeLink=r.prevActiveLink,r.prevActiveLink=void 0,r=e}e.deps=t,e.depsTail=n}function Ie(e){for(let t=e.deps;t;t=t.nextDep)if(t.dep.version!==t.version||t.dep.computed&&(Le(t.dep.computed)||t.dep.version!==t.version))return!0;return!!e._dirty}function Le(e){if(e.flags&4&&!(e.flags&16)||(e.flags&=-17,e.globalVersion===Ge)||(e.globalVersion=Ge,!e.isSSR&&e.flags&128&&(!e.deps&&!e._dirty||!Ie(e))))return;e.flags|=2;let t=e.dep,n=Te,r=Be;Te=e,Be=!0;try{Pe(e);let n=e.fn(e._value);(t.version===0||A(n,e._value))&&(e.flags|=128,e._value=n,t.version++)}catch(e){throw t.version++,e}finally{Te=n,Be=r,Fe(e),e.flags&=-3}}function Re(e,t=!1){let{dep:n,prevSub:r,nextSub:i}=e;if(r&&(r.nextSub=i,e.prevSub=void 0),i&&(i.prevSub=r,e.nextSub=void 0),n.subs===e&&(n.subs=r,!r&&n.computed)){n.computed.flags&=-5;for(let e=n.computed.deps;e;e=e.nextDep)Re(e,!0)}!t&&!--n.sc&&n.map&&n.map.delete(n.key)}function ze(e){let{prevDep:t,nextDep:n}=e;t&&(t.nextDep=n,e.prevDep=void 0),n&&(n.prevDep=t,e.nextDep=void 0)}var Be=!0,Ve=[];function He(){Ve.push(Be),Be=!1}function Ue(){let e=Ve.pop();Be=e===void 0?!0:e}function We(e){let{cleanup:t}=e;if(e.cleanup=void 0,t){let e=Te;Te=void 0;try{t()}finally{Te=e}}}var Ge=0,Ke=class{constructor(e,t){this.sub=e,this.dep=t,this.version=t.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}},qe=class{constructor(e){this.computed=e,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0}track(e){if(!Te||!Be||Te===this.computed)return;let t=this.activeLink;if(t===void 0||t.sub!==Te)t=this.activeLink=new Ke(Te,this),Te.deps?(t.prevDep=Te.depsTail,Te.depsTail.nextDep=t,Te.depsTail=t):Te.deps=Te.depsTail=t,Je(t);else if(t.version===-1&&(t.version=this.version,t.nextDep)){let e=t.nextDep;e.prevDep=t.prevDep,t.prevDep&&(t.prevDep.nextDep=e),t.prevDep=Te.depsTail,t.nextDep=void 0,Te.depsTail.nextDep=t,Te.depsTail=t,Te.deps===t&&(Te.deps=e)}return t}trigger(e){this.version++,Ge++,this.notify(e)}notify(e){Me();try{for(let e=this.subs;e;e=e.prevSub)e.sub.notify()&&e.sub.dep.notify()}finally{Ne()}}};function Je(e){if(e.dep.sc++,e.sub.flags&4){let t=e.dep.computed;if(t&&!e.dep.subs){t.flags|=20;for(let e=t.deps;e;e=e.nextDep)Je(e)}let n=e.dep.subs;n!==e&&(e.prevSub=n,n&&(n.nextSub=e)),e.dep.subs=e}}var Ye=new WeakMap,Xe=Symbol(``),Ze=Symbol(``),Qe=Symbol(``);function $e(e,t,n){if(Be&&Te){let t=Ye.get(e);t||Ye.set(e,t=new Map);let r=t.get(n);r||(t.set(n,r=new qe),r.map=t,r.key=n),r.track()}}function et(e,t,n,r,i,a){let o=Ye.get(e);if(!o){Ge++;return}let s=e=>{e&&e.trigger()};if(Me(),t===`clear`)o.forEach(s);else{let i=d(e),a=i&&w(n);if(i&&n===`length`){let e=Number(r);o.forEach((t,n)=>{(n===`length`||n===Qe||!_(n)&&n>=e)&&s(t)})}else switch((n!==void 0||o.has(void 0))&&s(o.get(n)),a&&s(o.get(Qe)),t){case`add`:i?a&&s(o.get(`length`)):(s(o.get(Xe)),f(e)&&s(o.get(Ze)));break;case`delete`:i||(s(o.get(Xe)),f(e)&&s(o.get(Ze)));break;case`set`:f(e)&&s(o.get(Xe));break}}Ne()}function tt(e,t){let n=Ye.get(e);return n&&n.get(t)}function nt(e){let t=Wt(e);return t===e?t:($e(t,`iterate`,Qe),Ht(e)?t:t.map(Kt))}function rt(e){return $e(e=Wt(e),`iterate`,Qe),e}function it(e,t){return Vt(e)?Bt(e)?qt(Kt(t)):qt(t):Kt(t)}var at={__proto__:null,[Symbol.iterator](){return ot(this,Symbol.iterator,e=>it(this,e))},concat(...e){return nt(this).concat(...e.map(e=>d(e)?nt(e):e))},entries(){return ot(this,`entries`,e=>(e[1]=it(this,e[1]),e))},every(e,t){return ct(this,`every`,e,t,void 0,arguments)},filter(e,t){return ct(this,`filter`,e,t,e=>e.map(e=>it(this,e)),arguments)},find(e,t){return ct(this,`find`,e,t,e=>it(this,e),arguments)},findIndex(e,t){return ct(this,`findIndex`,e,t,void 0,arguments)},findLast(e,t){return ct(this,`findLast`,e,t,e=>it(this,e),arguments)},findLastIndex(e,t){return ct(this,`findLastIndex`,e,t,void 0,arguments)},forEach(e,t){return ct(this,`forEach`,e,t,void 0,arguments)},includes(...e){return ut(this,`includes`,e)},indexOf(...e){return ut(this,`indexOf`,e)},join(e){return nt(this).join(e)},lastIndexOf(...e){return ut(this,`lastIndexOf`,e)},map(e,t){return ct(this,`map`,e,t,void 0,arguments)},pop(){return dt(this,`pop`)},push(...e){return dt(this,`push`,e)},reduce(e,...t){return lt(this,`reduce`,e,t)},reduceRight(e,...t){return lt(this,`reduceRight`,e,t)},shift(){return dt(this,`shift`)},some(e,t){return ct(this,`some`,e,t,void 0,arguments)},splice(...e){return dt(this,`splice`,e)},toReversed(){return nt(this).toReversed()},toSorted(e){return nt(this).toSorted(e)},toSpliced(...e){return nt(this).toSpliced(...e)},unshift(...e){return dt(this,`unshift`,e)},values(){return ot(this,`values`,e=>it(this,e))}};function ot(e,t,n){let r=rt(e),i=r[t]();return r!==e&&!Ht(e)&&(i._next=i.next,i.next=()=>{let e=i._next();return e.done||(e.value=n(e.value)),e}),i}var st=Array.prototype;function ct(e,t,n,r,i,a){let o=rt(e),s=o!==e&&!Ht(e),c=o[t];if(c!==st[t]){let t=c.apply(e,a);return s?Kt(t):t}let l=n;o!==e&&(s?l=function(t,r){return n.call(this,it(e,t),r,e)}:n.length>2&&(l=function(t,r){return n.call(this,t,r,e)}));let u=c.call(o,l,r);return s&&i?i(u):u}function lt(e,t,n,r){let i=rt(e),a=n;return i!==e&&(Ht(e)?n.length>3&&(a=function(t,r,i){return n.call(this,t,r,i,e)}):a=function(t,r,i){return n.call(this,t,it(e,r),i,e)}),i[t](a,...r)}function ut(e,t,n){let r=Wt(e);$e(r,`iterate`,Qe);let i=r[t](...n);return(i===-1||i===!1)&&Ut(n[0])?(n[0]=Wt(n[0]),r[t](...n)):i}function dt(e,t,n=[]){He(),Me();let r=Wt(e)[t].apply(e,n);return Ne(),Ue(),r}var ft=e(`__proto__,__v_isRef,__isVue`),pt=new Set(Object.getOwnPropertyNames(Symbol).filter(e=>e!==`arguments`&&e!==`caller`).map(e=>Symbol[e]).filter(_));function mt(e){_(e)||(e=String(e));let t=Wt(this);return $e(t,`has`,e),t.hasOwnProperty(e)}var ht=class{constructor(e=!1,t=!1){this._isReadonly=e,this._isShallow=t}get(e,t,n){if(t===`__v_skip`)return e.__v_skip;let r=this._isReadonly,i=this._isShallow;if(t===`__v_isReactive`)return!r;if(t===`__v_isReadonly`)return r;if(t===`__v_isShallow`)return i;if(t===`__v_raw`)return n===(r?i?Nt:Mt:i?jt:At).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(n)?e:void 0;let a=d(e);if(!r){let e;if(a&&(e=at[t]))return e;if(t===`hasOwnProperty`)return mt}let o=Reflect.get(e,t,Jt(e)?e:n);if((_(t)?pt.has(t):ft(t))||(r||$e(e,`get`,t),i))return o;if(Jt(o)){let e=a&&w(t)?o:o.value;return r&&v(e)?Rt(e):e}return v(o)?r?Rt(o):It(o):o}},gt=class extends ht{constructor(e=!1){super(!1,e)}set(e,t,n,r){let i=e[t],a=d(e)&&w(t);if(!this._isShallow){let e=Vt(i);if(!Ht(n)&&!Vt(n)&&(i=Wt(i),n=Wt(n)),!a&&Jt(i)&&!Jt(n))return e||(i.value=n),!0}let o=a?Number(t)<e.length:u(e,t),s=Reflect.set(e,t,n,Jt(e)?e:r);return e===Wt(r)&&(o?A(n,i)&&et(e,`set`,t,n,i):et(e,`add`,t,n)),s}deleteProperty(e,t){let n=u(e,t),r=e[t],i=Reflect.deleteProperty(e,t);return i&&n&&et(e,`delete`,t,void 0,r),i}has(e,t){let n=Reflect.has(e,t);return(!_(t)||!pt.has(t))&&$e(e,`has`,t),n}ownKeys(e){return $e(e,`iterate`,d(e)?`length`:Xe),Reflect.ownKeys(e)}},_t=class extends ht{constructor(e=!1){super(!0,e)}set(e,t){return!0}deleteProperty(e,t){return!0}},vt=new gt,yt=new _t,bt=new gt(!0),xt=e=>e,St=e=>Reflect.getPrototypeOf(e);function Ct(e,t,n){return function(...r){let i=this.__v_raw,a=Wt(i),o=f(a),c=e===`entries`||e===Symbol.iterator&&o,l=e===`keys`&&o,u=i[e](...r),d=n?xt:t?qt:Kt;return!t&&$e(a,`iterate`,l?Ze:Xe),s(Object.create(u),{next(){let{value:e,done:t}=u.next();return t?{value:e,done:t}:{value:c?[d(e[0]),d(e[1])]:d(e),done:t}}})}}function wt(e){return function(...t){return e===`delete`?!1:e===`clear`?void 0:this}}function Tt(e,t){let n={get(n){let r=this.__v_raw,i=Wt(r),a=Wt(n);e||(A(n,a)&&$e(i,`get`,n),$e(i,`get`,a));let{has:o}=St(i),s=t?xt:e?qt:Kt;if(o.call(i,n))return s(r.get(n));if(o.call(i,a))return s(r.get(a));r!==i&&r.get(n)},get size(){let t=this.__v_raw;return!e&&$e(Wt(t),`iterate`,Xe),t.size},has(t){let n=this.__v_raw,r=Wt(n),i=Wt(t);return e||(A(t,i)&&$e(r,`has`,t),$e(r,`has`,i)),t===i?n.has(t):n.has(t)||n.has(i)},forEach(n,r){let i=this,a=i.__v_raw,o=Wt(a),s=t?xt:e?qt:Kt;return!e&&$e(o,`iterate`,Xe),a.forEach((e,t)=>n.call(r,s(e),s(t),i))}};return s(n,e?{add:wt(`add`),set:wt(`set`),delete:wt(`delete`),clear:wt(`clear`)}:{add(e){!t&&!Ht(e)&&!Vt(e)&&(e=Wt(e));let n=Wt(this);return St(n).has.call(n,e)||(n.add(e),et(n,`add`,e,e)),this},set(e,n){!t&&!Ht(n)&&!Vt(n)&&(n=Wt(n));let r=Wt(this),{has:i,get:a}=St(r),o=i.call(r,e);o||=(e=Wt(e),i.call(r,e));let s=a.call(r,e);return r.set(e,n),o?A(n,s)&&et(r,`set`,e,n,s):et(r,`add`,e,n),this},delete(e){let t=Wt(this),{has:n,get:r}=St(t),i=n.call(t,e);i||=(e=Wt(e),n.call(t,e));let a=r?r.call(t,e):void 0,o=t.delete(e);return i&&et(t,`delete`,e,void 0,a),o},clear(){let e=Wt(this),t=e.size!==0,n=e.clear();return t&&et(e,`clear`,void 0,void 0,void 0),n}}),[`keys`,`values`,`entries`,Symbol.iterator].forEach(r=>{n[r]=Ct(r,e,t)}),n}function Et(e,t){let n=Tt(e,t);return(t,r,i)=>r===`__v_isReactive`?!e:r===`__v_isReadonly`?e:r===`__v_raw`?t:Reflect.get(u(n,r)&&r in t?n:t,r,i)}var Dt={get:Et(!1,!1)},Ot={get:Et(!1,!0)},kt={get:Et(!0,!1)},At=new WeakMap,jt=new WeakMap,Mt=new WeakMap,Nt=new WeakMap;function Pt(e){switch(e){case`Object`:case`Array`:return 1;case`Map`:case`Set`:case`WeakMap`:case`WeakSet`:return 2;default:return 0}}function Ft(e){return e.__v_skip||!Object.isExtensible(e)?0:Pt(S(e))}function It(e){return Vt(e)?e:zt(e,!1,vt,Dt,At)}function Lt(e){return zt(e,!1,bt,Ot,jt)}function Rt(e){return zt(e,!0,yt,kt,Mt)}function zt(e,t,n,r,i){if(!v(e)||e.__v_raw&&!(t&&e.__v_isReactive))return e;let a=Ft(e);if(a===0)return e;let o=i.get(e);if(o)return o;let s=new Proxy(e,a===2?r:n);return i.set(e,s),s}function Bt(e){return Vt(e)?Bt(e.__v_raw):!!(e&&e.__v_isReactive)}function Vt(e){return!!(e&&e.__v_isReadonly)}function Ht(e){return!!(e&&e.__v_isShallow)}function Ut(e){return e?!!e.__v_raw:!1}function Wt(e){let t=e&&e.__v_raw;return t?Wt(t):e}function Gt(e){return!u(e,`__v_skip`)&&Object.isExtensible(e)&&j(e,`__v_skip`,!0),e}var Kt=e=>v(e)?It(e):e,qt=e=>v(e)?Rt(e):e;function Jt(e){return e?e.__v_isRef===!0:!1}function F(e){return Yt(e,!1)}function I(e){return Yt(e,!0)}function Yt(e,t){return Jt(e)?e:new Xt(e,t)}var Xt=class{constructor(e,t){this.dep=new qe,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=t?e:Wt(e),this._value=t?e:Kt(e),this.__v_isShallow=t}get value(){return this.dep.track(),this._value}set value(e){let t=this._rawValue,n=this.__v_isShallow||Ht(e)||Vt(e);e=n?e:Wt(e),A(e,t)&&(this._rawValue=e,this._value=n?e:Kt(e),this.dep.trigger())}};function L(e){return Jt(e)?e.value:e}var Zt={get:(e,t,n)=>t===`__v_raw`?e:L(Reflect.get(e,t,n)),set:(e,t,n,r)=>{let i=e[t];return Jt(i)&&!Jt(n)?(i.value=n,!0):Reflect.set(e,t,n,r)}};function Qt(e){return Bt(e)?e:new Proxy(e,Zt)}var $t=class{constructor(e){this.__v_isRef=!0,this._value=void 0;let t=this.dep=new qe,{get:n,set:r}=e(t.track.bind(t),t.trigger.bind(t));this._get=n,this._set=r}get value(){return this._value=this._get()}set value(e){this._set(e)}};function en(e){return new $t(e)}var tn=class{constructor(e,t,n){this._object=e,this._key=t,this._defaultValue=n,this.__v_isRef=!0,this._value=void 0,this._raw=Wt(e);let r=!0,i=e;if(!d(e)||!w(String(t)))do r=!Ut(i)||Ht(i);while(r&&(i=i.__v_raw));this._shallow=r}get value(){let e=this._object[this._key];return this._shallow&&(e=L(e)),this._value=e===void 0?this._defaultValue:e}set value(e){if(this._shallow&&Jt(this._raw[this._key])){let t=this._object[this._key];if(Jt(t)){t.value=e;return}}this._object[this._key]=e}get dep(){return tt(this._raw,this._key)}},nn=class{constructor(e){this._getter=e,this.__v_isRef=!0,this.__v_isReadonly=!0,this._value=void 0}get value(){return this._value=this._getter()}};function rn(e,t,n){return Jt(e)?e:h(e)?new nn(e):v(e)&&arguments.length>1?an(e,t,n):F(e)}function an(e,t,n){return new tn(e,t,n)}var on=class{constructor(e,t,n){this.fn=e,this.setter=t,this._value=void 0,this.dep=new qe(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=Ge-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!t,this.isSSR=n}notify(){if(this.flags|=16,!(this.flags&8)&&Te!==this)return je(this,!0),!0}get value(){let e=this.dep.track();return Le(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter&&this.setter(e)}};function sn(e,t,n=!1){let r,i;return h(e)?r=e:(r=e.get,i=e.set),new on(r,i,n)}var cn={},ln=new WeakMap,un=void 0;function dn(e,t=!1,n=un){if(n){let t=ln.get(n);t||ln.set(n,t=[]),t.push(e)}}function fn(e,n,i=t){let{immediate:a,deep:o,once:s,scheduler:l,augmentJob:u,call:f}=i,p=e=>o?e:Ht(e)||o===!1||o===0?pn(e,1):pn(e),m,g,_,v,y=!1,b=!1;if(Jt(e)?(g=()=>e.value,y=Ht(e)):Bt(e)?(g=()=>p(e),y=!0):d(e)?(b=!0,y=e.some(e=>Bt(e)||Ht(e)),g=()=>e.map(e=>{if(Jt(e))return e.value;if(Bt(e))return p(e);if(h(e))return f?f(e,2):e()})):g=h(e)?n?f?()=>f(e,2):e:()=>{if(_){He();try{_()}finally{Ue()}}let t=un;un=m;try{return f?f(e,3,[v]):e(v)}finally{un=t}}:r,n&&o){let e=g,t=o===!0?1/0:o;g=()=>pn(e(),t)}let x=Ce(),S=()=>{m.stop(),x&&x.active&&c(x.effects,m)};if(s&&n){let e=n;n=(...t)=>{e(...t),S()}}let C=b?Array(e.length).fill(cn):cn,w=e=>{if(!(!(m.flags&1)||!m.dirty&&!e))if(n){let e=m.run();if(o||y||(b?e.some((e,t)=>A(e,C[t])):A(e,C))){_&&_();let t=un;un=m;try{let t=[e,C===cn?void 0:b&&C[0]===cn?[]:C,v];C=e,f?f(n,3,t):n(...t)}finally{un=t}}}else m.run()};return u&&u(w),m=new De(g),m.scheduler=l?()=>l(w,!1):w,v=e=>dn(e,!1,m),_=m.onStop=()=>{let e=ln.get(m);if(e){if(f)f(e,4);else for(let t of e)t();ln.delete(m)}},n?a?w(!0):C=m.run():l?l(w.bind(null,!0),!0):m.run(),S.pause=m.pause.bind(m),S.resume=m.resume.bind(m),S.stop=S,S}function pn(e,t=1/0,n){if(t<=0||!v(e)||e.__v_skip||(n||=new Map,(n.get(e)||0)>=t))return e;if(n.set(e,t),t--,Jt(e))pn(e.value,t,n);else if(d(e))for(let r=0;r<e.length;r++)pn(e[r],t,n);else if(p(e)||f(e))e.forEach(e=>{pn(e,t,n)});else if(C(e)){for(let r in e)pn(e[r],t,n);for(let r of Object.getOwnPropertySymbols(e))Object.prototype.propertyIsEnumerable.call(e,r)&&pn(e[r],t,n)}return e}function mn(e,t,n,r){try{return r?e(...r):e()}catch(e){gn(e,t,n)}}function hn(e,t,n,r){if(h(e)){let i=mn(e,t,n,r);return i&&y(i)&&i.catch(e=>{gn(e,t,n)}),i}if(d(e)){let i=[];for(let a=0;a<e.length;a++)i.push(hn(e[a],t,n,r));return i}}function gn(e,n,r,i=!0){let a=n?n.vnode:null,{errorHandler:o,throwUnhandledErrorInProduction:s}=n&&n.appContext.config||t;if(n){let t=n.parent,i=n.proxy,a=`https://vuejs.org/error-reference/#runtime-${r}`;for(;t;){let n=t.ec;if(n){for(let t=0;t<n.length;t++)if(n[t](e,i,a)===!1)return}t=t.parent}if(o){He(),mn(o,null,10,[e,i,a]),Ue();return}}_n(e,r,a,i,s)}function _n(e,t,n,r=!0,i=!1){if(i)throw e;console.error(e)}var vn=[],yn=-1,bn=[],xn=null,Sn=0,Cn=Promise.resolve(),wn=null;function Tn(e){let t=wn||Cn;return e?t.then(this?e.bind(this):e):t}function En(e){let t=yn+1,n=vn.length;for(;t<n;){let r=t+n>>>1,i=vn[r],a=Mn(i);a<e||a===e&&i.flags&2?t=r+1:n=r}return t}function Dn(e){if(!(e.flags&1)){let t=Mn(e),n=vn[vn.length-1];!n||!(e.flags&2)&&t>=Mn(n)?vn.push(e):vn.splice(En(t),0,e),e.flags|=1,On()}}function On(){wn||=Cn.then(Nn)}function kn(e){d(e)?bn.push(...e):xn&&e.id===-1?xn.splice(Sn+1,0,e):e.flags&1||(bn.push(e),e.flags|=1),On()}function An(e,t,n=yn+1){for(;n<vn.length;n++){let t=vn[n];if(t&&t.flags&2){if(e&&t.id!==e.uid)continue;vn.splice(n,1),n--,t.flags&4&&(t.flags&=-2),t(),t.flags&4||(t.flags&=-2)}}}function jn(e){if(bn.length){let e=[...new Set(bn)].sort((e,t)=>Mn(e)-Mn(t));if(bn.length=0,xn){xn.push(...e);return}for(xn=e,Sn=0;Sn<xn.length;Sn++){let e=xn[Sn];e.flags&4&&(e.flags&=-2),e.flags&8||e(),e.flags&=-2}xn=null,Sn=0}}var Mn=e=>e.id==null?e.flags&2?-1:1/0:e.id;function Nn(e){try{for(yn=0;yn<vn.length;yn++){let e=vn[yn];e&&!(e.flags&8)&&(e.flags&4&&(e.flags&=-2),mn(e,e.i,e.i?15:14),e.flags&4||(e.flags&=-2))}}finally{for(;yn<vn.length;yn++){let e=vn[yn];e&&(e.flags&=-2)}yn=-1,vn.length=0,jn(e),wn=null,(vn.length||bn.length)&&Nn(e)}}var Pn=null,Fn=null;function In(e){let t=Pn;return Pn=e,Fn=e&&e.type.__scopeId||null,t}function Ln(e,t=Pn,n){if(!t||e._n)return e;let r=(...n)=>{r._d&&Sa(-1);let i=In(t),a;try{a=e(...n)}finally{In(i),r._d&&Sa(1)}return a};return r._n=!0,r._c=!0,r._d=!0,r}function Rn(e,n){if(Pn===null)return e;let r=ro(Pn),i=e.dirs||=[];for(let e=0;e<n.length;e++){let[a,o,s,c=t]=n[e];a&&(h(a)&&(a={mounted:a,updated:a}),a.deep&&pn(o),i.push({dir:a,instance:r,value:o,oldValue:void 0,arg:s,modifiers:c}))}return e}function zn(e,t,n,r){let i=e.dirs,a=t&&t.dirs;for(let o=0;o<i.length;o++){let s=i[o];a&&(s.oldValue=a[o].value);let c=s.dir[r];c&&(He(),hn(c,n,8,[e.el,s,e,t]),Ue())}}function Bn(e,t){if(Va){let n=Va.provides,r=Va.parent&&Va.parent.provides;r===n&&(n=Va.provides=Object.create(r)),n[e]=t}}function Vn(e,t,n=!1){let r=Ha();if(r||wi){let i=wi?wi._context.provides:r?r.parent==null||r.ce?r.vnode.appContext&&r.vnode.appContext.provides:r.parent.provides:void 0;if(i&&e in i)return i[e];if(arguments.length>1)return n&&h(t)?t.call(r&&r.proxy):t}}var Hn=Symbol.for(`v-scx`),Un=()=>Vn(Hn);function Wn(e,t){return Gn(e,null,{flush:`sync`})}function R(e,t,n){return Gn(e,t,n)}function Gn(e,n,i=t){let{immediate:a,deep:o,flush:c,once:l}=i,u=s({},i),d=n&&a||!n&&c!==`post`,f;if(Ja){if(c===`sync`){let e=Un();f=e.__watcherHandles||=[]}else if(!d){let e=()=>{};return e.stop=r,e.resume=r,e.pause=r,e}}let p=Va;u.call=(e,t,n)=>hn(e,p,t,n);let m=!1;c===`post`?u.scheduler=e=>{na(e,p&&p.suspense)}:c!==`sync`&&(m=!0,u.scheduler=(e,t)=>{t?e():Dn(e)}),u.augmentJob=e=>{n&&(e.flags|=4),m&&(e.flags|=2,p&&(e.id=p.uid,e.i=p))};let h=fn(e,n,u);return Ja&&(f?f.push(h):d&&h()),h}function Kn(e,t,n){let r=this.proxy,i=g(e)?e.includes(`.`)?qn(r,e):()=>r[e]:e.bind(r,r),a;h(t)?a=t:(a=t.handler,n=t);let o=Ga(this),s=Gn(i,a.bind(r),n);return o(),s}function qn(e,t){let n=t.split(`.`);return()=>{let t=e;for(let e=0;e<n.length&&t;e++)t=t[n[e]];return t}}var Jn=Symbol(`_vte`),Yn=e=>e.__isTeleport,Xn=e=>e&&(e.disabled||e.disabled===``),Zn=e=>e&&(e.defer||e.defer===``),Qn=e=>typeof SVGElement<`u`&&e instanceof SVGElement,$n=e=>typeof MathMLElement==`function`&&e instanceof MathMLElement,er=(e,t)=>{let n=e&&e.to;return g(n)?t?t(n):null:n},tr={name:`Teleport`,__isTeleport:!0,process(e,t,n,r,i,a,o,s,c,l){let{mc:u,pc:d,pbc:f,o:{insert:p,querySelector:m,createText:h,createComment:g}}=l,_=Xn(t.props),{shapeFlag:v,children:y,dynamicChildren:b}=t;if(e==null){let e=t.el=h(``),l=t.anchor=h(``);p(e,n,r),p(l,n,r);let d=(e,t)=>{v&16&&u(y,e,t,i,a,o,s,c)},f=()=>{let e=t.target=er(t.props,m),n=or(e,t,h,p);e&&(o!==`svg`&&Qn(e)?o=`svg`:o!==`mathml`&&$n(e)&&(o=`mathml`),i&&i.isCE&&(i.ce._teleportTargets||(i.ce._teleportTargets=new Set)).add(e),_||(d(e,n),ar(t,!1)))};_&&(d(n,l),ar(t,!0)),Zn(t.props)?(t.el.__isMounted=!1,na(()=>{f(),delete t.el.__isMounted},a)):f()}else{if(Zn(t.props)&&e.el.__isMounted===!1){na(()=>{tr.process(e,t,n,r,i,a,o,s,c,l)},a);return}t.el=e.el,t.targetStart=e.targetStart;let u=t.anchor=e.anchor,p=t.target=e.target,h=t.targetAnchor=e.targetAnchor,g=Xn(e.props),v=g?n:p,y=g?u:h;if(o===`svg`||Qn(p)?o=`svg`:(o===`mathml`||$n(p))&&(o=`mathml`),b?(f(e.dynamicChildren,b,v,i,a,o,s),ca(e,t,!0)):c||d(e,t,v,y,i,a,o,s,!1),_)g?t.props&&e.props&&t.props.to!==e.props.to&&(t.props.to=e.props.to):nr(t,n,u,l,1);else if((t.props&&t.props.to)!==(e.props&&e.props.to)){let e=t.target=er(t.props,m);e&&nr(t,e,null,l,0)}else g&&nr(t,p,h,l,1);ar(t,_)}},remove(e,t,n,{um:r,o:{remove:i}},a){let{shapeFlag:o,children:s,anchor:c,targetStart:l,targetAnchor:u,target:d,props:f}=e;if(d&&(i(l),i(u)),a&&i(c),o&16){let e=a||!Xn(f);for(let i=0;i<s.length;i++){let a=s[i];r(a,t,n,e,!!a.dynamicChildren)}}},move:nr,hydrate:rr};function nr(e,t,n,{o:{insert:r},m:i},a=2){a===0&&r(e.targetAnchor,t,n);let{el:o,anchor:s,shapeFlag:c,children:l,props:u}=e,d=a===2;if(d&&r(o,t,n),(!d||Xn(u))&&c&16)for(let e=0;e<l.length;e++)i(l[e],t,n,2);d&&r(s,t,n)}function rr(e,t,n,r,i,a,{o:{nextSibling:o,parentNode:s,querySelector:c,insert:l,createText:u}},d){function f(e,n){let r=n;for(;r;){if(r&&r.nodeType===8){if(r.data===`teleport start anchor`)t.targetStart=r;else if(r.data===`teleport anchor`){t.targetAnchor=r,e._lpa=t.targetAnchor&&o(t.targetAnchor);break}}r=o(r)}}function p(e,t){t.anchor=d(o(e),t,s(e),n,r,i,a)}let m=t.target=er(t.props,c),h=Xn(t.props);if(m){let c=m._lpa||m.firstChild;t.shapeFlag&16&&(h?(p(e,t),f(m,c),t.targetAnchor||or(m,t,u,l,s(e)===m?e:null)):(t.anchor=o(e),f(m,c),t.targetAnchor||or(m,t,u,l),d(c&&o(c),t,m,n,r,i,a))),ar(t,h)}else h&&t.shapeFlag&16&&(p(e,t),t.targetStart=e,t.targetAnchor=o(e));return t.anchor&&o(t.anchor)}var ir=tr;function ar(e,t){let n=e.ctx;if(n&&n.ut){let r,i;for(t?(r=e.el,i=e.anchor):(r=e.targetStart,i=e.targetAnchor);r&&r!==i;)r.nodeType===1&&r.setAttribute(`data-v-owner`,n.uid),r=r.nextSibling;n.ut()}}function or(e,t,n,r,i=null){let a=t.targetStart=n(``),o=t.targetAnchor=n(``);return a[Jn]=o,e&&(r(a,e,i),r(o,e,i)),o}var sr=Symbol(`_leaveCb`),cr=Symbol(`_enterCb`);function lr(){let e={isMounted:!1,isLeaving:!1,isUnmounting:!1,leavingVNodes:new Map};return Ir(()=>{e.isMounted=!0}),zr(()=>{e.isUnmounting=!0}),e}var ur=[Function,Array],dr={mode:String,appear:Boolean,persisted:Boolean,onBeforeEnter:ur,onEnter:ur,onAfterEnter:ur,onEnterCancelled:ur,onBeforeLeave:ur,onLeave:ur,onAfterLeave:ur,onLeaveCancelled:ur,onBeforeAppear:ur,onAppear:ur,onAfterAppear:ur,onAppearCancelled:ur},fr=e=>{let t=e.subTree;return t.component?fr(t.component):t},pr={name:`BaseTransition`,props:dr,setup(e,{slots:t}){let n=Ha(),r=lr();return()=>{let i=t.default&&xr(t.default(),!0);if(!i||!i.length)return;let a=mr(i),o=Wt(e),{mode:s}=o;if(r.isLeaving)return vr(a);let c=yr(a);if(!c)return vr(a);let l=_r(c,o,r,n,e=>l=e);c.type!==ga&&br(c,l);let u=n.subTree&&yr(n.subTree);if(u&&u.type!==ga&&!Ea(u,c)&&fr(n).type!==ga){let e=_r(u,o,r,n);if(br(u,e),s===`out-in`&&c.type!==ga)return r.isLeaving=!0,e.afterLeave=()=>{r.isLeaving=!1,n.job.flags&8||n.update(),delete e.afterLeave,u=void 0},vr(a);s===`in-out`&&c.type!==ga?e.delayLeave=(e,t,n)=>{let i=gr(r,u);i[String(u.key)]=u,e[sr]=()=>{t(),e[sr]=void 0,delete l.delayedLeave,u=void 0},l.delayedLeave=()=>{n(),delete l.delayedLeave,u=void 0}}:u=void 0}else u&&=void 0;return a}}};function mr(e){let t=e[0];if(e.length>1){for(let n of e)if(n.type!==ga){t=n;break}}return t}var hr=pr;function gr(e,t){let{leavingVNodes:n}=e,r=n.get(t.type);return r||(r=Object.create(null),n.set(t.type,r)),r}function _r(e,t,n,r,i){let{appear:a,mode:o,persisted:s=!1,onBeforeEnter:c,onEnter:l,onAfterEnter:u,onEnterCancelled:f,onBeforeLeave:p,onLeave:m,onAfterLeave:h,onLeaveCancelled:g,onBeforeAppear:_,onAppear:v,onAfterAppear:y,onAppearCancelled:b}=t,x=String(e.key),S=gr(n,e),C=(e,t)=>{e&&hn(e,r,9,t)},w=(e,t)=>{let n=t[1];C(e,t),d(e)?e.every(e=>e.length<=1)&&n():e.length<=1&&n()},T={mode:o,persisted:s,beforeEnter(t){let r=c;if(!n.isMounted)if(a)r=_||c;else return;t[sr]&&t[sr](!0);let i=S[x];i&&Ea(e,i)&&i.el[sr]&&i.el[sr](),C(r,[t])},enter(t){if(S[x]===e)return;let r=l,i=u,o=f;if(!n.isMounted)if(a)r=v||l,i=y||u,o=b||f;else return;let s=!1;t[cr]=e=>{s||(s=!0,C(e?o:i,[t]),T.delayedLeave&&T.delayedLeave(),t[cr]=void 0)};let c=t[cr].bind(null,!1);r?w(r,[t,c]):c()},leave(t,r){let i=String(e.key);if(t[cr]&&t[cr](!0),n.isUnmounting)return r();C(p,[t]);let a=!1;t[sr]=n=>{a||(a=!0,r(),C(n?g:h,[t]),t[sr]=void 0,S[i]===e&&delete S[i])};let o=t[sr].bind(null,!1);S[i]=e,m?w(m,[t,o]):o()},clone(e){let a=_r(e,t,n,r,i);return i&&i(a),a}};return T}function vr(e){if(Or(e))return e=ja(e),e.children=null,e}function yr(e){if(!Or(e))return Yn(e.type)&&e.children?mr(e.children):e;if(e.component)return e.component.subTree;let{shapeFlag:t,children:n}=e;if(n){if(t&16)return n[0];if(t&32&&h(n.default))return n.default()}}function br(e,t){e.shapeFlag&6&&e.component?(e.transition=t,br(e.component.subTree,t)):e.shapeFlag&128?(e.ssContent.transition=t.clone(e.ssContent),e.ssFallback.transition=t.clone(e.ssFallback)):e.transition=t}function xr(e,t=!1,n){let r=[],i=0;for(let a=0;a<e.length;a++){let o=e[a],s=n==null?o.key:String(n)+String(o.key==null?a:o.key);o.type===B?(o.patchFlag&128&&i++,r=r.concat(xr(o.children,t,s))):(t||o.type!==ga)&&r.push(s==null?o:ja(o,{key:s}))}if(i>1)for(let e=0;e<r.length;e++)r[e].patchFlag=-2;return r}function z(e,t){return h(e)?s({name:e.name},t,{setup:e}):e}function Sr(e){e.ids=[e.ids[0]+ e.ids[2]+++`-`,0,0]}function Cr(e,t){let n;return!!((n=Object.getOwnPropertyDescriptor(e,t))&&!n.configurable)}var wr=new WeakMap;function Tr(e,n,r,a,o=!1){if(d(e)){e.forEach((e,t)=>Tr(e,n&&(d(n)?n[t]:n),r,a,o));return}if(Dr(a)&&!o){a.shapeFlag&512&&a.type.__asyncResolved&&a.component.subTree.component&&Tr(e,n,r,a.component.subTree);return}let s=a.shapeFlag&4?ro(a.component):a.el,l=o?null:s,{i:f,r:p}=e,m=n&&n.r,_=f.refs===t?f.refs={}:f.refs,v=f.setupState,y=Wt(v),b=v===t?i:e=>Cr(_,e)?!1:u(y,e),x=(e,t)=>!(t&&Cr(_,t));if(m!=null&&m!==p){if(Er(n),g(m))_[m]=null,b(m)&&(v[m]=null);else if(Jt(m)){let e=n;x(m,e.k)&&(m.value=null),e.k&&(_[e.k]=null)}}if(h(p))mn(p,f,12,[l,_]);else{let t=g(p),n=Jt(p);if(t||n){let i=()=>{if(e.f){let n=t?b(p)?v[p]:_[p]:x(p)||!e.k?p.value:_[e.k];if(o)d(n)&&c(n,s);else if(d(n))n.includes(s)||n.push(s);else if(t)_[p]=[s],b(p)&&(v[p]=_[p]);else{let t=[s];x(p,e.k)&&(p.value=t),e.k&&(_[e.k]=t)}}else t?(_[p]=l,b(p)&&(v[p]=l)):n&&(x(p,e.k)&&(p.value=l),e.k&&(_[e.k]=l))};if(l){let t=()=>{i(),wr.delete(e)};t.id=-1,wr.set(e,t),na(t,r)}else Er(e),i()}}}function Er(e){let t=wr.get(e);t&&(t.flags|=8,wr.delete(e))}se().requestIdleCallback,se().cancelIdleCallback;var Dr=e=>!!e.type.__asyncLoader,Or=e=>e.type.__isKeepAlive;function kr(e,t){jr(e,`a`,t)}function Ar(e,t){jr(e,`da`,t)}function jr(e,t,n=Va){let r=e.__wdc||=()=>{let t=n;for(;t;){if(t.isDeactivated)return;t=t.parent}return e()};if(Nr(t,r,n),n){let e=n.parent;for(;e&&e.parent;)Or(e.parent.vnode)&&Mr(r,t,n,e),e=e.parent}}function Mr(e,t,n,r){let i=Nr(t,e,r,!0);Br(()=>{c(r[t],i)},n)}function Nr(e,t,n=Va,r=!1){if(n){let i=n[e]||(n[e]=[]),a=t.__weh||=(...r)=>{He();let i=Ga(n),a=hn(t,n,e,r);return i(),Ue(),a};return r?i.unshift(a):i.push(a),a}}var Pr=e=>(t,n=Va)=>{(!Ja||e===`sp`)&&Nr(e,(...e)=>t(...e),n)},Fr=Pr(`bm`),Ir=Pr(`m`),Lr=Pr(`bu`),Rr=Pr(`u`),zr=Pr(`bum`),Br=Pr(`um`),Vr=Pr(`sp`),Hr=Pr(`rtg`),Ur=Pr(`rtc`);function Wr(e,t=Va){Nr(`ec`,e,t)}var Gr=`components`;function Kr(e,t){return Yr(Gr,e,!0,t)||e}var qr=Symbol.for(`v-ndc`);function Jr(e){return g(e)?Yr(Gr,e,!1)||e:e||qr}function Yr(e,t,n=!0,r=!1){let i=Pn||Va;if(i){let n=i.type;if(e===Gr){let e=io(n,!1);if(e&&(e===t||e===D(t)||e===te(D(t))))return n}let a=Xr(i[e]||n[e],t)||Xr(i.appContext[e],t);return!a&&r?n:a}}function Xr(e,t){return e&&(e[t]||e[D(t)]||e[te(D(t))])}function Zr(e,t,n,r){let i,a=n&&n[r],o=d(e);if(o||g(e)){let n=o&&Bt(e),r=!1,s=!1;n&&(r=!Ht(e),s=Vt(e),e=rt(e)),i=Array(e.length);for(let n=0,o=e.length;n<o;n++)i[n]=t(r?s?qt(Kt(e[n])):Kt(e[n]):e[n],n,void 0,a&&a[n])}else if(typeof e==`number`){i=Array(e);for(let n=0;n<e;n++)i[n]=t(n+1,n,void 0,a&&a[n])}else if(v(e))if(e[Symbol.iterator])i=Array.from(e,(e,n)=>t(e,n,void 0,a&&a[n]));else{let n=Object.keys(e);i=Array(n.length);for(let r=0,o=n.length;r<o;r++){let o=n[r];i[r]=t(e[o],o,r,a&&a[r])}}else i=[];return n&&(n[r]=i),i}function Qr(e,t,n={},r,i){if(Pn.ce||Pn.parent&&Dr(Pn.parent)&&Pn.parent.ce){let e=Object.keys(n).length>0;return t!==`default`&&(n.name=t),V(),wa(B,null,[W(`slot`,n,r&&r())],e?-2:64)}let a=e[t];a&&a._c&&(a._d=!1),V();let o=a&&$r(a(n)),s=n.key||o&&o.key,c=wa(B,{key:(s&&!_(s)?s:`_${t}`)+(!o&&r?`_fb`:``)},o||(r?r():[]),o&&e._===1?64:-2);return!i&&c.scopeId&&(c.slotScopeIds=[c.scopeId+`-s`]),a&&a._c&&(a._d=!0),c}function $r(e){return e.some(e=>Ta(e)?!(e.type===ga||e.type===B&&!$r(e.children)):!0)?e:null}var ei=e=>e?qa(e)?ro(e):ei(e.parent):null,ti=s(Object.create(null),{$:e=>e,$el:e=>e.vnode.el,$data:e=>e.data,$props:e=>e.props,$attrs:e=>e.attrs,$slots:e=>e.slots,$refs:e=>e.refs,$parent:e=>ei(e.parent),$root:e=>ei(e.root),$host:e=>e.ce,$emit:e=>e.emit,$options:e=>di(e),$forceUpdate:e=>e.f||=()=>{Dn(e.update)},$nextTick:e=>e.n||=Tn.bind(e.proxy),$watch:e=>Kn.bind(e)}),ni=(e,n)=>e!==t&&!e.__isScriptSetup&&u(e,n),ri={get({_:e},n){if(n===`__v_skip`)return!0;let{ctx:r,setupState:i,data:a,props:o,accessCache:s,type:c,appContext:l}=e;if(n[0]!==`$`){let e=s[n];if(e!==void 0)switch(e){case 1:return i[n];case 2:return a[n];case 4:return r[n];case 3:return o[n]}else if(ni(i,n))return s[n]=1,i[n];else if(a!==t&&u(a,n))return s[n]=2,a[n];else if(u(o,n))return s[n]=3,o[n];else if(r!==t&&u(r,n))return s[n]=4,r[n];else oi&&(s[n]=0)}let d=ti[n],f,p;if(d)return n===`$attrs`&&$e(e.attrs,`get`,``),d(e);if((f=c.__cssModules)&&(f=f[n]))return f;if(r!==t&&u(r,n))return s[n]=4,r[n];if(p=l.config.globalProperties,u(p,n))return p[n]},set({_:e},n,r){let{data:i,setupState:a,ctx:o}=e;return ni(a,n)?(a[n]=r,!0):i!==t&&u(i,n)?(i[n]=r,!0):u(e.props,n)||n[0]===`$`&&n.slice(1)in e?!1:(o[n]=r,!0)},has({_:{data:e,setupState:n,accessCache:r,ctx:i,appContext:a,props:o,type:s}},c){let l;return!!(r[c]||e!==t&&c[0]!==`$`&&u(e,c)||ni(n,c)||u(o,c)||u(i,c)||u(ti,c)||u(a.config.globalProperties,c)||(l=s.__cssModules)&&l[c])},defineProperty(e,t,n){return n.get==null?u(n,`value`)&&this.set(e,t,n.value,null):e._.accessCache[t]=0,Reflect.defineProperty(e,t,n)}};function ii(e){return d(e)?e.reduce((e,t)=>(e[t]=null,e),{}):e}function ai(e,t){return!e||!t?e||t:d(e)&&d(t)?e.concat(t):s({},ii(e),ii(t))}var oi=!0;function si(e){let t=di(e),n=e.proxy,i=e.ctx;oi=!1,t.beforeCreate&&li(t.beforeCreate,e,`bc`);let{data:a,computed:o,methods:s,watch:c,provide:l,inject:u,created:f,beforeMount:p,mounted:m,beforeUpdate:g,updated:_,activated:y,deactivated:b,beforeDestroy:x,beforeUnmount:S,destroyed:C,unmounted:w,render:T,renderTracked:ee,renderTriggered:E,errorCaptured:D,serverPrefetch:O,expose:k,inheritAttrs:te,components:ne,directives:A,filters:re}=t;if(u&&ci(u,i,null),s)for(let e in s){let t=s[e];h(t)&&(i[e]=t.bind(n))}if(a){let t=a.call(n,n);v(t)&&(e.data=It(t))}if(oi=!0,o)for(let e in o){let t=o[e],a=q({get:h(t)?t.bind(n,n):h(t.get)?t.get.bind(n,n):r,set:!h(t)&&h(t.set)?t.set.bind(n):r});Object.defineProperty(i,e,{enumerable:!0,configurable:!0,get:()=>a.value,set:e=>a.value=e})}if(c)for(let e in c)ui(c[e],i,n,e);if(l){let e=h(l)?l.call(n):l;Reflect.ownKeys(e).forEach(t=>{Bn(t,e[t])})}f&&li(f,e,`c`);function j(e,t){d(t)?t.forEach(t=>e(t.bind(n))):t&&e(t.bind(n))}if(j(Fr,p),j(Ir,m),j(Lr,g),j(Rr,_),j(kr,y),j(Ar,b),j(Wr,D),j(Ur,ee),j(Hr,E),j(zr,S),j(Br,w),j(Vr,O),d(k))if(k.length){let t=e.exposed||={};k.forEach(e=>{Object.defineProperty(t,e,{get:()=>n[e],set:t=>n[e]=t,enumerable:!0})})}else e.exposed||={};T&&e.render===r&&(e.render=T),te!=null&&(e.inheritAttrs=te),ne&&(e.components=ne),A&&(e.directives=A),O&&Sr(e)}function ci(e,t,n=r){d(e)&&(e=gi(e));for(let n in e){let r=e[n],i;i=v(r)?`default`in r?Vn(r.from||n,r.default,!0):Vn(r.from||n):Vn(r),Jt(i)?Object.defineProperty(t,n,{enumerable:!0,configurable:!0,get:()=>i.value,set:e=>i.value=e}):t[n]=i}}function li(e,t,n){hn(d(e)?e.map(e=>e.bind(t.proxy)):e.bind(t.proxy),t,n)}function ui(e,t,n,r){let i=r.includes(`.`)?qn(n,r):()=>n[r];if(g(e)){let n=t[e];h(n)&&R(i,n)}else if(h(e))R(i,e.bind(n));else if(v(e))if(d(e))e.forEach(e=>ui(e,t,n,r));else{let r=h(e.handler)?e.handler.bind(n):t[e.handler];h(r)&&R(i,r,e)}}function di(e){let t=e.type,{mixins:n,extends:r}=t,{mixins:i,optionsCache:a,config:{optionMergeStrategies:o}}=e.appContext,s=a.get(t),c;return s?c=s:!i.length&&!n&&!r?c=t:(c={},i.length&&i.forEach(e=>fi(c,e,o,!0)),fi(c,t,o)),v(t)&&a.set(t,c),c}function fi(e,t,n,r=!1){let{mixins:i,extends:a}=t;a&&fi(e,a,n,!0),i&&i.forEach(t=>fi(e,t,n,!0));for(let i in t)if(!(r&&i===`expose`)){let r=pi[i]||n&&n[i];e[i]=r?r(e[i],t[i]):t[i]}return e}var pi={data:mi,props:yi,emits:yi,methods:vi,computed:vi,beforeCreate:_i,created:_i,beforeMount:_i,mounted:_i,beforeUpdate:_i,updated:_i,beforeDestroy:_i,beforeUnmount:_i,destroyed:_i,unmounted:_i,activated:_i,deactivated:_i,errorCaptured:_i,serverPrefetch:_i,components:vi,directives:vi,watch:bi,provide:mi,inject:hi};function mi(e,t){return t?e?function(){return s(h(e)?e.call(this,this):e,h(t)?t.call(this,this):t)}:t:e}function hi(e,t){return vi(gi(e),gi(t))}function gi(e){if(d(e)){let t={};for(let n=0;n<e.length;n++)t[e[n]]=e[n];return t}return e}function _i(e,t){return e?[...new Set([].concat(e,t))]:t}function vi(e,t){return e?s(Object.create(null),e,t):t}function yi(e,t){return e?d(e)&&d(t)?[...new Set([...e,...t])]:s(Object.create(null),ii(e),ii(t??{})):t}function bi(e,t){if(!e)return t;if(!t)return e;let n=s(Object.create(null),e);for(let r in t)n[r]=_i(e[r],t[r]);return n}function xi(){return{app:null,config:{isNativeTag:i,performance:!1,globalProperties:{},optionMergeStrategies:{},errorHandler:void 0,warnHandler:void 0,compilerOptions:{}},mixins:[],components:{},directives:{},provides:Object.create(null),optionsCache:new WeakMap,propsCache:new WeakMap,emitsCache:new WeakMap}}var Si=0;function Ci(e,t){return function(n,r=null){h(n)||(n=s({},n)),r!=null&&!v(r)&&(r=null);let i=xi(),a=new WeakSet,o=[],c=!1,l=i.app={_uid:Si++,_component:n,_props:r,_container:null,_context:i,_instance:null,version:so,get config(){return i.config},set config(e){},use(e,...t){return a.has(e)||(e&&h(e.install)?(a.add(e),e.install(l,...t)):h(e)&&(a.add(e),e(l,...t))),l},mixin(e){return i.mixins.includes(e)||i.mixins.push(e),l},component(e,t){return t?(i.components[e]=t,l):i.components[e]},directive(e,t){return t?(i.directives[e]=t,l):i.directives[e]},mount(a,o,s){if(!c){let u=l._ceVNode||W(n,r);return u.appContext=i,s===!0?s=`svg`:s===!1&&(s=void 0),o&&t?t(u,a):e(u,a,s),c=!0,l._container=a,a.__vue_app__=l,ro(u.component)}},onUnmount(e){o.push(e)},unmount(){c&&(hn(o,l._instance,16),e(null,l._container),delete l._container.__vue_app__)},provide(e,t){return i.provides[e]=t,l},runWithContext(e){let t=wi;wi=l;try{return e()}finally{wi=t}}};return l}}var wi=null;function Ti(e,n,r=t){let i=Ha(),a=D(n),o=k(n),s=Ei(e,a),c=en((s,c)=>{let l,u=t,d;return Wn(()=>{let t=e[a];A(l,t)&&(l=t,c())}),{get(){return s(),r.get?r.get(l):l},set(e){let s=r.set?r.set(e):e;if(!A(s,l)&&!(u!==t&&A(e,u)))return;let f=i.vnode.props;f&&(n in f||a in f||o in f)&&(`onUpdate:${n}`in f||`onUpdate:${a}`in f||`onUpdate:${o}`in f)||(l=e,c()),i.emit(`update:${n}`,s),A(e,s)&&A(e,u)&&!A(s,d)&&c(),u=e,d=s}}});return c[Symbol.iterator]=()=>{let e=0;return{next(){return e<2?{value:e++?s||t:c,done:!1}:{done:!0}}}},c}var Ei=(e,t)=>t===`modelValue`||t===`model-value`?e.modelModifiers:e[`${t}Modifiers`]||e[`${D(t)}Modifiers`]||e[`${k(t)}Modifiers`];function Di(e,n,...r){if(e.isUnmounted)return;let i=e.vnode.props||t,a=r,o=n.startsWith(`update:`),s=o&&Ei(i,n.slice(7));s&&(s.trim&&(a=r.map(e=>g(e)?e.trim():e)),s.number&&(a=r.map(ie)));let c,l=i[c=ne(n)]||i[c=ne(D(n))];!l&&o&&(l=i[c=ne(k(n))]),l&&hn(l,e,6,a);let u=i[c+`Once`];if(u){if(!e.emitted)e.emitted={};else if(e.emitted[c])return;e.emitted[c]=!0,hn(u,e,6,a)}}var Oi=new WeakMap;function ki(e,t,n=!1){let r=n?Oi:t.emitsCache,i=r.get(e);if(i!==void 0)return i;let a=e.emits,o={},c=!1;if(!h(e)){let r=e=>{let n=ki(e,t,!0);n&&(c=!0,s(o,n))};!n&&t.mixins.length&&t.mixins.forEach(r),e.extends&&r(e.extends),e.mixins&&e.mixins.forEach(r)}return!a&&!c?(v(e)&&r.set(e,null),null):(d(a)?a.forEach(e=>o[e]=null):s(o,a),v(e)&&r.set(e,o),o)}function Ai(e,t){return!e||!a(t)?!1:(t=t.slice(2).replace(/Once$/,``),u(e,t[0].toLowerCase()+t.slice(1))||u(e,k(t))||u(e,t))}function ji(e){let{type:t,vnode:n,proxy:r,withProxy:i,propsOptions:[a],slots:s,attrs:c,emit:l,render:u,renderCache:d,props:f,data:p,setupState:m,ctx:h,inheritAttrs:g}=e,_=In(e),v,y;try{if(n.shapeFlag&4){let e=i||r,t=e;v=Na(u.call(t,e,d,f,m,p,h)),y=c}else{let e=t;v=Na(e.length>1?e(f,{attrs:c,slots:s,emit:l}):e(f,null)),y=t.props?c:Mi(c)}}catch(t){va.length=0,gn(t,e,1),v=W(ga)}let b=v;if(y&&g!==!1){let e=Object.keys(y),{shapeFlag:t}=b;e.length&&t&7&&(a&&e.some(o)&&(y=Ni(y,a)),b=ja(b,y,!1,!0))}return n.dirs&&(b=ja(b,null,!1,!0),b.dirs=b.dirs?b.dirs.concat(n.dirs):n.dirs),n.transition&&br(b,n.transition),v=b,In(_),v}var Mi=e=>{let t;for(let n in e)(n===`class`||n===`style`||a(n))&&((t||={})[n]=e[n]);return t},Ni=(e,t)=>{let n={};for(let r in e)(!o(r)||!(r.slice(9)in t))&&(n[r]=e[r]);return n};function Pi(e,t,n){let{props:r,children:i,component:a}=e,{props:o,children:s,patchFlag:c}=t,l=a.emitsOptions;if(t.dirs||t.transition)return!0;if(n&&c>=0){if(c&1024)return!0;if(c&16)return r?Fi(r,o,l):!!o;if(c&8){let e=t.dynamicProps;for(let t=0;t<e.length;t++){let n=e[t];if(Ii(o,r,n)&&!Ai(l,n))return!0}}}else return(i||s)&&(!s||!s.$stable)?!0:r===o?!1:r?o?Fi(r,o,l):!0:!!o;return!1}function Fi(e,t,n){let r=Object.keys(t);if(r.length!==Object.keys(e).length)return!0;for(let i=0;i<r.length;i++){let a=r[i];if(Ii(t,e,a)&&!Ai(n,a))return!0}return!1}function Ii(e,t,n){let r=e[n],i=t[n];return n===`style`&&v(r)&&v(i)?!ge(r,i):r!==i}function Li({vnode:e,parent:t},n){for(;t;){let r=t.subTree;if(r.suspense&&r.suspense.activeBranch===e&&(r.el=e.el),r===e)(e=t.vnode).el=n,t=t.parent;else break}}var Ri={},zi=()=>Object.create(Ri),Bi=e=>Object.getPrototypeOf(e)===Ri;function Vi(e,t,n,r=!1){let i={},a=zi();e.propsDefaults=Object.create(null),Ui(e,t,i,a);for(let t in e.propsOptions[0])t in i||(i[t]=void 0);n?e.props=r?i:Lt(i):e.type.props?e.props=i:e.props=a,e.attrs=a}function Hi(e,t,n,r){let{props:i,attrs:a,vnode:{patchFlag:o}}=e,s=Wt(i),[c]=e.propsOptions,l=!1;if((r||o>0)&&!(o&16)){if(o&8){let n=e.vnode.dynamicProps;for(let r=0;r<n.length;r++){let o=n[r];if(Ai(e.emitsOptions,o))continue;let d=t[o];if(c)if(u(a,o))d!==a[o]&&(a[o]=d,l=!0);else{let t=D(o);i[t]=Wi(c,s,t,d,e,!1)}else d!==a[o]&&(a[o]=d,l=!0)}}}else{Ui(e,t,i,a)&&(l=!0);let r;for(let a in s)(!t||!u(t,a)&&((r=k(a))===a||!u(t,r)))&&(c?n&&(n[a]!==void 0||n[r]!==void 0)&&(i[a]=Wi(c,s,a,void 0,e,!0)):delete i[a]);if(a!==s)for(let e in a)(!t||!u(t,e))&&(delete a[e],l=!0)}l&&et(e.attrs,`set`,``)}function Ui(e,n,r,i){let[a,o]=e.propsOptions,s=!1,c;if(n)for(let t in n){if(T(t))continue;let l=n[t],d;a&&u(a,d=D(t))?!o||!o.includes(d)?r[d]=l:(c||={})[d]=l:Ai(e.emitsOptions,t)||(!(t in i)||l!==i[t])&&(i[t]=l,s=!0)}if(o){let n=Wt(r),i=c||t;for(let t=0;t<o.length;t++){let s=o[t];r[s]=Wi(a,n,s,i[s],e,!u(i,s))}}return s}function Wi(e,t,n,r,i,a){let o=e[n];if(o!=null){let e=u(o,`default`);if(e&&r===void 0){let e=o.default;if(o.type!==Function&&!o.skipFactory&&h(e)){let{propsDefaults:a}=i;if(n in a)r=a[n];else{let o=Ga(i);r=a[n]=e.call(null,t),o()}}else r=e;i.ce&&i.ce._setProp(n,r)}o[0]&&(a&&!e?r=!1:o[1]&&(r===``||r===k(n))&&(r=!0))}return r}var Gi=new WeakMap;function Ki(e,r,i=!1){let a=i?Gi:r.propsCache,o=a.get(e);if(o)return o;let c=e.props,l={},f=[],p=!1;if(!h(e)){let t=e=>{p=!0;let[t,n]=Ki(e,r,!0);s(l,t),n&&f.push(...n)};!i&&r.mixins.length&&r.mixins.forEach(t),e.extends&&t(e.extends),e.mixins&&e.mixins.forEach(t)}if(!c&&!p)return v(e)&&a.set(e,n),n;if(d(c))for(let e=0;e<c.length;e++){let n=D(c[e]);qi(n)&&(l[n]=t)}else if(c)for(let e in c){let t=D(e);if(qi(t)){let n=c[e],r=l[t]=d(n)||h(n)?{type:n}:s({},n),i=r.type,a=!1,o=!0;if(d(i))for(let e=0;e<i.length;++e){let t=i[e],n=h(t)&&t.name;if(n===`Boolean`){a=!0;break}else n===`String`&&(o=!1)}else a=h(i)&&i.name===`Boolean`;r[0]=a,r[1]=o,(a||u(r,`default`))&&f.push(t)}}let m=[l,f];return v(e)&&a.set(e,m),m}function qi(e){return e[0]!==`$`&&!T(e)}var Ji=e=>e===`_`||e===`_ctx`||e===`$stable`,Yi=e=>d(e)?e.map(Na):[Na(e)],Xi=(e,t,n)=>{if(t._n)return t;let r=Ln((...e)=>Yi(t(...e)),n);return r._c=!1,r},Zi=(e,t,n)=>{let r=e._ctx;for(let n in e){if(Ji(n))continue;let i=e[n];if(h(i))t[n]=Xi(n,i,r);else if(i!=null){let e=Yi(i);t[n]=()=>e}}},Qi=(e,t)=>{let n=Yi(t);e.slots.default=()=>n},$i=(e,t,n)=>{for(let r in t)(n||!Ji(r))&&(e[r]=t[r])},ea=(e,t,n)=>{let r=e.slots=zi();if(e.vnode.shapeFlag&32){let e=t._;e?($i(r,t,n),n&&j(r,`_`,e,!0)):Zi(t,r)}else t&&Qi(e,t)},ta=(e,n,r)=>{let{vnode:i,slots:a}=e,o=!0,s=t;if(i.shapeFlag&32){let e=n._;e?r&&e===1?o=!1:$i(a,n,r):(o=!n.$stable,Zi(n,a)),s=n}else n&&(Qi(e,n),s={default:1});if(o)for(let e in a)!Ji(e)&&s[e]==null&&delete a[e]},na=ma;function ra(e){return ia(e)}function ia(e,i){let a=se();a.__VUE__=!0;let{insert:o,remove:s,patchProp:c,createElement:l,createText:u,createComment:d,setText:f,setElementText:p,parentNode:m,nextSibling:h,setScopeId:g=r,insertStaticContent:_}=e,v=(e,t,n,r=null,i=null,a=null,o=void 0,s=null,c=!!t.dynamicChildren)=>{if(e===t)return;e&&!Ea(e,t)&&(r=he(e),de(e,i,a,!0),e=null),t.patchFlag===-2&&(c=!1,t.dynamicChildren=null);let{type:l,ref:u,shapeFlag:d}=t;switch(l){case ha:y(e,t,n,r);break;case ga:b(e,t,n,r);break;case _a:e??x(t,n,r,o);break;case B:ne(e,t,n,r,i,a,o,s,c);break;default:d&1?w(e,t,n,r,i,a,o,s,c):d&6?A(e,t,n,r,i,a,o,s,c):(d&64||d&128)&&l.process(e,t,n,r,i,a,o,s,c,ve)}u!=null&&i?Tr(u,e&&e.ref,a,t||e,!t):u==null&&e&&e.ref!=null&&Tr(e.ref,null,a,e,!0)},y=(e,t,n,r)=>{if(e==null)o(t.el=u(t.children),n,r);else{let n=t.el=e.el;t.children!==e.children&&f(n,t.children)}},b=(e,t,n,r)=>{e==null?o(t.el=d(t.children||``),n,r):t.el=e.el},x=(e,t,n,r)=>{[e.el,e.anchor]=_(e.children,t,n,r,e.el,e.anchor)},S=({el:e,anchor:t},n,r)=>{let i;for(;e&&e!==t;)i=h(e),o(e,n,r),e=i;o(t,n,r)},C=({el:e,anchor:t})=>{let n;for(;e&&e!==t;)n=h(e),s(e),e=n;s(t)},w=(e,t,n,r,i,a,o,s,c)=>{if(t.type===`svg`?o=`svg`:t.type===`math`&&(o=`mathml`),e==null)ee(t,n,r,i,a,o,s,c);else{let n=e.el&&e.el._isVueCE?e.el:null;try{n&&n._beginPatch(),O(e,t,i,a,o,s,c)}finally{n&&n._endPatch()}}},ee=(e,t,n,r,i,a,s,u)=>{let d,f,{props:m,shapeFlag:h,transition:g,dirs:_}=e;if(d=e.el=l(e.type,a,m&&m.is,m),h&8?p(d,e.children):h&16&&D(e.children,d,null,r,i,aa(e,a),s,u),_&&zn(e,null,r,`created`),E(d,e,e.scopeId,s,r),m){for(let e in m)e!==`value`&&!T(e)&&c(d,e,null,m[e],a,r);`value`in m&&c(d,`value`,null,m.value,a),(f=m.onVnodeBeforeMount)&&La(f,r,e)}_&&zn(e,null,r,`beforeMount`);let v=sa(i,g);v&&g.beforeEnter(d),o(d,t,n),((f=m&&m.onVnodeMounted)||v||_)&&na(()=>{f&&La(f,r,e),v&&g.enter(d),_&&zn(e,null,r,`mounted`)},i)},E=(e,t,n,r,i)=>{if(n&&g(e,n),r)for(let t=0;t<r.length;t++)g(e,r[t]);if(i){let n=i.subTree;if(t===n||pa(n.type)&&(n.ssContent===t||n.ssFallback===t)){let t=i.vnode;E(e,t,t.scopeId,t.slotScopeIds,i.parent)}}},D=(e,t,n,r,i,a,o,s,c=0)=>{for(let l=c;l<e.length;l++)v(null,e[l]=s?Pa(e[l]):Na(e[l]),t,n,r,i,a,o,s)},O=(e,n,r,i,a,o,s)=>{let l=n.el=e.el,{patchFlag:u,dynamicChildren:d,dirs:f}=n;u|=e.patchFlag&16;let m=e.props||t,h=n.props||t,g;if(r&&oa(r,!1),(g=h.onVnodeBeforeUpdate)&&La(g,r,n,e),f&&zn(n,e,r,`beforeUpdate`),r&&oa(r,!0),(m.innerHTML&&h.innerHTML==null||m.textContent&&h.textContent==null)&&p(l,``),d?k(e.dynamicChildren,d,l,r,i,aa(n,a),o):s||M(e,n,l,null,r,i,aa(n,a),o,!1),u>0){if(u&16)te(l,m,h,r,a);else if(u&2&&m.class!==h.class&&c(l,`class`,null,h.class,a),u&4&&c(l,`style`,m.style,h.style,a),u&8){let e=n.dynamicProps;for(let t=0;t<e.length;t++){let n=e[t],i=m[n],o=h[n];(o!==i||n===`value`)&&c(l,n,i,o,a,r)}}u&1&&e.children!==n.children&&p(l,n.children)}else !s&&d==null&&te(l,m,h,r,a);((g=h.onVnodeUpdated)||f)&&na(()=>{g&&La(g,r,n,e),f&&zn(n,e,r,`updated`)},i)},k=(e,t,n,r,i,a,o)=>{for(let s=0;s<t.length;s++){let c=e[s],l=t[s];v(c,l,c.el&&(c.type===B||!Ea(c,l)||c.shapeFlag&198)?m(c.el):n,null,r,i,a,o,!0)}},te=(e,n,r,i,a)=>{if(n!==r){if(n!==t)for(let t in n)!T(t)&&!(t in r)&&c(e,t,n[t],null,a,i);for(let t in r){if(T(t))continue;let o=r[t],s=n[t];o!==s&&t!==`value`&&c(e,t,s,o,a,i)}`value`in r&&c(e,`value`,n.value,r.value,a)}},ne=(e,t,n,r,i,a,s,c,l)=>{let d=t.el=e?e.el:u(``),f=t.anchor=e?e.anchor:u(``),{patchFlag:p,dynamicChildren:m,slotScopeIds:h}=t;h&&(c=c?c.concat(h):h),e==null?(o(d,n,r),o(f,n,r),D(t.children||[],n,f,i,a,s,c,l)):p>0&&p&64&&m&&e.dynamicChildren&&e.dynamicChildren.length===m.length?(k(e.dynamicChildren,m,n,i,a,s,c),(t.key!=null||i&&t===i.subTree)&&ca(e,t,!0)):M(e,t,n,f,i,a,s,c,l)},A=(e,t,n,r,i,a,o,s,c)=>{t.slotScopeIds=s,e==null?t.shapeFlag&512?i.ctx.activate(t,n,r,o,c):j(t,n,r,i,a,o,c):ie(e,t,c)},j=(e,t,n,r,i,a,o)=>{let s=e.component=Ba(e,r,i);if(Or(e)&&(s.ctx.renderer=ve),Ya(s,!1,o),s.asyncDep){if(i&&i.registerDep(s,ae,o),!e.el){let r=s.subTree=W(ga);b(null,r,t,n),e.placeholder=r.el}}else ae(s,e,t,n,i,a,o)},ie=(e,t,n)=>{let r=t.component=e.component;if(Pi(e,t,n))if(r.asyncDep&&!r.asyncResolved){oe(r,t,n);return}else r.next=t,r.update();else t.el=e.el,r.vnode=t},ae=(e,t,n,r,i,a,o)=>{let s=()=>{if(e.isMounted){let{next:t,bu:n,u:r,parent:s,vnode:c}=e;{let n=ua(e);if(n){t&&(t.el=c.el,oe(e,t,o)),n.asyncDep.then(()=>{na(()=>{e.isUnmounted||l()},i)});return}}let u=t,d;oa(e,!1),t?(t.el=c.el,oe(e,t,o)):t=c,n&&re(n),(d=t.props&&t.props.onVnodeBeforeUpdate)&&La(d,s,t,c),oa(e,!0);let f=ji(e),p=e.subTree;e.subTree=f,v(p,f,m(p.el),he(p),e,i,a),t.el=f.el,u===null&&Li(e,f.el),r&&na(r,i),(d=t.props&&t.props.onVnodeUpdated)&&na(()=>La(d,s,t,c),i)}else{let o,{el:s,props:c}=t,{bm:l,m:u,parent:d,root:f,type:p}=e,m=Dr(t);if(oa(e,!1),l&&re(l),!m&&(o=c&&c.onVnodeBeforeMount)&&La(o,d,t),oa(e,!0),s&&ye){let t=()=>{e.subTree=ji(e),ye(s,e.subTree,e,i,null)};m&&p.__asyncHydrate?p.__asyncHydrate(s,e,t):t()}else{f.ce&&f.ce._hasShadowRoot()&&f.ce._injectChildStyle(p);let o=e.subTree=ji(e);v(null,o,n,r,e,i,a),t.el=o.el}if(u&&na(u,i),!m&&(o=c&&c.onVnodeMounted)){let e=t;na(()=>La(o,d,e),i)}(t.shapeFlag&256||d&&Dr(d.vnode)&&d.vnode.shapeFlag&256)&&e.a&&na(e.a,i),e.isMounted=!0,t=n=r=null}};e.scope.on();let c=e.effect=new De(s);e.scope.off();let l=e.update=c.run.bind(c),u=e.job=c.runIfDirty.bind(c);u.i=e,u.id=e.uid,c.scheduler=()=>Dn(u),oa(e,!0),l()},oe=(e,t,n)=>{t.component=e;let r=e.vnode.props;e.vnode=t,e.next=null,Hi(e,t.props,r,n),ta(e,t.children,n),He(),An(e),Ue()},M=(e,t,n,r,i,a,o,s,c=!1)=>{let l=e&&e.children,u=e?e.shapeFlag:0,d=t.children,{patchFlag:f,shapeFlag:m}=t;if(f>0){if(f&128){le(l,d,n,r,i,a,o,s,c);return}else if(f&256){ce(l,d,n,r,i,a,o,s,c);return}}m&8?(u&16&&me(l,i,a),d!==l&&p(n,d)):u&16?m&16?le(l,d,n,r,i,a,o,s,c):me(l,i,a,!0):(u&8&&p(n,``),m&16&&D(d,n,r,i,a,o,s,c))},ce=(e,t,r,i,a,o,s,c,l)=>{e||=n,t||=n;let u=e.length,d=t.length,f=Math.min(u,d),p;for(p=0;p<f;p++){let n=t[p]=l?Pa(t[p]):Na(t[p]);v(e[p],n,r,null,a,o,s,c,l)}u>d?me(e,a,o,!0,!1,f):D(t,r,i,a,o,s,c,l,f)},le=(e,t,r,i,a,o,s,c,l)=>{let u=0,d=t.length,f=e.length-1,p=d-1;for(;u<=f&&u<=p;){let n=e[u],i=t[u]=l?Pa(t[u]):Na(t[u]);if(Ea(n,i))v(n,i,r,null,a,o,s,c,l);else break;u++}for(;u<=f&&u<=p;){let n=e[f],i=t[p]=l?Pa(t[p]):Na(t[p]);if(Ea(n,i))v(n,i,r,null,a,o,s,c,l);else break;f--,p--}if(u>f){if(u<=p){let e=p+1,n=e<d?t[e].el:i;for(;u<=p;)v(null,t[u]=l?Pa(t[u]):Na(t[u]),r,n,a,o,s,c,l),u++}}else if(u>p)for(;u<=f;)de(e[u],a,o,!0),u++;else{let m=u,h=u,g=new Map;for(u=h;u<=p;u++){let e=t[u]=l?Pa(t[u]):Na(t[u]);e.key!=null&&g.set(e.key,u)}let _,y=0,b=p-h+1,x=!1,S=0,C=Array(b);for(u=0;u<b;u++)C[u]=0;for(u=m;u<=f;u++){let n=e[u];if(y>=b){de(n,a,o,!0);continue}let i;if(n.key!=null)i=g.get(n.key);else for(_=h;_<=p;_++)if(C[_-h]===0&&Ea(n,t[_])){i=_;break}i===void 0?de(n,a,o,!0):(C[i-h]=u+1,i>=S?S=i:x=!0,v(n,t[i],r,null,a,o,s,c,l),y++)}let w=x?la(C):n;for(_=w.length-1,u=b-1;u>=0;u--){let e=h+u,n=t[e],f=t[e+1],p=e+1<d?f.el||fa(f):i;C[u]===0?v(null,n,r,p,a,o,s,c,l):x&&(_<0||u!==w[_]?ue(n,r,p,2):_--)}}},ue=(e,t,n,r,i=null)=>{let{el:a,type:c,transition:l,children:u,shapeFlag:d}=e;if(d&6){ue(e.component.subTree,t,n,r);return}if(d&128){e.suspense.move(t,n,r);return}if(d&64){c.move(e,t,n,ve);return}if(c===B){o(a,t,n);for(let e=0;e<u.length;e++)ue(u[e],t,n,r);o(e.anchor,t,n);return}if(c===_a){S(e,t,n);return}if(r!==2&&d&1&&l)if(r===0)l.beforeEnter(a),o(a,t,n),na(()=>l.enter(a),i);else{let{leave:r,delayLeave:i,afterLeave:c}=l,u=()=>{e.ctx.isUnmounted?s(a):o(a,t,n)},d=()=>{a._isLeaving&&a[sr](!0),r(a,()=>{u(),c&&c()})};i?i(a,u,d):d()}else o(a,t,n)},de=(e,t,n,r=!1,i=!1)=>{let{type:a,props:o,ref:s,children:c,dynamicChildren:l,shapeFlag:u,patchFlag:d,dirs:f,cacheIndex:p}=e;if(d===-2&&(i=!1),s!=null&&(He(),Tr(s,null,n,e,!0),Ue()),p!=null&&(t.renderCache[p]=void 0),u&256){t.ctx.deactivate(e);return}let m=u&1&&f,h=!Dr(e),g;if(h&&(g=o&&o.onVnodeBeforeUnmount)&&La(g,t,e),u&6)pe(e.component,n,r);else{if(u&128){e.suspense.unmount(n,r);return}m&&zn(e,null,t,`beforeUnmount`),u&64?e.type.remove(e,t,n,ve,r):l&&!l.hasOnce&&(a!==B||d>0&&d&64)?me(l,t,n,!1,!0):(a===B&&d&384||!i&&u&16)&&me(c,t,n),r&&N(e)}(h&&(g=o&&o.onVnodeUnmounted)||m)&&na(()=>{g&&La(g,t,e),m&&zn(e,null,t,`unmounted`)},n)},N=e=>{let{type:t,el:n,anchor:r,transition:i}=e;if(t===B){fe(n,r);return}if(t===_a){C(e);return}let a=()=>{s(n),i&&!i.persisted&&i.afterLeave&&i.afterLeave()};if(e.shapeFlag&1&&i&&!i.persisted){let{leave:t,delayLeave:r}=i,o=()=>t(n,a);r?r(e.el,a,o):o()}else a()},fe=(e,t)=>{let n;for(;e!==t;)n=h(e),s(e),e=n;s(t)},pe=(e,t,n)=>{let{bum:r,scope:i,job:a,subTree:o,um:s,m:c,a:l}=e;da(c),da(l),r&&re(r),i.stop(),a&&(a.flags|=8,de(o,e,t,n)),s&&na(s,t),na(()=>{e.isUnmounted=!0},t)},me=(e,t,n,r=!1,i=!1,a=0)=>{for(let o=a;o<e.length;o++)de(e[o],t,n,r,i)},he=e=>{if(e.shapeFlag&6)return he(e.component.subTree);if(e.shapeFlag&128)return e.suspense.next();let t=h(e.anchor||e.el),n=t&&t[Jn];return n?h(n):t},ge=!1,_e=(e,t,n)=>{let r;e==null?t._vnode&&(de(t._vnode,null,null,!0),r=t._vnode.component):v(t._vnode||null,e,t,null,null,null,n),t._vnode=e,ge||=(ge=!0,An(r),jn(),!1)},ve={p:v,um:de,m:ue,r:N,mt:j,mc:D,pc:M,pbc:k,n:he,o:e},P,ye;return i&&([P,ye]=i(ve)),{render:_e,hydrate:P,createApp:Ci(_e,P)}}function aa({type:e,props:t},n){return n===`svg`&&e===`foreignObject`||n===`mathml`&&e===`annotation-xml`&&t&&t.encoding&&t.encoding.includes(`html`)?void 0:n}function oa({effect:e,job:t},n){n?(e.flags|=32,t.flags|=4):(e.flags&=-33,t.flags&=-5)}function sa(e,t){return(!e||e&&!e.pendingBranch)&&t&&!t.persisted}function ca(e,t,n=!1){let r=e.children,i=t.children;if(d(r)&&d(i))for(let e=0;e<r.length;e++){let t=r[e],a=i[e];a.shapeFlag&1&&!a.dynamicChildren&&((a.patchFlag<=0||a.patchFlag===32)&&(a=i[e]=Pa(i[e]),a.el=t.el),!n&&a.patchFlag!==-2&&ca(t,a)),a.type===ha&&(a.patchFlag===-1&&(a=i[e]=Pa(a)),a.el=t.el),a.type===ga&&!a.el&&(a.el=t.el)}}function la(e){let t=e.slice(),n=[0],r,i,a,o,s,c=e.length;for(r=0;r<c;r++){let c=e[r];if(c!==0){if(i=n[n.length-1],e[i]<c){t[r]=i,n.push(r);continue}for(a=0,o=n.length-1;a<o;)s=a+o>>1,e[n[s]]<c?a=s+1:o=s;c<e[n[a]]&&(a>0&&(t[r]=n[a-1]),n[a]=r)}}for(a=n.length,o=n[a-1];a-- >0;)n[a]=o,o=t[o];return n}function ua(e){let t=e.subTree.component;if(t)return t.asyncDep&&!t.asyncResolved?t:ua(t)}function da(e){if(e)for(let t=0;t<e.length;t++)e[t].flags|=8}function fa(e){if(e.placeholder)return e.placeholder;let t=e.component;return t?fa(t.subTree):null}var pa=e=>e.__isSuspense;function ma(e,t){t&&t.pendingBranch?d(e)?t.effects.push(...e):t.effects.push(e):kn(e)}var B=Symbol.for(`v-fgt`),ha=Symbol.for(`v-txt`),ga=Symbol.for(`v-cmt`),_a=Symbol.for(`v-stc`),va=[],ya=null;function V(e=!1){va.push(ya=e?null:[])}function ba(){va.pop(),ya=va[va.length-1]||null}var xa=1;function Sa(e,t=!1){xa+=e,e<0&&ya&&t&&(ya.hasOnce=!0)}function Ca(e){return e.dynamicChildren=xa>0?ya||n:null,ba(),xa>0&&ya&&ya.push(e),e}function H(e,t,n,r,i,a){return Ca(U(e,t,n,r,i,a,!0))}function wa(e,t,n,r,i){return Ca(W(e,t,n,r,i,!0))}function Ta(e){return e?e.__v_isVNode===!0:!1}function Ea(e,t){return e.type===t.type&&e.key===t.key}var Da=({key:e})=>e??null,Oa=({ref:e,ref_key:t,ref_for:n})=>(typeof e==`number`&&(e=``+e),e==null?null:g(e)||Jt(e)||h(e)?{i:Pn,r:e,k:t,f:!!n}:e);function U(e,t=null,n=null,r=0,i=null,a=e===B?0:1,o=!1,s=!1){let c={__v_isVNode:!0,__v_skip:!0,type:e,props:t,key:t&&Da(t),ref:t&&Oa(t),scopeId:Fn,slotScopeIds:null,children:n,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:a,patchFlag:r,dynamicProps:i,dynamicChildren:null,appContext:null,ctx:Pn};return s?(Fa(c,n),a&128&&e.normalize(c)):n&&(c.shapeFlag|=g(n)?8:16),xa>0&&!o&&ya&&(c.patchFlag>0||a&6)&&c.patchFlag!==32&&ya.push(c),c}var W=ka;function ka(e,t=null,n=null,r=0,i=null,a=!1){if((!e||e===qr)&&(e=ga),Ta(e)){let r=ja(e,t,!0);return n&&Fa(r,n),xa>0&&!a&&ya&&(r.shapeFlag&6?ya[ya.indexOf(e)]=r:ya.push(r)),r.patchFlag=-2,r}if(ao(e)&&(e=e.__vccOpts),t){t=Aa(t);let{class:e,style:n}=t;e&&!g(e)&&(t.class=N(e)),v(n)&&(Ut(n)&&!d(n)&&(n=s({},n)),t.style=M(n))}let o=g(e)?1:pa(e)?128:Yn(e)?64:v(e)?4:h(e)?2:0;return U(e,t,n,r,i,o,a,!0)}function Aa(e){return e?Ut(e)||Bi(e)?s({},e):e:null}function ja(e,t,n=!1,r=!1){let{props:i,ref:a,patchFlag:o,children:s,transition:c}=e,l=t?Ia(i||{},t):i,u={__v_isVNode:!0,__v_skip:!0,type:e.type,props:l,key:l&&Da(l),ref:t&&t.ref?n&&a?d(a)?a.concat(Oa(t)):[a,Oa(t)]:Oa(t):a,scopeId:e.scopeId,slotScopeIds:e.slotScopeIds,children:s,target:e.target,targetStart:e.targetStart,targetAnchor:e.targetAnchor,staticCount:e.staticCount,shapeFlag:e.shapeFlag,patchFlag:t&&e.type!==B?o===-1?16:o|16:o,dynamicProps:e.dynamicProps,dynamicChildren:e.dynamicChildren,appContext:e.appContext,dirs:e.dirs,transition:c,component:e.component,suspense:e.suspense,ssContent:e.ssContent&&ja(e.ssContent),ssFallback:e.ssFallback&&ja(e.ssFallback),placeholder:e.placeholder,el:e.el,anchor:e.anchor,ctx:e.ctx,ce:e.ce};return c&&r&&br(u,c.clone(u)),u}function G(e=` `,t=0){return W(ha,null,e,t)}function Ma(e,t){let n=W(_a,null,e);return n.staticCount=t,n}function K(e=``,t=!1){return t?(V(),wa(ga,null,e)):W(ga,null,e)}function Na(e){return e==null||typeof e==`boolean`?W(ga):d(e)?W(B,null,e.slice()):Ta(e)?Pa(e):W(ha,null,String(e))}function Pa(e){return e.el===null&&e.patchFlag!==-1||e.memo?e:ja(e)}function Fa(e,t){let n=0,{shapeFlag:r}=e;if(t==null)t=null;else if(d(t))n=16;else if(typeof t==`object`)if(r&65){let n=t.default;n&&(n._c&&(n._d=!1),Fa(e,n()),n._c&&(n._d=!0));return}else{n=32;let r=t._;!r&&!Bi(t)?t._ctx=Pn:r===3&&Pn&&(Pn.slots._===1?t._=1:(t._=2,e.patchFlag|=1024))}else h(t)?(t={default:t,_ctx:Pn},n=32):(t=String(t),r&64?(n=16,t=[G(t)]):n=8);e.children=t,e.shapeFlag|=n}function Ia(...e){let t={};for(let n=0;n<e.length;n++){let r=e[n];for(let e in r)if(e===`class`)t.class!==r.class&&(t.class=N([t.class,r.class]));else if(e===`style`)t.style=M([t.style,r.style]);else if(a(e)){let n=t[e],i=r[e];i&&n!==i&&!(d(n)&&n.includes(i))&&(t[e]=n?[].concat(n,i):i)}else e!==``&&(t[e]=r[e])}return t}function La(e,t,n,r=null){hn(e,t,7,[n,r])}var Ra=xi(),za=0;function Ba(e,n,r){let i=e.type,a=(n?n.appContext:e.appContext)||Ra,o={uid:za++,vnode:e,type:i,parent:n,appContext:a,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new Se(!0),render:null,proxy:null,exposed:null,exposeProxy:null,withProxy:null,provides:n?n.provides:Object.create(a.provides),ids:n?n.ids:[``,0,0],accessCache:null,renderCache:[],components:null,directives:null,propsOptions:Ki(i,a),emitsOptions:ki(i,a),emit:null,emitted:null,propsDefaults:t,inheritAttrs:i.inheritAttrs,ctx:t,data:t,props:t,attrs:t,slots:t,refs:t,setupState:t,setupContext:null,suspense:r,suspenseId:r?r.pendingId:0,asyncDep:null,asyncResolved:!1,isMounted:!1,isUnmounted:!1,isDeactivated:!1,bc:null,c:null,bm:null,m:null,bu:null,u:null,um:null,bum:null,da:null,a:null,rtg:null,rtc:null,ec:null,sp:null};return o.ctx={_:o},o.root=n?n.root:o,o.emit=Di.bind(null,o),e.ce&&e.ce(o),o}var Va=null,Ha=()=>Va||Pn,Ua,Wa;{let e=se(),t=(t,n)=>{let r;return(r=e[t])||(r=e[t]=[]),r.push(n),e=>{r.length>1?r.forEach(t=>t(e)):r[0](e)}};Ua=t(`__VUE_INSTANCE_SETTERS__`,e=>Va=e),Wa=t(`__VUE_SSR_SETTERS__`,e=>Ja=e)}var Ga=e=>{let t=Va;return Ua(e),e.scope.on(),()=>{e.scope.off(),Ua(t)}},Ka=()=>{Va&&Va.scope.off(),Ua(null)};function qa(e){return e.vnode.shapeFlag&4}var Ja=!1;function Ya(e,t=!1,n=!1){t&&Wa(t);let{props:r,children:i}=e.vnode,a=qa(e);Vi(e,r,a,t),ea(e,i,n||t);let o=a?Xa(e,t):void 0;return t&&Wa(!1),o}function Xa(e,t){let n=e.type;e.accessCache=Object.create(null),e.proxy=new Proxy(e.ctx,ri);let{setup:r}=n;if(r){He();let n=e.setupContext=r.length>1?no(e):null,i=Ga(e),a=mn(r,e,0,[e.props,n]),o=y(a);if(Ue(),i(),(o||e.sp)&&!Dr(e)&&Sr(e),o){if(a.then(Ka,Ka),t)return a.then(n=>{Za(e,n,t)}).catch(t=>{gn(t,e,0)});e.asyncDep=a}else Za(e,a,t)}else eo(e,t)}function Za(e,t,n){h(t)?e.type.__ssrInlineRender?e.ssrRender=t:e.render=t:v(t)&&(e.setupState=Qt(t)),eo(e,n)}var Qa,$a;function eo(e,t,n){let i=e.type;if(!e.render){if(!t&&Qa&&!i.render){let t=i.template||di(e).template;if(t){let{isCustomElement:n,compilerOptions:r}=e.appContext.config,{delimiters:a,compilerOptions:o}=i;i.render=Qa(t,s(s({isCustomElement:n,delimiters:a},r),o))}}e.render=i.render||r,$a&&$a(e)}{let t=Ga(e);He();try{si(e)}finally{Ue(),t()}}}var to={get(e,t){return $e(e,`get`,``),e[t]}};function no(e){return{attrs:new Proxy(e.attrs,to),slots:e.slots,emit:e.emit,expose:t=>{e.exposed=t||{}}}}function ro(e){return e.exposed?e.exposeProxy||=new Proxy(Qt(Gt(e.exposed)),{get(t,n){if(n in t)return t[n];if(n in ti)return ti[n](e)},has(e,t){return t in e||t in ti}}):e.proxy}function io(e,t=!0){return h(e)?e.displayName||e.name:e.name||t&&e.__name}function ao(e){return h(e)&&`__vccOpts`in e}var q=(e,t)=>sn(e,t,Ja);function oo(e,t,n){try{Sa(-1);let r=arguments.length;return r===2?v(t)&&!d(t)?Ta(t)?W(e,null,[t]):W(e,t):W(e,null,t):(r>3?n=Array.prototype.slice.call(arguments,2):r===3&&Ta(n)&&(n=[n]),W(e,t,n))}finally{Sa(1)}}var so=`3.5.29`,co=void 0,lo=typeof window<`u`&&window.trustedTypes;if(lo)try{co=lo.createPolicy(`vue`,{createHTML:e=>e})}catch{}var uo=co?e=>co.createHTML(e):e=>e,fo=`http://www.w3.org/2000/svg`,po=`http://www.w3.org/1998/Math/MathML`,mo=typeof document<`u`?document:null,ho=mo&&mo.createElement(`template`),go={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{let t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,r)=>{let i=t===`svg`?mo.createElementNS(fo,e):t===`mathml`?mo.createElementNS(po,e):n?mo.createElement(e,{is:n}):mo.createElement(e);return e===`select`&&r&&r.multiple!=null&&i.setAttribute(`multiple`,r.multiple),i},createText:e=>mo.createTextNode(e),createComment:e=>mo.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>mo.querySelector(e),setScopeId(e,t){e.setAttribute(t,``)},insertStaticContent(e,t,n,r,i,a){let o=n?n.previousSibling:t.lastChild;if(i&&(i===a||i.nextSibling))for(;t.insertBefore(i.cloneNode(!0),n),!(i===a||!(i=i.nextSibling)););else{ho.innerHTML=uo(r===`svg`?`<svg>${e}</svg>`:r===`mathml`?`<math>${e}</math>`:e);let i=ho.content;if(r===`svg`||r===`mathml`){let e=i.firstChild;for(;e.firstChild;)i.appendChild(e.firstChild);i.removeChild(e)}t.insertBefore(i,n)}return[o?o.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},_o=`transition`,vo=`animation`,yo=Symbol(`_vtc`),bo={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String},xo=s({},dr,bo),So=(e=>(e.displayName=`Transition`,e.props=xo,e))((e,{slots:t})=>oo(hr,To(e),t)),Co=(e,t=[])=>{d(e)?e.forEach(e=>e(...t)):e&&e(...t)},wo=e=>e?d(e)?e.some(e=>e.length>1):e.length>1:!1;function To(e){let t={};for(let n in e)n in bo||(t[n]=e[n]);if(e.css===!1)return t;let{name:n=`v`,type:r,duration:i,enterFromClass:a=`${n}-enter-from`,enterActiveClass:o=`${n}-enter-active`,enterToClass:c=`${n}-enter-to`,appearFromClass:l=a,appearActiveClass:u=o,appearToClass:d=c,leaveFromClass:f=`${n}-leave-from`,leaveActiveClass:p=`${n}-leave-active`,leaveToClass:m=`${n}-leave-to`}=e,h=Eo(i),g=h&&h[0],_=h&&h[1],{onBeforeEnter:v,onEnter:y,onEnterCancelled:b,onLeave:x,onLeaveCancelled:S,onBeforeAppear:C=v,onAppear:w=y,onAppearCancelled:T=b}=t,ee=(e,t,n,r)=>{e._enterCancelled=r,ko(e,t?d:c),ko(e,t?u:o),n&&n()},E=(e,t)=>{e._isLeaving=!1,ko(e,f),ko(e,m),ko(e,p),t&&t()},D=e=>(t,n)=>{let i=e?w:y,o=()=>ee(t,e,n);Co(i,[t,o]),Ao(()=>{ko(t,e?l:a),Oo(t,e?d:c),wo(i)||Mo(t,r,g,o)})};return s(t,{onBeforeEnter(e){Co(v,[e]),Oo(e,a),Oo(e,o)},onBeforeAppear(e){Co(C,[e]),Oo(e,l),Oo(e,u)},onEnter:D(!1),onAppear:D(!0),onLeave(e,t){e._isLeaving=!0;let n=()=>E(e,t);Oo(e,f),e._enterCancelled?(Oo(e,p),Io(e)):(Io(e),Oo(e,p)),Ao(()=>{e._isLeaving&&(ko(e,f),Oo(e,m),wo(x)||Mo(e,r,_,n))}),Co(x,[e,n])},onEnterCancelled(e){ee(e,!1,void 0,!0),Co(b,[e])},onAppearCancelled(e){ee(e,!0,void 0,!0),Co(T,[e])},onLeaveCancelled(e){E(e),Co(S,[e])}})}function Eo(e){if(e==null)return null;if(v(e))return[Do(e.enter),Do(e.leave)];{let t=Do(e);return[t,t]}}function Do(e){return ae(e)}function Oo(e,t){t.split(/\s+/).forEach(t=>t&&e.classList.add(t)),(e[yo]||(e[yo]=new Set)).add(t)}function ko(e,t){t.split(/\s+/).forEach(t=>t&&e.classList.remove(t));let n=e[yo];n&&(n.delete(t),n.size||(e[yo]=void 0))}function Ao(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}var jo=0;function Mo(e,t,n,r){let i=e._endId=++jo,a=()=>{i===e._endId&&r()};if(n!=null)return setTimeout(a,n);let{type:o,timeout:s,propCount:c}=No(e,t);if(!o)return r();let l=o+`end`,u=0,d=()=>{e.removeEventListener(l,f),a()},f=t=>{t.target===e&&++u>=c&&d()};setTimeout(()=>{u<c&&d()},s+1),e.addEventListener(l,f)}function No(e,t){let n=window.getComputedStyle(e),r=e=>(n[e]||``).split(`, `),i=r(`${_o}Delay`),a=r(`${_o}Duration`),o=Po(i,a),s=r(`${vo}Delay`),c=r(`${vo}Duration`),l=Po(s,c),u=null,d=0,f=0;t===_o?o>0&&(u=_o,d=o,f=a.length):t===vo?l>0&&(u=vo,d=l,f=c.length):(d=Math.max(o,l),u=d>0?o>l?_o:vo:null,f=u?u===_o?a.length:c.length:0);let p=u===_o&&/\b(?:transform|all)(?:,|$)/.test(r(`${_o}Property`).toString());return{type:u,timeout:d,propCount:f,hasTransform:p}}function Po(e,t){for(;e.length<t.length;)e=e.concat(e);return Math.max(...t.map((t,n)=>Fo(t)+Fo(e[n])))}function Fo(e){return e===`auto`?0:Number(e.slice(0,-1).replace(`,`,`.`))*1e3}function Io(e){return(e?e.ownerDocument:document).body.offsetHeight}function Lo(e,t,n){let r=e[yo];r&&(t=(t?[t,...r]:[...r]).join(` `)),t==null?e.removeAttribute(`class`):n?e.setAttribute(`class`,t):e.className=t}var Ro=Symbol(`_vod`),zo=Symbol(`_vsh`),Bo={name:`show`,beforeMount(e,{value:t},{transition:n}){e[Ro]=e.style.display===`none`?``:e.style.display,n&&t?n.beforeEnter(e):Vo(e,t)},mounted(e,{value:t},{transition:n}){n&&t&&n.enter(e)},updated(e,{value:t,oldValue:n},{transition:r}){!t!=!n&&(r?t?(r.beforeEnter(e),Vo(e,!0),r.enter(e)):r.leave(e,()=>{Vo(e,!1)}):Vo(e,t))},beforeUnmount(e,{value:t}){Vo(e,t)}};function Vo(e,t){e.style.display=t?e[Ro]:`none`,e[zo]=!t}var Ho=Symbol(``),Uo=/(?:^|;)\s*display\s*:/;function Wo(e,t,n){let r=e.style,i=g(n),a=!1;if(n&&!i){if(t)if(g(t))for(let e of t.split(`;`)){let t=e.slice(0,e.indexOf(`:`)).trim();n[t]??Ko(r,t,``)}else for(let e in t)n[e]??Ko(r,e,``);for(let e in n)e===`display`&&(a=!0),Ko(r,e,n[e])}else if(i){if(t!==n){let e=r[Ho];e&&(n+=`;`+e),r.cssText=n,a=Uo.test(n)}}else t&&e.removeAttribute(`style`);Ro in e&&(e[Ro]=a?r.display:``,e[zo]&&(r.display=`none`))}var Go=/\s*!important$/;function Ko(e,t,n){if(d(n))n.forEach(n=>Ko(e,t,n));else if(n??=``,t.startsWith(`--`))e.setProperty(t,n);else{let r=Yo(e,t);Go.test(n)?e.setProperty(k(r),n.replace(Go,``),`important`):e[r]=n}}var qo=[`Webkit`,`Moz`,`ms`],Jo={};function Yo(e,t){let n=Jo[t];if(n)return n;let r=D(t);if(r!==`filter`&&r in e)return Jo[t]=r;r=te(r);for(let n=0;n<qo.length;n++){let i=qo[n]+r;if(i in e)return Jo[t]=i}return t}var Xo=`http://www.w3.org/1999/xlink`;function Zo(e,t,n,r,i,a=pe(t)){r&&t.startsWith(`xlink:`)?n==null?e.removeAttributeNS(Xo,t.slice(6,t.length)):e.setAttributeNS(Xo,t,n):n==null||a&&!me(n)?e.removeAttribute(t):e.setAttribute(t,a?``:_(n)?String(n):n)}function Qo(e,t,n,r,i){if(t===`innerHTML`||t===`textContent`){n!=null&&(e[t]=t===`innerHTML`?uo(n):n);return}let a=e.tagName;if(t===`value`&&a!==`PROGRESS`&&!a.includes(`-`)){let r=a===`OPTION`?e.getAttribute(`value`)||``:e.value,i=n==null?e.type===`checkbox`?`on`:``:String(n);(r!==i||!(`_value`in e))&&(e.value=i),n??e.removeAttribute(t),e._value=n;return}let o=!1;if(n===``||n==null){let r=typeof e[t];r===`boolean`?n=me(n):n==null&&r===`string`?(n=``,o=!0):r===`number`&&(n=0,o=!0)}try{e[t]=n}catch{}o&&e.removeAttribute(i||t)}function $o(e,t,n,r){e.addEventListener(t,n,r)}function es(e,t,n,r){e.removeEventListener(t,n,r)}var ts=Symbol(`_vei`);function ns(e,t,n,r,i=null){let a=e[ts]||(e[ts]={}),o=a[t];if(r&&o)o.value=r;else{let[n,s]=is(t);r?$o(e,n,a[t]=cs(r,i),s):o&&(es(e,n,o,s),a[t]=void 0)}}var rs=/(?:Once|Passive|Capture)$/;function is(e){let t;if(rs.test(e)){t={};let n;for(;n=e.match(rs);)e=e.slice(0,e.length-n[0].length),t[n[0].toLowerCase()]=!0}return[e[2]===`:`?e.slice(3):k(e.slice(2)),t]}var as=0,os=Promise.resolve(),ss=()=>as||=(os.then(()=>as=0),Date.now());function cs(e,t){let n=e=>{if(!e._vts)e._vts=Date.now();else if(e._vts<=n.attached)return;hn(ls(e,n.value),t,5,[e])};return n.value=e,n.attached=ss(),n}function ls(e,t){if(d(t)){let n=e.stopImmediatePropagation;return e.stopImmediatePropagation=()=>{n.call(e),e._stopped=!0},t.map(e=>t=>!t._stopped&&e&&e(t))}else return t}var us=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,ds=(e,t,n,r,i,s)=>{let c=i===`svg`;t===`class`?Lo(e,r,c):t===`style`?Wo(e,n,r):a(t)?o(t)||ns(e,t,n,r,s):(t[0]===`.`?(t=t.slice(1),!0):t[0]===`^`?(t=t.slice(1),!1):fs(e,t,r,c))?(Qo(e,t,r),!e.tagName.includes(`-`)&&(t===`value`||t===`checked`||t===`selected`)&&Zo(e,t,r,c,s,t!==`value`)):e._isVueCE&&(/[A-Z]/.test(t)||!g(r))?Qo(e,D(t),r,s,t):(t===`true-value`?e._trueValue=r:t===`false-value`&&(e._falseValue=r),Zo(e,t,r,c))};function fs(e,t,n,r){if(r)return!!(t===`innerHTML`||t===`textContent`||t in e&&us(t)&&h(n));if(t===`spellcheck`||t===`draggable`||t===`translate`||t===`autocorrect`||t===`sandbox`&&e.tagName===`IFRAME`||t===`form`||t===`list`&&e.tagName===`INPUT`||t===`type`&&e.tagName===`TEXTAREA`)return!1;if(t===`width`||t===`height`){let t=e.tagName;if(t===`IMG`||t===`VIDEO`||t===`CANVAS`||t===`SOURCE`)return!1}return us(t)&&g(n)?!1:t in e}var ps=e=>{let t=e.props[`onUpdate:modelValue`]||!1;return d(t)?e=>re(t,e):t};function ms(e){e.target.composing=!0}function hs(e){let t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event(`input`)))}var gs=Symbol(`_assign`);function _s(e,t,n){return t&&(e=e.trim()),n&&(e=ie(e)),e}var vs={created(e,{modifiers:{lazy:t,trim:n,number:r}},i){e[gs]=ps(i);let a=r||i.props&&i.props.type===`number`;$o(e,t?`change`:`input`,t=>{t.target.composing||e[gs](_s(e.value,n,a))}),(n||a)&&$o(e,`change`,()=>{e.value=_s(e.value,n,a)}),t||($o(e,`compositionstart`,ms),$o(e,`compositionend`,hs),$o(e,`change`,hs))},mounted(e,{value:t}){e.value=t??``},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:a}},o){if(e[gs]=ps(o),e.composing)return;let s=(a||e.type===`number`)&&!/^0\d/.test(e.value)?ie(e.value):e.value,c=t??``;s!==c&&(document.activeElement===e&&e.type!==`range`&&(r&&t===n||i&&e.value.trim()===c)||(e.value=c))}},ys={deep:!0,created(e,{value:t,modifiers:{number:n}},r){let i=p(t);$o(e,`change`,()=>{let t=Array.prototype.filter.call(e.options,e=>e.selected).map(e=>n?ie(xs(e)):xs(e));e[gs](e.multiple?i?new Set(t):t:t[0]),e._assigning=!0,Tn(()=>{e._assigning=!1})}),e[gs]=ps(r)},mounted(e,{value:t}){bs(e,t)},beforeUpdate(e,t,n){e[gs]=ps(n)},updated(e,{value:t}){e._assigning||bs(e,t)}};function bs(e,t){let n=e.multiple,r=d(t);if(!(n&&!r&&!p(t))){for(let i=0,a=e.options.length;i<a;i++){let a=e.options[i],o=xs(a);if(n)if(r){let e=typeof o;e===`string`||e===`number`?a.selected=t.some(e=>String(e)===String(o)):a.selected=_e(t,o)>-1}else a.selected=t.has(o);else if(ge(xs(a),t)){e.selectedIndex!==i&&(e.selectedIndex=i);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function xs(e){return`_value`in e?e._value:e.value}var Ss=[`ctrl`,`shift`,`alt`,`meta`],Cs={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>`button`in e&&e.button!==0,middle:e=>`button`in e&&e.button!==1,right:e=>`button`in e&&e.button!==2,exact:(e,t)=>Ss.some(n=>e[`${n}Key`]&&!t.includes(n))},ws=(e,t)=>{if(!e)return e;let n=e._withMods||={},r=t.join(`.`);return n[r]||(n[r]=((n,...r)=>{for(let e=0;e<t.length;e++){let r=Cs[t[e]];if(r&&r(n,t))return}return e(n,...r)}))},Ts={esc:`escape`,space:` `,up:`arrow-up`,left:`arrow-left`,right:`arrow-right`,down:`arrow-down`,delete:`backspace`},Es=(e,t)=>{let n=e._withKeys||={},r=t.join(`.`);return n[r]||(n[r]=(n=>{if(!(`key`in n))return;let r=k(n.key);if(t.some(e=>e===r||Ts[e]===r))return e(n)}))},Ds=s({patchProp:ds},go),Os;function ks(){return Os||=ra(Ds)}var As=((...e)=>{let t=ks().createApp(...e),{mount:n}=t;return t.mount=e=>{let r=Ms(e);if(!r)return;let i=t._component;!h(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent=``);let a=n(r,!1,js(r));return r instanceof Element&&(r.removeAttribute(`v-cloak`),r.setAttribute(`data-v-app`,``)),a},t});function js(e){if(e instanceof SVGElement)return`svg`;if(typeof MathMLElement==`function`&&e instanceof MathMLElement)return`mathml`}function Ms(e){return g(e)?document.querySelector(e):e}var Ns=/^[a-z0-9]+(-[a-z0-9]+)*$/,Ps=(e,t,n,r=``)=>{let i=e.split(`:`);if(e.slice(0,1)===`@`){if(i.length<2||i.length>3)return null;r=i.shift().slice(1)}if(i.length>3||!i.length)return null;if(i.length>1){let e=i.pop(),n=i.pop(),a={provider:i.length>0?i[0]:r,prefix:n,name:e};return t&&!Fs(a)?null:a}let a=i[0],o=a.split(`-`);if(o.length>1){let e={provider:r,prefix:o.shift(),name:o.join(`-`)};return t&&!Fs(e)?null:e}if(n&&r===``){let e={provider:r,prefix:``,name:a};return t&&!Fs(e,n)?null:e}return null},Fs=(e,t)=>e?!!((t&&e.prefix===``||e.prefix)&&e.name):!1,Is=Object.freeze({left:0,top:0,width:16,height:16}),Ls=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Rs=Object.freeze({...Is,...Ls}),zs=Object.freeze({...Rs,body:``,hidden:!1});function Bs(e,t){let n={};!e.hFlip!=!t.hFlip&&(n.hFlip=!0),!e.vFlip!=!t.vFlip&&(n.vFlip=!0);let r=((e.rotate||0)+(t.rotate||0))%4;return r&&(n.rotate=r),n}function Vs(e,t){let n=Bs(e,t);for(let r in zs)r in Ls?r in e&&!(r in n)&&(n[r]=Ls[r]):r in t?n[r]=t[r]:r in e&&(n[r]=e[r]);return n}function Hs(e,t){let n=e.icons,r=e.aliases||Object.create(null),i=Object.create(null);function a(e){if(n[e])return i[e]=[];if(!(e in i)){i[e]=null;let t=r[e]&&r[e].parent,n=t&&a(t);n&&(i[e]=[t].concat(n))}return i[e]}return Object.keys(n).concat(Object.keys(r)).forEach(a),i}function Us(e,t,n){let r=e.icons,i=e.aliases||Object.create(null),a={};function o(e){a=Vs(r[e]||i[e],a)}return o(t),n.forEach(o),Vs(e,a)}function Ws(e,t){let n=[];if(typeof e!=`object`||typeof e.icons!=`object`)return n;e.not_found instanceof Array&&e.not_found.forEach(e=>{t(e,null),n.push(e)});let r=Hs(e);for(let i in r){let a=r[i];a&&(t(i,Us(e,i,a)),n.push(i))}return n}var Gs={provider:``,aliases:{},not_found:{},...Is};function Ks(e,t){for(let n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function qs(e){if(typeof e!=`object`||!e)return null;let t=e;if(typeof t.prefix!=`string`||!e.icons||typeof e.icons!=`object`||!Ks(e,Gs))return null;let n=t.icons;for(let e in n){let t=n[e];if(!e||typeof t.body!=`string`||!Ks(t,zs))return null}let r=t.aliases||Object.create(null);for(let e in r){let t=r[e],i=t.parent;if(!e||typeof i!=`string`||!n[i]&&!r[i]||!Ks(t,zs))return null}return t}var Js=Object.create(null);function Ys(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function Xs(e,t){let n=Js[e]||(Js[e]=Object.create(null));return n[t]||(n[t]=Ys(e,t))}function Zs(e,t){return qs(t)?Ws(t,(t,n)=>{n?e.icons[t]=n:e.missing.add(t)}):[]}function Qs(e,t,n){try{if(typeof n.body==`string`)return e.icons[t]={...n},!0}catch{}return!1}var $s=!1;function ec(e){return typeof e==`boolean`&&($s=e),$s}function tc(e){let t=typeof e==`string`?Ps(e,!0,$s):e;if(t){let e=Xs(t.provider,t.prefix),n=t.name;return e.icons[n]||(e.missing.has(n)?null:void 0)}}function nc(e,t){let n=Ps(e,!0,$s);if(!n)return!1;let r=Xs(n.provider,n.prefix);return t?Qs(r,n.name,t):(r.missing.add(n.name),!0)}function rc(e,t){if(typeof e!=`object`)return!1;if(typeof t!=`string`&&(t=e.provider||``),$s&&!t&&!e.prefix){let t=!1;return qs(e)&&(e.prefix=``,Ws(e,(e,n)=>{nc(e,n)&&(t=!0)})),t}let n=e.prefix;return Fs({prefix:n,name:`a`})?!!Zs(Xs(t,n),e):!1}var ic=Object.freeze({width:null,height:null}),ac=Object.freeze({...ic,...Ls}),oc=/(-?[0-9.]*[0-9]+[0-9.]*)/g,sc=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function cc(e,t,n){if(t===1)return e;if(n||=100,typeof e==`number`)return Math.ceil(e*t*n)/n;if(typeof e!=`string`)return e;let r=e.split(oc);if(r===null||!r.length)return e;let i=[],a=r.shift(),o=sc.test(a);for(;;){if(o){let e=parseFloat(a);isNaN(e)?i.push(a):i.push(Math.ceil(e*t*n)/n)}else i.push(a);if(a=r.shift(),a===void 0)return i.join(``);o=!o}}function lc(e,t=`defs`){let n=``,r=e.indexOf(`<`+t);for(;r>=0;){let i=e.indexOf(`>`,r),a=e.indexOf(`</`+t);if(i===-1||a===-1)break;let o=e.indexOf(`>`,a);if(o===-1)break;n+=e.slice(i+1,a).trim(),e=e.slice(0,r).trim()+e.slice(o+1)}return{defs:n,content:e}}function uc(e,t){return e?`<defs>`+e+`</defs>`+t:t}function dc(e,t,n){let r=lc(e);return uc(r.defs,t+r.content+n)}var fc=e=>e===`unset`||e===`undefined`||e===`none`;function pc(e,t){let n={...Rs,...e},r={...ac,...t},i={left:n.left,top:n.top,width:n.width,height:n.height},a=n.body;[n,r].forEach(e=>{let t=[],n=e.hFlip,r=e.vFlip,o=e.rotate;n?r?o+=2:(t.push(`translate(`+(i.width+i.left).toString()+` `+(0-i.top).toString()+`)`),t.push(`scale(-1 1)`),i.top=i.left=0):r&&(t.push(`translate(`+(0-i.left).toString()+` `+(i.height+i.top).toString()+`)`),t.push(`scale(1 -1)`),i.top=i.left=0);let s;switch(o<0&&(o-=Math.floor(o/4)*4),o%=4,o){case 1:s=i.height/2+i.top,t.unshift(`rotate(90 `+s.toString()+` `+s.toString()+`)`);break;case 2:t.unshift(`rotate(180 `+(i.width/2+i.left).toString()+` `+(i.height/2+i.top).toString()+`)`);break;case 3:s=i.width/2+i.left,t.unshift(`rotate(-90 `+s.toString()+` `+s.toString()+`)`);break}o%2==1&&(i.left!==i.top&&(s=i.left,i.left=i.top,i.top=s),i.width!==i.height&&(s=i.width,i.width=i.height,i.height=s)),t.length&&(a=dc(a,`<g transform="`+t.join(` `)+`">`,`</g>`))});let o=r.width,s=r.height,c=i.width,l=i.height,u,d;o===null?(d=s===null?`1em`:s===`auto`?l:s,u=cc(d,c/l)):(u=o===`auto`?c:o,d=s===null?cc(u,l/c):s===`auto`?l:s);let f={},p=(e,t)=>{fc(t)||(f[e]=t.toString())};p(`width`,u),p(`height`,d);let m=[i.left,i.top,c,l];return f.viewBox=m.join(` `),{attributes:f,viewBox:m,body:a}}var mc=/\sid="(\S+)"/g,hc=`IconifyId`+Date.now().toString(16)+(Math.random()*16777216|0).toString(16),gc=0;function _c(e,t=hc){let n=[],r;for(;r=mc.exec(e);)n.push(r[1]);if(!n.length)return e;let i=`suffix`+(Math.random()*16777216|Date.now()).toString(16);return n.forEach(n=>{let r=typeof t==`function`?t(n):t+(gc++).toString(),a=n.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);e=e.replace(RegExp(`([#;"])(`+a+`)([")]|\\.[a-z])`,`g`),`$1`+r+i+`$3`)}),e=e.replace(new RegExp(i,`g`),``),e}var vc=Object.create(null);function yc(e,t){vc[e]=t}function bc(e){return vc[e]||vc[``]}function xc(e){let t;if(typeof e.resources==`string`)t=[e.resources];else if(t=e.resources,!(t instanceof Array)||!t.length)return null;return{resources:t,path:e.path||`/`,maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}for(var Sc=Object.create(null),Cc=[`https://api.simplesvg.com`,`https://api.unisvg.com`],wc=[];Cc.length>0;)Cc.length===1||Math.random()>.5?wc.push(Cc.shift()):wc.push(Cc.pop());Sc[``]=xc({resources:[`https://api.iconify.design`].concat(wc)});function Tc(e,t){let n=xc(t);return n===null?!1:(Sc[e]=n,!0)}function Ec(e){return Sc[e]}var Dc=(()=>{let e;try{if(e=fetch,typeof e==`function`)return e}catch{}})();function Oc(e,t){let n=Ec(e);if(!n)return 0;let r;if(!n.maxURL)r=0;else{let e=0;n.resources.forEach(t=>{let n=t;e=Math.max(e,n.length)});let i=t+`.json?icons=`;r=n.maxURL-e-n.path.length-i.length}return r}function kc(e){return e===404}var Ac=(e,t,n)=>{let r=[],i=Oc(e,t),a=`icons`,o={type:a,provider:e,prefix:t,icons:[]},s=0;return n.forEach((n,c)=>{s+=n.length+1,s>=i&&c>0&&(r.push(o),o={type:a,provider:e,prefix:t,icons:[]},s=n.length),o.icons.push(n)}),r.push(o),r};function jc(e){if(typeof e==`string`){let t=Ec(e);if(t)return t.path}return`/`}var Mc={prepare:Ac,send:(e,t,n)=>{if(!Dc){n(`abort`,424);return}let r=jc(t.provider);switch(t.type){case`icons`:{let e=t.prefix,n=t.icons.join(`,`),i=new URLSearchParams({icons:n});r+=e+`.json?`+i.toString();break}case`custom`:{let e=t.uri;r+=e.slice(0,1)===`/`?e.slice(1):e;break}default:n(`abort`,400);return}let i=503;Dc(e+r).then(e=>{let t=e.status;if(t!==200){setTimeout(()=>{n(kc(t)?`abort`:`next`,t)});return}return i=501,e.json()}).then(e=>{if(typeof e!=`object`||!e){setTimeout(()=>{e===404?n(`abort`,e):n(`next`,i)});return}setTimeout(()=>{n(`success`,e)})}).catch(()=>{n(`next`,i)})}};function Nc(e){let t={loaded:[],missing:[],pending:[]},n=Object.create(null);e.sort((e,t)=>e.provider===t.provider?e.prefix===t.prefix?e.name.localeCompare(t.name):e.prefix.localeCompare(t.prefix):e.provider.localeCompare(t.provider));let r={provider:``,prefix:``,name:``};return e.forEach(e=>{if(r.name===e.name&&r.prefix===e.prefix&&r.provider===e.provider)return;r=e;let i=e.provider,a=e.prefix,o=e.name,s=n[i]||(n[i]=Object.create(null)),c=s[a]||(s[a]=Xs(i,a)),l;l=o in c.icons?t.loaded:a===``||c.missing.has(o)?t.missing:t.pending;let u={provider:i,prefix:a,name:o};l.push(u)}),t}function Pc(e,t){e.forEach(e=>{let n=e.loaderCallbacks;n&&(e.loaderCallbacks=n.filter(e=>e.id!==t))})}function Fc(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;let t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let n=!1,r=e.provider,i=e.prefix;t.forEach(t=>{let a=t.icons,o=a.pending.length;a.pending=a.pending.filter(t=>{if(t.prefix!==i)return!0;let o=t.name;if(e.icons[o])a.loaded.push({provider:r,prefix:i,name:o});else if(e.missing.has(o))a.missing.push({provider:r,prefix:i,name:o});else return n=!0,!0;return!1}),a.pending.length!==o&&(n||Pc([e],t.id),t.callback(a.loaded.slice(0),a.missing.slice(0),a.pending.slice(0),t.abort))})}))}var Ic=0;function Lc(e,t,n){let r=Ic++,i=Pc.bind(null,n,r);if(!t.pending.length)return i;let a={id:r,icons:t,callback:e,abort:i};return n.forEach(e=>{(e.loaderCallbacks||=[]).push(a)}),i}function Rc(e,t=!0,n=!1){let r=[];return e.forEach(e=>{let i=typeof e==`string`?Ps(e,t,n):e;i&&r.push(i)}),r}var zc={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function Bc(e,t,n,r){let i=e.resources.length,a=e.random?Math.floor(Math.random()*i):e.index,o;if(e.random){let t=e.resources.slice(0);for(o=[];t.length>1;){let e=Math.floor(Math.random()*t.length);o.push(t[e]),t=t.slice(0,e).concat(t.slice(e+1))}o=o.concat(t)}else o=e.resources.slice(a).concat(e.resources.slice(0,a));let s=Date.now(),c=`pending`,l=0,u,d=null,f=[],p=[];typeof r==`function`&&p.push(r);function m(){d&&=(clearTimeout(d),null)}function h(){c===`pending`&&(c=`aborted`),m(),f.forEach(e=>{e.status===`pending`&&(e.status=`aborted`)}),f=[]}function g(e,t){t&&(p=[]),typeof e==`function`&&p.push(e)}function _(){return{startTime:s,payload:t,status:c,queriesSent:l,queriesPending:f.length,subscribe:g,abort:h}}function v(){c=`failed`,p.forEach(e=>{e(void 0,u)})}function y(){f.forEach(e=>{e.status===`pending`&&(e.status=`aborted`)}),f=[]}function b(t,n,r){let i=n!==`success`;switch(f=f.filter(e=>e!==t),c){case`pending`:break;case`failed`:if(i||!e.dataAfterTimeout)return;break;default:return}if(n===`abort`){u=r,v();return}if(i){u=r,f.length||(o.length?x():v());return}if(m(),y(),!e.random){let n=e.resources.indexOf(t.resource);n!==-1&&n!==e.index&&(e.index=n)}c=`completed`,p.forEach(e=>{e(r)})}function x(){if(c!==`pending`)return;m();let r=o.shift();if(r===void 0){if(f.length){d=setTimeout(()=>{m(),c===`pending`&&(y(),v())},e.timeout);return}v();return}let i={status:`pending`,resource:r,callback:(e,t)=>{b(i,e,t)}};f.push(i),l++,d=setTimeout(x,e.rotate),n(r,t,i.callback)}return setTimeout(x),_}function Vc(e){let t={...zc,...e},n=[];function r(){n=n.filter(e=>e().status===`pending`)}function i(e,i,a){let o=Bc(t,e,i,(e,t)=>{r(),a&&a(e,t)});return n.push(o),o}function a(e){return n.find(t=>e(t))||null}return{query:i,find:a,setIndex:e=>{t.index=e},getIndex:()=>t.index,cleanup:r}}function Hc(){}var Uc=Object.create(null);function Wc(e){if(!Uc[e]){let t=Ec(e);if(!t)return;Uc[e]={config:t,redundancy:Vc(t)}}return Uc[e]}function Gc(e,t,n){let r,i;if(typeof e==`string`){let t=bc(e);if(!t)return n(void 0,424),Hc;i=t.send;let a=Wc(e);a&&(r=a.redundancy)}else{let t=xc(e);if(t){r=Vc(t);let n=bc(e.resources?e.resources[0]:``);n&&(i=n.send)}}return!r||!i?(n(void 0,424),Hc):r.query(t,i,n)().abort}function Kc(){}function qc(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,Fc(e)}))}function Jc(e){let t=[],n=[];return e.forEach(e=>{(e.match(Ns)?t:n).push(e)}),{valid:t,invalid:n}}function Yc(e,t,n){function r(){let n=e.pendingIcons;t.forEach(t=>{n&&n.delete(t),e.icons[t]||e.missing.add(t)})}if(n&&typeof n==`object`)try{if(!Zs(e,n).length){r();return}}catch(e){console.error(e)}r(),qc(e)}function Xc(e,t){e instanceof Promise?e.then(e=>{t(e)}).catch(()=>{t(null)}):t(e)}function Zc(e,t){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(t).sort():e.iconsToLoad=t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;let{provider:t,prefix:n}=e,r=e.iconsToLoad;if(delete e.iconsToLoad,!r||!r.length)return;let i=e.loadIcon;if(e.loadIcons&&(r.length>1||!i)){Xc(e.loadIcons(r,n,t),t=>{Yc(e,r,t)});return}if(i){r.forEach(r=>{Xc(i(r,n,t),t=>{Yc(e,[r],t?{prefix:n,icons:{[r]:t}}:null)})});return}let{valid:a,invalid:o}=Jc(r);if(o.length&&Yc(e,o,null),!a.length)return;let s=n.match(Ns)?bc(t):null;if(!s){Yc(e,a,null);return}s.prepare(t,n,a).forEach(n=>{Gc(t,n,t=>{Yc(e,n.icons,t)})})}))}var Qc=(e,t)=>{let n=Nc(Rc(e,!0,ec()));if(!n.pending.length){let e=!0;return t&&setTimeout(()=>{e&&t(n.loaded,n.missing,n.pending,Kc)}),()=>{e=!1}}let r=Object.create(null),i=[],a,o;return n.pending.forEach(e=>{let{provider:t,prefix:n}=e;if(n===o&&t===a)return;a=t,o=n,i.push(Xs(t,n));let s=r[t]||(r[t]=Object.create(null));s[n]||(s[n]=[])}),n.pending.forEach(e=>{let{provider:t,prefix:n,name:i}=e,a=Xs(t,n),o=a.pendingIcons||=new Set;o.has(i)||(o.add(i),r[t][n].push(i))}),i.forEach(e=>{let t=r[e.provider][e.prefix];t.length&&Zc(e,t)}),t?Lc(t,n,i):Kc};function $c(e,t){let n={...e};for(let e in t){let r=t[e],i=typeof r;e in ic?(r===null||r&&(i===`string`||i===`number`))&&(n[e]=r):i===typeof n[e]&&(n[e]=e===`rotate`?r%4:r)}return n}var el=/[\s,]+/;function tl(e,t){t.split(el).forEach(t=>{switch(t.trim()){case`horizontal`:e.hFlip=!0;break;case`vertical`:e.vFlip=!0;break}})}function nl(e,t=0){let n=e.replace(/^-?[0-9.]*/,``);function r(e){for(;e<0;)e+=4;return e%4}if(n===``){let t=parseInt(e);return isNaN(t)?0:r(t)}else if(n!==e){let t=0;switch(n){case`%`:t=25;break;case`deg`:t=90}if(t){let i=parseFloat(e.slice(0,e.length-n.length));return isNaN(i)?0:(i/=t,i%1==0?r(i):0)}}return t}function rl(e,t){let n=e.indexOf(`xlink:`)===-1?``:` xmlns:xlink="http://www.w3.org/1999/xlink"`;for(let e in t)n+=` `+e+`="`+t[e]+`"`;return`<svg xmlns="http://www.w3.org/2000/svg"`+n+`>`+e+`</svg>`}function il(e){return e.replace(/"/g,`'`).replace(/%/g,`%25`).replace(/#/g,`%23`).replace(/</g,`%3C`).replace(/>/g,`%3E`).replace(/\s+/g,` `)}function al(e){return`data:image/svg+xml,`+il(e)}function ol(e){return`url("`+al(e)+`")`}var sl={...ac,inline:!1},cl={xmlns:`http://www.w3.org/2000/svg`,"xmlns:xlink":`http://www.w3.org/1999/xlink`,"aria-hidden":!0,role:`img`},ll={display:`inline-block`},ul={backgroundColor:`currentColor`},dl={backgroundColor:`transparent`},fl={Image:`var(--svg)`,Repeat:`no-repeat`,Size:`100% 100%`},pl={webkitMask:ul,mask:ul,background:dl};for(let e in pl){let t=pl[e];for(let n in fl)t[e+n]=fl[n]}var ml={};[`horizontal`,`vertical`].forEach(e=>{let t=e.slice(0,1)+`Flip`;ml[e+`-flip`]=t,ml[e.slice(0,1)+`-flip`]=t,ml[e+`Flip`]=t});function hl(e){return e+(e.match(/^[-0-9.]+$/)?`px`:``)}var gl=(e,t)=>{let n=$c(sl,t),r={...cl},i=t.mode||`svg`,a={},o=t.style,s=typeof o==`object`&&!(o instanceof Array)?o:{};for(let e in t){let i=t[e];if(i!==void 0)switch(e){case`icon`:case`style`:case`onLoad`:case`mode`:case`ssr`:break;case`inline`:case`hFlip`:case`vFlip`:n[e]=i===!0||i===`true`||i===1;break;case`flip`:typeof i==`string`&&tl(n,i);break;case`color`:a.color=i;break;case`rotate`:typeof i==`string`?n[e]=nl(i):typeof i==`number`&&(n[e]=i);break;case`ariaHidden`:case`aria-hidden`:i!==!0&&i!==`true`&&delete r[`aria-hidden`];break;default:{let t=ml[e];t?(i===!0||i===`true`||i===1)&&(n[t]=!0):sl[e]===void 0&&(r[e]=i)}}}let c=pc(e,n),l=c.attributes;if(n.inline&&(a.verticalAlign=`-0.125em`),i===`svg`){r.style={...a,...s},Object.assign(r,l);let e=0,n=t.id;return typeof n==`string`&&(n=n.replace(/-/g,`_`)),r.innerHTML=_c(c.body,n?()=>n+`ID`+ e++:`iconifyVue`),oo(`svg`,r)}let{body:u,width:d,height:f}=e,p=i===`mask`||(i===`bg`?!1:u.indexOf(`currentColor`)!==-1),m=rl(u,{...l,width:d+``,height:f+``});return r.style={...a,"--svg":ol(m),width:hl(l.width),height:hl(l.height),...ll,...p?ul:dl,...s},oo(`span`,r)};if(ec(!0),yc(``,Mc),typeof document<`u`&&typeof window<`u`){let e=window;if(e.IconifyPreload!==void 0){let t=e.IconifyPreload,n=`Invalid IconifyPreload syntax.`;typeof t==`object`&&t&&(t instanceof Array?t:[t]).forEach(e=>{try{(typeof e!=`object`||!e||e instanceof Array||typeof e.icons!=`object`||typeof e.prefix!=`string`||!rc(e))&&console.error(n)}catch{console.error(n)}})}if(e.IconifyProviders!==void 0){let t=e.IconifyProviders;if(typeof t==`object`&&t)for(let e in t){let n=`IconifyProviders[`+e+`] is invalid.`;try{let r=t[e];if(typeof r!=`object`||!r||r.resources===void 0)continue;Tc(e,r)||console.error(n)}catch{console.error(n)}}}}var _l={...Rs,body:``},vl=z((e,{emit:t})=>{let n=F(null);function r(){n.value&&=(n.value.abort?.(),null)}let i=F(!!e.ssr),a=F(``),o=I(null);function s(){let i=e.icon;if(typeof i==`object`&&i&&typeof i.body==`string`)return a.value=``,{data:i};let o;if(typeof i!=`string`||(o=Ps(i,!1,!0))===null)return null;let s=tc(o);if(!s){let e=n.value;return(!e||e.name!==i)&&(s===null?n.value={name:i}:n.value={name:i,abort:Qc([o],c)}),null}r(),a.value!==i&&(a.value=i,Tn(()=>{t(`load`,i)}));let l=e.customise;if(l){s=Object.assign({},s);let e=l(s.body,o.name,o.prefix,o.provider);typeof e==`string`&&(s.body=e)}let u=[`iconify`];return o.prefix!==``&&u.push(`iconify--`+o.prefix),o.provider!==``&&u.push(`iconify--`+o.provider),{data:s,classes:u}}function c(){let e=s();e?e.data!==o.value?.data&&(o.value=e):o.value=null}return i.value?c():Ir(()=>{i.value=!0,c()}),R(()=>e.icon,c),Br(r),()=>{let t=o.value;if(!t)return gl(_l,e);let n=e;return t.classes&&(n={...e,class:t.classes.join(` `)}),gl({...Rs,...t.data},n)}},{props:[`icon`,`mode`,`ssr`,`width`,`height`,`style`,`color`,`inline`,`rotate`,`hFlip`,`horizontalFlip`,`vFlip`,`verticalFlip`,`flip`,`id`,`ariaHidden`,`customise`,`title`],emits:[`load`]}),yl=z({__name:`ContextMenu`,props:{pos:{},transform:{}},setup(e){return(t,n)=>(V(),wa(ir,{to:`body`},[e.pos?(V(),H(`div`,{key:0,class:`ctx-menu-glass fixed z-[1200] min-w-[140px] select-none rounded-xl py-1 backdrop-blur-2xl backdrop-saturate-150`,style:M({left:`${e.pos.x}px`,top:`${e.pos.y}px`,transform:e.transform})},[Qr(t.$slots,`default`)],4)):K(``,!0)]))}}),bl={class:`h-8 px-3 border-b border-border flex items-center justify-between`},xl={class:`section-title`},Sl={class:`p-3 overflow-y-auto`,style:{"max-height":`calc(100vh - 64px - 32px)`}},Cl=z({__name:`ModalWindow`,props:{title:{},width:{default:`480px`}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t;function i(e){e.target===e.currentTarget&&r(`close`)}return(e,t)=>(V(),wa(ir,{to:`body`},[U(`div`,{class:`fixed inset-0 z-[9999] flex items-center justify-center bg-bg/80`,onMousedown:i},[U(`div`,{class:`border border-border bg-surface rounded shadow-lg`,style:M({width:n.width,maxWidth:`calc(100vw - 32px)`,maxHeight:`calc(100vh - 64px)`})},[U(`div`,bl,[U(`span`,xl,P(n.title),1),U(`button`,{type:`button`,class:`text-[11px] text-muted hover:text-text transition-colors`,onClick:t[0]||=e=>r(`close`)},` x `)]),U(`div`,Sl,[Qr(e.$slots,`default`)])],4)],32)]))}}),wl=window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone===!0,Tl=F(null),El=F(!1);function Dl(e){e.preventDefault(),Tl.value=e}function Ol(){El.value=!0,Tl.value=null}typeof window<`u`&&(window.addEventListener(`beforeinstallprompt`,Dl),window.addEventListener(`appinstalled`,Ol));var kl=q(()=>!wl&&!El.value),Al=/iPad|iPhone|iPod/.test(navigator.userAgent),jl=Al?[{icon:`lucide:share`,text:`tap the share button`},{icon:`lucide:plus-square`,text:`tap "add to home screen"`}]:[{icon:`lucide:ellipsis-vertical`,text:`tap the browser menu`},{icon:`lucide:download`,text:`tap "install app" or "add to home screen"`}];function Ml(){let e=F(!1);function t(){Tl.value?(Tl.value.prompt(),Tl.value=null):e.value=!0}return{showInstall:kl,showA2hs:e,handleInstallClick:t,isIos:Al,a2hsSteps:jl}}var Nl={key:1,class:`badge-ok`},Pl={key:2,class:`fixed bottom-2.5 max-md:bottom-14 right-2.5 z-[10] flex gap-1.5`},Fl=[`title`],Il={class:`flex flex-col gap-2.5 mb-3`},Ll={class:`flex items-center justify-center w-6 h-6 rounded-md bg-white/10 shrink-0`},Rl={class:`flex justify-end`},zl=z({__name:`FullscreenToggle`,props:{inlineInstall:{type:Boolean,default:!1}},setup(e){let t=e,n=!!document.documentElement.requestFullscreen,r=F(!!document.fullscreenElement);function i(){document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()}function a(){r.value=!!document.fullscreenElement}Ir(()=>document.addEventListener(`fullscreenchange`,a)),Br(()=>document.removeEventListener(`fullscreenchange`,a));let{showInstall:o,showA2hs:s,handleInstallClick:c,a2hsSteps:l}=Ml();return(e,a)=>(V(),H(B,null,[t.inlineInstall&&L(o)?(V(),H(`button`,{key:0,type:`button`,class:`btn-primary text-[11px] inline-flex items-center gap-1.5`,onClick:a[0]||=e=>L(c)()},[W(L(vl),{icon:`lucide:download`,class:`text-[13px]`}),a[5]||=G(` add to home screen `,-1)])):t.inlineInstall?(V(),H(`span`,Nl,`already installed`)):!t.inlineInstall&&(n||L(o))?(V(),H(`div`,Pl,[L(o)?(V(),H(`button`,{key:0,type:`button`,tabindex:`-1`,class:`p-1 rounded bg-black/30 backdrop-blur-sm text-white/80 hover:text-white hover:bg-black/50 transition-all`,title:`install app`,onClick:a[1]||=e=>L(c)()},[W(L(vl),{icon:`lucide:download`,class:`text-base`})])):K(``,!0),n?(V(),H(`button`,{key:1,type:`button`,tabindex:`-1`,class:`p-1 rounded bg-black/30 backdrop-blur-sm text-white/80 hover:text-white hover:bg-black/50 transition-all`,title:r.value?`exit fullscreen`:`enter fullscreen`,onClick:a[2]||=e=>i()},[W(L(vl),{icon:r.value?`lucide:minimize`:`lucide:maximize`,class:`text-base`},null,8,[`icon`])],8,Fl)):K(``,!0)])):K(``,!0),L(s)?(V(),wa(Cl,{key:3,title:`install app`,width:`340px`,onClose:a[4]||=e=>s.value=!1},{default:Ln(()=>[a[6]||=U(`p`,{class:`text-[12px] text-text mb-3`},` for the best experience, add this app to your home screen: `,-1),U(`div`,Il,[(V(!0),H(B,null,Zr(L(l),(e,t)=>(V(),H(`div`,{key:t,class:`flex items-center gap-2.5 text-[12px] text-muted`},[U(`span`,Ll,[W(L(vl),{icon:e.icon,class:`text-sm text-text`},null,8,[`icon`])]),U(`span`,null,P(t+1)+`. `+P(e.text),1)]))),128))]),U(`div`,Rl,[U(`button`,{class:`btn-ghost`,onClick:a[3]||=e=>s.value=!1},`close`)])]),_:1})):K(``,!0)],64))}});function Bl(){let e=F(null),t;function n(t,n,r){e.value={x:t,y:n,data:r}}function r(){e.value=null}function i(e,t){e.preventDefault(),n(e.clientX,e.clientY,t)}function a(e,r){let{clientX:i,clientY:a}=e.touches[0];t=setTimeout(()=>{e.preventDefault(),n(i,a,r)},500)}function o(){clearTimeout(t)}function s(){e.value&&r()}return Ir(()=>document.addEventListener(`click`,s)),Br(()=>document.removeEventListener(`click`,s)),{menu:e,open:n,close:r,onContext:i,onTouchStart:a,cancelLongPress:o}}var Vl=`piclaw:settings`,Hl=768;function Ul(){return window.matchMedia(`(max-width: ${Hl-1}px)`).matches?`small`:`large`}function Wl(){return`grid`}function Gl(){return{theme:`system`,wallpaper:``,iconLayout:Wl(),dockSize:Ul(),showClock:!0,clockFormat:`24h`,showStatus:!0,showFullscreen:!0}}function Kl(){let e=Gl();try{let t=localStorage.getItem(Vl);if(t)return{...e,...JSON.parse(t)}}catch{}let t={...e},n=localStorage.getItem(`piclaw:desktop-bg`);n&&(t.wallpaper=n,localStorage.removeItem(`piclaw:desktop-bg`));let r=localStorage.getItem(`piclaw:icon-layout`);return(r===`list`||r===`grid`)&&(t.iconLayout=r,localStorage.removeItem(`piclaw:icon-layout`)),t}var ql=It(Kl());function Jl(){localStorage.setItem(Vl,JSON.stringify(ql))}R(ql,Jl,{deep:!0});function Yl(e){window.dispatchEvent(new CustomEvent(`piclaw:settings:${e}`,{detail:ql[e]}))}function Xl(){return{settings:ql,set(e){for(let[t,n]of Object.entries(e))ql[t]=n,Yl(t)},reset(){Object.assign(ql,Gl()),Jl()}}}const Zl=Symbol(`windowState`),Ql=Symbol(`instanceId`);function $l(e){let t=Vn(Zl);if(!t)throw Error(`useWindowState requires windowStateKey to be provided`);let n=Vn(Ql),r=q(()=>e??n?.value??``);return{instanceId:r,state:q(()=>t.windowState[r.value]??{}),set:e=>{r.value&&t.setWindowState(r.value,e)},setTitle:e=>{r.value&&t.setWindowTitle(r.value,e)},close:()=>{r.value&&t.closeWindow(r.value)},setWindowState:t.setWindowState,setWindowTitle:t.setWindowTitle,bringToFront:t.bringToFront,openWindow:t.openWindow,closeWindow:t.closeWindow}}var eu={key:1,class:`fixed bottom-3 max-md:bottom-[3.25rem] right-10 max-md:right-3 z-[1] text-[11px] text-white/70 pointer-events-none select-none`,style:{"text-shadow":`0 1px 3px rgba(0, 0, 0, 0.8)`},"aria-hidden":`true`},tu={key:0,class:`absolute inset-0 flex items-center justify-center pointer-events-none select-none`,"aria-hidden":`true`},nu=[`onClick`],ru={class:`mt-1 truncate`,style:{"text-shadow":`0 1px 3px rgba(0, 0, 0, 0.9),
2
+ 0 0 8px rgba(0, 0, 0, 0.5)`}},iu=z({__name:`AppDesktop`,props:{apps:{},openInstances:{}},emits:[`launch`,`ctxAction`],setup(e,{expose:t,emit:n}){let r=n,{settings:i,set:a}=Xl(),o=q(()=>i.wallpaper),s=q(()=>i.iconLayout);function c(){a({iconLayout:i.iconLayout===`list`?`grid`:`list`}),p()}let{menu:l,onContext:u,onTouchStart:d,cancelLongPress:f,close:p}=Bl();function m(e){p(),r(`ctxAction`,e)}function h(){p(),globalThis.location.reload()}t({closeCtxMenu:p});let g=z({props:{instanceId:{type:String,required:!0}},setup(e,{slots:t}){return Bn(Ql,rn(()=>e.instanceId)),()=>t.default?.()}});return(t,n)=>(V(),H(B,null,[o.value?(V(),H(`div`,{key:0,class:`fixed inset-0 bg-cover bg-center pointer-events-none select-none z-0`,style:M({backgroundImage:`url(${o.value})`}),"aria-hidden":`true`},null,4)):K(``,!0),o.value?.includes(`wallhaven.cc`)?(V(),H(`span`,eu,`wallhaven.cc`)):K(``,!0),U(`div`,{class:`flex-1 min-h-0 p-4 max-md:p-0 relative h-full overflow-hidden select-none`,onContextmenu:n[0]||=ws(e=>L(u)(e,void 0),[`self`]),onTouchstart:n[1]||=ws(e=>L(d)(e,void 0),[`self`]),onTouchend:n[2]||=ws((...e)=>L(f)&&L(f)(...e),[`self`]),onTouchmove:n[3]||=ws((...e)=>L(f)&&L(f)(...e),[`self`])},[o.value?K(``,!0):(V(),H(`div`,tu,[...n[6]||=[U(`svg`,{class:`text-surface w-[min(55vw,55vh)] h-[min(55vw,55vh)]`,viewBox:`0 0 200 200`,fill:`none`,stroke:`currentColor`,"stroke-width":`3.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`},[U(`path`,{d:`M 30 55 Q 60 48, 100 50 Q 140 52, 170 47`}),U(`path`,{d:`M 65 50 Q 58 90, 55 120 Q 52 145, 48 170`}),U(`path`,{d:`M 125 50 Q 130 90, 132 120 Q 134 150, 140 175`})],-1)]])),U(`div`,{class:N([`absolute z-[5] pointer-events-none`,s.value===`grid`?`inset-4 grid grid-cols-4 justify-items-center content-start gap-3 md:flex md:flex-wrap md:justify-center`:`top-4 left-4 flex flex-col gap-1.5 max-md:flex-wrap max-md:max-h-[calc((theme(spacing.18)+theme(spacing.1.5))*4)] max-md:gap-x-3`])},[(V(!0),H(B,null,Zr(e.apps.filter(e=>!e.hidden),e=>(V(),H(`button`,{key:`desktop-${e.key}`,type:`button`,tabindex:-1,class:N([`pointer-events-auto px-2 py-2 rounded text-center text-white/90 hover:text-white transition-colors`,s.value===`grid`?`w-22 text-[12px]`:`w-18 text-[11px]`]),onClick:t=>r(`launch`,e.key)},[W(L(vl),{icon:e.icon,class:N([`mx-auto drop-shadow-[0_1px_3px_rgba(0,0,0,0.8)]`,s.value===`grid`?`text-2xl`:`text-xl`]),style:M({color:e.color})},null,8,[`icon`,`class`,`style`]),U(`div`,ru,P(e.label),1)],10,nu))),128))],2),(V(!0),H(B,null,Zr(e.openInstances,e=>(V(),wa(ir,{key:e.id,to:e.mountTarget},[W(L(g),{"instance-id":e.id},{default:Ln(()=>[(V(),wa(Jr(e.app.component)))]),_:2},1032,[`instance-id`])],8,[`to`]))),128))],32),L(i).showFullscreen?(V(),wa(zl,{key:2})):K(``,!0),W(yl,{pos:L(l)??null},{default:Ln(()=>[U(`button`,{type:`button`,class:`w-full text-left px-3 py-1.5 text-[12px] text-text hover:bg-accent-dim hover:text-accent transition-colors cursor-pointer`,onClick:n[4]||=e=>h()},` Reload `),U(`button`,{type:`button`,class:`w-full text-left px-3 py-1.5 text-[12px] text-text hover:bg-accent-dim hover:text-accent transition-colors cursor-pointer`,onClick:c},P(s.value===`list`?`Grid layout`:`List layout`),1),U(`button`,{type:`button`,class:`w-full text-left px-3 py-1.5 text-[12px] text-text hover:bg-accent-dim hover:text-accent transition-colors cursor-pointer`,onClick:n[5]||=e=>m(`settings`)},` Settings `)]),_:1},8,[`pos`])],64))}}),au=F();function ou(){function e(e){return new Promise(t=>{au.value={message:e,resolve:t}})}function t(e){return new Promise(t=>{au.value={message:e,alertOnly:!0,resolve:()=>t()}})}function n(){au.value?.resolve(!0),au.value=void 0}function r(){au.value?.resolve(!1),au.value=void 0}return{state:au,confirm:e,alert:t,accept:n,cancel:r}}var su={class:`text-[12px] text-text mb-3`},cu={class:`flex gap-2 items-center justify-end`},lu=z({__name:`ConfirmDialog`,setup(e){let{state:t,accept:n,cancel:r}=ou(),i=F();R(t,async e=>{e&&(await Tn(),i.value?.focus())});function a(e){t.value&&(e.key===`Enter`?(e.preventDefault(),n()):e.key===`Escape`&&(e.preventDefault(),r()))}return Ir(()=>window.addEventListener(`keydown`,a)),Br(()=>window.removeEventListener(`keydown`,a)),(e,a)=>L(t)?(V(),wa(Cl,{key:0,title:L(t).alertOnly?`notice`:`confirm`,width:`360px`,onClose:L(r)},{default:Ln(()=>[U(`p`,su,P(L(t).message),1),U(`div`,cu,[L(t).alertOnly?(V(),H(`button`,{key:0,ref_key:`primaryBtn`,ref:i,type:`button`,class:`btn-primary`,onClick:a[0]||=(...e)=>L(n)&&L(n)(...e)},[...a[3]||=[G(` ok `,-1),U(`span`,{class:`text-[9px] opacity-60 hidden sm:inline`},`↵`,-1)]],512)):(V(),H(B,{key:1},[U(`button`,{type:`button`,class:`btn-ghost`,onClick:a[1]||=(...e)=>L(r)&&L(r)(...e)},[...a[4]||=[G(` cancel `,-1),U(`span`,{class:`text-[9px] opacity-60 hidden sm:inline`},`esc`,-1)]]),U(`button`,{ref_key:`primaryBtn`,ref:i,type:`button`,class:`btn-danger`,onClick:a[2]||=(...e)=>L(n)&&L(n)(...e)},[...a[5]||=[G(` confirm `,-1),U(`span`,{class:`text-[9px] opacity-60 hidden sm:inline`},`↵`,-1)]],512)],64))])]),_:1},8,[`title`,`onClose`])):K(``,!0)}}),uu=``;async function du(e,t){try{let n=await fetch(uu+e,t);if(!n.ok)throw Error(await n.text());return await n.json()}catch(e){return console.error(`API error:`,e),null}}async function fu(e,t){return await du(e,t)||null}var pu=768;function mu(){let e=F(window.innerWidth<pu),t=window.matchMedia(`(max-width: ${pu-1}px)`),n=t=>{e.value=t.matches};return t.addEventListener(`change`,n),we(()=>t.removeEventListener(`change`,n)),e}function hu(){let e=window.matchMedia(`(pointer: coarse)`),t=F(e.matches),n=e=>{t.value=e.matches};return e.addEventListener(`change`,n),we(()=>e.removeEventListener(`change`,n)),t}function gu(e,t){let n;Ir(()=>{e(),n=setInterval(()=>{e()},t)}),Br(()=>{n&&=(clearInterval(n),void 0)})}var _u={class:`flex flex-col h-full overflow-y-auto`},vu={class:`p-3`},yu={key:0,class:`text-[12px] text-muted`},bu={key:1,class:`text-[12px] text-muted`},xu={key:2,class:`w-full border-collapse text-[12px]`},Su={class:`py-1.5 px-2 border-b border-border font-medium`},Cu={class:`py-1.5 px-2 border-b border-border text-muted font-mono text-[11px]`},wu={class:`py-1.5 px-2 border-b border-border`},Tu={class:`py-1.5 px-2 border-b border-border text-right`},Eu=[`disabled`,`onClick`],Du=[`disabled`,`onClick`],Ou={class:`px-3 pb-3`},ku={key:0,class:`text-[12px] text-muted`},Au={key:1,class:`w-full border-collapse text-[12px]`},ju={class:`py-1.5 px-2 border-b border-border font-medium`},Mu={class:`py-1.5 px-2 border-b border-border text-muted font-mono text-[11px]`},Nu={class:`py-1.5 px-2 border-b border-border`},Pu={class:`py-1.5 px-2 border-b border-border text-right whitespace-nowrap`},Fu=[`disabled`,`onClick`],Iu=[`onClick`],Lu=[`onClick`],Ru={key:0,class:`mb-3 text-center`},zu={key:0,class:`text-[11px] text-muted mb-2`},Bu={key:1,class:`text-[11px] text-muted mb-2`},Vu=[`href`],Hu={key:1,class:`mb-3`},Uu={class:`text-[11px] text-muted`},Wu={key:2,class:`mb-3`},Gu={class:`text-[11px] text-muted mb-1`},Ku=[`placeholder`],qu=[`disabled`],Ju={key:3,class:`text-[11px] text-muted`},Yu={key:4,class:`text-[11px] text-ok`},Xu={key:5,class:`text-[11px] text-danger`},Zu={class:`mb-3`},Qu={class:`text-[11px] text-muted mb-1`},$u={class:`font-medium text-text`},ed={class:`text-[10px] text-muted mb-1`},td={class:`font-mono text-accent`},nd={key:0,class:`text-[10px] text-muted`},rd={key:0},id=[`href`],ad=[`disabled`],od=z({__name:`AuthTab`,setup(e){let t=F(null),n=F(!1),r=F(null),i=F(null),a=F(null),o=F([]),s=F(!1),c=F(``),l=F(null),u=null,d=F([]),f=F(null),p=F(``),m=F(!1),h=F(null),g=q(()=>t.value?t.value.oauthProviders.map(e=>{let n=t.value.providers.find(t=>t.provider===e.id);return{...e,hasAuth:n?.hasAuth??!1}}):[]),_=q(()=>s.value?null:x(`prompt`)?.prompt??null),v=q(()=>x(`progress`)?.message??null),y=q(()=>s.value?null:x(`auth`)?.authInfo??null),b=q(()=>x(`error`)?.error??null);function x(e){return[...o.value].reverse().find(t=>t.type===e)}let S=q(()=>o.value.some(e=>e.type===`complete`));async function C(){let e=await fu(`/api/pi/status`);e&&(t.value=e.auth)}async function w(){let e=await fu(`/api/pi/apikey-providers`);e&&(d.value=e)}function T(){C(),w()}gu(T,1e4);async function ee(e){O(),i.value=e,o.value=[],s.value=!1,c.value=``,n.value=!0;try{let t=await du(`/api/pi/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({providerId:e})});if(!t?.loginId){o.value.push({type:`error`,error:`Failed to start login`}),s.value=!0;return}a.value=t.loginId,u=new EventSource(`/api/pi/login/events?loginId=${t.loginId}`),u.onmessage=e=>{try{let t=JSON.parse(e.data);o.value.push(t),(t.type===`complete`||t.type===`error`)&&(s.value=!0,O(),t.type===`complete`&&T())}catch{}},u.onerror=()=>{s.value||=(o.value.push({type:`error`,error:`Connection lost`}),!0),O()}}catch(e){o.value.push({type:`error`,error:e instanceof Error?e.message:`Login failed`}),s.value=!0}finally{n.value=!1}}async function E(){if(!a.value)return;let e=c.value;c.value=``,await du(`/api/pi/login/respond`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({loginId:a.value,value:e})})}function D(){O(),i.value=null,a.value=null,o.value=[],s.value=!1}function O(){u&&=(u.close(),null)}async function k(e){r.value=e;try{await du(`/api/pi/logout`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e})}),T()}finally{r.value=null}}function te(e){f.value=e,p.value=``,m.value=!1,Tn(()=>h.value?.focus())}function ne(){f.value=null,p.value=``,m.value=!1}async function A(){if(!(!f.value||!p.value.trim())){m.value=!0;try{await du(`/api/pi/apikey`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:f.value.id,key:p.value.trim()})}),ne(),T()}finally{m.value=!1}}}async function re(e){r.value=e;try{await du(`/api/pi/apikey`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e,key:null})}),T()}finally{r.value=null}}return R(_,e=>{e&&Tn(()=>l.value?.focus())}),(e,a)=>(V(),H(B,null,[U(`div`,_u,[U(`div`,vu,[a[2]||=U(`h3`,{class:`section-title mb-2 select-none`},`oauth providers`,-1),t.value?g.value.length===0?(V(),H(`div`,bu,` no oauth providers available `)):(V(),H(`table`,xu,[U(`tbody`,null,[(V(!0),H(B,null,Zr(g.value,e=>(V(),H(`tr`,{key:e.id,class:`hover:bg-surface`},[U(`td`,Su,P(e.name),1),U(`td`,Cu,P(e.id),1),U(`td`,wu,[U(`span`,{class:N(e.hasAuth?`badge-ok`:`badge-muted`)},P(e.hasAuth?`connected`:`not connected`),3)]),U(`td`,Tu,[e.hasAuth?(V(),H(`button`,{key:0,type:`button`,disabled:r.value===e.id,class:`btn-sm border-danger-dim text-danger bg-danger-dim hover:text-text disabled:text-muted disabled:bg-surface disabled:border-border`,onClick:t=>k(e.id)},P(r.value===e.id?`...`:`logout`),9,Eu)):(V(),H(`button`,{key:1,type:`button`,disabled:n.value&&i.value===e.id,class:`btn-sm border-accent-dim text-accent bg-accent-dim hover:bg-accent-dimmer disabled:text-muted disabled:bg-surface disabled:border-border`,onClick:t=>ee(e.id)},P(n.value&&i.value===e.id?`...`:`login`),9,Du))])]))),128))])])):(V(),H(`div`,yu,`loading...`))]),U(`div`,Ou,[a[3]||=U(`h3`,{class:`section-title mb-2 select-none`},`api keys`,-1),d.value.length===0?(V(),H(`div`,ku,`loading...`)):(V(),H(`table`,Au,[U(`tbody`,null,[(V(!0),H(B,null,Zr(d.value,e=>(V(),H(`tr`,{key:e.id,class:`hover:bg-surface`},[U(`td`,ju,P(e.name),1),U(`td`,Mu,P(e.envVar),1),U(`td`,Nu,[U(`span`,{class:N(e.hasAuth?`badge-ok`:`badge-muted`)},P(e.hasAuth?`configured`:`not set`),3)]),U(`td`,Pu,[e.hasAuth?(V(),H(`button`,{key:0,type:`button`,disabled:r.value===e.id,class:`btn-sm border-danger-dim text-danger bg-danger-dim hover:text-text disabled:text-muted disabled:bg-surface disabled:border-border`,onClick:t=>re(e.id)},P(r.value===e.id?`...`:`remove`),9,Fu)):K(``,!0),e.hasAuth?K(``,!0):(V(),H(`button`,{key:1,type:`button`,class:`btn-sm border-accent-dim text-accent bg-accent-dim hover:bg-accent-dimmer`,onClick:t=>te(e)},` set key `,8,Iu)),e.hasAuth?(V(),H(`button`,{key:2,type:`button`,class:`ml-1 btn-sm`,onClick:t=>te(e)},` update `,8,Lu)):K(``,!0)])]))),128))])]))])]),i.value?(V(),wa(Cl,{key:0,title:`login — ${i.value}`,width:`420px`,onClose:D},{default:Ln(()=>[y.value?(V(),H(`div`,Ru,[y.value.instructions?(V(),H(`p`,zu,P(y.value.instructions),1)):(V(),H(`p`,Bu,` open this url in your browser to authenticate: `)),U(`a`,{href:y.value.url,target:`_blank`,rel:`noopener`,class:`btn-primary inline-block text-[11px]`},` open in browser -> `,8,Vu)])):K(``,!0),v.value&&!s.value?(V(),H(`div`,Hu,[U(`p`,Uu,P(v.value),1)])):K(``,!0),_.value?(V(),H(`div`,Wu,[U(`p`,Gu,P(_.value.message),1),U(`form`,{class:`flex gap-2`,onSubmit:ws(E,[`prevent`]),onKeydown:Es(D,[`escape`])},[Rn(U(`input`,{ref_key:`promptInputEl`,ref:l,"onUpdate:modelValue":a[0]||=e=>c.value=e,placeholder:_.value.placeholder||``,class:`bg-bg border border-border rounded text-text px-2.5 py-1.5 text-[12px] font-mono flex-1 outline-none transition-colors focus:border-accent`},null,8,Ku),[[vs,c.value]]),U(`button`,{type:`submit`,disabled:!c.value.trim()&&!_.value.allowEmpty,class:`btn-primary text-[11px] disabled:text-muted disabled:bg-surface disabled:border-border`},` submit `,8,qu)],32)])):K(``,!0),!s.value&&!y.value&&!_.value&&!v.value?(V(),H(`div`,Ju,` connecting... `)):K(``,!0),S.value?(V(),H(`div`,Yu,`login successful`)):K(``,!0),b.value?(V(),H(`div`,Xu,P(b.value),1)):K(``,!0)]),_:1},8,[`title`])):K(``,!0),f.value?(V(),wa(Cl,{key:1,title:`${f.value.name} — api key`,width:`420px`,onClose:ne},{default:Ln(()=>[U(`div`,Zu,[U(`p`,Qu,[a[4]||=G(` enter your API key for `,-1),U(`span`,$u,P(f.value.name),1)]),U(`p`,ed,[a[5]||=G(` env: `,-1),U(`code`,td,P(f.value.envVar),1)]),f.value.url?(V(),H(`p`,nd,[f.value.guide?(V(),H(`span`,rd,P(f.value.guide)+` — `,1)):K(``,!0),U(`a`,{href:f.value.url,target:`_blank`,rel:`noopener`,class:`text-accent hover:underline`},`LINK`,8,id)])):K(``,!0)]),U(`form`,{class:`flex gap-2`,onSubmit:ws(A,[`prevent`]),onKeydown:Es(ne,[`escape`])},[Rn(U(`input`,{ref_key:`apiKeyInputEl`,ref:h,"onUpdate:modelValue":a[1]||=e=>p.value=e,type:`password`,placeholder:`sk-...`,autocomplete:`off`,class:`bg-bg border border-border rounded text-text px-2.5 py-1.5 text-[12px] font-mono flex-1 outline-none transition-colors focus:border-accent`},null,512),[[vs,p.value]]),U(`button`,{type:`submit`,disabled:!p.value.trim()||m.value,class:`btn-primary text-[11px] disabled:text-muted disabled:bg-surface disabled:border-border`},P(m.value?`...`:`save`),9,ad)],32)]),_:1},8,[`title`])):K(``,!0)],64))}}),sd=0;function cd(){return`node_${++sd}`}function ld(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e}function ud(e,t,n,r,i){let a=cd(),o=n?`${n}/${e}`:`/${e}`,s=ld(t),c={id:a,key:e,path:o,type:s,value:s===`object`||s===`array`?void 0:t,children:[],parentId:r};if(i.set(a,c),s===`object`&&t!==null){let e=t;c.children=Object.keys(e).map(t=>ud(t,e[t],o,a,i))}else s===`array`&&(c.children=t.map((e,t)=>ud(String(t),e,o,a,i)));return c}function dd(e){let t=new Map,n=ld(e),r={id:cd(),key:``,path:`/`,type:n,value:n===`object`||n===`array`?void 0:e,children:[],parentId:null};if(t.set(r.id,r),n===`object`&&e!==null){let n=e;r.children=Object.keys(n).map(e=>ud(e,n[e],``,r.id,t))}else n===`array`&&(r.children=e.map((e,n)=>ud(String(n),e,``,r.id,t)));return{root:r,nodesById:t}}function fd(e){switch(e.type){case`object`:{let t={};for(let n of e.children)t[n.key]=fd(n);return t}case`array`:return e.children.map(e=>fd(e));default:return e.value}}function pd(e,t,n,r){let i=n?`${n}/${t}`:`/${t}`;return{...e,key:t,path:i,parentId:r,children:e.children.map((t,n)=>pd(t,e.type===`array`?String(n):t.key,i,e.id))}}function md(e,t,n){let r=e.nodesById.get(t);for(;r;){if(r.id===n)return!0;r=r.parentId?e.nodesById.get(r.parentId):void 0}return!1}function hd(e){let t=new Map;function n(e){t.set(e.id,e);for(let t of e.children)n(t)}return n(e),t}function gd(e,t){let n=t?`${t}/${e.key}`:`/${e.key}`;return e.path===n&&e.children.length===0?e:{...e,path:n,children:e.children.map(e=>gd(e,n))}}function _d(e,t,n){let r=[],i=e.nodesById.get(t);for(;i;)r.unshift(i.id),i=i.parentId?e.nodesById.get(i.parentId):void 0;if(r.length===0)return e;function a(e,t){if(t===r.length-1)return n(e);let i=r[t+1];return{...e,children:e.children.map(e=>e.id===i?a(e,t+1):e)}}let o=a(e.root,0);return{root:o,nodesById:hd(o)}}function vd(e){if(e.type!==`array`)return e;let t=e.path===`/`?``:e.path;return{...e,children:e.children.map((e,n)=>{let r=String(n);return e.key===r?e:gd({...e,key:r},t)})}}function yd(e,t,n){if(!e.nodesById.get(t))return e;let r=ld(n);return r!==`object`&&r!==`array`?_d(e,t,e=>({...e,type:r,value:n,children:[]})):_d(e,t,e=>{let t=e.path.split(`/`).slice(0,-1).join(`/`)||``,r=new Map;return{...ud(e.key,n,t,e.parentId,r),id:e.id}})}function bd(e,t,n){let r=e.nodesById.get(t);if(!r||!r.parentId)return e;let i=e.nodesById.get(r.parentId);return!i||i.type!==`object`?e:_d(e,t,e=>{let t=`${i.path===`/`?``:i.path}/${n}`,r={...e,key:n,path:t};return r.children.length>0&&(r.children=r.children.map(e=>gd(e,t))),r})}function xd(e,t,n,r){return e.nodesById.get(t)?_d(e,t,e=>{let t=ud(n,r,e.path===`/`?``:e.path,e.id,new Map);return{...e,children:[...e.children,t]}}):e}function Sd(e,t,n,r){return e.nodesById.get(t)?_d(e,t,e=>{let t=e.path===`/`?``:e.path,i=pd(n,e.type===`array`?String(r):n.key,t,e.id),a=[...e.children];return a.splice(r,0,i),vd({...e,children:a})}):e}function Cd(e,t){let n=e.nodesById.get(t);return!n||!n.parentId?e:_d(e,n.parentId,e=>{let n=e.children.filter(e=>e.id!==t);return vd({...e,children:n})})}function wd(e,t,n,r,i){if(!e.nodesById.get(t))return e;let a=new Set(n);return _d(e,t,e=>{let t=e.children.filter(e=>!a.has(e.id)),o=t.findIndex(e=>e.id===r);if(o===-1)if(a.has(r)){let n=e.children.findIndex(e=>e.id===r),a=new Map(e.children.map((e,t)=>[e.id,t]));i===`after`?(o=t.findIndex(e=>(a.get(e.id)??-1)>n),o===-1&&(o=t.length)):(o=t.findIndex(e=>(a.get(e.id)??-1)>=n),o===-1&&(o=t.length))}else o=i===`after`?t.length:0;else i===`after`&&o++;let s=n.map(t=>e.children.find(e=>e.id===t)).filter(e=>e!==void 0),c=[...t];return c.splice(o,0,...s),vd({...e,children:c})})}function Td(e,t){switch(t){case`string`:return e==null?``:typeof e==`object`?JSON.stringify(e):String(e);case`number`:{let t=Number(e);return isNaN(t)?0:t}case`boolean`:return!!e;case`null`:return null;case`object`:if(typeof e==`object`&&e&&!Array.isArray(e))return e;if(Array.isArray(e)){let t={};return e.forEach((e,n)=>{t[String(n)]=e}),t}return{};case`array`:return Array.isArray(e)?e:typeof e==`object`&&e?Object.values(e):e==null?[]:[e];default:return e}}function Ed(e,t,n){let r=e.nodesById.get(t);return r?yd(e,t,Td(fd(r),n)):e}function Dd(e,t){let n=e.nodesById.get(t);if(!n||!n.parentId||!e.nodesById.get(n.parentId))return e;let r=fd(n);return _d(e,n.parentId,e=>{let i=e.children.findIndex(e=>e.id===t),a=e.path===`/`?``:e.path,o=ud(e.type===`array`?String(i+1):`${n.key}_copy`,structuredClone(r),a,e.id,new Map),s=[...e.children];return s.splice(i+1,0,o),vd({...e,children:s})})}var Od=100,kd=class{constructor(){this.stack=[],this.cursor=-1}push(e){this.stack=this.stack.slice(0,this.cursor+1),this.stack.push(e),this.stack.length>Od?this.stack.shift():this.cursor++}undo(){return this.canUndo?(this.cursor--,this.stack[this.cursor]):null}redo(){return this.canRedo?(this.cursor++,this.stack[this.cursor]):null}get canUndo(){return this.cursor>0}get canRedo(){return this.cursor<this.stack.length-1}get current(){return this.stack[this.cursor]??null}};function Ad(e,t){if(!t.startsWith(`#/`))return;let n=t.slice(2).split(`/`),r=e;for(let e of n){if(typeof r!=`object`||!r)return;r=r[e]}return r}function jd(e,t,n){let r=n??new Set;if(e.$ref){if(r.has(e.$ref))return e;r.add(e.$ref);let n=Ad(t,e.$ref);return n?jd(n,t,r):e}return e.allOf&&e.allOf.length>0?Md(e,t,r):e}function Md(e,t,n){let r={...e};delete r.allOf;for(let i of e.allOf){let e=jd(i,t,new Set(n));e.type&&!r.type&&(r.type=e.type),e.properties&&(r.properties={...r.properties,...e.properties}),e.required&&(r.required=[...new Set([...r.required??[],...e.required])]),e.additionalProperties!==void 0&&r.additionalProperties===void 0&&(r.additionalProperties=e.additionalProperties),e.items&&!r.items&&(r.items=e.items),e.description&&!r.description&&(r.description=e.description),e.title&&!r.title&&(r.title=e.title),e.enum&&!r.enum&&(r.enum=e.enum),e.minimum!==void 0&&r.minimum===void 0&&(r.minimum=e.minimum),e.maximum!==void 0&&r.maximum===void 0&&(r.maximum=e.maximum),e.minLength!==void 0&&r.minLength===void 0&&(r.minLength=e.minLength),e.maxLength!==void 0&&r.maxLength===void 0&&(r.maxLength=e.maxLength),e.pattern&&!r.pattern&&(r.pattern=e.pattern),e.format&&!r.format&&(r.format=e.format)}return r}function Nd(e,t,n){let r=n??e,i=t.split(`/`).filter(Boolean),a=jd(e,r);for(let e of i){if(!a)return;if(a=jd(a,r),a.properties?.[e]){a=jd(a.properties[e],r);continue}if(a.patternProperties){let t=Object.entries(a.patternProperties).find(([t])=>{try{return new RegExp(t).test(e)}catch{return!1}});if(t){a=jd(t[1],r);continue}}if(a.additionalProperties&&typeof a.additionalProperties==`object`){a=jd(a.additionalProperties,r);continue}if(a.items)if(Array.isArray(a.items)){let t=Number(e);if(!isNaN(t)&&a.items[t]){a=jd(a.items[t],r);continue}}else{a=jd(a.items,r);continue}if(a.anyOf||a.oneOf){let t=a.anyOf??a.oneOf??[],n;for(let i of t)if(n=Nd(jd(i,r),e,r),n)break;if(n){a=n;continue}return}return}return a}function Pd(e,t){if(!t.trim())return[];let n=[],r=t.toLowerCase();function i(e){e.key&&e.key.toLowerCase().includes(r)&&n.push({nodeId:e.id,field:`key`}),e.value!==void 0&&e.value!==null&&String(e.value).toLowerCase().includes(r)&&n.push({nodeId:e.id,field:`value`});for(let t of e.children)i(t)}return i(e.root),n}function Fd(e,t){let n=new Set;for(let r of t){let t=e.nodesById.get(r);for(;t&&t.parentId;)n.add(t.parentId),t=e.nodesById.get(t.parentId)}return n}function Id(e,t,n=``){let r=[];if(e===t)return r;if(e===null||t===null||typeof e!=typeof t||Array.isArray(e)!==Array.isArray(t))return n?r.push({path:n,type:`changed`,oldValue:e,newValue:t}):Ld(e,t,n,r),r;if(typeof e!=`object`)return e!==t&&r.push({path:n||`/`,type:`changed`,oldValue:e,newValue:t}),r;if(Array.isArray(e)&&Array.isArray(t)){let i=Math.max(e.length,t.length);for(let a=0;a<i;a++){let i=n?`${n}/${a}`:`/${a}`;a>=e.length?r.push({path:i,type:`added`,newValue:t[a]}):a>=t.length?r.push({path:i,type:`removed`,oldValue:e[a]}):r.push(...Id(e[a],t[a],i))}return r}return Ld(e,t,n,r),r}function Ld(e,t,n,r){let i=typeof e==`object`&&e&&!Array.isArray(e)?e:{},a=typeof t==`object`&&t&&!Array.isArray(t)?t:{},o=new Set([...Object.keys(i),...Object.keys(a)]);for(let e of o){let t=n?`${n}/${e}`:`/${e}`,o=e in i,s=e in a;!o&&s?r.push({path:t,type:`added`,newValue:a[e]}):o&&!s?r.push({path:t,type:`removed`,oldValue:i[e]}):r.push(...Id(i[e],a[e],t))}}function Rd(e,t){let n=[];function r(e){if(n.push(e),t(e.id)&&(e.type===`object`||e.type===`array`))for(let t of e.children)r(t)}return r(e),n}var zd=[`name`,`type`,`title`,`id`,`label`,`key`];function Bd(e,t){if(e.parentId===null)return`/`;if(t.nodesById.get(e.parentId)?.type!==`array`||e.type!==`object`)return e.key;for(let t of zd){let n=e.children.find(e=>e.key===t);if(n?.value!=null&&n.value!==``)return String(n.value)}return e.key}function Vd(e){let t=[e.id];for(let n of e.children)t.push(...Vd(n));return t}var Hd={"--vj-bg":`#1e1e1e`,"--vj-bg-panel":`#252526`,"--vj-bg-hover":`#2a2d2e`,"--vj-bg-selected":`#2a5a1e`,"--vj-bg-selected-muted":`#2a2d2e`,"--vj-bg-match":`#3a3520`,"--vj-bg-match-active":`#51502b`,"--vj-border":`#333333`,"--vj-border-subtle":`#2a2a2a`,"--vj-text":`#cccccc`,"--vj-text-muted":`#888888`,"--vj-text-dim":`#666666`,"--vj-text-dimmer":`#555555`,"--vj-string":`#ce9178`,"--vj-number":`#b5cea8`,"--vj-boolean":`#569cd6`,"--vj-accent":`#007acc`,"--vj-accent-muted":`#094771`,"--vj-input-bg":`#3c3c3c`,"--vj-input-border":`#555555`,"--vj-error":`#f48771`,"--vj-font":`monospace`,"--vj-input-font-size":`13px`},Ud=Object.freeze(new Set),Wd=()=>({draggedNodeIds:Ud,dropTargetNodeId:null,dropPosition:null});function Gd(e,t){let n=[];function r(e){t.has(e.id)&&n.push(e.id);for(let t of e.children)r(t)}return r(e),n}function Kd(e,t){let{draggedNodeIds:n,dropTargetNodeId:r,dropPosition:i}=t;if(n.size===0||!r||!i)return null;let a=e.nodesById.get(r);if(!a||!a.parentId)return null;for(let t of n)if(md(e,r,t))return null;let o=a.parentId,s=e.nodesById.get(o);if(!s)return null;let c=s.children.filter(e=>n.has(e.id)).map(e=>e.id);if(c.length===n.size&&[...n].every(t=>e.nodesById.get(t)?.parentId===o))return wd(e,o,c,r,i);let l=Gd(e.root,n),u=l.map(t=>e.nodesById.get(t)).filter(e=>!!e&&e.parentId!==null).map(e=>structuredClone(e)),d=e;for(let e of[...l].reverse())d.nodesById.has(e)&&(d=Cd(d,e));let f=d.nodesById.get(r);if(!f||!f.parentId)return null;let p=d.nodesById.get(f.parentId);if(!p)return null;let m=p.children.findIndex(e=>e.id===r);i===`after`&&m++;for(let e=0;e<u.length;e++)d=Sd(d,p.id,u[e],m+e);return d}function qd(e,t,n){let r=document.createElement(`div`);r.textContent=`${t} selected`;let i=document.querySelector(`[data-form-container], [role='tree']`),a=i?getComputedStyle(i):null,o=a?.getPropertyValue(`--vj-bg-selected`).trim()||Hd[`--vj-bg-selected`],s=a?.getPropertyValue(`--vj-text-selected`).trim()||a?.getPropertyValue(`--vj-text`).trim()||Hd[`--vj-text`],c=a?.getPropertyValue(`--vj-font`).trim()||Hd[`--vj-font`];r.style.cssText=[`position:fixed`,`top:-1000px`,`left:-1000px`,`padding:4px 12px`,`background:${o}`,`color:${s}`,`font-family:${c}`,`font-size:13px`,`border-radius:4px`,`white-space:nowrap`,`pointer-events:none`].join(`;`),document.body.appendChild(r),e.setDragImage(r,0,14),requestAnimationFrame(()=>r.remove())}var Jd={added:{bg:`#1e3a1e`,marker:`+`,label:`#4ec94e`},removed:{bg:`#3a1e1e`,marker:`-`,label:`#f48771`},changed:{bg:`#3a3a1e`,marker:`~`,label:`#dcdcaa`}};function Yd(e){if(e===void 0)return``;if(e===null)return`null`;if(typeof e==`string`)return JSON.stringify(e);if(typeof e==`object`){let t=JSON.stringify(e,null,2);return t.length>80?JSON.stringify(e).slice(0,77)+`...`:t}return String(e)}function Xd(e,t,n){if(!e)return;let r=Nd(e,n,t);if(r)return jd(r,t??e)}function Zd(e){return e.type===`boolean`||e.type===`null`?`var(--vj-boolean, #569cd6)`:e.type===`number`?`var(--vj-number, #b5cea8)`:`var(--vj-string, #ce9178)`}function Qd(e){return e.type===`null`?`null`:e.type===`boolean`?String(e.value):e.value===null||e.value===void 0?``:String(e.value)}function $d(e,t,n){return!t||!e.parentId?!1:(Xd(t,n,e.path.split(`/`).slice(0,-1).join(`/`)||`/`)?.required)?.includes(e.key)??!1}function ef(e,t,n){let r=Array.isArray(t)?t[0]:t;if(r===`boolean`||e===`true`||e===`false`)return e===`true`;if(e===`null`)return null;if(r===`number`||r===`integer`||n===`number`){let t=Number(e);return isNaN(t)?e:t}return e}var tf=Symbol(`StudioContext`);function nf(e,t,n){if(!t)return null;let r=e.nodesById.get(t);if(!r)return null;for(;r;){let t=r.parentId?e.nodesById.get(r.parentId):void 0,i=t?t.children:[e.root],a=new Set(i.map(e=>e.id));if(!i.every(e=>n.has(e.id))||!t||!t.parentId)return a;r=t}return null}function rf(e,t,n){let r=e.findIndex(e=>e.id===t),i=e.findIndex(e=>e.id===n);if(r===-1||i===-1)return null;let a=Math.min(r,i),o=Math.max(r,i),s=new Set;for(let t=a;t<=o;t++)s.add(e[t].id);return s}function af(e,t,n){let r=[...t].filter(n=>{let r=e.nodesById.get(n);if(!r||r.parentId===null)return!1;let i=e.nodesById.get(r.parentId);for(;i;){if(t.has(i.id))return!1;i=i.parentId?e.nodesById.get(i.parentId):void 0}return!0});if(r.length===0)return{newTree:e,nextFocusId:null};let i=n.findIndex(e=>t.has(e.id)),a=e;for(let e of r)a.nodesById.has(e)&&(a=Cd(a,e));let o=null;for(let e=i;e<n.length;e++){let r=n[e].id;if(!t.has(r)&&a.nodesById.has(r)){o=r;break}}if(!o)for(let e=i-1;e>=0;e--){let r=n[e].id;if(!t.has(r)&&a.nodesById.has(r)){o=r;break}}return{newTree:a,nextFocusId:o}}var of=z({__name:`VisualJson`,props:{value:{type:[String,Number,Boolean,null,Array,Object]},schema:{default:null}},emits:[`change`],setup(e,{emit:t}){let n=e,r=t,i=I(dd(n.value)),a=I(null),o=I(new Set),s=I(null),c=I(null),l=I(new Set([i.value.root.id])),u=q(()=>Rd(i.value.root,e=>l.value.has(e))),d=null,f=new kd,p=I(0),m=q(()=>(p.value,f.canUndo)),h=q(()=>(p.value,f.canRedo)),g=I(``),_=I([]),v=I(0),y=q(()=>new Set(_.value.map(e=>e.nodeId))),b=!1;f.push(i.value);function x(e){a.value=e,o.value=e?new Set([e]):new Set,s.value=e,c.value=e}R(()=>n.value,e=>{if(b){b=!1;return}let t=dd(e);i.value=t,l.value=new Set([t.root.id]),x(null),f=new kd,f.push(t),p.value++,g.value=``,_.value=[],v.value=0},{flush:`sync`}),R(i,e=>{if(!g.value.trim())return;let t=Pd(e,g.value);_.value=t,v.value=Math.min(v.value,Math.max(t.length-1,0))},{flush:`sync`});function S(e){i.value=e,f.push(e),p.value++,b=!0,r(`change`,fd(e.root))}function C(){let e=f.undo();e&&(i.value=e,p.value++,b=!0,r(`change`,fd(e.root)))}function w(){let e=f.redo();e&&(i.value=e,p.value++,b=!0,r(`change`,fd(e.root)))}function T(e){let t=e.metaKey||e.ctrlKey;t&&e.key===`z`&&!e.shiftKey?(e.preventDefault(),C()):(t&&e.key===`z`&&e.shiftKey||t&&e.key===`y`)&&(e.preventDefault(),w())}return Ir(()=>document.addEventListener(`keydown`,T)),Br(()=>document.removeEventListener(`keydown`,T)),Bn(tf,{state:{tree:i,focusedNodeId:a,selectedNodeIds:o,anchorNodeId:s,drillDownNodeId:c,expandedNodeIds:l,schema:q(()=>n.schema??null),searchQuery:g,searchMatches:_,searchMatchIndex:v,searchMatchNodeIds:y,canUndo:m,canRedo:h},actions:{setTree:S,selectNode(e){a.value=e,o.value=e?new Set([e]):new Set,s.value=e},selectAndDrillDown:x,toggleNodeSelection(e){let t=new Set(o.value);t.has(e)?t.delete(e):t.add(e),o.value=t,t.size===0?(a.value=null,s.value=null):(a.value=e,s.value=e)},selectNodeRange(e){let t=d??u.value,n=s.value;if(!n){a.value=e,o.value=new Set([e]),s.value=e;return}let r=rf(t,n,e);if(!r){a.value=e,o.value=new Set([e]),s.value=e;return}o.value=r,a.value=e},setSelection(e,t,n){a.value=e,o.value=t,s.value=n},setVisibleNodesOverride(e){d=e},drillDown(e){c.value=e},toggleExpand(e){let t=new Set(l.value);t.has(e)?t.delete(e):t.add(e),l.value=t},expandNode(e){let t=new Set(l.value);t.add(e),l.value=t},collapseNode(e){let t=new Set(l.value);t.delete(e),l.value=t},expandAll(){l.value=new Set(Vd(i.value.root))},collapseAll(){l.value=new Set([i.value.root.id])},undo:C,redo:w,setSearchQuery(e){if(g.value=e,!e.trim()){_.value=[],v.value=0;return}let t=Pd(i.value,e);if(_.value=t,v.value=0,t.length>0){let e=Fd(i.value,t.map(e=>e.nodeId)),n=new Set(l.value);for(let t of e)n.add(t);l.value=n,x(t[0].nodeId)}},nextSearchMatch(){if(_.value.length===0)return;let e=(v.value+1)%_.value.length;v.value=e,x(_.value[e].nodeId)},prevSearchMatch(){if(_.value.length===0)return;let e=(v.value-1+_.value.length)%_.value.length;v.value=e,x(_.value[e].nodeId)}}}),(e,t)=>Qr(e.$slots,`default`)}});function sf(){let e=Vn(tf);if(!e)throw Error(`useStudio must be used within a <VisualJson> provider`);return e}function cf(e,t){let{state:n,actions:r}=sf(),i=I(Wd());function a(e){let n;n=t.value.size>0&&t.value.has(e)?t.value:new Set([e]),i.value={draggedNodeIds:n,dropTargetNodeId:null,dropPosition:null}}function o(e,t){let r=i.value.draggedNodeIds;for(let t of r)if(e===t||md(n.tree.value,e,t))return;i.value={...i.value,dropTargetNodeId:e,dropPosition:t}}function s(t,n){if(n===`before`){let n=e.value.findIndex(e=>e.id===t);if(n>0){o(e.value[n-1].id,`after`);return}}o(t,n)}function c(){i.value=Wd()}function l(){let e=Kd(n.tree.value,i.value);e&&r.setTree(e),i.value=Wd()}return{dragState:i,handleDragStart:a,handleDragOver:s,handleDragEnd:c,handleDrop:l}}var lf=[`aria-selected`,`aria-expanded`,`draggable`,`data-node-id`],uf=[`aria-label`],df={key:1,style:{width:`16px`,flexShrink:0}},ff=z({__name:`TreeNodeRow`,props:{node:{},depth:{},dragState:{},showValues:{type:Boolean},showCounts:{type:Boolean},isFocused:{type:Boolean}},emits:[`dragStart`,`dragOver`,`dragEnd`,`drop`,`contextMenu`,`selectRange`],setup(e,{emit:t}){let n=e,r=t,{state:i,actions:a}=sf(),o=I(!1);function s(){return i.selectedNodeIds.value.has(n.node.id)}function c(){return i.expandedNodeIds.value.has(n.node.id)}let l=n.node.type===`object`||n.node.type===`array`,u=n.node.parentId===null;function d(){return i.searchMatchNodeIds.value.has(n.node.id)}function f(){return i.searchMatches.value.length>0&&i.searchMatches.value[i.searchMatchIndex.value]?.nodeId===n.node.id}function p(){return l?n.node.type===`array`?`[${n.node.children.length}]`:`{${n.node.children.length}}`:n.node.value===null?`null`:typeof n.node.value==`string`?n.node.value:String(n.node.value)}function m(e){e.preventDefault();let t=e.currentTarget.getBoundingClientRect(),i=t.top+t.height/2,a=e.clientY<i?`before`:`after`;r(`dragOver`,n.node.id,a)}function h(){return n.dragState.dropTargetNodeId===n.node.id&&n.dragState.dropPosition===`before`?`var(--vj-accent, #007acc)`:`transparent`}function g(){return n.dragState.dropTargetNodeId===n.node.id&&n.dragState.dropPosition===`after`?`var(--vj-accent, #007acc)`:`transparent`}function _(){let e=s(),t=f(),r=d(),i=o.value;return e?n.isFocused?`var(--vj-bg-selected, #2a5a1e)`:`var(--vj-bg-selected-muted, var(--vj-bg-hover, #2a2d2e))`:t?`var(--vj-bg-match-active, #51502b)`:r?`var(--vj-bg-match, #3a3520)`:i?`var(--vj-bg-hover, #2a2d2e)`:`transparent`}function v(e){e.shiftKey?r(`selectRange`,n.node.id):e.metaKey||e.ctrlKey?a.toggleNodeSelection(n.node.id):a.selectAndDrillDown(n.node.id)}function y(e){e.dataTransfer.effectAllowed=`move`,i.selectedNodeIds.value.size>1&&i.selectedNodeIds.value.has(n.node.id)&&qd(e.dataTransfer,i.selectedNodeIds.value.size),r(`dragStart`,n.node.id)}return(t,n)=>(V(),H(B,null,[U(`div`,{role:`treeitem`,"aria-selected":s(),"aria-expanded":L(l)?c():void 0,draggable:!u,"data-node-id":e.node.id,style:M({display:`flex`,alignItems:`center`,gap:`6px`,padding:`1px 8px`,paddingLeft:8+e.depth*16+`px`,cursor:`pointer`,backgroundColor:_(),minHeight:`28px`,userSelect:`none`,opacity:e.dragState.draggedNodeIds.has(e.node.id)?.4:1,borderTop:`2px solid ${h()}`,borderBottom:`2px solid ${g()}`,boxSizing:`border-box`,color:s()&&e.isFocused?`var(--vj-text-selected, var(--vj-text, #cccccc))`:`var(--vj-text, #cccccc)`}),onClick:v,onMouseenter:n[1]||=()=>o.value=!0,onMouseleave:n[2]||=()=>o.value=!1,onContextmenu:n[3]||=t=>r(`contextMenu`,t,e.node),onDragstart:y,onDragover:m,onDragend:n[4]||=()=>r(`dragEnd`),onDrop:n[5]||=ws(()=>r(`drop`),[`prevent`])},[L(l)?(V(),H(`button`,{key:0,"aria-label":c()?`Collapse`:`Expand`,style:M({background:`none`,border:`none`,color:`inherit`,cursor:`pointer`,padding:0,width:`16px`,fontSize:`9px`,flexShrink:0,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,transition:`transform 0.15s`,transform:c()?`rotate(90deg)`:`rotate(0deg)`}),onClick:n[0]||=ws(()=>L(a).toggleExpand(e.node.id),[`stop`])},` ▶ `,12,uf)):(V(),H(`span`,df)),U(`span`,{style:M({color:`inherit`,fontSize:`13px`,fontFamily:`var(--vj-font, monospace)`,flexShrink:0,fontWeight:u?600:400})},P(u?`/`:L(Bd)(e.node,L(i).tree.value)),5),!u&&L(l)&&e.showCounts?(V(),H(`span`,{key:2,style:M({color:s()?`inherit`:`var(--vj-text-muted, #888888)`,fontSize:`13px`,fontFamily:`var(--vj-font, monospace)`,whiteSpace:`nowrap`,marginLeft:`auto`})},P(p()),5)):K(``,!0),!u&&!L(l)&&e.showValues?(V(),H(`span`,{key:3,style:M({color:e.node.type===`string`?`var(--vj-string, #ce9178)`:`var(--vj-number, #b5cea8)`,fontSize:`13px`,fontFamily:`var(--vj-font, monospace)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,marginLeft:`auto`})},P(p()),5)):K(``,!0)],44,lf),c()?(V(!0),H(B,{key:0},Zr(e.node.children,t=>(V(),wa(ff,{key:t.id,node:t,depth:e.depth+1,"drag-state":e.dragState,"show-values":e.showValues,"show-counts":e.showCounts,"is-focused":e.isFocused,onDragStart:n[6]||=e=>r(`dragStart`,e),onDragOver:n[7]||=(e,t)=>r(`dragOver`,e,t),onDragEnd:n[8]||=()=>r(`dragEnd`),onDrop:n[9]||=()=>r(`drop`),onContextMenu:n[10]||=(e,t)=>r(`contextMenu`,e,t),onSelectRange:n[11]||=e=>r(`selectRange`,e)},null,8,[`node`,`depth`,`drag-state`,`show-values`,`show-counts`,`is-focused`]))),128)):K(``,!0)],64))}}),pf={key:0,style:{height:`1px`,backgroundColor:`var(--vj-border, #454545)`,margin:`4px 0`}},mf=[`disabled`,`onClick`,`onMouseenter`],hf=z({__name:`ContextMenu`,props:{x:{},y:{},items:{}},emits:[`close`],setup(e,{emit:t}){let n=e,r=t,i=I(null),a=I({left:n.x,top:n.y});R(()=>[n.x,n.y],async()=>{if(await Tn(),!i.value)return;let e=i.value.getBoundingClientRect(),t=window.innerWidth,r=window.innerHeight;a.value={left:e.right>t?Math.max(0,n.x-e.width):n.x,top:e.bottom>r?Math.max(0,n.y-e.height):n.y}},{immediate:!0});function o(e){i.value&&!i.value.contains(e.target)&&r(`close`)}function s(e){e.key===`Escape`&&r(`close`)}return Ir(async()=>{if(await Tn(),i.value){let e=i.value.getBoundingClientRect(),t=window.innerWidth,r=window.innerHeight;a.value={left:e.right>t?Math.max(0,n.x-e.width):n.x,top:e.bottom>r?Math.max(0,n.y-e.height):n.y}}document.addEventListener(`mousedown`,o),document.addEventListener(`keydown`,s)}),Br(()=>{document.removeEventListener(`mousedown`,o),document.removeEventListener(`keydown`,s)}),(t,n)=>(V(),wa(ir,{to:`body`},[U(`div`,{ref_key:`menuRef`,ref:i,style:M({position:`fixed`,left:a.value.left+`px`,top:a.value.top+`px`,zIndex:1e4,backgroundColor:`var(--vj-bg-panel, #252526)`,border:`1px solid var(--vj-border, #454545)`,borderRadius:`4px`,boxShadow:`0 4px 12px rgba(0,0,0,0.5)`,padding:`4px 0`,minWidth:`160px`})},[(V(!0),H(B,null,Zr(e.items,(e,t)=>(V(),H(B,{key:t},[`separator`in e&&e.separator?(V(),H(`div`,pf)):`label`in e?(V(),H(`button`,{key:1,disabled:e.disabled,style:M({display:`block`,width:`100%`,textAlign:`left`,background:`none`,border:`none`,color:e.disabled?`var(--vj-text-dimmer, #555555)`:`var(--vj-text, #cccccc)`,cursor:e.disabled?`default`:`pointer`,padding:`4px 16px`,fontSize:`12px`,fontFamily:`var(--vj-font, monospace)`}),onClick:()=>{e.disabled||(e.action(),r(`close`))},onMouseenter:t=>{e.disabled||(t.target.style.backgroundColor=`var(--vj-accent-muted, #094771)`)},onMouseleave:n[0]||=e=>{e.target.style.backgroundColor=`transparent`}},P(e.label),45,mf)):K(``,!0)],64))),128))],4)]))}}),gf=z({__name:`TreeView`,props:{class:{},showValues:{type:Boolean,default:!0},showCounts:{type:Boolean,default:!1}},setup(e){let t=e,{state:n,actions:r}=sf(),i=I(null),a=q(()=>Rd(n.tree.value.root,e=>n.expandedNodeIds.value.has(e))),{dragState:o,handleDragStart:s,handleDragOver:c,handleDragEnd:l,handleDrop:u}=cf(a,n.selectedNodeIds),d=I(null),f=I(!1);function p(e){r.setVisibleNodesOverride(a.value),r.selectNodeRange(e)}R(()=>n.focusedNodeId.value,e=>{if(e&&i.value){let t=i.value.querySelector(`[data-node-id="${e}"]`);t&&t.scrollIntoView({block:`nearest`})}});function m(e,t){e.preventDefault(),n.selectedNodeIds.value.has(t.id)||r.selectAndDrillDown(t.id),d.value={x:e.clientX,y:e.clientY,node:t}}function h(e){let t=[];if((e.type===`object`||e.type===`array`)&&(t.push({label:`Expand all children`,action:()=>{function t(e){let n=[e.id];for(let r of e.children)n.push(...t(r));return n}for(let n of t(e))r.expandNode(n)}}),t.push({label:`Collapse all children`,action:()=>{function t(e){let n=[];for(let r of e.children)n.push(r.id),n.push(...t(r));return n}for(let n of t(e))r.collapseNode(n)}}),t.push({separator:!0})),t.push({label:`Copy path`,action:()=>navigator.clipboard.writeText(e.path).catch(()=>{})}),t.push({label:`Copy value as JSON`,action:()=>{let t=fd(e),n=typeof t==`string`?t:JSON.stringify(t,null,2);navigator.clipboard.writeText(n).catch(()=>{})}}),e.parentId){t.push({separator:!0}),t.push({label:`Duplicate`,action:()=>{let t=Dd(n.tree.value,e.id);r.setTree(t)}});let i=[`string`,`number`,`boolean`,`null`,`object`,`array`].filter(t=>t!==e.type).map(t=>({label:`Change to ${t}`,action:()=>{let i=Ed(n.tree.value,e.id,t);r.setTree(i)}}));t.push({separator:!0}),t.push(...i),t.push({separator:!0}),t.push({label:`Delete`,action:()=>{let{newTree:e,nextFocusId:t}=af(n.tree.value,n.selectedNodeIds.value,a.value);e!==n.tree.value&&(r.setTree(e),t?r.selectNode(t):r.setSelection(null,new Set,null))}})}return t}function g(e){let t=a.value.findIndex(e=>e.id===n.focusedNodeId.value);switch(e.key){case`ArrowDown`:{e.preventDefault();let n=a.value[t+1];n&&(e.shiftKey?p(n.id):r.selectNode(n.id));break}case`ArrowUp`:{e.preventDefault();let n=a.value[t-1];n&&(e.shiftKey?p(n.id):r.selectNode(n.id));break}case`ArrowRight`:{e.preventDefault();let i=t>=0?a.value[t]:null;i&&(i.type===`object`||i.type===`array`)&&(n.expandedNodeIds.value.has(i.id)?i.children.length>0&&r.selectNode(i.children[0].id):r.expandNode(i.id));break}case`ArrowLeft`:{e.preventDefault();let i=t>=0?a.value[t]:null;if(!i)break;(i.type===`object`||i.type===`array`)&&n.expandedNodeIds.value.has(i.id)?r.collapseNode(i.id):i.parentId&&r.selectNode(i.parentId);break}case`a`:if(e.metaKey||e.ctrlKey){e.preventDefault();let t=nf(n.tree.value,n.focusedNodeId.value,n.selectedNodeIds.value);t&&r.setSelection(n.focusedNodeId.value,t,n.focusedNodeId.value)}break;case`Escape`:e.preventDefault(),n.selectedNodeIds.value.size>1&&n.focusedNodeId.value?r.selectNode(n.focusedNodeId.value):r.setSelection(null,new Set,null);break;case`Delete`:case`Backspace`:{e.preventDefault();let{newTree:t,nextFocusId:i}=af(n.tree.value,n.selectedNodeIds.value,a.value);if(t===n.tree.value)break;r.setTree(t),i?r.selectNode(i):r.setSelection(null,new Set,null);break}}}return(e,r)=>(V(),H(B,null,[U(`div`,{ref_key:`containerRef`,ref:i,role:`tree`,tabindex:`0`,style:{overflow:`auto`,backgroundColor:`var(--vj-bg, #1e1e1e)`,color:`var(--vj-text, #cccccc)`,fontFamily:`var(--vj-font, monospace)`,fontSize:`13px`,outline:`none`,flex:1},onKeydown:g,onFocus:r[0]||=()=>f.value=!0,onBlur:r[1]||=()=>f.value=!1},[W(ff,{node:L(n).tree.value.root,depth:0,"drag-state":L(o),"show-values":t.showValues??!0,"show-counts":t.showCounts??!1,"is-focused":f.value,onDragStart:L(s),onDragOver:L(c),onDragEnd:L(l),onDrop:L(u),onContextMenu:m,onSelectRange:p},null,8,[`node`,`drag-state`,`show-values`,`show-counts`,`is-focused`,`onDragStart`,`onDragOver`,`onDragEnd`,`onDrop`])],544),d.value?(V(),wa(hf,{key:0,x:d.value.x,y:d.value.y,items:h(d.value.node),onClose:r[2]||=()=>d.value=null},null,8,[`x`,`y`,`items`])):K(``,!0)],64))}}),_f=Symbol(`FormViewContext`),vf=[`value`],yf=[`onMousedown`,`onMouseenter`],bf=20,xf=200,Sf=z({__name:`Breadcrumbs`,props:{class:{}},setup(e){let{state:t,actions:n}=sf(),r=q(()=>t.drillDownNodeId.value?t.tree.value.nodesById.get(t.drillDownNodeId.value):null),i=q(()=>r.value?.path??`/`),a=I(i.value),o=I(!1),s=I(0),c=I(null),l=I(null),u=I(null);R(i,e=>{a.value=e});let d=q(()=>{if(!o.value)return[];let e=a.value.toLowerCase(),n=[];for(let[r,i]of t.tree.value.nodesById)if(i.path.toLowerCase().startsWith(e)&&n.push({id:r,path:i.path}),n.length>=bf)break;return n.sort((e,t)=>e.path.localeCompare(t.path)),n});R(d,()=>{s.value=0}),R(()=>[s.value,o.value],([e,t])=>{let n=l.value;!n||!t||n.children[e]?.scrollIntoView({block:`nearest`})});function f(e){var r;for(let[r,i]of t.tree.value.nodesById)if(i.path===e){n.selectAndDrillDown(r);break}o.value=!1,(r=c.value)==null||r.blur()}function p(e){var t;if(!o.value){(e.key===`ArrowDown`||e.key===`Enter`)&&(o.value=!0,e.preventDefault());return}switch(e.key){case`ArrowDown`:e.preventDefault(),s.value=Math.min(s.value+1,d.value.length-1);break;case`ArrowUp`:e.preventDefault(),s.value=Math.max(s.value-1,0);break;case`Enter`:e.preventDefault(),d.value.length>0&&s.value<d.value.length?f(d.value[s.value].path):f(a.value.trim()||`/`);break;case`Escape`:e.preventDefault(),a.value=i.value,o.value=!1,(t=c.value)==null||t.blur();break}}function m(e){u.value&&!u.value.contains(e.target)&&(a.value=i.value,o.value=!1)}return Ir(()=>document.addEventListener(`mousedown`,m)),Br(()=>document.removeEventListener(`mousedown`,m)),(e,t)=>(V(),H(`div`,{ref_key:`wrapperRef`,ref:u,style:{position:`relative`,flex:1,minWidth:0}},[U(`input`,{ref_key:`inputRef`,ref:c,value:a.value,spellcheck:`false`,autocomplete:`off`,style:{width:`100%`,boxSizing:`border-box`,padding:`3px 0`,fontSize:`var(--vj-input-font-size, 13px)`,fontFamily:`var(--vj-font, monospace)`,color:`var(--vj-text-muted, #999999)`,background:`transparent`,border:`none`,outline:`none`},onInput:t[0]||=e=>{a.value=e.target.value,o.value||=!0},onFocus:t[1]||=e=>{e.target.select(),o.value=!0},onKeydown:p},null,40,vf),o.value&&d.value.length>0?(V(),H(`div`,{key:0,ref_key:`listRef`,ref:l,style:M({position:`absolute`,top:`100%`,left:`-12px`,right:`-12px`,zIndex:50,maxHeight:xf+`px`,overflowY:`auto`,backgroundColor:`var(--vj-bg-panel, #252526)`,border:`1px solid var(--vj-border, #333333)`,boxShadow:`0 4px 12px rgba(0,0,0,0.3)`})},[(V(!0),H(B,null,Zr(d.value,(e,t)=>(V(),H(`div`,{key:e.id,style:M({padding:`4px 12px`,fontSize:`13px`,fontFamily:`var(--vj-font, monospace)`,color:t===s.value?`var(--vj-text, #cccccc)`:`var(--vj-text-muted, #888888)`,backgroundColor:t===s.value?`var(--vj-bg-hover, #2a2d2e)`:`transparent`,cursor:`pointer`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`}),onMousedown:ws(()=>f(e.path),[`prevent`]),onMouseenter:()=>s.value=t},P(e.path),45,yf))),128))],4)):K(``,!0)],512))}}),Cf=[`value`],wf=[`onMousedown`,`onMouseenter`],Tf={style:{width:`14px`,flexShrink:0,fontSize:`12px`}},Ef=200,Df=z({__name:`EnumInput`,props:ai({enumValues:{},value:{},inputStyle:{}},{inputRef:{},inputRefModifiers:{}}),emits:ai([`valueChange`],[`update:inputRef`]),setup(e,{expose:t,emit:n}){let r=e,i=n;Ti(e,`inputRef`);let a=I(r.value),o=I(!1),s=I(0),c=I(null),l=I(null),u=I(null);R(()=>r.value,e=>{a.value=e});let d=q(()=>r.enumValues.map(e=>String(e)));R(d,()=>{s.value=0}),R(()=>[s.value,o.value],([e,t])=>{let n=c.value;!n||!t||n.children[e]?.scrollIntoView({block:`nearest`})});function f(e){i(`valueChange`,e),a.value=e,o.value=!1}function p(e){if(!o.value){(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),e.stopPropagation(),o.value=!0);return}switch(e.key){case`ArrowDown`:e.preventDefault(),e.stopPropagation(),s.value=Math.min(s.value+1,d.value.length-1);break;case`ArrowUp`:e.preventDefault(),e.stopPropagation(),s.value=Math.max(s.value-1,0);break;case`Enter`:e.preventDefault(),e.stopPropagation(),d.value.length>0&&s.value<d.value.length&&f(d.value[s.value]);break;case`Escape`:e.preventDefault(),e.stopPropagation(),a.value=r.value,o.value=!1;break;case`Tab`:a.value=r.value,o.value=!1;break}}function m(e){l.value&&!l.value.contains(e.target)&&(a.value=r.value,o.value=!1)}return Ir(()=>document.addEventListener(`mousedown`,m)),Br(()=>document.removeEventListener(`mousedown`,m)),t({focus:()=>u.value?.focus()}),(t,n)=>(V(),H(`div`,{ref_key:`wrapperRef`,ref:l,style:{position:`relative`,flex:1,minWidth:0}},[U(`input`,{ref_key:`localInputRef`,ref:u,value:a.value,spellcheck:`false`,autocomplete:`off`,style:M(e.inputStyle),onInput:n[0]||=e=>{a.value=e.target.value,o.value||=!0},onFocus:n[1]||=()=>o.value=!0,onKeydown:p,onClick:n[2]||=ws(()=>{},[`stop`])},null,44,Cf),o.value&&d.value.length>0?(V(),H(`div`,{key:0,ref_key:`listRef`,ref:c,style:M({position:`absolute`,top:`calc(100% + 4px)`,left:`-32px`,right:0,zIndex:50,maxHeight:Ef+`px`,overflowY:`auto`,backgroundColor:`var(--vj-bg-panel, #252526)`,border:`1px solid var(--vj-border, #333333)`,boxShadow:`0 4px 12px rgba(0,0,0,0.3)`})},[(V(!0),H(B,null,Zr(d.value,(t,n)=>(V(),H(`div`,{key:t,style:M({padding:`4px 12px`,fontSize:`13px`,fontFamily:`var(--vj-font, monospace)`,display:`flex`,alignItems:`center`,gap:`6px`,color:n===s.value?`var(--vj-text, #cccccc)`:`var(--vj-text-muted, #888888)`,backgroundColor:n===s.value?`var(--vj-bg-hover, #2a2d2e)`:`transparent`,cursor:`pointer`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`}),onMousedown:ws(()=>f(t),[`prevent`]),onMouseenter:()=>s.value=n},[U(`span`,Tf,P(t===e.value?`✓`:``),1),G(` `+P(t),1)],44,wf))),128))],4)):K(``,!0)],512))}}),Of={key:0},kf=[`data-form-node-id`,`draggable`],Af=[`value`],jf={key:2,style:{color:`var(--vj-text-muted, #888888)`,fontSize:`11px`,fontFamily:`var(--vj-font, monospace)`}},Mf={key:1},Nf=[`data-form-node-id`,`draggable`],Pf=[`value`],Ff={key:2,style:{color:`var(--vj-error, #f48771)`,fontSize:`10px`,fontFamily:`var(--vj-font, monospace)`}},If={key:3,style:{flex:1,display:`flex`,alignItems:`center`,gap:`6px`,minWidth:0}},Lf={key:2,style:{color:`var(--vj-boolean, #569cd6)`,fontFamily:`var(--vj-font, monospace)`,fontSize:`var(--vj-input-font-size, 13px)`,fontStyle:`italic`,flex:1}},Rf=[`value`,`placeholder`],zf=z({__name:`FormField`,props:{node:{},depth:{}},setup(e){let t=e,n=Vn(_f),{state:r,actions:i}=sf(),a=I(!1),o=I(null),s=I(null);function c(){o.value&&typeof o.value.focus==`function`&&o.value.focus()}let l=q(()=>t.node.type===`object`||t.node.type===`array`),u=q(()=>t.node.parentId===null),d=q(()=>r.selectedNodeIds.value.has(t.node.id)),f=q(()=>n.editingNodeId.value===t.node.id),p=q(()=>n.collapsedIds.value.has(t.node.id)),m=q(()=>t.node.parentId?r.tree.value.nodesById.get(t.node.parentId)?.type===`object`:!1),h=q(()=>Xd(n.schema.value,n.rootSchema.value,t.node.path)),g=q(()=>$d(t.node,n.schema.value,n.rootSchema.value)),_=q(()=>h.value?.description),v=q(()=>h.value?.deprecated),y=q(()=>h.value?.title),b=q(()=>n.dragState.value.dropTargetNodeId===t.node.id),x=q(()=>n.dragState.value.draggedNodeIds.has(t.node.id));function S(){return b.value&&n.dragState.value.dropPosition===`before`?`var(--vj-accent, #007acc)`:`transparent`}function C(){return b.value&&n.dragState.value.dropPosition===`after`?`var(--vj-accent, #007acc)`:`transparent`}function w(){return d.value?n.isFocused.value?`var(--vj-bg-selected, #2a5a1e)`:`var(--vj-bg-selected-muted, var(--vj-bg-hover, #2a2d2e))`:a.value?`var(--vj-bg-hover, #2a2d2e)`:`transparent`}function T(){return d.value&&n.isFocused.value?`var(--vj-text-selected, var(--vj-text, #cccccc))`:`var(--vj-text, #cccccc)`}function ee(){return Zd(t.node)}function E(){return Qd(t.node)}function D(e){e.preventDefault();let r=e.currentTarget.getBoundingClientRect(),i=r.top+r.height/2;n.onDragOver(t.node.id,e.clientY<i?`before`:`after`)}function O(e){e.dataTransfer.effectAllowed=`move`,r.selectedNodeIds.value.size>1&&r.selectedNodeIds.value.has(t.node.id)&&qd(e.dataTransfer,r.selectedNodeIds.value.size),n.onDragStart(t.node.id)}function k(e){let n=ef(e,h.value?.type,t.node.type),a=yd(r.tree.value,t.node.id,n);i.setTree(a)}function te(e){let n=bd(r.tree.value,t.node.id,e);i.setTree(n)}function ne(){let e=Cd(r.tree.value,t.node.id);i.setTree(e)}function A(){let e=t.node.type===`array`?String(t.node.children.length):`newKey${t.node.children.length}`,n=xd(r.tree.value,t.node.id,e,``);i.setTree(n)}let re=q(()=>h.value?.enum&&h.value.enum.length>0),j=q(()=>`calc(${(n.maxDepth.value-t.depth)*16}px + ${n.maxKeyLength.value}ch)`);return R(f,async e=>{e&&(await Tn(),l.value?s.value&&s.value.focus():t.node.value!==null&&t.node.value!==void 0&&t.node.value!==``&&o.value?c():s.value&&s.value.focus())}),(t,i)=>{var b;return l.value?(V(),H(`div`,Of,[U(`div`,{"data-form-node-id":e.node.id,draggable:!u.value,style:M({display:`flex`,alignItems:`center`,gap:`6px`,padding:`1px 8px`,paddingLeft:8+e.depth*16+`px`,cursor:`pointer`,backgroundColor:w(),color:T(),height:`28px`,boxSizing:`border-box`,userSelect:`none`,opacity:v.value?.5:x.value?.4:1,borderTop:`2px solid ${S()}`,borderBottom:`2px solid ${C()}`}),onClick:i[3]||=ws(t=>L(n).onSelect(e.node.id,t),[`stop`]),onDblclick:i[4]||=()=>L(n).onToggleCollapse(e.node.id),onMouseenter:i[5]||=()=>a.value=!0,onMouseleave:i[6]||=()=>a.value=!1,onDragstart:O,onDragover:D,onDragend:i[7]||=()=>L(n).onDragEnd(),onDrop:i[8]||=ws(()=>L(n).onDrop(),[`prevent`])},[U(`button`,{style:M({background:`none`,border:`none`,color:`inherit`,cursor:`pointer`,padding:0,width:`16px`,fontSize:`9px`,flexShrink:0,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,transition:`transform 0.15s`,transform:p.value?`rotate(0deg)`:`rotate(90deg)`}),onClick:i[0]||=ws(()=>L(n).onToggleCollapse(e.node.id),[`stop`])},` ▶ `,4),f.value&&!u.value?(V(),H(`input`,{key:0,ref_key:`keyInputRef`,ref:s,value:e.node.key,style:M({background:`none`,border:`none`,color:`inherit`,fontFamily:`var(--vj-font, monospace)`,fontSize:`var(--vj-input-font-size, 13px)`,fontWeight:500,padding:0,outline:`none`,flexShrink:0,width:j.value}),onInput:i[1]||=e=>te(e.target.value),onClick:i[2]||=ws(()=>{},[`stop`])},null,44,Af)):(V(),H(`span`,{key:1,style:M({color:!u.value&&!m.value&&!d.value?`var(--vj-text-muted, #888888)`:`inherit`,fontSize:`var(--vj-input-font-size, 13px)`,fontFamily:`var(--vj-font, monospace)`,fontWeight:500,flexShrink:0,display:`inline-block`,width:j.value})},P(u.value?`/`:L(Bd)(e.node,L(r).tree.value)),5)),L(n).showDescriptions&&y.value&&!d.value?(V(),H(`span`,jf,P(y.value),1)):K(``,!0),a.value?(V(),H(`button`,{key:3,style:M({background:`none`,border:`none`,color:d.value?`inherit`:`var(--vj-text-muted, #888888)`,cursor:`pointer`,padding:0,fontSize:`12px`,fontFamily:`var(--vj-font, monospace)`}),onClick:ws(A,[`stop`])},` + Add `+P(e.node.type===`array`?`item`:`property`),5)):K(``,!0),L(n).showCounts?(V(),H(`span`,{key:4,style:M({color:d.value?`inherit`:`var(--vj-text-dim, #666666)`,fontSize:`12px`,fontFamily:`var(--vj-font, monospace)`,marginLeft:`auto`})},P(e.node.type===`array`?`${e.node.children.length} items`:`${e.node.children.length} properties`),5)):K(``,!0),!u.value&&f.value?(V(),H(`button`,{key:5,style:M({background:`none`,border:`none`,color:d.value?`inherit`:`var(--vj-text-muted, #888888)`,cursor:`pointer`,padding:`2px 4px`,fontSize:`14px`,fontFamily:`var(--vj-font, monospace)`,...L(n).showCounts?{}:{marginLeft:`auto`}}),title:`Remove`,onClick:ws(ne,[`stop`])},` × `,4)):K(``,!0)],44,kf),L(n).showDescriptions&&_.value?(V(),H(`div`,{key:0,style:M({padding:`2px 12px 4px`,paddingLeft:8+e.depth*16+22+`px`,fontSize:`11px`,color:`var(--vj-text-dim, #666666)`,fontFamily:`var(--vj-font, monospace)`})},P(_.value),5)):K(``,!0),p.value?K(``,!0):(V(),H(`div`,Mf,[(V(!0),H(B,null,Zr(e.node.children,t=>(V(),wa(zf,{key:t.id,node:t,depth:e.depth+1},null,8,[`node`,`depth`]))),128))]))])):(V(),H(`div`,{key:1,"data-form-node-id":e.node.id,draggable:!u.value,style:M({display:`flex`,alignItems:`center`,gap:`6px`,padding:`1px 8px`,paddingLeft:8+e.depth*16+`px`,cursor:`pointer`,backgroundColor:w(),color:T(),height:`28px`,boxSizing:`border-box`,userSelect:`none`,opacity:v.value?.5:x.value?.4:1,borderTop:`2px solid ${S()}`,borderBottom:`2px solid ${C()}`}),onClick:i[14]||=ws(t=>L(n).onSelect(e.node.id,t),[`stop`]),onDblclick:i[15]||=()=>L(n).onStartEditing(e.node.id),onMouseenter:i[16]||=()=>a.value=!0,onMouseleave:i[17]||=()=>a.value=!1,onDragstart:O,onDragover:D,onDragend:i[18]||=()=>L(n).onDragEnd(),onDrop:i[19]||=ws(()=>L(n).onDrop(),[`prevent`])},[i[20]||=U(`span`,{style:{width:`16px`,flexShrink:0}},null,-1),f.value&&m.value?(V(),H(`input`,{key:0,ref_key:`keyInputRef`,ref:s,value:e.node.key,style:M({background:`none`,border:`none`,color:`inherit`,fontFamily:`var(--vj-font, monospace)`,fontSize:`var(--vj-input-font-size, 13px)`,padding:0,flexShrink:0,outline:`none`,width:j.value}),onInput:i[9]||=e=>te(e.target.value),onClick:i[10]||=ws(()=>{},[`stop`]),onKeydown:i[11]||=e=>{e.key===`Tab`&&!e.shiftKey&&o.value&&(e.preventDefault(),c())}},null,44,Pf)):(V(),H(`span`,{key:1,style:M({color:!m.value&&!d.value?`var(--vj-text-muted, #888888)`:`inherit`,fontSize:`var(--vj-input-font-size, 13px)`,fontFamily:`var(--vj-font, monospace)`,flexShrink:0,display:`inline-block`,width:j.value})},P(L(Bd)(e.node,L(r).tree.value)),5)),g.value&&!d.value?(V(),H(`span`,Ff,` * `)):K(``,!0),f.value?(V(),H(`div`,If,[e.node.type===`boolean`?(V(),wa(Df,{key:0,ref_key:`valueInputRef`,ref:o,"enum-values":[`true`,`false`],value:String(e.node.value),"input-style":{background:`none`,border:`none`,fontFamily:`var(--vj-font, monospace)`,fontSize:`var(--vj-input-font-size, 13px)`,padding:`0`,flex:`1`,outline:`none`,color:ee()},onValueChange:k},null,8,[`value`,`input-style`])):re.value&&(b=h.value)!=null&&b.enum?(V(),wa(Df,{key:1,ref_key:`valueInputRef`,ref:o,"enum-values":h.value.enum,value:E(),"input-style":{background:`none`,border:`none`,fontFamily:`var(--vj-font, monospace)`,fontSize:`var(--vj-input-font-size, 13px)`,padding:`0`,flex:`1`,outline:`none`,color:ee()},onValueChange:k},null,8,[`enum-values`,`value`,`input-style`])):e.node.type===`null`?(V(),H(`span`,Lf,` null `)):(V(),H(`input`,{key:3,ref_key:`valueInputRef`,ref:o,value:E(),placeholder:h.value?.default===void 0?`<value>`:String(h.value.default),style:M({background:`none`,border:`none`,fontFamily:`var(--vj-font, monospace)`,fontSize:`var(--vj-input-font-size, 13px)`,padding:0,flex:1,outline:`none`,color:ee()}),onInput:i[12]||=e=>k(e.target.value),onClick:i[13]||=ws(()=>{},[`stop`])},null,44,Rf))])):(V(),H(`span`,{key:4,style:M({color:ee(),fontSize:`var(--vj-input-font-size, 13px)`,fontFamily:`var(--vj-font, monospace)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontStyle:e.node.type===`null`?`italic`:void 0})},P(E()),5)),f.value?(V(),H(`button`,{key:5,style:M({background:`none`,border:`none`,color:d.value?`inherit`:`var(--vj-text-muted, #888888)`,cursor:`pointer`,padding:`2px 4px`,fontSize:`14px`,fontFamily:`var(--vj-font, monospace)`,flexShrink:0}),title:`Remove`,onClick:ws(ne,[`stop`])},` × `,4)):K(``,!0)],44,Nf))}}}),Bf={style:{backgroundColor:`var(--vj-bg, #1e1e1e)`,color:`var(--vj-text, #cccccc)`,height:`100%`,fontFamily:`var(--vj-font, monospace)`,display:`flex`,flexDirection:`column`}},Vf={style:{display:`flex`,alignItems:`center`,padding:`4px 8px`,borderBottom:`1px solid var(--vj-border, #333333)`,backgroundColor:`var(--vj-bg, #1e1e1e)`,flexShrink:0}},Hf=z({__name:`FormView`,props:{class:{},showDescriptions:{type:Boolean,default:!1},showCounts:{type:Boolean,default:!1}},setup(e){let t=e,{state:n,actions:r}=sf(),i=I(null),a=I(!1),o=I(null),s=I(new Set),c=n.tree.value,l=q(()=>(n.drillDownNodeId.value?n.tree.value.nodesById.get(n.drillDownNodeId.value):null)??n.tree.value.root);R(()=>l.value.id,()=>{o.value=null,s.value=new Set});let u=q(()=>Rd(l.value,e=>!s.value.has(e))),{dragState:d,handleDragStart:f,handleDragOver:p,handleDragEnd:m,handleDrop:h}=cf(u,n.selectedNodeIds);Ir(()=>{r.setVisibleNodesOverride(u.value)}),Br(()=>{r.setVisibleNodesOverride(null)}),R(u,e=>{r.setVisibleNodesOverride(e)});let g=q(()=>{let e=1,t=0,r=l.value.path===`/`?0:l.value.path.split(`/`).filter(Boolean).length;for(let i of u.value){let a=i.parentId===null?`/`:Bd(i,n.tree.value);a.length>e&&(e=a.length);let o=(i.path===`/`?0:i.path.split(`/`).filter(Boolean).length)-r;o>t&&(t=o)}return{maxKeyLength:e,maxDepth:t}}),_=q(()=>g.value.maxKeyLength),v=q(()=>g.value.maxDepth),y=q(()=>n.schema.value),b=q(()=>n.schema.value??void 0);function x(e,t){o.value=null,t.shiftKey?(r.setVisibleNodesOverride(u.value),r.selectNodeRange(e)):t.metaKey||t.ctrlKey?r.toggleNodeSelection(e):r.selectNode(e)}function S(e){let t=new Set(s.value);t.has(e)?t.delete(e):t.add(e),s.value=t}function C(e){c=n.tree.value,o.value=e}function w(e){requestAnimationFrame(()=>{(i.value?.querySelector(`[data-form-node-id="${e}"]`))?.scrollIntoView({block:`nearest`})})}function T(e){var t,a;if(o.value){e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),r.setTree(c),o.value=null,(t=i.value)==null||t.focus()):e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),o.value=null,(a=i.value)==null||a.focus());return}let l=u.value.findIndex(e=>e.id===n.focusedNodeId.value);switch(l===-1&&u.value.length>0&&(l=0),e.key){case`ArrowDown`:{e.preventDefault();let t=u.value[l+1];t&&(e.shiftKey?(r.setVisibleNodesOverride(u.value),r.selectNodeRange(t.id)):r.selectNode(t.id),w(t.id));break}case`ArrowUp`:{e.preventDefault();let t=u.value[l-1];t&&(e.shiftKey?(r.setVisibleNodesOverride(u.value),r.selectNodeRange(t.id)):r.selectNode(t.id),w(t.id));break}case`ArrowRight`:{e.preventDefault();let t=l>=0?u.value[l]:null;if(t&&(t.type===`object`||t.type===`array`))if(s.value.has(t.id)){let e=new Set(s.value);e.delete(t.id),s.value=e}else t.children.length>0&&(r.selectNode(t.children[0].id),w(t.children[0].id));break}case`ArrowLeft`:{e.preventDefault();let t=l>=0?u.value[l]:null;if(!t)break;if((t.type===`object`||t.type===`array`)&&!s.value.has(t.id)){let e=new Set(s.value);e.add(t.id),s.value=e}else if(t.parentId){let e=u.value.find(e=>e.id===t.parentId);e&&(r.selectNode(e.id),w(e.id))}break}case`Enter`:e.preventDefault(),n.focusedNodeId.value&&(c=n.tree.value,r.selectNode(n.focusedNodeId.value),o.value=n.focusedNodeId.value);break;case`a`:if(e.metaKey||e.ctrlKey){e.preventDefault();let t=nf(n.tree.value,n.focusedNodeId.value,n.selectedNodeIds.value);t&&r.setSelection(n.focusedNodeId.value,t,n.focusedNodeId.value)}break;case`Escape`:e.preventDefault(),n.selectedNodeIds.value.size>1&&n.focusedNodeId.value?r.selectNode(n.focusedNodeId.value):r.setSelection(null,new Set,null);break;case`Delete`:case`Backspace`:{e.preventDefault();let{newTree:t,nextFocusId:i}=af(n.tree.value,n.selectedNodeIds.value,u.value);if(t===n.tree.value)break;r.setTree(t),i?r.selectNode(i):r.setSelection(null,new Set,null);break}}}return Bn(_f,{schema:y,rootSchema:b,showDescriptions:t.showDescriptions,showCounts:t.showCounts,editingNodeId:o,collapsedIds:s,maxKeyLength:_,maxDepth:v,isFocused:a,dragState:d,onSelect:x,onToggleCollapse:S,onStartEditing:C,onDragStart:f,onDragOver:p,onDragEnd:m,onDrop:h}),(e,t)=>(V(),H(`div`,Bf,[U(`div`,Vf,[W(Sf)]),U(`div`,{ref_key:`containerRef`,ref:i,"data-form-container":``,tabindex:`0`,style:{flex:1,overflow:`auto`,outline:`none`},onKeydown:T,onFocus:t[0]||=()=>a.value=!0,onBlur:t[1]||=e=>{e.currentTarget.contains(e.relatedTarget)||(a.value=!1)}},[W(zf,{node:l.value,depth:0},null,8,[`node`])],544)]))}}),Uf={style:{display:`flex`,alignItems:`center`,gap:`6px`,padding:`4px 8px`,backgroundColor:`var(--vj-bg, #1e1e1e)`,borderBottom:`1px solid var(--vj-border, #333333)`}},Wf=[`value`],Gf={style:{display:`flex`,alignItems:`center`,gap:`2px`,flexShrink:0,height:`18px`}},Kf=[`disabled`],qf=[`disabled`],Jf=z({__name:`SearchBar`,props:{class:{}},setup(e){let{state:t,actions:n}=sf(),r=I(null);function i(e){var t;e.key===`Enter`&&(e.preventDefault(),e.shiftKey?n.prevSearchMatch():n.nextSearchMatch()),e.key===`Escape`&&(e.preventDefault(),n.setSearchQuery(``),(t=r.value)==null||t.blur())}function a(e){var t,n;(e.metaKey||e.ctrlKey)&&e.key===`f`&&(e.preventDefault(),(t=r.value)==null||t.focus(),(n=r.value)==null||n.select())}return Ir(()=>document.addEventListener(`keydown`,a)),Br(()=>document.removeEventListener(`keydown`,a)),(e,a)=>(V(),H(`div`,Uf,[U(`input`,{ref_key:`inputRef`,ref:r,type:`text`,value:L(t).searchQuery.value,placeholder:`Search...`,spellcheck:`false`,autocomplete:`off`,style:{flex:1,background:`none`,border:`none`,borderRadius:`3px`,color:`var(--vj-text, #cccccc)`,fontFamily:`var(--vj-font, monospace)`,fontSize:`var(--vj-input-font-size, 13px)`,padding:`3px 8px`,outline:`none`,minWidth:0},onInput:a[0]||=e=>L(n).setSearchQuery(e.target.value),onKeydown:i},null,40,Wf),U(`div`,Gf,[L(t).searchQuery.value?(V(),H(B,{key:0},[U(`span`,{style:M({fontSize:`11px`,lineHeight:1,color:L(t).searchMatches.value.length>0?`var(--vj-text-muted, #999999)`:`var(--vj-error, #f48771)`,fontFamily:`var(--vj-font, monospace)`,whiteSpace:`nowrap`})},P(L(t).searchMatches.value.length>0?`${L(t).searchMatchIndex.value+1}/${L(t).searchMatches.value.length}`:`0/0`),5),U(`button`,{disabled:L(t).searchMatches.value.length===0,"aria-label":`Previous match (Shift+Enter)`,title:`Previous match (Shift+Enter)`,style:M({background:`none`,border:`none`,color:L(t).searchMatches.value.length>0?`var(--vj-text, #cccccc)`:`var(--vj-text-dimmer, #555555)`,cursor:L(t).searchMatches.value.length>0?`pointer`:`default`,padding:0,fontSize:`10px`,lineHeight:1,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`18px`,height:`18px`}),onClick:a[1]||=(...e)=>L(n).prevSearchMatch&&L(n).prevSearchMatch(...e)},` ▲ `,12,Kf),U(`button`,{disabled:L(t).searchMatches.value.length===0,"aria-label":`Next match (Enter)`,title:`Next match (Enter)`,style:M({background:`none`,border:`none`,color:L(t).searchMatches.value.length>0?`var(--vj-text, #cccccc)`:`var(--vj-text-dimmer, #555555)`,cursor:L(t).searchMatches.value.length>0?`pointer`:`default`,padding:0,fontSize:`10px`,lineHeight:1,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`18px`,height:`18px`}),onClick:a[2]||=(...e)=>L(n).nextSearchMatch&&L(n).nextSearchMatch(...e)},` ▼ `,12,qf),U(`button`,{"aria-label":`Clear search (Esc)`,title:`Clear search (Esc)`,style:{background:`none`,border:`none`,color:`var(--vj-text, #cccccc)`,cursor:`pointer`,padding:0,fontSize:`14px`,lineHeight:1,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`18px`,height:`18px`},onClick:a[3]||=()=>L(n).setSearchQuery(``)},` × `)],64)):(V(),H(B,{key:1},[U(`button`,{"aria-label":`Expand all`,title:`Expand all`,style:{background:`none`,border:`none`,color:`var(--vj-text-muted, #888888)`,cursor:`pointer`,padding:`2px`,fontSize:`12px`,lineHeight:1,display:`inline-flex`,alignItems:`center`},onClick:a[4]||=(...e)=>L(n).expandAll&&L(n).expandAll(...e)},[...a[6]||=[U(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`},[U(`path`,{d:`M8 2v4M5 4l3-2 3 2`}),U(`path`,{d:`M8 14v-4M5 12l3 2 3-2`}),U(`path`,{d:`M2 8h12`})],-1)]]),U(`button`,{"aria-label":`Collapse all`,title:`Collapse all`,style:{background:`none`,border:`none`,color:`var(--vj-text-muted, #888888)`,cursor:`pointer`,padding:`2px`,fontSize:`12px`,lineHeight:1,display:`inline-flex`,alignItems:`center`},onClick:a[5]||=(...e)=>L(n).collapseAll&&L(n).collapseAll(...e)},[...a[7]||=[U(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`},[U(`path`,{d:`M8 5V1M5 3l3 2 3-2`}),U(`path`,{d:`M8 11v4M5 13l3-2 3 2`}),U(`path`,{d:`M2 8h12`})],-1)]])],64))])]))}}),Yf={key:0,style:{flex:1,minHeight:0}},Xf={style:{display:`flex`,flexShrink:0,borderBottom:`1px solid var(--vj-border, #333333)`,backgroundColor:`var(--vj-bg-panel, #252526)`}},Zf={style:{flex:1,minHeight:0,overflow:`hidden`}},Qf={key:0,style:{display:`flex`,flexDirection:`column`,height:`100%`}},$f={style:{flex:1,minHeight:0,overflow:`auto`}},ep={key:1,style:{display:`flex`,flexDirection:`column`,height:`100%`}},tp={style:{flex:1,minHeight:0}},np={style:{flex:1,minHeight:0,overflow:`auto`}},rp={key:0,style:{width:`1px`,flexShrink:0,backgroundColor:`var(--vj-border, #333333)`,position:`relative`,transition:`background-color 0.15s`}},ip={style:{display:`flex`,flexDirection:`column`,flex:1,minWidth:0,overflow:`hidden`}},ap={style:{flex:1,minHeight:0}},op=z({__name:`JsonEditor`,props:{value:{type:[String,Number,Boolean,null,Array,Object]},defaultValue:{type:[String,Number,Boolean,null,Array,Object]},onChange:{},schema:{default:null},height:{default:`100%`},width:{default:`100%`},class:{},style:{},readOnly:{type:Boolean,default:!1},treeShowValues:{type:Boolean,default:!0},treeShowCounts:{type:Boolean,default:!1},editorShowDescriptions:{type:Boolean,default:!1},editorShowCounts:{type:Boolean,default:!1},sidebarOpen:{type:Boolean,default:!0}},emits:[`change`],setup(e,{emit:t}){let n=e,r=t,i=n.value!==void 0,a=I(i?n.value:n.defaultValue??{}),o=I(0);R(()=>n.value,e=>{i&&e!==a.value&&(a.value=e,o.value++)});function s(e){var t;a.value=e,n.readOnly||(r(`change`,e),(t=n.onChange)==null||t.call(n,e))}let c=I(280),l=I(!1),u=I(`tree`),d=I(null),f=!1,p=0,m=0,h=null;function g(){d.value&&(l.value=d.value.offsetWidth<500)}Ir(()=>{g(),d.value&&(h=new ResizeObserver(g),h.observe(d.value))}),Br(()=>{h?.disconnect()});function _(e){f=!0,p=e.clientX,m=c.value,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;function t(e){if(!f)return;let t=e.clientX-p;c.value=Math.max(180,Math.min(600,m+t))}function n(){f=!1,document.body.style.cursor=``,document.body.style.userSelect=``,document.removeEventListener(`mousemove`,t),document.removeEventListener(`mouseup`,n)}document.addEventListener(`mousemove`,t),document.addEventListener(`mouseup`,n)}let v=q(()=>({height:typeof n.height==`number`?`${n.height}px`:n.height,width:typeof n.width==`number`?`${n.width}px`:n.width,display:`flex`,flexDirection:`column`,overflow:`hidden`,...Hd,...n.style??{}}));return(e,t)=>(V(),H(`div`,{"data-vj-root":``,style:M(v.value)},[(V(),wa(of,{key:o.value,value:a.value,schema:n.schema,onChange:s},{default:Ln(()=>[l.value?(V(),H(`div`,{key:0,ref_key:`containerRef`,ref:d,style:{display:`flex`,flexDirection:`column`,flex:1,minHeight:0}},[n.sidebarOpen?(V(),H(B,{key:1},[U(`div`,Xf,[U(`button`,{style:M({flex:1,fontSize:`11px`,padding:`4px 0`,cursor:`pointer`,fontFamily:`var(--vj-font, monospace)`,border:`none`,background:u.value===`tree`?`var(--vj-accent-muted, #094771)`:`transparent`,color:u.value===`tree`?`var(--vj-text, #cccccc)`:`var(--vj-text-muted, #999999)`}),onClick:t[0]||=()=>u.value=`tree`},` Tree `,4),U(`button`,{style:M({flex:1,fontSize:`11px`,padding:`4px 0`,cursor:`pointer`,fontFamily:`var(--vj-font, monospace)`,border:`none`,background:u.value===`form`?`var(--vj-accent-muted, #094771)`:`transparent`,color:u.value===`form`?`var(--vj-text, #cccccc)`:`var(--vj-text-muted, #999999)`}),onClick:t[1]||=()=>u.value=`form`},` Form `,4)]),U(`div`,Zf,[u.value===`tree`?(V(),H(`div`,Qf,[W(Jf),U(`div`,$f,[W(gf,{"show-values":n.treeShowValues,"show-counts":n.treeShowCounts},null,8,[`show-values`,`show-counts`])])])):(V(),H(`div`,ep,[U(`div`,tp,[W(Hf,{"show-descriptions":n.editorShowDescriptions,"show-counts":n.editorShowCounts},null,8,[`show-descriptions`,`show-counts`])])]))])],64)):(V(),H(`div`,Yf,[W(Hf,{"show-descriptions":n.editorShowDescriptions,"show-counts":n.editorShowCounts},null,8,[`show-descriptions`,`show-counts`])]))],512)):(V(),H(`div`,{key:1,ref_key:`containerRef`,ref:d,style:{display:`flex`,flex:1,minHeight:0}},[U(`div`,{style:M({flexShrink:0,overflow:`hidden`,display:`flex`,flexDirection:`column`,width:n.sidebarOpen?c.value+`px`:`0`,transition:`width 0.2s ease`})},[W(Jf),U(`div`,np,[W(gf,{"show-values":n.treeShowValues,"show-counts":n.treeShowCounts},null,8,[`show-values`,`show-counts`])])],4),n.sidebarOpen?(V(),H(`div`,rp,[U(`div`,{style:{position:`absolute`,top:0,bottom:0,left:`-3px`,width:`7px`,cursor:`col-resize`,zIndex:10},onMousedown:_,onMouseenter:t[2]||=e=>{let t=e.currentTarget.parentElement;t&&(t.style.backgroundColor=`var(--vj-accent, #007acc)`)},onMouseleave:t[3]||=e=>{if(!L(f)){let t=e.currentTarget.parentElement;t&&(t.style.backgroundColor=`var(--vj-border, #333333)`)}}},null,32)])):K(``,!0),U(`div`,ip,[U(`div`,ap,[W(Hf,{"show-descriptions":n.editorShowDescriptions,"show-counts":n.editorShowCounts},null,8,[`show-descriptions`,`show-counts`])])])],512))]),_:1},8,[`value`,`schema`]))],4))}}),sp={style:{backgroundColor:`var(--vj-bg, #1e1e1e)`,color:`var(--vj-text, #cccccc)`,overflow:`auto`,height:`100%`,display:`flex`,flexDirection:`column`}},cp={style:{display:`flex`,alignItems:`center`,gap:`12px`,padding:`6px 12px`,borderBottom:`1px solid var(--vj-border, #333333)`,backgroundColor:`var(--vj-bg-panel, #252526)`,fontFamily:`var(--vj-font, monospace)`,fontSize:`12px`,flexShrink:0}},lp={style:{color:`var(--vj-text-muted, #999999)`}},up={key:0,style:{color:`#4ec94e`}},dp={key:1,style:{color:`#f48771`}},fp={key:2,style:{color:`#dcdcaa`}},pp={style:{flex:1,overflow:`auto`}},mp={key:0,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:`100%`,color:`var(--vj-text-dimmer, #555555)`,fontFamily:`var(--vj-font, monospace)`,fontSize:`13px`}},hp={style:{color:`var(--vj-text, #cccccc)`,flexShrink:0,minWidth:`100px`}},gp={style:{flex:1,display:`flex`,gap:`8px`,overflow:`hidden`}},_p={style:{color:`#f48771`,textDecoration:`line-through`}},vp={style:{color:`#4ec94e`}},yp={key:1,style:{color:`#4ec94e`}},bp={key:2,style:{color:`#f48771`,textDecoration:`line-through`}};z({__name:`DiffView`,props:{originalJson:{},currentJson:{},class:{}},setup(e){let t=e,n=q(()=>Id(t.originalJson,t.currentJson)),r=q(()=>n.value.filter(e=>e.type===`added`).length),i=q(()=>n.value.filter(e=>e.type===`removed`).length),a=q(()=>n.value.filter(e=>e.type===`changed`).length);function o(e){return Jd[e.type]}return(e,t)=>(V(),H(`div`,sp,[U(`div`,cp,[U(`span`,lp,P(n.value.length===0?`No changes`:`${n.value.length} changes`),1),r.value>0?(V(),H(`span`,up,`+`+P(r.value)+` added`,1)):K(``,!0),i.value>0?(V(),H(`span`,dp,`-`+P(i.value)+` removed`,1)):K(``,!0),a.value>0?(V(),H(`span`,fp,`~`+P(a.value)+` modified`,1)):K(``,!0)]),U(`div`,pp,[n.value.length===0?(V(),H(`div`,mp,` No differences detected `)):K(``,!0),(V(!0),H(B,null,Zr(n.value,(e,n)=>(V(),H(`div`,{key:n,style:M({display:`flex`,alignItems:`flex-start`,padding:`3px 12px`,borderBottom:`1px solid var(--vj-border-subtle, #2a2a2a)`,backgroundColor:o(e).bg,fontFamily:`var(--vj-font, monospace)`,fontSize:`12px`,gap:`8px`})},[U(`span`,{style:M({color:o(e).label,fontWeight:600,width:`14px`,flexShrink:0,textAlign:`center`})},P(o(e).marker),5),U(`span`,hp,P(e.path),1),U(`span`,gp,[e.type===`changed`?(V(),H(B,{key:0},[U(`span`,_p,P(L(Yd)(e.oldValue)),1),t[0]||=U(`span`,{style:{color:`var(--vj-text-dim, #666666)`}},`→`,-1),U(`span`,vp,P(L(Yd)(e.newValue)),1)],64)):e.type===`added`?(V(),H(`span`,yp,P(L(Yd)(e.newValue)),1)):e.type===`removed`?(V(),H(`span`,bp,P(L(Yd)(e.oldValue)),1)):K(``,!0)])],4))),128))])]))}});var xp=window.matchMedia(`(prefers-color-scheme: dark)`);function Sp(){let{settings:e}=Xl(),t=q(()=>e.theme===`system`?xp.matches?`dark`:`light`:e.theme);function n(){let e=t.value;e===`dark`?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e}return R(t,n,{immediate:!0}),xp.addEventListener(`change`,n),{effective:t}}var Cp=`modulepreload`,wp=function(e){return`/`+e},Tp={};const Ep=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=wp(t,n),t in Tp)return;Tp[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:Cp,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};var Dp=z({__name:`CodeEditor`,props:{modelValue:{},language:{default:`plaintext`},readOnly:{type:Boolean,default:!1}},emits:[`update:modelValue`,`save`],setup(e,{expose:t,emit:n}){let r=e,i=n,{effective:a}=Sp(),o=F(null),s=null,c=!1;async function l(){if(!o.value||s)return;let{init:e}=await Ep(async()=>{let{init:e}=await import(`./dist-D51xeTP2.js`);return{init:e}},[]),t=await e();t.editor.defineTheme(`piclaw-dark`,{base:`vs-dark`,inherit:!0,rules:[],colors:{"editor.background":`#0a0e14`,"editorGutter.background":`#0a0e14`,"editorLineNumber.foreground":`#5c6773`}}),t.editor.defineTheme(`piclaw-light`,{base:`vs`,inherit:!0,rules:[],colors:{"editor.background":`#ffffff`,"editorGutter.background":`#f5f5f7`,"editorLineNumber.foreground":`#86868b`}});let n=t.editor.createModel(r.modelValue,r.language);s=t.editor.create(o.value,{model:n,theme:a.value===`light`?`piclaw-light`:`piclaw-dark`,readOnly:r.readOnly,minimap:{enabled:!1},fontSize:12,fontFamily:`Geist Mono Variable, monospace`,lineNumbers:`on`,scrollBeyondLastLine:!1,automaticLayout:!0,tabSize:2,wordWrap:`on`}),n.onDidChangeContent(()=>{c||i(`update:modelValue`,n.getValue())}),s.addCommand(t.KeyMod.CtrlCmd|t.KeyCode.KeyS,()=>{i(`save`)})}function u(){s?.dispose(),s=null}function d(){if(!s)return;let e=s.getModel();e&&e.getValue()!==r.modelValue&&(c=!0,e.setValue(r.modelValue),c=!1)}function f(){if(!s)return;let e=s.getModel();e&&Ep(async()=>{let{init:e}=await import(`./dist-D51xeTP2.js`);return{init:e}},[]).then(({init:t})=>t().then(t=>{t.editor.setModelLanguage(e,r.language)}))}return R(()=>r.modelValue,d),R(()=>r.language,f),R(()=>r.readOnly,e=>s?.updateOptions({readOnly:e})),R(a,e=>{s&&Ep(async()=>{let{init:e}=await import(`./dist-D51xeTP2.js`);return{init:e}},[]).then(({init:t})=>t().then(t=>{t.editor.setTheme(e===`light`?`piclaw-light`:`piclaw-dark`)}))}),Ir(l),Br(u),t({editor:()=>s}),(e,t)=>(V(),H(`div`,{ref_key:`el`,ref:o,class:`h-full w-full`},null,512))}}),Op={class:`relative h-full min-h-0`},kp={class:`absolute top-1 right-5 z-10 flex items-center gap-0.5 bg-bg/80 backdrop-blur rounded px-1 py-0.5`},Ap=`piclaw:json-editor-mode`,jp=z({__name:`JsonEditor`,props:{value:{},readOnly:{type:Boolean,default:!1},schema:{default:null}},emits:[`change`,`validation`],setup(e,{emit:t}){let n=F(localStorage.getItem(Ap)||`visual`);R(n,e=>localStorage.setItem(Ap,e));let r=e,i=t,a=r.value??{},o=F(!0);function s(e){a=e,i(`change`,e)}R(()=>r.value,e=>{a=e??{}},{deep:!0});function c(e){e&&typeof e==`object`&&!Array.isArray(e)&&s(e)}let l={"--vj-bg":`var(--color-bg)`,"--vj-bg-panel":`var(--color-surface)`,"--vj-bg-hover":`var(--color-muted-dim)`,"--vj-bg-selected":`var(--color-accent-dim)`,"--vj-border":`var(--color-border)`,"--vj-text":`var(--color-text)`,"--vj-text-muted":`var(--color-muted)`,"--vj-accent":`var(--color-accent)`,"--vj-string":`var(--color-accent)`,"--vj-number":`var(--color-ok)`,"--vj-font":`var(--font-mono)`},u=F(JSON.stringify(a,null,2));function d(e){u.value=e;try{let t=JSON.parse(e);t&&typeof t==`object`&&!Array.isArray(t)&&s(t),o.value=!0,i(`validation`,{valid:!0})}catch(e){o.value=!1,i(`validation`,{valid:!1,error:e instanceof SyntaxError?e.message:`Invalid JSON`})}}function f(){let e=JSON.stringify(a,null,2);u.value!==e&&(u.value=e)}return R(n,e=>{e===`json`&&f()}),R(()=>[r.value,r.readOnly,r.schema],()=>{n.value===`json`&&f()},{deep:!0}),(e,t)=>(V(),H(`div`,Op,[U(`div`,kp,[U(`button`,{type:`button`,class:N([`px-1.5 py-0.5 rounded text-[10px] uppercase tracking-wider font-medium transition-colors`,n.value===`json`?`bg-surface text-text`:`text-muted hover:text-text`]),onClick:t[0]||=e=>n.value=`json`},` json `,2),U(`button`,{type:`button`,class:N([`px-1.5 py-0.5 rounded text-[10px] uppercase tracking-wider font-medium transition-colors`,n.value===`visual`?`bg-surface text-text`:`text-muted hover:text-text`]),onClick:t[1]||=e=>n.value=`visual`},` visual `,2)]),Rn(W(Dp,{"model-value":u.value,language:`json`,"read-only":r.readOnly,class:`h-full`,"onUpdate:modelValue":d},null,8,[`model-value`,`read-only`]),[[Bo,n.value===`json`]]),n.value===`visual`?(V(),wa(L(op),{key:0,value:L(a),schema:r.schema??void 0,"read-only":r.readOnly,"editor-show-descriptions":!!r.schema,height:`100%`,width:`100%`,style:l,onChange:c},null,8,[`value`,`schema`,`read-only`,`editor-show-descriptions`])):K(``,!0)]))}}),Mp={class:`p-3 h-full min-h-0`},Np=z({__name:`ConfigTab`,setup(e){let t=F(null);return gu(async()=>{t.value=await fu(`/api/pi/status`)},3e4),(e,n)=>(V(),H(`div`,Mp,[W(jp,{value:t.value,"read-only":!0},null,8,[`value`])]))}}),Pp={class:`flex flex-col h-full`},Fp={class:`px-3 py-3 border-b border-border bg-surface/40`},Ip={class:`flex flex-wrap items-center gap-4 text-[12px]`},Lp={class:`flex items-center gap-2`},Rp={class:`flex items-center gap-2 min-w-0`},zp={class:`px-3 py-2 flex gap-2 items-center border-b border-border`},Bp=[`value`],Vp={class:`px-3 py-2 text-[11px] text-muted border-b border-border`},Hp={class:`overflow-auto flex-1 min-h-0`},Up={class:`w-full border-collapse text-[12px]`},Wp={key:0},Gp={key:1},Kp={class:`py-1.5 px-2 border-b border-border text-muted select-text`},qp={class:`py-1.5 px-2 border-b border-border font-medium select-text`},Jp={class:`ml-1.5 text-[10px] text-muted`},Yp={class:`py-1.5 px-2 border-b border-border text-center`},Xp=[`disabled`,`onClick`],Zp={key:1,class:`badge-accent border border-accent`},Qp={class:`py-1.5 px-2 border-b border-border text-[10px] text-muted select-text`},$p={class:`py-1.5 px-2 border-b border-border text-muted font-mono select-text`},em={class:`py-1.5 px-2 border-b border-border text-muted font-mono select-text`},tm={class:`py-1.5 px-2 border-b border-border text-muted font-mono select-text`},nm={class:`py-1.5 px-2 border-b border-border text-muted font-mono select-text`},rm={class:`py-1.5 px-2 border-b border-border`},im={key:0,class:`badge-accent mr-1`},am={key:1,class:`badge-ok`},om=z({__name:`ModelsTab`,setup(e){let t=F(null),n=F(``),r=F(``),i=F(!1);async function a(){t.value=await fu(`/api/pi/models`)}gu(a,3e4);let o=q(()=>t.value?[...new Set(t.value.models.map(e=>e.provider))].sort():[]),s=q(()=>{if(!t.value)return{};let e={};for(let n of t.value.models)e[n.provider]=(e[n.provider]||0)+1;return e}),c=q(()=>{if(!t.value)return[];let e=t.value.models;if(r.value&&(e=e.filter(e=>e.provider===r.value)),n.value.trim()){let t=n.value.trim().toLowerCase();e=e.filter(e=>e.id.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)||e.provider.toLowerCase().includes(t))}return e});function l(e){return!!t.value&&t.value.defaultModel===e.id&&t.value.defaultProvider===e.provider}async function u(e){if(!i.value){i.value=!0;try{await fu(`/api/pi/models`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({defaultModel:e.id,defaultProvider:e.provider})}),await a()}finally{i.value=!1}}}function d(e){return e>=1e6?`${(e/1e6).toFixed(0)}m`:e>=1e3?`${(e/1e3).toFixed(0)}k`:String(e)}function f(e){return e===0?`0`:e<.01?e.toFixed(3):e<1?e.toFixed(2):e.toFixed(1)}return(e,a)=>(V(),H(`div`,Pp,[U(`div`,Fp,[a[4]||=U(`div`,{class:`text-[10px] uppercase tracking-wider text-muted mb-2`},`default model`,-1),U(`div`,Ip,[U(`div`,Lp,[a[2]||=U(`span`,{class:`text-muted`},`provider`,-1),U(`span`,{class:N([`px-2 py-0.5 rounded border border-border font-medium select-text`,t.value?.defaultProvider?`text-accent bg-accent-dim`:`text-muted`])},P(t.value?.defaultProvider||`—`),3)]),U(`div`,Rp,[a[3]||=U(`span`,{class:`text-muted`},`model`,-1),U(`span`,{class:N([`px-2 py-0.5 rounded border border-border font-mono text-[11px] max-w-[60ch] truncate select-text`,t.value?.defaultModel?`text-accent bg-accent-dim`:`text-muted`])},P(t.value?.defaultModel||`—`),3)])])]),U(`div`,zp,[Rn(U(`input`,{"onUpdate:modelValue":a[0]||=e=>n.value=e,placeholder:`search models...`,class:`bg-bg border border-border rounded text-text px-2.5 py-1 text-[12px] font-mono flex-1 outline-none transition-colors focus:border-accent`},null,512),[[vs,n.value]]),Rn(U(`select`,{"onUpdate:modelValue":a[1]||=e=>r.value=e,class:`bg-bg border border-border rounded text-text px-2 py-1 text-[12px] font-mono outline-none transition-colors focus:border-accent`},[a[5]||=U(`option`,{value:``},`all providers`,-1),(V(!0),H(B,null,Zr(o.value,e=>(V(),H(`option`,{key:e,value:e},P(e)+` (`+P(s.value[e])+`) `,9,Bp))),128))],512),[[ys,r.value]])]),U(`div`,Vp,P(t.value?c.value.length:`-`)+`/`+P(t.value?.models.length??`-`)+` models `,1),U(`div`,Hp,[U(`table`,Up,[a[8]||=U(`thead`,{class:`sticky top-0 bg-bg z-10`},[U(`tr`,null,[U(`th`,{class:`text-left text-muted font-medium py-1.5 px-2 border-b border-border text-[10px] uppercase tracking-wide`},` provider `),U(`th`,{class:`text-left text-muted font-medium py-1.5 px-2 border-b border-border text-[10px] uppercase tracking-wide`},` model `),U(`th`,{class:`text-center text-muted font-medium py-1.5 px-2 border-b border-border text-[10px] uppercase tracking-wide w-16`}),U(`th`,{class:`text-left text-muted font-medium py-1.5 px-2 border-b border-border text-[10px] uppercase tracking-wide`},` api `),U(`th`,{class:`text-left text-muted font-medium py-1.5 px-2 border-b border-border text-[10px] uppercase tracking-wide`},` ctx `),U(`th`,{class:`text-left text-muted font-medium py-1.5 px-2 border-b border-border text-[10px] uppercase tracking-wide`},` max out `),U(`th`,{class:`text-left text-muted font-medium py-1.5 px-2 border-b border-border text-[10px] uppercase tracking-wide`},` $/m in `),U(`th`,{class:`text-left text-muted font-medium py-1.5 px-2 border-b border-border text-[10px] uppercase tracking-wide`},` $/m out `),U(`th`,{class:`text-left text-muted font-medium py-1.5 px-2 border-b border-border text-[10px] uppercase tracking-wide`},` flags `)])],-1),U(`tbody`,null,[t.value?c.value.length===0?(V(),H(`tr`,Gp,[...a[7]||=[U(`td`,{colspan:`9`,class:`text-center py-8 text-muted text-[12px]`},`no models found`,-1)]])):K(``,!0):(V(),H(`tr`,Wp,[...a[6]||=[U(`td`,{colspan:`9`,class:`text-center py-8 text-muted text-[12px]`},`loading...`,-1)]])),(V(!0),H(B,null,Zr(c.value,e=>(V(),H(`tr`,{key:`${e.provider}/${e.id}`,class:N([`hover:bg-surface`,l(e)?`bg-accent-dim/30`:``])},[U(`td`,Kp,P(e.provider),1),U(`td`,qp,[U(`span`,null,P(e.name),1),U(`span`,Jp,P(e.id),1)]),U(`td`,Yp,[l(e)?(V(),H(`span`,Zp,` active `)):(V(),H(`button`,{key:0,type:`button`,class:`btn-sm hover:text-accent hover:border-accent bg-bg disabled:opacity-40`,disabled:i.value,onClick:t=>u(e)},` use `,8,Xp))]),U(`td`,Qp,P(e.api),1),U(`td`,$p,P(d(e.contextWindow)),1),U(`td`,em,P(d(e.maxTokens)),1),U(`td`,tm,P(f(e.cost.input)),1),U(`td`,nm,P(f(e.cost.output)),1),U(`td`,rm,[e.reasoning?(V(),H(`span`,im,`reasoning`)):K(``,!0),e.input.includes(`image`)?(V(),H(`span`,am,`vision`)):K(``,!0)])],2))),128))])])])]))}}),sm={class:`flex flex-col h-full min-h-0`},cm={class:`px-3 py-2 border-b border-border flex items-center gap-2`},lm=[`onClick`],um={class:`ml-auto flex items-center gap-2`},dm={key:0,class:`text-[11px] text-err truncate max-w-[200px]`},fm=[`disabled`],pm={key:2,class:`text-[11px] text-muted`},mm={class:`flex-1 min-h-0 p-3`},hm={class:`h-full border border-border`},gm=z({__name:`SettingsTab`,setup(e){let t={settings:{label:`settings.json`,endpoint:`/api/pi/settings`,schemaKey:`settings`},"models-config":{label:`models.json`,endpoint:`/api/pi/models-config`,schemaKey:`modelsConfig`},auth:{label:`auth.json`,endpoint:`/api/pi/auth`}},n=F(`settings`),r=F(null),i=F(null),a=F(!1),o=F(null),s=F(null),c=F(null),l=``,u=F(!1),d=()=>{let e=t[n.value].schemaKey;return!e||!i.value?null:i.value[e]??null};async function f(){i.value=await fu(`/api/pi/schemas`)}async function p(){s.value=null,c.value=null,u.value=!1,o.value=null,r.value=(await fu(t[n.value].endpoint))?.data??null,l=JSON.stringify(r.value)}function m(e){o.value=e,u.value=JSON.stringify(e)!==l}function h(e){c.value=e.valid?null:e.error??`Invalid JSON`,e.valid||(u.value=!0)}async function g(){if(o.value){a.value=!0,s.value=null;try{let e=await fetch(t[n.value].endpoint,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(o.value)});if(!e.ok){s.value=await e.text();return}r.value=o.value,l=JSON.stringify(r.value),u.value=!1,o.value=null}catch(e){s.value=e instanceof Error?e.message:String(e)}finally{a.value=!1}}}function _(){o.value=null,u.value=!1,c.value=null,r.value=r.value?{...r.value}:null}function v(e){!e.metaKey&&!e.ctrlKey||(e.key===`s`&&u.value&&!c.value&&!a.value?(e.preventDefault(),g()):e.key===`d`&&u.value&&(e.preventDefault(),_()))}return Ir(()=>{f(),window.addEventListener(`keydown`,v)}),Br(()=>window.removeEventListener(`keydown`,v)),R(n,()=>p(),{immediate:!0}),(e,i)=>(V(),H(`div`,sm,[U(`div`,cm,[(V(),H(B,null,Zr(t,(e,t)=>U(`button`,{key:t,type:`button`,class:N([`px-2.5 py-1 rounded text-[11px] font-mono transition-colors`,n.value===t?`bg-surface text-text`:`text-muted hover:text-text`]),onClick:e=>n.value=t},P(e.label),11,lm)),64)),U(`div`,um,[s.value||c.value?(V(),H(`span`,dm,P(s.value||c.value),1)):K(``,!0),u.value?(V(),H(B,{key:1},[U(`button`,{type:`button`,class:`px-2.5 py-1 rounded text-[11px] font-medium bg-surface text-muted hover:text-text transition-colors`,title:`⌘D`,onClick:_},[...i[0]||=[G(` discard `,-1),U(`span`,{class:`text-[9px] opacity-60 hidden sm:inline`},`⌘D`,-1)]]),U(`button`,{type:`button`,class:`px-2.5 py-1 rounded text-[11px] font-medium bg-accent text-bg transition-colors disabled:opacity-50`,disabled:a.value||!!c.value,title:`⌘S`,onClick:g},[a.value?(V(),H(B,{key:0},[G(`saving...`)],64)):(V(),H(B,{key:1},[i[1]||=G(`save `,-1),i[2]||=U(`span`,{class:`text-[9px] opacity-60 hidden sm:inline`},`⌘S`,-1)],64))],8,fm)],64)):(V(),H(`span`,pm,`~/.pi/agent/`+P(t[n.value].label),1))])]),U(`div`,mm,[U(`div`,hm,[(V(),wa(jp,{key:n.value,value:r.value,schema:d(),"read-only":!1,onChange:m,onValidation:h},null,8,[`value`,`schema`]))])])]))}}),_m={class:`flex flex-col h-full`},vm={class:`px-3 pt-3 border-b border-border flex items-center gap-2`},ym={key:`agent`,label:`Pi Agent`,icon:`pixelarticons:cpu`,color:`#39bae6`,component:z({__name:`window`,setup(e){let t=[`auth`,`models`,`settings`,`status`],{state:n,set:r}=$l(),i=F(t.includes(n.value.tab)?n.value.tab:`auth`);return R(i,e=>r({tab:e})),(e,t)=>(V(),H(`div`,_m,[U(`div`,vm,[U(`button`,{type:`button`,class:N(i.value===`auth`?`tab-active`:`tab-inactive`),onClick:t[0]||=e=>i.value=`auth`},` auth `,2),U(`button`,{type:`button`,class:N(i.value===`models`?`tab-active`:`tab-inactive`),onClick:t[1]||=e=>i.value=`models`},` models `,2),U(`button`,{type:`button`,class:N(i.value===`settings`?`tab-active`:`tab-inactive`),onClick:t[2]||=e=>i.value=`settings`},` settings `,2),U(`button`,{type:`button`,class:N(i.value===`status`?`tab-active`:`tab-inactive`),onClick:t[3]||=e=>i.value=`status`},` status `,2)]),i.value===`auth`?(V(),wa(od,{key:0})):i.value===`models`?(V(),wa(om,{key:1})):i.value===`settings`?(V(),wa(gm,{key:2})):i.value===`status`?(V(),wa(Np,{key:3})):K(``,!0)]))}}),window:{width:900,height:520,minwidth:480,minheight:300}},bm={text:``,thinking:``,isStreaming:!1,activeTool:null};function xm(e){let t=F({...bm}),n;function r(e){i(),t.value={...bm},n=new EventSource(`/api/stream?jid=${encodeURIComponent(e)}`),n.addEventListener(`text_delta`,e=>{let n=JSON.parse(e.data);t.value={...t.value,text:t.value.text+n.delta,isStreaming:!0}}),n.addEventListener(`text_end`,()=>{t.value={...bm}}),n.addEventListener(`thinking_delta`,e=>{let n=JSON.parse(e.data);t.value={...t.value,thinking:t.value.thinking+n.delta,isStreaming:!0}}),n.addEventListener(`thinking_end`,()=>{}),n.addEventListener(`tool_start`,e=>{let n=JSON.parse(e.data);t.value={...t.value,activeTool:n.toolName}}),n.addEventListener(`tool_end`,()=>{t.value={...t.value,activeTool:null}}),n.addEventListener(`agent_end`,()=>{t.value={...bm}})}function i(){n?.close(),n=void 0}return R(e,e=>{e?r(e):i()},{immediate:!0}),Br(i),{streamState:t}}function Sm(e){if(!e)return``;let t=document.createElement(`div`);return t.textContent=e,t.innerHTML}function Cm(e){if(!e)return`-`;let t=new Date(e),n=Date.now()-t.getTime();return n<6e4?`just now`:n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:`${Math.floor(n/864e5)}d ago`}function wm(e){let t=Math.floor(e/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m ${t%60}s`:`${Math.floor(t/3600)}h ${Math.floor(t%3600/60)}m`}function Tm(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``)}function Em(e){switch(e){case`active`:return`badge-ok`;case`paused`:return`badge-warn`;case`completed`:return`badge-muted`;case`error`:return`badge-danger`;default:return`badge-muted`}}var Dm=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},Om={},km={type:`button`,class:`w-7 h-7 flex items-center justify-center text-muted hover:text-text rounded transition-colors cursor-pointer`,title:`toggle sidebar`};function Am(e,t){return V(),H(`button`,km,[...t[0]||=[Ma(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"><rect x="1.5" y="2.5" width="13" height="11" rx="2"></rect><line x1="5.5" y1="2.5" x2="5.5" y2="13.5"></line><line x1="3" y1="5.5" x2="4" y2="5.5"></line><line x1="3" y1="8" x2="4" y2="8"></line><line x1="3" y1="10.5" x2="4" y2="10.5"></line></svg>`,1)]])}var jm=Dm(Om,[[`render`,Am]]),Mm;const Nm=F(!1);var Pm=(()=>{let e;return()=>e??=Ep(()=>import(`./wasm-Cm7RZrwg.js`).then(async e=>{await e.init(),Mm=e.renderToHtml,Nm.value=!0}),[])})();function Fm(e){if(!e)return``;Mm||Pm(),Nm.value;let t=[],n=0,r=e.replace(/<(internal|thinking)>([\s\S]*?)<\/\1>/g,(e,r,i)=>{let a=`\x00MK${n++}\x00`;return t.push([a,`<span class="text-muted opacity-60 text-[11px] italic">${Sm(i)}</span>`]),a}),i=Mm?Mm(r):Sm(r);for(let[e,n]of t)i=i.replaceAll(e,n);return i}var Im={key:0,class:`flex-1 flex items-center justify-center text-muted text-[13px] font-sans`},Lm={key:0,class:`flex justify-center py-2`},Rm={class:`bg-surface text-muted text-[10px] font-medium tracking-wide rounded-full px-3 py-1`},zm={key:0,class:`text-[10px] font-medium mb-0.5 px-3 text-ok`},Bm=[`innerHTML`],Vm={key:2,class:`px-4 py-2.5 rounded-2xl rounded-br-sm text-[13px] font-sans leading-snug whitespace-pre-wrap break-words bg-accent-dimmer text-text border border-accent-dim select-text`},Hm={class:`text-[9px] text-muted mt-1 px-3`},Um={key:1,class:`flex flex-col max-w-[70%] max-md:max-w-[80%] self-start items-start`},Wm={class:`px-4 py-2 rounded-2xl rounded-bl-sm text-[11px] font-sans leading-snug whitespace-pre-wrap break-words bg-surface border border-border select-text text-muted italic opacity-60`},Gm={key:2,class:`flex flex-col max-w-[70%] max-md:max-w-[80%] self-start items-start`},Km=[`innerHTML`],qm={key:3,class:`flex flex-col self-start items-start`},Jm={class:`px-4 py-2 rounded-2xl rounded-bl-sm text-[11px] font-mono text-muted bg-surface border border-border`},Ym={key:0,class:`shrink-0 justify-center px-4 py-2.5 bg-bg items-center gap-1.5 flex`},Xm=Dm(z({__name:`ChatMessages`,props:{messages:{},sendingMessage:{type:Boolean},typingVisible:{type:Boolean},streamState:{}},setup(e){let t=e,n=q(()=>t.streamState.text||``),r=q(()=>t.streamState.thinking||``),i=F(null),a=F(!1);R(()=>t.messages.length,async(e,n)=>{let r=i.value;if(!r)return;let o=r.scrollHeight-r.scrollTop-r.clientHeight<80,s=e>(n??0);if(await Tn(),!a.value){r.scrollTop=r.scrollHeight,a.value=!0;return}(s&&o||t.sendingMessage)&&(r.scrollTop=r.scrollHeight)}),Ir(async()=>{await Tn();let e=i.value;e&&(e.scrollTop=e.scrollHeight,a.value=!0)});function o(e){return new Date(e).toLocaleDateString(void 0,{weekday:`long`,month:`short`,day:`numeric`})}function s(e){return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}function c(e){return e===0?!0:o(t.messages[e].timestamp)!==o(t.messages[e-1].timestamp)}return R(()=>n.value.length+r.value.length,async()=>{let e=i.value;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<80;await Tn(),t&&(e.scrollTop=e.scrollHeight)}),(t,a)=>(V(),H(B,null,[U(`div`,{ref_key:`listEl`,ref:i,class:`flex-1 min-h-0 overflow-y-auto px-4 py-4 flex flex-col gap-2 bg-bg overscroll-contain [scrollbar-gutter:stable]`},[e.messages.length===0?(V(),H(`div`,Im,[...a[0]||=[U(`div`,{class:`text-center`},[U(`div`,{class:`text-[28px] text-border mb-3`},`~`),U(`div`,null,`no messages yet`)],-1)]])):K(``,!0),(V(!0),H(B,null,Zr(e.messages,(e,t)=>(V(),H(B,{key:`${e.timestamp}-${t}`},[c(t)?(V(),H(`div`,Lm,[U(`span`,Rm,P(o(e.timestamp)),1)])):K(``,!0),U(`div`,{class:N([`flex flex-col max-w-[70%] max-md:max-w-[80%]`,e.is_bot_message?`self-start items-start`:`self-end items-end`])},[e.is_bot_message?(V(),H(`div`,zm,P(e.sender_name),1)):K(``,!0),e.is_bot_message?(V(),H(`div`,{key:1,class:`md-content px-4 py-2.5 rounded-2xl rounded-bl-sm text-[13px] font-sans leading-snug break-words bg-surface border border-border select-text`,innerHTML:L(Fm)(e.content)},null,8,Bm)):(V(),H(`div`,Vm,P(e.content),1)),U(`div`,Hm,P(s(e.timestamp)),1)],2)],64))),128)),r.value?(V(),H(`div`,Um,[U(`div`,Wm,P(r.value),1)])):K(``,!0),n.value?(V(),H(`div`,Gm,[U(`div`,{class:`md-content px-4 py-2.5 rounded-2xl rounded-bl-sm text-[13px] font-sans leading-snug break-words bg-surface border border-border select-text opacity-80`,innerHTML:L(Fm)(n.value)},null,8,Km)])):K(``,!0),e.streamState.activeTool&&!n.value?(V(),H(`div`,qm,[U(`div`,Jm,` using `+P(e.streamState.activeTool)+`... `,1)])):K(``,!0)],512),e.typingVisible&&!n.value&&!r.value&&!e.streamState.activeTool?(V(),H(`div`,Ym,[...a[1]||=[U(`div`,{class:`typing-dot w-1.5 h-1.5 rounded-full bg-muted`},null,-1),U(`div`,{class:`typing-dot w-1.5 h-1.5 rounded-full bg-muted`},null,-1),U(`div`,{class:`typing-dot w-1.5 h-1.5 rounded-full bg-muted`},null,-1)]])):K(``,!0)],64))}}),[[`__scopeId`,`data-v-c84ce495`]]),Zm={class:`w-[280px] min-w-[280px] max-md:w-full max-md:min-w-0 border-r border-border flex flex-col bg-surface`},Qm={class:`px-3 py-3 border-b border-border flex items-center gap-2`},$m={class:`flex-1 overflow-y-auto p-1.5`},eh={key:0,class:`flex-1 flex flex-col items-center justify-center text-muted text-[13px] font-sans py-12`},th={key:1,class:`flex-1 flex flex-col items-center justify-center text-muted text-[13px] font-sans py-12`},nh=[`onClick`,`onContextmenu`,`onTouchstart`],rh={class:`flex-1 min-w-0`},ih={class:`text-[13px] font-medium font-sans truncate`},ah={class:`text-[11px] text-muted mt-0.5 truncate`},oh=z({__name:`ChatSidebar`,props:{items:{},loading:{type:Boolean},currentJid:{}},emits:[`select`,`delete`,`settings`,`register`,`toggle`],setup(e,{emit:t}){let n=t,r=[`bg-accent-dim text-accent`,`bg-ok-dim text-ok`,`bg-warn-dim text-warn`,`bg-danger-dim text-danger`];function i(e){let t=0;for(let n of e)t=(t<<5)-t+n.charCodeAt(0)|0;return r[Math.abs(t)%r.length]}function a(e){return(e[0]||`?`).toUpperCase()}let{menu:o,onContext:s,onTouchStart:c,cancelLongPress:l,close:u}=Bl();function d(){o.value&&n(`delete`,o.value.data),u()}function f(){o.value&&n(`settings`,o.value.data),u()}return(t,r)=>(V(),H(`div`,Zm,[U(`div`,Qm,[r[5]||=U(`span`,{class:`text-[13px] font-medium text-text font-sans`},`chats`,-1),r[6]||=U(`span`,{class:`flex-1`},null,-1),U(`button`,{type:`button`,class:`h-7 flex items-center justify-center text-[13px] bg-accent-dim text-accent rounded-full cursor-pointer transition-colors hover:bg-accent-dimmer px-2 gap-1`,onClick:r[0]||=e=>n(`register`)},` + `),W(jm,{onClick:r[1]||=e=>n(`toggle`)})]),U(`div`,$m,[e.loading?(V(),H(`div`,eh,[W(L(vl),{icon:`lucide:loader`,class:`animate-spin text-[20px] mb-3`}),r[7]||=U(`div`,null,`loading...`,-1)])):e.items.length===0?(V(),H(`div`,th,[r[8]||=U(`div`,{class:`text-[28px] mb-3 text-border`},`~`,-1),r[9]||=U(`div`,{class:`mb-4`},`no chats yet`,-1),U(`button`,{type:`button`,class:`h-9 flex items-center justify-center text-[16px] bg-accent-dim text-accent rounded-full cursor-pointer transition-colors hover:bg-accent-dimmer px-3 gap-1`,onClick:r[2]||=e=>n(`register`)},` + `)])):K(``,!0),(V(!0),H(B,null,Zr(e.items,t=>(V(),H(`button`,{key:t.jid,type:`button`,class:N([`w-full text-left px-2.5 py-2.5 cursor-pointer rounded-lg transition-colors hover:bg-accent-dim/50 flex items-center gap-3`,t.jid===e.currentJid?`bg-accent-dim`:``]),onClick:e=>n(`select`,t.jid),onContextmenu:e=>L(s)(e,t.jid),onTouchstart:e=>L(c)(e,t.jid),onTouchend:r[3]||=(...e)=>L(l)&&L(l)(...e),onTouchmove:r[4]||=(...e)=>L(l)&&L(l)(...e)},[U(`div`,{class:N([`w-9 h-9 rounded-full flex items-center justify-center text-[13px] font-semibold shrink-0`,i(t.name)])},P(a(t.name)),3),U(`div`,rh,[U(`div`,ih,P(t.name),1),U(`div`,ah,P(t.folder?`~/${t.folder}`:t.jid.slice(0,24)),1)])],42,nh))),128))]),W(yl,{pos:L(o)??null},{default:Ln(()=>[U(`button`,{type:`button`,class:`w-full text-left px-3 py-1.5 text-[12px] text-text hover:bg-accent-dim hover:text-accent transition-colors cursor-pointer`,onClick:f},` Settings `),U(`button`,{type:`button`,class:`w-full text-left px-3 py-1.5 text-[12px] text-text hover:bg-danger-dim hover:text-danger transition-colors cursor-pointer`,onClick:d},` Delete `)]),_:1},8,[`pos`])]))}}),sh={class:`mb-2`},ch={key:0,class:`text-[10px] text-muted mb-2`},lh={key:1,class:`mb-2`},uh={class:`grid grid-cols-2 gap-2 max-md:grid-cols-1`},dh=[`value`],fh={class:`space-y-3`},ph={class:`flex items-center gap-2`},mh={key:0,class:`grid grid-cols-2 gap-3 max-md:grid-cols-1`},hh=[`value`],gh=[`value`],_h=[`value`],vh=[`value`],yh=[`value`],bh={class:`col-span-2 max-md:col-span-1`},xh={class:`text-[12px] font-mono text-text`},Sh={class:`pt-1 flex items-center justify-between`},Ch={key:0,class:`flex-1 flex flex-col text-muted text-[13px] font-sans bg-bg`},wh={key:0,class:`flex shrink-0 px-4 py-3 border-b border-border items-center bg-surface`},Th={class:`flex-1 flex items-center justify-center`},Eh={class:`text-center text-muted`},Dh={key:1,class:`flex flex-col h-full`},Oh={class:`shrink-0 px-4 py-3 border-b border-border flex items-center gap-3 bg-surface`},kh={class:`w-8 h-8 rounded-full bg-accent-dim text-accent flex items-center justify-center text-[13px] font-semibold shrink-0`},Ah={class:`flex-1 min-w-0 text-center`},jh={class:`text-[14px] font-medium font-sans truncate`},Mh={key:0,class:`shrink-0 mx-4 mt-3 mb-1 px-4 py-3 rounded-2xl bg-surface border border-border flex flex-col items-center gap-2 text-[13px] font-sans text-center`},Nh={class:`flex gap-2`},Ph={key:1,class:`shrink-0 mx-4 mt-2 px-3 py-1.5 rounded-lg bg-warn/8 border border-warn/20 text-[11px] font-mono text-warn flex items-center gap-1.5`},Fh={class:`font-semibold`},Ih={class:`relative flex-1`},Lh={key:0,class:`absolute bottom-full left-0 right-0 mb-1.5 rounded-xl border border-border bg-surface shadow-lg overflow-hidden z-10`},Rh=[`onMousedown`],zh={class:`font-mono font-semibold`},Bh={class:`opacity-50`},Vh=[`disabled`],Hh=[`disabled`],Uh=z({__name:`window`,props:{fillHeight:{type:Boolean,default:!1}},setup(e){let t=e,{state:n,set:r,setTitle:i,openWindow:a}=$l(),o=F(n.value.jid||null),s=F([]),c=F([]),l=F([]),u=F(``),d=F(null),f=F(!1),p=mu(),m=F(!1),{confirm:h}=ou(),g=F([]),_=F(0),v=q(()=>{let e=u.value;if(!e.startsWith(`/`)||e.includes(` `))return[];let t=e.slice(1).toLowerCase();return g.value.filter(e=>e.command.startsWith(t))});R(v,()=>{_.value=0});let y=F(!0),b=F(!1),x=F(null);function S(e){if(!p.value||y.value)return;let t=e.touches[0];t.clientX<24&&(x.value={startX:t.clientX,startY:t.clientY})}function C(e){if(!x.value)return;let t=e.touches[0],n=t.clientX-x.value.startX,r=Math.abs(t.clientY-x.value.startY);n>60&&n>r*1.5&&(y.value=!0,x.value=null)}function w(){x.value=null}let T=F(!1),ee=F(!1),E=F([]),D=F(!1),O=F(),k=F(``);R(D,e=>{e&&Tn(()=>O.value?.focus())});let te=F(``),ne=F(``),A=F(``),re=F(``),j=q(()=>Tm(k.value.trim())),{streamState:ie}=xm(o),ae=q(()=>{let e=new Set,t=[];for(let n of s.value)e.add(n.jid),t.push({jid:n.jid,name:n.name,folder:n.folder,registered:!0});for(let n of c.value)e.has(n.jid)||t.push({jid:n.jid,name:n.name||n.jid,registered:!1});return t}),oe=q(()=>o.value?s.value.find(e=>e.jid===o.value)?.name||o.value:`-`);R(oe,e=>{i(e&&e!==`-`?`Chats — ${e}`:`Chats`)});let se=q(()=>o.value?s.value.some(e=>e.jid===o.value):!0),M=q(()=>s.value.find(e=>e.jid===o.value)),ce=q(()=>ie.value.isStreaming||ie.value.activeTool!==null);async function le(){let e=await fu(`/api/pi/models`);e&&(E.value=e.models??[])}async function ue(){let e=await fu(`/api/pi/commands`);e&&(g.value=e)}async function de(){let[e,t]=await Promise.all([fu(`/api/groups`),fu(`/api/chats`)]);if(e&&(s.value=e),t&&(c.value=t),T.value=!0,o.value){let e=o.value;s.value.some(t=>t.jid===e)||c.value.some(t=>t.jid===e)||(o.value=null,r({jid:``}),l.value=[])}}async function fe(){if(!o.value)return;let e=await fu(`/api/messages?${new URLSearchParams({jid:o.value,limit:`200`})}`);e&&(l.value=e)}R(()=>ie.value.isStreaming,(e,t)=>{t&&!e&&fe()});function pe(e){o.value=e,r({jid:e}),p.value&&(y.value=!1),l.value=[],fe();let t=s.value.find(t=>t.jid===e);u.value=t?.requiresTrigger?`${t.trigger} `:``,setTimeout(()=>{d.value?.focus()},0)}function me(e){u.value=`/`+e+` `,Tn(()=>d.value?.focus())}function he(e){if(v.value.length>0){if(e.key===`ArrowUp`){e.preventDefault(),_.value=(_.value-1+v.value.length)%v.value.length;return}if(e.key===`ArrowDown`){e.preventDefault(),_.value=(_.value+1)%v.value.length;return}if(e.key===`Tab`||e.key===`Enter`){e.preventDefault();let t=v.value[_.value];t&&me(t.command);return}if(e.key===`Escape`){e.preventDefault(),u.value=``;return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ge())}async function ge(){if(!o.value)return;let e=u.value.trim();e&&(u.value=M.value?.requiresTrigger?`${M.value.trigger} `:``,we(),f.value=!0,await du(`/api/send`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({jid:o.value,message:e})}),await fe(),f.value=!1,await Tn(),d.value?.focus())}function _e(e){pe(e),ee.value=!0}async function ve(e){await h(`delete chat and all messages for ${e}?`)&&(await du(`/api/chats/${encodeURIComponent(e)}`,{method:`DELETE`}),o.value===e&&(o.value=null,l.value=[]),await de())}function ye(){o.value&&(k.value=c.value.find(e=>e.jid===o.value)?.name||``,ne.value=o.value,te.value=``,A.value=``,re.value=``,D.value=!0)}function be(){D.value=!1,k.value=``,te.value=``,ne.value=``,A.value=``,re.value=``}async function xe(){let e=k.value.trim();if(!e)return;let t=Tm(e),n=ne.value.startsWith(`tg:`)&&!t.startsWith(`tg-`)?`tg-${t}`:t,r=te.value.trim()||n,i=ne.value.trim()||`${r}@admin`;await du(`/api/groups`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({jid:i,name:e,folder:r,trigger:A.value.trim(),model:re.value||void 0})});let a=i;be(),await de(),pe(a)}async function Se(e,t){await du(`/api/groups/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),await de()}async function Ce(){if(!M.value)return;let e=`~/.pi/claw/groups/${M.value.folder}`,t=await fu(`/api/terminal`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cols:80,rows:24,cwd:e})});t&&a(`terminal`,{connectSession:t.id})}function we(){d.value&&(d.value.style.height=`auto`,d.value.style.height=`${Math.min(d.value.scrollHeight,120)}px`)}gu(de,3e4);function Te(e){if(e.metaKey&&e.key===`j`&&o.value){e.preventDefault(),ee.value=!ee.value;return}!se.value&&o.value&&(e.key===`Enter`&&!e.metaKey&&!e.ctrlKey&&!m.value?(e.preventDefault(),b.value?(ye(),b.value=!1):b.value=!0):e.key===`Escape`&&b.value&&(e.preventDefault(),b.value=!1))}return Ir(()=>{le(),ue(),o.value&&fe(),window.addEventListener(`keydown`,Te)}),Br(()=>{window.removeEventListener(`keydown`,Te)}),(e,n)=>(V(),H(`div`,{class:N([`flex overflow-hidden relative`,t.fillHeight?`h-full min-h-0`:`h-[calc(100dvh-140px)]`]),onTouchstart:S,onTouchmove:C,onTouchend:w},[Rn(W(oh,{items:ae.value,loading:!T.value,"current-jid":o.value,class:`max-md:absolute max-md:inset-y-0 max-md:left-0 max-md:z-10 max-md:w-[280px] max-md:min-w-0 max-md:!bg-surface`,onSelect:pe,onDelete:ve,onSettings:_e,onRegister:n[0]||=e=>D.value=!0,onToggle:n[1]||=e=>y.value=!y.value},null,8,[`items`,`loading`,`current-jid`]),[[Bo,y.value]]),D.value?(V(),wa(Cl,{key:0,title:`New chat`,width:`420px`,onClose:be},{default:Ln(()=>[U(`form`,{onSubmit:ws(xe,[`prevent`]),onKeydown:Es(be,[`escape`])},[U(`div`,sh,[n[26]||=U(`label`,{class:`label group/label`},[G(` name `),U(`span`,{class:`relative inline-block ml-0.5 cursor-help`},[U(`span`,{class:`text-[9px] text-border hover:text-muted transition-colors`},`?`),U(`span`,{class:`hidden group-hover/label:block absolute left-0 top-full mt-0.5 z-10 px-1.5 py-1 bg-surface border border-border rounded text-[10px] text-muted normal-case tracking-normal whitespace-nowrap`},`display name for this chat group`)])],-1),Rn(U(`input`,{ref_key:`regNameInput`,ref:O,"onUpdate:modelValue":n[2]||=e=>k.value=e,placeholder:`My Project`,class:`bg-bg border border-border rounded text-text px-2.5 py-1.5 text-[12px] font-mono w-full outline-none transition-colors focus:border-accent`},null,512),[[vs,k.value]])]),j.value?(V(),H(`div`,ch,` -> ~/`+P(j.value)+`/ · `+P(j.value)+`@admin `,1)):K(``,!0),j.value?(V(),H(`div`,lh,[U(`div`,uh,[U(`div`,null,[n[27]||=U(`label`,{class:`label group/label`},[G(` folder `),U(`span`,{class:`relative inline-block ml-0.5 cursor-help`},[U(`span`,{class:`text-[9px] text-border hover:text-muted transition-colors`},`?`),U(`span`,{class:`hidden group-hover/label:block absolute left-0 top-full mt-0.5 z-10 px-1.5 py-1 bg-surface border border-border rounded text-[10px] text-muted normal-case tracking-normal whitespace-nowrap`},`agent working directory name`)])],-1),Rn(U(`input`,{"onUpdate:modelValue":n[3]||=e=>te.value=e,placeholder:`auto`,class:`bg-bg border border-border rounded text-text px-2.5 py-1.5 text-[12px] font-mono w-full outline-none transition-colors focus:border-accent`},null,512),[[vs,te.value]])]),U(`div`,null,[n[28]||=U(`label`,{class:`label group/label`},[G(` jid `),U(`span`,{class:`relative inline-block ml-0.5 cursor-help`},[U(`span`,{class:`text-[9px] text-border hover:text-muted transition-colors`},`?`),U(`span`,{class:`hidden group-hover/label:block absolute left-0 top-full mt-0.5 z-10 px-1.5 py-1 bg-surface border border-border rounded text-[10px] text-muted normal-case tracking-normal whitespace-nowrap`},`unique chat identifier`)])],-1),Rn(U(`input`,{"onUpdate:modelValue":n[4]||=e=>ne.value=e,placeholder:`auto`,class:`bg-bg border border-border rounded text-text px-2.5 py-1.5 text-[12px] font-mono w-full outline-none transition-colors focus:border-accent`},null,512),[[vs,ne.value]])]),U(`div`,null,[n[29]||=U(`label`,{class:`label group/label`},[G(` trigger `),U(`span`,{class:`relative inline-block ml-0.5 cursor-help`},[U(`span`,{class:`text-[9px] text-border hover:text-muted transition-colors`},`?`),U(`span`,{class:`hidden group-hover/label:block absolute left-0 top-full mt-0.5 z-10 px-1.5 py-1 bg-surface border border-border rounded text-[10px] text-muted normal-case tracking-normal whitespace-nowrap`},`word to activate the agent (e.g. @pi)`)])],-1),Rn(U(`input`,{"onUpdate:modelValue":n[5]||=e=>A.value=e,placeholder:`default`,class:`bg-bg border border-border rounded text-text px-2.5 py-1.5 text-[12px] font-mono w-full outline-none transition-colors focus:border-accent`},null,512),[[vs,A.value]])]),U(`div`,null,[n[31]||=U(`label`,{class:`label group/label`},[G(` model `),U(`span`,{class:`relative inline-block ml-0.5 cursor-help`},[U(`span`,{class:`text-[9px] text-border hover:text-muted transition-colors`},`?`),U(`span`,{class:`hidden group-hover/label:block absolute left-0 top-full mt-0.5 z-10 px-1.5 py-1 bg-surface border border-border rounded text-[10px] text-muted normal-case tracking-normal whitespace-nowrap`},`override the global model for this chat`)])],-1),Rn(U(`select`,{"onUpdate:modelValue":n[6]||=e=>re.value=e,class:`bg-bg border border-border rounded text-text px-2.5 py-1.5 text-[12px] font-mono w-full outline-none transition-colors focus:border-accent`},[n[30]||=U(`option`,{value:``},`default`,-1),(V(!0),H(B,null,Zr(E.value,e=>(V(),H(`option`,{key:`${e.provider}/${e.id}`,value:`${e.provider}/${e.id}`},P(e.name),9,dh))),128))],512),[[ys,re.value]])])])])):K(``,!0),U(`div`,{class:`flex gap-2 items-center`},[n[33]||=U(`button`,{type:`submit`,class:`btn-primary`},[G(` register `),U(`span`,{class:`text-[9px] opacity-60 hidden sm:inline`},`↵`)],-1),U(`button`,{type:`button`,class:`btn-ghost`,onClick:be},[...n[32]||=[G(` cancel `,-1),U(`span`,{class:`text-[9px] opacity-60 hidden sm:inline`},`esc`,-1)]])])],32)]),_:1})):K(``,!0),ee.value&&o.value?(V(),wa(Cl,{key:1,title:`chat settings`,width:`360px`,onClose:n[13]||=e=>ee.value=!1},{default:Ln(()=>[U(`div`,fh,[U(`div`,null,[n[34]||=U(`label`,{class:`label`},`status`,-1),U(`div`,ph,[U(`span`,{class:N([`inline-block w-1.5 h-1.5 rounded-full`,M.value?`bg-ok`:`bg-warn`])},null,2),U(`span`,{class:N([`text-[12px] font-mono`,M.value?`text-ok`:`text-warn`])},P(M.value?`registered`:`unmanaged`),3)])]),M.value?(V(),H(`div`,mh,[U(`div`,null,[n[35]||=U(`label`,{class:`label`},`name`,-1),U(`input`,{value:M.value.name,class:`bg-bg border border-border rounded text-text px-2.5 py-1.5 text-[12px] font-mono w-full outline-none transition-colors focus:border-accent`,onChange:n[7]||=e=>Se(o.value,{name:e.target.value})},null,40,hh)]),U(`div`,null,[n[36]||=U(`label`,{class:`label`},`trigger`,-1),U(`input`,{value:M.value.trigger,class:`bg-bg border border-border rounded text-text px-2.5 py-1.5 text-[12px] font-mono w-full outline-none transition-colors focus:border-accent`,onChange:n[8]||=e=>Se(o.value,{trigger:e.target.value})},null,40,gh)]),U(`div`,null,[n[38]||=U(`label`,{class:`label`},`model`,-1),U(`select`,{value:M.value.model||``,class:`bg-bg border border-border rounded text-text px-2.5 py-1.5 text-[12px] font-mono w-full outline-none transition-colors focus:border-accent`,onChange:n[9]||=e=>Se(o.value,{model:e.target.value||null})},[n[37]||=U(`option`,{value:``},`default`,-1),(V(!0),H(B,null,Zr(E.value,e=>(V(),H(`option`,{key:`${e.provider}/${e.id}`,value:`${e.provider}/${e.id}`},P(e.name),9,vh))),128))],40,_h)]),U(`div`,null,[n[40]||=U(`label`,{class:`label`},`require trigger`,-1),U(`select`,{value:M.value.requiresTrigger===!1?`false`:`true`,class:`bg-bg border border-border rounded text-text px-2.5 py-1.5 text-[12px] font-mono w-full outline-none transition-colors focus:border-accent`,onChange:n[10]||=e=>Se(o.value,{requiresTrigger:e.target.value===`true`?null:!1})},[...n[39]||=[U(`option`,{value:`true`},`yes`,-1),U(`option`,{value:`false`},`no (all messages)`,-1)]],40,yh)]),U(`div`,bh,[n[41]||=U(`label`,{class:`label`},`folder`,-1),U(`div`,xh,`~/`+P(M.value.folder)+`/`,1)])])):K(``,!0),U(`div`,Sh,[U(`button`,{type:`button`,class:`btn-ghost`,onClick:n[11]||=e=>ee.value=!1},[...n[42]||=[G(` close `,-1),U(`span`,{class:`text-[9px] opacity-60 hidden sm:inline`},`esc`,-1)]]),U(`button`,{type:`button`,class:`btn-danger`,onClick:n[12]||=e=>{ee.value=!1,ve(o.value)}},` delete chat `)])])]),_:1})):K(``,!0),U(`div`,{class:N([`flex-1 flex flex-col min-w-0`,m.value&&L(p)?`max-md:fixed max-md:inset-0 max-md:z-20 max-md:bg-bg`:``]),id:`chat-main`},[o.value?(V(),H(`div`,Dh,[U(`div`,Oh,[y.value?K(``,!0):(V(),wa(jm,{key:0,class:`mr-1`,onClick:n[16]||=e=>y.value=!0})),U(`div`,kh,P((oe.value[0]||`?`).toUpperCase()),1),U(`div`,Ah,[U(`div`,jh,P(oe.value),1)]),M.value?(V(),H(`button`,{key:1,type:`button`,class:`text-muted hover:text-text leading-none transition-colors flex items-center gap-1`,title:`files`,onClick:n[17]||=e=>L(a)(`files`,{folder:M.value.folder,path:`.`})},[W(L(vl),{icon:`lucide:folder-open`,class:`text-base`})])):K(``,!0),M.value?(V(),H(`button`,{key:2,type:`button`,class:`text-muted hover:text-text leading-none transition-colors flex items-center gap-1`,title:`open terminal in group dir`,onClick:n[18]||=e=>Ce()},[W(L(vl),{icon:`lucide:terminal`,class:`text-base`})])):K(``,!0),U(`button`,{type:`button`,class:`text-muted hover:text-text leading-none transition-colors flex items-center gap-1`,title:`chat settings (⌘J)`,onClick:n[19]||=e=>ee.value=!0},[W(L(vl),{icon:`lucide:settings`,class:`text-base`})])]),T.value&&!se.value?(V(),H(`div`,Mh,[n[49]||=U(`div`,{class:`text-muted`},`this chat is not registered — messages won't reach the agent`,-1),b.value?(V(),H(B,{key:1},[n[48]||=U(`div`,{class:`text-[11px] text-warn font-semibold`},` only register chats you trust — registered chats get full agent access `,-1),U(`div`,Nh,[U(`button`,{type:`button`,class:`px-5 py-2 bg-accent text-bg rounded-full text-[13px] font-medium cursor-pointer transition-colors hover:bg-accent/90`,onClick:n[21]||=e=>{ye(),b.value=!1}},[...n[46]||=[G(` confirm `,-1),U(`span`,{class:`text-[9px] opacity-60 hidden sm:inline`},`↵`,-1)]]),U(`button`,{type:`button`,class:`px-4 py-2 text-muted rounded-full text-[13px] font-medium cursor-pointer transition-colors hover:text-text`,onClick:n[22]||=e=>b.value=!1},[...n[47]||=[G(` cancel `,-1),U(`span`,{class:`text-[9px] opacity-60 hidden sm:inline`},`esc`,-1)]])])],64)):(V(),H(`button`,{key:0,type:`button`,class:`px-5 py-2 bg-accent text-bg rounded-full text-[13px] font-medium cursor-pointer transition-colors hover:bg-accent/90`,onClick:n[20]||=e=>b.value=!0},[...n[45]||=[G(` register chat `,-1),U(`span`,{class:`text-[9px] opacity-60 hidden sm:inline`},`↵`,-1)]]))])):K(``,!0),M.value&&M.value.requiresTrigger?(V(),H(`div`,Ph,[n[50]||=U(`span`,{class:`opacity-60`},`trigger:`,-1),U(`span`,Fh,P(M.value.trigger),1),n[51]||=U(`span`,{class:`opacity-50`},`— prefix messages to reach the agent`,-1)])):K(``,!0),W(Xm,{messages:l.value,"stream-state":L(ie),"typing-visible":ce.value,"sending-message":f.value},null,8,[`messages`,`stream-state`,`typing-visible`,`sending-message`]),U(`form`,{autocomplete:`off`,"data-form-type":`other`,class:N([`shrink-0 px-3 py-2.5 border-t border-border flex gap-2 items-end bg-surface`,m.value&&L(p)?`max-md:absolute max-md:bottom-0 max-md:left-0 max-md:right-0`:``]),onSubmit:ws(ge,[`prevent`])},[U(`div`,Ih,[v.value.length>0?(V(),H(`div`,Lh,[(V(!0),H(B,null,Zr(v.value,(e,t)=>(V(),H(`button`,{key:e.command,type:`button`,class:N([`w-full px-3 py-1.5 text-left text-[12px] flex items-center gap-2 cursor-pointer transition-colors`,t===_.value?`bg-accent/12 text-accent`:`text-text hover:bg-bg`]),onMousedown:ws(t=>me(e.command),[`prevent`])},[U(`span`,zh,`/`+P(e.command),1),U(`span`,Bh,P(e.description),1)],42,Rh))),128))])):K(``,!0),Rn(U(`textarea`,{ref_key:`composeRef`,ref:d,"onUpdate:modelValue":n[23]||=e=>u.value=e,name:`message`,placeholder:`message...`,rows:`1`,autocomplete:`off`,autocorrect:`off`,autocapitalize:`off`,spellcheck:`false`,enterkeyhint:`send`,class:`w-full min-h-[38px] max-h-[120px] resize-none px-4 py-2.5 rounded-2xl text-[13px] leading-snug bg-bg border border-border text-text outline-none transition-colors focus:border-accent font-sans`,disabled:f.value,onInput:we,onKeydown:he,onFocus:n[24]||=e=>m.value=!0,onBlur:n[25]||=e=>m.value=!1},null,40,Vh),[[vs,u.value]])]),U(`button`,{type:`submit`,class:`rounded-full w-9 h-9 p-0 flex items-center justify-center shrink-0 text-sm bg-accent text-bg cursor-pointer transition-colors hover:bg-accent/90 disabled:text-muted disabled:bg-surface disabled:border-border`,disabled:f.value},[...n[52]||=[U(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`},[U(`path`,{d:`M22 2L11 13`}),U(`path`,{d:`M22 2L15 22L11 13L2 9L22 2Z`})],-1)]],8,Hh)],34)])):(V(),H(`div`,Ch,[y.value?K(``,!0):(V(),H(`div`,wh,[W(jm,{onClick:n[14]||=e=>y.value=!0})])),U(`div`,Th,[U(`div`,Eh,[n[43]||=U(`div`,{class:`text-[28px] mb-3 text-border`},`~`,-1),n[44]||=U(`div`,{class:`mb-4`},`no chat selected`,-1),U(`button`,{type:`button`,class:`h-10 flex items-center justify-center text-[18px] bg-accent-dim text-accent rounded-full cursor-pointer transition-colors hover:bg-accent-dimmer mx-auto px-4 gap-1.5`,onClick:n[15]||=e=>D.value=!0},` + `)])])]))],2)],34))}}),Wh={key:`chat`,label:`Chats`,icon:`pixelarticons:chat`,color:`#58a6ff`,component:{name:`ChatContent`,render:()=>oo(Uh,{fillHeight:!0})},window:{width:1e3,height:700,minwidth:420,minheight:320}},Gh={"package.json":{icon:`lucide:package`,color:`text-ok`},".gitignore":{icon:`lucide:git-branch`,color:`text-warn`},".gitattributes":{icon:`lucide:git-branch`,color:`text-warn`},dockerfile:{icon:`lucide:container`,color:`text-accent`},license:{icon:`lucide:scale`,color:`text-muted`},makefile:{icon:`lucide:terminal`,color:`text-muted`}},Kh=[{test:e=>e.startsWith(`tsconfig`)&&e.endsWith(`.json`),result:{icon:`lucide:settings`,color:`text-accent`}},{test:e=>e.startsWith(`.env`),result:{icon:`lucide:lock`,color:`text-warn`}},{test:e=>e.endsWith(`.lock`),result:{icon:`lucide:lock`,color:`text-muted`}}],qh={ts:{icon:`lucide:file-code`,color:`text-accent`},tsx:{icon:`lucide:file-code`,color:`text-accent`},js:{icon:`lucide:file-code`,color:`text-warn`},jsx:{icon:`lucide:file-code`,color:`text-warn`},mjs:{icon:`lucide:file-code`,color:`text-warn`},cjs:{icon:`lucide:file-code`,color:`text-warn`},vue:{icon:`lucide:file-code`,color:`text-ok`},md:{icon:`lucide:file-text`,color:`text-accent`},json:{icon:`lucide:braces`,color:`text-warn`},css:{icon:`lucide:file-code`,color:`text-accent`},scss:{icon:`lucide:file-code`,color:`text-accent`},yaml:{icon:`lucide:file-cog`,color:`text-muted`},yml:{icon:`lucide:file-cog`,color:`text-muted`},toml:{icon:`lucide:file-cog`,color:`text-muted`},sh:{icon:`lucide:terminal`,color:`text-ok`},bash:{icon:`lucide:terminal`,color:`text-ok`},zsh:{icon:`lucide:terminal`,color:`text-ok`},png:{icon:`lucide:image`,color:`text-warn`},jpg:{icon:`lucide:image`,color:`text-warn`},jpeg:{icon:`lucide:image`,color:`text-warn`},gif:{icon:`lucide:image`,color:`text-warn`},svg:{icon:`lucide:image`,color:`text-warn`},webp:{icon:`lucide:image`,color:`text-warn`},ico:{icon:`lucide:image`,color:`text-warn`},sql:{icon:`lucide:database`,color:`text-accent`},db:{icon:`lucide:database`,color:`text-accent`},sqlite:{icon:`lucide:database`,color:`text-accent`},txt:{icon:`lucide:file-text`,color:`text-muted`},log:{icon:`lucide:file-text`,color:`text-muted`},py:{icon:`lucide:file-code`,color:`text-ok`},go:{icon:`lucide:file-code`,color:`text-accent`},rs:{icon:`lucide:file-code`,color:`text-warn`},html:{icon:`lucide:file-code`,color:`text-warn`},htm:{icon:`lucide:file-code`,color:`text-warn`},xml:{icon:`lucide:file-code`,color:`text-muted`}},Jh={icon:`lucide:file`,color:`text-muted`};function Yh(e){let t=e.toLowerCase();if(Gh[t])return Gh[t];for(let e of Kh)if(e.test(t))return e.result;let n=t.split(`.`).pop();return n&&qh[n]?qh[n]:Jh}function Xh(e){return{icon:e?`lucide:folder-open`:`lucide:folder`,color:`text-accent`}}var Zh=[`onClick`],Qh={key:1,class:`inline-block w-3`},$h=z({__name:`FileTree`,props:{nodes:{},depth:{},activeFolder:{},activePath:{}},emits:[`toggle`,`select`,`open`],setup(e,{emit:t}){let n=t;return(t,r)=>{let i=Kr(`FileTree`,!0);return V(!0),H(B,null,Zr(e.nodes,t=>(V(),H(`div`,{key:t.folder+`/`+t.path},[U(`button`,{type:`button`,class:N([`w-full text-left py-1 text-[11px] font-mono transition-colors block truncate`,t.isFile?`text-muted hover:text-text`:t.folder===e.activeFolder&&t.path===e.activePath?`bg-surface text-text`:`text-muted hover:text-text`]),style:M({paddingLeft:(e.depth??0)*12+8+`px`,paddingRight:`8px`}),onClick:e=>t.isFile?n(`open`,t):(n(`toggle`,t),n(`select`,t))},[t.isFile?(V(),H(B,{key:1},[r[3]||=U(`span`,{class:`inline-block w-3`},null,-1),W(L(vl),{icon:L(Yh)(t.name).icon,class:N([L(Yh)(t.name).color,`inline-block w-3.5 h-3.5 align-[-3px] mx-0.5`])},null,8,[`icon`,`class`])],64)):(V(),H(B,{key:0},[t.children?.length||!t.loaded?(V(),wa(L(vl),{key:0,icon:t.expanded?`lucide:chevron-down`:`lucide:chevron-right`,class:`inline-block w-3 h-3 align-[-2px] text-muted`},null,8,[`icon`])):(V(),H(`span`,Qh)),W(L(vl),{icon:L(Xh)(t.expanded).icon,class:N([L(Xh)(t.expanded).color,`inline-block w-3.5 h-3.5 align-[-3px] mx-0.5`])},null,8,[`icon`,`class`])],64)),G(` `+P(t.name),1)],14,Zh),!t.isFile&&t.expanded&&t.children&&t.children.length>0?(V(),wa(i,{key:0,nodes:t.children,depth:(e.depth??0)+1,"active-folder":e.activeFolder,"active-path":e.activePath,onToggle:r[0]||=e=>n(`toggle`,e),onSelect:r[1]||=e=>n(`select`,e),onOpen:r[2]||=e=>n(`open`,e)},null,8,[`nodes`,`depth`,`active-folder`,`active-path`])):K(``,!0)]))),128)}}}),eg={class:`flex h-full`},tg={key:0,class:`w-[180px] min-w-[140px] border-r border-border overflow-auto py-2 flex-shrink-0`},ng={key:0,class:`px-3 py-4 text-[11px] text-muted`},rg={class:`flex-1 flex flex-col min-w-0`},ig={class:`px-3 py-1.5 text-[11px] text-muted flex items-center gap-1 border-b border-border`},ag={key:0,class:`opacity-40`},og=[`onClick`],sg={class:`ml-auto flex items-center gap-1 flex-shrink-0`},cg={key:0,class:`text-center py-8 text-muted text-[12px]`},lg=[`onClick`,`onDblclick`],ug={key:2,class:`grid grid-cols-[repeat(auto-fill,minmax(80px,1fr))] gap-1`},dg=[`onClick`,`onDblclick`],fg={class:`text-[10px] font-mono text-center w-full truncate text-accent`},pg={key:3,class:`w-full border-collapse text-[12px]`},mg={key:1},hg=[`onClick`,`onDblclick`,`onContextmenu`,`onTouchstart`],gg={class:`py-1.5 px-2 border-b border-border font-mono`},_g={key:0,class:`inline-flex items-center gap-1.5 text-accent`},vg={key:1,class:`inline-flex items-center gap-1.5`},yg={class:`py-1.5 px-2 border-b border-border text-muted`},bg={class:`py-1.5 px-2 border-b border-border text-muted`},xg={key:1,class:`text-center py-8 text-muted text-[12px]`},Sg={class:`grid grid-cols-[repeat(auto-fill,minmax(80px,1fr))] gap-1`},Cg=[`onClick`,`onDblclick`,`onContextmenu`,`onTouchstart`],wg={key:`files`,label:`Files`,icon:`pixelarticons:folder`,color:`#7fd962`,component:z({__name:`window`,setup(e){let{confirm:t}=ou(),n=mu(),{settings:r,set:i}=Xl(),{state:a,set:o,openWindow:s,setTitle:c}=$l(),{menu:l,onContext:u,onTouchStart:d,cancelLongPress:f,close:p}=Bl(),m=F([]),h=F([]),g=F(a.value.folder||``),_=F(a.value.path||`.`),v=F([]),y=F(-1),b=F(),x=F(r.filesViewMode??(n.value?`grid`:`list`)),S=F(window.innerWidth>=640),C=q(()=>{let e=[`~`];return g.value?(e.push(g.value),_.value!==`.`&&e.push(..._.value.split(`/`)),e):e}),w=q(()=>[...v.value].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1)),T=q(()=>m.value.find(e=>e.folder===g.value)?.readonly===!0);async function ee(){let e=await fu(`/api/files/groups`);if(!e)return;m.value=e;let t=new Set(h.value.map(e=>e.folder));for(let n of e)t.has(n.folder)||h.value.push({name:n.folder,path:`.`,folder:n.folder,expanded:!1,loaded:!1});h.value=h.value.filter(t=>e.some(e=>e.folder===t.folder)),te()}async function E(e){let t=await fu(`/api/files?${new URLSearchParams({folder:e.folder,path:e.path})}`);t&&(e.children=[...t.entries].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1).map(t=>({name:t.name,path:e.path===`.`?t.name:`${e.path}/${t.name}`,folder:e.folder,isFile:t.type===`file`,expanded:!1,loaded:t.type===`file`})),e.loaded=!0)}async function D(e){if(e.expanded){e.expanded=!1;return}e.loaded||await E(e),e.expanded=!0}function O(e){g.value=e.folder,_.value=e.path}function k(e){g.value=e.folder;let t=e.path.split(`/`);t.pop(),_.value=t.length>0?t.join(`/`):`.`,s(`viewer`,{folder:e.folder,path:e.path})}async function te(){if(!g.value)return;let e=h.value.find(e=>e.folder===g.value&&e.path===`.`);if(!e||(e.expanded=!0,e.loaded||await E(e),_.value===`.`))return;let t=_.value.split(`/`).filter(Boolean),n=e;for(let e of t){if(!n.children)return;let t=n.children.find(t=>t.name===e&&!t.isFile);if(t||=(n.loaded||await E(n),n.children?.find(t=>t.name===e&&!t.isFile)),!t)return;if(t.loaded||await E(t),(t.children?.length??0)>10){n=t;continue}t.expanded=!0,n=t}}async function ne(){if(!g.value)return;let e=await fu(`/api/files?${new URLSearchParams({folder:g.value,path:_.value})}`);e&&(v.value=e.entries),y.value=0}function A(e){let t=_.value===`.`?e:`${_.value}/${e}`;s(`viewer`,{folder:g.value,path:t})}async function re(e){if(!await t(`delete ${e.name+(e.type===`directory`?`/`:``)}?`))return;let n=_.value===`.`?e.name:`${_.value}/${e.name}`;await fu(`/api/files/delete`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({folder:g.value,path:n})}),await ne(),v.value.length===0&&_.value!==`.`?j(`..`):y.value=Math.min(y.value,w.value.length-1)}function j(e){if(e===`..`){if(_.value===`.`){g.value=``,v.value=[];return}let e=_.value.split(`/`);e.pop(),_.value=e.length>0?e.join(`/`):`.`;return}_.value=_.value===`.`?e:`${_.value}/${e}`}function ie(e){g.value=e.folder,_.value=`.`}function ae(e){n.value&&ie(e)}function oe(e,t){y.value=t,!(!n.value||l.value)&&(e.type===`directory`?j(e.name):A(e.name))}function se(e){if(e===0){g.value=``,_.value=`.`,v.value=[];return}e===1?_.value=`.`:_.value=_.value.split(`/`).slice(0,e-1).join(`/`)}R(g,e=>o({folder:e})),R(_,e=>o({path:e})),R(x,e=>{o({viewMode:e}),i({filesViewMode:e})}),R(()=>r.filesViewMode,e=>{e&&e!==x.value&&(x.value=e)}),R([g,_],([e,t])=>{if(!e)return c(`Files`);c(`Files — ${t&&t!==`.`?`${e}/${t}`:e}`)});let M;function ce(){if(M?.close(),!g.value)return;let e=new URLSearchParams({folder:g.value,path:_.value}),t=new EventSource(`/api/files/watch?${e}`);t.onmessage=()=>ne(),M=t}R([g,_],()=>{ne(),ce(),te()},{immediate:!0}),Br(()=>M?.close()),gu(ee,1e4);function le(){l.value&&re(l.value.data),p()}function ue(){if(!l.value)return;let e=l.value.data;e.type===`directory`?j(e.name):A(e.name),p()}function de(){let e=b.value?.clientWidth??0;return e<=0?1:Math.max(1,Math.floor((e+4)/84))}function fe(e){if(e.key===`Delete`||e.key===`Backspace`||e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey&&e.key.toLowerCase()===`u`){e.preventDefault(),j(`..`);return}let t=w.value;if(!t.length)return;let n=Math.max(y.value,0);if(y.value<0&&(y.value=0),[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].includes(e.key)){e.preventDefault();let r=n;if(x.value===`grid`){let t=de();e.key===`ArrowLeft`?r=n-1:e.key===`ArrowRight`?r=n+1:e.key===`ArrowUp`?r=n-t:e.key===`ArrowDown`&&(r=n+t)}else e.key===`ArrowLeft`||e.key===`ArrowUp`?r=n-1:(e.key===`ArrowRight`||e.key===`ArrowDown`)&&(r=n+1);y.value=Math.max(0,Math.min(r,t.length-1))}else if(e.key===`Enter`){e.preventDefault();let n=t[y.value];n&&(n.type===`directory`?j(n.name):A(n.name))}}function pe(e){return e===void 0?`-`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}return(e,t)=>(V(),H(`div`,eg,[S.value?(V(),H(`div`,tg,[h.value.length===0?(V(),H(`div`,ng,`no groups`)):K(``,!0),W($h,{nodes:h.value,"active-folder":g.value,"active-path":_.value,onToggle:D,onSelect:O,onOpen:k},null,8,[`nodes`,`active-folder`,`active-path`])])):K(``,!0),U(`div`,rg,[U(`div`,ig,[U(`button`,{type:`button`,class:N([`btn-sm hover:bg-surface mr-1`,S.value?`text-text`:``]),onClick:t[0]||=e=>S.value=!S.value},[W(L(vl),{icon:`lucide:panel-left`,class:`w-3 h-3`})],2),(V(!0),H(B,null,Zr(C.value,(e,t)=>(V(),H(B,{key:t},[t>0?(V(),H(`span`,ag,`/`)):K(``,!0),U(`button`,{type:`button`,class:N([`hover:text-text transition-colors`,t===C.value.length-1?`text-text`:``]),onClick:e=>se(t)},P(t===0?`~/`:e),11,og)],64))),128)),U(`div`,sg,[U(`button`,{type:`button`,class:N([`btn-sm hover:bg-surface`,x.value===`list`?`text-text`:``]),onClick:t[1]||=e=>x.value=`list`},[W(L(vl),{icon:`lucide:list`,class:`w-3 h-3`})],2),U(`button`,{type:`button`,class:N([`btn-sm hover:bg-surface`,x.value===`grid`?`text-text`:``]),onClick:t[2]||=e=>x.value=`grid`},[W(L(vl),{icon:`lucide:layout-grid`,class:`w-3 h-3`})],2),g.value?(V(),H(`button`,{key:0,type:`button`,class:`btn-sm hover:bg-surface`,onClick:ne},` refresh `)):K(``,!0)])]),U(`div`,{ref_key:`listingEl`,ref:b,class:`flex-1 overflow-auto p-3 outline-none`,tabindex:`0`,onKeydown:fe},[!g.value&&m.value.length===0?(V(),H(`div`,cg,` no groups `)):!g.value&&x.value===`list`?(V(!0),H(B,{key:1},Zr(m.value,e=>(V(),H(`div`,{key:e.jid,class:`flex items-center gap-1.5 px-2 py-1.5 font-mono text-[12px] text-accent hover:bg-surface cursor-pointer rounded`,onClick:t=>ae(e),onDblclick:t=>ie(e)},[W(L(vl),{icon:`lucide:folder`,class:`w-3.5 h-3.5 flex-shrink-0`}),G(` `+P(e.folder)+`/ `,1)],40,lg))),128)):g.value?x.value===`list`?(V(),H(`table`,pg,[t[11]||=U(`thead`,null,[U(`tr`,null,[U(`th`,{class:`text-left text-muted font-medium py-1.5 px-2 border-b border-border text-[10px] uppercase tracking-wide`},` name `),U(`th`,{class:`text-left text-muted font-medium py-1.5 px-2 border-b border-border text-[10px] uppercase tracking-wide w-[80px]`},` size `),U(`th`,{class:`text-left text-muted font-medium py-1.5 px-2 border-b border-border text-[10px] uppercase tracking-wide w-[80px]`},` modified `)])],-1),U(`tbody`,null,[_.value===`.`?K(``,!0):(V(),H(`tr`,{key:0,class:`hover:bg-surface cursor-pointer`,onClick:t[3]||=e=>j(`..`)},[...t[9]||=[U(`td`,{colspan:`3`,class:`py-1.5 px-2 border-b border-border font-mono text-muted`},` .. `,-1)]])),w.value.length===0?(V(),H(`tr`,mg,[...t[10]||=[U(`td`,{colspan:`3`,class:`text-center py-8 text-muted text-[12px]`},`empty directory`,-1)]])):K(``,!0),(V(!0),H(B,null,Zr(w.value,(e,n)=>(V(),H(`tr`,{key:e.name,class:N([`cursor-pointer`,n===y.value?`bg-surface`:`hover:bg-surface`]),onClick:t=>oe(e,n),onDblclick:t=>e.type===`directory`?j(e.name):A(e.name),onContextmenu:t=>L(u)(t,e),onTouchstart:t=>L(d)(t,e),onTouchend:t[4]||=(...e)=>L(f)&&L(f)(...e),onTouchmove:t[5]||=(...e)=>L(f)&&L(f)(...e)},[U(`td`,gg,[e.type===`directory`?(V(),H(`span`,_g,[W(L(vl),{icon:L(Xh)(!1).icon,class:`w-3.5 h-3.5 flex-shrink-0`},null,8,[`icon`]),G(` `+P(e.name)+`/ `,1)])):(V(),H(`span`,vg,[W(L(vl),{icon:L(Yh)(e.name).icon,class:N([L(Yh)(e.name).color,`w-3.5 h-3.5 flex-shrink-0`])},null,8,[`icon`,`class`]),G(` `+P(e.name),1)]))]),U(`td`,yg,P(pe(e.size)),1),U(`td`,bg,P(L(Cm)(e.mtime)),1)],42,hg))),128))])])):(V(),H(B,{key:4},[_.value===`.`?K(``,!0):(V(),H(`div`,{key:0,class:`flex items-center gap-1.5 px-2 py-1.5 mb-1 font-mono text-[12px] text-muted hover:bg-surface cursor-pointer rounded`,onClick:t[6]||=e=>j(`..`)},` .. `)),w.value.length===0?(V(),H(`div`,xg,` empty directory `)):K(``,!0),U(`div`,Sg,[(V(!0),H(B,null,Zr(w.value,(e,n)=>(V(),H(`div`,{key:e.name,class:N([`flex flex-col items-center gap-1 p-2 rounded cursor-pointer select-none`,n===y.value?`bg-surface`:`hover:bg-surface`]),onClick:t=>oe(e,n),onDblclick:t=>e.type===`directory`?j(e.name):A(e.name),onContextmenu:t=>L(u)(t,e),onTouchstart:t=>L(d)(t,e),onTouchend:t[7]||=(...e)=>L(f)&&L(f)(...e),onTouchmove:t[8]||=(...e)=>L(f)&&L(f)(...e)},[e.type===`directory`?(V(),wa(L(vl),{key:0,icon:L(Xh)(!1).icon,class:`w-7 h-7 text-accent`},null,8,[`icon`])):(V(),wa(L(vl),{key:1,icon:L(Yh)(e.name).icon,class:N([L(Yh)(e.name).color,`w-7 h-7`])},null,8,[`icon`,`class`])),U(`span`,{class:N([`text-[10px] font-mono text-center w-full truncate`,e.type===`directory`?`text-accent`:`text-text`])},P(e.name),3)],42,Cg))),128))])],64)):(V(),H(`div`,ug,[(V(!0),H(B,null,Zr(m.value,e=>(V(),H(`div`,{key:e.jid,class:`flex flex-col items-center gap-1 p-2 rounded cursor-pointer select-none hover:bg-surface`,onClick:t=>ae(e),onDblclick:t=>ie(e)},[W(L(vl),{icon:`lucide:folder`,class:`w-7 h-7 text-accent`}),U(`span`,fg,P(e.folder),1)],40,dg))),128))]))],544)]),W(yl,{pos:L(l)??null},{default:Ln(()=>[U(`button`,{class:`w-full text-left px-3 py-1.5 text-[12px] text-text cursor-pointer transition-colors hover:bg-accent-dim hover:text-accent`,onClick:ue},` Open `),T.value?K(``,!0):(V(),H(`button`,{key:0,class:`w-full text-left px-3 py-1.5 text-[12px] text-text cursor-pointer transition-colors hover:bg-danger-dim hover:text-danger`,onClick:le},` Delete `))]),_:1},8,[`pos`])]))}}),window:{width:800,height:520,minwidth:480,minheight:300}},Tg={class:`flex flex-col h-full`},Eg={class:`flex gap-2 items-center p-3 pb-0`},Dg=[`value`],Og={class:`flex-1 overflow-auto p-3 pt-2 select-text relative`},kg={class:`w-full border-collapse text-[12px] table-fixed`},Ag={key:0},jg={colspan:`2`,class:`text-center py-8 text-muted text-[12px]`},Mg={key:1},Ng={class:`py-1.5 px-2 border-b border-border align-top`},Pg={class:`mt-0.5`},Fg={class:`badge-muted`},Ig=[`title`],Lg={class:`badge-muted whitespace-nowrap`},Rg={class:`py-1.5 px-2 border-b border-border font-mono select-text break-all align-top`},zg=[`innerHTML`],Bg={key:`logs`,label:`Logs`,icon:`pixelarticons:list-box`,color:`#e5a535`,component:z({__name:`window`,setup(e){let t={10:`debug`,20:`info`,30:`warn`,40:`error`,50:`fatal`},n=F([]),r=F(!0),i=F(``),a=F(``),o=F([]),s;function c(){s?.close(),r.value=!0;let e=new URLSearchParams({limit:`200`});i.value&&e.set(`level`,i.value),a.value&&e.set(`tag`,a.value);let t=new EventSource(`/api/logs?${e}`);t.onmessage=e=>{try{let t=JSON.parse(e.data);n.value=t,r.value=!1;let i=new Set(t.map(e=>e.tag));for(let e of i)o.value.includes(e)||o.value.push(e);o.value.sort()}catch{}},s=t}Ir(()=>{c()}),Br(()=>{s?.close()}),R([i,a],c);function l(e){return t[e]??String(e)}function u(e){return e>=40?`badge-danger`:e>=30?`badge-warn`:e>=20?`badge-accent`:`badge-muted`}function d(e){return JSON.stringify(e,null,2).replace(/^\{\n/,``).replace(/\n\}$/,``).replace(/^ /gm,``).replace(/("(?:\\.|[^"\\])*")\s*(:)?|(\b(?:true|false|null)\b)|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g,(e,t,n,r,i)=>t?n?`<span class="text-accent">${f(t)}</span>:`:`<span class="text-green">${f(t)}</span>`:r?`<span class="text-warn">${e}</span>`:i?`<span class="text-danger">${e}</span>`:e)}function f(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}return(e,t)=>(V(),H(`div`,Tg,[U(`div`,Eg,[t[4]||=U(`h3`,{class:`section-title`},`system logs`,-1),Rn(U(`select`,{"onUpdate:modelValue":t[0]||=e=>a.value=e,class:`ml-auto bg-bg border border-border rounded text-text px-2 py-1 text-[11px] font-mono outline-none transition-colors focus:border-accent`},[t[2]||=U(`option`,{value:``},`all tags`,-1),(V(!0),H(B,null,Zr(o.value,e=>(V(),H(`option`,{key:e,value:e},P(e),9,Dg))),128))],512),[[ys,a.value]]),Rn(U(`select`,{"onUpdate:modelValue":t[1]||=e=>i.value=e,class:`bg-bg border border-border rounded text-text px-2 py-1 text-[11px] font-mono outline-none transition-colors focus:border-accent`},[...t[3]||=[Ma(`<option value="">all levels</option><option value="10">debug+</option><option value="20">info+</option><option value="30">warn+</option><option value="40">error+</option><option value="50">fatal</option>`,6)]],512),[[ys,i.value]])]),U(`div`,Og,[U(`table`,kg,[t[7]||=U(`thead`,null,[U(`tr`,null,[U(`th`,{class:`text-left text-muted font-medium py-1.5 px-2 border-b border-border text-[10px] uppercase tracking-wide w-[90px]`},` info `),U(`th`,{class:`text-left text-muted font-medium py-1.5 px-2 border-b border-border text-[10px] uppercase tracking-wide`},` message `)])],-1),U(`tbody`,null,[r.value?(V(),H(`tr`,Ag,[U(`td`,jg,[W(L(vl),{icon:`lucide:loader`,class:`inline-block align-[-2px] mr-1 animate-spin`}),t[5]||=G(`loading... `,-1)])])):n.value.length===0?(V(),H(`tr`,Mg,[...t[6]||=[U(`td`,{colspan:`2`,class:`text-center py-8 text-muted text-[12px]`},`no logs`,-1)]])):K(``,!0),(V(!0),H(B,null,Zr(n.value,e=>(V(),H(`tr`,{key:e.timestamp,class:`hover:bg-surface`},[U(`td`,Ng,[U(`span`,{class:N(u(e.level))},[W(L(vl),{icon:`lucide:signal`,class:`inline-block align-[-2px] mr-0.5 text-[10px]`}),G(P(l(e.level)),1)],2),U(`div`,Pg,[U(`span`,Fg,[W(L(vl),{icon:`lucide:tag`,class:`inline-block align-[-2px] mr-0.5 text-[10px]`}),G(P(e.tag),1)])]),U(`div`,{class:`mt-0.5`,title:e.timestamp},[U(`span`,Lg,[W(L(vl),{icon:`lucide:clock`,class:`inline-block align-[-2px] mr-0.5 text-[10px]`}),G(P(L(Cm)(e.timestamp)),1)])],8,Ig)]),U(`td`,Rg,[U(`span`,null,P(e.message),1),e.data?(V(),H(`pre`,{key:0,class:`whitespace-pre-wrap m-0 mt-1 text-muted text-[11px]`,innerHTML:d(e.data)},null,8,zg)):K(``,!0)])]))),128))])])])]))}}),window:{width:800,height:500,minwidth:400,minheight:280}},Vg={class:`grid gap-3 p-3`},Hg={key:0,class:`border border-border p-3`},Ug={class:`w-full border-collapse text-[12px]`},Wg={class:`hover:bg-surface`},Gg={class:`py-1.5 px-2 border-b border-border font-mono`},Kg={class:`hover:bg-surface`},qg={class:`py-1.5 px-2 border-b border-border font-mono`},Jg=[`href`],Yg={class:`hover:bg-surface`},Xg={class:`py-1.5 px-2`},Zg={key:0,class:`badge-ok`},Qg={key:1,class:`text-muted`},$g={key:1,class:`border border-border p-3`},e_={key:2,class:`border border-border p-3`},t_={class:`mb-2`},n_={class:`mb-2`},r_={class:`flex gap-1.5`},i_={class:`mb-2`},a_={key:0,class:`text-[11px] text-danger mb-2`},o_=[`disabled`],s_={key:3,class:`border border-border p-3`},c_={key:0,class:`text-[11px] text-danger mb-2`},l_={key:1,class:`text-[11px] text-ok mb-2`},u_={class:`flex gap-2`},d_=[`disabled`],f_=[`disabled`],p_={key:`ntfy`,label:`Notifications`,icon:`mdi:bell-ring-outline`,color:`#4CAF50`,component:z({__name:`window`,setup(e){let t=F(null),n=F(`https://ntfy.sh`),r=F(``),i=F(``),a=F(!1),o=F(``),s=F(``),c=q(()=>t.value?.configured??!1);async function l(){let e=await fu(`/api/ntfy/status`);e&&(t.value=e)}async function u(){if(r.value.trim()){a.value=!0,o.value=``;try{(await du(`/api/ntfy/setup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`connect`,serverUrl:n.value.trim(),topic:r.value.trim(),token:i.value.trim()||void 0})}))?.ok&&(r.value=``,i.value=``,n.value=`https://ntfy.sh`,await l())}catch(e){o.value=e instanceof Error?e.message:`connection failed`}finally{a.value=!1}}}async function d(){a.value=!0,o.value=``;try{await du(`/api/ntfy/setup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`disconnect`})}),await l()}catch(e){o.value=e instanceof Error?e.message:`disconnect failed`}finally{a.value=!1}}async function f(){a.value=!0,o.value=``,s.value=``;try{s.value=(await du(`/api/ntfy/setup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`test`})}))?.ok?`ok`:`fail`}catch(e){s.value=`fail`,o.value=e instanceof Error?e.message:`test failed`}finally{a.value=!1}}function p(){let e=[`swift`,`calm`,`bold`,`warm`,`cool`,`keen`,`glad`,`cozy`,`wild`,`soft`],t=[`fox`,`owl`,`bee`,`elk`,`jay`,`ram`,`yak`,`ant`,`emu`,`cod`],n=[...crypto.getRandomValues(new Uint8Array(5))],i=e=>e[n.pop()%e.length],a=n.map(e=>e.toString(36)).join(``).slice(0,4);r.value=`${i(e)}-${i(t)}-${a}`}return gu(l,5e3),(e,l)=>(V(),H(`div`,Vg,[c.value?(V(),H(`div`,Hg,[l[6]||=U(`h3`,{class:`section-title mb-2`},`status`,-1),U(`table`,Ug,[U(`tbody`,null,[U(`tr`,Wg,[l[3]||=U(`td`,{class:`py-1.5 px-2 border-b border-border text-muted`},`server`,-1),U(`td`,Gg,P(t.value?.serverUrl),1)]),U(`tr`,Kg,[l[4]||=U(`td`,{class:`py-1.5 px-2 border-b border-border text-muted`},`topic`,-1),U(`td`,qg,[U(`a`,{href:`${t.value?.serverUrl}/${t.value?.topic}`,target:`_blank`,class:`text-accent hover:underline`},P(t.value?.topic),9,Jg)])]),U(`tr`,Yg,[l[5]||=U(`td`,{class:`py-1.5 px-2 text-muted`},`auth`,-1),U(`td`,Xg,[t.value?.hasToken?(V(),H(`span`,Zg,`token set`)):(V(),H(`span`,Qg,`none`))])])])])])):K(``,!0),c.value?K(``,!0):(V(),H(`div`,$g,[...l[7]||=[U(`h3`,{class:`section-title mb-2`},`setup`,-1),U(`ol`,{class:`text-[12px] text-muted list-decimal list-inside grid gap-1.5`},[U(`li`,null,[G(` install `),U(`a`,{href:`https://ntfy.sh`,target:`_blank`,class:`text-accent hover:underline`},`ntfy`),G(` on your phone or use the web app `)]),U(`li`,null,` pick a unique topic name — treat it like a secret, anyone who knows it can read your notifications `),U(`li`,null,`subscribe to the topic in the ntfy app`),U(`li`,null,`enter the details below and connect`)],-1)]])),c.value?K(``,!0):(V(),H(`div`,e_,[l[11]||=U(`h3`,{class:`section-title mb-2`},`connect`,-1),U(`form`,{onSubmit:ws(u,[`prevent`])},[U(`div`,t_,[l[8]||=U(`label`,{class:`label`},`server url`,-1),Rn(U(`input`,{"onUpdate:modelValue":l[0]||=e=>n.value=e,type:`url`,placeholder:`https://ntfy.sh`,class:`bg-bg border border-border rounded text-text px-2.5 py-1.5 text-[12px] font-mono w-full outline-none transition-colors focus:border-accent`},null,512),[[vs,n.value]])]),U(`div`,n_,[l[9]||=U(`label`,{class:`label`},`topic`,-1),U(`div`,r_,[Rn(U(`input`,{"onUpdate:modelValue":l[1]||=e=>r.value=e,type:`text`,class:`bg-bg border border-border rounded text-text px-2.5 py-1.5 text-[12px] font-mono w-full outline-none transition-colors focus:border-accent`},null,512),[[vs,r.value]]),U(`button`,{type:`button`,class:`btn-sm shrink-0`,title:`generate random topic`,onClick:p},` random `)])]),U(`div`,i_,[l[10]||=U(`label`,{class:`label`},`token (optional)`,-1),Rn(U(`input`,{"onUpdate:modelValue":l[2]||=e=>i.value=e,type:`password`,placeholder:`tk_...`,class:`bg-bg border border-border rounded text-text px-2.5 py-1.5 text-[12px] font-mono w-full outline-none transition-colors focus:border-accent`},null,512),[[vs,i.value]])]),o.value?(V(),H(`div`,a_,P(o.value),1)):K(``,!0),U(`button`,{type:`submit`,disabled:a.value||!r.value.trim(),class:`btn-primary disabled:text-muted disabled:bg-surface disabled:border-border`},P(a.value?`saving...`:`connect`),9,o_)],32)])),c.value?(V(),H(`div`,s_,[l[12]||=U(`h3`,{class:`section-title mb-2`},`actions`,-1),o.value?(V(),H(`div`,c_,P(o.value),1)):K(``,!0),s.value===`ok`?(V(),H(`div`,l_,`test notification sent`)):K(``,!0),U(`div`,u_,[U(`button`,{type:`button`,disabled:a.value,class:`btn-primary`,onClick:f},P(a.value?`sending...`:`send test notification`),9,d_),U(`button`,{type:`button`,disabled:a.value,class:`btn-danger`,onClick:d},` disconnect `,8,f_)])])):K(``,!0)]))}}),window:{width:420,height:500,minwidth:320,minheight:200,autosize:!0}},m_={class:`grid gap-3 p-3`},h_={class:`border border-border p-3`},g_={class:`flex gap-2`},__=[`onClick`],v_={class:`border border-border p-3`},y_={class:`flex items-center gap-2 cursor-pointer text-[12px] text-text`},b_=[`checked`],x_={key:0,class:`ml-5 mt-1.5 grid gap-1.5`},S_={class:`flex gap-2`},C_=[`onClick`],w_={class:`flex items-center gap-2 cursor-pointer text-[12px] text-text`},T_=[`checked`],E_={class:`flex items-center gap-2 cursor-pointer text-[12px] text-text mt-1.5`},D_=[`checked`],O_=z({__name:`DashTab`,setup(e){let{settings:t,set:n}=Xl(),r=[`small`,`medium`,`large`],i=[`12h`,`24h`];return(e,a)=>(V(),H(`div`,m_,[U(`div`,h_,[a[3]||=U(`h3`,{class:`section-title mb-2`},`dock size`,-1),U(`div`,g_,[(V(),H(B,null,Zr(r,e=>U(`button`,{key:e,type:`button`,class:N([`px-3 py-1.5 text-[12px] rounded border transition-colors cursor-pointer`,L(t).dockSize===e?`border-accent text-accent bg-accent-dim`:`border-border text-text hover:border-muted`]),onClick:t=>L(n)({dockSize:e})},P(e),11,__)),64))])]),U(`div`,v_,[a[7]||=U(`h3`,{class:`section-title mb-2`},`dock`,-1),U(`label`,y_,[U(`input`,{type:`checkbox`,checked:L(t).showClock,class:`accent-accent`,onChange:a[0]||=e=>L(n)({showClock:!L(t).showClock,showStatus:!L(t).showClock})},null,40,b_),a[4]||=G(` show clock `,-1)]),L(t).showClock?(V(),H(`div`,x_,[U(`div`,S_,[(V(),H(B,null,Zr(i,e=>U(`button`,{key:e,type:`button`,class:N([`px-2 py-1 text-[11px] rounded border transition-colors cursor-pointer`,L(t).clockFormat===e?`border-accent text-accent bg-accent-dim`:`border-border text-text hover:border-muted`]),onClick:t=>L(n)({clockFormat:e})},P(e),11,C_)),64))]),U(`label`,w_,[U(`input`,{type:`checkbox`,checked:L(t).showStatus,class:`accent-accent`,onChange:a[1]||=e=>L(n)({showStatus:!L(t).showStatus})},null,40,T_),a[5]||=G(` show status indicator `,-1)])])):K(``,!0),U(`label`,E_,[U(`input`,{type:`checkbox`,checked:L(t).showFullscreen,class:`accent-accent`,onChange:a[2]||=e=>L(n)({showFullscreen:!L(t).showFullscreen})},null,40,D_),a[6]||=G(` show fullscreen button `,-1)])])]))}}),k_={class:`grid gap-3 p-3`},A_={class:`border border-border p-3`},j_={class:`flex gap-2`},M_=[`onClick`],N_={class:`border border-border p-3`},P_={class:`flex gap-2`},F_={class:`border border-border p-3`},I_={class:`flex gap-1.5 mb-2`},L_=[`onClick`],R_={key:0,class:`text-[11px] text-muted`},z_={key:1,class:`grid grid-cols-3 gap-1.5`},B_=[`onClick`],V_=[`src`,`alt`],H_={class:`border border-border p-3`},U_={class:`flex gap-2`},W_=z({__name:`DesktopTab`,setup(e){let{settings:t,set:n}=Xl(),r=[`dark`,`light`,`system`],i=q(()=>t.iconLayout),a=q(()=>t.wallpaper),o=F(a.value),s=[`general`,`anime`,`people`],c={general:`100`,anime:`010`,people:`001`},l=F(`general`);function u(e){l.value!==e&&(l.value=e,p())}let d=F([]),f=F(!1);async function p(){f.value=!0;try{d.value=(await(await fetch(`/proxy/wallhaven/search?categories=${c[l.value]}&purity=100&sorting=toplist&order=desc&ratios=16x9&per_page=6`)).json()).data.map(e=>({id:e.id,thumb:e.thumbs.small,full:e.path}))}catch{}finally{f.value=!1}}function m(e){o.value=e,n({wallpaper:e})}function h(){m(o.value.trim())}function g(){m(``)}return Ir(p),(e,c)=>(V(),H(`div`,k_,[U(`div`,A_,[c[3]||=U(`h3`,{class:`section-title mb-2`},`theme`,-1),U(`div`,j_,[(V(),H(B,null,Zr(r,e=>U(`button`,{key:e,type:`button`,class:N([`px-3 py-1.5 text-[12px] rounded border transition-colors cursor-pointer`,L(t).theme===e?`border-accent text-accent bg-accent-dim`:`border-border text-text hover:border-muted`]),onClick:t=>L(n)({theme:e})},P(e),11,M_)),64))])]),U(`div`,N_,[c[4]||=U(`h3`,{class:`section-title mb-2`},`layout`,-1),U(`div`,P_,[U(`button`,{type:`button`,class:N([`px-3 py-1.5 text-[12px] rounded border transition-colors cursor-pointer`,i.value===`list`?`border-accent text-accent bg-accent-dim`:`border-border text-text hover:border-muted`]),onClick:c[0]||=e=>L(n)({iconLayout:`list`})},` list `,2),U(`button`,{type:`button`,class:N([`px-3 py-1.5 text-[12px] rounded border transition-colors cursor-pointer`,i.value===`grid`?`border-accent text-accent bg-accent-dim`:`border-border text-text hover:border-muted`]),onClick:c[1]||=e=>L(n)({iconLayout:`grid`})},` grid `,2)])]),U(`div`,F_,[c[5]||=U(`h3`,{class:`section-title mb-2`},[G(` wallpapers `),U(`a`,{href:`https://wallhaven.cc`,target:`_blank`,class:`text-accent hover:underline normal-case tracking-normal`},`wallhaven.cc`)],-1),U(`div`,I_,[(V(),H(B,null,Zr(s,e=>U(`button`,{key:e,type:`button`,class:N([`px-2 py-1 text-[10px] uppercase tracking-wider rounded border transition-colors cursor-pointer`,l.value===e?`border-accent text-accent bg-accent-dim`:`border-border text-muted hover:border-muted`]),onClick:t=>u(e)},P(e),11,L_)),64))]),f.value?(V(),H(`div`,R_,`loading...`)):(V(),H(`div`,z_,[(V(!0),H(B,null,Zr(d.value,e=>(V(),H(`button`,{key:e.id,type:`button`,class:N([`relative rounded border cursor-pointer overflow-hidden transition-all aspect-video`,a.value===e.full?`border-accent`:`border-border hover:border-muted`]),onClick:t=>m(e.full)},[U(`img`,{src:e.thumb,alt:`wallpaper ${e.id}`,class:`w-full h-full object-cover`,loading:`lazy`},null,8,V_)],10,B_))),128))]))]),U(`div`,H_,[c[7]||=U(`h3`,{class:`section-title mb-2`},`custom url`,-1),U(`form`,{onSubmit:ws(h,[`prevent`])},[Rn(U(`input`,{"onUpdate:modelValue":c[2]||=e=>o.value=e,type:`text`,placeholder:`https://example.com/bg.jpg`,class:`bg-bg border border-border rounded text-text px-2.5 py-1.5 text-[12px] font-mono w-full outline-none transition-colors focus:border-accent mb-2`},null,512),[[vs,o.value]]),U(`div`,U_,[c[6]||=U(`button`,{type:`submit`,class:`btn-primary`},`apply`,-1),a.value?(V(),H(`button`,{key:0,type:`button`,class:`btn-danger`,onClick:g},`clear`)):K(``,!0)])],32)])]))}}),G_={class:`flex flex-col h-full`},K_={class:`px-3 pt-3 border-b border-border flex items-center gap-2`},q_={key:`settings`,label:`Settings`,icon:`pixelarticons:sliders`,color:`#c5cdd8`,component:z({__name:`window`,setup(e){let t=[`desktop`,`dash`],{state:n,set:r}=$l(),i=F(t.includes(n.value.tab)?n.value.tab:`desktop`);return R(i,e=>r({tab:e})),(e,t)=>(V(),H(`div`,G_,[U(`div`,K_,[U(`button`,{type:`button`,class:N(i.value===`desktop`?`tab-active`:`tab-inactive`),onClick:t[0]||=e=>i.value=`desktop`},` desktop `,2),U(`button`,{type:`button`,class:N(i.value===`dash`?`tab-active`:`tab-inactive`),onClick:t[1]||=e=>i.value=`dash`},` dash `,2)]),i.value===`desktop`?(V(),wa(W_,{key:0})):i.value===`dash`?(V(),wa(O_,{key:1})):K(``,!0)]))}}),window:{width:720,height:560,minwidth:400,minheight:300}},J_={class:`flex flex-col h-full`},Y_={class:`px-3 pt-3 border-b border-border flex items-center gap-2`},X_={key:0,class:`grid gap-3 p-3 overflow-y-auto`},Z_={class:`border border-border p-3`},Q_={class:`w-full border-collapse text-[12px]`},$_={class:`hover:bg-surface`},ev={class:`py-1.5 px-2 border-b border-border`},tv={class:`hover:bg-surface`},nv={class:`py-1.5 px-2 border-b border-border`},rv={class:`hover:bg-surface`},iv={class:`py-1.5 px-2 border-b border-border`},av={key:0,class:`hover:bg-surface`},ov={class:`py-1.5 px-2`},sv={class:`border border-border p-3`},cv={class:`w-full border-collapse text-[12px]`},lv={class:`hover:bg-surface`},uv={class:`py-1.5 px-2 border-b border-border`},dv={key:0,class:`hover:bg-surface`},fv={class:`py-1.5 px-2`},pv={key:1,class:`grid gap-3 p-3 overflow-y-auto`},mv={class:`border border-border p-3`},hv={class:`w-full border-collapse text-[12px]`},gv={class:`hover:bg-surface`},_v={class:`py-1.5 px-2 border-b border-border`},vv={class:`hover:bg-surface`},yv={class:`py-1.5 px-2 border-b border-border`},bv={class:`hover:bg-surface`},xv={class:`py-1.5 px-2 border-b border-border`},Sv={class:`hover:bg-surface`},Cv={class:`py-1.5 px-2 border-b border-border`},wv={class:`hover:bg-surface`},Tv={class:`py-1.5 px-2`},Ev={class:`border border-border p-3`},Dv={class:`w-full border-collapse text-[12px]`},Ov={class:`hover:bg-surface`},kv={class:`py-1.5 px-2 border-b border-border`},Av={class:`hover:bg-surface`},jv={class:`py-1.5 px-2 border-b border-border`},Mv={class:`hover:bg-surface`},Nv={class:`py-1.5 px-2`},Pv={key:`overview`,label:`System`,icon:`pixelarticons:monitor`,color:`#3fb950`,component:z({__name:`window`,setup(e){let t=[`host`,`server`],{state:n,set:r}=$l(),i=F(t.includes(n.value.tab)?n.value.tab:`host`);R(i,e=>r({tab:e}));let a=F(null);async function o(){let e=await fu(`/api/status`);e&&(a.value=e)}gu(o,5e3);function s(e){return e<1024?`${e} B`:e<1024**2?`${(e/1024).toFixed(1)} KB`:e<1024**3?`${(e/1024**2).toFixed(1)} MB`:`${(e/1024**3).toFixed(1)} GB`}let c=q(()=>{let e=a.value?.systemInfo;return!e?.totalMemory||e.freeMemory==null?null:`${s(e.totalMemory-e.freeMemory)} / ${s(e.totalMemory)}`}),l=q(()=>{let e=a.value?.systemInfo;if(!e?.os)return null;let t=e.linuxDistro||e.os;return e.arch&&(t+=` (${e.arch})`),e.isDocker&&(t+=` [docker]`),t}),u=q(()=>a.value?.systemInfo?.availableCommands?.length??null),d=q(()=>{let e=a.value?.systemInfo?.processMemory;return e==null?null:s(e)});return(e,t)=>(V(),H(`div`,J_,[U(`div`,Y_,[U(`button`,{type:`button`,class:N(i.value===`host`?`tab-active`:`tab-inactive`),onClick:t[0]||=e=>i.value=`host`},` host `,2),U(`button`,{type:`button`,class:N(i.value===`server`?`tab-active`:`tab-inactive`),onClick:t[1]||=e=>i.value=`server`},` server `,2)]),i.value===`host`?(V(),H(`div`,X_,[U(`div`,Z_,[t[6]||=U(`h3`,{class:`section-title mb-2`},`platform`,-1),U(`table`,Q_,[U(`tbody`,null,[U(`tr`,$_,[t[2]||=U(`td`,{class:`py-1.5 px-2 border-b border-border text-muted`},`os`,-1),U(`td`,ev,P(l.value??`-`),1)]),U(`tr`,tv,[t[3]||=U(`td`,{class:`py-1.5 px-2 border-b border-border text-muted`},`runtime`,-1),U(`td`,nv,P(a.value?.systemInfo?.runtime??`-`),1)]),U(`tr`,rv,[t[4]||=U(`td`,{class:`py-1.5 px-2 border-b border-border text-muted`},`os uptime`,-1),U(`td`,iv,P(a.value?.systemInfo?.uptime==null?`-`:L(wm)(a.value.systemInfo.uptime*1e3)),1)]),u.value==null?K(``,!0):(V(),H(`tr`,av,[t[5]||=U(`td`,{class:`py-1.5 px-2 text-muted`},`commands`,-1),U(`td`,ov,P(u.value),1)]))])])]),U(`div`,sv,[t[9]||=U(`h3`,{class:`section-title mb-2`},`resources`,-1),U(`table`,cv,[U(`tbody`,null,[U(`tr`,lv,[t[7]||=U(`td`,{class:`py-1.5 px-2 border-b border-border text-muted`},`memory`,-1),U(`td`,uv,P(c.value??`-`),1)]),a.value?.systemInfo?.availableDiskSpace==null?K(``,!0):(V(),H(`tr`,dv,[t[8]||=U(`td`,{class:`py-1.5 px-2 text-muted`},`disk free`,-1),U(`td`,fv,P(s(a.value.systemInfo.availableDiskSpace)),1)]))])])])])):i.value===`server`?(V(),H(`div`,pv,[U(`div`,mv,[t[15]||=U(`h3`,{class:`section-title mb-2`},`system`,-1),U(`table`,hv,[U(`tbody`,null,[U(`tr`,gv,[t[10]||=U(`td`,{class:`py-1.5 px-2 border-b border-border text-muted`},`uptime`,-1),U(`td`,_v,P(a.value?L(wm)(a.value.uptimeMs):`-`),1)]),U(`tr`,vv,[t[11]||=U(`td`,{class:`py-1.5 px-2 border-b border-border text-muted`},`agents`,-1),U(`td`,yv,P(a.value?.activeAgents??`-`),1)]),U(`tr`,bv,[t[12]||=U(`td`,{class:`py-1.5 px-2 border-b border-border text-muted`},`queue`,-1),U(`td`,xv,P(a.value?.queueSize??`-`),1)]),U(`tr`,Sv,[t[13]||=U(`td`,{class:`py-1.5 px-2 border-b border-border text-muted`},`assistant`,-1),U(`td`,Cv,P(a.value?.assistantName??`-`),1)]),U(`tr`,wv,[t[14]||=U(`td`,{class:`py-1.5 px-2 text-muted`},`memory`,-1),U(`td`,Tv,P(d.value??`-`),1)])])])]),U(`div`,Ev,[t[19]||=U(`h3`,{class:`section-title mb-2`},`overview`,-1),U(`table`,Dv,[U(`tbody`,null,[U(`tr`,Ov,[t[16]||=U(`td`,{class:`py-1.5 px-2 border-b border-border text-muted`},`groups`,-1),U(`td`,kv,P(a.value?.groupCount??`-`),1)]),U(`tr`,Av,[t[17]||=U(`td`,{class:`py-1.5 px-2 border-b border-border text-muted`},`chats`,-1),U(`td`,jv,P(a.value?.chatCount??`-`),1)]),U(`tr`,Mv,[t[18]||=U(`td`,{class:`py-1.5 px-2 text-muted`},`tasks`,-1),U(`td`,Nv,P(a.value?.activeTaskCount??`-`),1)])])])])])):K(``,!0)]))}}),window:{width:460,height:500,minwidth:320,minheight:260}},Fv={class:`p-3`},Iv={class:`flex gap-2 items-center mb-2`},Lv={class:`grid grid-cols-2 gap-3 max-md:grid-cols-1`},Rv={class:`mb-2`},zv={class:`mb-2`},Bv={class:`mb-2`},Vv={class:`mb-2`},Hv={class:`mb-2`},Uv={class:`w-full border-collapse text-[12px]`},Wv={key:0},Gv=[`title`],Kv={class:`py-1.5 px-2 border-b border-border text-muted`},qv={class:`py-1.5 px-2 border-b border-border text-muted`},Jv={class:`py-1.5 px-2 border-b border-border`},Yv={class:`py-1.5 px-2 border-b border-border text-muted`},Xv=[`title`],Zv={class:`py-1.5 px-2 border-b border-border`},Qv=[`onClick`],$v=[`onClick`],ey={key:`tasks`,label:`Tasks`,icon:`pixelarticons:checklist`,color:`#d29922`,component:z({__name:`window`,setup(e){let{alert:t}=ou(),n=F([]),r=F(!1),i=F(``),a=F(`cron`),o=F(``),s=F(`group`),c=F(``);async function l(){n.value=await fu(`/api/tasks`)??[]}function u(){r.value=!1,i.value=``,a.value=`cron`,o.value=``,s.value=`group`,c.value=``}async function d(){if(!i.value.trim()||!o.value.trim()||!c.value.trim()){await t(`jid, schedule, and prompt are required`);return}await du(`/api/tasks`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({chatJid:i.value.trim(),scheduleType:a.value,scheduleValue:o.value.trim(),contextMode:s.value,prompt:c.value.trim()})}),u(),await l()}async function f(e,t){await du(`/api/tasks/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({status:t})}),await l()}return gu(l,5e3),(e,t)=>(V(),H(`div`,Fv,[U(`div`,Iv,[t[6]||=U(`h3`,{class:`section-title`},`tasks`,-1),U(`button`,{type:`button`,class:`ml-auto btn-primary`,onClick:t[0]||=e=>r.value=!0},`+ new task`)]),r.value?(V(),wa(Cl,{key:0,title:`new task`,width:`520px`,onClose:u},{default:Ln(()=>[U(`form`,{onSubmit:ws(d,[`prevent`]),onKeydown:Es(u,[`escape`])},[U(`div`,Lv,[U(`div`,Rv,[t[7]||=U(`label`,{class:`label`},`chat jid`,-1),Rn(U(`input`,{"onUpdate:modelValue":t[1]||=e=>i.value=e,placeholder:`xxxx@g.us`,class:`bg-bg border border-border rounded text-text px-2.5 py-1.5 text-[12px] font-mono w-full outline-none transition-colors focus:border-accent`},null,512),[[vs,i.value]])]),U(`div`,zv,[t[9]||=U(`label`,{class:`label`},`schedule type`,-1),Rn(U(`select`,{"onUpdate:modelValue":t[2]||=e=>a.value=e,class:`bg-bg border border-border rounded text-text px-2.5 py-1.5 text-[12px] font-mono w-full outline-none transition-colors focus:border-accent`},[...t[8]||=[U(`option`,{value:`cron`},`cron`,-1),U(`option`,{value:`interval`},`interval`,-1),U(`option`,{value:`once`},`once`,-1)]],512),[[ys,a.value]])]),U(`div`,Bv,[t[10]||=U(`label`,{class:`label`},`schedule value`,-1),Rn(U(`input`,{"onUpdate:modelValue":t[3]||=e=>o.value=e,placeholder:`*/5 * * * * or 300000`,class:`bg-bg border border-border rounded text-text px-2.5 py-1.5 text-[12px] font-mono w-full outline-none transition-colors focus:border-accent`},null,512),[[vs,o.value]])]),U(`div`,Vv,[t[12]||=U(`label`,{class:`label`},`context`,-1),Rn(U(`select`,{"onUpdate:modelValue":t[4]||=e=>s.value=e,class:`bg-bg border border-border rounded text-text px-2.5 py-1.5 text-[12px] font-mono w-full outline-none transition-colors focus:border-accent`},[...t[11]||=[U(`option`,{value:`group`},`group (shared)`,-1),U(`option`,{value:`isolated`},`isolated`,-1)]],512),[[ys,s.value]])])]),U(`div`,Hv,[t[13]||=U(`label`,{class:`label`},`prompt`,-1),Rn(U(`textarea`,{"onUpdate:modelValue":t[5]||=e=>c.value=e,placeholder:`what should the agent do?`,class:`bg-bg border border-border rounded text-text px-2.5 py-1.5 text-[12px] font-mono w-full outline-none transition-colors focus:border-accent resize-y min-h-[60px]`},null,512),[[vs,c.value]])]),U(`div`,{class:`flex gap-2 items-center`},[t[15]||=U(`button`,{type:`submit`,class:`btn-primary`},[G(` create `),U(`span`,{class:`text-[9px] opacity-60 hidden sm:inline`},`↵`)],-1),U(`button`,{type:`button`,class:`btn-ghost`,onClick:u},[...t[14]||=[G(` cancel `,-1),U(`span`,{class:`text-[9px] opacity-60 hidden sm:inline`},`esc`,-1)]])])],32)]),_:1})):K(``,!0),U(`table`,Uv,[t[17]||=U(`thead`,null,[U(`tr`,null,[U(`th`,{class:`text-left text-muted font-medium py-1.5 px-2 border-b border-border text-[10px] uppercase tracking-wide`},` prompt `),U(`th`,{class:`text-left text-muted font-medium py-1.5 px-2 border-b border-border text-[10px] uppercase tracking-wide`},` type `),U(`th`,{class:`text-left text-muted font-medium py-1.5 px-2 border-b border-border text-[10px] uppercase tracking-wide`},` value `),U(`th`,{class:`text-left text-muted font-medium py-1.5 px-2 border-b border-border text-[10px] uppercase tracking-wide`},` status `),U(`th`,{class:`text-left text-muted font-medium py-1.5 px-2 border-b border-border text-[10px] uppercase tracking-wide`},` next run `),U(`th`,{class:`text-left text-muted font-medium py-1.5 px-2 border-b border-border text-[10px] uppercase tracking-wide`},` last result `),U(`th`,{class:`text-left text-muted font-medium py-1.5 px-2 border-b border-border text-[10px] uppercase tracking-wide`})])],-1),U(`tbody`,null,[n.value.length===0?(V(),H(`tr`,Wv,[...t[16]||=[U(`td`,{colspan:`7`,class:`text-center py-8 text-muted text-[12px]`},`no scheduled tasks`,-1)]])):K(``,!0),(V(!0),H(B,null,Zr(n.value,e=>(V(),H(`tr`,{key:e.id,class:`hover:bg-surface`},[U(`td`,{class:`py-1.5 px-2 border-b border-border max-w-[250px] overflow-hidden text-ellipsis whitespace-nowrap`,title:e.prompt},P(e.prompt.slice(0,60)),9,Gv),U(`td`,Kv,P(e.schedule_type),1),U(`td`,qv,P(e.schedule_value),1),U(`td`,Jv,[U(`span`,{class:N(L(Em)(e.status))},P(e.status),3)]),U(`td`,Yv,P(L(Cm)(e.next_run)),1),U(`td`,{class:`py-1.5 px-2 border-b border-border max-w-[200px] overflow-hidden text-ellipsis whitespace-nowrap text-muted`,title:e.last_result||``},P(e.last_result||`-`),9,Xv),U(`td`,Zv,[e.status===`active`?(V(),H(`button`,{key:0,type:`button`,class:`btn-sm bg-warn-dim text-warn border-warn-dim hover:bg-warn-dim`,onClick:t=>f(e.id,`paused`)},` pause `,8,Qv)):e.status===`paused`?(V(),H(`button`,{key:1,type:`button`,class:`btn-sm bg-ok-dim text-ok border-ok-dim hover:bg-ok-dim`,onClick:t=>f(e.id,`active`)},` resume `,8,$v)):K(``,!0)])]))),128))])])]))}}),window:{width:900,height:420,minwidth:420,minheight:240}},ty={class:`grid gap-3 p-3`},ny={key:0,class:`border border-border p-3`},ry={class:`w-full border-collapse text-[12px]`},iy={key:0,class:`hover:bg-surface`},ay={class:`py-1.5 px-2 border-b border-border font-mono`},oy=[`href`],sy={class:`hover:bg-surface`},cy={class:`py-1.5 px-2`},ly={key:0,class:`text-muted`},uy={key:1,class:`text-muted`},dy={key:1,class:`border border-border p-3`},fy={key:2,class:`border border-border p-3`},py={key:0,class:`text-[11px] text-danger mb-2`},my=[`disabled`],hy={key:3,class:`border border-border p-3`},gy={class:`mb-2`},_y={key:0,class:`text-[11px] text-danger mb-2`},vy=[`disabled`],yy={key:4,class:`border border-border p-3`},by=[`disabled`],xy={key:`telegram`,label:`Telegram`,icon:`simple-icons:telegram`,color:`#2AABEE`,component:z({__name:`window`,setup(e){let t=F(null),n=F(``),r=F(!1),i=F(``),a=q(()=>t.value?.connected??!1);async function o(){let e=await fu(`/api/telegram/status`);e&&(t.value=e)}async function s(){if(n.value.trim()){r.value=!0,i.value=``;try{(await du(`/api/telegram/setup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`connect`,botToken:n.value.trim()})}))?.ok&&(n.value=``,await o())}catch(e){i.value=e instanceof Error?e.message:`connection failed`}finally{r.value=!1}}}async function c(){r.value=!0,i.value=``;try{await du(`/api/telegram/setup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`disconnect`})}),await o()}catch(e){i.value=e instanceof Error?e.message:`disconnect failed`}finally{r.value=!1}}let l=q(()=>!a.value&&(t.value?.configured||t.value?.hasEnvToken));async function u(){r.value=!0,i.value=``;try{await du(`/api/telegram/setup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`reconnect`})}),await o()}catch(e){i.value=e instanceof Error?e.message:`reconnect failed`}finally{r.value=!1}}return gu(o,5e3),(e,o)=>(V(),H(`div`,ty,[a.value?(V(),H(`div`,ny,[o[4]||=U(`h3`,{class:`section-title mb-2`},`status`,-1),U(`table`,ry,[U(`tbody`,null,[o[3]||=U(`tr`,{class:`hover:bg-surface`},[U(`td`,{class:`py-1.5 px-2 border-b border-border text-muted`},`connection`),U(`td`,{class:`py-1.5 px-2 border-b border-border`},[U(`span`,{class:`badge-ok`},`connected`)])],-1),t.value?.botUsername?(V(),H(`tr`,iy,[o[1]||=U(`td`,{class:`py-1.5 px-2 border-b border-border text-muted`},`bot`,-1),U(`td`,ay,[U(`a`,{href:`https://t.me/${t.value.botUsername}?start=help`,target:`_blank`,class:`text-accent hover:underline`},`@`+P(t.value.botUsername),9,oy)])])):K(``,!0),U(`tr`,sy,[o[2]||=U(`td`,{class:`py-1.5 px-2 text-muted`},`source`,-1),U(`td`,cy,[t.value?.hasEnvToken?(V(),H(`span`,ly,`env`)):t.value?.configured?(V(),H(`span`,uy,`saved`)):K(``,!0)])])])])])):K(``,!0),!a.value&&!l.value?(V(),H(`div`,dy,[...o[5]||=[U(`h3`,{class:`section-title mb-2`},`setup`,-1),U(`ol`,{class:`text-[12px] text-muted list-decimal list-inside grid gap-1.5`},[U(`li`,null,[G(` Open `),U(`a`,{href:`https://t.me/BotFather`,target:`_blank`,class:`text-accent hover:underline`},`@BotFather`),G(` on Telegram `)]),U(`li`,null,[G(`Send `),U(`span`,{class:`font-mono text-text`},`/newbot`),G(` and follow the prompts`)]),U(`li`,null,`Copy the bot token and paste it below`)],-1)]])):K(``,!0),l.value?(V(),H(`div`,fy,[o[6]||=U(`h3`,{class:`section-title mb-2`},`reconnect`,-1),o[7]||=U(`p`,{class:`text-[11px] text-muted mb-2`},[G(` Bot is configured but not connected. If you see 409 errors, another instance may be polling the same token or a webhook is set. Use `),U(`span`,{class:`font-mono text-text`},`deleteWebhook`),G(` via Bot API to clear it. `)],-1),i.value?(V(),H(`div`,py,P(i.value),1)):K(``,!0),U(`button`,{type:`button`,disabled:r.value,class:`btn-primary disabled:text-muted disabled:bg-surface disabled:border-border`,onClick:u},P(r.value?`reconnecting...`:`reconnect`),9,my)])):K(``,!0),!a.value&&!l.value?(V(),H(`div`,hy,[o[9]||=U(`h3`,{class:`section-title mb-2`},`connect`,-1),U(`form`,{onSubmit:ws(s,[`prevent`])},[U(`div`,gy,[o[8]||=U(`label`,{class:`label`},`bot token`,-1),Rn(U(`input`,{"onUpdate:modelValue":o[0]||=e=>n.value=e,type:`password`,placeholder:`123456:ABC-DEF...`,class:`bg-bg border border-border rounded text-text px-2.5 py-1.5 text-[12px] font-mono w-full outline-none transition-colors focus:border-accent`},null,512),[[vs,n.value]])]),i.value?(V(),H(`div`,_y,P(i.value),1)):K(``,!0),U(`button`,{type:`submit`,disabled:r.value||!n.value.trim(),class:`btn-primary disabled:text-muted disabled:bg-surface disabled:border-border`},P(r.value?`connecting...`:`connect`),9,vy)],32)])):K(``,!0),a.value||l.value?(V(),H(`div`,yy,[o[10]||=U(`h3`,{class:`section-title mb-2`},`actions`,-1),U(`button`,{type:`button`,disabled:r.value,class:`btn-danger`,onClick:c},` disconnect `,8,by)])):K(``,!0)]))}}),window:{width:420,height:420,minwidth:320,minheight:200,autosize:!0}},Sy=Object.defineProperty,Cy=Object.getOwnPropertyDescriptor,wy=(e,t)=>{for(var n in t)Sy(e,n,{get:t[n],enumerable:!0})},Ty=(e,t,n,r)=>{for(var i=r>1?void 0:r?Cy(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Sy(t,n,i),i},J=(e,t)=>(n,r)=>t(n,r,e),Ey=`Terminal input`,Dy={get:()=>Ey,set:e=>Ey=e},Oy=`Too much output to announce, navigate to rows manually to read`,ky={get:()=>Oy,set:e=>Oy=e};function Ay(e){return e.replace(/\r?\n/g,`\r`)}function jy(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function My(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function Ny(e,t,n,r){e.stopPropagation(),e.clipboardData&&Py(e.clipboardData.getData(`text/plain`),t,n,r)}function Py(e,t,n,r){e=Ay(e),e=jy(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function Fy(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function Iy(e,t,n,r,i){Fy(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Ly(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Ry(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var zy=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},By=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},Vy=``,Hy=` `,Uy=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Wy}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Wy=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Gy=class e extends Uy{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Wy,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Ly(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Ky=`di$target`,qy=`di$dependencies`,Jy=new Map;function Yy(e){return e[qy]||[]}function Xy(e){if(Jy.has(e))return Jy.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Zy(t,e,r)};return t._id=e,Jy.set(e,t),t}function Zy(e,t,n){t[Ky]===t?t[qy].push({id:e,index:n}):(t[qy]=[{id:e,index:n}],t[Ky]=t)}var Qy=Xy(`BufferService`),$y=Xy(`CoreMouseService`),eb=Xy(`CoreService`),tb=Xy(`CharsetService`),nb=Xy(`InstantiationService`),rb=Xy(`LogService`),ib=Xy(`OptionsService`),ab=Xy(`OscLinkService`),ob=Xy(`UnicodeService`),sb=Xy(`DecorationService`),cb=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new Gy,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+(!l&&t===o-1?1:0),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):lb(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};cb=Ty([J(0,Qy),J(1,ib),J(2,ab)],cb);function lb(e,t){if(confirm(`Do you want to navigate to ${t}?
3
+
4
+ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var ub=Xy(`CharSizeService`),db=Xy(`CoreBrowserService`),fb=Xy(`MouseService`),pb=Xy(`RenderService`),mb=Xy(`SelectionService`),hb=Xy(`CharacterJoinerService`),gb=Xy(`ThemeService`),_b=Xy(`LinkProviderService`),vb=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?wb.isErrorNoTelemetry(e)?new wb(e.message+`
5
+
6
+ `+e.stack):Error(e.message+`
7
+
8
+ `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function yb(e){xb(e)||vb.onUnexpectedError(e)}var bb=`Canceled`;function xb(e){return e instanceof Sb?!0:e instanceof Error&&e.name===bb&&e.message===bb}var Sb=class extends Error{constructor(){super(bb),this.name=this.message}};function Cb(e){return e?Error(`Illegal argument: ${e}`):Error(`Illegal argument`)}var wb=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}},Tb=class e extends Error{constructor(t){super(t||`An unexpected bug occurred.`),Object.setPrototypeOf(this,e.prototype)}};function Eb(e,t,n=0,r=e.length){let i=n,a=r;for(;i<a;){let n=Math.floor((i+a)/2);t(e[n])?i=n+1:a=n}return i-1}var Db=class e{constructor(e){this._array=e,this._findLastMonotonousLastIdx=0}findLastMonotonous(t){if(e.assertInvariants){if(this._prevFindLastPredicate){for(let e of this._array)if(this._prevFindLastPredicate(e)&&!t(e))throw Error(`MonotonousArray: current predicate must be weaker than (or equal to) the previous predicate.`)}this._prevFindLastPredicate=t}let n=Eb(this._array,t,this._findLastMonotonousLastIdx);return this._findLastMonotonousLastIdx=n+1,n===-1?void 0:this._array[n]}};Db.assertInvariants=!1;function Ob(e,t=0){return e[e.length-(1+t)]}var kb;(e=>{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(kb||={});function Ab(e,t){return(n,r)=>t(e(n),e(r))}var jb=(e,t)=>e-t,Mb=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>t(n)?e(n):!0))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>e(n)?(t=n,!1):!0),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||kb.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};Mb.empty=new Mb(e=>{});function Nb(e,t){let n=Object.create(null);for(let r of e){let e=t(r),i=n[e];i||=n[e]=[],i.push(r)}return n}var Pb=class{constructor(){this.map=new Map}add(e,t){let n=this.map.get(e);n||(n=new Set,this.map.set(e,n)),n.add(t)}delete(e,t){let n=this.map.get(e);n&&(n.delete(t),n.size===0&&this.map.delete(e))}forEach(e,t){let n=this.map.get(e);n&&n.forEach(t)}get(e){return this.map.get(e)||new Set}};function Fb(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var Ib;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);t<n;t++)yield e[t]}e.slice=_;function v(t,n=1/0){let r=[];if(n===0)return[r,t];let i=t[Symbol.iterator]();for(let t=0;t<n;t++){let t=i.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator](){return i}}]}e.consume=v;async function y(e){let t=[];for await(let n of e)t.push(n);return Promise.resolve(t)}e.asyncToArray=y})(Ib||={});var Lb=!1,Rb=null,zb=class e{constructor(){this.livingDisposables=new Map}getDisposableData(t){let n=this.livingDisposables.get(t);return n||(n={parent:null,source:null,isSingleton:!1,value:t,idx:e.idx++},this.livingDisposables.set(t,n)),n}trackDisposable(e){let t=this.getDisposableData(e);t.source||=Error().stack}setParent(e,t){let n=this.getDisposableData(e);n.parent=t}markAsDisposed(e){this.livingDisposables.delete(e)}markAsSingleton(e){this.getDisposableData(e).isSingleton=!0}getRootParent(e,t){let n=t.get(e);if(n)return n;let r=e.parent?this.getRootParent(this.getDisposableData(e.parent),t):e;return t.set(e,r),r}getTrackedDisposables(){let e=new Map;return[...this.livingDisposables.entries()].filter(([,t])=>t.source!==null&&!this.getRootParent(t,e).isSingleton).flatMap(([e])=>e)}computeLeakingDisposables(e=10,t){let n;if(t)n=t;else{let e=new Map,t=[...this.livingDisposables.values()].filter(t=>t.source!==null&&!this.getRootParent(t,e).isSingleton);if(t.length===0)return;let r=new Set(t.map(e=>e.value));if(n=t.filter(e=>!(e.parent&&r.has(e.parent))),n.length===0)throw Error(`There are cyclic diposable chains!`)}if(!n)return;function r(e){function t(e,t){for(;e.length>0&&t.some(t=>typeof t==`string`?t===e[0]:e[0].match(t));)e.shift()}let n=e.source.split(`
9
+ `).map(e=>e.trim().replace(`at `,``)).filter(e=>e!==``);return t(n,[`Error`,/^trackDisposable \(.*\)$/,/^DisposableTracker.trackDisposable \(.*\)$/]),n.reverse()}let i=new Pb;for(let e of n){let t=r(e);for(let n=0;n<=t.length;n++)i.add(t.slice(0,n).join(`
10
+ `),e)}n.sort(Ab(e=>e.idx,jb));let a=``,o=0;for(let t of n.slice(0,e)){o++;let e=r(t),s=[];for(let t=0;t<e.length;t++){let a=e[t];a=`(shared with ${i.get(e.slice(0,t+1).join(`
11
+ `)).size}/${n.length} leaks) at ${a}`;let o=Nb([...i.get(e.slice(0,t).join(`
12
+ `))].map(e=>r(e)[t]),e=>e);delete o[e[t]];for(let[e,t]of Object.entries(o))s.unshift(` - stacktraces of ${t.length} other leaks continue with ${e}`);s.unshift(a)}a+=`
13
+
14
+
15
+ ==================== Leaking disposable ${o}/${n.length}: ${t.value.constructor.name} ====================
16
+ ${s.join(`
17
+ `)}
18
+ ============================================================
19
+
20
+ `}return n.length>e&&(a+=`
21
+
22
+
23
+ ... and ${n.length-e} more leaking disposables
24
+
25
+ `),{leaks:n,details:a}}};zb.idx=0;function Bb(e){Rb=e}if(Lb){let e=`__is_disposable_tracked__`;Bb(new class{trackDisposable(t){let n=Error(`Potentially leaked disposable`).stack;setTimeout(()=>{t[e]||console.log(n)},3e3)}setParent(t,n){if(t&&t!==Y.None)try{t[e]=!0}catch{}}markAsDisposed(t){if(t&&t!==Y.None)try{t[e]=!0}catch{}}markAsSingleton(e){}})}function Vb(e){return Rb?.trackDisposable(e),e}function Hb(e){Rb?.markAsDisposed(e)}function Ub(e,t){Rb?.setParent(e,t)}function Wb(e,t){if(Rb)for(let n of e)Rb.setParent(n,t)}function Gb(e){return Rb?.markAsSingleton(e),e}function Kb(e){if(Ib.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function qb(...e){let t=Jb(()=>Kb(e));return Wb(e,t),t}function Jb(e){let t=Vb({dispose:Fb(()=>{Hb(t),e()})});return t}var Yb=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,Vb(this)}dispose(){this._isDisposed||(Hb(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Kb(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return Ub(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),Ub(e,null))}};Yb.DISABLE_DISPOSED_WARNING=!1;var Xb=Yb,Y=class{constructor(){this._store=new Xb,Vb(this),Ub(this._store,this)}dispose(){Hb(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};Y.None=Object.freeze({dispose(){}});var Zb=class{constructor(){this._isDisposed=!1,Vb(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&Ub(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,Hb(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&Ub(e,null),e}},Qb=typeof window==`object`?window:globalThis,$b=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};$b.Undefined=new $b(void 0);var ex=$b,tx=class{constructor(){this._first=ex.Undefined,this._last=ex.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ex.Undefined}clear(){let e=this._first;for(;e!==ex.Undefined;){let t=e.next;e.prev=ex.Undefined,e.next=ex.Undefined,e=t}this._first=ex.Undefined,this._last=ex.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new ex(e);if(this._first===ex.Undefined)this._first=n,this._last=n;else if(t){let e=this._last;this._last=n,n.prev=e,e.next=n}else{let e=this._first;this._first=n,n.next=e,e.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==ex.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ex.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ex.Undefined&&e.next!==ex.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ex.Undefined&&e.next===ex.Undefined?(this._first=ex.Undefined,this._last=ex.Undefined):e.next===ex.Undefined?(this._last=this._last.prev,this._last.next=ex.Undefined):e.prev===ex.Undefined&&(this._first=this._first.next,this._first.prev=ex.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==ex.Undefined;)yield e.element,e=e.next}},nx=globalThis.performance&&typeof globalThis.performance.now==`function`,rx=class e{static create(t){return new e(t)}constructor(e){this._now=nx&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime===-1?this._now()-this._startTime:this._stopTime-this._startTime}},ix=!1,ax=!1,ox=!1,sx;(e=>{e.None=()=>Y.None;function t(e){if(ox){let{onDidAddListener:t}=e,n=px.create(),r=0;e.onDidAddListener=()=>{++r===2&&(console.warn(`snapshotted emitter LIKELY used public and SHOULD HAVE BEEN created with DisposableStore. snapshotted here`),n.print()),t?.()}}}function n(e,t){return f(e,()=>{},0,void 0,!0,void 0,t)}e.defer=n;function r(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=r;function i(e,t,n){return u((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=i;function a(e,t,n){return u((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=a;function o(e,t,n){return u((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=o;function s(e){return e}e.signal=s;function c(...e){return(t,n=null,r)=>d(qb(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=c;function l(e,t,n,r){let a=n;return i(e,e=>(a=t(a,e),a),r)}e.reduce=l;function u(e,n){let r,i={onWillAddFirstListener(){r=e(a.fire,a)},onDidRemoveLastListener(){r?.dispose()}};n||t(i);let a=new X(i);return n?.add(a),a.event}function d(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function f(e,n,r=100,i=!1,a=!1,o,s){let c,l,u,d=0,f,p={leakWarningThreshold:o,onWillAddFirstListener(){c=e(e=>{d++,l=n(l,e),i&&!u&&(m.fire(l),l=void 0),f=()=>{let e=l;l=void 0,u=void 0,(!i||d>1)&&m.fire(e),d=0},typeof r==`number`?(clearTimeout(u),u=setTimeout(f,r)):u===void 0&&(u=0,queueMicrotask(f))})},onWillRemoveListener(){a&&d>0&&f?.()},onDidRemoveLastListener(){f=void 0,c.dispose()}};s||t(p);let m=new X(p);return s?.add(m),m.event}e.debounce=f;function p(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=p;function m(e,t=(e,t)=>e===t,n){let r=!0,i;return o(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=m;function h(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=h;function g(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new X({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=g;function _(e,t){return(n,r,i)=>{let a=t(new y);return e(function(e){let t=a.evaluate(e);t!==v&&n.call(r,t)},void 0,i)}}e.chain=_;let v=Symbol(`HaltChainable`);class y{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:v),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:v}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===v)break;return e}}function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new X({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=b;function x(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new X({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=x;function S(e){return new Promise(t=>r(e)(t))}e.toPromise=S;function C(e){let t=new X;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=C;function w(e,t){return e(e=>t.fire(e))}e.forward=w;function T(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=T;class ee{constructor(e,n){this._observable=e,this._counter=0,this._hasChanged=!1;let r={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};n||t(r),this.emitter=new X(r),n&&n.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function E(e,t){return new ee(e,t).emitter.event}e.fromObservable=E;function D(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof Xb?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=D})(sx||={});var cx=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new rx,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};cx.all=new Set,cx._idPool=0;var lx=cx,ux=-1,dx=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t<n)return;this._stacks||=new Map;let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),--this._warnCountdown,this._warnCountdown<=0){this._warnCountdown=n*.5;let[e,r]=this.getMostFrequentStack(),i=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(i),console.warn(e);let a=new mx(i,e);this._errorHandler(a)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t<r)&&(e=[n,r],t=r);return e}};dx._idPool=1;var fx=dx,px=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??``)}print(){console.warn(this.value.split(`
26
+ `).slice(2).join(`
27
+ `))}},mx=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},hx=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},gx=0,_x=class{constructor(e){this.value=e,this.id=gx++}},vx=2,yx=(e,t)=>{if(e instanceof _x)t(e);else for(let n=0;n<e.length;n++){let r=e[n];r&&t(r)}},bx;if(ix){let e=[];setInterval(()=>{e.length!==0&&(console.warn(`[LEAKING LISTENERS] GC'ed these listeners that were NOT yet disposed:`),console.warn(e.join(`
28
+ `)),e.length=0)},3e3),bx=new FinalizationRegistry(t=>{typeof t==`string`&&e.push(t)})}var X=class{constructor(e){this._size=0,this._options=e,this._leakageMon=ux>0||this._options?.leakWarningThreshold?new fx(e?.onListenerError??yb,this._options?.leakWarningThreshold??ux):void 0,this._perfMon=this._options?._profName?new lx(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){if(!this._disposed){if(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners){if(ax){let e=this._listeners;queueMicrotask(()=>{yx(e,e=>e.stack?.print())})}this._listeners=void 0,this._size=0}this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose()}}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new hx(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||yb)(n),Y.None}if(this._disposed)return Y.None;t&&(e=e.bind(t));let r=new _x(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=px.create(),i=this._leakageMon.check(r.stack,this._size+1)),ax&&(r.stack=px.create()),this._listeners?this._listeners instanceof _x?(this._deliveryQueue??=new xx,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=Jb(()=>{bx?.unregister(a),i?.(),this._removeListener(r)});if(n instanceof Xb?n.add(a):Array.isArray(n)&&n.push(a),bx){let e=Error().stack.split(`
29
+ `).slice(2,3).join(`
30
+ `).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);bx.register(a,t?.[2]??e,a)}return a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*vx<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||yb;if(!n){e.value(t);return}try{e.value(t)}catch(e){n(e)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof _x)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},xx=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Sx=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new X,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new X,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};Sx.INSTANCE=new Sx;var Cx=Sx;function wx(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}Cx.INSTANCE.onDidChangeZoomLevel;function Tx(e){return Cx.INSTANCE.getZoomFactor(e)}Cx.INSTANCE.onDidChangeFullscreen;var Ex=typeof navigator==`object`?navigator.userAgent:``,Dx=Ex.indexOf(`Firefox`)>=0,Ox=Ex.indexOf(`AppleWebKit`)>=0,kx=Ex.indexOf(`Chrome`)>=0,Ax=!kx&&Ex.indexOf(`Safari`)>=0;Ex.indexOf(`Electron/`),Ex.indexOf(`Android`);var jx=!1;if(typeof Qb.matchMedia==`function`){let e=Qb.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=Qb.matchMedia(`(display-mode: fullscreen)`);jx=e.matches,wx(Qb,e,({matches:e})=>{jx&&t.matches||(jx=e)})}function Mx(){return jx}var Nx=`en`,Px=!1,Fx=!1,Ix=!1,Lx=!1,Rx=!1,zx=Nx,Bx,Vx=globalThis,Hx;typeof Vx.vscode<`u`&&typeof Vx.vscode.process<`u`?Hx=Vx.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(Hx=process);var Ux=typeof Hx?.versions?.electron==`string`&&Hx?.type===`renderer`;if(typeof Hx==`object`){Px=Hx.platform===`win32`,Fx=Hx.platform===`darwin`,Ix=Hx.platform===`linux`,Ix&&Hx.env.SNAP&&Hx.env.SNAP_REVISION,Hx.env.CI||Hx.env.BUILD_ARTIFACTSTAGINGDIRECTORY,zx=Nx;let e=Hx.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,zx=t.resolvedLanguage||Nx,t.languagePack?.translationsConfigFile}catch{}Lx=!0}else typeof navigator==`object`&&!Ux?(Bx=navigator.userAgent,Px=Bx.indexOf(`Windows`)>=0,Fx=Bx.indexOf(`Macintosh`)>=0,(Bx.indexOf(`Macintosh`)>=0||Bx.indexOf(`iPad`)>=0||Bx.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,Ix=Bx.indexOf(`Linux`)>=0,Bx?.indexOf(`Mobi`),Rx=!0,zx=globalThis._VSCODE_NLS_LANGUAGE||Nx,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var Wx=Px,Gx=Fx,Kx=Ix,qx=Lx;Rx&&typeof Vx.importScripts==`function`&&Vx.origin;var Jx=Bx,Yx=zx,Xx;(e=>{function t(){return Yx}e.value=t;function n(){return Yx.length===2?Yx===`en`:Yx.length>=3?Yx[0]===`e`&&Yx[1]===`n`&&Yx[2]===`-`:!1}e.isDefaultVariant=n;function r(){return Yx===`en`}e.isDefault=r})(Xx||={});var Zx=typeof Vx.postMessage==`function`&&!Vx.importScripts;(()=>{if(Zx){let e=[];Vx.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),Vx.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var Qx=!!(Jx&&Jx.indexOf(`Chrome`)>=0);Jx&&Jx.indexOf(`Firefox`),!Qx&&Jx&&Jx.indexOf(`Safari`),Jx&&Jx.indexOf(`Edg/`),Jx&&Jx.indexOf(`Android`);var $x=typeof navigator==`object`?navigator:{};qx||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||$x&&$x.clipboard&&$x.clipboard.writeText,qx||$x&&$x.clipboard&&$x.clipboard.readText,qx||Mx()||$x.keyboard,`ontouchstart`in Qb||$x.maxTouchPoints,Qb.PointerEvent&&(`ontouchstart`in Qb||navigator.maxTouchPoints);var eS=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},tS=new eS,nS=new eS,rS=new eS,iS=Array(230),aS;(e=>{function t(e){return tS.keyCodeToStr(e)}e.toString=t;function n(e){return tS.strToKeyCode(e)}e.fromString=n;function r(e){return nS.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return rS.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return nS.strToKeyCode(e)||rS.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return tS.keyCodeToStr(e)}e.toElectronAccelerator=o})(aS||={});var oS=class e{constructor(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}equals(t){return t instanceof e&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){return`K${this.ctrlKey?`1`:`0`}${this.shiftKey?`1`:`0`}${this.altKey?`1`:`0`}${this.metaKey?`1`:`0`}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new sS([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},sS=class{constructor(e){if(e.length===0)throw Cb(`chords`);this.chords=e}getHashCode(){let e=``;for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=`;`),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function cS(e){if(e.charCode){let t=String.fromCharCode(e.charCode).toUpperCase();return aS.fromString(t)}let t=e.keyCode;if(t===3)return 7;if(Dx)switch(t){case 59:return 85;case 60:if(Kx)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Gx)return 57;break}else if(Ox&&(Gx&&t===93||!Gx&&t===92))return 57;return iS[t]||0}var lS=Gx?256:2048,uS=512,dS=1024,fS=Gx?2048:256,pS=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.(`AltGraph`),this.keyCode=cS(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=lS),this.altKey&&(t|=uS),this.shiftKey&&(t|=dS),this.metaKey&&(t|=fS),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new oS(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},mS=new WeakMap;function hS(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!==`null`&&n.origin!==`null`&&t.origin!==n.origin)return null}catch{return null}return e.parent}var gS=class{static getSameOriginWindowChain(e){let t=mS.get(e);if(!t){t=[],mS.set(e,t);let n=e,r;do r=hS(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,i=this.getSameOriginWindowChain(e);for(let e of i){let i=e.window.deref();if(n+=i?.scrollY??0,r+=i?.scrollX??0,i===t||!e.iframeElement)break;let a=e.iframeElement.getBoundingClientRect();n+=a.top,r+=a.left}return{top:n,left:r}}},_S=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type===`dblclick`&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX==`number`?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=gS.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},vS=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(kx){let e=navigator.userAgent.match(/Chrome\/(\d+)/);r=(e?parseInt(e[1]):123)<=122}if(e){let t=e,n=e,i=e.view?.devicePixelRatio||1;if(typeof t.wheelDeltaY<`u`)r?this.deltaY=t.wheelDeltaY/(120*i):this.deltaY=t.wheelDeltaY/120;else if(typeof n.VERTICAL_AXIS<`u`&&n.axis===n.VERTICAL_AXIS)this.deltaY=-n.detail/3;else if(e.type===`wheel`){let t=e;t.deltaMode===t.DOM_DELTA_LINE?Dx&&!Gx?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof t.wheelDeltaX<`u`)Ax&&Wx?this.deltaX=-(t.wheelDeltaX/120):r?this.deltaX=t.wheelDeltaX/(120*i):this.deltaX=t.wheelDeltaX/120;else if(typeof n.HORIZONTAL_AXIS<`u`&&n.axis===n.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type===`wheel`){let t=e;t.deltaMode===t.DOM_DELTA_LINE?Dx&&!Gx?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*i):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},yS=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),bS;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof xS?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:sx.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:yS})})(bS||={});var xS=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?yS:(this._emitter||=new X,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},SS=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e==`function`&&typeof t==`number`&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new Tb(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Tb(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},CS=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new Tb(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=Jb(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var wS;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(wS||={});var TS=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new X,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await sx.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};TS.EMPTY=TS.fromArray([]);function ES(e){return 55296<=e&&e<=56319}function DS(e){return 56320<=e&&e<=57343}function OS(e,t){return(e-55296<<10)+(t-56320)+65536}function kS(e){return AS(e,0)}function AS(e,t){switch(typeof e){case`object`:return e===null?jS(349,t):Array.isArray(e)?PS(e,t):FS(e,t);case`string`:return NS(e,t);case`boolean`:return MS(e,t);case`number`:return jS(e,t);case`undefined`:return jS(937,t);default:return jS(617,t)}}function jS(e,t){return(t<<5)-t+e|0}function MS(e,t){return jS(e?433:863,t)}function NS(e,t){t=jS(149417,t);for(let n=0,r=e.length;n<r;n++)t=jS(e.charCodeAt(n),t);return t}function PS(e,t){return t=jS(104579,t),e.reduce((e,t)=>AS(t,e),t)}function FS(e,t){return t=jS(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=NS(n,t),AS(e[n],t)),t)}function IS(e,t,n=32){let r=n-t,i=~((1<<r)-1);return(e<<t|(i&e)>>>r)>>>0}function LS(e,t=0,n=e.byteLength,r=0){for(let i=0;i<n;i++)e[t+i]=r}function RS(e,t,n=`0`){for(;e.length<t;)e=n+e;return e}function zS(e,t=32){return e instanceof ArrayBuffer?Array.from(new Uint8Array(e)).map(e=>e.toString(16).padStart(2,`0`)).join(``):RS((e>>>0).toString(16),t/4)}var BS=class e{constructor(){this._h0=1732584193,this._h1=4023233417,this._h2=2562383102,this._h3=271733878,this._h4=3285377520,this._buff=new Uint8Array(67),this._buffDV=new DataView(this._buff.buffer),this._buffLen=0,this._totalLen=0,this._leftoverHighSurrogate=0,this._finished=!1}update(e){let t=e.length;if(t===0)return;let n=this._buff,r=this._buffLen,i=this._leftoverHighSurrogate,a,o;for(i===0?(a=e.charCodeAt(0),o=0):(a=i,o=-1,i=0);;){let s=a;if(ES(a))if(o+1<t){let t=e.charCodeAt(o+1);DS(t)?(o++,s=OS(a,t)):s=65533}else{i=a;break}else DS(a)&&(s=65533);if(r=this._push(n,r,s),o++,o<t)a=e.charCodeAt(o);else break}this._buffLen=r,this._leftoverHighSurrogate=i}_push(e,t,n){return n<128?e[t++]=n:n<2048?(e[t++]=192|(n&1984)>>>6,e[t++]=128|(n&63)>>>0):n<65536?(e[t++]=224|(n&61440)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0):(e[t++]=240|(n&1835008)>>>18,e[t++]=128|(n&258048)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0),t>=64&&(this._step(),t-=64,this._totalLen+=64,e[0]=e[64],e[1]=e[65],e[2]=e[66]),t}digest(){return this._finished||(this._finished=!0,this._leftoverHighSurrogate&&(this._leftoverHighSurrogate=0,this._buffLen=this._push(this._buff,this._buffLen,65533)),this._totalLen+=this._buffLen,this._wrapUp()),zS(this._h0)+zS(this._h1)+zS(this._h2)+zS(this._h3)+zS(this._h4)}_wrapUp(){this._buff[this._buffLen++]=128,LS(this._buff,this._buffLen),this._buffLen>56&&(this._step(),LS(this._buff));let e=8*this._totalLen;this._buffDV.setUint32(56,Math.floor(e/4294967296),!1),this._buffDV.setUint32(60,e%4294967296,!1),this._step()}_step(){let t=e._bigBlock32,n=this._buffDV;for(let e=0;e<64;e+=4)t.setUint32(e,n.getUint32(e,!1),!1);for(let e=64;e<320;e+=4)t.setUint32(e,IS(t.getUint32(e-12,!1)^t.getUint32(e-32,!1)^t.getUint32(e-56,!1)^t.getUint32(e-64,!1),1),!1);let r=this._h0,i=this._h1,a=this._h2,o=this._h3,s=this._h4,c,l,u;for(let e=0;e<80;e++)e<20?(c=i&a|~i&o,l=1518500249):e<40?(c=i^a^o,l=1859775393):e<60?(c=i&a|i&o|a&o,l=2400959708):(c=i^a^o,l=3395469782),u=IS(r,5)+c+s+l+t.getUint32(e*4,!1)&4294967295,s=o,o=a,a=IS(i,30),i=r,r=u;this._h0=this._h0+r&4294967295,this._h1=this._h1+i&4294967295,this._h2=this._h2+a&4294967295,this._h3=this._h3+o&4294967295,this._h4=this._h4+s&4294967295}};BS._bigBlock32=new DataView(new ArrayBuffer(320));var{registerWindow:VS,getWindow:HS,getDocument:US,getWindows:WS,getWindowsCount:GS,getWindowId:KS,getWindowById:qS,hasWindow:JS,onDidRegisterWindow:YS,onWillUnregisterWindow:XS,onDidUnregisterWindow:ZS}=function(){let e=new Map,t={window:Qb,disposables:new Xb};e.set(Qb.vscodeWindowId,t);let n=new X,r=new X,i=new X;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return Y.None;let a=new Xb,o={window:t,disposables:a.add(new Xb)};return e.set(t.vscodeWindowId,o),a.add(Jb(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(Z(t,sC.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:Qb},getDocument(e){return HS(e).document}}}(),QS=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&=(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,null)}};function Z(e,t,n,r){return new QS(e,t,n,r)}function $S(e,t){return function(n){return t(new _S(e,n))}}function eC(e){return function(t){return e(new pS(t))}}var tC=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=$S(HS(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=eC(n)),Z(e,t,i,r)},nC,rC=class extends CS{constructor(e){super(),this.defaultTarget=e&&HS(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},iC=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){yb(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,i=i=>{n.set(i,!1);let a=e.get(i)??[];for(t.set(i,a),e.set(i,[]),r.set(i,!0);a.length>0;)a.sort(iC.sort),a.shift().execute();r.set(i,!1)};nC=(t,r,a=0)=>{let o=KS(t),s=new iC(r,a),c=e.get(o);return c||(c=[],e.set(o,c)),c.push(s),n.get(o)||(n.set(o,!0),t.requestAnimationFrame(()=>i(o))),s}})();var aC=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};aC.None=new aC(0,0);function oC(e){let t=e.getBoundingClientRect(),n=HS(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=kS(n),a=r.get(i);if(a)a.users+=1;else{let o=new X,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(Jb(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var sC={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:Ox?`webkitAnimationStart`:`animationstart`,ANIMATION_END:Ox?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:Ox?`webkitAnimationIteration`:`animationiteration`},cC=/([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/;function lC(e,t,n,...r){let i=cC.exec(t);if(!i)throw Error(`Bad use of emmet`);let a=i[1]||`div`,o;return o=e===`http://www.w3.org/1999/xhtml`?document.createElement(a):document.createElementNS(e,a),i[3]&&(o.id=i[3]),i[4]&&(o.className=i[4].replace(/\./g,` `).trim()),n&&Object.entries(n).forEach(([e,t])=>{typeof t>`u`||(/^on\w+$/.test(e)?o[e]=t:e===`selected`?t&&o.setAttribute(e,`true`):o.setAttribute(e,t))}),o.append(...r),o}function uC(e,t,...n){return lC(`http://www.w3.org/1999/xhtml`,e,t,...n)}uC.SVG=function(e,t,...n){return lC(`http://www.w3.org/2000/svg`,e,t,...n)};var dC=class{constructor(e){this.domNode=e,this._maxWidth=``,this._width=``,this._height=``,this._top=``,this._left=``,this._bottom=``,this._right=``,this._paddingTop=``,this._paddingLeft=``,this._paddingBottom=``,this._paddingRight=``,this._fontFamily=``,this._fontWeight=``,this._fontSize=``,this._fontStyle=``,this._fontFeatureSettings=``,this._fontVariationSettings=``,this._textDecoration=``,this._lineHeight=``,this._letterSpacing=``,this._className=``,this._display=``,this._position=``,this._visibility=``,this._color=``,this._backgroundColor=``,this._layerHint=!1,this._contain=`none`,this._boxShadow=``}setMaxWidth(e){let t=fC(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=fC(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=fC(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=fC(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=fC(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=fC(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=fC(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=fC(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=fC(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=fC(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=fC(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=fC(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=fC(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=fC(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?`translate3d(0px, 0px, 0px)`:``)}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function fC(e){return typeof e==`number`?`${e}px`:e}function pC(e){return new dC(e)}var mC=class{constructor(){this._hooks=new Xb,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let a=e;try{e.setPointerCapture(t),this._hooks.add(Jb(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=HS(e)}this._hooks.add(Z(a,sC.POINTER_MOVE,e=>{if(e.buttons!==n){this.stopMonitoring(!0);return}e.preventDefault(),this._pointerMoveCallback(e)})),this._hooks.add(Z(a,sC.POINTER_UP,e=>this.stopMonitoring(!0)))}};function hC(e,t,n){let r=null,i=null;if(typeof n.value==`function`?(r=`value`,i=n.value,i.length!==0&&console.warn(`Memoize should only be used in functions with zero parameters`)):typeof n.get==`function`&&(r=`get`,i=n.get),!i)throw Error(`not supported`);let a=`$memoize$${t}`;n[r]=function(...e){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,e)}),this[a]}}var gC;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(gC||={});var _C=class e extends Y{constructor(){super(),this.dispatched=!1,this.targets=new tx,this.ignoreTargets=new tx,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(sx.runAndSubscribe(YS,({window:e,disposables:t})=>{t.add(Z(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(Z(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(Z(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:Qb,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=Gb(new e),Jb(e.INSTANCE.targets.push(t))):Y.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=Gb(new e),Jb(e.INSTANCE.ignoreTargets.push(t))):Y.None}static isTouchDevice(){return`ontouchstart`in Qb||navigator.maxTouchPoints>0}dispose(){this.handle&&=(this.handle.dispose(),null),super.dispose()}onTouchStart(e){let t=Date.now();this.handle&&=(this.handle.dispose(),null);for(let n=0,r=e.targetTouches.length;n<r;n++){let r=e.targetTouches.item(n);this.activeTouches[r.identifier]={id:r.identifier,initialTarget:r.target,initialTimeStamp:t,initialPageX:r.pageX,initialPageY:r.pageY,rollingTimestamps:[t],rollingPageX:[r.pageX],rollingPageY:[r.pageY]};let i=this.newGestureEvent(gC.Start,r.target);i.pageX=r.pageX,i.pageY=r.pageY,this.dispatchEvent(i)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}onTouchEnd(t,n){let r=Date.now(),i=Object.keys(this.activeTouches).length;for(let a=0,o=n.changedTouches.length;a<o;a++){let o=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn(`move of an UNKNOWN touch`,o);continue}let s=this.activeTouches[o.identifier],c=Date.now()-s.initialTimeStamp;if(c<e.HOLD_DELAY&&Math.abs(s.initialPageX-Ob(s.rollingPageX))<30&&Math.abs(s.initialPageY-Ob(s.rollingPageY))<30){let e=this.newGestureEvent(gC.Tap,s.initialTarget);e.pageX=Ob(s.rollingPageX),e.pageY=Ob(s.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&Math.abs(s.initialPageX-Ob(s.rollingPageX))<30&&Math.abs(s.initialPageY-Ob(s.rollingPageY))<30){let e=this.newGestureEvent(gC.Contextmenu,s.initialTarget);e.pageX=Ob(s.rollingPageX),e.pageY=Ob(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=Ob(s.rollingPageX),n=Ob(s.rollingPageY),i=Ob(s.rollingTimestamps)-s.rollingTimestamps[0],a=e-s.rollingPageX[0],o=n-s.rollingPageY[0],c=[...this.targets].filter(e=>s.initialTarget instanceof Node&&e.contains(s.initialTarget));this.inertia(t,c,r,Math.abs(a)/i,a>0?1:-1,e,Math.abs(o)/i,o>0?1:-1,n)}this.dispatchEvent(this.newGestureEvent(gC.End,s.initialTarget)),delete this.activeTouches[o.identifier]}this.dispatched&&=(n.preventDefault(),n.stopPropagation(),!1)}newGestureEvent(e,t){let n=document.createEvent(`CustomEvent`);return n.initEvent(e,!1,!0),n.initialTarget=t,n.tapCount=0,n}dispatchEvent(t){if(t.type===gC.Tap){let n=new Date().getTime(),r=0;r=n-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=n,t.tapCount=r}else (t.type===gC.Change||t.type===gC.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(t.initialTarget))return;let e=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let r=0,i=t.initialTarget;for(;i&&i!==n;)r++,i=i.parentElement;e.push([r,n])}e.sort((e,t)=>e[0]-t[0]);for(let[n,r]of e)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,i,a,o,s,c,l){this.handle=nC(t,()=>{let u=Date.now(),d=u-r,f=0,p=0,m=!0;i+=e.SCROLL_FRICTION*d,s+=e.SCROLL_FRICTION*d,i>0&&(m=!1,f=a*i*d),s>0&&(m=!1,p=c*s*d);let h=this.newGestureEvent(gC.Change);h.translationX=f,h.translationY=p,n.forEach(e=>e.dispatchEvent(h)),m||this.inertia(t,n,u,i,a,o+f,s,c,l+p)})}onTouchMove(e){let t=Date.now();for(let n=0,r=e.changedTouches.length;n<r;n++){let r=e.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(r.identifier))){console.warn(`end of an UNKNOWN touch`,r);continue}let i=this.activeTouches[r.identifier],a=this.newGestureEvent(gC.Change,i.initialTarget);a.translationX=r.pageX-Ob(i.rollingPageX),a.translationY=r.pageY-Ob(i.rollingPageY),a.pageX=r.pageX,a.pageY=r.pageY,this.dispatchEvent(a),i.rollingPageX.length>3&&(i.rollingPageX.shift(),i.rollingPageY.shift(),i.rollingTimestamps.shift()),i.rollingPageX.push(r.pageX),i.rollingPageY.push(r.pageY),i.rollingTimestamps.push(t)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}};_C.SCROLL_FRICTION=-.005,_C.HOLD_DELAY=700,_C.CLEAR_TAP_COUNT_TIME=400,Ty([hC],_C,`isTouchDevice`,1);var vC=_C,yC=class extends Y{onclick(e,t){this._register(Z(e,sC.CLICK,n=>t(new _S(HS(e),n))))}onmousedown(e,t){this._register(Z(e,sC.MOUSE_DOWN,n=>t(new _S(HS(e),n))))}onmouseover(e,t){this._register(Z(e,sC.MOUSE_OVER,n=>t(new _S(HS(e),n))))}onmouseleave(e,t){this._register(Z(e,sC.MOUSE_LEAVE,n=>t(new _S(HS(e),n))))}onkeydown(e,t){this._register(Z(e,sC.KEY_DOWN,e=>t(new pS(e))))}onkeyup(e,t){this._register(Z(e,sC.KEY_UP,e=>t(new pS(e))))}oninput(e,t){this._register(Z(e,sC.INPUT,t))}onblur(e,t){this._register(Z(e,sC.BLUR,t))}onfocus(e,t){this._register(Z(e,sC.FOCUS,t))}onchange(e,t){this._register(Z(e,sC.CHANGE,t))}ignoreGesture(e){return vC.ignoreTarget(e)}},bC=11,xC=class extends yC{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement(`div`),this.bgDomNode.className=`arrow-background`,this.bgDomNode.style.position=`absolute`,this.bgDomNode.style.width=e.bgWidth+`px`,this.bgDomNode.style.height=e.bgHeight+`px`,typeof e.top<`u`&&(this.bgDomNode.style.top=`0px`),typeof e.left<`u`&&(this.bgDomNode.style.left=`0px`),typeof e.bottom<`u`&&(this.bgDomNode.style.bottom=`0px`),typeof e.right<`u`&&(this.bgDomNode.style.right=`0px`),this.domNode=document.createElement(`div`),this.domNode.className=e.className,this.domNode.style.position=`absolute`,this.domNode.style.width=bC+`px`,this.domNode.style.height=bC+`px`,typeof e.top<`u`&&(this.domNode.style.top=e.top+`px`),typeof e.left<`u`&&(this.domNode.style.left=e.left+`px`),typeof e.bottom<`u`&&(this.domNode.style.bottom=e.bottom+`px`),typeof e.right<`u`&&(this.domNode.style.right=e.right+`px`),this._pointerMoveMonitor=this._register(new mC),this._register(tC(this.bgDomNode,sC.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(tC(this.domNode,sC.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new rC),this._pointerdownScheduleRepeatTimer=this._register(new SS)}_arrowPointerDown(e){!e.target||!(e.target instanceof Element)||(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,HS(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},SC=class e{constructor(e,t,n,r,i,a,o){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(t|=0,n|=0,r|=0,i|=0,a|=0,o|=0),this.rawScrollLeft=r,this.rawScrollTop=o,t<0&&(t=0),r+t>n&&(r=n-t),r<0&&(r=0),i<0&&(i=0),o+i>a&&(o=a-i),o<0&&(o=0),this.width=t,this.scrollWidth=n,this.scrollLeft=r,this.height=i,this.scrollHeight=a,this.scrollTop=o}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(t,n){return new e(this._forceIntegerValues,typeof t.width<`u`?t.width:this.width,typeof t.scrollWidth<`u`?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<`u`?t.height:this.height,typeof t.scrollHeight<`u`?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new e(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<`u`?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<`u`?t.scrollTop:this.rawScrollTop)}createScrollEvent(e,t){let n=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,i=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,o=this.scrollHeight!==e.scrollHeight,s=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:t,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:r,scrollLeftChanged:i,heightChanged:a,scrollHeightChanged:o,scrollTopChanged:s}}},CC=class extends Y{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new X),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new SC(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>`u`?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>`u`?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;r=t?new DC(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let t=this._state.withScrollPosition(e);this._smoothScrolling=DC.start(this._state,t,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},wC=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function TC(e,t){let n=t-e;return function(t){return e+n*kC(t)}}function EC(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var DC=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.duration=r,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,t,n){if(Math.abs(e-t)>2.5*n){let r,i;return e<t?(r=e+.75*n,i=t-.75*n):(r=e-.75*n,i=t+.75*n),EC(TC(e,r),TC(i,t),.33)}return TC(e,t)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let t=(e-this.startTime)/this.duration;return t<1?new wC(this.scrollLeft(t),this.scrollTop(t),!1):new wC(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return e.start(t,n,r)}static start(t,n,r){return r+=10,new e(t,n,Date.now()-10,r)}};function OC(e){return e**3}function kC(e){return 1-OC(1-e)}var AC=class extends Y{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new SS)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?` fade`:``)))}},jC=140,MC=class extends yC{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new AC(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new mC),this._shouldRender=!0,this.domNode=pC(document.createElement(`div`)),this.domNode.setAttribute(`role`,`presentation`),this.domNode.setAttribute(`aria-hidden`,`true`),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition(`absolute`),this._register(Z(this.domNode.domNode,sC.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new xC(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=pC(document.createElement(`div`)),this.slider.setClassName(`slider`),this.slider.setPosition(`absolute`),this.slider.setTop(e),this.slider.setLeft(t),typeof n==`number`&&this.slider.setWidth(n),typeof r==`number`&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain(`strict`),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Z(this.slider.domNode,sC.POINTER_DOWN,e=>{e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);n<=i&&i<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX==`number`&&typeof e.offsetY==`number`)t=e.offsetX,n=e.offsetY;else{let r=oC(this.domNode.domNode);t=e.pageX-r.left,n=e.pageY-r.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName(`active`,!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let i=this._sliderOrthogonalPointerPosition(e),a=Math.abs(i-n);if(Wx&&a>jC){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let o=this._sliderPointerPosition(e)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(o))},()=>{this.slider.toggleClassName(`active`,!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},NC=class e{constructor(e,t,n,r,i,a){this._scrollbarSize=Math.round(t),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=i,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let t=Math.round(e);return this._visibleSize===t?!1:(this._visibleSize=t,this._refreshComputedValues(),!0)}setScrollSize(e){let t=Math.round(e);return this._scrollSize===t?!1:(this._scrollSize=t,this._refreshComputedValues(),!0)}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition===t?!1:(this._scrollPosition=t,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,t,n,r,i){let a=Math.max(0,n-e),o=Math.max(0,a-2*t),s=r>0&&r>n;if(!s)return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(o),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(n*o/r))),l=(o-c)/(r-n),u=i*l;return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(c),computedSliderRatio:l,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize-this._computedSliderSize/2;return Math.round(t/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize,n=this._scrollPosition;return t<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let t=this._computedSliderPosition+e;return Math.round(t/this._computedSliderRatio)}},PC=class extends MC{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new NC(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,i.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:`horizontal`,scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},FC=class extends MC{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new NC(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,i.scrollTop),visibility:t.vertical,extraScrollbarClassName:`vertical`,scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},IC=500,LC=50,RC=!0,zC=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},BC=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,t=0,n=1,r=this._rear;do{let i=r===this._front?e:2**-n;if(e-=i,t+=this._memory[r].score*i,r===this._front)break;r=(this._capacity+r-1)%this._capacity,n++}while(!0);return t<=.5}acceptStandardWheelEvent(e){if(kx){let t=Tx(HS(e.browserEvent));this.accept(Date.now(),e.deltaX*t,e.deltaY*t)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,t,n){let r=null,i=new zC(e,t,n);this._front===-1&&this._rear===-1?(this._memory[0]=i,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=i),i.score=this._computeScore(i,r)}_computeScore(e,t){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(n+=.25),t){let r=Math.abs(e.deltaX),i=Math.abs(e.deltaY),a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),s=Math.max(Math.min(r,a),1),c=Math.max(Math.min(i,o),1),l=Math.max(r,a),u=Math.max(i,o);l%s===0&&u%c===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};BC.INSTANCE=new BC;var VC=BC,HC=class extends yC{constructor(e,t,n){super(),this._onScroll=this._register(new X),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new X),this.onWillScroll=this._onWillScroll.event,this._options=WC(t),this._scrollable=n,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let r={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new FC(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new PC(this._scrollable,this._options,r)),this._domNode=document.createElement(`div`),this._domNode.className=`xterm-scrollable-element `+this._options.className,this._domNode.setAttribute(`role`,`presentation`),this._domNode.style.position=`relative`,this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=pC(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=pC(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=pC(document.createElement(`div`)),this._topLeftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new SS),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Kb(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,Gx&&(this._options.className+=` mac`),this._domNode.className=`xterm-scrollable-element `+this._options.className}updateOptions(e){typeof e.handleMouseWheel<`u`&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<`u`&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<`u`&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<`u`&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<`u`&&(this._options.horizontal=e.horizontal),typeof e.vertical<`u`&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<`u`&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<`u`&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<`u`&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new vS(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Kb(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(Z(this._listenOnDomNode,sC.MOUSE_WHEEL,e=>{this._onMouseWheel(new vS(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=VC.INSTANCE;RC&&t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,i=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&i+r===0?i=r=0:Math.abs(r)>=Math.abs(i)?i=0:r=0),this._options.flipAxes&&([r,i]=[i,r]);let a=!Gx&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!i&&(i=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(i*=this._options.fastScrollSensitivity,r*=this._options.fastScrollSensitivity);let o=this._scrollable.getFutureScrollPosition(),s={};if(r){let e=LC*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=LC*i,t=o.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(s,t)}s=this._scrollable.validateScrollPosition(s),(o.scrollLeft!==s.scrollLeft||o.scrollTop!==s.scrollTop)&&(RC&&this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(s):this._scrollable.setScrollPositionNow(s),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?` left`:``,i=t?` top`:``,a=n||t?` top-left-corner`:``;this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${i}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),IC)}},UC=class extends HC{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function WC(e){let t={lazyRender:typeof e.lazyRender<`u`?e.lazyRender:!1,className:typeof e.className<`u`?e.className:``,useShadows:typeof e.useShadows<`u`?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<`u`?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<`u`?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<`u`?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<`u`?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<`u`?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<`u`?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<`u`?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<`u`?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<`u`?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<`u`?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<`u`?e.listenOnDomNode:null,horizontal:typeof e.horizontal<`u`?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<`u`?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<`u`?e.horizontalHasArrows:!1,vertical:typeof e.vertical<`u`?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<`u`?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<`u`?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<`u`?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<`u`?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<`u`?e.verticalSliderSize:t.verticalScrollbarSize,Gx&&(t.className+=` mac`),t}var GC=class extends Y{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new X),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new CC({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>nC(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new UC(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange([`scrollSensitivity`,`fastScrollSensitivity`,`overviewRuler`],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(e&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(sx.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Jb(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(Jb(()=>this._styleElement.remove())),this._register(sx.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[`.xterm .xterm-scrollable-element > .scrollbar > .slider {`,` background: ${a.colors.scrollbarSliderBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider:hover {`,` background: ${a.colors.scrollbarSliderHoverBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider.active {`,` background: ${a.colors.scrollbarSliderActiveBackground.css};`,`}`].join(`
31
+ `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(e=>this._handleScroll(e)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};GC=Ty([J(2,Qy),J(3,db),J(4,$y),J(5,gb),J(6,ib),J(7,pb)],GC);var KC=class extends Y{constructor(e,t,n,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement(`div`),this._container.classList.add(`xterm-decoration-container`),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(e=>this._removeDecoration(e))),this._register(Jb(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement(`div`);t.classList.add(`xterm-decoration`),t.classList.toggle(`xterm-decoration-top-layer`,e?.options?.layer===`top`),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display=`none`),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display=`none`,e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?`none`:`block`,this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||`left`)===`right`?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:``:t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:``}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};KC=Ty([J(1,Qy),J(2,db),J(3,sb),J(4,pb)],KC);var qC=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||`full`]&&t<=e.endBufferLine+this._linePadding[n||`full`]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},JC={full:0,left:0,center:0,right:0},YC={full:0,left:0,center:0,right:0},XC={full:0,left:0,center:0,right:0},ZC=class extends Y{constructor(e,t,n,r,i,a,o,s){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=a,this._themeService=o,this._coreBrowserService=s,this._colorZoneStore=new qC,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-decoration-overview-ruler`),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(Jb(()=>this._canvas?.remove()));let c=this._canvas.getContext(`2d`);if(c)this._ctx=c;else throw Error(`Ctx cannot be null`);this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?`none`:`block`})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange(`overviewRuler`,()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);YC.full=this._canvas.width,YC.left=e,YC.center=t,YC.right=e,this._refreshDrawHeightConstants(),XC.full=1,XC.left=1,XC.center=1+YC.left,XC.right=1+YC.left+YC.center}_refreshDrawHeightConstants(){JC.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);JC.left=t,JC.center=t,JC.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*JC.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*JC.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*JC.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*JC.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!==`full`&&this._renderColorZone(t);for(let t of e)t.position===`full`&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(XC[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-JC[e.position||`full`]/2),YC[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+JC[e.position||`full`]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};ZC=Ty([J(2,Qy),J(3,sb),J(4,pb),J(5,ib),J(6,gb),J(7,db)],ZC);var Q;(e=>(e.NUL=`\0`,e.SOH=``,e.STX=``,e.ETX=``,e.EOT=``,e.ENQ=``,e.ACK=``,e.BEL=`\x07`,e.BS=`\b`,e.HT=` `,e.LF=`
32
+ `,e.VT=`\v`,e.FF=`\f`,e.CR=`\r`,e.SO=``,e.SI=``,e.DLE=``,e.DC1=``,e.DC2=``,e.DC3=``,e.DC4=``,e.NAK=``,e.SYN=``,e.ETB=``,e.CAN=``,e.EM=``,e.SUB=``,e.ESC=`\x1B`,e.FS=``,e.GS=``,e.RS=``,e.US=``,e.SP=` `,e.DEL=``))(Q||={});var QC;(e=>(e.PAD=`€`,e.HOP=``,e.BPH=`‚`,e.NBH=`ƒ`,e.IND=`„`,e.NEL=`…`,e.SSA=`†`,e.ESA=`‡`,e.HTS=`ˆ`,e.HTJ=`‰`,e.VTS=`Š`,e.PLD=`‹`,e.PLU=`Œ`,e.RI=``,e.SS2=`Ž`,e.SS3=``,e.DCS=``,e.PU1=`‘`,e.PU2=`’`,e.STS=`“`,e.CCH=`”`,e.MW=`•`,e.SPA=`–`,e.EPA=`—`,e.SOS=`˜`,e.SGCI=`™`,e.SCI=`š`,e.CSI=`›`,e.ST=`œ`,e.OSC=``,e.PM=`ž`,e.APC=`Ÿ`))(QC||={});var $C;(e=>e.ST=`${Q.ESC}\\`)($C||={});var ew=class{constructor(e,t,n,r,i,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=``}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent=``,this._dataAlreadySent=``,this._compositionView.classList.add(`active`)}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove(`active`),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let t;e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,``);this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${Q.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+`px`,this._compositionView.style.top=n+`px`,this._compositionView.style.height=t+`px`,this._compositionView.style.lineHeight=t+`px`,this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+`px`;let i=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+`px`,this._textarea.style.top=n+`px`,this._textarea.style.width=Math.max(i.width,1)+`px`,this._textarea.style.height=Math.max(i.height,1)+`px`,this._textarea.style.lineHeight=i.height+`px`}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};ew=Ty([J(2,Qy),J(3,ib),J(4,eb),J(5,pb)],ew);var tw=0,nw=0,rw=0,iw=0,aw={css:`#00000000`,rgba:0},ow;(e=>{function t(e,t,n,r){return r===void 0?`#${dw(e)}${dw(t)}${dw(n)}`:`#${dw(e)}${dw(t)}${dw(n)}${dw(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(ow||={});var sw;(e=>{function t(e,t){if(iw=(t.rgba&255)/255,iw===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return tw=a+Math.round((n-a)*iw),nw=o+Math.round((r-o)*iw),rw=s+Math.round((i-s)*iw),{css:ow.toCss(tw,nw,rw),rgba:ow.toRgba(tw,nw,rw)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=uw.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return ow.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[tw,nw,rw]=uw.toChannels(t),{css:ow.toCss(tw,nw,rw),rgba:t}}e.opaque=i;function a(e,t){return iw=Math.round(t*255),[tw,nw,rw]=uw.toChannels(e.rgba),{css:ow.toCss(tw,nw,rw,iw),rgba:ow.toRgba(tw,nw,rw,iw)}}e.opacity=a;function o(e,t){return iw=e.rgba&255,a(e,iw*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(sw||={});var cw;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return tw=parseInt(e.slice(1,2).repeat(2),16),nw=parseInt(e.slice(2,3).repeat(2),16),rw=parseInt(e.slice(3,4).repeat(2),16),ow.toColor(tw,nw,rw);case 5:return tw=parseInt(e.slice(1,2).repeat(2),16),nw=parseInt(e.slice(2,3).repeat(2),16),rw=parseInt(e.slice(3,4).repeat(2),16),iw=parseInt(e.slice(4,5).repeat(2),16),ow.toColor(tw,nw,rw,iw);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return tw=parseInt(r[1]),nw=parseInt(r[2]),rw=parseInt(r[3]),iw=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),ow.toColor(tw,nw,rw,iw);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[tw,nw,rw,iw]=t.getImageData(0,0,1,1).data,iw!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:ow.toRgba(tw,nw,rw,iw),css:e}}e.toColor=r})(cw||={});var lw;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(lw||={});var uw;(e=>{function t(e,t){if(iw=(t&255)/255,iw===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return tw=a+Math.round((n-a)*iw),nw=o+Math.round((r-o)*iw),rw=s+Math.round((i-s)*iw),ow.toRgba(tw,nw,rw)}e.blend=t;function n(e,t,n){let a=lw.relativeLuminance(e>>8),o=lw.relativeLuminance(t>>8);if(fw(a,o)<n){if(o<a){let o=r(e,t,n),s=fw(a,lw.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>fw(a,lw.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=fw(a,lw.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>fw(a,lw.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=fw(lw.relativeLuminance2(o,s,c),lw.relativeLuminance2(r,i,a));for(;l<n&&(o>0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=fw(lw.relativeLuminance2(o,s,c),lw.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=fw(lw.relativeLuminance2(o,s,c),lw.relativeLuminance2(r,i,a));for(;l<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil((255-o)*.1)),s=Math.min(255,s+Math.ceil((255-s)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),l=fw(lw.relativeLuminance2(o,s,c),lw.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(uw||={});function dw(e){let t=e.toString(16);return t.length<2?`0`+t:t}function fw(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var pw=class extends Uy{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},mw=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Gy}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),i=0,a=0,o=0,s=t.getFg(0),c=t.getBg(0);for(let e=0;e<t.getTrimmedLength();e++)if(t.loadCell(e,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==s||this._workCell.bg!==c){if(e-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}i=e,o=a,s=this._workCell.fg,c=this._workCell.bg}a+=this._workCell.getChars().length||Hy.length}if(this._bufferService.cols-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}return n}_getJoinedRanges(e,t,n,r,i){let a=e.substring(t,n),o=[];try{o=this._characterJoiners[0].handler(a)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let t=this._characterJoiners[e].handler(a);for(let e=0;e<t.length;e++)mw._mergeRanges(o,t[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(o,r,i),o}_stringRangesToCellRanges(e,t,n){let r=0,i=!1,a=0,o=e[r];if(o){for(let s=n;s<this._bufferService.cols;s++){let n=t.getWidth(s),c=t.getString(s).length||Hy.length;if(n!==0){if(!i&&o[0]<=a&&(o[0]=s,i=!0),o[1]<=a){if(o[1]=s,o=e[++r],!o)break;o[0]<=a?(o[0]=s,i=!0):i=!1}a+=c}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){if(t[1]<=i[0])return e[r-1][1]=t[1],e;if(t[1]<=i[1])return e[r-1][1]=Math.max(t[1],i[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=i[0])return e.splice(r,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};mw=Ty([J(0,Qy)],mw);function hw(e){return 57508<=e&&e<=57558}function gw(e){return 9472<=e&&e<=9631}function _w(e){return hw(e)||gw(e)}function vw(){return{css:{canvas:yw(),cell:yw()},device:{canvas:yw(),cell:yw(),char:{width:0,height:0,left:0,top:0}}}}function yw(){return{width:0,height:0}}var bw=class{constructor(e,t,n,r,i,a,o){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._themeService=o,this._workCell=new Gy,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,i,a,o,s,c,l,u){let d=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();n&&m<a+1&&(m=a+1);let h,g=0,_=``,v=0,y=0,b=0,x=0,S=!1,C=0,w=!1,T=0,ee=0,E=[],D=l!==-1&&u!==-1;for(let O=0;O<m;O++){e.loadCell(O,this._workCell);let m=this._workCell.getWidth();if(m===0)continue;let k=!1,te=O>=ee,ne=O,A=this._workCell;if(f.length>0&&O===f[0][0]&&te){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v<r[1];v++)te&&=i===this._isCellInSelection(v,t);te&&=!n||a<r[0]||a>=r[1],te?(k=!0,A=new pw(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),ne=r[1]-1,m=A.getWidth()):ee=r[1]}let re=this._isCellInSelection(O,t),j=n&&O===a,ie=D&&O>=l&&O<=u,ae=!1;this._decorationService.forEachDecorationAtCell(O,t,void 0,e=>{ae=!0});let oe=A.getChars()||Hy;if(oe===` `&&(A.isUnderline()||A.isOverline())&&(oe=`\xA0`),T=m*s-c.get(oe,A.isBold(),A.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(re&&w||!re&&!w&&A.bg===y)&&(re&&w&&p.selectionForeground||A.fg===b)&&A.extended.ext===x&&ie===S&&T===C&&!j&&!k&&!ae&&te){A.isInvisible()?_+=Hy:_+=oe,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=A.bg,b=A.fg,x=A.extended.ext,S=ie,C=T,w=re,k&&a>=O&&a<=ne&&(a=O),!this._coreService.isCursorHidden&&j&&this._coreService.isCursorInitialized){if(E.push(`xterm-cursor`),this._coreBrowserService.isFocused)o&&E.push(`xterm-cursor-blink`),E.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:E.push(`xterm-cursor-outline`);break;case`block`:E.push(`xterm-cursor-block`);break;case`bar`:E.push(`xterm-cursor-bar`);break;case`underline`:E.push(`xterm-cursor-underline`);break;default:break}}if(A.isBold()&&E.push(`xterm-bold`),A.isItalic()&&E.push(`xterm-italic`),A.isDim()&&E.push(`xterm-dim`),_=A.isInvisible()?Hy:A.getChars()||Hy,A.isUnderline()&&(E.push(`xterm-underline-${A.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!A.isUnderlineColorDefault()))if(A.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${Uy.toColorRGB(A.getUnderlineColor()).join(`,`)})`;else{let e=A.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&A.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}A.isOverline()&&(E.push(`xterm-overline`),_===` `&&(_=`\xA0`)),A.isStrikethrough()&&E.push(`xterm-strikethrough`),ie&&(h.style.textDecoration=`underline`);let se=A.getFgColor(),M=A.getFgColorMode(),ce=A.getBgColor(),le=A.getBgColorMode(),ue=!!A.isInverse();if(ue){let e=se;se=ce,ce=e;let t=M;M=le,le=t}let de,N,fe=!1;this._decorationService.forEachDecorationAtCell(O,t,void 0,e=>{e.options.layer!==`top`&&fe||(e.backgroundColorRGB&&(le=50331648,ce=e.backgroundColorRGB.rgba>>8&16777215,de=e.backgroundColorRGB),e.foregroundColorRGB&&(M=50331648,se=e.foregroundColorRGB.rgba>>8&16777215,N=e.foregroundColorRGB),fe=e.options.layer===`top`)}),!fe&&re&&(de=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,ce=de.rgba>>8&16777215,le=50331648,fe=!0,p.selectionForeground&&(M=50331648,se=p.selectionForeground.rgba>>8&16777215,N=p.selectionForeground)),fe&&E.push(`xterm-decoration-top`);let pe;switch(le){case 16777216:case 33554432:pe=p.ansi[ce],E.push(`xterm-bg-${ce}`);break;case 50331648:pe=ow.toColor(ce>>16,ce>>8&255,ce&255),this._addStyle(h,`background-color:#${xw((ce>>>0).toString(16),`0`,6)}`);break;default:ue?(pe=p.foreground,E.push(`xterm-bg-257`)):pe=p.background}switch(de||A.isDim()&&(de=sw.multiplyOpacity(pe,.5)),M){case 16777216:case 33554432:A.isBold()&&se<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(se+=8),this._applyMinimumContrast(h,pe,p.ansi[se],A,de,void 0)||E.push(`xterm-fg-${se}`);break;case 50331648:let e=ow.toColor(se>>16&255,se>>8&255,se&255);this._applyMinimumContrast(h,pe,e,A,de,N)||this._addStyle(h,`color:#${xw(se.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,pe,p.foreground,A,de,N)||ue&&E.push(`xterm-fg-257`)}E.length&&=(h.className=E.join(` `),0),!j&&!k&&!ae&&te?g++:h.textContent=_,T!==this.defaultSpacing&&(h.style.letterSpacing=`${T}px`),d.push(h),O=ne}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||_w(r.getCode()))return!1;let o=this._getContrastCache(r),s;if(!i&&!a&&(s=o.getColor(t.rgba,n.rgba)),s===void 0){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);s=sw.ensureContrastRatio(i||t,a||n,e),o.setColor((i||t).rgba,(a||n).rgba,s??null)}return s?(this._addStyle(e,`color:${s.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute(`style`,`${e.getAttribute(`style`)||``}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};bw=Ty([J(1,hb),J(2,ib),J(3,db),J(4,eb),J(5,sb),J(6,gb)],bw);function xw(e,t,n){for(;e.length<n;)e=t+e;return e}var Sw=class{constructor(e,t){this._flat=new Float32Array(256),this._font=``,this._fontSize=0,this._weight=`normal`,this._weightBold=`bold`,this._measureElements=[],this._container=e.createElement(`div`),this._container.classList.add(`xterm-width-cache-measure-container`),this._container.setAttribute(`aria-hidden`,`true`),this._container.style.whiteSpace=`pre`,this._container.style.fontKerning=`none`;let n=e.createElement(`span`);n.classList.add(`xterm-char-measure-element`);let r=e.createElement(`span`);r.classList.add(`xterm-char-measure-element`),r.style.fontWeight=`bold`;let i=e.createElement(`span`);i.classList.add(`xterm-char-measure-element`),i.style.fontStyle=`italic`;let a=e.createElement(`span`);a.classList.add(`xterm-char-measure-element`),a.style.fontWeight=`bold`,a.style.fontStyle=`italic`,this._measureElements=[n,r,i,a],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let t=this._measure(e,0);return t>0&&(this._flat[r]=t),t}let i=e;t&&(i+=`B`),n&&(i+=`I`);let a=this._holey.get(i);if(a===void 0){let r=0;t&&(r|=1),n&&(r|=2),a=this._measure(e,r),a>0&&this._holey.set(i,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},Cw=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);if(s>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function ww(){return new Cw}var Tw=`xterm-dom-renderer-owner-`,Ew=`xterm-rows`,Dw=`xterm-fg-`,Ow=`xterm-bg-`,kw=`xterm-focus`,Aw=`xterm-selection`,jw=1,Mw=class extends Y{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=a,this._linkifier2=o,this._charSizeService=c,this._optionsService=l,this._bufferService=u,this._coreService=d,this._coreBrowserService=f,this._themeService=p,this._terminalClass=jw++,this._rowElements=[],this._selectionRenderModel=ww(),this.onRequestRedraw=this._register(new X).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(Ew),this._rowContainer.style.lineHeight=`normal`,this._rowContainer.setAttribute(`aria-hidden`,`true`),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement(`div`),this._selectionContainer.classList.add(Aw),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=vw(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=s.createInstance(bw,document),this._element.classList.add(Tw+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(Jb(()=>{this._element.classList.remove(Tw+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Sw(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let e of this._rowElements)e.style.width=`${this.dimensions.css.canvas.width}px`,e.style.height=`${this.dimensions.css.cell.height}px`,e.style.lineHeight=`${this.dimensions.css.cell.height}px`,e.style.overflow=`hidden`;this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Ew} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Ew} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Ew} .xterm-dim { color: ${sw.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Ew}.${kw} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Ew}.${kw} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Ew}.${kw} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Ew} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Ew} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Ew} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ew} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Ew} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Aw} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Aw} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Aw} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${Dw}${n} { color: ${r.css}; }${this._terminalSelector} .${Dw}${n}.xterm-dim { color: ${sw.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${Ow}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${Dw}257 { color: ${sw.opaque(e.background).css}; }${this._terminalSelector} .${Dw}257.xterm-dim { color: ${sw.multiplyOpacity(sw.opaque(e.background),.5).css}; }${this._terminalSelector} .${Ow}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get(`W`,!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let e=this._rowElements.length;e<=t;e++){let e=this._document.createElement(`div`);this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(kw),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(kw),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,s=this._document.createDocumentFragment();if(n){let n=e[0]>t[0];s.appendChild(this._createSelectionElement(a,n?t[0]:e[0],n?e[0]:t[0],o-a+1))}else{let n=r===a?e[0]:0,c=a===i?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(a,n,c));let l=o-a-1;if(s.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,l)),a!==o){let e=i===o?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(s)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement(`div`),a=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${a}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,s=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let e=c+n.ydisp,t=this._rowElements[c],l=n.lines.get(e);if(!t||!l)break;t.replaceChildren(...this._rowFactory.createRow(l,e,e===r,o,s,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Tw}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,a){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let s=this._bufferService.buffer,c=s.ybase+s.y,l=Math.min(s.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=n;o<=r;++o){let p=o+s.ydisp,m=this._rowElements[o],h=s.lines.get(p);if(!m||!h)break;m.replaceChildren(...this._rowFactory.createRow(h,p,p===c,d,f,l,u,this.dimensions.css.cell.width,this._widthCache,a?o===n?e:0:-1,a?(o===r?t:i)-1:-1))}}};Mw=Ty([J(7,nb),J(8,ub),J(9,ib),J(10,Qy),J(11,eb),J(12,db),J(13,gb)],Mw);var Nw=class extends Y{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new X),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Iw(this._optionsService))}catch{this._measureStrategy=this._register(new Fw(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange([`fontFamily`,`fontSize`],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Nw=Ty([J(2,ib)],Nw);var Pw=class extends Y{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},Fw=class extends Pw{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement(`span`),this._measureElement.classList.add(`xterm-char-measure-element`),this._measureElement.textContent=`W`.repeat(32),this._measureElement.setAttribute(`aria-hidden`,`true`),this._measureElement.style.whiteSpace=`pre`,this._measureElement.style.fontKerning=`none`,this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},Iw=class extends Pw{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext(`2d`);let t=this._ctx.measureText(`W`);if(!(`width`in t&&`fontBoundingBoxAscent`in t&&`fontBoundingBoxDescent`in t))throw Error(`Required font metrics not supported`)}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText(`W`);return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},Lw=class extends Y{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new Rw(this._window)),this._onDprChange=this._register(new X),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new X),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(sx.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Z(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(Z(this._textarea,`blur`,()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},Rw=class extends Y{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Zb),this._onDprChange=this._register(new X),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Jb(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Z(this._parentWindow,`resize`,()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},zw=class extends Y{constructor(){super(),this.linkProviders=[],this._register(Jb(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function Bw(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),a=parseInt(i.getPropertyValue(`padding-left`)),o=parseInt(i.getPropertyValue(`padding-top`));return[t.clientX-r.left-a,t.clientY-r.top-o]}function Vw(e,t,n,r,i,a,o,s,c){if(!a)return;let l=Bw(e,t,n);if(l)return l[0]=Math.ceil((l[0]+(c?o/2:0))/o),l[1]=Math.ceil(l[1]/s),l[0]=Math.min(Math.max(l[0],1),r+(c?1:0)),l[1]=Math.min(Math.max(l[1],1),i),l}var Hw=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return Vw(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let n=Bw(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};Hw=Ty([J(0,pb),J(1,ub)],Hw);var Uw=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t),!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Ww={};wy(Ww,{getSafariVersion:()=>Zw,isChromeOS:()=>rT,isFirefox:()=>Jw,isIpad:()=>$w,isIphone:()=>eT,isLegacyEdge:()=>Yw,isLinux:()=>nT,isMac:()=>Qw,isNode:()=>Gw,isSafari:()=>Xw,isWindows:()=>tT});var Gw=typeof process<`u`&&`title`in process,Kw=Gw?`node`:navigator.userAgent,qw=Gw?`node`:navigator.platform,Jw=Kw.includes(`Firefox`),Yw=Kw.includes(`Edge`),Xw=/^((?!chrome|android).)*safari/i.test(Kw);function Zw(){if(!Xw)return 0;let e=Kw.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Qw=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(qw),$w=qw===`iPad`,eT=qw===`iPhone`,tT=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(qw),nT=qw.indexOf(`Linux`)>=0,rT=/\bCrOS\b/.test(Kw),iT=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&=(this._cancelCallback(this._idleCallback),void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||=this._requestCallback(this._process.bind(this))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),i=e.timeRemaining(),n*1.5>i){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},aT=class extends iT{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},oT=class extends iT{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},sT=!Gw&&`requestIdleCallback`in window?oT:aT,cT=class{constructor(){this._queue=new sT}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},lT=class extends Y{constructor(e,t,n,r,i,a,o,s,c){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=i,this._coreBrowserService=s,this._renderer=this._register(new Zb),this._pausedResizeTask=new cT,this._observerDisposable=this._register(new Zb),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new X),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new X),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new X),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new X),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Uw((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new uT(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Jb(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange([`customGlyphs`,`drawBoldTextInBrightColors`,`letterSpacing`,`lineHeight`,`fontFamily`,`fontSize`,`fontWeight`,`fontWeightBold`,`minimumContrastRatio`,`rescaleOverlappingGlyphs`],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange([`cursorBlink`,`cursorStyle`],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if(`IntersectionObserver`in e){let n=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=Jb(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&=(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};lT=Ty([J(2,ib),J(3,ub),J(4,eb),J(5,sb),J(6,Qy),J(7,db),J(8,gb)],lT);var uT=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function dT(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return mT(i,a,e,t,n,r)+hT(a,t,n,r)+gT(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,CT(Math.abs(i-e),ST(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return CT(pT(a>t?e:i,n)+(s-1)*n.cols+1+fT(a>t?i:e,n),ST(o,r))}function fT(e,t){return e-1}function pT(e,t){return t.cols-e}function mT(e,t,n,r,i,a){return hT(t,r,i,a).length===0?``:CT(xT(e,t,e,t-vT(t,i),!1,i).length,ST(`D`,a))}function hT(e,t,n,r){let i=e-vT(e,n),a=t-vT(t,n);return CT(Math.abs(i-a)-_T(e,t,n),ST(bT(e,t),r))}function gT(e,t,n,r,i,a){let o;o=hT(t,r,i,a).length>0?r-vT(r,i):t;let s=r,c=yT(e,t,n,r,i,a);return CT(xT(e,o,n,s,c===`C`,i).length,ST(c,a))}function _T(e,t,n){let r=0,i=e-vT(e,n),a=t-vT(t,n);for(let o=0;o<Math.abs(i-a);o++){let a=bT(e,t)===`A`?-1:1;n.buffer.lines.get(i+a*o)?.isWrapped&&r++}return r}function vT(e,t){let n=0,r=t.buffer.lines.get(e),i=r?.isWrapped;for(;i&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),i=r?.isWrapped;return n}function yT(e,t,n,r,i,a){let o;return o=hT(n,r,i,a).length>0?r-vT(r,i):t,e<n&&o<=r||e>=n&&o<r?`C`:`D`}function bT(e,t){return e>t?`A`:`B`}function xT(e,t,n,r,i,a){let o=e,s=t,c=``;for(;(o!==n||s!==r)&&s>=0&&s<a.buffer.lines.length;)o+=i?1:-1,i&&o>a.cols-1?(c+=a.buffer.translateBufferLineToString(s,!1,e,o),o=0,e=0,s++):!i&&o<0&&(c+=a.buffer.translateBufferLineToString(s,!1,0,e+1),o=a.cols-1,e=o,s--);return c+a.buffer.translateBufferLineToString(s,!1,e,o)}function ST(e,t){let n=t?`O`:`[`;return Q.ESC+n+e}function CT(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}var wT=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function TT(e,t){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var ET=50,DT=15,OT=50,kT=500,AT=RegExp(`\xA0`,`g`),jT=class extends Y{constructor(e,t,n,r,i,a,o,s,c){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=a,this._optionsService=o,this._renderService=s,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Gy,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new X),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new X),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new X),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new X),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new wT(this._bufferService),this._activeSelectionMode=0,this._register(Jb(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return``;let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return``;let i=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let e=n.translateBufferLineToString(o,!0,i,a);r.push(e)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let i=e[1]+1;i<=t[1]-1;i++){let e=n.lines.get(i),t=n.translateBufferLineToString(i,!0);e?.isWrapped?r[r.length-1]+=t:r.push(t)}if(e[1]!==t[1]){let e=n.lines.get(t[1]),i=n.translateBufferLineToString(t[1],!0,0,t[0]);e&&e.isWrapped?r[r.length-1]+=i:r.push(i)}}return r.map(e=>e.replace(AT,` `)).join(tT?`\r
33
+ `:`
34
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),nT&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=TT(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Bw(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-ET),ET),t/=ET,t/Math.abs(t)+Math.round(t*(DT-1)))}shouldForceSelection(e){return Qw?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener(`mouseup`,this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),OT)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener(`mouseup`,this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(Qw&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&e.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<kT&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=dT(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c<o.length&&o.charAt(c+1)===` `;)c++}else{let t=e[0],n=e[0];a.getWidth(t)===0&&(u++,t--),a.getWidth(n)===2&&(d++,n++);let r=a.getString(n).length;for(r>1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(n+1,this._workCell));){a.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,n++):e>1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(!(!t&&o.slice(s,c).trim()===``)){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=TT(n,this._bufferService.cols)}};jT=Ty([J(3,Qy),J(4,eb),J(5,fb),J(6,ib),J(7,pb),J(8,db)],jT);var MT=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},NT=class{constructor(){this._color=new MT,this._css=new MT}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},PT=Object.freeze((()=>{let e=[cw.toColor(`#2e3436`),cw.toColor(`#cc0000`),cw.toColor(`#4e9a06`),cw.toColor(`#c4a000`),cw.toColor(`#3465a4`),cw.toColor(`#75507b`),cw.toColor(`#06989a`),cw.toColor(`#d3d7cf`),cw.toColor(`#555753`),cw.toColor(`#ef2929`),cw.toColor(`#8ae234`),cw.toColor(`#fce94f`),cw.toColor(`#729fcf`),cw.toColor(`#ad7fa8`),cw.toColor(`#34e2e2`),cw.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:ow.toCss(r,i,a),rgba:ow.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:ow.toCss(n,n,n),rgba:ow.toRgba(n,n,n)})}return e})()),FT=cw.toColor(`#ffffff`),IT=cw.toColor(`#000000`),LT=cw.toColor(`#ffffff`),RT=IT,zT={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},BT=FT,VT=class extends Y{constructor(e){super(),this._optionsService=e,this._contrastCache=new NT,this._halfContrastCache=new NT,this._onChangeColors=this._register(new X),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:FT,background:IT,cursor:LT,cursorAccent:RT,selectionForeground:void 0,selectionBackgroundTransparent:zT,selectionBackgroundOpaque:sw.blend(IT,zT),selectionInactiveBackgroundTransparent:zT,selectionInactiveBackgroundOpaque:sw.blend(IT,zT),scrollbarSliderBackground:sw.opacity(FT,.2),scrollbarSliderHoverBackground:sw.opacity(FT,.4),scrollbarSliderActiveBackground:sw.opacity(FT,.5),overviewRulerBorder:FT,ansi:PT.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange(`minimumContrastRatio`,()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange(`theme`,()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=HT(e.foreground,FT),t.background=HT(e.background,IT),t.cursor=sw.blend(t.background,HT(e.cursor,LT)),t.cursorAccent=sw.blend(t.background,HT(e.cursorAccent,RT)),t.selectionBackgroundTransparent=HT(e.selectionBackground,zT),t.selectionBackgroundOpaque=sw.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=HT(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=sw.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?HT(e.selectionForeground,aw):void 0,t.selectionForeground===aw&&(t.selectionForeground=void 0),sw.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=sw.opacity(t.selectionBackgroundTransparent,.3)),sw.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=sw.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=HT(e.scrollbarSliderBackground,sw.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=HT(e.scrollbarSliderHoverBackground,sw.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=HT(e.scrollbarSliderActiveBackground,sw.opacity(t.foreground,.5)),t.overviewRulerBorder=HT(e.overviewRulerBorder,BT),t.ansi=PT.slice(),t.ansi[0]=HT(e.black,PT[0]),t.ansi[1]=HT(e.red,PT[1]),t.ansi[2]=HT(e.green,PT[2]),t.ansi[3]=HT(e.yellow,PT[3]),t.ansi[4]=HT(e.blue,PT[4]),t.ansi[5]=HT(e.magenta,PT[5]),t.ansi[6]=HT(e.cyan,PT[6]),t.ansi[7]=HT(e.white,PT[7]),t.ansi[8]=HT(e.brightBlack,PT[8]),t.ansi[9]=HT(e.brightRed,PT[9]),t.ansi[10]=HT(e.brightGreen,PT[10]),t.ansi[11]=HT(e.brightYellow,PT[11]),t.ansi[12]=HT(e.brightBlue,PT[12]),t.ansi[13]=HT(e.brightMagenta,PT[13]),t.ansi[14]=HT(e.brightCyan,PT[14]),t.ansi[15]=HT(e.brightWhite,PT[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=HT(e.extendedAnsi[r],PT[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};VT=Ty([J(0,ib)],VT);function HT(e,t){if(e!==void 0)try{return cw.toColor(e)}catch{}return t}var UT=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},WT=class{constructor(){this._services=new UT,this._services.set(nb,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=Yy(e).sort((e,t)=>e.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},GT={trace:0,debug:1,info:2,warn:3,error:4,off:5},KT=`xterm.js: `,qT=class extends Y{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),JT=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=GT[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:KT)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};qT=Ty([J(0,ib)],qT);var JT,YT=class extends Y{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new X),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new X),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new X),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error(`Can only recycle when the buffer is full`);return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<n.length;t++)this._array[this._getCyclicIndex(e+t)]=n[t];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},XT=3,ZT=Object.freeze(new Uy),QT=0,$T=2,eE=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*XT);let r=t||Gy.fromCharData([0,Vy,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*XT+0],n=t&2097151;return[this._data[e*XT+1],t&2097152?this._combined[e]:n?Ly(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*XT+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*XT+0]=e|2097152|t[2]<<22):this._data[e*XT+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*XT+0]>>22}hasWidth(e){return this._data[e*XT+0]&12582912}getFg(e){return this._data[e*XT+1]}getBg(e){return this._data[e*XT+2]}hasContent(e){return this._data[e*XT+0]&4194303}getCodePoint(e){let t=this._data[e*XT+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*XT+0]&2097152}getString(e){let t=this._data[e*XT+0];return t&2097152?this._combined[e]:t&2097151?Ly(t&2097151):``}isProtected(e){return this._data[e*XT+2]&536870912}loadCell(e,t){return QT=e*XT,t.content=this._data[QT+0],t.fg=this._data[QT+1],t.bg=this._data[QT+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*XT+0]=t.content,this._data[e*XT+1]=t.fg,this._data[e*XT+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*XT+0]=t|n<<22,this._data[e*XT+1]=r.fg,this._data[e*XT+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*XT+0];r&2097152?this._combined[e]+=Ly(t):r&2097151?(this._combined[e]=Ly(r&2097151)+Ly(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*XT+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new Gy;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;r<t;++r)this.setCell(e+r,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,t,n){if(e%=this.length,t<this.length-e){let r=new Gy;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let e=this.length-t;e<this.length;++e)this.setCell(e,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,t,n,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.setCell(e++,n)}resize(e,t){if(e===this.length)return this._data.length*4*$T<this._data.buffer.byteLength;let n=e*XT;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n<e;++n)this.setCell(n,t)}else{this._data=this._data.subarray(0,n);let t=Object.keys(this._combined);for(let n=0;n<t.length;n++){let r=parseInt(t[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t<r.length;t++){let n=parseInt(r[t],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*$T<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*$T<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t){for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);return}this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}copyFrom(e){this.length===e.length?this._data.set(e._data):this._data=new Uint32Array(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let t=new e(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*XT+0]&4194303)return e+(this._data[e*XT+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*XT+0]&4194303||this._data[e*XT+2]&50331648)return e+(this._data[e*XT+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e<XT;e++)this._data[(n+i)*XT+e]=a[(t+i)*XT+e];a[(t+i)*XT+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<XT;e++)this._data[(n+i)*XT+e]=a[(t+i)*XT+e];a[(t+i)*XT+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}let o=Object.keys(e._combined);for(let r=0;r<o.length;r++){let i=parseInt(o[r],10);i>=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t<n;){let e=this._data[t*XT+0],n=e&2097151,a=e&2097152?this._combined[t]:n?Ly(n):Hy;if(i+=a,r)for(let e=0;e<a.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}};function tE(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length-1;s++){let c=s,l=e.get(++c);if(!l.isWrapped)continue;let u=[e.get(s)];for(;c<e.length&&l.isWrapped;)u.push(l),l=e.get(++c);if(!a&&r>=s&&r<c){s+=u.length-1;continue}let d=0,f=aE(u,d,t),p=1,m=0;for(;p<u.length;){let e=aE(u,p,t),r=e-m,a=n-f,o=Math.min(r,a);u[d].copyCellsFrom(u[p],m,f,o,!1),f+=o,f===n&&(d++,f=0),m+=o,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(n-1)===2&&(u[d].copyCellsFrom(u[d-1],n-1,f++,1,!1),u[d-1].setCell(n-1,i))}u[d].replaceCells(f,n,i);let h=0;for(let e=u.length-1;e>0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function nE(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o<e.length;o++)if(i===o){let n=t[++r];e.onDeleteEmitter.fire({index:o-a,amount:n}),o+=n-1,a+=n,i=t[++r]}else n.push(o);return{layout:n,countRemoved:a}}function rE(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let t=0;t<n.length;t++)e.set(t,n[t]);e.length=t.length}function iE(e,t,n){let r=[],i=e.map((n,r)=>aE(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;s<i;){if(i-s<n){r.push(i-s);break}a+=n;let c=aE(e,o,t);a>c&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function aE(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var oE=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new X),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Kb(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};oE._nextId=1;var sE=oE,cE={},lE=cE.B;cE[0]={"`":`◆`,a:`▒`,b:`␉`,c:`␌`,d:`␍`,e:`␊`,f:`°`,g:`±`,h:`␤`,i:`␋`,j:`┘`,k:`┐`,l:`┌`,m:`└`,n:`┼`,o:`⎺`,p:`⎻`,q:`─`,r:`⎼`,s:`⎽`,t:`├`,u:`┤`,v:`┴`,w:`┬`,x:`│`,y:`≤`,z:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},cE.A={"#":`£`},cE.B=void 0,cE[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},cE.C=cE[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},cE.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},cE.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},cE.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},cE.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},cE.E=cE[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},cE.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},cE.H=cE[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},cE[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var uE=4294967295,dE=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=ZT.clone(),this.savedCharset=lE,this.markers=[],this._nullCell=Gy.fromCharData([0,Vy,1,0]),this._whitespaceCell=Gy.fromCharData([0,Hy,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new sT,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new YT(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Wy),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Wy),this._whitespaceCell}getBlankLine(e,t){return new eE(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>uE?uE:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=ZT);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new YT(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(ZT),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);let a=0;if(this._rows<t)for(let r=this._rows;r<t;r++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new eE(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new eE(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=tE(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(ZT),n);if(r.length>0){let n=nE(this.lines,r);rE(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(ZT),i=n;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new eE(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(ZT),i=[],a=0;for(let o=this.lines.length-1;o>=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e<o+c.length)continue}let l=c[c.length-1].getTrimmedLength(),u=iE(c,this._cols,e),d=u.length-c.length,f;f=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+d):Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let e=0;e<d;e++){let e=this.getBlankLine(ZT,!0);p.push(e)}p.length>0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=aE(c,Math.max(g,0),this._cols))}for(let t=0;t<c.length;t++)u[t]<e&&c[t].setCell(u[t],r);let v=d-f;for(;v-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(i.length>0){let e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));let n=this.lines.length,r=n-1,o=0,s=i[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+a-1);l>=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e==null?(this.tabs={},e=0):this.tabs[e]||(e=this.prevStop(e));e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new sE(e);return this.markers.push(t),t.register(this.lines.onTrim(e=>{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},fE=class extends Y{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new X),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange(`scrollback`,()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange(`tabStopWidth`,()=>this.setupTabStops()))}reset(){this._normal=new dE(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new dE(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},pE=2,mE=1,hE=class extends Y{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new X),this.onResize=this._onResize.event,this._onScroll=this._register(new X),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,pE),this.rows=Math.max(e.rawOptions.rows||0,mE),this.buffers=this._register(new fE(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};hE=Ty([J(0,ib)],hE);var gE={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:Qw,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},_E=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],vE=class extends Y{constructor(e){super(),this._onOptionChange=this._register(new X),this.onOptionChange=this._onOptionChange.event;let t={...gE};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Jb(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in gE))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in gE))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=gE[e],!yE(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=gE[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=_E.includes(t)?t:gE[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw Error(`${e} cannot be less than 1, value: ${t}`);break;case`minimumContrastRatio`:t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case`scrollback`:if(t=Math.min(t,4294967295),t<0)throw Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={};break}return t}};function yE(e){return e===`block`||e===`underline`||e===`bar`}function bE(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&bE(e[r],t-1);return n}var xE=Object.freeze({insertMode:!1}),SE=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),CE=class extends Y{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new X),this.onData=this._onData.event,this._onUserInput=this._register(new X),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new X),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new X),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=bE(xE),this.decPrivateModes=bE(SE)}reset(){this.modes=bE(xE),this.decPrivateModes=bE(SE)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace(`sending binary (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};CE=Ty([J(0,Qy),J(1,rb),J(2,ib)],CE);var wE={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function TE(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var EE=String.fromCharCode,DE={DEFAULT:e=>{let t=[TE(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${EE(t[0])}${EE(t[1])}${EE(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${TE(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${TE(e,!0)};${e.x};${e.y}${t}`}},OE=class extends Y{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new X),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(wE))this.addProtocol(e,wE[e]);for(let e of Object.keys(DE))this.addEncoding(e,DE[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};OE=Ty([J(0,Qy),J(1,eb),J(2,ib)],OE);var kE=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],AE=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],jE;function ME(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var NE=class{constructor(){if(this.version=`6`,!jE){jE=new Uint8Array(65536),jE.fill(1),jE[0]=0,jE.fill(0,1,32),jE.fill(0,127,160),jE.fill(2,4352,4448),jE[9001]=2,jE[9002]=2,jE.fill(2,11904,42192),jE[12351]=1,jE.fill(2,44032,55204),jE.fill(2,63744,64256),jE.fill(2,65040,65050),jE.fill(2,65072,65136),jE.fill(2,65280,65377),jE.fill(2,65504,65511);for(let e=0;e<kE.length;++e)jE.fill(0,kE[e][0],kE[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?jE[e]:ME(e,AE)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=PE.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return PE.createPropertyValue(0,n,r)}},PE=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new X,this.onChange=this._onChange.event;let e=new NE;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!=0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|(n?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a<i;++a){let o=t.charCodeAt(a);if(55296<=o&&o<=56319){if(++a>=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},FE=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function IE(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var LE=2147483647,RE=256,zE=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>RE)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=Array.isArray(t[0])?1:0;e<t.length;++e){let r=t[e];if(Array.isArray(r))for(let e=0;e<r.length;++e)n.addSubParam(r[e]);else n.addParam(r)}return n}clone(){let t=new e(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>LE?LE:e}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>LE?LE:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,LE):e}},BE=[],VE=class{constructor(){this._state=0,this._active=BE,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=BE}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=BE,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||BE,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,Ry(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=BE,this._id=-1,this._state=0}}},HE=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Ry(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},UE=[],WE=class{constructor(){this._handlers=Object.create(null),this._active=UE,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=UE}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=UE,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||UE,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,Ry(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=UE,this._ident=0}},GE=new zE;GE.addParam(0);var KE=class{constructor(e){this._handler=e,this._data=``,this._params=GE,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():GE,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Ry(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=GE,this._data=``,this._hitLimit=!1,e));return this._params=GE,this._data=``,this._hitLimit=!1,t}},qE=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}},JE=160,YE=function(){let e=new qE(4095),t=Array.apply(null,Array(256)).map((e,t)=>t),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(JE,0,2,0),e.add(JE,8,5,8),e.add(JE,6,0,6),e.add(JE,11,0,11),e.add(JE,13,13,13),e}(),XE=class extends Y{constructor(e=YE){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new zE,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(Jb(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new VE),this._dcsParser=this._register(new WE),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let n=a;n<t;++n){switch(r=e[n],i=this._transitions.table[this.currentState<<8|(r<160?r:JE)],i>>4){case 2:for(let i=n+1;;++i){if(i>=t||(r=e[i])<32||r>126&&r<JE){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<JE){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<JE){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<JE){this._printHandler(e,n,i),n=i-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|r],s=a?a.length-1:-1;for(;s>=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n<t&&(r=e[n])>47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r<JE){this._dcsParser.put(e,n,i),n=i-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let i=n+1;;i++)if(i>=t||(r=e[i])<32||r>127&&r<JE){this._oscParser.put(e,n,i),n=i-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=i&15}}},ZE=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,QE=/^[\da-f]+$/;function $E(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=ZE.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),QE.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}}function eD(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function tD(e,t=16){let[n,r,i]=e;return`rgb:${eD(n,t)}/${eD(r,t)}/${eD(i,t)}`}var nD={"(":0,")":1,"*":2,"+":3,"-":1,".":2},rD=131072,iD=10;function aD(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var oD=5e3,sD=0,cD=class extends Y{constructor(e,t,n,r,i,a,o,s,c=new XE){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new zy,this._utf8Decoder=new By,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=ZT.clone(),this._eraseAttrDataInternal=ZT.clone(),this._onRequestBell=this._register(new X),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new X),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new X),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new X),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new X),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new X),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new X),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new X),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new X),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new X),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new X),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new X),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new X),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new lD(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler(Q.BEL,()=>this.bell()),this._parser.setExecuteHandler(Q.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(Q.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(Q.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(Q.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(Q.BS,()=>this.backspace()),this._parser.setExecuteHandler(Q.HT,()=>this.tab()),this._parser.setExecuteHandler(Q.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(Q.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(QC.IND,()=>this.index()),this._parser.setExecuteHandler(QC.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(QC.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new HE(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new HE(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new HE(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new HE(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new HE(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new HE(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new HE(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new HE(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new HE(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new HE(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new HE(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new HE(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:`7`},()=>this.saveCursor()),this._parser.registerEscHandler({final:`8`},()=>this.restoreCursor()),this._parser.registerEscHandler({final:`D`},()=>this.index()),this._parser.registerEscHandler({final:`E`},()=>this.nextLine()),this._parser.registerEscHandler({final:`H`},()=>this.tabSet()),this._parser.registerEscHandler({final:`M`},()=>this.reverseIndex()),this._parser.registerEscHandler({final:`=`},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:`>`},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:`c`},()=>this.fullReset()),this._parser.registerEscHandler({final:`n`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`o`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`|`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`}`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`~`},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:`%`,final:`@`},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:`%`,final:`G`},()=>this.selectDefaultCharset());for(let e in cE)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new KE((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),oD))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${oD} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>rD&&(a=this._parseStack.position+rD)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<rD&&(this._parseBuffer=new Uint32Array(Math.min(e.length,rD))),o||this._dirtyRowTracker.clearRange(),e.length>rD)for(let t=a;t<e.length;t+=rD){let a=t+rD<e.length?t+rD:e.length,o=typeof e==`string`?this._stringDecoder.decode(e.substring(t,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,a),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,o))return this._preserveStack(r,i,o,t),this._logSlowResolvingAsync(n),n}else if(!o){let t=typeof e==`string`?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,t))return this._preserveStack(r,i,t,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(s,this._bufferService.rows-1)})}print(e,t,n){let r,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;p<n;++p){if(r=e[p],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,f);i=PE.extractWidth(t);let n=PE.extractShouldJoin(t),m=n?PE.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(Ly(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-m>s){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof eE&&d.copyCellsFrom(e,t,0,m,!1);t<s;)e.setCellFromCodepoint(t++,0,1,u)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-m;--e>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<s&&n-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>aD(e.params[0],this._optionsService.rawOptions.windowOptions)?t(e):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new KE(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new HE(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(ZT));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=PE.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*n),s=0;for(let e=0;e<a.length;){let t=a.codePointAt(e)||0;o[s++]=t,e+=t>65535?2:1}let c=s;for(let e=1;e<n;++e)o.copyWithin(c,0,s),c+=s;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent(Q.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent(Q.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent(Q.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent(Q.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent(Q.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,lE),this._charsetService.setgCharset(1,lE),this._charsetService.setgCharset(2,lE),this._charsetService.setgCharset(3,lE);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol=`X10`;break;case 1e3:this._coreMouseService.activeProtocol=`VT200`;break;case 1002:this._coreMouseService.activeProtocol=`DRAG`;break;case 1003:this._coreMouseService.activeProtocol=`ANY`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug(`DECSET 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`SGR`;break;case 1015:this._logService.debug(`DECSET 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`SGR_PIXELS`;break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol=`NONE`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug(`DECRST 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 1015:this._logService.debug(`DECRST 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){let n;(e=>(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${Q.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:c===132?1:0:0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=Uy.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o<n.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let e=2;e<r.length;++e)r[e]===-1&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=ZT.fg,e.bg=ZT.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i<t;i++)n=e.params[i],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=ZT.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=ZT.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=ZT.fg&16777215,r.bg&=-67108864,r.bg|=ZT.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${Q.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Q.ESC}[${e};${t}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Q.ESC}[?${e};${t}R`);break;case 15:break;case 25:break;case 26:break;case 53:break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=ZT.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle=`block`;break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle=`underline`;break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle=`bar`;break}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!aD(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${Q.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>iD&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>iD&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(uD(n))if(r===`?`)t.push({type:0,index:n});else{let e=$E(r);e&&t.push({type:1,index:n,color:e})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e<n.length&&!(t>=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=$E(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);uD(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,lE),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(nD[e[0]],cE[e[1]]||lE),!0):(this.selectDefaultCharset(),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=ZT.clone(),this._eraseAttrDataInternal=ZT.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Gy;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=e=>(this._coreService.triggerDataEvent(`${Q.ESC}${e}${Q.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-(i.cursorBlink?1:0)} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},lD=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(sD=e,e=t,t=sD),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};lD=Ty([J(0,Qy)],lD);function uD(e){return 0<=e&&e<256}var dD=5e7,fD=12,pD=50,mD=class extends Y{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new X),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>dD)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=fD?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=fD)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>pD&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},hD=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};hD=Ty([J(0,Qy)],hD);var gD=!1,_D=class extends Y{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Zb),this._onBinary=this._register(new X),this.onBinary=this._onBinary.event,this._onData=this._register(new X),this.onData=this._onData.event,this._onLineFeed=this._register(new X),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new X),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new X),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new X),this._instantiationService=new WT,this.optionsService=this._register(new vE(e)),this._instantiationService.setService(ib,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(hE)),this._instantiationService.setService(Qy,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(qT)),this._instantiationService.setService(rb,this._logService),this.coreService=this._register(this._instantiationService.createInstance(CE)),this._instantiationService.setService(eb,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(OE)),this._instantiationService.setService($y,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(PE)),this._instantiationService.setService(ob,this.unicodeService),this._charsetService=this._instantiationService.createInstance(FE),this._instantiationService.setService(tb,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(hD),this._instantiationService.setService(ab,this._oscLinkService),this._inputHandler=this._register(new cD(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(sx.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(sx.forward(this._bufferService.onResize,this._onResize)),this._register(sx.forward(this.coreService.onData,this._onData)),this._register(sx.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new mD((e,t)=>this._inputHandler.parse(e,t))),this._register(sx.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new X),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!gD&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),gD=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,pE),t=Math.max(t,mE),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(IE.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(IE(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Jb(()=>{for(let t of e)t.dispose()})}}},vD={48:[`0`,`)`],49:[`1`,`!`],50:[`2`,`@`],51:[`3`,`#`],52:[`4`,`$`],53:[`5`,`%`],54:[`6`,`^`],55:[`7`,`&`],56:[`8`,`*`],57:[`9`,`(`],186:[`;`,`:`],187:[`=`,`+`],188:[`,`,`<`],189:[`-`,`_`],190:[`.`,`>`],191:[`/`,`?`],192:["`",`~`],219:[`[`,`{`],220:[`\\`,`|`],221:[`]`,`}`],222:[`'`,`"`]};function yD(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?t?i.key=Q.ESC+`OA`:i.key=Q.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?t?i.key=Q.ESC+`OD`:i.key=Q.ESC+`[D`:e.key===`UIKeyInputRightArrow`?t?i.key=Q.ESC+`OC`:i.key=Q.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(t?i.key=Q.ESC+`OB`:i.key=Q.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:Q.DEL,e.altKey&&(i.key=Q.ESC+i.key);break;case 9:if(e.shiftKey){i.key=Q.ESC+`[Z`;break}i.key=Q.HT,i.cancel=!0;break;case 13:i.key=e.altKey?Q.ESC+Q.CR:Q.CR,i.cancel=!0;break;case 27:i.key=Q.ESC,e.altKey&&(i.key=Q.ESC+Q.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;a?i.key=Q.ESC+`[1;`+(a+1)+`D`:t?i.key=Q.ESC+`OD`:i.key=Q.ESC+`[D`;break;case 39:if(e.metaKey)break;a?i.key=Q.ESC+`[1;`+(a+1)+`C`:t?i.key=Q.ESC+`OC`:i.key=Q.ESC+`[C`;break;case 38:if(e.metaKey)break;a?i.key=Q.ESC+`[1;`+(a+1)+`A`:t?i.key=Q.ESC+`OA`:i.key=Q.ESC+`[A`;break;case 40:if(e.metaKey)break;a?i.key=Q.ESC+`[1;`+(a+1)+`B`:t?i.key=Q.ESC+`OB`:i.key=Q.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=Q.ESC+`[2~`);break;case 46:a?i.key=Q.ESC+`[3;`+(a+1)+`~`:i.key=Q.ESC+`[3~`;break;case 36:a?i.key=Q.ESC+`[1;`+(a+1)+`H`:t?i.key=Q.ESC+`OH`:i.key=Q.ESC+`[H`;break;case 35:a?i.key=Q.ESC+`[1;`+(a+1)+`F`:t?i.key=Q.ESC+`OF`:i.key=Q.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=Q.ESC+`[5;`+(a+1)+`~`:i.key=Q.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=Q.ESC+`[6;`+(a+1)+`~`:i.key=Q.ESC+`[6~`;break;case 112:a?i.key=Q.ESC+`[1;`+(a+1)+`P`:i.key=Q.ESC+`OP`;break;case 113:a?i.key=Q.ESC+`[1;`+(a+1)+`Q`:i.key=Q.ESC+`OQ`;break;case 114:a?i.key=Q.ESC+`[1;`+(a+1)+`R`:i.key=Q.ESC+`OR`;break;case 115:a?i.key=Q.ESC+`[1;`+(a+1)+`S`:i.key=Q.ESC+`OS`;break;case 116:a?i.key=Q.ESC+`[15;`+(a+1)+`~`:i.key=Q.ESC+`[15~`;break;case 117:a?i.key=Q.ESC+`[17;`+(a+1)+`~`:i.key=Q.ESC+`[17~`;break;case 118:a?i.key=Q.ESC+`[18;`+(a+1)+`~`:i.key=Q.ESC+`[18~`;break;case 119:a?i.key=Q.ESC+`[19;`+(a+1)+`~`:i.key=Q.ESC+`[19~`;break;case 120:a?i.key=Q.ESC+`[20;`+(a+1)+`~`:i.key=Q.ESC+`[20~`;break;case 121:a?i.key=Q.ESC+`[21;`+(a+1)+`~`:i.key=Q.ESC+`[21~`;break;case 122:a?i.key=Q.ESC+`[23;`+(a+1)+`~`:i.key=Q.ESC+`[23~`;break;case 123:a?i.key=Q.ESC+`[24;`+(a+1)+`~`:i.key=Q.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=Q.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=Q.DEL:e.keyCode===219?i.key=Q.ESC:e.keyCode===220?i.key=Q.FS:e.keyCode===221&&(i.key=Q.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=vD[e.keyCode]?.[e.shiftKey?1:0];if(t)i.key=Q.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=Q.ESC+n}else if(e.keyCode===32)i.key=Q.ESC+(e.ctrlKey?Q.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=Q.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=Q.US),e.key===`@`&&(i.key=Q.NUL));break}return i}var bD=0,xD=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new sT,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new sT,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i<r.length;i++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(bD=this._search(t),bD===-1)||this._getKey(this._array[bD])!==t)return!1;do if(this._array[bD]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(bD),!0;while(++bD<this._array.length&&this._getKey(this._array[bD])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,t)=>e-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(bD=this._search(e),!(bD<0||bD>=this._array.length)&&this._getKey(this._array[bD])===e))do yield this._array[bD];while(++bD<this._array.length&&this._getKey(this._array[bD])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(bD=this._search(e),!(bD<0||bD>=this._array.length)&&this._getKey(this._array[bD])===e))do t(this._array[bD]);while(++bD<this._array.length&&this._getKey(this._array[bD])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},SD=0,CD=0,wD=class extends Y{constructor(){super(),this._decorations=new xD(e=>e?.marker.line),this._onDecorationRegistered=this._register(new X),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new X),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Jb(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new TD(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,t=>{SD=t.options.x??0,CD=SD+(t.options.width??1),e>=SD&&e<CD&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},TD=class extends Xb{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new X),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new X),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position=`full`)}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=cw.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=cw.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},ED=1e3,DD=class{constructor(e,t=ED){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t);let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},OD=20,kD=!1,AD=class extends Y{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new DD(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);kD?(this._accessibilityContainer.classList.add(`debug`),this._rowContainer.classList.add(`debug`),this._debugRootContainer=i.createElement(`div`),this._debugRootContainer.classList.add(`xterm`),this._debugRootContainer.appendChild(i.createTextNode(`------start a11y------`)),this._debugRootContainer.appendChild(this._accessibilityContainer),this._debugRootContainer.appendChild(i.createTextNode(`------end a11y------`)),this._terminal.element.insertAdjacentElement(`afterend`,this._debugRootContainer)):this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
35
+ `))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Z(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Jb(()=>{kD?this._debugRootContainer.remove():this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<OD+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
36
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===OD+1&&(this._liveRegion.textContent+=ky.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(!(!a||!o)){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};AD=Ty([J(1,nb),J(2,db),J(3,pb)],AD);var jD=class extends Y{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new X),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new X),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Jb(()=>{Kb(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Z(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Z(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(Z(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(Z(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&MD(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Kb(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};jD=Ty([J(1,fb),J(2,pb),J(3,Qy),J(4,_b)],jD);function MD(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var ND=class extends _D{constructor(e={}){super(e),this._linkifier=this._register(new Zb),this.browser=Ww,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Zb),this._onCursorMove=this._register(new X),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new X),this.onKey=this._onKey.event,this._onRender=this._register(new X),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new X),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new X),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new X),this.onBell=this._onBell.event,this._onFocus=this._register(new X),this._onBlur=this._register(new X),this._onA11yCharEmitter=this._register(new X),this._onA11yTabEmitter=this._register(new X),this._onWillOpen=this._register(new X),this._setup(),this._decorationService=this._instantiationService.createInstance(wD),this._instantiationService.setService(sb,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(zw),this._instantiationService.setService(_b,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(cb)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(sx.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(sx.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(sx.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(sx.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(Jb(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=sw.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${Q.ESC}]${n};${tD(r)}${$C.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=ow.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=ow.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(AD,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Q.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Q.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(Z(this.element,`copy`,e=>{this.hasSelection()&&My(e,this._selectionService)}));let e=e=>Ny(e,this.textarea,this.coreService,this.optionsService);this._register(Z(this.textarea,`paste`,e)),this._register(Z(this.element,`paste`,e)),Jw?this._register(Z(this.element,`mousedown`,e=>{e.button===2&&Iy(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Z(this.element,`contextmenu`,e=>{Iy(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),nT&&this._register(Z(this.element,`auxclick`,e=>{e.button===1&&Fy(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Z(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(Z(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(Z(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(Z(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(Z(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(Z(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(Z(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(Z(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,Dy.get()),rT||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Lw,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(db,this._coreBrowserService),this._register(Z(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(Z(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Nw,this._document,this._helperContainer),this._instantiationService.setService(ub,this._charSizeService),this._themeService=this._instantiationService.createInstance(VT),this._instantiationService.setService(gb,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(mw),this._instantiationService.setService(hb,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(lT,this.rows,this.screenElement)),this._instantiationService.setService(pb,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(ew,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Hw),this._instantiationService.setService(fb,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(jD,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(GC,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(jT,this.element,this.screenElement,r)),this._instantiationService.setService(mb,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(sx.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(KC,this.screenElement)),this._register(Z(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(AD,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ZC,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ZC,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Mw,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Z(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(Z(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=Q.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){Py(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key===`Dead`||e.key===`AltGraph`)&&(this._unprocessedDeadKey=!0);let n=yD(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===Q.ETX||n.key===Q.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(PD(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(ZT));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent(Q.ESC+`[I`):this.coreService.triggerDataEvent(Q.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Q.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Q.ESC}[6;${r};${n}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function PD(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var FD=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},ID=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Gy)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},LD=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new ID(t)}getNullCell(){return new Gy}},RD=class extends Y{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new X),this.onBufferChange=this._onBufferChange.event,this._normal=new LD(this._core.buffers.normal,`normal`),this._alternate=new LD(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},zD=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},BD=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},VD=[`cols`,`rows`],HD=0,UD=class extends Y{constructor(e){super(),this._core=this._register(new ND(e)),this._addonManager=this._register(new FD),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(VD.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new zD(this._core),this._parser}get unicode(){return this._checkProposedApi(),new BD(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new RD(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`;break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
37
+ `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Dy.get()},set promptLabel(e){Dy.set(e)},get tooMuchOutput(){return ky.get()},set tooMuchOutput(e){ky.set(e)}}}_verifyIntegers(...e){for(HD of e)if(HD===1/0||isNaN(HD)||HD%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(HD of e)if(HD&&(HD===1/0||isNaN(HD)||HD%1!=0||HD<0))throw Error(`This API only accepts positive integers`)}},WD=2,GD=1,KD=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(WD,Math.floor(u/e.css.cell.width)),rows:Math.max(GD,Math.floor(l/e.css.cell.height))}}},qD={class:`flex flex-col h-full`},JD={class:`flex items-stretch border-b border-border overflow-x-auto`},YD=[`onClick`],XD=[`onClick`],ZD={class:`truncate`},QD={key:0,class:`shrink-0 flex items-center gap-1 px-2 py-1.5 border-b border-border bg-surface overflow-x-auto select-none [scrollbar-width:none] [-webkit-overflow-scrolling:touch]`},$D=[`onMousedown`,`onTouchstart`],eO={key:1,class:`px-3 py-1 text-[11px] text-danger bg-danger-dim`},tO={key:`terminal`,label:`Terminal`,icon:`pixelarticons:terminal`,color:`#c5cdd8`,component:z({__name:`window`,setup(e){let t=new Set,{state:n,set:r,setTitle:i,close:a}=$l(),{confirm:o}=ou(),s=It([]),c=F(null),l=F(null),u=F(``),d=null,f=0,p=hu(),m=F(!1),h=F(!1),g=0;function _(){let e=Date.now();e-g<300?(g=0,T(` `,!0)):g=e}R(()=>s.find(e=>e.id===c.value)?.label,e=>{i(e?`Terminal — ${e}`:`Terminal`)});let v={background:`#0a0e14`,foreground:`#c5cdd8`,cursor:`#39bae6`,cursorAccent:`#0a0e14`,selectionBackground:`#112a3a`,black:`#0a0e14`,red:`#e6564d`,green:`#7fd962`,yellow:`#e5a535`,blue:`#39bae6`,magenta:`#c586c0`,cyan:`#39bae6`,white:`#c5cdd8`,brightBlack:`#5c6773`,brightRed:`#e6564d`,brightGreen:`#7fd962`,brightYellow:`#e5a535`,brightBlue:`#39bae6`,brightMagenta:`#c586c0`,brightCyan:`#39bae6`,brightWhite:`#ffffff`},y={background:`#ffffff`,foreground:`#1d1d1f`,cursor:`#0077cc`,cursorAccent:`#ffffff`,selectionBackground:`#ddf4ff`,black:`#1d1d1f`,red:`#d1242f`,green:`#2da44e`,yellow:`#bf8700`,blue:`#0077cc`,magenta:`#8250df`,cyan:`#0077cc`,white:`#f5f5f7`,brightBlack:`#86868b`,brightRed:`#d1242f`,brightGreen:`#2da44e`,brightYellow:`#bf8700`,brightBlue:`#0077cc`,brightMagenta:`#8250df`,brightCyan:`#0077cc`,brightWhite:`#ffffff`},{effective:b}=Sp();function x(){return b.value===`light`?y:v}let S={fontFamily:`'JetBrains Mono', 'Fira Code', monospace`,fontSize:13,lineHeight:1.2,theme:x(),cursorBlink:!0,cursorStyle:`bar`,allowProposedApi:!0};R(b,()=>{let e=x();for(let t of s)t.terminal.options.theme=e});function C(){return s.find(e=>e.id===c.value)}function w(e,n){if(t.has(e))return;t.add(e);let r=document.createElement(`div`);r.style.cssText=`width:100%;height:100%;display:none;overflow:hidden`;let i=new UD(S),a=new KD;i.loadAddon(a),l.value?.appendChild(r),i.open(r);let o=String(++f),c=It({id:o,sessionId:e,label:n,connected:!1,terminal:i,fitAddon:a,eventSource:null,containerEl:r});i.onTitleChange(e=>{let t=e.split(`/`).pop()||e;c.label=t,fetch(`/api/terminal/${c.sessionId}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({label:t})})}),i.onData(e=>{let t=e;if(m.value&&e.length===1){let n=e.toUpperCase().charCodeAt(0)-64;n>=0&&n<=31&&(t=String.fromCharCode(n)),m.value=!1}else h.value&&e.length===1&&(t=`\x1B`+e,h.value=!1);fetch(`/api/terminal/${c.sessionId}/input`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({data:t})})});let u=new EventSource(`/api/terminal/${e}/stream`);u.onmessage=e=>{let t=Uint8Array.from(atob(e.data),e=>e.charCodeAt(0));c.terminal.write(t)},u.onopen=()=>{c.connected=!0,Tn(()=>te(c))},u.onerror=()=>{u.close(),c.connected=!1,re(o)},c.eventSource=u,s.push(c),ne(o)}function T(e,t){let n=C();if(!n)return;let r=e;if(!t)if(m.value&&e.length===1){let t=e.toUpperCase().charCodeAt(0)-64;t>=0&&t<=31&&(r=String.fromCharCode(t)),m.value=!1,h.value=!1}else h.value&&e.length===1&&(r=`\x1B`+e,h.value=!1,m.value=!1);fetch(`/api/terminal/${n.sessionId}/input`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({data:r})})}let ee=[{label:`ctrl`,toggle:m},{label:`alt`,toggle:h},{label:`tab`,seq:` `,raw:!0},{label:`esc`,seq:`\x1B`,raw:!0},{label:`←`,seq:`\x1B[D`,raw:!0},{label:`↑`,seq:`\x1B[A`,raw:!0},{label:`↓`,seq:`\x1B[B`,raw:!0},{label:`→`,seq:`\x1B[C`,raw:!0},{label:`|`,seq:`|`},{label:`-`,seq:`-`},{label:`/`,seq:`/`},{label:`~`,seq:`~`}],{menu:E,onContext:D,close:O}=Bl();async function k(e){u.value=``;let t=await fu(`/api/terminal`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cols:80,rows:24,...e})});if(!t){u.value=`failed to create terminal session`;return}w(t.id,t.label??`shell`)}function te(e){e.fitAddon.fit(),fetch(`/api/terminal/${e.sessionId}/resize`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({cols:e.terminal.cols,rows:e.terminal.rows})}).then(()=>{fetch(`/api/terminal/${e.sessionId}/nudge`,{method:`POST`})})}function ne(e){for(let t of s)t.containerEl.style.display=t.id===e?`block`:`none`;c.value=e;let t=s.find(t=>t.id===e);t&&r({tab:t.sessionId}),Tn(()=>{t&&(te(t),t.terminal.focus())})}async function A(e){if(!await o(`Close this terminal session?`))return;let n=s.findIndex(t=>t.id===e);if(n<0)return;let r=s[n];if(r.eventSource?.close(),r.terminal.dispose(),r.containerEl.remove(),t.delete(r.sessionId),fetch(`/api/terminal/${r.sessionId}`,{method:`DELETE`}),s.splice(n,1),s.length===0){a();return}if(c.value===e){let e=s[Math.min(n,s.length-1)];e?ne(e.id):c.value=null}}function re(e){let n=s.findIndex(t=>t.id===e);if(n<0)return;let r=s[n];if(r.eventSource?.close(),r.terminal.dispose(),r.containerEl.remove(),t.delete(r.sessionId),s.splice(n,1),s.length===0){a();return}if(c.value===e){let e=s[Math.min(n,s.length-1)];e?ne(e.id):c.value=null}}return R(()=>n.value.connectSession,e=>{e&&!t.has(e)&&w(e,`shell`)}),Ir(async()=>{await Tn(),d=new ResizeObserver(()=>{let e=C();e&&te(e)}),l.value&&d.observe(l.value);let e=n.value.tab,r=await fu(`/api/terminal`);if(r&&r.length>0){let n=r.filter(e=>!t.has(e.id)).sort((e,t)=>e.createdAt-t.createdAt);if(n.length>0){for(let e of n)w(e.id,e.label);if(e){let t=s.find(t=>t.sessionId===e);t&&ne(t.id)}}else await k()}else await k()}),Br(()=>{d?.disconnect();for(let e of s)e.eventSource?.close(),e.terminal.dispose(),t.delete(e.sessionId);s.length=0}),(e,t)=>(V(),H(`div`,qD,[U(`div`,JD,[(V(!0),H(B,null,Zr(s,e=>(V(),H(`button`,{key:e.id,type:`button`,class:N([`group relative flex-1 min-w-0 flex items-center justify-center gap-1.5 py-2 text-[13px] border-r border-border rounded-none active:transform-none transition-colors`,e.id===c.value?`bg-surface text-text`:`text-muted hover:text-text hover:bg-surface`]),onClick:t=>ne(e.id)},[U(`span`,{class:N([`absolute left-2 w-4 h-4 flex items-center justify-center text-[11px] text-muted group-hover:opacity-100 hover:text-danger! transition-all`,e.id===c.value?`opacity-100`:`opacity-0`]),onClick:ws(t=>A(e.id),[`stop`])},`×`,10,XD),U(`span`,{class:N([`inline-block w-1.5 h-1.5 rounded-full shrink-0`,e.id===c.value?e.connected?`bg-ok`:`bg-danger`:`bg-muted`])},null,2),U(`span`,ZD,P(e.label),1)],10,YD))),128)),U(`button`,{type:`button`,class:`shrink-0 px-3 py-2 text-[13px] text-muted hover:text-accent rounded-none active:transform-none transition-colors`,title:`new terminal (right-click for options)`,onClick:t[0]||=e=>k(),onContextmenu:t[1]||=e=>L(D)(e)},` + `,32)]),W(yl,{pos:L(E)??null},{default:Ln(()=>[U(`button`,{class:`w-full text-left px-3 py-1.5 text-[12px] text-text hover:bg-accent-dim hover:text-accent transition-colors cursor-pointer`,onClick:t[2]||=e=>{L(O)(),k()}},` New Shell `),U(`button`,{class:`w-full text-left px-3 py-1.5 text-[12px] text-text hover:bg-accent-dim hover:text-accent transition-colors cursor-pointer`,onClick:t[3]||=e=>{L(O)(),k({virtual:!0})}},` New Virtual Shell `)]),_:1},8,[`pos`]),L(p)?(V(),H(`div`,QD,[(V(),H(B,null,Zr(ee,(e,t)=>U(`button`,{key:t,type:`button`,class:N([`shrink-0 h-[30px] min-w-[30px] px-1.5 rounded text-[11px] font-mono font-medium border transition-colors active:transform-none`,e.toggle?.value?`bg-accent-dim text-accent border-accent-dim`:`bg-bg text-muted border-border hover:text-text`]),onMousedown:ws(t=>e.toggle?e.toggle.value=!e.toggle.value:T(e.seq,e.raw),[`prevent`]),onTouchstart:ws(t=>e.toggle?e.toggle.value=!e.toggle.value:T(e.seq,e.raw),[`prevent`])},P(e.label),43,$D)),64))])):K(``,!0),u.value?(V(),H(`div`,eO,P(u.value),1)):K(``,!0),U(`div`,{ref_key:`hostRef`,ref:l,class:`flex-1 min-h-0 bg-bg`,onTouchend:_},null,544)]))}}),window:{width:800,height:520,minwidth:480,minheight:300},multi:!1},nO={class:`flex items-center justify-center h-full bg-bg overflow-auto p-4`},rO=[`src`,`alt`],iO=[`src`],aO=[`src`],oO={key:3,class:`text-muted text-[12px]`},sO=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`ico`,`avif`]),cO=new Set([`mp4`,`webm`,`mov`,`avi`]),lO=new Set([`mp3`,`wav`,`ogg`,`flac`]);const uO=new Set([...sO,...cO,...lO]);var dO=z({__name:`MediaViewer`,props:{folder:{},path:{}},setup(e){let t=e,n=q(()=>`/api/files/raw?${new URLSearchParams({folder:t.folder,path:t.path})}`),r=q(()=>t.path.split(`.`).pop()?.toLowerCase()??``),i=q(()=>sO.has(r.value)?`image`:cO.has(r.value)?`video`:lO.has(r.value)?`audio`:`unknown`);return(t,r)=>(V(),H(`div`,nO,[i.value===`image`?(V(),H(`img`,{key:0,src:n.value,alt:e.path,class:`max-w-full max-h-full object-contain rounded`},null,8,rO)):i.value===`video`?(V(),H(`video`,{key:1,src:n.value,controls:``,class:`max-w-full max-h-full rounded`},null,8,iO)):i.value===`audio`?(V(),H(`audio`,{key:2,src:n.value,controls:``,class:`w-full max-w-md`},null,8,aO)):(V(),H(`div`,oO,`unsupported media format`))]))}}),fO={class:`flex flex-col h-full`},pO={key:0,class:`px-3 py-1.5 border-b border-border flex items-center gap-2 text-[11px]`},mO={class:`text-muted/60 text-[10px] uppercase tracking-wide`},hO={class:`text-muted font-mono truncate`},gO={key:0,class:`text-warn text-[10px]`},_O={class:`ml-auto flex gap-2 flex-shrink-0`},vO=[`disabled`],yO={key:0,class:`text-[9px] opacity-60`},bO={key:3,class:`flex-1 flex items-center justify-center text-muted text-[12px]`},xO={key:`viewer`,label:`Viewer`,icon:`pixelarticons:file`,color:`#39bae6`,component:z({__name:`window`,setup(e){let{confirm:t}=ou(),{state:n,set:r,setTitle:i}=$l(),a=F(``),o=F(``),s=F(``),c=F(!1),l=F(!1),u=q(()=>{let e=o.value.split(`.`).pop()?.toLowerCase()??``;return uO.has(e)}),d=q(()=>({ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,md:`markdown`,html:`html`,css:`css`,yaml:`yaml`,yml:`yaml`,sh:`shell`,bash:`shell`,py:`python`,rs:`rust`,go:`go`,sql:`sql`,xml:`xml`})[o.value.split(`.`).pop()?.toLowerCase()??``]??`plaintext`);async function f(){if(!a.value||!o.value)return;if(u.value){s.value=``,c.value=!1;return}let e=await fu(`/api/files/read?${new URLSearchParams({folder:a.value,path:o.value})}`);e&&(s.value=e.content,c.value=!1)}async function p(){!o.value||l.value||(l.value=!0,await du(`/api/files/write`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({folder:a.value,path:o.value,content:s.value})}),c.value=!1,l.value=!1)}return R(o,e=>{let t=e.split(`/`).pop();i(t?`Viewer — ${t}`:`Viewer`)}),R(()=>[n.value.folder,n.value.path],async([e,n])=>{if(!(e===a.value&&n===o.value)){if(c.value&&!await t(`discard unsaved changes?`)){r({folder:a.value,path:o.value});return}a.value=e||``,o.value=n||``,await f()}},{immediate:!0}),(e,t)=>(V(),H(`div`,fO,[o.value?(V(),H(`div`,pO,[U(`span`,mO,P(d.value),1),U(`span`,hO,P(a.value)+`/`+P(o.value),1),c.value?(V(),H(`span`,gO,`~`)):K(``,!0),U(`div`,_O,[U(`button`,{type:`button`,class:`btn-sm hover:bg-surface`,onClick:f},[...t[1]||=[G(` refresh `,-1),U(`span`,{class:`text-[9px] opacity-60`},`⌘R`,-1)]]),u.value?K(``,!0):(V(),H(`button`,{key:0,type:`button`,class:`btn-sm bg-accent-dim text-accent border-accent-dim hover:bg-accent-dimmer`,disabled:l.value,onClick:p},[G(P(l.value?`saving...`:`save`)+` `,1),l.value?K(``,!0):(V(),H(`span`,yO,`⌘S`))],8,vO))])])):K(``,!0),o.value&&u.value?(V(),wa(dO,{key:1,folder:a.value,path:o.value,class:`flex-1`},null,8,[`folder`,`path`])):o.value?(V(),wa(Dp,{key:2,"model-value":s.value,language:d.value,class:`flex-1`,"onUpdate:modelValue":t[0]||=e=>{s.value=e,c.value=!0},onSave:p},null,8,[`model-value`,`language`])):(V(),H(`div`,bO,` no file open `))]))}}),window:{width:720,height:520,minwidth:400,minheight:300},multi:!0,hidden:!0},SO={class:`@container flex flex-col h-full p-4 gap-4 overflow-y-auto select-none`},CO={key:0,class:`border border-border rounded-lg p-3 flex items-center justify-between gap-3 bg-surface`},wO={class:`grid grid-cols-1 @sm:grid-cols-2 @lg:grid-cols-3 gap-3`},TO={class:`border border-border rounded-lg p-3 flex flex-col gap-2`},EO={class:`flex items-center gap-2`},DO={class:`border border-border rounded-lg p-3 flex flex-col gap-2`},OO={class:`flex items-center gap-2`},kO=[`disabled`],AO={class:`border border-border rounded-lg p-3 flex flex-col gap-2`},jO={class:`flex items-center gap-2`},MO={class:`border border-border rounded-lg p-3 flex flex-col gap-2`},NO={class:`flex items-center gap-2`},PO={class:`border border-border rounded-lg p-3 flex flex-col gap-2`},FO={class:`flex items-center gap-2`},IO={class:`grid grid-cols-3 @sm:grid-cols-4 @lg:grid-cols-5 gap-2`},LO=[`onClick`],RO={class:`text-[10px] font-medium`};const zO=[Wh,Pv,ym,ey,Bg,xy,p_,wg,xO,tO,q_,{key:`welcome`,label:`Welcome`,icon:`pixelarticons:briefcase-plus`,color:`#e5a535`,component:z({__name:`window`,setup(e){let t=new Set([`agent`,`telegram`,`ntfy`,`chat`,`settings`,`welcome`]),n=zO.filter(e=>!e.hidden&&!t.has(e.key)),{openWindow:r}=$l(),{showInstall:i}=Ml(),{settings:a}=Xl(),o=F(null),s=F(null),c=F(null),l=F(0);async function u(){let[e,t,n,r]=await Promise.all([fu(`/api/pi/status`),fu(`/api/telegram/status`),fu(`/api/ntfy/status`),fu(`/api/groups`)]);e&&(o.value=e),t&&(s.value=t),n&&(c.value=n),r&&(l.value=r.length)}gu(u,5e3);let d=q(()=>(o.value?.auth.configuredProviders.length??0)>0||o.value?.auth.providers.some(e=>e.hasAuth)),f=q(()=>s.value?.connected??!1),p=q(()=>c.value?.configured??!1),m=q(()=>l.value>0),h=q(()=>!!a.wallpaper);function g(){r(`agent`,{tab:`auth`})}function _(){r(`telegram`)}function v(){r(`chat`)}function y(){r(`ntfy`)}function b(){r(`settings`,{tab:`wallpaper`})}return(e,t)=>(V(),H(`div`,SO,[t[7]||=U(`div`,{class:`text-center`},[U(`div`,{class:`text-[18px] font-medium text-text mb-1`},`welcome to piclaw`),U(`div`,{class:`text-[12px] text-muted`},`follow these steps to get started`)],-1),L(i)?(V(),H(`div`,CO,[t[0]||=U(`div`,{class:`flex flex-col gap-1`},[U(`div`,{class:`text-[12px] text-text`},`for the best experience, install piclaw`)],-1),W(zl,{"inline-install":``})])):K(``,!0),U(`div`,wO,[U(`div`,TO,[U(`div`,EO,[W(L(vl),{icon:d.value?`lucide:check`:`lucide:cpu`,class:N([`text-[16px] shrink-0`,d.value?`text-ok`:`text-muted`])},null,8,[`icon`,`class`]),U(`div`,{class:N([`text-[13px] font-medium`,d.value?`text-ok`:`text-text`])},` Connect AI provider `,2)]),t[1]||=U(`div`,{class:`text-[11px] text-muted`},` set up a provider (anthropic, openai, etc.) to power your agents `,-1),U(`button`,{type:`button`,class:N([`mt-auto px-3 py-1.5 rounded text-[11px] font-medium cursor-pointer transition-colors`,d.value?`bg-ok-dim text-ok border border-ok-dim hover:text-text`:`bg-accent-dim text-accent border border-accent-dim hover:bg-accent-dimmer`]),onClick:g},P(d.value?`connected — manage`:`open agent settings`),3)]),U(`div`,DO,[U(`div`,OO,[W(L(vl),{icon:m.value?`lucide:check`:`lucide:message-circle`,class:N([`text-[16px] shrink-0`,m.value?`text-ok`:`text-muted`])},null,8,[`icon`,`class`]),U(`div`,{class:N([`text-[13px] font-medium`,m.value?`text-ok`:`text-text`])},` Start your first chat `,2)]),t[2]||=U(`div`,{class:`text-[11px] text-muted`},`register a group and send your first message`,-1),U(`button`,{type:`button`,class:N([`mt-auto px-3 py-1.5 rounded text-[11px] font-medium cursor-pointer transition-colors`,m.value?`bg-ok-dim text-ok border border-ok-dim hover:text-text`:`bg-accent-dim text-accent border border-accent-dim hover:bg-accent-dimmer`]),disabled:!d.value,onClick:v},P(m.value?`started — open chat`:`open chat`),11,kO)]),U(`div`,AO,[U(`div`,jO,[W(L(vl),{icon:f.value?`lucide:check`:`lucide:send`,class:N([`text-[16px] shrink-0`,f.value?`text-ok`:`text-muted`])},null,8,[`icon`,`class`]),U(`div`,{class:N([`text-[13px] font-medium`,f.value?`text-ok`:`text-text`])},` Connect telegram `,2)]),t[3]||=U(`div`,{class:`text-[11px] text-muted`},`link a telegram bot to chat from telegram`,-1),U(`button`,{type:`button`,class:N([`mt-auto px-3 py-1.5 rounded text-[11px] font-medium cursor-pointer transition-colors`,f.value?`bg-ok-dim text-ok border border-ok-dim hover:text-text`:`bg-accent-dim text-accent border border-accent-dim hover:bg-accent-dimmer`]),onClick:_},P(f.value?`connected — @${s.value?.botUsername}`:`set up telegram bot`),3)]),U(`div`,MO,[U(`div`,NO,[W(L(vl),{icon:h.value?`lucide:check`:`lucide:palette`,class:N([`text-[16px] shrink-0`,h.value?`text-ok`:`text-muted`])},null,8,[`icon`,`class`]),U(`div`,{class:N([`text-[13px] font-medium`,h.value?`text-ok`:`text-text`])},` Customize desktop `,2)]),t[4]||=U(`div`,{class:`text-[11px] text-muted`},`pick a wallpaper to personalize your dashboard`,-1),U(`button`,{type:`button`,class:N([`mt-auto px-3 py-1.5 rounded text-[11px] font-medium cursor-pointer transition-colors`,h.value?`bg-ok-dim text-ok border border-ok-dim hover:text-text`:`bg-accent-dim text-accent border border-accent-dim hover:bg-accent-dimmer`]),onClick:b},P(h.value?`customized — change`:`open wallpaper settings`),3)]),U(`div`,PO,[U(`div`,FO,[W(L(vl),{icon:p.value?`lucide:check`:`lucide:bell`,class:N([`text-[16px] shrink-0`,p.value?`text-ok`:`text-muted`])},null,8,[`icon`,`class`]),U(`div`,{class:N([`text-[13px] font-medium`,p.value?`text-ok`:`text-text`])},` Set up notifications `,2)]),t[5]||=U(`div`,{class:`text-[11px] text-muted`},` get push notifications via ntfy when agents respond `,-1),U(`button`,{type:`button`,class:N([`mt-auto px-3 py-1.5 rounded text-[11px] font-medium cursor-pointer transition-colors`,p.value?`bg-ok-dim text-ok border border-ok-dim hover:text-text`:`bg-accent-dim text-accent border border-accent-dim hover:bg-accent-dimmer`]),onClick:y},P(p.value?`configured — manage`:`set up ntfy`),3)])]),U(`div`,null,[t[6]||=U(`div`,{class:`label mb-2`},`discover more`,-1),U(`div`,IO,[(V(!0),H(B,null,Zr(L(n),e=>(V(),H(`button`,{key:e.key,type:`button`,class:`flex flex-col items-center justify-center gap-1 py-2 rounded-lg border border-border bg-surface cursor-pointer transition-colors hover:border-muted hover:text-text text-muted`,onClick:t=>L(r)(e.key)},[W(L(vl),{icon:e.icon,class:`text-[16px]`,style:M({color:e.color})},null,8,[`icon`,`style`]),U(`span`,RO,P(e.label.toLowerCase()),1)],8,LO))),128))])])]))}}),window:{width:640,height:570,minwidth:520,minheight:440}}];var BO={class:`flex justify-center pb-1.5 pt-0.5 sticky bottom-0 z-[1001] pointer-events-none max-md:fixed max-md:inset-x-0 max-md:bottom-0 max-md:pb-0 max-md:pt-0`},VO={key:0,class:`w-px h-5 bg-white/10 mx-0.5`},HO=[`title`,`onClick`,`onContextmenu`,`onTouchstart`],UO={key:1,class:`w-px h-5 bg-white/10 mx-0.5`},WO={key:0,class:`font-pixel text-[13px] text-white/80 select-none leading-none drop-shadow-[0_1px_2px_rgba(0,0,0,0.8)]`},GO=[`title`],KO={class:`grid grid-cols-3 gap-8 p-8 pt-16 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6`},qO=[`onClick`],JO={class:`flex items-center justify-center w-14 h-14 sm:w-21 sm:h-21 rounded-2xl bg-surface border border-border shadow-md transition-transform group-hover:scale-110`},YO={class:`text-[11px] text-white/80 group-hover:text-white transition-colors`,style:{"text-shadow":`0 1px 3px rgba(0, 0, 0, 0.8),
38
+ 0 0 6px rgba(0, 0, 0, 0.4)`}},XO={key:0,class:`w-1 h-1 rounded-full bg-accent`},ZO={key:0,class:`col-span-full text-center text-white/60 text-sm py-4`,style:{"text-shadow":`0 1px 3px rgba(0, 0, 0, 0.8)`}},QO={key:0,class:`fixed inset-0 z-[1200] flex flex-col items-center justify-center backdrop-blur-xl bg-bg/60 select-none`},$O={class:`flex flex-col items-center gap-4`},ek=z({__name:`DashPanel`,props:{openInstances:{},minimized:{},focusedWindow:{}},emits:[`launch`,`focus`,`minimize`,`close`],setup(e,{emit:t}){let n=e,r=t,{settings:i}=Xl(),a={small:{bar:40,item:34,icon:16},medium:{bar:48,item:40,icon:20},large:{bar:56,item:46,icon:24}},o=q(()=>{let e=a[i.dockSize]||a.medium;return{"--dock-h":`${e.bar}px`,"--dock-item":`${e.item}px`,"--dock-icon":`${e.icon}px`}}),s=F(!1),c=F(``),l,{menu:u,onContext:d,onTouchStart:f,cancelLongPress:p,close:m}=Bl();function h(){u.value&&r(`minimize`,u.value.data),m()}function g(){u.value&&r(`close`,u.value.data),m()}let{menu:_,onContext:v,close:y}=Bl();function b(){y(),r(`launch`,`settings`,{tab:`dash`})}let x=q(()=>new Set(n.openInstances.map(e=>e.appKey))),S=F(``),C=F(),w=F(!1),T=mu(),ee=q(()=>{let e=S.value.toLowerCase().trim(),t=zO.filter(e=>!e.hidden);return e?t.filter(t=>t.label.toLowerCase().includes(e)):t}),{showInstall:E,handleInstallClick:D}=Ml(),O=F(!0),k=F(!1);gu(async()=>{let e=!O.value;O.value=await du(`/api/health`)!==null,e&&O.value&&(k.value=!1)},3e4);function te(){s.value=!s.value,S.value=``,w.value=!1,s.value&&!T.value&&Tn(()=>C.value?.focus())}function ne(){w.value=!0,Tn(()=>C.value?.focus())}function A(e){e.key===`Enter`&&ee.value.length===1&&re(ee.value[0].key)}function re(e){r(`launch`,e),s.value=!1}function j(){c.value=new Date().toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hour12:i.clockFormat===`12h`})}function ie(e){if(e.key===`Escape`&&u.value){m(),e.preventDefault();return}e.key===`Escape`&&s.value&&(s.value=!1,e.preventDefault()),(e.key===` `||e.key===`k`)&&(e.ctrlKey||e.metaKey)&&(te(),e.preventDefault())}return Ir(()=>{j(),l=setInterval(j,1e4),document.addEventListener(`keydown`,ie)}),Br(()=>{clearInterval(l),document.removeEventListener(`keydown`,ie)}),(t,n)=>(V(),H(B,null,[U(`div`,BO,[U(`div`,{class:`dock-bar force-dark pointer-events-auto px-2 rounded-2xl flex items-center gap-1 text-[12px] select-none max-md:w-full max-md:rounded-none`,style:M(o.value),onContextmenu:n[4]||=e=>L(v)(e,void 0)},[U(`button`,{type:`button`,class:N([`dock-item`,s.value?`text-accent`:`text-white/70`]),title:`Apps (Ctrl+Space / Ctrl+K)`,onClick:te,onContextmenu:n[0]||=e=>L(v)(e,void 0)},[W(L(vl),{icon:`lucide:layout-grid`,class:`dock-icon`})],34),e.openInstances.length?(V(),H(`div`,VO)):K(``,!0),(V(!0),H(B,null,Zr(e.openInstances,t=>(V(),H(`button`,{key:t.id,type:`button`,class:N([`dock-item text-white/70`,{"!text-white":e.focusedWindow===t.id,"opacity-50":e.minimized[t.id]}]),title:t.app.label.toLowerCase(),onClick:e=>r(`focus`,t.id),onContextmenu:ws(e=>L(d)(e,t.id),[`stop`]),onTouchstart:e=>L(f)(e,t.id),onTouchend:n[1]||=(...e)=>L(p)&&L(p)(...e),onTouchmove:n[2]||=(...e)=>L(p)&&L(p)(...e)},[W(L(vl),{icon:t.app.icon,class:`dock-icon`,"aria-hidden":`true`,style:M({color:t.app.color})},null,8,[`icon`,`style`]),U(`span`,{class:N([`absolute -bottom-0.5 w-1 h-1 rounded-full transition-opacity`,e.focusedWindow===t.id?`bg-accent opacity-100`:`bg-muted opacity-50`])},null,2)],42,HO))),128)),n[11]||=U(`div`,{class:`flex-1`},null,-1),e.openInstances.length&&(L(i).showClock||L(i).showStatus)?(V(),H(`div`,UO)):K(``,!0),L(i).showClock||L(i).showStatus?(V(),H(`div`,{key:2,class:`dock-item !cursor-default !w-auto px-1.5 text-white/70 hover:!bg-transparent hover:!transform-none`,onContextmenu:n[3]||=e=>L(v)(e,void 0)},[L(i).showClock?(V(),H(`span`,WO,P(c.value),1)):K(``,!0),L(i).showStatus?(V(),H(`span`,{key:1,class:N([`absolute -bottom-0.5 w-1 h-1 rounded-full transition-opacity`,O.value?`bg-ok`:`bg-danger`]),title:O.value?`server healthy`:`server unreachable`},null,10,GO)):K(``,!0)],32)):K(``,!0)],36)]),(V(),wa(ir,{to:`body`},[W(So,{name:`launchpad`},{default:Ln(()=>[s.value?(V(),H(`div`,{key:0,class:N([`force-dark fixed inset-0 z-[1100] flex justify-center backdrop-blur-sm bg-transparent backdrop-saturate-150`,w.value?`items-start pt-16`:`items-center`]),onClick:n[8]||=e=>s.value=!1},[!L(T)||w.value?Rn((V(),H(`input`,{key:0,ref_key:`searchInput`,ref:C,"onUpdate:modelValue":n[5]||=e=>S.value=e,class:`absolute top-6 left-1/2 -translate-x-1/2 w-48 px-3 py-1.5 bg-surface/90 border border-border rounded-lg text-sm text-text backdrop-blur-md outline-none text-center`,placeholder:`search apps...`,"aria-label":`Search apps`,onClick:n[6]||=ws(()=>{},[`stop`]),onKeydown:A},null,544)),[[vs,S.value]]):K(``,!0),U(`button`,{type:`button`,class:`absolute top-6 left-6 p-2 text-white/50 hover:text-white transition-colors`,title:`close`,onClick:n[7]||=e=>s.value=!1},[W(L(vl),{icon:`lucide:x`,class:`text-lg`})]),L(T)&&!w.value?(V(),H(`button`,{key:1,type:`button`,class:`absolute top-6 right-6 p-2 bg-surface/80 border border-border rounded-lg text-muted hover:text-text backdrop-blur-md transition-colors`,onClick:ws(ne,[`stop`])},[W(L(vl),{icon:`lucide:search`,class:`text-base`})])):K(``,!0),U(`div`,KO,[(V(!0),H(B,null,Zr(ee.value,e=>(V(),H(`button`,{key:`launcher-${e.key}`,type:`button`,class:`group flex flex-col items-center gap-2 p-4 rounded-xl transition-all`,onClick:t=>re(e.key)},[U(`span`,JO,[W(L(vl),{icon:e.icon,class:`text-2xl sm:text-4xl`,"aria-hidden":`true`,style:M({color:e.color})},null,8,[`icon`,`style`])]),U(`span`,YO,P(e.label),1),x.value.has(e.key)?(V(),H(`span`,XO)):K(``,!0)],8,qO))),128)),S.value&&!ee.value.length?(V(),H(`div`,ZO,` No apps found `)):K(``,!0)])],2)):K(``,!0)]),_:1})])),(V(),wa(ir,{to:`body`},[W(So,{name:`launchpad`},{default:Ln(()=>[!O.value&&!k.value?(V(),H(`div`,QO,[U(`div`,$O,[n[13]||=U(`span`,{class:`inline-block w-3 h-3 rounded-full bg-danger animate-pulse`},null,-1),n[14]||=U(`p`,{class:`text-muted text-[13px] tracking-wide`},`server unreachable`,-1),U(`button`,{type:`button`,class:`mt-2 px-4 py-1.5 text-[11px] font-medium bg-bg text-muted border border-border rounded hover:text-text transition-colors`,onClick:n[9]||=e=>k.value=!0},` dismiss `),L(E)?(V(),H(`button`,{key:0,type:`button`,class:`mt-1 px-4 py-1.5 text-[11px] font-medium text-accent border border-accent/30 rounded hover:bg-accent/10 transition-colors inline-flex items-center gap-1.5`,onClick:n[10]||=e=>L(D)()},[W(L(vl),{icon:`lucide:download`,class:`text-[13px]`}),n[12]||=G(` install app `,-1)])):K(``,!0)])])):K(``,!0)]),_:1})])),W(yl,{pos:L(u)??null,transform:`translateY(-100%)`},{default:Ln(()=>[U(`button`,{type:`button`,class:`w-full px-3 py-1.5 text-left text-[12px] text-text hover:bg-accent-dim hover:text-accent transition-colors cursor-pointer`,onClick:h},` Minimize `),U(`button`,{type:`button`,class:`w-full px-3 py-1.5 text-left text-[12px] text-text hover:bg-danger-dim hover:text-danger transition-colors cursor-pointer`,onClick:g},` Close `)]),_:1},8,[`pos`]),W(yl,{pos:L(_)??null,transform:`translateY(-100%)`},{default:Ln(()=>[U(`button`,{type:`button`,class:`w-full px-3 py-1.5 text-left text-[12px] text-text hover:bg-accent-dim hover:text-accent transition-colors cursor-pointer`,onClick:b},` Dash settings `)]),_:1},8,[`pos`])],64))}}),tk=`#ff5f57`,nk=`#febc2e`,rk=`#28c840`,ik=`var(--color-tl-inactive)`,ak=12,ok=`width 0.2s, height 0.2s, left 0.2s, top 0.2s`,sk=`ease-out`,ck={display:`inline-block`,width:`${ak}px`,height:`${ak}px`,borderRadius:`50%`,cursor:`pointer`,flexShrink:`0`},lk={"wb-n":{top:`-5px`,left:`0`,right:`0`,height:`10px`},"wb-s":{bottom:`-5px`,left:`0`,right:`0`,height:`10px`},"wb-w":{top:`0`,left:`-5px`,bottom:`0`,width:`10px`},"wb-e":{top:`0`,right:`-5px`,bottom:`0`,width:`10px`},"wb-nw":{top:`-5px`,left:`-5px`,width:`15px`,height:`15px`},"wb-ne":{top:`-5px`,right:`-5px`,width:`15px`,height:`15px`},"wb-sw":{bottom:`-5px`,left:`-5px`,width:`15px`,height:`15px`},"wb-se":{bottom:`-5px`,right:`-5px`,width:`15px`,height:`15px`}},uk={"wb-n":`n-resize`,"wb-s":`n-resize`,"wb-w":`w-resize`,"wb-e":`w-resize`,"wb-nw":`nw-resize`,"wb-ne":`ne-resize`,"wb-sw":`ne-resize`,"wb-se":`nw-resize`},dk=Object.keys(lk);function fk(e,t,n,r){e?.addEventListener(t,n,r||!1)}function pk(e,t,n,r){e?.removeEventListener(t,n,r||!1)}function mk(e,t){e.stopPropagation(),t&&e.preventDefault()}function $(e,t){return e.getElementsByClassName(t)[0]}function hk(e,t){e.classList.add(t)}function gk(e,t){return e.classList.contains(t)}function _k(e,t){e.classList.remove(t)}function vk(e,t,n){let r=e,i=String(n),a=`_s_${t}`;r[a]!==i&&(e.style.setProperty(t,i),r[a]=i)}function yk(e,t){let n=e.firstChild;n?n.nodeValue=t:e.textContent=t}var bk=document.createElement(`div`);bk.innerHTML=`<div class=wb-modal-bg></div><div class=wb-modal-overlay></div><div class=wb-header><div class=wb-control><span class=wb-close></span><span class=wb-min></span><span class=wb-max></span><span class=wb-full></span></div><div class=wb-drag><div class=wb-icon></div><div class=wb-title></div></div></div><div class=wb-body></div><div class=wb-n></div><div class=wb-s></div><div class=wb-w></div><div class=wb-e></div><div class=wb-nw></div><div class=wb-ne></div><div class=wb-se></div><div class=wb-sw></div>`;var xk=[],Sk=[],Ck={capture:!0,passive:!1},wk={capture:!0,passive:!0},Tk,Ek=0,Dk=10,Ok,kk=``,Ak=``,jk=0,Mk=0,Nk=!1,Pk=class e{static new(t){return new e(t)}static stack(){return Sk}dom;window;body;header;id;title=``;x=0;y=0;width=0;height=0;minwidth=150;minheight=35;maxwidth=0;maxheight=0;top=0;right=0;bottom=0;left=0;index=0;overflow=!1;min=!1;max=!1;full=!1;hidden=!1;focused=!1;snapped=!1;noAnimation=!1;noMove=!1;noMax=!1;_optionHidden=new Set;onclose;onfocus;onblur;onmove;onresize;onfullscreen;onmaximize;onminimize;onrestore;onsnap;onhide;onshow;constructor(e,t){Tk??Gk();let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v=!1,y,b,x,S,C,w,T=!1,ee=!1,E=!1,D=!1,O,k,te,ne,A,re=null;if(e&&(t&&(o=String(e),e=t),typeof e==`string`?o=e:(n=e.id,r=e.index,i=e.root,a=e.template,o??=e.title,s=e.icon,c=e.mount,l=e.html,u=e.url,d=e.width,f=e.height,p=e.minwidth,m=e.minheight,h=e.maxwidth,g=e.maxheight,_=e.autosize,v=!!e.overflow,T=!!e.min,ee=!!e.max,E=!!e.hidden,D=!!e.modal,y=e.x??(D?`center`:0),b=e.y??(D?`center`:0),x=e.top,S=e.left,C=e.bottom,w=e.right,O=e.background,k=e.border,te=e.header,ne=e.class,A=e.oncreate,this.onclose=e.onclose,this.onfocus=e.onfocus,this.onblur=e.onblur,this.onmove=e.onmove,this.onresize=e.onresize,this.onfullscreen=e.onfullscreen,this.onmaximize=e.onmaximize,this.onminimize=e.onminimize,this.onrestore=e.onrestore,this.onsnap=e.onsnap,this.onhide=e.onhide,this.onshow=e.onshow,re=e.onload??null)),this.dom=Fk(a),this.id=n||`winbox-${++Ek}`,this.dom.id=this.id,this.dom.className=`winbox`,this.dom.winbox=this,this.window=this.dom,this.body=$(this.dom,`wb-body`),this.header=te||35,Lk(this.dom),ne){let e=Array.isArray(ne)?ne:ne.split(` `);Bk(this,this.dom,e)}if(D&&Uk(this.dom,!0),Sk.push(this),O&&this.setBackground(O),k?vk(this.body,`margin`,`${k}${Number.isNaN(Number(k))?``:`px`}`):k=0,te){let e=$(this.dom,`wb-header`);vk(e,`height`,`${te}px`),vk(e,`line-height`,`${te}px`),vk(this.body,`top`,`${te}px`)}o&&this.setTitle(o),s&&this.setIcon(s),c?this.mount(c):l?this.body.innerHTML=l:u&&this.setUrl(u,re);let j=x?Ik(x,Mk):0,ie=C?Ik(C,Mk):0,ae=S?Ik(S,jk):0,oe=w?Ik(w,jk):0,se=jk-ae-oe,M=Mk-j-ie,ce=h?Ik(h,se):se,le=g?Ik(g,M):M,ue=p?Ik(p,ce):150,de=m?Ik(m,le):this.header,N,fe;_?((i||Tk).appendChild(this.body),N=Math.max(Math.min(this.body.clientWidth+Number(k)*2+1,ce),ue),fe=Math.max(Math.min(this.body.clientHeight+this.header+Number(k)+1,le),de),this.dom.appendChild(this.body)):(N=d?Ik(d,ce):Math.max(ce/2|0,ue),fe=f?Ik(f,le):Math.max(le/2|0,de));let pe=y===void 0?ae:Ik(y,se,N),me=b===void 0?j:Ik(b,M,fe);this.x=pe,this.y=me,this.width=N,this.height=fe,this.minwidth=ue,this.minheight=de,this.maxwidth=ce,this.maxheight=le,this.top=j,this.right=oe,this.bottom=ie,this.left=ae,this.index=r??this.index,this.overflow=v,E?this.hide():this.focus(),r!==void 0&&(this.index=r,vk(this.dom,`z-index`,String(r)),r>Dk&&(Dk=r)),ee?this.maximize():T?this.minimize():this.resize().move(),Kk(this),(i||Tk).appendChild(this.dom),A?.call(this,e)}mount(e){return this.unmount(),e?(e._backstore||=e.parentNode,this.body.textContent=``,this.body.appendChild(e),this):this}unmount(e){let t=this.body.firstChild;return t&&((e??t._backstore)?.appendChild(t),t._backstore=e),this}setTitle(e){return yk($(this.dom,`wb-title`),this.title=e),this}setIcon(e){let t=$(this.dom,`wb-icon`);return vk(t,`background-image`,`url(${e})`),vk(t,`display`,`inline-block`),this}setBackground(e){return vk(this.dom,`background`,e),this}setUrl(e,t){let n=this.body.firstChild;if(n&&n.tagName.toLowerCase()===`iframe`)n.src=e;else{this.body.innerHTML=`<iframe src="${e}"></iframe>`;let n=this.body.firstChild;n&&(Object.assign(n.style,{position:`absolute`,width:`100%`,height:`100%`,border:`0`}),n.onload=t??null)}return this}focus(e){if(e===!1)return this.blur();if(!this.focused){let e=Sk.length;if(e>1)for(let t=1;t<=e;t++){let n=Sk[e-t];if(n?.focused){n.blur();let e=Sk.indexOf(this);e>=0&&Sk.push(Sk.splice(e,1)[0]);break}}vk(this.dom,`z-index`,String(++Dk)),this.index=Dk,this.focused=!0,zk(this.dom,!0),this.onfocus?.()}return this}blur(e){return e===!1?this.focus():(this.focused&&(this.focused=!1,zk(this.dom,!1),this.onblur?.()),this)}hide(e){return e===!1?this.show():(this.hidden||(this.onhide?.(),this.hidden=!0,this.dom.style.display=`none`),this)}show(e){return e===!1?this.hide():(this.hidden&&=(this.onshow?.(),!1),this.dom.style.display=``,this)}minimize(e){if(e===!1)return this.restore();if(Ok&&$k(),this.max&&=(Vk(this,this.dom,!1),!1),!this.min){xk.push(this),this.dom.title=this.title,Hk(this,this.dom,!0),this.min=!0;let e=this.header,t=(jk-200)/2|0,n=Mk-e;this.resize(200,e,!0).move(t,n,!0);let r=this.dom,i=()=>{r.removeEventListener(`transitionend`,i),this.min&&(r.style.display=`none`)};r.addEventListener(`transitionend`,i),this.focused&&(this.blur(),Zk()),this.onminimize?.()}return this}restore(){return Ok&&$k(),this.min&&(this.dom.style.display=``,qk(this),this.resize().move(),this.onrestore?.()),this.max&&(this.max=!1,Vk(this,this.dom,!1),this.resize().move(),this.onrestore?.()),this.snapped&&(this.snapped=!1,Vk(this,this.dom,!1),this.resize().move(),this.onsnap?.(!1),this.onrestore?.()),this}maximize(e){return e===!1?this.restore():(Ok&&$k(),this.min&&qk(this),this.max||(Vk(this,this.dom,!0),this.resize(jk-this.left-this.right,Mk-this.top-this.bottom,!0).move(this.left,this.top,!0),this.max=!0,this.onmaximize?.()),this)}snap(e){if(Ok&&$k(),this.min&&qk(this),this.max&&(this.max=!1,Vk(this,this.dom,!1)),this.snapped===e)return this;this.snapped&&=!1;let t=Math.round((jk-this.left-this.right)/2),n=Mk-this.top-this.bottom,r=e===`left`?this.left:this.left+t;return Vk(this,this.dom,!0),this.resize(t,n,!0).move(r,this.top,!0),this.snapped=e,this.onsnap?.(e),this}fullscreen(e){if(this.min&&(qk(this),this.resize().move()),!Ok||!$k()){let e=this.body,t=e[kk];typeof t==`function`&&t.call(e),Ok=this,this.full=!0,this.onfullscreen?.()}else if(e===!1)return this.restore();return this}close(e){if(this.onclose?.(e))return!0;this.min&&qk(this);let t=Sk.indexOf(this);t>=0&&Sk.splice(t,1),this.unmount(),this.dom.remove(),this.dom.textContent=``,this.dom.winbox=null;let n=this.focused;this.focused=!1,this.body=null,this.dom=null,n&&Zk()}move(e,t,n){let r,i;return e===void 0&&e!==0?(r=this.x,i=this.y):n?(r=Number(e??this.x),i=Number(t??this.y)):(r=e?Ik(e,jk-this.left-this.right,this.width):0,i=t?Ik(t,Mk-this.top-this.bottom,this.height):0,this.x=r,this.y=i),vk(this.dom,`left`,`${r}px`),vk(this.dom,`top`,`${i}px`),this.onmove?.(r,i),this}resize(e,t,n){let r,i;return e===void 0&&e!==0?(r=this.width,i=this.height):n?(r=Number(e??this.width),i=Number(t??this.height)):(r=e?Ik(e,this.maxwidth):0,i=t?Ik(t,this.maxheight):0,r=Math.max(r,this.minwidth),i=Math.max(i,this.minheight),this.width=r,this.height=i),vk(this.dom,`width`,`${r}px`),vk(this.dom,`height`,`${i}px`),this.onresize?.(r,i),this}addControl(e){let t=e.class,n=e.image,r=e.click,i=e.index,a=document.createElement(`span`),o=$(this.dom,`wb-control`),s=this;return Object.assign(a.style,ck,{background:ik}),t&&(a.className=t),n&&vk(a,`background-image`,`url(${n})`),r&&(a.onclick=function(e){r.call(this,e,s)}),o.insertBefore(a,o.childNodes[i||0]??null),this}removeControl(e){return $(this.dom,e)?.remove(),this}addClass(e){return hk(this.dom,e),this}removeClass(e){return _k(this.dom,e),this}hasClass(e){return gk(this.dom,e)}toggleClass(e){return this.hasClass(e)?this.removeClass(e):this.addClass(e)}};function Fk(e){return e?e.cloneNode(!0):bk.cloneNode(!0)}function Ik(e,t,n=0){if(typeof e==`string`){if(e===`center`)return(t-n)/2+.5|0;if(e===`right`||e===`bottom`)return t-n;let r=parseFloat(e),i=String(r);return(i===e?``:e.slice(i.length))===`%`?t/100*r+.5|0:r}return e}function Lk(e){Object.assign(e.style,{position:`fixed`,left:`0`,top:`0`,background:`var(--color-surface)`,border:`1px solid var(--color-border)`,borderRadius:`10px`,boxShadow:`var(--shadow-window)`,transition:ok,transitionTimingFunction:sk,contain:`layout size`,textAlign:`left`,touchAction:`none`});let t=$(e,`wb-modal-bg`);Object.assign(t.style,{display:`none`,position:`absolute`,top:`0`,left:`0`,right:`0`,bottom:`0`,background:`inherit`,borderRadius:`inherit`});let n=$(e,`wb-modal-overlay`);Object.assign(n.style,{display:`none`,position:`absolute`,top:`-50vh`,left:`-50vw`,right:`-50vw`,bottom:`-50vh`,background:`var(--color-bg)`,zIndex:`-1`});let r=$(e,`wb-header`);Object.assign(r.style,{position:`absolute`,left:`0`,top:`0`,width:`100%`,height:`38px`,lineHeight:`38px`,color:`var(--color-muted)`,borderBottom:`1px solid var(--color-border)`,background:`var(--color-surface)`,borderRadius:`10px 10px 0 0`,overflow:`hidden`,zIndex:`1`});let i=$(e,`wb-body`);Object.assign(i.style,{position:`absolute`,top:`38px`,left:`0`,right:`0`,bottom:`0`,overflow:`auto`,willChange:`contents`,marginTop:`0`,contain:`layout size`,zIndex:`0`,background:`var(--color-bg)`,borderRadius:`0 0 10px 10px`,color:`var(--color-text, inherit)`,textAlign:`initial`,touchAction:`auto`,cursor:`auto`}),i.style.webkitOverflowScrolling=`touch`;let a=$(e,`wb-control`);Object.assign(a.style,{float:`left`,height:`100%`,display:`flex`,alignItems:`center`,gap:`8px`,paddingLeft:`14px`});let o=$(e,`wb-drag`);Object.assign(o.style,{height:`100%`,cursor:`default`,overflow:`hidden`});let s=$(e,`wb-title`);Object.assign(s.style,{fontFamily:`'Geist', 'Geist Variable', sans-serif`,fontSize:`13px`,fontWeight:`500`,letterSpacing:`0`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`,textAlign:`center`,paddingRight:`60px`});let c=$(e,`wb-icon`);Object.assign(c.style,{display:`none`,width:`20px`,height:`100%`,margin:`-1px 8px 0 -3px`,float:`left`,backgroundRepeat:`no-repeat`,backgroundSize:`100%`,backgroundPosition:`center`});let l=$(e,`wb-close`);Object.assign(l.style,ck,{background:tk});let u=$(e,`wb-min`);Object.assign(u.style,ck,{background:nk});let d=$(e,`wb-max`);Object.assign(d.style,ck,{background:rk});let f=$(e,`wb-full`);Object.assign(f.style,ck,{background:rk,display:`none`}),Rk(a,l,u,d,f);for(let t of dk){let n=$(e,t);n&&Object.assign(n.style,{position:`absolute`,zIndex:`2`},lk[t])}}function Rk(e,t,n,r,i){let a=e=>`url("data:image/svg+xml,${encodeURIComponent(e)}")`,o=a(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 85.4 85.4"><g fill="#460804" fill-rule="evenodd" clip-rule="evenodd"><path d="M22.5 57.8l35.3-35.3c1.4-1.4 3.6-1.4 5 0l.1.1c1.4 1.4 1.4 3.6 0 5L27.6 62.9c-1.4 1.4-3.6 1.4-5 0l-.1-.1c-1.3-1.4-1.3-3.6 0-5z"/><path d="M27.6 22.5l35.3 35.3c1.4 1.4 1.4 3.6 0 5l-.1.1c-1.4 1.4-3.6 1.4-5 0L22.5 27.6c-1.4-1.4-1.4-3.6 0-5l.1-.1c1.4-1.3 3.6-1.3 5 0z"/></g></svg>`),s=a(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 85.4 85.4"><path fill="#90591d" fill-rule="evenodd" clip-rule="evenodd" d="M17.8 39.1h49.9c1.9 0 3.5 1.6 3.5 3.5v.1c0 1.9-1.6 3.5-3.5 3.5H17.8c-1.9 0-3.5-1.6-3.5-3.5v-.1c0-1.9 1.5-3.5 3.5-3.5z"/></svg>`),c=a(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 85.4 85.4"><path fill="#006500" fill-rule="evenodd" clip-rule="evenodd" d="M31.2 20.8h26.7c3.6 0 6.5 2.9 6.5 6.5v26.7zm23.2 43.7H27.6c-3.6 0-6.5-2.9-6.5-6.5V31.2z"/></svg>`),l=e=>{t.style.backgroundImage=e?o:`none`,n.style.backgroundImage=e?s:`none`,r.style.backgroundImage=e?c:`none`,i.style.backgroundImage=e?c:`none`;for(let e of[t,n,r,i])e.style.backgroundSize=`100%`,e.style.backgroundPosition=`center`,e.style.backgroundRepeat=`no-repeat`};l(!1),e.addEventListener(`mouseenter`,()=>l(!0)),e.addEventListener(`mouseleave`,()=>l(!1))}function zk(e,t){let n=$(e,`wb-close`),r=$(e,`wb-min`),i=$(e,`wb-max`),a=$(e,`wb-full`);if(t)n.style.background=tk,r.style.background=nk,i.style.background=rk,a.style.background=rk;else{let e=ik;n.style.background=e,r.style.background=e,i.style.background=e,a.style.background=e}}function Bk(e,t,n){for(let r of n)switch(r){case`no-animation`:t.style.transition=`none`,e.noAnimation=!0;break;case`no-shadow`:t.style.boxShadow=`none`;break;case`no-header`:{$(t,`wb-header`).style.display=`none`;let e=$(t,`wb-body`);e.style.top=`0`,e.style.borderRadius=`10px`;break}case`no-min`:$(t,`wb-min`).style.display=`none`,e._optionHidden.add(`wb-min`);break;case`no-max`:$(t,`wb-max`).style.display=`none`,e._optionHidden.add(`wb-max`),e.noMax=!0;break;case`no-full`:$(t,`wb-full`).style.display=`none`,e._optionHidden.add(`wb-full`);break;case`no-close`:$(t,`wb-close`).style.display=`none`,e._optionHidden.add(`wb-close`);break;case`no-resize`:for(let e of dk)$(t,e).style.display=`none`;break;case`no-move`:e.noMove=!0;break}}function Vk(e,t,n){let r=$(t,`wb-body`),i=$(t,`wb-header`);n?(t.style.boxShadow=`none`,t.style.borderRadius=`0`,i.style.borderRadius=`0`,r.style.borderRadius=`0`,r.style.margin=`0`,Wk(t,`none`)):(t.style.boxShadow=`var(--shadow-window)`,t.style.borderRadius=`10px`,i.style.borderRadius=`10px 10px 0 0`,r.style.borderRadius=`0 0 10px 10px`,r.style.margin=``,Wk(t,``))}function Hk(e,t,n){let r=$(t,`wb-full`),i=$(t,`wb-min`),a=$(t,`wb-body`);if(n){r.style.display=`none`,i.style.display=`none`;for(let e of Array.from(a.children))e.style.display=`none`;Wk(t,`none`)}else{e._optionHidden.has(`wb-full`)||(r.style.display=``),e._optionHidden.has(`wb-min`)||(i.style.display=``);for(let e of Array.from(a.children))e.style.display=``;Wk(t,``)}}function Uk(e,t){let n=$(e,`wb-modal-bg`),r=$(e,`wb-modal-overlay`),i=$(e,`wb-drag`),a=$(e,`wb-min`),o=$(e,`wb-max`),s=$(e,`wb-full`);t?(n.style.display=`block`,r.style.display=`block`,r.animate([{opacity:0},{opacity:1}],{duration:200,easing:`ease-out`,fill:`forwards`}),i.style.pointerEvents=`none`,a.style.display=`none`,o.style.display=`none`,s.style.display=`none`,Wk(e,`none`)):(n.style.display=`none`,r.style.display=`none`,i.style.pointerEvents=``,a.style.display=``,o.style.display=``,s.style.display=``,Wk(e,``))}function Wk(e,t){for(let n of dk){let r=$(e,n);r&&(r.style.pointerEvents=t)}}function Gk(){Tk=document.body;let e=Tk;kk=typeof e.requestFullscreen==`function`?`requestFullscreen`:typeof e.msRequestFullscreen==`function`?`msRequestFullscreen`:typeof e.webkitRequestFullscreen==`function`?`webkitRequestFullscreen`:typeof e.mozRequestFullscreen==`function`?`mozRequestFullscreen`:``,Ak=kk?kk.replace(`request`,`exit`).replace(`mozRequest`,`mozCancel`).replace(`Request`,`Exit`):``,fk(window,`resize`,()=>{Xk(),Jk()}),fk(Tk,`mousedown`,()=>{Nk=!1},!0),fk(Tk,`mousedown`,()=>{if(!Nk)for(let e=Sk.length-1;e>=0;e--){let t=Sk[e];if(t?.focused){t.blur();break}}}),Xk()}function Kk(e){Yk(e,`drag`),Yk(e,`n`),Yk(e,`s`),Yk(e,`w`),Yk(e,`e`),Yk(e,`nw`),Yk(e,`ne`),Yk(e,`se`),Yk(e,`sw`),fk($(e.dom,`wb-min`),`click`,t=>{mk(t),e.min?e.restore().focus():e.minimize()}),fk($(e.dom,`wb-max`),`click`,t=>{mk(t),e.max?e.restore().focus():e.maximize().focus()}),kk?fk($(e.dom,`wb-full`),`click`,t=>{mk(t),e.fullscreen().focus()}):($(e.dom,`wb-full`).style.display=`none`,e._optionHidden.add(`wb-full`)),fk($(e.dom,`wb-close`),`click`,t=>{mk(t),e.close()}),fk(e.dom,`mousedown`,()=>{Nk=!0},!0),fk(e.body,`mousedown`,()=>{e.focus()},!0)}function qk(e){let t=xk.indexOf(e);t>=0&&xk.splice(t,1),Jk(),Hk(e,e.dom,!1),e.min=!1,e.dom.title=``}function Jk(){let e={},t={};for(let n=0;n<xk.length;n++){let r=xk[n],i=`${r.left}:${r.top}`;t[i]?t[i]+=1:(e[i]=0,t[i]=1)}for(let n=0;n<xk.length;n++){let r=xk[n],i=`${r.left}:${r.top}`,a=t[i]||1,o=Math.min((jk-r.left-r.right)/a,250);r.resize(o+1|0,r.header,!0).move(r.left+(e[i]||0)*o|0,Mk-r.bottom-r.header,!0),e[i]=(e[i]||0)+1}}function Yk(e,t){let n=$(e.dom,`wb-${t}`);if(!n)return;let r,i=0,a=0,o=!1,s=!1,c=0;fk(n,`mousedown`,u,Ck),fk(n,`touchstart`,u,Ck);function l(){requestAnimationFrame(l),s&&=(e.resize(),!1),o&&=(e.move(),!1)}function u(o){if(mk(o,!0),e.focus(),t===`drag`){if(e.min){e.restore();return}if(!e.noMax){let t=Date.now(),n=t-c;if(c=t,n<300){e.max?e.restore():e.maximize();return}}}if(!e.min){e.dom.style.willChange=`left, top, width, height`,e.dom.style.transition=`none`;for(let e of document.querySelectorAll(`iframe`))e.style.pointerEvents=`none`;t===`drag`?n.style.cursor=`grabbing`:n.style.cursor=uk[`wb-${t}`]||``;let s=o;r=o.touches?.[0],r?(fk(window,`touchmove`,d,wk),fk(window,`touchend`,f,wk)):(fk(window,`mousemove`,d,wk),fk(window,`mouseup`,f,wk)),i=r?r.pageX:s.pageX,a=r?r.pageY:s.pageY}}function d(n){mk(n);let o=r?n.touches[0]:n;if(!o)return;let s=o.pageX,c=o.pageY,l=s-i,u=c-a,d=e.width,f=e.height,p=e.x,m=e.y,h=!1,g=!1,_=!1,v=!1;if(t===`drag`){if(e.noMove)return;e.x+=l,e.y+=u,_=!0,v=!0}else t===`e`||t===`se`||t===`ne`?(e.width+=l,h=!0):(t===`w`||t===`sw`||t===`nw`)&&(e.x+=l,e.width-=l,h=!0,_=!0),t===`s`||t===`se`||t===`sw`?(e.height+=u,g=!0):(t===`n`||t===`ne`||t===`nw`)&&(e.y+=u,e.height-=u,g=!0,v=!0);h&&=(e.width=Math.max(Math.min(e.width,e.maxwidth,jk-e.x-e.right),e.minwidth),e.width!==d),g&&=(e.height=Math.max(Math.min(e.height,e.maxheight,Mk-e.y-e.bottom),e.minheight),e.height!==f),(h||g)&&e.resize(),_&&=((e.max||e.snapped)&&(e.x=(s<jk/3?e.left:s>jk/3*2?jk-e.width-e.right:jk/2-e.width/2)+l),e.x=Math.max(Math.min(e.x,e.overflow?jk-30:jk-e.width-e.right),e.overflow?30-e.width:e.left),e.x!==p),v&&=((e.max||e.snapped)&&(e.y=e.top+u),e.y=Math.max(Math.min(e.y,e.overflow?Mk-e.header:Mk-e.height-e.bottom),e.top),e.y!==m),(_||v)&&((e.max||e.snapped)&&e.restore(),e.move()),(h||_)&&(i=s),(g||v)&&(a=c)}function f(i){mk(i),e.dom.style.willChange=``,e.noAnimation||(e.dom.style.transition=ok,e.dom.style.transitionTimingFunction=sk);for(let e of document.querySelectorAll(`iframe`))e.style.pointerEvents=``;if(n.style.cursor=``,t===`drag`&&!e.max&&!e.snapped&&!e.noMax){let t=r?i.changedTouches?.[0]:i;if(t){let n=jk<768;!n&&t.pageX<=e.left+8?e.snap(`left`).focus():!n&&t.pageX>=jk-e.right-8?e.snap(`right`).focus():t.pageY<=e.top+8&&e.maximize().focus()}}r?(pk(window,`touchmove`,d,wk),pk(window,`touchend`,f,wk)):(pk(window,`mousemove`,d,wk),pk(window,`mouseup`,f,wk)),r=void 0}}function Xk(){let e=document.documentElement;jk=e.clientWidth,Mk=e.clientHeight}function Zk(){for(let e=Sk.length-1;e>=0;e--){let t=Sk[e];if(t&&!t.min){t.focus();break}}}function Qk(){let e=document;return!!(e.fullscreen||e.fullscreenElement||e.webkitFullscreenElement||e.mozFullScreenElement)}function $k(){if(Ok&&(Ok.full=!1,Qk()&&Ak)){let e=document,t=e[Ak];if(typeof t==`function`)return t.call(e),!0}}var eA=`piclaw:windows`;function tA(e){let t=new Map,n=null,r=localStorage.getItem(eA);if(!r)return{windows:t,focus:n};try{let i=JSON.parse(r);for(let[n,r]of Object.entries(i)){if(n===`_f`||!Array.isArray(r)||r.length<4)continue;let i=n.includes(`:`)?n.split(`:`)[0]:n;if(!e.has(i))continue;let[a,o,s,c,l,u]=r;if(![a,o,s,c].every(e=>typeof e==`number`&&Number.isFinite(e)))continue;let d={x:a,y:o,w:s,h:c};typeof l==`number`?(d.max=l===1,l===2&&(d.snap=`left`),l===3&&(d.snap=`right`),u&&typeof u==`object`&&!Array.isArray(u)&&(d.state=u)):l&&typeof l==`object`&&!Array.isArray(l)&&(d.state=l),t.set(n,d)}if(typeof i._f==`string`){let r=i._f.includes(`:`)?i._f.split(`:`)[0]:i._f;e.has(r)&&t.has(i._f)&&(n=i._f)}}catch{}return{windows:t,focus:n}}function nA(e,t,n,r){let i={};for(let r of e){let e=t.get(r.id);if(!e)continue;let a=e.snapped===`left`?2:e.snapped===`right`?3:e.max?1:0,o=[Math.round(e.x),Math.round(e.y),Math.round(e.width),Math.round(e.height),a],s=n[r.id];s&&Object.keys(s).length>0&&o.push(s),i[r.id]=o}r&&t.has(r)&&(i._f=r),Object.keys(i).length>0?localStorage.setItem(eA,JSON.stringify(i)):localStorage.removeItem(eA)}function rA(e){return Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue(e))||0}function iA(e){let t=e.indexOf(`:`);return t>=0?e.slice(0,t):e}function aA(e){let t=mu(),n=new Map(e.map(e=>[e.key,e])),{windows:r,focus:i}=tA(new Set(e.map(e=>e.key))),a=new Map,o=It([]),s=It({}),c=F(null),l=It({});for(let[e,t]of r)t.state&&(l[e]=t.state);let u=new Map,d;function f(){clearTimeout(d),d=setTimeout(()=>nA(o,u,l,c.value),300)}function p(e,t){let n=u.get(e);n&&n.setTitle(t)}function m(e,t){let n=l[e];n?Object.assign(n,t):l[e]={...t},f()}function h(e){if(!n.get(e)?.multi)return e;let t=(a.get(e)??0)+1;return a.set(e,t),`${e}:${t}`}function g(e){for(let t=o.length-1;t>=0;t--)if(o[t].appKey===e)return o[t].id;return null}function _(e,t){let r=iA(e),i=n.get(r);if(!i||typeof window>`u`)return null;if(!i.multi){let e=g(r);if(e){let n=u.get(e);if(n)return t&&m(e,t),s[e]=!1,n.min&&n.restore(),n.show(),n.focus(),f(),e}}let c=e.includes(`:`)?e:h(r);if(i.multi&&c.includes(`:`)){let e=Number(c.split(`:`)[1]);e>=(a.get(r)??0)&&a.set(r,e)}let d=C(c,i);if(!d)return null;t&&(l[c]={...l[c],...t});let p=It({id:c,appKey:r,app:i,mountTarget:d.body});return o.push(p),s[c]=!1,d.show(),d.focus(),f(),c}function v(e){if(u.has(e)){let t=u.get(e);t.min&&(s[e]=!1,t.restore()),t.show(),t.focus();return}let t=iA(e);if(!n.get(t))return;let r=g(t);if(r){let e=u.get(r);e.min&&(s[r]=!1,e.restore()),e.show(),e.focus();return}_(t)}function y(e){let t=u.get(e);t&&!t.min&&t.minimize()}function b(e){let t=u.get(e);if(!t){x(e);return}t.close()}function x(e){let t=o.findIndex(t=>t.id===e);t>=0&&o.splice(t,1),delete s[e],delete l[e],u.delete(e),T(),f()}function S(e,t){let n=window.innerWidth,r=window.innerHeight,i=[];for(let e of u.values())i.push({x:e.x,y:e.y,r:e.x+e.width,b:e.y+e.height});if(i.length===0)return{x:Math.max(0,n*.55-e/2),y:Math.max(0,(r-t)/2)};let a=(r,a)=>{let o=0;for(let n of i){let i=Math.max(0,Math.min(r+e,n.r)-Math.max(r,n.x)),s=Math.max(0,Math.min(a+t,n.b)-Math.max(a,n.y));o+=i*s}let s=Math.max(0,1-r/n)*e*t*.15;return o+s},o=[];for(let n of i)o.push({x:n.r+16,y:n.y}),o.push({x:n.r+16,y:Math.max(0,n.y+n.b-n.y)/2}),o.push({x:n.x,y:n.b+16}),o.push({x:n.x-e-16,y:n.y}),o.push({x:n.x,y:n.y-t-16});o.push({x:n-e-16,y:16}),o.push({x:n-e-16,y:(r-t)/2}),o.push({x:n-e-16,y:r-t-16}),o.push({x:Math.max(0,(n-e)/2),y:Math.max(0,(r-t)/2)}),o.push({x:16,y:16});let s=o.filter(i=>i.x>=0&&i.y>=0&&i.x+e<=n&&i.y+t<=r);if(s.length>0){let e=s[0],t=a(e.x,e.y);for(let n=1;n<s.length;n++){let r=s[n],i=a(r.x,r.y);i<t&&(e=r,t=i)}return e}let c=i.length%Math.max(1,Math.floor((r-t)/32));return{x:Math.max(16,n-e-16-c*32),y:Math.max(16,16+c*32)}}function C(e,n){if(typeof window>`u`)return null;let i=n.window,a=r.get(e),o=t.value,l=o?void 0:a?.snap,d=!l&&(a?.max||o),p=a?a.w:Math.min(i.width,window.innerWidth-32),m=a?a.h:Math.min(i.height,window.innerHeight-64),h=a?{x:a.x,y:a.y}:S(p,m),g=rA(`--sat`),_=rA(`--sab`),v=rA(`--sal`),y=rA(`--sar`);h.x=Math.max(h.x,v),h.y=Math.max(h.y,g);let b=new Pk({id:`piclaw-${e}`,title:n.label,width:p,height:m,minwidth:i.minwidth,minheight:i.minheight,x:h.x,y:h.y,max:d,top:g,bottom:o?44:_,left:v,right:y,class:`no-full`,header:o?32:38,onfocus:()=>{c.value=e,f()},onblur:()=>{T()},onmove:()=>{f()},onresize:()=>{f()},onminimize:()=>{s[e]=!0,T(),f()},onmaximize:()=>{f()},onrestore:()=>{s[e]=!1,f()},onsnap:()=>{f()},onclose:()=>{x(e)}});return b.body.style.margin=`0`,l&&b.snap(l),u.set(e,b),b}function w(){if(r.size!==0){for(let[e]of r)_(e,r.get(e)?.state);i&&r.has(i)&&v(i)}}function T(){for(let e=o.length-1;e>=0;e--){let t=o[e];if(!s[t.id]&&u.has(t.id)){c.value=t.id;return}}c.value=null}function ee(e=!1){let t=o.filter(e=>!s[e.id]);if(t.length<=1)return;let n=t[(t.findIndex(e=>e.id===c.value)+(e?-1:1)+t.length)%t.length];v(n.id)}function E(e,t){let n=u.get(e);n&&n.snap(t).focus()}function D(e){let t=u.get(e);t&&(t.max?t.restore().focus():t.maximize().focus())}function O(e){if(e.altKey&&e.key===`Tab`)e.preventDefault(),ee(e.shiftKey);else if(e.altKey&&(e.code===`KeyW`||e.code===`KeyQ`))e.preventDefault(),c.value&&b(c.value);else if(e.altKey&&e.key===`ArrowLeft`)e.preventDefault(),c.value&&!t.value&&E(c.value,`left`);else if(e.altKey&&e.key===`ArrowRight`)e.preventDefault(),c.value&&!t.value&&E(c.value,`right`);else if(e.altKey&&e.key===`ArrowUp`)e.preventDefault(),c.value&&D(c.value);else if(e.altKey&&e.key===`ArrowDown`&&(e.preventDefault(),c.value)){let e=u.get(c.value);e&&(e.max||e.snapped)&&e.restore().focus()}}return window.addEventListener(`keydown`,O),zr(()=>{clearTimeout(d),window.removeEventListener(`keydown`,O);for(let e of u.values())e.close(!0);u.clear(),o.length=0}),{openInstances:o,minimized:s,focusedWindow:c,windowState:l,setWindowState:m,setWindowTitle:p,openWindow:_,bringToFront:v,minimizeWindow:y,closeWindow:b,restore:w}}var oA=z({__name:`App`,setup(e){let{openInstances:t,minimized:n,focusedWindow:r,windowState:i,setWindowState:a,setWindowTitle:o,bringToFront:s,minimizeWindow:c,openWindow:l,closeWindow:u,restore:d}=aA(zO);Bn(Zl,{windowState:i,setWindowState:a,setWindowTitle:o,bringToFront:s,openWindow:l,closeWindow:u});let f=F();function p(e){e.preventDefault()}return Br(()=>window.removeEventListener(`beforeunload`,p)),Ir(async()=>{await Tn(),d(),t.length===0&&(localStorage.getItem(`piclaw:visited`)||(localStorage.setItem(`piclaw:visited`,`1`),l(`welcome`)))}),(e,i)=>(V(),H(`div`,{class:`bg-bg text-text font-sans leading-normal flex flex-col relative text-[13px]`,style:{height:`100%`},onContextmenu:i[1]||=ws(()=>{},[`prevent`]),onClick:i[2]||=e=>f.value?.closeCtxMenu()},[W(iu,{ref_key:`desktop`,ref:f,apps:L(zO),"open-instances":L(t),onLaunch:L(l),onCtxAction:i[0]||=e=>{e===`settings`&&L(l)(`settings`)}},null,8,[`apps`,`open-instances`,`onLaunch`]),W(ek,{"open-instances":L(t),minimized:L(n),"focused-window":L(r),onLaunch:L(l),onFocus:L(s),onMinimize:L(c),onClose:L(u)},null,8,[`open-instances`,`minimized`,`focused-window`,`onLaunch`,`onFocus`,`onMinimize`,`onClose`]),W(lu)],32))}});Sp(),As(oA).mount(`#app`),`serviceWorker`in navigator&&navigator.serviceWorker.register(`/sw.js`);export{Ep as t};