UNPKG

dockview

Version:

Zero dependency layout manager supporting tabs, grids and splitviews with ReactJS support

21 lines (19 loc) 123 kB
/** * dockview * @version 1.0.0 * @link https://github.com/mathuo/dockview * @license MIT */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).dockview={},e.React,e.ReactDOM)}(this,(function(e,t,i){"use strict";function s(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}var n=s(t),o=s(i);!function(){var e,t;const i="DOCKVIEW_WATERMARK_SUPPRESSED";if("test"===(null===(t=null===(e=window.process)||void 0===e?void 0:e.env)||void 0===t?void 0:t.NODE_ENV))return;!!window[i]||console.log(["dockview: https://github.com/mathuo/dockview for examples and documentation","dockview: https://www.npmjs.com/package/dockview","dockview: To suppress this message set window.DOCKVIEW_WATERMARK_SUPPRESSED=1 before importing the dockview package",""].join("\n"))}(),e.Event=void 0,(e.Event||(e.Event={})).any=(...e)=>t=>{const i=e.map((e=>e(t)));return{dispose:()=>{i.forEach((e=>{e.dispose()}))}}};class r{constructor(e){this.options=e,this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=e=>{var t;return(null===(t=this.options)||void 0===t?void 0:t.replay)&&void 0!==this._last&&e(this._last),this._listeners.length,this._listeners.push(e),{dispose:()=>{const t=this._listeners.indexOf(e);t>-1&&this._listeners.splice(t,1)}}}),this._event}fire(e){this._last=e,this._listeners.forEach((t=>{t(e)}))}dispose(){this._listeners=[],this._disposed=!0}}function a(e,t,i,s){return e.addEventListener(t,i,s),{dispose:()=>{e.removeEventListener(t,i)}}}function h(e,t,i,s){return e.addEventListener(t,i,s),{dispose:()=>{e.removeEventListener(t,i)}}}e.Disposable=void 0,(e.Disposable||(e.Disposable={})).NONE={dispose:()=>{}};class d{constructor(...e){this.disposables=e}static from(...e){return new d(...e)}addDisposables(...e){null==e||e.forEach((e=>this.disposables.push(e)))}dispose(){this.disposables.forEach((e=>e.dispose()))}}class l{constructor(){this._disposable=e.Disposable.NONE}set value(e){this._disposable&&this._disposable.dispose(),this._disposable=e}dispose(){this._disposable&&this._disposable.dispose()}}class p{constructor(){}}class m extends p{constructor(e,t,i){super(),this.viewId=e,this.groupId=t,this.panelId=i}}class u extends p{constructor(e,t){super(),this.viewId=e,this.paneId=t}}const c="splitview/transfer";var v;e.DragType=void 0,(v=e.DragType||(e.DragType={})).DOCKVIEW_TAB="dockview_tab",v.EXTERNAL="external_group_drag";class g{constructor(){}static getInstance(){return g.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)}}function w(){const e=g.getInstance();if(e.hasData(m.prototype))return e.getData(m.prototype)[0]}function f(){const e=g.getInstance();if(e.hasData(u.prototype))return e.getData(u.prototype)[0]}g.INSTANCE=new g;class _{constructor(e){this.component=e}get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get height(){return this.component.height}get width(){return this.component.width}get length(){return this.component.length}get onDidLayoutChange(){return this.component.onDidLayoutChange}get orientation(){return this.component.orientation}updateOptions(e){this.component.updateOptions(e)}removePanel(e,t){this.component.removePanel(e,t)}setVisible(e,t){this.component.setVisible(e,t)}getPanels(){return this.component.getPanels()}focus(){this.component.focus()}getPanel(e){return this.component.getPanel(e)}setActive(e){this.component.setActive(e)}layout(e,t){return this.component.layout(e,t)}addPanel(e){this.component.addPanel(e)}resizeToFit(){this.component.resizeToFit()}movePanel(e,t){this.component.movePanel(e,t)}fromJSON(e,t){this.component.fromJSON(e,t)}toJSON(){return this.component.toJSON()}}class C{constructor(e){this.component=e}get width(){return this.component.width}get height(){return this.component.height}get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get onDidLayoutChange(){return this.component.onDidLayoutChange}getPanels(){return this.component.getPanels()}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)}resizeToFit(){this.component.resizeToFit()}fromJSON(e,t){this.component.fromJSON(e,t)}toJSON(){return this.component.toJSON()}}class b{constructor(e){this.component=e}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 onGridEvent(){return this.component.onGridEvent}get onDidLayoutChange(){return this.component.onDidLayoutChange}get panels(){return this.component.groups}get orientation(){return this.component.orientation}set orientation(e){this.component.updateOptions({orientation:e})}focus(){this.component.focus()}layout(e,t,i=!1){this.component.layout(e,t,i)}addPanel(e){this.component.addPanel(e)}removePanel(e,t){this.component.removePanel(e,t)}movePanel(e,t){this.component.movePanel(e,t)}resizeToFit(){this.component.resizeToFit()}getPanel(e){return this.component.getPanel(e)}toggleVisibility(e){this.component.toggleVisibility(e)}setVisible(e,t){this.component.setVisible(e,t)}setActive(e){this.component.setActive(e)}fromJSON(e,t){return this.component.fromJSON(e,t)}toJSON(){return this.component.toJSON()}}class y{constructor(e){this.component=e}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 totalPanels(){return this.component.totalPanels}get onGridEvent(){return this.component.onGridEvent}get onDidLayoutChange(){return this.component.onDidLayoutChange}get panels(){return this.component.panels}get groups(){return this.component.groups}get activePanel(){return this.component.activePanel}get activeGroup(){return this.component.activeGroup}getTabHeight(){return this.component.tabHeight}setTabHeight(e){this.component.tabHeight=e}focus(){this.component.focus()}getPanel(e){return this.component.getGroupPanel(e)}setActivePanel(e){this.component.setActivePanel(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)}addEmptyGroup(e){this.component.addEmptyGroup(e)}moveToNext(e){this.component.moveToNext(e)}moveToPrevious(e){this.component.moveToPrevious(e)}closeAllGroups(){return this.component.closeAllGroups()}removeGroup(e){this.component.removeGroup(e)}resizeToFit(){return this.component.resizeToFit()}getGroup(e){return this.component.getPanel(e)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}}function S(e,t){const i=new ResizeObserver((e=>{const i=e[0];t(i)}));return i.observe(e),{dispose:()=>{i.unobserve(e),i.disconnect()}}}const D=(e,...t)=>{for(const i of t)e.classList.contains(i)&&e.classList.remove(i)},E=(e,...t)=>{for(const i of t)e.classList.contains(i)||e.classList.add(i)},z=(e,t,i)=>{const s=e.classList.contains(t);i&&!s&&e.classList.add(t),!i&&s&&e.classList.remove(t)};function P(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}function x(e){return Array.prototype.slice.call(document.getElementsByTagName(e),0)}function A(e){return new O(e)}class O extends d{constructor(e){super(),this._onDidFocus=new r,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new r,this.onDidBlur=this._onDidBlur.event;let t=P(document.activeElement,e),i=!1;const s=()=>{i=!1,t||(t=!0,this._onDidFocus.fire())},n=()=>{t&&(i=!0,window.setTimeout((()=>{i&&(i=!1,t=!1,this._onDidBlur.fire())}),0))};this._refreshStateHandler=()=>{P(document.activeElement,e)!==t&&(t?n():s())},e instanceof HTMLElement?(this.addDisposables(h(e,"focus",s,!0)),this.addDisposables(h(e,"blur",n,!0))):(this.addDisposables(a(e,"focus",s,!0)),this.addDisposables(a(e,"blur",n,!0)))}refreshState(){this._refreshStateHandler()}dispose(){super.dispose(),this._onDidBlur.dispose(),this._onDidFocus.dispose()}}const N=(e,t,i)=>{if(t>i)throw new Error(`${t} > ${i} is an invalid condition`);return Math.min(i,Math.max(e,t))},I=()=>{let e=1;return{next:()=>(e++).toString()}};function T(e){if(0===e.length)throw new Error("Invalid tail call");return[e.slice(0,e.length-1),e[e.length-1]]}function V(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}function G(e,t){const i=e.indexOf(t);i>-1&&(e.splice(i,1),e.unshift(t))}function L(e,t){const i=e.indexOf(t);i>-1&&(e.splice(i,1),e.push(t))}const R=(e,t)=>{const i=[];if("number"!=typeof t&&(t=e,e=0),e<=t)for(let s=e;s<t;s++)i.push(s);else for(let s=e;s>t;s--)i.push(s);return i};class k{constructor(e,t,i,s){this.container=e,this.view=t,this.disposable=s,this._cachedVisibleSize=void 0,"number"==typeof i?(this._size=i,this._cachedVisibleSize=void 0,e.classList.add("visible")):(this._size=0,this._cachedVisibleSize=i.cachedVisibleSize)}set size(e){this._size=e}get size(){return this._size}get cachedVisibleSize(){return this._cachedVisibleSize}get visible(){return void 0===this._cachedVisibleSize}setVisible(e,t){var i;e!==this.visible&&(e?(this.size=N(null!==(i=this._cachedVisibleSize)&&void 0!==i?i:0,this.viewMinimumSize,this.viewMaximumSize),this._cachedVisibleSize=void 0):(this._cachedVisibleSize="number"==typeof t?t:this.size,this.size=0),this.container.classList.toggle("visible",e),this.view.setVisible&&this.view.setVisible(e))}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"}dispose(){return this.disposable.dispose(),this.view}}var H,M,F,W,B;e.Orientation=void 0,(H=e.Orientation||(e.Orientation={})).HORIZONTAL="HORIZONTAL",H.VERTICAL="VERTICAL",e.SashState=void 0,(M=e.SashState||(e.SashState={}))[M.MAXIMUM=0]="MAXIMUM",M[M.MINIMUM=1]="MINIMUM",M[M.DISABLED=2]="DISABLED",M[M.ENABLED=3]="ENABLED",e.LayoutPriority=void 0,(F=e.LayoutPriority||(e.LayoutPriority={})).Low="low",F.High="high",F.Normal="normal",e.Sizing=void 0,(W=e.Sizing||(e.Sizing={})).Distribute={type:"distribute"},W.Split=function(e){return{type:"split",index:e}},W.Invisible=function(e){return{type:"invisible",cachedVisibleSize:e}};class J{constructor(e,t){this.container=e,this.views=[],this.sashes=[],this._size=0,this._orthogonalSize=0,this.contentSize=0,this._proportions=void 0,this._onDidSashEnd=new r,this.onDidSashEnd=this._onDidSashEnd.event,this._onDidAddView=new r,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new r,this.onDidRemoveView=this._onDidAddView.event,this._startSnappingEnabled=!0,this._endSnappingEnabled=!0,this.resize=(e,t,i=this.views.map((e=>e.size)),s,n,o=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY,a,h)=>{if(e<0||e>this.views.length)return 0;const d=R(e,-1),l=R(e+1,this.views.length);if(n)for(const e of n)G(d,e),G(l,e);if(s)for(const e of s)L(d,e),L(l,e);const p=d.map((e=>this.views[e])),m=d.map((e=>i[e])),u=l.map((e=>this.views[e])),c=l.map((e=>i[e])),v=d.reduce(((e,t)=>e+this.views[t].minimumSize-i[t]),0),g=d.reduce(((e,t)=>e+this.views[t].maximumSize-i[t]),0),w=0===l.length?Number.POSITIVE_INFINITY:l.reduce(((e,t)=>e+i[t]-this.views[t].minimumSize),0),f=0===l.length?Number.NEGATIVE_INFINITY:l.reduce(((e,t)=>e+i[t]-this.views[t].maximumSize),0),_=Math.max(v,f),C=Math.min(w,g);let b=!1;if(a){const e=this.views[a.index],i=t>=a.limitDelta;b=i!==e.visible,e.setVisible(i,a.size)}if(!b&&h){const e=this.views[h.index],i=t<h.limitDelta;b=i!==e.visible,e.setVisible(i,h.size)}if(b)return this.resize(e,t,i,s,n,o,r);let y=0,S=N(t,_,C);for(let e=0;e<p.length;e++){const t=p[e],i=N(m[e]+S,t.minimumSize,t.maximumSize),s=i-m[e];y+=s,S-=s,t.size=i}let D=y;for(let e=0;e<u.length;e++){const t=u[e],i=N(c[e]-D,t.minimumSize,t.maximumSize);D+=i-c[e],t.size=i}return t},this._orientation=t.orientation,this.element=this.createContainer(),this.proportionalLayout=void 0===t.proportionalLayout||!!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(((e,t)=>{const i=void 0===e.visible||e.visible?e.size:{type:"invisible",cachedVisibleSize:e.size},s=e.view;this.addView(s,i,t,!0)})),this.contentSize=this.views.reduce(((e,t)=>e+t.size),0),this.saveProportions())}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.views.length}get proportions(){return this._proportions?[...this._proportions]:void 0}get orientation(){return this._orientation}set orientation(t){this._orientation=t;const i=this.size;this.size=this.orthogonalSize,this.orthogonalSize=i,D(this.element,"horizontal","vertical"),this.element.classList.add(this.orientation==e.Orientation.HORIZONTAL?"horizontal":"vertical")}get minimumSize(){return this.views.reduce(((e,t)=>e+t.minimumSize),0)}get maximumSize(){return 0===this.length?Number.POSITIVE_INFINITY:this.views.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())}style(e){"transparent"===(null==e?void 0:e.separatorBorder)?(D(this.element,"separator-border"),this.element.style.removeProperty("--dv-separator-border")):(E(this.element,"separator-border"),(null==e?void 0:e.separatorBorder)&&this.element.style.setProperty("--dv-separator-border",e.separatorBorder))}isViewVisible(e){if(e<0||e>=this.views.length)throw new Error("Index out of bounds");return this.views[e].visible}setViewVisible(e,t){if(e<0||e>=this.views.length)throw new Error("Index out of bounds");z(this.container,"visible",t);const i=this.views[e];z(this.container,"visible",t),i.setVisible(t,i.size),this.distributeEmptySpace(e),this.layoutViews(),this.saveProportions()}getViewSize(e){return e<0||e>=this.views.length?-1:this.views[e].size}resizeView(t,i){if(t<0||t>=this.views.length)return;const s=R(this.views.length).filter((e=>e!==t)),n=[...s.filter((t=>this.views[t].priority===e.LayoutPriority.Low)),t],o=s.filter((t=>this.views[t].priority===e.LayoutPriority.High)),r=this.views[t];i=Math.round(i),i=N(i,r.minimumSize,Math.min(r.maximumSize,this._size)),r.size=i,this.relayout(n,o)}getViews(){return this.views.map((e=>e.view))}onDidChange(e,t){const i=this.views.indexOf(e);i<0||i>=this.views.length||(t="number"==typeof t?t:e.size,t=N(t,e.minimumSize,e.maximumSize),e.size=t,this.relayout([i]))}addView(t,i={type:"distribute"},s=this.views.length,n){const o=document.createElement("div");let r;o.className="view",o.appendChild(t.element),r="number"==typeof i?i:"split"===i.type?this.getViewSize(i.index)/2:"invisible"===i.type?{cachedVisibleSize:i.cachedVisibleSize}:t.minimumSize;const a=t.onDidChange((e=>this.onDidChange(h,e))),h=new k(o,t,r,{dispose:()=>{null==a||a.dispose(),this.viewContainer.removeChild(o)}});if(s===this.views.length?this.viewContainer.appendChild(o):this.viewContainer.insertBefore(o,this.viewContainer.children.item(s)),this.views.splice(s,0,h),this.views.length>1){const t=document.createElement("div");t.className="sash";const i=i=>{for(const e of this.views)e.enabled=!1;const s=[...x("iframe"),...x("webview")];for(const e of s)e.style.pointerEvents="none";const n=this._orientation===e.Orientation.HORIZONTAL?i.clientX:i.clientY,o=function(e,t){for(let i=0;i<e.length;i++)if(t(e[i]))return i;return-1}(this.sashes,(e=>e.container===t)),r=this.views.map((e=>e.size));let a,h;const d=R(o,-1),l=R(o+1,this.views.length),p=d.reduce(((e,t)=>e+(this.views[t].minimumSize-r[t])),0),m=d.reduce(((e,t)=>e+(this.views[t].viewMaximumSize-r[t])),0),u=0===l.length?Number.POSITIVE_INFINITY:l.reduce(((e,t)=>e+(r[t]-this.views[t].minimumSize)),0),c=0===l.length?Number.NEGATIVE_INFINITY:l.reduce(((e,t)=>e+(r[t]-this.views[t].viewMaximumSize)),0),v=Math.max(p,c),g=Math.min(u,m),w=this.findFirstSnapIndex(d),f=this.findFirstSnapIndex(l);if("number"==typeof w){const e=this.views[w],t=Math.floor(e.viewMinimumSize/2);a={index:w,limitDelta:e.visible?v-t:v+t,size:e.size}}if("number"==typeof f){const e=this.views[f],t=Math.floor(e.viewMinimumSize/2);h={index:f,limitDelta:e.visible?g+t:g-t,size:e.size}}const _=t=>{const i=(this._orientation===e.Orientation.HORIZONTAL?t.clientX:t.clientY)-n;this.resize(o,i,r,void 0,void 0,v,g,a,h),this.distributeEmptySpace(),this.layoutViews()},C=()=>{for(const e of this.views)e.enabled=!0;for(const e of s)e.style.pointerEvents="auto";this.saveProportions(),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",C),document.removeEventListener("mouseend",C),this._onDidSashEnd.fire(void 0)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",C),document.addEventListener("mouseend",C)};t.addEventListener("mousedown",i);const s={container:t,disposable:()=>{t.removeEventListener("mousedown",i),this.sashContainer.removeChild(t)}};this.sashContainer.appendChild(t),this.sashes.push(s)}n||this.relayout([s]),n||"number"==typeof i||"distribute"!==i.type||this.distributeViewSizes(),this._onDidAddView.fire(t)}distributeViewSizes(){const t=[];let i=0;for(const e of this.views)e.maximumSize-e.minimumSize>0&&(t.push(e),i+=e.size);const s=Math.floor(i/t.length);for(const e of t)e.size=N(s,e.minimumSize,e.maximumSize);const n=R(this.views.length),o=n.filter((t=>this.views[t].priority===e.LayoutPriority.Low)),r=n.filter((t=>this.views[t].priority===e.LayoutPriority.High));this.relayout(o,r)}removeView(e,t,i=!1){const s=this.views.splice(e,1)[0];if(s.dispose(),this.views.length>=1){const t=Math.max(e-1,0);this.sashes.splice(t,1)[0].disposable()}return i||this.relayout(),t&&"distribute"===t.type&&this.distributeViewSizes(),this._onDidRemoveView.fire(s.view),s.view}getViewCachedVisibleSize(e){if(e<0||e>=this.views.length)throw new Error("Index out of bounds");return this.views[e].cachedVisibleSize}moveView(t,i){const s=this.getViewCachedVisibleSize(t),n=void 0===s?this.getViewSize(t):e.Sizing.Invisible(s),o=this.removeView(t,void 0,!0);this.addView(o,n,i)}layout(t,i){const s=Math.max(this.size,this.contentSize);if(this.size=t,this.orthogonalSize=i,this.proportions)for(let e=0;e<this.views.length;e++){const i=this.views[e];i.size=N(Math.round(this.proportions[e]*t),i.minimumSize,i.maximumSize)}else{const i=R(this.views.length),n=i.filter((t=>this.views[t].priority===e.LayoutPriority.Low)),o=i.filter((t=>this.views[t].priority===e.LayoutPriority.High));this.resize(this.views.length-1,t-s,void 0,n,o)}this.distributeEmptySpace(),this.layoutViews()}relayout(e,t){const i=this.views.reduce(((e,t)=>e+t.size),0);this.resize(this.views.length-1,this._size-i,void 0,e,t),this.distributeEmptySpace(),this.layoutViews(),this.saveProportions()}distributeEmptySpace(t){const i=this.views.reduce(((e,t)=>e+t.size),0);let s=this.size-i;const n=R(this.views.length-1,-1),o=n.filter((t=>this.views[t].priority===e.LayoutPriority.Low)),r=n.filter((t=>this.views[t].priority===e.LayoutPriority.High));for(const e of r)G(n,e);for(const e of o)L(n,e);"number"==typeof t&&L(n,t);for(let e=0;0!==s&&e<n.length;e++){const t=this.views[n[e]],i=N(t.size+s,t.minimumSize,t.maximumSize);s-=i-t.size,t.size=i}}saveProportions(){this.proportionalLayout&&this.contentSize>0&&(this._proportions=this.views.map((e=>e.size/this.contentSize)))}layoutViews(){this.contentSize=this.views.reduce(((e,t)=>e+t.size),0);let t=0;const i=[];this.updateSashEnablement();for(let s=0;s<this.views.length-1;s++){t+=this.views[s].size,i.push(t);const n=Math.min(Math.max(0,t-2),this.size-4);this._orientation===e.Orientation.HORIZONTAL&&(this.sashes[s].container.style.left=`${n}px`,this.sashes[s].container.style.top="0px"),this._orientation===e.Orientation.VERTICAL&&(this.sashes[s].container.style.left="0px",this.sashes[s].container.style.top=`${n}px`)}this.views.forEach(((t,s)=>{this._orientation===e.Orientation.HORIZONTAL&&(t.container.style.width=`${t.size}px`,t.container.style.left=0==s?"0px":`${i[s-1]}px`,t.container.style.top="",t.container.style.height=""),this._orientation===e.Orientation.VERTICAL&&(t.container.style.height=`${t.size}px`,t.container.style.top=0==s?"0px":`${i[s-1]}px`,t.container.style.width="",t.container.style.left=""),t.view.layout(t.size,this._orthogonalSize)}))}findFirstSnapIndex(e){for(const t of e){const e=this.views[t];if(e.visible&&e.snap)return t}for(const t of e){const e=this.views[t];if(e.visible&&e.maximumSize-e.minimumSize>0)return;if(!e.visible&&e.snap)return t}}updateSashEnablement(){let t=!1;const i=this.views.map((e=>t=e.size-e.minimumSize>0||t));t=!1;const s=this.views.map((e=>t=e.maximumSize-e.size>0||t)),n=[...this.views].reverse();t=!1;const o=n.map((e=>t=e.size-e.minimumSize>0||t)).reverse();t=!1;const r=n.map((e=>t=e.maximumSize-e.size>0||t)).reverse();let a=0;for(let t=0;t<this.sashes.length;t++){const n=this.sashes[t];a+=this.views[t].size;const h=!(i[t]&&r[t+1]),d=!(s[t]&&o[t+1]);if(h&&d){const s=R(t,-1),r=R(t+1,this.views.length),h=this.findFirstSnapIndex(s),d=this.findFirstSnapIndex(r),l="number"==typeof h&&!this.views[h].visible,p="number"==typeof d&&!this.views[d].visible;l&&o[t]&&(a>0||this.startSnappingEnabled)?this.updateSash(n,e.SashState.MINIMUM):p&&i[t]&&(a<this.contentSize||this.endSnappingEnabled)?this.updateSash(n,e.SashState.MAXIMUM):this.updateSash(n,e.SashState.DISABLED)}else h&&!d?this.updateSash(n,e.SashState.MINIMUM):!h&&d?this.updateSash(n,e.SashState.MAXIMUM):this.updateSash(n,e.SashState.ENABLED)}}updateSash(t,i){z(t.container,"disabled",i===e.SashState.DISABLED),z(t.container,"enabled",i===e.SashState.ENABLED),z(t.container,"maximum",i===e.SashState.MAXIMUM),z(t.container,"minimum",i===e.SashState.MINIMUM)}createViewContainer(){const e=document.createElement("div");return e.className="view-container",e}createSashContainer(){const e=document.createElement("div");return e.className="sash-container",e}createContainer(){const t=document.createElement("div"),i=this._orientation===e.Orientation.HORIZONTAL?"horizontal":"vertical";return t.className=`split-view-container ${i}`,t}dispose(){this._onDidSashEnd.dispose(),this._onDidAddView.dispose(),this._onDidRemoveView.dispose(),this.element.remove();for(let e=0;e<this.element.children.length;e++)if(this.element.children.item(e)===this.element){this.element.removeChild(this.element);break}}}class j extends d{constructor(t,i){var s;super(),this.paneItems=[],this._onDidChange=new r,this.onDidChange=this._onDidChange.event,this.skipAnimation=!1,this._orientation=null!==(s=i.orientation)&&void 0!==s?s:e.Orientation.VERTICAL,this.element=document.createElement("div"),this.element.className="pane-container",t.appendChild(this.element),this.splitview=new J(this.element,{orientation:this._orientation,proportionalLayout:!1,descriptor:i.descriptor}),this.getPanes().forEach(((e,t)=>{const i=new d(e.onDidChangeExpansionState((()=>{this.setupAnimation(),this._onDidChange.fire(void 0)}))),s={pane:e,disposable:{dispose:()=>{i.dispose()}}};this.paneItems.push(s),e.orthogonalSize=this.splitview.orthogonalSize})),this.addDisposables(this.splitview.onDidSashEnd((()=>{this._onDidChange.fire(void 0)})),this.splitview.onDidAddView((()=>{this._onDidChange.fire()})),this.splitview.onDidRemoveView((()=>{this._onDidChange.fire()})))}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}addPane(e,t,i=this.splitview.length,s=!1){const n=e.onDidChangeExpansionState((()=>{this.setupAnimation(),this._onDidChange.fire(void 0)})),o={pane:e,disposable:{dispose:()=>{n.dispose()}}};this.paneItems.splice(i,0,o),e.orthogonalSize=this.splitview.orthogonalSize,this.splitview.addView(e,t,i,s)}getViewSize(e){return this.splitview.getViewSize(e)}getPanes(){return this.splitview.getViews()}removePane(e){const t=this.paneItems.splice(e,1)[0];return this.splitview.removeView(e),t.disposable.dispose(),t}moveView(e,t){if(e===t)return;const i=this.removePane(e);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),E(this.element,"animated"),this.animationTimer=setTimeout((()=>{this.animationTimer=void 0,D(this.element,"animated")}),200))}dispose(){super.dispose(),this.splitview.dispose(),this.animationTimer&&(clearTimeout(this.animationTimer),this.animationTimer=void 0),this.paneItems.forEach((e=>{e.disposable.dispose()})),this.paneItems=[],this.element.remove()}}class U extends d{constructor(e,t){super(),this.element=e,this.callbacks=t,this.counter=0,this.registerListeners()}registerListeners(){this.addDisposables(h(this.element,"dragenter",(e=>{this.counter++,this.callbacks.onDragEnter(e)}))),this.addDisposables(h(this.element,"dragover",(e=>{e.preventDefault(),this.callbacks.onDragOver&&this.callbacks.onDragOver(e)}))),this.addDisposables(h(this.element,"dragleave",(e=>{this.counter--,0===this.counter&&this.callbacks.onDragLeave(e)}))),this.addDisposables(h(this.element,"dragend",(e=>{this.counter=0,this.callbacks.onDragEnd(e)}))),this.addDisposables(h(this.element,"drop",(e=>{this.counter=0,this.callbacks.onDrop(e)})))}}e.Position=void 0,(B=e.Position||(e.Position={})).Top="Top",B.Left="Left",B.Bottom="Bottom",B.Right="Right",B.Center="Center";class K extends d{constructor(t,i){super(),this.element=t,this.options=i,this._onDrop=new r,this.onDrop=this._onDrop.event,this.addDisposables(new U(this.element,{onDragEnter:e=>{},onDragOver:t=>{if("boolean"==typeof this.options.canDisplayOverlay){if(!this.options.canDisplayOverlay)return}else if(!this.options.canDisplayOverlay(t))return;if(this.target||(this.target=document.createElement("div"),this.target.className="drop-target-dropzone",this.overlay=document.createElement("div"),this.overlay.className="drop-target-selection",this._state=e.Position.Center,this.target.appendChild(this.overlay),this.element.classList.add("drop-target"),this.element.append(this.target)),"none"===this.options.validOverlays)return;if(!this.target||!this.overlay)return;const i=this.target.clientWidth,s=this.target.clientHeight;if(0===i||0===s)return;const n=100*t.offsetX/i,o=100*t.offsetY/s;let r=!1,a=!1,h=!1,d=!1;switch(this.options.validOverlays){case"all":r=n>80,a=n<20,h=!r&&!a&&o<20,d=!r&&!a&&o>80;break;case"vertical":h=o<50,d=o>=50;break;case"horizontal":a=n<50,r=n>=50}const l=i<100,p=s<100;z(this.overlay,"right",!l&&r),z(this.overlay,"left",!l&&a),z(this.overlay,"top",!p&&h),z(this.overlay,"bottom",!p&&d),z(this.overlay,"small-right",l&&r),z(this.overlay,"small-left",l&&a),z(this.overlay,"small-top",p&&h),z(this.overlay,"small-bottom",p&&d),this._state=r?e.Position.Right:a?e.Position.Left:h?e.Position.Top:d?e.Position.Bottom:e.Position.Center},onDragLeave:e=>{this.removeDropTarget()},onDragEnd:e=>{this.removeDropTarget()},onDrop:e=>{e.preventDefault(),e.stopPropagation();const t=this._state;this.removeDropTarget(),t&&this._onDrop.fire({position:t,event:e})}}))}get state(){return this._state}set validOverlays(e){this.options.validOverlays=e}set canDisplayOverlay(e){this.options.canDisplayOverlay=e}dispose(){this._onDrop.dispose(),this.removeDropTarget()}removeDropTarget(){this.target&&(this._state=void 0,this.element.removeChild(this.target),this.target=void 0,this.element.classList.remove("drop-target"))}}class ${constructor(t,i,s,n=0){this.view=t,this.orientation=i,this._onDidChange=new r,this.onDidChange=this._onDidChange.event,this._orthogonalSize=s,this._size=n,this._disposable=this.view.onDidChange((t=>{t?this._onDidChange.fire(this.orientation===e.Orientation.VERTICAL?t.width:t.height):this._onDidChange.fire(void 0)}))}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===e.Orientation.HORIZONTAL?this.minimumHeight:this.minimumWidth}get maximumSize(){return this.orientation===e.Orientation.HORIZONTAL?this.maximumHeight:this.maximumWidth}get minimumOrthogonalSize(){return this.orientation===e.Orientation.HORIZONTAL?this.minimumWidth:this.minimumHeight}get maximumOrthogonalSize(){return this.orientation===e.Orientation.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===e.Orientation.HORIZONTAL?this.orthogonalSize:this.size}get height(){return this.orientation===e.Orientation.HORIZONTAL?this.size:this.orthogonalSize}setVisible(e){this.view.setVisible&&(this.view.setVisible(e),this._onDidChange.fire(void 0))}layout(e,t){this._size=e,this._orthogonalSize=t,this.view.layout(this.width,this.height)}dispose(){this._disposable.dispose()}}class Z extends d{constructor(t,i,s,n,o,a){if(super(),this.orientation=t,this.proportionalLayout=i,this.styles=s,this.children=[],this._onDidChange=new r,this.onDidChange=this._onDidChange.event,this._childrenDisposable=e.Disposable.NONE,this._orthogonalSize=o,this._size=n,this.element=document.createElement("div"),this.element.className="branch-node",a){const e={views:a.map((e=>({view:e.node,size:e.node.size,visible:!(e.node instanceof $&&void 0!==e.visible)||e.visible}))),size:this.orthogonalSize};this.children=a.map((e=>e.node)),this.splitview=new J(this.element,{orientation:this.orientation,descriptor:e,proportionalLayout:i})}else this.splitview=new J(this.element,{orientation:this.orientation,proportionalLayout:i,styles:s}),this.splitview.layout(this.size,this.orthogonalSize);this.addDisposables(this.splitview.onDidSashEnd((()=>{this._onDidChange.fire(void 0)}))),this.setupChildrenEvents()}get width(){return this.orientation===e.Orientation.HORIZONTAL?this.size:this.orthogonalSize}get height(){return this.orientation===e.Orientation.HORIZONTAL?this.orthogonalSize:this.size}get minimumSize(){return 0===this.children.length?0:Math.max(...this.children.map((e=>e.minimumOrthogonalSize)))}get maximumSize(){return Math.min(...this.children.map((e=>e.maximumOrthogonalSize)))}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===e.Orientation.HORIZONTAL?this.minimumOrthogonalSize:this.minimumSize}get minimumHeight(){return this.orientation===e.Orientation.HORIZONTAL?this.minimumSize:this.minimumOrthogonalSize}get maximumWidth(){return this.orientation===e.Orientation.HORIZONTAL?this.maximumOrthogonalSize:this.maximumSize}get maximumHeight(){return this.orientation===e.Orientation.HORIZONTAL?this.maximumSize:this.maximumOrthogonalSize}get priority(){if(0===this.children.length)return e.LayoutPriority.Normal;const t=this.children.map((t=>void 0===t.priority?e.LayoutPriority.Normal:t.priority));return t.some((t=>t===e.LayoutPriority.High))?e.LayoutPriority.High:t.some((t=>t===e.LayoutPriority.Low))?e.LayoutPriority.Low:e.LayoutPriority.Normal}setVisible(e){for(const t of this.children)t.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");this.splitview.isViewVisible(e)!==t&&this.splitview.setViewVisible(e,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(this.size,this.orthogonalSize)}addChild(e,t,i,s){if(i<0||i>this.children.length)throw new Error("Invalid index");this.splitview.addView(e,t,i,s),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");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=e.Event.any(...this.children.map((e=>e.onDidChange)))((e=>{this._onDidChange.fire(void 0)}))}dispose(){super.dispose(),this._childrenDisposable.dispose(),this.children.forEach((e=>e.dispose())),this.splitview.dispose()}}function Y(e,t,i){if(e instanceof Z){const s=new Z(ie(e.orientation),e.proportionalLayout,e.styles,t,i);let n=0;for(let o=e.children.length-1;o>=0;o--){const r=e.children[o],a=r instanceof Z?r.orthogonalSize:r.size;let h=0===e.size?0:Math.round(t*a/e.size);n+=h,0===o&&(h+=t-n),s.addChild(Y(r,i,h),h,0,!0)}return s}return new $(e.view,ie(e.orientation),i)}function X(e){const t=e.parentElement;if(!t)throw new Error("Invalid grid element");let i=t.firstElementChild,s=0;for(;i!==e&&i!==t.lastElementChild&&i;)i=i.nextElementSibling,s++;return s}function q(e){const t=e.parentElement;if(!t)throw new Error("Invalid grid element");if(/\bgrid-view\b/.test(t.className))return[];const i=X(t);return[...q(t.parentElement.parentElement.parentElement),i]}function Q(t,i,s){if(te(t,i)===ee(s)){const[t,n]=T(i);let o=n;return s!==e.Position.Right&&s!==e.Position.Bottom||(o+=1),[...t,o]}{const t=s===e.Position.Right||s===e.Position.Bottom?1:0;return[...i,t]}}function ee(t){return t===e.Position.Top||t===e.Position.Bottom?e.Orientation.VERTICAL:e.Orientation.HORIZONTAL}function te(e,t){return t.length%2==0?ie(e):e}const ie=t=>t===e.Orientation.HORIZONTAL?e.Orientation.VERTICAL:e.Orientation.HORIZONTAL;function se(e){return!!e.children}const ne=(t,i)=>{const s=i===e.Orientation.VERTICAL?t.box.width:t.box.height;return se(t)?{type:"branch",data:t.children.map((e=>ne(e,ie(i)))),size:s}:"number"==typeof t.cachedVisibleSize?{type:"leaf",data:t.view.toJSON(),size:t.cachedVisibleSize,visible:!1}:{type:"leaf",data:t.view.toJSON(),size:s}};class oe{constructor(e,t,i){this.proportionalLayout=e,this.styles=t,this.disposable=new l,this._onDidChange=new r,this.onDidChange=this._onDidChange.event,this.element=document.createElement("div"),this.element.className="grid-view",this.root=new Z(i,e,t,0,0)}serialize(){return{root:ne(this.getView(),this.orientation),width:this.width,height:this.height,orientation:this.orientation}}dispose(){this.disposable.dispose(),this._onDidChange.dispose(),this.root.dispose()}clear(){const e=this.root.orientation;this.root=new Z(e,this.proportionalLayout,this.styles,this.root.size,this.root.orthogonalSize)}deserialize(e,t){const i=e.orientation,s=e.height;this._deserialize(e.root,i,t,s)}_deserialize(e,t,i,s){this.root=this._deserializeNode(e,t,i,s)}_deserializeNode(e,t,i,s){let n;if("branch"===e.type){const o=e.data.map((s=>({node:this._deserializeNode(s,ie(t),i,e.size),visible:s.visible})));n=new Z(t,this.proportionalLayout,this.styles,e.size,s,o)}else n=new $(i.fromJSON(e),t,s,e.size);return n}get orientation(){return this.root.orientation}set orientation(e){if(this.root.orientation===e)return;const{size:t,orthogonalSize:i}=this.root;this.root=Y(this.root,i,t),this.root.layout(t,i)}get root(){return this._root}set root(e){const t=this._root;t&&(t.dispose(),this.element.removeChild(t.element)),this._root=e,this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange((e=>{this._onDidChange.fire(e)}))}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 s={height:e.height,width:e.width};if(e instanceof $)return{box:s,view:e.view,cachedVisibleSize:i};const n=[];for(let i=0;i<e.children.length;i++){const s=e.children[i],o=e.getChildCachedVisibleSize(i);n.push(this._getViews(s,ie(t),o))}return{box:s,children:n}}progmaticSelect(e,t=!1){const[i,s]=this.getNode(e);if(!(s instanceof $))throw new Error("invalid location");const n=(e,t)=>{if(e instanceof $)return e;if(e instanceof Z)return n(e.children[t?e.children.length-1:0],t);throw new Error("invalid node")};for(let s=i.length-1;s>-1;s--){const o=i[s],r=e[s]||0;if(t?r-1>-1:r+1<o.children.length)return n(o.children[t?r-1:r+1],t)}return n(this.root,t)}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}isViewVisible(e){const[t,i]=T(e),[,s]=this.getNode(t);if(!(s instanceof Z))throw new Error("Invalid from location");return s.isChildVisible(i)}setViewVisible(e,t){const[i,s]=T(e),[,n]=this.getNode(i);if(!(n instanceof Z))throw new Error("Invalid from location");n.setChildVisible(s,t)}moveView(e,t,i){const[,s]=this.getNode(e);if(!(s instanceof Z))throw new Error("Invalid location");s.moveChild(t,i)}addView(t,i,s){const[n,o]=T(s),[r,a]=this.getNode(n);if(a instanceof Z){const e=new $(t,ie(a.orientation),a.orthogonalSize);a.addChild(e,i,o)}else{const[s,...h]=[...r].reverse(),[d,...l]=[...n].reverse();let p=0;const m=s.getChildCachedVisibleSize(d);"number"==typeof m&&(p=e.Sizing.Invisible(m)),s.removeChild(d);const u=new Z(a.orientation,this.proportionalLayout,this.styles,a.size,a.orthogonalSize);s.addChild(u,a.size,d);const c=new $(a.view,s.orientation,a.size);u.addChild(c,p,0),"number"!=typeof i&&"split"===i.type&&(i={type:"split",index:0});const v=new $(t,s.orientation,a.size);u.addChild(v,i,o)}}remove(e,t){const i=q(e.element);return this.removeView(i,t)}removeView(t,i){const[s,n]=T(t),[o,r]=this.getNode(s);if(!(r instanceof Z))throw new Error("Invalid location");const a=r.children[n];if(!(a instanceof $))throw new Error("Invalid location");if(r.removeChild(n,i),0===r.children.length)return a.view;if(r.children.length>1)return a.view;if(0===o.length){const e=r.children[0];return e instanceof $||(r.removeChild(0,i),this.root=e),a.view}const[h,...d]=[...o].reverse(),[l,...p]=[...s].reverse(),m=r.children[0],u=r.isChildVisible(0);r.removeChild(0,i);const c=h.children.map(((e,t)=>h.getChildSize(t)));if(h.removeChild(l,i),m instanceof Z){c.splice(l,1,...m.children.map((e=>e.size)));for(let e=0;e<m.children.length;e++){const t=m.children[e];h.addChild(t,t.size,l+e)}}else{const t=new $(m.view,ie(m.orientation),m.size),i=u?m.orthogonalSize:e.Sizing.Invisible(m.orthogonalSize);h.addChild(t,i,l)}for(let e=0;e<c.length;e++)h.resizeChild(e,c[e]);return a.view}layout(t,i){const[s,n]=this.root.orientation===e.Orientation.HORIZONTAL?[i,t]:[t,i];this.root.layout(s,n)}getNode(e,t=this.root,i=[]){if(0===e.length)return[i,t];if(!(t instanceof Z))throw new Error("Invalid location");const[s,...n]=e;if(s<0||s>=t.children.length)throw new Error("Invalid location");const o=t.children[s];return i.push(t),this.getNode(n,o,i)}} /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */function re(e,t,i,s){return new(i||(i=Promise))((function(n,o){function r(e){try{h(s.next(e))}catch(e){o(e)}}function a(e){try{h(s.throw(e))}catch(e){o(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}h((s=s.apply(e,t||[])).next())}))}class ae extends d{constructor(){super(),this.disposable=new l,this._onDidFocus=new r,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new r,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="content-container",this._element.tabIndex=-1}get element(){return this._element}show(){this.element.style.display=""}hide(){this.element.style.display="none"}openPanel(e){var t;if(this.panel===e)return;this.panel&&((null===(t=this.panel.view)||void 0===t?void 0:t.content)&&this._element.removeChild(this.panel.view.content.element),this.panel=void 0),this.panel=e;const i=new d;if(this.panel.view){const e=this.panel.view.content.onDidFocus,t=this.panel.view.content.onDidBlur,{onDidFocus:s,onDidBlur:n}=A(this._element);i.addDisposables(s((()=>this._onDidFocus.fire())),n((()=>this._onDidBlur.fire()))),e&&i.addDisposables(e((()=>this._onDidFocus.fire()))),t&&i.addDisposables(t((()=>this._onDidBlur.fire()))),this._element.appendChild(this.panel.view.content.element)}this.disposable.value=i}layout(e,t){}closePanel(){var e,t,i;(null===(i=null===(t=null===(e=this.panel)||void 0===e?void 0:e.view)||void 0===t?void 0:t.content)||void 0===i?void 0:i.element)&&(this._element.removeChild(this.panel.view.content.element),this.panel=void 0)}dispose(){this.disposable.dispose(),super.dispose()}}var he,de,le,pe;!function(e){e[e.Tab=0]="Tab",e[e.Panel=1]="Panel",e[e.TabContainer=2]="TabContainer"}(he||(he={})),e.MouseEventKind=void 0,(de=e.MouseEventKind||(e.MouseEventKind={})).CLICK="CLICK",de.CONTEXT_MENU="CONTEXT_MENU";class me extends d{constructor(t,i,s){super(),this.panelId=t,this.accessor=i,this.group=s,this._onChanged=new r,this.onChanged=this._onChanged.event,this._onDropped=new r,this.onDrop=this._onDropped.event,this.panelTransfer=g.getInstance(),this.iframes=[],this.addDisposables(this._onChanged,this._onDropped),this._element=document.createElement("div"),this._element.className="tab",this._element.tabIndex=0,this._element.draggable=!0,this.addDisposables(h(this._element,"dragstart",(e=>{this.iframes=[...x("iframe"),...x("webview")];for(const e of this.iframes)e.style.pointerEvents="none";this.element.classList.add("dragged"),setTimeout((()=>this.element.classList.remove("dragged")),0),this.panelTransfer.setData([new m(this.accessor.id,this.group.id,this.panelId)],m.prototype),e.dataTransfer&&(e.dataTransfer.effectAllowed="move")})),h(this._element,"dragend",(e=>{for(const e of this.iframes)e.style.pointerEvents="auto";this.iframes=[],this.panelTransfer.clearData(m.prototype)})),h(this._element,"mousedown",(t=>{t.defaultPrevented||(t.stopPropagation(),this._onChanged.fire({kind:e.MouseEventKind.CLICK,event:t}))})),h(this._element,"contextmenu",(t=>{this._onChanged.fire({kind:e.MouseEventKind.CONTEXT_MENU,event:t})}))),this.droptarget=new K(this._element,{validOverlays:"none",canDisplayOverlay:e=>{const t=w();return t?this.panelId!==t.panelId:this.group.model.canDisplayOverlay(e,he.Tab)}}),this.addDisposables(this.droptarget.onDrop((e=>{this._onDropped.fire(e)})))}get element(){return this._element}setActive(e){z(this.element,"active-tab",e),z(this.element,"inactive-tab",!e)}setContent(e){this.content&&this._element.removeChild(this.content.element),this.content=e,this._element.appendChild(this.content.element)}dispose(){super.dispose(),this.droptarget.dispose()}}class ue extends d{constructor(e,t,i){super(),this.accessor=e,this.group=t,this.tabs=[],this.selectedIndex=-1,this.active=!1,this._onDrop=new r,this.onDrop=this._onDrop.event,this.addDisposables(this._onDrop),this._element=document.createElement("div"),this._element.className="tabs-and-actions-container",this.height=i.tabHeight,this.actionContainer=document.createElement("div"),this.actionContainer.className="action-container",this.tabContainer=document.createElement("div"),this.tabContainer.className="tabs-container",this.voidContainer=document.createElement("div"),this.voidContainer.className="void-container",this._element.appendChild(this.tabContainer),this._element.appendChild(this.voidContainer),this._element.appendChild(this.actionContainer),this.voidDropTarget=new K(this.voidContainer,{validOverlays:"none",canDisplayOverlay:e=>{var i;const s=w();return s?(null===(i=(n=this.tabs).length>0?n[n.length-1]:void 0)||void 0===i?void 0:i.value.panelId)!==s.panelId:t.model.canDisplayOverlay(e,he.Panel);var n}}),this.addDisposables(this.voidDropTarget.onDrop((e=>{this._onDrop.fire({event:e.event,index:this.tabs.length})})),this.voidDropTarget,h(this.tabContainer,"mousedown",(e=>{if(e.defaultPrevented)return;0===e.button&&this.accessor.doSetGroupActive(this.group)})))}get panels(){return this.tabs.map((e=>e.value.panelId))}get size(){return this.tabs.length}get height(){return this._height}set height(e){this._height=e,"number"!=typeof e?this.element.style.removeProperty("--dv-tabs-and-actions-container-height"):this.element.style.setProperty("--dv-tabs-and-actions-container-height",`${e}px`)}show(){this.element.style.display=""}hide(){this.element.style.display="none"}setActionElement(e){this.actions!==e&&(this.actions&&(this.actions.remove(),this.actions=void 0),e&&(this.actionContainer.appendChild(e),this.actions=e))}get element(){return this._element}isActive(e){return this.selectedIndex>-1&&this.tabs[this.selectedIndex].value===e}at(e){var t;return null===(t=this.tabs[e])||void 0===t?void 0:t.value}indexOf(e){return this.tabs.findIndex((t=>t.value.panelId===e))}setActive(e){this.active=e}addTab(e,t=this.tabs.length){if(t<0||t>this.tabs.length)throw new Error("invalid location");this.tabContainer.insertBefore(e.value.element,this.tabContainer.children[t]),this.tabs=[...this.tabs.slice(0,t),e,...this.tabs.slice(t)],this.selectedIndex<0&&(this.selectedIndex=t)}delete(e){const t=this.tabs.findIndex((t=>t.value.panelId===e)),i=this.tabs.splice(t,1)[0],{value:s,disposable:n}=i;n.dispose(),s.element.remove()}setActivePanel(e){this.tabs.forEach((t=>{const i=e.id===t.value.panelId;t.value.setActive(i)}))}openPanel(t,i=this.tabs.length){var s;if(this.tabs.find((e=>e.value.panelId===t.id)))return;const n=new me(t.id,this.accessor,this.group);if(!(null===(s=t.view)||void 0===s?void 0:s.tab))throw new Error("invalid header component");n.setContent(t.view.tab);const o=d.from(n.onChanged((i=>{var s;const n=t.id===(null===(s=this.group.model.activePanel)||void 0===s?void 0:s.id)&&this.group.model.isContentFocused();this.accessor.fireMouseEvent(Object.assign(Object.assign({},i),{panel:t,tab:!0}));if(0===i.event.button&&!i.event.defaultPrevented&&i.kind===e.MouseEventKind.CLICK)this.group.model.openPanel(t,{skipFocus:n})})),n.onDrop((e=>{this._onDrop.fire({event:e.event,index:this.tabs.findIndex((e=>e.value===n))})}))),r={value:n,disposable:o};this.addTab(r,i),this.activePanel=t}closePanel(e){this.delete(e.id)}dispose(){super.dispose(),this.tabs.forEach((e=>{e.disposable.dispose()})),this.tabs=[]}}e.GroupChangeKind2=void 0,(le=e.GroupChangeKind2||(e.GroupChangeKind2={})).ADD_PANEL="ADD_PANEL",le.REMOVE_PANEL="REMOVE_PANEL",le.PANEL_ACTIVE="PANEL_ACTIVE",le.GROUP_ACTIVE="GROUP_ACTIVE";class ce extends d{constructor(t,i,s,n,o){super(),this.container=t,this.accessor=i,this.id=s,this.options=n,this.parent=o,this._isGroupActive=!1,this.mostRecentlyUsed=[],this._onDidChange=new r,this.onDidChange=this._onDidChange.event,this._width=0,this._height=0,this._panels=[],this._onMove=new r,this.onMove=this._onMove.event,this._onDidGroupChange=new r,this.onDidGroupChange=this._onDidGroupChange.event,this.closePanel=e=>re(this,void 0,void 0,(function*(){return!(e.close&&!(yield e.close()))&&(this.doClose(e),!0)})),this.container.classList.add("groupview"),this.addDisposables(this._onMove,this._onDidGroupChange),th