@jimka/typescript-ui 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/dist/lib/{AbstractInput-B10DfLOf.js → AbstractInput-sRNPzWel.js} +2 -2
  2. package/dist/lib/{AbstractInput-B10DfLOf.js.map → AbstractInput-sRNPzWel.js.map} +1 -1
  3. package/dist/lib/Anchor-CwRhdP2J.js +2 -0
  4. package/dist/lib/Anchor-CwRhdP2J.js.map +1 -0
  5. package/dist/lib/AnimatedDropdown-H3Rh-YMZ.js +2 -0
  6. package/dist/lib/AnimatedDropdown-H3Rh-YMZ.js.map +1 -0
  7. package/dist/lib/Border-0DJFDiij.js +2 -0
  8. package/dist/lib/Border-0DJFDiij.js.map +1 -0
  9. package/dist/lib/Button-MpMIYBYJ.js +2 -0
  10. package/dist/lib/Button-MpMIYBYJ.js.map +1 -0
  11. package/dist/lib/{Card-CD3jxshU.js → Card-QYo27r5b.js} +2 -2
  12. package/dist/lib/{Card-CD3jxshU.js.map → Card-QYo27r5b.js.map} +1 -1
  13. package/dist/lib/Checkbox-D0JYK-wc.js +2 -0
  14. package/dist/lib/Checkbox-D0JYK-wc.js.map +1 -0
  15. package/dist/lib/CheckboxMenuRow-CesLhSnp.js +2 -0
  16. package/dist/lib/CheckboxMenuRow-CesLhSnp.js.map +1 -0
  17. package/dist/lib/{CodeEditor-BGlB232h.js → CodeEditor-N1FQodcF.js} +2 -2
  18. package/dist/lib/CodeEditor-N1FQodcF.js.map +1 -0
  19. package/dist/lib/ComboBox-Dx8Tk9yg.js +2 -0
  20. package/dist/lib/ComboBox-Dx8Tk9yg.js.map +1 -0
  21. package/dist/lib/Component-B0ShfPVi.js +2 -0
  22. package/dist/lib/Component-B0ShfPVi.js.map +1 -0
  23. package/dist/lib/Container-abY5Ww3W.js +2 -0
  24. package/dist/lib/{Container-C7RPLQEc.js.map → Container-abY5Ww3W.js.map} +1 -1
  25. package/dist/lib/{DOM-Ba8YRVel.js → DOM-C-Edb3tA.js} +2 -2
  26. package/dist/lib/DOM-C-Edb3tA.js.map +1 -0
  27. package/dist/lib/Dialog-cbA9V17e.js +2 -0
  28. package/dist/lib/Dialog-cbA9V17e.js.map +1 -0
  29. package/dist/lib/{FieldDecorator-HG65hEtk.js → FieldDecorator-BlYMfZ9L.js} +2 -2
  30. package/dist/lib/{FieldDecorator-HG65hEtk.js.map → FieldDecorator-BlYMfZ9L.js.map} +1 -1
  31. package/dist/lib/{Fit-Cg3dPyZg.js → Fit-BhlB-HAo.js} +2 -2
  32. package/dist/lib/{Fit-Cg3dPyZg.js.map → Fit-BhlB-HAo.js.map} +1 -1
  33. package/dist/lib/{FloatingPanel-D5buuVrQ.js → FloatingPanel-DkJXsZ2D.js} +2 -2
  34. package/dist/lib/{FloatingPanel-D5buuVrQ.js.map → FloatingPanel-DkJXsZ2D.js.map} +1 -1
  35. package/dist/lib/{Glyph-DeJF_zsR.js → Glyph-_VeBacS2.js} +2 -2
  36. package/dist/lib/{Glyph-DeJF_zsR.js.map → Glyph-_VeBacS2.js.map} +1 -1
  37. package/dist/lib/{Grid-BYBohJIA.js → Grid-Daiz7F5d.js} +2 -2
  38. package/dist/lib/Grid-Daiz7F5d.js.map +1 -0
  39. package/dist/lib/GridConstraints-C58LuTqM.js +2 -0
  40. package/dist/lib/{GridConstraints-Bts284FI.js.map → GridConstraints-C58LuTqM.js.map} +1 -1
  41. package/dist/lib/{Header-BIFJK9nR.js → Header-Dql3Zxc6.js} +2 -2
  42. package/dist/lib/{Header-BIFJK9nR.js.map → Header-Dql3Zxc6.js.map} +1 -1
  43. package/dist/lib/{IconText-Dsb1xS-E.js → IconText-PUjhTLlp.js} +2 -2
  44. package/dist/lib/{IconText-Dsb1xS-E.js.map → IconText-PUjhTLlp.js.map} +1 -1
  45. package/dist/lib/LayoutSerialization-CMxunLfV.js +2 -0
  46. package/dist/lib/LayoutSerialization-CMxunLfV.js.map +1 -0
  47. package/dist/lib/List-nx8220Fi.js +2 -0
  48. package/dist/lib/{List-BPd-IXZR.js.map → List-nx8220Fi.js.map} +1 -1
  49. package/dist/lib/MemoryStore-DhPoU-7X.js +2 -0
  50. package/dist/lib/MemoryStore-DhPoU-7X.js.map +1 -0
  51. package/dist/lib/Menu-Q0bpXXze.js +2 -0
  52. package/dist/lib/Menu-Q0bpXXze.js.map +1 -0
  53. package/dist/lib/{MenuButton-BR4KOFld.js → MenuButton-DCXi0tsP.js} +2 -2
  54. package/dist/lib/{MenuButton-BR4KOFld.js.map → MenuButton-DCXi0tsP.js.map} +1 -1
  55. package/dist/lib/OverlayFade-3pof2AJH.js +2 -0
  56. package/dist/lib/OverlayFade-3pof2AJH.js.map +1 -0
  57. package/dist/lib/{Panel-CpNQTLNF.js → Panel-Cy1pdlWO.js} +2 -2
  58. package/dist/lib/{Panel-CpNQTLNF.js.map → Panel-Cy1pdlWO.js.map} +1 -1
  59. package/dist/lib/{Position-PBVBW1JS.js → Position-BwtxouxK.js} +2 -2
  60. package/dist/lib/{Position-PBVBW1JS.js.map → Position-BwtxouxK.js.map} +1 -1
  61. package/dist/lib/{ProgressSpinner-lAsK26C-.js → ProgressSpinner-DK8xEQ9y.js} +2 -2
  62. package/dist/lib/{ProgressSpinner-lAsK26C-.js.map → ProgressSpinner-DK8xEQ9y.js.map} +1 -1
  63. package/dist/lib/RadioButton-BEwpqg1k.js +2 -0
  64. package/dist/lib/{RadioButton-CCcIaL54.js.map → RadioButton-BEwpqg1k.js.map} +1 -1
  65. package/dist/lib/RadioMenuRow-DP5qPyFR.js +2 -0
  66. package/dist/lib/RadioMenuRow-DP5qPyFR.js.map +1 -0
  67. package/dist/lib/{RovingTabIndex-C2Vzq0IX.js → RovingTabIndex-pHEv5oLD.js} +2 -2
  68. package/dist/lib/{RovingTabIndex-C2Vzq0IX.js.map → RovingTabIndex-pHEv5oLD.js.map} +1 -1
  69. package/dist/lib/Scrollbar-t8fFrUVQ.js +2 -0
  70. package/dist/lib/Scrollbar-t8fFrUVQ.js.map +1 -0
  71. package/dist/lib/{Slider-DZ9drUxn.js → Slider-CTbwR6HR.js} +2 -2
  72. package/dist/lib/{Slider-DZ9drUxn.js.map → Slider-CTbwR6HR.js.map} +1 -1
  73. package/dist/lib/{Spacer-SDhOMp2g.js → Spacer-srdN2d2b.js} +2 -2
  74. package/dist/lib/{Spacer-SDhOMp2g.js.map → Spacer-srdN2d2b.js.map} +1 -1
  75. package/dist/lib/TabButton-DLoMQzky.js +2 -0
  76. package/dist/lib/TabButton-DLoMQzky.js.map +1 -0
  77. package/dist/lib/TabCloseButton-CY7BGitY.js +2 -0
  78. package/dist/lib/TabCloseButton-CY7BGitY.js.map +1 -0
  79. package/dist/lib/{Text-CdHf3B-1.js → Text-CMKnK9uB.js} +2 -2
  80. package/dist/lib/{Text-CdHf3B-1.js.map → Text-CMKnK9uB.js.map} +1 -1
  81. package/dist/lib/{Tooltip-B_UF5bXD.js → Tooltip-CUOJOqQi.js} +3 -3
  82. package/dist/lib/Tooltip-CUOJOqQi.js.map +1 -0
  83. package/dist/lib/Tree-C64JNPWJ.js +2 -0
  84. package/dist/lib/Tree-C64JNPWJ.js.map +1 -0
  85. package/dist/lib/VBox-DfJPWXqc.js +2 -0
  86. package/dist/lib/VBox-DfJPWXqc.js.map +1 -0
  87. package/dist/lib/VirtualScroller-DTIn19o1.js +2 -0
  88. package/dist/lib/VirtualScroller-DTIn19o1.js.map +1 -0
  89. package/dist/lib/assets/StoreWorker-B5NwRM2I.js +2 -0
  90. package/dist/lib/assets/StoreWorker-B5NwRM2I.js.map +1 -0
  91. package/dist/lib/component/button.es.js +1 -1
  92. package/dist/lib/component/button.es.js.map +1 -1
  93. package/dist/lib/component/chart.es.js +1 -1
  94. package/dist/lib/component/container.es.js +1 -1
  95. package/dist/lib/component/container.es.js.map +1 -1
  96. package/dist/lib/component/diagram.es.js +1 -1
  97. package/dist/lib/component/diagram.es.js.map +1 -1
  98. package/dist/lib/component/display.es.js +1 -1
  99. package/dist/lib/component/display.es.js.map +1 -1
  100. package/dist/lib/component/editor.es.js +2 -2
  101. package/dist/lib/component/editor.es.js.map +1 -1
  102. package/dist/lib/component/input.es.js +1 -1
  103. package/dist/lib/component/input.es.js.map +1 -1
  104. package/dist/lib/component/list.es.js +1 -1
  105. package/dist/lib/component/list.es.js.map +1 -1
  106. package/dist/lib/component/menubar.es.js +1 -1
  107. package/dist/lib/component/menubar.es.js.map +1 -1
  108. package/dist/lib/component/table.es.js +6 -3
  109. package/dist/lib/component/table.es.js.map +1 -1
  110. package/dist/lib/component/tree.es.js +1 -1
  111. package/dist/lib/core.es.js +1 -1
  112. package/dist/lib/core.es.js.map +1 -1
  113. package/dist/lib/data.es.js +1 -1
  114. package/dist/lib/glyphs/solid/index.es.js +1 -1
  115. package/dist/lib/layout.es.js +1 -1
  116. package/dist/lib/layout.es.js.map +1 -1
  117. package/dist/lib/overlay.es.js +1 -1
  118. package/dist/lib/overlay.es.js.map +1 -1
  119. package/dist/lib/primitive.es.js +1 -1
  120. package/dist/lib/router.es.js +1 -1
  121. package/dist/lib/router.es.js.map +1 -1
  122. package/dist/lib/selectionsEqual-gMG7gCVI.js +2 -0
  123. package/dist/lib/selectionsEqual-gMG7gCVI.js.map +1 -0
  124. package/dist/lib/types/component/button/Button.d.ts +13 -0
  125. package/dist/lib/types/component/button/MenuButton.d.ts +1 -0
  126. package/dist/lib/types/component/button/PopupButton.d.ts +22 -0
  127. package/dist/lib/types/component/button/TabButton.d.ts +4 -0
  128. package/dist/lib/types/component/button/index.d.ts +2 -0
  129. package/dist/lib/types/component/container/CheckboxMenuRow.d.ts +33 -0
  130. package/dist/lib/types/component/container/CollapseButton.d.ts +11 -3
  131. package/dist/lib/types/component/container/MenuItem.d.ts +15 -5
  132. package/dist/lib/types/component/container/MenuRow.d.ts +24 -0
  133. package/dist/lib/types/component/container/MenuSeparator.d.ts +4 -2
  134. package/dist/lib/types/component/container/RadioMenuRow.d.ts +33 -0
  135. package/dist/lib/types/component/container/Scrollbar.d.ts +5 -0
  136. package/dist/lib/types/component/container/SplitGutter.d.ts +7 -2
  137. package/dist/lib/types/component/container/TabBar.d.ts +2 -0
  138. package/dist/lib/types/component/container/WindowBorder.d.ts +1 -1
  139. package/dist/lib/types/component/container/index.d.ts +6 -1
  140. package/dist/lib/types/component/display/WebGLCanvas.d.ts +1 -0
  141. package/dist/lib/types/component/input/AbstractCalendarDropdown.d.ts +2 -0
  142. package/dist/lib/types/component/input/AbstractPickerField.d.ts +3 -2
  143. package/dist/lib/types/component/list/AbstractSelectableList.d.ts +1 -1
  144. package/dist/lib/types/component/list/MultiSelectList.d.ts +2 -1
  145. package/dist/lib/types/component/shared/VirtualRowView.d.ts +2 -0
  146. package/dist/lib/types/component/table/Body.d.ts +22 -1
  147. package/dist/lib/types/component/table/Column.d.ts +3 -1
  148. package/dist/lib/types/component/table/ColumnConfig.d.ts +2 -0
  149. package/dist/lib/types/component/table/ColumnFilter.d.ts +27 -0
  150. package/dist/lib/types/component/table/Header.d.ts +30 -3
  151. package/dist/lib/types/component/table/Row.d.ts +4 -0
  152. package/dist/lib/types/component/table/Table.d.ts +29 -0
  153. package/dist/lib/types/component/table/TableExporter.d.ts +4 -3
  154. package/dist/lib/types/component/table/TreeBody.d.ts +2 -1
  155. package/dist/lib/types/component/table/cell/CellText.d.ts +9 -0
  156. package/dist/lib/types/component/table/cell/Filter.d.ts +54 -0
  157. package/dist/lib/types/component/table/cell/FilterClauseBadge.d.ts +21 -0
  158. package/dist/lib/types/component/table/cell/GroupSeparator.d.ts +9 -0
  159. package/dist/lib/types/component/table/cell/Header.d.ts +1 -0
  160. package/dist/lib/types/component/table/cell/editor/CellEditor.d.ts +1 -0
  161. package/dist/lib/types/component/table/cell/renderer/CellRenderer.d.ts +1 -0
  162. package/dist/lib/types/component/table/cell/renderer/Combo.d.ts +2 -0
  163. package/dist/lib/types/component/table/cell/renderer/Date.d.ts +2 -0
  164. package/dist/lib/types/component/table/cell/renderer/DateTime.d.ts +2 -0
  165. package/dist/lib/types/component/table/cell/renderer/Filter.d.ts +16 -0
  166. package/dist/lib/types/component/table/cell/renderer/Glyph.d.ts +1 -0
  167. package/dist/lib/types/component/table/cell/renderer/Link.d.ts +2 -0
  168. package/dist/lib/types/component/table/cell/renderer/Number.d.ts +3 -1
  169. package/dist/lib/types/component/table/cell/renderer/String.d.ts +2 -0
  170. package/dist/lib/types/component/table/cell/renderer/Time.d.ts +2 -0
  171. package/dist/lib/types/component/table/cell/renderer/TreeCell.d.ts +1 -0
  172. package/dist/lib/types/component/table/index.d.ts +6 -0
  173. package/dist/lib/types/component/tree/Tree.d.ts +17 -1
  174. package/dist/lib/types/component/tree/index.d.ts +1 -1
  175. package/dist/lib/types/core/AnimatedDropdown.d.ts +0 -9
  176. package/dist/lib/types/core/Body.d.ts +4 -0
  177. package/dist/lib/types/core/ClassStyleRules.d.ts +1 -0
  178. package/dist/lib/types/core/DOM.d.ts +10 -0
  179. package/dist/lib/types/core/Event.d.ts +11 -2
  180. package/dist/lib/types/core/OverlayFade.d.ts +12 -0
  181. package/dist/lib/types/core/OverlayPosition.d.ts +6 -0
  182. package/dist/lib/types/core/Theme.d.ts +8 -0
  183. package/dist/lib/types/core/index.d.ts +5 -3
  184. package/dist/lib/types/data/AbstractStore.d.ts +3 -0
  185. package/dist/lib/types/data/FilterDescriptor.d.ts +13 -0
  186. package/dist/lib/types/data/index.d.ts +2 -1
  187. package/dist/lib/types/data/temporalText.d.ts +2 -0
  188. package/dist/lib/types/layout/BoxLayout.d.ts +6 -1
  189. package/dist/lib/types/layout/Grid.d.ts +1 -0
  190. package/dist/lib/types/layout/HFlow.d.ts +1 -1
  191. package/dist/lib/types/layout/Split.d.ts +10 -1
  192. package/dist/lib/types/layout/Tab.d.ts +7 -1
  193. package/dist/lib/types/layout/VFlow.d.ts +1 -1
  194. package/dist/lib/types/layout/index.d.ts +1 -1
  195. package/dist/lib/types/overlay/Dock.d.ts +1 -0
  196. package/dist/lib/types/overlay/Menu.d.ts +1 -1
  197. package/dist/lib/types/overlay/Popover.d.ts +3 -0
  198. package/dist/lib/types/overlay/PopupPanel.d.ts +17 -0
  199. package/dist/lib/types/overlay/Window.d.ts +2 -0
  200. package/dist/lib/types/overlay/index.d.ts +2 -0
  201. package/dist/lib/types/router/RoutePattern.d.ts +7 -0
  202. package/dist/lib/types/router/Router.d.ts +6 -2
  203. package/dist/lib/types/router/index.d.ts +1 -1
  204. package/dist/lib/validation.es.js +1 -1
  205. package/llms.txt +4 -0
  206. package/package.json +1 -1
  207. package/dist/lib/AbstractBooleanInput-CbW7ZrDT.js +0 -2
  208. package/dist/lib/AbstractBooleanInput-CbW7ZrDT.js.map +0 -1
  209. package/dist/lib/Anchor-BsblS5it.js +0 -2
  210. package/dist/lib/Anchor-BsblS5it.js.map +0 -1
  211. package/dist/lib/AnimatedDropdown-kL47HPGP.js +0 -2
  212. package/dist/lib/AnimatedDropdown-kL47HPGP.js.map +0 -1
  213. package/dist/lib/Border-CNS6aEXB.js +0 -2
  214. package/dist/lib/Border-CNS6aEXB.js.map +0 -1
  215. package/dist/lib/Button-T16zSZip.js +0 -2
  216. package/dist/lib/Button-T16zSZip.js.map +0 -1
  217. package/dist/lib/CodeEditor-BGlB232h.js.map +0 -1
  218. package/dist/lib/ComboBox-C9FYMuLv.js +0 -2
  219. package/dist/lib/ComboBox-C9FYMuLv.js.map +0 -1
  220. package/dist/lib/Component-w65rPK75.js +0 -2
  221. package/dist/lib/Component-w65rPK75.js.map +0 -1
  222. package/dist/lib/Container-C7RPLQEc.js +0 -2
  223. package/dist/lib/DOM-Ba8YRVel.js.map +0 -1
  224. package/dist/lib/DragManager-UvPHSoRm.js +0 -2
  225. package/dist/lib/DragManager-UvPHSoRm.js.map +0 -1
  226. package/dist/lib/Grid-BYBohJIA.js.map +0 -1
  227. package/dist/lib/GridConstraints-Bts284FI.js +0 -2
  228. package/dist/lib/LayoutSerialization-ySzY1h2l.js +0 -2
  229. package/dist/lib/LayoutSerialization-ySzY1h2l.js.map +0 -1
  230. package/dist/lib/LayoutSizes-DKDK1Cle.js +0 -2
  231. package/dist/lib/LayoutSizes-DKDK1Cle.js.map +0 -1
  232. package/dist/lib/List-BPd-IXZR.js +0 -2
  233. package/dist/lib/MemoryStore-BgP7-Uzn.js +0 -2
  234. package/dist/lib/MemoryStore-BgP7-Uzn.js.map +0 -1
  235. package/dist/lib/Menu-C0roOCY7.js +0 -2
  236. package/dist/lib/Menu-C0roOCY7.js.map +0 -1
  237. package/dist/lib/RadioButton-CCcIaL54.js +0 -2
  238. package/dist/lib/Scrollbar-C3ZZyZ1e.js +0 -2
  239. package/dist/lib/Scrollbar-C3ZZyZ1e.js.map +0 -1
  240. package/dist/lib/TabButton-DNo4ZgV8.js +0 -2
  241. package/dist/lib/TabButton-DNo4ZgV8.js.map +0 -1
  242. package/dist/lib/Tooltip-B_UF5bXD.js.map +0 -1
  243. package/dist/lib/Tree-C7qLbIYH.js +0 -2
  244. package/dist/lib/Tree-C7qLbIYH.js.map +0 -1
  245. package/dist/lib/VBox-32fxpkDl.js +0 -2
  246. package/dist/lib/VBox-32fxpkDl.js.map +0 -1
  247. package/dist/lib/VirtualScroller-cvFNMS7U.js +0 -2
  248. package/dist/lib/VirtualScroller-cvFNMS7U.js.map +0 -1
  249. package/dist/lib/assets/StoreWorker-CgOBYoai.js +0 -2
  250. package/dist/lib/assets/StoreWorker-CgOBYoai.js.map +0 -1
  251. package/dist/lib/selectionsEqual-BrTxPMmK.js +0 -2
  252. package/dist/lib/selectionsEqual-BrTxPMmK.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./Position-PBVBW1JS.js";import{t as c}from"./Placement-7kqdaK4Z.js";var Point=class extends t{_x;_y;constructor(e,t){super(),this._x=e??0,this._y=t??0}getX(){return this._x??0}getY(){return this._y??0}render(){return this.getX()+` `+this.getY()}};export{r as Insets,c as Placement,Point,s as Position,e as UNBOUNDED,a as borderSideWidth,n as borderToStyle,i as isUnbounded,o as saturate};
