react-bwin 0.3.3 → 0.3.4

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.
@@ -1,8 +1,8 @@
1
- (function(w,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],u):(w=typeof globalThis<"u"?globalThis:w||self,u(w.ReactBinaryWindow={},w.React,w.ReactDOM))})(this,function(w,u,F){"use strict";var _=Object.defineProperty,q=(e,t,i)=>t in e?_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,E=(e,t,i)=>q(e,typeof t!="symbol"?t+"":t,i);function U(e=.7,t=128){const i=256-t,n=Math.floor(Math.random()*i+t),s=Math.floor(Math.random()*i+t),o=Math.floor(Math.random()*i+t),h=Math.max(.5,Math.random()*e);return`rgba(${n}, ${s}, ${o}, ${h})`}function C(e=2,t=3){if(e<0||t<0)throw new Error("Parameters must be non-negative numbers");const i="ABCDEFGHIJKLMNOPQRSTUVWXYZ",n="0123456789";let s="";for(let o=0;o<e;o++){const h=Math.floor(Math.random()*i.length);s+=i[h]}s+="-";for(let o=0;o<t;o++){const h=Math.floor(Math.random()*n.length);s+=n[h]}return s}function x(e,t){for(;t.firstChild;)e.append(t.firstChild)}function j(e,t){const i=document.createElement("div");x(i,e),x(e,t),x(t,i)}function S(e){if(typeof e=="number"&&!isNaN(e))return e;if(typeof e=="string"){const t=e.trim();if(t.endsWith("%")){const i=t.slice(0,-1);if(!i)return NaN;const n=Number(i);return isNaN(n)?NaN:n/100}if(t.endsWith("px")){const i=t.slice(0,-2);if(!i)return NaN;const n=Number(i);return isNaN(n)?NaN:n}return Number(t)}return NaN}function X(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype}function Y(e,t){for(const i in t){if(Object.hasOwn(e,i))throw new Error(`Key "${i}" already exists in target object`);e[i]=t[i]}return e}function K(e){const t=document.createElement("template");return t.innerHTML=e.trim(),t.content}function z(e){if(e==null||e==="")return null;if(typeof e=="string")try{const t=K(e);return t.childNodes.length===1?t.firstChild:t}catch{return document.createTextNode(e)}return e instanceof Node?e:document.createTextNode(String(e))}function M(e){const t=parseFloat(e.style.left)||0,i=parseFloat(e.style.top)||0,n=parseFloat(e.style.width)||0,s=parseFloat(e.style.height)||0;return{left:t,top:i,width:n,height:s}}const a={Top:"top",Right:"right",Bottom:"bottom",Left:"left",Center:"center",Root:"root",Unknown:"unknown",Outside:"outside"};function V(e){switch(e){case a.Top:return a.Bottom;case a.Right:return a.Left;case a.Bottom:return a.Top;case a.Left:return a.Right;default:throw new Error(`[bwin] Invalid position: ${e}`)}}function Z({width:e,height:t,x:i}){return t/e*i}function J({width:e,height:t,y:i}){return e/t*i}function Q({width:e,height:t,x:i}){return t-t/e*i}function tt({width:e,height:t,y:i}){return e-e/t*i}function et(e,{clientX:t,clientY:i}){const n=e.getBoundingClientRect(),{width:s,height:o}=n,h=t-n.left,r=i-n.top;if(h<0||h>s||r<0||r>o)return a.Outside;const d=.3,l=Z({width:s,height:o,x:h}),c=Q({width:s,height:o,x:h}),g=J({width:s,height:o,y:r}),f=tt({width:s,height:o,y:r});return h<s*(.5-d/2)&&r>l&&r<c?a.Left:h>s*(.5+d/2)&&r<l&&r>c?a.Right:r<o*(.5-d/2)&&h>g&&h<f?a.Top:r>o*(.5+d/2)&&h<g&&h>f?a.Bottom:h>s*(.5-d/2)&&h<s*(.5+d/2)&&r>o*(.5-d/2)&&r<o*(.5+d/2)?a.Center:a.Unknown}const it=100,nt=100,v={left:0,top:0,width:150,height:150,minWidth:it,minHeight:nt};class m{constructor({left:t=v.left,top:i=v.top,width:n=v.width,height:s=v.height,minWidth:o=v.minWidth,minHeight:h=v.minHeight,domNode:r=null,store:d={},position:l,id:c}=v){if(this.id=c??C(),!l)throw new Error("[bwin] Sash position is required");this.position=l,this.domNode=r,this._top=i,this._left=t,this._width=n,this._height=s,this.children=[],this.minWidth=o,this.minHeight=h,this.store=d}walk(t){this.children.forEach(i=>i.walk(t)),t(this)}isLeaf(){return this.children.length===0}isSplit(){return this.children.length>0}isLeftRightSplit(){return this.children.some(t=>t.position===a.Left||t.position===a.Right)}isTopBottomSplit(){return this.children.some(t=>t.position===a.Top||t.position===a.Bottom)}get leftChild(){return this.children.find(t=>t.position===a.Left)}get rightChild(){return this.children.find(t=>t.position===a.Right)}get topChild(){return this.children.find(t=>t.position===a.Top)}get bottomChild(){return this.children.find(t=>t.position===a.Bottom)}getChildren(){let t=null,i=null,n=null,s=null;for(const o of this.children)o.position===a.Left?t=o:o.position===a.Right?i=o:o.position===a.Top?n=o:o.position===a.Bottom&&(s=o);return[n,i,s,t]}getAllLeafDescendants(){const t=[];return this.walk(i=>{i.children.length===0&&t.push(i)}),t}calcMinWidth(){if(this.isLeaf())return this.minWidth;const[t,i,n,s]=this.getChildren();if(s&&i){const o=s.calcMinWidth()+i.calcMinWidth();return Math.max(this.minWidth,o)}if(t&&n){const o=Math.max(t.calcMinWidth(),n.calcMinWidth());return Math.max(this.minWidth,o)}}calcMinHeight(){if(this.isLeaf())return this.minHeight;const[t,i,n,s]=this.getChildren();if(s&&i){const o=Math.max(s.calcMinHeight(),i.calcMinHeight());return Math.max(this.minHeight,o)}if(t&&n){const o=t.calcMinHeight()+n.calcMinHeight();return Math.max(this.minHeight,o)}}getById(t){if(this.id===t)return this;for(const i of this.children){const n=i.getById(t);if(n)return n}return null}swapIds(t,i){const n=this.getById(t),s=this.getById(i);if(!n||!s)throw new Error("[bwin] Sash not found when swapping IDs");const o=n.id;n.id=s.id,s.id=o}getAllIds(){const t=[this.id];for(const i of this.children)t.push(...i.getAllIds());return t}addChild(t){if(this.children.length>=2)throw new Error("[bwin] Maximum 2 children allowed");this.children.push(t)}getDescendantParentById(t){for(const i of this.children){if(i.id===t)return this;const n=i.getDescendantParentById(t);if(n)return n}return null}getChildSiblingById(t){return this.children.find(i=>i.id!==t)}get top(){return this._top}set top(t){const i=t-this._top;this._top=t;const[n,s,o,h]=this.getChildren();n&&o&&(n.top+=i,o.top+=i),h&&s&&(h.top+=i,s.top+=i)}get left(){return this._left}set left(t){const i=t-this._left;this._left=t;const[n,s,o,h]=this.getChildren();h&&s&&(h.left+=i,s.left+=i),n&&o&&(n.left+=i,o.left+=i)}get width(){return this._width}set width(t){const i=t-this._width;this._width=t;const[n,s,o,h]=this.getChildren();if(h&&s){const r=h.width+s.width,d=i*(h.width/r),l=r+i;let c=h.width+d,g=l-c,f=s.left+d;const b=h.calcMinWidth(),y=s.calcMinWidth();i<0&&(c<b&&g>y?(c=h.width,g=l-c,f=h.left+c):g<y&&c>b&&(g=s.width,c=l-g,f=h.left+c)),h.width=c,s.width=g,s.left=f}n&&o&&(n.width+=i,o.width+=i)}get height(){return this._height}set height(t){const i=t-this._height;this._height=t;const[n,s,o,h]=this.getChildren();if(n&&o){const r=n.height+o.height,d=i*(n.height/r),l=r+i;let c=n.height+d,g=l-c,f=o.top+d;if(i<0){const b=n.calcMinHeight(),y=o.calcMinHeight();c<b&&g>y?(c=n.height,g=l-c,f=n.top+c):g<y&&c>b&&(g=o.height,c=l-g,f=n.top+c)}n.height=c,o.height=g,o.top=f}h&&s&&(h.height+=i,s.height+=i)}}const H={size:"50%",position:a.Left};class P{constructor({parentRect:t,children:i,siblingConfigNode:n,id:s,minWidth:o,minHeight:h,position:r,size:d,...l}){E(this,"left"),E(this,"top"),E(this,"width"),E(this,"height"),this.parentRect=t,this.children=i,this.siblingConfigNode=n,this.id=s,this.minWidth=o,this.minHeight=h,this.position=this.getPosition(r),this.size=this.getSize(d),this.nonCoreData=l,this.setBounds()}getPosition(t){if(!this.siblingConfigNode)return t;const i=V(this.siblingConfigNode.position);if(!t)return i;if(t!==i)throw new Error("[bwin] Sibling position and current position are not opposite");return t}getSize(t){if(!this.siblingConfigNode)return S(t);if(!t){if(this.siblingConfigNode.size<1)return 1-this.siblingConfigNode.size;if(this.siblingConfigNode.position===a.Left||this.siblingConfigNode.position===a.Right)return this.parentRect.width-this.siblingConfigNode.width;if(this.siblingConfigNode.position===a.Top||this.siblingConfigNode.position===a.Bottom)return this.parentRect.height-this.siblingConfigNode.height}const i=S(t);if(i<1){if(i+this.siblingConfigNode.size!==1)throw new Error("[bwin] Sum of sibling sizes is not equal to 1")}else{if((this.position===a.Left||this.position===a.Right)&&i+this.siblingConfigNode.size!==this.parentRect.width)throw new Error("[bwin] Sum of sibling sizes is not equal to parent width");if((this.position===a.Top||this.position===a.Bottom)&&i+this.siblingConfigNode.size!==this.parentRect.height)throw new Error("[bwin] Sum of sibling sizes is not equal to parent height")}return i}setBounds(){if(this.position===a.Root)this.left=0,this.top=0,this.width=this.parentRect.width,this.height=this.parentRect.height;else if(this.position===a.Left){const t=this.size<1?this.parentRect.width*this.size:this.size;this.left=this.parentRect.left,this.top=this.parentRect.top,this.width=t,this.height=this.parentRect.height}else if(this.position===a.Right){const t=this.size<1?this.parentRect.width*this.size:this.size;this.left=this.parentRect.left+this.parentRect.width-t,this.top=this.parentRect.top,this.width=t,this.height=this.parentRect.height}else if(this.position===a.Top){const t=this.size<1?this.parentRect.height*this.size:this.size;this.left=this.parentRect.left,this.top=this.parentRect.top,this.width=this.parentRect.width,this.height=t}else if(this.position===a.Bottom){const t=this.size<1?this.parentRect.height*this.size:this.size;this.left=this.parentRect.left,this.top=this.parentRect.top+this.parentRect.height-t,this.width=this.parentRect.width,this.height=t}}createSash(){return new m({left:this.left,top:this.top,width:this.width,height:this.height,position:this.position,id:this.id,minWidth:this.minWidth,minHeight:this.minHeight,store:this.nonCoreData})}normConfig(t){if(X(t))return t;if(Array.isArray(t))return{children:t};if(typeof t=="string"||typeof t=="number"){const i=S(t);if(isNaN(i))throw new Error(`[bwin] Invalid size value: ${i}`);return{size:t}}else{if(t==null)return{};throw new Error(`[bwin] Invalid config value: ${t}`)}}createPrimaryConfigNode({size:t,position:i,children:n,id:s,minWidth:o,minHeight:h,...r}){return new P({parentRect:this,size:t??H.size,position:i??H.position,children:n,id:s,minWidth:o,minHeight:h,...r})}createSecondaryConfigNode({size:t,position:i,children:n,id:s,minWidth:o,minHeight:h,...r},d){return new P({parentRect:this,size:t,position:i,children:n,siblingConfigNode:d,id:s,minWidth:o,minHeight:h,...r})}buildSashTree(){const t=this.createSash();if(!Array.isArray(this.children)||this.children.length===0)return t;const i=this.normConfig(this.children[0]),n=this.normConfig(this.children.at(1));let s,o;return!i.size&&!i.position&&n?(n.position||(n.position=a.Right),s=this.createPrimaryConfigNode(n),o=this.createSecondaryConfigNode(i,s)):(s=this.createPrimaryConfigNode(i),o=this.createSecondaryConfigNode(n,s)),s&&o&&(t.children.push(s.buildSashTree()),t.children.push(o.buildSashTree())),t}}const R={width:333,height:333},$={fitContainer:!1};class st extends P{constructor({id:t,children:i,width:n=R.width,height:s=R.height,fitContainer:o=$.fitContainer,...h}={...R,...$}){super({id:t,children:i,size:NaN,position:a.Root,parentRect:{width:n,height:s},...h}),this.fitContainer=o}}class ot extends m{constructor(t=v){super({...t,position:a.Root}),Object.assign(this,$)}}function ht(e){const t=document.createElement("bw-pane");return t.style.top=`${e.top}px`,t.style.left=`${e.left}px`,t.style.width=`${e.width}px`,t.style.height=`${e.height}px`,t.setAttribute("sash-id",e.id),t.setAttribute("position",e.position),t}function rt(e){const t=e.domNode;return t.style.top=`${e.top}px`,t.style.left=`${e.left}px`,t.style.width=`${e.width}px`,t.style.height=`${e.height}px`,t.setAttribute("position",e.position),t}function at(e,{size:t,id:i}){const n=S(t);let s=e.width/2;n&&(n<1?s=e.width*n:s=n);const o=new m({id:i,top:e.top,left:e.left,width:s,height:e.height,position:a.Left}),h=new m({id:e.id,top:e.top,left:e.left+o.width,width:e.width-s,height:e.height,position:a.Right,domNode:e.domNode});return e.addChild(o),e.addChild(h),e.domNode=null,e.id=C(),o}function lt(e,{size:t,id:i}){const n=S(t);let s=e.width/2;n&&(n<1?s=e.width*n:s=n);const o=new m({id:e.id,left:e.left,top:e.top,width:e.width-s,height:e.height,position:a.Left,domNode:e.domNode}),h=new m({id:i,left:e.left+o.width,top:e.top,width:s,height:e.height,position:a.Right});return e.addChild(o),e.addChild(h),e.domNode=null,e.id=C(),h}function dt(e,{size:t,id:i}){const n=S(t);let s=e.height/2;n&&(n<1?s=e.height*n:s=n);const o=new m({id:i,left:e.left,top:e.top,width:e.width,height:s,position:a.Top}),h=new m({id:e.id,left:e.left,top:e.top+o.height,width:e.width,height:e.height-s,position:a.Bottom,domNode:e.domNode});return e.addChild(o),e.addChild(h),e.domNode=null,e.id=C(),o}function ct(e,{size:t,id:i}){const n=S(t);let s=e.height/2;n&&(n<1?s=e.height*n:s=n);const o=new m({id:e.id,top:e.top,left:e.left,width:e.width,height:e.height-s,position:a.Top,domNode:e.domNode}),h=new m({id:i,top:e.top+o.height,left:e.left,width:e.width,height:s,position:a.Bottom});return e.addChild(o),e.addChild(h),e.domNode=null,e.id=C(),h}function ut(e,{position:t,size:i,id:n,minWidth:s,minHeight:o}){if(t===a.Left)return at(e,{size:i,id:n});if(t===a.Right)return lt(e,{size:i,id:n});if(t===a.Top)return dt(e,{size:i,id:n});if(t===a.Bottom)return ct(e,{size:i,id:n})}function D(e){if(e.tagName==="BW-PANE")return e.getAttribute("sash-id");const t=e.closest("bw-pane");if(!t)throw new Error("[bwin] Pane element not found");return t.getAttribute("sash-id")}const pt={createPane(e){const t=ht(e);return e.store.droppable===!1&&t.setAttribute("can-drop","false"),t},onPaneCreate(e,t){t.store.content&&e.append(z(t.store.content)),this!=null&&this.debug&&(e.style.backgroundColor=U(),e.innerHTML="",e.append(I(e)))},updatePane(e){return rt(e)},onPaneUpdate(e,t){this!=null&&this.debug&&(e.innerHTML="",e.append(I(e)))},addPane(e,{position:t,size:i,id:n}){if(!t)throw new Error("[bwin] Position is required when adding pane");const s=this.rootSash.getById(e);if(!s)throw new Error("[bwin] Parent sash not found when adding pane");const o=ut(s,{position:t,size:i,id:n});return this.update(),o},removePane(e){const t=this.rootSash.getDescendantParentById(e);if(!t)throw new Error("[bwin] Parent sash not found when removing pane");const i=t.getChildSiblingById(e);i.children.length===0?(t.id=i.id,t.domNode=i.domNode,t.domNode.setAttribute("sash-id",i.id),t.children=[]):(t.id=C(),t.children=i.children,i.position===a.Left?i.width=t.width:i.position===a.Right?(i.width=t.width,i.left=t.left):i.position===a.Top?i.height=t.height:i.position===a.Bottom&&(i.height=t.height,i.top=t.top)),this.update()},swapPanes(e,t){const i=D(e),n=D(t),s=e.getAttribute("can-drop")!=="false",o=t.getAttribute("can-drop")!=="false";this.rootSash.swapIds(i,n),j(e,this.activeDropPaneEl),e.setAttribute("sash-id",n),t.setAttribute("sash-id",i),e.setAttribute("can-drop",o),t.setAttribute("can-drop",s)}};function I(e){const t=document.createElement("pre");t.style.fontSize="10px";const i=`
2
- ${e.getAttribute("sash-id")}
3
- ${e.getAttribute("position")}
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`react`),require(`react-dom`)):typeof define==`function`&&define.amd?define([`exports`,`react`,`react-dom`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ReactBinaryWindow={},e.React,e.ReactDOM))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var s=o(t),l=0,u=s.length,d;l<u;l++)d=s[l],!c.call(e,d)&&d!==n&&i(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=a(t,d))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:r(s(e)),l(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e)))(t,1);function u(e=.7,t=128){let n=256-t;return`rgba(${Math.floor(Math.random()*n+t)}, ${Math.floor(Math.random()*n+t)}, ${Math.floor(Math.random()*n+t)}, ${Math.max(.5,Math.random()*e)})`}function d(e=2,t=3){if(e<0||t<0)throw Error(`Parameters must be non-negative numbers`);let n=``;for(let t=0;t<e;t++){let e=Math.floor(Math.random()*26);n+=`ABCDEFGHIJKLMNOPQRSTUVWXYZ`[e]}n+=`-`;for(let e=0;e<t;e++){let e=Math.floor(Math.random()*10);n+=`0123456789`[e]}return n}function f(e,t){for(;t.firstChild;)e.append(t.firstChild)}function p(e,t){let n=document.createElement(`div`);f(n,e),f(e,t),f(t,n)}function m(e){if(typeof e==`number`&&!isNaN(e))return e;if(typeof e==`string`){let t=e.trim();if(t.endsWith(`%`)){let e=t.slice(0,-1);if(!e)return NaN;let n=Number(e);return isNaN(n)?NaN:n/100}if(t.endsWith(`px`)){let e=t.slice(0,-2);if(!e)return NaN;let n=Number(e);return isNaN(n)?NaN:n}return Number(t)}return NaN}function h(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype}function g(e,t){for(let n in t){if(Object.hasOwn(e,n))throw Error(`Key "${n}" already exists in target object`);e[n]=t[n]}return e}function _(e){let t=document.createElement(`template`);return t.innerHTML=e.trim(),t.content}function v(e){if(e==null||e===``)return null;if(typeof e==`string`)try{let t=_(e);return t.childNodes.length===1?t.firstChild:t}catch{return document.createTextNode(e)}return e instanceof Node?e:document.createTextNode(String(e))}function y(e){return{left:parseFloat(e.style.left)||0,top:parseFloat(e.style.top)||0,width:parseFloat(e.style.width)||0,height:parseFloat(e.style.height)||0}}var b={Top:`top`,Right:`right`,Bottom:`bottom`,Left:`left`,Center:`center`,Root:`root`,Unknown:`unknown`,Outside:`outside`};function ee(e){switch(e){case b.Top:return b.Bottom;case b.Right:return b.Left;case b.Bottom:return b.Top;case b.Left:return b.Right;default:throw Error(`[bwin] Invalid position: ${e}`)}}function te({width:e,height:t,x:n}){return t/e*n}function ne({width:e,height:t,y:n}){return e/t*n}function x({width:e,height:t,x:n}){return t-t/e*n}function S({width:e,height:t,y:n}){return e-e/t*n}function C(e,{clientX:t,clientY:n}){let r=e.getBoundingClientRect(),{width:i,height:a}=r,o=t-r.left,s=n-r.top;if(o<0||o>i||s<0||s>a)return b.Outside;let c=.3,l=te({width:i,height:a,x:o}),u=x({width:i,height:a,x:o}),d=ne({width:i,height:a,y:s}),f=S({width:i,height:a,y:s});return o<i*(.5-c/2)&&s>l&&s<u?b.Left:o>i*.65&&s<l&&s>u?b.Right:s<a*(.5-c/2)&&o>d&&o<f?b.Top:s>a*.65&&o<d&&o>f?b.Bottom:o>i*(.5-c/2)&&o<i*.65&&s>a*(.5-c/2)&&s<a*.65?b.Center:b.Unknown}var w={left:0,top:0,width:150,height:150,minWidth:100,minHeight:100,resizeStrategy:`classic`},T=class{constructor({left:e=w.left,top:t=w.top,width:n=w.width,height:r=w.height,minWidth:i=w.minWidth,minHeight:a=w.minHeight,resizeStrategy:o=w.resizeStrategy,parent:s=null,domNode:c=null,store:l={},position:u,id:f}=w){if(this.id=f??d(),!u)throw Error(`[bwin] Sash position is required`);this.position=u,this.domNode=c,this.parent=s,this._top=t,this._left=e,this._width=n,this._height=r,this.children=[],this.minWidth=i,this.minHeight=a,this.resizeStrategy=o,this.store=l}walk(e){this.children.forEach(t=>t.walk(e)),e(this)}isLeaf(){return this.children.length===0}isSplit(){return this.children.length>0}isLeftRightSplit(){return this.children.some(e=>e.position===b.Left||e.position===b.Right)}isTopBottomSplit(){return this.children.some(e=>e.position===b.Top||e.position===b.Bottom)}get leftChild(){return this.children.find(e=>e.position===b.Left)}get rightChild(){return this.children.find(e=>e.position===b.Right)}get topChild(){return this.children.find(e=>e.position===b.Top)}get bottomChild(){return this.children.find(e=>e.position===b.Bottom)}getChildren(){let e=null,t=null,n=null,r=null;for(let i of this.children)i.position===b.Left?e=i:i.position===b.Right?t=i:i.position===b.Top?n=i:i.position===b.Bottom&&(r=i);return[n,t,r,e]}getAllLeafDescendants(){let e=[];return this.walk(t=>{t.children.length===0&&e.push(t)}),e}calcMinWidth(){if(this.isLeaf())return this.minWidth;let[e,t,n,r]=this.getChildren();if(r&&t){let e=r.calcMinWidth()+t.calcMinWidth();return Math.max(this.minWidth,e)}if(e&&n){let t=Math.max(e.calcMinWidth(),n.calcMinWidth());return Math.max(this.minWidth,t)}}calcMinHeight(){if(this.isLeaf())return this.minHeight;let[e,t,n,r]=this.getChildren();if(r&&t){let e=Math.max(r.calcMinHeight(),t.calcMinHeight());return Math.max(this.minHeight,e)}if(e&&n){let t=e.calcMinHeight()+n.calcMinHeight();return Math.max(this.minHeight,t)}}getById(e){if(this.id===e)return this;for(let t of this.children){let n=t.getById(e);if(n)return n}return null}swapIds(e,t){let n=this.getById(e),r=this.getById(t);if(!n||!r)throw Error(`[bwin] Sash not found when swapping IDs`);let i=n.id;n.id=r.id,r.id=i}getAllIds(){let e=[this.id];for(let t of this.children)e.push(...t.getAllIds());return e}addChild(e){if(this.children.length>=2)throw Error(`[bwin] Maximum 2 children allowed`);this.children.push(e)}getDescendantParentById(e){for(let t of this.children){if(t.id===e)return this;let n=t.getDescendantParentById(e);if(n)return n}return null}getChildSiblingById(e){return this.children.find(t=>t.id!==e)}get top(){return this._top}set top(e){let t=e-this._top;this._top=e;let[n,r,i,a]=this.getChildren();n&&i&&(n.top+=t,i.top+=t),a&&r&&(a.top+=t,r.top+=t)}get left(){return this._left}set left(e){let t=e-this._left;this._left=e;let[n,r,i,a]=this.getChildren();a&&r&&(a.left+=t,r.left+=t),n&&i&&(n.left+=t,i.left+=t)}get width(){return this._width}set width(e){let t=e-this._width;this._width=e;let[n,r,i,a]=this.getChildren();if(a&&r){let e=a.width+r.width,n=t*(a.width/e),i=e+t,o,s,c;if(this.resizeStrategy===`natural`&&this.position===b.Left?(o=a.width,s=r.width+t,c=r.left):this.resizeStrategy===`natural`&&this.position===b.Right?(o=a.width+t,s=r.width,c=a.left+o):(o=a.width+n,s=i-o,c=r.left+n),t<0){let e=a.calcMinWidth(),t=r.calcMinWidth();o<e&&s>t?(o=a.width,s=i-o,c=a.left+o):s<t&&o>e&&(s=r.width,o=i-s,c=a.left+o)}a.width=o,r.width=s,r.left=c}n&&i&&(n.width+=t,i.width+=t)}get height(){return this._height}set height(e){let t=e-this._height;this._height=e;let[n,r,i,a]=this.getChildren();if(n&&i){let e=n.height+i.height,r=t*(n.height/e),a=e+t,o,s,c;if(this.resizeStrategy===`natural`&&this.position===b.Top?(o=n.height,s=i.height+t,c=i.top):this.resizeStrategy===`natural`&&this.position===b.Bottom?(o=n.height+t,s=i.height,c=n.top+o):(o=n.height+r,s=a-o,c=i.top+r),t<0){let e=n.calcMinHeight(),t=i.calcMinHeight();o<e&&s>t?(o=n.height,s=a-o,c=n.top+o):s<t&&o>e&&(s=i.height,o=a-s,c=n.top+o)}n.height=o,i.height=s,i.top=c}a&&r&&(a.height+=t,r.height+=t)}},E={size:`50%`,position:b.Left},re=class e{left;top;width;height;constructor({parentRect:e,children:t,siblingConfigNode:n,id:r,minWidth:i,minHeight:a,position:o,size:s,resizeStrategy:c,...l}){this.parentRect=e,this.children=t,this.siblingConfigNode=n,this.id=r,this.minWidth=i,this.minHeight=a,this.position=this.getPosition(o),this.size=this.getSize(s),this.resizeStrategy=c,this.nonCoreData=l,this.setBounds()}getPosition(e){if(!this.siblingConfigNode)return e;let t=ee(this.siblingConfigNode.position);if(!e)return t;if(e!==t)throw Error(`[bwin] Sibling position and current position are not opposite`);return e}getSize(e){if(!this.siblingConfigNode)return m(e);if(!e){if(this.siblingConfigNode.size<1)return 1-this.siblingConfigNode.size;if(this.siblingConfigNode.position===b.Left||this.siblingConfigNode.position===b.Right)return this.parentRect.width-this.siblingConfigNode.width;if(this.siblingConfigNode.position===b.Top||this.siblingConfigNode.position===b.Bottom)return this.parentRect.height-this.siblingConfigNode.height}let t=m(e);if(t<1){if(t+this.siblingConfigNode.size!==1)throw Error(`[bwin] Sum of sibling sizes is not equal to 1`)}else{if((this.position===b.Left||this.position===b.Right)&&t+this.siblingConfigNode.size!==this.parentRect.width)throw Error(`[bwin] Sum of sibling sizes is not equal to parent width`);if((this.position===b.Top||this.position===b.Bottom)&&t+this.siblingConfigNode.size!==this.parentRect.height)throw Error(`[bwin] Sum of sibling sizes is not equal to parent height`)}return t}setBounds(){if(this.position===b.Root)this.left=0,this.top=0,this.width=this.parentRect.width,this.height=this.parentRect.height;else if(this.position===b.Left){let e=this.size<1?this.parentRect.width*this.size:this.size;this.left=this.parentRect.left,this.top=this.parentRect.top,this.width=e,this.height=this.parentRect.height}else if(this.position===b.Right){let e=this.size<1?this.parentRect.width*this.size:this.size;this.left=this.parentRect.left+this.parentRect.width-e,this.top=this.parentRect.top,this.width=e,this.height=this.parentRect.height}else if(this.position===b.Top){let e=this.size<1?this.parentRect.height*this.size:this.size;this.left=this.parentRect.left,this.top=this.parentRect.top,this.width=this.parentRect.width,this.height=e}else if(this.position===b.Bottom){let e=this.size<1?this.parentRect.height*this.size:this.size;this.left=this.parentRect.left,this.top=this.parentRect.top+this.parentRect.height-e,this.width=this.parentRect.width,this.height=e}}createSash({resizeStrategy:e}={}){return new T({left:this.left,top:this.top,width:this.width,height:this.height,position:this.position,id:this.id,minWidth:this.minWidth,minHeight:this.minHeight,resizeStrategy:e||this.resizeStrategy,store:this.nonCoreData})}normConfig(e){if(h(e))return e;if(Array.isArray(e))return{children:e};if(typeof e==`string`||typeof e==`number`){let t=m(e);if(isNaN(t))throw Error(`[bwin] Invalid size value: ${t}`);return{size:e}}else if(e==null)return{};else throw Error(`[bwin] Invalid config value: ${e}`)}createPrimaryConfigNode({size:t,position:n,children:r,id:i,minWidth:a,minHeight:o,...s}){return new e({parentRect:this,size:t??E.size,position:n??E.position,children:r,id:i,minWidth:a,minHeight:o,...s})}createSecondaryConfigNode({size:t,position:n,children:r,id:i,minWidth:a,minHeight:o,...s},c){return new e({parentRect:this,size:t,position:n,children:r,siblingConfigNode:c,id:i,minWidth:a,minHeight:o,...s})}buildSashTree({resizeStrategy:e}={}){let t=this.createSash({resizeStrategy:e});if(!Array.isArray(this.children)||this.children.length===0)return t;let n=this.normConfig(this.children[0]),r=this.normConfig(this.children.at(1)),i,a;if(!n.size&&!n.position&&r?(r.position||=b.Right,i=this.createPrimaryConfigNode(r),a=this.createSecondaryConfigNode(n,i)):(i=this.createPrimaryConfigNode(n),a=this.createSecondaryConfigNode(r,i)),i&&a){let n=i.buildSashTree({resizeStrategy:e}),r=a.buildSashTree({resizeStrategy:e});n.parent=t,r.parent=t,t.children.push(n),t.children.push(r)}return t}},D={width:333,height:333},O={fitContainer:!1,theme:``},ie=class extends re{constructor({id:e,children:t,width:n=D.width,height:r=D.height,fitContainer:i=O.fitContainer,theme:a=O.theme,...o}={...D,...O}){super({id:e,children:t,size:NaN,position:b.Root,parentRect:{width:n,height:r},...o}),this.fitContainer=i,this.theme=a}},k=class extends T{constructor(e=w){super({...e,position:b.Root}),Object.assign(this,O)}};function A(e){let t=document.createElement(`bw-pane`);return t.style.top=`${e.top}px`,t.style.left=`${e.left}px`,t.style.width=`${e.width}px`,t.style.height=`${e.height}px`,t.setAttribute(`sash-id`,e.id),t.setAttribute(`position`,e.position),t}function j(e){let t=e.domNode;return t.style.top=`${e.top}px`,t.style.left=`${e.left}px`,t.style.width=`${e.width}px`,t.style.height=`${e.height}px`,t.setAttribute(`position`,e.position),t}function M(e,{size:t,id:n}){let r=m(t),i=e.width/2;r&&(i=r<1?e.width*r:r);let a=new T({id:n,top:e.top,left:e.left,width:i,height:e.height,position:b.Left}),o=new T({id:e.id,top:e.top,left:e.left+a.width,width:e.width-i,height:e.height,position:b.Right,domNode:e.domNode});return e.addChild(a),e.addChild(o),e.domNode=null,e.id=d(),a}function N(e,{size:t,id:n}){let r=m(t),i=e.width/2;r&&(i=r<1?e.width*r:r);let a=new T({id:e.id,left:e.left,top:e.top,width:e.width-i,height:e.height,position:b.Left,domNode:e.domNode}),o=new T({id:n,left:e.left+a.width,top:e.top,width:i,height:e.height,position:b.Right});return e.addChild(a),e.addChild(o),e.domNode=null,e.id=d(),o}function P(e,{size:t,id:n}){let r=m(t),i=e.height/2;r&&(i=r<1?e.height*r:r);let a=new T({id:n,left:e.left,top:e.top,width:e.width,height:i,position:b.Top}),o=new T({id:e.id,left:e.left,top:e.top+a.height,width:e.width,height:e.height-i,position:b.Bottom,domNode:e.domNode});return e.addChild(a),e.addChild(o),e.domNode=null,e.id=d(),a}function F(e,{size:t,id:n}){let r=m(t),i=e.height/2;r&&(i=r<1?e.height*r:r);let a=new T({id:e.id,top:e.top,left:e.left,width:e.width,height:e.height-i,position:b.Top,domNode:e.domNode}),o=new T({id:n,top:e.top+a.height,left:e.left,width:e.width,height:i,position:b.Bottom});return e.addChild(a),e.addChild(o),e.domNode=null,e.id=d(),o}function I(e,{position:t,size:n,id:r,minWidth:i,minHeight:a}){if(t===b.Left)return M(e,{size:n,id:r});if(t===b.Right)return N(e,{size:n,id:r});if(t===b.Top)return P(e,{size:n,id:r});if(t===b.Bottom)return F(e,{size:n,id:r})}function L(e){if(e.tagName===`BW-PANE`)return e.getAttribute(`sash-id`);let t=e.closest(`bw-pane`);if(!t)throw Error(`[bwin] Pane element not found`);return t.getAttribute(`sash-id`)}var R={createPane(e){let t=A(e);return e.store.droppable===!1&&t.setAttribute(`can-drop`,`false`),t},onPaneCreate(e,t){t.store.content&&e.append(v(t.store.content)),this?.debug&&(e.style.backgroundColor=u(),e.innerHTML=``,e.append(z(e)))},updatePane(e){return j(e)},onPaneUpdate(e,t){this?.debug&&(e.innerHTML=``,e.append(z(e)))},addPane(e,{position:t,size:n,id:r}){if(!t)throw Error(`[bwin] Position is required when adding pane`);let i=this.rootSash.getById(e);if(!i)throw Error(`[bwin] Parent sash not found when adding pane`);let a=I(i,{position:t,size:n,id:r});return this.update(),a},removePane(e){let t=this.rootSash.getDescendantParentById(e);if(!t)throw Error(`[bwin] Parent sash not found when removing pane`);let n=t.getChildSiblingById(e);n.children.length===0?(t.id=n.id,t.domNode=n.domNode,t.domNode.setAttribute(`sash-id`,n.id),t.children=[]):(t.id=d(),t.children=n.children,n.position===b.Left?n.width=t.width:n.position===b.Right?(n.width=t.width,n.left=t.left):n.position===b.Top?n.height=t.height:n.position===b.Bottom&&(n.height=t.height,n.top=t.top)),this.update()},swapPanes(e,t){let n=L(e),r=L(t),i=e.getAttribute(`can-drop`)!==`false`,a=t.getAttribute(`can-drop`)!==`false`;this.rootSash.swapIds(n,r),p(e,this.activeDropPaneEl),e.setAttribute(`sash-id`,r),t.setAttribute(`sash-id`,n),e.setAttribute(`can-drop`,a),t.setAttribute(`can-drop`,i)}};function z(e){let t=document.createElement(`pre`);return t.style.fontSize=`10px`,t.innerHTML=`
2
+ ${e.getAttribute(`sash-id`)}
3
+ ${e.getAttribute(`position`)}
4
4
  top: ${e.style.top}
5
5
  left: ${e.style.left}
6
6
  width: ${e.style.width}
7
7
  height: ${e.style.height}
8
- `;return t.innerHTML=i.trim(),t}const gt={createWindow(){const e=document.createElement("bw-window");return e.style.width=`${this.rootSash.width}px`,e.style.height=`${this.rootSash.height}px`,e.setAttribute("root-sash-id",this.rootSash.id),e},glaze(){this.rootSash.walk(e=>{let t=null;e.children.length>0?(t=this.createMuntin(e),this.onMuntinCreate(t,e),this.windowElement.append(t)):(t=this.createPane(e),this.onPaneCreate(t,e),this.windowElement.prepend(t)),e.domNode=t})},update(){this.windowElement.style.width=`${this.rootSash.width}px`,this.windowElement.style.height=`${this.rootSash.height}px`;const e=this.rootSash.getAllIds(),t=[];this.windowElement.querySelectorAll("[sash-id]").forEach(i=>{const n=i.getAttribute("sash-id");t.push(n),e.includes(n)||i.remove()}),this.rootSash.walk(i=>{i.children.length>0?t.includes(i.id)?(this.updateMuntin(i),this.onMuntinUpdate(i.domNode,i)):(i.domNode=this.createMuntin(i),this.windowElement.append(i.domNode)):t.includes(i.id)?(this.updatePane(i),this.onPaneUpdate(i.domNode,i)):(i.domNode||(i.domNode=this.createPane(i)),this.windowElement.prepend(i.domNode))})}},ft={muntinSize:4,createMuntin(e){const t=document.createElement("bw-muntin"),i=e.leftChild,n=e.topChild;return i?(t.style.width=`${this.muntinSize}px`,t.style.height=`${e.height}px`,t.style.top=`${e.top}px`,t.style.left=`${e.left+i.width-this.muntinSize/2}px`,t.setAttribute("vertical","")):n&&(t.style.width=`${e.width}px`,t.style.height=`${this.muntinSize}px`,t.style.top=`${e.top+n.height-this.muntinSize/2}px`,t.style.left=`${e.left}px`,t.setAttribute("horizontal","")),t.setAttribute("sash-id",e.id),e.store.resizable===!1&&t.setAttribute("resizable","false"),t},onMuntinCreate(e,t){},updateMuntin(e){const t=e.domNode,i=e.leftChild,n=e.topChild;i?(t.style.height=`${e.height}px`,t.style.top=`${e.top}px`,t.style.left=`${e.left+i.width-this.muntinSize/2}px`):n&&(t.style.width=`${e.width}px`,t.style.top=`${e.top+n.height-this.muntinSize/2}px`,t.style.left=`${e.left}px`)},onMuntinUpdate(e,t){}},wt={fitContainer:!1,fit(){this.rootSash.width=this.containerElement.clientWidth,this.rootSash.height=this.containerElement.clientHeight,this.update()},enableFitContainer(){new ResizeObserver(e=>{for(const t of e)t.target===this.containerElement&&this.fitContainer&&this.fit()}).observe(this.containerElement)}},mt={activeMuntinSash:null,isResizeStarted:!1,isDropStarted:!1,lastX:0,lastY:0,applyResizeStyles(){this.activeMuntinSash.domNode.hasAttribute("vertical")?document.body.classList.add("body--bw-resize-x"):this.activeMuntinSash.domNode.hasAttribute("horizontal")&&document.body.classList.add("body--bw-resize-y")},revertResizeStyles(){document.body.classList.remove("body--bw-resize-x"),document.body.classList.remove("body--bw-resize-y")},enableResize(){document.addEventListener("mousedown",e=>{if(e.target.tagName!=="BW-MUNTIN"||e.target.getAttribute("resizable")==="false")return;const t=e.target.getAttribute("sash-id");this.activeMuntinSash=this.rootSash.getById(t),this.activeMuntinSash&&(this.isResizeStarted=!0,this.lastX=e.pageX,this.lastY=e.pageY,this.applyResizeStyles())}),document.addEventListener("mousemove",e=>{if(!this.isResizeStarted||!this.activeMuntinSash)return;const[t,i,n,s]=this.activeMuntinSash.getChildren(),o=this.activeMuntinSash.isLeftRightSplit(),h=this.activeMuntinSash.isTopBottomSplit();if(o&&s&&i){const r=e.pageX-this.lastX,d=s.width+r,l=i.width-r;if(r>0&&l<=i.calcMinWidth()||r<0&&d<=s.calcMinWidth())return;s.width=d,i.width=l,i.left=i.left+r,this.update(),this.lastX=e.pageX}else if(h&&t&&n){const r=e.pageY-this.lastY,d=t.height+r,l=n.height-r;if(r>0&&l<=n.calcMinHeight()||r<0&&d<=t.calcMinHeight())return;t.height=d,n.height=l,n.top=n.top+r,this.update(),this.lastY=e.pageY}}),document.addEventListener("mouseup",()=>{this.isResizeStarted=!1,this.activeMuntinSash=null,this.revertResizeStyles()})}},bt={activeDropPaneEl:null,onPaneDrop(e,t){},enableDrop(){this.windowElement.addEventListener("dragover",e=>{e.preventDefault();const t=e.target.matches("bw-pane")?e.target:e.target.closest("bw-pane");if(!t||(t!==this.activeDropPaneEl&&(this.activeDropPaneEl&&this.activeDropPaneEl.removeAttribute("drop-area"),this.activeDropPaneEl=t),t.getAttribute("can-drop")==="false"))return;const i=et(t,e);t.setAttribute("drop-area",i)}),this.windowElement.addEventListener("dragleave",e=>{e.currentTarget.contains(e.relatedTarget)&&e.currentTarget!==e.relatedTarget||this.activeDropPaneEl&&(this.activeDropPaneEl.removeAttribute("drop-area"),this.activeDropPaneEl=null)}),this.windowElement.addEventListener("drop",e=>{if(!this.activeDropPaneEl||this.activeDropPaneEl.getAttribute("can-drop")==="false")return;const t=this.activeDropPaneEl.getAttribute("sash-id"),i=this.rootSash.getById(t);this.onPaneDrop(e,i),typeof i.store.onDrop=="function"&&i.store.onDrop(e,i),this.activeDropPaneEl.removeAttribute("drop-area"),this.activeDropPaneEl=null})}},yt=!1;class O{constructor(t){E(this,"windowElement",null),E(this,"containerElement",null),E(this,"debug",yt);let i=null;t instanceof ot?(i=t,this.rootSash=t):(i=new st(t),this.rootSash=i.buildSashTree()),this.fitContainer=i.fitContainer}frame(t){this.containerElement=t,this.windowElement=this.createWindow(),this.glaze(),this.containerElement.append(this.windowElement)}enableFeatures(){this.enableResize(),this.enableDrop(),this.fitContainer&&this.enableFitContainer()}mount(t){this.frame(t),this.enableFeatures()}static assemble(...t){t.forEach(i=>{Y(this.prototype,i)})}}O.assemble(gt,ft,pt,wt,bt,mt);const Et={label:"",className:"bw-glass-action--close",onClick:(e,t)=>{const i=D(e.target);t.removePane(i)}},vt={label:"",className:"bw-glass-action--minimize",onClick:(e,t)=>{const i=t.sillElement;if(!i)throw new Error("[bwin] Sill element not found when minimizing");const n=z('<button class="bw-minimized-glass" />');i.append(n);const s=e.target.closest("bw-pane"),o=e.target.closest("bw-glass"),h=s.getAttribute("sash-id"),r=s.getAttribute("position");n.bwGlassElement=o,n.bwOriginalPosition=r,n.bwOriginalBoundingRect=M(s),n.bwOriginalSashId=h,t.removePane(h)}},Nt={label:"",className:"bw-glass-action--maximize",onClick:e=>{const t=e.target.closest("bw-pane");t.hasAttribute("maximized")?(t.removeAttribute("maximized"),t.style.left=`${t.bwOriginalBoundingRect.left}px`,t.style.top=`${t.bwOriginalBoundingRect.top}px`,t.style.width=`${t.bwOriginalBoundingRect.width}px`,t.style.height=`${t.bwOriginalBoundingRect.height}px`):(t.setAttribute("maximized",""),t.bwOriginalBoundingRect=M(t),t.style.left="0",t.style.top="0",t.style.width="100%",t.style.height="100%")}};function St(e,t){const i=e.left+e.width,n=e.top+e.height,s=t.left+t.width,o=t.top+t.height;if(e.left>=s||t.left>=i||e.top>=o||t.top>=n)return null;const h=Math.max(e.left,t.left),r=Math.max(e.top,t.top),d=Math.min(i,s),l=Math.min(n,o);return{left:h,top:r,width:d-h,height:l-r}}const B=[vt,Nt,Et],zt={enableActions(){this.handleMinimizedGlassClick(),this.observeActionButtons()},restoreGlass(e){const t=e.bwOriginalBoundingRect;let i=0,n=null;if(this.windowElement.querySelectorAll("bw-pane").forEach(s=>{const o=M(s),h=St(t,o);if(h){const r=h.width*h.height;r>i&&(i=r,n=s)}}),n){const s=e.bwOriginalPosition,o=M(n),h=n.getAttribute("sash-id"),r=this.rootSash.getById(h);let d=0;if(s===a.Left||s===a.Right)d=o.width-t.width<r.minWidth?o.width/2:t.width;else if(s===a.Top||s===a.Bottom)d=o.height-t.height<r.minHeight?o.height/2:t.height;else throw new Error("[bwin] Invalid position when restoring glass");const l=e.bwOriginalSashId;this.addPane(n.getAttribute("sash-id"),{id:l,position:s,size:d}).domNode.append(e.bwGlassElement)}},handleMinimizedGlassClick(){this.sillElement.addEventListener("click",e=>{if(!e.target.matches(".bw-minimized-glass"))return;const t=e.target;this.restoreGlass(t),t.remove()})},updateDisabledStateOfActionButtons(){this.updateDisabledState(".bw-glass-action--close"),this.updateDisabledState(".bw-glass-action--minimize"),this.updateDisabledState(".bw-glass-action--maximize")},updateDisabledState(e){if(this.windowElement.querySelectorAll("bw-pane").length===1){const t=this.windowElement.querySelector(e);t&&t.setAttribute("disabled","")}else this.windowElement.querySelectorAll(e).forEach(t=>{t.removeAttribute("disabled")})},observeActionButtons(){this.updateDisabledStateOfActionButtons(),new MutationObserver(e=>{e.forEach(t=>{t.type==="childList"&&this.updateDisabledStateOfActionButtons()})}).observe(this.windowElement,{childList:!0})}},A={title:null,content:null,tabs:[],actions:void 0,draggable:!0};class G{constructor({title:t=A.title,content:i=A.content,tabs:n=A.tabs,actions:s=A.actions,draggable:o=A.draggable,sash:h,binaryWindow:r}){E(this,"domNode"),this.title=t,this.content=i,this.tabs=n,this.actions=s,this.sash=h,this.draggable=o,this.binaryWindow=r,this.build()}build(){const t=document.createElement("bw-glass-header");if(Array.isArray(this.tabs)&&this.tabs.length>0)t.append(this.createTabs());else if(this.title){const s=document.createElement("bw-glass-title");s.append(z(this.title)),t.append(s)}t.setAttribute("can-drag",this.draggable),t.append(this.createActions());const i=document.createElement("bw-glass-content"),n=z(this.content);n&&i.append(n),this.domNode=document.createElement("bw-glass"),this.domNode.append(t,i)}createTabs(){const t=document.createElement("bw-glass-tab-container");for(const i of this.tabs){const n=(i==null?void 0:i.label)??i,s=z(`<button class="bw-glass-tab">${n}</button>`);t.append(s)}return t}createActions(){const t=document.createElement("bw-glass-action-container"),i=this.actions===void 0?B:Array.isArray(this.actions)?this.actions:[];for(const n of i){const s=(n==null?void 0:n.label)??n,o=n.className?`bw-glass-action ${n.className}`:"bw-glass-action",h=z(`<button class="${o}">${s}</button>`);typeof n.onClick=="function"&&h.addEventListener("click",r=>{n.onClick(r,this.binaryWindow)}),t.append(h)}return t}get contentElement(){return this.domNode.querySelector("bw-glass-content")}get headerElement(){return this.domNode.querySelector("bw-glass-header")}}const Ct={activeDragGlassEl:null,activeDragGlassPaneCanDrop:!1,onPaneDrop(e,t){if(!this.activeDragGlassEl)return;const i=this.activeDropPaneEl.getAttribute("drop-area");if(i==="center"){const n=this.activeDragGlassEl.closest("bw-pane");this.swapPanes(n,this.activeDropPaneEl);return}else{const n=D(this.activeDragGlassEl);this.removePane(n),this.addPane(t.id,{position:i,id:n}).domNode.append(this.activeDragGlassEl)}},enableDrag(){document.addEventListener("mousedown",e=>{if(e.button!==0||!e.target.matches("bw-glass-header"))return;if(e.target.getAttribute("can-drag")==="false"){e.preventDefault();return}const t=e.target.closest("bw-glass");t.setAttribute("draggable",!0),this.activeDragGlassEl=t}),document.addEventListener("mouseup",()=>{this.activeDragGlassEl&&(this.activeDragGlassEl.removeAttribute("draggable"),this.activeDragGlassEl=null)}),this.windowElement.addEventListener("dragstart",e=>{if(!(e.target instanceof HTMLElement)||!e.target.matches("bw-glass")||!this.activeDragGlassEl)return;e.dataTransfer.effectAllowed="move";const t=this.activeDragGlassEl.closest("bw-pane");this.activeDragGlassPaneCanDrop=t.getAttribute("can-drop")!=="false",t.setAttribute("can-drop",!1)}),this.windowElement.addEventListener("dragend",()=>{this.activeDragGlassEl&&(this.activeDragGlassEl.removeAttribute("draggable"),this.activeDragGlassEl.closest("bw-pane").setAttribute("can-drop",this.activeDragGlassPaneCanDrop),this.activeDragGlassEl=null)})}},At={trimMuntin(e){e.hasAttribute("vertical")?(e.style.top=`${parseFloat(e.style.top)+this.muntinSize/2}px`,e.style.height=`${parseFloat(e.style.height)-this.muntinSize}px`):e.hasAttribute("horizontal")&&(e.style.left=`${parseFloat(e.style.left)+this.muntinSize/2}px`,e.style.width=`${parseFloat(e.style.width)-this.muntinSize}px`)},onMuntinCreate(e){this.trimMuntin(e)},onMuntinUpdate(e){this.trimMuntin(e)}};class k extends O{constructor(){super(...arguments),E(this,"sillElement",null)}frame(){super.frame(...arguments);const t=z("<bw-sill />");this.windowElement.append(t),this.sillElement=t}enableFeatures(){super.enableFeatures(),this.enableDrag(),this.enableActions()}onPaneCreate(t,i){const n=new G({...i.store,sash:i,binaryWindow:this});t.innerHTML="",t.append(n.domNode),this.debug&&n.contentElement.prepend(`${i.id}`)}onPaneUpdate(){}addPane(t,i){const{position:n,size:s,id:o,...h}=i,r=super.addPane(t,{position:n,size:s,id:o}),d=new G({...h,sash:r,binaryWindow:this});return r.domNode.append(d.domNode),r}}k.assemble(Ct,At,zt);const N=4;function Mt({sash:e}){var c;const t=u.useRef(),i=e.leftChild,n=e.topChild;let s,o,h,r,d,l;return i?(s=N,o=e.height-N,h=e.top+N/2,r=e.left+i.width-N/2,d=!0):n&&(s=e.width-N,o=N,h=e.top+n.height-N/2,r=e.left+N/2,l=!0),u.useEffect(()=>{e.domNode=t.current},[]),u.createElement("bw-muntin",{"sash-id":e.id,style:{width:s,height:o,top:h,left:r},vertical:d,horizontal:l,resizable:((c=e.store)==null?void 0:c.resizable)===!1?"false":"true",ref:t})}function Pt({sash:e,bwin:t}){var c,g,f,b,y;const i=u.useRef(),{left:n,top:s,width:o,height:h,id:r,position:d}=e;u.useEffect(()=>{e.domNode=i.current},[]);const l=((c=e.store)==null?void 0:c.actions)===void 0?B:Array.isArray(e.store.actions)?e.store.actions:[];return u.createElement("bw-pane",{"sash-id":r,position:d,style:{left:n,top:s,width:o,height:h},"can-drop":((g=e.store)==null?void 0:g.droppable)===!1?"false":"true",ref:i},u.createElement("bw-glass",null,u.createElement("bw-glass-header",{"can-drag":((f=e.store)==null?void 0:f.draggable)===!1?"false":"true"},((b=e.store)==null?void 0:b.title)&&u.createElement("bw-glass-title",null,e.store.title),l.length>0&&u.createElement("bw-glass-action-container",null,l.map((p,L)=>{const T=p.className?`bw-glass-action ${p.className}`:"bw-glass-action";return u.createElement("button",{className:T,key:L,onClick:W=>p.onClick(W,t)},p.label)}))),u.createElement("bw-glass-content",null,(y=e.store)==null?void 0:y.content)))}const Dt=u.forwardRef((e,t)=>{const i=u.useRef(),n=u.useRef(),[s,o]=u.useState(),{panes:h,...r}=e,d={...r,children:h},l=new k(d),c=[],g=[];l.rootSash.walk(p=>{p.children.length>0?c.push(p):g.push(p)}),u.useEffect(()=>{const p=i.current;p!=null&&p.parentElement&&(l.windowElement=p,l.containerElement=p.parentElement,l.sillElement=n.current,l.enableFeatures())},[]),u.useImperativeHandle(t,()=>({fit:l.fit.bind(l),removePane:l.removePane.bind(l),addPane:y}),[]);const f=u.createElement("bw-window",{"root-sash-id":l.rootSash.id,style:{width:l.rootSash.width,height:l.rootSash.height},ref:i},g.map(p=>u.createElement(Pt,{key:p.id,sash:p,bwin:l})),c.map(p=>u.createElement(Mt,{key:p.id,sash:p})),u.createElement("bw-sill",{ref:n})),b=u.useMemo(()=>f,[]);function y(p,L){const{content:T,...W}=L,Rt=l.addPane(p,W),$t=document.querySelector(`bw-pane[sash-id="${Rt.id}"] bw-glass-content`);o(Bt=>[...Bt||[],{node:T,container:$t}])}return u.createElement(u.Fragment,null,b,s==null?void 0:s.map(p=>F.createPortal(p.node,p.container)))}),xt="0.3.3";w.BUILTIN_ACTIONS=B,w.Window=Dt,w.version=xt,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
8
+ `.trim(),t}var B={createWindow({theme:e}={}){let t=document.createElement(`bw-window`);return t.style.width=`${this.rootSash.width}px`,t.style.height=`${this.rootSash.height}px`,t.setAttribute(`root-sash-id`,this.rootSash.id),e&&t.setAttribute(`theme`,e),t},glaze(){this.rootSash.walk(e=>{let t=null;e.children.length>0?(t=this.createMuntin(e),this.onMuntinCreate(t,e),this.windowElement.append(t)):(t=this.createPane(e),this.onPaneCreate(t,e),this.windowElement.prepend(t)),e.domNode=t})},update(){this.windowElement.style.width=`${this.rootSash.width}px`,this.windowElement.style.height=`${this.rootSash.height}px`;let e=this.rootSash.getAllIds(),t=[];this.windowElement.querySelectorAll(`[sash-id]`).forEach(n=>{let r=n.getAttribute(`sash-id`);t.push(r),e.includes(r)||n.remove()}),this.rootSash.walk(e=>{e.children.length>0?t.includes(e.id)?(this.updateMuntin(e),this.onMuntinUpdate(e.domNode,e)):(e.domNode=this.createMuntin(e),this.windowElement.append(e.domNode)):t.includes(e.id)?(this.updatePane(e),this.onPaneUpdate(e.domNode,e)):(e.domNode||=this.createPane(e),this.windowElement.prepend(e.domNode))})}},V={muntinSize:4,createMuntin(e){let t=document.createElement(`bw-muntin`),n=e.leftChild,r=e.topChild;return n?(t.style.width=`${this.muntinSize}px`,t.style.height=`${e.height}px`,t.style.top=`${e.top}px`,t.style.left=`${e.left+n.width-this.muntinSize/2}px`,t.setAttribute(`vertical`,``)):r&&(t.style.width=`${e.width}px`,t.style.height=`${this.muntinSize}px`,t.style.top=`${e.top+r.height-this.muntinSize/2}px`,t.style.left=`${e.left}px`,t.setAttribute(`horizontal`,``)),t.setAttribute(`sash-id`,e.id),e.store.resizable===!1&&t.setAttribute(`resizable`,`false`),t},onMuntinCreate(e,t){},updateMuntin(e){let t=e.domNode,n=e.leftChild,r=e.topChild;n?(t.style.height=`${e.height}px`,t.style.top=`${e.top}px`,t.style.left=`${e.left+n.width-this.muntinSize/2}px`):r&&(t.style.width=`${e.width}px`,t.style.top=`${e.top+r.height-this.muntinSize/2}px`,t.style.left=`${e.left}px`)},onMuntinUpdate(e,t){}},H={fitContainer:!1,fit(){this.rootSash.width=this.containerElement.clientWidth,this.rootSash.height=this.containerElement.clientHeight,this.update()},enableFitContainer(){new ResizeObserver(e=>{requestAnimationFrame(()=>{for(let t of e)t.target===this.containerElement&&this.fitContainer&&this.fit()})}).observe(this.containerElement)}},U={activeMuntinSash:null,isResizeStarted:!1,isDropStarted:!1,lastX:0,lastY:0,applyResizeStyles(){this.activeMuntinSash.domNode.hasAttribute(`vertical`)?document.body.classList.add(`body--bw-resize-x`):this.activeMuntinSash.domNode.hasAttribute(`horizontal`)&&document.body.classList.add(`body--bw-resize-y`)},revertResizeStyles(){document.body.classList.remove(`body--bw-resize-x`),document.body.classList.remove(`body--bw-resize-y`)},enableResize(){document.addEventListener(`mousedown`,e=>{if(e.target.tagName!==`BW-MUNTIN`||e.target.getAttribute(`resizable`)===`false`)return;let t=e.target.getAttribute(`sash-id`);this.activeMuntinSash=this.rootSash.getById(t),this.activeMuntinSash&&(this.isResizeStarted=!0,this.lastX=e.pageX,this.lastY=e.pageY,this.applyResizeStyles())}),document.addEventListener(`mousemove`,e=>{if(!this.isResizeStarted||!this.activeMuntinSash)return;let[t,n,r,i]=this.activeMuntinSash.getChildren(),a=this.activeMuntinSash.isLeftRightSplit(),o=this.activeMuntinSash.isTopBottomSplit();if(a&&i&&n){let t=e.pageX-this.lastX,r=i.width+t,a=n.width-t;if(t>0&&a<=n.calcMinWidth()||t<0&&r<=i.calcMinWidth())return;i.width=r,n.width=a,n.left+=t,this.update(),this.lastX=e.pageX}else if(o&&t&&r){let n=e.pageY-this.lastY,i=t.height+n,a=r.height-n;if(n>0&&a<=r.calcMinHeight()||n<0&&i<=t.calcMinHeight())return;t.height=i,r.height=a,r.top+=n,this.update(),this.lastY=e.pageY}}),document.addEventListener(`mouseup`,()=>{this.isResizeStarted=!1,this.activeMuntinSash=null,this.revertResizeStyles()})}},ae={activeDropPaneEl:null,onPaneDrop(e,t){},enableDrop(){this.windowElement.addEventListener(`dragover`,e=>{e.preventDefault();let t=e.target.matches(`bw-pane`)?e.target:e.target.closest(`bw-pane`);if(!t||(t!==this.activeDropPaneEl&&(this.activeDropPaneEl&&this.activeDropPaneEl.removeAttribute(`drop-area`),this.activeDropPaneEl=t),t.getAttribute(`can-drop`)===`false`))return;let n=C(t,e);t.setAttribute(`drop-area`,n)}),this.windowElement.addEventListener(`dragleave`,e=>{e.currentTarget.contains(e.relatedTarget)&&e.currentTarget!==e.relatedTarget||(this.activeDropPaneEl&&=(this.activeDropPaneEl.removeAttribute(`drop-area`),null))}),this.windowElement.addEventListener(`drop`,e=>{if(!this.activeDropPaneEl||this.activeDropPaneEl.getAttribute(`can-drop`)===`false`)return;let t=this.activeDropPaneEl.getAttribute(`sash-id`),n=this.rootSash.getById(t);this.onPaneDrop(e,n),typeof n.store.onDrop==`function`&&n.store.onDrop(e,n),this.activeDropPaneEl.removeAttribute(`drop-area`),this.activeDropPaneEl=null})}},W=!1,G=class{windowElement=null;containerElement=null;debug=W;constructor(e){let t=null;e instanceof k?(t=e,this.rootSash=e):(t=new ie(e),this.rootSash=t.buildSashTree({resizeStrategy:t.resizeStrategy})),this.fitContainer=t.fitContainer,this.theme=t.theme}frame(e){this.containerElement=e,this.windowElement=this.createWindow({theme:this.theme}),this.glaze(),this.containerElement.append(this.windowElement)}enableFeatures(){this.enableResize(),this.enableDrop(),this.fitContainer&&this.enableFitContainer()}mount(e){this.frame(e),this.enableFeatures()}static assemble(...e){e.forEach(e=>{g(this.prototype,e)})}};G.assemble(B,V,R,H,ae,U);var K={label:``,className:`bw-glass-action--close`,onClick:(e,t)=>{let n=L(e.target);t.removePane(n)}},q={label:``,className:`bw-glass-action--minimize`,onClick:(e,t)=>{let n=t.sillElement;if(!n)throw Error(`[bwin] Sill element not found when minimizing`);let r=v(`<button class="bw-minimized-glass" />`);n.append(r);let i=e.target.closest(`bw-pane`),a=e.target.closest(`bw-glass`),o=i.getAttribute(`sash-id`),s=i.getAttribute(`position`);r.bwGlassElement=a,r.bwOriginalPosition=s,r.bwOriginalBoundingRect=y(i),r.bwOriginalSashId=o,t.removePane(o)}},J={label:``,className:`bw-glass-action--maximize`,onClick:e=>{let t=e.target.closest(`bw-pane`);t.hasAttribute(`maximized`)?(t.removeAttribute(`maximized`),t.style.left=`${t.bwOriginalBoundingRect.left}px`,t.style.top=`${t.bwOriginalBoundingRect.top}px`,t.style.width=`${t.bwOriginalBoundingRect.width}px`,t.style.height=`${t.bwOriginalBoundingRect.height}px`):(t.setAttribute(`maximized`,``),t.bwOriginalBoundingRect=y(t),t.style.left=`0`,t.style.top=`0`,t.style.width=`100%`,t.style.height=`100%`)}};function oe(e,t){let n=e.left+e.width,r=e.top+e.height,i=t.left+t.width,a=t.top+t.height;if(e.left>=i||t.left>=n||e.top>=a||t.top>=r)return null;let o=Math.max(e.left,t.left),s=Math.max(e.top,t.top),c=Math.min(n,i),l=Math.min(r,a);return{left:o,top:s,width:c-o,height:l-s}}var Y=[q,J,K],se={enableActions(){this.handleMinimizedGlassClick(),this.observeActionButtons()},restoreGlass(e){let t=e.bwOriginalBoundingRect,n=0,r=null;if(this.windowElement.querySelectorAll(`bw-pane`).forEach(e=>{let i=oe(t,y(e));if(i){let t=i.width*i.height;t>n&&(n=t,r=e)}}),r){let n=e.bwOriginalPosition,i=y(r),a=r.getAttribute(`sash-id`),o=this.rootSash.getById(a),s=0;if(n===b.Left||n===b.Right)s=i.width-t.width<o.minWidth?i.width/2:t.width;else if(n===b.Top||n===b.Bottom)s=i.height-t.height<o.minHeight?i.height/2:t.height;else throw Error(`[bwin] Invalid position when restoring glass`);let c=e.bwOriginalSashId;this.addPane(r.getAttribute(`sash-id`),{id:c,position:n,size:s}).domNode.append(e.bwGlassElement)}},handleMinimizedGlassClick(){this.sillElement.addEventListener(`click`,e=>{if(!e.target.matches(`.bw-minimized-glass`))return;let t=e.target;this.restoreGlass(t),t.remove()})},updateDisabledStateOfActionButtons(){this.updateDisabledState(`.bw-glass-action--close`),this.updateDisabledState(`.bw-glass-action--minimize`),this.updateDisabledState(`.bw-glass-action--maximize`)},updateDisabledState(e){if(this.windowElement.querySelectorAll(`bw-pane`).length===1){let t=this.windowElement.querySelector(e);t&&t.setAttribute(`disabled`,``)}else this.windowElement.querySelectorAll(e).forEach(e=>{e.removeAttribute(`disabled`)})},getMinimizedGlassElementBySashId(e){let t=this.windowElement.querySelectorAll(`.bw-minimized-glass`);return Array.from(t).find(t=>t.bwOriginalSashId===e)},observeActionButtons(){this.updateDisabledStateOfActionButtons(),new MutationObserver(e=>{e.forEach(e=>{e.type===`childList`&&this.updateDisabledStateOfActionButtons()})}).observe(this.windowElement,{childList:!0})}},X={title:null,content:null,tabs:[],actions:void 0,draggable:!0},Z=class{domNode;constructor({title:e=X.title,content:t=X.content,tabs:n=X.tabs,actions:r=X.actions,draggable:i=X.draggable,sash:a,binaryWindow:o}){this.title=e,this.content=t,this.tabs=n,this.actions=r,this.sash=a,this.draggable=i,this.binaryWindow=o,this.build()}build(){let e=document.createElement(`bw-glass-header`);if(Array.isArray(this.tabs)&&this.tabs.length>0)e.append(this.createTabs());else if(this.title){let t=document.createElement(`bw-glass-title`);t.append(v(this.title)),e.append(t)}e.setAttribute(`can-drag`,this.draggable),e.append(this.createActions());let t=document.createElement(`bw-glass-content`),n=v(this.content);n&&t.append(n),this.domNode=document.createElement(`bw-glass`),this.domNode.append(e,t)}createTabs(){let e=document.createElement(`bw-glass-tab-container`);for(let t of this.tabs){let n=v(`<button class="bw-glass-tab">${t?.label??t}</button>`);e.append(n)}return e}createActions(){let e=document.createElement(`bw-glass-action-container`),t=this.actions===void 0?Y:Array.isArray(this.actions)?this.actions:[];for(let n of t){let t=n?.label??n,r=v(`<button class="${n.className?`bw-glass-action ${n.className}`:`bw-glass-action`}">${t}</button>`);typeof n.onClick==`function`&&r.addEventListener(`click`,e=>{n.onClick(e,this.binaryWindow)}),e.append(r)}return e}get contentElement(){return this.domNode.querySelector(`bw-glass-content`)}get headerElement(){return this.domNode.querySelector(`bw-glass-header`)}},ce={activeDragGlassEl:null,activeDragGlassPaneCanDrop:!1,onPaneDrop(e,t){if(!this.activeDragGlassEl)return;let n=this.activeDropPaneEl.getAttribute(`drop-area`);if(n===`center`){let e=this.activeDragGlassEl.closest(`bw-pane`);this.swapPanes(e,this.activeDropPaneEl);return}else{let e=L(this.activeDragGlassEl);this.removePane(e),this.addPane(t.id,{position:n,id:e}).domNode.append(this.activeDragGlassEl)}},enableDrag(){document.addEventListener(`mousedown`,e=>{if(e.button!==0||!e.target.matches(`bw-glass-header`))return;if(e.target.getAttribute(`can-drag`)===`false`){e.preventDefault();return}let t=e.target.closest(`bw-glass`);t.setAttribute(`draggable`,!0),this.activeDragGlassEl=t}),document.addEventListener(`mouseup`,()=>{this.activeDragGlassEl&&=(this.activeDragGlassEl.removeAttribute(`draggable`),null)}),this.windowElement.addEventListener(`dragstart`,e=>{if(!(e.target instanceof HTMLElement)||!e.target.matches(`bw-glass`)||!this.activeDragGlassEl)return;e.dataTransfer.effectAllowed=`move`;let t=this.activeDragGlassEl.closest(`bw-pane`);this.activeDragGlassPaneCanDrop=t.getAttribute(`can-drop`)!==`false`,t.setAttribute(`can-drop`,!1)}),this.windowElement.addEventListener(`dragend`,()=>{this.activeDragGlassEl&&=(this.activeDragGlassEl.removeAttribute(`draggable`),this.activeDragGlassEl.closest(`bw-pane`).setAttribute(`can-drop`,this.activeDragGlassPaneCanDrop),null)})}},le={trimMuntin(e){e.hasAttribute(`vertical`)?(e.style.top=`${parseFloat(e.style.top)+this.muntinSize/2}px`,e.style.height=`${parseFloat(e.style.height)-this.muntinSize}px`):e.hasAttribute(`horizontal`)&&(e.style.left=`${parseFloat(e.style.left)+this.muntinSize/2}px`,e.style.width=`${parseFloat(e.style.width)-this.muntinSize}px`)},onMuntinCreate(e){this.trimMuntin(e)},onMuntinUpdate(e){this.trimMuntin(e)}},Q=class extends G{sillElement=null;frame(){super.frame(...arguments);let e=v(`<bw-sill />`);this.windowElement.append(e),this.sillElement=e}enableFeatures(){super.enableFeatures(),this.enableDrag(),this.enableActions()}onPaneCreate(e,t){let n=new Z({...t.store,sash:t,binaryWindow:this});e.innerHTML=``,e.append(n.domNode),this.debug&&n.contentElement.prepend(`${t.id}`)}onPaneUpdate(){}addPane(e,t){let{position:n,size:r,id:i,...a}=t,o=super.addPane(e,{position:n,size:r,id:i}),s=new Z({...a,sash:o,binaryWindow:this});return o.domNode.append(s.domNode),o}setTheme(e){if(!e){this.theme=``,this.windowElement.removeAttribute(`theme`);return}this.theme=e,this.windowElement.setAttribute(`theme`,e)}removePane(e){if(this.windowElement.querySelector(`[sash-id="${e}"]`)){super.removePane(e);return}let t=this.getMinimizedGlassElementBySashId(e);t&&t.remove()}};Q.assemble(ce,le,se);var $=4;function ue({sash:e}){let n=(0,t.useRef)(),r=e.leftChild,i=e.topChild,a,o,s,c,l,u;return r?(a=$,o=e.height-$,s=e.top+$/2,c=e.left+r.width-$/2,l=!0):i&&(a=e.width-$,o=$,s=e.top+i.height-$/2,c=e.left+$/2,u=!0),(0,t.useEffect)(()=>{e.domNode=n.current},[]),t.default.createElement(`bw-muntin`,{"sash-id":e.id,style:{width:a,height:o,top:s,left:c},vertical:l,horizontal:u,resizable:e.store?.resizable===!1?`false`:`true`,ref:n})}function de({sash:e,bwin:n}){let r=(0,t.useRef)(),{left:i,top:a,width:o,height:s,id:c,position:l}=e;(0,t.useEffect)(()=>{e.domNode=r.current},[]);let u=e.store?.actions===void 0?Y:Array.isArray(e.store.actions)?e.store.actions:[];return t.default.createElement(`bw-pane`,{"sash-id":c,position:l,style:{left:i,top:a,width:o,height:s},"can-drop":e.store?.droppable===!1?`false`:`true`,ref:r},t.default.createElement(`bw-glass`,null,t.default.createElement(`bw-glass-header`,{"can-drag":e.store?.draggable===!1?`false`:`true`},e.store?.title&&t.default.createElement(`bw-glass-title`,null,e.store.title),u.length>0&&t.default.createElement(`bw-glass-action-container`,null,u.map((e,r)=>{let i=e.className?`bw-glass-action ${e.className}`:`bw-glass-action`;return t.default.createElement(`button`,{className:i,key:r,onClick:t=>e.onClick(t,n)},e.label)}))),t.default.createElement(`bw-glass-content`,null,e.store?.content)))}var fe=(0,t.forwardRef)((e,r)=>{let i=(0,t.useRef)(),a=(0,t.useRef)(),[o,s]=(0,t.useState)(),{panes:c,...l}=e,u=new Q({...l,children:c}),d=[],f=[];u.rootSash.walk(e=>{e.children.length>0?d.push(e):f.push(e)}),(0,t.useEffect)(()=>{let e=i.current;e?.parentElement&&(u.windowElement=e,u.containerElement=e.parentElement,u.sillElement=a.current,u.enableFeatures())},[]),(0,t.useImperativeHandle)(r,()=>({fit:u.fit.bind(u),removePane:u.removePane.bind(u),addPane:h}),[]);let p=t.default.createElement(`bw-window`,{"root-sash-id":u.rootSash.id,style:{width:u.rootSash.width,height:u.rootSash.height},ref:i},f.map(e=>t.default.createElement(de,{key:e.id,sash:e,bwin:u})),d.map(e=>t.default.createElement(ue,{key:e.id,sash:e})),t.default.createElement(`bw-sill`,{ref:a})),m=(0,t.useMemo)(()=>p,[]);function h(e,t){let{content:n,...r}=t,i=u.addPane(e,r),a=document.querySelector(`bw-pane[sash-id="${i.id}"] bw-glass-content`);s(e=>[...e||[],{node:n,container:a}])}return t.default.createElement(t.default.Fragment,null,m,o?.map(e=>(0,n.createPortal)(e.node,e.container)))});e.BUILTIN_ACTIONS=Y,e.Window=fe,e.version=`0.3.4`});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-bwin",
3
3
  "description": "A tiling window manager in React based on Binary Window library",
