react-zeugma 6.7.3 → 6.7.4
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 +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
.zeugma-resizing *:not([role="separator"]) {
|
|
7
7
|
pointer-events: none !important;
|
|
8
8
|
}
|
|
9
|
-
`,document.head.appendChild(o),t.setAttribute("data-resizing","true");let l=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",l),document.removeEventListener("pointerup",a),r();};document.addEventListener("pointermove",l),document.addEventListener("pointerup",a);}function we(e){try{return JSON.stringify(e)}catch{return ""}}var je=Dn.createContext(void 0),Ke=Dn.createContext(void 0),be=Dn.createContext(void 0),Qe=Dn.createContext(void 0),re=()=>{let e=Dn.useContext(je);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},$e=()=>{let e=Dn.useContext(Ke);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e},Ae=()=>{let e=Dn.useContext(Qe);if(!e)throw new Error("useZeugmaDrag must be used within a Zeugma provider");return e};function pt(e){let t=Dn.useRef(null);return Dn.useEffect(()=>{if(!e){t.current=null;return}let n=o=>{t.current={x:o.clientX,y:o.clientY};},r=o=>{let l=o.touches[0]||o.changedTouches[0];l&&(t.current={x:l.clientX,y:l.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){Dn.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]=Dn.useState({}),n=Dn.useRef({}),r=Dn.useRef(null),o=Dn.useRef({}),l=Dn.useRef(null),a=Dn.useRef(true);Dn.useEffect(()=>(a.current=true,()=>{a.current=false;}),[]);let s=Dn.useCallback((f,v,P)=>{a.current&&t(g=>{if(!v){if(P&&g[f]!==P||!g[f])return g;let w={...g};return delete w[f],w}return g[f]===v?g:{...g,[f]:v}});},[]),i=Dn.useCallback((f,v)=>{n.current[f]=v;},[]),d=Dn.useCallback(f=>{r.current=f;},[]),u=Dn.useCallback((f,v)=>{o.current[f]=v;},[]);return {portalTargets:e,registerPortalTarget:s,registerRenderCallback:i,renderCallbacksRef:n,registerRenderPane:d,renderPaneRef:r,registerTabHeader:u,tabHeadersRef:o,activeIdRef:l}}function dn(e){let t=new Set;function n(r){r&&(r.type==="pane"?r.tabIds.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 Dn.useMemo(()=>dn(e),[e])}function bt(e){let{onDragStart:t,onDragEnd:n}=e,[r,o]=Dn.useState(null),[l,a]=Dn.useState(null),s=Dn.useCallback(d=>{t&&t(d);},[t]),i=Dn.useCallback((d,u,f)=>{n&&n(d,u,f);},[n]);return {overTabId:r,setOverTabId:o,overTabPosition:l,setOverTabPosition:a,handleDragStartInternal:s,handleDragEndInternal:i}}function vt(e){let n=Dn.useContext(be)?.registerRenderPane;Dn.useEffect(()=>{n&&e&&n(e);},[n,e]);}function de(){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.tabIds.includes(t)){let o=e.tabIds.filter(s=>s!==t);if(o.length===0)return null;let l=e.activeTabId;e.activeTabId===t&&(l=o[0]);let a={...e.tabsMetadata};return delete a[t],{...e,tabIds:o,activeTabId:l,tabsMetadata:Object.keys(a).length>0?a: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:de(),tabIds:[o],activeTabId:o}:o;if(e.type==="pane"){if(e.id===t){let l=typeof o=="string"?{type:"pane",id:de(),tabIds:[o],activeTabId:o}:o,a=r==="left"||r==="top";return {type:"split",direction:n,first:a?l:e,second:a?e:l,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 un(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:de(),tabIds:[n],activeTabId:n,tabsMetadata:r?{[n]:r}:void 0};let o=t?K(e,t):null;if(o&&o.type==="pane"){let s=function(i){if(i.type==="pane"&&i.id===t){let d=[...i.tabIds];d.includes(n)||d.push(n);let u=i.tabsMetadata;return r&&(u={...i.tabsMetadata,[n]:r}),{...i,tabIds:d,activeTabId:n,tabsMetadata:u}}return i.type==="split"?{...i,first:s(i.first),second:s(i.second)}:i};return s(e)}let l={type:"pane",id:de(),tabIds:[n],activeTabId:n,tabsMetadata:r?{[n]:r}:void 0};return un(e,l)}function Te(e,t,n){return e===null?null:e===t?{...e,splitPercentage:n}:e.type==="split"?{...e,first:Te(e.first,t,n)||e.first,second:Te(e.second,t,n)||e.second}:e}function K(e,t){return e===null?null:e.type==="pane"?e.id===t?e:null:e.type==="split"?K(e.first,t)??K(e.second,t):null}function B(e,t){return e===null?null:e.type==="pane"?e.tabIds.includes(t)?e:null:e.type==="split"?B(e.first,t)??B(e.second,t):null}function Tt(e,t){return K(e,t)??B(e,t)}function Pt(e,t){let n=B(e,t);if(!n)return null;let r=n.tabIds.indexOf(t);return {id:t,paneId:n.id,isActive:n.activeTabId===t,index:r,metadata:n.tabsMetadata?.[t]}}function Rt(e,t){return B(e,t)?.tabsMetadata?.[t]}function xt(e,t){let n=K(e,t);return n?.tabsMetadata?.[n.activeTabId]}function Oe(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.tabIds.includes(t)){let r=e.tabsMetadata||{},o=r[t],l=n(o),a={...r};return l===void 0?delete a[t]:a[t]=l,{...e,tabsMetadata:Object.keys(a).length>0?a:void 0}}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 Fe(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:Fe(e.first,t,n)??e.first,second:Fe(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 yt(e,t,n){if(e===null)return null;let o=B(e,t)?.tabsMetadata?.[t],l=ue(e,t);if(l===null)return {type:"pane",id:de(),tabIds:[t],activeTabId:t,tabsMetadata:o?{[t]:o}:void 0};function a(s){if(s.type==="pane"){if(s.id===n){let i=[...s.tabIds];i.includes(t)||i.push(t);let d={...s.tabsMetadata};return o&&(d[t]=o),{...s,tabIds:i,activeTabId:t,tabsMetadata:Object.keys(d).length>0?d:void 0}}return s}return s.type==="split"?{...s,first:a(s.first),second:a(s.second)}:s}return a(l)}function Be(e,t,n,r="before"){if(e===null)return null;let l=B(e,t)?.tabsMetadata?.[t],a=ue(e,t);if(a===null)return {type:"pane",id:de(),tabIds:[t],activeTabId:t,tabsMetadata:l?{[t]:l}:void 0};function s(i){if(i.type==="pane"){if(i.tabIds.includes(n)){let u=[...i.tabIds].filter(P=>P!==t),f=u.indexOf(n);f<0&&(f=0),r==="after"&&(f+=1),u.splice(f,0,t);let v={...i.tabsMetadata};return l&&(v[t]=l),{...i,tabIds:u,activeTabId:t,tabsMetadata:Object.keys(v).length>0?v:void 0}}return i}return i.type==="split"?{...i,first:s(i.first),second:s(i.second)}:i}return s(a)}function me(e,t=0,n=0,r=100,o=100,l="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:i,second:d}=e,f={id:`splitter-${l}-${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},v={panes:[],splitters:[]},P={panes:[],splitters:[]};if(a==="row"){let g=r*(s/100);v=me(i,t,n,g,o,`${l}-L`),P=me(d,t+g,n,r-g,o,`${l}-R`);}else {let g=o*(s/100);v=me(i,t,n,r,g,`${l}-T`),P=me(d,t,n+g,r,o-g,`${l}-B`);}return {panes:[...v.panes,...P.panes],splitters:[f,...v.splitters,...P.splitters]}}function Dt(e,t,n,r="before"){if(e===null)return null;let o=K(e,t);if(!o)return e;let l=o.tabIds,a=o.activeTabId,s=o.tabsMetadata||{},i=fe(e,t);if(i===null)return o;function d(u){if(u.type==="pane"){if(u.tabIds.includes(n)){let v=[...u.tabIds].filter(w=>!l.includes(w)),P=v.indexOf(n);P<0&&(P=0),r==="after"&&(P+=1),v.splice(P,0,...l);let g={...u.tabsMetadata};for(let w of l)s[w]&&(g[w]=s[w]);return {...u,tabIds:v,activeTabId:a,tabsMetadata:Object.keys(g).length>0?g:void 0}}return u}return u.type==="split"?{...u,first:d(u.first),second:d(u.second)}:u}return d(i)}function Ct(e,t,n,r){if(!((t==="tab"||t==="pane")&&n&&e.includes(n))||!r)return -1;let a=e.indexOf(n);return r==="before"?a:a+1}function pn(e){let{initialLayout:t,layout:n,onChange:r,fullscreenPaneId:o,onFullscreenChange:l,locked:a=false}=e,[s,i]=Dn.useState(()=>n!==void 0?n:t??null),[d,u]=Dn.useState(()=>n!==void 0?n:t??null),[f,v]=Dn.useState(()=>we(n!==void 0?n:null)),[P,g]=Dn.useState(o||null),[w,M]=Dn.useState(a),[A,h]=Dn.useState(null),[k,C]=Dn.useState(null),[E,N]=Dn.useState(null),y=Dn.useRef(null),F=Dn.useCallback(c=>{y.current=c;},[]),$=Dn.useRef(s);$.current=s;let X=Dn.useRef(r);X.current=r;let W=Dn.useRef(l);W.current=l;let ne=Dn.useCallback(c=>{g(c),W.current?.(c);},[]);if(Dn.useEffect(()=>{M(a);},[a]),Dn.useEffect(()=>{o!==void 0&&g(o);},[o]),n!==void 0){let c=we(n);c!==f&&(v(c),i(n),u(n));}let D=Dn.useCallback(c=>(...m)=>{let I=$.current,z=c(I,...m);we(I)!==we(z)&&($.current=z,i(z),u(z),X.current?.(z));},[]),ae=Dn.useCallback(D((c,m)=>typeof m=="function"?m(c):m),[D]),oe=Dn.useCallback(c=>{u(m=>typeof c=="function"?c(m):c);},[]),Z=Dn.useCallback(c=>{g(null),W.current?.(null),h(null),C(null),N(null),ae(c),u(()=>typeof c=="function"?c($.current):c);},[ae]),_=Dn.useCallback(D((c,m)=>fe(c,m)),[D]),H=Dn.useCallback(D((c,m,I,z)=>{let q=ue(c,m)??c;return ht(q,I,m,z)}),[D]),b=Dn.useCallback(D((c,m,I,z,q)=>{let te=K(c,m)??B(c,m);if(!te)return c;let O=K(c,q)??B(c,q)??{type:"pane",id:q,tabIds:[q],activeTabId:q},ie=fe(c,O.id);return ye(ie,te.id,I,z,O)}),[D]),S=Dn.useCallback(D((c,m,I)=>Te(c,m,I)),[D]),p=Dn.useCallback(D((c,m,I)=>Oe(c,m,I)),[D]),Q=Dn.useCallback(D((c,m,I)=>{let z=K(c,m)??B(c,m);return z?Fe(c,z.id,I):c}),[D]),R=Dn.useCallback(D((c,m,I)=>{let z=K(c,m)??B(c,m);return z?De(c,z.id,I):c}),[D]),L=Dn.useCallback(D((c,m,I)=>{let z=K(c,I)??B(c,I);return z?yt(c,m,z.id):c}),[D]),ce=Dn.useCallback(D((c,m,I,z)=>Be(c,m,I,z)),[D]),J=Dn.useCallback(D((c,m)=>ue(c,m)),[D]),Y=Dn.useCallback(c=>K($.current,c),[]),G=Dn.useCallback(c=>B($.current,c),[]),ee=Dn.useCallback(c=>Pt($.current,c),[]),T=Dn.useCallback(c=>Rt($.current,c),[]),x=Dn.useCallback(c=>xt($.current,c),[]);return {layout:s,setLayout:Z,_internalSetLayout:oe,renderingLayout:d,fullscreenPaneId:P,setFullscreenPaneId:ne,locked:w,setLocked:M,activeId:A,setActiveId:h,activeType:k,setActiveType:C,dismissIntentId:E,setDismissIntentId:N,containerRef:y,setContainerRef:F,removePane:_,addTab:H,updateMetadata:p,updatePaneLock:Q,selectTab:R,mergeTab:L,moveTab:ce,removeTab:J,splitPane:b,updateSplitPercentage:S,findPaneById:Y,findPaneContainingTab:G,findTabById:ee,getTabMetadata:T,getActiveTabMetadata:x}}var fn=()=>{let e=re(),t=$e();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 We=class extends core.PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},Ue=class extends core.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};var St=e=>{let n=e.active.id.toString().startsWith("tab-header-"),o=core.pointerWithin(e);if(o.length>0)return [...o].sort((a,s)=>{let i=a.id.toString(),d=s.id.toString(),u=i.startsWith("tab-drop-"),f=d.startsWith("tab-drop-");if(u&&!f)return -1;if(!u&&f)return 1;let v=i.startsWith("drop-root-"),P=d.startsWith("drop-root-");return v&&!P?-1:!v&&P?1:0});if(n){let l=e.droppableContainers.filter(a=>a.id.toString().startsWith("tab-drop-"));return core.closestCenter({...e,droppableContainers:l})}return []};function Ne(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 Mt(e){let{layout:t,_internalSetLayout:n,setLayout:r,activeId:o,setActiveId:l,activeType:a,setActiveType:s,dismissIntentId:i,setDismissIntentId:d,setOverTabId:u,setOverTabPosition:f,containerRef:v,dragActivationDistance:P,enableDragToDismiss:g,dismissThreshold:w,onRemove:M,onDragStart:A,onDragEnd:h,onDismissIntentChange:k,removeTab:C,removePane:E}=e,N=Dn.useRef(null),y=pt(o),F=Dn.useRef(null),[$,X]=Dn.useState(false);return ft($),{sensors:core.useSensors(core.useSensor(We,{activationConstraint:{distance:P}}),core.useSensor(Ue,{activationConstraint:{delay:250,tolerance:5}})),collisionDetection:St,onDragStart:Z=>{let _=Z.active.id.toString(),H=_.startsWith("tab-header-"),b=H?_.substring(11):_;l(b),s(H?"tab":"pane"),u(null),f(null);let S=Z.activatorEvent;y.current=Ne(S),g&&v.current?N.current=v.current.getBoundingClientRect():N.current=null;let p=t;if(H){let R=B(t,b);R&&(p=De(t,R.id,b)||t);}F.current=p;let Q=H?ue(p,b):fe(p,b);n(Q),A&&A(b);},onDragMove:Z=>{let{over:_}=Z,H=_?.id.toString()||"",b=H.startsWith("drop-locked-");X(T=>T===b?T:b);let S=Z.active.id.toString(),p=S.startsWith("tab-header-"),Q=p?S.substring(11):S,R=H.match(/^tab-drop-(.+)$/);if(R&&_&&(p||a==="pane")){let[,T]=R;if(Q!==T){let x="before",se=_.rect,c=Z.activatorEvent,m=null;if(y.current)m=y.current.x;else {let I=Ne(c);I&&(m=I.x+Z.delta.x);}if(m!==null){let I=se.left+se.width/2;m>I&&(x="after");}u(I=>I===T?I:T),f(I=>I===x?I:x);}else u(x=>x===null?x:null),f(x=>x===null?x:null);}else u(T=>T===null?T:null),f(T=>T===null?T:null);if(!g)return;let L=N.current;if(!L){i!==null&&(d(null),k?.(null));return}let ce=Z.activatorEvent,J=null,Y=null;if(y.current)J=y.current.x,Y=y.current.y;else {let T=Ne(ce);T&&(J=T.x+Z.delta.x,Y=T.y+Z.delta.y);}let G=0;if(J!==null&&Y!==null){let T=0,x=0;J<L.left?T=L.left-J:J>L.right&&(T=J-L.right),Y<L.top?x=L.top-Y:Y>L.bottom&&(x=Y-L.bottom),G=Math.sqrt(T*T+x*x);}else {let T=Z.active.rect.current.translated;if(T){let x=T.left+T.width/2,se=T.top+T.height/2,c=0,m=0;x<L.left?c=L.left-x:x>L.right&&(c=x-L.right),se<L.top?m=L.top-se:se>L.bottom&&(m=se-L.bottom),G=Math.sqrt(c*c+m*m);}}G>w?i!==Q&&(d(Q),k?.(Q)):i!==null&&(d(null),k?.(null));},onDragEnd:Z=>{l(null),s(null),X(false),u(null),f(null);let{active:_,over:H}=Z,b=_.id.toString(),S=b.startsWith("tab-header-"),p=S?b.substring(11):b,Q=g&&i===p;d(null),k?.(null),N.current=null;let R=F.current||t;if(F.current=null,Q){M?M(p):S?C(p):E(p),h&&h(p,null,null);return}if(!H){n(R),h&&h(p,null,null);return}let L=H.id.toString();if(L.startsWith("drop-locked-")){n(R),h&&h(p,null,null);return}let ce=L.match(/^tab-drop-(.+)$/);if(ce){let[,q]=ce;if(S)if(p!==q){let te="before",O=H.rect,ie=Z.activatorEvent,j=null;if(y.current)j=y.current.x;else {let U=Ne(ie);U&&(j=U.x+Z.delta.x);}if(j!==null){let U=O.left+O.width/2;j>U&&(te="after");}let pe=Be(R,p,q,te);r(pe),h&&h(p,q,{type:"move",position:"center"});}else n(R),h&&h(p,null,null);else {let te="before",O=H.rect,ie=Z.activatorEvent,j=null;if(y.current)j=y.current.x;else {let U=Ne(ie);U&&(j=U.x+Z.delta.x);}if(j!==null){let U=O.left+O.width/2;j>U&&(te="after");}let pe=Dt(R,p,q,te);r(pe),h&&h(p,q,{type:"move",position:"center"});}return}let J=L.match(/^drop-root-(1\/4|1\/3)-(top|bottom|left|right|start|end)$/);if(J){let[,q,te]=J,O=te;O==="start"&&(O="left"),O==="end"&&(O="right");let ie=S?ue(R,p):fe(R,p),j;if(S){let U=B(R,p)?.tabsMetadata?.[p];j={type:"pane",id:de(),tabIds:[p],activeTabId:p,tabsMetadata:U?{[p]:U}:void 0};}else j=K(R,p)??{type:"pane",id:de(),tabIds:[p],activeTabId:p};if(ie===null)r(j);else {let pe=O==="left"||O==="right",U=O==="left"||O==="top",he=50;q==="1/4"?he=U?25:75:q==="1/3"&&(he=U?100/3:200/3),r({type:"split",direction:pe?"row":"column",first:U?j:ie,second:U?ie:j,splitPercentage:he});}h&&h(p,"root",{type:"split",direction:O==="left"||O==="right"?"row":"column",position:O});return}let Y=L.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!Y){n(R),h&&h(p,null,null);return}let[,G,ee]=Y,T=S?B(R,p):K(R,p),x=T&&T.id===ee,se=T&&T.tabIds.length===1;if(p===ee||x&&se){n(R),h&&h(p,null,null);return}let c=G==="left"||G==="right"?"row":"column",m;if(S){let te=B(R,p)?.tabsMetadata?.[p];m={type:"pane",id:de(),tabIds:[p],activeTabId:p,tabsMetadata:te?{[p]:te}:void 0};}else m=K(R,p)??{type:"pane",id:de(),tabIds:[p],activeTabId:p};let I=S?ue(R,p):fe(R,p),z=ye(I,ee,c,G,m);r(z),h&&h(p,ee,{type:"split",direction:c,position:G});},onDragCancel:()=>{l(null),s(null),X(false),u(null),f(null),d(null),k?.(null),N.current=null;let Z=F.current||t;F.current=null,n(Z),Z!==t&&r(Z);}}}function Lt({persist:e,layout:t,setLayout:n}){let r=typeof e=="object"?e.enabled!==false:!!e,o=typeof e=="object"&&e.key||"zeugma-layout",[l,a]=Dn.useState(false);Dn.useEffect(()=>{if(r){let s=localStorage.getItem(o);if(s)try{let i=JSON.parse(s);i&&n(i);}catch(i){console.error("Failed to parse persisted zeugma layout",i);}}a(true);},[r,o,n]),Dn.useEffect(()=>{r&&l&&(t?localStorage.setItem(o,JSON.stringify(t)):localStorage.removeItem(o));},[r,o,t,l]);}var Zt=({activeId:e,render:t,className:n})=>{let r=Dn.useRef(null);return Dn.useEffect(()=>{let o=l=>{r.current&&(r.current.style.transform=`translate(${l.clientX+12}px, ${l.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 kt=Dn__default.default.memo(({tabDetails:e,target:t,renderWidget:n})=>{let{id:r}=e,[o,l]=Dn.useState(false),a=Dn.useRef(null);if(Dn.useEffect(()=>{l(true);},[]),Dn.useEffect(()=>{if(!o||!a.current)return;let i=a.current;if(t)t.appendChild(i);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(i);}},[t,o]),Dn.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:l,tabHeadersRef:a,classNames:s})=>{if(r)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:r({type:t,id:e,isDismissing:e===n})});if(t==="pane"){let i=o.current||l;if(i)return jsxRuntime.jsx("div",{className:s.paneDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:i(e)})}else if(t==="tab"){let i=o.current||l;if(i)return jsxRuntime.jsx("div",{className:s.tabDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:i(e)});let d=a.current[e];if(d){let u=s.tab?typeof s.tab=="function"?s.tab(e):s.tab:"";return jsxRuntime.jsx("div",{className:`${s.tabDragPreview||""} ${u}`.trim(),style:{display:"inline-flex",position:"relative",pointerEvents:"none",overflow:"hidden"},children:d({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:l,layout:a,currentNode:s,onLayoutChange:i,onResizeStart:d,onResizeEnd:u,parentLeft:f,parentTop:v,parentWidth:P,parentHeight:g}){let{onResizeStart:w,onResize:M,onResizeEnd:A,minSplitPercentage:h=5,maxSplitPercentage:k=95,locked:C=false}=re();return Dn.useCallback(E=>{if(C)return;E.preventDefault();let N=e.current;if(!N)return;d&&d(),w&&w(s);let y=N.getBoundingClientRect(),F=E.clientX,$=E.clientY,X=r,W=E.currentTarget,ne=y.left+y.width*(f/100),D=y.top+y.height*(v/100),ae=y.width*(P/100),oe=y.height*(g/100),_=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(b=>b!==W&&b.getAttribute("data-direction")===n).map(b=>{let S=b.getBoundingClientRect();return t?S.left+S.width/2:S.top+S.height/2}),H=X;ut({cursor:t?"col-resize":"row-resize",resizerEl:W,onMove:b=>{let S=t?(b.clientX-F)/ae*100:(b.clientY-$)/oe*100,p=X+S,Q=t?ne+(ae-o)*(p/100)+o/2:D+(oe-o)*(p/100)+o/2,R=1/0,L=null;for(let G of _){let ee=Math.abs(Q-G);ee<l&&ee<R&&(R=ee,L=G);}let ce=p;L!==null&&(ce=t?(L-o/2-ne)/(ae-o)*100:(L-o/2-D)/(oe-o)*100);let J=Math.max(h,Math.min(k,ce));H=J;let Y=Te(a,s,J);if(Y){let{panes:G,splitters:ee}=me(Y),T=e.current;if(T){for(let x of G)T.style.setProperty(`--pane-left-${x.paneId}`,`${x.left}%`),T.style.setProperty(`--pane-top-${x.paneId}`,`${x.top}%`),T.style.setProperty(`--pane-width-${x.paneId}`,`${x.width}%`),T.style.setProperty(`--pane-height-${x.paneId}`,`${x.height}%`);for(let x of ee)T.style.setProperty(`--splitter-pos-${x.id}`,`${x.direction==="row"?x.left:x.top}%`);}}M&&M(s,J);},onEnd:()=>{let b=Te(a,s,H),S=e.current;if(S){let{panes:p,splitters:Q}=me(b);for(let R of p)S.style.removeProperty(`--pane-left-${R.paneId}`),S.style.removeProperty(`--pane-top-${R.paneId}`),S.style.removeProperty(`--pane-width-${R.paneId}`),S.style.removeProperty(`--pane-height-${R.paneId}`);for(let R of Q)S.style.removeProperty(`--splitter-pos-${R.id}`);}i(b),u&&u(),A&&A(s,H);}});},[e,t,n,r,o,l,a,s,i,d,u,w,M,A,h,k,f,v,P,g])}var $t=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:r})=>{let{renderingLayout:o,setLayout:l,classNames:a,locked:s}=re(),[i,d]=Dn.useState(false),{currentNode:u,direction:f,left:v,top:P,width:g,height:w,parentLeft:M,parentTop:A,parentWidth:h,parentHeight:k}=e,C=f==="row",E=nt({containerRef:r,isRow:C,direction:f,splitPercentage:u.splitPercentage,resizerSize:t,snapThreshold:n,layout:o,currentNode:u,onLayoutChange:l,onResizeStart:()=>d(true),onResizeEnd:()=>d(false),parentLeft:M,parentTop:A,parentWidth:h,parentHeight:k}),N=C?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${v}%) - ${t/2}px)`,top:`calc(${P}% + ${t/2}px)`,width:`${t}px`,height:`calc(${w}% - ${t}px)`,cursor:s?"default":"col-resize",pointerEvents:s?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`calc(${v}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${P}%) - ${t/2}px)`,width:`calc(${g}% - ${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":i||void 0,style:N,onPointerDown:E,role:"separator","aria-valuenow":u.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},At=Dn__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:l,dismissIntentId:a,setContainerRef:s,fullscreenPaneId:i,snapThreshold:d,locked:u,classNames:f,resizerSize:v}=re(),P=r!==void 0?r:d??8,g=n!==void 0?n:v??4,w=t!==void 0?t:o,M=Dn.useRef(null),{panes:A,splitters:h}=Dn.useMemo(()=>w?me(w):{panes:[],splitters:[]},[w]);if(!w&&t!==void 0)return null;let k=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[A.map(C=>{let E=i===C.paneId;return jsxRuntime.jsx("div",{style:{position:"absolute",left:E?"0%":`var(--pane-left-${C.paneId}, ${C.left}%)`,top:E?"0%":`var(--pane-top-${C.paneId}, ${C.top}%)`,width:E?"100%":`var(--pane-width-${C.paneId}, ${C.width}%)`,height:E?"100%":`var(--pane-height-${C.paneId}, ${C.height}%)`,overflow:"hidden",zIndex:E?20:1,display:i&&!E?"none":"block",padding:E?"0px":`${g/2}px`,boxSizing:"border-box"},children:jsxRuntime.jsx(At,{paneId:C.paneId,renderPane:e})},C.paneId)}),!i&&h.map(C=>jsxRuntime.jsx($t,{splitter:C,resizerSize:g,snapThreshold:P,containerRef:M},C.id))]});if(t===void 0){let C=l!==null&&l===a,E=y=>{s(y),M.current=y;},N=`${f.dashboard||""} ${C&&f.dashboardDismissActive||""} ${u&&f.dashboardLocked||""}`.trim();return jsxRuntime.jsxs("div",{ref:E,className:N,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[k(),l!==null&&!u&&jsxRuntime.jsx(Ft,{activeClassName:f.rootDropPreview??f.dropPreview})]})}return jsxRuntime.jsx("div",{ref:M,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:k()})};var Hn=e=>{let{controller:t,children:n,renderDragOverlay:r,classNames:o={},renderPane:l,resizerSize:a,dragActivationDistance:s=8,snapThreshold:i=8,minSplitPercentage:d=5,maxSplitPercentage:u=95,enableDragToDismiss:f=false,dismissThreshold:v=60,onRemove:P,onDragStart:g,onDragEnd:w,onResizeStart:M,onResize:A,onResizeEnd:h,onDismissIntentChange:k,persist:C=false}=e,E=t,{layout:N,setLayout:y,_internalSetLayout:F,renderingLayout:$,fullscreenPaneId:X,setFullscreenPaneId:W,locked:ne,setLocked:D,findPaneById:ae,findPaneContainingTab:oe,findTabById:Z,getTabMetadata:_,getActiveTabMetadata:H,activeId:b,setActiveId:S,activeType:p,setActiveType:Q,dismissIntentId:R,setDismissIntentId:L,containerRef:ce,setContainerRef:J,removePane:Y,addTab:G,updateMetadata:ee,updatePaneLock:T,selectTab:x,mergeTab:se,removeTab:c,splitPane:m,updateSplitPercentage:I,moveTab:z}=E;Lt({persist:C,layout:N,setLayout:y});let{portalTargets:q,registerPortalTarget:te,registerRenderCallback:O,renderCallbacksRef:ie,registerRenderPane:j,renderPaneRef:pe,registerTabHeader:U,tabHeadersRef:he,activeIdRef:Se}=gt(),{overTabId:it,setOverTabId:jt,overTabPosition:lt,setOverTabPosition:Kt,handleDragStartInternal:Qt,handleDragEndInternal:en}=bt({onDragStart:g,onDragEnd:w}),tn=Mt({layout:N,_internalSetLayout:F,setLayout:y,activeId:b,setActiveId:S,activeType:p,setActiveType:Q,dismissIntentId:R,setDismissIntentId:L,setOverTabId:jt,setOverTabPosition:Kt,containerRef:ce,dragActivationDistance:s,enableDragToDismiss:f,dismissThreshold:v,onRemove:P,onDragStart:Qt,onDragEnd:en,onDismissIntentChange:k,removeTab:c,removePane:Y}),_e=Dn.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=Dn.useCallback((ge,ke)=>{h&&h(ge,ke);},[h]),nn=Dn.useMemo(()=>({layout:N,renderingLayout:$,setLayout:y,activeId:b,activeType:p,dismissIntentId:R,setContainerRef:J,fullscreenPaneId:X,classNames:_e,onRemove:P,onFullscreenChange:W,snapThreshold:i,onResizeStart:M,onResize:A,onResizeEnd:ct,minSplitPercentage:d,maxSplitPercentage:u,locked:ne,setLocked:D,findPaneById:ae,findPaneContainingTab:oe,findTabById:Z,getTabMetadata:_,getActiveTabMetadata:H,renderPane:l,resizerSize:a}),[N,$,b,p,R,J,X,_e,P,W,i,M,A,d,u,y,ct,ne,D,ae,oe,Z,_,H,l,a]),on=Dn.useMemo(()=>({overTabId:it,overTabPosition:lt}),[it,lt]),rn=Dn.useMemo(()=>({removePane:Y,addTab:G,updateMetadata:ee,updatePaneLock:T,selectTab:x,mergeTab:se,removeTab:c,setFullscreenPaneId:W,setLocked:D,splitPane:m,updateSplitPercentage:I,moveTab:z}),[Y,G,ee,T,x,se,c,W,D,m,I,z]),an=mt(N),sn=Dn.useMemo(()=>({registerPortalTarget:te,registerRenderCallback:O,renderCallbacksRef:ie,registerRenderPane:j,renderPaneRef:pe,registerTabHeader:U,tabHeadersRef:he,activeIdRef:Se}),[te,O,ie,j,pe,U,he,Se]);return Se&&(Se.current=b),jsxRuntime.jsx(Ke.Provider,{value:rn,children:jsxRuntime.jsx(je.Provider,{value:nn,children:jsxRuntime.jsx(Qe.Provider,{value:on,children:jsxRuntime.jsxs(be.Provider,{value:sn,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",...tn,children:n}),b&&p&&jsxRuntime.jsx(Zt,{activeId:b,render:ge=>jsxRuntime.jsx("div",{style:{transition:"transform 150ms cubic-bezier(0.2, 0, 0, 1)",transform:ge===R?"scale(0.8)":"scale(1)",transformOrigin:"top left"},children:jsxRuntime.jsx(zt,{activeId:ge,activeType:p,dismissIntentId:R,renderDragOverlay:r,renderPaneRef:pe,renderPane:l,tabHeadersRef:he,classNames:_e})}),className:`${o.dragOverlay||""} ${b===R&&o.dismissPreview||""}`.trim()}),jsxRuntime.jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:an.map(ge=>{let ke=q[ge],dt=Z(ge);return dt?jsxRuntime.jsx(kt,{tabDetails:dt,target:ke||null,renderWidget:ie.current[ge]},ge):null})})]})})})})},On=({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})},Fn=e=>{let{children:t,...n}=e,{controller:r}=e;if(!r)throw new Error("Zeugma component requires a controller.");return jsxRuntime.jsx(Hn,{...e,children:t!==void 0?t:jsxRuntime.jsx(On,{...n})})};var Wn={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"}}},Un={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"}}},Xn=({id:e,fraction:t,edge:n,activeClassName:r})=>{let{setNodeRef:o,isOver:l}=core.useDroppable({id:e}),a={position:"absolute",pointerEvents:"none",zIndex:101,boxSizing:"border-box",...Un[n][t]};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:o,style:Wn[n][t]}),l&&jsxRuntime.jsx("div",{className:r,style:a})]})},Ft=({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(Xn,{id:n.id,fraction:n.fraction,edge:n.edge,activeClassName:e},n.id))});var Je=Dn.createContext(null);var Gn={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"}},jn={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:Gn[t]}),o&&jsxRuntime.jsx("div",{className:n,style:jn[t]})]})};var Vt=({children:e,className:t,style:n})=>{let r=Dn.useContext(Je);if(!r)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:o,...l}=r;return jsxRuntime.jsx("div",{className:t,style:{cursor:o?"default":"grab",userSelect:o?"auto":"none",touchAction:o?"auto":"none",...n},...o?{}:l,children:e})};var io=Dn.createContext(void 0);var Ze=({id:e,locked:t=false,children:n,className:r,style:o})=>{let{locked:l,classNames:a={}}=re(),{overTabId:s}=Ae(),i=Dn.useContext(be);Dn.useEffect(()=>(i?.registerTabHeader&&i.registerTabHeader(e,n),()=>{i?.registerTabHeader&&i.activeIdRef?.current!==e&&i.registerTabHeader(e,()=>null);}),[e,n,i]);let d=Dn.useContext(at),u=t||l||(d?.locked??false),{attributes:f,listeners:v,setNodeRef:P,isDragging:g}=core.useDraggable({id:`tab-header-${e}`,disabled:u}),{setNodeRef:w,isOver:M}=core.useDroppable({id:`tab-drop-${e}`,disabled:u}),A=D=>{P(D),w(D);},h=M&&s===e,k=d?.tabIds||[],C=k.indexOf(e),E=d?.activeTabId,y=C>0&&e!==E&&k[C-1]!==E?jsxRuntime.jsx("div",{className:a.tabSeparator}):null,F=d?d.activeTabId===e:false,$=d?.tabsMetadata?.[e],X=Dn.useCallback(()=>{d?.selectTab(e);},[d,e]),W=Dn.useCallback(()=>{d?.removeTab(e);},[d,e]),ne=Dn.useMemo(()=>({tabId:e,isActive:F,isDragging:g,isOver:h,metadata:$,locked:u,selectTab:X,removeTab:W}),[e,F,g,h,$,u,X,W]);return jsxRuntime.jsx(io.Provider,{value:ne,children:jsxRuntime.jsxs("div",{ref:A,id:`tab-header-${e}`,className:r,style:{display:"inline-flex",position:"relative",cursor:u?"default":"grab",...o},...u?{}:v,...u?{}:f,children:[y,n({isDragging:g,isOver:h})]})})};var at=Dn.createContext(void 0);var Jt=(e,t)=>typeof e=="function"?e(t):e,st=({tabIds:e,activeTabId:t,locked:n,tabsMetadata:r,selectTab:o,removeTab:l,renderTab:a,classNames:s,styles:i})=>{let d=Dn.useContext(Ye),u=e??d?.tabIds??[],f=t??d?.activeTabId??"",v=n??d?.locked??false,P=r??d?.tabsMetadata,g=o??d?.selectTab??(()=>{}),w=l??d?.removeTab??(()=>{}),{classNames:M={},activeType:A}=re(),{overTabId:h,overTabPosition:k}=Ae(),C=Dn.useMemo(()=>({tabIds:u,activeTabId:f,locked:v,tabsMetadata:P,selectTab:g,removeTab:w}),[u,f,v,P,g,w]),E=Ct(u,A,h,k);return jsxRuntime.jsx(at.Provider,{value:C,children:jsxRuntime.jsxs("div",{className:s?.container,style:{display:"flex",alignItems:"center",height:"100%",...i?.container},children:[u.map((N,y)=>{let F=P?.[N],$=Jt(s?.tab,N),X=Jt(i?.tab,N),W=y===E;return jsxRuntime.jsxs(Dn__default.default.Fragment,{children:[W&&M.tabDropPreview&&jsxRuntime.jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsxRuntime.jsx("div",{className:M.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:y===0?"none":"translateX(-50%)"}})}),jsxRuntime.jsx(Ze,{id:N,locked:v,className:$,style:X,children:({isDragging:ne,isOver:D})=>a({id:N,paneId:d?.id??"",isActive:N===f,index:y,isDragging:ne,isOver:D,metadata:F,onSelect:()=>g(N),onRemove:()=>w(N)})})]},N)}),E===u.length&&M.tabDropPreview&&jsxRuntime.jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsxRuntime.jsx("div",{className:M.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:"translateX(-100%)"}})})]})})};st.Tab=Ze;var qt=({className:e,style:t,children:n})=>jsxRuntime.jsx("div",{className:e,style:t,children:n});var Ye=Dn.createContext(void 0),Gt=()=>{let e=Dn.useContext(Ye);if(!e)throw new Error("usePaneContext must be used within a Pane component");return e},To=({children:e,className:t,style:n})=>{let{activeTabId:r}=Gt(),{classNames:o}=re(),l=Dn.useRef(null),a=Dn.useContext(be);if(!a)throw new Error("PaneContent must be used within a Zeugma provider");let{registerPortalTarget:s,registerRenderCallback:i}=a,d=Dn.useMemo(()=>typeof e=="function"?e:()=>e,[e]);return i(r,d),Dn.useEffect(()=>{let u=l.current;return s(r,u),()=>{s(r,null,u);}},[r,s]),jsxRuntime.jsx("div",{ref:l,id:`zeugma-tab-target-${r}`,className:`${o.tabContentWrapper||""} ${t||""}`.trim(),style:{height:"100%",width:"100%",...n}})},Ie=({id:e,children:t,style:n,locked:r=false})=>{let{layout:o,renderingLayout:l,activeId:a,activeType:s,classNames:i,fullscreenPaneId:d,onFullscreenChange:u,locked:f}=re(),{removePane:v,updateMetadata:P,selectTab:g,removeTab:w}=$e(),M=Dn.useMemo(()=>{if(s==="tab"&&e===a){let p=B(o,e)?.tabsMetadata?.[e];return {type:"pane",id:e,tabIds:[e],activeTabId:e,tabsMetadata:p?{[e]:p}:void 0}}return Tt(e===a?o:l,e)},[o,l,e,a,s]),A=M?.id??e,h=M?.tabIds??[e],k=M?.activeTabId??e,C=M?.tabsMetadata,E=C?.[e],N=M?.locked??false,y=r||N,F=f||y,$=f||y,X=a!==null&&a!==e&&(!h.includes(a)||h.length>1)&&!$,{attributes:W,listeners:ne,setNodeRef:D}=core.useDraggable({id:e,disabled:F}),ae=a!==null&&h.includes(a),oe=d===e,Z=Dn.useMemo(()=>({isDragging:ae,isFullscreen:oe,toggleFullscreen:()=>u?.(oe?null:e),remove:()=>{oe&&u?.(null),v(A);},metadata:E,updateMetadata:b=>{P(e,b);},locked:F,tabIds:h,activeTabId:k,selectTab:b=>g(A,b),removeTab:b=>{oe&&b===k&&u?.(null),w(b);},tabsMetadata:C,updateTabMetadata:(b,S)=>{P(b,S);}}),[ae,oe,u,e,w,E,P,F,h,k,g,A,C]),_=Dn.useMemo(()=>F?{disabled:true}:{...ne,...W},[ne,W,F]),H=`${i.pane||""} ${y&&i.paneLocked||""}`.trim();return jsxRuntime.jsx(Ye.Provider,{value:{id:e,...Z},children:jsxRuntime.jsx(Je.Provider,{value:_,children:jsxRuntime.jsxs("div",{ref:D,id:e,className:H,style:{position:"relative",width:"100%",height:"100%",...n},children:[t,X&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:["top","bottom","left","right"].map(b=>jsxRuntime.jsx(rt,{id:`drop-${b}-${e}`,position:b,activeClassName:i.dropPreview},b))}),a!==null&&a!==e&&$&&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:i.lockedPreview||""})})]})})})};Ie.Content=To;Ie.DragHandle=Vt;Ie.Tabs=st;Ie.Tab=Ze;Ie.Controls=qt;exports.Pane=Ie;exports.PaneTree=ot;exports.Zeugma=Fn;exports.usePaneContext=Gt;exports.useResizer=nt;exports.useZeugma=pn;exports.useZeugmaContext=fn;//# sourceMappingURL=index.cjs.map
|
|
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 we(e){try{return JSON.stringify(e)}catch{return ""}}var je=Dn.createContext(void 0),Ke=Dn.createContext(void 0),be=Dn.createContext(void 0),Qe=Dn.createContext(void 0),ae=()=>{let e=Dn.useContext(je);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},$e=()=>{let e=Dn.useContext(Ke);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e},Ae=()=>{let e=Dn.useContext(Qe);if(!e)throw new Error("useZeugmaDrag must be used within a Zeugma provider");return e};function pt(e){let t=Dn.useRef(null);return Dn.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){Dn.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]=Dn.useState({}),n=Dn.useRef({}),r=Dn.useRef(null),o=Dn.useRef({}),i=Dn.useRef(null),a=Dn.useRef(true);Dn.useEffect(()=>(a.current=true,()=>{a.current=false;}),[]);let s=Dn.useCallback((f,v,P)=>{a.current&&t(b=>{if(!v){if(P&&b[f]!==P||!b[f])return b;let I={...b};return delete I[f],I}return b[f]===v?b:{...b,[f]:v}});},[]),l=Dn.useCallback((f,v)=>{n.current[f]=v;},[]),u=Dn.useCallback(f=>{r.current=f;},[]),c=Dn.useCallback((f,v)=>{o.current[f]=v;},[]);return {portalTargets:e,registerPortalTarget:s,registerRenderCallback:l,renderCallbacksRef:n,registerRenderPane:u,renderPaneRef:r,registerTabHeader:c,tabHeadersRef:o,activeIdRef:i}}function dn(e){let t=new Set;function n(r){r&&(r.type==="pane"?r.tabIds.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 Dn.useMemo(()=>dn(e),[e])}function bt(e){let{onDragStart:t,onDragEnd:n}=e,[r,o]=Dn.useState(null),[i,a]=Dn.useState(null),s=Dn.useCallback(u=>{t&&t(u);},[t]),l=Dn.useCallback((u,c,f)=>{n&&n(u,c,f);},[n]);return {overTabId:r,setOverTabId:o,overTabPosition:i,setOverTabPosition:a,handleDragStartInternal:s,handleDragEndInternal:l}}function vt(e){let n=Dn.useContext(be)?.registerRenderPane;Dn.useEffect(()=>{n&&e&&n(e);},[n,e]);}function de(){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.tabIds.includes(t)){let o=e.tabIds.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,tabIds:o,activeTabId:i,tabsMetadata:Object.keys(a).length>0?a: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:de(),tabIds:[o],activeTabId:o}:o;if(e.type==="pane"){if(e.id===t){let i=typeof o=="string"?{type:"pane",id:de(),tabIds:[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:ye(e.first,t,n,r,o)||e.first,second:ye(e.second,t,n,r,o)||e.second}}function un(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:de(),tabIds:[n],activeTabId:n,tabsMetadata:r?{[n]:r}:void 0};let o=t?K(e,t):null;if(o&&o.type==="pane"){let s=function(l){if(l.type==="pane"&&l.id===t){let u=[...l.tabIds];u.includes(n)||u.push(n);let c=l.tabsMetadata;return r&&(c={...l.tabsMetadata,[n]:r}),{...l,tabIds:u,activeTabId:n,tabsMetadata:c}}return l.type==="split"?{...l,first:s(l.first),second:s(l.second)}:l};return s(e)}let i={type:"pane",id:de(),tabIds:[n],activeTabId:n,tabsMetadata:r?{[n]:r}:void 0};return un(e,i)}function Te(e,t,n){return e===null?null:e===t?{...e,splitPercentage:n}:e.type==="split"?{...e,first:Te(e.first,t,n)||e.first,second:Te(e.second,t,n)||e.second}:e}function K(e,t){return e===null?null:e.type==="pane"?e.id===t?e:null:e.type==="split"?K(e.first,t)??K(e.second,t):null}function B(e,t){return e===null?null:e.type==="pane"?e.tabIds.includes(t)?e:null:e.type==="split"?B(e.first,t)??B(e.second,t):null}function Tt(e,t){return K(e,t)??B(e,t)}function Pt(e,t){let n=B(e,t);if(!n)return null;let r=n.tabIds.indexOf(t);return {id:t,paneId:n.id,isActive:n.activeTabId===t,index:r,metadata:n.tabsMetadata?.[t]}}function Rt(e,t){return B(e,t)?.tabsMetadata?.[t]}function xt(e,t){let n=K(e,t);return n?.tabsMetadata?.[n.activeTabId]}function Oe(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.tabIds.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:Oe(e.first,t,n)??e.first,second:Oe(e.second,t,n)??e.second}:e}function Fe(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:Fe(e.first,t,n)??e.first,second:Fe(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 yt(e,t,n){if(e===null)return null;let o=B(e,t)?.tabsMetadata?.[t],i=ue(e,t);if(i===null)return {type:"pane",id:de(),tabIds:[t],activeTabId:t,tabsMetadata:o?{[t]:o}:void 0};function a(s){if(s.type==="pane"){if(s.id===n){let l=[...s.tabIds];l.includes(t)||l.push(t);let u={...s.tabsMetadata};return o&&(u[t]=o),{...s,tabIds:l,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=B(e,t)?.tabsMetadata?.[t],a=ue(e,t);if(a===null)return {type:"pane",id:de(),tabIds:[t],activeTabId:t,tabsMetadata:i?{[t]:i}:void 0};function s(l){if(l.type==="pane"){if(l.tabIds.includes(n)){let c=[...l.tabIds].filter(P=>P!==t),f=c.indexOf(n);f<0&&(f=0),r==="after"&&(f+=1),c.splice(f,0,t);let v={...l.tabsMetadata};return i&&(v[t]=i),{...l,tabIds:c,activeTabId:t,tabsMetadata:Object.keys(v).length>0?v:void 0}}return l}return l.type==="split"?{...l,first:s(l.first),second:s(l.second)}:l}return s(a)}function me(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:l,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},v={panes:[],splitters:[]},P={panes:[],splitters:[]};if(a==="row"){let b=r*(s/100);v=me(l,t,n,b,o,`${i}-L`),P=me(u,t+b,n,r-b,o,`${i}-R`);}else {let b=o*(s/100);v=me(l,t,n,r,b,`${i}-T`),P=me(u,t,n+b,r,o-b,`${i}-B`);}return {panes:[...v.panes,...P.panes],splitters:[f,...v.splitters,...P.splitters]}}function Dt(e,t,n,r="before"){if(e===null)return null;let o=K(e,t);if(!o)return e;let i=o.tabIds,a=o.activeTabId,s=o.tabsMetadata||{},l=fe(e,t);if(l===null)return o;function u(c){if(c.type==="pane"){if(c.tabIds.includes(n)){let v=[...c.tabIds].filter(I=>!i.includes(I)),P=v.indexOf(n);P<0&&(P=0),r==="after"&&(P+=1),v.splice(P,0,...i);let b={...c.tabsMetadata};for(let I of i)s[I]&&(b[I]=s[I]);return {...c,tabIds:v,activeTabId:a,tabsMetadata:Object.keys(b).length>0?b:void 0}}return c}return c.type==="split"?{...c,first:u(c.first),second:u(c.second)}:c}return u(l)}function Ct(e,t,n,r){if(!((t==="tab"||t==="pane")&&n&&e.includes(n))||!r)return -1;let a=e.indexOf(n);return r==="before"?a:a+1}function pn(e){let{initialLayout:t,layout:n,onChange:r,fullscreenPaneId:o,onFullscreenChange:i,locked:a=false}=e,[s,l]=Dn.useState(()=>n!==void 0?n:t??null),[u,c]=Dn.useState(()=>n!==void 0?n:t??null),[f,v]=Dn.useState(()=>we(n!==void 0?n:null)),[P,b]=Dn.useState(o||null),[I,M]=Dn.useState(a),[A,h]=Dn.useState(null),[k,y]=Dn.useState(null),[E,S]=Dn.useState(null),D=Dn.useRef(null),F=Dn.useCallback(d=>{D.current=d;},[]),$=Dn.useRef(s);$.current=s;let X=Dn.useRef(r);X.current=r;let W=Dn.useRef(i);W.current=i;let Q=Dn.useCallback(d=>{b(d),W.current?.(d);},[]);if(Dn.useEffect(()=>{M(a);},[a]),Dn.useEffect(()=>{o!==void 0&&b(o);},[o]),n!==void 0){let d=we(n);d!==f&&(v(d),l(n),c(n));}let C=Dn.useCallback(d=>(...g)=>{let w=$.current,z=d(w,...g);we(w)!==we(z)&&($.current=z,l(z),c(z),X.current?.(z));},[]),ee=Dn.useCallback(C((d,g)=>typeof g=="function"?g(d):g),[C]),re=Dn.useCallback(d=>{c(g=>typeof d=="function"?d(g):d);},[]),Z=Dn.useCallback(d=>{b(null),W.current?.(null),h(null),y(null),S(null),ee(d),c(()=>typeof d=="function"?d($.current):d);},[ee]),_=Dn.useCallback(C((d,g)=>fe(d,g)),[C]),H=Dn.useCallback(C((d,g,w,z)=>{let q=ue(d,g)??d;return ht(q,w,g,z)}),[C]),m=Dn.useCallback(C((d,g,w,z,q)=>{let oe=K(d,g)??B(d,g);if(!oe)return d;let O=K(d,q)??B(d,q)??{type:"pane",id:q,tabIds:[q],activeTabId:q},ie=fe(d,O.id);return ye(ie,oe.id,w,z,O)}),[C]),N=Dn.useCallback(C((d,g,w)=>Te(d,g,w)),[C]),p=Dn.useCallback(C((d,g,w)=>Oe(d,g,w)),[C]),te=Dn.useCallback(C((d,g,w)=>{let z=K(d,g)??B(d,g);return z?Fe(d,z.id,w):d}),[C]),R=Dn.useCallback(C((d,g,w)=>{let z=K(d,g)??B(d,g);return z?De(d,z.id,w):d}),[C]),L=Dn.useCallback(C((d,g,w)=>{let z=K(d,w)??B(d,w);return z?yt(d,g,z.id):d}),[C]),ce=Dn.useCallback(C((d,g,w,z)=>Be(d,g,w,z)),[C]),J=Dn.useCallback(C((d,g)=>ue(d,g)),[C]),Y=Dn.useCallback(d=>K($.current,d),[]),G=Dn.useCallback(d=>B($.current,d),[]),ne=Dn.useCallback(d=>Pt($.current,d),[]),T=Dn.useCallback(d=>Rt($.current,d),[]),x=Dn.useCallback(d=>xt($.current,d),[]);return {layout:s,setLayout:Z,_internalSetLayout:re,renderingLayout:u,fullscreenPaneId:P,setFullscreenPaneId:Q,locked:I,setLocked:M,activeId:A,setActiveId:h,activeType:k,setActiveType:y,dismissIntentId:E,setDismissIntentId:S,containerRef:D,setContainerRef:F,removePane:_,addTab:H,updateMetadata:p,updatePaneLock:te,selectTab:R,mergeTab:L,moveTab:ce,removeTab:J,splitPane:m,updateSplitPercentage:N,findPaneById:Y,findPaneContainingTab:G,findTabById:ne,getTabMetadata:T,getActiveTabMetadata:x}}var fn=()=>{let e=ae(),t=$e();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 We=class extends core.PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},Ue=class extends core.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};var St=e=>{let n=e.active.id.toString().startsWith("tab-header-"),o=core.pointerWithin(e);if(o.length>0)return [...o].sort((a,s)=>{let l=a.id.toString(),u=s.id.toString(),c=l.startsWith("tab-drop-"),f=u.startsWith("tab-drop-");if(c&&!f)return -1;if(!c&&f)return 1;let v=l.startsWith("drop-root-"),P=u.startsWith("drop-root-");return v&&!P?-1:!v&&P?1:0});if(n){let i=e.droppableContainers.filter(a=>a.id.toString().startsWith("tab-drop-"));return core.closestCenter({...e,droppableContainers:i})}return []};function Ne(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 Mt(e){let{layout:t,_internalSetLayout:n,setLayout:r,activeId:o,setActiveId:i,activeType:a,setActiveType:s,dismissIntentId:l,setDismissIntentId:u,setOverTabId:c,setOverTabPosition:f,containerRef:v,dragActivationDistance:P,enableDragToDismiss:b,dismissThreshold:I,onRemove:M,onDragStart:A,onDragEnd:h,onDismissIntentChange:k,removeTab:y,removePane:E}=e,S=Dn.useRef(null),D=pt(o),F=Dn.useRef(null),[$,X]=Dn.useState(false);return ft($),{sensors:core.useSensors(core.useSensor(We,{activationConstraint:{distance:P}}),core.useSensor(Ue,{activationConstraint:{delay:250,tolerance:5}})),collisionDetection:St,onDragStart:Z=>{let _=Z.active.id.toString(),H=_.startsWith("tab-header-"),m=H?_.substring(11):_;i(m),s(H?"tab":"pane"),c(null),f(null);let N=Z.activatorEvent;D.current=Ne(N),b&&v.current?S.current=v.current.getBoundingClientRect():S.current=null;let p=t;if(H){let R=B(t,m);R&&(p=De(t,R.id,m)||t);}F.current=p;let te=H?ue(p,m):fe(p,m);n(te),A&&A(m);},onDragMove:Z=>{let{over:_}=Z,H=_?.id.toString()||"",m=H.startsWith("drop-locked-");X(T=>T===m?T:m);let N=Z.active.id.toString(),p=N.startsWith("tab-header-"),te=p?N.substring(11):N,R=H.match(/^tab-drop-(.+)$/);if(R&&_&&(p||a==="pane")){let[,T]=R;if(te!==T){let x="before",se=_.rect,d=Z.activatorEvent,g=null;if(D.current)g=D.current.x;else {let w=Ne(d);w&&(g=w.x+Z.delta.x);}if(g!==null){let w=se.left+se.width/2;g>w&&(x="after");}c(w=>w===T?w:T),f(w=>w===x?w:x);}else c(x=>x===null?x:null),f(x=>x===null?x:null);}else c(T=>T===null?T:null),f(T=>T===null?T:null);if(!b)return;let L=S.current;if(!L){l!==null&&(u(null),k?.(null));return}let ce=Z.activatorEvent,J=null,Y=null;if(D.current)J=D.current.x,Y=D.current.y;else {let T=Ne(ce);T&&(J=T.x+Z.delta.x,Y=T.y+Z.delta.y);}let G=0;if(J!==null&&Y!==null){let T=0,x=0;J<L.left?T=L.left-J:J>L.right&&(T=J-L.right),Y<L.top?x=L.top-Y:Y>L.bottom&&(x=Y-L.bottom),G=Math.sqrt(T*T+x*x);}else {let T=Z.active.rect.current.translated;if(T){let x=T.left+T.width/2,se=T.top+T.height/2,d=0,g=0;x<L.left?d=L.left-x:x>L.right&&(d=x-L.right),se<L.top?g=L.top-se:se>L.bottom&&(g=se-L.bottom),G=Math.sqrt(d*d+g*g);}}G>I?l!==te&&(u(te),k?.(te)):l!==null&&(u(null),k?.(null));},onDragEnd:Z=>{i(null),s(null),X(false),c(null),f(null);let{active:_,over:H}=Z,m=_.id.toString(),N=m.startsWith("tab-header-"),p=N?m.substring(11):m,te=b&&l===p;u(null),k?.(null),S.current=null;let R=F.current||t;if(F.current=null,te){M?M(p):N?y(p):E(p),h&&h(p,null,null);return}if(!H){n(R),h&&h(p,null,null);return}let L=H.id.toString();if(L.startsWith("drop-locked-")){n(R),h&&h(p,null,null);return}let ce=L.match(/^tab-drop-(.+)$/);if(ce){let[,q]=ce;if(N)if(p!==q){let oe="before",O=H.rect,ie=Z.activatorEvent,j=null;if(D.current)j=D.current.x;else {let U=Ne(ie);U&&(j=U.x+Z.delta.x);}if(j!==null){let U=O.left+O.width/2;j>U&&(oe="after");}let pe=Be(R,p,q,oe);r(pe),h&&h(p,q,{type:"move",position:"center"});}else n(R),h&&h(p,null,null);else {let oe="before",O=H.rect,ie=Z.activatorEvent,j=null;if(D.current)j=D.current.x;else {let U=Ne(ie);U&&(j=U.x+Z.delta.x);}if(j!==null){let U=O.left+O.width/2;j>U&&(oe="after");}let pe=Dt(R,p,q,oe);r(pe),h&&h(p,q,{type:"move",position:"center"});}return}let J=L.match(/^drop-root-(1\/4|1\/3)-(top|bottom|left|right|start|end)$/);if(J){let[,q,oe]=J,O=oe;O==="start"&&(O="left"),O==="end"&&(O="right");let ie=N?ue(R,p):fe(R,p),j;if(N){let U=B(R,p)?.tabsMetadata?.[p];j={type:"pane",id:de(),tabIds:[p],activeTabId:p,tabsMetadata:U?{[p]:U}:void 0};}else j=K(R,p)??{type:"pane",id:de(),tabIds:[p],activeTabId:p};if(ie===null)r(j);else {let pe=O==="left"||O==="right",U=O==="left"||O==="top",he=50;q==="1/4"?he=U?25:75:q==="1/3"&&(he=U?100/3:200/3),r({type:"split",direction:pe?"row":"column",first:U?j:ie,second:U?ie:j,splitPercentage:he});}h&&h(p,"root",{type:"split",direction:O==="left"||O==="right"?"row":"column",position:O});return}let Y=L.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!Y){n(R),h&&h(p,null,null);return}let[,G,ne]=Y,T=N?B(R,p):K(R,p),x=T&&T.id===ne,se=T&&T.tabIds.length===1;if(p===ne||x&&se){n(R),h&&h(p,null,null);return}let d=G==="left"||G==="right"?"row":"column",g;if(N){let oe=B(R,p)?.tabsMetadata?.[p];g={type:"pane",id:de(),tabIds:[p],activeTabId:p,tabsMetadata:oe?{[p]:oe}:void 0};}else g=K(R,p)??{type:"pane",id:de(),tabIds:[p],activeTabId:p};let w=N?ue(R,p):fe(R,p),z=ye(w,ne,d,G,g);r(z),h&&h(p,ne,{type:"split",direction:d,position:G});},onDragCancel:()=>{i(null),s(null),X(false),c(null),f(null),u(null),k?.(null),S.current=null;let Z=F.current||t;F.current=null,n(Z),Z!==t&&r(Z);}}}function Lt({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]=Dn.useState(false);Dn.useEffect(()=>{if(r){let s=localStorage.getItem(o);if(s)try{let l=JSON.parse(s);l&&n(l);}catch(l){console.error("Failed to parse persisted zeugma layout",l);}}a(true);},[r,o,n]),Dn.useEffect(()=>{r&&i&&(t?localStorage.setItem(o,JSON.stringify(t)):localStorage.removeItem(o));},[r,o,t,i]);}var Zt=({activeId:e,render:t,className:n})=>{let r=Dn.useRef(null);return Dn.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 kt=Dn__default.default.memo(({tabDetails:e,target:t,renderWidget:n})=>{let{id:r}=e,[o,i]=Dn.useState(false),a=Dn.useRef(null);if(Dn.useEffect(()=>{i(true);},[]),Dn.useEffect(()=>{if(!o||!a.current)return;let l=a.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]),Dn.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 l=o.current||i;if(l)return jsxRuntime.jsx("div",{className:s.paneDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:l(e)})}else if(t==="tab"){let l=o.current||i;if(l)return jsxRuntime.jsx("div",{className:s.tabDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:l(e)});let u=a.current[e];if(u){let c=s.tab?typeof s.tab=="function"?s.tab(e):s.tab:"";return jsxRuntime.jsx("div",{className:`${s.tabDragPreview||""} ${c}`.trim(),style:{display:"inline-flex",position:"relative",pointerEvents:"none",overflow:"hidden"},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:l,onResizeStart:u,onResizeEnd:c,parentLeft:f,parentTop:v,parentWidth:P,parentHeight:b}){let{onResizeStart:I,onResize:M,onResizeEnd:A,minSplitPercentage:h=5,maxSplitPercentage:k=95,locked:y=false}=ae();return Dn.useCallback(E=>{if(y)return;E.preventDefault();let S=e.current;if(!S)return;u&&u(),I&&I(s);let D=S.getBoundingClientRect(),F=E.clientX,$=E.clientY,X=r,W=E.currentTarget,Q=D.left+D.width*(f/100),C=D.top+D.height*(v/100),ee=D.width*(P/100),re=D.height*(b/100),_=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(m=>m!==W&&m.getAttribute("data-direction")===n).map(m=>{let N=m.getBoundingClientRect();return t?N.left+N.width/2:N.top+N.height/2}),H=X;ut({cursor:t?"col-resize":"row-resize",resizerEl:W,onMove:m=>{let N=t?(m.clientX-F)/ee*100:(m.clientY-$)/re*100,p=X+N,te=t?Q+(ee-o)*(p/100)+o/2:C+(re-o)*(p/100)+o/2,R=1/0,L=null;for(let G of _){let ne=Math.abs(te-G);ne<i&&ne<R&&(R=ne,L=G);}let ce=p;L!==null&&(ce=t?(L-o/2-Q)/(ee-o)*100:(L-o/2-C)/(re-o)*100);let J=Math.max(h,Math.min(k,ce));H=J;let Y=Te(a,s,J);if(Y){let{panes:G,splitters:ne}=me(Y),T=e.current;if(T){for(let x of G)T.style.setProperty(`--pane-left-${x.paneId}`,`${x.left}%`),T.style.setProperty(`--pane-top-${x.paneId}`,`${x.top}%`),T.style.setProperty(`--pane-width-${x.paneId}`,`${x.width}%`),T.style.setProperty(`--pane-height-${x.paneId}`,`${x.height}%`);for(let x of ne)T.style.setProperty(`--splitter-pos-${x.id}`,`${x.direction==="row"?x.left:x.top}%`);}}M&&M(s,J);},onEnd:()=>{let m=Te(a,s,H),N=e.current;if(N){let{panes:p,splitters:te}=me(m);for(let R of p)N.style.removeProperty(`--pane-left-${R.paneId}`),N.style.removeProperty(`--pane-top-${R.paneId}`),N.style.removeProperty(`--pane-width-${R.paneId}`),N.style.removeProperty(`--pane-height-${R.paneId}`);for(let R of te)N.style.removeProperty(`--splitter-pos-${R.id}`);}l(m),c&&c(),A&&A(s,H);}});},[e,t,n,r,o,i,a,s,l,u,c,I,M,A,h,k,f,v,P,b])}var $t=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:r})=>{let{renderingLayout:o,setLayout:i,classNames:a,locked:s}=ae(),[l,u]=Dn.useState(false),{currentNode:c,direction:f,left:v,top:P,width:b,height:I,parentLeft:M,parentTop:A,parentWidth:h,parentHeight:k}=e,y=f==="row",E=nt({containerRef:r,isRow:y,direction:f,splitPercentage:c.splitPercentage,resizerSize:t,snapThreshold:n,layout:o,currentNode:c,onLayoutChange:i,onResizeStart:()=>u(true),onResizeEnd:()=>u(false),parentLeft:M,parentTop:A,parentWidth:h,parentHeight:k}),S=y?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${v}%) - ${t/2}px)`,top:`calc(${P}% + ${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(${v}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${P}%) - ${t/2}px)`,width:`calc(${b}% - ${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":l||void 0,style:S,onPointerDown:E,role:"separator","aria-valuenow":c.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},At=Dn__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:l,snapThreshold:u,locked:c,classNames:f,resizerSize:v}=ae(),P=r!==void 0?r:u??8,b=n!==void 0?n:v??4,I=t!==void 0?t:o,M=Dn.useRef(null),{panes:A,splitters:h}=Dn.useMemo(()=>I?me(I):{panes:[],splitters:[]},[I]);if(!I&&t!==void 0)return null;let k=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[A.map(y=>{let E=l===y.paneId;return jsxRuntime.jsx("div",{style:{position:"absolute",left:E?"0%":`var(--pane-left-${y.paneId}, ${y.left}%)`,top:E?"0%":`var(--pane-top-${y.paneId}, ${y.top}%)`,width:E?"100%":`var(--pane-width-${y.paneId}, ${y.width}%)`,height:E?"100%":`var(--pane-height-${y.paneId}, ${y.height}%)`,overflow:"hidden",zIndex:E?20:1,display:l&&!E?"none":"block",padding:E?"0px":`${b/2}px`,boxSizing:"border-box"},children:jsxRuntime.jsx(At,{paneId:y.paneId,renderPane:e})},y.paneId)}),!l&&h.map(y=>jsxRuntime.jsx($t,{splitter:y,resizerSize:b,snapThreshold:P,containerRef:M},y.id))]});if(t===void 0){let y=i!==null&&i===a,E=D=>{s(D),M.current=D;},S=`${f.dashboard||""} ${y&&f.dashboardDismissActive||""} ${c&&f.dashboardLocked||""}`.trim();return jsxRuntime.jsxs("div",{ref:E,className:S,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[k(),i!==null&&!c&&jsxRuntime.jsx(Ft,{activeClassName:f.rootDropPreview??f.dropPreview})]})}return jsxRuntime.jsx("div",{ref:M,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:k()})};var Hn=e=>{let{controller:t,children:n,renderDragOverlay:r,classNames:o={},renderPane:i,resizerSize:a,dragActivationDistance:s=8,snapThreshold:l=8,minSplitPercentage:u=5,maxSplitPercentage:c=95,enableDragToDismiss:f=false,dismissThreshold:v=60,onRemove:P,onDragStart:b,onDragEnd:I,onResizeStart:M,onResize:A,onResizeEnd:h,onDismissIntentChange:k,persist:y=false}=e,E=t,{layout:S,setLayout:D,_internalSetLayout:F,renderingLayout:$,fullscreenPaneId:X,setFullscreenPaneId:W,locked:Q,setLocked:C,findPaneById:ee,findPaneContainingTab:re,findTabById:Z,getTabMetadata:_,getActiveTabMetadata:H,activeId:m,setActiveId:N,activeType:p,setActiveType:te,dismissIntentId:R,setDismissIntentId:L,containerRef:ce,setContainerRef:J,removePane:Y,addTab:G,updateMetadata:ne,updatePaneLock:T,selectTab:x,mergeTab:se,removeTab:d,splitPane:g,updateSplitPercentage:w,moveTab:z}=E;Lt({persist:y,layout:S,setLayout:D});let{portalTargets:q,registerPortalTarget:oe,registerRenderCallback:O,renderCallbacksRef:ie,registerRenderPane:j,renderPaneRef:pe,registerTabHeader:U,tabHeadersRef:he,activeIdRef:Se}=gt(),{overTabId:it,setOverTabId:jt,overTabPosition:lt,setOverTabPosition:Kt,handleDragStartInternal:Qt,handleDragEndInternal:en}=bt({onDragStart:b,onDragEnd:I}),tn=Mt({layout:S,_internalSetLayout:F,setLayout:D,activeId:m,setActiveId:N,activeType:p,setActiveType:te,dismissIntentId:R,setDismissIntentId:L,setOverTabId:jt,setOverTabPosition:Kt,containerRef:ce,dragActivationDistance:s,enableDragToDismiss:f,dismissThreshold:v,onRemove:P,onDragStart:Qt,onDragEnd:en,onDismissIntentChange:k,removeTab:d,removePane:Y}),_e=Dn.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=Dn.useCallback((ge,ke)=>{h&&h(ge,ke);},[h]),nn=Dn.useMemo(()=>({layout:S,renderingLayout:$,setLayout:D,activeId:m,activeType:p,dismissIntentId:R,setContainerRef:J,fullscreenPaneId:X,classNames:_e,onRemove:P,onFullscreenChange:W,snapThreshold:l,onResizeStart:M,onResize:A,onResizeEnd:ct,minSplitPercentage:u,maxSplitPercentage:c,locked:Q,setLocked:C,findPaneById:ee,findPaneContainingTab:re,findTabById:Z,getTabMetadata:_,getActiveTabMetadata:H,renderPane:i,resizerSize:a}),[S,$,m,p,R,J,X,_e,P,W,l,M,A,u,c,D,ct,Q,C,ee,re,Z,_,H,i,a]),on=Dn.useMemo(()=>({overTabId:it,overTabPosition:lt}),[it,lt]),rn=Dn.useMemo(()=>({removePane:Y,addTab:G,updateMetadata:ne,updatePaneLock:T,selectTab:x,mergeTab:se,removeTab:d,setFullscreenPaneId:W,setLocked:C,splitPane:g,updateSplitPercentage:w,moveTab:z}),[Y,G,ne,T,x,se,d,W,C,g,w,z]),an=mt(S),sn=Dn.useMemo(()=>({registerPortalTarget:oe,registerRenderCallback:O,renderCallbacksRef:ie,registerRenderPane:j,renderPaneRef:pe,registerTabHeader:U,tabHeadersRef:he,activeIdRef:Se}),[oe,O,ie,j,pe,U,he,Se]);return Se&&(Se.current=m),jsxRuntime.jsx(Ke.Provider,{value:rn,children:jsxRuntime.jsx(je.Provider,{value:nn,children:jsxRuntime.jsx(Qe.Provider,{value:on,children:jsxRuntime.jsxs(be.Provider,{value:sn,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",...tn,children:n}),m&&p&&jsxRuntime.jsx(Zt,{activeId:m,render:ge=>jsxRuntime.jsx("div",{style:{transition:"transform 150ms cubic-bezier(0.2, 0, 0, 1)",transform:ge===R?"scale(0.8)":"scale(1)",transformOrigin:"top left"},children:jsxRuntime.jsx(zt,{activeId:ge,activeType:p,dismissIntentId:R,renderDragOverlay:r,renderPaneRef:pe,renderPane:i,tabHeadersRef:he,classNames:_e})}),className:`${o.dragOverlay||""} ${m===R&&o.dismissPreview||""}`.trim()}),jsxRuntime.jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:an.map(ge=>{let ke=q[ge],dt=Z(ge);return dt?jsxRuntime.jsx(kt,{tabDetails:dt,target:ke||null,renderWidget:ie.current[ge]},ge):null})})]})})})})},On=({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})},Fn=e=>{let{children:t,...n}=e,{controller:r}=e;if(!r)throw new Error("Zeugma component requires a controller.");return jsxRuntime.jsx(Hn,{...e,children:t!==void 0?t:jsxRuntime.jsx(On,{...n})})};var Wn={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"}}},Un={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"}}},Xn=({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",...Un[n][t]};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:o,style:Wn[n][t]}),i&&jsxRuntime.jsx("div",{className:r,style:a})]})},Ft=({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(Xn,{id:n.id,fraction:n.fraction,edge:n.edge,activeClassName:e},n.id))});var Je=Dn.createContext(null);var Gn={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"}},jn={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:Gn[t]}),o&&jsxRuntime.jsx("div",{className:n,style:jn[t]})]})};var Vt=({children:e,className:t,style:n})=>{let r=Dn.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 io=Dn.createContext(void 0);var Ze=({id:e,locked:t=false,children:n,className:r,style:o})=>{let{locked:i,classNames:a={},fullscreenPaneId:s}=ae(),{overTabId:l}=Ae(),u=Dn.useContext(be);Dn.useEffect(()=>(u?.registerTabHeader&&u.registerTabHeader(e,n),()=>{u?.registerTabHeader&&u.activeIdRef?.current!==e&&u.registerTabHeader(e,()=>null);}),[e,n,u]);let c=Dn.useContext(at),f=t||i||(c?.locked??false)||s!==null,{attributes:v,listeners:P,setNodeRef:b,isDragging:I}=core.useDraggable({id:`tab-header-${e}`,disabled:f}),{setNodeRef:M,isOver:A}=core.useDroppable({id:`tab-drop-${e}`,disabled:f}),h=ee=>{b(ee),M(ee);},k=A&&l===e,y=c?.tabIds||[],E=y.indexOf(e),S=c?.activeTabId,F=E>0&&e!==S&&y[E-1]!==S?jsxRuntime.jsx("div",{className:a.tabSeparator}):null,$=c?c.activeTabId===e:false,X=c?.tabsMetadata?.[e],W=Dn.useCallback(()=>{c?.selectTab(e);},[c,e]),Q=Dn.useCallback(()=>{c?.removeTab(e);},[c,e]),C=Dn.useMemo(()=>({tabId:e,isActive:$,isDragging:I,isOver:k,metadata:X,locked:f,selectTab:W,removeTab:Q}),[e,$,I,k,X,f,W,Q]);return jsxRuntime.jsx(io.Provider,{value:C,children:jsxRuntime.jsxs("div",{ref:h,id:`tab-header-${e}`,className:r,style:{display:"inline-flex",position:"relative",cursor:f?"default":"grab",...o},...f?{}:P,...f?{}:v,children:[F,n({isDragging:I,isOver:k})]})})};var at=Dn.createContext(void 0);var Jt=(e,t)=>typeof e=="function"?e(t):e,st=({tabIds:e,activeTabId:t,locked:n,tabsMetadata:r,selectTab:o,removeTab:i,renderTab:a,classNames:s,styles:l})=>{let u=Dn.useContext(Ye),c=e??u?.tabIds??[],f=t??u?.activeTabId??"",v=n??u?.locked??false,P=r??u?.tabsMetadata,b=o??u?.selectTab??(()=>{}),I=i??u?.removeTab??(()=>{}),{classNames:M={},activeType:A}=ae(),{overTabId:h,overTabPosition:k}=Ae(),y=Dn.useMemo(()=>({tabIds:c,activeTabId:f,locked:v,tabsMetadata:P,selectTab:b,removeTab:I}),[c,f,v,P,b,I]),E=Ct(c,A,h,k);return jsxRuntime.jsx(at.Provider,{value:y,children:jsxRuntime.jsxs("div",{className:s?.container,style:{display:"flex",alignItems:"center",height:"100%",...l?.container},children:[c.map((S,D)=>{let F=P?.[S],$=Jt(s?.tab,S),X=Jt(l?.tab,S),W=D===E;return jsxRuntime.jsxs(Dn__default.default.Fragment,{children:[W&&M.tabDropPreview&&jsxRuntime.jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsxRuntime.jsx("div",{className:M.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:D===0?"none":"translateX(-50%)"}})}),jsxRuntime.jsx(Ze,{id:S,locked:v,className:$,style:X,children:({isDragging:Q,isOver:C})=>a({id:S,paneId:u?.id??"",isActive:S===f,index:D,isDragging:Q,isOver:C,metadata:F,onSelect:()=>b(S),onRemove:()=>I(S)})})]},S)}),E===c.length&&M.tabDropPreview&&jsxRuntime.jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsxRuntime.jsx("div",{className:M.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:"translateX(-100%)"}})})]})})};st.Tab=Ze;var qt=({className:e,style:t,children:n})=>jsxRuntime.jsx("div",{className:e,style:t,children:n});var Ye=Dn.createContext(void 0),Gt=()=>{let e=Dn.useContext(Ye);if(!e)throw new Error("usePaneContext must be used within a Pane component");return e},To=({children:e,className:t,style:n})=>{let{activeTabId:r}=Gt(),{classNames:o}=ae(),i=Dn.useRef(null),a=Dn.useContext(be);if(!a)throw new Error("PaneContent must be used within a Zeugma provider");let{registerPortalTarget:s,registerRenderCallback:l}=a,u=Dn.useMemo(()=>typeof e=="function"?e:()=>e,[e]);return l(r,u),Dn.useEffect(()=>{let c=i.current;return s(r,c),()=>{s(r,null,c);}},[r,s]),jsxRuntime.jsx("div",{ref:i,id:`zeugma-tab-target-${r}`,className:`${o.tabContentWrapper||""} ${t||""}`.trim(),style:{height:"100%",width:"100%",...n}})},Ie=({id:e,children:t,style:n,locked:r=false})=>{let{layout:o,renderingLayout:i,activeId:a,activeType:s,classNames:l,fullscreenPaneId:u,onFullscreenChange:c,locked:f}=ae(),{removePane:v,updateMetadata:P,selectTab:b,removeTab:I}=$e(),M=Dn.useMemo(()=>{if(s==="tab"&&e===a){let p=B(o,e)?.tabsMetadata?.[e];return {type:"pane",id:e,tabIds:[e],activeTabId:e,tabsMetadata:p?{[e]:p}:void 0}}return Tt(e===a?o:i,e)},[o,i,e,a,s]),A=M?.id??e,h=M?.tabIds??[e],k=M?.activeTabId??e,y=M?.tabsMetadata,E=y?.[e],S=M?.locked??false,D=r||S,F=f||D||u!==null,$=f||D||u!==null,X=a!==null&&a!==e&&(!h.includes(a)||h.length>1)&&!$,{attributes:W,listeners:Q,setNodeRef:C}=core.useDraggable({id:e,disabled:F}),ee=a!==null&&h.includes(a),re=u===e,Z=Dn.useMemo(()=>({isDragging:ee,isFullscreen:re,toggleFullscreen:()=>c?.(re?null:e),remove:()=>{re&&c?.(null),v(A);},metadata:E,updateMetadata:m=>{P(e,m);},locked:F,tabIds:h,activeTabId:k,selectTab:m=>b(A,m),removeTab:m=>{re&&m===k&&c?.(null),I(m);},tabsMetadata:y,updateTabMetadata:(m,N)=>{P(m,N);}}),[ee,re,c,e,I,E,P,F,h,k,b,A,y]),_=Dn.useMemo(()=>F?{disabled:true}:{...Q,...W},[Q,W,F]),H=`${l.pane||""} ${D&&l.paneLocked||""}`.trim();return jsxRuntime.jsx(Ye.Provider,{value:{id:e,...Z},children:jsxRuntime.jsx(Je.Provider,{value:_,children:jsxRuntime.jsxs("div",{ref:C,id:e,className:H,style:{position:"relative",width:"100%",height:"100%",...n},children:[t,X&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:["top","bottom","left","right"].map(m=>jsxRuntime.jsx(rt,{id:`drop-${m}-${e}`,position:m,activeClassName:l.dropPreview},m))}),a!==null&&a!==e&&$&&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:l.lockedPreview||""})})]})})})};Ie.Content=To;Ie.DragHandle=Vt;Ie.Tabs=st;Ie.Tab=Ze;Ie.Controls=qt;exports.Pane=Ie;exports.PaneTree=ot;exports.Zeugma=Fn;exports.usePaneContext=Gt;exports.useResizer=nt;exports.useZeugma=pn;exports.useZeugmaContext=fn;//# sourceMappingURL=index.cjs.map
|
|
10
10
|
//# sourceMappingURL=index.cjs.map
|