react-zeugma 5.3.2 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -166,6 +166,22 @@ Wraps the individual pane components inside the renderer. Utilizes a render prop
166
166
  | `remove` | `() => void` | Triggers removal of this pane from the layout tree. |
167
167
  | `renderActiveTab` | `() => ReactNode` | Renders the target placeholder element for the currently active tab in the pane. |
168
168
 
169
+ ### `<Tabs>`
170
+
171
+ A helper component that renders a list of tab items for a pane, wrapping the internal drag-and-drop tab logic.
172
+
173
+ | Prop | Type | Required | Description |
174
+ | :------------- | :----------------------------------------------------------------------------------------------------------------------------------- | :------- | :------------------------------------------------------------------- |
175
+ | `tabs` | `string[]` | Yes | The list of tab IDs in this pane. |
176
+ | `activeTabId` | `string` | Yes | The currently active tab ID. |
177
+ | `locked` | `boolean` | No | Whether dragging/reordering tabs is disabled (defaults to `false`). |
178
+ | `tabsMetadata` | `Record<string, Record<string, any>>` | No | Metadata associated with each tab. |
179
+ | `selectTab` | `(id: string) => void` | Yes | Callback when a tab is selected. |
180
+ | `removeTab` | `(id: string) => void` | Yes | Callback when a tab is closed/removed. |
181
+ | `classNames` | `{ container?: string; tab?: string \| ((tabId: string) => string) }` | No | Custom class names for the container and individual tab items. |
182
+ | `styles` | `{ container?: CSSProperties; tab?: CSSProperties \| ((tabId: string) => CSSProperties) }` | No | Custom inline CSS styles for the container and individual tab items. |
183
+ | `children` | `(props: { tabId: string; activeTabId: string; isDragging: boolean; isOver: boolean; metadata?: Record<string, any> }) => ReactNode` | Yes | Render prop function called for each tab item. |
184
+
169
185
  ### `<DragHandle>`
170
186
 
171
187
  Defines the interactive drag region inside a `<Pane>`. **Must be placed inside a `<Pane>` component.**
@@ -427,6 +443,22 @@ interface PaneRenderProps {
427
443
  }