4
- "version": "0.3.3",
4
+ "version": "0.3.4",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
@@ -32,25 +32,26 @@
32
32
  },
33
33
  "./react-bwin.css": "./dist/react-bwin.css"
34
34
  },
35
- "scripts": {
36
- "dev": "vite",
37
- "build": "tsc -b && vite build"
38
- },
39
35
  "peerDependencies": {
40
36
  "react": ">=16.8.0",
41
37
  "react-dom": ">=16.8.0"
42
38
  },
43
39
  "devDependencies": {
44
- "@types/node": "^22.10.1",
40
+ "@types/node": "^24.12.4",
45
41
  "@types/react": "^16.14.62",
46
42
  "@types/react-dom": "^16.9.24",
47
- "@vitejs/plugin-react": "^4.3.4",
48
- "bwin": "0.2.5",
43
+ "@vitejs/plugin-react": "^6.0.2",
44
+ "bwin": "0.3.3",
45
+ "picocolors": "^1.1.1",
49
46
  "prettier": "^3.4.1",
50
47
  "react": "^16.14.0",
51
48
  "react-dom": "^16.14.0",
52
49
  "typescript": "^5.6.2",
53
- "vite": "^6.0.1",
50
+ "vite": "^8.0.13",
54
51
  "zustand": "^4.5.5"
52
+ },
53
+ "scripts": {
54
+ "dev": "vite",
55
+ "build": "tsc -b && vite build"
55
56
  }
56
- }
57
+ }