dockview 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/api/component.api.d.ts +3 -3
- package/dist/cjs/api/component.api.js +3 -3
- package/dist/cjs/groupview/groupview.js +6 -3
- package/dist/cjs/groupview/groupview.js.map +1 -1
- package/dist/cjs/groupview/tab.js +1 -0
- package/dist/cjs/groupview/tab.js.map +1 -1
- package/dist/cjs/groupview/titlebar/tabsContainer.d.ts +1 -3
- package/dist/cjs/groupview/titlebar/tabsContainer.js +2 -4
- package/dist/cjs/groupview/titlebar/tabsContainer.js.map +1 -1
- package/dist/dockview.amd.js +12 -11
- package/dist/dockview.amd.min.js +2 -2
- package/dist/dockview.amd.min.noStyle.js +2 -2
- package/dist/dockview.amd.noStyle.js +12 -11
- package/dist/dockview.cjs.js +12 -11
- package/dist/dockview.esm.js +12 -11
- package/dist/dockview.esm.min.js +2 -2
- package/dist/dockview.js +12 -11
- package/dist/dockview.min.js +2 -2
- package/dist/dockview.min.noStyle.js +2 -2
- package/dist/dockview.noStyle.js +12 -11
- package/dist/esm/api/component.api.d.ts +3 -3
- package/dist/esm/api/component.api.js +3 -3
- package/dist/esm/groupview/groupview.js +5 -3
- package/dist/esm/groupview/tab.js +1 -0
- package/dist/esm/groupview/titlebar/tabsContainer.d.ts +1 -3
- package/dist/esm/groupview/titlebar/tabsContainer.js +2 -4
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dockview
|
|
3
|
-
* @version 1.4.
|
|
3
|
+
* @version 1.4.2
|
|
4
4
|
* @link https://github.com/mathuo/dockview
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
define(["exports","react","react-dom"],(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,o=s(t),r=s(i);class a{constructor(){}}class h extends a{constructor(e,t,i){super(),this.viewId=e,this.groupId=t,this.panelId=i}}class d extends a{constructor(e,t){super(),this.viewId=e,this.paneId=t}}class l{constructor(){}static getInstance(){return l.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 p(){const e=l.getInstance();if(e.hasData(h.prototype))return e.getData(h.prototype)[0]}function m(){const e=l.getInstance();if(e.hasData(d.prototype))return e.getData(d.prototype)[0]}l.INSTANCE=new l,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 u{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.push(e),{dispose:()=>{const t=this._listeners.indexOf(e);t>-1&&this._listeners.splice(t,1)}}}),this._event}fire(e){this._last=e;for(const t of this._listeners)t(e)}dispose(){this._listeners=[],this._disposed=!0}}function c(e,t,i,s){return e.addEventListener(t,i,s),{dispose:()=>{e.removeEventListener(t,i)}}}function v(e,t,i,s){return e.addEventListener(t,i,s),{dispose:()=>{e.removeEventListener(t,i)}}}class g{constructor(){this._onFired=new u,this.onEvent=this._onFired.event}fire(){this.timer&&clearTimeout(this.timer),this.timer=setTimeout((()=>{this._onFired.fire(),clearTimeout(this.timer)}))}dispose(){this._onFired.dispose()}}!function(e){e.NONE={dispose:()=>{}}}(n||(n={}));class w{constructor(...e){this.disposables=e}static from(...e){return new w(...e)}addDisposables(...e){e.forEach((e=>this.disposables.push(e)))}dispose(){this.disposables.forEach((e=>e.dispose()))}}class _{constructor(){this._disposable=n.NONE}set value(e){this._disposable&&this._disposable.dispose(),this._disposable=e}dispose(){this._disposable&&(this._disposable.dispose(),this._disposable=n.NONE)}}function f(e,t){const i=new ResizeObserver((e=>{const i=e[0];t(i)}));return i.observe(e),{dispose:()=>{i.unobserve(e),i.disconnect()}}}const C=(e,...t)=>{for(const i of t)e.classList.contains(i)&&e.classList.remove(i)},b=(e,...t)=>{for(const i of t)e.classList.contains(i)||e.classList.add(i)},D=(e,t,i)=>{const s=e.classList.contains(t);i&&!s&&e.classList.add(t),!i&&s&&e.classList.remove(t)};function y(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}function S(e){return Array.prototype.slice.call(document.getElementsByTagName(e),0)}function z(e){return new E(e)}class E extends w{constructor(e){super(),this._onDidFocus=new u,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new u,this.onDidBlur=this._onDidBlur.event;let t=y(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=()=>{y(document.activeElement,e)!==t&&(t?n():s())},e instanceof HTMLElement?(this.addDisposables(v(e,"focus",s,!0)),this.addDisposables(v(e,"blur",n,!0))):(this.addDisposables(c(e,"focus",s,!0)),this.addDisposables(c(e,"blur",n,!0)))}refreshState(){this._refreshStateHandler()}dispose(){super.dispose(),this._onDidBlur.dispose(),this._onDidFocus.dispose()}}const x=(e,t,i)=>{if(t>i)throw new Error(`${t} > ${i} is an invalid condition`);return Math.min(i,Math.max(e,t))},P=()=>{let e=1;return{next:()=>(e++).toString()}};function A(e){if(0===e.length)throw new Error("Invalid tail call");return[e.slice(0,e.length-1),e[e.length-1]]}function O(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 N(e,t){const i=e.indexOf(t);i>-1&&(e.splice(i,1),e.unshift(t))}function V(e,t){const i=e.indexOf(t);i>-1&&(e.splice(i,1),e.push(t))}const I=(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 L{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=x(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 T,G,R,k,H;e.Orientation=void 0,(T=e.Orientation||(e.Orientation={})).HORIZONTAL="HORIZONTAL",T.VERTICAL="VERTICAL",e.SashState=void 0,(G=e.SashState||(e.SashState={}))[G.MAXIMUM=0]="MAXIMUM",G[G.MINIMUM=1]="MINIMUM",G[G.DISABLED=2]="DISABLED",G[G.ENABLED=3]="ENABLED",e.LayoutPriority=void 0,(R=e.LayoutPriority||(e.LayoutPriority={})).Low="low",R.High="high",R.Normal="normal",e.Sizing=void 0,(k=e.Sizing||(e.Sizing={})).Distribute={type:"distribute"},k.Split=function(e){return{type:"split",index:e}},k.Invisible=function(e){return{type:"invisible",cachedVisibleSize:e}};class M{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 u,this.onDidSashEnd=this._onDidSashEnd.event,this._onDidAddView=new u,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new u,this.onDidRemoveView=this._onDidRemoveView.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=I(e,-1),l=I(e+1,this.views.length);if(n)for(const e of n)N(d,e),N(l,e);if(s)for(const e of s)V(d,e),V(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),_=0===l.length?Number.NEGATIVE_INFINITY:l.reduce(((e,t)=>e+i[t]-this.views[t].maximumSize),0),f=Math.max(v,_),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 D=0,y=x(t,f,C);for(let e=0;e<p.length;e++){const t=p[e],i=x(m[e]+y,t.minimumSize,t.maximumSize),s=i-m[e];D+=s,y-=s,t.size=i}let S=D;for(let e=0;e<u.length;e++){const t=u[e],i=x(c[e]-S,t.minimumSize,t.maximumSize);S+=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,C(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)?(C(this.element,"separator-border"),this.element.style.removeProperty("--dv-separator-border")):(b(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");D(this.container,"visible",t);const i=this.views[e];D(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=I(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=x(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=x(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 L(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=[...S("iframe"),...S("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=I(o,-1),l=I(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),_=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 _){const e=this.views[_],t=Math.floor(e.viewMinimumSize/2);h={index:_,limitDelta:e.visible?g+t:g-t,size:e.size}}const f=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",f),document.removeEventListener("mouseup",C),document.removeEventListener("mouseend",C),this._onDidSashEnd.fire(void 0)};document.addEventListener("mousemove",f),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=x(s,e.minimumSize,e.maximumSize);const n=I(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=x(Math.round(this.proportions[e]*t),i.minimumSize,i.maximumSize)}else{const i=I(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=I(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)N(n,e);for(const e of o)V(n,e);"number"==typeof t&&V(n,t);for(let e=0;0!==s&&e<n.length;e++){const t=this.views[n[e]],i=x(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=I(t,-1),r=I(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){D(t.container,"disabled",i===e.SashState.DISABLED),D(t.container,"enabled",i===e.SashState.ENABLED),D(t.container,"maximum",i===e.SashState.MAXIMUM),D(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();for(let e=0;e<this.element.children.length;e++)if(this.element.children.item(e)===this.element){this.element.removeChild(this.element);break}this.element.remove()}}class F extends w{constructor(t,i){var s;super(),this.paneItems=[],this.skipAnimation=!1,this._onDidChange=new u,this.onDidChange=this._onDidChange.event,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 M(this.element,{orientation:this._orientation,proportionalLayout:!1,descriptor:i.descriptor}),this.getPanes().forEach((e=>{const t=new w(e.onDidChangeExpansionState((()=>{this.setupAnimation(),this._onDidChange.fire(void 0)}))),i={pane:e,disposable:{dispose:()=>{t.dispose()}}};this.paneItems.push(i),e.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()})))}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,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),b(this.element,"animated"),this.animationTimer=setTimeout((()=>{this.animationTimer=void 0,C(this.element,"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 W extends w{constructor(e,t){super(),this.element=e,this.callbacks=t,this.counter=0,this.registerListeners()}registerListeners(){this.addDisposables(v(this.element,"dragenter",(e=>{this.counter++,this.callbacks.onDragEnter(e)}))),this.addDisposables(v(this.element,"dragover",(e=>{e.preventDefault(),this.callbacks.onDragOver&&this.callbacks.onDragOver(e)}))),this.addDisposables(v(this.element,"dragleave",(e=>{this.counter--,0===this.counter&&this.callbacks.onDragLeave(e)}))),this.addDisposables(v(this.element,"dragend",(e=>{this.counter=0,this.callbacks.onDragEnd(e)}))),this.addDisposables(v(this.element,"drop",(e=>{this.counter=0,this.callbacks.onDrop(e)})))}}e.Position=void 0,(H=e.Position||(e.Position={})).Top="Top",H.Left="Left",H.Bottom="Bottom",H.Right="Right",H.Center="Center";class J extends w{constructor(t,i){super(),this.element=t,this.options=i,this._onDrop=new u,this.onDrop=this._onDrop.event,this.addDisposables(this._onDrop,new W(this.element,{onDragEnter:()=>{},onDragOver:t=>{const i=this.element.clientWidth,s=this.element.clientHeight;if(0===i||0===s)return;const n=100*t.offsetX/i,o=100*t.offsetY/s,r=this.calculateQuadrant(this.options.validOverlays,n,o);if("boolean"==typeof this.options.canDisplayOverlay){if(!this.options.canDisplayOverlay)return}else if(!this.options.canDisplayOverlay(t,r))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 a=i<100,h=s<100;this.toggleClasses(r,a,h),this.setState(r)},onDragLeave:()=>{this.removeDropTarget()},onDragEnd:()=>{this.removeDropTarget()},onDrop:e=>{e.preventDefault(),e.stopPropagation();const t=this._state;this.removeDropTarget(),t&&this._onDrop.fire({position:t,nativeEvent:e})}}))}get state(){return this._state}set validOverlays(e){this.options.validOverlays=e}set canDisplayOverlay(e){this.options.canDisplayOverlay=e}dispose(){this.removeDropTarget()}toggleClasses(e,t,i){if(!this.overlay)return;const s="left"===e,n="right"===e,o="top"===e,r="bottom"===e;D(this.overlay,"right",!t&&n),D(this.overlay,"left",!t&&s),D(this.overlay,"top",!i&&o),D(this.overlay,"bottom",!i&&r),D(this.overlay,"small-right",t&&n),D(this.overlay,"small-left",t&&s),D(this.overlay,"small-top",i&&o),D(this.overlay,"small-bottom",i&&r)}setState(t){switch(t){case"top":this._state=e.Position.Top;break;case"left":this._state=e.Position.Left;break;case"bottom":this._state=e.Position.Bottom;break;case"right":this._state=e.Position.Right;break;default:this._state=e.Position.Center}}calculateQuadrant(e,t,i){switch(e){case"all":if(t<20)return"left";if(t>80)return"right";if(i<20)return"top";if(i>80)return"bottom";break;case"vertical":return i<50?"top":"bottom";case"horizontal":return t<50?"left":"right"}return null}removeDropTarget(){this.target&&(this._state=void 0,this.element.removeChild(this.target),this.target=void 0,this.element.classList.remove("drop-target"))}}class B{constructor(t,i,s,n=0){this.view=t,this.orientation=i,this._onDidChange=new u,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._onDidChange.dispose(),this._disposable.dispose()}}class j extends w{constructor(e,t,i,s,o,r){if(super(),this.orientation=e,this.proportionalLayout=t,this.styles=i,this.children=[],this._onDidChange=new u,this.onDidChange=this._onDidChange.event,this._childrenDisposable=n.NONE,this._orthogonalSize=o,this._size=s,this.element=document.createElement("div"),this.element.className="branch-node",r){const e={views:r.map((e=>({view:e.node,size:e.node.size,visible:!(e.node instanceof B&&void 0!==e.visible)||e.visible}))),size:this.size};this.children=r.map((e=>e.node)),this.splitview=new M(this.element,{orientation:this.orientation,descriptor:e,proportionalLayout:t})}else this.splitview=new M(this.element,{orientation:this.orientation,proportionalLayout:t,styles:i}),this.splitview.layout(this.size,this.orthogonalSize);this.addDisposables(this._onDidChange,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)))((()=>{this._onDidChange.fire(void 0)}))}dispose(){super.dispose(),this._childrenDisposable.dispose(),this.children.forEach((e=>e.dispose())),this.splitview.dispose()}}function $(e,t){if(e instanceof B)return e;if(e instanceof j)return $(e.children[t?e.children.length-1:0],t);throw new Error("invalid node")}function Z(e,t,i){if(e instanceof j){const s=new j(q(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 j?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(Z(r,i,h),h,0,!0)}return s}return new B(e.view,q(e.orientation),i)}function U(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 X(e){const t=e.parentElement;if(!t)throw new Error("Invalid grid element");if(/\bgrid-view\b/.test(t.className))return[];const i=U(t);return[...X(t.parentElement.parentElement.parentElement),i]}function K(t,i,s){if(Q(t,i)===Y(s)){const[t,n]=A(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 Y(t){return t===e.Position.Top||t===e.Position.Bottom?e.Orientation.VERTICAL:e.Orientation.HORIZONTAL}function Q(e,t){return t.length%2==0?q(e):e}const q=t=>t===e.Orientation.HORIZONTAL?e.Orientation.VERTICAL:e.Orientation.HORIZONTAL;function ee(e){return!!e.children}const te=(t,i)=>{const s=i===e.Orientation.VERTICAL?t.box.width:t.box.height;return ee(t)?{type:"branch",data:t.children.map((e=>te(e,q(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 ie{constructor(e,t,i){this.proportionalLayout=e,this.styles=t,this.disposable=new _,this._onDidChange=new u,this.onDidChange=this._onDidChange.event,this.element=document.createElement("div"),this.element.className="grid-view",this.root=new j(i,e,t,0,0)}serialize(){return{root:te(this.getView(),this.orientation),width:this.width,height:this.height,orientation:this.orientation}}dispose(){this.disposable.dispose(),this._onDidChange.dispose(),this.root.dispose(),this.element.remove()}clear(){const e=this.root.orientation;this.root=new j(e,this.proportionalLayout,this.styles,this.root.size,this.root.orthogonalSize)}deserialize(t,i){const s=t.orientation,n=s===e.Orientation.VERTICAL?t.height:t.width;this._deserialize(t.root,s,i,n)}_deserialize(e,t,i,s){this.root=this._deserializeNode(e,t,i,s,!0)}_deserializeNode(e,t,i,s,n=!1){let o;if("branch"===e.type){const r=e.data.map((s=>({node:this._deserializeNode(s,q(t),i,e.size),visible:s.visible})));o=new j(t,this.proportionalLayout,this.styles,n?s:e.size,n?e.size:s,r)}else o=new B(i.fromJSON(e),t,s,e.size);return o}get orientation(){return this.root.orientation}set orientation(e){if(this.root.orientation===e)return;const{size:t,orthogonalSize:i}=this.root;this.root=Z(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 B)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,q(t),o))}return{box:s,children:n}}progmaticSelect(e,t=!1){const[i,s]=this.getNode(e);if(!(s instanceof B))throw new Error("invalid location");for(let s=i.length-1;s>-1;s--){const n=i[s],o=e[s]||0;if(t?o-1>-1:o+1<n.children.length)return $(n.children[t?o-1:o+1],t)}return $(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]=A(e),[,s]=this.getNode(t);if(!(s instanceof j))throw new Error("Invalid from location");return s.isChildVisible(i)}setViewVisible(e,t){const[i,s]=A(e),[,n]=this.getNode(i);if(!(n instanceof j))throw new Error("Invalid from location");n.setChildVisible(s,t)}moveView(e,t,i){const[,s]=this.getNode(e);if(!(s instanceof j))throw new Error("Invalid location");s.moveChild(t,i)}addView(t,i,s){const[n,o]=A(s),[r,a]=this.getNode(n);if(a instanceof j){const e=new B(t,q(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 j(a.orientation,this.proportionalLayout,this.styles,a.size,a.orthogonalSize);s.addChild(u,a.size,d);const c=new B(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 B(t,s.orientation,a.size);u.addChild(v,i,o)}}remove(e,t){const i=X(e.element);return this.removeView(i,t)}removeView(t,i){const[s,n]=A(t),[o,r]=this.getNode(s);if(!(r instanceof j))throw new Error("Invalid location");const a=r.children[n];if(!(a instanceof B))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;const h=r.children[0];if(0===o.length)return h instanceof B||(r.removeChild(0,i),this.root=h),a.view;const[d,...l]=[...o].reverse(),[p,...m]=[...s].reverse(),u=r.isChildVisible(0);r.removeChild(0,i);const c=d.children.map(((e,t)=>d.getChildSize(t)));if(d.removeChild(p,i),h instanceof j){c.splice(p,1,...h.children.map((e=>e.size)));for(let e=0;e<h.children.length;e++){const t=h.children[e];d.addChild(t,t.size,p+e)}}else{const t=new B(h.view,q(h.orientation),h.size),i=u?h.orthogonalSize:e.Sizing.Invisible(h.orthogonalSize);d.addChild(t,i,p)}for(let e=0;e<c.length;e++)d.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 j))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)}}class se{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 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}updateOptions(e){this.component.updateOptions(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()}}class ne{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 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(){const e=new u,t=this.component.onDidDrop((t=>{e.fire(Object.assign(Object.assign({},t),{api:this}))}));return e.dispose=()=>{t.dispose(),e.dispose()},e.event}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()}}class oe{constructor(e){this.component=e}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 width(){return this.component.width}get height(){return this.component.height}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidAddGroup(){return this.component.onDidAddGroup}get onDidRemoveGroup(){return this.component.onDidRemoveGroup}get onDidActiveGroupChange(){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})}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()}}class re{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 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 onDidLayoutFromJSON(){return this.component.onDidLayoutfromJSON}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidDrop(){return this.component.onDidDrop}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)}layout(e,t,i=!1){this.component.layout(e,t,i)}addPanel(e){return this.component.addPanel(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)}getGroup(e){return this.component.getPanel(e)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}}class ae extends w{constructor(){super(),this.disposable=new _,this._onDidFocus=new u,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new u,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="content-container",this._element.tabIndex=-1,this.addDisposables(this._onDidFocus,this._onDidBlur)}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 w;if(this.panel.view){const e=this.panel.view.content.onDidFocus,t=this.panel.view.content.onDidBlur,{onDidFocus:s,onDidBlur:n}=z(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;!function(e){e[e.Tab=0]="Tab",e[e.Panel=1]="Panel",e[e.TabContainer=2]="TabContainer"}(he||(he={}));class pe extends w{constructor(e){super(),this.el=e,this.disposable=new _,this._onDragStart=new u,this.onDragStart=this._onDragStart.event,this.iframes=[],this.configure()}configure(){this.addDisposables(this._onDragStart,v(this.el,"dragstart",(e=>{this.iframes=[...S("iframe"),...S("webview")];for(const e of this.iframes)e.style.pointerEvents="none";this.el.classList.add("dragged"),setTimeout((()=>this.el.classList.remove("dragged")),0),this.disposable.value=this.getData(),e.dataTransfer&&(e.dataTransfer.effectAllowed="move")})),v(this.el,"dragend",(()=>{for(const e of this.iframes)e.style.pointerEvents="auto";this.iframes=[],this.disposable.dispose()})))}}e.MouseEventKind=void 0,(de=e.MouseEventKind||(e.MouseEventKind={})).CLICK="CLICK",de.CONTEXT_MENU="CONTEXT_MENU";class me extends w{constructor(t,i,s){super(),this.panelId=t,this.group=s,this._onChanged=new u,this.onChanged=this._onChanged.event,this._onDropped=new u,this.onDrop=this._onDropped.event,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(new class extends pe{constructor(){super(...arguments),this.panelTransfer=l.getInstance()}getData(){return this.panelTransfer.setData([new h(i.id,s.id,t)],h.prototype),{dispose:()=>{this.panelTransfer.clearData(h.prototype)}}}dispose(){}}(this._element)),this.addDisposables(v(this._element,"mousedown",(t=>{t.defaultPrevented||(t.stopPropagation(),this._onChanged.fire({kind:e.MouseEventKind.CLICK,event:t}))})),v(this._element,"contextmenu",(t=>{this._onChanged.fire({kind:e.MouseEventKind.CONTEXT_MENU,event:t})}))),this.droptarget=new J(this._element,{validOverlays:"none",canDisplayOverlay:e=>{const t=p();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){D(this.element,"active-tab",e),D(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 w{constructor(e,t,i){super(),this.accessor=e,this.group=t,this.tabs=[],this.selectedIndex=-1,this.active=!1,this._hidden=!1,this._onDrop=new u,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 J(this.voidContainer,{validOverlays:"none",canDisplayOverlay:e=>{var i;const s=p();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.nativeEvent,index:this.tabs.length})})),this.voidDropTarget,v(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`)}get hidden(){return this._hidden}set hidden(e){this._hidden=e,this.element.style.display=e?"none":""}show(){this.hidden||(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=w.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}));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.nativeEvent,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";class ce extends w{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._locked=!1,this.mostRecentlyUsed=[],this._onDidChange=new u,this.onDidChange=this._onDidChange.event,this._width=0,this._height=0,this._panels=[],this._onMove=new u,this.onMove=this._onMove.event,this._onDidGroupChange=new u,this.onDidGroupChange=this._onDidGroupChange.event,this._onDidDrop=new u,this.onDidDrop=this._onDidDrop.event,this.container.classList.add("groupview"),this.addDisposables(this._onMove,this._onDidGroupChange,this._onDidChange,this._onDidDrop),this.tabsContainer=new ue(this.accessor,this.parent,{tabHeight:n.tabHeight}),this.contentContainer=new ae,this.dropTarget=new J(this.contentContainer.element,{validOverlays:"all",canDisplayOverlay:(e,t)=>{if(this.locked&&!t)return!1;const i=p();if(i){return!(1===this._panels.length&&i.groupId===this.id)}return this.canDisplayOverlay(e,he.Panel)}}),t.append(this.tabsContainer.element,this.contentContainer.element),this.header.hidden=!!n.hideHeader,this.locked=!!n.locked,this.addDisposables(this._onMove,this._onDidGroupChange,this.tabsContainer.onDrop((t=>{this.handleDropEvent(t.event,e.Position.Center,t.index)})),this.contentContainer.onDidFocus((()=>{this.accessor.doSetGroupActive(this.parent,!0)})),this.contentContainer.onDidBlur((()=>{})),this.dropTarget.onDrop((e=>{this.handleDropEvent(e.nativeEvent,e.position)})))}get element(){throw new Error("not supported")}get activePanel(){return this._activePanel}get locked(){return this._locked}set locked(e){this._locked=e}get isActive(){return this._isGroupActive}get panels(){return this._panels}get size(){return this._panels.length}get isEmpty(){return 0===this._panels.length}get minimumHeight(){return 100}get maximumHeight(){return Number.MAX_SAFE_INTEGER}get minimumWidth(){return 100}get maximumWidth(){return Number.MAX_SAFE_INTEGER}get hasWatermark(){return!(!this.watermark||!this.container.contains(this.watermark.element))}get header(){return this.tabsContainer}get isContentFocused(){return!!document.activeElement&&y(document.activeElement,this.contentContainer.element)}initialize(){var e,t;(null===(e=this.options)||void 0===e?void 0:e.panels)&&this.options.panels.forEach((e=>{this.doAddPanel(e)})),(null===(t=this.options)||void 0===t?void 0:t.activePanel)&&this.openPanel(this.options.activePanel),this.setActive(this.isActive,!0,!0),this.updateContainer()}indexOf(e){return this.tabsContainer.indexOf(e.id)}toJSON(){var e;const t={views:this.tabsContainer.panels,activeView:null===(e=this._activePanel)||void 0===e?void 0:e.id,id:this.id};return this.locked&&(t.locked=!0),this.header.hidden&&(t.hideHeader=!0),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)return;i=0}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)return;i=this.panels.length-1}this.openPanel(this.panels[i])}containsPanel(e){return this.panels.includes(e)}init(e){}update(e){}focus(){var e;null===(e=this._activePanel)||void 0===e||e.focus()}openPanel(e,t={}){("number"!=typeof t.index||t.index>this.panels.length)&&(t.index=this.panels.length);const i=!!t.skipSetActive;e.updateParentGroup(this.parent,!0),i||this._activePanel!==e?(this.doAddPanel(e,t.index),i||(this.doSetActivePanel(e),this.accessor.doSetGroupActive(this.parent,!!t.skipFocus)),this.updateContainer()):this.accessor.doSetGroupActive(this.parent)}removePanel(e){const t="string"==typeof e?e:e.id,i=this._panels.find((e=>e.id===t));if(!i)throw new Error("invalid operation");return this._removePanel(i)}closeAllPanels(){if(this.panels.length>0){const e=[...this.panels];for(const t of e)this.doClose(t)}else this.accessor.removeGroup(this.parent)}closePanel(e){this.doClose(e)}doClose(e){this.accessor.removePanel(e)}isPanelActive(e){return this._activePanel===e}updateActions(){var e,t;this.isActive&&(null===(t=null===(e=this._activePanel)||void 0===e?void 0:e.view)||void 0===t?void 0:t.actions)?this.tabsContainer.setActionElement(this._activePanel.view.actions.element):this.tabsContainer.setActionElement(void 0)}setActive(e,t=!1,i=!1){var s,n;i||this.isActive!==e?(this._isGroupActive=e,D(this.container,"active-group",e),D(this.container,"inactive-group",!e),this.tabsContainer.setActive(this.isActive),!this._activePanel&&this.panels.length>0&&this.doSetActivePanel(this.panels[0]),this.updateContainer(),e&&(t||null===(n=this._activePanel)||void 0===n||n.focus())):t||null===(s=this._activePanel)||void 0===s||s.focus()}layout(e,t){var i;this._width=e,this._height=t,this.contentContainer.layout(this._width,this._height),(null===(i=this._activePanel)||void 0===i?void 0:i.layout)&&this._activePanel.layout(this._width,this._height)}_removePanel(e){const t=this._activePanel===e;if(this.doRemovePanel(e),t&&this.panels.length>0){const e=this.mostRecentlyUsed[0];this.openPanel(e)}return this._activePanel&&0===this.panels.length&&this.doSetActivePanel(void 0),this.updateContainer(),e}doRemovePanel(t){const i=this.panels.indexOf(t);this._activePanel===t&&this.contentContainer.closePanel(),this.tabsContainer.delete(t.id),this._panels.splice(i,1),this.mostRecentlyUsed.includes(t)&&this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(t),1),this._onDidGroupChange.fire({kind:e.GroupChangeKind2.REMOVE_PANEL,panel:t})}doAddPanel(t,i=this.panels.length){const s=this._panels.indexOf(t)>-1;this.tabsContainer.openPanel(t,i),this.contentContainer.openPanel(t),this.tabsContainer.show(),this.contentContainer.show(),s||(this.updateMru(t),this.panels.splice(i,0,t),this._onDidGroupChange.fire({kind:e.GroupChangeKind2.ADD_PANEL,panel:t}))}doSetActivePanel(t){this._activePanel=t,t&&(this.tabsContainer.setActivePanel(t),t.layout(this._width,this._height),this.updateMru(t),this._onDidGroupChange.fire({kind:e.GroupChangeKind2.PANEL_ACTIVE,panel:t}))}updateMru(e){this.mostRecentlyUsed.includes(e)&&this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(e),1),this.mostRecentlyUsed=[e,...this.mostRecentlyUsed]}updateContainer(){if(this.updateActions(),D(this.container,"empty",this.isEmpty),this.panels.forEach((e=>e.updateParentGroup(this.parent,this.isActive))),this.isEmpty&&!this.watermark){const e=this.accessor.createWatermarkComponent();e.init({containerApi:new re(this.accessor),params:{},title:"",api:null}),this.watermark=e,v(this.watermark.element,"click",(()=>{this.isActive||this.accessor.doSetGroupActive(this.parent)})),this.contentContainer.hide(),this.tabsContainer.hide(),this.container.appendChild(this.watermark.element),this.watermark.updateParentGroup(this.parent,!0)}!this.isEmpty&&this.watermark&&(this.watermark.element.remove(),this.watermark.dispose(),this.watermark=void 0,this.contentContainer.show(),this.tabsContainer.show())}canDisplayOverlay(e,t){return!!this.accessor.options.showDndOverlay&&this.accessor.options.showDndOverlay(e,t)}handleDropEvent(e,t,i){const s=p();if(s){if(-1!==this.tabsContainer.indexOf(s.panelId)&&1===this.tabsContainer.size)return;const{groupId:e,panelId:n}=s;if(this.id===e&&!t){if(this.tabsContainer.indexOf(n)===i)return}this._onMove.fire({target:t,groupId:s.groupId,itemId:s.panelId,index:i})}else this._onDidDrop.fire({nativeEvent:e,position:t,index:i,getData:()=>p()})}dispose(){var e;super.dispose(),null===(e=this.watermark)||void 0===e||e.dispose();for(const e of this.panels)e.dispose();this.dropTarget.dispose(),this.tabsContainer.dispose(),this.contentContainer.dispose()}}const ve=P();function ge(t){switch(t){case"left":return e.Position.Left;case"right":return e.Position.Right;case"above":return e.Position.Top;case"below":return e.Position.Bottom;default:return e.Position.Center}}class we extends w{constructor(t,i){super(),this._element=t,this._id=ve.next(),this._groups=new Map,this._onDidLayoutChange=new u,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidRemoveGroup=new u,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new u,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidActiveGroupChange=new u,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._bufferOnDidLayoutChange=new g,this.gridview=new ie(!!i.proportionalLayout,i.styles,i.orientation),this.element.appendChild(this.gridview.element),this.layout(0,0,!0),this.addDisposables(this.gridview.onDidChange((()=>{this._onDidLayoutChange.fire()}))),this.addDisposables(e.Event.any(this.onDidAddGroup,this.onDidRemoveGroup,this.onDidActiveGroupChange)((()=>{this._bufferOnDidLayoutChange.fire()})),this._bufferOnDidLayoutChange.onEvent((()=>{this._onDidLayoutChange.fire()})),this._bufferOnDidLayoutChange)}get id(){return this._id}get element(){return this._element}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}setVisible(e,t){this.gridview.setViewVisible(X(e.element),t),this._onDidLayoutChange.fire()}isVisible(e){return this.gridview.isViewVisible(X(e.element))}doAddGroup(t,i=[0],s){this.gridview.addView(t,null!=s?s:e.Sizing.Distribute,i),this._onDidAddGroup.fire(t),this.doSetGroupActive(t)}doRemoveGroup(t,i){if(!this._groups.has(t.id))throw new Error("invalid operation");const s=this._groups.get(t.id),n=this.gridview.remove(t,e.Sizing.Distribute);if(s&&!(null==i?void 0:i.skipDispose)&&(s.disposable.dispose(),s.value.dispose(),this._groups.delete(t.id)),this._onDidRemoveGroup.fire(t),!(null==i?void 0:i.skipActive)&&this._activeGroup===t){const e=Array.from(this._groups.values());this.doSetGroupActive(e.length>0?e[0].value:void 0)}return n}getPanel(e){var t;return null===(t=this._groups.get(e))||void 0===t?void 0:t.value}doSetGroupActive(e,t){this._activeGroup!==e&&(this._activeGroup&&(this._activeGroup.setActive(!1),t||this._activeGroup.focus()),e&&(e.setActive(!0),t||e.focus()),this._activeGroup=e,this._onDidActiveGroupChange.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=X(e.group.element),s=null===(t=this.gridview.next(i))||void 0===t?void 0:t.view;this.doSetGroupActive(s)}moveToPrevious(e){var t;if(e||(e={}),!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}const i=X(e.group.element),s=null===(t=this.gridview.previous(i))||void 0===t?void 0:t.view;this.doSetGroupActive(s)}layout(e,t,i){(i||e!==this.width||t!==this.height)&&(this.element.style.height=`${t}px`,this.element.style.width=`${e}px`,this.gridview.layout(e,t))}dispose(){super.dispose(),this._onDidActiveGroupChange.dispose(),this._onDidAddGroup.dispose(),this._onDidRemoveGroup.dispose(),this._onDidLayoutChange.dispose();for(const e of this.groups)e.dispose();this.gridview.dispose()}}class _e extends w{constructor(e){super(),this.id=e,this._isFocused=!1,this._isActive=!1,this._isVisible=!0,this._width=0,this._height=0,this._onDidDimensionChange=new u({replay:!0}),this.onDidDimensionsChange=this._onDidDimensionChange.event,this._onDidChangeFocus=new u({replay:!0}),this.onDidFocusChange=this._onDidChangeFocus.event,this._onFocusEvent=new u,this.onFocusEvent=this._onFocusEvent.event,this._onDidVisibilityChange=new u({replay:!0}),this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._onVisibilityChange=new u,this.onVisibilityChange=this._onVisibilityChange.event,this._onDidActiveChange=new u({replay:!0}),this.onDidActiveChange=this._onDidActiveChange.event,this._onActiveChange=new u,this.onActiveChange=this._onActiveChange.event,this.addDisposables(this._onDidDimensionChange,this._onDidChangeFocus,this._onDidVisibilityChange,this._onDidActiveChange,this._onFocusEvent,this._onActiveChange,this._onVisibilityChange,this.onDidFocusChange((e=>{this._isFocused=e.isFocused})),this.onDidActiveChange((e=>{this._isActive=e.isActive})),this.onDidVisibilityChange((e=>{this._isVisible=e.isVisible})),this.onDidDimensionsChange((e=>{this._width=e.width,this._height=e.height})))}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}setVisible(e){this._onVisibilityChange.fire({isVisible:e})}setActive(){this._onActiveChange.fire()}dispose(){super.dispose()}}class fe extends _e{constructor(e){super(e),this._onDidConstraintsChangeInternal=new u,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new u({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new u,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 Ce extends fe{constructor(e,t){super(e.id),this.panel=e,this._onDidTitleChange=new u,this.onDidTitleChange=this._onDidTitleChange.event,this._titleChanged=new u,this.titleChanged=this._titleChanged.event,this._suppressClosableChanged=new u,this.suppressClosableChanged=this._suppressClosableChanged.event,this._onDidActiveGroupChange=new u,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._onDidGroupChange=new u,this.onDidGroupChange=this._onDidGroupChange.event,this.disposable=new _,this._group=t,this.addDisposables(this.disposable,this._onDidTitleChange,this._titleChanged,this._suppressClosableChanged,this._onDidGroupChange,this._onDidActiveGroupChange)}get title(){return this.panel.title}get suppressClosable(){return!!this.panel.suppressClosable}get isGroupActive(){var e;return!!(null===(e=this.group)||void 0===e?void 0:e.isActive)}set group(e){const t=this.isGroupActive;this._group=e,this._onDidGroupChange.fire(),this._group&&(this.disposable.value=this._group.api.onDidActiveChange((()=>{this._onDidActiveGroupChange.fire()})),this.isGroupActive!==t&&this._onDidActiveGroupChange.fire())}get group(){return this._group}setTitle(e){this._onDidTitleChange.fire({title:e})}close(){if(!this.group)throw new Error(`panel ${this.id} has no group`);return this.group.model.closePanel(this.panel)}}class be extends w{constructor(e,t,i,s){super(),this.id=e,this.containerApi=i,this.mutableDisposable=new _,this._suppressClosable=!1,this._title="",this._group=s,this.api=new Ce(this,this._group),this.addDisposables(this.api.onActiveChange((()=>{t.setActivePanel(this)})),this.api.onDidTitleChange((e=>{const t=e.title;this.update({params:{title:t}})})))}get params(){var e;return null===(e=this._params)||void 0===e?void 0:e.params}get title(){return this._title}get suppressClosable(){return this._suppressClosable}get group(){return this._group}get view(){return this._view}init(e){var t;this._params=e.params,this._view=e.view,this.setTitle(e.title),this.setSuppressClosable(e.suppressClosable||!1),null===(t=this.view)||void 0===t||t.init(Object.assign(Object.assign({},e),{api:this.api,containerApi:this.containerApi}))}focus(){this.api._onFocusEvent.fire()}toJSON(){return{id:this.id,view:this.view.toJSON(),params:Object.keys(this._params||{}).length>0?this._params:void 0,suppressClosable:this.suppressClosable||void 0,title:this.title}}setTitle(e){var t;e!==(null===(t=this._params)||void 0===t?void 0:t.title)&&(this._title=e,this.api._titleChanged.fire({title:this.title}))}setSuppressClosable(e){var t;e!==(null===(t=this._params)||void 0===t?void 0:t.suppressClosable)&&(this._suppressClosable=e,this.api._suppressClosableChanged.fire({suppressClosable:!!this.suppressClosable}))}update(e){var t;const i=e.params;this._params=Object.assign(Object.assign({},this._params||{}),e.params.params),"string"==typeof i.title&&this.setTitle(i.title),"boolean"==typeof i.suppressClosable&&this.setSuppressClosable(i.suppressClosable),null===(t=this.view)||void 0===t||t.update({params:{params:this._params,title:this.title,suppressClosable:this.suppressClosable}})}updateParentGroup(e,t){var i;this._group=e,this.api.group=e;const s=this._group.model.isPanelActive(this);this.api._onDidActiveChange.fire({isActive:t&&s}),this.api._onDidVisibilityChange.fire({isVisible:s}),null===(i=this.view)||void 0===i||i.updateParentGroup(this._group,this._group.model.isPanelActive(this))}layout(e,t){var i;this.api._onDidDimensionChange.fire({width:e,height:t-(this.group.model.header.height||0)}),null===(i=this.view)||void 0===i||i.layout(e,t)}dispose(){var e;this.api.dispose(),this.mutableDisposable.dispose(),null===(e=this.view)||void 0===e||e.dispose()}}class De{constructor(){this._element=document.createElement("div"),this._element.className="actions-bar",this._list=document.createElement("ul"),this._list.className="actions-container",this._element.appendChild(this._list)}get element(){return this._element}add(e){document.createElement("li").className="action-item",this._list.appendChild(e)}}class ye extends w{constructor(){super(),this._element=document.createElement("div"),this._element.className="watermark";const e=document.createElement("div");e.className="watermark-title";const t=document.createElement("span");t.style.flexGrow="1";const i=document.createElement("div");i.className="watermark-content",this._element.appendChild(e),this._element.appendChild(i);const s=new De;e.appendChild(t),e.appendChild(s.element);const n=document.createElement("a");n.className="close-action",s.add(n),this.addDisposables(v(n,"click",(e=>{var t;e.preventDefault(),this.group&&(null===(t=this.params)||void 0===t||t.containerApi.removeGroup(this.group))})))}get id(){return"watermark"}update(e){}focus(){}toJSON(){return{}}layout(e,t){}init(e){this.params=e,this.addDisposables(this.params.containerApi.onDidLayoutChange((()=>{this.render()}))),this.render()}updateParentGroup(e,t){this.group=e,this.render()}get element(){return this._element}render(){const e=!!(this.params&&this.params.containerApi.size<=1);D(this.element,"has-actions",e)}dispose(){super.dispose()}}class Se{constructor(e,t){this.layout=e,this.panelDeserializer=t}fromJSON(e){const t=e.data,i=t.views,s=t.activeView,n=this.layout.createGroup({id:t.id,locked:!!t.locked,hideHeader:!!t.hideHeader});for(const e of i){const t=this.panelDeserializer.createPanel(e,n),i="string"==typeof s&&s===t.id;n.model.openPanel(t,{skipSetActive:!i})}return!n.activePanel&&n.panels.length>0&&n.model.openPanel(n.panels[n.panels.length-1]),n}}function ze(e,t,i={},s={},n,o){const r="string"==typeof t?i[t]:void 0,a="string"==typeof t?s[t]:void 0;if(r&&a)throw new Error(`Cannot create '${e}'. component '${t}' registered as both a component and frameworkComponent`);if(a){if(!n)throw new Error(`Cannot create '${e}' for framework component '${t}'. you must register a frameworkPanelWrapper to use framework components`);return n.createComponent(e,t,a)}if(!r){if(o)return o();throw new Error(`Cannot create '${e}', no component '${t}' provided`)}return new r(e,t)}class Ee extends w{constructor(){super(),this._isPanelVisible=!1,this._isGroupActive=!1,this.params={},this._element=document.createElement("div"),this._element.className="default-tab",this._content=document.createElement("div"),this._content.className="tab-content",this._actionContainer=document.createElement("div"),this._actionContainer.className="action-container",this._list=document.createElement("ul"),this._list.className="tab-list",this.action=document.createElement("a"),this.action.className="tab-action",this._element.appendChild(this._content),this._element.appendChild(this._actionContainer),this._actionContainer.appendChild(this._list),this._list.appendChild(this.action),this.addDisposables(v(this._actionContainer,"mousedown",(e=>{e.preventDefault()}))),this.render()}get element(){return this._element}get id(){return"__DEFAULT_TAB__"}update(e){this.params=Object.assign(Object.assign({},this.params),e.params),this.render()}toJSON(){return{id:this.id}}focus(){}init(e){this.params=e,this._content.textContent=e.title,this.params.suppressClosable?this.action.classList.add("disable-close"):v(this.action,"click",(e=>{e.preventDefault(),this.params.api.close()}))}updateParentGroup(e,t){const i=this._isPanelVisible!==t||this._isGroupActive!==e.isActive;this._isPanelVisible=t,this._isGroupActive=e.isActive,i&&this.render()}layout(e,t){}render(){this._content.textContent!==this.params.title&&(this._content.textContent=this.params.title)}}class xe extends w{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{onDidFocus:s,onDidBlur:n}=z(this._element);this.addDisposables(this.api,s((()=>{this.api._onDidChangeFocus.fire({isFocused:!0})})),n((()=>{this.api._onDidChangeFocus.fire({isFocused:!1})})))}get element(){return this._element}get width(){return this._width}get height(){return this._height}get params(){var e;return null===(e=this._params)||void 0===e?void 0:e.params}focus(){this.api._onFocusEvent.fire()}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({},null===(t=this._params)||void 0===t?void 0:t.params),e.params)}),null===(i=this.part)||void 0===i||i.update({params:this._params.params})}toJSON(){var e,t;const i=null!==(t=null===(e=this._params)||void 0===e?void 0:e.params)&&void 0!==t?t:{};return{id:this.id,component:this.component,params:Object.keys(i).length>0?i:void 0}}dispose(){var e;super.dispose(),this.api.dispose(),null===(e=this.part)||void 0===e||e.dispose()}}class Pe extends xe{constructor(e,t,i=new fe(e)){super(e,t,i),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 u,this.onDidChange=this._onDidChange.event,this.addDisposables(this._onDidChange,this.api.onVisibilityChange((e=>{const{isVisible:t}=e,{accessor:i}=this._params;i.setVisible(this,t)})),this.api.onActiveChange((()=>{const{accessor:e}=this._params;e.setActive(this)})),this.api.onDidConstraintsChangeInternal((e=>{"number"!=typeof e.minimumWidth&&"function"!=typeof e.minimumWidth||(this._minimumWidth=e.minimumWidth),"number"!=typeof e.minimumHeight&&"function"!=typeof e.minimumHeight||(this._minimumHeight=e.minimumHeight),"number"!=typeof e.maximumWidth&&"function"!=typeof e.maximumWidth||(this._maximumWidth=e.maximumWidth),"number"!=typeof e.maximumHeight&&"function"!=typeof e.maximumHeight||(this._maximumHeight=e.maximumHeight)})),this.api.onDidSizeChange((e=>{this._onDidChange.fire({height:e.height,width:e.width})})))}get priority(){return this._priority}get snap(){return this._snap}get minimumWidth(){const e="function"==typeof this._minimumWidth?this._minimumWidth():this._minimumWidth;return e!==this._evaluatedMinimumWidth&&(this._evaluatedMinimumWidth=e,this.updateConstraints()),e}get minimumHeight(){const e="function"==typeof this._minimumHeight?this._minimumHeight():this._minimumHeight;return e!==this._evaluatedMinimumHeight&&(this._evaluatedMinimumHeight=e,this.updateConstraints()),e}get maximumHeight(){const e="function"==typeof this._maximumHeight?this._maximumHeight():this._maximumHeight;return e!==this._evaluatedMaximumHeight&&(this._evaluatedMaximumHeight=e,this.updateConstraints()),e}get maximumWidth(){const e="function"==typeof this._maximumWidth?this._maximumWidth():this._maximumWidth;return e!==this._evaluatedMaximumWidth&&(this._evaluatedMaximumWidth=e,this.updateConstraints()),e}get isActive(){return this.api.isActive}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),"boolean"==typeof e.isVisible&&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=e=>e===Number.MAX_SAFE_INTEGER?void 0:e,i=e=>e<=0?void 0:e;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})}}class Ae extends fe{}class Oe extends Pe{constructor(e,t,i){super(t,"groupview_default",new Ae(t)),this._model=new ce(this.element,e,t,i,this)}get panels(){return this._model.panels}get activePanel(){return this._model.activePanel}get size(){return this._model.size}get model(){return this._model}get minimumHeight(){return this._model.minimumHeight}get maximumHeight(){return this._model.maximumHeight}get minimumWidth(){return this._model.minimumWidth}get maximumWidth(){return this._model.maximumWidth}get locked(){return this._model.locked}set locked(e){this._model.locked=e}get header(){return this._model.header}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()}}class Ne{constructor(e){var t;this._content=e.content,this._tab=null!==(t=e.tab)&&void 0!==t?t:new Ee,this._actions=e.actions||(this.content.actions?{element:this.content.actions,dispose:()=>{}}:void 0)}get content(){return this._content}get tab(){return this._tab}get actions(){return this._actions}init(e){this.content.init(Object.assign(Object.assign({},e),{tab:this.tab})),this.tab.init(e)}updateParentGroup(e,t){var i;this._content.updateParentGroup(e,t),null===(i=this._tab)||void 0===i||i.updateParentGroup(e,t)}layout(e,t){this.content.layout(e,t)}update(e){this.content.update(e),this.tab.update(e)}toJSON(){return{content:this.content.toJSON(),tab:this.tab instanceof Ee?void 0:this.tab.toJSON()}}dispose(){var e;this.content.dispose(),this.tab.dispose(),null===(e=this.actions)||void 0===e||e.dispose()}}const Ve=P();class Ie extends we{constructor(t,i){super(t,{proportionalLayout:!0,orientation:i.orientation||e.Orientation.HORIZONTAL,styles:i.styles}),this._onTabInteractionEvent=new u,this.onTabInteractionEvent=this._onTabInteractionEvent.event,this._onTabContextMenu=new u,this.onTabContextMenu=this._onTabContextMenu.event,this._onDidDrop=new u,this.onDidDrop=this._onDidDrop.event,this._onDidRemovePanel=new u,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidAddPanel=new u,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidLayoutfromJSON=new u,this.onDidLayoutfromJSON=this._onDidLayoutfromJSON.event,this._onDidActivePanelChange=new u,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this.addDisposables(this._onTabInteractionEvent,this._onTabContextMenu,this._onDidDrop,e.Event.any(this.onDidAddPanel,this.onDidRemovePanel,this.onDidActivePanelChange)((()=>{this._bufferOnDidLayoutChange.fire()}))),this._options=i,this.options.components||(this.options.components={}),this.options.frameworkComponents||(this.options.frameworkComponents={}),this.options.frameworkTabComponents||(this.options.frameworkTabComponents={}),this.options.tabComponents||(this.options.tabComponents={}),this.options.watermarkComponent||this.options.watermarkFrameworkComponent||(this.options.watermarkComponent=ye),this._api=new re(this)}get totalPanels(){return this.panels.length}get panels(){return this.groups.flatMap((e=>e.panels))}get deserializer(){return this._deserializer}set deserializer(e){this._deserializer=e}get options(){return this._options}get activePanel(){const e=this.activeGroup;if(e)return e.activePanel}set tabHeight(e){this.options.tabHeight=e,this._groups.forEach((t=>{t.value.model.header.height=e}))}get tabHeight(){return this.options.tabHeight}updateOptions(e){const t="string"==typeof e.orientation&&this.options.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)}focus(){var e;null===(e=this.activeGroup)||void 0===e||e.focus()}getGroupPanel(e){return this.panels.find((t=>t.id===e))}setActivePanel(e){this.doSetGroupActive(e.group),e.group.model.openPanel(e)}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])return void e.group.model.moveToNext({suppressRoll:!0});const i=X(e.group.element),s=null===(t=this.gridview.next(i))||void 0===t?void 0:t.view;this.doSetGroupActive(s)}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])return void e.group.model.moveToPrevious({suppressRoll:!0});const i=X(e.group.element),s=null===(t=this.gridview.previous(i))||void 0===t?void 0:t.view;s&&this.doSetGroupActive(s)}toJSON(){var e;return{grid:this.gridview.serialize(),panels:this.panels.reduce(((e,t)=>(e[t.id]=t.toJSON(),e)),{}),activeGroup:null===(e=this.activeGroup)||void 0===e?void 0:e.id,options:{tabHeight:this.tabHeight}}}fromJSON(e){const t=Array.from(this._groups.values()).map((e=>e.value));for(const e of t)this.removeGroup(e,!0);if(this.gridview.clear(),!this.deserializer)throw new Error("invalid deserializer");const{grid:i,panels:s,options:n,activeGroup:o}=e;if("number"==typeof(null==n?void 0:n.tabHeight)&&(this.tabHeight=n.tabHeight),!this.deserializer)throw new Error("no deserializer provided");if(this.gridview.deserialize(i,new Se(this,{createPanel:(e,t)=>{const i=s[e];return this.deserializer.fromJSON(i,t)}})),"string"==typeof o){const e=this.getPanel(o);e&&this.doSetGroupActive(e)}this.gridview.layout(this.width,this.height),this._onDidLayoutfromJSON.fire()}closeAllGroups(){for(const e of this._groups.entries()){const[t,i]=e;i.value.model.closeAllPanels()}}fireMouseEvent(t){t.kind===e.MouseEventKind.CONTEXT_MENU&&t.tab&&t.panel&&this._onTabContextMenu.fire({event:t.event,api:this._api,panel:t.panel})}addPanel(t){var i,s;if(this.panels.find((e=>e.id===t.id)))throw new Error(`panel with id ${t.id} already exists`);let n,o;if(null===(i=t.position)||void 0===i?void 0:i.referencePanel){const e=this.getGroupPanel(t.position.referencePanel);if(!e)throw new Error(`referencePanel ${t.position.referencePanel} does not exist`);n=this.findGroup(e)}else n=this.activeGroup;if(n){const i=ge((null===(s=t.position)||void 0===s?void 0:s.direction)||"within");if(i===e.Position.Center)o=this.createPanel(t,n),n.model.openPanel(o);else{const e=X(n.element),s=K(this.gridview.orientation,e,i),r=this.createGroupAtLocation(s);o=this.createPanel(t,r),r.model.openPanel(o)}}else{const e=this.createGroupAtLocation();o=this.createPanel(t,e),e.model.openPanel(o)}return o}removePanel(e,t={removeEmptyGroup:!0,skipDispose:!1}){const i=e.group;if(!i)throw new Error(`cannot remove panel ${e.id}. it's missing a group.`);i.model.removePanel(e),e.dispose();!(1===this.size)&&0===i.size&&t.removeEmptyGroup&&this.removeGroup(i)}createWatermarkComponent(){var e;return ze("watermark-id","watermark-name",this.options.watermarkComponent?{"watermark-name":this.options.watermarkComponent}:{},this.options.watermarkFrameworkComponent?{"watermark-name":this.options.watermarkFrameworkComponent}:{},null===(e=this.options.frameworkComponentFactory)||void 0===e?void 0:e.watermark)}addEmptyGroup(e){const t=this.createGroup();if(e){const i=this.panels.find((t=>t.id===e.referencePanel));if(!i)throw new Error(`reference panel ${e.referencePanel} does not exist`);const s=this.findGroup(i);if(!s)throw new Error(`reference group for reference panel ${e.referencePanel} does not exist`);const n=ge(e.direction||"within"),o=X(s.element),r=K(this.gridview.orientation,o,n);this.doAddGroup(t,r)}else this.doAddGroup(t)}removeGroup(e,t=!1){const i=[...e.panels];for(const e of i)this.removePanel(e,{removeEmptyGroup:!1,skipDispose:!1});super.doRemoveGroup(e,{skipActive:t})}moveGroupOrPanel(t,i,s,n,o){var r;const a=i?null===(r=this._groups.get(i))||void 0===r?void 0:r.value:void 0;if(n&&n!==e.Position.Center){const e=X(t.element),i=K(this.gridview.orientation,e,n);if(a&&a.size<2){const[e,s]=A(i),o=X(a.element),[r,h]=A(o);if(O(r,e))this.gridview.moveView(r,h,s);else{const e=this.doRemoveGroup(a,{skipActive:!0,skipDispose:!0}),i=X(t.element),s=K(this.gridview.orientation,i,n);this.doAddGroup(e,s)}}else{const t=(null==a?void 0:a.model.removePanel(s))||this.panels.find((e=>e.id===s));if(!t)throw new Error(`No panel with id ${s}`);const i=K(this.gridview.orientation,e,n);this.createGroupAtLocation(i).model.openPanel(t)}}else{const e=(null==a?void 0:a.model.removePanel(s))||this.panels.find((e=>e.id===s));if(!e)throw new Error(`No panel with id ${s}`);0===(null==a?void 0:a.model.size)&&this.doRemoveGroup(a),t.model.openPanel(e,{index:o})}}doSetGroupActive(e,t){var i,s;const n=this._activeGroup===e;super.doSetGroupActive(e,t),!n&&(null===(i=this._activeGroup)||void 0===i?void 0:i.activePanel)&&this._onDidActivePanelChange.fire(null===(s=this._activeGroup)||void 0===s?void 0:s.activePanel)}createGroup(t){t||(t={tabHeight:this.tabHeight}),"number"!=typeof t.tabHeight&&(t.tabHeight=this.tabHeight);let i=null==t?void 0:t.id;if(i&&this._groups.has(t.id)&&(console.warn(`Duplicate group id ${null==t?void 0:t.id}. reassigning group id to avoid errors`),i=void 0),!i)for(i=Ve.next();this._groups.has(i);)i=Ve.next();const s=new Oe(this,i,t);if(s.init({params:{},accessor:null}),!this._groups.has(s.id)){const t=new w(s.model.onMove((e=>{const{groupId:t,itemId:i,target:n,index:o}=e;this.moveGroupOrPanel(s,t,i,n,o)})),s.model.onDidDrop((e=>{this._onDidDrop.fire(Object.assign(Object.assign({},e),{api:this._api}))})),s.model.onDidGroupChange((t=>{switch(t.kind){case e.GroupChangeKind2.ADD_PANEL:t.panel&&this._onDidAddPanel.fire(t.panel);break;case e.GroupChangeKind2.REMOVE_PANEL:t.panel&&this._onDidRemovePanel.fire(t.panel);break;case e.GroupChangeKind2.PANEL_ACTIVE:this._onDidActivePanelChange.fire(t.panel)}})));this._groups.set(s.id,{value:s,disposable:t})}return s.initialize(),"number"==typeof this.options.tabHeight&&(s.model.header.height=this.options.tabHeight),s}createPanel(e,t){const i=new Ne({content:this.createContentComponent(e.id,e.component),tab:this.createTabComponent(e.id,e.tabComponent)}),s=new be(e.id,this,this._api,t);return s.init({view:i,title:e.title||e.id,suppressClosable:null==e?void 0:e.suppressClosable,params:(null==e?void 0:e.params)||{}}),s}createContentComponent(e,t){var i;return ze(e,t,this.options.components||{},this.options.frameworkComponents,null===(i=this.options.frameworkComponentFactory)||void 0===i?void 0:i.content)}createTabComponent(e,t){var i;return ze(e,t,this.options.tabComponents||{},this.options.frameworkTabComponents,null===(i=this.options.frameworkComponentFactory)||void 0===i?void 0:i.tab,(()=>new Ee))}createGroupAtLocation(e=[0]){const t=this.createGroup();return this.doAddGroup(t,e),t}findGroup(e){var t;return null===(t=Array.from(this._groups.values()).find((t=>t.value.model.containsPanel(e))))||void 0===t?void 0:t.value}dispose(){super.dispose(),this._onDidActivePanelChange.dispose(),this._onDidAddPanel.dispose(),this._onDidRemovePanel.dispose(),this._onDidLayoutfromJSON.dispose()}}class Le extends we{constructor(e,t){super(e,{proportionalLayout:t.proportionalLayout,orientation:t.orientation,styles:t.styles}),this._onDidLayoutfromJSON=new u,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._options=t,this.options.components||(this.options.components={}),this.options.frameworkComponents||(this.options.frameworkComponents={})}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}updateOptions(e){const t="string"==typeof e.orientation&&this.options.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:null===(e=this.activeGroup)||void 0===e?void 0:e.id}}setVisible(e,t){this.gridview.setViewVisible(X(e.element),t)}setActive(e){this._groups.forEach(((t,i)=>{t.value.setActive(e===t.value)}))}focus(){var e;null===(e=this.activeGroup)||void 0===e||e.focus()}fromJSON(e){const{grid:t,activePanel:i}=e,s=Array.from(this._groups.values());for(const e of s)e.disposable.dispose(),this.doRemoveGroup(e.value,{skipActive:!0});this.gridview.clear();const n=[];if(this.gridview.deserialize(t,{fromJSON:e=>{const{data:t}=e,i=ze(t.id,t.component,this.options.components||{},this.options.frameworkComponents||{},this.options.frameworkComponentFactory?{createComponent:this.options.frameworkComponentFactory.createComponent}:void 0);return n.push((()=>i.init({params:t.params,minimumWidth:t.minimumWidth,maximumWidth:t.maximumWidth,minimumHeight:t.minimumHeight,maximumHeight:t.maximumHeight,priority:t.priority,snap:!!t.snap,accessor:this,isVisible:e.visible}))),this.registerPanel(i),i}}),this.layout(this.width,this.height,!0),n.forEach((e=>e())),"string"==typeof i){const e=this.getPanel(i);e&&this.doSetGroupActive(e)}this._onDidLayoutfromJSON.fire()}movePanel(t,i){var s;let n;const o=this.gridview.remove(t),r=null===(s=this._groups.get(i.reference))||void 0===s?void 0:s.value;if(!r)throw new Error(`reference group ${i.reference} does not exist`);const a=ge(i.direction);if(a===e.Position.Center)throw new Error(`${a} not supported as an option`);{const e=X(r.element);n=K(this.gridview.orientation,e,a)}this.doAddGroup(o,n,i.size)}addPanel(t){var i,s;let n=t.location||[0];if(null===(i=t.position)||void 0===i?void 0:i.referencePanel){const i=null===(s=this._groups.get(t.position.referencePanel))||void 0===s?void 0:s.value;if(!i)throw new Error(`reference group ${t.position.referencePanel} does not exist`);const o=ge(t.position.direction);if(o===e.Position.Center)throw new Error(`${o} not supported as an option`);{const e=X(i.element);n=K(this.gridview.orientation,e,o)}}const o=ze(t.id,t.component,this.options.components||{},this.options.frameworkComponents||{},this.options.frameworkComponentFactory?{createComponent:this.options.frameworkComponentFactory.createComponent}:void 0);return o.init({params:t.params||{},minimumWidth:t.minimumWidth,maximumWidth:t.maximumWidth,minimumHeight:t.minimumHeight,maximumHeight:t.maximumHeight,priority:t.priority,snap:!!t.snap,accessor:this,isVisible:!0}),this.registerPanel(o),this.doAddGroup(o,n,t.size),o}registerPanel(e){const t=new w(e.api.onDidFocusChange((t=>{t.isFocused&&this._groups.forEach((t=>{const i=t.value;i!==e?i.setActive(!1):i.setActive(!0)}))})));this._groups.set(e.id,{value:e,disposable:t})}moveGroup(e,t,i){const s=this.getPanel(t);if(!s)throw new Error("invalid operation");const n=X(e.element),o=K(this.gridview.orientation,n,i),[r,a]=A(o),h=X(s.element),[d,l]=A(h);if(O(d,r))return void this.gridview.moveView(d,l,a);const p=this.doRemoveGroup(s,{skipActive:!0,skipDispose:!0}),m=X(e.element),u=K(this.gridview.orientation,m,i);this.doAddGroup(p,u)}removeGroup(e){super.removeGroup(e)}dispose(){super.dispose(),this._onDidLayoutfromJSON.dispose()}}class Te extends w{constructor(e,t){super(),this.element=e,this._disposable=new _,this._panels=new Map,this._onDidLayoutfromJSON=new u,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidAddView=new u,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new u,this.onDidRemoveView=this._onDidRemoveView.event,this._onDidLayoutChange=new u,this.onDidLayoutChange=this._onDidLayoutChange.event,this._options=t,t.components||(t.components={}),t.frameworkComponents||(t.frameworkComponents={}),this.splitview=new M(this.element,t),this.addDisposables(this._disposable,this._onDidAddView,this._onDidLayoutfromJSON,this._onDidRemoveView,this._onDidLayoutChange)}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=e,this._disposable.value=new w(this._splitview.onDidSashEnd((()=>{this._onDidLayoutChange.fire(void 0)})),this._splitview.onDidAddView((e=>this._onDidAddView.fire(e))),this._splitview.onDidRemoveView((e=>this._onDidRemoveView.fire(e))))}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get height(){return this.splitview.orientation===e.Orientation.HORIZONTAL?this.splitview.orthogonalSize:this.splitview.size}get width(){return this.splitview.orientation===e.Orientation.HORIZONTAL?this.splitview.size:this.splitview.orthogonalSize}updateOptions(e){const t="string"==typeof e.orientation&&this.options.orientation!==e.orientation;this._options=Object.assign(Object.assign({},this.options),e),t&&(this.splitview.orientation=e.orientation),this.splitview.layout(this.splitview.size,this.splitview.orthogonalSize)}focus(){var e;null===(e=this._activePanel)||void 0===e||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((t=>t!==e)).forEach((e=>{e.api._onDidActiveChange.fire({isActive:!1}),t||e.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.disposable.dispose(),i.value.dispose(),this._panels.delete(e.id);const s=this.panels.findIndex((t=>t===e));this.splitview.removeView(s,t);const n=this.panels;n.length>0&&this.setActive(n[n.length-1])}getPanel(e){return this.panels.find((t=>t.id===e))}addPanel(t){if(this._panels.has(t.id))throw new Error(`panel ${t.id} already exists`);const i=ze(t.id,t.component,this.options.components||{},this.options.frameworkComponents||{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.createComponent}:void 0);i.orientation=this.splitview.orientation,i.init({params:t.params||{},minimumSize:t.minimumSize,maximumSize:t.maximumSize,snap:t.snap,priority:t.priority,accessor:this});const s="number"==typeof t.size?t.size:e.Sizing.Distribute,n="number"==typeof t.index?t.index:void 0;return this.splitview.addView(i,s,n),this.doAddView(i),this.setActive(i),i}layout(t,i){const[s,n]=this.splitview.orientation===e.Orientation.HORIZONTAL?[t,i]:[i,t];this.splitview.layout(s,n)}doAddView(e){const t=e.api.onDidFocusChange((t=>{t.isFocused&&this.setActive(e,!0)}));this._panels.set(e.id,{disposable:t,value:e})}toJSON(){var e;return{views:this.splitview.getViews().map(((e,t)=>({size:this.splitview.getViewSize(t),data:e.toJSON(),snap:!!e.snap,priority:e.priority}))),activeView:null===(e=this._activePanel)||void 0===e?void 0:e.id,size:this.splitview.size,orientation:this.splitview.orientation}}fromJSON(e){const{views:t,orientation:i,size:s,activeView:n}=e;for(const[e,t]of this._panels.entries())t.disposable.dispose(),t.value.dispose();this._panels.clear(),this.splitview.dispose();const o=[];if(this.splitview=new M(this.element,{orientation:i,proportionalLayout:this.options.proportionalLayout,descriptor:{size:s,views:t.map((e=>{const t=e.data;if(this._panels.has(t.id))throw new Error(`panel ${t.id} already exists`);const s=ze(t.id,t.component,this.options.components||{},this.options.frameworkComponents||{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.createComponent}:void 0);return o.push((()=>{s.init({params:t.params||{},minimumSize:t.minimumSize,maximumSize:t.maximumSize,snap:e.snap,priority:e.priority,accessor:this})})),s.orientation=i,this.doAddView(s),setTimeout((()=>{this._onDidAddView.fire(s)}),0),{size:e.size,view:s}}))}}),this.layout(this.width,this.height),o.forEach((e=>e())),"string"==typeof n){const e=this.getPanel(n);e&&this.setActive(e)}this._onDidLayoutfromJSON.fire()}dispose(){for(const[e,t]of this._panels.entries())t.disposable.dispose(),t.value.dispose();this._panels.clear(),this.splitview.dispose(),super.dispose()}}class Ge extends _e{constructor(e){super(e),this._onDidConstraintsChangeInternal=new u,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new u({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new u,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 Re extends Ge{constructor(e){super(e),this._onDidExpansionChange=new u({replay:!0}),this.onDidExpansionChange=this._onDidExpansionChange.event,this._onMouseEnter=new u({}),this.onMouseEnter=this._onMouseEnter.event,this._onMouseLeave=new u({}),this.onMouseLeave=this._onMouseLeave.event,this.addDisposables(this._onDidExpansionChange,this._onMouseEnter,this._onMouseLeave)}set pane(e){this._pane=e}setExpanded(e){var t;null===(t=this._pane)||void 0===t||t.setExpanded(e)}get isExpanded(){var e;return!!(null===(e=this._pane)||void 0===e?void 0:e.isExpanded())}}class ke extends xe{constructor(e,t,i,s,n,o){super(e,t,new Re(e)),this.headerComponent=i,this._onDidChangeExpansionState=new u({replay:!0}),this.onDidChangeExpansionState=this._onDidChangeExpansionState.event,this._onDidChange=new u,this.onDidChange=this._onDidChange.event,this.headerSize=22,this._orthogonalSize=0,this._size=0,this._minimumBodySize=100,this._maximumBodySize=Number.POSITIVE_INFINITY,this._isExpanded=!1,this.expandedSize=0,this.api.pane=this,this._isExpanded=n,this._headerVisible=o,this._onDidChangeExpansionState.fire(this.isExpanded()),this._orientation=s,this.element.classList.add("pane"),this.addDisposables(this.api.onDidSizeChange((e=>{this._onDidChange.fire(e.size)})),v(this.element,"mouseenter",(e=>{this.api._onMouseEnter.fire(e)})),v(this.element,"mouseleave",(e=>{this.api._onMouseLeave.fire(e)}))),this.addDisposables(this._onDidChangeExpansionState,this.onDidChangeExpansionState((e=>{this.api._onDidExpansionChange.fire({isExpanded:e})})),this.api.onDidFocusChange((e=>{this.header&&(e.isFocused?b(this.header,"focused"):C(this.header,"focused"))}))),this.renderOnce()}set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){return this.headerSize+(this.isExpanded()?this._minimumBodySize:0)}get maximumSize(){return this.headerSize+(this.isExpanded()?this._maximumBodySize:0)}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="number"==typeof e?e:0}get maximumBodySize(){return this._maximumBodySize}set maximumBodySize(e){this._maximumBodySize="number"==typeof e?e:Number.POSITIVE_INFINITY}get headerVisible(){return this._headerVisible}set headerVisible(e){this._headerVisible=e,this.header.style.display=e?"":"none"}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 e;null===(e=this.body)||void 0===e||e.remove()}),200),this._onDidChange.fire(e?this.width:void 0),this._onDidChangeExpansionState.fire(e))}layout(t,i){this._size=t,this._orthogonalSize=i;const[s,n]=this.orientation===e.Orientation.HORIZONTAL?[t,i]:[i,t];this.isExpanded()&&(this.expandedSize=s),super.layout(s,n)}init(e){var t,i;super.init(e),"number"==typeof e.minimumBodySize&&(this.minimumBodySize=e.minimumBodySize),"number"==typeof e.maximumBodySize&&(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})),null===(t=this.body)||void 0===t||t.append(this.bodyPart.element),null===(i=this.header)||void 0===i||i.append(this.headerPart.element),"boolean"==typeof e.isExpanded&&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="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="pane-body",this.element.appendChild(this.body)}getComponent(){return{update:e=>{var t,i;null===(t=this.bodyPart)||void 0===t||t.update({params:e}),null===(i=this.headerPart)||void 0===i||i.update({params:e})},dispose:()=>{var e,t;null===(e=this.bodyPart)||void 0===e||e.dispose(),null===(t=this.headerPart)||void 0===t||t.dispose()}}}}class He extends ke{constructor(e,t,i,s,n,o){super(e,t,i,s,n,!0),this._onDidDrop=new u,this.onDidDrop=this._onDidDrop.event,o||this.initDragFeatures()}initDragFeatures(){if(!this.header)return;const e=this.id;this.header.draggable=!0,this.handler=new class extends pe{getData(){return l.getInstance().setData([new d("paneview",e)],d.prototype),{dispose:()=>{l.getInstance().clearData(d.prototype)}}}}(this.header),this.target=new J(this.element,{validOverlays:"vertical",canDisplayOverlay:()=>{const e=m();return!e||e.paneId!==this.id}}),this.addDisposables(this._onDidDrop,this.handler,this.target,this.target.onDrop((e=>{this.onDrop(e)})))}onDrop(t){const i=m();if(!i)return void this._onDidDrop.fire(Object.assign(Object.assign({},t),{panel:this,getData:()=>m()}));const s=this._params.containerApi,n=i.paneId,o=s.getPanel(n);if(!o)return void this._onDidDrop.fire(Object.assign(Object.assign({},t),{panel:this,getData:()=>m()}));const r=s.panels,a=r.indexOf(o);let h=s.panels.indexOf(this);t.position!==e.Position.Left&&t.position!==e.Position.Top||(h=Math.max(0,h-1)),t.position!==e.Position.Right&&t.position!==e.Position.Bottom||(a>h&&h++,h=Math.min(r.length-1,h)),s.movePanel(a,h)}}class Me extends w{constructor(){super(),this.disposable=new _,this.apiRef={api:null},this._element=document.createElement("div"),this.element.className="default-header",this._content=document.createElement("span"),this._expander=document.createElement("a"),this.element.appendChild(this._content),this.element.appendChild(this._expander),this.addDisposables(v(this._expander,"click",(()=>{var e;null===(e=this.apiRef.api)||void 0===e||e.setExpanded(!this.apiRef.api.isExpanded)})))}get element(){return this._element}init(e){this.apiRef.api=e.api,this._content.textContent=e.title,this._expander.textContent=e.api.isExpanded?"<":">",this.disposable.value=e.api.onDidExpansionChange((e=>{this._expander.textContent=e.isExpanded?"<":">"}))}update(e){}dispose(){this.disposable.dispose(),super.dispose()}}class Fe extends He{constructor(e){super(e.id,e.component,e.headerComponent,e.orientation,e.isExpanded,e.disableDnd),this.options=e}getBodyComponent(){return this.options.body}getHeaderComponent(){return this.options.header}}class We extends w{constructor(t,i){super(),this.element=t,this._disposable=new _,this._viewDisposables=new Map,this._onDidLayoutfromJSON=new u,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidLayoutChange=new u,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidDrop=new u,this.onDidDrop=this._onDidDrop.event,this._onDidAddView=new u,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new u,this.onDidRemoveView=this._onDidRemoveView.event,this.addDisposables(this._onDidLayoutChange,this._onDidLayoutfromJSON,this._onDidDrop,this._onDidAddView,this._onDidRemoveView),this._options=i,i.components||(i.components={}),i.frameworkComponents||(i.frameworkComponents={}),this.paneview=new F(this.element,{orientation:e.Orientation.VERTICAL}),this.addDisposables(this._disposable)}get panels(){return this.paneview.getPanes()}set paneview(e){this._paneview=e,this._disposable.value=new w(this._paneview.onDidChange((()=>{this._onDidLayoutChange.fire(void 0)})),this._paneview.onDidAddView((e=>this._onDidAddView.fire(e))),this._paneview.onDidRemoveView((e=>this._onDidRemoveView.fire(e))))}get paneview(){return this._paneview}get minimumSize(){return this.paneview.minimumSize}get maximumSize(){return this.paneview.maximumSize}get height(){return this.paneview.orientation===e.Orientation.HORIZONTAL?this.paneview.orthogonalSize:this.paneview.size}get width(){return this.paneview.orientation===e.Orientation.HORIZONTAL?this.paneview.size:this.paneview.orthogonalSize}get options(){return this._options}focus(){}updateOptions(e){this._options=Object.assign(Object.assign({},this.options),e)}addPanel(t){const i=ze(t.id,t.component,this.options.components||{},this.options.frameworkComponents||{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.body.createComponent}:void 0);let s;s=t.headerComponent?ze(t.id,t.headerComponent,this.options.headerComponents||{},this.options.headerframeworkComponents,this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.header.createComponent}:void 0):new Me;const n=new Fe({id:t.id,component:t.component,headerComponent:t.headerComponent,header:s,body:i,orientation:e.Orientation.VERTICAL,isExpanded:!!t.isExpanded,disableDnd:!!this.options.disableDnd});this.doAddPanel(n);const o="number"==typeof t.size?t.size:e.Sizing.Distribute,r="number"==typeof t.index?t.index:void 0;return n.init({params:t.params||{},minimumBodySize:t.minimumBodySize,maximumBodySize:t.maximumBodySize,isExpanded:t.isExpanded,title:t.title,containerApi:new ne(this)}),this.paneview.addPane(n,o,r),n.orientation=this.paneview.orientation,n}removePanel(e){const t=this.panels.findIndex((t=>t===e));this.paneview.removePane(t),this.doRemovePanel(e)}movePanel(e,t){this.paneview.moveView(e,t)}getPanel(e){return this.panels.find((t=>t.id===e))}layout(t,i){const[s,n]=this.paneview.orientation===e.Orientation.HORIZONTAL?[t,i]:[i,t];this.paneview.layout(s,n)}toJSON(){const e=e=>e===Number.MAX_SAFE_INTEGER||e===Number.POSITIVE_INFINITY?void 0:e;return{views:this.paneview.getPanes().map(((t,i)=>{return{size:this.paneview.getViewSize(i),data:t.toJSON(),minimumSize:(s=t.minimumBodySize,s<=0?void 0:s),maximumSize:e(t.maximumBodySize),expanded:t.isExpanded()};var s})),size:this.paneview.size}}fromJSON(t){const{views:i,size:s}=t,n=[];for(const[e,t]of this._viewDisposables.entries())t.dispose();this._viewDisposables.clear(),this.paneview.dispose(),this.paneview=new F(this.element,{orientation:e.Orientation.VERTICAL,descriptor:{size:s,views:i.map((t=>{const i=t.data,s=ze(i.id,i.component,this.options.components||{},this.options.frameworkComponents||{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.body.createComponent}:void 0);let o;o=i.headerComponent?ze(i.id,i.headerComponent,this.options.headerComponents||{},this.options.headerframeworkComponents||{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.header.createComponent}:void 0):new Me;const r=new Fe({id:i.id,component:i.component,headerComponent:i.headerComponent,header:o,body:s,orientation:e.Orientation.VERTICAL,isExpanded:!!t.expanded,disableDnd:!!this.options.disableDnd});return this.doAddPanel(r),n.push((()=>{r.init({params:i.params||{},minimumBodySize:t.minimumSize,maximumBodySize:t.maximumSize,title:i.title,isExpanded:!!t.expanded,containerApi:new ne(this)}),r.orientation=this.paneview.orientation})),setTimeout((()=>{this._onDidAddView.fire(r)}),0),{size:t.size,view:r}}))}}),this.layout(this.width,this.height),n.forEach((e=>e())),this._onDidLayoutfromJSON.fire()}doAddPanel(e){const t=e.onDidDrop((e=>{this._onDidDrop.fire(e)}));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.paneview.dispose()}}class Je extends xe{constructor(e,t){super(e,t,new Ge(e)),this._evaluatedMinimumSize=0,this._evaluatedMaximumSize=Number.POSITIVE_INFINITY,this._minimumSize=0,this._maximumSize=Number.POSITIVE_INFINITY,this._snap=!1,this._onDidChange=new u,this.onDidChange=this._onDidChange.event,this.addDisposables(this._onDidChange,this.api.onVisibilityChange((e=>{const{isVisible:t}=e,{accessor:i}=this._params;i.setVisible(this,t)})),this.api.onActiveChange((()=>{const{accessor:e}=this._params;e.setActive(this)})),this.api.onDidConstraintsChangeInternal((e=>{"number"!=typeof e.minimumSize&&"function"!=typeof e.minimumSize||(this._minimumSize=e.minimumSize),"number"!=typeof e.maximumSize&&"function"!=typeof e.maximumSize||(this._maximumSize=e.maximumSize),this.updateConstraints()})),this.api.onDidSizeChange((e=>{this._onDidChange.fire(e.size)})))}get priority(){return this._priority}set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){const e="function"==typeof this._minimumSize?this._minimumSize():this._minimumSize;return e!==this._evaluatedMinimumSize&&(this._evaluatedMinimumSize=e,this.updateConstraints()),e}get maximumSize(){const e="function"==typeof this._maximumSize?this._maximumSize():this._maximumSize;return e!==this._evaluatedMaximumSize&&(this._evaluatedMaximumSize=e,this.updateConstraints()),e}get snap(){return this._snap}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}layout(t,i){const[s,n]=this.orientation===e.Orientation.HORIZONTAL?[t,i]:[i,t];super.layout(s,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(){return Object.assign(Object.assign({},super.toJSON()),{minimumSize:(e=this.minimumSize,e<=0?void 0:e),maximumSize:(e=>e===Number.MAX_SAFE_INTEGER||e===Number.POSITIVE_INFINITY?void 0:e)(this.maximumSize)});var e}updateConstraints(){this.api._onDidConstraintsChange.fire({maximumSize:this._evaluatedMaximumSize,minimumSize:this._evaluatedMinimumSize})}}const Be=(e,t)=>{const[i,s]=o.useState(),n=o.useRef(e.componentProps);return o.useImperativeHandle(t,(()=>({update:e=>{n.current=Object.assign(Object.assign({},n.current),e),s(Date.now())}})),[]),o.createElement(e.component,n.current)};Be.displayName="DockviewReactJsBridge";const je=P(),$e=o.createContext({});class Ze{constructor(e,t,i,s,n){this.parent=e,this.portalStore=t,this.component=i,this.parameters=s,this.context=n,this.disposed=!1,this.createPortal()}update(e){var t;if(this.disposed)throw new Error("invalid operation: resource is already disposed");null===(t=this.componentInstance)||void 0===t||t.update(e)}createPortal(){if(this.disposed)throw new Error("invalid operation: resource is already disposed");if("function"!=typeof this.component)throw new Error("Invalid Operation. dockview only supports React Functional Components.");const e=o.createElement(o.forwardRef(Be),{component:this.component,componentProps:this.parameters,ref:e=>{this.componentInstance=e}}),t=this.context?o.createElement($e.Provider,{value:this.context},e):e,i=r.createPortal(t,this.parent,je.next());this.ref={portal:i,disposable:this.portalStore.addPortal(i)}}dispose(){var e;null===(e=this.ref)||void 0===e||e.disposable.dispose(),this.disposed=!0}}const Ue=()=>{const[e,t]=o.useState([]);o.useDebugValue(`Portal count: ${e.length}`);return[e,o.useCallback((e=>{t((t=>[...t,e]));let i=!1;return{dispose:()=>{if(i)throw new Error("invalid operation: resource already disposed");i=!0,t((t=>t.filter((t=>t!==e))))}}}),[])]};class Xe{constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._onDidFocus=new u,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new u,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="dockview-react-part",this._actionsElement=document.createElement("div"),this._actionsElement.className="dockview-react-part"}get element(){return this._element}get actions(){return this._actionsElement}focus(){}init(e){const t={api:e.api,containerApi:e.containerApi,actionsPortalElement:this._actionsElement,tabPortalElement:e.tab};this.part=new Ze(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi},t)}toJSON(){return{id:this.id}}update(e){var t;null===(t=this.part)||void 0===t||t.update(e.params)}updateParentGroup(e,t){this._group=e}layout(e,t){}dispose(){var e,t;this._onDidFocus.dispose(),this._onDidBlur.dispose(),null===(e=this.part)||void 0===e||e.dispose(),null===(t=this.actionsPart)||void 0===t||t.dispose()}}class Ke{constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.className="dockview-react-part"}get element(){return this._element}focus(){}init(e){this.part=new Ze(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi})}update(e){var t;null===(t=this.part)||void 0===t||t.update(e.params)}toJSON(){return{id:this.id}}layout(e,t){}updateParentGroup(e,t){}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}class Ye{constructor(e){this.layout=e}fromJSON(e,t){var i,s,n;const o=e.id,r=e.params,a=e.title,h=e.suppressClosable,d=e.view,l=new Ne({content:ze(d.content.id,d.content.id,this.layout.options.components,this.layout.options.frameworkComponents,null===(i=this.layout.options.frameworkComponentFactory)||void 0===i?void 0:i.content),tab:(null===(s=d.tab)||void 0===s?void 0:s.id)?ze(d.tab.id,d.tab.id,this.layout.options.tabComponents,this.layout.options.frameworkTabComponents,null===(n=this.layout.options.frameworkComponentFactory)||void 0===n?void 0:n.tab):new Ee}),p=new be(o,this.layout,new re(this.layout),t);return p.init({view:l,title:a,suppressClosable:h,params:r||{}}),p}}class Qe{constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._groupRef={value:void 0},this._element=document.createElement("div"),this._element.className="dockview-react-part"}get element(){return this._element}init(e){this.parameters=e,this.part=new Ze(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi,close:()=>{this._groupRef.value&&e.containerApi.removeGroup(this._groupRef.value)}})}focus(){}update(e){var t,i;this.parameters&&(this.parameters.params=e.params),null===(t=this.part)||void 0===t||t.update({params:(null===(i=this.parameters)||void 0===i?void 0:i.params)||{}})}toJSON(){return{id:this.id}}layout(e,t){}updateParentGroup(e,t){this._groupRef.value=e}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}const qe=o.forwardRef(((e,t)=>{const i=o.useRef(null),s=o.useRef(),[n,r]=Ue();return o.useImperativeHandle(t,(()=>i.current),[]),o.useEffect((()=>{if(e.disableAutoResizing)return()=>{};const t=f(i.current,(e=>{var t;const{width:i,height:n}=e.contentRect;null===(t=s.current)||void 0===t||t.layout(i,n)}));return()=>{t.dispose()}}),[e.disableAutoResizing]),o.useEffect((()=>{var t;const n={content:{createComponent:(e,t,i)=>new Xe(t,i,{addPortal:r})},tab:{createComponent:(e,t,i)=>new Ke(t,i,{addPortal:r})},watermark:{createComponent:(e,t,i)=>new Qe(t,i,{addPortal:r})}},o=document.createElement("div"),a=new Ie(o,{frameworkComponentFactory:n,frameworkComponents:e.components,frameworkTabComponents:e.tabComponents,tabHeight:e.tabHeight,watermarkFrameworkComponent:e.watermarkComponent,styles:e.hideBorders?{separatorBorder:"transparent"}:void 0});null===(t=i.current)||void 0===t||t.appendChild(a.element),a.deserializer=new Ye(a);const{clientWidth:h,clientHeight:d}=i.current;return a.layout(h,d),e.onReady&&e.onReady({api:new re(a)}),s.current=a,()=>{a.dispose(),o.remove()}}),[]),o.useEffect((()=>{if(!s.current)return()=>{};const t=s.current.onDidDrop((t=>{e.onDidDrop&&e.onDidDrop(t)}));return()=>{t.dispose()}}),[e.onDidDrop]),o.useEffect((()=>{s.current&&s.current.updateOptions({frameworkComponents:e.components})}),[e.components]),o.useEffect((()=>{s.current&&s.current.updateOptions({watermarkFrameworkComponent:e.watermarkComponent})}),[e.watermarkComponent]),o.useEffect((()=>{s.current&&s.current.updateOptions({showDndOverlay:e.showDndOverlay})}),[e.showDndOverlay]),o.useEffect((()=>{s.current&&s.current.updateOptions({frameworkTabComponents:e.tabComponents})}),[e.tabComponents]),o.useEffect((()=>{if(!e.onTabContextMenu||!s.current)return()=>{};const t=s.current.onTabContextMenu((t=>{e.onTabContextMenu&&e.onTabContextMenu(t)}));return()=>{t.dispose()}}),[e.onTabContextMenu]),o.createElement("div",{className:e.className,style:{height:"100%",width:"100%"},ref:i},n)}));qe.displayName="DockviewComponent";class et extends Je{constructor(e,t,i,s){super(e,t),this.reactComponent=i,this.reactPortalStore=s}getComponent(){var e;return new Ze(this.element,this.reactPortalStore,this.reactComponent,{params:(null===(e=this._params)||void 0===e?void 0:e.params)||{},api:this.api,containerApi:new se(this._params.accessor)})}}const tt=o.forwardRef(((t,i)=>{const s=o.useRef(null),n=o.useRef(),[r,a]=Ue();return o.useImperativeHandle(i,(()=>s.current),[]),o.useEffect((()=>{if(t.disableAutoResizing)return()=>{};const e=f(s.current,(e=>{var t;const{width:i,height:s}=e.contentRect;null===(t=n.current)||void 0===t||t.layout(i,s)}));return()=>{e.dispose()}}),[t.disableAutoResizing]),o.useEffect((()=>{const i=new Te(s.current,{orientation:t.orientation||e.Orientation.HORIZONTAL,frameworkComponents:t.components,frameworkWrapper:{createComponent:(e,t,i)=>new et(e,t,i,{addPortal:a})},proportionalLayout:"boolean"!=typeof t.proportionalLayout||t.proportionalLayout,styles:t.hideBorders?{separatorBorder:"transparent"}:void 0}),{clientWidth:o,clientHeight:r}=s.current;return i.layout(o,r),t.onReady&&t.onReady({api:new se(i)}),n.current=i,()=>{i.dispose()}}),[]),o.useEffect((()=>{n.current&&n.current.updateOptions({frameworkComponents:t.components})}),[t.components]),o.createElement("div",{className:t.className,style:{height:"100%",width:"100%"},ref:s},r)}));tt.displayName="SplitviewComponent";class it extends Pe{constructor(e,t,i,s){super(e,t),this.reactComponent=i,this.reactPortalStore=s}getComponent(){var e;return new Ze(this.element,this.reactPortalStore,this.reactComponent,{params:(null===(e=this._params)||void 0===e?void 0:e.params)||{},api:this.api,containerApi:new oe(this._params.accessor)})}}const st=o.forwardRef(((t,i)=>{const s=o.useRef(null),n=o.useRef(),[r,a]=Ue();return o.useImperativeHandle(i,(()=>s.current),[]),o.useEffect((()=>{if(t.disableAutoResizing)return()=>{};const e=f(s.current,(e=>{var t;const{width:i,height:s}=e.contentRect;null===(t=n.current)||void 0===t||t.layout(i,s)}));return()=>{e.dispose()}}),[t.disableAutoResizing]),o.useEffect((()=>{var i;const o=document.createElement("div"),r=new Le(o,{proportionalLayout:"boolean"!=typeof t.proportionalLayout||t.proportionalLayout,orientation:t.orientation||e.Orientation.HORIZONTAL,frameworkComponents:t.components,frameworkComponentFactory:{createComponent:(e,t,i)=>new it(e,t,i,{addPortal:a})},styles:t.hideBorders?{separatorBorder:"transparent"}:void 0});null===(i=s.current)||void 0===i||i.appendChild(r.element);const{clientWidth:h,clientHeight:d}=s.current;return r.layout(h,d),t.onReady&&t.onReady({api:new oe(r)}),n.current=r,()=>{r.dispose(),o.remove()}}),[]),o.useEffect((()=>{n.current&&n.current.updateOptions({frameworkComponents:t.components})}),[t.components]),o.createElement("div",{className:t.className,style:{height:"100%",width:"100%"},ref:s},r)}));st.displayName="GridviewComponent";class nt{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%"}get element(){return this._element}init(e){this.part=new Ze(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;null===(t=this.part)||void 0===t||t.update(e.params)}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}const ot=o.forwardRef(((e,t)=>{const i=o.useRef(null),s=o.useRef(),[n,r]=Ue();return o.useImperativeHandle(t,(()=>i.current),[]),o.useEffect((()=>{if(e.disableAutoResizing)return()=>{};const t=f(i.current,(e=>{var t;const{width:i,height:n}=e.contentRect;null===(t=s.current)||void 0===t||t.layout(i,n)}));return()=>{t.dispose()}}),[e.disableAutoResizing]),o.useEffect((()=>{const t=(e,t,i)=>new nt(e,i,{addPortal:r}),n=new We(i.current,{frameworkComponents:e.components,components:{},headerComponents:{},disableDnd:e.disableDnd,headerframeworkComponents:e.headerComponents,frameworkWrapper:{header:{createComponent:t},body:{createComponent:t}}}),o=new ne(n),{clientWidth:a,clientHeight:h}=i.current;return n.layout(a,h),e.onReady&&e.onReady({api:o}),s.current=n,()=>{n.dispose()}}),[]),o.useEffect((()=>{s.current&&s.current.updateOptions({frameworkComponents:e.components})}),[e.components]),o.useEffect((()=>{s.current&&s.current.updateOptions({headerframeworkComponents:e.headerComponents})}),[e.headerComponents]),o.useEffect((()=>{if(!s.current)return()=>{};const t=s.current,i=t.onDidDrop((i=>{e.onDidDrop&&e.onDidDrop(Object.assign(Object.assign({},i),{api:new ne(t)}))}));return()=>{i.dispose()}}),[e.onDidDrop]),o.createElement("div",{className:e.className,style:{height:"100%",width:"100%"},ref:i},n)}));ot.displayName="PaneviewComponent",e.BaseGrid=we,e.ContentContainer=ae,e.DockviewApi=re,e.DockviewComponent=Ie,e.DockviewReact=qe,e.Gridview=ie,e.GridviewApi=oe,e.GridviewComponent=Le,e.GridviewPanel=Pe,e.GridviewReact=st,e.Groupview=ce,e.LocalSelectionTransfer=l,e.PaneFramework=Fe,e.PaneTransfer=d,e.PanelTransfer=h,e.Paneview=F,e.PaneviewApi=ne,e.PaneviewComponent=We,e.PaneviewPanel=ke,e.PaneviewReact=ot,e.ReactPanelContentPart=Xe,e.ReactPanelHeaderPart=Ke,e.ReactPart=Ze,e.ReactPartContext=$e,e.Splitview=M,e.SplitviewApi=se,e.SplitviewComponent=Te,e.SplitviewPanel=Je,e.SplitviewReact=tt,e.Tab=me,e.getDirectionOrientation=Y,e.getGridLocation=X,e.getLocationOrientation=Q,e.getPaneData=m,e.getPanelData=p,e.getRelativeLocation=K,e.indexInParent=U,e.isGridBranchNode=ee,e.isReactElement=function(e){return null==e?void 0:e.type},e.orthogonal=q,e.toTarget=ge,e.usePortalsLifecycle=Ue,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
7
|
+
define(["exports","react","react-dom"],(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,o=s(t),r=s(i);class a{constructor(){}}class h extends a{constructor(e,t,i){super(),this.viewId=e,this.groupId=t,this.panelId=i}}class d extends a{constructor(e,t){super(),this.viewId=e,this.paneId=t}}class l{constructor(){}static getInstance(){return l.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 p(){const e=l.getInstance();if(e.hasData(h.prototype))return e.getData(h.prototype)[0]}function m(){const e=l.getInstance();if(e.hasData(d.prototype))return e.getData(d.prototype)[0]}l.INSTANCE=new l,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 u{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.push(e),{dispose:()=>{const t=this._listeners.indexOf(e);t>-1&&this._listeners.splice(t,1)}}}),this._event}fire(e){this._last=e;for(const t of this._listeners)t(e)}dispose(){this._listeners=[],this._disposed=!0}}function c(e,t,i,s){return e.addEventListener(t,i,s),{dispose:()=>{e.removeEventListener(t,i)}}}function v(e,t,i,s){return e.addEventListener(t,i,s),{dispose:()=>{e.removeEventListener(t,i)}}}class g{constructor(){this._onFired=new u,this.onEvent=this._onFired.event}fire(){this.timer&&clearTimeout(this.timer),this.timer=setTimeout((()=>{this._onFired.fire(),clearTimeout(this.timer)}))}dispose(){this._onFired.dispose()}}!function(e){e.NONE={dispose:()=>{}}}(n||(n={}));class w{constructor(...e){this.disposables=e}static from(...e){return new w(...e)}addDisposables(...e){e.forEach((e=>this.disposables.push(e)))}dispose(){this.disposables.forEach((e=>e.dispose()))}}class _{constructor(){this._disposable=n.NONE}set value(e){this._disposable&&this._disposable.dispose(),this._disposable=e}dispose(){this._disposable&&(this._disposable.dispose(),this._disposable=n.NONE)}}function f(e,t){const i=new ResizeObserver((e=>{const i=e[0];t(i)}));return i.observe(e),{dispose:()=>{i.unobserve(e),i.disconnect()}}}const C=(e,...t)=>{for(const i of t)e.classList.contains(i)&&e.classList.remove(i)},b=(e,...t)=>{for(const i of t)e.classList.contains(i)||e.classList.add(i)},D=(e,t,i)=>{const s=e.classList.contains(t);i&&!s&&e.classList.add(t),!i&&s&&e.classList.remove(t)};function y(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}function S(e){return Array.prototype.slice.call(document.getElementsByTagName(e),0)}function z(e){return new E(e)}class E extends w{constructor(e){super(),this._onDidFocus=new u,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new u,this.onDidBlur=this._onDidBlur.event;let t=y(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=()=>{y(document.activeElement,e)!==t&&(t?n():s())},e instanceof HTMLElement?(this.addDisposables(v(e,"focus",s,!0)),this.addDisposables(v(e,"blur",n,!0))):(this.addDisposables(c(e,"focus",s,!0)),this.addDisposables(c(e,"blur",n,!0)))}refreshState(){this._refreshStateHandler()}dispose(){super.dispose(),this._onDidBlur.dispose(),this._onDidFocus.dispose()}}const x=(e,t,i)=>{if(t>i)throw new Error(`${t} > ${i} is an invalid condition`);return Math.min(i,Math.max(e,t))},P=()=>{let e=1;return{next:()=>(e++).toString()}};function A(e){if(0===e.length)throw new Error("Invalid tail call");return[e.slice(0,e.length-1),e[e.length-1]]}function O(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 N(e,t){const i=e.indexOf(t);i>-1&&(e.splice(i,1),e.unshift(t))}function V(e,t){const i=e.indexOf(t);i>-1&&(e.splice(i,1),e.push(t))}const I=(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 L{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=x(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 T,G,R,k,H;e.Orientation=void 0,(T=e.Orientation||(e.Orientation={})).HORIZONTAL="HORIZONTAL",T.VERTICAL="VERTICAL",e.SashState=void 0,(G=e.SashState||(e.SashState={}))[G.MAXIMUM=0]="MAXIMUM",G[G.MINIMUM=1]="MINIMUM",G[G.DISABLED=2]="DISABLED",G[G.ENABLED=3]="ENABLED",e.LayoutPriority=void 0,(R=e.LayoutPriority||(e.LayoutPriority={})).Low="low",R.High="high",R.Normal="normal",e.Sizing=void 0,(k=e.Sizing||(e.Sizing={})).Distribute={type:"distribute"},k.Split=function(e){return{type:"split",index:e}},k.Invisible=function(e){return{type:"invisible",cachedVisibleSize:e}};class M{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 u,this.onDidSashEnd=this._onDidSashEnd.event,this._onDidAddView=new u,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new u,this.onDidRemoveView=this._onDidRemoveView.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=I(e,-1),l=I(e+1,this.views.length);if(n)for(const e of n)N(d,e),N(l,e);if(s)for(const e of s)V(d,e),V(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),_=0===l.length?Number.NEGATIVE_INFINITY:l.reduce(((e,t)=>e+i[t]-this.views[t].maximumSize),0),f=Math.max(v,_),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 D=0,y=x(t,f,C);for(let e=0;e<p.length;e++){const t=p[e],i=x(m[e]+y,t.minimumSize,t.maximumSize),s=i-m[e];D+=s,y-=s,t.size=i}let S=D;for(let e=0;e<u.length;e++){const t=u[e],i=x(c[e]-S,t.minimumSize,t.maximumSize);S+=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,C(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)?(C(this.element,"separator-border"),this.element.style.removeProperty("--dv-separator-border")):(b(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");D(this.container,"visible",t);const i=this.views[e];D(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=I(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=x(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=x(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 L(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=[...S("iframe"),...S("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=I(o,-1),l=I(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),_=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 _){const e=this.views[_],t=Math.floor(e.viewMinimumSize/2);h={index:_,limitDelta:e.visible?g+t:g-t,size:e.size}}const f=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",f),document.removeEventListener("mouseup",C),document.removeEventListener("mouseend",C),this._onDidSashEnd.fire(void 0)};document.addEventListener("mousemove",f),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=x(s,e.minimumSize,e.maximumSize);const n=I(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=x(Math.round(this.proportions[e]*t),i.minimumSize,i.maximumSize)}else{const i=I(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=I(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)N(n,e);for(const e of o)V(n,e);"number"==typeof t&&V(n,t);for(let e=0;0!==s&&e<n.length;e++){const t=this.views[n[e]],i=x(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=I(t,-1),r=I(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){D(t.container,"disabled",i===e.SashState.DISABLED),D(t.container,"enabled",i===e.SashState.ENABLED),D(t.container,"maximum",i===e.SashState.MAXIMUM),D(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();for(let e=0;e<this.element.children.length;e++)if(this.element.children.item(e)===this.element){this.element.removeChild(this.element);break}this.element.remove()}}class F extends w{constructor(t,i){var s;super(),this.paneItems=[],this.skipAnimation=!1,this._onDidChange=new u,this.onDidChange=this._onDidChange.event,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 M(this.element,{orientation:this._orientation,proportionalLayout:!1,descriptor:i.descriptor}),this.getPanes().forEach((e=>{const t=new w(e.onDidChangeExpansionState((()=>{this.setupAnimation(),this._onDidChange.fire(void 0)}))),i={pane:e,disposable:{dispose:()=>{t.dispose()}}};this.paneItems.push(i),e.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()})))}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,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),b(this.element,"animated"),this.animationTimer=setTimeout((()=>{this.animationTimer=void 0,C(this.element,"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 W extends w{constructor(e,t){super(),this.element=e,this.callbacks=t,this.counter=0,this.registerListeners()}registerListeners(){this.addDisposables(v(this.element,"dragenter",(e=>{this.counter++,this.callbacks.onDragEnter(e)}))),this.addDisposables(v(this.element,"dragover",(e=>{e.preventDefault(),this.callbacks.onDragOver&&this.callbacks.onDragOver(e)}))),this.addDisposables(v(this.element,"dragleave",(e=>{this.counter--,0===this.counter&&this.callbacks.onDragLeave(e)}))),this.addDisposables(v(this.element,"dragend",(e=>{this.counter=0,this.callbacks.onDragEnd(e)}))),this.addDisposables(v(this.element,"drop",(e=>{this.counter=0,this.callbacks.onDrop(e)})))}}e.Position=void 0,(H=e.Position||(e.Position={})).Top="Top",H.Left="Left",H.Bottom="Bottom",H.Right="Right",H.Center="Center";class J extends w{constructor(t,i){super(),this.element=t,this.options=i,this._onDrop=new u,this.onDrop=this._onDrop.event,this.addDisposables(this._onDrop,new W(this.element,{onDragEnter:()=>{},onDragOver:t=>{const i=this.element.clientWidth,s=this.element.clientHeight;if(0===i||0===s)return;const n=100*t.offsetX/i,o=100*t.offsetY/s,r=this.calculateQuadrant(this.options.validOverlays,n,o);if("boolean"==typeof this.options.canDisplayOverlay){if(!this.options.canDisplayOverlay)return}else if(!this.options.canDisplayOverlay(t,r))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 a=i<100,h=s<100;this.toggleClasses(r,a,h),this.setState(r)},onDragLeave:()=>{this.removeDropTarget()},onDragEnd:()=>{this.removeDropTarget()},onDrop:e=>{e.preventDefault(),e.stopPropagation();const t=this._state;this.removeDropTarget(),t&&this._onDrop.fire({position:t,nativeEvent:e})}}))}get state(){return this._state}set validOverlays(e){this.options.validOverlays=e}set canDisplayOverlay(e){this.options.canDisplayOverlay=e}dispose(){this.removeDropTarget()}toggleClasses(e,t,i){if(!this.overlay)return;const s="left"===e,n="right"===e,o="top"===e,r="bottom"===e;D(this.overlay,"right",!t&&n),D(this.overlay,"left",!t&&s),D(this.overlay,"top",!i&&o),D(this.overlay,"bottom",!i&&r),D(this.overlay,"small-right",t&&n),D(this.overlay,"small-left",t&&s),D(this.overlay,"small-top",i&&o),D(this.overlay,"small-bottom",i&&r)}setState(t){switch(t){case"top":this._state=e.Position.Top;break;case"left":this._state=e.Position.Left;break;case"bottom":this._state=e.Position.Bottom;break;case"right":this._state=e.Position.Right;break;default:this._state=e.Position.Center}}calculateQuadrant(e,t,i){switch(e){case"all":if(t<20)return"left";if(t>80)return"right";if(i<20)return"top";if(i>80)return"bottom";break;case"vertical":return i<50?"top":"bottom";case"horizontal":return t<50?"left":"right"}return null}removeDropTarget(){this.target&&(this._state=void 0,this.element.removeChild(this.target),this.target=void 0,this.element.classList.remove("drop-target"))}}class B{constructor(t,i,s,n=0){this.view=t,this.orientation=i,this._onDidChange=new u,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._onDidChange.dispose(),this._disposable.dispose()}}class j extends w{constructor(e,t,i,s,o,r){if(super(),this.orientation=e,this.proportionalLayout=t,this.styles=i,this.children=[],this._onDidChange=new u,this.onDidChange=this._onDidChange.event,this._childrenDisposable=n.NONE,this._orthogonalSize=o,this._size=s,this.element=document.createElement("div"),this.element.className="branch-node",r){const e={views:r.map((e=>({view:e.node,size:e.node.size,visible:!(e.node instanceof B&&void 0!==e.visible)||e.visible}))),size:this.size};this.children=r.map((e=>e.node)),this.splitview=new M(this.element,{orientation:this.orientation,descriptor:e,proportionalLayout:t})}else this.splitview=new M(this.element,{orientation:this.orientation,proportionalLayout:t,styles:i}),this.splitview.layout(this.size,this.orthogonalSize);this.addDisposables(this._onDidChange,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)))((()=>{this._onDidChange.fire(void 0)}))}dispose(){super.dispose(),this._childrenDisposable.dispose(),this.children.forEach((e=>e.dispose())),this.splitview.dispose()}}function $(e,t){if(e instanceof B)return e;if(e instanceof j)return $(e.children[t?e.children.length-1:0],t);throw new Error("invalid node")}function Z(e,t,i){if(e instanceof j){const s=new j(q(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 j?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(Z(r,i,h),h,0,!0)}return s}return new B(e.view,q(e.orientation),i)}function U(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 X(e){const t=e.parentElement;if(!t)throw new Error("Invalid grid element");if(/\bgrid-view\b/.test(t.className))return[];const i=U(t);return[...X(t.parentElement.parentElement.parentElement),i]}function K(t,i,s){if(Q(t,i)===Y(s)){const[t,n]=A(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 Y(t){return t===e.Position.Top||t===e.Position.Bottom?e.Orientation.VERTICAL:e.Orientation.HORIZONTAL}function Q(e,t){return t.length%2==0?q(e):e}const q=t=>t===e.Orientation.HORIZONTAL?e.Orientation.VERTICAL:e.Orientation.HORIZONTAL;function ee(e){return!!e.children}const te=(t,i)=>{const s=i===e.Orientation.VERTICAL?t.box.width:t.box.height;return ee(t)?{type:"branch",data:t.children.map((e=>te(e,q(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 ie{constructor(e,t,i){this.proportionalLayout=e,this.styles=t,this.disposable=new _,this._onDidChange=new u,this.onDidChange=this._onDidChange.event,this.element=document.createElement("div"),this.element.className="grid-view",this.root=new j(i,e,t,0,0)}serialize(){return{root:te(this.getView(),this.orientation),width:this.width,height:this.height,orientation:this.orientation}}dispose(){this.disposable.dispose(),this._onDidChange.dispose(),this.root.dispose(),this.element.remove()}clear(){const e=this.root.orientation;this.root=new j(e,this.proportionalLayout,this.styles,this.root.size,this.root.orthogonalSize)}deserialize(t,i){const s=t.orientation,n=s===e.Orientation.VERTICAL?t.height:t.width;this._deserialize(t.root,s,i,n)}_deserialize(e,t,i,s){this.root=this._deserializeNode(e,t,i,s,!0)}_deserializeNode(e,t,i,s,n=!1){let o;if("branch"===e.type){const r=e.data.map((s=>({node:this._deserializeNode(s,q(t),i,e.size),visible:s.visible})));o=new j(t,this.proportionalLayout,this.styles,n?s:e.size,n?e.size:s,r)}else o=new B(i.fromJSON(e),t,s,e.size);return o}get orientation(){return this.root.orientation}set orientation(e){if(this.root.orientation===e)return;const{size:t,orthogonalSize:i}=this.root;this.root=Z(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 B)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,q(t),o))}return{box:s,children:n}}progmaticSelect(e,t=!1){const[i,s]=this.getNode(e);if(!(s instanceof B))throw new Error("invalid location");for(let s=i.length-1;s>-1;s--){const n=i[s],o=e[s]||0;if(t?o-1>-1:o+1<n.children.length)return $(n.children[t?o-1:o+1],t)}return $(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]=A(e),[,s]=this.getNode(t);if(!(s instanceof j))throw new Error("Invalid from location");return s.isChildVisible(i)}setViewVisible(e,t){const[i,s]=A(e),[,n]=this.getNode(i);if(!(n instanceof j))throw new Error("Invalid from location");n.setChildVisible(s,t)}moveView(e,t,i){const[,s]=this.getNode(e);if(!(s instanceof j))throw new Error("Invalid location");s.moveChild(t,i)}addView(t,i,s){const[n,o]=A(s),[r,a]=this.getNode(n);if(a instanceof j){const e=new B(t,q(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 j(a.orientation,this.proportionalLayout,this.styles,a.size,a.orthogonalSize);s.addChild(u,a.size,d);const c=new B(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 B(t,s.orientation,a.size);u.addChild(v,i,o)}}remove(e,t){const i=X(e.element);return this.removeView(i,t)}removeView(t,i){const[s,n]=A(t),[o,r]=this.getNode(s);if(!(r instanceof j))throw new Error("Invalid location");const a=r.children[n];if(!(a instanceof B))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;const h=r.children[0];if(0===o.length)return h instanceof B||(r.removeChild(0,i),this.root=h),a.view;const[d,...l]=[...o].reverse(),[p,...m]=[...s].reverse(),u=r.isChildVisible(0);r.removeChild(0,i);const c=d.children.map(((e,t)=>d.getChildSize(t)));if(d.removeChild(p,i),h instanceof j){c.splice(p,1,...h.children.map((e=>e.size)));for(let e=0;e<h.children.length;e++){const t=h.children[e];d.addChild(t,t.size,p+e)}}else{const t=new B(h.view,q(h.orientation),h.size),i=u?h.orthogonalSize:e.Sizing.Invisible(h.orthogonalSize);d.addChild(t,i,p)}for(let e=0;e<c.length;e++)d.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 j))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)}}class se{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 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}updateOptions(e){this.component.updateOptions(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()}}class ne{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 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(){const e=new u,t=this.component.onDidDrop((t=>{e.fire(Object.assign(Object.assign({},t),{api:this}))}));return e.dispose=()=>{t.dispose(),e.dispose()},e.event}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()}}class oe{constructor(e){this.component=e}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 width(){return this.component.width}get height(){return this.component.height}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})}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()}}class re{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 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 onDidLayoutFromJSON(){return this.component.onDidLayoutfromJSON}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidDrop(){return this.component.onDidDrop}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)}layout(e,t,i=!1){this.component.layout(e,t,i)}addPanel(e){return this.component.addPanel(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)}getGroup(e){return this.component.getPanel(e)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}}class ae extends w{constructor(){super(),this.disposable=new _,this._onDidFocus=new u,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new u,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="content-container",this._element.tabIndex=-1,this.addDisposables(this._onDidFocus,this._onDidBlur)}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 w;if(this.panel.view){const e=this.panel.view.content.onDidFocus,t=this.panel.view.content.onDidBlur,{onDidFocus:s,onDidBlur:n}=z(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;!function(e){e[e.Tab=0]="Tab",e[e.Panel=1]="Panel",e[e.TabContainer=2]="TabContainer"}(he||(he={}));class pe extends w{constructor(e){super(),this.el=e,this.disposable=new _,this._onDragStart=new u,this.onDragStart=this._onDragStart.event,this.iframes=[],this.configure()}configure(){this.addDisposables(this._onDragStart,v(this.el,"dragstart",(e=>{this.iframes=[...S("iframe"),...S("webview")];for(const e of this.iframes)e.style.pointerEvents="none";this.el.classList.add("dragged"),setTimeout((()=>this.el.classList.remove("dragged")),0),this.disposable.value=this.getData(),e.dataTransfer&&(e.dataTransfer.effectAllowed="move")})),v(this.el,"dragend",(()=>{for(const e of this.iframes)e.style.pointerEvents="auto";this.iframes=[],this.disposable.dispose()})))}}e.MouseEventKind=void 0,(de=e.MouseEventKind||(e.MouseEventKind={})).CLICK="CLICK",de.CONTEXT_MENU="CONTEXT_MENU";class me extends w{constructor(t,i,s){super(),this.panelId=t,this.group=s,this._onChanged=new u,this.onChanged=this._onChanged.event,this._onDropped=new u,this.onDrop=this._onDropped.event,this.addDisposables(this._onChanged,this._onDropped),this._element=document.createElement("div"),this._element.className="tab",this._element.tabIndex=0,this._element.draggable=!0,D(this.element,"inactive-tab",!0),this.addDisposables(new class extends pe{constructor(){super(...arguments),this.panelTransfer=l.getInstance()}getData(){return this.panelTransfer.setData([new h(i.id,s.id,t)],h.prototype),{dispose:()=>{this.panelTransfer.clearData(h.prototype)}}}dispose(){}}(this._element)),this.addDisposables(v(this._element,"mousedown",(t=>{t.defaultPrevented||(t.stopPropagation(),this._onChanged.fire({kind:e.MouseEventKind.CLICK,event:t}))})),v(this._element,"contextmenu",(t=>{this._onChanged.fire({kind:e.MouseEventKind.CONTEXT_MENU,event:t})}))),this.droptarget=new J(this._element,{validOverlays:"none",canDisplayOverlay:e=>{const t=p();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){D(this.element,"active-tab",e),D(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 w{constructor(e,t,i){super(),this.accessor=e,this.group=t,this.tabs=[],this.selectedIndex=-1,this._hidden=!1,this._onDrop=new u,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 J(this.voidContainer,{validOverlays:"none",canDisplayOverlay:e=>{var i;const s=p();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.nativeEvent,index:this.tabs.length})})),this.voidDropTarget,v(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`)}get hidden(){return this._hidden}set hidden(e){this._hidden=e,this.element.style.display=e?"none":""}show(){this.hidden||(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){}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=w.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}));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.nativeEvent,index:this.tabs.findIndex((e=>e.value===n))})}))),r={value:n,disposable:o};this.addTab(r,i)}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";class ce extends w{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._locked=!1,this.mostRecentlyUsed=[],this._onDidChange=new u,this.onDidChange=this._onDidChange.event,this._width=0,this._height=0,this._panels=[],this._onMove=new u,this.onMove=this._onMove.event,this._onDidGroupChange=new u,this.onDidGroupChange=this._onDidGroupChange.event,this._onDidDrop=new u,this.onDidDrop=this._onDidDrop.event,this.container.classList.add("groupview"),this.addDisposables(this._onMove,this._onDidGroupChange,this._onDidChange,this._onDidDrop),this.tabsContainer=new ue(this.accessor,this.parent,{tabHeight:n.tabHeight}),this.contentContainer=new ae,this.dropTarget=new J(this.contentContainer.element,{validOverlays:"all",canDisplayOverlay:(e,t)=>{if(this.locked&&!t)return!1;const i=p();if(i){return!(1===this._panels.length&&i.groupId===this.id)}return this.canDisplayOverlay(e,he.Panel)}}),t.append(this.tabsContainer.element,this.contentContainer.element),this.header.hidden=!!n.hideHeader,this.locked=!!n.locked,this.addDisposables(this._onMove,this._onDidGroupChange,this.tabsContainer.onDrop((t=>{this.handleDropEvent(t.event,e.Position.Center,t.index)})),this.contentContainer.onDidFocus((()=>{this.accessor.doSetGroupActive(this.parent,!0)})),this.contentContainer.onDidBlur((()=>{})),this.dropTarget.onDrop((e=>{this.handleDropEvent(e.nativeEvent,e.position)})))}get element(){throw new Error("not supported")}get activePanel(){return this._activePanel}get locked(){return this._locked}set locked(e){this._locked=e}get isActive(){return this._isGroupActive}get panels(){return this._panels}get size(){return this._panels.length}get isEmpty(){return 0===this._panels.length}get minimumHeight(){return 100}get maximumHeight(){return Number.MAX_SAFE_INTEGER}get minimumWidth(){return 100}get maximumWidth(){return Number.MAX_SAFE_INTEGER}get hasWatermark(){return!(!this.watermark||!this.container.contains(this.watermark.element))}get header(){return this.tabsContainer}get isContentFocused(){return!!document.activeElement&&y(document.activeElement,this.contentContainer.element)}initialize(){var e,t;(null===(e=this.options)||void 0===e?void 0:e.panels)&&this.options.panels.forEach((e=>{this.doAddPanel(e)})),(null===(t=this.options)||void 0===t?void 0:t.activePanel)&&this.openPanel(this.options.activePanel),this.setActive(this.isActive,!0,!0),this.updateContainer()}indexOf(e){return this.tabsContainer.indexOf(e.id)}toJSON(){var e;const t={views:this.tabsContainer.panels,activeView:null===(e=this._activePanel)||void 0===e?void 0:e.id,id:this.id};return this.locked&&(t.locked=!0),this.header.hidden&&(t.hideHeader=!0),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)return;i=0}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)return;i=this.panels.length-1}this.openPanel(this.panels[i])}containsPanel(e){return this.panels.includes(e)}init(e){}update(e){}focus(){var e;null===(e=this._activePanel)||void 0===e||e.focus()}openPanel(e,t={}){("number"!=typeof t.index||t.index>this.panels.length)&&(t.index=this.panels.length);const i=!!t.skipSetActive;e.updateParentGroup(this.parent,!0),i||this._activePanel!==e?(this.doAddPanel(e,t.index,i),i||(this.doSetActivePanel(e),this.accessor.doSetGroupActive(this.parent,!!t.skipFocus)),this.updateContainer()):this.accessor.doSetGroupActive(this.parent)}removePanel(e){const t="string"==typeof e?e:e.id,i=this._panels.find((e=>e.id===t));if(!i)throw new Error("invalid operation");return this._removePanel(i)}closeAllPanels(){if(this.panels.length>0){const e=[...this.panels];for(const t of e)this.doClose(t)}else this.accessor.removeGroup(this.parent)}closePanel(e){this.doClose(e)}doClose(e){this.accessor.removePanel(e)}isPanelActive(e){return this._activePanel===e}updateActions(){var e,t;this.isActive&&(null===(t=null===(e=this._activePanel)||void 0===e?void 0:e.view)||void 0===t?void 0:t.actions)?this.tabsContainer.setActionElement(this._activePanel.view.actions.element):this.tabsContainer.setActionElement(void 0)}setActive(e,t=!1,i=!1){var s,n;i||this.isActive!==e?(this._isGroupActive=e,D(this.container,"active-group",e),D(this.container,"inactive-group",!e),this.tabsContainer.setActive(this.isActive),!this._activePanel&&this.panels.length>0&&this.doSetActivePanel(this.panels[0]),this.updateContainer(),e&&(t||null===(n=this._activePanel)||void 0===n||n.focus())):t||null===(s=this._activePanel)||void 0===s||s.focus()}layout(e,t){var i;this._width=e,this._height=t,this.contentContainer.layout(this._width,this._height),(null===(i=this._activePanel)||void 0===i?void 0:i.layout)&&this._activePanel.layout(this._width,this._height)}_removePanel(e){const t=this._activePanel===e;if(this.doRemovePanel(e),t&&this.panels.length>0){const e=this.mostRecentlyUsed[0];this.openPanel(e)}return this._activePanel&&0===this.panels.length&&this.doSetActivePanel(void 0),this.updateContainer(),e}doRemovePanel(t){const i=this.panels.indexOf(t);this._activePanel===t&&this.contentContainer.closePanel(),this.tabsContainer.delete(t.id),this._panels.splice(i,1),this.mostRecentlyUsed.includes(t)&&this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(t),1),this._onDidGroupChange.fire({kind:e.GroupChangeKind2.REMOVE_PANEL,panel:t})}doAddPanel(t,i=this.panels.length,s=!1){const n=this._panels.indexOf(t)>-1;this.tabsContainer.openPanel(t,i),s||this.contentContainer.openPanel(t),this.tabsContainer.show(),this.contentContainer.show(),n||(this.updateMru(t),this.panels.splice(i,0,t),this._onDidGroupChange.fire({kind:e.GroupChangeKind2.ADD_PANEL,panel:t}))}doSetActivePanel(t){this._activePanel=t,t&&(this.tabsContainer.setActivePanel(t),t.layout(this._width,this._height),this.updateMru(t),this._onDidGroupChange.fire({kind:e.GroupChangeKind2.PANEL_ACTIVE,panel:t}))}updateMru(e){this.mostRecentlyUsed.includes(e)&&this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(e),1),this.mostRecentlyUsed=[e,...this.mostRecentlyUsed]}updateContainer(){if(this.updateActions(),D(this.container,"empty",this.isEmpty),this.panels.forEach((e=>e.updateParentGroup(this.parent,this.isActive))),this.isEmpty&&!this.watermark){const e=this.accessor.createWatermarkComponent();e.init({containerApi:new re(this.accessor),params:{},title:"",api:null}),this.watermark=e,v(this.watermark.element,"click",(()=>{this.isActive||this.accessor.doSetGroupActive(this.parent)})),this.contentContainer.hide(),this.tabsContainer.hide(),this.container.appendChild(this.watermark.element),this.watermark.updateParentGroup(this.parent,!0)}!this.isEmpty&&this.watermark&&(this.watermark.element.remove(),this.watermark.dispose(),this.watermark=void 0,this.contentContainer.show(),this.tabsContainer.show())}canDisplayOverlay(e,t){return!!this.accessor.options.showDndOverlay&&this.accessor.options.showDndOverlay(e,t)}handleDropEvent(e,t,i){const s=p();if(s){if(-1!==this.tabsContainer.indexOf(s.panelId)&&1===this.tabsContainer.size)return;const{groupId:e,panelId:n}=s;if(this.id===e&&!t){if(this.tabsContainer.indexOf(n)===i)return}this._onMove.fire({target:t,groupId:s.groupId,itemId:s.panelId,index:i})}else this._onDidDrop.fire({nativeEvent:e,position:t,index:i,getData:()=>p()})}dispose(){var e;super.dispose(),null===(e=this.watermark)||void 0===e||e.dispose();for(const e of this.panels)e.dispose();this.dropTarget.dispose(),this.tabsContainer.dispose(),this.contentContainer.dispose()}}const ve=P();function ge(t){switch(t){case"left":return e.Position.Left;case"right":return e.Position.Right;case"above":return e.Position.Top;case"below":return e.Position.Bottom;default:return e.Position.Center}}class we extends w{constructor(t,i){super(),this._element=t,this._id=ve.next(),this._groups=new Map,this._onDidLayoutChange=new u,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidRemoveGroup=new u,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new u,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidActiveGroupChange=new u,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._bufferOnDidLayoutChange=new g,this.gridview=new ie(!!i.proportionalLayout,i.styles,i.orientation),this.element.appendChild(this.gridview.element),this.layout(0,0,!0),this.addDisposables(this.gridview.onDidChange((()=>{this._onDidLayoutChange.fire()}))),this.addDisposables(e.Event.any(this.onDidAddGroup,this.onDidRemoveGroup,this.onDidActiveGroupChange)((()=>{this._bufferOnDidLayoutChange.fire()})),this._bufferOnDidLayoutChange.onEvent((()=>{this._onDidLayoutChange.fire()})),this._bufferOnDidLayoutChange)}get id(){return this._id}get element(){return this._element}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}setVisible(e,t){this.gridview.setViewVisible(X(e.element),t),this._onDidLayoutChange.fire()}isVisible(e){return this.gridview.isViewVisible(X(e.element))}doAddGroup(t,i=[0],s){this.gridview.addView(t,null!=s?s:e.Sizing.Distribute,i),this._onDidAddGroup.fire(t),this.doSetGroupActive(t)}doRemoveGroup(t,i){if(!this._groups.has(t.id))throw new Error("invalid operation");const s=this._groups.get(t.id),n=this.gridview.remove(t,e.Sizing.Distribute);if(s&&!(null==i?void 0:i.skipDispose)&&(s.disposable.dispose(),s.value.dispose(),this._groups.delete(t.id)),this._onDidRemoveGroup.fire(t),!(null==i?void 0:i.skipActive)&&this._activeGroup===t){const e=Array.from(this._groups.values());this.doSetGroupActive(e.length>0?e[0].value:void 0)}return n}getPanel(e){var t;return null===(t=this._groups.get(e))||void 0===t?void 0:t.value}doSetGroupActive(e,t){this._activeGroup!==e&&(this._activeGroup&&(this._activeGroup.setActive(!1),t||this._activeGroup.focus()),e&&(e.setActive(!0),t||e.focus()),this._activeGroup=e,this._onDidActiveGroupChange.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=X(e.group.element),s=null===(t=this.gridview.next(i))||void 0===t?void 0:t.view;this.doSetGroupActive(s)}moveToPrevious(e){var t;if(e||(e={}),!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}const i=X(e.group.element),s=null===(t=this.gridview.previous(i))||void 0===t?void 0:t.view;this.doSetGroupActive(s)}layout(e,t,i){(i||e!==this.width||t!==this.height)&&(this.element.style.height=`${t}px`,this.element.style.width=`${e}px`,this.gridview.layout(e,t))}dispose(){super.dispose(),this._onDidActiveGroupChange.dispose(),this._onDidAddGroup.dispose(),this._onDidRemoveGroup.dispose(),this._onDidLayoutChange.dispose();for(const e of this.groups)e.dispose();this.gridview.dispose()}}class _e extends w{constructor(e){super(),this.id=e,this._isFocused=!1,this._isActive=!1,this._isVisible=!0,this._width=0,this._height=0,this._onDidDimensionChange=new u({replay:!0}),this.onDidDimensionsChange=this._onDidDimensionChange.event,this._onDidChangeFocus=new u({replay:!0}),this.onDidFocusChange=this._onDidChangeFocus.event,this._onFocusEvent=new u,this.onFocusEvent=this._onFocusEvent.event,this._onDidVisibilityChange=new u({replay:!0}),this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._onVisibilityChange=new u,this.onVisibilityChange=this._onVisibilityChange.event,this._onDidActiveChange=new u({replay:!0}),this.onDidActiveChange=this._onDidActiveChange.event,this._onActiveChange=new u,this.onActiveChange=this._onActiveChange.event,this.addDisposables(this._onDidDimensionChange,this._onDidChangeFocus,this._onDidVisibilityChange,this._onDidActiveChange,this._onFocusEvent,this._onActiveChange,this._onVisibilityChange,this.onDidFocusChange((e=>{this._isFocused=e.isFocused})),this.onDidActiveChange((e=>{this._isActive=e.isActive})),this.onDidVisibilityChange((e=>{this._isVisible=e.isVisible})),this.onDidDimensionsChange((e=>{this._width=e.width,this._height=e.height})))}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}setVisible(e){this._onVisibilityChange.fire({isVisible:e})}setActive(){this._onActiveChange.fire()}dispose(){super.dispose()}}class fe extends _e{constructor(e){super(e),this._onDidConstraintsChangeInternal=new u,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new u({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new u,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 Ce extends fe{constructor(e,t){super(e.id),this.panel=e,this._onDidTitleChange=new u,this.onDidTitleChange=this._onDidTitleChange.event,this._titleChanged=new u,this.titleChanged=this._titleChanged.event,this._suppressClosableChanged=new u,this.suppressClosableChanged=this._suppressClosableChanged.event,this._onDidActiveGroupChange=new u,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._onDidGroupChange=new u,this.onDidGroupChange=this._onDidGroupChange.event,this.disposable=new _,this._group=t,this.addDisposables(this.disposable,this._onDidTitleChange,this._titleChanged,this._suppressClosableChanged,this._onDidGroupChange,this._onDidActiveGroupChange)}get title(){return this.panel.title}get suppressClosable(){return!!this.panel.suppressClosable}get isGroupActive(){var e;return!!(null===(e=this.group)||void 0===e?void 0:e.isActive)}set group(e){const t=this.isGroupActive;this._group=e,this._onDidGroupChange.fire(),this._group&&(this.disposable.value=this._group.api.onDidActiveChange((()=>{this._onDidActiveGroupChange.fire()})),this.isGroupActive!==t&&this._onDidActiveGroupChange.fire())}get group(){return this._group}setTitle(e){this._onDidTitleChange.fire({title:e})}close(){if(!this.group)throw new Error(`panel ${this.id} has no group`);return this.group.model.closePanel(this.panel)}}class be extends w{constructor(e,t,i,s){super(),this.id=e,this.containerApi=i,this.mutableDisposable=new _,this._suppressClosable=!1,this._title="",this._group=s,this.api=new Ce(this,this._group),this.addDisposables(this.api.onActiveChange((()=>{t.setActivePanel(this)})),this.api.onDidTitleChange((e=>{const t=e.title;this.update({params:{title:t}})})))}get params(){var e;return null===(e=this._params)||void 0===e?void 0:e.params}get title(){return this._title}get suppressClosable(){return this._suppressClosable}get group(){return this._group}get view(){return this._view}init(e){var t;this._params=e.params,this._view=e.view,this.setTitle(e.title),this.setSuppressClosable(e.suppressClosable||!1),null===(t=this.view)||void 0===t||t.init(Object.assign(Object.assign({},e),{api:this.api,containerApi:this.containerApi}))}focus(){this.api._onFocusEvent.fire()}toJSON(){return{id:this.id,view:this.view.toJSON(),params:Object.keys(this._params||{}).length>0?this._params:void 0,suppressClosable:this.suppressClosable||void 0,title:this.title}}setTitle(e){var t;e!==(null===(t=this._params)||void 0===t?void 0:t.title)&&(this._title=e,this.api._titleChanged.fire({title:this.title}))}setSuppressClosable(e){var t;e!==(null===(t=this._params)||void 0===t?void 0:t.suppressClosable)&&(this._suppressClosable=e,this.api._suppressClosableChanged.fire({suppressClosable:!!this.suppressClosable}))}update(e){var t;const i=e.params;this._params=Object.assign(Object.assign({},this._params||{}),e.params.params),"string"==typeof i.title&&this.setTitle(i.title),"boolean"==typeof i.suppressClosable&&this.setSuppressClosable(i.suppressClosable),null===(t=this.view)||void 0===t||t.update({params:{params:this._params,title:this.title,suppressClosable:this.suppressClosable}})}updateParentGroup(e,t){var i;this._group=e,this.api.group=e;const s=this._group.model.isPanelActive(this);this.api._onDidActiveChange.fire({isActive:t&&s}),this.api._onDidVisibilityChange.fire({isVisible:s}),null===(i=this.view)||void 0===i||i.updateParentGroup(this._group,this._group.model.isPanelActive(this))}layout(e,t){var i;this.api._onDidDimensionChange.fire({width:e,height:t-(this.group.model.header.height||0)}),null===(i=this.view)||void 0===i||i.layout(e,t)}dispose(){var e;this.api.dispose(),this.mutableDisposable.dispose(),null===(e=this.view)||void 0===e||e.dispose()}}class De{constructor(){this._element=document.createElement("div"),this._element.className="actions-bar",this._list=document.createElement("ul"),this._list.className="actions-container",this._element.appendChild(this._list)}get element(){return this._element}add(e){document.createElement("li").className="action-item",this._list.appendChild(e)}}class ye extends w{constructor(){super(),this._element=document.createElement("div"),this._element.className="watermark";const e=document.createElement("div");e.className="watermark-title";const t=document.createElement("span");t.style.flexGrow="1";const i=document.createElement("div");i.className="watermark-content",this._element.appendChild(e),this._element.appendChild(i);const s=new De;e.appendChild(t),e.appendChild(s.element);const n=document.createElement("a");n.className="close-action",s.add(n),this.addDisposables(v(n,"click",(e=>{var t;e.preventDefault(),this.group&&(null===(t=this.params)||void 0===t||t.containerApi.removeGroup(this.group))})))}get id(){return"watermark"}update(e){}focus(){}toJSON(){return{}}layout(e,t){}init(e){this.params=e,this.addDisposables(this.params.containerApi.onDidLayoutChange((()=>{this.render()}))),this.render()}updateParentGroup(e,t){this.group=e,this.render()}get element(){return this._element}render(){const e=!!(this.params&&this.params.containerApi.size<=1);D(this.element,"has-actions",e)}dispose(){super.dispose()}}class Se{constructor(e,t){this.layout=e,this.panelDeserializer=t}fromJSON(e){const t=e.data,i=t.views,s=t.activeView,n=this.layout.createGroup({id:t.id,locked:!!t.locked,hideHeader:!!t.hideHeader});for(const e of i){const t=this.panelDeserializer.createPanel(e,n),i="string"==typeof s&&s===t.id;n.model.openPanel(t,{skipSetActive:!i})}return!n.activePanel&&n.panels.length>0&&n.model.openPanel(n.panels[n.panels.length-1]),n}}function ze(e,t,i={},s={},n,o){const r="string"==typeof t?i[t]:void 0,a="string"==typeof t?s[t]:void 0;if(r&&a)throw new Error(`Cannot create '${e}'. component '${t}' registered as both a component and frameworkComponent`);if(a){if(!n)throw new Error(`Cannot create '${e}' for framework component '${t}'. you must register a frameworkPanelWrapper to use framework components`);return n.createComponent(e,t,a)}if(!r){if(o)return o();throw new Error(`Cannot create '${e}', no component '${t}' provided`)}return new r(e,t)}class Ee extends w{constructor(){super(),this._isPanelVisible=!1,this._isGroupActive=!1,this.params={},this._element=document.createElement("div"),this._element.className="default-tab",this._content=document.createElement("div"),this._content.className="tab-content",this._actionContainer=document.createElement("div"),this._actionContainer.className="action-container",this._list=document.createElement("ul"),this._list.className="tab-list",this.action=document.createElement("a"),this.action.className="tab-action",this._element.appendChild(this._content),this._element.appendChild(this._actionContainer),this._actionContainer.appendChild(this._list),this._list.appendChild(this.action),this.addDisposables(v(this._actionContainer,"mousedown",(e=>{e.preventDefault()}))),this.render()}get element(){return this._element}get id(){return"__DEFAULT_TAB__"}update(e){this.params=Object.assign(Object.assign({},this.params),e.params),this.render()}toJSON(){return{id:this.id}}focus(){}init(e){this.params=e,this._content.textContent=e.title,this.params.suppressClosable?this.action.classList.add("disable-close"):v(this.action,"click",(e=>{e.preventDefault(),this.params.api.close()}))}updateParentGroup(e,t){const i=this._isPanelVisible!==t||this._isGroupActive!==e.isActive;this._isPanelVisible=t,this._isGroupActive=e.isActive,i&&this.render()}layout(e,t){}render(){this._content.textContent!==this.params.title&&(this._content.textContent=this.params.title)}}class xe extends w{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{onDidFocus:s,onDidBlur:n}=z(this._element);this.addDisposables(this.api,s((()=>{this.api._onDidChangeFocus.fire({isFocused:!0})})),n((()=>{this.api._onDidChangeFocus.fire({isFocused:!1})})))}get element(){return this._element}get width(){return this._width}get height(){return this._height}get params(){var e;return null===(e=this._params)||void 0===e?void 0:e.params}focus(){this.api._onFocusEvent.fire()}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({},null===(t=this._params)||void 0===t?void 0:t.params),e.params)}),null===(i=this.part)||void 0===i||i.update({params:this._params.params})}toJSON(){var e,t;const i=null!==(t=null===(e=this._params)||void 0===e?void 0:e.params)&&void 0!==t?t:{};return{id:this.id,component:this.component,params:Object.keys(i).length>0?i:void 0}}dispose(){var e;super.dispose(),this.api.dispose(),null===(e=this.part)||void 0===e||e.dispose()}}class Pe extends xe{constructor(e,t,i=new fe(e)){super(e,t,i),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 u,this.onDidChange=this._onDidChange.event,this.addDisposables(this._onDidChange,this.api.onVisibilityChange((e=>{const{isVisible:t}=e,{accessor:i}=this._params;i.setVisible(this,t)})),this.api.onActiveChange((()=>{const{accessor:e}=this._params;e.setActive(this)})),this.api.onDidConstraintsChangeInternal((e=>{"number"!=typeof e.minimumWidth&&"function"!=typeof e.minimumWidth||(this._minimumWidth=e.minimumWidth),"number"!=typeof e.minimumHeight&&"function"!=typeof e.minimumHeight||(this._minimumHeight=e.minimumHeight),"number"!=typeof e.maximumWidth&&"function"!=typeof e.maximumWidth||(this._maximumWidth=e.maximumWidth),"number"!=typeof e.maximumHeight&&"function"!=typeof e.maximumHeight||(this._maximumHeight=e.maximumHeight)})),this.api.onDidSizeChange((e=>{this._onDidChange.fire({height:e.height,width:e.width})})))}get priority(){return this._priority}get snap(){return this._snap}get minimumWidth(){const e="function"==typeof this._minimumWidth?this._minimumWidth():this._minimumWidth;return e!==this._evaluatedMinimumWidth&&(this._evaluatedMinimumWidth=e,this.updateConstraints()),e}get minimumHeight(){const e="function"==typeof this._minimumHeight?this._minimumHeight():this._minimumHeight;return e!==this._evaluatedMinimumHeight&&(this._evaluatedMinimumHeight=e,this.updateConstraints()),e}get maximumHeight(){const e="function"==typeof this._maximumHeight?this._maximumHeight():this._maximumHeight;return e!==this._evaluatedMaximumHeight&&(this._evaluatedMaximumHeight=e,this.updateConstraints()),e}get maximumWidth(){const e="function"==typeof this._maximumWidth?this._maximumWidth():this._maximumWidth;return e!==this._evaluatedMaximumWidth&&(this._evaluatedMaximumWidth=e,this.updateConstraints()),e}get isActive(){return this.api.isActive}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),"boolean"==typeof e.isVisible&&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=e=>e===Number.MAX_SAFE_INTEGER?void 0:e,i=e=>e<=0?void 0:e;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})}}class Ae extends fe{}class Oe extends Pe{constructor(e,t,i){super(t,"groupview_default",new Ae(t)),this._model=new ce(this.element,e,t,i,this)}get panels(){return this._model.panels}get activePanel(){return this._model.activePanel}get size(){return this._model.size}get model(){return this._model}get minimumHeight(){return this._model.minimumHeight}get maximumHeight(){return this._model.maximumHeight}get minimumWidth(){return this._model.minimumWidth}get maximumWidth(){return this._model.maximumWidth}get locked(){return this._model.locked}set locked(e){this._model.locked=e}get header(){return this._model.header}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()}}class Ne{constructor(e){var t;this._content=e.content,this._tab=null!==(t=e.tab)&&void 0!==t?t:new Ee,this._actions=e.actions||(this.content.actions?{element:this.content.actions,dispose:()=>{}}:void 0)}get content(){return this._content}get tab(){return this._tab}get actions(){return this._actions}init(e){this.content.init(Object.assign(Object.assign({},e),{tab:this.tab})),this.tab.init(e)}updateParentGroup(e,t){var i;this._content.updateParentGroup(e,t),null===(i=this._tab)||void 0===i||i.updateParentGroup(e,t)}layout(e,t){this.content.layout(e,t)}update(e){this.content.update(e),this.tab.update(e)}toJSON(){return{content:this.content.toJSON(),tab:this.tab instanceof Ee?void 0:this.tab.toJSON()}}dispose(){var e;this.content.dispose(),this.tab.dispose(),null===(e=this.actions)||void 0===e||e.dispose()}}const Ve=P();class Ie extends we{constructor(t,i){super(t,{proportionalLayout:!0,orientation:i.orientation||e.Orientation.HORIZONTAL,styles:i.styles}),this._onTabInteractionEvent=new u,this.onTabInteractionEvent=this._onTabInteractionEvent.event,this._onTabContextMenu=new u,this.onTabContextMenu=this._onTabContextMenu.event,this._onDidDrop=new u,this.onDidDrop=this._onDidDrop.event,this._onDidRemovePanel=new u,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidAddPanel=new u,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidLayoutfromJSON=new u,this.onDidLayoutfromJSON=this._onDidLayoutfromJSON.event,this._onDidActivePanelChange=new u,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this.addDisposables(this._onTabInteractionEvent,this._onTabContextMenu,this._onDidDrop,e.Event.any(this.onDidAddPanel,this.onDidRemovePanel,this.onDidActivePanelChange)((()=>{this._bufferOnDidLayoutChange.fire()}))),this._options=i,this.options.components||(this.options.components={}),this.options.frameworkComponents||(this.options.frameworkComponents={}),this.options.frameworkTabComponents||(this.options.frameworkTabComponents={}),this.options.tabComponents||(this.options.tabComponents={}),this.options.watermarkComponent||this.options.watermarkFrameworkComponent||(this.options.watermarkComponent=ye),this._api=new re(this)}get totalPanels(){return this.panels.length}get panels(){return this.groups.flatMap((e=>e.panels))}get deserializer(){return this._deserializer}set deserializer(e){this._deserializer=e}get options(){return this._options}get activePanel(){const e=this.activeGroup;if(e)return e.activePanel}set tabHeight(e){this.options.tabHeight=e,this._groups.forEach((t=>{t.value.model.header.height=e}))}get tabHeight(){return this.options.tabHeight}updateOptions(e){const t="string"==typeof e.orientation&&this.options.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)}focus(){var e;null===(e=this.activeGroup)||void 0===e||e.focus()}getGroupPanel(e){return this.panels.find((t=>t.id===e))}setActivePanel(e){this.doSetGroupActive(e.group),e.group.model.openPanel(e)}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])return void e.group.model.moveToNext({suppressRoll:!0});const i=X(e.group.element),s=null===(t=this.gridview.next(i))||void 0===t?void 0:t.view;this.doSetGroupActive(s)}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])return void e.group.model.moveToPrevious({suppressRoll:!0});const i=X(e.group.element),s=null===(t=this.gridview.previous(i))||void 0===t?void 0:t.view;s&&this.doSetGroupActive(s)}toJSON(){var e;return{grid:this.gridview.serialize(),panels:this.panels.reduce(((e,t)=>(e[t.id]=t.toJSON(),e)),{}),activeGroup:null===(e=this.activeGroup)||void 0===e?void 0:e.id,options:{tabHeight:this.tabHeight}}}fromJSON(e){const t=Array.from(this._groups.values()).map((e=>e.value));for(const e of t)this.removeGroup(e,!0);if(this.gridview.clear(),!this.deserializer)throw new Error("invalid deserializer");const{grid:i,panels:s,options:n,activeGroup:o}=e;if("number"==typeof(null==n?void 0:n.tabHeight)&&(this.tabHeight=n.tabHeight),!this.deserializer)throw new Error("no deserializer provided");if(this.gridview.deserialize(i,new Se(this,{createPanel:(e,t)=>{const i=s[e];return this.deserializer.fromJSON(i,t)}})),"string"==typeof o){const e=this.getPanel(o);e&&this.doSetGroupActive(e)}this.gridview.layout(this.width,this.height),this._onDidLayoutfromJSON.fire()}closeAllGroups(){for(const e of this._groups.entries()){const[t,i]=e;i.value.model.closeAllPanels()}}fireMouseEvent(t){t.kind===e.MouseEventKind.CONTEXT_MENU&&t.tab&&t.panel&&this._onTabContextMenu.fire({event:t.event,api:this._api,panel:t.panel})}addPanel(t){var i,s;if(this.panels.find((e=>e.id===t.id)))throw new Error(`panel with id ${t.id} already exists`);let n,o;if(null===(i=t.position)||void 0===i?void 0:i.referencePanel){const e=this.getGroupPanel(t.position.referencePanel);if(!e)throw new Error(`referencePanel ${t.position.referencePanel} does not exist`);n=this.findGroup(e)}else n=this.activeGroup;if(n){const i=ge((null===(s=t.position)||void 0===s?void 0:s.direction)||"within");if(i===e.Position.Center)o=this.createPanel(t,n),n.model.openPanel(o);else{const e=X(n.element),s=K(this.gridview.orientation,e,i),r=this.createGroupAtLocation(s);o=this.createPanel(t,r),r.model.openPanel(o)}}else{const e=this.createGroupAtLocation();o=this.createPanel(t,e),e.model.openPanel(o)}return o}removePanel(e,t={removeEmptyGroup:!0,skipDispose:!1}){const i=e.group;if(!i)throw new Error(`cannot remove panel ${e.id}. it's missing a group.`);i.model.removePanel(e),e.dispose();!(1===this.size)&&0===i.size&&t.removeEmptyGroup&&this.removeGroup(i)}createWatermarkComponent(){var e;return ze("watermark-id","watermark-name",this.options.watermarkComponent?{"watermark-name":this.options.watermarkComponent}:{},this.options.watermarkFrameworkComponent?{"watermark-name":this.options.watermarkFrameworkComponent}:{},null===(e=this.options.frameworkComponentFactory)||void 0===e?void 0:e.watermark)}addEmptyGroup(e){const t=this.createGroup();if(e){const i=this.panels.find((t=>t.id===e.referencePanel));if(!i)throw new Error(`reference panel ${e.referencePanel} does not exist`);const s=this.findGroup(i);if(!s)throw new Error(`reference group for reference panel ${e.referencePanel} does not exist`);const n=ge(e.direction||"within"),o=X(s.element),r=K(this.gridview.orientation,o,n);this.doAddGroup(t,r)}else this.doAddGroup(t)}removeGroup(e,t=!1){const i=[...e.panels];for(const e of i)this.removePanel(e,{removeEmptyGroup:!1,skipDispose:!1});super.doRemoveGroup(e,{skipActive:t})}moveGroupOrPanel(t,i,s,n,o){var r;const a=i?null===(r=this._groups.get(i))||void 0===r?void 0:r.value:void 0;if(n&&n!==e.Position.Center){const e=X(t.element),i=K(this.gridview.orientation,e,n);if(a&&a.size<2){const[e,s]=A(i),o=X(a.element),[r,h]=A(o);if(O(r,e))this.gridview.moveView(r,h,s);else{const e=this.doRemoveGroup(a,{skipActive:!0,skipDispose:!0}),i=X(t.element),s=K(this.gridview.orientation,i,n);this.doAddGroup(e,s)}}else{const t=(null==a?void 0:a.model.removePanel(s))||this.panels.find((e=>e.id===s));if(!t)throw new Error(`No panel with id ${s}`);const i=K(this.gridview.orientation,e,n);this.createGroupAtLocation(i).model.openPanel(t)}}else{const e=(null==a?void 0:a.model.removePanel(s))||this.panels.find((e=>e.id===s));if(!e)throw new Error(`No panel with id ${s}`);0===(null==a?void 0:a.model.size)&&this.doRemoveGroup(a),t.model.openPanel(e,{index:o})}}doSetGroupActive(e,t){var i,s;const n=this._activeGroup===e;super.doSetGroupActive(e,t),!n&&(null===(i=this._activeGroup)||void 0===i?void 0:i.activePanel)&&this._onDidActivePanelChange.fire(null===(s=this._activeGroup)||void 0===s?void 0:s.activePanel)}createGroup(t){t||(t={tabHeight:this.tabHeight}),"number"!=typeof t.tabHeight&&(t.tabHeight=this.tabHeight);let i=null==t?void 0:t.id;if(i&&this._groups.has(t.id)&&(console.warn(`Duplicate group id ${null==t?void 0:t.id}. reassigning group id to avoid errors`),i=void 0),!i)for(i=Ve.next();this._groups.has(i);)i=Ve.next();const s=new Oe(this,i,t);if(s.init({params:{},accessor:null}),!this._groups.has(s.id)){const t=new w(s.model.onMove((e=>{const{groupId:t,itemId:i,target:n,index:o}=e;this.moveGroupOrPanel(s,t,i,n,o)})),s.model.onDidDrop((e=>{this._onDidDrop.fire(Object.assign(Object.assign({},e),{api:this._api}))})),s.model.onDidGroupChange((t=>{switch(t.kind){case e.GroupChangeKind2.ADD_PANEL:t.panel&&this._onDidAddPanel.fire(t.panel);break;case e.GroupChangeKind2.REMOVE_PANEL:t.panel&&this._onDidRemovePanel.fire(t.panel);break;case e.GroupChangeKind2.PANEL_ACTIVE:this._onDidActivePanelChange.fire(t.panel)}})));this._groups.set(s.id,{value:s,disposable:t})}return s.initialize(),"number"==typeof this.options.tabHeight&&(s.model.header.height=this.options.tabHeight),s}createPanel(e,t){const i=new Ne({content:this.createContentComponent(e.id,e.component),tab:this.createTabComponent(e.id,e.tabComponent)}),s=new be(e.id,this,this._api,t);return s.init({view:i,title:e.title||e.id,suppressClosable:null==e?void 0:e.suppressClosable,params:(null==e?void 0:e.params)||{}}),s}createContentComponent(e,t){var i;return ze(e,t,this.options.components||{},this.options.frameworkComponents,null===(i=this.options.frameworkComponentFactory)||void 0===i?void 0:i.content)}createTabComponent(e,t){var i;return ze(e,t,this.options.tabComponents||{},this.options.frameworkTabComponents,null===(i=this.options.frameworkComponentFactory)||void 0===i?void 0:i.tab,(()=>new Ee))}createGroupAtLocation(e=[0]){const t=this.createGroup();return this.doAddGroup(t,e),t}findGroup(e){var t;return null===(t=Array.from(this._groups.values()).find((t=>t.value.model.containsPanel(e))))||void 0===t?void 0:t.value}dispose(){super.dispose(),this._onDidActivePanelChange.dispose(),this._onDidAddPanel.dispose(),this._onDidRemovePanel.dispose(),this._onDidLayoutfromJSON.dispose()}}class Le extends we{constructor(e,t){super(e,{proportionalLayout:t.proportionalLayout,orientation:t.orientation,styles:t.styles}),this._onDidLayoutfromJSON=new u,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._options=t,this.options.components||(this.options.components={}),this.options.frameworkComponents||(this.options.frameworkComponents={})}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}updateOptions(e){const t="string"==typeof e.orientation&&this.options.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:null===(e=this.activeGroup)||void 0===e?void 0:e.id}}setVisible(e,t){this.gridview.setViewVisible(X(e.element),t)}setActive(e){this._groups.forEach(((t,i)=>{t.value.setActive(e===t.value)}))}focus(){var e;null===(e=this.activeGroup)||void 0===e||e.focus()}fromJSON(e){const{grid:t,activePanel:i}=e,s=Array.from(this._groups.values());for(const e of s)e.disposable.dispose(),this.doRemoveGroup(e.value,{skipActive:!0});this.gridview.clear();const n=[];if(this.gridview.deserialize(t,{fromJSON:e=>{const{data:t}=e,i=ze(t.id,t.component,this.options.components||{},this.options.frameworkComponents||{},this.options.frameworkComponentFactory?{createComponent:this.options.frameworkComponentFactory.createComponent}:void 0);return n.push((()=>i.init({params:t.params,minimumWidth:t.minimumWidth,maximumWidth:t.maximumWidth,minimumHeight:t.minimumHeight,maximumHeight:t.maximumHeight,priority:t.priority,snap:!!t.snap,accessor:this,isVisible:e.visible}))),this.registerPanel(i),i}}),this.layout(this.width,this.height,!0),n.forEach((e=>e())),"string"==typeof i){const e=this.getPanel(i);e&&this.doSetGroupActive(e)}this._onDidLayoutfromJSON.fire()}movePanel(t,i){var s;let n;const o=this.gridview.remove(t),r=null===(s=this._groups.get(i.reference))||void 0===s?void 0:s.value;if(!r)throw new Error(`reference group ${i.reference} does not exist`);const a=ge(i.direction);if(a===e.Position.Center)throw new Error(`${a} not supported as an option`);{const e=X(r.element);n=K(this.gridview.orientation,e,a)}this.doAddGroup(o,n,i.size)}addPanel(t){var i,s;let n=t.location||[0];if(null===(i=t.position)||void 0===i?void 0:i.referencePanel){const i=null===(s=this._groups.get(t.position.referencePanel))||void 0===s?void 0:s.value;if(!i)throw new Error(`reference group ${t.position.referencePanel} does not exist`);const o=ge(t.position.direction);if(o===e.Position.Center)throw new Error(`${o} not supported as an option`);{const e=X(i.element);n=K(this.gridview.orientation,e,o)}}const o=ze(t.id,t.component,this.options.components||{},this.options.frameworkComponents||{},this.options.frameworkComponentFactory?{createComponent:this.options.frameworkComponentFactory.createComponent}:void 0);return o.init({params:t.params||{},minimumWidth:t.minimumWidth,maximumWidth:t.maximumWidth,minimumHeight:t.minimumHeight,maximumHeight:t.maximumHeight,priority:t.priority,snap:!!t.snap,accessor:this,isVisible:!0}),this.registerPanel(o),this.doAddGroup(o,n,t.size),o}registerPanel(e){const t=new w(e.api.onDidFocusChange((t=>{t.isFocused&&this._groups.forEach((t=>{const i=t.value;i!==e?i.setActive(!1):i.setActive(!0)}))})));this._groups.set(e.id,{value:e,disposable:t})}moveGroup(e,t,i){const s=this.getPanel(t);if(!s)throw new Error("invalid operation");const n=X(e.element),o=K(this.gridview.orientation,n,i),[r,a]=A(o),h=X(s.element),[d,l]=A(h);if(O(d,r))return void this.gridview.moveView(d,l,a);const p=this.doRemoveGroup(s,{skipActive:!0,skipDispose:!0}),m=X(e.element),u=K(this.gridview.orientation,m,i);this.doAddGroup(p,u)}removeGroup(e){super.removeGroup(e)}dispose(){super.dispose(),this._onDidLayoutfromJSON.dispose()}}class Te extends w{constructor(e,t){super(),this.element=e,this._disposable=new _,this._panels=new Map,this._onDidLayoutfromJSON=new u,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidAddView=new u,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new u,this.onDidRemoveView=this._onDidRemoveView.event,this._onDidLayoutChange=new u,this.onDidLayoutChange=this._onDidLayoutChange.event,this._options=t,t.components||(t.components={}),t.frameworkComponents||(t.frameworkComponents={}),this.splitview=new M(this.element,t),this.addDisposables(this._disposable,this._onDidAddView,this._onDidLayoutfromJSON,this._onDidRemoveView,this._onDidLayoutChange)}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=e,this._disposable.value=new w(this._splitview.onDidSashEnd((()=>{this._onDidLayoutChange.fire(void 0)})),this._splitview.onDidAddView((e=>this._onDidAddView.fire(e))),this._splitview.onDidRemoveView((e=>this._onDidRemoveView.fire(e))))}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get height(){return this.splitview.orientation===e.Orientation.HORIZONTAL?this.splitview.orthogonalSize:this.splitview.size}get width(){return this.splitview.orientation===e.Orientation.HORIZONTAL?this.splitview.size:this.splitview.orthogonalSize}updateOptions(e){const t="string"==typeof e.orientation&&this.options.orientation!==e.orientation;this._options=Object.assign(Object.assign({},this.options),e),t&&(this.splitview.orientation=e.orientation),this.splitview.layout(this.splitview.size,this.splitview.orthogonalSize)}focus(){var e;null===(e=this._activePanel)||void 0===e||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((t=>t!==e)).forEach((e=>{e.api._onDidActiveChange.fire({isActive:!1}),t||e.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.disposable.dispose(),i.value.dispose(),this._panels.delete(e.id);const s=this.panels.findIndex((t=>t===e));this.splitview.removeView(s,t);const n=this.panels;n.length>0&&this.setActive(n[n.length-1])}getPanel(e){return this.panels.find((t=>t.id===e))}addPanel(t){if(this._panels.has(t.id))throw new Error(`panel ${t.id} already exists`);const i=ze(t.id,t.component,this.options.components||{},this.options.frameworkComponents||{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.createComponent}:void 0);i.orientation=this.splitview.orientation,i.init({params:t.params||{},minimumSize:t.minimumSize,maximumSize:t.maximumSize,snap:t.snap,priority:t.priority,accessor:this});const s="number"==typeof t.size?t.size:e.Sizing.Distribute,n="number"==typeof t.index?t.index:void 0;return this.splitview.addView(i,s,n),this.doAddView(i),this.setActive(i),i}layout(t,i){const[s,n]=this.splitview.orientation===e.Orientation.HORIZONTAL?[t,i]:[i,t];this.splitview.layout(s,n)}doAddView(e){const t=e.api.onDidFocusChange((t=>{t.isFocused&&this.setActive(e,!0)}));this._panels.set(e.id,{disposable:t,value:e})}toJSON(){var e;return{views:this.splitview.getViews().map(((e,t)=>({size:this.splitview.getViewSize(t),data:e.toJSON(),snap:!!e.snap,priority:e.priority}))),activeView:null===(e=this._activePanel)||void 0===e?void 0:e.id,size:this.splitview.size,orientation:this.splitview.orientation}}fromJSON(e){const{views:t,orientation:i,size:s,activeView:n}=e;for(const[e,t]of this._panels.entries())t.disposable.dispose(),t.value.dispose();this._panels.clear(),this.splitview.dispose();const o=[];if(this.splitview=new M(this.element,{orientation:i,proportionalLayout:this.options.proportionalLayout,descriptor:{size:s,views:t.map((e=>{const t=e.data;if(this._panels.has(t.id))throw new Error(`panel ${t.id} already exists`);const s=ze(t.id,t.component,this.options.components||{},this.options.frameworkComponents||{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.createComponent}:void 0);return o.push((()=>{s.init({params:t.params||{},minimumSize:t.minimumSize,maximumSize:t.maximumSize,snap:e.snap,priority:e.priority,accessor:this})})),s.orientation=i,this.doAddView(s),setTimeout((()=>{this._onDidAddView.fire(s)}),0),{size:e.size,view:s}}))}}),this.layout(this.width,this.height),o.forEach((e=>e())),"string"==typeof n){const e=this.getPanel(n);e&&this.setActive(e)}this._onDidLayoutfromJSON.fire()}dispose(){for(const[e,t]of this._panels.entries())t.disposable.dispose(),t.value.dispose();this._panels.clear(),this.splitview.dispose(),super.dispose()}}class Ge extends _e{constructor(e){super(e),this._onDidConstraintsChangeInternal=new u,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new u({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new u,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 Re extends Ge{constructor(e){super(e),this._onDidExpansionChange=new u({replay:!0}),this.onDidExpansionChange=this._onDidExpansionChange.event,this._onMouseEnter=new u({}),this.onMouseEnter=this._onMouseEnter.event,this._onMouseLeave=new u({}),this.onMouseLeave=this._onMouseLeave.event,this.addDisposables(this._onDidExpansionChange,this._onMouseEnter,this._onMouseLeave)}set pane(e){this._pane=e}setExpanded(e){var t;null===(t=this._pane)||void 0===t||t.setExpanded(e)}get isExpanded(){var e;return!!(null===(e=this._pane)||void 0===e?void 0:e.isExpanded())}}class ke extends xe{constructor(e,t,i,s,n,o){super(e,t,new Re(e)),this.headerComponent=i,this._onDidChangeExpansionState=new u({replay:!0}),this.onDidChangeExpansionState=this._onDidChangeExpansionState.event,this._onDidChange=new u,this.onDidChange=this._onDidChange.event,this.headerSize=22,this._orthogonalSize=0,this._size=0,this._minimumBodySize=100,this._maximumBodySize=Number.POSITIVE_INFINITY,this._isExpanded=!1,this.expandedSize=0,this.api.pane=this,this._isExpanded=n,this._headerVisible=o,this._onDidChangeExpansionState.fire(this.isExpanded()),this._orientation=s,this.element.classList.add("pane"),this.addDisposables(this.api.onDidSizeChange((e=>{this._onDidChange.fire(e.size)})),v(this.element,"mouseenter",(e=>{this.api._onMouseEnter.fire(e)})),v(this.element,"mouseleave",(e=>{this.api._onMouseLeave.fire(e)}))),this.addDisposables(this._onDidChangeExpansionState,this.onDidChangeExpansionState((e=>{this.api._onDidExpansionChange.fire({isExpanded:e})})),this.api.onDidFocusChange((e=>{this.header&&(e.isFocused?b(this.header,"focused"):C(this.header,"focused"))}))),this.renderOnce()}set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){return this.headerSize+(this.isExpanded()?this._minimumBodySize:0)}get maximumSize(){return this.headerSize+(this.isExpanded()?this._maximumBodySize:0)}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="number"==typeof e?e:0}get maximumBodySize(){return this._maximumBodySize}set maximumBodySize(e){this._maximumBodySize="number"==typeof e?e:Number.POSITIVE_INFINITY}get headerVisible(){return this._headerVisible}set headerVisible(e){this._headerVisible=e,this.header.style.display=e?"":"none"}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 e;null===(e=this.body)||void 0===e||e.remove()}),200),this._onDidChange.fire(e?this.width:void 0),this._onDidChangeExpansionState.fire(e))}layout(t,i){this._size=t,this._orthogonalSize=i;const[s,n]=this.orientation===e.Orientation.HORIZONTAL?[t,i]:[i,t];this.isExpanded()&&(this.expandedSize=s),super.layout(s,n)}init(e){var t,i;super.init(e),"number"==typeof e.minimumBodySize&&(this.minimumBodySize=e.minimumBodySize),"number"==typeof e.maximumBodySize&&(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})),null===(t=this.body)||void 0===t||t.append(this.bodyPart.element),null===(i=this.header)||void 0===i||i.append(this.headerPart.element),"boolean"==typeof e.isExpanded&&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="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="pane-body",this.element.appendChild(this.body)}getComponent(){return{update:e=>{var t,i;null===(t=this.bodyPart)||void 0===t||t.update({params:e}),null===(i=this.headerPart)||void 0===i||i.update({params:e})},dispose:()=>{var e,t;null===(e=this.bodyPart)||void 0===e||e.dispose(),null===(t=this.headerPart)||void 0===t||t.dispose()}}}}class He extends ke{constructor(e,t,i,s,n,o){super(e,t,i,s,n,!0),this._onDidDrop=new u,this.onDidDrop=this._onDidDrop.event,o||this.initDragFeatures()}initDragFeatures(){if(!this.header)return;const e=this.id;this.header.draggable=!0,this.handler=new class extends pe{getData(){return l.getInstance().setData([new d("paneview",e)],d.prototype),{dispose:()=>{l.getInstance().clearData(d.prototype)}}}}(this.header),this.target=new J(this.element,{validOverlays:"vertical",canDisplayOverlay:()=>{const e=m();return!e||e.paneId!==this.id}}),this.addDisposables(this._onDidDrop,this.handler,this.target,this.target.onDrop((e=>{this.onDrop(e)})))}onDrop(t){const i=m();if(!i)return void this._onDidDrop.fire(Object.assign(Object.assign({},t),{panel:this,getData:()=>m()}));const s=this._params.containerApi,n=i.paneId,o=s.getPanel(n);if(!o)return void this._onDidDrop.fire(Object.assign(Object.assign({},t),{panel:this,getData:()=>m()}));const r=s.panels,a=r.indexOf(o);let h=s.panels.indexOf(this);t.position!==e.Position.Left&&t.position!==e.Position.Top||(h=Math.max(0,h-1)),t.position!==e.Position.Right&&t.position!==e.Position.Bottom||(a>h&&h++,h=Math.min(r.length-1,h)),s.movePanel(a,h)}}class Me extends w{constructor(){super(),this.disposable=new _,this.apiRef={api:null},this._element=document.createElement("div"),this.element.className="default-header",this._content=document.createElement("span"),this._expander=document.createElement("a"),this.element.appendChild(this._content),this.element.appendChild(this._expander),this.addDisposables(v(this._expander,"click",(()=>{var e;null===(e=this.apiRef.api)||void 0===e||e.setExpanded(!this.apiRef.api.isExpanded)})))}get element(){return this._element}init(e){this.apiRef.api=e.api,this._content.textContent=e.title,this._expander.textContent=e.api.isExpanded?"<":">",this.disposable.value=e.api.onDidExpansionChange((e=>{this._expander.textContent=e.isExpanded?"<":">"}))}update(e){}dispose(){this.disposable.dispose(),super.dispose()}}class Fe extends He{constructor(e){super(e.id,e.component,e.headerComponent,e.orientation,e.isExpanded,e.disableDnd),this.options=e}getBodyComponent(){return this.options.body}getHeaderComponent(){return this.options.header}}class We extends w{constructor(t,i){super(),this.element=t,this._disposable=new _,this._viewDisposables=new Map,this._onDidLayoutfromJSON=new u,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidLayoutChange=new u,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidDrop=new u,this.onDidDrop=this._onDidDrop.event,this._onDidAddView=new u,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new u,this.onDidRemoveView=this._onDidRemoveView.event,this.addDisposables(this._onDidLayoutChange,this._onDidLayoutfromJSON,this._onDidDrop,this._onDidAddView,this._onDidRemoveView),this._options=i,i.components||(i.components={}),i.frameworkComponents||(i.frameworkComponents={}),this.paneview=new F(this.element,{orientation:e.Orientation.VERTICAL}),this.addDisposables(this._disposable)}get panels(){return this.paneview.getPanes()}set paneview(e){this._paneview=e,this._disposable.value=new w(this._paneview.onDidChange((()=>{this._onDidLayoutChange.fire(void 0)})),this._paneview.onDidAddView((e=>this._onDidAddView.fire(e))),this._paneview.onDidRemoveView((e=>this._onDidRemoveView.fire(e))))}get paneview(){return this._paneview}get minimumSize(){return this.paneview.minimumSize}get maximumSize(){return this.paneview.maximumSize}get height(){return this.paneview.orientation===e.Orientation.HORIZONTAL?this.paneview.orthogonalSize:this.paneview.size}get width(){return this.paneview.orientation===e.Orientation.HORIZONTAL?this.paneview.size:this.paneview.orthogonalSize}get options(){return this._options}focus(){}updateOptions(e){this._options=Object.assign(Object.assign({},this.options),e)}addPanel(t){const i=ze(t.id,t.component,this.options.components||{},this.options.frameworkComponents||{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.body.createComponent}:void 0);let s;s=t.headerComponent?ze(t.id,t.headerComponent,this.options.headerComponents||{},this.options.headerframeworkComponents,this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.header.createComponent}:void 0):new Me;const n=new Fe({id:t.id,component:t.component,headerComponent:t.headerComponent,header:s,body:i,orientation:e.Orientation.VERTICAL,isExpanded:!!t.isExpanded,disableDnd:!!this.options.disableDnd});this.doAddPanel(n);const o="number"==typeof t.size?t.size:e.Sizing.Distribute,r="number"==typeof t.index?t.index:void 0;return n.init({params:t.params||{},minimumBodySize:t.minimumBodySize,maximumBodySize:t.maximumBodySize,isExpanded:t.isExpanded,title:t.title,containerApi:new ne(this)}),this.paneview.addPane(n,o,r),n.orientation=this.paneview.orientation,n}removePanel(e){const t=this.panels.findIndex((t=>t===e));this.paneview.removePane(t),this.doRemovePanel(e)}movePanel(e,t){this.paneview.moveView(e,t)}getPanel(e){return this.panels.find((t=>t.id===e))}layout(t,i){const[s,n]=this.paneview.orientation===e.Orientation.HORIZONTAL?[t,i]:[i,t];this.paneview.layout(s,n)}toJSON(){const e=e=>e===Number.MAX_SAFE_INTEGER||e===Number.POSITIVE_INFINITY?void 0:e;return{views:this.paneview.getPanes().map(((t,i)=>{return{size:this.paneview.getViewSize(i),data:t.toJSON(),minimumSize:(s=t.minimumBodySize,s<=0?void 0:s),maximumSize:e(t.maximumBodySize),expanded:t.isExpanded()};var s})),size:this.paneview.size}}fromJSON(t){const{views:i,size:s}=t,n=[];for(const[e,t]of this._viewDisposables.entries())t.dispose();this._viewDisposables.clear(),this.paneview.dispose(),this.paneview=new F(this.element,{orientation:e.Orientation.VERTICAL,descriptor:{size:s,views:i.map((t=>{const i=t.data,s=ze(i.id,i.component,this.options.components||{},this.options.frameworkComponents||{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.body.createComponent}:void 0);let o;o=i.headerComponent?ze(i.id,i.headerComponent,this.options.headerComponents||{},this.options.headerframeworkComponents||{},this.options.frameworkWrapper?{createComponent:this.options.frameworkWrapper.header.createComponent}:void 0):new Me;const r=new Fe({id:i.id,component:i.component,headerComponent:i.headerComponent,header:o,body:s,orientation:e.Orientation.VERTICAL,isExpanded:!!t.expanded,disableDnd:!!this.options.disableDnd});return this.doAddPanel(r),n.push((()=>{r.init({params:i.params||{},minimumBodySize:t.minimumSize,maximumBodySize:t.maximumSize,title:i.title,isExpanded:!!t.expanded,containerApi:new ne(this)}),r.orientation=this.paneview.orientation})),setTimeout((()=>{this._onDidAddView.fire(r)}),0),{size:t.size,view:r}}))}}),this.layout(this.width,this.height),n.forEach((e=>e())),this._onDidLayoutfromJSON.fire()}doAddPanel(e){const t=e.onDidDrop((e=>{this._onDidDrop.fire(e)}));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.paneview.dispose()}}class Je extends xe{constructor(e,t){super(e,t,new Ge(e)),this._evaluatedMinimumSize=0,this._evaluatedMaximumSize=Number.POSITIVE_INFINITY,this._minimumSize=0,this._maximumSize=Number.POSITIVE_INFINITY,this._snap=!1,this._onDidChange=new u,this.onDidChange=this._onDidChange.event,this.addDisposables(this._onDidChange,this.api.onVisibilityChange((e=>{const{isVisible:t}=e,{accessor:i}=this._params;i.setVisible(this,t)})),this.api.onActiveChange((()=>{const{accessor:e}=this._params;e.setActive(this)})),this.api.onDidConstraintsChangeInternal((e=>{"number"!=typeof e.minimumSize&&"function"!=typeof e.minimumSize||(this._minimumSize=e.minimumSize),"number"!=typeof e.maximumSize&&"function"!=typeof e.maximumSize||(this._maximumSize=e.maximumSize),this.updateConstraints()})),this.api.onDidSizeChange((e=>{this._onDidChange.fire(e.size)})))}get priority(){return this._priority}set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){const e="function"==typeof this._minimumSize?this._minimumSize():this._minimumSize;return e!==this._evaluatedMinimumSize&&(this._evaluatedMinimumSize=e,this.updateConstraints()),e}get maximumSize(){const e="function"==typeof this._maximumSize?this._maximumSize():this._maximumSize;return e!==this._evaluatedMaximumSize&&(this._evaluatedMaximumSize=e,this.updateConstraints()),e}get snap(){return this._snap}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}layout(t,i){const[s,n]=this.orientation===e.Orientation.HORIZONTAL?[t,i]:[i,t];super.layout(s,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(){return Object.assign(Object.assign({},super.toJSON()),{minimumSize:(e=this.minimumSize,e<=0?void 0:e),maximumSize:(e=>e===Number.MAX_SAFE_INTEGER||e===Number.POSITIVE_INFINITY?void 0:e)(this.maximumSize)});var e}updateConstraints(){this.api._onDidConstraintsChange.fire({maximumSize:this._evaluatedMaximumSize,minimumSize:this._evaluatedMinimumSize})}}const Be=(e,t)=>{const[i,s]=o.useState(),n=o.useRef(e.componentProps);return o.useImperativeHandle(t,(()=>({update:e=>{n.current=Object.assign(Object.assign({},n.current),e),s(Date.now())}})),[]),o.createElement(e.component,n.current)};Be.displayName="DockviewReactJsBridge";const je=P(),$e=o.createContext({});class Ze{constructor(e,t,i,s,n){this.parent=e,this.portalStore=t,this.component=i,this.parameters=s,this.context=n,this.disposed=!1,this.createPortal()}update(e){var t;if(this.disposed)throw new Error("invalid operation: resource is already disposed");null===(t=this.componentInstance)||void 0===t||t.update(e)}createPortal(){if(this.disposed)throw new Error("invalid operation: resource is already disposed");if("function"!=typeof this.component)throw new Error("Invalid Operation. dockview only supports React Functional Components.");const e=o.createElement(o.forwardRef(Be),{component:this.component,componentProps:this.parameters,ref:e=>{this.componentInstance=e}}),t=this.context?o.createElement($e.Provider,{value:this.context},e):e,i=r.createPortal(t,this.parent,je.next());this.ref={portal:i,disposable:this.portalStore.addPortal(i)}}dispose(){var e;null===(e=this.ref)||void 0===e||e.disposable.dispose(),this.disposed=!0}}const Ue=()=>{const[e,t]=o.useState([]);o.useDebugValue(`Portal count: ${e.length}`);return[e,o.useCallback((e=>{t((t=>[...t,e]));let i=!1;return{dispose:()=>{if(i)throw new Error("invalid operation: resource already disposed");i=!0,t((t=>t.filter((t=>t!==e))))}}}),[])]};class Xe{constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._onDidFocus=new u,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new u,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="dockview-react-part",this._actionsElement=document.createElement("div"),this._actionsElement.className="dockview-react-part"}get element(){return this._element}get actions(){return this._actionsElement}focus(){}init(e){const t={api:e.api,containerApi:e.containerApi,actionsPortalElement:this._actionsElement,tabPortalElement:e.tab};this.part=new Ze(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi},t)}toJSON(){return{id:this.id}}update(e){var t;null===(t=this.part)||void 0===t||t.update(e.params)}updateParentGroup(e,t){this._group=e}layout(e,t){}dispose(){var e,t;this._onDidFocus.dispose(),this._onDidBlur.dispose(),null===(e=this.part)||void 0===e||e.dispose(),null===(t=this.actionsPart)||void 0===t||t.dispose()}}class Ke{constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._element=document.createElement("div"),this._element.className="dockview-react-part"}get element(){return this._element}focus(){}init(e){this.part=new Ze(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi})}update(e){var t;null===(t=this.part)||void 0===t||t.update(e.params)}toJSON(){return{id:this.id}}layout(e,t){}updateParentGroup(e,t){}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}class Ye{constructor(e){this.layout=e}fromJSON(e,t){var i,s,n;const o=e.id,r=e.params,a=e.title,h=e.suppressClosable,d=e.view,l=new Ne({content:ze(d.content.id,d.content.id,this.layout.options.components,this.layout.options.frameworkComponents,null===(i=this.layout.options.frameworkComponentFactory)||void 0===i?void 0:i.content),tab:(null===(s=d.tab)||void 0===s?void 0:s.id)?ze(d.tab.id,d.tab.id,this.layout.options.tabComponents,this.layout.options.frameworkTabComponents,null===(n=this.layout.options.frameworkComponentFactory)||void 0===n?void 0:n.tab):new Ee}),p=new be(o,this.layout,new re(this.layout),t);return p.init({view:l,title:a,suppressClosable:h,params:r||{}}),p}}class Qe{constructor(e,t,i){this.id=e,this.component=t,this.reactPortalStore=i,this._groupRef={value:void 0},this._element=document.createElement("div"),this._element.className="dockview-react-part"}get element(){return this._element}init(e){this.parameters=e,this.part=new Ze(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi,close:()=>{this._groupRef.value&&e.containerApi.removeGroup(this._groupRef.value)}})}focus(){}update(e){var t,i;this.parameters&&(this.parameters.params=e.params),null===(t=this.part)||void 0===t||t.update({params:(null===(i=this.parameters)||void 0===i?void 0:i.params)||{}})}toJSON(){return{id:this.id}}layout(e,t){}updateParentGroup(e,t){this._groupRef.value=e}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}const qe=o.forwardRef(((e,t)=>{const i=o.useRef(null),s=o.useRef(),[n,r]=Ue();return o.useImperativeHandle(t,(()=>i.current),[]),o.useEffect((()=>{if(e.disableAutoResizing)return()=>{};const t=f(i.current,(e=>{var t;const{width:i,height:n}=e.contentRect;null===(t=s.current)||void 0===t||t.layout(i,n)}));return()=>{t.dispose()}}),[e.disableAutoResizing]),o.useEffect((()=>{var t;const n={content:{createComponent:(e,t,i)=>new Xe(t,i,{addPortal:r})},tab:{createComponent:(e,t,i)=>new Ke(t,i,{addPortal:r})},watermark:{createComponent:(e,t,i)=>new Qe(t,i,{addPortal:r})}},o=document.createElement("div"),a=new Ie(o,{frameworkComponentFactory:n,frameworkComponents:e.components,frameworkTabComponents:e.tabComponents,tabHeight:e.tabHeight,watermarkFrameworkComponent:e.watermarkComponent,styles:e.hideBorders?{separatorBorder:"transparent"}:void 0});null===(t=i.current)||void 0===t||t.appendChild(a.element),a.deserializer=new Ye(a);const{clientWidth:h,clientHeight:d}=i.current;return a.layout(h,d),e.onReady&&e.onReady({api:new re(a)}),s.current=a,()=>{a.dispose(),o.remove()}}),[]),o.useEffect((()=>{if(!s.current)return()=>{};const t=s.current.onDidDrop((t=>{e.onDidDrop&&e.onDidDrop(t)}));return()=>{t.dispose()}}),[e.onDidDrop]),o.useEffect((()=>{s.current&&s.current.updateOptions({frameworkComponents:e.components})}),[e.components]),o.useEffect((()=>{s.current&&s.current.updateOptions({watermarkFrameworkComponent:e.watermarkComponent})}),[e.watermarkComponent]),o.useEffect((()=>{s.current&&s.current.updateOptions({showDndOverlay:e.showDndOverlay})}),[e.showDndOverlay]),o.useEffect((()=>{s.current&&s.current.updateOptions({frameworkTabComponents:e.tabComponents})}),[e.tabComponents]),o.useEffect((()=>{if(!e.onTabContextMenu||!s.current)return()=>{};const t=s.current.onTabContextMenu((t=>{e.onTabContextMenu&&e.onTabContextMenu(t)}));return()=>{t.dispose()}}),[e.onTabContextMenu]),o.createElement("div",{className:e.className,style:{height:"100%",width:"100%"},ref:i},n)}));qe.displayName="DockviewComponent";class et extends Je{constructor(e,t,i,s){super(e,t),this.reactComponent=i,this.reactPortalStore=s}getComponent(){var e;return new Ze(this.element,this.reactPortalStore,this.reactComponent,{params:(null===(e=this._params)||void 0===e?void 0:e.params)||{},api:this.api,containerApi:new se(this._params.accessor)})}}const tt=o.forwardRef(((t,i)=>{const s=o.useRef(null),n=o.useRef(),[r,a]=Ue();return o.useImperativeHandle(i,(()=>s.current),[]),o.useEffect((()=>{if(t.disableAutoResizing)return()=>{};const e=f(s.current,(e=>{var t;const{width:i,height:s}=e.contentRect;null===(t=n.current)||void 0===t||t.layout(i,s)}));return()=>{e.dispose()}}),[t.disableAutoResizing]),o.useEffect((()=>{const i=new Te(s.current,{orientation:t.orientation||e.Orientation.HORIZONTAL,frameworkComponents:t.components,frameworkWrapper:{createComponent:(e,t,i)=>new et(e,t,i,{addPortal:a})},proportionalLayout:"boolean"!=typeof t.proportionalLayout||t.proportionalLayout,styles:t.hideBorders?{separatorBorder:"transparent"}:void 0}),{clientWidth:o,clientHeight:r}=s.current;return i.layout(o,r),t.onReady&&t.onReady({api:new se(i)}),n.current=i,()=>{i.dispose()}}),[]),o.useEffect((()=>{n.current&&n.current.updateOptions({frameworkComponents:t.components})}),[t.components]),o.createElement("div",{className:t.className,style:{height:"100%",width:"100%"},ref:s},r)}));tt.displayName="SplitviewComponent";class it extends Pe{constructor(e,t,i,s){super(e,t),this.reactComponent=i,this.reactPortalStore=s}getComponent(){var e;return new Ze(this.element,this.reactPortalStore,this.reactComponent,{params:(null===(e=this._params)||void 0===e?void 0:e.params)||{},api:this.api,containerApi:new oe(this._params.accessor)})}}const st=o.forwardRef(((t,i)=>{const s=o.useRef(null),n=o.useRef(),[r,a]=Ue();return o.useImperativeHandle(i,(()=>s.current),[]),o.useEffect((()=>{if(t.disableAutoResizing)return()=>{};const e=f(s.current,(e=>{var t;const{width:i,height:s}=e.contentRect;null===(t=n.current)||void 0===t||t.layout(i,s)}));return()=>{e.dispose()}}),[t.disableAutoResizing]),o.useEffect((()=>{var i;const o=document.createElement("div"),r=new Le(o,{proportionalLayout:"boolean"!=typeof t.proportionalLayout||t.proportionalLayout,orientation:t.orientation||e.Orientation.HORIZONTAL,frameworkComponents:t.components,frameworkComponentFactory:{createComponent:(e,t,i)=>new it(e,t,i,{addPortal:a})},styles:t.hideBorders?{separatorBorder:"transparent"}:void 0});null===(i=s.current)||void 0===i||i.appendChild(r.element);const{clientWidth:h,clientHeight:d}=s.current;return r.layout(h,d),t.onReady&&t.onReady({api:new oe(r)}),n.current=r,()=>{r.dispose(),o.remove()}}),[]),o.useEffect((()=>{n.current&&n.current.updateOptions({frameworkComponents:t.components})}),[t.components]),o.createElement("div",{className:t.className,style:{height:"100%",width:"100%"},ref:s},r)}));st.displayName="GridviewComponent";class nt{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%"}get element(){return this._element}init(e){this.part=new Ze(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;null===(t=this.part)||void 0===t||t.update(e.params)}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}const ot=o.forwardRef(((e,t)=>{const i=o.useRef(null),s=o.useRef(),[n,r]=Ue();return o.useImperativeHandle(t,(()=>i.current),[]),o.useEffect((()=>{if(e.disableAutoResizing)return()=>{};const t=f(i.current,(e=>{var t;const{width:i,height:n}=e.contentRect;null===(t=s.current)||void 0===t||t.layout(i,n)}));return()=>{t.dispose()}}),[e.disableAutoResizing]),o.useEffect((()=>{const t=(e,t,i)=>new nt(e,i,{addPortal:r}),n=new We(i.current,{frameworkComponents:e.components,components:{},headerComponents:{},disableDnd:e.disableDnd,headerframeworkComponents:e.headerComponents,frameworkWrapper:{header:{createComponent:t},body:{createComponent:t}}}),o=new ne(n),{clientWidth:a,clientHeight:h}=i.current;return n.layout(a,h),e.onReady&&e.onReady({api:o}),s.current=n,()=>{n.dispose()}}),[]),o.useEffect((()=>{s.current&&s.current.updateOptions({frameworkComponents:e.components})}),[e.components]),o.useEffect((()=>{s.current&&s.current.updateOptions({headerframeworkComponents:e.headerComponents})}),[e.headerComponents]),o.useEffect((()=>{if(!s.current)return()=>{};const t=s.current,i=t.onDidDrop((i=>{e.onDidDrop&&e.onDidDrop(Object.assign(Object.assign({},i),{api:new ne(t)}))}));return()=>{i.dispose()}}),[e.onDidDrop]),o.createElement("div",{className:e.className,style:{height:"100%",width:"100%"},ref:i},n)}));ot.displayName="PaneviewComponent",e.BaseGrid=we,e.ContentContainer=ae,e.DockviewApi=re,e.DockviewComponent=Ie,e.DockviewReact=qe,e.Gridview=ie,e.GridviewApi=oe,e.GridviewComponent=Le,e.GridviewPanel=Pe,e.GridviewReact=st,e.Groupview=ce,e.LocalSelectionTransfer=l,e.PaneFramework=Fe,e.PaneTransfer=d,e.PanelTransfer=h,e.Paneview=F,e.PaneviewApi=ne,e.PaneviewComponent=We,e.PaneviewPanel=ke,e.PaneviewReact=ot,e.ReactPanelContentPart=Xe,e.ReactPanelHeaderPart=Ke,e.ReactPart=Ze,e.ReactPartContext=$e,e.Splitview=M,e.SplitviewApi=se,e.SplitviewComponent=Te,e.SplitviewPanel=Je,e.SplitviewReact=tt,e.Tab=me,e.getDirectionOrientation=Y,e.getGridLocation=X,e.getLocationOrientation=Q,e.getPaneData=m,e.getPanelData=p,e.getRelativeLocation=K,e.indexInParent=U,e.isGridBranchNode=ee,e.isReactElement=function(e){return null==e?void 0:e.type},e.orthogonal=q,e.toTarget=ge,e.usePortalsLifecycle=Ue,Object.defineProperty(e,"__esModule",{value:!0})}));
|