react-zeugma 6.9.8 → 6.9.9

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/devtools.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var a=new Map;function i(r){let e=a.get(r);return e||(e={mounts:0,renders:0,listeners:new Set},a.set(r,e)),e}function N(r,e){let n=i(r);return n.listeners.add(e),()=>{n.listeners.delete(e);}}function g(r){let e=a.get(r);e&&e.listeners.forEach(n=>n());}function v(r){let e=a.get(r);e&&(e.mounts=0,e.renders=0,g(r));}function S(){a.clear();}function p(r,e){let n=react.useId(),c=typeof r=="string"?{id:r,...e}:r||{},{id:t=n,logToConsole:u=false,disabled:o=false}=c,s=react.useRef(0),l=react.useRef(false),[,R]=react.useState(0);if(o||(s.current+=1),react.useEffect(()=>{if(o)return;let C=N(t,()=>{R(P=>P+1);}),b=i(t);return b.mounts+=1,l.current=true,u&&console.log(`[DevTools:${t}] Mounted: ${b.mounts} | Rendered: ${s.current}`),g(t),()=>{l.current=false,C();}},[t,o,u]),!o){let C=i(t);C.renders=Math.max(C.renders,s.current);}let m=react.useCallback(()=>{s.current=0,v(t);},[t]);return o?{mounts:0,renders:0,reset:m}:{mounts:i(t).mounts,renders:s.current,reset:m}}function G({id:r,className:e,style:n,logToConsole:c=false,disabled:t=false}){let{mounts:u,renders:o}=p(r,{logToConsole:c,disabled:t});return t?null:jsxRuntime.jsxs("div",{className:e,style:n,children:[jsxRuntime.jsxs("span",{children:["M: ",jsxRuntime.jsx("strong",{children:u})]}),jsxRuntime.jsx("span",{children:"|"}),jsxRuntime.jsxs("span",{children:["R: ",jsxRuntime.jsx("strong",{children:o})]})]})}function I({id:r,label:e,children:n,className:c,footerClassName:t,style:u,logToConsole:o=false,disabled:s=false}){let l=e||r||"widget",{mounts:R,renders:m}=p(r,{logToConsole:o,disabled:s});return s?jsxRuntime.jsx(jsxRuntime.Fragment,{children:n}):jsxRuntime.jsxs("div",{className:c,style:u,children:[n&&jsxRuntime.jsx("div",{className:"flex-1 overflow-hidden relative min-h-0",children:n}),jsxRuntime.jsxs("div",{className:t,children:[jsxRuntime.jsx("span",{className:"truncate",children:l}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsxs("span",{children:["Mounts: ",jsxRuntime.jsx("strong",{className:"counter-mounts",children:R})]}),jsxRuntime.jsx("span",{children:"|"}),jsxRuntime.jsxs("span",{children:["Renders: ",jsxRuntime.jsx("strong",{className:"counter-renders",children:m})]})]})]})]})}exports.RenderCounterBadge=G;exports.RenderCounterFooter=I;exports.clearAllCounters=S;exports.resetCounterRecord=v;exports.useRenderCounter=p;//# sourceMappingURL=devtools.cjs.map
1
+ 'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var c=new Map;function p(r){let e=c.get(r);return e||(e={mounts:0,renders:0,listeners:new Set},c.set(r,e)),e}function w(r,e){let n=p(r);return n.listeners.add(e),()=>{n.listeners.delete(e);}}function g(r){let e=c.get(r);e&&e.listeners.forEach(n=>n());}function y(r){let e=c.get(r);e&&(e.mounts=0,e.renders=0,g(r));}function M(){c.clear();}function a(r,e){let n=react.useId(),i=typeof r=="string"?{id:r,...e}:r||{},{id:t=n,logToConsole:u=false,disabled:o=false}=i,s=react.useRef(0),f=react.useRef(false),[,R]=react.useState(0);if(o||(s.current+=1),react.useEffect(()=>{if(o)return;let C=w(t,()=>{R(S=>S+1);}),b=p(t);return b.mounts+=1,f.current=true,u&&console.log(`[DevTools:${t}] Mounted: ${b.mounts} | Rendered: ${s.current}`),g(t),()=>{f.current=false,C();}},[t,o,u]),!o){let C=p(t);C.renders=Math.max(C.renders,s.current);}let m=react.useCallback(()=>{s.current=0,y(t);},[t]);return o?{mounts:0,renders:0,reset:m}:{mounts:p(t).mounts,renders:s.current,reset:m}}function I({id:r,className:e,style:n,logToConsole:i=false,disabled:t=false}){let{mounts:u,renders:o}=a(r,{logToConsole:i,disabled:t});return t?null:jsxRuntime.jsxs("div",{className:e,style:n,children:[jsxRuntime.jsxs("span",{children:["M: ",jsxRuntime.jsx("strong",{children:u})]}),jsxRuntime.jsx("span",{children:"|"}),jsxRuntime.jsxs("span",{children:["R: ",jsxRuntime.jsx("strong",{children:o})]})]})}function A({id:r,label:e,children:n,className:i,footerClassName:t,style:u,logToConsole:o=false,disabled:s=false}){let f=e||r||"widget",{mounts:R,renders:m}=a(r,{logToConsole:o,disabled:s});return s?jsxRuntime.jsx(jsxRuntime.Fragment,{children:n}):jsxRuntime.jsxs("div",{className:i,style:u,children:[n&&jsxRuntime.jsx("div",{style:{flex:1,height:"100%",width:"100%",minHeight:0,overflow:"hidden",position:"relative"},children:n}),jsxRuntime.jsxs("div",{className:t,children:[jsxRuntime.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:f}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[jsxRuntime.jsxs("span",{children:["Mounts: ",jsxRuntime.jsx("strong",{className:"counter-mounts",children:R})]}),jsxRuntime.jsx("span",{children:"|"}),jsxRuntime.jsxs("span",{children:["Renders: ",jsxRuntime.jsx("strong",{className:"counter-renders",children:m})]})]})]})]})}exports.RenderCounterBadge=I;exports.RenderCounterFooter=A;exports.clearAllCounters=M;exports.resetCounterRecord=y;exports.useRenderCounter=a;//# sourceMappingURL=devtools.cjs.map
2
2
  //# sourceMappingURL=devtools.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/devtools/store.ts","../src/devtools/use-render-counter.ts","../src/devtools/render-counter-badge.tsx","../src/devtools/render-counter-footer.tsx"],"names":["store","getCounterRecord","id","record","subscribeCounter","listener","notifyCounter","fn","resetCounterRecord","clearAllCounters","useRenderCounter","idOrOptions","maybeOptions","defaultAutoId","useId","options","logToConsole","disabled","renderCountRef","useRef","isMountedRef","forceUpdate","useState","useEffect","unsubscribe","c","reset","useCallback","RenderCounterBadge","className","style","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,CAAA,CAAO,SAAA,CAAU,gBAAA,CAAkB,QAAA,CAAAH,CAAAA,CAAO,CAAA,CAAA,CACrD,CAAA,CACAG,cAAAA,CAAC,MAAA,CAAA,CAAK,QAAA,CAAA,GAAA,CAAC,CAAA,CACPD,eAAAA,CAAC,MAAA,CAAA,CAAK,QAAA,CAAA,CAAA,WAAA,CACKC,cAAAA,CAAC,QAAA,CAAA,CAAO,SAAA,CAAU,iBAAA,CAAmB,QAAA,CAAAF,CAAAA,CAAQ,CAAA,CAAA,CACxD,CAAA,CAAA,CACF,CAAA,CAAA,CACF,CAAA,CAAA,CACF,CAEJ","file":"devtools.cjs","sourcesContent":["type Listener = () => void\n\ninterface GlobalCounterRecord {\n mounts: number\n renders: number\n listeners: Set<Listener>\n}\n\nconst store = new Map<string, GlobalCounterRecord>()\n\nexport function getCounterRecord(id: string): GlobalCounterRecord {\n let record = store.get(id)\n if (!record) {\n record = { mounts: 0, renders: 0, listeners: new Set() }\n store.set(id, record)\n }\n return record\n}\n\nexport function subscribeCounter(id: string, listener: Listener): () => void {\n const record = getCounterRecord(id)\n record.listeners.add(listener)\n return () => {\n record.listeners.delete(listener)\n }\n}\n\nexport function notifyCounter(id: string) {\n const record = store.get(id)\n if (record) {\n record.listeners.forEach((fn) => fn())\n }\n}\n\nexport function resetCounterRecord(id: string) {\n const record = store.get(id)\n if (record) {\n record.mounts = 0\n record.renders = 0\n notifyCounter(id)\n }\n}\n\nexport function clearAllCounters() {\n store.clear()\n}\n","'use client'\n\nimport { useRef, useEffect, useState, useCallback, useId } from 'react'\nimport type { RenderCounterOptions, RenderCounterState } from './types'\nimport { getCounterRecord, subscribeCounter, notifyCounter, resetCounterRecord } from './store'\n\n/**\n * A React hook that tracks component mount and render counts in a React 18/19 StrictMode safe manner.\n * Supports optional global ID sharing, console logging, and manual reset.\n */\nexport function useRenderCounter(\n idOrOptions?: string | RenderCounterOptions,\n maybeOptions?: RenderCounterOptions,\n): RenderCounterState {\n const defaultAutoId = useId()\n\n const options: RenderCounterOptions =\n typeof idOrOptions === 'string' ? { id: idOrOptions, ...maybeOptions } : idOrOptions || {}\n\n const { id = defaultAutoId, logToConsole = false, disabled = false } = options\n\n const renderCountRef = useRef<number>(0)\n const isMountedRef = useRef<boolean>(false)\n const [, forceUpdate] = useState<number>(0)\n\n if (!disabled) {\n renderCountRef.current += 1\n }\n\n useEffect(() => {\n if (disabled) return\n\n const unsubscribe = subscribeCounter(id, () => {\n forceUpdate((c) => c + 1)\n })\n\n const record = getCounterRecord(id)\n record.mounts += 1\n isMountedRef.current = true\n\n if (logToConsole) {\n console.log(\n `[DevTools:${id}] Mounted: ${record.mounts} | Rendered: ${renderCountRef.current}`,\n )\n }\n\n notifyCounter(id)\n\n return () => {\n isMountedRef.current = false\n unsubscribe()\n }\n }, [id, disabled, logToConsole])\n\n if (!disabled) {\n const record = getCounterRecord(id)\n record.renders = Math.max(record.renders, renderCountRef.current)\n }\n\n const reset = useCallback(() => {\n renderCountRef.current = 0\n resetCounterRecord(id)\n }, [id])\n\n if (disabled) {\n return { mounts: 0, renders: 0, reset }\n }\n\n const record = getCounterRecord(id)\n\n return {\n mounts: record.mounts,\n renders: renderCountRef.current,\n reset,\n }\n}\n","'use client'\n\nimport type { RenderCounterBadgeProps } from './types'\nimport { useRenderCounter } from './use-render-counter'\n\n/**\n * A badge displaying mount and render counters for debugging component lifecycles.\n */\nexport function RenderCounterBadge({\n id,\n className,\n style,\n logToConsole = false,\n disabled = false,\n}: RenderCounterBadgeProps) {\n const { mounts, renders } = useRenderCounter(id, { logToConsole, disabled })\n\n if (disabled) {\n return null\n }\n\n return (\n <div className={className} style={style}>\n <span>\n M: <strong>{mounts}</strong>\n </span>\n <span>|</span>\n <span>\n R: <strong>{renders}</strong>\n </span>\n </div>\n )\n}\n","'use client'\n\nimport type { RenderCounterFooterProps } from './types'\nimport { useRenderCounter } from './use-render-counter'\n\n/**\n * A container footer component for displaying mount and render counters at the bottom of widgets or panels.\n */\nexport function RenderCounterFooter({\n id,\n label,\n children,\n className,\n footerClassName,\n style,\n logToConsole = false,\n disabled = false,\n}: RenderCounterFooterProps) {\n const displayId = label || id || 'widget'\n const { mounts, renders } = useRenderCounter(id, { logToConsole, disabled })\n\n if (disabled) {\n return <>{children}</>\n }\n\n return (\n <div className={className} style={style}>\n {children && <div className=\"flex-1 overflow-hidden relative min-h-0\">{children}</div>}\n <div className={footerClassName}>\n <span className=\"truncate\">{displayId}</span>\n <div className=\"flex items-center gap-3\">\n <span>\n Mounts: <strong className=\"counter-mounts\">{mounts}</strong>\n </span>\n <span>|</span>\n <span>\n Renders: <strong className=\"counter-renders\">{renders}</strong>\n </span>\n </div>\n </div>\n </div>\n )\n}\n"]}
