regular-layout 0.2.0 → 0.2.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.
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/layout/types.ts", "../src/layout/constants.ts", "../src/layout/generate_grid.ts", "../src/layout/calculate_intersect.ts", "../src/layout/remove_child.ts", "../src/layout/insert_child.ts", "../src/layout/redistribute_panel_sizes.ts", "../src/layout/generate_overlay.ts", "../src/layout/calculate_edge.ts", "../src/layout/flatten.ts", "../src/regular-layout.ts", "../src/regular-layout-frame.ts", "../src/regular-layout-tab.ts", "../src/extensions.ts"],
4
- "sourcesContent": ["// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\n/**\n * The overlay behavior type.\n */\nexport type OverlayMode = \"grid\" | \"absolute\";\n\n/**\n * The representation of a CSS grid, in JSON form.\n */\nexport type Layout = SplitLayout | TabLayout;\n\n/**\n * The orientation (of a `SplitPanel`).\n */\nexport type Orientation = \"horizontal\" | \"vertical\";\n\n/**\n * A logical rectange in percent-coordinates (of a (1, 1) square).\n */\nexport interface ViewWindow {\n\trow_start: number;\n\trow_end: number;\n\tcol_start: number;\n\tcol_end: number;\n}\n\n/**\n * A split panel that divides space among multiple child layouts\n * .\n * Child panels are arranged either horizontally (side by side) or vertically\n * (stacked), via the `orientation` property `\"horizzontal\"` and `\"vertical\"`\n * (respectively).\n *\n * While the type structure of `SplitLayout` allows nesting levels with the same\n * `orientation`, calling `RegularLayout.restore` with such a `Layout` will be\n * flattened to the equivalent layout with every child guaranteed to have the\n * opposite `orientation` as its parent.\n */\nexport interface SplitLayout {\n\ttype: \"split-panel\";\n\tchildren: Layout[];\n\tsizes: number[];\n\torientation: Orientation;\n}\n\n/**\n * A leaf panel node that contains a single named child element.\n */\nexport interface TabLayout {\n\ttype: \"child-panel\";\n\tchild: string[];\n\tselected?: number;\n}\n\n/**\n * Represents a draggable divider between two panels in the layout.\n *\n * Used for hit detection.\n */\nexport interface LayoutDivider {\n\tpath: number[];\n\tview_window: ViewWindow;\n\ttype: Orientation;\n}\n\n/**\n * Represents a panel location result from hit detection.\n *\n * Contains both the panel identifier and its grid position in relative units.\n * The generic parameter `T` allows DOM-only properties (e.g. `DOMRect`) to be\n * shared in this cross-platform module.\n */\nexport interface LayoutPath<T = undefined> {\n\ttype: \"layout-path\";\n\tslot: string;\n\tpath: number[];\n\tview_window: ViewWindow;\n\tcolumn: number;\n\trow: number;\n\tcolumn_offset: number;\n\trow_offset: number;\n\torientation: Orientation;\n\tis_edge: boolean;\n\tlayout: T;\n}\n\n/**\n * An empty `Layout` with no panels.\n */\nexport const EMPTY_PANEL: Layout = {\n\ttype: \"split-panel\",\n\torientation: \"horizontal\",\n\tsizes: [],\n\tchildren: [],\n};\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { OverlayMode } from \"./types\";\n\n/**\n * The prefix to use for `CustomEvent`s generated by `regular-layout`, e.g.\n * `\"regular-layout-before-update\"`.\n */\nexport const CUSTOM_EVENT_NAME_PREFIX = \"regular-layout\";\n\n/**\n * The minimum number of pixels the mouse must move to be considered a drag.\n */\nexport const MIN_DRAG_DISTANCE = 10;\n\n/**\n * Class name to use for child elements in overlay position (dragging).\n */\nexport const OVERLAY_CLASSNAME = \"overlay\";\n\n/**\n * The percentage of the maximum resize distance that will be clamped.\n *\n */\nexport const MINIMUM_REDISTRIBUTION_SIZE_THRESHOLD = 0.15;\n\n/**\n * Threshold from panel edge that is considered a split vs drop action.\n */\nexport const SPLIT_EDGE_TOLERANCE = 0.25;\n\n/**\n * Threshold from _container_ edge that is considered a split action on the root\n * node.\n */\nexport const SPLIT_ROOT_EDGE_TOLERANCE = 0.01;\n\n/**\n * Tolerance threshold for considering two grid track positions as identical.\n *\n * When collecting and deduplicating track positions, any positions closer than\n * this value are treated as the same position to avoid redundant grid tracks.\n */\nexport const GRID_TRACK_COLLAPSE_TOLERANCE = 0.001;\n\n/**\n * The overlay default behavior.\n */\nexport const OVERLAY_DEFAULT: OverlayMode = \"absolute\";\n\n/**\n * Width of split panel dividers in pixels (for hit-test purposes).\n */\nexport const GRID_DIVIDER_SIZE = 6;\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport { GRID_TRACK_COLLAPSE_TOLERANCE } from \"./constants.ts\";\nimport type { Layout } from \"./types.ts\";\n\ninterface GridCell {\n\tchild: string;\n\tcolStart: number;\n\tcolEnd: number;\n\trowStart: number;\n\trowEnd: number;\n}\n\nfunction dedupe_sort(result: number[], pos: number) {\n\tif (\n\t\tresult.length === 0 ||\n\t\tMath.abs(pos - result[result.length - 1]) > GRID_TRACK_COLLAPSE_TOLERANCE\n\t) {\n\t\tresult.push(pos);\n\t}\n\n\treturn result;\n}\n\nfunction dedupe_positions(positions: number[]): number[] {\n\tconst sorted = positions.sort((a, b) => a - b);\n\treturn sorted.reduce(dedupe_sort, []);\n}\n\nfunction collect_track_positions(\n\tpanel: Layout,\n\torientation: \"horizontal\" | \"vertical\",\n\tstart: number,\n\tend: number,\n): number[] {\n\tif (panel.type === \"child-panel\") {\n\t\treturn [start, end];\n\t}\n\n\tconst positions: number[] = [start, end];\n\tif (panel.orientation === orientation) {\n\t\tlet current = start;\n\t\tconst range = end - start;\n\t\tfor (let i = 0; i < panel.children.length; i++) {\n\t\t\tconst size = panel.sizes[i];\n\t\t\tconst next = current + size * range;\n\t\t\tpositions.push(\n\t\t\t\t...collect_track_positions(\n\t\t\t\t\tpanel.children[i],\n\t\t\t\t\torientation,\n\t\t\t\t\tcurrent,\n\t\t\t\t\tnext,\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tcurrent = next;\n\t\t}\n\t} else {\n\t\tfor (const child of panel.children) {\n\t\t\tpositions.push(\n\t\t\t\t...collect_track_positions(child, orientation, start, end),\n\t\t\t);\n\t\t}\n\t}\n\n\treturn dedupe_positions(positions);\n}\n\nfunction find_track_index(positions: number[], value: number): number {\n\tconst index = positions.findIndex(\n\t\t(pos) => Math.abs(pos - value) < GRID_TRACK_COLLAPSE_TOLERANCE,\n\t);\n\n\treturn index === -1 ? 0 : index;\n}\n\nfunction build_cells(\n\tpanel: Layout,\n\tcolPositions: number[],\n\trowPositions: number[],\n\tcolStart: number,\n\tcolEnd: number,\n\trowStart: number,\n\trowEnd: number,\n): GridCell[] {\n\tif (panel.type === \"child-panel\") {\n\t\tconst selected = panel.selected ?? 0;\n\t\treturn [\n\t\t\t{\n\t\t\t\tchild: panel.child[selected],\n\t\t\t\tcolStart: find_track_index(colPositions, colStart),\n\t\t\t\tcolEnd: find_track_index(colPositions, colEnd),\n\t\t\t\trowStart: find_track_index(rowPositions, rowStart),\n\t\t\t\trowEnd: find_track_index(rowPositions, rowEnd),\n\t\t\t},\n\t\t];\n\t}\n\n\tconst { children, sizes, orientation } = panel;\n\tconst isHorizontal = orientation === \"horizontal\";\n\tlet current = isHorizontal ? colStart : rowStart;\n\tconst range = isHorizontal ? colEnd - colStart : rowEnd - rowStart;\n\tconst cells: GridCell[] = [];\n\tfor (let i = 0; i < children.length; i++) {\n\t\tconst next = current + sizes[i] * range;\n\t\tif (isHorizontal) {\n\t\t\tcells.push(\n\t\t\t\t...build_cells(\n\t\t\t\t\tchildren[i],\n\t\t\t\t\tcolPositions,\n\t\t\t\t\trowPositions,\n\t\t\t\t\tcurrent,\n\t\t\t\t\tnext,\n\t\t\t\t\trowStart,\n\t\t\t\t\trowEnd,\n\t\t\t\t),\n\t\t\t);\n\t\t} else {\n\t\t\tcells.push(\n\t\t\t\t...build_cells(\n\t\t\t\t\tchildren[i],\n\t\t\t\t\tcolPositions,\n\t\t\t\t\trowPositions,\n\t\t\t\t\tcolStart,\n\t\t\t\t\tcolEnd,\n\t\t\t\t\tcurrent,\n\t\t\t\t\tnext,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tcurrent = next;\n\t}\n\n\treturn cells;\n}\n\nconst host_template = (rowTemplate: string, colTemplate: string) =>\n\t`:host ::slotted(*){display:none}:host{display:grid;grid-template-rows:${rowTemplate};grid-template-columns:${colTemplate}}`;\n\nconst child_template = (slot: string, rowPart: string, colPart: string) =>\n\t`:host ::slotted([name=\"${slot}\"]){display:flex;grid-column:${colPart};grid-row:${rowPart}}`;\n\n/**\n * Generates CSS Grid styles to render a layout tree.\n * Creates grid-template-rows, grid-template-columns, and positioning rules for\n * all child panels.\n *\n * @param layout - The layout tree to convert to CSS\n * @param round - If true, rounds percentages to whole numbers. Useful for\n * avoiding sub-pixel rendering issues. Defaults to false.\n * @returns CSS string containing :host and ::slotted rules implementing the\n * layout.\n *\n * @example\n * ```typescript\n * const layout = {\n * type: \"split-panel\",\n * orientation: \"horizontal\",\n * children: [\n * { type: \"child-panel\", child: \"sidebar\" },\n * { type: \"child-panel\", child: \"main\" }\n * ],\n * sizes: [0.25, 0.75]\n * };\n *\n * const css = create_css_grid_layout(layout);\n * // Returns CSS like:\n * // :host { display: grid; grid-template-columns: 25% 75%; ... }\n * // :host ::slotted([name=sidebar]) { grid-column: 1; grid-row: 1; }\n * // :host ::slotted([name=main]) { grid-column: 2; grid-row: 1; }\n * ```\n */\nexport function create_css_grid_layout(\n\tlayout: Layout,\n\tround: boolean = false,\n\toverlay?: [string, string],\n): string {\n\tif (layout.type === \"child-panel\") {\n\t\tconst selected = layout.selected ?? 0;\n\t\treturn `${host_template(\"100%\", \"100%\")}\\n${child_template(layout.child[selected], \"1\", \"1\")}`;\n\t}\n\n\tconst createTemplate = (positions: number[]) => {\n\t\tconst sizes = positions\n\t\t\t.slice(0, -1)\n\t\t\t.map((pos, i) => positions[i + 1] - pos);\n\t\treturn sizes\n\t\t\t.map((s) => `${round ? Math.round(s * 100) : s * 100}fr`)\n\t\t\t.join(\" \");\n\t};\n\n\tconst colPositions = collect_track_positions(layout, \"horizontal\", 0, 1);\n\tconst colTemplate = createTemplate(colPositions);\n\tconst rowPositions = collect_track_positions(layout, \"vertical\", 0, 1);\n\tconst rowTemplate = createTemplate(rowPositions);\n\tconst formatGridLine = (start: number, end: number) =>\n\t\tend - start === 1 ? `${start + 1}` : `${start + 1} / ${end + 1}`;\n\n\tconst cells = build_cells(layout, colPositions, rowPositions, 0, 1, 0, 1);\n\tconst css = [host_template(rowTemplate, colTemplate)];\n\tfor (const cell of cells) {\n\t\tconst colPart = formatGridLine(cell.colStart, cell.colEnd);\n\t\tconst rowPart = formatGridLine(cell.rowStart, cell.rowEnd);\n\t\tcss.push(child_template(cell.child, rowPart, colPart));\n\t\tif (cell.child === overlay?.[1]) {\n\t\t\tcss.push(child_template(overlay[0], rowPart, colPart));\n\t\t\tcss.push(`:host ::slotted([name=${overlay[0]}]){z-index:1}`);\n\t\t}\n\t}\n\n\treturn css.join(\"\\n\");\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport { GRID_DIVIDER_SIZE } from \"./constants.ts\";\nimport type { LayoutPath, LayoutDivider, Layout, ViewWindow } from \"./types.ts\";\n\nconst VIEW_WINDOW = {\n\trow_start: 0,\n\trow_end: 1,\n\tcol_start: 0,\n\tcol_end: 1,\n};\n\n/**\n * Determines which panel or divider is located at a given position in the\n * layout.\n *\n * @param column - Horizontal position as a fraction (0-1) of the container width\n * @param row - Vertical position as a fraction (0-1) of the container height\n * @param layout - The layout tree to search\n * @param check_dividers - Whether `LayoutDivider` intersection should be\n * checked, which you may not want for e.g. `drop` actions.\n * @returns The panel path if over a panel, a divider if over a resizable\n * boundary, or null if outside all panels\n */\nexport function calculate_intersection(\n\tcolumn: number,\n\trow: number,\n\tlayout: Layout,\n\tcheck_dividers?: null,\n): LayoutPath | null;\n\nexport function calculate_intersection(\n\tcolumn: number,\n\trow: number,\n\tlayout: Layout,\n\tcheck_dividers?: DOMRect,\n): LayoutPath | null | LayoutDivider;\n\nexport function calculate_intersection(\n\tcolumn: number,\n\trow: number,\n\tlayout: Layout,\n\tcheck_dividers?: DOMRect | null,\n): LayoutPath | null | LayoutDivider;\n\nexport function calculate_intersection(\n\tcolumn: number,\n\trow: number,\n\tlayout: Layout,\n\tcheck_dividers: DOMRect | null = null,\n): LayoutPath | null | LayoutDivider {\n\treturn calculate_intersection_recursive(column, row, layout, check_dividers);\n}\n\nfunction calculate_intersection_recursive(\n\tcolumn: number,\n\trow: number,\n\tpanel: Layout,\n\tcheck_dividers: DOMRect | null,\n\tparent_orientation: \"horizontal\" | \"vertical\" | null = null,\n\tview_window: ViewWindow = structuredClone(VIEW_WINDOW),\n\tpath: number[] = [],\n): LayoutPath | null | LayoutDivider {\n\tif (column < 0 || row < 0 || column > 1 || row > 1) {\n\t\treturn null;\n\t}\n\n\t// Base case: if this is a child panel, return its name\n\tif (panel.type === \"child-panel\") {\n\t\tconst selected = panel.selected ?? 0;\n\t\tconst col_width = view_window.col_end - view_window.col_start;\n\t\tconst row_height = view_window.row_end - view_window.row_start;\n\t\treturn {\n\t\t\ttype: \"layout-path\",\n\t\t\tlayout: undefined,\n\t\t\tslot: panel.child[selected],\n\t\t\tpath,\n\t\t\tview_window,\n\t\t\tis_edge: false,\n\t\t\tcolumn,\n\t\t\trow,\n\t\t\tcolumn_offset: (column - view_window.col_start) / col_width,\n\t\t\trow_offset: (row - view_window.row_start) / row_height,\n\t\t\torientation: parent_orientation || \"horizontal\",\n\t\t};\n\t}\n\n\t// For split panels, determine which child was hit\n\tconst is_vertical = panel.orientation === \"vertical\";\n\tconst position = is_vertical ? row : column;\n\tconst start_key = is_vertical ? \"row_start\" : \"col_start\";\n\tconst end_key = is_vertical ? \"row_end\" : \"col_end\";\n\tconst rect_dim = is_vertical ? check_dividers?.height : check_dividers?.width;\n\tlet current_pos = view_window[start_key];\n\tconst total_size = view_window[end_key] - view_window[start_key];\n\tfor (let i = 0; i < panel.children.length; i++) {\n\t\tconst next_pos = current_pos + total_size * panel.sizes[i];\n\n\t\t// Check if position is on a divider\n\t\tif (check_dividers && rect_dim) {\n\t\t\tconst divider_threshold = GRID_DIVIDER_SIZE / rect_dim;\n\t\t\tif (Math.abs(position - next_pos) < divider_threshold) {\n\t\t\t\treturn {\n\t\t\t\t\tpath: [...path, i],\n\t\t\t\t\ttype: panel.orientation,\n\t\t\t\t\tview_window: {\n\t\t\t\t\t\t...view_window,\n\t\t\t\t\t\t[start_key]: current_pos,\n\t\t\t\t\t\t[end_key]: next_pos,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\t// Check if position falls within this child's bounds\n\t\tif (position >= current_pos && position < next_pos) {\n\t\t\treturn calculate_intersection_recursive(\n\t\t\t\tcolumn,\n\t\t\t\trow,\n\t\t\t\tpanel.children[i],\n\t\t\t\tcheck_dividers,\n\t\t\t\tpanel.orientation,\n\t\t\t\t{\n\t\t\t\t\t...view_window,\n\t\t\t\t\t[start_key]: current_pos,\n\t\t\t\t\t[end_key]: next_pos,\n\t\t\t\t},\n\t\t\t\t[...path, i],\n\t\t\t);\n\t\t}\n\n\t\tcurrent_pos = next_pos;\n\t}\n\n\t// If we get here, the hit was outside all children (possibly in a gap or\n\t// boundary).\n\treturn null;\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { Layout, TabLayout } from \"./types.ts\";\nimport { EMPTY_PANEL } from \"./types.ts\";\n\n/**\n * Removes a child panel from the layout tree by its name.\n *\n * Redistributes the removed panel's space proportionally among remaining\n * siblings. Automatically collapses split panels when only one child remains.\n *\n * @param panel - The root layout tree to remove from.\n * @param child - Name of the child panel to remove.\n * @returns A new layout tree with the child removed (original is not mutated).\n * Returns `EMPTY_PANEL` if the last panel is removed.\n */\nexport function remove_child(panel: Layout, child: string): Layout {\n\t// If this is a child panel, handle tab removal\n\tif (panel.type === \"child-panel\") {\n\t\tif (panel.child.includes(child)) {\n\t\t\tconst newChild = panel.child.filter((c) => c !== child);\n\t\t\tif (newChild.length === 0) {\n\t\t\t\treturn structuredClone(EMPTY_PANEL);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\ttype: \"child-panel\",\n\t\t\t\tchild: newChild,\n\t\t\t};\n\t\t}\n\n\t\treturn structuredClone(panel);\n\t}\n\n\t// Clone the panel structure\n\tconst result = structuredClone(panel);\n\n\t// Try to remove the child from this split panel's children\n\tconst index = result.children.findIndex((p) => {\n\t\tif (p.type === \"child-panel\") {\n\t\t\treturn p.child.includes(child);\n\t\t}\n\n\t\treturn false;\n\t});\n\n\tif (index !== -1) {\n\t\tconst tab_layout = result.children[index] as TabLayout;\n\t\tif (tab_layout.child.length === 1) {\n\t\t\t// Found the child at this level - remove it\n\t\t\tconst newChildren = result.children.filter((_, i) => i !== index);\n\t\t\tconst newSizes = remove_and_redistribute(result.sizes, index);\n\n\t\t\t// If only one child remains, collapse the split panel\n\t\t\tif (newChildren.length === 1) {\n\t\t\t\treturn newChildren[0];\n\t\t\t}\n\n\t\t\tresult.children = newChildren;\n\t\t\tresult.sizes = newSizes;\n\t\t} else {\n\t\t\ttab_layout.child.splice(tab_layout.child.indexOf(child), 1);\n\t\t\tif (\n\t\t\t\ttab_layout.selected &&\n\t\t\t\ttab_layout.selected >= tab_layout.child.length\n\t\t\t) {\n\t\t\t\ttab_layout.selected--;\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t// Child not found at this level - recursively search children\n\tlet modified = false;\n\tconst newChildren = result.children.map((p) => {\n\t\tif (p.type === \"split-panel\") {\n\t\t\tconst updated = remove_child(p, child);\n\t\t\tif (updated !== p) {\n\t\t\t\tmodified = true;\n\t\t\t}\n\n\t\t\treturn updated;\n\t\t}\n\n\t\treturn p;\n\t});\n\n\tif (modified) {\n\t\tresult.children = newChildren;\n\t}\n\n\treturn result;\n}\n\nfunction remove_and_redistribute(arr: number[], index: number): number[] {\n\tconst result = [];\n\n\t// Get the size of the element being removed\n\tconst removed_size = arr[index];\n\n\t// Calculate the total of remaining elements\n\tlet remaining_total = 0;\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tif (i !== index) {\n\t\t\tremaining_total += arr[i];\n\t\t}\n\t}\n\n\t// Distribute the removed size proportionally to remaining elements\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tif (i !== index) {\n\t\t\tconst proportion = arr[i] / remaining_total;\n\t\t\tresult.push(arr[i] + removed_size * proportion);\n\t\t}\n\t}\n\n\treturn result;\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { Layout } from \"./types.ts\";\n\n/**\n * Inserts a new child panel into the layout tree at a specified location.\n * Creates a split panel if necessary and redistributes sizes equally among all\n * children.\n *\n * @param panel - The root layout tree to insert into\n * @param child - Unique identifier for the new child panel\n * @param path - Array of indices defining where to insert. Empty array inserts\n * at root level.\n * @param orientation - Orientation for newly created split panels. Defaults to\n * \"horizontal\".\n * @param is_edge - If true, create the split at the parent level.\n * @returns A new layout tree with the child inserted (original is not mutated).\n */\nexport function insert_child(\n\tpanel: Layout,\n\tchild: string,\n\tpath: number[],\n\torientation?: \"horizontal\" | \"vertical\",\n): Layout {\n\tconst createChildPanel = (childId: string): Layout => ({\n\t\ttype: \"child-panel\",\n\t\tchild: [childId],\n\t});\n\n\tif (path.length === 0) {\n\t\t// Insert at root level\n\t\tif (panel.type === \"child-panel\") {\n\t\t\t// Add to existing child-panel as a tab\n\t\t\treturn {\n\t\t\t\ttype: \"child-panel\",\n\t\t\t\tchild: [child, ...panel.child],\n\t\t\t};\n\t\t} else if (orientation) {\n\t\t\t// When inserting at edge of root, wrap the entire panel in a new split\n\t\t\treturn {\n\t\t\t\ttype: \"split-panel\",\n\t\t\t\torientation: orientation,\n\t\t\t\tchildren: [createChildPanel(child), panel],\n\t\t\t\tsizes: [0.5, 0.5],\n\t\t\t};\n\t\t} else {\n\t\t\t// Append to existing split-panel\n\t\t\tconst newChildren = [...panel.children, createChildPanel(child)];\n\t\t\tconst newSizes = [...panel.sizes, 1 / (newChildren.length - 1)];\n\t\t\treturn {\n\t\t\t\t...panel,\n\t\t\t\tchildren: newChildren,\n\t\t\t\tsizes: redistribute(newSizes),\n\t\t\t};\n\t\t}\n\t}\n\n\t// Navigate down the path\n\tconst [index, ...restPath] = path;\n\n\t// Special case: when orientation is provided and restPath is empty, handle edge insertion\n\tif (orientation && restPath.length === 0) {\n\t\t// If panel is a split-panel with the same orientation, insert into its children\n\t\tif (panel.type === \"split-panel\" && panel.orientation === orientation) {\n\t\t\tconst newChildren = [...panel.children];\n\t\t\tnewChildren.splice(index, 0, createChildPanel(child));\n\t\t\tconst newSizes = [...panel.sizes];\n\t\t\tnewSizes.splice(index, 0, 1 / (newChildren.length - 1));\n\t\t\treturn {\n\t\t\t\t...panel,\n\t\t\t\tchildren: newChildren,\n\t\t\t\tsizes: redistribute(newSizes),\n\t\t\t};\n\t\t}\n\n\t\t// Otherwise, wrap the entire panel in a new split at the edge\n\t\tconst children =\n\t\t\tindex === 0\n\t\t\t\t? [createChildPanel(child), panel]\n\t\t\t\t: [panel, createChildPanel(child)];\n\n\t\treturn {\n\t\t\ttype: \"split-panel\",\n\t\t\torientation: orientation,\n\t\t\tchildren,\n\t\t\tsizes: [0.5, 0.5],\n\t\t};\n\t}\n\n\tif (panel.type === \"child-panel\") {\n\t\t// Stack into child array only when ALL of these conditions are met:\n\t\t// 1. Path has exactly one element (restPath is empty)\n\t\t// 2. Orientation was NOT explicitly provided (orientation is undefined)\n\t\t// 3. Index is within the valid stacking range [0, child.length]\n\t\tif (\n\t\t\trestPath.length === 0 &&\n\t\t\torientation === undefined &&\n\t\t\tindex >= 0 &&\n\t\t\tindex <= panel.child.length\n\t\t) {\n\t\t\tconst newChild = [...panel.child];\n\t\t\tnewChild.splice(index, 0, child);\n\t\t\treturn {\n\t\t\t\t...panel,\n\t\t\t\tchild: newChild,\n\t\t\t};\n\t\t}\n\n\t\t// Otherwise, wrap in a split panel and recurse\n\t\tconst newPanel: Layout = {\n\t\t\ttype: \"split-panel\",\n\t\t\torientation: orientation || \"horizontal\",\n\t\t\tchildren: [panel],\n\t\t\tsizes: [1],\n\t\t};\n\n\t\treturn insert_child(newPanel, child, path, orientation);\n\t}\n\n\tif (restPath.length === 0 || index === panel.children.length) {\n\t\tif (orientation && panel.children[index]) {\n\t\t\t// When inserting at an edge, create a split panel with the new child and existing child\n\t\t\tconst newSplitPanel: Layout = {\n\t\t\t\ttype: \"split-panel\",\n\t\t\t\torientation: orientation,\n\t\t\t\tchildren: [createChildPanel(child), panel.children[index]],\n\t\t\t\tsizes: [0.5, 0.5],\n\t\t\t};\n\n\t\t\tconst newChildren = [...panel.children];\n\t\t\tnewChildren[index] = newSplitPanel;\n\t\t\treturn {\n\t\t\t\t...panel,\n\t\t\t\tchildren: newChildren,\n\t\t\t\tsizes: redistribute(panel.sizes),\n\t\t\t};\n\t\t}\n\n\t\t// Insert at this level at the specified index\n\t\tconst newChildren = [...panel.children];\n\t\tnewChildren.splice(index, 0, createChildPanel(child));\n\t\tconst newSizes = [...panel.sizes];\n\t\tnewSizes.splice(index, 0, 1 / (newChildren.length - 1));\n\t\treturn {\n\t\t\t...panel,\n\t\t\tchildren: newChildren,\n\t\t\tsizes: redistribute(newSizes),\n\t\t};\n\t}\n\n\tconst targetChild = panel.children[index];\n\n\t// Determine the orientation to pass down when navigating into a child-panel\n\tconst childOrientation =\n\t\ttargetChild.type === \"child-panel\" &&\n\t\trestPath.length > 0 &&\n\t\torientation !== undefined\n\t\t\t? panel.orientation === \"horizontal\"\n\t\t\t\t? \"vertical\"\n\t\t\t\t: \"horizontal\"\n\t\t\t: orientation;\n\n\tconst updatedChild = insert_child(\n\t\ttargetChild,\n\t\tchild,\n\t\trestPath,\n\t\tchildOrientation,\n\t);\n\n\tconst newChildren = [...panel.children];\n\tnewChildren[index] = updatedChild;\n\treturn {\n\t\t...panel,\n\t\tchildren: newChildren,\n\t};\n}\n\nfunction redistribute(arr: number[]): number[] {\n\tconst total = arr.reduce((sum, val) => sum + val, 0);\n\treturn arr.map((val) => val / total);\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport { MINIMUM_REDISTRIBUTION_SIZE_THRESHOLD } from \"./constants.ts\";\nimport type { Layout } from \"./types.ts\";\n\n/**\n * Adjusts panel sizes during a drag operation on a divider.\n *\n * The `delta` is distributed proportionally among affected panels, maintaining\n * the sum:\n *\n * - Panels before and including the path index shrink by delta.\n * - Panels after the path index grow by delta.\n *\n * @param panel - The root layout tree to modify.\n * @param path - Path to the divider being dragged (identifies which split panel\n * to resize).\n * @param delta - Amount to resize, as a fraction (0-1). Positive values grow\n * panels before the divider, negative values shrink them.\n * @returns A new layout tree with updated sizes (original is not mutated).\n * ```\n */\nexport function redistribute_panel_sizes(\n\tpanel: Layout,\n\tpath: number[],\n\tdelta: number,\n): Layout {\n\t// Clone the entire panel structure\n\tconst result = structuredClone(panel);\n\n\t// Find the orientation of the insertion panel,\n\t// and scale the delta on the respective axis if aligned.\n\tlet current: Layout = result;\n\tconst deltas = { horizontal: delta, vertical: delta };\n\tfor (let i = 0; i < path.length - 1; i++) {\n\t\tif (current.type === \"split-panel\") {\n\t\t\tdeltas[current.orientation] /= current.sizes[path[i]];\n\t\t\tcurrent = current.children[path[i]];\n\t\t}\n\t}\n\n\t// Apply the redistribution at the final path index\n\tif (current.type === \"split-panel\") {\n\t\tconst delta = deltas[current.orientation];\n\t\tconst index = path[path.length - 1];\n\n\t\t// It would be fun to remove this condition.\n\t\tif (index < current.sizes.length - 1) {\n\t\t\tcurrent.sizes = add_and_redistribute(current.sizes, index, delta);\n\t\t}\n\t}\n\n\treturn result;\n}\n\nfunction add_and_redistribute(\n\tarr: number[],\n\tindex: number,\n\tdelta: number,\n): number[] {\n\tconst result = [...arr];\n\tlet before_total = 0;\n\tfor (let i = 0; i <= index; i++) {\n\t\tbefore_total += arr[i];\n\t}\n\n\tlet after_total = 0;\n\tfor (let i = index + 1; i < arr.length; i++) {\n\t\tafter_total += arr[i];\n\t}\n\n\t// Clamp `delta` to prevent redistributing either side to 0.\n\tdelta =\n\t\tMath.sign(delta) *\n\t\tMath.min(\n\t\t\tMath.abs(delta),\n\t\t\t(1 - MINIMUM_REDISTRIBUTION_SIZE_THRESHOLD) *\n\t\t\t\t(delta > 0 ? before_total : after_total),\n\t\t);\n\n\t// Redistribute elements\n\tfor (let i = 0; i <= index; i++) {\n\t\tconst proportion = arr[i] / before_total;\n\t\tresult[i] = arr[i] - delta * proportion;\n\t}\n\n\tfor (let i = index + 1; i < arr.length; i++) {\n\t\tconst proportion = arr[i] / after_total;\n\t\tresult[i] = arr[i] + delta * proportion;\n\t}\n\n\treturn result;\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { LayoutPath } from \"./types\";\n\nexport function updateOverlaySheet(\n\tslot: string,\n\tbox: DOMRect,\n\tstyle: CSSStyleDeclaration,\n\tdrag_target: LayoutPath<undefined> | null,\n) {\n\tif (!drag_target) {\n\t\treturn `:host ::slotted([name=\"${slot}\"]){display:none;}`;\n\t}\n\n\tconst {\n\t\tview_window: { row_start, row_end, col_start, col_end },\n\t} = drag_target;\n\n\tconst box_height =\n\t\tbox.height - parseFloat(style.paddingTop) - parseFloat(style.paddingBottom);\n\n\tconst box_width =\n\t\tbox.width - parseFloat(style.paddingLeft) - parseFloat(style.paddingRight);\n\n\tconst top = row_start * box_height + parseFloat(style.paddingTop);\n\tconst left = col_start * box_width + parseFloat(style.paddingLeft);\n\tconst height = (row_end - row_start) * box_height;\n\tconst width = (col_end - col_start) * box_width;\n\tconst css = `display:flex;position:absolute!important;z-index:1;top:${top}px;left:${left}px;height:${height}px;width:${width}px;`;\n\treturn `::slotted([name=\"${slot}\"]){${css}}`;\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport { SPLIT_EDGE_TOLERANCE, SPLIT_ROOT_EDGE_TOLERANCE } from \"./constants\";\nimport { insert_child } from \"./insert_child\";\nimport type { Layout, LayoutPath, Orientation, ViewWindow } from \"./types\";\n\n/**\n * Calculates an insertion point (which may involve splitting a single\n * `\"child-panel\"` into a new `\"split-panel\"`), based on the cursor position.\n * *\n * @param col - The cursor column.\n * @param row - The cursor row.\n * @param panel - The `Layout` to insert into.\n * @param slot - The slot identifier where the insert should occur\n * @param drop_target - The `LayoutPath` (from `calculateIntersect`) of the\n * panel to either insert next to, or split by.\n * @returns A new `LayoutPath` reflecting the updated (maybe) `\"split-panel\"`,\n * which is enough to draw the overlay.\n */\nexport function calculate_edge(\n\tcol: number,\n\trow: number,\n\tpanel: Layout,\n\tslot: string,\n\tdrop_target: LayoutPath,\n\tbox?: DOMRect,\n): LayoutPath {\n\t// Check root edges first\n\tif (col < SPLIT_ROOT_EDGE_TOLERANCE) {\n\t\treturn insert_root_edge(panel, slot, drop_target, [0], true, \"horizontal\");\n\t}\n\n\tif (col > 1 - SPLIT_ROOT_EDGE_TOLERANCE) {\n\t\treturn insert_root_edge(\n\t\t\tpanel,\n\t\t\tslot,\n\t\t\tdrop_target,\n\t\t\tdrop_target.path.length > 0 ? drop_target.path : [],\n\t\t\tfalse,\n\t\t\t\"horizontal\",\n\t\t);\n\t}\n\n\tif (row < SPLIT_ROOT_EDGE_TOLERANCE) {\n\t\treturn insert_root_edge(panel, slot, drop_target, [0], true, \"vertical\");\n\t}\n\n\tif (row > 1 - SPLIT_ROOT_EDGE_TOLERANCE) {\n\t\treturn insert_root_edge(panel, slot, drop_target, [], false, \"vertical\");\n\t}\n\n\t// Check panel edges\n\tconst is_column_edge =\n\t\tdrop_target.column_offset < SPLIT_EDGE_TOLERANCE ||\n\t\tdrop_target.column_offset > 1 - SPLIT_EDGE_TOLERANCE;\n\n\tconst is_row_edge =\n\t\tdrop_target.row_offset < SPLIT_EDGE_TOLERANCE ||\n\t\tdrop_target.row_offset > 1 - SPLIT_EDGE_TOLERANCE;\n\n\t// If both edges triggered, choose closer axis\n\tif (is_column_edge && is_row_edge) {\n\t\tconst col_distance = Math.abs(drop_target.column_offset - 0.5);\n\t\tconst row_distance = Math.abs(drop_target.row_offset - 0.5);\n\t\tconst col_scale =\n\t\t\t(box?.width || 1) *\n\t\t\t(drop_target.view_window.col_end - drop_target.view_window.col_start);\n\n\t\tconst row_scale =\n\t\t\t(box?.height || 1) *\n\t\t\t(drop_target.view_window.row_end - drop_target.view_window.row_start);\n\n\t\tconst use_column = col_distance * col_scale > row_distance * row_scale;\n\n\t\treturn insert_axis(\n\t\t\tpanel,\n\t\t\tslot,\n\t\t\tdrop_target,\n\t\t\tuse_column\n\t\t\t\t? drop_target.column_offset < SPLIT_EDGE_TOLERANCE\n\t\t\t\t: drop_target.row_offset < SPLIT_EDGE_TOLERANCE,\n\t\t\tuse_column ? \"horizontal\" : \"vertical\",\n\t\t);\n\t}\n\n\tif (is_column_edge) {\n\t\treturn insert_axis(\n\t\t\tpanel,\n\t\t\tslot,\n\t\t\tdrop_target,\n\t\t\tdrop_target.column_offset < SPLIT_EDGE_TOLERANCE,\n\t\t\t\"horizontal\",\n\t\t);\n\t}\n\n\tif (is_row_edge) {\n\t\treturn insert_axis(\n\t\t\tpanel,\n\t\t\tslot,\n\t\t\tdrop_target,\n\t\t\tdrop_target.row_offset < SPLIT_EDGE_TOLERANCE,\n\t\t\t\"vertical\",\n\t\t);\n\t}\n\n\t// Not at an edge - insert as a tab\n\treturn {\n\t\t...drop_target,\n\t\tpath: [...drop_target.path, 0],\n\t};\n}\n\nfunction insert_root_edge(\n\tpanel: Layout,\n\tslot: string,\n\tdrop_target: LayoutPath,\n\tpath: number[],\n\tis_before: boolean,\n\torientation: Orientation,\n): LayoutPath {\n\treturn insert_axis(\n\t\tpanel,\n\t\tslot,\n\t\t{ ...drop_target, path, orientation },\n\t\tis_before,\n\t\torientation,\n\t);\n}\n\nfunction insert_axis(\n\tpanel: Layout,\n\tslot: string,\n\tdrop_target: LayoutPath,\n\tis_before: boolean,\n\taxis_orientation: Orientation,\n): LayoutPath {\n\tlet result_path: number[];\n\n\tif (drop_target.orientation === axis_orientation) {\n\t\t// Same orientation - insert into existing split\n\t\tif (drop_target.path.length === 0) {\n\t\t\tresult_path = [is_before ? 0 : 1];\n\t\t} else {\n\t\t\tconst last_index = drop_target.path[drop_target.path.length - 1];\n\t\t\tresult_path = [\n\t\t\t\t...drop_target.path.slice(0, -1),\n\t\t\t\tis_before ? last_index : last_index + 1,\n\t\t\t];\n\t\t}\n\t} else {\n\t\t// Different orientation - split the child panel\n\t\tresult_path = [...drop_target.path, is_before ? 0 : 1];\n\t}\n\n\tconst new_panel = insert_child(panel, slot, result_path, axis_orientation);\n\tconst view_window = calculate_view_window(new_panel, result_path);\n\treturn {\n\t\t...drop_target,\n\t\tpath: result_path,\n\t\tslot: drop_target.slot,\n\t\tis_edge: true,\n\t\torientation: axis_orientation,\n\t\tview_window,\n\t};\n}\n\nfunction calculate_view_window(panel: Layout, path: number[]): ViewWindow {\n\tlet view_window: ViewWindow = {\n\t\trow_start: 0,\n\t\trow_end: 1,\n\t\tcol_start: 0,\n\t\tcol_end: 1,\n\t};\n\n\tlet current_panel = panel;\n\tfor (const step of path) {\n\t\tif (current_panel.type === \"child-panel\") {\n\t\t\tbreak;\n\t\t}\n\n\t\tconst index = Math.min(step, current_panel.children.length - 1);\n\t\tconst is_vertical = current_panel.orientation === \"vertical\";\n\t\tconst start_key = is_vertical ? \"row_start\" : \"col_start\";\n\t\tconst end_key = is_vertical ? \"row_end\" : \"col_end\";\n\t\tconst total_size = view_window[end_key] - view_window[start_key];\n\t\tconst offset = current_panel.sizes\n\t\t\t.slice(0, index)\n\t\t\t.reduce((sum, size) => sum + size * total_size, view_window[start_key]);\n\n\t\tview_window = {\n\t\t\t...view_window,\n\t\t\t[start_key]: offset,\n\t\t\t[end_key]: offset + total_size * current_panel.sizes[index],\n\t\t};\n\n\t\tcurrent_panel = current_panel.children[index];\n\t}\n\n\treturn view_window;\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { Layout } from \"./types.ts\";\n\n/**\n * Flattens the layout tree by merging parent and child split panels that have\n * the same orientation and type.\n *\n * When a split panel contains a child split panel with the same orientation,\n * they are merged into a single split panel. The sizes array is scaled\n * correctly to maintain proportions.\n *\n * @param layout - The layout tree to flatten\n * @returns A new flattened layout tree (original is not mutated).\n */\nexport function flatten(layout: Layout): Layout {\n\tif (layout.type === \"child-panel\") {\n\t\tlayout.selected = layout.selected || 0;\n\t\treturn layout;\n\t}\n\n\tconst flattenedChildren: Layout[] = [];\n\tconst flattenedSizes: number[] = [];\n\tfor (let i = 0; i < layout.children.length; i++) {\n\t\tconst child = layout.children[i];\n\t\tconst childSize = layout.sizes[i];\n\t\tconst flattenedChild = flatten(child);\n\n\t\tif (\n\t\t\tflattenedChild.type === \"split-panel\" &&\n\t\t\tflattenedChild.orientation === layout.orientation\n\t\t) {\n\t\t\tfor (let j = 0; j < flattenedChild.children.length; j++) {\n\t\t\t\tflattenedChildren.push(flattenedChild.children[j]);\n\t\t\t\tflattenedSizes.push(flattenedChild.sizes[j] * childSize);\n\t\t\t}\n\t\t} else {\n\t\t\tflattenedChildren.push(flattenedChild);\n\t\t\tflattenedSizes.push(childSize);\n\t\t}\n\t}\n\n\tif (flattenedChildren.length === 1) {\n\t\treturn flattenedChildren[0];\n\t}\n\n\treturn {\n\t\ttype: \"split-panel\",\n\t\torientation: layout.orientation,\n\t\tchildren: flattenedChildren,\n\t\tsizes: flattenedSizes,\n\t};\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\n/**\n * This module defines the `<regular-layout>` custom element for browser\n * environments.\n *\n * @packageDocumentation\n */\n\nimport { EMPTY_PANEL } from \"./layout/types.ts\";\nimport { create_css_grid_layout } from \"./layout/generate_grid.ts\";\nimport type {\n\tLayoutPath,\n\tLayout,\n\tLayoutDivider,\n\tTabLayout,\n\tOverlayMode,\n\tOrientation,\n} from \"./layout/types.ts\";\nimport { calculate_intersection } from \"./layout/calculate_intersect.ts\";\nimport { remove_child } from \"./layout/remove_child.ts\";\nimport { insert_child } from \"./layout/insert_child.ts\";\nimport { redistribute_panel_sizes } from \"./layout/redistribute_panel_sizes.ts\";\nimport { updateOverlaySheet } from \"./layout/generate_overlay.ts\";\nimport { calculate_edge } from \"./layout/calculate_edge.ts\";\nimport { flatten } from \"./layout/flatten.ts\";\nimport {\n\tCUSTOM_EVENT_NAME_PREFIX,\n\tOVERLAY_CLASSNAME,\n\tOVERLAY_DEFAULT,\n} from \"./layout/constants.ts\";\n\n/**\n * A Web Component that provides a resizable panel layout system.\n * Panels are arranged using CSS Grid and can be resized by dragging dividers.\n *\n * The component uses Shadow DOM and CSS Grid to manage layout.\n *\n * @example\n * ```html\n * <regular-layout>\n * <div name=\"sidebar\">Sidebar content</div>\n * <div name=\"main\">Main content</div>\n * </regular-layout>\n * ```\n *\n * @example\n * ```typescript\n * const layout = document.querySelector('regular-layout');\n *\n * // Insert panels into the grid layout\n * layout.insertPanel('main');\n * layout.insertPanel('sidebar');\n *\n * // Remove a panel (DOM child is still connected, but not slotted)\n * layout.removePanel('sidebar');\n *\n * // Save current layout\n * const state = layout.save();\n *\n * // Restore layout later\n * layout.restore(state);\n * ```\n *\n */\nexport class RegularLayout extends HTMLElement {\n\tprivate _shadowRoot: ShadowRoot;\n\tprivate _panel: Layout;\n\tprivate _stylesheet: CSSStyleSheet;\n\tprivate _cursor_stylesheet: CSSStyleSheet;\n\tprivate _drag_target?: [LayoutDivider, number, number];\n\tprivate _cursor_override: boolean;\n\tprivate _dimensions?: { box: DOMRect; style: CSSStyleDeclaration };\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis._panel = structuredClone(EMPTY_PANEL);\n\n\t\t// Why does this implementation use a `<slot>` at all? We must use\n\t\t// `<slot>` and the Shadow DOM to scope the grid CSS rules to each\n\t\t// instance of `<regular-layout>` (without e.g. giving them unique\n\t\t// `\"id\"` and injecting into `document,head`), and we can only select\n\t\t// `::slotted` light DOM children from `adoptedStyleSheets` on the\n\t\t// `ShadowRoot`.\n\n\t\t// In addition, this model uses a single un-named `<slot>` to host all\n\t\t// light-DOM children, and the child's `\"name\"` attribute to identify\n\t\t// its position in the `Layout`. Alternatively, using named\n\t\tthis._shadowRoot = this.attachShadow({ mode: \"open\" });\n\t\tthis._shadowRoot.innerHTML = `<slot></slot>`;\n\t\tthis._stylesheet = new CSSStyleSheet();\n\t\tthis._cursor_stylesheet = new CSSStyleSheet();\n\t\tthis._cursor_override = false;\n\t\tthis._shadowRoot.adoptedStyleSheets = [\n\t\t\tthis._stylesheet,\n\t\t\tthis._cursor_stylesheet,\n\t\t];\n\t}\n\n\tconnectedCallback() {\n\t\tthis.addEventListener(\"pointerdown\", this.onPointerDown);\n\t\tthis.addEventListener(\"pointerup\", this.onPointerUp);\n\t\tthis.addEventListener(\"pointermove\", this.onPointerMove);\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.removeEventListener(\"pointerdown\", this.onPointerDown);\n\t\tthis.removeEventListener(\"pointerup\", this.onPointerUp);\n\t\tthis.removeEventListener(\"pointermove\", this.onPointerMove);\n\t}\n\n\t/**\n\t * Determines which panel is at a given screen coordinate.\n\t *\n\t * @param column - X coordinate in screen pixels.\n\t * @param row - Y coordinate in screen pixels.\n\t * @returns Panel information if a panel is at that position, null otherwise.\n\t */\n\tcalculateIntersect = (\n\t\tx: number,\n\t\ty: number,\n\t\tcheck_dividers: boolean = false,\n\t): LayoutPath<Layout> | null => {\n\t\tconst [col, row, box] = this.relativeCoordinates(x, y, false);\n\t\tconst panel = calculate_intersection(\n\t\t\tcol,\n\t\t\trow,\n\t\t\tthis._panel,\n\t\t\tcheck_dividers ? box : null,\n\t\t);\n\n\t\tif (panel?.type === \"layout-path\") {\n\t\t\treturn { ...panel, layout: this.save() };\n\t\t}\n\n\t\treturn null;\n\t};\n\n\t/**\n\t * Sets the visual overlay state during drag-and-drop operations.\n\t * Displays a preview of where a panel would be placed at the given coordinates.\n\t *\n\t * @param x - X coordinate in screen pixels.\n\t * @param y - Y coordinate in screen pixels.\n\t * @param dragTarget - A `LayoutPath` (presumably from `calculateIntersect`)\n\t * which points to the drag element in the current layout.\n\t * @param className - The CSS class name to use for the overlay panel\n\t * (defaults to \"overlay\").\n\t * @param mode - Overlay rendering mode: \"grid\" uses CSS grid to position\n\t * the target, \"absolute\" positions the panel absolutely. Defaults to\n\t * \"absolute\".\n\t */\n\tsetOverlayState = (\n\t\tx: number,\n\t\ty: number,\n\t\t{ slot }: LayoutPath<unknown>,\n\t\tclassName: string = OVERLAY_CLASSNAME,\n\t\tmode: OverlayMode = OVERLAY_DEFAULT,\n\t) => {\n\t\tconst panel = remove_child(this._panel, slot);\n\t\tArray.from(this.children)\n\t\t\t.find((x) => x.getAttribute(\"name\") === slot)\n\t\t\t?.classList.add(className);\n\n\t\tconst [col, row, box, style] = this.relativeCoordinates(x, y, false);\n\t\tlet drop_target = calculate_intersection(col, row, panel);\n\t\tif (drop_target) {\n\t\t\tdrop_target = calculate_edge(col, row, panel, slot, drop_target, box);\n\t\t}\n\n\t\tif (mode === \"grid\" && drop_target) {\n\t\t\tconst path: [string, string] = [slot, drop_target?.slot];\n\t\t\tconst css = create_css_grid_layout(panel, false, path);\n\t\t\tthis._stylesheet.replaceSync(css);\n\t\t} else if (mode === \"absolute\") {\n\t\t\tconst grid_css = create_css_grid_layout(panel);\n\t\t\tconst overlay_css = updateOverlaySheet(slot, box, style, drop_target);\n\t\t\tthis._stylesheet.replaceSync([grid_css, overlay_css].join(\"\\n\"));\n\t\t}\n\n\t\tconst event_name = `${CUSTOM_EVENT_NAME_PREFIX}-before-update`;\n\t\tconst event = new CustomEvent<Layout>(event_name, { detail: panel });\n\t\tthis.dispatchEvent(event);\n\t};\n\n\t/**\n\t * Clears the overlay state and commits the panel placement.\n\t *\n\t * @param x - X coordinate in screen pixels.\n\t * @param y - Y coordinate in screen pixels.\n\t * @param dragTarget - A `LayoutPath` (presumably from `calculateIntersect`)\n\t * which points to the drag element in the current layout.\n\t * @param className - The CSS class name to use for the overlay panel\n\t * (defaults to \"overlay\").\n\t * @param mode - Overlay rendering mode that was used, must match the mode\n\t * passed to `setOverlayState`. Defaults to \"absolute\".\n\t */\n\tclearOverlayState = (\n\t\tx: number,\n\t\ty: number,\n\t\tdrag_target: LayoutPath<Layout>,\n\t\tclassName: string = OVERLAY_CLASSNAME,\n\t) => {\n\t\tlet panel = this._panel;\n\t\tpanel = remove_child(panel, drag_target.slot);\n\t\tArray.from(this.children)\n\t\t\t.find((x) => x.getAttribute(\"name\") === drag_target.slot)\n\t\t\t?.classList.remove(className);\n\n\t\tconst [col, row, box] = this.relativeCoordinates(x, y, false);\n\t\tlet drop_target = calculate_intersection(col, row, panel);\n\t\tif (drop_target) {\n\t\t\tdrop_target = calculate_edge(\n\t\t\t\tcol,\n\t\t\t\trow,\n\t\t\t\tpanel,\n\t\t\t\tdrag_target.slot,\n\t\t\t\tdrop_target,\n\t\t\t\tbox,\n\t\t\t);\n\t\t}\n\n\t\tconst { path, orientation } = drop_target ? drop_target : drag_target;\n\t\tconst new_layout = drop_target\n\t\t\t? insert_child(\n\t\t\t\t\tpanel,\n\t\t\t\t\tdrag_target.slot,\n\t\t\t\t\tpath,\n\t\t\t\t\tdrop_target?.is_edge ? orientation : undefined,\n\t\t\t\t)\n\t\t\t: drag_target.layout;\n\n\t\tthis.restore(new_layout);\n\t};\n\n\t/**\n\t * Inserts a new panel into the layout at a specified path.\n\t *\n\t * @param name - Unique identifier for the new panel.\n\t * @param path - Index path defining where to insert.\n\t * @param split - Force a split in the layout at the end of `path`\n\t * regardless if there is a leaf at this position or not. Optionally,\n\t *. `split` may be your preferred `Orientation`, which will be used by\n\t * the new `SplitPanel` _if_ there is an option of orientation (e.g. if\n\t * the layout had no pre-existing `SplitPanel`)\n\t */\n\tinsertPanel = (\n\t\tname: string,\n\t\tpath: number[] = [],\n\t\tsplit?: boolean | Orientation,\n\t) => {\n\t\tlet orientation: Orientation | undefined;\n\t\tif (typeof split === \"boolean\" && split) {\n\t\t\torientation = \"horizontal\";\n\t\t} else if (typeof split === \"string\") {\n\t\t\torientation = split;\n\t\t}\n\n\t\tthis.restore(insert_child(this._panel, name, path, orientation));\n\t};\n\n\t/**\n\t * Removes a panel from the layout by name.\n\t *\n\t * @param name - Name of the panel to remove\n\t */\n\tremovePanel = (name: string) => {\n\t\tthis.restore(remove_child(this._panel, name));\n\t};\n\n\t/**\n\t * Retrieves a panel by name from the layout tree.\n\t *\n\t * @param name - Name of the panel to find.\n\t * @param layout - Optional layout tree to search in (defaults to current layout).\n\t * @returns The TabLayout containing the panel if found, null otherwise.\n\t */\n\tgetPanel = (name: string, layout: Layout = this._panel): TabLayout | null => {\n\t\tif (layout.type === \"child-panel\") {\n\t\t\tif (layout.child.includes(name)) {\n\t\t\t\treturn layout;\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\n\t\tfor (const child of layout.children) {\n\t\t\tconst found = this.getPanel(name, child);\n\t\t\tif (found) {\n\t\t\t\treturn found;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t};\n\n\t/**\n\t * Clears the entire layout, unslotting all panels.\n\t */\n\tclear = () => {\n\t\tthis.restore(EMPTY_PANEL);\n\t};\n\n\t/**\n\t * Restores the layout from a saved state.\n\t *\n\t * @param layout - The layout tree to restore\n\t *\n\t * @example\n\t * ```typescript\n\t * const layout = document.querySelector('regular-layout');\n\t * const savedState = JSON.parse(localStorage.getItem('layout'));\n\t * layout.restore(savedState);\n\t * ```\n\t */\n\trestore = (layout: Layout, _is_flattened: boolean = false) => {\n\t\tthis._panel = !_is_flattened ? flatten(layout) : layout;\n\t\tconst css = create_css_grid_layout(this._panel);\n\t\tthis._stylesheet.replaceSync(css);\n\t\tconst event_name = `${CUSTOM_EVENT_NAME_PREFIX}-update`;\n\t\tconst event = new CustomEvent<Layout>(event_name, { detail: this._panel });\n\t\tthis.dispatchEvent(event);\n\t};\n\n\t/**\n\t * Serializes the current layout state, which can be restored via `restore`.\n\t *\n\t * @returns The current layout tree\n\t *\n\t * @example\n\t * ```typescript\n\t * const layout = document.querySelector('regular-layout');\n\t * const state = layout.save();\n\t * localStorage.setItem('layout', JSON.stringify(state));\n\t * ```\n\t */\n\tsave = (): Layout => {\n\t\treturn structuredClone(this._panel);\n\t};\n\n\t/**\n\t * Converts screen coordinates to relative layout coordinates.\n\t *\n\t * Transforms absolute pixel positions into normalized coordinates (0-1 range)\n\t * relative to the layout's bounding box.\n\t *\n\t * @param clientX - X coordinate in screen pixels (client space).\n\t * @param clientY - Y coordinate in screen pixels (client space).\n\t * @returns A tuple containing:\n\t * - col: Normalized X coordinate (0 = left edge, 1 = right edge)\n\t * - row: Normalized Y coordinate (0 = top edge, 1 = bottom edge)\n\t * - box: The layout element's bounding rectangle\n\t */\n\trelativeCoordinates = (\n\t\tclientX: number,\n\t\tclientY: number,\n\t\trecalculate_bounds: boolean = true,\n\t): [number, number, DOMRect, CSSStyleDeclaration] => {\n\t\tif (recalculate_bounds || !this._dimensions) {\n\t\t\tthis._dimensions = {\n\t\t\t\tbox: this.getBoundingClientRect(),\n\t\t\t\tstyle: getComputedStyle(this),\n\t\t\t};\n\t\t}\n\n\t\tconst box = this._dimensions.box;\n\t\tconst style = this._dimensions.style;\n\t\tconst col =\n\t\t\t(clientX - box.left - parseFloat(style.paddingLeft)) /\n\t\t\t(box.width -\n\t\t\t\tparseFloat(style.paddingLeft) -\n\t\t\t\tparseFloat(style.paddingRight));\n\t\tconst row =\n\t\t\t(clientY - box.top - parseFloat(style.paddingTop)) /\n\t\t\t(box.height -\n\t\t\t\tparseFloat(style.paddingTop) -\n\t\t\t\tparseFloat(style.paddingBottom));\n\n\t\treturn [col, row, box, style];\n\t};\n\n\tprivate onPointerDown = (event: PointerEvent) => {\n\t\tif (event.target === this) {\n\t\t\tconst [col, row, box] = this.relativeCoordinates(\n\t\t\t\tevent.clientX,\n\t\t\t\tevent.clientY,\n\t\t\t);\n\n\t\t\tconst hit = calculate_intersection(col, row, this._panel, box);\n\t\t\tif (hit && hit.type !== \"layout-path\") {\n\t\t\t\tthis._drag_target = [hit, col, row];\n\t\t\t\tthis.setPointerCapture(event.pointerId);\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate onPointerMove = (event: PointerEvent) => {\n\t\tif (this._drag_target) {\n\t\t\tconst [col, row] = this.relativeCoordinates(\n\t\t\t\tevent.clientX,\n\t\t\t\tevent.clientY,\n\t\t\t\tfalse,\n\t\t\t);\n\n\t\t\tconst [{ path, type }, old_col, old_row] = this._drag_target;\n\t\t\tconst offset = type === \"horizontal\" ? old_col - col : old_row - row;\n\t\t\tconst panel = redistribute_panel_sizes(this._panel, path, offset);\n\t\t\tthis._stylesheet.replaceSync(create_css_grid_layout(panel));\n\t\t} else if (event.target === this) {\n\t\t\tconst [col, row, box] = this.relativeCoordinates(\n\t\t\t\tevent.clientX,\n\t\t\t\tevent.clientY,\n\t\t\t\tfalse,\n\t\t\t);\n\n\t\t\tconst divider = calculate_intersection(col, row, this._panel, box);\n\t\t\tif (divider?.type === \"vertical\") {\n\t\t\t\tthis._cursor_stylesheet.replaceSync(\":host{cursor:row-resize\");\n\t\t\t\tthis._cursor_override = true;\n\t\t\t} else if (divider?.type === \"horizontal\") {\n\t\t\t\tthis._cursor_stylesheet.replaceSync(\":host{cursor:col-resize\");\n\t\t\t\tthis._cursor_override = true;\n\t\t\t}\n\t\t} else if (this._cursor_override) {\n\t\t\tthis._cursor_override = false;\n\t\t\tthis._cursor_stylesheet.replaceSync(\"\");\n\t\t}\n\t};\n\n\tprivate onPointerUp = (event: PointerEvent) => {\n\t\tif (this._drag_target) {\n\t\t\tthis.releasePointerCapture(event.pointerId);\n\t\t\tconst [col, row] = this.relativeCoordinates(\n\t\t\t\tevent.clientX,\n\t\t\t\tevent.clientY,\n\t\t\t\tfalse,\n\t\t\t);\n\n\t\t\tconst [{ path, type }, old_col, old_row] = this._drag_target;\n\t\t\tconst offset = type === \"horizontal\" ? old_col - col : old_row - row;\n\t\t\tconst panel = redistribute_panel_sizes(this._panel, path, offset);\n\t\t\tthis.restore(panel, true);\n\t\t\tthis._drag_target = undefined;\n\t\t}\n\t};\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport { MIN_DRAG_DISTANCE, OVERLAY_CLASSNAME } from \"./layout/constants.ts\";\nimport type { Layout, LayoutPath } from \"./layout/types.ts\";\nimport type { RegularLayoutEvent } from \"./extensions.ts\";\nimport type { RegularLayout } from \"./regular-layout.ts\";\nimport type { RegularLayoutTab } from \"./regular-layout-tab.ts\";\n\nconst CSS = `\n:host{box-sizing:border-box;flex-direction:column}\n:host::part(titlebar){display:flex;height:24px;user-select:none;overflow:hidden}\n:host::part(container){flex:1 1 auto}\n:host::part(title){flex:1 1 auto;pointer-events:none}\n:host::part(close){align-self:stretch}\n:host::slotted{flex:1 1 auto;}\n:host regular-layout-tab{width:0px;}\n`;\n\nconst HTML_TEMPLATE = `\n\t<div part=\"titlebar\"></div>\n\t<slot part=\"container\"></slot>\n`;\n\n/**\n * A custom element that represents a draggable panel within a\n * `<regular-layout>`.\n *\n * `<regular-layout-frame>` is optional - you may also use a `<regular-layout>`\n * with just plain `<div>` children (for example), but panels will not be\n * moveable within the layout unless you manually call `setOverlayState` and\n * `clearOverlayState` (or otherwise impement panel moving via the\n * `<regular-layout>` API).\n *\n * `<regular-layout-frame>` simple and highly customizable implementations\n * based on [CSS `part`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/::part)\n * for custom styling, and symmetric\n * [named `slot`s](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_templates_and_slots)\n * for wholesale replacement of the underlying Shadow DOM.\n *\n * @example\n * ```html\n * <regular-layout>\n * <regular-layout-frame name=\"panel-1\">\n * <!-- Panel content here -->\n * </regular-layout-frame>\n * </regular-layout>\n * ```\n */\nexport class RegularLayoutFrame extends HTMLElement {\n\tprivate _shadowRoot: ShadowRoot;\n\tprivate _container_sheet: CSSStyleSheet;\n\tprivate _layout!: RegularLayout;\n\tprivate _header!: HTMLElement;\n\tprivate _drag_state: LayoutPath<Layout> | null = null;\n\tprivate _drag_moved: boolean = false;\n\tprivate _tab_to_index_map: WeakMap<RegularLayoutTab, number> = new WeakMap();\n\tconstructor() {\n\t\tsuper();\n\t\tthis._container_sheet = new CSSStyleSheet();\n\t\tthis._container_sheet.replaceSync(CSS);\n\t\tthis._shadowRoot = this.attachShadow({ mode: \"open\" });\n\t\tthis._shadowRoot.adoptedStyleSheets = [this._container_sheet];\n\t}\n\n\tconnectedCallback() {\n\t\tthis._shadowRoot.innerHTML = HTML_TEMPLATE;\n\t\tthis._layout = this.parentElement as RegularLayout;\n\t\tthis._header = this._shadowRoot.children[0] as HTMLElement;\n\t\tthis._header.addEventListener(\"pointerdown\", this.onPointerDown);\n\t\tthis._header.addEventListener(\"pointermove\", this.onPointerMove);\n\t\tthis._header.addEventListener(\"pointerup\", this.onPointerUp);\n\t\tthis._header.addEventListener(\"lostpointercapture\", this.onPointerLost);\n\t\tthis._layout.addEventListener(\"regular-layout-update\", this.drawTabs);\n\t\tthis._layout.addEventListener(\n\t\t\t\"regular-layout-before-update\",\n\t\t\tthis.drawTabs,\n\t\t);\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis._header.removeEventListener(\"pointerdown\", this.onPointerDown);\n\t\tthis._header.removeEventListener(\"pointermove\", this.onPointerMove);\n\t\tthis._header.removeEventListener(\"pointerup\", this.onPointerUp);\n\t\tthis._header.removeEventListener(\"lostpointercapture\", this.onPointerLost);\n\t\tthis._layout.removeEventListener(\"regular-layout-update\", this.drawTabs);\n\t\tthis._layout.removeEventListener(\n\t\t\t\"regular-layout-before-update\",\n\t\t\tthis.drawTabs,\n\t\t);\n\t}\n\n\tprivate onPointerDown = (event: PointerEvent): void => {\n\t\tconst elem = event.target as RegularLayoutTab;\n\t\tif (elem.part.contains(\"tab\")) {\n\t\t\tthis._drag_state = this._layout.calculateIntersect(\n\t\t\t\tevent.clientX,\n\t\t\t\tevent.clientY,\n\t\t\t);\n\n\t\t\tif (this._drag_state) {\n\t\t\t\tthis._header.setPointerCapture(event.pointerId);\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate onPointerMove = (event: PointerEvent): void => {\n\t\tif (this._drag_state) {\n\t\t\t// Only initiate a drag if the cursor has moved sufficiently.\n\t\t\tif (!this._drag_moved) {\n\t\t\t\tconst [current_col, current_row, box] =\n\t\t\t\t\tthis._layout.relativeCoordinates(event.clientX, event.clientY);\n\n\t\t\t\tconst dx = (current_col - this._drag_state.column) * box.width;\n\t\t\t\tconst dy = (current_row - this._drag_state.row) * box.height;\n\t\t\t\tif (Math.sqrt(dx * dx + dy * dy) <= MIN_DRAG_DISTANCE) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis._drag_moved = true;\n\t\t\tthis._layout.setOverlayState(\n\t\t\t\tevent.clientX,\n\t\t\t\tevent.clientY,\n\t\t\t\tthis._drag_state,\n\t\t\t\tOVERLAY_CLASSNAME,\n\t\t\t);\n\t\t}\n\t};\n\n\tprivate onPointerUp = (event: PointerEvent): void => {\n\t\tif (this._drag_state && this._drag_moved) {\n\t\t\tthis._layout.clearOverlayState(\n\t\t\t\tevent.clientX,\n\t\t\t\tevent.clientY,\n\t\t\t\tthis._drag_state,\n\t\t\t\tOVERLAY_CLASSNAME,\n\t\t\t);\n\t\t}\n\n\t\t// TODO This may be handled by `onPointerLost`, not sure if this is\n\t\t// browser-specific behavior ...\n\t\tthis._header.releasePointerCapture(event.pointerId);\n\t\tthis._drag_state = null;\n\t\tthis._drag_moved = false;\n\t};\n\n\tprivate onPointerLost = (event: PointerEvent): void => {\n\t\tif (this._drag_state) {\n\t\t\tthis._layout.clearOverlayState(-1, -1, this._drag_state);\n\t\t}\n\n\t\tthis._header.releasePointerCapture(event.pointerId);\n\t\tthis._drag_state = null;\n\t\tthis._drag_moved = false;\n\t};\n\n\tprivate drawTabs = (event: RegularLayoutEvent) => {\n\t\tconst slot = this.getAttribute(\"name\");\n\t\tif (!slot) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst new_panel = event.detail;\n\t\tlet new_tab_panel = this._layout.getPanel(slot, new_panel);\n\t\tif (!new_tab_panel) {\n\t\t\tnew_tab_panel = {\n\t\t\t\ttype: \"child-panel\",\n\t\t\t\tchild: [slot],\n\t\t\t\tselected: 0,\n\t\t\t};\n\t\t}\n\n\t\tfor (let i = 0; i < new_tab_panel.child.length; i++) {\n\t\t\tif (i >= this._header.children.length) {\n\t\t\t\tconst new_tab = document.createElement(\"regular-layout-tab\");\n\t\t\t\tnew_tab.populate(this._layout, new_tab_panel, i);\n\t\t\t\tthis._header.appendChild(new_tab);\n\t\t\t\tthis._tab_to_index_map.set(new_tab, i);\n\t\t\t} else {\n\t\t\t\tconst tab = this._header.children[i] as RegularLayoutTab;\n\t\t\t\ttab.populate(this._layout, new_tab_panel, i);\n\t\t\t}\n\t\t}\n\n\t\tconst last_index = new_tab_panel.child.length;\n\t\tfor (let j = this._header.children.length - 1; j >= last_index; j--) {\n\t\t\tthis._header.removeChild(this._header.children[j]);\n\t\t}\n\t};\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { TabLayout } from \"./layout/types.ts\";\nimport type { RegularLayout } from \"./regular-layout.ts\";\n\n/**\n * A custom HTML element representing an individual tab in a tab panel.\n *\n * This element manages the visual representation and interactions for a single tab,\n * including selection state, close functionality, and content display.\n */\nexport class RegularLayoutTab extends HTMLElement {\n\tprivate _layout?: RegularLayout;\n\tprivate _tab_panel?: TabLayout;\n\tprivate _index?: number;\n\n\t/**\n\t * Populates or updates the tab with layout information.\n\t *\n\t * This method initializes the tab's content and event listeners on first call,\n\t * and efficiently updates only the changed properties on subsequent calls.\n\t *\n\t * @param layout - The parent RegularLayout instance managing this tab.\n\t * @param tab_panel - The tab panel layout containing this tab.\n\t * @param index - The index of this tab within the tab panel.\n\t */\n\tpopulate = (layout: RegularLayout, tab_panel: TabLayout, index: number) => {\n\t\tif (this._tab_panel) {\n\t\t\tconst tab_changed =\n\t\t\t\t(index === tab_panel.selected) !==\n\t\t\t\t(index === this._tab_panel?.selected);\n\n\t\t\tconst index_changed =\n\t\t\t\ttab_changed || this._tab_panel?.child[index] !== tab_panel.child[index];\n\n\t\t\tif (index_changed) {\n\t\t\t\tconst selected = tab_panel.selected === index;\n\t\t\t\tconst slot = tab_panel.child[index];\n\t\t\t\tthis.children[0].textContent = slot;\n\n\t\t\t\tif (selected) {\n\t\t\t\t\tthis.children[1].part.add(\"active-close\");\n\t\t\t\t\tthis.part.add(\"active-tab\");\n\t\t\t\t} else {\n\t\t\t\t\tthis.children[1].part.remove(\"active-close\");\n\t\t\t\t\tthis.part.remove(\"active-tab\");\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst slot = tab_panel.child[index];\n\t\t\tconst selected = tab_panel.selected === index;\n\t\t\tconst parts = selected ? \"active-close close\" : \"close\";\n\t\t\tthis.innerHTML = `<div part=\"title\"></div><button part=\"${parts}\"></button>`;\n\t\t\tif (selected) {\n\t\t\t\tthis.part.add(\"tab\", \"active-tab\");\n\t\t\t} else {\n\t\t\t\tthis.part.add(\"tab\");\n\t\t\t}\n\n\t\t\tthis.addEventListener(\"pointerdown\", this.onTabClick);\n\t\t\tthis.children[0].textContent = slot;\n\t\t\tthis.children[1].addEventListener(\"pointerdown\", this.onTabClose);\n\t\t}\n\n\t\tthis._tab_panel = tab_panel;\n\t\tthis._layout = layout;\n\t\tthis._index = index;\n\t};\n\n\tprivate onTabClose = (_: Event) => {\n\t\tif (this._tab_panel !== undefined && this._index !== undefined) {\n\t\t\tthis._layout?.removePanel(this._tab_panel.child[this._index]);\n\t\t}\n\t};\n\n\tprivate onTabClick = (_: PointerEvent) => {\n\t\tif (\n\t\t\tthis._tab_panel !== undefined &&\n\t\t\tthis._index !== undefined &&\n\t\t\tthis._index !== this._tab_panel.selected\n\t\t) {\n\t\t\tconst new_layout = this._layout?.save();\n\t\t\tconst new_tab_panel = this._layout?.getPanel(\n\t\t\t\tthis._tab_panel.child[this._index],\n\t\t\t\tnew_layout,\n\t\t\t);\n\n\t\t\tif (new_tab_panel && new_layout) {\n\t\t\t\tnew_tab_panel.selected = this._index;\n\t\t\t\tthis._layout?.restore(new_layout);\n\t\t\t}\n\t\t}\n\t};\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport { RegularLayout } from \"./regular-layout.ts\";\nimport { RegularLayoutFrame } from \"./regular-layout-frame.ts\";\nimport type { Layout } from \"./layout/types.ts\";\nimport { RegularLayoutTab } from \"./regular-layout-tab.ts\";\n\ncustomElements.define(\"regular-layout\", RegularLayout);\ncustomElements.define(\"regular-layout-frame\", RegularLayoutFrame);\ncustomElements.define(\"regular-layout-tab\", RegularLayoutTab);\n\ndeclare global {\n\tinterface Document {\n\t\tcreateElement(\n\t\t\ttagName: \"regular-layout\",\n\t\t\toptions?: ElementCreationOptions,\n\t\t): RegularLayout;\n\n\t\tcreateElement(\n\t\t\ttagName: \"regular-layout-frame\",\n\t\t\toptions?: ElementCreationOptions,\n\t\t): RegularLayoutFrame;\n\n\t\tcreateElement(\n\t\t\ttagName: \"regular-layout-tab\",\n\t\t\toptions?: ElementCreationOptions,\n\t\t): RegularLayoutTab;\n\n\t\tquerySelector<E extends Element = Element>(selectors: string): E | null;\n\t\tquerySelector(selectors: \"regular-layout\"): RegularLayout | null;\n\t\tquerySelector(selectors: \"regular-layout-frame\"): RegularLayoutFrame | null;\n\t\tquerySelector(selectors: \"regular-layout-tab\"): RegularLayoutTab | null;\n\t}\n\n\tinterface CustomElementRegistry {\n\t\tget(tagName: \"regular-layout\"): typeof RegularLayout;\n\t\tget(tagName: \"regular-layout-frame\"): typeof RegularLayoutFrame;\n\t}\n\n\tinterface HTMLElement {\n\t\taddEventListener(\n\t\t\tname: \"regular-layout-update\",\n\t\t\tcb: (e: RegularLayoutEvent) => void,\n\t\t\toptions?: { signal: AbortSignal },\n\t\t): void;\n\n\t\taddEventListener(\n\t\t\tname: \"regular-layout-before-update\",\n\t\t\tcb: (e: RegularLayoutEvent) => void,\n\t\t\toptions?: { signal: AbortSignal },\n\t\t): void;\n\n\t\tremoveEventListener(\n\t\t\tname: \"regular-layout-update\",\n\t\t\tcb: (e: RegularLayoutEvent) => void,\n\t\t): void;\n\n\t\tremoveEventListener(\n\t\t\tname: \"regular-layout-before-update\",\n\t\t\tcb: (e: RegularLayoutEvent) => void,\n\t\t): void;\n\t}\n}\n\nexport type RegularLayoutEvent = CustomEvent<Layout>;\n"],
5
- "mappings": "AAmGO,IAAMA,EAAsB,CAClC,KAAM,cACN,YAAa,aACb,MAAO,CAAC,EACR,SAAU,CAAC,CACZ,ECvFO,IAAMC,EAA2B,iBAUjC,IAAMC,EAAoB,UA8B1B,IAAMC,EAA+B,WCnC5C,SAASC,EAAYC,EAAkBC,EAAa,CACnD,OACCD,EAAO,SAAW,GAClB,KAAK,IAAIC,EAAMD,EAAOA,EAAO,OAAS,CAAC,CAAC,EAAI,OAE5CA,EAAO,KAAKC,CAAG,EAGTD,CACR,CAEA,SAASE,EAAiBC,EAA+B,CAExD,OADeA,EAAU,KAAK,CAACC,EAAGC,IAAMD,EAAIC,CAAC,EAC/B,OAAON,EAAa,CAAC,CAAC,CACrC,CAEA,SAASO,EACRC,EACAC,EACAC,EACAC,EACW,CACX,GAAIH,EAAM,OAAS,cAClB,MAAO,CAACE,EAAOC,CAAG,EAGnB,IAAMP,EAAsB,CAACM,EAAOC,CAAG,EACvC,GAAIH,EAAM,cAAgBC,EAAa,CACtC,IAAIG,EAAUF,EACRG,EAAQF,EAAMD,EACpB,QAASI,EAAI,EAAGA,EAAIN,EAAM,SAAS,OAAQM,IAAK,CAC/C,IAAMC,EAAOP,EAAM,MAAMM,CAAC,EACpBE,EAAOJ,EAAUG,EAAOF,EAC9BT,EAAU,KACT,GAAGG,EACFC,EAAM,SAASM,CAAC,EAChBL,EACAG,EACAI,CACD,CACD,EAEAJ,EAAUI,CACX,CACD,KACC,SAAWC,KAAST,EAAM,SACzBJ,EAAU,KACT,GAAGG,EAAwBU,EAAOR,EAAaC,EAAOC,CAAG,CAC1D,EAIF,OAAOR,EAAiBC,CAAS,CAClC,CAEA,SAASc,EAAiBd,EAAqBe,EAAuB,CACrE,IAAMC,EAAQhB,EAAU,UACtBF,GAAQ,KAAK,IAAIA,EAAMiB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AAK,UAAU,EACpD,KAAK,SAAS,CAAC,EAAE,YAAcC,EAC/B,KAAK,SAAS,CAAC,EAAE,iBAAiB,cAAe,KAAK,UAAU,CACjE,CAEA,KAAK,WAAaH,EAClB,KAAK,QAAUD,EACf,KAAK,OAASE,CACf,EAEQ,WAAcI,GAAa,CAC9B,KAAK,aAAe,QAAa,KAAK,SAAW,QACpD,KAAK,SAAS,YAAY,KAAK,WAAW,MAAM,KAAK,MAAM,CAAC,CAE9D,EAEQ,WAAcA,GAAoB,CACzC,GACC,KAAK,aAAe,QACpB,KAAK,SAAW,QAChB,KAAK,SAAW,KAAK,WAAW,SAC/B,CACD,IAAMC,EAAa,KAAK,SAAS,KAAK,EAChCC,EAAgB,KAAK,SAAS,SACnC,KAAK,WAAW,MAAM,KAAK,MAAM,EACjCD,CACD,EAEIC,GAAiBD,IACpBC,EAAc,SAAW,KAAK,OAC9B,KAAK,SAAS,QAAQD,CAAU,EAElC,CACD,CACD,ECtFA,eAAe,OAAO,iBAAkBE,CAAa,EACrD,eAAe,OAAO,uBAAwBC,CAAkB,EAChE,eAAe,OAAO,qBAAsBC,CAAgB",
6
- "names": ["EMPTY_PANEL", "CUSTOM_EVENT_NAME_PREFIX", "OVERLAY_CLASSNAME", "OVERLAY_DEFAULT", "dedupe_sort", "result", "pos", "dedupe_positions", "positions", "a", "b", "collect_track_positions", "panel", "orientation", "start", "end", "current", "range", "i", "size", "next", "child", "find_track_index", "value", "index", "build_cells", "colPositions", "rowPositions", "colStart", "colEnd", "rowStart", "rowEnd", "selected", "children", "sizes", "isHorizontal", "cells", "host_template", "rowTemplate", "colTemplate", "child_template", "slot", "rowPart", "colPart", "create_css_grid_layout", "layout", "round", "overlay", "createTemplate", "s", "formatGridLine", "css", "cell", "VIEW_WINDOW", "calculate_intersection", "column", "row", "layout", "check_dividers", "calculate_intersection_recursive", "panel", "parent_orientation", "view_window", "path", "selected", "col_width", "row_height", "is_vertical", "position", "start_key", "end_key", "rect_dim", "current_pos", "total_size", "i", "next_pos", "divider_threshold", "remove_child", "panel", "child", "newChild", "c", "EMPTY_PANEL", "result", "index", "p", "tab_layout", "newChildren", "_", "i", "newSizes", "remove_and_redistribute", "modified", "updated", "arr", "removed_size", "remaining_total", "proportion", "insert_child", "panel", "child", "path", "orientation", "createChildPanel", "childId", "newChildren", "newSizes", "redistribute", "index", "restPath", "children", "newChild", "newSplitPanel", "targetChild", "childOrientation", "updatedChild", "arr", "total", "sum", "val", "redistribute_panel_sizes", "panel", "path", "delta", "result", "current", "deltas", "i", "index", "add_and_redistribute", "arr", "before_total", "after_total", "proportion", "updateOverlaySheet", "slot", "box", "style", "drag_target", "row_start", "row_end", "col_start", "col_end", "box_height", "box_width", "top", "left", "height", "width", "css", "calculate_edge", "col", "row", "panel", "slot", "drop_target", "box", "insert_root_edge", "is_column_edge", "is_row_edge", "col_distance", "row_distance", "col_scale", "row_scale", "use_column", "insert_axis", "path", "is_before", "orientation", "axis_orientation", "result_path", "last_index", "new_panel", "insert_child", "view_window", "calculate_view_window", "current_panel", "step", "index", "is_vertical", "start_key", "end_key", "total_size", "offset", "sum", "size", "flatten", "layout", "flattenedChildren", "flattenedSizes", "i", "child", "childSize", "flattenedChild", "j", "RegularLayout", "EMPTY_PANEL", "x", "y", "check_dividers", "col", "row", "box", "panel", "calculate_intersection", "slot", "className", "OVERLAY_CLASSNAME", "mode", "OVERLAY_DEFAULT", "remove_child", "style", "drop_target", "calculate_edge", "path", "css", "create_css_grid_layout", "grid_css", "overlay_css", "updateOverlaySheet", "event_name", "CUSTOM_EVENT_NAME_PREFIX", "event", "drag_target", "orientation", "new_layout", "insert_child", "name", "split", "layout", "child", "found", "_is_flattened", "flatten", "clientX", "clientY", "recalculate_bounds", "hit", "type", "old_col", "old_row", "offset", "redistribute_panel_sizes", "divider", "CSS", "HTML_TEMPLATE", "RegularLayoutFrame", "event", "current_col", "current_row", "box", "dx", "dy", "OVERLAY_CLASSNAME", "slot", "new_panel", "new_tab_panel", "i", "new_tab", "last_index", "j", "RegularLayoutTab", "layout", "tab_panel", "index", "selected", "slot", "parts", "_", "new_layout", "new_tab_panel", "RegularLayout", "RegularLayoutFrame", "RegularLayoutTab"]
4
+ "sourcesContent": ["// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\n/**\n * The overlay behavior type.\n */\nexport type OverlayMode = \"grid\" | \"absolute\";\n\n/**\n * The representation of a CSS grid, in JSON form.\n */\nexport type Layout = SplitLayout | TabLayout;\n\n/**\n * The orientation (of a `SplitPanel`).\n */\nexport type Orientation = \"horizontal\" | \"vertical\";\n\n/**\n * A logical rectange in percent-coordinates (of a (1, 1) square).\n */\nexport interface ViewWindow {\n\trow_start: number;\n\trow_end: number;\n\tcol_start: number;\n\tcol_end: number;\n}\n\n\n/**\n * A split panel that divides space among multiple child layouts\n * .\n * Child panels are arranged either horizontally (side by side) or vertically\n * (stacked), via the `orientation` property `\"horizzontal\"` and `\"vertical\"`\n * (respectively).\n *\n * While the type structure of `SplitLayout` allows nesting levels with the same\n * `orientation`, calling `RegularLayout.restore` with such a `Layout` will be\n * flattened to the equivalent layout with every child guaranteed to have the\n * opposite `orientation` as its parent.\n */\nexport interface SplitLayout {\n\ttype: \"split-panel\";\n\tchildren: Layout[];\n\tsizes: number[];\n\torientation: Orientation;\n}\n\n/**\n * A leaf panel node that contains a single named child element.\n */\nexport interface TabLayout {\n\ttype: \"child-panel\";\n\tchild: string[];\n\tselected?: number;\n}\n\n/**\n * Represents a draggable divider between two panels in the layout.\n *\n * Used for hit detection.\n */\nexport interface LayoutDivider {\n\tpath: number[];\n\tview_window: ViewWindow;\n\ttype: Orientation;\n}\n\n/**\n * Represents a panel location result from hit detection.\n *\n * Contains both the panel identifier and its grid position in relative units.\n * The generic parameter `T` allows DOM-only properties (e.g. `DOMRect`) to be\n * shared in this cross-platform module.\n */\nexport interface LayoutPath<T = undefined> {\n\ttype: \"layout-path\";\n\tslot: string;\n\tpath: number[];\n\tview_window: ViewWindow;\n\tcolumn: number;\n\trow: number;\n\tcolumn_offset: number;\n\trow_offset: number;\n\torientation: Orientation;\n\tis_edge: boolean;\n\tlayout: T;\n}\n\n/**\n * An empty `Layout` with no panels.\n */\nexport const EMPTY_PANEL: Layout = {\n\ttype: \"split-panel\",\n\torientation: \"horizontal\",\n\tsizes: [],\n\tchildren: [],\n};\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { OverlayMode } from \"./types\";\n\n/**\n * Instance-specific constants which define the behavior and rendering details\n * of a `<regular-layout>`.\n */\nexport interface Physics {\n\t/**\n\t * The prefix to use for `CustomEvent`s generated by `regular-layout`, e.g.\n\t * `\"regular-layout-before-update\"`.\n\t */\n\tCUSTOM_EVENT_NAME_PREFIX: string;\n\n\t/**\n\t * The attribute name to use for matching child `Element`s to grid\n\t * positions.\n\t */\n\tCHILD_ATTRIBUTE_NAME: string;\n\n\t/**\n\t * The minimum number of pixels the mouse must move to be considered a drag.\n\t */\n\tMIN_DRAG_DISTANCE: number;\n\n\t/**\n\t * Should floating point pixel calculations be rounded. Useful for testing.\n\t */\n\tSHOULD_ROUND: boolean;\n\n\t/**\n\t * Class name to use for child elements in overlay position (dragging).\n\t */\n\tOVERLAY_CLASSNAME: string;\n\n\t/**\n\t * The percentage of the maximum resize distance that will be clamped.\n\t */\n\tMINIMUM_REDISTRIBUTION_SIZE_THRESHOLD: number;\n\n\t/**\n\t * Threshold from panel edge that is considered a split vs drop action.\n\t */\n\tSPLIT_EDGE_TOLERANCE: number;\n\n\t/**\n\t * Threshold from _container_ edge that is considered a split action on the root\n\t * node.\n\t */\n\tSPLIT_ROOT_EDGE_TOLERANCE: number;\n\n\t/**\n\t * Tolerance threshold for considering two grid track positions as identical.\n\t *\n\t * When collecting and deduplicating track positions, any positions closer than\n\t * this value are treated as the same position to avoid redundant grid tracks.\n\t */\n\tGRID_TRACK_COLLAPSE_TOLERANCE: number;\n\n\t/**\n\t * The overlay default behavior.\n\t */\n\tOVERLAY_DEFAULT: OverlayMode;\n\n\t/**\n\t * Width of split panel dividers in pixels (for hit-test purposes).\n\t */\n\tGRID_DIVIDER_SIZE: number;\n\n\t/**\n\t * Whether the grid should trigger column resize if the grid itself is not\n\t * the `event.target`.\n\t */\n\tGRID_DIVIDER_CHECK_TARGET: boolean;\n}\n\n/**\n * Like `GlobalPhysics`, but suitable for partial definition for incremental\n * updates.\n */\nexport interface PhysicsUpdate {\n\tCUSTOM_EVENT_NAME_PREFIX?: string;\n\tCHILD_ATTRIBUTE_NAME?: string;\n\tMIN_DRAG_DISTANCE?: number;\n\tSHOULD_ROUND?: boolean;\n\tOVERLAY_CLASSNAME?: string;\n\tMINIMUM_REDISTRIBUTION_SIZE_THRESHOLD?: number;\n\tSPLIT_EDGE_TOLERANCE?: number;\n\tSPLIT_ROOT_EDGE_TOLERANCE?: number;\n\tGRID_TRACK_COLLAPSE_TOLERANCE?: number;\n\tOVERLAY_DEFAULT?: OverlayMode;\n\tGRID_DIVIDER_SIZE?: number;\n\tGRID_DIVIDER_CHECK_TARGET?: boolean;\n}\n\nexport const DEFAULT_PHYSICS: Physics = Object.freeze({\n\tCUSTOM_EVENT_NAME_PREFIX: \"regular-layout\",\n\tCHILD_ATTRIBUTE_NAME: \"name\",\n\tMIN_DRAG_DISTANCE: 10,\n\tSHOULD_ROUND: false,\n\tOVERLAY_CLASSNAME: \"overlay\",\n\tMINIMUM_REDISTRIBUTION_SIZE_THRESHOLD: 0.15,\n\tSPLIT_EDGE_TOLERANCE: 0.25,\n\tSPLIT_ROOT_EDGE_TOLERANCE: 0.01,\n\tGRID_TRACK_COLLAPSE_TOLERANCE: 0.001,\n\tOVERLAY_DEFAULT: \"absolute\",\n\tGRID_DIVIDER_SIZE: 6,\n\tGRID_DIVIDER_CHECK_TARGET: true,\n});\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport { DEFAULT_PHYSICS, type Physics } from \"./constants.ts\";\nimport type { Layout } from \"./types.ts\";\n\ninterface GridCell {\n\tchild: string;\n\tcolStart: number;\n\tcolEnd: number;\n\trowStart: number;\n\trowEnd: number;\n}\n\nfunction dedupe_sort(physics: Physics, result: number[], pos: number) {\n\tif (\n\t\tresult.length === 0 ||\n\t\tMath.abs(pos - result[result.length - 1]) >\n\t\t\tphysics.GRID_TRACK_COLLAPSE_TOLERANCE\n\t) {\n\t\tresult.push(pos);\n\t}\n\n\treturn result;\n}\n\nfunction dedupe_positions(physics: Physics, positions: number[]): number[] {\n\tconst sorted = positions.sort((a, b) => a - b);\n\treturn sorted.reduce(dedupe_sort.bind(undefined, physics), []);\n}\n\nfunction collect_track_positions(\n\tpanel: Layout,\n\torientation: \"horizontal\" | \"vertical\",\n\tstart: number,\n\tend: number,\n\tphysics: Physics,\n): number[] {\n\tif (panel.type === \"child-panel\") {\n\t\treturn [start, end];\n\t}\n\n\tconst positions: number[] = [start, end];\n\tif (panel.orientation === orientation) {\n\t\tlet current = start;\n\t\tconst range = end - start;\n\t\tfor (let i = 0; i < panel.children.length; i++) {\n\t\t\tconst size = panel.sizes[i];\n\t\t\tconst next = current + size * range;\n\t\t\tpositions.push(\n\t\t\t\t...collect_track_positions(\n\t\t\t\t\tpanel.children[i],\n\t\t\t\t\torientation,\n\t\t\t\t\tcurrent,\n\t\t\t\t\tnext,\n\t\t\t\t\tphysics,\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tcurrent = next;\n\t\t}\n\t} else {\n\t\tfor (const child of panel.children) {\n\t\t\tpositions.push(\n\t\t\t\t...collect_track_positions(child, orientation, start, end, physics),\n\t\t\t);\n\t\t}\n\t}\n\n\treturn dedupe_positions(physics, positions);\n}\n\nfunction find_track_index(\n\tphysics: Physics,\n\tpositions: number[],\n\tvalue: number,\n): number {\n\tconst index = positions.findIndex(\n\t\t(pos) => Math.abs(pos - value) < physics.GRID_TRACK_COLLAPSE_TOLERANCE,\n\t);\n\n\treturn index === -1 ? 0 : index;\n}\n\nfunction build_cells(\n\tpanel: Layout,\n\tcolPositions: number[],\n\trowPositions: number[],\n\tcolStart: number,\n\tcolEnd: number,\n\trowStart: number,\n\trowEnd: number,\n\tphysics: Physics,\n): GridCell[] {\n\tif (panel.type === \"child-panel\") {\n\t\tconst selected = panel.selected ?? 0;\n\t\treturn [\n\t\t\t{\n\t\t\t\tchild: panel.child[selected],\n\t\t\t\tcolStart: find_track_index(physics, colPositions, colStart),\n\t\t\t\tcolEnd: find_track_index(physics, colPositions, colEnd),\n\t\t\t\trowStart: find_track_index(physics, rowPositions, rowStart),\n\t\t\t\trowEnd: find_track_index(physics, rowPositions, rowEnd),\n\t\t\t},\n\t\t];\n\t}\n\n\tconst { children, sizes, orientation } = panel;\n\tconst isHorizontal = orientation === \"horizontal\";\n\tlet current = isHorizontal ? colStart : rowStart;\n\tconst range = isHorizontal ? colEnd - colStart : rowEnd - rowStart;\n\tconst cells: GridCell[] = [];\n\tfor (let i = 0; i < children.length; i++) {\n\t\tconst next = current + sizes[i] * range;\n\t\tif (isHorizontal) {\n\t\t\tcells.push(\n\t\t\t\t...build_cells(\n\t\t\t\t\tchildren[i],\n\t\t\t\t\tcolPositions,\n\t\t\t\t\trowPositions,\n\t\t\t\t\tcurrent,\n\t\t\t\t\tnext,\n\t\t\t\t\trowStart,\n\t\t\t\t\trowEnd,\n\t\t\t\t\tphysics,\n\t\t\t\t),\n\t\t\t);\n\t\t} else {\n\t\t\tcells.push(\n\t\t\t\t...build_cells(\n\t\t\t\t\tchildren[i],\n\t\t\t\t\tcolPositions,\n\t\t\t\t\trowPositions,\n\t\t\t\t\tcolStart,\n\t\t\t\t\tcolEnd,\n\t\t\t\t\tcurrent,\n\t\t\t\t\tnext,\n\t\t\t\t\tphysics,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tcurrent = next;\n\t}\n\n\treturn cells;\n}\n\nconst host_template = (rowTemplate: string, colTemplate: string) =>\n\t`:host ::slotted(*){display:none}:host{display:grid;grid-template-rows:${rowTemplate};grid-template-columns:${colTemplate}}`;\n\nconst child_template = (\n\tphysics: Physics,\n\tslot: string,\n\trowPart: string,\n\tcolPart: string,\n) =>\n\t`:host ::slotted([${physics.CHILD_ATTRIBUTE_NAME}=\"${slot}\"]){display:flex;grid-column:${colPart};grid-row:${rowPart}}`;\n\n/**\n * Generates CSS Grid styles to render a layout tree.\n * Creates grid-template-rows, grid-template-columns, and positioning rules for\n * all child panels.\n *\n * @param layout - The layout tree to convert to CSS\n * @param round - If true, rounds percentages to whole numbers. Useful for\n * avoiding sub-pixel rendering issues. Defaults to false.\n * @returns CSS string containing :host and ::slotted rules implementing the\n * layout.\n *\n * @example\n * ```typescript\n * const layout = {\n * type: \"split-panel\",\n * orientation: \"horizontal\",\n * children: [\n * { type: \"child-panel\", child: \"sidebar\" },\n * { type: \"child-panel\", child: \"main\" }\n * ],\n * sizes: [0.25, 0.75]\n * };\n *\n * const css = create_css_grid_layout(layout);\n * // Returns CSS like:\n * // :host { display: grid; grid-template-columns: 25% 75%; ... }\n * // :host ::slotted([name=sidebar]) { grid-column: 1; grid-row: 1; }\n * // :host ::slotted([name=main]) { grid-column: 2; grid-row: 1; }\n * ```\n */\nexport function create_css_grid_layout(\n\tlayout: Layout,\n\toverlay?: [string, string],\n\tphysics: Physics = DEFAULT_PHYSICS,\n): string {\n\tif (layout.type === \"child-panel\") {\n\t\tconst selected = layout.selected ?? 0;\n\t\treturn [\n\t\t\thost_template(\"100%\", \"100%\"),\n\t\t\tchild_template(physics, layout.child[selected], \"1\", \"1\"),\n\t\t].join(\"\\n\");\n\t}\n\n\tconst createTemplate = (positions: number[]) => {\n\t\tconst sizes = positions\n\t\t\t.slice(0, -1)\n\t\t\t.map((pos, i) => positions[i + 1] - pos);\n\t\treturn sizes\n\t\t\t.map((s) => `${physics.SHOULD_ROUND ? Math.round(s * 100) : s * 100}fr`)\n\t\t\t.join(\" \");\n\t};\n\n\tconst colPositions = collect_track_positions(\n\t\tlayout,\n\t\t\"horizontal\",\n\t\t0,\n\t\t1,\n\t\tphysics,\n\t);\n\n\tconst colTemplate = createTemplate(colPositions);\n\tconst rowPositions = collect_track_positions(\n\t\tlayout,\n\t\t\"vertical\",\n\t\t0,\n\t\t1,\n\t\tphysics,\n\t);\n\n\tconst rowTemplate = createTemplate(rowPositions);\n\tconst formatGridLine = (start: number, end: number) =>\n\t\tend - start === 1 ? `${start + 1}` : `${start + 1} / ${end + 1}`;\n\n\tconst cells = build_cells(\n\t\tlayout,\n\t\tcolPositions,\n\t\trowPositions,\n\t\t0,\n\t\t1,\n\t\t0,\n\t\t1,\n\t\tphysics,\n\t);\n\n\tconst css = [host_template(rowTemplate, colTemplate)];\n\tfor (const cell of cells) {\n\t\tconst colPart = formatGridLine(cell.colStart, cell.colEnd);\n\t\tconst rowPart = formatGridLine(cell.rowStart, cell.rowEnd);\n\t\tcss.push(child_template(physics, cell.child, rowPart, colPart));\n\t\tif (cell.child === overlay?.[1]) {\n\t\t\tcss.push(child_template(physics, overlay[0], rowPart, colPart));\n\t\t\tcss.push(\n\t\t\t\t`:host ::slotted([${physics.CHILD_ATTRIBUTE_NAME}=${overlay[0]}]){z-index:1}`,\n\t\t\t);\n\t\t}\n\t}\n\n\treturn css.join(\"\\n\");\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { LayoutPath, LayoutDivider, Layout, ViewWindow } from \"./types.ts\";\n\nconst VIEW_WINDOW = {\n\trow_start: 0,\n\trow_end: 1,\n\tcol_start: 0,\n\tcol_end: 1,\n};\n\n/**\n * Determines which panel or divider is located at a given position in the\n * layout.\n *\n * @param column - Horizontal position as a fraction (0-1) of the container width\n * @param row - Vertical position as a fraction (0-1) of the container height\n * @param layout - The layout tree to search\n * @param check_dividers - Whether `LayoutDivider` intersection should be\n * checked, which you may not want for e.g. `drop` actions.\n * @returns The panel path if over a panel, a divider if over a resizable\n * boundary, or null if outside all panels\n */\nexport function calculate_intersection(\n\tcolumn: number,\n\trow: number,\n\tlayout: Layout,\n\tcheck_dividers?: null,\n): LayoutPath | null;\n\nexport function calculate_intersection(\n\tcolumn: number,\n\trow: number,\n\tlayout: Layout,\n\tcheck_dividers?: { rect: DOMRect; size: number },\n): LayoutPath | null | LayoutDivider;\n\nexport function calculate_intersection(\n\tcolumn: number,\n\trow: number,\n\tlayout: Layout,\n\tcheck_dividers?: { rect: DOMRect; size: number } | null,\n): LayoutPath | null | LayoutDivider;\n\nexport function calculate_intersection(\n\tcolumn: number,\n\trow: number,\n\tlayout: Layout,\n\tcheck_dividers: { rect: DOMRect; size: number } | null = null,\n): LayoutPath | null | LayoutDivider {\n\treturn calculate_intersection_recursive(column, row, layout, check_dividers);\n}\n\nfunction calculate_intersection_recursive(\n\tcolumn: number,\n\trow: number,\n\tpanel: Layout,\n\tcheck_dividers: { rect: DOMRect; size: number } | null,\n\tparent_orientation: \"horizontal\" | \"vertical\" | null = null,\n\tview_window: ViewWindow = structuredClone(VIEW_WINDOW),\n\tpath: number[] = [],\n): LayoutPath | null | LayoutDivider {\n\tif (column < 0 || row < 0 || column > 1 || row > 1) {\n\t\treturn null;\n\t}\n\n\t// Base case: if this is a child panel, return its name\n\tif (panel.type === \"child-panel\") {\n\t\tconst selected = panel.selected ?? 0;\n\t\tconst col_width = view_window.col_end - view_window.col_start;\n\t\tconst row_height = view_window.row_end - view_window.row_start;\n\t\treturn {\n\t\t\ttype: \"layout-path\",\n\t\t\tlayout: undefined,\n\t\t\tslot: panel.child[selected],\n\t\t\tpath,\n\t\t\tview_window,\n\t\t\tis_edge: false,\n\t\t\tcolumn,\n\t\t\trow,\n\t\t\tcolumn_offset: (column - view_window.col_start) / col_width,\n\t\t\trow_offset: (row - view_window.row_start) / row_height,\n\t\t\torientation: parent_orientation || \"horizontal\",\n\t\t};\n\t}\n\n\t// For split panels, determine which child was hit\n\tconst is_vertical = panel.orientation === \"vertical\";\n\tconst position = is_vertical ? row : column;\n\tconst start_key = is_vertical ? \"row_start\" : \"col_start\";\n\tconst end_key = is_vertical ? \"row_end\" : \"col_end\";\n\tconst rect_dim = is_vertical\n\t\t? check_dividers?.rect?.height\n\t\t: check_dividers?.rect?.width;\n\n\tlet current_pos = view_window[start_key];\n\tconst total_size = view_window[end_key] - view_window[start_key];\n\tfor (let i = 0; i < panel.children.length; i++) {\n\t\tconst next_pos = current_pos + total_size * panel.sizes[i];\n\n\t\t// Check if position is on a divider\n\t\tif (check_dividers && rect_dim) {\n\t\t\tconst divider_threshold = check_dividers.size / rect_dim;\n\t\t\tif (Math.abs(position - next_pos) < divider_threshold) {\n\t\t\t\treturn {\n\t\t\t\t\tpath: [...path, i],\n\t\t\t\t\ttype: panel.orientation,\n\t\t\t\t\tview_window: {\n\t\t\t\t\t\t...view_window,\n\t\t\t\t\t\t[start_key]: current_pos,\n\t\t\t\t\t\t[end_key]: next_pos,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\t// Check if position falls within this child's bounds\n\t\tif (position >= current_pos && position < next_pos) {\n\t\t\treturn calculate_intersection_recursive(\n\t\t\t\tcolumn,\n\t\t\t\trow,\n\t\t\t\tpanel.children[i],\n\t\t\t\tcheck_dividers,\n\t\t\t\tpanel.orientation,\n\t\t\t\t{\n\t\t\t\t\t...view_window,\n\t\t\t\t\t[start_key]: current_pos,\n\t\t\t\t\t[end_key]: next_pos,\n\t\t\t\t},\n\t\t\t\t[...path, i],\n\t\t\t);\n\t\t}\n\n\t\tcurrent_pos = next_pos;\n\t}\n\n\t// If we get here, the hit was outside all children (possibly in a gap or\n\t// boundary).\n\treturn null;\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { Layout, TabLayout } from \"./types.ts\";\nimport { EMPTY_PANEL } from \"./types.ts\";\n\n/**\n * Removes a child panel from the layout tree by its name.\n *\n * Redistributes the removed panel's space proportionally among remaining\n * siblings. Automatically collapses split panels when only one child remains.\n *\n * @param panel - The root layout tree to remove from.\n * @param child - Name of the child panel to remove.\n * @returns A new layout tree with the child removed (original is not mutated).\n * Returns `EMPTY_PANEL` if the last panel is removed.\n */\nexport function remove_child(panel: Layout, child: string): Layout {\n\t// If this is a child panel, handle tab removal\n\tif (panel.type === \"child-panel\") {\n\t\tif (panel.child.includes(child)) {\n\t\t\tconst newChild = panel.child.filter((c) => c !== child);\n\t\t\tif (newChild.length === 0) {\n\t\t\t\treturn structuredClone(EMPTY_PANEL);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\ttype: \"child-panel\",\n\t\t\t\tchild: newChild,\n\t\t\t};\n\t\t}\n\n\t\treturn structuredClone(panel);\n\t}\n\n\t// Clone the panel structure\n\tconst result = structuredClone(panel);\n\n\t// Try to remove the child from this split panel's children\n\tconst index = result.children.findIndex((p) => {\n\t\tif (p.type === \"child-panel\") {\n\t\t\treturn p.child.includes(child);\n\t\t}\n\n\t\treturn false;\n\t});\n\n\tif (index !== -1) {\n\t\tconst tab_layout = result.children[index] as TabLayout;\n\t\tif (tab_layout.child.length === 1) {\n\t\t\t// Found the child at this level - remove it\n\t\t\tconst newChildren = result.children.filter((_, i) => i !== index);\n\t\t\tconst newSizes = remove_and_redistribute(result.sizes, index);\n\n\t\t\t// If only one child remains, collapse the split panel\n\t\t\tif (newChildren.length === 1) {\n\t\t\t\treturn newChildren[0];\n\t\t\t}\n\n\t\t\tresult.children = newChildren;\n\t\t\tresult.sizes = newSizes;\n\t\t} else {\n\t\t\ttab_layout.child.splice(tab_layout.child.indexOf(child), 1);\n\t\t\tif (\n\t\t\t\ttab_layout.selected &&\n\t\t\t\ttab_layout.selected >= tab_layout.child.length\n\t\t\t) {\n\t\t\t\ttab_layout.selected--;\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t// Child not found at this level - recursively search children\n\tlet modified = false;\n\tconst newChildren = result.children.map((p) => {\n\t\tif (p.type === \"split-panel\") {\n\t\t\tconst updated = remove_child(p, child);\n\t\t\tif (updated !== p) {\n\t\t\t\tmodified = true;\n\t\t\t}\n\n\t\t\treturn updated;\n\t\t}\n\n\t\treturn p;\n\t});\n\n\tif (modified) {\n\t\tresult.children = newChildren;\n\t}\n\n\treturn result;\n}\n\nfunction remove_and_redistribute(arr: number[], index: number): number[] {\n\tconst result = [];\n\n\t// Get the size of the element being removed\n\tconst removed_size = arr[index];\n\n\t// Calculate the total of remaining elements\n\tlet remaining_total = 0;\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tif (i !== index) {\n\t\t\tremaining_total += arr[i];\n\t\t}\n\t}\n\n\t// Distribute the removed size proportionally to remaining elements\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tif (i !== index) {\n\t\t\tconst proportion = arr[i] / remaining_total;\n\t\t\tresult.push(arr[i] + removed_size * proportion);\n\t\t}\n\t}\n\n\treturn result;\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { Layout } from \"./types.ts\";\n\n/**\n * Inserts a new child panel into the layout tree at a specified location.\n * Creates a split panel if necessary and redistributes sizes equally among all\n * children.\n *\n * @param panel - The root layout tree to insert into\n * @param child - Unique identifier for the new child panel\n * @param path - Array of indices defining where to insert. Empty array inserts\n * at root level.\n * @param orientation - Orientation for newly created split panels. Defaults to\n * \"horizontal\".\n * @param is_edge - If true, create the split at the parent level.\n * @returns A new layout tree with the child inserted (original is not mutated).\n */\nexport function insert_child(\n\tpanel: Layout,\n\tchild: string,\n\tpath: number[],\n\torientation?: \"horizontal\" | \"vertical\",\n): Layout {\n\tconst createChildPanel = (childId: string): Layout => ({\n\t\ttype: \"child-panel\",\n\t\tchild: [childId],\n\t});\n\n\tif (path.length === 0) {\n\t\t// Insert at root level\n\t\tif (panel.type === \"child-panel\") {\n\t\t\t// Add to existing child-panel as a tab\n\t\t\treturn {\n\t\t\t\ttype: \"child-panel\",\n\t\t\t\tchild: [child, ...panel.child],\n\t\t\t};\n\t\t} else if (orientation) {\n\t\t\t// When inserting at edge of root, wrap the entire panel in a new split\n\t\t\treturn {\n\t\t\t\ttype: \"split-panel\",\n\t\t\t\torientation: orientation,\n\t\t\t\tchildren: [createChildPanel(child), panel],\n\t\t\t\tsizes: [0.5, 0.5],\n\t\t\t};\n\t\t} else {\n\t\t\t// Append to existing split-panel\n\t\t\tconst newChildren = [...panel.children, createChildPanel(child)];\n\t\t\tconst newSizes = [...panel.sizes, 1 / (newChildren.length - 1)];\n\t\t\treturn {\n\t\t\t\t...panel,\n\t\t\t\tchildren: newChildren,\n\t\t\t\tsizes: redistribute(newSizes),\n\t\t\t};\n\t\t}\n\t}\n\n\t// Navigate down the path\n\tconst [index, ...restPath] = path;\n\n\t// Special case: when orientation is provided and restPath is empty, handle edge insertion\n\tif (orientation && restPath.length === 0) {\n\t\t// If panel is a split-panel with the same orientation, insert into its children\n\t\tif (panel.type === \"split-panel\" && panel.orientation === orientation) {\n\t\t\tconst newChildren = [...panel.children];\n\t\t\tnewChildren.splice(index, 0, createChildPanel(child));\n\t\t\tconst newSizes = [...panel.sizes];\n\t\t\tnewSizes.splice(index, 0, 1 / (newChildren.length - 1));\n\t\t\treturn {\n\t\t\t\t...panel,\n\t\t\t\tchildren: newChildren,\n\t\t\t\tsizes: redistribute(newSizes),\n\t\t\t};\n\t\t}\n\n\t\t// Otherwise, wrap the entire panel in a new split at the edge\n\t\tconst children =\n\t\t\tindex === 0\n\t\t\t\t? [createChildPanel(child), panel]\n\t\t\t\t: [panel, createChildPanel(child)];\n\n\t\treturn {\n\t\t\ttype: \"split-panel\",\n\t\t\torientation: orientation,\n\t\t\tchildren,\n\t\t\tsizes: [0.5, 0.5],\n\t\t};\n\t}\n\n\tif (panel.type === \"child-panel\") {\n\t\t// Stack into child array only when ALL of these conditions are met:\n\t\t// 1. Path has exactly one element (restPath is empty)\n\t\t// 2. Orientation was NOT explicitly provided (orientation is undefined)\n\t\t// 3. Index is within the valid stacking range [0, child.length]\n\t\tif (\n\t\t\trestPath.length === 0 &&\n\t\t\torientation === undefined &&\n\t\t\tindex >= 0 &&\n\t\t\tindex <= panel.child.length\n\t\t) {\n\t\t\tconst newChild = [...panel.child];\n\t\t\tnewChild.splice(index, 0, child);\n\t\t\treturn {\n\t\t\t\t...panel,\n\t\t\t\tchild: newChild,\n\t\t\t};\n\t\t}\n\n\t\t// Otherwise, wrap in a split panel and recurse\n\t\tconst newPanel: Layout = {\n\t\t\ttype: \"split-panel\",\n\t\t\torientation: orientation || \"horizontal\",\n\t\t\tchildren: [panel],\n\t\t\tsizes: [1],\n\t\t};\n\n\t\treturn insert_child(newPanel, child, path, orientation);\n\t}\n\n\tif (restPath.length === 0 || index === panel.children.length) {\n\t\tif (orientation && panel.children[index]) {\n\t\t\t// When inserting at an edge, create a split panel with the new child and existing child\n\t\t\tconst newSplitPanel: Layout = {\n\t\t\t\ttype: \"split-panel\",\n\t\t\t\torientation: orientation,\n\t\t\t\tchildren: [createChildPanel(child), panel.children[index]],\n\t\t\t\tsizes: [0.5, 0.5],\n\t\t\t};\n\n\t\t\tconst newChildren = [...panel.children];\n\t\t\tnewChildren[index] = newSplitPanel;\n\t\t\treturn {\n\t\t\t\t...panel,\n\t\t\t\tchildren: newChildren,\n\t\t\t\tsizes: redistribute(panel.sizes),\n\t\t\t};\n\t\t}\n\n\t\t// Insert at this level at the specified index\n\t\tconst newChildren = [...panel.children];\n\t\tnewChildren.splice(index, 0, createChildPanel(child));\n\t\tconst newSizes = [...panel.sizes];\n\t\tnewSizes.splice(index, 0, 1 / (newChildren.length - 1));\n\t\treturn {\n\t\t\t...panel,\n\t\t\tchildren: newChildren,\n\t\t\tsizes: redistribute(newSizes),\n\t\t};\n\t}\n\n\tconst targetChild = panel.children[index];\n\n\t// Determine the orientation to pass down when navigating into a child-panel\n\tconst childOrientation =\n\t\ttargetChild.type === \"child-panel\" &&\n\t\trestPath.length > 0 &&\n\t\torientation !== undefined\n\t\t\t? panel.orientation === \"horizontal\"\n\t\t\t\t? \"vertical\"\n\t\t\t\t: \"horizontal\"\n\t\t\t: orientation;\n\n\tconst updatedChild = insert_child(\n\t\ttargetChild,\n\t\tchild,\n\t\trestPath,\n\t\tchildOrientation,\n\t);\n\n\tconst newChildren = [...panel.children];\n\tnewChildren[index] = updatedChild;\n\treturn {\n\t\t...panel,\n\t\tchildren: newChildren,\n\t};\n}\n\nfunction redistribute(arr: number[]): number[] {\n\tconst total = arr.reduce((sum, val) => sum + val, 0);\n\treturn arr.map((val) => val / total);\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport { DEFAULT_PHYSICS } from \"./constants.ts\";\nimport type { Layout } from \"./types.ts\";\n\n/**\n * Adjusts panel sizes during a drag operation on a divider.\n *\n * The `delta` is distributed proportionally among affected panels, maintaining\n * the sum:\n *\n * - Panels before and including the path index shrink by delta.\n * - Panels after the path index grow by delta.\n *\n * @param panel - The root layout tree to modify.\n * @param path - Path to the divider being dragged (identifies which split panel\n * to resize).\n * @param delta - Amount to resize, as a fraction (0-1). Positive values grow\n * panels before the divider, negative values shrink them.\n * @returns A new layout tree with updated sizes (original is not mutated).\n * ```\n */\nexport function redistribute_panel_sizes(\n\tpanel: Layout,\n\tpath: number[],\n\tdelta: number,\n\tphysics = DEFAULT_PHYSICS,\n): Layout {\n\t// Clone the entire panel structure\n\tconst result = structuredClone(panel);\n\n\t// Find the orientation of the insertion panel,\n\t// and scale the delta on the respective axis if aligned.\n\tlet current: Layout = result;\n\tconst deltas = { horizontal: delta, vertical: delta };\n\tfor (let i = 0; i < path.length - 1; i++) {\n\t\tif (current.type === \"split-panel\") {\n\t\t\tdeltas[current.orientation] /= current.sizes[path[i]];\n\t\t\tcurrent = current.children[path[i]];\n\t\t}\n\t}\n\n\t// Apply the redistribution at the final path index\n\tif (current.type === \"split-panel\") {\n\t\tconst delta = deltas[current.orientation];\n\t\tconst index = path[path.length - 1];\n\n\t\t// It would be fun to remove this condition.\n\t\tif (index < current.sizes.length - 1) {\n\t\t\tcurrent.sizes = add_and_redistribute(\n\t\t\t\tphysics,\n\t\t\t\tcurrent.sizes,\n\t\t\t\tindex,\n\t\t\t\tdelta,\n\t\t\t);\n\t\t}\n\t}\n\n\treturn result;\n}\n\nfunction add_and_redistribute(\n\tphysics: typeof DEFAULT_PHYSICS,\n\tarr: number[],\n\tindex: number,\n\tdelta: number,\n): number[] {\n\tconst result = [...arr];\n\tlet before_total = 0;\n\tfor (let i = 0; i <= index; i++) {\n\t\tbefore_total += arr[i];\n\t}\n\n\tlet after_total = 0;\n\tfor (let i = index + 1; i < arr.length; i++) {\n\t\tafter_total += arr[i];\n\t}\n\n\t// Clamp `delta` to prevent redistributing either side to 0.\n\tdelta =\n\t\tMath.sign(delta) *\n\t\tMath.min(\n\t\t\tMath.abs(delta),\n\t\t\t(1 - physics.MINIMUM_REDISTRIBUTION_SIZE_THRESHOLD) *\n\t\t\t\t(delta > 0 ? before_total : after_total),\n\t\t);\n\n\t// Redistribute elements\n\tfor (let i = 0; i <= index; i++) {\n\t\tconst proportion = arr[i] / before_total;\n\t\tresult[i] = arr[i] - delta * proportion;\n\t}\n\n\tfor (let i = index + 1; i < arr.length; i++) {\n\t\tconst proportion = arr[i] / after_total;\n\t\tresult[i] = arr[i] + delta * proportion;\n\t}\n\n\treturn result;\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport { DEFAULT_PHYSICS } from \"./constants\";\nimport type { LayoutPath } from \"./types\";\n\nexport function updateOverlaySheet(\n\tslot: string,\n\tbox: DOMRect,\n\tstyle: CSSStyleDeclaration,\n\tdrag_target: LayoutPath<undefined> | null,\n\tphysics = DEFAULT_PHYSICS,\n) {\n\tif (!drag_target) {\n\t\treturn `:host ::slotted([${physics.CHILD_ATTRIBUTE_NAME}=\"${slot}\"]){display:none;}`;\n\t}\n\n\tconst {\n\t\tview_window: { row_start, row_end, col_start, col_end },\n\t} = drag_target;\n\n\tconst box_height =\n\t\tbox.height - parseFloat(style.paddingTop) - parseFloat(style.paddingBottom);\n\n\tconst box_width =\n\t\tbox.width - parseFloat(style.paddingLeft) - parseFloat(style.paddingRight);\n\n\tconst top = row_start * box_height + parseFloat(style.paddingTop);\n\tconst left = col_start * box_width + parseFloat(style.paddingLeft);\n\tconst height = (row_end - row_start) * box_height;\n\tconst width = (col_end - col_start) * box_width;\n\tconst css = `display:flex;position:absolute!important;z-index:1;top:${top}px;left:${left}px;height:${height}px;width:${width}px;`;\n\treturn `::slotted([${physics.CHILD_ATTRIBUTE_NAME}=\"${slot}\"]){${css}}`;\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport { DEFAULT_PHYSICS, type Physics } from \"./constants\";\nimport { insert_child } from \"./insert_child\";\nimport type { Layout, LayoutPath, Orientation, ViewWindow } from \"./types\";\n\n/**\n * Calculates an insertion point (which may involve splitting a single\n * `\"child-panel\"` into a new `\"split-panel\"`), based on the cursor position.\n * *\n * @param col - The cursor column.\n * @param row - The cursor row.\n * @param panel - The `Layout` to insert into.\n * @param slot - The slot identifier where the insert should occur\n * @param drop_target - The `LayoutPath` (from `calculateIntersect`) of the\n * panel to either insert next to, or split by.\n * @returns A new `LayoutPath` reflecting the updated (maybe) `\"split-panel\"`,\n * which is enough to draw the overlay.\n */\nexport function calculate_edge(\n\tcol: number,\n\trow: number,\n\tpanel: Layout,\n\tslot: string,\n\tdrop_target: LayoutPath,\n\tbox?: DOMRect,\n\tphysics: Physics = DEFAULT_PHYSICS,\n): LayoutPath {\n\t// Check root edges first\n\tif (col < physics.SPLIT_ROOT_EDGE_TOLERANCE) {\n\t\treturn insert_root_edge(panel, slot, drop_target, [0], true, \"horizontal\");\n\t}\n\n\tif (col > 1 - physics.SPLIT_ROOT_EDGE_TOLERANCE) {\n\t\treturn insert_root_edge(\n\t\t\tpanel,\n\t\t\tslot,\n\t\t\tdrop_target,\n\t\t\tdrop_target.path.length > 0 ? drop_target.path : [1],\n\t\t\tfalse,\n\t\t\t\"horizontal\",\n\t\t);\n\t}\n\n\tif (row < physics.SPLIT_ROOT_EDGE_TOLERANCE) {\n\t\treturn insert_root_edge(panel, slot, drop_target, [0], true, \"vertical\");\n\t}\n\n\tif (row > 1 - physics.SPLIT_ROOT_EDGE_TOLERANCE) {\n\t\treturn insert_root_edge(\n\t\t\tpanel,\n\t\t\tslot,\n\t\t\tdrop_target,\n\t\t\tdrop_target.path.length > 0 ? drop_target.path : [1],\n\t\t\tfalse,\n\t\t\t\"vertical\",\n\t\t);\n\t}\n\n\t// Check panel edges\n\tconst is_column_edge =\n\t\tdrop_target.column_offset < physics.SPLIT_EDGE_TOLERANCE ||\n\t\tdrop_target.column_offset > 1 - physics.SPLIT_EDGE_TOLERANCE;\n\n\tconst is_row_edge =\n\t\tdrop_target.row_offset < physics.SPLIT_EDGE_TOLERANCE ||\n\t\tdrop_target.row_offset > 1 - physics.SPLIT_EDGE_TOLERANCE;\n\n\t// If both edges triggered, choose closer axis\n\tif (is_column_edge && is_row_edge) {\n\t\tconst col_distance = Math.abs(drop_target.column_offset - 0.5);\n\t\tconst row_distance = Math.abs(drop_target.row_offset - 0.5);\n\t\tconst col_scale =\n\t\t\t(box?.width || 1) *\n\t\t\t(drop_target.view_window.col_end - drop_target.view_window.col_start);\n\n\t\tconst row_scale =\n\t\t\t(box?.height || 1) *\n\t\t\t(drop_target.view_window.row_end - drop_target.view_window.row_start);\n\n\t\tconst use_column = col_distance * col_scale > row_distance * row_scale;\n\n\t\treturn insert_axis(\n\t\t\tpanel,\n\t\t\tslot,\n\t\t\tdrop_target,\n\t\t\tuse_column\n\t\t\t\t? drop_target.column_offset < physics.SPLIT_EDGE_TOLERANCE\n\t\t\t\t: drop_target.row_offset < physics.SPLIT_EDGE_TOLERANCE,\n\t\t\tuse_column ? \"horizontal\" : \"vertical\",\n\t\t);\n\t}\n\n\tif (is_column_edge) {\n\t\treturn insert_axis(\n\t\t\tpanel,\n\t\t\tslot,\n\t\t\tdrop_target,\n\t\t\tdrop_target.column_offset < physics.SPLIT_EDGE_TOLERANCE,\n\t\t\t\"horizontal\",\n\t\t);\n\t}\n\n\tif (is_row_edge) {\n\t\treturn insert_axis(\n\t\t\tpanel,\n\t\t\tslot,\n\t\t\tdrop_target,\n\t\t\tdrop_target.row_offset < physics.SPLIT_EDGE_TOLERANCE,\n\t\t\t\"vertical\",\n\t\t);\n\t}\n\n\t// Not at an edge - insert as a tab\n\treturn {\n\t\t...drop_target,\n\t\tpath: [...drop_target.path, 0],\n\t};\n}\n\nfunction insert_root_edge(\n\tpanel: Layout,\n\tslot: string,\n\tdrop_target: LayoutPath,\n\tpath: number[],\n\tis_before: boolean,\n\torientation: Orientation,\n): LayoutPath {\n\treturn insert_axis(\n\t\tpanel,\n\t\tslot,\n\t\t{ ...drop_target, path, orientation },\n\t\tis_before,\n\t\torientation,\n\t);\n}\n\nfunction insert_axis(\n\tpanel: Layout,\n\tslot: string,\n\tdrop_target: LayoutPath,\n\tis_before: boolean,\n\taxis_orientation: Orientation,\n): LayoutPath {\n\tlet result_path: number[];\n\n\tif (drop_target.orientation === axis_orientation) {\n\t\t// Same orientation - insert into existing split\n\t\tif (drop_target.path.length === 0) {\n\t\t\tresult_path = [is_before ? 0 : 1];\n\t\t} else {\n\t\t\tconst last_index = drop_target.path[drop_target.path.length - 1];\n\t\t\tresult_path = [\n\t\t\t\t...drop_target.path.slice(0, -1),\n\t\t\t\tis_before ? last_index : last_index + 1,\n\t\t\t];\n\t\t}\n\t} else {\n\t\t// Different orientation - split the child panel\n\t\tresult_path = [...drop_target.path, is_before ? 0 : 1];\n\t}\n\n\tconst new_panel = insert_child(panel, slot, result_path, axis_orientation);\n\tconst view_window = calculate_view_window(new_panel, result_path);\n\treturn {\n\t\t...drop_target,\n\t\tpath: result_path,\n\t\tslot: drop_target.slot,\n\t\tis_edge: true,\n\t\torientation: axis_orientation,\n\t\tview_window,\n\t};\n}\n\nfunction calculate_view_window(panel: Layout, path: number[]): ViewWindow {\n\tlet view_window: ViewWindow = {\n\t\trow_start: 0,\n\t\trow_end: 1,\n\t\tcol_start: 0,\n\t\tcol_end: 1,\n\t};\n\n\tlet current_panel = panel;\n\tfor (const step of path) {\n\t\tif (current_panel.type === \"child-panel\") {\n\t\t\tbreak;\n\t\t}\n\n\t\tconst index = Math.min(step, current_panel.children.length - 1);\n\t\tconst is_vertical = current_panel.orientation === \"vertical\";\n\t\tconst start_key = is_vertical ? \"row_start\" : \"col_start\";\n\t\tconst end_key = is_vertical ? \"row_end\" : \"col_end\";\n\t\tconst total_size = view_window[end_key] - view_window[start_key];\n\t\tconst offset = current_panel.sizes\n\t\t\t.slice(0, index)\n\t\t\t.reduce((sum, size) => sum + size * total_size, view_window[start_key]);\n\n\t\tview_window = {\n\t\t\t...view_window,\n\t\t\t[start_key]: offset,\n\t\t\t[end_key]: offset + total_size * current_panel.sizes[index],\n\t\t};\n\n\t\tcurrent_panel = current_panel.children[index];\n\t}\n\n\treturn view_window;\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { Layout } from \"./types.ts\";\n\n/**\n * Flattens the layout tree by merging parent and child split panels that have\n * the same orientation and type.\n *\n * When a split panel contains a child split panel with the same orientation,\n * they are merged into a single split panel. The sizes array is scaled\n * correctly to maintain proportions.\n *\n * @param layout - The layout tree to flatten\n * @returns A new flattened layout tree (original is not mutated).\n */\nexport function flatten(layout: Layout): Layout {\n\tif (layout.type === \"child-panel\") {\n\t\tlayout.selected = layout.selected || 0;\n\t\treturn layout;\n\t}\n\n\tconst flattenedChildren: Layout[] = [];\n\tconst flattenedSizes: number[] = [];\n\tfor (let i = 0; i < layout.children.length; i++) {\n\t\tconst child = layout.children[i];\n\t\tconst childSize = layout.sizes[i];\n\t\tconst flattenedChild = flatten(child);\n\n\t\tif (\n\t\t\tflattenedChild.type === \"split-panel\" &&\n\t\t\tflattenedChild.orientation === layout.orientation\n\t\t) {\n\t\t\tfor (let j = 0; j < flattenedChild.children.length; j++) {\n\t\t\t\tflattenedChildren.push(flattenedChild.children[j]);\n\t\t\t\tflattenedSizes.push(flattenedChild.sizes[j] * childSize);\n\t\t\t}\n\t\t} else {\n\t\t\tflattenedChildren.push(flattenedChild);\n\t\t\tflattenedSizes.push(childSize);\n\t\t}\n\t}\n\n\tif (flattenedChildren.length === 1) {\n\t\treturn flattenedChildren[0];\n\t}\n\n\treturn {\n\t\ttype: \"split-panel\",\n\t\torientation: layout.orientation,\n\t\tchildren: flattenedChildren,\n\t\tsizes: flattenedSizes,\n\t};\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\n/**\n * This module defines the `<regular-layout>` custom element for browser\n * environments.\n *\n * @packageDocumentation\n */\n\nimport { EMPTY_PANEL } from \"./layout/types.ts\";\nimport { create_css_grid_layout } from \"./layout/generate_grid.ts\";\nimport type {\n\tLayoutPath,\n\tLayout,\n\tLayoutDivider,\n\tTabLayout,\n\tOverlayMode,\n\tOrientation,\n} from \"./layout/types.ts\";\nimport { calculate_intersection } from \"./layout/calculate_intersect.ts\";\nimport { remove_child } from \"./layout/remove_child.ts\";\nimport { insert_child } from \"./layout/insert_child.ts\";\nimport { redistribute_panel_sizes } from \"./layout/redistribute_panel_sizes.ts\";\nimport { updateOverlaySheet } from \"./layout/generate_overlay.ts\";\nimport { calculate_edge } from \"./layout/calculate_edge.ts\";\nimport { flatten } from \"./layout/flatten.ts\";\nimport {\n\tDEFAULT_PHYSICS,\n\ttype PhysicsUpdate,\n\ttype Physics,\n} from \"./layout/constants.ts\";\n\n/**\n * A Web Component that provides a resizable panel layout system.\n * Panels are arranged using CSS Grid and can be resized by dragging dividers.\n *\n * The component uses Shadow DOM and CSS Grid to manage layout.\n *\n * @example\n * ```html\n * <regular-layout>\n * <div name=\"sidebar\">Sidebar content</div>\n * <div name=\"main\">Main content</div>\n * </regular-layout>\n * ```\n *\n * @example\n * ```typescript\n * const layout = document.querySelector('regular-layout');\n *\n * // Insert panels into the grid layout\n * layout.insertPanel('main');\n * layout.insertPanel('sidebar');\n *\n * // Remove a panel (DOM child is still connected, but not slotted)\n * layout.removePanel('sidebar');\n *\n * // Save current layout\n * const state = layout.save();\n *\n * // Restore layout later\n * layout.restore(state);\n * ```\n *\n */\nexport class RegularLayout extends HTMLElement {\n\tprivate _shadowRoot: ShadowRoot;\n\tprivate _panel: Layout;\n\tprivate _stylesheet: CSSStyleSheet;\n\tprivate _cursor_stylesheet: CSSStyleSheet;\n\tprivate _drag_target?: [LayoutDivider, number, number];\n\tprivate _cursor_override: boolean;\n\tprivate _dimensions?: { box: DOMRect; style: CSSStyleDeclaration };\n\tprivate _physics: Physics;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis._physics = DEFAULT_PHYSICS;\n\t\tthis._panel = structuredClone(EMPTY_PANEL);\n\n\t\t// Why does this implementation use a `<slot>` at all? We must use\n\t\t// `<slot>` and the Shadow DOM to scope the grid CSS rules to each\n\t\t// instance of `<regular-layout>` (without e.g. giving them unique\n\t\t// `\"id\"` and injecting into `document,head`), and we can only select\n\t\t// `::slotted` light DOM children from `adoptedStyleSheets` on the\n\t\t// `ShadowRoot`.\n\n\t\t// In addition, this model uses a single un-named `<slot>` to host all\n\t\t// light-DOM children, and the child's `\"name\"` attribute to identify\n\t\t// its position in the `Layout`. Alternatively, using named\n\t\tthis._shadowRoot = this.attachShadow({ mode: \"open\" });\n\t\tthis._shadowRoot.innerHTML = `<slot></slot>`;\n\t\tthis._stylesheet = new CSSStyleSheet();\n\t\tthis._cursor_stylesheet = new CSSStyleSheet();\n\t\tthis._cursor_override = false;\n\t\tthis._shadowRoot.adoptedStyleSheets = [\n\t\t\tthis._stylesheet,\n\t\t\tthis._cursor_stylesheet,\n\t\t];\n\t}\n\n\tconnectedCallback() {\n\t\tthis.addEventListener(\"pointerdown\", this.onPointerDown);\n\t\tthis.addEventListener(\"pointerup\", this.onPointerUp);\n\t\tthis.addEventListener(\"pointermove\", this.onPointerMove);\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.removeEventListener(\"pointerdown\", this.onPointerDown);\n\t\tthis.removeEventListener(\"pointerup\", this.onPointerUp);\n\t\tthis.removeEventListener(\"pointermove\", this.onPointerMove);\n\t}\n\n\t/**\n\t * Determines which panel is at a given screen coordinate.\n\t *\n\t * @param column - X coordinate in screen pixels.\n\t * @param row - Y coordinate in screen pixels.\n\t * @returns Panel information if a panel is at that position, null otherwise.\n\t */\n\tcalculateIntersect = (\n\t\tx: number,\n\t\ty: number,\n\t\tcheck_dividers: boolean = false,\n\t): LayoutPath<Layout> | null => {\n\t\tconst [col, row, rect] = this.relativeCoordinates(x, y, false);\n\t\tconst panel = calculate_intersection(\n\t\t\tcol,\n\t\t\trow,\n\t\t\tthis._panel,\n\t\t\tcheck_dividers ? { rect, size: this._physics.GRID_DIVIDER_SIZE } : null,\n\t\t);\n\n\t\tif (panel?.type === \"layout-path\") {\n\t\t\treturn { ...panel, layout: this.save() };\n\t\t}\n\n\t\treturn null;\n\t};\n\n\t/**\n\t * Sets the visual overlay state during drag-and-drop operations.\n\t * Displays a preview of where a panel would be placed at the given coordinates.\n\t *\n\t * @param x - X coordinate in screen pixels.\n\t * @param y - Y coordinate in screen pixels.\n\t * @param dragTarget - A `LayoutPath` (presumably from `calculateIntersect`)\n\t * which points to the drag element in the current layout.\n\t * @param className - The CSS class name to use for the overlay panel\n\t * (defaults to \"overlay\").\n\t * @param mode - Overlay rendering mode: \"grid\" uses CSS grid to position\n\t * the target, \"absolute\" positions the panel absolutely. Defaults to\n\t * \"absolute\".\n\t */\n\tsetOverlayState = (\n\t\tx: number,\n\t\ty: number,\n\t\t{ slot }: LayoutPath<unknown>,\n\t\tclassName: string = this._physics.OVERLAY_CLASSNAME,\n\t\tmode: OverlayMode = this._physics.OVERLAY_DEFAULT,\n\t) => {\n\t\tconst panel = remove_child(this._panel, slot);\n\t\tArray.from(this.children)\n\t\t\t.find((x) => x.getAttribute(this._physics.CHILD_ATTRIBUTE_NAME) === slot)\n\t\t\t?.classList.add(className);\n\n\t\tconst [col, row, box, style] = this.relativeCoordinates(x, y, false);\n\t\tlet drop_target = calculate_intersection(col, row, panel);\n\t\tif (drop_target) {\n\t\t\tdrop_target = calculate_edge(\n\t\t\t\tcol,\n\t\t\t\trow,\n\t\t\t\tpanel,\n\t\t\t\tslot,\n\t\t\t\tdrop_target,\n\t\t\t\tbox,\n\t\t\t\tthis._physics,\n\t\t\t);\n\t\t}\n\n\t\tif (mode === \"grid\" && drop_target) {\n\t\t\tconst path: [string, string] = [slot, drop_target?.slot];\n\t\t\tconst css = create_css_grid_layout(panel, path, this._physics);\n\t\t\tthis._stylesheet.replaceSync(css);\n\t\t} else if (mode === \"absolute\") {\n\t\t\tconst grid_css = create_css_grid_layout(panel, undefined, this._physics);\n\n\t\t\tconst overlay_css = updateOverlaySheet(\n\t\t\t\tslot,\n\t\t\t\tbox,\n\t\t\t\tstyle,\n\t\t\t\tdrop_target,\n\t\t\t\tthis._physics,\n\t\t\t);\n\n\t\t\tthis._stylesheet.replaceSync([grid_css, overlay_css].join(\"\\n\"));\n\t\t}\n\n\t\tconst event_name = `${this._physics.CUSTOM_EVENT_NAME_PREFIX}-before-update`;\n\t\tconst event = new CustomEvent<Layout>(event_name, { detail: panel });\n\t\tthis.dispatchEvent(event);\n\t};\n\n\t/**\n\t * Clears the overlay state and commits the panel placement.\n\t *\n\t * @param x - X coordinate in screen pixels.\n\t * @param y - Y coordinate in screen pixels.\n\t * @param dragTarget - A `LayoutPath` (presumably from `calculateIntersect`)\n\t * which points to the drag element in the current layout.\n\t * @param className - The CSS class name to use for the overlay panel\n\t * (defaults to \"overlay\").\n\t * @param mode - Overlay rendering mode that was used, must match the mode\n\t * passed to `setOverlayState`. Defaults to \"absolute\".\n\t */\n\tclearOverlayState = (\n\t\tx: number,\n\t\ty: number,\n\t\tdrag_target: LayoutPath<Layout>,\n\t\tclassName: string = this._physics.OVERLAY_CLASSNAME,\n\t) => {\n\t\tlet panel = this._panel;\n\t\tpanel = remove_child(panel, drag_target.slot);\n\t\tArray.from(this.children)\n\t\t\t.find(\n\t\t\t\t(x) =>\n\t\t\t\t\tx.getAttribute(this._physics.CHILD_ATTRIBUTE_NAME) ===\n\t\t\t\t\tdrag_target.slot,\n\t\t\t)\n\t\t\t?.classList.remove(className);\n\n\t\tconst [col, row, box] = this.relativeCoordinates(x, y, false);\n\t\tlet drop_target = calculate_intersection(col, row, panel);\n\t\tif (drop_target) {\n\t\t\tdrop_target = calculate_edge(\n\t\t\t\tcol,\n\t\t\t\trow,\n\t\t\t\tpanel,\n\t\t\t\tdrag_target.slot,\n\t\t\t\tdrop_target,\n\t\t\t\tbox,\n\t\t\t\tthis._physics,\n\t\t\t);\n\t\t}\n\n\t\tconst { path, orientation } = drop_target ? drop_target : drag_target;\n\t\tconst new_layout = drop_target\n\t\t\t? insert_child(\n\t\t\t\t\tpanel,\n\t\t\t\t\tdrag_target.slot,\n\t\t\t\t\tpath,\n\t\t\t\t\tdrop_target?.is_edge ? orientation : undefined,\n\t\t\t\t)\n\t\t\t: drag_target.layout;\n\n\t\tthis.restore(new_layout);\n\t};\n\n\t/**\n\t * Inserts a new panel into the layout at a specified path.\n\t *\n\t * @param name - Unique identifier for the new panel.\n\t * @param path - Index path defining where to insert.\n\t * @param split - Force a split in the layout at the end of `path`\n\t * regardless if there is a leaf at this position or not. Optionally,\n\t *. `split` may be your preferred `Orientation`, which will be used by\n\t * the new `SplitPanel` _if_ there is an option of orientation (e.g. if\n\t * the layout had no pre-existing `SplitPanel`)\n\t */\n\tinsertPanel = (\n\t\tname: string,\n\t\tpath: number[] = [],\n\t\tsplit?: boolean | Orientation,\n\t) => {\n\t\tlet orientation: Orientation | undefined;\n\t\tif (typeof split === \"boolean\" && split) {\n\t\t\torientation = \"horizontal\";\n\t\t} else if (typeof split === \"string\") {\n\t\t\torientation = split;\n\t\t}\n\n\t\tthis.restore(insert_child(this._panel, name, path, orientation));\n\t};\n\n\t/**\n\t * Removes a panel from the layout by name.\n\t *\n\t * @param name - Name of the panel to remove\n\t */\n\tremovePanel = (name: string) => {\n\t\tthis.restore(remove_child(this._panel, name));\n\t};\n\n\t/**\n\t * Retrieves a panel by name from the layout tree.\n\t *\n\t * @param name - Name of the panel to find.\n\t * @param layout - Optional layout tree to search in (defaults to current layout).\n\t * @returns The TabLayout containing the panel if found, null otherwise.\n\t */\n\tgetPanel = (name: string, layout: Layout = this._panel): TabLayout | null => {\n\t\tif (layout.type === \"child-panel\") {\n\t\t\tif (layout.child.includes(name)) {\n\t\t\t\treturn layout;\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\n\t\tfor (const child of layout.children) {\n\t\t\tconst found = this.getPanel(name, child);\n\t\t\tif (found) {\n\t\t\t\treturn found;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t};\n\n\t/**\n\t * Clears the entire layout, unslotting all panels.\n\t */\n\tclear = () => {\n\t\tthis.restore(EMPTY_PANEL);\n\t};\n\n\t/**\n\t * Restores the layout from a saved state.\n\t *\n\t * @param layout - The layout tree to restore\n\t *\n\t * @example\n\t * ```typescript\n\t * const layout = document.querySelector('regular-layout');\n\t * const savedState = JSON.parse(localStorage.getItem('layout'));\n\t * layout.restore(savedState);\n\t * ```\n\t */\n\trestore = (layout: Layout, _is_flattened: boolean = false) => {\n\t\tthis._panel = !_is_flattened ? flatten(layout) : layout;\n\t\tconst css = create_css_grid_layout(this._panel, undefined, this._physics);\n\n\t\tthis._stylesheet.replaceSync(css);\n\t\tconst event_name = `${this._physics.CUSTOM_EVENT_NAME_PREFIX}-update`;\n\t\tconst event = new CustomEvent<Layout>(event_name, { detail: this._panel });\n\t\tthis.dispatchEvent(event);\n\t};\n\n\t/**\n\t * Serializes the current layout state, which can be restored via `restore`.\n\t *\n\t * @returns The current layout tree\n\t *\n\t * @example\n\t * ```typescript\n\t * const layout = document.querySelector('regular-layout');\n\t * const state = layout.save();\n\t * localStorage.setItem('layout', JSON.stringify(state));\n\t * ```\n\t */\n\tsave = (): Layout => {\n\t\treturn structuredClone(this._panel);\n\t};\n\n\t/**\n\t * Override this instance's global constants.\n\t *\n\t * @param physics\n\t */\n\trestorePhysics(physics: PhysicsUpdate) {\n\t\tthis._physics = Object.freeze({\n\t\t\t...this._physics,\n\t\t\t...physics,\n\t\t});\n\t}\n\n\t/**\n\t * Get this instance's constants.\n\t *\n\t * @returns The current constants\n\t */\n\tsavePhysics(): Physics {\n\t\treturn this._physics;\n\t}\n\n\t/**\n\t * Converts screen coordinates to relative layout coordinates.\n\t *\n\t * Transforms absolute pixel positions into normalized coordinates (0-1 range)\n\t * relative to the layout's bounding box.\n\t *\n\t * @param clientX - X coordinate in screen pixels (client space).\n\t * @param clientY - Y coordinate in screen pixels (client space).\n\t * @returns A tuple containing:\n\t * - col: Normalized X coordinate (0 = left edge, 1 = right edge)\n\t * - row: Normalized Y coordinate (0 = top edge, 1 = bottom edge)\n\t * - box: The layout element's bounding rectangle\n\t */\n\trelativeCoordinates = (\n\t\tclientX: number,\n\t\tclientY: number,\n\t\trecalculate_bounds: boolean = true,\n\t): [number, number, DOMRect, CSSStyleDeclaration] => {\n\t\tif (recalculate_bounds || !this._dimensions) {\n\t\t\tthis._dimensions = {\n\t\t\t\tbox: this.getBoundingClientRect(),\n\t\t\t\tstyle: getComputedStyle(this),\n\t\t\t};\n\t\t}\n\n\t\tconst box = this._dimensions.box;\n\t\tconst style = this._dimensions.style;\n\t\tconst col =\n\t\t\t(clientX - box.left - parseFloat(style.paddingLeft)) /\n\t\t\t(box.width -\n\t\t\t\tparseFloat(style.paddingLeft) -\n\t\t\t\tparseFloat(style.paddingRight));\n\t\tconst row =\n\t\t\t(clientY - box.top - parseFloat(style.paddingTop)) /\n\t\t\t(box.height -\n\t\t\t\tparseFloat(style.paddingTop) -\n\t\t\t\tparseFloat(style.paddingBottom));\n\n\t\treturn [col, row, box, style];\n\t};\n\n\tprivate onPointerDown = (event: PointerEvent) => {\n\t\tif (!this._physics.GRID_DIVIDER_CHECK_TARGET || event.target === this) {\n\t\t\tconst [col, row, rect] = this.relativeCoordinates(\n\t\t\t\tevent.clientX,\n\t\t\t\tevent.clientY,\n\t\t\t);\n\n\t\t\tconst hit = calculate_intersection(col, row, this._panel, {\n\t\t\t\trect,\n\t\t\t\tsize: this._physics.GRID_DIVIDER_SIZE,\n\t\t\t});\n\t\t\tif (hit && hit.type !== \"layout-path\") {\n\t\t\t\tthis._drag_target = [hit, col, row];\n\t\t\t\tthis.setPointerCapture(event.pointerId);\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate onPointerMove = (event: PointerEvent) => {\n\t\tif (this._drag_target) {\n\t\t\tconst [col, row] = this.relativeCoordinates(\n\t\t\t\tevent.clientX,\n\t\t\t\tevent.clientY,\n\t\t\t\tfalse,\n\t\t\t);\n\n\t\t\tconst [{ path, type }, old_col, old_row] = this._drag_target;\n\t\t\tconst offset = type === \"horizontal\" ? old_col - col : old_row - row;\n\t\t\tconst panel = redistribute_panel_sizes(this._panel, path, offset);\n\t\t\tthis._stylesheet.replaceSync(\n\t\t\t\tcreate_css_grid_layout(panel, undefined, this._physics),\n\t\t\t);\n\t\t}\n\n\t\tif (this._physics.GRID_DIVIDER_CHECK_TARGET && event.target !== this) {\n\t\t\tif (this._cursor_override) {\n\t\t\t\tthis._cursor_override = false;\n\t\t\t\tthis._cursor_stylesheet.replaceSync(\"\");\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst [col, row, rect] = this.relativeCoordinates(\n\t\t\tevent.clientX,\n\t\t\tevent.clientY,\n\t\t\tfalse,\n\t\t);\n\n\t\tconst divider = calculate_intersection(col, row, this._panel, {\n\t\t\trect,\n\t\t\tsize: this._physics.GRID_DIVIDER_SIZE,\n\t\t});\n\n\t\tif (divider?.type === \"vertical\") {\n\t\t\tthis._cursor_stylesheet.replaceSync(\":host{cursor:row-resize\");\n\t\t\tthis._cursor_override = true;\n\t\t} else if (divider?.type === \"horizontal\") {\n\t\t\tthis._cursor_stylesheet.replaceSync(\":host{cursor:col-resize\");\n\t\t\tthis._cursor_override = true;\n\t\t} else if (this._cursor_override) {\n\t\t\tthis._cursor_override = false;\n\t\t\tthis._cursor_stylesheet.replaceSync(\"\");\n\t\t}\n\t};\n\n\tprivate onPointerUp = (event: PointerEvent) => {\n\t\tif (this._drag_target) {\n\t\t\tthis.releasePointerCapture(event.pointerId);\n\t\t\tconst [col, row] = this.relativeCoordinates(\n\t\t\t\tevent.clientX,\n\t\t\t\tevent.clientY,\n\t\t\t\tfalse,\n\t\t\t);\n\n\t\t\tconst [{ path, type }, old_col, old_row] = this._drag_target;\n\t\t\tconst offset = type === \"horizontal\" ? old_col - col : old_row - row;\n\t\t\tconst panel = redistribute_panel_sizes(this._panel, path, offset);\n\t\t\tthis.restore(panel, true);\n\t\t\tthis._drag_target = undefined;\n\t\t}\n\t};\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { Layout, LayoutPath } from \"./layout/types.ts\";\nimport type { RegularLayoutEvent } from \"./extensions.ts\";\nimport type { RegularLayout } from \"./regular-layout.ts\";\nimport type { RegularLayoutTab } from \"./regular-layout-tab.ts\";\n\nconst CSS = `\n:host{box-sizing:border-box;flex-direction:column}\n:host::part(titlebar){display:flex;height:24px;user-select:none;overflow:hidden}\n:host::part(container){flex:1 1 auto}\n:host::part(title){flex:1 1 auto;pointer-events:none}\n:host::part(close){align-self:stretch}\n:host::slotted{flex:1 1 auto;}\n:host regular-layout-tab{width:0px;}\n`;\n\nconst HTML_TEMPLATE = `\n\t<div part=\"titlebar\"></div>\n\t<slot part=\"container\"></slot>\n`;\n\n/**\n * A custom element that represents a draggable panel within a\n * `<regular-layout>`.\n *\n * `<regular-layout-frame>` is optional - you may also use a `<regular-layout>`\n * with just plain `<div>` children (for example), but panels will not be\n * moveable within the layout unless you manually call `setOverlayState` and\n * `clearOverlayState` (or otherwise impement panel moving via the\n * `<regular-layout>` API).\n *\n * `<regular-layout-frame>` simple and highly customizable implementations\n * based on [CSS `part`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/::part)\n * for custom styling, and symmetric\n * [named `slot`s](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_templates_and_slots)\n * for wholesale replacement of the underlying Shadow DOM.\n *\n * @example\n * ```html\n * <regular-layout>\n * <regular-layout-frame name=\"panel-1\">\n * <!-- Panel content here -->\n * </regular-layout-frame>\n * </regular-layout>\n * ```\n */\nexport class RegularLayoutFrame extends HTMLElement {\n\tprivate _shadowRoot: ShadowRoot;\n\tprivate _container_sheet: CSSStyleSheet;\n\tprivate _layout!: RegularLayout;\n\tprivate _header!: HTMLElement;\n\tprivate _drag_state: LayoutPath<Layout> | null = null;\n\tprivate _drag_moved: boolean = false;\n\tprivate _tab_to_index_map: WeakMap<RegularLayoutTab, number> = new WeakMap();\n\tconstructor() {\n\t\tsuper();\n\t\tthis._container_sheet = new CSSStyleSheet();\n\t\tthis._container_sheet.replaceSync(CSS);\n\t\tthis._shadowRoot = this.attachShadow({ mode: \"open\" });\n\t\tthis._shadowRoot.adoptedStyleSheets = [this._container_sheet];\n\t}\n\n\tconnectedCallback() {\n\t\tthis._shadowRoot.innerHTML = HTML_TEMPLATE;\n\t\tthis._layout = this.parentElement as RegularLayout;\n\t\tthis._header = this._shadowRoot.children[0] as HTMLElement;\n\t\tthis._header.addEventListener(\"pointerdown\", this.onPointerDown);\n\t\tthis._header.addEventListener(\"pointermove\", this.onPointerMove);\n\t\tthis._header.addEventListener(\"pointerup\", this.onPointerUp);\n\t\tthis._header.addEventListener(\"lostpointercapture\", this.onPointerLost);\n\t\tthis._layout.addEventListener(\"regular-layout-update\", this.drawTabs);\n\t\tthis._layout.addEventListener(\n\t\t\t\"regular-layout-before-update\",\n\t\t\tthis.drawTabs,\n\t\t);\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis._header.removeEventListener(\"pointerdown\", this.onPointerDown);\n\t\tthis._header.removeEventListener(\"pointermove\", this.onPointerMove);\n\t\tthis._header.removeEventListener(\"pointerup\", this.onPointerUp);\n\t\tthis._header.removeEventListener(\"lostpointercapture\", this.onPointerLost);\n\t\tthis._layout.removeEventListener(\"regular-layout-update\", this.drawTabs);\n\t\tthis._layout.removeEventListener(\n\t\t\t\"regular-layout-before-update\",\n\t\t\tthis.drawTabs,\n\t\t);\n\t}\n\n\tprivate onPointerDown = (event: PointerEvent): void => {\n\t\tconst elem = event.target as RegularLayoutTab;\n\t\tif (elem.part.contains(\"tab\")) {\n\t\t\tthis._drag_state = this._layout.calculateIntersect(\n\t\t\t\tevent.clientX,\n\t\t\t\tevent.clientY,\n\t\t\t);\n\n\t\t\tif (this._drag_state) {\n\t\t\t\tthis._header.setPointerCapture(event.pointerId);\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate onPointerMove = (event: PointerEvent): void => {\n\t\tif (this._drag_state) {\n\t\t\tconst physics = this._layout.savePhysics();\n\n\t\t\t// Only initiate a drag if the cursor has moved sufficiently.\n\t\t\tif (!this._drag_moved) {\n\t\t\t\tconst [current_col, current_row, box] =\n\t\t\t\t\tthis._layout.relativeCoordinates(event.clientX, event.clientY);\n\n\t\t\t\tconst dx = (current_col - this._drag_state.column) * box.width;\n\t\t\t\tconst dy = (current_row - this._drag_state.row) * box.height;\n\t\t\t\tif (Math.sqrt(dx * dx + dy * dy) <= physics.MIN_DRAG_DISTANCE) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis._drag_moved = true;\n\t\t\tthis._layout.setOverlayState(\n\t\t\t\tevent.clientX,\n\t\t\t\tevent.clientY,\n\t\t\t\tthis._drag_state,\n\t\t\t\tphysics.OVERLAY_CLASSNAME,\n\t\t\t);\n\t\t}\n\t};\n\n\tprivate onPointerUp = (event: PointerEvent): void => {\n\t\tif (this._drag_state && this._drag_moved) {\n\t\t\tthis._layout.clearOverlayState(\n\t\t\t\tevent.clientX,\n\t\t\t\tevent.clientY,\n\t\t\t\tthis._drag_state,\n\t\t\t);\n\t\t}\n\n\t\t// TODO This may be handled by `onPointerLost`, not sure if this is\n\t\t// browser-specific behavior ...\n\t\tthis._header.releasePointerCapture(event.pointerId);\n\t\tthis._drag_state = null;\n\t\tthis._drag_moved = false;\n\t};\n\n\tprivate onPointerLost = (event: PointerEvent): void => {\n\t\tif (this._drag_state) {\n\t\t\tthis._layout.clearOverlayState(-1, -1, this._drag_state);\n\t\t}\n\n\t\tthis._header.releasePointerCapture(event.pointerId);\n\t\tthis._drag_state = null;\n\t\tthis._drag_moved = false;\n\t};\n\n\tprivate drawTabs = (event: RegularLayoutEvent) => {\n\t\tconst slot = this.getAttribute(\n\t\t\tthis._layout.savePhysics().CHILD_ATTRIBUTE_NAME,\n\t\t);\n\n\t\tif (!slot) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst new_panel = event.detail;\n\t\tlet new_tab_panel = this._layout.getPanel(slot, new_panel);\n\t\tif (!new_tab_panel) {\n\t\t\tnew_tab_panel = {\n\t\t\t\ttype: \"child-panel\",\n\t\t\t\tchild: [slot],\n\t\t\t\tselected: 0,\n\t\t\t};\n\t\t}\n\n\t\tfor (let i = 0; i < new_tab_panel.child.length; i++) {\n\t\t\tif (i >= this._header.children.length) {\n\t\t\t\tconst new_tab = document.createElement(\"regular-layout-tab\");\n\t\t\t\tnew_tab.populate(this._layout, new_tab_panel, i);\n\t\t\t\tthis._header.appendChild(new_tab);\n\t\t\t\tthis._tab_to_index_map.set(new_tab, i);\n\t\t\t} else {\n\t\t\t\tconst tab = this._header.children[i] as RegularLayoutTab;\n\t\t\t\ttab.populate(this._layout, new_tab_panel, i);\n\t\t\t}\n\t\t}\n\n\t\tconst last_index = new_tab_panel.child.length;\n\t\tfor (let j = this._header.children.length - 1; j >= last_index; j--) {\n\t\t\tthis._header.removeChild(this._header.children[j]);\n\t\t}\n\t};\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { TabLayout } from \"./layout/types.ts\";\nimport type { RegularLayout } from \"./regular-layout.ts\";\n\n/**\n * A custom HTML element representing an individual tab in a tab panel.\n *\n * This element manages the visual representation and interactions for a single tab,\n * including selection state, close functionality, and content display.\n */\nexport class RegularLayoutTab extends HTMLElement {\n\tprivate _layout?: RegularLayout;\n\tprivate _tab_panel?: TabLayout;\n\tprivate _index?: number;\n\n\t/**\n\t * Populates or updates the tab with layout information.\n\t *\n\t * This method initializes the tab's content and event listeners on first call,\n\t * and efficiently updates only the changed properties on subsequent calls.\n\t *\n\t * @param layout - The parent RegularLayout instance managing this tab.\n\t * @param tab_panel - The tab panel layout containing this tab.\n\t * @param index - The index of this tab within the tab panel.\n\t */\n\tpopulate = (layout: RegularLayout, tab_panel: TabLayout, index: number) => {\n\t\tif (this._tab_panel) {\n\t\t\tconst tab_changed =\n\t\t\t\t(index === tab_panel.selected) !==\n\t\t\t\t(index === this._tab_panel?.selected);\n\n\t\t\tconst index_changed =\n\t\t\t\ttab_changed || this._tab_panel?.child[index] !== tab_panel.child[index];\n\n\t\t\tif (index_changed) {\n\t\t\t\tconst selected = tab_panel.selected === index;\n\t\t\t\tconst slot = tab_panel.child[index];\n\t\t\t\tthis.children[0].textContent = slot;\n\n\t\t\t\tif (selected) {\n\t\t\t\t\tthis.children[1].part.add(\"active-close\");\n\t\t\t\t\tthis.part.add(\"active-tab\");\n\t\t\t\t} else {\n\t\t\t\t\tthis.children[1].part.remove(\"active-close\");\n\t\t\t\t\tthis.part.remove(\"active-tab\");\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst slot = tab_panel.child[index];\n\t\t\tconst selected = tab_panel.selected === index;\n\t\t\tconst parts = selected ? \"active-close close\" : \"close\";\n\t\t\tthis.innerHTML = `<div part=\"title\"></div><button part=\"${parts}\"></button>`;\n\t\t\tif (selected) {\n\t\t\t\tthis.part.add(\"tab\", \"active-tab\");\n\t\t\t} else {\n\t\t\t\tthis.part.add(\"tab\");\n\t\t\t}\n\n\t\t\tthis.addEventListener(\"pointerdown\", this.onTabClick);\n\t\t\tthis.children[0].textContent = slot;\n\t\t\tthis.children[1].addEventListener(\"pointerdown\", this.onTabClose);\n\t\t}\n\n\t\tthis._tab_panel = tab_panel;\n\t\tthis._layout = layout;\n\t\tthis._index = index;\n\t};\n\n\tprivate onTabClose = (_: Event) => {\n\t\tif (this._tab_panel !== undefined && this._index !== undefined) {\n\t\t\tthis._layout?.removePanel(this._tab_panel.child[this._index]);\n\t\t}\n\t};\n\n\tprivate onTabClick = (_: PointerEvent) => {\n\t\tif (\n\t\t\tthis._tab_panel !== undefined &&\n\t\t\tthis._index !== undefined &&\n\t\t\tthis._index !== this._tab_panel.selected\n\t\t) {\n\t\t\tconst new_layout = this._layout?.save();\n\t\t\tconst new_tab_panel = this._layout?.getPanel(\n\t\t\t\tthis._tab_panel.child[this._index],\n\t\t\t\tnew_layout,\n\t\t\t);\n\n\t\t\tif (new_tab_panel && new_layout) {\n\t\t\t\tnew_tab_panel.selected = this._index;\n\t\t\t\tthis._layout?.restore(new_layout);\n\t\t\t}\n\t\t}\n\t};\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport { RegularLayout } from \"./regular-layout.ts\";\nimport { RegularLayoutFrame } from \"./regular-layout-frame.ts\";\nimport type { Layout } from \"./layout/types.ts\";\nimport { RegularLayoutTab } from \"./regular-layout-tab.ts\";\n\ncustomElements.define(\"regular-layout\", RegularLayout);\ncustomElements.define(\"regular-layout-frame\", RegularLayoutFrame);\ncustomElements.define(\"regular-layout-tab\", RegularLayoutTab);\n\ndeclare global {\n\tinterface Document {\n\t\tcreateElement(\n\t\t\ttagName: \"regular-layout\",\n\t\t\toptions?: ElementCreationOptions,\n\t\t): RegularLayout;\n\n\t\tcreateElement(\n\t\t\ttagName: \"regular-layout-frame\",\n\t\t\toptions?: ElementCreationOptions,\n\t\t): RegularLayoutFrame;\n\n\t\tcreateElement(\n\t\t\ttagName: \"regular-layout-tab\",\n\t\t\toptions?: ElementCreationOptions,\n\t\t): RegularLayoutTab;\n\n\t\tquerySelector<E extends Element = Element>(selectors: string): E | null;\n\t\tquerySelector(selectors: \"regular-layout\"): RegularLayout | null;\n\t\tquerySelector(selectors: \"regular-layout-frame\"): RegularLayoutFrame | null;\n\t\tquerySelector(selectors: \"regular-layout-tab\"): RegularLayoutTab | null;\n\t}\n\n\tinterface CustomElementRegistry {\n\t\tget(tagName: \"regular-layout\"): typeof RegularLayout;\n\t\tget(tagName: \"regular-layout-frame\"): typeof RegularLayoutFrame;\n\t}\n\n\tinterface HTMLElement {\n\t\taddEventListener(\n\t\t\tname: \"regular-layout-update\",\n\t\t\tcb: (e: RegularLayoutEvent) => void,\n\t\t\toptions?: { signal: AbortSignal },\n\t\t): void;\n\n\t\taddEventListener(\n\t\t\tname: \"regular-layout-before-update\",\n\t\t\tcb: (e: RegularLayoutEvent) => void,\n\t\t\toptions?: { signal: AbortSignal },\n\t\t): void;\n\n\t\tremoveEventListener(\n\t\t\tname: \"regular-layout-update\",\n\t\t\tcb: (e: RegularLayoutEvent) => void,\n\t\t): void;\n\n\t\tremoveEventListener(\n\t\t\tname: \"regular-layout-before-update\",\n\t\t\tcb: (e: RegularLayoutEvent) => void,\n\t\t): void;\n\t}\n}\n\nexport type RegularLayoutEvent = CustomEvent<Layout>;\n"],
5
+ "mappings": "AAoGO,IAAMA,EAAsB,CAClC,KAAM,cACN,YAAa,aACb,MAAO,CAAC,EACR,SAAU,CAAC,CACZ,ECAO,IAAMC,EAA2B,OAAO,OAAO,CACrD,yBAA0B,iBAC1B,qBAAsB,OACtB,kBAAmB,GACnB,aAAc,GACd,kBAAmB,UACnB,sCAAuC,IACvC,qBAAsB,IACtB,0BAA2B,IAC3B,8BAA+B,KAC/B,gBAAiB,WACjB,kBAAmB,EACnB,0BAA2B,EAC5B,CAAC,EChGD,SAASC,EAAYC,EAAkBC,EAAkBC,EAAa,CACrE,OACCD,EAAO,SAAW,GAClB,KAAK,IAAIC,EAAMD,EAAOA,EAAO,OAAS,CAAC,CAAC,EACvCD,EAAQ,gCAETC,EAAO,KAAKC,CAAG,EAGTD,CACR,CAEA,SAASE,EAAiBH,EAAkBI,EAA+B,CAE1E,OADeA,EAAU,KAAK,CAACC,EAAGC,IAAMD,EAAIC,CAAC,EAC/B,OAAOP,EAAY,KAAK,OAAWC,CAAO,EAAG,CAAC,CAAC,CAC9D,CAEA,SAASO,EACRC,EACAC,EACAC,EACAC,EACAX,EACW,CACX,GAAIQ,EAAM,OAAS,cAClB,MAAO,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CQ,CACD,EAEIC,GAAiBD,IACpBC,EAAc,SAAW,KAAKT,EAC9B,KAAKF,GAAS,QAAQU,CAAU,EAElC,CACD,CACD,ECtFA,eAAe,OAAO,iBAAkBE,CAAa,EACrD,eAAe,OAAO,uBAAwBC,CAAkB,EAChE,eAAe,OAAO,qBAAsBC,CAAgB",
6
+ "names": ["EMPTY_PANEL", "DEFAULT_PHYSICS", "dedupe_sort", "physics", "result", "pos", "dedupe_positions", "positions", "a", "b", "collect_track_positions", "panel", "orientation", "start", "end", "current", "range", "i", "size", "next", "child", "find_track_index", "value", "index", "build_cells", "colPositions", "rowPositions", "colStart", "colEnd", "rowStart", "rowEnd", "selected", "children", "sizes", "isHorizontal", "cells", "host_template", "rowTemplate", "colTemplate", "child_template", "slot", "rowPart", "colPart", "create_css_grid_layout", "layout", "overlay", "DEFAULT_PHYSICS", "createTemplate", "s", "formatGridLine", "css", "cell", "VIEW_WINDOW", "calculate_intersection", "column", "row", "layout", "check_dividers", "calculate_intersection_recursive", "panel", "parent_orientation", "view_window", "path", "selected", "col_width", "row_height", "is_vertical", "position", "start_key", "end_key", "rect_dim", "current_pos", "total_size", "i", "next_pos", "divider_threshold", "remove_child", "panel", "child", "newChild", "c", "EMPTY_PANEL", "result", "index", "p", "tab_layout", "newChildren", "_", "i", "newSizes", "remove_and_redistribute", "modified", "updated", "arr", "removed_size", "remaining_total", "proportion", "insert_child", "panel", "child", "path", "orientation", "createChildPanel", "childId", "newChildren", "newSizes", "redistribute", "index", "restPath", "children", "newChild", "newSplitPanel", "targetChild", "childOrientation", "updatedChild", "arr", "total", "sum", "val", "redistribute_panel_sizes", "panel", "path", "delta", "physics", "DEFAULT_PHYSICS", "result", "current", "deltas", "i", "index", "add_and_redistribute", "arr", "before_total", "after_total", "proportion", "updateOverlaySheet", "slot", "box", "style", "drag_target", "physics", "DEFAULT_PHYSICS", "row_start", "row_end", "col_start", "col_end", "box_height", "box_width", "top", "left", "height", "width", "css", "calculate_edge", "col", "row", "panel", "slot", "drop_target", "box", "physics", "DEFAULT_PHYSICS", "insert_root_edge", "is_column_edge", "is_row_edge", "col_distance", "row_distance", "col_scale", "row_scale", "use_column", "insert_axis", "path", "is_before", "orientation", "axis_orientation", "result_path", "last_index", "new_panel", "insert_child", "view_window", "calculate_view_window", "current_panel", "step", "index", "is_vertical", "start_key", "end_key", "total_size", "offset", "sum", "size", "flatten", "layout", "flattenedChildren", "flattenedSizes", "i", "child", "childSize", "flattenedChild", "j", "RegularLayout", "_shadowRoot", "_panel", "_stylesheet", "_cursor_stylesheet", "_drag_target", "_cursor_override", "_dimensions", "_physics", "DEFAULT_PHYSICS", "EMPTY_PANEL", "x", "y", "check_dividers", "col", "row", "rect", "panel", "calculate_intersection", "slot", "className", "mode", "remove_child", "box", "style", "drop_target", "calculate_edge", "path", "css", "create_css_grid_layout", "grid_css", "overlay_css", "updateOverlaySheet", "event_name", "event", "drag_target", "orientation", "new_layout", "insert_child", "name", "split", "layout", "child", "found", "_is_flattened", "flatten", "physics", "clientX", "clientY", "recalculate_bounds", "hit", "type", "old_col", "old_row", "offset", "redistribute_panel_sizes", "divider", "CSS", "HTML_TEMPLATE", "RegularLayoutFrame", "_shadowRoot", "_container_sheet", "_layout", "_header", "_drag_state", "_drag_moved", "_tab_to_index_map", "event", "physics", "current_col", "current_row", "box", "dx", "dy", "slot", "new_panel", "new_tab_panel", "i", "new_tab", "last_index", "j", "RegularLayoutTab", "_layout", "_tab_panel", "_index", "layout", "tab_panel", "index", "selected", "slot", "parts", "_", "new_layout", "new_tab_panel", "RegularLayout", "RegularLayoutFrame", "RegularLayoutTab"]
7
7
  }