react-zeugma 6.9.6 → 6.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/devtools.cjs +1 -1
- package/dist/devtools.cjs.map +1 -1
- package/dist/devtools.d.cts +1 -1
- package/dist/devtools.d.ts +1 -1
- package/dist/devtools.js +1 -1
- package/dist/devtools.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/{render-counter-footer-CYe6-Atc.d.cts → render-counter-footer-rAKCzuRX.d.cts} +2 -2
- package/dist/{render-counter-footer-CYe6-Atc.d.ts → render-counter-footer-rAKCzuRX.d.ts} +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -578,5 +578,5 @@ function MyDashboardWidget({ id }: { id: string }) {
|
|
|
578
578
|
### Components & Hooks
|
|
579
579
|
|
|
580
580
|
- `useRenderCounter(idOrOptions?, options?)`: React 18/19 StrictMode-safe hook returning `{ mounts, renders, reset }`.
|
|
581
|
-
- `<RenderCounterBadge id={id} position="top-right" />`:
|
|
582
|
-
- `<RenderCounterFooter id={id} label="Widget Name">`:
|
|
581
|
+
- `<RenderCounterBadge id={id} position="top-right" className="..." />`: Unstyled overlay badge for any panel or component.
|
|
582
|
+
- `<RenderCounterFooter id={id} label="Widget Name" className="..." footerClassName="...">`: Unstyled wrapper component rendering a bottom status footer for tabbed widgets.
|
package/dist/devtools.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var
|
|
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
|
|
2
2
|
//# sourceMappingURL=devtools.cjs.map
|
package/dist/devtools.cjs.map
CHANGED
|
@@ -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","POSITION_STYLES","RenderCounterBadge","position","className","style","mounts","renders","posClass","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,CAAAA,CAAiBC,CAAE,CAAA,CAClC,OAAAC,CAAAA,CAAO,SAAA,CAAU,GAAA,CAAIE,CAAQ,CAAA,CACtB,IAAM,CACXF,CAAAA,CAAO,SAAA,CAAU,MAAA,CA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AJ,CAAAA,CAAO,CAAA,CAAA,CACrE,CAAA,CACAI,cAAAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,YAAA,CAAa,QAAA,CAAA,GAAA,CAAC,CAAA,CAC9BD,eAAAA,CAAC,MAAA,CAAA,CAAK,QAAA,CAAA,CAAA,WAAA,CACKC,cAAAA,CAAC,QAAA,CAAA,CAAO,SAAA,CAAU,+BAAA,CAAiC,QAAA,CAAAH,CAAAA,CAAQ,CAAA,CAAA,CACtE,CAAA,CAAA,CACF,CAAA,CAAA,CACF,GACF,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\nconst POSITION_STYLES: Record<NonNullable<RenderCounterBadgeProps['position']>, string> = {\n 'top-right': 'top-2 right-2',\n 'top-left': 'top-2 left-2',\n 'bottom-right': 'bottom-2 right-2',\n 'bottom-left': 'bottom-2 left-2',\n}\n\n/**\n * A floating overlay badge displaying mount and render counters for debugging component lifecycles.\n */\nexport function RenderCounterBadge({\n id,\n position = 'top-right',\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 const posClass = POSITION_STYLES[position] || POSITION_STYLES['top-right']\n\n return (\n <div\n className={`absolute ${posClass} z-50 pointer-events-none flex items-center gap-2 rounded px-2 py-1 text-[11px] font-mono bg-zinc-900/90 text-zinc-200 border border-zinc-700/80 shadow-md backdrop-blur-xs select-none ${className}`}\n style={style}\n >\n <span>\n M: <strong className=\"text-emerald-400 font-semibold\">{mounts}</strong>\n </span>\n <span className=\"opacity-30\">|</span>\n <span>\n R: <strong className=\"text-indigo-400 font-semibold\">{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\n className={`h-full w-full flex flex-col overflow-hidden min-h-0 ${className}`}\n style={style}\n >\n {children && <div className=\"flex-1 overflow-hidden relative min-h-0\">{children}</div>}\n <div\n className={`bg-zinc-900/90 border-t border-zinc-800 px-3 py-1.5 flex items-center justify-between text-[11px] text-zinc-400 font-mono shrink-0 select-none ${footerClassName}`}\n >\n <span className=\"truncate max-w-[140px] text-zinc-300 font-semibold\">{displayId}</span>\n <div className=\"flex items-center gap-3\">\n <span>\n Mounts: <strong className=\"text-emerald-400 font-semibold\">{mounts}</strong>\n </span>\n <span className=\"opacity-20\">|</span>\n <span>\n Renders: <strong className=\"text-indigo-400 font-semibold\">{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,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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AAAA,CAAC,MAAA,CAAA,CAAK,QAAA,CAAA,CAAA,UAAA,CACIC,cAAAA,CAAC,QAAA,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"]}
|
package/dist/devtools.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { R as RenderCounterBadge, a as RenderCounterBadgeProps, b as RenderCounterFooter, c as RenderCounterFooterProps, d as RenderCounterOptions, e as RenderCounterState, u as useRenderCounter } from './render-counter-footer-
|
|
1
|
+
export { R as RenderCounterBadge, a as RenderCounterBadgeProps, b as RenderCounterFooter, c as RenderCounterFooterProps, d as RenderCounterOptions, e as RenderCounterState, u as useRenderCounter } from './render-counter-footer-rAKCzuRX.cjs';
|
|
2
2
|
import 'react';
|
|
3
3
|
|
|
4
4
|
declare function resetCounterRecord(id: string): void;
|
package/dist/devtools.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { R as RenderCounterBadge, a as RenderCounterBadgeProps, b as RenderCounterFooter, c as RenderCounterFooterProps, d as RenderCounterOptions, e as RenderCounterState, u as useRenderCounter } from './render-counter-footer-
|
|
1
|
+
export { R as RenderCounterBadge, a as RenderCounterBadgeProps, b as RenderCounterFooter, c as RenderCounterFooterProps, d as RenderCounterOptions, e as RenderCounterState, u as useRenderCounter } from './render-counter-footer-rAKCzuRX.js';
|
|
2
2
|
import 'react';
|
|
3
3
|
|
|
4
4
|
declare function resetCounterRecord(id: string): void;
|
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
|
|
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
|
|
2
2
|
//# sourceMappingURL=devtools.js.map
|
package/dist/devtools.js.map
CHANGED
|
@@ -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","POSITION_STYLES","RenderCounterBadge","position","className","style","mounts","renders","posClass","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,IA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yBAAA,CACb,QAAA,CAAA,CAAAA,IAAAA,CAAC,MAAA,CAAA,CAAK,QAAA,CAAA,CAAA,UAAA,CACIC,GAAAA,CAAC,QAAA,CAAA,CAAO,SAAA,CAAU,gCAAA,CAAkC,QAAA,CAAAJ,CAAAA,CAAO,CAAA,CAAA,CACrE,CAAA,CACAI,GAAAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,YAAA,CAAa,QAAA,CAAA,GAAA,CAAC,CAAA,CAC9BD,IAAAA,CAAC,MAAA,CAAA,CAAK,QAAA,CAAA,CAAA,WAAA,CACKC,GAAAA,CAAC,QAAA,CAAA,CAAO,SAAA,CAAU,+BAAA,CAAiC,QAAA,CAAAH,CAAAA,CAAQ,CAAA,CAAA,CACtE,CAAA,CAAA,CACF,CAAA,CAAA,CACF,GACF,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\nconst POSITION_STYLES: Record<NonNullable<RenderCounterBadgeProps['position']>, string> = {\n 'top-right': 'top-2 right-2',\n 'top-left': 'top-2 left-2',\n 'bottom-right': 'bottom-2 right-2',\n 'bottom-left': 'bottom-2 left-2',\n}\n\n/**\n * A floating overlay badge displaying mount and render counters for debugging component lifecycles.\n */\nexport function RenderCounterBadge({\n id,\n position = 'top-right',\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 const posClass = POSITION_STYLES[position] || POSITION_STYLES['top-right']\n\n return (\n <div\n className={`absolute ${posClass} z-50 pointer-events-none flex items-center gap-2 rounded px-2 py-1 text-[11px] font-mono bg-zinc-900/90 text-zinc-200 border border-zinc-700/80 shadow-md backdrop-blur-xs select-none ${className}`}\n style={style}\n >\n <span>\n M: <strong className=\"text-emerald-400 font-semibold\">{mounts}</strong>\n </span>\n <span className=\"opacity-30\">|</span>\n <span>\n R: <strong className=\"text-indigo-400 font-semibold\">{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\n className={`h-full w-full flex flex-col overflow-hidden min-h-0 ${className}`}\n style={style}\n >\n {children && <div className=\"flex-1 overflow-hidden relative min-h-0\">{children}</div>}\n <div\n className={`bg-zinc-900/90 border-t border-zinc-800 px-3 py-1.5 flex items-center justify-between text-[11px] text-zinc-400 font-mono shrink-0 select-none ${footerClassName}`}\n >\n <span className=\"truncate max-w-[140px] text-zinc-300 font-semibold\">{displayId}</span>\n <div className=\"flex items-center gap-3\">\n <span>\n Mounts: <strong className=\"text-emerald-400 font-semibold\">{mounts}</strong>\n </span>\n <span className=\"opacity-20\">|</span>\n <span>\n Renders: <strong className=\"text-indigo-400 font-semibold\">{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,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,CAAA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AA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,UAAA,CAAY,QAAA,CAAAK,CAAAA,CAAU,CAAA,CACtCN,IAAAA,CAAC,KAAA,CAAA,CAAI,SAAA,CAAU,yBAAA,CACb,UAAAA,IAAAA,CAAC,MAAA,CAAA,CAAK,QAAA,CAAA,CAAA,UAAA,CACIC,GAAAA,CAAC,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"]}
|
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);},i=()=>{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",i),r();};document.addEventListener("pointermove",c),document.addEventListener("pointerup",i);}var vt=ge.createContext(void 0),Re=ge.createContext(void 0),Te=ge.createContext(void 0),ht=ge.createContext(void 0),ie=()=>{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},Je=()=>{let e=ge.useContext(ht);if(!e)throw new Error("useZeugmaDrag must be used within a Zeugma provider");return e};function $t(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 Bt(e){ge.useEffect(()=>(e?document.body.style.setProperty("cursor","not-allowed","important"):document.body.style.removeProperty("cursor"),()=>{document.body.style.removeProperty("cursor");}),[e]);}function _t(){let[e,t]=ge.useState({}),[n,r]=ge.useState({}),o=ge.useRef({}),c=ge.useRef(null),i=ge.useRef({}),s=ge.useRef(null),u=ge.useRef(true);ge.useEffect(()=>(u.current=true,()=>{u.current=false;}),[]);let f=ge.useCallback((y,D,I)=>{u.current&&t(T=>{if(!D){if(I&&T[y]!==I||!T[y])return T;let z={...T};return delete z[y],z}return T[y]===D?T:{...T,[y]:D}});},[]),l=ge.useCallback((y,D)=>{u.current&&r(I=>{if(!D){if(!I[y])return I;let T={...I};return delete T[y],T}return I[y]===D?I:{...I,[y]:D}});},[]),b=ge.useCallback((y,D)=>{o.current[y]=D;},[]),g=ge.useCallback(y=>{c.current=y;},[]),m=ge.useCallback((y,D)=>{i.current[y]=D;},[]);return {portalTargets:ge.useMemo(()=>({...e,...n}),[e,n]),registerPortalTarget:f,registerPopoutTarget:l,registerRenderCallback:b,renderCallbacksRef:o,registerRenderPane:g,renderPaneRef:c,registerTabHeader:m,tabHeadersRef:i,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 Ft(e){return ge.useMemo(()=>Yn(e),[e])}function Vt(e){let{onDragStart:t,onDragEnd:n}=e,[r,o]=ge.useState(null),[c,i]=ge.useState(null),s=ge.useCallback(f=>{t&&t(f);},[t]),u=ge.useCallback((f,l,b)=>{n&&n(f,l,b);},[n]);return {overTabId:r,setOverTabId:o,overTabPosition:c,setOverTabPosition:i,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 i={...e.tabsMetadata};return delete i[t],{...e,tabIds:o,activeTabId:c,tabsMetadata:Object.keys(i).length>0?i: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,i=r==="left"||r==="top";return {type:"split",direction:n,first:i?c:e,second:i?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 Wt(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 l=u.tabsMetadata;return r&&(l={...u.tabsMetadata,[n]:r}),{...u,tabIds:f,activeTabId:n,tabsMetadata:l}}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 W(e,t){return e===null?null:e.type==="pane"?e.tabIds.includes(t)?e:null:e.type==="split"?W(e.first,t)??W(e.second,t):null}function qt(e,t){return te(e,t)??W(e,t)}function nt(e,t){let n=W(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 Ut(e,t){return W(e,t)?.tabsMetadata?.[t]}function Xt(e,t){let n=te(e,t);return n?.tabsMetadata?.[n.activeTabId]}function et(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),i={...r};return c===void 0?delete i[t]:i[t]=c,{...e,tabsMetadata:Object.keys(i).length>0?i:void 0}}return e}return e.type==="split"?{...e,first:et(e.first,t,n)??e.first,second:et(e.second,t,n)??e.second}:e}function tt(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:tt(e.first,t,n)??e.first,second:tt(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 Yt(e,t,n){if(e===null)return null;let o=W(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 i(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:i(s.first),second:i(s.second)}:s}return i(c)}function Jn(e,t,n){if(e===null)return null;if(t===n)return e;let r=W(e,t),o=W(e,n);if(!r||!o)return e;let c=r.id,i=o.id,s=r.tabsMetadata?.[t],u=o.tabsMetadata?.[n];function f(l){if(l.type==="pane"){let b=false,g=[...l.tabIds],m=l.activeTabId,w=l.tabsMetadata?{...l.tabsMetadata}:{};if(c===i){if(l.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 l.id===c&&(g=g.map(y=>y===t?n:y),m===t&&(m=n),delete w[t],u&&(w[n]=u),b=true),l.id===i&&(g=g.map(y=>y===n?t:y),m===n&&(m=t),delete w[n],s&&(w[t]=s),b=true);return b?{...l,tabIds:g,activeTabId:m,tabsMetadata:Object.keys(w).length>0?w:void 0}:l}return l.type==="split"?{...l,first:f(l.first),second:f(l.second)}:l}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=W(e,t)?.tabsMetadata?.[t],i=fe(e,t);if(i===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 l=[...u.tabIds].filter(m=>m!==t),b=l.indexOf(n);b<0&&(b=0),r==="after"&&(b+=1),l.splice(b,0,t);let g={...u.tabsMetadata};return c&&(g[t]=c),{...u,tabIds:l,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(i)}function he(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:i,splitPercentage:s,first:u,second:f}=e,b={id:`splitter-${c}-${i}`,currentNode:e,direction:i,left:i==="row"?t+r*(s/100):t,top:i==="column"?n+o*(s/100):n,width:i==="row"?0:r,height:i==="column"?0:o,parentLeft:t,parentTop:n,parentWidth:r,parentHeight:o},g={panes:[],splitters:[]},m={panes:[],splitters:[]};if(i==="row"){let w=r*(s/100);g=he(u,t,n,w,o,`${c}-L`),m=he(f,t+w,n,r-w,o,`${c}-R`);}else {let w=o*(s/100);g=he(u,t,n,r,w,`${c}-T`),m=he(f,t,n+w,r,o-w,`${c}-B`);}return {panes:[...g.panes,...m.panes],splitters:[b,...g.splitters,...m.splitters]}}function Gt(e,t,n,r="before"){if(e===null)return null;let o=te(e,t);if(!o)return e;let c=o.tabIds,i=o.activeTabId,s=o.tabsMetadata||{},u=be(e,t);if(u===null)return o;function f(l){if(l.type==="pane"){if(l.tabIds.includes(n)){let g=[...l.tabIds].filter(y=>!c.includes(y)),m=g.indexOf(n);m<0&&(m=0),r==="after"&&(m+=1),g.splice(m,0,...c);let w={...l.tabsMetadata};for(let y of c)s[y]&&(w[y]=s[y]);return {...l,tabIds:g,activeTabId:i,tabsMetadata:Object.keys(w).length>0?w:void 0}}return l}return l.type==="split"?{...l,first:f(l.first),second:f(l.second)}:l}return f(u)}function Jt(e,t,n,r){if(!((t==="tab"||t==="pane")&&n&&e.includes(n))||!r)return -1;let i=e.indexOf(n);return r==="before"?i:i+1}function Qt(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],i=t[o];if(typeof c=="object"&&c!==null&&typeof i=="object"&&i!==null){if(!Qt(c,i))return false}else if(c!==i)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)||!Qt(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:i=false}=e,[s,u]=ge.useState(()=>n!==void 0?n:t??null),[f,l]=ge.useState(()=>n!==void 0?n:t??null),b=ge.useRef(n),[g,m]=ge.useState(o||null),[w,y]=ge.useState(i),[D,I]=ge.useState([]),[T,z]=ge.useState(null),[E,k]=ge.useState(null),[M,a]=ge.useState(null),d=ge.useRef(null),h=ge.useCallback(p=>{d.current=p;},[]),P=ge.useRef(s);P.current=s;let N=ge.useRef(g);N.current=g;let X=ge.useRef(r);X.current=r;let Y=ge.useRef(c);Y.current=c;let ne=ge.useCallback(p=>{m(p),Y.current?.(p);},[]);ge.useEffect(()=>{y(i);},[i]),ge.useEffect(()=>{o!==void 0&&m(o);},[o]),n!==void 0&&(Be(n,b.current??null)||(b.current=n,u(n),l(n),I(p=>{if(p.length===0)return p;let R=p.filter(C=>nt(n,C)!==null);return R.length===p.length?p:R})));let O=ge.useCallback(p=>(...R)=>{let C=P.current,F=p(C,...R);Be(C,F)||(P.current=F,u(F),l(F),I(_=>{if(_.length===0)return _;let ae=_.filter(j=>nt(F,j)!==null);return ae.length===_.length?_:ae}),X.current?.(F));},[]),H=ge.useCallback(O((p,R)=>typeof R=="function"?R(p):R),[O]),U=ge.useCallback(p=>{N.current===null&&l(R=>typeof p=="function"?p(R):p);},[]),V=ge.useCallback(p=>{m(null),Y.current?.(null),z(null),k(null),a(null),H(p),l(()=>typeof p=="function"?p(P.current):p);},[H]),A=ge.useCallback(O((p,R)=>N.current!==null?p:be(p,R)),[O]),Z=ge.useCallback(O((p,R,C,F)=>{if(N.current!==null)return p;let _=fe(p,R)??p;return Wt(_,C,R,F)}),[O]),v=ge.useCallback(O((p,R,C,F,_)=>{if(N.current!==null)return p;let ae=te(p,R)??W(p,R);if(!ae)return p;let j=te(p,_)??W(p,_)??{type:"pane",id:_,tabIds:[_],activeTabId:_},ve=be(p,j.id);return Se(ve,ae.id,C,F,j)}),[O]),$=ge.useCallback(O((p,R,C)=>N.current!==null?p:xe(p,R,C)),[O]),x=ge.useCallback(O((p,R,C)=>et(p,R,C)),[O]),B=ge.useCallback(O((p,R,C)=>{let F=te(p,R)??W(p,R);return F?tt(p,F.id,C):p}),[O]),ue=ge.useCallback(O((p,R,C)=>{let F=te(p,R)??W(p,R);return F?Ne(p,F.id,C):p}),[O]),G=ge.useCallback(O((p,R,C)=>{if(N.current!==null)return p;let F=te(p,C)??W(p,C);return F?Yt(p,R,F.id):p}),[O]),J=ge.useCallback(O((p,R,C,F)=>N.current!==null?p:$e(p,R,C,F)),[O]),Q=ge.useCallback(O((p,R)=>N.current!==null?p:fe(p,R)),[O]),K=ge.useCallback(p=>te(P.current,p),[]),S=ge.useCallback(p=>W(P.current,p),[]),L=ge.useCallback(p=>nt(P.current,p),[]),le=ge.useCallback(p=>Ut(P.current,p),[]),se=ge.useCallback(p=>Xt(P.current,p),[]),ee=ge.useCallback(p=>{N.current===null&&I(R=>R.includes(p)?R:[...R,p]);},[]),oe=ge.useCallback(p=>{N.current===null&&I(R=>R.includes(p)?R.filter(C=>C!==p):R);},[]);return {layout:s,setLayout:V,_internalSetLayout:U,renderingLayout:f,fullscreenPaneId:g,setFullscreenPaneId:ne,locked:w,setLocked:y,poppedOutTabIds:D,activeId:T,setActiveId:z,activeType:E,setActiveType:k,dismissIntentId:M,setDismissIntentId:a,containerRef:d,setContainerRef:h,removePane:A,addTab:Z,updateMetadata:x,updatePaneLock:B,selectTab:ue,mergeTab:G,moveTab:J,removeTab:Q,splitPane:v,updateSplitPercentage:$,popoutTab:ee,dockTab:oe,findPaneById:K,findPaneContainingTab:S,findTabById:L,getTabMetadata:le,getActiveTabMetadata:se}}var eo=()=>{let e=ie(),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 ot=class extends core.PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},rt=class extends core.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};var en=e=>{let n=e.active.id.toString().startsWith("tab-header-"),o=core.pointerWithin(e);if(o.length>0)return [...o].sort((i,s)=>{let u=i.id.toString(),f=s.id.toString(),l=u.startsWith("tab-drop-"),b=f.startsWith("tab-drop-");if(l&&!b)return -1;if(!l&&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(i=>i.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 on(e){let{layout:t,_internalSetLayout:n,setLayout:r,activeId:o,setActiveId:c,activeType:i,setActiveType:s,dismissIntentId:u,setDismissIntentId:f,setOverTabId:l,setOverTabPosition:b,containerRef:g,dragActivationDistance:m,enableDragToDismiss:w,dismissThreshold:y,onRemove:D,onDragStart:I,onDragEnd:T,onDismissIntentChange:z,removeTab:E,removePane:k}=e,M=ge.useRef(null),a=$t(o),d=ge.useRef(null),[h,P]=ge.useState(false);return Bt(h),{sensors:core.useSensors(core.useSensor(ot,{activationConstraint:{distance:m}}),core.useSensor(rt,{activationConstraint:{delay:250,tolerance:5}})),collisionDetection:en,onDragStart:H=>{let U=H.active.id.toString(),V=U.startsWith("tab-header-"),A=V?U.substring(11):U;c(A),s(V?"tab":"pane"),l(null),b(null);let Z=H.activatorEvent;a.current=_e(Z),w&&g.current?M.current=g.current.getBoundingClientRect():M.current=null;let v=t;if(V){let x=W(t,A);x&&(v=Ne(t,x.id,A)||t);}d.current=v;let $=V?fe(v,A):be(v,A);n($),I&&I(A);},onDragMove:H=>{let{over:U}=H,V=U?.id.toString()||"",A=V.startsWith("drop-locked-");P(S=>S===A?S:A);let Z=H.active.id.toString(),v=Z.startsWith("tab-header-"),$=v?Z.substring(11):Z,x=V.match(/^tab-drop-(.+)$/);if(x&&U&&(v||i==="pane")){let[,S]=x;if($!==S){let L="before",le=U.rect,se=H.activatorEvent,ee=null;if(a.current)ee=a.current.x;else {let oe=_e(se);oe&&(ee=oe.x+H.delta.x);}if(ee!==null){let oe=le.left+le.width/2;ee>oe&&(L="after");}l(oe=>oe===S?oe:S),b(oe=>oe===L?oe:L);}else l(L=>L===null?L:null),b(L=>L===null?L:null);}else l(S=>S===null?S:null),b(S=>S===null?S:null);if(!w)return;let B=M.current;if(!B){u!==null&&(f(null),z?.(null));return}let ue=H.activatorEvent,G=null,J=null;if(a.current)G=a.current.x,J=a.current.y;else {let S=_e(ue);S&&(G=S.x+H.delta.x,J=S.y+H.delta.y);}let Q=0;if(G!==null&&J!==null){let S=0,L=0;G<B.left?S=B.left-G:G>B.right&&(S=G-B.right),J<B.top?L=B.top-J:J>B.bottom&&(L=J-B.bottom),Q=Math.sqrt(S*S+L*L);}else {let S=H.active.rect.current.translated;if(S){let L=S.left+S.width/2,le=S.top+S.height/2,se=0,ee=0;L<B.left?se=B.left-L:L>B.right&&(se=L-B.right),le<B.top?ee=B.top-le:le>B.bottom&&(ee=le-B.bottom),Q=Math.sqrt(se*se+ee*ee);}}Q>y?u!==$&&(f($),z?.($)):u!==null&&(f(null),z?.(null));},onDragEnd:H=>{c(null),s(null),P(false),l(null),b(null);let{active:U,over:V}=H,A=U.id.toString(),Z=A.startsWith("tab-header-"),v=Z?A.substring(11):A,$=w&&u===v;f(null),z?.(null),M.current=null;let x=d.current||t;if(d.current=null,$){D?D(v):Z?E(v):k(v),T&&T(v,null,null);return}if(!V){n(x),T&&T(v,null,null);return}let B=V.id.toString();if(B.startsWith("drop-locked-")){n(x),T&&T(v,null,null);return}let ue=B.match(/^tab-drop-(.+)$/);if(ue){let[,p]=ue;if(Z)if(v!==p){let R="before",C=V.rect,F=H.activatorEvent,_=null;if(a.current)_=a.current.x;else {let j=_e(F);j&&(_=j.x+H.delta.x);}if(_!==null){let j=C.left+C.width/2;_>j&&(R="after");}let ae=$e(x,v,p,R);r(ae),T&&T(v,p,{type:"move",position:"center"});}else n(x),T&&T(v,null,null);else {let R="before",C=V.rect,F=H.activatorEvent,_=null;if(a.current)_=a.current.x;else {let j=_e(F);j&&(_=j.x+H.delta.x);}if(_!==null){let j=C.left+C.width/2;_>j&&(R="after");}let ae=Gt(x,v,p,R);r(ae),T&&T(v,p,{type:"move",position:"center"});}return}let G=B.match(/^drop-root-(1\/4|1\/3)-(top|bottom|left|right|start|end)$/);if(G){let[,p,R]=G,C=R;C==="start"&&(C="left"),C==="end"&&(C="right");let F=Z?fe(x,v):be(x,v),_;if(Z){let j=W(x,v)?.tabsMetadata?.[v];_={type:"pane",id:pe(),tabIds:[v],activeTabId:v,tabsMetadata:j?{[v]:j}:void 0};}else _=te(x,v)??{type:"pane",id:pe(),tabIds:[v],activeTabId:v};if(F===null)r(_);else {let ae=C==="left"||C==="right",j=C==="left"||C==="top",ve=50;p==="1/4"?ve=j?25:75:p==="1/3"&&(ve=j?100/3:200/3),r({type:"split",direction:ae?"row":"column",first:j?_:F,second:j?F:_,splitPercentage:ve});}T&&T(v,"root",{type:"split",direction:C==="left"||C==="right"?"row":"column",position:C});return}let J=B.match(/^drop-(left|right|top|bottom|center)-(.+)$/);if(!J){n(x),T&&T(v,null,null);return}let[,Q,K]=J;if(Q==="center"){if(Z){let p=te(x,K);if(p&&p.activeTabId){let R=p.activeTabId,C=$e(x,v,R,"center");r(C),T&&T(v,K,{type:"move",position:"center"});}else n(x),T&&T(v,null,null);}else n(x),T&&T(v,null,null);return}let S=Z?W(x,v):te(x,v),L=S&&S.id===K,le=S&&S.tabIds.length===1;if(v===K||L&&le){n(x),T&&T(v,null,null);return}let se=Q==="left"||Q==="right"?"row":"column",ee;if(Z){let R=W(x,v)?.tabsMetadata?.[v];ee={type:"pane",id:pe(),tabIds:[v],activeTabId:v,tabsMetadata:R?{[v]:R}:void 0};}else ee=te(x,v)??{type:"pane",id:pe(),tabIds:[v],activeTabId:v};let oe=Z?fe(x,v):be(x,v),Ze=Se(oe,K,se,Q,ee);r(Ze),T&&T(v,K,{type:"split",direction:se,position:Q});},onDragCancel:()=>{c(null),s(null),P(false),l(null),b(null),f(null),z?.(null),M.current=null;let H=d.current||t;d.current=null,n(H),H!==t&&r(H);}}}function an({persist:e,layout:t,setLayout:n}){let r=typeof e=="object"?e.enabled!==false:!!e,o=typeof e=="object"&&e.key||"zeugma-layout",[c,i]=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);}}i(true);},[r,o,n]),ge.useEffect(()=>{r&&c&&(t?localStorage.setItem(o,JSON.stringify(t)):localStorage.removeItem(o));},[r,o,t,c]);}var De=null,ln=false,re=new Set,Ce=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")&&re.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);re.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 cn=e=>{typeof requestAnimationFrame<"u"?requestAnimationFrame(e):setTimeout(e,0);};function me(){if(typeof window>"u")return document;if(De&&De.target){let t=De.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 un(){if(typeof window>"u"||ln)return;ln=true;let e=(a,d)=>{if(!a||!d)return false;try{let h=Object.getPrototypeOf(a);for(;h;){if(h===d)return !0;h=Object.getPrototypeOf(h);}}catch{}return false},t=(a,d)=>{try{Object.defineProperty(a,Symbol.hasInstance,{value:function(h){return h?e(h,a.prototype)?!0:d(h):!1},configurable:!0,writable:!0});}catch(h){console.warn("Failed to patch Symbol.hasInstance on",a,h);}};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"),i=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:i?.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,l=["innerWidth","innerHeight","pageXOffset","pageYOffset","scrollX","scrollY","screenX","screenY","outerWidth","outerHeight","devicePixelRatio"],b={};l.forEach(a=>{let d=Object.getOwnPropertyDescriptor(f,a)||Object.getOwnPropertyDescriptor(window,a);d&&d.get&&(b[a]=d.get);}),l.forEach(a=>{Object.defineProperty(window,a,{get(){let d=me();if(d&&d!==document&&d.defaultView)try{return d.defaultView[a]}catch{}let h=b[a];return h?h.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 re)try{if(d.contains(a))return !0}catch{}return false};let m=()=>{De=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 h=me();return h&&h!==document?h.createElement(a,d):y.call(document,a,d)};let D=document.addEventListener;document.addEventListener=function(a,d,h){Ce.add({target:"document",type:a,listener:d,options:h}),D.call(document,a,d,h),re.forEach(P=>{try{P.addEventListener(a,d,h);}catch{}});};let I=document.removeEventListener;document.removeEventListener=function(a,d,h){for(let P of Ce)if(P.target==="document"&&P.type===a&&P.listener===d){Ce.delete(P);break}I.call(document,a,d,h),re.forEach(P=>{try{P.removeEventListener(a,d,h);}catch{}});};let T=window.addEventListener;window.addEventListener=function(a,d,h){Ce.add({target:"window",type:a,listener:d,options:h}),T.call(window,a,d,h),re.forEach(P=>{try{P.defaultView&&P.defaultView.addEventListener(a,d,h);}catch{}});};let z=window.removeEventListener;window.removeEventListener=function(a,d,h){for(let P of Ce)if(P.target==="window"&&P.type===a&&P.listener===d){Ce.delete(P);break}z.call(window,a,d,h),re.forEach(P=>{try{P.defaultView&&P.defaultView.removeEventListener(a,d,h);}catch{}});};let E=document.getElementById;document.getElementById=function(a){let d=me();if(d&&d!==document)return d.getElementById(a);let h=E.call(document,a);if(h)return h;for(let P of re)try{let N=P.getElementById(a);if(N)return N}catch{}return null};let k=document.querySelector;document.querySelector=function(a){let d=me();if(d&&d!==document)return d.querySelector(a);let h=k.call(document,a);if(h)return h;for(let P of re)try{let N=P.querySelector(a);if(N)return N}catch{}return null};let M=document.querySelectorAll;document.querySelectorAll=function(a){let d=me();if(d&&d!==document)return d.querySelectorAll(a);let h=M.call(document,a);if(h.length>0)return h;for(let P of re)try{let N=P.querySelectorAll(a);if(N.length>0)return N}catch{}return h};}function dn(e){let{poppedOutTabIds:t,registerPopoutTarget:n,findTabById:r,dockTab:o}=e,c=ge.useRef({});ge.useEffect(()=>{let i=c.current;t.forEach(s=>{if(i[s]){try{i[s].focus();}catch{}return}un();let f=r(s)?.metadata?.title||`Tab ${s}`,l=window.open("",`zeugma-popout-${s}`,"width=800,height=600");if(!l){console.warn("Failed to open popout window. Check popup blocker."),o(s);return}i[s]=l,re.add(l.document),Ce.forEach(d=>{try{d.target==="window"?l.addEventListener(d.type,d.listener,d.options):l.document.addEventListener(d.type,d.listener,d.options);}catch{}}),co(),uo(),l.document.title=f,l.document.head.innerHTML="";try{let d=l.document.createElement("base");d.setAttribute("href",window.location.origin+"/"),l.document.head.appendChild(d);}catch{}if(Array.from(document.querySelectorAll('style, link[rel="stylesheet"]')).forEach(d=>{let h=d.cloneNode(true);if(d.tagName.toLowerCase()==="link"){let P=d.href;P&&h.setAttribute("href",P);}else if(d.tagName.toLowerCase()==="style")try{let P=d.sheet?.cssRules;if(P&&P.length>0){let N=Array.from(P).map(X=>X.cssText).join(`
|
|
9
|
+
`,document.head.appendChild(o),t.setAttribute("data-resizing","true");let c=s=>{n(s);},i=()=>{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",i),r();};document.addEventListener("pointermove",c),document.addEventListener("pointerup",i);}var vt=ge.createContext(void 0),Re=ge.createContext(void 0),Te=ge.createContext(void 0),ht=ge.createContext(void 0),ie=()=>{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},Je=()=>{let e=ge.useContext(ht);if(!e)throw new Error("useZeugmaDrag must be used within a Zeugma provider");return e};function $t(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 Bt(e){ge.useEffect(()=>(e?document.body.style.setProperty("cursor","not-allowed","important"):document.body.style.removeProperty("cursor"),()=>{document.body.style.removeProperty("cursor");}),[e]);}function _t(){let[e,t]=ge.useState({}),[n,r]=ge.useState({}),o=ge.useRef({}),c=ge.useRef(null),i=ge.useRef({}),s=ge.useRef(null),u=ge.useRef(true);ge.useEffect(()=>(u.current=true,()=>{u.current=false;}),[]);let f=ge.useCallback((y,D,I)=>{u.current&&t(T=>{if(!D){if(I&&T[y]!==I||!T[y])return T;let z={...T};return delete z[y],z}return T[y]===D?T:{...T,[y]:D}});},[]),l=ge.useCallback((y,D)=>{u.current&&r(I=>{if(!D){if(!I[y])return I;let T={...I};return delete T[y],T}return I[y]===D?I:{...I,[y]:D}});},[]),b=ge.useCallback((y,D)=>{o.current[y]=D;},[]),g=ge.useCallback(y=>{c.current=y;},[]),m=ge.useCallback((y,D)=>{i.current[y]=D;},[]);return {portalTargets:ge.useMemo(()=>({...e,...n}),[e,n]),registerPortalTarget:f,registerPopoutTarget:l,registerRenderCallback:b,renderCallbacksRef:o,registerRenderPane:g,renderPaneRef:c,registerTabHeader:m,tabHeadersRef:i,activeIdRef:s}}function Xn(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 Ft(e){return ge.useMemo(()=>Xn(e),[e])}function Vt(e){let{onDragStart:t,onDragEnd:n}=e,[r,o]=ge.useState(null),[c,i]=ge.useState(null),s=ge.useCallback(f=>{t&&t(f);},[t]),u=ge.useCallback((f,l,b)=>{n&&n(f,l,b);},[n]);return {overTabId:r,setOverTabId:o,overTabPosition:c,setOverTabPosition:i,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 i={...e.tabsMetadata};return delete i[t],{...e,tabIds:o,activeTabId:c,tabsMetadata:Object.keys(i).length>0?i: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,i=r==="left"||r==="top";return {type:"split",direction:n,first:i?c:e,second:i?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 Yn(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 Wt(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 l=u.tabsMetadata;return r&&(l={...u.tabsMetadata,[n]:r}),{...u,tabIds:f,activeTabId:n,tabsMetadata:l}}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 Yn(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 W(e,t){return e===null?null:e.type==="pane"?e.tabIds.includes(t)?e:null:e.type==="split"?W(e.first,t)??W(e.second,t):null}function qt(e,t){return te(e,t)??W(e,t)}function nt(e,t){let n=W(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 Ut(e,t){return W(e,t)?.tabsMetadata?.[t]}function Xt(e,t){let n=te(e,t);return n?.tabsMetadata?.[n.activeTabId]}function et(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),i={...r};return c===void 0?delete i[t]:i[t]=c,{...e,tabsMetadata:Object.keys(i).length>0?i:void 0}}return e}return e.type==="split"?{...e,first:et(e.first,t,n)??e.first,second:et(e.second,t,n)??e.second}:e}function tt(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:tt(e.first,t,n)??e.first,second:tt(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 Yt(e,t,n){if(e===null)return null;let o=W(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 i(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:i(s.first),second:i(s.second)}:s}return i(c)}function Gn(e,t,n){if(e===null)return null;if(t===n)return e;let r=W(e,t),o=W(e,n);if(!r||!o)return e;let c=r.id,i=o.id,s=r.tabsMetadata?.[t],u=o.tabsMetadata?.[n];function f(l){if(l.type==="pane"){let b=false,g=[...l.tabIds],m=l.activeTabId,w=l.tabsMetadata?{...l.tabsMetadata}:{};if(c===i){if(l.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 l.id===c&&(g=g.map(y=>y===t?n:y),m===t&&(m=n),delete w[t],u&&(w[n]=u),b=true),l.id===i&&(g=g.map(y=>y===n?t:y),m===n&&(m=t),delete w[n],s&&(w[t]=s),b=true);return b?{...l,tabIds:g,activeTabId:m,tabsMetadata:Object.keys(w).length>0?w:void 0}:l}return l.type==="split"?{...l,first:f(l.first),second:f(l.second)}:l}return f(e)}function $e(e,t,n,r="before"){if(e===null)return null;if(t===n)return e;if(r==="center")return Gn(e,t,n);let c=W(e,t)?.tabsMetadata?.[t],i=fe(e,t);if(i===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 l=[...u.tabIds].filter(m=>m!==t),b=l.indexOf(n);b<0&&(b=0),r==="after"&&(b+=1),l.splice(b,0,t);let g={...u.tabsMetadata};return c&&(g[t]=c),{...u,tabIds:l,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(i)}function he(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:i,splitPercentage:s,first:u,second:f}=e,b={id:`splitter-${c}-${i}`,currentNode:e,direction:i,left:i==="row"?t+r*(s/100):t,top:i==="column"?n+o*(s/100):n,width:i==="row"?0:r,height:i==="column"?0:o,parentLeft:t,parentTop:n,parentWidth:r,parentHeight:o},g={panes:[],splitters:[]},m={panes:[],splitters:[]};if(i==="row"){let w=r*(s/100);g=he(u,t,n,w,o,`${c}-L`),m=he(f,t+w,n,r-w,o,`${c}-R`);}else {let w=o*(s/100);g=he(u,t,n,r,w,`${c}-T`),m=he(f,t,n+w,r,o-w,`${c}-B`);}return {panes:[...g.panes,...m.panes],splitters:[b,...g.splitters,...m.splitters]}}function Gt(e,t,n,r="before"){if(e===null)return null;let o=te(e,t);if(!o)return e;let c=o.tabIds,i=o.activeTabId,s=o.tabsMetadata||{},u=be(e,t);if(u===null)return o;function f(l){if(l.type==="pane"){if(l.tabIds.includes(n)){let g=[...l.tabIds].filter(y=>!c.includes(y)),m=g.indexOf(n);m<0&&(m=0),r==="after"&&(m+=1),g.splice(m,0,...c);let w={...l.tabsMetadata};for(let y of c)s[y]&&(w[y]=s[y]);return {...l,tabIds:g,activeTabId:i,tabsMetadata:Object.keys(w).length>0?w:void 0}}return l}return l.type==="split"?{...l,first:f(l.first),second:f(l.second)}:l}return f(u)}function Jt(e,t,n,r){if(!((t==="tab"||t==="pane")&&n&&e.includes(n))||!r)return -1;let i=e.indexOf(n);return r==="before"?i:i+1}function Qt(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],i=t[o];if(typeof c=="object"&&c!==null&&typeof i=="object"&&i!==null){if(!Qt(c,i))return false}else if(c!==i)return false}return true}function Jn(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)||!Qt(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 Jn(e.tabsMetadata,n.tabsMetadata)}}function Qn(e){let{initialLayout:t,layout:n,onChange:r,fullscreenPaneId:o,onFullscreenChange:c,locked:i=false}=e,[s,u]=ge.useState(()=>n!==void 0?n:t??null),[f,l]=ge.useState(()=>n!==void 0?n:t??null),b=ge.useRef(n),[g,m]=ge.useState(o||null),[w,y]=ge.useState(i),[D,I]=ge.useState([]),[T,z]=ge.useState(null),[E,k]=ge.useState(null),[M,a]=ge.useState(null),d=ge.useRef(null),h=ge.useCallback(p=>{d.current=p;},[]),P=ge.useRef(s);P.current=s;let N=ge.useRef(g);N.current=g;let X=ge.useRef(r);X.current=r;let Y=ge.useRef(c);Y.current=c;let ne=ge.useCallback(p=>{m(p),Y.current?.(p);},[]);ge.useEffect(()=>{y(i);},[i]),ge.useEffect(()=>{o!==void 0&&m(o);},[o]),n!==void 0&&(Be(n,b.current??null)||(b.current=n,u(n),l(n),I(p=>{if(p.length===0)return p;let R=p.filter(C=>nt(n,C)!==null);return R.length===p.length?p:R})));let O=ge.useCallback(p=>(...R)=>{let C=P.current,F=p(C,...R);Be(C,F)||(P.current=F,u(F),l(F),I(_=>{if(_.length===0)return _;let ae=_.filter(j=>nt(F,j)!==null);return ae.length===_.length?_:ae}),X.current?.(F));},[]),H=ge.useCallback(O((p,R)=>typeof R=="function"?R(p):R),[O]),U=ge.useCallback(p=>{N.current===null&&l(R=>typeof p=="function"?p(R):p);},[]),V=ge.useCallback(p=>{m(null),Y.current?.(null),z(null),k(null),a(null),H(p),l(()=>typeof p=="function"?p(P.current):p);},[H]),A=ge.useCallback(O((p,R)=>N.current!==null?p:be(p,R)),[O]),Z=ge.useCallback(O((p,R,C,F)=>{if(N.current!==null)return p;let _=fe(p,R)??p;return Wt(_,C,R,F)}),[O]),v=ge.useCallback(O((p,R,C,F,_)=>{if(N.current!==null)return p;let ae=te(p,R)??W(p,R);if(!ae)return p;let j=te(p,_)??W(p,_)??{type:"pane",id:_,tabIds:[_],activeTabId:_},ve=be(p,j.id);return Se(ve,ae.id,C,F,j)}),[O]),$=ge.useCallback(O((p,R,C)=>N.current!==null?p:xe(p,R,C)),[O]),x=ge.useCallback(O((p,R,C)=>et(p,R,C)),[O]),B=ge.useCallback(O((p,R,C)=>{let F=te(p,R)??W(p,R);return F?tt(p,F.id,C):p}),[O]),ue=ge.useCallback(O((p,R,C)=>{let F=te(p,R)??W(p,R);return F?Ne(p,F.id,C):p}),[O]),G=ge.useCallback(O((p,R,C)=>{if(N.current!==null)return p;let F=te(p,C)??W(p,C);return F?Yt(p,R,F.id):p}),[O]),J=ge.useCallback(O((p,R,C,F)=>N.current!==null?p:$e(p,R,C,F)),[O]),Q=ge.useCallback(O((p,R)=>N.current!==null?p:fe(p,R)),[O]),K=ge.useCallback(p=>te(P.current,p),[]),S=ge.useCallback(p=>W(P.current,p),[]),L=ge.useCallback(p=>nt(P.current,p),[]),le=ge.useCallback(p=>Ut(P.current,p),[]),se=ge.useCallback(p=>Xt(P.current,p),[]),ee=ge.useCallback(p=>{N.current===null&&I(R=>R.includes(p)?R:[...R,p]);},[]),oe=ge.useCallback(p=>{N.current===null&&I(R=>R.includes(p)?R.filter(C=>C!==p):R);},[]);return {layout:s,setLayout:V,_internalSetLayout:U,renderingLayout:f,fullscreenPaneId:g,setFullscreenPaneId:ne,locked:w,setLocked:y,poppedOutTabIds:D,activeId:T,setActiveId:z,activeType:E,setActiveType:k,dismissIntentId:M,setDismissIntentId:a,containerRef:d,setContainerRef:h,removePane:A,addTab:Z,updateMetadata:x,updatePaneLock:B,selectTab:ue,mergeTab:G,moveTab:J,removeTab:Q,splitPane:v,updateSplitPercentage:$,popoutTab:ee,dockTab:oe,findPaneById:K,findPaneContainingTab:S,findTabById:L,getTabMetadata:le,getActiveTabMetadata:se}}var Kn=()=>{let e=ie(),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 ot=class extends core.PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},rt=class extends core.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};var en=e=>{let n=e.active.id.toString().startsWith("tab-header-"),o=core.pointerWithin(e);if(o.length>0)return [...o].sort((i,s)=>{let u=i.id.toString(),f=s.id.toString(),l=u.startsWith("tab-drop-"),b=f.startsWith("tab-drop-");if(l&&!b)return -1;if(!l&&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(i=>i.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 on(e){let{layout:t,_internalSetLayout:n,setLayout:r,activeId:o,setActiveId:c,activeType:i,setActiveType:s,dismissIntentId:u,setDismissIntentId:f,setOverTabId:l,setOverTabPosition:b,containerRef:g,dragActivationDistance:m,enableDragToDismiss:w,dismissThreshold:y,onRemove:D,onDragStart:I,onDragEnd:T,onDismissIntentChange:z,removeTab:E,removePane:k}=e,M=ge.useRef(null),a=$t(o),d=ge.useRef(null),[h,P]=ge.useState(false);return Bt(h),{sensors:core.useSensors(core.useSensor(ot,{activationConstraint:{distance:m}}),core.useSensor(rt,{activationConstraint:{delay:250,tolerance:5}})),collisionDetection:en,onDragStart:H=>{let U=H.active.id.toString(),V=U.startsWith("tab-header-"),A=V?U.substring(11):U;c(A),s(V?"tab":"pane"),l(null),b(null);let Z=H.activatorEvent;a.current=_e(Z),w&&g.current?M.current=g.current.getBoundingClientRect():M.current=null;let v=t;if(V){let x=W(t,A);x&&(v=Ne(t,x.id,A)||t);}d.current=v;let $=V?fe(v,A):be(v,A);n($),I&&I(A);},onDragMove:H=>{let{over:U}=H,V=U?.id.toString()||"",A=V.startsWith("drop-locked-");P(S=>S===A?S:A);let Z=H.active.id.toString(),v=Z.startsWith("tab-header-"),$=v?Z.substring(11):Z,x=V.match(/^tab-drop-(.+)$/);if(x&&U&&(v||i==="pane")){let[,S]=x;if($!==S){let L="before",le=U.rect,se=H.activatorEvent,ee=null;if(a.current)ee=a.current.x;else {let oe=_e(se);oe&&(ee=oe.x+H.delta.x);}if(ee!==null){let oe=le.left+le.width/2;ee>oe&&(L="after");}l(oe=>oe===S?oe:S),b(oe=>oe===L?oe:L);}else l(L=>L===null?L:null),b(L=>L===null?L:null);}else l(S=>S===null?S:null),b(S=>S===null?S:null);if(!w)return;let B=M.current;if(!B){u!==null&&(f(null),z?.(null));return}let ue=H.activatorEvent,G=null,J=null;if(a.current)G=a.current.x,J=a.current.y;else {let S=_e(ue);S&&(G=S.x+H.delta.x,J=S.y+H.delta.y);}let Q=0;if(G!==null&&J!==null){let S=0,L=0;G<B.left?S=B.left-G:G>B.right&&(S=G-B.right),J<B.top?L=B.top-J:J>B.bottom&&(L=J-B.bottom),Q=Math.sqrt(S*S+L*L);}else {let S=H.active.rect.current.translated;if(S){let L=S.left+S.width/2,le=S.top+S.height/2,se=0,ee=0;L<B.left?se=B.left-L:L>B.right&&(se=L-B.right),le<B.top?ee=B.top-le:le>B.bottom&&(ee=le-B.bottom),Q=Math.sqrt(se*se+ee*ee);}}Q>y?u!==$&&(f($),z?.($)):u!==null&&(f(null),z?.(null));},onDragEnd:H=>{c(null),s(null),P(false),l(null),b(null);let{active:U,over:V}=H,A=U.id.toString(),Z=A.startsWith("tab-header-"),v=Z?A.substring(11):A,$=w&&u===v;f(null),z?.(null),M.current=null;let x=d.current||t;if(d.current=null,$){D?D(v):Z?E(v):k(v),T&&T(v,null,null);return}if(!V){n(x),T&&T(v,null,null);return}let B=V.id.toString();if(B.startsWith("drop-locked-")){n(x),T&&T(v,null,null);return}let ue=B.match(/^tab-drop-(.+)$/);if(ue){let[,p]=ue;if(Z)if(v!==p){let R="before",C=V.rect,F=H.activatorEvent,_=null;if(a.current)_=a.current.x;else {let j=_e(F);j&&(_=j.x+H.delta.x);}if(_!==null){let j=C.left+C.width/2;_>j&&(R="after");}let ae=$e(x,v,p,R);r(ae),T&&T(v,p,{type:"move",position:"center"});}else n(x),T&&T(v,null,null);else {let R="before",C=V.rect,F=H.activatorEvent,_=null;if(a.current)_=a.current.x;else {let j=_e(F);j&&(_=j.x+H.delta.x);}if(_!==null){let j=C.left+C.width/2;_>j&&(R="after");}let ae=Gt(x,v,p,R);r(ae),T&&T(v,p,{type:"move",position:"center"});}return}let G=B.match(/^drop-root-(1\/4|1\/3)-(top|bottom|left|right|start|end)$/);if(G){let[,p,R]=G,C=R;C==="start"&&(C="left"),C==="end"&&(C="right");let F=Z?fe(x,v):be(x,v),_;if(Z){let j=W(x,v)?.tabsMetadata?.[v];_={type:"pane",id:pe(),tabIds:[v],activeTabId:v,tabsMetadata:j?{[v]:j}:void 0};}else _=te(x,v)??{type:"pane",id:pe(),tabIds:[v],activeTabId:v};if(F===null)r(_);else {let ae=C==="left"||C==="right",j=C==="left"||C==="top",ve=50;p==="1/4"?ve=j?25:75:p==="1/3"&&(ve=j?100/3:200/3),r({type:"split",direction:ae?"row":"column",first:j?_:F,second:j?F:_,splitPercentage:ve});}T&&T(v,"root",{type:"split",direction:C==="left"||C==="right"?"row":"column",position:C});return}let J=B.match(/^drop-(left|right|top|bottom|center)-(.+)$/);if(!J){n(x),T&&T(v,null,null);return}let[,Q,K]=J;if(Q==="center"){if(Z){let p=te(x,K);if(p&&p.activeTabId){let R=p.activeTabId,C=$e(x,v,R,"center");r(C),T&&T(v,K,{type:"move",position:"center"});}else n(x),T&&T(v,null,null);}else n(x),T&&T(v,null,null);return}let S=Z?W(x,v):te(x,v),L=S&&S.id===K,le=S&&S.tabIds.length===1;if(v===K||L&&le){n(x),T&&T(v,null,null);return}let se=Q==="left"||Q==="right"?"row":"column",ee;if(Z){let R=W(x,v)?.tabsMetadata?.[v];ee={type:"pane",id:pe(),tabIds:[v],activeTabId:v,tabsMetadata:R?{[v]:R}:void 0};}else ee=te(x,v)??{type:"pane",id:pe(),tabIds:[v],activeTabId:v};let oe=Z?fe(x,v):be(x,v),Ze=Se(oe,K,se,Q,ee);r(Ze),T&&T(v,K,{type:"split",direction:se,position:Q});},onDragCancel:()=>{c(null),s(null),P(false),l(null),b(null),f(null),z?.(null),M.current=null;let H=d.current||t;d.current=null,n(H),H!==t&&r(H);}}}function an({persist:e,layout:t,setLayout:n}){let r=typeof e=="object"?e.enabled!==false:!!e,o=typeof e=="object"&&e.key||"zeugma-layout",[c,i]=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);}}i(true);},[r,o,n]),ge.useEffect(()=>{r&&c&&(t?localStorage.setItem(o,JSON.stringify(t)):localStorage.removeItem(o));},[r,o,t,c]);}var De=null,ln=false,re=new Set,Ce=new Set,Le=null;function lo(){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")&&re.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 co(){typeof window>"u"||ke||(ke=new MutationObserver(e=>{e.forEach(t=>{if(t.type==="attributes"&&t.attributeName){let n=document.documentElement.getAttribute(t.attributeName);re.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 cn=e=>{typeof requestAnimationFrame<"u"?requestAnimationFrame(e):setTimeout(e,0);};function me(){if(typeof window>"u")return document;if(De&&De.target){let t=De.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 un(){if(typeof window>"u"||ln)return;ln=true;let e=(a,d)=>{if(!a||!d)return false;try{let h=Object.getPrototypeOf(a);for(;h;){if(h===d)return !0;h=Object.getPrototypeOf(h);}}catch{}return false},t=(a,d)=>{try{Object.defineProperty(a,Symbol.hasInstance,{value:function(h){return h?e(h,a.prototype)?!0:d(h):!1},configurable:!0,writable:!0});}catch(h){console.warn("Failed to patch Symbol.hasInstance on",a,h);}};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"),i=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:i?.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,l=["innerWidth","innerHeight","pageXOffset","pageYOffset","scrollX","scrollY","screenX","screenY","outerWidth","outerHeight","devicePixelRatio"],b={};l.forEach(a=>{let d=Object.getOwnPropertyDescriptor(f,a)||Object.getOwnPropertyDescriptor(window,a);d&&d.get&&(b[a]=d.get);}),l.forEach(a=>{Object.defineProperty(window,a,{get(){let d=me();if(d&&d!==document&&d.defaultView)try{return d.defaultView[a]}catch{}let h=b[a];return h?h.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 re)try{if(d.contains(a))return !0}catch{}return false};let m=()=>{De=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 h=me();return h&&h!==document?h.createElement(a,d):y.call(document,a,d)};let D=document.addEventListener;document.addEventListener=function(a,d,h){Ce.add({target:"document",type:a,listener:d,options:h}),D.call(document,a,d,h),re.forEach(P=>{try{P.addEventListener(a,d,h);}catch{}});};let I=document.removeEventListener;document.removeEventListener=function(a,d,h){for(let P of Ce)if(P.target==="document"&&P.type===a&&P.listener===d){Ce.delete(P);break}I.call(document,a,d,h),re.forEach(P=>{try{P.removeEventListener(a,d,h);}catch{}});};let T=window.addEventListener;window.addEventListener=function(a,d,h){Ce.add({target:"window",type:a,listener:d,options:h}),T.call(window,a,d,h),re.forEach(P=>{try{P.defaultView&&P.defaultView.addEventListener(a,d,h);}catch{}});};let z=window.removeEventListener;window.removeEventListener=function(a,d,h){for(let P of Ce)if(P.target==="window"&&P.type===a&&P.listener===d){Ce.delete(P);break}z.call(window,a,d,h),re.forEach(P=>{try{P.defaultView&&P.defaultView.removeEventListener(a,d,h);}catch{}});};let E=document.getElementById;document.getElementById=function(a){let d=me();if(d&&d!==document)return d.getElementById(a);let h=E.call(document,a);if(h)return h;for(let P of re)try{let N=P.getElementById(a);if(N)return N}catch{}return null};let k=document.querySelector;document.querySelector=function(a){let d=me();if(d&&d!==document)return d.querySelector(a);let h=k.call(document,a);if(h)return h;for(let P of re)try{let N=P.querySelector(a);if(N)return N}catch{}return null};let M=document.querySelectorAll;document.querySelectorAll=function(a){let d=me();if(d&&d!==document)return d.querySelectorAll(a);let h=M.call(document,a);if(h.length>0)return h;for(let P of re)try{let N=P.querySelectorAll(a);if(N.length>0)return N}catch{}return h};}function dn(e){let{poppedOutTabIds:t,registerPopoutTarget:n,findTabById:r,dockTab:o}=e,c=ge.useRef({});ge.useEffect(()=>{let i=c.current;t.forEach(s=>{if(i[s]){try{i[s].focus();}catch{}return}un();let f=r(s)?.metadata?.title||`Tab ${s}`,l=window.open("",`zeugma-popout-${s}`,"width=800,height=600");if(!l){console.warn("Failed to open popout window. Check popup blocker."),o(s);return}i[s]=l,re.add(l.document),Ce.forEach(d=>{try{d.target==="window"?l.addEventListener(d.type,d.listener,d.options):l.document.addEventListener(d.type,d.listener,d.options);}catch{}}),lo(),co(),l.document.title=f,l.document.head.innerHTML="";try{let d=l.document.createElement("base");d.setAttribute("href",window.location.origin+"/"),l.document.head.appendChild(d);}catch{}if(Array.from(document.querySelectorAll('style, link[rel="stylesheet"]')).forEach(d=>{let h=d.cloneNode(true);if(d.tagName.toLowerCase()==="link"){let P=d.href;P&&h.setAttribute("href",P);}else if(d.tagName.toLowerCase()==="style")try{let P=d.sheet?.cssRules;if(P&&P.length>0){let N=Array.from(P).map(X=>X.cssText).join(`
|
|
10
10
|
`);h.textContent=N;}}catch{}l.document.head.appendChild(h);}),typeof document.adoptedStyleSheets<"u"&&typeof l.document.adoptedStyleSheets<"u")try{let d=Array.from(document.adoptedStyleSheets).map(h=>{try{let P=new l.CSSStyleSheet,N=Array.from(h.cssRules).map(X=>X.cssText).join(`
|
|
11
|
-
`);return P.replaceSync(N),P}catch{return null}}).filter(h=>h!==null);l.document.adoptedStyleSheets=d;}catch(d){console.warn("Failed to copy adoptedStyleSheets:",d);}l.document.documentElement.className=document.documentElement.className,l.document.body.className=document.body.className,Array.from(document.documentElement.attributes).forEach(d=>{l.document.documentElement.setAttribute(d.name,d.value);}),l.document.body.style.margin="0",l.document.body.style.padding="0",l.document.body.style.height="100vh",l.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),w=window.getComputedStyle(document.body),y=w.backgroundColor,I=!y||y==="transparent"||y==="rgba(0, 0, 0, 0)"?m.backgroundColor:y,T=g&&g!=="transparent"&&g!=="rgba(0, 0, 0, 0)"?g:I&&I!=="transparent"&&I!=="rgba(0, 0, 0, 0)"?I:"#181b1f";document.documentElement.getAttribute("data-theme")||(l.document.documentElement.style.backgroundColor=T,l.document.body.style.backgroundColor=T),l.document.body.style.color=w.color||m.color,l.document.body.style.fontFamily=w.fontFamily||m.fontFamily;let E=l.document.createElement("div");E.id=`zeugma-popout-container-${s}`,E.className="grafana-panel h-full w-full overflow-hidden",E.style.width="100%",E.style.height="100%",E.style.border="none",l.document.body.appendChild(E),n?.(s,E);let k=["pointerdown","mousedown","click","keydown","focus","touchstart"],M=d=>{De=d,globalThis.__zeugmaActivePopoutDocument=l.document,setTimeout(()=>{De===d&&(De=null,globalThis.__zeugmaActivePopoutDocument=null);},0);};k.forEach(d=>{l.addEventListener(d,M,true);});let a=()=>{re.delete(l.document),re.size===0&&(yt(),Tt()),o(s);};l.addEventListener("beforeunload",a),l.__zeugmaCleanup=()=>{k.forEach(d=>{l.removeEventListener(d,M,true);}),l.removeEventListener("beforeunload",a);};}),Object.keys(i).forEach(s=>{if(!t.includes(s)){let u=i[s];if(delete i[s],n?.(s,null),u){re.delete(u.document),re.size===0&&(yt(),Tt());try{let f=u;f.__zeugmaCleanup&&f.__zeugmaCleanup(),cn(()=>{try{f.close();}catch{}});}catch{}}}});},[t,n,r,o]),ge.useEffect(()=>()=>{let i=c.current;Object.keys(i).forEach(s=>{let u=i[s];if(u){re.delete(u.document);try{let f=u;f.__zeugmaCleanup&&f.__zeugmaCleanup(),cn(()=>{try{f.close();}catch{}});}catch{}}}),re.size===0&&(yt(),Tt());},[]);}typeof window<"u"&&un();var pn=({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,i)=>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;}},i),ge__default.default.useLayoutEffect=(c,i)=>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;}},i),o&&(ge__default.default.useInsertionEffect=(c,i)=>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;}},i)),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);}},mn=ge__default.default.memo(({tabDetails:e,target:t,renderWidget:n})=>{let{id:r}=e,[o,c]=ge.useState(false),i=ge.useRef(null);if(ge.useEffect(()=>{c(true);},[]),ge.useEffect(()=>{if(!o||!i.current)return;let g=i.current;if(t)t.ownerDocument.adoptNode(g),t.appendChild(g);else {let m=document.getElementById("zeugma-hidden-portal-container");m||(m=document.createElement("div"),m.id="zeugma-hidden-portal-container",m.style.display="none",document.body.appendChild(m)),document.adoptNode(g),m.appendChild(g);}},[t,o]),ge.useEffect(()=>()=>{i.current&&i.current.remove();},[]),!o)return null;let s=t?t.ownerDocument:document;i.current&&i.current.ownerDocument!==s&&s.adoptNode(i.current),i.current||(i.current=s.createElement("div"),i.current.className=`zeugma-portal-wrapper-${r}`,i.current.style.width="100%",i.current.style.height="100%");let u=i.current;if(!u||!n)return null;let f=!!(t&&t.ownerDocument&&t.ownerDocument!==document),l=e.remountOnPopout?f?"-popped":"-docked":"",b=jsxRuntime.jsx(ge__default.default.Fragment,{children:n(e)},`${r}${l}`);return reactDom.createPortal(jsxRuntime.jsx(ho,{popoutDoc:f&&t?t.ownerDocument:document,children:b}),u)},(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 gn=({activeId:e,activeType:t,dismissIntentId:n,renderDragOverlay:r,renderPaneRef:o,renderPane:c,tabHeadersRef:i,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=i.current[e];if(f){let l=s.tab?typeof s.tab=="function"?s.tab(e):s.tab:"";return jsxRuntime.jsx("div",{className:`${s.tabDragPreview||""} ${l}`.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:i,currentNode:s,onLayoutChange:u,onResizeStart:f,onResizeEnd:l,parentLeft:b,parentTop:g,parentWidth:m,parentHeight:w}){let{onResizeStart:y,onResize:D,onResizeEnd:I,minSplitPercentage:T=5,maxSplitPercentage:z=95,locked:E=false}=ie();return ge.useCallback(k=>{if(E)return;k.preventDefault();let M=e.current;if(!M)return;f&&f(),y&&y(s);let a=M.getBoundingClientRect(),d=k.clientX,h=k.clientY,P=r,N=k.currentTarget,X=a.left+a.width*(b/100),Y=a.top+a.height*(g/100),ne=a.width*(m/100),O=a.height*(w/100),U=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(A=>A!==N&&A.getAttribute("data-direction")===n).map(A=>{let Z=A.getBoundingClientRect();return t?Z.left+Z.width/2:Z.top+Z.height/2}),V=P;Zt({cursor:t?"col-resize":"row-resize",resizerEl:N,onMove:A=>{let Z=t?(A.clientX-d)/ne*100:(A.clientY-h)/O*100,v=P+Z,$=t?X+(ne-o)*(v/100)+o/2:Y+(O-o)*(v/100)+o/2,x=1/0,B=null;for(let Q of U){let K=Math.abs($-Q);K<c&&K<x&&(x=K,B=Q);}let ue=v;B!==null&&(ue=t?(B-o/2-X)/(ne-o)*100:(B-o/2-Y)/(O-o)*100);let G=Math.max(T,Math.min(z,ue));V=G;let J=xe(i,s,G);if(J){let{panes:Q,splitters:K}=he(J),S=e.current;if(S){for(let L of Q)S.style.setProperty(`--pane-left-${L.paneId}`,`${L.left}%`),S.style.setProperty(`--pane-top-${L.paneId}`,`${L.top}%`),S.style.setProperty(`--pane-width-${L.paneId}`,`${L.width}%`),S.style.setProperty(`--pane-height-${L.paneId}`,`${L.height}%`);for(let L of K)S.style.setProperty(`--splitter-pos-${L.id}`,`${L.direction==="row"?L.left:L.top}%`);}}D&&D(s,G);},onEnd:()=>{let A=xe(i,s,V),Z=e.current;if(Z){let{panes:v,splitters:$}=he(A);for(let x of v)Z.style.removeProperty(`--pane-left-${x.paneId}`),Z.style.removeProperty(`--pane-top-${x.paneId}`),Z.style.removeProperty(`--pane-width-${x.paneId}`),Z.style.removeProperty(`--pane-height-${x.paneId}`);for(let x of $)Z.style.removeProperty(`--splitter-pos-${x.id}`);}u(A),l&&l(),I&&I(s,V);}});},[e,t,n,r,o,c,i,s,u,f,l,y,D,I,T,z,b,g,m,w])}var bn=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:r})=>{let{renderingLayout:o,setLayout:c,classNames:i,locked:s}=ie(),[u,f]=ge.useState(false),{currentNode:l,direction:b,left:g,top:m,width:w,height:y,parentLeft:D,parentTop:I,parentWidth:T,parentHeight:z}=e,E=b==="row",k=Rt({containerRef:r,isRow:E,direction:b,splitPercentage:l.splitPercentage,resizerSize:t,snapThreshold:n,layout:o,currentNode:l,onLayoutChange:c,onResizeStart:()=>f(true),onResizeEnd:()=>f(false),parentLeft:D,parentTop:I,parentWidth:T,parentHeight:z}),M=E?{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(${w}% - ${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:i.resizer||"","data-direction":b,"data-resizing":u||void 0,style:M,onPointerDown:k,role:"separator","aria-valuenow":l.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},vn=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:i,setContainerRef:s,fullscreenPaneId:u,snapThreshold:f,locked:l,classNames:b,resizerSize:g}=ie(),m=r!==void 0?r:f??8,w=n!==void 0?n:g??4,y=t!==void 0?t:o,D=ge.useRef(null),{panes:I,splitters:T}=ge.useMemo(()=>y?he(y):{panes:[],splitters:[]},[y]);if(!y&&t!==void 0)return null;let z=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[I.map(E=>{let k=u===E.paneId;return jsxRuntime.jsx("div",{style:{position:"absolute",left:k?"0%":`var(--pane-left-${E.paneId}, ${E.left}%)`,top:k?"0%":`var(--pane-top-${E.paneId}, ${E.top}%)`,width:k?"100%":`var(--pane-width-${E.paneId}, ${E.width}%)`,height:k?"100%":`var(--pane-height-${E.paneId}, ${E.height}%)`,overflow:"hidden",zIndex:k?20:1,display:u&&!k?"none":"block",padding:k?"0px":`${w/2}px`,boxSizing:"border-box"},children:jsxRuntime.jsx(vn,{paneId:E.paneId,renderPane:e})},E.paneId)}),!u&&T.map(E=>jsxRuntime.jsx(bn,{splitter:E,resizerSize:w,snapThreshold:m,containerRef:D},E.id))]});if(t===void 0){let E=c!==null&&c===i,k=a=>{s(a),D.current=a;},M=`${b.dashboard||""} ${E&&b.dashboardDismissActive||""} ${l&&b.dashboardLocked||""}`.trim();return jsxRuntime.jsxs("div",{ref:k,className:M,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[z(),c!==null&&!l&&jsxRuntime.jsx(Tn,{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:i,dragActivationDistance:s=8,snapThreshold:u=8,minSplitPercentage:f=5,maxSplitPercentage:l=95,enableDragToDismiss:b=false,dismissThreshold:g=60,onRemove:m,onDragStart:w,onDragEnd:y,onResizeStart:D,onResize:I,onResizeEnd:T,onDismissIntentChange:z,persist:E=false}=e,k=t,{layout:M,setLayout:a,_internalSetLayout:d,renderingLayout:h,fullscreenPaneId:P,setFullscreenPaneId:N,locked:X,setLocked:Y,findPaneById:ne,findPaneContainingTab:O,findTabById:H,getTabMetadata:U,getActiveTabMetadata:V,activeId:A,setActiveId:Z,activeType:v,setActiveType:$,dismissIntentId:x,setDismissIntentId:B,containerRef:ue,setContainerRef:G,removePane:J,addTab:Q,updateMetadata:K,updatePaneLock:S,selectTab:L,mergeTab:le,removeTab:se,splitPane:ee,updateSplitPercentage:oe,moveTab:Ze,poppedOutTabIds:p=[],popoutTab:R,dockTab:C}=k;an({persist:E,layout:M,setLayout:a});let{portalTargets:F,registerPortalTarget:_,registerPopoutTarget:ae,registerRenderCallback:j,renderCallbacksRef:ve,registerRenderPane:pt,renderPaneRef:ft,registerTabHeader:Lt,tabHeadersRef:mt,activeIdRef:Xe}=_t();dn({poppedOutTabIds:p,registerPopoutTarget:ae,findTabById:H,dockTab:C});let kt=ge.useCallback(de=>p.includes(de),[p]),{overTabId:Mt,setOverTabId:Hn,overTabPosition:Ot,setOverTabPosition:$n,handleDragStartInternal:Bn,handleDragEndInternal:_n}=Vt({onDragStart:w,onDragEnd:y}),Fn=on({layout:M,_internalSetLayout:d,setLayout:a,activeId:A,setActiveId:Z,activeType:v,setActiveType:$,dismissIntentId:x,setDismissIntentId:B,setOverTabId:Hn,setOverTabPosition:$n,containerRef:ue,dragActivationDistance:s,enableDragToDismiss:b,dismissThreshold:g,onRemove:m,onDragStart:Bn,onDragEnd:_n,onDismissIntentChange:z,removeTab:se,removePane:J}),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]),At=ge.useCallback((de,Ye)=>{T&&T(de,Ye);},[T]),Vn=ge.useMemo(()=>({layout:M,renderingLayout:h,setLayout:a,activeId:A,activeType:v,dismissIntentId:x,setContainerRef:G,fullscreenPaneId:P,classNames:gt,onRemove:m,onFullscreenChange:N,snapThreshold:u,onResizeStart:D,onResize:I,onResizeEnd:At,minSplitPercentage:f,maxSplitPercentage:l,locked:X,setLocked:Y,findPaneById:ne,findPaneContainingTab:O,findTabById:H,getTabMetadata:U,getActiveTabMetadata:V,renderPane:c,resizerSize:i,poppedOutTabIds:p,isTabPoppedOut:kt}),[M,h,A,v,x,G,P,gt,m,N,u,D,I,f,l,a,At,X,Y,ne,O,H,U,V,c,i,p,kt]),jn=ge.useMemo(()=>({overTabId:Mt,overTabPosition:Ot}),[Mt,Ot]),Wn=ge.useMemo(()=>({removePane:J,addTab:Q,updateMetadata:K,updatePaneLock:S,selectTab:L,mergeTab:le,removeTab:se,setFullscreenPaneId:N,setLocked:Y,splitPane:ee,updateSplitPercentage:oe,moveTab:Ze,popoutTab:R,dockTab:C}),[J,Q,K,S,L,le,se,N,Y,ee,oe,Ze,R,C]),qn=Ft(M),Un=ge.useMemo(()=>({registerPortalTarget:_,registerRenderCallback:j,renderCallbacksRef:ve,registerRenderPane:pt,renderPaneRef:ft,registerTabHeader:Lt,tabHeadersRef:mt,activeIdRef:Xe,registerPopoutTarget:ae}),[_,j,ve,pt,ft,Lt,mt,Xe,ae]);return Xe&&(Xe.current=A),jsxRuntime.jsx(Re.Provider,{value:Wn,children:jsxRuntime.jsx(vt.Provider,{value:Vn,children:jsxRuntime.jsx(ht.Provider,{value:jn,children:jsxRuntime.jsxs(Te.Provider,{value:Un,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",...Fn,children:n}),A&&v&&jsxRuntime.jsx(pn,{activeId:A,render:de=>jsxRuntime.jsx("div",{style:{transition:"transform 150ms cubic-bezier(0.2, 0, 0, 1)",transform:de===x?"scale(0.8)":"scale(1)",transformOrigin:"top left"},children:jsxRuntime.jsx(gn,{activeId:de,activeType:v,dismissIntentId:x,renderDragOverlay:r,renderPaneRef:ft,renderPane:c,tabHeadersRef:mt,classNames:gt})}),className:`${o.dragOverlay||""} ${A===x&&o.dismissPreview||""}`.trim()}),jsxRuntime.jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:qn.map(de=>{let Ye=F[de],zt=H(de);return zt?jsxRuntime.jsx(mn,{tabDetails:zt,target:Ye||null,renderWidget:ve.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}),i={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:i})]})},Tn=({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 it=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"}},lt=({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 wn=({children:e,className:t,style:n})=>{let r=ge.useContext(it);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 We=({id:e,locked:t=false,children:n,className:r,style:o})=>{let{locked:c,classNames:i={},fullscreenPaneId:s,poppedOutTabIds:u=[]}=ie(),f=ge.useContext(Re),{overTabId:l}=Je(),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(Ct),w=t||c||(m?.locked??false)||s!==null,{attributes:y,listeners:D,setNodeRef:I,isDragging:T}=core.useDraggable({id:`tab-header-${e}`,disabled:w}),{setNodeRef:z,isOver:E}=core.useDroppable({id:`tab-drop-${e}`,disabled:w}),k=U=>{I(U),z(U);},M=E&&l===e,a=m?.tabIds||[],d=a.indexOf(e),h=m?.activeTabId,N=d>0&&e!==h&&a[d-1]!==h?jsxRuntime.jsx("div",{className:i.tabSeparator}):null,X=m?m.activeTabId===e:false,Y=m?.tabsMetadata?.[e],ne=ge.useCallback(()=>{m?.selectTab(e);},[m,e]),O=ge.useCallback(()=>{m?.removeTab(e);},[m,e]),H=ge.useMemo(()=>({tabId:e,isActive:X,isDragging:T,isOver:M,metadata:Y,locked:w,selectTab:ne,removeTab:O,isPoppedOut:g,popoutTab:()=>f?.popoutTab(e),dockTab:()=>f?.dockTab(e)}),[e,X,T,M,Y,w,ne,O,g,f]);return jsxRuntime.jsx(Jo.Provider,{value:H,children:jsxRuntime.jsxs("div",{ref:k,id:`tab-header-${e}`,className:r,style:{display:"inline-flex",position:"relative",cursor:w?"default":"grab",...o},...w?{}:D,...w?{}:y,children:[N,n({isDragging:T,isOver:M})]})})};var Ct=ge.createContext(void 0);var En=(e,t)=>typeof e=="function"?e(t):e,Dt=({tabIds:e,activeTabId:t,locked:n,tabsMetadata:r,selectTab:o,removeTab:c,renderTab:i,classNames:s,styles:u})=>{let f=ge.useContext(ct),l=e??f?.tabIds??[],b=t??f?.activeTabId??"",g=n??f?.locked??false,m=r??f?.tabsMetadata,w=o??f?.selectTab??(()=>{}),y=c??f?.removeTab??(()=>{}),{classNames:D={},activeType:I,poppedOutTabIds:T=[]}=ie(),z=ge.useContext(Re),{overTabId:E,overTabPosition:k}=Je(),M=ge.useMemo(()=>({tabIds:l,activeTabId:b,locked:g,tabsMetadata:m,selectTab:w,removeTab:y}),[l,b,g,m,w,y]),a=Jt(l,I,E,k);return jsxRuntime.jsx(Ct.Provider,{value:M,children:jsxRuntime.jsxs("div",{className:s?.container,style:{display:"flex",alignItems:"center",height:"100%",...u?.container},children:[l.map((d,h)=>{let P=m?.[d],N=En(s?.tab,d),X=En(u?.tab,d),Y=h===a;return jsxRuntime.jsxs(ge__default.default.Fragment,{children:[Y&&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:h===0?"none":"translateX(-50%)"}})}),jsxRuntime.jsx(We,{id:d,locked:g,className:N,style:X,children:({isDragging:ne,isOver:O})=>i({id:d,paneId:f?.id??"",isActive:d===b,index:h,isDragging:ne,isOver:O,metadata:P,onSelect:()=>w(d),onRemove:()=>y(d),isPoppedOut:T.includes(d),popout:()=>z?.popoutTab(d),dock:()=>z?.dockTab(d)})})]},d)}),a===l.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%)"}})})]})})};Dt.Tab=We;var Nn=({className:e,style:t,children:n})=>jsxRuntime.jsx("div",{className:e,style:t,children:n});var ct=ge.createContext(void 0),Ln=()=>{let e=ge.useContext(ct);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}=Ln(),{classNames:o,isTabPoppedOut:c}=ie(),{dockTab:i}=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:l}=u,b=ge.useMemo(()=>typeof e=="function"?e:()=>e,[e]);l(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:()=>i(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:i,activeType:s,classNames:u,fullscreenPaneId:f,onFullscreenChange:l,locked:b,poppedOutTabIds:g=[]}=ie(),{removePane:m,updateMetadata:w,selectTab:y,removeTab:D,popoutTab:I,dockTab:T}=He(),z=ge.useMemo(()=>{if(s==="tab"&&e===i){let B=W(o,e)?.tabsMetadata?.[e];return {type:"pane",id:e,tabIds:[e],activeTabId:e,tabsMetadata:B?{[e]:B}:void 0}}return qt(e===i?o:c,e)},[o,c,e,i,s]),E=z?.id??e,k=z?.tabIds??[e],M=z?.activeTabId??e,a=z?.tabsMetadata,d=a?.[e],h=z?.locked??false,P=r||h,N=b||P||f!==null,X=b||P||f!==null,Y=i!==null&&i!==e&&(!k.includes(i)||k.length>1)&&!X,{attributes:ne,listeners:O,setNodeRef:H}=core.useDraggable({id:e,disabled:N}),U=i!==null&&k.includes(i),V=f===e,A=ge.useMemo(()=>({isDragging:U,isFullscreen:V,toggleFullscreen:()=>l?.(V?null:e),remove:()=>{V&&l?.(null),m(E);},metadata:d,updateMetadata:$=>{w(e,$);},locked:N,tabIds:k,activeTabId:M,selectTab:$=>y(E,$),removeTab:$=>{V&&$===M&&l?.(null),D($);},tabsMetadata:a,updateTabMetadata:($,x)=>{w($,x);},isActiveTabPoppedOut:g.includes(M),popoutTab:$=>I($||M),dockTab:$=>T($||M)}),[U,V,l,e,D,d,w,N,k,M,y,E,a,g,I,T]),Z=ge.useMemo(()=>N?{disabled:true}:{...O,...ne},[O,ne,N]),v=`${u.pane||""} ${P&&u.paneLocked||""}`.trim();return jsxRuntime.jsx(ct.Provider,{value:{id:e,...A},children:jsxRuntime.jsx(it.Provider,{value:Z,children:jsxRuntime.jsxs("div",{ref:H,id:e,className:v,style:{position:"relative",width:"100%",height:"100%",...n},children:[t,Y&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:[["top","bottom","left","right"].map($=>jsxRuntime.jsx(lt,{id:`drop-${$}-${e}`,position:$,activeClassName:u.dropPreview},$)),s==="tab"&&jsxRuntime.jsx(lt,{id:`drop-center-${e}`,position:"center",activeClassName:u.swapPreview??u.dropPreview})]}),i!==null&&i!==e&&X&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsxRuntime.jsx(lt,{id:`drop-locked-${e}`,position:"full",activeClassName:u.lockedPreview||""})})]})})})};Oe.Content=ir;Oe.DragHandle=wn;Oe.Tabs=Dt;Oe.Tab=We;Oe.Controls=Nn;var dt=new Map;function qe(e){let t=dt.get(e);return t||(t={mounts:0,renders:0,listeners:new Set},dt.set(e,t)),t}function kn(e,t){let n=qe(e);return n.listeners.add(t),()=>{n.listeners.delete(t);}}function St(e){let t=dt.get(e);t&&t.listeners.forEach(n=>n());}function Mn(e){let t=dt.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:i=false}=r,s=ge.useRef(0),u=ge.useRef(false),[,f]=ge.useState(0);if(i||(s.current+=1),ge.useEffect(()=>{if(i)return;let g=kn(o,()=>{f(w=>w+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,i,c]),!i){let g=qe(o);g.renders=Math.max(g.renders,s.current);}let l=ge.useCallback(()=>{s.current=0,Mn(o);},[o]);return i?{mounts:0,renders:0,reset:l}:{mounts:qe(o).mounts,renders:s.current,reset:l}}var An={"top-right":"top-2 right-2","top-left":"top-2 left-2","bottom-right":"bottom-2 right-2","bottom-left":"bottom-2 left-2"};function zn({id:e,position:t="top-right",className:n="",style:r,logToConsole:o=false,disabled:c=false}){let{mounts:i,renders:s}=Ae(e,{logToConsole:o,disabled:c});if(c)return null;let u=An[t]||An["top-right"];return jsxRuntime.jsxs("div",{className:`absolute ${u} z-50 pointer-events-none flex items-center gap-2 rounded px-2 py-1 text-[11px] font-mono bg-zinc-900/90 text-zinc-200 border border-zinc-700/80 shadow-md backdrop-blur-xs select-none ${n}`,style:r,children:[jsxRuntime.jsxs("span",{children:["M: ",jsxRuntime.jsx("strong",{className:"text-emerald-400 font-semibold",children:i})]}),jsxRuntime.jsx("span",{className:"opacity-30",children:"|"}),jsxRuntime.jsxs("span",{children:["R: ",jsxRuntime.jsx("strong",{className:"text-indigo-400 font-semibold",children:s})]})]})}function Zn({id:e,label:t,children:n,className:r="",footerClassName:o="",style:c,logToConsole:i=false,disabled:s=false}){let u=t||e||"widget",{mounts:f,renders:l}=Ae(e,{logToConsole:i,disabled:s});return s?jsxRuntime.jsx(jsxRuntime.Fragment,{children:n}):jsxRuntime.jsxs("div",{className:`h-full w-full flex flex-col overflow-hidden min-h-0 ${r}`,style:c,children:[n&&jsxRuntime.jsx("div",{className:"flex-1 overflow-hidden relative min-h-0",children:n}),jsxRuntime.jsxs("div",{className:`bg-zinc-900/90 border-t border-zinc-800 px-3 py-1.5 flex items-center justify-between text-[11px] text-zinc-400 font-mono shrink-0 select-none ${o}`,children:[jsxRuntime.jsx("span",{className:"truncate max-w-[140px] text-zinc-300 font-semibold",children:u}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsxs("span",{children:["Mounts: ",jsxRuntime.jsx("strong",{className:"text-emerald-400 font-semibold",children:f})]}),jsxRuntime.jsx("span",{className:"opacity-20",children:"|"}),jsxRuntime.jsxs("span",{children:["Renders: ",jsxRuntime.jsx("strong",{className:"text-indigo-400 font-semibold",children:l})]})]})]})]})}exports.Pane=Oe;exports.PaneTree=wt;exports.RenderCounterBadge=zn;exports.RenderCounterFooter=Zn;exports.Zeugma=Io;exports.usePaneContext=Ln;exports.useRenderCounter=Ae;exports.useResizer=Rt;exports.useZeugma=Kn;exports.useZeugmaContext=eo;//# sourceMappingURL=index.cjs.map
|
|
11
|
+
`);return P.replaceSync(N),P}catch{return null}}).filter(h=>h!==null);l.document.adoptedStyleSheets=d;}catch(d){console.warn("Failed to copy adoptedStyleSheets:",d);}l.document.documentElement.className=document.documentElement.className,l.document.body.className=document.body.className,Array.from(document.documentElement.attributes).forEach(d=>{l.document.documentElement.setAttribute(d.name,d.value);}),l.document.body.style.margin="0",l.document.body.style.padding="0",l.document.body.style.height="100vh",l.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),w=window.getComputedStyle(document.body),y=w.backgroundColor,I=!y||y==="transparent"||y==="rgba(0, 0, 0, 0)"?m.backgroundColor:y,T=g&&g!=="transparent"&&g!=="rgba(0, 0, 0, 0)"?g:I&&I!=="transparent"&&I!=="rgba(0, 0, 0, 0)"?I:"#181b1f";document.documentElement.getAttribute("data-theme")||(l.document.documentElement.style.backgroundColor=T,l.document.body.style.backgroundColor=T),l.document.body.style.color=w.color||m.color,l.document.body.style.fontFamily=w.fontFamily||m.fontFamily;let E=l.document.createElement("div");E.id=`zeugma-popout-container-${s}`,E.className="grafana-panel h-full w-full overflow-hidden",E.style.width="100%",E.style.height="100%",E.style.border="none",l.document.body.appendChild(E),n?.(s,E);let k=["pointerdown","mousedown","click","keydown","focus","touchstart"],M=d=>{De=d,globalThis.__zeugmaActivePopoutDocument=l.document,setTimeout(()=>{De===d&&(De=null,globalThis.__zeugmaActivePopoutDocument=null);},0);};k.forEach(d=>{l.addEventListener(d,M,true);});let a=()=>{re.delete(l.document),re.size===0&&(yt(),Tt()),o(s);};l.addEventListener("beforeunload",a),l.__zeugmaCleanup=()=>{k.forEach(d=>{l.removeEventListener(d,M,true);}),l.removeEventListener("beforeunload",a);};}),Object.keys(i).forEach(s=>{if(!t.includes(s)){let u=i[s];if(delete i[s],n?.(s,null),u){re.delete(u.document),re.size===0&&(yt(),Tt());try{let f=u;f.__zeugmaCleanup&&f.__zeugmaCleanup(),cn(()=>{try{f.close();}catch{}});}catch{}}}});},[t,n,r,o]),ge.useEffect(()=>()=>{let i=c.current;Object.keys(i).forEach(s=>{let u=i[s];if(u){re.delete(u.document);try{let f=u;f.__zeugmaCleanup&&f.__zeugmaCleanup(),cn(()=>{try{f.close();}catch{}});}catch{}}}),re.size===0&&(yt(),Tt());},[]);}typeof window<"u"&&un();var pn=({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 vo=({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,i)=>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;}},i),ge__default.default.useLayoutEffect=(c,i)=>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;}},i),o&&(ge__default.default.useInsertionEffect=(c,i)=>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;}},i)),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);}},mn=ge__default.default.memo(({tabDetails:e,target:t,renderWidget:n})=>{let{id:r}=e,[o,c]=ge.useState(false),i=ge.useRef(null);if(ge.useEffect(()=>{c(true);},[]),ge.useEffect(()=>{if(!o||!i.current)return;let g=i.current;if(t)t.ownerDocument.adoptNode(g),t.appendChild(g);else {let m=document.getElementById("zeugma-hidden-portal-container");m||(m=document.createElement("div"),m.id="zeugma-hidden-portal-container",m.style.display="none",document.body.appendChild(m)),document.adoptNode(g),m.appendChild(g);}},[t,o]),ge.useEffect(()=>()=>{i.current&&i.current.remove();},[]),!o)return null;let s=t?t.ownerDocument:document;i.current&&i.current.ownerDocument!==s&&s.adoptNode(i.current),i.current||(i.current=s.createElement("div"),i.current.className=`zeugma-portal-wrapper-${r}`,i.current.style.width="100%",i.current.style.height="100%");let u=i.current;if(!u||!n)return null;let f=!!(t&&t.ownerDocument&&t.ownerDocument!==document),l=e.remountOnPopout?f?"-popped":"-docked":"",b=jsxRuntime.jsx(ge__default.default.Fragment,{children:n(e)},`${r}${l}`);return reactDom.createPortal(jsxRuntime.jsx(vo,{popoutDoc:f&&t?t.ownerDocument:document,children:b}),u)},(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 gn=({activeId:e,activeType:t,dismissIntentId:n,renderDragOverlay:r,renderPaneRef:o,renderPane:c,tabHeadersRef:i,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=i.current[e];if(f){let l=s.tab?typeof s.tab=="function"?s.tab(e):s.tab:"";return jsxRuntime.jsx("div",{className:`${s.tabDragPreview||""} ${l}`.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:i,currentNode:s,onLayoutChange:u,onResizeStart:f,onResizeEnd:l,parentLeft:b,parentTop:g,parentWidth:m,parentHeight:w}){let{onResizeStart:y,onResize:D,onResizeEnd:I,minSplitPercentage:T=5,maxSplitPercentage:z=95,locked:E=false}=ie();return ge.useCallback(k=>{if(E)return;k.preventDefault();let M=e.current;if(!M)return;f&&f(),y&&y(s);let a=M.getBoundingClientRect(),d=k.clientX,h=k.clientY,P=r,N=k.currentTarget,X=a.left+a.width*(b/100),Y=a.top+a.height*(g/100),ne=a.width*(m/100),O=a.height*(w/100),U=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(A=>A!==N&&A.getAttribute("data-direction")===n).map(A=>{let Z=A.getBoundingClientRect();return t?Z.left+Z.width/2:Z.top+Z.height/2}),V=P;Zt({cursor:t?"col-resize":"row-resize",resizerEl:N,onMove:A=>{let Z=t?(A.clientX-d)/ne*100:(A.clientY-h)/O*100,v=P+Z,$=t?X+(ne-o)*(v/100)+o/2:Y+(O-o)*(v/100)+o/2,x=1/0,B=null;for(let Q of U){let K=Math.abs($-Q);K<c&&K<x&&(x=K,B=Q);}let ue=v;B!==null&&(ue=t?(B-o/2-X)/(ne-o)*100:(B-o/2-Y)/(O-o)*100);let G=Math.max(T,Math.min(z,ue));V=G;let J=xe(i,s,G);if(J){let{panes:Q,splitters:K}=he(J),S=e.current;if(S){for(let L of Q)S.style.setProperty(`--pane-left-${L.paneId}`,`${L.left}%`),S.style.setProperty(`--pane-top-${L.paneId}`,`${L.top}%`),S.style.setProperty(`--pane-width-${L.paneId}`,`${L.width}%`),S.style.setProperty(`--pane-height-${L.paneId}`,`${L.height}%`);for(let L of K)S.style.setProperty(`--splitter-pos-${L.id}`,`${L.direction==="row"?L.left:L.top}%`);}}D&&D(s,G);},onEnd:()=>{let A=xe(i,s,V),Z=e.current;if(Z){let{panes:v,splitters:$}=he(A);for(let x of v)Z.style.removeProperty(`--pane-left-${x.paneId}`),Z.style.removeProperty(`--pane-top-${x.paneId}`),Z.style.removeProperty(`--pane-width-${x.paneId}`),Z.style.removeProperty(`--pane-height-${x.paneId}`);for(let x of $)Z.style.removeProperty(`--splitter-pos-${x.id}`);}u(A),l&&l(),I&&I(s,V);}});},[e,t,n,r,o,c,i,s,u,f,l,y,D,I,T,z,b,g,m,w])}var bn=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:r})=>{let{renderingLayout:o,setLayout:c,classNames:i,locked:s}=ie(),[u,f]=ge.useState(false),{currentNode:l,direction:b,left:g,top:m,width:w,height:y,parentLeft:D,parentTop:I,parentWidth:T,parentHeight:z}=e,E=b==="row",k=Rt({containerRef:r,isRow:E,direction:b,splitPercentage:l.splitPercentage,resizerSize:t,snapThreshold:n,layout:o,currentNode:l,onLayoutChange:c,onResizeStart:()=>f(true),onResizeEnd:()=>f(false),parentLeft:D,parentTop:I,parentWidth:T,parentHeight:z}),M=E?{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(${w}% - ${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:i.resizer||"","data-direction":b,"data-resizing":u||void 0,style:M,onPointerDown:k,role:"separator","aria-valuenow":l.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},vn=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:i,setContainerRef:s,fullscreenPaneId:u,snapThreshold:f,locked:l,classNames:b,resizerSize:g}=ie(),m=r!==void 0?r:f??8,w=n!==void 0?n:g??4,y=t!==void 0?t:o,D=ge.useRef(null),{panes:I,splitters:T}=ge.useMemo(()=>y?he(y):{panes:[],splitters:[]},[y]);if(!y&&t!==void 0)return null;let z=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[I.map(E=>{let k=u===E.paneId;return jsxRuntime.jsx("div",{style:{position:"absolute",left:k?"0%":`var(--pane-left-${E.paneId}, ${E.left}%)`,top:k?"0%":`var(--pane-top-${E.paneId}, ${E.top}%)`,width:k?"100%":`var(--pane-width-${E.paneId}, ${E.width}%)`,height:k?"100%":`var(--pane-height-${E.paneId}, ${E.height}%)`,overflow:"hidden",zIndex:k?20:1,display:u&&!k?"none":"block",padding:k?"0px":`${w/2}px`,boxSizing:"border-box"},children:jsxRuntime.jsx(vn,{paneId:E.paneId,renderPane:e})},E.paneId)}),!u&&T.map(E=>jsxRuntime.jsx(bn,{splitter:E,resizerSize:w,snapThreshold:m,containerRef:D},E.id))]});if(t===void 0){let E=c!==null&&c===i,k=a=>{s(a),D.current=a;},M=`${b.dashboard||""} ${E&&b.dashboardDismissActive||""} ${l&&b.dashboardLocked||""}`.trim();return jsxRuntime.jsxs("div",{ref:k,className:M,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[z(),c!==null&&!l&&jsxRuntime.jsx(Tn,{activeClassName:b.rootDropPreview??b.dropPreview})]})}return jsxRuntime.jsx("div",{ref:D,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:z()})};var Eo=e=>{let{controller:t,children:n,renderDragOverlay:r,classNames:o={},renderPane:c,resizerSize:i,dragActivationDistance:s=8,snapThreshold:u=8,minSplitPercentage:f=5,maxSplitPercentage:l=95,enableDragToDismiss:b=false,dismissThreshold:g=60,onRemove:m,onDragStart:w,onDragEnd:y,onResizeStart:D,onResize:I,onResizeEnd:T,onDismissIntentChange:z,persist:E=false}=e,k=t,{layout:M,setLayout:a,_internalSetLayout:d,renderingLayout:h,fullscreenPaneId:P,setFullscreenPaneId:N,locked:X,setLocked:Y,findPaneById:ne,findPaneContainingTab:O,findTabById:H,getTabMetadata:U,getActiveTabMetadata:V,activeId:A,setActiveId:Z,activeType:v,setActiveType:$,dismissIntentId:x,setDismissIntentId:B,containerRef:ue,setContainerRef:G,removePane:J,addTab:Q,updateMetadata:K,updatePaneLock:S,selectTab:L,mergeTab:le,removeTab:se,splitPane:ee,updateSplitPercentage:oe,moveTab:Ze,poppedOutTabIds:p=[],popoutTab:R,dockTab:C}=k;an({persist:E,layout:M,setLayout:a});let{portalTargets:F,registerPortalTarget:_,registerPopoutTarget:ae,registerRenderCallback:j,renderCallbacksRef:ve,registerRenderPane:pt,renderPaneRef:ft,registerTabHeader:Lt,tabHeadersRef:mt,activeIdRef:Xe}=_t();dn({poppedOutTabIds:p,registerPopoutTarget:ae,findTabById:H,dockTab:C});let kt=ge.useCallback(de=>p.includes(de),[p]),{overTabId:Mt,setOverTabId:Zn,overTabPosition:Ot,setOverTabPosition:Hn,handleDragStartInternal:$n,handleDragEndInternal:Bn}=Vt({onDragStart:w,onDragEnd:y}),_n=on({layout:M,_internalSetLayout:d,setLayout:a,activeId:A,setActiveId:Z,activeType:v,setActiveType:$,dismissIntentId:x,setDismissIntentId:B,setOverTabId:Zn,setOverTabPosition:Hn,containerRef:ue,dragActivationDistance:s,enableDragToDismiss:b,dismissThreshold:g,onRemove:m,onDragStart:$n,onDragEnd:Bn,onDismissIntentChange:z,removeTab:se,removePane:J}),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]),At=ge.useCallback((de,Ye)=>{T&&T(de,Ye);},[T]),Fn=ge.useMemo(()=>({layout:M,renderingLayout:h,setLayout:a,activeId:A,activeType:v,dismissIntentId:x,setContainerRef:G,fullscreenPaneId:P,classNames:gt,onRemove:m,onFullscreenChange:N,snapThreshold:u,onResizeStart:D,onResize:I,onResizeEnd:At,minSplitPercentage:f,maxSplitPercentage:l,locked:X,setLocked:Y,findPaneById:ne,findPaneContainingTab:O,findTabById:H,getTabMetadata:U,getActiveTabMetadata:V,renderPane:c,resizerSize:i,poppedOutTabIds:p,isTabPoppedOut:kt}),[M,h,A,v,x,G,P,gt,m,N,u,D,I,f,l,a,At,X,Y,ne,O,H,U,V,c,i,p,kt]),Vn=ge.useMemo(()=>({overTabId:Mt,overTabPosition:Ot}),[Mt,Ot]),jn=ge.useMemo(()=>({removePane:J,addTab:Q,updateMetadata:K,updatePaneLock:S,selectTab:L,mergeTab:le,removeTab:se,setFullscreenPaneId:N,setLocked:Y,splitPane:ee,updateSplitPercentage:oe,moveTab:Ze,popoutTab:R,dockTab:C}),[J,Q,K,S,L,le,se,N,Y,ee,oe,Ze,R,C]),Wn=Ft(M),qn=ge.useMemo(()=>({registerPortalTarget:_,registerRenderCallback:j,renderCallbacksRef:ve,registerRenderPane:pt,renderPaneRef:ft,registerTabHeader:Lt,tabHeadersRef:mt,activeIdRef:Xe,registerPopoutTarget:ae}),[_,j,ve,pt,ft,Lt,mt,Xe,ae]);return Xe&&(Xe.current=A),jsxRuntime.jsx(Re.Provider,{value:jn,children:jsxRuntime.jsx(vt.Provider,{value:Fn,children:jsxRuntime.jsx(ht.Provider,{value:Vn,children:jsxRuntime.jsxs(Te.Provider,{value:qn,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",..._n,children:n}),A&&v&&jsxRuntime.jsx(pn,{activeId:A,render:de=>jsxRuntime.jsx("div",{style:{transition:"transform 150ms cubic-bezier(0.2, 0, 0, 1)",transform:de===x?"scale(0.8)":"scale(1)",transformOrigin:"top left"},children:jsxRuntime.jsx(gn,{activeId:de,activeType:v,dismissIntentId:x,renderDragOverlay:r,renderPaneRef:ft,renderPane:c,tabHeadersRef:mt,classNames:gt})}),className:`${o.dragOverlay||""} ${A===x&&o.dismissPreview||""}`.trim()}),jsxRuntime.jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:Wn.map(de=>{let Ye=F[de],zt=H(de);return zt?jsxRuntime.jsx(mn,{tabDetails:zt,target:Ye||null,renderWidget:ve.current[de]},de):null})})]})})})})},So=({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})},No=e=>{let{children:t,...n}=e,{controller:r}=e;if(!r)throw new Error("Zeugma component requires a controller.");return jsxRuntime.jsx(Eo,{...e,children:t!==void 0?t:jsxRuntime.jsx(So,{...n})})};var ko={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"}}},Mo={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"}}},Oo=({id:e,fraction:t,edge:n,activeClassName:r})=>{let{setNodeRef:o,isOver:c}=core.useDroppable({id:e}),i={position:"absolute",pointerEvents:"none",zIndex:101,boxSizing:"border-box",...Mo[n][t]};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:o,style:ko[n][t]}),c&&jsxRuntime.jsx("div",{className:r,style:i})]})},Tn=({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(Oo,{id:n.id,fraction:n.fraction,edge:n.edge,activeClassName:e},n.id))});var it=ge.createContext(null);var $o={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"}},Bo={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"}},lt=({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:$o[t]}),o&&jsxRuntime.jsx("div",{className:n,style:Bo[t]})]})};var wn=({children:e,className:t,style:n})=>{let r=ge.useContext(it);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 Go=ge.createContext(void 0);var We=({id:e,locked:t=false,children:n,className:r,style:o})=>{let{locked:c,classNames:i={},fullscreenPaneId:s,poppedOutTabIds:u=[]}=ie(),f=ge.useContext(Re),{overTabId:l}=Je(),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(Ct),w=t||c||(m?.locked??false)||s!==null,{attributes:y,listeners:D,setNodeRef:I,isDragging:T}=core.useDraggable({id:`tab-header-${e}`,disabled:w}),{setNodeRef:z,isOver:E}=core.useDroppable({id:`tab-drop-${e}`,disabled:w}),k=U=>{I(U),z(U);},M=E&&l===e,a=m?.tabIds||[],d=a.indexOf(e),h=m?.activeTabId,N=d>0&&e!==h&&a[d-1]!==h?jsxRuntime.jsx("div",{className:i.tabSeparator}):null,X=m?m.activeTabId===e:false,Y=m?.tabsMetadata?.[e],ne=ge.useCallback(()=>{m?.selectTab(e);},[m,e]),O=ge.useCallback(()=>{m?.removeTab(e);},[m,e]),H=ge.useMemo(()=>({tabId:e,isActive:X,isDragging:T,isOver:M,metadata:Y,locked:w,selectTab:ne,removeTab:O,isPoppedOut:g,popoutTab:()=>f?.popoutTab(e),dockTab:()=>f?.dockTab(e)}),[e,X,T,M,Y,w,ne,O,g,f]);return jsxRuntime.jsx(Go.Provider,{value:H,children:jsxRuntime.jsxs("div",{ref:k,id:`tab-header-${e}`,className:r,style:{display:"inline-flex",position:"relative",cursor:w?"default":"grab",...o},...w?{}:D,...w?{}:y,children:[N,n({isDragging:T,isOver:M})]})})};var Ct=ge.createContext(void 0);var En=(e,t)=>typeof e=="function"?e(t):e,Dt=({tabIds:e,activeTabId:t,locked:n,tabsMetadata:r,selectTab:o,removeTab:c,renderTab:i,classNames:s,styles:u})=>{let f=ge.useContext(ct),l=e??f?.tabIds??[],b=t??f?.activeTabId??"",g=n??f?.locked??false,m=r??f?.tabsMetadata,w=o??f?.selectTab??(()=>{}),y=c??f?.removeTab??(()=>{}),{classNames:D={},activeType:I,poppedOutTabIds:T=[]}=ie(),z=ge.useContext(Re),{overTabId:E,overTabPosition:k}=Je(),M=ge.useMemo(()=>({tabIds:l,activeTabId:b,locked:g,tabsMetadata:m,selectTab:w,removeTab:y}),[l,b,g,m,w,y]),a=Jt(l,I,E,k);return jsxRuntime.jsx(Ct.Provider,{value:M,children:jsxRuntime.jsxs("div",{className:s?.container,style:{display:"flex",alignItems:"center",height:"100%",...u?.container},children:[l.map((d,h)=>{let P=m?.[d],N=En(s?.tab,d),X=En(u?.tab,d),Y=h===a;return jsxRuntime.jsxs(ge__default.default.Fragment,{children:[Y&&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:h===0?"none":"translateX(-50%)"}})}),jsxRuntime.jsx(We,{id:d,locked:g,className:N,style:X,children:({isDragging:ne,isOver:O})=>i({id:d,paneId:f?.id??"",isActive:d===b,index:h,isDragging:ne,isOver:O,metadata:P,onSelect:()=>w(d),onRemove:()=>y(d),isPoppedOut:T.includes(d),popout:()=>z?.popoutTab(d),dock:()=>z?.dockTab(d)})})]},d)}),a===l.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%)"}})})]})})};Dt.Tab=We;var Nn=({className:e,style:t,children:n})=>jsxRuntime.jsx("div",{className:e,style:t,children:n});var ct=ge.createContext(void 0),Ln=()=>{let e=ge.useContext(ct);if(!e)throw new Error("usePaneContext must be used within a Pane component");return e},sr=({children:e,className:t,style:n})=>{let{activeTabId:r}=Ln(),{classNames:o,isTabPoppedOut:c}=ie(),{dockTab:i}=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:l}=u,b=ge.useMemo(()=>typeof e=="function"?e:()=>e,[e]);l(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:()=>i(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:i,activeType:s,classNames:u,fullscreenPaneId:f,onFullscreenChange:l,locked:b,poppedOutTabIds:g=[]}=ie(),{removePane:m,updateMetadata:w,selectTab:y,removeTab:D,popoutTab:I,dockTab:T}=He(),z=ge.useMemo(()=>{if(s==="tab"&&e===i){let B=W(o,e)?.tabsMetadata?.[e];return {type:"pane",id:e,tabIds:[e],activeTabId:e,tabsMetadata:B?{[e]:B}:void 0}}return qt(e===i?o:c,e)},[o,c,e,i,s]),E=z?.id??e,k=z?.tabIds??[e],M=z?.activeTabId??e,a=z?.tabsMetadata,d=a?.[e],h=z?.locked??false,P=r||h,N=b||P||f!==null,X=b||P||f!==null,Y=i!==null&&i!==e&&(!k.includes(i)||k.length>1)&&!X,{attributes:ne,listeners:O,setNodeRef:H}=core.useDraggable({id:e,disabled:N}),U=i!==null&&k.includes(i),V=f===e,A=ge.useMemo(()=>({isDragging:U,isFullscreen:V,toggleFullscreen:()=>l?.(V?null:e),remove:()=>{V&&l?.(null),m(E);},metadata:d,updateMetadata:$=>{w(e,$);},locked:N,tabIds:k,activeTabId:M,selectTab:$=>y(E,$),removeTab:$=>{V&&$===M&&l?.(null),D($);},tabsMetadata:a,updateTabMetadata:($,x)=>{w($,x);},isActiveTabPoppedOut:g.includes(M),popoutTab:$=>I($||M),dockTab:$=>T($||M)}),[U,V,l,e,D,d,w,N,k,M,y,E,a,g,I,T]),Z=ge.useMemo(()=>N?{disabled:true}:{...O,...ne},[O,ne,N]),v=`${u.pane||""} ${P&&u.paneLocked||""}`.trim();return jsxRuntime.jsx(ct.Provider,{value:{id:e,...A},children:jsxRuntime.jsx(it.Provider,{value:Z,children:jsxRuntime.jsxs("div",{ref:H,id:e,className:v,style:{position:"relative",width:"100%",height:"100%",...n},children:[t,Y&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:[["top","bottom","left","right"].map($=>jsxRuntime.jsx(lt,{id:`drop-${$}-${e}`,position:$,activeClassName:u.dropPreview},$)),s==="tab"&&jsxRuntime.jsx(lt,{id:`drop-center-${e}`,position:"center",activeClassName:u.swapPreview??u.dropPreview})]}),i!==null&&i!==e&&X&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsxRuntime.jsx(lt,{id:`drop-locked-${e}`,position:"full",activeClassName:u.lockedPreview||""})})]})})})};Oe.Content=sr;Oe.DragHandle=wn;Oe.Tabs=Dt;Oe.Tab=We;Oe.Controls=Nn;var dt=new Map;function qe(e){let t=dt.get(e);return t||(t={mounts:0,renders:0,listeners:new Set},dt.set(e,t)),t}function kn(e,t){let n=qe(e);return n.listeners.add(t),()=>{n.listeners.delete(t);}}function St(e){let t=dt.get(e);t&&t.listeners.forEach(n=>n());}function Mn(e){let t=dt.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:i=false}=r,s=ge.useRef(0),u=ge.useRef(false),[,f]=ge.useState(0);if(i||(s.current+=1),ge.useEffect(()=>{if(i)return;let g=kn(o,()=>{f(w=>w+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,i,c]),!i){let g=qe(o);g.renders=Math.max(g.renders,s.current);}let l=ge.useCallback(()=>{s.current=0,Mn(o);},[o]);return i?{mounts:0,renders:0,reset:l}:{mounts:qe(o).mounts,renders:s.current,reset:l}}function An({id:e,className:t,style:n,logToConsole:r=false,disabled:o=false}){let{mounts:c,renders:i}=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:i})]})]})}function zn({id:e,label:t,children:n,className:r,footerClassName:o,style:c,logToConsole:i=false,disabled:s=false}){let u=t||e||"widget",{mounts:f,renders:l}=Ae(e,{logToConsole:i,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:l})]})]})]})]})}exports.Pane=Oe;exports.PaneTree=wt;exports.RenderCounterBadge=An;exports.RenderCounterFooter=zn;exports.Zeugma=No;exports.usePaneContext=Ln;exports.useRenderCounter=Ae;exports.useResizer=Rt;exports.useZeugma=Qn;exports.useZeugmaContext=Kn;//# sourceMappingURL=index.cjs.map
|
|
12
12
|
//# sourceMappingURL=index.cjs.map
|