1
+ {"version":3,"sources":["../src/devtools/store.ts","../src/devtools/use-render-counter.ts","../src/devtools/render-counter-badge.tsx","../src/devtools/render-counter-footer.tsx"],"names":["store","getCounterRecord","id","record","subscribeCounter","listener","notifyCounter","fn","resetCounterRecord","clearAllCounters","useRenderCounter","idOrOptions","maybeOptions","defaultAutoId","useId","options","logToConsole","disabled","renderCountRef","useRef","isMountedRef","forceUpdate","useState","useEffect","unsubscribe","c","reset","useCallback","RenderCounterBadge","className","style","mounts","renders","jsxs","jsx","RenderCounterFooter","label","children","footerClassName","displayId","Fragment"],"mappings":"gFAQA,IAAMA,CAAAA,CAAQ,IAAI,GAAA,CAEX,SAASC,CAAAA,CAAiBC,CAAAA,CAAiC,CAChE,IAAIC,CAAAA,CAASH,CAAAA,CAAM,GAAA,CAAIE,CAAE,CAAA,CACzB,OAAKC,CAAAA,GACHA,CAAAA,CAAS,CAAE,MAAA,CAAQ,CAAA,CAAG,OAAA,CAAS,CAAA,CAAG,SAAA,CAAW,IAAI,GAAM,CAAA,CACvDH,CAAAA,CAAM,GAAA,CAAIE,CAAAA,CAAIC,CAAM,CAAA,CAAA,CAEfA,CACT,CAEO,SAASC,CAAAA,CAAiBF,CAAAA,CAAYG,CAAAA,CAAgC,CAC3E,IAAMF,CAAAA,CAASF,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G,cAAAA,CAAC,MAAA,CAAA,CAAK,QAAA,CAAA,GAAA,CAAC,CAAA,CACPD,eAAAA,CAAC,MAAA,CAAA,CAAK,QAAA,CAAA,CAAA,WAAA,CACKC,cAAAA,CAAC,QAAA,CAAA,CAAO,SAAA,CAAU,iBAAA,CAAmB,QAAA,CAAAF,CAAAA,CAAQ,CAAA,CAAA,CACxD,CAAA,CAAA,CACF,CAAA,CAAA,CACF,CAAA,CAAA,CACF,CAEJ","file":"devtools.cjs","sourcesContent":["type Listener = () => void\n\ninterface GlobalCounterRecord {\n mounts: number\n renders: number\n listeners: Set<Listener>\n}\n\nconst store = new Map<string, GlobalCounterRecord>()\n\nexport function getCounterRecord(id: string): GlobalCounterRecord {\n let record = store.get(id)\n if (!record) {\n record = { mounts: 0, renders: 0, listeners: new Set() }\n store.set(id, record)\n }\n return record\n}\n\nexport function subscribeCounter(id: string, listener: Listener): () => void {\n const record = getCounterRecord(id)\n record.listeners.add(listener)\n return () => {\n record.listeners.delete(listener)\n }\n}\n\nexport function notifyCounter(id: string) {\n const record = store.get(id)\n if (record) {\n record.listeners.forEach((fn) => fn())\n }\n}\n\nexport function resetCounterRecord(id: string) {\n const record = store.get(id)\n if (record) {\n record.mounts = 0\n record.renders = 0\n notifyCounter(id)\n }\n}\n\nexport function clearAllCounters() {\n store.clear()\n}\n","'use client'\n\nimport { useRef, useEffect, useState, useCallback, useId } from 'react'\nimport type { RenderCounterOptions, RenderCounterState } from './types'\nimport { getCounterRecord, subscribeCounter, notifyCounter, resetCounterRecord } from './store'\n\n/**\n * A React hook that tracks component mount and render counts in a React 18/19 StrictMode safe manner.\n * Supports optional global ID sharing, console logging, and manual reset.\n */\nexport function useRenderCounter(\n idOrOptions?: string | RenderCounterOptions,\n maybeOptions?: RenderCounterOptions,\n): RenderCounterState {\n const defaultAutoId = useId()\n\n const options: RenderCounterOptions =\n typeof idOrOptions === 'string' ? { id: idOrOptions, ...maybeOptions } : idOrOptions || {}\n\n const { id = defaultAutoId, logToConsole = false, disabled = false } = options\n\n const renderCountRef = useRef<number>(0)\n const isMountedRef = useRef<boolean>(false)\n const [, forceUpdate] = useState<number>(0)\n\n if (!disabled) {\n renderCountRef.current += 1\n }\n\n useEffect(() => {\n if (disabled) return\n\n const unsubscribe = subscribeCounter(id, () => {\n forceUpdate((c) => c + 1)\n })\n\n const record = getCounterRecord(id)\n record.mounts += 1\n isMountedRef.current = true\n\n if (logToConsole) {\n console.log(\n `[DevTools:${id}] Mounted: ${record.mounts} | Rendered: ${renderCountRef.current}`,\n )\n }\n\n notifyCounter(id)\n\n return () => {\n isMountedRef.current = false\n unsubscribe()\n }\n }, [id, disabled, logToConsole])\n\n if (!disabled) {\n const record = getCounterRecord(id)\n record.renders = Math.max(record.renders, renderCountRef.current)\n }\n\n const reset = useCallback(() => {\n renderCountRef.current = 0\n resetCounterRecord(id)\n }, [id])\n\n if (disabled) {\n return { mounts: 0, renders: 0, reset }\n }\n\n const record = getCounterRecord(id)\n\n return {\n mounts: record.mounts,\n renders: renderCountRef.current,\n reset,\n }\n}\n","'use client'\n\nimport type { RenderCounterBadgeProps } from './types'\nimport { useRenderCounter } from './use-render-counter'\n\n/**\n * A badge displaying mount and render counters for debugging component lifecycles.\n */\nexport function RenderCounterBadge({\n id,\n className,\n style,\n logToConsole = false,\n disabled = false,\n}: RenderCounterBadgeProps) {\n const { mounts, renders } = useRenderCounter(id, { logToConsole, disabled })\n\n if (disabled) {\n return null\n }\n\n return (\n <div className={className} style={style}>\n <span>\n M: <strong>{mounts}</strong>\n </span>\n <span>|</span>\n <span>\n R: <strong>{renders}</strong>\n </span>\n </div>\n )\n}\n","'use client'\n\nimport type { RenderCounterFooterProps } from './types'\nimport { useRenderCounter } from './use-render-counter'\n\n/**\n * A container footer component for displaying mount and render counters at the bottom of widgets or panels.\n */\nexport function RenderCounterFooter({\n id,\n label,\n children,\n className,\n footerClassName,\n style,\n logToConsole = false,\n disabled = false,\n}: RenderCounterFooterProps) {\n const displayId = label || id || 'widget'\n const { mounts, renders } = useRenderCounter(id, { logToConsole, disabled })\n\n if (disabled) {\n return <>{children}</>\n }\n\n return (\n <div className={className} style={style}>\n {children && (\n <div\n style={{\n flex: 1,\n height: '100%',\n width: '100%',\n minHeight: 0,\n overflow: 'hidden',\n position: 'relative',\n }}\n >\n {children}\n </div>\n )}\n <div className={footerClassName}>\n <span\n style={{\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n }}\n >\n {displayId}\n </span>\n <div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>\n <span>\n Mounts: <strong className=\"counter-mounts\">{mounts}</strong>\n </span>\n <span>|</span>\n <span>\n Renders: <strong className=\"counter-renders\">{renders}</strong>\n </span>\n </div>\n </div>\n </div>\n )\n}\n"]}
package/dist/devtools.js CHANGED
@@ -1,2 +1,2 @@
1
- import {useId,useRef,useState,useEffect,useCallback}from'react';import {jsxs,jsx,Fragment}from'react/jsx-runtime';var a=new Map;function i(r){let e=a.get(r);return e||(e={mounts:0,renders:0,listeners:new Set},a.set(r,e)),e}function N(r,e){let n=i(r);return n.listeners.add(e),()=>{n.listeners.delete(e);}}function g(r){let e=a.get(r);e&&e.listeners.forEach(n=>n());}function v(r){let e=a.get(r);e&&(e.mounts=0,e.renders=0,g(r));}function S(){a.clear();}function p(r,e){let n=useId(),c=typeof r=="string"?{id:r,...e}:r||{},{id:t=n,logToConsole:u=false,disabled:o=false}=c,s=useRef(0),l=useRef(false),[,R]=useState(0);if(o||(s.current+=1),useEffect(()=>{if(o)return;let C=N(t,()=>{R(P=>P+1);}),b=i(t);return b.mounts+=1,l.current=true,u&&console.log(`[DevTools:${t}] Mounted: ${b.mounts} | Rendered: ${s.current}`),g(t),()=>{l.current=false,C();}},[t,o,u]),!o){let C=i(t);C.renders=Math.max(C.renders,s.current);}let m=useCallback(()=>{s.current=0,v(t);},[t]);return o?{mounts:0,renders:0,reset:m}:{mounts:i(t).mounts,renders:s.current,reset:m}}function G({id:r,className:e,style:n,logToConsole:c=false,disabled:t=false}){let{mounts:u,renders:o}=p(r,{logToConsole:c,disabled:t});return t?null:jsxs("div",{className:e,style:n,children:[jsxs("span",{children:["M: ",jsx("strong",{children:u})]}),jsx("span",{children:"|"}),jsxs("span",{children:["R: ",jsx("strong",{children:o})]})]})}function I({id:r,label:e,children:n,className:c,footerClassName:t,style:u,logToConsole:o=false,disabled:s=false}){let l=e||r||"widget",{mounts:R,renders:m}=p(r,{logToConsole:o,disabled:s});return s?jsx(Fragment,{children:n}):jsxs("div",{className:c,style:u,children:[n&&jsx("div",{className:"flex-1 overflow-hidden relative min-h-0",children:n}),jsxs("div",{className:t,children:[jsx("span",{className:"truncate",children:l}),jsxs("div",{className:"flex items-center gap-3",children:[jsxs("span",{children:["Mounts: ",jsx("strong",{className:"counter-mounts",children:R})]}),jsx("span",{children:"|"}),jsxs("span",{children:["Renders: ",jsx("strong",{className:"counter-renders",children:m})]})]})]})]})}export{G as RenderCounterBadge,I as RenderCounterFooter,S as clearAllCounters,v as resetCounterRecord,p as useRenderCounter};//# sourceMappingURL=devtools.js.map
1
+ import {useId,useRef,useState,useEffect,useCallback}from'react';import {jsxs,jsx,Fragment}from'react/jsx-runtime';var c=new Map;function p(r){let e=c.get(r);return e||(e={mounts:0,renders:0,listeners:new Set},c.set(r,e)),e}function w(r,e){let n=p(r);return n.listeners.add(e),()=>{n.listeners.delete(e);}}function g(r){let e=c.get(r);e&&e.listeners.forEach(n=>n());}function y(r){let e=c.get(r);e&&(e.mounts=0,e.renders=0,g(r));}function M(){c.clear();}function a(r,e){let n=useId(),i=typeof r=="string"?{id:r,...e}:r||{},{id:t=n,logToConsole:u=false,disabled:o=false}=i,s=useRef(0),f=useRef(false),[,R]=useState(0);if(o||(s.current+=1),useEffect(()=>{if(o)return;let C=w(t,()=>{R(S=>S+1);}),b=p(t);return b.mounts+=1,f.current=true,u&&console.log(`[DevTools:${t}] Mounted: ${b.mounts} | Rendered: ${s.current}`),g(t),()=>{f.current=false,C();}},[t,o,u]),!o){let C=p(t);C.renders=Math.max(C.renders,s.current);}let m=useCallback(()=>{s.current=0,y(t);},[t]);return o?{mounts:0,renders:0,reset:m}:{mounts:p(t).mounts,renders:s.current,reset:m}}function I({id:r,className:e,style:n,logToConsole:i=false,disabled:t=false}){let{mounts:u,renders:o}=a(r,{logToConsole:i,disabled:t});return t?null:jsxs("div",{className:e,style:n,children:[jsxs("span",{children:["M: ",jsx("strong",{children:u})]}),jsx("span",{children:"|"}),jsxs("span",{children:["R: ",jsx("strong",{children:o})]})]})}function A({id:r,label:e,children:n,className:i,footerClassName:t,style:u,logToConsole:o=false,disabled:s=false}){let f=e||r||"widget",{mounts:R,renders:m}=a(r,{logToConsole:o,disabled:s});return s?jsx(Fragment,{children:n}):jsxs("div",{className:i,style:u,children:[n&&jsx("div",{style:{flex:1,height:"100%",width:"100%",minHeight:0,overflow:"hidden",position:"relative"},children:n}),jsxs("div",{className:t,children:[jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:f}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[jsxs("span",{children:["Mounts: ",jsx("strong",{className:"counter-mounts",children:R})]}),jsx("span",{children:"|"}),jsxs("span",{children:["Renders: ",jsx("strong",{className:"counter-renders",children:m})]})]})]})]})}export{I as RenderCounterBadge,A as RenderCounterFooter,M as clearAllCounters,y as resetCounterRecord,a as useRenderCounter};//# sourceMappingURL=devtools.js.map
2
2
  //# sourceMappingURL=devtools.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/devtools/store.ts","../src/devtools/use-render-counter.ts","../src/devtools/render-counter-badge.tsx","../src/devtools/render-counter-footer.tsx"],"names":["store","getCounterRecord","id","record","subscribeCounter","listener","notifyCounter","fn","resetCounterRecord","clearAllCounters","useRenderCounter","idOrOptions","maybeOptions","defaultAutoId","useId","options","logToConsole","disabled","renderCountRef","useRef","isMountedRef","forceUpdate","useState","useEffect","unsubscribe","c","reset","useCallback","RenderCounterBadge","className","style","mounts","renders","jsxs","jsx","RenderCounterFooter","label","children","footerClassName","displayId","Fragment"],"mappings":"kHAQA,IAAMA,CAAAA,CAAQ,IAAI,GAAA,CAEX,SAASC,CAAAA,CAAiBC,CAAAA,CAAiC,CAChE,IAAIC,CAAAA,CAASH,CAAAA,CAAM,GAAA,CAAIE,CAAE,CAAA,CACzB,OAAKC,CAAAA,GACHA,CAAAA,CAAS,CAAE,MAAA,CAAQ,CAAA,CAAG,OAAA,CAAS,CAAA,CAAG,SAAA,CAAW,IAAI,GAAM,CAAA,CACvDH,CAAAA,CAAM,GAAA,CAAIE,CAAAA,CAAIC,CAAM,CAAA,CAAA,CAEfA,CACT,CAEO,SAASC,CAAAA,CAAiBF,CAAAA,CAAYG,CAAAA,CAAgC,CAC3E,IAAMF,CAAAA,CAASF,CAAAA,CAAiBC,CAAE,CAAA,CAClC,OAAAC,CAAAA,CAAO,SAAA,CAAU,GAAA,CAAIE,CAAQ,CAAA,CACtB,IAAM,CACXF,CAAAA,CAAO,SAAA,CAAU,MAAA,CAAOE,CAAQ,EAClC,CACF,CAEO,SAASC,CAAAA,CAAcJ,CAAAA,CAAY,CACxC,IAAMC,CAAAA,CAASH,CAAAA,CAAM,GAAA,CAAIE,CAAE,CAAA,CACvBC,CAAAA,EACFA,CAAAA,CAAO,SAAA,CAAU,OAAA,CAASI,CAAAA,EAAOA,CAAAA,EAAI,EAEzC,CAEO,SAASC,CAAAA,CAAmBN,CAAAA,CAAY,CAC7C,IAAMC,CAAAA,CAASH,CAAAA,CAAM,GAAA,CAAIE,CAAE,CAAA,CACvBC,CAAAA,GACFA,CAAAA,CAAO,MAAA,CAAS,CAAA,CAChBA,CAAAA,CAAO,QAAU,CAAA,CACjBG,CAAAA,CAAcJ,CAAE,CAAA,EAEpB,CAEO,SAASO,CAAAA,EAAmB,CACjCT,CAAAA,CAAM,KAAA,GACR,CCnCO,SAASU,CAAAA,CACdC,EACAC,CAAAA,CACoB,CACpB,IAAMC,CAAAA,CAA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QAAA,CAAA,CAAO,SAAA,CAAU,gBAAA,CAAkB,QAAA,CAAAH,CAAAA,CAAO,CAAA,CAAA,CACrD,CAAA,CACAG,GAAAA,CAAC,MAAA,CAAA,CAAK,QAAA,CAAA,GAAA,CAAC,CAAA,CACPD,IAAAA,CAAC,MAAA,CAAA,CAAK,QAAA,CAAA,CAAA,WAAA,CACKC,GAAAA,CAAC,QAAA,CAAA,CAAO,SAAA,CAAU,iBAAA,CAAmB,QAAA,CAAAF,CAAAA,CAAQ,CAAA,CAAA,CACxD,CAAA,CAAA,CACF,CAAA,CAAA,CACF,CAAA,CAAA,CACF,CAEJ","file":"devtools.js","sourcesContent":["type Listener = () => void\n\ninterface GlobalCounterRecord {\n mounts: number\n renders: number\n listeners: Set<Listener>\n}\n\nconst store = new Map<string, GlobalCounterRecord>()\n\nexport function getCounterRecord(id: string): GlobalCounterRecord {\n let record = store.get(id)\n if (!record) {\n record = { mounts: 0, renders: 0, listeners: new Set() }\n store.set(id, record)\n }\n return record\n}\n\nexport function subscribeCounter(id: string, listener: Listener): () => void {\n const record = getCounterRecord(id)\n record.listeners.add(listener)\n return () => {\n record.listeners.delete(listener)\n }\n}\n\nexport function notifyCounter(id: string) {\n const record = store.get(id)\n if (record) {\n record.listeners.forEach((fn) => fn())\n }\n}\n\nexport function resetCounterRecord(id: string) {\n const record = store.get(id)\n if (record) {\n record.mounts = 0\n record.renders = 0\n notifyCounter(id)\n }\n}\n\nexport function clearAllCounters() {\n store.clear()\n}\n","'use client'\n\nimport { useRef, useEffect, useState, useCallback, useId } from 'react'\nimport type { RenderCounterOptions, RenderCounterState } from './types'\nimport { getCounterRecord, subscribeCounter, notifyCounter, resetCounterRecord } from './store'\n\n/**\n * A React hook that tracks component mount and render counts in a React 18/19 StrictMode safe manner.\n * Supports optional global ID sharing, console logging, and manual reset.\n */\nexport function useRenderCounter(\n idOrOptions?: string | RenderCounterOptions,\n maybeOptions?: RenderCounterOptions,\n): RenderCounterState {\n const defaultAutoId = useId()\n\n const options: RenderCounterOptions =\n typeof idOrOptions === 'string' ? { id: idOrOptions, ...maybeOptions } : idOrOptions || {}\n\n const { id = defaultAutoId, logToConsole = false, disabled = false } = options\n\n const renderCountRef = useRef<number>(0)\n const isMountedRef = useRef<boolean>(false)\n const [, forceUpdate] = useState<number>(0)\n\n if (!disabled) {\n renderCountRef.current += 1\n }\n\n useEffect(() => {\n if (disabled) return\n\n const unsubscribe = subscribeCounter(id, () => {\n forceUpdate((c) => c + 1)\n })\n\n const record = getCounterRecord(id)\n record.mounts += 1\n isMountedRef.current = true\n\n if (logToConsole) {\n console.log(\n `[DevTools:${id}] Mounted: ${record.mounts} | Rendered: ${renderCountRef.current}`,\n )\n }\n\n notifyCounter(id)\n\n return () => {\n isMountedRef.current = false\n unsubscribe()\n }\n }, [id, disabled, logToConsole])\n\n if (!disabled) {\n const record = getCounterRecord(id)\n record.renders = Math.max(record.renders, renderCountRef.current)\n }\n\n const reset = useCallback(() => {\n renderCountRef.current = 0\n resetCounterRecord(id)\n }, [id])\n\n if (disabled) {\n return { mounts: 0, renders: 0, reset }\n }\n\n const record = getCounterRecord(id)\n\n return {\n mounts: record.mounts,\n renders: renderCountRef.current,\n reset,\n }\n}\n","'use client'\n\nimport type { RenderCounterBadgeProps } from './types'\nimport { useRenderCounter } from './use-render-counter'\n\n/**\n * A badge displaying mount and render counters for debugging component lifecycles.\n */\nexport function RenderCounterBadge({\n id,\n className,\n style,\n logToConsole = false,\n disabled = false,\n}: RenderCounterBadgeProps) {\n const { mounts, renders } = useRenderCounter(id, { logToConsole, disabled })\n\n if (disabled) {\n return null\n }\n\n return (\n <div className={className} style={style}>\n <span>\n M: <strong>{mounts}</strong>\n </span>\n <span>|</span>\n <span>\n R: <strong>{renders}</strong>\n </span>\n </div>\n )\n}\n","'use client'\n\nimport type { RenderCounterFooterProps } from './types'\nimport { useRenderCounter } from './use-render-counter'\n\n/**\n * A container footer component for displaying mount and render counters at the bottom of widgets or panels.\n */\nexport function RenderCounterFooter({\n id,\n label,\n children,\n className,\n footerClassName,\n style,\n logToConsole = false,\n disabled = false,\n}: RenderCounterFooterProps) {\n const displayId = label || id || 'widget'\n const { mounts, renders } = useRenderCounter(id, { logToConsole, disabled })\n\n if (disabled) {\n return <>{children}</>\n }\n\n return (\n <div className={className} style={style}>\n {children && <div className=\"flex-1 overflow-hidden relative min-h-0\">{children}</div>}\n <div className={footerClassName}>\n <span className=\"truncate\">{displayId}</span>\n <div className=\"flex items-center gap-3\">\n <span>\n Mounts: <strong className=\"counter-mounts\">{mounts}</strong>\n </span>\n <span>|</span>\n <span>\n Renders: <strong className=\"counter-renders\">{renders}</strong>\n </span>\n </div>\n </div>\n </div>\n )\n}\n"]}
1
+ {"version":3,"sources":["../src/devtools/store.ts","../src/devtools/use-render-counter.ts","../src/devtools/render-counter-badge.tsx","../src/devtools/render-counter-footer.tsx"],"names":["store","getCounterRecord","id","record","subscribeCounter","listener","notifyCounter","fn","resetCounterRecord","clearAllCounters","useRenderCounter","idOrOptions","maybeOptions","defaultAutoId","useId","options","logToConsole","disabled","renderCountRef","useRef","isMountedRef","forceUpdate","useState","useEffect","unsubscribe","c","reset","useCallback","RenderCounterBadge","className","style","mounts","renders","jsxs","jsx","RenderCounterFooter","label","children","footerClassName","displayId","Fragment"],"mappings":"kHAQA,IAAMA,CAAAA,CAAQ,IAAI,GAAA,CAEX,SAASC,CAAAA,CAAiBC,CAAAA,CAAiC,CAChE,IAAIC,CAAAA,CAASH,CAAAA,CAAM,GAAA,CAAIE,CAAE,CAAA,CACzB,OAAKC,CAAAA,GACHA,CAAAA,CAAS,CAAE,MAAA,CAAQ,CAAA,CAAG,OAAA,CAAS,CAAA,CAAG,SAAA,CAAW,IAAI,GAAM,CAAA,CACvDH,CAAAA,CAAM,GAAA,CAAIE,CAAAA,CAAIC,CAAM,CAAA,CAAA,CAEfA,CACT,CAEO,SAASC,CAAAA,CAAiBF,CAAAA,CAAYG,CAAAA,CAAgC,CAC3E,IAAMF,CAAAA,CAAS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G,GAAAA,CAAC,MAAA,CAAA,CAAK,QAAA,CAAA,GAAA,CAAC,CAAA,CACPD,IAAAA,CAAC,MAAA,CAAA,CAAK,QAAA,CAAA,CAAA,WAAA,CACKC,GAAAA,CAAC,QAAA,CAAA,CAAO,SAAA,CAAU,iBAAA,CAAmB,QAAA,CAAAF,CAAAA,CAAQ,CAAA,CAAA,CACxD,CAAA,CAAA,CACF,CAAA,CAAA,CACF,CAAA,CAAA,CACF,CAEJ","file":"devtools.js","sourcesContent":["type Listener = () => void\n\ninterface GlobalCounterRecord {\n mounts: number\n renders: number\n listeners: Set<Listener>\n}\n\nconst store = new Map<string, GlobalCounterRecord>()\n\nexport function getCounterRecord(id: string): GlobalCounterRecord {\n let record = store.get(id)\n if (!record) {\n record = { mounts: 0, renders: 0, listeners: new Set() }\n store.set(id, record)\n }\n return record\n}\n\nexport function subscribeCounter(id: string, listener: Listener): () => void {\n const record = getCounterRecord(id)\n record.listeners.add(listener)\n return () => {\n record.listeners.delete(listener)\n }\n}\n\nexport function notifyCounter(id: string) {\n const record = store.get(id)\n if (record) {\n record.listeners.forEach((fn) => fn())\n }\n}\n\nexport function resetCounterRecord(id: string) {\n const record = store.get(id)\n if (record) {\n record.mounts = 0\n record.renders = 0\n notifyCounter(id)\n }\n}\n\nexport function clearAllCounters() {\n store.clear()\n}\n","'use client'\n\nimport { useRef, useEffect, useState, useCallback, useId } from 'react'\nimport type { RenderCounterOptions, RenderCounterState } from './types'\nimport { getCounterRecord, subscribeCounter, notifyCounter, resetCounterRecord } from './store'\n\n/**\n * A React hook that tracks component mount and render counts in a React 18/19 StrictMode safe manner.\n * Supports optional global ID sharing, console logging, and manual reset.\n */\nexport function useRenderCounter(\n idOrOptions?: string | RenderCounterOptions,\n maybeOptions?: RenderCounterOptions,\n): RenderCounterState {\n const defaultAutoId = useId()\n\n const options: RenderCounterOptions =\n typeof idOrOptions === 'string' ? { id: idOrOptions, ...maybeOptions } : idOrOptions || {}\n\n const { id = defaultAutoId, logToConsole = false, disabled = false } = options\n\n const renderCountRef = useRef<number>(0)\n const isMountedRef = useRef<boolean>(false)\n const [, forceUpdate] = useState<number>(0)\n\n if (!disabled) {\n renderCountRef.current += 1\n }\n\n useEffect(() => {\n if (disabled) return\n\n const unsubscribe = subscribeCounter(id, () => {\n forceUpdate((c) => c + 1)\n })\n\n const record = getCounterRecord(id)\n record.mounts += 1\n isMountedRef.current = true\n\n if (logToConsole) {\n console.log(\n `[DevTools:${id}] Mounted: ${record.mounts} | Rendered: ${renderCountRef.current}`,\n )\n }\n\n notifyCounter(id)\n\n return () => {\n isMountedRef.current = false\n unsubscribe()\n }\n }, [id, disabled, logToConsole])\n\n if (!disabled) {\n const record = getCounterRecord(id)\n record.renders = Math.max(record.renders, renderCountRef.current)\n }\n\n const reset = useCallback(() => {\n renderCountRef.current = 0\n resetCounterRecord(id)\n }, [id])\n\n if (disabled) {\n return { mounts: 0, renders: 0, reset }\n }\n\n const record = getCounterRecord(id)\n\n return {\n mounts: record.mounts,\n renders: renderCountRef.current,\n reset,\n }\n}\n","'use client'\n\nimport type { RenderCounterBadgeProps } from './types'\nimport { useRenderCounter } from './use-render-counter'\n\n/**\n * A badge displaying mount and render counters for debugging component lifecycles.\n */\nexport function RenderCounterBadge({\n id,\n className,\n style,\n logToConsole = false,\n disabled = false,\n}: RenderCounterBadgeProps) {\n const { mounts, renders } = useRenderCounter(id, { logToConsole, disabled })\n\n if (disabled) {\n return null\n }\n\n return (\n <div className={className} style={style}>\n <span>\n M: <strong>{mounts}</strong>\n </span>\n <span>|</span>\n <span>\n R: <strong>{renders}</strong>\n </span>\n </div>\n )\n}\n","'use client'\n\nimport type { RenderCounterFooterProps } from './types'\nimport { useRenderCounter } from './use-render-counter'\n\n/**\n * A container footer component for displaying mount and render counters at the bottom of widgets or panels.\n */\nexport function RenderCounterFooter({\n id,\n label,\n children,\n className,\n footerClassName,\n style,\n logToConsole = false,\n disabled = false,\n}: RenderCounterFooterProps) {\n const displayId = label || id || 'widget'\n const { mounts, renders } = useRenderCounter(id, { logToConsole, disabled })\n\n if (disabled) {\n return <>{children}</>\n }\n\n return (\n <div className={className} style={style}>\n {children && (\n <div\n style={{\n flex: 1,\n height: '100%',\n width: '100%',\n minHeight: 0,\n overflow: 'hidden',\n position: 'relative',\n }}\n >\n {children}\n </div>\n )}\n <div className={footerClassName}>\n <span\n style={{\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n }}\n >\n {displayId}\n </span>\n <div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>\n <span>\n Mounts: <strong className=\"counter-mounts\">{mounts}</strong>\n </span>\n <span>|</span>\n <span>\n Renders: <strong className=\"counter-renders\">{renders}</strong>\n </span>\n </div>\n </div>\n </div>\n )\n}\n"]}
package/dist/index.cjs CHANGED
@@ -6,7 +6,7 @@
6
6
  .zeugma-resizing *:not([role="separator"]) {
7
7
  pointer-events: none !important;
8
8
  }