1
+ import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./Position-BwtxouxK.js";import{t as c}from"./Placement-7kqdaK4Z.js";var Point=class extends t{_x;_y;constructor(e,t){super(),this._x=e??0,this._y=t??0}getX(){return this._x??0}getY(){return this._y??0}render(){return this.getX()+` `+this.getY()}};export{r as Insets,c as Placement,Point,s as Position,e as UNBOUNDED,a as borderSideWidth,n as borderToStyle,i as isUnbounded,o as saturate};
2
2
  //# sourceMappingURL=primitive.es.js.map
@@ -1,2 +1,2 @@
1
- import{t as e}from"./DOM-Ba8YRVel.js";import{t}from"./ListenerBag-WPdKuuds.js";function normalizePath(e){let t=e.startsWith(`#`)?e.slice(1):e,n=t.indexOf(`?`);return n>=0&&(t=t.slice(0,n)),`/`+splitPath(t).join(`/`)}function splitPath(e){return e.split(`/`).filter(e=>e.length>0)}function splitFragment(e){let t=e.indexOf(`#`);return t===-1?{path:e,fragment:``}:{path:e.slice(0,t),fragment:e.slice(t+1)}}function normalizeBase(e){let t=splitPath(e);return t.length===0?`/`:`/`+t.join(`/`)+`/`}function stripBase(e,t){let n=normalizeBase(e).slice(0,-1);return n!==``&&(t===n||t.startsWith(n+`/`))?normalizePath(t.slice(n.length)):normalizePath(t)}function joinBase(e,t){let n=normalizeBase(e),r=normalizePath(t);return r===`/`?n:n.slice(0,-1)+r}function compilePattern(e){let t=normalizePath(e),n=splitPath(t),r=n.map((t,r)=>{if(t===`*`){if(r!==n.length-1)throw Error(`RoutePattern: "*" is only valid as the final segment of "${e}"`);return{kind:`catchAll`,value:``}}return t.startsWith(`:`)?{kind:`param`,value:t.slice(1)}:{kind:`static`,value:t}});return{pattern:t,key:r.map(e=>e.kind===`static`?e.value:e.kind===`param`?`:`:`*`).join(`/`),segments:r}}function matchPattern(e,t){let n=e.segments,r=n.length>0&&n.at(-1).kind===`catchAll`,i=r?n.length-1:n.length;if(r?t.length<i:t.length!==i)return null;let a={};for(let e=0;e<i;e+=1){let r=n[e],i=t[e];if(r.kind===`static`){if(r.value!==i)return null}else r.kind===`param`&&(a[r.value]=decodeSegment(i))}return a}function decodeSegment(e){try{return decodeURIComponent(e)}catch{return e}}var n={static:2,param:1,catchAll:0};function rankAt(e,t){return t>=e.length?3:n[e[t].kind]}function selectPattern(e,t){let n=splitPath(t),r=null,i=null;for(let t of e){let e=matchPattern(t,n);e!==null&&(r===null||isMoreSpecific(t.segments,r.segments))&&(r=t,i=e)}return r===null?null:{compiled:r,params:i}}function isMoreSpecific(e,t){let n=Math.max(e.length,t.length);for(let r=0;r<n;r+=1){let n=rankAt(e,r),i=rankAt(t,r);if(n!==i)return n>i}return!1}var Router=class{_routes=new Map;_listeners=new t;_started=!1;_mode;_base;_onHashChange=()=>this.handleHashChange();_onPopState=()=>this.handlePopState();constructor(e){this.applyOptions(e??{})}register(e,t){let n=compilePattern(e),r=this._routes.get(n.key);return r!==void 0&&r.pattern!==n.pattern&&console.warn(`Router: "${r.pattern}" and "${n.pattern}" have the same specificity; "${n.pattern}" replaces it.`),this._routes.set(n.key,{...n,handler:t}),this}start(){return this._started?(console.warn(`Router: start() called on an already-started router; ignoring.`),this):(this._started=!0,this.applyCurrentRoute(),this._mode===`history`?e.sink.addListener(e.source.getWindow(),`popstate`,this._onPopState):e.sink.addListener(e.source.getWindow(),`hashchange`,this._onHashChange),this)}stop(){return this._started?(this._mode===`history`?e.sink.removeListener(e.source.getWindow(),`popstate`,this._onPopState):e.sink.removeListener(e.source.getWindow(),`hashchange`,this._onHashChange),this._started=!1,this):this}navigate(t,n){let r=splitFragment(t);if(this._mode===`hash`){let t=`#/`+splitPath(normalizePath(r.path)).map(e=>encodeURIComponent(e)).join(`/`);return n?.replace===!0?e.sink.replaceLocationHash(t):e.sink.setLocationHash(t),this}let i=normalizePath(r.path),a=r.fragment;if(i===this.getPath()&&a===this.getFragment())return this;let o=this.getHref(a===``?i:`${i}#${a}`);return n?.replace===!0?e.sink.replaceHistoryPath(o):e.sink.pushHistoryPath(o),this.applyCurrentRoute(),this}getHref(e){let t=splitFragment(e),n=`/`+splitPath(normalizePath(t.path)).map(e=>encodeURIComponent(e)).join(`/`);if(this._mode===`hash`)return`#`+n;let r=joinBase(this._base,n);return t.fragment===``?r:`${r}#${t.fragment}`}getPath(t){if(this._mode===`hash`){let n=t??e.source.getLocationHash();return this.decodePath(normalizePath(n))}let n=t??e.source.getLocationPathname();return this.decodePath(stripBase(this._base,splitFragment(n).path))}getFragment(t){if(this._mode===`hash`)return``;if(t!==void 0)return splitFragment(t).fragment;let n=e.source.getLocationHash();return n.startsWith(`#`)?n.slice(1):n}decodePath(e){return`/`+splitPath(e).map(e=>{try{return decodeURIComponent(e)}catch{return e}}).join(`/`)}on(e,t){return this._listeners.add(e,t),this}off(e,t){return this._listeners.remove(e,t),this}emit(e,t){this._listeners.fire(e,t)}applyCurrentRoute(){let e=this.getPath(),t=this.getFragment(),n=selectPattern(Array.from(this._routes.values()),e);if(n===null){this.emit(`nomatch`,e);return}let r={pattern:n.compiled.pattern,params:n.params,path:e,fragment:t};n.compiled.handler(n.params,e,t),this.emit(`navigate`,r)}applyOptions(e){if(this._mode=e.mode??`hash`,this._base=normalizeBase(e.base??`/`),e.routes!==void 0)for(let t of Object.keys(e.routes))this.register(t,e.routes[t]);if(e.listeners!==void 0)for(let t of Object.keys(e.listeners)){let n=e.listeners[t];n!==void 0&&this._listeners.add(t,n)}}handleHashChange(){this.applyCurrentRoute()}handlePopState(){this.applyCurrentRoute()}};export{Router};
1
+ import{t as e}from"./DOM-C-Edb3tA.js";import{t}from"./ListenerBag-WPdKuuds.js";function normalizePath(e){return`/`+splitPath(splitQuery(e.startsWith(`#`)?e.slice(1):e).path).join(`/`)}function splitPath(e){return e.split(`/`).filter(e=>e.length>0)}function splitFragment(e){let t=e.indexOf(`#`);return t===-1?{path:e,fragment:``}:{path:e.slice(0,t),fragment:e.slice(t+1)}}function splitQuery(e){let t=e.indexOf(`?`);return t===-1?{path:e,query:``}:{path:e.slice(0,t),query:e.slice(t+1)}}function parseQuery(e){let t=e.startsWith(`?`)?e.slice(1):e,n={};for(let e of t.split(`&`)){if(e.length===0)continue;let t=e.indexOf(`=`),r=t===-1?e:e.slice(0,t),i=t===-1?``:e.slice(t+1),a=decodeSegment(r);a.length!==0&&(n[a]=decodeSegment(i))}return n}function formatQuery(e){return Object.keys(e).map(t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`).join(`&`)}function sameQuery(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])}function normalizeBase(e){let t=splitPath(e);return t.length===0?`/`:`/`+t.join(`/`)+`/`}function stripBase(e,t){let n=normalizeBase(e).slice(0,-1);return n!==``&&(t===n||t.startsWith(n+`/`))?normalizePath(t.slice(n.length)):normalizePath(t)}function joinBase(e,t){let n=normalizeBase(e),r=normalizePath(t);return r===`/`?n:n.slice(0,-1)+r}function compilePattern(e){let t=normalizePath(e),n=splitPath(t),r=n.map((t,r)=>{if(t===`*`){if(r!==n.length-1)throw Error(`RoutePattern: "*" is only valid as the final segment of "${e}"`);return{kind:`catchAll`,value:``}}return t.startsWith(`:`)?{kind:`param`,value:t.slice(1)}:{kind:`static`,value:t}});return{pattern:t,key:r.map(e=>e.kind===`static`?e.value:e.kind===`param`?`:`:`*`).join(`/`),segments:r}}function matchPattern(e,t){let n=e.segments,r=n.length>0&&n.at(-1).kind===`catchAll`,i=r?n.length-1:n.length;if(r?t.length<i:t.length!==i)return null;let a={};for(let e=0;e<i;e+=1){let r=n[e],i=t[e];if(r.kind===`static`){if(r.value!==i)return null}else r.kind===`param`&&(a[r.value]=decodeSegment(i))}return a}function decodeSegment(e){try{return decodeURIComponent(e)}catch{return e}}var n={static:2,param:1,catchAll:0};function rankAt(e,t){return t>=e.length?3:n[e[t].kind]}function selectPattern(e,t){let n=splitPath(t),r=null,i=null;for(let t of e){let e=matchPattern(t,n);e!==null&&(r===null||isMoreSpecific(t.segments,r.segments))&&(r=t,i=e)}return r===null?null:{compiled:r,params:i}}function isMoreSpecific(e,t){let n=Math.max(e.length,t.length);for(let r=0;r<n;r+=1){let n=rankAt(e,r),i=rankAt(t,r);if(n!==i)return n>i}return!1}var Router=class{_routes=new Map;_listeners=new t;_started=!1;_mode;_base;_onHashChange=()=>this.handleHashChange();_onPopState=()=>this.handlePopState();constructor(e){this.applyOptions(e??{})}register(e,t){let n=compilePattern(e),r=this._routes.get(n.key);return r!==void 0&&r.pattern!==n.pattern&&console.warn(`Router: "${r.pattern}" and "${n.pattern}" have the same specificity; "${n.pattern}" replaces it.`),this._routes.set(n.key,{...n,handler:t}),this}start(){return this._started?(console.warn(`Router: start() called on an already-started router; ignoring.`),this):(this._started=!0,this.applyCurrentRoute(),this._mode===`history`?e.sink.addListener(e.source.getWindow(),`popstate`,this._onPopState):e.sink.addListener(e.source.getWindow(),`hashchange`,this._onHashChange),this)}stop(){return this._started?(this._mode===`history`?e.sink.removeListener(e.source.getWindow(),`popstate`,this._onPopState):e.sink.removeListener(e.source.getWindow(),`hashchange`,this._onHashChange),this._started=!1,this):this}navigate(t,n){let r=splitFragment(t),i=splitQuery(r.path),a=n?.query??parseQuery(i.query);if(this._mode===`hash`){let r=this.getHref(t,a);return n?.replace===!0?e.sink.replaceLocationHash(r):e.sink.setLocationHash(r),this}let o=normalizePath(i.path),s=r.fragment;if(o===this.getPath()&&s===this.getFragment()&&sameQuery(a,this.getQuery()))return this;let c=this.getHref(s===``?o:`${o}#${s}`,a);return n?.replace===!0?e.sink.replaceHistoryPath(c):e.sink.pushHistoryPath(c),this.applyCurrentRoute(),this}getHref(e,t){let n=splitFragment(e),r=splitQuery(n.path),i=t??parseQuery(r.query),a=`/`+splitPath(normalizePath(r.path)).map(e=>encodeURIComponent(e)).join(`/`),o=formatQuery(i),s=o===``?``:`?`+o;if(this._mode===`hash`)return`#`+a+s;let c=joinBase(this._base,a)+s;return n.fragment===``?c:`${c}#${n.fragment}`}getPath(t){if(this._mode===`hash`){let n=t??e.source.getLocationHash();return this.decodePath(normalizePath(n))}let n=t??e.source.getLocationPathname();return this.decodePath(stripBase(this._base,splitFragment(n).path))}getFragment(t){if(this._mode===`hash`)return``;if(t!==void 0)return splitFragment(t).fragment;let n=e.source.getLocationHash();return n.startsWith(`#`)?n.slice(1):n}getQuery(t){return this._mode===`hash`?parseQuery(splitQuery(t??e.source.getLocationHash()).query):parseQuery(t===void 0?e.source.getLocationSearch():splitQuery(splitFragment(t).path).query)}decodePath(e){return`/`+splitPath(e).map(e=>{try{return decodeURIComponent(e)}catch{return e}}).join(`/`)}on(e,t){return this._listeners.add(e,t),this}off(e,t){return this._listeners.remove(e,t),this}emit(e,t){this._listeners.fire(e,t)}applyCurrentRoute(){let e=this.getPath(),t=this.getFragment(),n=this.getQuery(),r=selectPattern(Array.from(this._routes.values()),e);if(r===null){this.emit(`nomatch`,e);return}let i={pattern:r.compiled.pattern,params:r.params,path:e,fragment:t,query:n};r.compiled.handler(r.params,e,t,n),this.emit(`navigate`,i)}applyOptions(e){if(this._mode=e.mode??`hash`,this._base=normalizeBase(e.base??`/`),e.routes!==void 0)for(let t of Object.keys(e.routes))this.register(t,e.routes[t]);if(e.listeners!==void 0)for(let t of Object.keys(e.listeners)){let n=e.listeners[t];n!==void 0&&this._listeners.add(t,n)}}handleHashChange(){this.applyCurrentRoute()}handlePopState(){this.applyCurrentRoute()}};export{Router};
2
2
  //# sourceMappingURL=router.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"router.es.js","names":[],"sources":["../../src/typescript/lib/router/RoutePattern.ts","../../src/typescript/lib/router/Router.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\n// Pure route-pattern mechanics behind Router: normalizing a hash/path,\n// compiling a registered pattern into segments + an ambiguity key, matching a\n// path against a compiled pattern, and picking the most specific match. No\n// DOM seam involved — internal to router/, not exported from the barrel.\n\n/** The kind of a single pattern segment. */\nexport type SegmentKind = \"static\" | \"param\" | \"catchAll\";\n\n/** One segment of a compiled pattern. */\nexport interface RouteSegment {\n kind: SegmentKind;\n /** Literal text for \"static\", the parameter name for \"param\", \"\" for \"catchAll\". */\n value: string;\n}\n\n/** A pattern parsed into segments, plus its ambiguity key. */\nexport interface CompiledPattern {\n /** The pattern string as registered, after normalization (e.g. \"/data/:id\"). */\n pattern: string;\n /** Ambiguity key: static segments by literal, \"param\" as \":\", \"catchAll\" as \"*\". */\n key: string;\n segments: RouteSegment[];\n}\n\n/**\n * Normalizes a hash or path to a leading-slash, no-trailing-slash path: strips\n * a leading `\"#\"`, discards everything from the first `\"?\"` onward, and\n * collapses empty segments (so a doubled `\"//\"` and a trailing `\"/\"` both\n * disappear). `\"\"`, `\"#\"`, and `\"#/\"` all normalize to `\"/\"`.\n *\n * @param input - The raw hash (with or without its leading `\"#\"`) or path.\n * @returns The normalized path.\n */\nexport function normalizePath(input: string): string {\n let path = input.startsWith(\"#\") ? input.slice(1) : input;\n const queryIndex = path.indexOf(\"?\");\n\n if (queryIndex >= 0) {\n path = path.slice(0, queryIndex);\n }\n\n return \"/\" + splitPath(path).join(\"/\");\n}\n\n/**\n * Splits a normalized path into its non-empty segments.\n *\n * @param path - The path to split.\n * @returns The segments, in order.\n */\nexport function splitPath(path: string): string[] {\n return path.split(\"/\").filter((segment) => segment.length > 0);\n}\n\n/**\n * Splits a URL-ish string at its first `\"#\"`: the part before, and the\n * fragment without its `\"#\"`. Everything after the first `\"#\"` is the\n * fragment verbatim — a second `\"#\"` in the input stays part of it. Never\n * normalizes either half; the caller runs `path` through {@link normalizePath}.\n *\n * @param input - The raw href or path, with or without a fragment.\n * @returns The part before the first `\"#\"`, and the fragment without it.\n */\nexport function splitFragment(input: string): { path: string; fragment: string } {\n const hashIndex = input.indexOf(\"#\");\n\n if (hashIndex === -1) {\n return { path: input, fragment: \"\" };\n }\n\n return { path: input.slice(0, hashIndex), fragment: input.slice(hashIndex + 1) };\n}\n\n/**\n * Normalizes a base to leading-and-trailing-slash form, so\n * {@link stripBase} and {@link joinBase} can both assume that shape.\n * `\"\"`, `\"/\"`, `\"x\"`, `\"/x\"`, and `\"/x/\"` all become `\"/\"` or `\"/x/\"`.\n *\n * @param base - The raw base path.\n * @returns The normalized base.\n */\nexport function normalizeBase(base: string): string {\n const segments = splitPath(base);\n\n return segments.length === 0 ? \"/\" : \"/\" + segments.join(\"/\") + \"/\";\n}\n\n/**\n * Removes `base` from the front of `pathname`, then normalizes what is\n * left through {@link normalizePath}. A `pathname` that does not start with\n * `base` is normalized as-is rather than rejected.\n *\n * @param base - The site base, in any shape {@link normalizeBase} accepts.\n * @param pathname - The URL path to strip the base from.\n * @returns The normalized path with `base` removed.\n */\nexport function stripBase(base: string, pathname: string): string {\n const normalizedBase = normalizeBase(base);\n // Base without its trailing slash, e.g. \"/typescript-ui\" (\"\" at the root).\n const basePrefix = normalizedBase.slice(0, -1);\n\n if (basePrefix !== \"\" && (pathname === basePrefix || pathname.startsWith(basePrefix + \"/\"))) {\n return normalizePath(pathname.slice(basePrefix.length));\n }\n\n return normalizePath(pathname);\n}\n\n/**\n * Joins a normalized base and a normalized path into a URL path — the\n * inverse of {@link stripBase}.\n *\n * @param base - The site base, in any shape {@link normalizeBase} accepts.\n * @param path - The route path, in any shape {@link normalizePath} accepts.\n * @returns The joined URL path.\n */\nexport function joinBase(base: string, path: string): string {\n const normalizedBase = normalizeBase(base);\n const normalizedPath = normalizePath(path);\n\n if (normalizedPath === \"/\") {\n return normalizedBase;\n }\n\n return normalizedBase.slice(0, -1) + normalizedPath;\n}\n\n/**\n * Parses a registered pattern into {@link RouteSegment}s and derives its\n * ambiguity key.\n *\n * @param pattern - The pattern string, e.g. `\"/data/rows/:sel\"`.\n * @returns The compiled pattern.\n * @throws If `\"*\"` appears anywhere but the final segment.\n */\nexport function compilePattern(pattern: string): CompiledPattern {\n const normalized = normalizePath(pattern);\n const rawSegments = splitPath(normalized);\n\n const segments: RouteSegment[] = rawSegments.map((raw, i) => {\n if (raw === \"*\") {\n if (i !== rawSegments.length - 1) {\n throw new Error(`RoutePattern: \"*\" is only valid as the final segment of \"${pattern}\"`);\n }\n\n return { kind: \"catchAll\", value: \"\" };\n }\n\n if (raw.startsWith(\":\")) {\n return { kind: \"param\", value: raw.slice(1) };\n }\n\n return { kind: \"static\", value: raw };\n });\n\n const key = segments\n .map((segment) => segment.kind === \"static\" ? segment.value : segment.kind === \"param\" ? \":\" : \"*\")\n .join(\"/\");\n\n return { pattern: normalized, key, segments };\n}\n\n/**\n * Returns the extracted params when `segments` match `compiled`, or `null`\n * when they don't. A trailing `catchAll` segment matches zero or more\n * remaining segments; every other kind requires an exact segment count.\n * Captured `:param` values run through `decodeURIComponent`, falling back to\n * the raw segment text on a malformed escape.\n *\n * @param compiled - The compiled pattern to match against.\n * @param segments - The candidate path's segments (from {@link splitPath}).\n * @returns The extracted params, or `null` when there is no match.\n */\nexport function matchPattern(compiled: CompiledPattern, segments: string[]): Record<string, string> | null {\n const patternSegments = compiled.segments;\n const isCatchAll = patternSegments.length > 0 && patternSegments.at(-1)!.kind === \"catchAll\";\n const staticLength = isCatchAll ? patternSegments.length - 1 : patternSegments.length;\n\n if (isCatchAll ? segments.length < staticLength : segments.length !== staticLength) {\n return null;\n }\n\n const params: Record<string, string> = {};\n\n for (let i = 0; i < staticLength; i += 1) {\n const patternSegment = patternSegments[i];\n const value = segments[i];\n\n if (patternSegment.kind === \"static\") {\n if (patternSegment.value !== value) {\n return null;\n }\n } else if (patternSegment.kind === \"param\") {\n params[patternSegment.value] = decodeSegment(value);\n }\n }\n\n return params;\n}\n\n/**\n * Decodes a captured path segment, falling back to the raw text when it\n * carries a malformed percent-escape.\n *\n * @param value - The raw segment text.\n * @returns The decoded value, or `value` unchanged on a decode failure.\n */\nfunction decodeSegment(value: string): string {\n try {\n return decodeURIComponent(value);\n } catch {\n return value;\n }\n}\n\n/** Rank of each real segment kind: higher wins a specificity tie-break. */\nconst KIND_RANK: Record<SegmentKind, number> = { static: 2, param: 1, catchAll: 0 };\n\n/**\n * Rank of position `i` in `segments`. Reaching the end of the pattern (`i` at\n * or past its length) outranks every real segment kind — see\n * {@link selectPattern}.\n *\n * @param segments - The pattern's segments.\n * @param i - The position to rank.\n * @returns The rank at that position.\n */\nfunction rankAt(segments: readonly RouteSegment[], i: number): number {\n return i >= segments.length ? 3 : KIND_RANK[segments[i].kind];\n}\n\n/**\n * Returns the highest-ranked pattern in `compiled` that matches `path`, or\n * `null` when none match. Patterns are compared segment by segment from the\n * left via {@link rankAt}; the first position where two matching patterns\n * differ decides the winner. Two patterns can never tie on every position —\n * that would mean identical ambiguity keys, which the route table (see\n * `Router`) forbids. Registration order never affects the result.\n *\n * @param compiled - The candidate compiled patterns.\n * @param path - The normalized path to match.\n * @returns The winning pattern and its extracted params, or `null`.\n */\nexport function selectPattern<T extends CompiledPattern>(\n compiled: readonly T[],\n path: string,\n): { compiled: T; params: Record<string, string> } | null {\n const segments = splitPath(path);\n\n let best: T | null = null;\n let bestParams: Record<string, string> | null = null;\n\n for (const candidate of compiled) {\n const params = matchPattern(candidate, segments);\n\n if (params === null) {\n continue;\n }\n\n if (best === null || isMoreSpecific(candidate.segments, best.segments)) {\n best = candidate;\n bestParams = params;\n }\n }\n\n return best === null ? null : { compiled: best, params: bestParams! };\n}\n\n/**\n * Whether `a` outranks `b` by {@link rankAt} at the first position where they\n * differ.\n *\n * @param a - The candidate pattern's segments.\n * @param b - The current best pattern's segments.\n * @returns `true` when `a` is more specific than `b`.\n */\nfunction isMoreSpecific(a: readonly RouteSegment[], b: readonly RouteSegment[]): boolean {\n const length = Math.max(a.length, b.length);\n\n for (let i = 0; i < length; i += 1) {\n const rankA = rankAt(a, i);\n const rankB = rankAt(b, i);\n\n if (rankA !== rankB) {\n return rankA > rankB;\n }\n }\n\n return false;\n}\n","// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { DOM } from '~/core/DOM.js';\nimport { ListenerBag } from '~/core/ListenerBag.js';\nimport { compilePattern, normalizePath, splitPath, splitFragment, selectPattern, normalizeBase, stripBase, joinBase, type CompiledPattern } from '~/router/RoutePattern.js';\n\n/** Params extracted from a matched pattern's `:name` segments. */\nexport type RouteParams = Record<string, string>;\n\n/** A registered route's callback: drives whatever it fronts, never builds it. */\nexport type RouteHandler = (params: RouteParams, path: string, fragment: string) => void;\n\n/** The events a {@link Router} emits. */\nexport type RouterEvent = \"navigate\" | \"nomatch\";\n\n/** Where a {@link Router} reads and writes the route: the URL hash, or the path. */\nexport type RouterMode = \"hash\" | \"history\";\n\n/** The pattern and params a navigation resolved to. */\nexport interface RouteMatch {\n /** The pattern that won, as registered. */\n pattern: string;\n params: RouteParams;\n /** The normalized path that was matched. */\n path: string;\n /** The URL fragment without its `\"#\"`, or `\"\"` when there is none. Always `\"\"` in hash mode. */\n fragment: string;\n}\n\n/** Construction options for {@link Router}. */\nexport interface RouterOptions {\n /** Defaults to `\"hash\"`. */\n mode?: RouterMode;\n /** Path prefix the site is served under, e.g. `\"/typescript-ui/\"`. History mode only; defaults to `\"/\"`. */\n base?: string;\n /** Patterns to `register` at construction, keyed by pattern string. */\n routes?: Record<string, RouteHandler>;\n listeners?: Partial<{\n navigate: (match: RouteMatch) => void;\n nomatch: (path: string) => void;\n }>;\n}\n\n/** A registered route: its compiled pattern plus the handler it drives. */\ntype CompiledRoute = CompiledPattern & { handler: RouteHandler };\n\n/**\n * Maps the URL hash or path to a single top-level app section. Patterns are\n * registered with {@link register} (e.g. `\"/data/rows/:sel\"`); on a\n * navigation, the router selects the most specific matching pattern, extracts\n * its `:param` values, and calls that pattern's handler — the handler drives\n * components that already exist, it never builds them.\n *\n * {@link start} reads the current hash or path, applies the matching route\n * synchronously, then installs the `hashchange` (or, in History mode,\n * `popstate`) listener; call it once the app has built its component tree\n * and before the first layout pass runs, so the routed section is already\n * selected when that pass runs. {@link stop} removes the listener.\n *\n * It is a plain class (no DOM element, so not `callable()`-wrapped) — it\n * follows the shape of a data store: an options bag, a private listener bag,\n * and typed `on` / `off` / `emit` forwarders.\n *\n * @category Core\n */\nexport class Router {\n\n private _routes: Map<string, CompiledRoute> = new Map();\n private _listeners: ListenerBag<RouterEvent> = new ListenerBag<RouterEvent>();\n private _started: boolean = false;\n // Set once in applyOptions and never reassigned after — construction-only,\n // like the compiled route table. Not `readonly`: strictPropertyInitialization\n // rejects a readonly field assigned from a method the constructor merely calls.\n private _mode!: RouterMode;\n private _base!: string;\n\n // Stable references so add/remove pair up; each delegates to a named method.\n private readonly _onHashChange: () => void = () => this.handleHashChange();\n private readonly _onPopState: () => void = () => this.handlePopState();\n\n /**\n * @param options - Routes and listeners to register at construction.\n */\n constructor(options?: RouterOptions) {\n this.applyOptions(options ?? {});\n }\n\n /**\n * Registers a pattern's handler. Re-registering the exact same pattern\n * string replaces its handler silently. Registering a *different*\n * pattern string that collides with an already-registered one on\n * specificity (e.g. `\"/users/:id\"` and `\"/users/:name\"`) replaces it too,\n * but logs a warning naming both patterns — that collision usually\n * signals an authoring mistake.\n *\n * @param pattern - The route pattern, e.g. `\"/data/rows/:sel\"`.\n * @param handler - Called with the extracted params and the normalized\n * path when this pattern wins a navigation.\n * @returns This router, for chaining.\n */\n register(pattern: string, handler: RouteHandler): this {\n const compiled = compilePattern(pattern);\n const existing = this._routes.get(compiled.key);\n\n if (existing !== undefined && existing.pattern !== compiled.pattern) {\n console.warn(`Router: \"${existing.pattern}\" and \"${compiled.pattern}\" have the same specificity; \"${compiled.pattern}\" replaces it.`);\n }\n\n this._routes.set(compiled.key, { ...compiled, handler });\n\n return this;\n }\n\n /**\n * Reads the current hash or path, applies the matching route\n * synchronously, then installs the `hashchange` (hash mode) or\n * `popstate` (History mode) listener. Calling `start()` again on an\n * already-started router logs a warning and is otherwise a no-op — it\n * does not install a second listener.\n *\n * @returns This router, for chaining.\n */\n start(): this {\n if (this._started) {\n console.warn(`Router: start() called on an already-started router; ignoring.`);\n\n return this;\n }\n\n this._started = true;\n this.applyCurrentRoute();\n\n if (this._mode === \"history\") {\n DOM.sink.addListener(DOM.source.getWindow(), \"popstate\", this._onPopState);\n } else {\n DOM.sink.addListener(DOM.source.getWindow(), \"hashchange\", this._onHashChange);\n }\n\n return this;\n }\n\n /**\n * Removes the `hashchange` (hash mode) or `popstate` (History mode)\n * listener. Safe to call when never started, or more than once.\n *\n * @returns This router, for chaining.\n */\n stop(): this {\n if (!this._started) {\n return this;\n }\n\n if (this._mode === \"history\") {\n DOM.sink.removeListener(DOM.source.getWindow(), \"popstate\", this._onPopState);\n } else {\n DOM.sink.removeListener(DOM.source.getWindow(), \"hashchange\", this._onHashChange);\n }\n\n this._started = false;\n\n return this;\n }\n\n /**\n * Navigates to `path` — pushing a history entry, or replacing the\n * current one when `options.replace` is `true`. In hash mode this writes\n * the hash, discarding any `#fragment` in `path` (the `#` is already\n * spent on the route); in History mode this writes `location.pathname`\n * and `location.hash` via `pushState` / `replaceState` and — since\n * neither fires an event — applies the matching route itself. Either\n * way, navigating to the path (and, in History mode, fragment) already\n * current is a same-value write: no history entry is written and no\n * handler re-runs.\n *\n * @param path - The path to navigate to, e.g. `\"/settings\"` or, in\n * History mode, `\"/settings#section\"`.\n * @param options - `replace` to replace the current history entry instead\n * of pushing a new one.\n * @returns This router, for chaining.\n */\n navigate(path: string, options?: { replace?: boolean }): this {\n const split = splitFragment(path);\n\n if (this._mode === \"hash\") {\n const segments = splitPath(normalizePath(split.path));\n const hash = \"#/\" + segments.map((segment) => encodeURIComponent(segment)).join(\"/\");\n\n if (options?.replace === true) {\n DOM.sink.replaceLocationHash(hash);\n } else {\n DOM.sink.setLocationHash(hash);\n }\n\n return this;\n }\n\n const target = normalizePath(split.path);\n const fragment = split.fragment;\n\n if (target === this.getPath() && fragment === this.getFragment()) {\n return this;\n }\n\n const url = this.getHref(fragment === \"\" ? target : `${target}#${fragment}`);\n\n if (options?.replace === true) {\n DOM.sink.replaceHistoryPath(url);\n } else {\n DOM.sink.pushHistoryPath(url);\n }\n\n this.applyCurrentRoute(); // pushState/replaceState fire no event; apply it ourselves\n\n return this;\n }\n\n /**\n * The href an `<a>` for `path` should carry, in this router's mode and\n * base: a `\"#/…\"` fragment in hash mode, a base-joined path in History\n * mode. Each segment is percent-encoded. A `#fragment` in `path` is\n * dropped first and, in History mode only, re-appended verbatim\n * (unencoded, so it keeps matching a heading `id`) after the encoded\n * path — hash mode has nowhere to put it, since its own `#` is already\n * spent on the route.\n *\n * @param path - The route path to format, e.g. `\"/guide/installation\"`\n * or, in History mode, `\"/guide/installation#section\"`.\n * @returns The formatted href.\n */\n getHref(path: string): string {\n const split = splitFragment(path);\n const segments = splitPath(normalizePath(split.path)).map((segment) => encodeURIComponent(segment));\n const encodedPath = \"/\" + segments.join(\"/\");\n\n if (this._mode === \"hash\") {\n return \"#\" + encodedPath;\n }\n\n const href = joinBase(this._base, encodedPath);\n\n return split.fragment === \"\" ? href : `${href}#${split.fragment}`;\n }\n\n /**\n * The route path for `href`, or — with no argument — for the current\n * URL. The inverse of {@link getHref}: percent-encoded segments are\n * decoded, and in History mode the base is stripped first and any\n * `#fragment` is split off before normalizing (see {@link getFragment}\n * to read it).\n *\n * @param href - The href to parse; defaults to the current hash (hash\n * mode) or `location.pathname` (History mode), read through the DOM seam.\n * @returns The normalized, decoded path, without a fragment.\n */\n getPath(href?: string): string {\n if (this._mode === \"hash\") {\n const raw = href ?? DOM.source.getLocationHash();\n\n return this.decodePath(normalizePath(raw));\n }\n\n const raw = href ?? DOM.source.getLocationPathname();\n\n return this.decodePath(stripBase(this._base, splitFragment(raw).path));\n }\n\n /**\n * The fragment for `href`, or — with no argument — for the current URL,\n * without its leading `\"#\"`. Always `\"\"` in hash mode, since the `#`\n * there is already spent on the route.\n *\n * @param href - The href to parse; defaults to the current\n * `location.hash`, read through the DOM seam.\n * @returns The fragment, or `\"\"` when there is none.\n */\n getFragment(href?: string): string {\n if (this._mode === \"hash\") {\n return \"\";\n }\n\n if (href !== undefined) {\n return splitFragment(href).fragment;\n }\n\n const hash = DOM.source.getLocationHash();\n\n return hash.startsWith(\"#\") ? hash.slice(1) : hash;\n }\n\n /**\n * Decodes each percent-encoded segment of an already-normalized path,\n * falling back to the raw segment text on a malformed escape.\n *\n * @param path - The normalized path to decode.\n * @returns The decoded path.\n */\n private decodePath(path: string): string {\n const segments = splitPath(path).map((segment) => {\n try {\n return decodeURIComponent(segment);\n } catch {\n return segment;\n }\n });\n\n return \"/\" + segments.join(\"/\");\n }\n\n on(event: \"navigate\", listener: (match: RouteMatch) => void): this;\n on(event: \"nomatch\", listener: (path: string) => void): this;\n\n /**\n * Subscribes a listener to a router event. Listeners fire in\n * registration order.\n *\n * @param event - The event to listen for.\n * @param listener - The callback to invoke.\n * @returns This router, for chaining.\n */\n on(event: RouterEvent, listener: Function): this {\n this._listeners.add(event, listener);\n\n return this;\n }\n\n /**\n * Removes a previously registered listener. No-op if it was never\n * registered for that event.\n *\n * @param event - The event the listener was registered for.\n * @param listener - The exact callback reference to remove.\n * @returns This router, for chaining.\n */\n off(event: RouterEvent, listener: Function): this {\n this._listeners.remove(event, listener);\n\n return this;\n }\n\n /**\n * Notifies all listeners registered for an event, in registration order.\n *\n * @param event - The event to emit.\n * @param payload - The value passed to each listener.\n */\n protected emit(event: RouterEvent, payload: unknown): void {\n this._listeners.fire(event, payload);\n }\n\n /**\n * Reads the current hash or path and calls the most specific matching\n * pattern's handler, emitting `\"navigate\"` — or emits `\"nomatch\"` when\n * nothing matches. Shared by {@link start}, the `hashchange` listener,\n * the `popstate` listener, and History-mode {@link navigate}.\n */\n private applyCurrentRoute(): void {\n const path = this.getPath();\n const fragment = this.getFragment();\n const result = selectPattern(Array.from(this._routes.values()), path);\n\n if (result === null) {\n this.emit(\"nomatch\", path);\n\n return;\n }\n\n const match: RouteMatch = { pattern: result.compiled.pattern, params: result.params, path, fragment };\n\n result.compiled.handler(result.params, path, fragment);\n this.emit(\"navigate\", match);\n }\n\n /**\n * Applies an {@link RouterOptions} bag: sets `mode` and `base`, registers\n * `routes`, then wires `listeners`. Called from the constructor body,\n * after every field initializer has run.\n *\n * @param options - The options bag to apply.\n */\n protected applyOptions(options: RouterOptions): void {\n this._mode = options.mode ?? \"hash\";\n this._base = normalizeBase(options.base ?? \"/\");\n\n if (options.routes !== undefined) {\n for (const pattern of Object.keys(options.routes)) {\n this.register(pattern, options.routes[pattern]);\n }\n }\n\n if (options.listeners !== undefined) {\n for (const event of Object.keys(options.listeners) as RouterEvent[]) {\n const listener = options.listeners[event];\n\n if (listener !== undefined) {\n this._listeners.add(event, listener);\n }\n }\n }\n }\n\n private handleHashChange(): void {\n this.applyCurrentRoute();\n }\n\n private handlePopState(): void {\n this.applyCurrentRoute();\n }\n}\n"],"mappings":"+EAmCA,SAAgB,cAAc,EAAuB,CACjD,IAAI,EAAO,EAAM,WAAW,GAAG,EAAI,EAAM,MAAM,CAAC,EAAI,EAC9C,EAAa,EAAK,QAAQ,GAAG,EAMnC,OAJI,GAAc,IACd,EAAO,EAAK,MAAM,EAAG,CAAU,GAG5B,IAAM,UAAU,CAAI,CAAC,CAAC,KAAK,GAAG,CACzC,CAQA,SAAgB,UAAU,EAAwB,CAC9C,OAAO,EAAK,MAAM,GAAG,CAAC,CAAC,OAAQ,GAAY,EAAQ,OAAS,CAAC,CACjE,CAWA,SAAgB,cAAc,EAAmD,CAC7E,IAAM,EAAY,EAAM,QAAQ,GAAG,EAMnC,OAJI,IAAc,GACP,CAAE,KAAM,EAAO,SAAU,EAAG,EAGhC,CAAE,KAAM,EAAM,MAAM,EAAG,CAAS,EAAG,SAAU,EAAM,MAAM,EAAY,CAAC,CAAE,CACnF,CAUA,SAAgB,cAAc,EAAsB,CAChD,IAAM,EAAW,UAAU,CAAI,EAE/B,OAAO,EAAS,SAAW,EAAI,IAAM,IAAM,EAAS,KAAK,GAAG,EAAI,GACpE,CAWA,SAAgB,UAAU,EAAc,EAA0B,CAG9D,IAAM,EAFiB,cAAc,CAElB,CAAA,CAAe,MAAM,EAAG,EAAE,EAM7C,OAJI,IAAe,KAAO,IAAa,GAAc,EAAS,WAAW,EAAa,GAAG,GAC9E,cAAc,EAAS,MAAM,EAA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,EAE/B,IACX,CAQA,KAAe,EAAoB,EAAwB,CACvD,KAAK,WAAW,KAAK,EAAO,CAAO,CACvC,CAQA,mBAAkC,CAC9B,IAAM,EAAW,KAAK,QAAQ,EACxB,EAAW,KAAK,YAAY,EAC5B,EAAW,cAAc,MAAM,KAAK,KAAK,QAAQ,OAAO,CAAC,EAAG,CAAI,EAEtE,GAAI,IAAW,KAAM,CACjB,KAAK,KAAK,UAAW,CAAI,EAEzB,MACJ,CAEA,IAAM,EAAoB,CAAE,QAAS,EAAO,SAAS,QAAS,OAAQ,EAAO,OAAQ,OAAM,UAAS,EAEpG,EAAO,SAAS,QAAQ,EAAO,OAAQ,EAAM,CAAQ,EACrD,KAAK,KAAK,WAAY,CAAK,CAC/B,CASA,aAAuB,EAA8B,CAIjD,GAHA,KAAK,MAAQ,EAAQ,MAAQ,OAC7B,KAAK,MAAQ,cAAc,EAAQ,MAAQ,GAAG,EAE1C,EAAQ,SAAW,IAAA,GACnB,IAAK,IAAM,KAAW,OAAO,KAAK,EAAQ,MAAM,EAC5C,KAAK,SAAS,EAAS,EAAQ,OAAO,EAAQ,EAItD,GAAI,EAAQ,YAAc,IAAA,GACtB,IAAK,IAAM,KAAS,OAAO,KAAK,EAAQ,SAAS,EAAoB,CACjE,IAAM,EAAW,EAAQ,UAAU,GAE/B,IAAa,IAAA,IACb,KAAK,WAAW,IAAI,EAAO,CAAQ,CAE3C,CAER,CAEA,kBAAiC,CAC7B,KAAK,kBAAkB,CAC3B,CAEA,gBAA+B,CAC3B,KAAK,kBAAkB,CAC3B,CACJ"}
1
+ {"version":3,"file":"router.es.js","names":[],"sources":["../../src/typescript/lib/router/RoutePattern.ts","../../src/typescript/lib/router/Router.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\n// Pure route-pattern mechanics behind Router: normalizing a hash/path,\n// compiling a registered pattern into segments + an ambiguity key, matching a\n// path against a compiled pattern, and picking the most specific match. No\n// DOM seam involved — internal to router/, not exported from the barrel.\n\n/** The kind of a single pattern segment. */\nexport type SegmentKind = \"static\" | \"param\" | \"catchAll\";\n\n/** One segment of a compiled pattern. */\nexport interface RouteSegment {\n kind: SegmentKind;\n /** Literal text for \"static\", the parameter name for \"param\", \"\" for \"catchAll\". */\n value: string;\n}\n\n/** A pattern parsed into segments, plus its ambiguity key. */\nexport interface CompiledPattern {\n /** The pattern string as registered, after normalization (e.g. \"/data/:id\"). */\n pattern: string;\n /** Ambiguity key: static segments by literal, \"param\" as \":\", \"catchAll\" as \"*\". */\n key: string;\n segments: RouteSegment[];\n}\n\n/**\n * Normalizes a hash or path to a leading-slash, no-trailing-slash path: strips\n * a leading `\"#\"`, discards everything from the first `\"?\"` onward, and\n * collapses empty segments (so a doubled `\"//\"` and a trailing `\"/\"` both\n * disappear). `\"\"`, `\"#\"`, and `\"#/\"` all normalize to `\"/\"`.\n *\n * @param input - The raw hash (with or without its leading `\"#\"`) or path.\n * @returns The normalized path.\n */\nexport function normalizePath(input: string): string {\n const withoutHash = input.startsWith(\"#\") ? input.slice(1) : input;\n\n return \"/\" + splitPath(splitQuery(withoutHash).path).join(\"/\");\n}\n\n/**\n * Splits a normalized path into its non-empty segments.\n *\n * @param path - The path to split.\n * @returns The segments, in order.\n */\nexport function splitPath(path: string): string[] {\n return path.split(\"/\").filter((segment) => segment.length > 0);\n}\n\n/**\n * Splits a URL-ish string at its first `\"#\"`: the part before, and the\n * fragment without its `\"#\"`. Everything after the first `\"#\"` is the\n * fragment verbatim — a second `\"#\"` in the input stays part of it. Never\n * normalizes either half; the caller runs `path` through {@link normalizePath}.\n *\n * @param input - The raw href or path, with or without a fragment.\n * @returns The part before the first `\"#\"`, and the fragment without it.\n */\nexport function splitFragment(input: string): { path: string; fragment: string } {\n const hashIndex = input.indexOf(\"#\");\n\n if (hashIndex === -1) {\n return { path: input, fragment: \"\" };\n }\n\n return { path: input.slice(0, hashIndex), fragment: input.slice(hashIndex + 1) };\n}\n\n/**\n * Splits a URL-ish string at its first `\"?\"`: the part before, and the query\n * without its `\"?\"`. Everything after the first `\"?\"` is the query verbatim —\n * a second `\"?\"` stays part of it.\n *\n * @param input - The raw href or path, with or without a query.\n * @returns The part before the first `\"?\"`, and the query without it.\n */\nexport function splitQuery(input: string): { path: string; query: string } {\n const queryIndex = input.indexOf(\"?\");\n\n if (queryIndex === -1) {\n return { path: input, query: \"\" };\n }\n\n return { path: input.slice(0, queryIndex), query: input.slice(queryIndex + 1) };\n}\n\n/**\n * Parses a query string into decoded key/value pairs. Tolerates one leading\n * `\"?\"`. Later duplicates of a key win; pairs that are empty or have an empty\n * key are skipped.\n *\n * @param query - The raw query string, with or without its leading `\"?\"`.\n * @returns The decoded key/value pairs.\n */\nexport function parseQuery(query: string): Record<string, string> {\n const body = query.startsWith(\"?\") ? query.slice(1) : query;\n const result: Record<string, string> = {};\n\n for (const pair of body.split(\"&\")) {\n if (pair.length === 0) {\n continue;\n }\n\n const equalsIndex = pair.indexOf(\"=\");\n const rawKey = equalsIndex === -1 ? pair : pair.slice(0, equalsIndex);\n const rawValue = equalsIndex === -1 ? \"\" : pair.slice(equalsIndex + 1);\n const key = decodeSegment(rawKey);\n\n if (key.length === 0) {\n continue;\n }\n\n result[key] = decodeSegment(rawValue);\n }\n\n return result;\n}\n\n/**\n * Serializes key/value pairs into a query string, without a leading `\"?\"`.\n * Keys come out in `Object.keys` order — insertion order, except that\n * integer-like keys come first, in ascending order.\n *\n * @param query - The key/value pairs to serialize.\n * @returns The query string, or `\"\"` for an empty record.\n */\nexport function formatQuery(query: Record<string, string>): string {\n return Object.keys(query)\n .map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(query[key])}`)\n .join(\"&\");\n}\n\n/**\n * Whether two query records hold the same keys with the same values,\n * regardless of key order.\n *\n * @param a - The first query record.\n * @param b - The second query record.\n * @returns `true` when both records hold the same key/value pairs.\n */\nexport function sameQuery(a: Record<string, string>, b: Record<string, string>): boolean {\n const aKeys = Object.keys(a);\n\n return aKeys.length === Object.keys(b).length && aKeys.every((key) => a[key] === b[key]);\n}\n\n/**\n * Normalizes a base to leading-and-trailing-slash form, so\n * {@link stripBase} and {@link joinBase} can both assume that shape.\n * `\"\"`, `\"/\"`, `\"x\"`, `\"/x\"`, and `\"/x/\"` all become `\"/\"` or `\"/x/\"`.\n *\n * @param base - The raw base path.\n * @returns The normalized base.\n */\nexport function normalizeBase(base: string): string {\n const segments = splitPath(base);\n\n return segments.length === 0 ? \"/\" : \"/\" + segments.join(\"/\") + \"/\";\n}\n\n/**\n * Removes `base` from the front of `pathname`, then normalizes what is\n * left through {@link normalizePath}. A `pathname` that does not start with\n * `base` is normalized as-is rather than rejected.\n *\n * @param base - The site base, in any shape {@link normalizeBase} accepts.\n * @param pathname - The URL path to strip the base from.\n * @returns The normalized path with `base` removed.\n */\nexport function stripBase(base: string, pathname: string): string {\n const normalizedBase = normalizeBase(base);\n // Base without its trailing slash, e.g. \"/typescript-ui\" (\"\" at the root).\n const basePrefix = normalizedBase.slice(0, -1);\n\n if (basePrefix !== \"\" && (pathname === basePrefix || pathname.startsWith(basePrefix + \"/\"))) {\n return normalizePath(pathname.slice(basePrefix.length));\n }\n\n return normalizePath(pathname);\n}\n\n/**\n * Joins a normalized base and a normalized path into a URL path — the\n * inverse of {@link stripBase}.\n *\n * @param base - The site base, in any shape {@link normalizeBase} accepts.\n * @param path - The route path, in any shape {@link normalizePath} accepts.\n * @returns The joined URL path.\n */\nexport function joinBase(base: string, path: string): string {\n const normalizedBase = normalizeBase(base);\n const normalizedPath = normalizePath(path);\n\n if (normalizedPath === \"/\") {\n return normalizedBase;\n }\n\n return normalizedBase.slice(0, -1) + normalizedPath;\n}\n\n/**\n * Parses a registered pattern into {@link RouteSegment}s and derives its\n * ambiguity key.\n *\n * @param pattern - The pattern string, e.g. `\"/data/rows/:sel\"`.\n * @returns The compiled pattern.\n * @throws If `\"*\"` appears anywhere but the final segment.\n */\nexport function compilePattern(pattern: string): CompiledPattern {\n const normalized = normalizePath(pattern);\n const rawSegments = splitPath(normalized);\n\n const segments: RouteSegment[] = rawSegments.map((raw, i) => {\n if (raw === \"*\") {\n if (i !== rawSegments.length - 1) {\n throw new Error(`RoutePattern: \"*\" is only valid as the final segment of \"${pattern}\"`);\n }\n\n return { kind: \"catchAll\", value: \"\" };\n }\n\n if (raw.startsWith(\":\")) {\n return { kind: \"param\", value: raw.slice(1) };\n }\n\n return { kind: \"static\", value: raw };\n });\n\n const key = segments\n .map((segment) => segment.kind === \"static\" ? segment.value : segment.kind === \"param\" ? \":\" : \"*\")\n .join(\"/\");\n\n return { pattern: normalized, key, segments };\n}\n\n/**\n * Returns the extracted params when `segments` match `compiled`, or `null`\n * when they don't. A trailing `catchAll` segment matches zero or more\n * remaining segments; every other kind requires an exact segment count.\n * Captured `:param` values run through `decodeURIComponent`, falling back to\n * the raw segment text on a malformed escape.\n *\n * @param compiled - The compiled pattern to match against.\n * @param segments - The candidate path's segments (from {@link splitPath}).\n * @returns The extracted params, or `null` when there is no match.\n */\nexport function matchPattern(compiled: CompiledPattern, segments: string[]): Record<string, string> | null {\n const patternSegments = compiled.segments;\n const isCatchAll = patternSegments.length > 0 && patternSegments.at(-1)!.kind === \"catchAll\";\n const staticLength = isCatchAll ? patternSegments.length - 1 : patternSegments.length;\n\n if (isCatchAll ? segments.length < staticLength : segments.length !== staticLength) {\n return null;\n }\n\n const params: Record<string, string> = {};\n\n for (let i = 0; i < staticLength; i += 1) {\n const patternSegment = patternSegments[i];\n const value = segments[i];\n\n if (patternSegment.kind === \"static\") {\n if (patternSegment.value !== value) {\n return null;\n }\n } else if (patternSegment.kind === \"param\") {\n params[patternSegment.value] = decodeSegment(value);\n }\n }\n\n return params;\n}\n\n/**\n * Decodes a captured path segment or query part, falling back to the raw\n * text when it carries a malformed percent-escape.\n *\n * @param value - The raw segment text.\n * @returns The decoded value, or `value` unchanged on a decode failure.\n */\nfunction decodeSegment(value: string): string {\n try {\n return decodeURIComponent(value);\n } catch {\n return value;\n }\n}\n\n/** Rank of each real segment kind: higher wins a specificity tie-break. */\nconst KIND_RANK: Record<SegmentKind, number> = { static: 2, param: 1, catchAll: 0 };\n\n/**\n * Rank of position `i` in `segments`. Reaching the end of the pattern (`i` at\n * or past its length) outranks every real segment kind — see\n * {@link selectPattern}.\n *\n * @param segments - The pattern's segments.\n * @param i - The position to rank.\n * @returns The rank at that position.\n */\nfunction rankAt(segments: readonly RouteSegment[], i: number): number {\n return i >= segments.length ? 3 : KIND_RANK[segments[i].kind];\n}\n\n/**\n * Returns the highest-ranked pattern in `compiled` that matches `path`, or\n * `null` when none match. Patterns are compared segment by segment from the\n * left via {@link rankAt}; the first position where two matching patterns\n * differ decides the winner. Two patterns can never tie on every position —\n * that would mean identical ambiguity keys, which the route table (see\n * `Router`) forbids. Registration order never affects the result.\n *\n * @param compiled - The candidate compiled patterns.\n * @param path - The normalized path to match.\n * @returns The winning pattern and its extracted params, or `null`.\n */\nexport function selectPattern<T extends CompiledPattern>(\n compiled: readonly T[],\n path: string,\n): { compiled: T; params: Record<string, string> } | null {\n const segments = splitPath(path);\n\n let best: T | null = null;\n let bestParams: Record<string, string> | null = null;\n\n for (const candidate of compiled) {\n const params = matchPattern(candidate, segments);\n\n if (params === null) {\n continue;\n }\n\n if (best === null || isMoreSpecific(candidate.segments, best.segments)) {\n best = candidate;\n bestParams = params;\n }\n }\n\n return best === null ? null : { compiled: best, params: bestParams! };\n}\n\n/**\n * Whether `a` outranks `b` by {@link rankAt} at the first position where they\n * differ.\n *\n * @param a - The candidate pattern's segments.\n * @param b - The current best pattern's segments.\n * @returns `true` when `a` is more specific than `b`.\n */\nfunction isMoreSpecific(a: readonly RouteSegment[], b: readonly RouteSegment[]): boolean {\n const length = Math.max(a.length, b.length);\n\n for (let i = 0; i < length; i += 1) {\n const rankA = rankAt(a, i);\n const rankB = rankAt(b, i);\n\n if (rankA !== rankB) {\n return rankA > rankB;\n }\n }\n\n return false;\n}\n","// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { DOM } from '~/core/DOM.js';\nimport { ListenerBag } from '~/core/ListenerBag.js';\nimport { compilePattern, normalizePath, splitPath, splitFragment, splitQuery, parseQuery, formatQuery, sameQuery, selectPattern, normalizeBase, stripBase, joinBase, type CompiledPattern } from '~/router/RoutePattern.js';\n\n/** Params extracted from a matched pattern's `:name` segments. */\nexport type RouteParams = Record<string, string>;\n\n/** Query parameters of a navigation, decoded. Empty when the URL carries none. */\nexport type RouteQuery = Record<string, string>;\n\n/** A registered route's callback: drives whatever it fronts, never builds it. */\nexport type RouteHandler = (params: RouteParams, path: string, fragment: string, query: RouteQuery) => void;\n\n/** The events a {@link Router} emits. */\nexport type RouterEvent = \"navigate\" | \"nomatch\";\n\n/** Where a {@link Router} reads and writes the route: the URL hash, or the path. */\nexport type RouterMode = \"hash\" | \"history\";\n\n/** The pattern and params a navigation resolved to. */\nexport interface RouteMatch {\n /** The pattern that won, as registered. */\n pattern: string;\n params: RouteParams;\n /** The normalized path that was matched. */\n path: string;\n /** The URL fragment without its `\"#\"`, or `\"\"` when there is none. Always `\"\"` in hash mode. */\n fragment: string;\n /** The query parameters the URL carried, decoded. `{}` when there are none. */\n query: RouteQuery;\n}\n\n/** Construction options for {@link Router}. */\nexport interface RouterOptions {\n /** Defaults to `\"hash\"`. */\n mode?: RouterMode;\n /** Path prefix the site is served under, e.g. `\"/typescript-ui/\"`. History mode only; defaults to `\"/\"`. */\n base?: string;\n /** Patterns to `register` at construction, keyed by pattern string. */\n routes?: Record<string, RouteHandler>;\n listeners?: Partial<{\n navigate: (match: RouteMatch) => void;\n nomatch: (path: string) => void;\n }>;\n}\n\n/** A registered route: its compiled pattern plus the handler it drives. */\ntype CompiledRoute = CompiledPattern & { handler: RouteHandler };\n\n/**\n * Maps the URL hash or path to a single top-level app section. Patterns are\n * registered with {@link register} (e.g. `\"/data/rows/:sel\"`); on a\n * navigation, the router selects the most specific matching pattern, extracts\n * its `:param` values, and calls that pattern's handler — the handler drives\n * components that already exist, it never builds them.\n *\n * {@link start} reads the current hash or path, applies the matching route\n * synchronously, then installs the `hashchange` (or, in History mode,\n * `popstate`) listener; call it once the app has built its component tree\n * and before the first layout pass runs, so the routed section is already\n * selected when that pass runs. {@link stop} removes the listener.\n *\n * A navigation may also carry query parameters — view-mode properties\n * layered on top of a route that already matched, never part of pattern\n * matching. In hash mode the query is embedded in the hash; in History mode\n * it is the real `location.search`. `getQuery` reads it, `getHref` and\n * `navigate` write it, and each matched route's handler receives it as a\n * fourth argument alongside {@link RouteMatch}'s `query` field.\n *\n * It is a plain class (no DOM element, so not `callable()`-wrapped) — it\n * follows the shape of a data store: an options bag, a private listener bag,\n * and typed `on` / `off` / `emit` forwarders.\n *\n * @category Core\n */\nexport class Router {\n\n private _routes: Map<string, CompiledRoute> = new Map();\n private _listeners: ListenerBag<RouterEvent> = new ListenerBag<RouterEvent>();\n private _started: boolean = false;\n // Set once in applyOptions and never reassigned after — construction-only,\n // like the compiled route table. Not `readonly`: strictPropertyInitialization\n // rejects a readonly field assigned from a method the constructor merely calls.\n private _mode!: RouterMode;\n private _base!: string;\n\n // Stable references so add/remove pair up; each delegates to a named method.\n private readonly _onHashChange: () => void = () => this.handleHashChange();\n private readonly _onPopState: () => void = () => this.handlePopState();\n\n /**\n * @param options - Routes and listeners to register at construction.\n */\n constructor(options?: RouterOptions) {\n this.applyOptions(options ?? {});\n }\n\n /**\n * Registers a pattern's handler. Re-registering the exact same pattern\n * string replaces its handler silently. Registering a *different*\n * pattern string that collides with an already-registered one on\n * specificity (e.g. `\"/users/:id\"` and `\"/users/:name\"`) replaces it too,\n * but logs a warning naming both patterns — that collision usually\n * signals an authoring mistake.\n *\n * @param pattern - The route pattern, e.g. `\"/data/rows/:sel\"`.\n * @param handler - Called with the extracted params and the normalized\n * path when this pattern wins a navigation.\n * @returns This router, for chaining.\n */\n register(pattern: string, handler: RouteHandler): this {\n const compiled = compilePattern(pattern);\n const existing = this._routes.get(compiled.key);\n\n if (existing !== undefined && existing.pattern !== compiled.pattern) {\n console.warn(`Router: \"${existing.pattern}\" and \"${compiled.pattern}\" have the same specificity; \"${compiled.pattern}\" replaces it.`);\n }\n\n this._routes.set(compiled.key, { ...compiled, handler });\n\n return this;\n }\n\n /**\n * Reads the current hash or path, applies the matching route\n * synchronously, then installs the `hashchange` (hash mode) or\n * `popstate` (History mode) listener. Calling `start()` again on an\n * already-started router logs a warning and is otherwise a no-op — it\n * does not install a second listener.\n *\n * @returns This router, for chaining.\n */\n start(): this {\n if (this._started) {\n console.warn(`Router: start() called on an already-started router; ignoring.`);\n\n return this;\n }\n\n this._started = true;\n this.applyCurrentRoute();\n\n if (this._mode === \"history\") {\n DOM.sink.addListener(DOM.source.getWindow(), \"popstate\", this._onPopState);\n } else {\n DOM.sink.addListener(DOM.source.getWindow(), \"hashchange\", this._onHashChange);\n }\n\n return this;\n }\n\n /**\n * Removes the `hashchange` (hash mode) or `popstate` (History mode)\n * listener. Safe to call when never started, or more than once.\n *\n * @returns This router, for chaining.\n */\n stop(): this {\n if (!this._started) {\n return this;\n }\n\n if (this._mode === \"history\") {\n DOM.sink.removeListener(DOM.source.getWindow(), \"popstate\", this._onPopState);\n } else {\n DOM.sink.removeListener(DOM.source.getWindow(), \"hashchange\", this._onHashChange);\n }\n\n this._started = false;\n\n return this;\n }\n\n /**\n * Navigates to `path` — pushing a history entry, or replacing the\n * current one when `options.replace` is `true`. In hash mode this writes\n * the hash, discarding any `#fragment` in `path` (the `#` is already\n * spent on the route); in History mode this writes `location.pathname`\n * and `location.hash` via `pushState` / `replaceState` and — since\n * neither fires an event — applies the matching route itself. Either\n * way, navigating to the path (and, in History mode, fragment and query)\n * already current is a same-value write: no history entry is written and\n * no handler re-runs.\n *\n * `options.query` sets the query explicitly, replacing (never merging)\n * any query embedded in `path`; an omitted query falls back to whatever\n * `path` embeds, and both default to no query at all.\n *\n * @param path - The path to navigate to, e.g. `\"/settings\"` or, in\n * History mode, `\"/settings#section\"`. May embed a `?query`.\n * @param options - `replace` to replace the current history entry instead\n * of pushing a new one; `query` to set the query explicitly.\n * @returns This router, for chaining.\n */\n navigate(path: string, options?: { replace?: boolean; query?: RouteQuery }): this {\n const split = splitFragment(path);\n const withoutQuery = splitQuery(split.path);\n const query = options?.query ?? parseQuery(withoutQuery.query);\n\n if (this._mode === \"hash\") {\n const hash = this.getHref(path, query);\n\n if (options?.replace === true) {\n DOM.sink.replaceLocationHash(hash);\n } else {\n DOM.sink.setLocationHash(hash);\n }\n\n return this;\n }\n\n const target = normalizePath(withoutQuery.path);\n const fragment = split.fragment;\n\n if (target === this.getPath() && fragment === this.getFragment() && sameQuery(query, this.getQuery())) {\n return this;\n }\n\n const url = this.getHref(fragment === \"\" ? target : `${target}#${fragment}`, query);\n\n if (options?.replace === true) {\n DOM.sink.replaceHistoryPath(url);\n } else {\n DOM.sink.pushHistoryPath(url);\n }\n\n this.applyCurrentRoute(); // pushState/replaceState fire no event; apply it ourselves\n\n return this;\n }\n\n /**\n * The href an `<a>` for `path` should carry, in this router's mode and\n * base: a `\"#/…\"` fragment in hash mode, a base-joined path in History\n * mode. Each segment is percent-encoded. A `#fragment` in `path` is\n * dropped first and, in History mode only, re-appended verbatim\n * (unencoded, so it keeps matching a heading `id`) after the encoded\n * path and query — hash mode has nowhere to put it, since its own `#`\n * is already spent on the route.\n *\n * `path` may embed a `?query`; `query` sets it explicitly instead,\n * replacing (never merging) whatever `path` embeds. The result is\n * ordered path, then `?query`, then `#fragment`.\n *\n * @param path - The route path to format, e.g. `\"/guide/installation\"`\n * or, in History mode, `\"/guide/installation#section\"`. May embed a\n * `?query`.\n * @param query - The query to use instead of whatever `path` embeds.\n * @returns The formatted href.\n */\n getHref(path: string, query?: RouteQuery): string {\n const split = splitFragment(path);\n const withoutQuery = splitQuery(split.path);\n const effective = query ?? parseQuery(withoutQuery.query);\n const segments = splitPath(normalizePath(withoutQuery.path)).map((segment) => encodeURIComponent(segment));\n const encodedPath = \"/\" + segments.join(\"/\");\n const queryString = formatQuery(effective);\n const suffix = queryString === \"\" ? \"\" : \"?\" + queryString;\n\n if (this._mode === \"hash\") {\n return \"#\" + encodedPath + suffix;\n }\n\n const href = joinBase(this._base, encodedPath) + suffix;\n\n return split.fragment === \"\" ? href : `${href}#${split.fragment}`;\n }\n\n /**\n * The route path for `href`, or — with no argument — for the current\n * URL. The inverse of {@link getHref}: percent-encoded segments are\n * decoded, and in History mode the base is stripped first and any\n * `#fragment` is split off before normalizing (see {@link getFragment}\n * to read it).\n *\n * @param href - The href to parse; defaults to the current hash (hash\n * mode) or `location.pathname` (History mode), read through the DOM seam.\n * @returns The normalized, decoded path, without a fragment.\n */\n getPath(href?: string): string {\n if (this._mode === \"hash\") {\n const raw = href ?? DOM.source.getLocationHash();\n\n return this.decodePath(normalizePath(raw));\n }\n\n const raw = href ?? DOM.source.getLocationPathname();\n\n return this.decodePath(stripBase(this._base, splitFragment(raw).path));\n }\n\n /**\n * The fragment for `href`, or — with no argument — for the current URL,\n * without its leading `\"#\"`. Always `\"\"` in hash mode, since the `#`\n * there is already spent on the route.\n *\n * @param href - The href to parse; defaults to the current\n * `location.hash`, read through the DOM seam.\n * @returns The fragment, or `\"\"` when there is none.\n */\n getFragment(href?: string): string {\n if (this._mode === \"hash\") {\n return \"\";\n }\n\n if (href !== undefined) {\n return splitFragment(href).fragment;\n }\n\n const hash = DOM.source.getLocationHash();\n\n return hash.startsWith(\"#\") ? hash.slice(1) : hash;\n }\n\n /**\n * The query parameters for `href`, or — with no argument — for the\n * current URL, decoded. In hash mode the query is embedded in the hash;\n * in History mode it is the real `location.search`, read through the DOM\n * seam. Unlike {@link getFragment}, this is never hard-wired to `{}` in\n * hash mode — the query is real in both modes.\n *\n * @param href - The href to parse; defaults to the current hash (hash\n * mode) or `location.search` (History mode), read through the DOM seam.\n * @returns The decoded query parameters, or `{}` when there are none.\n */\n getQuery(href?: string): RouteQuery {\n if (this._mode === \"hash\") {\n return parseQuery(splitQuery(href ?? DOM.source.getLocationHash()).query);\n }\n\n if (href !== undefined) {\n return parseQuery(splitQuery(splitFragment(href).path).query);\n }\n\n return parseQuery(DOM.source.getLocationSearch());\n }\n\n /**\n * Decodes each percent-encoded segment of an already-normalized path,\n * falling back to the raw segment text on a malformed escape.\n *\n * @param path - The normalized path to decode.\n * @returns The decoded path.\n */\n private decodePath(path: string): string {\n const segments = splitPath(path).map((segment) => {\n try {\n return decodeURIComponent(segment);\n } catch {\n return segment;\n }\n });\n\n return \"/\" + segments.join(\"/\");\n }\n\n on(event: \"navigate\", listener: (match: RouteMatch) => void): this;\n on(event: \"nomatch\", listener: (path: string) => void): this;\n\n /**\n * Subscribes a listener to a router event. Listeners fire in\n * registration order.\n *\n * @param event - The event to listen for.\n * @param listener - The callback to invoke.\n * @returns This router, for chaining.\n */\n on(event: RouterEvent, listener: Function): this {\n this._listeners.add(event, listener);\n\n return this;\n }\n\n /**\n * Removes a previously registered listener. No-op if it was never\n * registered for that event.\n *\n * @param event - The event the listener was registered for.\n * @param listener - The exact callback reference to remove.\n * @returns This router, for chaining.\n */\n off(event: RouterEvent, listener: Function): this {\n this._listeners.remove(event, listener);\n\n return this;\n }\n\n /**\n * Notifies all listeners registered for an event, in registration order.\n *\n * @param event - The event to emit.\n * @param payload - The value passed to each listener.\n */\n protected emit(event: RouterEvent, payload: unknown): void {\n this._listeners.fire(event, payload);\n }\n\n /**\n * Reads the current hash or path and calls the most specific matching\n * pattern's handler, emitting `\"navigate\"` — or emits `\"nomatch\"` when\n * nothing matches. Shared by {@link start}, the `hashchange` listener,\n * the `popstate` listener, and History-mode {@link navigate}.\n */\n private applyCurrentRoute(): void {\n const path = this.getPath();\n const fragment = this.getFragment();\n const query = this.getQuery();\n const result = selectPattern(Array.from(this._routes.values()), path);\n\n if (result === null) {\n this.emit(\"nomatch\", path);\n\n return;\n }\n\n const match: RouteMatch = { pattern: result.compiled.pattern, params: result.params, path, fragment, query };\n\n result.compiled.handler(result.params, path, fragment, query);\n this.emit(\"navigate\", match);\n }\n\n /**\n * Applies an {@link RouterOptions} bag: sets `mode` and `base`, registers\n * `routes`, then wires `listeners`. Called from the constructor body,\n * after every field initializer has run.\n *\n * @param options - The options bag to apply.\n */\n protected applyOptions(options: RouterOptions): void {\n this._mode = options.mode ?? \"hash\";\n this._base = normalizeBase(options.base ?? \"/\");\n\n if (options.routes !== undefined) {\n for (const pattern of Object.keys(options.routes)) {\n this.register(pattern, options.routes[pattern]);\n }\n }\n\n if (options.listeners !== undefined) {\n for (const event of Object.keys(options.listeners) as RouterEvent[]) {\n const listener = options.listeners[event];\n\n if (listener !== undefined) {\n this._listeners.add(event, listener);\n }\n }\n }\n }\n\n private handleHashChange(): void {\n this.applyCurrentRoute();\n }\n\n private handlePopState(): void {\n this.applyCurrentRoute();\n }\n}\n"],"mappings":"+EAmCA,SAAgB,cAAc,EAAuB,CAGjD,MAAO,IAAM,UAAU,WAFH,EAAM,WAAW,GAAG,EAAI,EAAM,MAAM,CAAC,EAAI,CAEhB,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,GAAG,CACjE,CAQA,SAAgB,UAAU,EAAwB,CAC9C,OAAO,EAAK,MAAM,GAAG,CAAC,CAAC,OAAQ,GAAY,EAAQ,OAAS,CAAC,CACjE,CAWA,SAAgB,cAAc,EAAmD,CAC7E,IAAM,EAAY,EAAM,QAAQ,GAAG,EAMnC,OAJI,IAAc,GACP,CAAE,KAAM,EAAO,SAAU,EAAG,EAGhC,CAAE,KAAM,EAAM,MAAM,EAAG,CAAS,EAAG,SAAU,EAAM,MAAM,EAAY,CAAC,CAAE,CACnF,CAUA,SAAgB,WAAW,EAAgD,CACvE,IAAM,EAAa,EAAM,QAAQ,GAAG,EAMpC,OAJI,IAAe,GACR,CAAE,KAAM,EAAO,MAAO,EAAG,EAG7B,CAAE,KAAM,EAAM,MAAM,EAAG,CAAU,EAAG,MAAO,EAAM,MAAM,EAAa,CAAC,CAAE,CAClF,CAUA,SAAgB,WAAW,EAAuC,CAC9D,IAAM,EAAS,EAAM,WAAW,GAAG,EAAI,EAAM,MAAM,CAAC,EAAI,E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from"./DOM-C-Edb3tA.js";import{t,u as n}from"./Component-B0ShfPVi.js";import{t as r}from"./VirtualScroller-DTIn19o1.js";var i=2;function rotateLeft(e,t){e.push(...e.splice(0,t))}var VirtualRowView=class extends t{_rowPool=[];_boundIndices=[];_rowGeom=[];_rowDisplayed=[];_scroller=null;_lastWindowStart=null;_renderDeferred=!1;_renderResumed=!1;_pendingScrollX=null;_pendingScrollY=null;_pendingScrollRow=null;initScroller(e){this._scroller=new r(this,e,()=>this.onScrollerTick());for(let e of this._scroller.ownedHandles())this.trackHandle(e)}onScrollerTick(){this.renderWindow()}destructor(){for(let e of this._rowPool)e.dispose();this._scroller?.dispose(),super.destructor()}setScrollX(e){return this._scroller?.resetWheelEase(),this.holdScrollWhileFirstLayoutHeld(`x`,e)||this._scroller?.setScrollX(e),this}setScrollY(e){return this._scroller?.resetWheelEase(),this.holdScrollWhileFirstLayoutHeld(`y`,e)||this._scroller?.setScrollY(e),this}holdScrollWhileFirstLayoutHeld(e,t){return n()?(e===`x`?this._pendingScrollX=t:(this._pendingScrollY=t,this._pendingScrollRow=null),!0):(e===`x`?this._pendingScrollX=null:(this._pendingScrollY=null,this._pendingScrollRow=null),!1)}applyPendingScroll(){let e=this._pendingScrollX,t=this._pendingScrollY,n=this._pendingScrollRow;this._pendingScrollX=null,this._pendingScrollY=null,this._pendingScrollRow=null,e!==null&&this.setScrollX(e),t!==null&&this.setScrollY(t),n!==null&&this.scrollRowIntoView(n)}computeVisibleWindow(e,t,n){let r=this.getRowHeight(),a=Math.max(0,Math.floor(e/r)-i),o=Math.min(n-1,Math.ceil((e+t)/r)+i);return{firstRow:a,lastRow:o,windowSize:o-a+1>0?o-a+1:0}}computePoolTarget(e,t,n){return Math.min(n,Math.max(e,Math.ceil(t/this.getRowHeight())+4+2))}computePageSize(){let e=this.getRowHeight();return Math.max(1,Math.floor((this.getHeight()||e)/e))}growRowPool(t){if(!this._scroller||this._rowPool.length>=t)return;let n=this._scroller.getRowsContainer(),r=e.sink.createDocumentFragment();for(;this._rowPool.length<t;){let t=this.createPoolRow(),n=t.getElement(!0);e.sink.appendChild(r,n),t.setY(0),t.setWillChange(`transform`),this._rowPool.push(t),this._boundIndices.push(-1),this._rowGeom.push(null),this._rowDisplayed.push(!1)}e.sink.appendChild(n,r),e.sink.release(r)}alignPoolWindow(e){let t=this._lastWindowStart===null?0:e-this._lastWindowStart;this._lastWindowStart=e;let n=this._rowPool.length;if(t===0||n===0)return;let r=(t%n+n)%n;rotateLeft(this._rowPool,r),rotateLeft(this._boundIndices,r),rotateLeft(this._rowGeom,r),rotateLeft(this._rowDisplayed,r)}positionRow(e,t,n){let r=this._rowPool[e],i=this.getRowHeight(),a=this._rowGeom[e],o=!a||a.ty!==t||a.w!==n||a.h!==i;return o&&(r.setAutoCommitStyle(!1),r.setX(0),r.setTranslate(0,t),r.setWidth(n),r.setHeight(i),r.setAutoCommitStyle(!0),this._rowGeom[e]={ty:t,w:n,h:i}),this._rowDisplayed[e]||(r.setDisplayed(!0),this._rowDisplayed[e]=!0),o}hideExcessPoolRows(e){for(let t=e;t<this._rowPool.length;t++)this._rowDisplayed[t]&&(this._rowPool[t].setDisplayed(!1),this._rowDisplayed[t]=!1),this._boundIndices[t]=-1,this._rowGeom[t]=null}invalidateGeom(){for(let e=0;e<this._rowGeom.length;e++)this._rowGeom[e]=null}deferRenderWhileFirstLayoutHeld(){return n()?(this._renderDeferred=!0,this.scheduleLayout(),!0):(this._renderResumed=this._renderDeferred,this._renderDeferred=!1,!1)}wasRenderDeferred(){return this._renderDeferred}finishResumedRender(){let e=this._renderResumed;return this._renderResumed=!1,this.applyPendingScroll(),e}renderWindowIfDeferred(){return!this._renderDeferred||this.isLayoutPaused()?!1:(this.renderWindow(),!0)}onThemeReflow(){this._boundIndices.fill(-1),this.invalidateGeom(),this.renderWindow()}scrollRowIntoView(e){if(e<0||!this._scroller)return;if(n()){this._pendingScrollRow=e;return}let t=this.getRowHeight(),r=e*t,i=r+t,a=this._scroller.getScrollY(),o=this.getHeight(),s=a+o,c=a;r<a?c=r:i>s&&(c=i-o),c!==a&&this.setScrollY(c)}};function selectionsEqual(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}export{VirtualRowView as n,selectionsEqual as t};
2
+ //# sourceMappingURL=selectionsEqual-gMG7gCVI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectionsEqual-gMG7gCVI.js","names":[],"sources":["../../src/typescript/lib/component/shared/VirtualRowView.ts","../../src/typescript/lib/component/shared/selectionsEqual.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { Component, ComponentOptions } from \"~/core/Component.js\";\nimport { DOM } from \"~/core/DOM.js\";\nimport type { Handle } from \"~/core/DOM.js\";\nimport { VirtualScroller } from \"~/component/container/VirtualScroller.js\";\nimport { isFirstLayoutHeld } from \"~/core/FirstLayoutGate.js\";\n\n/** Number of off-screen rows to render above and below the visible viewport. */\nconst SCROLL_BUFFER = 2;\n\n/** Rotates `arr` left by `shift` in place: `arr[i]` becomes what was at `arr[(i + shift) % arr.length]`. */\nfunction rotateLeft<T>(arr: T[], shift: number): void {\n arr.push(...arr.splice(0, shift));\n}\n\n/**\n * Shared transform-windowed virtual-scroll base for the data views —\n * `table/Body` and `tree/Tree` are its only two subclasses. It owns the\n * recycled row pool (`_rowPool` and the parallel `_boundIndices` / `_rowGeom` /\n * `_rowDisplayed` bookkeeping arrays), the {@link VirtualScroller} wiring, and\n * the window / pool-growth / geometry reconciliation primitives each subclass's\n * render pass composes.\n *\n * Only two things genuinely diverge between the two consumers, so only those\n * are hooks:\n *\n * - **Row height** — `Body` derives it live from the theme line box; `Tree`\n * uses a fixed constant. Read through {@link getRowHeight} on every call so a\n * live theme change is honoured.\n * - **Row construction** — the pool-row scaffolding (fragment batching, `setY(0)`\n * pin, `will-change` promotion, parallel-array bookkeeping) is identical; only\n * the row object each subclass builds differs. {@link createPoolRow} returns a\n * fully-constructed, un-appended row and the base owns the rest.\n *\n * The per-frame render pass itself ({@link renderWindow}) stays subclass-specific\n * because the content-width derivation genuinely diverges; the base exposes the\n * shared primitives it calls ({@link computeVisibleWindow},\n * {@link computePoolTarget}, {@link growRowPool}, {@link positionRow},\n * {@link hideExcessPoolRows}).\n *\n * @typeParam TRow - The concrete pooled row component type.\n * @typeParam TOptions - The subclass's options bag.\n *\n * @internal Not barrel-exported; the two subclasses are the only consumers.\n */\nabstract class VirtualRowView<\n TRow extends Component,\n TOptions extends ComponentOptions = ComponentOptions,\n> extends Component<TOptions> {\n\n protected _rowPool : TRow[] = [];\n protected _boundIndices : number[] = [];\n protected _rowGeom : Array<{ ty: number, w: number, h: number } | null> = [];\n protected _rowDisplayed : boolean[] = [];\n protected _scroller : VirtualScroller | null = null;\n\n /** The data index pool slot 0 was aligned to on the last render, for {@link alignPoolWindow} to derive the scroll delta. `null` before the first render. */\n private _lastWindowStart: number | null = null;\n\n /** Whether the startup font gate skipped a render pass that still owes a run. */\n private _renderDeferred: boolean = false;\n /** Whether the render now in flight is the one a skipped pass left pending. */\n private _renderResumed : boolean = false;\n /** Scroll offsets the gate held back, applied once a render pass has run. */\n private _pendingScrollX: number | null = null;\n private _pendingScrollY: number | null = null;\n /** A row reveal the gate held back, recomputed once a render pass has run. */\n private _pendingScrollRow: number | null = null;\n\n /**\n * Returns the height in pixels of a single row. Read on every window /\n * geometry calculation, so a subclass that recomputes it (e.g. on a theme\n * change) reflects the new value immediately.\n */\n protected abstract getRowHeight(): number;\n\n /**\n * Constructs one pool row, fully wired but not yet appended to the\n * rows container — the base's {@link growRowPool} owns the append, the\n * `setY(0)` pin, the `will-change` promotion, and the parallel-array\n * bookkeeping.\n */\n protected abstract createPoolRow(): TRow;\n\n /**\n * Recomputes and reconciles the visible row window against the current\n * scroll position and dataset. Subclass-specific because the content-width\n * derivation diverges; both implementations compose the shared primitives\n * on this base.\n */\n protected abstract renderWindow(): void;\n\n /**\n * Constructs the {@link VirtualScroller} for this view and tracks its\n * container handles so they are released with the component. The scroller's\n * onScroll hook is routed through {@link onScrollerTick}.\n *\n * @param element - This view's initialised element handle.\n */\n protected initScroller(element: Handle): void {\n this._scroller = new VirtualScroller(this, element, () => this.onScrollerTick());\n\n // Track the scroller's created container handles so they are released\n // with this view (on destructor or GC); the scroller is not a Component.\n for (const handle of this._scroller.ownedHandles()) {\n this.trackHandle(handle);\n }\n }\n\n /**\n * Invoked on every scroller tick. Default behaviour re-renders the window;\n * `Body` overrides it to additionally emit its scroll events.\n */\n protected onScrollerTick(): void {\n this.renderWindow();\n }\n\n /**\n * Destroys the pooled rows and the scroller's overlay scrollbars before the\n * inherited teardown runs.\n *\n * {@link growRowPool} appends each row's element straight to the rows\n * container and keeps the row only in `_rowPool`, so a pooled row is never\n * registered as a child component and the base destructor's recursion over\n * `_components` cannot reach it. Without this override neither the rows nor\n * their cells (which *are* registered on their row) release their\n * per-instance stylesheet rules, so the shared sheet grows by roughly the\n * view's whole cell count on every teardown. The scroller's two\n * `Scrollbar` overlays are raw-appended the same way, so they need the\n * same explicit disposal.\n */\n protected destructor(): void {\n for (const row of this._rowPool) {\n row.dispose();\n }\n\n this._scroller?.dispose();\n\n super.destructor();\n }\n\n /**\n * Sets the JS-controlled horizontal scroll position. Delegates to the\n * underlying {@link VirtualScroller}.\n *\n * @param x - The new scroll position in pixels.\n */\n setScrollX(x: number): this {\n // Ahead of the hold: a programmatic scroll cancels an in-flight wheel\n // ease whether or not the offset itself has to wait.\n this._scroller?.resetWheelEase();\n\n if (this.holdScrollWhileFirstLayoutHeld(\"x\", x)) {\n return this;\n }\n\n this._scroller?.setScrollX(x);\n\n return this;\n }\n\n /**\n * Sets the JS-controlled vertical scroll position. Delegates to the\n * underlying {@link VirtualScroller}.\n *\n * @param y - The new scroll position in pixels.\n */\n setScrollY(y: number): this {\n // Ahead of the hold: a programmatic scroll cancels an in-flight wheel\n // ease whether or not the offset itself has to wait.\n this._scroller?.resetWheelEase();\n\n if (this.holdScrollWhileFirstLayoutHeld(\"y\", y)) {\n return this;\n }\n\n this._scroller?.setScrollY(y);\n\n return this;\n }\n\n /**\n * Holds a scroll offset set while the startup font gate is holding this\n * view's render pass, for {@link applyPendingScroll} to apply once the pass\n * has run.\n *\n * @param axis - Which offset is being set.\n * @param offset - The requested offset in pixels.\n *\n * @returns `true` when the caller must return without scrolling.\n *\n * @remarks The scroller clamps every offset against a content extent that\n * only the render pass publishes, so an offset set while that pass is\n * deferred clamps to 0 and the request is lost — a row revealed during\n * startup would end up selected but off-screen. This guards the offsets\n * that are viewport-independent and so can be replayed verbatim: the\n * table's `scrollToRecord`, and a consumer restoring a saved offset.\n * `scrollRowIntoView` is held one level higher instead, by row index, since\n * its target depends on a height the gate is also holding. The table's\n * `scrollColumnIntoView` has that same width dependence but fires only from\n * a pooled cell's editor, which cannot exist while the pass is deferred.\n */\n private holdScrollWhileFirstLayoutHeld(axis: \"x\" | \"y\", offset: number): boolean {\n if (!isFirstLayoutHeld()) {\n // This offset is being applied for real, so it supersedes anything\n // held for the same axis — otherwise the held one would replay on\n // the next render and revert it. A held row reveal is a vertical\n // request too, so it goes with the Y offset.\n if (axis === \"x\") {\n this._pendingScrollX = null;\n } else {\n this._pendingScrollY = null;\n this._pendingScrollRow = null;\n }\n\n return false;\n }\n\n if (axis === \"x\") {\n this._pendingScrollX = offset;\n } else {\n this._pendingScrollY = offset;\n this._pendingScrollRow = null;\n }\n\n return true;\n }\n\n /**\n * Applies the scroll offsets {@link holdScrollWhileFirstLayoutHeld} held\n * back, now that a render pass has published the content extent they clamp\n * against. A no-op once they are applied.\n */\n private applyPendingScroll(): void {\n const x = this._pendingScrollX;\n const y = this._pendingScrollY;\n const row = this._pendingScrollRow;\n\n this._pendingScrollX = null;\n this._pendingScrollY = null;\n this._pendingScrollRow = null;\n\n if (x !== null) {\n this.setScrollX(x);\n }\n\n if (y !== null) {\n this.setScrollY(y);\n }\n\n // Applied after the offsets, which is what makes a reveal win over a\n // raw offset held before it. The reverse order is handled the other\n // way: a raw offset set later clears the reveal outright, so the two\n // vertical requests always resolve to whichever came last.\n if (row !== null) {\n this.scrollRowIntoView(row);\n }\n }\n\n /**\n * Computes the `[firstRow, lastRow]` data-index window visible in the\n * current viewport, padded by `SCROLL_BUFFER` on each side and clamped to\n * the dataset bounds.\n *\n * @param scrollY - The current scroll offset in pixels.\n * @param visibleHeight - The viewport height in pixels.\n * @param totalRows - The total number of rows in the dataset.\n * @returns The `firstRow` / `lastRow` data indices and the number of rows in the window.\n */\n protected computeVisibleWindow(scrollY: number, visibleHeight: number, totalRows: number): { firstRow: number, lastRow: number, windowSize: number } {\n const rowHeight = this.getRowHeight();\n const firstRow = Math.max(0, Math.floor(scrollY / rowHeight) - SCROLL_BUFFER);\n const lastRow = Math.min(\n totalRows - 1,\n Math.ceil((scrollY + visibleHeight) / rowHeight) + SCROLL_BUFFER\n );\n const windowSize = lastRow - firstRow + 1 > 0 ? lastRow - firstRow + 1 : 0;\n\n return { firstRow, lastRow, windowSize };\n }\n\n /**\n * Computes the row-pool target size: the max possible window for the\n * current viewport, not just the current windowSize. windowSize shrinks\n * near the top/bottom edges of the dataset because firstRow clamps to 0\n * (and lastRow to totalRows-1); growing only to windowSize would force\n * regrowth mid-scroll once the user passes a viewport-edge boundary. Pre-\n * growing pays the per-row first-layout cost once.\n *\n * @param windowSize - The current visible-window size.\n * @param visibleHeight - The viewport height in pixels.\n * @param totalRows - The total number of rows in the dataset.\n * @returns The pool target size.\n */\n protected computePoolTarget(windowSize: number, visibleHeight: number, totalRows: number): number {\n return Math.min(\n totalRows,\n Math.max(\n windowSize,\n Math.ceil(visibleHeight / this.getRowHeight()) + 2 * SCROLL_BUFFER + 2\n )\n );\n }\n\n /**\n * Computes the number of whole rows a page-nav keystroke should move by:\n * one viewport height, floored to at least one row.\n *\n * @returns The page size in rows.\n */\n protected computePageSize(): number {\n const rowHeight = this.getRowHeight();\n\n return Math.max(1, Math.floor((this.getHeight() || rowHeight) / rowHeight));\n }\n\n /**\n * Grows the row pool up to `poolTarget`, batching new row elements through\n * a {@link DocumentFragment} so the live rows container sees a single\n * append instead of N. Each new slot pins its static top to 0, promotes it\n * to its own compositor layer, and extends the parallel bookkeeping arrays\n * in lockstep.\n *\n * @param poolTarget - The target pool size.\n */\n protected growRowPool(poolTarget: number): void {\n if (!this._scroller || this._rowPool.length >= poolTarget) {\n return;\n }\n\n const rowsContainer = this._scroller.getRowsContainer();\n const growFragment = DOM.sink.createDocumentFragment();\n\n while (this._rowPool.length < poolTarget) {\n const row = this.createPoolRow();\n const rowEl = row.getElement(true)!;\n\n DOM.sink.appendChild(growFragment, rowEl);\n\n // Pin row's static top to 0 once. Per-frame Y offset comes from\n // translateY, which is composite-only (avoids layout/paint per\n // scroll tick).\n row.setY(0);\n\n // Pre-promote pooled rows to their own compositor layer so the first\n // scroll-driven translate doesn't pay a layer-creation cost.\n row.setWillChange(\"transform\");\n\n this._rowPool.push(row);\n this._boundIndices.push(-1);\n this._rowGeom.push(null);\n this._rowDisplayed.push(false);\n }\n\n DOM.sink.appendChild(rowsContainer, growFragment);\n DOM.sink.release(growFragment);\n }\n\n /**\n * Rotates the pool bookkeeping arrays so each slot keeps tracking the\n * same data index it held before the window moved, instead of being\n * rebound to whichever index now falls at that slot's window-relative\n * position.\n *\n * @param firstRow - The new window's first data index.\n *\n * @remarks Both subclasses key a pool slot by its offset within the\n * window (`firstRow + i`), so without this a one-row scroll shifts every\n * slot's data index by one and forces every pooled row — including the\n * off-screen `SCROLL_BUFFER` rows — through a full rebind and\n * reposition on every tick, instead of just the one row entering the\n * window. Call once per render, after {@link growRowPool} and before the\n * bind pass reads `_rowPool` / `_boundIndices` / `_rowGeom` /\n * `_rowDisplayed` by slot index.\n */\n protected alignPoolWindow(firstRow: number): void {\n const delta = this._lastWindowStart === null ? 0 : firstRow - this._lastWindowStart;\n\n this._lastWindowStart = firstRow;\n\n const n = this._rowPool.length;\n if (delta === 0 || n === 0) {\n return;\n }\n\n const shift = ((delta % n) + n) % n;\n\n rotateLeft(this._rowPool, shift);\n rotateLeft(this._boundIndices, shift);\n rotateLeft(this._rowGeom, shift);\n rotateLeft(this._rowDisplayed, shift);\n }\n\n /**\n * Positions the pool slot at `slot` to `targetY` and sizes it to `rowWidth`,\n * writing the translate/size only when the cached geometry differs from the\n * target, and toggling the row displayed on the false→true edge.\n *\n * @param slot - The pool-slot index.\n * @param targetY - The row's translate-Y offset in pixels.\n * @param rowWidth - The row's width in pixels.\n * @returns `true` when the geometry changed (the subclass may need to re-lay\n * out the row's children), `false` when it was already at the target.\n */\n protected positionRow(slot: number, targetY: number, rowWidth: number): boolean {\n const row = this._rowPool[slot];\n const rowHeight = this.getRowHeight();\n const prev = this._rowGeom[slot];\n const geomChanged = !prev || prev.ty !== targetY || prev.w !== rowWidth || prev.h !== rowHeight;\n\n if (geomChanged) {\n row.setAutoCommitStyle(false);\n row.setX(0);\n row.setTranslate(0, targetY);\n row.setWidth(rowWidth);\n row.setHeight(rowHeight);\n row.setAutoCommitStyle(true);\n this._rowGeom[slot] = { ty: targetY, w: rowWidth, h: rowHeight };\n }\n\n if (!this._rowDisplayed[slot]) {\n row.setDisplayed(true);\n this._rowDisplayed[slot] = true;\n }\n\n return geomChanged;\n }\n\n /**\n * Hides pool slots whose index falls outside the visible window and\n * clears their cached binding so the next bind triggers a full rebuild.\n *\n * @param windowSize - The number of pool slots currently in use.\n */\n protected hideExcessPoolRows(windowSize: number): void {\n for (let i = windowSize; i < this._rowPool.length; i++) {\n if (this._rowDisplayed[i]) {\n this._rowPool[i].setDisplayed(false);\n this._rowDisplayed[i] = false;\n }\n this._boundIndices[i] = -1;\n this._rowGeom[i] = null;\n }\n }\n\n /**\n * Clears the cached row geometry so the next render re-applies positions and\n * sizes for every slot. `Body` overrides this to additionally clear its\n * per-cell geometry cache.\n */\n protected invalidateGeom(): void {\n for (let i = 0; i < this._rowGeom.length; i++) {\n this._rowGeom[i] = null;\n }\n }\n\n /**\n * Skips a render pass while the startup font gate is held, arranging for it\n * to run once the gate opens.\n *\n * @returns `true` when the caller must return without rendering.\n *\n * @remarks Both subclasses call {@link renderWindow} from many synchronous\n * entry points — `init`, a data change, a selection move — so a row's\n * geometry is routinely committed outside the coalesced layout queue, and\n * `init` in particular commits it the moment the element exists. Holding the\n * queue therefore does not hold these views; they have to check the gate\n * themselves. Deferring at this one choke point covers every entry point at\n * once, rather than guarding each caller.\n */\n protected deferRenderWhileFirstLayoutHeld(): boolean {\n if (!isFirstLayoutHeld()) {\n // This render is going ahead, which satisfies anything a held pass\n // left pending — clearing it keeps a later layout from replaying a\n // startup-era pass over the fresher state this one just committed.\n // Note that it also took over that pass's unfinished business, so\n // flag it for `finishResumedRender` to pick up once it has rendered.\n this._renderResumed = this._renderDeferred;\n this._renderDeferred = false;\n\n return false;\n }\n\n this._renderDeferred = true;\n this.scheduleLayout();\n\n return true;\n }\n\n /**\n * Whether the last render pass on this view was skipped by the startup font\n * gate and is still waiting to run.\n *\n * @returns `true` while a pass is pending.\n */\n protected wasRenderDeferred(): boolean {\n return this._renderDeferred;\n }\n\n /**\n * Reports, once, that the render now finishing is the one a held pass left\n * pending — so the caller can redo the post-render work that pass skipped.\n *\n * @returns `true` exactly once per resumed pass, at the end of the render\n * that resumed it.\n *\n * @remarks Called at the tail of {@link renderWindow} rather than from a\n * layout hook because a render resumes from whichever entry point reaches\n * it first, and for the table body that is the parent table layout calling\n * `renderWindow` directly rather than anything going through `doLayout`.\n */\n protected finishResumedRender(): boolean {\n // Read and clear before applying the scroll: applying it re-enters\n // `renderWindow` through the scroller's onScroll hook, and that nested\n // pass resets this flag. Reading it afterwards would lose the caller's\n // post-render work on exactly the passes that carry both.\n const resumed = this._renderResumed;\n\n this._renderResumed = false;\n\n // This pass has published the content extent, so any held offset can be\n // applied now — whether or not the pass is itself the deferred one.\n this.applyPendingScroll();\n\n return resumed;\n }\n\n /**\n * Runs the render pass the startup font gate deferred, if one is pending.\n * Each subclass calls this from its own `doLayout`, which is what picks the\n * pass back up once the gate opens.\n *\n * @returns `true` when a deferred pass ran, so the caller can skip a render\n * of its own and refresh whatever it keeps in step with the rendered rows.\n *\n * @remarks A paused view keeps its pass pending rather than running it: a\n * parent's layout recursion reaches `Body.doLayout` regardless of the\n * child's pause state, so rendering here would defeat a `pauseLayout` the\n * caller asked for. (`Tree.doLayout` already returns early when paused, so\n * the guard only binds for the body.) `resumeLayout` runs a layout of its\n * own, which picks the pass up.\n */\n protected renderWindowIfDeferred(): boolean {\n if (!this._renderDeferred || this.isLayoutPaused()) {\n return false;\n }\n\n // The pending flag is left for `renderWindow`'s own gate check to\n // consume: that is what marks this render as the resumed one, which\n // `finishResumedRender` reads at the end of the pass.\n this.renderWindow();\n\n return true;\n }\n\n /**\n * Re-binds and re-renders every pooled row after a text-metrics reflow —\n * a theme change, or the web font swapping in over the fallback face.\n *\n * @remarks Pooled rows do not ride `ThemeManager`'s reflow for free. Both\n * subclasses render through renderers whose `Text` runs with\n * `setAutoMeasure(false)`, so a bound row only re-measures inside the\n * renderer's `update()` — which {@link renderWindow} skips for a slot that\n * is already bound to its data index. Without the `_boundIndices` reset a\n * visible row therefore keeps the width it measured against whichever font\n * was active when it was bound, clipping the wider glyphs of the real face\n * once it arrives. Subclasses that cache metrics-derived state of their own\n * (row height, content width) override this to refresh it, then chain up.\n */\n protected onThemeReflow(): void {\n this._boundIndices.fill(-1);\n this.invalidateGeom();\n this.renderWindow();\n }\n\n /**\n * Scrolls the view so the row at `index` is fully visible, without moving\n * the viewport unless necessary. Delegates through {@link VirtualScroller}\n * so the header translate + scrollbar thumb stay in sync.\n *\n * @param index - The data index of the row to reveal. A negative index is a\n * no-op (the row is not in the current view).\n */\n protected scrollRowIntoView(index: number): void {\n if (index < 0 || !this._scroller) {\n return;\n }\n\n // Hold the row, not a target. The target depends on this view's height,\n // and at startup that height arrives from the very layout the gate is\n // holding — so computing it now would either read an unset height and\n // reveal nothing, or read 0 and scroll the row just out of view.\n if (isFirstLayoutHeld()) {\n this._pendingScrollRow = index;\n\n return;\n }\n\n const rowHeight = this.getRowHeight();\n const top = index * rowHeight;\n const bottom = top + rowHeight;\n const scrollTop = this._scroller.getScrollY();\n const viewportHeight = this.getHeight();\n const visibleBottom = scrollTop + viewportHeight;\n\n let target = scrollTop;\n if (top < scrollTop) {\n target = top;\n } else if (bottom > visibleBottom) {\n target = bottom - viewportHeight;\n }\n if (target !== scrollTop) {\n this.setScrollY(target);\n }\n }\n}\n\nexport { VirtualRowView };\n","// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\n/**\n * Compares two selection sets by membership only — size and element\n * identity, regardless of insertion order.\n *\n * Pure; no DOM, no component state.\n *\n * @typeParam T - The selection identity type.\n * @param a - One selection set.\n * @param b - The other selection set.\n * @returns `true` when both sets have the same size and every member of\n * `a` is present in `b`.\n *\n * @internal Shared by `Tree` and `Body`; not barrel-exported.\n */\nexport function selectionsEqual<T>(a: ReadonlySet<T>, b: ReadonlySet<T>): boolean {\n if (a.size !== b.size) {\n return false;\n }\n\n for (const item of a) {\n if (!b.has(item)) {\n return false;\n }\n }\n\n return true;\n}\n"],"mappings":"sIASA,IAAM,EAAgB,EAGtB,SAAS,WAAc,EAAU,EAAqB,CAClD,EAAI,KAAK,GAAG,EAAI,OAAO,EAAG,CAAK,CAAC,CACpC,CAgCA,IAAe,eAAf,cAGU,CAAoB,CAE1B,SAAgF,CAAC,EACjF,cAA+E,CAAC,EAChF,SAA+E,CAAC,EAChF,cAA+E,CAAC,EAChF,UAA+E,KAG/E,iBAA0C,KAG1C,gBAAmC,GAEnC,eAAmC,GAEnC,gBAAyC,KACzC,gBAAyC,KAEzC,kBAA2C,KAgC3C,aAAuB,EAAuB,CAC1C,KAAK,UAAY,IAAI,EAAgB,KAAM,MAAe,KAAK,eAAe,CAAC,EAI/E,IAAK,IAAM,KAAU,KAAK,UAAU,aAAa,EAC7C,KAAK,YAAY,CAAM,CAE/B,CAMA,gBAAiC,CAC7B,KAAK,aAAa,CACtB,CAgBA,YAA6B,CACzB,IAAK,IAAM,KAAO,KAAK,SAC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M,EAAiB,KAAK,aAAa,EACnC,EAAiB,EAAQ,EACzB,EAAiB,EAAM,EACvB,EAAiB,KAAK,UAAU,WAAW,EAC3C,EAAiB,KAAK,UAAU,EAChC,EAAiB,EAAY,EAE/B,EAAS,EACT,EAAM,EACN,EAAS,EACF,EAAS,IAChB,EAAS,EAAS,GAElB,IAAW,GACX,KAAK,WAAW,CAAM,CAE9B,CACJ,ECxlBA,SAAgB,gBAAmB,EAAmB,EAA4B,CAC9E,GAAI,EAAE,OAAS,EAAE,KACb,MAAO,GAGX,IAAK,IAAM,KAAQ,EACf,GAAI,CAAC,EAAE,IAAI,CAAI,EACX,MAAO,GAIf,MAAO,EACX"}
@@ -53,6 +53,19 @@ declare class Button<TOptions extends ButtonOptions = ButtonOptions> extends Com
53
53
  private _glyphSizePinned;
54
54
  private _consumerSetPreferredSize?;
55
55
  private readonly _onThemeChange;
56
+ private _pressedPointerId;
57
+ private _pressedPointerInside;
58
+ private _spaceHeld;
59
+ private _updatePressedClass;
60
+ private _isInsideTarget;
61
+ private readonly _onPointerDown;
62
+ private readonly _onPointerOver;
63
+ private readonly _onPointerOut;
64
+ private readonly _onAuxMouseDown;
65
+ private readonly _onPointerRelease;
66
+ private readonly _onSpaceDown;
67
+ private readonly _onSpaceUp;
68
+ private readonly _onBlur;
56
69
  private _pressedStyleRule?;
57
70
  private get pressedStyleRule();
58
71
  private _pressedBorder;
@@ -14,6 +14,7 @@ declare class MenuButton<TOptions extends MenuButtonOptions = MenuButtonOptions>
14
14
  getMenuItems(): MenuItemConfig[] | (() => MenuItemConfig[]) | null;
15
15
  isScrollToBottomOnShow(): boolean;
16
16
  protected applyOptions(options: TOptions): this;
17
+ protected shouldToggleMenu(): boolean;
17
18
  private toggleMenu;
18
19
  private resolveMenuItems;
19
20
  }
@@ -0,0 +1,22 @@
1
+ import { Button, ButtonOptions } from "../../component/button/Button.js";
2
+ import { PopupPanel } from "../../overlay/PopupPanel.js";
3
+ export interface PopupButtonOptions extends ButtonOptions {
4
+ panel?: PopupPanel | (() => PopupPanel);
5
+ }
6
+ declare class PopupButton<TOptions extends PopupButtonOptions = PopupButtonOptions> extends Button<TOptions> {
7
+ private _resolvedPanel;
8
+ private readonly _boundTogglePopup;
9
+ private readonly _boundClosePopup;
10
+ constructor(text?: string, options?: TOptions, subclassDefaults?: Partial<TOptions>);
11
+ constructor(options: TOptions);
12
+ protected destructor(): void;
13
+ setPanel(panel: PopupPanel | (() => PopupPanel)): this;
14
+ getPanel(): PopupPanel | (() => PopupPanel) | null;
15
+ protected applyOptions(options: TOptions): this;
16
+ protected ensurePanel(): PopupPanel | null;
17
+ private togglePopup;
18
+ private closePopup;
19
+ }
20
+ declare const PopupButtonCallable: import("../../core/Callable.js").Callable<typeof PopupButton>;
21
+ type PopupButtonCallable<TOptions extends PopupButtonOptions = PopupButtonOptions> = PopupButton<TOptions>;
22
+ export { PopupButton as _PopupButton, PopupButtonCallable as PopupButton, };
@@ -6,12 +6,16 @@ export interface TabButtonOptions extends ToggleButtonOptions {
6
6
  declare class TabButton extends ToggleButton {
7
7
  private _closeable;
8
8
  private _closeButton;
9
+ private _busy;
10
+ private _busyIndicator;
9
11
  constructor(text: string, options?: TabButtonOptions, subclassDefaults?: Partial<TabButtonOptions>);
10
12
  protected destructor(): void;
11
13
  private applyTabStyling;
12
14
  private buildCloseButton;
13
15
  getCloseButton(): TabCloseButton | null;
14
16
  isCloseable(): boolean;
17
+ setBusy(busy: boolean): this;
18
+ isBusy(): boolean;
15
19
  }
16
20
  declare const TabButtonCallable: import("../../core/Callable.js").Callable<typeof TabButton>;
17
21
  type TabButtonCallable = TabButton;
@@ -10,3 +10,5 @@ export { SplitButton } from '../../component/button/SplitButton.js';
10
10
  export type { SplitButtonOptions } from '../../component/button/SplitButton.js';
11
11
  export { MenuButton } from '../../component/button/MenuButton.js';
12
12
  export type { MenuButtonOptions } from '../../component/button/MenuButton.js';
13
+ export { PopupButton } from '../../component/button/PopupButton.js';
14
+ export type { PopupButtonOptions } from '../../component/button/PopupButton.js';
@@ -0,0 +1,33 @@
1
+ import { ComponentOptions } from "../../core/Component.js";
2
+ import { MenuRow } from "../../component/container/MenuRow.js";
3
+ export type CheckboxMenuRowEvent = "action";
4
+ export interface CheckboxMenuRowOptions extends ComponentOptions {
5
+ text?: string;
6
+ checked?: boolean;
7
+ enabled?: boolean;
8
+ listeners?: {
9
+ action?: () => void;
10
+ };
11
+ }
12
+ declare class CheckboxMenuRow extends MenuRow<CheckboxMenuRowOptions> {
13
+ private _checkbox;
14
+ private _iconStart;
15
+ private _checkZone;
16
+ private readonly _onMouseOver;
17
+ private readonly _onMouseOut;
18
+ private readonly _onClick;
19
+ constructor(options?: CheckboxMenuRowOptions, subclassDefaults?: Partial<CheckboxMenuRowOptions>);
20
+ isChecked(): boolean;
21
+ setChecked(value: boolean): this;
22
+ isNavigable(): boolean;
23
+ isEnabled(): boolean;
24
+ activate(): void;
25
+ getContentWidth(): number;
26
+ setColumns(checkZone: number, iconStart: number, _titleColumn: number): void;
27
+ doLayout(): this;
28
+ on(event: "action", listener: () => void): this;
29
+ off(event: "action", listener: () => void): this;
30
+ }
31
+ declare const CheckboxMenuRowCallable: import("../../core/Callable.js").Callable<typeof CheckboxMenuRow>;
32
+ type CheckboxMenuRowCallable = CheckboxMenuRow;
33
+ export { CheckboxMenuRow as _CheckboxMenuRow, CheckboxMenuRowCallable as CheckboxMenuRow };
@@ -1,15 +1,19 @@
1
1
  import { Component, ComponentOptions } from "../../core/Component.js";
2
2
  import type { Handle } from "../../core/DOM.js";
3
3
  export type CollapseDirection = "north" | "south" | "east" | "west";
4
- export type CollapseButtonEvent = "collapse";
4
+ export type CollapseTrigger = "click" | "dblclick";
5
+ export type CollapseButtonEvent = "collapse" | "contextmenu";
5
6
  export interface CollapseButtonOptions extends ComponentOptions {
6
7
  direction?: CollapseDirection;
8
+ trigger?: CollapseTrigger;
7
9
  listeners?: {
8
10
  collapse?: () => void;
11
+ contextmenu?: (x: number, y: number) => void;
9
12
  };
10
13
  }
11
14
  declare class CollapseButton extends Component<CollapseButtonOptions> {
12
15
  private _direction;
16
+ private _trigger;
13
17
  private _listeners;
14
18
  constructor(options?: CollapseButtonOptions);
15
19
  protected applyOptions(options: CollapseButtonOptions): this;
@@ -17,12 +21,16 @@ declare class CollapseButton extends Component<CollapseButtonOptions> {
17
21
  private applyRotation;
18
22
  setStripMode(filled: boolean): this;
19
23
  getDirection(): CollapseDirection;
24
+ getTrigger(): CollapseTrigger;
20
25
  setDirection(direction: CollapseDirection): this;
21
26
  on(event: "collapse", listener: () => void): this;
27
+ on(event: "contextmenu", listener: (x: number, y: number) => void): this;
22
28
  off(event: CollapseButtonEvent, listener: Function): this;
23
- protected emit(event: CollapseButtonEvent): void;
24
- private onDoubleClick;
29
+ protected emit(event: "collapse"): void;
30
+ protected emit(event: "contextmenu", x: number, y: number): void;
31
+ private onActivate;
25
32
  private onMouseDown;
33
+ private onContextMenu;
26
34
  }
27
35
  declare const CollapseButtonCallable: import("../../core/Callable.js").Callable<typeof CollapseButton>;
28
36
  type CollapseButtonCallable = CollapseButton;
@@ -1,5 +1,6 @@
1
- import { Component, ComponentOptions } from "../../core/Component.js";
1
+ import { ComponentOptions } from "../../core/Component.js";
2
2
  import { BorderOptions } from "../../primitive/Border.js";
3
+ import { MenuRow } from "../../component/container/MenuRow.js";
3
4
  export interface MenuItemOptions extends ComponentOptions {
4
5
  text?: string;
5
6
  enabled?: boolean;
@@ -9,36 +10,42 @@ export type MenuItemCSSVarPrefix = "menu-bar" | "context-menu";
9
10
  export interface MenuItemConfig {
10
11
  text?: string;
11
12
  action?: () => void;
13
+ closeOnActivate?: boolean;
12
14
  enabled?: boolean;
13
15
  shortcut?: string;
16
+ checked?: boolean;
14
17
  icon?: string;
15
18
  glyph?: string;
16
19
  glyphColor?: string;
17
20
  submenu?: MenuConfig;
18
21
  separator?: true;
22
+ row?: () => MenuRow;
19
23
  }
20
24
  export interface MenuConfig {
21
25
  label: string;
22
26
  items: MenuItemConfig[] | (() => MenuItemConfig[]);
23
27
  glyph?: string;
24
28
  }
25
- declare class MenuItem extends Component {
29
+ declare class MenuItem extends MenuRow {
26
30
  static readonly HEIGHT: number;
27
31
  private static readonly SEPARATOR_HEIGHT;
28
32
  static readonly TEXT_INSET: number;
29
33
  static readonly ICON_ZONE: number;
34
+ static readonly CHECK_ZONE: number;
30
35
  static readonly CHEVRON_ZONE: number;
31
36
  static readonly RIGHT_PAD: number;
32
37
  static readonly TEXT_GAP: number;
33
38
  private readonly _config;
34
39
  private readonly _onActivate;
35
40
  private readonly _onOpenSubmenu;
36
- private readonly _cssVarPrefix;
41
+ private _checked;
42
+ private _checkText;
37
43
  private _iconText;
38
44
  private _iconGlyph;
39
45
  private _titleText;
40
46
  private _shortcutText;
41
47
  private _chevronText;
48
+ private _checkZone;
42
49
  private _iconStart;
43
50
  private _titleColumn;
44
51
  private _submenuTimer;
@@ -49,13 +56,16 @@ declare class MenuItem extends Component {
49
56
  protected applyOptions(options: MenuItemOptions): this;
50
57
  hasSubmenu(): boolean;
51
58
  hasIcon(): boolean;
59
+ hasCheck(): boolean;
60
+ isChecked(): boolean;
52
61
  titleTextWidth(): number;
53
62
  shortcutTextWidth(): number;
54
- setColumns(iconStart: number, titleColumn: number): void;
63
+ setColumns(checkZone: number, iconStart: number, titleColumn: number): void;
55
64
  getSubmenuConfig(): MenuConfig | null;
56
- setFocused(focused: boolean): this;
57
65
  isSeparator(): boolean;
66
+ isNavigable(): boolean;
58
67
  isEnabled(): boolean;
68
+ private activateLeaf;
59
69
  activate(): void;
60
70
  protected destructor(): void;
61
71
  getBaseline(): number | null;
@@ -0,0 +1,24 @@
1
+ import { Component, ComponentOptions } from "../../core/Component.js";
2
+ import type { MenuItemCSSVarPrefix } from "../../component/container/MenuItem.js";
3
+ export declare abstract class MenuRow<TOptions extends ComponentOptions = ComponentOptions> extends Component<TOptions> {
4
+ static readonly HEIGHT: number;
5
+ private _cssVarPrefix;
6
+ private _closeMenu;
7
+ constructor(options?: TOptions, subclassDefaults?: Partial<TOptions>);
8
+ isSeparator(): boolean;
9
+ isEnabled(): boolean;
10
+ isNavigable(): boolean;
11
+ setFocused(focused: boolean): this;
12
+ activate(): void;
13
+ hasCheck(): boolean;
14
+ hasIcon(): boolean;
15
+ hasSubmenu(): boolean;
16
+ titleTextWidth(): number;
17
+ shortcutTextWidth(): number;
18
+ getContentWidth(): number;
19
+ setColumns(_checkZone: number, _iconStart: number, _titleColumn: number): void;
20
+ setCssVarPrefix(prefix: MenuItemCSSVarPrefix): this;
21
+ setMenuCloseHandler(close: () => void): void;
22
+ protected getCssVarPrefix(): MenuItemCSSVarPrefix;
23
+ protected closeMenu(): void;
24
+ }
@@ -1,10 +1,12 @@
1
- import { Component, ComponentOptions } from "../../core/Component.js";
1
+ import { ComponentOptions } from "../../core/Component.js";
2
2
  import type { MenuItemCSSVarPrefix } from "../../component/container/MenuItem.js";
3
+ import { MenuRow } from "../../component/container/MenuRow.js";
3
4
  export interface MenuSeparatorOptions extends ComponentOptions {
4
5
  }
5
- declare class MenuSeparator extends Component<MenuSeparatorOptions> {
6
+ declare class MenuSeparator extends MenuRow<MenuSeparatorOptions> {
6
7
  static readonly HEIGHT: number;
7
8
  constructor(cssVarPrefix?: MenuItemCSSVarPrefix, options?: MenuSeparatorOptions, subclassDefaults?: Partial<MenuSeparatorOptions>);
9
+ isSeparator(): boolean;
8
10
  }
9
11
  declare const MenuSeparatorCallable: import("../../core/Callable.js").Callable<typeof MenuSeparator>;
10
12
  type MenuSeparatorCallable = MenuSeparator;
@@ -0,0 +1,33 @@
1
+ import { ComponentOptions } from "../../core/Component.js";
2
+ import { MenuRow } from "../../component/container/MenuRow.js";
3
+ export type RadioMenuRowEvent = "action";
4
+ export interface RadioMenuRowOptions extends ComponentOptions {
5
+ text?: string;
6
+ checked?: boolean;
7
+ enabled?: boolean;
8
+ listeners?: {
9
+ action?: () => void;
10
+ };
11
+ }
12
+ declare class RadioMenuRow extends MenuRow<RadioMenuRowOptions> {
13
+ private _radio;
14
+ private _iconStart;
15
+ private _checkZone;
16
+ private readonly _onMouseOver;
17
+ private readonly _onMouseOut;
18
+ private readonly _onClick;
19
+ constructor(options?: RadioMenuRowOptions, subclassDefaults?: Partial<RadioMenuRowOptions>);
20
+ isChecked(): boolean;
21
+ setChecked(value: boolean): this;
22
+ isNavigable(): boolean;
23
+ isEnabled(): boolean;
24
+ activate(): void;
25
+ getContentWidth(): number;
26
+ setColumns(checkZone: number, iconStart: number, _titleColumn: number): void;
27
+ doLayout(): this;
28
+ on(event: "action", listener: () => void): this;
29
+ off(event: "action", listener: () => void): this;
30
+ }
31
+ declare const RadioMenuRowCallable: import("../../core/Callable.js").Callable<typeof RadioMenuRow>;
32
+ type RadioMenuRowCallable = RadioMenuRow;
33
+ export { RadioMenuRow as _RadioMenuRow, RadioMenuRowCallable as RadioMenuRow };