@oneworks/client 0.1.0-alpha.0 → 0.1.0-beta.0

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/dist/assets/ActionSearchToolbar-8q-bk3mu.js +1 -0
  2. package/dist/assets/ActionSearchToolbar-CMBns0Zm.css +1 -0
  3. package/dist/assets/AgentRoomRoute-DfSI_dFH.js +1 -0
  4. package/dist/assets/AgentRoomSessionRoute-DH9PdjZm.js +3 -0
  5. package/dist/assets/ArchiveRoute-E9-htB4H.js +1 -0
  6. package/dist/assets/{AuthenticatedApp-BTs4l2pB.js → AuthenticatedApp-CgBrvMuc.js} +236 -224
  7. package/dist/assets/AuthenticatedApp-scWyvbOf.css +1 -0
  8. package/dist/assets/AutomationRoute-Bw2xw5bx.js +1 -0
  9. package/dist/assets/BenchmarkRoute-3VS17jHr.js +21 -0
  10. package/dist/assets/ChatRoute-CBQ3j4Je.js +2 -0
  11. package/dist/assets/Collapse-B-oCiEx4.js +10 -0
  12. package/dist/assets/{ComposerLanding-Cl6zfbOm.js → ComposerLanding-SZn_zRGX.js} +4 -4
  13. package/dist/assets/ConfigEditors-BuDavOAj.css +1 -0
  14. package/dist/assets/ConfigRoute-Dv-7BRGG.js +28 -0
  15. package/dist/assets/ConfigRoute-TW2qRRNP.css +1 -0
  16. package/dist/assets/InteractionStructureRoute-FDl9jRvT.js +1 -0
  17. package/dist/assets/KnowledgeRoute-C5em_VSL.js +1 -0
  18. package/dist/assets/LauncherApp-olYmK_zO.js +2 -0
  19. package/dist/assets/LauncherRoute-NsK8KCzb.css +1 -0
  20. package/dist/assets/LauncherRoute-Qt8dQkIk.js +2 -0
  21. package/dist/assets/MobileAwareSelect-BmK6WApn.js +37 -0
  22. package/dist/assets/MobileAwareSelect-BySpAJpa.css +1 -0
  23. package/dist/assets/{ModuleManagementRoute-DQACRan1.js → ModuleManagementRoute-B1I_8JKc.js} +3 -3
  24. package/dist/assets/NotFoundRoute-Bj6_YY3I.js +1 -0
  25. package/dist/assets/PluginStoreRoute-B847PAZ5.js +1 -0
  26. package/dist/assets/PluginStoreRoute-Cfalv335.css +1 -0
  27. package/dist/assets/RouteContainerPanelTabs-BnIptVwq.js +11 -0
  28. package/dist/assets/RouteContainerPanelTabs-DAjUmk7i.css +1 -0
  29. package/dist/assets/SchemaObjectEditor-B9fPfDyT.js +1 -0
  30. package/dist/assets/StandaloneMobileDebugRoute-BR4w_LeM.js +1 -0
  31. package/dist/assets/StandaloneMobileDebugRoute-DuOLjUb9.css +1 -0
  32. package/dist/assets/WorkspaceApp-BNmtIdn4.js +9 -0
  33. package/dist/assets/agent-room-session-paths-CYMSFD9m.css +32 -0
  34. package/dist/assets/agent-room-session-paths-Dca8S6NN.js +537 -0
  35. package/dist/assets/{arc-BXsvCKst.js → arc-JBUpUV6M.js} +1 -1
  36. package/dist/assets/azure-C6wcxVWu.ico +0 -0
  37. package/dist/assets/{blockDiagram-c4efeb88-hc-xNCrG.js → blockDiagram-c4efeb88-DKhNwgEQ.js} +2 -2
  38. package/dist/assets/{c4Diagram-c83219d4-DVHTOuVr.js → c4Diagram-c83219d4-CWODEGms.js} +2 -2
  39. package/dist/assets/channel-BsuHYNQO.js +1 -0
  40. package/dist/assets/classDiagram-beda092f-DlghsOqF.js +2 -0
  41. package/dist/assets/classDiagram-v2-2358418a-CrSR8gWz.js +2 -0
  42. package/dist/assets/client-build-info-bcijLdfD.js +1 -0
  43. package/dist/assets/clone-BKV6leIk.js +1 -0
  44. package/dist/assets/{createText-1719965b-x3Mhf0Jh.js → createText-1719965b-CLlPr73k.js} +1 -1
  45. package/dist/assets/cssMode-Bt_74RVV.js +1 -0
  46. package/dist/assets/customParseFormat-DwjB960X.js +1 -0
  47. package/dist/assets/dockPanelConstants-4XXOUD0A.css +1 -0
  48. package/dist/assets/dockPanelConstants-BWuu_DJp.js +8 -0
  49. package/dist/assets/{edges-96097737-COVuSxRY.js → edges-96097737-L_gy1fky.js} +1 -1
  50. package/dist/assets/{erDiagram-0228fc6a-WcgqCWce.js → erDiagram-0228fc6a-X1QMD6me.js} +2 -2
  51. package/dist/assets/{flowDb-c6c81e3f-nYly38YN.js → flowDb-c6c81e3f-DNdWK0Po.js} +1 -1
  52. package/dist/assets/{flowDiagram-50d868cf-DLYALlBY.js → flowDiagram-50d868cf-C2khStgw.js} +2 -2
  53. package/dist/assets/flowDiagram-v2-4f6560a1-DW5hyUju.js +1 -0
  54. package/dist/assets/{flowchart-elk-definition-6af322e1-Da8rP8k4.js → flowchart-elk-definition-6af322e1-C89sxd2D.js} +2 -2
  55. package/dist/assets/{freemarker2-OWISI6Bb.js → freemarker2-DZ1XIuHj.js} +2 -2
  56. package/dist/assets/ganttDiagram-a2739b55-Ba3rPNKd.js +257 -0
  57. package/dist/assets/gemini-B9inYaVW.png +0 -0
  58. package/dist/assets/{gitGraphDiagram-82fe8481-DCk8Jny9.js → gitGraphDiagram-82fe8481-DTEFHHtN.js} +2 -2
  59. package/dist/assets/{graph-DvFQr_wY.js → graph-BPujwFoF.js} +1 -1
  60. package/dist/assets/handlebars-lOgsnnQw.js +1 -0
  61. package/dist/assets/html-DLHadu9L.js +1 -0
  62. package/dist/assets/htmlMode-VeiQ-IsQ.js +1 -0
  63. package/dist/assets/{index-5325376f-CRF6GGjL.js → index-5325376f-Cx2RM6pk.js} +1 -1
  64. package/dist/assets/{index-BnZLa3J3.js → index-CBFCjoHv.js} +2 -2
  65. package/dist/assets/index-CJEVYkL9.js +1 -0
  66. package/dist/assets/index-CWmEuVWV.js +36 -0
  67. package/dist/assets/index-Cp4GfHnF.js +727 -0
  68. package/dist/assets/index-D4eelxQF.js +13 -0
  69. package/dist/assets/index-DBUG8CzV.js +3 -0
  70. package/dist/assets/index-jfuA2A4w.css +1 -0
  71. package/dist/assets/index-sFqkb8xv.js +13 -0
  72. package/dist/assets/{infoDiagram-8eee0895-dVa2Kh9_.js → infoDiagram-8eee0895-Bj9hWnDg.js} +2 -2
  73. package/dist/assets/interaction-panel-mobile-debug-pages-1Gdivksn.js +113 -0
  74. package/dist/assets/interaction-panel-mobile-debug-pages-8AAd4Csf.css +1 -0
  75. package/dist/assets/javascript-CXJw-bvU.js +1 -0
  76. package/dist/assets/{journeyDiagram-c64418c1-BJCT1TJ7.js → journeyDiagram-c64418c1-BXAycrrn.js} +2 -2
  77. package/dist/assets/{jsonMode-RsjNGxUQ.js → jsonMode-DmUNJfpX.js} +4 -4
  78. package/dist/assets/{layout-BMZRkCUf.js → layout-Bp8GVMnq.js} +1 -1
  79. package/dist/assets/{line-C99msl9T.js → line-olpPNgnh.js} +1 -1
  80. package/dist/assets/{linear-CJHB38BG.js → linear-flh_7ux_.js} +1 -1
  81. package/dist/assets/liquid-BiVpRgBP.js +1 -0
  82. package/dist/assets/{lspLanguageFeatures-D8zjArb3.js → lspLanguageFeatures-olWF83eX.js} +1 -1
  83. package/dist/assets/mdx-B5dr7YB-.js +1 -0
  84. package/dist/assets/{mermaid.core-DWzpZH_g.js → mermaid.core-NVIiXnRA.js} +4 -4
  85. package/dist/assets/micu-dUcmmgZZ.png +0 -0
  86. package/dist/assets/{mindmap-definition-8da855dc-DulNL_Ks.js → mindmap-definition-8da855dc-BOCh8K8K.js} +2 -2
  87. package/dist/assets/minimax-B5WRVrUt.png +0 -0
  88. package/dist/assets/openai-ABb0YGGa.svg +71 -0
  89. package/dist/assets/openrouter-CsJ_bD5Q.ico +0 -0
  90. package/dist/assets/{pieDiagram-a8764435-CHfubQBm.js → pieDiagram-a8764435-CCitKBQK.js} +3 -3
  91. package/dist/assets/project-file-tree-icons-DXkdVC0r.css +1 -0
  92. package/dist/assets/project-file-tree-icons-DqqhgvoI.js +2 -0
  93. package/dist/assets/python-BkEOPIle.js +1 -0
  94. package/dist/assets/{quadrantDiagram-1e28029f-CFHca9nu.js → quadrantDiagram-1e28029f-C_FvcHzZ.js} +2 -2
  95. package/dist/assets/qwen-Cla2cGrM.svg +107 -0
  96. package/dist/assets/razor-BCMQgdis.js +1 -0
  97. package/dist/assets/requesty-DAzbbw8F.ico +0 -0
  98. package/dist/assets/{requirementDiagram-08caed73-ClrFG92W.js → requirementDiagram-08caed73-B001ugYd.js} +2 -2
  99. package/dist/assets/route-plugin-chrome-B-Goj3vG.js +1 -0
  100. package/dist/assets/sankeyDiagram-a04cb91d-BnkC9YW5.js +8 -0
  101. package/dist/assets/{sequenceDiagram-c5b8d532-ZoeuLa-n.js → sequenceDiagram-c5b8d532-BGiFCs5z.js} +2 -2
  102. package/dist/assets/shortcutUtils-20iqPDwh.js +27 -0
  103. package/dist/assets/stateDiagram-1ecb1508-Uk4XxTkP.js +1 -0
  104. package/dist/assets/stateDiagram-v2-c2b004d7-Db6Ouywh.js +1 -0
  105. package/dist/assets/{styles-b4e223ce-0VFG2Z9W.js → styles-b4e223ce-CfG45yIm.js} +1 -1
  106. package/dist/assets/{styles-ca3715f6-DaJIsB-N.js → styles-ca3715f6-BGGbMvKc.js} +1 -1
  107. package/dist/assets/{styles-d45a18b0-DT8DH24o.js → styles-d45a18b0-mHteeqS2.js} +1 -1
  108. package/dist/assets/{svgDrawCommon-b86b1483-DxTZXiLW.js → svgDrawCommon-b86b1483-BAMR2PsF.js} +1 -1
  109. package/dist/assets/{timeline-definition-faaaa080-lu3ppiNq.js → timeline-definition-faaaa080-DLBoPuJD.js} +2 -2
  110. package/dist/assets/{tsMode-B6pOKC1l.js → tsMode-BTzZ8Zos.js} +2 -2
  111. package/dist/assets/typescript-_rLmAd51.js +1 -0
  112. package/dist/assets/use-app-preferences-gyulV-hA.js +1 -0
  113. package/dist/assets/use-chat-session-actions-DDZ5KCua.js +2 -0
  114. package/dist/assets/{vendor-react-BNJ5yonH.js → vendor-react-CnooHTJc.js} +1 -1
  115. package/dist/assets/vendor-state-BYwEPTaO.js +1 -0
  116. package/dist/assets/worker-BZxxbL_z.js +1 -0
  117. package/dist/assets/workspace-file-openers-BwZ5cSeq.js +1 -0
  118. package/dist/assets/workspace-file-openers-fM4AQXug.css +1 -0
  119. package/dist/assets/xml-BAU8TJ-c.js +1 -0
  120. package/dist/assets/{xychartDiagram-f5964ef8-DvmrNK0s.js → xychartDiagram-f5964ef8-CNfcxTsi.js} +2 -2
  121. package/dist/assets/yaml-_cphTIn0.js +1 -0
  122. package/dist/assets/yunwu-C0h7koCA.png +0 -0
  123. package/dist/assets/zhipu-CWmkm5qz.png +0 -0
  124. package/dist/index.html +4 -4
  125. package/dist/sw.js +5 -3
  126. package/package.json +20 -15
  127. package/dist/assets/AgentRoomRoute-rNmmPMvh.js +0 -1
  128. package/dist/assets/AgentRoomSessionRoute-Dg8yQRY_.js +0 -1
  129. package/dist/assets/ArchiveRoute-BWE_JVjl.js +0 -1
  130. package/dist/assets/AuthenticatedApp-Bop-GglJ.css +0 -1
  131. package/dist/assets/AutomationRoute-CoJ8YGK2.js +0 -1
  132. package/dist/assets/BenchmarkRoute-BcRZ1AFC.js +0 -21
  133. package/dist/assets/ChatRoute-DBN4uo7j.js +0 -1
  134. package/dist/assets/Collapse-DDrFhfKr.js +0 -8
  135. package/dist/assets/ConfigEditors-jcXiTWRg.css +0 -1
  136. package/dist/assets/ConfigRoute-D5zxs-kv.css +0 -1
  137. package/dist/assets/ConfigRoute-z5Dj1ihn.js +0 -2
  138. package/dist/assets/ConfigSectionPanel-DHIwutHm.js +0 -13
  139. package/dist/assets/DockPanel-DuxVeJzf.js +0 -11
  140. package/dist/assets/DockPanel-HEMeJ1MR.css +0 -1
  141. package/dist/assets/InteractionStructureRoute-B8yJdycA.js +0 -1
  142. package/dist/assets/KnowledgeRoute-BPYnBocT.js +0 -1
  143. package/dist/assets/LauncherApp-BqKOigOK.js +0 -2
  144. package/dist/assets/LauncherRoute-C1g-gjbs.js +0 -2
  145. package/dist/assets/LauncherRoute-DtjtKtXc.css +0 -1
  146. package/dist/assets/PluginStoreRoute-Bny2x-oC.css +0 -1
  147. package/dist/assets/PluginStoreRoute-CGIBez_4.js +0 -3
  148. package/dist/assets/SchemaObjectEditor-BdzgIkYh.js +0 -1
  149. package/dist/assets/WorkspaceApp-DGL3CHCp.js +0 -46
  150. package/dist/assets/agent-room-session-paths-Bl0JdX79.js +0 -153
  151. package/dist/assets/agent-room-session-paths-CCE5rS0K.css +0 -32
  152. package/dist/assets/channel-X7k9544o.js +0 -1
  153. package/dist/assets/classDiagram-beda092f-C--_J0De.js +0 -2
  154. package/dist/assets/classDiagram-v2-2358418a-VLoB_o-4.js +0 -2
  155. package/dist/assets/client-build-info-CUyezPn4.js +0 -37
  156. package/dist/assets/client-build-info-CgBKDSmG.css +0 -1
  157. package/dist/assets/clone-BsR4Dtrm.js +0 -1
  158. package/dist/assets/copy-OJ_6Pvs2.js +0 -28
  159. package/dist/assets/cssMode-Dg95dCSS.js +0 -1
  160. package/dist/assets/flowDiagram-v2-4f6560a1-DZXqc8d3.js +0 -1
  161. package/dist/assets/ganttDiagram-a2739b55-SFoaaNUl.js +0 -257
  162. package/dist/assets/handlebars-DvhbIeVz.js +0 -1
  163. package/dist/assets/html-B6ANaoGC.js +0 -1
  164. package/dist/assets/htmlMode-CA_KA1J8.js +0 -1
  165. package/dist/assets/index-BfLbHhFR.js +0 -13
  166. package/dist/assets/index-C9FQLbWu.js +0 -1
  167. package/dist/assets/index-DA1kZA8X.css +0 -1
  168. package/dist/assets/index-Dn-Bbs_z.js +0 -705
  169. package/dist/assets/javascript-qaeO24NX.js +0 -1
  170. package/dist/assets/liquid-yYJuHMAu.js +0 -1
  171. package/dist/assets/mdx-CrAkCLhE.js +0 -1
  172. package/dist/assets/python-h0Aqhxqi.js +0 -1
  173. package/dist/assets/razor-DalkOWO-.js +0 -1
  174. package/dist/assets/sankeyDiagram-a04cb91d-C9DgEVjM.js +0 -8
  175. package/dist/assets/stateDiagram-1ecb1508-DDRxhJDf.js +0 -1
  176. package/dist/assets/stateDiagram-v2-c2b004d7-CIob4OCF.js +0 -1
  177. package/dist/assets/typescript-Bn-lx_lA.js +0 -1
  178. package/dist/assets/use-app-preferences-B4K999VJ.js +0 -1
  179. package/dist/assets/use-chat-session-actions-5N-NQ9my.js +0 -2
  180. package/dist/assets/use-project-theme-preview-sources-5CPt1X2N.js +0 -1
  181. package/dist/assets/vendor-state-CBVXPiKY.js +0 -1
  182. package/dist/assets/workspace-file-openers-DAuX65xw.js +0 -1
  183. package/dist/assets/workspace-file-openers-erSFu-UO.css +0 -1
  184. package/dist/assets/xml-C1SO5DSd.js +0 -1
  185. package/dist/assets/yaml-DihjE03_.js +0 -1
@@ -1,11 +0,0 @@
1
- import{R as O,a as Cn,r as x,c as Dn,j as V}from"./vendor-react-BNJ5yonH.js";import{bu as Wt,bv as Ht,bw as Ft,a4 as ft,bx as yn}from"./AuthenticatedApp-BTs4l2pB.js";import{D as Bt}from"./copy-OJ_6Pvs2.js";import{T as xn}from"./client-build-info-CUyezPn4.js";import{av as ni}from"./index-Dn-Bbs_z.js";/**
2
- * dockview-core
3
- * @version 6.2.2
4
- * @link https://github.com/mathuo/dockview
5
- * @license MIT
6
- */class zi{}class Ce extends zi{constructor(e,t,i,n){super(),this.viewId=e,this.groupId=t,this.panelId=i,this.tabGroupId=n}}class qe extends zi{constructor(e,t){super(),this.viewId=e,this.paneId=t}}class De{constructor(){}static getInstance(){return De.INSTANCE}hasData(e){return e&&e===this.proto}clearData(e){this.hasData(e)&&(this.proto=void 0,this.data=void 0)}getData(e){if(this.hasData(e))return this.data}setData(e,t){t&&(this.data=e,this.proto=t)}}De.INSTANCE=new De;function re(){const o=De.getInstance();if(o.hasData(Ce.prototype))return o.getData(Ce.prototype)[0]}function Ye(){const o=De.getInstance();if(o.hasData(qe.prototype))return o.getData(qe.prototype)[0]}var ne;(function(o){o.NONE={dispose:()=>{}};function e(t){return{dispose:()=>{t()}}}o.from=e})(ne||(ne={}));class R{get isDisposed(){return this._isDisposed}constructor(...e){this._isDisposed=!1,this._disposables=new Set(e)}addDisposables(...e){e.forEach(t=>this._disposables.add(t))}removeDisposable(e){this._disposables.delete(e)}dispose(){this._isDisposed||(this._isDisposed=!0,this._disposables.forEach(e=>e.dispose()),this._disposables.clear())}}class le{constructor(){this._disposable=ne.NONE}set value(e){this._disposable&&this._disposable.dispose(),this._disposable=e}dispose(){this._disposable&&(this._disposable.dispose(),this._disposable=ne.NONE)}}var He;(function(o){o.any=(...e)=>t=>{const i=e.map(n=>n(t));return{dispose:()=>{i.forEach(n=>{n.dispose()})}}}})(He||(He={}));class $t{constructor(){this._defaultPrevented=!1}get defaultPrevented(){return this._defaultPrevented}preventDefault(){this._defaultPrevented=!0}}class ki{constructor(){this._isAccepted=!1}get isAccepted(){return this._isAccepted}accept(){this._isAccepted=!0}}class Sn{constructor(){this.events=new Map}get size(){return this.events.size}add(e,t){this.events.set(e,t)}delete(e){this.events.delete(e)}clear(){this.events.clear()}}class gt{static create(){var e;return new gt((e=new Error().stack)!==null&&e!==void 0?e:"")}constructor(e){this.value=e}print(){console.warn("dockview: stacktrace",this.value)}}class Pn{constructor(e,t){this.callback=e,this.stacktrace=t}}class _{static setLeakageMonitorEnabled(e){e!==_.ENABLE_TRACKING&&_.MEMORY_LEAK_WATCHER.clear(),_.ENABLE_TRACKING=e}get value(){return this._last}constructor(e){this.options=e,this._listeners=[],this._disposed=!1,this._pauseTokens=new Set}get event(){return this._event||(this._event=e=>{var t;!((t=this.options)===null||t===void 0)&&t.replay&&this._last!==void 0&&e(this._last);const i=new Pn(e,_.ENABLE_TRACKING?gt.create():void 0);return this._listeners.push(i),{dispose:()=>{const n=this._listeners.indexOf(i);n>-1&&this._listeners.splice(n,1)}}},_.ENABLE_TRACKING&&_.MEMORY_LEAK_WATCHER.add(this._event,gt.create())),this._event}fire(e){var t;if(!(this._pauseTokens.size>0)){!((t=this.options)===null||t===void 0)&&t.replay&&(this._last=e);for(const i of this._listeners)i.callback(e)}}pause(){const e={};return this._pauseTokens.add(e),ne.from(()=>this._pauseTokens.delete(e))}dispose(){this._disposed||(this._disposed=!0,this._listeners.length>0&&(_.ENABLE_TRACKING&&queueMicrotask(()=>{var e;for(const t of this._listeners)console.warn("dockview: stacktrace",(e=t.stacktrace)===null||e===void 0?void 0:e.print())}),this._listeners=[]),_.ENABLE_TRACKING&&this._event&&_.MEMORY_LEAK_WATCHER.delete(this._event))}}_.ENABLE_TRACKING=!1;_.MEMORY_LEAK_WATCHER=new Sn;function k(o,e,t,i){return o.addEventListener(e,t,i),{dispose:()=>{o.removeEventListener(e,t,i)}}}class si{constructor(){this._onFired=new _,this._currentFireCount=0,this._queued=!1,this.onEvent=e=>{const t=this._currentFireCount;return this._onFired.event(()=>{this._currentFireCount>t&&e()})}}fire(){this._currentFireCount++,!this._queued&&(this._queued=!0,queueMicrotask(()=>{this._queued=!1,this._onFired.fire()}))}dispose(){this._onFired.dispose()}}class Gn extends R{constructor(e){super(),this._onDidChange=new _,this.onDidChange=this._onDidChange.event,this._value=null,this.addDisposables(this._onDidChange,tt(e,t=>{const i=t.target.scrollWidth>t.target.clientWidth,n=t.target.scrollHeight>t.target.clientHeight;this._value={hasScrollX:i,hasScrollY:n},this._onDidChange.fire(this._value)}))}}function tt(o,e){const t=new ResizeObserver(i=>{requestAnimationFrame(()=>{const n=i[0];e(n)})});return t.observe(o),{dispose:()=>{t.unobserve(o),t.disconnect()}}}const ye=(o,...e)=>{for(const t of e)o.classList.contains(t)&&o.classList.remove(t)},xe=(o,...e)=>{for(const t of e)o.classList.contains(t)||o.classList.add(t)},A=(o,e,t)=>{const i=o.classList.contains(e);t&&!i&&o.classList.add(e),!t&&i&&o.classList.remove(e)};function Et(o,e){for(;o;){if(o===e)return!0;o=o.parentNode}return!1}function Oi(o){return new An(o)}class An extends R{constructor(e){super(),this._onDidFocus=new _,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new _,this.onDidBlur=this._onDidBlur.event,this.addDisposables(this._onDidFocus,this._onDidBlur);let t=Et(document.activeElement,e),i=!1;const n=()=>{i=!1,t||(t=!0,this._onDidFocus.fire())},s=()=>{t&&(i=!0,window.setTimeout(()=>{i&&(i=!1,t=!1,this._onDidBlur.fire())},0))};this._refreshStateHandler=()=>{Et(document.activeElement,e)!==t&&(t?s():n())},this.addDisposables(k(e,"focus",n,!0)),this.addDisposables(k(e,"blur",s,!0))}refreshState(){this._refreshStateHandler()}}const Ri="dv-quasiPreventDefault";function In(o){o[Ri]=!0}function oi(o){return o[Ri]}function En(o,e){const t=Array.from(e);for(const i of t){if(i.href){const s=o.createElement("link");s.href=i.href,s.type=i.type,s.rel="stylesheet",o.head.appendChild(s)}let n=[];try{i.cssRules&&(n=Array.from(i.cssRules).map(s=>s.cssText))}catch(s){console.warn("dockview: failed to access stylesheet rules due to security restrictions",s)}for(const s of n){const l=o.createElement("style");l.appendChild(o.createTextNode(s)),o.head.appendChild(l)}}}function Tt(o){const{left:e,top:t,width:i,height:n}=o.getBoundingClientRect();return{left:e+window.scrollX,top:t+window.scrollY,width:i,height:n}}function Tn(o){let e=o;for(;e!=null&&e.parentNode;){if(e.parentNode===document)return!0;e.parentNode instanceof DocumentFragment?e=e.parentNode.host:e=e.parentNode}return!1}function zn(o,e){o.setAttribute("data-testid",e)}function kn(o){const e=[];function t(i){if(i.nodeType===Node.ELEMENT_NODE){o.includes(i.tagName)&&e.push(i),i.shadowRoot&&t(i.shadowRoot);for(const n of i.children)t(n)}}return t(document.documentElement),e}function Qe(o=document){const e=kn(["IFRAME","WEBVIEW"]),t=new WeakMap;for(const i of e)t.set(i,i.style.pointerEvents),i.style.pointerEvents="none";return{release:()=>{var i;for(const n of e)n.style.pointerEvents=(i=t.get(n))!==null&&i!==void 0?i:"auto";e.splice(0,e.length)}}}function On(o){function e(n){const s=[];for(let l=0;l<n.classList.length;l++)s.push(n.classList.item(l));return s}let t,i=o;for(;i!==null&&(t=e(i).find(n=>n.startsWith("dockview-theme-")),typeof t!="string");)i=i.parentElement;return t}class bt{constructor(e){this.element=e,this._classNames=[]}setClassNames(e){for(const t of this._classNames)A(this.element,t,!1);this._classNames=e.split(" ").filter(t=>t.trim().length>0);for(const t of this._classNames)A(this.element,t,!0)}}const Vi=100;function ri(o,e){const t=Tt(o),i=Tt(e);return!(t.left<i.left||t.left+t.width>i.left+i.width||t.top<i.top||t.top+t.height>i.top+i.height)}function Rn(o){const e=new _;let t=o.screenX,i=o.screenY,n;const s=()=>{if(o.closed)return;const l=o.screenX,a=o.screenY;(l!==t||a!==i)&&(clearTimeout(n),n=setTimeout(()=>{e.fire()},Vi),t=l,i=a),requestAnimationFrame(s)};return s(),e}function Vn(o,e){let t;return new R(k(o,"resize",()=>{clearTimeout(t),t=setTimeout(()=>{e()},Vi)}))}function Mn(o,e,t={buffer:10}){const i=t.buffer,n=o.getBoundingClientRect(),s=e.getBoundingClientRect();let l=0,a=0;const r=n.left-s.left,d=n.top-s.top,h=n.bottom-s.bottom,c=n.right-s.right;r<i?l=i-r:c>i&&(l=-i-c),d<i?a=i-d:h>i&&(a=-h-i),(l!==0||a!==0)&&(o.style.transform=`translate(${l}px, ${a}px)`)}function Mi(o){let e=o;for(;e&&(e.style.zIndex==="auto"||e.style.zIndex==="");)e=e.parentElement;return e}function ze(o){if(o.length===0)throw new Error("Invalid tail call");return[o.slice(0,o.length-1),o[o.length-1]]}function Ni(o,e){if(o.length!==e.length)return!1;for(let t=0;t<o.length;t++)if(o[t]!==e[t])return!1;return!0}function xt(o,e){const t=o.indexOf(e);t>-1&&(o.splice(t,1),o.unshift(e))}function lt(o,e){const t=o.indexOf(e);t>-1&&(o.splice(t,1),o.push(e))}function Nn(o,e){for(let t=0;t<o.length;t++){const i=o[t];if(e(i))return t}return-1}function St(o,e){const t=o.findIndex(i=>i===e);return t>-1?(o.splice(t,1),!0):!1}const Y=(o,e,t)=>e>t?e:Math.min(t,Math.max(o,e)),Ut=()=>{let o=1;return{next:()=>(o++).toString()}},_e=(o,e)=>{const t=[];if(typeof e!="number"&&(e=o,o=0),o<=e)for(let i=o;i<e;i++)t.push(i);else for(let i=o;i>e;i--)t.push(i);return t};class Ln{set size(e){this._size=e}get size(){return this._size}get cachedVisibleSize(){return this._cachedVisibleSize}get visible(){return typeof this._cachedVisibleSize>"u"}get minimumSize(){return this.visible?this.view.minimumSize:0}get viewMinimumSize(){return this.view.minimumSize}get maximumSize(){return this.visible?this.view.maximumSize:0}get viewMaximumSize(){return this.view.maximumSize}get priority(){return this.view.priority}get snap(){return!!this.view.snap}set enabled(e){this.container.style.pointerEvents=e?"":"none"}constructor(e,t,i,n){this.container=e,this.view=t,this.disposable=n,this._cachedVisibleSize=void 0,typeof i=="number"?(this._size=i,this._cachedVisibleSize=void 0,e.classList.add("visible")):(this._size=0,this._cachedVisibleSize=i.cachedVisibleSize)}setVisible(e,t){var i;e!==this.visible&&(e?(this.size=Y((i=this._cachedVisibleSize)!==null&&i!==void 0?i:0,this.viewMinimumSize,this.viewMaximumSize),this._cachedVisibleSize=void 0):(this._cachedVisibleSize=typeof t=="number"?t:this.size,this.size=0),this.container.classList.toggle("visible",e),this.view.setVisible&&this.view.setVisible(e))}dispose(){return this.disposable.dispose(),this.view}}var z;(function(o){o.HORIZONTAL="HORIZONTAL",o.VERTICAL="VERTICAL"})(z||(z={}));var ge;(function(o){o[o.MAXIMUM=0]="MAXIMUM",o[o.MINIMUM=1]="MINIMUM",o[o.DISABLED=2]="DISABLED",o[o.ENABLED=3]="ENABLED"})(ge||(ge={}));var ie;(function(o){o.Low="low",o.High="high",o.Normal="normal"})(ie||(ie={}));var ve;(function(o){o.Distribute={type:"distribute"};function e(i){return{type:"split",index:i}}o.Split=e;function t(i){return{type:"invisible",cachedVisibleSize:i}}o.Invisible=t})(ve||(ve={}));class Fe{get contentSize(){return this._contentSize}get size(){return this._size}set size(e){this._size=e}get orthogonalSize(){return this._orthogonalSize}set orthogonalSize(e){this._orthogonalSize=e}get length(){return this.viewItems.length}get proportions(){return this._proportions?[...this._proportions]:void 0}get orientation(){return this._orientation}set orientation(e){this._orientation=e;const t=this.size;this.size=this.orthogonalSize,this.orthogonalSize=t,ye(this.element,"dv-horizontal","dv-vertical"),this.element.classList.add(this.orientation==z.HORIZONTAL?"dv-horizontal":"dv-vertical")}get minimumSize(){return this.viewItems.reduce((e,t)=>e+t.minimumSize,0)}get maximumSize(){return this.length===0?Number.POSITIVE_INFINITY:this.viewItems.reduce((e,t)=>e+t.maximumSize,0)}get startSnappingEnabled(){return this._startSnappingEnabled}set startSnappingEnabled(e){this._startSnappingEnabled!==e&&(this._startSnappingEnabled=e,this.updateSashEnablement())}get endSnappingEnabled(){return this._endSnappingEnabled}set endSnappingEnabled(e){this._endSnappingEnabled!==e&&(this._endSnappingEnabled=e,this.updateSashEnablement())}get disabled(){return this._disabled}set disabled(e){this._disabled=e,A(this.element,"dv-splitview-disabled",e)}get margin(){return this._margin}set margin(e){this._margin=e,A(this.element,"dv-splitview-has-margin",e!==0)}constructor(e,t){var i,n;this.container=e,this.viewItems=[],this.sashes=[],this._size=0,this._orthogonalSize=0,this._contentSize=0,this._proportions=void 0,this._startSnappingEnabled=!0,this._endSnappingEnabled=!0,this._disabled=!1,this._margin=0,this._onDidSashEnd=new _,this.onDidSashEnd=this._onDidSashEnd.event,this._onDidAddView=new _,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new _,this.onDidRemoveView=this._onDidRemoveView.event,this.resize=(s,l,a=this.viewItems.map(f=>f.size),r,d,h=Number.NEGATIVE_INFINITY,c=Number.POSITIVE_INFINITY,u,p)=>{if(s<0||s>this.viewItems.length)return 0;const f=_e(s,-1),m=_e(s+1,this.viewItems.length);if(d)for(const y of d)xt(f,y),xt(m,y);if(r)for(const y of r)lt(f,y),lt(m,y);const g=f.map(y=>this.viewItems[y]),v=f.map(y=>a[y]),b=m.map(y=>this.viewItems[y]),w=m.map(y=>a[y]),C=f.reduce((y,S)=>y+this.viewItems[S].minimumSize-a[S],0),I=f.reduce((y,S)=>y+this.viewItems[S].maximumSize-a[S],0),E=m.length===0?Number.POSITIVE_INFINITY:m.reduce((y,S)=>y+a[S]-this.viewItems[S].minimumSize,0),D=m.length===0?Number.NEGATIVE_INFINITY:m.reduce((y,S)=>y+a[S]-this.viewItems[S].maximumSize,0),G=Math.max(C,D),M=Math.min(E,I);let H=!1;if(u){const y=this.viewItems[u.index],S=l>=u.limitDelta;H=S!==y.visible,y.setVisible(S,u.size)}if(!H&&p){const y=this.viewItems[p.index],S=l<p.limitDelta;H=S!==y.visible,y.setVisible(S,p.size)}if(H)return this.resize(s,l,a,r,d,h,c);const N=Y(l,G,M);let L=0,X=N;for(let y=0;y<g.length;y++){const S=g[y],j=Y(v[y]+X,S.minimumSize,S.maximumSize),W=j-v[y];L+=W,X-=W,S.size=j}let B=L;for(let y=0;y<b.length;y++){const S=b[y],j=Y(w[y]-B,S.minimumSize,S.maximumSize),W=j-w[y];B+=W,S.size=j}return l},this._orientation=(i=t.orientation)!==null&&i!==void 0?i:z.VERTICAL,this.element=this.createContainer(),this.margin=(n=t.margin)!==null&&n!==void 0?n:0,this.proportionalLayout=t.proportionalLayout===void 0?!0:!!t.proportionalLayout,this.viewContainer=this.createViewContainer(),this.sashContainer=this.createSashContainer(),this.element.appendChild(this.sashContainer),this.element.appendChild(this.viewContainer),this.container.appendChild(this.element),this.style(t.styles),t.descriptor&&(this._size=t.descriptor.size,t.descriptor.views.forEach((s,l)=>{const a=s.visible===void 0||s.visible?s.size:{type:"invisible",cachedVisibleSize:s.size},r=s.view;this.addView(r,a,l,!0)}),this._contentSize=this.viewItems.reduce((s,l)=>s+l.size,0),this.saveProportions())}style(e){(e==null?void 0:e.separatorBorder)==="transparent"?(ye(this.element,"dv-separator-border"),this.element.style.removeProperty("--dv-separator-border")):(xe(this.element,"dv-separator-border"),e!=null&&e.separatorBorder&&this.element.style.setProperty("--dv-separator-border",e.separatorBorder))}isViewVisible(e){if(e<0||e>=this.viewItems.length)throw new Error("Index out of bounds");return this.viewItems[e].visible}setViewVisible(e,t){if(e<0||e>=this.viewItems.length)throw new Error("Index out of bounds");const i=this.viewItems[e];i.setVisible(t,i.size),this.distributeEmptySpace(e),this.layoutViews(),this.saveProportions()}getViewSize(e){return e<0||e>=this.viewItems.length?-1:this.viewItems[e].size}resizeView(e,t){if(e<0||e>=this.viewItems.length)return;const i=_e(this.viewItems.length).filter(a=>a!==e),n=[...i.filter(a=>this.viewItems[a].priority===ie.Low),e],s=i.filter(a=>this.viewItems[a].priority===ie.High),l=this.viewItems[e];t=Math.round(t),t=Y(t,l.minimumSize,Math.min(l.maximumSize,this._size)),l.size=t,this.relayout(n,s)}getViews(){return this.viewItems.map(e=>e.view)}onDidChange(e,t){const i=this.viewItems.indexOf(e);if(i<0||i>=this.viewItems.length)return;t=typeof t=="number"?t:e.size,t=Y(t,e.minimumSize,e.maximumSize),e.size=t;const n=_e(this.viewItems.length).filter(a=>a!==i),s=[...n.filter(a=>this.viewItems[a].priority===ie.Low),i],l=n.filter(a=>this.viewItems[a].priority===ie.High);this.relayout([...s,i],l)}addView(e,t={type:"distribute"},i=this.viewItems.length,n){const s=document.createElement("div");s.className="dv-view",s.appendChild(e.element);let l;typeof t=="number"?l=t:t.type==="split"?l=this.getViewSize(t.index)/2:t.type==="invisible"?l={cachedVisibleSize:t.cachedVisibleSize}:l=e.minimumSize;const a=e.onDidChange(d=>this.onDidChange(r,d.size)),r=new Ln(s,e,l,{dispose:()=>{a.dispose(),this.viewContainer.removeChild(s)}});if(i===this.viewItems.length?this.viewContainer.appendChild(s):this.viewContainer.insertBefore(s,this.viewContainer.children.item(i)),this.viewItems.splice(i,0,r),this.viewItems.length>1){const d=document.createElement("div");d.className="dv-sash";const h=u=>{for(const y of this.viewItems)y.enabled=!1;const p=Qe(),f=this._orientation===z.HORIZONTAL?u.clientX:u.clientY,m=Nn(this.sashes,y=>y.container===d),g=this.viewItems.map(y=>y.size);let v,b;const w=_e(m,-1),C=_e(m+1,this.viewItems.length),I=w.reduce((y,S)=>y+(this.viewItems[S].minimumSize-g[S]),0),E=w.reduce((y,S)=>y+(this.viewItems[S].viewMaximumSize-g[S]),0),D=C.length===0?Number.POSITIVE_INFINITY:C.reduce((y,S)=>y+(g[S]-this.viewItems[S].minimumSize),0),G=C.length===0?Number.NEGATIVE_INFINITY:C.reduce((y,S)=>y+(g[S]-this.viewItems[S].viewMaximumSize),0),M=Math.max(I,G),H=Math.min(D,E),N=this.findFirstSnapIndex(w),L=this.findFirstSnapIndex(C);if(typeof N=="number"){const y=this.viewItems[N],S=Math.floor(y.viewMinimumSize/2);v={index:N,limitDelta:y.visible?M-S:M+S,size:y.size}}if(typeof L=="number"){const y=this.viewItems[L],S=Math.floor(y.viewMinimumSize/2);b={index:L,limitDelta:y.visible?H+S:H-S,size:y.size}}const X=y=>{const j=(this._orientation===z.HORIZONTAL?y.clientX:y.clientY)-f;this.resize(m,j,g,void 0,void 0,M,H,v,b),this.distributeEmptySpace(),this.layoutViews()},B=()=>{for(const y of this.viewItems)y.enabled=!0;p.release(),this.saveProportions(),document.removeEventListener("pointermove",X),document.removeEventListener("pointerup",B),document.removeEventListener("pointercancel",B),document.removeEventListener("contextmenu",B),this._onDidSashEnd.fire(void 0)};document.addEventListener("pointermove",X),document.addEventListener("pointerup",B),document.addEventListener("pointercancel",B),document.addEventListener("contextmenu",B)};d.addEventListener("pointerdown",h);const c={container:d,disposable:()=>{d.removeEventListener("pointerdown",h),this.sashContainer.removeChild(d)}};this.sashContainer.appendChild(d),this.sashes.push(c)}n||this.relayout([i]),!n&&typeof t!="number"&&t.type==="distribute"&&this.distributeViewSizes(),this._onDidAddView.fire(e)}distributeViewSizes(){const e=[];let t=0;for(const a of this.viewItems)a.maximumSize-a.minimumSize>0&&(e.push(a),t+=a.size);const i=Math.floor(t/e.length);for(const a of e)a.size=Y(i,a.minimumSize,a.maximumSize);const n=_e(this.viewItems.length),s=n.filter(a=>this.viewItems[a].priority===ie.Low),l=n.filter(a=>this.viewItems[a].priority===ie.High);this.relayout(s,l)}removeView(e,t,i=!1){const n=this.viewItems.splice(e,1)[0];if(n.dispose(),this.viewItems.length>=1){const s=Math.max(e-1,0);this.sashes.splice(s,1)[0].disposable()}return i||this.relayout(),t&&t.type==="distribute"&&this.distributeViewSizes(),this._onDidRemoveView.fire(n.view),n.view}getViewCachedVisibleSize(e){if(e<0||e>=this.viewItems.length)throw new Error("Index out of bounds");return this.viewItems[e].cachedVisibleSize}moveView(e,t){const i=this.getViewCachedVisibleSize(e),n=typeof i>"u"?this.getViewSize(e):ve.Invisible(i),s=this.removeView(e,void 0,!0);this.addView(s,n,t)}layout(e,t){const i=Math.max(this.size,this._contentSize);if(this.size=e,this.orthogonalSize=t,this.proportions){let n=0;for(let s=0;s<this.viewItems.length;s++){const l=this.viewItems[s],a=this.proportions[s];typeof a=="number"?n+=a:e-=l.size}for(let s=0;s<this.viewItems.length;s++){const l=this.viewItems[s],a=this.proportions[s];typeof a=="number"&&n>0&&(l.size=Y(Math.round(a*e/n),l.minimumSize,l.maximumSize))}}else{const n=_e(this.viewItems.length),s=n.filter(a=>this.viewItems[a].priority===ie.Low),l=n.filter(a=>this.viewItems[a].priority===ie.High);this.resize(this.viewItems.length-1,e-i,void 0,s,l)}this.distributeEmptySpace(),this.layoutViews()}relayout(e,t){const i=this.viewItems.reduce((n,s)=>n+s.size,0);this.resize(this.viewItems.length-1,this._size-i,void 0,e,t),this.distributeEmptySpace(),this.layoutViews(),this.saveProportions()}distributeEmptySpace(e){const t=this.viewItems.reduce((a,r)=>a+r.size,0);let i=this.size-t;const n=_e(this.viewItems.length-1,-1),s=n.filter(a=>this.viewItems[a].priority===ie.Low),l=n.filter(a=>this.viewItems[a].priority===ie.High);for(const a of l)xt(n,a);for(const a of s)lt(n,a);typeof e=="number"&&lt(n,e);for(let a=0;i!==0&&a<n.length;a++){const r=this.viewItems[n[a]],d=Y(r.size+i,r.minimumSize,r.maximumSize),h=d-r.size;i-=h,r.size=d}}saveProportions(){this.proportionalLayout&&this._contentSize>0&&(this._proportions=this.viewItems.map(e=>e.visible?e.size/this._contentSize:void 0))}layoutViews(){if(this._contentSize=this.viewItems.reduce((r,d)=>r+d.size,0),this.updateSashEnablement(),this.viewItems.length===0)return;const e=this.viewItems.filter(r=>r.visible),t=Math.max(0,e.length-1),i=this.margin*t/Math.max(1,e.length);let n=0;const s=[],l=4,a=this.viewItems.reduce((r,d,h)=>{const c=d.visible?1:0;return h===0?r.push(c):r.push(r[h-1]+c),r},[]);this.viewItems.forEach((r,d)=>{n+=this.viewItems[d].size,s.push(n);const h=r.visible?r.size-i:0,c=Math.max(0,a[d]-1),u=d===0||c===0?0:s[d-1]+c/t*i;if(d<this.viewItems.length-1){const p=r.visible?u+h-l/2+this.margin/2:u;this._orientation===z.HORIZONTAL&&(this.sashes[d].container.style.left=`${p}px`,this.sashes[d].container.style.top="0px"),this._orientation===z.VERTICAL&&(this.sashes[d].container.style.left="0px",this.sashes[d].container.style.top=`${p}px`)}this._orientation===z.HORIZONTAL&&(r.container.style.width=`${h}px`,r.container.style.left=`${u}px`,r.container.style.top="",r.container.style.height=""),this._orientation===z.VERTICAL&&(r.container.style.height=`${h}px`,r.container.style.top=`${u}px`,r.container.style.width="",r.container.style.left=""),r.view.layout(r.size-i,this._orthogonalSize)})}findFirstSnapIndex(e){for(const t of e){const i=this.viewItems[t];if(i.visible&&i.snap)return t}for(const t of e){const i=this.viewItems[t];if(i.visible&&i.maximumSize-i.minimumSize>0)return;if(!i.visible&&i.snap)return t}}updateSashEnablement(){let e=!1;const t=this.viewItems.map(r=>e=r.size-r.minimumSize>0||e);e=!1;const i=this.viewItems.map(r=>e=r.maximumSize-r.size>0||e),n=[...this.viewItems].reverse();e=!1;const s=n.map(r=>e=r.size-r.minimumSize>0||e).reverse();e=!1;const l=n.map(r=>e=r.maximumSize-r.size>0||e).reverse();let a=0;for(let r=0;r<this.sashes.length;r++){const d=this.sashes[r],h=this.viewItems[r];a+=h.size;const c=!(t[r]&&l[r+1]),u=!(i[r]&&s[r+1]);if(c&&u){const p=_e(r,-1),f=_e(r+1,this.viewItems.length),m=this.findFirstSnapIndex(p),g=this.findFirstSnapIndex(f),v=typeof m=="number"&&!this.viewItems[m].visible,b=typeof g=="number"&&!this.viewItems[g].visible;v&&s[r]&&(a>0||this.startSnappingEnabled)?this.updateSash(d,ge.MINIMUM):b&&t[r]&&(a<this._contentSize||this.endSnappingEnabled)?this.updateSash(d,ge.MAXIMUM):this.updateSash(d,ge.DISABLED)}else c&&!u?this.updateSash(d,ge.MINIMUM):!c&&u?this.updateSash(d,ge.MAXIMUM):this.updateSash(d,ge.ENABLED)}}updateSash(e,t){A(e.container,"dv-disabled",t===ge.DISABLED),A(e.container,"dv-enabled",t===ge.ENABLED),A(e.container,"dv-maximum",t===ge.MAXIMUM),A(e.container,"dv-minimum",t===ge.MINIMUM)}createViewContainer(){const e=document.createElement("div");return e.className="dv-view-container",e}createSashContainer(){const e=document.createElement("div");return e.className="dv-sash-container",e}createContainer(){const e=document.createElement("div"),t=this._orientation===z.HORIZONTAL?"dv-horizontal":"dv-vertical";return e.className=`dv-split-view-container ${t}`,e}dispose(){this._onDidSashEnd.dispose(),this._onDidAddView.dispose(),this._onDidRemoveView.dispose();for(let e=0;e<this.element.children.length;e++)if(this.element.children.item(e)===this.element){this.element.removeChild(this.element);break}for(const e of this.viewItems)e.dispose();this.element.remove()}}const zt=Object.keys({orientation:void 0,descriptor:void 0,proportionalLayout:void 0,styles:void 0,margin:void 0,disableAutoResizing:void 0,className:void 0});class ai extends R{get onDidAddView(){return this.splitview.onDidAddView}get onDidRemoveView(){return this.splitview.onDidRemoveView}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get orientation(){return this.splitview.orientation}get size(){return this.splitview.size}get orthogonalSize(){return this.splitview.orthogonalSize}constructor(e,t){var i;super(),this.paneItems=[],this.skipAnimation=!1,this._onDidChange=new _,this.onDidChange=this._onDidChange.event,this._orientation=(i=t.orientation)!==null&&i!==void 0?i:z.VERTICAL,this.element=document.createElement("div"),this.element.className="dv-pane-container",e.appendChild(this.element),this.splitview=new Fe(this.element,{orientation:this._orientation,proportionalLayout:!1,descriptor:t.descriptor}),this.getPanes().forEach(n=>{const s=new R(n.onDidChangeExpansionState(()=>{this.setupAnimation(),this._onDidChange.fire(void 0)})),l={pane:n,disposable:{dispose:()=>{s.dispose()}}};this.paneItems.push(l),n.orthogonalSize=this.splitview.orthogonalSize}),this.addDisposables(this._onDidChange,this.splitview.onDidSashEnd(()=>{this._onDidChange.fire(void 0)}),this.splitview.onDidAddView(()=>{this._onDidChange.fire()}),this.splitview.onDidRemoveView(()=>{this._onDidChange.fire()}))}setViewVisible(e,t){this.splitview.setViewVisible(e,t)}addPane(e,t,i=this.splitview.length,n=!1){const s=e.onDidChangeExpansionState(()=>{this.setupAnimation(),this._onDidChange.fire(void 0)}),l={pane:e,disposable:{dispose:()=>{s.dispose()}}};this.paneItems.splice(i,0,l),e.orthogonalSize=this.splitview.orthogonalSize,this.splitview.addView(e,t,i,n)}getViewSize(e){return this.splitview.getViewSize(e)}getPanes(){return this.splitview.getViews()}removePane(e,t={skipDispose:!1}){const i=this.paneItems.splice(e,1)[0];return this.splitview.removeView(e),t.skipDispose||(i.disposable.dispose(),i.pane.dispose()),i}moveView(e,t){if(e===t)return;const i=this.removePane(e,{skipDispose:!0});this.skipAnimation=!0;try{this.addPane(i.pane,i.pane.size,t,!1)}finally{this.skipAnimation=!1}}layout(e,t){this.splitview.layout(e,t)}setupAnimation(){this.skipAnimation||(this.animationTimer&&(clearTimeout(this.animationTimer),this.animationTimer=void 0),xe(this.element,"dv-animated"),this.animationTimer=setTimeout(()=>{this.animationTimer=void 0,ye(this.element,"dv-animated")},200))}dispose(){super.dispose(),this.animationTimer&&(clearTimeout(this.animationTimer),this.animationTimer=void 0),this.paneItems.forEach(e=>{e.disposable.dispose(),e.pane.dispose()}),this.paneItems=[],this.splitview.dispose(),this.element.remove()}}class he{get minimumWidth(){return this.view.minimumWidth}get maximumWidth(){return this.view.maximumWidth}get minimumHeight(){return this.view.minimumHeight}get maximumHeight(){return this.view.maximumHeight}get priority(){return this.view.priority}get snap(){return this.view.snap}get minimumSize(){return this.orientation===z.HORIZONTAL?this.minimumHeight:this.minimumWidth}get maximumSize(){return this.orientation===z.HORIZONTAL?this.maximumHeight:this.maximumWidth}get minimumOrthogonalSize(){return this.orientation===z.HORIZONTAL?this.minimumWidth:this.minimumHeight}get maximumOrthogonalSize(){return this.orientation===z.HORIZONTAL?this.maximumWidth:this.maximumHeight}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get element(){return this.view.element}get width(){return this.orientation===z.HORIZONTAL?this.orthogonalSize:this.size}get height(){return this.orientation===z.HORIZONTAL?this.size:this.orthogonalSize}constructor(e,t,i,n=0){this.view=e,this.orientation=t,this._onDidChange=new _,this.onDidChange=this._onDidChange.event,this._orthogonalSize=i,this._size=n,this._disposable=this.view.onDidChange(s=>{s?this._onDidChange.fire({size:this.orientation===z.VERTICAL?s.width:s.height,orthogonalSize:this.orientation===z.VERTICAL?s.height:s.width}):this._onDidChange.fire({})})}setVisible(e){this.view.setVisible&&this.view.setVisible(e)}layout(e,t){this._size=e,this._orthogonalSize=t,this.view.layout(this.width,this.height)}dispose(){this._onDidChange.dispose(),this._disposable.dispose()}}class te extends R{get width(){return this.orientation===z.HORIZONTAL?this.size:this.orthogonalSize}get height(){return this.orientation===z.HORIZONTAL?this.orthogonalSize:this.size}get minimumSize(){return this.children.length===0?0:Math.max(...this.children.map((e,t)=>this.splitview.isViewVisible(t)?e.minimumOrthogonalSize:0))}get maximumSize(){return Math.min(...this.children.map((e,t)=>this.splitview.isViewVisible(t)?e.maximumOrthogonalSize:Number.POSITIVE_INFINITY))}get minimumOrthogonalSize(){return this.splitview.minimumSize}get maximumOrthogonalSize(){return this.splitview.maximumSize}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get minimumWidth(){return this.orientation===z.HORIZONTAL?this.minimumOrthogonalSize:this.minimumSize}get minimumHeight(){return this.orientation===z.HORIZONTAL?this.minimumSize:this.minimumOrthogonalSize}get maximumWidth(){return this.orientation===z.HORIZONTAL?this.maximumOrthogonalSize:this.maximumSize}get maximumHeight(){return this.orientation===z.HORIZONTAL?this.maximumSize:this.maximumOrthogonalSize}get priority(){if(this.children.length===0)return ie.Normal;const e=this.children.map(t=>typeof t.priority>"u"?ie.Normal:t.priority);return e.some(t=>t===ie.High)?ie.High:e.some(t=>t===ie.Low)?ie.Low:ie.Normal}get disabled(){return this.splitview.disabled}set disabled(e){this.splitview.disabled=e}get margin(){return this.splitview.margin}set margin(e){this.splitview.margin=e,this.children.forEach(t=>{t instanceof te&&(t.margin=e)})}constructor(e,t,i,n,s,l,a,r){if(super(),this.orientation=e,this.proportionalLayout=t,this.styles=i,this._childrenDisposable=ne.NONE,this.children=[],this._onDidChange=new _,this.onDidChange=this._onDidChange.event,this._onDidVisibilityChange=new _,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._orthogonalSize=s,this._size=n,this.element=document.createElement("div"),this.element.className="dv-branch-node",!r)this.splitview=new Fe(this.element,{orientation:this.orientation,proportionalLayout:t,styles:i,margin:a}),this.splitview.layout(this.size,this.orthogonalSize);else{const d={views:r.map(h=>({view:h.node,size:h.node.size,visible:h.node instanceof he&&h.visible!==void 0?h.visible:!0})),size:this.orthogonalSize};this.children=r.map(h=>h.node),this.splitview=new Fe(this.element,{orientation:this.orientation,descriptor:d,proportionalLayout:t,styles:i,margin:a})}this.disabled=l,this.addDisposables(this._onDidChange,this._onDidVisibilityChange,this.splitview.onDidSashEnd(()=>{this._onDidChange.fire({})})),this.setupChildrenEvents()}setVisible(e){}isChildVisible(e){if(e<0||e>=this.children.length)throw new Error("Invalid index");return this.splitview.isViewVisible(e)}setChildVisible(e,t){if(e<0||e>=this.children.length)throw new Error("Invalid index");if(this.splitview.isViewVisible(e)===t)return;const i=this.splitview.contentSize===0;this.splitview.setViewVisible(e,t);const n=this.splitview.contentSize===0;(t&&i||!t&&n)&&this._onDidVisibilityChange.fire({visible:t})}moveChild(e,t){if(e===t)return;if(e<0||e>=this.children.length)throw new Error("Invalid from index");e<t&&t--,this.splitview.moveView(e,t);const i=this._removeChild(e);this._addChild(i,t)}getChildSize(e){if(e<0||e>=this.children.length)throw new Error("Invalid index");return this.splitview.getViewSize(e)}resizeChild(e,t){if(e<0||e>=this.children.length)throw new Error("Invalid index");this.splitview.resizeView(e,t)}layout(e,t){this._size=t,this._orthogonalSize=e,this.splitview.layout(t,e)}addChild(e,t,i,n){if(i<0||i>this.children.length)throw new Error("Invalid index");this.splitview.addView(e,t,i,n),this._addChild(e,i)}getChildCachedVisibleSize(e){if(e<0||e>=this.children.length)throw new Error("Invalid index");return this.splitview.getViewCachedVisibleSize(e)}removeChild(e,t){if(e<0||e>=this.children.length)throw new Error("Invalid index");return this.splitview.removeView(e,t),this._removeChild(e)}_addChild(e,t){this.children.splice(t,0,e),this.setupChildrenEvents()}_removeChild(e){const[t]=this.children.splice(e,1);return this.setupChildrenEvents(),t}setupChildrenEvents(){this._childrenDisposable.dispose(),this._childrenDisposable=new R(He.any(...this.children.map(e=>e.onDidChange))(e=>{this._onDidChange.fire({size:e.orthogonalSize})}),...this.children.map((e,t)=>e instanceof te?e.onDidVisibilityChange(({visible:i})=>{this.setChildVisible(t,i)}):ne.NONE))}dispose(){this._childrenDisposable.dispose(),this.splitview.dispose(),this.children.forEach(e=>e.dispose()),super.dispose()}}function kt(o,e){if(o instanceof he)return o;if(o instanceof te)return kt(o.children[e?o.children.length-1:0],e);throw new Error("invalid node")}function Li(o,e,t){if(o instanceof te){const i=new te(o.orientation,o.proportionalLayout,o.styles,e,t,o.disabled,o.margin);for(let n=o.children.length-1;n>=0;n--){const s=o.children[n];i.addChild(Li(s,s.size,s.orthogonalSize),s.size,0,!0)}return i}else return new he(o.view,o.orientation,t)}function Ot(o,e,t){if(o instanceof te){const i=new te(Ie(o.orientation),o.proportionalLayout,o.styles,e,t,o.disabled,o.margin);let n=0;for(let s=o.children.length-1;s>=0;s--){const l=o.children[s],a=l instanceof te?l.orthogonalSize:l.size;let r=o.size===0?0:Math.round(e*a/o.size);n+=r,s===0&&(r+=e-n),i.addChild(Ot(l,t,r),r,0,!0)}return i}else return new he(o.view,Ie(o.orientation),t)}function Wn(o){const e=o.parentElement;if(!e)throw new Error("Invalid grid element");let t=e.firstElementChild,i=0;for(;t!==o&&t!==e.lastElementChild&&t;)t=t.nextElementSibling,i++;return i}function Z(o){const e=o.parentElement;if(!e)throw new Error("Invalid grid element");if(/\bdv-grid-view\b/.test(e.className))return[];const t=Wn(e),i=e.parentElement.parentElement.parentElement;return[...Z(i),t]}function be(o,e,t){const i=Fn(o,e),n=Hn(t);if(i===n){const[s,l]=ze(e);let a=l;return(t==="right"||t==="bottom")&&(a+=1),[...s,a]}else{const s=t==="right"||t==="bottom"?1:0;return[...e,s]}}function Hn(o){return o==="top"||o==="bottom"?z.VERTICAL:z.HORIZONTAL}function Fn(o,e){return e.length%2===0?Ie(o):o}const Ie=o=>o===z.HORIZONTAL?z.VERTICAL:z.HORIZONTAL;function Bn(o){return!!o.children}const Rt=(o,e)=>{const t=e===z.VERTICAL?o.box.width:o.box.height;return Bn(o)?{type:"branch",data:o.children.map(i=>Rt(i,Ie(e))),size:t}:typeof o.cachedVisibleSize=="number"?{type:"leaf",data:o.view.toJSON(),size:o.cachedVisibleSize,visible:!1}:{type:"leaf",data:o.view.toJSON(),size:t}};class $n{get length(){return this._root?this._root.children.length:0}get orientation(){return this.root.orientation}set orientation(e){if(this.root.orientation===e)return;const{size:t,orthogonalSize:i}=this.root;this.root=Ot(this.root,i,t),this.root.layout(t,i)}get width(){return this.root.width}get height(){return this.root.height}get minimumWidth(){return this.root.minimumWidth}get minimumHeight(){return this.root.minimumHeight}get maximumWidth(){return this.root.maximumHeight}get maximumHeight(){return this.root.maximumHeight}get locked(){return this._locked}set locked(e){this._locked=e;const t=[this.root];for(;t.length>0;){const i=t.pop();i instanceof te&&(i.disabled=e,t.push(...i.children))}}get margin(){return this._margin}set margin(e){this._margin=e,this.root.margin=e}maximizedView(){var e;return(e=this._maximizedNode)===null||e===void 0?void 0:e.leaf.view}hasMaximizedView(){return this._maximizedNode!==void 0}maximizeView(e){var t;const i=Z(e.element),[n,s]=this.getNode(i);if(!(s instanceof he)||((t=this._maximizedNode)===null||t===void 0?void 0:t.leaf)===s)return;this.hasMaximizedView()&&this.exitMaximizedView(),Rt(this.getView(),this.orientation);const l=[];function a(r,d){for(let h=0;h<r.children.length;h++){const c=r.children[h];c instanceof he?c!==d&&(r.isChildVisible(h)?r.setChildVisible(h,!1):l.push(c)):a(c,d)}}a(this.root,s),this._maximizedNode={leaf:s,hiddenOnMaximize:l},this._onDidMaximizedNodeChange.fire({view:s.view,isMaximized:!0})}exitMaximizedView(){if(!this._maximizedNode)return;const e=this._maximizedNode.hiddenOnMaximize;function t(n){for(let s=n.children.length-1;s>=0;s--){const l=n.children[s];l instanceof he?e.includes(l)||n.setChildVisible(s,!0):t(l)}}t(this.root);const i=this._maximizedNode.leaf;this._maximizedNode=void 0,this._onDidMaximizedNodeChange.fire({view:i.view,isMaximized:!1})}serialize(){const e=this.maximizedView();let t;e&&(t=Z(e.element));const i=this._onDidMaximizedNodeChange.pause();try{this.hasMaximizedView()&&this.exitMaximizedView();const s={root:Rt(this.getView(),this.orientation),width:this.width,height:this.height,orientation:this.orientation};return t&&(s.maximizedNode={location:t}),e&&this.maximizeView(e),s}finally{i.dispose()}}dispose(){this.disposable.dispose(),this._onDidChange.dispose(),this._onDidMaximizedNodeChange.dispose(),this._onDidViewVisibilityChange.dispose(),this.root.dispose(),this._maximizedNode=void 0,this.element.remove()}clear(){const e=this.root.orientation;this.root=new te(e,this.proportionalLayout,this.styles,this.root.size,this.root.orthogonalSize,this.locked,this.margin)}deserialize(e,t){const i=e.orientation,n=i===z.VERTICAL?e.height:e.width;if(this._deserialize(e.root,i,t,n),this.layout(e.width,e.height),e.maximizedNode){const s=e.maximizedNode.location,[l,a]=this.getNode(s);if(!(a instanceof he))return;this.maximizeView(a.view)}}_deserialize(e,t,i,n){this.root=this._deserializeNode(e,t,i,n)}_deserializeNode(e,t,i,n){var s;let l;if(e.type==="branch"){const r=e.data.map(d=>({node:this._deserializeNode(d,Ie(t),i,e.size),visible:d.visible}));l=new te(t,this.proportionalLayout,this.styles,e.size,n,this.locked,this.margin,r)}else{const a=i.fromJSON(e);typeof e.visible=="boolean"&&((s=a.setVisible)===null||s===void 0||s.call(a,e.visible)),l=new he(a,t,n,e.size)}return l}get root(){return this._root}set root(e){const t=this._root;t&&(t.dispose(),this._maximizedNode=void 0,this.element.removeChild(t.element)),this._root=e,this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(i=>{this._onDidChange.fire(i)})}normalize(){if(!this._root||this._root.children.length!==1)return;const e=this.root,t=e.children[0];if(t instanceof he)return;e.element.remove();const i=e.removeChild(0);e.dispose(),i.dispose(),this._root=Li(t,t.size,t.orthogonalSize),this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(n=>{this._onDidChange.fire(n)})}insertOrthogonalSplitviewAtRoot(){if(!this._root)return;const e=this.root;if(e.element.remove(),this._root=new te(Ie(e.orientation),this.proportionalLayout,this.styles,this.root.orthogonalSize,this.root.size,this.locked,this.margin),e.children.length!==0)if(e.children.length===1){const t=e.children[0];e.removeChild(0).dispose(),e.dispose(),this._root.addChild(Ot(t,t.orthogonalSize,t.size),ve.Distribute,0)}else this._root.addChild(e,ve.Distribute,0);this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(t=>{this._onDidChange.fire(t)})}next(e){return this.progmaticSelect(e)}previous(e){return this.progmaticSelect(e,!0)}getView(e){const t=e?this.getNode(e)[1]:this.root;return this._getViews(t,this.orientation)}_getViews(e,t,i){const n={height:e.height,width:e.width};if(e instanceof he)return{box:n,view:e.view,cachedVisibleSize:i};const s=[];for(let l=0;l<e.children.length;l++){const a=e.children[l],r=e.getChildCachedVisibleSize(l);s.push(this._getViews(a,Ie(t),r))}return{box:n,children:s}}progmaticSelect(e,t=!1){const[i,n]=this.getNode(e);if(!(n instanceof he))throw new Error("invalid location");for(let s=i.length-1;s>-1;s--){const l=i[s],a=e[s]||0;if(t?a-1>-1:a+1<l.children.length)return kt(l.children[t?a-1:a+1],t)}return kt(this.root,t)}constructor(e,t,i,n,s){this.proportionalLayout=e,this.styles=t,this._locked=!1,this._margin=0,this._maximizedNode=void 0,this.disposable=new le,this._onDidChange=new _,this.onDidChange=this._onDidChange.event,this._onDidViewVisibilityChange=new _,this.onDidViewVisibilityChange=this._onDidViewVisibilityChange.event,this._onDidMaximizedNodeChange=new _,this.onDidMaximizedNodeChange=this._onDidMaximizedNodeChange.event,this.element=document.createElement("div"),this.element.className="dv-grid-view",this._locked=n??!1,this._margin=s??0,this.root=new te(i,e,t,0,0,this.locked,this.margin)}isViewVisible(e){const[t,i]=ze(e),[,n]=this.getNode(t);if(!(n instanceof te))throw new Error("Invalid from location");return n.isChildVisible(i)}setViewVisible(e,t){this.hasMaximizedView()&&this.exitMaximizedView();const[i,n]=ze(e),[,s]=this.getNode(i);if(!(s instanceof te))throw new Error("Invalid from location");this._onDidViewVisibilityChange.fire(),s.setChildVisible(n,t)}moveView(e,t,i){this.hasMaximizedView()&&this.exitMaximizedView();const[,n]=this.getNode(e);if(!(n instanceof te))throw new Error("Invalid location");n.moveChild(t,i)}addView(e,t,i){this.hasMaximizedView()&&this.exitMaximizedView();const[n,s]=ze(i),[l,a]=this.getNode(n);if(a instanceof te){const r=new he(e,Ie(a.orientation),a.orthogonalSize);a.addChild(r,t,s)}else{const[r,...d]=[...l].reverse(),[h,...c]=[...n].reverse();let u=0;const p=r.getChildCachedVisibleSize(h);typeof p=="number"&&(u=ve.Invisible(p)),r.removeChild(h).dispose();const m=new te(a.orientation,this.proportionalLayout,this.styles,a.size,a.orthogonalSize,this.locked,this.margin);r.addChild(m,a.size,h);const g=new he(a.view,r.orientation,a.size);m.addChild(g,u,0),typeof t!="number"&&t.type==="split"&&(t={type:"split",index:0});const v=new he(e,r.orientation,a.size);m.addChild(v,t,s)}}remove(e,t){const i=Z(e.element);return this.removeView(i,t)}removeView(e,t){this.hasMaximizedView()&&this.exitMaximizedView();const[i,n]=ze(e),[s,l]=this.getNode(i);if(!(l instanceof te))throw new Error("Invalid location");const a=l.children[n];if(!(a instanceof he))throw new Error("Invalid location");if(l.removeChild(n,t),a.dispose(),l.children.length!==1)return a.view;const r=l.children[0];if(s.length===0)return r instanceof he||(l.removeChild(0,t),this.root=r),a.view;const[d,...h]=[...s].reverse(),[c,...u]=[...i].reverse(),p=l.isChildVisible(0);l.removeChild(0,t);const f=d.children.map((m,g)=>d.getChildSize(g));if(d.removeChild(c,t).dispose(),r instanceof te){f.splice(c,1,...r.children.map(m=>m.size));for(let m=0;m<r.children.length;m++){const g=r.children[m];d.addChild(g,g.size,c+m)}for(;r.children.length>0;)r.removeChild(0)}else{const m=new he(r.view,Ie(r.orientation),r.size),g=p?r.orthogonalSize:ve.Invisible(r.orthogonalSize);d.addChild(m,g,c)}r.dispose();for(let m=0;m<f.length;m++)d.resizeChild(m,f[m]);return a.view}layout(e,t){const[i,n]=this.root.orientation===z.HORIZONTAL?[t,e]:[e,t];this.root.layout(i,n)}getNode(e,t=this.root,i=[]){if(e.length===0)return[i,t];if(!(t instanceof te))throw new Error("Invalid location");const[n,...s]=e;if(n<0||n>=t.children.length)throw new Error("Invalid location");const l=t.children[n];return i.push(t),this.getNode(s,l,i)}}const Vt=Object.keys({disableAutoResizing:void 0,proportionalLayout:void 0,orientation:void 0,hideBorders:void 0,className:void 0});class jt extends R{get element(){return this._element}get disableResizing(){return this._disableResizing}set disableResizing(e){this._disableResizing=e}constructor(e,t=!1){super(),this._lastWidth=-1,this._lastHeight=-1,this._disableResizing=t,this._element=e,this.addDisposables(tt(this._element,i=>{if(this.isDisposed||this.disableResizing||!this._element.offsetParent||!Tn(this._element))return;const n=Math.round(i.contentRect.width),s=Math.round(i.contentRect.height);n===this._lastWidth&&s===this._lastHeight||(this._lastWidth=n,this._lastHeight=s,this.layout(n,s))}))}}const Un=Ut();function vt(o){switch(o){case"left":return"left";case"right":return"right";case"above":return"top";case"below":return"bottom";case"within":default:return"center"}}class Wi extends jt{get id(){return this._id}get size(){return this._groups.size}get groups(){return Array.from(this._groups.values()).map(e=>e.value)}get width(){return this.gridview.width}get height(){return this.gridview.height}get minimumHeight(){return this.gridview.minimumHeight}get maximumHeight(){return this.gridview.maximumHeight}get minimumWidth(){return this.gridview.minimumWidth}get maximumWidth(){return this.gridview.maximumWidth}get activeGroup(){return this._activeGroup}get locked(){return this.gridview.locked}set locked(e){this.gridview.locked=e}constructor(e,t){var i;super(document.createElement("div"),t.disableAutoResizing),this._id=Un.next(),this._groups=new Map,this._onDidRemove=new _,this.onDidRemove=this._onDidRemove.event,this._onDidAdd=new _,this.onDidAdd=this._onDidAdd.event,this._onDidMaximizedChange=new _,this.onDidMaximizedChange=this._onDidMaximizedChange.event,this._onDidActiveChange=new _,this.onDidActiveChange=this._onDidActiveChange.event,this._bufferOnDidLayoutChange=new si,this.onDidLayoutChange=this._bufferOnDidLayoutChange.onEvent,this._onDidViewVisibilityChangeMicroTaskQueue=new si,this.onDidViewVisibilityChangeMicroTaskQueue=this._onDidViewVisibilityChangeMicroTaskQueue.onEvent,this.element.style.height="100%",this.element.style.width="100%",this._classNames=new bt(this.element),this._classNames.setClassNames((i=t.className)!==null&&i!==void 0?i:""),e.appendChild(this.element),this.gridview=new $n(!!t.proportionalLayout,t.styles,t.orientation,t.locked,t.margin),this.gridview.locked=!!t.locked,this.element.appendChild(this.gridview.element),this.layout(0,0,!0),this.addDisposables(this.gridview.onDidMaximizedNodeChange(n=>{this._onDidMaximizedChange.fire({panel:n.view,isMaximized:n.isMaximized})}),this.gridview.onDidViewVisibilityChange(()=>this._onDidViewVisibilityChangeMicroTaskQueue.fire()),this.onDidViewVisibilityChangeMicroTaskQueue(()=>{this.forceRelayout()}),ne.from(()=>{var n;(n=this.element.parentElement)===null||n===void 0||n.removeChild(this.element)}),this.gridview.onDidChange(()=>{this._bufferOnDidLayoutChange.fire()}),He.any(this.onDidAdd,this.onDidRemove,this.onDidActiveChange)(()=>{this._bufferOnDidLayoutChange.fire()}),this._onDidMaximizedChange,this._onDidViewVisibilityChangeMicroTaskQueue,this._bufferOnDidLayoutChange)}setVisible(e,t){this.gridview.setViewVisible(Z(e.element),t),this._bufferOnDidLayoutChange.fire()}isVisible(e){return this.gridview.isViewVisible(Z(e.element))}updateOptions(e){var t,i,n,s;e.proportionalLayout,e.orientation&&(this.gridview.orientation=e.orientation),"disableResizing"in e&&(this.disableResizing=(t=e.disableAutoResizing)!==null&&t!==void 0?t:!1),"locked"in e&&(this.locked=(i=e.locked)!==null&&i!==void 0?i:!1),"margin"in e&&(this.gridview.margin=(n=e.margin)!==null&&n!==void 0?n:0),"className"in e&&this._classNames.setClassNames((s=e.className)!==null&&s!==void 0?s:"")}maximizeGroup(e){this.gridview.maximizeView(e),this.doSetGroupActive(e)}isMaximizedGroup(e){return this.gridview.maximizedView()===e}exitMaximizedGroup(){this.gridview.exitMaximizedView()}hasMaximizedGroup(){return this.gridview.hasMaximizedView()}doAddGroup(e,t=[0],i){this.gridview.addView(e,i??ve.Distribute,t),this._onDidAdd.fire(e)}doRemoveGroup(e,t){if(!this._groups.has(e.id))throw new Error("invalid operation");const i=this._groups.get(e.id),n=this.gridview.remove(e,ve.Distribute);if(i&&!(t!=null&&t.skipDispose)&&(i.disposable.dispose(),i.value.dispose(),this._groups.delete(e.id),this._onDidRemove.fire(e)),!(t!=null&&t.skipActive)&&this._activeGroup===e){const s=Array.from(this._groups.values());this.doSetGroupActive(s.length>0?s[0].value:void 0)}return n}getPanel(e){var t;return(t=this._groups.get(e))===null||t===void 0?void 0:t.value}doSetGroupActive(e){this._activeGroup!==e&&(this._activeGroup&&this._activeGroup.setActive(!1),e&&e.setActive(!0),this._activeGroup=e,this._onDidActiveChange.fire(e))}removeGroup(e){this.doRemoveGroup(e)}moveToNext(e){var t;if(e||(e={}),!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}const i=Z(e.group.element),n=(t=this.gridview.next(i))===null||t===void 0?void 0:t.view;this.doSetGroupActive(n)}moveToPrevious(e){var t;if(e||(e={}),!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}const i=Z(e.group.element),n=(t=this.gridview.previous(i))===null||t===void 0?void 0:t.view;this.doSetGroupActive(n)}forceRelayout(){this.layout(this.width,this.height,!0)}layout(e,t,i){(i||e!==this.width||t!==this.height)&&(this.gridview.element.style.height=`${t}px`,this.gridview.element.style.width=`${e}px`,this.gridview.layout(e,t))}dispose(){this._onDidActiveChange.dispose(),this._onDidAdd.dispose(),this._onDidRemove.dispose();for(const e of this.groups)e.dispose();this.gridview.dispose(),super.dispose()}}class Hi{get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get width(){return this.component.width}get height(){return this.component.height}get length(){return this.component.length}get orientation(){return this.component.orientation}get panels(){return this.component.panels}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidAddView(){return this.component.onDidAddView}get onDidRemoveView(){return this.component.onDidRemoveView}constructor(e){this.component=e}removePanel(e,t){this.component.removePanel(e,t)}focus(){this.component.focus()}getPanel(e){return this.component.getPanel(e)}layout(e,t){return this.component.layout(e,t)}addPanel(e){return this.component.addPanel(e)}movePanel(e,t){this.component.movePanel(e,t)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}}class et{get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get width(){return this.component.width}get height(){return this.component.height}get panels(){return this.component.panels}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidAddView(){return this.component.onDidAddView}get onDidRemoveView(){return this.component.onDidRemoveView}get onDidDrop(){return this.component.onDidDrop}get onUnhandledDragOverEvent(){return this.component.onUnhandledDragOverEvent}constructor(e){this.component=e}removePanel(e){this.component.removePanel(e)}getPanel(e){return this.component.getPanel(e)}movePanel(e,t){this.component.movePanel(e,t)}focus(){this.component.focus()}layout(e,t){this.component.layout(e,t)}addPanel(e){return this.component.addPanel(e)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}}class Fi{get width(){return this.component.width}get height(){return this.component.height}get minimumHeight(){return this.component.minimumHeight}get maximumHeight(){return this.component.maximumHeight}get minimumWidth(){return this.component.minimumWidth}get maximumWidth(){return this.component.maximumWidth}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidAddPanel(){return this.component.onDidAddGroup}get onDidRemovePanel(){return this.component.onDidRemoveGroup}get onDidActivePanelChange(){return this.component.onDidActiveGroupChange}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get panels(){return this.component.groups}get orientation(){return this.component.orientation}set orientation(e){this.component.updateOptions({orientation:e})}constructor(e){this.component=e}focus(){this.component.focus()}layout(e,t,i=!1){this.component.layout(e,t,i)}addPanel(e){return this.component.addPanel(e)}removePanel(e,t){this.component.removePanel(e,t)}movePanel(e,t){this.component.movePanel(e,t)}getPanel(e){return this.component.getPanel(e)}fromJSON(e){return this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}}class _t{get id(){return this.component.id}get width(){return this.component.width}get height(){return this.component.height}get minimumHeight(){return this.component.minimumHeight}get maximumHeight(){return this.component.maximumHeight}get minimumWidth(){return this.component.minimumWidth}get maximumWidth(){return this.component.maximumWidth}get size(){return this.component.size}get tabGroupColors(){return this.component.tabGroupColorPalette.entries()}get totalPanels(){return this.component.totalPanels}get onDidActiveGroupChange(){return this.component.onDidActiveGroupChange}get onDidAddGroup(){return this.component.onDidAddGroup}get onDidRemoveGroup(){return this.component.onDidRemoveGroup}get onDidActivePanelChange(){return this.component.onDidActivePanelChange}get onDidAddPanel(){return this.component.onDidAddPanel}get onDidRemovePanel(){return this.component.onDidRemovePanel}get onDidMovePanel(){return this.component.onDidMovePanel}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidDrop(){return this.component.onDidDrop}get onWillDrop(){return this.component.onWillDrop}get onWillShowOverlay(){return this.component.onWillShowOverlay}get onWillDragGroup(){return this.component.onWillDragGroup}get onWillDragPanel(){return this.component.onWillDragPanel}get onUnhandledDragOverEvent(){return this.component.onUnhandledDragOverEvent}get onDidPopoutGroupSizeChange(){return this.component.onDidPopoutGroupSizeChange}get onDidPopoutGroupPositionChange(){return this.component.onDidPopoutGroupPositionChange}get onDidOpenPopoutWindowFail(){return this.component.onDidOpenPopoutWindowFail}get onDidCreateTabGroup(){return this.component.onDidCreateTabGroup}get onDidDestroyTabGroup(){return this.component.onDidDestroyTabGroup}get onDidAddPanelToTabGroup(){return this.component.onDidAddPanelToTabGroup}get onDidRemovePanelFromTabGroup(){return this.component.onDidRemovePanelFromTabGroup}get onDidTabGroupChange(){return this.component.onDidTabGroupChange}get onDidTabGroupCollapsedChange(){return this.component.onDidTabGroupCollapsedChange}get panels(){return this.component.panels}get groups(){return this.component.groups}get activePanel(){return this.component.activePanel}get activeGroup(){return this.component.activeGroup}constructor(e){this.component=e}focus(){this.component.focus()}getPanel(e){return this.component.getGroupPanel(e)}layout(e,t,i=!1){this.component.layout(e,t,i)}addPanel(e){return this.component.addPanel(e)}removePanel(e){this.component.removePanel(e)}addGroup(e){return this.component.addGroup(e)}closeAllGroups(){return this.component.closeAllGroups()}removeGroup(e){this.component.removeGroup(e)}getGroup(e){return this.component.getPanel(e)}addFloatingGroup(e,t){return this.component.addFloatingGroup(e,t)}fromJSON(e,t){this.component.fromJSON(e,t)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}moveToNext(e){this.component.moveToNext(e)}moveToPrevious(e){this.component.moveToPrevious(e)}maximizeGroup(e){this.component.maximizeGroup(e.group)}hasMaximizedGroup(){return this.component.hasMaximizedGroup()}exitMaximizedGroup(){this.component.exitMaximizedGroup()}get onDidMaximizedGroupChange(){return this.component.onDidMaximizedGroupChange}addPopoutGroup(e,t){return this.component.addPopoutGroup(e,t)}addEdgeGroup(e,t){return this.component.addEdgeGroup(e,t)}getEdgeGroup(e){return this.component.getEdgeGroup(e)}setEdgeGroupVisible(e,t){this.component.setEdgeGroupVisible(e,t)}isEdgeGroupVisible(e){return this.component.isEdgeGroupVisible(e)}removeEdgeGroup(e){this.component.removeEdgeGroup(e)}updateOptions(e){this.component.updateOptions(e)}_getGroupModel(e){const t=this.component.getPanel(e);if(!t)throw new Error(`dockview: group '${e}' not found`);return t.model}createTabGroup(e){return this._getGroupModel(e.groupId).createTabGroup({label:e.label,color:e.color,componentParams:e.componentParams})}dissolveTabGroup(e){this._getGroupModel(e.groupId).dissolveTabGroup(e.tabGroupId)}addPanelToTabGroup(e){this._getGroupModel(e.groupId).addPanelToTabGroup(e.tabGroupId,e.panelId,e.index)}removePanelFromTabGroup(e){this._getGroupModel(e.groupId).removePanelFromTabGroup(e.panelId)}getTabGroups(e){return this._getGroupModel(e.groupId).getTabGroups()}getTabGroupForPanel(e){return this._getGroupModel(e.groupId).getTabGroupForPanel(e.panelId)}moveTabGroup(e){this._getGroupModel(e.groupId).moveTabGroup(e.tabGroupId,e.index)}dispose(){this.component.dispose()}}class Kt extends R{constructor(e,t){super(),this.el=e,this.disabled=t,this.dataDisposable=new le,this.pointerEventsDisposable=new le,this._onDragStart=new _,this.onDragStart=this._onDragStart.event,this.addDisposables(this._onDragStart,this.dataDisposable,this.pointerEventsDisposable),this.configure()}setDisabled(e){this.disabled=e}isCancelled(e){return!1}configure(){this.addDisposables(this._onDragStart,k(this.el,"dragstart",e=>{if(e.defaultPrevented||this.isCancelled(e)||this.disabled){e.preventDefault();return}const t=Qe();this.pointerEventsDisposable.value={dispose:()=>{t.release()}},this.el.classList.add("dv-dragged"),setTimeout(()=>this.el.classList.remove("dv-dragged"),0),this.dataDisposable.value=this.getData(e),this._onDragStart.fire(e),e.dataTransfer&&(e.dataTransfer.effectAllowed="move",e.dataTransfer.items.length>0||e.dataTransfer.setData("text/plain",""))}),k(this.el,"dragend",()=>{this.pointerEventsDisposable.dispose(),setTimeout(()=>{this.dataDisposable.dispose()},0)}))}}class Bi extends R{constructor(e,t){super(),this.element=e,this.callbacks=t,this.target=null,this.registerListeners()}onDragEnter(e){this.target=e.target,this.callbacks.onDragEnter(e)}onDragOver(e){e.preventDefault(),this.callbacks.onDragOver&&this.callbacks.onDragOver(e)}onDragLeave(e){this.target===e.target&&(this.target=null,this.callbacks.onDragLeave(e))}onDragEnd(e){this.target=null,this.callbacks.onDragEnd(e)}onDrop(e){this.callbacks.onDrop(e)}registerListeners(){this.addDisposables(k(this.element,"dragenter",e=>{this.onDragEnter(e)},!0)),this.addDisposables(k(this.element,"dragover",e=>{this.onDragOver(e)},!0)),this.addDisposables(k(this.element,"dragleave",e=>{this.onDragLeave(e)})),this.addDisposables(k(this.element,"dragend",e=>{this.onDragEnd(e)})),this.addDisposables(k(this.element,"drop",e=>{this.onDrop(e)}))}}function jn(o,e){const{top:t,left:i,width:n,height:s}=e,l=`${Math.round(t)}px`,a=`${Math.round(i)}px`,r=`${Math.round(n)}px`,d=`${Math.round(s)}px`;o.style.top=l,o.style.left=a,o.style.width=r,o.style.height=d,o.style.visibility="visible",(!o.style.transform||o.style.transform==="")&&(o.style.transform="translate3d(0, 0, 0)")}function Kn(o,e){const{top:t,left:i,width:n,height:s}=e;o.style.top=t,o.style.left=i,o.style.width=n,o.style.height=s,o.style.visibility="visible",(!o.style.transform||o.style.transform==="")&&(o.style.transform="translate3d(0, 0, 0)")}function Jn(o,e){const{top:t,left:i,width:n,height:s}=e,l=`${Math.round(t)}px`,a=`${Math.round(i)}px`,r=`${Math.round(n)}px`,d=`${Math.round(s)}px`;return o.style.top!==l||o.style.left!==a||o.style.width!==r||o.style.height!==d}class Yn extends $t{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}constructor(e){super(),this.options=e}}function li(o){switch(o){case"above":return"top";case"below":return"bottom";case"left":return"left";case"right":return"right";case"within":return"center";default:throw new Error(`invalid direction '${o}'`)}}function Zn(o){switch(o){case"top":return"above";case"bottom":return"below";case"left":return"left";case"right":return"right";case"center":return"within";default:throw new Error(`invalid position '${o}'`)}}const Xn={value:20,type:"percentage"},qn={value:50,type:"percentage"},Qn=100,es=100;class we extends R{get disabled(){return this._disabled}set disabled(e){this._disabled=e}get state(){return this._state}constructor(e,t){super(),this.element=e,this.options=t,this._onDrop=new _,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new _,this.onWillShowOverlay=this._onWillShowOverlay.event,this._disabled=!1,this._acceptedTargetZonesSet=new Set(this.options.acceptedTargetZones),this.dnd=new Bi(this.element,{onDragEnter:()=>{var i,n,s;(s=(n=(i=this.options).getOverrideTarget)===null||n===void 0?void 0:n.call(i))===null||s===void 0||s.getElements()},onDragOver:i=>{var n,s,l,a,r,d,h;we.ACTUAL_TARGET=this;const c=(s=(n=this.options).getOverrideTarget)===null||s===void 0?void 0:s.call(n);if(this._acceptedTargetZonesSet.size===0){if(c)return;this.removeDropTarget();return}const u=(r=(a=(l=this.options).getOverlayOutline)===null||a===void 0?void 0:a.call(l))!==null&&r!==void 0?r:this.element,p=u.offsetWidth,f=u.offsetHeight;if(p===0||f===0)return;const m=i.currentTarget.getBoundingClientRect(),g=((d=i.clientX)!==null&&d!==void 0?d:0)-m.left,v=((h=i.clientY)!==null&&h!==void 0?h:0)-m.top,b=this.calculateQuadrant(this._acceptedTargetZonesSet,g,v,p,f);if(this.isAlreadyUsed(i)||b===null){this.removeDropTarget();return}if(!this.options.canDisplayOverlay(i,b)){if(c)return;this.removeDropTarget();return}const w=new Yn({nativeEvent:i,position:b});if(this._onWillShowOverlay.fire(w),w.defaultPrevented){this.removeDropTarget();return}this.markAsUsed(i),c||this.targetElement||(this.targetElement=document.createElement("div"),this.targetElement.className="dv-drop-target-dropzone",this.overlayElement=document.createElement("div"),this.overlayElement.className="dv-drop-target-selection",this._state="center",this.targetElement.appendChild(this.overlayElement),u.classList.add("dv-drop-target"),u.append(this.targetElement)),this.toggleClasses(b,p,f),this._state=b},onDragLeave:()=>{var i,n;!((n=(i=this.options).getOverrideTarget)===null||n===void 0)&&n.call(i)||this.removeDropTarget()},onDragEnd:i=>{var n,s;const l=(s=(n=this.options).getOverrideTarget)===null||s===void 0?void 0:s.call(n);l&&we.ACTUAL_TARGET===this&&this._state&&(i.stopPropagation(),this._onDrop.fire({position:this._state,nativeEvent:i})),this.removeDropTarget(),l==null||l.clear()},onDrop:i=>{var n,s,l;i.preventDefault();const a=this._state;this.removeDropTarget(),(l=(s=(n=this.options).getOverrideTarget)===null||s===void 0?void 0:s.call(n))===null||l===void 0||l.clear(),a&&(i.stopPropagation(),this._onDrop.fire({position:a,nativeEvent:i}))}}),this.addDisposables(this._onDrop,this._onWillShowOverlay,this.dnd)}setTargetZones(e){this._acceptedTargetZonesSet=new Set(e)}setOverlayModel(e){this.options.overlayModel=e}dispose(){this.removeDropTarget(),super.dispose()}markAsUsed(e){e[we.USED_EVENT_ID]=!0}isAlreadyUsed(e){const t=e[we.USED_EVENT_ID];return typeof t=="boolean"&&t}toggleClasses(e,t,i){var n,s,l,a,r,d,h,c,u,p,f;const m=(s=(n=this.options).getOverrideTarget)===null||s===void 0?void 0:s.call(n);if(!m&&!this.overlayElement)return;const g=(a=(l=this.options.overlayModel)===null||l===void 0?void 0:l.smallWidthBoundary)!==null&&a!==void 0?a:Qn,v=(d=(r=this.options.overlayModel)===null||r===void 0?void 0:r.smallHeightBoundary)!==null&&d!==void 0?d:es,b=t<g,w=i<v,C=e==="left",I=e==="right",E=e==="top",D=e==="bottom",G=!b&&I,M=!b&&C,H=!w&&E,N=!w&&D;let L=1;const X=(c=(h=this.options.overlayModel)===null||h===void 0?void 0:h.size)!==null&&c!==void 0?c:qn;if(X.type==="percentage"?L=Y(X.value,0,100)/100:((G||M)&&(L=Y(0,X.value,t)/t),(H||N)&&(L=Y(0,X.value,i)/i)),m){const S=(f=(p=(u=this.options).getOverlayOutline)===null||p===void 0?void 0:p.call(u))!==null&&f!==void 0?f:this.element,j=S.getBoundingClientRect(),W=m.getElements(void 0,S),se=W.root,$=W.overlay,K=se.getBoundingClientRect(),oe=j.top-K.top,ce=j.left-K.left,J={top:oe,left:ce,width:t,height:i};if(G?(J.left=ce+t*(1-L),J.width=t*L):M?J.width=t*L:H?J.height=i*L:N&&(J.top=oe+i*(1-L),J.height=i*L),b&&C&&(J.width=4),b&&I&&(J.left=ce+t-4,J.width=4),w&&E&&(J.height=4),w&&D&&(J.top=oe+i-4,J.height=4),!Jn($,J))return;jn($,J),$.className=`dv-drop-target-anchor${this.options.className?` ${this.options.className}`:""}`,A($,"dv-drop-target-left",C),A($,"dv-drop-target-right",I),A($,"dv-drop-target-top",E),A($,"dv-drop-target-bottom",D),A($,"dv-drop-target-anchor-line",b&&(C||I)||w&&(E||D)),A($,"dv-drop-target-center",e==="center"),W.changed&&(A($,"dv-drop-target-anchor-container-changed",!0),setTimeout(()=>{A($,"dv-drop-target-anchor-container-changed",!1)},10));return}if(!this.overlayElement)return;const B={top:"0px",left:"0px",width:"100%",height:"100%"};G?(B.left=`${100*(1-L)}%`,B.width=`${100*L}%`):M?B.width=`${100*L}%`:H?B.height=`${100*L}%`:N&&(B.top=`${100*(1-L)}%`,B.height=`${100*L}%`),b&&C&&(B.width="4px"),b&&I&&(B.left=`${t-4}px`,B.width="4px"),w&&E&&(B.height="4px"),w&&D&&(B.top=`${i-4}px`,B.height="4px"),Kn(this.overlayElement,B);const y=b&&(C||I)||w&&(E||D);A(this.overlayElement,"dv-drop-target-small-vertical",w),A(this.overlayElement,"dv-drop-target-small-horizontal",b),A(this.overlayElement,"dv-drop-target-selection-line",y),A(this.overlayElement,"dv-drop-target-left",C),A(this.overlayElement,"dv-drop-target-right",I),A(this.overlayElement,"dv-drop-target-top",E),A(this.overlayElement,"dv-drop-target-bottom",D),A(this.overlayElement,"dv-drop-target-center",e==="center")}calculateQuadrant(e,t,i,n,s){var l,a;const r=(a=(l=this.options.overlayModel)===null||l===void 0?void 0:l.activationSize)!==null&&a!==void 0?a:Xn;return r.type==="percentage"?ts(e,t,i,n,s,r.value):is(e,t,i,n,s,r.value)}removeDropTarget(){var e;this.targetElement&&(this._state=void 0,(e=this.targetElement.parentElement)===null||e===void 0||e.classList.remove("dv-drop-target"),this.targetElement.remove(),this.targetElement=void 0,this.overlayElement=void 0)}}we.USED_EVENT_ID="__dockview_droptarget_event_is_used__";function ts(o,e,t,i,n,s){const l=100*e/i,a=100*t/n;return o.has("left")&&l<s?"left":o.has("right")&&l>100-s?"right":o.has("top")&&a<s?"top":o.has("bottom")&&a>100-s?"bottom":o.has("center")?"center":null}function is(o,e,t,i,n,s){return o.has("left")&&e<s?"left":o.has("right")&&e>i-s?"right":o.has("top")&&t<s?"top":o.has("bottom")&&t>n-s?"bottom":o.has("center")?"center":null}const Mt=Object.keys({disableAutoResizing:void 0,disableDnd:void 0,className:void 0});class ns extends ki{constructor(e,t,i,n){super(),this.nativeEvent=e,this.position=t,this.getData=i,this.panel=n}}class $i extends $t{constructor(){super()}}class Ui extends R{get isFocused(){return this._isFocused}get isActive(){return this._isActive}get isVisible(){return this._isVisible}get width(){return this._width}get height(){return this._height}constructor(e,t){super(),this.id=e,this.component=t,this._isFocused=!1,this._isActive=!1,this._isVisible=!0,this._width=0,this._height=0,this._parameters={},this.panelUpdatesDisposable=new le,this._onDidDimensionChange=new _,this.onDidDimensionsChange=this._onDidDimensionChange.event,this._onDidChangeFocus=new _,this.onDidFocusChange=this._onDidChangeFocus.event,this._onWillFocus=new _,this.onWillFocus=this._onWillFocus.event,this._onDidVisibilityChange=new _,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._onWillVisibilityChange=new _,this.onWillVisibilityChange=this._onWillVisibilityChange.event,this._onDidActiveChange=new _,this.onDidActiveChange=this._onDidActiveChange.event,this._onActiveChange=new _,this.onActiveChange=this._onActiveChange.event,this._onDidParametersChange=new _,this.onDidParametersChange=this._onDidParametersChange.event,this.addDisposables(this.onDidFocusChange(i=>{this._isFocused=i.isFocused}),this.onDidActiveChange(i=>{this._isActive=i.isActive}),this.onDidVisibilityChange(i=>{this._isVisible=i.isVisible}),this.onDidDimensionsChange(i=>{this._width=i.width,this._height=i.height}),this.panelUpdatesDisposable,this._onDidDimensionChange,this._onDidChangeFocus,this._onDidVisibilityChange,this._onDidActiveChange,this._onWillFocus,this._onActiveChange,this._onWillFocus,this._onWillVisibilityChange,this._onDidParametersChange)}getParameters(){return this._parameters}initialize(e){this.panelUpdatesDisposable.value=this._onDidParametersChange.event(t=>{this._parameters=t,e.update({params:t})})}setVisible(e){this._onWillVisibilityChange.fire({isVisible:e})}setActive(){this._onActiveChange.fire()}updateParameters(e){this._onDidParametersChange.fire(e)}}class ji extends Ui{constructor(e,t){super(e,t),this._onDidConstraintsChangeInternal=new _,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new _({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new _,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}}class ss extends ji{set pane(e){this._pane=e}constructor(e,t){super(e,t),this._onDidExpansionChange=new _({replay:!0}),this.onDidExpansionChange=this._onDidExpansionChange.event,this._onMouseEnter=new _({}),this.onMouseEnter=this._onMouseEnter.event,this._onMouseLeave=new _({}),this.onMouseLeave=this._onMouseLeave.event,this.addDisposables(this._onDidExpansionChange,this._onMouseEnter,this._onMouseLeave)}setExpanded(e){var t;(t=this._pane)===null||t===void 0||t.setExpanded(e)}get isExpanded(){var e;return!!(!((e=this._pane)===null||e===void 0)&&e.isExpanded())}}class Jt extends R{get element(){return this._element}get width(){return this._width}get height(){return this._height}get params(){var e;return(e=this._params)===null||e===void 0?void 0:e.params}constructor(e,t,i){super(),this.id=e,this.component=t,this.api=i,this._height=0,this._width=0,this._element=document.createElement("div"),this._element.tabIndex=-1,this._element.style.outline="none",this._element.style.height="100%",this._element.style.width="100%",this._element.style.overflow="hidden";const n=Oi(this._element);this.addDisposables(this.api,n.onDidFocus(()=>{this.api._onDidChangeFocus.fire({isFocused:!0})}),n.onDidBlur(()=>{this.api._onDidChangeFocus.fire({isFocused:!1})}),n)}focus(){const e=new $i;this.api._onWillFocus.fire(e),!e.defaultPrevented&&this._element.focus()}layout(e,t){this._width=e,this._height=t,this.api._onDidDimensionChange.fire({width:e,height:t}),this.part&&this._params&&this.part.update(this._params.params)}init(e){this._params=e,this.part=this.getComponent()}update(e){var t,i;this._params=Object.assign(Object.assign({},this._params),{params:Object.assign(Object.assign({},(t=this._params)===null||t===void 0?void 0:t.params),e.params)});for(const n of Object.keys(e.params))e.params[n]===void 0&&delete this._params.params[n];(i=this.part)===null||i===void 0||i.update({params:this._params.params})}toJSON(){var e,t;const i=(t=(e=this._params)===null||e===void 0?void 0:e.params)!==null&&t!==void 0?t:{};return{id:this.id,component:this.component,params:Object.keys(i).length>0?i:void 0}}dispose(){var e;this.api.dispose(),(e=this.part)===null||e===void 0||e.dispose(),super.dispose()}}class os extends Jt{set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){const e=this.headerSize,i=this.isExpanded()?this._minimumBodySize:0;return e+i}get maximumSize(){const e=this.headerSize,i=this.isExpanded()?this._maximumBodySize:0;return e+i}get size(){return this._size}get orthogonalSize(){return this._orthogonalSize}set orthogonalSize(e){this._orthogonalSize=e}get minimumBodySize(){return this._minimumBodySize}set minimumBodySize(e){this._minimumBodySize=typeof e=="number"?e:0}get maximumBodySize(){return this._maximumBodySize}set maximumBodySize(e){this._maximumBodySize=typeof e=="number"?e:Number.POSITIVE_INFINITY}get headerVisible(){return this._headerVisible}set headerVisible(e){this._headerVisible=e,this.header.style.display=e?"":"none"}constructor(e){super(e.id,e.component,new ss(e.id,e.component)),this._onDidChangeExpansionState=new _({replay:!0}),this.onDidChangeExpansionState=this._onDidChangeExpansionState.event,this._onDidChange=new _,this.onDidChange=this._onDidChange.event,this._orthogonalSize=0,this._size=0,this._isExpanded=!1,this.api.pane=this,this.api.initialize(this),this.headerSize=e.headerSize,this.headerComponent=e.headerComponent,this._minimumBodySize=e.minimumBodySize,this._maximumBodySize=e.maximumBodySize,this._isExpanded=e.isExpanded,this._headerVisible=e.isHeaderVisible,this._onDidChangeExpansionState.fire(this.isExpanded()),this._orientation=e.orientation,this.element.classList.add("dv-pane"),this.addDisposables(this.api.onWillVisibilityChange(t=>{const{isVisible:i}=t,{accessor:n}=this._params;n.setVisible(this,i)}),this.api.onDidSizeChange(t=>{this._onDidChange.fire({size:t.size})}),k(this.element,"mouseenter",t=>{this.api._onMouseEnter.fire(t)}),k(this.element,"mouseleave",t=>{this.api._onMouseLeave.fire(t)})),this.addDisposables(this._onDidChangeExpansionState,this.onDidChangeExpansionState(t=>{this.api._onDidExpansionChange.fire({isExpanded:t})}),this.api.onDidFocusChange(t=>{this.header&&(t.isFocused?xe(this.header,"focused"):ye(this.header,"focused"))})),this.renderOnce()}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}isExpanded(){return this._isExpanded}setExpanded(e){this._isExpanded!==e&&(this._isExpanded=e,e?(this.animationTimer&&clearTimeout(this.animationTimer),this.body&&this.element.appendChild(this.body)):this.animationTimer=setTimeout(()=>{var t;(t=this.body)===null||t===void 0||t.remove()},200),this._onDidChange.fire(e?{size:this.width}:{}),this._onDidChangeExpansionState.fire(e))}layout(e,t){this._size=e,this._orthogonalSize=t;const[i,n]=this.orientation===z.HORIZONTAL?[e,t]:[t,e];super.layout(i,n)}init(e){var t,i;super.init(e),typeof e.minimumBodySize=="number"&&(this.minimumBodySize=e.minimumBodySize),typeof e.maximumBodySize=="number"&&(this.maximumBodySize=e.maximumBodySize),this.bodyPart=this.getBodyComponent(),this.headerPart=this.getHeaderComponent(),this.bodyPart.init(Object.assign(Object.assign({},e),{api:this.api})),this.headerPart.init(Object.assign(Object.assign({},e),{api:this.api})),(t=this.body)===null||t===void 0||t.append(this.bodyPart.element),(i=this.header)===null||i===void 0||i.append(this.headerPart.element),typeof e.isExpanded=="boolean"&&this.setExpanded(e.isExpanded)}toJSON(){const e=this._params;return Object.assign(Object.assign({},super.toJSON()),{headerComponent:this.headerComponent,title:e.title})}renderOnce(){this.header=document.createElement("div"),this.header.tabIndex=0,this.header.className="dv-pane-header",this.header.style.height=`${this.headerSize}px`,this.header.style.lineHeight=`${this.headerSize}px`,this.header.style.minHeight=`${this.headerSize}px`,this.header.style.maxHeight=`${this.headerSize}px`,this.element.appendChild(this.header),this.body=document.createElement("div"),this.body.className="dv-pane-body",this.element.appendChild(this.body)}getComponent(){return{update:e=>{var t,i;(t=this.bodyPart)===null||t===void 0||t.update({params:e}),(i=this.headerPart)===null||i===void 0||i.update({params:e})},dispose:()=>{var e,t;(e=this.bodyPart)===null||e===void 0||e.dispose(),(t=this.headerPart)===null||t===void 0||t.dispose()}}}}class rs extends os{constructor(e){super({id:e.id,component:e.component,headerComponent:e.headerComponent,orientation:e.orientation,isExpanded:e.isExpanded,isHeaderVisible:!0,headerSize:e.headerSize,minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize}),this._onDidDrop=new _,this.onDidDrop=this._onDidDrop.event,this._onUnhandledDragOverEvent=new _,this.onUnhandledDragOverEvent=this._onUnhandledDragOverEvent.event,this.accessor=e.accessor,this.addDisposables(this._onDidDrop,this._onUnhandledDragOverEvent),e.disableDnd||this.initDragFeatures()}initDragFeatures(){if(!this.header)return;const e=this.id,t=this.accessor.id;this.header.draggable=!0,this.handler=new class extends Kt{getData(){return De.getInstance().setData([new qe(t,e)],qe.prototype),{dispose:()=>{De.getInstance().clearData(qe.prototype)}}}}(this.header),this.target=new we(this.element,{acceptedTargetZones:["top","bottom"],overlayModel:{activationSize:{type:"percentage",value:50}},canDisplayOverlay:(i,n)=>{const s=Ye();if(s&&s.paneId!==this.id&&s.viewId===this.accessor.id)return!0;const l=new ns(i,n,Ye,this);return this._onUnhandledDragOverEvent.fire(l),l.isAccepted}}),this.addDisposables(this._onDidDrop,this.handler,this.target,this.target.onDrop(i=>{this.onDrop(i)}))}onDrop(e){const t=Ye();if(!t||t.viewId!==this.accessor.id){this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,api:new et(this.accessor),getData:Ye}));return}const i=this._params.containerApi,n=t.paneId,s=i.getPanel(n);if(!s){this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,getData:Ye,api:new et(this.accessor)}));return}const l=i.panels,a=l.indexOf(s);let r=i.panels.indexOf(this);(e.position==="left"||e.position==="top")&&(r=Math.max(0,r-1)),(e.position==="right"||e.position==="bottom")&&(a>r&&r++,r=Math.min(l.length-1,r)),i.movePanel(a,r)}}class as extends R{get element(){return this._element}constructor(e,t){super(),this.accessor=e,this.group=t,this.disposable=new le,this._onDidFocus=new _,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new _,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="dv-content-container",this._element.tabIndex=-1,this.addDisposables(this._onDidFocus,this._onDidBlur);const i=t.dropTargetContainer;this.dropTarget=new we(this.element,{getOverlayOutline:()=>{var n;return((n=e.options.theme)===null||n===void 0?void 0:n.dndPanelOverlay)==="group"?this.element.parentElement:null},className:"dv-drop-target-content",acceptedTargetZones:["top","bottom","left","right","center"],canDisplayOverlay:(n,s)=>{if(this.group.locked==="no-drop-target"||this.group.locked&&s==="center")return!1;const l=re();return!l&&n.shiftKey&&this.group.location.type!=="floating"?!1:l&&l.viewId===this.accessor.id?!0:this.group.canDisplayOverlay(n,s,"content")},getOverrideTarget:i?()=>i.model:void 0}),this.addDisposables(this.dropTarget)}show(){this.element.style.display=""}hide(){this.element.style.display="none"}renderPanel(e,t={asActive:!0}){var i,n,s,l;const a=t.asActive||this.panel&&this.group.isPanelActive(this.panel);this.panel&&this.panel.view.content.element.parentElement===this._element&&(this._element.removeChild(this.panel.view.content.element),(n=(i=this.panel.view.content).onHide)===null||n===void 0||n.call(i)),this.panel=e;let r;switch(e.api.renderer){case"onlyWhenVisible":this.group.renderContainer.detatch(e),this.panel&&a&&(this._element.appendChild(this.panel.view.content.element),(l=(s=this.panel.view.content).onShow)===null||l===void 0||l.call(s)),r=this._element;break;case"always":e.view.content.element.parentElement===this._element&&this._element.removeChild(e.view.content.element),r=this.group.renderContainer.attach({panel:e,referenceContainer:this});break;default:throw new Error(`dockview: invalid renderer type '${e.api.renderer}'`)}if(a){const d=Oi(r);this.focusTracker=d;const h=new R;h.addDisposables(d,d.onDidFocus(()=>this._onDidFocus.fire()),d.onDidBlur(()=>this._onDidBlur.fire())),this.disposable.value=h}}openPanel(e){this.panel!==e&&this.renderPanel(e)}layout(e,t){}closePanel(){var e,t,i;this.panel&&this.panel.api.renderer==="onlyWhenVisible"&&((e=this.panel.view.content.element.parentElement)===null||e===void 0||e.removeChild(this.panel.view.content.element),(i=(t=this.panel.view.content).onHide)===null||i===void 0||i.call(t)),this.panel=void 0}dispose(){this.disposable.dispose(),super.dispose()}refreshFocusState(){var e;!((e=this.focusTracker)===null||e===void 0)&&e.refreshState&&this.focusTracker.refreshState()}}function Ki(o,e,t){var i,n;xe(e,"dv-dragged"),e.style.top="-9999px",document.body.appendChild(e),o.setDragImage(e,(i=t==null?void 0:t.x)!==null&&i!==void 0?i:0,(n=t==null?void 0:t.y)!==null&&n!==void 0?n:0),setTimeout(()=>{ye(e,"dv-dragged"),e.remove()},0)}class ls extends Kt{constructor(e,t,i,n,s){super(e,s),this.accessor=t,this.group=i,this.panel=n,this.panelTransfer=De.getInstance()}getData(e){return this.panelTransfer.setData([new Ce(this.accessor.id,this.group.id,this.panel.id)],Ce.prototype),{dispose:()=>{this.panelTransfer.clearData(Ce.prototype)}}}}class ds extends R{get element(){return this._element}constructor(e,t,i){super(),this.panel=e,this.accessor=t,this.group=i,this.content=void 0,this._direction="horizontal",this._onPointDown=new _,this.onPointerDown=this._onPointDown.event,this._onTabClick=new _,this.onTabClick=this._onTabClick.event,this._onDropped=new _,this.onDrop=this._onDropped.event,this._onDragStart=new _,this.onDragStart=this._onDragStart.event,this._onDragEnd=new _,this.onDragEnd=this._onDragEnd.event,this._element=document.createElement("div"),this._element.className="dv-tab",this._element.tabIndex=0,this._element.draggable=!this.accessor.options.disableDnd,A(this.element,"dv-inactive-tab",!0),this.dragHandler=new ls(this._element,this.accessor,this.group,this.panel,!!this.accessor.options.disableDnd),this.dropTarget=new we(this._element,{acceptedTargetZones:["left","right"],overlayModel:this._buildOverlayModel(),canDisplayOverlay:(n,s)=>{var l;if(this.group.locked)return!1;const a=re();return a&&this.accessor.id===a.viewId?((l=this.accessor.options.theme)===null||l===void 0?void 0:l.tabAnimation)!=="smooth":this.group.model.canDisplayOverlay(n,s,"tab")},getOverrideTarget:()=>{var n;return(n=i.model.dropTargetContainer)===null||n===void 0?void 0:n.model}}),this.onWillShowOverlay=this.dropTarget.onWillShowOverlay,this.addDisposables(this._onPointDown,this._onTabClick,this._onDropped,this._onDragStart,this._onDragEnd,this.accessor.onDidOptionsChange(()=>{this.dropTarget.setOverlayModel(this._buildOverlayModel())}),this.dragHandler.onDragStart(n=>{var s;if(n.dataTransfer){const l=getComputedStyle(this.element),a=this.element.cloneNode(!0),r=this._direction==="vertical",d=new Set(["writing-mode","inline-size","block-size","min-inline-size","min-block-size","max-inline-size","max-block-size","margin-inline","margin-inline-start","margin-inline-end","margin-block","margin-block-start","margin-block-end","padding-inline","padding-inline-start","padding-inline-end","padding-block","padding-block-start","padding-block-end"]);Array.from(l).forEach(h=>{r&&d.has(h)||a.style.setProperty(h,l.getPropertyValue(h),l.getPropertyPriority(h))}),r&&(a.style.setProperty("writing-mode","horizontal-tb"),a.style.setProperty("width",l.height),a.style.setProperty("height",l.width)),a.style.position="absolute",a.classList.add("dv-tab-ghost-drag"),Ki(n.dataTransfer,a,{y:-10,x:30})}this._onDragStart.fire(n),((s=this.accessor.options.theme)===null||s===void 0?void 0:s.tabAnimation)==="smooth"&&requestAnimationFrame(()=>{A(this.element,"dv-tab--dragging",!0)})}),k(this._element,"dragend",n=>{A(this.element,"dv-tab--dragging",!1),this._onDragEnd.fire(n)}),this.dragHandler,k(this._element,"pointerdown",n=>{this._onPointDown.fire(n)}),k(this._element,"click",n=>{this._onTabClick.fire(n)}),k(this._element,"contextmenu",n=>{this.accessor.contextMenuController.show(this.panel,this.group,n)}),this.dropTarget.onDrop(n=>{this._onDropped.fire(n)}),this.dropTarget)}setActive(e){A(this.element,"dv-active-tab",e),A(this.element,"dv-inactive-tab",!e)}setContent(e){this.content&&this._element.removeChild(this.content.element),this.content=e,this._element.appendChild(this.content.element)}_buildOverlayModel(){var e;const t=((e=this.accessor.options.theme)===null||e===void 0?void 0:e.dndTabIndicator)==="line"?Number.POSITIVE_INFINITY:0;return{activationSize:{value:50,type:"percentage"},smallWidthBoundary:t,smallHeightBoundary:t}}setDirection(e){this._direction=e,this.dropTarget.setTargetZones(e==="vertical"?["top","bottom"]:["left","right"])}updateDragAndDropState(){this._element.draggable=!this.accessor.options.disableDnd,this.dragHandler.setDisabled(!!this.accessor.options.disableDnd)}}class wt{get kind(){return this.options.kind}get nativeEvent(){return this.event.nativeEvent}get position(){return this.event.position}get defaultPrevented(){return this.event.defaultPrevented}get panel(){return this.options.panel}get api(){return this.options.api}get group(){return this.options.group}preventDefault(){this.event.preventDefault()}getData(){return this.options.getData()}constructor(e,t){this.event=e,this.options=t}}class hs extends Kt{constructor(e,t,i,n){super(e,n),this.accessor=t,this.group=i,this.panelTransfer=De.getInstance(),this.addDisposables(k(e,"pointerdown",s=>{s.shiftKey&&In(s)},!0))}isCancelled(e){return this.group.api.location.type==="floating"&&!e.shiftKey||this.group.api.location.type==="edge"&&this.group.size===0}getData(e){const t=e.dataTransfer;this.panelTransfer.setData([new Ce(this.accessor.id,this.group.id,null)],Ce.prototype);const i=window.getComputedStyle(this.el),n=i.getPropertyValue("--dv-activegroup-visiblepanel-tab-background-color"),s=i.getPropertyValue("--dv-activegroup-visiblepanel-tab-color");if(t){const l=document.createElement("div");l.style.backgroundColor=n,l.style.color=s,l.style.padding="2px 8px",l.style.height="24px",l.style.fontSize="11px",l.style.lineHeight="20px",l.style.borderRadius="12px",l.style.position="absolute",l.style.pointerEvents="none",l.style.top="-9999px",l.textContent=`Multiple Panels (${this.group.size})`,Ki(t,l,{y:-10,x:30})}return{dispose:()=>{this.panelTransfer.clearData(Ce.prototype)}}}}class cs extends R{get element(){return this._element}constructor(e,t){super(),this.accessor=e,this.group=t,this._onDrop=new _,this.onDrop=this._onDrop.event,this._onDragStart=new _,this.onDragStart=this._onDragStart.event,this._element=document.createElement("div"),this._element.className="dv-void-container",this._element.draggable=!this.accessor.options.disableDnd,A(this._element,"dv-draggable",!this.accessor.options.disableDnd),this.addDisposables(this._onDrop,this._onDragStart,k(this._element,"pointerdown",()=>{this.accessor.doSetGroupActive(this.group)})),this.handler=new hs(this._element,e,t,!!this.accessor.options.disableDnd),this.dropTarget=new we(this._element,{acceptedTargetZones:["center"],canDisplayOverlay:(i,n)=>{const s=re();return s&&this.accessor.id===s.viewId?!0:t.model.canDisplayOverlay(i,n,"header_space")},getOverrideTarget:()=>{var i;return(i=t.model.dropTargetContainer)===null||i===void 0?void 0:i.model}}),this.onWillShowOverlay=this.dropTarget.onWillShowOverlay,this.addDisposables(this.handler,this.handler.onDragStart(i=>{this._onDragStart.fire(i)}),this.dropTarget.onDrop(i=>{this._onDrop.fire(i)}),this.dropTarget)}updateDragAndDropState(){this._element.draggable=!this.accessor.options.disableDnd,A(this._element,"dv-draggable",!this.accessor.options.disableDnd),this.handler.setDisabled(!!this.accessor.options.disableDnd)}}class Ct extends R{get element(){return this._element}get orientation(){return this._orientation}set orientation(e){this._orientation!==e&&(this._scrollOffset=0,this._orientation=e,ye(this._scrollbar,"dv-scrollbar-vertical","dv-scrollbar-horizontal"),e==="vertical"?xe(this._scrollbar,"dv-scrollbar-vertical"):xe(this._scrollbar,"dv-scrollbar-horizontal"))}constructor(e){super(),this.scrollableElement=e,this._scrollOffset=0,this._orientation="horizontal",this._element=document.createElement("div"),this._element.className="dv-scrollable",this._scrollbar=document.createElement("div"),this._scrollbar.className="dv-scrollbar dv-scrollbar-horizontal",this.element.appendChild(e),this.element.appendChild(this._scrollbar),this.addDisposables(k(this.element,"wheel",t=>{this._scrollOffset+=t.deltaY*Ct.MouseWheelSpeed,this.calculateScrollbarStyles()}),k(this._scrollbar,"pointerdown",t=>{t.preventDefault(),A(this.element,"dv-scrollable-scrolling",!0);const i=this._orientation==="horizontal"?t.clientX:t.clientY,n=this._scrollOffset,s=a=>{const r=this._orientation==="horizontal"?a.clientX-i:a.clientY-i,d=this._orientation==="horizontal"?this.element.clientWidth:this.element.clientHeight,h=this._orientation==="horizontal"?this.scrollableElement.scrollWidth:this.scrollableElement.scrollHeight,c=d/h;this._scrollOffset=n+r/c,this.calculateScrollbarStyles()},l=()=>{A(this.element,"dv-scrollable-scrolling",!1),document.removeEventListener("pointermove",s),document.removeEventListener("pointerup",l),document.removeEventListener("pointercancel",l)};document.addEventListener("pointermove",s),document.addEventListener("pointerup",l),document.addEventListener("pointercancel",l)}),k(this.element,"scroll",()=>{this.calculateScrollbarStyles()}),k(this.scrollableElement,"scroll",()=>{this._scrollOffset=this._orientation==="horizontal"?this.scrollableElement.scrollLeft:this.scrollableElement.scrollTop,this.calculateScrollbarStyles()}),tt(this.element,()=>{A(this.element,"dv-scrollable-resizing",!0),this._animationTimer&&clearTimeout(this._animationTimer),this._animationTimer=setTimeout(()=>{clearTimeout(this._animationTimer),A(this.element,"dv-scrollable-resizing",!1)},500),this.calculateScrollbarStyles()}))}calculateScrollbarStyles(){const e=this._orientation==="horizontal"?this.element.clientWidth:this.element.clientHeight,t=this._orientation==="horizontal"?this.scrollableElement.scrollWidth:this.scrollableElement.scrollHeight;if(t>e){const n=e*(e/t);this._orientation==="horizontal"?(this._scrollbar.style.width=`${n}px`,this._scrollbar.style.height=""):(this._scrollbar.style.height=`${n}px`,this._scrollbar.style.width=""),this._scrollOffset=Y(this._scrollOffset,0,t-e),this._orientation==="horizontal"?this.scrollableElement.scrollLeft=this._scrollOffset:this.scrollableElement.scrollTop=this._scrollOffset;const s=this._scrollOffset/(t-e);this._orientation==="horizontal"?(this._scrollbar.style.left=`${(e-n)*s}px`,this._scrollbar.style.top=""):(this._scrollbar.style.top=`${(e-n)*s}px`,this._scrollbar.style.left="")}else this._orientation==="horizontal"?(this._scrollbar.style.width="0px",this._scrollbar.style.left="0px"):(this._scrollbar.style.height="0px",this._scrollbar.style.top="0px"),this._scrollOffset=0}}Ct.MouseWheelSpeed=1;const Yt=[{id:"grey",value:"var(--dv-tab-group-color-grey)",label:"Grey"},{id:"blue",value:"var(--dv-tab-group-color-blue)",label:"Blue"},{id:"red",value:"var(--dv-tab-group-color-red)",label:"Red"},{id:"yellow",value:"var(--dv-tab-group-color-yellow)",label:"Yellow"},{id:"green",value:"var(--dv-tab-group-color-green)",label:"Green"},{id:"pink",value:"var(--dv-tab-group-color-pink)",label:"Pink"},{id:"purple",value:"var(--dv-tab-group-color-purple)",label:"Purple"},{id:"cyan",value:"var(--dv-tab-group-color-cyan)",label:"Cyan"},{id:"orange",value:"var(--dv-tab-group-color-orange)",label:"Orange"}];class Ji{constructor(e,t=!0){this._entries=e.slice(),this._byId=new Map(e.map(i=>[i.id,i])),this._enabled=t}get enabled(){return this._enabled}set enabled(e){this._enabled=e}setEntries(e){this._entries=e.slice(),this._byId=new Map(e.map(t=>[t.id,t]))}entries(){return this._entries}has(e){return this._byId.has(e)}get(e){return this._byId.get(e)}defaultId(){var e;return(e=this._entries[0])===null||e===void 0?void 0:e.id}resolveValue(e){if(!this._enabled||!e)return;const t=this._byId.get(e);return t?t.value:e}}let Pt;function Yi(){return Pt||(Pt=new Ji(Yt,!0)),Pt}function Zt(o,e,t){const i=(t??Yi()).resolveValue(e);i===void 0?o.style.removeProperty("--dv-tab-group-color"):o.style.setProperty("--dv-tab-group-color",i)}function Zi(o,e){return(e??Yi()).resolveValue(o)}class di extends R{get element(){return this._element}constructor(e){super(),this._palette=e,this._onClick=new _,this.onClick=this._onClick.event,this._onContextMenu=new _,this.onContextMenu=this._onContextMenu.event,this._onDragStart=new _,this.onDragStart=this._onDragStart.event,this._element=document.createElement("div"),this._element.className="dv-tab-group-chip",this._element.tabIndex=0,this._element.draggable=!0,this._label=document.createElement("span"),this._label.className="dv-tab-group-chip-label",this._element.appendChild(this._label),this.addDisposables(this._onClick,this._onContextMenu,this._onDragStart,k(this._element,"click",t=>{this._onClick.fire(t)}),k(this._element,"contextmenu",t=>{this._onContextMenu.fire(t)}),k(this._element,"dragstart",t=>{this._onDragStart.fire(t)}))}init(e){this._tabGroup=e.tabGroup,this.updateColor(e.tabGroup.color),this.updateLabel(e.tabGroup.label),this.updateCollapsed(e.tabGroup.collapsed),this.addDisposables(e.tabGroup.onDidChange(()=>{this._tabGroup&&(this.updateColor(this._tabGroup.color),this.updateLabel(this._tabGroup.label))}),e.tabGroup.onDidCollapseChange(t=>{this.updateCollapsed(t)}),this._onClick.event(()=>{var t;(t=this._tabGroup)===null||t===void 0||t.toggle()}))}update(e){this._tabGroup=e.tabGroup,this.updateColor(e.tabGroup.color),this.updateLabel(e.tabGroup.label),this.updateCollapsed(e.tabGroup.collapsed)}updateColor(e){var t;Zt(this._element,e,this._palette),A(this._element,"dv-tab-group-chip--accent-off",((t=this._palette)===null||t===void 0?void 0:t.enabled)===!1)}updateLabel(e){this._label.textContent=e,A(this._label,"dv-tab-group-chip-label--empty",!e)}updateCollapsed(e){A(this._element,"dv-tab-group-chip--collapsed",e)}}class Xi{get underlines(){return this._underlines}constructor(e){this._ctx=e,this._underlines=new Map,this._rafId=null}positionUnderlines(){requestAnimationFrame(()=>{this._positionUnderlinesSync()})}trackUnderlines(){this._rafId!==null&&cancelAnimationFrame(this._rafId);const e=performance.now(),t=250,i=()=>{this._positionUnderlinesSync(),performance.now()-e<t?this._rafId=requestAnimationFrame(i):this._rafId=null};this._rafId=requestAnimationFrame(i)}syncUnderlineElements(e){for(const t of e)if(!this._underlines.has(t)){const i=document.createElement("div");i.className="dv-tab-group-underline",this._ctx.tabsList.appendChild(i),this._underlines.set(t,i)}for(const[t,i]of this._underlines)e.has(t)||(i.remove(),this._underlines.delete(t))}getUnderline(e){return this._underlines.get(e)}dispose(){this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null);for(const[,e]of this._underlines)e.remove();this._underlines.clear()}_positionUnderlinesSync(){const e=this._ctx.tabsList.getBoundingClientRect(),t=this._ctx.getTabGroups(),i=this._ctx.getDirection()==="vertical",n=i?e.width:e.height,s=this._ctx.getActivePanelId(),l=this._ctx.getTabMap();for(const a of t){const r=this._underlines.get(a.id);if(!r)continue;const d=a.panelIds;if(d.length===0){r.style.display="none";continue}r.style.display="";const h=this._ctx.getChipElement(a.id);let c;if(h){const b=h.getBoundingClientRect(),w=getComputedStyle(h),C=i?Number.parseFloat(w.marginTop)||0:Number.parseFloat(w.marginLeft)||0;c=i?b.top-e.top-C:b.left-e.left-C}else{const b=d[0],w=l.get(b);if(w){const C=w.value.element.getBoundingClientRect();c=i?C.top-e.top:C.left-e.left}else c=0}const u=d[d.length-1],p=l.get(u);if(!p){i?(r.style.top=`${c}px`,r.style.height="0px",r.style.left="",r.style.width=""):(r.style.left=`${c}px`,r.style.width="0px",r.style.top="",r.style.height="");continue}const f=p.value.element.getBoundingClientRect();let m=i?f.bottom-e.top:f.right-e.left,g=m-c;if((a.collapsed||a.panelIds.some(b=>{const w=l.get(b);return w&&w.value.element.classList.contains("dv-tab--group-expanding")}))&&h){const b=h.getBoundingClientRect(),w=i?b.top+b.height/2-e.top:b.left+b.width/2-e.left;let C=0,I=0;for(const D of a.panelIds){const G=l.get(D);if(!G)continue;const M=G.value.element;i?(C+=M.getBoundingClientRect().height,I+=M.scrollHeight):(C+=M.getBoundingClientRect().width,I+=M.scrollWidth)}const E=I>0?Math.min(1,C/I):0;c=w+(c-w)*E,m=w+(m-w)*E,g=Math.max(0,m-c)}i?(r.style.top=`${c}px`,r.style.height=`${Math.max(0,g)}px`,r.style.left="",r.style.width=""):(r.style.left=`${c}px`,r.style.width=`${Math.max(0,g)}px`,r.style.top="",r.style.height=""),this.applyShape(r,a,c,g,n,s,e,i)}}}class us extends Xi{_applyStraightLine(e,t,i,n,s,l){l?(e.setAttribute("width",String(n)),e.setAttribute("height",String(s)),i.style.width=`${n}px`,i.style.height=`${s}px`,t.setAttribute("d",`M ${n/2},0 L ${n/2},${s}`)):(e.setAttribute("width",String(s)),e.setAttribute("height",String(n)),i.style.width=`${s}px`,i.style.height=`${n}px`,t.setAttribute("d",`M 0,${n/2} L ${s},${n/2}`))}applyShape(e,t,i,n,s,l,a,r){const h=s,c=n,u=Zi(t.color,this._ctx.getColorPalette());if(c<=0||h<=0||u===void 0){e.style.display="none";return}e.style.display="";let p;l&&t.panelIds.includes(l)&&(p=this._ctx.getTabMap().get(l));let f=e.firstElementChild,m;if(!f||f.tagName!=="svg"?(e.innerHTML="",f=document.createElementNS("http://www.w3.org/2000/svg","svg"),f.style.display="block",m=document.createElementNS("http://www.w3.org/2000/svg","path"),m.setAttribute("fill","none"),f.appendChild(m),e.appendChild(f)):m=f.firstElementChild,m.setAttribute("stroke",u),m.setAttribute("stroke-width",String(2)),!p){this._applyStraightLine(f,m,e,2,c,r);return}const g=p.value.element.getBoundingClientRect();let v,b;if(r?(v=Math.max(0,g.top-a.top-i),b=Math.min(c,g.bottom-a.top-i)):(v=Math.max(0,g.left-a.left-i),b=Math.min(c,g.right-a.left-i)),b<=v){this._applyStraightLine(f,m,e,2,c,r);return}const w=6,C=2/2;if(r){const I=h,E=c;f.setAttribute("width",String(I)),f.setAttribute("height",String(E)),e.style.width=`${I}px`,e.style.height=`${E}px`;const D=C,G=I-C,M=[`M ${D},0`,`L ${D},${v-w}`,`Q ${D},${v} ${D+w},${v}`,`L ${G-w},${v}`,`Q ${G},${v} ${G},${v+w}`,`L ${G},${b-w}`,`Q ${G},${b} ${G-w},${b}`,`L ${D+w},${b}`,`Q ${D},${b} ${D},${b+w}`,`L ${D},${E}`].join(" ");m.setAttribute("d",M)}else{const I=c,E=h;f.setAttribute("width",String(I)),f.setAttribute("height",String(E)),e.style.width=`${I}px`,e.style.height=`${E}px`;const D=E-C,G=C,M=[`M 0,${D}`,`L ${v-w},${D}`,`Q ${v},${D} ${v},${D-w}`,`L ${v},${G+w}`,`Q ${v},${G} ${v+w},${G}`,`L ${b-w},${G}`,`Q ${b},${G} ${b},${G+w}`,`L ${b},${D-w}`,`Q ${b},${D} ${b+w},${D}`,`L ${I},${D}`].join(" ");m.setAttribute("d",M)}}}class ps extends Xi{applyShape(e,t,i,n,s,l,a,r){const h=Zi(t.color,this._ctx.getColorPalette());if(n<=0||h===void 0){e.style.display="none";return}e.style.display="",e.firstElementChild&&(e.innerHTML=""),e.style.backgroundColor=h,r?(e.style.width="2px",e.style.height=`${n}px`):(e.style.width=`${n}px`,e.style.height="2px")}}const ms=new Map;class fs{get chipRenderers(){return this._chipRenderers}get groupUnderlines(){var e,t;return(t=(e=this._indicator)===null||e===void 0?void 0:e.underlines)!==null&&t!==void 0?t:ms}get skipNextCollapseAnimation(){return this._skipNextCollapseAnimation}set skipNextCollapseAnimation(e){this._skipNextCollapseAnimation=e}constructor(e,t){this._ctx=e,this._callbacks=t,this._chipRenderers=new Map,this._indicator=null,this._skipNextCollapseAnimation=!1,this._pendingTransitionCleanups=new Map}update(){const t=this._ctx.group.model.getTabGroups(),i=new Set;for(const n of t)i.add(n.id),this._ensureChipForGroup(n),this._positionChipForGroup(n);for(const[n,s]of this._chipRenderers)i.has(n)||(s.chip.element.remove(),s.chip.dispose(),s.disposable.dispose(),this._chipRenderers.delete(n));this._updateTabGroupClasses()}refreshAccents(){var e,t;for(const i of this._ctx.group.model.getTabGroups()){const n=this._chipRenderers.get(i.id);(t=n==null?void 0:(e=n.chip).update)===null||t===void 0||t.call(e,{tabGroup:i})}this._updateTabGroupClasses()}positionAllChips(){if(this._chipRenderers.size!==0)for(const e of this._ctx.group.model.getTabGroups())this._positionChipForGroup(e)}snapshotChipWidths(){const e=new Map;for(const[t,i]of this._chipRenderers)e.set(t,i.chip.element.getBoundingClientRect().width);return e}positionUnderlines(){var e;(e=this._indicator)===null||e===void 0||e.positionUnderlines()}trackUnderlines(){var e;(e=this._indicator)===null||e===void 0||e.trackUnderlines()}setGroupDragImage(e,t,i){if(!e.dataTransfer)return;const n=this._ctx.getDirection()==="vertical",s=this._ctx.tabsList.cloneNode(!0);n?(s.classList.remove("dv-tabs-container-vertical","dv-vertical"),s.classList.add("dv-horizontal"),s.style.writingMode="horizontal-tb",s.style.height=`${this._ctx.tabsList.offsetWidth}px`):s.style.height=`${this._ctx.tabsList.offsetHeight}px`,s.style.width="auto",s.style.overflow="visible",s.style.pointerEvents="none";const l=Array.from(s.children),a=Array.from(this._ctx.tabsList.children);for(let f=l.length-1;f>=0;f--)a[f]!==i&&l[f].remove();const r=document.createElement("div");r.className="dv-groupview dv-active-group",r.style.position="fixed",r.style.top="-10000px",r.style.left="0px",r.style.height="auto",r.style.width="auto",r.style.pointerEvents="none";const d=document.createElement("div");d.className="dv-tabs-and-actions-container",d.style.height="auto",d.style.width="auto",r.appendChild(d),d.appendChild(s),this._ctx.accessor.element.appendChild(r);const h=s.querySelector(".dv-tab-group-chip"),c=i.getBoundingClientRect(),u=e.clientX-c.left,p=e.clientY-c.top;if(h){const f=h.getBoundingClientRect(),m=r.getBoundingClientRect(),g=f.left-m.left+u,v=f.top-m.top+p;e.dataTransfer.setDragImage(r,g,v)}else e.dataTransfer.setDragImage(r,u,p);requestAnimationFrame(()=>{r.remove()})}cleanupTransition(e){var t;(t=this._pendingTransitionCleanups.get(e))===null||t===void 0||t(),this._pendingTransitionCleanups.delete(e)}disposeAll(){var e;(e=this._indicator)===null||e===void 0||e.dispose(),this._indicator=null;for(const[,t]of this._pendingTransitionCleanups)t();this._pendingTransitionCleanups.clear();for(const[,t]of this._chipRenderers)t.chip.element.remove(),t.chip.dispose(),t.disposable.dispose();this._chipRenderers.clear()}_ensureIndicator(){var e,t;const n=((t=(e=this._ctx.accessor.options.theme)===null||e===void 0?void 0:e.tabGroupIndicator)!==null&&t!==void 0?t:"wrap")==="none"?ps:us;this._indicator&&!(this._indicator instanceof n)&&(this._indicator.dispose(),this._indicator=null),this._indicator||(this._indicator=new n({tabsList:this._ctx.tabsList,getTabGroups:()=>this._ctx.group.model.getTabGroups(),getActivePanelId:()=>{var s;return(s=this._ctx.group.activePanel)===null||s===void 0?void 0:s.id},getTabMap:()=>this._ctx.getTabMap(),getChipElement:s=>{var l;return(l=this._chipRenderers.get(s))===null||l===void 0?void 0:l.chip.element},getDirection:()=>this._ctx.getDirection(),getColorPalette:()=>this._ctx.accessor.tabGroupColorPalette}))}_ensureChipForGroup(e){if(this._chipRenderers.has(e.id))return;const t=this._ctx.accessor.options.createTabGroupChipComponent,i=t?t(e):new di(this._ctx.accessor.tabGroupColorPalette);i.init({tabGroup:e,api:this._ctx.accessor.api});const n=[e.onDidChange(()=>{var l;(l=i.update)===null||l===void 0||l.call(i,{tabGroup:e}),this._updateTabGroupClasses()}),e.onDidPanelChange(()=>{this._positionChipForGroup(e),this._updateTabGroupClasses()}),e.onDidCollapseChange(()=>{this._updateTabGroupClasses()})];i instanceof di?n.push(i.onContextMenu(l=>{this._callbacks.onChipContextMenu(e,l)}),i.onDragStart(l=>{this._callbacks.onChipDragStart(e,i,l)})):n.push(k(i.element,"contextmenu",l=>{this._callbacks.onChipContextMenu(e,l)}),k(i.element,"dragstart",l=>{this._callbacks.onChipDragStart(e,i,l)}));const s=new R(...n);this._chipRenderers.set(e.id,{chip:i,disposable:s}),e.collapsed&&(this._skipNextCollapseAnimation=!0)}_positionChipForGroup(e){const t=this._chipRenderers.get(e.id);if(!t)return;const i=t.chip.element,n=e.panelIds;if(n.length===0){i.remove();return}const s=n[0],l=this._ctx.getTabMap().get(s);if(!l){i.remove();return}const a=l.value.element;i.nextSibling!==a&&this._ctx.tabsList.insertBefore(i,a)}_updateTabGroupClasses(){var e;const i=this._ctx.group.model.getTabGroups(),n=this._ctx.getTabs(),s=this._ctx.getTabMap();let l=!1;const a=new Map;for(const d of i)for(const h of d.panelIds)a.set(h,d);for(const d of n){const h=d.value,c=h.panel.id,u=a.get(c),p=!!u;if(A(h.element,"dv-tab--grouped",p),u){const f=u.panelIds,m=f[0]===c,g=f[f.length-1]===c;A(h.element,"dv-tab--group-first",m),A(h.element,"dv-tab--group-last",g),Zt(h.element,u.color,this._ctx.accessor.tabGroupColorPalette);const v=h.element.classList.contains("dv-tab--group-collapsed");if(!u.collapsed&&v){l=!0,h.element.classList.remove("dv-tab--group-collapsed"),h.element.classList.add("dv-tab--group-expanding"),(e=this._pendingTransitionCleanups.get(c))===null||e===void 0||e();const b=()=>{h.element.classList.remove("dv-tab--group-expanding"),h.element.style.removeProperty("width"),h.element.removeEventListener("transitionend",b),clearTimeout(w),this._pendingTransitionCleanups.delete(c)},w=setTimeout(b,300);this._pendingTransitionCleanups.set(c,b),h.element.addEventListener("transitionend",b)}}else A(h.element,"dv-tab--group-first",!1),A(h.element,"dv-tab--group-last",!1),h.element.classList.remove("dv-tab--group-collapsed","dv-tab--group-expanding"),h.element.style.removeProperty("width"),h.element.style.removeProperty("--dv-tab-group-color")}const r=new Set;for(const d of i)if(r.add(d.id),d.collapsed&&d.panelIds.some(c=>{const u=s.get(c);return u&&!u.value.element.classList.contains("dv-tab--group-collapsed")}))if(this._skipNextCollapseAnimation){const c=[];for(const u of d.panelIds){const p=s.get(u);p&&(p.value.element.style.transition="none",p.value.element.classList.add("dv-tab--group-collapsed"),c.push(p.value.element))}if(c.length>0){c[0].offsetHeight;for(const u of c)u.style.removeProperty("transition")}}else{l=!0;const c=this._ctx.getDirection()==="vertical";for(const u of d.panelIds){const p=s.get(u);if(p&&!p.value.element.classList.contains("dv-tab--group-collapsed")){const f=p.value.element.getBoundingClientRect();c?p.value.element.style.height=`${f.height}px`:p.value.element.style.width=`${f.width}px`,p.value.element.offsetHeight,p.value.element.classList.add("dv-tab--group-collapsed")}}}this._skipNextCollapseAnimation=!1,this._ensureIndicator(),this._indicator&&(this._indicator.syncUnderlineElements(r),l?this._indicator.trackUnderlines():this._indicator.positionUnderlines())}}class gs extends R{get showTabsOverflowControl(){return this._showTabsOverflowControl}set showTabsOverflowControl(e){if(this._showTabsOverflowControl!=e&&(this._showTabsOverflowControl=e,e)){const t=new Gn(this._tabsList);this._observerDisposable.value=new R(t,t.onDidChange(i=>{const n=i.hasScrollX||i.hasScrollY;this.toggleDropdown({reset:!n}),this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}),k(this._tabsList,"scroll",()=>{this.toggleDropdown({reset:!1}),this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}))}}get element(){return this._element}set voidContainer(e){var t;(t=this._voidContainerListeners)===null||t===void 0||t.dispose(),this._voidContainerListeners=null,this._voidContainer=e,e&&(this._voidContainerListeners=new R(k(e,"dragover",i=>{this._animState&&i.preventDefault()}),k(e,"drop",i=>{var n;!((n=this._animState)===null||n===void 0)&&n.sourceTabGroupId&&this._animState.currentInsertionIndex!==null&&(i.preventDefault(),i.stopPropagation(),this.handleVoidDrop())})))}handleVoidDrop(){var e,t;if(!(!((e=this._animState)===null||e===void 0)&&e.sourceTabGroupId))return!1;const i=this._animState.sourceTabGroupId,n=(t=this._animState.currentInsertionIndex)!==null&&t!==void 0?t:this._tabs.length;return this._animState=null,this._commitGroupMove(i,n),!0}get panels(){return this._tabs.map(e=>e.value.panel.id)}get size(){return this._tabs.length}get tabs(){return this._tabs.map(e=>e.value)}get direction(){return this._direction}set direction(e){if(this._direction!==e){this._direction=e,this._scrollbar&&(this._scrollbar.orientation=e),ye(this._tabsList,"dv-horizontal","dv-vertical"),e==="vertical"?xe(this._tabsList,"dv-tabs-container-vertical","dv-vertical"):(ye(this._tabsList,"dv-tabs-container-vertical"),xe(this._tabsList,"dv-horizontal"));for(const t of this._tabs)t.value.setDirection(e)}}constructor(e,t,i){super(),this.group=e,this.accessor=t,this._observerDisposable=new le,this._scrollbar=null,this._tabs=[],this._tabMap=new Map,this.selectedIndex=-1,this._showTabsOverflowControl=!1,this._direction="horizontal",this._animState=null,this._pendingMarginCleanups=new Map,this._pendingCollapse=!1,this._flipTransitionCleanup=null,this._voidContainer=null,this._voidContainerListeners=null,this._extendedDropZone=null,this._chipDragCleanup=null,this._onTabDragStart=new _,this.onTabDragStart=this._onTabDragStart.event,this._onDrop=new _,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new _,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onOverflowTabsChange=new _,this.onOverflowTabsChange=this._onOverflowTabsChange.event,this._tabsList=document.createElement("div"),this._tabsList.className="dv-tabs-container",this.showTabsOverflowControl=i.showTabsOverflowControl,t.options.scrollbars==="native"?this._element=this._tabsList:(this._scrollbar=new Ct(this._tabsList),this._scrollbar.orientation=this.direction,this._element=this._scrollbar.element,this.addDisposables(this._scrollbar)),this._tabGroupManager=new fs({group:this.group,accessor:this.accessor,tabsList:this._tabsList,getTabs:()=>this._tabs,getTabMap:()=>this._tabMap,getDirection:()=>this._direction},{onChipContextMenu:(n,s)=>{this.accessor.contextMenuController.showForChip(n,this.group,s)},onChipDragStart:(n,s,l)=>{this._handleChipDragStart(n,s,l)}}),this.addDisposables(this._onOverflowTabsChange,this._observerDisposable,this._onWillShowOverlay,this._onDrop,this._onTabDragStart,{dispose:()=>{var n;(n=this._flipTransitionCleanup)===null||n===void 0||n.call(this)}},k(this.element,"pointerdown",n=>{if(n.defaultPrevented)return;n.button===0&&this.accessor.doSetGroupActive(this.group)}),k(this._tabsList,"dragover",n=>{var s,l,a,r;if(!this.accessor.options.disableDnd){if(this._animState){const d=re();d!=null&&d.tabGroupId&&d.groupId!==this.group.id&&this._animState.sourceTabGroupId!==d.tabGroupId&&(this._animState=null)}if(!this._animState){const d=re();if(((s=this.accessor.options.theme)===null||s===void 0?void 0:s.tabAnimation)==="default"&&!(d!=null&&d.tabGroupId))return;if(d&&(d.panelId||d.tabGroupId)&&d.groupId!==this.group.id){const h=this.getAverageTabWidth();if(d.tabGroupId){const c=this.accessor.getPanel(d.groupId),u=c==null?void 0:c.model.getTabGroups().find(m=>m.id===d.tabGroupId),p=(l=u==null?void 0:u.panelIds.length)!==null&&l!==void 0?l:1,f=h*p+h;this._animState={sourceTabId:"",sourceIndex:-1,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:d.tabGroupId,sourceGroupPanelIds:u?new Set(u.panelIds):new Set,sourceChipWidth:h,cursorOffsetFromDragLeft:f/2,sourceGapWidth:f,containerLeft:this._tabsList.getBoundingClientRect().left}}else this._animState={sourceTabId:d.panelId,sourceIndex:-1,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:null,sourceGroupPanelIds:null,sourceChipWidth:0,cursorOffsetFromDragLeft:h/2,sourceGapWidth:h,containerLeft:this._tabsList.getBoundingClientRect().left}}else return}n.preventDefault(),this._animState.sourceIndex!==-1&&((r=(a=this.group.model.dropTargetContainer)===null||a===void 0?void 0:a.model)===null||r===void 0||r.clear()),this.handleDragOver(n)}},!0),k(this._tabsList,"dragleave",n=>{var s,l,a;if(!this._animState)return;const r=n.relatedTarget;if(r&&this._tabsList.contains(r))return;if(r&&(!((s=this._extendedDropZone)===null||s===void 0)&&s.contains(r))){this.resetTabTransforms(),this._animState.currentInsertionIndex=null;return}const d=n.relatedTarget;this._voidContainer&&d&&(d===this._voidContainer||this._voidContainer.contains(d))||(this.resetTabTransforms(),this._animState&&(this._animState.sourceIndex===-1?((a=(l=this.group.model.dropTargetContainer)===null||l===void 0?void 0:l.model)===null||a===void 0||a.clear(),this._animState=null):this._animState.currentInsertionIndex=null))},!0),k(this._tabsList,"dragend",()=>{this.resetDragAnimation()}),k(this._tabsList,"drop",n=>{var s,l,a;if(!this._animState||this._animState.currentInsertionIndex===null||((s=this.accessor.options.theme)===null||s===void 0?void 0:s.tabAnimation)!=="smooth"&&!this._animState.sourceTabGroupId)return;n.stopPropagation(),n.preventDefault(),(a=(l=this.group.model.dropTargetContainer)===null||l===void 0?void 0:l.model)===null||a===void 0||a.clear();const r=this._animState;if(this._animState=null,this._pendingCollapse=!1,r.sourceTabGroupId){this._commitGroupMove(r.sourceTabGroupId,r.currentInsertionIndex);return}const d=r.currentInsertionIndex,h=r.sourceIndex,c=d-(h!==-1&&h<d?1:0),u=this.group.model.getTabGroupForPanel(r.sourceTabId);if(c===h&&!r.targetTabGroupId&&!u){this._uncollapsSourceTab(r.sourceTabId),this.resetTabTransforms();return}this._uncollapsSourceTab(r.sourceTabId);const p=this.snapshotTabPositions();this.resetTabTransforms(),this._onDrop.fire({event:n,index:c,targetTabGroupId:r.targetTabGroupId}),this.runFlipAnimation(p,r.sourceTabId,r.sourceIndex===-1,{from:Math.min(h,c),to:Math.max(h,c)})},!0),ne.from(()=>{var n;(n=this._voidContainerListeners)===null||n===void 0||n.dispose(),this.resetDragAnimation(),this._tabGroupManager.disposeAll();for(const{value:s,disposable:l}of this._tabs)l.dispose(),s.dispose();this._tabs=[],this._tabMap.clear()}))}indexOf(e){return this._tabs.findIndex(t=>t.value.panel.id===e)}isActive(e){return this.selectedIndex>-1&&this._tabs[this.selectedIndex].value===e}setActivePanel(e){const t=this._direction==="vertical";let i=0;for(const n of this._tabs){const s=e.id===n.value.panel.id;if(n.value.setActive(s),s){const l=n.value.element,a=l.parentElement;t?(i<a.scrollTop||i+l.clientHeight>a.scrollTop+a.clientHeight)&&(a.scrollTop=i):(i<a.scrollLeft||i+l.clientWidth>a.scrollLeft+a.clientWidth)&&(a.scrollLeft=i)}i+=t?n.value.element.clientHeight:n.value.element.clientWidth}this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}openPanel(e,t=this._tabs.length){if(this._tabMap.has(e.id))return;const i=new ds(e,this.accessor,this.group);i.setContent(e.view.tab),this._direction!=="horizontal"&&i.setDirection(this._direction);const n=new R(i.onDragStart(l=>{var a;if(this._onTabDragStart.fire({nativeEvent:l,panel:e}),((a=this.accessor.options.theme)===null||a===void 0?void 0:a.tabAnimation)==="smooth"){const r=i.element.getBoundingClientRect().width,d=this._tabs.findIndex(h=>h.value===i);this._animState={sourceTabId:e.id,sourceIndex:d,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:null,sourceGroupPanelIds:null,sourceChipWidth:0,cursorOffsetFromDragLeft:r/2,sourceGapWidth:r,containerLeft:this._tabsList.getBoundingClientRect().left},this._pendingCollapse=!0,requestAnimationFrame(()=>{var h,c;this._pendingCollapse=!1,this._animState&&(i.element.style.transition="none",A(i.element,"dv-tab--dragging",!0),i.element.offsetHeight,(h=(c=this._animState).currentInsertionIndex)!==null&&h!==void 0||(c.currentInsertionIndex=d),this.applyDragOverTransforms(!0),i.element.style.removeProperty("transition"))})}}),i.onTabClick(l=>{l.defaultPrevented||this.group.api.location.type==="edge"&&(this.group.activePanel===e?this.group.api.isCollapsed()?this.group.api.expand():this.group.api.collapse():(this.group.model.openPanel(e),this.group.api.isCollapsed()&&this.group.api.expand()))}),i.onPointerDown(l=>{if(l.defaultPrevented)return;const a=!this.accessor.options.disableFloatingGroups,r=this.group.api.location.type==="floating"&&this.size===1;if(a&&!r&&l.shiftKey){l.preventDefault();const d=this.accessor.getGroupPanel(i.panel.id),{top:h,left:c}=i.element.getBoundingClientRect(),{top:u,left:p}=this.accessor.element.getBoundingClientRect();this.accessor.addFloatingGroup(d,{x:c-p,y:h-u,inDragMode:!0});return}switch(l.button){case 0:this.group.api.location.type==="edge"||this.group.activePanel!==e&&this.group.model.openPanel(e);break}}),i.onDrop(l=>{var a,r,d,h;const c=this._animState;this._animState=null,this._pendingCollapse=!1;const u=this._tabs.findIndex(p=>p.value===i);if(c){const p=l.position==="right"?u+1:u;if(c.sourceTabGroupId){this._commitGroupMove(c.sourceTabGroupId,(a=c.currentInsertionIndex)!==null&&a!==void 0?a:p);return}this._uncollapsSourceTab(c.sourceTabId);const f=this.snapshotTabPositions();this.resetTabTransforms(),this._onDrop.fire({event:l.nativeEvent,index:p,targetTabGroupId:c.targetTabGroupId}),((r=this.accessor.options.theme)===null||r===void 0?void 0:r.tabAnimation)==="smooth"&&this.runFlipAnimation(f,c.sourceTabId,c.sourceIndex===-1,c.sourceIndex!==-1?{from:Math.min(c.sourceIndex,p),to:Math.max(c.sourceIndex,p)}:void 0)}else{const p=this._direction==="vertical"?"bottom":"right",f=l.position===p?u+1:u,m=re(),g=m?this._tabs.findIndex(w=>w.value.panel.id===m.panelId):-1,v=f-(g!==-1&&g<f?1:0),b=(h=(d=this.group.model.getTabGroupForPanel(i.panel.id))===null||d===void 0?void 0:d.id)!==null&&h!==void 0?h:null;this._onDrop.fire({event:l.nativeEvent,index:v,targetTabGroupId:b})}}),i.onWillShowOverlay(l=>{this._onWillShowOverlay.fire(new wt(l,{kind:"tab",panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:re}))})),s={value:i,disposable:n};this.addTab(s,t),this._tabGroupManager.positionAllChips(),this._animState&&(this._animState.tabPositions=this.snapshotTabPositions(),this._animState.chipPositions=this._tabGroupManager.snapshotChipWidths(),this.applyDragOverTransforms())}delete(e){var t;((t=this._animState)===null||t===void 0?void 0:t.sourceTabId)===e&&(this.resetTabTransforms(),this._animState=null),this._tabGroupManager.cleanupTransition(e);const i=this.indexOf(e),n=this._tabs.splice(i,1)[0];if(this._tabMap.delete(e),n){const{value:s,disposable:l}=n;l.dispose(),s.dispose(),s.element.remove()}this._animState&&(this._animState.tabPositions=this.snapshotTabPositions(),this._animState.chipPositions=this._tabGroupManager.snapshotChipWidths(),this.applyDragOverTransforms())}addTab(e,t=this._tabs.length){if(t<0||t>this._tabs.length)throw new Error("invalid location");const i=t<this._tabs.length?this._tabs[t].value.element:null;this._tabsList.insertBefore(e.value.element,i),this._tabs=[...this._tabs.slice(0,t),e,...this._tabs.slice(t)],this._tabMap.set(e.value.panel.id,e),this.selectedIndex<0&&(this.selectedIndex=t)}toggleDropdown(e){if(e.reset){this._onOverflowTabsChange.fire({tabs:[],tabGroups:[],reset:!0});return}const t=this._tabs.filter(s=>!ri(s.value.element,this._tabsList)).map(s=>s.value.panel.id),i=new Set(t),n=[];for(const s of this.group.model.getTabGroups()){const l=this._tabGroupManager.chipRenderers.get(s.id),a=l&&!ri(l.chip.element,this._tabsList),r=s.panelIds.length>0&&s.panelIds.every(d=>i.has(d));if((a||r)&&(n.push(s.id),s.collapsed))for(const d of s.panelIds)i.has(d)||(i.add(d),t.push(d))}this._onOverflowTabsChange.fire({tabs:t,tabGroups:n,reset:!1})}updateDragAndDropState(){for(const e of this._tabs)e.value.updateDragAndDropState()}updateTabGroups(){this._tabGroupManager.update()}refreshTabGroupAccent(){this._tabGroupManager.refreshAccents()}_handleChipDragStart(e,t,i){var n;const s=e.panelIds[0],l=s?this._tabs.findIndex(p=>p.value.panel.id===s):-1,a=t.element.getBoundingClientRect();let r=a.width;for(const p of e.panelIds){const f=this._tabMap.get(p);f&&(r+=f.value.element.getBoundingClientRect().width)}this._animState={sourceTabId:"",sourceIndex:l,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:e.id,sourceGroupPanelIds:new Set(e.panelIds),sourceChipWidth:a.width,cursorOffsetFromDragLeft:i.clientX-a.left,sourceGapWidth:r,containerLeft:this._tabsList.getBoundingClientRect().left};const d=De.getInstance();d.setData([new Ce(this.accessor.id,this.group.id,null,e.id)],Ce.prototype);const h=Qe(),c=t.element,u=()=>{c.removeEventListener("dragend",u),this.resetDragAnimation()};if(c.addEventListener("dragend",u),this._chipDragCleanup={dispose:()=>{c.removeEventListener("dragend",u),d.clearData(Ce.prototype),h.release()}},i.dataTransfer&&(i.dataTransfer.effectAllowed="move",i.dataTransfer.items.length===0&&i.dataTransfer.setData("text/plain","")),((n=this.accessor.options.theme)===null||n===void 0?void 0:n.tabAnimation)==="smooth"){const p=new Set(e.panelIds);this._pendingCollapse=!0,requestAnimationFrame(()=>{var f,m;if(this._pendingCollapse=!1,!this._animState)return;for(const b of this._tabs)p.has(b.value.panel.id)&&(b.value.element.style.transition="none",A(b.value.element,"dv-tab--dragging",!0));const g=this._tabGroupManager.chipRenderers.get(e.id);g&&(g.chip.element.style.transition="none",A(g.chip.element,"dv-tab-group-chip--dragging",!0)),this._tabsList.offsetHeight;const v=this._tabGroupManager.groupUnderlines.get(e.id);v&&(v.style.display="none"),(f=(m=this._animState).currentInsertionIndex)!==null&&f!==void 0||(m.currentInsertionIndex=l),this.applyDragOverTransforms(!0);for(const b of this._tabs)p.has(b.value.panel.id)&&b.value.element.style.removeProperty("transition");g&&g.chip.element.style.removeProperty("transition")})}this._tabGroupManager.setGroupDragImage(i,e,t.element)}setExtendedDropZone(e){this._extendedDropZone=e}setExternalInsertionIndex(e){this._animState&&e!==this._animState.currentInsertionIndex&&(this._animState.currentInsertionIndex=e,this.applyDragOverTransforms())}clearExternalAnimState(){this._animState&&(this.resetTabTransforms(),this._animState.sourceIndex===-1?this._animState=null:this._animState.currentInsertionIndex=null)}snapshotTabPositions(){const e=new Map;for(const t of this._tabs)e.set(t.value.panel.id,t.value.element.getBoundingClientRect());return e}getAverageTabWidth(){if(this._tabs.length===0)return 0;const e=this._direction==="vertical";let t=0;for(const i of this._tabs){const n=i.value.element.getBoundingClientRect();t+=e?n.height:n.width}return t/this._tabs.length}handleDragOver(e){var t,i,n,s,l;if(!this._animState)return;const a=e.clientX;let r=null,d=null;const h=this._animState.sourceGroupPanelIds,u=a-this._animState.cursorOffsetFromDragLeft-this._animState.containerLeft;let p=0;const f=new Map;if(this._tabGroupManager.chipRenderers.size>0){const m=this.group.model.getTabGroups();for(const g of m)g.id!==this._animState.sourceTabGroupId&&g.panelIds.length>0&&f.set(g.panelIds[0],g.id)}for(let m=0;m<this._tabs.length;m++){const g=this._tabs[m].value;if(g.panel.id===this._animState.sourceTabId||h!=null&&h.has(g.panel.id))continue;const v=f.get(g.panel.id);if(v){const C=(t=this._animState.chipPositions.get(v))!==null&&t!==void 0?t:0;if(p+C>u){r??(r=m);break}p+=C}const b=this._animState.tabPositions.get(g.panel.id),w=b?b.width:g.element.getBoundingClientRect().width;if(p+w/2<=u)p+=w,r=m+1;else{r??(r=m);break}}if(r!==null&&this._tabGroupManager.chipRenderers.size>0){const m=!!this._animState.sourceTabGroupId,g=this.group.model.getTabGroups();let v=0;for(let b=0;b<this._tabs.length;b++){const w=this._tabs[b].value;if(w.panel.id===this._animState.sourceTabId||h!=null&&h.has(w.panel.id))continue;if(b>=r)break;const C=f.get(w.panel.id);C&&(v+=(i=this._animState.chipPositions.get(C))!==null&&i!==void 0?i:0);const I=this._animState.tabPositions.get(w.panel.id);v+=I?I.width:w.element.getBoundingClientRect().width}for(const b of g){const w=b.panelIds.filter(G=>G!==this._animState.sourceTabId&&!(h!=null&&h.has(G)));if(w.length===0)continue;const C=this._tabs.findIndex(G=>G.value.panel.id===w[0]),I=this._tabs.findIndex(G=>G.value.panel.id===w[w.length-1]);if(C===-1||I===-1)continue;const E=r>=C&&r<=I,D=!E&&r===C-1;if(!(!E&&!D)){if(m){const G=(C+I+1)/2;r<G?r=C:r=I+1;break}if(D){let G=!0;for(let N=r;N<C;N++){const L=this._tabs[N].value.panel.id;if(L!==this._animState.sourceTabId&&!(h!=null&&h.has(L))){G=!1;break}}if(!G)continue;const M=(n=this._animState.chipPositions.get(b.id))!==null&&n!==void 0?n:0,H=b.collapsed?this._animState.containerLeft+v+M/2:this._animState.containerLeft+v+M;a>=H&&(r=C,d=b.id);break}if(E){const G=(s=this._animState.chipPositions.get(b.id))!==null&&s!==void 0?s:0,M=this._animState.containerLeft+v+G;r===C?a>=M&&(d=b.id):d=b.id;break}}}}r===this._animState.currentInsertionIndex&&d===this._animState.targetTabGroupId||(this._animState.currentInsertionIndex=r,this._animState.targetTabGroupId=d,((l=this.accessor.options.theme)===null||l===void 0?void 0:l.tabAnimation)==="smooth"&&this.applyDragOverTransforms())}_removeClassInstantlyBatch(e,t){const i=[];for(const n of e)n.classList.contains(t)&&(n.style.transition="none",A(n,t,!1),i.push(n));if(i.length>0){i[0].offsetHeight;for(const n of i)n.style.removeProperty("transition")}}_uncollapsSourceTab(e){const t=this._tabMap.get(e);t&&this._removeClassInstantlyBatch([t.value.element],"dv-tab--dragging")}applyDragOverTransforms(e=!1){if(!this._animState||this._animState.currentInsertionIndex===null){this.resetTabTransforms();return}if(this._pendingCollapse)return;const t=this._animState.currentInsertionIndex;let i;const n=this._animState.sourceGroupPanelIds;if(this._animState.sourceTabGroupId&&n)i=this._animState.sourceGapWidth;else{const h=this._animState.tabPositions.get(this._animState.sourceTabId);i=h?h.width:this.getAverageTabWidth()}let s=null;if(this._tabGroupManager.chipRenderers.size>0){const h=this.group.model.getTabGroups();for(const c of h){if(c.id===this._animState.sourceTabGroupId||c.panelIds.includes(this._animState.sourceTabId))continue;const u=c.panelIds.filter(m=>m!==this._animState.sourceTabId&&!(n!=null&&n.has(m)));if(u.length===0)continue;const p=this._tabs.findIndex(m=>m.value.panel.id===u[0]);if((!this._animState.targetTabGroupId||this._animState.targetTabGroupId===c.id&&c.collapsed)&&p>=t){let m=!1;for(let g=t;g<p;g++){const v=this._tabs[g].value.panel.id;if(v!==this._animState.sourceTabId&&!(n!=null&&n.has(v))){m=!0;break}}if(!m){const g=this._tabGroupManager.chipRenderers.get(c.id);g&&(s=g.chip.element)}break}}}const l=h=>h.classList.contains("dv-tab-group-chip")?"dv-tab-group-chip--shifting":"dv-tab--shifting",a=(h,c)=>{e?(h.style.transition="none",h.style.marginLeft=c,h.offsetHeight,h.style.removeProperty("transition")):h.style.marginLeft=c,A(h,l(h),!0)},r=h=>{const c=l(h),u=this._pendingMarginCleanups.get(h);if(u&&u(),e||!h.style.marginLeft)h.style.removeProperty("margin-left"),A(h,c,!1);else{h.style.marginLeft="0px",A(h,c,!0);const p=()=>{h.style.removeProperty("margin-left"),A(h,c,!1),h.removeEventListener("transitionend",p),clearTimeout(f),this._pendingMarginCleanups.delete(h)},f=setTimeout(p,300);this._pendingMarginCleanups.set(h,p),h.addEventListener("transitionend",p)}};let d=!1;for(const[h,c]of this._tabGroupManager.chipRenderers)h!==this._animState.sourceTabGroupId&&r(c.chip.element);s&&(a(s,`${i}px`),d=!0);for(let h=0;h<this._tabs.length;h++){const c=this._tabs[h].value;c.panel.id!==this._animState.sourceTabId&&(n!=null&&n.has(c.panel.id)||(!d&&h>=t?(a(c.element,`${i}px`),d=!0):r(c.element)))}this._tabGroupManager.trackUnderlines()}resetTabTransforms(){for(const[,e]of this._pendingMarginCleanups)e();this._pendingMarginCleanups.clear();for(const e of this._tabs)e.value.element.style.removeProperty("margin-left"),e.value.element.style.removeProperty("margin-right"),e.value.element.style.removeProperty("margin-top"),e.value.element.style.removeProperty("margin-bottom"),e.value.element.style.removeProperty("transform"),A(e.value.element,"dv-tab--shifting",!1);for(const[,e]of this._tabGroupManager.chipRenderers)e.chip.element.style.removeProperty("margin-left"),A(e.chip.element,"dv-tab-group-chip--shifting",!1);this._tabGroupManager.positionUnderlines()}_commitGroupMove(e,t){var i,n,s;const l=re();if((i=this._chipDragCleanup)===null||i===void 0||i.dispose(),this._chipDragCleanup=null,this.group.model.getTabGroups().some(r=>r.id===e))if(((n=this.accessor.options.theme)===null||n===void 0?void 0:n.tabAnimation)==="smooth"){this._clearGroupDragClasses(e);const r=this.snapshotTabPositions();this.resetTabTransforms(),this.group.model.moveTabGroup(e,t),this.runFlipAnimation(r,"",!1)}else this._tabGroupManager.skipNextCollapseAnimation=!0,this.group.model.moveTabGroup(e,t);else l&&(this.resetTabTransforms(),this.accessor.moveGroupOrPanel({from:{groupId:l.groupId,tabGroupId:(s=l.tabGroupId)!==null&&s!==void 0?s:e},to:{group:this.group,position:"center",index:t}}))}_clearGroupDragClasses(e){const t=this._tabGroupManager.chipRenderers.get(e);t&&this._removeClassInstantlyBatch([t.chip.element],"dv-tab-group-chip--dragging"),this._removeClassInstantlyBatch(this._tabs.map(n=>n.value.element),"dv-tab--dragging");const i=this._tabGroupManager.groupUnderlines.get(e);i&&i.style.removeProperty("display"),this._tabGroupManager.skipNextCollapseAnimation=!0}resetDragAnimation(){var e,t;this._pendingCollapse=!1,this.resetTabTransforms(),!((e=this._animState)===null||e===void 0)&&e.sourceTabGroupId?this._clearGroupDragClasses(this._animState.sourceTabGroupId):this._removeClassInstantlyBatch(this._tabs.map(i=>i.value.element),"dv-tab--dragging"),this._animState=null,(t=this._chipDragCleanup)===null||t===void 0||t.dispose(),this._chipDragCleanup=null;for(const[,i]of this._tabGroupManager.groupUnderlines)i.style.removeProperty("display")}runFlipAnimation(e,t,i=!1,n){const s=this._direction==="vertical";let l=!1;for(let a=0;a<this._tabs.length;a++){const r=this._tabs[a],d=r.value.panel.id;if(d===t){if(i){const p=r.value.element.getBoundingClientRect();r.value.element.style.transform=s?`translateY(${p.height}px)`:`translateX(${p.width}px)`,A(r.value.element,"dv-tab--shifting",!0),l=!0}continue}if(n!==void 0&&(a<n.from||a>n.to))continue;const h=e.get(d);if(!h)continue;const c=r.value.element.getBoundingClientRect(),u=s?h.top-c.top:h.left-c.left;Math.abs(u)<1||(r.value.element.style.transform=s?`translateY(${u}px)`:`translateX(${u}px)`,A(r.value.element,"dv-tab--shifting",!0),l=!0)}l&&requestAnimationFrame(()=>{var a;for(const h of this._tabs)h.value.element.style.transform&&(h.value.element.style.transform="");this._tabGroupManager.trackUnderlines(),(a=this._flipTransitionCleanup)===null||a===void 0||a.call(this);const r=h=>{if(h.propertyName==="transform"){d();for(const c of this._tabs)A(c.value.element,"dv-tab--shifting",!1);this._tabGroupManager.positionUnderlines()}},d=()=>{this._tabsList.removeEventListener("transitionend",r),this._flipTransitionCleanup=null};this._flipTransitionCleanup=d,this._tabsList.addEventListener("transitionend",r)})}}const Xt=o=>{const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttributeNS(null,"height",o.height),e.setAttributeNS(null,"width",o.width),e.setAttributeNS(null,"viewBox",o.viewbox),e.setAttributeNS(null,"aria-hidden","false"),e.setAttributeNS(null,"focusable","false"),e.classList.add("dv-svg");const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttributeNS(null,"d",o.path),e.appendChild(t),e},vs=()=>Xt({width:"11",height:"11",viewbox:"0 0 28 28",path:"M2.1 27.3L0 25.2L11.55 13.65L0 2.1L2.1 0L13.65 11.55L25.2 0L27.3 2.1L15.75 13.65L27.3 25.2L25.2 27.3L13.65 15.75L2.1 27.3Z"}),_s=()=>Xt({width:"11",height:"11",viewbox:"0 0 24 15",path:"M12 14.15L0 2.15L2.15 0L12 9.9L21.85 0.0499992L24 2.2L12 14.15Z"}),qi=()=>Xt({width:"11",height:"11",viewbox:"0 0 15 25",path:"M2.15 24.1L0 21.95L9.9 12.05L0 2.15L2.15 0L14.2 12.05L2.15 24.1Z"});function bs(){const o=document.createElement("div");o.className="dv-tabs-overflow-dropdown-default";const e=document.createElement("span");e.textContent="";const t=qi();return o.appendChild(t),o.appendChild(e),{element:o,update:i=>{e.textContent=`${i.tabs}`}}}class ws extends R{get onTabDragStart(){return this.tabs.onTabDragStart}get panels(){return this.tabs.panels}get size(){return this.tabs.size}get hidden(){return this._hidden}set hidden(e){this._hidden=e,this.element.style.display=e?"none":""}get direction(){return this._direction}set direction(e){this._direction=e,e==="vertical"?(xe(this._element,"dv-groupview-header-vertical"),xe(this.rightActionsContainer,"dv-right-actions-container-vertical"),this.tabs.direction=e):(ye(this._element,"dv-groupview-header-vertical"),ye(this.rightActionsContainer,"dv-right-actions-container-vertical"),this.tabs.direction=e)}get element(){return this._element}constructor(e,t){super(),this.accessor=e,this.group=t,this._hidden=!1,this._direction="horizontal",this.dropdownPart=null,this._overflowTabs=[],this._overflowTabGroups=[],this._dropdownDisposable=new le,this._onDrop=new _,this.onDrop=this._onDrop.event,this._onGroupDragStart=new _,this.onGroupDragStart=this._onGroupDragStart.event,this._onWillShowOverlay=new _,this.onWillShowOverlay=this._onWillShowOverlay.event,this._element=document.createElement("div"),this._element.className="dv-tabs-and-actions-container",A(this._element,"dv-full-width-single-tab",this.accessor.options.singleTabMode==="fullwidth"),this.rightActionsContainer=document.createElement("div"),this.rightActionsContainer.className="dv-right-actions-container",this.leftActionsContainer=document.createElement("div"),this.leftActionsContainer.className="dv-left-actions-container",this.preActionsContainer=document.createElement("div"),this.preActionsContainer.className="dv-pre-actions-container",this.tabs=new gs(t,e,{showTabsOverflowControl:!e.options.disableTabsOverflowList}),this.voidContainer=new cs(this.accessor,this.group),this.tabs.voidContainer=this.voidContainer.element,this._element.appendChild(this.preActionsContainer),this._element.appendChild(this.tabs.element),this._element.appendChild(this.leftActionsContainer),this._element.appendChild(this.voidContainer.element),this._element.appendChild(this.rightActionsContainer),this.tabs.setExtendedDropZone(this._element),this.addDisposables(this.tabs.onDrop(i=>this._onDrop.fire(i)),this.tabs.onWillShowOverlay(i=>this._onWillShowOverlay.fire(i)),e.onDidOptionsChange(()=>{this.tabs.showTabsOverflowControl=!e.options.disableTabsOverflowList}),this.tabs.onOverflowTabsChange(i=>{this.toggleDropdown(i)}),this.tabs,this._onWillShowOverlay,this._onDrop,this._onGroupDragStart,this.voidContainer,this.voidContainer.onDragStart(i=>{this._onGroupDragStart.fire({nativeEvent:i,group:this.group})}),this.voidContainer.onDrop(i=>{this.tabs.handleVoidDrop()||this._onDrop.fire({event:i.nativeEvent,index:this.tabs.size})}),this.voidContainer.onWillShowOverlay(i=>{this._onWillShowOverlay.fire(new wt(i,{kind:"header_space",panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:re}))}),k(this.leftActionsContainer,"dragleave",i=>{const n=i.relatedTarget;!this.leftActionsContainer.contains(n)&&!this._element.contains(n)&&this.tabs.clearExternalAnimState()}),k(this.voidContainer.element,"dragleave",i=>{const n=i.relatedTarget;this.voidContainer.element.contains(n)||(this._element.contains(n)?this.tabs.setExternalInsertionIndex(null):this.tabs.clearExternalAnimState())}),k(this.voidContainer.element,"pointerdown",i=>{if(i.defaultPrevented)return;if(!this.accessor.options.disableFloatingGroups&&i.shiftKey&&this.group.api.location.type!=="floating"&&this.group.api.location.type!=="edge"){i.preventDefault();const{top:s,left:l}=this.element.getBoundingClientRect(),{top:a,left:r}=this.accessor.element.getBoundingClientRect();this.accessor.addFloatingGroup(this.group,{x:l-r+20,y:s-a+20,inDragMode:!0})}}))}show(){this.hidden||(this.element.style.display="")}hide(){this._element.style.display="none"}setRightActionsElement(e){this.rightActions!==e&&(this.rightActions&&(this.rightActions.remove(),this.rightActions=void 0),e&&(this.rightActionsContainer.appendChild(e),this.rightActions=e))}setLeftActionsElement(e){this.leftActions!==e&&(this.leftActions&&(this.leftActions.remove(),this.leftActions=void 0),e&&(this.leftActionsContainer.appendChild(e),this.leftActions=e))}setPrefixActionsElement(e){this.preActions!==e&&(this.preActions&&(this.preActions.remove(),this.preActions=void 0),e&&(this.preActionsContainer.appendChild(e),this.preActions=e))}isActive(e){return this.tabs.isActive(e)}indexOf(e){return this.tabs.indexOf(e)}setActive(e){}delete(e){this.tabs.delete(e),this.updateClassnames()}setActivePanel(e){this.tabs.setActivePanel(e)}openPanel(e,t=this.tabs.size){this.tabs.openPanel(e,t),this.updateClassnames()}closePanel(e){this.delete(e.id)}updateClassnames(){A(this._element,"dv-single-tab",this.size===1)}toggleDropdown(e){const t=e.reset?[]:e.tabs,i=e.reset?[]:e.tabGroups;this._overflowTabs=t,this._overflowTabGroups=i;const n=this._overflowTabs.length;if(n>0&&this.dropdownPart){this.dropdownPart.update({tabs:n});return}if(n===0){this._dropdownDisposable.dispose();return}const s=document.createElement("div");s.className="dv-tabs-overflow-dropdown-root";const l=bs();l.update({tabs:n}),this.dropdownPart=l,s.appendChild(l.element),this.rightActionsContainer.prepend(s),this._dropdownDisposable.value=new R(ne.from(()=>{var a,r;s.remove(),(r=(a=this.dropdownPart)===null||a===void 0?void 0:a.dispose)===null||r===void 0||r.call(a),this.dropdownPart=null}),k(s,"pointerdown",a=>{a.preventDefault()},{capture:!0}),k(s,"click",a=>{const r=document.createElement("div");r.style.overflow="auto",r.className="dv-tabs-overflow-container";const d=new Set(this._overflowTabGroups),h=this.group.model.getTabGroups(),c=new Map;for(const f of h)if(d.has(f.id))for(const m of f.panelIds)c.set(m,f);const u=new Set;for(const f of this.tabs.tabs.filter(m=>this._overflowTabs.includes(m.panel.id))){const m=c.get(f.panel.id);if(m&&!u.has(m.id)){u.add(m.id);const C=document.createElement("div");C.className="dv-tabs-overflow-group-header";const I=document.createElement("span");I.className="dv-tabs-overflow-group-color",Zt(I,m.color,this.accessor.tabGroupColorPalette),C.appendChild(I);const E=document.createElement("span");if(E.className="dv-tabs-overflow-group-label",E.textContent=m.label||m.id,C.appendChild(E),m.collapsed){const D=document.createElement("span");D.className="dv-tabs-overflow-group-collapsed-badge",D.textContent=`${m.panelIds.length}`,C.appendChild(D)}C.addEventListener("click",()=>{this.accessor.getPopupServiceForGroup(this.group).close(),m.collapsed&&m.expand();const D=m.panelIds[0];if(D){const G=this.group.panels.find(M=>M.id===D);G==null||G.api.setActive()}}),r.appendChild(C)}const g=this.group.panels.find(C=>C===f.panel),b=g.view.createTabRenderer("headerOverflow").element,w=document.createElement("div");A(w,"dv-tab",!0),A(w,"dv-active-tab",g.api.isActive),A(w,"dv-inactive-tab",!g.api.isActive),m&&A(w,"dv-tab--grouped",!0),w.addEventListener("click",C=>{this.accessor.getPopupServiceForGroup(this.group).close(),!C.defaultPrevented&&(m!=null&&m.collapsed&&m.expand(),f.element.scrollIntoView(),f.panel.api.setActive())}),w.appendChild(b),r.appendChild(w)}const p=Mi(s);this.accessor.getPopupServiceForGroup(this.group).openPopover(r,{x:a.clientX,y:a.clientY,zIndex:p!=null&&p.style.zIndex?`calc(${p.style.zIndex} * 2)`:void 0})}))}updateDragAndDropState(){this.tabs.updateDragAndDropState(),this.voidContainer.updateDragAndDropState()}updateTabGroups(){this.tabs.updateTabGroups()}refreshTabGroupAccent(){this.tabs.refreshTabGroupAccent()}}class Qi extends ki{constructor(e,t,i,n,s){super(),this.nativeEvent=e,this.target=t,this.position=i,this.getData=n,this.group=s}}const Nt=Object.keys({disableAutoResizing:void 0,hideBorders:void 0,singleTabMode:void 0,disableFloatingGroups:void 0,floatingGroupBounds:void 0,popoutUrl:void 0,defaultRenderer:void 0,defaultHeaderPosition:void 0,debug:void 0,rootOverlayModel:void 0,locked:void 0,disableDnd:void 0,className:void 0,noPanelsOverlay:void 0,dndEdges:void 0,theme:void 0,disableTabsOverflowList:void 0,scrollbars:void 0,getTabContextMenuItems:void 0,getTabGroupChipContextMenuItems:void 0,createTabGroupChipComponent:void 0,tabGroupColors:void 0,tabGroupAccent:void 0});function Cs(o){return!!o.referencePanel}function Ds(o){return!!o.referenceGroup}function ys(o){return!!o.referencePanel}function xs(o){return!!o.referenceGroup}class Ss extends R{get label(){return this._label}get color(){return this._color}get componentParams(){return this._componentParams}setLabel(e){this.isDisposed||this._label===e||(this._label=e,this._onDidChange.fire())}setColor(e){if(this.isDisposed)return;const t=e===""?void 0:e;this._color!==t&&(this._color=t,this._onDidChange.fire())}setComponentParams(e){this.isDisposed||(this._componentParams=e,this._onDidChange.fire())}get collapsed(){return this._collapsed}get panelIds(){return this._panelIds}get size(){return this._panelIds.length}get isEmpty(){return this._panelIds.length===0}constructor(e,t){var i,n;super(),this.id=e,this._collapsed=!1,this._panelIds=[],this._onDidChange=new _,this.onDidChange=this._onDidChange.event,this._onDidPanelChange=new _,this.onDidPanelChange=this._onDidPanelChange.event,this._onDidCollapseChange=new _,this.onDidCollapseChange=this._onDidCollapseChange.event,this._onDidDestroy=new _,this.onDidDestroy=this._onDidDestroy.event,this._label=(i=t==null?void 0:t.label)!==null&&i!==void 0?i:"",this._color=(t==null?void 0:t.color)===""||t==null?void 0:t.color,this._collapsed=(n=t==null?void 0:t.collapsed)!==null&&n!==void 0?n:!1,this._componentParams=t==null?void 0:t.componentParams,this.addDisposables(this._onDidChange,this._onDidPanelChange,this._onDidCollapseChange,this._onDidDestroy)}addPanel(e,t){if(this.isDisposed||this._panelIds.includes(e))return;const i=t!==void 0?Math.max(0,Math.min(t,this._panelIds.length)):this._panelIds.length;this._panelIds.splice(i,0,e),this._onDidPanelChange.fire({panelId:e,type:"add"})}removePanel(e){if(this.isDisposed)return!1;const t=this._panelIds.indexOf(e);return t===-1?!1:(this._panelIds.splice(t,1),this._onDidPanelChange.fire({panelId:e,type:"remove"}),!0)}indexOfPanel(e){return this._panelIds.indexOf(e)}containsPanel(e){return this._panelIds.includes(e)}collapse(){this.isDisposed||this._collapsed||(this._collapsed=!0,this._onDidCollapseChange.fire(!0))}expand(){this.isDisposed||!this._collapsed||(this._collapsed=!1,this._onDidCollapseChange.fire(!1))}toggle(){this._collapsed?this.expand():this.collapse()}toJSON(){const e={id:this.id,collapsed:this._collapsed,panelIds:[...this._panelIds]};return this._label&&(e.label=this._label),this._color!==void 0&&(e.color=this._color),this._componentParams!==void 0&&(e.componentParams=this._componentParams),e}dispose(){this._onDidDestroy.fire(),super.dispose()}}class qt extends $t{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}get panel(){return this.options.panel}get group(){return this.options.group}get api(){return this.options.api}constructor(e){super(),this.options=e}getData(){return this.options.getData()}}class en extends qt{get kind(){return this._kind}constructor(e){super(e),this._kind=e.kind}}class Ps extends R{get tabGroups(){return this._tabGroups}get element(){throw new Error("dockview: not supported")}get activePanel(){return this._activePanel}get locked(){return this._locked}set locked(e){this._locked=e,A(this.container,"dv-locked-groupview",e==="no-drop-target"||e)}get isActive(){return this._isGroupActive}get panels(){return this._panels}get size(){return this._panels.length}get isEmpty(){return this._panels.length===0}get hasWatermark(){return!!(this.watermark&&this.container.contains(this.watermark.element))}get header(){return this.tabsContainer}get isContentFocused(){return document.activeElement?Et(document.activeElement,this.contentContainer.element):!1}get headerPosition(){var e;return(e=this._headerPosition)!==null&&e!==void 0?e:"top"}set headerPosition(e){var t;this._headerPosition=e,ye(this.container,"dv-groupview-header-top","dv-groupview-header-bottom","dv-groupview-header-left","dv-groupview-header-right"),xe(this.container,`dv-groupview-header-${e}`);const i=e==="top"||e==="bottom"?"horizontal":"vertical";this.tabsContainer.direction=i,this.header.direction=i,!((t=this._activePanel)===null||t===void 0)&&t.layout&&this._activePanel.layout(this._width,this._height),(this._leftHeaderActions||this._rightHeaderActions||this._prefixHeaderActions)&&this.updateHeaderActions()}get location(){return this._location}set location(e){switch(this._location=e,A(this.container,"dv-groupview-floating",!1),A(this.container,"dv-groupview-popout",!1),A(this.container,"dv-groupview-edge",!1),e.type){case"grid":this.contentContainer.dropTarget.setTargetZones(["top","bottom","left","right","center"]);break;case"floating":this.contentContainer.dropTarget.setTargetZones(["center"]),this.contentContainer.dropTarget.setTargetZones(e?["center"]:["top","bottom","left","right","center"]),A(this.container,"dv-groupview-floating",!0);break;case"popout":this.contentContainer.dropTarget.setTargetZones(["center"]),A(this.container,"dv-groupview-popout",!0);break;case"edge":this.contentContainer.dropTarget.setTargetZones(["center"]),A(this.container,"dv-groupview-edge",!0);break}this.groupPanel.api._onDidLocationChange.fire({location:this.location})}constructor(e,t,i,n,s){var l,a;super(),this.container=e,this.accessor=t,this.id=i,this.options=n,this.groupPanel=s,this._isGroupActive=!1,this._locked=!1,this._rightHeaderActionsDisposable=new le,this._leftHeaderActionsDisposable=new le,this._prefixHeaderActionsDisposable=new le,this._location={type:"grid"},this.mostRecentlyUsed=[],this._overwriteRenderContainer=null,this._overwriteDropTargetContainer=null,this._onDidChange=new _,this.onDidChange=this._onDidChange.event,this._width=0,this._height=0,this._panels=[],this._panelDisposables=new Map,this._tabGroupDisposables=new Map,this._pendingMicrotaskDisposables=new Set,this._onMove=new _,this.onMove=this._onMove.event,this._onDidDrop=new _,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new _,this.onWillDrop=this._onWillDrop.event,this._onWillShowOverlay=new _,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onTabDragStart=new _,this.onTabDragStart=this._onTabDragStart.event,this._onGroupDragStart=new _,this.onGroupDragStart=this._onGroupDragStart.event,this._onDidAddPanel=new _,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPanelTitleChange=new _,this.onDidPanelTitleChange=this._onDidPanelTitleChange.event,this._onDidPanelParametersChange=new _,this.onDidPanelParametersChange=this._onDidPanelParametersChange.event,this._onDidRemovePanel=new _,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidActivePanelChange=new _,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onUnhandledDragOverEvent=new _,this.onUnhandledDragOverEvent=this._onUnhandledDragOverEvent.event,this._tabGroups=[],this._tabGroupMap=new Map,this._panelToTabGroup=new Map,this._tabGroupIdCounter=0,this._pendingTabGroupUpdate=!1,this._onDidCreateTabGroup=new _,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new _,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new _,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new _,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new _,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new _,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,A(this.container,"dv-groupview",!0),this._api=new _t(this.accessor),this.tabsContainer=new ws(this.accessor,this.groupPanel),this.contentContainer=new as(this.accessor,this),e.append(this.tabsContainer.element,this.contentContainer.element),this.header.hidden=!!n.hideHeader,this.locked=(l=n.locked)!==null&&l!==void 0?l:!1,this.headerPosition=(a=n.headerPosition)!==null&&a!==void 0?a:t.defaultHeaderPosition,this.addDisposables(this._onTabDragStart,this._onGroupDragStart,this._onWillShowOverlay,this._rightHeaderActionsDisposable,this._leftHeaderActionsDisposable,this._prefixHeaderActionsDisposable,this.tabsContainer.onTabDragStart(r=>{this._onTabDragStart.fire(r)}),this.tabsContainer.onGroupDragStart(r=>{this._onGroupDragStart.fire(r)}),this.tabsContainer.onDrop(r=>{var d;const h=re(),c=(d=h==null?void 0:h.panelId)!==null&&d!==void 0?d:null;if(this.handleDropEvent("header",r.event,"center",r.index),c&&r.targetTabGroupId){const u=this._tabGroupMap.get(r.targetTabGroupId);let p;if(u){const f=this._panels.findIndex(m=>m.id===c);if(f!==-1){p=0;for(const m of u.panelIds)this._panels.findIndex(v=>v.id===m)<f&&p++}}this.addPanelToTabGroup(r.targetTabGroupId,c,p)}else c&&r.targetTabGroupId===null&&this.removePanelFromTabGroup(c)}),this.contentContainer.onDidFocus(()=>{this.accessor.doSetGroupActive(this.groupPanel)}),this.contentContainer.onDidBlur(()=>{}),this.contentContainer.dropTarget.onDrop(r=>{this.handleDropEvent("content",r.nativeEvent,r.position)}),this.tabsContainer.onWillShowOverlay(r=>{this._onWillShowOverlay.fire(r)}),this.contentContainer.dropTarget.onWillShowOverlay(r=>{this._onWillShowOverlay.fire(new wt(r,{kind:"content",panel:this.activePanel,api:this._api,group:this.groupPanel,getData:re}))}),this._onMove,this._onDidChange,this._onDidDrop,this._onWillDrop,this._onDidAddPanel,this._onDidRemovePanel,this._onDidActivePanelChange,this._onUnhandledDragOverEvent,this._onDidPanelTitleChange,this._onDidPanelParametersChange,this._onDidCreateTabGroup,this._onDidDestroyTabGroup,this._onDidAddPanelToTabGroup,this._onDidRemovePanelFromTabGroup,this._onDidTabGroupChange,this._onDidTabGroupCollapsedChange,this._onDidCreateTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidDestroyTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidAddPanelToTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidRemovePanelFromTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidTabGroupChange.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidTabGroupCollapsedChange.event(()=>{this._scheduleTabGroupUpdate()}))}_scheduleTabGroupUpdate(){this._pendingTabGroupUpdate||(this._pendingTabGroupUpdate=!0,queueMicrotask(()=>{this._pendingTabGroupUpdate=!1,this.isDisposed||this.tabsContainer.updateTabGroups()}))}createTabGroup(e){var t;const i=(t=e==null?void 0:e.id)!==null&&t!==void 0?t:`tg-${this.id}-${this._tabGroupIdCounter++}`,n=new Ss(i,{label:e==null?void 0:e.label,color:e==null?void 0:e.color,collapsed:e==null?void 0:e.collapsed,componentParams:e==null?void 0:e.componentParams});return this._tabGroups.push(n),this._tabGroupMap.set(i,n),this._tabGroupDisposables.set(i,new R(n.onDidChange(()=>{this._onDidTabGroupChange.fire({tabGroup:n})}),n.onDidCollapseChange(s=>{s?this._handleGroupCollapse(n):this._handleGroupExpand(n),this._onDidTabGroupCollapsedChange.fire({tabGroup:n})}),n.onDidDestroy(()=>{this._removeTabGroupInternal(n)}))),this._onDidCreateTabGroup.fire({tabGroup:n}),n}dissolveTabGroup(e){const t=this._tabGroupMap.get(e);if(!t)return;const i=[...t.panelIds];for(const n of i)t.removePanel(n),this._panelToTabGroup.delete(n),this._onDidRemovePanelFromTabGroup.fire({tabGroup:t,panelId:n});t.dispose()}addPanelToTabGroup(e,t,i){const n=this._tabGroupMap.get(e);if(!n||!this._panels.some(l=>l.id===t))return;const s=this.getTabGroupForPanel(t);if(s){if(s.id===e)return;this.removePanelFromTabGroup(t)}n.addPanel(t,i),this._panelToTabGroup.set(t,n),this._enforceContiguity(n,t),this._onDidAddPanelToTabGroup.fire({tabGroup:n,panelId:t})}movePanelWithinGroup(e,t,i){const n=this._tabGroupMap.get(e);!n||!n.containsPanel(t)||(n.removePanel(t),n.addPanel(t,i),this._enforceContiguity(n,t),this.tabsContainer.updateTabGroups())}movePanelBetweenGroups(e,t,i){const n=this._findTabGroupForPanel(e),s=this._tabGroupMap.get(t);s&&(n&&(n.removePanel(e),this._panelToTabGroup.delete(e),this._onDidRemovePanelFromTabGroup.fire({tabGroup:n,panelId:e}),n.isEmpty&&n.dispose()),s.addPanel(e,i),this._panelToTabGroup.set(e,s),this._enforceContiguity(s,e),this._onDidAddPanelToTabGroup.fire({tabGroup:s,panelId:e}))}moveTabGroup(e,t){const i=this._tabGroupMap.get(e);if(!i||i.panelIds.length===0)return;const n=new Set(i.panelIds),s=i.panelIds.map(d=>this._panels.find(h=>h.id===d)).filter(d=>d!==void 0);if(s.length===0)return;let l=0;for(let d=0;d<Math.min(t,this._panels.length);d++)n.has(this._panels[d].id)&&l++;for(const d of s){const h=this._panels.indexOf(d);h!==-1&&this._panels.splice(h,1)}const a=t-l,r=Math.max(0,Math.min(a,this._panels.length));this._panels.splice(r,0,...s);for(const d of this._panels)this.tabsContainer.delete(d.id);for(let d=0;d<this._panels.length;d++)this.tabsContainer.openPanel(this._panels[d],d);this.tabsContainer.updateTabGroups()}_enforceContiguity(e,t){const i=this._panels.find(r=>r.id===t);if(!i)return;const n=e.indexOfPanel(t),s=this._computeGlobalIndex(e,n),l=this._panels.indexOf(i);if(l===s)return;this._panels.splice(l,1);const a=s>l?s-1:s;this._panels.splice(a,0,i),this.tabsContainer.delete(t),this.tabsContainer.openPanel(i,a)}_computeGlobalIndex(e,t){const i=e.panelIds;if(i.length<=1){const n=this._panels.find(s=>s.id===i[0]);return n?this._panels.indexOf(n):this._panels.length}for(let n=0;n<i.length;n++){if(n===t)continue;const s=this._panels.find(l=>l.id===i[n]);if(s){const l=this._panels.indexOf(s);return Math.max(0,l+(t-n))}}return this._panels.length}removePanelFromTabGroup(e){const t=this._findTabGroupForPanel(e);t&&(t.removePanel(e),this._panelToTabGroup.delete(e),this._onDidRemovePanelFromTabGroup.fire({tabGroup:t,panelId:e}),t.isEmpty&&t.dispose())}getTabGroups(){return this._tabGroups}updateTabGroups(){this.tabsContainer.updateTabGroups()}refreshTabGroupAccent(){this.tabsContainer.refreshTabGroupAccent()}getTabGroupForPanel(e){return this._findTabGroupForPanel(e)}_findTabGroupForPanel(e){return this._panelToTabGroup.get(e)}_removeTabGroupInternal(e){const t=this._tabGroups.indexOf(e);if(t!==-1){this._tabGroups.splice(t,1),this._tabGroupMap.delete(e.id);for(const n of e.panelIds)this._panelToTabGroup.delete(n);this._onDidDestroyTabGroup.fire({tabGroup:e});const i=this._tabGroupDisposables.get(e.id);this._tabGroupDisposables.delete(e.id),i&&(this._pendingMicrotaskDisposables.add(i),queueMicrotask(()=>{this._pendingMicrotaskDisposables.delete(i),i.dispose()}))}}_handleGroupCollapse(e){if(!this._activePanel||!e.containsPanel(this._activePanel.id))return;const t=this._panels.indexOf(this._activePanel);for(let i=t+1;i<this._panels.length;i++){const n=this._panels[i],s=this._findTabGroupForPanel(n.id);if(!s||!s.collapsed){this.doSetActivePanel(n),this.updateContainer();return}}for(let i=t-1;i>=0;i--){const n=this._panels[i],s=this._findTabGroupForPanel(n.id);if(!s||!s.collapsed){this.doSetActivePanel(n),this.updateContainer();return}}this.contentContainer.closePanel(),this.doSetActivePanel(void 0),this.updateContainer()}_handleGroupExpand(e){if(this._activePanel)return;const t=e.panelIds[0];if(t){const i=this._panels.find(n=>n.id===t);i&&(this.doSetActivePanel(i),this.updateContainer())}}restoreTabGroups(e){for(const t of e){const i=t.id.match(/-(\d+)$/);if(i){const n=parseInt(i[1],10)+1;n>this._tabGroupIdCounter&&(this._tabGroupIdCounter=n)}}for(const t of e){const i=this.createTabGroup({id:t.id,label:t.label,color:t.color,componentParams:t.componentParams}),n=this._tabGroupMap.get(i.id);for(const s of t.panelIds)this._panels.some(l=>l.id===s)&&(i.addPanel(s),this._panelToTabGroup.set(s,n),this._enforceContiguity(n,s));t.collapsed&&i.collapse(),i.isEmpty&&i.dispose()}}focusContent(){this.contentContainer.element.focus()}set renderContainer(e){this.panels.forEach(t=>{this.renderContainer.detatch(t)}),this._overwriteRenderContainer=e,this.panels.forEach(t=>{this.rerender(t)})}get renderContainer(){var e;return(e=this._overwriteRenderContainer)!==null&&e!==void 0?e:this.accessor.overlayRenderContainer}set dropTargetContainer(e){this._overwriteDropTargetContainer=e}get dropTargetContainer(){var e;return(e=this._overwriteDropTargetContainer)!==null&&e!==void 0?e:this.accessor.rootDropTargetContainer}initialize(){this.options.panels&&this.options.panels.forEach(e=>{this.doAddPanel(e)}),this.options.activePanel&&this.openPanel(this.options.activePanel),this.setActive(this.isActive,!0),this.updateContainer(),this.updateHeaderActions()}updateHeaderActions(){this.accessor.options.createRightHeaderActionComponent?(this._rightHeaderActions=this.accessor.options.createRightHeaderActionComponent(this.groupPanel),this._rightHeaderActionsDisposable.value=this._rightHeaderActions,this._rightHeaderActions.init({containerApi:this._api,api:this.groupPanel.api,group:this.groupPanel}),this.tabsContainer.setRightActionsElement(this._rightHeaderActions.element)):(this._rightHeaderActions=void 0,this._rightHeaderActionsDisposable.dispose(),this.tabsContainer.setRightActionsElement(void 0)),this.accessor.options.createLeftHeaderActionComponent?(this._leftHeaderActions=this.accessor.options.createLeftHeaderActionComponent(this.groupPanel),this._leftHeaderActionsDisposable.value=this._leftHeaderActions,this._leftHeaderActions.init({containerApi:this._api,api:this.groupPanel.api,group:this.groupPanel}),this.tabsContainer.setLeftActionsElement(this._leftHeaderActions.element)):(this._leftHeaderActions=void 0,this._leftHeaderActionsDisposable.dispose(),this.tabsContainer.setLeftActionsElement(void 0)),this.accessor.options.createPrefixHeaderActionComponent?(this._prefixHeaderActions=this.accessor.options.createPrefixHeaderActionComponent(this.groupPanel),this._prefixHeaderActionsDisposable.value=this._prefixHeaderActions,this._prefixHeaderActions.init({containerApi:this._api,api:this.groupPanel.api,group:this.groupPanel}),this.tabsContainer.setPrefixActionsElement(this._prefixHeaderActions.element)):(this._prefixHeaderActions=void 0,this._prefixHeaderActionsDisposable.dispose(),this.tabsContainer.setPrefixActionsElement(void 0))}rerender(e){this.contentContainer.renderPanel(e,{asActive:!1})}indexOf(e){return this.tabsContainer.indexOf(e.id)}toJSON(){var e;const t={views:this.tabsContainer.panels,activeView:(e=this._activePanel)===null||e===void 0?void 0:e.id,id:this.id};return this.locked!==!1&&(t.locked=this.locked),this.header.hidden&&(t.hideHeader=!0),this.headerPosition!=="top"&&(t.headerPosition=this.headerPosition),this._tabGroups.length>0&&(t.tabGroups=this._tabGroups.map(i=>i.toJSON())),t}moveToNext(e){e||(e={}),e.panel||(e.panel=this.activePanel);const t=e.panel?this.panels.indexOf(e.panel):-1;let i;if(t<this.panels.length-1)i=t+1;else if(!e.suppressRoll)i=0;else return;this.openPanel(this.panels[i])}moveToPrevious(e){if(e||(e={}),e.panel||(e.panel=this.activePanel),!e.panel)return;const t=this.panels.indexOf(e.panel);let i;if(t>0)i=t-1;else if(!e.suppressRoll)i=this.panels.length-1;else return;this.openPanel(this.panels[i])}containsPanel(e){return this.panels.includes(e)}init(e){}update(e){}focus(){var e;(e=this._activePanel)===null||e===void 0||e.focus()}openPanel(e,t={}){(typeof t.index!="number"||t.index>this.panels.length)&&(t.index=this.panels.length);const i=!!t.skipSetActive;if(e.updateParentGroup(this.groupPanel,{skipSetActive:t.skipSetActive}),this.doAddPanel(e,t.index,{skipSetActive:i}),this._activePanel===e){this.contentContainer.renderPanel(e,{asActive:!0});return}i||this.doSetActivePanel(e),t.skipSetGroupActive||this.accessor.doSetGroupActive(this.groupPanel),t.skipSetActive||this.updateContainer()}removePanel(e,t={skipSetActive:!1}){const i=typeof e=="string"?e:e.id,n=this._panels.find(s=>s.id===i);if(!n)throw new Error("invalid operation");return this._removePanel(n,t)}closeAllPanels(){if(this.panels.length>0){const e=[...this.panels];for(const t of e)this.doClose(t)}else this.accessor.removeGroup(this.groupPanel)}closePanel(e){this.doClose(e)}doClose(e){const t=this.panels.length===1&&this.accessor.groups.length===1;this.accessor.removePanel(e,t&&this.accessor.options.noPanelsOverlay==="emptyGroup"?{removeEmptyGroup:!1}:void 0)}isPanelActive(e){return this._activePanel===e}updateActions(e){this.tabsContainer.setRightActionsElement(e)}setActive(e,t=!1){if(!(!t&&this.isActive===e)){if(this._isGroupActive=e,A(this.container,"dv-active-group",e),A(this.container,"dv-inactive-group",!e),this.tabsContainer.setActive(this.isActive),!this._activePanel&&this.panels.length>0){const i=this._panels.find(n=>{const s=this._findTabGroupForPanel(n.id);return!s||!s.collapsed});i&&this.doSetActivePanel(i)}this.updateContainer()}}layout(e,t){var i;this._width=e,this._height=t,this.contentContainer.layout(this._width,this._height),!((i=this._activePanel)===null||i===void 0)&&i.layout&&this._activePanel.layout(this._width,this._height)}_removePanel(e,t){const i=this._activePanel===e;if(this.doRemovePanel(e),i&&this.panels.length>0){const n=this.mostRecentlyUsed[0];this.openPanel(n,{skipSetActive:t.skipSetActive,skipSetGroupActive:t.skipSetActiveGroup})}return this._activePanel&&this.panels.length===0&&this.doSetActivePanel(void 0),t.skipSetActive||this.updateContainer(),e}doRemovePanel(e){const t=this.panels.indexOf(e);if(this._activePanel===e&&this.contentContainer.closePanel(),this.tabsContainer.delete(e.id),this._panels.splice(t,1),this.mostRecentlyUsed.includes(e)){const n=this.mostRecentlyUsed.indexOf(e);this.mostRecentlyUsed.splice(n,1)}const i=this._panelDisposables.get(e.id);i&&(i.dispose(),this._panelDisposables.delete(e.id)),this.removePanelFromTabGroup(e.id),this._onDidRemovePanel.fire({panel:e})}doAddPanel(e,t=this.panels.length,i={skipSetActive:!1}){const s=this._panels.indexOf(e)>-1;this.tabsContainer.show(),this.contentContainer.show(),this.tabsContainer.openPanel(e,t),i.skipSetActive?e.api.renderer==="always"&&this.contentContainer.renderPanel(e,{asActive:!1}):this.contentContainer.openPanel(e),!s&&(this.updateMru(e),this.panels.splice(t,0,e),this._panelDisposables.set(e.id,new R(e.api.onDidTitleChange(l=>this._onDidPanelTitleChange.fire(l)),e.api.onDidParametersChange(l=>this._onDidPanelParametersChange.fire(l)))),this._onDidAddPanel.fire({panel:e}))}doSetActivePanel(e){this._activePanel!==e&&(this._activePanel=e,e&&(this.tabsContainer.setActivePanel(e),this.contentContainer.openPanel(e),e.layout(this._width,this._height),this.updateMru(e),this.contentContainer.refreshFocusState(),this._onDidActivePanelChange.fire({panel:e})))}updateMru(e){this.mostRecentlyUsed.includes(e)&&this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(e),1),this.mostRecentlyUsed=[e,...this.mostRecentlyUsed]}updateContainer(){var e,t;this.panels.forEach(n=>n.runEvents());const i=this.isEmpty||!this._activePanel;if(i&&!this.watermark){const n=this.accessor.createWatermarkComponent();n.init({containerApi:this._api,group:this.groupPanel}),this.watermark=n,k(this.watermark.element,"pointerdown",()=>{this.isActive||this.accessor.doSetGroupActive(this.groupPanel)}),this.contentContainer.element.appendChild(this.watermark.element)}!i&&this.watermark&&(this.watermark.element.remove(),(t=(e=this.watermark).dispose)===null||t===void 0||t.call(e),this.watermark=void 0)}canDisplayOverlay(e,t,i){const n=new Qi(e,i,t,re,this.accessor.getPanel(this.id));return this._onUnhandledDragOverEvent.fire(n),n.isAccepted}handleDropEvent(e,t,i,n){if(this.locked==="no-drop-target")return;function s(){switch(e){case"header":return typeof n=="number"?"tab":"header_space";case"content":return"content"}}const l=typeof n=="number"?this.panels[n]:void 0,a=new en({nativeEvent:t,position:i,panel:l,getData:()=>re(),kind:s(),group:this.groupPanel,api:this._api});if(this._onWillDrop.fire(a),a.defaultPrevented)return;const r=re();if(r&&r.viewId===this.accessor.id){if(e==="content"&&r.groupId===this.id&&(i==="center"||r.panelId===null&&!r.tabGroupId)||e==="header"&&r.groupId===this.id&&r.panelId===null&&!r.tabGroupId)return;if(r.panelId===null){const{groupId:p}=r;this._onMove.fire({target:i,groupId:p,index:n,tabGroupId:r.tabGroupId});return}if(this.tabsContainer.indexOf(r.panelId)!==-1&&this.tabsContainer.size===1)return;const{groupId:h,panelId:c}=r;if(this.id===h&&!i&&this.tabsContainer.indexOf(c)===n)return;this._onMove.fire({target:i,groupId:r.groupId,itemId:r.panelId,index:n})}else this._onDidDrop.fire(new qt({nativeEvent:t,position:i,panel:l,getData:()=>re(),group:this.groupPanel,api:this._api}))}updateDragAndDropState(){this.tabsContainer.updateDragAndDropState()}dispose(){var e,t,i;super.dispose(),(e=this.watermark)===null||e===void 0||e.element.remove(),(i=(t=this.watermark)===null||t===void 0?void 0:t.dispose)===null||i===void 0||i.call(t),this.watermark=void 0;for(const n of[...this._tabGroups])n.dispose();for(const n of this._tabGroupDisposables.values())n.dispose();this._tabGroupDisposables.clear();for(const n of this._pendingMicrotaskDisposables)n.dispose();this._pendingMicrotaskDisposables.clear();for(const n of this.panels)n.dispose();this.tabsContainer.dispose(),this.contentContainer.dispose()}}class Qt extends Ui{constructor(e,t,i){super(e,t),this._onDidConstraintsChangeInternal=new _,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new _,this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new _,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange),i&&this.initialize(i)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}}class tn extends Jt{get priority(){return this._priority}get snap(){return this._snap}get minimumWidth(){return this.__minimumWidth()}get minimumHeight(){return this.__minimumHeight()}get maximumHeight(){return this.__maximumHeight()}get maximumWidth(){return this.__maximumWidth()}__minimumWidth(){const e=typeof this._minimumWidth=="function"?this._minimumWidth():this._minimumWidth;return e!==this._evaluatedMinimumWidth&&(this._evaluatedMinimumWidth=e,this.updateConstraints()),e}__maximumWidth(){const e=typeof this._maximumWidth=="function"?this._maximumWidth():this._maximumWidth;return e!==this._evaluatedMaximumWidth&&(this._evaluatedMaximumWidth=e,this.updateConstraints()),e}__minimumHeight(){const e=typeof this._minimumHeight=="function"?this._minimumHeight():this._minimumHeight;return e!==this._evaluatedMinimumHeight&&(this._evaluatedMinimumHeight=e,this.updateConstraints()),e}__maximumHeight(){const e=typeof this._maximumHeight=="function"?this._maximumHeight():this._maximumHeight;return e!==this._evaluatedMaximumHeight&&(this._evaluatedMaximumHeight=e,this.updateConstraints()),e}get isActive(){return this.api.isActive}get isVisible(){return this.api.isVisible}constructor(e,t,i,n){super(e,t,n??new Qt(e,t)),this._evaluatedMinimumWidth=0,this._evaluatedMaximumWidth=Number.MAX_SAFE_INTEGER,this._evaluatedMinimumHeight=0,this._evaluatedMaximumHeight=Number.MAX_SAFE_INTEGER,this._minimumWidth=0,this._minimumHeight=0,this._maximumWidth=Number.MAX_SAFE_INTEGER,this._maximumHeight=Number.MAX_SAFE_INTEGER,this._snap=!1,this._onDidChange=new _,this.onDidChange=this._onDidChange.event,typeof(i==null?void 0:i.minimumWidth)=="number"&&(this._minimumWidth=i.minimumWidth),typeof(i==null?void 0:i.maximumWidth)=="number"&&(this._maximumWidth=i.maximumWidth),typeof(i==null?void 0:i.minimumHeight)=="number"&&(this._minimumHeight=i.minimumHeight),typeof(i==null?void 0:i.maximumHeight)=="number"&&(this._maximumHeight=i.maximumHeight),this.api.initialize(this),this.addDisposables(this.api.onWillVisibilityChange(s=>{const{isVisible:l}=s,{accessor:a}=this._params;a.setVisible(this,l)}),this.api.onActiveChange(()=>{const{accessor:s}=this._params;s.doSetGroupActive(this)}),this.api.onDidConstraintsChangeInternal(s=>{(typeof s.minimumWidth=="number"||typeof s.minimumWidth=="function")&&(this._minimumWidth=s.minimumWidth),(typeof s.minimumHeight=="number"||typeof s.minimumHeight=="function")&&(this._minimumHeight=s.minimumHeight),(typeof s.maximumWidth=="number"||typeof s.maximumWidth=="function")&&(this._maximumWidth=s.maximumWidth),(typeof s.maximumHeight=="number"||typeof s.maximumHeight=="function")&&(this._maximumHeight=s.maximumHeight)}),this.api.onDidSizeChange(s=>{this._onDidChange.fire({height:s.height,width:s.width})}),this._onDidChange)}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}init(e){e.maximumHeight&&(this._maximumHeight=e.maximumHeight),e.minimumHeight&&(this._minimumHeight=e.minimumHeight),e.maximumWidth&&(this._maximumWidth=e.maximumWidth),e.minimumWidth&&(this._minimumWidth=e.minimumWidth),this._priority=e.priority,this._snap=!!e.snap,super.init(e),typeof e.isVisible=="boolean"&&this.setVisible(e.isVisible)}updateConstraints(){this.api._onDidConstraintsChange.fire({minimumWidth:this._evaluatedMinimumWidth,maximumWidth:this._evaluatedMaximumWidth,minimumHeight:this._evaluatedMinimumHeight,maximumHeight:this._evaluatedMaximumHeight})}toJSON(){const e=super.toJSON(),t=n=>n===Number.MAX_SAFE_INTEGER?void 0:n,i=n=>n<=0?void 0:n;return Object.assign(Object.assign({},e),{minimumHeight:i(this.minimumHeight),maximumHeight:t(this.maximumHeight),minimumWidth:i(this.minimumWidth),maximumWidth:t(this.maximumWidth),snap:this.snap,priority:this.priority})}}const We="dockview: DockviewGroupPanelApiImpl not initialized";class Gs extends Qt{get location(){if(!this._group)throw new Error(We);return this._group.model.location}constructor(e,t){super(e,"__dockviewgroup__"),this.accessor=t,this._onDidLocationChange=new _,this.onDidLocationChange=this._onDidLocationChange.event,this._onDidActivePanelChange=new _,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidCollapsedChange=new _,this.onDidCollapsedChange=this._onDidCollapsedChange.event,this.addDisposables(this._onDidLocationChange,this._onDidActivePanelChange,this._onDidCollapsedChange,this._onDidVisibilityChange.event(i=>{i.isVisible&&this._pendingSize&&(super.setSize(this._pendingSize),this._pendingSize=void 0)}))}setSize(e){this._pendingSize=Object.assign({},e),super.setSize(e)}close(){if(this._group)return this.accessor.removeGroup(this._group)}getWindow(){return this.location.type==="popout"?this.location.getWindow():window}setHeaderPosition(e){if(!this._group)throw new Error(We);this._group.model.headerPosition=e}getHeaderPosition(){if(!this._group)throw new Error(We);return this._group.model.headerPosition}moveTo(e){var t,i,n,s;if(!this._group)throw new Error(We);const l=(t=e.group)!==null&&t!==void 0?t:this.accessor.addGroup({direction:Zn((i=e.position)!==null&&i!==void 0?i:"right"),skipSetActive:(n=e.skipSetActive)!==null&&n!==void 0?n:!1});this.accessor.moveGroupOrPanel({from:{groupId:this._group.id},to:{group:l,position:e.group&&(s=e.position)!==null&&s!==void 0?s:"center",index:e.index},skipSetActive:e.skipSetActive})}maximize(){if(!this._group)throw new Error(We);this.location.type==="grid"&&this.accessor.maximizeGroup(this._group)}isMaximized(){if(!this._group)throw new Error(We);return this.accessor.isMaximizedGroup(this._group)}exitMaximized(){if(!this._group)throw new Error(We);this.isMaximized()&&this.accessor.exitMaximizedGroup()}collapse(){this._group&&this.accessor.setEdgeGroupCollapsed(this._group,!0)}expand(){this._group&&this.accessor.setEdgeGroupCollapsed(this._group,!1)}isCollapsed(){return this._group?this.accessor.isEdgeGroupCollapsed(this._group):!1}initialize(e){this._group=e}}const As=100,Is=100;class dt extends tn{get minimumWidth(){var e;if(typeof this._explicitConstraints.minimumWidth=="number")return this._explicitConstraints.minimumWidth;const t=(e=this.activePanel)===null||e===void 0?void 0:e.minimumWidth;return typeof t=="number"?t:super.__minimumWidth()}get minimumHeight(){var e;if(typeof this._explicitConstraints.minimumHeight=="number")return this._explicitConstraints.minimumHeight;const t=(e=this.activePanel)===null||e===void 0?void 0:e.minimumHeight;return typeof t=="number"?t:super.__minimumHeight()}get maximumWidth(){var e;if(typeof this._explicitConstraints.maximumWidth=="number")return this._explicitConstraints.maximumWidth;const t=(e=this.activePanel)===null||e===void 0?void 0:e.maximumWidth;return typeof t=="number"?t:super.__maximumWidth()}get maximumHeight(){var e;if(typeof this._explicitConstraints.maximumHeight=="number")return this._explicitConstraints.maximumHeight;const t=(e=this.activePanel)===null||e===void 0?void 0:e.maximumHeight;return typeof t=="number"?t:super.__maximumHeight()}get panels(){return this._model.panels}get activePanel(){return this._model.activePanel}get size(){return this._model.size}get model(){return this._model}get locked(){return this._model.locked}set locked(e){this._model.locked=e}get header(){return this._model.header}constructor(e,t,i){var n,s,l,a,r,d;super(t,"groupview_default",{minimumHeight:(s=(n=i.constraints)===null||n===void 0?void 0:n.minimumHeight)!==null&&s!==void 0?s:Is,minimumWidth:(a=(l=i.constraints)===null||l===void 0?void 0:l.minimumWidth)!==null&&a!==void 0?a:As,maximumHeight:(r=i.constraints)===null||r===void 0?void 0:r.maximumHeight,maximumWidth:(d=i.constraints)===null||d===void 0?void 0:d.maximumWidth},new Gs(t,e)),this._explicitConstraints={},this.api.initialize(this),this._model=new Ps(this.element,e,t,i,this),this.addDisposables(this.model.onDidActivePanelChange(h=>{this.api._onDidActivePanelChange.fire(h)}),this.api.onDidConstraintsChangeInternal(h=>{h.minimumWidth!==void 0&&(this._explicitConstraints.minimumWidth=typeof h.minimumWidth=="function"?h.minimumWidth():h.minimumWidth),h.minimumHeight!==void 0&&(this._explicitConstraints.minimumHeight=typeof h.minimumHeight=="function"?h.minimumHeight():h.minimumHeight),h.maximumWidth!==void 0&&(this._explicitConstraints.maximumWidth=typeof h.maximumWidth=="function"?h.maximumWidth():h.maximumWidth),h.maximumHeight!==void 0&&(this._explicitConstraints.maximumHeight=typeof h.maximumHeight=="function"?h.maximumHeight():h.maximumHeight)}))}focus(){this.api.isActive||this.api.setActive(),super.focus()}initialize(){this._model.initialize()}setActive(e){super.setActive(e),this.model.setActive(e)}layout(e,t){super.layout(e,t),this.model.layout(e,t)}getComponent(){return this._model}toJSON(){return this.model.toJSON()}}const Es={className:"dockview-theme-abyss",tabGroupIndicator:"none"};class Ts extends Qt{get location(){return this.group.api.location}get title(){return this.panel.title}get isGroupActive(){return this.group.isActive}get renderer(){return this.panel.renderer}set group(e){const t=this._group;this._group!==e&&(this._group=e,this._onDidGroupChange.fire({}),this.setupGroupEventListeners(t),this._onDidLocationChange.fire({location:this.group.api.location}))}get group(){return this._group}get tabComponent(){return this._tabComponent}constructor(e,t,i,n,s){super(e.id,n),this.panel=e,this.accessor=i,this._onDidTitleChange=new _,this.onDidTitleChange=this._onDidTitleChange.event,this._onDidActiveGroupChange=new _,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._onDidGroupChange=new _,this.onDidGroupChange=this._onDidGroupChange.event,this._onDidRendererChange=new _,this.onDidRendererChange=this._onDidRendererChange.event,this._onDidLocationChange=new _,this.onDidLocationChange=this._onDidLocationChange.event,this.groupEventsDisposable=new le,this._tabComponent=s,this.initialize(e),this._group=t,this.setupGroupEventListeners(),this.addDisposables(this.groupEventsDisposable,this._onDidRendererChange,this._onDidTitleChange,this._onDidGroupChange,this._onDidActiveGroupChange,this._onDidLocationChange)}getWindow(){return this.group.api.getWindow()}moveTo(e){var t,i;this.accessor.moveGroupOrPanel({from:{groupId:this._group.id,panelId:this.panel.id},to:{group:(t=e.group)!==null&&t!==void 0?t:this._group,position:e.group&&(i=e.position)!==null&&i!==void 0?i:"center",index:e.index},skipSetActive:e.skipSetActive})}setTitle(e){this.panel.setTitle(e)}setRenderer(e){this.panel.setRenderer(e)}close(){this.group.model.closePanel(this.panel)}maximize(){this.group.api.maximize()}isMaximized(){return this.group.api.isMaximized()}exitMaximized(){this.group.api.exitMaximized()}setupGroupEventListeners(e){var t;let i=(t=e==null?void 0:e.isActive)!==null&&t!==void 0?t:!1;this.groupEventsDisposable.value=new R(this.group.api.onDidVisibilityChange(n=>{const s=!n.isVisible&&this.isVisible,l=n.isVisible&&!this.isVisible,a=this.group.model.isPanelActive(this.panel);(s||l&&a)&&this._onDidVisibilityChange.fire(n)}),this.group.api.onDidLocationChange(n=>{this.group===this.panel.group&&this._onDidLocationChange.fire(n)}),this.group.api.onDidActiveChange(()=>{this.group===this.panel.group&&i!==this.isGroupActive&&(i=this.isGroupActive,this._onDidActiveGroupChange.fire({isActive:this.isGroupActive}))}))}}class Ke extends R{get params(){return this._params}get title(){return this._title}get group(){return this._group}get renderer(){var e;return(e=this._renderer)!==null&&e!==void 0?e:this.accessor.renderer}get minimumWidth(){return this._minimumWidth}get minimumHeight(){return this._minimumHeight}get maximumWidth(){return this._maximumWidth}get maximumHeight(){return this._maximumHeight}constructor(e,t,i,n,s,l,a,r){super(),this.id=e,this.accessor=n,this.containerApi=s,this.view=a,this._renderer=r.renderer,this._group=l,this._minimumWidth=r.minimumWidth,this._minimumHeight=r.minimumHeight,this._maximumWidth=r.maximumWidth,this._maximumHeight=r.maximumHeight,this.api=new Ts(this,this._group,n,t,i),this.addDisposables(this.api.onActiveChange(()=>{n.setActivePanel(this)}),this.api.onDidSizeChange(d=>{this.group.api.setSize(d)}),this.api.onDidRendererChange(()=>{this.group.model.rerender(this)}))}init(e){this._params=e.params,this.view.init(Object.assign(Object.assign({},e),{api:this.api,containerApi:this.containerApi})),this.setTitle(e.title)}focus(){const e=new $i;this.api._onWillFocus.fire(e),!e.defaultPrevented&&(this.api.isActive||this.api.setActive())}toJSON(){return{id:this.id,contentComponent:this.view.contentComponent,tabComponent:this.view.tabComponent,params:Object.keys(this._params||{}).length>0?this._params:void 0,title:this.title,renderer:this._renderer,minimumHeight:this._minimumHeight,maximumHeight:this._maximumHeight,minimumWidth:this._minimumWidth,maximumWidth:this._maximumWidth}}setTitle(e){e!==this.title&&(this._title=e,this.api._onDidTitleChange.fire({title:e}))}setRenderer(e){e!==this.renderer&&(this._renderer=e,this.api._onDidRendererChange.fire({renderer:e}))}update(e){var t;this._params=Object.assign(Object.assign({},(t=this._params)!==null&&t!==void 0?t:{}),e.params);for(const i of Object.keys(e.params))e.params[i]===void 0&&delete this._params[i];this.view.update({params:this._params})}updateFromStateModel(e){var t,i,n;this._maximumHeight=e.maximumHeight,this._minimumHeight=e.minimumHeight,this._maximumWidth=e.maximumWidth,this._minimumWidth=e.minimumWidth,this.update({params:(t=e.params)!==null&&t!==void 0?t:{}}),this.setTitle((i=e.title)!==null&&i!==void 0?i:this.id),this.setRenderer((n=e.renderer)!==null&&n!==void 0?n:this.accessor.renderer)}updateParentGroup(e,t){this._group=e,this.api.group=this._group;const i=this._group.model.isPanelActive(this),n=this.group.api.isActive&&i;t!=null&&t.skipSetActive||this.api.isActive!==n&&this.api._onDidActiveChange.fire({isActive:this.group.api.isActive&&i}),this.api.isVisible!==i&&this.api._onDidVisibilityChange.fire({isVisible:i})}runEvents(){const e=this._group.model.isPanelActive(this),t=this.group.api.isActive&&e;this.api.isActive!==t&&this.api._onDidActiveChange.fire({isActive:this.group.api.isActive&&e}),this.api.isVisible!==e&&this.api._onDidVisibilityChange.fire({isVisible:e})}layout(e,t){this.api._onDidDimensionChange.fire({width:e,height:t}),this.view.layout(e,t)}dispose(){this.api.dispose(),this.view.dispose()}}class hi extends R{get element(){return this._element}constructor(){super(),this._element=document.createElement("div"),this._element.className="dv-default-tab",this._content=document.createElement("div"),this._content.className="dv-default-tab-content",this.action=document.createElement("div"),this.action.className="dv-default-tab-action",this.action.appendChild(vs()),this._element.appendChild(this._content),this._element.appendChild(this.action),this.render()}init(e){this._title=e.title,this.addDisposables(e.api.onDidTitleChange(t=>{this._title=t.title,this.render()}),k(this.action,"pointerdown",t=>{t.preventDefault()}),k(this.action,"click",t=>{t.defaultPrevented||(t.preventDefault(),e.api.close())})),this.render()}render(){var e;this._content.textContent!==this._title&&(this._content.textContent=(e=this._title)!==null&&e!==void 0?e:"")}}class nn{get content(){return this._content}get tab(){return this._tab}constructor(e,t,i,n){this.accessor=e,this.id=t,this.contentComponent=i,this.tabComponent=n,this._content=this.createContentComponent(this.id,i),this._tab=this.createTabComponent(this.id,n)}createTabRenderer(e){var t;const i=this.createTabComponent(this.id,this.tabComponent);return this._params&&i.init(Object.assign(Object.assign({},this._params),{tabLocation:e})),this._updateEvent&&((t=i.update)===null||t===void 0||t.call(i,this._updateEvent)),i}init(e){this._params=e,this.content.init(e),this.tab.init(Object.assign(Object.assign({},e),{tabLocation:"header"}))}layout(e,t){var i,n;(n=(i=this.content).layout)===null||n===void 0||n.call(i,e,t)}update(e){var t,i,n,s;this._updateEvent=e,(i=(t=this.content).update)===null||i===void 0||i.call(t,e),(s=(n=this.tab).update)===null||s===void 0||s.call(n,e)}dispose(){var e,t,i,n;(t=(e=this.content).dispose)===null||t===void 0||t.call(e),(n=(i=this.tab).dispose)===null||n===void 0||n.call(i)}createContentComponent(e,t){return this.accessor.options.createComponent({id:e,name:t})}createTabComponent(e,t){const i=t??this.accessor.options.defaultTabComponent;if(i){if(this.accessor.options.createTabComponent){const n=this.accessor.options.createTabComponent({id:e,name:i});return n||new hi}console.warn(`dockview: tabComponent '${t}' was not found. falling back to the default tab.`)}return new hi}}class zs{constructor(e){this.accessor=e}fromJSON(e,t){var i,n;const s=e.id,l=e.params,a=e.title,r=e.view,d=r?r.content.id:(i=e.contentComponent)!==null&&i!==void 0?i:"unknown",h=r?(n=r.tab)===null||n===void 0?void 0:n.id:e.tabComponent,c=new nn(this.accessor,s,d,h),u=new Ke(s,d,h,this.accessor,new _t(this.accessor),t,c,{renderer:e.renderer,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight});return u.init({title:a??s,params:l??{}}),u}}class ks extends R{get element(){return this._element}constructor(){super(),this._element=document.createElement("div"),this._element.className="dv-watermark"}init(e){}}class Os{constructor(){this._orderedList=[]}push(e){this._orderedList=[...this._orderedList.filter(t=>t!==e),e],this.update()}destroy(e){this._orderedList=this._orderedList.filter(t=>t!==e),this.update()}update(){for(let e=0;e<this._orderedList.length;e++)this._orderedList[e].setAttribute("aria-level",`${e}`),this._orderedList[e].style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${e*2})`}}const ht=new Os;class Ae extends R{set minimumInViewportWidth(e){this.options.minimumInViewportWidth=e}set minimumInViewportHeight(e){this.options.minimumInViewportHeight=e}get element(){return this._element}get isVisible(){return this._isVisible}constructor(e){super(),this.options=e,this._element=document.createElement("div"),this._onDidChange=new _,this.onDidChange=this._onDidChange.event,this._onDidChangeEnd=new _,this.onDidChangeEnd=this._onDidChangeEnd.event,this.addDisposables(this._onDidChange,this._onDidChangeEnd),this._element.className="dv-resize-container",this._isVisible=!0,this.setupResize("top"),this.setupResize("bottom"),this.setupResize("left"),this.setupResize("right"),this.setupResize("topleft"),this.setupResize("topright"),this.setupResize("bottomleft"),this.setupResize("bottomright"),this._element.appendChild(this.options.content),this.options.container.appendChild(this._element),this.setBounds(Object.assign(Object.assign(Object.assign(Object.assign({height:this.options.height,width:this.options.width},"top"in this.options&&{top:this.options.top}),"bottom"in this.options&&{bottom:this.options.bottom}),"left"in this.options&&{left:this.options.left}),"right"in this.options&&{right:this.options.right})),ht.push(this._element)}setVisible(e){e!==this.isVisible&&(this._isVisible=e,A(this.element,"dv-hidden",!this.isVisible))}bringToFront(){ht.push(this._element)}setBounds(e={}){typeof e.height=="number"&&(this._element.style.height=`${e.height}px`),typeof e.width=="number"&&(this._element.style.width=`${e.width}px`),"top"in e&&typeof e.top=="number"&&(this._element.style.top=`${e.top}px`,this._element.style.bottom="auto",this.verticalAlignment="top"),"bottom"in e&&typeof e.bottom=="number"&&(this._element.style.bottom=`${e.bottom}px`,this._element.style.top="auto",this.verticalAlignment="bottom"),"left"in e&&typeof e.left=="number"&&(this._element.style.left=`${e.left}px`,this._element.style.right="auto",this.horiziontalAlignment="left"),"right"in e&&typeof e.right=="number"&&(this._element.style.right=`${e.right}px`,this._element.style.left="auto",this.horiziontalAlignment="right");const t=this.options.container.getBoundingClientRect(),i=this._element.getBoundingClientRect(),n=Math.max(0,this.getMinimumWidth(i.width)),s=Math.max(0,this.getMinimumHeight(i.height));if(this.verticalAlignment==="top"){const l=Y(i.top-t.top,-s,Math.max(0,t.height-i.height+s));this._element.style.top=`${l}px`,this._element.style.bottom="auto"}if(this.verticalAlignment==="bottom"){const l=Y(t.bottom-i.bottom,-s,Math.max(0,t.height-i.height+s));this._element.style.bottom=`${l}px`,this._element.style.top="auto"}if(this.horiziontalAlignment==="left"){const l=Y(i.left-t.left,-n,Math.max(0,t.width-i.width+n));this._element.style.left=`${l}px`,this._element.style.right="auto"}if(this.horiziontalAlignment==="right"){const l=Y(t.right-i.right,-n,Math.max(0,t.width-i.width+n));this._element.style.right=`${l}px`,this._element.style.left="auto"}this._onDidChange.fire()}toJSON(){const e=this.options.container.getBoundingClientRect(),t=this._element.getBoundingClientRect(),i={};return this.verticalAlignment==="top"?i.top=parseFloat(this._element.style.top):this.verticalAlignment==="bottom"?i.bottom=parseFloat(this._element.style.bottom):i.top=t.top-e.top,this.horiziontalAlignment==="left"?i.left=parseFloat(this._element.style.left):this.horiziontalAlignment==="right"?i.right=parseFloat(this._element.style.right):i.left=t.left-e.left,i.width=t.width,i.height=t.height,i}setupDrag(e,t={inDragMode:!1}){const i=new le,n=()=>{let s=null;const l=Qe();i.value=new R({dispose:()=>{l.release()}},k(window,"pointermove",a=>{const r=this.options.container.getBoundingClientRect(),d=a.clientX-r.left,h=a.clientY-r.top;A(this._element,"dv-resize-container-dragging",!0);const c=this._element.getBoundingClientRect();s===null&&(s={x:a.clientX-c.left,y:a.clientY-c.top});const u=Math.max(0,this.getMinimumWidth(c.width)),p=Math.max(0,this.getMinimumHeight(c.height)),f=Y(h-s.y,-p,Math.max(0,r.height-c.height+p)),m=Y(s.y-h+r.height-c.height,-p,Math.max(0,r.height-c.height+p)),g=Y(d-s.x,-u,Math.max(0,r.width-c.width+u)),v=Y(s.x-d+r.width-c.width,-u,Math.max(0,r.width-c.width+u)),b={};f<=m?b.top=f:b.bottom=m,g<=v?b.left=g:b.right=v,this.setBounds(b)}),k(window,"pointerup",()=>{A(this._element,"dv-resize-container-dragging",!1),i.dispose(),this._onDidChangeEnd.fire()}))};this.addDisposables(i,k(e,"pointerdown",s=>{if(s.defaultPrevented){s.preventDefault();return}oi(s)||n()}),k(this.options.content,"pointerdown",s=>{s.defaultPrevented||oi(s)||s.shiftKey&&n()}),k(this.options.content,"pointerdown",()=>{ht.push(this._element)},!0)),t.inDragMode&&n()}setupResize(e){const t=document.createElement("div");t.className=`dv-resize-handle-${e}`,this._element.appendChild(t);const i=new le;this.addDisposables(i,k(t,"pointerdown",n=>{n.preventDefault();let s=null;const l=Qe();i.value=new R(k(window,"pointermove",a=>{const r=this.options.container.getBoundingClientRect(),d=this._element.getBoundingClientRect(),h=a.clientY-r.top,c=a.clientX-r.left;s===null&&(s={originalY:h,originalHeight:d.height,originalX:c,originalWidth:d.width});let u,p,f,m,g,v;const b=()=>{const D=s.originalY+s.originalHeight>r.height?Math.max(0,r.height-Ae.MINIMUM_HEIGHT):Math.max(0,s.originalY+s.originalHeight-Ae.MINIMUM_HEIGHT);u=Y(h,0,D),f=s.originalY+s.originalHeight-u,p=r.height-u-f},w=()=>{u=s.originalY-s.originalHeight;const D=u<0&&typeof this.options.minimumInViewportHeight=="number"?-u+this.options.minimumInViewportHeight:Ae.MINIMUM_HEIGHT,G=r.height-Math.max(0,u);f=Y(h-u,D,G),p=r.height-u-f},C=()=>{const D=s.originalX+s.originalWidth>r.width?Math.max(0,r.width-Ae.MINIMUM_WIDTH):Math.max(0,s.originalX+s.originalWidth-Ae.MINIMUM_WIDTH);m=Y(c,0,D),v=s.originalX+s.originalWidth-m,g=r.width-m-v},I=()=>{m=s.originalX-s.originalWidth;const D=m<0&&typeof this.options.minimumInViewportWidth=="number"?-m+this.options.minimumInViewportWidth:Ae.MINIMUM_WIDTH,G=r.width-Math.max(0,m);v=Y(c-m,D,G),g=r.width-m-v};switch(e){case"top":b();break;case"bottom":w();break;case"left":C();break;case"right":I();break;case"topleft":b(),C();break;case"topright":b(),I();break;case"bottomleft":w(),C();break;case"bottomright":w(),I();break}const E={};u<=p?E.top=u:E.bottom=p,m<=g?E.left=m:E.right=g,E.height=f,E.width=v,this.setBounds(E)}),{dispose:()=>{l.release()}},k(window,"pointerup",()=>{i.dispose(),this._onDidChangeEnd.fire()}))}))}getMinimumWidth(e){return typeof this.options.minimumInViewportWidth=="number"?e-this.options.minimumInViewportWidth:0}getMinimumHeight(e){return typeof this.options.minimumInViewportHeight=="number"?e-this.options.minimumInViewportHeight:0}dispose(){ht.destroy(this._element),this._element.remove(),super.dispose()}}Ae.MINIMUM_HEIGHT=20;Ae.MINIMUM_WIDTH=20;class Rs extends R{constructor(e,t){super(),this.group=e,this.overlay=t,this.addDisposables(t)}position(e){this.overlay.setBounds(e)}}const ct=100,Me={left:100,top:100,width:300,height:300},Vs=100;class Ms{constructor(){this.cache=new Map,this.currentFrameId=0,this.rafId=null}getPosition(e){const t=this.cache.get(e);if(t&&t.frameId===this.currentFrameId)return t.rect;this.scheduleFrameUpdate();const i=Tt(e);return this.cache.set(e,{rect:i,frameId:this.currentFrameId}),i}invalidate(){this.currentFrameId++}scheduleFrameUpdate(){this.rafId||(this.rafId=requestAnimationFrame(()=>{this.currentFrameId++,this.rafId=null}))}}function Ns(){const o=document.createElement("div");return o.tabIndex=-1,o}class ci extends R{constructor(e,t){super(),this.element=e,this.accessor=t,this.map={},this._disposed=!1,this.positionCache=new Ms,this.pendingUpdates=new Set,this.addDisposables(ne.from(()=>{for(const i of Object.values(this.map))i.disposable.dispose(),i.destroy.dispose();this._disposed=!0}))}updateAllPositions(){if(!this._disposed){this.positionCache.invalidate();for(const e of Object.values(this.map))e.panel.api.isVisible&&e.resize&&e.resize()}}detatch(e){if(this.map[e.api.id]){const{disposable:t,destroy:i}=this.map[e.api.id];return t.dispose(),i.dispose(),delete this.map[e.api.id],!0}return!1}attach(e){const{panel:t,referenceContainer:i}=e;if(!this.map[t.api.id]){const c=Ns();c.className="dv-render-overlay",c.style.visibility="hidden",this.map[t.api.id]={panel:t,disposable:ne.NONE,destroy:ne.NONE,element:c}}const n=this.map[t.api.id].element,s=t.view.content.element;s.parentElement!==n&&n.appendChild(s),n.parentElement!==this.element&&this.element.appendChild(n);const l=()=>{const c=t.api.id;this.pendingUpdates.has(c)||(this.pendingUpdates.add(c),requestAnimationFrame(()=>{if(this.pendingUpdates.delete(c),this.isDisposed||!this.map[c])return;const u=this.positionCache.getPosition(i.element),p=this.positionCache.getPosition(this.element),f=u.left-p.left,m=u.top-p.top,g=u.width,v=u.height;n.style.left=`${f}px`,n.style.top=`${m}px`,n.style.width=`${g}px`,n.style.height=`${v}px`,t.api.isVisible?(n.style.visibility="",n.style.pointerEvents=""):(n.style.visibility="hidden",n.style.pointerEvents="none"),A(n,"dv-render-overlay-float",t.group.api.location.type==="floating")}))},a=()=>{t.api.isVisible?(this.positionCache.invalidate(),l(),n.style.pointerEvents=""):(n.style.visibility="hidden",n.style.pointerEvents="none")},r=new le,d=()=>{t.api.location.type==="floating"?queueMicrotask(()=>{const c=this.accessor.floatingGroups.find(m=>m.group===t.api.group);if(!c)return;const u=c.overlay.element,p=()=>{const m=Number(u.getAttribute("aria-level"));n.style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${m*2+1})`},f=new MutationObserver(()=>{p()});r.value=ne.from(()=>f.disconnect()),f.observe(u,{attributeFilter:["aria-level"],attributes:!0}),p()}):n.style.zIndex=""},h=new R(r,new Bi(n,{onDragEnd:c=>{i.dropTarget.dnd.onDragEnd(c)},onDragEnter:c=>{i.dropTarget.dnd.onDragEnter(c)},onDragLeave:c=>{i.dropTarget.dnd.onDragLeave(c)},onDrop:c=>{i.dropTarget.dnd.onDrop(c)},onDragOver:c=>{i.dropTarget.dnd.onDragOver(c)}}),t.api.onDidVisibilityChange(()=>{a()}),t.api.onDidDimensionsChange(()=>{t.api.isVisible&&l()}),t.api.onDidLocationChange(()=>{d()}));return this.map[t.api.id].destroy=ne.from(()=>{var c;s.parentElement===n&&n.removeChild(s),(c=n.parentElement)===null||c===void 0||c.removeChild(n)}),d(),queueMicrotask(()=>{this.isDisposed||a()}),this.map[t.api.id].disposable.dispose(),this.map[t.api.id].disposable=h,this.map[t.api.id].resize=l,n}}function Ls(o,e,t,i){function n(s){return s instanceof t?s:new t(function(l){l(s)})}return new(t||(t=Promise))(function(s,l){function a(h){try{d(i.next(h))}catch(c){l(c)}}function r(h){try{d(i.throw(h))}catch(c){l(c)}}function d(h){h.done?s(h.value):n(h.value).then(a,r)}d((i=i.apply(o,[])).next())})}function Ws(o){let e;try{e=new URL(o,window.location.href)}catch{throw new Error(`dockview: invalid popout URL: ${o}`)}if(!(e.protocol==="http:"||e.protocol==="https:")||e.origin!==window.location.origin)throw new Error(`dockview: popout URL must be same-origin http(s); got: ${o}`)}class Hs extends R{get window(){var e,t;return(t=(e=this._window)===null||e===void 0?void 0:e.value)!==null&&t!==void 0?t:null}constructor(e,t,i){super(),this.target=e,this.className=t,this.options=i,this._onWillClose=new _,this.onWillClose=this._onWillClose.event,this._onDidClose=new _,this.onDidClose=this._onDidClose.event,this._window=null,this.addDisposables(this._onWillClose,this._onDidClose,{dispose:()=>{this.close()}})}dimensions(){if(!this._window)return null;const e=this._window.value.screenX,t=this._window.value.screenY,i=this._window.value.innerWidth,n=this._window.value.innerHeight;return{top:t,left:e,width:i,height:n}}close(){var e,t;this._window&&(this._onWillClose.fire(),(t=(e=this.options).onWillClose)===null||t===void 0||t.call(e,{id:this.target,window:this._window.value}),this._window.disposable.dispose(),this._window=null,this._onDidClose.fire())}open(){return Ls(this,void 0,void 0,function*(){var e,t;if(this._window)throw new Error("instance of popout window is already open");const i=`${this.options.url}`;Ws(i);const n=Object.entries({top:this.options.top,left:this.options.left,width:this.options.width,height:this.options.height}).map(([r,d])=>`${r}=${d}`).join(","),s=window.open(i,this.target,n);if(!s)return null;const l=new R;this._window={value:s,disposable:l},l.addDisposables(ne.from(()=>{s.close()}),k(window,"beforeunload",()=>{this.close()}));const a=this.createPopoutWindowContainer();return this.className&&a.classList.add(this.className),(t=(e=this.options).onDidOpen)===null||t===void 0||t.call(e,{id:this.target,window:s}),new Promise((r,d)=>{s.addEventListener("unload",h=>{}),s.addEventListener("load",()=>{try{const h=s.document;h.title=document.title,h.body.appendChild(a),En(h,window.document.styleSheets),k(s,"beforeunload",()=>{this.close()}),r(a)}catch(h){d(h)}})})})}createPopoutWindowContainer(){const e=document.createElement("div");return e.classList.add("dv-popout-window"),e.id="dv-popout-window",e.style.position="absolute",e.style.width="100%",e.style.height="100%",e.style.top="0px",e.style.left="0px",e}}class Fs extends R{constructor(e){super(),this.accessor=e,this.init()}init(){const e=new Set,t=new Set;this.addDisposables(this.accessor.onDidAddPanel(i=>{if(e.has(i.api.id))throw new Error(`dockview: Invalid event sequence. [onDidAddPanel] called for panel ${i.api.id} but panel already exists`);e.add(i.api.id)}),this.accessor.onDidRemovePanel(i=>{if(e.has(i.api.id))e.delete(i.api.id);else throw new Error(`dockview: Invalid event sequence. [onDidRemovePanel] called for panel ${i.api.id} but panel does not exists`)}),this.accessor.onDidAddGroup(i=>{if(t.has(i.api.id))throw new Error(`dockview: Invalid event sequence. [onDidAddGroup] called for group ${i.api.id} but group already exists`);t.add(i.api.id)}),this.accessor.onDidRemoveGroup(i=>{if(t.has(i.api.id))t.delete(i.api.id);else throw new Error(`dockview: Invalid event sequence. [onDidRemoveGroup] called for group ${i.api.id} but group does not exists`)}))}}class ui extends R{constructor(e,t=window){super(),this._active=null,this._activeDisposable=new le,this._root=e,this._window=t,this._element=t.document.createElement("div"),this._element.className="dv-popover-anchor",this._element.style.position="relative",this._root.prepend(this._element),this.addDisposables(ne.from(()=>{this.close()}),this._activeDisposable)}updateRoot(e){e.prepend(this._element),this._root=e}openPopover(e,t){var i;this.close();const n=this._window.document.createElement("div");n.style.position="absolute",n.style.zIndex=(i=t.zIndex)!==null&&i!==void 0?i:"var(--dv-overlay-z-index)",n.appendChild(e);const s=this._element.getBoundingClientRect(),l=s.left,a=s.top;n.style.top=`${t.y-a}px`,n.style.left=`${t.x-l}px`,this._element.appendChild(n),this._active=n,this._activeDisposable.value=new R(k(this._window,"pointerdown",r=>{var d;const h=r.target;if(!(h instanceof HTMLElement))return;let c=h;for(;c&&c!==n;)c=(d=c==null?void 0:c.parentElement)!==null&&d!==void 0?d:null;c||this.close()}),k(this._window,"keydown",r=>{(r.key==="Escape"||r.key==="Enter")&&this.close()}),k(this._window,"resize",()=>{this.close()})),this._window.requestAnimationFrame(()=>{Mn(n,this._root)})}close(){this._active&&(this._active.remove(),this._activeDisposable.dispose(),this._active=null)}}function pi(o){if(!(o instanceof HTMLElement))return;const e=Mi(o);return e!=null&&e.style.zIndex?`calc(${e.style.zIndex} * 2)`:void 0}let Bs=0;const $s=()=>`dv-ctx-menu-item-${Bs++}`;function Ze(o){return typeof o=="object"}function Xe(o,e,t,i){const n=document.createElement("div");return n.className="dv-context-menu-item",n.setAttribute("role","menuitem"),i&&(n.classList.add("dv-context-menu-item--disabled"),n.setAttribute("aria-disabled","true")),n.textContent=o,i||n.addEventListener("click",()=>{t(),e()}),n}function mi(){const o=document.createElement("div");return o.className="dv-context-menu-separator",o.setAttribute("role","separator"),o}function Us(o){const e=document.createElement("div");e.className="dv-context-menu-rename";const t=document.createElement("input");return t.className="dv-context-menu-rename-input",t.type="text",t.placeholder="Name This Group",t.value=o.label,t.addEventListener("input",()=>{o.setLabel(t.value)}),t.addEventListener("keydown",i=>{i.key!=="Escape"&&i.key!=="Enter"&&i.stopPropagation()}),t.addEventListener("click",i=>{i.stopPropagation()}),e.appendChild(t),requestAnimationFrame(()=>{t.focus(),t.select()}),e}function js(o,e){const t=document.createElement("div");if(t.className="dv-context-menu-color-picker",!e.enabled)return t;for(const i of e.entries()){const n=document.createElement("div");n.className="dv-context-menu-color-swatch",n.style.setProperty("--dv-tab-group-color",i.value),i.label&&(n.title=i.label),o.color===i.id&&n.classList.add("dv-context-menu-color-swatch--selected"),n.addEventListener("click",()=>{o.setColor(i.id)}),t.appendChild(n)}return t}class Ks{constructor(e){this.accessor=e}show(e,t,i){var n,s;if(!this.accessor.options.getTabContextMenuItems)return;const l=this.accessor.options.getTabContextMenuItems({panel:e,group:t,api:this.accessor.api,event:i});if(l.length===0)return;i.preventDefault();const a=this.accessor.getPopupServiceForGroup(t),r=()=>a.close(),d=document.createElement("div");d.className="dv-context-menu",d.setAttribute("role","menu");for(const h of l)if(h==="separator")d.appendChild(mi());else if(h==="close")d.appendChild(Xe("Close",r,()=>e.api.close()));else if(h==="closeOthers")d.appendChild(Xe("Close Others",r,()=>{t.panels.filter(c=>c!==e).forEach(c=>c.api.close())}));else if(h==="closeAll")d.appendChild(Xe("Close All",r,()=>{[...t.panels].forEach(c=>c.api.close())}));else if(Ze(h)&&h.element)d.appendChild(h.element);else if(Ze(h)&&h.component){const c=(s=(n=this.accessor.options).createContextMenuItemComponent)===null||s===void 0?void 0:s.call(n,{id:$s(),component:h.component});c&&(c.init({panel:e,group:t,api:this.accessor.api,close:r,componentProps:h.componentProps}),d.appendChild(c.element))}else Ze(h)&&h.label&&d.appendChild(Xe(h.label,r,()=>{var c;return(c=h.action)===null||c===void 0?void 0:c.call(h)},h.disabled));a.openPopover(d,{x:i.clientX,y:i.clientY,zIndex:pi(i.target)})}showForChip(e,t,i){if(!this.accessor.options.getTabGroupChipContextMenuItems)return;const n=this.accessor.options.getTabGroupChipContextMenuItems({tabGroup:e,group:t,api:this.accessor.api,event:i});if(n.length===0)return;i.preventDefault();const s=this.accessor.getPopupServiceForGroup(t),l=()=>s.close(),a=document.createElement("div");a.className="dv-context-menu",a.setAttribute("role","menu");for(const r of n)r==="separator"?a.appendChild(mi()):r==="rename"?a.appendChild(Us(e)):r==="colorPicker"?a.appendChild(js(e,this.accessor.tabGroupColorPalette)):Ze(r)&&r.element?a.appendChild(r.element):Ze(r)&&r.label&&a.appendChild(Xe(r.label,l,()=>{var d;return(d=r.action)===null||d===void 0?void 0:d.call(r)},r.disabled));s.openPopover(a,{x:i.clientX,y:i.clientY,zIndex:pi(i.target)})}}class fi extends R{get disabled(){return this._disabled}set disabled(e){var t;this.disabled!==e&&(this._disabled=e,e&&((t=this.model)===null||t===void 0||t.clear()))}get model(){if(!this.disabled)return{clear:()=>{var e;this._model&&((e=this._model.root.parentElement)===null||e===void 0||e.removeChild(this._model.root)),this._model=void 0},exists:()=>!!this._model,getElements:(e,t)=>{const i=this._outline!==t;if(this._outline=t,this._model)return this._model.changed=i,this._model;const n=this.createContainer(),s=this.createAnchor();if(this._model={root:n,overlay:s,changed:i},n.appendChild(s),this.element.appendChild(n),(e==null?void 0:e.target)instanceof HTMLElement){const l=e.target.getBoundingClientRect(),a=this.element.getBoundingClientRect();s.style.left=`${l.left-a.left}px`,s.style.top=`${l.top-a.top}px`}return this._model}}}constructor(e,t){super(),this.element=e,this._disabled=!1,this._disabled=t.disabled,this.addDisposables(ne.from(()=>{var i;(i=this.model)===null||i===void 0||i.clear()}))}createContainer(){const e=document.createElement("div");return e.className="dv-drop-target-container",e}createAnchor(){const e=document.createElement("div");return e.className="dv-drop-target-anchor",e.style.visibility="hidden",e}}class Js{get minimumSize(){return this._isCollapsed?this._collapsedSize:this._expandedMinimumSize}get maximumSize(){return this._isCollapsed?this._collapsedSize:this._expandedMaximumSize}get element(){return this._group.element}get isCollapsed(){return this._isCollapsed}get lastExpandedSize(){return this._lastExpandedSize}get collapsedSize(){return this._collapsedSize}constructor(e,t,i){var n,s,l;this._onDidChange=new _,this.onDidChange=this._onDidChange.event,this.snap=!1,this.priority=ie.Low,this._isCollapsed=!1,this._group=t,this._orientation=i,t.element.classList.add("dv-edge-group"),t.element.dataset.testid=`dv-edge-group-${e.id}`,this._collapsedSize=(n=e.collapsedSize)!==null&&n!==void 0?n:35,this._expandedMaximumSize=(s=e.maximumSize)!==null&&s!==void 0?s:Number.POSITIVE_INFINITY,this._expandedMinimumSize=e.minimumSize!==void 0?e.minimumSize:this._collapsedSize+50,this._lastExpandedSize=(l=e.initialSize)!==null&&l!==void 0?l:200,e.collapsed&&(this._isCollapsed=!0,t.element.classList.add("dv-edge-collapsed"))}layout(e,t){this._isCollapsed||(this._lastExpandedSize=e),this._orientation==="horizontal"?this._group.layout(e,t):this._group.layout(t,e)}setCollapsed(e){this._isCollapsed!==e&&(this._isCollapsed=e,this._group.element.classList.toggle("dv-edge-collapsed",e))}setVisible(e){}restoreExpandedSize(e){this._lastExpandedSize=e}updateCollapsedSize(e,t){this._collapsedSize=e,this._expandedMinimumSize=t}dispose(){this._onDidChange.dispose()}}class Ys{get element(){return this._dockviewElement}constructor(e,t){this._dockviewElement=e,this._layoutDockview=t,this.priority=ie.High,this.minimumSize=100,this.maximumSize=Number.POSITIVE_INFINITY,this._onDidChange=new _,this.onDidChange=this._onDidChange.event}layout(e,t){this._layoutDockview(t,e)}setVisible(e){}dispose(){this._onDidChange.dispose()}}class Zs{get element(){return this._element}constructor(e,t=0){this._onDidChange=new _,this.onDidChange=this._onDidChange.event,this.minimumSize=100,this.maximumSize=Number.POSITIVE_INFINITY,this.priority=ie.High,this._element=document.createElement("div"),this._element.className="dv-shell-middle-column",this._element.style.height="100%",this._element.style.width="100%",this._splitview=new Fe(this._element,{orientation:z.VERTICAL,proportionalLayout:!1,margin:t}),this._centerIndex=0,this._splitview.addView(e,{type:"distribute"},0)}addTopView(e,t){this._splitview.addView(e,t,0),this._topIndex=0,this._centerIndex+=1,this._bottomIndex!==void 0&&(this._bottomIndex+=1)}addBottomView(e,t){const i=this._splitview.length;this._splitview.addView(e,t,i),this._bottomIndex=i}removeView(e){const t=e==="top"?this._topIndex:this._bottomIndex;t!==void 0&&(this._splitview.removeView(t),e==="top"?(this._topIndex=void 0,this._centerIndex-=1,this._bottomIndex!==void 0&&(this._bottomIndex-=1)):this._bottomIndex=void 0)}layout(e,t){this._splitview.layout(t,e)}setVisible(e){}setViewVisible(e,t){const i=e==="top"?this._topIndex:this._bottomIndex;i!==void 0&&this._splitview.setViewVisible(i,t)}isViewVisible(e){const t=e==="top"?this._topIndex:this._bottomIndex;return t!==void 0?this._splitview.isViewVisible(t):!1}getViewSize(e){const t=e==="top"?this._topIndex:this._bottomIndex;return t!==void 0?this._splitview.getViewSize(t):0}resizeView(e,t){const i=e==="top"?this._topIndex:this._bottomIndex;i!==void 0&&this._splitview.resizeView(i,t)}updateMargin(e){this._splitview.margin=e}dispose(){this._onDidChange.dispose(),this._splitview.dispose()}}function Xs(o,e,t){var i;const n=((i=o.collapsedSize)!==null&&i!==void 0?i:e)+t,s=Object.assign(Object.assign({},o),{collapsedSize:n});return o.minimumSize!==void 0&&(s.minimumSize=o.minimumSize+t),s}class qs{constructor(e,t,i,n=0,s=35){this._disposables=new R,this._viewConfigs=new Map,this._currentWidth=0,this._currentHeight=0,this._gap=n,this._defaultCollapsedSize=s,this._shellElement=document.createElement("div"),this._shellElement.className="dv-shell",this._shellElement.style.height="100%",this._shellElement.style.width="100%",this._shellElement.style.position="relative",e.appendChild(this._shellElement);const l=new Ys(t,i);this._middleColumn=new Zs(l,n),this._outerSplitview=new Fe(this._shellElement,{orientation:z.HORIZONTAL,proportionalLayout:!1,margin:n}),this._middleIndex=0,this._outerSplitview.addView(this._middleColumn,{type:"distribute"},0),this._disposables.addDisposables(tt(this._shellElement,a=>{const r=Math.round(a.contentRect.width),d=Math.round(a.contentRect.height);r===this._currentWidth&&d===this._currentHeight||(this._currentWidth=r,this._currentHeight=d,this.layout(r,d))}),this._outerSplitview,this._middleColumn,l)}get element(){return this._shellElement}addEdgeView(e,t,i){if(this.hasEdgeGroup(e))throw new Error(`dockview: edge group already registered at position '${e}'`);this._viewConfigs.set(e,t);const n=1+(this._viewConfigs.has("left")?1:0)+(this._viewConfigs.has("right")?1:0),s=1+(this._viewConfigs.has("top")?1:0)+(this._viewConfigs.has("bottom")?1:0),l=n>1?this._gap*(n-1)/n:0,a=s>1?this._gap*(s-1)/s:0,r=e==="left"||e==="right",d=r?l:a,h=r?"horizontal":"vertical",c=new Js(Xs(Object.assign({collapsedSize:this._defaultCollapsedSize},t),this._defaultCollapsedSize,d),i,h),u=c.isCollapsed?c.collapsedSize:c.lastExpandedSize;switch(e){case"left":this._outerSplitview.addView(c,u,0),this._leftIndex=0,this._middleIndex+=1,this._rightIndex!==void 0&&(this._rightIndex+=1),this._leftView=c;break;case"right":{const p=this._outerSplitview.length;this._outerSplitview.addView(c,u,p),this._rightIndex=p,this._rightView=c}break;case"top":this._middleColumn.addTopView(c,u),this._topView=c;break;case"bottom":this._middleColumn.addBottomView(c,u),this._bottomView=c;break}return this._disposables.addDisposables(c),this.updateTheme(this._gap,this._defaultCollapsedSize),c}layout(e,t){this._outerSplitview.layout(e,t)}updateTheme(e,t){var i,n,s,l;this._gap=e,this._defaultCollapsedSize=t;const a=1+(this._viewConfigs.has("left")?1:0)+(this._viewConfigs.has("right")?1:0),r=1+(this._viewConfigs.has("top")?1:0)+(this._viewConfigs.has("bottom")?1:0),d=a>1?e*(a-1)/a:0,h=r>1?e*(r-1)/r:0;this._outerSplitview.margin=e,this._middleColumn.updateMargin(e);const c=(g,v,b)=>{var w;const I=((w=v.collapsedSize)!==null&&w!==void 0?w:t)+b,E=v.minimumSize,D=E!==void 0?E+b:I+50;g.updateCollapsedSize(I,D)},u=this._viewConfigs.get("top");this._topView&&u&&c(this._topView,u,h);const p=this._viewConfigs.get("bottom");this._bottomView&&p&&c(this._bottomView,p,h);const f=this._viewConfigs.get("left");this._leftView&&f&&c(this._leftView,f,d);const m=this._viewConfigs.get("right");this._rightView&&m&&c(this._rightView,m,d),!((i=this._leftView)===null||i===void 0)&&i.isCollapsed&&this._leftIndex!==void 0&&this._outerSplitview.resizeView(this._leftIndex,this._leftView.collapsedSize),!((n=this._rightView)===null||n===void 0)&&n.isCollapsed&&this._rightIndex!==void 0&&this._outerSplitview.resizeView(this._rightIndex,this._rightView.collapsedSize),!((s=this._topView)===null||s===void 0)&&s.isCollapsed&&this._middleColumn.resizeView("top",this._topView.collapsedSize),!((l=this._bottomView)===null||l===void 0)&&l.isCollapsed&&this._middleColumn.resizeView("bottom",this._bottomView.collapsedSize),this._currentWidth>0&&this._currentHeight>0&&this.layout(this._currentWidth,this._currentHeight)}removeEdgeView(e){const t=this._getView(e);if(t){switch(e){case"left":this._outerSplitview.removeView(this._leftIndex),this._leftIndex=void 0,this._leftView=void 0,this._middleIndex-=1,this._rightIndex!==void 0&&(this._rightIndex-=1);break;case"right":this._outerSplitview.removeView(this._rightIndex),this._rightIndex=void 0,this._rightView=void 0;break;case"top":this._middleColumn.removeView("top"),this._topView=void 0;break;case"bottom":this._middleColumn.removeView("bottom"),this._bottomView=void 0;break}this._disposables.removeDisposable(t),t.dispose(),this._viewConfigs.delete(e),this.updateTheme(this._gap,this._defaultCollapsedSize)}}hasEdgeGroup(e){switch(e){case"top":return this._topView!==void 0;case"bottom":return this._bottomView!==void 0;case"left":return this._leftView!==void 0;case"right":return this._rightView!==void 0}}setEdgeGroupVisible(e,t){switch(e){case"left":this._leftIndex!==void 0&&this._outerSplitview.setViewVisible(this._leftIndex,t);break;case"right":this._rightIndex!==void 0&&this._outerSplitview.setViewVisible(this._rightIndex,t);break;case"top":case"bottom":this._middleColumn.setViewVisible(e,t);break}}isEdgeGroupVisible(e){switch(e){case"left":return this._leftIndex!==void 0?this._outerSplitview.isViewVisible(this._leftIndex):!1;case"right":return this._rightIndex!==void 0?this._outerSplitview.isViewVisible(this._rightIndex):!1;case"top":case"bottom":return this._middleColumn.isViewVisible(e)}}setEdgeGroupCollapsed(e,t){const i=this._getView(e);if(!i)return;i.setCollapsed(t);const n=t?i.collapsedSize:i.lastExpandedSize;switch(e){case"left":this._leftIndex!==void 0&&this._outerSplitview.resizeView(this._leftIndex,n);break;case"right":this._rightIndex!==void 0&&this._outerSplitview.resizeView(this._rightIndex,n);break;case"top":case"bottom":this._middleColumn.resizeView(e,n);break}}isEdgeGroupCollapsed(e){var t,i;return(i=(t=this._getView(e))===null||t===void 0?void 0:t.isCollapsed)!==null&&i!==void 0?i:!1}_getView(e){switch(e){case"top":return this._topView;case"bottom":return this._bottomView;case"left":return this._leftView;case"right":return this._rightView}}toJSON(){const e={};return this._leftView&&this._leftIndex!==void 0&&(e.left={size:this._leftView.isCollapsed?this._leftView.lastExpandedSize:this._outerSplitview.getViewSize(this._leftIndex),visible:this._outerSplitview.isViewVisible(this._leftIndex),collapsed:this._leftView.isCollapsed||void 0}),this._rightView&&this._rightIndex!==void 0&&(e.right={size:this._rightView.isCollapsed?this._rightView.lastExpandedSize:this._outerSplitview.getViewSize(this._rightIndex),visible:this._outerSplitview.isViewVisible(this._rightIndex),collapsed:this._rightView.isCollapsed||void 0}),this._topView&&(e.top={size:this._topView.isCollapsed?this._topView.lastExpandedSize:this._middleColumn.getViewSize("top"),visible:this._middleColumn.isViewVisible("top"),collapsed:this._topView.isCollapsed||void 0}),this._bottomView&&(e.bottom={size:this._bottomView.isCollapsed?this._bottomView.lastExpandedSize:this._middleColumn.getViewSize("bottom"),visible:this._middleColumn.isViewVisible("bottom"),collapsed:this._bottomView.isCollapsed||void 0}),e}fromJSON(e){var t,i,n,s,l,a,r,d,h,c,u,p,f,m,g,v,b,w,C,I;e.left&&this._leftIndex!==void 0&&((t=this._leftView)===null||t===void 0||t.restoreExpandedSize(e.left.size),(i=this._leftView)===null||i===void 0||i.setCollapsed((n=e.left.collapsed)!==null&&n!==void 0?n:!1),this._outerSplitview.resizeView(this._leftIndex,e.left.collapsed&&(l=(s=this._leftView)===null||s===void 0?void 0:s.collapsedSize)!==null&&l!==void 0?l:e.left.size),e.left.visible||this._outerSplitview.setViewVisible(this._leftIndex,!1)),e.right&&this._rightIndex!==void 0&&((a=this._rightView)===null||a===void 0||a.restoreExpandedSize(e.right.size),(r=this._rightView)===null||r===void 0||r.setCollapsed((d=e.right.collapsed)!==null&&d!==void 0?d:!1),this._outerSplitview.resizeView(this._rightIndex,e.right.collapsed&&(c=(h=this._rightView)===null||h===void 0?void 0:h.collapsedSize)!==null&&c!==void 0?c:e.right.size),e.right.visible||this._outerSplitview.setViewVisible(this._rightIndex,!1)),e.top&&((u=this._topView)===null||u===void 0||u.restoreExpandedSize(e.top.size),(p=this._topView)===null||p===void 0||p.setCollapsed((f=e.top.collapsed)!==null&&f!==void 0?f:!1),this._middleColumn.resizeView("top",e.top.collapsed&&(g=(m=this._topView)===null||m===void 0?void 0:m.collapsedSize)!==null&&g!==void 0?g:e.top.size),e.top.visible||this._middleColumn.setViewVisible("top",!1)),e.bottom&&((v=this._bottomView)===null||v===void 0||v.restoreExpandedSize(e.bottom.size),(b=this._bottomView)===null||b===void 0||b.setCollapsed((w=e.bottom.collapsed)!==null&&w!==void 0?w:!1),this._middleColumn.resizeView("bottom",e.bottom.collapsed&&(I=(C=this._bottomView)===null||C===void 0?void 0:C.collapsedSize)!==null&&I!==void 0?I:e.bottom.size),e.bottom.visible||this._middleColumn.setViewVisible("bottom",!1))}dispose(){var e;this._disposables.dispose(),(e=this._shellElement.parentElement)===null||e===void 0||e.removeChild(this._shellElement)}}const gi={activationSize:{type:"pixels",value:10},size:{type:"pixels",value:20}};function Qs(o){var e;const t=(e=o.tabGroupColors)!==null&&e!==void 0?e:Yt,i=o.tabGroupAccent!=="off";return new Ji(t,i)}function ut(o){const e=o.from.activePanel;[...o.from.panels].map(i=>{const n=o.from.model.removePanel(i);return o.from.model.renderContainer.detatch(i),n}).forEach(i=>{o.to.model.openPanel(i,{skipSetActive:e!==i,skipSetGroupActive:!0})})}class eo extends Wi{get orientation(){return this.gridview.orientation}get totalPanels(){return this.panels.length}get panels(){return this.groups.flatMap(e=>e.panels)}get options(){return this._options}get tabGroupColorPalette(){return this._tabGroupColorPalette}get activePanel(){const e=this.activeGroup;if(e)return e.activePanel}get renderer(){var e;return(e=this.options.defaultRenderer)!==null&&e!==void 0?e:"onlyWhenVisible"}get defaultHeaderPosition(){var e;return(e=this.options.defaultHeaderPosition)!==null&&e!==void 0?e:"top"}get api(){return this._api}get floatingGroups(){return this._floatingGroups}get popoutRestorationPromise(){return this._popoutRestorationPromise}constructor(e,t){var i,n,s,l,a,r;super(e,{proportionalLayout:!0,orientation:z.HORIZONTAL,styles:t.hideBorders?{separatorBorder:"transparent"}:void 0,disableAutoResizing:t.disableAutoResizing,locked:t.locked,margin:(n=(i=t.theme)===null||i===void 0?void 0:i.gap)!==null&&n!==void 0?n:0,className:t.className}),this.nextGroupId=Ut(),this._deserializer=new zs(this),this._watermark=null,this._popoutPopupServices=new Map,this._onWillDragPanel=new _,this.onWillDragPanel=this._onWillDragPanel.event,this._onWillDragGroup=new _,this.onWillDragGroup=this._onWillDragGroup.event,this._onDidDrop=new _,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new _,this.onWillDrop=this._onWillDrop.event,this._onWillShowOverlay=new _,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onUnhandledDragOverEvent=new _,this.onUnhandledDragOverEvent=this._onUnhandledDragOverEvent.event,this._onDidRemovePanel=new _,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidAddPanel=new _,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPopoutGroupSizeChange=new _,this.onDidPopoutGroupSizeChange=this._onDidPopoutGroupSizeChange.event,this._onDidPopoutGroupPositionChange=new _,this.onDidPopoutGroupPositionChange=this._onDidPopoutGroupPositionChange.event,this._onDidOpenPopoutWindowFail=new _,this.onDidOpenPopoutWindowFail=this._onDidOpenPopoutWindowFail.event,this._onDidLayoutFromJSON=new _,this.onDidLayoutFromJSON=this._onDidLayoutFromJSON.event,this._onDidActivePanelChange=new _({replay:!0}),this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidMovePanel=new _,this.onDidMovePanel=this._onDidMovePanel.event,this._onDidCreateTabGroup=new _,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new _,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new _,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new _,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new _,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new _,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,this._onDidMaximizedGroupChange=new _,this.onDidMaximizedGroupChange=this._onDidMaximizedGroupChange.event,this._inShellLayout=!1,this._edgeGroups=new Map,this._edgeGroupDisposables=new Map,this._floatingGroups=[],this._popoutGroups=[],this._popoutRestorationPromise=Promise.resolve(),this._onDidRemoveGroup=new _,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new _,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidOptionsChange=new _,this.onDidOptionsChange=this._onDidOptionsChange.event,this._onDidActiveGroupChange=new _,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._moving=!1,this._options=t,this._tabGroupColorPalette=Qs(t),this.popupService=new ui(this.element),this.contextMenuController=new Ks(this),this._api=new _t(this),this.disableResizing=!0,e.removeChild(this.element),this._shellManager=new qs(e,this.element,(d,h)=>this._layoutFromShell(d,h),(l=(s=t.theme)===null||s===void 0?void 0:s.gap)!==null&&l!==void 0?l:0,(a=t.theme)===null||a===void 0?void 0:a.edgeGroupCollapsedSize),this.popupService.updateRoot(this._shellManager.element),this._shellThemeClassnames=new bt(this._shellManager.element),this.rootDropTargetContainer=new fi(this._shellManager.element,{disabled:!0}),this.overlayRenderContainer=new ci(this._shellManager.element,this),this._floatingOverlayHost=document.createElement("div"),this._floatingOverlayHost.className="dv-floating-overlay-host",this._shellManager.element.appendChild(this._floatingOverlayHost),this._rootDropTarget=new we(this.element,{className:"dv-drop-target-edge",canDisplayOverlay:(d,h)=>{const c=re();if(c)return c.viewId!==this.id?!1:h==="center"?this.gridview.length===0:!0;if(h==="center"&&this.gridview.length!==0)return!1;const u=new Qi(d,"edge",h,re);return this._onUnhandledDragOverEvent.fire(u),u.isAccepted},acceptedTargetZones:["top","bottom","left","right","center"],overlayModel:(r=t.rootOverlayModel)!==null&&r!==void 0?r:gi,getOverrideTarget:()=>{var d;return(d=this.rootDropTargetContainer)===null||d===void 0?void 0:d.model}}),this.updateDropTargetModel(t),A(this.gridview.element,"dv-dockview",!0),A(this.element,"dv-debug",!!t.debug),this.updateTheme(),this.updateWatermark(),t.debug&&this.addDisposables(new Fs(this)),this.addDisposables(this.rootDropTargetContainer,this.overlayRenderContainer,this._onWillDragPanel,this._onWillDragGroup,this._onWillShowOverlay,this._onDidActivePanelChange,this._onDidAddPanel,this._onDidRemovePanel,this._onDidLayoutFromJSON,this._onDidDrop,this._onWillDrop,this._onDidMovePanel,this._onDidMovePanel.event(()=>{this.debouncedUpdateAllPositions()}),this._onDidAddGroup,this._onDidRemoveGroup,this._onDidActiveGroupChange,this._onUnhandledDragOverEvent,this._onDidMaximizedGroupChange,this._onDidOptionsChange,this._onDidPopoutGroupSizeChange,this._onDidPopoutGroupPositionChange,this._onDidOpenPopoutWindowFail,this._onDidCreateTabGroup,this._onDidDestroyTabGroup,this._onDidAddPanelToTabGroup,this._onDidRemovePanelFromTabGroup,this._onDidTabGroupChange,this._onDidTabGroupCollapsedChange,this.onDidViewVisibilityChangeMicroTaskQueue(()=>{this.updateWatermark()}),this.onDidAdd(d=>{this._moving||this._onDidAddGroup.fire(d)}),this.onDidRemove(d=>{this._moving||this._onDidRemoveGroup.fire(d)}),this.onDidActiveChange(d=>{this._moving||this._onDidActiveGroupChange.fire(d)}),this.onDidMaximizedChange(d=>{this._onDidMaximizedGroupChange.fire({group:d.panel,isMaximized:d.isMaximized})}),He.any(this.onDidAdd,this.onDidRemove)(()=>{this.updateWatermark()}),He.any(this.onDidAddPanel,this.onDidRemovePanel,this.onDidAddGroup,this.onDidRemove,this.onDidRemoveGroup,this.onDidMovePanel,this.onDidActivePanelChange,this.onDidPopoutGroupPositionChange,this.onDidPopoutGroupSizeChange,this.onDidCreateTabGroup,this.onDidDestroyTabGroup,this.onDidAddPanelToTabGroup,this.onDidRemovePanelFromTabGroup,this.onDidTabGroupChange,this.onDidTabGroupCollapsedChange)(()=>{this._bufferOnDidLayoutChange.fire()}),ne.from(()=>{var d;for(const h of[...this._floatingGroups])h.dispose();for(const h of[...this._popoutGroups])h.disposable.dispose();(d=this._shellManager)===null||d===void 0||d.dispose();for(const h of this._edgeGroupDisposables.values())h.dispose();this._edgeGroupDisposables.clear()}),this._rootDropTarget,this._rootDropTarget.onWillShowOverlay(d=>{this.gridview.length>0&&d.position==="center"||this._onWillShowOverlay.fire(new wt(d,{kind:"edge",panel:void 0,api:this._api,group:void 0,getData:re}))}),this._rootDropTarget.onDrop(d=>{var h;const c=new en({nativeEvent:d.nativeEvent,position:d.position,panel:void 0,api:this._api,group:void 0,getData:re,kind:"edge"});if(this._onWillDrop.fire(c),c.defaultPrevented)return;const u=re();u?this.moveGroupOrPanel({from:{groupId:u.groupId,panelId:(h=u.panelId)!==null&&h!==void 0?h:void 0},to:{group:this.orthogonalize(d.position),position:"center"}}):this._onDidDrop.fire(new qt({nativeEvent:d.nativeEvent,position:d.position,panel:void 0,api:this._api,group:void 0,getData:re}))}),this._rootDropTarget)}setVisible(e,t){switch(e.api.location.type){case"grid":super.setVisible(e,t);break;case"floating":{const i=this.floatingGroups.find(n=>n.group===e);i&&(i.overlay.setVisible(t),e.api._onDidVisibilityChange.fire({isVisible:t}));break}case"popout":console.warn("dockview: You cannot hide a group that is in a popout window");break}}getPopupServiceForGroup(e){var t;return(t=this._popoutPopupServices.get(e.id))!==null&&t!==void 0?t:this.popupService}addPopoutGroup(e,t){var i,n,s,l,a;if(e instanceof dt&&e.model.location.type==="edge")return Promise.resolve(!1);if(e instanceof Ke&&e.group.size===1)return this.addPopoutGroup(e.group,t);const r=On(this.gridview.element),d=this.element;function h(){return t!=null&&t.position?t.position:e instanceof dt?e.element.getBoundingClientRect():e.group?e.group.element.getBoundingClientRect():d.getBoundingClientRect()}const c=h(),u=(n=(i=t==null?void 0:t.overridePopoutGroup)===null||i===void 0?void 0:i.id)!==null&&n!==void 0?n:this.getNextGroupId(),p=new Hs(`${this.id}-${u}`,r??"",{url:(a=(s=t==null?void 0:t.popoutUrl)!==null&&s!==void 0?s:(l=this.options)===null||l===void 0?void 0:l.popoutUrl)!==null&&a!==void 0?a:"/popout.html",left:window.screenX+c.left,top:window.screenY+c.top,width:c.width,height:c.height,onDidOpen:t==null?void 0:t.onDidOpen,onWillClose:t==null?void 0:t.onWillClose}),f=new R(p,p.onDidClose(()=>{f.dispose()}));return p.open().then(m=>{var g;if(p.isDisposed)return!1;const v=t!=null&&t.referenceGroup?t.referenceGroup:e instanceof Ke?e.group:e,b=e.api.location.type,w=v.element.parentElement!==null;let C;if(w?t!=null&&t.overridePopoutGroup?C=t.overridePopoutGroup:(C=this.createGroup({id:u}),m&&this._onDidAddGroup.fire(C)):C=v,m===null)return console.error("dockview: failed to create popout. perhaps you need to allow pop-ups for this website"),f.dispose(),this._onDidOpenPopoutWindowFail.fire(),this.movingLock(()=>ut({from:C,to:v})),v.api.isVisible||v.api.setVisible(!0),!1;const I=document.createElement("div");I.className="dv-overlay-render-container";const E=new ci(I,this);C.model.renderContainer=E,C.layout(p.window.innerWidth,p.window.innerHeight);let D;if(!(t!=null&&t.overridePopoutGroup)&&w)if(e instanceof Ke)this.movingLock(()=>{const y=v.model.removePanel(e);C.model.openPanel(y)});else switch(this.movingLock(()=>ut({from:v,to:C})),b){case"grid":v.api.setVisible(!1);break;case"floating":case"popout":D=(g=this._floatingGroups.find(y=>y.group.api.id===e.api.id))===null||g===void 0?void 0:g.overlay.toJSON(),this.removeGroup(v);break}m.classList.add("dv-dockview"),m.style.overflow="hidden",m.appendChild(I),m.appendChild(C.element);const G=document.createElement("div"),M=new fi(G,{disabled:this.rootDropTargetContainer.disabled});m.appendChild(G),C.model.dropTargetContainer=M;const H=new ui(m,p.window);this._popoutPopupServices.set(C.id,H),f.addDisposables(H,ne.from(()=>{this._popoutPopupServices.delete(C.id)})),C.model.location={type:"popout",getWindow:()=>p.window,popoutUrl:t==null?void 0:t.popoutUrl},w&&e.api.location.type==="grid"&&e.api.setVisible(!1),this.doSetGroupAndPanelActive(C),f.addDisposables(C.api.onDidActiveChange(y=>{var S;y.isActive&&((S=p.window)===null||S===void 0||S.focus())}),C.api.onWillFocus(()=>{var y;(y=p.window)===null||y===void 0||y.focus()}));let N;const L=w&&v&&this.getPanel(v.id),X={window:p,popoutGroup:C,referenceGroup:L?v.id:void 0,disposable:{dispose:()=>(f.dispose(),N)}},B=Rn(p.window);return f.addDisposables(B,Vn(p.window,()=>{this._onDidPopoutGroupSizeChange.fire({width:p.window.innerWidth,height:p.window.innerHeight,group:C})}),B.event(()=>{this._onDidPopoutGroupPositionChange.fire({screenX:p.window.screenX,screenY:p.window.screenX,group:C})}),k(p.window,"resize",()=>{C.layout(p.window.innerWidth,p.window.innerHeight)}),E,ne.from(()=>{if(!this.isDisposed){if(w&&this.getPanel(v.id))this.movingLock(()=>ut({from:C,to:v})),v.api.isVisible||v.api.setVisible(!0),this.getPanel(C.id)&&this.doRemoveGroup(C,{skipPopoutAssociated:!0});else if(this.getPanel(C.id)){if(C.model.renderContainer=this.overlayRenderContainer,C.model.dropTargetContainer=this.rootDropTargetContainer,N=C,!this._popoutGroups.find(S=>S.popoutGroup===C))return;D?this.addFloatingGroup(C,{height:D.height,width:D.width,position:D}):(this.doRemoveGroup(C,{skipDispose:!0,skipActive:!0,skipPopoutReturn:!0}),C.model.location={type:"grid"},this.movingLock(()=>{this.doAddGroup(C,[0])})),this.doSetGroupAndPanelActive(C)}}})),this._popoutGroups.push(X),this.updateWatermark(),!0}).catch(m=>(console.error("dockview: failed to create popout.",m),!1))}addFloatingGroup(e,t){var i,n,s,l,a,r;if(e instanceof dt&&e.model.location.type==="edge")return;let d;if(e instanceof Ke)d=this.createGroup(),this._onDidAddGroup.fire(d),this.movingLock(()=>this.removePanel(e,{removeEmptyGroup:!0,skipDispose:!0,skipSetActiveGroup:!0})),this.movingLock(()=>d.model.openPanel(e,{skipSetGroupActive:!0}));else{d=e;const g=(i=this._popoutGroups.find(w=>w.popoutGroup===d))===null||i===void 0?void 0:i.referenceGroup,v=g?this.getPanel(g):void 0;typeof(t==null?void 0:t.skipRemoveGroup)=="boolean"&&t.skipRemoveGroup||(v?(this.movingLock(()=>ut({from:e,to:v})),this.doRemoveGroup(e,{skipPopoutReturn:!0,skipPopoutAssociated:!0}),this.doRemoveGroup(v,{skipDispose:!0}),d=v):this.doRemoveGroup(e,{skipDispose:!0,skipPopoutReturn:!0,skipPopoutAssociated:!1}))}function h(){if(t!=null&&t.position){const g={};return"left"in t.position?g.left=Math.max(t.position.left,0):"right"in t.position?g.right=Math.max(t.position.right,0):g.left=Me.left,"top"in t.position?g.top=Math.max(t.position.top,0):"bottom"in t.position?g.bottom=Math.max(t.position.bottom,0):g.top=Me.top,typeof t.width=="number"?g.width=Math.max(t.width,0):g.width=Me.width,typeof t.height=="number"?g.height=Math.max(t.height,0):g.height=Me.height,g}return{left:typeof(t==null?void 0:t.x)=="number"?Math.max(t.x,0):Me.left,top:typeof(t==null?void 0:t.y)=="number"?Math.max(t.y,0):Me.top,width:typeof(t==null?void 0:t.width)=="number"?Math.max(t.width,0):Me.width,height:typeof(t==null?void 0:t.height)=="number"?Math.max(t.height,0):Me.height}}const c=h(),u=new Ae(Object.assign(Object.assign({container:(n=this._floatingOverlayHost)!==null&&n!==void 0?n:this.gridview.element,content:d.element},c),{minimumInViewportWidth:this.options.floatingGroupBounds==="boundedWithinViewport"?void 0:(l=(s=this.options.floatingGroupBounds)===null||s===void 0?void 0:s.minimumWidthWithinViewport)!==null&&l!==void 0?l:ct,minimumInViewportHeight:this.options.floatingGroupBounds==="boundedWithinViewport"?void 0:(r=(a=this.options.floatingGroupBounds)===null||a===void 0?void 0:a.minimumHeightWithinViewport)!==null&&r!==void 0?r:ct})),p=d.element.querySelector(".dv-void-container");if(!p)throw new Error("dockview: failed to find drag handle");u.setupDrag(p,{inDragMode:typeof(t==null?void 0:t.inDragMode)=="boolean"?t.inDragMode:!1});const f=new Rs(d,u),m=new R(d.api.onDidActiveChange(g=>{g.isActive&&u.bringToFront()}),(()=>{let g=-1,v=-1;return tt(d.element,b=>{const w=Math.round(b.contentRect.width),C=Math.round(b.contentRect.height);w===g&&C===v||(g=w,v=C,d.layout(w,C))})})());f.addDisposables(u.onDidChange(()=>{d.layout(d.width,d.height)}),u.onDidChangeEnd(()=>{this._bufferOnDidLayoutChange.fire()}),d.onDidChange(g=>{u.setBounds({height:g==null?void 0:g.height,width:g==null?void 0:g.width})}),{dispose:()=>{m.dispose(),St(this._floatingGroups,f),d.model.location={type:"grid"},this.updateWatermark()}}),this._floatingGroups.push(f),d.model.location={type:"floating"},t!=null&&t.skipActiveGroup||this.doSetGroupAndPanelActive(d),this.updateWatermark()}orthogonalize(e,t){switch(this.gridview.normalize(),e){case"top":case"bottom":this.gridview.orientation===z.HORIZONTAL&&this.gridview.insertOrthogonalSplitviewAtRoot();break;case"left":case"right":this.gridview.orientation===z.VERTICAL&&this.gridview.insertOrthogonalSplitviewAtRoot();break}switch(e){case"top":case"left":case"center":return this.createGroupAtLocation([0],void 0,t);case"bottom":case"right":return this.createGroupAtLocation([this.gridview.length],void 0,t);default:throw new Error(`dockview: unsupported position ${e}`)}}updateOptions(e){var t,i,n;if(super.updateOptions(e),"floatingGroupBounds"in e)for(const a of this._floatingGroups){switch(e.floatingGroupBounds){case"boundedWithinViewport":a.overlay.minimumInViewportHeight=void 0,a.overlay.minimumInViewportWidth=void 0;break;case void 0:a.overlay.minimumInViewportHeight=ct,a.overlay.minimumInViewportWidth=ct;break;default:a.overlay.minimumInViewportHeight=(t=e.floatingGroupBounds)===null||t===void 0?void 0:t.minimumHeightWithinViewport,a.overlay.minimumInViewportWidth=(i=e.floatingGroupBounds)===null||i===void 0?void 0:i.minimumWidthWithinViewport}a.overlay.setBounds()}this.updateDropTargetModel(e);const s=this.options.disableDnd;this._options=Object.assign(Object.assign({},this.options),e);const l=this.options.disableDnd;if(s!==l&&this.updateDragAndDropState(),"theme"in e&&this.updateTheme(),"createRightHeaderActionComponent"in e||"createLeftHeaderActionComponent"in e||"createPrefixHeaderActionComponent"in e)for(const a of this.groups)a.model.updateHeaderActions();if("tabGroupColors"in e||"tabGroupAccent"in e){this._tabGroupColorPalette.setEntries((n=this._options.tabGroupColors)!==null&&n!==void 0?n:Yt),this._tabGroupColorPalette.enabled=this._options.tabGroupAccent!=="off";for(const a of this.groups)a.model.refreshTabGroupAccent()}this._onDidOptionsChange.fire(),this._layoutFromShell(this.gridview.width,this.gridview.height)}layout(e,t,i){if(this._shellManager&&!this._inShellLayout?this._shellManager.layout(e,t):super.layout(e,t,i),this._syncFloatingOverlayHost(),this._floatingGroups)for(const n of this._floatingGroups)n.overlay.setBounds()}_syncFloatingOverlayHost(){if(!this._floatingOverlayHost||!this._shellManager)return;const e=this._shellManager.element.getBoundingClientRect(),t=this.element.getBoundingClientRect(),i=this._floatingOverlayHost;i.style.left=`${t.left-e.left}px`,i.style.top=`${t.top-e.top}px`,i.style.width=`${t.width}px`,i.style.height=`${t.height}px`}_layoutFromShell(e,t){this._inShellLayout=!0,this.layout(e,t,!0),this._inShellLayout=!1}forceRelayout(){this._shellManager?this._layoutFromShell(this.width,this.height):super.forceRelayout()}addEdgeGroup(e,t){if(this._edgeGroups.has(e))throw new Error(`dockview: edge group already exists at position '${e}'`);const i=this.createGroup({id:t.id});i.model.location={type:"edge",position:e},i.model.headerPosition=e,this._edgeGroups.set(e,i),this._onDidAddGroup.fire(i);const n=i.model.onDidRemovePanel(()=>{i.model.isEmpty&&this.setEdgeGroupCollapsed(i,!0)});return this._edgeGroupDisposables.set(e,n),this._shellManager.addEdgeView(e,t,i),i.api}getEdgeGroup(e){var t;return(t=this._edgeGroups.get(e))===null||t===void 0?void 0:t.api}setEdgeGroupVisible(e,t){this._shellManager.setEdgeGroupVisible(e,t)}isEdgeGroupVisible(e){return this._shellManager.isEdgeGroupVisible(e)}removeEdgeGroup(e){var t;const i=this._edgeGroups.get(e);if(!i)throw new Error(`dockview: no edge group exists at position '${e}'`);for(const n of[...i.panels])this.removePanel(n,{removeEmptyGroup:!1,skipDispose:!1});(t=this._edgeGroupDisposables.get(e))===null||t===void 0||t.dispose(),this._edgeGroupDisposables.delete(e),this._shellManager.removeEdgeView(e),this._edgeGroups.delete(e),i.dispose(),this._groups.delete(i.id),this._onDidRemoveGroup.fire(i)}setEdgeGroupCollapsed(e,t){for(const[i,n]of this._edgeGroups)if(n===e){if(this._shellManager.isEdgeGroupCollapsed(i)===t)return;this._shellManager.setEdgeGroupCollapsed(i,t),n.api._onDidCollapsedChange.fire({isCollapsed:t});return}}isEdgeGroupCollapsed(e){for(const[t,i]of this._edgeGroups)if(i===e)return this._shellManager.isEdgeGroupCollapsed(t);return!1}updateDragAndDropState(){for(const e of this.groups)e.model.updateDragAndDropState()}focus(){var e;(e=this.activeGroup)===null||e===void 0||e.focus()}getGroupPanel(e){return this.panels.find(t=>t.id===e)}setActivePanel(e){e.group.model.openPanel(e),this.doSetGroupAndPanelActive(e.group)}moveToNext(e={}){var t;if(!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}if(e.includePanel&&e.group&&e.group.activePanel!==e.group.panels[e.group.panels.length-1]){e.group.model.moveToNext({suppressRoll:!0});return}const i=Z(e.group.element),n=(t=this.gridview.next(i))===null||t===void 0?void 0:t.view;this.doSetGroupAndPanelActive(n)}moveToPrevious(e={}){var t;if(!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}if(e.includePanel&&e.group&&e.group.activePanel!==e.group.panels[0]){e.group.model.moveToPrevious({suppressRoll:!0});return}const i=Z(e.group.element),n=(t=this.gridview.previous(i))===null||t===void 0?void 0:t.view;n&&this.doSetGroupAndPanelActive(n)}toJSON(){var e;const t=this.gridview.serialize(),i=this.panels.reduce((a,r)=>(a[r.id]=r.toJSON(),a),{}),n=this._floatingGroups.map(a=>({data:a.group.toJSON(),position:a.overlay.toJSON()})),s=this._popoutGroups.map(a=>({data:a.popoutGroup.toJSON(),gridReferenceGroup:a.referenceGroup,position:a.window.dimensions(),url:a.popoutGroup.api.location.type==="popout"?a.popoutGroup.api.location.popoutUrl:void 0})),l={grid:t,panels:i,activeGroup:(e=this.activeGroup)===null||e===void 0?void 0:e.id};if(n.length>0&&(l.floatingGroups=n),s.length>0&&(l.popoutGroups=s),this._edgeGroups.size>0){const a=this._shellManager.toJSON();for(const[r,d]of this._edgeGroups){const h=a[r];h&&(h.group=d.toJSON())}l.edgeGroups=a}return l}fromJSON(e,t){var i,n,s;const l=new Map;let a;if(t!=null&&t.reuseExistingPanels){a=this.createGroup(),this._groups.delete(a.api.id);const c=Object.keys(e.panels);for(const u of this.panels)c.includes(u.api.id)&&l.set(u.api.id,u);this.movingLock(()=>{Array.from(l.values()).forEach(u=>{this.moveGroupOrPanel({from:{groupId:u.api.group.api.id,panelId:u.api.id},to:{group:a,position:"center"},keepEmptyGroups:!0})})})}if(this.clear(),typeof e!="object"||e===null)throw new Error("dockview: serialized layout must be a non-null object");const{grid:r,panels:d,activeGroup:h}=e;if(r.root.type!=="branch"||!Array.isArray(r.root.data))throw new Error("dockview: root must be of type branch");try{const c=this.width,u=this.height,p=v=>{const{id:b,locked:w,hideHeader:C,headerPosition:I,views:E,activeView:D}=v;if(typeof b!="string")throw new Error("dockview: group id must be of type string");const G=this.createGroup({id:b,locked:!!w,hideHeader:!!C,headerPosition:I});this._onDidAddGroup.fire(G);const M=[];for(const H of E){const N=l.get(H);if(a&&N)this.movingLock(()=>{a.model.removePanel(N)}),M.push(N),N.updateFromStateModel(d[H]);else{const L=this._deserializer.fromJSON(d[H],G);M.push(L)}}for(let H=0;H<E.length;H++){const N=M[H],L=typeof D=="string"&&D===N.id;l.has(N.api.id)?this.movingLock(()=>{G.model.openPanel(N,{skipSetActive:!L,skipSetGroupActive:!0})}):G.model.openPanel(N,{skipSetActive:!L,skipSetGroupActive:!0})}return v.tabGroups&&v.tabGroups.length>0&&G.model.restoreTabGroups(v.tabGroups),!G.activePanel&&G.panels.length>0&&G.model.openPanel(G.panels[G.panels.length-1],{skipSetGroupActive:!0}),G};if(this.gridview.deserialize(r,{fromJSON:v=>p(v.data)}),this._layoutFromShell(c,u),e.edgeGroups){for(const v of["top","bottom","left","right"]){const b=e.edgeGroups[v];if(b&&!this._edgeGroups.has(v)){const w=b.group,C=(i=w==null?void 0:w.id)!==null&&i!==void 0?i:`${v}-group`;this.addEdgeGroup(v,{id:C})}}for(const[v,b]of this._edgeGroups){const w=e.edgeGroups[v],C=w==null?void 0:w.group;if(C){const{views:I,activeView:E}=C,D=[];for(const G of I)if(d[G]){const M=this._deserializer.fromJSON(d[G],b);D.push(M)}for(let G=0;G<D.length;G++){const M=D[G],H=E===M.id;b.model.openPanel(M,{skipSetActive:!H,skipSetGroupActive:!0})}C.tabGroups&&C.tabGroups.length>0&&b.model.restoreTabGroups(C.tabGroups),!b.activePanel&&b.panels.length>0&&b.model.openPanel(b.panels[b.panels.length-1],{skipSetGroupActive:!0})}}this._shellManager.fromJSON(e.edgeGroups)}const f=(n=e.floatingGroups)!==null&&n!==void 0?n:[];for(const v of f){const{data:b,position:w}=v,C=p(b);this.addFloatingGroup(C,{position:w,width:w.width,height:w.height,skipRemoveGroup:!0,inDragMode:!1})}const m=(s=e.popoutGroups)!==null&&s!==void 0?s:[],g=[];m.forEach((v,b)=>{const{data:w,position:C,gridReferenceGroup:I,url:E}=v,D=p(w),G=new Promise(M=>{setTimeout(()=>{this.addPopoutGroup(D,{position:C??void 0,overridePopoutGroup:I?D:void 0,referenceGroup:I?this.getPanel(I):void 0,popoutUrl:E}),M()},b*Vs)});g.push(G)}),this._popoutRestorationPromise=Promise.all(g).then(()=>{});for(const v of this._floatingGroups)v.overlay.setBounds();if(typeof h=="string"){const v=this.getPanel(h);v&&this.doSetGroupAndPanelActive(v)}}catch(c){console.error("dockview: failed to deserialize layout. Reverting changes",c);for(const u of this.groups)for(const p of u.panels)this.removePanel(p,{removeEmptyGroup:!1,skipDispose:!1});for(const u of this.groups)u.dispose(),this._groups.delete(u.id),this._onDidRemoveGroup.fire(u);for(const u of[...this._floatingGroups])u.dispose();throw this.clear(),c}this.updateWatermark(),this.debouncedUpdateAllPositions(),this._onDidLayoutFromJSON.fire()}clear(){const e=Array.from(this._groups.values()).map(i=>i.value),t=!!this.activeGroup;for(const i of e){if([...this._edgeGroups.values()].includes(i)){const n=[...i.panels];for(const s of n)this.removePanel(s,{removeEmptyGroup:!1});continue}this.removeGroup(i,{skipActive:!0})}t&&this.doSetGroupAndPanelActive(void 0),this.gridview.clear()}closeAllGroups(){for(const e of this._groups.entries()){const[t,i]=e;i.value.model.closeAllPanels()}}addPanel(e){var t,i;if(this.panels.find(r=>r.id===e.id))throw new Error(`dockview: panel with id ${e.id} already exists`);let n;if(e.position&&e.floating)throw new Error("dockview: you can only provide one of: position, floating as arguments to .addPanel(...)");const s={width:e.initialWidth,height:e.initialHeight};let l;if(e.position)if(Cs(e.position)){const r=typeof e.position.referencePanel=="string"?this.getGroupPanel(e.position.referencePanel):e.position.referencePanel;if(l=e.position.index,!r)throw new Error(`dockview: referencePanel '${e.position.referencePanel}' does not exist`);n=this.findGroup(r)}else if(Ds(e.position)){if(n=typeof e.position.referenceGroup=="string"?(t=this._groups.get(e.position.referenceGroup))===null||t===void 0?void 0:t.value:e.position.referenceGroup,l=e.position.index,!n)throw new Error(`dockview: referenceGroup '${e.position.referenceGroup}' does not exist`)}else{const r=this.orthogonalize(li(e.position.direction)),d=this.createPanel(e,r);return r.model.openPanel(d,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:l}),e.inactive||this.doSetGroupAndPanelActive(r),r.api.setSize({height:s==null?void 0:s.height,width:s==null?void 0:s.width}),d}else n=this.activeGroup;let a;if(n){const r=vt(((i=e.position)===null||i===void 0?void 0:i.direction)||"within");if(e.floating){const d=this.createGroup();this._onDidAddGroup.fire(d);const h=typeof e.floating=="object"&&e.floating!==null?e.floating:{};this.addFloatingGroup(d,Object.assign(Object.assign({},h),{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),a=this.createPanel(e,d),d.model.openPanel(a,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:l})}else if(n.api.location.type==="floating"||n.api.location.type==="edge"||r==="center")a=this.createPanel(e,n),n.model.openPanel(a,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:l}),n.api.setSize({width:s==null?void 0:s.width,height:s==null?void 0:s.height}),e.inactive||this.doSetGroupAndPanelActive(n);else{const d=Z(n.element),h=be(this.gridview.orientation,d,r),c=this.createGroupAtLocation(h,this.orientationAtLocation(h)===z.VERTICAL?s==null?void 0:s.height:s==null?void 0:s.width);a=this.createPanel(e,c),c.model.openPanel(a,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:l}),e.inactive||this.doSetGroupAndPanelActive(c)}}else if(e.floating){const r=this.createGroup();this._onDidAddGroup.fire(r);const d=typeof e.floating=="object"&&e.floating!==null?e.floating:{};this.addFloatingGroup(r,Object.assign(Object.assign({},d),{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),a=this.createPanel(e,r),r.model.openPanel(a,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:l})}else{const r=this.createGroupAtLocation([0],this.gridview.orientation===z.VERTICAL?s==null?void 0:s.height:s==null?void 0:s.width);a=this.createPanel(e,r),r.model.openPanel(a,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:l}),e.inactive||this.doSetGroupAndPanelActive(r)}return a}removePanel(e,t={removeEmptyGroup:!0}){const i=e.group;if(!i)throw new Error(`dockview: cannot remove panel ${e.id}. it's missing a group.`);i.model.removePanel(e,{skipSetActiveGroup:t.skipSetActiveGroup}),t.skipDispose||(e.group.model.renderContainer.detatch(e),e.dispose()),i.size===0&&t.removeEmptyGroup&&this.removeGroup(i,{skipActive:t.skipSetActiveGroup})}createWatermarkComponent(){return this.options.createWatermarkComponent?this.options.createWatermarkComponent():new ks}updateWatermark(){var e,t;if(this.groups.filter(i=>i.api.location.type==="grid"&&i.api.isVisible).length===0){if(!this._watermark){this._watermark=this.createWatermarkComponent(),this._watermark.init({containerApi:new _t(this)});const i=document.createElement("div");i.className="dv-watermark-container",zn(i,"watermark-component"),i.appendChild(this._watermark.element),this.gridview.element.appendChild(i)}}else this._watermark&&(this._watermark.element.parentElement.remove(),(t=(e=this._watermark).dispose)===null||t===void 0||t.call(e),this._watermark=null)}addGroup(e){var t;if(e){let i;if(ys(e)){const d=typeof e.referencePanel=="string"?this.panels.find(h=>h.id===e.referencePanel):e.referencePanel;if(!d)throw new Error(`dockview: reference panel ${e.referencePanel} does not exist`);if(i=this.findGroup(d),!i)throw new Error(`dockview: reference group for reference panel ${e.referencePanel} does not exist`)}else if(xs(e)){if(i=typeof e.referenceGroup=="string"?(t=this._groups.get(e.referenceGroup))===null||t===void 0?void 0:t.value:e.referenceGroup,!i)throw new Error(`dockview: reference group ${e.referenceGroup} does not exist`)}else{const d=this.orthogonalize(li(e.direction),e);return e.skipSetActive||this.doSetGroupAndPanelActive(d),d}const n=vt(e.direction||"within"),s=Z(i.element),l=be(this.gridview.orientation,s,n),a=this.createGroup(e),r=this.getLocationOrientation(l)===z.VERTICAL?e.initialHeight:e.initialWidth;return this.doAddGroup(a,l,r),e.skipSetActive||this.doSetGroupAndPanelActive(a),a}else{const i=this.createGroup(e);return this.doAddGroup(i),this.doSetGroupAndPanelActive(i),i}}getLocationOrientation(e){return e.length%2==0&&this.gridview.orientation===z.HORIZONTAL?z.HORIZONTAL:z.VERTICAL}removeGroup(e,t){this.doRemoveGroup(e,t)}doRemoveGroup(e,t){var i;if([...this._edgeGroups.values()].includes(e))return e;const n=[...e.panels];if(!(t!=null&&t.skipDispose))for(const a of n)this.removePanel(a,{removeEmptyGroup:!1,skipDispose:(i=t==null?void 0:t.skipDispose)!==null&&i!==void 0?i:!1});const s=this.activePanel;if(e.api.location.type==="floating"){const a=this._floatingGroups.find(r=>r.group===e);if(a){if(t!=null&&t.skipDispose||(a.group.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)),St(this._floatingGroups,a),a.dispose(),!(t!=null&&t.skipActive)&&this._activeGroup===e){const r=Array.from(this._groups.values());this.doSetGroupAndPanelActive(r.length>0?r[0].value:void 0)}return a.group}throw new Error("dockview: failed to find floating group")}if(e.api.location.type==="popout"){const a=this._popoutGroups.find(r=>r.popoutGroup===e);if(a){if(!(t!=null&&t.skipDispose)){if(!(t!=null&&t.skipPopoutAssociated)){const d=a.referenceGroup?this.getPanel(a.referenceGroup):void 0;d&&d.panels.length===0&&this.removeGroup(d)}a.popoutGroup.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)}St(this._popoutGroups,a);const r=a.disposable.dispose();if(!(t!=null&&t.skipPopoutReturn)&&r&&(this.doAddGroup(r,[0]),this.doSetGroupAndPanelActive(r)),!(t!=null&&t.skipActive)&&this._activeGroup===e){const d=Array.from(this._groups.values());this.doSetGroupAndPanelActive(d.length>0?d[0].value:void 0)}return this.updateWatermark(),a.popoutGroup}throw new Error("dockview: failed to find popout group")}const l=super.doRemoveGroup(e,t);return t!=null&&t.skipActive||this.activePanel!==s&&this._onDidActivePanelChange.fire(this.activePanel),l}debouncedUpdateAllPositions(){this._updatePositionsFrameId!==void 0&&cancelAnimationFrame(this._updatePositionsFrameId),this._updatePositionsFrameId=requestAnimationFrame(()=>{this._updatePositionsFrameId=void 0,this.overlayRenderContainer.updateAllPositions()})}movingLock(e){const t=this._moving;try{return this._moving=!0,e()}finally{this._moving=t}}moveGroupOrPanel(e){var t;const i=e.to.group,n=e.from.groupId,s=e.from.panelId,l=e.to.position,a=e.to.index,r=n?(t=this._groups.get(n))===null||t===void 0?void 0:t.value:void 0;if(!r)throw new Error(`dockview: Failed to find group id ${n}`);if(s===void 0){e.from.tabGroupId?this.moveTabGroupToGroup({sourceGroup:r,tabGroupId:e.from.tabGroupId,destinationGroup:i,destinationTarget:l,destinationIndex:a,skipSetActive:e.skipSetActive,keepEmptyGroups:e.keepEmptyGroups}):this.moveGroup({from:{group:r},to:{group:i,position:l},skipSetActive:e.skipSetActive});return}if(!l||l==="center"){const d=this.movingLock(()=>r.model.removePanel(s,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!d)throw new Error(`dockview: No panel with id ${s}`);!e.keepEmptyGroups&&r.model.size===0&&this.doRemoveGroup(r,{skipActive:!0});const h=i.model.size===0;this.movingLock(()=>{var c;return i.model.openPanel(d,{index:a,skipSetActive:((c=e.skipSetActive)!==null&&c!==void 0?c:!1)&&!h,skipSetGroupActive:!0})}),e.skipSetActive||this.doSetGroupAndPanelActive(i),this._onDidMovePanel.fire({panel:d,from:r})}else{const d=Z(i.element),h=be(this.gridview.orientation,d,l);if(r.size<2){const[c,u]=ze(h);if(r.api.location.type==="grid"){const g=Z(r.element),[v,b]=ze(g);if(Ni(v,c)){this.gridview.moveView(v,b,u),this._onDidMovePanel.fire({panel:this.getGroupPanel(s),from:r});return}}if(r.api.location.type==="popout"){const g=this._popoutGroups.find(w=>w.popoutGroup===r),v=this.movingLock(()=>g.popoutGroup.model.removePanel(g.popoutGroup.panels[0],{skipSetActive:!0,skipSetActiveGroup:!0}));this.doRemoveGroup(r,{skipActive:!0});const b=this.createGroupAtLocation(h);this.movingLock(()=>b.model.openPanel(v,{skipSetActive:!0})),this.doSetGroupAndPanelActive(b),this._onDidMovePanel.fire({panel:this.getGroupPanel(s),from:r});return}if(r.api.location.type==="edge"){const g=this.movingLock(()=>r.model.removePanel(s,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!g)throw new Error(`dockview: No panel with id ${s}`);const v=this.createGroupAtLocation(h);this.movingLock(()=>v.model.openPanel(g,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(v),this._onDidMovePanel.fire({panel:g,from:r});return}const p=this.movingLock(()=>this.doRemoveGroup(r,{skipActive:!0,skipDispose:!0})),f=Z(i.element),m=be(this.gridview.orientation,f,l);this.movingLock(()=>this.doAddGroup(p,m)),this.doSetGroupAndPanelActive(p),this._onDidMovePanel.fire({panel:this.getGroupPanel(s),from:r})}else{const c=this.movingLock(()=>r.model.removePanel(s,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!c)throw new Error(`dockview: No panel with id ${s}`);const u=be(this.gridview.orientation,d,l),p=this.createGroupAtLocation(u);this.movingLock(()=>p.model.openPanel(c,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(p),this._onDidMovePanel.fire({panel:c,from:r})}}}moveTabGroupToGroup(e){const{sourceGroup:t,tabGroupId:i,destinationGroup:n,destinationTarget:s,destinationIndex:l}=e,a=t.model.getTabGroups().find(v=>v.id===i);if(!a||a.panelIds.length===0)return;const r=a.label,d=a.color,h=a.collapsed,c=a.componentParams,u=[...a.panelIds],p=s&&s!=="center"?Z(n.element):void 0,f=this.movingLock(()=>u.map(v=>t.model.removePanel(v,{skipSetActive:!1,skipSetActiveGroup:!0})).filter(v=>v!==void 0));if(f.length===0)return;const m=v=>{this.movingLock(()=>{for(const w of f)v.model.openPanel(w,{index:l,skipSetActive:!0,skipSetGroupActive:!0})});const b=v.model.createTabGroup({label:r,color:d,collapsed:h,componentParams:c});for(const w of f)v.model.addPanelToTabGroup(b.id,w.id);e.skipSetActive||this.doSetGroupAndPanelActive(v);for(const w of f)this._onDidMovePanel.fire({panel:w,from:t})};let g;if(!s||s==="center"||!p)g=n;else{const v=be(this.gridview.orientation,p,s);g=this.createGroupAtLocation(v)}!e.keepEmptyGroups&&t.model.size===0&&t!==g&&this.doRemoveGroup(t,{skipActive:!0}),m(g)}moveGroup(e){const t=e.from.group,i=e.to.group,n=e.to.position;let s=t;if(n==="center"){const l=t.activePanel,a=t.model.getTabGroups().map(d=>({label:d.label,color:d.color,collapsed:d.collapsed,componentParams:d.componentParams,panelIds:[...d.panelIds]})),r=this.movingLock(()=>[...t.panels].map(d=>t.model.removePanel(d.id,{skipSetActive:!0})));(t==null?void 0:t.model.size)===0&&this.doRemoveGroup(t,{skipActive:!0}),this.movingLock(()=>{for(const d of r)i.model.openPanel(d,{skipSetActive:d!==l,skipSetGroupActive:!0})});for(const d of a){const h=i.model.createTabGroup({label:d.label,color:d.color,collapsed:d.collapsed,componentParams:d.componentParams});for(const c of d.panelIds)i.model.addPanelToTabGroup(h.id,c)}e.skipSetActive!==!0?this.doSetGroupAndPanelActive(i):this.activePanel||this.doSetGroupAndPanelActive(i)}else{if(t.api.location.type==="edge"){const l=t.activePanel,a=t.model.getTabGroups().map(d=>({label:d.label,color:d.color,collapsed:d.collapsed,componentParams:d.componentParams,panelIds:[...d.panelIds]})),r=this.movingLock(()=>[...t.panels].map(d=>t.model.removePanel(d.id,{skipSetActive:!0})));s=this.createGroup(),this.movingLock(()=>{for(const d of r)s.model.openPanel(d,{skipSetActive:d!==l,skipSetGroupActive:!0})});for(const d of a){const h=s.model.createTabGroup({label:d.label,color:d.color,collapsed:d.collapsed,componentParams:d.componentParams});for(const c of d.panelIds)s.model.addPanelToTabGroup(h.id,c)}}else switch(t.api.location.type){case"grid":this.gridview.removeView(Z(t.element));break;case"floating":{const l=this._floatingGroups.find(a=>a.group===t);if(!l)throw new Error("dockview: failed to find floating group");l.dispose();break}case"popout":{const l=this._popoutGroups.find(r=>r.popoutGroup===t);if(!l)throw new Error("dockview: failed to find popout group");const a=this._popoutGroups.indexOf(l);if(a>=0&&this._popoutGroups.splice(a,1),l.referenceGroup){const r=this.getPanel(l.referenceGroup);r&&!r.api.isVisible&&this.doRemoveGroup(r,{skipActive:!0})}l.window.dispose(),i.api.location.type==="grid"?(t.model.renderContainer=this.overlayRenderContainer,t.model.dropTargetContainer=this.rootDropTargetContainer,t.model.location={type:"grid"}):i.api.location.type==="floating"&&(t.model.renderContainer=this.overlayRenderContainer,t.model.dropTargetContainer=this.rootDropTargetContainer,t.model.location={type:"floating"});break}}if(i.api.location.type==="grid"){const l=Z(i.element),a=be(this.gridview.orientation,l,n);let r;switch(this.gridview.orientation){case z.VERTICAL:r=l.length%2==0?t.api.width:t.api.height;break;case z.HORIZONTAL:r=l.length%2==0?t.api.height:t.api.width;break}this.gridview.addView(s,r,a)}else if(i.api.location.type==="floating"){const l=this._floatingGroups.find(a=>a.group===i);if(l){const a=l.overlay.toJSON();let r,d;"left"in a?r=a.left+50:"right"in a?r=Math.max(0,a.right-a.width-50):r=50,"top"in a?d=a.top+50:"bottom"in a?d=Math.max(0,a.bottom-a.height-50):d=50,this.addFloatingGroup(s,{height:a.height,width:a.width,position:{left:r,top:d}})}}}if(s.panels.forEach(l=>{this._onDidMovePanel.fire({panel:l,from:t})}),this.debouncedUpdateAllPositions(),e.skipSetActive===!1){const l=i??t;this.doSetGroupAndPanelActive(l)}else s!==t&&e.skipSetActive!==!0&&this.doSetGroupAndPanelActive(s)}doSetGroupActive(e){super.doSetGroupActive(e);const t=this.activePanel;!this._moving&&t!==this._onDidActivePanelChange.value&&this._onDidActivePanelChange.fire(t)}doSetGroupAndPanelActive(e){super.doSetGroupActive(e);const t=this.activePanel;e&&this.hasMaximizedGroup()&&!this.isMaximizedGroup(e)&&this.exitMaximizedGroup(),!this._moving&&t!==this._onDidActivePanelChange.value&&this._onDidActivePanelChange.fire(t)}getNextGroupId(){let e=this.nextGroupId.next();for(;this._groups.has(e);)e=this.nextGroupId.next();return e}createGroup(e){e||(e={});let t=e==null?void 0:e.id;if(t&&this._groups.has(e.id)&&(console.warn(`dockview: Duplicate group id ${e==null?void 0:e.id}. reassigning group id to avoid errors`),t=void 0),!t)for(t=this.nextGroupId.next();this._groups.has(t);)t=this.nextGroupId.next();const i=new dt(this,t,e);if(i.init({params:{},accessor:this}),!this._groups.has(i.id)){const n=new R(i.model.onTabDragStart(s=>{this._onWillDragPanel.fire(s)}),i.model.onGroupDragStart(s=>{this._onWillDragGroup.fire(s)}),i.model.onMove(s=>{const{groupId:l,itemId:a,target:r,index:d,tabGroupId:h}=s;this.moveGroupOrPanel({from:{groupId:l,panelId:a,tabGroupId:h},to:{group:i,position:r,index:d}})}),i.model.onDidDrop(s=>{this._onDidDrop.fire(s)}),i.model.onWillDrop(s=>{this._onWillDrop.fire(s)}),i.model.onWillShowOverlay(s=>{if(this.options.disableDnd){s.preventDefault();return}this._onWillShowOverlay.fire(s)}),i.model.onUnhandledDragOverEvent(s=>{this._onUnhandledDragOverEvent.fire(s)}),i.model.onDidAddPanel(s=>{this._moving||this._onDidAddPanel.fire(s.panel)}),i.model.onDidRemovePanel(s=>{this._moving||this._onDidRemovePanel.fire(s.panel)}),i.model.onDidActivePanelChange(s=>{this._moving||s.panel===this.activePanel&&this._onDidActivePanelChange.value!==s.panel&&this._onDidActivePanelChange.fire(s.panel)}),i.model.onDidCreateTabGroup(s=>{this._onDidCreateTabGroup.fire(s)}),i.model.onDidDestroyTabGroup(s=>{this._onDidDestroyTabGroup.fire(s)}),i.model.onDidAddPanelToTabGroup(s=>{this._onDidAddPanelToTabGroup.fire(s)}),i.model.onDidRemovePanelFromTabGroup(s=>{this._onDidRemovePanelFromTabGroup.fire(s)}),i.model.onDidTabGroupChange(s=>{this._onDidTabGroupChange.fire(s)}),i.model.onDidTabGroupCollapsedChange(s=>{this._onDidTabGroupCollapsedChange.fire(s)}),He.any(i.model.onDidPanelTitleChange,i.model.onDidPanelParametersChange)(()=>{this._bufferOnDidLayoutChange.fire()}));this._groups.set(i.id,{value:i,disposable:n})}return i.initialize(),i}createPanel(e,t){var i,n,s;const l=e.component,a=(i=e.tabComponent)!==null&&i!==void 0?i:this.options.defaultTabComponent,r=new nn(this,e.id,l,a),d=new Ke(e.id,l,a,this,this._api,t,r,{renderer:e.renderer,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight});return d.init({title:(n=e.title)!==null&&n!==void 0?n:e.id,params:(s=e==null?void 0:e.params)!==null&&s!==void 0?s:{}}),d}createGroupAtLocation(e,t,i){const n=this.createGroup(i);return this.doAddGroup(n,e,t),n}findGroup(e){var t;return(t=Array.from(this._groups.values()).find(i=>i.value.model.containsPanel(e)))===null||t===void 0?void 0:t.value}orientationAtLocation(e){const t=this.gridview.orientation;return e.length%2==1?t:Ie(t)}updateDropTargetModel(e){"dndEdges"in e&&(this._rootDropTarget.disabled=typeof e.dndEdges=="boolean"&&e.dndEdges===!1,typeof e.dndEdges=="object"&&e.dndEdges!==null?this._rootDropTarget.setOverlayModel(e.dndEdges):this._rootDropTarget.setOverlayModel(gi)),"rootOverlayModel"in e&&this.updateDropTargetModel({dndEdges:e.dndEdges})}updateTheme(){var e,t,i,n,s,l,a,r,d;const h=(e=this._options.theme)!==null&&e!==void 0?e:Es;switch((t=this._shellThemeClassnames)===null||t===void 0||t.setClassNames(h.className),this.gridview.margin=(i=h.gap)!==null&&i!==void 0?i:0,(n=this._shellManager)===null||n===void 0||n.updateTheme((s=h.gap)!==null&&s!==void 0?s:0,(l=h.edgeGroupCollapsedSize)!==null&&l!==void 0?l:35),h.dndOverlayBorder!==void 0?(this.element.style.setProperty("--dv-drag-over-border",h.dndOverlayBorder),(a=this._shellManager)===null||a===void 0||a.element.style.setProperty("--dv-drag-over-border",h.dndOverlayBorder)):(this.element.style.removeProperty("--dv-drag-over-border"),(r=this._shellManager)===null||r===void 0||r.element.style.removeProperty("--dv-drag-over-border")),h.dndOverlayMounting){case"absolute":this.rootDropTargetContainer.disabled=!1;break;case"relative":default:this.rootDropTargetContainer.disabled=!0;break}const c=((d=h.tabGroupIndicator)!==null&&d!==void 0?d:"wrap")==="none";A(this.element,"dv-tab-group-indicator-none",c),this._shellManager&&A(this._shellManager.element,"dv-tab-group-indicator-none",c);for(const u of this.groups)u.model.updateTabGroups()}}class to extends Wi{get orientation(){return this.gridview.orientation}set orientation(e){this.gridview.orientation=e}get options(){return this._options}get deserializer(){return this._deserializer}set deserializer(e){this._deserializer=e}constructor(e,t){var i;super(e,{proportionalLayout:(i=t.proportionalLayout)!==null&&i!==void 0?i:!0,orientation:t.orientation,styles:t.hideBorders?{separatorBorder:"transparent"}:void 0,disableAutoResizing:t.disableAutoResizing,className:t.className}),this._onDidLayoutfromJSON=new _,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidRemoveGroup=new _,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new _,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidActiveGroupChange=new _,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._options=t,this.addDisposables(this._onDidAddGroup,this._onDidRemoveGroup,this._onDidActiveGroupChange,this.onDidAdd(n=>{this._onDidAddGroup.fire(n)}),this.onDidRemove(n=>{this._onDidRemoveGroup.fire(n)}),this.onDidActiveChange(n=>{this._onDidActiveGroupChange.fire(n)}))}updateOptions(e){super.updateOptions(e);const t=typeof e.orientation=="string"&&this.gridview.orientation!==e.orientation;this._options=Object.assign(Object.assign({},this.options),e),t&&(this.gridview.orientation=e.orientation),this.layout(this.gridview.width,this.gridview.height,!0)}removePanel(e){this.removeGroup(e)}toJSON(){var e;return{grid:this.gridview.serialize(),activePanel:(e=this.activeGroup)===null||e===void 0?void 0:e.id}}setVisible(e,t){this.gridview.setViewVisible(Z(e.element),t)}setActive(e){this._groups.forEach((t,i)=>{t.value.setActive(e===t.value)})}focus(){var e;(e=this.activeGroup)===null||e===void 0||e.focus()}fromJSON(e){this.clear();const{grid:t,activePanel:i}=e;try{const n=[],s=this.width,l=this.height;if(this.gridview.deserialize(t,{fromJSON:a=>{const{data:r}=a,d=this.options.createComponent({id:r.id,name:r.component});return n.push(()=>d.init({params:r.params,minimumWidth:r.minimumWidth,maximumWidth:r.maximumWidth,minimumHeight:r.minimumHeight,maximumHeight:r.maximumHeight,priority:r.priority,snap:!!r.snap,accessor:this,isVisible:a.visible})),this._onDidAddGroup.fire(d),this.registerPanel(d),d}}),this.layout(s,l,!0),n.forEach(a=>a()),typeof i=="string"){const a=this.getPanel(i);a&&this.doSetGroupActive(a)}}catch(n){for(const s of this.groups)s.dispose(),this._groups.delete(s.id),this._onDidRemoveGroup.fire(s);throw this.clear(),n}this._onDidLayoutfromJSON.fire()}clear(){const e=this.activeGroup,t=Array.from(this._groups.values());for(const i of t)i.disposable.dispose(),this.doRemoveGroup(i.value,{skipActive:!0});e&&this.doSetGroupActive(void 0),this.gridview.clear()}movePanel(e,t){var i;let n;const s=this.gridview.remove(e),l=(i=this._groups.get(t.reference))===null||i===void 0?void 0:i.value;if(!l)throw new Error(`reference group ${t.reference} does not exist`);const a=vt(t.direction);if(a==="center")throw new Error(`${a} not supported as an option`);{const r=Z(l.element);n=be(this.gridview.orientation,r,a)}this.doAddGroup(s,n,t.size)}addPanel(e){var t,i,n,s;let l=(t=e.location)!==null&&t!==void 0?t:[0];if(!((i=e.position)===null||i===void 0)&&i.referencePanel){const r=(n=this._groups.get(e.position.referencePanel))===null||n===void 0?void 0:n.value;if(!r)throw new Error(`reference group ${e.position.referencePanel} does not exist`);const d=vt(e.position.direction);if(d==="center")throw new Error(`${d} not supported as an option`);{const h=Z(r.element);l=be(this.gridview.orientation,h,d)}}const a=this.options.createComponent({id:e.id,name:e.component});return a.init({params:(s=e.params)!==null&&s!==void 0?s:{},minimumWidth:e.minimumWidth,maximumWidth:e.maximumWidth,minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight,priority:e.priority,snap:!!e.snap,accessor:this,isVisible:!0}),this.doAddGroup(a,l,e.size),this.registerPanel(a),this.doSetGroupActive(a),a}registerPanel(e){const t=new R(e.api.onDidFocusChange(i=>{i.isFocused&&this._groups.forEach(n=>{const s=n.value;s!==e?s.setActive(!1):s.setActive(!0)})}));this._groups.set(e.id,{value:e,disposable:t})}moveGroup(e,t,i){const n=this.getPanel(t);if(!n)throw new Error("invalid operation");const s=Z(e.element),l=be(this.gridview.orientation,s,i),[a,r]=ze(l),d=Z(n.element),[h,c]=ze(d);if(Ni(h,a)){this.gridview.moveView(h,c,r);return}const u=this.doRemoveGroup(n,{skipActive:!0,skipDispose:!0}),p=Z(e.element),f=be(this.gridview.orientation,p,i);this.doAddGroup(u,f)}removeGroup(e){super.removeGroup(e)}dispose(){super.dispose(),this._onDidLayoutfromJSON.dispose()}}class io extends jt{get panels(){return this.splitview.getViews()}get options(){return this._options}get length(){return this._panels.size}get orientation(){return this.splitview.orientation}get splitview(){return this._splitview}set splitview(e){this._splitview&&this._splitview.dispose(),this._splitview=e,this._splitviewChangeDisposable.value=new R(this._splitview.onDidSashEnd(()=>{this._onDidLayoutChange.fire(void 0)}),this._splitview.onDidAddView(t=>this._onDidAddView.fire(t)),this._splitview.onDidRemoveView(t=>this._onDidRemoveView.fire(t)))}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get height(){return this.splitview.orientation===z.HORIZONTAL?this.splitview.orthogonalSize:this.splitview.size}get width(){return this.splitview.orientation===z.HORIZONTAL?this.splitview.size:this.splitview.orthogonalSize}constructor(e,t){var i;super(document.createElement("div"),t.disableAutoResizing),this._splitviewChangeDisposable=new le,this._panels=new Map,this._onDidLayoutfromJSON=new _,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidAddView=new _,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new _,this.onDidRemoveView=this._onDidRemoveView.event,this._onDidLayoutChange=new _,this.onDidLayoutChange=this._onDidLayoutChange.event,this.element.style.height="100%",this.element.style.width="100%",this._classNames=new bt(this.element),this._classNames.setClassNames((i=t.className)!==null&&i!==void 0?i:""),e.appendChild(this.element),this._options=t,this.splitview=new Fe(this.element,t),this.addDisposables(this._onDidAddView,this._onDidLayoutfromJSON,this._onDidRemoveView,this._onDidLayoutChange)}updateOptions(e){var t,i;"className"in e&&this._classNames.setClassNames((t=e.className)!==null&&t!==void 0?t:""),"disableResizing"in e&&(this.disableResizing=(i=e.disableAutoResizing)!==null&&i!==void 0?i:!1),typeof e.orientation=="string"&&(this.splitview.orientation=e.orientation),this._options=Object.assign(Object.assign({},this.options),e),this.splitview.layout(this.splitview.size,this.splitview.orthogonalSize)}focus(){var e;(e=this._activePanel)===null||e===void 0||e.focus()}movePanel(e,t){this.splitview.moveView(e,t)}setVisible(e,t){const i=this.panels.indexOf(e);this.splitview.setViewVisible(i,t)}setActive(e,t){this._activePanel=e,this.panels.filter(i=>i!==e).forEach(i=>{i.api._onDidActiveChange.fire({isActive:!1}),t||i.focus()}),e.api._onDidActiveChange.fire({isActive:!0}),t||e.focus()}removePanel(e,t){const i=this._panels.get(e.id);if(!i)throw new Error(`unknown splitview panel ${e.id}`);i.dispose(),this._panels.delete(e.id);const n=this.panels.findIndex(a=>a===e);this.splitview.removeView(n,t).dispose();const l=this.panels;l.length>0&&this.setActive(l[l.length-1])}getPanel(e){return this.panels.find(t=>t.id===e)}addPanel(e){var t;if(this._panels.has(e.id))throw new Error(`panel ${e.id} already exists`);const i=this.options.createComponent({id:e.id,name:e.component});i.orientation=this.splitview.orientation,i.init({params:(t=e.params)!==null&&t!==void 0?t:{},minimumSize:e.minimumSize,maximumSize:e.maximumSize,snap:e.snap,priority:e.priority,accessor:this});const n=typeof e.size=="number"?e.size:ve.Distribute,s=typeof e.index=="number"?e.index:void 0;return this.splitview.addView(i,n,s),this.doAddView(i),this.setActive(i),i}layout(e,t){const[i,n]=this.splitview.orientation===z.HORIZONTAL?[e,t]:[t,e];this.splitview.layout(i,n)}doAddView(e){const t=e.api.onDidFocusChange(i=>{i.isFocused&&this.setActive(e,!0)});this._panels.set(e.id,t)}toJSON(){var e;return{views:this.splitview.getViews().map((i,n)=>({size:this.splitview.getViewSize(n),data:i.toJSON(),snap:!!i.snap,priority:i.priority})),activeView:(e=this._activePanel)===null||e===void 0?void 0:e.id,size:this.splitview.size,orientation:this.splitview.orientation}}fromJSON(e){this.clear();const{views:t,orientation:i,size:n,activeView:s}=e,l=[],a=this.width,r=this.height;if(this.splitview=new Fe(this.element,{orientation:i,proportionalLayout:this.options.proportionalLayout,descriptor:{size:n,views:t.map(d=>{const h=d.data;if(this._panels.has(h.id))throw new Error(`panel ${h.id} already exists`);const c=this.options.createComponent({id:h.id,name:h.component});return l.push(()=>{var u;c.init({params:(u=h.params)!==null&&u!==void 0?u:{},minimumSize:h.minimumSize,maximumSize:h.maximumSize,snap:d.snap,priority:d.priority,accessor:this})}),c.orientation=i,this.doAddView(c),setTimeout(()=>{this._onDidAddView.fire(c)},0),{size:d.size,view:c}})}}),this.layout(a,r),l.forEach(d=>d()),typeof s=="string"){const d=this.getPanel(s);d&&this.setActive(d)}this._onDidLayoutfromJSON.fire()}clear(){for(const e of this._panels.values())e.dispose();for(this._panels.clear();this.splitview.length>0;)this.splitview.removeView(0,ve.Distribute,!0).dispose()}dispose(){for(const t of this._panels.values())t.dispose();this._panels.clear();const e=this.splitview.getViews();this._splitviewChangeDisposable.dispose(),this.splitview.dispose();for(const t of e)t.dispose();this.element.remove(),super.dispose()}}class vi extends R{get element(){return this._element}constructor(){super(),this._expandedIcon=_s(),this._collapsedIcon=qi(),this.disposable=new le,this.apiRef={api:null},this._element=document.createElement("div"),this.element.className="dv-default-header",this._content=document.createElement("span"),this._expander=document.createElement("div"),this._expander.className="dv-pane-header-icon",this.element.appendChild(this._expander),this.element.appendChild(this._content),this.addDisposables(k(this._element,"click",()=>{var e;(e=this.apiRef.api)===null||e===void 0||e.setExpanded(!this.apiRef.api.isExpanded)}))}init(e){this.apiRef.api=e.api,this._content.textContent=e.title,this.updateIcon(),this.disposable.value=e.api.onDidExpansionChange(()=>{this.updateIcon()})}updateIcon(){var e;const t=!!(!((e=this.apiRef.api)===null||e===void 0)&&e.isExpanded);A(this._expander,"collapsed",!t),t?(this._expander.contains(this._collapsedIcon)&&this._collapsedIcon.remove(),this._expander.contains(this._expandedIcon)||this._expander.appendChild(this._expandedIcon)):(this._expander.contains(this._expandedIcon)&&this._expandedIcon.remove(),this._expander.contains(this._collapsedIcon)||this._expander.appendChild(this._collapsedIcon))}update(e){}dispose(){this.disposable.dispose(),super.dispose()}}const no=Ut(),_i=22,bi=0,wi=Number.MAX_SAFE_INTEGER;class Ci extends rs{constructor(e){super({accessor:e.accessor,id:e.id,component:e.component,headerComponent:e.headerComponent,orientation:e.orientation,isExpanded:e.isExpanded,disableDnd:e.disableDnd,headerSize:e.headerSize,minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize}),this.options=e}getBodyComponent(){return this.options.body}getHeaderComponent(){return this.options.header}}class so extends jt{get id(){return this._id}get panels(){return this.paneview.getPanes()}set paneview(e){this._paneview=e,this._disposable.value=new R(this._paneview.onDidChange(()=>{this._onDidLayoutChange.fire(void 0)}),this._paneview.onDidAddView(t=>this._onDidAddView.fire(t)),this._paneview.onDidRemoveView(t=>this._onDidRemoveView.fire(t)))}get paneview(){return this._paneview}get minimumSize(){return this.paneview.minimumSize}get maximumSize(){return this.paneview.maximumSize}get height(){return this.paneview.orientation===z.HORIZONTAL?this.paneview.orthogonalSize:this.paneview.size}get width(){return this.paneview.orientation===z.HORIZONTAL?this.paneview.size:this.paneview.orthogonalSize}get options(){return this._options}constructor(e,t){var i;super(document.createElement("div"),t.disableAutoResizing),this._id=no.next(),this._disposable=new le,this._viewDisposables=new Map,this._onDidLayoutfromJSON=new _,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidLayoutChange=new _,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidDrop=new _,this.onDidDrop=this._onDidDrop.event,this._onDidAddView=new _,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new _,this.onDidRemoveView=this._onDidRemoveView.event,this._onUnhandledDragOverEvent=new _,this.onUnhandledDragOverEvent=this._onUnhandledDragOverEvent.event,this.element.style.height="100%",this.element.style.width="100%",this.addDisposables(this._onDidLayoutChange,this._onDidLayoutfromJSON,this._onDidDrop,this._onDidAddView,this._onDidRemoveView,this._onUnhandledDragOverEvent),this._classNames=new bt(this.element),this._classNames.setClassNames((i=t.className)!==null&&i!==void 0?i:""),e.appendChild(this.element),this._options=t,this.paneview=new ai(this.element,{orientation:z.VERTICAL}),this.addDisposables(this._disposable)}setVisible(e,t){const i=this.panels.indexOf(e);this.paneview.setViewVisible(i,t)}focus(){}updateOptions(e){var t,i;"className"in e&&this._classNames.setClassNames((t=e.className)!==null&&t!==void 0?t:""),"disableResizing"in e&&(this.disableResizing=(i=e.disableAutoResizing)!==null&&i!==void 0?i:!1),this._options=Object.assign(Object.assign({},this.options),e)}addPanel(e){var t,i;const n=this.options.createComponent({id:e.id,name:e.component});let s;e.headerComponent&&this.options.createHeaderComponent&&(s=this.options.createHeaderComponent({id:e.id,name:e.headerComponent})),s||(s=new vi);const l=new Ci({id:e.id,component:e.component,headerComponent:e.headerComponent,header:s,body:n,orientation:z.VERTICAL,isExpanded:!!e.isExpanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:(t=e.headerSize)!==null&&t!==void 0?t:_i,minimumBodySize:bi,maximumBodySize:wi});this.doAddPanel(l);const a=typeof e.size=="number"?e.size:ve.Distribute,r=typeof e.index=="number"?e.index:void 0;return l.init({params:(i=e.params)!==null&&i!==void 0?i:{},minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize,isExpanded:e.isExpanded,title:e.title,containerApi:new et(this),accessor:this}),this.paneview.addPane(l,a,r),l.orientation=this.paneview.orientation,l}removePanel(e){const i=this.panels.findIndex(n=>n===e);this.paneview.removePane(i),this.doRemovePanel(e)}movePanel(e,t){this.paneview.moveView(e,t)}getPanel(e){return this.panels.find(t=>t.id===e)}layout(e,t){const[i,n]=this.paneview.orientation===z.HORIZONTAL?[e,t]:[t,e];this.paneview.layout(i,n)}toJSON(){const e=n=>n===Number.MAX_SAFE_INTEGER||n===Number.POSITIVE_INFINITY?void 0:n,t=n=>n<=0?void 0:n;return{views:this.paneview.getPanes().map((n,s)=>({size:this.paneview.getViewSize(s),data:n.toJSON(),minimumSize:t(n.minimumBodySize),maximumSize:e(n.maximumBodySize),headerSize:n.headerSize,expanded:n.isExpanded()})),size:this.paneview.size}}fromJSON(e){this.clear();const{views:t,size:i}=e,n=[],s=this.width,l=this.height;this.paneview=new ai(this.element,{orientation:z.VERTICAL,descriptor:{size:i,views:t.map(a=>{var r,d,h;const c=a.data,u=this.options.createComponent({id:c.id,name:c.component});let p;c.headerComponent&&this.options.createHeaderComponent&&(p=this.options.createHeaderComponent({id:c.id,name:c.headerComponent})),p||(p=new vi);const f=new Ci({id:c.id,component:c.component,headerComponent:c.headerComponent,header:p,body:u,orientation:z.VERTICAL,isExpanded:!!a.expanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:(r=a.headerSize)!==null&&r!==void 0?r:_i,minimumBodySize:(d=a.minimumSize)!==null&&d!==void 0?d:bi,maximumBodySize:(h=a.maximumSize)!==null&&h!==void 0?h:wi});return this.doAddPanel(f),n.push(()=>{var m;f.init({params:(m=c.params)!==null&&m!==void 0?m:{},minimumBodySize:a.minimumSize,maximumBodySize:a.maximumSize,title:c.title,isExpanded:!!a.expanded,containerApi:new et(this),accessor:this}),f.orientation=this.paneview.orientation}),setTimeout(()=>{this._onDidAddView.fire(f)},0),{size:a.size,view:f}})}}),this.layout(s,l),n.forEach(a=>a()),this._onDidLayoutfromJSON.fire()}clear(){for(const[e,t]of this._viewDisposables.entries())t.dispose();this._viewDisposables.clear(),this.paneview.dispose()}doAddPanel(e){const t=new R(e.onDidDrop(i=>{this._onDidDrop.fire(i)}),e.onUnhandledDragOverEvent(i=>{this._onUnhandledDragOverEvent.fire(i)}));this._viewDisposables.set(e.id,t)}doRemovePanel(e){const t=this._viewDisposables.get(e.id);t&&(t.dispose(),this._viewDisposables.delete(e.id))}dispose(){super.dispose();for(const[e,t]of this._viewDisposables.entries())t.dispose();this._viewDisposables.clear(),this.element.remove(),this.paneview.dispose()}}class oo extends Jt{get priority(){return this._priority}set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){const e=typeof this._minimumSize=="function"?this._minimumSize():this._minimumSize;return e!==this._evaluatedMinimumSize&&(this._evaluatedMinimumSize=e,this.updateConstraints()),e}get maximumSize(){const e=typeof this._maximumSize=="function"?this._maximumSize():this._maximumSize;return e!==this._evaluatedMaximumSize&&(this._evaluatedMaximumSize=e,this.updateConstraints()),e}get snap(){return this._snap}constructor(e,t){super(e,t,new ji(e,t)),this._evaluatedMinimumSize=0,this._evaluatedMaximumSize=Number.POSITIVE_INFINITY,this._minimumSize=0,this._maximumSize=Number.POSITIVE_INFINITY,this._snap=!1,this._onDidChange=new _,this.onDidChange=this._onDidChange.event,this.api.initialize(this),this.addDisposables(this._onDidChange,this.api.onWillVisibilityChange(i=>{const{isVisible:n}=i,{accessor:s}=this._params;s.setVisible(this,n)}),this.api.onActiveChange(()=>{const{accessor:i}=this._params;i.setActive(this)}),this.api.onDidConstraintsChangeInternal(i=>{(typeof i.minimumSize=="number"||typeof i.minimumSize=="function")&&(this._minimumSize=i.minimumSize),(typeof i.maximumSize=="number"||typeof i.maximumSize=="function")&&(this._maximumSize=i.maximumSize),this.updateConstraints()}),this.api.onDidSizeChange(i=>{this._onDidChange.fire({size:i.size})}))}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}layout(e,t){const[i,n]=this.orientation===z.HORIZONTAL?[e,t]:[t,e];super.layout(i,n)}init(e){super.init(e),this._priority=e.priority,e.minimumSize&&(this._minimumSize=e.minimumSize),e.maximumSize&&(this._maximumSize=e.maximumSize),e.snap&&(this._snap=e.snap)}toJSON(){const e=i=>i===Number.MAX_SAFE_INTEGER||i===Number.POSITIVE_INFINITY?void 0:i,t=i=>i<=0?void 0:i;return Object.assign(Object.assign({},super.toJSON()),{minimumSize:t(this.minimumSize),maximumSize:e(this.maximumSize)})}updateConstraints(){this.api._onDidConstraintsChange.fire({maximumSize:this._evaluatedMaximumSize,minimumSize:this._evaluatedMinimumSize})}}function ro(o,e){return new eo(o,e).api}function ao(o,e){const t=new io(o,e);return new Hi(t)}function lo(o,e){const t=new to(o,e);return new Fi(t)}function ho(o,e){const t=new so(o,e);return new et(t)}/**
7
- * dockview
8
- * @version 6.2.2
9
- * @link https://github.com/mathuo/dockview
10
- * @license MIT
11
- */const sn=(o,e)=>{const[,t]=O.useState(0),i=O.useRef(o.componentProps);return O.useImperativeHandle(e,()=>({update:n=>{i.current=Object.assign(Object.assign({},i.current),n),t(s=>s+1)}}),[]),O.createElement(o.component,i.current)};sn.displayName="DockviewReactJsBridge";const co=(()=>{let o=1;return{next:()=>`dockview_react_portal_key_${(o++).toString()}`}})(),uo=O.createContext({});class ke{constructor(e,t,i,n,s){this.parent=e,this.portalStore=t,this.component=i,this.parameters=n,this.context=s,this._initialProps={},this.disposed=!1,this.createPortal()}update(e){if(this.disposed)throw new Error("invalid operation: resource is already disposed");this.componentInstance?this.componentInstance.update(e):this._initialProps=Object.assign(Object.assign({},this._initialProps),e)}createPortal(){if(this.disposed)throw new Error("invalid operation: resource is already disposed");if(!po(this.component))throw new Error("Dockview: Only React.memo(...), React.ForwardRef(...) and functional components are accepted as components");const e=O.createElement(O.forwardRef(sn),{component:this.component,componentProps:this.parameters,ref:n=>{this.componentInstance=n,Object.keys(this._initialProps).length>0&&(this.componentInstance.update(this._initialProps),this._initialProps={})}}),t=this.context?O.createElement(uo.Provider,{value:this.context},e):e,i=Cn.createPortal(t,this.parent,co.next());this.ref={portal:i,disposable:this.portalStore.addPortal(i)}}dispose(){var e;(e=this.ref)===null||e===void 0||e.disposable.dispose(),this.disposed=!0}}const Dt=()=>{const[o,e]=O.useState([]);O.useDebugValue(`Portal count: ${o.length}`);const t=O.useCallback(i=>{e(s=>[...s,i]);let n=!1;return ne.from(()=>{if(n)throw new Error("invalid operation: resource already disposed");n=!0,e(s=>s.filter(l=>l!==i))})},[]);return[o,t]};function po(o){return typeof o=="function"||!!(o!=null&&o.$$typeof)}class Di{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._onDidFocus=new _,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new _,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}focus(){}init(e){this.part=new ke(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi})}update(e){var t;(t=this.part)===null||t===void 0||t.update({params:e.params})}layout(e,t){}dispose(){var e;this._onDidFocus.dispose(),this._onDidBlur.dispose(),(e=this.part)===null||e===void 0||e.dispose()}}class yi{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}focus(){}init(e){this.part=new ke(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi,tabLocation:e.tabLocation})}update(e){var t;(t=this.part)===null||t===void 0||t.update({params:e.params})}layout(e,t){}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}}class xi{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new ke(this.element,this.reactPortalStore,this.component,{group:e.group,containerApi:e.containerApi})}focus(){}update(e){var t,i,n;this.parameters&&(this.parameters.params=e.params),(t=this.part)===null||t===void 0||t.update({params:(n=(i=this.parameters)===null||i===void 0?void 0:i.params)!==null&&n!==void 0?n:{}})}layout(e,t){}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}}class mo{get element(){return this._element}get part(){return this._part}constructor(e,t,i){this.component=e,this.reactPortalStore=t,this._group=i,this.mutableDisposable=new le,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.mutableDisposable.value=new R(this._group.model.onDidAddPanel(()=>{this.updatePanels()}),this._group.model.onDidRemovePanel(()=>{this.updatePanels()}),this._group.model.onDidActivePanelChange(()=>{this.updateActivePanel()}),e.api.onDidActiveChange(()=>{this.updateGroupActive()}),e.api.onDidLocationChange(t=>{this.updateLocation(t.location)})),this._part=new ke(this.element,this.reactPortalStore,this.component,{api:e.api,containerApi:e.containerApi,panels:this._group.model.panels,activePanel:this._group.model.activePanel,isGroupActive:this._group.api.isActive,group:this._group,headerPosition:this._group.model.headerPosition,location:e.api.location})}dispose(){var e;this.mutableDisposable.dispose(),(e=this._part)===null||e===void 0||e.dispose()}update(e){var t;(t=this._part)===null||t===void 0||t.update(e.params)}updatePanels(){this.update({params:{panels:this._group.model.panels}})}updateActivePanel(){this.update({params:{activePanel:this._group.model.activePanel}})}updateGroupActive(){this.update({params:{isGroupActive:this._group.api.isActive}})}updateLocation(e){this.update({params:{location:e}})}}class fo{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new ke(this._element,this.reactPortalStore,this.component,e)}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}}class Si{get element(){return this._element}constructor(e,t){this.component=e,this.reactPortalStore=t,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.display="inline-flex"}init(e){this.part=new ke(this._element,this.reactPortalStore,this.component,{tabGroup:e.tabGroup,api:e.api})}update(e){var t;(t=this.part)===null||t===void 0||t.update({tabGroup:e.tabGroup})}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}}function je(o,e){return o?t=>new mo(o,e,t):void 0}const pt="props.defaultTabComponent";function go(o){return Nt.reduce((t,i)=>(i in o&&(t[i]=o[i]),t),{})}const on=O.forwardRef((o,e)=>{const t=O.useRef(null),i=O.useRef(void 0),[n,s]=Dt();O.useImperativeHandle(e,()=>t.current,[]);const l=O.useRef({});return O.useEffect(()=>{const a={};Nt.forEach(r=>{const d=r,h=o[d];d in o&&h!==l.current[d]&&(a[d]=h)}),i.current&&i.current.updateOptions(a),l.current=o},Nt.map(a=>o[a])),O.useEffect(()=>{var a;if(!t.current)return;const r=(a=o.tabComponents)!==null&&a!==void 0?a:{};o.defaultTabComponent&&(r[pt]=o.defaultTabComponent);const d={createLeftHeaderActionComponent:je(o.leftHeaderActionsComponent,{addPortal:s}),createRightHeaderActionComponent:je(o.rightHeaderActionsComponent,{addPortal:s}),createPrefixHeaderActionComponent:je(o.prefixHeaderActionsComponent,{addPortal:s}),createComponent:f=>new Di(f.id,o.components[f.name],{addPortal:s}),createTabComponent(f){return new yi(f.id,r[f.name],{addPortal:s})},createWatermarkComponent:o.watermarkComponent?()=>new xi("watermark",o.watermarkComponent,{addPortal:s}):void 0,defaultTabComponent:o.defaultTabComponent?pt:void 0,createContextMenuItemComponent:f=>{if(f.component)return new fo(f.id,f.component,{addPortal:s})}},h=go(o);if(o.tabGroupChipComponent){const f=o.tabGroupChipComponent;h.createTabGroupChipComponent=()=>new Si(f,{addPortal:s})}const c=ro(t.current,Object.assign(Object.assign({},h),d)),{clientWidth:u,clientHeight:p}=t.current;return c.layout(u,p),o.onReady&&o.onReady({api:c}),i.current=c,()=>{i.current=void 0,c.dispose()}},[]),O.useEffect(()=>{if(!i.current)return()=>{};const a=i.current.onDidDrop(r=>{o.onDidDrop&&o.onDidDrop(r)});return()=>{a.dispose()}},[o.onDidDrop]),O.useEffect(()=>{if(!i.current)return()=>{};const a=i.current.onWillDrop(r=>{o.onWillDrop&&o.onWillDrop(r)});return()=>{a.dispose()}},[o.onWillDrop]),O.useEffect(()=>{i.current&&i.current.updateOptions({createTabGroupChipComponent:o.tabGroupChipComponent?()=>new Si(o.tabGroupChipComponent,{addPortal:s}):void 0})},[o.tabGroupChipComponent]),O.useEffect(()=>{i.current&&i.current.updateOptions({createComponent:a=>new Di(a.id,o.components[a.name],{addPortal:s})})},[o.components]),O.useEffect(()=>{var a;if(!i.current)return;const r=(a=o.tabComponents)!==null&&a!==void 0?a:{};o.defaultTabComponent&&(r[pt]=o.defaultTabComponent),i.current.updateOptions({defaultTabComponent:o.defaultTabComponent?pt:void 0,createTabComponent(d){return new yi(d.id,r[d.name],{addPortal:s})}})},[o.tabComponents,o.defaultTabComponent]),O.useEffect(()=>{i.current&&i.current.updateOptions({createWatermarkComponent:o.watermarkComponent?()=>new xi("watermark",o.watermarkComponent,{addPortal:s}):void 0})},[o.watermarkComponent]),O.useEffect(()=>{i.current&&i.current.updateOptions({createRightHeaderActionComponent:je(o.rightHeaderActionsComponent,{addPortal:s})})},[o.rightHeaderActionsComponent]),O.useEffect(()=>{i.current&&i.current.updateOptions({createLeftHeaderActionComponent:je(o.leftHeaderActionsComponent,{addPortal:s})})},[o.leftHeaderActionsComponent]),O.useEffect(()=>{i.current&&i.current.updateOptions({createPrefixHeaderActionComponent:je(o.prefixHeaderActionsComponent,{addPortal:s})})},[o.prefixHeaderActionsComponent]),O.createElement("div",{style:{height:"100%",width:"100%"},ref:t},n)});on.displayName="DockviewComponent";class Pi extends oo{constructor(e,t,i,n){super(e,t),this.reactComponent=i,this.reactPortalStore=n}getComponent(){var e,t;return new ke(this.element,this.reactPortalStore,this.reactComponent,{params:(t=(e=this._params)===null||e===void 0?void 0:e.params)!==null&&t!==void 0?t:{},api:this.api,containerApi:new Hi(this._params.accessor)})}}function vo(o){return zt.reduce((t,i)=>(i in o&&(t[i]=o[i]),t),{})}const _o=O.forwardRef((o,e)=>{const t=O.useRef(null),i=O.useRef(void 0),[n,s]=Dt();O.useImperativeHandle(e,()=>t.current,[]);const l=O.useRef({});return O.useEffect(()=>{const a={};zt.forEach(r=>{const d=r,h=o[d];d in o&&h!==l.current[d]&&(a[d]=h)}),i.current&&i.current.updateOptions(a),l.current=o},zt.map(a=>o[a])),O.useEffect(()=>{if(!t.current)return()=>{};const a={createComponent:c=>new Pi(c.id,c.name,o.components[c.name],{addPortal:s})},r=ao(t.current,Object.assign(Object.assign({},vo(o)),a)),{clientWidth:d,clientHeight:h}=t.current;return r.layout(d,h),o.onReady&&o.onReady({api:r}),i.current=r,()=>{i.current=void 0,r.dispose()}},[]),O.useEffect(()=>{i.current&&i.current.updateOptions({createComponent:a=>new Pi(a.id,a.name,o.components[a.name],{addPortal:s})})},[o.components]),O.createElement("div",{style:{height:"100%",width:"100%"},ref:t},n)});_o.displayName="SplitviewComponent";class Gi extends tn{constructor(e,t,i,n){super(e,t),this.reactComponent=i,this.reactPortalStore=n}getComponent(){var e,t;return new ke(this.element,this.reactPortalStore,this.reactComponent,{params:(t=(e=this._params)===null||e===void 0?void 0:e.params)!==null&&t!==void 0?t:{},api:this.api,containerApi:new Fi(this._params.accessor)})}}function bo(o){return Vt.reduce((t,i)=>(i in o&&(t[i]=o[i]),t),{})}const wo=O.forwardRef((o,e)=>{const t=O.useRef(null),i=O.useRef(void 0),[n,s]=Dt();O.useImperativeHandle(e,()=>t.current,[]);const l=O.useRef({});return O.useEffect(()=>{const a={};Vt.forEach(r=>{const d=r,h=o[d];d in o&&h!==l.current[d]&&(a[d]=h)}),i.current&&i.current.updateOptions(a),l.current=o},Vt.map(a=>o[a])),O.useEffect(()=>{if(!t.current)return()=>{};const a={createComponent:c=>new Gi(c.id,c.name,o.components[c.name],{addPortal:s})},r=lo(t.current,Object.assign(Object.assign({},bo(o)),a)),{clientWidth:d,clientHeight:h}=t.current;return r.layout(d,h),o.onReady&&o.onReady({api:r}),i.current=r,()=>{i.current=void 0,r.dispose()}},[]),O.useEffect(()=>{i.current&&i.current.updateOptions({createComponent:a=>new Gi(a.id,a.name,o.components[a.name],{addPortal:s})})},[o.components]),O.createElement("div",{style:{height:"100%",width:"100%"},ref:t},n)});wo.displayName="GridviewComponent";class mt{get element(){return this._element}constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new ke(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,title:e.title,containerApi:e.containerApi})}toJSON(){return{id:this.id}}update(e){var t;(t=this.part)===null||t===void 0||t.update(e.params)}dispose(){var e;(e=this.part)===null||e===void 0||e.dispose()}}function Co(o){return Mt.reduce((t,i)=>(i in o&&(t[i]=o[i]),t),{})}const Do=O.forwardRef((o,e)=>{const t=O.useRef(null),i=O.useRef(void 0),[n,s]=Dt();O.useImperativeHandle(e,()=>t.current,[]);const l=O.useRef({});return O.useEffect(()=>{const a={};Mt.forEach(r=>{const d=r,h=o[d];d in o&&h!==l.current[d]&&(a[d]=h)}),i.current&&i.current.updateOptions(a),l.current=o},Mt.map(a=>o[a])),O.useEffect(()=>{var a;if(!t.current)return()=>{};const r=(a=o.headerComponents)!==null&&a!==void 0?a:{},d={createComponent:p=>new mt(p.id,o.components[p.name],{addPortal:s}),createHeaderComponent:p=>new mt(p.id,r[p.name],{addPortal:s})},h=ho(t.current,Object.assign(Object.assign({},Co(o)),d)),{clientWidth:c,clientHeight:u}=t.current;return h.layout(c,u),o.onReady&&o.onReady({api:h}),i.current=h,()=>{i.current=void 0,h.dispose()}},[]),O.useEffect(()=>{i.current&&i.current.updateOptions({createComponent:a=>new mt(a.id,o.components[a.name],{addPortal:s})})},[o.components]),O.useEffect(()=>{var a;if(!i.current)return;const r=(a=o.headerComponents)!==null&&a!==void 0?a:{};i.current.updateOptions({createHeaderComponent:d=>new mt(d.id,r[d.name],{addPortal:s})})},[o.headerComponents]),O.useEffect(()=>{if(!i.current)return()=>{};const a=i.current.onDidDrop(r=>{o.onDidDrop&&o.onDidDrop(r)});return()=>{a.dispose()}},[o.onDidDrop]),O.createElement("div",{style:{height:"100%",width:"100%"},ref:t},n)});Do.displayName="PaneviewComponent";const rn="route-container-panel-dock-content",an="route-container-panel-dock-tab",yo="application/vnd.oneworks.route-container-panel-tab+json",Lt="route-container-panel-dock:external-tab-drop",Gt="route-container-panel-dock:context-menu-open",xo=12,So=".route-container-panel-dock",At=(o,e,t,i)=>t==null||t.enabled===!1?null:{icon:t.icon??e,key:t.key??o,label:t.label,...t.active!=null?{active:t.active}:{},...t.activeIcon!=null||i!=null?{activeIcon:t.activeIcon??i}:{},...t.disabled!=null?{disabled:t.disabled}:{},onSelect:t.onSelect},Po=o=>[At("fullscreen","fullscreen",o==null?void 0:o.fullscreen,"fullscreen_exit"),At("minimize","bottom_panel_close",o==null?void 0:o.minimize),At("close","disabled_by_default",o==null?void 0:o.close)].filter(e=>e!=null),Ai=(o,e)=>{const t=new Set(o),i=new Set,n=[];for(const s of e)!t.has(s)||i.has(s)||(i.add(s),n.push(s));return n},Go=(o,e)=>{if(o==null||typeof window>"u")return null;try{const t=JSON.parse(window.localStorage.getItem(o)??"null"),i=new Set(e.map(n=>n.key));return t==null||typeof t!="object"||t.panels==null||typeof t.panels!="object"?null:Object.keys(t.panels).every(n=>i.has(n))?t:null}catch{return null}},Ao=(o,e)=>{o==null||typeof window>"u"||window.localStorage.setItem(o,JSON.stringify(e))},Io=o=>{try{const e=JSON.parse(o.getData(yo));return e==null||typeof e!="object"||typeof e.scope!="string"||typeof e.sourceWorkspaceKey!="string"||typeof e.tabKey!="string"?null:e}catch{return null}},Eo=o=>o==null||typeof o!="object"||typeof o.scope!="string"||typeof o.sourceWorkspaceKey!="string"||typeof o.targetWorkspaceKey!="string"||typeof o.tabKey!="string"?null:o,To=(o,e,t)=>{const i=document.elementFromPoint(o,e);if(!(i instanceof Element))return null;const n=i.closest(So);if(n instanceof HTMLElement){const s=n.dataset.routeContainerPanelDockWorkspaceKey;if(n.dataset.routeContainerPanelDockDroppable==="true"&&n.dataset.routeContainerPanelDockScope===t.scope&&s!=null&&s!==t.sourceWorkspaceKey)return{element:n,targetWorkspaceKey:s}}for(const s of t.dropTargets??[])if(s.targetWorkspaceKey!==t.sourceWorkspaceKey)try{const l=i.closest(s.selector);if(!(l instanceof HTMLElement))continue;return{element:l,targetWorkspaceKey:s.targetWorkspaceKey}}catch{continue}return null},zo=o=>{var i;const e=o.filter(n=>n.api.isVisible&&n.panels.length>0&&n.api.location.type==="grid").map(n=>({group:n,rect:n.element.getBoundingClientRect()})).filter(({rect:n})=>n.width>0&&n.height>0);if(e.length===0)return;const t=Math.min(...e.map(({rect:n})=>n.top));return(i=e.filter(({rect:n})=>Math.abs(n.top-t)<=2).sort((n,s)=>s.rect.right-n.rect.right||n.rect.left-s.rect.left)[0])==null?void 0:i.group.api.id},ln=x.createContext(null),Je=o=>{var t;const e=(t=o.title)==null?void 0:t.trim();return e!=null&&e.length>0?e:o.label},ko=o=>{var t;const e=(t=o.title)==null?void 0:t.trim();return e!=null&&e.length>0},Ii=o=>o.group.panels.length,Oo=o=>o instanceof Element&&o.closest(".route-container-panel-dock-context-dropdown, .route-container-panel-dock__context-anchor")!=null,it=()=>{const o=x.useContext(ln);if(o==null)throw new Error("RouteContainerPanelDockWorkspace must be rendered inside its context provider");return o};function Ro({api:o,params:e}){const{tabByKey:t}=it(),i=t[e.tabKey],[n,s]=x.useState(()=>o.isVisible);if(x.useEffect(()=>{s(o.isVisible);const r=o.onDidVisibilityChange(()=>{s(o.isVisible)});return()=>r.dispose()},[o]),i==null)return null;const l=typeof i.content=="function"?i.content({isVisible:n,tab:i,tabKey:i.key}):i.content,a=`route-container-panel-dock__content ${n?"is-visible":"is-hidden"}`;return V.jsx("div",{className:a,children:l})}function Vo({api:o,containerApi:e,params:t}){const{activeTab:i,closeLabel:n,closeTab:s,externalTabDrag:l,hasContextMenu:a,isTabClosable:r,openContextMenu:d,openedTabs:h,panelKey:c,selectTab:u,tabByKey:p,tabs:f,visibleTabs:m}=it(),g=p[t.tabKey],[v,b]=x.useState(!1),w=x.useRef(null),C=x.useRef(!1),[I,E]=x.useState(()=>({group:o.group,tabCount:Ii(o)})),D=x.useCallback(()=>{E(S=>{const j=o.group,W=Ii(o);return S.group===j&&S.tabCount===W?S:{group:j,tabCount:W}})},[o]);if(x.useEffect(()=>{D();const S=[o.onDidGroupChange(D),e.onDidLayoutChange(D)];return()=>{S.forEach(j=>j.dispose())}},[o,e,D]),x.useEffect(()=>{D();const{model:S}=I.group,j=[S.onDidAddPanel(D),S.onDidRemovePanel(D),S.onDidActivePanelChange(D)];return()=>{j.forEach(W=>W.dispose())}},[I.group,D]),g==null)return null;const G=Je(g),M=r(g.key,I.tabCount),H=(n==null?void 0:n(G))??G,N=(l==null?void 0:l.draggable)===!0&&g.disabled!==!0,L=S=>{a&&d(S,{activeTab:i,closeTab:s,isActive:i===g.key,isClosable:M,isOpened:h.includes(g.key),openedTabs:h,panelKey:c,selectTab:u,tab:g,tabs:f,target:"tab",visibleTabs:m})},X=()=>{var S;(S=w.current)==null||S.element.classList.remove("is-external-drop-target"),w.current=null},B=(S,j)=>{var se,$;if(l==null)return null;const W=To(S,j,{dropTargets:l.dropTargets,scope:l.scope,sourceWorkspaceKey:l.workspaceKey});return(W==null?void 0:W.element)===((se=w.current)==null?void 0:se.element)&&(W==null?void 0:W.targetWorkspaceKey)===(($=w.current)==null?void 0:$.targetWorkspaceKey)||(X(),W==null||W.element.classList.add("is-external-drop-target"),w.current=W),W},y=S=>{if(!N||l==null||S.button!==0)return;S.stopPropagation();const j=S.pointerId,W=S.clientX,se=S.clientY,$=l.workspaceKey,K=l.scope,oe=g.key;let ce=!1;const J=()=>{window.removeEventListener("pointermove",pe),window.removeEventListener("pointerup",ue),window.removeEventListener("pointercancel",Se),X(),b(!1)},pe=de=>{if(de.pointerId!==j)return;const me=de.clientX-W,q=de.clientY-se;!ce&&Math.hypot(me,q)<xo||(ce=!0,de.preventDefault(),b(!0),B(de.clientX,de.clientY))},ue=de=>{var Ee;if(de.pointerId!==j)return;const me=ce?B(de.clientX,de.clientY):null;if(J(),ce&&(C.current=!0,window.setTimeout(()=>{C.current=!1},0)),me==null)return;de.preventDefault(),de.stopPropagation();const q=me.targetWorkspaceKey;if(l.onDrop!=null){if(!(((Ee=l.canDrop)==null?void 0:Ee.call(l,{sourceWorkspaceKey:$,tab:g,tabKey:oe,targetWorkspaceKey:q}))??!0))return;l.onDrop({sourceWorkspaceKey:$,tab:g,tabKey:oe,targetWorkspaceKey:q});return}window.dispatchEvent(new CustomEvent(Lt,{detail:{scope:K,sourceWorkspaceKey:$,tabKey:oe,targetWorkspaceKey:q}}))},Se=de=>{de.pointerId===j&&J()};o.setActive(),window.addEventListener("pointermove",pe,{passive:!1}),window.addEventListener("pointerup",ue),window.addEventListener("pointercancel",Se)};return V.jsxs("div",{className:["route-container-panel-dock-tab",M?"is-closable":"",N?"is-external-draggable":"",v?"is-external-dragging":""].filter(Boolean).join(" "),title:G,onClick:()=>o.setActive(),onContextMenu:a?L:void 0,onPointerDown:N?y:void 0,children:[V.jsx("span",{className:"route-container-panel-dock-tab__icon",children:g.iconNode??V.jsx(ft,{name:i===g.key&&g.activeIcon!=null?g.activeIcon:g.icon,"aria-hidden":"true"})}),V.jsx("span",{className:"route-container-panel-dock-tab__label",children:g.label}),g.badge!=null&&V.jsx("span",{className:"route-container-panel-dock-tab__badge",children:g.badge}),M&&V.jsx("button",{type:"button",className:"route-container-panel-dock-tab__close","aria-label":H,title:H,onClick:S=>{if(S.stopPropagation(),C.current){S.preventDefault(),C.current=!1;return}s(g.key)},onPointerDown:N?y:S=>S.stopPropagation(),children:V.jsx(ft,{name:"cancel","aria-hidden":"true"})})]})}const dn=o=>{o.stopPropagation()},ei=()=>V.jsx("span",{className:"material-symbols-rounded nav-menu-submenu-chevron",children:"keyboard_arrow_right"});function Mo({api:o}){return V.jsx(hn,{onBeforeOpen:()=>o.setActive()})}function hn({onBeforeOpen:o}){const{createMenuIcon:e,createMenuItems:t,createMenuLabel:i,createMenuSections:n,createMenuSelectedKeys:s,onCreateMenuClick:l,onCreateMenuOpenChange:a}=it(),[r,d]=x.useState(!1),h=typeof navigator<"u"&&navigator.platform.includes("Mac"),c=x.useCallback(()=>d(!1),[]),u=x.useMemo(()=>Wt({closeMenu:c,isMac:h,sections:n}),[c,n,h]),p=t??u,f=x.useMemo(()=>Ht(n),[n]),m=s??f,g=v=>{d(v),a==null||a(v)};return i==null||p==null||p.length===0?null:V.jsx("div",{className:"route-container-panel-dock__prefix-actions",onPointerDown:dn,children:V.jsx(Bt,{overlayClassName:`${Ft} route-container-panel-dock-create-dropdown`,menu:{expandIcon:ei(),items:p,onClick:l,selectedKeys:m,triggerSubMenuAction:"click"},open:r,placement:"bottomLeft",trigger:["click"],transitionName:"ant-slide-down",onOpenChange:g,children:V.jsx("button",{type:"button",className:["route-container-panel-dock__create-action",r?"is-open":""].filter(Boolean).join(" "),"data-dock-panel-no-resize":"true","aria-label":i,"aria-haspopup":"menu","aria-expanded":r,title:i,onClick:o,children:V.jsx(ft,{name:e,"aria-hidden":"true"})})})})}function No({action:o}){const[e,t]=x.useState(!1),i=o.active&&o.activeIcon!=null?o.activeIcon:o.icon,n=o.label,s=typeof navigator<"u"&&navigator.platform.includes("Mac"),l=x.useCallback(()=>t(!1),[]),a=x.useMemo(()=>o.menuSections==null?void 0:Wt({closeMenu:l,isMac:s,sections:o.menuSections}),[o.menuSections,l,s]),r=x.useMemo(()=>o.menuSections==null?[]:Ht(o.menuSections),[o.menuSections]),d=o.menuItems??a,h=o.menuSelectedKeys??r,c=V.jsx(xn,{title:n,placement:"top",children:V.jsx("button",{type:"button",className:["route-container-panel-dock__header-action",o.active?"is-active":"",e?"is-open":""].filter(Boolean).join(" "),"aria-label":n,"aria-pressed":o.active,disabled:o.disabled,title:n,onClick:d==null||d.length===0?o.onSelect:void 0,children:V.jsx(ft,{name:i,"aria-hidden":"true"})})});return d==null||d.length===0?c:V.jsx(Bt,{overlayClassName:`${Ft} route-container-panel-dock-action-dropdown`,menu:{expandIcon:ei(),items:d,selectedKeys:h,triggerSubMenuAction:"click"},open:e,placement:"bottomRight",trigger:["click"],transitionName:"ant-slide-down",onOpenChange:u=>{var p;t(u),(p=o.onMenuOpenChange)==null||p.call(o,u)},children:c})}function cn({actions:o}){const e=o;return e.length===0?null:V.jsx("div",{className:"route-container-panel-dock__header-actions",onPointerDown:dn,children:e.map(t=>V.jsx(No,{action:t},t.key))})}function Lo({activePanel:o,containerApi:e,group:t}){const{activeTab:i,getHeaderActions:n,headerActions:s,panelChromeActions:l,panelKey:a,tabByKey:r}=it(),[d,h]=x.useState(!1),c=x.useCallback(()=>{h(zo(e.groups)===t.api.id)},[e,t]);x.useEffect(()=>{c();const m=window.requestAnimationFrame(c),g=[t.api.onDidDimensionsChange(c),e.onDidAddGroup(c),e.onDidLayoutChange(c),e.onDidMaximizedGroupChange(c),e.onDidRemoveGroup(c)];return()=>{window.cancelAnimationFrame(m);for(const v of g)v.dispose()}},[e,t,c]);const u=o==null?null:r[o.id]??null,p=(n==null?void 0:n({activeTab:i,groupActiveTab:u,groupActiveTabKey:(u==null?void 0:u.key)??null,isTopRightGroup:d,panelKey:a}))??s,f=d?[...p,...l]:p;return f.length===0||n==null&&(!d||o==null)?null:V.jsx(cn,{actions:f})}const Ei=(o,e,t)=>{var n;const i=new Set(e.map(s=>s.key));for(const s of o.panels)i.has(s.id)||o.removePanel(s);for(const s of e){const l=o.getPanel(s.key);if(l==null){o.addPanel({id:s.key,component:rn,tabComponent:an,title:Je(s),renderer:"always",inactive:s.key!==t,params:{tabKey:s.key}});continue}l.api.setTitle(Je(s)),l.api.updateParameters({tabKey:s.key}),l.api.renderer!=="always"&&l.api.setRenderer("always")}t!=null&&((n=o.getPanel(t))==null||n.api.setActive())};function er({activeTab:o,ariaLabel:e,className:t,closable:i=!1,closeLabel:n,createMenuIcon:s="add_box",createMenuItems:l,createMenuLabel:a,createMenuSections:r=[],createMenuSelectedKeys:d,defaultContent:h,disableFloatingGroups:c=!1,externalTabDrag:u,getContextMenuSections:p,getHeaderActions:f,getTabContextMenuItems:m,headerActions:g=[],labelMode:v="icon-only",minOpenTabs:b=0,openedTabs:w,panelChromeActions:C,panelKey:I,storageKey:E,tabs:D,onCreateMenuClick:G,onCreateMenuOpenChange:M,onTabChange:H,onTabClose:N}){const L=x.useRef(null),X=x.useId(),B=x.useRef([]),y=x.useRef(!1),S=x.useRef(null),j=x.useMemo(()=>D.map(P=>P),[D]),W=x.useMemo(()=>D.map(P=>P.key),[D]),se=x.useMemo(()=>Ai(W,w),[w,W]),$=o??se[0]??null,K=x.useMemo(()=>{const P=new Set(se);return(i?D.filter(T=>P.has(T.key)||T.key===$):D).map(T=>T)},[i,$,se,D]),oe=x.useMemo(()=>K.map(P=>P.key),[K]),ce=x.useMemo(()=>Object.fromEntries(K.map(P=>[P.key,P])),[K]),J=x.useMemo(()=>Po(C),[C]),pe=x.useRef($),ue=x.useRef(se),Se=x.useRef(K),[de,me]=x.useState(!1),[q,Ee]=x.useState(null);x.useEffect(()=>{pe.current=$,ue.current=se,Se.current=K},[$,se,K]);const Pe=x.useCallback(()=>{B.current.forEach(P=>P.dispose()),B.current=[]},[]),Ne=x.useCallback(()=>{const P=L.current;P==null||y.current||Ao(E,P.toJSON())},[E]),Oe=x.useCallback(P=>(u==null?void 0:u.droppable)===!0&&u.onDrop!=null,[u]),Be=x.useCallback(P=>{var Q;if(P==null||(u==null?void 0:u.droppable)!==!0||u.onDrop==null)return!1;const T=u.workspaceKey;if(P.scope!==u.scope||P.sourceWorkspaceKey===T)return!1;const F=D.find(ae=>ae.key===P.tabKey);return F==null||F.disabled===!0?!1:((Q=u.canDrop)==null?void 0:Q.call(u,{sourceWorkspaceKey:P.sourceWorkspaceKey,tab:F,tabKey:F.key,targetWorkspaceKey:T}))??!0},[u,D]),U=x.useCallback(P=>{Oe(P.dataTransfer)&&(P.preventDefault(),P.dataTransfer.dropEffect="move",me(!0))},[Oe]),ee=x.useCallback(P=>{Oe(P.dataTransfer)&&(P.preventDefault(),P.dataTransfer.dropEffect="move",me(!0))},[Oe]),fe=x.useCallback(P=>{const T=P.relatedTarget;T instanceof Node&&P.currentTarget.contains(T)||me(!1)},[]),Le=x.useCallback(P=>{if(!Oe(P.dataTransfer))return;const T=Io(P.dataTransfer);if(!Be(T)||T==null||(u==null?void 0:u.onDrop)==null){me(!1);return}const F=D.find(Q=>Q.key===T.tabKey);if(F==null){me(!1);return}P.preventDefault(),P.stopPropagation(),me(!1),u.onDrop({sourceWorkspaceKey:T.sourceWorkspaceKey,tab:F,tabKey:F.key,targetWorkspaceKey:u.workspaceKey})},[Be,Oe,u,D]);x.useEffect(()=>{if((u==null?void 0:u.droppable)!==!0||u.onDrop==null)return;const P=T=>{var Ge;const F=Eo(T.detail);if(F==null||F.targetWorkspaceKey!==u.workspaceKey)return;const Q={scope:F.scope,sourceWorkspaceKey:F.sourceWorkspaceKey,tabKey:F.tabKey};if(!Be(Q))return;const ae=D.find(Te=>Te.key===F.tabKey);ae!=null&&((Ge=u.onDrop)==null||Ge.call(u,{sourceWorkspaceKey:F.sourceWorkspaceKey,tab:ae,tabKey:ae.key,targetWorkspaceKey:u.workspaceKey}))};return window.addEventListener(Lt,P),()=>{window.removeEventListener(Lt,P)}},[Be,u,D]);const nt=x.useCallback(()=>{S.current!=null&&(window.clearTimeout(S.current),S.current=null),y.current=!0},[]),st=x.useCallback(P=>{S.current=window.setTimeout(()=>{S.current=null,y.current=!1,P==null||P()},80)},[]),ot=x.useCallback(P=>{H(P,Ai(W,[...ue.current,P]))},[H,W]),Re=x.useCallback(P=>{const T=P,F=ue.current,Q=F.indexOf(T),ae=F.filter(Ue=>Ue!==T),Ge=ae[Math.max(0,Q-1)]??ae[0]??null,Te=pe.current===T?Ge:pe.current;N==null||N(T),H(Te,ae)},[H,N]),$e=x.useCallback((P,T)=>{const F=Se.current.find(ae=>ae.key===P),Q=T??ue.current.length;return F!=null&&i&&ko(F)&&ue.current.includes(P)&&Q>b},[i,b]),Ve=x.useCallback(()=>Ee(null),[]),rt=x.useCallback((P,T)=>{const F=(p==null?void 0:p(T))??[],Q=T.target==="tab"&&T.tab!=null&&T.isClosable?[{items:[{icon:"close",key:`route-container-panel:${T.panelKey??"panel"}:${T.tab.key}:close`,label:(n==null?void 0:n(Je(T.tab)))??Je(T.tab),onSelect:()=>{T.tab!=null&&T.closeTab(T.tab.key)}}],key:`route-container-panel:${T.panelKey??"panel"}:${T.tab.key}:default`}]:[],ae=[...F,...Q].filter(Ge=>Ge.items.length>0);ae.length!==0&&(P.preventDefault(),P.stopPropagation(),window.dispatchEvent(new CustomEvent(Gt,{detail:{ownerId:X}})),Ee({sections:ae,x:P.clientX,y:P.clientY}))},[n,X,p]),pn=x.useCallback(P=>{if(p==null)return;const T=P.target;if(!(T instanceof Element))return;const F=T.closest(".dv-tabs-and-actions-container, .route-container-panel-dock__empty-header"),Q=T.closest(".route-container-panel-dock__content, .route-container-panel-dock__empty-content, .dv-content-container, .dv-view"),ae=F instanceof HTMLElement&&P.currentTarget.contains(F),Ge=Q instanceof HTMLElement&&P.currentTarget.contains(Q);if(!ae&&!Ge||T.closest([".dv-tab",".route-container-panel-dock-tab",".dv-pre-actions-container",".dv-right-actions-container",".ant-dropdown",".ant-select",".ant-input",'[contenteditable="true"]','[data-dock-panel-no-resize="true"]','[role="button"]',"a","button","input","select","textarea"].join(", "))!=null)return;const Te=L.current;rt(P,{activeTab:pe.current,closeTab:Re,isActive:!1,isClosable:!1,isOpened:!1,openedTabs:ue.current,panelKey:I,selectTab:Ue=>{var at;return(at=Te==null?void 0:Te.getPanel(Ue))==null?void 0:at.api.setActive()},tabs:j,target:"blank",visibleTabs:Se.current})},[j,p,rt,I]),mn=x.useCallback(P=>{L.current=P.api,Pe(),nt();try{const T=Go(E,Se.current);T!=null&&P.api.fromJSON(T,{reuseExistingPanels:!0}),Ei(P.api,Se.current,pe.current)}finally{st(Ne)}B.current=[P.api.onDidActivePanelChange(T=>{y.current||T==null||oe.includes(T.id)&&ot(T.id)}),P.api.onDidRemovePanel(T=>{y.current||!$e(T.id)||Re(T.id)}),P.api.onDidLayoutChange(Ne)]},[nt,Re,Pe,st,$e,Ne,ot,E,oe]),fn=x.useCallback(({api:P,group:T,panel:F})=>{const Q=ce[F.id];if(Q==null)return[];const ae=$e(Q.key,T.panels.length),Ge={activeTab:pe.current,closeTab:yt=>Re(yt),isActive:pe.current===Q.key,isClosable:ae,isOpened:ue.current.includes(Q.key),selectTab:yt=>{var ii;return(ii=P.getPanel(yt))==null?void 0:ii.api.setActive()},tab:Q},Te=(m==null?void 0:m(Ge))??[],Ue=Je(Q),at=ae?[{label:(n==null?void 0:n(Ue))??Ue,action:()=>Re(Q.key)}]:[];return[...Te,...at]},[n,Re,m,$e,ce]),ti=typeof navigator<"u"&&navigator.platform.includes("Mac"),gn=x.useMemo(()=>q==null?[]:Wt({closeMenu:Ve,isMac:ti,sections:q.sections}),[Ve,q,ti]),vn=x.useMemo(()=>q==null?[]:Ht(q.sections),[q]);x.useEffect(()=>{const P=L.current;if(!(P==null||K.length===0)){nt();try{Ei(P,K,$)}finally{st(Ne)}}},[nt,$,st,Ne,K]),x.useEffect(()=>{K.length>0||(Pe(),L.current=null)},[Pe,K.length]),x.useEffect(()=>()=>{S.current!=null&&window.clearTimeout(S.current),Pe()},[Pe]),x.useEffect(()=>{const P=T=>{const F=T.detail;(F==null?void 0:F.ownerId)!==X&&Ve()};return window.addEventListener(Gt,P),()=>{window.removeEventListener(Gt,P)}},[Ve,X]),x.useEffect(()=>{if(q==null)return;const P=F=>{Oo(F.target)||Ve()},T=F=>{F.key==="Escape"&&Ve()};return window.addEventListener("pointerdown",P,!0),window.addEventListener("keydown",T,!0),()=>{window.removeEventListener("pointerdown",P,!0),window.removeEventListener("keydown",T,!0)}},[Ve,q]);const _n=x.useMemo(()=>({activeTab:$,closeLabel:n,closeTab:Re,closable:i,createMenuIcon:s,createMenuItems:l,createMenuLabel:a,createMenuSections:r,createMenuSelectedKeys:d,externalTabDrag:u,getHeaderActions:f,hasContextMenu:p!=null,headerActions:g,isTabClosable:$e,minOpenTabs:b,openContextMenu:rt,openedTabs:se,panelChromeActions:J,panelKey:I,selectTab:ot,tabs:j,tabByKey:ce,visibleTabs:K,onCreateMenuClick:G,onCreateMenuOpenChange:M}),[j,n,Re,i,s,l,a,r,d,u,$,p,f,g,$e,b,se,rt,J,I,ot,ce,K,G,M]),bn=x.useMemo(()=>typeof h!="function"?h??null:h({activeTab:$,openedTabs:se,panelKey:I,tabs:D,visibleTabs:K}),[h,$,se,I,D,K]),wn=typeof document>"u"||q==null?null:Dn.createPortal(V.jsx(Bt,{overlayClassName:`${Ft} route-container-panel-dock-context-dropdown`,menu:{expandIcon:ei(),items:gn,selectedKeys:vn,triggerSubMenuAction:"click"},open:!0,placement:"bottomLeft",trigger:[],transitionName:"ant-slide-down",onOpenChange:P=>{P||Ve()},children:V.jsx("span",{className:"route-container-panel-dock__context-anchor",style:{left:(q==null?void 0:q.x)??-9999,top:(q==null?void 0:q.y)??-9999}})}),document.body);return V.jsxs(ln.Provider,{value:_n,children:[wn,V.jsx("div",{className:["route-container-panel-dock",`is-${v}`,"dockview-theme-light",de?"is-external-drop-target":"",t].filter(Boolean).join(" "),role:"region","aria-label":e,"data-route-container-panel-dock-droppable":(u==null?void 0:u.droppable)===!0?"true":void 0,"data-route-container-panel-dock-scope":u==null?void 0:u.scope,"data-route-container-panel-dock-workspace-key":u==null?void 0:u.workspaceKey,onDragEnter:U,onDragOver:ee,onDragLeave:fe,onDrop:Le,onContextMenuCapture:pn,children:K.length===0?V.jsxs("div",{className:"route-container-panel-dock__empty-shell",children:[V.jsxs("div",{className:"route-container-panel-dock__empty-header",children:[V.jsx(hn,{}),V.jsx("span",{className:"route-container-panel-dock__empty-tab-strip"}),V.jsx(Wo,{})]}),V.jsx("div",{className:"route-container-panel-dock__empty-content",children:bn})]}):V.jsx(on,{components:{[rn]:Ro},tabComponents:{[an]:Vo},prefixHeaderActionsComponent:Mo,rightHeaderActionsComponent:Lo,disableFloatingGroups:c,noPanelsOverlay:"watermark",floatingGroupBounds:"boundedWithinViewport",onReady:mn,getTabContextMenuItems:p==null?fn:void 0})})]})}function Wo(){const{activeTab:o,getHeaderActions:e,headerActions:t,panelChromeActions:i,panelKey:n}=it(),l=[...(e==null?void 0:e({activeTab:o,groupActiveTab:null,groupActiveTabKey:null,isTopRightGroup:!0,panelKey:n}))??t,...i];return V.jsx(cn,{actions:l})}function Ho({actions:o,closeLabel:e,closeIcon:t="disabled_by_default",fullscreenEnterLabel:i,fullscreenExitLabel:n,fullscreenMinimizedIcon:s="open_in_full",fullscreenMinimizedLabel:l,isFullscreen:a,isMinimized:r=!1,meta:d,onClose:h,onToggleFullscreen:c,title:u}){const p=r?l??i:a?n:i,f=r?s:a?"fullscreen_exit":"fullscreen";return V.jsxs("div",{className:"dock-panel__header",children:[V.jsxs("div",{className:"dock-panel__header-main",children:[u!=null&&V.jsx("div",{className:"dock-panel__title",children:u}),d!=null&&V.jsx("span",{className:"dock-panel__meta",children:d})]}),V.jsx("div",{className:"dock-panel__header-spacer"}),(o!=null||c!=null||h!=null)&&V.jsxs("div",{className:"dock-panel__header-actions",children:[o,c!=null&&p!=null&&V.jsx(ni,{type:"text",className:"dock-panel__close-btn dock-panel__fullscreen-btn","data-dock-panel-no-resize":"true",icon:V.jsx("span",{className:"material-symbols-rounded",children:f}),title:p,"aria-label":p,onClick:c}),h!=null&&e!=null&&V.jsx(ni,{type:"text",className:["dock-panel__close-btn",t==="bottom_panel_close"||t==="bottom_panel_open"?"dock-panel__minimize-btn":""].filter(Boolean).join(" "),"data-dock-panel-no-resize":"true",icon:V.jsx("span",{className:"material-symbols-rounded",children:t}),title:e,"aria-label":e,onClick:h})]})]})}const Fo=180;function Bo(){const[o,e]=x.useState(!1),[t,i]=x.useState(!1),n=x.useRef(null),s=x.useCallback(()=>{n.current!=null&&(window.clearTimeout(n.current),n.current=null)},[]),l=x.useCallback(()=>{s(),i(!1),e(!0)},[s]),a=x.useCallback(()=>{s(),i(!0),n.current=window.setTimeout(()=>{e(!1),i(!1),n.current=null},Fo)},[s]),r=x.useCallback(()=>{if(o&&!t){a();return}l()},[l,a,o,t]);return x.useEffect(()=>s,[s]),{enterFullscreen:l,exitFullscreen:a,isFullscreen:o,isFullscreenExiting:t,toggleFullscreen:r}}const $o=240,un=180,Uo=240,It=(o,e,t)=>Math.min(Math.max(o,e),Math.max(e,t)),Ti=(o,e)=>{if(typeof o=="number")return o;const t=o==null?void 0:o.trim().match(/^(\d+(?:\.\d+)?)%$/);return t==null?un:e==null?0:Math.max(0,Math.round(e*Number(t[1])/100))},jo=o=>typeof o=="number"?`${o}px`:o,Ko=o=>(o==null?void 0:o.closest('button, a, input, textarea, select, option, [role="button"], [data-dock-panel-no-resize="true"]'))!=null;function tr({enterMotion:o="slide-up",allowResize:e=!0,allowFullscreen:t=!1,children:i,className:n,closeIcon:s,closeLabel:l,defaultHeight:a=$o,footer:r,fullscreenEnterLabel:d,fullscreenExitLabel:h,fullscreenMinimizedIcon:c,fullscreenMinimizedLabel:u,hideHeader:p=!1,isMinimized:f=!1,isResizeDisabled:m=!1,isOpen:g=!0,maxHeight:v=520,meta:b,minimizedHeight:w,minHeight:C=un,onClose:I,onExpandMinimized:E,resizeLabel:D,storageKey:G,title:M,actions:H}){const N=x.useRef(null),{isFullscreen:L,isFullscreenExiting:X,toggleFullscreen:B}=Bo(),y=L&&!f,[S,j]=x.useState(null),W=x.useMemo(()=>Ti(C,S),[S,C]),[se,$]=x.useState(()=>g&&o==="slide-up"),K=x.useRef(g),[oe,ce]=x.useState(()=>{const U=Number(localStorage.getItem(G)),ee=Ti(C,null);return Number.isFinite(U)&&U>0?It(U,ee,v):It(a,ee,v)}),J=x.useRef(oe),pe=e&&!m&&!f&&!y;x.useEffect(()=>{const U=K.current;if(K.current=g,!g||o!=="slide-up"){$(!1);return}U||$(!0)},[o,g]),x.useEffect(()=>{if(!se)return;const U=window.setTimeout(()=>$(!1),Uo);return()=>window.clearTimeout(U)},[se]);const ue=x.useCallback(()=>{var fe;const U=(fe=N.current)==null?void 0:fe.parentElement,ee=U==null?void 0:U.getBoundingClientRect().height;return ee!=null&&Number.isFinite(ee)?Math.max(0,ee):null},[]);x.useEffect(()=>{var Le;const U=()=>j(ue());U();const ee=(Le=N.current)==null?void 0:Le.parentElement;if(ee==null||typeof ResizeObserver>"u")return;const fe=new ResizeObserver(U);return fe.observe(ee),()=>fe.disconnect()},[ue]),x.useEffect(()=>{J.current=oe,localStorage.setItem(G,String(oe))},[oe,G]),x.useEffect(()=>{ce(U=>{var fe,Le;const ee=It(U,W,v);return ee===U?U:(J.current=ee,(fe=N.current)==null||fe.style.setProperty("--dock-panel-height",`${ee}px`),(Le=N.current)==null||Le.style.removeProperty("--dock-panel-resize-height"),ee)})},[W,v]);const Se=x.useCallback(()=>{const U=ue();return U!=null?Math.min(v,U-96):v},[v,ue]),de=x.useCallback(()=>{var U;return((U=N.current)==null?void 0:U.getBoundingClientRect().height)??oe},[oe]),me=x.useCallback(U=>{var ee;J.current=U,(ee=N.current)==null||ee.style.setProperty("--dock-panel-resize-height",`${U}px`)},[]),q=x.useCallback(U=>{var ee,fe;J.current=U,(ee=N.current)==null||ee.style.setProperty("--dock-panel-height",`${U}px`),(fe=N.current)==null||fe.style.removeProperty("--dock-panel-resize-height"),ce(U)},[]),Ee=yn({axis:"y",cursor:"row-resize",direction:-1,disabled:!pe,getMaxValue:Se,getStartValue:de,max:v,min:W,value:oe,onCommit:q,onPreview:me,onResizeStart:me,shouldIgnorePointerDown:Ko}),Pe=()=>{f&&(E==null||E()),B()},Ne=t||f&&E!=null,Oe=typeof i=="function"?i({isFullscreen:y,onToggleFullscreen:Pe}):i,Be=x.useMemo(()=>({"--dock-panel-height":`${oe}px`,"--dock-panel-max-height":`${v}px`,"--dock-panel-min-height":`${W}px`,...w==null?{}:{"--dock-panel-minimized-height":jo(w)}}),[W,v,w,oe]);return V.jsxs("div",{ref:N,className:`dock-panel ${se?"is-entering-slide-up":""} ${g?"is-open":"is-closing"} ${n??""} ${Ee.isResizing?"is-resizing":""} ${f?"is-minimized":""} ${pe?"is-resizable":"is-static"} ${m||f||y?"is-resize-disabled":""} ${y?"is-fullscreen":""} ${X?"is-fullscreen-exiting":""}`,style:Be,children:[pe&&V.jsx("div",{className:"dock-panel__resize-strip",role:"separator","aria-label":D,"aria-orientation":"horizontal","aria-valuemin":W,"aria-valuemax":v,"aria-valuenow":oe,tabIndex:0,title:D,onPointerDown:Ee.handlePointerDown,onKeyDown:Ee.handleKeyDown}),!p&&V.jsx(Ho,{actions:H,closeIcon:s,closeLabel:l,fullscreenEnterLabel:d,fullscreenExitLabel:h,fullscreenMinimizedIcon:c,fullscreenMinimizedLabel:u,isFullscreen:y,isMinimized:f,meta:b,title:M,onClose:I,onToggleFullscreen:Ne?Pe:void 0}),V.jsx("div",{className:"dock-panel__body",children:Oe}),r!=null&&V.jsx("div",{className:"dock-panel__footer",children:r})]})}export{tr as D,er as R};