428
444
  ```
429
445
 
446
+ ### `<Tabs>`
447
+
448
+ Renders a list of tabs inside a pane, wrapping the internal drag-and-drop mechanics.
449
+
450
+ #### Props
451
+
452
+ - `tabs: string[]` — The list of tab IDs.
453
+ - `activeTabId: string` — The currently active tab ID.
454
+ - `locked?: boolean` — Whether dragging is disabled (defaults to `false`).
455
+ - `tabsMetadata?: Record<string, Record<string, unknown>>` — Metadata for the tabs.
456
+ - `selectTab: (id: string) => void` — Callback when a tab is selected.
457
+ - `removeTab: (id: string) => void` — Callback when a tab is closed.
458
+ - `classNames?: { container?: string; tab?: string | ((tabId: string) => string) }` — Custom class names.
459
+ - `styles?: { container?: React.CSSProperties; tab?: React.CSSProperties | ((tabId: string) => React.CSSProperties) }` — Custom styles.
460
+ - `children: (props: { tabId: string; activeTabId: string; isDragging: boolean; isOver: boolean; metadata?: Record<string, unknown> }) => React.ReactNode` — Render prop function.
461
+
430
462
  ### `<DragHandle>`
431
463
 
432
464
  Defines the interactive drag region inside a `<Pane>`. **Must be placed inside a `<Pane>` component.**
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
- 'use strict';var Wt=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 Wt__default=/*#__PURE__*/_interopDefault(Wt);function qe(e){let t=Wt.useRef(null);return Wt.useEffect(()=>{if(!e){t.current=null;return}let n=r=>{t.current={x:r.clientX,y:r.clientY};},s=r=>{let o=r.touches[0]||r.changedTouches[0];o&&(t.current={x:o.clientX,y:o.clientY});};return window.addEventListener("pointermove",n,{passive:true}),window.addEventListener("touchmove",s,{passive:true}),()=>{window.removeEventListener("pointermove",n),window.removeEventListener("touchmove",s);}},[e]),t}function Je(e){Wt.useEffect(()=>(e?document.body.style.setProperty("cursor","not-allowed","important"):document.body.style.removeProperty("cursor"),()=>{document.body.style.removeProperty("cursor");}),[e]);}function Ge(){let[e,t]=Wt.useState({}),n=Wt.useRef(true);Wt.useEffect(()=>(n.current=true,()=>{n.current=false;}),[]);let s=Wt.useCallback((r,o)=>{n.current&&t(i=>i[r]===o?i:{...i,[r]:o});},[]);return {portalTargets:e,registerPortalTarget:s}}var yt=8,xt=8,Sn=4;function de(){return "pane-"+Math.random().toString(36).substring(2,11)}function me(e,t){if(e===null)return null;if(e.type==="pane")return e.id===t?null:e;let n=me(e.first,t),s=me(e.second,t);return n===null?s:s===null?n:{...e,first:n,second:s}}function pe(e,t){if(e===null)return null;if(e.type==="pane"){if(e.tabs.includes(t)){let r=e.tabs.filter(a=>a!==t);if(r.length===0)return null;let o=e.activeTabId;e.activeTabId===t&&(o=r[0]);let i={...e.tabsMetadata};return delete i[t],{...e,tabs:r,activeTabId:o,tabsMetadata:Object.keys(i).length>0?i:void 0}}return e}let n=pe(e.first,t),s=pe(e.second,t);return n===null?s:s===null?n:{...e,first:n,second:s}}function Pe(e,t,n,s,r){if(e===null)return typeof r=="string"?{type:"pane",id:de(),tabs:[r],activeTabId:r}:r;if(e.type==="pane"){if(e.id===t){let o=typeof r=="string"?{type:"pane",id:de(),tabs:[r],activeTabId:r}:r,i=s==="left"||s==="top";return {type:"split",direction:n,first:i?o:e,second:i?e:o,splitPercentage:50}}return e}return {...e,first:Pe(e.first,t,n,s,r)||e.first,second:Pe(e.second,t,n,s,r)||e.second}}function Ke(e,t,n){if(e===null)return {type:"pane",id:de(),tabs:[t],activeTabId:t,tabsMetadata:n?{[t]:n}:void 0};function s(r,o){return r.type==="pane"?{type:"split",direction:o==="row"?"column":"row",splitPercentage:50,first:r,second:{type:"pane",id:de(),tabs:[t],activeTabId:t,tabsMetadata:n?{[t]:n}:void 0}}:{...r,second:s(r.second,r.direction)}}return s(e,null)}function ge(e,t,n){return e===null?null:e===t?{...e,splitPercentage:n}:e.type==="split"?{...e,first:ge(e.first,t,n)||e.first,second:ge(e.second,t,n)||e.second}:e}function j(e,t){return e===null?null:e.type==="pane"?e.id===t?e:null:j(e.first,t)??j(e.second,t)}function Y(e,t){return e===null?null:e.type==="pane"?e.tabs.includes(t)?e:null:Y(e.first,t)??Y(e.second,t)}function je(e,t){let n=Y(e,t);if(!n)return null;let s=n.tabs.indexOf(t);return {id:t,paneId:n.id,isActive:n.activeTabId===t,index:s,metadata:n.tabsMetadata?.[t]}}function Se(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.tabs.includes(t)){let s=e.tabsMetadata||{},r=s[t],o=n(r),i={...s};return o===void 0?delete i[t]:i[t]=o,{...e,tabsMetadata:Object.keys(i).length>0?i:void 0}}return e}return {...e,first:Se(e.first,t,n)??e.first,second:Se(e.second,t,n)??e.second}}function De(e,t,n,s){if(e===null)return null;if(e.type==="pane"){if(e.id===t){let r=[...e.tabs];r.includes(n)||r.push(n);let o=e.tabsMetadata;return s&&(o={...e.tabsMetadata,[n]:s}),{...e,tabs:r,activeTabId:n,tabsMetadata:o}}return e}return {...e,first:De(e.first,t,n,s)||e.first,second:De(e.second,t,n,s)||e.second}}function Ce(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.id===t){if(n===false){let{locked:s,...r}=e;return r}return {...e,locked:n}}return e}return {...e,first:Ce(e.first,t,n)??e.first,second:Ce(e.second,t,n)??e.second}}function we(e,t,n){return e===null?null:e.type==="pane"?e.id===t?{...e,activeTabId:n}:e:{...e,first:we(e.first,t,n)??e.first,second:we(e.second,t,n)??e.second}}function Qe(e,t,n){if(e===null)return null;let r=Y(e,t)?.tabsMetadata?.[t],o=pe(e,t);if(o===null)return {type:"pane",id:de(),tabs:[t],activeTabId:t,tabsMetadata:r?{[t]:r}:void 0};function i(a){if(a.type==="pane"){if(a.id===n){let u=[...a.tabs];u.includes(t)||u.push(t);let f={...a.tabsMetadata};return r&&(f[t]=r),{...a,tabs:u,activeTabId:t,tabsMetadata:Object.keys(f).length>0?f:void 0}}return a}return {...a,first:i(a.first),second:i(a.second)}}return i(o)}function et(e,t,n,s="before"){if(e===null)return null;let o=Y(e,t)?.tabsMetadata?.[t],i=pe(e,t);if(i===null)return {type:"pane",id:de(),tabs:[t],activeTabId:t,tabsMetadata:o?{[t]:o}:void 0};function a(u){if(u.type==="pane"){if(u.tabs.includes(n)){let C=[...u.tabs].filter(x=>x!==t),g=C.indexOf(n);g<0&&(g=0),s==="after"&&(g+=1),C.splice(g,0,t);let v={...u.tabsMetadata};return o&&(v[t]=o),{...u,tabs:C,activeTabId:t,tabsMetadata:Object.keys(v).length>0?v:void 0}}return u}return {...u,first:a(u.first),second:a(u.second)}}return a(i)}function ue(e,t=0,n=0,s=100,r=100,o="root"){if(e===null)return {panes:[],splitters:[]};if(e.type==="pane")return {panes:[{paneId:e.id,left:t,top:n,width:s,height:r,node:e}],splitters:[]};let{direction:i,splitPercentage:a,first:u,second:f}=e,g={id:`splitter-${o}-${i}`,currentNode:e,direction:i,left:i==="row"?t+s*(a/100):t,top:i==="column"?n+r*(a/100):n,width:i==="row"?0:s,height:i==="column"?0:r,parentLeft:t,parentTop:n,parentWidth:s,parentHeight:r},v={panes:[],splitters:[]},x={panes:[],splitters:[]};if(i==="row"){let R=s*(a/100);v=ue(u,t,n,R,r,`${o}-L`),x=ue(f,t+R,n,s-R,r,`${o}-R`);}else {let R=r*(a/100);v=ue(u,t,n,s,R,`${o}-T`),x=ue(f,t,n+R,s,r-R,`${o}-B`);}return {panes:[...v.panes,...x.panes],splitters:[g,...v.splitters,...x.splitters]}}function xe(e){try{return JSON.stringify(e)}catch{return ""}}function Rt(e){let{initialLayout:t,layout:n,onChange:s,fullscreenPaneId:r,onFullscreenChange:o,locked:i=false,dragActivationDistance:a=8,snapThreshold:u=8,minSplitPercentage:f=5,maxSplitPercentage:C=95,enableDragToDismiss:g=false,dismissThreshold:v=60,onRemove:x,onDragStart:R,onDragEnd:$,onResizeStart:p,onResize:S,onResizeEnd:m,onDismissIntentChange:D}=e,[P,M]=Wt.useState(()=>n!==void 0?n:t??null),[H,W]=Wt.useState(()=>xe(n!==void 0?n:null)),[q,Z]=Wt.useState(r||null),[G,V]=Wt.useState(i),[J,Q]=Wt.useState(null),[ee,d]=Wt.useState(null),[T,k]=Wt.useState(null),E=Wt.useRef(null),y=Wt.useCallback(c=>{E.current=c;},[]),l=Wt.useRef(P);l.current=P;let I=Wt.useRef(s);I.current=s;let U=Wt.useRef(o);U.current=o;let h=Wt.useCallback(c=>{Z(c),U.current?.(c);},[]);if(Wt.useEffect(()=>{V(i);},[i]),Wt.useEffect(()=>{r!==void 0&&Z(r);},[r]),n!==void 0){let c=xe(n);c!==H&&(W(c),M(n));}let b=Wt.useCallback(c=>(...w)=>{let A=l.current,B=c(A,...w);xe(A)!==xe(B)&&(l.current=B,M(B),I.current?.(B));},[]),O=Wt.useCallback(b((c,w)=>typeof w=="function"?w(c):w),[b]),K=Wt.useCallback(b((c,w)=>me(c,w)),[b]),oe=Wt.useCallback(b((c,w,A)=>Ke(c,w,A)),[b]),N=Wt.useCallback(b((c,w,A,B)=>{let ce=j(c,w)??Y(c,w);if(!ce)return c;let ye=Y(c,A),Ae=ye&&ye.id===ce.id?c:pe(c,A)??c;return De(Ae,ce.id,A,B)}),[b]),L=Wt.useCallback(b((c,w,A,B,ce)=>{let ye=j(c,w)??Y(c,w);if(!ye)return c;let Ye=j(c,ce)??Y(c,ce)??{type:"pane",id:ce,tabs:[ce],activeTabId:ce},Ae=me(c,ce);return Pe(Ae,ye.id,A,B,Ye)}),[b]),z=Wt.useCallback(b((c,w,A)=>ge(c,w,A)),[b]),se=Wt.useCallback(b((c,w,A)=>Se(c,w,A)),[b]),ne=Wt.useCallback(b((c,w,A)=>{let B=j(c,w)??Y(c,w);return B?Ce(c,B.id,A):c}),[b]),ie=Wt.useCallback(b((c,w,A)=>{let B=j(c,w)??Y(c,w);return B?we(c,B.id,A):c}),[b]),ae=Wt.useCallback(b((c,w,A)=>{let B=j(c,A)??Y(c,A);return B?Qe(c,w,B.id):c}),[b]),F=Wt.useCallback(b((c,w,A,B)=>et(c,w,A,B)),[b]),te=Wt.useCallback(b((c,w)=>pe(c,w)),[b]),re=Wt.useCallback(c=>j(l.current,c),[]),he=Wt.useCallback(c=>Y(l.current,c),[]),ht=Wt.useCallback(c=>je(l.current,c),[]);return {layout:P,setLayout:O,fullscreenPaneId:q,setFullscreenPaneId:h,locked:G,setLocked:V,activeId:J,setActiveId:Q,activeType:ee,setActiveType:d,dismissIntentId:T,setDismissIntentId:k,containerRef:E,setContainerRef:y,dragActivationDistance:a,snapThreshold:u,minSplitPercentage:f,maxSplitPercentage:C,enableDragToDismiss:g,dismissThreshold:v,onRemove:x,onDragStart:R,onDragEnd:$,onResizeStart:p,onResize:S,onResizeEnd:m,onDismissIntentChange:D,removePane:K,addPane:oe,addTab:N,splitPane:L,updateSplitPercentage:z,updateTabMetadata:se,updatePaneLock:ne,selectTab:ie,mergeTab:ae,moveTab:F,removeTab:te,findPaneById:re,findPaneContainingTab:he,findTabById:ht}}function Ne({cursor:e,resizerEl:t,onMove:n,onEnd:s}){document.body.classList.add("zeugma-resizing");let r=document.createElement("style");r.id="zeugma-global-cursor-style",r.textContent=`
1
+ 'use strict';var _t=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 _t__default=/*#__PURE__*/_interopDefault(_t);function qe(e){let t=_t.useRef(null);return _t.useEffect(()=>{if(!e){t.current=null;return}let n=r=>{t.current={x:r.clientX,y:r.clientY};},s=r=>{let o=r.touches[0]||r.changedTouches[0];o&&(t.current={x:o.clientX,y:o.clientY});};return window.addEventListener("pointermove",n,{passive:true}),window.addEventListener("touchmove",s,{passive:true}),()=>{window.removeEventListener("pointermove",n),window.removeEventListener("touchmove",s);}},[e]),t}function Je(e){_t.useEffect(()=>(e?document.body.style.setProperty("cursor","not-allowed","important"):document.body.style.removeProperty("cursor"),()=>{document.body.style.removeProperty("cursor");}),[e]);}function Ge(){let[e,t]=_t.useState({}),n=_t.useRef(true);_t.useEffect(()=>(n.current=true,()=>{n.current=false;}),[]);let s=_t.useCallback((r,o)=>{n.current&&t(i=>i[r]===o?i:{...i,[r]:o});},[]);return {portalTargets:e,registerPortalTarget:s}}var Rt=8,St=8,Cn=4;function de(){return "pane-"+Math.random().toString(36).substring(2,11)}function me(e,t){if(e===null)return null;if(e.type==="pane")return e.id===t?null:e;let n=me(e.first,t),s=me(e.second,t);return n===null?s:s===null?n:{...e,first:n,second:s}}function pe(e,t){if(e===null)return null;if(e.type==="pane"){if(e.tabs.includes(t)){let r=e.tabs.filter(a=>a!==t);if(r.length===0)return null;let o=e.activeTabId;e.activeTabId===t&&(o=r[0]);let i={...e.tabsMetadata};return delete i[t],{...e,tabs:r,activeTabId:o,tabsMetadata:Object.keys(i).length>0?i:void 0}}return e}let n=pe(e.first,t),s=pe(e.second,t);return n===null?s:s===null?n:{...e,first:n,second:s}}function Pe(e,t,n,s,r){if(e===null)return typeof r=="string"?{type:"pane",id:de(),tabs:[r],activeTabId:r}:r;if(e.type==="pane"){if(e.id===t){let o=typeof r=="string"?{type:"pane",id:de(),tabs:[r],activeTabId:r}:r,i=s==="left"||s==="top";return {type:"split",direction:n,first:i?o:e,second:i?e:o,splitPercentage:50}}return e}return {...e,first:Pe(e.first,t,n,s,r)||e.first,second:Pe(e.second,t,n,s,r)||e.second}}function Ke(e,t,n){if(e===null)return {type:"pane",id:de(),tabs:[t],activeTabId:t,tabsMetadata:n?{[t]:n}:void 0};function s(r,o){return r.type==="pane"?{type:"split",direction:o==="row"?"column":"row",splitPercentage:50,first:r,second:{type:"pane",id:de(),tabs:[t],activeTabId:t,tabsMetadata:n?{[t]:n}:void 0}}:{...r,second:s(r.second,r.direction)}}return s(e,null)}function ge(e,t,n){return e===null?null:e===t?{...e,splitPercentage:n}:e.type==="split"?{...e,first:ge(e.first,t,n)||e.first,second:ge(e.second,t,n)||e.second}:e}function Q(e,t){return e===null?null:e.type==="pane"?e.id===t?e:null:Q(e.first,t)??Q(e.second,t)}function Y(e,t){return e===null?null:e.type==="pane"?e.tabs.includes(t)?e:null:Y(e.first,t)??Y(e.second,t)}function Qe(e,t){let n=Y(e,t);if(!n)return null;let s=n.tabs.indexOf(t);return {id:t,paneId:n.id,isActive:n.activeTabId===t,index:s,metadata:n.tabsMetadata?.[t]}}function Se(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.tabs.includes(t)){let s=e.tabsMetadata||{},r=s[t],o=n(r),i={...s};return o===void 0?delete i[t]:i[t]=o,{...e,tabsMetadata:Object.keys(i).length>0?i:void 0}}return e}return {...e,first:Se(e.first,t,n)??e.first,second:Se(e.second,t,n)??e.second}}function De(e,t,n,s){if(e===null)return null;if(e.type==="pane"){if(e.id===t){let r=[...e.tabs];r.includes(n)||r.push(n);let o=e.tabsMetadata;return s&&(o={...e.tabsMetadata,[n]:s}),{...e,tabs:r,activeTabId:n,tabsMetadata:o}}return e}return {...e,first:De(e.first,t,n,s)||e.first,second:De(e.second,t,n,s)||e.second}}function Ce(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.id===t){if(n===false){let{locked:s,...r}=e;return r}return {...e,locked:n}}return e}return {...e,first:Ce(e.first,t,n)??e.first,second:Ce(e.second,t,n)??e.second}}function we(e,t,n){return e===null?null:e.type==="pane"?e.id===t?{...e,activeTabId:n}:e:{...e,first:we(e.first,t,n)??e.first,second:we(e.second,t,n)??e.second}}function je(e,t,n){if(e===null)return null;let r=Y(e,t)?.tabsMetadata?.[t],o=pe(e,t);if(o===null)return {type:"pane",id:de(),tabs:[t],activeTabId:t,tabsMetadata:r?{[t]:r}:void 0};function i(a){if(a.type==="pane"){if(a.id===n){let u=[...a.tabs];u.includes(t)||u.push(t);let d={...a.tabsMetadata};return r&&(d[t]=r),{...a,tabs:u,activeTabId:t,tabsMetadata:Object.keys(d).length>0?d:void 0}}return a}return {...a,first:i(a.first),second:i(a.second)}}return i(o)}function et(e,t,n,s="before"){if(e===null)return null;let o=Y(e,t)?.tabsMetadata?.[t],i=pe(e,t);if(i===null)return {type:"pane",id:de(),tabs:[t],activeTabId:t,tabsMetadata:o?{[t]:o}:void 0};function a(u){if(u.type==="pane"){if(u.tabs.includes(n)){let y=[...u.tabs].filter(h=>h!==t),m=y.indexOf(n);m<0&&(m=0),s==="after"&&(m+=1),y.splice(m,0,t);let b={...u.tabsMetadata};return o&&(b[t]=o),{...u,tabs:y,activeTabId:t,tabsMetadata:Object.keys(b).length>0?b:void 0}}return u}return {...u,first:a(u.first),second:a(u.second)}}return a(i)}function ue(e,t=0,n=0,s=100,r=100,o="root"){if(e===null)return {panes:[],splitters:[]};if(e.type==="pane")return {panes:[{paneId:e.id,left:t,top:n,width:s,height:r,node:e}],splitters:[]};let{direction:i,splitPercentage:a,first:u,second:d}=e,m={id:`splitter-${o}-${i}`,currentNode:e,direction:i,left:i==="row"?t+s*(a/100):t,top:i==="column"?n+r*(a/100):n,width:i==="row"?0:s,height:i==="column"?0:r,parentLeft:t,parentTop:n,parentWidth:s,parentHeight:r},b={panes:[],splitters:[]},h={panes:[],splitters:[]};if(i==="row"){let T=s*(a/100);b=ue(u,t,n,T,r,`${o}-L`),h=ue(d,t+T,n,s-T,r,`${o}-R`);}else {let T=r*(a/100);b=ue(u,t,n,s,T,`${o}-T`),h=ue(d,t,n+T,s,r-T,`${o}-B`);}return {panes:[...b.panes,...h.panes],splitters:[m,...b.splitters,...h.splitters]}}function xe(e){try{return JSON.stringify(e)}catch{return ""}}function Dt(e){let{initialLayout:t,layout:n,onChange:s,fullscreenPaneId:r,onFullscreenChange:o,locked:i=false,dragActivationDistance:a=8,snapThreshold:u=8,minSplitPercentage:d=5,maxSplitPercentage:y=95,enableDragToDismiss:m=false,dismissThreshold:b=60,onRemove:h,onDragStart:T,onDragEnd:I,onResizeStart:f,onResize:D,onResizeEnd:g,onDismissIntentChange:C}=e,[x,L]=_t.useState(()=>n!==void 0?n:t??null),[H,W]=_t.useState(()=>xe(n!==void 0?n:null)),[q,Z]=_t.useState(r||null),[G,V]=_t.useState(i),[J,j]=_t.useState(null),[ee,p]=_t.useState(null),[R,k]=_t.useState(null),E=_t.useRef(null),S=_t.useCallback(c=>{E.current=c;},[]),l=_t.useRef(x);l.current=x;let M=_t.useRef(s);M.current=s;let U=_t.useRef(o);U.current=o;let P=_t.useCallback(c=>{Z(c),U.current?.(c);},[]);if(_t.useEffect(()=>{V(i);},[i]),_t.useEffect(()=>{r!==void 0&&Z(r);},[r]),n!==void 0){let c=xe(n);c!==H&&(W(c),L(n));}let v=_t.useCallback(c=>(...w)=>{let A=l.current,B=c(A,...w);xe(A)!==xe(B)&&(l.current=B,L(B),M.current?.(B));},[]),O=_t.useCallback(v((c,w)=>typeof w=="function"?w(c):w),[v]),K=_t.useCallback(v((c,w)=>me(c,w)),[v]),oe=_t.useCallback(v((c,w,A)=>Ke(c,w,A)),[v]),N=_t.useCallback(v((c,w,A,B)=>{let ce=Q(c,w)??Y(c,w);if(!ce)return c;let ye=Y(c,A),Ae=ye&&ye.id===ce.id?c:pe(c,A)??c;return De(Ae,ce.id,A,B)}),[v]),z=_t.useCallback(v((c,w,A,B,ce)=>{let ye=Q(c,w)??Y(c,w);if(!ye)return c;let Ye=Q(c,ce)??Y(c,ce)??{type:"pane",id:ce,tabs:[ce],activeTabId:ce},Ae=me(c,ce);return Pe(Ae,ye.id,A,B,Ye)}),[v]),$=_t.useCallback(v((c,w,A)=>ge(c,w,A)),[v]),se=_t.useCallback(v((c,w,A)=>Se(c,w,A)),[v]),ne=_t.useCallback(v((c,w,A)=>{let B=Q(c,w)??Y(c,w);return B?Ce(c,B.id,A):c}),[v]),ie=_t.useCallback(v((c,w,A)=>{let B=Q(c,w)??Y(c,w);return B?we(c,B.id,A):c}),[v]),ae=_t.useCallback(v((c,w,A)=>{let B=Q(c,A)??Y(c,A);return B?je(c,w,B.id):c}),[v]),F=_t.useCallback(v((c,w,A,B)=>et(c,w,A,B)),[v]),te=_t.useCallback(v((c,w)=>pe(c,w)),[v]),re=_t.useCallback(c=>Q(l.current,c),[]),he=_t.useCallback(c=>Y(l.current,c),[]),Tt=_t.useCallback(c=>Qe(l.current,c),[]);return {layout:x,setLayout:O,fullscreenPaneId:q,setFullscreenPaneId:P,locked:G,setLocked:V,activeId:J,setActiveId:j,activeType:ee,setActiveType:p,dismissIntentId:R,setDismissIntentId:k,containerRef:E,setContainerRef:S,dragActivationDistance:a,snapThreshold:u,minSplitPercentage:d,maxSplitPercentage:y,enableDragToDismiss:m,dismissThreshold:b,onRemove:h,onDragStart:T,onDragEnd:I,onResizeStart:f,onResize:D,onResizeEnd:g,onDismissIntentChange:C,removePane:K,addPane:oe,addTab:N,splitPane:z,updateSplitPercentage:$,updateTabMetadata:se,updatePaneLock:ne,selectTab:ie,mergeTab:ae,moveTab:F,removeTab:te,findPaneById:re,findPaneContainingTab:he,findTabById:Tt}}function Ne({cursor:e,resizerEl:t,onMove:n,onEnd:s}){document.body.classList.add("zeugma-resizing");let r=document.createElement("style");r.id="zeugma-global-cursor-style",r.textContent=`
2
2
  * {
3
3
  cursor: ${e} !important;
4
4
  user-select: none !important;
5
5
  }
6
- `,document.head.appendChild(r),t.setAttribute("data-resizing","true");let o=a=>{n(a);},i=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let a=document.getElementById("zeugma-global-cursor-style");a&&a.remove(),document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",i),s();};document.addEventListener("pointermove",o),document.addEventListener("pointerup",i);}var Ve=Wt.createContext(void 0),Be=Wt.createContext(void 0),Ie=Wt.createContext(void 0),le=()=>{let e=Wt.useContext(Ve);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},Me=()=>{let e=Wt.useContext(Be);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e};var St=()=>{let e=le(),t=Me();return {...e,...t}};var Le=class extends core.PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},ze=class extends core.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};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 ot(e){let{layout:t,setLayout:n,activeId:s,setActiveId:r,setActiveType:o,dismissIntentId:i,setDismissIntentId:a,setOverTabId:u,setOverTabPosition:f,containerRef:C,dragActivationDistance:g,enableDragToDismiss:v,dismissThreshold:x,onRemove:R,onDragStart:$,onDragEnd:p,onDismissIntentChange:S,removeTab:m,moveTab:D,selectTab:P}=e,M=Wt.useRef(null),H=qe(s),[W,q]=Wt.useState(false);Je(W);let Z=core.useSensors(core.useSensor(Le,{activationConstraint:{distance:g}}),core.useSensor(ze,{activationConstraint:{delay:250,tolerance:5}})),G=Wt.useCallback(d=>{let T=core.pointerWithin(d);if(T.length>0)return T;if(d.active.id.toString().startsWith("tab-header-")){let E=d.droppableContainers.filter(y=>y.id.toString().startsWith("tab-drop-"));return core.closestCenter({...d,droppableContainers:E})}return []},[]);return {sensors:Z,collisionDetection:G,onDragStart:d=>{let T=d.active.id.toString(),k=T.startsWith("tab-header-"),E=k?T.substring(11):T;r(E),o(k?"tab":"pane"),u(null),f(null);let y=d.activatorEvent;if(H.current=$e(y),v&&C.current?M.current=C.current.getBoundingClientRect():M.current=null,k){let l=Y(t,E);l&&P(l.id,E);}$&&$(E);},onDragMove:d=>{let{over:T}=d,k=T?.id.toString()||"",E=k.startsWith("drop-locked-");q(E);let y=k.match(/^tab-drop-(.+)$/);if(y&&T){let[,N]=y,L=d.active.id.toString();if((L.startsWith("tab-header-")?L.substring(11):L)!==N){let ne="before",ie=T.rect,ae=d.activatorEvent,F=null;if(H.current)F=H.current.x;else {let te=$e(ae);te&&(F=te.x+d.delta.x);}if(F!==null){let te=ie.left+ie.width/2;F>te&&(ne="after");}u(N),f(ne);}else u(null),f(null);}else u(null),f(null);if(!v)return;let l=d.active.id.toString(),U=l.startsWith("tab-header-")?l.substring(11):l,h=M.current;if(!h){i!==null&&(a(null),S?.(null));return}let b=d.activatorEvent,_=null,O=null;if(H.current)_=H.current.x,O=H.current.y;else {let N=$e(b);N&&(_=N.x+d.delta.x,O=N.y+d.delta.y);}let K=0;if(_!==null&&O!==null){let N=0,L=0;_<h.left?N=h.left-_:_>h.right&&(N=_-h.right),O<h.top?L=h.top-O:O>h.bottom&&(L=O-h.bottom),K=Math.sqrt(N*N+L*L);}else {let N=d.active.rect.current.translated;if(N){let L=N.left+N.width/2,z=N.top+N.height/2,se=0,ne=0;L<h.left?se=h.left-L:L>h.right&&(se=L-h.right),z<h.top?ne=h.top-z:z>h.bottom&&(ne=z-h.bottom),K=Math.sqrt(se*se+ne*ne);}}K>x?i!==U&&(a(U),S?.(U)):i!==null&&(a(null),S?.(null));},onDragEnd:d=>{r(null),o(null),q(false),u(null),f(null);let{active:T,over:k}=d,E=T.id.toString(),y=E.startsWith("tab-header-"),l=y?E.substring(11):E,I=v&&i===l;if(a(null),S?.(null),M.current=null,I){R?R(l):m(l),p&&p(l,null,null);return}if(!k){p&&p(l,null,null);return}let U=k.id.toString();if(U.startsWith("drop-locked-")){p&&p(l,null,null);return}let h=U.match(/^tab-drop-(.+)$/);if(h){let[,ie]=h;if(l!==ie){let ae="before",F=k.rect,te=d.activatorEvent,re=null;if(H.current)re=H.current.x;else {let he=$e(te);he&&(re=he.x+d.delta.x);}if(re!==null){let he=F.left+F.width/2;re>he&&(ae="after");}D(l,ie,ae),p&&p(l,ie,{type:"move",position:"center"});}else p&&p(l,null,null);return}let b=U.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!b){p&&p(l,null,null);return}let[,_,O]=b,K=y?Y(t,l):j(t,l),oe=K&&K.id===O,N=K&&K.tabs.length===1;if(l===O||oe&&N){p&&p(l,null,null);return}let L=_==="left"||_==="right"?"row":"column",z;if(y){let ae=Y(t,l)?.tabsMetadata?.[l];z={type:"pane",id:de(),tabs:[l],activeTabId:l,tabsMetadata:ae?{[l]:ae}:void 0};}else z=j(t,l)??{type:"pane",id:de(),tabs:[l],activeTabId:l};let se=y?pe(t,l):me(t,l),ne=Pe(se,O,L,_,z);n(ne),p&&p(l,O,{type:"split",direction:L,position:_});},onDragCancel:()=>{r(null),o(null),q(false),u(null),f(null),a(null),S?.(null),M.current=null;}}}var st=({activeId:e,render:t,className:n})=>{let s=Wt.useRef(null);return Wt.useEffect(()=>{let r=o=>{s.current&&(s.current.style.transform=`translate(${o.clientX+12}px, ${o.clientY+12}px)`);};return document.addEventListener("pointermove",r),()=>document.removeEventListener("pointermove",r)},[]),jsxRuntime.jsx("div",{ref:s,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var it=({tabId:e,target:t,renderWidget:n})=>{let[s,r]=Wt.useState(false),o=Wt.useRef(null);if(Wt.useEffect(()=>{r(true);},[]),Wt.useEffect(()=>{if(!s||!o.current)return;let a=o.current;if(t)t.appendChild(a);else {let u=document.getElementById("zeugma-hidden-portal-container");u||(u=document.createElement("div"),u.id="zeugma-hidden-portal-container",u.style.display="none",document.body.appendChild(u)),u.appendChild(a);}},[t,s]),Wt.useEffect(()=>()=>{o.current&&o.current.remove();},[]),!s)return null;o.current||(o.current=document.createElement("div"),o.current.className=`zeugma-portal-wrapper-${e}`,o.current.style.width="100%",o.current.style.height="100%");let i=o.current;return !i||!n?null:reactDom.createPortal(n(e),i)};var Ot=e=>{let t=e,{renderPane:n,renderWidget:s,renderDragOverlay:r,classNames:o={},children:i,layout:a,setLayout:u,fullscreenPaneId:f,setFullscreenPaneId:C,locked:g,setLocked:v,findPaneById:x,findPaneContainingTab:R,findTabById:$,activeId:p,activeType:S,dismissIntentId:m,setContainerRef:D,snapThreshold:P,minSplitPercentage:M,maxSplitPercentage:H,onRemove:W,onResizeStart:q,onResize:Z,onResizeEnd:G,removePane:V,addPane:J,addTab:Q,updateTabMetadata:ee,updatePaneLock:d,selectTab:T,mergeTab:k,removeTab:E,splitPane:y,updateSplitPercentage:l,moveTab:I}=t,{portalTargets:U,registerPortalTarget:h}=Ge(),[b,_]=Wt.useState(null),[O,K]=Wt.useState(null),oe=ot({...t,setOverTabId:_,setOverTabPosition:K}),N=Wt.useCallback(F=>n(F),[n]),L=Wt.useMemo(()=>o,[o.dashboard,o.dashboardDismissActive,o.pane,o.paneLocked,o.dropPreview,o.dragOverlay,o.resizer,o.dismissPreview,o.dashboardLocked,o.lockedPreview,o.tabDropPreview]),z=Wt.useCallback((F,te)=>{G&&G(F,te);},[G]),se=Wt.useMemo(()=>({layout:a,setLayout:u,renderPane:N,activeId:p,dismissIntentId:m,overTabId:b,overTabPosition:O,setContainerRef:D,fullscreenPaneId:f,classNames:L,onRemove:W,onFullscreenChange:C,snapThreshold:P,onResizeStart:q,onResize:Z,onResizeEnd:z,minSplitPercentage:M,maxSplitPercentage:H,locked:g,setLocked:v,findPaneById:x,findPaneContainingTab:R,findTabById:$}),[a,p,m,b,O,D,f,L,W,C,P,q,Z,M,H,u,N,z,g,v,x,R,$]),ne=Wt.useMemo(()=>({removePane:V,addPane:J,addTab:Q,updateTabMetadata:ee,updatePaneLock:d,selectTab:T,mergeTab:k,removeTab:E,setFullscreenPaneId:C,setLocked:v,splitPane:y,updateSplitPercentage:l,moveTab:I}),[V,J,Q,ee,d,T,k,E,C,v,y,l,I]),ie=Wt.useMemo(()=>{let F=[];function te(re){re&&(re.type==="pane"?F.push(...re.tabs):(te(re.first),te(re.second)));}return te(a),F},[a]),ae=Wt.useMemo(()=>({registerPortalTarget:h}),[h]);return jsxRuntime.jsx(Be.Provider,{value:ne,children:jsxRuntime.jsx(Ve.Provider,{value:se,children:jsxRuntime.jsxs(Ie.Provider,{value:ae,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",...oe,children:i}),p&&S&&r&&jsxRuntime.jsx(st,{activeId:p,render:F=>r(F,S),className:`${o.dragOverlay||""} ${p===m&&o.dismissPreview||""}`.trim()}),jsxRuntime.jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:ie.map(F=>jsxRuntime.jsx(it,{tabId:F,target:U[F]||null,renderWidget:s},F))})]})})})};function Ue({containerRef:e,isRow:t,direction:n,splitPercentage:s,resizerSize:r,snapThreshold:o,layout:i,currentNode:a,onLayoutChange:u,onResizeStart:f,onResizeEnd:C,parentLeft:g,parentTop:v,parentWidth:x,parentHeight:R}){let{onResizeStart:$,onResize:p,onResizeEnd:S,minSplitPercentage:m=5,maxSplitPercentage:D=95,locked:P=false}=le();return Wt.useCallback(M=>{if(P)return;M.preventDefault();let H=e.current;if(!H)return;f&&f(),$&&$(a);let W=H.getBoundingClientRect(),q=M.clientX,Z=M.clientY,G=s,V=M.currentTarget,J=W.left+W.width*(g/100),Q=W.top+W.height*(v/100),ee=W.width*(x/100),d=W.height*(R/100),k=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(y=>y!==V&&y.getAttribute("data-direction")===n).map(y=>{let l=y.getBoundingClientRect();return t?l.left+l.width/2:l.top+l.height/2}),E=G;Ne({cursor:t?"col-resize":"row-resize",resizerEl:V,onMove:y=>{let l=t?(y.clientX-q)/ee*100:(y.clientY-Z)/d*100,I=G+l,U=t?J+(ee-r)*(I/100)+r/2:Q+(d-r)*(I/100)+r/2,h=1/0,b=null;for(let oe of k){let N=Math.abs(U-oe);N<o&&N<h&&(h=N,b=oe);}let _=I;b!==null&&(_=t?(b-r/2-J)/(ee-r)*100:(b-r/2-Q)/(d-r)*100);let O=Math.max(m,Math.min(D,_));E=O;let K=ge(i,a,O);if(K){let{panes:oe,splitters:N}=ue(K),L=e.current;if(L){for(let z of oe)L.style.setProperty(`--pane-left-${z.paneId}`,`${z.left}%`),L.style.setProperty(`--pane-top-${z.paneId}`,`${z.top}%`),L.style.setProperty(`--pane-width-${z.paneId}`,`${z.width}%`),L.style.setProperty(`--pane-height-${z.paneId}`,`${z.height}%`);for(let z of N)L.style.setProperty(`--splitter-pos-${z.id}`,`${z.direction==="row"?z.left:z.top}%`);}}p&&p(a,O);},onEnd:()=>{let y=ge(i,a,E),l=e.current;if(l){let{panes:I,splitters:U}=ue(y);for(let h of I)l.style.removeProperty(`--pane-left-${h.paneId}`),l.style.removeProperty(`--pane-top-${h.paneId}`),l.style.removeProperty(`--pane-width-${h.paneId}`),l.style.removeProperty(`--pane-height-${h.paneId}`);for(let h of U)l.style.removeProperty(`--splitter-pos-${h.id}`);}u(y),C&&C(),S&&S(a,E);}});},[e,t,n,s,r,o,i,a,u,f,C,$,p,S,m,D,g,v,x,R])}var Xt=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:s})=>{let{layout:r,setLayout:o,classNames:i,locked:a}=le(),[u,f]=Wt.useState(false),{currentNode:C,direction:g,left:v,top:x,width:R,height:$,parentLeft:p,parentTop:S,parentWidth:m,parentHeight:D}=e,P=g==="row",M=Ue({containerRef:s,isRow:P,direction:g,splitPercentage:C.splitPercentage,resizerSize:t,snapThreshold:n,layout:r,currentNode:C,onLayoutChange:o,onResizeStart:()=>f(true),onResizeEnd:()=>f(false),parentLeft:p,parentTop:S,parentWidth:m,parentHeight:D}),H=P?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${v}%) - ${t/2}px)`,top:`calc(${x}% + ${t/2}px)`,width:`${t}px`,height:`calc(${$}% - ${t}px)`,cursor:a?"default":"col-resize",pointerEvents:a?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`calc(${v}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${x}%) - ${t/2}px)`,width:`calc(${R}% - ${t}px)`,height:`${t}px`,cursor:a?"default":"row-resize",pointerEvents:a?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"};return jsxRuntime.jsx("div",{className:i.resizer||"","data-direction":g,"data-resizing":u||void 0,style:H,onPointerDown:M,role:"separator","aria-valuenow":C.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},qt=Wt__default.default.memo(({paneId:e,renderPane:t})=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane),Jt=({tree:e,resizerSize:t=4,snapThreshold:n})=>{let{layout:s,renderPane:r,activeId:o,dismissIntentId:i,setContainerRef:a,fullscreenPaneId:u,snapThreshold:f,locked:C,classNames:g}=le(),v=n!==void 0?n:f??8,x=e!==void 0?e:s,R=Wt.useRef(null),{panes:$,splitters:p}=Wt.useMemo(()=>x?ue(x):{panes:[],splitters:[]},[x]);if(!x)return null;let S=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[$.map(m=>{let D=u===m.paneId;return jsxRuntime.jsx("div",{style:{position:"absolute",left:D?"0%":`var(--pane-left-${m.paneId}, ${m.left}%)`,top:D?"0%":`var(--pane-top-${m.paneId}, ${m.top}%)`,width:D?"100%":`var(--pane-width-${m.paneId}, ${m.width}%)`,height:D?"100%":`var(--pane-height-${m.paneId}, ${m.height}%)`,overflow:"hidden",zIndex:D?20:1,display:u&&!D?"none":"block",padding:D?"0px":`${t/2}px`,boxSizing:"border-box"},children:jsxRuntime.jsx(qt,{paneId:m.paneId,renderPane:r})},m.paneId)}),!u&&p.map(m=>jsxRuntime.jsx(Xt,{splitter:m,resizerSize:t,snapThreshold:v,containerRef:R},m.id))]});if(e===void 0){let m=o!==null&&o===i,D=M=>{a(M),R.current=M;},P=`${g.dashboard||""} ${m&&g.dashboardDismissActive||""} ${C&&g.dashboardLocked||""}`.trim();return jsxRuntime.jsx("div",{ref:D,className:P,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:S()})}return jsxRuntime.jsx("div",{ref:R,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:S()})};var ft="zeugma-height:",Qt="default-pane";function en(e){try{let t=localStorage.getItem(ft+e);if(t!==null){let n=Number(t);if(Number.isFinite(n)&&n>0)return n}}catch{}return null}function pt(e,t){try{localStorage.setItem(ft+e,String(Math.round(t)));}catch{}}var mt=({children:e,active:t=true,height:n,onHeightChange:s,minHeight:r=100,maxHeight:o=1/0,persist:i,localStorageKey:a,resizerHeight:u=6,className:f,resizerClassName:C})=>{let g=i?a||Qt:null,v=()=>{let P=(g?en(g):null)??n??400;return Ze(P,r,o)},[x,R]=Wt.useState(v),$=Wt.useRef(null),p=g?x:n??x,S=Wt.useRef(n);Wt.useEffect(()=>{if(n!==void 0&&n!==S.current){let P=Ze(n,r,o);R(P),g&&pt(g,P);}S.current=n;},[n,r,o,g]);let m=Wt.useCallback(()=>o,[o]),D=Wt.useCallback(P=>{P.preventDefault();let M=P.clientY,H=p,W=m(),q=P.currentTarget,Z=gt($.current),G=Z?Z.scrollTop:0,V=M,J=null,Q=(d,T)=>{let k=T-G,y=d-M+k,l=Ze(H+y,r,W);return $.current&&($.current.style.height=`${l}px`),l},ee=()=>{if(!Z)return;let d=Z===document.documentElement||Z===document.body?{top:0,bottom:window.innerHeight}:Z.getBoundingClientRect(),T=40,k=10,E=0;V>d.bottom-T?E=Math.min(1,(V-(d.bottom-T))/T)*k:V<d.top+T&&(E=-Math.min(1,(d.top+T-V)/T)*k),E!==0&&(Z.scrollTop+=E,Q(V,Z.scrollTop)),J=requestAnimationFrame(ee);};J=requestAnimationFrame(ee),Ne({cursor:"row-resize",resizerEl:q,onMove:d=>{V=d.clientY,Z&&Q(V,Z.scrollTop);},onEnd:()=>{J!==null&&cancelAnimationFrame(J);let d=H;$.current&&(d=$.current.getBoundingClientRect().height),d=Ze(d,r,W),R(d),s&&s(d),g&&pt(g,d);}});},[p,r,m,s,g]);return t?jsxRuntime.jsxs("div",{ref:$,className:`zeugma-resizable-container ${f||""}`.trim(),style:{height:`${p}px`,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:[jsxRuntime.jsx("div",{style:{height:`calc(100% - ${u}px)`,overflow:"hidden"},children:e}),jsxRuntime.jsx("div",{className:`zeugma-resizable-handle ${C||""}`.trim(),style:{height:`${u}px`,cursor:"row-resize",position:"relative",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box",flexShrink:0},onPointerDown:D,role:"separator","aria-orientation":"horizontal","aria-valuenow":Math.round(p),"aria-valuemin":r,"aria-valuemax":o===1/0?void 0:o})]}):jsxRuntime.jsx("div",{className:`zeugma-resizable-container disabled ${f||""}`.trim(),style:{height:"100%",position:"relative",overflow:"hidden",boxSizing:"border-box"},children:jsxRuntime.jsx("div",{style:{height:"100%",overflow:"hidden"},children:e})})};function Ze(e,t,n){return Math.max(t,Math.min(n,e))}function gt(e){if(typeof window>"u"||!e)return null;let t=e.parentElement;if(!t)return document.documentElement;let s=window.getComputedStyle(t).overflowY;return s==="auto"||s==="scroll"?t:gt(t)}var He=Wt.createContext(null);var un={top:{position:"absolute",top:0,left:"25%",width:"50%",height:"25%",zIndex:20,pointerEvents:"auto"},bottom:{position:"absolute",bottom:0,left:"25%",width:"50%",height:"25%",zIndex:20,pointerEvents:"auto"},left:{position:"absolute",top:"25%",left:0,width:"25%",height:"50%",zIndex:20,pointerEvents:"auto"},right:{position:"absolute",top:"25%",right:0,width:"25%",height:"50%",zIndex:20,pointerEvents:"auto"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:20,pointerEvents:"auto",cursor:"not-allowed"}},dn={top:{position:"absolute",top:0,left:0,right:0,height:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},bottom:{position:"absolute",bottom:0,left:0,right:0,height:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},left:{position:"absolute",top:0,bottom:0,left:0,width:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},right:{position:"absolute",top:0,bottom:0,right:0,width:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:21,pointerEvents:"none",boxSizing:"border-box"}},bt=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:s,isOver:r}=core.useDroppable({id:e});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:s,style:un[t]}),r&&jsxRuntime.jsx("div",{className:n,style:dn[t]})]})},pn=({id:e,children:t,style:n,locked:s=false})=>{let r=Wt.useRef(null),{layout:o,activeId:i,classNames:a,fullscreenPaneId:u,onFullscreenChange:f,locked:C}=le(),{removePane:g,updateTabMetadata:v,selectTab:x,removeTab:R}=Me(),$=Wt.useContext(Ie);if(!$)throw new Error("Pane must be used within a Zeugma provider");let{registerPortalTarget:p}=$,S=Wt.useMemo(()=>j(o,e),[o,e]),m=S?.id??e,D=S?.tabs??[e],P=S?.activeTabId??e,M=S?.tabsMetadata,H=M?.[e],W=S?.locked??false,q=s||W,Z=C||q,G=C||q,V=i!==null&&i!==e&&(!D.includes(i)||D.length>1)&&!G,{attributes:J,listeners:Q,setNodeRef:ee}=core.useDraggable({id:e,disabled:Z}),d=i!==null&&D.includes(i),T=u===e,k=Wt.useCallback(()=>jsxRuntime.jsx("div",{ref:r,id:`zeugma-tab-target-${P}`,className:"zeugma-tab-content-wrapper",style:{height:"100%",width:"100%"}}),[P]);Wt.useEffect(()=>{let I=r.current;return p(P,I),()=>{p(P,null);}},[P,p]);let E=Wt.useMemo(()=>({isDragging:d,isFullscreen:T,toggleFullscreen:()=>f?.(T?null:e),remove:()=>{T&&f?.(null),g(m);},metadata:H,updateMetadata:I=>{v(e,I);},locked:Z,tabs:D,activeTabId:P,selectTab:I=>x(m,I),removeTab:I=>{T&&I===P&&f?.(null),R(I);},tabsMetadata:M,updateTabMetadata:(I,U)=>{v(I,U);},renderActiveTab:k}),[d,T,f,e,R,H,v,Z,D,P,x,m,M,k]),y=Wt.useMemo(()=>Z?{disabled:true}:{...Q,...J},[Q,J,Z]),l=`${a.pane||""} ${q&&a.paneLocked||""}`.trim();return jsxRuntime.jsx(He.Provider,{value:y,children:jsxRuntime.jsxs("div",{ref:ee,className:l,style:{position:"relative",width:"100%",height:"100%",...n},children:[t(E),V&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:["top","bottom","left","right"].map(I=>jsxRuntime.jsx(bt,{id:`drop-${I}-${e}`,position:I,activeClassName:a.dropPreview},I))}),i!==null&&i!==e&&G&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsxRuntime.jsx(bt,{id:`drop-locked-${e}`,position:"full",activeClassName:a.lockedPreview||""})})]})})};var gn=({children:e,className:t,style:n})=>{let s=Wt.useContext(He);if(!s)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:r,...o}=s;return jsxRuntime.jsx("div",{className:t,style:{cursor:r?"default":"grab",userSelect:r?"auto":"none",touchAction:r?"auto":"none",...n},...r?{}:o,children:e})};var Pn=({id:e,locked:t=false,children:n,className:s,style:r})=>{let{locked:o,classNames:i={},overTabId:a,overTabPosition:u}=le(),f=t||o,{attributes:C,listeners:g,setNodeRef:v,isDragging:x}=core.useDraggable({id:`tab-header-${e}`,disabled:f}),{setNodeRef:R,isOver:$}=core.useDroppable({id:`tab-drop-${e}`,disabled:f}),p=D=>{v(D),R(D);},S=$&&a===e,m=S?u:null;return jsxRuntime.jsxs("div",{ref:p,className:s,style:{display:"inline-flex",position:"relative",cursor:f?"default":"grab",...r},...f?{}:g,...f?{}:C,children:[n({isDragging:x,isOver:S}),S&&m&&jsxRuntime.jsx("div",{className:i.tabDropPreview||"",style:{position:"absolute",top:0,bottom:0,width:"2px",backgroundColor:"#6366f1",left:m==="before"?0:void 0,right:m==="after"?0:void 0,pointerEvents:"none",zIndex:10}})]})};exports.DEFAULT_DRAG_ACTIVATION_DISTANCE=xt;exports.DEFAULT_RESIZER_SIZE=Sn;exports.DEFAULT_SNAP_THRESHOLD=yt;exports.DragHandle=gn;exports.Pane=pn;exports.PaneTree=Jt;exports.PortalRegistryContext=Ie;exports.ResizableContainer=mt;exports.Tab=Pn;exports.Zeugma=Ot;exports.ZeugmaActionsContext=Be;exports.ZeugmaStateContext=Ve;exports.createDragSession=Ne;exports.safeJsonStringify=xe;exports.useResizer=Ue;exports.useZeugma=Rt;exports.useZeugmaActions=Me;exports.useZeugmaContext=St;exports.useZeugmaState=le;//# sourceMappingURL=index.cjs.map
6
+ `,document.head.appendChild(r),t.setAttribute("data-resizing","true");let o=a=>{n(a);},i=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let a=document.getElementById("zeugma-global-cursor-style");a&&a.remove(),document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",i),s();};document.addEventListener("pointermove",o),document.addEventListener("pointerup",i);}var Ve=_t.createContext(void 0),Be=_t.createContext(void 0),Ie=_t.createContext(void 0),le=()=>{let e=_t.useContext(Ve);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},Me=()=>{let e=_t.useContext(Be);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e};var Ct=()=>{let e=le(),t=Me();return {...e,...t}};var Le=class extends core.PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},ze=class extends core.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};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 ot(e){let{layout:t,setLayout:n,activeId:s,setActiveId:r,setActiveType:o,dismissIntentId:i,setDismissIntentId:a,setOverTabId:u,setOverTabPosition:d,containerRef:y,dragActivationDistance:m,enableDragToDismiss:b,dismissThreshold:h,onRemove:T,onDragStart:I,onDragEnd:f,onDismissIntentChange:D,removeTab:g,moveTab:C,selectTab:x}=e,L=_t.useRef(null),H=qe(s),[W,q]=_t.useState(false);Je(W);let Z=core.useSensors(core.useSensor(Le,{activationConstraint:{distance:m}}),core.useSensor(ze,{activationConstraint:{delay:250,tolerance:5}})),G=_t.useCallback(p=>{let R=core.pointerWithin(p);if(R.length>0)return R;if(p.active.id.toString().startsWith("tab-header-")){let E=p.droppableContainers.filter(S=>S.id.toString().startsWith("tab-drop-"));return core.closestCenter({...p,droppableContainers:E})}return []},[]);return {sensors:Z,collisionDetection:G,onDragStart:p=>{let R=p.active.id.toString(),k=R.startsWith("tab-header-"),E=k?R.substring(11):R;r(E),o(k?"tab":"pane"),u(null),d(null);let S=p.activatorEvent;if(H.current=$e(S),b&&y.current?L.current=y.current.getBoundingClientRect():L.current=null,k){let l=Y(t,E);l&&x(l.id,E);}I&&I(E);},onDragMove:p=>{let{over:R}=p,k=R?.id.toString()||"",E=k.startsWith("drop-locked-");q(E);let S=k.match(/^tab-drop-(.+)$/);if(S&&R){let[,N]=S,z=p.active.id.toString();if((z.startsWith("tab-header-")?z.substring(11):z)!==N){let ne="before",ie=R.rect,ae=p.activatorEvent,F=null;if(H.current)F=H.current.x;else {let te=$e(ae);te&&(F=te.x+p.delta.x);}if(F!==null){let te=ie.left+ie.width/2;F>te&&(ne="after");}u(N),d(ne);}else u(null),d(null);}else u(null),d(null);if(!b)return;let l=p.active.id.toString(),U=l.startsWith("tab-header-")?l.substring(11):l,P=L.current;if(!P){i!==null&&(a(null),D?.(null));return}let v=p.activatorEvent,_=null,O=null;if(H.current)_=H.current.x,O=H.current.y;else {let N=$e(v);N&&(_=N.x+p.delta.x,O=N.y+p.delta.y);}let K=0;if(_!==null&&O!==null){let N=0,z=0;_<P.left?N=P.left-_:_>P.right&&(N=_-P.right),O<P.top?z=P.top-O:O>P.bottom&&(z=O-P.bottom),K=Math.sqrt(N*N+z*z);}else {let N=p.active.rect.current.translated;if(N){let z=N.left+N.width/2,$=N.top+N.height/2,se=0,ne=0;z<P.left?se=P.left-z:z>P.right&&(se=z-P.right),$<P.top?ne=P.top-$:$>P.bottom&&(ne=$-P.bottom),K=Math.sqrt(se*se+ne*ne);}}K>h?i!==U&&(a(U),D?.(U)):i!==null&&(a(null),D?.(null));},onDragEnd:p=>{r(null),o(null),q(false),u(null),d(null);let{active:R,over:k}=p,E=R.id.toString(),S=E.startsWith("tab-header-"),l=S?E.substring(11):E,M=b&&i===l;if(a(null),D?.(null),L.current=null,M){T?T(l):g(l),f&&f(l,null,null);return}if(!k){f&&f(l,null,null);return}let U=k.id.toString();if(U.startsWith("drop-locked-")){f&&f(l,null,null);return}let P=U.match(/^tab-drop-(.+)$/);if(P){let[,ie]=P;if(l!==ie){let ae="before",F=k.rect,te=p.activatorEvent,re=null;if(H.current)re=H.current.x;else {let he=$e(te);he&&(re=he.x+p.delta.x);}if(re!==null){let he=F.left+F.width/2;re>he&&(ae="after");}C(l,ie,ae),f&&f(l,ie,{type:"move",position:"center"});}else f&&f(l,null,null);return}let v=U.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!v){f&&f(l,null,null);return}let[,_,O]=v,K=S?Y(t,l):Q(t,l),oe=K&&K.id===O,N=K&&K.tabs.length===1;if(l===O||oe&&N){f&&f(l,null,null);return}let z=_==="left"||_==="right"?"row":"column",$;if(S){let ae=Y(t,l)?.tabsMetadata?.[l];$={type:"pane",id:de(),tabs:[l],activeTabId:l,tabsMetadata:ae?{[l]:ae}:void 0};}else $=Q(t,l)??{type:"pane",id:de(),tabs:[l],activeTabId:l};let se=S?pe(t,l):me(t,l),ne=Pe(se,O,z,_,$);n(ne),f&&f(l,O,{type:"split",direction:z,position:_});},onDragCancel:()=>{r(null),o(null),q(false),u(null),d(null),a(null),D?.(null),L.current=null;}}}var st=({activeId:e,render:t,className:n})=>{let s=_t.useRef(null);return _t.useEffect(()=>{let r=o=>{s.current&&(s.current.style.transform=`translate(${o.clientX+12}px, ${o.clientY+12}px)`);};return document.addEventListener("pointermove",r),()=>document.removeEventListener("pointermove",r)},[]),jsxRuntime.jsx("div",{ref:s,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var it=({tabId:e,target:t,renderWidget:n})=>{let[s,r]=_t.useState(false),o=_t.useRef(null);if(_t.useEffect(()=>{r(true);},[]),_t.useEffect(()=>{if(!s||!o.current)return;let a=o.current;if(t)t.appendChild(a);else {let u=document.getElementById("zeugma-hidden-portal-container");u||(u=document.createElement("div"),u.id="zeugma-hidden-portal-container",u.style.display="none",document.body.appendChild(u)),u.appendChild(a);}},[t,s]),_t.useEffect(()=>()=>{o.current&&o.current.remove();},[]),!s)return null;o.current||(o.current=document.createElement("div"),o.current.className=`zeugma-portal-wrapper-${e}`,o.current.style.width="100%",o.current.style.height="100%");let i=o.current;return !i||!n?null:reactDom.createPortal(n(e),i)};var Bt=e=>{let t=e,{renderPane:n,renderWidget:s,renderDragOverlay:r,classNames:o={},children:i,layout:a,setLayout:u,fullscreenPaneId:d,setFullscreenPaneId:y,locked:m,setLocked:b,findPaneById:h,findPaneContainingTab:T,findTabById:I,activeId:f,activeType:D,dismissIntentId:g,setContainerRef:C,snapThreshold:x,minSplitPercentage:L,maxSplitPercentage:H,onRemove:W,onResizeStart:q,onResize:Z,onResizeEnd:G,removePane:V,addPane:J,addTab:j,updateTabMetadata:ee,updatePaneLock:p,selectTab:R,mergeTab:k,removeTab:E,splitPane:S,updateSplitPercentage:l,moveTab:M}=t,{portalTargets:U,registerPortalTarget:P}=Ge(),[v,_]=_t.useState(null),[O,K]=_t.useState(null),oe=ot({...t,setOverTabId:_,setOverTabPosition:K}),N=_t.useCallback(F=>n(F),[n]),z=_t.useMemo(()=>o,[o.dashboard,o.dashboardDismissActive,o.pane,o.paneLocked,o.dropPreview,o.dragOverlay,o.resizer,o.dismissPreview,o.dashboardLocked,o.lockedPreview,o.tabDropPreview]),$=_t.useCallback((F,te)=>{G&&G(F,te);},[G]),se=_t.useMemo(()=>({layout:a,setLayout:u,renderPane:N,activeId:f,dismissIntentId:g,overTabId:v,overTabPosition:O,setContainerRef:C,fullscreenPaneId:d,classNames:z,onRemove:W,onFullscreenChange:y,snapThreshold:x,onResizeStart:q,onResize:Z,onResizeEnd:$,minSplitPercentage:L,maxSplitPercentage:H,locked:m,setLocked:b,findPaneById:h,findPaneContainingTab:T,findTabById:I}),[a,f,g,v,O,C,d,z,W,y,x,q,Z,L,H,u,N,$,m,b,h,T,I]),ne=_t.useMemo(()=>({removePane:V,addPane:J,addTab:j,updateTabMetadata:ee,updatePaneLock:p,selectTab:R,mergeTab:k,removeTab:E,setFullscreenPaneId:y,setLocked:b,splitPane:S,updateSplitPercentage:l,moveTab:M}),[V,J,j,ee,p,R,k,E,y,b,S,l,M]),ie=_t.useMemo(()=>{let F=[];function te(re){re&&(re.type==="pane"?F.push(...re.tabs):(te(re.first),te(re.second)));}return te(a),F},[a]),ae=_t.useMemo(()=>({registerPortalTarget:P}),[P]);return jsxRuntime.jsx(Be.Provider,{value:ne,children:jsxRuntime.jsx(Ve.Provider,{value:se,children:jsxRuntime.jsxs(Ie.Provider,{value:ae,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",...oe,children:i}),f&&D&&r&&jsxRuntime.jsx(st,{activeId:f,render:F=>r(F,D),className:`${o.dragOverlay||""} ${f===g&&o.dismissPreview||""}`.trim()}),jsxRuntime.jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:ie.map(F=>jsxRuntime.jsx(it,{tabId:F,target:U[F]||null,renderWidget:s},F))})]})})})};function Ue({containerRef:e,isRow:t,direction:n,splitPercentage:s,resizerSize:r,snapThreshold:o,layout:i,currentNode:a,onLayoutChange:u,onResizeStart:d,onResizeEnd:y,parentLeft:m,parentTop:b,parentWidth:h,parentHeight:T}){let{onResizeStart:I,onResize:f,onResizeEnd:D,minSplitPercentage:g=5,maxSplitPercentage:C=95,locked:x=false}=le();return _t.useCallback(L=>{if(x)return;L.preventDefault();let H=e.current;if(!H)return;d&&d(),I&&I(a);let W=H.getBoundingClientRect(),q=L.clientX,Z=L.clientY,G=s,V=L.currentTarget,J=W.left+W.width*(m/100),j=W.top+W.height*(b/100),ee=W.width*(h/100),p=W.height*(T/100),k=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(S=>S!==V&&S.getAttribute("data-direction")===n).map(S=>{let l=S.getBoundingClientRect();return t?l.left+l.width/2:l.top+l.height/2}),E=G;Ne({cursor:t?"col-resize":"row-resize",resizerEl:V,onMove:S=>{let l=t?(S.clientX-q)/ee*100:(S.clientY-Z)/p*100,M=G+l,U=t?J+(ee-r)*(M/100)+r/2:j+(p-r)*(M/100)+r/2,P=1/0,v=null;for(let oe of k){let N=Math.abs(U-oe);N<o&&N<P&&(P=N,v=oe);}let _=M;v!==null&&(_=t?(v-r/2-J)/(ee-r)*100:(v-r/2-j)/(p-r)*100);let O=Math.max(g,Math.min(C,_));E=O;let K=ge(i,a,O);if(K){let{panes:oe,splitters:N}=ue(K),z=e.current;if(z){for(let $ of oe)z.style.setProperty(`--pane-left-${$.paneId}`,`${$.left}%`),z.style.setProperty(`--pane-top-${$.paneId}`,`${$.top}%`),z.style.setProperty(`--pane-width-${$.paneId}`,`${$.width}%`),z.style.setProperty(`--pane-height-${$.paneId}`,`${$.height}%`);for(let $ of N)z.style.setProperty(`--splitter-pos-${$.id}`,`${$.direction==="row"?$.left:$.top}%`);}}f&&f(a,O);},onEnd:()=>{let S=ge(i,a,E),l=e.current;if(l){let{panes:M,splitters:U}=ue(S);for(let P of M)l.style.removeProperty(`--pane-left-${P.paneId}`),l.style.removeProperty(`--pane-top-${P.paneId}`),l.style.removeProperty(`--pane-width-${P.paneId}`),l.style.removeProperty(`--pane-height-${P.paneId}`);for(let P of U)l.style.removeProperty(`--splitter-pos-${P.id}`);}u(S),y&&y(),D&&D(a,E);}});},[e,t,n,s,r,o,i,a,u,d,y,I,f,D,g,C,m,b,h,T])}var Jt=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:s})=>{let{layout:r,setLayout:o,classNames:i,locked:a}=le(),[u,d]=_t.useState(false),{currentNode:y,direction:m,left:b,top:h,width:T,height:I,parentLeft:f,parentTop:D,parentWidth:g,parentHeight:C}=e,x=m==="row",L=Ue({containerRef:s,isRow:x,direction:m,splitPercentage:y.splitPercentage,resizerSize:t,snapThreshold:n,layout:r,currentNode:y,onLayoutChange:o,onResizeStart:()=>d(true),onResizeEnd:()=>d(false),parentLeft:f,parentTop:D,parentWidth:g,parentHeight:C}),H=x?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${b}%) - ${t/2}px)`,top:`calc(${h}% + ${t/2}px)`,width:`${t}px`,height:`calc(${I}% - ${t}px)`,cursor:a?"default":"col-resize",pointerEvents:a?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`calc(${b}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${h}%) - ${t/2}px)`,width:`calc(${T}% - ${t}px)`,height:`${t}px`,cursor:a?"default":"row-resize",pointerEvents:a?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"};return jsxRuntime.jsx("div",{className:i.resizer||"","data-direction":m,"data-resizing":u||void 0,style:H,onPointerDown:L,role:"separator","aria-valuenow":y.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},Gt=_t__default.default.memo(({paneId:e,renderPane:t})=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane),Kt=({tree:e,resizerSize:t=4,snapThreshold:n})=>{let{layout:s,renderPane:r,activeId:o,dismissIntentId:i,setContainerRef:a,fullscreenPaneId:u,snapThreshold:d,locked:y,classNames:m}=le(),b=n!==void 0?n:d??8,h=e!==void 0?e:s,T=_t.useRef(null),{panes:I,splitters:f}=_t.useMemo(()=>h?ue(h):{panes:[],splitters:[]},[h]);if(!h)return null;let D=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[I.map(g=>{let C=u===g.paneId;return jsxRuntime.jsx("div",{style:{position:"absolute",left:C?"0%":`var(--pane-left-${g.paneId}, ${g.left}%)`,top:C?"0%":`var(--pane-top-${g.paneId}, ${g.top}%)`,width:C?"100%":`var(--pane-width-${g.paneId}, ${g.width}%)`,height:C?"100%":`var(--pane-height-${g.paneId}, ${g.height}%)`,overflow:"hidden",zIndex:C?20:1,display:u&&!C?"none":"block",padding:C?"0px":`${t/2}px`,boxSizing:"border-box"},children:jsxRuntime.jsx(Gt,{paneId:g.paneId,renderPane:r})},g.paneId)}),!u&&f.map(g=>jsxRuntime.jsx(Jt,{splitter:g,resizerSize:t,snapThreshold:b,containerRef:T},g.id))]});if(e===void 0){let g=o!==null&&o===i,C=L=>{a(L),T.current=L;},x=`${m.dashboard||""} ${g&&m.dashboardDismissActive||""} ${y&&m.dashboardLocked||""}`.trim();return jsxRuntime.jsx("div",{ref:C,className:x,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:D()})}return jsxRuntime.jsx("div",{ref:T,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:D()})};var ft="zeugma-height:",tn="default-pane";function nn(e){try{let t=localStorage.getItem(ft+e);if(t!==null){let n=Number(t);if(Number.isFinite(n)&&n>0)return n}}catch{}return null}function pt(e,t){try{localStorage.setItem(ft+e,String(Math.round(t)));}catch{}}var mt=({children:e,active:t=true,height:n,onHeightChange:s,minHeight:r=100,maxHeight:o=1/0,persist:i,localStorageKey:a,resizerHeight:u=6,className:d,resizerClassName:y})=>{let m=i?a||tn:null,b=()=>{let x=(m?nn(m):null)??n??400;return Ze(x,r,o)},[h,T]=_t.useState(b),I=_t.useRef(null),f=m?h:n??h,D=_t.useRef(n);_t.useEffect(()=>{if(n!==void 0&&n!==D.current){let x=Ze(n,r,o);T(x),m&&pt(m,x);}D.current=n;},[n,r,o,m]);let g=_t.useCallback(()=>o,[o]),C=_t.useCallback(x=>{x.preventDefault();let L=x.clientY,H=f,W=g(),q=x.currentTarget,Z=gt(I.current),G=Z?Z.scrollTop:0,V=L,J=null,j=(p,R)=>{let k=R-G,S=p-L+k,l=Ze(H+S,r,W);return I.current&&(I.current.style.height=`${l}px`),l},ee=()=>{if(!Z)return;let p=Z===document.documentElement||Z===document.body?{top:0,bottom:window.innerHeight}:Z.getBoundingClientRect(),R=40,k=10,E=0;V>p.bottom-R?E=Math.min(1,(V-(p.bottom-R))/R)*k:V<p.top+R&&(E=-Math.min(1,(p.top+R-V)/R)*k),E!==0&&(Z.scrollTop+=E,j(V,Z.scrollTop)),J=requestAnimationFrame(ee);};J=requestAnimationFrame(ee),Ne({cursor:"row-resize",resizerEl:q,onMove:p=>{V=p.clientY,Z&&j(V,Z.scrollTop);},onEnd:()=>{J!==null&&cancelAnimationFrame(J);let p=H;I.current&&(p=I.current.getBoundingClientRect().height),p=Ze(p,r,W),T(p),s&&s(p),m&&pt(m,p);}});},[f,r,g,s,m]);return t?jsxRuntime.jsxs("div",{ref:I,className:`zeugma-resizable-container ${d||""}`.trim(),style:{height:`${f}px`,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:[jsxRuntime.jsx("div",{style:{height:`calc(100% - ${u}px)`,overflow:"hidden"},children:e}),jsxRuntime.jsx("div",{className:`zeugma-resizable-handle ${y||""}`.trim(),style:{height:`${u}px`,cursor:"row-resize",position:"relative",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box",flexShrink:0},onPointerDown:C,role:"separator","aria-orientation":"horizontal","aria-valuenow":Math.round(f),"aria-valuemin":r,"aria-valuemax":o===1/0?void 0:o})]}):jsxRuntime.jsx("div",{className:`zeugma-resizable-container disabled ${d||""}`.trim(),style:{height:"100%",position:"relative",overflow:"hidden",boxSizing:"border-box"},children:jsxRuntime.jsx("div",{style:{height:"100%",overflow:"hidden"},children:e})})};function Ze(e,t,n){return Math.max(t,Math.min(n,e))}function gt(e){if(typeof window>"u"||!e)return null;let t=e.parentElement;if(!t)return document.documentElement;let s=window.getComputedStyle(t).overflowY;return s==="auto"||s==="scroll"?t:gt(t)}var He=_t.createContext(null);var pn={top:{position:"absolute",top:0,left:"25%",width:"50%",height:"25%",zIndex:20,pointerEvents:"auto"},bottom:{position:"absolute",bottom:0,left:"25%",width:"50%",height:"25%",zIndex:20,pointerEvents:"auto"},left:{position:"absolute",top:"25%",left:0,width:"25%",height:"50%",zIndex:20,pointerEvents:"auto"},right:{position:"absolute",top:"25%",right:0,width:"25%",height:"50%",zIndex:20,pointerEvents:"auto"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:20,pointerEvents:"auto",cursor:"not-allowed"}},fn={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"}},bt=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:s,isOver:r}=core.useDroppable({id:e});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:s,style:pn[t]}),r&&jsxRuntime.jsx("div",{className:n,style:fn[t]})]})},mn=({id:e,children:t,style:n,locked:s=false})=>{let r=_t.useRef(null),{layout:o,activeId:i,classNames:a,fullscreenPaneId:u,onFullscreenChange:d,locked:y}=le(),{removePane:m,updateTabMetadata:b,selectTab:h,removeTab:T}=Me(),I=_t.useContext(Ie);if(!I)throw new Error("Pane must be used within a Zeugma provider");let{registerPortalTarget:f}=I,D=_t.useMemo(()=>Q(o,e),[o,e]),g=D?.id??e,C=D?.tabs??[e],x=D?.activeTabId??e,L=D?.tabsMetadata,H=L?.[e],W=D?.locked??false,q=s||W,Z=y||q,G=y||q,V=i!==null&&i!==e&&(!C.includes(i)||C.length>1)&&!G,{attributes:J,listeners:j,setNodeRef:ee}=core.useDraggable({id:e,disabled:Z}),p=i!==null&&C.includes(i),R=u===e,k=_t.useCallback(()=>jsxRuntime.jsx("div",{ref:r,id:`zeugma-tab-target-${x}`,className:"zeugma-tab-content-wrapper",style:{height:"100%",width:"100%"}}),[x]);_t.useEffect(()=>{let M=r.current;return f(x,M),()=>{f(x,null);}},[x,f]);let E=_t.useMemo(()=>({isDragging:p,isFullscreen:R,toggleFullscreen:()=>d?.(R?null:e),remove:()=>{R&&d?.(null),m(g);},metadata:H,updateMetadata:M=>{b(e,M);},locked:Z,tabs:C,activeTabId:x,selectTab:M=>h(g,M),removeTab:M=>{R&&M===x&&d?.(null),T(M);},tabsMetadata:L,updateTabMetadata:(M,U)=>{b(M,U);},renderActiveTab:k}),[p,R,d,e,T,H,b,Z,C,x,h,g,L,k]),S=_t.useMemo(()=>Z?{disabled:true}:{...j,...J},[j,J,Z]),l=`${a.pane||""} ${q&&a.paneLocked||""}`.trim();return jsxRuntime.jsx(He.Provider,{value:S,children:jsxRuntime.jsxs("div",{ref:ee,className:l,style:{position:"relative",width:"100%",height:"100%",...n},children:[t(E),V&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:["top","bottom","left","right"].map(M=>jsxRuntime.jsx(bt,{id:`drop-${M}-${e}`,position:M,activeClassName:a.dropPreview},M))}),i!==null&&i!==e&&G&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsxRuntime.jsx(bt,{id:`drop-locked-${e}`,position:"full",activeClassName:a.lockedPreview||""})})]})})};var vn=({children:e,className:t,style:n})=>{let s=_t.useContext(He);if(!s)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:r,...o}=s;return jsxRuntime.jsx("div",{className:t,style:{cursor:r?"default":"grab",userSelect:r?"auto":"none",touchAction:r?"auto":"none",...n},...r?{}:o,children:e})};var ht=({id:e,locked:t=false,children:n,className:s,style:r})=>{let{locked:o,classNames:i={},overTabId:a,overTabPosition:u}=le(),d=t||o,{attributes:y,listeners:m,setNodeRef:b,isDragging:h}=core.useDraggable({id:`tab-header-${e}`,disabled:d}),{setNodeRef:T,isOver:I}=core.useDroppable({id:`tab-drop-${e}`,disabled:d}),f=C=>{b(C),T(C);},D=I&&a===e,g=D?u:null;return jsxRuntime.jsxs("div",{ref:f,className:s,style:{display:"inline-flex",position:"relative",cursor:d?"default":"grab",...r},...d?{}:m,...d?{}:y,children:[n({isDragging:h,isOver:D}),D&&g&&jsxRuntime.jsx("div",{className:i.tabDropPreview||"",style:{position:"absolute",top:0,bottom:0,width:"2px",backgroundColor:"#6366f1",left:g==="before"?0:void 0,right:g==="after"?0:void 0,pointerEvents:"none",zIndex:10}})]})};var Rn=({tabs:e,activeTabId:t,locked:n=false,tabsMetadata:s,selectTab:r,removeTab:o,children:i,classNames:a,styles:u})=>jsxRuntime.jsx("div",{className:a?.container,style:{display:"flex",alignItems:"center",height:"100%",...u?.container},children:e.map(d=>{let y=s?.[d],m=a?.tab,b=typeof m=="function"?m(d):m,h=u?.tab,T=typeof h=="function"?h(d):h;return jsxRuntime.jsx(ht,{id:d,locked:n,className:b,style:T,children:({isDragging:I,isOver:f})=>i({tabId:d,activeTabId:t,isDragging:I,isOver:f,metadata:y,selectTab:r,removeTab:o})},d)})});exports.DEFAULT_DRAG_ACTIVATION_DISTANCE=St;exports.DEFAULT_RESIZER_SIZE=Cn;exports.DEFAULT_SNAP_THRESHOLD=Rt;exports.DragHandle=vn;exports.Pane=mn;exports.PaneTree=Kt;exports.PortalRegistryContext=Ie;exports.ResizableContainer=mt;exports.Tabs=Rn;exports.Zeugma=Bt;exports.ZeugmaActionsContext=Be;exports.ZeugmaStateContext=Ve;exports.createDragSession=Ne;exports.safeJsonStringify=xe;exports.useResizer=Ue;exports.useZeugma=Dt;exports.useZeugmaActions=Me;exports.useZeugmaContext=Ct;exports.useZeugmaState=le;//# sourceMappingURL=index.cjs.map
7
7
  //# sourceMappingURL=index.cjs.map