react-panel-layout 0.6.0 → 0.6.1

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.
Files changed (216) hide show
  1. package/dist/{FloatingPanelFrame-SgYLc6Ud.js → FloatingPanelFrame-3eU9AwPo.js} +2 -2
  2. package/dist/{FloatingPanelFrame-SgYLc6Ud.js.map → FloatingPanelFrame-3eU9AwPo.js.map} +1 -1
  3. package/dist/FloatingWindow-CUXnEtrb.js +827 -0
  4. package/dist/FloatingWindow-CUXnEtrb.js.map +1 -0
  5. package/dist/FloatingWindow-DMwyK0eK.cjs +2 -0
  6. package/dist/FloatingWindow-DMwyK0eK.cjs.map +1 -0
  7. package/dist/GridLayout-DKTg_N61.cjs +2 -0
  8. package/dist/{GridLayout-B4VRsC0r.cjs.map → GridLayout-DKTg_N61.cjs.map} +1 -1
  9. package/dist/{GridLayout-BltqeCPK.js → GridLayout-UWNxXw77.js} +34 -35
  10. package/dist/{GridLayout-BltqeCPK.js.map → GridLayout-UWNxXw77.js.map} +1 -1
  11. package/dist/{HorizontalDivider-WF1k_qND.js → HorizontalDivider-DdxzfV0l.js} +3 -3
  12. package/dist/{HorizontalDivider-WF1k_qND.js.map → HorizontalDivider-DdxzfV0l.js.map} +1 -1
  13. package/dist/{HorizontalDivider-B5Z-KZLk.cjs → HorizontalDivider-_pgV4Mcv.cjs} +2 -2
  14. package/dist/{HorizontalDivider-B5Z-KZLk.cjs.map → HorizontalDivider-_pgV4Mcv.cjs.map} +1 -1
  15. package/dist/{PanelSystem-Dr1TBhxM.js → PanelSystem-BqUzNtf2.js} +5 -5
  16. package/dist/{PanelSystem-Dr1TBhxM.js.map → PanelSystem-BqUzNtf2.js.map} +1 -1
  17. package/dist/{PanelSystem-Bs8bQwQF.cjs → PanelSystem-D603LKKv.cjs} +2 -2
  18. package/dist/{PanelSystem-Bs8bQwQF.cjs.map → PanelSystem-D603LKKv.cjs.map} +1 -1
  19. package/dist/ResizeHandle-CBcAS918.cjs +2 -0
  20. package/dist/{ResizeHandle-CScipO5l.cjs.map → ResizeHandle-CBcAS918.cjs.map} +1 -1
  21. package/dist/{ResizeHandle-CdA_JYfN.js → ResizeHandle-CXjc1meV.js} +28 -29
  22. package/dist/{ResizeHandle-CdA_JYfN.js.map → ResizeHandle-CXjc1meV.js.map} +1 -1
  23. package/dist/SwipePivotTabBar-DWrCuwEI.js +411 -0
  24. package/dist/SwipePivotTabBar-DWrCuwEI.js.map +1 -0
  25. package/dist/SwipePivotTabBar-fjjXkpj7.cjs +2 -0
  26. package/dist/SwipePivotTabBar-fjjXkpj7.cjs.map +1 -0
  27. package/dist/components/gesture/SwipeSafeZone.d.ts +40 -0
  28. package/dist/components/window/Drawer.d.ts +3 -1
  29. package/dist/components/window/DrawerLayers.d.ts +1 -1
  30. package/dist/components/window/drawerStyles.d.ts +69 -0
  31. package/dist/components/window/drawerSwipeConfig.d.ts +29 -0
  32. package/dist/components/window/useDrawerSwipeTransform.d.ts +23 -0
  33. package/dist/config.cjs +1 -1
  34. package/dist/config.js +3 -3
  35. package/dist/constants/styles.d.ts +17 -0
  36. package/dist/dialog/index.d.ts +69 -0
  37. package/dist/floating.js +1 -1
  38. package/dist/grid.cjs +1 -1
  39. package/dist/grid.js +2 -2
  40. package/dist/hooks/gesture/testing/createGestureSimulator.d.ts +7 -0
  41. package/dist/hooks/gesture/types.d.ts +48 -5
  42. package/dist/hooks/gesture/utils.d.ts +19 -0
  43. package/dist/hooks/useAnimationFrame.d.ts +2 -0
  44. package/dist/hooks/useOperationContinuity.d.ts +64 -0
  45. package/dist/hooks/useResizeObserver.d.ts +33 -1
  46. package/dist/hooks/useSharedElementTransition.d.ts +112 -0
  47. package/dist/hooks/useSwipeContentTransform.d.ts +9 -2
  48. package/dist/index.cjs +1 -1
  49. package/dist/index.js +7 -7
  50. package/dist/modules/dialog/AlertDialog.d.ts +9 -0
  51. package/dist/modules/dialog/DialogContainer.d.ts +37 -0
  52. package/dist/modules/dialog/Modal.d.ts +26 -0
  53. package/dist/modules/dialog/SwipeDialogContainer.d.ts +16 -0
  54. package/dist/modules/dialog/dialogAnimationUtils.d.ts +113 -0
  55. package/dist/modules/dialog/types.d.ts +183 -0
  56. package/dist/modules/dialog/useDialog.d.ts +39 -0
  57. package/dist/modules/dialog/useDialogContainer.d.ts +47 -0
  58. package/dist/modules/dialog/useDialogSwipeInput.d.ts +70 -0
  59. package/dist/modules/dialog/useDialogTransform.d.ts +82 -0
  60. package/dist/modules/drawer/types.d.ts +74 -0
  61. package/dist/modules/drawer/useDrawerSwipeInput.d.ts +24 -0
  62. package/dist/modules/pivot/SwipePivotTabBar.d.ts +3 -0
  63. package/dist/modules/stack/SwipeStackContent.d.ts +6 -3
  64. package/dist/modules/stack/SwipeStackOutlet.d.ts +4 -4
  65. package/dist/modules/stack/computeSwipeStackTransform.d.ts +1 -1
  66. package/dist/panels.cjs +1 -1
  67. package/dist/panels.js +1 -1
  68. package/dist/pivot.cjs +1 -1
  69. package/dist/pivot.js +1 -1
  70. package/dist/resizer.cjs +1 -1
  71. package/dist/resizer.js +2 -2
  72. package/dist/stack.cjs +1 -1
  73. package/dist/stack.cjs.map +1 -1
  74. package/dist/stack.js +503 -762
  75. package/dist/stack.js.map +1 -1
  76. package/dist/sticky-header/calculateStickyMetrics.d.ts +28 -0
  77. package/dist/sticky-header.cjs +1 -1
  78. package/dist/sticky-header.cjs.map +1 -1
  79. package/dist/sticky-header.js +59 -51
  80. package/dist/sticky-header.js.map +1 -1
  81. package/dist/{styles-DPPuJ0sf.js → styles-NkjuMOVS.js} +13 -13
  82. package/dist/{styles-DPPuJ0sf.js.map → styles-NkjuMOVS.js.map} +1 -1
  83. package/dist/styles-qf6ptVLD.cjs.map +1 -1
  84. package/dist/types.d.ts +16 -0
  85. package/dist/useDocumentPointerEvents-DXxw3qWj.js +54 -0
  86. package/dist/useDocumentPointerEvents-DXxw3qWj.js.map +1 -0
  87. package/dist/useDocumentPointerEvents-DxDSOtip.cjs +2 -0
  88. package/dist/useDocumentPointerEvents-DxDSOtip.cjs.map +1 -0
  89. package/dist/useNativeGestureGuard-C7TSqEkr.cjs +2 -0
  90. package/dist/useNativeGestureGuard-C7TSqEkr.cjs.map +1 -0
  91. package/dist/useNativeGestureGuard-CGYo6O0r.js +347 -0
  92. package/dist/useNativeGestureGuard-CGYo6O0r.js.map +1 -0
  93. package/dist/window/index.d.ts +2 -0
  94. package/dist/window.cjs +1 -1
  95. package/dist/window.cjs.map +1 -1
  96. package/dist/window.js +114 -103
  97. package/dist/window.js.map +1 -1
  98. package/package.json +6 -1
  99. package/src/components/gesture/SwipeSafeZone.tsx +69 -0
  100. package/src/components/window/Drawer.tsx +249 -162
  101. package/src/components/window/DrawerLayers.tsx +13 -3
  102. package/src/components/window/drawerStyles.spec.ts +263 -0
  103. package/src/components/window/drawerStyles.ts +228 -0
  104. package/src/components/window/drawerSwipeConfig.spec.ts +131 -0
  105. package/src/components/window/drawerSwipeConfig.ts +112 -0
  106. package/src/components/window/useDrawerSwipeTransform.spec.ts +234 -0
  107. package/src/components/window/useDrawerSwipeTransform.ts +129 -0
  108. package/src/constants/styles.ts +19 -0
  109. package/src/demo/pages/Dialog/alerts/index.tsx +22 -0
  110. package/src/demo/pages/Dialog/card/index.tsx +22 -0
  111. package/src/demo/pages/Dialog/components/AlertDialogDemo.tsx +124 -0
  112. package/src/demo/pages/Dialog/components/CardExpandDemo.module.css +243 -0
  113. package/src/demo/pages/Dialog/components/CardExpandDemo.tsx +204 -0
  114. package/src/demo/pages/Dialog/components/CustomAlertDialogDemo.tsx +219 -0
  115. package/src/demo/pages/Dialog/components/DialogDemos.module.css +77 -0
  116. package/src/demo/pages/Dialog/components/ModalBasics.tsx +45 -0
  117. package/src/demo/pages/Dialog/components/SwipeDialogDemo.module.css +77 -0
  118. package/src/demo/pages/Dialog/components/SwipeDialogDemo.tsx +181 -0
  119. package/src/demo/pages/Dialog/custom-alert/index.tsx +22 -0
  120. package/src/demo/pages/Dialog/modal/index.tsx +17 -0
  121. package/src/demo/pages/Dialog/swipe/index.tsx +22 -0
  122. package/src/demo/pages/Drawer/components/DrawerSwipe.module.css +316 -0
  123. package/src/demo/pages/Drawer/components/DrawerSwipe.tsx +178 -0
  124. package/src/demo/pages/Drawer/swipe/index.tsx +17 -0
  125. package/src/demo/pages/Pivot/components/SwipeTabsPivot.tsx +54 -23
  126. package/src/demo/pages/Pivot/swipe-debug/index.tsx +1 -1
  127. package/src/demo/pages/Stack/components/StackBasics.spec.tsx +152 -0
  128. package/src/demo/pages/Stack/components/StackBasics.tsx +179 -95
  129. package/src/demo/pages/Stack/components/StackTablet.spec.tsx +120 -0
  130. package/src/demo/pages/Stack/components/StackTablet.tsx +42 -21
  131. package/src/demo/routes.tsx +22 -1
  132. package/src/dialog/index.ts +85 -0
  133. package/src/hooks/gesture/testing/createGestureSimulator.spec.ts +68 -64
  134. package/src/hooks/gesture/testing/createGestureSimulator.ts +112 -37
  135. package/src/hooks/gesture/types.ts +83 -6
  136. package/src/hooks/gesture/useEdgeSwipeInput.spec.ts +22 -14
  137. package/src/hooks/gesture/useNativeGestureGuard.spec.ts +91 -31
  138. package/src/hooks/gesture/useNativeGestureGuard.ts +3 -1
  139. package/src/hooks/gesture/utils.ts +91 -0
  140. package/src/hooks/useAnimatedVisibility.spec.ts +44 -24
  141. package/src/hooks/useAnimatedVisibility.ts +28 -2
  142. package/src/hooks/useAnimationFrame.ts +8 -0
  143. package/src/hooks/useOperationContinuity.spec.ts +387 -0
  144. package/src/hooks/useOperationContinuity.ts +135 -0
  145. package/src/hooks/useResizeObserver.spec.tsx +277 -0
  146. package/src/hooks/useResizeObserver.tsx +108 -39
  147. package/src/hooks/useScrollContainer.ts +4 -10
  148. package/src/hooks/useSharedElementTransition.ts +333 -0
  149. package/src/hooks/useSwipeContentTransform.spec.ts +18 -18
  150. package/src/hooks/useSwipeContentTransform.ts +166 -28
  151. package/src/modules/dialog/AlertDialog.spec.tsx +387 -0
  152. package/src/modules/dialog/AlertDialog.tsx +221 -0
  153. package/src/modules/dialog/DialogContainer.spec.tsx +228 -0
  154. package/src/modules/dialog/DialogContainer.tsx +188 -0
  155. package/src/modules/dialog/Modal.spec.tsx +220 -0
  156. package/src/modules/dialog/Modal.tsx +182 -0
  157. package/src/modules/dialog/SwipeDialogContainer.tsx +208 -0
  158. package/src/modules/dialog/dialogAnimationUtils.spec.ts +253 -0
  159. package/src/modules/dialog/dialogAnimationUtils.ts +297 -0
  160. package/src/modules/dialog/types.ts +186 -0
  161. package/src/modules/dialog/useDialog.spec.tsx +447 -0
  162. package/src/modules/dialog/useDialog.ts +214 -0
  163. package/src/modules/dialog/useDialogContainer.spec.ts +331 -0
  164. package/src/modules/dialog/useDialogContainer.ts +150 -0
  165. package/src/modules/dialog/useDialogSwipeInput.spec.ts +157 -0
  166. package/src/modules/dialog/useDialogSwipeInput.ts +319 -0
  167. package/src/modules/dialog/useDialogTransform.spec.ts +370 -0
  168. package/src/modules/dialog/useDialogTransform.ts +407 -0
  169. package/src/modules/drawer/types.ts +102 -0
  170. package/src/modules/drawer/useDrawerSwipeInput.spec.ts +566 -0
  171. package/src/modules/drawer/useDrawerSwipeInput.ts +399 -0
  172. package/src/modules/panels/rendering/ContentRegistry.spec.tsx +21 -14
  173. package/src/modules/pivot/SwipePivotContent.position.spec.tsx +12 -8
  174. package/src/modules/pivot/SwipePivotContent.spec.tsx +55 -25
  175. package/src/modules/pivot/SwipePivotContent.tsx +2 -2
  176. package/src/modules/pivot/SwipePivotTabBar.spec.tsx +85 -68
  177. package/src/modules/pivot/SwipePivotTabBar.tsx +75 -15
  178. package/src/modules/pivot/scaleInputState.spec.ts +11 -2
  179. package/src/modules/pivot/usePivot.spec.ts +17 -3
  180. package/src/modules/pivot/usePivotSwipeInput.spec.ts +182 -123
  181. package/src/modules/stack/SwipeStackContent.spec.tsx +387 -100
  182. package/src/modules/stack/SwipeStackContent.tsx +43 -33
  183. package/src/modules/stack/SwipeStackOutlet.spec.tsx +14 -16
  184. package/src/modules/stack/SwipeStackOutlet.tsx +6 -6
  185. package/src/modules/stack/computeSwipeStackTransform.spec.ts +5 -5
  186. package/src/modules/stack/computeSwipeStackTransform.ts +3 -3
  187. package/src/modules/stack/swipeTransitionContinuity.spec.tsx +1133 -0
  188. package/src/modules/stack/useStackAnimationState.spec.ts +3 -1
  189. package/src/modules/stack/useStackAnimationState.ts +18 -13
  190. package/src/modules/stack/useStackNavigation.spec.ts +198 -3
  191. package/src/modules/stack/useStackNavigation.tsx +113 -56
  192. package/src/modules/stack/useStackSwipeInput.spec.ts +65 -32
  193. package/src/modules/stack/useStackSwipeInput.ts +1 -1
  194. package/src/sticky-header/StickyArea.tsx +29 -57
  195. package/src/sticky-header/calculateStickyMetrics.spec.ts +105 -0
  196. package/src/sticky-header/calculateStickyMetrics.ts +50 -0
  197. package/src/types.ts +18 -0
  198. package/src/window/index.ts +2 -0
  199. package/dist/FloatingWindow-BpdOpg_L.js +0 -400
  200. package/dist/FloatingWindow-BpdOpg_L.js.map +0 -1
  201. package/dist/FloatingWindow-TCDNY5gE.cjs +0 -2
  202. package/dist/FloatingWindow-TCDNY5gE.cjs.map +0 -1
  203. package/dist/GridLayout-B4VRsC0r.cjs +0 -2
  204. package/dist/ResizeHandle-CScipO5l.cjs +0 -2
  205. package/dist/SwipePivotTabBar-BGO9X94m.js +0 -407
  206. package/dist/SwipePivotTabBar-BGO9X94m.js.map +0 -1
  207. package/dist/SwipePivotTabBar-BrQismcZ.cjs +0 -2
  208. package/dist/SwipePivotTabBar-BrQismcZ.cjs.map +0 -1
  209. package/dist/useDocumentPointerEvents-CKdhGXd0.js +0 -46
  210. package/dist/useDocumentPointerEvents-CKdhGXd0.js.map +0 -1
  211. package/dist/useDocumentPointerEvents-ChqrKXDk.cjs +0 -2
  212. package/dist/useDocumentPointerEvents-ChqrKXDk.cjs.map +0 -1
  213. package/dist/useEffectEvent-Dp7HLCf0.js +0 -13
  214. package/dist/useEffectEvent-Dp7HLCf0.js.map +0 -1
  215. package/dist/useEffectEvent-huSsGUnl.cjs +0 -2
  216. package/dist/useEffectEvent-huSsGUnl.cjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FloatingWindow-CUXnEtrb.js","sources":["../src/components/gesture/SwipeSafeZone.tsx","../src/modules/drawer/types.ts","../src/modules/drawer/useDrawerSwipeInput.ts","../src/components/window/drawerStyles.ts","../src/components/window/drawerSwipeConfig.ts","../src/components/window/useDrawerSwipeTransform.ts","../src/components/window/Drawer.tsx","../src/hooks/useTransitionState.ts","../src/modules/window/useDrawerState.ts","../src/components/window/DrawerLayers.tsx","../src/modules/grid/GridLayoutContext.tsx","../src/PanelSystemContext.tsx","../src/modules/grid/LayerInstanceContext.tsx","../src/components/window/PopupLayerPortal.tsx","../src/components/window/FloatingWindow.tsx"],"sourcesContent":["/**\n * @file SwipeSafeZone component\n *\n * A wrapper component that marks an area as exempt from swipe gesture detection.\n * Content inside this zone will not trigger swipe-to-close or other swipe gestures.\n *\n * Use this for:\n * - Scrollable content areas\n * - Input fields and text areas\n * - Interactive elements that need drag/swipe for their own purposes\n */\nimport * as React from \"react\";\n\n/**\n * Data attribute used to identify swipe-safe zones.\n * Swipe gesture handlers should check for this attribute on target elements.\n */\nexport const SWIPE_SAFE_ZONE_ATTR = \"data-swipe-safe-zone\";\n\nexport type SwipeSafeZoneProps = {\n /** Content to render inside the safe zone */\n children: React.ReactNode;\n /** Additional CSS class name */\n className?: string;\n /** Additional inline styles */\n style?: React.CSSProperties;\n};\n\n/**\n * SwipeSafeZone marks an area where swipe gestures should not be triggered.\n *\n * @example\n * ```tsx\n * <SwipeSafeZone>\n * <ScrollableList items={items} />\n * </SwipeSafeZone>\n * ```\n */\nexport const SwipeSafeZone: React.FC<SwipeSafeZoneProps> = ({\n children,\n className,\n style,\n}) => {\n return (\n <div\n className={className}\n style={style}\n data-swipe-safe-zone=\"true\"\n >\n {children}\n </div>\n );\n};\n\n/**\n * Check if an element is inside a SwipeSafeZone.\n */\nexport function isInSwipeSafeZone(element: HTMLElement, container: HTMLElement): boolean {\n let current: HTMLElement | null = element;\n\n while (current && current !== container) {\n if (current.hasAttribute(SWIPE_SAFE_ZONE_ATTR)) {\n return true;\n }\n current = current.parentElement;\n }\n\n return false;\n}\n","/**\n * @file Type definitions for Drawer swipe gesture handling.\n */\nimport type * as React from \"react\";\nimport type { ContinuousOperationState } from \"../../hooks/gesture/types.js\";\n\n/**\n * Direction for drawer anchor (same as anchor edge).\n */\nexport type DrawerSwipeDirection = \"left\" | \"right\" | \"top\" | \"bottom\";\n\n/**\n * Options for useDrawerSwipeInput hook.\n */\nexport type UseDrawerSwipeInputOptions = {\n /** Container ref for edge detection zone (e.g., GridLayout container) */\n edgeContainerRef: React.RefObject<HTMLElement | null>;\n /** Drawer content ref (for close gesture) */\n drawerContentRef: React.RefObject<HTMLElement | null>;\n /** Drawer direction (anchor edge) */\n direction: DrawerSwipeDirection;\n /** Whether the drawer is currently open */\n isOpen: boolean;\n /** Callback when swipe should open the drawer */\n onSwipeOpen: () => void;\n /** Callback when swipe should close the drawer */\n onSwipeClose: () => void;\n /** Whether edge swipe to open is enabled. @default true */\n enableEdgeSwipeOpen?: boolean;\n /** Whether swipe to close is enabled. @default true */\n enableSwipeClose?: boolean;\n /** Width of edge detection zone in pixels. @default 20 */\n edgeWidth?: number;\n /** Dismiss threshold ratio (0-1). @default 0.3 */\n dismissThreshold?: number;\n};\n\n/**\n * Result from useDrawerSwipeInput hook.\n */\nexport type UseDrawerSwipeInputResult = {\n /** Current operation state */\n state: ContinuousOperationState;\n /** Whether currently opening via edge swipe */\n isOpening: boolean;\n /** Whether currently closing via drag */\n isClosing: boolean;\n /** Progress (0-1) towards open/close threshold */\n progress: number;\n /** Displacement in pixels (primary axis) */\n displacement: number;\n /** Props for edge container (open gesture zone) */\n edgeContainerProps: React.HTMLAttributes<HTMLElement> & {\n style: React.CSSProperties;\n };\n /** Props for drawer content (close gesture zone) */\n drawerContentProps: React.HTMLAttributes<HTMLElement> & {\n style: React.CSSProperties;\n };\n};\n\n/**\n * Get animation axis from direction.\n */\nexport function getDrawerAnimationAxis(direction: DrawerSwipeDirection): \"x\" | \"y\" {\n switch (direction) {\n case \"left\":\n case \"right\":\n return \"x\";\n case \"top\":\n case \"bottom\":\n return \"y\";\n }\n}\n\n/**\n * Get the sign for the close swipe direction.\n * Left drawer closes by swiping left (-1).\n * Right drawer closes by swiping right (+1).\n * Top drawer closes by swiping up (-1).\n * Bottom drawer closes by swiping down (+1).\n */\nexport function getDrawerCloseSwipeSign(direction: DrawerSwipeDirection): 1 | -1 {\n switch (direction) {\n case \"left\":\n return -1;\n case \"right\":\n return 1;\n case \"top\":\n return -1;\n case \"bottom\":\n return 1;\n }\n}\n\n/**\n * Get the sign for the open swipe direction.\n * This is the opposite of the close direction.\n */\nexport function getDrawerOpenSwipeSign(direction: DrawerSwipeDirection): 1 | -1 {\n return (getDrawerCloseSwipeSign(direction) * -1) as 1 | -1;\n}\n","/**\n * @file Hook for detecting swipe gestures to open/close a drawer.\n *\n * Combines:\n * - Edge swipe detection for opening (Stack pattern)\n * - Drag-to-close within drawer (Dialog pattern)\n * - Native gesture guard for browser back prevention\n */\nimport * as React from \"react\";\nimport { useEdgeSwipeInput } from \"../../hooks/gesture/useEdgeSwipeInput.js\";\nimport { useNativeGestureGuard } from \"../../hooks/gesture/useNativeGestureGuard.js\";\nimport { usePointerTracking } from \"../../hooks/gesture/usePointerTracking.js\";\nimport {\n mergeGestureContainerProps,\n isScrollableInDirection,\n} from \"../../hooks/gesture/utils.js\";\nimport { isInSwipeSafeZone } from \"../../components/gesture/SwipeSafeZone.js\";\nimport {\n type ContinuousOperationState,\n IDLE_CONTINUOUS_OPERATION_STATE,\n} from \"../../hooks/gesture/types.js\";\nimport type { UseDrawerSwipeInputOptions, UseDrawerSwipeInputResult } from \"./types.js\";\nimport { getDrawerAnimationAxis, getDrawerCloseSwipeSign, getDrawerOpenSwipeSign } from \"./types.js\";\n\n/**\n * Default dismiss threshold (30% of container size).\n */\nconst DEFAULT_DISMISS_THRESHOLD = 0.3;\n\n/**\n * Velocity threshold for quick flick dismissal (px/ms).\n */\nconst VELOCITY_THRESHOLD = 0.5;\n\n// ============================================================================\n// Helper functions (extracted to avoid ternary violations)\n// ============================================================================\n\nfunction getContainerSize(container: HTMLElement, axis: \"x\" | \"y\"): number {\n if (axis === \"x\") {\n return container.clientWidth;\n }\n return container.clientHeight;\n}\n\nfunction getAxisDelta(\n start: { x: number; y: number },\n current: { x: number; y: number },\n axis: \"x\" | \"y\",\n): number {\n if (axis === \"x\") {\n return current.x - start.x;\n }\n return current.y - start.y;\n}\n\nconst PHASE_MAP: Record<string, \"idle\" | \"operating\" | \"ended\"> = {\n idle: \"idle\",\n ended: \"ended\",\n};\n\nfunction normalizePhase(phase: string): \"idle\" | \"operating\" | \"ended\" {\n return PHASE_MAP[phase] ?? \"operating\";\n}\n\nfunction computeDisplacementValue(\n closeSwipeSign: 1 | -1,\n axis: \"x\" | \"y\",\n closeDisplacement: number,\n): { x: number; y: number } {\n const signedDisplacement = closeSwipeSign * closeDisplacement;\n if (axis === \"x\") {\n return { x: signedDisplacement, y: 0 };\n }\n return { x: 0, y: signedDisplacement };\n}\n\nfunction computeAxisDisplacement(\n displacement: { x: number; y: number },\n axis: \"x\" | \"y\",\n): number {\n if (axis === \"x\") {\n return Math.abs(displacement.x);\n }\n return Math.abs(displacement.y);\n}\n\nfunction isEdgeSwipeEnabled(enableEdgeSwipeOpen: boolean, isOpen: boolean): boolean {\n if (!enableEdgeSwipeOpen) {\n return false;\n }\n return !isOpen;\n}\n\nfunction isCloseSwipeEnabled(enableSwipeClose: boolean, isOpen: boolean): boolean {\n if (!enableSwipeClose) {\n return false;\n }\n return isOpen;\n}\n\nfunction isDrawerOpening(isEdgeGesture: boolean, isOpen: boolean): boolean {\n if (!isEdgeGesture) {\n return false;\n }\n return !isOpen;\n}\n\nfunction isDrawerClosing(closePhase: \"idle\" | \"operating\" | \"ended\", isOpen: boolean): boolean {\n if (closePhase === \"idle\") {\n return false;\n }\n return isOpen;\n}\n\nfunction computeVelocity(\n start: { x: number; y: number; timestamp: number } | null,\n current: { x: number; y: number; timestamp: number } | null,\n displacement: number,\n): number {\n if (!start || !current) {\n return 0;\n }\n const timeDelta = Math.max(1, current.timestamp - start.timestamp);\n return displacement / timeDelta;\n}\n\n/**\n * Hook for detecting swipe gestures to open/close a drawer.\n *\n * When drawer is closed:\n * - Detects edge swipe from the anchor edge to trigger open\n *\n * When drawer is open:\n * - Detects drag gesture within drawer to trigger close\n * - Respects scrollable content boundaries\n *\n * @example\n * ```tsx\n * const { state, edgeContainerProps, drawerContentProps } = useDrawerSwipeInput({\n * edgeContainerRef: gridLayoutRef,\n * drawerContentRef: drawerRef,\n * direction: \"left\",\n * isOpen,\n * onSwipeOpen: () => setOpen(true),\n * onSwipeClose: () => setOpen(false),\n * });\n * ```\n */\nexport function useDrawerSwipeInput(\n options: UseDrawerSwipeInputOptions,\n): UseDrawerSwipeInputResult {\n const {\n edgeContainerRef,\n drawerContentRef,\n direction,\n isOpen,\n onSwipeOpen,\n onSwipeClose,\n enableEdgeSwipeOpen = true,\n enableSwipeClose = true,\n edgeWidth = 20,\n dismissThreshold = DEFAULT_DISMISS_THRESHOLD,\n } = options;\n\n const axis = getDrawerAnimationAxis(direction);\n const closeSwipeSign = getDrawerCloseSwipeSign(direction);\n const openSwipeSign = getDrawerOpenSwipeSign(direction);\n\n // Track container size for progress calculation\n const containerSizeRef = React.useRef(0);\n\n // Measure drawer content size\n React.useLayoutEffect(() => {\n const container = drawerContentRef.current;\n if (!container) {\n return;\n }\n\n const updateSize = () => {\n containerSizeRef.current = getContainerSize(container, axis);\n };\n\n updateSize();\n\n const observer = new ResizeObserver(updateSize);\n observer.observe(container);\n\n return () => observer.disconnect();\n }, [drawerContentRef, axis]);\n\n // =========== Edge swipe to OPEN ===========\n const handleOpenSwipeEnd = React.useCallback(\n (state: { direction: 1 | -1 | 0 }) => {\n // Open when swiping in the correct direction (away from edge)\n if (state.direction === openSwipeSign) {\n onSwipeOpen();\n }\n },\n [openSwipeSign, onSwipeOpen],\n );\n\n const {\n isEdgeGesture,\n state: edgeSwipeState,\n containerProps: edgeSwipeProps,\n } = useEdgeSwipeInput({\n containerRef: edgeContainerRef,\n edge: direction,\n edgeWidth,\n enabled: isEdgeSwipeEnabled(enableEdgeSwipeOpen, isOpen),\n onSwipeEnd: handleOpenSwipeEnd,\n });\n\n // Native gesture guard for edge swipe\n const { containerProps: guardProps } = useNativeGestureGuard({\n containerRef: edgeContainerRef,\n active: isEdgeGesture,\n preventEdgeBack: true,\n preventOverscroll: true,\n edgeWidth,\n });\n\n // =========== Drag to CLOSE (Dialog pattern) ===========\n const { state: closeTracking, onPointerDown: baseClosePointerDown } = usePointerTracking({\n enabled: isCloseSwipeEnabled(enableSwipeClose, isOpen),\n });\n\n const [closePhase, setClosePhase] = React.useState<\"idle\" | \"operating\" | \"ended\">(\"idle\");\n const lastCloseDisplacementRef = React.useRef(0);\n\n // Wrap pointer down with scroll check and safe zone check\n const onClosePointerDown = React.useCallback(\n (event: React.PointerEvent) => {\n if (!enableSwipeClose || !isOpen) {\n return;\n }\n\n const container = drawerContentRef.current;\n if (!container) {\n return;\n }\n\n const target = event.target as HTMLElement;\n\n // Check if target is in a SwipeSafeZone\n if (isInSwipeSafeZone(target, container)) {\n return; // Don't start close swipe if inside safe zone\n }\n\n // Check if target is in a scrollable area that would block swipe\n if (isScrollableInDirection(target, container, axis, closeSwipeSign)) {\n return; // Don't start close swipe if inside scrollable content\n }\n\n baseClosePointerDown(event);\n },\n [enableSwipeClose, isOpen, drawerContentRef, axis, closeSwipeSign, baseClosePointerDown],\n );\n\n // Calculate close displacement\n const closeDisplacement = React.useMemo(() => {\n if (!closeTracking.isDown || !closeTracking.start || !closeTracking.current) {\n return lastCloseDisplacementRef.current;\n }\n\n const delta = getAxisDelta(closeTracking.start, closeTracking.current, axis);\n\n // Only count movement in close direction\n const signedDelta = delta * closeSwipeSign;\n return Math.max(0, signedDelta);\n }, [closeTracking.isDown, closeTracking.start, closeTracking.current, axis, closeSwipeSign]);\n\n // Track displacement while dragging\n React.useEffect(() => {\n if (closeTracking.isDown && closeTracking.current) {\n lastCloseDisplacementRef.current = closeDisplacement;\n }\n }, [closeTracking.isDown, closeTracking.current, closeDisplacement]);\n\n // Handle close drag start\n React.useEffect(() => {\n if (closeTracking.isDown && closePhase === \"idle\") {\n setClosePhase(\"operating\");\n }\n }, [closeTracking.isDown, closePhase]);\n\n // Handle close drag end\n React.useEffect(() => {\n if (!closeTracking.isDown && closePhase === \"operating\") {\n const displacement = lastCloseDisplacementRef.current;\n const hasMovement = displacement > 1;\n\n if (hasMovement) {\n setClosePhase(\"ended\");\n\n // Check if should close\n const containerSize = containerSizeRef.current;\n if (containerSize > 0) {\n const ratio = displacement / containerSize;\n const velocity = computeVelocity(closeTracking.start, closeTracking.current, displacement);\n\n if (ratio >= dismissThreshold || velocity >= VELOCITY_THRESHOLD) {\n onSwipeClose();\n }\n }\n } else {\n setClosePhase(\"idle\");\n lastCloseDisplacementRef.current = 0;\n }\n }\n }, [closeTracking.isDown, closePhase, dismissThreshold, onSwipeClose, closeTracking.start, closeTracking.current]);\n\n // Transition from ended to idle\n React.useEffect(() => {\n if (closePhase === \"ended\") {\n queueMicrotask(() => {\n setClosePhase(\"idle\");\n lastCloseDisplacementRef.current = 0;\n });\n }\n }, [closePhase]);\n\n // Reset close state when drawer closes\n React.useEffect(() => {\n if (!isOpen) {\n setClosePhase(\"idle\");\n lastCloseDisplacementRef.current = 0;\n }\n }, [isOpen]);\n\n // =========== Combined state ===========\n const isOpening = isDrawerOpening(isEdgeGesture, isOpen);\n const isClosing = isDrawerClosing(closePhase, isOpen);\n\n // Determine primary displacement based on current operation\n const displacement = React.useMemo(() => {\n if (isOpening) {\n return computeAxisDisplacement(edgeSwipeState.displacement, axis);\n }\n if (isClosing) {\n return closeDisplacement;\n }\n return 0;\n }, [isOpening, isClosing, axis, edgeSwipeState.displacement, closeDisplacement]);\n\n // Progress calculation\n const progress = React.useMemo(() => {\n const containerSize = containerSizeRef.current;\n if (containerSize <= 0) {\n return 0;\n }\n return Math.min(displacement / containerSize, 1);\n }, [displacement]);\n\n // Combined operation state\n const state = React.useMemo<ContinuousOperationState>(() => {\n if (isOpening) {\n return {\n phase: normalizePhase(edgeSwipeState.phase),\n displacement: edgeSwipeState.displacement,\n velocity: edgeSwipeState.velocity,\n };\n }\n if (isClosing) {\n return {\n phase: closePhase,\n displacement: computeDisplacementValue(closeSwipeSign, axis, closeDisplacement),\n velocity: { x: 0, y: 0 },\n };\n }\n return IDLE_CONTINUOUS_OPERATION_STATE;\n }, [isOpening, isClosing, edgeSwipeState, closePhase, closeDisplacement, axis, closeSwipeSign]);\n\n // Container props\n const edgeContainerProps = React.useMemo(\n () => mergeGestureContainerProps(edgeSwipeProps, guardProps),\n [edgeSwipeProps, guardProps],\n );\n\n const drawerContentProps = React.useMemo(() => ({\n onPointerDown: onClosePointerDown,\n style: {\n touchAction: \"none\" as const,\n userSelect: \"none\" as const,\n WebkitUserSelect: \"none\" as const,\n },\n }), [onClosePointerDown]);\n\n return {\n state,\n isOpening,\n isClosing,\n progress,\n displacement,\n edgeContainerProps,\n drawerContentProps,\n };\n}\n","/**\n * @file Drawer style computation utilities.\n *\n * Provides pure functions for computing drawer styles based on configuration.\n */\nimport type * as React from \"react\";\nimport type { DrawerBehavior } from \"../../types.js\";\nimport {\n COLOR_DRAWER_BACKDROP,\n DRAWER_TRANSITION_DURATION,\n DRAWER_TRANSITION_EASING,\n} from \"../../constants/styles.js\";\n\n/**\n * Base backdrop style shared by backdrop and edge zone.\n */\nexport const DRAWER_BACKDROP_BASE_STYLE: React.CSSProperties = {\n position: \"fixed\",\n inset: 0,\n background: COLOR_DRAWER_BACKDROP,\n};\n\n/**\n * Base drawer panel style.\n */\nexport const DRAWER_PANEL_BASE_STYLE: React.CSSProperties = {\n willChange: \"transform\",\n};\n\n/**\n * Placement-specific styles for drawer positioning.\n */\nexport type DrawerPlacement = \"left\" | \"right\" | \"top\" | \"bottom\";\n\nconst PLACEMENT_STYLES: Record<DrawerPlacement, React.CSSProperties> = {\n left: {\n top: 0,\n bottom: 0,\n left: 0,\n transform: \"translateX(-100%)\",\n },\n right: {\n top: 0,\n bottom: 0,\n right: 0,\n transform: \"translateX(100%)\",\n },\n top: {\n top: 0,\n left: 0,\n right: 0,\n transform: \"translateY(-100%)\",\n },\n bottom: {\n bottom: 0,\n left: 0,\n right: 0,\n transform: \"translateY(100%)\",\n },\n};\n\nconst OPEN_TRANSFORMS: Record<DrawerPlacement, string> = {\n left: \"translateX(0)\",\n right: \"translateX(0)\",\n top: \"translateY(0)\",\n bottom: \"translateY(0)\",\n};\n\n/**\n * Get placement-specific style.\n */\nexport function getPlacementStyle(placement: DrawerPlacement): React.CSSProperties {\n return PLACEMENT_STYLES[placement];\n}\n\n/**\n * Get transform value for open state.\n */\nexport function getOpenTransform(placement: DrawerPlacement): string {\n return OPEN_TRANSFORMS[placement];\n}\n\n/**\n * Get closed transform value.\n */\nexport function getClosedTransform(placement: DrawerPlacement): string {\n return PLACEMENT_STYLES[placement].transform as string;\n}\n\n/**\n * Compute CSS transition value.\n */\nexport function computeTransitionValue(\n mode: DrawerBehavior[\"transitionMode\"] | undefined,\n duration: DrawerBehavior[\"transitionDuration\"],\n easing: DrawerBehavior[\"transitionEasing\"],\n): string | undefined {\n if (mode === \"none\") {\n return undefined;\n }\n\n const durationValue = duration ?? DRAWER_TRANSITION_DURATION;\n const easingValue = easing ?? DRAWER_TRANSITION_EASING;\n\n return `transform ${durationValue} ${easingValue}`;\n}\n\n/**\n * Compute backdrop transition value.\n */\nexport function computeBackdropTransition(\n mode: DrawerBehavior[\"transitionMode\"] | undefined,\n duration: DrawerBehavior[\"transitionDuration\"],\n): string | undefined {\n if (mode === \"none\") {\n return undefined;\n }\n return `opacity ${duration ?? \"220ms\"} ease`;\n}\n\n/**\n * Check if placement is horizontal (left/right).\n */\nexport function isHorizontalPlacement(placement: DrawerPlacement): boolean {\n return placement === \"left\" || placement === \"right\";\n}\n\n/**\n * Format dimension value to CSS string.\n */\nexport function formatDimension(value: string | number | undefined): string | undefined {\n if (value === undefined) {\n return undefined;\n }\n if (typeof value === \"number\") {\n return `${value}px`;\n }\n return value;\n}\n\n// ============================================================================\n// Edge Zone Styles\n// ============================================================================\n\n/**\n * Options for computing edge zone style.\n */\nexport type EdgeZoneStyleOptions = {\n placement: DrawerPlacement;\n inline: boolean;\n edgeWidth: number;\n zIndex: number | undefined;\n};\n\n/**\n * Compute edge zone style based on placement and positioning context.\n *\n * The edge zone is positioned at the edge where the drawer appears from:\n * - left drawer: left edge of the container\n * - right drawer: right edge of the container\n * - top drawer: top edge of the container\n * - bottom drawer: bottom edge of the container\n *\n * When inline=true, uses absolute positioning (relative to parent container).\n * When inline=false, uses fixed positioning (relative to viewport).\n */\nexport function computeEdgeZoneStyle(options: EdgeZoneStyleOptions): React.CSSProperties {\n const { placement, inline, edgeWidth, zIndex } = options;\n const position = inline ? \"absolute\" : \"fixed\";\n const computedZIndex = zIndex !== undefined ? zIndex - 2 : 1000;\n\n return getEdgeZoneStyleByPlacement(placement, position, edgeWidth, computedZIndex);\n}\n\nfunction getEdgeZoneStyleByPlacement(\n placement: DrawerPlacement,\n position: \"absolute\" | \"fixed\",\n edgeWidth: number,\n zIndex: number,\n): React.CSSProperties {\n // Common base style\n const base: React.CSSProperties = {\n position,\n zIndex,\n background: \"transparent\",\n pointerEvents: \"auto\",\n };\n\n // Placement-specific positioning\n if (placement === \"left\") {\n return {\n ...base,\n top: 0,\n bottom: 0,\n left: 0,\n width: edgeWidth,\n };\n }\n\n if (placement === \"right\") {\n return {\n ...base,\n top: 0,\n bottom: 0,\n right: 0,\n width: edgeWidth,\n };\n }\n\n if (placement === \"top\") {\n return {\n ...base,\n top: 0,\n left: 0,\n right: 0,\n height: edgeWidth,\n };\n }\n\n // bottom\n return {\n ...base,\n bottom: 0,\n left: 0,\n right: 0,\n height: edgeWidth,\n };\n}\n","/**\n * @file Drawer swipe gesture configuration parsing.\n *\n * Normalizes swipeGestures config from DrawerBehavior into a consistent shape.\n */\nimport type { DrawerBehavior, WindowPosition } from \"../../types.js\";\nimport type { DrawerPlacement } from \"./drawerStyles.js\";\n\n/**\n * Normalized swipe gesture configuration.\n */\nexport type NormalizedSwipeConfig = {\n enabled: boolean;\n edgeSwipeOpen: boolean;\n swipeClose: boolean;\n edgeWidth: number;\n dismissThreshold: number;\n};\n\nconst DEFAULT_EDGE_WIDTH = 20;\nconst DEFAULT_DISMISS_THRESHOLD = 0.3;\n\nconst DISABLED_CONFIG: NormalizedSwipeConfig = {\n enabled: false,\n edgeSwipeOpen: false,\n swipeClose: false,\n edgeWidth: DEFAULT_EDGE_WIDTH,\n dismissThreshold: DEFAULT_DISMISS_THRESHOLD,\n};\n\nconst ENABLED_DEFAULT_CONFIG: NormalizedSwipeConfig = {\n enabled: true,\n edgeSwipeOpen: true,\n swipeClose: true,\n edgeWidth: DEFAULT_EDGE_WIDTH,\n dismissThreshold: DEFAULT_DISMISS_THRESHOLD,\n};\n\n/**\n * Parse swipeGestures config into normalized options.\n */\nexport function parseSwipeGesturesConfig(\n swipeGestures: DrawerBehavior[\"swipeGestures\"],\n): NormalizedSwipeConfig {\n if (swipeGestures === true) {\n return ENABLED_DEFAULT_CONFIG;\n }\n\n if (swipeGestures === false || swipeGestures === undefined) {\n return DISABLED_CONFIG;\n }\n\n return {\n enabled: true,\n edgeSwipeOpen: swipeGestures.edgeSwipeOpen ?? true,\n swipeClose: swipeGestures.swipeClose ?? true,\n edgeWidth: swipeGestures.edgeWidth ?? DEFAULT_EDGE_WIDTH,\n dismissThreshold: swipeGestures.dismissThreshold ?? DEFAULT_DISMISS_THRESHOLD,\n };\n}\n\n/**\n * Resolve drawer placement from anchor and position.\n */\nexport function resolvePlacement(\n anchor: DrawerBehavior[\"anchor\"],\n position: WindowPosition | undefined,\n): DrawerPlacement {\n if (anchor) {\n return anchor;\n }\n\n if (!position) {\n return \"right\";\n }\n\n if (position.left !== undefined) {\n return \"left\";\n }\n if (position.right !== undefined) {\n return \"right\";\n }\n if (position.top !== undefined) {\n return \"top\";\n }\n if (position.bottom !== undefined) {\n return \"bottom\";\n }\n\n return \"right\";\n}\n\n/**\n * Determine if edge zone should be visible.\n */\nexport function shouldShowEdgeZone(\n config: NormalizedSwipeConfig,\n isOpen: boolean,\n isOpening: boolean,\n): boolean {\n if (!config.enabled) {\n return false;\n }\n if (!config.edgeSwipeOpen) {\n return false;\n }\n // Show when closed or actively opening\n if (!isOpen) {\n return true;\n }\n return isOpening;\n}\n","/**\n * @file Hook for applying real-time transform during drawer swipe gestures.\n *\n * Handles DOM manipulation for smooth swipe animations.\n */\nimport * as React from \"react\";\nimport type { ContinuousOperationState } from \"../../hooks/gesture/types.js\";\nimport { getDrawerAnimationAxis, getDrawerCloseSwipeSign } from \"../../modules/drawer/types.js\";\nimport type { DrawerSwipeDirection } from \"../../modules/drawer/types.js\";\n\ntype UseDrawerSwipeTransformOptions = {\n drawerRef: React.RefObject<HTMLDivElement | null>;\n backdropRef: React.RefObject<HTMLDivElement | null>;\n placement: DrawerSwipeDirection;\n swipeState: ContinuousOperationState;\n displacement: number;\n isOpening: boolean;\n isClosing: boolean;\n enabled: boolean;\n};\n\n/**\n * Apply real-time transform to drawer and backdrop during swipe.\n */\nexport function useDrawerSwipeTransform(options: UseDrawerSwipeTransformOptions): void {\n const {\n drawerRef,\n backdropRef,\n placement,\n swipeState,\n displacement,\n isOpening,\n isClosing,\n enabled,\n } = options;\n\n const isOperating = swipeState.phase === \"operating\";\n\n // Apply real-time transform during swipe\n React.useLayoutEffect(() => {\n if (!enabled || !isOperating) {\n return;\n }\n\n const drawer = drawerRef.current;\n const backdrop = backdropRef.current;\n\n if (!drawer) {\n return;\n }\n\n const axis = getDrawerAnimationAxis(placement);\n const closeSign = getDrawerCloseSwipeSign(placement);\n const drawerSize = axis === \"x\" ? drawer.clientWidth : drawer.clientHeight;\n\n if (drawerSize <= 0) {\n return;\n }\n\n const translateFn = axis === \"x\" ? \"translateX\" : \"translateY\";\n\n if (isClosing) {\n applyClosingTransform(drawer, backdrop, translateFn, closeSign, displacement, drawerSize);\n } else if (isOpening) {\n applyOpeningTransform(drawer, backdrop, translateFn, closeSign, displacement, drawerSize);\n }\n }, [enabled, isOperating, isClosing, isOpening, displacement, placement, drawerRef, backdropRef]);\n\n // Reset transform after swipe ends\n React.useLayoutEffect(() => {\n if (!enabled || swipeState.phase !== \"ended\") {\n return;\n }\n\n const drawer = drawerRef.current;\n const backdrop = backdropRef.current;\n\n if (drawer) {\n drawer.style.transform = \"\";\n }\n if (backdrop) {\n backdrop.style.opacity = \"\";\n }\n }, [enabled, swipeState.phase, drawerRef, backdropRef]);\n}\n\nfunction applyClosingTransform(\n drawer: HTMLDivElement,\n backdrop: HTMLDivElement | null,\n translateFn: \"translateX\" | \"translateY\",\n closeSign: 1 | -1,\n displacement: number,\n drawerSize: number,\n): void {\n const translate = closeSign * displacement;\n drawer.style.transform = `${translateFn}(${translate}px)`;\n\n const progress = Math.min(displacement / drawerSize, 1);\n if (backdrop) {\n backdrop.style.opacity = String(1 - progress);\n }\n}\n\nfunction applyOpeningTransform(\n drawer: HTMLDivElement,\n backdrop: HTMLDivElement | null,\n translateFn: \"translateX\" | \"translateY\",\n closeSign: 1 | -1,\n displacement: number,\n drawerSize: number,\n): void {\n const closedPosition = closeSign * drawerSize;\n const translate = closedPosition + closeSign * -1 * displacement;\n const clampedTranslate = clampTranslate(translate, closeSign);\n drawer.style.transform = `${translateFn}(${clampedTranslate}px)`;\n\n const progress = Math.min(displacement / drawerSize, 1);\n if (backdrop) {\n backdrop.style.opacity = String(progress);\n backdrop.style.pointerEvents = \"auto\";\n }\n}\n\nfunction clampTranslate(translate: number, closeSign: 1 | -1): number {\n if (closeSign > 0) {\n return Math.max(0, translate);\n }\n return Math.min(0, translate);\n}\n","/**\n * @file Drawer component\n *\n * Mobile-friendly slide-in panel with backdrop support.\n * Supports swipe gestures for opening/closing.\n */\nimport * as React from \"react\";\nimport type { DrawerBehavior, WindowPosition } from \"../../types.js\";\nimport {\n FloatingPanelCloseButton,\n FloatingPanelContent,\n FloatingPanelFrame,\n FloatingPanelHeader,\n FloatingPanelTitle,\n} from \"../paneling/FloatingPanelFrame.js\";\nimport {\n DRAWER_HEADER_PADDING_Y,\n DRAWER_HEADER_PADDING_X,\n DRAWER_HEADER_GAP,\n DRAWER_CONTENT_PADDING,\n} from \"../../constants/styles.js\";\nimport { useDrawerSwipeInput } from \"../../modules/drawer/useDrawerSwipeInput.js\";\nimport type { DrawerSwipeDirection } from \"../../modules/drawer/types.js\";\nimport {\n DRAWER_BACKDROP_BASE_STYLE,\n DRAWER_PANEL_BASE_STYLE,\n getPlacementStyle,\n getOpenTransform,\n computeTransitionValue,\n computeBackdropTransition,\n formatDimension,\n computeEdgeZoneStyle,\n} from \"./drawerStyles.js\";\nimport type { DrawerPlacement } from \"./drawerStyles.js\";\nimport {\n parseSwipeGesturesConfig,\n resolvePlacement,\n shouldShowEdgeZone,\n} from \"./drawerSwipeConfig.js\";\nimport { useDrawerSwipeTransform } from \"./useDrawerSwipeTransform.js\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type DrawerProps = {\n id: string;\n config: DrawerBehavior;\n isOpen: boolean;\n onClose: () => void;\n onOpen?: () => void;\n children: React.ReactNode;\n zIndex?: number;\n width?: string | number;\n height?: string | number;\n position?: WindowPosition;\n};\n\n// ============================================================================\n// Sub-components\n// ============================================================================\n\ntype DrawerContentProps = {\n chrome: boolean;\n frameStyle: React.CSSProperties;\n header?: DrawerBehavior[\"header\"];\n dismissible: boolean;\n onClose: () => void;\n children: React.ReactNode;\n};\n\nconst DrawerContent: React.FC<DrawerContentProps> = ({\n chrome,\n frameStyle,\n header,\n dismissible,\n onClose,\n children,\n}) => {\n if (!chrome) {\n return <>{children}</>;\n }\n return (\n <FloatingPanelFrame style={frameStyle}>\n <DrawerHeaderView header={header} dismissible={dismissible} onClose={onClose} />\n <FloatingPanelContent\n style={{ padding: DRAWER_CONTENT_PADDING, flex: 1, display: \"flex\", flexDirection: \"column\" }}\n >\n {children}\n </FloatingPanelContent>\n </FloatingPanelFrame>\n );\n};\n\ntype DrawerHeaderViewProps = {\n header?: DrawerBehavior[\"header\"];\n dismissible: boolean;\n onClose: () => void;\n};\n\nfunction shouldShowCloseButton(dismissible: boolean, showCloseButton: boolean): boolean {\n if (!dismissible) {\n return false;\n }\n return showCloseButton;\n}\n\nfunction renderCloseButton(\n shouldShow: boolean,\n onClose: () => void,\n): React.ReactNode {\n if (!shouldShow) {\n return null;\n }\n return (\n <FloatingPanelCloseButton\n onClick={onClose}\n aria-label=\"Close drawer\"\n style={{ marginLeft: \"auto\" }}\n />\n );\n}\n\nfunction renderEdgeZone(\n showEdgeZone: boolean,\n edgeZoneRef: React.RefObject<HTMLDivElement | null>,\n edgeZoneStyle: React.CSSProperties,\n onPointerDown: ((e: React.PointerEvent<HTMLElement>) => void) | undefined,\n placement: string,\n): React.ReactNode {\n if (!showEdgeZone) {\n return null;\n }\n return (\n <div\n ref={edgeZoneRef}\n style={edgeZoneStyle}\n onPointerDown={onPointerDown}\n data-drawer-edge-zone={placement}\n />\n );\n}\n\nconst DrawerHeaderView: React.FC<DrawerHeaderViewProps> = ({ header, dismissible, onClose }) => {\n if (!header) {\n return null;\n }\n\n const showCloseButton = header.showCloseButton ?? true;\n const shouldShow = shouldShowCloseButton(dismissible, showCloseButton);\n\n return (\n <FloatingPanelHeader\n style={{ padding: `${DRAWER_HEADER_PADDING_Y} ${DRAWER_HEADER_PADDING_X}`, gap: DRAWER_HEADER_GAP }}\n >\n <FloatingPanelTitle>{header.title}</FloatingPanelTitle>\n {renderCloseButton(shouldShow, onClose)}\n </FloatingPanelHeader>\n );\n};\n\n// ============================================================================\n// Style computation hooks\n// ============================================================================\n\nfunction useDrawerPanelStyle(\n placement: DrawerPlacement,\n isOpen: boolean,\n isSwipeOperating: boolean,\n config: DrawerBehavior,\n dimensions: { width?: string | number; height?: string | number; zIndex?: number },\n): React.CSSProperties {\n return React.useMemo((): React.CSSProperties => {\n const effectiveMode = isSwipeOperating ? \"none\" : config.transitionMode;\n const transitionValue = computeTransitionValue(\n effectiveMode,\n config.transitionDuration,\n config.transitionEasing,\n );\n\n const placementStyle = getPlacementStyle(placement);\n const transform = isOpen ? getOpenTransform(placement) : placementStyle.transform;\n const position = config.inline ? \"absolute\" : \"fixed\";\n\n return {\n ...DRAWER_PANEL_BASE_STYLE,\n position,\n ...placementStyle,\n transform,\n transition: transitionValue,\n zIndex: dimensions.zIndex,\n width: formatDimension(dimensions.width),\n height: formatDimension(dimensions.height),\n };\n }, [placement, isOpen, isSwipeOperating, config, dimensions]);\n}\n\nfunction useBackdropStyle(\n placement: DrawerPlacement,\n isOpen: boolean,\n isSwipeOperating: boolean,\n config: DrawerBehavior,\n zIndex: number | undefined,\n): React.CSSProperties {\n return React.useMemo((): React.CSSProperties => {\n const effectiveMode = isSwipeOperating ? \"none\" : config.transitionMode;\n const transitionValue = computeBackdropTransition(effectiveMode, config.transitionDuration);\n const position = config.inline ? \"absolute\" as const : \"fixed\" as const;\n\n return {\n ...DRAWER_BACKDROP_BASE_STYLE,\n position,\n opacity: isOpen ? 1 : 0,\n pointerEvents: isOpen ? \"auto\" : \"none\",\n transition: transitionValue,\n zIndex: zIndex !== undefined ? zIndex - 1 : undefined,\n };\n }, [isOpen, isSwipeOperating, config, zIndex]);\n}\n\nfunction useFrameStyle(placement: DrawerPlacement): React.CSSProperties {\n return React.useMemo((): React.CSSProperties => {\n const style: React.CSSProperties = { borderRadius: 0 };\n if (placement === \"left\" || placement === \"right\") {\n style.height = \"100%\";\n }\n return style;\n }, [placement]);\n}\n\n// ============================================================================\n// Main Component\n// ============================================================================\n\nexport const Drawer: React.FC<DrawerProps> = ({\n id,\n config,\n isOpen,\n onClose,\n onOpen,\n children,\n zIndex,\n width,\n height,\n position,\n}) => {\n const {\n dismissible = true,\n header,\n chrome = true,\n inline = false,\n } = config;\n\n const swipeConfig = parseSwipeGesturesConfig(config.swipeGestures);\n const placement = resolvePlacement(config.anchor, position);\n\n // Refs\n const drawerRef = React.useRef<HTMLDivElement>(null);\n const backdropRef = React.useRef<HTMLDivElement>(null);\n const edgeZoneRef = React.useRef<HTMLDivElement>(null);\n\n // Swipe callbacks\n const handleSwipeOpen = React.useCallback(() => {\n onOpen?.();\n config.onStateChange?.(true);\n }, [onOpen, config]);\n\n const handleSwipeClose = React.useCallback(() => {\n onClose();\n }, [onClose]);\n\n // Swipe input handling\n const {\n state: swipeState,\n displacement,\n edgeContainerProps,\n drawerContentProps,\n isOpening,\n isClosing,\n } = useDrawerSwipeInput({\n edgeContainerRef: edgeZoneRef,\n drawerContentRef: drawerRef,\n direction: placement as DrawerSwipeDirection,\n isOpen,\n onSwipeOpen: handleSwipeOpen,\n onSwipeClose: handleSwipeClose,\n enableEdgeSwipeOpen: swipeConfig.edgeSwipeOpen,\n enableSwipeClose: swipeConfig.swipeClose,\n edgeWidth: swipeConfig.edgeWidth,\n dismissThreshold: swipeConfig.dismissThreshold,\n });\n\n const isSwipeOperating = swipeState.phase === \"operating\";\n\n // Apply swipe transform\n useDrawerSwipeTransform({\n drawerRef,\n backdropRef,\n placement: placement as DrawerSwipeDirection,\n swipeState,\n displacement,\n isOpening,\n isClosing,\n enabled: swipeConfig.enabled,\n });\n\n // Computed styles\n const drawerStyle = useDrawerPanelStyle(placement, isOpen, isSwipeOperating, config, { width, height, zIndex });\n const backdropStyle = useBackdropStyle(placement, isOpen, isSwipeOperating, config, zIndex);\n const frameStyle = useFrameStyle(placement);\n\n // Edge zone style: merge positioning style with gesture handlers' style\n const edgeZoneStyle = React.useMemo((): React.CSSProperties => {\n const positioningStyle = computeEdgeZoneStyle({\n placement,\n inline,\n edgeWidth: swipeConfig.edgeWidth,\n zIndex,\n });\n // Merge with gesture container styles (touchAction, etc.)\n return { ...positioningStyle, ...edgeContainerProps.style };\n }, [placement, inline, swipeConfig.edgeWidth, zIndex, edgeContainerProps.style]);\n\n // Merged drawer style with swipe props\n const mergedDrawerStyle = React.useMemo((): React.CSSProperties => {\n if (!swipeConfig.enabled) {\n return drawerStyle;\n }\n return { ...drawerStyle, ...drawerContentProps.style };\n }, [swipeConfig.enabled, drawerStyle, drawerContentProps.style]);\n\n // Visibility flags\n const showEdgeZone = shouldShowEdgeZone(swipeConfig, isOpen, isOpening);\n const ariaLabel = header?.title ?? config.ariaLabel ?? \"Drawer\";\n\n const edgeZoneElement = renderEdgeZone(showEdgeZone, edgeZoneRef, edgeZoneStyle, edgeContainerProps.onPointerDown, placement);\n\n return (\n <>\n {edgeZoneElement}\n <div\n ref={backdropRef}\n style={backdropStyle}\n onClick={dismissible ? onClose : undefined}\n />\n <div\n ref={drawerRef}\n data-layer-id={id}\n data-placement={placement}\n style={mergedDrawerStyle}\n role=\"dialog\"\n aria-modal={dismissible ? true : undefined}\n aria-hidden={isOpen ? undefined : true}\n aria-label={ariaLabel}\n onPointerDown={swipeConfig.enabled ? drawerContentProps.onPointerDown : undefined}\n >\n <DrawerContent\n chrome={chrome}\n frameStyle={frameStyle}\n header={header}\n dismissible={dismissible}\n onClose={onClose}\n >\n {children}\n </DrawerContent>\n </div>\n </>\n );\n};\n","/**\n * @file Generic transition state management with animation support.\n */\nimport * as React from \"react\";\n\nexport type TransitionMode = \"none\" | \"css\";\n\nexport type TransitionOptions = {\n mode?: TransitionMode;\n element?: React.RefObject<HTMLElement>;\n duration?: number;\n};\n\nexport type UseTransitionStateOptions = {\n onOpen?: (id: string) => void;\n onClose?: (id: string) => void;\n onTransitionEnd?: (id: string, isOpen: boolean) => void;\n};\n\nconst waitForTransitionEnd = (el: HTMLElement, timeout: number): Promise<void> =>\n new Promise((resolve) => {\n // eslint-disable-next-line no-restricted-syntax -- mutable flag needed for deduplication\n let resolved = false;\n const done = () => {\n if (resolved) {return;}\n resolved = true;\n el.removeEventListener(\"transitionend\", handler);\n resolve();\n };\n const handler = (e: TransitionEvent) => {\n if (e.target === el) {done();}\n };\n el.addEventListener(\"transitionend\", handler);\n setTimeout(done, timeout + 50);\n });\n\nexport const runTransition = async (\n update: () => void,\n mode: TransitionMode,\n el: HTMLElement | null | undefined,\n duration: number,\n): Promise<void> => {\n switch (mode) {\n case \"none\":\n update();\n return;\n\n case \"css\":\n update();\n if (el) {await waitForTransitionEnd(el, duration);}\n return;\n }\n};\n\nexport const useTransitionState = (options?: UseTransitionStateOptions) => {\n const [states, setStates] = React.useState<Record<string, boolean>>({});\n const optionsRef = React.useRef(options);\n optionsRef.current = options;\n\n const update = React.useCallback(\n async (id: string, isOpen: boolean, transitionOptions?: TransitionOptions) => {\n const { mode = \"none\", element, duration = 300 } = transitionOptions ?? {};\n\n const applyState = () => {\n setStates((prev) => {\n if (prev[id] === isOpen) {return prev;}\n return { ...prev, [id]: isOpen };\n });\n };\n\n await runTransition(applyState, mode, element?.current, duration);\n\n const opts = optionsRef.current;\n if (isOpen) {\n opts?.onOpen?.(id);\n } else {\n opts?.onClose?.(id);\n }\n opts?.onTransitionEnd?.(id, isOpen);\n },\n [],\n );\n\n const state = React.useCallback((id: string): boolean => states[id] ?? false, [states]);\n const open = React.useCallback(\n (id: string, opts?: TransitionOptions) => update(id, true, opts),\n [update],\n );\n const close = React.useCallback(\n (id: string, opts?: TransitionOptions) => update(id, false, opts),\n [update],\n );\n\n return { state, open, close };\n};\n","/**\n * @file Hook for managing drawer state (controlled/uncontrolled)\n */\nimport * as React from \"react\";\nimport {\n type TransitionMode,\n type TransitionOptions,\n runTransition,\n} from \"../../hooks/useTransitionState\";\nimport type { LayerDefinition } from \"../../types\";\n\nconst parseDuration = (value: string | undefined): number => {\n if (!value) {return 300;}\n const match = value.match(/(\\d+)/);\n return match ? parseInt(match[1], 10) : 300;\n};\n\nexport const useDrawerState = (layers: LayerDefinition[]) => {\n const [drawerStates, setDrawerStates] = React.useState<Record<string, boolean>>(() => {\n const initial: Record<string, boolean> = {};\n layers.forEach((layer) => {\n if (layer.drawer) {\n initial[layer.id] = layer.drawer.defaultOpen ?? false;\n }\n });\n return initial;\n });\n\n const layerMap = React.useMemo(() => {\n const map = new Map<string, LayerDefinition>();\n layers.forEach((layer) => map.set(layer.id, layer));\n return map;\n }, [layers]);\n\n const updateState = React.useCallback(\n async (layerId: string, isOpen: boolean, options?: TransitionOptions) => {\n const layer = layerMap.get(layerId);\n if (!layer?.drawer) {return;}\n\n const mode: TransitionMode = options?.mode ?? layer.drawer.transitionMode ?? \"css\";\n const duration = options?.duration ?? parseDuration(layer.drawer.transitionDuration);\n const element = options?.element?.current;\n\n const applyState = () => {\n if (layer.drawer?.open === undefined) {\n setDrawerStates((prev) => {\n if (prev[layerId] === isOpen) {return prev;}\n return { ...prev, [layerId]: isOpen };\n });\n }\n layer.drawer?.onStateChange?.(isOpen);\n };\n\n await runTransition(applyState, mode, element, duration);\n },\n [layerMap],\n );\n\n const state = React.useCallback(\n (layerId: string): boolean => {\n const layer = layerMap.get(layerId);\n if (layer?.drawer?.open !== undefined) {\n return layer.drawer.open;\n }\n return drawerStates[layerId] ?? false;\n },\n [layerMap, drawerStates],\n );\n\n const open = React.useCallback(\n (id: string, options?: TransitionOptions) => updateState(id, true, options),\n [updateState],\n );\n\n const close = React.useCallback(\n (id: string, options?: TransitionOptions) => updateState(id, false, options),\n [updateState],\n );\n\n return { state, open, close };\n};\n","/**\n * @file DrawerLayers component\n */\nimport * as React from \"react\";\nimport type { LayerDefinition } from \"../../types.js\";\nimport { Drawer } from \"./Drawer.js\";\nimport { useDrawerState } from \"../../modules/window/useDrawerState.js\";\n\nexport type DrawerLayersProps = {\n layers: LayerDefinition[];\n};\n\nexport const DrawerLayers: React.FC<DrawerLayersProps> = ({ layers }) => {\n const drawer = useDrawerState(layers);\n\n const drawerLayers = React.useMemo(() => layers.filter((layer) => layer.drawer), [layers]);\n\n const closeHandlers = React.useMemo(() => {\n const handlers = new Map<string, () => void>();\n drawerLayers.forEach((layer) => {\n handlers.set(layer.id, () => drawer.close(layer.id));\n });\n return handlers;\n }, [drawerLayers, drawer.close]);\n\n const openHandlers = React.useMemo(() => {\n const handlers = new Map<string, () => void>();\n drawerLayers.forEach((layer) => {\n handlers.set(layer.id, () => drawer.open(layer.id));\n });\n return handlers;\n }, [drawerLayers, drawer.open]);\n\n return (\n <>\n {drawerLayers.map((layer) => {\n if (!layer.drawer) {\n return null;\n }\n\n const isOpen = drawer.state(layer.id);\n const onClose = closeHandlers.get(layer.id);\n const onOpen = openHandlers.get(layer.id);\n\n if (!onClose) {\n return null;\n }\n\n return (\n <Drawer\n key={layer.id}\n id={layer.id}\n config={layer.drawer}\n isOpen={isOpen}\n onClose={onClose}\n onOpen={onOpen}\n zIndex={layer.zIndex}\n width={layer.width}\n height={layer.height}\n position={layer.position}\n >\n {layer.component}\n </Drawer>\n );\n })}\n </>\n );\n};\n","/**\n * @file Context provider for grid layer rendering helpers.\n */\nimport * as React from \"react\";\nimport type { LayerDefinition } from \"../../types\";\n\nexport type GridLayerHandleProps = React.HTMLAttributes<HTMLElement> & {\n \"data-drag-handle\": \"true\";\n};\n\nexport type ResizeHandleConfig =\n | {\n key: \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\";\n variant: \"corner\";\n horizontal: \"left\" | \"right\";\n vertical: \"top\" | \"bottom\";\n }\n | {\n key: \"left\" | \"right\" | \"top\" | \"bottom\";\n variant: \"edge\";\n horizontal?: \"left\" | \"right\";\n vertical?: \"top\" | \"bottom\";\n };\n\nexport type GridLayerRenderState = {\n style: React.CSSProperties;\n isResizable: boolean;\n isResizing: boolean;\n onResizeHandlePointerDown: (config: ResizeHandleConfig, event: React.PointerEvent<HTMLDivElement>) => void;\n};\n\nexport type GridLayoutContextValue = {\n handleLayerPointerDown: (event: React.PointerEvent<HTMLDivElement>) => void;\n getLayerRenderState: (layer: LayerDefinition) => GridLayerRenderState;\n getLayerHandleProps: (layerId: string) => GridLayerHandleProps;\n /**\n * Whether the GridLayout is mounted at root level.\n * When true, scrollable layers should delegate to browser's native scroll.\n */\n isRootLevel: boolean;\n};\n\nconst GridLayoutContext = React.createContext<GridLayoutContextValue | null>(null);\n\nexport const GridLayoutProvider: React.FC<\n React.PropsWithChildren<{ value: GridLayoutContextValue }>\n> = ({ value, children }) => {\n return <GridLayoutContext.Provider value={value}>{children}</GridLayoutContext.Provider>;\n};\n\nexport const useGridLayoutContext = (): GridLayoutContextValue => {\n const context = React.useContext(GridLayoutContext);\n if (!context) {\n throw new Error(\"useGridLayoutContext must be used within a GridLayoutProvider.\");\n }\n return context;\n};\n","/**\n * @file PanelSystemContext\n *\n * Core provider for panel definitions and registry. Grid-specific layout and\n * interactions are composed by UI layers (e.g., GridLayout) on top of this.\n *\n * Includes content caching to preserve React component state across re-renders.\n * This is essential for maintaining internal state when parent components\n * re-create the layers array.\n */\nimport * as React from \"react\";\nimport type { PanelLayoutConfig, LayerDefinition } from \"./types\";\nimport { useContentCache } from \"./hooks/useContentCache\";\n\nexport type PanelSystemContextValue = {\n config: PanelLayoutConfig;\n style?: React.CSSProperties;\n layers: {\n /** Raw panel definitions (no grid normalization). */\n defs: LayerDefinition[];\n /** Fast lookup map by id for consumers. */\n layerById: Map<string, LayerDefinition>;\n };\n /**\n * Get cached content for a layer. Returns the same ReactNode reference\n * for the same layer ID to prevent remounting on parent re-renders.\n */\n getCachedContent: (layerId: string) => React.ReactNode | null;\n};\n\nconst PanelSystemContext = React.createContext<PanelSystemContextValue | null>(null);\n\nexport const usePanelSystem = (): PanelSystemContextValue => {\n const ctx = React.useContext(PanelSystemContext);\n if (!ctx) {\n throw new Error(\"usePanelSystem must be used within a PanelSystemProvider.\");\n }\n return ctx;\n};\n\nexport type PanelSystemProviderProps = React.PropsWithChildren<{\n config: PanelLayoutConfig;\n layers: LayerDefinition[];\n style?: React.CSSProperties;\n}>;\n\nexport const PanelSystemProvider: React.FC<PanelSystemProviderProps> = ({ config, layers, style, children }) => {\n const layerById = React.useMemo(() => {\n const map = new Map<string, LayerDefinition>();\n layers.forEach((layer) => {\n map.set(layer.id, layer);\n });\n return map;\n }, [layers]);\n\n // Content resolver for useContentCache\n const resolveContent = React.useCallback(\n (layerId: string): React.ReactNode | null => {\n const layer = layerById.get(layerId);\n return layer?.component ?? null;\n },\n [layerById],\n );\n\n // Valid IDs for cache cleanup\n const validIds = React.useMemo(() => layers.map((l) => l.id), [layers]);\n\n // Use shared content cache hook\n const { getCachedContent } = useContentCache({\n resolveContent,\n validIds,\n });\n\n const value = React.useMemo<PanelSystemContextValue>(\n () => ({\n config,\n style,\n layers: {\n defs: layers,\n layerById,\n },\n getCachedContent,\n }),\n [config, style, layers, layerById, getCachedContent],\n );\n\n return <PanelSystemContext.Provider value={value}>{children}</PanelSystemContext.Provider>;\n};\n","/**\n * @file Context exposing the current grid layer id and helpers to child components.\n */\nimport * as React from \"react\";\nimport type { LayerDefinition } from \"../../types\";\nimport { usePanelSystem } from \"../../PanelSystemContext\";\nimport { useGridLayoutContext, type GridLayerHandleProps } from \"./GridLayoutContext\";\n\ntype LayerInstanceContextValue = {\n layerId: string;\n};\n\nconst LayerInstanceContext = React.createContext<LayerInstanceContextValue | null>(null);\n\nexport type LayerInstanceProviderProps = React.PropsWithChildren<LayerInstanceContextValue>;\n\nexport const LayerInstanceProvider: React.FC<LayerInstanceProviderProps> = ({ layerId, children }) => {\n const value = React.useMemo(() => ({ layerId }), [layerId]);\n return <LayerInstanceContext.Provider value={value}>{children}</LayerInstanceContext.Provider>;\n};\n\nexport const useLayerInstance = (): LayerInstanceContextValue => {\n const value = React.useContext(LayerInstanceContext);\n if (!value) {\n throw new Error(\"useLayerInstance must be used within a LayerInstanceProvider.\");\n }\n return value;\n};\n\n/**\n * Convenience: read the current layer definition from the core registry.\n */\nexport const useCurrentLayerDefinition = (): LayerDefinition => {\n const { layerId } = useLayerInstance();\n const { layers } = usePanelSystem();\n const def = layers.layerById.get(layerId);\n if (!def) {\n throw new Error(`Layer definition not found for id: ${layerId}`);\n }\n return def;\n};\n\n/**\n * Convenience: get drag handle props, pre-bound to the current layer.\n */\nexport const useCurrentLayerHandleProps = (): GridLayerHandleProps => {\n const { layerId } = useLayerInstance();\n const { getLayerHandleProps } = useGridLayoutContext();\n return React.useMemo(() => getLayerHandleProps(layerId), [getLayerHandleProps, layerId]);\n};\n\n/**\n * Compatibility helper for existing code using useLayerDragHandle.\n * Prefer useCurrentLayerHandleProps for direct access.\n */\nexport const useLayerDragHandleProps = useCurrentLayerHandleProps;\n","/**\n * @file Renders floating layers inside a dedicated browser popup window.\n */\nimport * as React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type { LayerDefinition, PopupWindowOptions, WindowPosition, WindowBounds } from \"../../types\";\nimport { LayerInstanceProvider } from \"../../modules/grid/LayerInstanceContext\";\n\nconst ensureNumericOffset = (value: number | string | undefined, key: keyof WindowPosition, layerId: string): number => {\n if (typeof value === \"number\" && Number.isFinite(value)) {\n return value;\n }\n throw new Error(`Popup layer \"${layerId}\" requires a numeric \"${key}\" value.`);\n};\n\nconst resolvePopupAnchor = (position: WindowPosition | undefined, layerId: string): { left: number; top: number } => {\n if (!position) {\n throw new Error(`Popup layer \"${layerId}\" must define position (left/top).`);\n }\n return {\n left: ensureNumericOffset(position.left, \"left\", layerId),\n top: ensureNumericOffset(position.top, \"top\", layerId),\n };\n};\n\nconst numericFeature = (value: number): string => {\n return `${Math.round(value)}`;\n};\n\nconst booleanFeature = (value: boolean | undefined): string | undefined => {\n if (value === undefined) {\n return undefined;\n }\n return value ? \"yes\" : \"no\";\n};\n\nconst buildWindowFeatures = (\n layerId: string,\n position: WindowPosition | undefined,\n width: number | string | undefined,\n height: number | string | undefined,\n options: PopupWindowOptions | undefined,\n): string => {\n const features: Record<string, string> = {};\n const anchor = resolvePopupAnchor(position, layerId);\n\n if (typeof width !== \"number\" || typeof height !== \"number\") {\n throw new Error(`Popup layer \"${layerId}\" requires numeric width/height.`);\n }\n features.width = numericFeature(width);\n features.height = numericFeature(height);\n features.left = numericFeature(anchor.left);\n features.top = numericFeature(anchor.top);\n\n const overrides = options?.features;\n if (overrides) {\n const toolbar = booleanFeature(overrides.toolbar);\n const menubar = booleanFeature(overrides.menubar);\n const location = booleanFeature(overrides.location);\n const status = booleanFeature(overrides.status);\n const resizable = booleanFeature(overrides.resizable);\n const scrollbars = booleanFeature(overrides.scrollbars);\n\n if (toolbar !== undefined) {\n features.toolbar = toolbar;\n }\n if (menubar !== undefined) {\n features.menubar = menubar;\n }\n if (location !== undefined) {\n features.location = location;\n }\n if (status !== undefined) {\n features.status = status;\n }\n if (resizable !== undefined) {\n features.resizable = resizable;\n }\n if (scrollbars !== undefined) {\n features.scrollbars = scrollbars;\n }\n }\n\n return Object.entries(features)\n .map(([key, value]) => `${key}=${value}`)\n .join(\",\");\n};\n\nconst applyBoundsToWindow = (\n popupWindow: Window,\n layerId: string,\n position: WindowPosition | undefined,\n width: number | string | undefined,\n height: number | string | undefined,\n) => {\n const anchor = resolvePopupAnchor(position, layerId);\n if (typeof width !== \"number\" || typeof height !== \"number\") {\n throw new Error(`Popup layer \"${layerId}\" requires numeric width/height.`);\n }\n popupWindow.moveTo(Math.round(anchor.left), Math.round(anchor.top));\n popupWindow.resizeTo(Math.round(width), Math.round(height));\n};\n\ntype PopupLayerPortalProps = {\n layer: LayerDefinition;\n};\n\nexport const PopupLayerPortal: React.FC<PopupLayerPortalProps> = ({ layer }) => {\n const floating = layer.floating;\n if (!floating) {\n throw new Error(`Layer \"${layer.id}\" is missing floating configuration required for popup mode.`);\n }\n const mode = floating.mode ?? \"embedded\";\n if (mode !== \"popup\") {\n throw new Error(`PopupLayerPortal received layer \"${layer.id}\" that is not configured for popup mode.`);\n }\n\n const containerRef = React.useRef<HTMLDivElement | null>(null);\n const popupWindowRef = React.useRef<Window | null>(null);\n const [isMounted, setIsMounted] = React.useState(false);\n\n React.useEffect(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n\n const features = buildWindowFeatures(layer.id, layer.position, layer.width, layer.height, floating.popup);\n const windowName = floating.popup?.name ?? layer.id;\n const createdWindow = resolvePopupWindow(\n windowName,\n features,\n {\n position: layer.position,\n size: { width: layer.width as number, height: layer.height as number },\n },\n floating.popup,\n );\n\n if (!createdWindow) {\n throw new Error(`Failed to open popup window for layer \"${layer.id}\".`);\n }\n\n const openedWindow = createdWindow;\n\n popupWindowRef.current = openedWindow;\n\n if (floating.popup?.focus !== false) {\n openedWindow.focus();\n }\n\n if (!openedWindow.document.title) {\n openedWindow.document.title = layer.id;\n }\n openedWindow.document.body.innerHTML = \"\";\n const mountNode = openedWindow.document.createElement(\"div\");\n mountNode.dataset.layerId = layer.id;\n openedWindow.document.body.appendChild(mountNode);\n containerRef.current = mountNode;\n setIsMounted(true);\n\n applyBoundsToWindow(openedWindow, layer.id, layer.position, layer.width, layer.height);\n\n const handleBeforeUnload = () => {\n popupWindowRef.current = null;\n containerRef.current = null;\n setIsMounted(false);\n };\n openedWindow.addEventListener(\"beforeunload\", handleBeforeUnload);\n\n return () => {\n openedWindow.removeEventListener(\"beforeunload\", handleBeforeUnload);\n if (floating.popup?.closeOnUnmount !== false) {\n openedWindow.close();\n }\n popupWindowRef.current = null;\n containerRef.current = null;\n setIsMounted(false);\n };\n }, [\n floating.popup?.closeOnUnmount,\n floating.popup?.features?.location,\n floating.popup?.features?.menubar,\n floating.popup?.features?.resizable,\n floating.popup?.features?.scrollbars,\n floating.popup?.features?.status,\n floating.popup?.features?.toolbar,\n floating.popup?.focus,\n floating.popup?.name,\n layer.id,\n ]);\n\n React.useEffect(() => {\n const popupWindow = popupWindowRef.current;\n if (!popupWindow) {\n return;\n }\n applyBoundsToWindow(popupWindow, layer.id, layer.position, layer.width, layer.height);\n }, [layer.position?.left, layer.position?.top, layer.height, layer.width, layer.id]);\n\n if (!isMounted || !containerRef.current) {\n return null;\n }\n\n return createPortal(<LayerInstanceProvider layerId={layer.id}>{layer.component}</LayerInstanceProvider>, containerRef.current);\n};\n\nconst resolvePopupWindow = (\n windowName: string,\n features: string,\n bounds: WindowBounds,\n options: PopupWindowOptions | undefined,\n): Window | null => {\n const customFactory = options?.createWindow;\n if (customFactory) {\n return customFactory({ name: windowName, features, bounds });\n }\n return window.open(\"\", windowName, features);\n};\n","/**\n * @file FloatingWindow component with chrome support\n *\n * Renders floating panel content with optional built-in chrome (FloatingPanelFrame).\n * When chrome is enabled and header is provided, header becomes the drag handle.\n */\nimport * as React from \"react\";\nimport type { FloatingBehavior } from \"../../types\";\nimport {\n FloatingPanelCloseButton,\n FloatingPanelFrame,\n FloatingPanelHeader,\n FloatingPanelTitle,\n FloatingPanelControls,\n FloatingPanelContent,\n} from \"../paneling/FloatingPanelFrame\";\n\nexport type FloatingWindowProps = {\n id: string;\n config: FloatingBehavior;\n onClose: () => void;\n children: React.ReactNode;\n};\n\ntype CloseButtonProps = {\n onClick: () => void;\n};\n\nconst CloseButton: React.FC<CloseButtonProps> = ({ onClick }) => (\n <FloatingPanelControls>\n <FloatingPanelCloseButton onClick={onClick} aria-label=\"Close window\" data-drag-ignore=\"true\" />\n </FloatingPanelControls>\n);\n\ntype FloatingWindowHeaderProps = {\n header?: FloatingBehavior[\"header\"];\n draggable?: boolean;\n onClose: () => void;\n};\n\nconst FloatingWindowHeader: React.FC<FloatingWindowHeaderProps> = ({ header, draggable, onClose }) => {\n if (!header) {\n return null;\n }\n\n const showCloseButton = header.showCloseButton ?? false;\n const dragHandleProps = draggable ? { \"data-drag-handle\": \"true\" } : {};\n const cursorStyle = draggable ? \"grab\" : undefined;\n\n return (\n <FloatingPanelHeader {...dragHandleProps} style={{ cursor: cursorStyle }}>\n {header.title ? <FloatingPanelTitle>{header.title}</FloatingPanelTitle> : null}\n {showCloseButton ? <CloseButton onClick={onClose} /> : null}\n </FloatingPanelHeader>\n );\n};\n\ntype FloatingWindowViewProps = {\n header?: FloatingBehavior[\"header\"];\n draggable?: boolean;\n chrome: boolean;\n onClose: () => void;\n children: React.ReactNode;\n};\n\nconst FloatingWindowView: React.FC<FloatingWindowViewProps> = ({ header, draggable, chrome, onClose, children }) => {\n if (!chrome) {\n return <>{children}</>;\n }\n\n return (\n <FloatingPanelFrame style={{ height: \"100%\", width: \"100%\" }}>\n <FloatingWindowHeader header={header} draggable={draggable} onClose={onClose} />\n <FloatingPanelContent style={{ flex: 1, display: \"flex\", flexDirection: \"column\" }}>\n {children}\n </FloatingPanelContent>\n </FloatingPanelFrame>\n );\n};\n\nexport const FloatingWindow: React.FC<FloatingWindowProps> = ({ id, config, onClose, children }) => {\n const chrome = config.chrome ?? false;\n const draggable = config.draggable ?? false;\n const ariaLabel = config.header?.title ?? config.ariaLabel ?? \"Floating window\";\n\n return (\n <div data-floating-window={id} role=\"dialog\" aria-label={ariaLabel} style={{ height: \"100%\", width: \"100%\" }}>\n <FloatingWindowView header={config.header} draggable={draggable} chrome={chrome} onClose={onClose}>\n {children}\n </FloatingWindowView>\n </div>\n );\n};\n\nFloatingWindow.displayName = \"FloatingWindow\";\n"],"names":["SWIPE_SAFE_ZONE_ATTR","SwipeSafeZone","children","className","style","jsx","isInSwipeSafeZone","element","container","current","getDrawerAnimationAxis","direction","getDrawerCloseSwipeSign","getDrawerOpenSwipeSign","DEFAULT_DISMISS_THRESHOLD","VELOCITY_THRESHOLD","getContainerSize","axis","getAxisDelta","start","PHASE_MAP","normalizePhase","phase","computeDisplacementValue","closeSwipeSign","closeDisplacement","signedDisplacement","computeAxisDisplacement","displacement","isEdgeSwipeEnabled","enableEdgeSwipeOpen","isOpen","isCloseSwipeEnabled","enableSwipeClose","isDrawerOpening","isEdgeGesture","isDrawerClosing","closePhase","computeVelocity","timeDelta","useDrawerSwipeInput","options","edgeContainerRef","drawerContentRef","onSwipeOpen","onSwipeClose","edgeWidth","dismissThreshold","openSwipeSign","containerSizeRef","React","updateSize","observer","handleOpenSwipeEnd","state","edgeSwipeState","edgeSwipeProps","useEdgeSwipeInput","guardProps","useNativeGestureGuard","closeTracking","baseClosePointerDown","usePointerTracking","setClosePhase","lastCloseDisplacementRef","onClosePointerDown","event","target","isScrollableInDirection","signedDelta","containerSize","ratio","velocity","isOpening","isClosing","progress","IDLE_CONTINUOUS_OPERATION_STATE","edgeContainerProps","mergeGestureContainerProps","drawerContentProps","DRAWER_BACKDROP_BASE_STYLE","COLOR_DRAWER_BACKDROP","DRAWER_PANEL_BASE_STYLE","PLACEMENT_STYLES","OPEN_TRANSFORMS","getPlacementStyle","placement","getOpenTransform","computeTransitionValue","mode","duration","easing","DRAWER_TRANSITION_DURATION","DRAWER_TRANSITION_EASING","computeBackdropTransition","formatDimension","value","computeEdgeZoneStyle","inline","zIndex","position","computedZIndex","getEdgeZoneStyleByPlacement","base","DEFAULT_EDGE_WIDTH","DISABLED_CONFIG","ENABLED_DEFAULT_CONFIG","parseSwipeGesturesConfig","swipeGestures","resolvePlacement","anchor","shouldShowEdgeZone","config","useDrawerSwipeTransform","drawerRef","backdropRef","swipeState","enabled","isOperating","drawer","backdrop","closeSign","drawerSize","translateFn","applyClosingTransform","applyOpeningTransform","translate","clampedTranslate","clampTranslate","DrawerContent","chrome","frameStyle","header","dismissible","onClose","jsxs","FloatingPanelFrame","DrawerHeaderView","FloatingPanelContent","DRAWER_CONTENT_PADDING","shouldShowCloseButton","showCloseButton","renderCloseButton","shouldShow","FloatingPanelCloseButton","renderEdgeZone","showEdgeZone","edgeZoneRef","edgeZoneStyle","onPointerDown","FloatingPanelHeader","DRAWER_HEADER_PADDING_Y","DRAWER_HEADER_PADDING_X","DRAWER_HEADER_GAP","FloatingPanelTitle","useDrawerPanelStyle","isSwipeOperating","dimensions","effectiveMode","transitionValue","placementStyle","transform","useBackdropStyle","useFrameStyle","Drawer","id","onOpen","width","height","swipeConfig","handleSwipeOpen","handleSwipeClose","drawerStyle","backdropStyle","mergedDrawerStyle","ariaLabel","edgeZoneElement","Fragment","waitForTransitionEnd","el","timeout","resolve","resolved","done","handler","e","runTransition","update","useTransitionState","states","setStates","optionsRef","transitionOptions","prev","opts","open","close","parseDuration","match","useDrawerState","layers","drawerStates","setDrawerStates","initial","layer","layerMap","map","updateState","layerId","DrawerLayers","drawerLayers","closeHandlers","handlers","openHandlers","GridLayoutContext","GridLayoutProvider","useGridLayoutContext","context","PanelSystemContext","usePanelSystem","ctx","PanelSystemProvider","layerById","resolveContent","validIds","l","getCachedContent","useContentCache","LayerInstanceContext","LayerInstanceProvider","useLayerInstance","ensureNumericOffset","key","resolvePopupAnchor","numericFeature","booleanFeature","buildWindowFeatures","features","overrides","toolbar","menubar","location","status","resizable","scrollbars","applyBoundsToWindow","popupWindow","PopupLayerPortal","floating","containerRef","popupWindowRef","isMounted","setIsMounted","windowName","createdWindow","resolvePopupWindow","openedWindow","mountNode","handleBeforeUnload","createPortal","bounds","customFactory","CloseButton","onClick","FloatingPanelControls","FloatingWindowHeader","draggable","FloatingWindowView","FloatingWindow"],"mappings":";;;;;;;AAiBO,MAAMA,KAAuB,wBAqBvBC,KAA8C,CAAC;AAAA,EAC1D,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AACF,MAEI,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,WAAAF;AAAA,IACA,OAAAC;AAAA,IACA,wBAAqB;AAAA,IAEpB,UAAAF;AAAA,EAAA;AAAA;AAQA,SAASI,GAAkBC,GAAsBC,GAAiC;AACvF,MAAIC,IAA8BF;AAElC,SAAOE,KAAWA,MAAYD,KAAW;AACvC,QAAIC,EAAQ,aAAaT,EAAoB;AAC3C,aAAO;AAET,IAAAS,IAAUA,EAAQ;AAAA,EACpB;AAEA,SAAO;AACT;ACJO,SAASC,GAAuBC,GAA4C;AACjF,UAAQA,GAAA;AAAA,IACN,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,EAAA;AAEb;AASO,SAASC,EAAwBD,GAAyC;AAC/E,UAAQA,GAAA;AAAA,IACN,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,EAAA;AA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,GAAI,MAAK,UAAS,cAAYU,GAAW,OAAO,EAAE,QAAQ,QAAQ,OAAO,OAAA,GAClG,UAAA,gBAAA1K,EAACsQ,IAAA,EAAmB,QAAQ3J,EAAO,QAAQ,WAAA0J,GAAsB,QAAAxI,GAAgB,SAAAI,GAC9E,UAAApI,EAAA,CACH,EAAA,CACF;AAEJ;AAEA0Q,GAAe,cAAc;"}
