react-zeugma 6.9.4 → 6.9.5

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
@@ -284,14 +284,14 @@ const controller = useZeugma({
284
284
 
285
285
  ##### Options
286
286
 
287
- | Parameter | Description | Type | Default |
288
- | -------------------- | --------------------------------------------------------------------------- | --------------------------------------- | ------- |
289
- | `initialLayout` | Initial layout tree structure. Only used on mount. | `TreeNode \| null` | `null` |
290
- | `layout` | Controlled layout tree structure. Hook runs in controlled mode if provided. | `TreeNode \| null` | `null` |
291
- | `onChange` | Callback triggered when the layout tree updates. | `(newLayout: TreeNode \| null) => void` | - |
292
- | `fullscreenPaneId` | Controlled fullscreen pane ID. | `string \| null` | `null` |
293
- | `onFullscreenChange` | Callback triggered when fullscreen state toggles. | `(paneId: string \| null) => void` | - |
294
- | `locked` | Global lock status to disable resizing and drag-and-drop operations. | `boolean` | `false` |
287
+ | Parameter | Description | Type | Default |
288
+ | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------- | ------- |
289
+ | `initialLayout` | Initial layout tree structure. Only used on mount. | `TreeNode \| null` | `null` |
290
+ | `layout` | Controlled layout tree structure. Hook runs in controlled mode if provided. | `TreeNode \| null` | `null` |
291
+ | `onChange` | Callback triggered when the layout tree updates. | `(newLayout: TreeNode \| null) => void` | - |
292
+ | `fullscreenPaneId` | Controlled fullscreen pane ID. When active (not null), structural layout changes (closes, additions, splits, merges, resizes, and popouts) are blocked at the API level. | `string \| null` | `null` |
293
+ | `onFullscreenChange` | Callback triggered when fullscreen state toggles. | `(paneId: string \| null) => void` | - |
294
+ | `locked` | Global lock status to disable resizing and drag-and-drop operations. | `boolean` | `false` |
295
295
 
296
296
  ---
297
297
 
@@ -310,32 +310,32 @@ const { layout, locked, setLocked, addTab, removePane, selectTab, findPaneById }
310
310
 
311
311
  ##### Context Values
312
312
 
313
- | Property / Method | Description | Type |
314
- | ----------------------- | -------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
315
- | `layout` | The current active layout tree structure. | `TreeNode \| null` |
316
- | `fullscreenPaneId` | The ID of the maximized fullscreen pane. | `string \| null` |
317
- | `locked` | Whether the dashboard layout is globally locked. | `boolean` |
318
- | `setLayout` | React state setter to update the layout tree. | `Dispatch<SetStateAction<TreeNode \| null>>` |
319
- | `setFullscreenPaneId` | Updates the active fullscreen pane ID. | `(paneId: string \| null) => void` |
320
- | `setLocked` | Updates the global layout lock state. | `Dispatch<SetStateAction<boolean>>` |
321
- | `removePane` | Removes a pane and collapses the split. | `(paneId: string) => void` |
322
- | `addTab` | Adds a tab to a pane, or splits/creates one if target is omitted. | `(tabId: string, targetPaneId?: string, metadata?: Record<string, unknown>) => void` |
323
- | `updateMetadata` | Mutates a specific tab's metadata. | `(id: string, updater: (current: Record<string, unknown> \| undefined) => Record<string, unknown> \| undefined) => void` |
324
- | `updatePaneLock` | Toggles the lock status of a specific pane. | `(paneId: string, locked: boolean) => void` |
325
- | `selectTab` | Focuses/activates a tab within a pane. | `(paneId: string, tabId: string) => void` |
326
- | `mergeTab` | Programmatically drags and drops a tab from one pane to another. | `(draggedTabId: string, targetPaneId: string) => void` |
327
- | `removeTab` | Programmatically closes a tab. | `(tabId: string) => void` |
328
- | `splitPane` | Programmatically splits a pane node and adds a new one. | `(targetId: string, direction: SplitDirection, splitType: 'left' \| 'right' \| 'top' \| 'bottom', paneToAdd: string) => void` |
329
- | `updateSplitPercentage` | Updates a SplitNode percentage. | `(currentNode: SplitNode, percentage: number) => void` |
330
- | `moveTab` | Reorders a tab next to another, or swaps them if position is 'center'. | `(draggedTabId: string, targetTabId: string, position?: 'before' \| 'after' \| 'center') => void` |
331
- | `findPaneById` | Queries a PaneNode by its unique ID. | `(paneId: string) => PaneNode \| null` |
332
- | `findPaneContainingTab` | Queries the parent PaneNode of a tab ID. | `(tabId: string) => PaneNode \| null` |
333
- | `findTabById` | Queries detailed tab location and state metadata. | `(tabId: string) => TabDetails \| null` |
334
- | `getTabMetadata` | Gets metadata for a tab ID. | `(tabId: string) => Record<string, unknown> \| undefined` |
335
- | `getActiveTabMetadata` | Gets metadata for the active tab in a pane. | `(paneId: string) => Record<string, unknown> \| undefined` |
336
- | `poppedOutTabIds` | **[Experimental]** The list of tab/widget IDs that are currently open in a new window. | `string[]` |
337
- | `popoutTab` | **[Experimental]** Popout the specified tab into a new window. | `(tabId: string) => void` |
338
- | `dockTab` | **[Experimental]** Dock the specified tab back to the main layout. | `(tabId: string) => void` |
313
+ | Property / Method | Description | Type |
314
+ | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
315
+ | `layout` | The current active layout tree structure. | `TreeNode \| null` |
316
+ | `fullscreenPaneId` | The ID of the maximized fullscreen pane. When active, structural layout changes (closes, additions, splits, merges, resizes, and popouts) are blocked at the API level. | `string \| null` |
317
+ | `locked` | Whether the dashboard layout is globally locked. | `boolean` |
318
+ | `setLayout` | React state setter to update the layout tree. | `Dispatch<SetStateAction<TreeNode \| null>>` |
319
+ | `setFullscreenPaneId` | Updates the active fullscreen pane ID. | `(paneId: string \| null) => void` |
320
+ | `setLocked` | Updates the global layout lock state. | `Dispatch<SetStateAction<boolean>>` |
321
+ | `removePane` | Removes a pane and collapses the split. | `(paneId: string) => void` |
322
+ | `addTab` | Adds a tab to a pane, or splits/creates one if target is omitted. | `(tabId: string, targetPaneId?: string, metadata?: Record<string, unknown>) => void` |
323
+ | `updateMetadata` | Mutates a specific tab's metadata. | `(id: string, updater: (current: Record<string, unknown> \| undefined) => Record<string, unknown> \| undefined) => void` |
324
+ | `updatePaneLock` | Toggles the lock status of a specific pane. | `(paneId: string, locked: boolean) => void` |
325
+ | `selectTab` | Focuses/activates a tab within a pane. | `(paneId: string, tabId: string) => void` |
326
+ | `mergeTab` | Programmatically drags and drops a tab from one pane to another. | `(draggedTabId: string, targetPaneId: string) => void` |
327
+ | `removeTab` | Programmatically closes a tab. | `(tabId: string) => void` |
328
+ | `splitPane` | Programmatically splits a pane node and adds a new one. | `(targetId: string, direction: SplitDirection, splitType: 'left' \| 'right' \| 'top' \| 'bottom', paneToAdd: string) => void` |
329
+ | `updateSplitPercentage` | Updates a SplitNode percentage. | `(currentNode: SplitNode, percentage: number) => void` |
330
+ | `moveTab` | Reorders a tab next to another, or swaps them if position is 'center'. | `(draggedTabId: string, targetTabId: string, position?: 'before' \| 'after' \| 'center') => void` |
331
+ | `findPaneById` | Queries a PaneNode by its unique ID. | `(paneId: string) => PaneNode \| null` |
332
+ | `findPaneContainingTab` | Queries the parent PaneNode of a tab ID. | `(tabId: string) => PaneNode \| null` |
333
+ | `findTabById` | Queries detailed tab location and state metadata. | `(tabId: string) => TabDetails \| null` |
334
+ | `getTabMetadata` | Gets metadata for a tab ID. | `(tabId: string) => Record<string, unknown> \| undefined` |
335
+ | `getActiveTabMetadata` | Gets metadata for the active tab in a pane. | `(paneId: string) => Record<string, unknown> \| undefined` |
336
+ | `poppedOutTabIds` | **[Experimental]** The list of tab/widget IDs that are currently open in a new window. | `string[]` |
337
+ | `popoutTab` | **[Experimental]** Popout the specified tab into a new window. | `(tabId: string) => void` |
338
+ | `dockTab` | **[Experimental]** Dock the specified tab back to the main layout. | `(tabId: string) => void` |
339
339
 
340
340
  ---
341
341
 
@@ -503,24 +503,38 @@ const parentPane = findPaneContainingTab(currentTree, 'new-file.js')
503
503
  > [!WARNING]
504
504
  > Popout window capabilities (opening tabs in separate browser windows via `window.open` and React portals) are **experimental** and may experience limitations or browser warnings depending on popup blockers, iframe restrictions, and context cleanup in third-party libraries. Use with caution in production.
505
505
 
506
- When using CSS-in-JS libraries like `styled-components` or `antd` (Ant Design) inside your widgets, dynamic styles and modals/portals are injected into the main document's `head`/`body` by default. In popped-out tabs, these styles will not apply because they render inside a separate window.
506
+ > [!NOTE]
507
+ > React Zeugma automatically clones and synchronizes all static stylesheets, `<link>` tags, and document attributes (such as `data-theme` or body classes) from the main window to any active popout window in real-time. You only need `renderPopoutWrapper` to configure dynamic CSS-in-JS style injection and context provider redirection.
508
+
509
+ When using CSS-in-JS libraries like `styled-components` or `antd` (Ant Design) inside your widgets, dynamic styles are injected into the main document's `<head>` by default. In popped-out tabs, these dynamic styles will not apply because they render inside a separate window. Additionally, shared JS context caches will prevent styles from being re-emitted unless a separate cache instance is created.
507
510
 
508
511
  You can use the `renderPopoutWrapper` callback prop on the `<Zeugma>` component to wrap popped-out widgets with the required style managers and providers targeting the child window's DOM.
509
512
 
510
513
  ##### Example (`styled-components` & `antd`):
511
514
 
512
515
  ```tsx
516
+ import React, { useMemo } from 'react'
513
517
  import { StyleSheetManager } from 'styled-components'
514
- import { StyleProvider } from '@ant-design/cssinjs'
518
+ import { StyleProvider, createCache } from '@ant-design/cssinjs'
515
519
  import { ConfigProvider } from 'antd'
516
- ;<Zeugma
517
- controller={controller}
518
- renderPopoutWrapper={({ document, children }) => (
520
+
521
+ // Using a wrapper component is recommended to safely instantiate a style cache per popout window
522
+ const PopoutStyleManager = ({ document, children }) => {
523
+ const cache = useMemo(() => createCache(), [])
524
+
525
+ return (
519
526
  <StyleSheetManager target={document.head}>
520
- <StyleProvider container={document.head}>
527
+ <StyleProvider cache={cache} container={document.head}>
521
528
  <ConfigProvider getPopupContainer={() => document.body}>{children}</ConfigProvider>
522
529
  </StyleProvider>
523
530
  </StyleSheetManager>
531
+ )
532
+ }
533
+
534
+ ;<Zeugma
535
+ controller={controller}
536
+ renderPopoutWrapper={({ document, children }) => (
537
+ <PopoutStyleManager document={document}>{children}</PopoutStyleManager>
524
538
  )}
525
539
  >
526
540
  {/* Dashboard grid structure */}
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var ge=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 ge__default=/*#__PURE__*/_interopDefault(ge);function It({cursor:e,resizerEl:t,onMove:n,onEnd:a}){document.body.classList.add("zeugma-resizing");let o=document.createElement("style");o.id="zeugma-global-cursor-style",o.textContent=`
1
+ 'use strict';var be=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 be__default=/*#__PURE__*/_interopDefault(be);function It({cursor:e,resizerEl:t,onMove:n,onEnd:a}){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,7 +6,7 @@
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 c=i=>{n(i);},u=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let i=document.getElementById("zeugma-global-cursor-style");i&&i.remove(),document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",u),a();};document.addEventListener("pointermove",c),document.addEventListener("pointerup",u);}function Ae(e){try{return JSON.stringify(e)}catch{return ""}}var pt=ge.createContext(void 0),we=ge.createContext(void 0),Pe=ge.createContext(void 0),ft=ge.createContext(void 0),re=()=>{let e=ge.useContext(pt);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},ze=()=>{let e=ge.useContext(we);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e},Ue=()=>{let e=ge.useContext(ft);if(!e)throw new Error("useZeugmaDrag must be used within a Zeugma provider");return e};function Mt(e){let t=ge.useRef(null);return ge.useEffect(()=>{if(!e){t.current=null;return}let n=o=>{t.current={x:o.clientX,y:o.clientY};},a=o=>{let c=o.touches[0]||o.changedTouches[0];c&&(t.current={x:c.clientX,y:c.clientY});};return window.addEventListener("pointermove",n,{passive:true}),window.addEventListener("touchmove",a,{passive:true}),()=>{window.removeEventListener("pointermove",n),window.removeEventListener("touchmove",a);}},[e]),t}function kt(e){ge.useEffect(()=>(e?document.body.style.setProperty("cursor","not-allowed","important"):document.body.style.removeProperty("cursor"),()=>{document.body.style.removeProperty("cursor");}),[e]);}function Ot(){let[e,t]=ge.useState({}),[n,a]=ge.useState({}),o=ge.useRef({}),c=ge.useRef(null),u=ge.useRef({}),i=ge.useRef(null),d=ge.useRef(true);ge.useEffect(()=>(d.current=true,()=>{d.current=false;}),[]);let f=ge.useCallback((P,D,L)=>{d.current&&t(v=>{if(!D){if(L&&v[P]!==L||!v[P])return v;let $={...v};return delete $[P],$}return v[P]===D?v:{...v,[P]:D}});},[]),s=ge.useCallback((P,D)=>{d.current&&a(L=>{if(!D){if(!L[P])return L;let v={...L};return delete v[P],v}return L[P]===D?L:{...L,[P]:D}});},[]),b=ge.useCallback((P,D)=>{o.current[P]=D;},[]),g=ge.useCallback(P=>{c.current=P;},[]),m=ge.useCallback((P,D)=>{u.current[P]=D;},[]);return {portalTargets:ge.useMemo(()=>({...e,...n}),[e,n]),registerPortalTarget:f,registerPopoutTarget:s,registerRenderCallback:b,renderCallbacksRef:o,registerRenderPane:g,renderPaneRef:c,registerTabHeader:m,tabHeadersRef:u,activeIdRef:i}}function An(e){let t=new Set;function n(a){a&&(a.type==="pane"?a.tabIds.forEach(o=>{t.add(o);}):a.type==="split"&&(n(a.first),n(a.second)));}return n(e),Array.from(t).sort()}function At(e){return ge.useMemo(()=>An(e),[e])}function zt(e){let{onDragStart:t,onDragEnd:n}=e,[a,o]=ge.useState(null),[c,u]=ge.useState(null),i=ge.useCallback(f=>{t&&t(f);},[t]),d=ge.useCallback((f,s,b)=>{n&&n(f,s,b);},[n]);return {overTabId:a,setOverTabId:o,overTabPosition:c,setOverTabPosition:u,handleDragStartInternal:i,handleDragEndInternal:d}}function Zt(e){let n=ge.useContext(Pe)?.registerRenderPane;ge.useEffect(()=>{n&&e&&n(e);},[n,e]);}function pe(){return "pane-"+Math.random().toString(36).substring(2,11)}function be(e,t){if(e===null)return null;if(e.type==="pane")return e.id===t?null:e;let n=be(e.first,t),a=be(e.second,t);return n===null?a:a===null?n:{...e,first:n,second:a}}function fe(e,t){if(e===null)return null;if(e.type==="pane"){if(e.tabIds.includes(t)){let o=e.tabIds.filter(i=>i!==t);if(o.length===0)return null;let c=e.activeTabId;e.activeTabId===t&&(c=o[0]);let u={...e.tabsMetadata};return delete u[t],{...e,tabIds:o,activeTabId:c,tabsMetadata:Object.keys(u).length>0?u:void 0}}return e}let n=fe(e.first,t),a=fe(e.second,t);return n===null?a:a===null?n:{...e,first:n,second:a}}function Se(e,t,n,a,o){if(e===null)return typeof o=="string"?{type:"pane",id:pe(),tabIds:[o],activeTabId:o}:o;if(e.type==="pane"){if(e.id===t){let c=typeof o=="string"?{type:"pane",id:pe(),tabIds:[o],activeTabId:o}:o,u=a==="left"||a==="top";return {type:"split",direction:n,first:u?c:e,second:u?e:c,splitPercentage:50}}return e}return {...e,first:Se(e.first,t,n,a,o)||e.first,second:Se(e.second,t,n,a,o)||e.second}}function zn(e,t){if(e===null)return t;function n(a,o){return a.type==="pane"?{type:"split",direction:o==="row"?"column":"row",splitPercentage:50,first:a,second:t}:{...a,second:n(a.second,a.direction)}}return n(e,null)}function Ht(e,t,n,a){if(e===null)return {type:"pane",id:pe(),tabIds:[n],activeTabId:n,tabsMetadata:a?{[n]:a}:void 0};let o=t?te(e,t):null;if(o&&o.type==="pane"){let i=function(d){if(d.type==="pane"&&d.id===t){let f=[...d.tabIds];f.includes(n)||f.push(n);let s=d.tabsMetadata;return a&&(s={...d.tabsMetadata,[n]:a}),{...d,tabIds:f,activeTabId:n,tabsMetadata:s}}return d.type==="split"?{...d,first:i(d.first),second:i(d.second)}:d};return i(e)}let c={type:"pane",id:pe(),tabIds:[n],activeTabId:n,tabsMetadata:a?{[n]:a}:void 0};return zn(e,c)}function xe(e,t,n){return e===null?null:e===t?{...e,splitPercentage:n}:e.type==="split"?{...e,first:xe(e.first,t,n)||e.first,second:xe(e.second,t,n)||e.second}:e}function te(e,t){return e===null?null:e.type==="pane"?e.id===t?e:null:e.type==="split"?te(e.first,t)??te(e.second,t):null}function U(e,t){return e===null?null:e.type==="pane"?e.tabIds.includes(t)?e:null:e.type==="split"?U(e.first,t)??U(e.second,t):null}function $t(e,t){return te(e,t)??U(e,t)}function Qe(e,t){let n=U(e,t);if(!n)return null;let a=n.tabIds.indexOf(t);return {id:t,paneId:n.id,isActive:n.activeTabId===t,index:a,metadata:n.tabsMetadata?.[t],remountOnPopout:n.tabsMetadata?.[t]?.remountOnPopout}}function _t(e,t){return U(e,t)?.tabsMetadata?.[t]}function Bt(e,t){let n=te(e,t);return n?.tabsMetadata?.[n.activeTabId]}function Je(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.tabIds.includes(t)){let a=e.tabsMetadata||{},o=a[t],c=n(o),u={...a};return c===void 0?delete u[t]:u[t]=c,{...e,tabsMetadata:Object.keys(u).length>0?u:void 0}}return e}return e.type==="split"?{...e,first:Je(e.first,t,n)??e.first,second:Je(e.second,t,n)??e.second}:e}function Ge(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.id===t){if(n===false){let{locked:a,...o}=e;return o}return {...e,locked:n}}return e}return e.type==="split"?{...e,first:Ge(e.first,t,n)??e.first,second:Ge(e.second,t,n)??e.second}:e}function Ne(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:Ne(e.first,t,n)??e.first,second:Ne(e.second,t,n)??e.second}:e}function Ft(e,t,n){if(e===null)return null;let o=U(e,t)?.tabsMetadata?.[t],c=fe(e,t);if(c===null)return {type:"pane",id:pe(),tabIds:[t],activeTabId:t,tabsMetadata:o?{[t]:o}:void 0};function u(i){if(i.type==="pane"){if(i.id===n){let d=[...i.tabIds];d.includes(t)||d.push(t);let f={...i.tabsMetadata};return o&&(f[t]=o),{...i,tabIds:d,activeTabId:t,tabsMetadata:Object.keys(f).length>0?f:void 0}}return i}return i.type==="split"?{...i,first:u(i.first),second:u(i.second)}:i}return u(c)}function Zn(e,t,n){if(e===null)return null;if(t===n)return e;let a=U(e,t),o=U(e,n);if(!a||!o)return e;let c=a.id,u=o.id,i=a.tabsMetadata?.[t],d=o.tabsMetadata?.[n];function f(s){if(s.type==="pane"){let b=false,g=[...s.tabIds],m=s.activeTabId,y=s.tabsMetadata?{...s.tabsMetadata}:{};if(c===u){if(s.id===c){let P=g.indexOf(t),D=g.indexOf(n);P!==-1&&D!==-1&&(g[P]=n,g[D]=t),m=t,b=true;}}else s.id===c&&(g=g.map(P=>P===t?n:P),m===t&&(m=n),delete y[t],d&&(y[n]=d),b=true),s.id===u&&(g=g.map(P=>P===n?t:P),m===n&&(m=t),delete y[n],i&&(y[t]=i),b=true);return b?{...s,tabIds:g,activeTabId:m,tabsMetadata:Object.keys(y).length>0?y:void 0}:s}return s.type==="split"?{...s,first:f(s.first),second:f(s.second)}:s}return f(e)}function Ze(e,t,n,a="before"){if(e===null)return null;if(t===n)return e;if(a==="center")return Zn(e,t,n);let c=U(e,t)?.tabsMetadata?.[t],u=fe(e,t);if(u===null)return {type:"pane",id:pe(),tabIds:[t],activeTabId:t,tabsMetadata:c?{[t]:c}:void 0};function i(d){if(d.type==="pane"){if(d.tabIds.includes(n)){let s=[...d.tabIds].filter(m=>m!==t),b=s.indexOf(n);b<0&&(b=0),a==="after"&&(b+=1),s.splice(b,0,t);let g={...d.tabsMetadata};return c&&(g[t]=c),{...d,tabIds:s,activeTabId:t,tabsMetadata:Object.keys(g).length>0?g:void 0}}return d}return d.type==="split"?{...d,first:i(d.first),second:i(d.second)}:d}return i(u)}function ve(e,t=0,n=0,a=100,o=100,c="root"){if(e===null)return {panes:[],splitters:[]};if(e.type==="pane")return {panes:[{paneId:e.id,left:t,top:n,width:a,height:o,node:e}],splitters:[]};let{direction:u,splitPercentage:i,first:d,second:f}=e,b={id:`splitter-${c}-${u}`,currentNode:e,direction:u,left:u==="row"?t+a*(i/100):t,top:u==="column"?n+o*(i/100):n,width:u==="row"?0:a,height:u==="column"?0:o,parentLeft:t,parentTop:n,parentWidth:a,parentHeight:o},g={panes:[],splitters:[]},m={panes:[],splitters:[]};if(u==="row"){let y=a*(i/100);g=ve(d,t,n,y,o,`${c}-L`),m=ve(f,t+y,n,a-y,o,`${c}-R`);}else {let y=o*(i/100);g=ve(d,t,n,a,y,`${c}-T`),m=ve(f,t,n+y,a,o-y,`${c}-B`);}return {panes:[...g.panes,...m.panes],splitters:[b,...g.splitters,...m.splitters]}}function Vt(e,t,n,a="before"){if(e===null)return null;let o=te(e,t);if(!o)return e;let c=o.tabIds,u=o.activeTabId,i=o.tabsMetadata||{},d=be(e,t);if(d===null)return o;function f(s){if(s.type==="pane"){if(s.tabIds.includes(n)){let g=[...s.tabIds].filter(P=>!c.includes(P)),m=g.indexOf(n);m<0&&(m=0),a==="after"&&(m+=1),g.splice(m,0,...c);let y={...s.tabsMetadata};for(let P of c)i[P]&&(y[P]=i[P]);return {...s,tabIds:g,activeTabId:u,tabsMetadata:Object.keys(y).length>0?y:void 0}}return s}return s.type==="split"?{...s,first:f(s.first),second:f(s.second)}:s}return f(d)}function Wt(e,t,n,a){if(!((t==="tab"||t==="pane")&&n&&e.includes(n))||!a)return -1;let u=e.indexOf(n);return a==="before"?u:u+1}function Hn(e){let{initialLayout:t,layout:n,onChange:a,fullscreenPaneId:o,onFullscreenChange:c,locked:u=false}=e,[i,d]=ge.useState(()=>n!==void 0?n:t??null),[f,s]=ge.useState(()=>n!==void 0?n:t??null),[b,g]=ge.useState(()=>Ae(n!==void 0?n:null)),[m,y]=ge.useState(o||null),[P,D]=ge.useState(u),[L,v]=ge.useState([]),[$,E]=ge.useState(null),[O,Z]=ge.useState(null),[r,l]=ge.useState(null),h=ge.useRef(null),R=ge.useCallback(p=>{h.current=p;},[]),M=ge.useRef(i);M.current=i;let q=ge.useRef(a);q.current=a;let ne=ge.useRef(c);ne.current=c;let J=ge.useCallback(p=>{y(p),ne.current?.(p);},[]);if(ge.useEffect(()=>{D(u);},[u]),ge.useEffect(()=>{o!==void 0&&y(o);},[o]),n!==void 0){let p=Ae(n);p!==b&&(g(p),d(n),s(n),v(T=>{if(T.length===0)return T;let x=T.filter(H=>Qe(n,H)!==null);return x.length===T.length?T:x}));}let A=ge.useCallback(p=>(...T)=>{let x=M.current,H=p(x,...T);Ae(x)!==Ae(H)&&(M.current=H,d(H),s(H),v(F=>{if(F.length===0)return F;let ie=F.filter(W=>Qe(H,W)!==null);return ie.length===F.length?F:ie}),q.current?.(H));},[]),_=ge.useCallback(A((p,T)=>typeof T=="function"?T(p):T),[A]),j=ge.useCallback(p=>{s(T=>typeof p=="function"?p(T):p);},[]),V=ge.useCallback(p=>{y(null),ne.current?.(null),E(null),Z(null),l(null),_(p),s(()=>typeof p=="function"?p(M.current):p);},[_]),B=ge.useCallback(A((p,T)=>be(p,T)),[A]),N=ge.useCallback(A((p,T,x,H)=>{let F=fe(p,T)??p;return Ht(F,x,T,H)}),[A]),w=ge.useCallback(A((p,T,x,H,F)=>{let ie=te(p,T)??U(p,T);if(!ie)return p;let W=te(p,F)??U(p,F)??{type:"pane",id:F,tabIds:[F],activeTabId:F},Te=be(p,W.id);return Se(Te,ie.id,x,H,W)}),[A]),z=ge.useCallback(A((p,T,x)=>xe(p,T,x)),[A]),C=ge.useCallback(A((p,T,x)=>Je(p,T,x)),[A]),k=ge.useCallback(A((p,T,x)=>{let H=te(p,T)??U(p,T);return H?Ge(p,H.id,x):p}),[A]),ue=ge.useCallback(A((p,T,x)=>{let H=te(p,T)??U(p,T);return H?Ne(p,H.id,x):p}),[A]),Q=ge.useCallback(A((p,T,x)=>{let H=te(p,x)??U(p,x);return H?Ft(p,T,H.id):p}),[A]),K=ge.useCallback(A((p,T,x,H)=>Ze(p,T,x,H)),[A]),Y=ge.useCallback(A((p,T)=>fe(p,T)),[A]),ee=ge.useCallback(p=>te(M.current,p),[]),S=ge.useCallback(p=>U(M.current,p),[]),I=ge.useCallback(p=>Qe(M.current,p),[]),se=ge.useCallback(p=>_t(M.current,p),[]),le=ge.useCallback(p=>Bt(M.current,p),[]),G=ge.useCallback(p=>{v(T=>T.includes(p)?T:[...T,p]);},[]),oe=ge.useCallback(p=>{v(T=>T.includes(p)?T.filter(x=>x!==p):T);},[]);return {layout:i,setLayout:V,_internalSetLayout:j,renderingLayout:f,fullscreenPaneId:m,setFullscreenPaneId:J,locked:P,setLocked:D,poppedOutTabIds:L,activeId:$,setActiveId:E,activeType:O,setActiveType:Z,dismissIntentId:r,setDismissIntentId:l,containerRef:h,setContainerRef:R,removePane:B,addTab:N,updateMetadata:C,updatePaneLock:k,selectTab:ue,mergeTab:Q,moveTab:K,removeTab:Y,splitPane:w,updateSplitPercentage:z,popoutTab:G,dockTab:oe,findPaneById:ee,findPaneContainingTab:S,findTabById:I,getTabMetadata:se,getActiveTabMetadata:le}}var $n=()=>{let e=re(),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,poppedOutTabIds:e.poppedOutTabIds,popoutTab:t.popoutTab,dockTab:t.dockTab}};var et=class extends core.PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},tt=class extends core.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};var qt=e=>{let n=e.active.id.toString().startsWith("tab-header-"),o=core.pointerWithin(e);if(o.length>0)return [...o].sort((u,i)=>{let d=u.id.toString(),f=i.id.toString(),s=d.startsWith("tab-drop-"),b=f.startsWith("tab-drop-");if(s&&!b)return -1;if(!s&&b)return 1;let g=d.startsWith("drop-root-"),m=f.startsWith("drop-root-");return g&&!m?-1:!g&&m?1:0});if(n){let c=e.droppableContainers.filter(u=>u.id.toString().startsWith("tab-drop-"));return core.closestCenter({...e,droppableContainers:c})}return []};function He(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 Yt(e){let{layout:t,_internalSetLayout:n,setLayout:a,activeId:o,setActiveId:c,activeType:u,setActiveType:i,dismissIntentId:d,setDismissIntentId:f,setOverTabId:s,setOverTabPosition:b,containerRef:g,dragActivationDistance:m,enableDragToDismiss:y,dismissThreshold:P,onRemove:D,onDragStart:L,onDragEnd:v,onDismissIntentChange:$,removeTab:E,removePane:O}=e,Z=ge.useRef(null),r=Mt(o),l=ge.useRef(null),[h,R]=ge.useState(false);return kt(h),{sensors:core.useSensors(core.useSensor(et,{activationConstraint:{distance:m}}),core.useSensor(tt,{activationConstraint:{delay:250,tolerance:5}})),collisionDetection:qt,onDragStart:_=>{let j=_.active.id.toString(),V=j.startsWith("tab-header-"),B=V?j.substring(11):j;c(B),i(V?"tab":"pane"),s(null),b(null);let N=_.activatorEvent;r.current=He(N),y&&g.current?Z.current=g.current.getBoundingClientRect():Z.current=null;let w=t;if(V){let C=U(t,B);C&&(w=Ne(t,C.id,B)||t);}l.current=w;let z=V?fe(w,B):be(w,B);n(z),L&&L(B);},onDragMove:_=>{let{over:j}=_,V=j?.id.toString()||"",B=V.startsWith("drop-locked-");R(S=>S===B?S:B);let N=_.active.id.toString(),w=N.startsWith("tab-header-"),z=w?N.substring(11):N,C=V.match(/^tab-drop-(.+)$/);if(C&&j&&(w||u==="pane")){let[,S]=C;if(z!==S){let I="before",se=j.rect,le=_.activatorEvent,G=null;if(r.current)G=r.current.x;else {let oe=He(le);oe&&(G=oe.x+_.delta.x);}if(G!==null){let oe=se.left+se.width/2;G>oe&&(I="after");}s(oe=>oe===S?oe:S),b(oe=>oe===I?oe:I);}else s(I=>I===null?I:null),b(I=>I===null?I:null);}else s(S=>S===null?S:null),b(S=>S===null?S:null);if(!y)return;let k=Z.current;if(!k){d!==null&&(f(null),$?.(null));return}let ue=_.activatorEvent,Q=null,K=null;if(r.current)Q=r.current.x,K=r.current.y;else {let S=He(ue);S&&(Q=S.x+_.delta.x,K=S.y+_.delta.y);}let Y=0;if(Q!==null&&K!==null){let S=0,I=0;Q<k.left?S=k.left-Q:Q>k.right&&(S=Q-k.right),K<k.top?I=k.top-K:K>k.bottom&&(I=K-k.bottom),Y=Math.sqrt(S*S+I*I);}else {let S=_.active.rect.current.translated;if(S){let I=S.left+S.width/2,se=S.top+S.height/2,le=0,G=0;I<k.left?le=k.left-I:I>k.right&&(le=I-k.right),se<k.top?G=k.top-se:se>k.bottom&&(G=se-k.bottom),Y=Math.sqrt(le*le+G*G);}}Y>P?d!==z&&(f(z),$?.(z)):d!==null&&(f(null),$?.(null));},onDragEnd:_=>{c(null),i(null),R(false),s(null),b(null);let{active:j,over:V}=_,B=j.id.toString(),N=B.startsWith("tab-header-"),w=N?B.substring(11):B,z=y&&d===w;f(null),$?.(null),Z.current=null;let C=l.current||t;if(l.current=null,z){D?D(w):N?E(w):O(w),v&&v(w,null,null);return}if(!V){n(C),v&&v(w,null,null);return}let k=V.id.toString();if(k.startsWith("drop-locked-")){n(C),v&&v(w,null,null);return}let ue=k.match(/^tab-drop-(.+)$/);if(ue){let[,p]=ue;if(N)if(w!==p){let T="before",x=V.rect,H=_.activatorEvent,F=null;if(r.current)F=r.current.x;else {let W=He(H);W&&(F=W.x+_.delta.x);}if(F!==null){let W=x.left+x.width/2;F>W&&(T="after");}let ie=Ze(C,w,p,T);a(ie),v&&v(w,p,{type:"move",position:"center"});}else n(C),v&&v(w,null,null);else {let T="before",x=V.rect,H=_.activatorEvent,F=null;if(r.current)F=r.current.x;else {let W=He(H);W&&(F=W.x+_.delta.x);}if(F!==null){let W=x.left+x.width/2;F>W&&(T="after");}let ie=Vt(C,w,p,T);a(ie),v&&v(w,p,{type:"move",position:"center"});}return}let Q=k.match(/^drop-root-(1\/4|1\/3)-(top|bottom|left|right|start|end)$/);if(Q){let[,p,T]=Q,x=T;x==="start"&&(x="left"),x==="end"&&(x="right");let H=N?fe(C,w):be(C,w),F;if(N){let W=U(C,w)?.tabsMetadata?.[w];F={type:"pane",id:pe(),tabIds:[w],activeTabId:w,tabsMetadata:W?{[w]:W}:void 0};}else F=te(C,w)??{type:"pane",id:pe(),tabIds:[w],activeTabId:w};if(H===null)a(F);else {let ie=x==="left"||x==="right",W=x==="left"||x==="top",Te=50;p==="1/4"?Te=W?25:75:p==="1/3"&&(Te=W?100/3:200/3),a({type:"split",direction:ie?"row":"column",first:W?F:H,second:W?H:F,splitPercentage:Te});}v&&v(w,"root",{type:"split",direction:x==="left"||x==="right"?"row":"column",position:x});return}let K=k.match(/^drop-(left|right|top|bottom|center)-(.+)$/);if(!K){n(C),v&&v(w,null,null);return}let[,Y,ee]=K;if(Y==="center"){if(N){let p=te(C,ee);if(p&&p.activeTabId){let T=p.activeTabId,x=Ze(C,w,T,"center");a(x),v&&v(w,ee,{type:"move",position:"center"});}else n(C),v&&v(w,null,null);}else n(C),v&&v(w,null,null);return}let S=N?U(C,w):te(C,w),I=S&&S.id===ee,se=S&&S.tabIds.length===1;if(w===ee||I&&se){n(C),v&&v(w,null,null);return}let le=Y==="left"||Y==="right"?"row":"column",G;if(N){let T=U(C,w)?.tabsMetadata?.[w];G={type:"pane",id:pe(),tabIds:[w],activeTabId:w,tabsMetadata:T?{[w]:T}:void 0};}else G=te(C,w)??{type:"pane",id:pe(),tabIds:[w],activeTabId:w};let oe=N?fe(C,w):be(C,w),Oe=Se(oe,ee,le,Y,G);a(Oe),v&&v(w,ee,{type:"split",direction:le,position:Y});},onDragCancel:()=>{c(null),i(null),R(false),s(null),b(null),f(null),$?.(null),Z.current=null;let _=l.current||t;l.current=null,n(_),_!==t&&a(_);}}}function Gt({persist:e,layout:t,setLayout:n}){let a=typeof e=="object"?e.enabled!==false:!!e,o=typeof e=="object"&&e.key||"zeugma-layout",[c,u]=ge.useState(false);ge.useEffect(()=>{if(a){let i=localStorage.getItem(o);if(i)try{let d=JSON.parse(i);d&&n(d);}catch(d){console.error("Failed to parse persisted zeugma layout",d);}}u(true);},[a,o,n]),ge.useEffect(()=>{a&&c&&(t?localStorage.setItem(o,JSON.stringify(t)):localStorage.removeItem(o));},[a,o,t,c]);}var Ee=null,Kt=false,ae=new Set,De=new Set,Ie=null;function Xn(){typeof window>"u"||Ie||(Ie=new MutationObserver(e=>{e.forEach(t=>{t.addedNodes.forEach(n=>{n instanceof HTMLElement&&(n.tagName.toLowerCase()==="style"||n.tagName.toLowerCase()==="link")&&ae.forEach(a=>{try{let o=n.cloneNode(!0);if(o.tagName.toLowerCase()==="link"){let c=n.href;c&&o.setAttribute("href",c);}a.head.appendChild(o);}catch(o){console.warn("Failed to mirror style node to popout:",o);}});});});}),Ie.observe(document.head,{childList:true}));}function mt(){Ie&&(Ie.disconnect(),Ie=null);}var Le=null;function Yn(){typeof window>"u"||Le||(Le=new MutationObserver(e=>{e.forEach(t=>{if(t.type==="attributes"&&t.attributeName){let n=document.documentElement.getAttribute(t.attributeName);ae.forEach(a=>{try{a&&a.documentElement&&(n!==null?a.documentElement.setAttribute(t.attributeName,n):a.documentElement.removeAttribute(t.attributeName));}catch(o){console.warn("Failed to sync documentElement attribute:",o);}});}});}),Le.observe(document.documentElement,{attributes:true}));}function gt(){Le&&(Le.disconnect(),Le=null);}var en=e=>{typeof requestAnimationFrame<"u"?requestAnimationFrame(e):setTimeout(e,0);};function me(){if(typeof window>"u")return document;if(Ee&&Ee.target){let t=Ee.target.ownerDocument;if(t&&t!==document)return t}let e=window.event;if(e&&e.target){let n=e.target.ownerDocument;if(n&&n!==document)return n}return window.__zeugmaActivePopoutDocument?window.__zeugmaActivePopoutDocument:document}function tn(){if(typeof window>"u"||Kt)return;Kt=true;let e=(r,l)=>{if(!r||!l)return false;try{let h=Object.getPrototypeOf(r);for(;h;){if(h===l)return !0;h=Object.getPrototypeOf(h);}}catch{}return false},t=(r,l)=>{try{Object.defineProperty(r,Symbol.hasInstance,{value:function(h){return h?e(h,r.prototype)?!0:l(h):!1},configurable:!0,writable:!0});}catch(h){console.warn("Failed to patch Symbol.hasInstance on",r,h);}};typeof Node<"u"&&t(Node,r=>typeof r.nodeType=="number"&&typeof r.nodeName=="string"),typeof Element<"u"&&t(Element,r=>r.nodeType===1),typeof HTMLElement<"u"&&t(HTMLElement,r=>r.nodeType===1&&typeof r.style=="object"),typeof HTMLBodyElement<"u"&&t(HTMLBodyElement,r=>r.nodeType===1&&r.tagName==="BODY"),typeof HTMLHtmlElement<"u"&&t(HTMLHtmlElement,r=>r.nodeType===1&&r.tagName==="HTML"),typeof HTMLInputElement<"u"&&t(HTMLInputElement,r=>r.nodeType===1&&r.tagName==="INPUT"),typeof HTMLTextAreaElement<"u"&&t(HTMLTextAreaElement,r=>r.nodeType===1&&r.tagName==="TEXTAREA"),typeof ShadowRoot<"u"&&t(ShadowRoot,r=>r.nodeType===11&&r.host!==void 0),typeof SVGElement<"u"&&t(SVGElement,r=>r.nodeType===1&&typeof r.getBBox=="function"),typeof Document<"u"&&t(Document,r=>r.nodeType===9),typeof Window<"u"&&t(Window,r=>r&&typeof r.document=="object"&&typeof r.location=="object");let n=Document.prototype,a=Object.getOwnPropertyDescriptor(n,"body"),o=Object.getOwnPropertyDescriptor(n,"documentElement"),c=Object.getOwnPropertyDescriptor(n,"head"),u=Object.getOwnPropertyDescriptor(n,"activeElement"),i=Object.getOwnPropertyDescriptor(n,"defaultView"),d=Object.getOwnPropertyDescriptor(n,"scrollingElement");Object.defineProperties(document,{body:{get(){let r=me();return r&&r!==document?r.body:a?.get?.call(document)||document.body},configurable:true},documentElement:{get(){let r=me();return r&&r!==document?r.documentElement:o?.get?.call(document)||document.documentElement},configurable:true},head:{get(){let r=me();return r&&r!==document?r.head:c?.get?.call(document)||document.head},configurable:true},activeElement:{get(){let r=me();return r&&r!==document?r.activeElement:u?.get?.call(document)||document.activeElement},configurable:true},defaultView:{get(){let r=me();return r&&r!==document?r.defaultView:i?.get?.call(document)||document.defaultView},configurable:true},scrollingElement:{get(){let r=me();return r&&r!==document?r.scrollingElement:d?.get?.call(document)||document.scrollingElement},configurable:true}});let f=Window.prototype,s=["innerWidth","innerHeight","pageXOffset","pageYOffset","scrollX","scrollY","screenX","screenY","outerWidth","outerHeight","devicePixelRatio"],b={};s.forEach(r=>{let l=Object.getOwnPropertyDescriptor(f,r)||Object.getOwnPropertyDescriptor(window,r);l&&l.get&&(b[r]=l.get);}),s.forEach(r=>{Object.defineProperty(window,r,{get(){let l=me();if(l&&l!==document&&l.defaultView)try{return l.defaultView[r]}catch{}let h=b[r];return h?h.call(window):window[r]},configurable:true});});let g=Node.prototype.contains;Node.prototype.contains=function(r){if(!r)return false;if(g.call(this,r))return true;if(this===document||this===document.body||this===document.documentElement)for(let l of ae)try{if(l.contains(r))return !0}catch{}return false};let m=()=>{Ee=null,globalThis.__zeugmaActivePopoutDocument=null;};["pointerdown","mousedown","click","keydown","focus","touchstart"].forEach(r=>{window.addEventListener(r,m,true);});let P=document.createElement;document.createElement=function(r,l){let h=me();return h&&h!==document?h.createElement(r,l):P.call(document,r,l)};let D=document.addEventListener;document.addEventListener=function(r,l,h){De.add({target:"document",type:r,listener:l,options:h}),D.call(document,r,l,h),ae.forEach(R=>{try{R.addEventListener(r,l,h);}catch{}});};let L=document.removeEventListener;document.removeEventListener=function(r,l,h){for(let R of De)if(R.target==="document"&&R.type===r&&R.listener===l){De.delete(R);break}L.call(document,r,l,h),ae.forEach(R=>{try{R.removeEventListener(r,l,h);}catch{}});};let v=window.addEventListener;window.addEventListener=function(r,l,h){De.add({target:"window",type:r,listener:l,options:h}),v.call(window,r,l,h),ae.forEach(R=>{try{R.defaultView&&R.defaultView.addEventListener(r,l,h);}catch{}});};let $=window.removeEventListener;window.removeEventListener=function(r,l,h){for(let R of De)if(R.target==="window"&&R.type===r&&R.listener===l){De.delete(R);break}$.call(window,r,l,h),ae.forEach(R=>{try{R.defaultView&&R.defaultView.removeEventListener(r,l,h);}catch{}});};let E=document.getElementById;document.getElementById=function(r){let l=me();if(l&&l!==document)return l.getElementById(r);let h=E.call(document,r);if(h)return h;for(let R of ae)try{let M=R.getElementById(r);if(M)return M}catch{}return null};let O=document.querySelector;document.querySelector=function(r){let l=me();if(l&&l!==document)return l.querySelector(r);let h=O.call(document,r);if(h)return h;for(let R of ae)try{let M=R.querySelector(r);if(M)return M}catch{}return null};let Z=document.querySelectorAll;document.querySelectorAll=function(r){let l=me();if(l&&l!==document)return l.querySelectorAll(r);let h=Z.call(document,r);if(h.length>0)return h;for(let R of ae)try{let M=R.querySelectorAll(r);if(M.length>0)return M}catch{}return h};}function nn(e){let{poppedOutTabIds:t,registerPopoutTarget:n,findTabById:a,dockTab:o}=e,c=ge.useRef({});ge.useEffect(()=>{let u=c.current;t.forEach(i=>{if(u[i]){try{u[i].focus();}catch{}return}tn();let f=a(i)?.metadata?.title||`Tab ${i}`,s=window.open("",`zeugma-popout-${i}`,"width=800,height=600");if(!s){console.warn("Failed to open popout window. Check popup blocker."),o(i);return}u[i]=s,ae.add(s.document),De.forEach(l=>{try{l.target==="window"?s.addEventListener(l.type,l.listener,l.options):s.document.addEventListener(l.type,l.listener,l.options);}catch{}}),Xn(),Yn(),s.document.title=f,s.document.head.innerHTML="";try{let l=s.document.createElement("base");l.setAttribute("href",window.location.origin+"/"),s.document.head.appendChild(l);}catch{}if(Array.from(document.querySelectorAll('style, link[rel="stylesheet"]')).forEach(l=>{let h=l.cloneNode(true);if(l.tagName.toLowerCase()==="link"){let R=l.href;R&&h.setAttribute("href",R);}else if(l.tagName.toLowerCase()==="style")try{let R=l.sheet?.cssRules;if(R&&R.length>0){let M=Array.from(R).map(q=>q.cssText).join(`
10
- `);h.textContent=M;}}catch{}s.document.head.appendChild(h);}),typeof document.adoptedStyleSheets<"u"&&typeof s.document.adoptedStyleSheets<"u")try{let l=Array.from(document.adoptedStyleSheets).map(h=>{try{let R=new s.CSSStyleSheet,M=Array.from(h.cssRules).map(q=>q.cssText).join(`
11
- `);return R.replaceSync(M),R}catch{return null}}).filter(h=>h!==null);s.document.adoptedStyleSheets=l;}catch(l){console.warn("Failed to copy adoptedStyleSheets:",l);}s.document.documentElement.className=document.documentElement.className,s.document.body.className=document.body.className,Array.from(document.documentElement.attributes).forEach(l=>{s.document.documentElement.setAttribute(l.name,l.value);}),s.document.body.style.margin="0",s.document.body.style.padding="0",s.document.body.style.height="100vh",s.document.body.style.overflow="hidden";let b=document.getElementById(`zeugma-tab-target-${i}`),g="";b&&(g=window.getComputedStyle(b).backgroundColor,(!g||g==="transparent"||g==="rgba(0, 0, 0, 0)")&&b.parentElement&&(g=window.getComputedStyle(b.parentElement).backgroundColor));let m=window.getComputedStyle(document.documentElement),y=window.getComputedStyle(document.body),P=y.backgroundColor,L=!P||P==="transparent"||P==="rgba(0, 0, 0, 0)"?m.backgroundColor:P,v=g&&g!=="transparent"&&g!=="rgba(0, 0, 0, 0)"?g:L&&L!=="transparent"&&L!=="rgba(0, 0, 0, 0)"?L:"#181b1f";document.documentElement.getAttribute("data-theme")||(s.document.documentElement.style.backgroundColor=v,s.document.body.style.backgroundColor=v),s.document.body.style.color=y.color||m.color,s.document.body.style.fontFamily=y.fontFamily||m.fontFamily;let E=s.document.createElement("div");E.id=`zeugma-popout-container-${i}`,E.className="grafana-panel h-full w-full overflow-hidden",E.style.width="100%",E.style.height="100%",E.style.border="none",s.document.body.appendChild(E),n?.(i,E);let O=["pointerdown","mousedown","click","keydown","focus","touchstart"],Z=l=>{Ee=l,globalThis.__zeugmaActivePopoutDocument=s.document,setTimeout(()=>{Ee===l&&(Ee=null,globalThis.__zeugmaActivePopoutDocument=null);},0);};O.forEach(l=>{s.addEventListener(l,Z,true);});let r=()=>{ae.delete(s.document),ae.size===0&&(mt(),gt()),o(i);};s.addEventListener("beforeunload",r),s.__zeugmaCleanup=()=>{O.forEach(l=>{s.removeEventListener(l,Z,true);}),s.removeEventListener("beforeunload",r);};}),Object.keys(u).forEach(i=>{if(!t.includes(i)){let d=u[i];if(delete u[i],n?.(i,null),d){ae.delete(d.document),ae.size===0&&(mt(),gt());try{let f=d;f.__zeugmaCleanup&&f.__zeugmaCleanup(),en(()=>{try{f.close();}catch{}});}catch{}}}});},[t,n,a,o]),ge.useEffect(()=>()=>{let u=c.current;Object.keys(u).forEach(i=>{let d=u[i];if(d){ae.delete(d.document);try{let f=d;f.__zeugmaCleanup&&f.__zeugmaCleanup(),en(()=>{try{f.close();}catch{}});}catch{}}}),ae.size===0&&(mt(),gt());},[]);}typeof window<"u"&&tn();var on=({activeId:e,render:t,className:n})=>{let a=ge.useRef(null);return ge.useEffect(()=>{let o=c=>{a.current&&(a.current.style.transform=`translate(${c.clientX+12}px, ${c.clientY+12}px)`);};return document.addEventListener("pointermove",o),()=>document.removeEventListener("pointermove",o)},[]),jsxRuntime.jsx("div",{ref:a,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var no=({popoutDoc:e,children:t})=>{if(e===document)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:t});let n=ge__default.default.useEffect,a=ge__default.default.useLayoutEffect,o=ge__default.default.useInsertionEffect;ge__default.default.useEffect=(c,u)=>n(()=>{window.__zeugmaActivePopoutDocument=e;try{let i=c();return typeof i=="function"?()=>{window.__zeugmaActivePopoutDocument=e;try{return i()}finally{window.__zeugmaActivePopoutDocument=null;}}:i}finally{window.__zeugmaActivePopoutDocument=null;}},u),ge__default.default.useLayoutEffect=(c,u)=>a(()=>{window.__zeugmaActivePopoutDocument=e;try{let i=c();return typeof i=="function"?()=>{window.__zeugmaActivePopoutDocument=e;try{return i()}finally{window.__zeugmaActivePopoutDocument=null;}}:i}finally{window.__zeugmaActivePopoutDocument=null;}},u),o&&(ge__default.default.useInsertionEffect=(c,u)=>o(()=>{window.__zeugmaActivePopoutDocument=e;try{let i=c();return typeof i=="function"?()=>{window.__zeugmaActivePopoutDocument=e;try{return i()}finally{window.__zeugmaActivePopoutDocument=null;}}:i}finally{window.__zeugmaActivePopoutDocument=null;}},u)),window.__zeugmaActivePopoutDocument=e;try{return jsxRuntime.jsx(jsxRuntime.Fragment,{children:t})}finally{window.__zeugmaActivePopoutDocument=null,ge__default.default.useEffect=n,ge__default.default.useLayoutEffect=a,o&&(ge__default.default.useInsertionEffect=o);}},an=ge__default.default.memo(({tabDetails:e,target:t,renderWidget:n})=>{let{id:a}=e,{renderPopoutWrapper:o}=re(),[c,u]=ge.useState(false),i=ge.useRef(null);if(ge.useEffect(()=>{u(true);},[]),ge.useEffect(()=>{if(!c||!i.current)return;let m=i.current;if(t)t.ownerDocument.adoptNode(m),t.appendChild(m);else {let y=document.getElementById("zeugma-hidden-portal-container");y||(y=document.createElement("div"),y.id="zeugma-hidden-portal-container",y.style.display="none",document.body.appendChild(y)),document.adoptNode(m),y.appendChild(m);}},[t,c]),ge.useEffect(()=>()=>{i.current&&i.current.remove();},[]),!c)return null;let d=t?t.ownerDocument:document;i.current&&i.current.ownerDocument!==d&&d.adoptNode(i.current),i.current||(i.current=d.createElement("div"),i.current.className=`zeugma-portal-wrapper-${a}`,i.current.style.width="100%",i.current.style.height="100%");let f=i.current;if(!f||!n)return null;let s=!!(t&&t.ownerDocument&&t.ownerDocument!==document),b=e.remountOnPopout?s?"-popped":"-docked":"",g=jsxRuntime.jsx(ge__default.default.Fragment,{children:n(e)},`${a}${b}`);return s&&t&&t.ownerDocument&&o&&(g=o({tabId:a,document:t.ownerDocument,window:t.ownerDocument.defaultView||window,children:g})),reactDom.createPortal(jsxRuntime.jsx(no,{popoutDoc:s&&t?t.ownerDocument:document,children:g}),f)},(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 sn=({activeId:e,activeType:t,dismissIntentId:n,renderDragOverlay:a,renderPaneRef:o,renderPane:c,tabHeadersRef:u,classNames:i})=>{if(a)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:a({type:t,id:e,isDismissing:e===n})});if(t==="pane"){let d=o.current||c;if(d)return jsxRuntime.jsx("div",{className:i.paneDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:d(e)})}else if(t==="tab"){let d=o.current||c;if(d)return jsxRuntime.jsx("div",{className:i.tabDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:d(e)});let f=u.current[e];if(f){let s=i.tab?typeof i.tab=="function"?i.tab(e):i.tab:"";return jsxRuntime.jsx("div",{className:`${i.tabDragPreview||""} ${s}`.trim(),style:{display:"inline-flex",position:"relative",pointerEvents:"none",overflow:"hidden"},children:f({isDragging:true,isOver:false})})}}return jsxRuntime.jsx("div",{style:{pointerEvents:"none",overflow:"hidden",width:"100%",height:"100%"}})};function vt({containerRef:e,isRow:t,direction:n,splitPercentage:a,resizerSize:o,snapThreshold:c,layout:u,currentNode:i,onLayoutChange:d,onResizeStart:f,onResizeEnd:s,parentLeft:b,parentTop:g,parentWidth:m,parentHeight:y}){let{onResizeStart:P,onResize:D,onResizeEnd:L,minSplitPercentage:v=5,maxSplitPercentage:$=95,locked:E=false}=re();return ge.useCallback(O=>{if(E)return;O.preventDefault();let Z=e.current;if(!Z)return;f&&f(),P&&P(i);let r=Z.getBoundingClientRect(),l=O.clientX,h=O.clientY,R=a,M=O.currentTarget,q=r.left+r.width*(b/100),ne=r.top+r.height*(g/100),J=r.width*(m/100),A=r.height*(y/100),j=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(B=>B!==M&&B.getAttribute("data-direction")===n).map(B=>{let N=B.getBoundingClientRect();return t?N.left+N.width/2:N.top+N.height/2}),V=R;It({cursor:t?"col-resize":"row-resize",resizerEl:M,onMove:B=>{let N=t?(B.clientX-l)/J*100:(B.clientY-h)/A*100,w=R+N,z=t?q+(J-o)*(w/100)+o/2:ne+(A-o)*(w/100)+o/2,C=1/0,k=null;for(let Y of j){let ee=Math.abs(z-Y);ee<c&&ee<C&&(C=ee,k=Y);}let ue=w;k!==null&&(ue=t?(k-o/2-q)/(J-o)*100:(k-o/2-ne)/(A-o)*100);let Q=Math.max(v,Math.min($,ue));V=Q;let K=xe(u,i,Q);if(K){let{panes:Y,splitters:ee}=ve(K),S=e.current;if(S){for(let I of Y)S.style.setProperty(`--pane-left-${I.paneId}`,`${I.left}%`),S.style.setProperty(`--pane-top-${I.paneId}`,`${I.top}%`),S.style.setProperty(`--pane-width-${I.paneId}`,`${I.width}%`),S.style.setProperty(`--pane-height-${I.paneId}`,`${I.height}%`);for(let I of ee)S.style.setProperty(`--splitter-pos-${I.id}`,`${I.direction==="row"?I.left:I.top}%`);}}D&&D(i,Q);},onEnd:()=>{let B=xe(u,i,V),N=e.current;if(N){let{panes:w,splitters:z}=ve(B);for(let C of w)N.style.removeProperty(`--pane-left-${C.paneId}`),N.style.removeProperty(`--pane-top-${C.paneId}`),N.style.removeProperty(`--pane-width-${C.paneId}`),N.style.removeProperty(`--pane-height-${C.paneId}`);for(let C of z)N.style.removeProperty(`--splitter-pos-${C.id}`);}d(B),s&&s(),L&&L(i,V);}});},[e,t,n,a,o,c,u,i,d,f,s,P,D,L,v,$,b,g,m,y])}var ln=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:a})=>{let{renderingLayout:o,setLayout:c,classNames:u,locked:i}=re(),[d,f]=ge.useState(false),{currentNode:s,direction:b,left:g,top:m,width:y,height:P,parentLeft:D,parentTop:L,parentWidth:v,parentHeight:$}=e,E=b==="row",O=vt({containerRef:a,isRow:E,direction:b,splitPercentage:s.splitPercentage,resizerSize:t,snapThreshold:n,layout:o,currentNode:s,onLayoutChange:c,onResizeStart:()=>f(true),onResizeEnd:()=>f(false),parentLeft:D,parentTop:L,parentWidth:v,parentHeight:$}),Z=E?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${g}%) - ${t/2}px)`,top:`calc(${m}% + ${t/2}px)`,width:`${t}px`,height:`calc(${P}% - ${t}px)`,cursor:i?"default":"col-resize",pointerEvents:i?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`calc(${g}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${m}%) - ${t/2}px)`,width:`calc(${y}% - ${t}px)`,height:`${t}px`,cursor:i?"default":"row-resize",pointerEvents:i?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"};return jsxRuntime.jsx("div",{className:u.resizer||"","data-direction":b,"data-resizing":d||void 0,style:Z,onPointerDown:O,role:"separator","aria-valuenow":s.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},cn=ge__default.default.memo(({paneId:e,renderPane:t})=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane);var ht=({renderPane:e,tree:t,resizerSize:n,snapThreshold:a})=>{Zt(e);let{renderingLayout:o,activeId:c,dismissIntentId:u,setContainerRef:i,fullscreenPaneId:d,snapThreshold:f,locked:s,classNames:b,resizerSize:g}=re(),m=a!==void 0?a:f??8,y=n!==void 0?n:g??4,P=t!==void 0?t:o,D=ge.useRef(null),{panes:L,splitters:v}=ge.useMemo(()=>P?ve(P):{panes:[],splitters:[]},[P]);if(!P&&t!==void 0)return null;let $=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[L.map(E=>{let O=d===E.paneId;return jsxRuntime.jsx("div",{style:{position:"absolute",left:O?"0%":`var(--pane-left-${E.paneId}, ${E.left}%)`,top:O?"0%":`var(--pane-top-${E.paneId}, ${E.top}%)`,width:O?"100%":`var(--pane-width-${E.paneId}, ${E.width}%)`,height:O?"100%":`var(--pane-height-${E.paneId}, ${E.height}%)`,overflow:"hidden",zIndex:O?20:1,display:d&&!O?"none":"block",padding:O?"0px":`${y/2}px`,boxSizing:"border-box"},children:jsxRuntime.jsx(cn,{paneId:E.paneId,renderPane:e})},E.paneId)}),!d&&v.map(E=>jsxRuntime.jsx(ln,{splitter:E,resizerSize:y,snapThreshold:m,containerRef:D},E.id))]});if(t===void 0){let E=c!==null&&c===u,O=r=>{i(r),D.current=r;},Z=`${b.dashboard||""} ${E&&b.dashboardDismissActive||""} ${s&&b.dashboardLocked||""}`.trim();return jsxRuntime.jsxs("div",{ref:O,className:Z,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[$(),c!==null&&!s&&jsxRuntime.jsx(pn,{activeClassName:b.rootDropPreview??b.dropPreview})]})}return jsxRuntime.jsx("div",{ref:D,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:$()})};var fo=e=>{let{controller:t,children:n,renderDragOverlay:a,classNames:o={},renderPane:c,resizerSize:u,dragActivationDistance:i=8,snapThreshold:d=8,minSplitPercentage:f=5,maxSplitPercentage:s=95,enableDragToDismiss:b=false,dismissThreshold:g=60,onRemove:m,onDragStart:y,onDragEnd:P,onResizeStart:D,onResize:L,onResizeEnd:v,onDismissIntentChange:$,persist:E=false,renderPopoutWrapper:O}=e,Z=t,{layout:r,setLayout:l,_internalSetLayout:h,renderingLayout:R,fullscreenPaneId:M,setFullscreenPaneId:q,locked:ne,setLocked:J,findPaneById:A,findPaneContainingTab:_,findTabById:j,getTabMetadata:V,getActiveTabMetadata:B,activeId:N,setActiveId:w,activeType:z,setActiveType:C,dismissIntentId:k,setDismissIntentId:ue,containerRef:Q,setContainerRef:K,removePane:Y,addTab:ee,updateMetadata:S,updatePaneLock:I,selectTab:se,mergeTab:le,removeTab:G,splitPane:oe,updateSplitPercentage:Oe,moveTab:p,poppedOutTabIds:T=[],popoutTab:x,dockTab:H}=Z;Gt({persist:E,layout:r,setLayout:l});let{portalTargets:F,registerPortalTarget:ie,registerPopoutTarget:W,registerRenderCallback:Te,renderCallbacksRef:Ve,registerRenderPane:Rt,renderPaneRef:lt,registerTabHeader:xt,tabHeadersRef:ct,activeIdRef:We}=Ot();nn({poppedOutTabIds:T,registerPopoutTarget:W,findTabById:j,dockTab:H});let Dt=ge.useCallback(de=>T.includes(de),[T]),{overTabId:Et,setOverTabId:xn,overTabPosition:Ct,setOverTabPosition:Dn,handleDragStartInternal:En,handleDragEndInternal:Cn}=zt({onDragStart:y,onDragEnd:P}),Sn=Yt({layout:r,_internalSetLayout:h,setLayout:l,activeId:N,setActiveId:w,activeType:z,setActiveType:C,dismissIntentId:k,setDismissIntentId:ue,setOverTabId:xn,setOverTabPosition:Dn,containerRef:Q,dragActivationDistance:i,enableDragToDismiss:b,dismissThreshold:g,onRemove:m,onDragStart:En,onDragEnd:Cn,onDismissIntentChange:$,removeTab:G,removePane:Y}),ut=ge.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]),St=ge.useCallback((de,je)=>{v&&v(de,je);},[v]),Nn=ge.useMemo(()=>({layout:r,renderingLayout:R,setLayout:l,activeId:N,activeType:z,dismissIntentId:k,setContainerRef:K,fullscreenPaneId:M,classNames:ut,onRemove:m,onFullscreenChange:q,snapThreshold:d,onResizeStart:D,onResize:L,onResizeEnd:St,minSplitPercentage:f,maxSplitPercentage:s,locked:ne,setLocked:J,findPaneById:A,findPaneContainingTab:_,findTabById:j,getTabMetadata:V,getActiveTabMetadata:B,renderPane:c,resizerSize:u,poppedOutTabIds:T,isTabPoppedOut:Dt,renderPopoutWrapper:O}),[r,R,N,z,k,K,M,ut,m,q,d,D,L,f,s,l,St,ne,J,A,_,j,V,B,c,u,T,Dt,O]),In=ge.useMemo(()=>({overTabId:Et,overTabPosition:Ct}),[Et,Ct]),Ln=ge.useMemo(()=>({removePane:Y,addTab:ee,updateMetadata:S,updatePaneLock:I,selectTab:se,mergeTab:le,removeTab:G,setFullscreenPaneId:q,setLocked:J,splitPane:oe,updateSplitPercentage:Oe,moveTab:p,popoutTab:x,dockTab:H}),[Y,ee,S,I,se,le,G,q,J,oe,Oe,p,x,H]),Mn=At(r),kn=ge.useMemo(()=>({registerPortalTarget:ie,registerRenderCallback:Te,renderCallbacksRef:Ve,registerRenderPane:Rt,renderPaneRef:lt,registerTabHeader:xt,tabHeadersRef:ct,activeIdRef:We,registerPopoutTarget:W}),[ie,Te,Ve,Rt,lt,xt,ct,We,W]);return We&&(We.current=N),jsxRuntime.jsx(we.Provider,{value:Ln,children:jsxRuntime.jsx(pt.Provider,{value:Nn,children:jsxRuntime.jsx(ft.Provider,{value:In,children:jsxRuntime.jsxs(Pe.Provider,{value:kn,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",...Sn,children:n}),N&&z&&jsxRuntime.jsx(on,{activeId:N,render:de=>jsxRuntime.jsx("div",{style:{transition:"transform 150ms cubic-bezier(0.2, 0, 0, 1)",transform:de===k?"scale(0.8)":"scale(1)",transformOrigin:"top left"},children:jsxRuntime.jsx(sn,{activeId:de,activeType:z,dismissIntentId:k,renderDragOverlay:a,renderPaneRef:lt,renderPane:c,tabHeadersRef:ct,classNames:ut})}),className:`${o.dragOverlay||""} ${N===k&&o.dismissPreview||""}`.trim()}),jsxRuntime.jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:Mn.map(de=>{let je=F[de],Nt=j(de);return Nt?jsxRuntime.jsx(an,{tabDetails:Nt,target:je||null,renderWidget:Ve.current[de]},de):null})})]})})})})},mo=({renderPane:e,resizerSize:t,snapThreshold:n})=>{if(!e)throw new Error("Zeugma component requires a renderPane prop when used as a standalone renderer.");return jsxRuntime.jsx(ht,{renderPane:e,resizerSize:t,snapThreshold:n})},go=e=>{let{children:t,...n}=e,{controller:a}=e;if(!a)throw new Error("Zeugma component requires a controller.");return jsxRuntime.jsx(fo,{...e,children:t!==void 0?t:jsxRuntime.jsx(mo,{...n})})};var ho={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"}}},yo={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"}}},To=({id:e,fraction:t,edge:n,activeClassName:a})=>{let{setNodeRef:o,isOver:c}=core.useDroppable({id:e}),u={position:"absolute",pointerEvents:"none",zIndex:101,boxSizing:"border-box",...yo[n][t]};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:o,style:ho[n][t]}),c&&jsxRuntime.jsx("div",{className:a,style:u})]})},pn=({activeClassName:e})=>jsxRuntime.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=>jsxRuntime.jsx(To,{id:n.id,fraction:n.fraction,edge:n.edge,activeClassName:e},n.id))});var rt=ge.createContext(null);var Do={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"},center:{position:"absolute",top:"25%",left:"25%",width:"50%",height:"50%",zIndex:22,pointerEvents:"auto"}},Eo={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"},center:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:21,pointerEvents:"none",boxSizing:"border-box"}},at=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:a,isOver:o}=core.useDroppable({id:e});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:a,style:Do[t]}),o&&jsxRuntime.jsx("div",{className:n,style:Eo[t]})]})};var gn=({children:e,className:t,style:n})=>{let a=ge.useContext(rt);if(!a)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:o,...c}=a;return jsxRuntime.jsx("div",{className:t,style:{cursor:o?"default":"grab",userSelect:o?"auto":"none",touchAction:o?"auto":"none",...n},...o?{}:c,children:e})};var zo=ge.createContext(void 0);var Fe=({id:e,locked:t=false,children:n,className:a,style:o})=>{let{locked:c,classNames:u={},fullscreenPaneId:i,poppedOutTabIds:d=[]}=re(),f=ge.useContext(we),{overTabId:s}=Ue(),b=ge.useContext(Pe);ge.useEffect(()=>(b?.registerTabHeader&&b.registerTabHeader(e,n),()=>{b?.registerTabHeader&&b.activeIdRef?.current!==e&&b.registerTabHeader(e,()=>null);}),[e,n,b]);let g=d.includes(e),m=ge.useContext(Tt),y=t||c||(m?.locked??false)||i!==null,{attributes:P,listeners:D,setNodeRef:L,isDragging:v}=core.useDraggable({id:`tab-header-${e}`,disabled:y}),{setNodeRef:$,isOver:E}=core.useDroppable({id:`tab-drop-${e}`,disabled:y}),O=j=>{L(j),$(j);},Z=E&&s===e,r=m?.tabIds||[],l=r.indexOf(e),h=m?.activeTabId,M=l>0&&e!==h&&r[l-1]!==h?jsxRuntime.jsx("div",{className:u.tabSeparator}):null,q=m?m.activeTabId===e:false,ne=m?.tabsMetadata?.[e],J=ge.useCallback(()=>{m?.selectTab(e);},[m,e]),A=ge.useCallback(()=>{m?.removeTab(e);},[m,e]),_=ge.useMemo(()=>({tabId:e,isActive:q,isDragging:v,isOver:Z,metadata:ne,locked:y,selectTab:J,removeTab:A,isPoppedOut:g,popoutTab:()=>f?.popoutTab(e),dockTab:()=>f?.dockTab(e)}),[e,q,v,Z,ne,y,J,A,g,f]);return jsxRuntime.jsx(zo.Provider,{value:_,children:jsxRuntime.jsxs("div",{ref:O,id:`tab-header-${e}`,className:a,style:{display:"inline-flex",position:"relative",cursor:y?"default":"grab",...o},...y?{}:D,...y?{}:P,children:[M,n({isDragging:v,isOver:Z})]})})};var Tt=ge.createContext(void 0);var yn=(e,t)=>typeof e=="function"?e(t):e,Pt=({tabIds:e,activeTabId:t,locked:n,tabsMetadata:a,selectTab:o,removeTab:c,renderTab:u,classNames:i,styles:d})=>{let f=ge.useContext(it),s=e??f?.tabIds??[],b=t??f?.activeTabId??"",g=n??f?.locked??false,m=a??f?.tabsMetadata,y=o??f?.selectTab??(()=>{}),P=c??f?.removeTab??(()=>{}),{classNames:D={},activeType:L,poppedOutTabIds:v=[]}=re(),$=ge.useContext(we),{overTabId:E,overTabPosition:O}=Ue(),Z=ge.useMemo(()=>({tabIds:s,activeTabId:b,locked:g,tabsMetadata:m,selectTab:y,removeTab:P}),[s,b,g,m,y,P]),r=Wt(s,L,E,O);return jsxRuntime.jsx(Tt.Provider,{value:Z,children:jsxRuntime.jsxs("div",{className:i?.container,style:{display:"flex",alignItems:"center",height:"100%",...d?.container},children:[s.map((l,h)=>{let R=m?.[l],M=yn(i?.tab,l),q=yn(d?.tab,l),ne=h===r;return jsxRuntime.jsxs(ge__default.default.Fragment,{children:[ne&&D.tabDropPreview&&jsxRuntime.jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsxRuntime.jsx("div",{className:D.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:h===0?"none":"translateX(-50%)"}})}),jsxRuntime.jsx(Fe,{id:l,locked:g,className:M,style:q,children:({isDragging:J,isOver:A})=>u({id:l,paneId:f?.id??"",isActive:l===b,index:h,isDragging:J,isOver:A,metadata:R,onSelect:()=>y(l),onRemove:()=>P(l),isPoppedOut:v.includes(l),popout:()=>$?.popoutTab(l),dock:()=>$?.dockTab(l)})})]},l)}),r===s.length&&D.tabDropPreview&&jsxRuntime.jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsxRuntime.jsx("div",{className:D.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:"translateX(-100%)"}})})]})})};Pt.Tab=Fe;var Pn=({className:e,style:t,children:n})=>jsxRuntime.jsx("div",{className:e,style:t,children:n});var it=ge.createContext(void 0),Rn=()=>{let e=ge.useContext(it);if(!e)throw new Error("usePaneContext must be used within a Pane component");return e},qo=({children:e,className:t,style:n})=>{let{activeTabId:a}=Rn(),{classNames:o,isTabPoppedOut:c}=re(),{dockTab:u}=ze(),i=ge.useRef(null),d=ge.useContext(Pe);if(!d)throw new Error("PaneContent must be used within a Zeugma provider");let{registerPortalTarget:f,registerRenderCallback:s}=d,b=ge.useMemo(()=>typeof e=="function"?e:()=>e,[e]);s(a,b),ge.useEffect(()=>{let m=i.current;return f(a,m),()=>{f(a,null,m);}},[a,f]);let g=c(a);return jsxRuntime.jsx("div",{ref:i,id:`zeugma-tab-target-${a}`,className:`${o.tabContentWrapper||""} ${t||""}`.trim(),style:{height:"100%",width:"100%",position:"relative",...n},children:g&&jsxRuntime.jsxs("div",{className:"zeugma-popout-placeholder",style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"12px",padding:"24px",textAlign:"center",backgroundColor:"#161719",color:"#94a3b8",fontSize:"13px",fontWeight:500},children:[jsxRuntime.jsx("div",{children:"This panel is open in a new window"}),jsxRuntime.jsx("button",{onClick:()=>u(a),style:{padding:"6px 12px",fontSize:"11px",fontWeight:600,borderRadius:"4px",backgroundColor:"#2563eb",color:"#ffffff",border:"none",cursor:"pointer",boxShadow:"0 1px 3px rgba(0,0,0,0.1)"},onMouseOver:m=>{m.currentTarget.style.backgroundColor="#1d4ed8";},onMouseOut:m=>{m.currentTarget.style.backgroundColor="#2563eb";},children:"Dock Back"})]})})},ke=({id:e,children:t,style:n,locked:a=false})=>{let{layout:o,renderingLayout:c,activeId:u,activeType:i,classNames:d,fullscreenPaneId:f,onFullscreenChange:s,locked:b,poppedOutTabIds:g=[]}=re(),{removePane:m,updateMetadata:y,selectTab:P,removeTab:D,popoutTab:L,dockTab:v}=ze(),$=ge.useMemo(()=>{if(i==="tab"&&e===u){let k=U(o,e)?.tabsMetadata?.[e];return {type:"pane",id:e,tabIds:[e],activeTabId:e,tabsMetadata:k?{[e]:k}:void 0}}return $t(e===u?o:c,e)},[o,c,e,u,i]),E=$?.id??e,O=$?.tabIds??[e],Z=$?.activeTabId??e,r=$?.tabsMetadata,l=r?.[e],h=$?.locked??false,R=a||h,M=b||R||f!==null,q=b||R||f!==null,ne=u!==null&&u!==e&&(!O.includes(u)||O.length>1)&&!q,{attributes:J,listeners:A,setNodeRef:_}=core.useDraggable({id:e,disabled:M}),j=u!==null&&O.includes(u),V=f===e,B=ge.useMemo(()=>({isDragging:j,isFullscreen:V,toggleFullscreen:()=>s?.(V?null:e),remove:()=>{V&&s?.(null),m(E);},metadata:l,updateMetadata:z=>{y(e,z);},locked:M,tabIds:O,activeTabId:Z,selectTab:z=>P(E,z),removeTab:z=>{V&&z===Z&&s?.(null),D(z);},tabsMetadata:r,updateTabMetadata:(z,C)=>{y(z,C);},isActiveTabPoppedOut:g.includes(Z),popoutTab:z=>L(z||Z),dockTab:z=>v(z||Z)}),[j,V,s,e,D,l,y,M,O,Z,P,E,r,g,L,v]),N=ge.useMemo(()=>M?{disabled:true}:{...A,...J},[A,J,M]),w=`${d.pane||""} ${R&&d.paneLocked||""}`.trim();return jsxRuntime.jsx(it.Provider,{value:{id:e,...B},children:jsxRuntime.jsx(rt.Provider,{value:N,children:jsxRuntime.jsxs("div",{ref:_,id:e,className:w,style:{position:"relative",width:"100%",height:"100%",...n},children:[t,ne&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:[["top","bottom","left","right"].map(z=>jsxRuntime.jsx(at,{id:`drop-${z}-${e}`,position:z,activeClassName:d.dropPreview},z)),i==="tab"&&jsxRuntime.jsx(at,{id:`drop-center-${e}`,position:"center",activeClassName:d.swapPreview??d.dropPreview})]}),u!==null&&u!==e&&q&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsxRuntime.jsx(at,{id:`drop-locked-${e}`,position:"full",activeClassName:d.lockedPreview||""})})]})})})};ke.Content=qo;ke.DragHandle=gn;ke.Tabs=Pt;ke.Tab=Fe;ke.Controls=Pn;exports.Pane=ke;exports.PaneTree=ht;exports.Zeugma=go;exports.usePaneContext=Rn;exports.useResizer=vt;exports.useZeugma=Hn;exports.useZeugmaContext=$n;//# sourceMappingURL=index.cjs.map
9
+ `,document.head.appendChild(o),t.setAttribute("data-resizing","true");let c=i=>{n(i);},u=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let i=document.getElementById("zeugma-global-cursor-style");i&&i.remove(),document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",u),a();};document.addEventListener("pointermove",c),document.addEventListener("pointerup",u);}function ze(e){try{return JSON.stringify(e)}catch{return ""}}var pt=be.createContext(void 0),we=be.createContext(void 0),Pe=be.createContext(void 0),ft=be.createContext(void 0),re=()=>{let e=be.useContext(pt);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},Ze=()=>{let e=be.useContext(we);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e},Xe=()=>{let e=be.useContext(ft);if(!e)throw new Error("useZeugmaDrag must be used within a Zeugma provider");return e};function Mt(e){let t=be.useRef(null);return be.useEffect(()=>{if(!e){t.current=null;return}let n=o=>{t.current={x:o.clientX,y:o.clientY};},a=o=>{let c=o.touches[0]||o.changedTouches[0];c&&(t.current={x:c.clientX,y:c.clientY});};return window.addEventListener("pointermove",n,{passive:true}),window.addEventListener("touchmove",a,{passive:true}),()=>{window.removeEventListener("pointermove",n),window.removeEventListener("touchmove",a);}},[e]),t}function kt(e){be.useEffect(()=>(e?document.body.style.setProperty("cursor","not-allowed","important"):document.body.style.removeProperty("cursor"),()=>{document.body.style.removeProperty("cursor");}),[e]);}function Ot(){let[e,t]=be.useState({}),[n,a]=be.useState({}),o=be.useRef({}),c=be.useRef(null),u=be.useRef({}),i=be.useRef(null),d=be.useRef(true);be.useEffect(()=>(d.current=true,()=>{d.current=false;}),[]);let f=be.useCallback((P,D,M)=>{d.current&&t(h=>{if(!D){if(M&&h[P]!==M||!h[P])return h;let $={...h};return delete $[P],$}return h[P]===D?h:{...h,[P]:D}});},[]),s=be.useCallback((P,D)=>{d.current&&a(M=>{if(!D){if(!M[P])return M;let h={...M};return delete h[P],h}return M[P]===D?M:{...M,[P]:D}});},[]),b=be.useCallback((P,D)=>{o.current[P]=D;},[]),g=be.useCallback(P=>{c.current=P;},[]),m=be.useCallback((P,D)=>{u.current[P]=D;},[]);return {portalTargets:be.useMemo(()=>({...e,...n}),[e,n]),registerPortalTarget:f,registerPopoutTarget:s,registerRenderCallback:b,renderCallbacksRef:o,registerRenderPane:g,renderPaneRef:c,registerTabHeader:m,tabHeadersRef:u,activeIdRef:i}}function An(e){let t=new Set;function n(a){a&&(a.type==="pane"?a.tabIds.forEach(o=>{t.add(o);}):a.type==="split"&&(n(a.first),n(a.second)));}return n(e),Array.from(t).sort()}function At(e){return be.useMemo(()=>An(e),[e])}function zt(e){let{onDragStart:t,onDragEnd:n}=e,[a,o]=be.useState(null),[c,u]=be.useState(null),i=be.useCallback(f=>{t&&t(f);},[t]),d=be.useCallback((f,s,b)=>{n&&n(f,s,b);},[n]);return {overTabId:a,setOverTabId:o,overTabPosition:c,setOverTabPosition:u,handleDragStartInternal:i,handleDragEndInternal:d}}function Zt(e){let n=be.useContext(Pe)?.registerRenderPane;be.useEffect(()=>{n&&e&&n(e);},[n,e]);}function fe(){return "pane-"+Math.random().toString(36).substring(2,11)}function ve(e,t){if(e===null)return null;if(e.type==="pane")return e.id===t?null:e;let n=ve(e.first,t),a=ve(e.second,t);return n===null?a:a===null?n:{...e,first:n,second:a}}function me(e,t){if(e===null)return null;if(e.type==="pane"){if(e.tabIds.includes(t)){let o=e.tabIds.filter(i=>i!==t);if(o.length===0)return null;let c=e.activeTabId;e.activeTabId===t&&(c=o[0]);let u={...e.tabsMetadata};return delete u[t],{...e,tabIds:o,activeTabId:c,tabsMetadata:Object.keys(u).length>0?u:void 0}}return e}let n=me(e.first,t),a=me(e.second,t);return n===null?a:a===null?n:{...e,first:n,second:a}}function Ie(e,t,n,a,o){if(e===null)return typeof o=="string"?{type:"pane",id:fe(),tabIds:[o],activeTabId:o}:o;if(e.type==="pane"){if(e.id===t){let c=typeof o=="string"?{type:"pane",id:fe(),tabIds:[o],activeTabId:o}:o,u=a==="left"||a==="top";return {type:"split",direction:n,first:u?c:e,second:u?e:c,splitPercentage:50}}return e}return {...e,first:Ie(e.first,t,n,a,o)||e.first,second:Ie(e.second,t,n,a,o)||e.second}}function zn(e,t){if(e===null)return t;function n(a,o){return a.type==="pane"?{type:"split",direction:o==="row"?"column":"row",splitPercentage:50,first:a,second:t}:{...a,second:n(a.second,a.direction)}}return n(e,null)}function Ht(e,t,n,a){if(e===null)return {type:"pane",id:fe(),tabIds:[n],activeTabId:n,tabsMetadata:a?{[n]:a}:void 0};let o=t?ee(e,t):null;if(o&&o.type==="pane"){let i=function(d){if(d.type==="pane"&&d.id===t){let f=[...d.tabIds];f.includes(n)||f.push(n);let s=d.tabsMetadata;return a&&(s={...d.tabsMetadata,[n]:a}),{...d,tabIds:f,activeTabId:n,tabsMetadata:s}}return d.type==="split"?{...d,first:i(d.first),second:i(d.second)}:d};return i(e)}let c={type:"pane",id:fe(),tabIds:[n],activeTabId:n,tabsMetadata:a?{[n]:a}:void 0};return zn(e,c)}function xe(e,t,n){return e===null?null:e===t?{...e,splitPercentage:n}:e.type==="split"?{...e,first:xe(e.first,t,n)||e.first,second:xe(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 q(e,t){return e===null?null:e.type==="pane"?e.tabIds.includes(t)?e:null:e.type==="split"?q(e.first,t)??q(e.second,t):null}function $t(e,t){return ee(e,t)??q(e,t)}function Ke(e,t){let n=q(e,t);if(!n)return null;let a=n.tabIds.indexOf(t);return {id:t,paneId:n.id,isActive:n.activeTabId===t,index:a,metadata:n.tabsMetadata?.[t],remountOnPopout:n.tabsMetadata?.[t]?.remountOnPopout}}function _t(e,t){return q(e,t)?.tabsMetadata?.[t]}function Bt(e,t){let n=ee(e,t);return n?.tabsMetadata?.[n.activeTabId]}function Ge(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.tabIds.includes(t)){let a=e.tabsMetadata||{},o=a[t],c=n(o),u={...a};return c===void 0?delete u[t]:u[t]=c,{...e,tabsMetadata:Object.keys(u).length>0?u:void 0}}return e}return e.type==="split"?{...e,first:Ge(e.first,t,n)??e.first,second:Ge(e.second,t,n)??e.second}:e}function Qe(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.id===t){if(n===false){let{locked:a,...o}=e;return o}return {...e,locked:n}}return e}return e.type==="split"?{...e,first:Qe(e.first,t,n)??e.first,second:Qe(e.second,t,n)??e.second}:e}function Le(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:Le(e.first,t,n)??e.first,second:Le(e.second,t,n)??e.second}:e}function Ft(e,t,n){if(e===null)return null;let o=q(e,t)?.tabsMetadata?.[t],c=me(e,t);if(c===null)return {type:"pane",id:fe(),tabIds:[t],activeTabId:t,tabsMetadata:o?{[t]:o}:void 0};function u(i){if(i.type==="pane"){if(i.id===n){let d=[...i.tabIds];d.includes(t)||d.push(t);let f={...i.tabsMetadata};return o&&(f[t]=o),{...i,tabIds:d,activeTabId:t,tabsMetadata:Object.keys(f).length>0?f:void 0}}return i}return i.type==="split"?{...i,first:u(i.first),second:u(i.second)}:i}return u(c)}function Zn(e,t,n){if(e===null)return null;if(t===n)return e;let a=q(e,t),o=q(e,n);if(!a||!o)return e;let c=a.id,u=o.id,i=a.tabsMetadata?.[t],d=o.tabsMetadata?.[n];function f(s){if(s.type==="pane"){let b=false,g=[...s.tabIds],m=s.activeTabId,T=s.tabsMetadata?{...s.tabsMetadata}:{};if(c===u){if(s.id===c){let P=g.indexOf(t),D=g.indexOf(n);P!==-1&&D!==-1&&(g[P]=n,g[D]=t),m=t,b=true;}}else s.id===c&&(g=g.map(P=>P===t?n:P),m===t&&(m=n),delete T[t],d&&(T[n]=d),b=true),s.id===u&&(g=g.map(P=>P===n?t:P),m===n&&(m=t),delete T[n],i&&(T[t]=i),b=true);return b?{...s,tabIds:g,activeTabId:m,tabsMetadata:Object.keys(T).length>0?T:void 0}:s}return s.type==="split"?{...s,first:f(s.first),second:f(s.second)}:s}return f(e)}function He(e,t,n,a="before"){if(e===null)return null;if(t===n)return e;if(a==="center")return Zn(e,t,n);let c=q(e,t)?.tabsMetadata?.[t],u=me(e,t);if(u===null)return {type:"pane",id:fe(),tabIds:[t],activeTabId:t,tabsMetadata:c?{[t]:c}:void 0};function i(d){if(d.type==="pane"){if(d.tabIds.includes(n)){let s=[...d.tabIds].filter(m=>m!==t),b=s.indexOf(n);b<0&&(b=0),a==="after"&&(b+=1),s.splice(b,0,t);let g={...d.tabsMetadata};return c&&(g[t]=c),{...d,tabIds:s,activeTabId:t,tabsMetadata:Object.keys(g).length>0?g:void 0}}return d}return d.type==="split"?{...d,first:i(d.first),second:i(d.second)}:d}return i(u)}function he(e,t=0,n=0,a=100,o=100,c="root"){if(e===null)return {panes:[],splitters:[]};if(e.type==="pane")return {panes:[{paneId:e.id,left:t,top:n,width:a,height:o,node:e}],splitters:[]};let{direction:u,splitPercentage:i,first:d,second:f}=e,b={id:`splitter-${c}-${u}`,currentNode:e,direction:u,left:u==="row"?t+a*(i/100):t,top:u==="column"?n+o*(i/100):n,width:u==="row"?0:a,height:u==="column"?0:o,parentLeft:t,parentTop:n,parentWidth:a,parentHeight:o},g={panes:[],splitters:[]},m={panes:[],splitters:[]};if(u==="row"){let T=a*(i/100);g=he(d,t,n,T,o,`${c}-L`),m=he(f,t+T,n,a-T,o,`${c}-R`);}else {let T=o*(i/100);g=he(d,t,n,a,T,`${c}-T`),m=he(f,t,n+T,a,o-T,`${c}-B`);}return {panes:[...g.panes,...m.panes],splitters:[b,...g.splitters,...m.splitters]}}function Vt(e,t,n,a="before"){if(e===null)return null;let o=ee(e,t);if(!o)return e;let c=o.tabIds,u=o.activeTabId,i=o.tabsMetadata||{},d=ve(e,t);if(d===null)return o;function f(s){if(s.type==="pane"){if(s.tabIds.includes(n)){let g=[...s.tabIds].filter(P=>!c.includes(P)),m=g.indexOf(n);m<0&&(m=0),a==="after"&&(m+=1),g.splice(m,0,...c);let T={...s.tabsMetadata};for(let P of c)i[P]&&(T[P]=i[P]);return {...s,tabIds:g,activeTabId:u,tabsMetadata:Object.keys(T).length>0?T:void 0}}return s}return s.type==="split"?{...s,first:f(s.first),second:f(s.second)}:s}return f(d)}function Wt(e,t,n,a){if(!((t==="tab"||t==="pane")&&n&&e.includes(n))||!a)return -1;let u=e.indexOf(n);return a==="before"?u:u+1}function Hn(e){let{initialLayout:t,layout:n,onChange:a,fullscreenPaneId:o,onFullscreenChange:c,locked:u=false}=e,[i,d]=be.useState(()=>n!==void 0?n:t??null),[f,s]=be.useState(()=>n!==void 0?n:t??null),[b,g]=be.useState(()=>ze(n!==void 0?n:null)),[m,T]=be.useState(o||null),[P,D]=be.useState(u),[M,h]=be.useState([]),[$,E]=be.useState(null),[A,H]=be.useState(null),[r,l]=be.useState(null),y=be.useRef(null),R=be.useCallback(p=>{y.current=p;},[]),k=be.useRef(i);k.current=i;let _=be.useRef(m);_.current=m;let ie=be.useRef(a);ie.current=a;let X=be.useRef(c);X.current=c;let te=be.useCallback(p=>{T(p),X.current?.(p);},[]);if(be.useEffect(()=>{D(u);},[u]),be.useEffect(()=>{o!==void 0&&T(o);},[o]),n!==void 0){let p=ze(n);p!==b&&(g(p),d(n),s(n),h(v=>{if(v.length===0)return v;let Z=v.filter(I=>Ke(n,I)!==null);return Z.length===v.length?v:Z}));}let x=be.useCallback(p=>(...v)=>{let Z=k.current,I=p(Z,...v);ze(Z)!==ze(I)&&(k.current=I,d(I),s(I),h(j=>{if(j.length===0)return j;let V=j.filter(de=>Ke(I,de)!==null);return V.length===j.length?j:V}),ie.current?.(I));},[]),W=be.useCallback(x((p,v)=>typeof v=="function"?v(p):v),[x]),F=be.useCallback(p=>{_.current===null&&s(v=>typeof p=="function"?p(v):p);},[]),B=be.useCallback(p=>{T(null),X.current?.(null),E(null),H(null),l(null),W(p),s(()=>typeof p=="function"?p(k.current):p);},[W]),N=be.useCallback(x((p,v)=>_.current!==null?p:ve(p,v)),[x]),w=be.useCallback(x((p,v,Z,I)=>{if(_.current!==null)return p;let j=me(p,v)??p;return Ht(j,Z,v,I)}),[x]),z=be.useCallback(x((p,v,Z,I,j)=>{if(_.current!==null)return p;let V=ee(p,v)??q(p,v);if(!V)return p;let de=ee(p,j)??q(p,j)??{type:"pane",id:j,tabIds:[j],activeTabId:j},Se=ve(p,de.id);return Ie(Se,V.id,Z,I,de)}),[x]),C=be.useCallback(x((p,v,Z)=>_.current!==null?p:xe(p,v,Z)),[x]),O=be.useCallback(x((p,v,Z)=>Ge(p,v,Z)),[x]),ue=be.useCallback(x((p,v,Z)=>{let I=ee(p,v)??q(p,v);return I?Qe(p,I.id,Z):p}),[x]),G=be.useCallback(x((p,v,Z)=>{let I=ee(p,v)??q(p,v);return I?Le(p,I.id,Z):p}),[x]),Q=be.useCallback(x((p,v,Z)=>{if(_.current!==null)return p;let I=ee(p,Z)??q(p,Z);return I?Ft(p,v,I.id):p}),[x]),Y=be.useCallback(x((p,v,Z,I)=>_.current!==null?p:He(p,v,Z,I)),[x]),K=be.useCallback(x((p,v)=>_.current!==null?p:me(p,v)),[x]),S=be.useCallback(p=>ee(k.current,p),[]),L=be.useCallback(p=>q(k.current,p),[]),se=be.useCallback(p=>Ke(k.current,p),[]),le=be.useCallback(p=>_t(k.current,p),[]),J=be.useCallback(p=>Bt(k.current,p),[]),ne=be.useCallback(p=>{_.current===null&&h(v=>v.includes(p)?v:[...v,p]);},[]),Ce=be.useCallback(p=>{_.current===null&&h(v=>v.includes(p)?v.filter(Z=>Z!==p):v);},[]);return {layout:i,setLayout:B,_internalSetLayout:F,renderingLayout:f,fullscreenPaneId:m,setFullscreenPaneId:te,locked:P,setLocked:D,poppedOutTabIds:M,activeId:$,setActiveId:E,activeType:A,setActiveType:H,dismissIntentId:r,setDismissIntentId:l,containerRef:y,setContainerRef:R,removePane:N,addTab:w,updateMetadata:O,updatePaneLock:ue,selectTab:G,mergeTab:Q,moveTab:Y,removeTab:K,splitPane:z,updateSplitPercentage:C,popoutTab:ne,dockTab:Ce,findPaneById:S,findPaneContainingTab:L,findTabById:se,getTabMetadata:le,getActiveTabMetadata:J}}var $n=()=>{let e=re(),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,poppedOutTabIds:e.poppedOutTabIds,popoutTab:t.popoutTab,dockTab:t.dockTab}};var et=class extends core.PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},tt=class extends core.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};var qt=e=>{let n=e.active.id.toString().startsWith("tab-header-"),o=core.pointerWithin(e);if(o.length>0)return [...o].sort((u,i)=>{let d=u.id.toString(),f=i.id.toString(),s=d.startsWith("tab-drop-"),b=f.startsWith("tab-drop-");if(s&&!b)return -1;if(!s&&b)return 1;let g=d.startsWith("drop-root-"),m=f.startsWith("drop-root-");return g&&!m?-1:!g&&m?1:0});if(n){let c=e.droppableContainers.filter(u=>u.id.toString().startsWith("tab-drop-"));return core.closestCenter({...e,droppableContainers:c})}return []};function _e(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 Yt(e){let{layout:t,_internalSetLayout:n,setLayout:a,activeId:o,setActiveId:c,activeType:u,setActiveType:i,dismissIntentId:d,setDismissIntentId:f,setOverTabId:s,setOverTabPosition:b,containerRef:g,dragActivationDistance:m,enableDragToDismiss:T,dismissThreshold:P,onRemove:D,onDragStart:M,onDragEnd:h,onDismissIntentChange:$,removeTab:E,removePane:A}=e,H=be.useRef(null),r=Mt(o),l=be.useRef(null),[y,R]=be.useState(false);return kt(y),{sensors:core.useSensors(core.useSensor(et,{activationConstraint:{distance:m}}),core.useSensor(tt,{activationConstraint:{delay:250,tolerance:5}})),collisionDetection:qt,onDragStart:x=>{let W=x.active.id.toString(),F=W.startsWith("tab-header-"),B=F?W.substring(11):W;c(B),i(F?"tab":"pane"),s(null),b(null);let N=x.activatorEvent;r.current=_e(N),T&&g.current?H.current=g.current.getBoundingClientRect():H.current=null;let w=t;if(F){let C=q(t,B);C&&(w=Le(t,C.id,B)||t);}l.current=w;let z=F?me(w,B):ve(w,B);n(z),M&&M(B);},onDragMove:x=>{let{over:W}=x,F=W?.id.toString()||"",B=F.startsWith("drop-locked-");R(S=>S===B?S:B);let N=x.active.id.toString(),w=N.startsWith("tab-header-"),z=w?N.substring(11):N,C=F.match(/^tab-drop-(.+)$/);if(C&&W&&(w||u==="pane")){let[,S]=C;if(z!==S){let L="before",se=W.rect,le=x.activatorEvent,J=null;if(r.current)J=r.current.x;else {let ne=_e(le);ne&&(J=ne.x+x.delta.x);}if(J!==null){let ne=se.left+se.width/2;J>ne&&(L="after");}s(ne=>ne===S?ne:S),b(ne=>ne===L?ne:L);}else s(L=>L===null?L:null),b(L=>L===null?L:null);}else s(S=>S===null?S:null),b(S=>S===null?S:null);if(!T)return;let O=H.current;if(!O){d!==null&&(f(null),$?.(null));return}let ue=x.activatorEvent,G=null,Q=null;if(r.current)G=r.current.x,Q=r.current.y;else {let S=_e(ue);S&&(G=S.x+x.delta.x,Q=S.y+x.delta.y);}let Y=0;if(G!==null&&Q!==null){let S=0,L=0;G<O.left?S=O.left-G:G>O.right&&(S=G-O.right),Q<O.top?L=O.top-Q:Q>O.bottom&&(L=Q-O.bottom),Y=Math.sqrt(S*S+L*L);}else {let S=x.active.rect.current.translated;if(S){let L=S.left+S.width/2,se=S.top+S.height/2,le=0,J=0;L<O.left?le=O.left-L:L>O.right&&(le=L-O.right),se<O.top?J=O.top-se:se>O.bottom&&(J=se-O.bottom),Y=Math.sqrt(le*le+J*J);}}Y>P?d!==z&&(f(z),$?.(z)):d!==null&&(f(null),$?.(null));},onDragEnd:x=>{c(null),i(null),R(false),s(null),b(null);let{active:W,over:F}=x,B=W.id.toString(),N=B.startsWith("tab-header-"),w=N?B.substring(11):B,z=T&&d===w;f(null),$?.(null),H.current=null;let C=l.current||t;if(l.current=null,z){D?D(w):N?E(w):A(w),h&&h(w,null,null);return}if(!F){n(C),h&&h(w,null,null);return}let O=F.id.toString();if(O.startsWith("drop-locked-")){n(C),h&&h(w,null,null);return}let ue=O.match(/^tab-drop-(.+)$/);if(ue){let[,oe]=ue;if(N)if(w!==oe){let p="before",v=F.rect,Z=x.activatorEvent,I=null;if(r.current)I=r.current.x;else {let V=_e(Z);V&&(I=V.x+x.delta.x);}if(I!==null){let V=v.left+v.width/2;I>V&&(p="after");}let j=He(C,w,oe,p);a(j),h&&h(w,oe,{type:"move",position:"center"});}else n(C),h&&h(w,null,null);else {let p="before",v=F.rect,Z=x.activatorEvent,I=null;if(r.current)I=r.current.x;else {let V=_e(Z);V&&(I=V.x+x.delta.x);}if(I!==null){let V=v.left+v.width/2;I>V&&(p="after");}let j=Vt(C,w,oe,p);a(j),h&&h(w,oe,{type:"move",position:"center"});}return}let G=O.match(/^drop-root-(1\/4|1\/3)-(top|bottom|left|right|start|end)$/);if(G){let[,oe,p]=G,v=p;v==="start"&&(v="left"),v==="end"&&(v="right");let Z=N?me(C,w):ve(C,w),I;if(N){let V=q(C,w)?.tabsMetadata?.[w];I={type:"pane",id:fe(),tabIds:[w],activeTabId:w,tabsMetadata:V?{[w]:V}:void 0};}else I=ee(C,w)??{type:"pane",id:fe(),tabIds:[w],activeTabId:w};if(Z===null)a(I);else {let j=v==="left"||v==="right",V=v==="left"||v==="top",de=50;oe==="1/4"?de=V?25:75:oe==="1/3"&&(de=V?100/3:200/3),a({type:"split",direction:j?"row":"column",first:V?I:Z,second:V?Z:I,splitPercentage:de});}h&&h(w,"root",{type:"split",direction:v==="left"||v==="right"?"row":"column",position:v});return}let Q=O.match(/^drop-(left|right|top|bottom|center)-(.+)$/);if(!Q){n(C),h&&h(w,null,null);return}let[,Y,K]=Q;if(Y==="center"){if(N){let oe=ee(C,K);if(oe&&oe.activeTabId){let p=oe.activeTabId,v=He(C,w,p,"center");a(v),h&&h(w,K,{type:"move",position:"center"});}else n(C),h&&h(w,null,null);}else n(C),h&&h(w,null,null);return}let S=N?q(C,w):ee(C,w),L=S&&S.id===K,se=S&&S.tabIds.length===1;if(w===K||L&&se){n(C),h&&h(w,null,null);return}let le=Y==="left"||Y==="right"?"row":"column",J;if(N){let p=q(C,w)?.tabsMetadata?.[w];J={type:"pane",id:fe(),tabIds:[w],activeTabId:w,tabsMetadata:p?{[w]:p}:void 0};}else J=ee(C,w)??{type:"pane",id:fe(),tabIds:[w],activeTabId:w};let ne=N?me(C,w):ve(C,w),Ce=Ie(ne,K,le,Y,J);a(Ce),h&&h(w,K,{type:"split",direction:le,position:Y});},onDragCancel:()=>{c(null),i(null),R(false),s(null),b(null),f(null),$?.(null),H.current=null;let x=l.current||t;l.current=null,n(x),x!==t&&a(x);}}}function Gt({persist:e,layout:t,setLayout:n}){let a=typeof e=="object"?e.enabled!==false:!!e,o=typeof e=="object"&&e.key||"zeugma-layout",[c,u]=be.useState(false);be.useEffect(()=>{if(a){let i=localStorage.getItem(o);if(i)try{let d=JSON.parse(i);d&&n(d);}catch(d){console.error("Failed to parse persisted zeugma layout",d);}}u(true);},[a,o,n]),be.useEffect(()=>{a&&c&&(t?localStorage.setItem(o,JSON.stringify(t)):localStorage.removeItem(o));},[a,o,t,c]);}var Ee=null,Kt=false,ae=new Set,De=new Set,Me=null;function Xn(){typeof window>"u"||Me||(Me=new MutationObserver(e=>{e.forEach(t=>{t.addedNodes.forEach(n=>{n instanceof HTMLElement&&(n.tagName.toLowerCase()==="style"||n.tagName.toLowerCase()==="link")&&ae.forEach(a=>{try{let o=n.cloneNode(!0);if(o.tagName.toLowerCase()==="link"){let c=n.href;c&&o.setAttribute("href",c);}a.head.appendChild(o);}catch(o){console.warn("Failed to mirror style node to popout:",o);}});});});}),Me.observe(document.head,{childList:true}));}function mt(){Me&&(Me.disconnect(),Me=null);}var ke=null;function Yn(){typeof window>"u"||ke||(ke=new MutationObserver(e=>{e.forEach(t=>{if(t.type==="attributes"&&t.attributeName){let n=document.documentElement.getAttribute(t.attributeName);ae.forEach(a=>{try{a&&a.documentElement&&(n!==null?a.documentElement.setAttribute(t.attributeName,n):a.documentElement.removeAttribute(t.attributeName));}catch(o){console.warn("Failed to sync documentElement attribute:",o);}});}});}),ke.observe(document.documentElement,{attributes:true}));}function gt(){ke&&(ke.disconnect(),ke=null);}var en=e=>{typeof requestAnimationFrame<"u"?requestAnimationFrame(e):setTimeout(e,0);};function ge(){if(typeof window>"u")return document;if(Ee&&Ee.target){let t=Ee.target.ownerDocument;if(t&&t!==document)return t}let e=window.event;if(e&&e.target){let n=e.target.ownerDocument;if(n&&n!==document)return n}return window.__zeugmaActivePopoutDocument?window.__zeugmaActivePopoutDocument:document}function tn(){if(typeof window>"u"||Kt)return;Kt=true;let e=(r,l)=>{if(!r||!l)return false;try{let y=Object.getPrototypeOf(r);for(;y;){if(y===l)return !0;y=Object.getPrototypeOf(y);}}catch{}return false},t=(r,l)=>{try{Object.defineProperty(r,Symbol.hasInstance,{value:function(y){return y?e(y,r.prototype)?!0:l(y):!1},configurable:!0,writable:!0});}catch(y){console.warn("Failed to patch Symbol.hasInstance on",r,y);}};typeof Node<"u"&&t(Node,r=>typeof r.nodeType=="number"&&typeof r.nodeName=="string"),typeof Element<"u"&&t(Element,r=>r.nodeType===1),typeof HTMLElement<"u"&&t(HTMLElement,r=>r.nodeType===1&&typeof r.style=="object"),typeof HTMLBodyElement<"u"&&t(HTMLBodyElement,r=>r.nodeType===1&&r.tagName==="BODY"),typeof HTMLHtmlElement<"u"&&t(HTMLHtmlElement,r=>r.nodeType===1&&r.tagName==="HTML"),typeof HTMLInputElement<"u"&&t(HTMLInputElement,r=>r.nodeType===1&&r.tagName==="INPUT"),typeof HTMLTextAreaElement<"u"&&t(HTMLTextAreaElement,r=>r.nodeType===1&&r.tagName==="TEXTAREA"),typeof ShadowRoot<"u"&&t(ShadowRoot,r=>r.nodeType===11&&r.host!==void 0),typeof SVGElement<"u"&&t(SVGElement,r=>r.nodeType===1&&typeof r.getBBox=="function"),typeof Document<"u"&&t(Document,r=>r.nodeType===9),typeof Window<"u"&&t(Window,r=>r&&typeof r.document=="object"&&typeof r.location=="object");let n=Document.prototype,a=Object.getOwnPropertyDescriptor(n,"body"),o=Object.getOwnPropertyDescriptor(n,"documentElement"),c=Object.getOwnPropertyDescriptor(n,"head"),u=Object.getOwnPropertyDescriptor(n,"activeElement"),i=Object.getOwnPropertyDescriptor(n,"defaultView"),d=Object.getOwnPropertyDescriptor(n,"scrollingElement");Object.defineProperties(document,{body:{get(){let r=ge();return r&&r!==document?r.body:a?.get?.call(document)||document.body},configurable:true},documentElement:{get(){let r=ge();return r&&r!==document?r.documentElement:o?.get?.call(document)||document.documentElement},configurable:true},head:{get(){let r=ge();return r&&r!==document?r.head:c?.get?.call(document)||document.head},configurable:true},activeElement:{get(){let r=ge();return r&&r!==document?r.activeElement:u?.get?.call(document)||document.activeElement},configurable:true},defaultView:{get(){let r=ge();return r&&r!==document?r.defaultView:i?.get?.call(document)||document.defaultView},configurable:true},scrollingElement:{get(){let r=ge();return r&&r!==document?r.scrollingElement:d?.get?.call(document)||document.scrollingElement},configurable:true}});let f=Window.prototype,s=["innerWidth","innerHeight","pageXOffset","pageYOffset","scrollX","scrollY","screenX","screenY","outerWidth","outerHeight","devicePixelRatio"],b={};s.forEach(r=>{let l=Object.getOwnPropertyDescriptor(f,r)||Object.getOwnPropertyDescriptor(window,r);l&&l.get&&(b[r]=l.get);}),s.forEach(r=>{Object.defineProperty(window,r,{get(){let l=ge();if(l&&l!==document&&l.defaultView)try{return l.defaultView[r]}catch{}let y=b[r];return y?y.call(window):window[r]},configurable:true});});let g=Node.prototype.contains;Node.prototype.contains=function(r){if(!r)return false;if(g.call(this,r))return true;if(this===document||this===document.body||this===document.documentElement)for(let l of ae)try{if(l.contains(r))return !0}catch{}return false};let m=()=>{Ee=null,globalThis.__zeugmaActivePopoutDocument=null;};["pointerdown","mousedown","click","keydown","focus","touchstart"].forEach(r=>{window.addEventListener(r,m,true);});let P=document.createElement;document.createElement=function(r,l){let y=ge();return y&&y!==document?y.createElement(r,l):P.call(document,r,l)};let D=document.addEventListener;document.addEventListener=function(r,l,y){De.add({target:"document",type:r,listener:l,options:y}),D.call(document,r,l,y),ae.forEach(R=>{try{R.addEventListener(r,l,y);}catch{}});};let M=document.removeEventListener;document.removeEventListener=function(r,l,y){for(let R of De)if(R.target==="document"&&R.type===r&&R.listener===l){De.delete(R);break}M.call(document,r,l,y),ae.forEach(R=>{try{R.removeEventListener(r,l,y);}catch{}});};let h=window.addEventListener;window.addEventListener=function(r,l,y){De.add({target:"window",type:r,listener:l,options:y}),h.call(window,r,l,y),ae.forEach(R=>{try{R.defaultView&&R.defaultView.addEventListener(r,l,y);}catch{}});};let $=window.removeEventListener;window.removeEventListener=function(r,l,y){for(let R of De)if(R.target==="window"&&R.type===r&&R.listener===l){De.delete(R);break}$.call(window,r,l,y),ae.forEach(R=>{try{R.defaultView&&R.defaultView.removeEventListener(r,l,y);}catch{}});};let E=document.getElementById;document.getElementById=function(r){let l=ge();if(l&&l!==document)return l.getElementById(r);let y=E.call(document,r);if(y)return y;for(let R of ae)try{let k=R.getElementById(r);if(k)return k}catch{}return null};let A=document.querySelector;document.querySelector=function(r){let l=ge();if(l&&l!==document)return l.querySelector(r);let y=A.call(document,r);if(y)return y;for(let R of ae)try{let k=R.querySelector(r);if(k)return k}catch{}return null};let H=document.querySelectorAll;document.querySelectorAll=function(r){let l=ge();if(l&&l!==document)return l.querySelectorAll(r);let y=H.call(document,r);if(y.length>0)return y;for(let R of ae)try{let k=R.querySelectorAll(r);if(k.length>0)return k}catch{}return y};}function nn(e){let{poppedOutTabIds:t,registerPopoutTarget:n,findTabById:a,dockTab:o}=e,c=be.useRef({});be.useEffect(()=>{let u=c.current;t.forEach(i=>{if(u[i]){try{u[i].focus();}catch{}return}tn();let f=a(i)?.metadata?.title||`Tab ${i}`,s=window.open("",`zeugma-popout-${i}`,"width=800,height=600");if(!s){console.warn("Failed to open popout window. Check popup blocker."),o(i);return}u[i]=s,ae.add(s.document),De.forEach(l=>{try{l.target==="window"?s.addEventListener(l.type,l.listener,l.options):s.document.addEventListener(l.type,l.listener,l.options);}catch{}}),Xn(),Yn(),s.document.title=f,s.document.head.innerHTML="";try{let l=s.document.createElement("base");l.setAttribute("href",window.location.origin+"/"),s.document.head.appendChild(l);}catch{}if(Array.from(document.querySelectorAll('style, link[rel="stylesheet"]')).forEach(l=>{let y=l.cloneNode(true);if(l.tagName.toLowerCase()==="link"){let R=l.href;R&&y.setAttribute("href",R);}else if(l.tagName.toLowerCase()==="style")try{let R=l.sheet?.cssRules;if(R&&R.length>0){let k=Array.from(R).map(_=>_.cssText).join(`
10
+ `);y.textContent=k;}}catch{}s.document.head.appendChild(y);}),typeof document.adoptedStyleSheets<"u"&&typeof s.document.adoptedStyleSheets<"u")try{let l=Array.from(document.adoptedStyleSheets).map(y=>{try{let R=new s.CSSStyleSheet,k=Array.from(y.cssRules).map(_=>_.cssText).join(`
11
+ `);return R.replaceSync(k),R}catch{return null}}).filter(y=>y!==null);s.document.adoptedStyleSheets=l;}catch(l){console.warn("Failed to copy adoptedStyleSheets:",l);}s.document.documentElement.className=document.documentElement.className,s.document.body.className=document.body.className,Array.from(document.documentElement.attributes).forEach(l=>{s.document.documentElement.setAttribute(l.name,l.value);}),s.document.body.style.margin="0",s.document.body.style.padding="0",s.document.body.style.height="100vh",s.document.body.style.overflow="hidden";let b=document.getElementById(`zeugma-tab-target-${i}`),g="";b&&(g=window.getComputedStyle(b).backgroundColor,(!g||g==="transparent"||g==="rgba(0, 0, 0, 0)")&&b.parentElement&&(g=window.getComputedStyle(b.parentElement).backgroundColor));let m=window.getComputedStyle(document.documentElement),T=window.getComputedStyle(document.body),P=T.backgroundColor,M=!P||P==="transparent"||P==="rgba(0, 0, 0, 0)"?m.backgroundColor:P,h=g&&g!=="transparent"&&g!=="rgba(0, 0, 0, 0)"?g:M&&M!=="transparent"&&M!=="rgba(0, 0, 0, 0)"?M:"#181b1f";document.documentElement.getAttribute("data-theme")||(s.document.documentElement.style.backgroundColor=h,s.document.body.style.backgroundColor=h),s.document.body.style.color=T.color||m.color,s.document.body.style.fontFamily=T.fontFamily||m.fontFamily;let E=s.document.createElement("div");E.id=`zeugma-popout-container-${i}`,E.className="grafana-panel h-full w-full overflow-hidden",E.style.width="100%",E.style.height="100%",E.style.border="none",s.document.body.appendChild(E),n?.(i,E);let A=["pointerdown","mousedown","click","keydown","focus","touchstart"],H=l=>{Ee=l,globalThis.__zeugmaActivePopoutDocument=s.document,setTimeout(()=>{Ee===l&&(Ee=null,globalThis.__zeugmaActivePopoutDocument=null);},0);};A.forEach(l=>{s.addEventListener(l,H,true);});let r=()=>{ae.delete(s.document),ae.size===0&&(mt(),gt()),o(i);};s.addEventListener("beforeunload",r),s.__zeugmaCleanup=()=>{A.forEach(l=>{s.removeEventListener(l,H,true);}),s.removeEventListener("beforeunload",r);};}),Object.keys(u).forEach(i=>{if(!t.includes(i)){let d=u[i];if(delete u[i],n?.(i,null),d){ae.delete(d.document),ae.size===0&&(mt(),gt());try{let f=d;f.__zeugmaCleanup&&f.__zeugmaCleanup(),en(()=>{try{f.close();}catch{}});}catch{}}}});},[t,n,a,o]),be.useEffect(()=>()=>{let u=c.current;Object.keys(u).forEach(i=>{let d=u[i];if(d){ae.delete(d.document);try{let f=d;f.__zeugmaCleanup&&f.__zeugmaCleanup(),en(()=>{try{f.close();}catch{}});}catch{}}}),ae.size===0&&(mt(),gt());},[]);}typeof window<"u"&&tn();var on=({activeId:e,render:t,className:n})=>{let a=be.useRef(null);return be.useEffect(()=>{let o=c=>{a.current&&(a.current.style.transform=`translate(${c.clientX+12}px, ${c.clientY+12}px)`);};return document.addEventListener("pointermove",o),()=>document.removeEventListener("pointermove",o)},[]),jsxRuntime.jsx("div",{ref:a,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var no=({popoutDoc:e,children:t})=>{if(e===document)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:t});let n=be__default.default.useEffect,a=be__default.default.useLayoutEffect,o=be__default.default.useInsertionEffect;be__default.default.useEffect=(c,u)=>n(()=>{window.__zeugmaActivePopoutDocument=e;try{let i=c();return typeof i=="function"?()=>{window.__zeugmaActivePopoutDocument=e;try{return i()}finally{window.__zeugmaActivePopoutDocument=null;}}:i}finally{window.__zeugmaActivePopoutDocument=null;}},u),be__default.default.useLayoutEffect=(c,u)=>a(()=>{window.__zeugmaActivePopoutDocument=e;try{let i=c();return typeof i=="function"?()=>{window.__zeugmaActivePopoutDocument=e;try{return i()}finally{window.__zeugmaActivePopoutDocument=null;}}:i}finally{window.__zeugmaActivePopoutDocument=null;}},u),o&&(be__default.default.useInsertionEffect=(c,u)=>o(()=>{window.__zeugmaActivePopoutDocument=e;try{let i=c();return typeof i=="function"?()=>{window.__zeugmaActivePopoutDocument=e;try{return i()}finally{window.__zeugmaActivePopoutDocument=null;}}:i}finally{window.__zeugmaActivePopoutDocument=null;}},u)),window.__zeugmaActivePopoutDocument=e;try{return jsxRuntime.jsx(jsxRuntime.Fragment,{children:t})}finally{window.__zeugmaActivePopoutDocument=null,be__default.default.useEffect=n,be__default.default.useLayoutEffect=a,o&&(be__default.default.useInsertionEffect=o);}},an=be__default.default.memo(({tabDetails:e,target:t,renderWidget:n})=>{let{id:a}=e,{renderPopoutWrapper:o}=re(),[c,u]=be.useState(false),i=be.useRef(null);if(be.useEffect(()=>{u(true);},[]),be.useEffect(()=>{if(!c||!i.current)return;let m=i.current;if(t)t.ownerDocument.adoptNode(m),t.appendChild(m);else {let T=document.getElementById("zeugma-hidden-portal-container");T||(T=document.createElement("div"),T.id="zeugma-hidden-portal-container",T.style.display="none",document.body.appendChild(T)),document.adoptNode(m),T.appendChild(m);}},[t,c]),be.useEffect(()=>()=>{i.current&&i.current.remove();},[]),!c)return null;let d=t?t.ownerDocument:document;i.current&&i.current.ownerDocument!==d&&d.adoptNode(i.current),i.current||(i.current=d.createElement("div"),i.current.className=`zeugma-portal-wrapper-${a}`,i.current.style.width="100%",i.current.style.height="100%");let f=i.current;if(!f||!n)return null;let s=!!(t&&t.ownerDocument&&t.ownerDocument!==document),b=e.remountOnPopout?s?"-popped":"-docked":"",g=jsxRuntime.jsx(be__default.default.Fragment,{children:n(e)},`${a}${b}`);return s&&t&&t.ownerDocument&&o&&(g=o({tabId:a,document:t.ownerDocument,window:t.ownerDocument.defaultView||window,children:g})),reactDom.createPortal(jsxRuntime.jsx(no,{popoutDoc:s&&t?t.ownerDocument:document,children:g}),f)},(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 sn=({activeId:e,activeType:t,dismissIntentId:n,renderDragOverlay:a,renderPaneRef:o,renderPane:c,tabHeadersRef:u,classNames:i})=>{if(a)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:a({type:t,id:e,isDismissing:e===n})});if(t==="pane"){let d=o.current||c;if(d)return jsxRuntime.jsx("div",{className:i.paneDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:d(e)})}else if(t==="tab"){let d=o.current||c;if(d)return jsxRuntime.jsx("div",{className:i.tabDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:d(e)});let f=u.current[e];if(f){let s=i.tab?typeof i.tab=="function"?i.tab(e):i.tab:"";return jsxRuntime.jsx("div",{className:`${i.tabDragPreview||""} ${s}`.trim(),style:{display:"inline-flex",position:"relative",pointerEvents:"none",overflow:"hidden"},children:f({isDragging:true,isOver:false})})}}return jsxRuntime.jsx("div",{style:{pointerEvents:"none",overflow:"hidden",width:"100%",height:"100%"}})};function vt({containerRef:e,isRow:t,direction:n,splitPercentage:a,resizerSize:o,snapThreshold:c,layout:u,currentNode:i,onLayoutChange:d,onResizeStart:f,onResizeEnd:s,parentLeft:b,parentTop:g,parentWidth:m,parentHeight:T}){let{onResizeStart:P,onResize:D,onResizeEnd:M,minSplitPercentage:h=5,maxSplitPercentage:$=95,locked:E=false}=re();return be.useCallback(A=>{if(E)return;A.preventDefault();let H=e.current;if(!H)return;f&&f(),P&&P(i);let r=H.getBoundingClientRect(),l=A.clientX,y=A.clientY,R=a,k=A.currentTarget,_=r.left+r.width*(b/100),ie=r.top+r.height*(g/100),X=r.width*(m/100),te=r.height*(T/100),W=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(B=>B!==k&&B.getAttribute("data-direction")===n).map(B=>{let N=B.getBoundingClientRect();return t?N.left+N.width/2:N.top+N.height/2}),F=R;It({cursor:t?"col-resize":"row-resize",resizerEl:k,onMove:B=>{let N=t?(B.clientX-l)/X*100:(B.clientY-y)/te*100,w=R+N,z=t?_+(X-o)*(w/100)+o/2:ie+(te-o)*(w/100)+o/2,C=1/0,O=null;for(let Y of W){let K=Math.abs(z-Y);K<c&&K<C&&(C=K,O=Y);}let ue=w;O!==null&&(ue=t?(O-o/2-_)/(X-o)*100:(O-o/2-ie)/(te-o)*100);let G=Math.max(h,Math.min($,ue));F=G;let Q=xe(u,i,G);if(Q){let{panes:Y,splitters:K}=he(Q),S=e.current;if(S){for(let L of Y)S.style.setProperty(`--pane-left-${L.paneId}`,`${L.left}%`),S.style.setProperty(`--pane-top-${L.paneId}`,`${L.top}%`),S.style.setProperty(`--pane-width-${L.paneId}`,`${L.width}%`),S.style.setProperty(`--pane-height-${L.paneId}`,`${L.height}%`);for(let L of K)S.style.setProperty(`--splitter-pos-${L.id}`,`${L.direction==="row"?L.left:L.top}%`);}}D&&D(i,G);},onEnd:()=>{let B=xe(u,i,F),N=e.current;if(N){let{panes:w,splitters:z}=he(B);for(let C of w)N.style.removeProperty(`--pane-left-${C.paneId}`),N.style.removeProperty(`--pane-top-${C.paneId}`),N.style.removeProperty(`--pane-width-${C.paneId}`),N.style.removeProperty(`--pane-height-${C.paneId}`);for(let C of z)N.style.removeProperty(`--splitter-pos-${C.id}`);}d(B),s&&s(),M&&M(i,F);}});},[e,t,n,a,o,c,u,i,d,f,s,P,D,M,h,$,b,g,m,T])}var ln=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:a})=>{let{renderingLayout:o,setLayout:c,classNames:u,locked:i}=re(),[d,f]=be.useState(false),{currentNode:s,direction:b,left:g,top:m,width:T,height:P,parentLeft:D,parentTop:M,parentWidth:h,parentHeight:$}=e,E=b==="row",A=vt({containerRef:a,isRow:E,direction:b,splitPercentage:s.splitPercentage,resizerSize:t,snapThreshold:n,layout:o,currentNode:s,onLayoutChange:c,onResizeStart:()=>f(true),onResizeEnd:()=>f(false),parentLeft:D,parentTop:M,parentWidth:h,parentHeight:$}),H=E?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${g}%) - ${t/2}px)`,top:`calc(${m}% + ${t/2}px)`,width:`${t}px`,height:`calc(${P}% - ${t}px)`,cursor:i?"default":"col-resize",pointerEvents:i?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`calc(${g}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${m}%) - ${t/2}px)`,width:`calc(${T}% - ${t}px)`,height:`${t}px`,cursor:i?"default":"row-resize",pointerEvents:i?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"};return jsxRuntime.jsx("div",{className:u.resizer||"","data-direction":b,"data-resizing":d||void 0,style:H,onPointerDown:A,role:"separator","aria-valuenow":s.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},cn=be__default.default.memo(({paneId:e,renderPane:t})=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane);var ht=({renderPane:e,tree:t,resizerSize:n,snapThreshold:a})=>{Zt(e);let{renderingLayout:o,activeId:c,dismissIntentId:u,setContainerRef:i,fullscreenPaneId:d,snapThreshold:f,locked:s,classNames:b,resizerSize:g}=re(),m=a!==void 0?a:f??8,T=n!==void 0?n:g??4,P=t!==void 0?t:o,D=be.useRef(null),{panes:M,splitters:h}=be.useMemo(()=>P?he(P):{panes:[],splitters:[]},[P]);if(!P&&t!==void 0)return null;let $=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[M.map(E=>{let A=d===E.paneId;return jsxRuntime.jsx("div",{style:{position:"absolute",left:A?"0%":`var(--pane-left-${E.paneId}, ${E.left}%)`,top:A?"0%":`var(--pane-top-${E.paneId}, ${E.top}%)`,width:A?"100%":`var(--pane-width-${E.paneId}, ${E.width}%)`,height:A?"100%":`var(--pane-height-${E.paneId}, ${E.height}%)`,overflow:"hidden",zIndex:A?20:1,display:d&&!A?"none":"block",padding:A?"0px":`${T/2}px`,boxSizing:"border-box"},children:jsxRuntime.jsx(cn,{paneId:E.paneId,renderPane:e})},E.paneId)}),!d&&h.map(E=>jsxRuntime.jsx(ln,{splitter:E,resizerSize:T,snapThreshold:m,containerRef:D},E.id))]});if(t===void 0){let E=c!==null&&c===u,A=r=>{i(r),D.current=r;},H=`${b.dashboard||""} ${E&&b.dashboardDismissActive||""} ${s&&b.dashboardLocked||""}`.trim();return jsxRuntime.jsxs("div",{ref:A,className:H,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[$(),c!==null&&!s&&jsxRuntime.jsx(pn,{activeClassName:b.rootDropPreview??b.dropPreview})]})}return jsxRuntime.jsx("div",{ref:D,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:$()})};var fo=e=>{let{controller:t,children:n,renderDragOverlay:a,classNames:o={},renderPane:c,resizerSize:u,dragActivationDistance:i=8,snapThreshold:d=8,minSplitPercentage:f=5,maxSplitPercentage:s=95,enableDragToDismiss:b=false,dismissThreshold:g=60,onRemove:m,onDragStart:T,onDragEnd:P,onResizeStart:D,onResize:M,onResizeEnd:h,onDismissIntentChange:$,persist:E=false,renderPopoutWrapper:A}=e,H=t,{layout:r,setLayout:l,_internalSetLayout:y,renderingLayout:R,fullscreenPaneId:k,setFullscreenPaneId:_,locked:ie,setLocked:X,findPaneById:te,findPaneContainingTab:x,findTabById:W,getTabMetadata:F,getActiveTabMetadata:B,activeId:N,setActiveId:w,activeType:z,setActiveType:C,dismissIntentId:O,setDismissIntentId:ue,containerRef:G,setContainerRef:Q,removePane:Y,addTab:K,updateMetadata:S,updatePaneLock:L,selectTab:se,mergeTab:le,removeTab:J,splitPane:ne,updateSplitPercentage:Ce,moveTab:oe,poppedOutTabIds:p=[],popoutTab:v,dockTab:Z}=H;Gt({persist:E,layout:r,setLayout:l});let{portalTargets:I,registerPortalTarget:j,registerPopoutTarget:V,registerRenderCallback:de,renderCallbacksRef:Se,registerRenderPane:Rt,renderPaneRef:lt,registerTabHeader:xt,tabHeadersRef:ct,activeIdRef:je}=Ot();nn({poppedOutTabIds:p,registerPopoutTarget:V,findTabById:W,dockTab:Z});let Dt=be.useCallback(pe=>p.includes(pe),[p]),{overTabId:Et,setOverTabId:xn,overTabPosition:Ct,setOverTabPosition:Dn,handleDragStartInternal:En,handleDragEndInternal:Cn}=zt({onDragStart:T,onDragEnd:P}),Sn=Yt({layout:r,_internalSetLayout:y,setLayout:l,activeId:N,setActiveId:w,activeType:z,setActiveType:C,dismissIntentId:O,setDismissIntentId:ue,setOverTabId:xn,setOverTabPosition:Dn,containerRef:G,dragActivationDistance:i,enableDragToDismiss:b,dismissThreshold:g,onRemove:m,onDragStart:En,onDragEnd:Cn,onDismissIntentChange:$,removeTab:J,removePane:Y}),ut=be.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]),St=be.useCallback((pe,qe)=>{h&&h(pe,qe);},[h]),Nn=be.useMemo(()=>({layout:r,renderingLayout:R,setLayout:l,activeId:N,activeType:z,dismissIntentId:O,setContainerRef:Q,fullscreenPaneId:k,classNames:ut,onRemove:m,onFullscreenChange:_,snapThreshold:d,onResizeStart:D,onResize:M,onResizeEnd:St,minSplitPercentage:f,maxSplitPercentage:s,locked:ie,setLocked:X,findPaneById:te,findPaneContainingTab:x,findTabById:W,getTabMetadata:F,getActiveTabMetadata:B,renderPane:c,resizerSize:u,poppedOutTabIds:p,isTabPoppedOut:Dt,renderPopoutWrapper:A}),[r,R,N,z,O,Q,k,ut,m,_,d,D,M,f,s,l,St,ie,X,te,x,W,F,B,c,u,p,Dt,A]),In=be.useMemo(()=>({overTabId:Et,overTabPosition:Ct}),[Et,Ct]),Ln=be.useMemo(()=>({removePane:Y,addTab:K,updateMetadata:S,updatePaneLock:L,selectTab:se,mergeTab:le,removeTab:J,setFullscreenPaneId:_,setLocked:X,splitPane:ne,updateSplitPercentage:Ce,moveTab:oe,popoutTab:v,dockTab:Z}),[Y,K,S,L,se,le,J,_,X,ne,Ce,oe,v,Z]),Mn=At(r),kn=be.useMemo(()=>({registerPortalTarget:j,registerRenderCallback:de,renderCallbacksRef:Se,registerRenderPane:Rt,renderPaneRef:lt,registerTabHeader:xt,tabHeadersRef:ct,activeIdRef:je,registerPopoutTarget:V}),[j,de,Se,Rt,lt,xt,ct,je,V]);return je&&(je.current=N),jsxRuntime.jsx(we.Provider,{value:Ln,children:jsxRuntime.jsx(pt.Provider,{value:Nn,children:jsxRuntime.jsx(ft.Provider,{value:In,children:jsxRuntime.jsxs(Pe.Provider,{value:kn,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",...Sn,children:n}),N&&z&&jsxRuntime.jsx(on,{activeId:N,render:pe=>jsxRuntime.jsx("div",{style:{transition:"transform 150ms cubic-bezier(0.2, 0, 0, 1)",transform:pe===O?"scale(0.8)":"scale(1)",transformOrigin:"top left"},children:jsxRuntime.jsx(sn,{activeId:pe,activeType:z,dismissIntentId:O,renderDragOverlay:a,renderPaneRef:lt,renderPane:c,tabHeadersRef:ct,classNames:ut})}),className:`${o.dragOverlay||""} ${N===O&&o.dismissPreview||""}`.trim()}),jsxRuntime.jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:Mn.map(pe=>{let qe=I[pe],Nt=W(pe);return Nt?jsxRuntime.jsx(an,{tabDetails:Nt,target:qe||null,renderWidget:Se.current[pe]},pe):null})})]})})})})},mo=({renderPane:e,resizerSize:t,snapThreshold:n})=>{if(!e)throw new Error("Zeugma component requires a renderPane prop when used as a standalone renderer.");return jsxRuntime.jsx(ht,{renderPane:e,resizerSize:t,snapThreshold:n})},go=e=>{let{children:t,...n}=e,{controller:a}=e;if(!a)throw new Error("Zeugma component requires a controller.");return jsxRuntime.jsx(fo,{...e,children:t!==void 0?t:jsxRuntime.jsx(mo,{...n})})};var ho={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"}}},yo={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"}}},To=({id:e,fraction:t,edge:n,activeClassName:a})=>{let{setNodeRef:o,isOver:c}=core.useDroppable({id:e}),u={position:"absolute",pointerEvents:"none",zIndex:101,boxSizing:"border-box",...yo[n][t]};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:o,style:ho[n][t]}),c&&jsxRuntime.jsx("div",{className:a,style:u})]})},pn=({activeClassName:e})=>jsxRuntime.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=>jsxRuntime.jsx(To,{id:n.id,fraction:n.fraction,edge:n.edge,activeClassName:e},n.id))});var rt=be.createContext(null);var Do={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"},center:{position:"absolute",top:"25%",left:"25%",width:"50%",height:"50%",zIndex:22,pointerEvents:"auto"}},Eo={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"},center:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:21,pointerEvents:"none",boxSizing:"border-box"}},at=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:a,isOver:o}=core.useDroppable({id:e});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:a,style:Do[t]}),o&&jsxRuntime.jsx("div",{className:n,style:Eo[t]})]})};var gn=({children:e,className:t,style:n})=>{let a=be.useContext(rt);if(!a)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:o,...c}=a;return jsxRuntime.jsx("div",{className:t,style:{cursor:o?"default":"grab",userSelect:o?"auto":"none",touchAction:o?"auto":"none",...n},...o?{}:c,children:e})};var zo=be.createContext(void 0);var We=({id:e,locked:t=false,children:n,className:a,style:o})=>{let{locked:c,classNames:u={},fullscreenPaneId:i,poppedOutTabIds:d=[]}=re(),f=be.useContext(we),{overTabId:s}=Xe(),b=be.useContext(Pe);be.useEffect(()=>(b?.registerTabHeader&&b.registerTabHeader(e,n),()=>{b?.registerTabHeader&&b.activeIdRef?.current!==e&&b.registerTabHeader(e,()=>null);}),[e,n,b]);let g=d.includes(e),m=be.useContext(Tt),T=t||c||(m?.locked??false)||i!==null,{attributes:P,listeners:D,setNodeRef:M,isDragging:h}=core.useDraggable({id:`tab-header-${e}`,disabled:T}),{setNodeRef:$,isOver:E}=core.useDroppable({id:`tab-drop-${e}`,disabled:T}),A=W=>{M(W),$(W);},H=E&&s===e,r=m?.tabIds||[],l=r.indexOf(e),y=m?.activeTabId,k=l>0&&e!==y&&r[l-1]!==y?jsxRuntime.jsx("div",{className:u.tabSeparator}):null,_=m?m.activeTabId===e:false,ie=m?.tabsMetadata?.[e],X=be.useCallback(()=>{m?.selectTab(e);},[m,e]),te=be.useCallback(()=>{m?.removeTab(e);},[m,e]),x=be.useMemo(()=>({tabId:e,isActive:_,isDragging:h,isOver:H,metadata:ie,locked:T,selectTab:X,removeTab:te,isPoppedOut:g,popoutTab:()=>f?.popoutTab(e),dockTab:()=>f?.dockTab(e)}),[e,_,h,H,ie,T,X,te,g,f]);return jsxRuntime.jsx(zo.Provider,{value:x,children:jsxRuntime.jsxs("div",{ref:A,id:`tab-header-${e}`,className:a,style:{display:"inline-flex",position:"relative",cursor:T?"default":"grab",...o},...T?{}:D,...T?{}:P,children:[k,n({isDragging:h,isOver:H})]})})};var Tt=be.createContext(void 0);var yn=(e,t)=>typeof e=="function"?e(t):e,Pt=({tabIds:e,activeTabId:t,locked:n,tabsMetadata:a,selectTab:o,removeTab:c,renderTab:u,classNames:i,styles:d})=>{let f=be.useContext(it),s=e??f?.tabIds??[],b=t??f?.activeTabId??"",g=n??f?.locked??false,m=a??f?.tabsMetadata,T=o??f?.selectTab??(()=>{}),P=c??f?.removeTab??(()=>{}),{classNames:D={},activeType:M,poppedOutTabIds:h=[]}=re(),$=be.useContext(we),{overTabId:E,overTabPosition:A}=Xe(),H=be.useMemo(()=>({tabIds:s,activeTabId:b,locked:g,tabsMetadata:m,selectTab:T,removeTab:P}),[s,b,g,m,T,P]),r=Wt(s,M,E,A);return jsxRuntime.jsx(Tt.Provider,{value:H,children:jsxRuntime.jsxs("div",{className:i?.container,style:{display:"flex",alignItems:"center",height:"100%",...d?.container},children:[s.map((l,y)=>{let R=m?.[l],k=yn(i?.tab,l),_=yn(d?.tab,l),ie=y===r;return jsxRuntime.jsxs(be__default.default.Fragment,{children:[ie&&D.tabDropPreview&&jsxRuntime.jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsxRuntime.jsx("div",{className:D.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:y===0?"none":"translateX(-50%)"}})}),jsxRuntime.jsx(We,{id:l,locked:g,className:k,style:_,children:({isDragging:X,isOver:te})=>u({id:l,paneId:f?.id??"",isActive:l===b,index:y,isDragging:X,isOver:te,metadata:R,onSelect:()=>T(l),onRemove:()=>P(l),isPoppedOut:h.includes(l),popout:()=>$?.popoutTab(l),dock:()=>$?.dockTab(l)})})]},l)}),r===s.length&&D.tabDropPreview&&jsxRuntime.jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsxRuntime.jsx("div",{className:D.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:"translateX(-100%)"}})})]})})};Pt.Tab=We;var Pn=({className:e,style:t,children:n})=>jsxRuntime.jsx("div",{className:e,style:t,children:n});var it=be.createContext(void 0),Rn=()=>{let e=be.useContext(it);if(!e)throw new Error("usePaneContext must be used within a Pane component");return e},qo=({children:e,className:t,style:n})=>{let{activeTabId:a}=Rn(),{classNames:o,isTabPoppedOut:c}=re(),{dockTab:u}=Ze(),i=be.useRef(null),d=be.useContext(Pe);if(!d)throw new Error("PaneContent must be used within a Zeugma provider");let{registerPortalTarget:f,registerRenderCallback:s}=d,b=be.useMemo(()=>typeof e=="function"?e:()=>e,[e]);s(a,b),be.useEffect(()=>{let m=i.current;return f(a,m),()=>{f(a,null,m);}},[a,f]);let g=c(a);return jsxRuntime.jsx("div",{ref:i,id:`zeugma-tab-target-${a}`,className:`${o.tabContentWrapper||""} ${t||""}`.trim(),style:{height:"100%",width:"100%",position:"relative",...n},children:g&&jsxRuntime.jsxs("div",{className:"zeugma-popout-placeholder",style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"12px",padding:"24px",textAlign:"center",backgroundColor:"#161719",color:"#94a3b8",fontSize:"13px",fontWeight:500},children:[jsxRuntime.jsx("div",{children:"This panel is open in a new window"}),jsxRuntime.jsx("button",{onClick:()=>u(a),style:{padding:"6px 12px",fontSize:"11px",fontWeight:600,borderRadius:"4px",backgroundColor:"#2563eb",color:"#ffffff",border:"none",cursor:"pointer",boxShadow:"0 1px 3px rgba(0,0,0,0.1)"},onMouseOver:m=>{m.currentTarget.style.backgroundColor="#1d4ed8";},onMouseOut:m=>{m.currentTarget.style.backgroundColor="#2563eb";},children:"Dock Back"})]})})},Ae=({id:e,children:t,style:n,locked:a=false})=>{let{layout:o,renderingLayout:c,activeId:u,activeType:i,classNames:d,fullscreenPaneId:f,onFullscreenChange:s,locked:b,poppedOutTabIds:g=[]}=re(),{removePane:m,updateMetadata:T,selectTab:P,removeTab:D,popoutTab:M,dockTab:h}=Ze(),$=be.useMemo(()=>{if(i==="tab"&&e===u){let O=q(o,e)?.tabsMetadata?.[e];return {type:"pane",id:e,tabIds:[e],activeTabId:e,tabsMetadata:O?{[e]:O}:void 0}}return $t(e===u?o:c,e)},[o,c,e,u,i]),E=$?.id??e,A=$?.tabIds??[e],H=$?.activeTabId??e,r=$?.tabsMetadata,l=r?.[e],y=$?.locked??false,R=a||y,k=b||R||f!==null,_=b||R||f!==null,ie=u!==null&&u!==e&&(!A.includes(u)||A.length>1)&&!_,{attributes:X,listeners:te,setNodeRef:x}=core.useDraggable({id:e,disabled:k}),W=u!==null&&A.includes(u),F=f===e,B=be.useMemo(()=>({isDragging:W,isFullscreen:F,toggleFullscreen:()=>s?.(F?null:e),remove:()=>{F&&s?.(null),m(E);},metadata:l,updateMetadata:z=>{T(e,z);},locked:k,tabIds:A,activeTabId:H,selectTab:z=>P(E,z),removeTab:z=>{F&&z===H&&s?.(null),D(z);},tabsMetadata:r,updateTabMetadata:(z,C)=>{T(z,C);},isActiveTabPoppedOut:g.includes(H),popoutTab:z=>M(z||H),dockTab:z=>h(z||H)}),[W,F,s,e,D,l,T,k,A,H,P,E,r,g,M,h]),N=be.useMemo(()=>k?{disabled:true}:{...te,...X},[te,X,k]),w=`${d.pane||""} ${R&&d.paneLocked||""}`.trim();return jsxRuntime.jsx(it.Provider,{value:{id:e,...B},children:jsxRuntime.jsx(rt.Provider,{value:N,children:jsxRuntime.jsxs("div",{ref:x,id:e,className:w,style:{position:"relative",width:"100%",height:"100%",...n},children:[t,ie&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:[["top","bottom","left","right"].map(z=>jsxRuntime.jsx(at,{id:`drop-${z}-${e}`,position:z,activeClassName:d.dropPreview},z)),i==="tab"&&jsxRuntime.jsx(at,{id:`drop-center-${e}`,position:"center",activeClassName:d.swapPreview??d.dropPreview})]}),u!==null&&u!==e&&_&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsxRuntime.jsx(at,{id:`drop-locked-${e}`,position:"full",activeClassName:d.lockedPreview||""})})]})})})};Ae.Content=qo;Ae.DragHandle=gn;Ae.Tabs=Pt;Ae.Tab=We;Ae.Controls=Pn;exports.Pane=Ae;exports.PaneTree=ht;exports.Zeugma=go;exports.usePaneContext=Rn;exports.useResizer=vt;exports.useZeugma=Hn;exports.useZeugmaContext=$n;//# sourceMappingURL=index.cjs.map
12
12
  //# sourceMappingURL=index.cjs.map