react-zeugma 4.1.1 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -132,10 +132,10 @@ A custom state hook that initializes and manages the recursive layout tree and h
132
132
 
133
133
  A custom React context hook that returns the unified layout controller properties and state actions. Must be used within a `<Zeugma>` provider component.
134
134
 
135
- Provides direct access to the current layout state (e.g., `layout`, `locked`) and mutation actions (e.g., `addPane`, `removePane`, `splitPane`, `updateTabMetadata`, etc.).
135
+ Provides direct access to the current layout state (e.g., `layout`, `locked`), state setters (e.g., `setLocked`), queries (e.g., `findTabById`, `findPaneContainingTab`, `findPaneById`), and mutation actions (e.g., `addPane`, `removePane`, `updateTabMetadata`, `removeTab`, `selectTab`, etc.).
136
136
 
137
137
  ```ts
138
- const { layout, locked, addPane, removeTab } = useZeugmaContext()
138
+ const { layout, locked, findTabById, setLocked } = useZeugmaContext()
139
139
  ```
140
140
 
141
141
  ### `<PaneTree>`
@@ -196,7 +196,7 @@ A vertical-resize container wrapper that wraps any node (typically `<PaneTree />
196
196
 
197
197
  ## Tree Utilities
198
198
 
199
- react-zeugma exposes serializable tree utility functions for programmatically mutating layout schemas.
199
+ Import these serializable tree utility functions from `react-zeugma/utils` for programmatically mutating or querying layout schemas.
200
200
 
201
201
  #### `removePane(tree: TreeNode | null, id: string): TreeNode | null`
202
202
 
@@ -210,10 +210,18 @@ Recursively matches the bottommost/rightmost pane leaf in the tree, splits it, a
210
210
 
211
211
  Splits the targeted `targetId` pane inside the tree with `direction` (_row_ / _column_) and type (_left_, _right_, _top_, _bottom_) to insert `paneToAdd`.
212
212
 
213
- #### `findPane(tree: TreeNode | null, paneId: string): PaneNode | null`
213
+ #### `findPaneById(tree: TreeNode | null, paneId: string): PaneNode | null`
214
214
 
215
215
  Recursively searches the layout tree and returns the target `PaneNode` if found, or `null` otherwise.
216
216
 
217
+ #### `findPaneContainingTab(tree: TreeNode | null, tabId: string): PaneNode | null`
218
+
219
+ Recursively searches the layout tree and returns the `PaneNode` containing the specified `tabId`.
220
+
221
+ #### `findTabById(tree: TreeNode | null, tabId: string): TabDetails | null`
222
+
223
+ Searches the layout tree for the given `tabId` and returns computed details (parent `paneId`, `isActive`, `index`, and custom `metadata`).
224
+
217
225
  ---
218
226
 
219
227
  ## Custom Styling
@@ -254,11 +262,22 @@ export interface SplitNode {
254
262
 
255
263
  export interface PaneNode {
256
264
  type: 'pane'
257
- paneId: string
258
- metadata?: Record<string, unknown>
265
+ id: string
266
+ tabs: string[]
267
+ activeTabId: string
268
+ locked?: boolean
269
+ tabsMetadata?: Record<string, Record<string, unknown>>
259
270
  }
260
271
 
261
272
  export type TreeNode = SplitNode | PaneNode
273
+
274
+ export interface TabDetails {
275
+ id: string
276
+ paneId: string
277
+ isActive: boolean
278
+ index: number
279
+ metadata: Record<string, unknown> | undefined
280
+ }
262
281
  ```
263
282
 
264
283
  ---
@@ -298,11 +317,22 @@ export interface SplitNode {
298
317
 
299
318
  export interface PaneNode {
300
319
  type: 'pane'
301
- paneId: string
302
- metadata?: Record<string, unknown>
320
+ id: string
321
+ tabs: string[]
322
+ activeTabId: string
323
+ locked?: boolean
324
+ tabsMetadata?: Record<string, Record<string, unknown>>
303
325
  }
304
326
 
305
327
  export type TreeNode = SplitNode | PaneNode
328
+
329
+ export interface TabDetails {
330
+ id: string
331
+ paneId: string
332
+ isActive: boolean
333
+ index: number
334
+ metadata: Record<string, unknown> | undefined
335
+ }
306
336
  ```
307
337
 
308
338
  - **`PaneNode` (Leaf):** Represents a single content pane. It must have a unique `paneId`.
@@ -427,7 +457,7 @@ A vertical-resize container wrapper that wraps any node (typically `<PaneTree />
427
457
 
428
458
  ## 3. Programmatic State Utilities
429
459
 
430
- Import these helpers from `react-zeugma` to manipulate the tree layout programmatically in your state handlers:
460
+ Import these helpers from `react-zeugma/utils` to manipulate or query the tree layout programmatically in your state handlers:
431
461
 
432
462
  - **`removePane(tree: TreeNode | null, idToRemove: string): TreeNode | null`**
433
463
  Removes a pane from the tree and collapses the leftover sibling split node.
@@ -435,8 +465,12 @@ Import these helpers from `react-zeugma` to manipulate the tree layout programma
435
465
  Splits a specific target pane by nesting it under a new `SplitNode` along with a new pane.
436
466
  - **`updateTabMetadata(tree: TreeNode | null, tabId: string, updater: (current: Record<string, unknown> | undefined) => Record<string, unknown> | undefined): TreeNode | null`**
437
467
  Updates the metadata of a specific tab.
438
- - **`findPane(tree: TreeNode | null, paneId: string): PaneNode | null`**
468
+ - **`findPaneById(tree: TreeNode | null, paneId: string): PaneNode | null`**
439
469
  Recursively searches the layout tree and returns the target `PaneNode` if found, or `null` otherwise.
470
+ - **`findPaneContainingTab(tree: TreeNode | null, tabId: string): PaneNode | null`**
471
+ Recursively searches the layout tree and returns the `PaneNode` containing the specified `tabId`.
472
+ - **`findTabById(tree: TreeNode | null, tabId: string): TabDetails | null`**
473
+ Searches the layout tree for the given `tabId` and returns computed details (parent `paneId`, `isActive`, `index`, and custom `metadata`).
440
474
 
441
475
  ---
442
476
 
@@ -495,12 +529,38 @@ export default function App() {
495
529
 
496
530
  `react-zeugma` is style-agnostic and relies on class name configuration for visual states. Define classes in your styling framework and pass them via the `classNames` prop on `<Zeugma>`:
497
531
 
532
+ > [!IMPORTANT]
533
+ > Starting from version `4.1.2`, `react-zeugma` is 100% headless and does not apply any internal default CSS fallback classes (such as `zeugma-resizer`, `zeugma-locked-preview`, etc.). All layout visual states must be styled by providing custom class names via the `classNames` configuration object.
534
+
498
535
  ```ts
499
536
  interface ZeugmaClassNames {
537
+ dashboard?: string // Applied to the root dashboard container
538
+ dashboardDismissActive?: string // Applied to root container when dismiss intent is active
539
+ dashboardLocked?: string // Applied to root container when dashboard is globally locked
500
540
  pane?: string // Applied to the outer wrapper of <Pane>
541
+ paneLocked?: string // Applied to the pane container when locked
501
542
  dropPreview?: string // Applied to the preview box when hovering over edge dropzones
502
543
  dragOverlay?: string // Applied to the cursor-following drag preview portal
503
544
  resizer?: string // Applied to the drag-to-resize split bar
545
+ dismissPreview?: string // Applied to the background dismiss zone indicator during a drag-out dismiss gesture
546
+ lockedPreview?: string // Applied to drop zone indicator when hovering over a locked pane
547
+ tabDropPreview?: string // Applied to the drop placeholder line element during tab drags
548
+ }
549
+ ```
550
+
551
+ ### Tab Drop Preview Customization
552
+
553
+ When dragging a tab over another, the library automatically renders a placeholder indicator line absolute-positioned on the left or right edge of the target tab.
554
+
555
+ To style this indicator line, configure a custom CSS class name via `classNames.tabDropPreview`.
556
+
557
+ Use this single class name in your CSS to customize the color and size (width) of the placeholder indicator line:
558
+
559
+ ```css
560
+ /* Custom tab drop placeholder styling */
561
+ .my-tab-preview {
562
+ background-color: #6366f1 !important; /* change color */
563
+ width: 3px !important; /* change width/size */
504
564
  }
505
565
  ```
506
566
 
@@ -518,7 +578,6 @@ interface ZeugmaClassNames {
518
578
 
519
579
  /* Edge drop previews */
520
580
  ```
521
- ````
522
581
 
523
582
  ---
524
583
 
@@ -537,3 +596,4 @@ During modern excavation efforts, archeologists discovered some of the most brea
537
596
  - [GitHub Repository](https://github.com/react-zeugma/react-zeugma)
538
597
  - [npm Package](https://www.npmjs.com/package/react-zeugma)
539
598
  - [Contributing Guide](https://github.com/react-zeugma/react-zeugma/blob/master/CONTRIBUTING.md)
599
+ ````
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
- 'use strict';var on=require('react'),core=require('@dnd-kit/core'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var on__default=/*#__PURE__*/_interopDefault(on);var Fe=on.createContext(void 0),Oe=on.createContext(void 0);var ne=()=>{let e=on.useContext(Fe);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},Ve=()=>{let e=on.useContext(Oe);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e};function ct(e){let t=on.useRef(null);return on.useEffect(()=>{if(!e){t.current=null;return}let n=r=>{t.current={x:r.clientX,y:r.clientY};},s=r=>{let o=r.touches[0]||r.changedTouches[0];o&&(t.current={x:o.clientX,y:o.clientY});};return window.addEventListener("pointermove",n,{passive:true}),window.addEventListener("touchmove",s,{passive:true}),()=>{window.removeEventListener("pointermove",n),window.removeEventListener("touchmove",s);}},[e]),t}function ut(e){on.useEffect(()=>(e?document.body.style.setProperty("cursor","not-allowed","important"):document.body.style.removeProperty("cursor"),()=>{document.body.style.removeProperty("cursor");}),[e]);}function dt(){let[e,t]=on.useState({}),n=on.useRef(true);on.useEffect(()=>(n.current=true,()=>{n.current=false;}),[]);let s=on.useCallback((r,o)=>{setTimeout(()=>{n.current&&t(i=>i[r]===o?i:{...i,[r]:o});},0);},[]);return {portalTargets:e,registerPortalTarget:s}}var We=on.createContext(void 0);var Zt=8,Ht=8,Wn=4;function ce(){return "pane-"+Math.random().toString(36).substring(2,11)}function ye(e,t){if(e===null)return null;if(e.type==="pane")return e.id===t?null:e;let n=ye(e.first,t),s=ye(e.second,t);return n===null?s:s===null?n:{...e,first:n,second:s}}function fe(e,t){if(e===null)return null;if(e.type==="pane"){if(e.tabs.includes(t)){let r=e.tabs.filter(a=>a!==t);if(r.length===0)return null;let o=e.activeTabId;e.activeTabId===t&&(o=r[0]);let i={...e.tabsMetadata};return delete i[t],{...e,tabs:r,activeTabId:o,tabsMetadata:Object.keys(i).length>0?i:void 0}}return e}let n=fe(e.first,t),s=fe(e.second,t);return n===null?s:s===null?n:{...e,first:n,second:s}}function De(e,t,n,s,r){if(e===null)return typeof r=="string"?{type:"pane",id:ce(),tabs:[r],activeTabId:r}:r;if(e.type==="pane"){if(e.id===t||e.tabs.includes(t)){let o=typeof r=="string"?{type:"pane",id:ce(),tabs:[r],activeTabId:r}:r,i=s==="left"||s==="top";return {type:"split",direction:n,first:i?o:e,second:i?e:o,splitPercentage:50}}return e}return {...e,first:De(e.first,t,n,s,r)||e.first,second:De(e.second,t,n,s,r)||e.second}}function pt(e,t){if(e===null)return {type:"pane",id:ce(),tabs:[t],activeTabId:t};function n(s,r){return s.type==="pane"?{type:"split",direction:r==="row"?"column":"row",splitPercentage:50,first:s,second:{type:"pane",id:ce(),tabs:[t],activeTabId:t}}:{...s,second:n(s.second,s.direction)}}return n(e,null)}function Te(e,t,n){return e===null?null:e===t?{...e,splitPercentage:n}:e.type==="split"?{...e,first:Te(e.first,t,n)||e.first,second:Te(e.second,t,n)||e.second}:e}function K(e,t){return e===null?null:e.type==="pane"?e.id===t||e.tabs.includes(t)?e:null:K(e.first,t)??K(e.second,t)}function _e(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.id===t||e.tabs.includes(t)){let s=e.tabsMetadata||{},r=s[t],o=n(r),i={...s};return o===void 0?delete i[t]:i[t]=o,{...e,tabsMetadata:Object.keys(i).length>0?i:void 0}}return e}return {...e,first:_e(e.first,t,n)??e.first,second:_e(e.second,t,n)??e.second}}function Ue(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.id===t||e.tabs.includes(t)){if(n===false){let{locked:s,...r}=e;return r}return {...e,locked:n}}return e}return {...e,first:Ue(e.first,t,n)??e.first,second:Ue(e.second,t,n)??e.second}}function Ye(e,t,n){return e===null?null:e.type==="pane"?e.id===t||e.tabs.includes(t)?{...e,activeTabId:n}:e:{...e,first:Ye(e.first,t,n)??e.first,second:Ye(e.second,t,n)??e.second}}function ft(e,t,n){if(e===null)return null;let r=K(e,t)?.tabsMetadata?.[t],o=fe(e,t);if(o===null)return {type:"pane",id:ce(),tabs:[t],activeTabId:t,tabsMetadata:r?{[t]:r}:void 0};function i(a){if(a.type==="pane"){if(a.id===n||a.tabs.includes(n)){let l=[...a.tabs];l.includes(t)||l.push(t);let P={...a.tabsMetadata};return r&&(P[t]=r),{...a,tabs:l,activeTabId:t,tabsMetadata:Object.keys(P).length>0?P:void 0}}return a}return {...a,first:i(a.first),second:i(a.second)}}return i(o)}function mt(e,t,n,s="before"){if(e===null)return null;let o=K(e,t)?.tabsMetadata?.[t],i=fe(e,t);if(i===null)return {type:"pane",id:ce(),tabs:[t],activeTabId:t,tabsMetadata:o?{[t]:o}:void 0};function a(l){if(l.type==="pane"){if(l.id===n||l.tabs.includes(n)){let D=[...l.tabs].filter(y=>y!==t),c=D.indexOf(n);c<0&&(c=0),s==="after"&&(c+=1),D.splice(c,0,t);let T={...l.tabsMetadata};return o&&(T[t]=o),{...l,tabs:D,activeTabId:t,tabsMetadata:Object.keys(T).length>0?T:void 0}}return l}return {...l,first:a(l.first),second:a(l.second)}}return a(i)}function le(e,t=0,n=0,s=100,r=100,o="root"){if(e===null)return {panes:[],splitters:[]};if(e.type==="pane")return {panes:[{paneId:e.id,left:t,top:n,width:s,height:r,node:e}],splitters:[]};let{direction:i,splitPercentage:a,first:l,second:P}=e,c={id:`splitter-${o}-${i}`,currentNode:e,direction:i,left:i==="row"?t+s*(a/100):t,top:i==="column"?n+r*(a/100):n,width:i==="row"?0:s,height:i==="column"?0:r,parentLeft:t,parentTop:n,parentWidth:s,parentHeight:r},T={panes:[],splitters:[]},y={panes:[],splitters:[]};if(i==="row"){let v=s*(a/100);T=le(l,t,n,v,r,`${o}-L`),y=le(P,t+v,n,s-v,r,`${o}-R`);}else {let v=r*(a/100);T=le(l,t,n,s,v,`${o}-T`),y=le(P,t,n+v,s,r-v,`${o}-B`);}return {panes:[...T.panes,...y.panes],splitters:[c,...T.splitters,...y.splitters]}}function Be({cursor:e,resizerEl:t,onMove:n,onEnd:s}){document.body.classList.add("zeugma-resizing");let r=document.createElement("style");r.id="zeugma-global-cursor-style",r.textContent=`
1
+ 'use strict';var At=require('react'),core=require('@dnd-kit/core'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var At__default=/*#__PURE__*/_interopDefault(At);function Ve(e){let t=At.useRef(null);return At.useEffect(()=>{if(!e){t.current=null;return}let n=r=>{t.current={x:r.clientX,y:r.clientY};},s=r=>{let o=r.touches[0]||r.changedTouches[0];o&&(t.current={x:o.clientX,y:o.clientY});};return window.addEventListener("pointermove",n,{passive:true}),window.addEventListener("touchmove",s,{passive:true}),()=>{window.removeEventListener("pointermove",n),window.removeEventListener("touchmove",s);}},[e]),t}function Be(e){At.useEffect(()=>(e?document.body.style.setProperty("cursor","not-allowed","important"):document.body.style.removeProperty("cursor"),()=>{document.body.style.removeProperty("cursor");}),[e]);}function We(){let[e,t]=At.useState({}),n=At.useRef(true);At.useEffect(()=>(n.current=true,()=>{n.current=false;}),[]);let s=At.useCallback((r,o)=>{n.current&&t(i=>i[r]===o?i:{...i,[r]:o});},[]);return {portalTargets:e,registerPortalTarget:s}}var gt=8,bt=8,Pn=4;function le(){return "pane-"+Math.random().toString(36).substring(2,11)}function de(e,t){if(e===null)return null;if(e.type==="pane")return e.id===t?null:e;let n=de(e.first,t),s=de(e.second,t);return n===null?s:s===null?n:{...e,first:n,second:s}}function ce(e,t){if(e===null)return null;if(e.type==="pane"){if(e.tabs.includes(t)){let r=e.tabs.filter(a=>a!==t);if(r.length===0)return null;let o=e.activeTabId;e.activeTabId===t&&(o=r[0]);let i={...e.tabsMetadata};return delete i[t],{...e,tabs:r,activeTabId:o,tabsMetadata:Object.keys(i).length>0?i:void 0}}return e}let n=ce(e.first,t),s=ce(e.second,t);return n===null?s:s===null?n:{...e,first:n,second:s}}function be(e,t,n,s,r){if(e===null)return typeof r=="string"?{type:"pane",id:le(),tabs:[r],activeTabId:r}:r;if(e.type==="pane"){if(e.id===t){let o=typeof r=="string"?{type:"pane",id:le(),tabs:[r],activeTabId:r}:r,i=s==="left"||s==="top";return {type:"split",direction:n,first:i?o:e,second:i?e:o,splitPercentage:50}}return e}return {...e,first:be(e.first,t,n,s,r)||e.first,second:be(e.second,t,n,s,r)||e.second}}function Ue(e,t){if(e===null)return {type:"pane",id:le(),tabs:[t],activeTabId:t};function n(s,r){return s.type==="pane"?{type:"split",direction:r==="row"?"column":"row",splitPercentage:50,first:s,second:{type:"pane",id:le(),tabs:[t],activeTabId:t}}:{...s,second:n(s.second,s.direction)}}return n(e,null)}function pe(e,t,n){return e===null?null:e===t?{...e,splitPercentage:n}:e.type==="split"?{...e,first:pe(e.first,t,n)||e.first,second:pe(e.second,t,n)||e.second}:e}function te(e,t){return e===null?null:e.type==="pane"?e.id===t?e:null:te(e.first,t)??te(e.second,t)}function G(e,t){return e===null?null:e.type==="pane"?e.tabs.includes(t)?e:null:G(e.first,t)??G(e.second,t)}function _e(e,t){let n=G(e,t);if(!n)return null;let s=n.tabs.indexOf(t);return {id:t,paneId:n.id,isActive:n.activeTabId===t,index:s,metadata:n.tabsMetadata?.[t]}}function ye(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.tabs.includes(t)){let s=e.tabsMetadata||{},r=s[t],o=n(r),i={...s};return o===void 0?delete i[t]:i[t]=o,{...e,tabsMetadata:Object.keys(i).length>0?i:void 0}}return e}return {...e,first:ye(e.first,t,n)??e.first,second:ye(e.second,t,n)??e.second}}function Te(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.id===t){if(n===false){let{locked:s,...r}=e;return r}return {...e,locked:n}}return e}return {...e,first:Te(e.first,t,n)??e.first,second:Te(e.second,t,n)??e.second}}function xe(e,t,n){return e===null?null:e.type==="pane"?e.id===t?{...e,activeTabId:n}:e:{...e,first:xe(e.first,t,n)??e.first,second:xe(e.second,t,n)??e.second}}function Ye(e,t,n){if(e===null)return null;let r=G(e,t)?.tabsMetadata?.[t],o=ce(e,t);if(o===null)return {type:"pane",id:le(),tabs:[t],activeTabId:t,tabsMetadata:r?{[t]:r}:void 0};function i(a){if(a.type==="pane"){if(a.id===n){let u=[...a.tabs];u.includes(t)||u.push(t);let m={...a.tabsMetadata};return r&&(m[t]=r),{...a,tabs:u,activeTabId:t,tabsMetadata:Object.keys(m).length>0?m:void 0}}return a}return {...a,first:i(a.first),second:i(a.second)}}return i(o)}function Xe(e,t,n,s="before"){if(e===null)return null;let o=G(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(u){if(u.type==="pane"){if(u.tabs.includes(n)){let E=[...u.tabs].filter(S=>S!==t),v=E.indexOf(n);v<0&&(v=0),s==="after"&&(v+=1),E.splice(v,0,t);let P={...u.tabsMetadata};return o&&(P[t]=o),{...u,tabs:E,activeTabId:t,tabsMetadata:Object.keys(P).length>0?P:void 0}}return u}return {...u,first:a(u.first),second:a(u.second)}}return a(i)}function ae(e,t=0,n=0,s=100,r=100,o="root"){if(e===null)return {panes:[],splitters:[]};if(e.type==="pane")return {panes:[{paneId:e.id,left:t,top:n,width:s,height:r,node:e}],splitters:[]};let{direction:i,splitPercentage:a,first:u,second:m}=e,v={id:`splitter-${o}-${i}`,currentNode:e,direction:i,left:i==="row"?t+s*(a/100):t,top:i==="column"?n+r*(a/100):n,width:i==="row"?0:s,height:i==="column"?0:r,parentLeft:t,parentTop:n,parentWidth:s,parentHeight:r},P={panes:[],splitters:[]},S={panes:[],splitters:[]};if(i==="row"){let R=s*(a/100);P=ae(u,t,n,R,r,`${o}-L`),S=ae(m,t+R,n,s-R,r,`${o}-R`);}else {let R=r*(a/100);P=ae(u,t,n,s,R,`${o}-T`),S=ae(m,t,n+R,s,r-R,`${o}-B`);}return {panes:[...P.panes,...S.panes],splitters:[v,...P.splitters,...S.splitters]}}function he(e){try{return JSON.stringify(e)}catch{return ""}}function ht(e){let{initialLayout:t,layout:n,onChange:s,fullscreenPaneId:r,onFullscreenChange:o,locked:i=false,dragActivationDistance:a=8,snapThreshold:u=8,minSplitPercentage:m=5,maxSplitPercentage:E=95,enableDragToDismiss:v=false,dismissThreshold:P=60,onRemove:S,onDragStart:R,onDragEnd:L,onResizeStart:f,onResize:D,onResizeEnd:g,onDismissIntentChange:C}=e,[b,I]=At.useState(()=>n!==void 0?n:t??null),[k,B]=At.useState(()=>he(n!==void 0?n:null)),[Y,$]=At.useState(r||null),[K,V]=At.useState(i),[X,Q]=At.useState(null),[ee,d]=At.useState(null),[y,Z]=At.useState(null),w=At.useRef(null),T=At.useCallback(l=>{w.current=l;},[]),c=At.useCallback(l=>{$(l),o?.(l);},[o]);if(At.useEffect(()=>{V(i);},[i]),At.useEffect(()=>{r!==void 0&&$(r);},[r]),n!==void 0){let l=he(n);l!==k&&(B(l),I(n));}let p=At.useCallback(l=>(...x)=>{let A=b,J=l(A,...x);he(A)!==he(J)&&(I(J),s?.(J));},[b,s]),h=At.useCallback(p((l,x)=>typeof x=="function"?x(l):x),[p]),ne=At.useCallback(p((l,x)=>de(l,x)),[p]),O=At.useCallback(p((l,x)=>Ue(l,x)),[p]),F=At.useCallback(p((l,x,A,J,ge)=>{let Fe=te(l,x)??G(l,x);if(!Fe)return l;let dt=te(l,ge)??G(l,ge)??{type:"pane",id:ge,tabs:[ge],activeTabId:ge},pt=de(l,ge);return be(pt,Fe.id,A,J,dt)}),[p]),q=At.useCallback(p((l,x,A)=>pe(l,x,A)),[p]),re=At.useCallback(p((l,x,A)=>ye(l,x,A)),[p]),N=At.useCallback(p((l,x,A)=>{let J=te(l,x)??G(l,x);return J?Te(l,J.id,A):l}),[p]),M=At.useCallback(p((l,x,A)=>{let J=te(l,x)??G(l,x);return J?xe(l,J.id,A):l}),[p]),z=At.useCallback(p((l,x,A)=>{let J=te(l,A)??G(l,A);return J?Ye(l,x,J.id):l}),[p]),H=At.useCallback(p((l,x,A,J)=>Xe(l,x,A,J)),[p]),U=At.useCallback(p((l,x)=>ce(l,x)),[p]),j=At.useCallback(l=>te(b,l),[b]),se=At.useCallback(l=>G(b,l),[b]),ie=At.useCallback(l=>_e(b,l),[b]);return {layout:b,setLayout:h,fullscreenPaneId:Y,setFullscreenPaneId:c,locked:K,setLocked:V,activeId:X,setActiveId:Q,activeType:ee,setActiveType:d,dismissIntentId:y,setDismissIntentId:Z,containerRef:w,setContainerRef:T,dragActivationDistance:a,snapThreshold:u,minSplitPercentage:m,maxSplitPercentage:E,enableDragToDismiss:v,dismissThreshold:P,onRemove:S,onDragStart:R,onDragEnd:L,onResizeStart:f,onResize:D,onResizeEnd:g,onDismissIntentChange:C,removePane:ne,addPane:O,splitPane:F,updateSplitPercentage:q,updateTabMetadata:re,updatePaneLock:N,selectTab:M,mergeTab:z,moveTab:H,removeTab:U,findPaneById:j,findPaneContainingTab:se,findTabById:ie}}function Se({cursor:e,resizerEl:t,onMove:n,onEnd:s}){document.body.classList.add("zeugma-resizing");let r=document.createElement("style");r.id="zeugma-global-cursor-style",r.textContent=`
2
2
  * {
3
3
  cursor: ${e} !important;
4
4
  user-select: none !important;
5
5
  }
6
- `,document.head.appendChild(r),t.setAttribute("data-resizing","true");let o=a=>{n(a);},i=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let a=document.getElementById("zeugma-global-cursor-style");a&&a.remove(),document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",i),s();};document.addEventListener("pointermove",o),document.addEventListener("pointerup",i);}function Le(e){try{return JSON.stringify(e)}catch{return ""}}function Ft(e){let{initialLayout:t,layout:n,onChange:s,fullscreenPaneId:r,onFullscreenChange:o,locked:i=false,dragActivationDistance:a=8,snapThreshold:l=8,minSplitPercentage:P=5,maxSplitPercentage:D=95,enableDragToDismiss:c=false,dismissThreshold:T=60,onRemove:y,onDragStart:v,onDragEnd:x,onResizeStart:C,onResize:z,onResizeEnd:d,onDismissIntentChange:h}=e,[S,N]=on.useState(()=>n!==void 0?n:t??null),[W,I]=on.useState(()=>Le(n!==void 0?n:null)),[X,w]=on.useState(r||null),[j,b]=on.useState(i),[O,J]=on.useState(null),[V,g]=on.useState(null),[Z,q]=on.useState(null),H=on.useRef(null),L=on.useCallback(p=>{H.current=p;},[]),u=on.useCallback(p=>{w(p),o?.(p);},[o]);if(on.useEffect(()=>{b(i);},[i]),on.useEffect(()=>{r!==void 0&&w(r);},[r]),n!==void 0){let p=Le(n);p!==W&&(I(p),N(n));}let f=on.useCallback(p=>(...R)=>{let k=S,ae=p(k,...R);Le(k)!==Le(ae)&&(N(ae),s?.(ae));},[S,s]),_=on.useCallback(f((p,R)=>typeof R=="function"?R(p):R),[f]),re=on.useCallback(f((p,R)=>ye(p,R)),[f]),ue=on.useCallback(f((p,R)=>pt(p,R)),[f]),be=on.useCallback(f((p,R,k,ae,he)=>{let $e=K(p,he)??{type:"pane",id:he,tabs:[he],activeTabId:he},je=ye(p,he);return De(je,R,k,ae,$e)}),[f]),ve=on.useCallback(f((p,R,k)=>Te(p,R,k)),[f]),Q=on.useCallback(f((p,R,k)=>_e(p,R,k)),[f]),U=on.useCallback(f((p,R,k)=>Ue(p,R,k)),[f]),oe=on.useCallback(f((p,R,k)=>Ye(p,R,k)),[f]),$=on.useCallback(f((p,R,k)=>ft(p,R,k)),[f]),ze=on.useCallback(f((p,R,k,ae)=>mt(p,R,k,ae)),[f]),Ie=on.useCallback(f((p,R)=>fe(p,R)),[f]);return {layout:S,setLayout:_,fullscreenPaneId:X,setFullscreenPaneId:u,locked:j,setLocked:b,activeId:O,setActiveId:J,activeType:V,setActiveType:g,dismissIntentId:Z,setDismissIntentId:q,containerRef:H,setContainerRef:L,dragActivationDistance:a,snapThreshold:l,minSplitPercentage:P,maxSplitPercentage:D,enableDragToDismiss:c,dismissThreshold:T,onRemove:y,onDragStart:v,onDragEnd:x,onResizeStart:C,onResize:z,onResizeEnd:d,onDismissIntentChange:h,removePane:re,addPane:ue,splitPane:be,updateSplitPercentage:ve,updateTabMetadata:Q,updatePaneLock:U,selectTab:oe,mergeTab:$,moveTab:ze,removeTab:Ie}}var Ot=()=>{let e=ne(),t=Ve();return {...e,...t}};var bt=({activeId:e,render:t,className:n})=>{let s=on.useRef(null);return on.useEffect(()=>{let r=o=>{s.current&&(s.current.style.transform=`translate(${o.clientX+12}px, ${o.clientY+12}px)`);};return document.addEventListener("pointermove",r),()=>document.removeEventListener("pointermove",r)},[]),jsxRuntime.jsx("div",{ref:s,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var Xe=class extends core.PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},qe=class extends core.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};var vt=({tabId:e,target:t,renderWidget:n})=>{let[s,r]=on.useState(false),o=on.useRef(null);if(on.useEffect(()=>{r(true);},[]),on.useEffect(()=>{if(!s||!o.current)return;let a=o.current;if(t)t.appendChild(a);else {let l=document.getElementById("zeugma-hidden-portal-container");l||(l=document.createElement("div"),l.id="zeugma-hidden-portal-container",l.style.display="none",document.body.appendChild(l)),l.appendChild(a);}},[t,s]),on.useEffect(()=>()=>{o.current&&o.current.remove();},[]),!s)return null;o.current||(o.current=document.createElement("div"),o.current.className=`zeugma-portal-wrapper-${e}`,o.current.style.width="100%",o.current.style.height="100%");let i=o.current;return !i||!n?null:reactDom.createPortal(n(e),i)};function nt(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}var tn=e=>{let{renderPane:t,renderWidget:n,renderDragOverlay:s,classNames:r={},children:o,layout:i,setLayout:a,fullscreenPaneId:l,setFullscreenPaneId:P,locked:D,activeId:c,setActiveId:T,activeType:y,setActiveType:v,dismissIntentId:x,setDismissIntentId:C,containerRef:z,setContainerRef:d,dragActivationDistance:h,snapThreshold:S,minSplitPercentage:N,maxSplitPercentage:W,enableDragToDismiss:I,dismissThreshold:X,onRemove:w,onDragStart:j,onDragEnd:b,onResizeStart:O,onResize:J,onResizeEnd:V,onDismissIntentChange:g,removePane:Z,addPane:q,splitPane:H,updateSplitPercentage:L,updateTabMetadata:u,updatePaneLock:f,selectTab:ge,mergeTab:_,moveTab:re,removeTab:ue}=e,{portalTargets:be,registerPortalTarget:ve}=dt(),Q=on.useRef(null),U=ct(c),[oe,$]=on.useState(false);ut(oe);let ze=on.useCallback(m=>t(m),[t]),Ie=on.useMemo(()=>r,[r.pane,r.paneLocked,r.dropPreview,r.dragOverlay,r.resizer,r.dismissPreview,r.dashboardLocked,r.lockedPreview]),p=core.useSensors(core.useSensor(Xe,{activationConstraint:{distance:h}}),core.useSensor(qe,{activationConstraint:{delay:250,tolerance:5}})),R=on.useCallback(m=>{let A=core.pointerWithin(m);if(A.length>0)return A;if(m.active.id.toString().startsWith("tab-header-")){let se=m.droppableContainers.filter(ee=>ee.id.toString().startsWith("tab-drop-"));return core.closestCenter({...m,droppableContainers:se})}return []},[]),k=m=>{let A=m.active.id.toString(),Y=A.startsWith("tab-header-"),se=Y?A.substring(11):A;T(se),v(Y?"tab":"pane");let ee=m.activatorEvent;U.current=nt(ee),I&&z.current?Q.current=z.current.getBoundingClientRect():Q.current=null,j&&j(se);},ae=m=>{let{over:A}=m,se=(A?.id.toString()||"").startsWith("drop-locked-");if($(se),!I)return;let ee=m.active.id.toString(),Ee=ee.startsWith("tab-header-")?ee.substring(11):ee,M=Q.current;if(!M){x!==null&&(C(null),g?.(null));return}let ke=m.activatorEvent,ie=null,G=null;if(U.current)ie=U.current.x,G=U.current.y;else {let F=nt(ke);F&&(ie=F.x+m.delta.x,G=F.y+m.delta.y);}let de=0;if(ie!==null&&G!==null){let F=0,te=0;ie<M.left?F=M.left-ie:ie>M.right&&(F=ie-M.right),G<M.top?te=M.top-G:G>M.bottom&&(te=G-M.bottom),de=Math.sqrt(F*F+te*te);}else {let F=m.active.rect.current.translated;if(F){let te=F.left+F.width/2,Pe=F.top+F.height/2,pe=0,Se=0;te<M.left?pe=M.left-te:te>M.right&&(pe=te-M.right),Pe<M.top?Se=M.top-Pe:Pe>M.bottom&&(Se=Pe-M.bottom),de=Math.sqrt(pe*pe+Se*Se);}}de>X?x!==Ee&&(C(Ee),g?.(Ee)):x!==null&&(C(null),g?.(null));},he=m=>{T(null),v(null),$(false);let{active:A,over:Y}=m,se=A.id.toString(),ee=se.startsWith("tab-header-"),E=ee?se.substring(11):se,Ee=I&&x===E;if(C(null),g?.(null),Q.current=null,Ee){w?w(E):ue(E),b&&b(E,null,null);return}if(!Y){b&&b(E,null,null);return}let M=Y.id.toString();if(M.startsWith("drop-locked-")){b&&b(E,null,null);return}let ke=M.match(/^tab-drop-(.+)$/);if(ke){let[,Ze]=ke;if(E!==Ze){let Ne="before",st=Y.rect,zt=m.activatorEvent,He=null;if(U.current)He=U.current.x;else {let Ae=nt(zt);Ae&&(He=Ae.x+m.delta.x);}if(He!==null){let Ae=st.left+st.width/2;He>Ae&&(Ne="after");}re(E,Ze,Ne);}b&&b(E,Ze,{type:"swap",position:"center"});return}let ie=M.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!ie){b&&b(E,null,null);return}let[,G,de]=ie,we=K(i,E),F=we&&we.id===de,te=we&&we.tabs.length===1;if(E===de||F&&te){b&&b(E,null,null);return}let Pe=G==="left"||G==="right"?"row":"column",pe;if(ee){let Ne=K(i,E)?.tabsMetadata?.[E];pe={type:"pane",id:ce(),tabs:[E],activeTabId:E,tabsMetadata:Ne?{[E]:Ne}:void 0};}else pe=K(i,E)??{type:"pane",id:ce(),tabs:[E],activeTabId:E};let Se=ee?fe(i,E):ye(i,E),Mt=De(Se,de,Pe,G,pe);a(Mt),b&&b(E,de,{type:"split",direction:Pe,position:G});},$e=on.useCallback((m,A)=>{V&&V(m,A);},[V]),je=on.useMemo(()=>({layout:i,onLayoutChange:m=>a(m),renderPane:ze,activeId:c,dismissIntentId:x,setContainerRef:d,fullscreenPaneId:l,classNames:Ie,onRemove:w,onFullscreenChange:P,snapThreshold:S,onResizeStart:O,onResize:J,onResizeEnd:$e,minSplitPercentage:N,maxSplitPercentage:W,locked:D}),[i,c,x,d,l,Ie,w,P,S,O,J,N,W,a,ze,$e,D]),wt=on.useMemo(()=>({removePane:Z,addPane:q,splitPane:H,updateSplitPercentage:L,updateTabMetadata:u,updatePaneLock:f,selectTab:ge,mergeTab:_,moveTab:re,removeTab:ue}),[Z,q,H,L,u,f,ge,_,re,ue]),Nt=on.useMemo(()=>{let m=[];function A(Y){Y&&(Y.type==="pane"?m.push(...Y.tabs):(A(Y.first),A(Y.second)));}return A(i),m},[i]),Lt=on.useMemo(()=>({registerPortalTarget:ve}),[ve]);return jsxRuntime.jsx(Oe.Provider,{value:wt,children:jsxRuntime.jsx(Fe.Provider,{value:je,children:jsxRuntime.jsxs(We.Provider,{value:Lt,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",sensors:p,collisionDetection:R,onDragStart:k,onDragMove:ae,onDragEnd:he,children:o}),c&&y&&s&&jsxRuntime.jsx(bt,{activeId:c,render:m=>s(m,y),className:`${r.dragOverlay||""} ${c===x?r.dismissPreview||"zeugma-dismiss-preview":""}`.trim()}),jsxRuntime.jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:Nt.map(m=>jsxRuntime.jsx(vt,{tabId:m,target:be[m]||null,renderWidget:n},m))})]})})})};function rt({containerRef:e,isRow:t,direction:n,splitPercentage:s,resizerSize:r,snapThreshold:o,layout:i,currentNode:a,onLayoutChange:l,onResizeStart:P,onResizeEnd:D,parentLeft:c,parentTop:T,parentWidth:y,parentHeight:v}){let{onResizeStart:x,onResize:C,onResizeEnd:z,minSplitPercentage:d=5,maxSplitPercentage:h=95,locked:S=false}=ne();return on.useCallback(N=>{if(S)return;N.preventDefault();let W=e.current;if(!W)return;P&&P(),x&&x(a);let I=W.getBoundingClientRect(),X=N.clientX,w=N.clientY,j=s,b=N.currentTarget,O=I.left+I.width*(c/100),J=I.top+I.height*(T/100),V=I.width*(y/100),g=I.height*(v/100),q=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(L=>L!==b&&L.getAttribute("data-direction")===n).map(L=>{let u=L.getBoundingClientRect();return t?u.left+u.width/2:u.top+u.height/2}),H=j;Be({cursor:t?"col-resize":"row-resize",resizerEl:b,onMove:L=>{let u=t?(L.clientX-X)/V*100:(L.clientY-w)/g*100,f=j+u,ge=t?O+(V-r)*(f/100)+r/2:J+(g-r)*(f/100)+r/2,_=1/0,re=null;for(let Q of q){let U=Math.abs(ge-Q);U<o&&U<_&&(_=U,re=Q);}let ue=f;re!==null&&(ue=t?(re-r/2-O)/(V-r)*100:(re-r/2-J)/(g-r)*100);let be=Math.max(d,Math.min(h,ue));H=be;let ve=Te(i,a,be);if(ve){let{panes:Q,splitters:U}=le(ve),oe=e.current;if(oe){for(let $ of Q)oe.style.setProperty(`--pane-left-${$.paneId}`,`${$.left}%`),oe.style.setProperty(`--pane-top-${$.paneId}`,`${$.top}%`),oe.style.setProperty(`--pane-width-${$.paneId}`,`${$.width}%`),oe.style.setProperty(`--pane-height-${$.paneId}`,`${$.height}%`);for(let $ of U)oe.style.setProperty(`--splitter-pos-${$.id}`,`${$.direction==="row"?$.left:$.top}%`);}}C&&C(a,be);},onEnd:()=>{let L=Te(i,a,H),u=e.current;if(u){let{panes:f,splitters:ge}=le(L);for(let _ of f)u.style.removeProperty(`--pane-left-${_.paneId}`),u.style.removeProperty(`--pane-top-${_.paneId}`),u.style.removeProperty(`--pane-width-${_.paneId}`),u.style.removeProperty(`--pane-height-${_.paneId}`);for(let _ of ge)u.style.removeProperty(`--splitter-pos-${_.id}`);}l(L),D&&D(),z&&z(a,H);}});},[e,t,n,s,r,o,i,a,l,P,D,x,C,z,d,h,c,T,y,v])}var cn=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:s})=>{let{layout:r,onLayoutChange:o,classNames:i,locked:a}=ne(),[l,P]=on.useState(false),{currentNode:D,direction:c,left:T,top:y,width:v,height:x,parentLeft:C,parentTop:z,parentWidth:d,parentHeight:h}=e,S=c==="row",N=rt({containerRef:s,isRow:S,direction:c,splitPercentage:D.splitPercentage,resizerSize:t,snapThreshold:n,layout:r,currentNode:D,onLayoutChange:o,onResizeStart:()=>P(true),onResizeEnd:()=>P(false),parentLeft:C,parentTop:z,parentWidth:d,parentHeight:h}),W=S?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${T}%) - ${t/2}px)`,top:`calc(${y}% + ${t/2}px)`,width:`${t}px`,height:`calc(${x}% - ${t}px)`,cursor:a?"default":"col-resize",pointerEvents:a?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`calc(${T}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${y}%) - ${t/2}px)`,width:`calc(${v}% - ${t}px)`,height:`${t}px`,cursor:a?"default":"row-resize",pointerEvents:a?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"};return jsxRuntime.jsx("div",{className:`zeugma-resizer ${i.resizer||""}`.trim(),"data-direction":c,"data-resizing":l||void 0,style:W,onPointerDown:N,role:"separator","aria-valuenow":D.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},un=on__default.default.memo(({paneId:e,renderPane:t})=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane),dn=({tree:e,resizerSize:t=4,snapThreshold:n})=>{let{layout:s,renderPane:r,activeId:o,dismissIntentId:i,setContainerRef:a,fullscreenPaneId:l,snapThreshold:P,locked:D,classNames:c}=ne(),T=n!==void 0?n:P??8,y=e!==void 0?e:s,v=on.useRef(null),{panes:x,splitters:C}=on.useMemo(()=>y?le(y):{panes:[],splitters:[]},[y]);if(!y)return null;let z=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[x.map(d=>{let h=l===d.paneId;return jsxRuntime.jsx("div",{style:{position:"absolute",left:h?"0%":`var(--pane-left-${d.paneId}, ${d.left}%)`,top:h?"0%":`var(--pane-top-${d.paneId}, ${d.top}%)`,width:h?"100%":`var(--pane-width-${d.paneId}, ${d.width}%)`,height:h?"100%":`var(--pane-height-${d.paneId}, ${d.height}%)`,overflow:"hidden",zIndex:h?20:1,display:l&&!h?"none":"block",padding:h?"0px":`${t/2}px`,boxSizing:"border-box"},children:jsxRuntime.jsx(un,{paneId:d.paneId,renderPane:r})},d.paneId)}),!l&&C.map(d=>jsxRuntime.jsx(cn,{splitter:d,resizerSize:t,snapThreshold:T,containerRef:v},d.id))]});if(e===void 0){let d=o!==null&&o===i,h=N=>{a(N),v.current=N;},S=`zeugma-dashboard-root ${d?"zeugma-dashboard-dismiss-active":""} ${D?c.dashboardLocked||"zeugma-dashboard-locked":""}`.trim();return jsxRuntime.jsx("div",{ref:h,className:S,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:z()})}return jsxRuntime.jsx("div",{ref:v,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:z()})};var Rt="zeugma-height:",gn="default-pane";function bn(e){try{let t=localStorage.getItem(Rt+e);if(t!==null){let n=Number(t);if(Number.isFinite(n)&&n>0)return n}}catch{}return null}function xt(e,t){try{localStorage.setItem(Rt+e,String(Math.round(t)));}catch{}}var St=({children:e,active:t=true,height:n,onHeightChange:s,minHeight:r=100,maxHeight:o=1/0,persist:i,localStorageKey:a,resizerHeight:l=6,className:P,resizerClassName:D})=>{let c=i?a||gn:null,T=()=>{let S=(c?bn(c):null)??n??400;return Je(S,r,o)},[y,v]=on.useState(T),x=on.useRef(null),C=c?y:n??y,z=on.useRef(n);on.useEffect(()=>{if(n!==void 0&&n!==z.current){let S=Je(n,r,o);v(S),c&&xt(c,S);}z.current=n;},[n,r,o,c]);let d=on.useCallback(()=>o,[o]),h=on.useCallback(S=>{S.preventDefault();let N=S.clientY,W=C,I=d(),X=S.currentTarget,w=Dt(x.current),j=w?w.scrollTop:0,b=N,O=null,J=(g,Z)=>{let q=Z-j,L=g-N+q,u=Je(W+L,r,I);return x.current&&(x.current.style.height=`${u}px`),u},V=()=>{if(!w)return;let g=w===document.documentElement||w===document.body?{top:0,bottom:window.innerHeight}:w.getBoundingClientRect(),Z=40,q=10,H=0;b>g.bottom-Z?H=Math.min(1,(b-(g.bottom-Z))/Z)*q:b<g.top+Z&&(H=-Math.min(1,(g.top+Z-b)/Z)*q),H!==0&&(w.scrollTop+=H,J(b,w.scrollTop)),O=requestAnimationFrame(V);};O=requestAnimationFrame(V),Be({cursor:"row-resize",resizerEl:X,onMove:g=>{b=g.clientY,w&&J(b,w.scrollTop);},onEnd:()=>{O!==null&&cancelAnimationFrame(O);let g=W;x.current&&(g=x.current.getBoundingClientRect().height),g=Je(g,r,I),v(g),s&&s(g),c&&xt(c,g);}});},[C,r,d,s,c]);return t?jsxRuntime.jsxs("div",{ref:x,className:`zeugma-resizable-container ${P||""}`.trim(),style:{height:`${C}px`,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:[jsxRuntime.jsx("div",{style:{height:`calc(100% - ${l}px)`,overflow:"hidden"},children:e}),jsxRuntime.jsx("div",{className:`zeugma-resizable-handle ${D||""}`.trim(),style:{height:`${l}px`,cursor:"row-resize",position:"relative",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box",flexShrink:0},onPointerDown:h,role:"separator","aria-orientation":"horizontal","aria-valuenow":Math.round(C),"aria-valuemin":r,"aria-valuemax":o===1/0?void 0:o})]}):jsxRuntime.jsx("div",{className:`zeugma-resizable-container disabled ${P||""}`.trim(),style:{height:"100%",position:"relative",overflow:"hidden",boxSizing:"border-box"},children:jsxRuntime.jsx("div",{style:{height:"100%",overflow:"hidden"},children:e})})};function Je(e,t,n){return Math.max(t,Math.min(n,e))}function Dt(e){if(typeof window>"u"||!e)return null;let t=e.parentElement;if(!t)return document.documentElement;let s=window.getComputedStyle(t).overflowY;return s==="auto"||s==="scroll"?t:Dt(t)}var Ke=on.createContext(null);var Sn={top:{position:"absolute",top:0,left:"25%",width:"50%",height:"25%",zIndex:20,pointerEvents:"auto"},bottom:{position:"absolute",bottom:0,left:"25%",width:"50%",height:"25%",zIndex:20,pointerEvents:"auto"},left:{position:"absolute",top:"25%",left:0,width:"25%",height:"50%",zIndex:20,pointerEvents:"auto"},right:{position:"absolute",top:"25%",right:0,width:"25%",height:"50%",zIndex:20,pointerEvents:"auto"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:20,pointerEvents:"auto",cursor:"not-allowed"}},Dn={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"}},Ct=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:s,isOver:r}=core.useDroppable({id:e});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:s,style:Sn[t]}),r&&jsxRuntime.jsx("div",{className:n,style:Dn[t]})]})},Cn=({id:e,children:t,style:n,locked:s=false})=>{let{layout:r,activeId:o,classNames:i,fullscreenPaneId:a,onFullscreenChange:l,locked:P}=ne(),{removePane:D,updateTabMetadata:c,selectTab:T,removeTab:y}=Ve(),v=on.useContext(We);if(!v)throw new Error("Pane must be used within a Zeugma provider");let{registerPortalTarget:x}=v,C=on.useMemo(()=>K(r,e),[r,e]),z=C?.id??e,d=C?.tabs??[e],h=C?.activeTabId??e,S=C?.tabsMetadata,N=S?.[e],W=C?.locked??false,I=s||W,X=P||I,w=P||I,j=o!==null&&o!==e&&(!d.includes(o)||d.length>1)&&!w,{attributes:b,listeners:O,setNodeRef:J}=core.useDraggable({id:e,disabled:X}),V=o!==null&&d.includes(o),g=a===e,Z=on.useCallback(()=>jsxRuntime.jsx("div",{id:`zeugma-tab-target-${h}`,className:"zeugma-tab-content-wrapper",style:{height:"100%",width:"100%"}}),[h]);on.useEffect(()=>{let u=document.getElementById(`zeugma-tab-target-${h}`);return x(h,u),()=>{x(h,null);}},[h,x]);let q=on.useMemo(()=>({isDragging:V,isFullscreen:g,toggleFullscreen:()=>l?.(g?null:e),remove:()=>{g&&l?.(null),D(z);},metadata:N,updateMetadata:u=>{c(e,u);},locked:X,tabs:d,activeTabId:h,selectTab:u=>T(z,u),removeTab:u=>{g&&u===h&&l?.(null),y(u);},tabsMetadata:S,updateTabMetadata:(u,f)=>{c(u,f);},renderActiveTab:Z}),[V,g,l,e,y,N,c,X,d,h,T,z,S,Z]),H=on.useMemo(()=>X?{disabled:true}:{...O,...b},[O,b,X]),L=`${i.pane||""} ${I?i.paneLocked||"zeugma-pane-locked":""}`.trim();return jsxRuntime.jsx(Ke.Provider,{value:H,children:jsxRuntime.jsxs("div",{ref:J,className:L,style:{position:"relative",width:"100%",height:"100%",...n},children:[t(q),j&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:["top","bottom","left","right"].map(u=>jsxRuntime.jsx(Ct,{id:`drop-${u}-${e}`,position:u,activeClassName:i.dropPreview},u))}),o!==null&&o!==e&&w&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsxRuntime.jsx(Ct,{id:`drop-locked-${e}`,position:"full",activeClassName:i.lockedPreview||"zeugma-locked-preview"})})]})})};var Nn=({children:e,className:t,style:n})=>{let s=on.useContext(Ke);if(!s)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:r,...o}=s;return jsxRuntime.jsx("div",{className:t,style:{cursor:r?"default":"grab",userSelect:r?"auto":"none",touchAction:r?"auto":"none",...n},...r?{}:o,children:e})};var In=({id:e,locked:t=false,children:n,className:s,style:r})=>{let{locked:o}=ne(),i=t||o,{attributes:a,listeners:l,setNodeRef:P,isDragging:D}=core.useDraggable({id:`tab-header-${e}`,disabled:i}),{setNodeRef:c,isOver:T}=core.useDroppable({id:`tab-drop-${e}`,disabled:i});return jsxRuntime.jsx("div",{ref:v=>{P(v),c(v);},className:s,style:{display:"inline-flex",cursor:i?"default":"grab",...r},...i?{}:l,...i?{}:a,children:n({isDragging:D,isOver:T})})};exports.DEFAULT_DRAG_ACTIVATION_DISTANCE=Ht;exports.DEFAULT_RESIZER_SIZE=Wn;exports.DEFAULT_SNAP_THRESHOLD=Zt;exports.DragHandle=Nn;exports.Pane=Cn;exports.PaneTree=dn;exports.ResizableContainer=St;exports.Tab=In;exports.Zeugma=tn;exports.addPane=pt;exports.computeLayout=le;exports.createDragSession=Be;exports.findPane=K;exports.generateUniqueId=ce;exports.mergeTab=ft;exports.moveTab=mt;exports.removePane=ye;exports.removeTab=fe;exports.safeJsonStringify=Le;exports.selectTab=Ye;exports.splitPane=De;exports.updatePaneLock=Ue;exports.updateSplitPercentage=Te;exports.updateTabMetadata=_e;exports.useResizer=rt;exports.useZeugma=Ft;exports.useZeugmaContext=Ot;//# sourceMappingURL=index.cjs.map
6
+ `,document.head.appendChild(r),t.setAttribute("data-resizing","true");let o=a=>{n(a);},i=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let a=document.getElementById("zeugma-global-cursor-style");a&&a.remove(),document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",i),s();};document.addEventListener("pointermove",o),document.addEventListener("pointerup",i);}var $e=At.createContext(void 0),Ze=At.createContext(void 0),Re=At.createContext(void 0),oe=()=>{let e=At.useContext($e);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},De=()=>{let e=At.useContext(Ze);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e};var Pt=()=>{let e=oe(),t=De();return {...e,...t}};var Ce=class extends core.PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},Ee=class extends core.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};function we(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 Ke(e){let{layout:t,setLayout:n,activeId:s,setActiveId:r,setActiveType:o,dismissIntentId:i,setDismissIntentId:a,setOverTabId:u,setOverTabPosition:m,containerRef:E,dragActivationDistance:v,enableDragToDismiss:P,dismissThreshold:S,onRemove:R,onDragStart:L,onDragEnd:f,onDismissIntentChange:D,removeTab:g,moveTab:C,selectTab:b}=e,I=At.useRef(null),k=Ve(s),[B,Y]=At.useState(false);Be(B);let $=core.useSensors(core.useSensor(Ce,{activationConstraint:{distance:v}}),core.useSensor(Ee,{activationConstraint:{delay:250,tolerance:5}})),K=At.useCallback(d=>{let y=core.pointerWithin(d);if(y.length>0)return y;if(d.active.id.toString().startsWith("tab-header-")){let w=d.droppableContainers.filter(T=>T.id.toString().startsWith("tab-drop-"));return core.closestCenter({...d,droppableContainers:w})}return []},[]);return {sensors:$,collisionDetection:K,onDragStart:d=>{let y=d.active.id.toString(),Z=y.startsWith("tab-header-"),w=Z?y.substring(11):y;r(w),o(Z?"tab":"pane"),u(null),m(null);let T=d.activatorEvent;if(k.current=we(T),P&&E.current?I.current=E.current.getBoundingClientRect():I.current=null,Z){let c=G(t,w);c&&b(c.id,w);}L&&L(w);},onDragMove:d=>{let{over:y}=d,Z=y?.id.toString()||"",w=Z.startsWith("drop-locked-");Y(w);let T=Z.match(/^tab-drop-(.+)$/);if(T&&y){let[,N]=T,M=d.active.id.toString();if((M.startsWith("tab-header-")?M.substring(11):M)!==N){let U="before",j=y.rect,se=d.activatorEvent,ie=null;if(k.current)ie=k.current.x;else {let l=we(se);l&&(ie=l.x+d.delta.x);}if(ie!==null){let l=j.left+j.width/2;ie>l&&(U="after");}u(N),m(U);}else u(null),m(null);}else u(null),m(null);if(!P)return;let c=d.active.id.toString(),W=c.startsWith("tab-header-")?c.substring(11):c,h=I.current;if(!h){i!==null&&(a(null),D?.(null));return}let ne=d.activatorEvent,O=null,F=null;if(k.current)O=k.current.x,F=k.current.y;else {let N=we(ne);N&&(O=N.x+d.delta.x,F=N.y+d.delta.y);}let q=0;if(O!==null&&F!==null){let N=0,M=0;O<h.left?N=h.left-O:O>h.right&&(N=O-h.right),F<h.top?M=h.top-F:F>h.bottom&&(M=F-h.bottom),q=Math.sqrt(N*N+M*M);}else {let N=d.active.rect.current.translated;if(N){let M=N.left+N.width/2,z=N.top+N.height/2,H=0,U=0;M<h.left?H=h.left-M:M>h.right&&(H=M-h.right),z<h.top?U=h.top-z:z>h.bottom&&(U=z-h.bottom),q=Math.sqrt(H*H+U*U);}}q>S?i!==W&&(a(W),D?.(W)):i!==null&&(a(null),D?.(null));},onDragEnd:d=>{r(null),o(null),Y(false),u(null),m(null);let{active:y,over:Z}=d,w=y.id.toString(),T=w.startsWith("tab-header-"),c=T?w.substring(11):w,p=P&&i===c;if(a(null),D?.(null),I.current=null,p){R?R(c):g(c),f&&f(c,null,null);return}if(!Z){f&&f(c,null,null);return}let W=Z.id.toString();if(W.startsWith("drop-locked-")){f&&f(c,null,null);return}let h=W.match(/^tab-drop-(.+)$/);if(h){let[,j]=h;if(c!==j){let se="before",ie=Z.rect,l=d.activatorEvent,x=null;if(k.current)x=k.current.x;else {let A=we(l);A&&(x=A.x+d.delta.x);}if(x!==null){let A=ie.left+ie.width/2;x>A&&(se="after");}C(c,j,se),f&&f(c,j,{type:"move",position:"center"});}else f&&f(c,null,null);return}let ne=W.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!ne){f&&f(c,null,null);return}let[,O,F]=ne,q=T?G(t,c):te(t,c),re=q&&q.id===F,N=q&&q.tabs.length===1;if(c===F||re&&N){f&&f(c,null,null);return}let M=O==="left"||O==="right"?"row":"column",z;if(T){let se=G(t,c)?.tabsMetadata?.[c];z={type:"pane",id:le(),tabs:[c],activeTabId:c,tabsMetadata:se?{[c]:se}:void 0};}else z=te(t,c)??{type:"pane",id:le(),tabs:[c],activeTabId:c};let H=T?ce(t,c):de(t,c),U=be(H,F,M,O,z);n(U),f&&f(c,F,{type:"split",direction:M,position:O});},onDragCancel:()=>{r(null),o(null),Y(false),u(null),m(null),a(null),D?.(null),I.current=null;}}}var je=({activeId:e,render:t,className:n})=>{let s=At.useRef(null);return At.useEffect(()=>{let r=o=>{s.current&&(s.current.style.transform=`translate(${o.clientX+12}px, ${o.clientY+12}px)`);};return document.addEventListener("pointermove",r),()=>document.removeEventListener("pointermove",r)},[]),jsxRuntime.jsx("div",{ref:s,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var Qe=({tabId:e,target:t,renderWidget:n})=>{let[s,r]=At.useState(false),o=At.useRef(null);if(At.useEffect(()=>{r(true);},[]),At.useEffect(()=>{if(!s||!o.current)return;let a=o.current;if(t)t.appendChild(a);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(a);}},[t,s]),At.useEffect(()=>()=>{o.current&&o.current.remove();},[]),!s)return null;o.current||(o.current=document.createElement("div"),o.current.className=`zeugma-portal-wrapper-${e}`,o.current.style.width="100%",o.current.style.height="100%");let i=o.current;return !i||!n?null:reactDom.createPortal(n(e),i)};var Zt=e=>{let t=e,{renderPane:n,renderWidget:s,renderDragOverlay:r,classNames:o={},children:i,layout:a,setLayout:u,fullscreenPaneId:m,setFullscreenPaneId:E,locked:v,setLocked:P,findPaneById:S,findPaneContainingTab:R,findTabById:L,activeId:f,activeType:D,dismissIntentId:g,setContainerRef:C,snapThreshold:b,minSplitPercentage:I,maxSplitPercentage:k,onRemove:B,onResizeStart:Y,onResize:$,onResizeEnd:K,removePane:V,addPane:X,updateTabMetadata:Q,updatePaneLock:ee,selectTab:d,mergeTab:y,removeTab:Z}=t,{portalTargets:w,registerPortalTarget:T}=We(),[c,p]=At.useState(null),[W,h]=At.useState(null),ne=Ke({...t,setOverTabId:p,setOverTabPosition:h}),O=At.useCallback(H=>n(H),[n]),F=At.useMemo(()=>o,[o.dashboard,o.dashboardDismissActive,o.pane,o.paneLocked,o.dropPreview,o.dragOverlay,o.resizer,o.dismissPreview,o.dashboardLocked,o.lockedPreview,o.tabDropPreview]),q=At.useCallback((H,U)=>{K&&K(H,U);},[K]),re=At.useMemo(()=>({layout:a,setLayout:u,renderPane:O,activeId:f,dismissIntentId:g,overTabId:c,overTabPosition:W,setContainerRef:C,fullscreenPaneId:m,classNames:F,onRemove:B,onFullscreenChange:E,snapThreshold:b,onResizeStart:Y,onResize:$,onResizeEnd:q,minSplitPercentage:I,maxSplitPercentage:k,locked:v,setLocked:P,findPaneById:S,findPaneContainingTab:R,findTabById:L}),[a,f,g,c,W,C,m,F,B,E,b,Y,$,I,k,u,O,q,v,P,S,R,L]),N=At.useMemo(()=>({removePane:V,addPane:X,updateTabMetadata:Q,updatePaneLock:ee,selectTab:d,mergeTab:y,removeTab:Z}),[V,X,Q,ee,d,y,Z]),M=At.useMemo(()=>{let H=[];function U(j){j&&(j.type==="pane"?H.push(...j.tabs):(U(j.first),U(j.second)));}return U(a),H},[a]),z=At.useMemo(()=>({registerPortalTarget:T}),[T]);return jsxRuntime.jsx(Ze.Provider,{value:N,children:jsxRuntime.jsx($e.Provider,{value:re,children:jsxRuntime.jsxs(Re.Provider,{value:z,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",...ne,children:i}),f&&D&&r&&jsxRuntime.jsx(je,{activeId:f,render:H=>r(H,D),className:`${o.dragOverlay||""} ${f===g&&o.dismissPreview||""}`.trim()}),jsxRuntime.jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:M.map(H=>jsxRuntime.jsx(Qe,{tabId:H,target:w[H]||null,renderWidget:s},H))})]})})})};function He({containerRef:e,isRow:t,direction:n,splitPercentage:s,resizerSize:r,snapThreshold:o,layout:i,currentNode:a,onLayoutChange:u,onResizeStart:m,onResizeEnd:E,parentLeft:v,parentTop:P,parentWidth:S,parentHeight:R}){let{onResizeStart:L,onResize:f,onResizeEnd:D,minSplitPercentage:g=5,maxSplitPercentage:C=95,locked:b=false}=oe();return At.useCallback(I=>{if(b)return;I.preventDefault();let k=e.current;if(!k)return;m&&m(),L&&L(a);let B=k.getBoundingClientRect(),Y=I.clientX,$=I.clientY,K=s,V=I.currentTarget,X=B.left+B.width*(v/100),Q=B.top+B.height*(P/100),ee=B.width*(S/100),d=B.height*(R/100),Z=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(T=>T!==V&&T.getAttribute("data-direction")===n).map(T=>{let c=T.getBoundingClientRect();return t?c.left+c.width/2:c.top+c.height/2}),w=K;Se({cursor:t?"col-resize":"row-resize",resizerEl:V,onMove:T=>{let c=t?(T.clientX-Y)/ee*100:(T.clientY-$)/d*100,p=K+c,W=t?X+(ee-r)*(p/100)+r/2:Q+(d-r)*(p/100)+r/2,h=1/0,ne=null;for(let re of Z){let N=Math.abs(W-re);N<o&&N<h&&(h=N,ne=re);}let O=p;ne!==null&&(O=t?(ne-r/2-X)/(ee-r)*100:(ne-r/2-Q)/(d-r)*100);let F=Math.max(g,Math.min(C,O));w=F;let q=pe(i,a,F);if(q){let{panes:re,splitters:N}=ae(q),M=e.current;if(M){for(let z of re)M.style.setProperty(`--pane-left-${z.paneId}`,`${z.left}%`),M.style.setProperty(`--pane-top-${z.paneId}`,`${z.top}%`),M.style.setProperty(`--pane-width-${z.paneId}`,`${z.width}%`),M.style.setProperty(`--pane-height-${z.paneId}`,`${z.height}%`);for(let z of N)M.style.setProperty(`--splitter-pos-${z.id}`,`${z.direction==="row"?z.left:z.top}%`);}}f&&f(a,F);},onEnd:()=>{let T=pe(i,a,w),c=e.current;if(c){let{panes:p,splitters:W}=ae(T);for(let h of p)c.style.removeProperty(`--pane-left-${h.paneId}`),c.style.removeProperty(`--pane-top-${h.paneId}`),c.style.removeProperty(`--pane-width-${h.paneId}`),c.style.removeProperty(`--pane-height-${h.paneId}`);for(let h of W)c.style.removeProperty(`--splitter-pos-${h.id}`);}u(T),E&&E(),D&&D(a,w);}});},[e,t,n,s,r,o,i,a,u,m,E,L,f,D,g,C,v,P,S,R])}var Bt=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:s})=>{let{layout:r,setLayout:o,classNames:i,locked:a}=oe(),[u,m]=At.useState(false),{currentNode:E,direction:v,left:P,top:S,width:R,height:L,parentLeft:f,parentTop:D,parentWidth:g,parentHeight:C}=e,b=v==="row",I=He({containerRef:s,isRow:b,direction:v,splitPercentage:E.splitPercentage,resizerSize:t,snapThreshold:n,layout:r,currentNode:E,onLayoutChange:o,onResizeStart:()=>m(true),onResizeEnd:()=>m(false),parentLeft:f,parentTop:D,parentWidth:g,parentHeight:C}),k=b?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${P}%) - ${t/2}px)`,top:`calc(${S}% + ${t/2}px)`,width:`${t}px`,height:`calc(${L}% - ${t}px)`,cursor:a?"default":"col-resize",pointerEvents:a?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`calc(${P}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${S}%) - ${t/2}px)`,width:`calc(${R}% - ${t}px)`,height:`${t}px`,cursor:a?"default":"row-resize",pointerEvents:a?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"};return jsxRuntime.jsx("div",{className:i.resizer||"","data-direction":v,"data-resizing":u||void 0,style:k,onPointerDown:I,role:"separator","aria-valuenow":E.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},Wt=At__default.default.memo(({paneId:e,renderPane:t})=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane),Ut=({tree:e,resizerSize:t=4,snapThreshold:n})=>{let{layout:s,renderPane:r,activeId:o,dismissIntentId:i,setContainerRef:a,fullscreenPaneId:u,snapThreshold:m,locked:E,classNames:v}=oe(),P=n!==void 0?n:m??8,S=e!==void 0?e:s,R=At.useRef(null),{panes:L,splitters:f}=At.useMemo(()=>S?ae(S):{panes:[],splitters:[]},[S]);if(!S)return null;let D=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[L.map(g=>{let C=u===g.paneId;return jsxRuntime.jsx("div",{style:{position:"absolute",left:C?"0%":`var(--pane-left-${g.paneId}, ${g.left}%)`,top:C?"0%":`var(--pane-top-${g.paneId}, ${g.top}%)`,width:C?"100%":`var(--pane-width-${g.paneId}, ${g.width}%)`,height:C?"100%":`var(--pane-height-${g.paneId}, ${g.height}%)`,overflow:"hidden",zIndex:C?20:1,display:u&&!C?"none":"block",padding:C?"0px":`${t/2}px`,boxSizing:"border-box"},children:jsxRuntime.jsx(Wt,{paneId:g.paneId,renderPane:r})},g.paneId)}),!u&&f.map(g=>jsxRuntime.jsx(Bt,{splitter:g,resizerSize:t,snapThreshold:P,containerRef:R},g.id))]});if(e===void 0){let g=o!==null&&o===i,C=I=>{a(I),R.current=I;},b=`${v.dashboard||""} ${g&&v.dashboardDismissActive||""} ${E&&v.dashboardLocked||""}`.trim();return jsxRuntime.jsx("div",{ref:C,className:b,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:D()})}return jsxRuntime.jsx("div",{ref:R,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:D()})};var it="zeugma-height:",qt="default-pane";function Jt(e){try{let t=localStorage.getItem(it+e);if(t!==null){let n=Number(t);if(Number.isFinite(n)&&n>0)return n}}catch{}return null}function st(e,t){try{localStorage.setItem(it+e,String(Math.round(t)));}catch{}}var at=({children:e,active:t=true,height:n,onHeightChange:s,minHeight:r=100,maxHeight:o=1/0,persist:i,localStorageKey:a,resizerHeight:u=6,className:m,resizerClassName:E})=>{let v=i?a||qt:null,P=()=>{let b=(v?Jt(v):null)??n??400;return Ne(b,r,o)},[S,R]=At.useState(P),L=At.useRef(null),f=v?S:n??S,D=At.useRef(n);At.useEffect(()=>{if(n!==void 0&&n!==D.current){let b=Ne(n,r,o);R(b),v&&st(v,b);}D.current=n;},[n,r,o,v]);let g=At.useCallback(()=>o,[o]),C=At.useCallback(b=>{b.preventDefault();let I=b.clientY,k=f,B=g(),Y=b.currentTarget,$=lt(L.current),K=$?$.scrollTop:0,V=I,X=null,Q=(d,y)=>{let Z=y-K,T=d-I+Z,c=Ne(k+T,r,B);return L.current&&(L.current.style.height=`${c}px`),c},ee=()=>{if(!$)return;let d=$===document.documentElement||$===document.body?{top:0,bottom:window.innerHeight}:$.getBoundingClientRect(),y=40,Z=10,w=0;V>d.bottom-y?w=Math.min(1,(V-(d.bottom-y))/y)*Z:V<d.top+y&&(w=-Math.min(1,(d.top+y-V)/y)*Z),w!==0&&($.scrollTop+=w,Q(V,$.scrollTop)),X=requestAnimationFrame(ee);};X=requestAnimationFrame(ee),Se({cursor:"row-resize",resizerEl:Y,onMove:d=>{V=d.clientY,$&&Q(V,$.scrollTop);},onEnd:()=>{X!==null&&cancelAnimationFrame(X);let d=k;L.current&&(d=L.current.getBoundingClientRect().height),d=Ne(d,r,B),R(d),s&&s(d),v&&st(v,d);}});},[f,r,g,s,v]);return t?jsxRuntime.jsxs("div",{ref:L,className:`zeugma-resizable-container ${m||""}`.trim(),style:{height:`${f}px`,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:[jsxRuntime.jsx("div",{style:{height:`calc(100% - ${u}px)`,overflow:"hidden"},children:e}),jsxRuntime.jsx("div",{className:`zeugma-resizable-handle ${E||""}`.trim(),style:{height:`${u}px`,cursor:"row-resize",position:"relative",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box",flexShrink:0},onPointerDown:C,role:"separator","aria-orientation":"horizontal","aria-valuenow":Math.round(f),"aria-valuemin":r,"aria-valuemax":o===1/0?void 0:o})]}):jsxRuntime.jsx("div",{className:`zeugma-resizable-container disabled ${m||""}`.trim(),style:{height:"100%",position:"relative",overflow:"hidden",boxSizing:"border-box"},children:jsxRuntime.jsx("div",{style:{height:"100%",overflow:"hidden"},children:e})})};function Ne(e,t,n){return Math.max(t,Math.min(n,e))}function lt(e){if(typeof window>"u"||!e)return null;let t=e.parentElement;if(!t)return document.documentElement;let s=window.getComputedStyle(t).overflowY;return s==="auto"||s==="scroll"?t:lt(t)}var Le=At.createContext(null);var on={top:{position:"absolute",top:0,left:"25%",width:"50%",height:"25%",zIndex:20,pointerEvents:"auto"},bottom:{position:"absolute",bottom:0,left:"25%",width:"50%",height:"25%",zIndex:20,pointerEvents:"auto"},left:{position:"absolute",top:"25%",left:0,width:"25%",height:"50%",zIndex:20,pointerEvents:"auto"},right:{position:"absolute",top:"25%",right:0,width:"25%",height:"50%",zIndex:20,pointerEvents:"auto"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:20,pointerEvents:"auto",cursor:"not-allowed"}},sn={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"}},ct=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:s,isOver:r}=core.useDroppable({id:e});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:s,style:on[t]}),r&&jsxRuntime.jsx("div",{className:n,style:sn[t]})]})},an=({id:e,children:t,style:n,locked:s=false})=>{let r=At.useRef(null),{layout:o,activeId:i,classNames:a,fullscreenPaneId:u,onFullscreenChange:m,locked:E}=oe(),{removePane:v,updateTabMetadata:P,selectTab:S,removeTab:R}=De(),L=At.useContext(Re);if(!L)throw new Error("Pane must be used within a Zeugma provider");let{registerPortalTarget:f}=L,D=At.useMemo(()=>te(o,e),[o,e]),g=D?.id??e,C=D?.tabs??[e],b=D?.activeTabId??e,I=D?.tabsMetadata,k=I?.[e],B=D?.locked??false,Y=s||B,$=E||Y,K=E||Y,V=i!==null&&i!==e&&(!C.includes(i)||C.length>1)&&!K,{attributes:X,listeners:Q,setNodeRef:ee}=core.useDraggable({id:e,disabled:$}),d=i!==null&&C.includes(i),y=u===e,Z=At.useCallback(()=>jsxRuntime.jsx("div",{ref:r,id:`zeugma-tab-target-${b}`,className:"zeugma-tab-content-wrapper",style:{height:"100%",width:"100%"}}),[b]);At.useEffect(()=>{let p=r.current;return f(b,p),()=>{f(b,null);}},[b,f]);let w=At.useMemo(()=>({isDragging:d,isFullscreen:y,toggleFullscreen:()=>m?.(y?null:e),remove:()=>{y&&m?.(null),v(g);},metadata:k,updateMetadata:p=>{P(e,p);},locked:$,tabs:C,activeTabId:b,selectTab:p=>S(g,p),removeTab:p=>{y&&p===b&&m?.(null),R(p);},tabsMetadata:I,updateTabMetadata:(p,W)=>{P(p,W);},renderActiveTab:Z}),[d,y,m,e,R,k,P,$,C,b,S,g,I,Z]),T=At.useMemo(()=>$?{disabled:true}:{...Q,...X},[Q,X,$]),c=`${a.pane||""} ${Y&&a.paneLocked||""}`.trim();return jsxRuntime.jsx(Le.Provider,{value:T,children:jsxRuntime.jsxs("div",{ref:ee,className:c,style:{position:"relative",width:"100%",height:"100%",...n},children:[t(w),V&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:["top","bottom","left","right"].map(p=>jsxRuntime.jsx(ct,{id:`drop-${p}-${e}`,position:p,activeClassName:a.dropPreview},p))}),i!==null&&i!==e&&K&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsxRuntime.jsx(ct,{id:`drop-locked-${e}`,position:"full",activeClassName:a.lockedPreview||""})})]})})};var un=({children:e,className:t,style:n})=>{let s=At.useContext(Le);if(!s)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:r,...o}=s;return jsxRuntime.jsx("div",{className:t,style:{cursor:r?"default":"grab",userSelect:r?"auto":"none",touchAction:r?"auto":"none",...n},...r?{}:o,children:e})};var mn=({id:e,locked:t=false,children:n,className:s,style:r})=>{let{locked:o,classNames:i={},overTabId:a,overTabPosition:u}=oe(),m=t||o,{attributes:E,listeners:v,setNodeRef:P,isDragging:S}=core.useDraggable({id:`tab-header-${e}`,disabled:m}),{setNodeRef:R,isOver:L}=core.useDroppable({id:`tab-drop-${e}`,disabled:m}),f=C=>{P(C),R(C);},D=L&&a===e,g=D?u:null;return jsxRuntime.jsxs("div",{ref:f,className:s,style:{display:"inline-flex",position:"relative",cursor:m?"default":"grab",...r},...m?{}:v,...m?{}:E,children:[n({isDragging:S,isOver:D}),D&&g&&jsxRuntime.jsx("div",{className:i.tabDropPreview||"",style:{position:"absolute",top:0,bottom:0,width:"2px",backgroundColor:"#6366f1",left:g==="before"?0:void 0,right:g==="after"?0:void 0,pointerEvents:"none",zIndex:10}})]})};exports.DEFAULT_DRAG_ACTIVATION_DISTANCE=bt;exports.DEFAULT_RESIZER_SIZE=Pn;exports.DEFAULT_SNAP_THRESHOLD=gt;exports.DragHandle=un;exports.Pane=an;exports.PaneTree=Ut;exports.PortalRegistryContext=Re;exports.ResizableContainer=at;exports.Tab=mn;exports.Zeugma=Zt;exports.ZeugmaActionsContext=Ze;exports.ZeugmaStateContext=$e;exports.createDragSession=Se;exports.safeJsonStringify=he;exports.useResizer=He;exports.useZeugma=ht;exports.useZeugmaActions=De;exports.useZeugmaContext=Pt;exports.useZeugmaState=oe;//# sourceMappingURL=index.cjs.map
7
7
  //# sourceMappingURL=index.cjs.map