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