@@ -0,0 +1,2 @@
1
+ "use strict";const p=require("react/jsx-runtime"),ue=require("react"),P=require("./FloatingPanelFrame-CEmXDvUA.cjs"),A=require("./styles-qf6ptVLD.cjs"),_=require("./useNativeGestureGuard-C7TSqEkr.cjs"),ce=require("react-dom"),le=require("./useContentCache-DqXtLrLs.cjs");function de(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const i=de(ue),fe="data-swipe-safe-zone",pe=({children:e,className:t,style:n})=>p.jsx("div",{className:t,style:n,"data-swipe-safe-zone":"true",children:e});function me(e,t){let n=e;for(;n&&n!==t;){if(n.hasAttribute(fe))return!0;n=n.parentElement}return!1}function K(e){switch(e){case"left":case"right":return"x";case"top":case"bottom":return"y"}}function G(e){switch(e){case"left":return-1;case"right":return 1;case"top":return-1;case"bottom":return 1}}function he(e){return G(e)*-1}const we=.3,ge=.5;function Se(e,t){return t==="x"?e.clientWidth:e.clientHeight}function be(e,t,n){return n==="x"?t.x-e.x:t.y-e.y}const Ee={idle:"idle",ended:"ended"};function Ce(e){return Ee[e]??"operating"}function De(e,t,n){const r=e*n;return t==="x"?{x:r,y:0}:{x:0,y:r}}function Pe(e,t){return Math.abs(t==="x"?e.x:e.y)}function xe(e,t){return e?!t:!1}function ve(e,t){return e?t:!1}function ye(e,t){return e?!t:!1}function Re(e,t){return e==="idle"?!1:t}function Te(e,t,n){if(!e||!t)return 0;const r=Math.max(1,t.timestamp-e.timestamp);return n/r}function Me(e){const{edgeContainerRef:t,drawerContentRef:n,direction:r,isOpen:o,onSwipeOpen:s,onSwipeClose:c,enableEdgeSwipeOpen:d=!0,enableSwipeClose:a=!0,edgeWidth:u=20,dismissThreshold:l=we}=e,f=K(r),w=G(r),b=he(r),m=i.useRef(0);i.useLayoutEffect(()=>{const S=n.current;if(!S)return;const D=()=>{m.current=Se(S,f)};D();const T=new ResizeObserver(D);return T.observe(S),()=>T.disconnect()},[n,f]);const g=i.useCallback(S=>{S.direction===b&&s()},[b,s]),{isEdgeGesture:E,state:v,containerProps:F}=_.useEdgeSwipeInput({containerRef:t,edge:r,edgeWidth:u,enabled:xe(d,o),onSwipeEnd:g}),{containerProps:N}=_.useNativeGestureGuard({containerRef:t,active:E,preventEdgeBack:!0,preventOverscroll:!0,edgeWidth:u}),{state:h,onPointerDown:j}=_.usePointerTracking({enabled:ve(a,o)}),[C,y]=i.useState("idle"),x=i.useRef(0),W=i.useCallback(S=>{if(!a||!o)return;const D=n.current;if(!D)return;const T=S.target;me(T,D)||_.isScrollableInDirection(T,D,f,w)||j(S)},[a,o,n,f,w,j]),M=i.useMemo(()=>{if(!h.isDown||!h.start||!h.current)return x.current;const D=be(h.start,h.current,f)*w;return Math.max(0,D)},[h.isDown,h.start,h.current,f,w]);i.useEffect(()=>{h.isDown&&h.current&&(x.current=M)},[h.isDown,h.current,M]),i.useEffect(()=>{h.isDown&&C==="idle"&&y("operating")},[h.isDown,C]),i.useEffect(()=>{if(!h.isDown&&C==="operating"){const S=x.current;if(S>1){y("ended");const T=m.current;if(T>0){const ie=S/T,ae=Te(h.start,h.current,S);(ie>=l||ae>=ge)&&c()}}else y("idle"),x.current=0}},[h.isDown,C,l,c,h.start,h.current]),i.useEffect(()=>{C==="ended"&&queueMicrotask(()=>{y("idle"),x.current=0})},[C]),i.useEffect(()=>{o||(y("idle"),x.current=0)},[o]);const L=ye(E,o),R=Re(C,o),I=i.useMemo(()=>L?Pe(v.displacement,f):R?M:0,[L,R,f,v.displacement,M]),B=i.useMemo(()=>{const S=m.current;return S<=0?0:Math.min(I/S,1)},[I]),$=i.useMemo(()=>L?{phase:Ce(v.phase),displacement:v.displacement,velocity:v.velocity}:R?{phase:C,displacement:De(w,f,M),velocity:{x:0,y:0}}:_.IDLE_CONTINUOUS_OPERATION_STATE,[L,R,v,C,M,f,w]),H=i.useMemo(()=>_.mergeGestureContainerProps(F,N),[F,N]),z=i.useMemo(()=>({onPointerDown:W,style:{touchAction:"none",userSelect:"none",WebkitUserSelect:"none"}}),[W]);return{state:$,isOpening:L,isClosing:R,progress:B,displacement:I,edgeContainerProps:H,drawerContentProps:z}}const Le={position:"fixed",inset:0,background:A.COLOR_DRAWER_BACKDROP},Ae={willChange:"transform"},_e={left:{top:0,bottom:0,left:0,transform:"translateX(-100%)"},right:{top:0,bottom:0,right:0,transform:"translateX(100%)"},top:{top:0,left:0,right:0,transform:"translateY(-100%)"},bottom:{bottom:0,left:0,right:0,transform:"translateY(100%)"}},Oe={left:"translateX(0)",right:"translateX(0)",top:"translateY(0)",bottom:"translateY(0)"};function Fe(e){return _e[e]}function je(e){return Oe[e]}function We(e,t,n){if(e==="none")return;const r=t??A.DRAWER_TRANSITION_DURATION,o=n??A.DRAWER_TRANSITION_EASING;return`transform ${r} ${o}`}function Ie(e,t){if(e!=="none")return`opacity ${t??"220ms"} ease`}function V(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Ne(e){const{placement:t,inline:n,edgeWidth:r,zIndex:o}=e,s=n?"absolute":"fixed",c=o!==void 0?o-2:1e3;return ke(t,s,r,c)}function ke(e,t,n,r){const o={position:t,zIndex:r,background:"transparent",pointerEvents:"auto"};return e==="left"?{...o,top:0,bottom:0,left:0,width:n}:e==="right"?{...o,top:0,bottom:0,right:0,width:n}:e==="top"?{...o,top:0,left:0,right:0,height:n}:{...o,bottom:0,left:0,right:0,height:n}}const Z=20,q=.3,Be={enabled:!1,edgeSwipeOpen:!1,swipeClose:!1,edgeWidth:Z,dismissThreshold:q},$e={enabled:!0,edgeSwipeOpen:!0,swipeClose:!0,edgeWidth:Z,dismissThreshold:q};function He(e){return e===!0?$e:e===!1||e===void 0?Be:{enabled:!0,edgeSwipeOpen:e.edgeSwipeOpen??!0,swipeClose:e.swipeClose??!0,edgeWidth:e.edgeWidth??Z,dismissThreshold:e.dismissThreshold??q}}function ze(e,t){return e||(t?t.left!==void 0?"left":t.right!==void 0?"right":t.top!==void 0?"top":t.bottom!==void 0?"bottom":"right":"right")}function Ge(e,t,n){return!e.enabled||!e.edgeSwipeOpen?!1:t?n:!0}function Ze(e){const{drawerRef:t,backdropRef:n,placement:r,swipeState:o,displacement:s,isOpening:c,isClosing:d,enabled:a}=e,u=o.phase==="operating";i.useLayoutEffect(()=>{if(!a||!u)return;const l=t.current,f=n.current;if(!l)return;const w=K(r),b=G(r),m=w==="x"?l.clientWidth:l.clientHeight;if(m<=0)return;const g=w==="x"?"translateX":"translateY";d?qe(l,f,g,b,s,m):c&&Ue(l,f,g,b,s,m)},[a,u,d,c,s,r,t,n]),i.useLayoutEffect(()=>{if(!a||o.phase!=="ended")return;const l=t.current,f=n.current;l&&(l.style.transform=""),f&&(f.style.opacity="")},[a,o.phase,t,n])}function qe(e,t,n,r,o,s){const c=r*o;e.style.transform=`${n}(${c}px)`;const d=Math.min(o/s,1);t&&(t.style.opacity=String(1-d))}function Ue(e,t,n,r,o,s){const d=r*s+r*-1*o,a=Ve(d,r);e.style.transform=`${n}(${a}px)`;const u=Math.min(o/s,1);t&&(t.style.opacity=String(u),t.style.pointerEvents="auto")}function Ve(e,t){return t>0?Math.max(0,e):Math.min(0,e)}const Ye=({chrome:e,frameStyle:t,header:n,dismissible:r,onClose:o,children:s})=>e?p.jsxs(P.FloatingPanelFrame,{style:t,children:[p.jsx(Qe,{header:n,dismissible:r,onClose:o}),p.jsx(P.FloatingPanelContent,{style:{padding:A.DRAWER_CONTENT_PADDING,flex:1,display:"flex",flexDirection:"column"},children:s})]}):p.jsx(p.Fragment,{children:s});function Xe(e,t){return e?t:!1}function Ke(e,t){return e?p.jsx(P.FloatingPanelCloseButton,{onClick:t,"aria-label":"Close drawer",style:{marginLeft:"auto"}}):null}function Je(e,t,n,r,o){return e?p.jsx("div",{ref:t,style:n,onPointerDown:r,"data-drawer-edge-zone":o}):null}const Qe=({header:e,dismissible:t,onClose:n})=>{if(!e)return null;const r=e.showCloseButton??!0,o=Xe(t,r);return p.jsxs(P.FloatingPanelHeader,{style:{padding:`${A.DRAWER_HEADER_PADDING_Y} ${A.DRAWER_HEADER_PADDING_X}`,gap:A.DRAWER_HEADER_GAP},children:[p.jsx(P.FloatingPanelTitle,{children:e.title}),Ke(o,n)]})};function et(e,t,n,r,o){return i.useMemo(()=>{const s=n?"none":r.transitionMode,c=We(s,r.transitionDuration,r.transitionEasing),d=Fe(e),a=t?je(e):d.transform,u=r.inline?"absolute":"fixed";return{...Ae,position:u,...d,transform:a,transition:c,zIndex:o.zIndex,width:V(o.width),height:V(o.height)}},[e,t,n,r,o])}function tt(e,t,n,r,o){return i.useMemo(()=>{const s=n?"none":r.transitionMode,c=Ie(s,r.transitionDuration),d=r.inline?"absolute":"fixed";return{...Le,position:d,opacity:t?1:0,pointerEvents:t?"auto":"none",transition:c,zIndex:o!==void 0?o-1:void 0}},[t,n,r,o])}function nt(e){return i.useMemo(()=>{const t={borderRadius:0};return(e==="left"||e==="right")&&(t.height="100%"),t},[e])}const J=({id:e,config:t,isOpen:n,onClose:r,onOpen:o,children:s,zIndex:c,width:d,height:a,position:u})=>{const{dismissible:l=!0,header:f,chrome:w=!0,inline:b=!1}=t,m=He(t.swipeGestures),g=ze(t.anchor,u),E=i.useRef(null),v=i.useRef(null),F=i.useRef(null),N=i.useCallback(()=>{o?.(),t.onStateChange?.(!0)},[o,t]),h=i.useCallback(()=>{r()},[r]),{state:j,displacement:C,edgeContainerProps:y,drawerContentProps:x,isOpening:W,isClosing:M}=Me({edgeContainerRef:F,drawerContentRef:E,direction:g,isOpen:n,onSwipeOpen:N,onSwipeClose:h,enableEdgeSwipeOpen:m.edgeSwipeOpen,enableSwipeClose:m.swipeClose,edgeWidth:m.edgeWidth,dismissThreshold:m.dismissThreshold}),L=j.phase==="operating";Ze({drawerRef:E,backdropRef:v,placement:g,swipeState:j,displacement:C,isOpening:W,isClosing:M,enabled:m.enabled});const R=et(g,n,L,t,{width:d,height:a,zIndex:c}),I=tt(g,n,L,t,c),B=nt(g),$=i.useMemo(()=>({...Ne({placement:g,inline:b,edgeWidth:m.edgeWidth,zIndex:c}),...y.style}),[g,b,m.edgeWidth,c,y.style]),H=i.useMemo(()=>m.enabled?{...R,...x.style}:R,[m.enabled,R,x.style]),z=Ge(m,n,W),S=f?.title??t.ariaLabel??"Drawer",D=Je(z,F,$,y.onPointerDown,g);return p.jsxs(p.Fragment,{children:[D,p.jsx("div",{ref:v,style:I,onClick:l?r:void 0}),p.jsx("div",{ref:E,"data-layer-id":e,"data-placement":g,style:H,role:"dialog","aria-modal":l?!0:void 0,"aria-hidden":n?void 0:!0,"aria-label":S,onPointerDown:m.enabled?x.onPointerDown:void 0,children:p.jsx(Ye,{chrome:w,frameStyle:B,header:f,dismissible:l,onClose:r,children:s})})]})},rt=(e,t)=>new Promise(n=>{let r=!1;const o=()=>{r||(r=!0,e.removeEventListener("transitionend",s),n())},s=c=>{c.target===e&&o()};e.addEventListener("transitionend",s),setTimeout(o,t+50)}),U=async(e,t,n,r)=>{switch(t){case"none":e();return;case"css":e(),n&&await rt(n,r);return}},ot=e=>{const[t,n]=i.useState({}),r=i.useRef(e);r.current=e;const o=i.useCallback(async(a,u,l)=>{const{mode:f="none",element:w,duration:b=300}=l??{};await U(()=>{n(E=>E[a]===u?E:{...E,[a]:u})},f,w?.current,b);const g=r.current;u?g?.onOpen?.(a):g?.onClose?.(a),g?.onTransitionEnd?.(a,u)},[]),s=i.useCallback(a=>t[a]??!1,[t]),c=i.useCallback((a,u)=>o(a,!0,u),[o]),d=i.useCallback((a,u)=>o(a,!1,u),[o]);return{state:s,open:c,close:d}},st=e=>{if(!e)return 300;const t=e.match(/(\d+)/);return t?parseInt(t[1],10):300},Q=e=>{const[t,n]=i.useState(()=>{const a={};return e.forEach(u=>{u.drawer&&(a[u.id]=u.drawer.defaultOpen??!1)}),a}),r=i.useMemo(()=>{const a=new Map;return e.forEach(u=>a.set(u.id,u)),a},[e]),o=i.useCallback(async(a,u,l)=>{const f=r.get(a);if(!f?.drawer)return;const w=l?.mode??f.drawer.transitionMode??"css",b=l?.duration??st(f.drawer.transitionDuration),m=l?.element?.current;await U(()=>{f.drawer?.open===void 0&&n(E=>E[a]===u?E:{...E,[a]:u}),f.drawer?.onStateChange?.(u)},w,m,b)},[r]),s=i.useCallback(a=>{const u=r.get(a);return u?.drawer?.open!==void 0?u.drawer.open:t[a]??!1},[r,t]),c=i.useCallback((a,u)=>o(a,!0,u),[o]),d=i.useCallback((a,u)=>o(a,!1,u),[o]);return{state:s,open:c,close:d}},it=({layers:e})=>{const t=Q(e),n=i.useMemo(()=>e.filter(s=>s.drawer),[e]),r=i.useMemo(()=>{const s=new Map;return n.forEach(c=>{s.set(c.id,()=>t.close(c.id))}),s},[n,t.close]),o=i.useMemo(()=>{const s=new Map;return n.forEach(c=>{s.set(c.id,()=>t.open(c.id))}),s},[n,t.open]);return p.jsx(p.Fragment,{children:n.map(s=>{if(!s.drawer)return null;const c=t.state(s.id),d=r.get(s.id),a=o.get(s.id);return d?p.jsx(J,{id:s.id,config:s.drawer,isOpen:c,onClose:d,onOpen:a,zIndex:s.zIndex,width:s.width,height:s.height,position:s.position,children:s.component},s.id):null})})},ee=i.createContext(null),at=({value:e,children:t})=>p.jsx(ee.Provider,{value:e,children:t}),ut=()=>{const e=i.useContext(ee);if(!e)throw new Error("useGridLayoutContext must be used within a GridLayoutProvider.");return e},te=i.createContext(null),ct=()=>{const e=i.useContext(te);if(!e)throw new Error("usePanelSystem must be used within a PanelSystemProvider.");return e},lt=({config:e,layers:t,style:n,children:r})=>{const o=i.useMemo(()=>{const u=new Map;return t.forEach(l=>{u.set(l.id,l)}),u},[t]),s=i.useCallback(u=>o.get(u)?.component??null,[o]),c=i.useMemo(()=>t.map(u=>u.id),[t]),{getCachedContent:d}=le.useContentCache({resolveContent:s,validIds:c}),a=i.useMemo(()=>({config:e,style:n,layers:{defs:t,layerById:o},getCachedContent:d}),[e,n,t,o,d]);return p.jsx(te.Provider,{value:a,children:r})},ne=i.createContext(null),re=({layerId:e,children:t})=>{const n=i.useMemo(()=>({layerId:e}),[e]);return p.jsx(ne.Provider,{value:n,children:t})},dt=()=>{const e=i.useContext(ne);if(!e)throw new Error("useLayerInstance must be used within a LayerInstanceProvider.");return e},Y=(e,t,n)=>{if(typeof e=="number"&&Number.isFinite(e))return e;throw new Error(`Popup layer "${n}" requires a numeric "${t}" value.`)},oe=(e,t)=>{if(!e)throw new Error(`Popup layer "${t}" must define position (left/top).`);return{left:Y(e.left,"left",t),top:Y(e.top,"top",t)}},k=e=>`${Math.round(e)}`,O=e=>{if(e!==void 0)return e?"yes":"no"},ft=(e,t,n,r,o)=>{const s={},c=oe(t,e);if(typeof n!="number"||typeof r!="number")throw new Error(`Popup layer "${e}" requires numeric width/height.`);s.width=k(n),s.height=k(r),s.left=k(c.left),s.top=k(c.top);const d=o?.features;if(d){const a=O(d.toolbar),u=O(d.menubar),l=O(d.location),f=O(d.status),w=O(d.resizable),b=O(d.scrollbars);a!==void 0&&(s.toolbar=a),u!==void 0&&(s.menubar=u),l!==void 0&&(s.location=l),f!==void 0&&(s.status=f),w!==void 0&&(s.resizable=w),b!==void 0&&(s.scrollbars=b)}return Object.entries(s).map(([a,u])=>`${a}=${u}`).join(",")},X=(e,t,n,r,o)=>{const s=oe(n,t);if(typeof r!="number"||typeof o!="number")throw new Error(`Popup layer "${t}" requires numeric width/height.`);e.moveTo(Math.round(s.left),Math.round(s.top)),e.resizeTo(Math.round(r),Math.round(o))},pt=({layer:e})=>{const t=e.floating;if(!t)throw new Error(`Layer "${e.id}" is missing floating configuration required for popup mode.`);if((t.mode??"embedded")!=="popup")throw new Error(`PopupLayerPortal received layer "${e.id}" that is not configured for popup mode.`);const r=i.useRef(null),o=i.useRef(null),[s,c]=i.useState(!1);return i.useEffect(()=>{if(typeof window>"u")return;const d=ft(e.id,e.position,e.width,e.height,t.popup),a=t.popup?.name??e.id,u=mt(a,d,{position:e.position,size:{width:e.width,height:e.height}},t.popup);if(!u)throw new Error(`Failed to open popup window for layer "${e.id}".`);const l=u;o.current=l,t.popup?.focus!==!1&&l.focus(),l.document.title||(l.document.title=e.id),l.document.body.innerHTML="";const f=l.document.createElement("div");f.dataset.layerId=e.id,l.document.body.appendChild(f),r.current=f,c(!0),X(l,e.id,e.position,e.width,e.height);const w=()=>{o.current=null,r.current=null,c(!1)};return l.addEventListener("beforeunload",w),()=>{l.removeEventListener("beforeunload",w),t.popup?.closeOnUnmount!==!1&&l.close(),o.current=null,r.current=null,c(!1)}},[t.popup?.closeOnUnmount,t.popup?.features?.location,t.popup?.features?.menubar,t.popup?.features?.resizable,t.popup?.features?.scrollbars,t.popup?.features?.status,t.popup?.features?.toolbar,t.popup?.focus,t.popup?.name,e.id]),i.useEffect(()=>{const d=o.current;d&&X(d,e.id,e.position,e.width,e.height)},[e.position?.left,e.position?.top,e.height,e.width,e.id]),!s||!r.current?null:ce.createPortal(p.jsx(re,{layerId:e.id,children:e.component}),r.current)},mt=(e,t,n,r)=>{const o=r?.createWindow;return o?o({name:e,features:t,bounds:n}):window.open("",e,t)},ht=({onClick:e})=>p.jsx(P.FloatingPanelControls,{children:p.jsx(P.FloatingPanelCloseButton,{onClick:e,"aria-label":"Close window","data-drag-ignore":"true"})}),wt=({header:e,draggable:t,onClose:n})=>{if(!e)return null;const r=e.showCloseButton??!1,o=t?{"data-drag-handle":"true"}:{},s=t?"grab":void 0;return p.jsxs(P.FloatingPanelHeader,{...o,style:{cursor:s},children:[e.title?p.jsx(P.FloatingPanelTitle,{children:e.title}):null,r?p.jsx(ht,{onClick:n}):null]})},gt=({header:e,draggable:t,chrome:n,onClose:r,children:o})=>n?p.jsxs(P.FloatingPanelFrame,{style:{height:"100%",width:"100%"},children:[p.jsx(wt,{header:e,draggable:t,onClose:r}),p.jsx(P.FloatingPanelContent,{style:{flex:1,display:"flex",flexDirection:"column"},children:o})]}):p.jsx(p.Fragment,{children:o}),se=({id:e,config:t,onClose:n,children:r})=>{const o=t.chrome??!1,s=t.draggable??!1,c=t.header?.title??t.ariaLabel??"Floating window";return p.jsx("div",{"data-floating-window":e,role:"dialog","aria-label":c,style:{height:"100%",width:"100%"},children:p.jsx(gt,{header:t.header,draggable:s,chrome:o,onClose:n,children:r})})};se.displayName="FloatingWindow";exports.Drawer=J;exports.DrawerLayers=it;exports.FloatingWindow=se;exports.GridLayoutProvider=at;exports.LayerInstanceProvider=re;exports.PanelSystemProvider=lt;exports.PopupLayerPortal=pt;exports.SwipeSafeZone=pe;exports.runTransition=U;exports.useDrawerState=Q;exports.useGridLayoutContext=ut;exports.useLayerInstance=dt;exports.usePanelSystem=ct;exports.useTransitionState=ot;
2
+ //# sourceMappingURL=FloatingWindow-DMwyK0eK.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FloatingWindow-DMwyK0eK.cjs","sources":["../src/components/gesture/SwipeSafeZone.tsx","../src/modules/drawer/types.ts","../src/modules/drawer/useDrawerSwipeInput.ts","../src/components/window/drawerStyles.ts","../src/components/window/drawerSwipeConfig.ts","../src/components/window/useDrawerSwipeTransform.ts","../src/components/window/Drawer.tsx","../src/hooks/useTransitionState.ts","../src/modules/window/useDrawerState.ts","../src/components/window/DrawerLayers.tsx","../src/modules/grid/GridLayoutContext.tsx","../src/PanelSystemContext.tsx","../src/modules/grid/LayerInstanceContext.tsx","../src/components/window/PopupLayerPortal.tsx","../src/components/window/FloatingWindow.tsx"],"sourcesContent":["/**\n * @file SwipeSafeZone component\n *\n * A wrapper component that marks an area as exempt from swipe gesture detection.\n * Content inside this zone will not trigger swipe-to-close or other swipe gestures.\n *\n * Use this for:\n * - Scrollable content areas\n * - Input fields and text areas\n * - Interactive elements that need drag/swipe for their own purposes\n */\nimport * as React from \"react\";\n\n/**\n * Data attribute used to identify swipe-safe zones.\n * Swipe gesture handlers should check for this attribute on target elements.\n */\nexport const SWIPE_SAFE_ZONE_ATTR = \"data-swipe-safe-zone\";\n\nexport type SwipeSafeZoneProps = {\n /** Content to render inside the safe zone */\n children: React.ReactNode;\n /** Additional CSS class name */\n className?: string;\n /** Additional inline styles */\n style?: React.CSSProperties;\n};\n\n/**\n * SwipeSafeZone marks an area where swipe gestures should not be triggered.\n *\n * @example\n * ```tsx\n * <SwipeSafeZone>\n * <ScrollableList items={items} />\n * </SwipeSafeZone>\n * ```\n */\nexport const SwipeSafeZone: React.FC<SwipeSafeZoneProps> = ({\n children,\n className,\n style,\n}) => {\n return (\n <div\n className={className}\n style={style}\n data-swipe-safe-zone=\"true\"\n >\n {children}\n </div>\n );\n};\n\n/**\n * Check if an element is inside a SwipeSafeZone.\n */\nexport function isInSwipeSafeZone(element: HTMLElement, container: HTMLElement): boolean {\n let current: HTMLElement | null = element;\n\n while (current && current !== container) {\n if (current.hasAttribute(SWIPE_SAFE_ZONE_ATTR)) {\n return true;\n }\n current = current.parentElement;\n }\n\n return false;\n}\n","/**\n * @file Type definitions for Drawer swipe gesture handling.\n */\nimport type * as React from \"react\";\nimport type { ContinuousOperationState } from \"../../hooks/gesture/types.js\";\n\n/**\n * Direction for drawer anchor (same as anchor edge).\n */\nexport type DrawerSwipeDirection = \"left\" | \"right\" | \"top\" | \"bottom\";\n\n/**\n * Options for useDrawerSwipeInput hook.\n */\nexport type UseDrawerSwipeInputOptions = {\n /** Container ref for edge detection zone (e.g., GridLayout container) */\n edgeContainerRef: React.RefObject<HTMLElement | null>;\n /** Drawer content ref (for close gesture) */\n drawerContentRef: React.RefObject<HTMLElement | null>;\n /** Drawer direction (anchor edge) */\n direction: DrawerSwipeDirection;\n /** Whether the drawer is currently open */\n isOpen: boolean;\n /** Callback when swipe should open the drawer */\n onSwipeOpen: () => void;\n /** Callback when swipe should close the drawer */\n onSwipeClose: () => void;\n /** Whether edge swipe to open is enabled. @default true */\n enableEdgeSwipeOpen?: boolean;\n /** Whether swipe to close is enabled. @default true */\n enableSwipeClose?: boolean;\n /** Width of edge detection zone in pixels. @default 20 */\n edgeWidth?: number;\n /** Dismiss threshold ratio (0-1). @default 0.3 */\n dismissThreshold?: number;\n};\n\n/**\n * Result from useDrawerSwipeInput hook.\n */\nexport type UseDrawerSwipeInputResult = {\n /** Current operation state */\n state: ContinuousOperationState;\n /** Whether currently opening via edge swipe */\n isOpening: boolean;\n /** Whether currently closing via drag */\n isClosing: boolean;\n /** Progress (0-1) towards open/close threshold */\n progress: number;\n /** Displacement in pixels (primary axis) */\n displacement: number;\n /** Props for edge container (open gesture zone) */\n edgeContainerProps: React.HTMLAttributes<HTMLElement> & {\n style: React.CSSProperties;\n };\n /** Props for drawer content (close gesture zone) */\n drawerContentProps: React.HTMLAttributes<HTMLElement> & {\n style: React.CSSProperties;\n };\n};\n\n/**\n * Get animation axis from direction.\n */\nexport function getDrawerAnimationAxis(direction: DrawerSwipeDirection): \"x\" | \"y\" {\n switch (direction) {\n case \"left\":\n case \"right\":\n return \"x\";\n case \"top\":\n case \"bottom\":\n return \"y\";\n }\n}\n\n/**\n * Get the sign for the close swipe direction.\n * Left drawer closes by swiping left (-1).\n * Right drawer closes by swiping right (+1).\n * Top drawer closes by swiping up (-1).\n * Bottom drawer closes by swiping down (+1).\n */\nexport function getDrawerCloseSwipeSign(direction: DrawerSwipeDirection): 1 | -1 {\n switch (direction) {\n case \"left\":\n return -1;\n case \"right\":\n return 1;\n case \"top\":\n return -1;\n case \"bottom\":\n return 1;\n }\n}\n\n/**\n * Get the sign for the open swipe direction.\n * This is the opposite of the close direction.\n */\nexport function getDrawerOpenSwipeSign(direction: DrawerSwipeDirection): 1 | -1 {\n return (getDrawerCloseSwipeSign(direction) * -1) as 1 | -1;\n}\n","/**\n * @file Hook for detecting swipe gestures to open/close a drawer.\n *\n * Combines:\n * - Edge swipe detection for opening (Stack pattern)\n * - Drag-to-close within drawer (Dialog pattern)\n * - Native gesture guard for browser back prevention\n */\nimport * as React from \"react\";\nimport { useEdgeSwipeInput } from \"../../hooks/gesture/useEdgeSwipeInput.js\";\nimport { useNativeGestureGuard } from \"../../hooks/gesture/useNativeGestureGuard.js\";\nimport { usePointerTracking } from \"../../hooks/gesture/usePointerTracking.js\";\nimport {\n mergeGestureContainerProps,\n isScrollableInDirection,\n} from \"../../hooks/gesture/utils.js\";\nimport { isInSwipeSafeZone } from \"../../components/gesture/SwipeSafeZone.js\";\nimport {\n type ContinuousOperationState,\n IDLE_CONTINUOUS_OPERATION_STATE,\n} from \"../../hooks/gesture/types.js\";\nimport type { UseDrawerSwipeInputOptions, UseDrawerSwipeInputResult } from \"./types.js\";\nimport { getDrawerAnimationAxis, getDrawerCloseSwipeSign, getDrawerOpenSwipeSign } from \"./types.js\";\n\n/**\n * Default dismiss threshold (30% of container size).\n */\nconst DEFAULT_DISMISS_THRESHOLD = 0.3;\n\n/**\n * Velocity threshold for quick flick dismissal (px/ms).\n */\nconst VELOCITY_THRESHOLD = 0.5;\n\n// ============================================================================\n// Helper functions (extracted to avoid ternary violations)\n// ============================================================================\n\nfunction getContainerSize(container: HTMLElement, axis: \"x\" | \"y\"): number {\n if (axis === \"x\") {\n return container.clientWidth;\n }\n return container.clientHeight;\n}\n\nfunction getAxisDelta(\n start: { x: number; y: number },\n current: { x: number; y: number },\n axis: \"x\" | \"y\",\n): number {\n if (axis === \"x\") {\n return current.x - start.x;\n }\n return current.y - start.y;\n}\n\nconst PHASE_MAP: Record<string, \"idle\" | \"operating\" | \"ended\"> = {\n idle: \"idle\",\n ended: \"ended\",\n};\n\nfunction normalizePhase(phase: string): \"idle\" | \"operating\" | \"ended\" {\n return PHASE_MAP[phase] ?? \"operating\";\n}\n\nfunction computeDisplacementValue(\n closeSwipeSign: 1 | -1,\n axis: \"x\" | \"y\",\n closeDisplacement: number,\n): { x: number; y: number } {\n const signedDisplacement = closeSwipeSign * closeDisplacement;\n if (axis === \"x\") {\n return { x: signedDisplacement, y: 0 };\n }\n return { x: 0, y: signedDisplacement };\n}\n\nfunction computeAxisDisplacement(\n displacement: { x: number; y: number },\n axis: \"x\" | \"y\",\n): number {\n if (axis === \"x\") {\n return Math.abs(displacement.x);\n }\n return Math.abs(displacement.y);\n}\n\nfunction isEdgeSwipeEnabled(enableEdgeSwipeOpen: boolean, isOpen: boolean): boolean {\n if (!enableEdgeSwipeOpen) {\n return false;\n }\n return !isOpen;\n}\n\nfunction isCloseSwipeEnabled(enableSwipeClose: boolean, isOpen: boolean): boolean {\n if (!enableSwipeClose) {\n return false;\n }\n return isOpen;\n}\n\nfunction isDrawerOpening(isEdgeGesture: boolean, isOpen: boolean): boolean {\n if (!isEdgeGesture) {\n return false;\n }\n return !isOpen;\n}\n\nfunction isDrawerClosing(closePhase: \"idle\" | \"operating\" | \"ended\", isOpen: boolean): boolean {\n if (closePhase === \"idle\") {\n return false;\n }\n return isOpen;\n}\n\nfunction computeVelocity(\n start: { x: number; y: number; timestamp: number } | null,\n current: { x: number; y: number; timestamp: number } | null,\n displacement: number,\n): number {\n if (!start || !current) {\n return 0;\n }\n const timeDelta = Math.max(1, current.timestamp - start.timestamp);\n return displacement / timeDelta;\n}\n\n/**\n * Hook for detecting swipe gestures to open/close a drawer.\n *\n * When drawer is closed:\n * - Detects edge swipe from the anchor edge to trigger open\n *\n * When drawer is open:\n * - Detects drag gesture within drawer to trigger close\n * - Respects scrollable content boundaries\n *\n * @example\n * ```tsx\n * const { state, edgeContainerProps, drawerContentProps } = useDrawerSwipeInput({\n * edgeContainerRef: gridLayoutRef,\n * drawerContentRef: drawerRef,\n * direction: \"left\",\n * isOpen,\n * onSwipeOpen: () => setOpen(true),\n * onSwipeClose: () => setOpen(false),\n * });\n * ```\n */\nexport function useDrawerSwipeInput(\n options: UseDrawerSwipeInputOptions,\n): UseDrawerSwipeInputResult {\n const {\n edgeContainerRef,\n drawerContentRef,\n direction,\n isOpen,\n onSwipeOpen,\n onSwipeClose,\n enableEdgeSwipeOpen = true,\n enableSwipeClose = true,\n edgeWidth = 20,\n dismissThreshold = DEFAULT_DISMISS_THRESHOLD,\n } = options;\n\n const axis = getDrawerAnimationAxis(direction);\n const closeSwipeSign = getDrawerCloseSwipeSign(direction);\n const openSwipeSign = getDrawerOpenSwipeSign(direction);\n\n // Track container size for progress calculation\n const containerSizeRef = React.useRef(0);\n\n // Measure drawer content size\n React.useLayoutEffect(() => {\n const container = drawerContentRef.current;\n if (!container) {\n return;\n }\n\n const updateSize = () => {\n containerSizeRef.current = getContainerSize(container, axis);\n };\n\n updateSize();\n\n const observer = new ResizeObserver(updateSize);\n observer.observe(container);\n\n return () => observer.disconnect();\n }, [drawerContentRef, axis]);\n\n // =========== Edge swipe to OPEN ===========\n const handleOpenSwipeEnd = React.useCallback(\n (state: { direction: 1 | -1 | 0 }) => {\n // Open when swiping in the correct direction (away from edge)\n if (state.direction === openSwipeSign) {\n onSwipeOpen();\n }\n },\n [openSwipeSign, onSwipeOpen],\n );\n\n const {\n isEdgeGesture,\n state: edgeSwipeState,\n containerProps: edgeSwipeProps,\n } = useEdgeSwipeInput({\n containerRef: edgeContainerRef,\n edge: direction,\n edgeWidth,\n enabled: isEdgeSwipeEnabled(enableEdgeSwipeOpen, isOpen),\n onSwipeEnd: handleOpenSwipeEnd,\n });\n\n // Native gesture guard for edge swipe\n const { containerProps: guardProps } = useNativeGestureGuard({\n containerRef: edgeContainerRef,\n active: isEdgeGesture,\n preventEdgeBack: true,\n preventOverscroll: true,\n edgeWidth,\n });\n\n // =========== Drag to CLOSE (Dialog pattern) ===========\n const { state: closeTracking, onPointerDown: baseClosePointerDown } = usePointerTracking({\n enabled: isCloseSwipeEnabled(enableSwipeClose, isOpen),\n });\n\n const [closePhase, setClosePhase] = React.useState<\"idle\" | \"operating\" | \"ended\">(\"idle\");\n const lastCloseDisplacementRef = React.useRef(0);\n\n // Wrap pointer down with scroll check and safe zone check\n const onClosePointerDown = React.useCallback(\n (event: React.PointerEvent) => {\n if (!enableSwipeClose || !isOpen) {\n return;\n }\n\n const container = drawerContentRef.current;\n if (!container) {\n return;\n }\n\n const target = event.target as HTMLElement;\n\n // Check if target is in a SwipeSafeZone\n if (isInSwipeSafeZone(target, container)) {\n return; // Don't start close swipe if inside safe zone\n }\n\n // Check if target is in a scrollable area that would block swipe\n if (isScrollableInDirection(target, container, axis, closeSwipeSign)) {\n return; // Don't start close swipe if inside scrollable content\n }\n\n baseClosePointerDown(event);\n },\n [enableSwipeClose, isOpen, drawerContentRef, axis, closeSwipeSign, baseClosePointerDown],\n );\n\n // Calculate close displacement\n const closeDisplacement = React.useMemo(() => {\n if (!closeTracking.isDown || !closeTracking.start || !closeTracking.current) {\n return lastCloseDisplacementRef.current;\n }\n\n const delta = getAxisDelta(closeTracking.start, closeTracking.current, axis);\n\n // Only count movement in close direction\n const signedDelta = delta * closeSwipeSign;\n return Math.max(0, signedDelta);\n }, [closeTracking.isDown, closeTracking.start, closeTracking.current, axis, closeSwipeSign]);\n\n // Track displacement while dragging\n React.useEffect(() => {\n if (closeTracking.isDown && closeTracking.current) {\n lastCloseDisplacementRef.current = closeDisplacement;\n }\n }, [closeTracking.isDown, closeTracking.current, closeDisplacement]);\n\n // Handle close drag start\n React.useEffect(() => {\n if (closeTracking.isDown && closePhase === \"idle\") {\n setClosePhase(\"operating\");\n }\n }, [closeTracking.isDown, closePhase]);\n\n // Handle close drag end\n React.useEffect(() => {\n if (!closeTracking.isDown && closePhase === \"operating\") {\n const displacement = lastCloseDisplacementRef.current;\n const hasMovement = displacement > 1;\n\n if (hasMovement) {\n setClosePhase(\"ended\");\n\n // Check if should close\n const containerSize = containerSizeRef.current;\n if (containerSize > 0) {\n const ratio = displacement / containerSize;\n const velocity = computeVelocity(closeTracking.start, closeTracking.current, displacement);\n\n if (ratio >= dismissThreshold || velocity >= VELOCITY_THRESHOLD) {\n onSwipeClose();\n }\n }\n } else {\n setClosePhase(\"idle\");\n lastCloseDisplacementRef.current = 0;\n }\n }\n }, [closeTracking.isDown, closePhase, dismissThreshold, onSwipeClose, closeTracking.start, closeTracking.current]);\n\n // Transition from ended to idle\n React.useEffect(() => {\n if (closePhase === \"ended\") {\n queueMicrotask(() => {\n setClosePhase(\"idle\");\n lastCloseDisplacementRef.current = 0;\n });\n }\n }, [closePhase]);\n\n // Reset close state when drawer closes\n React.useEffect(() => {\n if (!isOpen) {\n setClosePhase(\"idle\");\n lastCloseDisplacementRef.current = 0;\n }\n }, [isOpen]);\n\n // =========== Combined state ===========\n const isOpening = isDrawerOpening(isEdgeGesture, isOpen);\n const isClosing = isDrawerClosing(closePhase, isOpen);\n\n // Determine primary displacement based on current operation\n const displacement = React.useMemo(() => {\n if (isOpening) {\n return computeAxisDisplacement(edgeSwipeState.displacement, axis);\n }\n if (isClosing) {\n return closeDisplacement;\n }\n return 0;\n }, [isOpening, isClosing, axis, edgeSwipeState.displacement, closeDisplacement]);\n\n // Progress calculation\n const progress = React.useMemo(() => {\n const containerSize = containerSizeRef.current;\n if (containerSize <= 0) {\n return 0;\n }\n return Math.min(displacement / containerSize, 1);\n }, [displacement]);\n\n // Combined operation state\n const state = React.useMemo<ContinuousOperationState>(() => {\n if (isOpening) {\n return {\n phase: normalizePhase(edgeSwipeState.phase),\n displacement: edgeSwipeState.displacement,\n velocity: edgeSwipeState.velocity,\n };\n }\n if (isClosing) {\n return {\n phase: closePhase,\n displacement: computeDisplacementValue(closeSwipeSign, axis, closeDisplacement),\n velocity: { x: 0, y: 0 },\n };\n }\n return IDLE_CONTINUOUS_OPERATION_STATE;\n }, [isOpening, isClosing, edgeSwipeState, closePhase, closeDisplacement, axis, closeSwipeSign]);\n\n // Container props\n const edgeContainerProps = React.useMemo(\n () => mergeGestureContainerProps(edgeSwipeProps, guardProps),\n [edgeSwipeProps, guardProps],\n );\n\n const drawerContentProps = React.useMemo(() => ({\n onPointerDown: onClosePointerDown,\n style: {\n touchAction: \"none\" as const,\n userSelect: \"none\" as const,\n WebkitUserSelect: \"none\" as const,\n },\n }), [onClosePointerDown]);\n\n return {\n state,\n isOpening,\n isClosing,\n progress,\n displacement,\n edgeContainerProps,\n drawerContentProps,\n };\n}\n","/**\n * @file Drawer style computation utilities.\n *\n * Provides pure functions for computing drawer styles based on configuration.\n */\nimport type * as React from \"react\";\nimport type { DrawerBehavior } from \"../../types.js\";\nimport {\n COLOR_DRAWER_BACKDROP,\n DRAWER_TRANSITION_DURATION,\n DRAWER_TRANSITION_EASING,\n} from \"../../constants/styles.js\";\n\n/**\n * Base backdrop style shared by backdrop and edge zone.\n */\nexport const DRAWER_BACKDROP_BASE_STYLE: React.CSSProperties = {\n position: \"fixed\",\n inset: 0,\n background: COLOR_DRAWER_BACKDROP,\n};\n\n/**\n * Base drawer panel style.\n */\nexport const DRAWER_PANEL_BASE_STYLE: React.CSSProperties = {\n willChange: \"transform\",\n};\n\n/**\n * Placement-specific styles for drawer positioning.\n */\nexport type DrawerPlacement = \"left\" | \"right\" | \"top\" | \"bottom\";\n\nconst PLACEMENT_STYLES: Record<DrawerPlacement, React.CSSProperties> = {\n left: {\n top: 0,\n bottom: 0,\n left: 0,\n transform: \"translateX(-100%)\",\n },\n right: {\n top: 0,\n bottom: 0,\n right: 0,\n transform: \"translateX(100%)\",\n },\n top: {\n top: 0,\n left: 0,\n right: 0,\n transform: \"translateY(-100%)\",\n },\n bottom: {\n bottom: 0,\n left: 0,\n right: 0,\n transform: \"translateY(100%)\",\n },\n};\n\nconst OPEN_TRANSFORMS: Record<DrawerPlacement, string> = {\n left: \"translateX(0)\",\n right: \"translateX(0)\",\n top: \"translateY(0)\",\n bottom: \"translateY(0)\",\n};\n\n/**\n * Get placement-specific style.\n */\nexport function getPlacementStyle(placement: DrawerPlacement): React.CSSProperties {\n return PLACEMENT_STYLES[placement];\n}\n\n/**\n * Get transform value for open state.\n */\nexport function getOpenTransform(placement: DrawerPlacement): string {\n return OPEN_TRANSFORMS[placement];\n}\n\n/**\n * Get closed transform value.\n */\nexport function getClosedTransform(placement: DrawerPlacement): string {\n return PLACEMENT_STYLES[placement].transform as string;\n}\n\n/**\n * Compute CSS transition value.\n */\nexport function computeTransitionValue(\n mode: DrawerBehavior[\"transitionMode\"] | undefined,\n duration: DrawerBehavior[\"transitionDuration\"],\n easing: DrawerBehavior[\"transitionEasing\"],\n): string | undefined {\n if (mode === \"none\") {\n return undefined;\n }\n\n const durationValue = duration ?? DRAWER_TRANSITION_DURATION;\n const easingValue = easing ?? DRAWER_TRANSITION_EASING;\n\n return `transform ${durationValue} ${easingValue}`;\n}\n\n/**\n * Compute backdrop transition value.\n */\nexport function computeBackdropTransition(\n mode: DrawerBehavior[\"transitionMode\"] | undefined,\n duration: DrawerBehavior[\"transitionDuration\"],\n): string | undefined {\n if (mode === \"none\") {\n return undefined;\n }\n return `opacity ${duration ?? \"220ms\"} ease`;\n}\n\n/**\n * Check if placement is horizontal (left/right).\n */\nexport function isHorizontalPlacement(placement: DrawerPlacement): boolean {\n return placement === \"left\" || placement === \"right\";\n}\n\n/**\n * Format dimension value to CSS string.\n */\nexport function formatDimension(value: string | number | undefined): string | undefined {\n if (value === undefined) {\n return undefined;\n }\n if (typeof value === \"number\") {\n return `${value}px`;\n }\n return value;\n}\n\n// ============================================================================\n// Edge Zone Styles\n// ============================================================================\n\n/**\n * Options for computing edge zone style.\n */\nexport type EdgeZoneStyleOptions = {\n placement: DrawerPlacement;\n inline: boolean;\n edgeWidth: number;\n zIndex: number | undefined;\n};\n\n/**\n * Compute edge zone style based on placement and positioning context.\n *\n * The edge zone is positioned at the edge where the drawer appears from:\n * - left drawer: left edge of the container\n * - right drawer: right edge of the container\n * - top drawer: top edge of the container\n * - bottom drawer: bottom edge of the container\n *\n * When inline=true, uses absolute positioning (relative to parent container).\n * When inline=false, uses fixed positioning (relative to viewport).\n */\nexport function computeEdgeZoneStyle(options: EdgeZoneStyleOptions): React.CSSProperties {\n const { placement, inline, edgeWidth, zIndex } = options;\n const position = inline ? \"absolute\" : \"fixed\";\n const computedZIndex = zIndex !== undefined ? zIndex - 2 : 1000;\n\n return getEdgeZoneStyleByPlacement(placement, position, edgeWidth, computedZIndex);\n}\n\nfunction getEdgeZoneStyleByPlacement(\n placement: DrawerPlacement,\n position: \"absolute\" | \"fixed\",\n edgeWidth: number,\n zIndex: number,\n): React.CSSProperties {\n // Common base style\n const base: React.CSSProperties = {\n position,\n zIndex,\n background: \"transparent\",\n pointerEvents: \"auto\",\n };\n\n // Placement-specific positioning\n if (placement === \"left\") {\n return {\n ...base,\n top: 0,\n bottom: 0,\n left: 0,\n width: edgeWidth,\n };\n }\n\n if (placement === \"right\") {\n return {\n ...base,\n top: 0,\n bottom: 0,\n right: 0,\n width: edgeWidth,\n };\n }\n\n if (placement === \"top\") {\n return {\n ...base,\n top: 0,\n left: 0,\n right: 0,\n height: edgeWidth,\n };\n }\n\n // bottom\n return {\n ...base,\n bottom: 0,\n left: 0,\n right: 0,\n height: edgeWidth,\n };\n}\n","/**\n * @file Drawer swipe gesture configuration parsing.\n *\n * Normalizes swipeGestures config from DrawerBehavior into a consistent shape.\n */\nimport type { DrawerBehavior, WindowPosition } from \"../../types.js\";\nimport type { DrawerPlacement } from \"./drawerStyles.js\";\n\n/**\n * Normalized swipe gesture configuration.\n */\nexport type NormalizedSwipeConfig = {\n enabled: boolean;\n edgeSwipeOpen: boolean;\n swipeClose: boolean;\n edgeWidth: number;\n dismissThreshold: number;\n};\n\nconst DEFAULT_EDGE_WIDTH = 20;\nconst DEFAULT_DISMISS_THRESHOLD = 0.3;\n\nconst DISABLED_CONFIG: NormalizedSwipeConfig = {\n enabled: false,\n edgeSwipeOpen: false,\n swipeClose: false,\n edgeWidth: DEFAULT_EDGE_WIDTH,\n dismissThreshold: DEFAULT_DISMISS_THRESHOLD,\n};\n\nconst ENABLED_DEFAULT_CONFIG: NormalizedSwipeConfig = {\n enabled: true,\n edgeSwipeOpen: true,\n swipeClose: true,\n edgeWidth: DEFAULT_EDGE_WIDTH,\n dismissThreshold: DEFAULT_DISMISS_THRESHOLD,\n};\n\n/**\n * Parse swipeGestures config into normalized options.\n */\nexport function parseSwipeGesturesConfig(\n swipeGestures: DrawerBehavior[\"swipeGestures\"],\n): NormalizedSwipeConfig {\n if (swipeGestures === true) {\n return ENABLED_DEFAULT_CONFIG;\n }\n\n if (swipeGestures === false || swipeGestures === undefined) {\n return DISABLED_CONFIG;\n }\n\n return {\n enabled: true,\n edgeSwipeOpen: swipeGestures.edgeSwipeOpen ?? true,\n swipeClose: swipeGestures.swipeClose ?? true,\n edgeWidth: swipeGestures.edgeWidth ?? DEFAULT_EDGE_WIDTH,\n dismissThreshold: swipeGestures.dismissThreshold ?? DEFAULT_DISMISS_THRESHOLD,\n };\n}\n\n/**\n * Resolve drawer placement from anchor and position.\n */\nexport function resolvePlacement(\n anchor: DrawerBehavior[\"anchor\"],\n position: WindowPosition | undefined,\n): DrawerPlacement {\n if (anchor) {\n return anchor;\n }\n\n if (!position) {\n return \"right\";\n }\n\n if (position.left !== undefined) {\n return \"left\";\n }\n if (position.right !== undefined) {\n return \"right\";\n }\n if (position.top !== undefined) {\n return \"top\";\n }\n if (position.bottom !== undefined) {\n return \"bottom\";\n }\n\n return \"right\";\n}\n\n/**\n * Determine if edge zone should be visible.\n */\nexport function shouldShowEdgeZone(\n config: NormalizedSwipeConfig,\n isOpen: boolean,\n isOpening: boolean,\n): boolean {\n if (!config.enabled) {\n return false;\n }\n if (!config.edgeSwipeOpen) {\n return false;\n }\n // Show when closed or actively opening\n if (!isOpen) {\n return true;\n }\n return isOpening;\n}\n","/**\n * @file Hook for applying real-time transform during drawer swipe gestures.\n *\n * Handles DOM manipulation for smooth swipe animations.\n */\nimport * as React from \"react\";\nimport type { ContinuousOperationState } from \"../../hooks/gesture/types.js\";\nimport { getDrawerAnimationAxis, getDrawerCloseSwipeSign } from \"../../modules/drawer/types.js\";\nimport type { DrawerSwipeDirection } from \"../../modules/drawer/types.js\";\n\ntype UseDrawerSwipeTransformOptions = {\n drawerRef: React.RefObject<HTMLDivElement | null>;\n backdropRef: React.RefObject<HTMLDivElement | null>;\n placement: DrawerSwipeDirection;\n swipeState: ContinuousOperationState;\n displacement: number;\n isOpening: boolean;\n isClosing: boolean;\n enabled: boolean;\n};\n\n/**\n * Apply real-time transform to drawer and backdrop during swipe.\n */\nexport function useDrawerSwipeTransform(options: UseDrawerSwipeTransformOptions): void {\n const {\n drawerRef,\n backdropRef,\n placement,\n swipeState,\n displacement,\n isOpening,\n isClosing,\n enabled,\n } = options;\n\n const isOperating = swipeState.phase === \"operating\";\n\n // Apply real-time transform during swipe\n React.useLayoutEffect(() => {\n if (!enabled || !isOperating) {\n return;\n }\n\n const drawer = drawerRef.current;\n const backdrop = backdropRef.current;\n\n if (!drawer) {\n return;\n }\n\n const axis = getDrawerAnimationAxis(placement);\n const closeSign = getDrawerCloseSwipeSign(placement);\n const drawerSize = axis === \"x\" ? drawer.clientWidth : drawer.clientHeight;\n\n if (drawerSize <= 0) {\n return;\n }\n\n const translateFn = axis === \"x\" ? \"translateX\" : \"translateY\";\n\n if (isClosing) {\n applyClosingTransform(drawer, backdrop, translateFn, closeSign, displacement, drawerSize);\n } else if (isOpening) {\n applyOpeningTransform(drawer, backdrop, translateFn, closeSign, displacement, drawerSize);\n }\n }, [enabled, isOperating, isClosing, isOpening, displacement, placement, drawerRef, backdropRef]);\n\n // Reset transform after swipe ends\n React.useLayoutEffect(() => {\n if (!enabled || swipeState.phase !== \"ended\") {\n return;\n }\n\n const drawer = drawerRef.current;\n const backdrop = backdropRef.current;\n\n if (drawer) {\n drawer.style.transform = \"\";\n }\n if (backdrop) {\n backdrop.style.opacity = \"\";\n }\n }, [enabled, swipeState.phase, drawerRef, backdropRef]);\n}\n\nfunction applyClosingTransform(\n drawer: HTMLDivElement,\n backdrop: HTMLDivElement | null,\n translateFn: \"translateX\" | \"translateY\",\n closeSign: 1 | -1,\n displacement: number,\n drawerSize: number,\n): void {\n const translate = closeSign * displacement;\n drawer.style.transform = `${translateFn}(${translate}px)`;\n\n const progress = Math.min(displacement / drawerSize, 1);\n if (backdrop) {\n backdrop.style.opacity = String(1 - progress);\n }\n}\n\nfunction applyOpeningTransform(\n drawer: HTMLDivElement,\n backdrop: HTMLDivElement | null,\n translateFn: \"translateX\" | \"translateY\",\n closeSign: 1 | -1,\n displacement: number,\n drawerSize: number,\n): void {\n const closedPosition = closeSign * drawerSize;\n const translate = closedPosition + closeSign * -1 * displacement;\n const clampedTranslate = clampTranslate(translate, closeSign);\n drawer.style.transform = `${translateFn}(${clampedTranslate}px)`;\n\n const progress = Math.min(displacement / drawerSize, 1);\n if (backdrop) {\n backdrop.style.opacity = String(progress);\n backdrop.style.pointerEvents = \"auto\";\n }\n}\n\nfunction clampTranslate(translate: number, closeSign: 1 | -1): number {\n if (closeSign > 0) {\n return Math.max(0, translate);\n }\n return Math.min(0, translate);\n}\n","/**\n * @file Drawer component\n *\n * Mobile-friendly slide-in panel with backdrop support.\n * Supports swipe gestures for opening/closing.\n */\nimport * as React from \"react\";\nimport type { DrawerBehavior, WindowPosition } from \"../../types.js\";\nimport {\n FloatingPanelCloseButton,\n FloatingPanelContent,\n FloatingPanelFrame,\n FloatingPanelHeader,\n FloatingPanelTitle,\n} from \"../paneling/FloatingPanelFrame.js\";\nimport {\n DRAWER_HEADER_PADDING_Y,\n DRAWER_HEADER_PADDING_X,\n DRAWER_HEADER_GAP,\n DRAWER_CONTENT_PADDING,\n} from \"../../constants/styles.js\";\nimport { useDrawerSwipeInput } from \"../../modules/drawer/useDrawerSwipeInput.js\";\nimport type { DrawerSwipeDirection } from \"../../modules/drawer/types.js\";\nimport {\n DRAWER_BACKDROP_BASE_STYLE,\n DRAWER_PANEL_BASE_STYLE,\n getPlacementStyle,\n getOpenTransform,\n computeTransitionValue,\n computeBackdropTransition,\n formatDimension,\n computeEdgeZoneStyle,\n} from \"./drawerStyles.js\";\nimport type { DrawerPlacement } from \"./drawerStyles.js\";\nimport {\n parseSwipeGesturesConfig,\n resolvePlacement,\n shouldShowEdgeZone,\n} from \"./drawerSwipeConfig.js\";\nimport { useDrawerSwipeTransform } from \"./useDrawerSwipeTransform.js\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type DrawerProps = {\n id: string;\n config: DrawerBehavior;\n isOpen: boolean;\n onClose: () => void;\n onOpen?: () => void;\n children: React.ReactNode;\n zIndex?: number;\n width?: string | number;\n height?: string | number;\n position?: WindowPosition;\n};\n\n// ============================================================================\n// Sub-components\n// ============================================================================\n\ntype DrawerContentProps = {\n chrome: boolean;\n frameStyle: React.CSSProperties;\n header?: DrawerBehavior[\"header\"];\n dismissible: boolean;\n onClose: () => void;\n children: React.ReactNode;\n};\n\nconst DrawerContent: React.FC<DrawerContentProps> = ({\n chrome,\n frameStyle,\n header,\n dismissible,\n onClose,\n children,\n}) => {\n if (!chrome) {\n return <>{children}</>;\n }\n return (\n <FloatingPanelFrame style={frameStyle}>\n <DrawerHeaderView header={header} dismissible={dismissible} onClose={onClose} />\n <FloatingPanelContent\n style={{ padding: DRAWER_CONTENT_PADDING, flex: 1, display: \"flex\", flexDirection: \"column\" }}\n >\n {children}\n </FloatingPanelContent>\n </FloatingPanelFrame>\n );\n};\n\ntype DrawerHeaderViewProps = {\n header?: DrawerBehavior[\"header\"];\n dismissible: boolean;\n onClose: () => void;\n};\n\nfunction shouldShowCloseButton(dismissible: boolean, showCloseButton: boolean): boolean {\n if (!dismissible) {\n return false;\n }\n return showCloseButton;\n}\n\nfunction renderCloseButton(\n shouldShow: boolean,\n onClose: () => void,\n): React.ReactNode {\n if (!shouldShow) {\n return null;\n }\n return (\n <FloatingPanelCloseButton\n onClick={onClose}\n aria-label=\"Close drawer\"\n style={{ marginLeft: \"auto\" }}\n />\n );\n}\n\nfunction renderEdgeZone(\n showEdgeZone: boolean,\n edgeZoneRef: React.RefObject<HTMLDivElement | null>,\n edgeZoneStyle: React.CSSProperties,\n onPointerDown: ((e: React.PointerEvent<HTMLElement>) => void) | undefined,\n placement: string,\n): React.ReactNode {\n if (!showEdgeZone) {\n return null;\n }\n return (\n <div\n ref={edgeZoneRef}\n style={edgeZoneStyle}\n onPointerDown={onPointerDown}\n data-drawer-edge-zone={placement}\n />\n );\n}\n\nconst DrawerHeaderView: React.FC<DrawerHeaderViewProps> = ({ header, dismissible, onClose }) => {\n if (!header) {\n return null;\n }\n\n const showCloseButton = header.showCloseButton ?? true;\n const shouldShow = shouldShowCloseButton(dismissible, showCloseButton);\n\n return (\n <FloatingPanelHeader\n style={{ padding: `${DRAWER_HEADER_PADDING_Y} ${DRAWER_HEADER_PADDING_X}`, gap: DRAWER_HEADER_GAP }}\n >\n <FloatingPanelTitle>{header.title}</FloatingPanelTitle>\n {renderCloseButton(shouldShow, onClose)}\n </FloatingPanelHeader>\n );\n};\n\n// ============================================================================\n// Style computation hooks\n// ============================================================================\n\nfunction useDrawerPanelStyle(\n placement: DrawerPlacement,\n isOpen: boolean,\n isSwipeOperating: boolean,\n config: DrawerBehavior,\n dimensions: { width?: string | number; height?: string | number; zIndex?: number },\n): React.CSSProperties {\n return React.useMemo((): React.CSSProperties => {\n const effectiveMode = isSwipeOperating ? \"none\" : config.transitionMode;\n const transitionValue = computeTransitionValue(\n effectiveMode,\n config.transitionDuration,\n config.transitionEasing,\n );\n\n const placementStyle = getPlacementStyle(placement);\n const transform = isOpen ? getOpenTransform(placement) : placementStyle.transform;\n const position = config.inline ? \"absolute\" : \"fixed\";\n\n return {\n ...DRAWER_PANEL_BASE_STYLE,\n position,\n ...placementStyle,\n transform,\n transition: transitionValue,\n zIndex: dimensions.zIndex,\n width: formatDimension(dimensions.width),\n height: formatDimension(dimensions.height),\n };\n }, [placement, isOpen, isSwipeOperating, config, dimensions]);\n}\n\nfunction useBackdropStyle(\n placement: DrawerPlacement,\n isOpen: boolean,\n isSwipeOperating: boolean,\n config: DrawerBehavior,\n zIndex: number | undefined,\n): React.CSSProperties {\n return React.useMemo((): React.CSSProperties => {\n const effectiveMode = isSwipeOperating ? \"none\" : config.transitionMode;\n const transitionValue = computeBackdropTransition(effectiveMode, config.transitionDuration);\n const position = config.inline ? \"absolute\" as const : \"fixed\" as const;\n\n return {\n ...DRAWER_BACKDROP_BASE_STYLE,\n position,\n opacity: isOpen ? 1 : 0,\n pointerEvents: isOpen ? \"auto\" : \"none\",\n transition: transitionValue,\n zIndex: zIndex !== undefined ? zIndex - 1 : undefined,\n };\n }, [isOpen, isSwipeOperating, config, zIndex]);\n}\n\nfunction useFrameStyle(placement: DrawerPlacement): React.CSSProperties {\n return React.useMemo((): React.CSSProperties => {\n const style: React.CSSProperties = { borderRadius: 0 };\n if (placement === \"left\" || placement === \"right\") {\n style.height = \"100%\";\n }\n return style;\n }, [placement]);\n}\n\n// ============================================================================\n// Main Component\n// ============================================================================\n\nexport const Drawer: React.FC<DrawerProps> = ({\n id,\n config,\n isOpen,\n onClose,\n onOpen,\n children,\n zIndex,\n width,\n height,\n position,\n}) => {\n const {\n dismissible = true,\n header,\n chrome = true,\n inline = false,\n } = config;\n\n const swipeConfig = parseSwipeGesturesConfig(config.swipeGestures);\n const placement = resolvePlacement(config.anchor, position);\n\n // Refs\n const drawerRef = React.useRef<HTMLDivElement>(null);\n const backdropRef = React.useRef<HTMLDivElement>(null);\n const edgeZoneRef = React.useRef<HTMLDivElement>(null);\n\n // Swipe callbacks\n const handleSwipeOpen = React.useCallback(() => {\n onOpen?.();\n config.onStateChange?.(true);\n }, [onOpen, config]);\n\n const handleSwipeClose = React.useCallback(() => {\n onClose();\n }, [onClose]);\n\n // Swipe input handling\n const {\n state: swipeState,\n displacement,\n edgeContainerProps,\n drawerContentProps,\n isOpening,\n isClosing,\n } = useDrawerSwipeInput({\n edgeContainerRef: edgeZoneRef,\n drawerContentRef: drawerRef,\n direction: placement as DrawerSwipeDirection,\n isOpen,\n onSwipeOpen: handleSwipeOpen,\n onSwipeClose: handleSwipeClose,\n enableEdgeSwipeOpen: swipeConfig.edgeSwipeOpen,\n enableSwipeClose: swipeConfig.swipeClose,\n edgeWidth: swipeConfig.edgeWidth,\n dismissThreshold: swipeConfig.dismissThreshold,\n });\n\n const isSwipeOperating = swipeState.phase === \"operating\";\n\n // Apply swipe transform\n useDrawerSwipeTransform({\n drawerRef,\n backdropRef,\n placement: placement as DrawerSwipeDirection,\n swipeState,\n displacement,\n isOpening,\n isClosing,\n enabled: swipeConfig.enabled,\n });\n\n // Computed styles\n const drawerStyle = useDrawerPanelStyle(placement, isOpen, isSwipeOperating, config, { width, height, zIndex });\n const backdropStyle = useBackdropStyle(placement, isOpen, isSwipeOperating, config, zIndex);\n const frameStyle = useFrameStyle(placement);\n\n // Edge zone style: merge positioning style with gesture handlers' style\n const edgeZoneStyle = React.useMemo((): React.CSSProperties => {\n const positioningStyle = computeEdgeZoneStyle({\n placement,\n inline,\n edgeWidth: swipeConfig.edgeWidth,\n zIndex,\n });\n // Merge with gesture container styles (touchAction, etc.)\n return { ...positioningStyle, ...edgeContainerProps.style };\n }, [placement, inline, swipeConfig.edgeWidth, zIndex, edgeContainerProps.style]);\n\n // Merged drawer style with swipe props\n const mergedDrawerStyle = React.useMemo((): React.CSSProperties => {\n if (!swipeConfig.enabled) {\n return drawerStyle;\n }\n return { ...drawerStyle, ...drawerContentProps.style };\n }, [swipeConfig.enabled, drawerStyle, drawerContentProps.style]);\n\n // Visibility flags\n const showEdgeZone = shouldShowEdgeZone(swipeConfig, isOpen, isOpening);\n const ariaLabel = header?.title ?? config.ariaLabel ?? \"Drawer\";\n\n const edgeZoneElement = renderEdgeZone(showEdgeZone, edgeZoneRef, edgeZoneStyle, edgeContainerProps.onPointerDown, placement);\n\n return (\n <>\n {edgeZoneElement}\n <div\n ref={backdropRef}\n style={backdropStyle}\n onClick={dismissible ? onClose : undefined}\n />\n <div\n ref={drawerRef}\n data-layer-id={id}\n data-placement={placement}\n style={mergedDrawerStyle}\n role=\"dialog\"\n aria-modal={dismissible ? true : undefined}\n aria-hidden={isOpen ? undefined : true}\n aria-label={ariaLabel}\n onPointerDown={swipeConfig.enabled ? drawerContentProps.onPointerDown : undefined}\n >\n <DrawerContent\n chrome={chrome}\n frameStyle={frameStyle}\n header={header}\n dismissible={dismissible}\n onClose={onClose}\n >\n {children}\n </DrawerContent>\n </div>\n </>\n );\n};\n","/**\n * @file Generic transition state management with animation support.\n */\nimport * as React from \"react\";\n\nexport type TransitionMode = \"none\" | \"css\";\n\nexport type TransitionOptions = {\n mode?: TransitionMode;\n element?: React.RefObject<HTMLElement>;\n duration?: number;\n};\n\nexport type UseTransitionStateOptions = {\n onOpen?: (id: string) => void;\n onClose?: (id: string) => void;\n onTransitionEnd?: (id: string, isOpen: boolean) => void;\n};\n\nconst waitForTransitionEnd = (el: HTMLElement, timeout: number): Promise<void> =>\n new Promise((resolve) => {\n // eslint-disable-next-line no-restricted-syntax -- mutable flag needed for deduplication\n let resolved = false;\n const done = () => {\n if (resolved) {return;}\n resolved = true;\n el.removeEventListener(\"transitionend\", handler);\n resolve();\n };\n const handler = (e: TransitionEvent) => {\n if (e.target === el) {done();}\n };\n el.addEventListener(\"transitionend\", handler);\n setTimeout(done, timeout + 50);\n });\n\nexport const runTransition = async (\n update: () => void,\n mode: TransitionMode,\n el: HTMLElement | null | undefined,\n duration: number,\n): Promise<void> => {\n switch (mode) {\n case \"none\":\n update();\n return;\n\n case \"css\":\n update();\n if (el) {await waitForTransitionEnd(el, duration);}\n return;\n }\n};\n\nexport const useTransitionState = (options?: UseTransitionStateOptions) => {\n const [states, setStates] = React.useState<Record<string, boolean>>({});\n const optionsRef = React.useRef(options);\n optionsRef.current = options;\n\n const update = React.useCallback(\n async (id: string, isOpen: boolean, transitionOptions?: TransitionOptions) => {\n const { mode = \"none\", element, duration = 300 } = transitionOptions ?? {};\n\n const applyState = () => {\n setStates((prev) => {\n if (prev[id] === isOpen) {return prev;}\n return { ...prev, [id]: isOpen };\n });\n };\n\n await runTransition(applyState, mode, element?.current, duration);\n\n const opts = optionsRef.current;\n if (isOpen) {\n opts?.onOpen?.(id);\n } else {\n opts?.onClose?.(id);\n }\n opts?.onTransitionEnd?.(id, isOpen);\n },\n [],\n );\n\n const state = React.useCallback((id: string): boolean => states[id] ?? false, [states]);\n const open = React.useCallback(\n (id: string, opts?: TransitionOptions) => update(id, true, opts),\n [update],\n );\n const close = React.useCallback(\n (id: string, opts?: TransitionOptions) => update(id, false, opts),\n [update],\n );\n\n return { state, open, close };\n};\n","/**\n * @file Hook for managing drawer state (controlled/uncontrolled)\n */\nimport * as React from \"react\";\nimport {\n type TransitionMode,\n type TransitionOptions,\n runTransition,\n} from \"../../hooks/useTransitionState\";\nimport type { LayerDefinition } from \"../../types\";\n\nconst parseDuration = (value: string | undefined): number => {\n if (!value) {return 300;}\n const match = value.match(/(\\d+)/);\n return match ? parseInt(match[1], 10) : 300;\n};\n\nexport const useDrawerState = (layers: LayerDefinition[]) => {\n const [drawerStates, setDrawerStates] = React.useState<Record<string, boolean>>(() => {\n const initial: Record<string, boolean> = {};\n layers.forEach((layer) => {\n if (layer.drawer) {\n initial[layer.id] = layer.drawer.defaultOpen ?? false;\n }\n });\n return initial;\n });\n\n const layerMap = React.useMemo(() => {\n const map = new Map<string, LayerDefinition>();\n layers.forEach((layer) => map.set(layer.id, layer));\n return map;\n }, [layers]);\n\n const updateState = React.useCallback(\n async (layerId: string, isOpen: boolean, options?: TransitionOptions) => {\n const layer = layerMap.get(layerId);\n if (!layer?.drawer) {return;}\n\n const mode: TransitionMode = options?.mode ?? layer.drawer.transitionMode ?? \"css\";\n const duration = options?.duration ?? parseDuration(layer.drawer.transitionDuration);\n const element = options?.element?.current;\n\n const applyState = () => {\n if (layer.drawer?.open === undefined) {\n setDrawerStates((prev) => {\n if (prev[layerId] === isOpen) {return prev;}\n return { ...prev, [layerId]: isOpen };\n });\n }\n layer.drawer?.onStateChange?.(isOpen);\n };\n\n await runTransition(applyState, mode, element, duration);\n },\n [layerMap],\n );\n\n const state = React.useCallback(\n (layerId: string): boolean => {\n const layer = layerMap.get(layerId);\n if (layer?.drawer?.open !== undefined) {\n return layer.drawer.open;\n }\n return drawerStates[layerId] ?? false;\n },\n [layerMap, drawerStates],\n );\n\n const open = React.useCallback(\n (id: string, options?: TransitionOptions) => updateState(id, true, options),\n [updateState],\n );\n\n const close = React.useCallback(\n (id: string, options?: TransitionOptions) => updateState(id, false, options),\n [updateState],\n );\n\n return { state, open, close };\n};\n","/**\n * @file DrawerLayers component\n */\nimport * as React from \"react\";\nimport type { LayerDefinition } from \"../../types.js\";\nimport { Drawer } from \"./Drawer.js\";\nimport { useDrawerState } from \"../../modules/window/useDrawerState.js\";\n\nexport type DrawerLayersProps = {\n layers: LayerDefinition[];\n};\n\nexport const DrawerLayers: React.FC<DrawerLayersProps> = ({ layers }) => {\n const drawer = useDrawerState(layers);\n\n const drawerLayers = React.useMemo(() => layers.filter((layer) => layer.drawer), [layers]);\n\n const closeHandlers = React.useMemo(() => {\n const handlers = new Map<string, () => void>();\n drawerLayers.forEach((layer) => {\n handlers.set(layer.id, () => drawer.close(layer.id));\n });\n return handlers;\n }, [drawerLayers, drawer.close]);\n\n const openHandlers = React.useMemo(() => {\n const handlers = new Map<string, () => void>();\n drawerLayers.forEach((layer) => {\n handlers.set(layer.id, () => drawer.open(layer.id));\n });\n return handlers;\n }, [drawerLayers, drawer.open]);\n\n return (\n <>\n {drawerLayers.map((layer) => {\n if (!layer.drawer) {\n return null;\n }\n\n const isOpen = drawer.state(layer.id);\n const onClose = closeHandlers.get(layer.id);\n const onOpen = openHandlers.get(layer.id);\n\n if (!onClose) {\n return null;\n }\n\n return (\n <Drawer\n key={layer.id}\n id={layer.id}\n config={layer.drawer}\n isOpen={isOpen}\n onClose={onClose}\n onOpen={onOpen}\n zIndex={layer.zIndex}\n width={layer.width}\n height={layer.height}\n position={layer.position}\n >\n {layer.component}\n </Drawer>\n );\n })}\n </>\n );\n};\n","/**\n * @file Context provider for grid layer rendering helpers.\n */\nimport * as React from \"react\";\nimport type { LayerDefinition } from \"../../types\";\n\nexport type GridLayerHandleProps = React.HTMLAttributes<HTMLElement> & {\n \"data-drag-handle\": \"true\";\n};\n\nexport type ResizeHandleConfig =\n | {\n key: \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\";\n variant: \"corner\";\n horizontal: \"left\" | \"right\";\n vertical: \"top\" | \"bottom\";\n }\n | {\n key: \"left\" | \"right\" | \"top\" | \"bottom\";\n variant: \"edge\";\n horizontal?: \"left\" | \"right\";\n vertical?: \"top\" | \"bottom\";\n };\n\nexport type GridLayerRenderState = {\n style: React.CSSProperties;\n isResizable: boolean;\n isResizing: boolean;\n onResizeHandlePointerDown: (config: ResizeHandleConfig, event: React.PointerEvent<HTMLDivElement>) => void;\n};\n\nexport type GridLayoutContextValue = {\n handleLayerPointerDown: (event: React.PointerEvent<HTMLDivElement>) => void;\n getLayerRenderState: (layer: LayerDefinition) => GridLayerRenderState;\n getLayerHandleProps: (layerId: string) => GridLayerHandleProps;\n /**\n * Whether the GridLayout is mounted at root level.\n * When true, scrollable layers should delegate to browser's native scroll.\n */\n isRootLevel: boolean;\n};\n\nconst GridLayoutContext = React.createContext<GridLayoutContextValue | null>(null);\n\nexport const GridLayoutProvider: React.FC<\n React.PropsWithChildren<{ value: GridLayoutContextValue }>\n> = ({ value, children }) => {\n return <GridLayoutContext.Provider value={value}>{children}</GridLayoutContext.Provider>;\n};\n\nexport const useGridLayoutContext = (): GridLayoutContextValue => {\n const context = React.useContext(GridLayoutContext);\n if (!context) {\n throw new Error(\"useGridLayoutContext must be used within a GridLayoutProvider.\");\n }\n return context;\n};\n","/**\n * @file PanelSystemContext\n *\n * Core provider for panel definitions and registry. Grid-specific layout and\n * interactions are composed by UI layers (e.g., GridLayout) on top of this.\n *\n * Includes content caching to preserve React component state across re-renders.\n * This is essential for maintaining internal state when parent components\n * re-create the layers array.\n */\nimport * as React from \"react\";\nimport type { PanelLayoutConfig, LayerDefinition } from \"./types\";\nimport { useContentCache } from \"./hooks/useContentCache\";\n\nexport type PanelSystemContextValue = {\n config: PanelLayoutConfig;\n style?: React.CSSProperties;\n layers: {\n /** Raw panel definitions (no grid normalization). */\n defs: LayerDefinition[];\n /** Fast lookup map by id for consumers. */\n layerById: Map<string, LayerDefinition>;\n };\n /**\n * Get cached content for a layer. Returns the same ReactNode reference\n * for the same layer ID to prevent remounting on parent re-renders.\n */\n getCachedContent: (layerId: string) => React.ReactNode | null;\n};\n\nconst PanelSystemContext = React.createContext<PanelSystemContextValue | null>(null);\n\nexport const usePanelSystem = (): PanelSystemContextValue => {\n const ctx = React.useContext(PanelSystemContext);\n if (!ctx) {\n throw new Error(\"usePanelSystem must be used within a PanelSystemProvider.\");\n }\n return ctx;\n};\n\nexport type PanelSystemProviderProps = React.PropsWithChildren<{\n config: PanelLayoutConfig;\n layers: LayerDefinition[];\n style?: React.CSSProperties;\n}>;\n\nexport const PanelSystemProvider: React.FC<PanelSystemProviderProps> = ({ config, layers, style, children }) => {\n const layerById = React.useMemo(() => {\n const map = new Map<string, LayerDefinition>();\n layers.forEach((layer) => {\n map.set(layer.id, layer);\n });\n return map;\n }, [layers]);\n\n // Content resolver for useContentCache\n const resolveContent = React.useCallback(\n (layerId: string): React.ReactNode | null => {\n const layer = layerById.get(layerId);\n return layer?.component ?? null;\n },\n [layerById],\n );\n\n // Valid IDs for cache cleanup\n const validIds = React.useMemo(() => layers.map((l) => l.id), [layers]);\n\n // Use shared content cache hook\n const { getCachedContent } = useContentCache({\n resolveContent,\n validIds,\n });\n\n const value = React.useMemo<PanelSystemContextValue>(\n () => ({\n config,\n style,\n layers: {\n defs: layers,\n layerById,\n },\n getCachedContent,\n }),\n [config, style, layers, layerById, getCachedContent],\n );\n\n return <PanelSystemContext.Provider value={value}>{children}</PanelSystemContext.Provider>;\n};\n","/**\n * @file Context exposing the current grid layer id and helpers to child components.\n */\nimport * as React from \"react\";\nimport type { LayerDefinition } from \"../../types\";\nimport { usePanelSystem } from \"../../PanelSystemContext\";\nimport { useGridLayoutContext, type GridLayerHandleProps } from \"./GridLayoutContext\";\n\ntype LayerInstanceContextValue = {\n layerId: string;\n};\n\nconst LayerInstanceContext = React.createContext<LayerInstanceContextValue | null>(null);\n\nexport type LayerInstanceProviderProps = React.PropsWithChildren<LayerInstanceContextValue>;\n\nexport const LayerInstanceProvider: React.FC<LayerInstanceProviderProps> = ({ layerId, children }) => {\n const value = React.useMemo(() => ({ layerId }), [layerId]);\n return <LayerInstanceContext.Provider value={value}>{children}</LayerInstanceContext.Provider>;\n};\n\nexport const useLayerInstance = (): LayerInstanceContextValue => {\n const value = React.useContext(LayerInstanceContext);\n if (!value) {\n throw new Error(\"useLayerInstance must be used within a LayerInstanceProvider.\");\n }\n return value;\n};\n\n/**\n * Convenience: read the current layer definition from the core registry.\n */\nexport const useCurrentLayerDefinition = (): LayerDefinition => {\n const { layerId } = useLayerInstance();\n const { layers } = usePanelSystem();\n const def = layers.layerById.get(layerId);\n if (!def) {\n throw new Error(`Layer definition not found for id: ${layerId}`);\n }\n return def;\n};\n\n/**\n * Convenience: get drag handle props, pre-bound to the current layer.\n */\nexport const useCurrentLayerHandleProps = (): GridLayerHandleProps => {\n const { layerId } = useLayerInstance();\n const { getLayerHandleProps } = useGridLayoutContext();\n return React.useMemo(() => getLayerHandleProps(layerId), [getLayerHandleProps, layerId]);\n};\n\n/**\n * Compatibility helper for existing code using useLayerDragHandle.\n * Prefer useCurrentLayerHandleProps for direct access.\n */\nexport const useLayerDragHandleProps = useCurrentLayerHandleProps;\n","/**\n * @file Renders floating layers inside a dedicated browser popup window.\n */\nimport * as React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type { LayerDefinition, PopupWindowOptions, WindowPosition, WindowBounds } from \"../../types\";\nimport { LayerInstanceProvider } from \"../../modules/grid/LayerInstanceContext\";\n\nconst ensureNumericOffset = (value: number | string | undefined, key: keyof WindowPosition, layerId: string): number => {\n if (typeof value === \"number\" && Number.isFinite(value)) {\n return value;\n }\n throw new Error(`Popup layer \"${layerId}\" requires a numeric \"${key}\" value.`);\n};\n\nconst resolvePopupAnchor = (position: WindowPosition | undefined, layerId: string): { left: number; top: number } => {\n if (!position) {\n throw new Error(`Popup layer \"${layerId}\" must define position (left/top).`);\n }\n return {\n left: ensureNumericOffset(position.left, \"left\", layerId),\n top: ensureNumericOffset(position.top, \"top\", layerId),\n };\n};\n\nconst numericFeature = (value: number): string => {\n return `${Math.round(value)}`;\n};\n\nconst booleanFeature = (value: boolean | undefined): string | undefined => {\n if (value === undefined) {\n return undefined;\n }\n return value ? \"yes\" : \"no\";\n};\n\nconst buildWindowFeatures = (\n layerId: string,\n position: WindowPosition | undefined,\n width: number | string | undefined,\n height: number | string | undefined,\n options: PopupWindowOptions | undefined,\n): string => {\n const features: Record<string, string> = {};\n const anchor = resolvePopupAnchor(position, layerId);\n\n if (typeof width !== \"number\" || typeof height !== \"number\") {\n throw new Error(`Popup layer \"${layerId}\" requires numeric width/height.`);\n }\n features.width = numericFeature(width);\n features.height = numericFeature(height);\n features.left = numericFeature(anchor.left);\n features.top = numericFeature(anchor.top);\n\n const overrides = options?.features;\n if (overrides) {\n const toolbar = booleanFeature(overrides.toolbar);\n const menubar = booleanFeature(overrides.menubar);\n const location = booleanFeature(overrides.location);\n const status = booleanFeature(overrides.status);\n const resizable = booleanFeature(overrides.resizable);\n const scrollbars = booleanFeature(overrides.scrollbars);\n\n if (toolbar !== undefined) {\n features.toolbar = toolbar;\n }\n if (menubar !== undefined) {\n features.menubar = menubar;\n }\n if (location !== undefined) {\n features.location = location;\n }\n if (status !== undefined) {\n features.status = status;\n }\n if (resizable !== undefined) {\n features.resizable = resizable;\n }\n if (scrollbars !== undefined) {\n features.scrollbars = scrollbars;\n }\n }\n\n return Object.entries(features)\n .map(([key, value]) => `${key}=${value}`)\n .join(\",\");\n};\n\nconst applyBoundsToWindow = (\n popupWindow: Window,\n layerId: string,\n position: WindowPosition | undefined,\n width: number | string | undefined,\n height: number | string | undefined,\n) => {\n const anchor = resolvePopupAnchor(position, layerId);\n if (typeof width !== \"number\" || typeof height !== \"number\") {\n throw new Error(`Popup layer \"${layerId}\" requires numeric width/height.`);\n }\n popupWindow.moveTo(Math.round(anchor.left), Math.round(anchor.top));\n popupWindow.resizeTo(Math.round(width), Math.round(height));\n};\n\ntype PopupLayerPortalProps = {\n layer: LayerDefinition;\n};\n\nexport const PopupLayerPortal: React.FC<PopupLayerPortalProps> = ({ layer }) => {\n const floating = layer.floating;\n if (!floating) {\n throw new Error(`Layer \"${layer.id}\" is missing floating configuration required for popup mode.`);\n }\n const mode = floating.mode ?? \"embedded\";\n if (mode !== \"popup\") {\n throw new Error(`PopupLayerPortal received layer \"${layer.id}\" that is not configured for popup mode.`);\n }\n\n const containerRef = React.useRef<HTMLDivElement | null>(null);\n const popupWindowRef = React.useRef<Window | null>(null);\n const [isMounted, setIsMounted] = React.useState(false);\n\n React.useEffect(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n\n const features = buildWindowFeatures(layer.id, layer.position, layer.width, layer.height, floating.popup);\n const windowName = floating.popup?.name ?? layer.id;\n const createdWindow = resolvePopupWindow(\n windowName,\n features,\n {\n position: layer.position,\n size: { width: layer.width as number, height: layer.height as number },\n },\n floating.popup,\n );\n\n if (!createdWindow) {\n throw new Error(`Failed to open popup window for layer \"${layer.id}\".`);\n }\n\n const openedWindow = createdWindow;\n\n popupWindowRef.current = openedWindow;\n\n if (floating.popup?.focus !== false) {\n openedWindow.focus();\n }\n\n if (!openedWindow.document.title) {\n openedWindow.document.title = layer.id;\n }\n openedWindow.document.body.innerHTML = \"\";\n const mountNode = openedWindow.document.createElement(\"div\");\n mountNode.dataset.layerId = layer.id;\n openedWindow.document.body.appendChild(mountNode);\n containerRef.current = mountNode;\n setIsMounted(true);\n\n applyBoundsToWindow(openedWindow, layer.id, layer.position, layer.width, layer.height);\n\n const handleBeforeUnload = () => {\n popupWindowRef.current = null;\n containerRef.current = null;\n setIsMounted(false);\n };\n openedWindow.addEventListener(\"beforeunload\", handleBeforeUnload);\n\n return () => {\n openedWindow.removeEventListener(\"beforeunload\", handleBeforeUnload);\n if (floating.popup?.closeOnUnmount !== false) {\n openedWindow.close();\n }\n popupWindowRef.current = null;\n containerRef.current = null;\n setIsMounted(false);\n };\n }, [\n floating.popup?.closeOnUnmount,\n floating.popup?.features?.location,\n floating.popup?.features?.menubar,\n floating.popup?.features?.resizable,\n floating.popup?.features?.scrollbars,\n floating.popup?.features?.status,\n floating.popup?.features?.toolbar,\n floating.popup?.focus,\n floating.popup?.name,\n layer.id,\n ]);\n\n React.useEffect(() => {\n const popupWindow = popupWindowRef.current;\n if (!popupWindow) {\n return;\n }\n applyBoundsToWindow(popupWindow, layer.id, layer.position, layer.width, layer.height);\n }, [layer.position?.left, layer.position?.top, layer.height, layer.width, layer.id]);\n\n if (!isMounted || !containerRef.current) {\n return null;\n }\n\n return createPortal(<LayerInstanceProvider layerId={layer.id}>{layer.component}</LayerInstanceProvider>, containerRef.current);\n};\n\nconst resolvePopupWindow = (\n windowName: string,\n features: string,\n bounds: WindowBounds,\n options: PopupWindowOptions | undefined,\n): Window | null => {\n const customFactory = options?.createWindow;\n if (customFactory) {\n return customFactory({ name: windowName, features, bounds });\n }\n return window.open(\"\", windowName, features);\n};\n","/**\n * @file FloatingWindow component with chrome support\n *\n * Renders floating panel content with optional built-in chrome (FloatingPanelFrame).\n * When chrome is enabled and header is provided, header becomes the drag handle.\n */\nimport * as React from \"react\";\nimport type { FloatingBehavior } from \"../../types\";\nimport {\n FloatingPanelCloseButton,\n FloatingPanelFrame,\n FloatingPanelHeader,\n FloatingPanelTitle,\n FloatingPanelControls,\n FloatingPanelContent,\n} from \"../paneling/FloatingPanelFrame\";\n\nexport type FloatingWindowProps = {\n id: string;\n config: FloatingBehavior;\n onClose: () => void;\n children: React.ReactNode;\n};\n\ntype CloseButtonProps = {\n onClick: () => void;\n};\n\nconst CloseButton: React.FC<CloseButtonProps> = ({ onClick }) => (\n <FloatingPanelControls>\n <FloatingPanelCloseButton onClick={onClick} aria-label=\"Close window\" data-drag-ignore=\"true\" />\n </FloatingPanelControls>\n);\n\ntype FloatingWindowHeaderProps = {\n header?: FloatingBehavior[\"header\"];\n draggable?: boolean;\n onClose: () => void;\n};\n\nconst FloatingWindowHeader: React.FC<FloatingWindowHeaderProps> = ({ header, draggable, onClose }) => {\n if (!header) {\n return null;\n }\n\n const showCloseButton = header.showCloseButton ?? false;\n const dragHandleProps = draggable ? { \"data-drag-handle\": \"true\" } : {};\n const cursorStyle = draggable ? \"grab\" : undefined;\n\n return (\n <FloatingPanelHeader {...dragHandleProps} style={{ cursor: cursorStyle }}>\n {header.title ? <FloatingPanelTitle>{header.title}</FloatingPanelTitle> : null}\n {showCloseButton ? <CloseButton onClick={onClose} /> : null}\n </FloatingPanelHeader>\n );\n};\n\ntype FloatingWindowViewProps = {\n header?: FloatingBehavior[\"header\"];\n draggable?: boolean;\n chrome: boolean;\n onClose: () => void;\n children: React.ReactNode;\n};\n\nconst FloatingWindowView: React.FC<FloatingWindowViewProps> = ({ header, draggable, chrome, onClose, children }) => {\n if (!chrome) {\n return <>{children}</>;\n }\n\n return (\n <FloatingPanelFrame style={{ height: \"100%\", width: \"100%\" }}>\n <FloatingWindowHeader header={header} draggable={draggable} onClose={onClose} />\n <FloatingPanelContent style={{ flex: 1, display: \"flex\", flexDirection: \"column\" }}>\n {children}\n </FloatingPanelContent>\n </FloatingPanelFrame>\n );\n};\n\nexport const FloatingWindow: React.FC<FloatingWindowProps> = ({ id, config, onClose, children }) => {\n const chrome = config.chrome ?? false;\n const draggable = config.draggable ?? false;\n const ariaLabel = config.header?.title ?? config.ariaLabel ?? \"Floating window\";\n\n return (\n <div data-floating-window={id} role=\"dialog\" aria-label={ariaLabel} style={{ height: \"100%\", width: \"100%\" }}>\n <FloatingWindowView header={config.header} draggable={draggable} chrome={chrome} onClose={onClose}>\n {children}\n </FloatingWindowView>\n </div>\n );\n};\n\nFloatingWindow.displayName = \"FloatingWindow\";\n"],"names":["SWIPE_SAFE_ZONE_ATTR","SwipeSafeZone","children","className","style","jsx","isInSwipeSafeZone","element","container","current","getDrawerAnimationAxis","direction","getDrawerCloseSwipeSign","getDrawerOpenSwipeSign","DEFAULT_DISMISS_THRESHOLD","VELOCITY_THRESHOLD","getContainerSize","axis","getAxisDelta","start","PHASE_MAP","normalizePhase","phase","computeDisplacementValue","closeSwipeSign","closeDisplacement","signedDisplacement","computeAxisDisplacement","displacement","isEdgeSwipeEnabled","enableEdgeSwipeOpen","isOpen","isCloseSwipeEnabled","enableSwipeClose","isDrawerOpening","isEdgeGesture","isDrawerClosing","closePhase","computeVelocity","timeDelta","useDrawerSwipeInput","options","edgeContainerRef","drawerContentRef","onSwipeOpen","onSwipeClose","edgeWidth","dismissThreshold","openSwipeSign","containerSizeRef","React","updateSize","observer","handleOpenSwipeEnd","state","edgeSwipeState","edgeSwipeProps","useEdgeSwipeInput","guardProps","useNativeGestureGuard","closeTracking","baseClosePointerDown","usePointerTracking","setClosePhase","lastCloseDisplacementRef","onClosePointerDown","event","target","isScrollableInDirection","signedDelta","containerSize","ratio","velocity","isOpening","isClosing","progress","IDLE_CONTINUOUS_OPERATION_STATE","edgeContainerProps","mergeGestureContainerProps","drawerContentProps","DRAWER_BACKDROP_BASE_STYLE","COLOR_DRAWER_BACKDROP","DRAWER_PANEL_BASE_STYLE","PLACEMENT_STYLES","OPEN_TRANSFORMS","getPlacementStyle","placement","getOpenTransform","computeTransitionValue","mode","duration","easing","durationValue","DRAWER_TRANSITION_DURATION","easingValue","DRAWER_TRANSITION_EASING","computeBackdropTransition","formatDimension","value","computeEdgeZoneStyle","inline","zIndex","position","computedZIndex","getEdgeZoneStyleByPlacement","base","DEFAULT_EDGE_WIDTH","DISABLED_CONFIG","ENABLED_DEFAULT_CONFIG","parseSwipeGesturesConfig","swipeGestures","resolvePlacement","anchor","shouldShowEdgeZone","config","useDrawerSwipeTransform","drawerRef","backdropRef","swipeState","enabled","isOperating","drawer","backdrop","closeSign","drawerSize","translateFn","applyClosingTransform","applyOpeningTransform","translate","clampedTranslate","clampTranslate","DrawerContent","chrome","frameStyle","header","dismissible","onClose","jsxs","FloatingPanelFrame","DrawerHeaderView","FloatingPanelContent","DRAWER_CONTENT_PADDING","shouldShowCloseButton","showCloseButton","renderCloseButton","shouldShow","FloatingPanelCloseButton","renderEdgeZone","showEdgeZone","edgeZoneRef","edgeZoneStyle","onPointerDown","FloatingPanelHeader","DRAWER_HEADER_PADDING_Y","DRAWER_HEADER_PADDING_X","DRAWER_HEADER_GAP","FloatingPanelTitle","useDrawerPanelStyle","isSwipeOperating","dimensions","effectiveMode","transitionValue","placementStyle","transform","useBackdropStyle","useFrameStyle","Drawer","id","onOpen","width","height","swipeConfig","handleSwipeOpen","handleSwipeClose","drawerStyle","backdropStyle","mergedDrawerStyle","ariaLabel","edgeZoneElement","Fragment","waitForTransitionEnd","el","timeout","resolve","resolved","done","handler","e","runTransition","update","useTransitionState","states","setStates","optionsRef","transitionOptions","prev","opts","open","close","parseDuration","match","useDrawerState","layers","drawerStates","setDrawerStates","initial","layer","layerMap","map","updateState","layerId","DrawerLayers","drawerLayers","closeHandlers","handlers","openHandlers","GridLayoutContext","GridLayoutProvider","useGridLayoutContext","context","PanelSystemContext","usePanelSystem","ctx","PanelSystemProvider","layerById","resolveContent","validIds","l","getCachedContent","useContentCache","LayerInstanceContext","LayerInstanceProvider","useLayerInstance","ensureNumericOffset","key","resolvePopupAnchor","numericFeature","booleanFeature","buildWindowFeatures","features","overrides","toolbar","menubar","location","status","resizable","scrollbars","applyBoundsToWindow","popupWindow","PopupLayerPortal","floating","containerRef","popupWindowRef","isMounted","setIsMounted","windowName","createdWindow","resolvePopupWindow","openedWindow","mountNode","handleBeforeUnload","createPortal","bounds","customFactory","CloseButton","onClick","FloatingPanelControls","FloatingWindowHeader","draggable","dragHandleProps","cursorStyle","FloatingWindowView","FloatingWindow"],"mappings":"4iBAiBaA,GAAuB,uBAqBvBC,GAA8C,CAAC,CAC1D,SAAAC,EACA,UAAAC,EACA,MAAAC,CACF,IAEIC,EAAAA,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AAe,QAAA,EACrE,SAAA1I,CAAA,CACH,CAAA,EACF,oBATU,SAAAA,EAAS,EAaV8Q,GAAgD,CAAC,CAAE,GAAAzG,EAAI,OAAArD,EAAQ,QAAAsB,EAAS,SAAAtI,KAAe,CAClG,MAAMkI,EAASlB,EAAO,QAAU,GAC1B0J,EAAY1J,EAAO,WAAa,GAChC+D,EAAY/D,EAAO,QAAQ,OAASA,EAAO,WAAa,kBAE9D,OACE7G,EAAAA,IAAC,MAAA,CAAI,uBAAsBkK,EAAI,KAAK,SAAS,aAAYU,EAAW,MAAO,CAAE,OAAQ,OAAQ,MAAO,MAAA,EAClG,SAAA5K,EAAAA,IAAC0Q,GAAA,CAAmB,OAAQ7J,EAAO,OAAQ,UAAA0J,EAAsB,OAAAxI,EAAgB,QAAAI,EAC9E,SAAAtI,CAAA,CACH,CAAA,CACF,CAEJ,EAEA8Q,GAAe,YAAc"}
@@ -0,0 +1,2 @@
1
+ "use strict";const S=require("react/jsx-runtime"),yt=require("react"),L=require("./FloatingWindow-DMwyK0eK.cjs"),v=require("./styles-qf6ptVLD.cjs"),Tt=require("./SwipePivotTabBar-fjjXkpj7.cjs"),Lt=require("./ResizeHandle-CBcAS918.cjs"),mt=require("./useIsomorphicLayoutEffect-DGRNF4Lf.cjs"),j=require("./useDocumentPointerEvents-DxDSOtip.cjs");function xt(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const d=xt(yt),_t=()=>{const t=new Map;return e=>{if(!e)return;const n=t.get(e);if(n!==void 0)return n;const r=t.size;return t.set(e,r),r}},Ht=_t(),K=new Map,Pt=t=>{const e=`ovs-threshold:${t.threshold}-rootMargin:${t.rootMargin}-root:${Ht(t.root)}`;if(K.has(e))return K.get(e);const n=new class{#t=new Map;#e=new IntersectionObserver(r=>{r.forEach(o=>{const s=this.#t.get(o.target);s&&s(o)})},t);observe(r,o){return this.#t.set(r,o),this.#e.observe(r),()=>{this.#t.delete(r),this.#e.unobserve(r)}}};return K.set(e,n),n},st=Object.freeze({x:0,y:0,width:0,height:0,top:0,right:0,bottom:0,left:0});function Mt(t,{threshold:e=0,rootMargin:n="0px",root:r=null}){const[o,s]=d.useState(null);return d.useEffect(()=>{const a=t.current;return a?Pt({threshold:e,rootMargin:n,root:r}).observe(a,u=>{s({isIntersecting:u.isIntersecting,boundingClientRect:u.boundingClientRect,intersectionRatio:u.intersectionRatio,intersectionRect:u.intersectionRect,rootBounds:u.rootBounds,target:u.target,time:u.time})}):void 0},[t,e,n,r]),d.useMemo(()=>({isIntersecting:o?.isIntersecting??!1,boundingClientRect:o?.boundingClientRect??st,intersectionRatio:o?.intersectionRatio??0,intersectionRect:o?.intersectionRect??st,rootBounds:o?.rootBounds??null,target:o?.target??t.current,time:o?.time??0}),[o,t])}const pt={position:"absolute",pointerEvents:"auto",boxSizing:"border-box",background:"transparent",border:"none"},Dt={...pt,width:v.GRID_LAYER_CORNER_HIT_SIZE,height:v.GRID_LAYER_CORNER_HIT_SIZE,zIndex:2},Gt={...pt,zIndex:1},Nt={"top-left":{top:0,left:0,transform:"translate(-50%, -50%)",cursor:"nwse-resize"},"top-right":{top:0,right:0,transform:"translate(50%, -50%)",cursor:"nesw-resize"},"bottom-left":{bottom:0,left:0,transform:"translate(-50%, 50%)",cursor:"nesw-resize"},"bottom-right":{bottom:0,right:0,transform:"translate(50%, 50%)",cursor:"nwse-resize"}},kt={left:{top:v.GRID_LAYER_CORNER_HIT_SIZE,bottom:v.GRID_LAYER_CORNER_HIT_SIZE,left:0,width:v.GRID_LAYER_EDGE_HIT_THICKNESS,transform:"translateX(-50%)",cursor:"ew-resize"},right:{top:v.GRID_LAYER_CORNER_HIT_SIZE,bottom:v.GRID_LAYER_CORNER_HIT_SIZE,right:0,width:v.GRID_LAYER_EDGE_HIT_THICKNESS,transform:"translateX(50%)",cursor:"ew-resize"},top:{left:v.GRID_LAYER_CORNER_HIT_SIZE,right:v.GRID_LAYER_CORNER_HIT_SIZE,top:0,height:v.GRID_LAYER_EDGE_HIT_THICKNESS,transform:"translateY(-50%)",cursor:"ns-resize"},bottom:{left:v.GRID_LAYER_CORNER_HIT_SIZE,right:v.GRID_LAYER_CORNER_HIT_SIZE,bottom:0,height:v.GRID_LAYER_EDGE_HIT_THICKNESS,transform:"translateY(50%)",cursor:"ns-resize"}},At=[{key:"top-left",variant:"corner",horizontal:"left",vertical:"top"},{key:"top-right",variant:"corner",horizontal:"right",vertical:"top"},{key:"bottom-left",variant:"corner",horizontal:"left",vertical:"bottom"},{key:"bottom-right",variant:"corner",horizontal:"right",vertical:"bottom"},{key:"left",variant:"edge",horizontal:"left"},{key:"right",variant:"edge",horizontal:"right"},{key:"top",variant:"edge",vertical:"top"},{key:"bottom",variant:"edge",vertical:"bottom"}],bt=({layerId:t,onPointerDown:e})=>S.jsx(S.Fragment,{children:At.map(n=>{const r=n.variant==="corner"?Dt:Gt,o=n.variant==="corner"?Nt[n.key]:kt[n.key],s={...r,...o},a=n.variant==="corner"?{"data-resize-corner":n.key}:{"data-resize-edge":n.key};return S.jsx("div",{role:"presentation","aria-hidden":"true",style:s,...a,"data-layer-id":t,onPointerDown:l=>e(n,l)},n.key)})}),jt=({pivot:t})=>{const{Outlet:e}=Tt.usePivot({items:t.items,activeId:t.activeId,defaultActiveId:t.defaultActiveId,onActiveChange:t.onActiveChange,transitionMode:t.transitionMode});return S.jsx(e,{})},Ot=(t,e)=>t.pivot?S.jsx(jt,{pivot:t.pivot}):t.cache?e(t.id):t.component,St=d.memo(({layer:t,onClose:e})=>{const{getCachedContent:n}=L.usePanelSystem(),r=Ot(t,n);return t.floating?.chrome?S.jsx(L.FloatingWindow,{id:t.id,config:t.floating,onClose:e,children:r}):r});St.displayName="LayerContentRenderer";const zt=d.memo(({layerId:t,isResizable:e,onPointerDown:n})=>e?S.jsx(bt,{layerId:t,onPointerDown:n}):null);zt.displayName="LayerResizeHandles";const Yt=(t,e)=>t?"auto":e?"visible":"hidden",wt=d.memo(({layer:t,handleLayerPointerDown:e})=>{const{getLayerRenderState:n}=L.useGridLayoutContext(),{style:r,isResizable:o,isResizing:s,onResizeHandlePointerDown:a}=n(t),l=d.useMemo(()=>{const f={};return t.gridArea&&(f.gridArea=t.gridArea),t.gridRow&&(f.gridRow=t.gridRow),t.gridColumn&&(f.gridColumn=t.gridColumn),f},[t.gridArea,t.gridRow,t.gridColumn]),u=d.useMemo(()=>{const f=!!t.floating,g=Yt(t.scrollable,f),b={...r,...l,minWidth:0,minHeight:0,overflow:g};return o?{...b,position:"relative"}:b},[r,l,o,t.scrollable,t.floating]),p=d.useCallback(()=>{t.floating?.onClose?.()},[t.floating]);return S.jsxs("div",{"data-layer-id":t.id,"data-draggable":!!t.floating?.draggable,"data-resizable":o,"data-resizing":s,style:u,onPointerDown:e,children:[S.jsx(L.LayerInstanceProvider,{layerId:t.id,children:S.jsx(St,{layer:t,onClose:p})}),S.jsx(zt,{layerId:t.id,isResizable:o,onPointerDown:a})]})});wt.displayName="EmbeddedLayer";const Rt=({layers:t})=>{const{handleLayerPointerDown:e}=L.useGridLayoutContext();return S.jsx(S.Fragment,{children:t.map(n=>{const r=n.floating?.mode??"embedded";return n.floating&&r==="popup"?S.jsx(L.PopupLayerPortal,{layer:n},n.id):S.jsx(wt,{layer:n,handleLayerPointerDown:e},n.id)})})},it={position:"absolute",pointerEvents:"auto"},Z=({direction:t,trackIndex:e,align:n,gap:r,span:o,onResize:s})=>{const a=t==="col"?"vertical":"horizontal",l=d.useCallback(f=>{const g=n==="start"?-f:f;s(t,e,g)},[n,t,e,s]),u=d.useMemo(()=>t==="col"?{gridColumn:`${e+1} / ${e+2}`,gridRow:`${o.start} / ${o.end}`}:{gridRow:`${e+1} / ${e+2}`,gridColumn:`${o.start} / ${o.end}`},[t,e,o]),p=d.useMemo(()=>{const g=Math.max(0,r)/2+v.GRID_HANDLE_THICKNESS/2;return t==="col"?{...it,width:v.GRID_HANDLE_THICKNESS,height:"100%",top:0,bottom:0,...n==="start"?{left:-g}:{right:-g}}:{...it,width:"100%",height:v.GRID_HANDLE_THICKNESS,left:0,right:0,...n==="start"?{top:-g}:{bottom:-g}}},[n,t,r]);return S.jsx("div",{"data-resizable":"true",style:{...u,position:"relative",pointerEvents:"none"},children:S.jsx("div",{"data-direction":a,"data-align":n,"data-handle":"true",style:p,children:S.jsx(Lt.ResizeHandle,{direction:a,onResize:l})})})},$t=t=>{const e=new Map;t.forEach((r,o)=>{r.forEach((s,a)=>{if(!s||s===".")return;const l=e.get(s);if(l){const p={rowStart:Math.min(l.rowStart,o),rowEnd:Math.max(l.rowEnd,o),colStart:Math.min(l.colStart,a),colEnd:Math.max(l.colEnd,a)};e.set(s,p);return}const u={rowStart:o,rowEnd:o,colStart:a,colEnd:a};e.set(s,u)})});const n=new Map;return e.forEach((r,o)=>{const s=r.rowStart+1,a=r.rowEnd+2,l=r.colStart+1,u=r.colEnd+2,p={gridArea:o,gridRow:`${s} / ${a}`,gridColumn:`${l} / ${u}`};n.set(o,p)}),n},Ft=(t,e)=>{if((t.positionMode??"grid")!=="grid")return t;const r=t.gridArea??t.id,o=e.get(r);if(!o)return t;const s=!t.gridArea,a=!t.gridRow,l=!t.gridColumn;return!s&&!a&&!l?t:{...t,gridArea:s?o.gridArea:t.gridArea,gridRow:a?o.gridRow:t.gridRow,gridColumn:l?o.gridColumn:t.gridColumn}},Et=(t,e)=>{const n=d.useMemo(()=>$t(t.areas),[t.areas]),r=d.useMemo(()=>e.map(l=>Ft(l,n)),[e,n]),o=d.useMemo(()=>r.filter(l=>l.visible!==!1),[r]),s=d.useMemo(()=>o.filter(l=>!l.drawer),[o]),a=d.useMemo(()=>{const l=new Map;return r.forEach(u=>{l.set(u.id,u)}),l},[r]);return{normalizedLayers:r,visibleLayers:o,regularLayers:s,layerById:a}},Bt=t=>{if(!t)return{rowGap:0,columnGap:0};const e=t.split(/\s+/).map(r=>r.trim()).filter(Boolean),n=r=>{const o=r.match(/^(-?\d+(?:\.\d+)?)px$/);return o?Number.parseFloat(o[1]):0};if(e.length===1){const r=n(e[0]);return{rowGap:r,columnGap:r}}return{rowGap:n(e[0]),columnGap:n(e[1])}},Wt=(t,e)=>{if(!t)return[];const n=getComputedStyle(t);return(e==="col"?n.gridTemplateColumns:n.gridTemplateRows).split(/\s+/).map(o=>parseFloat(o)).filter(o=>!Number.isNaN(o))},q=(t,e=Number.NEGATIVE_INFINITY,n=Number.POSITIVE_INFINITY)=>Math.min(Math.max(t,e),n),Xt=(t,e)=>typeof t!="number"||!Number.isFinite(t)?e:t,F=(t,e)=>`${t}-${e}`,Kt=(t,e,n,r)=>{const o=F(n,r),s=e[o];return s!==void 0?`minmax(${t.minSize??0}px, ${s}px)`:t.size},at=(t,e,n)=>t.map((r,o)=>Kt(r,e,n,o)).join(" "),O=(t,e)=>t.reduce((n,r,o)=>(r.resizable&&r.size.endsWith("px")&&(n[F(e,o)]=parseInt(r.size,10)),n),{}),Zt=({trackSizes:t,track:e,direction:n,trackIndex:r,containerRef:o})=>{const s=F(n,r),a=t[s];if(a!==void 0)return a;const u=Wt(o?.current??null,n)[r];return u!==void 0&&u>0?u:e.size.endsWith("px")?Number.parseInt(e.size,10):300},Vt=(t,e)=>t.reduce((n,r,o)=>o===e?n:r.size.includes("fr")?n+100:n+(r.minSize??50),0),qt=({track:t,tracks:e,trackIndex:n,direction:r,containerRef:o,gapSizes:s})=>{if(!o?.current)return t.maxSize;const a=r==="col"?o.current.offsetWidth:o.current.offsetHeight,l=Vt(e,n),u=e.length-1,p=r==="col"?s.columnGap:s.rowGap,f=u*p,g=a-l-f;return t.maxSize!==void 0?Math.min(t.maxSize,g):g},Ut=(t,e,n)=>q(t,e??Number.NEGATIVE_INFINITY,n??Number.POSITIVE_INFINITY),ct=(t,e)=>{const n=t.length,r=[];for(let a=0;a<n;a++){const l=t[a],u=l[e],p=l[e+1];u!==p&&r.push(a)}if(r.length===0)return{start:1,end:n+1};const o=Math.min(...r),s=Math.max(...r);return{start:o+1,end:s+2}},lt=(t,e)=>{const n=t[e],r=t[e+1],o=n?.length??0,s=[];for(let u=0;u<o;u++){const p=n?.[u],f=r?.[u];p!==f&&s.push(u)}if(s.length===0)return{start:1,end:o+1};const a=Math.min(...s),l=Math.max(...s);return{start:a+1,end:l+2}},Jt=(t,e)=>{if(t.length===0)return[];const n=e.length;if(t.length===1)return t[0]?.resizable?[{trackIndex:0,align:"end",span:{start:1,end:n+1}}]:[];const r=[];return Array.from({length:t.length-1},(s,a)=>a).forEach(s=>{const a=t[s];if(t[s+1]?.resizable){const u=ct(e,s);r.push({trackIndex:s+1,align:"start",span:u});return}if(a?.resizable){const u=ct(e,s);r.push({trackIndex:s,align:"end",span:u})}}),r},Qt=(t,e)=>{if(t.length===0)return[];const n=e[0]?.length??0;if(t.length===1)return t[0]?.resizable?[{trackIndex:0,align:"end",span:{start:1,end:n+1}}]:[];const r=[];return Array.from({length:t.length-1},(s,a)=>a).forEach(s=>{const a=t[s];if(t[s+1]?.resizable){const u=lt(e,s);r.push({trackIndex:s+1,align:"start",span:u});return}if(a?.resizable){const u=lt(e,s);r.push({trackIndex:s,align:"end",span:u})}}),r},te=t=>t!==void 0?{gap:t}:{},ee=(t,e)=>{const n=Object.keys(e),r={};for(const f of n)r[f]=t[f]??e[f];const o=Object.keys(t),s=o.length!==n.length,a=o.some(f=>!Object.prototype.hasOwnProperty.call(r,f)),l=s?!0:a,u=n.some(f=>t[f]!==r[f]);return(l?!0:u)?r:null},vt=(t,e,n)=>{const[r,o]=d.useState(()=>({...O(t.columns,"col"),...O(t.rows,"row")}));mt.useIsomorphicLayoutEffect(()=>{const g={...O(t.columns,"col"),...O(t.rows,"row")};o(b=>ee(b,g)??b)},[t.columns,t.rows]);const s=d.useMemo(()=>t.areas.map(g=>`"${g.join(" ")}"`).join(" "),[t.areas]),a=d.useMemo(()=>Bt(t.gap),[t.gap]),l=d.useMemo(()=>Jt(t.columns,t.areas),[t.columns,t.areas]),u=d.useMemo(()=>Qt(t.rows,t.areas),[t.rows,t.areas]),p=d.useMemo(()=>({...t.style,...e,gridTemplateAreas:s,gridTemplateRows:at(t.rows,r,"row"),gridTemplateColumns:at(t.columns,r,"col"),...te(t.gap)}),[s,t.columns,t.gap,t.rows,t.style,e,r]),f=d.useCallback((g,b,R)=>{const I=g==="row"?t.rows:t.columns,C=I[b];if(!C||!C.resizable)return;const _=Zt({trackSizes:r,track:C,direction:g,trackIndex:b,containerRef:n}),H=qt({track:C,tracks:I,trackIndex:b,direction:g,containerRef:n,gapSizes:a}),P=F(g,b);o(N=>{const y=_+R,T=Ut(y,C.minSize,H);return{...N,[P]:T}})},[t.columns,t.rows,r,n,a]);return{columnHandles:l,rowHandles:u,gapSizes:a,gridStyle:p,handleResize:f}},ne=t=>t.positionMode?t.positionMode:t.floating?(t.floating.mode??"embedded")==="embedded"?"absolute":"relative":"grid",re=t=>({position:t==="grid"?"relative":t}),oe=(t,e)=>e!=="grid"?{}:{gridArea:t.gridArea,gridRow:t.gridRow,gridColumn:t.gridColumn},se=t=>t?{top:t.top,right:t.right,bottom:t.bottom,left:t.left}:{},ie=t=>t!==void 0?{zIndex:t}:{},ae=(t,e)=>({width:t,height:e}),ce=(t,e)=>t.pointerEvents!==void 0?typeof t.pointerEvents=="boolean"?{pointerEvents:t.pointerEvents?"auto":"none"}:{pointerEvents:t.pointerEvents}:e==="absolute"||e==="fixed"?{pointerEvents:"auto"}:{},le=t=>t.floating?t.floating.position??t.floating.defaultPosition??t.position:t.position,ue=t=>{if(t.floating){const e=t.floating.size??t.floating.defaultSize;if(e)return{width:e.width,height:e.height}}return{width:t.width,height:t.height}},de=t=>t.floating?.zIndex!==void 0?t.floating.zIndex:t.zIndex,ge=t=>{const e=ne(t),n=le(t),r=ue(t),o=de(t);return{...t.style,...re(e),...oe(t,e),...se(n),...ie(o),...ae(r.width,r.height),...ce(t,e)}},he=t=>{const e=t.floating;return e?e.mode??"embedded":null},D=t=>he(t)!=="embedded"?null:t.floating??null,ut=t=>t instanceof HTMLElement?["INPUT","TEXTAREA","SELECT","BUTTON"].includes(t.tagName):!1,dt=(t,e,n)=>{const r=e??Number.NEGATIVE_INFINITY,o=n??Number.POSITIVE_INFINITY;return q(t,r,o)},gt=(t,e,n)=>{if(typeof t=="number"&&Number.isFinite(t))return t;throw new Error(`Floating layer "${n}" must provide a numeric "${e}" value when draggable mode is enabled.`)},ht=t=>{const e=D(t);if(!e)throw new Error(`Floating layer "${t.id}" is missing floating configuration required for dragging.`);const n=e.position??e.defaultPosition??t.position;if(!n)throw new Error(`Floating layer "${t.id}" must define position with left and top values.`);return{left:gt(n.left,"left",t.id),top:gt(n.top,"top",t.id)}},fe=t=>{const e=D(t);return e?e.constraints??{}:{}},me=(t,e,n)=>t?t==="left"?e-n:e+n:e,pe=(t,e,n)=>t?t==="top"?e-n:e+n:e,be=(t,e,n)=>!t||t==="right"?e:e+n,Se=(t,e,n)=>!t||t==="bottom"?e:e+n,V=(t,e)=>t?t.dataset.layerId===e?t:V(t.parentElement,e):null,U=(t,e,n)=>!t||n?.(t)?null:e(t)?t:U(t.parentElement,e,n),ze=t=>t instanceof HTMLElement?U(t,e=>e.dataset.dragHandle==="true",e=>e.dataset.dragIgnore==="true"):null,ft=t=>t instanceof HTMLElement?U(t,e=>e.dataset.resizeCorner!==void 0||e.dataset.resizeEdge!==void 0)!==null:!1,Y=t=>{const e=D(t);return e?e.resizable===!0:!1},$=t=>{if(!D(t))return null;const n=Ee(t);if(!n)throw new Error(`Floating layer "${t.id}" must define width and height when resizable or draggable.`);return{width:n.width,height:n.height}},we=(t,e,n)=>{const r=t.filter(Y).reduce((g,b)=>{if(n===b.id){const I=e[b.id];if(I)return g[b.id]=I,g}const R=$(b);return R&&(g[b.id]=R),g},{}),o=Object.keys(e),s=Object.keys(r),a=o.length!==s.length,l=o.some(g=>!Object.prototype.hasOwnProperty.call(r,g)),u=a?!0:l,p=s.some(g=>{const b=e[g],R=r[g];return!b||!R?!0:b.width!==R.width||b.height!==R.height});return{sizes:r,changed:u?!0:p}},Re=({layers:t,layerById:e,isRootLevel:n})=>{const[r,o]=d.useState(null),[s,a]=d.useState(null),[l,u]=d.useState({}),[p,f]=d.useState({}),g=d.useRef(null),b=d.useRef(null),R=j.useEffectEvent((c,i)=>{e.get(c)?.floating?.onMove?.(i)}),I=j.useEffectEvent((c,i)=>{e.get(c)?.floating?.onResize?.(i)});mt.useIsomorphicLayoutEffect(()=>{const{sizes:c,changed:i}=we(t,p,s);i&&f(c)},[t,s]);const C=d.useCallback((c,i,h,m)=>{const z=ht(i),E=l[c]??{x:0,y:0},w={pointerStartX:m.clientX,pointerStartY:m.clientY,initialTranslationX:E.x,initialTranslationY:E.y,baseLeft:z.left,baseTop:z.top,layerId:c,pointerId:m.pointerId,target:h};if(w.target.setPointerCapture)try{w.target.setPointerCapture(w.pointerId)}catch{}g.current=w,o(c)},[l]),_=d.useCallback(c=>{const i=c.target,h=ze(i);if(!h)return;const m=h.closest("[data-layer-id]")?.getAttribute("data-layer-id");if(!m)return;const z=e.get(m);if(!z)return;const E=D(z);if(!(!E||E.draggable!==!0)&&!ut(c.target)&&!ft(c.target)&&h){const w=V(h,m);if(!w)return;C(m,z,w,c);return}},[C,e]),H=d.useCallback((c,i)=>{const h=e.get(c),m=h?D(h):null;if(!h||!m||m.draggable!==!0||ut(i.target)||ft(i.target))return;const z=V(i.currentTarget,c);z&&C(c,h,z,i)},[C,e]),P=d.useCallback((c,i,h)=>{const m=e.get(c);if(!m||!Y(m))return;const z=p[c]??$(m);if(!z)return;const E=ht(m),w=fe(m),x=l[c]??{x:0,y:0};if(h.stopPropagation(),h.preventDefault(),h.currentTarget.setPointerCapture)try{h.currentTarget.setPointerCapture(h.pointerId)}catch{}b.current={layerId:c,pointerId:h.pointerId,horizontalEdge:i.horizontal,verticalEdge:i.vertical,startX:h.clientX,startY:h.clientY,startWidth:z.width,startHeight:z.height,startPosition:x,baseLeft:E.left,baseTop:E.top,minWidth:w.minWidth,maxWidth:w.maxWidth,minHeight:w.minHeight,maxHeight:w.maxHeight,target:h.currentTarget},a(c)},[e,l,p]),N=d.useCallback(c=>{const i=g.current;if(!i)return;const h=c.clientX-i.pointerStartX,m=c.clientY-i.pointerStartY,z={x:i.initialTranslationX+h,y:i.initialTranslationY+m};u(E=>({...E,[i.layerId]:z})),R(i.layerId,{left:i.baseLeft+z.x,top:i.baseTop+z.y})},[R]),y=d.useCallback(c=>{const i=b.current;if(!i||i.pointerId!==c.pointerId||!e.get(i.layerId))return;const m=c.clientX-i.startX,z=c.clientY-i.startY,E=me(i.horizontalEdge,i.startWidth,m),w=pe(i.verticalEdge,i.startHeight,z),x=dt(E,i.minWidth,i.maxWidth),M=dt(w,i.minHeight,i.maxHeight),k=i.startWidth-x,B=i.startHeight-M,nt=be(i.horizontalEdge,i.startPosition.x,k),It=Se(i.verticalEdge,i.startPosition.y,B),W=p[i.layerId],rt={width:x,height:M};(!W||W.width!==x||W.height!==M)&&(f(X=>({...X,[i.layerId]:rt})),I(i.layerId,rt));const ot=l[i.layerId]??{x:0,y:0},A={x:nt,y:It};(ot.x!==A.x||ot.y!==A.y)&&(u(X=>({...X,[i.layerId]:A})),R(i.layerId,{left:i.baseLeft+A.x,top:i.baseTop+A.y}))},[e,l,p,R,I]),T=d.useCallback(c=>{const i=g.current;if(i){if(i.pointerId===c.pointerId&&i.target.releasePointerCapture)try{i.target.releasePointerCapture(i.pointerId)}catch{}g.current=null}o(null)},[]),G=d.useCallback(c=>{const i=b.current;if(i){if(i.pointerId===c.pointerId&&i.target.releasePointerCapture)try{i.target.releasePointerCapture(i.pointerId)}catch{}b.current=null}a(null)},[]);j.useDocumentPointerEvents(r!==null,{onMove:N,onUp:T,onCancel:T}),j.useDocumentPointerEvents(s!==null,{onMove:y,onUp:G,onCancel:G});const J=d.useCallback(c=>{const i=ge(c),h=D(c);if(!h||h.draggable!==!0)return i;const m=l[c.id],z=r===c.id,E=s===c.id,w=m?{transform:`translate(${m.x}px, ${m.y}px)`}:{},x=p[c.id],M=Y(c)?$(c):null,k=x??M,B=k?{width:`${k.width}px`,height:`${k.height}px`}:{};return{...i,...B,...w,...z||E?{cursor:"grabbing"}:{}}},[r,l,p,s]),Q=d.useCallback(c=>{if(!Y(c))return{isResizable:!1};const h=p[c.id],m=$(c);return(h??m)!==null?{isResizable:!0,onPointerDown:(x,M)=>{P(c.id,x,M)}}:{isResizable:!1}},[P,p]),tt=d.useCallback(c=>{const{isResizable:i,onPointerDown:h}=Q(c),m=J(c),z=s===c.id;return{style:m,isResizable:i,isResizing:z,onResizeHandlePointerDown:(E,w)=>{h&&h(E,w)}}},[J,Q,s]),et=d.useCallback(c=>({"data-drag-handle":"true",role:"button","aria-roledescription":"Drag handle","aria-label":"Drag layer",onPointerDown:i=>{H(c,i)}}),[H]);return{providerValue:d.useMemo(()=>({handleLayerPointerDown:_,getLayerRenderState:tt,getLayerHandleProps:et,isRootLevel:n}),[et,tt,_,n]),draggingLayerId:r,resizingLayerId:s}},Ee=t=>{if(t.floating){const e=t.floating.size??t.floating.defaultSize;if(e)return{width:e.width,height:e.height}}if(typeof t.width=="number"&&typeof t.height=="number")return{width:t.width,height:t.height}},Ct={display:"grid",width:"100%",height:"100%",overflow:"hidden"},ve={touchAction:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none",userSelect:"none"},Ce={...Ct,overflow:"visible",height:"auto",minHeight:"100%"},Ie=t=>t?Ce:Ct,ye=({config:t,layers:e,style:n,root:r=!1})=>{const o=d.useRef(null),{isIntersecting:s}=Mt(o,{threshold:0});return S.jsx(L.PanelSystemProvider,{config:t,layers:e,style:n,children:S.jsx(Te,{gridRef:o,isIntersecting:s,isRoot:r})})},Te=({gridRef:t,isIntersecting:e,isRoot:n})=>{const{config:r,style:o,layers:s}=L.usePanelSystem(),{normalizedLayers:a,visibleLayers:l,regularLayers:u,layerById:p}=Et(r,s.defs),{columnHandles:f,rowHandles:g,gapSizes:b,gridStyle:R,handleResize:I}=vt(r,o,t),{providerValue:C,draggingLayerId:_,resizingLayerId:H}=Re({layers:a,layerById:p,isRootLevel:n}),P=_?!0:!!H,N=d.useMemo(()=>({...Ie(n),...R,...P?ve:{}}),[R,P,n]);return S.jsxs(S.Fragment,{children:[S.jsxs("div",{ref:t,style:N,"data-dragging":!!_,"data-resizing":!!H,"data-visible":e,children:[S.jsx(L.GridLayoutProvider,{value:C,children:S.jsx(Rt,{layers:u})}),f.map(({trackIndex:y,align:T,span:G})=>S.jsx(Z,{direction:"col",trackIndex:y,align:T,gap:b.columnGap,span:G,onResize:I},`col-${y}:${T}`)),g.map(({trackIndex:y,align:T,span:G})=>S.jsx(Z,{direction:"row",trackIndex:y,align:T,gap:b.rowGap,span:G,onResize:I},`row-${y}:${T}`))]}),S.jsx(L.DrawerLayers,{layers:l})]})};exports.GridLayerList=Rt;exports.GridLayerResizeHandles=bt;exports.GridLayout=ye;exports.GridTrackResizeHandle=Z;exports.clampNumber=q;exports.toFiniteNumberOr=Xt;exports.useGridPlacements=Et;exports.useGridTracks=vt;
2
+ //# sourceMappingURL=GridLayout-DKTg_N61.cjs.map