react-zeugma 6.7.0 → 6.7.1

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/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { U as UseZeugmaOptions, Z as ZeugmaController, a as ZeugmaProps, S as SplitDirection, T as TreeNode, b as SplitNode, c as TabDetails } from './types-oKDEW-r-.cjs';
2
- export { D as DragOverlayActiveItem, P as PaneNode, d as ZeugmaClassNames } from './types-oKDEW-r-.cjs';
1
+ import { U as UseZeugmaOptions, Z as ZeugmaController, a as ZeugmaProps, S as SplitDirection, T as TreeNode, b as SplitNode, R as RenderTabProps, c as TabDetails } from './types-RzetLsAH.cjs';
2
+ export { D as DragOverlayActiveItem, P as PaneNode, d as ZeugmaClassNames } from './types-RzetLsAH.cjs';
3
3
  import React from 'react';
4
4
 
5
5
  declare function useZeugma(options: UseZeugmaOptions): ZeugmaController;
@@ -57,7 +57,7 @@ interface BaseLeafRenderProps {
57
57
  }
58
58
  interface PaneRenderProps extends BaseLeafRenderProps {
59
59
  /** The array of tab IDs in this pane. */
60
- tabs: string[];
60
+ tabIds: string[];
61
61
  /** The currently active tab ID. */
62
62
  activeTabId: string;
63
63
  /** Selects a specific tab to make it active. */
@@ -100,7 +100,7 @@ declare const Tab: React.FC<TabProps>;
100
100
 
101
101
  interface TabsProps {
102
102
  /** The list of tab IDs in this pane. */
103
- tabs?: string[];
103
+ tabIds?: string[];
104
104
  /** The currently active tab ID. */
105
105
  activeTabId?: string;
106
106
  /** Whether dragging is locked on these tabs. */
@@ -112,15 +112,7 @@ interface TabsProps {
112
112
  /** Callback when a tab is closed/removed. */
113
113
  removeTab?: (id: string) => void;
114
114
  /** Render function for each individual tab content. */
115
- renderTab: (props: {
116
- tabId: string;
117
- activeTabId: string;
118
- isDragging: boolean;
119
- isOver: boolean;
120
- metadata?: Record<string, unknown>;
121
- onSelect: () => void;
122
- onRemove: () => void;
123
- }) => React.ReactNode;
115
+ renderTab: (props: RenderTabProps) => React.ReactNode;
124
116
  /** Custom CSS classes for Tabs container and tab wrappers. */
125
117
  classNames?: {
126
118
  container?: string;
@@ -177,4 +169,4 @@ declare const Pane: React.FC<PaneProps> & {
177
169
  Controls: typeof PaneControls;
178
170
  };
179
171
 
180
- export { type DragHandleProps, Pane, type PaneControlsProps, type PaneProps, type PaneRenderProps, PaneTree, SplitDirection, SplitNode, TabDetails, type TabsProps, TreeNode, UseZeugmaOptions, Zeugma, ZeugmaController, ZeugmaProps, usePaneContext, useResizer, useZeugma, useZeugmaContext };
172
+ export { type DragHandleProps, Pane, type PaneControlsProps, type PaneProps, type PaneRenderProps, PaneTree, RenderTabProps, SplitDirection, SplitNode, TabDetails, type TabsProps, TreeNode, UseZeugmaOptions, Zeugma, ZeugmaController, ZeugmaProps, usePaneContext, useResizer, useZeugma, useZeugmaContext };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { U as UseZeugmaOptions, Z as ZeugmaController, a as ZeugmaProps, S as SplitDirection, T as TreeNode, b as SplitNode, c as TabDetails } from './types-oKDEW-r-.js';
2
- export { D as DragOverlayActiveItem, P as PaneNode, d as ZeugmaClassNames } from './types-oKDEW-r-.js';
1
+ import { U as UseZeugmaOptions, Z as ZeugmaController, a as ZeugmaProps, S as SplitDirection, T as TreeNode, b as SplitNode, R as RenderTabProps, c as TabDetails } from './types-RzetLsAH.js';
2
+ export { D as DragOverlayActiveItem, P as PaneNode, d as ZeugmaClassNames } from './types-RzetLsAH.js';
3
3
  import React from 'react';
4
4
 
5
5
  declare function useZeugma(options: UseZeugmaOptions): ZeugmaController;
@@ -57,7 +57,7 @@ interface BaseLeafRenderProps {
57
57
  }
58
58
  interface PaneRenderProps extends BaseLeafRenderProps {
59
59
  /** The array of tab IDs in this pane. */
60
- tabs: string[];
60
+ tabIds: string[];
61
61
  /** The currently active tab ID. */
62
62
  activeTabId: string;
63
63
  /** Selects a specific tab to make it active. */
@@ -100,7 +100,7 @@ declare const Tab: React.FC<TabProps>;
100
100
 
101
101
  interface TabsProps {
102
102
  /** The list of tab IDs in this pane. */
103
- tabs?: string[];
103
+ tabIds?: string[];
104
104
  /** The currently active tab ID. */
105
105
  activeTabId?: string;
106
106
  /** Whether dragging is locked on these tabs. */
@@ -112,15 +112,7 @@ interface TabsProps {
112
112
  /** Callback when a tab is closed/removed. */
113
113
  removeTab?: (id: string) => void;
114
114
  /** Render function for each individual tab content. */
115
- renderTab: (props: {
116
- tabId: string;
117
- activeTabId: string;
118
- isDragging: boolean;
119
- isOver: boolean;
120
- metadata?: Record<string, unknown>;
121
- onSelect: () => void;
122
- onRemove: () => void;
123
- }) => React.ReactNode;
115
+ renderTab: (props: RenderTabProps) => React.ReactNode;
124
116
  /** Custom CSS classes for Tabs container and tab wrappers. */
125
117
  classNames?: {
126
118
  container?: string;
@@ -177,4 +169,4 @@ declare const Pane: React.FC<PaneProps> & {
177
169
  Controls: typeof PaneControls;
178
170
  };
179
171
 
180
- export { type DragHandleProps, Pane, type PaneControlsProps, type PaneProps, type PaneRenderProps, PaneTree, SplitDirection, SplitNode, TabDetails, type TabsProps, TreeNode, UseZeugmaOptions, Zeugma, ZeugmaController, ZeugmaProps, usePaneContext, useResizer, useZeugma, useZeugmaContext };
172
+ export { type DragHandleProps, Pane, type PaneControlsProps, type PaneProps, type PaneRenderProps, PaneTree, RenderTabProps, SplitDirection, SplitNode, TabDetails, type TabsProps, TreeNode, UseZeugmaOptions, Zeugma, ZeugmaController, ZeugmaProps, usePaneContext, useResizer, useZeugma, useZeugmaContext };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import xn,{createContext,useState,useRef,useEffect,useCallback,useMemo,useContext}from'react';import {useDraggable,DndContext,useDroppable,useSensors,useSensor,pointerWithin,closestCenter,PointerSensor,TouchSensor}from'@dnd-kit/core';import {jsx,Fragment,jsxs}from'react/jsx-runtime';import {createPortal}from'react-dom';function dt({cursor:e,resizerEl:t,onMove:n,onEnd:r}){document.body.classList.add("zeugma-resizing");let o=document.createElement("style");o.id="zeugma-global-cursor-style",o.textContent=`
1
+ import yn,{createContext,useState,useRef,useEffect,useCallback,useMemo,useContext}from'react';import {useDraggable,DndContext,useDroppable,useSensors,useSensor,pointerWithin,closestCenter,PointerSensor,TouchSensor}from'@dnd-kit/core';import {jsx,Fragment,jsxs}from'react/jsx-runtime';import {createPortal}from'react-dom';function ut({cursor:e,resizerEl:t,onMove:n,onEnd:r}){document.body.classList.add("zeugma-resizing");let o=document.createElement("style");o.id="zeugma-global-cursor-style",o.textContent=`
2
2
  * {
3
3
  cursor: ${e} !important;
4
4
  user-select: none !important;
@@ -6,5 +6,5 @@ import xn,{createContext,useState,useRef,useEffect,useCallback,useMemo,useContex
6
6
  .zeugma-resizing *:not([role="separator"]) {
7
7
  pointer-events: none !important;
8
8
  }
9
- `,document.head.appendChild(o),t.setAttribute("data-resizing","true");let i=s=>{n(s);},a=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let s=document.getElementById("zeugma-global-cursor-style");s&&s.remove(),document.removeEventListener("pointermove",i),document.removeEventListener("pointerup",a),r();};document.addEventListener("pointermove",i),document.addEventListener("pointerup",a);}function Se(e){try{return JSON.stringify(e)}catch{return ""}}var Ke=createContext(void 0),je=createContext(void 0),ge=createContext(void 0),Qe=createContext(void 0),oe=()=>{let e=useContext(Ke);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},ze=()=>{let e=useContext(je);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e},$e=()=>{let e=useContext(Qe);if(!e)throw new Error("useZeugmaDrag must be used within a Zeugma provider");return e};function pt(e){let t=useRef(null);return useEffect(()=>{if(!e){t.current=null;return}let n=o=>{t.current={x:o.clientX,y:o.clientY};},r=o=>{let i=o.touches[0]||o.changedTouches[0];i&&(t.current={x:i.clientX,y:i.clientY});};return window.addEventListener("pointermove",n,{passive:true}),window.addEventListener("touchmove",r,{passive:true}),()=>{window.removeEventListener("pointermove",n),window.removeEventListener("touchmove",r);}},[e]),t}function ft(e){useEffect(()=>(e?document.body.style.setProperty("cursor","not-allowed","important"):document.body.style.removeProperty("cursor"),()=>{document.body.style.removeProperty("cursor");}),[e]);}function gt(){let[e,t]=useState({}),n=useRef({}),r=useRef(null),o=useRef({}),i=useRef(null),a=useRef(true);useEffect(()=>(a.current=true,()=>{a.current=false;}),[]);let s=useCallback((f,m)=>{a.current&&t(b=>{if(!m){if(!b[f])return b;let C={...b};return delete C[f],C}return b[f]===m?b:{...b,[f]:m}});},[]),c=useCallback((f,m)=>{n.current[f]=m;},[]),u=useCallback(f=>{r.current=f;},[]),p=useCallback((f,m)=>{o.current[f]=m;},[]);return {portalTargets:e,registerPortalTarget:s,registerRenderCallback:c,renderCallbacksRef:n,registerRenderPane:u,renderPaneRef:r,registerTabHeader:p,tabHeadersRef:o,activeIdRef:i}}function ln(e){let t=new Set;function n(r){r&&(r.type==="pane"?r.tabs.forEach(o=>{t.add(o);}):r.type==="split"&&(n(r.first),n(r.second)));}return n(e),Array.from(t).sort()}function mt(e){return useMemo(()=>ln(e),[e])}function bt(e){let{onDragStart:t,onDragEnd:n}=e,[r,o]=useState(null),[i,a]=useState(null),s=useCallback(u=>{t&&t(u);},[t]),c=useCallback((u,p,f)=>{n&&n(u,p,f);},[n]);return {overTabId:r,setOverTabId:o,overTabPosition:i,setOverTabPosition:a,handleDragStartInternal:s,handleDragEndInternal:c}}function vt(e){let n=useContext(ge)?.registerRenderPane;useEffect(()=>{n&&e&&n(e);},[n,e]);}function le(){return "pane-"+Math.random().toString(36).substring(2,11)}function fe(e,t){if(e===null)return null;if(e.type==="pane")return e.id===t?null:e;let n=fe(e.first,t),r=fe(e.second,t);return n===null?r:r===null?n:{...e,first:n,second:r}}function ce(e,t){if(e===null)return null;if(e.type==="pane"){if(e.tabs.includes(t)){let o=e.tabs.filter(s=>s!==t);if(o.length===0)return null;let i=e.activeTabId;e.activeTabId===t&&(i=o[0]);let a={...e.tabsMetadata};return delete a[t],{...e,tabs:o,activeTabId:i,tabsMetadata:Object.keys(a).length>0?a:void 0}}return e}let n=ce(e.first,t),r=ce(e.second,t);return n===null?r:r===null?n:{...e,first:n,second:r}}function xe(e,t,n,r,o){if(e===null)return typeof o=="string"?{type:"pane",id:le(),tabs:[o],activeTabId:o}:o;if(e.type==="pane"){if(e.id===t){let i=typeof o=="string"?{type:"pane",id:le(),tabs:[o],activeTabId:o}:o,a=r==="left"||r==="top";return {type:"split",direction:n,first:a?i:e,second:a?e:i,splitPercentage:50}}return e}return {...e,first:xe(e.first,t,n,r,o)||e.first,second:xe(e.second,t,n,r,o)||e.second}}function cn(e,t){if(e===null)return t;function n(r,o){return r.type==="pane"?{type:"split",direction:o==="row"?"column":"row",splitPercentage:50,first:r,second:t}:{...r,second:n(r.second,r.direction)}}return n(e,null)}function ht(e,t,n,r){if(e===null)return {type:"pane",id:le(),tabs:[n],activeTabId:n,tabsMetadata:r?{[n]:r}:void 0};let o=t?j(e,t):null;if(o&&o.type==="pane"){let s=function(c){if(c.type==="pane"&&c.id===t){let u=[...c.tabs];u.includes(n)||u.push(n);let p=c.tabsMetadata;return r&&(p={...c.tabsMetadata,[n]:r}),{...c,tabs:u,activeTabId:n,tabsMetadata:p}}return c.type==="split"?{...c,first:s(c.first),second:s(c.second)}:c};return s(e)}let i={type:"pane",id:le(),tabs:[n],activeTabId:n,tabsMetadata:r?{[n]:r}:void 0};return cn(e,i)}function ve(e,t,n){return e===null?null:e===t?{...e,splitPercentage:n}:e.type==="split"?{...e,first:ve(e.first,t,n)||e.first,second:ve(e.second,t,n)||e.second}:e}function j(e,t){return e===null?null:e.type==="pane"?e.id===t?e:null:e.type==="split"?j(e.first,t)??j(e.second,t):null}function q(e,t){return e===null?null:e.type==="pane"?e.tabs.includes(t)?e:null:e.type==="split"?q(e.first,t)??q(e.second,t):null}function Tt(e,t){let n=q(e,t);if(!n)return null;let r=n.tabs.indexOf(t);return {id:t,paneId:n.id,isActive:n.activeTabId===t,index:r,metadata:n.tabsMetadata?.[t]}}function Pt(e,t){return q(e,t)?.tabsMetadata?.[t]}function Rt(e,t){let n=j(e,t);return n?.tabsMetadata?.[n.activeTabId]}function He(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.tabs.includes(t)){let r=e.tabsMetadata||{},o=r[t],i=n(o),a={...r};return i===void 0?delete a[t]:a[t]=i,{...e,tabsMetadata:Object.keys(a).length>0?a:void 0}}return e}return e.type==="split"?{...e,first:He(e.first,t,n)??e.first,second:He(e.second,t,n)??e.second}:e}function Oe(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.id===t){if(n===false){let{locked:r,...o}=e;return o}return {...e,locked:n}}return e}return e.type==="split"?{...e,first:Oe(e.first,t,n)??e.first,second:Oe(e.second,t,n)??e.second}:e}function ye(e,t,n){return e===null?null:e.type==="pane"?e.id===t?e.activeTabId===n?e:{...e,activeTabId:n}:e:e.type==="split"?{...e,first:ye(e.first,t,n)??e.first,second:ye(e.second,t,n)??e.second}:e}function xt(e,t,n){if(e===null)return null;let o=q(e,t)?.tabsMetadata?.[t],i=ce(e,t);if(i===null)return {type:"pane",id:le(),tabs:[t],activeTabId:t,tabsMetadata:o?{[t]:o}:void 0};function a(s){if(s.type==="pane"){if(s.id===n){let c=[...s.tabs];c.includes(t)||c.push(t);let u={...s.tabsMetadata};return o&&(u[t]=o),{...s,tabs:c,activeTabId:t,tabsMetadata:Object.keys(u).length>0?u:void 0}}return s}return s.type==="split"?{...s,first:a(s.first),second:a(s.second)}:s}return a(i)}function Be(e,t,n,r="before"){if(e===null)return null;let i=q(e,t)?.tabsMetadata?.[t],a=ce(e,t);if(a===null)return {type:"pane",id:le(),tabs:[t],activeTabId:t,tabsMetadata:i?{[t]:i}:void 0};function s(c){if(c.type==="pane"){if(c.tabs.includes(n)){let p=[...c.tabs].filter(b=>b!==t),f=p.indexOf(n);f<0&&(f=0),r==="after"&&(f+=1),p.splice(f,0,t);let m={...c.tabsMetadata};return i&&(m[t]=i),{...c,tabs:p,activeTabId:t,tabsMetadata:Object.keys(m).length>0?m:void 0}}return c}return c.type==="split"?{...c,first:s(c.first),second:s(c.second)}:c}return s(a)}function pe(e,t=0,n=0,r=100,o=100,i="root"){if(e===null)return {panes:[],splitters:[]};if(e.type==="pane")return {panes:[{paneId:e.id,left:t,top:n,width:r,height:o,node:e}],splitters:[]};let{direction:a,splitPercentage:s,first:c,second:u}=e,f={id:`splitter-${i}-${a}`,currentNode:e,direction:a,left:a==="row"?t+r*(s/100):t,top:a==="column"?n+o*(s/100):n,width:a==="row"?0:r,height:a==="column"?0:o,parentLeft:t,parentTop:n,parentWidth:r,parentHeight:o},m={panes:[],splitters:[]},b={panes:[],splitters:[]};if(a==="row"){let C=r*(s/100);m=pe(c,t,n,C,o,`${i}-L`),b=pe(u,t+C,n,r-C,o,`${i}-R`);}else {let C=o*(s/100);m=pe(c,t,n,r,C,`${i}-T`),b=pe(u,t,n+C,r,o-C,`${i}-B`);}return {panes:[...m.panes,...b.panes],splitters:[f,...m.splitters,...b.splitters]}}function yt(e,t,n,r){if(!(t==="tab"&&n&&e.includes(n))||!r)return -1;let a=e.indexOf(n);return r==="before"?a:a+1}function un(e){let{initialLayout:t,layout:n,onChange:r,fullscreenPaneId:o,onFullscreenChange:i,locked:a=false}=e,[s,c]=useState(()=>n!==void 0?n:t??null),[u,p]=useState(()=>n!==void 0?n:t??null),[f,m]=useState(()=>Se(n!==void 0?n:null)),[b,C]=useState(o||null),[I,Z]=useState(a),[v,z]=useState(null),[H,y]=useState(null),[S,P]=useState(null),w=useRef(null),re=useCallback(l=>{w.current=l;},[]),$=useRef(s);$.current=s;let _=useRef(r);_.current=r;let F=useRef(i);F.current=i;let te=useCallback(l=>{C(l),F.current?.(l);},[]);if(useEffect(()=>{Z(a);},[a]),useEffect(()=>{o!==void 0&&C(o);},[o]),n!==void 0){let l=Se(n);l!==f&&(m(l),c(n),p(n));}let R=useCallback(l=>(...g)=>{let A=$.current,M=l(A,...g);Se(A)!==Se(M)&&($.current=M,c(M),p(M),_.current?.(M));},[]),U=useCallback(R((l,g)=>typeof g=="function"?g(l):g),[R]),L=useCallback(l=>{p(g=>typeof l=="function"?l(g):l);},[]),J=useCallback(l=>{C(null),F.current?.(null),z(null),y(null),P(null),U(l),p(()=>typeof l=="function"?l($.current):l);},[U]),V=useCallback(R((l,g)=>fe(l,g)),[R]),D=useCallback(R((l,g,A,M)=>{let Y=ce(l,g)??l;return ht(Y,A,g,M)}),[R]),x=useCallback(R((l,g,A,M,Y)=>{let W=j(l,g)??q(l,g);if(!W)return l;let ue=j(l,Y)??q(l,Y)??{type:"pane",id:Y,tabs:[Y],activeTabId:Y},Q=fe(l,Y);return xe(Q,W.id,A,M,ue)}),[R]),d=useCallback(R((l,g,A)=>ve(l,g,A)),[R]),O=useCallback(R((l,g,A)=>He(l,g,A)),[R]),E=useCallback(R((l,g,A)=>{let M=j(l,g)??q(l,g);return M?Oe(l,M.id,A):l}),[R]),T=useCallback(R((l,g,A)=>{let M=j(l,g)??q(l,g);return M?ye(l,M.id,A):l}),[R]),ae=useCallback(R((l,g,A)=>{let M=j(l,A)??q(l,A);return M?xt(l,g,M.id):l}),[R]),G=useCallback(R((l,g,A,M)=>Be(l,g,A,M)),[R]),X=useCallback(R((l,g)=>ce(l,g)),[R]),K=useCallback(l=>j($.current,l),[]),ne=useCallback(l=>q($.current,l),[]),h=useCallback(l=>Tt($.current,l),[]),N=useCallback(l=>Pt($.current,l),[]),k=useCallback(l=>Rt($.current,l),[]);return {layout:s,setLayout:J,_internalSetLayout:L,renderingLayout:u,fullscreenPaneId:b,setFullscreenPaneId:te,locked:I,setLocked:Z,activeId:v,setActiveId:z,activeType:H,setActiveType:y,dismissIntentId:S,setDismissIntentId:P,containerRef:w,setContainerRef:re,removePane:V,addTab:D,updateMetadata:O,updatePaneLock:E,selectTab:T,mergeTab:ae,moveTab:G,removeTab:X,splitPane:x,updateSplitPercentage:d,findPaneById:K,findPaneContainingTab:ne,findTabById:h,getTabMetadata:N,getActiveTabMetadata:k}}var dn=()=>{let e=oe(),t=ze();return {layout:e.layout,setLayout:e.setLayout,fullscreenPaneId:e.fullscreenPaneId,setFullscreenPaneId:t.setFullscreenPaneId,locked:e.locked,setLocked:t.setLocked,removePane:t.removePane,addTab:t.addTab,updateMetadata:t.updateMetadata,updatePaneLock:t.updatePaneLock,selectTab:t.selectTab,mergeTab:t.mergeTab,removeTab:t.removeTab,splitPane:t.splitPane,updateSplitPercentage:t.updateSplitPercentage,moveTab:t.moveTab,findPaneById:e.findPaneById,findPaneContainingTab:e.findPaneContainingTab,findTabById:e.findTabById,getTabMetadata:e.getTabMetadata,getActiveTabMetadata:e.getActiveTabMetadata}};var Ve=class extends PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},We=class extends TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};var Ct=e=>{let n=e.active.id.toString().startsWith("tab-header-"),r=pointerWithin(e),o=n?r:r.filter(i=>!i.id.toString().startsWith("tab-drop-"));if(o.length>0)return [...o].sort((a,s)=>{let c=a.id.toString(),u=s.id.toString();if(n){let m=c.startsWith("tab-drop-"),b=u.startsWith("tab-drop-");if(m&&!b)return -1;if(!m&&b)return 1}let p=c.startsWith("drop-root-"),f=u.startsWith("drop-root-");return p&&!f?-1:!p&&f?1:0});if(n){let i=e.droppableContainers.filter(a=>a.id.toString().startsWith("tab-drop-"));return closestCenter({...e,droppableContainers:i})}return []};function Ue(e){if(e instanceof MouseEvent||e instanceof PointerEvent)return {x:e.clientX,y:e.clientY};if(typeof TouchEvent<"u"&&e instanceof TouchEvent){let t=e.touches[0]||e.changedTouches[0];if(t)return {x:t.clientX,y:t.clientY}}return null}function Nt(e){let{layout:t,_internalSetLayout:n,setLayout:r,activeId:o,setActiveId:i,setActiveType:a,dismissIntentId:s,setDismissIntentId:c,setOverTabId:u,setOverTabPosition:p,containerRef:f,dragActivationDistance:m,enableDragToDismiss:b,dismissThreshold:C,onRemove:I,onDragStart:Z,onDragEnd:v,onDismissIntentChange:z,removeTab:H,removePane:y}=e,S=useRef(null),P=pt(o),w=useRef(null),[re,$]=useState(false);return ft(re),{sensors:useSensors(useSensor(Ve,{activationConstraint:{distance:m}}),useSensor(We,{activationConstraint:{delay:250,tolerance:5}})),collisionDetection:Ct,onDragStart:L=>{let J=L.active.id.toString(),V=J.startsWith("tab-header-"),D=V?J.substring(11):J;i(D),a(V?"tab":"pane"),u(null),p(null);let x=L.activatorEvent;P.current=Ue(x),b&&f.current?S.current=f.current.getBoundingClientRect():S.current=null;let d=t;if(V){let E=q(t,D);E&&(d=ye(t,E.id,D)||t);}w.current=d;let O=V?ce(d,D):fe(d,D);n(O),Z&&Z(D);},onDragMove:L=>{let{over:J}=L,V=J?.id.toString()||"",D=V.startsWith("drop-locked-");$(h=>h===D?h:D);let x=L.active.id.toString(),d=x.startsWith("tab-header-"),O=d?x.substring(11):x,E=V.match(/^tab-drop-(.+)$/);if(E&&J&&d){let[,h]=E;if(O!==h){let N="before",k=J.rect,se=L.activatorEvent,l=null;if(P.current)l=P.current.x;else {let g=Ue(se);g&&(l=g.x+L.delta.x);}if(l!==null){let g=k.left+k.width/2;l>g&&(N="after");}u(g=>g===h?g:h),p(g=>g===N?g:N);}else u(N=>N===null?N:null),p(N=>N===null?N:null);}else u(h=>h===null?h:null),p(h=>h===null?h:null);if(!b)return;let T=S.current;if(!T){s!==null&&(c(null),z?.(null));return}let ae=L.activatorEvent,G=null,X=null;if(P.current)G=P.current.x,X=P.current.y;else {let h=Ue(ae);h&&(G=h.x+L.delta.x,X=h.y+L.delta.y);}let K=0;if(G!==null&&X!==null){let h=0,N=0;G<T.left?h=T.left-G:G>T.right&&(h=G-T.right),X<T.top?N=T.top-X:X>T.bottom&&(N=X-T.bottom),K=Math.sqrt(h*h+N*N);}else {let h=L.active.rect.current.translated;if(h){let N=h.left+h.width/2,k=h.top+h.height/2,se=0,l=0;N<T.left?se=T.left-N:N>T.right&&(se=N-T.right),k<T.top?l=T.top-k:k>T.bottom&&(l=k-T.bottom),K=Math.sqrt(se*se+l*l);}}K>C?s!==O&&(c(O),z?.(O)):s!==null&&(c(null),z?.(null));},onDragEnd:L=>{i(null),a(null),$(false),u(null),p(null);let{active:J,over:V}=L,D=J.id.toString(),x=D.startsWith("tab-header-"),d=x?D.substring(11):D,O=b&&s===d;c(null),z?.(null),S.current=null;let E=w.current||t;if(w.current=null,O){I?I(d):x?H(d):y(d),v&&v(d,null,null);return}if(!V){n(E),v&&v(d,null,null);return}let T=V.id.toString();if(T.startsWith("drop-locked-")){n(E),v&&v(d,null,null);return}let ae=T.match(/^tab-drop-(.+)$/);if(ae){if(!x){n(E),v&&v(d,null,null);return}let[,M]=ae;if(d!==M){let Y="before",W=V.rect,ue=L.activatorEvent,Q=null;if(P.current)Q=P.current.x;else {let ee=Ue(ue);ee&&(Q=ee.x+L.delta.x);}if(Q!==null){let ee=W.left+W.width/2;Q>ee&&(Y="after");}let be=Be(E,d,M,Y);r(be),v&&v(d,M,{type:"move",position:"center"});}else n(E),v&&v(d,null,null);return}let G=T.match(/^drop-root-(1\/4|1\/3)-(top|bottom|left|right|start|end)$/);if(G){let[,M,Y]=G,W=Y;W==="start"&&(W="left"),W==="end"&&(W="right");let ue=x?ce(E,d):fe(E,d),Q;if(x){let ee=q(E,d)?.tabsMetadata?.[d];Q={type:"pane",id:le(),tabs:[d],activeTabId:d,tabsMetadata:ee?{[d]:ee}:void 0};}else Q=j(E,d)??{type:"pane",id:le(),tabs:[d],activeTabId:d};if(ue===null)r(Q);else {let be=W==="left"||W==="right",ee=W==="left"||W==="top",Te=50;M==="1/4"?Te=ee?25:75:M==="1/3"&&(Te=ee?100/3:200/3),r({type:"split",direction:be?"row":"column",first:ee?Q:ue,second:ee?ue:Q,splitPercentage:Te});}v&&v(d,"root",{type:"split",direction:W==="left"||W==="right"?"row":"column",position:W});return}let X=T.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!X){n(E),v&&v(d,null,null);return}let[,K,ne]=X,h=x?q(E,d):j(E,d),N=h&&h.id===ne,k=h&&h.tabs.length===1;if(d===ne||N&&k){n(E),v&&v(d,null,null);return}let se=K==="left"||K==="right"?"row":"column",l;if(x){let Y=q(E,d)?.tabsMetadata?.[d];l={type:"pane",id:le(),tabs:[d],activeTabId:d,tabsMetadata:Y?{[d]:Y}:void 0};}else l=j(E,d)??{type:"pane",id:le(),tabs:[d],activeTabId:d};let g=x?ce(E,d):fe(E,d),A=xe(g,ne,se,K,l);r(A),v&&v(d,ne,{type:"split",direction:se,position:K});},onDragCancel:()=>{i(null),a(null),$(false),u(null),p(null),c(null),z?.(null),S.current=null;let L=w.current||t;w.current=null,n(L),L!==t&&r(L);}}}function Et({persist:e,layout:t,setLayout:n}){let r=typeof e=="object"?e.enabled!==false:!!e,o=typeof e=="object"&&e.key||"zeugma-layout",[i,a]=useState(false);useEffect(()=>{if(r){let s=localStorage.getItem(o);if(s)try{let c=JSON.parse(s);c&&n(c);}catch(c){console.error("Failed to parse persisted zeugma layout",c);}}a(true);},[r,o,n]),useEffect(()=>{r&&i&&(t?localStorage.setItem(o,JSON.stringify(t)):localStorage.removeItem(o));},[r,o,t,i]);}var Mt=({activeId:e,render:t,className:n})=>{let r=useRef(null);return useEffect(()=>{let o=i=>{r.current&&(r.current.style.transform=`translate(${i.clientX+12}px, ${i.clientY+12}px)`);};return document.addEventListener("pointermove",o),()=>document.removeEventListener("pointermove",o)},[]),jsx("div",{ref:r,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var Lt=xn.memo(({tabDetails:e,target:t,renderWidget:n})=>{let{id:r}=e,[o,i]=useState(false),a=useRef(null);if(useEffect(()=>{i(true);},[]),useEffect(()=>{if(!o||!a.current)return;let c=a.current;if(t)t.appendChild(c);else {let u=document.getElementById("zeugma-hidden-portal-container");u||(u=document.createElement("div"),u.id="zeugma-hidden-portal-container",u.style.display="none",document.body.appendChild(u)),u.appendChild(c);}},[t,o]),useEffect(()=>()=>{a.current&&a.current.remove();},[]),!o)return null;a.current||(a.current=document.createElement("div"),a.current.className=`zeugma-portal-wrapper-${r}`,a.current.style.width="100%",a.current.style.height="100%");let s=a.current;return !s||!n?null:createPortal(n(e),s)},(e,t)=>e.target===t.target&&e.renderWidget===t.renderWidget&&e.tabDetails.id===t.tabDetails.id&&e.tabDetails.paneId===t.tabDetails.paneId&&e.tabDetails.isActive===t.tabDetails.isActive&&e.tabDetails.index===t.tabDetails.index&&e.tabDetails.metadata===t.tabDetails.metadata);var Zt=({activeId:e,activeType:t,dismissIntentId:n,renderDragOverlay:r,renderPaneRef:o,renderPane:i,tabHeadersRef:a,classNames:s})=>{if(r)return jsx(Fragment,{children:r({type:t,id:e,isDismissing:e===n})});if(t==="pane"){let c=o.current||i;if(c)return jsx("div",{className:s.paneDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:c(e)})}else if(t==="tab"){let c=o.current||i;if(c)return jsx("div",{className:s.tabDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:c(e)});let u=a.current[e];if(u){let p=s.tab?typeof s.tab=="function"?s.tab(e):s.tab:"";return jsx("div",{className:`${s.tabDragPreview||""} ${p}`.trim(),style:{display:"inline-flex",position:"relative",pointerEvents:"none",overflow:"hidden",width:"420px",height:"260px"},children:u({isDragging:true,isOver:false})})}}return jsx("div",{style:{pointerEvents:"none",overflow:"hidden",width:"100%",height:"100%"}})};function nt({containerRef:e,isRow:t,direction:n,splitPercentage:r,resizerSize:o,snapThreshold:i,layout:a,currentNode:s,onLayoutChange:c,onResizeStart:u,onResizeEnd:p,parentLeft:f,parentTop:m,parentWidth:b,parentHeight:C}){let{onResizeStart:I,onResize:Z,onResizeEnd:v,minSplitPercentage:z=5,maxSplitPercentage:H=95,locked:y=false}=oe();return useCallback(S=>{if(y)return;S.preventDefault();let P=e.current;if(!P)return;u&&u(),I&&I(s);let w=P.getBoundingClientRect(),re=S.clientX,$=S.clientY,_=r,F=S.currentTarget,te=w.left+w.width*(f/100),R=w.top+w.height*(m/100),U=w.width*(b/100),L=w.height*(C/100),V=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(x=>x!==F&&x.getAttribute("data-direction")===n).map(x=>{let d=x.getBoundingClientRect();return t?d.left+d.width/2:d.top+d.height/2}),D=_;dt({cursor:t?"col-resize":"row-resize",resizerEl:F,onMove:x=>{let d=t?(x.clientX-re)/U*100:(x.clientY-$)/L*100,O=_+d,E=t?te+(U-o)*(O/100)+o/2:R+(L-o)*(O/100)+o/2,T=1/0,ae=null;for(let ne of V){let h=Math.abs(E-ne);h<i&&h<T&&(T=h,ae=ne);}let G=O;ae!==null&&(G=t?(ae-o/2-te)/(U-o)*100:(ae-o/2-R)/(L-o)*100);let X=Math.max(z,Math.min(H,G));D=X;let K=ve(a,s,X);if(K){let{panes:ne,splitters:h}=pe(K),N=e.current;if(N){for(let k of ne)N.style.setProperty(`--pane-left-${k.paneId}`,`${k.left}%`),N.style.setProperty(`--pane-top-${k.paneId}`,`${k.top}%`),N.style.setProperty(`--pane-width-${k.paneId}`,`${k.width}%`),N.style.setProperty(`--pane-height-${k.paneId}`,`${k.height}%`);for(let k of h)N.style.setProperty(`--splitter-pos-${k.id}`,`${k.direction==="row"?k.left:k.top}%`);}}Z&&Z(s,X);},onEnd:()=>{let x=ve(a,s,D),d=e.current;if(d){let{panes:O,splitters:E}=pe(x);for(let T of O)d.style.removeProperty(`--pane-left-${T.paneId}`),d.style.removeProperty(`--pane-top-${T.paneId}`),d.style.removeProperty(`--pane-width-${T.paneId}`),d.style.removeProperty(`--pane-height-${T.paneId}`);for(let T of E)d.style.removeProperty(`--splitter-pos-${T.id}`);}c(x),p&&p(),v&&v(s,D);}});},[e,t,n,r,o,i,a,s,c,u,p,I,Z,v,z,H,f,m,b,C])}var kt=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:r})=>{let{renderingLayout:o,setLayout:i,classNames:a,locked:s}=oe(),[c,u]=useState(false),{currentNode:p,direction:f,left:m,top:b,width:C,height:I,parentLeft:Z,parentTop:v,parentWidth:z,parentHeight:H}=e,y=f==="row",S=nt({containerRef:r,isRow:y,direction:f,splitPercentage:p.splitPercentage,resizerSize:t,snapThreshold:n,layout:o,currentNode:p,onLayoutChange:i,onResizeStart:()=>u(true),onResizeEnd:()=>u(false),parentLeft:Z,parentTop:v,parentWidth:z,parentHeight:H}),P=y?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${m}%) - ${t/2}px)`,top:`calc(${b}% + ${t/2}px)`,width:`${t}px`,height:`calc(${I}% - ${t}px)`,cursor:s?"default":"col-resize",pointerEvents:s?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`calc(${m}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${b}%) - ${t/2}px)`,width:`calc(${C}% - ${t}px)`,height:`${t}px`,cursor:s?"default":"row-resize",pointerEvents:s?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"};return jsx("div",{className:a.resizer||"","data-direction":f,"data-resizing":c||void 0,style:P,onPointerDown:S,role:"separator","aria-valuenow":p.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},zt=xn.memo(({paneId:e,renderPane:t})=>jsx(Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane);var ot=({renderPane:e,tree:t,resizerSize:n,snapThreshold:r})=>{vt(e);let{renderingLayout:o,activeId:i,dismissIntentId:a,setContainerRef:s,fullscreenPaneId:c,snapThreshold:u,locked:p,classNames:f,resizerSize:m}=oe(),b=r!==void 0?r:u??8,C=n!==void 0?n:m??4,I=t!==void 0?t:o,Z=useRef(null),{panes:v,splitters:z}=useMemo(()=>I?pe(I):{panes:[],splitters:[]},[I]);if(!I&&t!==void 0)return null;let H=()=>jsxs(Fragment,{children:[v.map(y=>{let S=c===y.paneId;return jsx("div",{style:{position:"absolute",left:S?"0%":`var(--pane-left-${y.paneId}, ${y.left}%)`,top:S?"0%":`var(--pane-top-${y.paneId}, ${y.top}%)`,width:S?"100%":`var(--pane-width-${y.paneId}, ${y.width}%)`,height:S?"100%":`var(--pane-height-${y.paneId}, ${y.height}%)`,overflow:"hidden",zIndex:S?20:1,display:c&&!S?"none":"block",padding:S?"0px":`${C/2}px`,boxSizing:"border-box"},children:jsx(zt,{paneId:y.paneId,renderPane:e})},y.paneId)}),!c&&z.map(y=>jsx(kt,{splitter:y,resizerSize:C,snapThreshold:b,containerRef:Z},y.id))]});if(t===void 0){let y=i!==null&&i===a,S=w=>{s(w),Z.current=w;},P=`${f.dashboard||""} ${y&&f.dashboardDismissActive||""} ${p&&f.dashboardLocked||""}`.trim();return jsxs("div",{ref:S,className:P,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[H(),i!==null&&!p&&jsx(Ht,{activeClassName:f.rootDropPreview??f.dropPreview})]})}return jsx("div",{ref:Z,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:H()})};var $n=e=>{let{controller:t,children:n,renderDragOverlay:r,classNames:o={},renderPane:i,resizerSize:a,dragActivationDistance:s=8,snapThreshold:c=8,minSplitPercentage:u=5,maxSplitPercentage:p=95,enableDragToDismiss:f=false,dismissThreshold:m=60,onRemove:b,onDragStart:C,onDragEnd:I,onResizeStart:Z,onResize:v,onResizeEnd:z,onDismissIntentChange:H,persist:y=false}=e,S=t,{layout:P,setLayout:w,_internalSetLayout:re,renderingLayout:$,fullscreenPaneId:_,setFullscreenPaneId:F,locked:te,setLocked:R,findPaneById:U,findPaneContainingTab:L,findTabById:J,getTabMetadata:V,getActiveTabMetadata:D,activeId:x,setActiveId:d,activeType:O,setActiveType:E,dismissIntentId:T,setDismissIntentId:ae,containerRef:G,setContainerRef:X,removePane:K,addTab:ne,updateMetadata:h,updatePaneLock:N,selectTab:k,mergeTab:se,removeTab:l,splitPane:g,updateSplitPercentage:A,moveTab:M}=S;Et({persist:y,layout:P,setLayout:w});let{portalTargets:Y,registerPortalTarget:W,registerRenderCallback:ue,renderCallbacksRef:Q,registerRenderPane:be,renderPaneRef:ee,registerTabHeader:Te,tabHeadersRef:Me,activeIdRef:Le}=gt(),{overTabId:it,setOverTabId:_t,overTabPosition:lt,setOverTabPosition:Gt,handleDragStartInternal:Kt,handleDragEndInternal:jt}=bt({onDragStart:C,onDragEnd:I}),Qt=Nt({layout:P,_internalSetLayout:re,setLayout:w,activeId:x,setActiveId:d,setActiveType:E,dismissIntentId:T,setDismissIntentId:ae,setOverTabId:_t,setOverTabPosition:Gt,containerRef:G,dragActivationDistance:s,enableDragToDismiss:f,dismissThreshold:m,onRemove:b,onDragStart:Kt,onDragEnd:jt,onDismissIntentChange:H,removeTab:l,removePane:K}),_e=useMemo(()=>o,[o.dashboard,o.dashboardDismissActive,o.pane,o.paneLocked,o.dropPreview,o.rootDropPreview,o.dragOverlay,o.paneDragPreview,o.tabDragPreview,o.resizer,o.dismissPreview,o.dashboardLocked,o.lockedPreview,o.tabDropPreview,o.tabSeparator,o.tabsContainer,o.tab,o.paneContainer,o.paneHeader,o.paneControls,o.paneButton,o.tabCloseButton,o.dragHandle]),ct=useCallback((de,Ze)=>{z&&z(de,Ze);},[z]),en=useMemo(()=>({layout:P,renderingLayout:$,setLayout:w,activeId:x,activeType:O,dismissIntentId:T,setContainerRef:X,fullscreenPaneId:_,classNames:_e,onRemove:b,onFullscreenChange:F,snapThreshold:c,onResizeStart:Z,onResize:v,onResizeEnd:ct,minSplitPercentage:u,maxSplitPercentage:p,locked:te,setLocked:R,findPaneById:U,findPaneContainingTab:L,findTabById:J,getTabMetadata:V,getActiveTabMetadata:D,renderPane:i,resizerSize:a}),[P,$,x,O,T,X,_,_e,b,F,c,Z,v,u,p,w,ct,te,R,U,L,J,V,D,i,a]),tn=useMemo(()=>({overTabId:it,overTabPosition:lt}),[it,lt]),nn=useMemo(()=>({removePane:K,addTab:ne,updateMetadata:h,updatePaneLock:N,selectTab:k,mergeTab:se,removeTab:l,setFullscreenPaneId:F,setLocked:R,splitPane:g,updateSplitPercentage:A,moveTab:M}),[K,ne,h,N,k,se,l,F,R,g,A,M]),on=mt(P),rn=useMemo(()=>({registerPortalTarget:W,registerRenderCallback:ue,renderCallbacksRef:Q,registerRenderPane:be,renderPaneRef:ee,registerTabHeader:Te,tabHeadersRef:Me,activeIdRef:Le}),[W,ue,Q,be,ee,Te,Me,Le]);return Le&&(Le.current=x),jsx(je.Provider,{value:nn,children:jsx(Ke.Provider,{value:en,children:jsx(Qe.Provider,{value:tn,children:jsxs(ge.Provider,{value:rn,children:[jsx(DndContext,{id:"zeugma-dnd-context",...Qt,children:n}),x&&O&&jsx(Mt,{activeId:x,render:de=>jsx("div",{style:{transition:"transform 150ms cubic-bezier(0.2, 0, 0, 1)",transform:de===T?"scale(0.8)":"scale(1)",transformOrigin:"top left"},children:jsx(Zt,{activeId:de,activeType:O,dismissIntentId:T,renderDragOverlay:r,renderPaneRef:ee,renderPane:i,tabHeadersRef:Me,classNames:_e})}),className:`${o.dragOverlay||""} ${x===T&&o.dismissPreview||""}`.trim()}),jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:on.map(de=>{let Ze=Y[de],ut=J(de);return ut?jsx(Lt,{tabDetails:ut,target:Ze||null,renderWidget:Q.current[de]},de):null})})]})})})})},An=({renderPane:e,resizerSize:t,snapThreshold:n})=>{if(!e)throw new Error("Zeugma component requires a renderPane prop when used as a standalone renderer.");return jsx(ot,{renderPane:e,resizerSize:t,snapThreshold:n})},Hn=e=>{let{children:t,...n}=e,{controller:r}=e;if(!r)throw new Error("Zeugma component requires a controller.");return jsx($n,{...e,children:t!==void 0?t:jsx(An,{...n})})};var Fn={top:{"1/4":{position:"absolute",top:0,left:0,width:"100%",height:"24px",zIndex:100,pointerEvents:"auto"},"1/3":{position:"absolute",top:"24px",left:0,width:"100%",height:"24px",zIndex:100,pointerEvents:"auto"}},bottom:{"1/4":{position:"absolute",bottom:0,left:0,width:"100%",height:"24px",zIndex:100,pointerEvents:"auto"},"1/3":{position:"absolute",bottom:"24px",left:0,width:"100%",height:"24px",zIndex:100,pointerEvents:"auto"}},left:{"1/4":{position:"absolute",left:0,top:"48px",width:"24px",height:"calc(100% - 96px)",zIndex:100,pointerEvents:"auto"},"1/3":{position:"absolute",left:"24px",top:"48px",width:"24px",height:"calc(100% - 96px)",zIndex:100,pointerEvents:"auto"}},right:{"1/4":{position:"absolute",right:0,top:"48px",width:"24px",height:"calc(100% - 96px)",zIndex:100,pointerEvents:"auto"},"1/3":{position:"absolute",right:"24px",top:"48px",width:"24px",height:"calc(100% - 96px)",zIndex:100,pointerEvents:"auto"}}},Vn={top:{"1/4":{top:0,left:0,width:"100%",height:"60px",borderBottomLeftRadius:"12px",borderBottomRightRadius:"12px",borderTopLeftRadius:"0px",borderTopRightRadius:"0px"},"1/3":{top:0,left:0,width:"100%",height:"96px",borderBottomLeftRadius:"12px",borderBottomRightRadius:"12px",borderTopLeftRadius:"0px",borderTopRightRadius:"0px"}},bottom:{"1/4":{bottom:0,left:0,width:"100%",height:"60px",borderTopLeftRadius:"12px",borderTopRightRadius:"12px",borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},"1/3":{bottom:0,left:0,width:"100%",height:"96px",borderTopLeftRadius:"12px",borderTopRightRadius:"12px",borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"}},left:{"1/4":{left:0,top:0,width:"60px",height:"100%",borderTopRightRadius:"12px",borderBottomRightRadius:"12px",borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"},"1/3":{left:0,top:0,width:"96px",height:"100%",borderTopRightRadius:"12px",borderBottomRightRadius:"12px",borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"}},right:{"1/4":{right:0,top:0,width:"60px",height:"100%",borderTopLeftRadius:"12px",borderBottomLeftRadius:"12px",borderTopRightRadius:"0px",borderBottomRightRadius:"0px"},"1/3":{right:0,top:0,width:"96px",height:"100%",borderTopLeftRadius:"12px",borderBottomLeftRadius:"12px",borderTopRightRadius:"0px",borderBottomRightRadius:"0px"}}},Wn=({id:e,fraction:t,edge:n,activeClassName:r})=>{let{setNodeRef:o,isOver:i}=useDroppable({id:e}),a={position:"absolute",pointerEvents:"none",zIndex:101,boxSizing:"border-box",...Vn[n][t]};return jsxs(Fragment,{children:[jsx("div",{ref:o,style:Fn[n][t]}),i&&jsx("div",{className:r,style:a})]})},Ht=({activeClassName:e})=>jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:99,pointerEvents:"none"},children:[{id:"drop-root-1/4-top",fraction:"1/4",edge:"top"},{id:"drop-root-1/3-top",fraction:"1/3",edge:"top"},{id:"drop-root-1/4-bottom",fraction:"1/4",edge:"bottom"},{id:"drop-root-1/3-bottom",fraction:"1/3",edge:"bottom"},{id:"drop-root-1/4-left",fraction:"1/4",edge:"left"},{id:"drop-root-1/3-left",fraction:"1/3",edge:"left"},{id:"drop-root-1/4-right",fraction:"1/4",edge:"right"},{id:"drop-root-1/3-right",fraction:"1/3",edge:"right"}].map(n=>jsx(Wn,{id:n.id,fraction:n.fraction,edge:n.edge,activeClassName:e},n.id))});var Je=createContext(null);var qn={top:{position:"absolute",top:0,left:0,width:"100%",height:"25%",zIndex:20,pointerEvents:"auto"},bottom:{position:"absolute",bottom:0,left:0,width:"100%",height:"25%",zIndex:20,pointerEvents:"auto"},left:{position:"absolute",top:"25%",left:0,width:"50%",height:"50%",zIndex:20,pointerEvents:"auto"},right:{position:"absolute",top:"25%",right:0,width:"50%",height:"50%",zIndex:20,pointerEvents:"auto"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:20,pointerEvents:"auto",cursor:"not-allowed"}},_n={top:{position:"absolute",top:0,left:0,right:0,height:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},bottom:{position:"absolute",bottom:0,left:0,right:0,height:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},left:{position:"absolute",top:0,bottom:0,left:0,width:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},right:{position:"absolute",top:0,bottom:0,right:0,width:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:21,pointerEvents:"none",boxSizing:"border-box"}},rt=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:r,isOver:o}=useDroppable({id:e});return jsxs(Fragment,{children:[jsx("div",{ref:r,style:qn[t]}),o&&jsx("div",{className:n,style:_n[t]})]})};var Bt=({children:e,className:t,style:n})=>{let r=useContext(Je);if(!r)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:o,...i}=r;return jsx("div",{className:t,style:{cursor:o?"default":"grab",userSelect:o?"auto":"none",touchAction:o?"auto":"none",...n},...o?{}:i,children:e})};var ao=createContext(void 0);var Ee=({id:e,locked:t=false,children:n,className:r,style:o})=>{let{locked:i,classNames:a={},activeType:s}=oe(),{overTabId:c}=$e(),u=useContext(ge);useEffect(()=>(u?.registerTabHeader&&u.registerTabHeader(e,n),()=>{u?.registerTabHeader&&u.activeIdRef?.current!==e&&u.registerTabHeader(e,()=>null);}),[e,n,u]);let p=useContext(at),f=t||i||(p?.locked??false),{attributes:m,listeners:b,setNodeRef:C,isDragging:I}=useDraggable({id:`tab-header-${e}`,disabled:f}),{setNodeRef:Z,isOver:v}=useDroppable({id:`tab-drop-${e}`,disabled:f||s==="pane"}),z=U=>{C(U),Z(U);},H=v&&c===e,y=p?.tabs||[],S=y.indexOf(e),P=p?.activeTabId,re=S>0&&e!==P&&y[S-1]!==P?jsx("div",{className:a.tabSeparator}):null,$=p?p.activeTabId===e:false,_=p?.tabsMetadata?.[e],F=useCallback(()=>{p?.selectTab(e);},[p,e]),te=useCallback(()=>{p?.removeTab(e);},[p,e]),R=useMemo(()=>({tabId:e,isActive:$,isDragging:I,isOver:H,metadata:_,locked:f,selectTab:F,removeTab:te}),[e,$,I,H,_,f,F,te]);return jsx(ao.Provider,{value:R,children:jsxs("div",{ref:z,id:`tab-header-${e}`,className:r,style:{display:"inline-flex",position:"relative",cursor:f?"default":"grab",...o},...f?{}:b,...f?{}:m,children:[re,n({isDragging:I,isOver:H})]})})};var at=createContext(void 0);var Ut=(e,t)=>typeof e=="function"?e(t):e,st=({tabs:e,activeTabId:t,locked:n,tabsMetadata:r,selectTab:o,removeTab:i,renderTab:a,classNames:s,styles:c})=>{let u=useContext(Ye),p=e??u?.tabs??[],f=t??u?.activeTabId??"",m=n??u?.locked??false,b=r??u?.tabsMetadata,C=o??u?.selectTab??(()=>{}),I=i??u?.removeTab??(()=>{}),{classNames:Z={},activeType:v}=oe(),{overTabId:z,overTabPosition:H}=$e(),y=useMemo(()=>({tabs:p,activeTabId:f,locked:m,tabsMetadata:b,selectTab:C,removeTab:I}),[p,f,m,b,C,I]),S=yt(p,v,z,H);return jsx(at.Provider,{value:y,children:jsxs("div",{className:s?.container,style:{display:"flex",alignItems:"center",height:"100%",...c?.container},children:[p.map((P,w)=>{let re=b?.[P],$=Ut(s?.tab,P),_=Ut(c?.tab,P),F=w===S;return jsxs(xn.Fragment,{children:[F&&Z.tabDropPreview&&jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsx("div",{className:Z.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:w===0?"none":"translateX(-50%)"}})}),jsx(Ee,{id:P,locked:m,className:$,style:_,children:({isDragging:te,isOver:R})=>a({tabId:P,activeTabId:f,isDragging:te,isOver:R,metadata:re,onSelect:()=>C(P),onRemove:()=>I(P)})})]},P)}),S===p.length&&Z.tabDropPreview&&jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsx("div",{className:Z.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:"translateX(-100%)"}})})]})})};st.Tab=Ee;var Jt=({className:e,style:t,children:n})=>jsx("div",{className:e,style:t,children:n});var Ye=createContext(void 0),qt=()=>{let e=useContext(Ye);if(!e)throw new Error("usePaneContext must be used within a Pane component");return e},vo=({children:e,className:t,style:n})=>{let{activeTabId:r}=qt(),{classNames:o}=oe(),i=useRef(null),a=useContext(ge);if(!a)throw new Error("PaneContent must be used within a Zeugma provider");let{registerPortalTarget:s,registerRenderCallback:c}=a,u=useMemo(()=>typeof e=="function"?e:()=>e,[e]);return c(r,u),useEffect(()=>{let p=i.current;return s(r,p),()=>{s(r,null);}},[r,s]),jsx("div",{ref:i,id:`zeugma-tab-target-${r}`,className:`${o.tabContentWrapper||""} ${t||""}`.trim(),style:{height:"100%",width:"100%",...n}})},Ce=({id:e,children:t,style:n,locked:r=false})=>{let{layout:o,renderingLayout:i,activeId:a,classNames:s,fullscreenPaneId:c,onFullscreenChange:u,locked:p}=oe(),{removePane:f,updateMetadata:m,selectTab:b,removeTab:C}=ze(),I=useMemo(()=>j(e===a?o:i,e),[o,i,e,a]),Z=I?.id??e,v=I?.tabs??[e],z=I?.activeTabId??e,H=I?.tabsMetadata,y=H?.[e],S=I?.locked??false,P=r||S,w=p||P,re=p||P,$=a!==null&&a!==e&&(!v.includes(a)||v.length>1)&&!re,{attributes:_,listeners:F,setNodeRef:te}=useDraggable({id:e,disabled:w}),R=a!==null&&v.includes(a),U=c===e,L=useMemo(()=>({isDragging:R,isFullscreen:U,toggleFullscreen:()=>u?.(U?null:e),remove:()=>{U&&u?.(null),f(Z);},metadata:y,updateMetadata:D=>{m(e,D);},locked:w,tabs:v,activeTabId:z,selectTab:D=>b(Z,D),removeTab:D=>{U&&D===z&&u?.(null),C(D);},tabsMetadata:H,updateTabMetadata:(D,x)=>{m(D,x);}}),[R,U,u,e,C,y,m,w,v,z,b,Z,H]),J=useMemo(()=>w?{disabled:true}:{...F,..._},[F,_,w]),V=`${s.pane||""} ${P&&s.paneLocked||""}`.trim();return jsx(Ye.Provider,{value:{id:e,...L},children:jsx(Je.Provider,{value:J,children:jsxs("div",{ref:te,id:e,className:V,style:{position:"relative",width:"100%",height:"100%",...n},children:[t,$&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:["top","bottom","left","right"].map(D=>jsx(rt,{id:`drop-${D}-${e}`,position:D,activeClassName:s.dropPreview},D))}),a!==null&&a!==e&&re&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsx(rt,{id:`drop-locked-${e}`,position:"full",activeClassName:s.lockedPreview||""})})]})})})};Ce.Content=vo;Ce.DragHandle=Bt;Ce.Tabs=st;Ce.Tab=Ee;Ce.Controls=Jt;export{Ce as Pane,ot as PaneTree,Hn as Zeugma,qt as usePaneContext,nt as useResizer,un as useZeugma,dn as useZeugmaContext};//# sourceMappingURL=index.js.map
9
+ `,document.head.appendChild(o),t.setAttribute("data-resizing","true");let i=s=>{n(s);},a=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let s=document.getElementById("zeugma-global-cursor-style");s&&s.remove(),document.removeEventListener("pointermove",i),document.removeEventListener("pointerup",a),r();};document.addEventListener("pointermove",i),document.addEventListener("pointerup",a);}function Se(e){try{return JSON.stringify(e)}catch{return ""}}var Ke=createContext(void 0),je=createContext(void 0),ge=createContext(void 0),Qe=createContext(void 0),oe=()=>{let e=useContext(Ke);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},ze=()=>{let e=useContext(je);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e},$e=()=>{let e=useContext(Qe);if(!e)throw new Error("useZeugmaDrag must be used within a Zeugma provider");return e};function pt(e){let t=useRef(null);return useEffect(()=>{if(!e){t.current=null;return}let n=o=>{t.current={x:o.clientX,y:o.clientY};},r=o=>{let i=o.touches[0]||o.changedTouches[0];i&&(t.current={x:i.clientX,y:i.clientY});};return window.addEventListener("pointermove",n,{passive:true}),window.addEventListener("touchmove",r,{passive:true}),()=>{window.removeEventListener("pointermove",n),window.removeEventListener("touchmove",r);}},[e]),t}function ft(e){useEffect(()=>(e?document.body.style.setProperty("cursor","not-allowed","important"):document.body.style.removeProperty("cursor"),()=>{document.body.style.removeProperty("cursor");}),[e]);}function gt(){let[e,t]=useState({}),n=useRef({}),r=useRef(null),o=useRef({}),i=useRef(null),a=useRef(true);useEffect(()=>(a.current=true,()=>{a.current=false;}),[]);let s=useCallback((f,m)=>{a.current&&t(b=>{if(!m){if(!b[f])return b;let C={...b};return delete C[f],C}return b[f]===m?b:{...b,[f]:m}});},[]),c=useCallback((f,m)=>{n.current[f]=m;},[]),d=useCallback(f=>{r.current=f;},[]),p=useCallback((f,m)=>{o.current[f]=m;},[]);return {portalTargets:e,registerPortalTarget:s,registerRenderCallback:c,renderCallbacksRef:n,registerRenderPane:d,renderPaneRef:r,registerTabHeader:p,tabHeadersRef:o,activeIdRef:i}}function cn(e){let t=new Set;function n(r){r&&(r.type==="pane"?r.tabIds.forEach(o=>{t.add(o);}):r.type==="split"&&(n(r.first),n(r.second)));}return n(e),Array.from(t).sort()}function mt(e){return useMemo(()=>cn(e),[e])}function bt(e){let{onDragStart:t,onDragEnd:n}=e,[r,o]=useState(null),[i,a]=useState(null),s=useCallback(d=>{t&&t(d);},[t]),c=useCallback((d,p,f)=>{n&&n(d,p,f);},[n]);return {overTabId:r,setOverTabId:o,overTabPosition:i,setOverTabPosition:a,handleDragStartInternal:s,handleDragEndInternal:c}}function vt(e){let n=useContext(ge)?.registerRenderPane;useEffect(()=>{n&&e&&n(e);},[n,e]);}function le(){return "pane-"+Math.random().toString(36).substring(2,11)}function fe(e,t){if(e===null)return null;if(e.type==="pane")return e.id===t?null:e;let n=fe(e.first,t),r=fe(e.second,t);return n===null?r:r===null?n:{...e,first:n,second:r}}function ce(e,t){if(e===null)return null;if(e.type==="pane"){if(e.tabIds.includes(t)){let o=e.tabIds.filter(s=>s!==t);if(o.length===0)return null;let i=e.activeTabId;e.activeTabId===t&&(i=o[0]);let a={...e.tabsMetadata};return delete a[t],{...e,tabIds:o,activeTabId:i,tabsMetadata:Object.keys(a).length>0?a:void 0}}return e}let n=ce(e.first,t),r=ce(e.second,t);return n===null?r:r===null?n:{...e,first:n,second:r}}function xe(e,t,n,r,o){if(e===null)return typeof o=="string"?{type:"pane",id:le(),tabIds:[o],activeTabId:o}:o;if(e.type==="pane"){if(e.id===t){let i=typeof o=="string"?{type:"pane",id:le(),tabIds:[o],activeTabId:o}:o,a=r==="left"||r==="top";return {type:"split",direction:n,first:a?i:e,second:a?e:i,splitPercentage:50}}return e}return {...e,first:xe(e.first,t,n,r,o)||e.first,second:xe(e.second,t,n,r,o)||e.second}}function dn(e,t){if(e===null)return t;function n(r,o){return r.type==="pane"?{type:"split",direction:o==="row"?"column":"row",splitPercentage:50,first:r,second:t}:{...r,second:n(r.second,r.direction)}}return n(e,null)}function ht(e,t,n,r){if(e===null)return {type:"pane",id:le(),tabIds:[n],activeTabId:n,tabsMetadata:r?{[n]:r}:void 0};let o=t?ee(e,t):null;if(o&&o.type==="pane"){let s=function(c){if(c.type==="pane"&&c.id===t){let d=[...c.tabIds];d.includes(n)||d.push(n);let p=c.tabsMetadata;return r&&(p={...c.tabsMetadata,[n]:r}),{...c,tabIds:d,activeTabId:n,tabsMetadata:p}}return c.type==="split"?{...c,first:s(c.first),second:s(c.second)}:c};return s(e)}let i={type:"pane",id:le(),tabIds:[n],activeTabId:n,tabsMetadata:r?{[n]:r}:void 0};return dn(e,i)}function ve(e,t,n){return e===null?null:e===t?{...e,splitPercentage:n}:e.type==="split"?{...e,first:ve(e.first,t,n)||e.first,second:ve(e.second,t,n)||e.second}:e}function ee(e,t){return e===null?null:e.type==="pane"?e.id===t?e:null:e.type==="split"?ee(e.first,t)??ee(e.second,t):null}function J(e,t){return e===null?null:e.type==="pane"?e.tabIds.includes(t)?e:null:e.type==="split"?J(e.first,t)??J(e.second,t):null}function Tt(e,t){return ee(e,t)??J(e,t)}function Pt(e,t){let n=J(e,t);if(!n)return null;let r=n.tabIds.indexOf(t);return {id:t,paneId:n.id,isActive:n.activeTabId===t,index:r,metadata:n.tabsMetadata?.[t]}}function Rt(e,t){return J(e,t)?.tabsMetadata?.[t]}function xt(e,t){let n=ee(e,t);return n?.tabsMetadata?.[n.activeTabId]}function He(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.tabIds.includes(t)){let r=e.tabsMetadata||{},o=r[t],i=n(o),a={...r};return i===void 0?delete a[t]:a[t]=i,{...e,tabsMetadata:Object.keys(a).length>0?a:void 0}}return e}return e.type==="split"?{...e,first:He(e.first,t,n)??e.first,second:He(e.second,t,n)??e.second}:e}function Oe(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.id===t){if(n===false){let{locked:r,...o}=e;return o}return {...e,locked:n}}return e}return e.type==="split"?{...e,first:Oe(e.first,t,n)??e.first,second:Oe(e.second,t,n)??e.second}:e}function ye(e,t,n){return e===null?null:e.type==="pane"?e.id===t?e.activeTabId===n?e:{...e,activeTabId:n}:e:e.type==="split"?{...e,first:ye(e.first,t,n)??e.first,second:ye(e.second,t,n)??e.second}:e}function yt(e,t,n){if(e===null)return null;let o=J(e,t)?.tabsMetadata?.[t],i=ce(e,t);if(i===null)return {type:"pane",id:le(),tabIds:[t],activeTabId:t,tabsMetadata:o?{[t]:o}:void 0};function a(s){if(s.type==="pane"){if(s.id===n){let c=[...s.tabIds];c.includes(t)||c.push(t);let d={...s.tabsMetadata};return o&&(d[t]=o),{...s,tabIds:c,activeTabId:t,tabsMetadata:Object.keys(d).length>0?d:void 0}}return s}return s.type==="split"?{...s,first:a(s.first),second:a(s.second)}:s}return a(i)}function Fe(e,t,n,r="before"){if(e===null)return null;let i=J(e,t)?.tabsMetadata?.[t],a=ce(e,t);if(a===null)return {type:"pane",id:le(),tabIds:[t],activeTabId:t,tabsMetadata:i?{[t]:i}:void 0};function s(c){if(c.type==="pane"){if(c.tabIds.includes(n)){let p=[...c.tabIds].filter(b=>b!==t),f=p.indexOf(n);f<0&&(f=0),r==="after"&&(f+=1),p.splice(f,0,t);let m={...c.tabsMetadata};return i&&(m[t]=i),{...c,tabIds:p,activeTabId:t,tabsMetadata:Object.keys(m).length>0?m:void 0}}return c}return c.type==="split"?{...c,first:s(c.first),second:s(c.second)}:c}return s(a)}function pe(e,t=0,n=0,r=100,o=100,i="root"){if(e===null)return {panes:[],splitters:[]};if(e.type==="pane")return {panes:[{paneId:e.id,left:t,top:n,width:r,height:o,node:e}],splitters:[]};let{direction:a,splitPercentage:s,first:c,second:d}=e,f={id:`splitter-${i}-${a}`,currentNode:e,direction:a,left:a==="row"?t+r*(s/100):t,top:a==="column"?n+o*(s/100):n,width:a==="row"?0:r,height:a==="column"?0:o,parentLeft:t,parentTop:n,parentWidth:r,parentHeight:o},m={panes:[],splitters:[]},b={panes:[],splitters:[]};if(a==="row"){let C=r*(s/100);m=pe(c,t,n,C,o,`${i}-L`),b=pe(d,t+C,n,r-C,o,`${i}-R`);}else {let C=o*(s/100);m=pe(c,t,n,r,C,`${i}-T`),b=pe(d,t,n+C,r,o-C,`${i}-B`);}return {panes:[...m.panes,...b.panes],splitters:[f,...m.splitters,...b.splitters]}}function Dt(e,t,n,r){if(!(t==="tab"&&n&&e.includes(n))||!r)return -1;let a=e.indexOf(n);return r==="before"?a:a+1}function un(e){let{initialLayout:t,layout:n,onChange:r,fullscreenPaneId:o,onFullscreenChange:i,locked:a=false}=e,[s,c]=useState(()=>n!==void 0?n:t??null),[d,p]=useState(()=>n!==void 0?n:t??null),[f,m]=useState(()=>Se(n!==void 0?n:null)),[b,C]=useState(o||null),[N,Z]=useState(a),[v,z]=useState(null),[H,y]=useState(null),[S,T]=useState(null),I=useRef(null),re=useCallback(l=>{I.current=l;},[]),$=useRef(s);$.current=s;let _=useRef(r);_.current=r;let B=useRef(i);B.current=i;let te=useCallback(l=>{C(l),B.current?.(l);},[]);if(useEffect(()=>{Z(a);},[a]),useEffect(()=>{o!==void 0&&C(o);},[o]),n!==void 0){let l=Se(n);l!==f&&(m(l),c(n),p(n));}let R=useCallback(l=>(...g)=>{let A=$.current,M=l(A,...g);Se(A)!==Se(M)&&($.current=M,c(M),p(M),_.current?.(M));},[]),U=useCallback(R((l,g)=>typeof g=="function"?g(l):g),[R]),L=useCallback(l=>{p(g=>typeof l=="function"?l(g):l);},[]),Y=useCallback(l=>{C(null),B.current?.(null),z(null),y(null),T(null),U(l),p(()=>typeof l=="function"?l($.current):l);},[U]),V=useCallback(R((l,g)=>fe(l,g)),[R]),D=useCallback(R((l,g,A,M)=>{let q=ce(l,g)??l;return ht(q,A,g,M)}),[R]),x=useCallback(R((l,g,A,M,q)=>{let W=ee(l,g)??J(l,g);if(!W)return l;let de=ee(l,q)??J(l,q)??{type:"pane",id:q,tabIds:[q],activeTabId:q},j=fe(l,q);return xe(j,W.id,A,M,de)}),[R]),u=useCallback(R((l,g,A)=>ve(l,g,A)),[R]),O=useCallback(R((l,g,A)=>He(l,g,A)),[R]),E=useCallback(R((l,g,A)=>{let M=ee(l,g)??J(l,g);return M?Oe(l,M.id,A):l}),[R]),P=useCallback(R((l,g,A)=>{let M=ee(l,g)??J(l,g);return M?ye(l,M.id,A):l}),[R]),ae=useCallback(R((l,g,A)=>{let M=ee(l,A)??J(l,A);return M?yt(l,g,M.id):l}),[R]),G=useCallback(R((l,g,A,M)=>Fe(l,g,A,M)),[R]),X=useCallback(R((l,g)=>ce(l,g)),[R]),K=useCallback(l=>ee($.current,l),[]),ne=useCallback(l=>J($.current,l),[]),h=useCallback(l=>Pt($.current,l),[]),w=useCallback(l=>Rt($.current,l),[]),k=useCallback(l=>xt($.current,l),[]);return {layout:s,setLayout:Y,_internalSetLayout:L,renderingLayout:d,fullscreenPaneId:b,setFullscreenPaneId:te,locked:N,setLocked:Z,activeId:v,setActiveId:z,activeType:H,setActiveType:y,dismissIntentId:S,setDismissIntentId:T,containerRef:I,setContainerRef:re,removePane:V,addTab:D,updateMetadata:O,updatePaneLock:E,selectTab:P,mergeTab:ae,moveTab:G,removeTab:X,splitPane:x,updateSplitPercentage:u,findPaneById:K,findPaneContainingTab:ne,findTabById:h,getTabMetadata:w,getActiveTabMetadata:k}}var pn=()=>{let e=oe(),t=ze();return {layout:e.layout,setLayout:e.setLayout,fullscreenPaneId:e.fullscreenPaneId,setFullscreenPaneId:t.setFullscreenPaneId,locked:e.locked,setLocked:t.setLocked,removePane:t.removePane,addTab:t.addTab,updateMetadata:t.updateMetadata,updatePaneLock:t.updatePaneLock,selectTab:t.selectTab,mergeTab:t.mergeTab,removeTab:t.removeTab,splitPane:t.splitPane,updateSplitPercentage:t.updateSplitPercentage,moveTab:t.moveTab,findPaneById:e.findPaneById,findPaneContainingTab:e.findPaneContainingTab,findTabById:e.findTabById,getTabMetadata:e.getTabMetadata,getActiveTabMetadata:e.getActiveTabMetadata}};var Ve=class extends PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},We=class extends TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};var St=e=>{let n=e.active.id.toString().startsWith("tab-header-"),r=pointerWithin(e),o=n?r:r.filter(i=>!i.id.toString().startsWith("tab-drop-"));if(o.length>0)return [...o].sort((a,s)=>{let c=a.id.toString(),d=s.id.toString();if(n){let m=c.startsWith("tab-drop-"),b=d.startsWith("tab-drop-");if(m&&!b)return -1;if(!m&&b)return 1}let p=c.startsWith("drop-root-"),f=d.startsWith("drop-root-");return p&&!f?-1:!p&&f?1:0});if(n){let i=e.droppableContainers.filter(a=>a.id.toString().startsWith("tab-drop-"));return closestCenter({...e,droppableContainers:i})}return []};function Ue(e){if(e instanceof MouseEvent||e instanceof PointerEvent)return {x:e.clientX,y:e.clientY};if(typeof TouchEvent<"u"&&e instanceof TouchEvent){let t=e.touches[0]||e.changedTouches[0];if(t)return {x:t.clientX,y:t.clientY}}return null}function Nt(e){let{layout:t,_internalSetLayout:n,setLayout:r,activeId:o,setActiveId:i,setActiveType:a,dismissIntentId:s,setDismissIntentId:c,setOverTabId:d,setOverTabPosition:p,containerRef:f,dragActivationDistance:m,enableDragToDismiss:b,dismissThreshold:C,onRemove:N,onDragStart:Z,onDragEnd:v,onDismissIntentChange:z,removeTab:H,removePane:y}=e,S=useRef(null),T=pt(o),I=useRef(null),[re,$]=useState(false);return ft(re),{sensors:useSensors(useSensor(Ve,{activationConstraint:{distance:m}}),useSensor(We,{activationConstraint:{delay:250,tolerance:5}})),collisionDetection:St,onDragStart:L=>{let Y=L.active.id.toString(),V=Y.startsWith("tab-header-"),D=V?Y.substring(11):Y;i(D),a(V?"tab":"pane"),d(null),p(null);let x=L.activatorEvent;T.current=Ue(x),b&&f.current?S.current=f.current.getBoundingClientRect():S.current=null;let u=t;if(V){let E=J(t,D);E&&(u=ye(t,E.id,D)||t);}I.current=u;let O=V?ce(u,D):fe(u,D);n(O),Z&&Z(D);},onDragMove:L=>{let{over:Y}=L,V=Y?.id.toString()||"",D=V.startsWith("drop-locked-");$(h=>h===D?h:D);let x=L.active.id.toString(),u=x.startsWith("tab-header-"),O=u?x.substring(11):x,E=V.match(/^tab-drop-(.+)$/);if(E&&Y&&u){let[,h]=E;if(O!==h){let w="before",k=Y.rect,se=L.activatorEvent,l=null;if(T.current)l=T.current.x;else {let g=Ue(se);g&&(l=g.x+L.delta.x);}if(l!==null){let g=k.left+k.width/2;l>g&&(w="after");}d(g=>g===h?g:h),p(g=>g===w?g:w);}else d(w=>w===null?w:null),p(w=>w===null?w:null);}else d(h=>h===null?h:null),p(h=>h===null?h:null);if(!b)return;let P=S.current;if(!P){s!==null&&(c(null),z?.(null));return}let ae=L.activatorEvent,G=null,X=null;if(T.current)G=T.current.x,X=T.current.y;else {let h=Ue(ae);h&&(G=h.x+L.delta.x,X=h.y+L.delta.y);}let K=0;if(G!==null&&X!==null){let h=0,w=0;G<P.left?h=P.left-G:G>P.right&&(h=G-P.right),X<P.top?w=P.top-X:X>P.bottom&&(w=X-P.bottom),K=Math.sqrt(h*h+w*w);}else {let h=L.active.rect.current.translated;if(h){let w=h.left+h.width/2,k=h.top+h.height/2,se=0,l=0;w<P.left?se=P.left-w:w>P.right&&(se=w-P.right),k<P.top?l=P.top-k:k>P.bottom&&(l=k-P.bottom),K=Math.sqrt(se*se+l*l);}}K>C?s!==O&&(c(O),z?.(O)):s!==null&&(c(null),z?.(null));},onDragEnd:L=>{i(null),a(null),$(false),d(null),p(null);let{active:Y,over:V}=L,D=Y.id.toString(),x=D.startsWith("tab-header-"),u=x?D.substring(11):D,O=b&&s===u;c(null),z?.(null),S.current=null;let E=I.current||t;if(I.current=null,O){N?N(u):x?H(u):y(u),v&&v(u,null,null);return}if(!V){n(E),v&&v(u,null,null);return}let P=V.id.toString();if(P.startsWith("drop-locked-")){n(E),v&&v(u,null,null);return}let ae=P.match(/^tab-drop-(.+)$/);if(ae){if(!x){n(E),v&&v(u,null,null);return}let[,M]=ae;if(u!==M){let q="before",W=V.rect,de=L.activatorEvent,j=null;if(T.current)j=T.current.x;else {let Q=Ue(de);Q&&(j=Q.x+L.delta.x);}if(j!==null){let Q=W.left+W.width/2;j>Q&&(q="after");}let be=Fe(E,u,M,q);r(be),v&&v(u,M,{type:"move",position:"center"});}else n(E),v&&v(u,null,null);return}let G=P.match(/^drop-root-(1\/4|1\/3)-(top|bottom|left|right|start|end)$/);if(G){let[,M,q]=G,W=q;W==="start"&&(W="left"),W==="end"&&(W="right");let de=x?ce(E,u):fe(E,u),j;if(x){let Q=J(E,u)?.tabsMetadata?.[u];j={type:"pane",id:le(),tabIds:[u],activeTabId:u,tabsMetadata:Q?{[u]:Q}:void 0};}else j=ee(E,u)??{type:"pane",id:le(),tabIds:[u],activeTabId:u};if(de===null)r(j);else {let be=W==="left"||W==="right",Q=W==="left"||W==="top",Te=50;M==="1/4"?Te=Q?25:75:M==="1/3"&&(Te=Q?100/3:200/3),r({type:"split",direction:be?"row":"column",first:Q?j:de,second:Q?de:j,splitPercentage:Te});}v&&v(u,"root",{type:"split",direction:W==="left"||W==="right"?"row":"column",position:W});return}let X=P.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!X){n(E),v&&v(u,null,null);return}let[,K,ne]=X,h=x?J(E,u):ee(E,u),w=h&&h.id===ne,k=h&&h.tabIds.length===1;if(u===ne||w&&k){n(E),v&&v(u,null,null);return}let se=K==="left"||K==="right"?"row":"column",l;if(x){let q=J(E,u)?.tabsMetadata?.[u];l={type:"pane",id:le(),tabIds:[u],activeTabId:u,tabsMetadata:q?{[u]:q}:void 0};}else l=ee(E,u)??{type:"pane",id:le(),tabIds:[u],activeTabId:u};let g=x?ce(E,u):fe(E,u),A=xe(g,ne,se,K,l);r(A),v&&v(u,ne,{type:"split",direction:se,position:K});},onDragCancel:()=>{i(null),a(null),$(false),d(null),p(null),c(null),z?.(null),S.current=null;let L=I.current||t;I.current=null,n(L),L!==t&&r(L);}}}function Mt({persist:e,layout:t,setLayout:n}){let r=typeof e=="object"?e.enabled!==false:!!e,o=typeof e=="object"&&e.key||"zeugma-layout",[i,a]=useState(false);useEffect(()=>{if(r){let s=localStorage.getItem(o);if(s)try{let c=JSON.parse(s);c&&n(c);}catch(c){console.error("Failed to parse persisted zeugma layout",c);}}a(true);},[r,o,n]),useEffect(()=>{r&&i&&(t?localStorage.setItem(o,JSON.stringify(t)):localStorage.removeItem(o));},[r,o,t,i]);}var Lt=({activeId:e,render:t,className:n})=>{let r=useRef(null);return useEffect(()=>{let o=i=>{r.current&&(r.current.style.transform=`translate(${i.clientX+12}px, ${i.clientY+12}px)`);};return document.addEventListener("pointermove",o),()=>document.removeEventListener("pointermove",o)},[]),jsx("div",{ref:r,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var Zt=yn.memo(({tabDetails:e,target:t,renderWidget:n})=>{let{id:r}=e,[o,i]=useState(false),a=useRef(null);if(useEffect(()=>{i(true);},[]),useEffect(()=>{if(!o||!a.current)return;let c=a.current;if(t)t.appendChild(c);else {let d=document.getElementById("zeugma-hidden-portal-container");d||(d=document.createElement("div"),d.id="zeugma-hidden-portal-container",d.style.display="none",document.body.appendChild(d)),d.appendChild(c);}},[t,o]),useEffect(()=>()=>{a.current&&a.current.remove();},[]),!o)return null;a.current||(a.current=document.createElement("div"),a.current.className=`zeugma-portal-wrapper-${r}`,a.current.style.width="100%",a.current.style.height="100%");let s=a.current;return !s||!n?null:createPortal(n(e),s)},(e,t)=>e.target===t.target&&e.renderWidget===t.renderWidget&&e.tabDetails.id===t.tabDetails.id&&e.tabDetails.paneId===t.tabDetails.paneId&&e.tabDetails.isActive===t.tabDetails.isActive&&e.tabDetails.index===t.tabDetails.index&&e.tabDetails.metadata===t.tabDetails.metadata);var kt=({activeId:e,activeType:t,dismissIntentId:n,renderDragOverlay:r,renderPaneRef:o,renderPane:i,tabHeadersRef:a,classNames:s})=>{if(r)return jsx(Fragment,{children:r({type:t,id:e,isDismissing:e===n})});if(t==="pane"){let c=o.current||i;if(c)return jsx("div",{className:s.paneDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:c(e)})}else if(t==="tab"){let c=o.current||i;if(c)return jsx("div",{className:s.tabDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:c(e)});let d=a.current[e];if(d){let p=s.tab?typeof s.tab=="function"?s.tab(e):s.tab:"";return jsx("div",{className:`${s.tabDragPreview||""} ${p}`.trim(),style:{display:"inline-flex",position:"relative",pointerEvents:"none",overflow:"hidden",width:"420px",height:"260px"},children:d({isDragging:true,isOver:false})})}}return jsx("div",{style:{pointerEvents:"none",overflow:"hidden",width:"100%",height:"100%"}})};function nt({containerRef:e,isRow:t,direction:n,splitPercentage:r,resizerSize:o,snapThreshold:i,layout:a,currentNode:s,onLayoutChange:c,onResizeStart:d,onResizeEnd:p,parentLeft:f,parentTop:m,parentWidth:b,parentHeight:C}){let{onResizeStart:N,onResize:Z,onResizeEnd:v,minSplitPercentage:z=5,maxSplitPercentage:H=95,locked:y=false}=oe();return useCallback(S=>{if(y)return;S.preventDefault();let T=e.current;if(!T)return;d&&d(),N&&N(s);let I=T.getBoundingClientRect(),re=S.clientX,$=S.clientY,_=r,B=S.currentTarget,te=I.left+I.width*(f/100),R=I.top+I.height*(m/100),U=I.width*(b/100),L=I.height*(C/100),V=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(x=>x!==B&&x.getAttribute("data-direction")===n).map(x=>{let u=x.getBoundingClientRect();return t?u.left+u.width/2:u.top+u.height/2}),D=_;ut({cursor:t?"col-resize":"row-resize",resizerEl:B,onMove:x=>{let u=t?(x.clientX-re)/U*100:(x.clientY-$)/L*100,O=_+u,E=t?te+(U-o)*(O/100)+o/2:R+(L-o)*(O/100)+o/2,P=1/0,ae=null;for(let ne of V){let h=Math.abs(E-ne);h<i&&h<P&&(P=h,ae=ne);}let G=O;ae!==null&&(G=t?(ae-o/2-te)/(U-o)*100:(ae-o/2-R)/(L-o)*100);let X=Math.max(z,Math.min(H,G));D=X;let K=ve(a,s,X);if(K){let{panes:ne,splitters:h}=pe(K),w=e.current;if(w){for(let k of ne)w.style.setProperty(`--pane-left-${k.paneId}`,`${k.left}%`),w.style.setProperty(`--pane-top-${k.paneId}`,`${k.top}%`),w.style.setProperty(`--pane-width-${k.paneId}`,`${k.width}%`),w.style.setProperty(`--pane-height-${k.paneId}`,`${k.height}%`);for(let k of h)w.style.setProperty(`--splitter-pos-${k.id}`,`${k.direction==="row"?k.left:k.top}%`);}}Z&&Z(s,X);},onEnd:()=>{let x=ve(a,s,D),u=e.current;if(u){let{panes:O,splitters:E}=pe(x);for(let P of O)u.style.removeProperty(`--pane-left-${P.paneId}`),u.style.removeProperty(`--pane-top-${P.paneId}`),u.style.removeProperty(`--pane-width-${P.paneId}`),u.style.removeProperty(`--pane-height-${P.paneId}`);for(let P of E)u.style.removeProperty(`--splitter-pos-${P.id}`);}c(x),p&&p(),v&&v(s,D);}});},[e,t,n,r,o,i,a,s,c,d,p,N,Z,v,z,H,f,m,b,C])}var zt=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:r})=>{let{renderingLayout:o,setLayout:i,classNames:a,locked:s}=oe(),[c,d]=useState(false),{currentNode:p,direction:f,left:m,top:b,width:C,height:N,parentLeft:Z,parentTop:v,parentWidth:z,parentHeight:H}=e,y=f==="row",S=nt({containerRef:r,isRow:y,direction:f,splitPercentage:p.splitPercentage,resizerSize:t,snapThreshold:n,layout:o,currentNode:p,onLayoutChange:i,onResizeStart:()=>d(true),onResizeEnd:()=>d(false),parentLeft:Z,parentTop:v,parentWidth:z,parentHeight:H}),T=y?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${m}%) - ${t/2}px)`,top:`calc(${b}% + ${t/2}px)`,width:`${t}px`,height:`calc(${N}% - ${t}px)`,cursor:s?"default":"col-resize",pointerEvents:s?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`calc(${m}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${b}%) - ${t/2}px)`,width:`calc(${C}% - ${t}px)`,height:`${t}px`,cursor:s?"default":"row-resize",pointerEvents:s?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"};return jsx("div",{className:a.resizer||"","data-direction":f,"data-resizing":c||void 0,style:T,onPointerDown:S,role:"separator","aria-valuenow":p.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},$t=yn.memo(({paneId:e,renderPane:t})=>jsx(Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane);var ot=({renderPane:e,tree:t,resizerSize:n,snapThreshold:r})=>{vt(e);let{renderingLayout:o,activeId:i,dismissIntentId:a,setContainerRef:s,fullscreenPaneId:c,snapThreshold:d,locked:p,classNames:f,resizerSize:m}=oe(),b=r!==void 0?r:d??8,C=n!==void 0?n:m??4,N=t!==void 0?t:o,Z=useRef(null),{panes:v,splitters:z}=useMemo(()=>N?pe(N):{panes:[],splitters:[]},[N]);if(!N&&t!==void 0)return null;let H=()=>jsxs(Fragment,{children:[v.map(y=>{let S=c===y.paneId;return jsx("div",{style:{position:"absolute",left:S?"0%":`var(--pane-left-${y.paneId}, ${y.left}%)`,top:S?"0%":`var(--pane-top-${y.paneId}, ${y.top}%)`,width:S?"100%":`var(--pane-width-${y.paneId}, ${y.width}%)`,height:S?"100%":`var(--pane-height-${y.paneId}, ${y.height}%)`,overflow:"hidden",zIndex:S?20:1,display:c&&!S?"none":"block",padding:S?"0px":`${C/2}px`,boxSizing:"border-box"},children:jsx($t,{paneId:y.paneId,renderPane:e})},y.paneId)}),!c&&z.map(y=>jsx(zt,{splitter:y,resizerSize:C,snapThreshold:b,containerRef:Z},y.id))]});if(t===void 0){let y=i!==null&&i===a,S=I=>{s(I),Z.current=I;},T=`${f.dashboard||""} ${y&&f.dashboardDismissActive||""} ${p&&f.dashboardLocked||""}`.trim();return jsxs("div",{ref:S,className:T,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[H(),i!==null&&!p&&jsx(Ot,{activeClassName:f.rootDropPreview??f.dropPreview})]})}return jsx("div",{ref:Z,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:H()})};var An=e=>{let{controller:t,children:n,renderDragOverlay:r,classNames:o={},renderPane:i,resizerSize:a,dragActivationDistance:s=8,snapThreshold:c=8,minSplitPercentage:d=5,maxSplitPercentage:p=95,enableDragToDismiss:f=false,dismissThreshold:m=60,onRemove:b,onDragStart:C,onDragEnd:N,onResizeStart:Z,onResize:v,onResizeEnd:z,onDismissIntentChange:H,persist:y=false}=e,S=t,{layout:T,setLayout:I,_internalSetLayout:re,renderingLayout:$,fullscreenPaneId:_,setFullscreenPaneId:B,locked:te,setLocked:R,findPaneById:U,findPaneContainingTab:L,findTabById:Y,getTabMetadata:V,getActiveTabMetadata:D,activeId:x,setActiveId:u,activeType:O,setActiveType:E,dismissIntentId:P,setDismissIntentId:ae,containerRef:G,setContainerRef:X,removePane:K,addTab:ne,updateMetadata:h,updatePaneLock:w,selectTab:k,mergeTab:se,removeTab:l,splitPane:g,updateSplitPercentage:A,moveTab:M}=S;Mt({persist:y,layout:T,setLayout:I});let{portalTargets:q,registerPortalTarget:W,registerRenderCallback:de,renderCallbacksRef:j,registerRenderPane:be,renderPaneRef:Q,registerTabHeader:Te,tabHeadersRef:Me,activeIdRef:Le}=gt(),{overTabId:it,setOverTabId:Gt,overTabPosition:lt,setOverTabPosition:Kt,handleDragStartInternal:jt,handleDragEndInternal:Qt}=bt({onDragStart:C,onDragEnd:N}),en=Nt({layout:T,_internalSetLayout:re,setLayout:I,activeId:x,setActiveId:u,setActiveType:E,dismissIntentId:P,setDismissIntentId:ae,setOverTabId:Gt,setOverTabPosition:Kt,containerRef:G,dragActivationDistance:s,enableDragToDismiss:f,dismissThreshold:m,onRemove:b,onDragStart:jt,onDragEnd:Qt,onDismissIntentChange:H,removeTab:l,removePane:K}),_e=useMemo(()=>o,[o.dashboard,o.dashboardDismissActive,o.pane,o.paneLocked,o.dropPreview,o.rootDropPreview,o.dragOverlay,o.paneDragPreview,o.tabDragPreview,o.resizer,o.dismissPreview,o.dashboardLocked,o.lockedPreview,o.tabDropPreview,o.tabSeparator,o.tabsContainer,o.tab,o.paneContainer,o.paneHeader,o.paneControls,o.paneButton,o.tabCloseButton,o.dragHandle]),ct=useCallback((ue,Ze)=>{z&&z(ue,Ze);},[z]),tn=useMemo(()=>({layout:T,renderingLayout:$,setLayout:I,activeId:x,activeType:O,dismissIntentId:P,setContainerRef:X,fullscreenPaneId:_,classNames:_e,onRemove:b,onFullscreenChange:B,snapThreshold:c,onResizeStart:Z,onResize:v,onResizeEnd:ct,minSplitPercentage:d,maxSplitPercentage:p,locked:te,setLocked:R,findPaneById:U,findPaneContainingTab:L,findTabById:Y,getTabMetadata:V,getActiveTabMetadata:D,renderPane:i,resizerSize:a}),[T,$,x,O,P,X,_,_e,b,B,c,Z,v,d,p,I,ct,te,R,U,L,Y,V,D,i,a]),nn=useMemo(()=>({overTabId:it,overTabPosition:lt}),[it,lt]),on=useMemo(()=>({removePane:K,addTab:ne,updateMetadata:h,updatePaneLock:w,selectTab:k,mergeTab:se,removeTab:l,setFullscreenPaneId:B,setLocked:R,splitPane:g,updateSplitPercentage:A,moveTab:M}),[K,ne,h,w,k,se,l,B,R,g,A,M]),rn=mt(T),an=useMemo(()=>({registerPortalTarget:W,registerRenderCallback:de,renderCallbacksRef:j,registerRenderPane:be,renderPaneRef:Q,registerTabHeader:Te,tabHeadersRef:Me,activeIdRef:Le}),[W,de,j,be,Q,Te,Me,Le]);return Le&&(Le.current=x),jsx(je.Provider,{value:on,children:jsx(Ke.Provider,{value:tn,children:jsx(Qe.Provider,{value:nn,children:jsxs(ge.Provider,{value:an,children:[jsx(DndContext,{id:"zeugma-dnd-context",...en,children:n}),x&&O&&jsx(Lt,{activeId:x,render:ue=>jsx("div",{style:{transition:"transform 150ms cubic-bezier(0.2, 0, 0, 1)",transform:ue===P?"scale(0.8)":"scale(1)",transformOrigin:"top left"},children:jsx(kt,{activeId:ue,activeType:O,dismissIntentId:P,renderDragOverlay:r,renderPaneRef:Q,renderPane:i,tabHeadersRef:Me,classNames:_e})}),className:`${o.dragOverlay||""} ${x===P&&o.dismissPreview||""}`.trim()}),jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:rn.map(ue=>{let Ze=q[ue],dt=Y(ue);return dt?jsx(Zt,{tabDetails:dt,target:Ze||null,renderWidget:j.current[ue]},ue):null})})]})})})})},Hn=({renderPane:e,resizerSize:t,snapThreshold:n})=>{if(!e)throw new Error("Zeugma component requires a renderPane prop when used as a standalone renderer.");return jsx(ot,{renderPane:e,resizerSize:t,snapThreshold:n})},On=e=>{let{children:t,...n}=e,{controller:r}=e;if(!r)throw new Error("Zeugma component requires a controller.");return jsx(An,{...e,children:t!==void 0?t:jsx(Hn,{...n})})};var Vn={top:{"1/4":{position:"absolute",top:0,left:0,width:"100%",height:"24px",zIndex:100,pointerEvents:"auto"},"1/3":{position:"absolute",top:"24px",left:0,width:"100%",height:"24px",zIndex:100,pointerEvents:"auto"}},bottom:{"1/4":{position:"absolute",bottom:0,left:0,width:"100%",height:"24px",zIndex:100,pointerEvents:"auto"},"1/3":{position:"absolute",bottom:"24px",left:0,width:"100%",height:"24px",zIndex:100,pointerEvents:"auto"}},left:{"1/4":{position:"absolute",left:0,top:"48px",width:"24px",height:"calc(100% - 96px)",zIndex:100,pointerEvents:"auto"},"1/3":{position:"absolute",left:"24px",top:"48px",width:"24px",height:"calc(100% - 96px)",zIndex:100,pointerEvents:"auto"}},right:{"1/4":{position:"absolute",right:0,top:"48px",width:"24px",height:"calc(100% - 96px)",zIndex:100,pointerEvents:"auto"},"1/3":{position:"absolute",right:"24px",top:"48px",width:"24px",height:"calc(100% - 96px)",zIndex:100,pointerEvents:"auto"}}},Wn={top:{"1/4":{top:0,left:0,width:"100%",height:"60px",borderBottomLeftRadius:"12px",borderBottomRightRadius:"12px",borderTopLeftRadius:"0px",borderTopRightRadius:"0px"},"1/3":{top:0,left:0,width:"100%",height:"96px",borderBottomLeftRadius:"12px",borderBottomRightRadius:"12px",borderTopLeftRadius:"0px",borderTopRightRadius:"0px"}},bottom:{"1/4":{bottom:0,left:0,width:"100%",height:"60px",borderTopLeftRadius:"12px",borderTopRightRadius:"12px",borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},"1/3":{bottom:0,left:0,width:"100%",height:"96px",borderTopLeftRadius:"12px",borderTopRightRadius:"12px",borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"}},left:{"1/4":{left:0,top:0,width:"60px",height:"100%",borderTopRightRadius:"12px",borderBottomRightRadius:"12px",borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"},"1/3":{left:0,top:0,width:"96px",height:"100%",borderTopRightRadius:"12px",borderBottomRightRadius:"12px",borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"}},right:{"1/4":{right:0,top:0,width:"60px",height:"100%",borderTopLeftRadius:"12px",borderBottomLeftRadius:"12px",borderTopRightRadius:"0px",borderBottomRightRadius:"0px"},"1/3":{right:0,top:0,width:"96px",height:"100%",borderTopLeftRadius:"12px",borderBottomLeftRadius:"12px",borderTopRightRadius:"0px",borderBottomRightRadius:"0px"}}},Un=({id:e,fraction:t,edge:n,activeClassName:r})=>{let{setNodeRef:o,isOver:i}=useDroppable({id:e}),a={position:"absolute",pointerEvents:"none",zIndex:101,boxSizing:"border-box",...Wn[n][t]};return jsxs(Fragment,{children:[jsx("div",{ref:o,style:Vn[n][t]}),i&&jsx("div",{className:r,style:a})]})},Ot=({activeClassName:e})=>jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:99,pointerEvents:"none"},children:[{id:"drop-root-1/4-top",fraction:"1/4",edge:"top"},{id:"drop-root-1/3-top",fraction:"1/3",edge:"top"},{id:"drop-root-1/4-bottom",fraction:"1/4",edge:"bottom"},{id:"drop-root-1/3-bottom",fraction:"1/3",edge:"bottom"},{id:"drop-root-1/4-left",fraction:"1/4",edge:"left"},{id:"drop-root-1/3-left",fraction:"1/3",edge:"left"},{id:"drop-root-1/4-right",fraction:"1/4",edge:"right"},{id:"drop-root-1/3-right",fraction:"1/3",edge:"right"}].map(n=>jsx(Un,{id:n.id,fraction:n.fraction,edge:n.edge,activeClassName:e},n.id))});var Je=createContext(null);var _n={top:{position:"absolute",top:0,left:0,width:"100%",height:"25%",zIndex:20,pointerEvents:"auto"},bottom:{position:"absolute",bottom:0,left:0,width:"100%",height:"25%",zIndex:20,pointerEvents:"auto"},left:{position:"absolute",top:"25%",left:0,width:"50%",height:"50%",zIndex:20,pointerEvents:"auto"},right:{position:"absolute",top:"25%",right:0,width:"50%",height:"50%",zIndex:20,pointerEvents:"auto"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:20,pointerEvents:"auto",cursor:"not-allowed"}},Gn={top:{position:"absolute",top:0,left:0,right:0,height:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},bottom:{position:"absolute",bottom:0,left:0,right:0,height:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},left:{position:"absolute",top:0,bottom:0,left:0,width:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},right:{position:"absolute",top:0,bottom:0,right:0,width:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:21,pointerEvents:"none",boxSizing:"border-box"}},rt=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:r,isOver:o}=useDroppable({id:e});return jsxs(Fragment,{children:[jsx("div",{ref:r,style:_n[t]}),o&&jsx("div",{className:n,style:Gn[t]})]})};var Bt=({children:e,className:t,style:n})=>{let r=useContext(Je);if(!r)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:o,...i}=r;return jsx("div",{className:t,style:{cursor:o?"default":"grab",userSelect:o?"auto":"none",touchAction:o?"auto":"none",...n},...o?{}:i,children:e})};var so=createContext(void 0);var Ee=({id:e,locked:t=false,children:n,className:r,style:o})=>{let{locked:i,classNames:a={},activeType:s}=oe(),{overTabId:c}=$e(),d=useContext(ge);useEffect(()=>(d?.registerTabHeader&&d.registerTabHeader(e,n),()=>{d?.registerTabHeader&&d.activeIdRef?.current!==e&&d.registerTabHeader(e,()=>null);}),[e,n,d]);let p=useContext(at),f=t||i||(p?.locked??false),{attributes:m,listeners:b,setNodeRef:C,isDragging:N}=useDraggable({id:`tab-header-${e}`,disabled:f}),{setNodeRef:Z,isOver:v}=useDroppable({id:`tab-drop-${e}`,disabled:f||s==="pane"}),z=U=>{C(U),Z(U);},H=v&&c===e,y=p?.tabIds||[],S=y.indexOf(e),T=p?.activeTabId,re=S>0&&e!==T&&y[S-1]!==T?jsx("div",{className:a.tabSeparator}):null,$=p?p.activeTabId===e:false,_=p?.tabsMetadata?.[e],B=useCallback(()=>{p?.selectTab(e);},[p,e]),te=useCallback(()=>{p?.removeTab(e);},[p,e]),R=useMemo(()=>({tabId:e,isActive:$,isDragging:N,isOver:H,metadata:_,locked:f,selectTab:B,removeTab:te}),[e,$,N,H,_,f,B,te]);return jsx(so.Provider,{value:R,children:jsxs("div",{ref:z,id:`tab-header-${e}`,className:r,style:{display:"inline-flex",position:"relative",cursor:f?"default":"grab",...o},...f?{}:b,...f?{}:m,children:[re,n({isDragging:N,isOver:H})]})})};var at=createContext(void 0);var Xt=(e,t)=>typeof e=="function"?e(t):e,st=({tabIds:e,activeTabId:t,locked:n,tabsMetadata:r,selectTab:o,removeTab:i,renderTab:a,classNames:s,styles:c})=>{let d=useContext(Ye),p=e??d?.tabIds??[],f=t??d?.activeTabId??"",m=n??d?.locked??false,b=r??d?.tabsMetadata,C=o??d?.selectTab??(()=>{}),N=i??d?.removeTab??(()=>{}),{classNames:Z={},activeType:v}=oe(),{overTabId:z,overTabPosition:H}=$e(),y=useMemo(()=>({tabIds:p,activeTabId:f,locked:m,tabsMetadata:b,selectTab:C,removeTab:N}),[p,f,m,b,C,N]),S=Dt(p,v,z,H);return jsx(at.Provider,{value:y,children:jsxs("div",{className:s?.container,style:{display:"flex",alignItems:"center",height:"100%",...c?.container},children:[p.map((T,I)=>{let re=b?.[T],$=Xt(s?.tab,T),_=Xt(c?.tab,T),B=I===S;return jsxs(yn.Fragment,{children:[B&&Z.tabDropPreview&&jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsx("div",{className:Z.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:I===0?"none":"translateX(-50%)"}})}),jsx(Ee,{id:T,locked:m,className:$,style:_,children:({isDragging:te,isOver:R})=>a({id:T,paneId:d?.id??"",isActive:T===f,index:I,isDragging:te,isOver:R,metadata:re,onSelect:()=>C(T),onRemove:()=>N(T)})})]},T)}),S===p.length&&Z.tabDropPreview&&jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsx("div",{className:Z.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:"translateX(-100%)"}})})]})})};st.Tab=Ee;var Yt=({className:e,style:t,children:n})=>jsx("div",{className:e,style:t,children:n});var Ye=createContext(void 0),_t=()=>{let e=useContext(Ye);if(!e)throw new Error("usePaneContext must be used within a Pane component");return e},ho=({children:e,className:t,style:n})=>{let{activeTabId:r}=_t(),{classNames:o}=oe(),i=useRef(null),a=useContext(ge);if(!a)throw new Error("PaneContent must be used within a Zeugma provider");let{registerPortalTarget:s,registerRenderCallback:c}=a,d=useMemo(()=>typeof e=="function"?e:()=>e,[e]);return c(r,d),useEffect(()=>{let p=i.current;return s(r,p),()=>{s(r,null);}},[r,s]),jsx("div",{ref:i,id:`zeugma-tab-target-${r}`,className:`${o.tabContentWrapper||""} ${t||""}`.trim(),style:{height:"100%",width:"100%",...n}})},Ce=({id:e,children:t,style:n,locked:r=false})=>{let{layout:o,renderingLayout:i,activeId:a,classNames:s,fullscreenPaneId:c,onFullscreenChange:d,locked:p}=oe(),{removePane:f,updateMetadata:m,selectTab:b,removeTab:C}=ze(),N=useMemo(()=>Tt(e===a?o:i,e),[o,i,e,a]),Z=N?.id??e,v=N?.tabIds??[e],z=N?.activeTabId??e,H=N?.tabsMetadata,y=H?.[e],S=N?.locked??false,T=r||S,I=p||T,re=p||T,$=a!==null&&a!==e&&(!v.includes(a)||v.length>1)&&!re,{attributes:_,listeners:B,setNodeRef:te}=useDraggable({id:e,disabled:I}),R=a!==null&&v.includes(a),U=c===e,L=useMemo(()=>({isDragging:R,isFullscreen:U,toggleFullscreen:()=>d?.(U?null:e),remove:()=>{U&&d?.(null),f(Z);},metadata:y,updateMetadata:D=>{m(e,D);},locked:I,tabIds:v,activeTabId:z,selectTab:D=>b(Z,D),removeTab:D=>{U&&D===z&&d?.(null),C(D);},tabsMetadata:H,updateTabMetadata:(D,x)=>{m(D,x);}}),[R,U,d,e,C,y,m,I,v,z,b,Z,H]),Y=useMemo(()=>I?{disabled:true}:{...B,..._},[B,_,I]),V=`${s.pane||""} ${T&&s.paneLocked||""}`.trim();return jsx(Ye.Provider,{value:{id:e,...L},children:jsx(Je.Provider,{value:Y,children:jsxs("div",{ref:te,id:e,className:V,style:{position:"relative",width:"100%",height:"100%",...n},children:[t,$&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:["top","bottom","left","right"].map(D=>jsx(rt,{id:`drop-${D}-${e}`,position:D,activeClassName:s.dropPreview},D))}),a!==null&&a!==e&&re&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsx(rt,{id:`drop-locked-${e}`,position:"full",activeClassName:s.lockedPreview||""})})]})})})};Ce.Content=ho;Ce.DragHandle=Bt;Ce.Tabs=st;Ce.Tab=Ee;Ce.Controls=Yt;export{Ce as Pane,ot as PaneTree,On as Zeugma,_t as usePaneContext,nt as useResizer,un as useZeugma,pn as useZeugmaContext};//# sourceMappingURL=index.js.map
10
10
  //# sourceMappingURL=index.js.map