9
- `,document.head.appendChild(o),t.setAttribute("data-resizing","true");let c=s=>{n(s);},l=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let s=document.getElementById("zeugma-global-cursor-style");s&&s.remove(),document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",l),r();};document.addEventListener("pointermove",c),document.addEventListener("pointerup",l);}var vt=ge.createContext(void 0),Re=ge.createContext(void 0),Te=ge.createContext(void 0),ht=ge.createContext(void 0),re=()=>{let e=ge.useContext(vt);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},He=()=>{let e=ge.useContext(Re);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e},Qe=()=>{let e=ge.useContext(ht);if(!e)throw new Error("useZeugmaDrag must be used within a Zeugma provider");return e};function Bt(e){let t=ge.useRef(null);return ge.useEffect(()=>{if(!e){t.current=null;return}let n=o=>{t.current={x:o.clientX,y:o.clientY};},r=o=>{let c=o.touches[0]||o.changedTouches[0];c&&(t.current={x:c.clientX,y:c.clientY});};return window.addEventListener("pointermove",n,{passive:true}),window.addEventListener("touchmove",r,{passive:true}),()=>{window.removeEventListener("pointermove",n),window.removeEventListener("touchmove",r);}},[e]),t}function _t(e){ge.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]=ge.useState({}),[n,r]=ge.useState({}),o=ge.useRef({}),c=ge.useRef(null),l=ge.useRef({}),s=ge.useRef(null),u=ge.useRef(true);ge.useEffect(()=>(u.current=true,()=>{u.current=false;}),[]);let f=ge.useCallback((y,D,N)=>{u.current&&t(T=>{if(!D){if(N&&T[y]!==N||!T[y])return T;let Z={...T};return delete Z[y],Z}return T[y]===D?T:{...T,[y]:D}});},[]),i=ge.useCallback((y,D)=>{u.current&&r(N=>{if(!D){if(!N[y])return N;let T={...N};return delete T[y],T}return N[y]===D?N:{...N,[y]:D}});},[]),b=ge.useCallback((y,D)=>{o.current[y]=D;},[]),g=ge.useCallback(y=>{c.current=y;},[]),m=ge.useCallback((y,D)=>{l.current[y]=D;},[]);return {portalTargets:ge.useMemo(()=>({...e,...n}),[e,n]),registerPortalTarget:f,registerPopoutTarget:i,registerRenderCallback:b,renderCallbacksRef:o,registerRenderPane:g,renderPaneRef:c,registerTabHeader:m,tabHeadersRef:l,activeIdRef:s}}function Yn(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 Vt(e){return ge.useMemo(()=>Yn(e),[e])}function Wt(e){let{onDragStart:t,onDragEnd:n}=e,[r,o]=ge.useState(null),[c,l]=ge.useState(null),s=ge.useCallback(f=>{t&&t(f);},[t]),u=ge.useCallback((f,i,b)=>{n&&n(f,i,b);},[n]);return {overTabId:r,setOverTabId:o,overTabPosition:c,setOverTabPosition:l,handleDragStartInternal:s,handleDragEndInternal:u}}function jt(e){let n=ge.useContext(Te)?.registerRenderPane;ge.useEffect(()=>{n&&e&&n(e);},[n,e]);}function pe(){return "pane-"+Math.random().toString(36).substring(2,11)}function be(e,t){if(e===null)return null;if(e.type==="pane")return e.id===t?null:e;let n=be(e.first,t),r=be(e.second,t);return n===null?r:r===null?n:{...e,first:n,second:r}}function fe(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 c=e.activeTabId;e.activeTabId===t&&(c=o[0]);let l={...e.tabsMetadata};return delete l[t],{...e,tabIds:o,activeTabId:c,tabsMetadata:Object.keys(l).length>0?l:void 0}}return 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 Se(e,t,n,r,o){if(e===null)return typeof o=="string"?{type:"pane",id:pe(),tabIds:[o],activeTabId:o}:o;if(e.type==="pane"){if(e.id===t){let c=typeof o=="string"?{type:"pane",id:pe(),tabIds:[o],activeTabId:o}:o,l=r==="left"||r==="top";return {type:"split",direction:n,first:l?c:e,second:l?e:c,splitPercentage:50}}return e}return {...e,first:Se(e.first,t,n,r,o)||e.first,second:Se(e.second,t,n,r,o)||e.second}}function Gn(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 qt(e,t,n,r){if(e===null)return {type:"pane",id:pe(),tabIds:[n],activeTabId:n,tabsMetadata:r?{[n]:r}:void 0};let o=t?te(e,t):null;if(o&&o.type==="pane"){let s=function(u){if(u.type==="pane"&&u.id===t){let f=[...u.tabIds];f.includes(n)||f.push(n);let i=u.tabsMetadata;return r&&(i={...u.tabsMetadata,[n]:r}),{...u,tabIds:f,activeTabId:n,tabsMetadata:i}}return u.type==="split"?{...u,first:s(u.first),second:s(u.second)}:u};return s(e)}let c={type:"pane",id:pe(),tabIds:[n],activeTabId:n,tabsMetadata:r?{[n]:r}:void 0};return Gn(e,c)}function xe(e,t,n){return e===null?null:e===t?{...e,splitPercentage:n}:e.type==="split"?{...e,first:xe(e.first,t,n)||e.first,second:xe(e.second,t,n)||e.second}:e}function te(e,t){return e===null?null:e.type==="pane"?e.id===t?e:null:e.type==="split"?te(e.first,t)??te(e.second,t):null}function U(e,t){return e===null?null:e.type==="pane"?e.tabIds.includes(t)?e:null:e.type==="split"?U(e.first,t)??U(e.second,t):null}function Ut(e,t){return te(e,t)??U(e,t)}function ot(e,t){let n=U(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],remountOnPopout:n.tabsMetadata?.[t]?.remountOnPopout}}function Xt(e,t){return U(e,t)?.tabsMetadata?.[t]}function Yt(e,t){let n=te(e,t);return n?.tabsMetadata?.[n.activeTabId]}function tt(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.tabIds.includes(t)){let r=e.tabsMetadata||{},o=r[t],c=n(o),l={...r};return c===void 0?delete l[t]:l[t]=c,{...e,tabsMetadata:Object.keys(l).length>0?l:void 0}}return e}return e.type==="split"?{...e,first:tt(e.first,t,n)??e.first,second:tt(e.second,t,n)??e.second}:e}function nt(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:nt(e.first,t,n)??e.first,second:nt(e.second,t,n)??e.second}:e}function Ne(e,t,n){return e===null?null:e.type==="pane"?e.id===t?e.activeTabId===n?e:{...e,activeTabId:n}:e:e.type==="split"?{...e,first:Ne(e.first,t,n)??e.first,second:Ne(e.second,t,n)??e.second}:e}function Gt(e,t,n){if(e===null)return null;let o=U(e,t)?.tabsMetadata?.[t],c=fe(e,t);if(c===null)return {type:"pane",id:pe(),tabIds:[t],activeTabId:t,tabsMetadata:o?{[t]:o}:void 0};function l(s){if(s.type==="pane"){if(s.id===n){let u=[...s.tabIds];u.includes(t)||u.push(t);let f={...s.tabsMetadata};return o&&(f[t]=o),{...s,tabIds:u,activeTabId:t,tabsMetadata:Object.keys(f).length>0?f:void 0}}return s}return s.type==="split"?{...s,first:l(s.first),second:l(s.second)}:s}return l(c)}function Jn(e,t,n){if(e===null)return null;if(t===n)return e;let r=U(e,t),o=U(e,n);if(!r||!o)return e;let c=r.id,l=o.id,s=r.tabsMetadata?.[t],u=o.tabsMetadata?.[n];function f(i){if(i.type==="pane"){let b=false,g=[...i.tabIds],m=i.activeTabId,h=i.tabsMetadata?{...i.tabsMetadata}:{};if(c===l){if(i.id===c){let y=g.indexOf(t),D=g.indexOf(n);y!==-1&&D!==-1&&(g[y]=n,g[D]=t),m=t,b=true;}}else i.id===c&&(g=g.map(y=>y===t?n:y),m===t&&(m=n),delete h[t],u&&(h[n]=u),b=true),i.id===l&&(g=g.map(y=>y===n?t:y),m===n&&(m=t),delete h[n],s&&(h[t]=s),b=true);return b?{...i,tabIds:g,activeTabId:m,tabsMetadata:Object.keys(h).length>0?h:void 0}:i}return i.type==="split"?{...i,first:f(i.first),second:f(i.second)}:i}return f(e)}function $e(e,t,n,r="before"){if(e===null)return null;if(t===n)return e;if(r==="center")return Jn(e,t,n);let c=U(e,t)?.tabsMetadata?.[t],l=fe(e,t);if(l===null)return {type:"pane",id:pe(),tabIds:[t],activeTabId:t,tabsMetadata:c?{[t]:c}:void 0};function s(u){if(u.type==="pane"){if(u.tabIds.includes(n)){let i=[...u.tabIds].filter(m=>m!==t),b=i.indexOf(n);b<0&&(b=0),r==="after"&&(b+=1),i.splice(b,0,t);let g={...u.tabsMetadata};return c&&(g[t]=c),{...u,tabIds:i,activeTabId:t,tabsMetadata:Object.keys(g).length>0?g:void 0}}return u}return u.type==="split"?{...u,first:s(u.first),second:s(u.second)}:u}return s(l)}function ve(e,t=0,n=0,r=100,o=100,c="root"){if(e===null)return {panes:[],splitters:[]};if(e.type==="pane")return {panes:[{paneId:e.id,left:t,top:n,width:r,height:o,node:e}],splitters:[]};let{direction:l,splitPercentage:s,first:u,second:f}=e,b={id:`splitter-${c}-${l}`,currentNode:e,direction:l,left:l==="row"?t+r*(s/100):t,top:l==="column"?n+o*(s/100):n,width:l==="row"?0:r,height:l==="column"?0:o,parentLeft:t,parentTop:n,parentWidth:r,parentHeight:o},g={panes:[],splitters:[]},m={panes:[],splitters:[]};if(l==="row"){let h=r*(s/100);g=ve(u,t,n,h,o,`${c}-L`),m=ve(f,t+h,n,r-h,o,`${c}-R`);}else {let h=o*(s/100);g=ve(u,t,n,r,h,`${c}-T`),m=ve(f,t,n+h,r,o-h,`${c}-B`);}return {panes:[...g.panes,...m.panes],splitters:[b,...g.splitters,...m.splitters]}}function Jt(e,t,n,r="before"){if(e===null)return null;let o=te(e,t);if(!o)return e;let c=o.tabIds,l=o.activeTabId,s=o.tabsMetadata||{},u=be(e,t);if(u===null)return o;function f(i){if(i.type==="pane"){if(i.tabIds.includes(n)){let g=[...i.tabIds].filter(y=>!c.includes(y)),m=g.indexOf(n);m<0&&(m=0),r==="after"&&(m+=1),g.splice(m,0,...c);let h={...i.tabsMetadata};for(let y of c)s[y]&&(h[y]=s[y]);return {...i,tabIds:g,activeTabId:l,tabsMetadata:Object.keys(h).length>0?h:void 0}}return i}return i.type==="split"?{...i,first:f(i.first),second:f(i.second)}:i}return f(u)}function Qt(e,t,n,r){if(!((t==="tab"||t==="pane")&&n&&e.includes(n))||!r)return -1;let l=e.indexOf(n);return r==="before"?l:l+1}function Kt(e,t){if(e===t)return true;if(!e||!t)return false;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return false;for(let o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return false;let c=e[o],l=t[o];if(typeof c=="object"&&c!==null&&typeof l=="object"&&l!==null){if(!Kt(c,l))return false}else if(c!==l)return false}return true}function Qn(e,t){if(e===t)return true;if(!e||!t)return false;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return false;for(let o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Kt(e[o],t[o]))return false;return true}function Be(e,t){if(e===t)return true;if(!e||!t||e.type!==t.type)return false;if(e.type==="split"){let n=t;return e.direction===n.direction&&e.splitPercentage===n.splitPercentage&&Be(e.first,n.first)&&Be(e.second,n.second)}else {let n=t;if(e.id!==n.id||e.activeTabId!==n.activeTabId||e.locked!==n.locked||e.tabIds.length!==n.tabIds.length)return false;for(let r=0;r<e.tabIds.length;r++)if(e.tabIds[r]!==n.tabIds[r])return false;return Qn(e.tabsMetadata,n.tabsMetadata)}}function Kn(e){let{initialLayout:t,layout:n,onChange:r,fullscreenPaneId:o,onFullscreenChange:c,locked:l=false}=e,[s,u]=ge.useState(()=>n!==void 0?n:t??null),[f,i]=ge.useState(()=>n!==void 0?n:t??null),b=ge.useRef(n),[g,m]=ge.useState(o||null),[h,y]=ge.useState(l),[D,N]=ge.useState([]),[T,Z]=ge.useState(null),[C,M]=ge.useState(null),[H,a]=ge.useState(null),d=ge.useRef(null),v=ge.useCallback(p=>{d.current=p;},[]),R=ge.useRef(s);R.current=s;let I=ge.useRef(g);I.current=g;let q=ge.useRef(r);q.current=r;let ne=ge.useRef(c);ne.current=c;let G=ge.useCallback(p=>{m(p),ne.current?.(p);},[]);ge.useEffect(()=>{y(l);},[l]),ge.useEffect(()=>{o!==void 0&&m(o);},[o]),n!==void 0&&(Be(n,b.current??null)||(b.current=n,u(n),i(n),N(p=>{if(p.length===0)return p;let w=p.filter(x=>ot(n,x)!==null);return w.length===p.length?p:w})));let A=ge.useCallback(p=>(...w)=>{let x=R.current,$=p(x,...w);Be(x,$)||(R.current=$,u($),i($),N(F=>{if(F.length===0)return F;let se=F.filter(W=>ot($,W)!==null);return se.length===F.length?F:se}),q.current?.($));},[]),B=ge.useCallback(A((p,w)=>typeof w=="function"?w(p):w),[A]),j=ge.useCallback(p=>{I.current===null&&i(w=>typeof p=="function"?p(w):p);},[]),V=ge.useCallback(p=>{m(null),ne.current?.(null),Z(null),M(null),a(null),B(p),i(()=>typeof p=="function"?p(R.current):p);},[B]),_=ge.useCallback(A((p,w)=>I.current!==null?p:be(p,w)),[A]),L=ge.useCallback(A((p,w,x,$)=>{if(I.current!==null)return p;let F=fe(p,w)??p;return qt(F,x,w,$)}),[A]),P=ge.useCallback(A((p,w,x,$,F)=>{if(I.current!==null)return p;let se=te(p,w)??U(p,w);if(!se)return p;let W=te(p,F)??U(p,F)??{type:"pane",id:F,tabIds:[F],activeTabId:F},ye=be(p,W.id);return Se(ye,se.id,x,$,W)}),[A]),z=ge.useCallback(A((p,w,x)=>I.current!==null?p:xe(p,w,x)),[A]),E=ge.useCallback(A((p,w,x)=>tt(p,w,x)),[A]),O=ge.useCallback(A((p,w,x)=>{let $=te(p,w)??U(p,w);return $?nt(p,$.id,x):p}),[A]),ue=ge.useCallback(A((p,w,x)=>{let $=te(p,w)??U(p,w);return $?Ne(p,$.id,x):p}),[A]),Q=ge.useCallback(A((p,w,x)=>{if(I.current!==null)return p;let $=te(p,x)??U(p,x);return $?Gt(p,w,$.id):p}),[A]),K=ge.useCallback(A((p,w,x,$)=>I.current!==null?p:$e(p,w,x,$)),[A]),Y=ge.useCallback(A((p,w)=>I.current!==null?p:fe(p,w)),[A]),ee=ge.useCallback(p=>te(R.current,p),[]),S=ge.useCallback(p=>U(R.current,p),[]),k=ge.useCallback(p=>ot(R.current,p),[]),ie=ge.useCallback(p=>Xt(R.current,p),[]),le=ge.useCallback(p=>Yt(R.current,p),[]),J=ge.useCallback(p=>{I.current===null&&N(w=>w.includes(p)?w:[...w,p]);},[]),oe=ge.useCallback(p=>{I.current===null&&N(w=>w.includes(p)?w.filter(x=>x!==p):w);},[]);return {layout:s,setLayout:V,_internalSetLayout:j,renderingLayout:f,fullscreenPaneId:g,setFullscreenPaneId:G,locked:h,setLocked:y,poppedOutTabIds:D,activeId:T,setActiveId:Z,activeType:C,setActiveType:M,dismissIntentId:H,setDismissIntentId:a,containerRef:d,setContainerRef:v,removePane:_,addTab:L,updateMetadata:E,updatePaneLock:O,selectTab:ue,mergeTab:Q,moveTab:K,removeTab:Y,splitPane:P,updateSplitPercentage:z,popoutTab:J,dockTab:oe,findPaneById:ee,findPaneContainingTab:S,findTabById:k,getTabMetadata:ie,getActiveTabMetadata:le}}var eo=()=>{let e=re(),t=He();return {layout:e.layout,setLayout:e.setLayout,fullscreenPaneId:e.fullscreenPaneId,setFullscreenPaneId:t.setFullscreenPaneId,locked:e.locked,setLocked:t.setLocked,removePane:t.removePane,addTab:t.addTab,updateMetadata:t.updateMetadata,updatePaneLock:t.updatePaneLock,selectTab:t.selectTab,mergeTab:t.mergeTab,removeTab:t.removeTab,splitPane:t.splitPane,updateSplitPercentage:t.updateSplitPercentage,moveTab:t.moveTab,findPaneById:e.findPaneById,findPaneContainingTab:e.findPaneContainingTab,findTabById:e.findTabById,getTabMetadata:e.getTabMetadata,getActiveTabMetadata:e.getActiveTabMetadata,poppedOutTabIds:e.poppedOutTabIds,popoutTab:t.popoutTab,dockTab:t.dockTab}};var rt=class extends core.PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},at=class extends core.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};var tn=e=>{let n=e.active.id.toString().startsWith("tab-header-"),o=core.pointerWithin(e);if(o.length>0)return [...o].sort((l,s)=>{let u=l.id.toString(),f=s.id.toString(),i=u.startsWith("tab-drop-"),b=f.startsWith("tab-drop-");if(i&&!b)return -1;if(!i&&b)return 1;let g=u.startsWith("drop-root-"),m=f.startsWith("drop-root-");return g&&!m?-1:!g&&m?1:0});if(n){let c=e.droppableContainers.filter(l=>l.id.toString().startsWith("tab-drop-"));return core.closestCenter({...e,droppableContainers:c})}return []};function _e(e){if(e instanceof MouseEvent||e instanceof PointerEvent)return {x:e.clientX,y:e.clientY};if(typeof TouchEvent<"u"&&e instanceof TouchEvent){let t=e.touches[0]||e.changedTouches[0];if(t)return {x:t.clientX,y:t.clientY}}return null}function rn(e){let{layout:t,_internalSetLayout:n,setLayout:r,activeId:o,setActiveId:c,activeType:l,setActiveType:s,dismissIntentId:u,setDismissIntentId:f,setOverTabId:i,setOverTabPosition:b,containerRef:g,dragActivationDistance:m,enableDragToDismiss:h,dismissThreshold:y,onRemove:D,onDragStart:N,onDragEnd:T,onDismissIntentChange:Z,removeTab:C,removePane:M}=e,H=ge.useRef(null),a=Bt(o),d=ge.useRef(null),[v,R]=ge.useState(false);return _t(v),{sensors:core.useSensors(core.useSensor(rt,{activationConstraint:{distance:m}}),core.useSensor(at,{activationConstraint:{delay:250,tolerance:5}})),collisionDetection:tn,onDragStart:B=>{let j=B.active.id.toString(),V=j.startsWith("tab-header-"),_=V?j.substring(11):j;c(_),s(V?"tab":"pane"),i(null),b(null);let L=B.activatorEvent;a.current=_e(L),h&&g.current?H.current=g.current.getBoundingClientRect():H.current=null;let P=t;if(V){let E=U(t,_);E&&(P=Ne(t,E.id,_)||t);}d.current=P;let z=V?fe(P,_):be(P,_);n(z),N&&N(_);},onDragMove:B=>{let{over:j}=B,V=j?.id.toString()||"",_=V.startsWith("drop-locked-");R(S=>S===_?S:_);let L=B.active.id.toString(),P=L.startsWith("tab-header-"),z=P?L.substring(11):L,E=V.match(/^tab-drop-(.+)$/);if(E&&j&&(P||l==="pane")){let[,S]=E;if(z!==S){let k="before",ie=j.rect,le=B.activatorEvent,J=null;if(a.current)J=a.current.x;else {let oe=_e(le);oe&&(J=oe.x+B.delta.x);}if(J!==null){let oe=ie.left+ie.width/2;J>oe&&(k="after");}i(oe=>oe===S?oe:S),b(oe=>oe===k?oe:k);}else i(k=>k===null?k:null),b(k=>k===null?k:null);}else i(S=>S===null?S:null),b(S=>S===null?S:null);if(!h)return;let O=H.current;if(!O){u!==null&&(f(null),Z?.(null));return}let ue=B.activatorEvent,Q=null,K=null;if(a.current)Q=a.current.x,K=a.current.y;else {let S=_e(ue);S&&(Q=S.x+B.delta.x,K=S.y+B.delta.y);}let Y=0;if(Q!==null&&K!==null){let S=0,k=0;Q<O.left?S=O.left-Q:Q>O.right&&(S=Q-O.right),K<O.top?k=O.top-K:K>O.bottom&&(k=K-O.bottom),Y=Math.sqrt(S*S+k*k);}else {let S=B.active.rect.current.translated;if(S){let k=S.left+S.width/2,ie=S.top+S.height/2,le=0,J=0;k<O.left?le=O.left-k:k>O.right&&(le=k-O.right),ie<O.top?J=O.top-ie:ie>O.bottom&&(J=ie-O.bottom),Y=Math.sqrt(le*le+J*J);}}Y>y?u!==z&&(f(z),Z?.(z)):u!==null&&(f(null),Z?.(null));},onDragEnd:B=>{c(null),s(null),R(false),i(null),b(null);let{active:j,over:V}=B,_=j.id.toString(),L=_.startsWith("tab-header-"),P=L?_.substring(11):_,z=h&&u===P;f(null),Z?.(null),H.current=null;let E=d.current||t;if(d.current=null,z){D?D(P):L?C(P):M(P),T&&T(P,null,null);return}if(!V){n(E),T&&T(P,null,null);return}let O=V.id.toString();if(O.startsWith("drop-locked-")){n(E),T&&T(P,null,null);return}let ue=O.match(/^tab-drop-(.+)$/);if(ue){let[,p]=ue;if(L)if(P!==p){let w="before",x=V.rect,$=B.activatorEvent,F=null;if(a.current)F=a.current.x;else {let W=_e($);W&&(F=W.x+B.delta.x);}if(F!==null){let W=x.left+x.width/2;F>W&&(w="after");}let se=$e(E,P,p,w);r(se),T&&T(P,p,{type:"move",position:"center"});}else n(E),T&&T(P,null,null);else {let w="before",x=V.rect,$=B.activatorEvent,F=null;if(a.current)F=a.current.x;else {let W=_e($);W&&(F=W.x+B.delta.x);}if(F!==null){let W=x.left+x.width/2;F>W&&(w="after");}let se=Jt(E,P,p,w);r(se),T&&T(P,p,{type:"move",position:"center"});}return}let Q=O.match(/^drop-root-(1\/4|1\/3)-(top|bottom|left|right|start|end)$/);if(Q){let[,p,w]=Q,x=w;x==="start"&&(x="left"),x==="end"&&(x="right");let $=L?fe(E,P):be(E,P),F;if(L){let W=U(E,P)?.tabsMetadata?.[P];F={type:"pane",id:pe(),tabIds:[P],activeTabId:P,tabsMetadata:W?{[P]:W}:void 0};}else F=te(E,P)??{type:"pane",id:pe(),tabIds:[P],activeTabId:P};if($===null)r(F);else {let se=x==="left"||x==="right",W=x==="left"||x==="top",ye=50;p==="1/4"?ye=W?25:75:p==="1/3"&&(ye=W?100/3:200/3),r({type:"split",direction:se?"row":"column",first:W?F:$,second:W?$:F,splitPercentage:ye});}T&&T(P,"root",{type:"split",direction:x==="left"||x==="right"?"row":"column",position:x});return}let K=O.match(/^drop-(left|right|top|bottom|center)-(.+)$/);if(!K){n(E),T&&T(P,null,null);return}let[,Y,ee]=K;if(Y==="center"){if(L){let p=te(E,ee);if(p&&p.activeTabId){let w=p.activeTabId,x=$e(E,P,w,"center");r(x),T&&T(P,ee,{type:"move",position:"center"});}else n(E),T&&T(P,null,null);}else n(E),T&&T(P,null,null);return}let S=L?U(E,P):te(E,P),k=S&&S.id===ee,ie=S&&S.tabIds.length===1;if(P===ee||k&&ie){n(E),T&&T(P,null,null);return}let le=Y==="left"||Y==="right"?"row":"column",J;if(L){let w=U(E,P)?.tabsMetadata?.[P];J={type:"pane",id:pe(),tabIds:[P],activeTabId:P,tabsMetadata:w?{[P]:w}:void 0};}else J=te(E,P)??{type:"pane",id:pe(),tabIds:[P],activeTabId:P};let oe=L?fe(E,P):be(E,P),Ze=Se(oe,ee,le,Y,J);r(Ze),T&&T(P,ee,{type:"split",direction:le,position:Y});},onDragCancel:()=>{c(null),s(null),R(false),i(null),b(null),f(null),Z?.(null),H.current=null;let B=d.current||t;d.current=null,n(B),B!==t&&r(B);}}}function sn({persist:e,layout:t,setLayout:n}){let r=typeof e=="object"?e.enabled!==false:!!e,o=typeof e=="object"&&e.key||"zeugma-layout",[c,l]=ge.useState(false);ge.useEffect(()=>{if(r){let s=localStorage.getItem(o);if(s)try{let u=JSON.parse(s);u&&n(u);}catch(u){console.error("Failed to parse persisted zeugma layout",u);}}l(true);},[r,o,n]),ge.useEffect(()=>{r&&c&&(t?localStorage.setItem(o,JSON.stringify(t)):localStorage.removeItem(o));},[r,o,t,c]);}var Ce=null,cn=false,ae=new Set,De=new Set,Le=null;function co(){typeof window>"u"||Le||(Le=new MutationObserver(e=>{e.forEach(t=>{t.addedNodes.forEach(n=>{n instanceof HTMLElement&&(n.tagName.toLowerCase()==="style"||n.tagName.toLowerCase()==="link")&&ae.forEach(r=>{try{let o=n.cloneNode(!0);if(o.tagName.toLowerCase()==="link"){let c=n.href;c&&o.setAttribute("href",c);}r.head.appendChild(o);}catch(o){console.warn("Failed to mirror style node to popout:",o);}});});});}),Le.observe(document.head,{childList:true}));}function yt(){Le&&(Le.disconnect(),Le=null);}var ke=null;function uo(){typeof window>"u"||ke||(ke=new MutationObserver(e=>{e.forEach(t=>{if(t.type==="attributes"&&t.attributeName){let n=document.documentElement.getAttribute(t.attributeName);ae.forEach(r=>{try{r&&r.documentElement&&(n!==null?r.documentElement.setAttribute(t.attributeName,n):r.documentElement.removeAttribute(t.attributeName));}catch(o){console.warn("Failed to sync documentElement attribute:",o);}});}});}),ke.observe(document.documentElement,{attributes:true}));}function Tt(){ke&&(ke.disconnect(),ke=null);}var un=e=>{typeof requestAnimationFrame<"u"?requestAnimationFrame(e):setTimeout(e,0);};function me(){if(typeof window>"u")return document;if(Ce&&Ce.target){let t=Ce.target.ownerDocument;if(t&&t!==document)return t}let e=window.event;if(e&&e.target){let n=e.target.ownerDocument;if(n&&n!==document)return n}return window.__zeugmaActivePopoutDocument?window.__zeugmaActivePopoutDocument:document}function dn(){if(typeof window>"u"||cn)return;cn=true;let e=(a,d)=>{if(!a||!d)return false;try{let v=Object.getPrototypeOf(a);for(;v;){if(v===d)return !0;v=Object.getPrototypeOf(v);}}catch{}return false},t=(a,d)=>{try{Object.defineProperty(a,Symbol.hasInstance,{value:function(v){return v?e(v,a.prototype)?!0:d(v):!1},configurable:!0,writable:!0});}catch(v){console.warn("Failed to patch Symbol.hasInstance on",a,v);}};typeof Node<"u"&&t(Node,a=>typeof a.nodeType=="number"&&typeof a.nodeName=="string"),typeof Element<"u"&&t(Element,a=>a.nodeType===1),typeof HTMLElement<"u"&&t(HTMLElement,a=>a.nodeType===1&&typeof a.style=="object"),typeof HTMLBodyElement<"u"&&t(HTMLBodyElement,a=>a.nodeType===1&&a.tagName==="BODY"),typeof HTMLHtmlElement<"u"&&t(HTMLHtmlElement,a=>a.nodeType===1&&a.tagName==="HTML"),typeof HTMLInputElement<"u"&&t(HTMLInputElement,a=>a.nodeType===1&&a.tagName==="INPUT"),typeof HTMLTextAreaElement<"u"&&t(HTMLTextAreaElement,a=>a.nodeType===1&&a.tagName==="TEXTAREA"),typeof ShadowRoot<"u"&&t(ShadowRoot,a=>a.nodeType===11&&a.host!==void 0),typeof SVGElement<"u"&&t(SVGElement,a=>a.nodeType===1&&typeof a.getBBox=="function"),typeof Document<"u"&&t(Document,a=>a.nodeType===9),typeof Window<"u"&&t(Window,a=>a&&typeof a.document=="object"&&typeof a.location=="object");let n=Document.prototype,r=Object.getOwnPropertyDescriptor(n,"body"),o=Object.getOwnPropertyDescriptor(n,"documentElement"),c=Object.getOwnPropertyDescriptor(n,"head"),l=Object.getOwnPropertyDescriptor(n,"activeElement"),s=Object.getOwnPropertyDescriptor(n,"defaultView"),u=Object.getOwnPropertyDescriptor(n,"scrollingElement");Object.defineProperties(document,{body:{get(){let a=me();return a&&a!==document?a.body:r?.get?.call(document)||document.body},configurable:true},documentElement:{get(){let a=me();return a&&a!==document?a.documentElement:o?.get?.call(document)||document.documentElement},configurable:true},head:{get(){let a=me();return a&&a!==document?a.head:c?.get?.call(document)||document.head},configurable:true},activeElement:{get(){let a=me();return a&&a!==document?a.activeElement:l?.get?.call(document)||document.activeElement},configurable:true},defaultView:{get(){let a=me();return a&&a!==document?a.defaultView:s?.get?.call(document)||document.defaultView},configurable:true},scrollingElement:{get(){let a=me();return a&&a!==document?a.scrollingElement:u?.get?.call(document)||document.scrollingElement},configurable:true}});let f=Window.prototype,i=["innerWidth","innerHeight","pageXOffset","pageYOffset","scrollX","scrollY","screenX","screenY","outerWidth","outerHeight","devicePixelRatio"],b={};i.forEach(a=>{let d=Object.getOwnPropertyDescriptor(f,a)||Object.getOwnPropertyDescriptor(window,a);d&&d.get&&(b[a]=d.get);}),i.forEach(a=>{Object.defineProperty(window,a,{get(){let d=me();if(d&&d!==document&&d.defaultView)try{return d.defaultView[a]}catch{}let v=b[a];return v?v.call(window):window[a]},configurable:true});});let g=Node.prototype.contains;Node.prototype.contains=function(a){if(!a)return false;if(g.call(this,a))return true;if(this===document||this===document.body||this===document.documentElement)for(let d of ae)try{if(d.contains(a))return !0}catch{}return false};let m=()=>{Ce=null,globalThis.__zeugmaActivePopoutDocument=null;};["pointerdown","mousedown","click","keydown","focus","touchstart"].forEach(a=>{window.addEventListener(a,m,true);});let y=document.createElement;document.createElement=function(a,d){let v=me();return v&&v!==document?v.createElement(a,d):y.call(document,a,d)};let D=document.addEventListener;document.addEventListener=function(a,d,v){De.add({target:"document",type:a,listener:d,options:v}),D.call(document,a,d,v),ae.forEach(R=>{try{R.addEventListener(a,d,v);}catch{}});};let N=document.removeEventListener;document.removeEventListener=function(a,d,v){for(let R of De)if(R.target==="document"&&R.type===a&&R.listener===d){De.delete(R);break}N.call(document,a,d,v),ae.forEach(R=>{try{R.removeEventListener(a,d,v);}catch{}});};let T=window.addEventListener;window.addEventListener=function(a,d,v){De.add({target:"window",type:a,listener:d,options:v}),T.call(window,a,d,v),ae.forEach(R=>{try{R.defaultView&&R.defaultView.addEventListener(a,d,v);}catch{}});};let Z=window.removeEventListener;window.removeEventListener=function(a,d,v){for(let R of De)if(R.target==="window"&&R.type===a&&R.listener===d){De.delete(R);break}Z.call(window,a,d,v),ae.forEach(R=>{try{R.defaultView&&R.defaultView.removeEventListener(a,d,v);}catch{}});};let C=document.getElementById;document.getElementById=function(a){let d=me();if(d&&d!==document)return d.getElementById(a);let v=C.call(document,a);if(v)return v;for(let R of ae)try{let I=R.getElementById(a);if(I)return I}catch{}return null};let M=document.querySelector;document.querySelector=function(a){let d=me();if(d&&d!==document)return d.querySelector(a);let v=M.call(document,a);if(v)return v;for(let R of ae)try{let I=R.querySelector(a);if(I)return I}catch{}return null};let H=document.querySelectorAll;document.querySelectorAll=function(a){let d=me();if(d&&d!==document)return d.querySelectorAll(a);let v=H.call(document,a);if(v.length>0)return v;for(let R of ae)try{let I=R.querySelectorAll(a);if(I.length>0)return I}catch{}return v};}function pn(e){let{poppedOutTabIds:t,registerPopoutTarget:n,findTabById:r,dockTab:o}=e,c=ge.useRef({});ge.useEffect(()=>{let l=c.current;t.forEach(s=>{if(l[s]){try{l[s].focus();}catch{}return}dn();let f=r(s)?.metadata?.title||`Tab ${s}`,i=window.open("",`zeugma-popout-${s}`,"width=800,height=600");if(!i){console.warn("Failed to open popout window. Check popup blocker."),o(s);return}l[s]=i,ae.add(i.document),De.forEach(d=>{try{d.target==="window"?i.addEventListener(d.type,d.listener,d.options):i.document.addEventListener(d.type,d.listener,d.options);}catch{}}),co(),uo(),i.document.title=f,i.document.head.innerHTML="";try{let d=i.document.createElement("base");d.setAttribute("href",window.location.origin+"/"),i.document.head.appendChild(d);}catch{}if(Array.from(document.querySelectorAll('style, link[rel="stylesheet"]')).forEach(d=>{let v=d.cloneNode(true);if(d.tagName.toLowerCase()==="link"){let R=d.href;R&&v.setAttribute("href",R);}else if(d.tagName.toLowerCase()==="style")try{let R=d.sheet?.cssRules;if(R&&R.length>0){let I=Array.from(R).map(q=>q.cssText).join(`
10
- `);v.textContent=I;}}catch{}i.document.head.appendChild(v);}),typeof document.adoptedStyleSheets<"u"&&typeof i.document.adoptedStyleSheets<"u")try{let d=Array.from(document.adoptedStyleSheets).map(v=>{try{let R=new i.CSSStyleSheet,I=Array.from(v.cssRules).map(q=>q.cssText).join(`
11
- `);return R.replaceSync(I),R}catch{return null}}).filter(v=>v!==null);i.document.adoptedStyleSheets=d;}catch(d){console.warn("Failed to copy adoptedStyleSheets:",d);}i.document.documentElement.className=document.documentElement.className,i.document.body.className=document.body.className,Array.from(document.documentElement.attributes).forEach(d=>{i.document.documentElement.setAttribute(d.name,d.value);}),i.document.body.style.margin="0",i.document.body.style.padding="0",i.document.body.style.height="100vh",i.document.body.style.overflow="hidden";let b=document.getElementById(`zeugma-tab-target-${s}`),g="";b&&(g=window.getComputedStyle(b).backgroundColor,(!g||g==="transparent"||g==="rgba(0, 0, 0, 0)")&&b.parentElement&&(g=window.getComputedStyle(b.parentElement).backgroundColor));let m=window.getComputedStyle(document.documentElement),h=window.getComputedStyle(document.body),y=h.backgroundColor,N=!y||y==="transparent"||y==="rgba(0, 0, 0, 0)"?m.backgroundColor:y,T=g&&g!=="transparent"&&g!=="rgba(0, 0, 0, 0)"?g:N&&N!=="transparent"&&N!=="rgba(0, 0, 0, 0)"?N:"#181b1f";document.documentElement.getAttribute("data-theme")||(i.document.documentElement.style.backgroundColor=T,i.document.body.style.backgroundColor=T),i.document.body.style.color=h.color||m.color,i.document.body.style.fontFamily=h.fontFamily||m.fontFamily;let C=i.document.createElement("div");C.id=`zeugma-popout-container-${s}`,C.className="grafana-panel h-full w-full overflow-hidden",C.style.width="100%",C.style.height="100%",C.style.border="none",i.document.body.appendChild(C),n?.(s,C);let M=["pointerdown","mousedown","click","keydown","focus","touchstart"],H=d=>{Ce=d,globalThis.__zeugmaActivePopoutDocument=i.document,setTimeout(()=>{Ce===d&&(Ce=null,globalThis.__zeugmaActivePopoutDocument=null);},0);};M.forEach(d=>{i.addEventListener(d,H,true);});let a=()=>{ae.delete(i.document),ae.size===0&&(yt(),Tt()),o(s);};i.addEventListener("beforeunload",a),i.__zeugmaCleanup=()=>{M.forEach(d=>{i.removeEventListener(d,H,true);}),i.removeEventListener("beforeunload",a);};}),Object.keys(l).forEach(s=>{if(!t.includes(s)){let u=l[s];if(delete l[s],n?.(s,null),u){ae.delete(u.document),ae.size===0&&(yt(),Tt());try{let f=u;f.__zeugmaCleanup&&f.__zeugmaCleanup(),un(()=>{try{f.close();}catch{}});}catch{}}}});},[t,n,r,o]),ge.useEffect(()=>()=>{let l=c.current;Object.keys(l).forEach(s=>{let u=l[s];if(u){ae.delete(u.document);try{let f=u;f.__zeugmaCleanup&&f.__zeugmaCleanup(),un(()=>{try{f.close();}catch{}});}catch{}}}),ae.size===0&&(yt(),Tt());},[]);}typeof window<"u"&&dn();var fn=({activeId:e,render:t,className:n})=>{let r=ge.useRef(null);return ge.useEffect(()=>{let o=c=>{r.current&&(r.current.style.transform=`translate(${c.clientX+12}px, ${c.clientY+12}px)`);};return document.addEventListener("pointermove",o),()=>document.removeEventListener("pointermove",o)},[]),jsxRuntime.jsx("div",{ref:r,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var ho=({popoutDoc:e,children:t})=>{if(e===document)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:t});let n=ge__default.default.useEffect,r=ge__default.default.useLayoutEffect,o=ge__default.default.useInsertionEffect;ge__default.default.useEffect=(c,l)=>n(()=>{window.__zeugmaActivePopoutDocument=e;try{let s=c();return typeof s=="function"?()=>{window.__zeugmaActivePopoutDocument=e;try{return s()}finally{window.__zeugmaActivePopoutDocument=null;}}:s}finally{window.__zeugmaActivePopoutDocument=null;}},l),ge__default.default.useLayoutEffect=(c,l)=>r(()=>{window.__zeugmaActivePopoutDocument=e;try{let s=c();return typeof s=="function"?()=>{window.__zeugmaActivePopoutDocument=e;try{return s()}finally{window.__zeugmaActivePopoutDocument=null;}}:s}finally{window.__zeugmaActivePopoutDocument=null;}},l),o&&(ge__default.default.useInsertionEffect=(c,l)=>o(()=>{window.__zeugmaActivePopoutDocument=e;try{let s=c();return typeof s=="function"?()=>{window.__zeugmaActivePopoutDocument=e;try{return s()}finally{window.__zeugmaActivePopoutDocument=null;}}:s}finally{window.__zeugmaActivePopoutDocument=null;}},l)),window.__zeugmaActivePopoutDocument=e;try{return jsxRuntime.jsx(jsxRuntime.Fragment,{children:t})}finally{window.__zeugmaActivePopoutDocument=null,ge__default.default.useEffect=n,ge__default.default.useLayoutEffect=r,o&&(ge__default.default.useInsertionEffect=o);}},gn=ge__default.default.memo(({tabDetails:e,target:t,renderWidget:n})=>{let{id:r}=e,{renderPopoutWrapper:o}=re(),[c,l]=ge.useState(false),s=ge.useRef(null);if(ge.useEffect(()=>{l(true);},[]),ge.useEffect(()=>{if(!c||!s.current)return;let m=s.current;if(t)t.ownerDocument.adoptNode(m),t.appendChild(m);else {let h=document.getElementById("zeugma-hidden-portal-container");h||(h=document.createElement("div"),h.id="zeugma-hidden-portal-container",h.style.display="none",document.body.appendChild(h)),document.adoptNode(m),h.appendChild(m);}},[t,c]),ge.useEffect(()=>()=>{s.current&&s.current.remove();},[]),!c)return null;let u=t?t.ownerDocument:document;s.current&&s.current.ownerDocument!==u&&u.adoptNode(s.current),s.current||(s.current=u.createElement("div"),s.current.className=`zeugma-portal-wrapper-${r}`,s.current.style.width="100%",s.current.style.height="100%");let f=s.current;if(!f||!n)return null;let i=!!(t&&t.ownerDocument&&t.ownerDocument!==document),b=e.remountOnPopout?i?"-popped":"-docked":"",g=jsxRuntime.jsx(ge__default.default.Fragment,{children:n(e)},`${r}${b}`);return i&&t&&t.ownerDocument&&o&&(g=o({tabId:r,document:t.ownerDocument,window:t.ownerDocument.defaultView||window,children:g})),reactDom.createPortal(jsxRuntime.jsx(ho,{popoutDoc:i&&t?t.ownerDocument:document,children:g}),f)},(e,t)=>e.target===t.target&&e.renderWidget===t.renderWidget&&e.tabDetails.id===t.tabDetails.id&&e.tabDetails.paneId===t.tabDetails.paneId&&e.tabDetails.isActive===t.tabDetails.isActive&&e.tabDetails.index===t.tabDetails.index&&e.tabDetails.metadata===t.tabDetails.metadata);var bn=({activeId:e,activeType:t,dismissIntentId:n,renderDragOverlay:r,renderPaneRef:o,renderPane:c,tabHeadersRef:l,classNames:s})=>{if(r)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:r({type:t,id:e,isDismissing:e===n})});if(t==="pane"){let u=o.current||c;if(u)return jsxRuntime.jsx("div",{className:s.paneDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:u(e)})}else if(t==="tab"){let u=o.current||c;if(u)return jsxRuntime.jsx("div",{className:s.tabDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:u(e)});let f=l.current[e];if(f){let i=s.tab?typeof s.tab=="function"?s.tab(e):s.tab:"";return jsxRuntime.jsx("div",{className:`${s.tabDragPreview||""} ${i}`.trim(),style:{display:"inline-flex",position:"relative",pointerEvents:"none",overflow:"hidden"},children:f({isDragging:true,isOver:false})})}}return jsxRuntime.jsx("div",{style:{pointerEvents:"none",overflow:"hidden",width:"100%",height:"100%"}})};function Rt({containerRef:e,isRow:t,direction:n,splitPercentage:r,resizerSize:o,snapThreshold:c,layout:l,currentNode:s,onLayoutChange:u,onResizeStart:f,onResizeEnd:i,parentLeft:b,parentTop:g,parentWidth:m,parentHeight:h}){let{onResizeStart:y,onResize:D,onResizeEnd:N,minSplitPercentage:T=5,maxSplitPercentage:Z=95,locked:C=false}=re();return ge.useCallback(M=>{if(C)return;M.preventDefault();let H=e.current;if(!H)return;f&&f(),y&&y(s);let a=H.getBoundingClientRect(),d=M.clientX,v=M.clientY,R=r,I=M.currentTarget,q=a.left+a.width*(b/100),ne=a.top+a.height*(g/100),G=a.width*(m/100),A=a.height*(h/100),j=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(_=>_!==I&&_.getAttribute("data-direction")===n).map(_=>{let L=_.getBoundingClientRect();return t?L.left+L.width/2:L.top+L.height/2}),V=R;Ht({cursor:t?"col-resize":"row-resize",resizerEl:I,onMove:_=>{let L=t?(_.clientX-d)/G*100:(_.clientY-v)/A*100,P=R+L,z=t?q+(G-o)*(P/100)+o/2:ne+(A-o)*(P/100)+o/2,E=1/0,O=null;for(let Y of j){let ee=Math.abs(z-Y);ee<c&&ee<E&&(E=ee,O=Y);}let ue=P;O!==null&&(ue=t?(O-o/2-q)/(G-o)*100:(O-o/2-ne)/(A-o)*100);let Q=Math.max(T,Math.min(Z,ue));V=Q;let K=xe(l,s,Q);if(K){let{panes:Y,splitters:ee}=ve(K),S=e.current;if(S){for(let k of Y)S.style.setProperty(`--pane-left-${k.paneId}`,`${k.left}%`),S.style.setProperty(`--pane-top-${k.paneId}`,`${k.top}%`),S.style.setProperty(`--pane-width-${k.paneId}`,`${k.width}%`),S.style.setProperty(`--pane-height-${k.paneId}`,`${k.height}%`);for(let k of ee)S.style.setProperty(`--splitter-pos-${k.id}`,`${k.direction==="row"?k.left:k.top}%`);}}D&&D(s,Q);},onEnd:()=>{let _=xe(l,s,V),L=e.current;if(L){let{panes:P,splitters:z}=ve(_);for(let E of P)L.style.removeProperty(`--pane-left-${E.paneId}`),L.style.removeProperty(`--pane-top-${E.paneId}`),L.style.removeProperty(`--pane-width-${E.paneId}`),L.style.removeProperty(`--pane-height-${E.paneId}`);for(let E of z)L.style.removeProperty(`--splitter-pos-${E.id}`);}u(_),i&&i(),N&&N(s,V);}});},[e,t,n,r,o,c,l,s,u,f,i,y,D,N,T,Z,b,g,m,h])}var vn=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:r})=>{let{renderingLayout:o,setLayout:c,classNames:l,locked:s}=re(),[u,f]=ge.useState(false),{currentNode:i,direction:b,left:g,top:m,width:h,height:y,parentLeft:D,parentTop:N,parentWidth:T,parentHeight:Z}=e,C=b==="row",M=Rt({containerRef:r,isRow:C,direction:b,splitPercentage:i.splitPercentage,resizerSize:t,snapThreshold:n,layout:o,currentNode:i,onLayoutChange:c,onResizeStart:()=>f(true),onResizeEnd:()=>f(false),parentLeft:D,parentTop:N,parentWidth:T,parentHeight:Z}),H=C?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${g}%) - ${t/2}px)`,top:`calc(${m}% + ${t/2}px)`,width:`${t}px`,height:`calc(${y}% - ${t}px)`,cursor:s?"default":"col-resize",pointerEvents:s?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`calc(${g}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${m}%) - ${t/2}px)`,width:`calc(${h}% - ${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:l.resizer||"","data-direction":b,"data-resizing":u||void 0,style:H,onPointerDown:M,role:"separator","aria-valuenow":i.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},hn=ge__default.default.memo(({paneId:e,renderPane:t})=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane);var wt=({renderPane:e,tree:t,resizerSize:n,snapThreshold:r})=>{jt(e);let{renderingLayout:o,activeId:c,dismissIntentId:l,setContainerRef:s,fullscreenPaneId:u,snapThreshold:f,locked:i,classNames:b,resizerSize:g}=re(),m=r!==void 0?r:f??8,h=n!==void 0?n:g??4,y=t!==void 0?t:o,D=ge.useRef(null),{panes:N,splitters:T}=ge.useMemo(()=>y?ve(y):{panes:[],splitters:[]},[y]);if(!y&&t!==void 0)return null;let Z=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[N.map(C=>{let M=u===C.paneId;return jsxRuntime.jsx("div",{style:{position:"absolute",left:M?"0%":`var(--pane-left-${C.paneId}, ${C.left}%)`,top:M?"0%":`var(--pane-top-${C.paneId}, ${C.top}%)`,width:M?"100%":`var(--pane-width-${C.paneId}, ${C.width}%)`,height:M?"100%":`var(--pane-height-${C.paneId}, ${C.height}%)`,overflow:"hidden",zIndex:M?20:1,display:u&&!M?"none":"block",padding:M?"0px":`${h/2}px`,boxSizing:"border-box"},children:jsxRuntime.jsx(hn,{paneId:C.paneId,renderPane:e})},C.paneId)}),!u&&T.map(C=>jsxRuntime.jsx(vn,{splitter:C,resizerSize:h,snapThreshold:m,containerRef:D},C.id))]});if(t===void 0){let C=c!==null&&c===l,M=a=>{s(a),D.current=a;},H=`${b.dashboard||""} ${C&&b.dashboardDismissActive||""} ${i&&b.dashboardLocked||""}`.trim();return jsxRuntime.jsxs("div",{ref:M,className:H,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[Z(),c!==null&&!i&&jsxRuntime.jsx(Pn,{activeClassName:b.rootDropPreview??b.dropPreview})]})}return jsxRuntime.jsx("div",{ref:D,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:Z()})};var So=e=>{let{controller:t,children:n,renderDragOverlay:r,classNames:o={},renderPane:c,resizerSize:l,dragActivationDistance:s=8,snapThreshold:u=8,minSplitPercentage:f=5,maxSplitPercentage:i=95,enableDragToDismiss:b=false,dismissThreshold:g=60,onRemove:m,onDragStart:h,onDragEnd:y,onResizeStart:D,onResize:N,onResizeEnd:T,onDismissIntentChange:Z,persist:C=false,renderPopoutWrapper:M}=e,H=t,{layout:a,setLayout:d,_internalSetLayout:v,renderingLayout:R,fullscreenPaneId:I,setFullscreenPaneId:q,locked:ne,setLocked:G,findPaneById:A,findPaneContainingTab:B,findTabById:j,getTabMetadata:V,getActiveTabMetadata:_,activeId:L,setActiveId:P,activeType:z,setActiveType:E,dismissIntentId:O,setDismissIntentId:ue,containerRef:Q,setContainerRef:K,removePane:Y,addTab:ee,updateMetadata:S,updatePaneLock:k,selectTab:ie,mergeTab:le,removeTab:J,splitPane:oe,updateSplitPercentage:Ze,moveTab:p,poppedOutTabIds:w=[],popoutTab:x,dockTab:$}=H;sn({persist:C,layout:a,setLayout:d});let{portalTargets:F,registerPortalTarget:se,registerPopoutTarget:W,registerRenderCallback:ye,renderCallbacksRef:Xe,registerRenderPane:Lt,renderPaneRef:ft,registerTabHeader:kt,tabHeadersRef:mt,activeIdRef:Ye}=Ft();pn({poppedOutTabIds:w,registerPopoutTarget:W,findTabById:j,dockTab:$});let Mt=ge.useCallback(de=>w.includes(de),[w]),{overTabId:Ot,setOverTabId:Hn,overTabPosition:At,setOverTabPosition:$n,handleDragStartInternal:Bn,handleDragEndInternal:_n}=Wt({onDragStart:h,onDragEnd:y}),Fn=rn({layout:a,_internalSetLayout:v,setLayout:d,activeId:L,setActiveId:P,activeType:z,setActiveType:E,dismissIntentId:O,setDismissIntentId:ue,setOverTabId:Hn,setOverTabPosition:$n,containerRef:Q,dragActivationDistance:s,enableDragToDismiss:b,dismissThreshold:g,onRemove:m,onDragStart:Bn,onDragEnd:_n,onDismissIntentChange:Z,removeTab:J,removePane:Y}),gt=ge.useMemo(()=>o,[o.dashboard,o.dashboardDismissActive,o.pane,o.paneLocked,o.dropPreview,o.rootDropPreview,o.dragOverlay,o.paneDragPreview,o.tabDragPreview,o.resizer,o.dismissPreview,o.dashboardLocked,o.lockedPreview,o.tabDropPreview,o.tabSeparator,o.tabsContainer,o.tab,o.paneContainer,o.paneHeader,o.paneControls,o.paneButton,o.tabCloseButton,o.dragHandle]),zt=ge.useCallback((de,Ge)=>{T&&T(de,Ge);},[T]),Vn=ge.useMemo(()=>({layout:a,renderingLayout:R,setLayout:d,activeId:L,activeType:z,dismissIntentId:O,setContainerRef:K,fullscreenPaneId:I,classNames:gt,onRemove:m,onFullscreenChange:q,snapThreshold:u,onResizeStart:D,onResize:N,onResizeEnd:zt,minSplitPercentage:f,maxSplitPercentage:i,locked:ne,setLocked:G,findPaneById:A,findPaneContainingTab:B,findTabById:j,getTabMetadata:V,getActiveTabMetadata:_,renderPane:c,resizerSize:l,poppedOutTabIds:w,isTabPoppedOut:Mt,renderPopoutWrapper:M}),[a,R,L,z,O,K,I,gt,m,q,u,D,N,f,i,d,zt,ne,G,A,B,j,V,_,c,l,w,Mt,M]),Wn=ge.useMemo(()=>({overTabId:Ot,overTabPosition:At}),[Ot,At]),jn=ge.useMemo(()=>({removePane:Y,addTab:ee,updateMetadata:S,updatePaneLock:k,selectTab:ie,mergeTab:le,removeTab:J,setFullscreenPaneId:q,setLocked:G,splitPane:oe,updateSplitPercentage:Ze,moveTab:p,popoutTab:x,dockTab:$}),[Y,ee,S,k,ie,le,J,q,G,oe,Ze,p,x,$]),qn=Vt(a),Un=ge.useMemo(()=>({registerPortalTarget:se,registerRenderCallback:ye,renderCallbacksRef:Xe,registerRenderPane:Lt,renderPaneRef:ft,registerTabHeader:kt,tabHeadersRef:mt,activeIdRef:Ye,registerPopoutTarget:W}),[se,ye,Xe,Lt,ft,kt,mt,Ye,W]);return Ye&&(Ye.current=L),jsxRuntime.jsx(Re.Provider,{value:jn,children:jsxRuntime.jsx(vt.Provider,{value:Vn,children:jsxRuntime.jsx(ht.Provider,{value:Wn,children:jsxRuntime.jsxs(Te.Provider,{value:Un,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",...Fn,children:n}),L&&z&&jsxRuntime.jsx(fn,{activeId:L,render:de=>jsxRuntime.jsx("div",{style:{transition:"transform 150ms cubic-bezier(0.2, 0, 0, 1)",transform:de===O?"scale(0.8)":"scale(1)",transformOrigin:"top left"},children:jsxRuntime.jsx(bn,{activeId:de,activeType:z,dismissIntentId:O,renderDragOverlay:r,renderPaneRef:ft,renderPane:c,tabHeadersRef:mt,classNames:gt})}),className:`${o.dragOverlay||""} ${L===O&&o.dismissPreview||""}`.trim()}),jsxRuntime.jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:qn.map(de=>{let Ge=F[de],Zt=j(de);return Zt?jsxRuntime.jsx(gn,{tabDetails:Zt,target:Ge||null,renderWidget:Xe.current[de]},de):null})})]})})})})},No=({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(wt,{renderPane:e,resizerSize:t,snapThreshold:n})},Io=e=>{let{children:t,...n}=e,{controller:r}=e;if(!r)throw new Error("Zeugma component requires a controller.");return jsxRuntime.jsx(So,{...e,children:t!==void 0?t:jsxRuntime.jsx(No,{...n})})};var Mo={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"}}},Oo={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"}}},Ao=({id:e,fraction:t,edge:n,activeClassName:r})=>{let{setNodeRef:o,isOver:c}=core.useDroppable({id:e}),l={position:"absolute",pointerEvents:"none",zIndex:101,boxSizing:"border-box",...Oo[n][t]};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:o,style:Mo[n][t]}),c&&jsxRuntime.jsx("div",{className:r,style:l})]})},Pn=({activeClassName:e})=>jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:99,pointerEvents:"none"},children:[{id:"drop-root-1/4-top",fraction:"1/4",edge:"top"},{id:"drop-root-1/3-top",fraction:"1/3",edge:"top"},{id:"drop-root-1/4-bottom",fraction:"1/4",edge:"bottom"},{id:"drop-root-1/3-bottom",fraction:"1/3",edge:"bottom"},{id:"drop-root-1/4-left",fraction:"1/4",edge:"left"},{id:"drop-root-1/3-left",fraction:"1/3",edge:"left"},{id:"drop-root-1/4-right",fraction:"1/4",edge:"right"},{id:"drop-root-1/3-right",fraction:"1/3",edge:"right"}].map(n=>jsxRuntime.jsx(Ao,{id:n.id,fraction:n.fraction,edge:n.edge,activeClassName:e},n.id))});var lt=ge.createContext(null);var Bo={top:{position:"absolute",top:0,left:0,width:"100%",height:"25%",zIndex:20,pointerEvents:"auto"},bottom:{position:"absolute",bottom:0,left:0,width:"100%",height:"25%",zIndex:20,pointerEvents:"auto"},left:{position:"absolute",top:"25%",left:0,width:"50%",height:"50%",zIndex:20,pointerEvents:"auto"},right:{position:"absolute",top:"25%",right:0,width:"50%",height:"50%",zIndex:20,pointerEvents:"auto"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:20,pointerEvents:"auto",cursor:"not-allowed"},center:{position:"absolute",top:"25%",left:"25%",width:"50%",height:"50%",zIndex:22,pointerEvents:"auto"}},_o={top:{position:"absolute",top:0,left:0,right:0,height:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},bottom:{position:"absolute",bottom:0,left:0,right:0,height:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},left:{position:"absolute",top:0,bottom:0,left:0,width:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},right:{position:"absolute",top:0,bottom:0,right:0,width:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:21,pointerEvents:"none",boxSizing:"border-box"},center:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:21,pointerEvents:"none",boxSizing:"border-box"}},ct=({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:Bo[t]}),o&&jsxRuntime.jsx("div",{className:n,style:_o[t]})]})};var xn=({children:e,className:t,style:n})=>{let r=ge.useContext(lt);if(!r)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:o,...c}=r;return jsxRuntime.jsx("div",{className:t,style:{cursor:o?"default":"grab",userSelect:o?"auto":"none",touchAction:o?"auto":"none",...n},...o?{}:c,children:e})};var Jo=ge.createContext(void 0);var je=({id:e,locked:t=false,children:n,className:r,style:o})=>{let{locked:c,classNames:l={},fullscreenPaneId:s,poppedOutTabIds:u=[]}=re(),f=ge.useContext(Re),{overTabId:i}=Qe(),b=ge.useContext(Te);ge.useEffect(()=>(b?.registerTabHeader&&b.registerTabHeader(e,n),()=>{b?.registerTabHeader&&b.activeIdRef?.current!==e&&b.registerTabHeader(e,()=>null);}),[e,n,b]);let g=u.includes(e),m=ge.useContext(Dt),h=t||c||(m?.locked??false)||s!==null,{attributes:y,listeners:D,setNodeRef:N,isDragging:T}=core.useDraggable({id:`tab-header-${e}`,disabled:h}),{setNodeRef:Z,isOver:C}=core.useDroppable({id:`tab-drop-${e}`,disabled:h}),M=j=>{N(j),Z(j);},H=C&&i===e,a=m?.tabIds||[],d=a.indexOf(e),v=m?.activeTabId,I=d>0&&e!==v&&a[d-1]!==v?jsxRuntime.jsx("div",{className:l.tabSeparator}):null,q=m?m.activeTabId===e:false,ne=m?.tabsMetadata?.[e],G=ge.useCallback(()=>{m?.selectTab(e);},[m,e]),A=ge.useCallback(()=>{m?.removeTab(e);},[m,e]),B=ge.useMemo(()=>({tabId:e,isActive:q,isDragging:T,isOver:H,metadata:ne,locked:h,selectTab:G,removeTab:A,isPoppedOut:g,popoutTab:()=>f?.popoutTab(e),dockTab:()=>f?.dockTab(e)}),[e,q,T,H,ne,h,G,A,g,f]);return jsxRuntime.jsx(Jo.Provider,{value:B,children:jsxRuntime.jsxs("div",{ref:M,id:`tab-header-${e}`,className:r,style:{display:"inline-flex",position:"relative",cursor:h?"default":"grab",...o},...h?{}:D,...h?{}:y,children:[I,n({isDragging:T,isOver:H})]})})};var Dt=ge.createContext(void 0);var Sn=(e,t)=>typeof e=="function"?e(t):e,Ct=({tabIds:e,activeTabId:t,locked:n,tabsMetadata:r,selectTab:o,removeTab:c,renderTab:l,classNames:s,styles:u})=>{let f=ge.useContext(ut),i=e??f?.tabIds??[],b=t??f?.activeTabId??"",g=n??f?.locked??false,m=r??f?.tabsMetadata,h=o??f?.selectTab??(()=>{}),y=c??f?.removeTab??(()=>{}),{classNames:D={},activeType:N,poppedOutTabIds:T=[]}=re(),Z=ge.useContext(Re),{overTabId:C,overTabPosition:M}=Qe(),H=ge.useMemo(()=>({tabIds:i,activeTabId:b,locked:g,tabsMetadata:m,selectTab:h,removeTab:y}),[i,b,g,m,h,y]),a=Qt(i,N,C,M);return jsxRuntime.jsx(Dt.Provider,{value:H,children:jsxRuntime.jsxs("div",{className:s?.container,style:{display:"flex",alignItems:"center",height:"100%",...u?.container},children:[i.map((d,v)=>{let R=m?.[d],I=Sn(s?.tab,d),q=Sn(u?.tab,d),ne=v===a;return jsxRuntime.jsxs(ge__default.default.Fragment,{children:[ne&&D.tabDropPreview&&jsxRuntime.jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsxRuntime.jsx("div",{className:D.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:v===0?"none":"translateX(-50%)"}})}),jsxRuntime.jsx(je,{id:d,locked:g,className:I,style:q,children:({isDragging:G,isOver:A})=>l({id:d,paneId:f?.id??"",isActive:d===b,index:v,isDragging:G,isOver:A,metadata:R,onSelect:()=>h(d),onRemove:()=>y(d),isPoppedOut:T.includes(d),popout:()=>Z?.popoutTab(d),dock:()=>Z?.dockTab(d)})})]},d)}),a===i.length&&D.tabDropPreview&&jsxRuntime.jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsxRuntime.jsx("div",{className:D.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:"translateX(-100%)"}})})]})})};Ct.Tab=je;var In=({className:e,style:t,children:n})=>jsxRuntime.jsx("div",{className:e,style:t,children:n});var ut=ge.createContext(void 0),kn=()=>{let e=ge.useContext(ut);if(!e)throw new Error("usePaneContext must be used within a Pane component");return e},ir=({children:e,className:t,style:n})=>{let{activeTabId:r}=kn(),{classNames:o,isTabPoppedOut:c}=re(),{dockTab:l}=He(),s=ge.useRef(null),u=ge.useContext(Te);if(!u)throw new Error("PaneContent must be used within a Zeugma provider");let{registerPortalTarget:f,registerRenderCallback:i}=u,b=ge.useMemo(()=>typeof e=="function"?e:()=>e,[e]);i(r,b),ge.useEffect(()=>{let m=s.current;return f(r,m),()=>{f(r,null,m);}},[r,f]);let g=c(r);return jsxRuntime.jsx("div",{ref:s,id:`zeugma-tab-target-${r}`,className:`${o.tabContentWrapper||""} ${t||""}`.trim(),style:{height:"100%",width:"100%",position:"relative",...n},children:g&&jsxRuntime.jsxs("div",{className:"zeugma-popout-placeholder",style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"12px",padding:"24px",textAlign:"center",backgroundColor:"#161719",color:"#94a3b8",fontSize:"13px",fontWeight:500},children:[jsxRuntime.jsx("div",{children:"This panel is open in a new window"}),jsxRuntime.jsx("button",{onClick:()=>l(r),style:{padding:"6px 12px",fontSize:"11px",fontWeight:600,borderRadius:"4px",backgroundColor:"#2563eb",color:"#ffffff",border:"none",cursor:"pointer",boxShadow:"0 1px 3px rgba(0,0,0,0.1)"},onMouseOver:m=>{m.currentTarget.style.backgroundColor="#1d4ed8";},onMouseOut:m=>{m.currentTarget.style.backgroundColor="#2563eb";},children:"Dock Back"})]})})},Oe=({id:e,children:t,style:n,locked:r=false})=>{let{layout:o,renderingLayout:c,activeId:l,activeType:s,classNames:u,fullscreenPaneId:f,onFullscreenChange:i,locked:b,poppedOutTabIds:g=[]}=re(),{removePane:m,updateMetadata:h,selectTab:y,removeTab:D,popoutTab:N,dockTab:T}=He(),Z=ge.useMemo(()=>{if(s==="tab"&&e===l){let O=U(o,e)?.tabsMetadata?.[e];return {type:"pane",id:e,tabIds:[e],activeTabId:e,tabsMetadata:O?{[e]:O}:void 0}}return Ut(e===l?o:c,e)},[o,c,e,l,s]),C=Z?.id??e,M=Z?.tabIds??[e],H=Z?.activeTabId??e,a=Z?.tabsMetadata,d=a?.[e],v=Z?.locked??false,R=r||v,I=b||R||f!==null,q=b||R||f!==null,ne=l!==null&&l!==e&&(!M.includes(l)||M.length>1)&&!q,{attributes:G,listeners:A,setNodeRef:B}=core.useDraggable({id:e,disabled:I}),j=l!==null&&M.includes(l),V=f===e,_=ge.useMemo(()=>({isDragging:j,isFullscreen:V,toggleFullscreen:()=>i?.(V?null:e),remove:()=>{V&&i?.(null),m(C);},metadata:d,updateMetadata:z=>{h(e,z);},locked:I,tabIds:M,activeTabId:H,selectTab:z=>y(C,z),removeTab:z=>{V&&z===H&&i?.(null),D(z);},tabsMetadata:a,updateTabMetadata:(z,E)=>{h(z,E);},isActiveTabPoppedOut:g.includes(H),popoutTab:z=>N(z||H),dockTab:z=>T(z||H)}),[j,V,i,e,D,d,h,I,M,H,y,C,a,g,N,T]),L=ge.useMemo(()=>I?{disabled:true}:{...A,...G},[A,G,I]),P=`${u.pane||""} ${R&&u.paneLocked||""}`.trim();return jsxRuntime.jsx(ut.Provider,{value:{id:e,..._},children:jsxRuntime.jsx(lt.Provider,{value:L,children:jsxRuntime.jsxs("div",{ref:B,id:e,className:P,style:{position:"relative",width:"100%",height:"100%",...n},children:[t,ne&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:[["top","bottom","left","right"].map(z=>jsxRuntime.jsx(ct,{id:`drop-${z}-${e}`,position:z,activeClassName:u.dropPreview},z)),s==="tab"&&jsxRuntime.jsx(ct,{id:`drop-center-${e}`,position:"center",activeClassName:u.swapPreview??u.dropPreview})]}),l!==null&&l!==e&&q&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsxRuntime.jsx(ct,{id:`drop-locked-${e}`,position:"full",activeClassName:u.lockedPreview||""})})]})})})};Oe.Content=ir;Oe.DragHandle=xn;Oe.Tabs=Ct;Oe.Tab=je;Oe.Controls=In;var pt=new Map;function qe(e){let t=pt.get(e);return t||(t={mounts:0,renders:0,listeners:new Set},pt.set(e,t)),t}function Mn(e,t){let n=qe(e);return n.listeners.add(t),()=>{n.listeners.delete(t);}}function St(e){let t=pt.get(e);t&&t.listeners.forEach(n=>n());}function On(e){let t=pt.get(e);t&&(t.mounts=0,t.renders=0,St(e));}function Ae(e,t){let n=ge.useId(),r=typeof e=="string"?{id:e,...t}:e||{},{id:o=n,logToConsole:c=false,disabled:l=false}=r,s=ge.useRef(0),u=ge.useRef(false),[,f]=ge.useState(0);if(l||(s.current+=1),ge.useEffect(()=>{if(l)return;let g=Mn(o,()=>{f(h=>h+1);}),m=qe(o);return m.mounts+=1,u.current=true,c&&console.log(`[DevTools:${o}] Mounted: ${m.mounts} | Rendered: ${s.current}`),St(o),()=>{u.current=false,g();}},[o,l,c]),!l){let g=qe(o);g.renders=Math.max(g.renders,s.current);}let i=ge.useCallback(()=>{s.current=0,On(o);},[o]);return l?{mounts:0,renders:0,reset:i}:{mounts:qe(o).mounts,renders:s.current,reset:i}}function zn({id:e,className:t,style:n,logToConsole:r=false,disabled:o=false}){let{mounts:c,renders:l}=Ae(e,{logToConsole:r,disabled:o});return o?null:jsxRuntime.jsxs("div",{className:t,style:n,children:[jsxRuntime.jsxs("span",{children:["M: ",jsxRuntime.jsx("strong",{children:c})]}),jsxRuntime.jsx("span",{children:"|"}),jsxRuntime.jsxs("span",{children:["R: ",jsxRuntime.jsx("strong",{children:l})]})]})}function Zn({id:e,label:t,children:n,className:r,footerClassName:o,style:c,logToConsole:l=false,disabled:s=false}){let u=t||e||"widget",{mounts:f,renders:i}=Ae(e,{logToConsole:l,disabled:s});return s?jsxRuntime.jsx(jsxRuntime.Fragment,{children:n}):jsxRuntime.jsxs("div",{className:r,style:c,children:[n&&jsxRuntime.jsx("div",{className:"flex-1 overflow-hidden relative min-h-0",children:n}),jsxRuntime.jsxs("div",{className:o,children:[jsxRuntime.jsx("span",{className:"truncate",children:u}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsxs("span",{children:["Mounts: ",jsxRuntime.jsx("strong",{className:"counter-mounts",children:f})]}),jsxRuntime.jsx("span",{children:"|"}),jsxRuntime.jsxs("span",{children:["Renders: ",jsxRuntime.jsx("strong",{className:"counter-renders",children:i})]})]})]})]})}exports.Pane=Oe;exports.PaneTree=wt;exports.RenderCounterBadge=zn;exports.RenderCounterFooter=Zn;exports.Zeugma=Io;exports.usePaneContext=kn;exports.useRenderCounter=Ae;exports.useResizer=Rt;exports.useZeugma=Kn;exports.useZeugmaContext=eo;//# sourceMappingURL=index.cjs.map
9
+ `,document.head.appendChild(o),t.setAttribute("data-resizing","true");let c=s=>{n(s);},l=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let s=document.getElementById("zeugma-global-cursor-style");s&&s.remove(),document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",l),r();};document.addEventListener("pointermove",c),document.addEventListener("pointerup",l);}var vt=ge.createContext(void 0),we=ge.createContext(void 0),Te=ge.createContext(void 0),ht=ge.createContext(void 0),re=()=>{let e=ge.useContext(vt);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},He=()=>{let e=ge.useContext(we);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e},Qe=()=>{let e=ge.useContext(ht);if(!e)throw new Error("useZeugmaDrag must be used within a Zeugma provider");return e};function Bt(e){let t=ge.useRef(null);return ge.useEffect(()=>{if(!e){t.current=null;return}let n=o=>{t.current={x:o.clientX,y:o.clientY};},r=o=>{let c=o.touches[0]||o.changedTouches[0];c&&(t.current={x:c.clientX,y:c.clientY});};return window.addEventListener("pointermove",n,{passive:true}),window.addEventListener("touchmove",r,{passive:true}),()=>{window.removeEventListener("pointermove",n),window.removeEventListener("touchmove",r);}},[e]),t}function _t(e){ge.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]=ge.useState({}),[n,r]=ge.useState({}),o=ge.useRef({}),c=ge.useRef(null),l=ge.useRef({}),s=ge.useRef(null),u=ge.useRef(true);ge.useEffect(()=>(u.current=true,()=>{u.current=false;}),[]);let f=ge.useCallback((y,C,N)=>{u.current&&t(T=>{if(!C){if(N&&T[y]!==N||!T[y])return T;let Z={...T};return delete Z[y],Z}return T[y]===C?T:{...T,[y]:C}});},[]),i=ge.useCallback((y,C)=>{u.current&&r(N=>{if(!C){if(!N[y])return N;let T={...N};return delete T[y],T}return N[y]===C?N:{...N,[y]:C}});},[]),b=ge.useCallback((y,C)=>{o.current[y]=C;},[]),g=ge.useCallback(y=>{c.current=y;},[]),m=ge.useCallback((y,C)=>{l.current[y]=C;},[]);return {portalTargets:ge.useMemo(()=>({...e,...n}),[e,n]),registerPortalTarget:f,registerPopoutTarget:i,registerRenderCallback:b,renderCallbacksRef:o,registerRenderPane:g,renderPaneRef:c,registerTabHeader:m,tabHeadersRef:l,activeIdRef:s}}function Yn(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 Vt(e){return ge.useMemo(()=>Yn(e),[e])}function Wt(e){let{onDragStart:t,onDragEnd:n}=e,[r,o]=ge.useState(null),[c,l]=ge.useState(null),s=ge.useCallback(f=>{t&&t(f);},[t]),u=ge.useCallback((f,i,b)=>{n&&n(f,i,b);},[n]);return {overTabId:r,setOverTabId:o,overTabPosition:c,setOverTabPosition:l,handleDragStartInternal:s,handleDragEndInternal:u}}function jt(e){let n=ge.useContext(Te)?.registerRenderPane;ge.useEffect(()=>{n&&e&&n(e);},[n,e]);}function pe(){return "pane-"+Math.random().toString(36).substring(2,11)}function be(e,t){if(e===null)return null;if(e.type==="pane")return e.id===t?null:e;let n=be(e.first,t),r=be(e.second,t);return n===null?r:r===null?n:{...e,first:n,second:r}}function fe(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 c=e.activeTabId;e.activeTabId===t&&(c=o[0]);let l={...e.tabsMetadata};return delete l[t],{...e,tabIds:o,activeTabId:c,tabsMetadata:Object.keys(l).length>0?l:void 0}}return 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 Se(e,t,n,r,o){if(e===null)return typeof o=="string"?{type:"pane",id:pe(),tabIds:[o],activeTabId:o}:o;if(e.type==="pane"){if(e.id===t){let c=typeof o=="string"?{type:"pane",id:pe(),tabIds:[o],activeTabId:o}:o,l=r==="left"||r==="top";return {type:"split",direction:n,first:l?c:e,second:l?e:c,splitPercentage:50}}return e}return {...e,first:Se(e.first,t,n,r,o)||e.first,second:Se(e.second,t,n,r,o)||e.second}}function Gn(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 qt(e,t,n,r){if(e===null)return {type:"pane",id:pe(),tabIds:[n],activeTabId:n,tabsMetadata:r?{[n]:r}:void 0};let o=t?te(e,t):null;if(o&&o.type==="pane"){let s=function(u){if(u.type==="pane"&&u.id===t){let f=[...u.tabIds];f.includes(n)||f.push(n);let i=u.tabsMetadata;return r&&(i={...u.tabsMetadata,[n]:r}),{...u,tabIds:f,activeTabId:n,tabsMetadata:i}}return u.type==="split"?{...u,first:s(u.first),second:s(u.second)}:u};return s(e)}let c={type:"pane",id:pe(),tabIds:[n],activeTabId:n,tabsMetadata:r?{[n]:r}:void 0};return Gn(e,c)}function xe(e,t,n){return e===null?null:e===t?{...e,splitPercentage:n}:e.type==="split"?{...e,first:xe(e.first,t,n)||e.first,second:xe(e.second,t,n)||e.second}:e}function te(e,t){return e===null?null:e.type==="pane"?e.id===t?e:null:e.type==="split"?te(e.first,t)??te(e.second,t):null}function U(e,t){return e===null?null:e.type==="pane"?e.tabIds.includes(t)?e:null:e.type==="split"?U(e.first,t)??U(e.second,t):null}function Ut(e,t){return te(e,t)??U(e,t)}function ot(e,t){let n=U(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],remountOnPopout:n.tabsMetadata?.[t]?.remountOnPopout}}function Xt(e,t){return U(e,t)?.tabsMetadata?.[t]}function Yt(e,t){let n=te(e,t);return n?.tabsMetadata?.[n.activeTabId]}function tt(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.tabIds.includes(t)){let r=e.tabsMetadata||{},o=r[t],c=n(o),l={...r};return c===void 0?delete l[t]:l[t]=c,{...e,tabsMetadata:Object.keys(l).length>0?l:void 0}}return e}return e.type==="split"?{...e,first:tt(e.first,t,n)??e.first,second:tt(e.second,t,n)??e.second}:e}function nt(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:nt(e.first,t,n)??e.first,second:nt(e.second,t,n)??e.second}:e}function Ne(e,t,n){return e===null?null:e.type==="pane"?e.id===t?e.activeTabId===n?e:{...e,activeTabId:n}:e:e.type==="split"?{...e,first:Ne(e.first,t,n)??e.first,second:Ne(e.second,t,n)??e.second}:e}function Gt(e,t,n){if(e===null)return null;let o=U(e,t)?.tabsMetadata?.[t],c=fe(e,t);if(c===null)return {type:"pane",id:pe(),tabIds:[t],activeTabId:t,tabsMetadata:o?{[t]:o}:void 0};function l(s){if(s.type==="pane"){if(s.id===n){let u=[...s.tabIds];u.includes(t)||u.push(t);let f={...s.tabsMetadata};return o&&(f[t]=o),{...s,tabIds:u,activeTabId:t,tabsMetadata:Object.keys(f).length>0?f:void 0}}return s}return s.type==="split"?{...s,first:l(s.first),second:l(s.second)}:s}return l(c)}function Jn(e,t,n){if(e===null)return null;if(t===n)return e;let r=U(e,t),o=U(e,n);if(!r||!o)return e;let c=r.id,l=o.id,s=r.tabsMetadata?.[t],u=o.tabsMetadata?.[n];function f(i){if(i.type==="pane"){let b=false,g=[...i.tabIds],m=i.activeTabId,h=i.tabsMetadata?{...i.tabsMetadata}:{};if(c===l){if(i.id===c){let y=g.indexOf(t),C=g.indexOf(n);y!==-1&&C!==-1&&(g[y]=n,g[C]=t),m=t,b=true;}}else i.id===c&&(g=g.map(y=>y===t?n:y),m===t&&(m=n),delete h[t],u&&(h[n]=u),b=true),i.id===l&&(g=g.map(y=>y===n?t:y),m===n&&(m=t),delete h[n],s&&(h[t]=s),b=true);return b?{...i,tabIds:g,activeTabId:m,tabsMetadata:Object.keys(h).length>0?h:void 0}:i}return i.type==="split"?{...i,first:f(i.first),second:f(i.second)}:i}return f(e)}function $e(e,t,n,r="before"){if(e===null)return null;if(t===n)return e;if(r==="center")return Jn(e,t,n);let c=U(e,t)?.tabsMetadata?.[t],l=fe(e,t);if(l===null)return {type:"pane",id:pe(),tabIds:[t],activeTabId:t,tabsMetadata:c?{[t]:c}:void 0};function s(u){if(u.type==="pane"){if(u.tabIds.includes(n)){let i=[...u.tabIds].filter(m=>m!==t),b=i.indexOf(n);b<0&&(b=0),r==="after"&&(b+=1),i.splice(b,0,t);let g={...u.tabsMetadata};return c&&(g[t]=c),{...u,tabIds:i,activeTabId:t,tabsMetadata:Object.keys(g).length>0?g:void 0}}return u}return u.type==="split"?{...u,first:s(u.first),second:s(u.second)}:u}return s(l)}function ve(e,t=0,n=0,r=100,o=100,c="root"){if(e===null)return {panes:[],splitters:[]};if(e.type==="pane")return {panes:[{paneId:e.id,left:t,top:n,width:r,height:o,node:e}],splitters:[]};let{direction:l,splitPercentage:s,first:u,second:f}=e,b={id:`splitter-${c}-${l}`,currentNode:e,direction:l,left:l==="row"?t+r*(s/100):t,top:l==="column"?n+o*(s/100):n,width:l==="row"?0:r,height:l==="column"?0:o,parentLeft:t,parentTop:n,parentWidth:r,parentHeight:o},g={panes:[],splitters:[]},m={panes:[],splitters:[]};if(l==="row"){let h=r*(s/100);g=ve(u,t,n,h,o,`${c}-L`),m=ve(f,t+h,n,r-h,o,`${c}-R`);}else {let h=o*(s/100);g=ve(u,t,n,r,h,`${c}-T`),m=ve(f,t,n+h,r,o-h,`${c}-B`);}return {panes:[...g.panes,...m.panes],splitters:[b,...g.splitters,...m.splitters]}}function Jt(e,t,n,r="before"){if(e===null)return null;let o=te(e,t);if(!o)return e;let c=o.tabIds,l=o.activeTabId,s=o.tabsMetadata||{},u=be(e,t);if(u===null)return o;function f(i){if(i.type==="pane"){if(i.tabIds.includes(n)){let g=[...i.tabIds].filter(y=>!c.includes(y)),m=g.indexOf(n);m<0&&(m=0),r==="after"&&(m+=1),g.splice(m,0,...c);let h={...i.tabsMetadata};for(let y of c)s[y]&&(h[y]=s[y]);return {...i,tabIds:g,activeTabId:l,tabsMetadata:Object.keys(h).length>0?h:void 0}}return i}return i.type==="split"?{...i,first:f(i.first),second:f(i.second)}:i}return f(u)}function Qt(e,t,n,r){if(!((t==="tab"||t==="pane")&&n&&e.includes(n))||!r)return -1;let l=e.indexOf(n);return r==="before"?l:l+1}function Kt(e,t){if(e===t)return true;if(!e||!t)return false;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return false;for(let o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return false;let c=e[o],l=t[o];if(typeof c=="object"&&c!==null&&typeof l=="object"&&l!==null){if(!Kt(c,l))return false}else if(c!==l)return false}return true}function Qn(e,t){if(e===t)return true;if(!e||!t)return false;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return false;for(let o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Kt(e[o],t[o]))return false;return true}function Be(e,t){if(e===t)return true;if(!e||!t||e.type!==t.type)return false;if(e.type==="split"){let n=t;return e.direction===n.direction&&e.splitPercentage===n.splitPercentage&&Be(e.first,n.first)&&Be(e.second,n.second)}else {let n=t;if(e.id!==n.id||e.activeTabId!==n.activeTabId||e.locked!==n.locked||e.tabIds.length!==n.tabIds.length)return false;for(let r=0;r<e.tabIds.length;r++)if(e.tabIds[r]!==n.tabIds[r])return false;return Qn(e.tabsMetadata,n.tabsMetadata)}}function Kn(e){let{initialLayout:t,layout:n,onChange:r,fullscreenPaneId:o,onFullscreenChange:c,locked:l=false}=e,[s,u]=ge.useState(()=>n!==void 0?n:t??null),[f,i]=ge.useState(()=>n!==void 0?n:t??null),b=ge.useRef(n),[g,m]=ge.useState(o||null),[h,y]=ge.useState(l),[C,N]=ge.useState([]),[T,Z]=ge.useState(null),[D,M]=ge.useState(null),[H,a]=ge.useState(null),d=ge.useRef(null),v=ge.useCallback(p=>{d.current=p;},[]),w=ge.useRef(s);w.current=s;let I=ge.useRef(g);I.current=g;let q=ge.useRef(r);q.current=r;let ne=ge.useRef(c);ne.current=c;let G=ge.useCallback(p=>{m(p),ne.current?.(p);},[]);ge.useEffect(()=>{y(l);},[l]),ge.useEffect(()=>{o!==void 0&&m(o);},[o]),n!==void 0&&(Be(n,b.current??null)||(b.current=n,u(n),i(n),N(p=>{if(p.length===0)return p;let R=p.filter(x=>ot(n,x)!==null);return R.length===p.length?p:R})));let A=ge.useCallback(p=>(...R)=>{let x=w.current,$=p(x,...R);Be(x,$)||(w.current=$,u($),i($),N(F=>{if(F.length===0)return F;let se=F.filter(W=>ot($,W)!==null);return se.length===F.length?F:se}),q.current?.($));},[]),B=ge.useCallback(A((p,R)=>typeof R=="function"?R(p):R),[A]),j=ge.useCallback(p=>{I.current===null&&i(R=>typeof p=="function"?p(R):p);},[]),V=ge.useCallback(p=>{m(null),ne.current?.(null),Z(null),M(null),a(null),B(p),i(()=>typeof p=="function"?p(w.current):p);},[B]),_=ge.useCallback(A((p,R)=>I.current!==null?p:be(p,R)),[A]),L=ge.useCallback(A((p,R,x,$)=>{if(I.current!==null)return p;let F=fe(p,R)??p;return qt(F,x,R,$)}),[A]),P=ge.useCallback(A((p,R,x,$,F)=>{if(I.current!==null)return p;let se=te(p,R)??U(p,R);if(!se)return p;let W=te(p,F)??U(p,F)??{type:"pane",id:F,tabIds:[F],activeTabId:F},ye=be(p,W.id);return Se(ye,se.id,x,$,W)}),[A]),z=ge.useCallback(A((p,R,x)=>I.current!==null?p:xe(p,R,x)),[A]),E=ge.useCallback(A((p,R,x)=>tt(p,R,x)),[A]),O=ge.useCallback(A((p,R,x)=>{let $=te(p,R)??U(p,R);return $?nt(p,$.id,x):p}),[A]),ue=ge.useCallback(A((p,R,x)=>{let $=te(p,R)??U(p,R);return $?Ne(p,$.id,x):p}),[A]),Q=ge.useCallback(A((p,R,x)=>{if(I.current!==null)return p;let $=te(p,x)??U(p,x);return $?Gt(p,R,$.id):p}),[A]),K=ge.useCallback(A((p,R,x,$)=>I.current!==null?p:$e(p,R,x,$)),[A]),Y=ge.useCallback(A((p,R)=>I.current!==null?p:fe(p,R)),[A]),ee=ge.useCallback(p=>te(w.current,p),[]),S=ge.useCallback(p=>U(w.current,p),[]),k=ge.useCallback(p=>ot(w.current,p),[]),ie=ge.useCallback(p=>Xt(w.current,p),[]),le=ge.useCallback(p=>Yt(w.current,p),[]),J=ge.useCallback(p=>{I.current===null&&N(R=>R.includes(p)?R:[...R,p]);},[]),oe=ge.useCallback(p=>{I.current===null&&N(R=>R.includes(p)?R.filter(x=>x!==p):R);},[]);return {layout:s,setLayout:V,_internalSetLayout:j,renderingLayout:f,fullscreenPaneId:g,setFullscreenPaneId:G,locked:h,setLocked:y,poppedOutTabIds:C,activeId:T,setActiveId:Z,activeType:D,setActiveType:M,dismissIntentId:H,setDismissIntentId:a,containerRef:d,setContainerRef:v,removePane:_,addTab:L,updateMetadata:E,updatePaneLock:O,selectTab:ue,mergeTab:Q,moveTab:K,removeTab:Y,splitPane:P,updateSplitPercentage:z,popoutTab:J,dockTab:oe,findPaneById:ee,findPaneContainingTab:S,findTabById:k,getTabMetadata:ie,getActiveTabMetadata:le}}var eo=()=>{let e=re(),t=He();return {layout:e.layout,setLayout:e.setLayout,fullscreenPaneId:e.fullscreenPaneId,setFullscreenPaneId:t.setFullscreenPaneId,locked:e.locked,setLocked:t.setLocked,removePane:t.removePane,addTab:t.addTab,updateMetadata:t.updateMetadata,updatePaneLock:t.updatePaneLock,selectTab:t.selectTab,mergeTab:t.mergeTab,removeTab:t.removeTab,splitPane:t.splitPane,updateSplitPercentage:t.updateSplitPercentage,moveTab:t.moveTab,findPaneById:e.findPaneById,findPaneContainingTab:e.findPaneContainingTab,findTabById:e.findTabById,getTabMetadata:e.getTabMetadata,getActiveTabMetadata:e.getActiveTabMetadata,poppedOutTabIds:e.poppedOutTabIds,popoutTab:t.popoutTab,dockTab:t.dockTab}};var rt=class extends core.PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},at=class extends core.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};var tn=e=>{let n=e.active.id.toString().startsWith("tab-header-"),o=core.pointerWithin(e);if(o.length>0)return [...o].sort((l,s)=>{let u=l.id.toString(),f=s.id.toString(),i=u.startsWith("tab-drop-"),b=f.startsWith("tab-drop-");if(i&&!b)return -1;if(!i&&b)return 1;let g=u.startsWith("drop-root-"),m=f.startsWith("drop-root-");return g&&!m?-1:!g&&m?1:0});if(n){let c=e.droppableContainers.filter(l=>l.id.toString().startsWith("tab-drop-"));return core.closestCenter({...e,droppableContainers:c})}return []};function _e(e){if(e instanceof MouseEvent||e instanceof PointerEvent)return {x:e.clientX,y:e.clientY};if(typeof TouchEvent<"u"&&e instanceof TouchEvent){let t=e.touches[0]||e.changedTouches[0];if(t)return {x:t.clientX,y:t.clientY}}return null}function rn(e){let{layout:t,_internalSetLayout:n,setLayout:r,activeId:o,setActiveId:c,activeType:l,setActiveType:s,dismissIntentId:u,setDismissIntentId:f,setOverTabId:i,setOverTabPosition:b,containerRef:g,dragActivationDistance:m,enableDragToDismiss:h,dismissThreshold:y,onRemove:C,onDragStart:N,onDragEnd:T,onDismissIntentChange:Z,removeTab:D,removePane:M}=e,H=ge.useRef(null),a=Bt(o),d=ge.useRef(null),[v,w]=ge.useState(false);return _t(v),{sensors:core.useSensors(core.useSensor(rt,{activationConstraint:{distance:m}}),core.useSensor(at,{activationConstraint:{delay:250,tolerance:5}})),collisionDetection:tn,onDragStart:B=>{let j=B.active.id.toString(),V=j.startsWith("tab-header-"),_=V?j.substring(11):j;c(_),s(V?"tab":"pane"),i(null),b(null);let L=B.activatorEvent;a.current=_e(L),h&&g.current?H.current=g.current.getBoundingClientRect():H.current=null;let P=t;if(V){let E=U(t,_);E&&(P=Ne(t,E.id,_)||t);}d.current=P;let z=V?fe(P,_):be(P,_);n(z),N&&N(_);},onDragMove:B=>{let{over:j}=B,V=j?.id.toString()||"",_=V.startsWith("drop-locked-");w(S=>S===_?S:_);let L=B.active.id.toString(),P=L.startsWith("tab-header-"),z=P?L.substring(11):L,E=V.match(/^tab-drop-(.+)$/);if(E&&j&&(P||l==="pane")){let[,S]=E;if(z!==S){let k="before",ie=j.rect,le=B.activatorEvent,J=null;if(a.current)J=a.current.x;else {let oe=_e(le);oe&&(J=oe.x+B.delta.x);}if(J!==null){let oe=ie.left+ie.width/2;J>oe&&(k="after");}i(oe=>oe===S?oe:S),b(oe=>oe===k?oe:k);}else i(k=>k===null?k:null),b(k=>k===null?k:null);}else i(S=>S===null?S:null),b(S=>S===null?S:null);if(!h)return;let O=H.current;if(!O){u!==null&&(f(null),Z?.(null));return}let ue=B.activatorEvent,Q=null,K=null;if(a.current)Q=a.current.x,K=a.current.y;else {let S=_e(ue);S&&(Q=S.x+B.delta.x,K=S.y+B.delta.y);}let Y=0;if(Q!==null&&K!==null){let S=0,k=0;Q<O.left?S=O.left-Q:Q>O.right&&(S=Q-O.right),K<O.top?k=O.top-K:K>O.bottom&&(k=K-O.bottom),Y=Math.sqrt(S*S+k*k);}else {let S=B.active.rect.current.translated;if(S){let k=S.left+S.width/2,ie=S.top+S.height/2,le=0,J=0;k<O.left?le=O.left-k:k>O.right&&(le=k-O.right),ie<O.top?J=O.top-ie:ie>O.bottom&&(J=ie-O.bottom),Y=Math.sqrt(le*le+J*J);}}Y>y?u!==z&&(f(z),Z?.(z)):u!==null&&(f(null),Z?.(null));},onDragEnd:B=>{c(null),s(null),w(false),i(null),b(null);let{active:j,over:V}=B,_=j.id.toString(),L=_.startsWith("tab-header-"),P=L?_.substring(11):_,z=h&&u===P;f(null),Z?.(null),H.current=null;let E=d.current||t;if(d.current=null,z){C?C(P):L?D(P):M(P),T&&T(P,null,null);return}if(!V){n(E),T&&T(P,null,null);return}let O=V.id.toString();if(O.startsWith("drop-locked-")){n(E),T&&T(P,null,null);return}let ue=O.match(/^tab-drop-(.+)$/);if(ue){let[,p]=ue;if(L)if(P!==p){let R="before",x=V.rect,$=B.activatorEvent,F=null;if(a.current)F=a.current.x;else {let W=_e($);W&&(F=W.x+B.delta.x);}if(F!==null){let W=x.left+x.width/2;F>W&&(R="after");}let se=$e(E,P,p,R);r(se),T&&T(P,p,{type:"move",position:"center"});}else n(E),T&&T(P,null,null);else {let R="before",x=V.rect,$=B.activatorEvent,F=null;if(a.current)F=a.current.x;else {let W=_e($);W&&(F=W.x+B.delta.x);}if(F!==null){let W=x.left+x.width/2;F>W&&(R="after");}let se=Jt(E,P,p,R);r(se),T&&T(P,p,{type:"move",position:"center"});}return}let Q=O.match(/^drop-root-(1\/4|1\/3)-(top|bottom|left|right|start|end)$/);if(Q){let[,p,R]=Q,x=R;x==="start"&&(x="left"),x==="end"&&(x="right");let $=L?fe(E,P):be(E,P),F;if(L){let W=U(E,P)?.tabsMetadata?.[P];F={type:"pane",id:pe(),tabIds:[P],activeTabId:P,tabsMetadata:W?{[P]:W}:void 0};}else F=te(E,P)??{type:"pane",id:pe(),tabIds:[P],activeTabId:P};if($===null)r(F);else {let se=x==="left"||x==="right",W=x==="left"||x==="top",ye=50;p==="1/4"?ye=W?25:75:p==="1/3"&&(ye=W?100/3:200/3),r({type:"split",direction:se?"row":"column",first:W?F:$,second:W?$:F,splitPercentage:ye});}T&&T(P,"root",{type:"split",direction:x==="left"||x==="right"?"row":"column",position:x});return}let K=O.match(/^drop-(left|right|top|bottom|center)-(.+)$/);if(!K){n(E),T&&T(P,null,null);return}let[,Y,ee]=K;if(Y==="center"){if(L){let p=te(E,ee);if(p&&p.activeTabId){let R=p.activeTabId,x=$e(E,P,R,"center");r(x),T&&T(P,ee,{type:"move",position:"center"});}else n(E),T&&T(P,null,null);}else n(E),T&&T(P,null,null);return}let S=L?U(E,P):te(E,P),k=S&&S.id===ee,ie=S&&S.tabIds.length===1;if(P===ee||k&&ie){n(E),T&&T(P,null,null);return}let le=Y==="left"||Y==="right"?"row":"column",J;if(L){let R=U(E,P)?.tabsMetadata?.[P];J={type:"pane",id:pe(),tabIds:[P],activeTabId:P,tabsMetadata:R?{[P]:R}:void 0};}else J=te(E,P)??{type:"pane",id:pe(),tabIds:[P],activeTabId:P};let oe=L?fe(E,P):be(E,P),Ze=Se(oe,ee,le,Y,J);r(Ze),T&&T(P,ee,{type:"split",direction:le,position:Y});},onDragCancel:()=>{c(null),s(null),w(false),i(null),b(null),f(null),Z?.(null),H.current=null;let B=d.current||t;d.current=null,n(B),B!==t&&r(B);}}}function sn({persist:e,layout:t,setLayout:n}){let r=typeof e=="object"?e.enabled!==false:!!e,o=typeof e=="object"&&e.key||"zeugma-layout",[c,l]=ge.useState(false);ge.useEffect(()=>{if(r){let s=localStorage.getItem(o);if(s)try{let u=JSON.parse(s);u&&n(u);}catch(u){console.error("Failed to parse persisted zeugma layout",u);}}l(true);},[r,o,n]),ge.useEffect(()=>{r&&c&&(t?localStorage.setItem(o,JSON.stringify(t)):localStorage.removeItem(o));},[r,o,t,c]);}var Ce=null,cn=false,ae=new Set,De=new Set,Le=null;function co(){typeof window>"u"||Le||(Le=new MutationObserver(e=>{e.forEach(t=>{t.addedNodes.forEach(n=>{n instanceof HTMLElement&&(n.tagName.toLowerCase()==="style"||n.tagName.toLowerCase()==="link")&&ae.forEach(r=>{try{let o=n.cloneNode(!0);if(o.tagName.toLowerCase()==="link"){let c=n.href;c&&o.setAttribute("href",c);}r.head.appendChild(o);}catch(o){console.warn("Failed to mirror style node to popout:",o);}});});});}),Le.observe(document.head,{childList:true}));}function yt(){Le&&(Le.disconnect(),Le=null);}var ke=null;function uo(){typeof window>"u"||ke||(ke=new MutationObserver(e=>{e.forEach(t=>{if(t.type==="attributes"&&t.attributeName){let n=document.documentElement.getAttribute(t.attributeName);ae.forEach(r=>{try{r&&r.documentElement&&(n!==null?r.documentElement.setAttribute(t.attributeName,n):r.documentElement.removeAttribute(t.attributeName));}catch(o){console.warn("Failed to sync documentElement attribute:",o);}});}});}),ke.observe(document.documentElement,{attributes:true}));}function Tt(){ke&&(ke.disconnect(),ke=null);}var un=e=>{typeof requestAnimationFrame<"u"?requestAnimationFrame(e):setTimeout(e,0);};function me(){if(typeof window>"u")return document;if(Ce&&Ce.target){let t=Ce.target.ownerDocument;if(t&&t!==document)return t}let e=window.event;if(e&&e.target){let n=e.target.ownerDocument;if(n&&n!==document)return n}return window.__zeugmaActivePopoutDocument?window.__zeugmaActivePopoutDocument:document}function dn(){if(typeof window>"u"||cn)return;cn=true;let e=(a,d)=>{if(!a||!d)return false;try{let v=Object.getPrototypeOf(a);for(;v;){if(v===d)return !0;v=Object.getPrototypeOf(v);}}catch{}return false},t=(a,d)=>{try{Object.defineProperty(a,Symbol.hasInstance,{value:function(v){return v?e(v,a.prototype)?!0:d(v):!1},configurable:!0,writable:!0});}catch(v){console.warn("Failed to patch Symbol.hasInstance on",a,v);}};typeof Node<"u"&&t(Node,a=>typeof a.nodeType=="number"&&typeof a.nodeName=="string"),typeof Element<"u"&&t(Element,a=>a.nodeType===1),typeof HTMLElement<"u"&&t(HTMLElement,a=>a.nodeType===1&&typeof a.style=="object"),typeof HTMLBodyElement<"u"&&t(HTMLBodyElement,a=>a.nodeType===1&&a.tagName==="BODY"),typeof HTMLHtmlElement<"u"&&t(HTMLHtmlElement,a=>a.nodeType===1&&a.tagName==="HTML"),typeof HTMLInputElement<"u"&&t(HTMLInputElement,a=>a.nodeType===1&&a.tagName==="INPUT"),typeof HTMLTextAreaElement<"u"&&t(HTMLTextAreaElement,a=>a.nodeType===1&&a.tagName==="TEXTAREA"),typeof ShadowRoot<"u"&&t(ShadowRoot,a=>a.nodeType===11&&a.host!==void 0),typeof SVGElement<"u"&&t(SVGElement,a=>a.nodeType===1&&typeof a.getBBox=="function"),typeof Document<"u"&&t(Document,a=>a.nodeType===9),typeof Window<"u"&&t(Window,a=>a&&typeof a.document=="object"&&typeof a.location=="object");let n=Document.prototype,r=Object.getOwnPropertyDescriptor(n,"body"),o=Object.getOwnPropertyDescriptor(n,"documentElement"),c=Object.getOwnPropertyDescriptor(n,"head"),l=Object.getOwnPropertyDescriptor(n,"activeElement"),s=Object.getOwnPropertyDescriptor(n,"defaultView"),u=Object.getOwnPropertyDescriptor(n,"scrollingElement");Object.defineProperties(document,{body:{get(){let a=me();return a&&a!==document?a.body:r?.get?.call(document)||document.body},configurable:true},documentElement:{get(){let a=me();return a&&a!==document?a.documentElement:o?.get?.call(document)||document.documentElement},configurable:true},head:{get(){let a=me();return a&&a!==document?a.head:c?.get?.call(document)||document.head},configurable:true},activeElement:{get(){let a=me();return a&&a!==document?a.activeElement:l?.get?.call(document)||document.activeElement},configurable:true},defaultView:{get(){let a=me();return a&&a!==document?a.defaultView:s?.get?.call(document)||document.defaultView},configurable:true},scrollingElement:{get(){let a=me();return a&&a!==document?a.scrollingElement:u?.get?.call(document)||document.scrollingElement},configurable:true}});let f=Window.prototype,i=["innerWidth","innerHeight","pageXOffset","pageYOffset","scrollX","scrollY","screenX","screenY","outerWidth","outerHeight","devicePixelRatio"],b={};i.forEach(a=>{let d=Object.getOwnPropertyDescriptor(f,a)||Object.getOwnPropertyDescriptor(window,a);d&&d.get&&(b[a]=d.get);}),i.forEach(a=>{Object.defineProperty(window,a,{get(){let d=me();if(d&&d!==document&&d.defaultView)try{return d.defaultView[a]}catch{}let v=b[a];return v?v.call(window):window[a]},configurable:true});});let g=Node.prototype.contains;Node.prototype.contains=function(a){if(!a)return false;if(g.call(this,a))return true;if(this===document||this===document.body||this===document.documentElement)for(let d of ae)try{if(d.contains(a))return !0}catch{}return false};let m=()=>{Ce=null,globalThis.__zeugmaActivePopoutDocument=null;};["pointerdown","mousedown","click","keydown","focus","touchstart"].forEach(a=>{window.addEventListener(a,m,true);});let y=document.createElement;document.createElement=function(a,d){let v=me();return v&&v!==document?v.createElement(a,d):y.call(document,a,d)};let C=document.addEventListener;document.addEventListener=function(a,d,v){De.add({target:"document",type:a,listener:d,options:v}),C.call(document,a,d,v),ae.forEach(w=>{try{w.addEventListener(a,d,v);}catch{}});};let N=document.removeEventListener;document.removeEventListener=function(a,d,v){for(let w of De)if(w.target==="document"&&w.type===a&&w.listener===d){De.delete(w);break}N.call(document,a,d,v),ae.forEach(w=>{try{w.removeEventListener(a,d,v);}catch{}});};let T=window.addEventListener;window.addEventListener=function(a,d,v){De.add({target:"window",type:a,listener:d,options:v}),T.call(window,a,d,v),ae.forEach(w=>{try{w.defaultView&&w.defaultView.addEventListener(a,d,v);}catch{}});};let Z=window.removeEventListener;window.removeEventListener=function(a,d,v){for(let w of De)if(w.target==="window"&&w.type===a&&w.listener===d){De.delete(w);break}Z.call(window,a,d,v),ae.forEach(w=>{try{w.defaultView&&w.defaultView.removeEventListener(a,d,v);}catch{}});};let D=document.getElementById;document.getElementById=function(a){let d=me();if(d&&d!==document)return d.getElementById(a);let v=D.call(document,a);if(v)return v;for(let w of ae)try{let I=w.getElementById(a);if(I)return I}catch{}return null};let M=document.querySelector;document.querySelector=function(a){let d=me();if(d&&d!==document)return d.querySelector(a);let v=M.call(document,a);if(v)return v;for(let w of ae)try{let I=w.querySelector(a);if(I)return I}catch{}return null};let H=document.querySelectorAll;document.querySelectorAll=function(a){let d=me();if(d&&d!==document)return d.querySelectorAll(a);let v=H.call(document,a);if(v.length>0)return v;for(let w of ae)try{let I=w.querySelectorAll(a);if(I.length>0)return I}catch{}return v};}function pn(e){let{poppedOutTabIds:t,registerPopoutTarget:n,findTabById:r,dockTab:o}=e,c=ge.useRef({});ge.useEffect(()=>{let l=c.current;t.forEach(s=>{if(l[s]){try{l[s].focus();}catch{}return}dn();let f=r(s)?.metadata?.title||`Tab ${s}`,i=window.open("",`zeugma-popout-${s}`,"width=800,height=600");if(!i){console.warn("Failed to open popout window. Check popup blocker."),o(s);return}l[s]=i,ae.add(i.document),De.forEach(d=>{try{d.target==="window"?i.addEventListener(d.type,d.listener,d.options):i.document.addEventListener(d.type,d.listener,d.options);}catch{}}),co(),uo(),i.document.title=f,i.document.head.innerHTML="";try{let d=i.document.createElement("base");d.setAttribute("href",window.location.origin+"/"),i.document.head.appendChild(d);}catch{}if(Array.from(document.querySelectorAll('style, link[rel="stylesheet"]')).forEach(d=>{let v=d.cloneNode(true);if(d.tagName.toLowerCase()==="link"){let w=d.href;w&&v.setAttribute("href",w);}else if(d.tagName.toLowerCase()==="style")try{let w=d.sheet?.cssRules;if(w&&w.length>0){let I=Array.from(w).map(q=>q.cssText).join(`
10
+ `);v.textContent=I;}}catch{}i.document.head.appendChild(v);}),typeof document.adoptedStyleSheets<"u"&&typeof i.document.adoptedStyleSheets<"u")try{let d=Array.from(document.adoptedStyleSheets).map(v=>{try{let w=new i.CSSStyleSheet,I=Array.from(v.cssRules).map(q=>q.cssText).join(`
11
+ `);return w.replaceSync(I),w}catch{return null}}).filter(v=>v!==null);i.document.adoptedStyleSheets=d;}catch(d){console.warn("Failed to copy adoptedStyleSheets:",d);}i.document.documentElement.className=document.documentElement.className,i.document.body.className=document.body.className,Array.from(document.documentElement.attributes).forEach(d=>{i.document.documentElement.setAttribute(d.name,d.value);}),i.document.body.style.margin="0",i.document.body.style.padding="0",i.document.body.style.height="100vh",i.document.body.style.overflow="hidden";let b=document.getElementById(`zeugma-tab-target-${s}`),g="";b&&(g=window.getComputedStyle(b).backgroundColor,(!g||g==="transparent"||g==="rgba(0, 0, 0, 0)")&&b.parentElement&&(g=window.getComputedStyle(b.parentElement).backgroundColor));let m=window.getComputedStyle(document.documentElement),h=window.getComputedStyle(document.body),y=h.backgroundColor,N=!y||y==="transparent"||y==="rgba(0, 0, 0, 0)"?m.backgroundColor:y,T=g&&g!=="transparent"&&g!=="rgba(0, 0, 0, 0)"?g:N&&N!=="transparent"&&N!=="rgba(0, 0, 0, 0)"?N:"#181b1f";document.documentElement.getAttribute("data-theme")||(i.document.documentElement.style.backgroundColor=T,i.document.body.style.backgroundColor=T),i.document.body.style.color=h.color||m.color,i.document.body.style.fontFamily=h.fontFamily||m.fontFamily;let D=i.document.createElement("div");D.id=`zeugma-popout-container-${s}`,D.className="zeugma-popout-container",D.style.width="100%",D.style.height="100%",D.style.overflow="hidden",D.style.border="none",i.document.body.appendChild(D),n?.(s,D);let M=["pointerdown","mousedown","click","keydown","focus","touchstart"],H=d=>{Ce=d,globalThis.__zeugmaActivePopoutDocument=i.document,setTimeout(()=>{Ce===d&&(Ce=null,globalThis.__zeugmaActivePopoutDocument=null);},0);};M.forEach(d=>{i.addEventListener(d,H,true);});let a=()=>{ae.delete(i.document),ae.size===0&&(yt(),Tt()),o(s);};i.addEventListener("beforeunload",a),i.__zeugmaCleanup=()=>{M.forEach(d=>{i.removeEventListener(d,H,true);}),i.removeEventListener("beforeunload",a);};}),Object.keys(l).forEach(s=>{if(!t.includes(s)){let u=l[s];if(delete l[s],n?.(s,null),u){ae.delete(u.document),ae.size===0&&(yt(),Tt());try{let f=u;f.__zeugmaCleanup&&f.__zeugmaCleanup(),un(()=>{try{f.close();}catch{}});}catch{}}}});},[t,n,r,o]),ge.useEffect(()=>()=>{let l=c.current;Object.keys(l).forEach(s=>{let u=l[s];if(u){ae.delete(u.document);try{let f=u;f.__zeugmaCleanup&&f.__zeugmaCleanup(),un(()=>{try{f.close();}catch{}});}catch{}}}),ae.size===0&&(yt(),Tt());},[]);}typeof window<"u"&&dn();var fn=({activeId:e,render:t,className:n})=>{let r=ge.useRef(null);return ge.useEffect(()=>{let o=c=>{r.current&&(r.current.style.transform=`translate(${c.clientX+12}px, ${c.clientY+12}px)`);};return document.addEventListener("pointermove",o),()=>document.removeEventListener("pointermove",o)},[]),jsxRuntime.jsx("div",{ref:r,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var ho=({popoutDoc:e,children:t})=>{if(e===document)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:t});let n=ge__default.default.useEffect,r=ge__default.default.useLayoutEffect,o=ge__default.default.useInsertionEffect;ge__default.default.useEffect=(c,l)=>n(()=>{window.__zeugmaActivePopoutDocument=e;try{let s=c();return typeof s=="function"?()=>{window.__zeugmaActivePopoutDocument=e;try{return s()}finally{window.__zeugmaActivePopoutDocument=null;}}:s}finally{window.__zeugmaActivePopoutDocument=null;}},l),ge__default.default.useLayoutEffect=(c,l)=>r(()=>{window.__zeugmaActivePopoutDocument=e;try{let s=c();return typeof s=="function"?()=>{window.__zeugmaActivePopoutDocument=e;try{return s()}finally{window.__zeugmaActivePopoutDocument=null;}}:s}finally{window.__zeugmaActivePopoutDocument=null;}},l),o&&(ge__default.default.useInsertionEffect=(c,l)=>o(()=>{window.__zeugmaActivePopoutDocument=e;try{let s=c();return typeof s=="function"?()=>{window.__zeugmaActivePopoutDocument=e;try{return s()}finally{window.__zeugmaActivePopoutDocument=null;}}:s}finally{window.__zeugmaActivePopoutDocument=null;}},l)),window.__zeugmaActivePopoutDocument=e;try{return jsxRuntime.jsx(jsxRuntime.Fragment,{children:t})}finally{window.__zeugmaActivePopoutDocument=null,ge__default.default.useEffect=n,ge__default.default.useLayoutEffect=r,o&&(ge__default.default.useInsertionEffect=o);}},gn=ge__default.default.memo(({tabDetails:e,target:t,renderWidget:n})=>{let{id:r}=e,{renderPopoutWrapper:o}=re(),[c,l]=ge.useState(false),s=ge.useRef(null);if(ge.useEffect(()=>{l(true);},[]),ge.useEffect(()=>{if(!c||!s.current)return;let m=s.current;if(t)t.ownerDocument.adoptNode(m),t.appendChild(m);else {let h=document.getElementById("zeugma-hidden-portal-container");h||(h=document.createElement("div"),h.id="zeugma-hidden-portal-container",h.style.display="none",document.body.appendChild(h)),document.adoptNode(m),h.appendChild(m);}},[t,c]),ge.useEffect(()=>()=>{s.current&&s.current.remove();},[]),!c)return null;let u=t?t.ownerDocument:document;s.current&&s.current.ownerDocument!==u&&u.adoptNode(s.current),s.current||(s.current=u.createElement("div"),s.current.className=`zeugma-portal-wrapper-${r}`,s.current.style.width="100%",s.current.style.height="100%");let f=s.current;if(!f||!n)return null;let i=!!(t&&t.ownerDocument&&t.ownerDocument!==document),b=e.remountOnPopout?i?"-popped":"-docked":"",g=jsxRuntime.jsx(ge__default.default.Fragment,{children:n(e)},`${r}${b}`);return i&&t&&t.ownerDocument&&o&&(g=o({tabId:r,document:t.ownerDocument,window:t.ownerDocument.defaultView||window,children:g})),reactDom.createPortal(jsxRuntime.jsx(ho,{popoutDoc:i&&t?t.ownerDocument:document,children:g}),f)},(e,t)=>e.target===t.target&&e.renderWidget===t.renderWidget&&e.tabDetails.id===t.tabDetails.id&&e.tabDetails.paneId===t.tabDetails.paneId&&e.tabDetails.isActive===t.tabDetails.isActive&&e.tabDetails.index===t.tabDetails.index&&e.tabDetails.metadata===t.tabDetails.metadata);var bn=({activeId:e,activeType:t,dismissIntentId:n,renderDragOverlay:r,renderPaneRef:o,renderPane:c,tabHeadersRef:l,classNames:s})=>{if(r)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:r({type:t,id:e,isDismissing:e===n})});if(t==="pane"){let u=o.current||c;if(u)return jsxRuntime.jsx("div",{className:s.paneDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:u(e)})}else if(t==="tab"){let u=o.current||c;if(u)return jsxRuntime.jsx("div",{className:s.tabDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:u(e)});let f=l.current[e];if(f){let i=s.tab?typeof s.tab=="function"?s.tab(e):s.tab:"";return jsxRuntime.jsx("div",{className:`${s.tabDragPreview||""} ${i}`.trim(),style:{display:"inline-flex",position:"relative",pointerEvents:"none",overflow:"hidden"},children:f({isDragging:true,isOver:false})})}}return jsxRuntime.jsx("div",{style:{pointerEvents:"none",overflow:"hidden",width:"100%",height:"100%"}})};function wt({containerRef:e,isRow:t,direction:n,splitPercentage:r,resizerSize:o,snapThreshold:c,layout:l,currentNode:s,onLayoutChange:u,onResizeStart:f,onResizeEnd:i,parentLeft:b,parentTop:g,parentWidth:m,parentHeight:h}){let{onResizeStart:y,onResize:C,onResizeEnd:N,minSplitPercentage:T=5,maxSplitPercentage:Z=95,locked:D=false}=re();return ge.useCallback(M=>{if(D)return;M.preventDefault();let H=e.current;if(!H)return;f&&f(),y&&y(s);let a=H.getBoundingClientRect(),d=M.clientX,v=M.clientY,w=r,I=M.currentTarget,q=a.left+a.width*(b/100),ne=a.top+a.height*(g/100),G=a.width*(m/100),A=a.height*(h/100),j=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(_=>_!==I&&_.getAttribute("data-direction")===n).map(_=>{let L=_.getBoundingClientRect();return t?L.left+L.width/2:L.top+L.height/2}),V=w;Ht({cursor:t?"col-resize":"row-resize",resizerEl:I,onMove:_=>{let L=t?(_.clientX-d)/G*100:(_.clientY-v)/A*100,P=w+L,z=t?q+(G-o)*(P/100)+o/2:ne+(A-o)*(P/100)+o/2,E=1/0,O=null;for(let Y of j){let ee=Math.abs(z-Y);ee<c&&ee<E&&(E=ee,O=Y);}let ue=P;O!==null&&(ue=t?(O-o/2-q)/(G-o)*100:(O-o/2-ne)/(A-o)*100);let Q=Math.max(T,Math.min(Z,ue));V=Q;let K=xe(l,s,Q);if(K){let{panes:Y,splitters:ee}=ve(K),S=e.current;if(S){for(let k of Y)S.style.setProperty(`--pane-left-${k.paneId}`,`${k.left}%`),S.style.setProperty(`--pane-top-${k.paneId}`,`${k.top}%`),S.style.setProperty(`--pane-width-${k.paneId}`,`${k.width}%`),S.style.setProperty(`--pane-height-${k.paneId}`,`${k.height}%`);for(let k of ee)S.style.setProperty(`--splitter-pos-${k.id}`,`${k.direction==="row"?k.left:k.top}%`);}}C&&C(s,Q);},onEnd:()=>{let _=xe(l,s,V),L=e.current;if(L){let{panes:P,splitters:z}=ve(_);for(let E of P)L.style.removeProperty(`--pane-left-${E.paneId}`),L.style.removeProperty(`--pane-top-${E.paneId}`),L.style.removeProperty(`--pane-width-${E.paneId}`),L.style.removeProperty(`--pane-height-${E.paneId}`);for(let E of z)L.style.removeProperty(`--splitter-pos-${E.id}`);}u(_),i&&i(),N&&N(s,V);}});},[e,t,n,r,o,c,l,s,u,f,i,y,C,N,T,Z,b,g,m,h])}var vn=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:r})=>{let{renderingLayout:o,setLayout:c,classNames:l,locked:s}=re(),[u,f]=ge.useState(false),{currentNode:i,direction:b,left:g,top:m,width:h,height:y,parentLeft:C,parentTop:N,parentWidth:T,parentHeight:Z}=e,D=b==="row",M=wt({containerRef:r,isRow:D,direction:b,splitPercentage:i.splitPercentage,resizerSize:t,snapThreshold:n,layout:o,currentNode:i,onLayoutChange:c,onResizeStart:()=>f(true),onResizeEnd:()=>f(false),parentLeft:C,parentTop:N,parentWidth:T,parentHeight:Z}),H=D?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${g}%) - ${t/2}px)`,top:`calc(${m}% + ${t/2}px)`,width:`${t}px`,height:`calc(${y}% - ${t}px)`,cursor:s?"default":"col-resize",pointerEvents:s?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`calc(${g}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${m}%) - ${t/2}px)`,width:`calc(${h}% - ${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:l.resizer||"","data-direction":b,"data-resizing":u||void 0,style:H,onPointerDown:M,role:"separator","aria-valuenow":i.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},hn=ge__default.default.memo(({paneId:e,renderPane:t})=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane);var Rt=({renderPane:e,tree:t,resizerSize:n,snapThreshold:r})=>{jt(e);let{renderingLayout:o,activeId:c,dismissIntentId:l,setContainerRef:s,fullscreenPaneId:u,snapThreshold:f,locked:i,classNames:b,resizerSize:g}=re(),m=r!==void 0?r:f??8,h=n!==void 0?n:g??4,y=t!==void 0?t:o,C=ge.useRef(null),{panes:N,splitters:T}=ge.useMemo(()=>y?ve(y):{panes:[],splitters:[]},[y]);if(!y&&t!==void 0)return null;let Z=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[N.map(D=>{let M=u===D.paneId;return jsxRuntime.jsx("div",{style:{position:"absolute",left:M?"0%":`var(--pane-left-${D.paneId}, ${D.left}%)`,top:M?"0%":`var(--pane-top-${D.paneId}, ${D.top}%)`,width:M?"100%":`var(--pane-width-${D.paneId}, ${D.width}%)`,height:M?"100%":`var(--pane-height-${D.paneId}, ${D.height}%)`,overflow:"hidden",zIndex:M?20:1,display:u&&!M?"none":"block",padding:M?"0px":`${h/2}px`,boxSizing:"border-box"},children:jsxRuntime.jsx(hn,{paneId:D.paneId,renderPane:e})},D.paneId)}),!u&&T.map(D=>jsxRuntime.jsx(vn,{splitter:D,resizerSize:h,snapThreshold:m,containerRef:C},D.id))]});if(t===void 0){let D=c!==null&&c===l,M=a=>{s(a),C.current=a;},H=`${b.dashboard||""} ${D&&b.dashboardDismissActive||""} ${i&&b.dashboardLocked||""}`.trim();return jsxRuntime.jsxs("div",{ref:M,className:H,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[Z(),c!==null&&!i&&jsxRuntime.jsx(Pn,{activeClassName:b.rootDropPreview??b.dropPreview})]})}return jsxRuntime.jsx("div",{ref:C,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:Z()})};var So=e=>{let{controller:t,children:n,renderDragOverlay:r,classNames:o={},renderPane:c,resizerSize:l,dragActivationDistance:s=8,snapThreshold:u=8,minSplitPercentage:f=5,maxSplitPercentage:i=95,enableDragToDismiss:b=false,dismissThreshold:g=60,onRemove:m,onDragStart:h,onDragEnd:y,onResizeStart:C,onResize:N,onResizeEnd:T,onDismissIntentChange:Z,persist:D=false,renderPopoutWrapper:M}=e,H=t,{layout:a,setLayout:d,_internalSetLayout:v,renderingLayout:w,fullscreenPaneId:I,setFullscreenPaneId:q,locked:ne,setLocked:G,findPaneById:A,findPaneContainingTab:B,findTabById:j,getTabMetadata:V,getActiveTabMetadata:_,activeId:L,setActiveId:P,activeType:z,setActiveType:E,dismissIntentId:O,setDismissIntentId:ue,containerRef:Q,setContainerRef:K,removePane:Y,addTab:ee,updateMetadata:S,updatePaneLock:k,selectTab:ie,mergeTab:le,removeTab:J,splitPane:oe,updateSplitPercentage:Ze,moveTab:p,poppedOutTabIds:R=[],popoutTab:x,dockTab:$}=H;sn({persist:D,layout:a,setLayout:d});let{portalTargets:F,registerPortalTarget:se,registerPopoutTarget:W,registerRenderCallback:ye,renderCallbacksRef:Xe,registerRenderPane:Lt,renderPaneRef:ft,registerTabHeader:kt,tabHeadersRef:mt,activeIdRef:Ye}=Ft();pn({poppedOutTabIds:R,registerPopoutTarget:W,findTabById:j,dockTab:$});let Mt=ge.useCallback(de=>R.includes(de),[R]),{overTabId:Ot,setOverTabId:Hn,overTabPosition:At,setOverTabPosition:$n,handleDragStartInternal:Bn,handleDragEndInternal:_n}=Wt({onDragStart:h,onDragEnd:y}),Fn=rn({layout:a,_internalSetLayout:v,setLayout:d,activeId:L,setActiveId:P,activeType:z,setActiveType:E,dismissIntentId:O,setDismissIntentId:ue,setOverTabId:Hn,setOverTabPosition:$n,containerRef:Q,dragActivationDistance:s,enableDragToDismiss:b,dismissThreshold:g,onRemove:m,onDragStart:Bn,onDragEnd:_n,onDismissIntentChange:Z,removeTab:J,removePane:Y}),gt=ge.useMemo(()=>o,[o.dashboard,o.dashboardDismissActive,o.pane,o.paneLocked,o.dropPreview,o.rootDropPreview,o.dragOverlay,o.paneDragPreview,o.tabDragPreview,o.resizer,o.dismissPreview,o.dashboardLocked,o.lockedPreview,o.tabDropPreview,o.tabSeparator,o.tabsContainer,o.tab,o.paneContainer,o.paneHeader,o.paneControls,o.paneButton,o.tabCloseButton,o.dragHandle]),zt=ge.useCallback((de,Ge)=>{T&&T(de,Ge);},[T]),Vn=ge.useMemo(()=>({layout:a,renderingLayout:w,setLayout:d,activeId:L,activeType:z,dismissIntentId:O,setContainerRef:K,fullscreenPaneId:I,classNames:gt,onRemove:m,onFullscreenChange:q,snapThreshold:u,onResizeStart:C,onResize:N,onResizeEnd:zt,minSplitPercentage:f,maxSplitPercentage:i,locked:ne,setLocked:G,findPaneById:A,findPaneContainingTab:B,findTabById:j,getTabMetadata:V,getActiveTabMetadata:_,renderPane:c,resizerSize:l,poppedOutTabIds:R,isTabPoppedOut:Mt,renderPopoutWrapper:M}),[a,w,L,z,O,K,I,gt,m,q,u,C,N,f,i,d,zt,ne,G,A,B,j,V,_,c,l,R,Mt,M]),Wn=ge.useMemo(()=>({overTabId:Ot,overTabPosition:At}),[Ot,At]),jn=ge.useMemo(()=>({removePane:Y,addTab:ee,updateMetadata:S,updatePaneLock:k,selectTab:ie,mergeTab:le,removeTab:J,setFullscreenPaneId:q,setLocked:G,splitPane:oe,updateSplitPercentage:Ze,moveTab:p,popoutTab:x,dockTab:$}),[Y,ee,S,k,ie,le,J,q,G,oe,Ze,p,x,$]),qn=Vt(a),Un=ge.useMemo(()=>({registerPortalTarget:se,registerRenderCallback:ye,renderCallbacksRef:Xe,registerRenderPane:Lt,renderPaneRef:ft,registerTabHeader:kt,tabHeadersRef:mt,activeIdRef:Ye,registerPopoutTarget:W}),[se,ye,Xe,Lt,ft,kt,mt,Ye,W]);return Ye&&(Ye.current=L),jsxRuntime.jsx(we.Provider,{value:jn,children:jsxRuntime.jsx(vt.Provider,{value:Vn,children:jsxRuntime.jsx(ht.Provider,{value:Wn,children:jsxRuntime.jsxs(Te.Provider,{value:Un,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",...Fn,children:n}),L&&z&&jsxRuntime.jsx(fn,{activeId:L,render:de=>jsxRuntime.jsx("div",{style:{transition:"transform 150ms cubic-bezier(0.2, 0, 0, 1)",transform:de===O?"scale(0.8)":"scale(1)",transformOrigin:"top left"},children:jsxRuntime.jsx(bn,{activeId:de,activeType:z,dismissIntentId:O,renderDragOverlay:r,renderPaneRef:ft,renderPane:c,tabHeadersRef:mt,classNames:gt})}),className:`${o.dragOverlay||""} ${L===O&&o.dismissPreview||""}`.trim()}),jsxRuntime.jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:qn.map(de=>{let Ge=F[de],Zt=j(de);return Zt?jsxRuntime.jsx(gn,{tabDetails:Zt,target:Ge||null,renderWidget:Xe.current[de]},de):null})})]})})})})},No=({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(Rt,{renderPane:e,resizerSize:t,snapThreshold:n})},Io=e=>{let{children:t,...n}=e,{controller:r}=e;if(!r)throw new Error("Zeugma component requires a controller.");return jsxRuntime.jsx(So,{...e,children:t!==void 0?t:jsxRuntime.jsx(No,{...n})})};var Mo={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"}}},Oo={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"}}},Ao=({id:e,fraction:t,edge:n,activeClassName:r})=>{let{setNodeRef:o,isOver:c}=core.useDroppable({id:e}),l={position:"absolute",pointerEvents:"none",zIndex:101,boxSizing:"border-box",...Oo[n][t]};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:o,style:Mo[n][t]}),c&&jsxRuntime.jsx("div",{className:r,style:l})]})},Pn=({activeClassName:e})=>jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:99,pointerEvents:"none"},children:[{id:"drop-root-1/4-top",fraction:"1/4",edge:"top"},{id:"drop-root-1/3-top",fraction:"1/3",edge:"top"},{id:"drop-root-1/4-bottom",fraction:"1/4",edge:"bottom"},{id:"drop-root-1/3-bottom",fraction:"1/3",edge:"bottom"},{id:"drop-root-1/4-left",fraction:"1/4",edge:"left"},{id:"drop-root-1/3-left",fraction:"1/3",edge:"left"},{id:"drop-root-1/4-right",fraction:"1/4",edge:"right"},{id:"drop-root-1/3-right",fraction:"1/3",edge:"right"}].map(n=>jsxRuntime.jsx(Ao,{id:n.id,fraction:n.fraction,edge:n.edge,activeClassName:e},n.id))});var lt=ge.createContext(null);var Bo={top:{position:"absolute",top:0,left:0,width:"100%",height:"25%",zIndex:20,pointerEvents:"auto"},bottom:{position:"absolute",bottom:0,left:0,width:"100%",height:"25%",zIndex:20,pointerEvents:"auto"},left:{position:"absolute",top:"25%",left:0,width:"50%",height:"50%",zIndex:20,pointerEvents:"auto"},right:{position:"absolute",top:"25%",right:0,width:"50%",height:"50%",zIndex:20,pointerEvents:"auto"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:20,pointerEvents:"auto",cursor:"not-allowed"},center:{position:"absolute",top:"25%",left:"25%",width:"50%",height:"50%",zIndex:22,pointerEvents:"auto"}},_o={top:{position:"absolute",top:0,left:0,right:0,height:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},bottom:{position:"absolute",bottom:0,left:0,right:0,height:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},left:{position:"absolute",top:0,bottom:0,left:0,width:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},right:{position:"absolute",top:0,bottom:0,right:0,width:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:21,pointerEvents:"none",boxSizing:"border-box"},center:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:21,pointerEvents:"none",boxSizing:"border-box"}},ct=({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:Bo[t]}),o&&jsxRuntime.jsx("div",{className:n,style:_o[t]})]})};var xn=({children:e,className:t,style:n})=>{let r=ge.useContext(lt);if(!r)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:o,...c}=r;return jsxRuntime.jsx("div",{className:t,style:{cursor:o?"default":"grab",userSelect:o?"auto":"none",touchAction:o?"auto":"none",...n},...o?{}:c,children:e})};var Jo=ge.createContext(void 0);var je=({id:e,locked:t=false,children:n,className:r,style:o})=>{let{locked:c,classNames:l={},fullscreenPaneId:s,poppedOutTabIds:u=[]}=re(),f=ge.useContext(we),{overTabId:i}=Qe(),b=ge.useContext(Te);ge.useEffect(()=>(b?.registerTabHeader&&b.registerTabHeader(e,n),()=>{b?.registerTabHeader&&b.activeIdRef?.current!==e&&b.registerTabHeader(e,()=>null);}),[e,n,b]);let g=u.includes(e),m=ge.useContext(Dt),h=t||c||(m?.locked??false)||s!==null,{attributes:y,listeners:C,setNodeRef:N,isDragging:T}=core.useDraggable({id:`tab-header-${e}`,disabled:h}),{setNodeRef:Z,isOver:D}=core.useDroppable({id:`tab-drop-${e}`,disabled:h}),M=j=>{N(j),Z(j);},H=D&&i===e,a=m?.tabIds||[],d=a.indexOf(e),v=m?.activeTabId,I=d>0&&e!==v&&a[d-1]!==v?jsxRuntime.jsx("div",{className:l.tabSeparator}):null,q=m?m.activeTabId===e:false,ne=m?.tabsMetadata?.[e],G=ge.useCallback(()=>{m?.selectTab(e);},[m,e]),A=ge.useCallback(()=>{m?.removeTab(e);},[m,e]),B=ge.useMemo(()=>({tabId:e,isActive:q,isDragging:T,isOver:H,metadata:ne,locked:h,selectTab:G,removeTab:A,isPoppedOut:g,popoutTab:()=>f?.popoutTab(e),dockTab:()=>f?.dockTab(e)}),[e,q,T,H,ne,h,G,A,g,f]);return jsxRuntime.jsx(Jo.Provider,{value:B,children:jsxRuntime.jsxs("div",{ref:M,id:`tab-header-${e}`,className:r,style:{display:"inline-flex",position:"relative",cursor:h?"default":"grab",...o},...h?{}:C,...h?{}:y,children:[I,n({isDragging:T,isOver:H})]})})};var Dt=ge.createContext(void 0);var Sn=(e,t)=>typeof e=="function"?e(t):e,Ct=({tabIds:e,activeTabId:t,locked:n,tabsMetadata:r,selectTab:o,removeTab:c,renderTab:l,classNames:s,styles:u})=>{let f=ge.useContext(ut),i=e??f?.tabIds??[],b=t??f?.activeTabId??"",g=n??f?.locked??false,m=r??f?.tabsMetadata,h=o??f?.selectTab??(()=>{}),y=c??f?.removeTab??(()=>{}),{classNames:C={},activeType:N,poppedOutTabIds:T=[]}=re(),Z=ge.useContext(we),{overTabId:D,overTabPosition:M}=Qe(),H=ge.useMemo(()=>({tabIds:i,activeTabId:b,locked:g,tabsMetadata:m,selectTab:h,removeTab:y}),[i,b,g,m,h,y]),a=Qt(i,N,D,M);return jsxRuntime.jsx(Dt.Provider,{value:H,children:jsxRuntime.jsxs("div",{className:s?.container,style:{display:"flex",alignItems:"center",height:"100%",...u?.container},children:[i.map((d,v)=>{let w=m?.[d],I=Sn(s?.tab,d),q=Sn(u?.tab,d),ne=v===a;return jsxRuntime.jsxs(ge__default.default.Fragment,{children:[ne&&C.tabDropPreview&&jsxRuntime.jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsxRuntime.jsx("div",{className:C.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:v===0?"none":"translateX(-50%)"}})}),jsxRuntime.jsx(je,{id:d,locked:g,className:I,style:q,children:({isDragging:G,isOver:A})=>l({id:d,paneId:f?.id??"",isActive:d===b,index:v,isDragging:G,isOver:A,metadata:w,onSelect:()=>h(d),onRemove:()=>y(d),isPoppedOut:T.includes(d),popout:()=>Z?.popoutTab(d),dock:()=>Z?.dockTab(d)})})]},d)}),a===i.length&&C.tabDropPreview&&jsxRuntime.jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsxRuntime.jsx("div",{className:C.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:"translateX(-100%)"}})})]})})};Ct.Tab=je;var In=({className:e,style:t,children:n})=>jsxRuntime.jsx("div",{className:e,style:t,children:n});var ut=ge.createContext(void 0),kn=()=>{let e=ge.useContext(ut);if(!e)throw new Error("usePaneContext must be used within a Pane component");return e},ir=({children:e,className:t,style:n})=>{let{activeTabId:r}=kn(),{classNames:o,isTabPoppedOut:c}=re(),{dockTab:l}=He(),s=ge.useRef(null),u=ge.useContext(Te);if(!u)throw new Error("PaneContent must be used within a Zeugma provider");let{registerPortalTarget:f,registerRenderCallback:i}=u,b=ge.useMemo(()=>typeof e=="function"?e:()=>e,[e]);i(r,b),ge.useEffect(()=>{let m=s.current;return f(r,m),()=>{f(r,null,m);}},[r,f]);let g=c(r);return jsxRuntime.jsx("div",{ref:s,id:`zeugma-tab-target-${r}`,className:`${o.tabContentWrapper||""} ${t||""}`.trim(),style:{height:"100%",width:"100%",position:"relative",...n},children:g&&jsxRuntime.jsxs("div",{className:"zeugma-popout-placeholder",style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"12px",padding:"24px",textAlign:"center",backgroundColor:"#161719",color:"#94a3b8",fontSize:"13px",fontWeight:500},children:[jsxRuntime.jsx("div",{children:"This panel is open in a new window"}),jsxRuntime.jsx("button",{onClick:()=>l(r),style:{padding:"6px 12px",fontSize:"11px",fontWeight:600,borderRadius:"4px",backgroundColor:"#2563eb",color:"#ffffff",border:"none",cursor:"pointer",boxShadow:"0 1px 3px rgba(0,0,0,0.1)"},onMouseOver:m=>{m.currentTarget.style.backgroundColor="#1d4ed8";},onMouseOut:m=>{m.currentTarget.style.backgroundColor="#2563eb";},children:"Dock Back"})]})})},Oe=({id:e,children:t,style:n,locked:r=false})=>{let{layout:o,renderingLayout:c,activeId:l,activeType:s,classNames:u,fullscreenPaneId:f,onFullscreenChange:i,locked:b,poppedOutTabIds:g=[]}=re(),{removePane:m,updateMetadata:h,selectTab:y,removeTab:C,popoutTab:N,dockTab:T}=He(),Z=ge.useMemo(()=>{if(s==="tab"&&e===l){let O=U(o,e)?.tabsMetadata?.[e];return {type:"pane",id:e,tabIds:[e],activeTabId:e,tabsMetadata:O?{[e]:O}:void 0}}return Ut(e===l?o:c,e)},[o,c,e,l,s]),D=Z?.id??e,M=Z?.tabIds??[e],H=Z?.activeTabId??e,a=Z?.tabsMetadata,d=a?.[e],v=Z?.locked??false,w=r||v,I=b||w||f!==null,q=b||w||f!==null,ne=l!==null&&l!==e&&(!M.includes(l)||M.length>1)&&!q,{attributes:G,listeners:A,setNodeRef:B}=core.useDraggable({id:e,disabled:I}),j=l!==null&&M.includes(l),V=f===e,_=ge.useMemo(()=>({isDragging:j,isFullscreen:V,toggleFullscreen:()=>i?.(V?null:e),remove:()=>{V&&i?.(null),m(D);},metadata:d,updateMetadata:z=>{h(e,z);},locked:I,tabIds:M,activeTabId:H,selectTab:z=>y(D,z),removeTab:z=>{V&&z===H&&i?.(null),C(z);},tabsMetadata:a,updateTabMetadata:(z,E)=>{h(z,E);},isActiveTabPoppedOut:g.includes(H),popoutTab:z=>N(z||H),dockTab:z=>T(z||H)}),[j,V,i,e,C,d,h,I,M,H,y,D,a,g,N,T]),L=ge.useMemo(()=>I?{disabled:true}:{...A,...G},[A,G,I]),P=`${u.pane||""} ${w&&u.paneLocked||""}`.trim();return jsxRuntime.jsx(ut.Provider,{value:{id:e,..._},children:jsxRuntime.jsx(lt.Provider,{value:L,children:jsxRuntime.jsxs("div",{ref:B,id:e,className:P,style:{position:"relative",width:"100%",height:"100%",...n},children:[t,ne&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:[["top","bottom","left","right"].map(z=>jsxRuntime.jsx(ct,{id:`drop-${z}-${e}`,position:z,activeClassName:u.dropPreview},z)),s==="tab"&&jsxRuntime.jsx(ct,{id:`drop-center-${e}`,position:"center",activeClassName:u.swapPreview??u.dropPreview})]}),l!==null&&l!==e&&q&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsxRuntime.jsx(ct,{id:`drop-locked-${e}`,position:"full",activeClassName:u.lockedPreview||""})})]})})})};Oe.Content=ir;Oe.DragHandle=xn;Oe.Tabs=Ct;Oe.Tab=je;Oe.Controls=In;var pt=new Map;function qe(e){let t=pt.get(e);return t||(t={mounts:0,renders:0,listeners:new Set},pt.set(e,t)),t}function Mn(e,t){let n=qe(e);return n.listeners.add(t),()=>{n.listeners.delete(t);}}function St(e){let t=pt.get(e);t&&t.listeners.forEach(n=>n());}function On(e){let t=pt.get(e);t&&(t.mounts=0,t.renders=0,St(e));}function Ae(e,t){let n=ge.useId(),r=typeof e=="string"?{id:e,...t}:e||{},{id:o=n,logToConsole:c=false,disabled:l=false}=r,s=ge.useRef(0),u=ge.useRef(false),[,f]=ge.useState(0);if(l||(s.current+=1),ge.useEffect(()=>{if(l)return;let g=Mn(o,()=>{f(h=>h+1);}),m=qe(o);return m.mounts+=1,u.current=true,c&&console.log(`[DevTools:${o}] Mounted: ${m.mounts} | Rendered: ${s.current}`),St(o),()=>{u.current=false,g();}},[o,l,c]),!l){let g=qe(o);g.renders=Math.max(g.renders,s.current);}let i=ge.useCallback(()=>{s.current=0,On(o);},[o]);return l?{mounts:0,renders:0,reset:i}:{mounts:qe(o).mounts,renders:s.current,reset:i}}function zn({id:e,className:t,style:n,logToConsole:r=false,disabled:o=false}){let{mounts:c,renders:l}=Ae(e,{logToConsole:r,disabled:o});return o?null:jsxRuntime.jsxs("div",{className:t,style:n,children:[jsxRuntime.jsxs("span",{children:["M: ",jsxRuntime.jsx("strong",{children:c})]}),jsxRuntime.jsx("span",{children:"|"}),jsxRuntime.jsxs("span",{children:["R: ",jsxRuntime.jsx("strong",{children:l})]})]})}function Zn({id:e,label:t,children:n,className:r,footerClassName:o,style:c,logToConsole:l=false,disabled:s=false}){let u=t||e||"widget",{mounts:f,renders:i}=Ae(e,{logToConsole:l,disabled:s});return s?jsxRuntime.jsx(jsxRuntime.Fragment,{children:n}):jsxRuntime.jsxs("div",{className:r,style:c,children:[n&&jsxRuntime.jsx("div",{style:{flex:1,height:"100%",width:"100%",minHeight:0,overflow:"hidden",position:"relative"},children:n}),jsxRuntime.jsxs("div",{className:o,children:[jsxRuntime.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:u}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[jsxRuntime.jsxs("span",{children:["Mounts: ",jsxRuntime.jsx("strong",{className:"counter-mounts",children:f})]}),jsxRuntime.jsx("span",{children:"|"}),jsxRuntime.jsxs("span",{children:["Renders: ",jsxRuntime.jsx("strong",{className:"counter-renders",children:i})]})]})]})]})}exports.Pane=Oe;exports.PaneTree=Rt;exports.RenderCounterBadge=zn;exports.RenderCounterFooter=Zn;exports.Zeugma=Io;exports.usePaneContext=kn;exports.useRenderCounter=Ae;exports.useResizer=wt;exports.useZeugma=Kn;exports.useZeugmaContext=eo;//# sourceMappingURL=index.cjs.map
12
12
  //# sourceMappingURL=index.cjs.map