@ahoo-wang/wow-view-engine 9.2.0-rc.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 (1421) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +1182 -0
  3. package/README.zh-CN.md +1171 -0
  4. package/THIRD_PARTY_NOTICES.md +196 -0
  5. package/dist/actions-DK1yfiI8.js +9986 -0
  6. package/dist/actions-DK1yfiI8.js.map +1 -0
  7. package/dist/analysis/boxplot.d.ts +80 -0
  8. package/dist/analysis/boxplot.d.ts.map +1 -0
  9. package/dist/analysis/bucketChange.d.ts +25 -0
  10. package/dist/analysis/bucketChange.d.ts.map +1 -0
  11. package/dist/analysis/budget.d.ts +37 -0
  12. package/dist/analysis/budget.d.ts.map +1 -0
  13. package/dist/analysis/candidates.d.ts +96 -0
  14. package/dist/analysis/candidates.d.ts.map +1 -0
  15. package/dist/analysis/candlestick.d.ts +73 -0
  16. package/dist/analysis/candlestick.d.ts.map +1 -0
  17. package/dist/analysis/capability.d.ts +129 -0
  18. package/dist/analysis/capability.d.ts.map +1 -0
  19. package/dist/analysis/cartesian.d.ts +102 -0
  20. package/dist/analysis/cartesian.d.ts.map +1 -0
  21. package/dist/analysis/chart.d.ts +108 -0
  22. package/dist/analysis/chart.d.ts.map +1 -0
  23. package/dist/analysis/chartFamilies.d.ts +175 -0
  24. package/dist/analysis/chartFamilies.d.ts.map +1 -0
  25. package/dist/analysis/chartOptions.d.ts +113 -0
  26. package/dist/analysis/chartOptions.d.ts.map +1 -0
  27. package/dist/analysis/chartRefs.d.ts +31 -0
  28. package/dist/analysis/chartRefs.d.ts.map +1 -0
  29. package/dist/analysis/chartRows.d.ts +39 -0
  30. package/dist/analysis/chartRows.d.ts.map +1 -0
  31. package/dist/analysis/chartSlots.d.ts +73 -0
  32. package/dist/analysis/chartSlots.d.ts.map +1 -0
  33. package/dist/analysis/chartSwitch.d.ts +34 -0
  34. package/dist/analysis/chartSwitch.d.ts.map +1 -0
  35. package/dist/analysis/compile.d.ts +55 -0
  36. package/dist/analysis/compile.d.ts.map +1 -0
  37. package/dist/analysis/currency.d.ts +68 -0
  38. package/dist/analysis/currency.d.ts.map +1 -0
  39. package/dist/analysis/dangling.d.ts +52 -0
  40. package/dist/analysis/dangling.d.ts.map +1 -0
  41. package/dist/analysis/defaults.d.ts +168 -0
  42. package/dist/analysis/defaults.d.ts.map +1 -0
  43. package/dist/analysis/derived.d.ts +81 -0
  44. package/dist/analysis/derived.d.ts.map +1 -0
  45. package/dist/analysis/drill.d.ts +142 -0
  46. package/dist/analysis/drill.d.ts.map +1 -0
  47. package/dist/analysis/drillFilter.d.ts +34 -0
  48. package/dist/analysis/drillFilter.d.ts.map +1 -0
  49. package/dist/analysis/expand.d.ts +51 -0
  50. package/dist/analysis/expand.d.ts.map +1 -0
  51. package/dist/analysis/expressions.d.ts +12 -0
  52. package/dist/analysis/expressions.d.ts.map +1 -0
  53. package/dist/analysis/fitCharts.d.ts +93 -0
  54. package/dist/analysis/fitCharts.d.ts.map +1 -0
  55. package/dist/analysis/formula.d.ts +65 -0
  56. package/dist/analysis/formula.d.ts.map +1 -0
  57. package/dist/analysis/funnel.d.ts +48 -0
  58. package/dist/analysis/funnel.d.ts.map +1 -0
  59. package/dist/analysis/gauge.d.ts +34 -0
  60. package/dist/analysis/gauge.d.ts.map +1 -0
  61. package/dist/analysis/granularity.d.ts +22 -0
  62. package/dist/analysis/granularity.d.ts.map +1 -0
  63. package/dist/analysis/having.d.ts +38 -0
  64. package/dist/analysis/having.d.ts.map +1 -0
  65. package/dist/analysis/hierarchy.d.ts +73 -0
  66. package/dist/analysis/hierarchy.d.ts.map +1 -0
  67. package/dist/analysis/index.d.ts +29 -0
  68. package/dist/analysis/index.d.ts.map +1 -0
  69. package/dist/analysis/logScale.d.ts +20 -0
  70. package/dist/analysis/logScale.d.ts.map +1 -0
  71. package/dist/analysis/map.d.ts +28 -0
  72. package/dist/analysis/map.d.ts.map +1 -0
  73. package/dist/analysis/metricCard.d.ts +155 -0
  74. package/dist/analysis/metricCard.d.ts.map +1 -0
  75. package/dist/analysis/metricCondition.d.ts +41 -0
  76. package/dist/analysis/metricCondition.d.ts.map +1 -0
  77. package/dist/analysis/metricFormat.d.ts +136 -0
  78. package/dist/analysis/metricFormat.d.ts.map +1 -0
  79. package/dist/analysis/metricOrder.d.ts +47 -0
  80. package/dist/analysis/metricOrder.d.ts.map +1 -0
  81. package/dist/analysis/metricWindow.d.ts +28 -0
  82. package/dist/analysis/metricWindow.d.ts.map +1 -0
  83. package/dist/analysis/profiles.d.ts +53 -0
  84. package/dist/analysis/profiles.d.ts.map +1 -0
  85. package/dist/analysis/project.d.ts +242 -0
  86. package/dist/analysis/project.d.ts.map +1 -0
  87. package/dist/analysis/queryFilter.d.ts +32 -0
  88. package/dist/analysis/queryFilter.d.ts.map +1 -0
  89. package/dist/analysis/references.d.ts +41 -0
  90. package/dist/analysis/references.d.ts.map +1 -0
  91. package/dist/analysis/splitOther.d.ts +80 -0
  92. package/dist/analysis/splitOther.d.ts.map +1 -0
  93. package/dist/analysis/timeAxis.d.ts +173 -0
  94. package/dist/analysis/timeAxis.d.ts.map +1 -0
  95. package/dist/analysis/timeCharts.d.ts +76 -0
  96. package/dist/analysis/timeCharts.d.ts.map +1 -0
  97. package/dist/analysis/treemap.d.ts +36 -0
  98. package/dist/analysis/treemap.d.ts.map +1 -0
  99. package/dist/analysis/validate.d.ts +19 -0
  100. package/dist/analysis/validate.d.ts.map +1 -0
  101. package/dist/analysis/validateAliases.d.ts +16 -0
  102. package/dist/analysis/validateAliases.d.ts.map +1 -0
  103. package/dist/analysis/validateChart.d.ts +60 -0
  104. package/dist/analysis/validateChart.d.ts.map +1 -0
  105. package/dist/analysis/validateElements.d.ts +20 -0
  106. package/dist/analysis/validateElements.d.ts.map +1 -0
  107. package/dist/analysis/validateGroups.d.ts +5 -0
  108. package/dist/analysis/validateGroups.d.ts.map +1 -0
  109. package/dist/analysis/validateHaving.d.ts +9 -0
  110. package/dist/analysis/validateHaving.d.ts.map +1 -0
  111. package/dist/analysis/validateLevels.d.ts +33 -0
  112. package/dist/analysis/validateLevels.d.ts.map +1 -0
  113. package/dist/analysis/validateLimits.d.ts +3 -0
  114. package/dist/analysis/validateLimits.d.ts.map +1 -0
  115. package/dist/analysis/validateMetrics.d.ts +5 -0
  116. package/dist/analysis/validateMetrics.d.ts.map +1 -0
  117. package/dist/analysis/validateOffers.d.ts +12 -0
  118. package/dist/analysis/validateOffers.d.ts.map +1 -0
  119. package/dist/analysis/validateReferences.d.ts +16 -0
  120. package/dist/analysis/validateReferences.d.ts.map +1 -0
  121. package/dist/analysis/validateShape.d.ts +14 -0
  122. package/dist/analysis/validateShape.d.ts.map +1 -0
  123. package/dist/analysis/validateSort.d.ts +3 -0
  124. package/dist/analysis/validateSort.d.ts.map +1 -0
  125. package/dist/analysis/waterfall.d.ts +33 -0
  126. package/dist/analysis/waterfall.d.ts.map +1 -0
  127. package/dist/capabilities/aliases.d.ts +36 -0
  128. package/dist/capabilities/aliases.d.ts.map +1 -0
  129. package/dist/capabilities/analysis.d.ts +19 -0
  130. package/dist/capabilities/analysis.d.ts.map +1 -0
  131. package/dist/capabilities/cache.d.ts +69 -0
  132. package/dist/capabilities/cache.d.ts.map +1 -0
  133. package/dist/capabilities/fields.d.ts +50 -0
  134. package/dist/capabilities/fields.d.ts.map +1 -0
  135. package/dist/capabilities/index.d.ts +13 -0
  136. package/dist/capabilities/index.d.ts.map +1 -0
  137. package/dist/capabilities/limits.d.ts +24 -0
  138. package/dist/capabilities/limits.d.ts.map +1 -0
  139. package/dist/capabilities/match.d.ts +52 -0
  140. package/dist/capabilities/match.d.ts.map +1 -0
  141. package/dist/capabilities/narrow.d.ts +27 -0
  142. package/dist/capabilities/narrow.d.ts.map +1 -0
  143. package/dist/capabilities/open.d.ts +25 -0
  144. package/dist/capabilities/open.d.ts.map +1 -0
  145. package/dist/capabilities/record.d.ts +13 -0
  146. package/dist/capabilities/record.d.ts.map +1 -0
  147. package/dist/capabilities/violations.d.ts +19 -0
  148. package/dist/capabilities/violations.d.ts.map +1 -0
  149. package/dist/cartesianBrush-HLU12ig5.js +122 -0
  150. package/dist/cartesianBrush-HLU12ig5.js.map +1 -0
  151. package/dist/clickDraft-DQDQn4x-.js +184 -0
  152. package/dist/clickDraft-DQDQn4x-.js.map +1 -0
  153. package/dist/dashboard/boardFields.d.ts +11 -0
  154. package/dist/dashboard/boardFields.d.ts.map +1 -0
  155. package/dist/dashboard/click.d.ts +105 -0
  156. package/dist/dashboard/click.d.ts.map +1 -0
  157. package/dist/dashboard/clickDraft.d.ts +84 -0
  158. package/dist/dashboard/clickDraft.d.ts.map +1 -0
  159. package/dist/dashboard/declared.d.ts +29 -0
  160. package/dist/dashboard/declared.d.ts.map +1 -0
  161. package/dist/dashboard/defaults.d.ts +14 -0
  162. package/dist/dashboard/defaults.d.ts.map +1 -0
  163. package/dist/dashboard/edit.d.ts +118 -0
  164. package/dist/dashboard/edit.d.ts.map +1 -0
  165. package/dist/dashboard/filterEdit.d.ts +60 -0
  166. package/dist/dashboard/filterEdit.d.ts.map +1 -0
  167. package/dist/dashboard/filters.d.ts +104 -0
  168. package/dist/dashboard/filters.d.ts.map +1 -0
  169. package/dist/dashboard/index.d.ts +26 -0
  170. package/dist/dashboard/index.d.ts.map +1 -0
  171. package/dist/dashboard/layout.d.ts +184 -0
  172. package/dist/dashboard/layout.d.ts.map +1 -0
  173. package/dist/dashboard/merge.d.ts +32 -0
  174. package/dist/dashboard/merge.d.ts.map +1 -0
  175. package/dist/dashboard/migrate.d.ts +33 -0
  176. package/dist/dashboard/migrate.d.ts.map +1 -0
  177. package/dist/dashboard/panelFieldNames.d.ts +20 -0
  178. package/dist/dashboard/panelFieldNames.d.ts.map +1 -0
  179. package/dist/dashboard/panelLook.d.ts +18 -0
  180. package/dist/dashboard/panelLook.d.ts.map +1 -0
  181. package/dist/dashboard/panels.d.ts +78 -0
  182. package/dist/dashboard/panels.d.ts.map +1 -0
  183. package/dist/dashboard/placeholders.d.ts +3 -0
  184. package/dist/dashboard/placeholders.d.ts.map +1 -0
  185. package/dist/dashboard/tabs.d.ts +28 -0
  186. package/dist/dashboard/tabs.d.ts.map +1 -0
  187. package/dist/dashboard/timeBindings.d.ts +42 -0
  188. package/dist/dashboard/timeBindings.d.ts.map +1 -0
  189. package/dist/dashboard/validate.d.ts +80 -0
  190. package/dist/dashboard/validate.d.ts.map +1 -0
  191. package/dist/dashboard/validateFilters.d.ts +15 -0
  192. package/dist/dashboard/validateFilters.d.ts.map +1 -0
  193. package/dist/dashboard/wiring.d.ts +103 -0
  194. package/dist/dashboard/wiring.d.ts.map +1 -0
  195. package/dist/echarts-HUGzxow7.js +35 -0
  196. package/dist/echarts-HUGzxow7.js.map +1 -0
  197. package/dist/echartsGeo-BWbXo9ef.js +14 -0
  198. package/dist/echartsGeo-BWbXo9ef.js.map +1 -0
  199. package/dist/echartsHierarchy-Cm-9-LN9.js +14 -0
  200. package/dist/echartsHierarchy-Cm-9-LN9.js.map +1 -0
  201. package/dist/echartsStatistics-Lq-BjHez.js +20 -0
  202. package/dist/echartsStatistics-Lq-BjHez.js.map +1 -0
  203. package/dist/echartsTime-gMH0oF0x.js +15 -0
  204. package/dist/echartsTime-gMH0oF0x.js.map +1 -0
  205. package/dist/filter/compile.d.ts +23 -0
  206. package/dist/filter/compile.d.ts.map +1 -0
  207. package/dist/filter/configBase.d.ts +23 -0
  208. package/dist/filter/configBase.d.ts.map +1 -0
  209. package/dist/filter/describe.d.ts +234 -0
  210. package/dist/filter/describe.d.ts.map +1 -0
  211. package/dist/filter/fieldGroups.d.ts +17 -0
  212. package/dist/filter/fieldGroups.d.ts.map +1 -0
  213. package/dist/filter/fieldKind.d.ts +244 -0
  214. package/dist/filter/fieldKind.d.ts.map +1 -0
  215. package/dist/filter/index.d.ts +21 -0
  216. package/dist/filter/index.d.ts.map +1 -0
  217. package/dist/filter/issuePath.d.ts +21 -0
  218. package/dist/filter/issuePath.d.ts.map +1 -0
  219. package/dist/filter/kinds/array.d.ts +18 -0
  220. package/dist/filter/kinds/array.d.ts.map +1 -0
  221. package/dist/filter/kinds/boolean.d.ts +3 -0
  222. package/dist/filter/kinds/boolean.d.ts.map +1 -0
  223. package/dist/filter/kinds/dateTime.d.ts +39 -0
  224. package/dist/filter/kinds/dateTime.d.ts.map +1 -0
  225. package/dist/filter/kinds/deletion.d.ts +42 -0
  226. package/dist/filter/kinds/deletion.d.ts.map +1 -0
  227. package/dist/filter/kinds/duration.d.ts +27 -0
  228. package/dist/filter/kinds/duration.d.ts.map +1 -0
  229. package/dist/filter/kinds/elementMatch.d.ts +34 -0
  230. package/dist/filter/kinds/elementMatch.d.ts.map +1 -0
  231. package/dist/filter/kinds/entries.d.ts +20 -0
  232. package/dist/filter/kinds/entries.d.ts.map +1 -0
  233. package/dist/filter/kinds/enum.d.ts +7 -0
  234. package/dist/filter/kinds/enum.d.ts.map +1 -0
  235. package/dist/filter/kinds/index.d.ts +18 -0
  236. package/dist/filter/kinds/index.d.ts.map +1 -0
  237. package/dist/filter/kinds/metadata.d.ts +3 -0
  238. package/dist/filter/kinds/metadata.d.ts.map +1 -0
  239. package/dist/filter/kinds/number.d.ts +3 -0
  240. package/dist/filter/kinds/number.d.ts.map +1 -0
  241. package/dist/filter/kinds/options.d.ts +44 -0
  242. package/dist/filter/kinds/options.d.ts.map +1 -0
  243. package/dist/filter/kinds/presence.d.ts +18 -0
  244. package/dist/filter/kinds/presence.d.ts.map +1 -0
  245. package/dist/filter/kinds/reference.d.ts +8 -0
  246. package/dist/filter/kinds/reference.d.ts.map +1 -0
  247. package/dist/filter/kinds/search.d.ts +15 -0
  248. package/dist/filter/kinds/search.d.ts.map +1 -0
  249. package/dist/filter/kinds/string.d.ts +3 -0
  250. package/dist/filter/kinds/string.d.ts.map +1 -0
  251. package/dist/filter/marks.d.ts +28 -0
  252. package/dist/filter/marks.d.ts.map +1 -0
  253. package/dist/filter/search.d.ts +28 -0
  254. package/dist/filter/search.d.ts.map +1 -0
  255. package/dist/filter/time.d.ts +57 -0
  256. package/dist/filter/time.d.ts.map +1 -0
  257. package/dist/filter/tree.d.ts +186 -0
  258. package/dist/filter/tree.d.ts.map +1 -0
  259. package/dist/filter/validate.d.ts +42 -0
  260. package/dist/filter/validate.d.ts.map +1 -0
  261. package/dist/filter/values.d.ts +111 -0
  262. package/dist/filter/values.d.ts.map +1 -0
  263. package/dist/index.d.ts +138 -0
  264. package/dist/index.d.ts.map +1 -0
  265. package/dist/index.js +478 -0
  266. package/dist/index.js.map +1 -0
  267. package/dist/model/analysis.d.ts +327 -0
  268. package/dist/model/analysis.d.ts.map +1 -0
  269. package/dist/model/chart.d.ts +503 -0
  270. package/dist/model/chart.d.ts.map +1 -0
  271. package/dist/model/config.d.ts +68 -0
  272. package/dist/model/config.d.ts.map +1 -0
  273. package/dist/model/currency.d.ts +55 -0
  274. package/dist/model/currency.d.ts.map +1 -0
  275. package/dist/model/dashboard.d.ts +454 -0
  276. package/dist/model/dashboard.d.ts.map +1 -0
  277. package/dist/model/definition.d.ts +373 -0
  278. package/dist/model/definition.d.ts.map +1 -0
  279. package/dist/model/field.d.ts +432 -0
  280. package/dist/model/field.d.ts.map +1 -0
  281. package/dist/model/filter.d.ts +54 -0
  282. package/dist/model/filter.d.ts.map +1 -0
  283. package/dist/model/index.d.ts +21 -0
  284. package/dist/model/index.d.ts.map +1 -0
  285. package/dist/model/instance.d.ts +118 -0
  286. package/dist/model/instance.d.ts.map +1 -0
  287. package/dist/model/issue.d.ts +33 -0
  288. package/dist/model/issue.d.ts.map +1 -0
  289. package/dist/model/json.d.ts +34 -0
  290. package/dist/model/json.d.ts.map +1 -0
  291. package/dist/model/limits.d.ts +133 -0
  292. package/dist/model/limits.d.ts.map +1 -0
  293. package/dist/model/record.d.ts +114 -0
  294. package/dist/model/record.d.ts.map +1 -0
  295. package/dist/model/storeError.d.ts +105 -0
  296. package/dist/model/storeError.d.ts.map +1 -0
  297. package/dist/model/text.d.ts +58 -0
  298. package/dist/model/text.d.ts.map +1 -0
  299. package/dist/react/actionRunner.d.ts +161 -0
  300. package/dist/react/actionRunner.d.ts.map +1 -0
  301. package/dist/react/actions.d.ts +112 -0
  302. package/dist/react/actions.d.ts.map +1 -0
  303. package/dist/react/analysisEditing.d.ts +122 -0
  304. package/dist/react/analysisEditing.d.ts.map +1 -0
  305. package/dist/react/analysisFields.d.ts +38 -0
  306. package/dist/react/analysisFields.d.ts.map +1 -0
  307. package/dist/react/environment.d.ts +10 -0
  308. package/dist/react/environment.d.ts.map +1 -0
  309. package/dist/react/index.d.ts +41 -0
  310. package/dist/react/index.d.ts.map +1 -0
  311. package/dist/react/issues.d.ts +14 -0
  312. package/dist/react/issues.d.ts.map +1 -0
  313. package/dist/react/manager/abilities.d.ts +38 -0
  314. package/dist/react/manager/abilities.d.ts.map +1 -0
  315. package/dist/react/manager/order.d.ts +60 -0
  316. package/dist/react/manager/order.d.ts.map +1 -0
  317. package/dist/react/manager/outcomes.d.ts +55 -0
  318. package/dist/react/manager/outcomes.d.ts.map +1 -0
  319. package/dist/react/manager/queue.d.ts +56 -0
  320. package/dist/react/manager/queue.d.ts.map +1 -0
  321. package/dist/react/manager/useCommandRunner.d.ts +74 -0
  322. package/dist/react/manager/useCommandRunner.d.ts.map +1 -0
  323. package/dist/react/recordColumns.d.ts +68 -0
  324. package/dist/react/recordColumns.d.ts.map +1 -0
  325. package/dist/react/recordDraft.d.ts +31 -0
  326. package/dist/react/recordDraft.d.ts.map +1 -0
  327. package/dist/react/recordEdits.d.ts +58 -0
  328. package/dist/react/recordEdits.d.ts.map +1 -0
  329. package/dist/react/recordSelection.d.ts +46 -0
  330. package/dist/react/recordSelection.d.ts.map +1 -0
  331. package/dist/react/useAnalysisEditor.d.ts +183 -0
  332. package/dist/react/useAnalysisEditor.d.ts.map +1 -0
  333. package/dist/react/useAnalysisResult.d.ts +168 -0
  334. package/dist/react/useAnalysisResult.d.ts.map +1 -0
  335. package/dist/react/useAutoRefresh.d.ts +115 -0
  336. package/dist/react/useAutoRefresh.d.ts.map +1 -0
  337. package/dist/react/useDashboard.d.ts +204 -0
  338. package/dist/react/useDashboard.d.ts.map +1 -0
  339. package/dist/react/useFilterEditor.d.ts +255 -0
  340. package/dist/react/useFilterEditor.d.ts.map +1 -0
  341. package/dist/react/usePanelFollowUps.d.ts +31 -0
  342. package/dist/react/usePanelFollowUps.d.ts.map +1 -0
  343. package/dist/react/useRecordActions.d.ts +126 -0
  344. package/dist/react/useRecordActions.d.ts.map +1 -0
  345. package/dist/react/useRecordDetail.d.ts +76 -0
  346. package/dist/react/useRecordDetail.d.ts.map +1 -0
  347. package/dist/react/useRecordExport.d.ts +104 -0
  348. package/dist/react/useRecordExport.d.ts.map +1 -0
  349. package/dist/react/useRecordTable.d.ts +309 -0
  350. package/dist/react/useRecordTable.d.ts.map +1 -0
  351. package/dist/react/useReshape.d.ts +54 -0
  352. package/dist/react/useReshape.d.ts.map +1 -0
  353. package/dist/react/useSaveCommands.d.ts +119 -0
  354. package/dist/react/useSaveCommands.d.ts.map +1 -0
  355. package/dist/react/useSearchBox.d.ts +34 -0
  356. package/dist/react/useSearchBox.d.ts.map +1 -0
  357. package/dist/react/useUnavailable.d.ts +19 -0
  358. package/dist/react/useUnavailable.d.ts.map +1 -0
  359. package/dist/react/useValueCandidates.d.ts +41 -0
  360. package/dist/react/useValueCandidates.d.ts.map +1 -0
  361. package/dist/react/useViewEngine.d.ts +93 -0
  362. package/dist/react/useViewEngine.d.ts.map +1 -0
  363. package/dist/react/useViewList.d.ts +75 -0
  364. package/dist/react/useViewList.d.ts.map +1 -0
  365. package/dist/react/useViewManager.d.ts +92 -0
  366. package/dist/react/useViewManager.d.ts.map +1 -0
  367. package/dist/react/useWorkbench.d.ts +334 -0
  368. package/dist/react/useWorkbench.d.ts.map +1 -0
  369. package/dist/react/workbench/handOver.d.ts +73 -0
  370. package/dist/react/workbench/handOver.d.ts.map +1 -0
  371. package/dist/react/workbench/instanceSync.d.ts +55 -0
  372. package/dist/react/workbench/instanceSync.d.ts.map +1 -0
  373. package/dist/react/workbench/leaveGuard.d.ts +65 -0
  374. package/dist/react/workbench/leaveGuard.d.ts.map +1 -0
  375. package/dist/react/workbench/newView.d.ts +35 -0
  376. package/dist/react/workbench/newView.d.ts.map +1 -0
  377. package/dist/react/workbench/releaseDeleted.d.ts +19 -0
  378. package/dist/react/workbench/releaseDeleted.d.ts.map +1 -0
  379. package/dist/react/writes.d.ts +134 -0
  380. package/dist/react/writes.d.ts.map +1 -0
  381. package/dist/react-DzstAsWB.js +3648 -0
  382. package/dist/react-DzstAsWB.js.map +1 -0
  383. package/dist/react-router/index.d.ts +12 -0
  384. package/dist/react-router/index.d.ts.map +1 -0
  385. package/dist/react-router.js +27 -0
  386. package/dist/react-router.js.map +1 -0
  387. package/dist/react.js +3 -0
  388. package/dist/record/compile.d.ts +56 -0
  389. package/dist/record/compile.d.ts.map +1 -0
  390. package/dist/record/defaults.d.ts +9 -0
  391. package/dist/record/defaults.d.ts.map +1 -0
  392. package/dist/record/detail.d.ts +27 -0
  393. package/dist/record/detail.d.ts.map +1 -0
  394. package/dist/record/export.d.ts +78 -0
  395. package/dist/record/export.d.ts.map +1 -0
  396. package/dist/record/index.d.ts +12 -0
  397. package/dist/record/index.d.ts.map +1 -0
  398. package/dist/record/paging.d.ts +89 -0
  399. package/dist/record/paging.d.ts.map +1 -0
  400. package/dist/record/path.d.ts +13 -0
  401. package/dist/record/path.d.ts.map +1 -0
  402. package/dist/record/project.d.ts +245 -0
  403. package/dist/record/project.d.ts.map +1 -0
  404. package/dist/record/summaryCurrency.d.ts +18 -0
  405. package/dist/record/summaryCurrency.d.ts.map +1 -0
  406. package/dist/record/validate.d.ts +30 -0
  407. package/dist/record/validate.d.ts.map +1 -0
  408. package/dist/routes-DvPNPlQP.js +23 -0
  409. package/dist/routes-DvPNPlQP.js.map +1 -0
  410. package/dist/runtime/abort.d.ts +3 -0
  411. package/dist/runtime/abort.d.ts.map +1 -0
  412. package/dist/runtime/actions.d.ts +241 -0
  413. package/dist/runtime/actions.d.ts.map +1 -0
  414. package/dist/runtime/admission.d.ts +35 -0
  415. package/dist/runtime/admission.d.ts.map +1 -0
  416. package/dist/runtime/autoApply.d.ts +51 -0
  417. package/dist/runtime/autoApply.d.ts.map +1 -0
  418. package/dist/runtime/capabilities.d.ts +98 -0
  419. package/dist/runtime/capabilities.d.ts.map +1 -0
  420. package/dist/runtime/commandChecks.d.ts +22 -0
  421. package/dist/runtime/commandChecks.d.ts.map +1 -0
  422. package/dist/runtime/dashboard/anchor.d.ts +46 -0
  423. package/dist/runtime/dashboard/anchor.d.ts.map +1 -0
  424. package/dist/runtime/dashboard/canonical.d.ts +31 -0
  425. package/dist/runtime/dashboard/canonical.d.ts.map +1 -0
  426. package/dist/runtime/dashboard/children.d.ts +127 -0
  427. package/dist/runtime/dashboard/children.d.ts.map +1 -0
  428. package/dist/runtime/dashboard/commands.d.ts +172 -0
  429. package/dist/runtime/dashboard/commands.d.ts.map +1 -0
  430. package/dist/runtime/dashboard/contract.d.ts +250 -0
  431. package/dist/runtime/dashboard/contract.d.ts.map +1 -0
  432. package/dist/runtime/dashboard/editing.d.ts +197 -0
  433. package/dist/runtime/dashboard/editing.d.ts.map +1 -0
  434. package/dist/runtime/dashboard/filterCandidates.d.ts +38 -0
  435. package/dist/runtime/dashboard/filterCandidates.d.ts.map +1 -0
  436. package/dist/runtime/dashboard/filterValues.d.ts +117 -0
  437. package/dist/runtime/dashboard/filterValues.d.ts.map +1 -0
  438. package/dist/runtime/dashboard/grouping.d.ts +26 -0
  439. package/dist/runtime/dashboard/grouping.d.ts.map +1 -0
  440. package/dist/runtime/dashboard/history.d.ts +78 -0
  441. package/dist/runtime/dashboard/history.d.ts.map +1 -0
  442. package/dist/runtime/dashboard/opening.d.ts +17 -0
  443. package/dist/runtime/dashboard/opening.d.ts.map +1 -0
  444. package/dist/runtime/dashboard/owned.d.ts +38 -0
  445. package/dist/runtime/dashboard/owned.d.ts.map +1 -0
  446. package/dist/runtime/dashboard/panelRun.d.ts +101 -0
  447. package/dist/runtime/dashboard/panelRun.d.ts.map +1 -0
  448. package/dist/runtime/dashboard/panels.d.ts +155 -0
  449. package/dist/runtime/dashboard/panels.d.ts.map +1 -0
  450. package/dist/runtime/dashboard/presentation.d.ts +25 -0
  451. package/dist/runtime/dashboard/presentation.d.ts.map +1 -0
  452. package/dist/runtime/dashboard/press.d.ts +150 -0
  453. package/dist/runtime/dashboard/press.d.ts.map +1 -0
  454. package/dist/runtime/dashboard/references.d.ts +97 -0
  455. package/dist/runtime/dashboard/references.d.ts.map +1 -0
  456. package/dist/runtime/dashboardRuntime.d.ts +235 -0
  457. package/dist/runtime/dashboardRuntime.d.ts.map +1 -0
  458. package/dist/runtime/define/analysis.d.ts +8 -0
  459. package/dist/runtime/define/analysis.d.ts.map +1 -0
  460. package/dist/runtime/define/defineView.d.ts +42 -0
  461. package/dist/runtime/define/defineView.d.ts.map +1 -0
  462. package/dist/runtime/define/fields.d.ts +23 -0
  463. package/dist/runtime/define/fields.d.ts.map +1 -0
  464. package/dist/runtime/define/spec.d.ts +88 -0
  465. package/dist/runtime/define/spec.d.ts.map +1 -0
  466. package/dist/runtime/definitions.d.ts +35 -0
  467. package/dist/runtime/definitions.d.ts.map +1 -0
  468. package/dist/runtime/deprecated.d.ts +3 -0
  469. package/dist/runtime/deprecated.d.ts.map +1 -0
  470. package/dist/runtime/environment.d.ts +95 -0
  471. package/dist/runtime/environment.d.ts.map +1 -0
  472. package/dist/runtime/execute.d.ts +70 -0
  473. package/dist/runtime/execute.d.ts.map +1 -0
  474. package/dist/runtime/exportRows.d.ts +67 -0
  475. package/dist/runtime/exportRows.d.ts.map +1 -0
  476. package/dist/runtime/failures.d.ts +57 -0
  477. package/dist/runtime/failures.d.ts.map +1 -0
  478. package/dist/runtime/fetchRecord.d.ts +20 -0
  479. package/dist/runtime/fetchRecord.d.ts.map +1 -0
  480. package/dist/runtime/index.d.ts +35 -0
  481. package/dist/runtime/index.d.ts.map +1 -0
  482. package/dist/runtime/issueReport.d.ts +25 -0
  483. package/dist/runtime/issueReport.d.ts.map +1 -0
  484. package/dist/runtime/issues.d.ts +35 -0
  485. package/dist/runtime/issues.d.ts.map +1 -0
  486. package/dist/runtime/listeners.d.ts +36 -0
  487. package/dist/runtime/listeners.d.ts.map +1 -0
  488. package/dist/runtime/navigation.d.ts +139 -0
  489. package/dist/runtime/navigation.d.ts.map +1 -0
  490. package/dist/runtime/openRuntimes.d.ts +34 -0
  491. package/dist/runtime/openRuntimes.d.ts.map +1 -0
  492. package/dist/runtime/panelViews.d.ts +42 -0
  493. package/dist/runtime/panelViews.d.ts.map +1 -0
  494. package/dist/runtime/pending.d.ts +75 -0
  495. package/dist/runtime/pending.d.ts.map +1 -0
  496. package/dist/runtime/permissions.d.ts +80 -0
  497. package/dist/runtime/permissions.d.ts.map +1 -0
  498. package/dist/runtime/preferences.d.ts +37 -0
  499. package/dist/runtime/preferences.d.ts.map +1 -0
  500. package/dist/runtime/publish.d.ts +38 -0
  501. package/dist/runtime/publish.d.ts.map +1 -0
  502. package/dist/runtime/queryFailure.d.ts +59 -0
  503. package/dist/runtime/queryFailure.d.ts.map +1 -0
  504. package/dist/runtime/queryWeight.d.ts +29 -0
  505. package/dist/runtime/queryWeight.d.ts.map +1 -0
  506. package/dist/runtime/recordRuntime.d.ts +88 -0
  507. package/dist/runtime/recordRuntime.d.ts.map +1 -0
  508. package/dist/runtime/refreshTimer.d.ts +72 -0
  509. package/dist/runtime/refreshTimer.d.ts.map +1 -0
  510. package/dist/runtime/requestId.d.ts +11 -0
  511. package/dist/runtime/requestId.d.ts.map +1 -0
  512. package/dist/runtime/requestRunner.d.ts +58 -0
  513. package/dist/runtime/requestRunner.d.ts.map +1 -0
  514. package/dist/runtime/resources.d.ts +73 -0
  515. package/dist/runtime/resources.d.ts.map +1 -0
  516. package/dist/runtime/restyle.d.ts +21 -0
  517. package/dist/runtime/restyle.d.ts.map +1 -0
  518. package/dist/runtime/routes.d.ts +99 -0
  519. package/dist/runtime/routes.d.ts.map +1 -0
  520. package/dist/runtime/runtimeFactory.d.ts +80 -0
  521. package/dist/runtime/runtimeFactory.d.ts.map +1 -0
  522. package/dist/runtime/runtimeStore.d.ts +187 -0
  523. package/dist/runtime/runtimeStore.d.ts.map +1 -0
  524. package/dist/runtime/savedConditions.d.ts +11 -0
  525. package/dist/runtime/savedConditions.d.ts.map +1 -0
  526. package/dist/runtime/scope.d.ts +50 -0
  527. package/dist/runtime/scope.d.ts.map +1 -0
  528. package/dist/runtime/source.d.ts +108 -0
  529. package/dist/runtime/source.d.ts.map +1 -0
  530. package/dist/runtime/sourceReason.d.ts +65 -0
  531. package/dist/runtime/sourceReason.d.ts.map +1 -0
  532. package/dist/runtime/storedViews.d.ts +17 -0
  533. package/dist/runtime/storedViews.d.ts.map +1 -0
  534. package/dist/runtime/summaries.d.ts +25 -0
  535. package/dist/runtime/summaries.d.ts.map +1 -0
  536. package/dist/runtime/tabMemory.d.ts +39 -0
  537. package/dist/runtime/tabMemory.d.ts.map +1 -0
  538. package/dist/runtime/text.d.ts +20 -0
  539. package/dist/runtime/text.d.ts.map +1 -0
  540. package/dist/runtime/unavailable.d.ts +13 -0
  541. package/dist/runtime/unavailable.d.ts.map +1 -0
  542. package/dist/runtime/validateDefinition.d.ts +43 -0
  543. package/dist/runtime/validateDefinition.d.ts.map +1 -0
  544. package/dist/runtime/validateFields.d.ts +9 -0
  545. package/dist/runtime/validateFields.d.ts.map +1 -0
  546. package/dist/runtime/valueCandidates.d.ts +58 -0
  547. package/dist/runtime/valueCandidates.d.ts.map +1 -0
  548. package/dist/runtime/viewChanges.d.ts +39 -0
  549. package/dist/runtime/viewChanges.d.ts.map +1 -0
  550. package/dist/runtime/viewEngine.d.ts +292 -0
  551. package/dist/runtime/viewEngine.d.ts.map +1 -0
  552. package/dist/runtime/viewRuntime.d.ts +199 -0
  553. package/dist/runtime/viewRuntime.d.ts.map +1 -0
  554. package/dist/runtime/viewRuntimeTypes.d.ts +445 -0
  555. package/dist/runtime/viewRuntimeTypes.d.ts.map +1 -0
  556. package/dist/runtime/write.d.ts +96 -0
  557. package/dist/runtime/write.d.ts.map +1 -0
  558. package/dist/runtime/writeLedger.d.ts +134 -0
  559. package/dist/runtime/writeLedger.d.ts.map +1 -0
  560. package/dist/shadcn-bridge.css +107 -0
  561. package/dist/store/MemoryViewStore.d.ts +134 -0
  562. package/dist/store/MemoryViewStore.d.ts.map +1 -0
  563. package/dist/store/ViewStore.d.ts +116 -0
  564. package/dist/store/ViewStore.d.ts.map +1 -0
  565. package/dist/store/index.d.ts +10 -0
  566. package/dist/store/index.d.ts.map +1 -0
  567. package/dist/store/localStorageSnapshot.d.ts +65 -0
  568. package/dist/store/localStorageSnapshot.d.ts.map +1 -0
  569. package/dist/styles.css +3 -0
  570. package/dist/styles.d.ts +1 -0
  571. package/dist/styles.d.ts.map +1 -0
  572. package/dist/styles.js +0 -0
  573. package/dist/testing/actions.d.ts +78 -0
  574. package/dist/testing/actions.d.ts.map +1 -0
  575. package/dist/testing/aggregate.d.ts +24 -0
  576. package/dist/testing/aggregate.d.ts.map +1 -0
  577. package/dist/testing/calendar.d.ts +41 -0
  578. package/dist/testing/calendar.d.ts.map +1 -0
  579. package/dist/testing/expression.d.ts +17 -0
  580. package/dist/testing/expression.d.ts.map +1 -0
  581. package/dist/testing/filter.d.ts +48 -0
  582. package/dist/testing/filter.d.ts.map +1 -0
  583. package/dist/testing/index.d.ts +13 -0
  584. package/dist/testing/index.d.ts.map +1 -0
  585. package/dist/testing/source.d.ts +52 -0
  586. package/dist/testing/source.d.ts.map +1 -0
  587. package/dist/testing/values.d.ts +14 -0
  588. package/dist/testing/values.d.ts.map +1 -0
  589. package/dist/testing.js +725 -0
  590. package/dist/testing.js.map +1 -0
  591. package/dist/theme-check.mjs +6972 -0
  592. package/dist/theme-source.css +1393 -0
  593. package/dist/theme-tokens.json +5335 -0
  594. package/dist/themes/azure.css +126 -0
  595. package/dist/themes/contrast.css +122 -0
  596. package/dist/themes/neutral.css +2 -0
  597. package/dist/themes/porcelain.css +136 -0
  598. package/dist/themes.css +389 -0
  599. package/dist/ui/DashboardWorkbench.d.ts +133 -0
  600. package/dist/ui/DashboardWorkbench.d.ts.map +1 -0
  601. package/dist/ui/DataWorkbench.d.ts +155 -0
  602. package/dist/ui/DataWorkbench.d.ts.map +1 -0
  603. package/dist/ui/EmbeddedDashboard.d.ts +103 -0
  604. package/dist/ui/EmbeddedDashboard.d.ts.map +1 -0
  605. package/dist/ui/EmbeddedView.d.ts +76 -0
  606. package/dist/ui/EmbeddedView.d.ts.map +1 -0
  607. package/dist/ui/ViewHost.d.ts +94 -0
  608. package/dist/ui/ViewHost.d.ts.map +1 -0
  609. package/dist/ui/actions/ActionButtons.d.ts +49 -0
  610. package/dist/ui/actions/ActionButtons.d.ts.map +1 -0
  611. package/dist/ui/actions/ActionDialog.d.ts +35 -0
  612. package/dist/ui/actions/ActionDialog.d.ts.map +1 -0
  613. package/dist/ui/actions/ActionSurface.d.ts +60 -0
  614. package/dist/ui/actions/ActionSurface.d.ts.map +1 -0
  615. package/dist/ui/actions/BulkStatus.d.ts +41 -0
  616. package/dist/ui/actions/BulkStatus.d.ts.map +1 -0
  617. package/dist/ui/analysis/AnalysisChart.d.ts +71 -0
  618. package/dist/ui/analysis/AnalysisChart.d.ts.map +1 -0
  619. package/dist/ui/analysis/AnalysisTable.d.ts +54 -0
  620. package/dist/ui/analysis/AnalysisTable.d.ts.map +1 -0
  621. package/dist/ui/analysis/AnalysisToolbar.d.ts +68 -0
  622. package/dist/ui/analysis/AnalysisToolbar.d.ts.map +1 -0
  623. package/dist/ui/analysis/AxesTab.d.ts +11 -0
  624. package/dist/ui/analysis/AxesTab.d.ts.map +1 -0
  625. package/dist/ui/analysis/CardMenu.d.ts +41 -0
  626. package/dist/ui/analysis/CardMenu.d.ts.map +1 -0
  627. package/dist/ui/analysis/ChartOptions.d.ts +38 -0
  628. package/dist/ui/analysis/ChartOptions.d.ts.map +1 -0
  629. package/dist/ui/analysis/ChartPicker.d.ts +86 -0
  630. package/dist/ui/analysis/ChartPicker.d.ts.map +1 -0
  631. package/dist/ui/analysis/CompactSelect.d.ts +28 -0
  632. package/dist/ui/analysis/CompactSelect.d.ts.map +1 -0
  633. package/dist/ui/analysis/CompositionOptions.d.ts +18 -0
  634. package/dist/ui/analysis/CompositionOptions.d.ts.map +1 -0
  635. package/dist/ui/analysis/CurrencyStrip.d.ts +19 -0
  636. package/dist/ui/analysis/CurrencyStrip.d.ts.map +1 -0
  637. package/dist/ui/analysis/DataTab.d.ts +10 -0
  638. package/dist/ui/analysis/DataTab.d.ts.map +1 -0
  639. package/dist/ui/analysis/DimensionCard.d.ts +13 -0
  640. package/dist/ui/analysis/DimensionCard.d.ts.map +1 -0
  641. package/dist/ui/analysis/DisplayTab.d.ts +26 -0
  642. package/dist/ui/analysis/DisplayTab.d.ts.map +1 -0
  643. package/dist/ui/analysis/DrillMenu.d.ts +73 -0
  644. package/dist/ui/analysis/DrillMenu.d.ts.map +1 -0
  645. package/dist/ui/analysis/DroppedNotice.d.ts +28 -0
  646. package/dist/ui/analysis/DroppedNotice.d.ts.map +1 -0
  647. package/dist/ui/analysis/ElementsSlot.d.ts +22 -0
  648. package/dist/ui/analysis/ElementsSlot.d.ts.map +1 -0
  649. package/dist/ui/analysis/EmptyResult.d.ts +50 -0
  650. package/dist/ui/analysis/EmptyResult.d.ts.map +1 -0
  651. package/dist/ui/analysis/ExportMenu.d.ts +35 -0
  652. package/dist/ui/analysis/ExportMenu.d.ts.map +1 -0
  653. package/dist/ui/analysis/FormulaCard.d.ts +46 -0
  654. package/dist/ui/analysis/FormulaCard.d.ts.map +1 -0
  655. package/dist/ui/analysis/HavingRows.d.ts +50 -0
  656. package/dist/ui/analysis/HavingRows.d.ts.map +1 -0
  657. package/dist/ui/analysis/LevelOptions.d.ts +21 -0
  658. package/dist/ui/analysis/LevelOptions.d.ts.map +1 -0
  659. package/dist/ui/analysis/MapOptions.d.ts +8 -0
  660. package/dist/ui/analysis/MapOptions.d.ts.map +1 -0
  661. package/dist/ui/analysis/MetricCard.d.ts +29 -0
  662. package/dist/ui/analysis/MetricCard.d.ts.map +1 -0
  663. package/dist/ui/analysis/MetricCondition.d.ts +73 -0
  664. package/dist/ui/analysis/MetricCondition.d.ts.map +1 -0
  665. package/dist/ui/analysis/MetricSlot.d.ts +35 -0
  666. package/dist/ui/analysis/MetricSlot.d.ts.map +1 -0
  667. package/dist/ui/analysis/OrderedCards.d.ts +39 -0
  668. package/dist/ui/analysis/OrderedCards.d.ts.map +1 -0
  669. package/dist/ui/analysis/RangeSlot.d.ts +26 -0
  670. package/dist/ui/analysis/RangeSlot.d.ts.map +1 -0
  671. package/dist/ui/analysis/ReferenceOptions.d.ts +12 -0
  672. package/dist/ui/analysis/ReferenceOptions.d.ts.map +1 -0
  673. package/dist/ui/analysis/ResultSlot.d.ts +31 -0
  674. package/dist/ui/analysis/ResultSlot.d.ts.map +1 -0
  675. package/dist/ui/analysis/SeriesList.d.ts +35 -0
  676. package/dist/ui/analysis/SeriesList.d.ts.map +1 -0
  677. package/dist/ui/analysis/SkeletonResult.d.ts +36 -0
  678. package/dist/ui/analysis/SkeletonResult.d.ts.map +1 -0
  679. package/dist/ui/analysis/StatisticalOptions.d.ts +31 -0
  680. package/dist/ui/analysis/StatisticalOptions.d.ts.map +1 -0
  681. package/dist/ui/analysis/TermTip.d.ts +32 -0
  682. package/dist/ui/analysis/TermTip.d.ts.map +1 -0
  683. package/dist/ui/analysis/Tray.d.ts +45 -0
  684. package/dist/ui/analysis/Tray.d.ts.map +1 -0
  685. package/dist/ui/analysis/VisualizationPanel.d.ts +68 -0
  686. package/dist/ui/analysis/VisualizationPanel.d.ts.map +1 -0
  687. package/dist/ui/analysis/chartIcons.d.ts +19 -0
  688. package/dist/ui/analysis/chartIcons.d.ts.map +1 -0
  689. package/dist/ui/analysis/drag.d.ts +39 -0
  690. package/dist/ui/analysis/drag.d.ts.map +1 -0
  691. package/dist/ui/analysis/editing.d.ts +69 -0
  692. package/dist/ui/analysis/editing.d.ts.map +1 -0
  693. package/dist/ui/analysis/exportOffer.d.ts +60 -0
  694. package/dist/ui/analysis/exportOffer.d.ts.map +1 -0
  695. package/dist/ui/analysis/headerSort.d.ts +66 -0
  696. package/dist/ui/analysis/headerSort.d.ts.map +1 -0
  697. package/dist/ui/analysis/imageExport.d.ts +40 -0
  698. package/dist/ui/analysis/imageExport.d.ts.map +1 -0
  699. package/dist/ui/analysis/issueNames.d.ts +39 -0
  700. package/dist/ui/analysis/issueNames.d.ts.map +1 -0
  701. package/dist/ui/analysis/listFocus.d.ts +42 -0
  702. package/dist/ui/analysis/listFocus.d.ts.map +1 -0
  703. package/dist/ui/analysis/optionControls.d.ts +200 -0
  704. package/dist/ui/analysis/optionControls.d.ts.map +1 -0
  705. package/dist/ui/analysis/tableColumns.d.ts +79 -0
  706. package/dist/ui/analysis/tableColumns.d.ts.map +1 -0
  707. package/dist/ui/analysis/virtualRows.d.ts +66 -0
  708. package/dist/ui/analysis/virtualRows.d.ts.map +1 -0
  709. package/dist/ui/charts/Boxplot.d.ts +10 -0
  710. package/dist/ui/charts/Boxplot.d.ts.map +1 -0
  711. package/dist/ui/charts/Candlestick.d.ts +9 -0
  712. package/dist/ui/charts/Candlestick.d.ts.map +1 -0
  713. package/dist/ui/charts/Cartesian.d.ts +9 -0
  714. package/dist/ui/charts/Cartesian.d.ts.map +1 -0
  715. package/dist/ui/charts/ChartLegend.d.ts +47 -0
  716. package/dist/ui/charts/ChartLegend.d.ts.map +1 -0
  717. package/dist/ui/charts/ChartNotes.d.ts +14 -0
  718. package/dist/ui/charts/ChartNotes.d.ts.map +1 -0
  719. package/dist/ui/charts/ChartReading.d.ts +15 -0
  720. package/dist/ui/charts/ChartReading.d.ts.map +1 -0
  721. package/dist/ui/charts/EChart.d.ts +177 -0
  722. package/dist/ui/charts/EChart.d.ts.map +1 -0
  723. package/dist/ui/charts/Funnel.d.ts +27 -0
  724. package/dist/ui/charts/Funnel.d.ts.map +1 -0
  725. package/dist/ui/charts/Gauge.d.ts +9 -0
  726. package/dist/ui/charts/Gauge.d.ts.map +1 -0
  727. package/dist/ui/charts/GeoMap.d.ts +11 -0
  728. package/dist/ui/charts/GeoMap.d.ts.map +1 -0
  729. package/dist/ui/charts/Heatmap.d.ts +9 -0
  730. package/dist/ui/charts/Heatmap.d.ts.map +1 -0
  731. package/dist/ui/charts/Hierarchy.d.ts +12 -0
  732. package/dist/ui/charts/Hierarchy.d.ts.map +1 -0
  733. package/dist/ui/charts/MetricCard.d.ts +4 -0
  734. package/dist/ui/charts/MetricCard.d.ts.map +1 -0
  735. package/dist/ui/charts/PieSlices.d.ts +26 -0
  736. package/dist/ui/charts/PieSlices.d.ts.map +1 -0
  737. package/dist/ui/charts/Profiles.d.ts +11 -0
  738. package/dist/ui/charts/Profiles.d.ts.map +1 -0
  739. package/dist/ui/charts/ScatterPoints.d.ts +5 -0
  740. package/dist/ui/charts/ScatterPoints.d.ts.map +1 -0
  741. package/dist/ui/charts/TimeCharts.d.ts +10 -0
  742. package/dist/ui/charts/TimeCharts.d.ts.map +1 -0
  743. package/dist/ui/charts/Treemap.d.ts +12 -0
  744. package/dist/ui/charts/Treemap.d.ts.map +1 -0
  745. package/dist/ui/charts/Waterfall.d.ts +11 -0
  746. package/dist/ui/charts/Waterfall.d.ts.map +1 -0
  747. package/dist/ui/charts/axis.d.ts +101 -0
  748. package/dist/ui/charts/axis.d.ts.map +1 -0
  749. package/dist/ui/charts/boxplotOption.d.ts +33 -0
  750. package/dist/ui/charts/boxplotOption.d.ts.map +1 -0
  751. package/dist/ui/charts/candlestickOption.d.ts +42 -0
  752. package/dist/ui/charts/candlestickOption.d.ts.map +1 -0
  753. package/dist/ui/charts/cartesianBrush.d.ts +84 -0
  754. package/dist/ui/charts/cartesianBrush.d.ts.map +1 -0
  755. package/dist/ui/charts/cartesianFit.d.ts +72 -0
  756. package/dist/ui/charts/cartesianFit.d.ts.map +1 -0
  757. package/dist/ui/charts/cartesianMarks.d.ts +116 -0
  758. package/dist/ui/charts/cartesianMarks.d.ts.map +1 -0
  759. package/dist/ui/charts/cartesianOption.d.ts +32 -0
  760. package/dist/ui/charts/cartesianOption.d.ts.map +1 -0
  761. package/dist/ui/charts/cartesianPlan.d.ts +263 -0
  762. package/dist/ui/charts/cartesianPlan.d.ts.map +1 -0
  763. package/dist/ui/charts/cartesianSeries.d.ts +41 -0
  764. package/dist/ui/charts/cartesianSeries.d.ts.map +1 -0
  765. package/dist/ui/charts/cartesianTooltip.d.ts +14 -0
  766. package/dist/ui/charts/cartesianTooltip.d.ts.map +1 -0
  767. package/dist/ui/charts/cartesianZoom.d.ts +60 -0
  768. package/dist/ui/charts/cartesianZoom.d.ts.map +1 -0
  769. package/dist/ui/charts/categoryFrame.d.ts +106 -0
  770. package/dist/ui/charts/categoryFrame.d.ts.map +1 -0
  771. package/dist/ui/charts/dateTicks.d.ts +36 -0
  772. package/dist/ui/charts/dateTicks.d.ts.map +1 -0
  773. package/dist/ui/charts/echarts.d.ts +16 -0
  774. package/dist/ui/charts/echarts.d.ts.map +1 -0
  775. package/dist/ui/charts/echartsGeo.d.ts +5 -0
  776. package/dist/ui/charts/echartsGeo.d.ts.map +1 -0
  777. package/dist/ui/charts/echartsHierarchy.d.ts +2 -0
  778. package/dist/ui/charts/echartsHierarchy.d.ts.map +1 -0
  779. package/dist/ui/charts/echartsStatistics.d.ts +2 -0
  780. package/dist/ui/charts/echartsStatistics.d.ts.map +1 -0
  781. package/dist/ui/charts/echartsTime.d.ts +2 -0
  782. package/dist/ui/charts/echartsTime.d.ts.map +1 -0
  783. package/dist/ui/charts/family.d.ts +176 -0
  784. package/dist/ui/charts/family.d.ts.map +1 -0
  785. package/dist/ui/charts/frameClass.d.ts +18 -0
  786. package/dist/ui/charts/frameClass.d.ts.map +1 -0
  787. package/dist/ui/charts/funnelFit.d.ts +67 -0
  788. package/dist/ui/charts/funnelFit.d.ts.map +1 -0
  789. package/dist/ui/charts/funnelOption.d.ts +94 -0
  790. package/dist/ui/charts/funnelOption.d.ts.map +1 -0
  791. package/dist/ui/charts/gaugeOption.d.ts +32 -0
  792. package/dist/ui/charts/gaugeOption.d.ts.map +1 -0
  793. package/dist/ui/charts/heatmapOption.d.ts +38 -0
  794. package/dist/ui/charts/heatmapOption.d.ts.map +1 -0
  795. package/dist/ui/charts/hierarchyOption.d.ts +85 -0
  796. package/dist/ui/charts/hierarchyOption.d.ts.map +1 -0
  797. package/dist/ui/charts/highlight.d.ts +26 -0
  798. package/dist/ui/charts/highlight.d.ts.map +1 -0
  799. package/dist/ui/charts/image.d.ts +96 -0
  800. package/dist/ui/charts/image.d.ts.map +1 -0
  801. package/dist/ui/charts/legend.d.ts +11 -0
  802. package/dist/ui/charts/legend.d.ts.map +1 -0
  803. package/dist/ui/charts/load.d.ts +29 -0
  804. package/dist/ui/charts/load.d.ts.map +1 -0
  805. package/dist/ui/charts/mapOption.d.ts +39 -0
  806. package/dist/ui/charts/mapOption.d.ts.map +1 -0
  807. package/dist/ui/charts/maps.d.ts +53 -0
  808. package/dist/ui/charts/maps.d.ts.map +1 -0
  809. package/dist/ui/charts/markWords.d.ts +38 -0
  810. package/dist/ui/charts/markWords.d.ts.map +1 -0
  811. package/dist/ui/charts/measure.d.ts +2 -0
  812. package/dist/ui/charts/measure.d.ts.map +1 -0
  813. package/dist/ui/charts/motion.d.ts +15 -0
  814. package/dist/ui/charts/motion.d.ts.map +1 -0
  815. package/dist/ui/charts/optionMerge.d.ts +10 -0
  816. package/dist/ui/charts/optionMerge.d.ts.map +1 -0
  817. package/dist/ui/charts/palette.d.ts +43 -0
  818. package/dist/ui/charts/palette.d.ts.map +1 -0
  819. package/dist/ui/charts/patterns.d.ts +29 -0
  820. package/dist/ui/charts/patterns.d.ts.map +1 -0
  821. package/dist/ui/charts/periodSpan.d.ts +11 -0
  822. package/dist/ui/charts/periodSpan.d.ts.map +1 -0
  823. package/dist/ui/charts/pieOption.d.ts +107 -0
  824. package/dist/ui/charts/pieOption.d.ts.map +1 -0
  825. package/dist/ui/charts/print.d.ts +16 -0
  826. package/dist/ui/charts/print.d.ts.map +1 -0
  827. package/dist/ui/charts/profileOption.d.ts +47 -0
  828. package/dist/ui/charts/profileOption.d.ts.map +1 -0
  829. package/dist/ui/charts/reading.d.ts +66 -0
  830. package/dist/ui/charts/reading.d.ts.map +1 -0
  831. package/dist/ui/charts/readingStatistics.d.ts +58 -0
  832. package/dist/ui/charts/readingStatistics.d.ts.map +1 -0
  833. package/dist/ui/charts/scale.d.ts +42 -0
  834. package/dist/ui/charts/scale.d.ts.map +1 -0
  835. package/dist/ui/charts/scatterOption.d.ts +44 -0
  836. package/dist/ui/charts/scatterOption.d.ts.map +1 -0
  837. package/dist/ui/charts/sentence.d.ts +19 -0
  838. package/dist/ui/charts/sentence.d.ts.map +1 -0
  839. package/dist/ui/charts/sentenceParts.d.ts +36 -0
  840. package/dist/ui/charts/sentenceParts.d.ts.map +1 -0
  841. package/dist/ui/charts/sizes.d.ts +25 -0
  842. package/dist/ui/charts/sizes.d.ts.map +1 -0
  843. package/dist/ui/charts/sparklineOption.d.ts +19 -0
  844. package/dist/ui/charts/sparklineOption.d.ts.map +1 -0
  845. package/dist/ui/charts/theme.d.ts +179 -0
  846. package/dist/ui/charts/theme.d.ts.map +1 -0
  847. package/dist/ui/charts/timeOption.d.ts +54 -0
  848. package/dist/ui/charts/timeOption.d.ts.map +1 -0
  849. package/dist/ui/charts/tooltip.d.ts +51 -0
  850. package/dist/ui/charts/tooltip.d.ts.map +1 -0
  851. package/dist/ui/charts/treemapOption.d.ts +56 -0
  852. package/dist/ui/charts/treemapOption.d.ts.map +1 -0
  853. package/dist/ui/charts/waterfallOption.d.ts +58 -0
  854. package/dist/ui/charts/waterfallOption.d.ts.map +1 -0
  855. package/dist/ui/colorMode.d.ts +39 -0
  856. package/dist/ui/colorMode.d.ts.map +1 -0
  857. package/dist/ui/columns/ColumnRow.d.ts +79 -0
  858. package/dist/ui/columns/ColumnRow.d.ts.map +1 -0
  859. package/dist/ui/columns/ColumnSettings.d.ts +51 -0
  860. package/dist/ui/columns/ColumnSettings.d.ts.map +1 -0
  861. package/dist/ui/columns/WidthInput.d.ts +39 -0
  862. package/dist/ui/columns/WidthInput.d.ts.map +1 -0
  863. package/dist/ui/columns/drag.d.ts +34 -0
  864. package/dist/ui/columns/drag.d.ts.map +1 -0
  865. package/dist/ui/columns/rows.d.ts +155 -0
  866. package/dist/ui/columns/rows.d.ts.map +1 -0
  867. package/dist/ui/columns/sections.d.ts +55 -0
  868. package/dist/ui/columns/sections.d.ts.map +1 -0
  869. package/dist/ui/components/alert-dialog.d.ts +19 -0
  870. package/dist/ui/components/alert-dialog.d.ts.map +1 -0
  871. package/dist/ui/components/alert.d.ts +11 -0
  872. package/dist/ui/components/alert.d.ts.map +1 -0
  873. package/dist/ui/components/badge.d.ts +8 -0
  874. package/dist/ui/components/badge.d.ts.map +1 -0
  875. package/dist/ui/components/button-group.d.ts +11 -0
  876. package/dist/ui/components/button-group.d.ts.map +1 -0
  877. package/dist/ui/components/button.d.ts +9 -0
  878. package/dist/ui/components/button.d.ts.map +1 -0
  879. package/dist/ui/components/calendar.d.ts +11 -0
  880. package/dist/ui/components/calendar.d.ts.map +1 -0
  881. package/dist/ui/components/card.d.ts +12 -0
  882. package/dist/ui/components/card.d.ts.map +1 -0
  883. package/dist/ui/components/checkbox.d.ts +4 -0
  884. package/dist/ui/components/checkbox.d.ts.map +1 -0
  885. package/dist/ui/components/collapsible.d.ts +6 -0
  886. package/dist/ui/components/collapsible.d.ts.map +1 -0
  887. package/dist/ui/components/combobox.d.ts +25 -0
  888. package/dist/ui/components/combobox.d.ts.map +1 -0
  889. package/dist/ui/components/dialog.d.ts +18 -0
  890. package/dist/ui/components/dialog.d.ts.map +1 -0
  891. package/dist/ui/components/dropdown-menu.d.ts +30 -0
  892. package/dist/ui/components/dropdown-menu.d.ts.map +1 -0
  893. package/dist/ui/components/empty.d.ts +12 -0
  894. package/dist/ui/components/empty.d.ts.map +1 -0
  895. package/dist/ui/components/field.d.ts +25 -0
  896. package/dist/ui/components/field.d.ts.map +1 -0
  897. package/dist/ui/components/input-group.d.ts +19 -0
  898. package/dist/ui/components/input-group.d.ts.map +1 -0
  899. package/dist/ui/components/input.d.ts +4 -0
  900. package/dist/ui/components/input.d.ts.map +1 -0
  901. package/dist/ui/components/item.d.ts +23 -0
  902. package/dist/ui/components/item.d.ts.map +1 -0
  903. package/dist/ui/components/label.d.ts +4 -0
  904. package/dist/ui/components/label.d.ts.map +1 -0
  905. package/dist/ui/components/pagination.d.ts +18 -0
  906. package/dist/ui/components/pagination.d.ts.map +1 -0
  907. package/dist/ui/components/popover.d.ts +10 -0
  908. package/dist/ui/components/popover.d.ts.map +1 -0
  909. package/dist/ui/components/progress.d.ts +8 -0
  910. package/dist/ui/components/progress.d.ts.map +1 -0
  911. package/dist/ui/components/radio-group.d.ts +6 -0
  912. package/dist/ui/components/radio-group.d.ts.map +1 -0
  913. package/dist/ui/components/select.d.ts +16 -0
  914. package/dist/ui/components/select.d.ts.map +1 -0
  915. package/dist/ui/components/separator.d.ts +4 -0
  916. package/dist/ui/components/separator.d.ts.map +1 -0
  917. package/dist/ui/components/sheet.d.ts +15 -0
  918. package/dist/ui/components/sheet.d.ts.map +1 -0
  919. package/dist/ui/components/skeleton.d.ts +3 -0
  920. package/dist/ui/components/skeleton.d.ts.map +1 -0
  921. package/dist/ui/components/spinner.d.ts +3 -0
  922. package/dist/ui/components/spinner.d.ts.map +1 -0
  923. package/dist/ui/components/table.d.ts +11 -0
  924. package/dist/ui/components/table.d.ts.map +1 -0
  925. package/dist/ui/components/tabs.d.ts +11 -0
  926. package/dist/ui/components/tabs.d.ts.map +1 -0
  927. package/dist/ui/components/textarea.d.ts +4 -0
  928. package/dist/ui/components/textarea.d.ts.map +1 -0
  929. package/dist/ui/components/toast.d.ts +17 -0
  930. package/dist/ui/components/toast.d.ts.map +1 -0
  931. package/dist/ui/components/toggle-group.d.ts +12 -0
  932. package/dist/ui/components/toggle-group.d.ts.map +1 -0
  933. package/dist/ui/components/toggle.d.ts +9 -0
  934. package/dist/ui/components/toggle.d.ts.map +1 -0
  935. package/dist/ui/components/tooltip.d.ts +7 -0
  936. package/dist/ui/components/tooltip.d.ts.map +1 -0
  937. package/dist/ui/dashboard/AddMenu.d.ts +28 -0
  938. package/dist/ui/dashboard/AddMenu.d.ts.map +1 -0
  939. package/dist/ui/dashboard/Board.d.ts +49 -0
  940. package/dist/ui/dashboard/Board.d.ts.map +1 -0
  941. package/dist/ui/dashboard/BoardDestination.d.ts +48 -0
  942. package/dist/ui/dashboard/BoardDestination.d.ts.map +1 -0
  943. package/dist/ui/dashboard/BoardFilters.d.ts +58 -0
  944. package/dist/ui/dashboard/BoardFilters.d.ts.map +1 -0
  945. package/dist/ui/dashboard/BoardWidth.d.ts +15 -0
  946. package/dist/ui/dashboard/BoardWidth.d.ts.map +1 -0
  947. package/dist/ui/dashboard/ClickSettings.d.ts +30 -0
  948. package/dist/ui/dashboard/ClickSettings.d.ts.map +1 -0
  949. package/dist/ui/dashboard/ContentEditor.d.ts +40 -0
  950. package/dist/ui/dashboard/ContentEditor.d.ts.map +1 -0
  951. package/dist/ui/dashboard/DashboardArrange.d.ts +101 -0
  952. package/dist/ui/dashboard/DashboardArrange.d.ts.map +1 -0
  953. package/dist/ui/dashboard/DashboardGrid.d.ts +96 -0
  954. package/dist/ui/dashboard/DashboardGrid.d.ts.map +1 -0
  955. package/dist/ui/dashboard/DashboardPanel.d.ts +143 -0
  956. package/dist/ui/dashboard/DashboardPanel.d.ts.map +1 -0
  957. package/dist/ui/dashboard/DashboardPanels.d.ts +93 -0
  958. package/dist/ui/dashboard/DashboardPanels.d.ts.map +1 -0
  959. package/dist/ui/dashboard/DashboardTabs.d.ts +43 -0
  960. package/dist/ui/dashboard/DashboardTabs.d.ts.map +1 -0
  961. package/dist/ui/dashboard/EditBar.d.ts +55 -0
  962. package/dist/ui/dashboard/EditBar.d.ts.map +1 -0
  963. package/dist/ui/dashboard/EditableTabs.d.ts +32 -0
  964. package/dist/ui/dashboard/EditableTabs.d.ts.map +1 -0
  965. package/dist/ui/dashboard/FilterBar.d.ts +82 -0
  966. package/dist/ui/dashboard/FilterBar.d.ts.map +1 -0
  967. package/dist/ui/dashboard/FilterOrder.d.ts +40 -0
  968. package/dist/ui/dashboard/FilterOrder.d.ts.map +1 -0
  969. package/dist/ui/dashboard/FilterReadings.d.ts +41 -0
  970. package/dist/ui/dashboard/FilterReadings.d.ts.map +1 -0
  971. package/dist/ui/dashboard/FilterSettings.d.ts +32 -0
  972. package/dist/ui/dashboard/FilterSettings.d.ts.map +1 -0
  973. package/dist/ui/dashboard/FilterSheet.d.ts +24 -0
  974. package/dist/ui/dashboard/FilterSheet.d.ts.map +1 -0
  975. package/dist/ui/dashboard/FilterWiring.d.ts +47 -0
  976. package/dist/ui/dashboard/FilterWiring.d.ts.map +1 -0
  977. package/dist/ui/dashboard/GridBlocksLayer.d.ts +17 -0
  978. package/dist/ui/dashboard/GridBlocksLayer.d.ts.map +1 -0
  979. package/dist/ui/dashboard/GroupingControl.d.ts +10 -0
  980. package/dist/ui/dashboard/GroupingControl.d.ts.map +1 -0
  981. package/dist/ui/dashboard/NewAnalysisDialog.d.ts +41 -0
  982. package/dist/ui/dashboard/NewAnalysisDialog.d.ts.map +1 -0
  983. package/dist/ui/dashboard/PanelBodies.d.ts +101 -0
  984. package/dist/ui/dashboard/PanelBodies.d.ts.map +1 -0
  985. package/dist/ui/dashboard/PanelExport.d.ts +35 -0
  986. package/dist/ui/dashboard/PanelExport.d.ts.map +1 -0
  987. package/dist/ui/dashboard/PanelMarks.d.ts +43 -0
  988. package/dist/ui/dashboard/PanelMarks.d.ts.map +1 -0
  989. package/dist/ui/dashboard/PanelMenu.d.ts +56 -0
  990. package/dist/ui/dashboard/PanelMenu.d.ts.map +1 -0
  991. package/dist/ui/dashboard/PanelUnavailable.d.ts +45 -0
  992. package/dist/ui/dashboard/PanelUnavailable.d.ts.map +1 -0
  993. package/dist/ui/dashboard/PresentationDialog.d.ts +36 -0
  994. package/dist/ui/dashboard/PresentationDialog.d.ts.map +1 -0
  995. package/dist/ui/dashboard/ScrollCue.d.ts +21 -0
  996. package/dist/ui/dashboard/ScrollCue.d.ts.map +1 -0
  997. package/dist/ui/dashboard/ViewPicker.d.ts +59 -0
  998. package/dist/ui/dashboard/ViewPicker.d.ts.map +1 -0
  999. package/dist/ui/dashboard/buildShell.d.ts +44 -0
  1000. package/dist/ui/dashboard/buildShell.d.ts.map +1 -0
  1001. package/dist/ui/dashboard/building.d.ts +44 -0
  1002. package/dist/ui/dashboard/building.d.ts.map +1 -0
  1003. package/dist/ui/dashboard/commands.d.ts +131 -0
  1004. package/dist/ui/dashboard/commands.d.ts.map +1 -0
  1005. package/dist/ui/dashboard/extensions.d.ts +66 -0
  1006. package/dist/ui/dashboard/extensions.d.ts.map +1 -0
  1007. package/dist/ui/dashboard/filterModes.d.ts +60 -0
  1008. package/dist/ui/dashboard/filterModes.d.ts.map +1 -0
  1009. package/dist/ui/dashboard/filterOutcome.d.ts +24 -0
  1010. package/dist/ui/dashboard/filterOutcome.d.ts.map +1 -0
  1011. package/dist/ui/dashboard/findings.d.ts +24 -0
  1012. package/dist/ui/dashboard/findings.d.ts.map +1 -0
  1013. package/dist/ui/dashboard/gridBlocks.d.ts +55 -0
  1014. package/dist/ui/dashboard/gridBlocks.d.ts.map +1 -0
  1015. package/dist/ui/dashboard/gridPlacement.d.ts +38 -0
  1016. package/dist/ui/dashboard/gridPlacement.d.ts.map +1 -0
  1017. package/dist/ui/dashboard/gridWidth.d.ts +33 -0
  1018. package/dist/ui/dashboard/gridWidth.d.ts.map +1 -0
  1019. package/dist/ui/dashboard/history.d.ts +56 -0
  1020. package/dist/ui/dashboard/history.d.ts.map +1 -0
  1021. package/dist/ui/dashboard/landing.d.ts +13 -0
  1022. package/dist/ui/dashboard/landing.d.ts.map +1 -0
  1023. package/dist/ui/dashboard/panelFit.d.ts +43 -0
  1024. package/dist/ui/dashboard/panelFit.d.ts.map +1 -0
  1025. package/dist/ui/dashboard/press.d.ts +50 -0
  1026. package/dist/ui/dashboard/press.d.ts.map +1 -0
  1027. package/dist/ui/dashboard/reveal.d.ts +21 -0
  1028. package/dist/ui/dashboard/reveal.d.ts.map +1 -0
  1029. package/dist/ui/dashboard/scrollMore.d.ts +92 -0
  1030. package/dist/ui/dashboard/scrollMore.d.ts.map +1 -0
  1031. package/dist/ui/dashboard/touchGate.d.ts +30 -0
  1032. package/dist/ui/dashboard/touchGate.d.ts.map +1 -0
  1033. package/dist/ui/embed/EmbedFrame.d.ts +29 -0
  1034. package/dist/ui/embed/EmbedFrame.d.ts.map +1 -0
  1035. package/dist/ui/embed/EmbedHead.d.ts +81 -0
  1036. package/dist/ui/embed/EmbedHead.d.ts.map +1 -0
  1037. package/dist/ui/embed/EmbeddedAnalysis.d.ts +20 -0
  1038. package/dist/ui/embed/EmbeddedAnalysis.d.ts.map +1 -0
  1039. package/dist/ui/embed/EmbeddedRecord.d.ts +33 -0
  1040. package/dist/ui/embed/EmbeddedRecord.d.ts.map +1 -0
  1041. package/dist/ui/embed/options.d.ts +118 -0
  1042. package/dist/ui/embed/options.d.ts.map +1 -0
  1043. package/dist/ui/filter/AddEntry.d.ts +25 -0
  1044. package/dist/ui/filter/AddEntry.d.ts.map +1 -0
  1045. package/dist/ui/filter/AppliedBar.d.ts +39 -0
  1046. package/dist/ui/filter/AppliedBar.d.ts.map +1 -0
  1047. package/dist/ui/filter/ConditionPill.d.ts +38 -0
  1048. package/dist/ui/filter/ConditionPill.d.ts.map +1 -0
  1049. package/dist/ui/filter/FieldChecklist.d.ts +56 -0
  1050. package/dist/ui/filter/FieldChecklist.d.ts.map +1 -0
  1051. package/dist/ui/filter/FilterActions.d.ts +49 -0
  1052. package/dist/ui/filter/FilterActions.d.ts.map +1 -0
  1053. package/dist/ui/filter/FilterModes.d.ts +39 -0
  1054. package/dist/ui/filter/FilterModes.d.ts.map +1 -0
  1055. package/dist/ui/filter/FilterPanel.d.ts +76 -0
  1056. package/dist/ui/filter/FilterPanel.d.ts.map +1 -0
  1057. package/dist/ui/filter/FilterValueEditor.d.ts +103 -0
  1058. package/dist/ui/filter/FilterValueEditor.d.ts.map +1 -0
  1059. package/dist/ui/filter/GroupBlock.d.ts +49 -0
  1060. package/dist/ui/filter/GroupBlock.d.ts.map +1 -0
  1061. package/dist/ui/filter/conditionFocus.d.ts +39 -0
  1062. package/dist/ui/filter/conditionFocus.d.ts.map +1 -0
  1063. package/dist/ui/filter/enter.d.ts +20 -0
  1064. package/dist/ui/filter/enter.d.ts.map +1 -0
  1065. package/dist/ui/filter/groupOperators.d.ts +12 -0
  1066. package/dist/ui/filter/groupOperators.d.ts.map +1 -0
  1067. package/dist/ui/filter/inputs/calendar.d.ts +26 -0
  1068. package/dist/ui/filter/inputs/calendar.d.ts.map +1 -0
  1069. package/dist/ui/filter/inputs/candidates.d.ts +27 -0
  1070. package/dist/ui/filter/inputs/candidates.d.ts.map +1 -0
  1071. package/dist/ui/filter/inputs/chips.d.ts +56 -0
  1072. package/dist/ui/filter/inputs/chips.d.ts.map +1 -0
  1073. package/dist/ui/filter/inputs/date.d.ts +35 -0
  1074. package/dist/ui/filter/inputs/date.d.ts.map +1 -0
  1075. package/dist/ui/filter/inputs/daterange.d.ts +28 -0
  1076. package/dist/ui/filter/inputs/daterange.d.ts.map +1 -0
  1077. package/dist/ui/filter/inputs/duration.d.ts +16 -0
  1078. package/dist/ui/filter/inputs/duration.d.ts.map +1 -0
  1079. package/dist/ui/filter/inputs/number.d.ts +47 -0
  1080. package/dist/ui/filter/inputs/number.d.ts.map +1 -0
  1081. package/dist/ui/filter/inputs/relative.d.ts +23 -0
  1082. package/dist/ui/filter/inputs/relative.d.ts.map +1 -0
  1083. package/dist/ui/filter/inputs/remote.d.ts +20 -0
  1084. package/dist/ui/filter/inputs/remote.d.ts.map +1 -0
  1085. package/dist/ui/filter/inputs/select.d.ts +26 -0
  1086. package/dist/ui/filter/inputs/select.d.ts.map +1 -0
  1087. package/dist/ui/filter/inputs/shared.d.ts +79 -0
  1088. package/dist/ui/filter/inputs/shared.d.ts.map +1 -0
  1089. package/dist/ui/filter/inputs/suggested.d.ts +29 -0
  1090. package/dist/ui/filter/inputs/suggested.d.ts.map +1 -0
  1091. package/dist/ui/filter/inputs/text.d.ts +8 -0
  1092. package/dist/ui/filter/inputs/text.d.ts.map +1 -0
  1093. package/dist/ui/filter/inputs/time.d.ts +29 -0
  1094. package/dist/ui/filter/inputs/time.d.ts.map +1 -0
  1095. package/dist/ui/filter/inputs/timeOfDay.d.ts +38 -0
  1096. package/dist/ui/filter/inputs/timeOfDay.d.ts.map +1 -0
  1097. package/dist/ui/filter/inputs/unsupported.d.ts +33 -0
  1098. package/dist/ui/filter/inputs/unsupported.d.ts.map +1 -0
  1099. package/dist/ui/index.d.ts +123 -0
  1100. package/dist/ui/index.d.ts.map +1 -0
  1101. package/dist/ui/kit/Announcer.d.ts +75 -0
  1102. package/dist/ui/kit/Announcer.d.ts.map +1 -0
  1103. package/dist/ui/kit/CopyButton.d.ts +31 -0
  1104. package/dist/ui/kit/CopyButton.d.ts.map +1 -0
  1105. package/dist/ui/kit/DragHandle.d.ts +84 -0
  1106. package/dist/ui/kit/DragHandle.d.ts.map +1 -0
  1107. package/dist/ui/kit/ExportDialog.d.ts +111 -0
  1108. package/dist/ui/kit/ExportDialog.d.ts.map +1 -0
  1109. package/dist/ui/kit/ExportSteps.d.ts +38 -0
  1110. package/dist/ui/kit/ExportSteps.d.ts.map +1 -0
  1111. package/dist/ui/kit/FieldMenu.d.ts +22 -0
  1112. package/dist/ui/kit/FieldMenu.d.ts.map +1 -0
  1113. package/dist/ui/kit/HandOffMenu.d.ts +29 -0
  1114. package/dist/ui/kit/HandOffMenu.d.ts.map +1 -0
  1115. package/dist/ui/kit/IconButton.d.ts +74 -0
  1116. package/dist/ui/kit/IconButton.d.ts.map +1 -0
  1117. package/dist/ui/kit/MessagesProvider.d.ts +135 -0
  1118. package/dist/ui/kit/MessagesProvider.d.ts.map +1 -0
  1119. package/dist/ui/kit/MixedCheckbox.d.ts +16 -0
  1120. package/dist/ui/kit/MixedCheckbox.d.ts.map +1 -0
  1121. package/dist/ui/kit/OutcomeActions.d.ts +78 -0
  1122. package/dist/ui/kit/OutcomeActions.d.ts.map +1 -0
  1123. package/dist/ui/kit/PendingDot.d.ts +39 -0
  1124. package/dist/ui/kit/PendingDot.d.ts.map +1 -0
  1125. package/dist/ui/kit/RenameInput.d.ts +63 -0
  1126. package/dist/ui/kit/RenameInput.d.ts.map +1 -0
  1127. package/dist/ui/kit/RenderBoundary.d.ts +68 -0
  1128. package/dist/ui/kit/RenderBoundary.d.ts.map +1 -0
  1129. package/dist/ui/kit/RowItem.d.ts +31 -0
  1130. package/dist/ui/kit/RowItem.d.ts.map +1 -0
  1131. package/dist/ui/kit/StatusStrip.d.ts +114 -0
  1132. package/dist/ui/kit/StatusStrip.d.ts.map +1 -0
  1133. package/dist/ui/kit/SystemMark.d.ts +32 -0
  1134. package/dist/ui/kit/SystemMark.d.ts.map +1 -0
  1135. package/dist/ui/kit/Truncated.d.ts +25 -0
  1136. package/dist/ui/kit/Truncated.d.ts.map +1 -0
  1137. package/dist/ui/kit/ViewExpansion.d.ts +89 -0
  1138. package/dist/ui/kit/ViewExpansion.d.ts.map +1 -0
  1139. package/dist/ui/kit/ViewSurface.d.ts +100 -0
  1140. package/dist/ui/kit/ViewSurface.d.ts.map +1 -0
  1141. package/dist/ui/kit/alerts.d.ts +60 -0
  1142. package/dist/ui/kit/alerts.d.ts.map +1 -0
  1143. package/dist/ui/kit/anchor.d.ts +16 -0
  1144. package/dist/ui/kit/anchor.d.ts.map +1 -0
  1145. package/dist/ui/kit/badges.d.ts +34 -0
  1146. package/dist/ui/kit/badges.d.ts.map +1 -0
  1147. package/dist/ui/kit/band.d.ts +49 -0
  1148. package/dist/ui/kit/band.d.ts.map +1 -0
  1149. package/dist/ui/kit/chartFailure.d.ts +19 -0
  1150. package/dist/ui/kit/chartFailure.d.ts.map +1 -0
  1151. package/dist/ui/kit/copyText.d.ts +13 -0
  1152. package/dist/ui/kit/copyText.d.ts.map +1 -0
  1153. package/dist/ui/kit/cspNonce.d.ts +19 -0
  1154. package/dist/ui/kit/cspNonce.d.ts.map +1 -0
  1155. package/dist/ui/kit/currency.d.ts +26 -0
  1156. package/dist/ui/kit/currency.d.ts.map +1 -0
  1157. package/dist/ui/kit/datePart.d.ts +11 -0
  1158. package/dist/ui/kit/datePart.d.ts.map +1 -0
  1159. package/dist/ui/kit/display.d.ts +293 -0
  1160. package/dist/ui/kit/display.d.ts.map +1 -0
  1161. package/dist/ui/kit/download.d.ts +29 -0
  1162. package/dist/ui/kit/download.d.ts.map +1 -0
  1163. package/dist/ui/kit/dragAnnounce.d.ts +51 -0
  1164. package/dist/ui/kit/dragAnnounce.d.ts.map +1 -0
  1165. package/dist/ui/kit/dragDrop.d.ts +36 -0
  1166. package/dist/ui/kit/dragDrop.d.ts.map +1 -0
  1167. package/dist/ui/kit/dragPlugins.d.ts +35 -0
  1168. package/dist/ui/kit/dragPlugins.d.ts.map +1 -0
  1169. package/dist/ui/kit/dragWording.d.ts +15 -0
  1170. package/dist/ui/kit/dragWording.d.ts.map +1 -0
  1171. package/dist/ui/kit/failureSink.d.ts +19 -0
  1172. package/dist/ui/kit/failureSink.d.ts.map +1 -0
  1173. package/dist/ui/kit/features.d.ts +38 -0
  1174. package/dist/ui/kit/features.d.ts.map +1 -0
  1175. package/dist/ui/kit/focus.d.ts +54 -0
  1176. package/dist/ui/kit/focus.d.ts.map +1 -0
  1177. package/dist/ui/kit/kinds.d.ts +54 -0
  1178. package/dist/ui/kit/kinds.d.ts.map +1 -0
  1179. package/dist/ui/kit/layout.d.ts +77 -0
  1180. package/dist/ui/kit/layout.d.ts.map +1 -0
  1181. package/dist/ui/kit/messages.d.ts +56 -0
  1182. package/dist/ui/kit/messages.d.ts.map +1 -0
  1183. package/dist/ui/kit/numbers.d.ts +53 -0
  1184. package/dist/ui/kit/numbers.d.ts.map +1 -0
  1185. package/dist/ui/kit/popups.d.ts +83 -0
  1186. package/dist/ui/kit/popups.d.ts.map +1 -0
  1187. package/dist/ui/kit/presets.d.ts +42 -0
  1188. package/dist/ui/kit/presets.d.ts.map +1 -0
  1189. package/dist/ui/kit/roving.d.ts +32 -0
  1190. package/dist/ui/kit/roving.d.ts.map +1 -0
  1191. package/dist/ui/kit/summary.d.ts +45 -0
  1192. package/dist/ui/kit/summary.d.ts.map +1 -0
  1193. package/dist/ui/kit/toolbar.d.ts +92 -0
  1194. package/dist/ui/kit/toolbar.d.ts.map +1 -0
  1195. package/dist/ui/kit/variants.d.ts +464 -0
  1196. package/dist/ui/kit/variants.d.ts.map +1 -0
  1197. package/dist/ui/lib/utils.d.ts +2 -0
  1198. package/dist/ui/lib/utils.d.ts.map +1 -0
  1199. package/dist/ui/manage/DeleteDialog.d.ts +32 -0
  1200. package/dist/ui/manage/DeleteDialog.d.ts.map +1 -0
  1201. package/dist/ui/manage/ViewManager.d.ts +24 -0
  1202. package/dist/ui/manage/ViewManager.d.ts.map +1 -0
  1203. package/dist/ui/manage/ViewManagerRow.d.ts +96 -0
  1204. package/dist/ui/manage/ViewManagerRow.d.ts.map +1 -0
  1205. package/dist/ui/manage/drag.d.ts +33 -0
  1206. package/dist/ui/manage/drag.d.ts.map +1 -0
  1207. package/dist/ui/messages/actions.d.ts +32 -0
  1208. package/dist/ui/messages/actions.d.ts.map +1 -0
  1209. package/dist/ui/messages/analysis.d.ts +684 -0
  1210. package/dist/ui/messages/analysis.d.ts.map +1 -0
  1211. package/dist/ui/messages/building.d.ts +62 -0
  1212. package/dist/ui/messages/building.d.ts.map +1 -0
  1213. package/dist/ui/messages/bulk.d.ts +27 -0
  1214. package/dist/ui/messages/bulk.d.ts.map +1 -0
  1215. package/dist/ui/messages/capabilities.d.ts +38 -0
  1216. package/dist/ui/messages/capabilities.d.ts.map +1 -0
  1217. package/dist/ui/messages/clicks.d.ts +84 -0
  1218. package/dist/ui/messages/clicks.d.ts.map +1 -0
  1219. package/dist/ui/messages/config.d.ts +12 -0
  1220. package/dist/ui/messages/config.d.ts.map +1 -0
  1221. package/dist/ui/messages/dashboard.d.ts +310 -0
  1222. package/dist/ui/messages/dashboard.d.ts.map +1 -0
  1223. package/dist/ui/messages/definition.d.ts +71 -0
  1224. package/dist/ui/messages/definition.d.ts.map +1 -0
  1225. package/dist/ui/messages/embed.d.ts +11 -0
  1226. package/dist/ui/messages/embed.d.ts.map +1 -0
  1227. package/dist/ui/messages/en.d.ts +2098 -0
  1228. package/dist/ui/messages/en.d.ts.map +1 -0
  1229. package/dist/ui/messages/export.d.ts +50 -0
  1230. package/dist/ui/messages/export.d.ts.map +1 -0
  1231. package/dist/ui/messages/filter.d.ts +263 -0
  1232. package/dist/ui/messages/filter.d.ts.map +1 -0
  1233. package/dist/ui/messages/filters.d.ts +78 -0
  1234. package/dist/ui/messages/filters.d.ts.map +1 -0
  1235. package/dist/ui/messages/header.d.ts +14 -0
  1236. package/dist/ui/messages/header.d.ts.map +1 -0
  1237. package/dist/ui/messages/manage.d.ts +35 -0
  1238. package/dist/ui/messages/manage.d.ts.map +1 -0
  1239. package/dist/ui/messages/record.d.ts +172 -0
  1240. package/dist/ui/messages/record.d.ts.map +1 -0
  1241. package/dist/ui/messages/refresh.d.ts +19 -0
  1242. package/dist/ui/messages/refresh.d.ts.map +1 -0
  1243. package/dist/ui/messages/render.d.ts +11 -0
  1244. package/dist/ui/messages/render.d.ts.map +1 -0
  1245. package/dist/ui/messages/reorder.d.ts +19 -0
  1246. package/dist/ui/messages/reorder.d.ts.map +1 -0
  1247. package/dist/ui/messages/save.d.ts +59 -0
  1248. package/dist/ui/messages/save.d.ts.map +1 -0
  1249. package/dist/ui/messages/scope.d.ts +28 -0
  1250. package/dist/ui/messages/scope.d.ts.map +1 -0
  1251. package/dist/ui/messages/status.d.ts +28 -0
  1252. package/dist/ui/messages/status.d.ts.map +1 -0
  1253. package/dist/ui/messages/view.d.ts +160 -0
  1254. package/dist/ui/messages/view.d.ts.map +1 -0
  1255. package/dist/ui/messages/workbench.d.ts +21 -0
  1256. package/dist/ui/messages/workbench.d.ts.map +1 -0
  1257. package/dist/ui/messages/zh-CN.d.ts +12 -0
  1258. package/dist/ui/messages/zh-CN.d.ts.map +1 -0
  1259. package/dist/ui/record/CardSettings.d.ts +34 -0
  1260. package/dist/ui/record/CardSettings.d.ts.map +1 -0
  1261. package/dist/ui/record/CardSummaries.d.ts +15 -0
  1262. package/dist/ui/record/CardSummaries.d.ts.map +1 -0
  1263. package/dist/ui/record/ColumnResizer.d.ts +67 -0
  1264. package/dist/ui/record/ColumnResizer.d.ts.map +1 -0
  1265. package/dist/ui/record/DetailStructure.d.ts +51 -0
  1266. package/dist/ui/record/DetailStructure.d.ts.map +1 -0
  1267. package/dist/ui/record/EmptyResult.d.ts +41 -0
  1268. package/dist/ui/record/EmptyResult.d.ts.map +1 -0
  1269. package/dist/ui/record/Filler.d.ts +47 -0
  1270. package/dist/ui/record/Filler.d.ts.map +1 -0
  1271. package/dist/ui/record/OffscreenSummary.d.ts +46 -0
  1272. package/dist/ui/record/OffscreenSummary.d.ts.map +1 -0
  1273. package/dist/ui/record/RecordCards.d.ts +53 -0
  1274. package/dist/ui/record/RecordCards.d.ts.map +1 -0
  1275. package/dist/ui/record/RecordDetail.d.ts +45 -0
  1276. package/dist/ui/record/RecordDetail.d.ts.map +1 -0
  1277. package/dist/ui/record/RecordPagination.d.ts +32 -0
  1278. package/dist/ui/record/RecordPagination.d.ts.map +1 -0
  1279. package/dist/ui/record/RecordTable.d.ts +118 -0
  1280. package/dist/ui/record/RecordTable.d.ts.map +1 -0
  1281. package/dist/ui/record/RowActions.d.ts +14 -0
  1282. package/dist/ui/record/RowActions.d.ts.map +1 -0
  1283. package/dist/ui/record/RowCheckbox.d.ts +30 -0
  1284. package/dist/ui/record/RowCheckbox.d.ts.map +1 -0
  1285. package/dist/ui/record/SelectionBar.d.ts +26 -0
  1286. package/dist/ui/record/SelectionBar.d.ts.map +1 -0
  1287. package/dist/ui/record/SkeletonCards.d.ts +11 -0
  1288. package/dist/ui/record/SkeletonCards.d.ts.map +1 -0
  1289. package/dist/ui/record/SkeletonRows.d.ts +33 -0
  1290. package/dist/ui/record/SkeletonRows.d.ts.map +1 -0
  1291. package/dist/ui/record/SortableHeader.d.ts +75 -0
  1292. package/dist/ui/record/SortableHeader.d.ts.map +1 -0
  1293. package/dist/ui/record/SummaryRows.d.ts +43 -0
  1294. package/dist/ui/record/SummaryRows.d.ts.map +1 -0
  1295. package/dist/ui/record/cells.d.ts +41 -0
  1296. package/dist/ui/record/cells.d.ts.map +1 -0
  1297. package/dist/ui/record/columns.d.ts +190 -0
  1298. package/dist/ui/record/columns.d.ts.map +1 -0
  1299. package/dist/ui/record/detailPlacement.d.ts +24 -0
  1300. package/dist/ui/record/detailPlacement.d.ts.map +1 -0
  1301. package/dist/ui/record/emptyWayOut.d.ts +59 -0
  1302. package/dist/ui/record/emptyWayOut.d.ts.map +1 -0
  1303. package/dist/ui/record/exportOffer.d.ts +47 -0
  1304. package/dist/ui/record/exportOffer.d.ts.map +1 -0
  1305. package/dist/ui/record/headerRoving.d.ts +57 -0
  1306. package/dist/ui/record/headerRoving.d.ts.map +1 -0
  1307. package/dist/ui/record/issueNames.d.ts +25 -0
  1308. package/dist/ui/record/issueNames.d.ts.map +1 -0
  1309. package/dist/ui/record/offscreenSummaries.d.ts +81 -0
  1310. package/dist/ui/record/offscreenSummaries.d.ts.map +1 -0
  1311. package/dist/ui/record/openRows.d.ts +43 -0
  1312. package/dist/ui/record/openRows.d.ts.map +1 -0
  1313. package/dist/ui/record/overflow.d.ts +39 -0
  1314. package/dist/ui/record/overflow.d.ts.map +1 -0
  1315. package/dist/ui/record/pinCap.d.ts +68 -0
  1316. package/dist/ui/record/pinCap.d.ts.map +1 -0
  1317. package/dist/ui/record/queryAnnouncement.d.ts +47 -0
  1318. package/dist/ui/record/queryAnnouncement.d.ts.map +1 -0
  1319. package/dist/ui/record/roomBelowRows.d.ts +24 -0
  1320. package/dist/ui/record/roomBelowRows.d.ts.map +1 -0
  1321. package/dist/ui/record/sticky.d.ts +227 -0
  1322. package/dist/ui/record/sticky.d.ts.map +1 -0
  1323. package/dist/ui/record/summaryText.d.ts +10 -0
  1324. package/dist/ui/record/summaryText.d.ts.map +1 -0
  1325. package/dist/ui/record/useOffscreenColumns.d.ts +36 -0
  1326. package/dist/ui/record/useOffscreenColumns.d.ts.map +1 -0
  1327. package/dist/ui/record/useSummaries.d.ts +31 -0
  1328. package/dist/ui/record/useSummaries.d.ts.map +1 -0
  1329. package/dist/ui/sort/SortSettings.d.ts +47 -0
  1330. package/dist/ui/sort/SortSettings.d.ts.map +1 -0
  1331. package/dist/ui/sort/drag.d.ts +53 -0
  1332. package/dist/ui/sort/drag.d.ts.map +1 -0
  1333. package/dist/ui/theme/brandDocs.d.ts +15 -0
  1334. package/dist/ui/theme/brandDocs.d.ts.map +1 -0
  1335. package/dist/ui/theme/densityDocs.d.ts +9 -0
  1336. package/dist/ui/theme/densityDocs.d.ts.map +1 -0
  1337. package/dist/ui/theme/pairs.d.ts +138 -0
  1338. package/dist/ui/theme/pairs.d.ts.map +1 -0
  1339. package/dist/ui/theme/stateDocs.d.ts +149 -0
  1340. package/dist/ui/theme/stateDocs.d.ts.map +1 -0
  1341. package/dist/ui/theme/tokenDocs.d.ts +25 -0
  1342. package/dist/ui/theme/tokenDocs.d.ts.map +1 -0
  1343. package/dist/ui/theme/tokens.d.ts +1526 -0
  1344. package/dist/ui/theme/tokens.d.ts.map +1 -0
  1345. package/dist/ui/viewNavigation.d.ts +39 -0
  1346. package/dist/ui/viewNavigation.d.ts.map +1 -0
  1347. package/dist/ui/workbench/AnalysisParts.d.ts +57 -0
  1348. package/dist/ui/workbench/AnalysisParts.d.ts.map +1 -0
  1349. package/dist/ui/workbench/ConditionBlock.d.ts +20 -0
  1350. package/dist/ui/workbench/ConditionBlock.d.ts.map +1 -0
  1351. package/dist/ui/workbench/ConflictConfirm.d.ts +21 -0
  1352. package/dist/ui/workbench/ConflictConfirm.d.ts.map +1 -0
  1353. package/dist/ui/workbench/EditorBand.d.ts +73 -0
  1354. package/dist/ui/workbench/EditorBand.d.ts.map +1 -0
  1355. package/dist/ui/workbench/LeaveGuard.d.ts +27 -0
  1356. package/dist/ui/workbench/LeaveGuard.d.ts.map +1 -0
  1357. package/dist/ui/workbench/NewView.d.ts +40 -0
  1358. package/dist/ui/workbench/NewView.d.ts.map +1 -0
  1359. package/dist/ui/workbench/NoViews.d.ts +22 -0
  1360. package/dist/ui/workbench/NoViews.d.ts.map +1 -0
  1361. package/dist/ui/workbench/OpeningSkeleton.d.ts +35 -0
  1362. package/dist/ui/workbench/OpeningSkeleton.d.ts.map +1 -0
  1363. package/dist/ui/workbench/OriginBar.d.ts +20 -0
  1364. package/dist/ui/workbench/OriginBar.d.ts.map +1 -0
  1365. package/dist/ui/workbench/RecordParts.d.ts +135 -0
  1366. package/dist/ui/workbench/RecordParts.d.ts.map +1 -0
  1367. package/dist/ui/workbench/RefreshControl.d.ts +70 -0
  1368. package/dist/ui/workbench/RefreshControl.d.ts.map +1 -0
  1369. package/dist/ui/workbench/ResultBlock.d.ts +88 -0
  1370. package/dist/ui/workbench/ResultBlock.d.ts.map +1 -0
  1371. package/dist/ui/workbench/ResultToolbar.d.ts +109 -0
  1372. package/dist/ui/workbench/ResultToolbar.d.ts.map +1 -0
  1373. package/dist/ui/workbench/SaveActions.d.ts +76 -0
  1374. package/dist/ui/workbench/SaveActions.d.ts.map +1 -0
  1375. package/dist/ui/workbench/SaveAsDialog.d.ts +66 -0
  1376. package/dist/ui/workbench/SaveAsDialog.d.ts.map +1 -0
  1377. package/dist/ui/workbench/SearchBox.d.ts +18 -0
  1378. package/dist/ui/workbench/SearchBox.d.ts.map +1 -0
  1379. package/dist/ui/workbench/Sidebar.d.ts +50 -0
  1380. package/dist/ui/workbench/Sidebar.d.ts.map +1 -0
  1381. package/dist/ui/workbench/StatusLine.d.ts +31 -0
  1382. package/dist/ui/workbench/StatusLine.d.ts.map +1 -0
  1383. package/dist/ui/workbench/TitleBar.d.ts +39 -0
  1384. package/dist/ui/workbench/TitleBar.d.ts.map +1 -0
  1385. package/dist/ui/workbench/Unopenable.d.ts +19 -0
  1386. package/dist/ui/workbench/Unopenable.d.ts.map +1 -0
  1387. package/dist/ui/workbench/ViewEngineProvider.d.ts +93 -0
  1388. package/dist/ui/workbench/ViewEngineProvider.d.ts.map +1 -0
  1389. package/dist/ui/workbench/ViewHeader.d.ts +123 -0
  1390. package/dist/ui/workbench/ViewHeader.d.ts.map +1 -0
  1391. package/dist/ui/workbench/ViewList.d.ts +71 -0
  1392. package/dist/ui/workbench/ViewList.d.ts.map +1 -0
  1393. package/dist/ui/workbench/ViewSwitcher.d.ts +49 -0
  1394. package/dist/ui/workbench/ViewSwitcher.d.ts.map +1 -0
  1395. package/dist/ui/workbench/WorkbenchShell.d.ts +291 -0
  1396. package/dist/ui/workbench/WorkbenchShell.d.ts.map +1 -0
  1397. package/dist/ui/workbench/WriteOutcome.d.ts +51 -0
  1398. package/dist/ui/workbench/WriteOutcome.d.ts.map +1 -0
  1399. package/dist/ui/workbench/address.d.ts +84 -0
  1400. package/dist/ui/workbench/address.d.ts.map +1 -0
  1401. package/dist/ui/workbench/bindings.d.ts +45 -0
  1402. package/dist/ui/workbench/bindings.d.ts.map +1 -0
  1403. package/dist/ui/workbench/configRemedy.d.ts +28 -0
  1404. package/dist/ui/workbench/configRemedy.d.ts.map +1 -0
  1405. package/dist/ui/workbench/describeConfig.d.ts +23 -0
  1406. package/dist/ui/workbench/describeConfig.d.ts.map +1 -0
  1407. package/dist/ui/workbench/panelsToFix.d.ts +43 -0
  1408. package/dist/ui/workbench/panelsToFix.d.ts.map +1 -0
  1409. package/dist/ui/workbench/parts.d.ts +33 -0
  1410. package/dist/ui/workbench/parts.d.ts.map +1 -0
  1411. package/dist/ui/workbench/useEditorFold.d.ts +26 -0
  1412. package/dist/ui/workbench/useEditorFold.d.ts.map +1 -0
  1413. package/dist/ui/workbench/useSidebarFold.d.ts +57 -0
  1414. package/dist/ui/workbench/useSidebarFold.d.ts.map +1 -0
  1415. package/dist/ui/workbench/useWorkbenchFolds.d.ts +44 -0
  1416. package/dist/ui/workbench/useWorkbenchFolds.d.ts.map +1 -0
  1417. package/dist/ui.js +43488 -0
  1418. package/dist/ui.js.map +1 -0
  1419. package/dist/viewRuntimeTypes-yK2rlUjK.js +5482 -0
  1420. package/dist/viewRuntimeTypes-yK2rlUjK.js.map +1 -0
  1421. package/package.json +168 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-DzstAsWB.js","names":["AnalysisColumn","AnalysisMetric","derivedRefs","MetricMoveStop","side","at","MetricMove","metrics","to","stop","moveMetric","from","moving","unchanged","others","filter","_metric","reads","type","expression","lowest","after","forEach","metric","includes","alias","highest","length","before","target","Math","min","max","landed","undefined","next","splice","columnsAfterMove","columns","own","find","column","findIndex","rest","place","neighbour","earlier","slice","reverse","map","i","later","index","ALWAYS_VISIBLE","defaultRuntimeEnvironment","RuntimeEnvironment","VisibilitySource","documentVisibility","document","isVisible","visibilityState","subscribe","listener","addEventListener","removeEventListener","browserRuntimeEnvironment","overrides","Partial","visibility","issue","Issue","ViewKind","toIssue","kindMismatch","runtime","kind","drawn","includes","fiveNumberMetrics","ohlcMetrics","DEFAULT_MISSING_KEY","derivedMetric","durationMetric","formulaMetric","freeAlias","isDuration","metricWithCondition","momentMetrics","columnsAfterMove","moveMetric","AnalysisScope","Dropped","MetricMove","isDateCell","isValueMetric","without","AnalysisColumn","AnalysisDateDiffUnit","AnalysisGroup","AnalysisHavingExpression","AnalysisMetric","AnalysisViewConfig","FilterTree","ReshapeProposal","Pick","Partial","dropped","columns","DropCause","kind","name","Reshape","update","current","cause","QuestionEditingInput","reshape","edit","patch","scope","questionEditing","patchGroup","index","group","groups","map","at","metrics","patchMetric","metric","taken","alias","addGroup","updateGroup","removeGroup","filter","_group","renameGroup","label","undefined","setMissingBucket","on","type","missingKey","setDense","dense","addMetric","updateMetric","replaceMetric","renameMetric","setMetricFilter","duplicateMetric","copy","splice","addFiveNumbers","missing","length","addOhlc","from","to","moved","table","removeMetric","_metric","addFormula","dated","field","fields","get","cell","measurable","aggregations","values","entry","functions","first","second","addDuration","unit","durationEnds","groupByDuration","expression","interval","addDerived","moments","Set","readable","has","setHaving","having","QuestionEditing","ReturnType","includes","expressionInput","slice","AnalysisScope","FieldKindRegistry","datePartsOf","isSingleStringField","AnalysisDatePart","AnalysisDateUnit","AnalysisFunction","AnalysisGroupType","FieldDefinition","AnalysisFieldOption","field","label","groups","functions","dateUnits","dateParts","distinctCount","percentile","any","firstLast","missingKey","steps","expressionInput","cell","fieldOptions","scope","kinds","fields","values","map","aggregation","aggregations","get","name","kind","useCallback","useState","analysisScope","momentMetrics","Dropped","withoutDangling","AnalysisMetric","AnalysisViewConfig","ChartSpec","ViewConfig","ViewRuntime","fieldOptions","AnalysisFieldOption","DropCause","ReshapeProposal","DropNotice","cause","naming","fields","metrics","MetricRemoval","ReshapeInput","runtime","draft","config","change","update","current","Partial","fitTo","chart","shape","Pick","useReshape","t0","$","_c","owner","definition","kind","undefined","capability","analysis","drop","setDrop","t1","of","moments","havingMetrics","factsOf","t2","said","proposal","dropped","stepped","columns","listed","proposed","followed","facts","next","length","took","groups","filter","metric","removed","includes","alias","kinds","notice","before","having","aliases","Set","map","_temp","_temp2","sort","entry","has","table","column","after","getSnapshot","reshape","live","t3","t4","t5","before_0","edit","elements","t6","t7","Symbol","for","t8","index","shape_0","_metric","at","t9","t10","undone","undoDrop","dismissDrop","metricRemoval","metric_0","group","_c","_temp","_temp2","dequal","isRootFilterIssue","nodeAt","sameFilterNode","walkFilter","FilterPath","presentationMembers","FilterTree","Issue","ViewConfig","PendingReport","pending","count","conditions","EMPTY_TREE","op","children","filterOverBudget","issues","some","found","code","comparePending","draft","applied","was","Record","now","keys","Set","Object","presentation","kind","key","includes","before","after","nodes","pendingNodes","pendingBesides","state","C","patch","Partial","presentationOnlyEdits","saved","drawn","tree","inForce","visited","node","path","at","indexesOf","add","join","has","filter","step","EMPTY_TREE","useCallback","useEffect","useMemo","useRef","useState","useSyncExternalStore","FilterTree","Issue","ViewEngine","AnyViewRuntime","OpenOptions","ViewEngineOptions","browserRuntimeEnvironment","toIssue","NO_OP","useViewEngine","options","$","_c","t0","environment","engine","t1","t2","dispose","useViewRuntime","runtime","listener","subscribe","getSnapshot","SnapshotOf","R","snapshot","ViewRuntimeStore","S","DashboardOpening","Pick","OpenViewState","loading","error","scopeIssues","retry","retryableOpen","issue","code","OpenedView","instanceId","attempt","NOT_OPENED","NO_ISSUES","Reopen","after","NO_REOPEN","useOpenView","opening","scopeFilter","undefined","opened","setOpened","reopen","setReopen","latestScope","current","latestOpening","t3","t4","t5","t6","cancelled","opensOn","open","then","result","close","runtime_0","t7","t8","setScopeFilter","t9","t10","refusedScope","t11","listener_0","t12","disposed","t13","Symbol","for","_temp","answered","t14","_c","NO_ISSUES","_temp","useCallback","useMemo","approximateMetrics","dateDiffUnitsOf","overlaid","FieldGroupDefinition","FilterTree","AnalysisDateDiffUnit","AnalysisDateUnit","AnalysisElement","AnalysisGroup","AnalysisHavingExpression","AnalysisMetric","AnalysisSort","AnalysisViewConfig","ChartSpec","ChartType","FieldDefinition","Issue","analysisScope","limitBounds","withoutLevelsFrom","elementFilterFields","withLevel","fitChartSlots","switchChartType","havingRows","levelLabel","metricMeasures","momentMetrics","nextLevel","withElements","rangeSpan","recommendDateUnit","resultSpan","AnalysisLimitBounds","AnalysisScope","isFieldlessKind","questionEditing","DropCause","QuestionEditing","fieldOptions","AnalysisFieldOption","useReshape","DropNotice","MetricRemoval","FieldKindRegistry","OptionSource","ViewRuntime","answeringAnew","autoApplyDue","comparePending","pendingBesides","useViewRuntime","AnalysisEditorController","dropped","undoDrop","undone","dismissDrop","metricRemoval","index","elements","expandable","path","label","expansible","unit","elementLabel","elementFields","expand","collapse","setElementFilter","filter","groups","metrics","sort","limit","layout","chart","totals","issues","aliases","moments","ReadonlySet","fields","fieldGroups","countable","stale","havingAllowed","expressionsAllowed","havingMetrics","firstLastOrderBy","dateDiffUnits","metricSortAllowed","denseAllowed","approximate","having","ReturnType","ranHaving","conditionFields","kinds","optionSource","remote","pending","dateUnitFor","field","setSort","sortNow","setLimit","setLayout","setChartType","type","updateChart","patch","Partial","setTotals","submit","focus","blur","EMPTY_CHART","NO_MOMENTS","Set","EMPTY_GROUPS","NO_LIMIT_BOUNDS","max","fallback","useAnalysisEditor","runtime","$","_c","state","draft","config","kind","undefined","owner","definition","capability","analysis","t0","scope","t1","edit","t2","shape","fitTo","t3","t4","update","current","getSnapshot","change","t5","t6","reshape","t7","fields_0","t8","applied","result","dateUnits","timeZone","environment","span","now","data","view","rows","t9","t10","t11","t12","t13","t14","next","cause","current_0","rescope","t15","bb0","t16","Symbol","for","aggregations","values","field_0","get","scalar","name","inMetricFilter","editing","t17","declaredChain","length","t18","recordNoun","t19","index_0","_temp","t20","t21","t22","t23","index_1","t24","t25","index_2","current_1","map","element","at","t26","t27","t28","t29","limits","t30","t31","t32","t33","table","t34","t35","_temp2","t36","_temp3","t37","_temp4","t38","t39","t40","count","t41","t42","t43","expressions","t44","t45","t46","t47","metricSort","t48","dense","t49","t50","t51","t52","t53","t54","bind","t55","t56","t57","t58","sort_0","draft_0","applied_0","others","apply","t59","t60","t61","t62","current_2","t63","t64","current_3","t65","t66","patch_0","current_4","t67","t68","current_5","t69","t70","t71","t72","setEditing","t73","t74","t75","t76","metric","alias","group","found","code","startsWith","field_1","EMPTY_GROUPS","_c","_temp","_temp2","_temp3","_temp4","useEffect","useMemo","drillGroups","fitChartSlots","fitCharts","focusOn","groupFor","groupableFields","measureColumns","momentColumns","asksForWhole","projectAnalysis","shapeChart","splitBy","switchChartType","withStagesFrom","AnalysisColumnView","AnalysisProjection","ChartData","ChartFit","Picked","drillGap","drillRecordConditions","drillSpan","drilledFields","foldsSplit","describeFilter","FilterSummaryItem","AnalysisGroup","AnalysisViewConfig","ChartSpec","ChartType","FilterNode","RecordData","hasAsked","ViewRuntime","AnalysisFieldOption","AnalysisEditorController","WorkbenchController","NO_COLUMNS","SplitOption","field","label","FollowUpAction","kind","subject","run","title","gap","options","filter","FollowUpGroup","conditions","FollowUp","groups","actions","AnalysisResultController","view","ran","question","columns","tableColumns","chart","chartData","fits","Record","picked","choose","next","pickable","followUp","row","through","useAnalysisResult","runtime","analysis","workbench","$","_c","result","state","data","config","undefined","applied","asked","definition","t0","layout","shape","schema","t1","aliases","metrics","shapeKey","drafted","t2","map","_temp","_temp2","shapeAsked","t3","moments","t4","measures","t5","t6","fields","steps","stepsOf","rows","drawable","type","available","timeZone","environment","askedAt","receivedAt","elapsedMs","t7","overall","now","Date","cutShort","truncated","atLimit","splitWhole","approximate","submit","pending","t8","wantsWhole","t9","wantsSplitWhole","t10","t11","t12","repair","setLayout","fitted","updateChart","expanded","elements","length","t13","t14","kinds","t15","context","drilled","canDrill","records","push","_temp3","drill","named","values","heading","entry","op","children","_temp4","drawn","name","title_0","patch","split","follow","title_1","t16","option","metric","alias","group","setChartType","ReadonlySet","ReturnType","find","get","join","declared","Set","has","NO_COLUMNS","_c","_temp","_temp2","_temp3","_temp4","useCallback","useEffect","useMemo","useState","useSyncExternalStore","RefreshConfig","RuntimeLimits","ViewConfig","DashboardRuntime","ViewRuntime","ViewRuntimeState","listenerSet","refreshIntervalOf","useViewRuntime","TICK_MS","NO_INTERVALS","runnable","seconds","limits","undefined","Number","isInteger","minRefreshInterval","maxRefreshInterval","RefreshController","interval","chosen","intervals","unsound","setInterval","now","loading","dueAt","remaining","useAutoRefresh","runtime","$","_c","state","t0","own","readerRefresh","applied","refresh","draft","t1","issues","t2","some","_temp","t3","bb0","t4","t5","offered","refreshIntervals","filter","push","Set","sort","_temp2","next","kind","setRefreshInterval","edit","apply","t6","t7","t8","query","status","t9","nextRefreshAt","t10","due","getSnapshot","left_0","environment","getTime","Math","max","ceil","left","t11","t12","right","found","path","useRefreshCountdown","countdownStore","ticker","set","tick","clearInterval","subscribe","get","initial","listeners","emit","_c","_temp","_temp2","useCallback","useEffect","useRef","useState","RecordKey","ABANDONED","ActionRefusedError","FAILED","TIMED_OUT","UNAVAILABLE","isCalledOff","sourceFailure","SourceFailure","BulkRun","title","values","Readonly","Record","each","key","Promise","operation","timeout","BulkFailure","reason","BulkProgress","total","done","failed","BulkOutcome","succeeded","refused","unknown","skipped","kept","BulkSelection","keys","select","refresh","BulkRunning","progress","stopping","ActionRunner","run","selection","command","stop","running","outcome","dismiss","ActionFailureContext","ActionRunnerOptions","concurrency","onError","error","context","CONCURRENCY","Settled","kind","UNANSWERED","Set","unanswered","failure","unreachable","status","cause","depth","name","has","readSafely","useActionRunner","options","Math","max","floor","current","setRunning","setOutcome","busy","abandon","alive","length","next","given","resolve","report","judge","trim","settle","sent","timer","ReturnType","setTimeout","racers","undefined","Number","isFinite","push","race","clearTimeout","worker","settled","finish","map","filter","left","workers","Array","from","min","all","finally","failureReasons","count","counts","Map","set","get","sort","right","useCallback","useEffect","useMemo","useState","FieldOption","RecordKey","RecordRow","actionState","asksFirst","choiceOf","confirmOf","initialInput","missingInput","nextChange","offeredAt","refusalsByReason","runOne","splitFor","ActionConfirm","ActionInput","ActionPlace","RecordAction","RecordActions","RefusalGroup","useActionRunner","ActionFailureContext","ActionRunner","BulkRun","BulkSelection","RecordActionTable","rows","selection","selectedRows","select","keys","refresh","RecordActionsOptions","actions","table","also","concurrency","onError","error","context","RowActionView","action","available","reason","choices","option","BulkActionView","count","able","PendingAction","place","input","confirm","form","refused","missing","value","RecordActionsController","Pick","now","busy","forRow","row","forSelection","start","id","pending","setInput","name","onlyAble","cancel","runCommand","command","Pressed","NO_ROWS","RECHECK_FLOOR","valueOf","choice","picked","options","find","each","label","String","useRecordActions","t0","$","_c","t1","undefined","t2","t3","t4","runner","setNow","Date","pressed","setPressed","reread","t5","next","t6","t7","timer","setTimeout","Math","min","max","clearTimeout","map","Map","t8","t9","set","key","known","get","rowOf","running","run","t10","title","values","operation","timeout","key_0","execute","place_0","row_0","given","action_0","input_0","target","length","t11","bb0","action_1","place_1","keys_0","input_1","t12","t13","t14","t15","t16","t17","t18","t19","split","t20","t21","t22","row_1","place_2","flatMap","action_2","state","hidden","choice_0","filter","action_3","some","row_2","action_4","split_0","Symbol","for","value_0","last","confirm_0","dismiss","outcome","stop","NO_ROWS","_c","useCallback","ViewRuntime","rootSearch","searchFieldOf","withRootSearch","DataViewConfig","FieldDefinition","useViewRuntime","SearchBoxController","field","value","applied","byWords","set","text","submit","clear","useSearchBox","runtime","$","_c","state","t0","searchInDraft","t1","apply","t2","t3","t4","t5","t6","Symbol","for","bb0","definition","fields","draft","filter","name","t7","narrowing","findings","t8","t9","found","code","params","some","getSnapshot","edit","_c","useCallback","useMemo","Issue","ViewConfig","ViewRuntime","useViewRuntime","UnavailableController","issues","remove","useUnavailable","runtime","$","_c","state","t0","unavailable","t1","removeUnavailable","t2","length","_c","useCallback","useMemo","useState","useSyncExternalStore","DASHBOARD_GRID_COLUMNS","boardWidth","AnalysisDateUnit","DashboardWidth","DashboardField","DashboardFilters","DashboardPanel","DashboardTab","DashboardTimeGrouping","DataViewConfig","FieldDefinition","FieldOption","FilterValue","Issue","PanelClick","PanelLayout","RecordData","filtersOf","tabsOf","FilterReach","CrossFilterOutcome","DashboardEditing","DashboardFilterEditing","DashboardPanelState","DashboardRuntime","DestinationBoard","EditHistoryState","HandOver","OptionSource","PanelGrouping","PressDestination","ValueCandidateSource","ViewRuntime","boardFindings","FieldKindRegistry","useViewRuntime","DashboardPanelView","id","title","panel","layout","runtime","issues","fields","broken","tab","reach","Readonly","Record","grouping","click","DashboardController","panels","columns","width","showTab","tabId","resolving","loading","readAt","dirty","place","panelId","grown","ReadonlyMap","refresh","refreshPanel","building","setBuilding","active","edit","history","filterFields","timeGrouping","filters","filtersRun","setFilterValue","name","value","setGroupingUnit","unit","clearFilters","awaiting","setAwaiting","filterCandidates","filterChoices","filterOptions","remote","kinds","tabs","preload","instanceId","Promise","crossFilter","row","pressed","spanFilters","pressSpan","through","destination","destinationBoard","handOver","EMPTY_PANELS","NO_FILTERS","values","NO_NAMES","NO_ISSUES","NO_FIELDS","NO_HISTORY","undo","redo","useDashboard","$","_c","state","applied","t0","map","_temp","filter","_temp2","children","t1","listener","drop","child_0","child","subscribe","forEach","_temp3","watch","t2","some","_temp4","anyLoading","tabNow","t3","at","panel_0","received","getSnapshot","result","receivedAt","undefined","earliest","filtersNow","setAwaitingNames","t4","Symbol","for","on","names","includes","entry","appliedTabs","t5","toView","t6","t7","t8","t9","t10","t11","t12","t13","t14","t15","t16","t17","t18","t19","t20","panelId_0","t21","t22","t23","t24","t25","t26","t27","t28","t29","t30","t31","name_0","t32","t33","t34","t35","t36","t37","name_1","valueCandidates","t38","t39","name_2","wiredOptions","t40","t41","optionSource","t42","t43","t44","t45","t46","t47","t48","panelId_1","kind","t49","t50","panelId_2","row_0","t51","t52","panelId_3","t53","t54","panelId_4","name_3","row_1","t55","t56","panelId_5","row_2","t57","t58","instanceId_0","t59","t60","panelId_6","t61","t62","child_1","query","status","stop","waiting","found","severity","_c","_temp","_temp2","_temp3","_temp4","AnalysisViewConfig","DashboardFilters","FilterNode","FilterTree","RecordViewConfig","ViewConfig","ViewDefinition","dequal","drillFilter","isSimpleTree","searchFieldOf","withRootSearch","GroupNaming","subject","conditions","BoardOrigin","title","back","DashboardTarget","HandOver","scopeFilter","filter","from","SavedViewTarget","kind","definitionId","instanceId","UnsavedViewTarget","config","named","filters","tab","ViewNavigation","url","ViewHandOver","handedConditions","tree","children","withHandedFilter","C","length","withFilterMode","filterMode","untouchedSince","draft","landed","lookedOnly","view","saved","definition","search","fields","name","asked","Record","rest","sort","pageSize","useEffect","useMemo","useRef","AnalysisViewConfig","DataViewConfig","FilterNode","RecordViewConfig","ViewConfig","drillFilter","defaultRecordConfig","BoardOrigin","GroupNaming","HandOver","ViewNavigation","ViewRuntime","handedConditions","withFilterMode","withHandedFilter","useViewRuntime","WorkbenchController","FollowUpHost","Pick","NOTHING_HANDED","scopeFilter","filter","usePanelFollowUps","runtime","navigate","handOver","$","_c","state","latest","t0","t1","current","definition","canDrill","undefined","kind","record","t2","Symbol","for","handed","t3","drill","conditions","title","subject","away","config","limits","applied","definitionId","id","naming","origin","from","follow","config_0","title_0","conditions_0","subject_0","unsaved","ownedNavigation","getSnapshot","named","_c","useCallback","useMemo","FieldDefinition","FieldGroupDefinition","FilterGroupOperator","FilterLeaf","FilterMode","FilterNode","FilterOperatorName","FilterTree","Issue","ViewConfig","clearFilter","conditions","countLeaves","describeFilter","impliedDeletion","insertAt","filterIndexes","isRootFilterIssue","isSimpleTree","negateAt","nodeAt","operatorsOf","removeConditionAt","sameFilterNode","unmarkedErrors","updateAt","EditorDescriptor","FieldKindRegistry","FilterPath","FilterSummaryItem","isFilterGroup","holdsTime","isDurationOperator","hasAsked","OptionSource","ValueCandidateSource","ViewRuntime","ViewRuntimeState","comparePending","filterOverBudget","PendingReport","VALUE_CANDIDATE_OPERATORS","useViewRuntime","FilterEditorController","FilterTreeController","mode","applied","scoped","fixed","implied","count","simple","pending","pendingCount","conditionsPending","isPending","path","blocked","unmarked","setMode","clear","submit","discard","focus","blur","isRejection","found","code","startsWith","rejectedCondition","error","tree","name","params","node","field","ROOT","EMPTY_GROUPS","EMPTY_FIELDS","EMPTY_TREE","op","children","EMPTY_ISSUES","NOTHING_PENDING","askedFilter","state","kind","undefined","result","ownFilter","own","filter","config","fixedScope","runtime","useFilterEditor","fields","kinds","owner","draft","overBudget","issues","change","update","current","getSnapshot","edit","entry","rejected","query","fieldGroups","definition","base","treeController","onChange","next","optionSource","remote","valueCandidates","inForce","filterMode","ran","scope","scopeFilter","severity","length","apply","setEditing","reseedValue","previous","patch","Partial","byName","ReadonlyMap","operator","get","admitted","validate","value","some","emptyValue","addLeaf","parent","fieldsFor","clearValue","updateLeaf","addGroup","updateGroup","negate","remove","operatorsFor","editorFor","TreeControllerInput","durations","blankAt","blankLeaf","leaf","blankNode","map","addableFields","used","Set","condition","has","candidatesAt","sourceOf","includes","editor","input","Map","allowed","defaultOperator","RecordKey","RecordPaging","RecordRow","RecordViewRuntime","RowsMark","question","page","SelectionAnchor","key","rows","RecordSnapshot","ReturnType","rowsOnScreen","snapshot","mark","result","data","kind","view","own","pageOf","paging","mode","index","nextCursor","standingAnchor","anchor","some","row","toggledSelection","selection","selecting","includes","from","findIndex","to","range","slice","Math","min","max","map","leaving","Set","filter","entry","has","held","useCallback","useEffect","useState","Issue","RecordData","RecordKey","detailSections","DetailSection","RecordRow","RecordViewRuntime","recordReadIssue","rowsOnScreen","useViewRuntime","RecordDetailControl","open","onOpenChange","key","RecordDetailController","record","complete","loading","error","missing","sections","row","close","reload","Read","whole","answered","landed","attempt","Seed","useRecordDetail","runtime","t0","$","_c","t1","undefined","control","state","held","controlled","own","setOwn","seed","setSeed","read","setRead","setAttempt","result","receivedAt","t2","t3","controller","AbortController","fetchRecord","signal","then","aborted","failure","was","abort","t4","data","t5","t6","Symbol","for","_temp","current","t7","rows","find","row_0","onPage","shown","t8","t9","t10","t11","t12","definition","t13","n","_c","_temp","useCallback","useEffect","useRef","useState","Issue","RecordData","isExportCancelledError","RecordViewRuntime","sourceIssue","reportViewFailure","toIssue","RecordTableController","RecordExportScope","RecordExportScopes","selected","all","RecordExportProgress","scope","fetched","total","RecordExportOutcome","rows","capped","RecordExportController","scopes","running","progress","outcome","error","run","fileName","cancel","reset","RecordExportOptions","deliver","Promise","ExportState","IDLE","useRecordExport","runtime","table","options","state","setState","busy","live","AbortController","alive","delivery","current","abort","paging","selection","length","mode","settle","next","hand","caught","fetchAll","controller","result","exportRows","signal","onProgress","reported","undefined","picked","selectedRows","map","row","data","IDLE","RecordColumn","recordColumn","field","members","width","pinned","hidden","const","repinned","column","resized","shown","visible","withColumnsShown","columns","fields","offered","ReadonlySet","Set","kept","placed","flatMap","has","add","reordered","byField","Map","map","named","ordered","get","filter","columnHidden","columnPinned","SUMMARY_FUNCTIONS","RecordColumn","RecordSort","RecordSummary","SortDirection","SummaryFunction","isPlainObject","recordColumn","entries","value","Record","Array","isArray","filter","entry","field","sortDirection","recordSort","map","direction","recordSummaries","flatMap","includes","fn","wasSound","raw","read","length","recordColumns","width","pinned","hidden","nearestPageSize","RecordSort","RecordSummary","RecordViewConfig","SortDirection","ViewInstance","ViewRuntimeState","recordColumns","recordSort","recordSummaries","wasSound","cycledSort","current","field","exclusive","at","findIndex","entry","turned","direction","filter","_entry","index","map","offeredPageSizes","ladder","max","offered","size","undefined","Set","sort","left","right","admittedPageSize","Number","isInteger","admitted","rung","length","isFinite","summariesOf","next","saved","config","kind","summaries","repairing","patch","Partial","state","draft","repairs","columns","table","useCallback","useMemo","useRef","FieldGroupDefinition","Issue","RecordCardSpec","RecordColumn","RecordKey","RecordLayout","RecordSort","RecordSummary","SortDirection","SummaryFunction","RuntimeLimits","columnHidden","columnPinned","isFieldlessKind","nearestPageSize","recordColumns","recordSort","recordSummaries","reordered","repinned","resized","withColumnsShown","cycledSort","offeredPageSizes","repairing","summariesOf","admittedPageSize","clampPage","maxSortFields","RecordCardView","RecordColumnView","RecordPaging","RecordRow","SummaryRow","hasResult","QueryStatus","RecordViewRuntime","pendingBesides","RecordViewConfig","useViewRuntime","rowsOnScreen","standingAnchor","toggledSelection","SelectionAnchor","ToggleSelectionOptions","range","ToggleSortOptions","exclusive","RecordTableController","columns","card","rowKey","fieldGroups","cardSpec","setCard","patch","Partial","rows","paging","summaries","status","error","loading","conditionsChanged","filterRequired","sort","ranSort","sortOf","field","toggleSort","options","setSort","layout","layouts","setLayout","columnFields","hiddenOf","setColumns","fields","setColumnOrder","pinnedOf","setPinned","pinned","setColumnWidth","width","summaryOf","summaryFields","setSummary","fn","pageSize","pageSizes","setPageSize","size","pageSizeFix","selection","selectedRows","isSelected","key","toggle","toggleAll","clearSelection","select","keys","goTo","index","hasNext","next","previous","refresh","NO_SORT","NO_COLUMNS","NO_SUMMARIES","NO_SELECTION","NO_ROWS","NO_LAYOUTS","NO_CARD","title","NO_GROUPS","NO_CARD_SPEC","useRecordTable","runtime","$","_c","state","data","result","view","kind","t0","t1","Set","selected","t2","length","filter","row","has","draft","t3","ran","own","t4","t5","table","tableColumns","t6","t7","snapshot","getSnapshot","repaired","others","edit","apply","editAndApply","t8","sort_0","sortNow","t9","anchor","t10","options_0","snapshot_0","onScreen","from","current","mark","t11","all","map","_temp","definition","undefined","t12","t13","t14","record","t15","t16","t17","patch_0","t18","t19","t20","query","t21","t22","t23","t24","t25","issues","t26","some","_temp2","t27","field_0","find","entry","direction","t28","t29","t30","t31","t32","ladderOf","limits","rung","maxPageSize","state_0","t33","t34","_temp3","t35","t36","field_1","column_0","column","hidden","t37","t38","state_1","visible","offered","_temp4","_temp5","summary","saved","t39","t40","fields_0","t41","t42","field_4","column_1","t43","t44","field_5","column_2","t45","t46","field_6","column_3","t47","t48","field_7","entry_0","t49","t50","_temp6","t51","t52","t53","field_8","state_2","rest","entry_2","t54","t55","t56","t57","pageSize_0","t58","t59","t60","t61","key_0","t62","t63","t64","t65","keys_0","t66","t67","mode","page","t68","t69","cursor","nextCursor","t70","t71","t72","t73","t74","t75","entry_1","field_3","name","field_2","found","code","row_0","cardPageSizes","_c","_temp","_temp2","_temp3","TagEquality","one","Tag","other","CommandQueue","backs","tag","chain","Promise","sameTag","createCommandQueue","Object","is","enqueue","queue","task","T","at","findIndex","entry","landed","then","queued","push","release","mine","indexOf","splice","Issue","ViewInstance","ViewPreferences","isViewWriteError","WriteAction","WriteHandle","WritePayload","WriteState","toIssue","UNSENT","SettledWrite","state","handle","refused","payload","issue","requestId","kind","settle","caught","code","intent","RecoveredWrite","landed","written","instance","UNRECOVERED","recovered","result","savesView","action","unsettled","blocksNewIntent","holdsHandle","outcome","strandedHandle","mayRefuse","existing","mayReplace","incoming","useCallback","useRef","useState","audienceOf","Issue","ViewAudience","ViewInstance","ViewScope","ConflictChoice","ViewEngine","ViewRuntime","WriteState","stopsSave","instanceAbilities","mayCreate","useViewRuntime","toIssue","createCommandQueue","enqueue","CommandQueue","blocksNewIntent","recovered","savesView","UNRECOVERED","RecoveredWrite","SaveTargetInput","title","scope","SaveAbilities","save","saveAs","rename","delete","revert","createPersonal","createShared","createSystem","SaveCommandState","pending","error","write","dirty","blocked","hasErrors","audience","isNew","lastSavedAt","SaveCommands","Promise","input","retry","abandon","resolveConflict","choice","can","state","CommandProgress","runtime","savedAt","IDLE","useSaveCommands","engine","progress","setProgress","queue","run","code","command","T","fallback","landed","outcome","recovery","commands","current","guarded","at","environment","now","getTime","caught","failure","own","instanceId","saved","id","permissions","definition","instance","creating","landedSave","resolve","remove","then","action","getSnapshot","payload","retryWrite","it","wroteStore","abandonWrite","requestId","kind","issues","disposed","written","useCallback","useEffect","useState","ValueCandidate","ValueCandidateSource","sourceReason","VALUE_CANDIDATE_DEBOUNCE_MS","ValueCandidatesController","status","query","values","complete","reason","retry","Answered","source","NONE","useValueCandidates","active","$","_c","t0","blank","answered","setAnswered","attempt","setAttempt","t1","current","t2","trim","text","t3","controller","AbortController","settle","patch","signal","aborted","last","timer","setTimeout","search","then","answer","error","clearTimeout","abort","t4","t5","Symbol","for","_temp","t6","count","_c","_temp","useCallback","useEffect","useMemo","useState","Issue","ViewInstanceSummary","ViewKind","ViewPreferences","ViewEngine","orderSummaries","ViewPermissions","toIssue","ViewListOptions","kinds","ViewListReloadOptions","without","ViewListState","items","all","preferences","permissions","defaultInstanceId","loading","error","preferencesError","preferencesSettled","reload","options","Loaded","key","definitionId","value","T","NOTHING_LOADED","ReloadRequest","token","FIRST_LOAD","useViewList","engine","t0","$","_c","t1","undefined","t2","join","kindsKey","t3","Set","split","request","setRequest","list","setList","setPreferences","t4","t5","cancelled","then","listing","current","failed","current_0","error_0","t6","t7","Symbol","for","options_0","current_1","t8","t9","subscribe","change","kind","id","current_2","settled","retainedPreferences","t10","bb0","value_0","t11","t12","currentPreferences","listed","filter","item","kept","t13","t14","summary","has","t15","resolveDefault","t16","t17","_c","isSystemScope","ViewInstanceSummary","ViewPermissions","instanceAbilities","mayCreate","ManagedInstanceAbilities","rename","delete","changeAudience","publish","ViewManagerAbilities","reorder","setDefault","publishSystem","instance","id","anything","abilitiesOf","items","permissions","row","find","item","granted","undefined","scope","some","SYSTEM_INSTANCE_ID_PREFIX","SYSTEM_INSTANCE_ID_SEPARATOR","WriteState","holdsHandle","SettledWrite","PREFERENCES_KEY","const","Outcome","again","Promise","NO_OUTCOMES","ReadonlyMap","Map","kept","outcome","undefined","state","kind","withOutcome","outcomes","key","has","next","set","delete","projectStates","projected","ViewAudience","OptimisticOrder","base","order","visible","MovedOrder","sameOrder","one","other","length","every","id","at","placesOf","audiences","ReadonlyMap","audience","places","get","push","groupIndexOf","undefined","indexOf","planMoveTo","full","index","group","map","place","from","to","Math","min","max","moved","splice","held","member","includes","sort","forEach","shown","useCallback","useRef","useState","ViewEngine","WritePayload","ViewListState","holdsHandle","mayReplace","settle","strandedHandle","NO_OUTCOMES","withOutcome","Outcome","createCommandQueue","enqueue","CommandQueue","ManagerTag","engine","definitionId","sameTag","one","other","RunnerState","outcomes","ReadonlyMap","pending","NOTHING_RUN","RunOptions","again","Promise","recovery","guard","CommandRunner","run","key","intent","code","command","options","held","record","outcome","owns","tagged","useCommandRunner","reload","state","setState","live","queue","own","commit","next","current","get","execute","stranded","abandonWrite","action","caught","settled","blocked","resolve","start","undefined","commands","useCallback","useMemo","useRef","audienceOf","ViewAudience","ViewConfig","ViewPreferences","ConflictChoice","ViewEngine","WritePayload","WriteState","abilitiesOf","ViewManagerAbilities","kept","PREFERENCES_KEY","projectStates","UNSENT","groupIndexOf","planMoveTo","sameOrder","OptimisticOrder","useCommandRunner","ManagerTag","ViewListState","ManagedInstanceAbilities","ViewManagerController","rename","id","title","Promise","changeAudience","audience","delete","publishAsSystem","setDefault","moveTo","index","placeOf","outcomes","ReadonlyMap","retry","key","abandon","resolveConflict","choice","resubmit","canResubmit","pending","can","PendingOrder","useViewManager","engine","definitionId","list","$","_c","all","items","permissions","preferences","reload","run","held","record","owns","optimistic","t0","map","_temp","rendered","t1","_temp2","full","t2","Map","_temp3","audiences","t3","defaultInstanceId","order","revision","change","action","next","preferencesIntent","t4","t5","id_0","t6","id_1","remove","t7","id_2","row","find","item_2","item","input","scope","config","kind","intent","t8","id_3","put","again","t9","ahead","current","carried","base","visible","t10","id_4","t11","id_5","from","planned","resolve","submitted","put_0","reorder","landed","then","ok","t12","outcome","get","handle","state","payload","retryWrite","recovery","guard","t13","key_0","outcome_0","abandonWrite","t14","key_1","outcome_1","handle_0","state_0","landed_0","t15","key_2","outcome_2","state_1","t16","key_3","t17","t18","states","t19","item_1","item_0","_c","_temp","_temp2","useEffect","useRef","ViewHandOver","InstanceSyncOptions","instanceId","chosen","choose","id","asking","onInstanceChange","handOver","useInstanceSync","t0","$","_c","t1","undefined","seen","held","handed","t2","t3","previous","current","handedBefore","host","opening","kind","_c","useCallback","useEffect","useState","WriteState","blocksNewIntent","LeaveGuardState","dirty","write","LeaveGuard","asking","request","next","confirm","cancel","LeaveGuardOptions","onLeave","guardUnload","costly","state","useUnloadGuard","blocking","$","_c","t0","t1","window","ask","_temp","addEventListener","removeEventListener","event","preventDefault","returnValue","useLeaveGuard","undefined","t2","held","setHeld","t3","t4","t5","t6","_c","_temp","defaultAnalysisConfig","emptyDashboardConfig","RuntimeLimits","ViewAudience","ViewConfig","ViewDefinition","ViewKind","defaultRecordConfig","ViewPermissions","NewViewOptions","title","templates","Partial","Record","Blank","scope","config","offers","definition","kind","record","undefined","analysis","blankConfig","limits","newViewScope","permissions","createPersonal","createShared","blankView","newView","useEffect","useRef","OpenViewState","useReleaseDeleted","openId","chosen","opened","setChosen","$","_c","wasOpen","runtime","failed","error","code","t0","t1","current","t2","t3","_c","useEffect","useMemo","useRef","useState","useSyncExternalStore","AnalysisViewConfig","FilterNode","FilterTree","RecordViewConfig","ViewConfig","ViewKind","isSimpleTree","nodeAt","FilterPath","removeAt","sameFilterTree","AnyViewRuntime","ViewRuntime","SavedViewTarget","ViewEngine","ViewHandOver","handedConditions","withHandedFilter","listenerSet","FilterEditorController","HeldView","useHandOver","handOver","context","$","_c","engine","definitionId","kinds","request","hold","open","seen","t0","t1","Symbol","for","current","t2","t3","kind","includes","config","made","create","title","scope","scopeFilter","runtime","draft","getSnapshot","origin","from","handed","named","board","useHandedConditions","landing","landingStore","landed","subscribe","get","last","target","snapshot","own","saved","filter","merged","data","edit","filterMode","apply","set","Landed","listeners","next","emit","useHandedRemoval","bb0","conditions","length","clearValue","path","node","some","condition","heldBy","rest","backToSaved","children","child","only","op","undefined","_c","useCallback","useEffect","useMemo","useRef","useState","parseSystemInstanceId","sameJson","FilterNode","FilterTree","Issue","RecordViewConfig","ViewConfig","ViewInstance","ViewKind","drillFilter","narrowsTo","defaultRecordConfig","AnyViewRuntime","BoardOrigin","GroupNaming","SavedViewTarget","ViewEngine","ViewHandOver","ViewNavigation","ViewRuntimeState","WriteAction","lookedOnly","untouchedSince","withFilterMode","kindMismatch","useAutoRefresh","RefreshController","useFilterEditor","FilterEditorController","useSaveCommands","SaveCommands","useOpenView","useViewRuntime","DashboardOpening","OpenViewState","useViewList","ViewListState","useViewManager","ViewManagerController","useInstanceSync","useLeaveGuard","LeaveGuard","blankView","NewViewOptions","useReleaseDeleted","useHandedConditions","useHandedRemoval","useHandOver","WorkbenchOptions","kinds","instanceId","onInstanceChange","id","guardUnload","newView","onDrilldown","target","DrillTarget","opening","handOver","onNavigate","to","ViewOrigin","runtime","title","conditions","definitionId","origin","config","scopeFilter","HeldView","draft","named","from","handed","board","WorkbenchController","autoRun","setAutoRun","on","Promise","list","manager","openId","choose","creatable","create","kind","held","canDrill","drill","subject","follow","back","toBoard","handedOver","opened","state","unopenable","definitionIssues","declaredAt","commands","refresh","filter","leave","onSaved","instance","onRenamed","onDeleted","onRecovered","action","useWorkbench","engine","options","$","_c","t0","join","kindsKey","t1","split","t2","chosen","setChosen","defaultInstanceId","setHeld","heldRef","t3","next","previous","current","close","hold","t4","t5","view","setHanded","handedHere","t6","opensHere","byId","t7","loading","error","scopeIssues","retry","t8","wrongKind","handedDraft","t9","namedState","preferences","preferencesSettled","t10","t11","setAutoApply","t12","definition","dirty","can","save","write","t13","abandon","t14","onLeave","request","t15","id_0","t16","openHanded","t17","open","t18","asking","blanks","t19","definitions","get","permissions","map","limits","const","_temp","_temp2","t20","kind_1","blank_0","find","t21","made","blank","undefined","made_0","scope","getSnapshot","viewTitle","made_1","holdFrom","t22","includes","record","t23","conditions_0","viewTitle_0","subject_0","applied","config_0","t24","current_0","t25","reload","t26","t27","t28","t29","t30","t31","t32","saved","t33","t34","Symbol","for","t35","t36","t37","kind_0","views","declared","at","findIndex","viewId","_c","sameFilterNode","isDurationOperator","narrowsTo","momentMetrics","overlaid","audienceOf","shapeChart","columnPinned","isViewWriteError","foldsSplit","boardWidth","drillRecordConditions","limitBounds","filtersOf","conditions","defaultAnalysisConfig","focusOn","drillSpan","countLeaves","fitChartSlots","without","isSystemScope","switchChartType","DEFAULT_MISSING_KEY","clearFilter","removeConditionAt","holdsTime","drillFilter","SUMMARY_FUNCTIONS","metricMeasures","stopsSave","fiveNumberMetrics","freeAlias","columnHidden","isFilterGroup","drillGap","insertAt","groupableFields","drillGroups","metricWithCondition","reportViewFailure","nodeAt","splitBy","negateAt","groupFor","removeAt","splitFor","UNAVAILABLE","tabsOf","isPlainObject","asksFirst","momentColumns","issue","isFieldlessKind","initialInput","sameFilterTree","sourceFailure","missingInput","runOne","durationMetric","approximateMetrics","refusalsByReason","TIMED_OUT","datePartsOf","sameJson","asksForWhole","boardFindings","ohlcMetrics","choiceOf","projectAnalysis","operatorsOf","isSingleStringField","offeredAt","derivedMetric","SYSTEM_INSTANCE_ID_PREFIX","ActionRefusedError","elementFilterFields","walkFilter","actionState","describeFilter","isDateCell","nextChange","maxSortFields","isCalledOff","isSimpleTree","impliedDeletion","drilledFields","FAILED","dateDiffUnitsOf","fitCharts","isValueMetric","measureColumns","ABANDONED","analysisScope","updateAt","sourceReason","confirmOf","formulaMetric","nearestPageSize","clampPage","withStagesFrom","isDuration","parseSystemInstanceId","VALUE_CANDIDATE_OPERATORS","rootSearch","nextLevel","derivedRefs","withoutLevelsFrom","isRootFilterIssue","withRootSearch","presentationMembers","detailSections","withoutDangling","defaultRecordConfig","withLevel","unmarkedErrors","searchFieldOf","filterIndexes","refreshIntervalOf","ALWAYS_VISIBLE","resultSpan","recordReadIssue","orderSummaries","instanceAbilities","havingRows","autoApplyDue","sourceIssue","answeringAnew","emptyDashboardConfig","hasResult","mayCreate","ViewEngine","isExportCancelledError","hasAsked","toIssue","listenerSet","rangeSpan","withElements","defaultRuntimeEnvironment","levelLabel","recommendDateUnit","moveMetric","moving","metrics","from","unchanged","to","others","at","reads","lowest","after","metric","highest","before","target","landed","stop","next","columnsAfterMove","own","columns","column","alias","rest","place","neighbour","earlier","i","later","index","documentVisibility","listener","browserRuntimeEnvironment","overrides","kindMismatch","runtime","drawn","questionEditing","patchGroup","reshape","current","update","group","patchMetric","taken","patch","label","on","filter","copy","missing","moved","dated","field","scope","name","first","second","entry","durationEnds","unit","moments","edit","having","fieldOptions","aggregation","kinds","useReshape","$","c","t0","owner","definition","capability","drop","setDrop","useState","t1","of","factsOf","t2","change","fitTo","said","proposal","stepped","listed","proposed","shape","followed","took","naming","cause","aliases","_temp$11","_temp2$7","notice","live","draft","t3","t4","t5","before_0","t6","t7","t8","config","shape_0","t9","t10","metric_0","EMPTY_TREE$1","filterOverBudget","issues","found","comparePending","count","was","applied","now","keys","presentation","key","nodes","pendingNodes","dequal","pendingBesides","state","presentationOnlyEdits","saved","visited","tree","indexesOf","path","node","inForce","step","NO_OP","useViewEngine","options","engine","useEffect","useViewRuntime","subscribe","snapshot","useSyncExternalStore","retryableOpen","NOT_OPENED","NO_ISSUES$1","NO_REOPEN","useOpenView","scopeFilter","opened","setOpened","reopen","setReopen","latestScope","useRef","latestOpening","opening","instanceId","cancelled","opensOn","result","error","runtime_0","scopeIssues","t11","listener_0","t12","disposed","t13","_temp$10","retry","answered","t14","EMPTY_CHART","NO_MOMENTS","EMPTY_GROUPS$1","NO_LIMIT_BOUNDS","useAnalysisEditor","chart","fields","fields_0","span","timeZone","dateUnitFor","groups","elements","elementLabel","expandable","current_0","rescope","t15","t16","kind","field_0","conditionFields","editing","t17","t18","t19","index_0","_temp$9","t20","t21","t22","t23","index_1","t24","t25","current_1","index_2","element","t26","t27","t28","t29","t30","t31","t32","t33","t34","t35","_temp2$6","t36","_temp3$4","t37","_temp4$3","t38","t39","t40","t41","t42","t43","t44","t45","t46","t47","t48","t49","t50","t51","t52","t53","t54","t55","t56","t57","t58","draft_0","applied_0","sort_0","t59","t60","t61","t62","layout","current_2","t63","t64","current_3","type","t65","t66","current_4","patch_0","t67","t68","current_5","t69","t70","t71","t72","t73","t74","t75","t76","dismissDrop","dropped","metricRemoval","undoDrop","undone","field_1","NO_COLUMNS$1","useAnalysisResult","workbench","data","view","ran","asked","question","tableColumns","analysis","shapeKey","drafted","_temp$8","_temp2$5","shapeAsked","measures","stepsOf","fits","drawable","askedAt","chartData","picked","wantsWhole","wantsSplitWhole","pending","submit","fitted","choose","expanded","gap","pickable","context","drilled","through","row","actions","records","_temp3$3","title","named","heading","_temp4$2","subject","split","title_0","title_1","followUp","option","repair","declared","TICK_MS","NO_INTERVALS","runnable","seconds","limits","useAutoRefresh","chosen","readerRefresh","_temp$7","offered","_temp2$4","due","left_0","left","right","useRefreshCountdown","refresh","dueAt","remaining","countdownStore","ticker","tick","initial","listeners","CONCURRENCY","UNANSWERED","unanswered","failure","depth","readSafely","useActionRunner","concurrency","onError","running","setRunning","outcome","setOutcome","busy","stopping","abandon","alive","useCallback","selection","succeeded","failed","refused","unknown","operation","command","timeout","given","resolve","report","judge","settle","sent","key_0","error_0","timer","racers","resolve_0","worker","key_1","settled","finish","settled_0","each","skipped","key_2","each_0","kept","key_3","workers","failureReasons","counts","reason","NO_ROWS$1","RECHECK_FLOOR","valueOf","choice","action","input","useRecordActions","also","runner","setNow","pressed","setPressed","reread","table","rows","map","known","rowOf","run","select","confirm","value","execute","selectedRows","action_0","id","place_0","row_0","input_0","start","action_1","place_1","keys_0","input_1","place_2","action_2","row_1","choice_0","forRow","action_3","row_2","split_0","action_4","forSelection","last","value_0","setInput","able","onlyAble","confirm_0","cancel","useSearchBox","searchInDraft","text","set","clear","useUnavailable","remove","EMPTY_PANELS","NO_FILTERS","NO_NAMES","NO_ISSUES","NO_FIELDS","NO_HISTORY","useDashboard","panels","_temp$6","_temp2$3","children","child_0","_temp3$2","watch","_temp4$1","anyLoading","loading","tabNow","panel_0","received","earliest","readAt","filtersNow","awaiting","setAwaitingNames","names","setAwaiting","appliedTabs","toView","tabId","panelId","grown","panelId_0","active","name_0","name_1","name_2","remote","panelId_1","panelId_2","panelId_3","panelId_4","name_3","panelId_5","instanceId_0","panelId_6","child_1","child","panel","handedConditions","withHandedFilter","withFilterMode","untouchedSince","lookedOnly","search","NOTHING_HANDED","usePanelFollowUps","latest","handOver","canDrill","navigate","handed","away","origin","config_0","unsaved","subject_0","conditions_0","ownedNavigation","isRejection","rejectedCondition","ROOT","EMPTY_GROUPS","EMPTY_FIELDS","EMPTY_TREE","EMPTY_ISSUES","NOTHING_PENDING","askedFilter","ownFilter","fixedScope","fixed","useFilterEditor","useMemo","overBudget","rejected","fieldGroups","base","treeController","isPending","mode","reseedValue","previous","byName","blankAt","blankLeaf","leaf","blankNode","addableFields","used","parent","condition","candidatesAt","sourceOf","onChange","allowed","operator","op","durations","rowsOnScreen","pageOf","paging","standingAnchor","anchor","mark","toggledSelection","selecting","range","leaving","held","useRecordDetail","control","controlled","setOwn","seed","setSeed","read","setRead","attempt","setAttempt","controller","whole","onOpenChange","open","close","_temp$5","reload","onPage","shown","n","IDLE$1","useRecordExport","setState","deliver","delivery","scopes","hand","fileName","caught","fetchAll","total","reported","fileName_0","caught_0","fileName_1","reset","recordColumn","members","repinned","resized","visible","withColumnsShown","reordered","byField","entries","sortDirection","recordSort","recordSummaries","wasSound","raw","recordColumns","cycledSort","turned","exclusive","offeredPageSizes","ladder","max","size","admittedPageSize","admitted","rung","summariesOf","repairing","repairs","sort","summaries","NO_SORT","NO_COLUMNS","NO_SUMMARIES","NO_SELECTION","NO_ROWS","NO_LAYOUTS","NO_CARD","NO_GROUPS","NO_CARD_SPEC","useRecordTable","selected","ranSort","repaired","editAndApply","sortNow","toggleSort","snapshot_0","onScreen","options_0","toggle","all","_temp$4","toggleAll","pageSize","hasNext","_temp2$2","ladderOf","state_0","_temp3$1","column_0","state_1","_temp4","_temp5","summary","column_1","field_4","column_2","field_5","pinned","column_3","field_6","width","entry_0","field_7","_temp6","state_2","entry_2","field_8","fn","pageSize_0","entry_1","field_3","field_2","createCommandQueue","enqueue","queue","tag","task","queued","release","mine","intent","code","UNRECOVERED","recovered","savesView","unsettled","blocksNewIntent","holdsHandle","strandedHandle","mayRefuse","existing","mayReplace","incoming","IDLE","useSaveCommands","progress","setProgress","guarded","recovery","fallback","permissions","instance","creating","createPersonal","createShared","createSystem","save","landedSave","saveAs","rename","it","wroteStore","write","resolveConflict","it_0","revert","hasErrors","VALUE_CANDIDATE_DEBOUNCE_MS","NONE","useValueCandidates","source","blank","setAnswered","query","answer","_temp$3","NOTHING_LOADED","FIRST_LOAD","useViewList","kindsKey","request","setRequest","list","setList","preferences","setPreferences","definitionId","listing","preferencesSettled","retainedPreferences","currentPreferences","item","items","abilitiesOf","publishSystem","granted","PREFERENCES_KEY","NO_OUTCOMES","withOutcome","outcomes","projectStates","projected","sameOrder","one","other","placesOf","places","order","audiences","audience","groupIndexOf","planMoveTo","full","member","sameTag","NOTHING_RUN","useCommandRunner","owns","tagged","commit","record","next_0","stranded","outcome_0","again_0","recovery_0","blocked","guard","intent_0","code_0","command_0","useViewManager","optimistic","_temp$2","rendered","_temp2$1","_temp3","preferencesIntent","id_0","changeAudience","id_1","item_2","id_2","publishAsSystem","put","id_3","setDefault","ahead","carried","id_4","placeOf","planned","id_5","submitted","put_0","ok","moveTo","handle","outcome_1","handle_0","landed_0","outcome_2","again","resubmit","canResubmit","can","states","item_1","item_0","useInstanceSync","seen","asking","onInstanceChange","handedBefore","costly","useUnloadGuard","blocking","ask","_temp$1","event","useLeaveGuard","guardUnload","setHeld","onLeave","offers","blankConfig","newViewScope","blankView","newView","useReleaseDeleted","wasOpen","openId","setChosen","useHandOver","hold","made","useHandedConditions","landing","landingStore","merged","useHandedRemoval","heldBy","backToSaved","only","useWorkbench","heldRef","setHanded","handedHere","opensHere","byId","wrongKind","handedDraft","namedState","autoRun","commands","manager","leave","openHanded","blanks","_temp","_temp2","creatable","blank_0","kind_1","made_0","create","made_1","viewTitle","holdFrom","onDrilldown","viewTitle_0","drill","back","board","onNavigate","toBoard","declaredAt","kind_0"],"sources":["../src/analysis/metricOrder.ts","../src/react/environment.ts","../src/react/issues.ts","../src/react/analysisEditing.ts","../src/react/analysisFields.ts","../src/react/useReshape.ts","../src/runtime/pending.ts","../src/react/useViewEngine.ts","../src/react/useAnalysisEditor.ts","../src/react/useAnalysisResult.ts","../src/react/useAutoRefresh.ts","../src/react/actionRunner.ts","../src/react/useRecordActions.ts","../src/react/useSearchBox.ts","../src/react/useUnavailable.ts","../src/react/useDashboard.ts","../src/runtime/navigation.ts","../src/react/usePanelFollowUps.ts","../src/react/useFilterEditor.ts","../src/react/recordSelection.ts","../src/react/useRecordDetail.ts","../src/react/useRecordExport.ts","../src/react/recordColumns.ts","../src/react/recordDraft.ts","../src/react/recordEdits.ts","../src/react/useRecordTable.ts","../src/react/manager/queue.ts","../src/react/writes.ts","../src/react/useSaveCommands.ts","../src/react/useValueCandidates.ts","../src/react/useViewList.ts","../src/react/manager/abilities.ts","../src/react/manager/outcomes.ts","../src/react/manager/order.ts","../src/react/manager/useCommandRunner.ts","../src/react/useViewManager.ts","../src/react/workbench/instanceSync.ts","../src/react/workbench/leaveGuard.ts","../src/react/workbench/newView.ts","../src/react/workbench/releaseDeleted.ts","../src/react/workbench/handOver.ts","../src/react/useWorkbench.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { AnalysisColumn, AnalysisMetric } from '../model/index.js';\nimport { derivedRefs } from './dangling.js';\n\n/**\n * Why a metric could not go as far as it was asked: the metric it reads,\n * which it must stay after (`after`), or the derived metric that reads it,\n * which it must stay before (`before`).\n */\nexport interface MetricMoveStop {\n side: 'after' | 'before';\n /** The alias of the metric it stopped at. */\n at: string;\n}\n\n/** A metric moved in the list, as far as the rule lets it go. */\nexport interface MetricMove {\n metrics: AnalysisMetric[];\n /** Where it landed; its old index when it did not move at all. */\n to: number;\n /** Set when it landed short of where it was asked to go. */\n stop?: MetricMoveStop;\n}\n\n/**\n * The metric at `from` moved to `to`, where the order allows it (D71).\n *\n * A derived metric is read in list order — admission refuses one that reads\n * a metric declared after it (`analysis.derived.unknown-metric`), and the\n * editor's cascade takes it with that reading — so the order is part of the\n * question, not only of the table. A move is therefore **clamped**: a\n * derived metric goes no earlier than just after the last metric it reads,\n * and a metric goes no later than just before the first derived metric that\n * reads it. The move still happens as far as it can, and `stop` says which\n * metric it stopped at, so the editor can say why.\n *\n * `to` is the index the metric ends at in the new list. A metric that\n * would have to stand both after one and before another that come the\n * other way round has no place at all, and does not move.\n */\nexport function moveMetric(\n metrics: readonly AnalysisMetric[],\n from: number,\n to: number,\n): MetricMove {\n const moving = metrics[from];\n const unchanged = { metrics: [...metrics], to: from };\n if (!moving || from === to) return unchanged;\n const others = metrics.filter((_metric, at) => at !== from);\n const reads = moving.type === 'DERIVED' ? derivedRefs(moving.expression) : [];\n // After the last metric it reads…\n let lowest = 0;\n let after: string | undefined;\n others.forEach((metric, at) => {\n if (reads.includes(metric.alias) && at + 1 > lowest) {\n lowest = at + 1;\n after = metric.alias;\n }\n });\n // …and before the first derived metric that reads it.\n let highest = others.length;\n let before: string | undefined;\n others.forEach((metric, at) => {\n if (\n at < highest &&\n metric.type === 'DERIVED' &&\n derivedRefs(metric.expression).includes(moving.alias)\n ) {\n highest = at;\n before = metric.alias;\n }\n });\n if (lowest > highest) return unchanged;\n const target = Math.min(Math.max(to, 0), others.length);\n const landed = Math.min(Math.max(target, lowest), highest);\n const stop: MetricMoveStop | undefined =\n landed > target && after !== undefined\n ? { side: 'after', at: after }\n : landed < target && before !== undefined\n ? { side: 'before', at: before }\n : undefined;\n if (landed === from) return { ...unchanged, ...(stop ? { stop } : {}) };\n const next = [...others];\n next.splice(landed, 0, moving);\n return { metrics: next, to: landed, ...(stop ? { stop } : {}) };\n}\n\n/**\n * The table's declared columns after the metric `alias` moved to where it\n * stands in `metrics`: its column goes just after the column of the\n * nearest metric before it that has one, or else just before the column of\n * the nearest after it — so a moved metric's column follows it (D71) and\n * every other column keeps its place. A metric with no declared column, or\n * none around it with one, leaves the columns as they are: undeclared\n * columns already follow the config's order.\n */\nexport function columnsAfterMove(\n columns: readonly AnalysisColumn[],\n metrics: readonly AnalysisMetric[],\n alias: string,\n): AnalysisColumn[] {\n const own = columns.find(column => column.alias === alias);\n const at = metrics.findIndex(metric => metric.alias === alias);\n if (!own || at < 0) return [...columns];\n const rest = columns.filter(column => column !== own);\n const place = (neighbour: AnalysisMetric) =>\n rest.findIndex(column => column.alias === neighbour.alias);\n const earlier = metrics\n .slice(0, at)\n .reverse()\n .map(place)\n .find(i => i >= 0);\n const later = metrics\n .slice(at + 1)\n .map(place)\n .find(i => i >= 0);\n const index =\n earlier !== undefined ? earlier + 1 : later !== undefined ? later : -1;\n if (index < 0) return [...columns];\n rest.splice(index, 0, own);\n return rest;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ALWAYS_VISIBLE,\n defaultRuntimeEnvironment,\n type RuntimeEnvironment,\n type VisibilitySource,\n} from '../runtime/index.js';\n\n/**\n * Page visibility as the browser reports it, so a hidden tab stops\n * auto-refreshing. Falls back to \"always visible\" where there is no document,\n * which is what server rendering and a plain Node test are.\n */\nexport function documentVisibility(): VisibilitySource {\n if (typeof document === 'undefined') return ALWAYS_VISIBLE;\n return {\n isVisible: () => document.visibilityState !== 'hidden',\n subscribe: listener => {\n document.addEventListener('visibilitychange', listener);\n return () => {\n document.removeEventListener('visibilitychange', listener);\n };\n },\n };\n}\n\n/** The host a browser provides: ambient clock and timers, real visibility. */\nexport function browserRuntimeEnvironment(\n overrides: Partial<RuntimeEnvironment> = {},\n): RuntimeEnvironment {\n return defaultRuntimeEnvironment({\n visibility: documentVisibility(),\n ...overrides,\n });\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { issue } from '../filter/index.js';\nimport type { Issue, ViewKind } from '../model/index.js';\n\n// The one shape every command failure is rendered in. It moved to the\n// runtime, which needs it too; this layer keeps the name it always had.\nexport { toIssue } from '../runtime/issues.js';\n\n/**\n * The reason a view that opened cannot be drawn here, or nothing.\n *\n * One data definition holds record and analysis instances together, so a host\n * may name either of them to either workbench. The one that cannot render it\n * says so where every other failure to open is already reported — a body it\n * has no kernel for is an empty page, and an empty page explains nothing.\n */\nexport function kindMismatch(\n runtime: { kind: ViewKind } | null,\n drawn: readonly ViewKind[],\n): Issue | null {\n return runtime && !drawn.includes(runtime.kind)\n ? issue('view.open.wrong-kind', [], { kind: runtime.kind })\n : null;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { fiveNumberMetrics } from '../analysis/boxplot.js';\nimport { ohlcMetrics } from '../analysis/candlestick.js';\nimport {\n DEFAULT_MISSING_KEY,\n derivedMetric,\n durationMetric,\n formulaMetric,\n freeAlias,\n isDuration,\n metricWithCondition,\n momentMetrics,\n columnsAfterMove,\n moveMetric,\n type AnalysisScope,\n type Dropped,\n type MetricMove,\n} from '../analysis/index.js';\nimport {\n isDateCell,\n isValueMetric,\n without,\n type AnalysisColumn,\n type AnalysisDateDiffUnit,\n type AnalysisGroup,\n type AnalysisHavingExpression,\n type AnalysisMetric,\n type AnalysisViewConfig,\n type FilterTree,\n} from '../model/index.js';\n\n/**\n * What a change to the question proposes: the groups and metrics, the chain\n * where it moves, and what the change itself took out beyond what it was\n * asked to (`withElements`' `dropped`), for the editor to say.\n */\nexport type ReshapeProposal = Pick<AnalysisViewConfig, 'groups' | 'metrics'> &\n Partial<Pick<AnalysisViewConfig, 'elements'>> & {\n dropped?: Dropped;\n /** The table's declared columns, where the change moves one. */\n columns?: AnalysisColumn[];\n };\n\n/** The edit a drop is said after: a step of the chain, or any other. */\nexport type DropCause =\n { kind: 'expand'; name: string } | { kind: 'collapse'; name: string };\n\n/** A change to what is grouped or measured; see `useAnalysisEditor`'s reshape. */\nexport type Reshape = (\n update: (current: AnalysisViewConfig) => ReshapeProposal | undefined,\n cause?: DropCause,\n) => void;\n\nexport interface QuestionEditingInput {\n reshape: Reshape;\n /** A plain edit of the draft, for members nothing else names. */\n edit(patch: Partial<AnalysisViewConfig>): void;\n scope: AnalysisScope | null;\n}\n\n/**\n * The edits to the question — the dimensions, the metrics, what keeps a\n * group — as plain functions over the draft. They are built once per scope\n * and change the draft through `reshape`, which brings the chart, the sort\n * and the table columns along with whatever alias moved. Kept out of the\n * hook so the hook stays the wiring and this stays the rules.\n */\nexport function questionEditing({\n reshape,\n edit,\n scope,\n}: QuestionEditingInput) {\n const patchGroup = (\n index: number,\n update: (group: AnalysisGroup) => AnalysisGroup,\n ) =>\n reshape(current => ({\n groups: current.groups.map((group, at) =>\n at === index ? update(group) : group,\n ),\n metrics: current.metrics,\n }));\n const patchMetric = (\n index: number,\n update: (metric: AnalysisMetric) => AnalysisMetric,\n ) =>\n reshape(current => ({\n groups: current.groups,\n metrics: current.metrics.map((metric, at) =>\n at === index ? update(metric) : metric,\n ) as AnalysisViewConfig['metrics'],\n }));\n const taken = (current: AnalysisViewConfig) => [\n ...current.groups.map(group => group.alias),\n ...current.metrics.map(metric => metric.alias),\n ];\n\n return {\n addGroup: (group: AnalysisGroup) =>\n reshape(current => ({\n groups: [...current.groups, group],\n metrics: current.metrics,\n })),\n updateGroup: (index: number, patch: Partial<AnalysisGroup>) =>\n patchGroup(index, group => ({ ...group, ...patch }) as AnalysisGroup),\n removeGroup: (index: number) =>\n reshape(current => ({\n groups: current.groups.filter((_group, at) => at !== index),\n metrics: current.metrics,\n })),\n // The three settings that come and go rather than change: a name taken\n // back, a sentinel bucket dropped, a fill switched off leave no key\n // behind, so the config stays what a fresh one would be.\n renameGroup: (index: number, label: string | undefined) =>\n patchGroup(index, group =>\n label === undefined\n ? (without(group, 'label') as AnalysisGroup)\n : { ...group, label },\n ),\n setMissingBucket: (index: number, on: boolean) =>\n patchGroup(index, group =>\n group.type !== 'TERMS'\n ? group\n : on\n ? { ...group, missingKey: DEFAULT_MISSING_KEY }\n : without(group, 'missingKey'),\n ),\n setDense: (index: number, on: boolean) =>\n patchGroup(index, group =>\n group.type !== 'DATE_HISTOGRAM' && group.type !== 'DATE_PART'\n ? group\n : on\n ? { ...group, dense: true }\n : (without(group, 'dense') as AnalysisGroup),\n ),\n\n addMetric: (metric: AnalysisMetric) =>\n reshape(current => ({\n groups: current.groups,\n metrics: [...current.metrics, metric] as AnalysisViewConfig['metrics'],\n })),\n updateMetric: (index: number, patch: Partial<AnalysisMetric>) =>\n patchMetric(index, metric => ({ ...metric, ...patch }) as AnalysisMetric),\n /**\n * Puts a whole metric in a row's place. A change of summary is a change\n * of type — a sum becomes a distinct count — and a patch over the old\n * shape would leave its `function` or `expression` behind for admission\n * to trip over; the card builds the new metric and swaps it in.\n */\n replaceMetric: (index: number, metric: AnalysisMetric) =>\n patchMetric(index, () => metric),\n renameMetric: (index: number, label: string | undefined) =>\n patchMetric(index, metric =>\n label === undefined\n ? (without(metric, 'label') as AnalysisMetric)\n : { ...metric, label },\n ),\n /**\n * The conditions a metric counts under, or none. An empty tree is kept\n * while the card is being filled in — validation says it is unfinished\n * and the query waits — and `undefined` takes the condition away.\n */\n setMetricFilter: (index: number, filter: FilterTree | undefined) =>\n patchMetric(index, metric =>\n metric.type === 'DERIVED'\n ? metric\n : filter === undefined\n ? (without(metric, 'filter') as AnalysisMetric)\n : { ...metric, filter },\n ),\n /**\n * A second card of the same metric, right after it, with an empty\n * condition to fill in: 复制「金额的总和」并加条件. The copy keeps no\n * display name — two cards called the same thing is the ambiguity the\n * name exists to resolve, and the condition it is about to carry is what\n * resolves it. Answers the copy's alias — the card's identity — so the\n * slot can open the copy's conditions on the spot: the menu item\n * promised a condition, and a second identical card with nothing open is\n * not one. `reshape` runs synchronously against the live draft, so the\n * alias is in hand. `undefined` where there was nothing to copy.\n */\n duplicateMetric: (index: number): string | undefined => {\n let alias: string | undefined;\n reshape(current => {\n const copy = metricWithCondition(\n current.metrics[index],\n taken(current),\n );\n if (!copy) return undefined;\n alias = copy.alias;\n const metrics = [...current.metrics];\n metrics.splice(index + 1, 0, copy);\n return {\n groups: current.groups,\n metrics: metrics as AnalysisViewConfig['metrics'],\n };\n });\n return alias;\n },\n /**\n * The five numbers a boxplot draws of this metric's field (「补齐箱线图\n * 的五个数」): the ones among its lowest, 25th, 50th and 75th\n * percentiles and highest it is not, added right after it under its own\n * condition (`fiveNumberMetrics`). Nothing for a metric of no field.\n */\n addFiveNumbers: (index: number) =>\n reshape(current => {\n const metric = current.metrics[index];\n const missing = metric && fiveNumberMetrics(metric, taken(current));\n if (!missing || missing.length === 0) return undefined;\n const metrics = [...current.metrics];\n metrics.splice(index + 1, 0, ...missing);\n return {\n groups: current.groups,\n metrics: metrics as AnalysisViewConfig['metrics'],\n };\n }),\n /**\n * The four numbers a candlestick draws of this metric's field (「补齐 K\n * 线的四个数」): the ones among its opening value, highest, lowest and\n * closing value it is not, added right after it under its own condition\n * and ordered by its own time (`ohlcMetrics`). Nothing for a metric that\n * is none of the four of a field.\n */\n addOhlc: (index: number) =>\n reshape(current => {\n const metric = current.metrics[index];\n const missing = metric && ohlcMetrics(metric, taken(current));\n if (!missing || missing.length === 0) return undefined;\n const metrics = [...current.metrics];\n metrics.splice(index + 1, 0, ...missing);\n return {\n groups: current.groups,\n metrics: metrics as AnalysisViewConfig['metrics'],\n };\n }),\n /**\n * The metric at `from` put at `to`, as far as the order allows (D71): a\n * derived metric stays after what it reads, and a metric before what\n * reads it (`moveMetric`). Answers where it landed and, when it landed\n * short, which metric stopped it.\n */\n moveMetric: (from: number, to: number): MetricMove | undefined => {\n let moved: MetricMove | undefined;\n reshape(current => {\n moved = moveMetric(current.metrics, from, to);\n if (moved.to === from) return undefined;\n // 结果的列跟着走: a declared column order moves the column too.\n return {\n groups: current.groups,\n metrics: moved.metrics as AnalysisViewConfig['metrics'],\n columns: columnsAfterMove(\n current.table.columns,\n moved.metrics,\n current.metrics[from].alias,\n ),\n };\n });\n return moved;\n },\n removeMetric: (index: number) =>\n reshape(current =>\n // An aggregation query without a metric has nothing to return.\n current.metrics.length <= 1\n ? undefined\n : {\n groups: current.groups,\n metrics: current.metrics.filter(\n (_metric, at) => at !== index,\n ) as AnalysisViewConfig['metrics'],\n },\n ),\n /**\n * A formula over the first two fields the unit can measure, or over\n * one field twice when it has only one: the card is there to be\n * changed, and a card with a slot it cannot fill is not offered.\n */\n addFormula: () => {\n // A date is no operand (`analysis.expression.date-operand`): its\n // earliest and latest are functions of it, arithmetic is not.\n const dated = (name: string) => {\n const field = scope?.fields.get(name);\n return field !== undefined && isDateCell(field.cell ?? field.kind);\n };\n const measurable = [...(scope?.aggregations.values() ?? [])].filter(\n entry => entry.functions.length > 0 && !dated(entry.field),\n );\n const [first, second = first] = measurable;\n if (!first) return;\n reshape(current => ({\n groups: current.groups,\n metrics: [\n ...current.metrics,\n formulaMetric(\n first.field,\n second.field,\n first.functions[0],\n taken(current),\n ),\n ] as AnalysisViewConfig['metrics'],\n }));\n },\n /**\n * A time between two moments (N3, 「两个时刻之差」): the average `unit`s\n * from the first time the counting unit holds to the second — two\n * fields it buckets by date and takes into arithmetic. Nothing when it\n * holds fewer than two: a moment to itself is always nothing.\n */\n addDuration: (unit: AnalysisDateDiffUnit) => {\n const [from, to] = durationEnds(scope);\n if (!from || !to) return;\n reshape(current => ({\n groups: current.groups,\n metrics: [\n ...current.metrics,\n durationMetric(from, to, unit, taken(current)),\n ] as AnalysisViewConfig['metrics'],\n }));\n },\n /**\n * The duration a metric measures, cut into bands one `unit` wide as a\n * dimension of its own (「付款到发货 0–1 小时、1–2 小时…」, N3): a band of\n * a computed number, placed after the dimensions there are.\n */\n groupByDuration: (index: number) =>\n reshape(current => {\n const metric = current.metrics[index];\n if (!metric || !isDuration(metric)) return undefined;\n return {\n groups: [\n ...current.groups,\n {\n type: 'HISTOGRAM',\n alias: freeAlias('band', taken(current)),\n expression: metric.expression,\n interval: 1,\n },\n ],\n metrics: current.metrics,\n };\n }),\n /**\n * A derived metric over the first two metrics before it that a derived\n * one may read — any but a sample value or a moment\n * (`analysis.derived.moment-operand`) — or over one metric twice.\n */\n addDerived: () => {\n reshape(current => {\n const moments = scope\n ? momentMetrics(current.metrics, scope.fields)\n : new Set<string>();\n const readable = current.metrics.filter(\n metric => !isValueMetric(metric) && !moments.has(metric.alias),\n );\n const [first, second = first] = readable;\n if (!first) return undefined;\n return {\n groups: current.groups,\n metrics: [\n ...current.metrics,\n derivedMetric(first.alias, second.alias, taken(current)),\n ] as AnalysisViewConfig['metrics'],\n };\n });\n },\n setHaving: (having: AnalysisHavingExpression | undefined) =>\n edit(having === undefined ? { having: undefined } : { having }),\n };\n}\n\nexport type QuestionEditing = ReturnType<typeof questionEditing>;\n\n/**\n * The two times a new duration runs between: the first two fields of the\n * counting unit that it buckets by date and takes into arithmetic — which\n * is what Wow asks of each end of a `DATE_DIFF` (#3539).\n */\nfunction durationEnds(scope: AnalysisScope | null): string[] {\n return [...(scope?.aggregations.values() ?? [])]\n .filter(\n entry =>\n entry.groups.includes('DATE_HISTOGRAM' as never) &&\n entry.expressionInput !== false,\n )\n .map(entry => entry.field)\n .slice(0, 2);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { AnalysisScope } from '../analysis/index.js';\nimport type { FieldKindRegistry } from '../filter/index.js';\nimport {\n datePartsOf,\n isSingleStringField,\n type AnalysisDatePart,\n type AnalysisDateUnit,\n type AnalysisFunction,\n type AnalysisGroupType,\n type FieldDefinition,\n} from '../model/index.js';\n\n/** One field and what the definition allows doing with it. */\nexport interface AnalysisFieldOption {\n field: string;\n label: string;\n /** Group types this field offers; empty when it cannot be grouped. */\n groups: AnalysisGroupType[];\n /** Aggregation functions it offers; empty when it cannot be measured. */\n functions: AnalysisFunction[];\n dateUnits: AnalysisDateUnit[];\n /** The calendar parts a `DATE_PART` dimension on it may take (`datePartsOf`). */\n dateParts: AnalysisDatePart[];\n distinctCount: boolean;\n percentile: boolean;\n any: boolean;\n /** Whether it offers an opening and a closing value (FIRST / LAST). */\n firstLast: boolean;\n /** Whether a dimension on it may keep records missing the value as a group of their own. */\n missingKey: boolean;\n /** Whether its values are the steps of one process (`steps`): a funnel's. */\n steps?: boolean;\n /**\n * `false` where a formula may not take it as an operand\n * (`expressionInput`); absent or `true` where it may.\n */\n expressionInput?: boolean;\n /**\n * How its values read (`cell ?? kind`): the earliest of a `datetime` is\n * worded 「最早」 where a number's smallest is 「最小」, and a date is no\n * operand of a formula. Absent when not known.\n */\n cell?: string;\n}\n\n/** What the definition allows doing with each field of a scope. */\nexport function fieldOptions(\n scope: AnalysisScope,\n kinds: FieldKindRegistry | undefined,\n): AnalysisFieldOption[] {\n return [...scope.fields.values()].map((field: FieldDefinition) => {\n const aggregation = scope.aggregations.get(field.name);\n return {\n field: field.name,\n label: field.label,\n groups: aggregation?.groups ?? [],\n functions: aggregation?.functions ?? [],\n dateUnits: aggregation?.dateUnits ?? [],\n dateParts: datePartsOf(aggregation),\n distinctCount: aggregation?.distinctCount === true,\n percentile: aggregation?.percentile === true,\n any: aggregation?.any === true,\n firstLast: aggregation?.firstLast === true,\n missingKey:\n aggregation?.missingKey !== false &&\n isSingleStringField(field, kinds?.get(field.kind)),\n expressionInput: aggregation?.expressionInput !== false,\n steps: aggregation?.steps === true,\n cell: field.cell ?? field.kind,\n };\n });\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useState } from 'react';\nimport {\n analysisScope,\n momentMetrics,\n type Dropped,\n} from '../analysis/index.js';\nimport { withoutDangling } from '../analysis/dangling.js';\nimport type {\n AnalysisMetric,\n AnalysisViewConfig,\n ChartSpec,\n ViewConfig,\n} from '../model/index.js';\nimport type { ViewRuntime } from '../runtime/index.js';\nimport { fieldOptions, type AnalysisFieldOption } from './analysisFields.js';\nimport type { DropCause, ReshapeProposal } from './analysisEditing.js';\n\n/**\n * What the last edit took out of the question besides what it was asked\n * to — the dimensions and metrics a step of the chain left behind, the\n * derived metrics that read one removed — and the step it followed (D71).\n */\nexport interface DropNotice extends Dropped {\n /** The step of the chain it followed; absent after any other edit. */\n cause?: DropCause;\n /**\n * What the dropped ones are named against: the fields and metrics of the\n * question before the edit, whose scope may no longer hold their fields.\n */\n naming: { fields: AnalysisFieldOption[]; metrics: AnalysisMetric[] };\n}\n\n/**\n * Whether a metric's ✕ may take it out: `last` when it is the only one,\n * `cascade` when every other metric reads it and would leave with it — the\n * edit #3777 makes as asked, leaving admission to refuse it.\n */\nexport type MetricRemoval = 'ok' | 'last' | 'cascade';\n\nexport interface ReshapeInput {\n runtime: ViewRuntime | null;\n /** The draft on screen: the notice lasts while it is the one an edit made. */\n draft: ViewConfig | undefined;\n /** That draft, where it is an analysis. */\n config: AnalysisViewConfig | undefined;\n /** Edits the live draft (`useAnalysisEditor`'s `change`). */\n change(\n update: (current: AnalysisViewConfig) => Partial<AnalysisViewConfig>,\n ): void;\n /** The chart fitted to a shape (`useAnalysisEditor`'s `fitTo`). */\n fitTo(\n chart: ChartSpec,\n shape: Pick<AnalysisViewConfig, 'groups' | 'metrics' | 'elements'>,\n ): ChartSpec;\n}\n\n/**\n * The one way the question's shape changes — `reshape` — with what an edit\n * of it took out beyond what it was asked to kept for the notice that says\n * so and puts it back (D71), and whether a metric may be removed at all.\n */\nexport function useReshape({\n runtime,\n draft,\n config,\n change,\n fitTo,\n}: ReshapeInput) {\n const owner = runtime?.definition;\n const definition = owner?.kind === 'data' ? owner : undefined;\n const capability = definition?.analysis;\n /**\n * A change to what is grouped or measured, with everything that names an\n * alias brought along.\n *\n * Groups and metrics are what the rest of the config points at: the chart\n * addresses its slots by alias, the sort orders by one, the table lists\n * them. Editing the lists alone left those three naming aliases that were\n * gone — the chart reported `chart.group.unconsumed` and vanished, and the\n * sort reported `analysis.sort.unknown-alias` — so the one edit carries all\n * four. A slot, an ordering or a column the user chose is kept wherever it\n * still names something; nothing else survives the alias it referred to.\n * The metrics themselves follow the same way (`withoutDangling`): a\n * derived metric that read one gone goes with it, and so does a having\n * rule on it — else the next run stopped at `analysis.derived.unknown-metric`\n * or `analysis.having.unknown-metric`. Only what this edit broke goes: a\n * reference that read nothing before it stays for admission to point at.\n * Where following would leave nothing to measure, the edit is made as\n * asked, and admission says so.\n */\n // What the last edit took out, the question it started from and the\n // draft it made: the notice lasts while that draft is the draft. After\n // an undo, the draft it put back, so 「已撤销」 lasts as long.\n const [drop, setDrop] = useState<\n | { notice: DropNotice; before: AnalysisViewConfig; after: unknown }\n | { notice: null; after: unknown }\n | null\n >(null);\n const factsOf = useCallback(\n (of: AnalysisViewConfig): Parameters<typeof withoutDangling>[1] =>\n definition && capability\n ? {\n moments: momentMetrics(\n of.metrics,\n analysisScope(definition, capability, of).fields,\n ),\n havingMetrics: capability.havingMetrics,\n }\n : {},\n [definition, capability],\n );\n const reshape = useCallback(\n (\n update: (current: AnalysisViewConfig) => ReshapeProposal | undefined,\n cause?: DropCause,\n ) => {\n // Filled in by the update, which `change` runs synchronously.\n const said: { notice?: DropNotice; before?: AnalysisViewConfig } = {};\n change(current => {\n const proposal = update(current);\n if (!proposal) return {};\n const { dropped: stepped, columns: listed, ...proposed } = proposal;\n const shape = { ...current, ...proposed };\n const followed = withoutDangling(shape, factsOf(shape), {\n shape: current,\n facts: factsOf(current),\n });\n // Where following the edit would leave nothing to measure, the edit\n // is made as asked and admission says what it lacks.\n const next =\n followed.metrics.length === 0\n ? proposed\n : { ...proposed, metrics: followed.metrics };\n const took = {\n groups: stepped?.groups ?? [],\n metrics: [\n ...(stepped?.metrics ?? []),\n ...(followed.metrics.length === 0\n ? []\n : shape.metrics.filter(metric =>\n followed.removed.includes(metric.alias),\n )),\n ],\n };\n if (took.groups.length + took.metrics.length > 0) {\n const naming = {\n fields:\n definition && capability\n ? fieldOptions(\n analysisScope(definition, capability, current),\n runtime?.kinds,\n )\n : [],\n metrics: current.metrics,\n };\n said.notice = { ...took, naming, ...(cause ? { cause } : {}) };\n said.before = current;\n }\n // The having follows either way: only the derived metric's finding\n // is left for admission, not rules on a metric that left.\n const { having } = followed;\n const aliases = new Set([\n ...next.groups.map(group => group.alias),\n ...next.metrics.map(metric => metric.alias),\n ]);\n return {\n ...next,\n ...(having === current.having ? {} : { having }),\n chart: fitTo(current.chart, { ...current, ...next }),\n // Wow refuses a sort over an ungrouped aggregation, and it has one\n // row anyway, so losing the last group empties the ordering too.\n sort:\n next.groups.length === 0\n ? []\n : current.sort.filter(entry => aliases.has(entry.alias)),\n table: {\n ...current.table,\n columns: (listed ?? current.table.columns).filter(column =>\n aliases.has(column.alias),\n ),\n },\n };\n });\n const { notice, before } = said;\n if (notice && before && runtime)\n setDrop({ notice, before, after: runtime.getSnapshot().draft });\n },\n [change, fitTo, factsOf, runtime, definition, capability],\n );\n\n const live = drop && draft === drop.after ? drop : null;\n\n return {\n reshape,\n dropped: live?.notice ?? null,\n /** Whether the draft is the one the last undo put back. */\n undone: live !== null && live.notice === null,\n undoDrop: useCallback(() => {\n if (!runtime || !live?.notice) return;\n const { before } = live;\n runtime.edit({\n elements: before.elements,\n groups: before.groups,\n metrics: before.metrics,\n having: before.having,\n chart: before.chart,\n sort: before.sort,\n table: before.table,\n });\n setDrop({ notice: null, after: runtime.getSnapshot().draft });\n }, [runtime, live]),\n dismissDrop: useCallback(() => setDrop(null), []),\n metricRemoval: useCallback(\n (index: number): MetricRemoval => {\n if (!config || config.metrics.length <= 1) return 'last';\n const shape = {\n ...config,\n metrics: config.metrics.filter(\n (_metric, at) => at !== index,\n ) as AnalysisViewConfig['metrics'],\n };\n return withoutDangling(shape, factsOf(shape), {\n shape: config,\n facts: factsOf(config),\n }).metrics.length === 0\n ? 'cascade'\n : 'ok';\n },\n [config, factsOf],\n ),\n };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { dequal } from 'dequal';\nimport {\n isRootFilterIssue,\n nodeAt,\n sameFilterNode,\n walkFilter,\n type FilterPath,\n} from '../filter/index.js';\nimport {\n presentationMembers,\n type FilterTree,\n type Issue,\n type ViewConfig,\n} from '../model/index.js';\n\n/**\n * What the draft says that the applied config does not (D17-6).\n *\n * \"Changed, not applied\" is one of the screen's three credentials (D2), and\n * it used to be measured on the filter tree alone. Every other member of the\n * config could stand apart from `applied` with nothing on screen to say so:\n * a control that edits without applying — the filter mode, the analysis\n * editor's groups, metrics, sort, limit and chart, which all wait for Run —\n * and a control that edits and applies whose apply was refused, because the\n * draft holds an error and `apply` does not land. The sort editor, the page\n * size and the column settings then read the draft while the rows are still\n * the last execution's.\n *\n * So the credential is the whole config: `draft` against `applied`, member\n * by member. The conditions keep their finer reading — node by node, which is\n * what marks one pill and not its ancestors — and every other member counts\n * as one edit when it differs. A refused apply counts, since the two configs\n * still disagree; a draft equal to what was applied does not, whatever the\n * issues say about either.\n *\n * It lives in the runtime layer because `dequal` is the runtime's (see\n * `test/architecture.test.ts`): the same equality `revert` decides by.\n */\nexport interface PendingReport {\n /** True when the draft says anything the applied config does not. */\n pending: boolean;\n /**\n * How many edits wait for apply: the conditions edited since the last\n * apply, node by node, plus one for every other member that differs.\n */\n count: number;\n /**\n * Whether the conditions themselves differ. The filter editor's discard\n * puts the conditions back and nothing else, so it is offered on this\n * rather than on `pending`.\n */\n conditions: boolean;\n}\n\nconst EMPTY_TREE: FilterTree = { op: 'and', children: [] };\n\n/**\n * Whether `issues` refuse the config's own filter tree for its size. Such a\n * tree — from a store, possibly holding a cycle — is not walked at all: it\n * blocked apply, so it stands apart from `applied` by construction and\n * counts as one edit. An analysis element's or a dashboard panel's own\n * filter reports the very same codes under `['elements', …]` or\n * `['panels', …]`; the path is what says the finding is the root tree's.\n */\nexport function filterOverBudget(issues: readonly Issue[]): boolean {\n return issues.some(\n found =>\n (found.code === 'filter.tree.too-deep' ||\n found.code === 'filter.tree.too-many-nodes') &&\n isRootFilterIssue(found),\n );\n}\n\nexport function comparePending(\n draft: ViewConfig,\n applied: ViewConfig,\n issues: readonly Issue[],\n): PendingReport {\n let count = 0;\n let conditions = false;\n // Member by member, over whichever members either side has: a config is a\n // closed record per kind, but this compares all three kinds the same way.\n const was: Record<string, unknown> = { ...applied };\n const now: Record<string, unknown> = { ...draft };\n const keys = new Set([...Object.keys(now), ...Object.keys(was)]);\n // The dot says \"the rows on screen do not answer the config you see\", and\n // a member that never reaches the query cannot make that true. Which\n // members those are is the model's to declare, beside the types they are\n // members of (`presentationMembers`); read here they were string\n // comparisons that no `satisfies` could hold to the config.\n const presentation = presentationMembers(draft.kind);\n for (const key of keys) {\n if (presentation.includes(key)) continue;\n const before = was[key];\n const after = now[key];\n if (key === 'filter') {\n if (before === after) continue;\n const nodes = filterOverBudget(issues)\n ? 1\n : pendingNodes(\n (after as FilterTree | undefined) ?? EMPTY_TREE,\n (before as FilterTree | undefined) ?? EMPTY_TREE,\n );\n if (nodes > 0) conditions = true;\n count += nodes;\n continue;\n }\n if (!dequal(before, after)) count += 1;\n }\n return { pending: count > 0, count, conditions };\n}\n\n/**\n * Whether the draft waits for apply on anything `patch` does not write.\n *\n * A control that edits one member and runs — a header's sort above all —\n * may run only while nothing else waits: running applies the whole draft,\n * and a condition still waiting in the range is not the control's to apply\n * (todo 「记录视图按表头排序」; the analysis header's `sortNow`, #1807). The\n * patch is laid over both sides before they are compared, so an edit to the\n * same member that was held back earlier — which this one replaces — does\n * not count as another.\n */\nexport function pendingBesides<C extends ViewConfig>(\n state: { draft: C; applied: C; issues: readonly Issue[] },\n patch: Partial<C>,\n): boolean {\n return comparePending(\n { ...state.draft, ...patch },\n { ...state.applied, ...patch },\n state.issues,\n ).pending;\n}\n\n/**\n * Whether the draft differs from what was saved **only** in how the result\n * is drawn — the layout, the chart (`presentationMembers`) — and in at least\n * one of those (D23 Q15). The title bar then says 「只改了展示」 rather than\n * a bare 「已修改」, and takes the edits back without asking: what would be\n * lost is a way of looking, not a question, and putting the saved one back\n * runs nothing (a presentation edit never reached `applied`).\n */\nexport function presentationOnlyEdits(\n draft: ViewConfig,\n saved: ViewConfig,\n): boolean {\n const was: Record<string, unknown> = { ...saved };\n const now: Record<string, unknown> = { ...draft };\n const presentation = presentationMembers(draft.kind);\n let drawn = false;\n for (const key of new Set([...Object.keys(now), ...Object.keys(was)])) {\n if (dequal(now[key], was[key])) continue;\n if (!presentation.includes(key)) return false;\n drawn = true;\n }\n return drawn;\n}\n\n/**\n * The nodes of `tree` that say something other than `inForce` at the same\n * path, and the nodes only `inForce` has. A condition taken out of the draft\n * is still an edit not applied: the rows on screen were fetched under it.\n * Counting the draft alone would leave a badge of 0 beside an Apply button\n * that has something to do — a cleared filter most of all.\n */\nfunction pendingNodes(tree: FilterTree, inForce: FilterTree): number {\n let count = 0;\n const visited = new Set<string>();\n for (const { node, path } of walkFilter(tree)) {\n const at = indexesOf(path);\n visited.add(at.join(','));\n if (!sameFilterNode(node, nodeAt(inForce, at))) count += 1;\n }\n for (const { path } of walkFilter(inForce)) {\n const at = indexesOf(path);\n if (!visited.has(at.join(','))) count += 1;\n }\n return count;\n}\n\n/** A walk's path as the editor addresses nodes: the child indexes alone. */\nfunction indexesOf(path: readonly (string | number)[]): FilterPath {\n return path.filter((step): step is number => typeof step === 'number');\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from 'react';\nimport type { FilterTree, Issue } from '../model/index.js';\nimport {\n ViewEngine,\n type AnyViewRuntime,\n type OpenOptions,\n type ViewEngineOptions,\n} from '../runtime/index.js';\nimport { browserRuntimeEnvironment } from './environment.js';\nimport { toIssue } from './issues.js';\n\nconst NO_OP = () => {};\n\n/**\n * Creates one engine for the lifetime of the component and disposes it on\n * unmount. An application that wants a longer life builds the engine itself\n * and passes it to the other hooks; they take an engine, never options.\n *\n * Options are read once. Changing them later has no effect, because a\n * definition set and a store are not render-time values.\n */\nexport function useViewEngine(options: ViewEngineOptions): ViewEngine {\n const [engine] = useState(\n () =>\n new ViewEngine({\n ...options,\n // After the spread, so an explicit `environment: undefined` from a\n // caller's options object cannot drop page-visibility awareness.\n environment: options.environment ?? browserRuntimeEnvironment(),\n }),\n );\n useEffect(() => () => engine.dispose(), [engine]);\n return engine;\n}\n\n/**\n * Subscribes to a runtime. The runtime commits state before it notifies and\n * returns the same object while nothing changes, which is exactly what\n * `useSyncExternalStore` asks of a store.\n *\n * The parameter is the store shape rather than `ViewRuntime<C>`, so the\n * discriminated union `open` returns is accepted as it is and the snapshot\n * type follows from the runtime that was passed.\n */\nexport function useViewRuntime<R extends ViewRuntimeStore<unknown>>(\n runtime: R | null,\n): SnapshotOf<R> | null {\n const subscribe = useCallback(\n (listener: () => void) => runtime?.subscribe(listener) ?? NO_OP,\n [runtime],\n );\n const snapshot = useCallback(\n // The conditional type cannot be proven inside the generic; what makes it\n // true is that the value comes from this runtime's own `getSnapshot`.\n () => (runtime?.getSnapshot() ?? null) as SnapshotOf<R> | null,\n [runtime],\n );\n return useSyncExternalStore(subscribe, snapshot, snapshot);\n}\n\n/** What `useViewRuntime` needs: any runtime satisfies it. */\nexport interface ViewRuntimeStore<S> {\n subscribe(listener: () => void): () => void;\n getSnapshot(): S;\n}\n\n/**\n * The snapshot a runtime hands out. It distributes, so passing the union\n * `open` returns gives back the union of their states rather than one member.\n */\nexport type SnapshotOf<R> = R extends { getSnapshot(): infer S } ? S : never;\n\n/**\n * What a dashboard opens with, as a host's address has it: the tab on screen\n * and what the filters hold (D22 E, F), and what an embedding page holds of\n * them (`held`). Read as the view opens.\n */\nexport type DashboardOpening = Pick<OpenOptions, 'tab' | 'filters' | 'held'>;\n\nexport interface OpenViewState {\n runtime: AnyViewRuntime | null;\n loading: boolean;\n error: Issue | null;\n /**\n * What the view refused of the `scopeFilter` asked for, on the first open\n * as after it. A host that narrows to a field the definition does not admit\n * keeps the result it had — un-narrowed on an open — so the refusal has to\n * reach the screen rather than be dropped here.\n */\n scopeIssues: Issue[];\n /**\n * Opens the same id again: the way back from a failure that may pass — the\n * store unreachable, or answering with an error of its own\n * (`retryableOpen`). Loading again until the new answer lands.\n */\n retry(): void;\n}\n\n/**\n * Whether a failure to open may go away by itself, so trying again is worth\n * offering: the store could not be reached or could not answer\n * (`view.open.failed.unavailable`, `….server`), or what failed said nothing\n * the engine knows (`view.open.failed`). A view that is gone, refused or of\n * another kind answers the same the next time.\n */\nexport function retryableOpen(issue: Issue | null): boolean {\n if (!issue) return false;\n return (\n issue.code === 'view.open.failed' ||\n issue.code === 'view.open.failed.unavailable' ||\n issue.code === 'view.open.failed.unavailable.server'\n );\n}\n\n/**\n * What the last completed open produced, and which request it answered.\n * Loading is not in here: it is derived from whether this answer belongs to\n * the request on hand.\n */\ninterface OpenedView {\n engine: ViewEngine | null;\n instanceId: string | null;\n runtime: AnyViewRuntime | null;\n error: Issue | null;\n /** The opening it answered (`Reopen.attempt`). */\n attempt: number;\n}\n\nconst NOT_OPENED: OpenedView = {\n engine: null,\n instanceId: null,\n runtime: null,\n error: null,\n attempt: 0,\n};\n\n/**\n * Stable identity for \"nothing was refused\": what a view nobody has opened\n * yet has refused, and what keeps the memo below still.\n */\nconst NO_ISSUES: Issue[] = [];\n\n/**\n * How many times the id was opened again — a disposal forced it, or the\n * caller asked (`retry`) — and the last runtime a disposal did it for.\n */\ninterface Reopen {\n after: AnyViewRuntime | null;\n attempt: number;\n}\n\nconst NO_REOPEN: Reopen = { after: null, attempt: 0 };\n\n/**\n * Opens an instance and owns the runtime it produced: changing the id or\n * unmounting disposes the previous one, and a response that arrives after that\n * is dropped rather than applied to a view nobody is looking at.\n *\n * A runtime disposed under it — the engine lets one go when its instance is\n * deleted — is not handed out either. The id is opened again, and the caller\n * gets a live runtime for what is still there, or the not-found the engine\n * answers with, in place of a dead runtime that ignores every command.\n *\n * Loading is derived rather than stored. As long as the answer on hand belongs\n * to a different request, this one is still in flight, so the effect sets\n * state only when a response arrives.\n *\n * A `scopeFilter` is in force from the opening query: the engine admits it\n * with the config, so a host that scopes a view never lets an unscoped query\n * leave. It is read when the view opens and then followed, so a caller may\n * pass a fresh object every render without reopening anything. One the\n * definition refuses is not in force at all — the view runs un-narrowed and\n * `scopeIssues` says which condition did not take (D17-5).\n *\n * `opening` says which tab a dashboard opens on and what its filters hold\n * (`OpenOptions.tab`, `OpenOptions.filters`), and which definition the\n * caller draws (`OpenOptions.definitionId`), asked of the caller as each\n * view opens — only then does it mean anything.\n */\nexport function useOpenView(\n engine: ViewEngine,\n instanceId: string | null,\n scopeFilter: FilterTree | null = null,\n opening?: (\n instanceId: string,\n ) => Omit<OpenOptions, 'scopeFilter'> | undefined,\n): OpenViewState {\n const [opened, setOpened] = useState<OpenedView>(NOT_OPENED);\n // Advanced once per runtime disposed under the hook, so the opening effect\n // runs again for an id that did not change. The dead runtime is remembered\n // so the same one advances it only once.\n const [reopen, setReopen] = useState<Reopen>(NO_REOPEN);\n // Read at open time, so a new object identity does not reopen the view.\n // Kept fresh by the effect below rather than during render, and declared\n // before the opening effect so a reopen sees the current condition.\n const latestScope = useRef(scopeFilter);\n useEffect(() => {\n latestScope.current = scopeFilter;\n }, [scopeFilter]);\n const latestOpening = useRef(opening);\n useEffect(() => {\n latestOpening.current = opening;\n }, [opening]);\n\n useEffect(() => {\n // Only `null` means \"nothing to open\". Any string, empty included, is an\n // id the engine answers for, with a not-found the caller can show.\n if (instanceId === null) return;\n\n let runtime: AnyViewRuntime | null = null;\n let cancelled = false;\n\n const opensOn = latestOpening.current?.(instanceId);\n void engine\n .open(instanceId, { ...opensOn, scopeFilter: latestScope.current })\n .then(\n result => {\n if (cancelled) {\n engine.close(result);\n return;\n }\n runtime = result;\n setOpened({\n engine,\n instanceId,\n runtime: result,\n error: null,\n attempt: reopen.attempt,\n });\n },\n (error: unknown) => {\n if (cancelled) return;\n setOpened({\n engine,\n instanceId,\n runtime: null,\n error: toIssue(error, 'view.open.failed'),\n attempt: reopen.attempt,\n });\n },\n );\n\n return () => {\n cancelled = true;\n if (runtime) engine.close(runtime);\n };\n }, [engine, instanceId, reopen.attempt]);\n\n // Later changes are injected; `setScopeFilter` ignores an identical tree,\n // so this is quiet until the host actually narrows or widens the view.\n const runtime = opened.instanceId === instanceId ? opened.runtime : null;\n useEffect(() => {\n runtime?.setScopeFilter(scopeFilter);\n }, [runtime, scopeFilter]);\n // What the view refused of it. A refusal is the runtime's own state — it\n // keeps the scope that *is* in force running and notifies — so it is read\n // from there rather than caught from the injection above: a scope refused\n // as the view opened went in at construction, where no caller was holding\n // a return value to look at.\n const scopeIssues = useSyncExternalStore(\n useCallback(\n (listener: () => void) => runtime?.subscribe(listener) ?? NO_OP,\n [runtime],\n ),\n useCallback(() => runtime?.refusedScope ?? NO_ISSUES, [runtime]),\n );\n\n // A runtime is disposed without a notification — `dispose` drops its\n // listeners — so the subscription alone would never fire. The snapshot is\n // read on every render as well, which is where the disposal is seen.\n const disposed = useSyncExternalStore(\n useCallback(\n (listener: () => void) => runtime?.subscribe(listener) ?? NO_OP,\n [runtime],\n ),\n useCallback(() => runtime?.disposed === true, [runtime]),\n );\n // Adjusted during render, as state derived from a value that changed: React\n // re-renders at once with the new attempt and the effect above reopens.\n if (disposed && runtime !== null && reopen.after !== runtime)\n setReopen({ after: runtime, attempt: reopen.attempt + 1 });\n\n const retry = useCallback(\n () => setReopen(current => ({ ...current, attempt: current.attempt + 1 })),\n [],\n );\n\n const answered =\n opened.instanceId === instanceId &&\n opened.attempt === reopen.attempt &&\n (opened.engine === engine || instanceId === null) &&\n !disposed;\n\n return useMemo(\n () =>\n answered\n ? {\n runtime: opened.runtime,\n loading: false,\n error: opened.error,\n scopeIssues,\n retry,\n }\n : {\n runtime: null,\n loading: instanceId !== null,\n error: null,\n scopeIssues: NO_ISSUES,\n retry,\n },\n [answered, opened.runtime, opened.error, instanceId, scopeIssues, retry],\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n approximateMetrics,\n dateDiffUnitsOf,\n overlaid,\n} from '../model/index.js';\nimport type {\n FieldGroupDefinition,\n FilterTree,\n AnalysisDateDiffUnit,\n AnalysisDateUnit,\n AnalysisElement,\n AnalysisGroup,\n AnalysisHavingExpression,\n AnalysisMetric,\n AnalysisSort,\n AnalysisViewConfig,\n ChartSpec,\n ChartType,\n FieldDefinition,\n Issue,\n} from '../model/index.js';\nimport {\n analysisScope,\n limitBounds,\n withoutLevelsFrom,\n elementFilterFields,\n withLevel,\n fitChartSlots,\n switchChartType,\n havingRows,\n levelLabel,\n metricMeasures,\n momentMetrics,\n nextLevel,\n withElements,\n rangeSpan,\n recommendDateUnit,\n resultSpan,\n type AnalysisLimitBounds,\n type AnalysisScope,\n} from '../analysis/index.js';\nimport { isFieldlessKind } from '../model/index.js';\nimport {\n questionEditing,\n type DropCause,\n type QuestionEditing,\n} from './analysisEditing.js';\nimport { fieldOptions, type AnalysisFieldOption } from './analysisFields.js';\nimport {\n useReshape,\n type DropNotice,\n type MetricRemoval,\n} from './useReshape.js';\nimport type { FieldKindRegistry } from '../filter/index.js';\nimport type { OptionSource, ViewRuntime } from '../runtime/index.js';\nimport { answeringAnew, autoApplyDue } from '../runtime/autoApply.js';\nimport { comparePending, pendingBesides } from '../runtime/pending.js';\nimport { useViewRuntime } from './useViewEngine.js';\n\nexport interface AnalysisEditorController extends QuestionEditing {\n /**\n * What the latest edit took out beyond what it was asked to, while the\n * draft is still the one that edit made; `null` otherwise. Said with an\n * undo rather than asked before (D71: no confirmation dialog).\n */\n dropped: DropNotice | null;\n /** Puts the question back as it was before the edit `dropped` reports. */\n undoDrop(): void;\n /**\n * Whether the draft is still the one `undoDrop` put back — what lets\n * 「已撤销」 stay said until the next edit, not a render later.\n */\n undone: boolean;\n /** Takes the notice away and keeps the edit. */\n dismissDrop(): void;\n /** Whether the metric at `index` may be removed, and if not, why. */\n metricRemoval(index: number): MetricRemoval;\n /**\n * The expansion chain in force, outermost first (D20 屏 G): the arrays\n * the analysis counts inside. Empty when it counts records.\n */\n elements: AnalysisElement[];\n /** The next level the capability declares beyond the chain, or none. */\n expandable: { path: string; label: string } | null;\n /** Whether the capability declares a chain at all: the slot exists then. */\n expansible: boolean;\n /**\n * What is being counted: the innermost element, else the definition's\n * `recordNoun`; `null` where the definition names none, and a surface\n * says its own word for a record.\n */\n unit: string | null;\n /** The array a level expands, as its field is labelled. */\n elementLabel(index: number): string;\n /** The fields a level's own gate may name. */\n elementFields(index: number): FieldDefinition[];\n /** One level deeper, along the declared chain; re-scopes the question. */\n expand(path: string): void;\n /** Cuts the chain at `index`: that level and every level inside it leave. */\n collapse(index: number): void;\n /** A level's gate on the entries it lets through, or none. */\n setElementFilter(index: number, filter: FilterTree | undefined): void;\n groups: AnalysisGroup[];\n metrics: AnalysisMetric[];\n sort: AnalysisSort[];\n limit: number;\n /**\n * The range 「前 N 组」 may take and the N a blank stands for, from the one\n * `limitBounds` admission reads, so a field can say the bounds Apply is\n * refused by. `{ max: 0, fallback: 0 }` without an analysis capability.\n */\n limitBounds: AnalysisLimitBounds;\n layout: AnalysisViewConfig['layout'];\n chart: ChartSpec;\n totals: boolean;\n /** Issues about the analysis and its chart, not the whole view. */\n issues: Issue[];\n /** Aliases a chart or a sort may reference. */\n aliases: { groups: string[]; metrics: string[] };\n /**\n * The draft's metrics that are moments (`momentMetrics`) — the earliest or\n * the latest of a date — by alias: read in the table and on a card, never\n * measured by a mark, compared by 「只保留」 or calculated with.\n */\n moments: ReadonlySet<string>;\n /** What the definition allows, already expanded for configured elements. */\n fields: AnalysisFieldOption[];\n /** The picker groups the definition declares. */\n fieldGroups: readonly FieldGroupDefinition[];\n countable: boolean;\n /**\n * True while the rows on screen answer an older question than the one\n * being asked: the runtime is about to run the draft on its own\n * (`autoApplyDue`), or has sent it and the answer is on its way\n * (`answeringAnew`) — however slow it is. The result is drawn faded rather\n * than cleared, because a blank in between reads as a failure.\n */\n stale: boolean;\n /** Whether 「只保留」 exists here: the capability declares `having`. */\n havingAllowed: boolean;\n /** Whether a formula or a derived metric may be written: `expressions`. */\n expressionsAllowed: boolean;\n /**\n * The metric types 「只保留」 may compare (`havingMetrics`); `null` where\n * the capability names none, which is every type.\n */\n havingMetrics: readonly string[] | null;\n /**\n * The field an opening or closing value (FIRST / LAST) at the root is\n * ordered by when it names none (`firstLastOrderBy`, the model's event\n * time); `null` where the capability does not say.\n */\n firstLastOrderBy: string | null;\n /**\n * The units a time between two moments may be measured in\n * (`dateDiffUnitsOf`); empty where the capability offers no computed\n * expressions, which takes 「两个时刻之差」 away.\n */\n dateDiffUnits: readonly AnalysisDateDiffUnit[];\n /** Whether the rows may be ordered by a metric (`metricSort`). */\n metricSortAllowed: boolean;\n /** Whether a date dimension may fill its empty buckets (`dense`). */\n denseAllowed: boolean;\n /**\n * The metric types the source estimates (`approximateMetrics`): a metric\n * of one is named with 「≈」 wherever it is mentioned.\n */\n approximate: readonly string[];\n /**\n * 「只保留」 as rows of one comparison each, or `null` when the stored\n * having is a shape the rows cannot say (`havingRows`).\n */\n having: ReturnType<typeof havingRows>;\n /**\n * The 「只保留」 the rows on screen ran under — the result's config, not\n * the draft — or `undefined` when nothing ran or it kept every group. The\n * result's reading says it (`AnalysisToolbar`): a saved view opens with\n * the tray folded, and groups missing from the table with nothing on\n * screen saying why read as groups with no data.\n */\n ranHaving: AnalysisHavingExpression | undefined;\n /**\n * The fields a metric's own condition may name (D20 屏 H): the scalar\n * fields of the analysis scope — never a search, an array or an element\n * match, which Wow refuses in metric position — as the range's editor\n * names them, so the condition is built of the same pills.\n */\n conditionFields: readonly FieldDefinition[];\n /** The kinds those fields are read by; absent without a runtime. */\n kinds: FieldKindRegistry | undefined;\n /** Candidates for a remote value editor, as the range's editor has them. */\n optionSource?(remote: string): OptionSource | null;\n /**\n * True while the draft says something the last Run did not (D17-6): the\n * groups, metrics, sort, limit, chart and totals all wait for Run, and a\n * Run that was refused leaves them waiting. The same reading as the filter\n * editor's `pending` — both buttons run the whole draft.\n */\n pending: boolean;\n\n /**\n * The granularity a new time dimension on this field starts at (K4): read\n * off the applied range's conditions on the field, failing that off the\n * buckets a result already has on it, else the field's first unit.\n */\n dateUnitFor(field: AnalysisFieldOption): AnalysisDateUnit;\n setSort(sort: AnalysisSort[]): void;\n /**\n * Sets the sort and runs it now — unless something else in the draft is\n * waiting for Apply. A press on a result header asks to see *this* result\n * in another order; running would apply the other edits too (a range\n * condition not yet applied, a dimension added in the tray), which is not\n * that gesture's to do. Then the sort joins them, the pending dot shows,\n * and Apply runs them together — the rule the metric card's whole\n * (`useAnalysisResult`) keeps. Whether it ran is returned.\n */\n sortNow(sort: AnalysisSort[]): boolean;\n setLimit(limit: number): void;\n /** A redraw of the same rows, never a run; nor does it count as pending. */\n setLayout(layout: AnalysisViewConfig['layout']): void;\n setChartType(type: ChartType): void;\n updateChart(patch: Partial<ChartSpec>): void;\n setTotals(totals: boolean): void;\n submit(): void;\n /** Auto-refresh pauses between these two, so typing is never interrupted. */\n focus(): void;\n blur(): void;\n}\n\nconst EMPTY_CHART: ChartSpec = { type: 'bar' };\nconst NO_MOMENTS: ReadonlySet<string> = new Set();\n\n/**\n * Editing of an analysis draft: what to group by, what to measure, and how to\n * draw it.\n *\n * What may be grouped or measured comes from the definition's capability\n * rather than from the field list, because a backend that cannot sum a column\n * should not be offered the option.\n */\nconst EMPTY_GROUPS: readonly FieldGroupDefinition[] = [];\nconst NO_LIMIT_BOUNDS: AnalysisLimitBounds = { max: 0, fallback: 0 };\n\nexport function useAnalysisEditor(\n runtime: ViewRuntime | null,\n): AnalysisEditorController {\n const state = useViewRuntime(runtime);\n const draft = state?.draft;\n const config = draft && draft.kind === 'analysis' ? draft : undefined;\n\n // A dashboard runtime has no fields and no capabilities; the controller\n // then reports an empty scope rather than editing something that is not there.\n const owner = runtime?.definition;\n const definition = owner?.kind === 'data' ? owner : undefined;\n const capability = definition?.analysis;\n const scope = useMemo<AnalysisScope | null>(\n () =>\n definition && capability\n ? analysisScope(definition, capability, config)\n : null,\n [definition, capability, config],\n );\n\n const edit = useCallback(\n (patch: Partial<AnalysisViewConfig>) => runtime?.edit(patch),\n [runtime],\n );\n // The chart fitted to a shape, with what its metrics are read against the\n // scope of that shape, because a change to the expansion chain moves the\n // fields a metric summarises: which are moments, and what each measures.\n const fitTo = useCallback(\n (\n chart: ChartSpec,\n shape: Pick<AnalysisViewConfig, 'groups' | 'metrics' | 'elements'>,\n ) => {\n if (!definition || !capability)\n return fitChartSlots(chart, shape.groups, shape.metrics);\n const { fields } = analysisScope(definition, capability, shape);\n return fitChartSlots(\n chart,\n shape.groups,\n shape.metrics,\n momentMetrics(shape.metrics, fields),\n metricMeasures(shape.metrics, fields),\n );\n },\n [definition, capability],\n );\n const moments = useMemo(\n () =>\n config && scope\n ? momentMetrics(config.metrics, scope.fields)\n : NO_MOMENTS,\n [config, scope],\n );\n\n /** Reads the live draft, so several edits in one event compose. */\n const change = useCallback(\n (update: (current: AnalysisViewConfig) => Partial<AnalysisViewConfig>) => {\n if (!runtime) return;\n const current = runtime.getSnapshot().draft;\n if (current.kind !== 'analysis') return;\n runtime.edit(update(current));\n },\n [runtime],\n );\n\n const { reshape, dropped, undone, undoDrop, dismissDrop, metricRemoval } =\n useReshape({ runtime, draft: state?.draft, config, change, fitTo });\n\n const fields = useMemo<AnalysisFieldOption[]>(\n () => (scope ? fieldOptions(scope, runtime?.kinds) : []),\n [scope, runtime],\n );\n\n const dateUnitFor = useCallback(\n (field: AnalysisFieldOption): AnalysisDateUnit => {\n const applied = state?.applied;\n const result = state?.result;\n if (!runtime || !applied || applied.kind === 'dashboard')\n return field.dateUnits[0] ?? 'DAY';\n const { timeZone } = runtime.environment;\n const span =\n rangeSpan(\n applied.filter,\n field.field,\n runtime.environment.now(),\n timeZone,\n ) ??\n (result?.config.kind === 'analysis' && result.data.kind === 'analysis'\n ? resultSpan(\n result.data.view.rows,\n result.config.groups,\n field.field,\n timeZone,\n )\n : null);\n return recommendDateUnit(span, field.dateUnits);\n },\n [runtime, state],\n );\n\n const groups = config?.groups ?? [];\n const metrics = config?.metrics ?? [];\n const elements = useMemo(() => config?.elements ?? [], [config?.elements]);\n const elementLabel = useCallback(\n (index: number): string =>\n scope && definition ? levelLabel(definition, scope, index) : '',\n [scope, definition],\n );\n const expandable = useMemo(\n () =>\n scope && definition\n ? (nextLevel(definition, scope, elements) ?? null)\n : null,\n [scope, definition, elements],\n );\n const rescope = useCallback(\n (next: AnalysisElement[], cause: DropCause) =>\n reshape(\n current =>\n definition && capability\n ? withElements(current, next, definition, capability)\n : undefined,\n cause,\n ),\n [reshape, definition, capability],\n );\n const conditionFields = useMemo<FieldDefinition[]>(() => {\n if (!scope || !runtime) return [];\n return [...scope.fields.values()].filter((field: FieldDefinition) => {\n const kind = runtime.kinds.get(field.kind);\n return (\n kind !== undefined &&\n kind.scalar !== false &&\n !isFieldlessKind(field.kind, kind) &&\n // The source may keep it out of a metric's condition.\n scope.aggregations.get(field.name)?.inMetricFilter !== false\n );\n });\n }, [scope, runtime]);\n\n const editing = useMemo(\n () => questionEditing({ reshape, edit, scope }),\n [reshape, edit, scope],\n );\n\n return {\n dropped,\n undoDrop,\n undone,\n dismissDrop,\n metricRemoval,\n elements,\n expandable,\n expansible: (scope?.declaredChain.length ?? 0) > 0,\n unit:\n elements.length > 0\n ? elementLabel(elements.length - 1)\n : (definition?.recordNoun ?? null),\n elementLabel,\n elementFields: useCallback(\n // A search asks nothing of an expansion (Wow refuses `SEARCH` in\n // an element's gate), so it is not offered there.\n (index: number) =>\n scope\n ? elementFilterFields(scope, index).filter(\n field => field.kind !== 'search',\n )\n : [],\n [scope],\n ),\n expand: useCallback(\n (path: string) =>\n rescope(withLevel(elements, path), {\n kind: 'expand',\n name:\n expandable?.path === path\n ? expandable.label\n : elementLabel(elements.length),\n }),\n [rescope, elements, expandable, elementLabel],\n ),\n collapse: useCallback(\n (index: number) =>\n rescope(withoutLevelsFrom(elements, index), {\n kind: 'collapse',\n name: elementLabel(index),\n }),\n [rescope, elements, elementLabel],\n ),\n setElementFilter: useCallback(\n (index: number, filter: FilterTree | undefined) =>\n change(current => ({\n elements: (current.elements ?? []).map((element, at) =>\n at !== index\n ? element\n : filter === undefined\n ? { path: element.path }\n : { ...element, filter },\n ),\n })),\n [change],\n ),\n groups,\n metrics,\n sort: config?.sort ?? [],\n limit: config?.limit ?? 0,\n limitBounds: useMemo(\n () =>\n capability && runtime\n ? limitBounds(capability, runtime.limits)\n : NO_LIMIT_BOUNDS,\n [capability, runtime],\n ),\n layout: config?.layout ?? 'table',\n chart: config?.chart ?? EMPTY_CHART,\n totals: config?.table.totals === true,\n issues: (state?.issues ?? []).filter(\n found =>\n found.code.startsWith('analysis.') || found.code.startsWith('chart.'),\n ),\n aliases: {\n groups: groups.map(group => group.alias),\n metrics: metrics.map(metric => metric.alias),\n },\n moments,\n fields,\n fieldGroups: definition?.fieldGroups ?? EMPTY_GROUPS,\n countable: capability?.count === true,\n stale: state ? autoApplyDue(state) || answeringAnew(state) : false,\n havingAllowed: capability?.having === true,\n expressionsAllowed: capability?.expressions === true,\n havingMetrics: capability?.havingMetrics ?? null,\n firstLastOrderBy: capability?.firstLastOrderBy ?? null,\n dateDiffUnits: dateDiffUnitsOf(capability),\n metricSortAllowed: capability?.metricSort !== false,\n denseAllowed: capability?.dense !== false,\n approximate: approximateMetrics(capability),\n having: havingRows(config?.having),\n ranHaving:\n state?.result?.config.kind === 'analysis'\n ? state.result.config.having\n : undefined,\n conditionFields,\n kinds: runtime?.kinds,\n ...(runtime ? { optionSource: runtime.optionSource.bind(runtime) } : {}),\n dateUnitFor,\n pending: state\n ? comparePending(state.draft, state.applied, state.issues).pending\n : false,\n\n ...editing,\n setSort: useCallback((sort: AnalysisSort[]) => edit({ sort }), [edit]),\n sortNow: useCallback(\n (sort: AnalysisSort[]) => {\n if (!runtime) return false;\n const { draft, applied, issues } = runtime.getSnapshot();\n if (draft.kind !== 'analysis' || applied.kind !== 'analysis')\n return false;\n // What waits besides the sort: a sort edited in the tray and not\n // yet run — which this one replaces — does not hold it back. The\n // record table's writes keep the same rule (`pendingBesides`).\n const others = pendingBesides({ draft, applied, issues }, { sort });\n runtime.edit({ sort });\n if (others) return false;\n runtime.apply();\n return true;\n },\n [runtime],\n ),\n setLimit: useCallback((limit: number) => edit({ limit }), [edit]),\n // A redraw, not a run: the result's rows are drawn as a table or as a\n // chart from the same answer (`ANALYSIS_PRESENTATION_MEMBERS`). Under\n // the table the chart is not judged (D20), so the one it saved may name\n // slots of an older shape; turning to it fits it to the shape in force,\n // which keeps every slot that still names something. A shape no chart\n // draws is drawn as the table, and the kernel says so (`chart.as-table`).\n setLayout: useCallback(\n (layout: AnalysisViewConfig['layout']) =>\n change(current =>\n layout === 'chart' && current.layout !== 'chart'\n ? { layout, chart: fitTo(current.chart, current) }\n : { layout },\n ),\n [change, fitTo],\n ),\n setChartType: useCallback(\n (type: ChartType) =>\n // The new type's family sub-object is built from the groups and\n // metrics in force, because a type without one is `chart.family.missing`\n // and draws nothing; every other family is carried over, so switching\n // type and back returns to the settings that family had.\n change(current => ({\n chart: fitTo(switchChartType(current.chart, type), current),\n })),\n [change, fitTo],\n ),\n updateChart: useCallback(\n // A member given as `undefined` is taken out, as `edit` takes out a\n // config's: the value labels set back to 「自动」 left the view\n // unsaved otherwise.\n (patch: Partial<ChartSpec>) =>\n change(current => ({ chart: overlaid(current.chart, patch) })),\n [change],\n ),\n setTotals: useCallback(\n (totals: boolean) =>\n change(current => ({ table: { ...current.table, totals } })),\n [change],\n ),\n submit: useCallback(() => runtime?.apply(), [runtime]),\n focus: useCallback(() => runtime?.setEditing(true), [runtime]),\n blur: useCallback(() => runtime?.setEditing(false), [runtime]),\n };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useMemo } from 'react';\nimport {\n drillGroups,\n fitChartSlots,\n fitCharts,\n focusOn,\n groupFor,\n groupableFields,\n measureColumns,\n momentColumns,\n asksForWhole,\n projectAnalysis,\n shapeChart,\n splitBy,\n switchChartType,\n withStagesFrom,\n type AnalysisColumnView,\n type AnalysisProjection,\n type ChartData,\n type ChartFit,\n type Picked,\n} from '../analysis/index.js';\nimport {\n drillGap,\n drillRecordConditions,\n drillSpan,\n drilledFields,\n} from '../analysis/drill.js';\nimport { foldsSplit } from '../analysis/splitOther.js';\nimport { describeFilter, type FilterSummaryItem } from '../filter/index.js';\nimport type {\n AnalysisGroup,\n AnalysisViewConfig,\n ChartSpec,\n ChartType,\n FilterNode,\n RecordData,\n} from '../model/index.js';\nimport { hasAsked, type ViewRuntime } from '../runtime/index.js';\nimport type { AnalysisFieldOption } from './analysisFields.js';\nimport type { AnalysisEditorController } from './useAnalysisEditor.js';\nimport type { WorkbenchController } from './useWorkbench.js';\n\n/** Stable identity for \"nothing asked yet\", so the memos below stay quiet. */\nconst NO_COLUMNS: readonly AnalysisColumnView[] = [];\n\n/** A dimension a group can be split by: a field the result is not grouped on. */\nexport interface SplitOption {\n field: string;\n label: string;\n}\n\n/**\n * One thing the follow-up menu offers on a group (D20 追问). The menu draws\n * each kind its own way — an icon and a word are a host's to choose — and\n * runs it; which kinds are offered, in what order, and what running one\n * does are decided here, so a new follow-up is a new member of this union\n * and one more entry in `followUp`, not another pair of props on the menu.\n */\nexport type FollowUpAction =\n /**\n * Open the records behind the group, in a record view of their own. The\n * view is named `title`: wording, so the menu says it — of `subject`, the\n * definition's name for its records, and the group.\n *\n * With `gap`, offered and greyed with the reason it cannot run (D38): a\n * group counted over elements of elements, which no condition over the\n * records reaches (`drillGap`) — the menu says so rather than leave the\n * reader to wonder where 「查看这些记录」 went — and `run` does nothing.\n */\n | {\n kind: 'records';\n subject: string;\n run(title: string): void;\n gap?: 'nested-elements';\n }\n /**\n * Ask the same question of the group by another dimension, as a view of\n * its own beside this one (`WorkbenchController.follow`), as `focus`\n * does. Named `title`, of `subject` — this view's name — and the group.\n */\n | {\n kind: 'split';\n subject: string;\n options: readonly SplitOption[];\n run(field: string, title: string): void;\n }\n /**\n * Ask the same question of the group alone, as a view of its own beside\n * this one (`WorkbenchController.follow`), so the way back is this result\n * as it stands. Named `title`, of `subject` — this view's name — and the\n * group.\n */\n | { kind: 'focus'; subject: string; run(title: string): void }\n /**\n * Set a board's filter to the stretch of time the menu is about (D33\n * Q52): offered on a dashboard panel only, over a span, for each date\n * filter wired to the field it spans. The panel it was set from keeps\n * every group, as a press that sets a filter leaves it (D23 Q18). `filter`\n * is that filter's label, for the item to name it by.\n */\n | { kind: 'filter'; filter: string; run(): void };\n\n/** One dimension of the group pressed, for the menu to name it by. */\nexport interface FollowUpGroup {\n /**\n * The conditions that select it, as the applied bar names them — a date\n * bucket's range as its period, a number band's two comparisons as the\n * one segment they bound — so the menu, the name of a view opened from it\n * and that view's applied bar say one sentence.\n */\n conditions: readonly FilterSummaryItem[];\n}\n\n/** What the menu over one pressed group shows. */\nexport interface FollowUp {\n /** The group, one dimension each, in the order the result is grouped. */\n groups: readonly FollowUpGroup[];\n actions: readonly FollowUpAction[];\n}\n\nexport interface AnalysisResultController {\n /** The rows on screen, or null while there are none of an analysis. */\n view: AnalysisProjection | null;\n /** The config those rows ran on: what a chart and a follow-up address. */\n ran: AnalysisViewConfig | undefined;\n /**\n * The question the result answers or will answer: `ran` once rows are on\n * screen; before any are, the config on its way or the one that failed.\n * Undefined while nothing has been asked (`hasAsked`). What the rows are\n * *shaped* by — the reading, the chart types that fit, the slots a chart\n * can name — is known from the moment the question is sent, so the\n * toolbar and the visualization panel work while the first answer is on\n * its way and after it failed; only what needs the rows waits for them.\n */\n question: AnalysisViewConfig | undefined;\n /**\n * Every column of that question, as the result names them — the rows' own\n * schema, or the same projection over no rows while none have landed —\n * and the ones the table draws, in its order (`AnalysisProjection.columns`).\n * Both empty while nothing has been asked. The toolbar reads the first\n * out; a skeleton standing in for the table draws a bar per the second.\n */\n columns: readonly AnalysisColumnView[];\n tableColumns: readonly AnalysisColumnView[];\n /** The chart drawn over those rows, as the draft says to draw it. */\n chart: ChartSpec;\n /** The rows shaped for `chart`, or undefined while there is nothing to draw. */\n chartData: ChartData | undefined;\n /**\n * Which chart types the question's shape can draw, its rows included once\n * there are any (`fitCharts`); before anything was asked, the draft's\n * shape and the stages its chart names.\n */\n fits: Record<ChartType, ChartFit>;\n /** What the visualization panel shows as chosen. */\n picked: Picked;\n /**\n * Draw the rows as this type, or as the table. Over a question — rows on\n * screen, the first answer on its way, or a query that failed — it\n * redraws and never runs; with none asked — a saved chart refused, so\n * nothing ran — it fits the type to the draft's shape and runs (`repair`).\n */\n choose(next: Picked): void;\n /**\n * Whether a group of this result can be followed up at all. Over one\n * level of expanded elements its records are asked of one element (D38);\n * over elements of elements the menu opens and says why it cannot; over\n * an array the definition lets no condition match into, not at all.\n */\n pickable: boolean;\n /**\n * The menu over one pressed group, or null when no condition can say it.\n * With `through`, over a span instead (D33 Q52): every bucket of a time\n * axis from `row`'s to `through`'s, read as one range (`drillSpan`) — a\n * brush along the axis, or a second row picked with Shift in the table.\n */\n followUp(row: RecordData, through?: RecordData): FollowUp | null;\n}\n\n/**\n * The analysis result as a host draws it (phase-2 review, developer #9):\n * which rows, which chart over them, what the picker offers, and what a\n * press on one group can do next. Everything here reads a kernel and writes\n * the runtime; the component that draws it keeps only what is about the\n * screen — which panel is open, where the keyboard is, which mark was\n * pressed and where. `/ui` consumes this and nothing below it, which is\n * the contract its entry states.\n *\n * **The rows are the config that ran; how they are looked at is the\n * draft.** A result's rows and columns come from the config it was shaped\n * by, and nothing else can name them. The layout and the chart are\n * presentation (D20, `ANALYSIS_PRESENTATION_MEMBERS`): drawn from those\n * rows as the draft says, so switching to a chart or picking another type\n * redraws without a run. The draft's chart is fitted to the shape that ran\n * **only while the two shapes differ** — a dimension added in the tray but\n * not yet run is no column of these rows — because `fitChartSlots` opens a\n * narrowed slot back up, which is right when the shape moved under the\n * chart and wrong on every render of a chart narrowed on purpose.\n *\n * A follow-up is read off the same config the rows ran on, not the draft:\n * the group pressed is a group of that result, not of what is being edited.\n */\nexport function useAnalysisResult(\n runtime: ViewRuntime<AnalysisViewConfig> | null,\n analysis: AnalysisEditorController,\n workbench: Pick<\n WorkbenchController,\n 'state' | 'canDrill' | 'drill' | 'follow'\n >,\n): AnalysisResultController {\n const result = workbench.state?.result;\n const data = result?.data;\n const view: AnalysisProjection | null =\n data?.kind === 'analysis' ? data.view : null;\n const ran = result?.config.kind === 'analysis' ? result.config : undefined;\n // Before the first answer, the question itself. A query that was sent was\n // admitted, so the applied config is one the kernel can project; a config\n // refused before it ran was never asked, and stays undefined.\n const state = workbench.state;\n const applied = state?.applied;\n const asked =\n !ran && hasAsked(state) && applied?.kind === 'analysis'\n ? applied\n : undefined;\n const question = ran ?? asked;\n const definition = runtime?.definition;\n const shape = useMemo<Pick<AnalysisProjection, 'columns' | 'schema'> | null>(\n () =>\n view ??\n (asked && definition\n ? // Over no rows and as a table: the columns are all that is\n // wanted, and a chart shaped from nothing is work for no one.\n projectAnalysis(definition, { ...asked, layout: 'table' }, [])\n : null),\n [view, asked, definition],\n );\n const columns = shape ? (shape.schema ?? shape.columns) : NO_COLUMNS;\n const tableColumns = shape?.columns ?? NO_COLUMNS;\n\n const drafted = shapeKey(analysis.aliases.groups, analysis.aliases.metrics);\n const shapeAsked = question\n ? shapeKey(\n question.groups.map(group => group.alias),\n question.metrics.map(metric => metric.alias),\n )\n : null;\n // The moments of the question, read off its projection: a column that\n // reads as a date is one (`momentMetrics`), and no mark measures it.\n const moments = useMemo(() => momentColumns(columns), [columns]);\n // And what each measures (`metricMeasure`), so a combo picked here puts a\n // count and an amount on two axes as the editor would.\n const measures = useMemo(() => measureColumns(columns), [columns]);\n const chart = useMemo(\n () =>\n question && shapeAsked !== drafted\n ? fitChartSlots(\n analysis.chart,\n question.groups,\n question.metrics,\n moments,\n measures,\n )\n : analysis.chart,\n [analysis.chart, question, shapeAsked, drafted, moments, measures],\n );\n // What the picker offers. Over rows, the shape that ran and the rows\n // themselves: a funnel over one dimension takes its stages from them the\n // moment it is picked (`withStagesFrom`), so only they say whether it has\n // the two it needs. Before anything ran — a saved view whose chart is\n // refused runs nothing — the draft's shape, and the stages its chart\n // already names: picking from there is how such a view is repaired.\n const fits = useMemo(\n () =>\n question\n ? fitCharts({\n groups: question.groups,\n metrics: question.metrics,\n moments,\n steps: stepsOf(question.groups, analysis.fields),\n ...(view ? { rows: view.rows } : {}),\n })\n : fitCharts({\n groups: analysis.groups,\n metrics: analysis.metrics,\n moments: analysis.moments,\n steps: stepsOf(analysis.groups, analysis.fields),\n chart: analysis.chart,\n }),\n [\n question,\n view,\n moments,\n analysis.groups,\n analysis.metrics,\n analysis.moments,\n analysis.chart,\n analysis.fields,\n ],\n );\n // A chart the question's shape cannot draw — every metric a moment,\n // nothing to measure — is its table: the rows are there, and an empty\n // frame would say there were none. Before anything was asked there is no\n // shape to judge.\n const drawable = !question || fits[chart.type]?.available !== false;\n // Shaped as the runtime shaped it (`projectAnalysis`): day buckets stepped\n // in the engine's zone rather than the browser's, and a trend card's last\n // period the last one over when the question was asked — which is when\n // its answer arrived, less the time it took.\n const timeZone = runtime?.environment.timeZone;\n const askedAt = result ? result.receivedAt - result.elapsedMs : undefined;\n const chartData = useMemo(\n () =>\n view && ran && drawable\n ? shapeChart(\n { ...ran, chart, layout: 'chart' },\n view.rows,\n view.overall,\n {\n ...(timeZone === undefined ? {} : { timeZone }),\n ...(askedAt === undefined ? {} : { now: new Date(askedAt) }),\n cutShort: view.truncated || view.atLimit !== undefined,\n ...(view.splitWhole ? { splitWhole: view.splitWhole } : {}),\n ...(view.approximate ? { approximate: view.approximate } : {}),\n },\n )\n : undefined,\n [view, ran, chart, drawable, timeZone, askedAt],\n );\n const picked: Picked =\n analysis.layout === 'table' || !drawable ? 'table' : chart.type;\n\n // A chart that headlines the whole — a metric card over a trend — is one\n // the rows cannot draw alone: the buckets are only the groups that fit the\n // limit (`asksForWhole`). Picked over rows that ran without the whole, it\n // runs once, as the totals switch does. Not while the draft holds another\n // edit waiting for Apply — running would apply that too, which is not this\n // gesture's to do; the card adds up its buckets until then — and never\n // again for a config that asked and did not get it, which is a failed\n // query and not a missing question.\n const { submit, pending } = analysis;\n const wantsWhole =\n ran !== undefined &&\n analysis.layout === 'chart' &&\n drawable &&\n !asksForWhole(ran) &&\n asksForWhole({ ...ran, chart });\n // So does a split picked past the palette over rows that ran without its\n // axis's whole: its rest is folded into 「其他」 against that (D33 Q56).\n const wantsSplitWhole =\n view !== null &&\n ran !== undefined &&\n analysis.layout === 'chart' &&\n drawable &&\n !foldsSplit(ran, view.rows) &&\n foldsSplit({ ...ran, chart }, view.rows);\n useEffect(() => {\n if ((wantsWhole || wantsSplitWhole) && !pending) submit();\n }, [wantsWhole, wantsSplitWhole, pending, submit]);\n\n const choose = (next: Picked) => {\n // Nothing asked — a saved chart refused, so nothing ran — is a repair.\n // A question on its way or one that failed is not: its shape is known,\n // and a pick redraws over it as it would over rows.\n if (!question) {\n repair(analysis, next);\n return;\n }\n if (next === 'table') {\n analysis.setLayout('table');\n return;\n }\n analysis.setLayout('chart');\n // Fitted to the question's shape, so a type picked while the first\n // answer is on its way — or after it failed — is the chart the rows\n // land in; and a funnel of a group's values given the order they came\n // in, once there are rows to take it from.\n const fitted = fitChartSlots(\n switchChartType(chart, next),\n question.groups,\n question.metrics,\n moments,\n measures,\n );\n analysis.updateChart(view ? withStagesFrom(fitted, view.rows) : fitted);\n };\n\n // Over expanded elements a group names an element, and the records behind\n // it are the ones with such an element (D38): one level can say that, a\n // deeper chain cannot and says so, an array no condition matches into\n // offers nothing.\n const expanded = (ran?.elements?.length ?? 0) > 0;\n const gap = ran && drillGap(ran);\n const pickable =\n ran !== undefined &&\n runtime !== null &&\n (!expanded ||\n gap !== undefined ||\n drillRecordConditions(ran, runtime.fields, runtime.kinds, []) !== null);\n\n const followUp = (row: RecordData, through?: RecordData): FollowUp | null => {\n if (!pickable || !ran || !runtime) return null;\n const context = { timeZone: runtime.environment.timeZone };\n const drilled = through\n ? drillSpan(ran, runtime.fields, runtime.kinds, row, through, context)\n : drillGroups(ran, runtime.fields, runtime.kinds, row, context);\n if (!drilled) return null;\n const conditions =\n drillRecordConditions(ran, runtime.fields, runtime.kinds, drilled) ?? [];\n const actions: FollowUpAction[] = [];\n // Each view opened is named by its subject and the group, and called\n // by its subject alone once the reader takes the group off it.\n if (workbench.canDrill) {\n const records = runtime.definition.title;\n actions.push(\n gap\n ? { kind: 'records', subject: records, gap, run: () => {} }\n : {\n kind: 'records',\n subject: records,\n run: title => workbench.drill(conditions, title, records),\n },\n );\n }\n // The group named as the menu heads it, by the fields its conditions\n // name: the root's, or the counted element's.\n const named = [...(drilledFields(ran, runtime.fields)?.values() ?? [])];\n const heading = drilled.map(entry => ({\n conditions: describeFilter(\n named,\n { op: 'and', children: entry.conditions },\n runtime.kinds,\n ),\n }));\n // Over elements only the records: 「只显示这一组」 and 「按…拆开」 would\n // narrow the range the elements are counted under, which is the\n // expansion's gate and not the view's conditions — not offered yet.\n if (expanded)\n return actions.length > 0 ? { groups: heading, actions } : null;\n // Groupable fields the result is not already grouped by — the list the\n // tray adds a dimension from (`groupableFields`) — read off the config\n // that ran, for the reason the conditions are.\n const options: SplitOption[] = groupableFields(\n analysis.fields,\n ran.groups,\n ).map(option => ({ field: option.field, label: option.label }));\n // Both open beside this view: the question that ran, drawn as the screen\n // draws it — the layout and the chart are the draft's, and nothing else\n // the draft holds is applied by a gesture that did not ask for it.\n const drawn: AnalysisViewConfig = {\n ...ran,\n layout: analysis.layout,\n chart,\n };\n const subject = workbench.state?.title ?? '';\n if (options.length > 0)\n actions.push({\n kind: 'split',\n subject,\n options,\n run: (name, title) => {\n const patch = split(\n runtime,\n analysis,\n drawn,\n conditions,\n name,\n moments,\n );\n if (patch)\n workbench.follow(\n { ...drawn, ...patch },\n title,\n conditions,\n subject,\n );\n },\n });\n actions.push({\n kind: 'focus',\n subject,\n run: title =>\n workbench.follow(\n { ...drawn, ...focusOn(ran, conditions) },\n title,\n conditions,\n subject,\n ),\n });\n return { groups: heading, actions };\n };\n\n return {\n view,\n ran,\n question,\n columns,\n tableColumns,\n chart,\n chartData,\n fits,\n picked,\n choose,\n pickable,\n followUp,\n };\n}\n\n/**\n * A pick with no rows on screen. Nothing has run — most often because the\n * saved chart is refused (a funnel of one stage, or of averages), and a\n * refused config never runs — so there is nothing to redraw: the pick is\n * fitted to the shape of the draft (`setChartType`), which makes the config\n * one that validates, and then it runs.\n *\n * The table is always a way out, and needs nothing else: under the table\n * the chart is not judged (D20, `validateAnalysis`), so the refused chart\n * stays as it was saved and the table runs. The run is left to Apply while\n * the draft holds another edit, as a chart that asks for the whole is\n * (`wantsWhole`): running would apply that too, which is not this gesture's\n * to do.\n */\nfunction repair(analysis: AnalysisEditorController, next: Picked): void {\n if (next === 'table') analysis.setLayout('table');\n else {\n analysis.setLayout('chart');\n analysis.setChartType(next);\n }\n if (!analysis.pending) analysis.submit();\n}\n\n/**\n * The patch that asks `config` of the group by the field named, or null\n * where the field is not one to split by. The chart's slots follow the new\n * shape; the metrics do not change, so neither do the moments among them.\n */\nfunction split(\n runtime: ViewRuntime<AnalysisViewConfig>,\n analysis: AnalysisEditorController,\n config: AnalysisViewConfig,\n conditions: readonly FilterNode[],\n name: string,\n moments: ReadonlySet<string>,\n): ReturnType<typeof splitBy> | null {\n const field = runtime.fields.find(entry => entry.name === name);\n const option = analysis.fields.find(entry => entry.field === name);\n if (!field || !option) return null;\n return splitBy(\n config,\n conditions,\n groupFor(field, option, runtime.kinds.get(field.kind)),\n moments,\n );\n}\n\n/**\n * One shape as the one string a chart addresses it by: a chart names groups\n * and metrics by alias and by nothing else, so two shapes that spell the\n * same aliases in the same order are one shape as far as its slots go. The\n * separators are control characters no alias can hold, written as escapes:\n * a raw one in the source makes every text tool read the file as binary.\n */\nfunction shapeKey(groups: readonly string[], metrics: readonly string[]) {\n return `${groups.join('\\u0000')}\\u0001${metrics.join('\\u0000')}`;\n}\n\n/**\n * The dimensions, by alias, whose field the definition declares the steps of\n * one process (`AggregationFieldCapability.steps`): a funnel is offered as\n * fitting over these alone.\n */\nfunction stepsOf(\n groups: readonly AnalysisGroup[],\n fields: readonly AnalysisFieldOption[],\n): ReadonlySet<string> {\n const declared = new Set(\n fields.filter(field => field.steps).map(field => field.field),\n );\n return new Set(\n groups\n .filter(group => declared.has(group.field ?? ''))\n .map(group => group.alias),\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n useCallback,\n useEffect,\n useMemo,\n useState,\n useSyncExternalStore,\n} from 'react';\nimport type {\n RefreshConfig,\n RuntimeLimits,\n ViewConfig,\n} from '../model/index.js';\nimport type {\n DashboardRuntime,\n ViewRuntime,\n ViewRuntimeState,\n} from '../runtime/index.js';\nimport { listenerSet } from '../runtime/listeners.js';\nimport { refreshIntervalOf } from '../runtime/refreshTimer.js';\nimport { useViewRuntime } from './useViewEngine.js';\n\n// The ladder itself is the engine's (`RuntimeLimits.refreshIntervals`, with\n// the reasoning for its three rungs); this hook only cuts it to the bounds\n// and folds in the interval a view is saved at.\n\n/** How often the countdown redraws while a timer is armed. */\nconst TICK_MS = 1000;\n\n/** Stable identity for \"no runtime, nothing on offer\". */\nconst NO_INTERVALS: readonly number[] = [];\n\n/**\n * Whether the kernel would run this many seconds: a whole number inside the\n * budget.\n *\n * `validateRefresh` refuses a fractional interval as surely as one out of\n * range (`config.refresh.not-an-integer`), so both are the same answer here.\n * An interval that fails this is one the timer will never use — offering it\n * would offer a config that cannot run, and saying it would name a cadence\n * nothing keeps.\n */\nfunction runnable(\n seconds: number | null,\n limits: RuntimeLimits | undefined,\n): seconds is number {\n return (\n seconds !== null &&\n limits !== undefined &&\n Number.isInteger(seconds) &&\n seconds >= limits.minRefreshInterval &&\n seconds <= limits.maxRefreshInterval\n );\n}\n\n/**\n * How often this view renews its own answer, and the way to run one now.\n *\n * There is no state here beside the config: the interval *is*\n * `ViewConfigBase.refresh.interval`, saved with the view and read by the\n * runtime's one timer. A control that kept its own copy would give the saved\n * config, the timer and the screen three opinions about the same number. The\n * two numbers below are one member read at its two ages — what is running\n * and what is set — not two states.\n */\nexport interface RefreshController {\n /**\n * The interval **in force**: seconds between automatic refreshes, or\n * `null` when the view does not refresh itself.\n *\n * It is `applied`'s, because that is the one the runtime's timer reads. A\n * credential about what is happening has to answer to what is happening —\n * the same reason `AppliedBar` describes the result rather than the draft.\n * Choosing an interval edits and applies in one gesture, so this and\n * {@link chosen} agree except while a draft the kernel refuses holds\n * `apply` back, and then it is this one that is true.\n *\n * A stored value the kernel would refuse — fractional, or outside the\n * budget — reads as `null` rather than as itself: the timer will never use\n * it (an `applied` the kernel refuses can only come from a draft it\n * refuses, which is already holding the timer), so naming it would promise\n * a cadence nothing keeps. The refusal is the strip's to report.\n */\n interval: number | null;\n /**\n * What the view is **set** to: the draft's interval, which is what a save\n * would write and what the menu marks as picked.\n *\n * It is the editor's value, like the layout or the page size, and it is\n * kept apart from {@link interval} rather than folded into it because one\n * mark saying two things is how a credential starts lying. When they\n * differ, the draft is refused and the strip above the result says so.\n */\n chosen: number | null;\n /**\n * The intervals on offer, ascending, already cut to what\n * `RuntimeLimits.minRefreshInterval` and `maxRefreshInterval` admit. An\n * interval the limits refuse is absent rather than disabled (D4), so an\n * empty list means this view has no interval to choose and a control over\n * it has nothing to open.\n */\n intervals: readonly number[];\n /**\n * Whether admission has something to say about this view's `refresh`\n * member: missing, not an object, or an interval that is not a whole\n * number of seconds in range.\n *\n * A control reads it to know it still has work to do when it has nothing\n * to offer. Turning refresh **off** writes `{ interval: null }`, which is\n * the repair for every one of those refusals, so a menu that hid itself\n * because the limits left no rung would strand the user on a config that\n * blocks Apply and Save with no control on screen able to mend it — the\n * package's own rule is that a reported error is always reachable.\n */\n unsound: boolean;\n /**\n * Writes `refresh.interval` and applies it, the way a sort or a column\n * change does: without the apply the runtime's timer, which reads\n * `applied`, would never hear about it.\n */\n setInterval(interval: number | null): void;\n /** One refresh, now. Unchanged by any of the above. */\n now(): void;\n /** True while a query of this view is in flight. */\n loading: boolean;\n /**\n * When the next automatic refresh is due, on the runtime's clock, or `null`\n * while no timer is armed — the interval is off, or the runtime is holding\n * the timer for one of its four reasons.\n *\n * It is the runtime's `nextRefreshAt`, handed on as it stands. A control\n * counts down to it; it does not count for itself, because a second clock\n * beside the timer's is a second opinion about when the data will move.\n */\n dueAt: number | null;\n /**\n * Whole seconds from now until {@link dueAt}, read against the runtime's\n * own clock, or `null` when nothing is armed. Never negative: a timer that\n * is late is at zero, not behind.\n *\n * A function rather than a number, because it answers \"now\", and the\n * controller is built once per render while a countdown asks once a second.\n * {@link useRefreshCountdown} is what asks.\n */\n remaining(): number | null;\n}\n\n/**\n * The auto-refresh of one open view, as a control can offer it.\n *\n * The runtime decides when the timer runs and when it pauses — an invalid\n * draft, an editor with focus, a hidden page, a request in flight — and this\n * adds no rule of its own. All it does is make the interval reachable.\n */\nexport function useAutoRefresh(\n runtime: ViewRuntime<ViewConfig> | null,\n): RefreshController {\n const state = useViewRuntime(runtime);\n // A dashboard's reader may keep an interval of their own for this opening\n // (D26 Q35): it is the one in force and the one the menu marks, and the\n // board's own stays in its draft, untouched.\n const own = readerRefresh(runtime, state);\n // Both read through the runtime's own reading of the member: a config\n // arrives from a store, and neither \"what the timer uses\" nor \"what a save\n // would write\" may throw on the way to the screen.\n const applied = state\n ? refreshIntervalOf(own ? { refresh: own } : state.applied)\n : null;\n const chosen = state\n ? refreshIntervalOf(own ? { refresh: own } : state.draft)\n : null;\n const limits = runtime?.limits;\n\n return {\n interval: runnable(applied, limits) ? applied : null,\n chosen,\n // Every admission finding about this member, whatever its code: missing,\n // fractional, too short, too long. Read off `issues` rather than judged\n // again here, so the control and the kernel cannot come to different\n // conclusions about the same config.\n unsound: (state?.issues ?? []).some(found => found.path[0] === 'refresh'),\n intervals: useMemo(() => {\n if (!limits) return NO_INTERVALS;\n // What is picked joins the ladder when the kernel would run it: a view\n // saved at 45 seconds has to offer the rung it is sitting on, or the\n // menu would show nothing marked. One the kernel refuses does not —\n // that config is already refused, said in the strip above the result,\n // and the way out of it is a rung that works or Off, not the number\n // that broke. The ladder answers to the draft rather than to what is\n // in force, because the ladder is what the menu marks.\n const offered = limits.refreshIntervals.filter(seconds =>\n runnable(seconds, limits),\n );\n if (runnable(chosen, limits)) offered.push(chosen);\n return [...new Set(offered)].sort((left, right) => left - right);\n }, [chosen, limits]),\n setInterval: useCallback(\n (next: number | null) => {\n if (!runtime) return;\n // A dashboard says whose interval it is: the board's while it is\n // built, this reader's while it is read (D26 Q35).\n if (runtime.kind === 'dashboard') {\n (runtime as unknown as DashboardRuntime).setRefreshInterval(next);\n return;\n }\n runtime.edit({ refresh: { interval: next } });\n runtime.apply();\n },\n [runtime],\n ),\n now: useCallback(() => runtime?.refresh(), [runtime]),\n loading: state?.query.status === 'loading',\n dueAt: state?.nextRefreshAt ?? null,\n // Stable per runtime, so a ticker can depend on it without restarting on\n // every render of the surface around it. It reads the snapshot at call\n // time rather than the one this render closed over, because a countdown\n // asks between renders.\n remaining: useCallback(() => {\n if (!runtime) return null;\n const due = runtime.getSnapshot().nextRefreshAt;\n if (due === null) return null;\n const left = due - runtime.environment.now().getTime();\n return Math.max(0, Math.ceil(left / 1000));\n }, [runtime]),\n };\n}\n\n/** The interval a dashboard's reader chose for this opening, if any. */\nfunction readerRefresh(\n runtime: ViewRuntime<ViewConfig> | null,\n state: ViewRuntimeState<ViewConfig> | null,\n): RefreshConfig | null {\n if (runtime?.kind !== 'dashboard' || !state) return null;\n return (\n (state as { readerRefresh?: RefreshConfig | null }).readerRefresh ?? null\n );\n}\n\n/**\n * Whole seconds until the next automatic refresh, redrawn once a second.\n *\n * The ticker is a pulse, not a measurement: every reading comes from the\n * runtime's due time against the runtime's clock, so a tick that arrives\n * late, early or not at all changes when the number is redrawn and never\n * what it says. It runs only while a timer is armed — no interval, or a\n * runtime holding its timer, means no ticker — and only while the component\n * asking is mounted, which is the control that draws the count and not the\n * workbench around it: a view re-rendering its whole result once a second to\n * move one digit is the cost this hook exists to keep out of the table.\n */\nexport function useRefreshCountdown(refresh: RefreshController): number | null {\n const { dueAt, remaining } = refresh;\n // Read once as the store is built, so the control never paints one frame\n // of the cadence on its way to the count.\n const ticker = useState(() =>\n countdownStore(dueAt === null ? null : remaining()),\n )[0];\n useEffect(() => {\n ticker.set(dueAt === null ? null : remaining());\n if (dueAt === null) return;\n const tick = setInterval(() => ticker.set(remaining()), TICK_MS);\n return () => clearInterval(tick);\n }, [dueAt, remaining, ticker]);\n return useSyncExternalStore(ticker.subscribe, ticker.get, ticker.get);\n}\n\n/**\n * The seconds left, as a store the ticker writes and React reads.\n *\n * A reading is made by a timer, which belongs in an effect, and shown on\n * screen, which needs a render. `setState` from an effect body is the\n * cascading-render pattern `react-hooks` refuses; a store the effect writes\n * and `useSyncExternalStore` subscribes to is the shape it points at instead\n * — the same one `useOpenView` keeps its refusals in, and the one every\n * runtime in this package already has, down to the `listenerSet` that does\n * the subscribing and the telling.\n */\nfunction countdownStore(initial: number | null) {\n let seconds = initial;\n const listeners = listenerSet();\n return {\n get: (): number | null => seconds,\n set(next: number | null): void {\n if (seconds === next) return;\n seconds = next;\n listeners.emit();\n },\n subscribe: listeners.subscribe,\n };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport type { RecordKey } from '../model/index.js';\nimport {\n ABANDONED,\n ActionRefusedError,\n FAILED,\n TIMED_OUT,\n UNAVAILABLE,\n} from '../runtime/actions.js';\nimport { isCalledOff } from '../runtime/failures.js';\nimport { sourceFailure, type SourceFailure } from '../runtime/sourceReason.js';\n\n/**\n * One command over records, as the surface's runner takes it — a declared\n * action's, or a host's own from a slot (`run` on a slot's context): what it\n * is called, and what it does to one record. `each` resolves when the record\n * took the command and throws when it did not; what it throws is read for\n * the source's own reason (`sourceReason`), so a host passes the error on\n * rather than wording it — and an action's own refusal keeps its reason as\n * written, a key said where it is shown.\n */\nexport interface BulkRun {\n /**\n * Said before the counts: a host with several commands names which ran.\n * A key or words, said where it is shown.\n */\n title: string;\n /** Words said into `title`'s `{name}`s, each itself said first. */\n values?: Readonly<Record<string, string>>;\n each(key: RecordKey): Promise<unknown>;\n /**\n * What the host's `onError` is told the command was\n * (`context.operation`): a declared action's id; `title` by default.\n */\n operation?: string;\n /**\n * How long one record is waited for, in milliseconds; past it the\n * record's outcome is unknown and the run moves on. No deadline by\n * default.\n */\n timeout?: number;\n}\n\n/**\n * One record the command did not take, and the reason why: the source's\n * words, or the action's own refusal as written (a key stays a key).\n */\nexport interface BulkFailure {\n key: RecordKey;\n reason: string;\n}\n\n/** How far a command has come over the records it was handed. */\nexport interface BulkProgress {\n total: number;\n /** Settled either way. */\n done: number;\n failed: number;\n}\n\n/** What one command came to, once every record it started has settled. */\nexport interface BulkOutcome {\n title: string;\n values?: Readonly<Record<string, string>>;\n succeeded: readonly RecordKey[];\n /** Sent, and refused by the source: the source's reason for each. */\n failed: readonly BulkFailure[];\n /**\n * Not sent: the action refused the record when its turn came\n * (`ActionRefusedError`), with the action's reason as written.\n */\n refused: readonly BulkFailure[];\n /**\n * Sent, and nobody knows whether it took: the request timed out, the\n * network went, the action's `timeout` passed, or the reader stopped\n * waiting. Let go of rather than left selected — sent again blind, a\n * refund could be paid twice — to be checked against the refreshed rows.\n */\n unknown: readonly BulkFailure[];\n /** Never started, because the command was stopped. */\n skipped: readonly RecordKey[];\n /**\n * What the run left selected — the failed, the refused and the never\n * started, in the order picked; none for a record's own command.\n */\n kept: readonly RecordKey[];\n}\n\n/**\n * The records a command runs over, and what a command does to them\n * afterwards: the ones still to be dealt with stay selected (`select`), the\n * rest are let go, and the view is read again.\n */\nexport interface BulkSelection {\n keys: readonly RecordKey[];\n /** Absent for a record's own command, which leaves the selection be. */\n select?(keys: readonly RecordKey[]): void;\n refresh(): void;\n}\n\n/** The command in flight on a surface. */\nexport interface BulkRunning {\n title: string;\n values?: Readonly<Record<string, string>>;\n progress: BulkProgress;\n /**\n * Stop was pressed: nothing more starts, and a second press stops waiting\n * for what is under way.\n */\n stopping: boolean;\n}\n\n/** A surface's one runner: its command in flight, and what the last came to. */\nexport interface ActionRunner {\n run(selection: BulkSelection, command: BulkRun): void;\n /**\n * Starts nothing more; what is already in flight settles. Pressed again\n * while stopping, it stops waiting: what is still in flight is reported\n * with an unknown outcome and the run settles at once, so a `run` that\n * never answers cannot hold the surface.\n */\n stop(): void;\n /** The command in flight, or `null`. */\n running: BulkRunning | null;\n outcome: BulkOutcome | null;\n dismiss(): void;\n}\n\n/** Where a failure the runner reports happened. */\nexport interface ActionFailureContext {\n /** The record the command failed, or went unanswered, for. */\n key: RecordKey;\n /** `BulkRun.operation`, else its title. */\n operation: string;\n}\n\nexport interface ActionRunnerOptions {\n /**\n * How many records are in flight at once. A command writes, and a\n * selection of a hundred sent in one burst is a hundred writes landing on\n * one service at once; a handful at a time is quick and polite.\n */\n concurrency?: number;\n /**\n * Told of what a record's command threw — a failure, or a timeout or a\n * lost connection whose outcome is unknown — as it was thrown. Not of an\n * action's own refusal (`ActionRefusedError`) nor of an abort: neither is a\n * failure.\n */\n onError?(error: unknown, context: ActionFailureContext): void;\n}\n\nconst CONCURRENCY = 4;\n\n/** How one record came out. */\ntype Settled =\n { kind: 'done' } | { kind: 'failed' | 'refused' | 'unknown'; reason: string };\n\n/** The names a timeout or a cancelled request is thrown under. */\nconst UNANSWERED = new Set(['AbortError', 'TimeoutError', 'FetchTimeoutError']);\n\n/**\n * Whether a failure leaves the outcome unknown: the request may have\n * reached the service, and no answer came back — a timeout or an abort (by\n * name, on the error or what caused it), a request the network dropped\n * (fetch's `TypeError`), a gateway that gave up waiting (504).\n */\nfunction unanswered(error: unknown, failure: SourceFailure): boolean {\n if (failure.unreachable === true || failure.status === 504) return true;\n let cause: unknown = error;\n for (let depth = 0; depth < 4 && typeof cause === 'object'; depth += 1) {\n if (cause === null) return false;\n const { name } = cause as { name?: unknown };\n if (typeof name === 'string' && UNANSWERED.has(name)) return true;\n cause = (cause as { cause?: unknown }).cause;\n }\n return false;\n}\n\n/** What the source said, never rejecting: a failure read badly says nothing. */\nasync function readSafely(error: unknown): Promise<SourceFailure> {\n try {\n return await sourceFailure(error);\n } catch {\n return { reason: '' };\n }\n}\n\n/**\n * Everything of a bulk command that is not the command itself: records a\n * handful at a time, progress while it runs, a stop that starts nothing\n * more (and, pressed again, stops waiting), each record's deadline, the\n * source's reason for every record that refused, and afterwards a refresh\n * of the page the reader is on with the failed and the unsent rows left\n * selected — they are the rows still to be dealt with. A record whose\n * outcome is unknown is let go: it is checked, not sent again.\n *\n * One command at a time: commands write, so a second press over the same\n * rows is not a newer read that can supersede the first but a second write.\n *\n * It is the engine's, one per record surface (a workbench's record view, a\n * board's record panel): the declared actions run through it\n * (`useRecordActions`), and so does a host's own command from a slot\n * (`run` on the slot's context), so every command on a surface reports on\n * its one line.\n */\nexport function useActionRunner(\n options: ActionRunnerOptions = {},\n): ActionRunner {\n const concurrency = Math.max(\n 1,\n Math.floor(options.concurrency ?? CONCURRENCY),\n );\n // The latest handler, read when a failure lands rather than when the run\n // began: a host that re-renders keeps one runner.\n const onError = useRef(options.onError);\n useEffect(() => {\n onError.current = options.onError;\n });\n const [running, setRunning] = useState<BulkRunning | null>(null);\n const [outcome, setOutcome] = useState<BulkOutcome | null>(null);\n // Refs as well as state: two presses in one frame both see the old state,\n // and the workers read the stop between records, not between renders.\n const busy = useRef(false);\n const stopping = useRef(false);\n const abandon = useRef<(() => void) | null>(null);\n const alive = useRef(true);\n useEffect(() => {\n alive.current = true;\n return () => {\n alive.current = false;\n // The host that asked is gone, and with it the line that said how far\n // the run had come and the way to stop it: nothing more is started.\n // What is under way lands; the service has it already.\n stopping.current = true;\n };\n }, []);\n\n const run = useCallback(\n (selection: BulkSelection, command: BulkRun) => {\n // A run asked for once the host has gone — a handler that outlived\n // it — would have nobody to show it or stop it: nothing is started.\n if (!alive.current) return;\n if (busy.current || selection.keys.length === 0) return;\n const keys = [...selection.keys];\n const succeeded: RecordKey[] = [];\n const failed: BulkFailure[] = [];\n const refused: BulkFailure[] = [];\n const unknown: BulkFailure[] = [];\n const operation = command.operation ?? command.title;\n const timeout = command.timeout;\n let next = 0;\n busy.current = true;\n stopping.current = false;\n // The second Stop: every record still awaited settles as unknown.\n const given = new Promise<Settled>(resolve => {\n abandon.current = () => resolve({ kind: 'unknown', reason: ABANDONED });\n });\n const report = () => {\n if (!alive.current) return;\n setRunning({\n title: command.title,\n ...(command.values ? { values: command.values } : {}),\n progress: {\n total: keys.length,\n done:\n succeeded.length +\n failed.length +\n refused.length +\n unknown.length,\n failed: failed.length,\n },\n stopping: stopping.current,\n });\n };\n const judge = async (\n error: unknown,\n key: RecordKey,\n ): Promise<Settled> => {\n if (error instanceof ActionRefusedError)\n return { kind: 'refused', reason: error.reason || UNAVAILABLE };\n const failure = await readSafely(error);\n if (!isCalledOff(error))\n try {\n onError.current?.(error, { key, operation });\n } catch {\n // The host's handler is the host's: the run carries on.\n }\n return {\n kind: unanswered(error, failure) ? 'unknown' : 'failed',\n reason: failure.reason.trim() === '' ? FAILED : failure.reason,\n };\n };\n const settle = async (key: RecordKey): Promise<Settled> => {\n const sent = (async (): Promise<Settled> => {\n try {\n await command.each(key);\n return { kind: 'done' };\n } catch (error) {\n return judge(error, key);\n }\n })();\n let timer: ReturnType<typeof setTimeout> | undefined;\n const racers = [sent, given];\n if (timeout !== undefined && Number.isFinite(timeout) && timeout > 0)\n racers.push(\n new Promise<Settled>(resolve => {\n timer = setTimeout(\n () => resolve({ kind: 'unknown', reason: TIMED_OUT }),\n timeout,\n );\n }),\n );\n try {\n return await Promise.race(racers);\n } finally {\n clearTimeout(timer);\n }\n };\n const worker = async (): Promise<void> => {\n while (next < keys.length && !stopping.current) {\n const key = keys[next];\n next += 1;\n const settled = await settle(key);\n if (settled.kind === 'done') succeeded.push(key);\n else\n ({ failed, refused, unknown })[settled.kind].push({\n key,\n reason: settled.reason,\n });\n report();\n }\n };\n const finish = () => {\n // Settled whatever came of the rest: the surface is free again.\n busy.current = false;\n abandon.current = null;\n // The host may have gone while the command ran: the records under\n // way took it, and the report simply has nobody to reach.\n if (!alive.current) return;\n const settled = new Set<RecordKey>([\n ...succeeded,\n ...[...failed, ...refused, ...unknown].map(each => each.key),\n ]);\n const skipped = keys.filter(key => !settled.has(key));\n // What is left to deal with stays picked: the refused, the failed\n // and the never started, in the order they were picked. A record\n // whose outcome is unknown is let go — checked, not sent again.\n const left = new Set<RecordKey>([\n ...[...failed, ...refused].map(each => each.key),\n ...skipped,\n ]);\n const kept = selection.select ? keys.filter(key => left.has(key)) : [];\n setRunning(null);\n setOutcome({\n title: command.title,\n ...(command.values ? { values: command.values } : {}),\n succeeded,\n failed,\n refused,\n unknown,\n skipped,\n kept,\n });\n try {\n selection.select?.(kept);\n } finally {\n selection.refresh();\n }\n };\n setOutcome(null);\n report();\n const workers = Array.from(\n { length: Math.min(concurrency, keys.length) },\n worker,\n );\n void Promise.all(workers).finally(finish);\n },\n [concurrency],\n );\n\n const stop = useCallback(() => {\n if (!busy.current) return;\n if (stopping.current) {\n abandon.current?.();\n return;\n }\n stopping.current = true;\n setRunning(current => (current ? { ...current, stopping: true } : current));\n }, []);\n const dismiss = useCallback(() => setOutcome(null), []);\n return { run, stop, running, outcome, dismiss };\n}\n\n/**\n * The reasons a command's failures give, most common first — the strip says\n * a few of them rather than one reason for all, since records refuse for\n * different reasons and the most common is the one to fix first.\n */\nexport function failureReasons(\n failed: readonly BulkFailure[],\n): { reason: string; count: number }[] {\n const counts = new Map<string, number>();\n for (const { reason } of failed)\n counts.set(reason, (counts.get(reason) ?? 0) + 1);\n return [...counts]\n .map(([reason, count]) => ({ reason, count }))\n .sort((left, right) => right.count - left.count);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport type { FieldOption, RecordKey } from '../model/index.js';\nimport type { RecordRow } from '../record/index.js';\nimport {\n actionState,\n asksFirst,\n choiceOf,\n confirmOf,\n initialInput,\n missingInput,\n nextChange,\n offeredAt,\n refusalsByReason,\n runOne,\n splitFor,\n type ActionConfirm,\n type ActionInput,\n type ActionPlace,\n type RecordAction,\n type RecordActions,\n type RefusalGroup,\n} from '../runtime/actions.js';\nimport {\n useActionRunner,\n type ActionFailureContext,\n type ActionRunner,\n type BulkRun,\n type BulkSelection,\n} from './actionRunner.js';\n\n/** What of a record table the actions read and act on. */\nexport interface RecordActionTable {\n rows: readonly RecordRow[];\n selection: readonly RecordKey[];\n selectedRows: readonly RecordRow[];\n select(keys: readonly RecordKey[]): void;\n refresh(): void;\n}\n\nexport interface RecordActionsOptions {\n /** The declared actions (`actions()`); none leaves only the runner. */\n actions?: RecordActions;\n table: RecordActionTable;\n /**\n * What reading the view again after a command means here: the table's\n * own by default; a board's record panel reads the whole board again.\n */\n refresh?(): void;\n /**\n * Records shown beyond the table's page — the record detail's, opened by\n * a link — whose actions are drawn and whose availability can change on\n * its own as well.\n */\n also?: readonly RecordRow[];\n /** How many records are in flight at once; a handful by default. */\n concurrency?: number;\n /**\n * Told of what a command threw on a record, as it was thrown — not of an\n * action's own refusal, nor of an abort (`ActionRunnerOptions.onError`).\n */\n onError?(error: unknown, context: ActionFailureContext): void;\n}\n\n/** One action as a record's row, menu or detail draws it. */\nexport interface RowActionView {\n action: RecordAction;\n available: boolean;\n /** Why not, as the host wrote it (a key stays a key); `null` when able. */\n reason: string | null;\n /**\n * A choice's options, each with whether this record takes it — the value\n * it already holds is refused by the host's rule and not offered again.\n * `null` for an action that is not a choice.\n */\n choices: readonly { option: FieldOption; available: boolean }[] | null;\n}\n\n/** One action as the selection's bar draws it. */\nexport interface BulkActionView {\n action: RecordAction;\n /** How many records are picked: what the primary action's button counts. */\n count: number;\n /**\n * How many of them take it now, before any input — 「催发货 2/4 条」; the\n * dialog says which do not and why.\n */\n able: number;\n /**\n * Why none of them takes it, the commonest reason as the host wrote it;\n * `null` while one does.\n */\n reason: string | null;\n /** A choice's options, or `null`. */\n choices: readonly FieldOption[] | null;\n}\n\n/** An action pressed and waiting on the reader: its question, its form. */\nexport interface PendingAction {\n action: RecordAction;\n place: ActionPlace;\n /** What it runs over: the record, or the selection. */\n keys: readonly RecordKey[];\n input: ActionInput;\n /** The declared question for this input, or `null` for the engine's own. */\n confirm: ActionConfirm | null;\n /** Whether it has a form to fill (a choice is filled by its option). */\n form: boolean;\n /** The records that take it now. */\n able: readonly RecordKey[];\n /** The ones that will not be sent, by reason, the commonest first. */\n refused: readonly RefusalGroup[];\n /** Required fields still blank, by name. */\n missing: readonly string[];\n /** The option a choice picked, as the words `{value}` is said with. */\n value: string | null;\n}\n\n/**\n * The declared actions of one record surface (host-integration.md 5): what\n * each record and the selection are offered, the press that asks first or\n * runs, the question or form waiting on the reader, and the one runner every\n * command on the surface goes through — a few at a time, its progress, its\n * stop, its outcome, the refresh after.\n *\n * Availability is asked at the engine's clock, which moves on by itself when\n * a record's rule says it will change (`changesAt`): the host keeps no timer.\n */\nexport interface RecordActionsController extends Pick<\n ActionRunner,\n 'running' | 'outcome' | 'stop' | 'dismiss'\n> {\n /** The time the rules are asked at now. */\n now: number;\n /** A command is running: nothing else starts until it settles. */\n busy: boolean;\n /** The actions offered on a record at `row` or `detail`, hidden ones left out. */\n forRow(row: RecordRow, place: 'row' | 'detail'): readonly RowActionView[];\n /** The actions offered on the selection, left out where hidden on all of it. */\n forSelection(): readonly BulkActionView[];\n /**\n * Presses an action: on `row`, at `row` or `detail`; on the selection at\n * `bulk`. With a question or a form it waits (`pending`), otherwise it\n * runs. A choice's option comes as the input.\n */\n start(\n id: string,\n place: ActionPlace,\n row?: RecordRow,\n input?: ActionInput,\n ): void;\n pending: PendingAction | null;\n setInput(name: string, value: unknown): void;\n /** Picks only the records that take it — 「只选能做的」. */\n onlyAble(): void;\n /** Runs what is pending; the refused are reported, not sent. */\n confirm(): void;\n cancel(): void;\n /** Runs a host's own command (a slot's) on this surface's runner. */\n runCommand(selection: BulkSelection, command: BulkRun): void;\n}\n\ninterface Pressed {\n action: RecordAction;\n place: ActionPlace;\n keys: readonly RecordKey[];\n input: ActionInput;\n /** The records as they were pressed, where the table no longer has them. */\n rows: readonly RecordRow[];\n}\n\nconst NO_ROWS: readonly RecordRow[] = [];\n\n/**\n * The shortest wait before a rule is asked again on its own. A `changesAt`\n * that answers a moment ahead of every clock it is asked at — a target that\n * moves with `now` — would otherwise wake the surface without pause; a rule\n * that really flips sooner is seen at most this late.\n */\nconst RECHECK_FLOOR = 1_000;\n\n/** The words a choice's `{value}` is said with: the option picked. */\nfunction valueOf(action: RecordAction, input: ActionInput): string | null {\n const choice = choiceOf(action);\n if (!choice) return null;\n const picked = input[choice.name];\n const option = choice.options.find(each => each.value === picked);\n if (option) return option.label;\n // A value outside the options is shown as it is, where it is a value.\n return typeof picked === 'string' || typeof picked === 'number'\n ? String(picked)\n : null;\n}\n\nexport function useRecordActions({\n actions,\n table,\n refresh,\n also = NO_ROWS,\n concurrency,\n onError,\n}: RecordActionsOptions): RecordActionsController {\n const runner = useActionRunner({\n ...(concurrency === undefined ? {} : { concurrency }),\n ...(onError ? { onError } : {}),\n });\n const [now, setNow] = useState(Date.now);\n const [pressed, setPressed] = useState<Pressed | null>(null);\n const reread = refresh ?? table.refresh;\n const { rows, selection, selectedRows, select } = table;\n\n // The next moment any record on screen changes on its own, and a timer\n // that moves the clock there. A clock left behind while rows came in is\n // only ever early: a rule asked too early refuses, and says when it will\n // change, which is at once.\n const next = useMemo(\n () => nextChange(actions, [...rows, ...also], now),\n [actions, rows, also, now],\n );\n useEffect(() => {\n if (next === null) return;\n const timer = setTimeout(\n () => setNow(Date.now()),\n // The longest wait a timer holds; a later change is asked again then.\n Math.min(Math.max(RECHECK_FLOOR, next - Date.now()), 2_147_483_647),\n );\n return () => clearTimeout(timer);\n }, [next]);\n\n const known = useMemo(() => {\n const map = new Map<RecordKey, RecordRow>();\n for (const row of [...(pressed?.rows ?? []), ...also, ...rows])\n map.set(row.key, row);\n return map;\n }, [pressed, also, rows]);\n const rowOf = useCallback((key: RecordKey) => known.get(key), [known]);\n\n const busy = runner.running !== null;\n const { run } = runner;\n\n const execute = useCallback(\n ({ action, place, keys, input }: Pressed) => {\n const confirm = confirmOf(action, input);\n const value = valueOf(action, input);\n run(\n {\n keys,\n // A record's own command leaves the selection as it found it.\n ...(place === 'bulk' ? { select } : {}),\n refresh: reread,\n },\n {\n title: confirm?.action ?? action.label,\n ...(value === null ? {} : { values: { value } }),\n operation: action.id,\n ...(action.timeout === undefined ? {} : { timeout: action.timeout }),\n each: key => runOne(action, rowOf(key), input, Date.now()),\n },\n );\n },\n [run, select, reread, rowOf],\n );\n\n const start = useCallback(\n (id: string, place: ActionPlace, row?: RecordRow, given?: ActionInput) => {\n if (busy) return;\n const action = actions?.find(each => each.id === id);\n if (!action) return;\n if (place !== 'bulk' && !row) return;\n const input = { ...initialInput(action), ...given };\n const target: Pressed = {\n action,\n place,\n keys: place === 'bulk' ? [...selection] : [row!.key],\n input,\n rows: place === 'bulk' ? selectedRows : [row!],\n };\n if (target.keys.length === 0) return;\n setNow(Date.now());\n if (asksFirst(action, place, input)) setPressed(target);\n else execute(target);\n },\n [actions, busy, selection, selectedRows, execute],\n );\n\n const pending = useMemo<PendingAction | null>(() => {\n if (!pressed) return null;\n const { action, place, keys, input } = pressed;\n const split = splitFor(action, keys, rowOf, { now, input });\n const choice = choiceOf(action);\n return {\n action,\n place,\n keys,\n input,\n confirm: confirmOf(action, input),\n form: action.form !== undefined && choice === null,\n able: split.able,\n refused: refusalsByReason(split.refused),\n missing: missingInput(action, input),\n value: valueOf(action, input),\n };\n }, [pressed, rowOf, now]);\n\n const forRow = useCallback(\n (row: RecordRow, place: 'row' | 'detail'): RowActionView[] =>\n offeredAt(actions, place).flatMap(action => {\n const state = actionState(action, row, { now });\n if (state.hidden) return [];\n const choice = choiceOf(action);\n return [\n {\n action,\n available: state.available,\n reason: state.reason,\n choices: choice\n ? choice.options.map(option => ({\n option,\n available:\n state.available &&\n actionState(action, row, {\n now,\n input: { [choice.name]: option.value },\n }).available,\n }))\n : null,\n },\n ];\n }),\n [actions, now],\n );\n\n const forSelection = useCallback(\n (): BulkActionView[] =>\n offeredAt(actions, 'bulk')\n .filter(\n action =>\n // Keys whose record is not in hand are shown the action, and\n // refused in the dialog with why.\n selectedRows.length < selection.length ||\n selectedRows.some(row => !actionState(action, row, { now }).hidden),\n )\n .map(action => {\n const split = splitFor(action, selection, rowOf, { now });\n return {\n action,\n count: selection.length,\n able: split.able.length,\n reason:\n split.able.length === 0\n ? (refusalsByReason(split.refused)[0]?.reason ?? null)\n : null,\n choices: choiceOf(action)?.options ?? null,\n };\n }),\n [actions, selectedRows, selection, rowOf, now],\n );\n\n const setInput = useCallback(\n (name: string, value: unknown) =>\n setPressed(last =>\n last ? { ...last, input: { ...last.input, [name]: value } } : last,\n ),\n [],\n );\n\n const onlyAble = useCallback(() => {\n if (!pending || !pressed) return;\n const able = [...pending.able];\n if (pressed.place === 'bulk') select(able);\n setPressed({ ...pressed, keys: able });\n }, [pending, pressed, select]);\n\n const confirm = useCallback(() => {\n if (!pressed || !pending) return;\n if (pending.missing.length > 0 || pending.able.length === 0) return;\n setPressed(null);\n execute(pressed);\n }, [pressed, pending, execute]);\n\n const cancel = useCallback(() => setPressed(null), []);\n\n return {\n now,\n busy,\n forRow,\n forSelection,\n start,\n pending,\n setInput,\n onlyAble,\n confirm,\n cancel,\n runCommand: run,\n running: runner.running,\n outcome: runner.outcome,\n stop: runner.stop,\n dismiss: runner.dismiss,\n };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback } from 'react';\nimport type { ViewRuntime } from '../runtime/index.js';\nimport { rootSearch, searchFieldOf, withRootSearch } from '../filter/index.js';\nimport type { DataViewConfig, FieldDefinition } from '../model/index.js';\nimport { useViewRuntime } from './useViewEngine.js';\n\n/**\n * A view's search, kept on hand rather than behind the conditions editor.\n *\n * Searching an error used to take five steps — open the conditions, add\n * one, tick the search field, close the list, type — for the one condition\n * an operator reaches for first. When the definition declares a search\n * field (`kind: 'search'`), this is its box: the search condition on the\n * draft's root (`rootSearch`), edited in place (`withRootSearch`), the same\n * condition the editor shows as a pill and the applied bar reads back.\n */\nexport interface SearchBoxController {\n /** The definition's search field: its label names the box. */\n field: FieldDefinition;\n /** The search in the draft, as typed. */\n value: string;\n /** The search in force — what the rows on screen were found by. */\n applied: string;\n /**\n * The definition searches a phrase, and the source matches words only, so\n * the search is by words (capabilities.md 4.2, `capability.search.as-terms`):\n * the box says so where a reader looks before typing.\n */\n byWords: boolean;\n /** Edits the draft's search; blank takes the condition away. */\n set(text: string): void;\n /** Puts the draft in force — Enter in the box. */\n submit(): void;\n /** Takes the search away, and the rows found by it with it. */\n clear(): void;\n}\n\nexport function useSearchBox(\n runtime: ViewRuntime<DataViewConfig> | null,\n): SearchBoxController | null {\n const state = useViewRuntime(runtime);\n const set = useCallback(\n (text: string) => {\n if (runtime) searchInDraft(runtime, text);\n },\n [runtime],\n );\n const submit = useCallback(() => runtime?.apply(), [runtime]);\n const clear = useCallback(() => {\n if (!runtime) return;\n searchInDraft(runtime, '');\n runtime.apply();\n }, [runtime]);\n const field = runtime ? searchFieldOf(runtime.definition.fields) : null;\n if (!runtime || !state || !field) return null;\n return {\n field,\n value: rootSearch(state.draft.filter, field.name),\n applied: rootSearch(state.applied.filter, field.name),\n byWords: (runtime.definition.narrowing?.findings ?? []).some(\n found =>\n found.code === 'capability.search.as-terms' &&\n found.params?.field === field.name,\n ),\n set,\n submit,\n clear,\n };\n}\n\n/** Writes `text` as the draft's root search, where the definition has one. */\nfunction searchInDraft(runtime: ViewRuntime<DataViewConfig>, text: string) {\n const field = searchFieldOf(runtime.definition.fields);\n if (!field) return;\n const draft = runtime.getSnapshot().draft.filter;\n runtime.edit({ filter: withRootSearch(draft, field.name, text) });\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport type { Issue, ViewConfig } from '../model/index.js';\nimport type { ViewRuntime } from '../runtime/index.js';\nimport { useViewRuntime } from './useViewEngine.js';\n\n/**\n * What an open view uses that its source no longer admits, and the one\n * press that takes it out (capabilities.md Q2, `ViewRuntime.unavailable`).\n */\nexport interface UnavailableController {\n /** The findings, each at the place in the config it is about. */\n issues: Issue[];\n /** 「移除不可用的条件」: see `ViewRuntime.removeUnavailable`. */\n remove(): void;\n}\n\n/**\n * The view's unavailable parts, read again whenever its snapshot changes,\n * or `null` when there are none — so a surface draws its strip only where\n * there is something to say.\n */\nexport function useUnavailable(\n runtime: ViewRuntime<ViewConfig> | null,\n): UnavailableController | null {\n const state = useViewRuntime(runtime);\n const issues = useMemo(\n () => (runtime && state ? runtime.unavailable() : []),\n [runtime, state],\n );\n const remove = useCallback(() => runtime?.removeUnavailable(), [runtime]);\n return issues.length > 0 ? { issues, remove } : null;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useMemo, useState, useSyncExternalStore } from 'react';\nimport {\n DASHBOARD_GRID_COLUMNS,\n boardWidth,\n type AnalysisDateUnit,\n type DashboardWidth,\n type DashboardField,\n type DashboardFilters,\n type DashboardPanel,\n type DashboardTab,\n type DashboardTimeGrouping,\n type DataViewConfig,\n type FieldDefinition,\n type FieldOption,\n type FilterValue,\n type Issue,\n type PanelClick,\n type PanelLayout,\n type RecordData,\n} from '../model/index.js';\nimport { filtersOf, tabsOf, type FilterReach } from '../dashboard/index.js';\nimport type {\n CrossFilterOutcome,\n DashboardEditing,\n DashboardFilterEditing,\n DashboardPanelState,\n DashboardRuntime,\n DestinationBoard,\n EditHistoryState,\n HandOver,\n OptionSource,\n PanelGrouping,\n PressDestination,\n ValueCandidateSource,\n ViewRuntime,\n} from '../runtime/index.js';\nimport { boardFindings } from '../runtime/dashboard/panels.js';\nimport type { FieldKindRegistry } from '../filter/index.js';\nimport { useViewRuntime } from './useViewEngine.js';\n\n/** One panel, ready to place: geometry, what runs inside, what is wrong. */\nexport interface DashboardPanelView {\n id: string;\n title: string | undefined;\n panel: DashboardPanel;\n layout: PanelLayout;\n /** The runtime of a data panel that can run; `null` otherwise. */\n runtime: ViewRuntime<DataViewConfig> | null;\n issues: Issue[];\n /**\n * The fields of the view a data panel shows, which its findings are\n * named by (`DashboardPanelState.fields`); empty otherwise.\n */\n fields: readonly FieldDefinition[];\n /** True when this panel alone cannot show anything. */\n broken: boolean;\n /** The tab it is on; `null` on a board without tabs. */\n tab: string | null;\n /** What each filter does to it, by filter name (`filterReach`). */\n reach: Readonly<Record<string, FilterReach>>;\n /** What the time grouping does to it (`PanelGrouping`). */\n grouping: PanelGrouping;\n /**\n * What a press on one of its groups does (D22 I), or `null` for the\n * follow-up menu (`DashboardPanelState.click`).\n */\n click: PanelClick | null;\n}\n\nexport interface DashboardController {\n panels: DashboardPanelView[];\n /** Columns a layout is placed in; the kernel admits against the same number. */\n columns: number;\n /**\n * How wide the board on screen is laid out (D31, `boardWidth`): `full`\n * while no board is open, and for one saved before a board could say.\n */\n width: DashboardWidth;\n /** The tab on screen, whose panels alone run; `null` without tabs. */\n tab: string | null;\n /** Shows another tab (`DashboardRuntime.showTab`). */\n showTab(tabId: string): void;\n /**\n * What the board says about itself, above its panels (`boardFindings`):\n * its own findings — \"too many panels\" among them — and a panel's the\n * draft raised that no panel wears yet. Everything else a panel says in\n * its own frame.\n */\n issues: Issue[];\n /** True while a panel reference is still loading. */\n resolving: boolean;\n /**\n * True while any panel has a query in flight.\n *\n * A dashboard runs nothing of its own — `state.query` never leaves `idle`\n * — so \"is something running here\" is only answerable by asking the\n * panels, which is what the dashboard's own timer does before it fires\n * (`PanelChildren.loading`). A control that read the dashboard's\n * query state instead would call a board of twelve loading panels idle.\n */\n loading: boolean;\n /**\n * When the panels on the tab shown were read, on the runtime's clock\n * (`ViewResult.receivedAt`): the **earliest** of their last answers, so\n * 「更新于 10:32」 is true of every number on screen — a panel whose\n * refresh failed keeps its older rows, and the time says so. `null` until\n * one of them has answered. Panels on another tab are not on screen and\n * do not count.\n */\n readAt: number | null;\n dirty: boolean;\n /**\n * Moves or resizes one panel, and applies that alone, like sorting a\n * table: the panels it lands on are pushed down out of its way, and a\n * global filter still being edited stays unapplied\n * (`DashboardRuntime.place`).\n */\n place(\n panelId: string,\n layout: PanelLayout,\n grown?: ReadonlyMap<string, number>,\n ): void;\n /** Re-runs every panel at once. */\n refresh(): void;\n /** Re-runs one panel: the retry on a panel whose query failed. */\n refreshPanel(panelId: string): void;\n /**\n * Whether the board is being built — 「编辑」 pressed, not yet 「完成」 or\n * 「取消」 (`DashboardRuntimeState.building`). The runtime's, so its auto\n * refresh waits for it (D26 Q39) and every surface reads the same one.\n */\n building: boolean;\n /** Starts or ends building the board (`DashboardRuntime.setBuilding`). */\n setBuilding(active: boolean): void;\n /**\n * Building the board (D22 A–E): the runtime's own commands, each written\n * into the draft and onto the screen at once; `null` while no board is\n * open. Whether they are on offer is the UI's to say, by permission.\n */\n edit: (DashboardEditing & DashboardFilterEditing) | null;\n /**\n * What building the board can take back and make again — the step\n * `edit.undo()` and `edit.redo()` would, or `null` (`DashboardRuntimeState.history`).\n */\n history: EditHistoryState;\n /**\n * The board's filters as on screen, in the bar's order (D22 F); the same\n * list the draft and the applied config hold, since every edit writes\n * both.\n */\n filterFields: readonly DashboardField[];\n /** The board's time grouping; `null` on a board without one. */\n timeGrouping: DashboardTimeGrouping | null;\n /** What the filters hold now: the reader's, never the config's. */\n filters: DashboardFilters;\n /**\n * The step at which the filters' values last went out to the panels\n * (`DashboardRuntimeState.filtersRun`): what a change of them ran.\n */\n filtersRun: number;\n /**\n * Sets what one filter holds, `null` clearing it; the panels run on it a\n * moment later (`DashboardRuntime.setFilterValue`). Answers why a value\n * was refused.\n */\n setFilterValue(name: string, value: FilterValue | null): Issue[];\n setGroupingUnit(unit: AnalysisDateUnit): void;\n /** 「清空」: every filter cleared, the required ones to their defaults. */\n clearFilters(): void;\n /**\n * The filters whose control asks for a value it does not hold yet — a\n * date filter turned to 「指定日期」 with no day picked — by name. The\n * value in force is not what the bar shows, so a panel wired to one says\n * a date is to be picked rather than show the numbers of the value that\n * was (2026-09-26 review, P1-1).\n */\n awaiting: readonly string[];\n /** Says a filter's control is (or is no longer) awaiting a value. */\n setAwaiting(name: string, awaiting: boolean): void;\n /** What a text filter offers to pick from (`DashboardRuntime.valueCandidates`). */\n filterCandidates(name: string): ValueCandidateSource | null;\n /**\n * The list a filter without one of its own picks from, as its wired\n * fields declare it (`DashboardRuntime.wiredOptions`); `null` for none.\n */\n filterChoices(name: string): FieldOption[] | null;\n /** An id filter's candidates, by the host's source key (`optionSource`). */\n filterOptions(remote: string): OptionSource | null;\n /** The field kinds the board's filters are edited with; `null` without a board. */\n kinds: FieldKindRegistry | null;\n /**\n * The board's tabs in the order of its bar, as they are on screen (D22\n * E); none on a board without. Fewer than two draw no bar.\n */\n tabs: readonly DashboardTab[];\n /**\n * Loads a saved view before a panel shows it, so the panel is added at\n * the size of what it shows (`DashboardRuntime.preload`); never rejects.\n */\n preload(instanceId: string): Promise<void>;\n /**\n * A press on one group of a panel whose click sets a filter (D22 I,\n * `DashboardRuntime.crossFilter`): set from it, or cleared on a second\n * press of the same group.\n */\n crossFilter(panelId: string, row: RecordData): CrossFilterOutcome;\n /**\n * Whether a group is one its panel's press set a filter to — the click's,\n * or a span of its time axis (`pressSpan`).\n */\n pressed(panelId: string, row: RecordData): boolean;\n /**\n * The date filters a span of a panel's time axis can set\n * (`DashboardRuntime.spanFilters`, D33 Q52).\n */\n spanFilters(panelId: string): readonly DashboardField[];\n /**\n * A span of a panel's time axis set into one of those filters\n * (`DashboardRuntime.pressSpan`): the panel keeps every group.\n */\n pressSpan(\n panelId: string,\n name: string,\n row: RecordData,\n through: RecordData,\n ): CrossFilterOutcome;\n /** Where a press on a panel with a custom destination goes. */\n destination(\n panelId: string,\n row: RecordData,\n ): Promise<PressDestination | null>;\n /**\n * Another board a click opens, read for 「点击时…」 to list its filters\n * (`DashboardRuntime.destinationBoard`); `null` for one gone or unreadable.\n */\n destinationBoard(instanceId: string): Promise<DestinationBoard | null>;\n /**\n * What one data panel's view takes off the board as it stands\n * (`DashboardRuntime.handOver`, D26 Q30): every way off it — 「在工作台中\n * 打开」, the follow-ups, a view destination — hands this over.\n */\n handOver(panelId: string): HandOver | null;\n}\n\nconst EMPTY_PANELS: DashboardPanelState[] = [];\nconst NO_FILTERS: DashboardFilters = { values: {} };\nconst NO_NAMES: readonly string[] = [];\nconst NO_ISSUES: Issue[] = [];\nconst NO_FIELDS: readonly DashboardField[] = [];\nconst NO_HISTORY: EditHistoryState = { undo: null, redo: null };\n\n/**\n * A dashboard as a grid of panels.\n *\n * It reports the applied panels rather than the draft's, because a panel is\n * a running query and not a form field: what the grid shows is what is\n * executing. Geometry is the exception the design allows — moving a panel\n * applies that move alone in one gesture, so a drag lands immediately.\n */\nexport function useDashboard(\n runtime: DashboardRuntime | null,\n): DashboardController {\n const state = useViewRuntime(runtime);\n const panels = state?.panels ?? EMPTY_PANELS;\n const applied = state?.applied;\n\n // The children, watched here rather than left to the panels that draw\n // them: a child's query moving does not notify this runtime's subscribers\n // (it re-syncs the timer and the panel's issues, deliberately, so a grid\n // does not re-render on every panel request), so anything above the grid\n // that must know a request is out has to subscribe to the children itself.\n // The panels array keeps its identity while the set of panels is\n // unchanged, so neither memo churns as queries come and go.\n const children = useMemo(\n () =>\n panels\n .map(panel => panel.runtime)\n .filter(\n (child): child is ViewRuntime<DataViewConfig> => child !== null,\n ),\n [panels],\n );\n const watch = useCallback(\n (listener: () => void) => {\n const drop = children.map(child => child.subscribe(listener));\n return () => drop.forEach(stop => stop());\n },\n [children],\n );\n const anyLoading = useCallback(\n () =>\n children.some(child => child.getSnapshot().query.status === 'loading'),\n [children],\n );\n const loading = useSyncExternalStore(watch, anyLoading, anyLoading);\n const tabNow = state?.tab ?? null;\n const earliest = useCallback(() => {\n let at: number | null = null;\n for (const panel of panels) {\n if (panel.tab !== tabNow || !panel.runtime) continue;\n const received = panel.runtime.getSnapshot().result?.receivedAt;\n if (received !== undefined && (at === null || received < at))\n at = received;\n }\n return at;\n }, [panels, tabNow]);\n const readAt = useSyncExternalStore(watch, earliest, earliest);\n const filtersNow = state?.filters ?? null;\n const [awaiting, setAwaitingNames] = useState<readonly string[]>(NO_NAMES);\n const setAwaiting = useCallback((name: string, on: boolean) => {\n setAwaitingNames(names =>\n names.includes(name) === on\n ? names\n : on\n ? [...names, name]\n : names.filter(entry => entry !== name),\n );\n }, []);\n const appliedTabs = applied?.tabs;\n const issues = state?.issues;\n\n return {\n panels: useMemo(() => panels.map(toView), [panels]),\n columns: DASHBOARD_GRID_COLUMNS,\n width: boardWidth(applied ?? {}),\n tab: state?.tab ?? null,\n showTab: useCallback((tabId: string) => runtime?.showTab(tabId), [runtime]),\n issues: useMemo(\n () => (issues ? boardFindings({ issues, panels }) : NO_ISSUES),\n [issues, panels],\n ),\n resolving: state?.resolving ?? false,\n loading,\n readAt,\n dirty: state?.dirty ?? false,\n place: useCallback(\n (\n panelId: string,\n layout: PanelLayout,\n grown?: ReadonlyMap<string, number>,\n ) => runtime?.place(panelId, layout, grown),\n [runtime],\n ),\n refresh: useCallback(() => runtime?.refresh(), [runtime]),\n refreshPanel: useCallback(\n (panelId: string) => runtime?.refreshPanel(panelId),\n [runtime],\n ),\n building: state?.building ?? false,\n setBuilding: useCallback(\n (active: boolean) => runtime?.setBuilding(active),\n [runtime],\n ),\n edit: runtime,\n history: state?.history ?? NO_HISTORY,\n filterFields: useMemo(() => (applied ? filtersOf(applied) : []), [applied]),\n timeGrouping: applied?.timeGrouping ?? null,\n filters: state?.filters ?? NO_FILTERS,\n filtersRun: state?.filtersRun ?? 0,\n setFilterValue: useCallback(\n (name: string, value: FilterValue | null) =>\n runtime?.setFilterValue(name, value) ?? [],\n [runtime],\n ),\n setGroupingUnit: useCallback(\n (unit: AnalysisDateUnit) => runtime?.setGroupingUnit(unit),\n [runtime],\n ),\n clearFilters: useCallback(() => runtime?.clearFilters(), [runtime]),\n awaiting,\n setAwaiting,\n filterCandidates: useCallback(\n (name: string) => runtime?.valueCandidates(name) ?? null,\n [runtime],\n ),\n filterChoices: useCallback(\n (name: string) => runtime?.wiredOptions(name) ?? null,\n [runtime],\n ),\n filterOptions: useCallback(\n (remote: string) => runtime?.optionSource(remote) ?? null,\n [runtime],\n ),\n kinds: runtime?.kinds ?? null,\n // What is on screen: an edit writes the draft and the applied config\n // alike, so the two agree on the tabs whenever a panel is drawn.\n tabs: useMemo(() => tabsOf({ tabs: appliedTabs ?? [] }), [appliedTabs]),\n preload: useCallback(\n async (instanceId: string) => {\n await runtime?.preload(instanceId);\n },\n [runtime],\n ),\n crossFilter: useCallback(\n (panelId: string, row: RecordData): CrossFilterOutcome =>\n runtime?.crossFilter(panelId, row) ?? { kind: 'none' },\n [runtime],\n ),\n // Read against what the filters hold now, so a new value marks another\n // group: the callback is a new one whenever they change.\n pressed: useCallback(\n (panelId: string, row: RecordData) =>\n runtime !== null && filtersNow !== null\n ? runtime.pressed(panelId, row)\n : false,\n [runtime, filtersNow],\n ),\n // Read against what the filters hold now, as `pressed` is: a filter the\n // host took hold of since is no longer one a span can set.\n spanFilters: useCallback(\n (panelId: string) =>\n runtime !== null && filtersNow !== null\n ? runtime.spanFilters(panelId)\n : NO_FIELDS,\n [runtime, filtersNow],\n ),\n pressSpan: useCallback(\n (panelId: string, name: string, row: RecordData, through: RecordData) =>\n runtime?.pressSpan(panelId, name, row, through) ?? { kind: 'none' },\n [runtime],\n ),\n destination: useCallback(\n async (panelId: string, row: RecordData) =>\n runtime ? runtime.destination(panelId, row) : null,\n [runtime],\n ),\n destinationBoard: useCallback(\n async (instanceId: string) =>\n runtime ? runtime.destinationBoard(instanceId) : null,\n [runtime],\n ),\n handOver: useCallback(\n (panelId: string) => runtime?.handOver(panelId) ?? null,\n [runtime],\n ),\n };\n}\n\nfunction toView(panel: DashboardPanelState): DashboardPanelView {\n return {\n id: panel.id,\n title: panel.panel.title,\n panel: panel.panel,\n layout: panel.panel.layout,\n runtime: panel.runtime,\n issues: panel.issues,\n fields: panel.fields,\n tab: panel.tab,\n reach: panel.reach,\n grouping: panel.grouping,\n click: panel.click,\n // A data panel with no runtime cannot query, and any panel carrying an\n // error was refused by `validateDashboard` — a content panel included,\n // whose markdown, image or link the grid would otherwise render as\n // though nothing were wrong with it.\n // One on a tab not shown yet was never asked, which is not broken.\n broken:\n (panel.runtime === null &&\n panel.panel.kind === 'view' &&\n !panel.waiting) ||\n panel.issues.some(found => found.severity === 'error'),\n };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Where a way off a board or an embed goes, handed to the host's route: the\n * package never touches the address, so a view opened in the workbench, a\n * follow-up on a group, a panel's custom destination and the way back to\n * the board are all the host's to take. Neither a dashboard's nor a data\n * view's alone, so it sits beside both rather than in either's contract.\n */\n\nimport type {\n AnalysisViewConfig,\n DashboardFilters,\n FilterNode,\n FilterTree,\n RecordViewConfig,\n ViewConfig,\n ViewDefinition,\n} from '../model/index.js';\nimport { dequal } from 'dequal';\nimport { drillFilter } from '../analysis/index.js';\nimport {\n isSimpleTree,\n searchFieldOf,\n withRootSearch,\n} from '../filter/index.js';\n\n/**\n * What a name 「{subject} · {group}」 claims (D20 追问): the conditions that\n * select the group, and what the view is without them. While every one of\n * `conditions` still narrows the view (`narrowsTo`) the name stands; once\n * one is taken off, edited or negated, the view goes by `subject` — a name\n * that still said the group would say what the view no longer shows.\n */\nexport interface GroupNaming {\n /**\n * What the view is, the group aside: the definition's name for its\n * records, or the name of the question it was opened from.\n */\n subject: string;\n /** The group's own conditions, as the view opened with them. */\n conditions: readonly FilterNode[];\n}\n\n/**\n * The board a view was opened from (D26 Q33): what 「返回〈仪表盘〉」 names,\n * and where it goes — the board on the tab and under the filters it was\n * left on. The workbench draws the way back; the host only routes `back`.\n */\nexport interface BoardOrigin {\n title: string;\n back: DashboardTarget;\n}\n\n/**\n * What a view takes with it when it leaves a board (D26 Q30), in its own\n * field names — the same two parts through every way off it:\n * 「在工作台中打开」, a click's view destination, the follow-up menu and a\n * board's own analysis.\n */\nexport interface HandOver {\n /**\n * What is not the reader's: the board's fixed scope (`fixed`, D26 Q31)\n * and what the page holds — an embed's locked and hidden filters, or an\n * embedded view's `scopeFilter`. The opened view runs under it as its\n * scope — on the applied bar, and nobody's to take off there (H4).\n */\n scopeFilter: FilterTree | null;\n /**\n * What the reader set on the board: the opened view's own conditions,\n * which the reader can take off one by one.\n */\n filter: FilterTree | null;\n /** The board it left, for the way back; absent for a board never saved. */\n from?: BoardOrigin;\n}\n\n/**\n * A saved record or analysis view, opened on its own conditions with\n * `filter` added to them — so it opens 「已修改」 and 「还原」 takes them\n * back off — under `scopeFilter` as its scope. A host hands it to\n * `DataWorkbench`'s `handOver` as it is.\n */\nexport interface SavedViewTarget extends HandOver {\n kind: 'view';\n definitionId: string;\n instanceId: string;\n}\n\n/**\n * A view nobody saved: a follow-up on a group — its records, the same\n * question split by another dimension or of the group alone (D22 H) — or\n * an analysis the board owns. What the reader set on the board is already\n * among its conditions, as a view drilled out of another's are; what the\n * page holds is `scopeFilter`. A host hands it to `DataWorkbench`'s\n * `handOver` as it is.\n */\nexport interface UnsavedViewTarget {\n kind: 'unsaved';\n definitionId: string;\n title: string;\n config: RecordViewConfig | AnalysisViewConfig;\n scopeFilter: FilterTree | null;\n /** What `title` says of a group pressed, when it names one. */\n named?: GroupNaming;\n from?: BoardOrigin;\n}\n\n/**\n * A dashboard, opened with `filters` as its reader's values — the host\n * hands them to `DashboardWorkbench`'s `initialFilters` (or\n * `OpenOptions.filters`), never into the board's config. Another board a\n * panel's click opens (D23 Q17: each filter the author mapped holds the\n * group's value, every other one its default), or the way back to the one\n * a view left (`BoardOrigin.back`, on the tab it was left on).\n */\nexport interface DashboardTarget {\n kind: 'dashboard';\n definitionId: string;\n instanceId: string;\n filters: DashboardFilters;\n /** The tab to open on (`initialTab`); absent, where its reader last read it. */\n tab?: string | null;\n}\n\n/** Where a way off the board goes, for the host's route. */\nexport type ViewNavigation =\n | SavedViewTarget\n | UnsavedViewTarget\n | DashboardTarget\n /** A page of the host's: a panel's URL filled with the group pressed. */\n | { kind: 'url'; url: string };\n\n/** The two a workbench opens (`DataWorkbench`'s `handOver`). */\nexport type ViewHandOver = SavedViewTarget | UnsavedViewTarget;\n\n/** The conditions of a handed tree, as nodes to AND onto a view's own. */\nexport function handedConditions(tree: FilterTree | null): FilterNode[] {\n if (!tree) return [];\n return isSimpleTree(tree) ? tree.children : [tree];\n}\n\n/**\n * A config with what the reader set on a board (`HandOver.filter`) ANDed\n * onto its own conditions — flattened into one \"all of\" while its own\n * were one — and read in the editor's advanced mode once they no longer\n * are (`drillFilter`). The config itself when nothing was handed.\n */\nexport function withHandedFilter<\n C extends RecordViewConfig | AnalysisViewConfig,\n>(config: C, filter: FilterTree | null): C {\n const conditions = handedConditions(filter);\n if (conditions.length === 0) return config;\n return withFilterMode({\n ...config,\n filter: drillFilter(config.filter, conditions),\n });\n}\n\n/**\n * A condition tree that no longer flattens into one \"all of\" group is an\n * advanced one, which is how the editor has to open it.\n */\nexport function withFilterMode<C extends RecordViewConfig | AnalysisViewConfig>(\n config: C,\n): C {\n return isSimpleTree(config.filter)\n ? config\n : { ...config, filterMode: 'advanced' };\n}\n\n/**\n * Whether a handed view's draft still says what the hand-over left it at\n * (`landed`), whatever object holds it now: what the board added is then\n * the only difference from the saved view, and going back to the board\n * restores it there — nothing is lost, so nothing is asked (D26 Q33). A\n * config is JSON, so equal by value is the same config.\n */\nexport function untouchedSince(\n draft: ViewConfig,\n landed: ViewConfig | null,\n): boolean {\n return landed !== null && (draft === landed || dequal(draft, landed));\n}\n\n/**\n * Whether a draft differs from its saved config only in how it is looked\n * at — the sort, the page size, the text in the search box (the root search\n * on the definition's search field) — and in nothing it asks (R2-39). On a\n * view the reader cannot save in place, such a draft is a look-up nobody\n * meant to keep: switching away is not asked about, where a condition built\n * on it still is, since 「另存为」 is what it was for.\n */\nexport function lookedOnly(\n view: { draft: ViewConfig; saved: { config: ViewConfig } | null },\n definition: ViewDefinition | undefined,\n): boolean {\n const { draft } = view;\n const saved = view.saved?.config;\n if (!saved || draft.kind !== saved.kind || draft.kind === 'dashboard')\n return false;\n const search =\n definition?.kind === 'data'\n ? (searchFieldOf(definition.fields)?.name ?? null)\n : null;\n const asked = (config: ViewConfig): Record<string, unknown> => {\n const rest: Record<string, unknown> = { ...config };\n delete rest.sort;\n delete rest.pageSize;\n if (search !== null && 'filter' in config)\n rest.filter = withRootSearch(config.filter, search, '');\n return rest;\n };\n return dequal(asked(draft), asked(saved));\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useMemo, useRef } from 'react';\nimport type {\n AnalysisViewConfig,\n DataViewConfig,\n FilterNode,\n RecordViewConfig,\n ViewConfig,\n} from '../model/index.js';\nimport { drillFilter } from '../analysis/index.js';\nimport { defaultRecordConfig } from '../record/index.js';\nimport type {\n BoardOrigin,\n GroupNaming,\n HandOver,\n ViewNavigation,\n ViewRuntime,\n} from '../runtime/index.js';\nimport {\n handedConditions,\n withFilterMode,\n withHandedFilter,\n} from '../runtime/navigation.js';\nimport { useViewRuntime } from './useViewEngine.js';\nimport type { WorkbenchController } from './useWorkbench.js';\n\n/**\n * The part of a workbench the follow-up menu drives (`useAnalysisResult`):\n * what a dashboard panel hands it in place of one.\n */\nexport type FollowUpHost = Pick<\n WorkbenchController,\n 'state' | 'canDrill' | 'drill' | 'follow'\n>;\n\n/** A view that takes nothing off the page it leaves. */\nconst NOTHING_HANDED: HandOver = { scopeFilter: null, filter: null };\n\n/**\n * The follow-ups on a dashboard panel's groups (D22 H): the analysis view's\n * own menu — the records behind a group, the question split by another\n * dimension, the question of the group alone — each opened through the\n * host's route (`navigate`) as a view nobody saved, rather than beside the\n * panel: a board has no \"beside\". Without a route there is nothing to open,\n * and the menu is not offered at all.\n *\n * What opens takes what the panel's view takes off the page (`handOver`,\n * read at the press, D26 Q30): what the page holds as its scope, which\n * nobody in the workbench takes off; the reader's values as conditions of\n * its own beside the view's and the group's, which they can — so the\n * workbench shows what the panel showed. And the board it came from, for\n * the way back (Q33).\n */\nexport function usePanelFollowUps(\n runtime: ViewRuntime<DataViewConfig> | null,\n navigate: ((to: ViewNavigation) => void) | undefined,\n handOver: () => HandOver | null,\n): FollowUpHost {\n const state = useViewRuntime(runtime);\n // Read at the press rather than on render: the board's filters move\n // without this panel's view changing.\n const latest = useRef(handOver);\n useEffect(() => {\n latest.current = handOver;\n }, [handOver]);\n return useMemo(() => {\n const definition = runtime?.definition;\n const canDrill =\n navigate !== undefined &&\n runtime?.kind === 'analysis' &&\n definition?.kind === 'data' &&\n definition.record !== undefined;\n const handed = () => latest.current() ?? NOTHING_HANDED;\n return {\n state,\n canDrill,\n drill(\n conditions: readonly FilterNode[],\n title: string,\n subject?: string,\n ) {\n if (!canDrill || !runtime || !state || definition?.kind !== 'data')\n return;\n const away = handed();\n const config: RecordViewConfig = {\n ...defaultRecordConfig(definition, runtime.limits),\n filter: drillFilter(state.applied.filter, [\n ...handedConditions(away.filter),\n ...conditions,\n ]),\n };\n navigate?.({\n kind: 'unsaved',\n definitionId: definition.id,\n title,\n config: withFilterMode(config),\n scopeFilter: away.scopeFilter,\n ...naming(subject, conditions),\n ...origin(away.from),\n });\n },\n follow(\n config: ViewConfig,\n title: string,\n conditions: readonly FilterNode[],\n subject?: string,\n ) {\n if (!navigate || !runtime || config.kind !== 'analysis') return;\n navigate(\n unsaved(runtime, config, title, handed(), subject, conditions),\n );\n },\n };\n }, [runtime, state, navigate]);\n}\n\n/**\n * An analysis the board owns, opened in the workbench (「在工作台中打开」): it\n * has no saved view to open, so it goes as a view nobody saved, taking what\n * its panel takes off the board (`handOver`).\n */\nexport function ownedNavigation(\n runtime: ViewRuntime<DataViewConfig>,\n title: string,\n handOver: HandOver | null,\n): ViewNavigation | null {\n const config = runtime.getSnapshot().applied;\n if (config.kind !== 'analysis') return null;\n return unsaved(runtime, config, title, handOver ?? NOTHING_HANDED);\n}\n\n/** An analysis nobody saved, under what it takes off the page. */\nfunction unsaved(\n runtime: ViewRuntime<DataViewConfig>,\n config: AnalysisViewConfig,\n title: string,\n away: HandOver,\n subject?: string,\n conditions: readonly FilterNode[] = [],\n): ViewNavigation {\n return {\n kind: 'unsaved',\n definitionId: runtime.definition.id,\n title,\n config: withHandedFilter(config, away.filter),\n scopeFilter: away.scopeFilter,\n ...naming(subject, conditions),\n ...origin(away.from),\n };\n}\n\n/**\n * What the title claims of the group, which the workbench reads to stop\n * claiming it once the reader takes the group off: the group's conditions\n * alone, not the board's, which the title never named.\n */\nfunction naming(\n subject: string | undefined,\n conditions: readonly FilterNode[],\n): { named?: GroupNaming } {\n return subject === undefined ? {} : { named: { subject, conditions } };\n}\n\n/** The board a view leaves, when it has one to go back to. */\nfunction origin(from: BoardOrigin | undefined): { from?: BoardOrigin } {\n return from ? { from } : {};\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport type {\n FieldDefinition,\n FieldGroupDefinition,\n FilterGroupOperator,\n FilterLeaf,\n FilterMode,\n FilterNode,\n FilterOperatorName,\n FilterTree,\n Issue,\n ViewConfig,\n} from '../model/index.js';\nimport {\n clearFilter,\n conditions,\n countLeaves,\n describeFilter,\n impliedDeletion,\n insertAt,\n filterIndexes,\n isRootFilterIssue,\n isSimpleTree,\n negateAt,\n nodeAt,\n operatorsOf,\n removeConditionAt,\n sameFilterNode,\n unmarkedErrors,\n updateAt,\n type EditorDescriptor,\n type FieldKindRegistry,\n type FilterPath,\n type FilterSummaryItem,\n isFilterGroup,\n} from '../filter/index.js';\nimport { holdsTime, isDurationOperator } from '../filter/kinds/duration.js';\nimport {\n hasAsked,\n type OptionSource,\n type ValueCandidateSource,\n type ViewRuntime,\n type ViewRuntimeState,\n} from '../runtime/index.js';\nimport {\n comparePending,\n filterOverBudget,\n type PendingReport,\n} from '../runtime/pending.js';\nimport { VALUE_CANDIDATE_OPERATORS } from '../analysis/index.js';\nimport { useViewRuntime } from './useViewEngine.js';\n\n/**\n * One view's filter editor: a tree to edit, plus the things that belong to\n * the view around it — which mode it shows, what is currently applied, and\n * when to run.\n */\nexport interface FilterEditorController extends FilterTreeController {\n mode: FilterMode;\n /**\n * The view's own conditions the rows on screen were fetched under, for a\n * summary bar. It reads the config the result carries rather than `applied`,\n * so the bar always describes the data beside it: applying starts a query,\n * and until it answers, `applied` has already moved on. Before any result\n * exists it describes the question on its way, or the one that failed —\n * there are no rows for it to contradict, and the bar stands in its place\n * from the first query rather than appearing as the answer lands. Empty\n * while nothing has been asked (`hasAsked`).\n *\n * It describes `result.own`, not `result.config`: under a host scope filter\n * the two differ, and only the first is addressed by the paths this editor\n * takes — so `clearValue(item.path)` takes out the condition the badge names\n * (each of `item.paths`, for a segment). The scope's own conditions are\n * `scoped`.\n *\n * A dashboard has no conditions of its own to describe (D27): a reader\n * narrows it through its filters, which are a bar of their own, so this\n * is empty there. What it holds in force besides is `fixed`.\n *\n * A draft over the tree budget does not empty it. What the rows came back\n * under was admitted before it ran, so it is within budget whatever the\n * draft has since become, and a summary that blanked while the user edited\n * would stop describing the data it sits beside.\n */\n applied: FilterSummaryItem[];\n /**\n * The host's own conditions, in force alongside `applied` but not this\n * editor's to change: `setScopeFilter` injects them, the draft never holds\n * them, and no path here addresses them. A bar shows them as plain items,\n * with no remove — `clearValue` cannot reach them, and offering it would\n * promise a narrowing the user cannot undo. Empty when no scope is injected.\n */\n scoped: FilterSummaryItem[];\n /**\n * A dashboard's fixed scope (「固定范围」, `DashboardViewConfig.fixed`, D26\n * Q31): the board's own condition every panel runs under, in force beside\n * its filters and no reader's to change — so, like `scoped`, a bar shows it\n * with no remove, and no path here addresses it. Read off `applied`, as a\n * dashboard's `applied` is. Empty for any other view, and on a board built\n * since batch C.\n */\n fixed: FilterSummaryItem[];\n /**\n * Readings in force that nobody wrote: a declared deletion dimension the\n * view's own conditions and the host's scope both leave unanswered reads\n * as \"not deleted\" (D17-2), and a bar that kept quiet about it would be\n * describing rows it does not show. Like `scoped`, nothing here is the\n * editor's to remove; unlike it, adding the field is how it changes.\n */\n implied: FilterSummaryItem[];\n count: number;\n /** False when the tree needs the advanced editor to be shown faithfully. */\n simple: boolean;\n /**\n * True when the draft says something other than what was last applied —\n * anywhere in the config, not only in the conditions (D17-6). Apply runs\n * the whole draft, so its dot answers for the whole draft: a sort or a\n * page size whose apply was refused, an analysis editor's groups waiting\n * for Run, a filter mode switched and not applied. See `comparePending`.\n */\n pending: boolean;\n /**\n * How many edits wait for Apply; a badge count. The conditions count node\n * by node, both ways — a path the draft has and the applied tree does not\n * is a new condition, and a path only the applied tree has is one removed\n * since, so a cleared filter counts every condition it dropped — and every\n * other member of the config that differs counts as one.\n */\n pendingCount: number;\n /**\n * Whether the conditions themselves differ from the ones applied. This is\n * what `discard` can put back, so the offer to discard follows it rather\n * than `pending`: a sort waiting for apply is pending, and discarding the\n * conditions would not touch it.\n */\n conditionsPending: boolean;\n /**\n * Whether the node at `path` has been edited since the last apply. Compares\n * that node alone — a leaf by field, operator and value, a group by its\n * operator — so one edited condition marks one pill, not its ancestors too.\n * A node the applied tree has nothing at is pending: it is new. A node only\n * the applied tree has is pending too: it is gone.\n */\n isPending(path: FilterPath): boolean;\n /**\n * How many `issues` block apply by addressing a condition of this filter.\n * Every one of them counts, including the ones the panel can draw no pill\n * for — a malformed node has nothing to render — because Apply is refused\n * for those just the same, and a count that left them out would be a\n * button that stays disabled with nothing to show for it. What has no pill\n * is said in the strip above the editor (`unmarkedErrors`), so the count\n * never points at a fix that is nowhere on screen.\n */\n blocked: number;\n /**\n * The blocking errors the panel can draw on no pill, which is where the\n * count above points when it points at nothing: a malformed node has\n * nothing to render, a group wears no marker of its own, and an error\n * about the rest of the config — a column the definition dropped, a page\n * size it no longer admits — was never this editor's to mark. A surface\n * shows these in the strip above the editor.\n *\n * The pair of `blocked`: together they account for every error that stops\n * the view, one on the pills and one in the strip, with neither said twice.\n */\n unmarked: Issue[];\n setMode(mode: FilterMode): void;\n clear(): void;\n /** Applies the draft, which is what runs the query. */\n submit(): void;\n /**\n * Puts the draft conditions back to the ones last applied, and runs\n * nothing.\n *\n * It is an `edit` with no `apply` on purpose: the result on screen was\n * already fetched under `state.applied.filter`, so restoring that tree\n * leaves the query and the rows exactly as they are — re-running would\n * spend a request to arrive at the answer already there. `pending` falls\n * to false because the two trees agree again, which is the whole point.\n *\n * It is not `commands.revert`, which is about the *saved* config: revert\n * throws away every unsaved edit of the view and makes the stored one the\n * draft again. This throws away the unapplied conditions alone and touches\n * neither the saved config nor the columns, sort or paging.\n */\n discard(): void;\n /** Auto-refresh pauses between these two, so typing is never interrupted. */\n focus(): void;\n blur(): void;\n}\n\n/** The Issue of a query the source rejected for a named rule (D40). */\nfunction isRejection(found: Issue): boolean {\n return found.code.startsWith('runtime.query.failed.');\n}\n\n/**\n * The failed query's Issue, when it names a condition of the view's own\n * filter (`queryFailureIssue`) that `tree` still holds at that path on the\n * same field — an edit that moved or replaced it leaves nothing to mark.\n */\nfunction rejectedCondition(\n error: Issue | undefined,\n tree: FilterTree,\n): Issue | null {\n if (!error || !isRejection(error) || error.path[0] !== 'children')\n return null;\n const name = error.params?.name;\n if (typeof name !== 'string') return null;\n const node = nodeAt(tree, filterIndexes(error.path));\n if (!node || isFilterGroup(node)) return null;\n return node.field === name || name.startsWith(`${node.field}.`)\n ? error\n : null;\n}\n\nconst ROOT: FilterPath = [];\nconst EMPTY_GROUPS: readonly FieldGroupDefinition[] = [];\n/** Stable identity for \"no runtime yet\", so the memo below stays quiet. */\nconst EMPTY_FIELDS: readonly FieldDefinition[] = [];\n/** Stable identity for \"no runtime yet\"; every edit produces a new tree. */\nconst EMPTY_TREE: FilterTree = { op: 'and', children: [] };\n/** Stable identity for \"no runtime yet\", so `unmarked` stays still. */\nconst EMPTY_ISSUES: readonly Issue[] = [];\nconst NOTHING_PENDING: PendingReport = {\n pending: false,\n count: 0,\n conditions: false,\n};\n\n/**\n * The tree the applied bar describes: the one the rows on screen came back\n * under, or — before any rows have — the one the question on its way (or the\n * one that failed) was sent under.\n *\n * A data view reads its result first, which is the whole reason the bar\n * does not follow `applied`: between apply and answer the two differ, and\n * the rows on screen answer the older one. With no rows on screen there is\n * nothing for the newer one to contradict, and a bar that waited for the\n * first answer appeared as it landed and pushed the result down the page;\n * `hasAsked` says a query was sent, and a query that was sent was admitted,\n * so the tree is within budget. A dashboard asks nothing of its own — the\n * panels hold the queries, under no condition of the board's but its fixed\n * scope and its filters (D27) — so there is no tree to describe.\n */\nfunction askedFilter(\n state: ViewRuntimeState<ViewConfig> | null,\n): FilterTree | undefined {\n if (!state || state.applied.kind === 'dashboard') return undefined;\n if (state.result) return ownFilter(state.result.own);\n return hasAsked(state) ? state.applied.filter : undefined;\n}\n\n/** A view's own conditions; none for a dashboard, which has none (D27). */\nfunction ownFilter(config: ViewConfig | undefined): FilterTree | undefined {\n return config?.kind === 'dashboard' ? undefined : config?.filter;\n}\n\n/** A dashboard's fixed scope in force, when it holds a condition at all. */\nfunction fixedScope(\n runtime: ViewRuntime | null,\n state: ViewRuntimeState<ViewConfig> | null,\n): FilterTree | undefined {\n if (runtime?.kind !== 'dashboard' || !state) return undefined;\n const fixed: unknown = (state.applied as { fixed?: unknown }).fixed;\n return isFilterGroup(fixed) ? fixed : undefined;\n}\n\n/**\n * Editing of the draft filter tree, addressed by path.\n *\n * It holds no state of its own: every action is an `edit` on the runtime, so\n * two editors over one view agree, and undo is just not submitting. Over a\n * dashboard there is no tree to edit (D27): the tree is empty, and every\n * edit of it does nothing.\n */\nexport function useFilterEditor(\n runtime: ViewRuntime | null,\n): FilterEditorController {\n const state = useViewRuntime(runtime);\n // A dashboard's fields come from its draft rather than from a definition,\n // so this follows the state and not the runtime's identity.\n const fields = useMemo(\n () => runtime?.fields ?? EMPTY_FIELDS,\n // eslint-disable-next-line react-hooks/exhaustive-deps -- `fields` is a getter over `state`\n [runtime, state],\n );\n const kinds = runtime?.kinds;\n // The runtime whose conditions are edited here: none on a dashboard.\n const owner = runtime?.kind === 'dashboard' ? null : runtime;\n const tree = ownFilter(state?.draft) ?? EMPTY_TREE;\n // The budget findings of this filter alone. An analysis metric's or a\n // dashboard panel's own filter reports the very same codes, so the code\n // alone would let an oversized tree the editor does not draw switch off\n // `isPending` for the root tree — the path is what says the finding is\n // this filter's, exactly as `issues` below reads it.\n const overBudget = filterOverBudget(state?.issues ?? EMPTY_ISSUES);\n\n /**\n * Edits compose within one event: `edit` is synchronous, so each action\n * reads the tree the runtime holds now rather than the one its render\n * closed over — which is what `current` is for.\n */\n const change = useCallback(\n (update: (current: FilterTree) => FilterTree) => {\n const draft = runtime?.getSnapshot().draft;\n if (!runtime || !draft || draft.kind === 'dashboard') return;\n runtime.edit({ filter: update(draft.filter) });\n },\n [runtime],\n );\n\n // `validateFilter` addresses a node by its path (`[0]`, `[1, 0]`), so the\n // code is what says an Issue belongs to the filter at all — and the path\n // is what says it belongs to *this* filter: an element's or a dashboard\n // panel's own filter is validated in its own scope and re-pathed under\n // ['elements', …] or ['panels', …], which would otherwise mark top-level\n // conditions as invalid.\n //\n // A query the service rejected for one condition marks that condition too\n // (D40): the runtime addresses its Issue to the applied tree's condition\n // on the field the service named, and it is drawn on the draft's pill for\n // as long as the draft still holds that condition there.\n const issues = useMemo(() => {\n const found = (state?.issues ?? EMPTY_ISSUES).filter(\n entry =>\n entry.code.startsWith('config.filterMode.') ||\n (entry.code.startsWith('filter.') && isRootFilterIssue(entry)),\n );\n const rejected = rejectedCondition(state?.query.error, tree);\n return rejected ? [...found, rejected] : found;\n }, [state, tree]);\n const fieldGroups =\n runtime?.definition.kind === 'data'\n ? (runtime.definition.fieldGroups ?? EMPTY_GROUPS)\n : EMPTY_GROUPS;\n // The editing itself is `treeController`, bound to the runtime: it is the\n // same controller a nested editor runs over a leaf's value, so the nine\n // actions live once. What this hook adds is the view around the tree.\n const base = useMemo(\n () =>\n treeController({\n tree,\n fields,\n fieldGroups,\n kinds,\n issues,\n current: () => ownFilter(owner?.getSnapshot().draft) ?? tree,\n onChange: next => owner?.edit({ filter: next }),\n optionSource: remote => runtime?.optionSource(remote) ?? null,\n valueCandidates: field => runtime?.valueCandidates(field) ?? null,\n }),\n [tree, fields, fieldGroups, kinds, issues, runtime, owner],\n );\n\n // What \"not applied yet\" is measured against is the tree `apply` promoted,\n // which is not the one the result carries: between the two a query is in\n // flight, and the editor must not go on offering to apply what it just did.\n const inForce = ownFilter(state?.applied) ?? EMPTY_TREE;\n\n // An over-budget draft is not compared at all. It is deeper or wider than\n // admission allows — a tree from a store may even hold a cycle — so\n // walking it once per render would be work spent on conditions the panel\n // refuses to draw, and it already blocked apply. Nothing about it is\n // pending because nothing about it can be applied.\n const isPending = useCallback(\n (path: FilterPath) =>\n !overBudget && !sameFilterNode(nodeAt(tree, path), nodeAt(inForce, path)),\n [overBudget, tree, inForce],\n );\n\n // The whole config, not the tree alone: Apply runs all of it (D17-6).\n const pending = useMemo(\n () =>\n state\n ? comparePending(state.draft, state.applied, state.issues)\n : NOTHING_PENDING,\n [state],\n );\n\n return {\n ...base,\n mode:\n state && state.draft.kind !== 'dashboard'\n ? state.draft.filterMode\n : 'simple',\n // The result's own config, which was admitted before it ran and is\n // therefore within budget by construction — an over-budget draft blocked\n // apply, so it is not what produced these rows and does not silence what\n // did. `own` rather than `config`: a merged scope moves every path.\n applied: useMemo(() => {\n const ran = askedFilter(state);\n return !ran || !kinds ? [] : describeFilter(fields, ran, kinds);\n }, [state, fields, kinds]),\n // The scope in force now rather than the one the result ran under: it is\n // the host's statement about what the user is looking at, and a host that\n // narrows it has narrowed the question before the answer arrives.\n scoped: useMemo(\n () => {\n const scope = runtime?.scopeFilter;\n return !scope || !kinds ? [] : describeFilter(fields, scope, kinds);\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps -- `scopeFilter` is a getter the runtime notifies through\n [runtime, state, fields, kinds],\n ),\n // The board's own, which the reader sees in force and cannot take out.\n fixed: useMemo(() => {\n const fixed = fixedScope(runtime, state);\n return !fixed || !kinds ? [] : describeFilter(fields, fixed, kinds);\n }, [runtime, state, fields, kinds]),\n // Against the same trees the lists above describe: what ran, and what\n // the host and the board hold in force beside it.\n implied: useMemo(() => {\n const ran = askedFilter(state);\n return !ran || !kinds\n ? []\n : impliedDeletion(\n fields,\n [ran, runtime?.scopeFilter, fixedScope(runtime, state)],\n kinds,\n );\n }, [runtime, state, fields, kinds]),\n count: countLeaves(tree),\n simple: isSimpleTree(tree),\n pending: pending.pending,\n pendingCount: pending.count,\n conditionsPending: pending.conditions,\n isPending,\n // Conditions only: an error elsewhere in the config blocks apply too, but\n // it is not this editor's to count. Within the tree every error counts,\n // pill or no pill — a malformed node the panel skips still stops apply,\n // and the strip above the editor is where it is read.\n // A rejected condition marks its pill but blocks nothing: the draft is\n // admitted, and the service is the one that refused it.\n blocked: issues.filter(\n found =>\n found.severity === 'error' &&\n found.path[0] === 'children' &&\n !isRejection(found),\n ).length,\n // Over every finding of the view rather than over `issues`, which is\n // narrowed to this tree: an error about the columns or the page size is\n // marked nowhere either, and the strip is the only place it is read.\n unmarked: useMemo(\n () => unmarkedErrors(state?.issues ?? EMPTY_ISSUES, tree),\n [state, tree],\n ),\n setMode: useCallback(\n (mode: FilterMode) => owner?.edit({ filterMode: mode }),\n [owner],\n ),\n clear: useCallback(() => change(clearFilter), [change]),\n submit: useCallback(() => runtime?.apply(), [runtime]),\n // Read off the snapshot rather than off `inForce`, for the same reason\n // every other command here does: `edit` is synchronous, so the tree put\n // back is the one the runtime holds at the moment of the click.\n discard: useCallback(() => {\n const applied = runtime?.getSnapshot().applied;\n if (!runtime || !applied || applied.kind === 'dashboard') return;\n runtime.edit({ filter: applied.filter });\n }, [runtime]),\n focus: useCallback(() => runtime?.setEditing(true), [runtime]),\n blur: useCallback(() => runtime?.setEditing(false), [runtime]),\n };\n}\n\n/**\n * Keeps a leaf's value usable when its operator changes.\n *\n * Each operator implies a value shape — `EQ` takes one number, `BETWEEN` two,\n * `IN` a list — so carrying the old value across a switch would mark the row\n * invalid the moment the user picked a different operator, and block apply on\n * a mistake they did not make. The kind decides: a value its new operator\n * still admits is left alone, so `GT` to `GTE` keeps what was typed, and only\n * a value the new operator rejects is replaced by that operator's empty one.\n *\n * A patch that carries its own value is the editor writing what the user\n * typed, and is never second-guessed.\n */\nfunction reseedValue(\n previous: FilterLeaf,\n next: FilterLeaf,\n patch: Partial<FilterLeaf>,\n byName: ReadonlyMap<string, FieldDefinition>,\n kinds: FieldKindRegistry | undefined,\n): FilterLeaf {\n if (patch.operator === undefined || patch.operator === previous.operator)\n return next;\n if ('value' in patch) return next;\n\n const field = byName.get(next.field);\n if (!field || !kinds) return next;\n const kind = kinds.get(field.kind);\n if (!kind) return next;\n\n const admitted = kind.validate({\n value: next.value,\n operator: next.operator,\n field,\n kinds,\n path: [],\n });\n if (!admitted.some(found => found.severity === 'error')) return next;\n\n return {\n ...next,\n value: kind.emptyValue(next.operator, field) as FilterLeaf['value'],\n };\n}\n\n/**\n * The part of the controller that edits a tree, and nothing about the view\n * around it.\n *\n * `useFilterEditor` is one implementation, bound to a runtime's draft. A\n * condition that holds a condition — an element match — is another, bound to\n * a leaf's value, and the two render through the same components because the\n * thing being edited is the same thing.\n */\nexport interface FilterTreeController {\n tree: FilterTree;\n fields: readonly FieldDefinition[];\n /** The picker groups the definition declares; none for a dashboard's or an element's fields. */\n fieldGroups: readonly FieldGroupDefinition[];\n /** The registry admission used, so a nested editor admits by the same one. */\n kinds: FieldKindRegistry | undefined;\n issues: Issue[];\n addLeaf(field: string, parent?: FilterPath): void;\n /**\n * Fields a new condition may be added on under `parent`: every field not\n * already a condition of that group, since a group holds one condition per\n * field, and of a kind the registry knows, since a condition cannot be made\n * on one it does not. The picker lists these rather than `fields`.\n */\n fieldsFor(parent?: FilterPath): FieldDefinition[];\n /**\n * Sets a condition back to \"nothing said yet\": its value becomes the\n * kind's empty value for its operator, so the row stays and the condition\n * leaves the query. On a group, every condition in it. This is what the\n * applied summary's remove does — it takes a condition out of force without\n * taking the field away from the editor.\n */\n clearValue(path: FilterPath): void;\n updateLeaf(path: FilterPath, patch: Partial<FilterLeaf>): void;\n addGroup(op: FilterGroupOperator, parent?: FilterPath): void;\n updateGroup(path: FilterPath, op: FilterGroupOperator): void;\n /**\n * Flips the condition at `path` between itself and \"not itself\": a leaf is\n * wrapped in a `nor` group of its own, a leaf already alone in one is\n * unwrapped. `path` is the leaf's, as the pill holds it. This is simple\n * mode's switch (D18-7); advanced mode has the group operator for it.\n */\n negate(path: FilterPath): void;\n /**\n * Takes out whatever `path` names — and the negation around it, when the\n * path is that of a leaf alone in one. A caller holds a condition by its\n * leaf's path whether or not it is negated, so this is the only removal\n * either kind of pill needs (`removeConditionAt`).\n */\n remove(path: FilterPath): void;\n operatorsFor(field: string): FilterOperatorName[];\n editorFor(path: FilterPath): EditorDescriptor | null;\n /**\n * The remote candidates behind a `remote` editor's key, from the runtime\n * this editor is bound to; `null` where the host wired none, and absent\n * on a controller with no runtime at all. A nested editor over a leaf's\n * value shares its parent's.\n */\n optionSource?(remote: string): OptionSource | null;\n /**\n * The values the condition at `path` may be picked from, counted from the\n * data (`ViewRuntime.valueCandidates`), or `null` where none are offered:\n * its field is not one the data can list, or its operator takes something\n * other than one of the field's own values — a substring, a range, no\n * value at all. Absent on a controller whose fields are not the view's\n * own: a nested predicate's are an element's, which the view's data does\n * not count.\n */\n valueCandidates?(path: FilterPath): ValueCandidateSource | null;\n}\n\nexport interface TreeControllerInput {\n tree: FilterTree;\n fields: readonly FieldDefinition[];\n fieldGroups?: readonly FieldGroupDefinition[];\n kinds: FieldKindRegistry | undefined;\n /** Issues already rebased onto this tree. */\n issues: Issue[];\n /**\n * The tree an action reads at the moment it runs, where that is not the\n * `tree` it was built over: an editor bound to a runtime reads the draft\n * the runtime holds at the click, so two edits in one event compose —\n * adding a group and then a leaf inside it works. Left out, actions read\n * `tree`, which is what a nested editor over a leaf's value wants.\n */\n current?(): FilterTree;\n onChange(tree: FilterTree): void;\n /** See `FilterTreeController.optionSource`. */\n optionSource?(remote: string): OptionSource | null;\n /** The candidate source of a field by name; see `FilterTreeController.valueCandidates`. */\n valueCandidates?(field: string): ValueCandidateSource | null;\n /**\n * Whether a condition here may be a time since another moment (N3's\n * `EXPRESSION`). Left out, it may; one entry of an element is asked\n * nothing of the kind — Wow keeps it out of `ELEMENT_MATCH` — so the\n * predicate block says `false`.\n */\n durations?: boolean;\n}\n\n/** The tree with the node at `path` set to say nothing; see `clearValue`. */\nfunction blankAt(\n tree: FilterTree,\n path: FilterPath,\n byName: ReadonlyMap<string, FieldDefinition>,\n kinds: FieldKindRegistry | undefined,\n): FilterTree {\n const blankLeaf = (leaf: FilterLeaf): FilterLeaf => {\n const field = byName.get(leaf.field);\n const kind = field && kinds?.get(field.kind);\n if (!field || !kind) return leaf;\n return {\n ...leaf,\n value: kind.emptyValue(leaf.operator, field) as FilterLeaf['value'],\n };\n };\n const blankNode = (node: FilterNode): FilterNode =>\n isFilterGroup(node)\n ? { ...node, children: node.children.map(blankNode) }\n : blankLeaf(node);\n if (path.length === 0) return blankNode(tree) as FilterTree;\n return updateAt(tree, path, blankNode);\n}\n\n/** The fields a condition can still be added on at `parent`; see `fieldsFor`. */\nfunction addableFields(\n tree: FilterTree,\n fields: readonly FieldDefinition[],\n parent: FilterPath,\n kinds: FieldKindRegistry | undefined,\n): FieldDefinition[] {\n // A negated condition is still this group's condition on its field, which\n // is why the kernel's `conditions` is asked rather than the children read:\n // the wrapper it is stored in is the kernel's to know.\n const used = new Set(\n conditions(nodeAt(tree, parent)).map(condition => condition.leaf.field),\n );\n // A field whose kind the registry does not know is left out, because\n // `addLeaf` refuses it: there is no default operator to seed and no empty\n // value to start from, so the row it offered did nothing when clicked.\n // A condition a stored config already holds on such a field is a different\n // question — the definition changed under a saved view — and the panel\n // still draws it, read-only. A field left with no operator at all — its\n // source admits no condition on it (capabilities.md 5) — is left out too:\n // what the source cannot do is not offered.\n return fields.filter(field => {\n if (used.has(field.name)) return false;\n const kind = kinds?.get(field.kind);\n return kind !== undefined && operatorsOf(field, kind).length > 0;\n });\n}\n\n/** See `FilterTreeController.valueCandidates`. */\nfunction candidatesAt(\n tree: FilterTree,\n path: FilterPath,\n byName: ReadonlyMap<string, FieldDefinition>,\n kinds: FieldKindRegistry | undefined,\n sourceOf: (field: string) => ValueCandidateSource | null,\n): ValueCandidateSource | null {\n const node = nodeAt(tree, path);\n if (!node || isFilterGroup(node)) return null;\n if (!VALUE_CANDIDATE_OPERATORS.includes(node.operator)) return null;\n const field = byName.get(node.field);\n const kind = field && kinds?.get(field.kind);\n // The kind decides what the value is typed into, and a list of values\n // replaces only a text box: a kind drawing anything else has a control of\n // its own for this operator.\n if (!field || kind?.editor(node.operator, field, node.value).input !== 'text')\n return null;\n return sourceOf(node.field);\n}\n\n/**\n * A controller over any tree. It holds no state: every action produces the\n * next tree and hands it to `onChange`, which is what lets a nested one write\n * straight back into the leaf that carries it.\n */\nexport function treeController(\n input: TreeControllerInput,\n): FilterTreeController {\n const { tree, fields, kinds, issues, onChange } = input;\n const byName = new Map(fields.map(field => [field.name, field]));\n const sourceOf = input.valueCandidates;\n const change = (update: (current: FilterTree) => FilterTree) =>\n onChange(update(input.current?.() ?? tree));\n\n return {\n tree,\n fields,\n fieldGroups: input.fieldGroups ?? [],\n kinds,\n issues,\n ...(input.optionSource ? { optionSource: input.optionSource } : {}),\n ...(sourceOf\n ? {\n valueCandidates: (path: FilterPath) =>\n candidatesAt(tree, path, byName, kinds, sourceOf),\n }\n : {}),\n fieldsFor(parent = ROOT) {\n return addableFields(tree, fields, parent, kinds);\n },\n clearValue(path) {\n change(current => blankAt(current, path, byName, kinds));\n },\n addLeaf(field, parent = ROOT) {\n const definition = byName.get(field);\n const kind = definition && kinds?.get(definition.kind);\n if (!definition || !kind) return;\n const allowed = operatorsOf(definition, kind);\n const operator = allowed.includes(kind.defaultOperator)\n ? kind.defaultOperator\n : allowed[0];\n if (!operator) return;\n change(current =>\n insertAt(current, parent, {\n field,\n operator,\n value: kind.emptyValue(operator, definition) as FilterLeaf['value'],\n }),\n );\n },\n updateLeaf(path, patch) {\n change(current =>\n updateAt(current, path, node => {\n if ('children' in node) return node;\n const next = { ...node, ...patch };\n return reseedValue(node, next, patch, byName, kinds);\n }),\n );\n },\n addGroup(op, parent = ROOT) {\n change(current => insertAt(current, parent, { op, children: [] }));\n },\n updateGroup(path, op) {\n if (path.length === 0) {\n change(current => (current.op === op ? current : { ...current, op }));\n return;\n }\n change(current =>\n updateAt(current, path, node =>\n 'children' in node ? { ...node, op } : node,\n ),\n );\n },\n negate(path) {\n change(current => negateAt(current, path));\n },\n remove(path) {\n change(current => removeConditionAt(current, path));\n },\n operatorsFor(field) {\n const definition = byName.get(field);\n const kind = definition && kinds?.get(definition.kind);\n if (!definition || !kind) return [];\n // A time since another moment needs another time to run from: with\n // none beside this one, or inside one entry, it is not offered.\n const durations =\n input.durations !== false &&\n fields.some(entry => entry.name !== field && holdsTime(entry));\n return operatorsOf(definition, kind).filter(\n operator => durations || !isDurationOperator(operator),\n );\n },\n editorFor(path) {\n const node = nodeAt(tree, path);\n if (!node || 'children' in node) return null;\n const definition = byName.get(node.field);\n const kind = definition && kinds?.get(definition.kind);\n return kind && definition\n ? kind.editor(node.operator, definition, node.value)\n : null;\n },\n };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { RecordKey } from '../model/index.js';\nimport type { RecordPaging, RecordRow } from '../record/index.js';\nimport type { RecordViewRuntime } from '../runtime/index.js';\n\n/**\n * Which rows a set of rows is: the question that fetched them and the page\n * of its answer. Two results with the same mark are the same rows asked for\n * again — a refresh — and two with different marks are a different set, even\n * where a key turns up in both.\n *\n * The question is the applied config by identity (`ViewResult.own`): it is a\n * new object exactly when `apply` promotes a draft — a condition, a sort — and\n * the same one across every refresh of it.\n */\nexport interface RowsMark {\n readonly question: unknown;\n readonly page: number | string | null;\n}\n\n/** Where the last plain toggle landed, and among which rows. */\nexport interface SelectionAnchor {\n readonly key: RecordKey;\n readonly rows: RowsMark;\n}\n\ntype RecordSnapshot = ReturnType<RecordViewRuntime['getSnapshot']>;\n\n/** The rows on screen and their mark, or `null` before any record result. */\nexport function rowsOnScreen(\n snapshot: RecordSnapshot,\n): { rows: readonly RecordRow[]; mark: RowsMark } | null {\n const result = snapshot.result;\n if (!result || result.data.kind !== 'record') return null;\n const view = result.data.view;\n return {\n rows: view.rows,\n mark: { question: result.own, page: pageOf(view.paging) },\n };\n}\n\n/**\n * The page a result is. A cursor result does not say which page it is, only\n * the way on — and that is one per page, which is all a mark needs.\n */\nfunction pageOf(paging: RecordPaging): number | string | null {\n return paging.mode === 'paged' ? paging.index : paging.nextCursor;\n}\n\n/**\n * The anchor a range extends from, when it still stands among these rows:\n * set on this very page of this very question, and its row still on it.\n */\nexport function standingAnchor(\n anchor: SelectionAnchor | null,\n rows: readonly RecordRow[],\n mark: RowsMark,\n): RecordKey | null {\n if (\n anchor === null ||\n anchor.rows.question !== mark.question ||\n anchor.rows.page !== mark.page\n )\n return null;\n return rows.some(row => row.key === anchor.key) ? anchor.key : null;\n}\n\n/**\n * The selection after `key` is toggled — alone, or with every row between\n * `anchor` and it when there is an anchor to extend from.\n *\n * A range goes the way the pressed row goes: pressing an unselected row\n * selects the range, pressing a selected one unselects it, which is the rule\n * every file manager and mail client keeps. Rows are taken in result order,\n * so a range pressed upwards covers what one pressed downwards would.\n * Selected rows outside the range are left as they are.\n */\nexport function toggledSelection(\n selection: readonly RecordKey[],\n rows: readonly RecordRow[],\n key: RecordKey,\n anchor: RecordKey | null,\n): RecordKey[] {\n const selecting = !selection.includes(key);\n const from = anchor === null ? -1 : rows.findIndex(row => row.key === anchor);\n const to = rows.findIndex(row => row.key === key);\n const range =\n from < 0 || to < 0\n ? [key]\n : rows\n .slice(Math.min(from, to), Math.max(from, to) + 1)\n .map(row => row.key);\n if (!selecting) {\n const leaving = new Set(range);\n return selection.filter(entry => !leaving.has(entry));\n }\n const held = new Set(selection);\n return [...selection, ...range.filter(entry => !held.has(entry))];\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useEffect, useState } from 'react';\nimport type { Issue, RecordData, RecordKey } from '../model/index.js';\nimport {\n detailSections,\n type DetailSection,\n type RecordRow,\n} from '../record/index.js';\nimport type { RecordViewRuntime } from '../runtime/index.js';\nimport { recordReadIssue } from '../runtime/issues.js';\nimport { rowsOnScreen } from './recordSelection.js';\nimport { useViewRuntime } from './useViewEngine.js';\n\n/**\n * Who says which record the detail has open, as `value` and `onChange` say\n * it on an input.\n *\n * Leaving `open` out lets the detail own it: a press on a row opens that\n * row, the close button closes it. Passing it — a key, or `null` for none —\n * puts the host in charge: every later value opens what it names, whether or\n * not that record is on the page, and a press or a close only asks\n * (`onOpenChange`), so a host that keeps the key in its address (`?id=`)\n * opens the same record from the link.\n */\nexport interface RecordDetailControl {\n /**\n * The record open in the detail, by its row key, or `null` for none. A key\n * is matched against the page's rows as it is (`===`): hand it over in the\n * type the rows carry it in.\n */\n open?: RecordKey | null;\n /**\n * Told whenever the reader opens a record (its key) or closes the detail\n * (`null`) — in either mode, so a host can follow the detail without owning\n * it. Not told when `open` itself changes: that is the host's own doing.\n */\n onOpenChange?(key: RecordKey | null): void;\n}\n\nexport interface RecordDetailController {\n /** The record open in the detail, or `null` while none is. */\n key: RecordKey | null;\n /**\n * What the detail shows: the whole record once it has come, and the row\n * the page already had until then — so the detail opens at once, with what\n * was on screen, and fills in rather than blinking empty first. `null`\n * while a record opened by its key alone (a link to one not on the page)\n * has not been read yet, and after it could not be.\n */\n record: RecordData | null;\n /** Whether `record` is the whole record rather than the page's row. */\n complete: boolean;\n /** Reading the whole record. */\n loading: boolean;\n /**\n * Why the whole record could not be read, in the source's words:\n * `record.detail.forbidden` when the source refused the reader\n * (HTTP 401 or 403), `record.detail.failed` otherwise.\n */\n error: Issue | null;\n /** The record is no longer there: deleted, or out of the injected scope. */\n missing: boolean;\n /** How the detail is laid out: the definition's groups (`detailSections`). */\n sections: readonly DetailSection[];\n open(row: RecordRow): void;\n close(): void;\n /** Reads the whole record again — the way out of a failed read. */\n reload(): void;\n}\n\ninterface Read {\n key: RecordKey;\n whole: RecordData | null;\n error: Issue | null;\n missing: boolean;\n /**\n * Which of the view's results the read answered, boxed so that \"no result\n * yet\" is an answer too. The detail is loading while it answers an older\n * one than the latest, or another attempt than the latest.\n */\n answered: { landed: number | undefined; attempt: number };\n}\n\n/** The page's row a record opened with, kept while that record stays open. */\ninterface Seed {\n key: RecordKey;\n row: RecordData;\n}\n\n/**\n * One record's detail (production review A2): what an operator opens to\n * read a failure whole — the message a column clipped, the stack trace no\n * column holds.\n *\n * The record is read on its own (`runtime.fetchRecord`), and read again each\n * time the view's result lands: a command run from the list or from the\n * detail refreshes the view, and the detail then says what the record is\n * now, not what it was when it was opened. A read that a newer one or a\n * close overtakes is dropped.\n *\n * A record may be opened by its key alone (`control.open`, G2): a link to\n * one the page does not hold. It then starts from the page's row when the\n * page has it, and from nothing — `loading`, then the record, `missing`, or\n * `error` — when it does not.\n */\nexport function useRecordDetail(\n runtime: RecordViewRuntime | null,\n control: RecordDetailControl = {},\n): RecordDetailController {\n const state = useViewRuntime(runtime);\n const { open: held, onOpenChange } = control;\n const controlled = held !== undefined;\n const [own, setOwn] = useState<RecordKey | null>(null);\n const key = controlled ? held : own;\n const [seed, setSeed] = useState<Seed | null>(null);\n const [read, setRead] = useState<Read | null>(null);\n const [attempt, setAttempt] = useState(0);\n const landed = state?.result?.receivedAt;\n // A closed detail forgets what it read, so opening the same record again\n // starts from the page's row rather than from an old answer — a failure\n // or a \"no longer there\" that may no longer be true.\n if (key === null && read !== null) setRead(null);\n\n useEffect(() => {\n if (!runtime || key === null) return;\n const controller = new AbortController();\n const answered = { landed, attempt };\n runtime.fetchRecord(key, controller.signal).then(\n whole => {\n if (controller.signal.aborted) return;\n setRead({ key, whole, error: null, missing: whole === null, answered });\n },\n async (failure: unknown) => {\n if (controller.signal.aborted) return;\n const error = await recordReadIssue(failure);\n if (controller.signal.aborted) return;\n // A failed read keeps what an earlier one of the same record had.\n setRead(was => ({\n key,\n whole: was?.key === key ? was.whole : null,\n error,\n missing: false,\n answered,\n }));\n },\n );\n return () => controller.abort();\n }, [runtime, key, landed, attempt]);\n\n const open = useCallback(\n (row: RecordRow) => {\n setSeed({ key: row.key, row: row.data });\n if (!controlled) setOwn(row.key);\n onOpenChange?.(row.key);\n },\n [controlled, onOpenChange],\n );\n const close = useCallback(() => {\n if (!controlled) setOwn(null);\n onOpenChange?.(null);\n }, [controlled, onOpenChange]);\n const reload = useCallback(() => setAttempt(n => n + 1), []);\n\n const current = key !== null && read?.key === key ? read : null;\n const onPage =\n key === null\n ? undefined\n : state && rowsOnScreen(state)?.rows.find(row => row.key === key)?.data;\n const shown =\n key === null\n ? null\n : (current?.whole ??\n onPage ??\n (seed?.key === key ? seed.row : null) ??\n null);\n return {\n key,\n record: shown,\n complete: current?.whole != null,\n loading:\n key !== null &&\n (current === null ||\n current.answered.landed !== landed ||\n current.answered.attempt !== attempt),\n error: current?.error ?? null,\n missing: current?.missing ?? false,\n sections: runtime ? detailSections(runtime.definition) : [],\n open,\n close,\n reload,\n };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport type { Issue, RecordData } from '../model/index.js';\nimport {\n isExportCancelledError,\n type RecordViewRuntime,\n} from '../runtime/index.js';\nimport { sourceIssue } from '../runtime/issues.js';\nimport { reportViewFailure } from '../runtime/failures.js';\nimport { toIssue } from './issues.js';\nimport type { RecordTableController } from './useRecordTable.js';\n\n/**\n * The two readings of \"export\": what is picked, and what the conditions\n * match.\n *\n * \"This page\" used to be a third, and it was an artefact of paging rather\n * than an intent (D14): on a result that fits one page it is \"all\" said\n * twice, and on one that does not it is a slice cut by the sort and the page\n * size that nobody asked for. A sample is the header's select-all followed\n * by \"selected\".\n */\nexport type RecordExportScope = 'selected' | 'all';\n\nexport interface RecordExportScopes {\n /**\n * Rows picked, and **absent** while nothing is picked: the dialog offers\n * what the view can actually do (D4), and \"export the 0 selected rows\" is\n * a choice that does nothing.\n */\n selected?: number;\n /**\n * Rows the applied conditions match, or `null` when nobody can say: a\n * cursor source reports no total, and neither does a paged one that\n * withholds it. The export still runs; only the count is unknown.\n */\n all: number | null;\n}\n\nexport interface RecordExportProgress {\n scope: RecordExportScope;\n /** Rows in hand so far. */\n fetched: number;\n /** How many there are in all, where the source says. */\n total?: number;\n}\n\n/** What one finished export produced, until the next run or `reset()`. */\nexport interface RecordExportOutcome {\n scope: RecordExportScope;\n /** Rows the file holds. */\n rows: number;\n /** The ceiling stopped the fetch short of everything that matched. */\n capped: boolean;\n /** How many rows matched in all, where the source reports a total. */\n total?: number;\n}\n\nexport interface RecordExportController {\n scopes: RecordExportScopes;\n /** The scope being exported, or `null` while nothing runs. */\n running: RecordExportScope | null;\n progress: RecordExportProgress | null;\n /** The export that finished, so the window can report what it produced. */\n outcome: RecordExportOutcome | null;\n /**\n * The failure of the last export, as one Issue. Nothing while an export is\n * running or has gone well — a file cut short by the ceiling is not a\n * failure, and says so through `outcome.capped`.\n */\n error: Issue | null;\n /**\n * Starts one export; a no-op while another is running.\n *\n * `fileName` is what the window that starts the run has already promised\n * the file will be called. It is carried to `deliver` untouched rather\n * than worked out again when the rows are in hand: the name holds a day,\n * and the export may outlive one (D14).\n */\n run(scope: RecordExportScope, fileName: string): void;\n /** Stops the run in flight. */\n cancel(): void;\n /** Forgets the last outcome or failure; it does not stop a run. */\n reset(): void;\n}\n\nexport interface RecordExportOptions {\n /**\n * What becomes of the rows once they are in hand.\n *\n * The hook gathers; `/ui` serialises and hands the file over, because how a\n * value reads and how a browser saves a file are both its answers. A\n * failure here is reported exactly like a failed fetch — from the user's\n * side \"the export did not happen\" is one outcome, not two.\n *\n * `fileName` is the name the run was started under, so the file that is\n * handed over is the file that was promised.\n */\n deliver(\n rows: readonly RecordData[],\n scope: RecordExportScope,\n fileName: string,\n ): void | Promise<void>;\n}\n\ninterface ExportState {\n running: RecordExportScope | null;\n progress: RecordExportProgress | null;\n outcome: RecordExportOutcome | null;\n error: Issue | null;\n}\n\nconst IDLE: ExportState = {\n running: null,\n progress: null,\n outcome: null,\n error: null,\n};\n\n/**\n * Exporting the result: the rows that are picked, or everything the applied\n * conditions match.\n *\n * The picked rows are already in hand — they are the result on screen — so\n * they are handed straight over. \"All\" is a query of its own: `exportRows`\n * pages the source behind the view without touching it, which is why a long\n * export leaves the rows, the paging and the selection exactly as they were.\n *\n * It asks nothing. The one question there was — \"this is more than the cap,\n * still want it?\" — is now part of the window that starts the export (D14):\n * the count and the ceiling are on screen before the button is pressed, so\n * pressing it **is** the consent, and a hook that stopped to ask again would\n * be asking twice. Where no total is known there was never anything to ask,\n * and `outcome.capped` says afterwards that the ceiling cut the file short.\n */\nexport function useRecordExport(\n runtime: RecordViewRuntime | null,\n table: RecordTableController,\n options: RecordExportOptions,\n): RecordExportController {\n const [state, setState] = useState<ExportState>(IDLE);\n // Whether an export is in flight, readable between renders: `run` refuses\n // a second one without waiting for a render, which a double click on the\n // window's button would otherwise get — the picked scope fetches nothing,\n // so `live` below is empty for it and cannot be the gate.\n const busy = useRef(false);\n // The fetch in flight, so `cancel` reaches this one and a progress report\n // from a superseded run is ignored.\n const live = useRef<AbortController | null>(null);\n // Nothing lands after the component has gone, or after the view it was\n // exporting has been left behind.\n const alive = useRef(true);\n const deliver = options.deliver;\n const delivery = useRef(deliver);\n useEffect(() => {\n delivery.current = deliver;\n }, [deliver]);\n\n useEffect(() => {\n alive.current = true;\n return () => {\n alive.current = false;\n busy.current = false;\n live.current?.abort();\n live.current = null;\n };\n }, [runtime]);\n\n const paging = table.paging;\n const scopes: RecordExportScopes = {\n ...(table.selection.length > 0 ? { selected: table.selection.length } : {}),\n all: paging?.mode === 'paged' ? (paging.total ?? null) : null,\n };\n\n const settle = useCallback((next: ExportState): void => {\n busy.current = next.running !== null;\n if (alive.current) setState(next);\n }, []);\n\n /** Serialises and saves, and turns whatever that throws into one Issue. */\n const hand = useCallback(\n async (\n rows: readonly RecordData[],\n outcome: RecordExportOutcome,\n fileName: string,\n ): Promise<void> => {\n try {\n await delivery.current(rows, outcome.scope, fileName);\n settle({ ...IDLE, outcome });\n } catch (caught) {\n // The rows were in hand; the file could not be made or handed over.\n // A fetch that failed was told by the runtime (D40).\n reportViewFailure(runtime, 'export', 'deliver', caught);\n settle({ ...IDLE, error: toIssue(caught, 'export.failed') });\n }\n },\n [settle, runtime],\n );\n\n const fetchAll = useCallback(\n async (\n runtime: RecordViewRuntime,\n total: number | null,\n fileName: string,\n ): Promise<void> => {\n const controller = new AbortController();\n live.current = controller;\n settle({\n ...IDLE,\n running: 'all',\n progress: {\n scope: 'all',\n fetched: 0,\n ...(total === null ? {} : { total }),\n },\n });\n try {\n const result = await runtime.exportRows({\n signal: controller.signal,\n onProgress: (fetched, reported) => {\n if (!alive.current || live.current !== controller) return;\n setState(current => ({\n ...current,\n progress: {\n scope: 'all',\n fetched,\n ...(reported === undefined ? {} : { total: reported }),\n },\n }));\n },\n });\n await hand(\n result.rows,\n {\n scope: 'all',\n rows: result.rows.length,\n capped: result.capped,\n ...(total === null ? {} : { total }),\n },\n fileName,\n );\n } catch (caught) {\n // A cancel is the user's own answer, not a finding: the window\n // closes and nothing is said about it.\n settle(\n isExportCancelledError(caught)\n ? IDLE\n : { ...IDLE, error: await sourceIssue(caught, 'export.failed') },\n );\n } finally {\n if (live.current === controller) live.current = null;\n }\n },\n [hand, settle],\n );\n\n const run = useCallback(\n (scope: RecordExportScope, fileName: string) => {\n if (!runtime || busy.current) return;\n busy.current = true;\n if (scope === 'selected') {\n const picked = table.selectedRows;\n // Nothing is fetched for this one — the rows are the result on\n // screen — so `running` is set only for as long as delivery takes.\n settle({ ...IDLE, running: scope });\n void hand(\n picked.map(row => row.data),\n { scope, rows: picked.length, capped: false },\n fileName,\n );\n return;\n }\n void fetchAll(\n runtime,\n paging?.mode === 'paged' ? (paging.total ?? null) : null,\n fileName,\n );\n },\n [fetchAll, hand, paging, runtime, settle, table.selectedRows],\n );\n\n const cancel = useCallback(() => {\n live.current?.abort();\n live.current = null;\n settle(IDLE);\n }, [settle]);\n\n // Closing the window forgets what the last run produced, so opening it\n // again asks rather than reporting an export the user has already read.\n // Stopping one is `cancel`; this one leaves a run in flight alone.\n const reset = useCallback(() => {\n if (!busy.current) settle(IDLE);\n }, [settle]);\n\n return { scopes, ...state, run, cancel, reset };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * What the column commands write: one column with one member changed, and\n * the whole list with the switched-off ones marked.\n *\n * **Every column here is rebuilt rather than spread over**, because a config\n * is JSON and `{ pinned: undefined }` is not the same object as one without\n * the key: it survives a `dequal` against the saved baseline as a\n * difference, and a view that was only unpinned back to where it started\n * would stay marked as unsaved for the rest of the session. The same holds\n * of a width back at automatic and of a column switched off and on again.\n *\n * They are pure functions of a column list, which is what lets the rule\n * \"hiding a column keeps everything else about it\" be read in one place\n * rather than inferred from every call site.\n */\n\nimport type { RecordColumn } from '../model/index.js';\n\n/**\n * One column entry, carrying only the members it has something to say with.\n *\n * The one place a `RecordColumn` is built, so the rule above is kept once: a\n * member that is nothing — no width, not pinned, not hidden — leaves the key\n * out altogether rather than writing `undefined` under it. The three commands\n * below and the draft's own reading of a stored list all come through here;\n * each of them used to spell the three spreads out, and four spellings of\n * \"leave the key out\" is four chances for one of them to write\n * `{ pinned: undefined }` and mark a view unsaved for ever.\n */\nexport function recordColumn(\n field: string,\n members: {\n /** Pixels, or nothing for a column that sizes itself. */\n width?: number | null;\n /** Held against the left edge, or nothing for one that scrolls (D19). */\n pinned?: boolean | null;\n /** Whether the table leaves it undrawn; only `true` is ever written. */\n hidden?: boolean;\n },\n): RecordColumn {\n return {\n field,\n ...(members.width == null ? {} : { width: members.width }),\n ...(members.pinned ? { pinned: true as const } : {}),\n ...(members.hidden ? { hidden: true as const } : {}),\n };\n}\n\n/** One column held against the table's left edge, or let go (D19). */\nexport function repinned(column: RecordColumn, pinned: boolean): RecordColumn {\n return recordColumn(column.field, {\n width: column.width,\n pinned,\n hidden: column.hidden,\n });\n}\n\n/** One column at a fixed pixel width, or back to sizing itself. */\nexport function resized(\n column: RecordColumn,\n width: number | null,\n): RecordColumn {\n return recordColumn(column.field, {\n width,\n pinned: column.pinned,\n hidden: column.hidden,\n });\n}\n\n/**\n * One column switched on or off. Everything else about it stays: hiding a\n * column clears neither its width nor its pinning, because the entry is\n * kept precisely so that showing it again puts back the column that was\n * there.\n */\nexport function shown(column: RecordColumn, visible: boolean): RecordColumn {\n return recordColumn(column.field, {\n width: column.width,\n pinned: column.pinned,\n hidden: !visible,\n });\n}\n\n/**\n * The table's columns after `fields` is what it shows.\n *\n * A column the config already knows is switched **in place** — its entry\n * kept, `hidden` written or deleted — so switching it back on puts it back\n * where it was rather than at the end. Which is why this says nothing about\n * the order: a column that is not in the list has no order to give, so the\n * order is its own command.\n *\n * Two entries leave the list instead, because they have nowhere to come\n * back to: one whose field is not in `offered` — the definition dropped it,\n * or its kind is a handle rather than something a row holds — and a second\n * entry for a column already kept. Both are one row in the column settings\n * and both are configs `validateRecord` refuses (`record.field.unknown`,\n * `record.column.duplicate`), so switching them off is the repair it has\n * always been: hiding one would leave the query and the save blocked by the\n * control that had just run.\n *\n * A named field the config does not know yet joins at the end, once however\n * many times it is named — a column has to start somewhere.\n */\nexport function withColumnsShown(\n columns: readonly RecordColumn[],\n fields: readonly string[],\n offered: ReadonlySet<string>,\n): RecordColumn[] {\n const visible = new Set(fields);\n const kept = new Set<string>();\n const placed = columns.flatMap(column => {\n if (kept.has(column.field)) return [];\n if (!visible.has(column.field) && !offered.has(column.field)) return [];\n kept.add(column.field);\n return [shown(column, visible.has(column.field))];\n });\n return [\n ...placed,\n ...fields.flatMap(field => {\n if (kept.has(field)) return [];\n kept.add(field);\n return [{ field }];\n }),\n ];\n}\n\n/**\n * The table's columns in the order `fields` names them.\n *\n * A name that is not a column is ignored and a column the caller leaves\n * unnamed keeps its place at the end, so a control that knows about part of\n * the table — one area of the column settings — cannot drop the rest of it\n * by saying nothing about it.\n *\n * The columns are all of them, the switched-off ones included: a hidden\n * column has a place in the order, which is what makes switching it back on\n * put it back where it was, so a caller that means to order the whole table\n * names it along with the rest.\n */\nexport function reordered(\n columns: readonly RecordColumn[],\n fields: readonly string[],\n): RecordColumn[] {\n const byField = new Map(columns.map(column => [column.field, column]));\n const named = new Set<string>();\n const ordered = fields.flatMap(field => {\n const column = byField.get(field);\n // A name repeated by the caller would otherwise become a second column\n // of the same field, which `validateRecord` then refuses.\n if (!column || named.has(field)) return [];\n named.add(field);\n return [column];\n });\n return [...ordered, ...columns.filter(column => !named.has(column.field))];\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * The draft's lists as a control may read them.\n *\n * **The controller is the boundary.** A config comes from a store, so\n * `sort` may be an object, a string or an array with `null` in it, and\n * `summaries` may be any of those too. `validateRecord` reports the shape\n * (`record.sort.invalid`, `record.summaries.invalid`) and the draft rightly\n * stays in the error state — but the editor that would let the user delete\n * the offending entry is rendered from that same draft, and a `.map` over a\n * string takes the workbench down before they can. So what a controller\n * hands the UI is always a safely iterable list of well-formed entries,\n * whatever the store held, and no panel needs a defensive reading of its\n * own: the next one someone writes inherits the guarantee.\n *\n * Dropping a malformed entry here is also the repair. The list the user\n * edits is the sound one, so the first change they make writes it back\n * without the entry that was never readable, and admission goes quiet.\n */\n\nimport {\n columnHidden,\n columnPinned,\n SUMMARY_FUNCTIONS,\n type RecordColumn,\n type RecordSort,\n type RecordSummary,\n type SortDirection,\n type SummaryFunction,\n} from '../model/index.js';\nimport { isPlainObject } from '../filter/index.js';\nimport { recordColumn } from './recordColumns.js';\n\n/** Entries of `value` that are objects naming a `field`; none if it is not a list. */\nfunction entries(value: unknown): Record<string, unknown>[] {\n if (!Array.isArray(value)) return [];\n return value.filter(\n (entry): entry is Record<string, unknown> =>\n isPlainObject(entry) && typeof entry.field === 'string',\n );\n}\n\n/**\n * A direction as one of the two there are.\n *\n * Anything else reads as ascending rather than being dropped: the entry\n * names a field the user chose, and the direction is the part they can flip\n * once they can see it. `validateRecord` reports the value separately.\n */\nfunction sortDirection(value: unknown): SortDirection {\n return value === 'DESC' ? 'DESC' : 'ASC';\n}\n\nexport function recordSort(value: unknown): RecordSort[] {\n return entries(value).map(entry => ({\n field: entry.field as string,\n direction: sortDirection(entry.direction),\n }));\n}\n\n/**\n * Summaries as cells that can be drawn. An entry whose function is not one\n * the model names is dropped rather than guessed at — there is no sensible\n * default for \"which number is this\", and a wrong one would be a figure on\n * screen that nobody asked for.\n */\nexport function recordSummaries(value: unknown): RecordSummary[] {\n return entries(value).flatMap(entry =>\n SUMMARY_FUNCTIONS.includes(entry.fn as SummaryFunction)\n ? [{ field: entry.field as string, fn: entry.fn as SummaryFunction }]\n : [],\n );\n}\n\n/**\n * Whether `raw` was already the sound list `read` made of it.\n *\n * A list that had to be repaired is a config the kernel refuses\n * (`record.sort.invalid`, `record.summaries.invalid`, `record.table.invalid`)\n * over entries no control can address — they are not on screen, because they\n * could not be read. So the next write of any kind carries the repair with\n * it: the user changes a column and the sort that was a string becomes the\n * list they can see, which is the same promise this module makes about\n * entries, made about the list itself.\n */\nexport function wasSound(raw: unknown, read: readonly unknown[]): boolean {\n return Array.isArray(raw) && raw.length === read.length;\n}\n\n/**\n * Columns as the draft holds them, with a width, a pinning and a visibility\n * it can use. A column switched off keeps its entry and therefore its place\n * in the order, so it is read like any other — only `hidden` says the table\n * does not draw it, and anything but `true` under that name reads as shown.\n * A pinning is read the same way (`columnPinned`): it is one yes-or-no\n * (D19), so a stored `'left'` or `'top'` is a column that scrolls.\n */\nexport function recordColumns(value: unknown): RecordColumn[] {\n return entries(value).map(entry =>\n recordColumn(entry.field as string, {\n width: typeof entry.width === 'number' ? entry.width : null,\n pinned: columnPinned(entry.pinned),\n hidden: columnHidden(entry.hidden),\n }),\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * What a record command works out before it writes, with no React in it.\n *\n * The cycle one header press walks, the ladder a page-size select offers,\n * the spelling \"no summaries\" has to be written in and the repairs a patch\n * carries along are all functions of a config and an argument. They lived\n * inside `useRecordTable`'s callbacks, where they could only be reached\n * through a rendered hook and a runtime; here they are read and tested on\n * their own, and the controller is left as edit-and-apply wiring.\n *\n * `recordColumns.ts` holds the same kind of function for a column list.\n */\n\nimport { nearestPageSize } from '../model/index.js';\nimport type {\n RecordSort,\n RecordSummary,\n RecordViewConfig,\n SortDirection,\n ViewInstance,\n} from '../model/index.js';\nimport type { ViewRuntimeState } from '../runtime/index.js';\nimport {\n recordColumns,\n recordSort,\n recordSummaries,\n wasSound,\n} from './recordDraft.js';\n\n/**\n * The sort after one press on a column header: ascending, then descending,\n * then off.\n *\n * By default the field joins the sort — a new one at the end, an existing\n * one in its place, since the order of `sort` is the priority between\n * columns — so several columns may order the rows. With `exclusive` the\n * cycled field becomes the whole sort, wherever it stood: what a plain click\n * on a header means, where Shift is what adds.\n */\nexport function cycledSort(\n current: readonly RecordSort[],\n field: string,\n exclusive: boolean,\n): RecordSort[] {\n const at = current.findIndex(entry => entry.field === field);\n // The same cycle either way: off → ascending → descending → off.\n const turned: SortDirection | null =\n at < 0 ? 'ASC' : current[at].direction === 'ASC' ? 'DESC' : null;\n if (exclusive)\n // This column alone: a plain click says \"order the rows by this\", not\n // \"also by this\".\n return turned === null ? [] : [{ field, direction: turned }];\n if (at < 0) return [...current, { field, direction: 'ASC' }];\n if (turned === null) return current.filter((_entry, index) => index !== at);\n return current.map((entry, index) =>\n index === at ? { field, direction: turned } : entry,\n );\n}\n\n/**\n * The page sizes worth offering, in order and without a repeat.\n *\n * The ladder is the engine's (`RuntimeLimits.pageSizes`): a product that\n * wants 15/30/60 hands it in with the budgets rather than shipping a build.\n * A size above `max` is refused by `validateRecord`, so offering it would be\n * offering a way to break the view — and the size the view is running at\n * joins whatever it is, since a view saved at 500 under an older limit still\n * has to show what it is running at, and a select whose value is not among\n * its options shows nothing at all.\n */\nexport function offeredPageSizes(\n ladder: readonly number[],\n max: number | undefined,\n current: number,\n): number[] {\n const offered = ladder.filter(size => max === undefined || size <= max);\n return [...new Set([...offered, ...(current > 0 ? [current] : [])])].sort(\n (left, right) => left - right,\n );\n}\n\n/**\n * The rung of the layout's ladder nearest a size the limits refuse — above\n * `max`, not a whole number, or under one — or `null` for a size they\n * admit. Only rungs the limits admit are offered.\n */\nexport function admittedPageSize(\n ladder: readonly number[],\n max: number | undefined,\n size: number | undefined,\n): number | null {\n if (size === undefined || max === undefined) return null;\n if (Number.isInteger(size) && size >= 1 && size <= max) return null;\n const admitted = ladder.filter(\n rung => Number.isInteger(rung) && rung >= 1 && rung <= max,\n );\n if (admitted.length === 0) return null;\n return nearestPageSize(admitted, Number.isFinite(size) ? size : 0);\n}\n\n/**\n * The summaries to write, in the shape the saved config uses for none.\n *\n * `summaries` is optional, so \"no summaries\" is spelled two ways — an empty\n * list, or no member at all — and `dirty` is an equality against the saved\n * config, which cannot tell the difference between a shape and a change.\n * Adding a summary and taking it away again therefore left the view unsaved\n * for the rest of the session, with the leave guard asking about an edit\n * that had already been undone. `edit` removes a member given as\n * `undefined`, so answering with the saved config's own spelling makes\n * undoing an undo.\n */\nexport function summariesOf(\n next: RecordSummary[],\n saved: ViewInstance | null,\n): RecordSummary[] | undefined {\n if (next.length > 0) return next;\n const config = saved?.config;\n return config?.kind === 'record' && config.summaries !== undefined\n ? []\n : undefined;\n}\n\n/**\n * The patch, plus the sound form of any list the draft could not be read\n * from and this patch does not already replace.\n *\n * A list the controller had to repair is a config the kernel refuses over\n * entries that are not on screen — they could not be read, so no control\n * lists them and no control can take them out. Carrying the repair along\n * with whatever the user *did* change is what makes \"the first change they\n * make writes the sound list back\" true of every list rather than only of\n * the one they touched: with no sortable field left to add, an unreadable\n * `sort` had no other way out at all.\n */\nexport function repairing(\n patch: Partial<RecordViewConfig>,\n state: ViewRuntimeState<RecordViewConfig>,\n): Partial<RecordViewConfig> {\n const draft = state.draft;\n const repairs: Partial<RecordViewConfig> = {};\n\n const sort = recordSort(draft.sort);\n if (patch.sort === undefined && !wasSound(draft.sort, sort))\n repairs.sort = sort;\n\n const summaries = recordSummaries(draft.summaries);\n if (\n !('summaries' in patch) &&\n draft.summaries !== undefined &&\n !wasSound(draft.summaries, summaries)\n )\n repairs.summaries = summariesOf(summaries, state.saved);\n\n const columns = recordColumns(draft.table?.columns);\n if (patch.table === undefined && !wasSound(draft.table?.columns, columns))\n repairs.table = { columns };\n\n return { ...repairs, ...patch };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useMemo, useRef } from 'react';\nimport type {\n FieldGroupDefinition,\n Issue,\n RecordCardSpec,\n RecordColumn,\n RecordKey,\n RecordLayout,\n RecordSort,\n RecordSummary,\n SortDirection,\n SummaryFunction,\n RuntimeLimits,\n} from '../model/index.js';\nimport {\n columnHidden,\n columnPinned,\n isFieldlessKind,\n nearestPageSize,\n} from '../model/index.js';\nimport { recordColumns, recordSort, recordSummaries } from './recordDraft.js';\nimport {\n reordered,\n repinned,\n resized,\n withColumnsShown,\n} from './recordColumns.js';\nimport {\n cycledSort,\n offeredPageSizes,\n repairing,\n summariesOf,\n admittedPageSize,\n} from './recordEdits.js';\nimport { clampPage, maxSortFields } from '../record/index.js';\nimport type {\n RecordCardView,\n RecordColumnView,\n RecordPaging,\n RecordRow,\n SummaryRow,\n} from '../record/index.js';\nimport {\n hasResult,\n type QueryStatus,\n type RecordViewRuntime,\n} from '../runtime/index.js';\nimport { pendingBesides } from '../runtime/pending.js';\nimport type { RecordViewConfig } from '../model/index.js';\nimport { useViewRuntime } from './useViewEngine.js';\nimport {\n rowsOnScreen,\n standingAnchor,\n toggledSelection,\n type SelectionAnchor,\n} from './recordSelection.js';\n\n/** How {@link RecordTableController.toggle} treats the rows around one. */\nexport interface ToggleSelectionOptions {\n /**\n * Extend from the anchor — the row the last plain toggle landed on — to\n * this one, inclusive and in result order, the way Shift+click does in a\n * file manager: the range goes the way this row goes. With no anchor\n * standing among the rows on screen it is a plain toggle, and sets one.\n */\n range?: boolean;\n}\n\n/** How {@link RecordTableController.toggleSort} treats the other columns. */\nexport interface ToggleSortOptions {\n /** Make the cycled field the whole sort rather than joining it. */\n exclusive?: boolean;\n}\n\nexport interface RecordTableController {\n /** Columns of the result on screen, which follow the executed config. */\n columns: RecordColumnView[];\n /**\n * The card layout of the same result, projected by the kernel beside the\n * columns; both halves are saved side by side.\n */\n card: RecordCardView;\n /**\n * The field that says which record a row is — the definition's row key,\n * handed on so a control that lists the columns can hold it in place\n * without reading the definition itself. Absent before a runtime exists.\n */\n rowKey?: string;\n /** The picker groups the definition declares, for the column settings. */\n fieldGroups: readonly FieldGroupDefinition[];\n /**\n * The card half of the draft, as the settings edit it — the draft rather\n * than the result's config, for the reason `columnFields` reads the\n * draft: a control shows what the user has said, and the result follows.\n */\n cardSpec: RecordCardSpec;\n /**\n * Changes the card layout — which field titles it, which make its body,\n * where its image comes from, how many stand in a row — and applies at\n * once, as `setColumns` does: the cards follow the config that ran. Like\n * every write here, only while nothing else waits (see `toggleSort`).\n */\n setCard(patch: Partial<RecordCardSpec>): void;\n rows: RecordRow[];\n /**\n * Where the result stands: the page and size that ran, the pages the\n * pager can reach and whether a window cuts them short of the total\n * (`record/paging.ts`). The pager reads these and does no arithmetic of\n * its own.\n */\n paging: RecordPaging | null;\n summaries: SummaryRow | null;\n status: QueryStatus;\n error: Issue | null;\n /** True while a query is in flight and rows are still the previous ones. */\n loading: boolean;\n /**\n * The query failed, and the rows still on screen were fetched under other\n * conditions than the ones it asked (`ViewQueryState.conditionsChanged`):\n * the rows of the old conditions, not merely older rows. Left out — a\n * controller a host builds itself — it is `false`.\n */\n conditionsChanged?: boolean;\n /**\n * Whether a result ever came back for this view — the last one that did,\n * however old it is by now.\n *\n * It is not `rows.length > 0` and not `status === 'success'`: a failed\n * refresh keeps the rows it could not replace and turns the status to\n * `error`, and a result that matched nothing has no rows. What it answers\n * is the one question a table cannot answer from rows alone — is there a\n * result underneath this status, or is the frame empty because nothing has\n * ever been executed here.\n */\n hasResult: boolean;\n /**\n * The source counts only what a condition narrows and the view has none\n * (`record.filter.required`, capabilities.md Q3): nothing is sent, and\n * the table says to add a condition rather than showing nothing.\n */\n filterRequired?: boolean;\n\n /**\n * The draft's sort: what the sort editor edits, and what the next header\n * press cycles from.\n */\n sort: RecordSort[];\n /**\n * The sort the rows on screen were fetched by — the config that ran, not\n * the draft. The header's arrows and `aria-sort` say this one: while a\n * sort waits for Apply, a header pointing down over rows that go up would\n * be lying about them. Empty before anything has run.\n */\n ranSort: RecordSort[];\n sortOf(field: string): SortDirection | null;\n /**\n * Ascending, then descending, then off.\n *\n * By default the field joins the sort — a new one at the end, an existing\n * one in its place — so several columns may order the rows. With\n * `exclusive` the cycled field is the whole sort: what a plain click on a\n * header means, where Shift is what adds. Both are one `edit` and at most\n * one `apply`; imitating exclusivity with the additive form would spend\n * one query per column being cleared.\n *\n * **It runs only when nothing else waits.** A press is about the order of\n * the rows, so it applies at once as a table does — unless the draft holds\n * another edit waiting for Apply, a range condition above all. Running\n * then would apply that edit on the user's behalf; the sort joins it\n * instead, the pending dot shows, and Apply runs the two together\n * (`pendingBesides`, the rule the analysis header keeps). Every write here\n * that edits and runs keeps this rule: the page size, the columns, their\n * order, pinning and width, the summaries, the card and a layout switch\n * that moves the page size.\n */\n toggleSort(field: string, options?: ToggleSortOptions): void;\n /**\n * Replaces the whole sort, in priority order — and runs under the same\n * rule as `toggleSort`: at once when nothing else waits, otherwise with\n * the edits waiting for Apply.\n *\n * `toggleSort` is one column's answer and can only append; an editor that\n * shows the sort as a list needs to say which field comes first, flip one\n * of them and drop one of them, and all three are the same write.\n */\n setSort(sort: RecordSort[]): void;\n /**\n * How many fields this view may sort on at once.\n *\n * A cursor is a position in one total order, and Wow bounds how many\n * fields that order may be built from, so `validateRecord` refuses a\n * longer sort and `apply` never runs: the rows keep the order they had and\n * the view sits in an error the user did not ask for. A control that\n * offers a field therefore has to stop at the ceiling. A paged source has\n * no such bound, and answers with the number of fields it could sort on.\n */\n maxSortFields: number;\n\n layout: RecordLayout;\n /**\n * The layouts the definition allows, in its order. A switcher offers these\n * and nothing else — and renders nothing at all below two.\n */\n layouts: RecordLayout[];\n setLayout(layout: RecordLayout): void;\n /**\n * Fields of the draft's table layout, in order — the columns switched\n * off among them, because a hidden column keeps its place in the order\n * and a control that lists the table's columns has to list it there.\n */\n columnFields: string[];\n /** Whether the draft has this column switched off. */\n hiddenOf(field: string): boolean;\n /**\n * Which columns the table shows, and applies at once — while nothing else\n * waits for Apply; otherwise it joins what waits (see `toggleSort`).\n *\n * A column the config already knows is switched off **in place** —\n * `hidden: true`, its entry kept — rather than taken out of the list, so\n * switching it back on puts it back where it was rather than at the end.\n * Which is also why this says nothing about the order: that is\n * {@link setColumnOrder}'s, and a column that is not in the list has no\n * order to give. A named field the config does not know yet joins at the\n * end, as a column has to start somewhere.\n *\n * A column that goes takes its summary with it: a summary belongs to a\n * column, so one left behind buys an aggregation query with nowhere to\n * appear. Each column that stays is reused as it was configured, so its\n * width and pinning survive being switched off and on again.\n *\n * The two entries that have nowhere to come back to leave the list\n * instead: a column the definition no longer offers, and a second entry\n * for a column already kept. Both are one row in the settings and both\n * are configs the kernel refuses (`record.field.unknown`,\n * `record.column.duplicate`), so switching them off is the repair it has\n * always been — hiding one would leave the query and the save blocked by\n * the control that had just run.\n */\n setColumns(fields: string[]): void;\n /**\n * Puts the draft's columns in this order and applies at once, under the\n * rule `toggleSort` keeps.\n *\n * A name that is not a column is ignored and a column the caller leaves\n * unnamed keeps its place at the end, so a control that knows about part\n * of the table — one area of the column settings — cannot drop the rest\n * of it by saying nothing about it.\n *\n * The columns are all of them, the switched-off ones included: a hidden\n * column has a place in the order, which is what makes switching it back\n * on put it back where it was, so a caller that means to order the whole\n * table names it along with the rest.\n */\n setColumnOrder(fields: string[]): void;\n /** Whether the draft holds this column against the table's left edge. */\n pinnedOf(field: string): boolean;\n /**\n * Holds a column against the left edge, or lets it go. Applies at once,\n * under the rule `toggleSort` keeps.\n *\n * There is one end to pin to (D19): the right edge is the host's action\n * column, which is a render slot rather than anything a config names.\n */\n setPinned(field: string, pinned: boolean): void;\n /**\n * Sets one column's width in pixels, or `null` to let it size itself\n * again. Applies at once, like the other column commands, and under the\n * same rule.\n *\n * The number is taken as given: how narrow a column may be dragged is a\n * question about a grab handle rather than about a config, so the table's\n * own floor lives with the handle. What the kernel refuses is a width that\n * is not a positive finite number of pixels.\n */\n setColumnWidth(field: string, width: number | null): void;\n /** The function the draft summarises a column with, if any. */\n summaryOf(field: string): SummaryFunction | null;\n /**\n * Every field the draft's summaries name, in the order they name them and\n * without a repeat.\n *\n * It is not the column list: a config may summarise a field that is not a\n * column and that the definition no longer declares, and the settings can\n * only offer the way out of such a summary if they are told it is there.\n */\n summaryFields: string[];\n /**\n * Replaces whatever a column summarised with one function, or with none.\n *\n * A config may carry several functions for one field and the table shows\n * all of them; this writes one, because a control that offers a column one\n * summary is the shape the settings have. Setting one therefore drops the\n * others on that column, and `null` leaves it without a summary. Applies\n * at once under the rule `toggleSort` keeps.\n */\n setSummary(field: string, fn: SummaryFunction | null): void;\n pageSize: number;\n /**\n * Page sizes worth offering: the layout's ladder — `limits.pageSizes` for\n * a table, `limits.cardPageSizes` for cards, which are whole rows at every\n * width — cut to what the runtime limits admit and with the current size\n * folded in. A size above\n * `maxPageSize` is refused by `validateRecord`, so offering it would be\n * offering a way to break the view — and the saved size has to be in the\n * list whatever it is, or a select shows nothing at all.\n */\n pageSizes: number[];\n /** A new size is a new query: runs under the rule `toggleSort` keeps. */\n setPageSize(size: number): void;\n /**\n * The admitted page size nearest the draft's, where the draft's is one\n * the runtime refuses (`record.pageSize.too-large`, `not-positive`), and\n * `null` otherwise: the one-press way out of a stored size the limits no\n * longer admit. Nothing else offers it — a view that will not run has no\n * result and so no pagination to pick a size in (second review R1-P1-3).\n */\n pageSizeFix: number | null;\n\n selection: RecordKey[];\n /**\n * The selected rows of the current result, in result order. A bulk action\n * needs the rows and not only their keys — it names what it is about to\n * act on — and the selection is keys alone.\n */\n selectedRows: RecordRow[];\n isSelected(key: RecordKey): boolean;\n /**\n * Selects or unselects one row, or a range with `{ range: true }`. A\n * plain toggle moves the anchor a range extends from; a range does not,\n * so a second Shift+click re-draws the range from the same row. The\n * anchor belongs to the rows on screen: another page, or another\n * question applied, lets it go — a refresh of the same page keeps it.\n */\n toggle(key: RecordKey, options?: ToggleSelectionOptions): void;\n /** Selects every row of the current result, or clears the selection. */\n toggleAll(): void;\n clearSelection(): void;\n /** Picks exactly these rows, in this order. */\n select(keys: readonly RecordKey[]): void;\n\n /**\n * Paged sources only; a cursor source has no page numbers to jump to. A\n * page past the last reachable one lands on that one — past the end, the\n * reader wants the end, and a page beyond the source's window is one the\n * source refuses.\n */\n goTo(index: number): void;\n /**\n * Whether there is a page after this one: the next cursor for a cursor\n * source; for a paged one, the pages it can reach against the page that\n * ran. A source that reports no total cannot say, so it is taken as\n * \"there may be\" — up to its window, where it declares one.\n */\n hasNext: boolean;\n /** No-op at the end, where there is no next page to ask for. */\n next(): void;\n previous(): void;\n refresh(): void;\n}\n\n/** Stable identities for \"no runtime yet\", so memo dependencies stay still. */\nconst NO_SORT: RecordSort[] = [];\nconst NO_COLUMNS: RecordColumn[] = [];\nconst NO_SUMMARIES: RecordSummary[] = [];\nconst NO_SELECTION: RecordKey[] = [];\nconst NO_ROWS: RecordRow[] = [];\nconst NO_LAYOUTS: RecordLayout[] = [];\nconst NO_CARD: RecordCardView = { title: '', fields: [] };\nconst NO_GROUPS: readonly FieldGroupDefinition[] = [];\nconst NO_CARD_SPEC: RecordCardSpec = { title: '', fields: [] };\n\n/**\n * A record view as a table renders it, with no vendor types in sight.\n *\n * Rows and columns come from the last successful result rather than the draft,\n * because the kernel projected them from the config that ran. Changing columns\n * therefore applies immediately, and so does a sort while nothing else waits\n * (`toggleSort`); changing a filter waits for submit.\n */\nexport function useRecordTable(\n runtime: RecordViewRuntime | null,\n): RecordTableController {\n const state = useViewRuntime(runtime);\n const data = state?.result?.data;\n const view = data?.kind === 'record' ? data.view : null;\n\n const rows = useMemo(() => view?.rows ?? [], [view]);\n const selection = useMemo(() => state?.selection ?? NO_SELECTION, [state]);\n const selected = useMemo(() => new Set(selection), [selection]);\n // Result order, not click order: a bulk action lists what it will touch,\n // and the list has to read like the table above it.\n const selectedRows = useMemo(\n () =>\n selection.length === 0\n ? NO_ROWS\n : rows.filter(row => selected.has(row.key)),\n [rows, selected, selection],\n );\n // Read through `recordDraft`, so what this hands the UI is always a\n // list of well-formed entries whatever the store held — see the rule\n // on that module, and `docs/design/react.md`.\n const draft = state?.draft;\n const sort = useMemo(\n () => (draft ? recordSort(draft.sort) : NO_SORT),\n [draft],\n );\n const ran = state?.result?.own;\n const ranSort = useMemo(() => (ran ? recordSort(ran.sort) : NO_SORT), [ran]);\n const tableColumns = useMemo(\n () => (draft ? recordColumns(draft.table?.columns) : NO_COLUMNS),\n [draft],\n );\n const summaries = useMemo(\n () => (draft ? recordSummaries(draft.summaries) : NO_SUMMARIES),\n [draft],\n );\n\n // One write from a control that edits and runs — the sort, the page\n // size, the columns, the summaries, the card. It runs only while nothing\n // else waits: running applies the whole draft, and a condition still\n // waiting in the range is not this control's to apply. Otherwise the\n // write joins what waits, the pending dot counts it, and Apply runs them\n // together (`pendingBesides`; the analysis header's `sortNow` keeps the\n // same rule). The repairs a patch carries (`repairing`) are this write's\n // own, so they are laid over both sides with it rather than counted as\n // someone else's edit.\n const editAndApply = useCallback(\n (patch: Partial<RecordViewConfig>) => {\n if (!runtime) return;\n const snapshot = runtime.getSnapshot();\n const repaired = repairing(patch, snapshot);\n const others = pendingBesides(snapshot, repaired);\n runtime.edit(repaired);\n if (!others) runtime.apply();\n },\n [runtime],\n );\n\n const sortNow = useCallback(\n (sort: RecordSort[]) => editAndApply({ sort }),\n [editAndApply],\n );\n\n const toggleSort = useCallback(\n (field: string, options?: ToggleSortOptions) => {\n if (!runtime) return;\n sortNow(\n cycledSort(\n recordSort(runtime.getSnapshot().draft.sort),\n field,\n options?.exclusive ?? false,\n ),\n );\n },\n [runtime, sortNow],\n );\n\n // Where the last plain toggle landed. The controller's own rather than\n // the runtime's: it is how one pair of hands is picking rows, not a fact\n // about the view, and nothing but the next toggle ever reads it.\n const anchor = useRef<SelectionAnchor | null>(null);\n const toggle = useCallback(\n (key: RecordKey, options?: ToggleSelectionOptions) => {\n if (!runtime) return;\n const snapshot = runtime.getSnapshot();\n const onScreen = rowsOnScreen(snapshot);\n const from =\n options?.range && onScreen\n ? standingAnchor(anchor.current, onScreen.rows, onScreen.mark)\n : null;\n runtime.select(\n toggledSelection(snapshot.selection, onScreen?.rows ?? [], key, from),\n );\n // A range leaves the anchor where it is; anything else is a plain\n // toggle, a Shift+click with nothing to extend from included.\n if (from === null)\n anchor.current = onScreen ? { key, rows: onScreen.mark } : null;\n },\n [runtime],\n );\n\n const toggleAll = useCallback(() => {\n if (!runtime) return;\n const keys = runtime.getSnapshot().result?.data;\n const all =\n keys?.kind === 'record' ? keys.view.rows.map(row => row.key) : [];\n runtime.select(\n runtime.getSnapshot().selection.length === all.length ? [] : all,\n );\n }, [runtime]);\n\n const paging = view?.paging ?? null;\n const pageSize = state?.draft.pageSize ?? 0;\n\n // The paging facts are the kernel's, worked out from the page and size\n // that ran; the draft's size may be a different one still on its way.\n const hasNext = paging?.hasNext ?? false;\n const definition =\n runtime?.definition.kind === 'data' ? runtime.definition : undefined;\n\n return {\n columns: view?.columns ?? [],\n // Like the columns, the card follows the config that ran rather than the\n // draft, so a body field appears with the rows it belongs to.\n card: view?.card ?? NO_CARD,\n rowKey: definition?.record?.rowKey,\n fieldGroups: definition?.fieldGroups ?? NO_GROUPS,\n cardSpec: state?.draft.card ?? NO_CARD_SPEC,\n setCard: useCallback(\n (patch: Partial<RecordCardSpec>) => {\n if (!runtime) return;\n editAndApply({\n card: { ...runtime.getSnapshot().draft.card, ...patch },\n });\n },\n [editAndApply, runtime],\n ),\n rows,\n paging,\n summaries: data?.kind === 'record' ? data.summaries : null,\n status: state?.query.status ?? 'idle',\n error: state?.query.error ?? null,\n loading: state?.query.status === 'loading',\n conditionsChanged: state?.query.conditionsChanged === true,\n hasResult: hasResult(state),\n filterRequired: (state?.issues ?? []).some(\n found => found.code === 'record.filter.required',\n ),\n\n sort,\n sortOf: useCallback(\n (field: string) =>\n sort.find(entry => entry.field === field)?.direction ?? null,\n [sort],\n ),\n ranSort,\n toggleSort,\n setSort: sortNow,\n // The kernel owns the rule; the controller only hands it on, so the\n // ceiling a control stops at is the one `validateRecord` refuses past.\n maxSortFields: definition ? maxSortFields(definition) : 0,\n\n layout: state?.draft.layout ?? 'table',\n layouts: definition?.record?.layouts ?? NO_LAYOUTS,\n setLayout: useCallback(\n (layout: RecordLayout) => {\n if (!runtime) return;\n // The page size moves to the nearest rung of the new layout's\n // ladder in the same edit: a page of cards is whole rows, a page of\n // a table is the product's ladder, and the two meet at their nearest\n // (20 rows come back as 24 cards and go back as 20). A size already\n // on the ladder stays. A new size is a new query, so it runs.\n const current = runtime.getSnapshot().draft.pageSize;\n const size = nearestPageSize(\n ladderOf(runtime.limits, layout).filter(\n rung => rung <= runtime.limits.maxPageSize,\n ),\n current,\n );\n if (size !== current) {\n editAndApply({ layout, pageSize: size });\n return;\n }\n runtime.edit({ layout });\n // Both layouts draw the same result, so switching normally needs\n // no query. A view whose saved layout the definition no longer\n // allows has no result at all, though: `apply` was refused on\n // open, `refresh` is a no-op until something has been admitted,\n // and the switch that repairs it would otherwise leave the screen\n // as empty as it found it. Under the same rule as every other\n // write here: not while another edit waits for Apply.\n const state = runtime.getSnapshot();\n if (\n state.result === null &&\n state.query.status === 'idle' &&\n !pendingBesides(state, {})\n )\n runtime.apply();\n },\n [editAndApply, runtime],\n ),\n columnFields: useMemo(\n () => tableColumns.map(column => column.field),\n [tableColumns],\n ),\n // Read through `columnHidden`, so a config that came out of a store\n // saying `hidden: 'yes'` answers \"shown\" rather than making the type\n // this declares a lie. `validateRecord` reports the value separately.\n hiddenOf: useCallback(\n (field: string) =>\n columnHidden(\n tableColumns.find(column => column.field === field)?.hidden,\n ),\n [tableColumns],\n ),\n setColumns: useCallback(\n (fields: string[]) => {\n if (!runtime) return;\n const state = runtime.getSnapshot();\n const visible = new Set(fields);\n // What a switched-off column can come back to: a field the\n // definition still offers, and that a row actually holds.\n const offered = new Set(\n (runtime.definition.kind === 'data' ? runtime.definition.fields : [])\n .filter(field => !isFieldlessKind(field.kind))\n .map(field => field.name),\n );\n // A summary belongs to a column, so a column that goes takes its\n // summary with it — in this one update. Left behind, the runtime\n // keeps asking for an aggregate with nowhere to appear: the scope\n // row stands empty, a failed aggregate warns about a summary nobody\n // can see, and the settings disable the select that would clear it.\n editAndApply({\n table: {\n columns: withColumnsShown(\n recordColumns(state.draft.table?.columns),\n fields,\n offered,\n ),\n },\n summaries: summariesOf(\n recordSummaries(state.draft.summaries).filter(summary =>\n visible.has(summary.field),\n ),\n state.saved,\n ),\n });\n },\n [editAndApply, runtime],\n ),\n setColumnOrder: useCallback(\n (fields: string[]) => {\n if (!runtime) return;\n editAndApply({\n table: {\n columns: reordered(\n recordColumns(runtime.getSnapshot().draft.table?.columns),\n fields,\n ),\n },\n });\n },\n [editAndApply, runtime],\n ),\n // Read through `columnPinned`, so the type this declares is true even of\n // a config that came out of a store saying `pinned: 'left'`.\n pinnedOf: useCallback(\n (field: string) =>\n columnPinned(\n tableColumns.find(column => column.field === field)?.pinned,\n ),\n [tableColumns],\n ),\n setPinned: useCallback(\n (field: string, pinned: boolean) => {\n if (!runtime) return;\n editAndApply({\n table: {\n columns: recordColumns(\n runtime.getSnapshot().draft.table?.columns,\n ).map(column =>\n column.field === field ? repinned(column, pinned) : column,\n ),\n },\n });\n },\n [editAndApply, runtime],\n ),\n setColumnWidth: useCallback(\n (field: string, width: number | null) => {\n if (!runtime) return;\n editAndApply({\n table: {\n columns: recordColumns(\n runtime.getSnapshot().draft.table?.columns,\n ).map(column =>\n column.field === field ? resized(column, width) : column,\n ),\n },\n });\n },\n [editAndApply, runtime],\n ),\n summaryOf: useCallback(\n (field: string) =>\n summaries.find(entry => entry.field === field)?.fn ?? null,\n [summaries],\n ),\n summaryFields: useMemo(\n () => [...new Set(summaries.map(entry => entry.field))],\n [summaries],\n ),\n setSummary: useCallback(\n (field: string, fn: SummaryFunction | null) => {\n if (!runtime) return;\n const state = runtime.getSnapshot();\n const rest = recordSummaries(state.draft.summaries).filter(\n entry => entry.field !== field,\n );\n editAndApply({\n summaries: summariesOf(\n fn === null ? rest : [...rest, { field, fn }],\n state.saved,\n ),\n });\n },\n [editAndApply, runtime],\n ),\n pageSize,\n pageSizes: useMemo(\n () =>\n offeredPageSizes(\n ladderOf(runtime?.limits, state?.draft.layout ?? 'table'),\n runtime?.limits.maxPageSize,\n pageSize,\n ),\n [pageSize, runtime, state?.draft.layout],\n ),\n setPageSize: useCallback(\n (pageSize: number) => editAndApply({ pageSize }),\n [editAndApply],\n ),\n pageSizeFix: useMemo(\n () =>\n admittedPageSize(\n ladderOf(runtime?.limits, state?.draft.layout ?? 'table'),\n runtime?.limits.maxPageSize,\n state?.draft.pageSize,\n ),\n [runtime, state?.draft.layout, state?.draft.pageSize],\n ),\n\n selection,\n selectedRows,\n isSelected: useCallback((key: RecordKey) => selected.has(key), [selected]),\n toggle,\n toggleAll,\n clearSelection: useCallback(() => runtime?.select([]), [runtime]),\n select: useCallback(\n (keys: readonly RecordKey[]) => runtime?.select([...keys]),\n [runtime],\n ),\n\n // Page numbers only mean something to a paged source.\n goTo: useCallback(\n (index: number) => {\n if (paging?.mode !== 'paged') return;\n runtime?.page({ index: clampPage(paging, index) });\n },\n [runtime, paging],\n ),\n hasNext,\n next: useCallback(() => {\n if (!runtime || !paging || !hasNext) return;\n // Which move \"next\" is depends on the protocol the definition declared;\n // past the last page there is nothing to ask either source for.\n if (paging.mode === 'cursor') {\n runtime.page({ cursor: paging.nextCursor });\n return;\n }\n runtime.page({ index: paging.index + 1 });\n }, [runtime, paging, hasNext]),\n previous: useCallback(() => {\n if (!runtime || paging?.mode !== 'paged' || paging.index <= 1) return;\n runtime.page({ index: paging.index - 1 });\n }, [runtime, paging]),\n refresh: useCallback(() => runtime?.refresh(), [runtime]),\n };\n}\n\n/** The page-size ladder a layout offers from (`RuntimeLimits`). */\nfunction ladderOf(\n limits: RuntimeLimits | undefined,\n layout: RecordLayout,\n): readonly number[] {\n if (!limits) return [];\n return layout === 'card' ? limits.cardPageSizes : limits.pageSizes;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * One write at a time, in the order the clicks came — and only among the\n * commands that answer for the same inputs.\n *\n * Two rows deleted in quick succession are two writes against one list and one\n * `pending` slot: run together, the second one's completion clears the slot\n * while the first is still going, and the first row stops showing progress it\n * is still making. Chaining also keeps the reload each landing triggers from\n * reading a list the other write is halfway through.\n *\n * The tag is what keeps that chaining honest, and it cuts both ways. A hook\n * that swaps its inputs — a workbench moving to another definition, or to\n * another view — while a write hangs must not queue the new inputs' first\n * command behind it, or the row the user just clicked sits there showing\n * nothing. And it must not lose the old chain either: the user can come back\n * to those inputs while their write is still in flight, and a second write\n * against the same target is one the engine refuses with\n * `view.write.in-flight`, which the caller would report as the failure of the\n * click that was only second. So the queue holds one chain per tag rather\n * than one altogether, and each is dropped as it settles.\n *\n * There is no React in here: a queue is a plain mutable holder a hook keeps in\n * a ref, so any command hook can take one.\n */\n\n/** Whether two tags name the same inputs. */\nexport type TagEquality<Tag> = (one: Tag, other: Tag) => boolean;\n\nexport interface CommandQueue<Tag> {\n /**\n * The task at the back of each tag's chain, one entry per tag with something\n * still in flight. An entry is dropped as its chain settles, so an idle\n * queue is empty. Only ever read through {@link enqueue}.\n */\n backs: { tag: Tag; chain: Promise<unknown> }[];\n readonly sameTag: TagEquality<Tag>;\n}\n\n/**\n * An idle queue. `sameTag` decides which tasks chain: the default is identity,\n * which is what a tag that is one object — a runtime, an engine — wants; a tag\n * assembled per render passes its own comparison.\n */\nexport function createCommandQueue<Tag>(\n sameTag: TagEquality<Tag> = Object.is,\n): CommandQueue<Tag> {\n return { backs: [], sameTag };\n}\n\n/**\n * Runs `task` after whatever this tag already has in flight, and answers what\n * it answered.\n *\n * A task whose tag has nothing in flight starts now rather than a microtask\n * later, so the row the user just clicked shows progress in that same event —\n * and that is true of a tag nobody has used yet as much as of one whose last\n * write is over. Another tag's chain is never waited on: it answers for inputs\n * this task has nothing to do with.\n */\nexport function enqueue<Tag, T>(\n queue: CommandQueue<Tag>,\n tag: Tag,\n task: () => Promise<T>,\n): Promise<T> {\n const at = queue.backs.findIndex(entry => queue.sameTag(entry.tag, tag));\n // A task is expected to resolve whatever happened, so the rejection arm is\n // only there to keep one broken link from stalling the queue for good.\n const landed = at < 0 ? task() : queue.backs[at].chain.then(task, task);\n const queued = { tag, chain: landed };\n if (at < 0) queue.backs.push(queued);\n else queue.backs[at] = queued;\n // This tag goes idle again once its last task settles, so the next one is\n // not chained behind a promise that is already over — and a tag the caller\n // never comes back to leaves nothing behind.\n const release = () => {\n const mine = queue.backs.indexOf(queued);\n if (mine >= 0) queue.backs.splice(mine, 1);\n };\n void landed.then(release, release);\n return landed;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * One vocabulary for what a write ended as.\n *\n * Two hooks ask the same four questions of a write — how does a thrown command\n * become an outcome, did it land, did it save the view, and what may a new\n * intent do to an outcome already on screen — and they used to answer them\n * twice, in two sets of words, for the one contract\n * [management.md#冲突与未知结果](../../docs/design/management.md) states. The\n * answers live here, once.\n *\n * The one thing the two genuinely differ on is how many outcomes they hold:\n * `useSaveCommands` speaks for one open runtime and holds its single outcome,\n * while `useViewManager` holds one per row. That difference is in the names —\n * {@link blocksNewIntent} is the runtime's rule, {@link holdsHandle},\n * {@link strandedHandle} and {@link mayReplace} are the keyed slot's — and\n * nowhere else. {@link unsettled} is what they are both said in terms of, and\n * what a surface asks when all it needs to know is whether the engine is\n * still answering for the last write: `/ui`'s save commands disable\n * themselves by it and the leave guard asks {@link blocksNewIntent}, rather\n * than either of them listing the kinds again.\n *\n * Everything here is pure and React-free, so each rule is a question a test\n * can put directly.\n */\n\nimport type { Issue, ViewInstance, ViewPreferences } from '../model/index.js';\nimport {\n isViewWriteError,\n type WriteAction,\n type WriteHandle,\n type WritePayload,\n type WriteState,\n} from '../runtime/index.js';\nimport { toIssue } from './issues.js';\n\n/**\n * The revision and the request id of a write that never left. A refusal is\n * recorded so the caller can say why it did not happen, and its payload is the\n * intent rather than anything sent, so it quotes neither.\n */\nexport const UNSENT = '';\n\n/**\n * What a command ended as, and the address of the write behind it.\n *\n * The handle is absent when there is nothing left to replay: a command the\n * engine refused before dispatching, or a conflict it has already settled.\n */\nexport interface SettledWrite {\n state: WriteState;\n handle: WriteHandle | null;\n}\n\n/**\n * A refusal, in the shape the caller already renders. `ViewCommandError` means\n * nothing was sent, which is exactly a rejection with no outcome to recover.\n */\nexport function refused(payload: WritePayload, issue: Issue): WriteState {\n return { requestId: UNSENT, payload, kind: 'rejected', issue };\n}\n\n/**\n * What a command threw, as the outcome it is: a `ViewWriteError` carries its\n * own state and handle, and anything else never left, so it becomes a\n * rejection quoting the intent and the Issue {@link toIssue} made of it.\n */\nexport function settle(\n caught: unknown,\n code: string,\n intent: WritePayload,\n): SettledWrite {\n if (isViewWriteError(caught))\n return { state: caught.state, handle: caught.handle };\n return { state: refused(intent, toIssue(caught, code)), handle: null };\n}\n\n/** What replaying a write answered: whether it landed, and what it made. */\nexport interface RecoveredWrite {\n /** The command is done: the outcome it was raised against is settled. */\n landed: boolean;\n /**\n * Whether it saved this view — a `create` or a `save` that reached the\n * store. That is what a \"Saved\" moment is about, and two other landings\n * are not it: a conflict resolved by `reload` takes the stored state and\n * drops the draft, so it writes nothing at all; and a recovered `rename` or\n * `delete` does write, but not the config on screen — announcing \"View\n * saved\" after a retried rename would tell the user their unsaved edits are\n * safe when they are not.\n */\n written: boolean;\n /** The instance a recovered create, save or rename produced, if any. */\n instance: ViewInstance | null;\n}\n\n/** Nothing was replayed: no target, or no outcome to recover through. */\nexport const UNRECOVERED: RecoveredWrite = {\n landed: false,\n written: false,\n instance: null,\n};\n\n/**\n * What a replay or a conflict choice resolved with, as a {@link\n * RecoveredWrite}. Reaching this at all means the command landed; preferences\n * resolve too, and carry no instance.\n */\nexport function recovered(\n result: ViewInstance | ViewPreferences | void,\n written: boolean,\n): RecoveredWrite {\n return {\n landed: true,\n written,\n instance:\n typeof result === 'object' && result !== null && 'config' in result\n ? result\n : null,\n };\n}\n\n/**\n * Whether recovering this write saves the view itself. A `rename` and a\n * `delete` reach the store as much as a `save` does, but neither is the\n * config on screen: \"View saved\" after a retried rename says the edits are\n * safe when nothing of them has been written. A write the runtime no longer\n * holds — the outcome settled between the render and the click — answers no,\n * which is the quiet way to be wrong.\n */\nexport function savesView(action: WriteAction | undefined): boolean {\n return action === 'create' || action === 'save';\n}\n\n/**\n * Whether the engine is still answering for this write.\n *\n * A `conflict` and an `unknown` are both unsettled, for two different\n * reasons: one is waiting for the user to choose which version wins, the\n * other for a retry or an abandon. A `rejected` is the definite answer — the\n * store never took it, and there is nothing left outstanding.\n *\n * This is the coarse question, and it is not the same as either of the two\n * below: {@link blocksNewIntent} is narrower (only an `unknown` refuses a new\n * write from an open runtime), and {@link holdsHandle} adds the handle to it.\n */\nexport function unsettled(state: WriteState | null | undefined): boolean {\n return state?.kind === 'unknown' || state?.kind === 'conflict';\n}\n\n/**\n * Whether the one outcome an open runtime reports refuses a new write.\n *\n * Only `unknown` does: the request left and nothing came back, so a second\n * attempt might be a second write, and the engine refuses it outright. A\n * `conflict` and a `rejected` are definite answers, and what resolves them is\n * often a new intent — \"Save my copy\" after somebody else moved the baseline,\n * \"correct it and save again\" after a refusal — which this would disable.\n *\n * A row of the view manager holds one outcome per key rather than one\n * altogether, and a `conflict` costs it the handle it would need to answer\n * for; {@link holdsHandle} is that stricter rule.\n */\nexport function blocksNewIntent(state: WriteState | null | undefined): boolean {\n return state?.kind === 'unknown';\n}\n\n/**\n * Whether the outcome a key holds still addresses a write the engine will\n * answer for, and so refuses a new intent altogether.\n *\n * A row holds one outcome, so a new command for a key whose outcome is still\n * the engine's to answer for has nowhere to put its own: recording it would\n * drop the handle, and the write it addresses would be left in\n * `engine.pendingWrites()` with nothing on screen able to retry, overwrite or\n * abandon it. The engine refuses a second command against an `unknown`\n * outright; a `conflict` it would dispatch over, which is the same problem one\n * step later. A `rejected` outcome is a definite answer with nothing\n * outstanding, so management.md's \"correct it and save again\" goes through as\n * the new intent it is — which is {@link unsettled}, plus the handle that\n * makes it this key's to answer for.\n */\nexport function holdsHandle(outcome: SettledWrite | null | undefined): boolean {\n return outcome?.handle != null && unsettled(outcome.state);\n}\n\n/**\n * The handle a new command for this key would strand, or null when it strands\n * none.\n *\n * A `rejected` outcome that still holds a handle is the one unsettled outcome\n * a new command is allowed past ({@link holdsHandle}), and that command is\n * about to take its slot. Abandoning this handle first is what keeps the write\n * it addresses from being left in `engine.pendingWrites()` with nothing on\n * screen able to reach it.\n */\nexport function strandedHandle(\n outcome: SettledWrite | null | undefined,\n): WriteHandle | null {\n return outcome?.handle && !holdsHandle(outcome) ? outcome.handle : null;\n}\n\n/**\n * Whether the slot is free for an outcome that has nothing to replay.\n *\n * A refusal never left, so letting it take the place of an outcome that still\n * holds a handle would drop the only way to retry or abandon that write —\n * which is exactly what the engine refusing a second command against an\n * `unknown` outcome would otherwise do to it.\n */\nexport function mayRefuse(existing: SettledWrite | null | undefined): boolean {\n return existing?.handle == null;\n}\n\n/**\n * Whether `incoming` may be recorded over whatever the key holds. An outcome\n * that carries its own handle always may — it is a write the store has, and\n * the engine only dispatched it because the slot was open to it. One that\n * carries none is a refusal, and {@link mayRefuse} decides.\n */\nexport function mayReplace(\n existing: SettledWrite | null | undefined,\n incoming: SettledWrite,\n): boolean {\n return incoming.handle !== null || mayRefuse(existing);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useRef, useState } from 'react';\nimport {\n audienceOf,\n type Issue,\n type ViewAudience,\n type ViewInstance,\n type ViewScope,\n} from '../model/index.js';\nimport type {\n ConflictChoice,\n ViewEngine,\n ViewRuntime,\n WriteState,\n} from '../runtime/index.js';\nimport { stopsSave } from '../runtime/dashboard/panels.js';\nimport { instanceAbilities, mayCreate } from '../runtime/permissions.js';\nimport { useViewRuntime } from './useViewEngine.js';\nimport { toIssue } from './issues.js';\nimport {\n createCommandQueue,\n enqueue,\n type CommandQueue,\n} from './manager/queue.js';\nimport {\n blocksNewIntent,\n recovered,\n savesView,\n UNRECOVERED,\n type RecoveredWrite,\n} from './writes.js';\n\nexport type { RecoveredWrite } from './writes.js';\n\nexport interface SaveTargetInput {\n title: string;\n /** `system` makes the copy a stored system view; it needs `createSystem`. */\n scope: ViewScope;\n}\n\nexport interface SaveAbilities {\n save: boolean;\n /** True when a copy may be made in at least one scope. */\n saveAs: boolean;\n rename: boolean;\n delete: boolean;\n /** True when there are edits and a saved baseline to take them back to. */\n revert: boolean;\n /**\n * Which scope a copy may be made in. A dialog that offers a scope the user\n * cannot create in only lets them press Save to be refused, so it offers\n * these and defaults to the first of them.\n */\n createPersonal: boolean;\n createShared: boolean;\n /**\n * Whether a copy may be made a system view everyone sees: the host grants\n * `editSystem` (D81), whose silence is a refusal.\n */\n createSystem: boolean;\n}\n\nexport interface SaveCommandState {\n /** A write is in flight; a UI disables its buttons on this alone. */\n pending: boolean;\n /** The last refusal or failure, cleared when the next command starts. */\n error: Issue | null;\n /** An unresolved outcome: a conflict, a refusal, or an unknown result. */\n write: WriteState | null;\n dirty: boolean;\n /**\n * Nothing may be written right now: a write is in flight, the draft would\n * be refused, or the outcome on screen stops a new intent\n * ({@link blocksNewIntent}). One flag rather than three, because every\n * button that writes disables on all of them.\n *\n * It is deliberately coarse, so a button that has to tell the settled\n * outcomes apart — a rejection is a new attempt away, a conflict is not —\n * or that must refuse a *blind* Save while a conflict is on screen, reads\n * `write` and `hasErrors` themselves rather than this.\n */\n blocked: boolean;\n /**\n * The draft itself reports something that stops every write. Unlike\n * `blocked` it says nothing about outcomes, which is what lets a caller\n * decide for itself which of those it wants to stop on.\n *\n * For a dashboard that is an error about the board alone (`stopsSave`): a\n * panel's own trouble — a view some of its readers cannot open (D22 B), a\n * binding that no longer holds — is said on the panel and saved with it.\n */\n hasErrors: boolean;\n /**\n * Who sees the open view as it is saved: `personal` for its author alone,\n * `shared` for everyone it is shared with (a system view is `shared` too,\n * and has no save). A save in place over a shared view changes what all\n * of them see, which is what a UI asks about first; `null` with no view.\n */\n audience: ViewAudience | null;\n /**\n * The view has never been saved. Its first save is a create, which is why\n * a UI asks for a title and an audience before it rather than writing the\n * name the view opened under.\n */\n isNew: boolean;\n /**\n * When the last write of this view landed, by the engine's clock. A UI\n * shows a \"Saved\" moment from it, so it is a timestamp and not a boolean:\n * the same save twice in a row must read as two distinct moments. It is\n * cleared when the next write starts, and is `null` until one lands.\n *\n * Only a command that saved this view marks a moment. A conflict resolved\n * by `reload` settles and reloads without writing anything, and a recovered\n * `rename` or `delete` writes something that is not the config on screen —\n * both leave this where it was rather than saying \"Saved\" over edits that\n * were just discarded, or were never sent at all.\n */\n lastSavedAt: number | null;\n}\n\nexport interface SaveCommands {\n save(): Promise<ViewInstance | null>;\n saveAs(input: SaveTargetInput): Promise<ViewInstance | null>;\n rename(title: string): Promise<ViewInstance | null>;\n delete(): Promise<boolean>;\n /** Drops the edits and puts the saved config back in force. */\n revert(): void;\n /** Replays the pending write and reports what the replay answered. */\n retry(): Promise<RecoveredWrite>;\n /**\n * Gives up on an unsettled outcome. With no argument it is the one the\n * open view is reporting; a caller that has a `WriteState` in hand passes\n * it, because a write can outlive the runtime's report of it — the engine\n * clears a runtime's outcome as it settles whichever write landed last,\n * and a copy made out of a conflict is a write of its own.\n */\n abandon(write?: WriteState): void;\n /** Resolves a conflict and reports what the choice answered. */\n resolveConflict(choice: ConflictChoice): Promise<RecoveredWrite>;\n can: SaveAbilities;\n state: SaveCommandState;\n}\n\ninterface CommandProgress {\n runtime: ViewRuntime | null;\n pending: boolean;\n error: Issue | null;\n savedAt: number | null;\n}\n\nconst IDLE: CommandProgress = {\n runtime: null,\n pending: false,\n error: null,\n savedAt: null,\n};\n\n/**\n * The write commands of one open view, with the permissions that decide which\n * buttons are live.\n *\n * Every command resolves rather than rejects: the outcome lands in `state`, so\n * a click handler needs no try/catch and an unresolved write stays visible\n * until the user retries, overwrites or abandons it.\n */\nexport function useSaveCommands(\n engine: ViewEngine,\n runtime: ViewRuntime | null,\n): SaveCommands {\n const state = useViewRuntime(runtime);\n // Command state belongs to one view. A workbench reuses this hook across\n // views, so progress and the last failure are tagged with the runtime they\n // came from and read as empty for any other.\n const [progress, setProgress] = useState<CommandProgress>(IDLE);\n // One write in flight per runtime, on the same queue the manager's rows run\n // on: a second command waits for the first rather than racing it into the\n // engine's `view.write.in-flight` refusal, which the row would then report\n // as the failure of a click that was only impatient. The tag is the runtime,\n // so a workbench that switches views starts a fresh queue instead of holding\n // the new view's first command behind the one it left. Created on the first\n // command rather than per render, and never read during one.\n const queue = useRef<CommandQueue<ViewRuntime | null> | null>(null);\n\n const run = useCallback(\n <T>(\n code: string,\n command: () => Promise<T>,\n fallback: T,\n // Only the caller knows whether its outcome means the store took the\n // write: a delete resolves with `false` on failure, a retry with a\n // replay that may have answered \"not landed\".\n landed?: (outcome: T) => boolean,\n // A replay or a conflict choice: it addresses the outcome that is in\n // the way rather than being stopped by it. See {@link guarded}.\n recovery = false,\n ): Promise<T> => {\n const commands = (queue.current ??=\n createCommandQueue<ViewRuntime | null>());\n return enqueue(commands, runtime, async () => {\n // Asked at the front of the queue rather than at the click: the\n // command ahead may be the one that turned this view `unknown`, or\n // the last thing a runtime did before it was released. Sending anyway\n // earns a `view.write.unknown-pending` refusal, and the header would\n // show it as the failure of a click that was only second — over an\n // outcome the user still has to retry or abandon.\n if (!guarded(runtime, recovery)) return fallback;\n setProgress({ runtime, pending: true, error: null, savedAt: null });\n try {\n const outcome = await command();\n if (landed?.(outcome) === true) {\n const at = engine.environment.now().getTime();\n setProgress(current =>\n current.runtime === runtime\n ? { ...current, savedAt: at }\n : current,\n );\n }\n return outcome;\n } catch (caught) {\n const failure = toIssue(caught, code);\n // A workbench reuses this hook across views; another view's command\n // may have taken the slot while this one was in flight.\n setProgress(current =>\n current.runtime === runtime\n ? { runtime, pending: false, error: failure, savedAt: null }\n : current,\n );\n return fallback;\n } finally {\n // A command that outlived its view leaves the next view's state\n // alone.\n setProgress(current =>\n current.runtime === runtime && current.pending\n ? { ...current, pending: false }\n : current,\n );\n }\n });\n },\n [engine, runtime],\n );\n\n const own = progress.runtime === runtime ? progress : IDLE;\n\n const instanceId = state?.saved?.id ?? null;\n // Asked for only when a view is open: the store owns the answer, and an\n // unknown definition is not a question worth putting to it.\n const permissions = runtime\n ? engine.permissions(runtime.definition.id)\n : null;\n // Asked of `instanceAbilities`, the one reading the engine's guard refuses\n // by (D4): a system view is read-only unless the store keeps it and the\n // host grants `editSystem` (D81).\n const instance =\n permissions && state?.saved\n ? instanceAbilities(state.saved, permissions)\n : null;\n const creating =\n state !== null &&\n permissions !== null &&\n mayCreate(permissions, state.scope);\n // A copy is a create, so it needs the create permission of the scope it is\n // headed for — not of the scope the open view happens to sit in.\n const createPersonal = state !== null && permissions?.createPersonal === true;\n const createShared = state !== null && permissions?.createShared === true;\n const createSystem =\n state !== null && permissions !== null && mayCreate(permissions, 'system');\n\n const save = useCallback(\n () =>\n runtime\n ? run('view.save.failed', () => engine.save(runtime), null, landedSave)\n : Promise.resolve(null),\n [engine, runtime, run],\n );\n\n const saveAs = useCallback(\n (input: SaveTargetInput) =>\n runtime\n ? run(\n 'view.save-as.failed',\n () => engine.saveAs(runtime, input),\n null,\n landedSave,\n )\n : Promise.resolve(null),\n [engine, runtime, run],\n );\n\n const rename = useCallback(\n (title: string) =>\n instanceId\n ? run(\n 'view.rename.failed',\n () => engine.rename(instanceId, title),\n null,\n )\n : Promise.resolve(null),\n [engine, instanceId, run],\n );\n\n const remove = useCallback(\n () =>\n instanceId\n ? run(\n 'view.delete.failed',\n () => engine.delete(instanceId).then(() => true),\n false,\n )\n : Promise.resolve(false),\n [engine, instanceId, run],\n );\n\n const retry = useCallback(() => {\n if (!runtime) return Promise.resolve(UNRECOVERED);\n // What the write was for, read before the replay settles it and clears\n // it: a replay does write, but only a create or a save writes the config\n // on screen, and only that is a \"View saved\" moment.\n const action = runtime.getSnapshot().write?.payload.action;\n return run(\n 'view.retry.failed',\n // A delete resolves with nothing, which still means it landed; a\n // recovered create, save or rename carries the instance it produced.\n () =>\n engine.retryWrite(runtime).then(it => recovered(it, savesView(action))),\n UNRECOVERED,\n wroteStore,\n true,\n );\n }, [engine, runtime, run]);\n\n const abandon = useCallback(\n (write?: WriteState) => {\n if (!runtime) return;\n // Abandoning is the user acting now, not an old callback arriving late,\n // so its outcome takes the slot however it is held.\n try {\n // By its own handle when the caller named one: the runtime may have\n // stopped reporting it, and the engine would then answer that nothing\n // is pending while the write is still in its map.\n engine.abandonWrite(write ? { id: write.requestId } : runtime);\n // Giving up on an outcome is not a write, so it leaves the moment an\n // earlier one landed alone.\n setProgress(current => ({\n runtime,\n pending: false,\n error: null,\n savedAt: current.runtime === runtime ? current.savedAt : null,\n }));\n } catch (caught) {\n setProgress({\n runtime,\n pending: false,\n error: toIssue(caught, 'view.abandon.failed'),\n savedAt: null,\n });\n }\n },\n [engine, runtime],\n );\n\n const resolveConflict = useCallback(\n (choice: ConflictChoice) => {\n if (!runtime) return Promise.resolve(UNRECOVERED);\n const action = runtime.getSnapshot().write?.payload.action;\n return run(\n 'view.resolve.failed',\n // Both a reload and an overwrite resolve only when they landed, but\n // only an overwrite of a create or a save saves this view: a reload\n // takes the stored state and discards the draft, and an overwritten\n // rename moves a title rather than the config — timing either as a\n // save would put \"View saved\" on screen over edits still unsaved.\n () =>\n engine\n .resolveConflict(runtime, choice)\n .then(it =>\n recovered(it, choice === 'overwrite' && savesView(action)),\n ),\n UNRECOVERED,\n wroteStore,\n true,\n );\n },\n [engine, runtime, run],\n );\n\n const revert = useCallback(() => runtime?.revert(), [runtime]);\n\n const hasErrors =\n runtime !== null && stopsSave(runtime.kind, state?.issues ?? []);\n\n return {\n save,\n saveAs,\n rename,\n delete: remove,\n revert,\n retry,\n abandon,\n resolveConflict,\n can: {\n // An unsaved view needs the create permission for its own scope; a saved\n // one needs the permission that belongs to the instance.\n save: (state?.saved ? instance?.save : creating) === true,\n saveAs: createPersonal || createShared || createSystem,\n rename: instance?.rename === true,\n delete: instance?.delete === true,\n // Reverting writes nothing and needs no permission — it only puts back\n // what the store already holds.\n revert: state?.dirty === true && state.saved !== null,\n createPersonal,\n createShared,\n createSystem,\n },\n state: {\n pending: own.pending,\n error: own.error,\n write: state?.write ?? null,\n dirty: state?.dirty ?? false,\n blocked: own.pending || blocksNewIntent(state?.write) || hasErrors,\n hasErrors,\n audience: state ? audienceOf(state.scope) : null,\n isNew: state !== null && state.saved === null,\n lastSavedAt: own.savedAt,\n },\n };\n}\n\n/**\n * Whether a command that has reached the front of the queue may still go.\n *\n * A recovery always may: it is the very outcome in the way being answered.\n * Anything else is a new intent, and what stops it here is exactly what\n * {@link blocksNewIntent} stopped the click by — read again, because the\n * command ahead of this one may have turned the view `unknown` since. A\n * runtime released while this waited has nothing left to write to, and every\n * command on it is a no-op, so it is not worth an error either. Skipping\n * resolves the command's own fallback, which is what \"nothing happened\"\n * already reads as.\n */\nfunction guarded(runtime: ViewRuntime | null, recovery: boolean): boolean {\n if (runtime === null || runtime.disposed) return false;\n return recovery || !blocksNewIntent(runtime.getSnapshot().write);\n}\n\n/** A save or a copy that produced an instance is one the store took. */\nfunction landedSave(instance: ViewInstance | null): boolean {\n return instance !== null;\n}\n\n/**\n * A replay or a conflict choice marks a moment only when it saved this view.\n * Landing is not enough: `reload` settles the conflict by taking the stored\n * state, and nothing of the user's was saved.\n */\nfunction wroteStore(write: RecoveredWrite): boolean {\n return write.written;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useEffect, useState } from 'react';\nimport type { ValueCandidate } from '../analysis/index.js';\nimport type { ValueCandidateSource } from '../runtime/index.js';\nimport { sourceReason } from '../runtime/sourceReason.js';\n\n/** How long typing may pause before the values holding it are asked for. */\nexport const VALUE_CANDIDATE_DEBOUNCE_MS = 250;\n\nexport interface ValueCandidatesController {\n /**\n * `idle` until the list is first opened; `loading` while an answer is on\n * its way, with the last one still in `values`; `error` when it failed,\n * with the last one kept and `reason` saying why.\n */\n status: 'idle' | 'loading' | 'success' | 'error';\n /**\n * The text `values` answer. While it differs from what is typed now, the\n * answer to the new text is still on its way, and a control narrows what\n * it holds in the meantime rather than showing a list the text has left.\n */\n query: string;\n values: readonly ValueCandidate[];\n /** See `ValueCandidates.complete`; false until an answer says otherwise. */\n complete: boolean;\n /** What the source said went wrong, in its own words (`sourceReason`). */\n reason: string | null;\n /** Asks the same question again after a failure. */\n retry(): void;\n}\n\ninterface Answered {\n source: ValueCandidateSource | null | undefined;\n status: ValueCandidatesController['status'];\n query: string;\n values: readonly ValueCandidate[];\n complete: boolean;\n reason: string | null;\n}\n\nconst NONE: readonly ValueCandidate[] = [];\n\n/**\n * A condition's values offered from the data: the list of one\n * `ValueCandidateSource`, asked for while `active`.\n *\n * Nothing is asked until the list opens, because a panel holding a dozen\n * conditions must not cost a dozen aggregations to draw. The unnarrowed list\n * is asked for at once; a typed fragment only once typing has paused, and\n * every change of either aborts the request before it — as does closing the\n * list, which is what `active` going false means. The runtime keeps what\n * came back for the life of the view, so reopening the list asks nothing.\n *\n * The answer is kept per source: another field is another list, and what\n * the last one said is not shown under it for a moment.\n */\nexport function useValueCandidates(\n source: ValueCandidateSource | null | undefined,\n query: string,\n active: boolean,\n): ValueCandidatesController {\n const [answered, setAnswered] = useState<Answered>(() => blank(source));\n const [attempt, setAttempt] = useState(0);\n const current = answered.source === source ? answered : blank(source);\n const text = query.trim();\n\n useEffect(() => {\n if (!source || !active) return;\n const controller = new AbortController();\n const settle = (patch: Partial<Answered>) => {\n if (controller.signal.aborted) return;\n setAnswered(last => ({\n ...(last.source === source ? last : blank(source)),\n ...patch,\n }));\n };\n const timer = setTimeout(\n () => {\n settle({ status: 'loading', reason: null });\n source.search(text, controller.signal).then(\n answer =>\n settle({\n status: 'success',\n query: text,\n values: answer.values,\n complete: answer.complete,\n }),\n async (error: unknown) => {\n const reason = await sourceReason(error);\n settle({ status: 'error', reason });\n },\n );\n },\n text ? VALUE_CANDIDATE_DEBOUNCE_MS : 0,\n );\n return () => {\n clearTimeout(timer);\n controller.abort();\n };\n }, [source, text, active, attempt]);\n\n const retry = useCallback(() => setAttempt(count => count + 1), []);\n\n return {\n status: current.status,\n query: current.query,\n values: current.values,\n complete: current.complete,\n reason: current.reason,\n retry,\n };\n}\n\nfunction blank(source: ValueCandidateSource | null | undefined): Answered {\n return {\n source,\n status: 'idle',\n query: '',\n values: NONE,\n complete: false,\n reason: null,\n };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport type {\n Issue,\n ViewInstanceSummary,\n ViewKind,\n ViewPreferences,\n} from '../model/index.js';\nimport type { ViewEngine } from '../runtime/index.js';\nimport { orderSummaries } from '../runtime/preferences.js';\nimport type { ViewPermissions } from '../store/ViewStore.js';\nimport { toIssue } from './issues.js';\n\nexport interface ViewListOptions {\n /**\n * Narrows the list to these kinds, before it is ordered and before a\n * default is resolved from it.\n *\n * One data definition holds record and analysis instances together, and a\n * workbench draws the kinds it has parts for — both by default, one when a\n * host narrows it (D20). Without this the sidebar offers views the body\n * cannot render, and the effective default may land on one of them — which\n * is a blank page rather than a view. Left out, every kind is listed, which\n * is what a dashboard definition wants.\n */\n kinds?: readonly ViewKind[];\n}\n\n/** What a caller already knows about the list it is asking to be read again. */\nexport interface ViewListReloadOptions {\n /**\n * An instance that is gone: it is dropped from the summaries kept on screen\n * for the duration of the reload, and `defaultInstanceId` never names it,\n * before or after the answer lands.\n *\n * A reload refreshes rather than blanks, so without this the row deleted a\n * moment ago goes on being listed — and named as the default — until the\n * store answers, and a workbench riding on the default reopens a runtime\n * that has just been disposed.\n *\n * A delete through the engine fills this in by itself: the hook hears the\n * engine say which id went (D15). What is left for a caller is the delete\n * the engine never saw — a row removed by the host's own backend.\n */\n without?: string;\n}\n\nexport interface ViewListState {\n /** Summaries in the order the workbench shows them. */\n items: ViewInstanceSummary[];\n /**\n * The same summaries before `options.kinds` narrowed them, in the same\n * order. Equal to `items` when no kinds were asked for.\n *\n * A reorder stores one order for the whole definition, and a narrowed\n * workbench lists only some kinds: submitting the order it can see would\n * drop every other id from `preferences.order`. So a caller that writes\n * the order reads it from here and moves the two ids it can see inside it,\n * leaving the kinds it does not draw where they were.\n */\n all: ViewInstanceSummary[];\n preferences: ViewPreferences | null;\n permissions: ViewPermissions;\n /** The view to open when the caller names none; null until preferences settle. */\n defaultInstanceId: string | null;\n loading: boolean;\n error: Issue | null;\n /** Kept apart: without preferences the list still works, in server order. */\n preferencesError: Issue | null;\n /**\n * Whether the preferences have answered, read or failed. Until then\n * `preferences` is null for want of an answer, not because there are none,\n * so nothing the reader set there can be read off it yet.\n */\n preferencesSettled: boolean;\n reload(options?: ViewListReloadOptions): void;\n}\n\n/**\n * A completed load, tagged with the request it answered and the definition\n * it is about. The two are asked separately: `key` says whether this is the\n * newest answer, `definitionId` whether it is still about the right thing.\n */\ninterface Loaded<T> {\n key: string;\n definitionId: string;\n value: T | null;\n error: Issue | null;\n}\n\nconst NOTHING_LOADED: Loaded<never> = {\n key: '',\n definitionId: '',\n value: null,\n error: null,\n};\n\n/**\n * One request to read the list, and what the caller already knew when it\n * asked. `without` holds only until the answer arrives: if the delete did not\n * take after all, the row the store still has comes back rather than staying\n * hidden behind what the caller believed.\n */\ninterface ReloadRequest {\n token: number;\n without: string | null;\n}\n\nconst FIRST_LOAD: ReloadRequest = { token: 0, without: null };\n\n/**\n * The list, the preferences and the permissions of one definition.\n *\n * They load independently and never block each other: a failed list leaves an\n * open view alone, and failed preferences only drop back to server order.\n * Loading is derived from whether the answer on hand belongs to the current\n * request, so the effect writes state only when a response arrives.\n */\nexport function useViewList(\n engine: ViewEngine,\n definitionId: string,\n options: ViewListOptions = {},\n): ViewListState {\n // Read off the object rather than kept: a caller writes the options inline,\n // so the object — and the array in it — is new every render while what\n // they say is not. The kinds are held by what they say.\n const kindsKey = options.kinds?.join(' ');\n const kinds = useMemo(\n () =>\n kindsKey === undefined\n ? null\n : new Set(kindsKey.split(' ') as ViewKind[]),\n [kindsKey],\n );\n const [request, setRequest] = useState<ReloadRequest>(FIRST_LOAD);\n const [list, setList] =\n useState<Loaded<ViewInstanceSummary[]>>(NOTHING_LOADED);\n const [preferences, setPreferences] =\n useState<Loaded<ViewPreferences>>(NOTHING_LOADED);\n const key = `${request.token}:${definitionId}`;\n\n useEffect(() => {\n let cancelled = false;\n\n void engine.list(definitionId).then(\n // The store's failure rides beside what could be listed: the declared\n // views are there whatever the store said, so the sidebar keeps its\n // one guaranteed view and says why the rest are missing.\n listing => {\n if (cancelled) return;\n setList(current => ({\n key,\n definitionId,\n // A store that failed on a reload takes nothing off the screen:\n // the answer before it — the saved views included — stays, and\n // the failure is said beside it. Only a first read has nothing to\n // keep, and shows the declared views alone.\n value:\n listing.failed &&\n current.definitionId === definitionId &&\n current.value\n ? current.value\n : listing.items,\n error: listing.failed,\n }));\n },\n // A refusal of the whole list — an unknown definition, an invalid one.\n // What was on hand for this definition stays: a list that blanked here\n // took the default view with it, the workbench closed its runtime, and\n // an unsaved draft went with it without a question (F-05).\n (error: unknown) => {\n if (!cancelled)\n setList(current => ({\n key,\n definitionId,\n value: current.definitionId === definitionId ? current.value : null,\n error: toIssue(error, 'view.list.failed'),\n }));\n },\n );\n\n void engine.preferences(definitionId).then(\n value => {\n if (!cancelled)\n setPreferences({ key, definitionId, value, error: null });\n },\n (error: unknown) => {\n if (!cancelled)\n setPreferences({\n key,\n definitionId,\n value: null,\n error: toIssue(error, 'view.preferences.load-failed'),\n });\n },\n );\n\n return () => {\n cancelled = true;\n };\n }, [engine, definitionId, key]);\n\n const permissions = useMemo(\n () => engine.permissions(definitionId),\n [engine, definitionId],\n );\n const reload = useCallback(\n (options?: ViewListReloadOptions) =>\n setRequest(current => ({\n token: current.token + 1,\n without: options?.without ?? null,\n })),\n [],\n );\n\n // Every write the engine confirms is one this list may be a revision\n // behind — whoever sent it, through the manager, through the open view's\n // header, or straight through `engine.delete` from the host's own code.\n // The engine says so; nobody has to remember to (D15). A delete brings the\n // id it removed, so the row goes now rather than when the store answers.\n useEffect(\n () =>\n engine.subscribe(change => {\n if (change.definitionId !== definitionId) return;\n reload(change.kind === 'delete' ? { without: change.id } : undefined);\n }),\n [engine, definitionId, reload],\n );\n\n // A reload refreshes; it does not blank. What is on hand for *this*\n // definition stays on screen until the new answer lands, because a list\n // that empties mid-reload has no default view for a moment — and a\n // workbench riding on the default would close its runtime and lose the\n // unsaved draft with it. Only a change of definition clears the answer,\n // since then what is on hand is about something else.\n const current = list.definitionId === definitionId ? list : NOTHING_LOADED;\n const preferencesSettled = preferences.definitionId === definitionId;\n const settled = list.key === key;\n // What the caller told us is gone, held only while the retained answer is\n // the one that still has it. Once this request's own answer lands, the\n // store has the last word again.\n const without = settled ? null : request.without;\n\n const retainedPreferences = preferencesSettled ? preferences : NOTHING_LOADED;\n // The stored default is a revision behind too, and it names the row that\n // has just gone. Answering with it would open a view that no longer exists.\n const currentPreferences = useMemo(() => {\n const value = retainedPreferences.value;\n if (without === null || !value || value.defaultInstanceId !== without)\n return retainedPreferences;\n return {\n ...retainedPreferences,\n value: { ...value, defaultInstanceId: null },\n };\n }, [retainedPreferences, without]);\n\n const all = useMemo(() => {\n const listed = current.value ?? [];\n const kept =\n without === null ? listed : listed.filter(item => item.id !== without);\n return currentPreferences.value\n ? orderSummaries(kept, currentPreferences.value)\n : kept;\n }, [current.value, currentPreferences.value, without]);\n\n // The narrowing happens last, over the ordered list, so both the order and\n // the default below are resolved among the views the caller can open while\n // `all` keeps the positions of the kinds this caller does not draw.\n const items = useMemo(\n () => (kinds ? all.filter(summary => kinds.has(summary.kind)) : all),\n [all, kinds],\n );\n\n return {\n items,\n all,\n preferences: currentPreferences.value,\n permissions,\n // No default until preferences have settled: answering from server order\n // in the meantime opens one view and then swaps it for another.\n defaultInstanceId: !preferencesSettled\n ? null\n : currentPreferences.value\n ? engine.resolveDefault(items, currentPreferences.value)\n : (items[0]?.id ?? null),\n loading: !settled,\n error: current.error,\n preferencesError: currentPreferences.error,\n preferencesSettled,\n reload,\n };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Which of a view manager's buttons exist at all, read from the permissions\n * the store handed out and from the rows actually on screen.\n */\n\nimport { isSystemScope, type ViewInstanceSummary } from '../../model/index.js';\nimport type { ViewPermissions } from '../../store/ViewStore.js';\nimport { instanceAbilities, mayCreate } from '../../runtime/permissions.js';\n\n/** What may be done to one row. `save` is not among them: nothing here edits a config. */\nexport interface ManagedInstanceAbilities {\n rename: boolean;\n delete: boolean;\n /**\n * Whether the row may move to the other audience (设为共享/设为个人):\n * the store has `changeAudience`, allows it for this view, and allows\n * creating in the audience it would go to.\n */\n changeAudience: boolean;\n /**\n * Whether a copy of the row may be published as a system view\n * (「发布为系统视图」, D81): a personal or shared row, and `editSystem`\n * granted. The row itself is left as it is.\n */\n publish: boolean;\n}\n\nexport interface ViewManagerAbilities {\n reorder: boolean;\n setDefault: boolean;\n /**\n * Whether this user may publish views as system views at all (D81,\n * `editSystem`): a list-wide answer, so every row lays out the same cells.\n */\n publishSystem: boolean;\n instance(id: string): ManagedInstanceAbilities;\n /**\n * Whether anything at all can be managed: the order, the default, or the\n * title or existence of any row on the list. False means the manager would\n * open on a dialog of read-only rows, so the way in is not offered — a\n * button whose only lesson is that it leads nowhere.\n */\n anything: boolean;\n}\n\nexport function abilitiesOf(\n items: readonly ViewInstanceSummary[],\n permissions: ViewPermissions,\n): ViewManagerAbilities {\n const publishSystem = mayCreate(permissions, 'system');\n const instance = (id: string): ManagedInstanceAbilities => {\n // Asked of `instanceAbilities`, which is where \"a system view ships with\n // the definition, so no store write reaches it\" is decided — the same\n // reading the permission guard refuses by, so a button exists exactly\n // where the command would be allowed (D4). Deciding it here as well is\n // how a Rename came to be offered on a row the guard then refused.\n // The row whole, so a stored system view is read as one (D81).\n const row = items.find(item => item.id === id);\n const granted = instanceAbilities(row ?? { id }, permissions);\n return {\n rename: granted.rename,\n delete: granted.delete,\n changeAudience: granted.changeAudience,\n publish: publishSystem && row !== undefined && !isSystemScope(row.scope),\n };\n };\n return {\n reorder: permissions.reorder,\n setDefault: permissions.setDefault,\n publishSystem,\n instance,\n // Asked of the rows on screen rather than of the permissions alone: a\n // list whose every row is a system view answers \"nothing\", however freely\n // the store hands out `rename` and `delete`.\n anything:\n permissions.reorder ||\n permissions.setDefault ||\n items.some(item => {\n const granted = instance(item.id);\n return (\n granted.rename ||\n granted.delete ||\n granted.changeAudience ||\n granted.publish\n );\n }),\n };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * What a view manager's commands have produced: one outcome per row, held in a\n * map. The rules that decide what a row's slot accepts are `react/writes.ts`'s,\n * asked from there directly — this is the map around them.\n *\n * Everything here is a pure function over one `Outcome` or over the map of\n * them: the hook holds that map in React state, but none of these rules needs\n * to know that, and each is a rule a test can put a question to directly.\n */\n\nimport {\n SYSTEM_INSTANCE_ID_PREFIX,\n SYSTEM_INSTANCE_ID_SEPARATOR,\n} from '../../model/index.js';\nimport type { WriteState } from '../../runtime/index.js';\nimport { holdsHandle, type SettledWrite } from '../writes.js';\n\n/**\n * The key the order and the default view are recorded under.\n *\n * Both are one preference record, so both contend for one slot and share one\n * outcome: there is no instance to hang them off, and a row cannot be asked\n * to recover a write that was never about it.\n *\n * It shares the key space with instance ids, so it is taken from the one\n * namespace a `ViewStore` may not issue into — the `system:` prefix\n * `isSystemInstanceId` reserves — rather than from a bare word a store could\n * hand out as an id and collide with.\n */\nexport const PREFERENCES_KEY =\n `${SYSTEM_INSTANCE_ID_PREFIX}${SYSTEM_INSTANCE_ID_SEPARATOR}preferences` as const;\n\n/**\n * One recorded outcome: what the command settled as, plus the intent a\n * preference write keeps across a reload. The handle is the engine's, kept\n * here rather than handed out — a caller acts on the row it can see, and\n * `retry`, `abandon` and `resolveConflict` address the write for it.\n */\nexport interface Outcome extends SettledWrite {\n /**\n * The command as the user meant it, for a preference write whose conflict\n * was answered with a reload. Running it again is a new write — it reads\n * the revision the reload brought in — so the intent survives the reload\n * without ever being replayed behind the user's back.\n */\n again?: () => Promise<unknown>;\n}\n\nexport const NO_OUTCOMES: ReadonlyMap<string, Outcome> = new Map();\n\n/**\n * Whether an outcome is a conflict the engine has already settled and whose\n * intent is still the user's to put again: after a reload there is no handle\n * to recover through, and the button offers the write once more rather than\n * a recovery that would answer `false`.\n *\n * \"No handle to recover through\" is `holdsHandle` answering no over a\n * conflict, asked rather than restated: which outcomes the engine is still\n * answering for is `writes.ts`'s rule, and a second spelling of it here would\n * be a second place to fix when it moves.\n */\nexport function kept(outcome: Outcome | undefined): boolean {\n return (\n outcome !== undefined &&\n outcome.state.kind === 'conflict' &&\n !holdsHandle(outcome) &&\n outcome.again !== undefined\n );\n}\n\n/**\n * The map with this key recorded or dropped, or null when it would not change\n * — dropping a key nothing is held under is the one no-op, and answering it\n * with a new map would re-render every row for nothing.\n */\nexport function withOutcome(\n outcomes: ReadonlyMap<string, Outcome>,\n key: string,\n outcome: Outcome | null,\n): ReadonlyMap<string, Outcome> | null {\n if (outcome === null && !outcomes.has(key)) return null;\n const next = new Map(outcomes);\n if (outcome) next.set(key, outcome);\n else next.delete(key);\n return next;\n}\n\n/**\n * The outcomes as a caller reads them: the state alone, because the handle is\n * the engine's and the recovery actions address it on the row's behalf.\n */\nexport function projectStates(\n outcomes: ReadonlyMap<string, Outcome>,\n): ReadonlyMap<string, WriteState> {\n const projected = new Map<string, WriteState>();\n for (const [key, outcome] of outcomes) projected.set(key, outcome.state);\n return projected;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Where a row goes when it moves: pure arithmetic over orders of ids, with the\n * audience groups the sidebar renders taken into account.\n *\n * A move reasons over ids alone — the order a queued move computed has nothing\n * but ids — so the audience of each row arrives as a lookup rather than being\n * carried along with the summaries.\n */\n\nimport type { ViewAudience } from '../../model/index.js';\n\n/**\n * The order a queued move computed, while the list it was computed from is\n * still a reload behind it.\n *\n * `base` is the full rendered order it started from: once the list is no\n * longer that, the reload has landed and the rendered order is the truth\n * again. The two orders after the move are both kept, because they answer\n * different questions — `order` is what was submitted, and `visible` is the\n * list the next move reads its group and its indexes out of. Which inputs the\n * move was raised under is the caller's to tag on; this module only does the\n * arithmetic.\n */\nexport interface OptimisticOrder {\n /** The full rendered order, unfiltered, before this move. */\n base: readonly string[];\n /** The full order this move submitted. */\n order: readonly string[];\n /** The narrowed order as this move left it. */\n visible: readonly string[];\n}\n\n/**\n * The two orders one move produces; see {@link OptimisticOrder}. Both are\n * fresh arrays the caller owns — one of them is what it submits.\n */\nexport interface MovedOrder {\n order: string[];\n visible: string[];\n}\n\nexport function sameOrder(\n one: readonly string[],\n other: readonly string[],\n): boolean {\n return one.length === other.length && one.every((id, at) => id === other[at]);\n}\n\n/**\n * The places one audience occupies in an order of ids.\n *\n * Audience is why a move is not arithmetic on one flat list. Both lists draw\n * personal views above shared ones whatever order is stored, so the row above\n * a shared view on screen may be a personal one, and carrying a row across\n * that line would store a new order, spend a revision and move nothing\n * anybody can see. The drag is held inside its group by the library; this is\n * the same boundary written in indexes, for the arithmetic and for the arrow\n * keys on the handle.\n *\n * It walks an order of ids rather than the summaries themselves, because the\n * order a queued move computed is the one the next move has to reason over,\n * while a row's audience is the same wherever that order puts it.\n */\nfunction placesOf(\n order: readonly string[],\n audiences: ReadonlyMap<string, ViewAudience>,\n audience: ViewAudience,\n): number[] {\n const places: number[] = [];\n for (let at = 0; at < order.length; at += 1)\n if (audiences.get(order[at]) === audience) places.push(at);\n return places;\n}\n\n/**\n * Where a row sits inside its own audience group, counted over the rows the\n * user can see, or -1 when the list does not hold it.\n *\n * This is the index a move is expressed in, because it is the list a user is\n * looking at: one group of rows under one heading, and a drop that lands on\n * another row of it. A position in the flat rendered order would mean\n * something different on either side of the boundary.\n */\nexport function groupIndexOf(\n visible: readonly string[],\n audiences: ReadonlyMap<string, ViewAudience>,\n id: string,\n): number {\n const audience = audiences.get(id);\n if (audience === undefined) return -1;\n return placesOf(visible, audiences, audience).indexOf(visible.indexOf(id));\n}\n\n/**\n * What one move submits and what it leaves on screen, or null when there is\n * nothing to move: a row the list no longer holds, a row of no known\n * audience, or one already sitting where it is being sent.\n *\n * `index` is counted inside the row's own audience group, among the rows the\n * user can see, and is clamped to that group — being carried past the last\n * row of a group lands on the last row of it rather than in the group below.\n *\n * The move itself is made in the *full* order. Submitting the visible one\n * would store a list with every other kind's id missing, and the store keeps\n * one order for the whole definition: a record workbench reordering its own\n * views would silently drop the analyses. The places the group holds in that\n * order are rewritten with the group as this move leaves it, so every id that\n * took no part — another kind's, the other audience's — stays exactly where\n * it was. A row the submitted order does not hold cannot be placed in it, and\n * storing an order without it would spend a revision to lose it.\n */\nexport function planMoveTo(\n visible: readonly string[],\n full: readonly string[],\n audiences: ReadonlyMap<string, ViewAudience>,\n id: string,\n index: number,\n): MovedOrder | null {\n const audience = audiences.get(id);\n if (audience === undefined) return null;\n const places = placesOf(visible, audiences, audience);\n const group = places.map(place => visible[place]);\n const from = group.indexOf(id);\n if (from < 0) return null;\n const to = Math.min(Math.max(index, 0), group.length - 1);\n if (to === from) return null;\n const moved = [...group];\n moved.splice(from, 1);\n moved.splice(to, 0, id);\n\n // Sorted, so the group is written back into the places it already holds:\n // the ids that took no part keep the positions they had, and the ones that\n // moved trade places only with each other.\n const held = group.map(member => full.indexOf(member));\n if (held.includes(-1)) return null;\n held.sort((one, other) => one - other);\n const order = [...full];\n held.forEach((place, at) => {\n order[place] = moved[at];\n });\n const shown = [...visible];\n places.forEach((place, at) => {\n shown[place] = moved[at];\n });\n return { order, visible: shown };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * The protocol every view-manager command runs under: one outcome per key,\n * one write in flight, and both tagged with the inputs they answer for.\n *\n * It is the React half of the split — `queue.ts` serializes, `react/writes.ts`\n * decides what a slot accepts and `outcomes.ts` is the map of slots; this\n * holds the state those rules are asked about and turns a command into an\n * outcome the row can render.\n */\n\nimport { useCallback, useRef, useState } from 'react';\nimport type { ViewEngine, WritePayload } from '../../runtime/index.js';\nimport type { ViewListState } from '../useViewList.js';\nimport { holdsHandle, mayReplace, settle, strandedHandle } from '../writes.js';\nimport { NO_OUTCOMES, withOutcome, type Outcome } from './outcomes.js';\nimport { createCommandQueue, enqueue, type CommandQueue } from './queue.js';\n\n/**\n * The inputs a command, an outcome and a queued order all answer for.\n *\n * The tag is the derivation `useViewList` makes — \"which request does this\n * answer belong to\", asked of a command rather than of a load. A workbench\n * swaps `definitionId` or `engine` while a write is in flight, and without\n * the tag the rows of the definition just left keep their outcomes and their\n * progress against a list that no longer holds them, and a completion from\n * the old inputs repopulates the new one.\n */\nexport interface ManagerTag {\n /** Null only before the first command; nothing is tagged with it. */\n engine: ViewEngine | null;\n definitionId: string;\n}\n\nexport function sameTag(one: ManagerTag, other: ManagerTag): boolean {\n return one.engine === other.engine && one.definitionId === other.definitionId;\n}\n\n/** What the commands have produced, tagged with the inputs they were raised under. */\ninterface RunnerState extends ManagerTag {\n outcomes: ReadonlyMap<string, Outcome>;\n /** The key of the one write in flight; see `CommandRunner.pending`. */\n pending: string | null;\n}\n\n/** State belonging to no inputs, which is also how other inputs' state reads. */\nconst NOTHING_RUN: RunnerState = {\n engine: null,\n definitionId: '',\n outcomes: NO_OUTCOMES,\n pending: null,\n};\n\n/**\n * What a command tells the runner about itself, beyond what it writes.\n *\n * Both halves arrived with a different question — one keeps an intent alive\n * across a reload, the other decides whether an unsettled key accepts this\n * command at all — and they are independent: `resubmit` carries an intent and\n * is still an ordinary write, so the `unknown` guard applies to it.\n */\nexport interface RunOptions {\n /**\n * Kept with the outcome so the same intent can be put again later. Only\n * the preference commands pass one: everything else recovers through its\n * handle, which addresses the write the store already has.\n */\n again?: () => Promise<unknown>;\n /** A replay or a conflict choice, which is the one thing an unsettled outcome accepts. */\n recovery?: boolean;\n /**\n * Asked once more at the front of the queue, for a command that addresses\n * a handle it read when it was queued. The command ahead may have settled\n * that outcome — retried it, abandoned it, answered its conflict — and the\n * engine would refuse the second address with an error the row would show\n * as a failure of the click the user just made. False means \"nothing to do\n * any more\": the command is skipped and resolves `false`.\n */\n guard?: () => boolean;\n}\n\nexport interface CommandRunner {\n /**\n * Runs one command, resolving whether it landed rather than rejecting: what\n * happened is recorded under `key`, so a click handler needs no try/catch.\n */\n run(\n key: string,\n intent: WritePayload,\n code: string,\n command: () => Promise<unknown>,\n options?: RunOptions,\n ): Promise<boolean>;\n /** Unresolved outcomes raised under these inputs, by key. */\n outcomes: ReadonlyMap<string, Outcome>;\n /** The key of the write in flight, or null. */\n pending: string | null;\n /**\n * The outcome a command would be landing on, or null when the state on\n * hand was raised under other inputs and says nothing about this key. It is\n * read between renders, so a queued command sees what the one ahead of it\n * recorded.\n */\n held(key: string): Outcome | null;\n /** Records an outcome under a key, or drops the one it holds. */\n record(key: string, outcome: Outcome | null): void;\n /** Whether something raised elsewhere was raised under these same inputs. */\n owns(tagged: ManagerTag): boolean;\n}\n\n/**\n * One write at a time against one engine and definition, with what each\n * command produced kept under the key of the row that raised it.\n */\nexport function useCommandRunner(\n engine: ViewEngine,\n definitionId: string,\n reload: ViewListState['reload'],\n): CommandRunner {\n // Kept here rather than read back from `engine.pendingWrites()`: that map is\n // keyed by request id and says nothing about which row raised a write, and\n // the error each command rejects with already carries both halves.\n const [state, setState] = useState<RunnerState>(NOTHING_RUN);\n // The same state, readable between renders. A queued command decides\n // whether it may run at all from what the command before it recorded, and\n // no render has necessarily happened in between.\n const live = useRef<RunnerState>(NOTHING_RUN);\n // The write in flight, so the next one waits for it rather than racing it.\n const queue = useRef<CommandQueue<ManagerTag> | null>(null);\n\n const owns = useCallback(\n (tagged: ManagerTag): boolean => sameTag(tagged, { engine, definitionId }),\n [definitionId, engine],\n );\n\n // State raised under other inputs is about rows this render does not list,\n // so it reads as nothing rather than being shown against these ones.\n const own = owns(state) ? state : NOTHING_RUN;\n\n const commit = useCallback((next: RunnerState): void => {\n live.current = next;\n setState(next);\n }, []);\n\n const record = useCallback(\n (key: string, outcome: Outcome | null): void => {\n const current = live.current;\n // A completion from inputs the hook has moved on from answers for a\n // row the list no longer holds; it must not land on the new one.\n if (!owns(current)) return;\n const next = withOutcome(current.outcomes, key, outcome);\n if (next === null) return;\n commit({ ...current, outcomes: next });\n },\n [commit, owns],\n );\n\n const held = useCallback(\n (key: string): Outcome | null => {\n const current = live.current;\n return owns(current) ? (current.outcomes.get(key) ?? null) : null;\n },\n [owns],\n );\n\n const execute = useCallback(\n async (\n key: string,\n intent: WritePayload,\n code: string,\n command: () => Promise<unknown>,\n again?: () => Promise<unknown>,\n /** True for a replay or a conflict choice; see `RunOptions.recovery`. */\n recovery = false,\n ): Promise<boolean> => {\n // This command is about to take the slot of whatever the key holds, so\n // a write that would be left unreachable by that is settled first; see\n // `strandedHandle`. A recovery is not a new intent — it is that very\n // handle being used.\n const stranded = recovery ? null : strandedHandle(held(key));\n if (stranded) {\n try {\n engine.abandonWrite(stranded);\n } catch {\n // Already settled, which is the state this wanted it in.\n }\n }\n // Claiming the slot also tags it: a command under new inputs starts\n // from nothing rather than inheriting the outcomes of the old ones.\n const current = live.current;\n commit(\n owns(current)\n ? { ...current, pending: key }\n : { engine, definitionId, outcomes: NO_OUTCOMES, pending: key },\n );\n try {\n await command();\n // It landed: nothing is left to recover, and the list it changed —\n // the titles, the order, the default — is now a revision behind.\n //\n // A delete is not reloaded from here. The engine has already told the\n // list, carrying the id that went (D15), and a second plain reload\n // would take that id back out of the request — leaving the row\n // listed, and named as the default, until the store answers.\n record(key, null);\n if (intent.action !== 'delete') reload();\n return true;\n } catch (caught) {\n // A refusal never left, and it may not displace a handle; see\n // `mayReplace`. The intent still rides along either way: a refusal is\n // the user's command all the same, and `resubmit` is how a preference\n // write is put again.\n const outcome = settle(caught, code, intent);\n if (mayReplace(held(key), outcome)) record(key, { ...outcome, again });\n return false;\n } finally {\n const settled = live.current;\n if (owns(settled) && settled.pending === key)\n commit({ ...settled, pending: null });\n }\n },\n [commit, definitionId, engine, held, owns, record, reload],\n );\n\n const run = useCallback(\n (\n key: string,\n intent: WritePayload,\n code: string,\n command: () => Promise<unknown>,\n { again, recovery = false, guard }: RunOptions = {},\n ): Promise<boolean> => {\n // A recovery addresses the outcome that is in the way; every other\n // command waits for it to be settled, as `holdsHandle` explains.\n const blocked = () => !recovery && holdsHandle(held(key));\n if (blocked()) return Promise.resolve(false);\n // Asked again at the front of the queue: the command ahead may be the\n // one that turns this key `unknown`, or that settles the very handle a\n // recovery was queued to address.\n const start = () =>\n blocked() || (guard !== undefined && !guard())\n ? Promise.resolve(false)\n : execute(key, intent, code, command, again, recovery);\n // Created on the first command rather than per render, and never read\n // during one: it is a mutable holder, not state anything renders from.\n const commands = (queue.current ??= createCommandQueue(sameTag));\n return enqueue(commands, { engine, definitionId }, start);\n },\n [definitionId, engine, execute, held],\n );\n\n return {\n run,\n outcomes: own.outcomes,\n pending: own.pending,\n held,\n record,\n owns,\n };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useMemo, useRef } from 'react';\nimport {\n audienceOf,\n type ViewAudience,\n type ViewConfig,\n type ViewPreferences,\n} from '../model/index.js';\nimport type {\n ConflictChoice,\n ViewEngine,\n WritePayload,\n WriteState,\n} from '../runtime/index.js';\nimport { abilitiesOf, type ViewManagerAbilities } from './manager/abilities.js';\nimport { kept, PREFERENCES_KEY, projectStates } from './manager/outcomes.js';\nimport { UNSENT } from './writes.js';\nimport {\n groupIndexOf,\n planMoveTo,\n sameOrder,\n type OptimisticOrder,\n} from './manager/order.js';\nimport {\n useCommandRunner,\n type ManagerTag,\n} from './manager/useCommandRunner.js';\nimport type { ViewListState } from './useViewList.js';\n\nexport { PREFERENCES_KEY } from './manager/outcomes.js';\nexport type {\n ManagedInstanceAbilities,\n ViewManagerAbilities,\n} from './manager/abilities.js';\n\nexport interface ViewManagerController {\n rename(id: string, title: string): Promise<boolean>;\n /**\n * Moves a view to `audience` in place (设为共享/设为个人, D18 item 10);\n * the list reloads and draws it under that group.\n */\n changeAudience(id: string, audience: ViewAudience): Promise<boolean>;\n delete(id: string): Promise<boolean>;\n /**\n * 「发布为系统视图」 (D81): a copy of the saved view, as a stored system\n * view everyone sees; the view itself stays where it is. The list reloads\n * and draws the copy among the system views.\n */\n publishAsSystem(id: string): Promise<boolean>;\n setDefault(id: string | null): Promise<boolean>;\n /**\n * Puts a view at one place inside its own audience group, counted over the\n * rows the list shows. The order is one list, but it is read as two —\n * personal above shared — so a move across that boundary is a write with\n * nothing to show for it, and there is no index that expresses one.\n *\n * It resolves false without writing when there is nothing to do: a row the\n * list no longer holds, or one already at that place.\n */\n moveTo(id: string, index: number): Promise<boolean>;\n /**\n * Where a row sits inside its own group, which is the index {@link moveTo}\n * is expressed in — a drag reads it off the row it was dropped on, the\n * arrow keys off the row itself. -1 when the list does not hold the row.\n *\n * **Ask it as the move is made, not while rendering.** A move that is\n * queued but has not landed is not in the list yet, and this answers for\n * the order that move submitted — which is the one the next move has to be\n * expressed in, and which no render can see.\n */\n placeOf(id: string): number;\n /**\n * Unresolved outcomes, by instance id or {@link PREFERENCES_KEY}. Empty\n * again once `definitionId` or `engine` changes: they answer for the rows\n * of the definition they were raised under, not for whichever list is on\n * screen now.\n */\n outcomes: ReadonlyMap<string, WriteState>;\n retry(key: string): Promise<boolean>;\n abandon(key: string): void;\n resolveConflict(key: string, choice: ConflictChoice): Promise<boolean>;\n /**\n * Puts the intent that conflicted to the store once more, as a new write\n * against the revision just reloaded — the second half of how design/management.md\n * settles a preference conflict: reload, keep the intent, put it to the\n * user again. It is not a replay of the old write, which would carry the\n * revision that lost, nor of the whole record, which would carry the other\n * half of the preferences as they were read before the reload.\n */\n resubmit(key: string): Promise<boolean>;\n /** Whether {@link resubmit} has an intent to put again under this key. */\n canResubmit(key: string): boolean;\n /**\n * The key of the write in flight, so one row alone shows progress. Commands\n * run one at a time, so there is never a second write for this one slot to\n * be wrong about.\n */\n pending: string | null;\n can: ViewManagerAbilities;\n}\n\n/** A queued move's orders, with the inputs it was computed under. */\ntype PendingOrder = OptimisticOrder & ManagerTag;\n\n/**\n * Managing the views a list shows, rather than the one that is open: rename,\n * move to the other audience, delete, reorder and choose a default, with the recovery actions for writes\n * that no runtime owns.\n *\n * Every command resolves rather than rejects, as `useSaveCommands` does: what\n * happened lands in `outcomes` under the row it belongs to, so a click handler\n * needs no try/catch and an unresolved write stays visible until the user\n * retries, overwrites or abandons it. A write that lands reloads the list,\n * because it is the list that changed.\n *\n * This is the composition alone. The rules the commands are decided by live\n * beside it: `react/writes.ts` is the one write-outcome vocabulary this hook\n * and `useSaveCommands` share, `manager/outcomes.ts` holds the map of slots\n * those rules are asked about,\n * `manager/queue.ts` serializes, `manager/order.ts` does the arithmetic of a\n * move, and `manager/useCommandRunner.ts` is the protocol all five commands\n * and the recovery actions run under.\n */\nexport function useViewManager(\n engine: ViewEngine,\n definitionId: string,\n list: ViewListState,\n): ViewManagerController {\n const { all, items, permissions, preferences, reload } = list;\n const { run, outcomes, pending, held, record, owns } = useCommandRunner(\n engine,\n definitionId,\n reload,\n );\n // What the moves already queued have submitted; see `move`.\n const optimistic = useRef<PendingOrder | null>(null);\n\n // The order on screen, and the group each row sits in. A move reasons over\n // ids alone — the order a queued one computed has nothing but ids — so the\n // audience that decides which neighbour it may swap with is looked up here\n // rather than carried along.\n const rendered = useMemo(() => items.map(item => item.id), [items]);\n // The whole definition's order, kinds this list does not draw included. It\n // is what a reorder submits: the store keeps one order per definition, and\n // an order assembled from the narrowed list would drop every id the caller\n // filtered out. The rows the user moves are still only the visible ones.\n const full = useMemo(() => all.map(item => item.id), [all]);\n const audiences = useMemo(\n () =>\n new Map<string, ViewAudience>(\n all.map(item => [item.id, audienceOf(item.scope)]),\n ),\n [all],\n );\n\n /**\n * The preferences this command means to store. It is only read when the\n * engine refuses before sending, which is why it may quote no revision.\n */\n const preferencesIntent = useCallback(\n (change: Partial<ViewPreferences>): WritePayload => ({\n action: 'preferences',\n definitionId,\n next: {\n order: preferences?.order ?? [],\n defaultInstanceId: preferences?.defaultInstanceId ?? null,\n revision: preferences?.revision ?? UNSENT,\n ...change,\n },\n }),\n [definitionId, preferences],\n );\n\n const rename = useCallback(\n (id: string, title: string) =>\n run(\n id,\n { action: 'rename', id, revision: UNSENT, title },\n 'view.rename.failed',\n () => engine.rename(id, title),\n ),\n [engine, run],\n );\n\n const changeAudience = useCallback(\n (id: string, audience: ViewAudience) =>\n run(\n id,\n { action: 'changeAudience', id, revision: UNSENT, audience },\n 'view.changeAudience.failed',\n () => engine.changeAudience(id, audience),\n ),\n [engine, run],\n );\n\n const remove = useCallback(\n (id: string) =>\n run(\n id,\n { action: 'delete', id, definitionId, revision: UNSENT },\n 'view.delete.failed',\n () => engine.delete(id),\n ),\n [definitionId, engine, run],\n );\n\n const publishAsSystem = useCallback(\n (id: string) => {\n const row = all.find(item => item.id === id);\n return run(\n id,\n {\n action: 'create',\n // Never sent. The row holds no config, and the one written is\n // read off the saved view by `engine.publishAsSystem` itself.\n // This intent is kept only for a refusal before sending\n // (`refused`), which reads its action and nothing else; a write\n // that left is reported with the engine's own payload\n // (`ViewWriteError.state`). So `config` is a stand-in of the\n // row's kind, not a copy of the view.\n input: {\n definitionId,\n title: row?.title ?? '',\n scope: 'system',\n config: { kind: row?.kind ?? 'record' } as ViewConfig,\n },\n intent: 'save-as',\n },\n 'view.publish.failed',\n () => engine.publishAsSystem(id),\n );\n },\n [all, definitionId, engine, run],\n );\n\n const setDefault = useCallback(\n (id: string | null) => {\n // The same thunk twice over: once as the command, once as the intent\n // kept for a `resubmit` after a reload settled a conflict.\n const put = () => engine.setDefault(definitionId, id);\n return run(\n PREFERENCES_KEY,\n preferencesIntent({ defaultInstanceId: id }),\n 'view.preferences.failed',\n put,\n { again: put },\n );\n },\n [definitionId, engine, preferencesIntent, run],\n );\n\n /**\n * The two orders a move reasons over, as they stand this instant.\n *\n * Moves are serialized and the list only catches up on the reload a landing\n * triggers, so two quick moves of one row would both read the same rendered\n * order and the second would ask for a place the first already put it in.\n * The order a queued move computed stands in for the list until the list is\n * no longer the one it was computed from — after which the reload has\n * landed and the rendered order is the truth again.\n *\n * It reads a ref, so it answers when it is called and not before: this is\n * for the moment a move is made, never for a render.\n */\n const current = useCallback(() => {\n const ahead = optimistic.current;\n const carried =\n ahead && owns(ahead) && sameOrder(ahead.base, full) ? ahead : null;\n return carried\n ? { visible: carried.visible, order: carried.order }\n : { visible: rendered, order: full };\n }, [full, owns, rendered]);\n\n const placeOf = useCallback(\n (id: string) => groupIndexOf(current().visible, audiences, id),\n [audiences, current],\n );\n\n const moveTo = useCallback(\n (id: string, index: number) => {\n const { visible, order: from } = current();\n const planned = planMoveTo(visible, from, audiences, id, index);\n if (planned === null) return Promise.resolve(false);\n const submitted: PendingOrder = {\n engine,\n definitionId,\n base: full,\n ...planned,\n };\n optimistic.current = submitted;\n // The whole order goes, not the one pair that moved: the server holds\n // a list, not a diff.\n const put = () => engine.reorder(definitionId, planned.order);\n const landed = run(\n PREFERENCES_KEY,\n preferencesIntent({ order: planned.order }),\n 'view.preferences.failed',\n put,\n { again: put },\n );\n void landed.then(ok => {\n // A move that never landed leaves the list where it was, so the\n // order it computed must go with it rather than stand in for a list\n // that was never rearranged.\n if (!ok && optimistic.current === submitted) optimistic.current = null;\n });\n return landed;\n },\n [audiences, current, definitionId, engine, full, preferencesIntent, run],\n );\n\n const retry = useCallback(\n (key: string) => {\n const outcome = outcomes.get(key);\n // Nothing to replay: a refusal never left, and a settled conflict is no\n // longer the engine's to answer for.\n if (!outcome?.handle) return Promise.resolve(false);\n const { handle, state } = outcome;\n return run(\n key,\n state.payload,\n 'view.retry.failed',\n () => engine.retryWrite(handle),\n // Read again at the front of the queue: the command ahead may have\n // settled this very outcome, and replaying a handle the engine no\n // longer holds would answer the click with an error about a write\n // that is already over.\n { recovery: true, guard: () => held(key)?.handle === handle },\n );\n },\n [engine, held, outcomes, run],\n );\n\n const abandon = useCallback(\n (key: string): void => {\n const outcome = outcomes.get(key);\n if (!outcome) return;\n if (outcome.handle) {\n try {\n engine.abandonWrite(outcome.handle);\n } catch {\n // Already settled. Dropping it is the whole intent, and a row left\n // showing a message nothing can clear is the only wrong answer.\n }\n }\n record(key, null);\n },\n [engine, outcomes, record],\n );\n\n const resolveConflict = useCallback(\n async (key: string, choice: ConflictChoice): Promise<boolean> => {\n const outcome = outcomes.get(key);\n if (!outcome?.handle || outcome.state.kind !== 'conflict') return false;\n const { handle, state } = outcome;\n const landed = await run(\n key,\n state.payload,\n 'view.resolve.failed',\n () => engine.resolveConflict(handle, choice),\n // As in `retry`: the conflict may have been settled by the command\n // ahead of this one in the queue.\n { recovery: true, guard: () => held(key)?.handle === handle },\n );\n // Reloading a preference conflict is not the end of it (design/management.md):\n // the stored order and default are read again, and the user's own\n // intent is kept and put to them once more rather than replayed at the\n // new revision behind their back. The list has reloaded, the row goes\n // on saying what happened, and the handle goes — the engine settled it,\n // so pressing the same button again is a new write.\n if (landed && key === PREFERENCES_KEY && choice === 'reload')\n record(key, { state, handle: null, again: outcome.again });\n return landed;\n },\n [engine, held, outcomes, record, run],\n );\n\n const resubmit = useCallback(\n (key: string): Promise<boolean> => {\n const outcome = outcomes.get(key);\n // Only an intent that was kept is put again: a conflict the engine\n // still holds is answered through `resolveConflict`, and a refusal\n // never left, so there is nothing a second identical write would do.\n if (!outcome || !kept(outcome)) return Promise.resolve(false);\n const { again, state } = outcome;\n if (!again) return Promise.resolve(false);\n // Not a recovery: the engine settled the conflict on the reload, so\n // this is an ordinary new write and the `unknown` guard applies to it\n // exactly as it does to a first attempt.\n return run(key, state.payload, 'view.preferences.failed', again, {\n again,\n });\n },\n [outcomes, run],\n );\n\n const canResubmit = useCallback(\n (key: string) => kept(outcomes.get(key)),\n [outcomes],\n );\n\n const can = useMemo<ViewManagerAbilities>(\n () => abilitiesOf(items, permissions),\n [items, permissions],\n );\n\n const states = useMemo(() => projectStates(outcomes), [outcomes]);\n\n return {\n rename,\n changeAudience,\n delete: remove,\n publishAsSystem,\n setDefault,\n moveTo,\n placeOf,\n outcomes: states,\n retry,\n abandon,\n resolveConflict,\n resubmit,\n canResubmit,\n pending,\n can,\n };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useRef } from 'react';\nimport type { ViewHandOver } from '../../runtime/index.js';\n\n/** What the sync watches, and what it does about a disagreement. */\nexport interface InstanceSyncOptions {\n /**\n * The value the host holds, or `undefined` when it holds none.\n *\n * `undefined` is the uncontrolled form and the only thing that means it: a\n * host that passes `null` is holding a value, and the value is \"whichever\n * view is the effective default\".\n */\n instanceId?: string | null;\n /** The pin the workbench holds now — `useWorkbench`'s own `chosen`. */\n chosen: string | null;\n /** Opens another view, through the leave guard. */\n choose(id: string | null): void;\n /** True while the guard's question is still on screen. */\n asking: boolean;\n /** Told what is open, in the same vocabulary `instanceId` is written in. */\n onInstanceChange?(id: string | null): void;\n /**\n * The hand-over the host passes (`WorkbenchOptions.handOver`). A host that\n * keeps one with its history entry names the handed view and hands it over\n * in one move — Back to that entry from another view does both — and the\n * hand-over opens it, under what it carries (`useHandOver`); opening it\n * here as well would open it bare, and the later of the two would win.\n */\n handOver?: ViewHandOver | null;\n}\n\n/**\n * Keeps the host's value and the open view in agreement.\n *\n * `instanceId` is controlled in the sense `value` is on an input — the host\n * is the one that says which view is open — but a view is not a string: it\n * holds an unsaved draft, and swapping it out is a loss the leave guard has\n * to ask about first. So a pushed value cannot simply be rendered. The\n * workbench *converges* on it instead: whichever side moved last is the side\n * that speaks, and the other one follows.\n *\n * - the host named a view that is not open → it is opened, through the same\n * guard a click on the sidebar goes through;\n * - the workbench moved on its own — a user's switch, the copy a save-as\n * opened, a rename, a pin released with its deleted view — → the host is\n * told, and its route follows;\n * - the guard refused the push and the user stayed → the host is told what is\n * open, so its route is never left naming a view that is not on screen.\n *\n * What is reported is exactly what may be passed back in: `null` means the\n * effective default in the report as it does in the prop, so a host can store\n * one and hand it over on the next mount without translating it.\n *\n * Switching between the two forms mid-life is unsupported, as it is on an\n * input: the first value decides which side owns the open view.\n */\nexport function useInstanceSync({\n instanceId,\n chosen,\n choose,\n asking,\n onInstanceChange,\n handOver = null,\n}: InstanceSyncOptions): void {\n /** The host's last value, so a *change* of it can be told from a rerender. */\n const seen = useRef(instanceId);\n /**\n * The last value the host and the workbench agreed on: what it pushed, or\n * what it was told. In the controlled form the prop says the first half and\n * this says the second, and they differ exactly while a report is owed.\n */\n const held = useRef(chosen);\n /** The host's last hand-over, so a new one can be told from a rerender. */\n const handed = useRef(handOver);\n\n useEffect(() => {\n const previous = seen.current;\n seen.current = instanceId;\n const handedBefore = handed.current;\n handed.current = handOver;\n // Nothing has settled while the question is still up: the answer decides\n // whether the pushed view opens or the old one stays.\n if (asking) return;\n\n const host = instanceId === undefined ? held.current : instanceId;\n if (host === chosen) {\n held.current = chosen;\n return;\n }\n // The host is the side that moved. Its own move is not reported back to\n // it, so `held` takes the pushed value before the guard sees it.\n if (instanceId !== undefined && instanceId !== previous) {\n held.current = instanceId;\n // Pushed with a new hand-over of that very view: the hand-over opens\n // it, with what it carries, through the same guard.\n const opening =\n handOver !== handedBefore &&\n handOver?.kind === 'view' &&\n handOver.instanceId === instanceId;\n if (!opening) choose(instanceId);\n return;\n }\n // The workbench is the side that moved, or the push was refused. Either\n // way it is said once: a host that does not follow is not told twice.\n if (held.current === chosen) return;\n held.current = chosen;\n onInstanceChange?.(chosen);\n }, [asking, chosen, choose, instanceId, onInstanceChange, handOver]);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useEffect, useState } from 'react';\nimport type { WriteState } from '../../runtime/index.js';\nimport { blocksNewIntent } from '../writes.js';\n\n/**\n * What the guard reads off the open view. Both facts are losses, and they are\n * different ones: edits that were never sent, and a write whose result never\n * came back — leaving takes the first away and takes away the chance to\n * settle the second.\n */\nexport interface LeaveGuardState {\n dirty: boolean;\n write: WriteState | null;\n}\n\n/**\n * Leave protection with no dialog in it: the question, and the two answers.\n *\n * A host renders whatever it likes from `asking` — `/ui` renders\n * `LeaveDialog` — so the rule about *when* work would be lost lives in one\n * place and is not retold by every surface that has to obey it.\n */\nexport interface LeaveGuard {\n /** True while a switch is waiting for an answer. */\n asking: boolean;\n /** Runs `next` now, or after the user says it is all right to lose this. */\n request(next: () => void): void;\n /** Yes: settles the pending write, then runs what was held. */\n confirm(): void;\n /** No: drops what was held and stays where it is. */\n cancel(): void;\n}\n\nexport interface LeaveGuardOptions {\n /**\n * Called on confirm, before the switch. Leaving disposes the runtime, and\n * an unsettled write outlives it inside the engine: the handle would point\n * at a runtime nobody can reach, and `engine.pendingWrites()` would hold it\n * for the rest of the session with nothing on screen able to retry,\n * overwrite or abandon it. `useWorkbench` passes `commands.abandon` here.\n */\n onLeave?(): void;\n /**\n * Whether closing the tab or navigating away is guarded too, on top of the\n * switch this hook asks about itself. On by default, and only a host that\n * owns the whole page should be turning it off: the prompt belongs to the\n * document, so a workbench that puts it up is speaking for every other\n * thing on that page (D18 Ⅸ).\n */\n guardUnload?: boolean;\n}\n\n/**\n * Whether anything would be lost by closing this view right now.\n *\n * The second loss is `blocksNewIntent`'s rule, asked rather than restated: an\n * `unknown` is the outcome the engine will not let a new write past, and\n * leaving takes away the retry or the abandon that would settle it. A\n * `conflict` is not one of these — it is answered by a new intent, which is\n * exactly what leaving gives up on deliberately, and a `rejected` never left\n * at all.\n */\nfunction costly(state: LeaveGuardState | null): boolean {\n return state !== null && (state.dirty || blocksNewIntent(state.write));\n}\n\n/**\n * The same question asked of the browser: closing the tab, going back, or\n * following a link off the page takes the draft with it, and none of that\n * goes through `request` — nothing in this package is even told it happened.\n * So while there is something to lose the page says so the one way a page\n * can, and while there is not it says nothing at all: a tab that argues\n * about being closed every time is a tab people learn to close twice.\n *\n * What it asks with is not ours to choose. Every browser shows its own\n * sentence and has ignored a custom one for a decade, so the handler carries\n * no wording — the wording that matters is `LeaveDialog`'s, which is the\n * question we *can* phrase, and this is the fallback for the exits that never\n * reach it.\n *\n * `window` is checked for, not assumed: `/react` renders on a server too, and\n * a hook that reached for a global there would take the whole page down (see\n * `environment.ts`, which answers page visibility the same way).\n */\nfunction useUnloadGuard(blocking: boolean): void {\n useEffect(() => {\n if (!blocking || typeof window === 'undefined') return;\n const ask = (event: BeforeUnloadEvent) => {\n event.preventDefault();\n // Legacy, and still what Chrome and Edge before 119 read. The value\n // itself is never shown; being non-empty is the whole of its meaning.\n event.returnValue = true;\n };\n window.addEventListener('beforeunload', ask);\n return () => {\n window.removeEventListener('beforeunload', ask);\n };\n }, [blocking]);\n}\n\n/**\n * The confirmation that stands between an open view and the next one.\n *\n * Opening another view releases this one's runtime, and a runtime is where\n * the unsaved draft lives — there is nowhere else it is kept. So leaving is\n * the deletion of work, asked about once, and a view with nothing to lose is\n * never asked about at all: a guard that interrupts every switch is one\n * people learn to dismiss without reading.\n *\n * The switch inside the page and the way out of the page are the same rule,\n * so they are read off the same `blocking`: the sidebar, the switcher and a\n * pushed `instanceId` come through `request`, and the tab's own close button\n * comes through `beforeunload` (D18 Ⅸ). An embedded view has neither — it\n * has no editor, no draft and no save, and `EmbeddedView` never calls this\n * hook — so a business page that shows one is never argued with on the way\n * out.\n */\nexport function useLeaveGuard(\n state: LeaveGuardState | null,\n { onLeave, guardUnload = true }: LeaveGuardOptions = {},\n): LeaveGuard {\n // The continuation, held until it is answered. Stored inside an object so\n // the state setter does not take it for an updater function.\n const [held, setHeld] = useState<{ next: () => void } | null>(null);\n const blocking = costly(state);\n useUnloadGuard(guardUnload && blocking);\n\n const request = useCallback(\n (next: () => void) => {\n if (blocking) setHeld({ next });\n else next();\n },\n [blocking],\n );\n\n return {\n asking: held !== null,\n request,\n confirm() {\n // Settled before the switch, not after: `next` releases this runtime,\n // and the outcome would have nothing left to be an outcome of.\n onLeave?.();\n held?.next();\n setHeld(null);\n },\n cancel() {\n setHeld(null);\n },\n };\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { defaultAnalysisConfig } from '../../analysis/index.js';\nimport { emptyDashboardConfig } from '../../dashboard/index.js';\nimport type {\n RuntimeLimits,\n ViewAudience,\n ViewConfig,\n ViewDefinition,\n ViewKind,\n} from '../../model/index.js';\nimport { defaultRecordConfig } from '../../record/index.js';\nimport type { ViewPermissions } from '../../store/index.js';\n\n/**\n * What a workbench needs before it can make a view from nothing.\n *\n * The title is required because the engine refuses a view without one, and\n * it is the UI's to word — this layer carries no catalogue — so a workbench\n * that gives none simply offers no new view. A template is the host's own\n * first view of one kind; a kind without one starts from the default built\n * from the definition.\n */\nexport interface NewViewOptions {\n /** The name a new view opens under, until the first save names it. */\n title: string;\n /**\n * What a new view of each kind starts from; the kind's own default when\n * its entry is left out. A template of the wrong kind is refused as no\n * template: it is a mistake at the call site, and a workbench that then\n * offered the default instead would hide it.\n */\n templates?: Partial<Record<ViewKind, ViewConfig>>;\n}\n\n/** What `create` will hand the engine, or null where no view can be made. */\nexport interface Blank {\n scope: ViewAudience;\n config: ViewConfig;\n}\n\n/**\n * Whether the definition offers views of this kind at all: a data definition\n * with no analysis capability has no analysis view to make, and a dashboard\n * definition holds dashboards alone.\n */\nfunction offers(definition: ViewDefinition, kind: ViewKind): boolean {\n if (kind === 'dashboard') return definition.kind === 'dashboard';\n if (definition.kind !== 'data') return false;\n return kind === 'record'\n ? definition.record !== undefined\n : definition.analysis !== undefined;\n}\n\n/** A complete starting config for a view of this kind on this definition. */\nfunction blankConfig(\n definition: ViewDefinition,\n kind: ViewKind,\n limits: RuntimeLimits,\n): ViewConfig {\n if (kind === 'dashboard' || definition.kind !== 'data')\n return emptyDashboardConfig();\n return kind === 'record'\n ? defaultRecordConfig(definition, limits)\n : defaultAnalysisConfig(definition, limits);\n}\n\n/**\n * Where a new view goes: the user's own, unless they may only publish. The\n * first save asks again, with both audiences on offer; this is only where\n * the view sits while it is being made.\n */\nfunction newViewScope(permissions: ViewPermissions): ViewAudience | null {\n if (permissions.createPersonal) return 'personal';\n if (permissions.createShared) return 'shared';\n return null;\n}\n\n/**\n * The view `create` would make, decided once from the definition, the\n * permissions and the host's template — or null, which is what turns every\n * \"new view\" control off: a definition that has no such kind, a user who\n * may create nowhere, or a workbench that gave no title to open one under.\n */\nexport function blankView(\n definition: ViewDefinition | undefined,\n kind: ViewKind,\n permissions: ViewPermissions,\n limits: RuntimeLimits,\n newView: NewViewOptions | undefined,\n): Blank | null {\n if (!newView || !definition || !offers(definition, kind)) return null;\n const scope = newViewScope(permissions);\n if (scope === null) return null;\n const config =\n newView.templates?.[kind] ?? blankConfig(definition, kind, limits);\n return config.kind === kind ? { scope, config } : null;\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useRef } from 'react';\nimport type { OpenViewState } from '../useViewEngine.js';\n\n/**\n * Lets the pinned view go once it is gone.\n *\n * A delete from the manager disposes the runtime; `useOpenView` asks for the\n * id again and is told there is no such view. That is the cue — and only for\n * a view that was open, never for an id the host asked for and the store\n * never had, which is a mistake to report rather than to navigate away from.\n *\n * Every workbench needs it, and for the same reason: a `chosen` id left\n * pinned to a deleted view answers \"not found\" for as long as the page is\n * open, so the page would never move on to the view that is still there.\n */\nexport function useReleaseDeleted(\n /** The id actually being opened: the pin, or the list's default. */\n openId: string | null,\n /** The pin alone; only a pinned id is this hook's to release. */\n chosen: string | null,\n opened: OpenViewState,\n setChosen: (id: string | null) => void,\n): void {\n const wasOpen = useRef<string | null>(null);\n const { runtime } = opened;\n const failed = opened.error?.code;\n useEffect(() => {\n if (runtime) wasOpen.current = openId;\n }, [runtime, openId]);\n useEffect(() => {\n if (chosen === null || chosen !== wasOpen.current) return;\n if (failed !== 'view.open.failed.not_found') return;\n wasOpen.current = null;\n setChosen(null);\n }, [chosen, failed, setChosen]);\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n useEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from 'react';\nimport type {\n AnalysisViewConfig,\n FilterNode,\n FilterTree,\n RecordViewConfig,\n ViewConfig,\n ViewKind,\n} from '../../model/index.js';\nimport {\n isSimpleTree,\n nodeAt,\n type FilterPath,\n removeAt,\n sameFilterTree,\n} from '../../filter/index.js';\nimport type {\n AnyViewRuntime,\n ViewRuntime,\n SavedViewTarget,\n ViewEngine,\n ViewHandOver,\n} from '../../runtime/index.js';\nimport {\n handedConditions,\n withHandedFilter,\n} from '../../runtime/navigation.js';\nimport { listenerSet } from '../../runtime/listeners.js';\nimport type { FilterEditorController } from '../useFilterEditor.js';\nimport type { HeldView } from '../useWorkbench.js';\n\n/**\n * Opens each new `handOver` once, through the leave guard (D22 H, D26 Q30):\n * a view a dashboard or an embed sent through the host's route.\n *\n * - One nobody saved (`unsaved`) — a follow-up on a group, a board's own\n * analysis — opens as a view made from nothing does: unsaved, under its\n * title until its first save, which is a create; held as `handed`, so the\n * shell opens it with its editor folded. One of a kind the workbench does\n * not draw is left alone.\n * - A saved one (`view`) is opened by its id (`open`), which is what makes\n * it that view — listed, saved in place, routed by its id.\n *\n * Either runs under the handed `scopeFilter` as its scope. The same object\n * again opens nothing — a host re-rendering with the route it already\n * followed must not open a second copy — so a host opens the same view\n * twice by handing a new object, or by handing none in between (Back to\n * the entry that holds it, after a switch that handed nothing).\n *\n * Opening is an effect, so StrictMode's rehearsal of the unmount closes the\n * view the first run opened (the workbench lets its held views go on the way\n * out); what was seen is forgotten with it, and the second run opens it\n * again.\n */\nexport function useHandOver(\n handOver: ViewHandOver | null | undefined,\n context: {\n engine: ViewEngine;\n definitionId: string;\n kinds: readonly ViewKind[];\n request(proceed: () => void): void;\n hold(view: HeldView): void;\n open(target: SavedViewTarget): void;\n },\n): void {\n const { engine, definitionId, kinds, request, hold, open } = context;\n const seen = useRef<ViewHandOver | null>(null);\n useEffect(\n () => () => {\n seen.current = null;\n },\n [],\n );\n useEffect(() => {\n // One the host stopped handing is forgotten: the same object handed\n // again later — Back to the history entry that holds it — is a new\n // hand-over, not a rerender of the route already followed.\n if (!handOver) {\n seen.current = null;\n return;\n }\n if (seen.current === handOver) return;\n seen.current = handOver;\n if (handOver.kind === 'view') {\n request(() => open(handOver));\n return;\n }\n if (!kinds.includes(handOver.config.kind)) return;\n request(() => {\n const made = engine.create(definitionId, {\n title: handOver.title,\n scope: 'personal',\n config: handOver.config,\n scopeFilter: handOver.scopeFilter,\n });\n hold({\n runtime: made,\n draft: made.getSnapshot().draft,\n origin: null,\n from: null,\n handed: true,\n ...(handOver.named ? { named: handOver.named } : {}),\n ...(handOver.from ? { board: handOver.from } : {}),\n });\n });\n }, [handOver, kinds, request, engine, definitionId, hold, open]);\n}\n\n/**\n * A saved view handed over (`SavedViewTarget`), once it is open by its id:\n * what the reader set on the board goes onto its own conditions and runs —\n * so it opens 「已修改」, the conditions on 「正在显示」 each removable,\n * and 「还原」 takes them back off. They go onto what the view was saved\n * with, not onto whatever draft it had: the leave guard already asked\n * before that draft went.\n *\n * Answers the draft it was left with, once, until the reader touches it:\n * leaving an untouched hand-over asks nothing, as leaving an untouched view\n * made from nothing asks nothing. Once per hand-over and runtime: a runtime\n * opened again for the same hand-over (StrictMode's rehearsal closes the\n * first) takes the conditions again, since it opened on the saved view.\n *\n * Landing edits the runtime, which is an effect; what it left is read on\n * render, so the effect writes it into a store `useSyncExternalStore`\n * reads (`landingStore`) rather than calling `setState` from its body.\n */\nexport function useHandedConditions(\n handed: SavedViewTarget | null,\n runtime: AnyViewRuntime | null,\n): ViewConfig | null {\n const landing = useState(landingStore)[0];\n const landed = useSyncExternalStore(\n landing.subscribe,\n landing.get,\n landing.get,\n );\n useEffect(() => {\n if (!handed || !runtime) return;\n const last = landing.get();\n if (last?.target === handed && last.runtime === runtime) return;\n const snapshot = runtime.getSnapshot();\n const own = snapshot.saved?.config ?? snapshot.draft;\n if (own.kind !== 'dashboard' && handed.filter) {\n const merged = withHandedFilter(own, handed.filter);\n const data = runtime as ViewRuntime<\n RecordViewConfig | AnalysisViewConfig\n >;\n data.edit({ filter: merged.filter, filterMode: merged.filterMode });\n data.apply();\n }\n landing.set({\n target: handed,\n runtime,\n draft: runtime.getSnapshot().draft,\n });\n }, [handed, runtime, landing]);\n return landed && landed.target === handed && landed.runtime === runtime\n ? landed.draft\n : null;\n}\n\n/** What a hand-over left a runtime with: the draft, once it landed. */\ninterface Landed {\n target: SavedViewTarget;\n runtime: AnyViewRuntime;\n draft: ViewConfig;\n}\n\n/** The last landing, as a store the effect writes and React reads. */\nfunction landingStore() {\n let landed: Landed | null = null;\n const listeners = listenerSet();\n return {\n get: (): Landed | null => landed,\n set(next: Landed): void {\n landed = next;\n listeners.emit();\n },\n subscribe: listeners.subscribe,\n };\n}\n\n/**\n * The filter editor of a saved view handed over (`SavedViewTarget`), whose\n * ✕ on 「正在显示」 takes a condition the board handed it **off** rather\n * than blanking it (D26 Q30). ✕ elsewhere clears a condition's value and\n * leaves its field in the editor for the next question — the reader put the\n * field there. A handed condition is no row the reader built: blanked, it\n * stayed behind as a field-without-a-value the saved view never had, so\n * taking every handed condition off still read 「已修改」 with 保存 offered\n * (walk of #1882). So one is removed outright, and once the tree is the\n * saved one again — the \"all of\" `drillFilter` wrapped an advanced tree in\n * included — the saved filter and its mode come back as they were, and the\n * view is clean.\n *\n * A handed condition is a child of the root \"all of\" (`withHandedFilter`\n * puts them there) equal to one handed; one the saved view holds as well is\n * the view's own, and cleared as any other. The same controller otherwise.\n */\nexport function useHandedRemoval(\n filter: FilterEditorController,\n handed: SavedViewTarget | null,\n runtime: AnyViewRuntime | null,\n): FilterEditorController {\n return useMemo(() => {\n const conditions = handedConditions(handed?.filter ?? null);\n if (!runtime || conditions.length === 0) return filter;\n return {\n ...filter,\n clearValue(path: FilterPath) {\n const { draft, saved } = runtime.getSnapshot();\n const own = saved?.config;\n if (\n draft.kind === 'dashboard' ||\n !own ||\n own.kind === 'dashboard' ||\n own.kind !== draft.kind\n ) {\n filter.clearValue(path);\n return;\n }\n const node = path.length === 1 ? nodeAt(draft.filter, path) : null;\n if (\n !node ||\n !conditions.some(condition => sameFilterTree(node, condition)) ||\n heldBy(own.filter, node)\n ) {\n filter.clearValue(path);\n return;\n }\n const rest = removeAt(draft.filter, path);\n const data = runtime as ViewRuntime<\n RecordViewConfig | AnalysisViewConfig\n >;\n data.edit(\n backToSaved(rest, own.filter)\n ? { filter: own.filter, filterMode: own.filterMode }\n : { filter: rest },\n );\n },\n };\n }, [filter, handed, runtime]);\n}\n\n/** Whether a saved tree holds `node` among its root's own conditions. */\nfunction heldBy(saved: FilterTree, node: FilterNode): boolean {\n return (\n isSimpleTree(saved) &&\n saved.children.some(child => sameFilterTree(child, node))\n );\n}\n\n/**\n * Whether what is left is the saved tree: the same, or the saved tree alone\n * in the \"all of\" `drillFilter` wrapped it in to add to it.\n */\nfunction backToSaved(rest: FilterTree, saved: FilterTree): boolean {\n if (sameFilterTree(rest, saved)) return true;\n const [only] = rest.children;\n return (\n rest.op === 'and' &&\n rest.children.length === 1 &&\n only !== undefined &&\n sameFilterTree(only, saved)\n );\n}\n","/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport {\n parseSystemInstanceId,\n sameJson,\n type FilterNode,\n type FilterTree,\n type Issue,\n type RecordViewConfig,\n type ViewConfig,\n type ViewInstance,\n type ViewKind,\n} from '../model/index.js';\nimport { drillFilter, narrowsTo } from '../analysis/index.js';\nimport { defaultRecordConfig } from '../record/index.js';\nimport type {\n AnyViewRuntime,\n BoardOrigin,\n GroupNaming,\n SavedViewTarget,\n ViewEngine,\n ViewHandOver,\n ViewNavigation,\n ViewRuntimeState,\n WriteAction,\n} from '../runtime/index.js';\nimport {\n lookedOnly,\n untouchedSince,\n withFilterMode,\n} from '../runtime/navigation.js';\nimport { kindMismatch } from './issues.js';\nimport { useAutoRefresh, type RefreshController } from './useAutoRefresh.js';\nimport {\n useFilterEditor,\n type FilterEditorController,\n} from './useFilterEditor.js';\nimport { useSaveCommands, type SaveCommands } from './useSaveCommands.js';\nimport {\n useOpenView,\n useViewRuntime,\n type DashboardOpening,\n type OpenViewState,\n} from './useViewEngine.js';\nimport { useViewList, type ViewListState } from './useViewList.js';\nimport {\n useViewManager,\n type ViewManagerController,\n} from './useViewManager.js';\nimport { useInstanceSync } from './workbench/instanceSync.js';\nimport { useLeaveGuard, type LeaveGuard } from './workbench/leaveGuard.js';\nimport { blankView, type NewViewOptions } from './workbench/newView.js';\nimport { useReleaseDeleted } from './workbench/releaseDeleted.js';\nimport {\n useHandedConditions,\n useHandedRemoval,\n useHandOver,\n} from './workbench/handOver.js';\n\nexport interface WorkbenchOptions {\n /**\n * The kinds this workbench has parts for. They narrow the list — and with\n * it the effective default — and an instance of any other kind is reported\n * as unopenable. A data workbench draws record and analysis views in one\n * list (D20); a host narrows it to one kind by naming only that one (D9).\n */\n kinds: readonly ViewKind[];\n /**\n * Which view is open, as `value` is on an input: leaving it out is the\n * uncontrolled form and the workbench owns the open view from the effective\n * default on; passing it — a string, or `null` for that effective default —\n * makes the host the one that says which view is open, and every later\n * change of it opens that view.\n *\n * It converges rather than renders, because a view holds an unsaved draft:\n * a pushed value goes through the same leave guard a click goes through,\n * and `onInstanceChange` says what is open now. See\n * `workbench/instanceSync.ts` for the whole of that contract.\n */\n instanceId?: string | null;\n /**\n * Told which view is open whenever that changes: the user picked another,\n * a save-as opened its copy, a rename kept it, or a deleted view let the\n * pin go. `null` means the effective default, exactly as it does in\n * `instanceId`, so what comes out goes back in unchanged — which is what\n * makes a workbench addressable by a route.\n */\n onInstanceChange?(id: string | null): void;\n /**\n * Whether closing the tab is guarded as well as switching views. On by\n * default; a host that mounts this workbench as one part of a larger page\n * — or renders it on a server — can say no. See `workbench/leaveGuard.ts`.\n */\n guardUnload?: boolean;\n /**\n * What a view made from nothing opens as: the name it carries until its\n * first save, and the config it starts from. Left out, the workbench\n * offers no new view — the engine refuses a view with no title, and the\n * title is wording, which this layer does not carry. `/ui` passes its\n * catalogue's word; a host's own template goes in `templates`. A view\n * opened out of another is named by whoever opens it (`drill`, `follow`),\n * so this has no say there.\n */\n newView?: NewViewOptions;\n /**\n * Takes over drilling (H5): given, the workbench builds the record view a\n * row would open and hands it here instead of holding it — a host that\n * wants the records on a page of its own opens them there. `canDrill` is\n * unchanged by it; the gesture exists exactly when there is something to\n * drill into.\n */\n onDrilldown?(target: DrillTarget): void;\n /**\n * What a dashboard opens with (D22 E, F), asked as each view opens: the\n * tab and the filter values a host's route names. Nothing, and the board\n * opens where its reader last read it, every filter at its default\n * (`ViewEngine.open`).\n */\n opening?(instanceId: string): DashboardOpening | undefined;\n /**\n * A view a dashboard or an embed handed the host's route, to open here\n * (D22 H, D26 Q30): a saved one (`view`), opened by its id with what the\n * reader set on the board among its own conditions, or one nobody saved\n * (`unsaved`) — a follow-up on a group, a board's own analysis — opened as\n * a view made from nothing. Either runs under what the page holds as its\n * scope. Each new object opens once, through the leave guard\n * (`useHandOver`).\n */\n handOver?: ViewHandOver | null;\n /**\n * The host's route, which the way back to the board a view was handed\n * from goes by (`board`, D26 Q33). Without it there is no way back drawn.\n */\n onNavigate?(to: ViewNavigation): void;\n}\n\n/**\n * Where a held view came from: the view it was drilled out of, and the\n * conditions the drill added. It is the workbench's fact, not the view's —\n * the \"from\" line under the title bar reads it, and going back is the\n * workbench's command — so it lives beside the held view rather than in its\n * config, which is what a save would keep.\n */\nexport interface ViewOrigin {\n /** The view drilled from, still open with the result it was drilled on. */\n runtime: AnyViewRuntime;\n title: string;\n /** What the drill added to the origin's conditions: the row's own. */\n conditions: readonly FilterNode[];\n}\n\n/** What a drill would open, as offered to a host that takes drilling over. */\nexport interface DrillTarget {\n definitionId: string;\n origin: ViewOrigin;\n /** The name the records open under, as the caller of `drill` gave it. */\n title: string;\n /** The record view: the origin's filter plus the row's, default columns. */\n config: RecordViewConfig;\n /** The origin's injected scope, which the drilled view inherits (H4). */\n scopeFilter: FilterTree | null;\n}\n\n/**\n * A view the workbench holds rather than opens by id: made from nothing, or\n * drilled out of another. The draft it opened with is kept so the leave\n * guard can tell an untouched one — which costs nothing to let go — from one\n * the user has already shaped.\n */\nexport interface HeldView {\n runtime: AnyViewRuntime;\n draft: ViewConfig;\n /** Null for a view made from nothing; a drilled view knows its origin. */\n origin: ViewOrigin | null;\n /**\n * What its title says of the group it was opened from, when it names one\n * (「订单 · 仓库 是 华南」): while those conditions still narrow it, the\n * title stands; once the reader takes one off, the workbench calls it by\n * `subject` (`WorkbenchController.state`).\n */\n named?: GroupNaming;\n /**\n * The held view the origin itself was, when it was one: drilling out of an\n * unsaved analysis view — or out of a group already followed — must not\n * let that view go, so going back puts it back as it was held.\n */\n from: HeldView | null;\n /**\n * Handed over by a host (`WorkbenchOptions.unsaved`) — a dashboard's\n * follow-up on a group, a board's own analysis — rather than made here:\n * like a view opened from another's group, its conditions are what it was\n * opened with, so the shell opens it with its editor folded.\n */\n handed?: true;\n /** The board it was handed from, for the way back (`WorkbenchController.board`). */\n board?: BoardOrigin;\n}\n\n/**\n * Everything a workbench needs that is not its own markup: which views there\n * are, which one is open, what it says, and what happens when the user moves\n * to another.\n *\n * The default workbenches differ in their editor and their result and in\n * nothing else, so the shell around those two is assembled once here. A host\n * that writes its own markup calls this and loses none of the rules — the\n * wrong-kind report, the released pin, the leave guard and the header's four\n * outcomes are all in the controller rather than in the components.\n */\nexport interface WorkbenchController {\n /** The kinds this workbench draws, as it was given them. */\n kinds: readonly ViewKind[];\n /**\n * 「改了就跑」 (D20): whether an analysis runs again on its own as its\n * question is edited — the user's preference for this definition, on\n * when unsaid, pushed onto the open analysis view. The range still waits\n * for Apply either way.\n */\n autoRun: boolean;\n setAutoRun(on: boolean): Promise<void>;\n /** The views of this definition, of those kinds, in the user's order. */\n list: ViewListState;\n manager: ViewManagerController;\n /** What is open now: the explicit choice, or the effective default. */\n openId: string | null;\n /** Opens another view, through the leave guard. */\n choose(id: string | null): void;\n /**\n * The kinds a new view may be made of here, in the order of `kinds`: the\n * definition has the kind, the user may create in some audience, and\n * `newView` gave it a name. Every \"new view\" control exists on this and\n * on nothing else (D4) — one kind is a button, several are a menu, none is\n * no control.\n */\n creatable: readonly ViewKind[];\n /**\n * Opens a view of that kind made from nothing, through the leave guard;\n * a kind not in `creatable` does nothing. It is unsaved until its first\n * save, which is a create: the workbench then opens what the store took,\n * as it does a copy. An unsaved view has no id, so a host routing the\n * workbench hears nothing until that save lands.\n */\n create(kind: ViewKind): void;\n /**\n * The view the workbench holds instead of opening by id, if any: one made\n * from nothing, or one opened out of another (`drill`, `follow`). Its\n * `origin` is what the \"from\" line reads.\n */\n held: HeldView | null;\n /**\n * Whether a row of the open analysis view can open the records behind it\n * (H2): the workbench draws record views and the definition has them.\n * The drill gesture exists on this and on nothing else.\n */\n canDrill: boolean;\n /**\n * Opens the records behind one row of the open analysis view: an unsaved\n * record view under the origin's conditions plus `conditions`, held with\n * its origin so the way back is on screen (D20). The origin stays open\n * with the result it was drilled on, so going back shows that result\n * rather than running it again. Nothing is left behind, so the leave guard\n * is not asked. Does nothing while `canDrill` is false.\n *\n * `title` is what the records open under until they are saved — wording,\n * which this layer does not carry, so the caller says it: `/ui` names them\n * by what they are, the definition's records of that group (D20 追问).\n * `subject` is that name without the group, which the view goes by once\n * `conditions` no longer narrow it (`GroupNaming`); left out, `title`\n * stands whatever the conditions become.\n */\n drill(\n conditions: readonly FilterNode[],\n title: string,\n subject?: string,\n ): void;\n /**\n * Opens `config` as a view of its own, held with the open view as its\n * origin: the follow-up that narrows an analysis to one group (D20 追问\n * 「只显示这一组」) is a new question beside the one it came from, not an\n * edit that writes over it. The origin stays open with its result, so\n * `back()` shows that result again without running it; the view opened is\n * unsaved, named `title`, under the origin's injected scope, and saving it\n * is a first save like any new view's. `conditions` are what the follow-up\n * added, kept on the origin for whoever reads it. The origin keeps its\n * draft, so the leave guard is not asked. `subject` is as `drill`'s.\n */\n follow(\n config: ViewConfig,\n title: string,\n conditions: readonly FilterNode[],\n subject?: string,\n ): void;\n /**\n * Returns to the held view's origin, through the leave guard: an untouched\n * view opened out of another goes without a question, one the user shaped\n * is asked about. Does nothing while nothing held has an origin.\n */\n back(): void;\n /**\n * The board the open view was handed from (D26 Q33), while it is the view\n * on screen and a route goes back: the shell draws 「返回〈仪表盘〉」 from\n * it. `null` under a view opened out of another here, whose own way back\n * (`back`) is the one on screen.\n */\n board: BoardOrigin | null;\n /** Goes back to `board` through the host's route, past the leave guard. */\n toBoard(): void;\n /**\n * Whether the view on screen is one a board or an embed handed over\n * (`handOver`, D26 Q30), saved or not: the press that sent it took the\n * keyboard off the page it was on, so the shell gives it to the title.\n */\n handedOver: boolean;\n opened: OpenViewState;\n /** Null while the view is unopenable or still loading. */\n runtime: AnyViewRuntime | null;\n /**\n * The open view's state — under the name it goes by now: a held view\n * named by a group whose conditions it no longer runs under is called by\n * its `subject` (`HeldView.named`), so the title bar, 「另存为」 and a\n * follow-up opened from it never name a group it does not show.\n */\n state: ViewRuntimeState<ViewConfig> | null;\n /**\n * Why there is nothing to draw: the open failed, or it opened and is of\n * another kind. A host may name any id, so a view this page has no kernel\n * for is reported where every other failure to open is, rather than left\n * as a title bar over an empty body.\n */\n unopenable: Issue | null;\n /**\n * What admission found wrong with the definition itself — a system view\n * the kernel refuses, a field group naming a field it does not have.\n * The shell shows them in the status line beside the view's own, since a\n * definition's error is otherwise reported to `onIssue` alone and the\n * screen said nothing.\n */\n definitionIssues: Issue[];\n /**\n * Where the open view sits in the definition's `views`, when it is one\n * the definition declares in code, else `null`. A definition finding under\n * `['views', n, …]` with this `n` is about the view on screen — which, for\n * a board, reports its own panels' findings by name as well (`panels`),\n * so the status line says each once.\n */\n declaredAt: number | null;\n commands: SaveCommands;\n /**\n * How the open view renews its own answer: one refresh now, and the\n * interval it keeps itself up to date by. It is assembled here rather than\n * in each workbench because `refresh` lives on `ViewConfigBase` — every\n * kind has one, and every kind reaches it the same way.\n */\n refresh: RefreshController;\n /**\n * The open view's filter editor. One per opening, built here because the\n * shell needs it too — the applied bar describes it, and the error strip\n * shows exactly the errors it does not mark (`filter.unmarked`).\n */\n filter: FilterEditorController;\n leave: LeaveGuard;\n /** A saved copy is what the workbench then shows. */\n onSaved(instance: ViewInstance): void;\n /**\n * A rename keeps the view. The pin goes on before the reload: a workbench\n * riding on the default would otherwise close its runtime and lose the\n * draft.\n */\n onRenamed(instance: ViewInstance): void;\n /**\n * A delete moves on. The engine let the runtime go with the instance, and\n * it has already told the list which id went (D15), so all that is left\n * here is to let the pin go: the default moves, and the open id follows it\n * — or empties with the list.\n */\n onDeleted(): void;\n /** A recovered write may have changed the list; read it again. */\n onRecovered(action: WriteAction): void;\n}\n\n/**\n * The shell of one workbench, without any of its look.\n *\n * The kinds are a parameter: what differs between record, analysis and\n * dashboard is the editor and the result they render from `runtime`, not the\n * way a view is found, opened, left or saved.\n *\n * One command is the exception, and it is the follow-up seam rather than an\n * oversight: `drill` opens the records behind one group of an analysis\n * result (D20 追问). It names both kinds on purpose — `canDrill` asks the\n * open view to be an `analysis` and `record` to be among the kinds this\n * workbench lists, and what it opens is a `RecordViewConfig` built from\n * `defaultRecordConfig` with `drillFilter` over the conditions that ran.\n * Nothing else here reads a kind.\n */\nexport function useWorkbench(\n engine: ViewEngine,\n definitionId: string,\n options: WorkbenchOptions,\n): WorkbenchController {\n const {\n instanceId,\n onInstanceChange,\n guardUnload,\n newView,\n onDrilldown,\n opening,\n onNavigate,\n } = options;\n // Held by what they say: a host writes the array inline, so the object is\n // new every render while the kinds in it are not.\n const kindsKey = options.kinds.join(' ');\n const kinds = useMemo(() => kindsKey.split(' ') as ViewKind[], [kindsKey]);\n // Only the views this page can open: the sidebar offers no view the body\n // cannot render, and the effective default is resolved among those alone.\n const list = useViewList(engine, definitionId, { kinds });\n const [chosen, setChosen] = useState<string | null>(instanceId ?? null);\n const openId = chosen ?? list.defaultInstanceId;\n\n // A view the workbench holds is opened by this hook and not by an id, so\n // it is kept here beside the pin. While one made from nothing is open,\n // nothing is opened by id — the pin stays what it was and comes back into\n // force once the view is saved or let go. A drilled view is different: its\n // origin is the view opened by id, and it stays open underneath with the\n // result it was drilled on, which is what going back shows.\n //\n // The ref is what the release reads: closing a runtime belongs to the\n // moment it is replaced, not to a render.\n const [held, setHeld] = useState<HeldView | null>(null);\n const heldRef = useRef<HeldView | null>(null);\n const hold = useCallback(\n (next: HeldView | null) => {\n const previous = heldRef.current;\n heldRef.current = next;\n setHeld(next);\n // The one runtime that must not go with the view it drew is the origin\n // a drill is keeping: it comes back as it was held.\n if (previous && previous !== next?.from) engine.close(previous.runtime);\n },\n [engine],\n );\n // On the way out only. A cleanup keyed on the view itself would close it\n // under StrictMode's rehearsal of the unmount, with nothing to open it\n // again — the view was made by a press, not by an effect.\n useEffect(\n () => () => {\n // Every held view in the chain: a drilled view over the unsaved view\n // it came from is two runtimes to let go.\n for (let view = heldRef.current; view; view = view.from)\n engine.close(view.runtime);\n heldRef.current = null;\n },\n [engine],\n );\n\n // A saved view a board handed over (D26 Q30): the page's hold is its\n // scope for as long as it is the view opened by id, and goes when the\n // reader picks another.\n const [handed, setHanded] = useState<SavedViewTarget | null>(null);\n const handedHere =\n handed &&\n handed.instanceId === openId &&\n handed.definitionId === definitionId\n ? handed\n : null;\n // A view made from nothing releases the one opened by id; a drilled view\n // keeps it, because it is the origin.\n // Only this definition's views: an id of another's — an address two\n // workbenches share, a host's slip — is refused before it runs.\n const opensHere = useCallback(\n (id: string) => ({ ...opening?.(id), definitionId }),\n [opening, definitionId],\n );\n const byId = useOpenView(\n engine,\n held && !held.origin ? null : openId,\n handedHere?.scopeFilter ?? null,\n opensHere,\n );\n const opened: OpenViewState = held\n ? {\n runtime: held.runtime,\n loading: false,\n error: null,\n scopeIssues: [],\n // Never offered: a view held here was made, and did not fail to open.\n retry: byId.retry,\n }\n : byId;\n const wrongKind = held ? null : kindMismatch(byId.runtime, kinds);\n const runtime = held ? held.runtime : wrongKind ? null : byId.runtime;\n const current = useViewRuntime(runtime);\n const handedDraft = useHandedConditions(\n handedHere,\n wrongKind ? null : byId.runtime,\n );\n const state = useMemo(() => namedState(current, held), [current, held]);\n const autoRun = list.preferences?.autoRun ?? true;\n // The preference reaches every runtime alike; which members run on their\n // own is the model's to say per kind (`autoRunMembers`), and a kind that\n // declares none never does. Read whenever it or the open view changes.\n // Held off until the preferences have answered: the default `true` above\n // stands in only for a preference that is not there, and a reader who\n // turned it off would otherwise have an edit made before the answer run\n // on its own. One made while held runs once the answer turns it on.\n const preferencesSettled = list.preferencesSettled;\n useEffect(() => {\n runtime?.setAutoApply(preferencesSettled && autoRun);\n }, [runtime, autoRun, preferencesSettled]);\n // A handed saved view's ✕ takes a board's condition off (D26 Q30); a\n // view held here is another runtime, and clears as any view does.\n const filter = useHandedRemoval(\n useFilterEditor(runtime),\n held ? null : handedHere,\n runtime,\n );\n const refresh = useAutoRefresh(runtime);\n const commands = useSaveCommands(engine, runtime);\n const manager = useViewManager(engine, definitionId, list);\n const leave = useLeaveGuard(\n state\n ? {\n // A held view counts as dirty from the start — losing it loses\n // everything — but one nobody has touched yet holds nothing worth\n // a question: the draft is the config it opened with.\n // A saved view handed over is the same: what the board added is\n // its only change until the reader makes another, and the way\n // back puts that on the board again (D26 Q33). Compared as it\n // is, keys and all: shaped and shaped back is untouched.\n // A search, a sort or a page size on a view this reader cannot\n // save in place is a look-up, not work (R2-39).\n dirty: held\n ? !sameJson(state.draft, held.draft)\n : state.dirty &&\n !untouchedSince(state.draft, handedDraft) &&\n (commands.can.save || !lookedOnly(state, runtime?.definition)),\n write: state.write,\n }\n : null,\n // Leaving settles the outcome first, because the runtime it belongs to\n // is about to go.\n { onLeave: () => commands.abandon(), guardUnload },\n );\n useReleaseDeleted(openId, chosen, byId, setChosen);\n\n // Read off the guard rather than the guard itself: `request` is the one\n // stable part of it, and the object is new on every render.\n const request = leave.request;\n const choose = useCallback(\n // Opening another view releases this one's runtime and the draft goes\n // with it, so the switch is asked about before it happens.\n (id: string | null) =>\n request(() => {\n hold(null);\n setHanded(null);\n setChosen(id);\n }),\n [request, hold],\n );\n const openHanded = useCallback(\n (target: SavedViewTarget) => {\n hold(null);\n setHanded(target);\n setChosen(target.instanceId);\n },\n [hold],\n );\n useHandOver(options.handOver, {\n engine,\n definitionId,\n kinds,\n request,\n hold,\n open: openHanded,\n });\n // Which view is open is the one piece of workbench state a host may also\n // hold — a route, a link somebody shares — so the two are kept in\n // agreement here, once, for every workbench and every hand-built one.\n useInstanceSync({\n instanceId,\n chosen,\n choose,\n asking: leave.asking,\n onInstanceChange,\n handOver: options.handOver,\n });\n\n // Decided once per render from what is true now, so the controls that\n // offer a new view and the command they call cannot disagree.\n const definition = engine.definitions.get(definitionId);\n const permissions = engine.permissions(definitionId);\n const blanks = kinds.map(\n kind =>\n [\n kind,\n blankView(definition, kind, permissions, engine.limits, newView),\n ] as const,\n );\n const creatable = blanks\n .filter(([, blank]) => blank !== null)\n .map(([kind]) => kind);\n const title = newView?.title;\n const create = useCallback(\n (kind: ViewKind) => {\n const blank = blanks.find(([made]) => made === kind)?.[1];\n if (!blank || title === undefined) return;\n request(() => {\n const made = engine.create(definitionId, {\n title,\n scope: blank.scope,\n config: blank.config,\n });\n hold({\n runtime: made,\n draft: made.getSnapshot().draft,\n origin: null,\n from: null,\n });\n });\n },\n [blanks, title, request, engine, definitionId, hold],\n );\n\n // Opens `config` beside the view on screen, which becomes its origin: kept\n // open with its result, so going back shows that result without a run.\n // Not a permission: a view opened this way is looked at, not written (H1);\n // its first save asks, as a new view's does. It inherits the origin's\n // scope as it is — the page's narrowing is not the view's to widen (H4).\n //\n // Not through the leave guard either: nothing is left. The origin keeps\n // its draft and its pending write, held or opened by id, and `back()`\n // returns to both — asking \"leave without saving?\" here would name a loss\n // that does not happen.\n const holdFrom = useCallback(\n (\n config: ViewConfig,\n viewTitle: string,\n conditions: readonly FilterNode[],\n subject?: string,\n ) => {\n if (!runtime || !state) return;\n const made = engine.create(definitionId, {\n title: viewTitle,\n scope: 'personal',\n config,\n scopeFilter: runtime.scopeFilter,\n });\n hold({\n runtime: made,\n draft: made.getSnapshot().draft,\n origin: { runtime, title: state.title, conditions },\n from: heldRef.current,\n ...(subject === undefined ? {} : { named: { subject, conditions } }),\n });\n },\n [runtime, state, engine, definitionId, hold],\n );\n\n // Drilling needs a record view to open and a place to draw it.\n const canDrill =\n runtime?.kind === 'analysis' &&\n kinds.includes('record') &&\n definition?.kind === 'data' &&\n definition.record !== undefined;\n const drill = useCallback(\n (\n conditions: readonly FilterNode[],\n viewTitle: string,\n subject?: string,\n ) => {\n if (\n !canDrill ||\n !runtime ||\n !state ||\n state.applied.kind === 'dashboard' ||\n !definition ||\n definition.kind !== 'data'\n )\n return;\n // Under what ran, not what is being typed: the row came from the\n // applied conditions.\n // Advanced where the row's range could not flatten beside the\n // analysis's own on the same field (`drillFilter`).\n const config: RecordViewConfig = withFilterMode({\n ...defaultRecordConfig(definition, engine.limits),\n filter: drillFilter(state.applied.filter, conditions),\n });\n if (onDrilldown) {\n onDrilldown({\n definitionId,\n origin: { runtime, title: state.title, conditions },\n title: viewTitle,\n config,\n scopeFilter: runtime.scopeFilter,\n });\n return;\n }\n holdFrom(config, viewTitle, conditions, subject);\n },\n [\n canDrill,\n runtime,\n state,\n definition,\n engine,\n definitionId,\n onDrilldown,\n holdFrom,\n ],\n );\n const back = useCallback(() => {\n const current = heldRef.current;\n if (!current?.origin) return;\n // The origin was either held itself — put back as it was — or opened by\n // id, which never closed: letting the drilled view go shows it again,\n // with the result it kept.\n request(() => hold(current.from));\n }, [request, hold]);\n // The board a view was handed from, while that view is on screen: a view\n // opened out of it here shows its own way back instead.\n const board = !onNavigate\n ? null\n : held\n ? held.origin\n ? null\n : (held.board ?? null)\n : (handedHere?.from ?? null);\n const toBoard = useCallback(() => {\n if (board) request(() => onNavigate?.(board.back));\n }, [board, request, onNavigate]);\n\n const reload = list.reload;\n const open = useCallback(\n (instance: ViewInstance) => {\n // What the store took is what the screen shows from here, opened by\n // its id like any other view; a held view that was just saved is let\n // go for the instance it became.\n hold(null);\n setChosen(instance.id);\n reload();\n },\n [reload, hold],\n );\n\n return {\n kinds,\n autoRun,\n setAutoRun: useCallback(\n async (on: boolean) => {\n await engine.setAutoRun(definitionId, on);\n reload();\n },\n [engine, definitionId, reload],\n ),\n list,\n manager,\n openId,\n choose,\n creatable,\n create,\n held,\n canDrill,\n drill,\n follow: holdFrom,\n back,\n board,\n toBoard,\n handedOver: held ? held.handed === true : handedHere !== null,\n opened,\n runtime,\n state,\n unopenable: opened.error ?? wrongKind,\n definitionIssues: engine.definitionIssues(definitionId),\n declaredAt: declaredAt(definition, state?.saved?.id),\n commands,\n filter,\n refresh,\n leave,\n onSaved: open,\n onRenamed: open,\n // No reload from here: the engine's notification is already out, carrying\n // the id that went, and a plain reload would take that id back out of the\n // request — listing the row, and naming it as the default, until the\n // store answers.\n onDeleted: useCallback(() => setChosen(null), []),\n onRecovered: useCallback(() => reload(), [reload]),\n };\n}\n\n/**\n * The state under the name the view goes by now. A held view named by a\n * group (`HeldView.named`) keeps that name while the group's conditions are\n * all among what it applied, and is called by its subject once one is not:\n * taken off the applied bar, edited to another value, negated. Read off the\n * applied config, not the draft — the title names what the screen shows,\n * and a condition still being typed has not changed that.\n */\nfunction namedState(\n state: ViewRuntimeState<ViewConfig> | null,\n held: HeldView | null,\n): ViewRuntimeState<ViewConfig> | null {\n const named = held?.named;\n if (\n !state ||\n !named ||\n state.applied.kind === 'dashboard' ||\n narrowsTo(state.applied.filter, named.conditions)\n )\n return state;\n return { ...state, title: named.subject };\n}\n\n/** Where the view `id` names sits in the definition's `views`, or `null`. */\nfunction declaredAt(\n definition: { id: string; views?: readonly { id: string }[] } | undefined,\n id: string | undefined,\n): number | null {\n const declared = id ? parseSystemInstanceId(id) : null;\n if (!definition || declared?.definitionId !== definition.id) return null;\n const at = (definition.views ?? []).findIndex(\n view => view.id === declared.viewId,\n );\n return at < 0 ? null : at;\n}\n"],"mappings":";;;;;;AAoDA,SAAgBU,GACdH,GACAI,GACAH,GACY;CACZ,IAAMI,IAASL,EAAQI,IACjBE,IAAY;EAAEN,SAAS,CAAC,GAAGA,CAAO;EAAGC,IAAIG;CAAK;CACpD,IAAI,CAACC,KAAUD,MAASH,GAAI,OAAOK;CACnC,IAAMC,IAASP,EAAQQ,QAAQC,GAASX,MAAOA,MAAOM,CAAI,GACpDM,IAAQL,EAAOM,SAAS,YAAYhB,GAAYU,EAAOO,UAAU,IAAI,CAAA,GAEvEC,IAAS,GACTC;CACJP,EAAOQ,SAASC,GAAQlB,MAAO;EAC7B,AAAIY,EAAMO,SAASD,EAAOE,KAAK,KAAKpB,IAAK,IAAIe,MAC3CA,IAASf,IAAK,GACdgB,IAAQE,EAAOE;CAEnB,CAAC;CAED,IAAIC,IAAUZ,EAAOa,QACjBC;CAWJ,IAVAd,EAAOQ,S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