react-zeugma 6.6.1 → 6.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +5 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import hn,{createContext,useState,useRef,useEffect,useCallback,useMemo,useContext}from'react';import {useDraggable,DndContext,useDroppable,useSensors,useSensor,pointerWithin,closestCenter,PointerSensor,TouchSensor}from'@dnd-kit/core';import {jsx,Fragment,jsxs}from'react/jsx-runtime';import {createPortal}from'react-dom';function dt({cursor:e,resizerEl:t,onMove:n,onEnd:r}){document.body.classList.add("zeugma-resizing");let o=document.createElement("style");o.id="zeugma-global-cursor-style",o.textContent=`
|
|
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=createContext(void 0),je=createContext(void 0),be=createContext(void 0),et=createContext(void 0),oe=()=>{let e=useContext(Qe);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},ze=()=>{let e=useContext(je);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e},Ae=()=>{let e=useContext(et);if(!e)throw new Error("useZeugmaDrag must be used within a Zeugma provider");return e};function mt(e){let t=useRef(null);return useEffect(()=>{if(!e){t.current=null;return}let n=o=>{t.current={x:o.clientX,y:o.clientY};},r=o=>{let 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){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]=useState({}),n=useRef({}),r=useRef(null),o=useRef({}),a=useRef(null),i=useRef(true);useEffect(()=>(i.current=true,()=>{i.current=false;}),[]);let c=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=useCallback((f,m)=>{n.current[f]=m;},[]),u=useCallback(f=>{r.current=f;},[]),p=useCallback((f,m)=>{o.current[f]=m;},[]);return {portalTargets:e,registerPortalTarget: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 useMemo(()=>an(e,t),[e,t])}function Tt(e){let{activeId:t,findPaneContainingTab:n,onDragStart:r,onDragEnd:o}=e,[a,i]=useState(null),[c,l]=useState(null),[u,p]=useState(null),f=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=useCallback((b,y,T)=>{p(null),o&&o(b,y,T);},[o]);return 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=useContext(be)?.registerRenderPane;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]=useState(()=>n!==void 0?n:t??null),[u,p]=useState(()=>Ne(n!==void 0?n:null)),[f,m]=useState(o||null),[b,y]=useState(i),[T,E]=useState(null),[z,H]=useState(null),[h,P]=useState(null),[w,M]=useState(null),L=useRef(null),F=useCallback(s=>{L.current=s;},[]),A=useRef(c);A.current=c;let Z=useRef(T);Z.current=T;let U=useRef(r);U.current=r;let G=useRef(a);G.current=a;let K=useCallback(s=>{m(s),G.current?.(s);},[]);if(useEffect(()=>{y(i);},[i]),useEffect(()=>{o!==void 0&&m(o);},[o]),n!==void 0){let s=Ne(n);s!==u&&(p(s),l(n));}let R=useCallback(s=>(...d)=>{let $=A.current,k=s($,...d);Ne($)!==Ne(k)&&(A.current=k,l(k),U.current?.(k));},[]),ie=useCallback(R((s,d)=>typeof d=="function"?d(s):d),[R]),O=useCallback(s=>{l(d=>{let $=typeof s=="function"?s(d):s;return A.current=$,$});},[]),B=useCallback(s=>{m(null),G.current?.(null),E(null),H(null),P(null),M(null),ie(s);},[ie]),S=useCallback(R((s,d)=>fe(s,d)),[R]),C=useCallback(R((s,d,$,k)=>{let Y=ue(s,d)??s;return Rt(Y,$,d,k)}),[R]),N=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=useCallback(R((s,d,$)=>Te(s,d,$)),[R]),Q=useCallback(R((s,d,$)=>Be(s,d,$)),[R]),D=useCallback(R((s,d,$)=>{let k=ee(s,d)??q(s,d);return k?Oe(s,k.id,$):s}),[R]),I=useCallback(R((s,d,$)=>{let k=ee(s,d)??q(s,d);return k?De(s,k.id,$):s}),[R]),se=useCallback(R((s,d,$)=>{let k=ee(s,$)??q(s,$);return k?xt(s,d,k.id):s}),[R]),J=useCallback(R((s,d,$,k)=>Fe(s,d,$,k)),[R]),X=useCallback(R((s,d)=>ue(s,d)),[R]),_=useCallback(s=>{let d=ee(A.current,s);return !d&&Z.current&&(d=ee(Z.current,s)),d},[]),j=useCallback(s=>{let d=q(A.current,s);return !d&&Z.current&&(d=q(Z.current,s)),d},[]),v=useCallback(s=>{let d=tt(A.current,s);return !d&&Z.current&&(d=tt(Z.current,s)),d},[]),x=useCallback(s=>{let d=nt(A.current,s);return !d&&Z.current&&(d=nt(Z.current,s)),d},[]),re=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 PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},We=class extends TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};var Ct=e=>{let n=e.active.id.toString().startsWith("tab-header-"),r=pointerWithin(e),o=n?r:r.filter(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 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=useRef(null),F=mt(i),[A,Z]=useState(false);return bt(A),{sensors:useSensors(useSensor(Ve,{activationConstraint:{distance:y}}),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=useRef(null);return 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)},[]),jsx("div",{ref:r,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var It=Pn.memo(({tabDetails:e,target:t,renderWidget:n})=>{let{id:r}=e,[o,a]=useState(false),i=useRef(null);if(useEffect(()=>{a(true);},[]),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]),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: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 jsx(Fragment,{children:o({type:t,id:e,isDismissing:e===n})});if(t==="pane"){let u=a.current||i;if(u)return 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 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 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 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 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]=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 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.memo(({paneId:e,renderPane:t})=>jsx(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=useRef(null),{panes:z,splitters:H}=useMemo(()=>T?pe(T):{panes:[],splitters:[]},[T]);if(!T&&t!==void 0)return null;let h=()=>jsxs(Fragment,{children:[z.map(P=>{let w=l===P.paneId;return 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:jsx(Lt,{paneId:P.paneId,renderPane:e})},P.paneId)}),!l&&H.map(P=>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 jsxs("div",{ref:w,className:M,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[h(),a!==null&&!p&&jsx($t,{activeClassName:f.rootDropPreview??f.dropPreview})]})}return 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=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=useCallback((me,Ge)=>{H&&H(me,Ge);},[H]),Qt=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=useMemo(()=>({overTabId:ut,overTabPosition:dt}),[ut,dt]),en=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=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),jsx(je.Provider,{value:en,children:jsx(Qe.Provider,{value:Qt,children:jsx(et.Provider,{value:jt,children:jsxs(be.Provider,{value:nn,children:[jsx(DndContext,{id:"zeugma-dnd-context",...Kt,children:n}),B&&C&&jsx(Nt,{activeId:B,render:me=>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()}),jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:tn.map(me=>{let Ge=k[me],ft=R(me);return ft?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 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 jsx(kn,{...e,children:t!==void 0?t: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}=useDroppable({id:e}),i={position:"absolute",pointerEvents:"none",zIndex:101,boxSizing:"border-box",...On[n][t]};return jsxs(Fragment,{children:[jsx("div",{ref:o,style:Bn[n][t]}),a&&jsx("div",{className:r,style:i})]})},$t=({activeClassName:e})=>jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:99,pointerEvents:"none"},children:[{id:"drop-root-1/4-top",fraction:"1/4",edge:"top"},{id:"drop-root-1/3-top",fraction:"1/3",edge:"top"},{id:"drop-root-1/4-bottom",fraction:"1/4",edge:"bottom"},{id:"drop-root-1/3-bottom",fraction:"1/3",edge:"bottom"},{id:"drop-root-1/4-left",fraction:"1/4",edge:"left"},{id:"drop-root-1/3-left",fraction:"1/3",edge:"left"},{id:"drop-root-1/4-right",fraction:"1/4",edge:"right"},{id:"drop-root-1/3-right",fraction:"1/3",edge:"right"}].map(n=>jsx(Fn,{id:n.id,fraction:n.fraction,edge:n.edge,activeClassName:e},n.id))});var Ye=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}=useDroppable({id:e});return jsxs(Fragment,{children:[jsx("div",{ref:r,style:Yn[t]}),o&&jsx("div",{className:n,style:qn[t]})]})};var At=({children:e,className:t,style:n})=>{let r=useContext(Ye);if(!r)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:o,...a}=r;return jsx("div",{className:t,style:{cursor:o?"default":"grab",userSelect:o?"auto":"none",touchAction:o?"auto":"none",...n},...o?{}:a,children:e})};var oo=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=useContext(be);useEffect(()=>(u?.registerTabHeader&&u.registerTabHeader(e,n),()=>{u?.registerTabHeader&&u.activeIdRef?.current!==e&&u.registerTabHeader(e,()=>null);}),[e,n,u]);let p=useContext(lt),f=t||a||(p?.locked??false),{attributes:m,listeners:b,setNodeRef:y,isDragging:T}=useDraggable({id:`tab-header-${e}`,disabled:f}),{setNodeRef:E,isOver:z}=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?jsx("div",{className:i.tabSeparator}):null,A=p?p.activeTabId===e:false,Z=p?.tabsMetadata?.[e],U=useCallback(()=>{p?.selectTab(e);},[p,e]),G=useCallback(()=>{p?.removeTab(e);},[p,e]),K=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 jsx(oo.Provider,{value:K,children: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=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=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=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 jsx(lt.Provider,{value:P,children: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 jsxs(Pn.Fragment,{children:[U&&E.tabDropPreview&&jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsx("div",{className:E.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:L===0?"none":"translateX(-50%)"}})}),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&&jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children: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})=>jsx("div",{className:e,style:t,children:n});var qe=createContext(void 0),Xt=()=>{let e=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=useRef(null),i=useContext(be);if(!i)throw new Error("PaneContent must be used within a Zeugma provider");let{registerPortalTarget:c,registerRenderCallback:l}=i,u=useMemo(()=>typeof e=="function"?e:()=>e,[e]);return l(r,u),useEffect(()=>{let p=a.current;return c(r,p),()=>{c(r,null);}},[r,c]),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=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}=useDraggable({id:e,disabled:L}),K=a!==null&&z.includes(a),R=c===e,ie=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=useMemo(()=>L?{disabled:true}:{...U,...Z},[U,Z,L]),B=`${i.pane||""} ${M&&i.paneLocked||""}`.trim();return jsx(qe.Provider,{value:{id:e,...ie},children:jsx(Ye.Provider,{value:O,children:jsxs("div",{ref:G,id:e,className:B,style:{position:"relative",width:"100%",height:"100%",...n},children:[t,A&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:["top","bottom","left","right"].map(S=>jsx(st,{id:`drop-${S}-${e}`,position:S,activeClassName:i.dropPreview},S))}),a!==null&&a!==e&&F&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children: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;export{we as Pane,it as PaneTree,zn as Zeugma,Xt as usePaneContext,at as useResizer,ln as useZeugma,cn as useZeugmaContext};//# sourceMappingURL=index.js.map
|
|
6
|
+
.zeugma-resizing *:not([role="separator"]) {
|
|
7
|
+
pointer-events: none !important;
|
|
8
|
+
}
|
|
9
|
+
`,document.head.appendChild(o),t.setAttribute("data-resizing","true");let a=i=>{n(i);},s=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let i=document.getElementById("zeugma-global-cursor-style");i&&i.remove(),document.removeEventListener("pointermove",a),document.removeEventListener("pointerup",s),r();};document.addEventListener("pointermove",a),document.addEventListener("pointerup",s);}function we(e){try{return JSON.stringify(e)}catch{return ""}}var Ge=createContext(void 0),Ke=createContext(void 0),me=createContext(void 0),Qe=createContext(void 0),oe=()=>{let e=useContext(Ge);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},ke=()=>{let e=useContext(Ke);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e},ze=()=>{let e=useContext(Qe);if(!e)throw new Error("useZeugmaDrag must be used within a Zeugma provider");return e};function ut(e){let t=useRef(null);return useEffect(()=>{if(!e){t.current=null;return}let n=o=>{t.current={x:o.clientX,y:o.clientY};},r=o=>{let 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 pt(e){useEffect(()=>(e?document.body.style.setProperty("cursor","not-allowed","important"):document.body.style.removeProperty("cursor"),()=>{document.body.style.removeProperty("cursor");}),[e]);}function ft(){let[e,t]=useState({}),n=useRef({}),r=useRef(null),o=useRef({}),a=useRef(null),s=useRef(true);useEffect(()=>(s.current=true,()=>{s.current=false;}),[]);let i=useCallback((f,m)=>{s.current&&t(b=>{if(!m){if(!b[f])return b;let S={...b};return delete S[f],S}return b[f]===m?b:{...b,[f]:m}});},[]),l=useCallback((f,m)=>{n.current[f]=m;},[]),d=useCallback(f=>{r.current=f;},[]),p=useCallback((f,m)=>{o.current[f]=m;},[]);return {portalTargets:e,registerPortalTarget:i,registerRenderCallback:l,renderCallbacksRef:n,registerRenderPane:d,renderPaneRef:r,registerTabHeader:p,tabHeadersRef:o,activeIdRef:a}}function rn(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 gt(e){return useMemo(()=>rn(e),[e])}function mt(e){let{onDragStart:t,onDragEnd:n}=e,[r,o]=useState(null),[a,s]=useState(null),i=useCallback(d=>{t&&t(d);},[t]),l=useCallback((d,p,f)=>{n&&n(d,p,f);},[n]);return {overTabId:r,setOverTabId:o,overTabPosition:a,setOverTabPosition:s,handleDragStartInternal:i,handleDragEndInternal:l}}function bt(e){let n=useContext(me)?.registerRenderPane;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 de(e,t){if(e===null)return null;if(e.type==="pane"){if(e.tabs.includes(t)){let o=e.tabs.filter(i=>i!==t);if(o.length===0)return null;let a=e.activeTabId;e.activeTabId===t&&(a=o[0]);let s={...e.tabsMetadata};return delete s[t],{...e,tabs:o,activeTabId:a,tabsMetadata:Object.keys(s).length>0?s:void 0}}return e}let n=de(e.first,t),r=de(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: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,s=r==="left"||r==="top";return {type:"split",direction:n,first:s?a:e,second:s?e:a,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 an(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 vt(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?re(e,t):null;if(o&&o.type==="pane"){let i=function(l){if(l.type==="pane"&&l.id===t){let d=[...l.tabs];d.includes(n)||d.push(n);let p=l.tabsMetadata;return r&&(p={...l.tabsMetadata,[n]:r}),{...l,tabs:d,activeTabId:n,tabsMetadata:p}}return l.type==="split"?{...l,first:i(l.first),second:i(l.second)}:l};return i(e)}let a={type:"pane",id:ce(),tabs:[n],activeTabId:n,tabsMetadata:r?{[n]:r}:void 0};return an(e,a)}function he(e,t,n){return e===null?null:e===t?{...e,splitPercentage:n}:e.type==="split"?{...e,first:he(e.first,t,n)||e.first,second:he(e.second,t,n)||e.second}:e}function re(e,t){return e===null?null:e.type==="pane"?e.id===t?e:null:e.type==="split"?re(e.first,t)??re(e.second,t):null}function _(e,t){return e===null?null:e.type==="pane"?e.tabs.includes(t)?e:null:e.type==="split"?_(e.first,t)??_(e.second,t):null}function ht(e,t){let n=_(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 Tt(e,t){return _(e,t)?.tabsMetadata?.[t]}function Pt(e,t){let n=re(e,t);return n?.tabsMetadata?.[n.activeTabId]}function Ae(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),s={...r};return a===void 0?delete s[t]:s[t]=a,{...e,tabsMetadata:Object.keys(s).length>0?s:void 0}}return e}return e.type==="split"?{...e,first:Ae(e.first,t,n)??e.first,second:Ae(e.second,t,n)??e.second}:e}function He(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:He(e.first,t,n)??e.first,second:He(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 Rt(e,t,n){if(e===null)return null;let o=_(e,t)?.tabsMetadata?.[t],a=de(e,t);if(a===null)return {type:"pane",id:ce(),tabs:[t],activeTabId:t,tabsMetadata:o?{[t]:o}:void 0};function s(i){if(i.type==="pane"){if(i.id===n){let l=[...i.tabs];l.includes(t)||l.push(t);let d={...i.tabsMetadata};return o&&(d[t]=o),{...i,tabs:l,activeTabId:t,tabsMetadata:Object.keys(d).length>0?d:void 0}}return i}return i.type==="split"?{...i,first:s(i.first),second:s(i.second)}:i}return s(a)}function Oe(e,t,n,r="before"){if(e===null)return null;let a=_(e,t)?.tabsMetadata?.[t],s=de(e,t);if(s===null)return {type:"pane",id:ce(),tabs:[t],activeTabId:t,tabsMetadata:a?{[t]:a}:void 0};function i(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:i(l.first),second:i(l.second)}:l}return i(s)}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:s,splitPercentage:i,first:l,second:d}=e,f={id:`splitter-${a}-${s}`,currentNode:e,direction:s,left:s==="row"?t+r*(i/100):t,top:s==="column"?n+o*(i/100):n,width:s==="row"?0:r,height:s==="column"?0:o,parentLeft:t,parentTop:n,parentWidth:r,parentHeight:o},m={panes:[],splitters:[]},b={panes:[],splitters:[]};if(s==="row"){let S=r*(i/100);m=pe(l,t,n,S,o,`${a}-L`),b=pe(d,t+S,n,r-S,o,`${a}-R`);}else {let S=o*(i/100);m=pe(l,t,n,r,S,`${a}-T`),b=pe(d,t,n+S,r,o-S,`${a}-B`);}return {panes:[...m.panes,...b.panes],splitters:[f,...m.splitters,...b.splitters]}}function xt(e,t,n,r){if(!(t==="tab"&&n&&e.includes(n))||!r)return -1;let s=e.indexOf(n);return r==="before"?s:s+1}function sn(e){let{initialLayout:t,layout:n,onChange:r,fullscreenPaneId:o,onFullscreenChange:a,locked:s=false}=e,[i,l]=useState(()=>n!==void 0?n:t??null),[d,p]=useState(()=>n!==void 0?n:t??null),[f,m]=useState(()=>we(n!==void 0?n:null)),[b,S]=useState(o||null),[N,Z]=useState(s),[v,z]=useState(null),[H,x]=useState(null),[R,P]=useState(null),M=useRef(null),j=useCallback(c=>{M.current=c;},[]),A=useRef(i);A.current=i;let W=useRef(r);W.current=r;let Y=useRef(a);Y.current=a;let G=useCallback(c=>{S(c),Y.current?.(c);},[]);if(useEffect(()=>{Z(s);},[s]),useEffect(()=>{o!==void 0&&S(o);},[o]),n!==void 0){let c=we(n);c!==f&&(m(c),l(n),p(n));}let y=useCallback(c=>(...g)=>{let $=A.current,L=c($,...g);we($)!==we(L)&&(A.current=L,l(L),p(L),W.current?.(L));},[]),U=useCallback(y((c,g)=>typeof g=="function"?g(c):g),[y]),I=useCallback(c=>{p(g=>typeof c=="function"?c(g):c);},[]),K=useCallback(c=>{S(null),Y.current?.(null),z(null),x(null),P(null),U(c);},[U]),B=useCallback(y((c,g)=>fe(c,g)),[y]),T=useCallback(y((c,g,$,L)=>{let X=de(c,g)??c;return vt(X,$,g,L)}),[y]),E=useCallback(y((c,g,$,L,X)=>{let V=re(c,g)??_(c,g);if(!V)return c;let le=re(c,X)??_(c,X)??{type:"pane",id:X,tabs:[X],activeTabId:X},te=fe(c,X);return xe(te,V.id,$,L,le)}),[y]),u=useCallback(y((c,g,$)=>he(c,g,$)),[y]),q=useCallback(y((c,g,$)=>Ae(c,g,$)),[y]),D=useCallback(y((c,g,$)=>{let L=re(c,g)??_(c,g);return L?He(c,L.id,$):c}),[y]),C=useCallback(y((c,g,$)=>{let L=re(c,g)??_(c,g);return L?ye(c,L.id,$):c}),[y]),se=useCallback(y((c,g,$)=>{let L=re(c,$)??_(c,$);return L?Rt(c,g,L.id):c}),[y]),J=useCallback(y((c,g,$,L)=>Oe(c,g,$,L)),[y]),F=useCallback(y((c,g)=>de(c,g)),[y]),Q=useCallback(c=>re(A.current,c),[]),ee=useCallback(c=>_(A.current,c),[]),h=useCallback(c=>ht(A.current,c),[]),w=useCallback(c=>Tt(A.current,c),[]),k=useCallback(c=>Pt(A.current,c),[]);return {layout:i,setLayout:K,_internalSetLayout:I,renderingLayout:d,fullscreenPaneId:b,setFullscreenPaneId:G,locked:N,setLocked:Z,activeId:v,setActiveId:z,activeType:H,setActiveType:x,dismissIntentId:R,setDismissIntentId:P,containerRef:M,setContainerRef:j,removePane:B,addTab:T,updateMetadata:q,updatePaneLock:D,selectTab:C,mergeTab:se,moveTab:J,removeTab:F,splitPane:E,updateSplitPercentage:u,findPaneById:Q,findPaneContainingTab:ee,findTabById:h,getTabMetadata:w,getActiveTabMetadata:k}}var ln=()=>{let e=oe(),t=ke();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 Fe=class extends PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},Ve=class extends TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};var Dt=e=>{let n=e.active.id.toString().startsWith("tab-header-"),r=pointerWithin(e),o=n?r:r.filter(a=>!a.id.toString().startsWith("tab-drop-"));if(o.length>0)return [...o].sort((s,i)=>{let l=s.id.toString(),d=i.id.toString();if(n){let m=l.startsWith("tab-drop-"),b=d.startsWith("tab-drop-");if(m&&!b)return -1;if(!m&&b)return 1}let p=l.startsWith("drop-root-"),f=d.startsWith("drop-root-");return p&&!f?-1:!p&&f?1:0});if(n){let a=e.droppableContainers.filter(s=>s.id.toString().startsWith("tab-drop-"));return closestCenter({...e,droppableContainers:a})}return []};function We(e){if(e instanceof MouseEvent||e instanceof PointerEvent)return {x:e.clientX,y:e.clientY};if(typeof TouchEvent<"u"&&e instanceof TouchEvent){let t=e.touches[0]||e.changedTouches[0];if(t)return {x:t.clientX,y:t.clientY}}return null}function wt(e){let{layout:t,_internalSetLayout:n,setLayout:r,activeId:o,setActiveId:a,setActiveType:s,dismissIntentId:i,setDismissIntentId:l,setOverTabId:d,setOverTabPosition:p,containerRef:f,dragActivationDistance:m,enableDragToDismiss:b,dismissThreshold:S,onRemove:N,onDragStart:Z,onDragEnd:v,onDismissIntentChange:z,removeTab:H,removePane:x}=e,R=useRef(null),P=ut(o),M=useRef(null),[j,A]=useState(false);return pt(j),{sensors:useSensors(useSensor(Fe,{activationConstraint:{distance:m}}),useSensor(Ve,{activationConstraint:{delay:250,tolerance:5}})),collisionDetection:Dt,onDragStart:I=>{let K=I.active.id.toString(),B=K.startsWith("tab-header-"),T=B?K.substring(11):K;a(T),s(B?"tab":"pane"),d(null),p(null);let E=I.activatorEvent;P.current=We(E),b&&f.current?R.current=f.current.getBoundingClientRect():R.current=null;let u=t;if(B){let D=_(t,T);D&&(u=ye(t,D.id,T)||t);}M.current=u;let q=B?de(u,T):fe(u,T);n(q),Z&&Z(T);},onDragMove:I=>{let{over:K}=I,B=K?.id.toString()||"",T=B.startsWith("drop-locked-");A(h=>h===T?h:T);let E=I.active.id.toString(),u=E.startsWith("tab-header-"),q=u?E.substring(11):E,D=B.match(/^tab-drop-(.+)$/);if(D&&K&&u){let[,h]=D;if(q!==h){let w="before",k=K.rect,ae=I.activatorEvent,c=null;if(P.current)c=P.current.x;else {let g=We(ae);g&&(c=g.x+I.delta.x);}if(c!==null){let g=k.left+k.width/2;c>g&&(w="after");}d(g=>g===h?g:h),p(g=>g===w?g:w);}else d(w=>w===null?w:null),p(w=>w===null?w:null);}else d(h=>h===null?h:null),p(h=>h===null?h:null);if(!b)return;let C=R.current;if(!C){i!==null&&(l(null),z?.(null));return}let se=I.activatorEvent,J=null,F=null;if(P.current)J=P.current.x,F=P.current.y;else {let h=We(se);h&&(J=h.x+I.delta.x,F=h.y+I.delta.y);}let Q=0;if(J!==null&&F!==null){let h=0,w=0;J<C.left?h=C.left-J:J>C.right&&(h=J-C.right),F<C.top?w=C.top-F:F>C.bottom&&(w=F-C.bottom),Q=Math.sqrt(h*h+w*w);}else {let h=I.active.rect.current.translated;if(h){let w=h.left+h.width/2,k=h.top+h.height/2,ae=0,c=0;w<C.left?ae=C.left-w:w>C.right&&(ae=w-C.right),k<C.top?c=C.top-k:k>C.bottom&&(c=k-C.bottom),Q=Math.sqrt(ae*ae+c*c);}}Q>S?i!==q&&(l(q),z?.(q)):i!==null&&(l(null),z?.(null));},onDragEnd:I=>{a(null),s(null),A(false),d(null),p(null);let{active:K,over:B}=I,T=K.id.toString(),E=T.startsWith("tab-header-"),u=E?T.substring(11):T,q=b&&i===u;l(null),z?.(null),R.current=null;let D=M.current||t;if(M.current=null,q){N?N(u):E?H(u):x(u),v&&v(u,null,null);return}if(!B){n(D),v&&v(u,null,null);return}let C=B.id.toString();if(C.startsWith("drop-locked-")){n(D),v&&v(u,null,null);return}let se=C.match(/^tab-drop-(.+)$/);if(se){if(!E){n(D),v&&v(u,null,null);return}let[,L]=se;if(u!==L){let X="before",V=B.rect,le=I.activatorEvent,te=null;if(P.current)te=P.current.x;else {let ne=We(le);ne&&(te=ne.x+I.delta.x);}if(te!==null){let ne=V.left+V.width/2;te>ne&&(X="after");}let ge=Oe(D,u,L,X);r(ge),v&&v(u,L,{type:"move",position:"center"});}else n(D),v&&v(u,null,null);return}let J=C.match(/^drop-root-(1\/4|1\/3)-(top|bottom|left|right|start|end)$/);if(J){let[,L,X]=J,V=X;V==="start"&&(V="left"),V==="end"&&(V="right");let le=E?de(D,u):fe(D,u),te;if(E){let ne=_(D,u)?.tabsMetadata?.[u];te={type:"pane",id:ce(),tabs:[u],activeTabId:u,tabsMetadata:ne?{[u]:ne}:void 0};}else te=re(D,u)??{type:"pane",id:ce(),tabs:[u],activeTabId:u};if(le===null)r(te);else {let ge=V==="left"||V==="right",ne=V==="left"||V==="top",ve=50;L==="1/4"?ve=ne?25:75:L==="1/3"&&(ve=ne?100/3:200/3),r({type:"split",direction:ge?"row":"column",first:ne?te:le,second:ne?le:te,splitPercentage:ve});}v&&v(u,"root",{type:"split",direction:V==="left"||V==="right"?"row":"column",position:V});return}let F=C.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!F){n(D),v&&v(u,null,null);return}let[,Q,ee]=F,h=E?_(D,u):re(D,u),w=h&&h.id===ee,k=h&&h.tabs.length===1;if(u===ee||w&&k){n(D),v&&v(u,null,null);return}let ae=Q==="left"||Q==="right"?"row":"column",c;if(E){let X=_(D,u)?.tabsMetadata?.[u];c={type:"pane",id:ce(),tabs:[u],activeTabId:u,tabsMetadata:X?{[u]:X}:void 0};}else c=re(D,u)??{type:"pane",id:ce(),tabs:[u],activeTabId:u};let g=E?de(D,u):fe(D,u),$=xe(g,ee,ae,Q,c);r($),v&&v(u,ee,{type:"split",direction:ae,position:Q});},onDragCancel:()=>{a(null),s(null),A(false),d(null),p(null),l(null),z?.(null),R.current=null;let I=M.current||t;M.current=null,n(I),I!==t&&r(I);}}}var Nt=({activeId:e,render:t,className:n})=>{let r=useRef(null);return 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)},[]),jsx("div",{ref:r,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var It=hn.memo(({tabDetails:e,target:t,renderWidget:n})=>{let{id:r}=e,[o,a]=useState(false),s=useRef(null);if(useEffect(()=>{a(true);},[]),useEffect(()=>{if(!o||!s.current)return;let l=s.current;if(t)t.appendChild(l);else {let d=document.getElementById("zeugma-hidden-portal-container");d||(d=document.createElement("div"),d.id="zeugma-hidden-portal-container",d.style.display="none",document.body.appendChild(d)),d.appendChild(l);}},[t,o]),useEffect(()=>()=>{s.current&&s.current.remove();},[]),!o)return null;s.current||(s.current=document.createElement("div"),s.current.className=`zeugma-portal-wrapper-${r}`,s.current.style.width="100%",s.current.style.height="100%");let i=s.current;return !i||!n?null:createPortal(n(e),i)},(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,renderDragOverlay:r,renderPaneRef:o,renderPane:a,tabHeadersRef:s,classNames:i})=>{if(r)return jsx(Fragment,{children:r({type:t,id:e,isDismissing:e===n})});if(t==="pane"){let l=o.current||a;if(l)return jsx("div",{className:i.paneDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:l(e)})}else if(t==="tab"){let l=o.current||a;if(l)return jsx("div",{className:i.tabDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:l(e)});let d=s.current[e];if(d){let p=i.tab?typeof i.tab=="function"?i.tab(e):i.tab:"";return jsx("div",{className:`${i.tabDragPreview||""} ${p}`.trim(),style:{display:"inline-flex",position:"relative",pointerEvents:"none",overflow:"hidden",width:"420px",height:"260px"},children:d({isDragging:true,isOver:false})})}}return jsx("div",{style:{pointerEvents:"none",overflow:"hidden",width:"100%",height:"100%"}})};function tt({containerRef:e,isRow:t,direction:n,splitPercentage:r,resizerSize:o,snapThreshold:a,layout:s,currentNode:i,onLayoutChange:l,onResizeStart:d,onResizeEnd:p,parentLeft:f,parentTop:m,parentWidth:b,parentHeight:S}){let{onResizeStart:N,onResize:Z,onResizeEnd:v,minSplitPercentage:z=5,maxSplitPercentage:H=95,locked:x=false}=oe();return useCallback(R=>{if(x)return;R.preventDefault();let P=e.current;if(!P)return;d&&d(),N&&N(i);let M=P.getBoundingClientRect(),j=R.clientX,A=R.clientY,W=r,Y=R.currentTarget,G=M.left+M.width*(f/100),y=M.top+M.height*(m/100),U=M.width*(b/100),I=M.height*(S/100),B=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(E=>E!==Y&&E.getAttribute("data-direction")===n).map(E=>{let u=E.getBoundingClientRect();return t?u.left+u.width/2:u.top+u.height/2}),T=W;dt({cursor:t?"col-resize":"row-resize",resizerEl:Y,onMove:E=>{let u=t?(E.clientX-j)/U*100:(E.clientY-A)/I*100,q=W+u,D=t?G+(U-o)*(q/100)+o/2:y+(I-o)*(q/100)+o/2,C=1/0,se=null;for(let ee of B){let h=Math.abs(D-ee);h<a&&h<C&&(C=h,se=ee);}let J=q;se!==null&&(J=t?(se-o/2-G)/(U-o)*100:(se-o/2-y)/(I-o)*100);let F=Math.max(z,Math.min(H,J));T=F;let Q=he(s,i,F);if(Q){let{panes:ee,splitters:h}=pe(Q),w=e.current;if(w){for(let k of ee)w.style.setProperty(`--pane-left-${k.paneId}`,`${k.left}%`),w.style.setProperty(`--pane-top-${k.paneId}`,`${k.top}%`),w.style.setProperty(`--pane-width-${k.paneId}`,`${k.width}%`),w.style.setProperty(`--pane-height-${k.paneId}`,`${k.height}%`);for(let k of h)w.style.setProperty(`--splitter-pos-${k.id}`,`${k.direction==="row"?k.left:k.top}%`);}}Z&&Z(i,F);},onEnd:()=>{let E=he(s,i,T),u=e.current;if(u){let{panes:q,splitters:D}=pe(E);for(let C of q)u.style.removeProperty(`--pane-left-${C.paneId}`),u.style.removeProperty(`--pane-top-${C.paneId}`),u.style.removeProperty(`--pane-width-${C.paneId}`),u.style.removeProperty(`--pane-height-${C.paneId}`);for(let C of D)u.style.removeProperty(`--splitter-pos-${C.id}`);}l(E),p&&p(),v&&v(i,T);}});},[e,t,n,r,o,a,s,i,l,d,p,N,Z,v,z,H,f,m,b,S])}var Mt=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:r})=>{let{renderingLayout:o,setLayout:a,classNames:s,locked:i}=oe(),[l,d]=useState(false),{currentNode:p,direction:f,left:m,top:b,width:S,height:N,parentLeft:Z,parentTop:v,parentWidth:z,parentHeight:H}=e,x=f==="row",R=tt({containerRef:r,isRow:x,direction:f,splitPercentage:p.splitPercentage,resizerSize:t,snapThreshold:n,layout:o,currentNode:p,onLayoutChange:a,onResizeStart:()=>d(true),onResizeEnd:()=>d(false),parentLeft:Z,parentTop:v,parentWidth:z,parentHeight:H}),P=x?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${m}%) - ${t/2}px)`,top:`calc(${b}% + ${t/2}px)`,width:`${t}px`,height:`calc(${N}% - ${t}px)`,cursor:i?"default":"col-resize",pointerEvents:i?"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(${S}% - ${t}px)`,height:`${t}px`,cursor:i?"default":"row-resize",pointerEvents:i?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"};return jsx("div",{className:s.resizer||"","data-direction":f,"data-resizing":l||void 0,style:P,onPointerDown:R,role:"separator","aria-valuenow":p.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},Lt=hn.memo(({paneId:e,renderPane:t})=>jsx(Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane);var nt=({renderPane:e,tree:t,resizerSize:n,snapThreshold:r})=>{bt(e);let{renderingLayout:o,activeId:a,dismissIntentId:s,setContainerRef:i,fullscreenPaneId:l,snapThreshold:d,locked:p,classNames:f,resizerSize:m}=oe(),b=r!==void 0?r:d??8,S=n!==void 0?n:m??4,N=t!==void 0?t:o,Z=useRef(null),{panes:v,splitters:z}=useMemo(()=>N?pe(N):{panes:[],splitters:[]},[N]);if(!N&&t!==void 0)return null;let H=()=>jsxs(Fragment,{children:[v.map(x=>{let R=l===x.paneId;return jsx("div",{style:{position:"absolute",left:R?"0%":`var(--pane-left-${x.paneId}, ${x.left}%)`,top:R?"0%":`var(--pane-top-${x.paneId}, ${x.top}%)`,width:R?"100%":`var(--pane-width-${x.paneId}, ${x.width}%)`,height:R?"100%":`var(--pane-height-${x.paneId}, ${x.height}%)`,overflow:"hidden",zIndex:R?20:1,display:l&&!R?"none":"block",padding:R?"0px":`${S/2}px`,boxSizing:"border-box"},children:jsx(Lt,{paneId:x.paneId,renderPane:e})},x.paneId)}),!l&&z.map(x=>jsx(Mt,{splitter:x,resizerSize:S,snapThreshold:b,containerRef:Z},x.id))]});if(t===void 0){let x=a!==null&&a===s,R=M=>{i(M),Z.current=M;},P=`${f.dashboard||""} ${x&&f.dashboardDismissActive||""} ${p&&f.dashboardLocked||""}`.trim();return jsxs("div",{ref:R,className:P,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[H(),a!==null&&!p&&jsx(zt,{activeClassName:f.rootDropPreview??f.dropPreview})]})}return jsx("div",{ref:Z,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:H()})};var Ln=e=>{let{controller:t,children:n,renderDragOverlay:r,classNames:o={},renderPane:a,resizerSize:s,dragActivationDistance:i=8,snapThreshold:l=8,minSplitPercentage:d=5,maxSplitPercentage:p=95,enableDragToDismiss:f=false,dismissThreshold:m=60,onRemove:b,onDragStart:S,onDragEnd:N,onResizeStart:Z,onResize:v,onResizeEnd:z,onDismissIntentChange:H}=e,x=t,{layout:R,setLayout:P,_internalSetLayout:M,renderingLayout:j,fullscreenPaneId:A,setFullscreenPaneId:W,locked:Y,setLocked:G,findPaneById:y,findPaneContainingTab:U,findTabById:I,getTabMetadata:K,getActiveTabMetadata:B,activeId:T,setActiveId:E,activeType:u,setActiveType:q,dismissIntentId:D,setDismissIntentId:C,containerRef:se,setContainerRef:J,removePane:F,addTab:Q,updateMetadata:ee,updatePaneLock:h,selectTab:w,mergeTab:k,removeTab:ae,splitPane:c,updateSplitPercentage:g,moveTab:$}=x,{portalTargets:L,registerPortalTarget:X,registerRenderCallback:V,renderCallbacksRef:le,registerRenderPane:te,renderPaneRef:ge,registerTabHeader:ne,tabHeadersRef:ve,activeIdRef:Se}=ft(),{overTabId:st,setOverTabId:Yt,overTabPosition:it,setOverTabPosition:qt,handleDragStartInternal:Jt,handleDragEndInternal:_t}=mt({onDragStart:S,onDragEnd:N}),Gt=wt({layout:R,_internalSetLayout:M,setLayout:P,activeId:T,setActiveId:E,setActiveType:q,dismissIntentId:D,setDismissIntentId:C,setOverTabId:Yt,setOverTabPosition:qt,containerRef:se,dragActivationDistance:i,enableDragToDismiss:f,dismissThreshold:m,onRemove:b,onDragStart:Jt,onDragEnd:_t,onDismissIntentChange:H,removeTab:ae,removePane:F}),Je=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]),lt=useCallback((ue,Le)=>{z&&z(ue,Le);},[z]),Kt=useMemo(()=>({layout:R,renderingLayout:j,setLayout:P,activeId:T,activeType:u,dismissIntentId:D,setContainerRef:J,fullscreenPaneId:A,classNames:Je,onRemove:b,onFullscreenChange:W,snapThreshold:l,onResizeStart:Z,onResize:v,onResizeEnd:lt,minSplitPercentage:d,maxSplitPercentage:p,locked:Y,setLocked:G,findPaneById:y,findPaneContainingTab:U,findTabById:I,getTabMetadata:K,getActiveTabMetadata:B,renderPane:a,resizerSize:s}),[R,j,T,u,D,J,A,Je,b,W,l,Z,v,d,p,P,lt,Y,G,y,U,I,K,B,a,s]),Qt=useMemo(()=>({overTabId:st,overTabPosition:it}),[st,it]),jt=useMemo(()=>({removePane:F,addTab:Q,updateMetadata:ee,updatePaneLock:h,selectTab:w,mergeTab:k,removeTab:ae,setFullscreenPaneId:W,setLocked:G,splitPane:c,updateSplitPercentage:g,moveTab:$}),[F,Q,ee,h,w,k,ae,W,G,c,g,$]),en=gt(R),tn=useMemo(()=>({registerPortalTarget:X,registerRenderCallback:V,renderCallbacksRef:le,registerRenderPane:te,renderPaneRef:ge,registerTabHeader:ne,tabHeadersRef:ve,activeIdRef:Se}),[X,V,le,te,ge,ne,ve,Se]);return Se&&(Se.current=T),jsx(Ke.Provider,{value:jt,children:jsx(Ge.Provider,{value:Kt,children:jsx(Qe.Provider,{value:Qt,children:jsxs(me.Provider,{value:tn,children:[jsx(DndContext,{id:"zeugma-dnd-context",...Gt,children:n}),T&&u&&jsx(Nt,{activeId:T,render:ue=>jsx("div",{style:{transition:"transform 150ms cubic-bezier(0.2, 0, 0, 1)",transform:ue===D?"scale(0.8)":"scale(1)",transformOrigin:"top left"},children:jsx(Et,{activeId:ue,activeType:u,dismissIntentId:D,renderDragOverlay:r,renderPaneRef:ge,renderPane:a,tabHeadersRef:ve,classNames:Je})}),className:`${o.dragOverlay||""} ${T===D&&o.dismissPreview||""}`.trim()}),jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:en.map(ue=>{let Le=L[ue],ct=I(ue);return ct?jsx(It,{tabDetails:ct,target:Le||null,renderWidget:le.current[ue]},ue):null})})]})})})})},Zn=({renderPane:e,resizerSize:t,snapThreshold:n})=>{if(!e)throw new Error("Zeugma component requires a renderPane prop when used as a standalone renderer.");return jsx(nt,{renderPane:e,resizerSize:t,snapThreshold:n})},kn=e=>{let{children:t,...n}=e,{controller:r}=e;if(!r)throw new Error("Zeugma component requires a controller.");return jsx(Ln,{...e,children:t!==void 0?t:jsx(Zn,{...n})})};var An={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"}}},Hn={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"}}},On=({id:e,fraction:t,edge:n,activeClassName:r})=>{let{setNodeRef:o,isOver:a}=useDroppable({id:e}),s={position:"absolute",pointerEvents:"none",zIndex:101,boxSizing:"border-box",...Hn[n][t]};return jsxs(Fragment,{children:[jsx("div",{ref:o,style:An[n][t]}),a&&jsx("div",{className:r,style:s})]})},zt=({activeClassName:e})=>jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:99,pointerEvents:"none"},children:[{id:"drop-root-1/4-top",fraction:"1/4",edge:"top"},{id:"drop-root-1/3-top",fraction:"1/3",edge:"top"},{id:"drop-root-1/4-bottom",fraction:"1/4",edge:"bottom"},{id:"drop-root-1/3-bottom",fraction:"1/3",edge:"bottom"},{id:"drop-root-1/4-left",fraction:"1/4",edge:"left"},{id:"drop-root-1/3-left",fraction:"1/3",edge:"left"},{id:"drop-root-1/4-right",fraction:"1/4",edge:"right"},{id:"drop-root-1/3-right",fraction:"1/3",edge:"right"}].map(n=>jsx(On,{id:n.id,fraction:n.fraction,edge:n.edge,activeClassName:e},n.id))});var Xe=createContext(null);var Un={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"}},Xn={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"}},ot=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:r,isOver:o}=useDroppable({id:e});return jsxs(Fragment,{children:[jsx("div",{ref:r,style:Un[t]}),o&&jsx("div",{className:n,style:Xn[t]})]})};var At=({children:e,className:t,style:n})=>{let r=useContext(Xe);if(!r)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:o,...a}=r;return jsx("div",{className:t,style:{cursor:o?"default":"grab",userSelect:o?"auto":"none",touchAction:o?"auto":"none",...n},...o?{}:a,children:e})};var to=createContext(void 0);var Me=({id:e,locked:t=false,children:n,className:r,style:o})=>{let{locked:a,classNames:s={},activeType:i}=oe(),{overTabId:l}=ze(),d=useContext(me);useEffect(()=>(d?.registerTabHeader&&d.registerTabHeader(e,n),()=>{d?.registerTabHeader&&d.activeIdRef?.current!==e&&d.registerTabHeader(e,()=>null);}),[e,n,d]);let p=useContext(rt),f=t||a||(p?.locked??false),{attributes:m,listeners:b,setNodeRef:S,isDragging:N}=useDraggable({id:`tab-header-${e}`,disabled:f}),{setNodeRef:Z,isOver:v}=useDroppable({id:`tab-drop-${e}`,disabled:f||i==="pane"}),z=U=>{S(U),Z(U);},H=v&&l===e,x=p?.tabs||[],R=x.indexOf(e),P=p?.activeTabId,j=R>0&&e!==P&&x[R-1]!==P?jsx("div",{className:s.tabSeparator}):null,A=p?p.activeTabId===e:false,W=p?.tabsMetadata?.[e],Y=useCallback(()=>{p?.selectTab(e);},[p,e]),G=useCallback(()=>{p?.removeTab(e);},[p,e]),y=useMemo(()=>({tabId:e,isActive:A,isDragging:N,isOver:H,metadata:W,locked:f,selectTab:Y,removeTab:G}),[e,A,N,H,W,f,Y,G]);return jsx(to.Provider,{value:y,children:jsxs("div",{ref:z,id:`tab-header-${e}`,className:r,style:{display:"inline-flex",position:"relative",cursor:f?"default":"grab",...o},...f?{}:b,...f?{}:m,children:[j,n({isDragging:N,isOver:H})]})})};var rt=createContext(void 0);var Ft=(e,t)=>typeof e=="function"?e(t):e,at=({tabs:e,activeTabId:t,locked:n,tabsMetadata:r,selectTab:o,removeTab:a,renderTab:s,classNames:i,styles:l})=>{let d=useContext(Ye),p=e??d?.tabs??[],f=t??d?.activeTabId??"",m=n??d?.locked??false,b=r??d?.tabsMetadata,S=o??d?.selectTab??(()=>{}),N=a??d?.removeTab??(()=>{}),{classNames:Z={},activeType:v}=oe(),{overTabId:z,overTabPosition:H}=ze(),x=useMemo(()=>({tabs:p,activeTabId:f,locked:m,tabsMetadata:b,selectTab:S,removeTab:N}),[p,f,m,b,S,N]),R=xt(p,v,z,H);return jsx(rt.Provider,{value:x,children:jsxs("div",{className:i?.container,style:{display:"flex",alignItems:"center",height:"100%",...l?.container},children:[p.map((P,M)=>{let j=b?.[P],A=Ft(i?.tab,P),W=Ft(l?.tab,P),Y=M===R;return jsxs(hn.Fragment,{children:[Y&&Z.tabDropPreview&&jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsx("div",{className:Z.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:M===0?"none":"translateX(-50%)"}})}),jsx(Me,{id:P,locked:m,className:A,style:W,children:({isDragging:G,isOver:y})=>s({tabId:P,activeTabId:f,isDragging:G,isOver:y,metadata:j,onSelect:()=>S(P),onRemove:()=>N(P)})})]},P)}),R===p.length&&Z.tabDropPreview&&jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsx("div",{className:Z.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:"translateX(-100%)"}})})]})})};at.Tab=Me;var Wt=({className:e,style:t,children:n})=>jsx("div",{className:e,style:t,children:n});var Ye=createContext(void 0),Xt=()=>{let e=useContext(Ye);if(!e)throw new Error("usePaneContext must be used within a Pane component");return e},fo=({children:e,className:t,style:n})=>{let{activeTabId:r}=Xt(),{classNames:o}=oe(),a=useRef(null),s=useContext(me);if(!s)throw new Error("PaneContent must be used within a Zeugma provider");let{registerPortalTarget:i,registerRenderCallback:l}=s,d=useMemo(()=>typeof e=="function"?e:()=>e,[e]);return l(r,d),useEffect(()=>{let p=a.current;return i(r,p),()=>{i(r,null);}},[r,i]),jsx("div",{ref:a,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,activeId:a,classNames:s,fullscreenPaneId:i,onFullscreenChange:l,locked:d,findPaneById:p}=oe(),{removePane:f,updateMetadata:m,selectTab:b,removeTab:S}=ke(),N=useMemo(()=>p(e),[o,e,p]),Z=N?.id??e,v=N?.tabs??[e],z=N?.activeTabId??e,H=N?.tabsMetadata,x=H?.[e],R=N?.locked??false,P=r||R,M=d||P,j=d||P,A=a!==null&&a!==e&&(!v.includes(a)||v.length>1)&&!j,{attributes:W,listeners:Y,setNodeRef:G}=useDraggable({id:e,disabled:M}),y=a!==null&&v.includes(a),U=i===e,I=useMemo(()=>({isDragging:y,isFullscreen:U,toggleFullscreen:()=>l?.(U?null:e),remove:()=>{U&&l?.(null),f(Z);},metadata:x,updateMetadata:T=>{m(e,T);},locked:M,tabs:v,activeTabId:z,selectTab:T=>b(Z,T),removeTab:T=>{U&&T===z&&l?.(null),S(T);},tabsMetadata:H,updateTabMetadata:(T,E)=>{m(T,E);}}),[y,U,l,e,S,x,m,M,v,z,b,Z,H]),K=useMemo(()=>M?{disabled:true}:{...Y,...W},[Y,W,M]),B=`${s.pane||""} ${P&&s.paneLocked||""}`.trim();return jsx(Ye.Provider,{value:{id:e,...I},children:jsx(Xe.Provider,{value:K,children:jsxs("div",{ref:G,id:e,className:B,style:{position:"relative",width:"100%",height:"100%",...n},children:[t,A&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:["top","bottom","left","right"].map(T=>jsx(ot,{id:`drop-${T}-${e}`,position:T,activeClassName:s.dropPreview},T))}),a!==null&&a!==e&&j&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsx(ot,{id:`drop-locked-${e}`,position:"full",activeClassName:s.lockedPreview||""})})]})})})};Ce.Content=fo;Ce.DragHandle=At;Ce.Tabs=at;Ce.Tab=Me;Ce.Controls=Wt;export{Ce as Pane,nt as PaneTree,kn as Zeugma,Xt as usePaneContext,tt as useResizer,sn as useZeugma,ln as useZeugmaContext};//# sourceMappingURL=index.js.map
|
|
7
10
|
//# sourceMappingURL=index.js.map
|