@elaraai/e3-ui 1.0.103 → 1.0.104

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 (287) hide show
  1. package/dist/src/allocation/functions.d.ts +2 -1
  2. package/dist/src/allocation/functions.d.ts.map +1 -1
  3. package/dist/src/allocation/functions.js +3 -2
  4. package/dist/src/allocation/functions.js.map +1 -1
  5. package/dist/src/allocation/index.d.ts +120 -1
  6. package/dist/src/allocation/index.d.ts.map +1 -1
  7. package/dist/src/allocation/index.js +24 -4
  8. package/dist/src/allocation/index.js.map +1 -1
  9. package/dist/src/bind/data-indexed.d.ts +25 -4
  10. package/dist/src/bind/data-indexed.d.ts.map +1 -1
  11. package/dist/src/bind/data-indexed.js +58 -7
  12. package/dist/src/bind/data-indexed.js.map +1 -1
  13. package/dist/src/bind/data.d.ts +12 -14
  14. package/dist/src/bind/data.d.ts.map +1 -1
  15. package/dist/src/bind/data.js +11 -11
  16. package/dist/src/bind/data.js.map +1 -1
  17. package/dist/src/bind/func.d.ts +7 -2
  18. package/dist/src/bind/func.d.ts.map +1 -1
  19. package/dist/src/bind/func.js +10 -3
  20. package/dist/src/bind/func.js.map +1 -1
  21. package/dist/src/calendar/index.d.ts +148 -1
  22. package/dist/src/calendar/index.d.ts.map +1 -1
  23. package/dist/src/calendar/index.js +55 -5
  24. package/dist/src/calendar/index.js.map +1 -1
  25. package/dist/src/flowchart/canvas.d.ts +32 -14
  26. package/dist/src/flowchart/canvas.d.ts.map +1 -1
  27. package/dist/src/flowchart/canvas.js +21 -6
  28. package/dist/src/flowchart/canvas.js.map +1 -1
  29. package/dist/src/flowchart/details.d.ts +469 -0
  30. package/dist/src/flowchart/details.d.ts.map +1 -0
  31. package/dist/src/flowchart/details.js +1035 -0
  32. package/dist/src/flowchart/details.js.map +1 -0
  33. package/dist/src/flowchart/flowchart.d.ts +16 -72
  34. package/dist/src/flowchart/flowchart.d.ts.map +1 -1
  35. package/dist/src/flowchart/flowchart.js +10 -1
  36. package/dist/src/flowchart/flowchart.js.map +1 -1
  37. package/dist/src/flowchart/index.d.ts +282 -251
  38. package/dist/src/flowchart/index.d.ts.map +1 -1
  39. package/dist/src/flowchart/index.js +234 -220
  40. package/dist/src/flowchart/index.js.map +1 -1
  41. package/dist/src/flowchart/kinds.d.ts +438 -0
  42. package/dist/src/flowchart/kinds.d.ts.map +1 -0
  43. package/dist/src/flowchart/kinds.js +799 -0
  44. package/dist/src/flowchart/kinds.js.map +1 -0
  45. package/dist/src/flowchart/library.d.ts +154 -739
  46. package/dist/src/flowchart/library.d.ts.map +1 -1
  47. package/dist/src/flowchart/library.js +191 -673
  48. package/dist/src/flowchart/library.js.map +1 -1
  49. package/dist/src/flowchart/payload.d.ts +3652 -7843
  50. package/dist/src/flowchart/payload.d.ts.map +1 -1
  51. package/dist/src/flowchart/payload.js +331 -469
  52. package/dist/src/flowchart/payload.js.map +1 -1
  53. package/dist/src/flowchart/templates.d.ts +657 -0
  54. package/dist/src/flowchart/templates.d.ts.map +1 -0
  55. package/dist/src/flowchart/templates.js +658 -0
  56. package/dist/src/flowchart/templates.js.map +1 -0
  57. package/dist/src/flowchart/types.d.ts +2258 -214
  58. package/dist/src/flowchart/types.d.ts.map +1 -1
  59. package/dist/src/flowchart/types.js +374 -124
  60. package/dist/src/flowchart/types.js.map +1 -1
  61. package/dist/src/index.d.ts +13 -15
  62. package/dist/src/index.d.ts.map +1 -1
  63. package/dist/src/index.js +24 -29
  64. package/dist/src/index.js.map +1 -1
  65. package/dist/src/internal.d.ts +5 -7
  66. package/dist/src/internal.d.ts.map +1 -1
  67. package/dist/src/internal.js +12 -19
  68. package/dist/src/internal.js.map +1 -1
  69. package/dist/src/ontology/index.d.ts +44 -15
  70. package/dist/src/ontology/index.d.ts.map +1 -1
  71. package/dist/src/ontology/index.js +19 -11
  72. package/dist/src/ontology/index.js.map +1 -1
  73. package/dist/src/plan/event-rows.d.ts +2 -1
  74. package/dist/src/plan/event-rows.d.ts.map +1 -1
  75. package/dist/src/plan/event-rows.js +6 -4
  76. package/dist/src/plan/event-rows.js.map +1 -1
  77. package/dist/src/plan/ir.d.ts +1 -0
  78. package/dist/src/plan/ir.d.ts.map +1 -1
  79. package/dist/src/plan/plan.d.ts +145 -1
  80. package/dist/src/plan/plan.d.ts.map +1 -1
  81. package/dist/src/plan/plan.js +67 -3
  82. package/dist/src/plan/plan.js.map +1 -1
  83. package/dist/src/plan/types.d.ts +1 -0
  84. package/dist/src/plan/types.d.ts.map +1 -1
  85. package/dist/src/query/builder.d.ts +362 -315
  86. package/dist/src/query/builder.d.ts.map +1 -1
  87. package/dist/src/query/builder.js +12 -1
  88. package/dist/src/query/builder.js.map +1 -1
  89. package/dist/src/query/index.d.ts +5 -1
  90. package/dist/src/query/index.d.ts.map +1 -1
  91. package/dist/src/query/index.js +3 -1
  92. package/dist/src/query/index.js.map +1 -1
  93. package/dist/src/roster/fit.d.ts +5 -2
  94. package/dist/src/roster/fit.d.ts.map +1 -1
  95. package/dist/src/roster/fit.js +5 -3
  96. package/dist/src/roster/fit.js.map +1 -1
  97. package/dist/src/roster/index.d.ts +103 -2
  98. package/dist/src/roster/index.d.ts.map +1 -1
  99. package/dist/src/roster/index.js +45 -6
  100. package/dist/src/roster/index.js.map +1 -1
  101. package/dist/src/runtime/index.d.ts +1 -3
  102. package/dist/src/runtime/index.d.ts.map +1 -1
  103. package/dist/src/runtime/index.js +1 -3
  104. package/dist/src/runtime/index.js.map +1 -1
  105. package/dist/src/schedule/record-window.d.ts +1 -0
  106. package/dist/src/schedule/record-window.d.ts.map +1 -1
  107. package/dist/src/schematic/index.d.ts +1 -1
  108. package/dist/src/schematic/index.d.ts.map +1 -1
  109. package/dist/src/schematic/index.js +1 -1
  110. package/dist/src/schematic/index.js.map +1 -1
  111. package/dist/src/schematic/kinds.d.ts +4 -24
  112. package/dist/src/schematic/kinds.d.ts.map +1 -1
  113. package/dist/src/schematic/kinds.js +8 -212
  114. package/dist/src/schematic/kinds.js.map +1 -1
  115. package/dist/src/schematic/payload.d.ts +140 -1
  116. package/dist/src/schematic/payload.d.ts.map +1 -1
  117. package/dist/src/schematic/payload.js +38 -1
  118. package/dist/src/schematic/payload.js.map +1 -1
  119. package/dist/src/schematic/types.d.ts.map +1 -1
  120. package/dist/src/schematic/types.js +4 -36
  121. package/dist/src/schematic/types.js.map +1 -1
  122. package/dist/src/schematic/window.d.ts +9 -42
  123. package/dist/src/schematic/window.d.ts.map +1 -1
  124. package/dist/src/schematic/window.js +10 -115
  125. package/dist/src/schematic/window.js.map +1 -1
  126. package/dist/src/sheet/actions.d.ts +388 -0
  127. package/dist/src/sheet/actions.d.ts.map +1 -0
  128. package/dist/src/sheet/actions.js +594 -0
  129. package/dist/src/sheet/actions.js.map +1 -0
  130. package/dist/src/sheet/bridge.d.ts +12 -1
  131. package/dist/src/sheet/bridge.d.ts.map +1 -1
  132. package/dist/src/sheet/bridge.js +30 -6
  133. package/dist/src/sheet/bridge.js.map +1 -1
  134. package/dist/src/sheet/columns.d.ts +5 -2
  135. package/dist/src/sheet/columns.d.ts.map +1 -1
  136. package/dist/src/sheet/columns.js.map +1 -1
  137. package/dist/src/sheet/draft-bridge.d.ts +9 -4
  138. package/dist/src/sheet/draft-bridge.d.ts.map +1 -1
  139. package/dist/src/sheet/draft-bridge.js +22 -7
  140. package/dist/src/sheet/draft-bridge.js.map +1 -1
  141. package/dist/src/sheet/fields.d.ts +13 -0
  142. package/dist/src/sheet/fields.d.ts.map +1 -1
  143. package/dist/src/sheet/fields.js +3 -0
  144. package/dist/src/sheet/fields.js.map +1 -1
  145. package/dist/src/sheet/index.d.ts +32 -2
  146. package/dist/src/sheet/index.d.ts.map +1 -1
  147. package/dist/src/sheet/index.js +18 -3
  148. package/dist/src/sheet/index.js.map +1 -1
  149. package/dist/src/sheet/library.d.ts +8 -0
  150. package/dist/src/sheet/library.d.ts.map +1 -1
  151. package/dist/src/sheet/root.d.ts +23 -1
  152. package/dist/src/sheet/root.d.ts.map +1 -1
  153. package/dist/src/sheet/root.js +40 -5
  154. package/dist/src/sheet/root.js.map +1 -1
  155. package/dist/src/sheet/sheet.d.ts +7843 -4132
  156. package/dist/src/sheet/sheet.d.ts.map +1 -1
  157. package/dist/src/sheet/sheet.js +41 -2
  158. package/dist/src/sheet/sheet.js.map +1 -1
  159. package/dist/src/sheet/templates.d.ts +4 -0
  160. package/dist/src/sheet/templates.d.ts.map +1 -1
  161. package/dist/src/sheet/types.d.ts +12449 -5268
  162. package/dist/src/sheet/types.d.ts.map +1 -1
  163. package/dist/src/sheet/types.js +114 -2
  164. package/dist/src/sheet/types.js.map +1 -1
  165. package/dist/src/utils/derive.d.ts +1 -1
  166. package/dist/src/utils/derive.js +1 -1
  167. package/dist/src/utils/record-kind.d.ts +625 -0
  168. package/dist/src/utils/record-kind.d.ts.map +1 -0
  169. package/dist/src/utils/record-kind.js +450 -0
  170. package/dist/src/utils/record-kind.js.map +1 -0
  171. package/dist/src/utils/views.d.ts +55 -0
  172. package/dist/src/utils/views.d.ts.map +1 -0
  173. package/dist/src/utils/views.js +72 -0
  174. package/dist/src/utils/views.js.map +1 -0
  175. package/dist/src/utils/vocabulary.d.ts +48 -0
  176. package/dist/src/utils/vocabulary.d.ts.map +1 -0
  177. package/dist/src/utils/vocabulary.js +47 -0
  178. package/dist/src/utils/vocabulary.js.map +1 -0
  179. package/dist/test/allocation/allocation.examples.d.ts +2 -0
  180. package/dist/test/allocation/allocation.examples.d.ts.map +1 -1
  181. package/dist/test/allocation/allocation.examples.js +81 -2
  182. package/dist/test/allocation/allocation.examples.js.map +1 -1
  183. package/dist/test/bind/func/func.examples.d.ts +19 -1
  184. package/dist/test/bind/func/func.examples.d.ts.map +1 -1
  185. package/dist/test/bind/func/func.examples.js +36 -1
  186. package/dist/test/bind/func/func.examples.js.map +1 -1
  187. package/dist/test/calendar/calendar.examples.d.ts +2 -0
  188. package/dist/test/calendar/calendar.examples.d.ts.map +1 -1
  189. package/dist/test/calendar/calendar.examples.js +80 -2
  190. package/dist/test/calendar/calendar.examples.js.map +1 -1
  191. package/dist/test/decision/queue.examples.d.ts +1 -0
  192. package/dist/test/decision/queue.examples.d.ts.map +1 -1
  193. package/dist/test/decision/queue.examples.js +12 -0
  194. package/dist/test/decision/queue.examples.js.map +1 -1
  195. package/dist/test/examples-package.d.ts.map +1 -1
  196. package/dist/test/examples-package.js +5 -4
  197. package/dist/test/examples-package.js.map +1 -1
  198. package/dist/test/flowchart/flowchart.examples.d.ts +1250 -4605
  199. package/dist/test/flowchart/flowchart.examples.d.ts.map +1 -1
  200. package/dist/test/flowchart/flowchart.examples.js +861 -512
  201. package/dist/test/flowchart/flowchart.examples.js.map +1 -1
  202. package/dist/test/ontology/ontology.examples.d.ts +2 -3
  203. package/dist/test/ontology/ontology.examples.d.ts.map +1 -1
  204. package/dist/test/ontology/ontology.examples.js +32 -21
  205. package/dist/test/ontology/ontology.examples.js.map +1 -1
  206. package/dist/test/plan/plan-events.examples.d.ts +1 -0
  207. package/dist/test/plan/plan-events.examples.d.ts.map +1 -1
  208. package/dist/test/plan/plan-events.examples.js +44 -0
  209. package/dist/test/plan/plan-events.examples.js.map +1 -1
  210. package/dist/test/plan/plan-nested.examples.d.ts +2 -2
  211. package/dist/test/plan/plan-nested.examples.js +5 -5
  212. package/dist/test/plan/plan-nested.examples.js.map +1 -1
  213. package/dist/test/plan/plan-records.examples.d.ts.map +1 -1
  214. package/dist/test/plan/plan-records.examples.js +1 -1
  215. package/dist/test/plan/plan-records.examples.js.map +1 -1
  216. package/dist/test/query/query.examples.d.ts +2 -0
  217. package/dist/test/query/query.examples.d.ts.map +1 -1
  218. package/dist/test/query/query.examples.js +37 -1
  219. package/dist/test/query/query.examples.js.map +1 -1
  220. package/dist/test/roster/roster.examples.d.ts +2 -0
  221. package/dist/test/roster/roster.examples.d.ts.map +1 -1
  222. package/dist/test/roster/roster.examples.js +76 -15
  223. package/dist/test/roster/roster.examples.js.map +1 -1
  224. package/dist/test/schematic/schematic-records.examples.d.ts.map +1 -1
  225. package/dist/test/schematic/schematic-records.examples.js +6 -4
  226. package/dist/test/schematic/schematic-records.examples.js.map +1 -1
  227. package/dist/test/schematic/schematic.examples.d.ts +1 -0
  228. package/dist/test/schematic/schematic.examples.d.ts.map +1 -1
  229. package/dist/test/schematic/schematic.examples.js +144 -0
  230. package/dist/test/schematic/schematic.examples.js.map +1 -1
  231. package/dist/test/sheet/sheet-actions.examples.d.ts +1264 -0
  232. package/dist/test/sheet/sheet-actions.examples.d.ts.map +1 -0
  233. package/dist/test/sheet/sheet-actions.examples.js +394 -0
  234. package/dist/test/sheet/sheet-actions.examples.js.map +1 -0
  235. package/dist/test/sheet/sheet.examples.d.ts +1 -0
  236. package/dist/test/sheet/sheet.examples.d.ts.map +1 -1
  237. package/dist/test/sheet/sheet.examples.js +77 -0
  238. package/dist/test/sheet/sheet.examples.js.map +1 -1
  239. package/dist/test/studio/studio.examples.d.ts +1 -0
  240. package/dist/test/studio/studio.examples.d.ts.map +1 -1
  241. package/dist/test/studio/studio.examples.js +18 -8
  242. package/dist/test/studio/studio.examples.js.map +1 -1
  243. package/package.json +12 -12
  244. package/dist/src/diff/index.d.ts +0 -407
  245. package/dist/src/diff/index.d.ts.map +0 -1
  246. package/dist/src/diff/index.js +0 -203
  247. package/dist/src/diff/index.js.map +0 -1
  248. package/dist/src/experiment/index.d.ts +0 -1033
  249. package/dist/src/experiment/index.d.ts.map +0 -1
  250. package/dist/src/experiment/index.js +0 -197
  251. package/dist/src/experiment/index.js.map +0 -1
  252. package/dist/src/experiment/types.d.ts +0 -1093
  253. package/dist/src/experiment/types.d.ts.map +0 -1
  254. package/dist/src/experiment/types.js +0 -423
  255. package/dist/src/experiment/types.js.map +0 -1
  256. package/dist/src/flowchart/over.d.ts +0 -227
  257. package/dist/src/flowchart/over.d.ts.map +0 -1
  258. package/dist/src/flowchart/over.js +0 -213
  259. package/dist/src/flowchart/over.js.map +0 -1
  260. package/dist/src/flowchart/patch.d.ts +0 -64
  261. package/dist/src/flowchart/patch.d.ts.map +0 -1
  262. package/dist/src/flowchart/patch.js +0 -67
  263. package/dist/src/flowchart/patch.js.map +0 -1
  264. package/dist/src/flowchart/values.d.ts +0 -271
  265. package/dist/src/flowchart/values.d.ts.map +0 -1
  266. package/dist/src/flowchart/values.js +0 -220
  267. package/dist/src/flowchart/values.js.map +0 -1
  268. package/dist/src/flowchart/window.d.ts +0 -306
  269. package/dist/src/flowchart/window.d.ts.map +0 -1
  270. package/dist/src/flowchart/window.js +0 -63
  271. package/dist/src/flowchart/window.js.map +0 -1
  272. package/dist/src/runtime/diff.d.ts +0 -36
  273. package/dist/src/runtime/diff.d.ts.map +0 -1
  274. package/dist/src/runtime/diff.js +0 -34
  275. package/dist/src/runtime/diff.js.map +0 -1
  276. package/dist/src/runtime/experiment.d.ts +0 -48
  277. package/dist/src/runtime/experiment.d.ts.map +0 -1
  278. package/dist/src/runtime/experiment.js +0 -10
  279. package/dist/src/runtime/experiment.js.map +0 -1
  280. package/dist/test/diff/diff.examples.d.ts +0 -313
  281. package/dist/test/diff/diff.examples.d.ts.map +0 -1
  282. package/dist/test/diff/diff.examples.js +0 -452
  283. package/dist/test/diff/diff.examples.js.map +0 -1
  284. package/dist/test/experiment/experiment.examples.d.ts +0 -1512
  285. package/dist/test/experiment/experiment.examples.d.ts.map +0 -1
  286. package/dist/test/experiment/experiment.examples.js +0 -609
  287. package/dist/test/experiment/experiment.examples.js.map +0 -1
@@ -0,0 +1,658 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ /**
6
+ * `Flowchart.templates(rows, spec)` (#1501, `Flowchart Records Spec.md` R14,
7
+ * D8): the cards a kind's library tab lists. Cards are records (#1340,
8
+ * ruling 9), as the Schematic's are: the rows are a record of the app's, read
9
+ * whole through `Data.bind(record).read()`, and each card is one of its rows,
10
+ * its key the record's key. A list names its source of the Flowchart's
11
+ * `Slice.bindRecords`, whose shown keys narrow its cards.
12
+ *
13
+ * - A state's card gives every field of the row but its lane and its order:
14
+ * dropped on a lane, it adds a state there.
15
+ * - A transition's gives every field but its ends: dropped on a transition,
16
+ * it gives it its values, its ends kept.
17
+ * - A lane's gives every field but its order: dropped between two lanes, or at
18
+ * the band row's tail, it adds a lane there.
19
+ *
20
+ * Each accessor is reified once and called per row.
21
+ *
22
+ * @packageDocumentation
23
+ */
24
+ import { ArrayType, East, Expr, OptionType, StringType, isTypeEqual, none, printType, } from "@elaraai/east";
25
+ import { FlowchartTemplateType } from "./types.js";
26
+ /** Identifies a list of cards read from a record. */
27
+ export const FLOWCHART_TEMPLATES = Symbol("Flowchart.templates");
28
+ /**
29
+ * Declares a kind's cards over a record's rows (see the module docs).
30
+ *
31
+ * @typeParam C - The cards record's row type
32
+ * @typeParam V - The values' struct type
33
+ * @param rows - The cards, keyed by String: a record's rows, `Data.bind(record).read()`
34
+ * @param spec - Each card's name and group, its values, and its source of the slice
35
+ * @returns The cards, which a kind's `templates` takes
36
+ * @throws {Error} When the rows are not a Dict keyed by String, or `values` returns no struct
37
+ *
38
+ * @example
39
+ * ```tsx
40
+ * // .tsx file with the `@jsxImportSource @elaraai/e3-ui` pragma
41
+ * import { ArrayType, DateTimeType, DictType, East, FloatType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, none, some, variant } from "@elaraai/east";
42
+ * import { Box, Fields, Reactive, Slice, UIComponentType } from "@elaraai/east-ui";
43
+ * import { Data, Flowchart, Record } from "@elaraai/e3-ui";
44
+ * import e3 from "@elaraai/e3";
45
+ *
46
+ * // The depot's four records, and the records of the cards its library lists: each list of cards follows its own
47
+ * // source of the rail, as the states and the transitions follow theirs.
48
+ * export const DepotState = StructType({
49
+ * name: StringType, // what its card calls it
50
+ * phase: StringType, // the lane it stands in, by the lane's key
51
+ * seq: FloatType, // its place in its lane
52
+ * slots: OptionType(IntegerType), // a class of interchangeable states: the ×N badge
53
+ * flow: StringType, // the flow it belongs to: one record holds the depot's flows
54
+ * });
55
+ * export const DepotTransition = StructType({
56
+ * src: StringType, // the state it leaves, by its key
57
+ * dst: StringType, // the state it enters
58
+ * kind: VariantType({ planned: NullType, observed: NullType }),
59
+ * trigger: OptionType(StringType), // the decision that governs it, by its key
60
+ * volume: OptionType(FloatType), // the parcels measured on it
61
+ * n: OptionType(IntegerType), // the moves behind them
62
+ * at: OptionType(DateTimeType), // when they were measured
63
+ * flow: StringType,
64
+ * });
65
+ * export const DepotLane = StructType({ label: StringType, seq: FloatType });
66
+ * export const DepotDecision = StructType({ name: StringType, owner: StringType });
67
+ * export const depotStates = e3.record("flowchart_depot_states", DictType(StringType, DepotState), {
68
+ * initial: new Map([
69
+ * ["ARV", { name: "Arrived", phase: "intake", seq: 1, slots: none, flow: "Parcels" }],
70
+ * ["SCN", { name: "Scanned", phase: "intake", seq: 2, slots: none, flow: "Parcels" }],
71
+ * ["IND", { name: "Inducted", phase: "induct", seq: 1, slots: none, flow: "Parcels" }],
72
+ * ["LBL", { name: "Relabelled", phase: "induct", seq: 2, slots: none, flow: "Parcels" }],
73
+ * ["CH*", { name: "Sort chutes (class)", phase: "sort", seq: 1, slots: some(14n), flow: "Parcels" }],
74
+ * ["SRD", { name: "Sorted", phase: "sort", seq: 2, slots: none, flow: "Parcels" }],
75
+ * ["HLD", { name: "Held", phase: "hold", seq: 1, slots: none, flow: "Parcels" }],
76
+ * ["CLR", { name: "Cleared", phase: "hold", seq: 2, slots: none, flow: "Parcels" }],
77
+ * ["LDD", { name: "Loaded", phase: "dispatch", seq: 1, slots: none, flow: "Parcels" }],
78
+ * ["DSP", { name: "Dispatched", phase: "dispatch", seq: 2, slots: none, flow: "Parcels" }],
79
+ * // The returns flow's states, beside the parcels'.
80
+ * ["RCV", { name: "Received", phase: "intake", seq: 3, slots: none, flow: "Returns" }],
81
+ * ["INS", { name: "Inspected", phase: "hold", seq: 3, slots: none, flow: "Returns" }],
82
+ * ["RSD", { name: "Resent", phase: "dispatch", seq: 3, slots: none, flow: "Returns" }],
83
+ * ]),
84
+ * mutations: (mutation) => ({ patch: mutation.patch() }),
85
+ * indexes: (index) => ({
86
+ * flowchart_states_by_flow: index.on(["flow"]),
87
+ * flowchart_states_by_lane: index.on(["flow", "phase"]),
88
+ * }),
89
+ * });
90
+ * export const depotTransitions = e3.record("flowchart_depot_transitions", DictType(StringType, DepotTransition), {
91
+ * initial: new Map([
92
+ * ["l1", { src: "ARV", dst: "SCN", kind: variant("planned", null), trigger: none, volume: some(18460), n: some(412n), at: some(new Date("2026-06-30T00:00:00Z")), flow: "Parcels" }],
93
+ * ["l2", { src: "SCN", dst: "IND", kind: variant("planned", null), trigger: none, volume: some(18390), n: some(409n), at: some(new Date("2026-06-30T00:00:00Z")), flow: "Parcels" }],
94
+ * // In place: parcels inducted again, counted but not weighed.
95
+ * ["l3", { src: "IND", dst: "IND", kind: variant("observed", null), trigger: none, volume: none, n: some(2n), at: some(new Date("2026-06-30T00:00:00Z")), flow: "Parcels" }],
96
+ * ["l4", { src: "IND", dst: "CH*", kind: variant("planned", null), trigger: some("route"), volume: some(17350), n: some(386n), at: some(new Date("2026-06-30T00:00:00Z")), flow: "Parcels" }],
97
+ * ["l5", { src: "CH*", dst: "SRD", kind: variant("planned", null), trigger: none, volume: some(18210), n: some(405n), at: some(new Date("2026-06-30T00:00:00Z")), flow: "Parcels" }],
98
+ * ["l6", { src: "SRD", dst: "HLD", kind: variant("planned", null), trigger: none, volume: some(8420), n: some(188n), at: some(new Date("2026-06-30T00:00:00Z")), flow: "Parcels" }],
99
+ * ["l7", { src: "HLD", dst: "CLR", kind: variant("planned", null), trigger: some("customs"), volume: some(8350), n: some(186n), at: some(new Date("2026-06-30T00:00:00Z")), flow: "Parcels" }],
100
+ * ["l8", { src: "CLR", dst: "LDD", kind: variant("planned", null), trigger: none, volume: some(8240), n: some(183n), at: some(new Date("2026-06-30T00:00:00Z")), flow: "Parcels" }],
101
+ * ["l9", { src: "LDD", dst: "DSP", kind: variant("planned", null), trigger: none, volume: some(17030), n: some(378n), at: some(new Date("2026-06-30T00:00:00Z")), flow: "Parcels" }],
102
+ * // Its far end names a state no row is keyed by: drawn as a ghost, and listed in Issues.
103
+ * ["l10", { src: "DSP", dst: "DLV", kind: variant("planned", null), trigger: none, volume: none, n: none, at: none, flow: "Parcels" }],
104
+ * // Observed, not planned: parcels relabelled before they are sorted.
105
+ * ["l11", { src: "IND", dst: "LBL", kind: variant("observed", null), trigger: none, volume: some(980), n: some(22n), at: some(new Date("2026-06-30T00:00:00Z")), flow: "Parcels" }],
106
+ * ["l12", { src: "LBL", dst: "CH*", kind: variant("observed", null), trigger: none, volume: some(975), n: some(22n), at: some(new Date("2026-06-30T00:00:00Z")), flow: "Parcels" }],
107
+ * ["l13", { src: "SRD", dst: "LDD", kind: variant("planned", null), trigger: none, volume: some(8790), n: some(195n), at: some(new Date("2026-06-30T00:00:00Z")), flow: "Parcels" }],
108
+ * ["r1", { src: "RCV", dst: "INS", kind: variant("planned", null), trigger: none, volume: some(640), n: some(15n), at: some(new Date("2026-06-30T00:00:00Z")), flow: "Returns" }],
109
+ * ["r2", { src: "INS", dst: "RSD", kind: variant("planned", null), trigger: none, volume: some(610), n: some(14n), at: some(new Date("2026-06-30T00:00:00Z")), flow: "Returns" }],
110
+ * ]),
111
+ * mutations: (mutation) => ({ patch: mutation.patch() }),
112
+ * indexes: (index) => ({
113
+ * flowchart_transitions_by_flow: index.on(["flow"]),
114
+ * }),
115
+ * });
116
+ * export const depotLanes = e3.record("flowchart_depot_lanes", DictType(StringType, DepotLane), {
117
+ * initial: new Map([
118
+ * ["intake", { label: "Intake", seq: 1 }], ["induct", { label: "Induct", seq: 2 }], ["sort", { label: "Sort", seq: 3 }],
119
+ * ["hold", { label: "Hold", seq: 4 }], ["dispatch", { label: "Dispatch", seq: 5 }],
120
+ * ]),
121
+ * mutations: (mutation) => ({ patch: mutation.patch() }),
122
+ * });
123
+ * export const depotDecisions = e3.record("flowchart_depot_decisions", DictType(StringType, DepotDecision), {
124
+ * initial: new Map([["route", { name: "route", owner: "sort-planner" }], ["customs", { name: "customs", owner: "customs-desk" }]]),
125
+ * mutations: (mutation) => ({ patch: mutation.patch() }),
126
+ * });
127
+ * // What one service's parcels did in a state: the same figures as the state's own, for that service alone.
128
+ * export const ServiceEvidence = StructType({
129
+ * flags: SetType(StringType), // what the app's task flags this service's parcels with
130
+ * parcels: IntegerType, // its parcels through the state
131
+ * waiting: IntegerType, // still in it when measured
132
+ * hours: ArrayType(IntegerType), // its parcels by time in state: a count a bin, in the bins' order
133
+ * exceptions: DictType(StringType, IntegerType), // its parcels by what went wrong
134
+ * });
135
+ * // What the depot measured in each state and on each transition: the app's own rows, keyed as the states and
136
+ * // the transitions are, written by its evidence task through each record's door.
137
+ * export const StateEvidence = StructType({
138
+ * flags: SetType(StringType), // what the app's task flags the state with
139
+ * equipment: SetType(StringType), // what handles parcels there
140
+ * shifts: SetType(StringType), // the shifts that staff it
141
+ * parcels: IntegerType, // through the state
142
+ * waiting: IntegerType, // still in it when measured
143
+ * hours: ArrayType(IntegerType), // parcels by time in state: a count a bin, in the bins' order
144
+ * service: DictType(StringType, IntegerType), // parcels by service
145
+ * exceptions: DictType(StringType, IntegerType), // parcels by what went wrong
146
+ * byService: DictType(StringType, ServiceEvidence), // each service's own: Standard, Priority, Economy, International
147
+ * });
148
+ * export const MoveEvidence = StructType({
149
+ * region: DictType(StringType, IntegerType),
150
+ * service: DictType(StringType, IntegerType),
151
+ * origins: DictType(StringType, StructType({ parcels: IntegerType, late: IntegerType })),
152
+ * });
153
+ * // What the evidence task last wrote, made up: a row a state but Dispatched, whose card says no data. Each row
154
+ * // files each service's own figures apart, which add up to its own: their parcels are its Service list's counts,
155
+ * // their waiting adds to its waiting, their hours bin by bin to its hours, their exceptions by name to its
156
+ * // exceptions, and their flags join to its flags. The returns take no international parcels: their states hold no
157
+ * // International entry.
158
+ * export const stateEvidence = e3.record("flowchart_depot_state_evidence", DictType(StringType, StateEvidence), {
159
+ * initial: new Map([
160
+ * ["ARV", {
161
+ * flags: new Set<string>(), equipment: new Set(["Conveyor"]), shifts: new Set(["Early", "Late", "Night"]),
162
+ * parcels: 18460n, waiting: 60n,
163
+ * hours: [5538n, 6277n, 3692n, 1846n, 738n, 369n, 0n, 0n, 0n, 0n, 0n, 0n],
164
+ * service: new Map([["Standard", 10337n], ["Priority", 4615n], ["Economy", 2400n], ["International", 1108n]]),
165
+ * exceptions: new Map([["Late arrival", 52n], ["Damaged packaging", 11n]]),
166
+ * byService: new Map([
167
+ * ["Standard", { flags: new Set<string>(), parcels: 10337n, waiting: 33n, hours: [3005n, 3534n, 2118n, 1062n, 417n, 201n, 0n, 0n, 0n, 0n, 0n, 0n], exceptions: new Map([["Late arrival", 26n], ["Damaged packaging", 6n]]) }],
168
+ * ["Priority", { flags: new Set<string>(), parcels: 4615n, waiting: 15n, hours: [1735n, 1637n, 788n, 316n, 100n, 39n, 0n, 0n, 0n, 0n, 0n, 0n], exceptions: new Map([["Late arrival", 11n], ["Damaged packaging", 3n]]) }],
169
+ * ["Economy", { flags: new Set<string>(), parcels: 2400n, waiting: 8n, hours: [589n, 781n, 528n, 298n, 132n, 72n, 0n, 0n, 0n, 0n, 0n, 0n], exceptions: new Map([["Late arrival", 12n], ["Damaged packaging", 1n]]) }],
170
+ * ["International", { flags: new Set<string>(), parcels: 1108n, waiting: 4n, hours: [209n, 325n, 258n, 170n, 89n, 57n, 0n, 0n, 0n, 0n, 0n, 0n], exceptions: new Map([["Late arrival", 3n], ["Damaged packaging", 1n]]) }],
171
+ * ]),
172
+ * }],
173
+ * ["SCN", {
174
+ * flags: new Set(["Fragile"]), equipment: new Set(["Scanner", "Conveyor"]), shifts: new Set(["Early", "Late", "Night"]),
175
+ * parcels: 18390n, waiting: 35n,
176
+ * hours: [7723n, 5701n, 2759n, 1471n, 552n, 184n, 0n, 0n, 0n, 0n, 0n, 0n],
177
+ * service: new Map([["Standard", 10298n], ["Priority", 4598n], ["Economy", 2391n], ["International", 1103n]]),
178
+ * exceptions: new Map([["Unreadable label", 61n], ["Damaged packaging", 9n]]),
179
+ * byService: new Map([
180
+ * ["Standard", { flags: new Set(["Fragile"]), parcels: 10298n, waiting: 20n, hours: [4236n, 3228n, 1584n, 842n, 309n, 99n, 0n, 0n, 0n, 0n, 0n, 0n], exceptions: new Map([["Unreadable label", 34n], ["Damaged packaging", 5n]]) }],
181
+ * ["Priority", { flags: new Set<string>(), parcels: 4598n, waiting: 9n, hours: [2307n, 1411n, 555n, 237n, 70n, 18n, 0n, 0n, 0n, 0n, 0n, 0n], exceptions: new Map([["Unreadable label", 15n], ["Damaged packaging", 2n]]) }],
182
+ * ["Economy", { flags: new Set<string>(), parcels: 2391n, waiting: 4n, hours: [860n, 739n, 409n, 245n, 101n, 37n, 0n, 0n, 0n, 0n, 0n, 0n], exceptions: new Map([["Unreadable label", 8n], ["Damaged packaging", 1n]]) }],
183
+ * ["International", { flags: new Set<string>(), parcels: 1103n, waiting: 2n, hours: [320n, 323n, 211n, 147n, 72n, 30n, 0n, 0n, 0n, 0n, 0n, 0n], exceptions: new Map([["Unreadable label", 4n], ["Damaged packaging", 1n]]) }],
184
+ * ]),
185
+ * }],
186
+ * ["IND", {
187
+ * flags: new Set(["Oversize", "Fragile"]), equipment: new Set(["Conveyor", "Scanner"]), shifts: new Set(["Early", "Late"]),
188
+ * parcels: 18390n, waiting: 120n,
189
+ * hours: [2207n, 4781n, 5517n, 3310n, 1655n, 736n, 184n, 0n, 0n, 0n, 0n, 0n],
190
+ * service: new Map([["Standard", 10482n], ["Priority", 4414n], ["Economy", 2391n], ["International", 1103n]]),
191
+ * exceptions: new Map([["Missort", 22n]]),
192
+ * byService: new Map([
193
+ * ["Standard", { flags: new Set(["Oversize", "Fragile"]), parcels: 10482n, waiting: 68n, hours: [1183n, 2685n, 3191n, 1939n, 964n, 419n, 101n, 0n, 0n, 0n, 0n, 0n], exceptions: new Map([["Missort", 13n]]) }],
194
+ * ["Priority", { flags: new Set<string>(), parcels: 4414n, waiting: 29n, hours: [750n, 1367n, 1303n, 635n, 254n, 88n, 17n, 0n, 0n, 0n, 0n, 0n], exceptions: new Map([["Missort", 5n]]) }],
195
+ * ["Economy", { flags: new Set(["Oversize"]), parcels: 2391n, waiting: 16n, hours: [209n, 533n, 715n, 489n, 274n, 135n, 36n, 0n, 0n, 0n, 0n, 0n], exceptions: new Map([["Missort", 3n]]) }],
196
+ * ["International", { flags: new Set<string>(), parcels: 1103n, waiting: 7n, hours: [65n, 196n, 308n, 247n, 163n, 94n, 30n, 0n, 0n, 0n, 0n, 0n], exceptions: new Map([["Missort", 1n]]) }],
197
+ * ]),
198
+ * }],
199
+ * ["LBL", {
200
+ * flags: new Set(["At risk"]), equipment: new Set(["Label printer", "Scanner"]), shifts: new Set(["Late"]),
201
+ * parcels: 980n, waiting: 15n,
202
+ * hours: [20n, 59n, 137n, 255n, 273n, 157n, 59n, 20n, 0n, 0n, 0n, 0n],
203
+ * service: new Map([["Standard", 471n], ["Priority", 294n], ["Economy", 137n], ["International", 78n]]),
204
+ * exceptions: new Map([["Unreadable label", 712n], ["Address check", 268n]]),
205
+ * byService: new Map([
206
+ * ["Standard", { flags: new Set<string>(), parcels: 471n, waiting: 7n, hours: [9n, 25n, 63n, 123n, 135n, 78n, 29n, 9n, 0n, 0n, 0n, 0n], exceptions: new Map([["Unreadable label", 342n], ["Address check", 129n]]) }],
207
+ * ["Priority", { flags: new Set(["At risk"]), parcels: 294n, waiting: 5n, hours: [10n, 27n, 53n, 83n, 74n, 34n, 10n, 3n, 0n, 0n, 0n, 0n], exceptions: new Map([["Unreadable label", 214n], ["Address check", 80n]]) }],
208
+ * ["Economy", { flags: new Set<string>(), parcels: 137n, waiting: 2n, hours: [1n, 5n, 15n, 33n, 41n, 27n, 11n, 4n, 0n, 0n, 0n, 0n], exceptions: new Map([["Unreadable label", 99n], ["Address check", 38n]]) }],
209
+ * ["International", { flags: new Set<string>(), parcels: 78n, waiting: 1n, hours: [0n, 2n, 6n, 16n, 23n, 18n, 9n, 4n, 0n, 0n, 0n, 0n], exceptions: new Map([["Unreadable label", 57n], ["Address check", 21n]]) }],
210
+ * ]),
211
+ * }],
212
+ * ["CH*", {
213
+ * flags: new Set(["At risk"]), equipment: new Set(["Conveyor", "Scanner"]), shifts: new Set(["Early", "Late", "Night", "Weekend"]),
214
+ * parcels: 18290n, waiting: 140n,
215
+ * hours: [1463n, 4024n, 6218n, 4024n, 1646n, 732n, 183n, 0n, 0n, 0n, 0n, 0n],
216
+ * service: new Map([["Standard", 10425n], ["Priority", 4390n], ["Economy", 2378n], ["International", 1097n]]),
217
+ * exceptions: new Map([["Missort", 41n], ["Chute full", 26n]]),
218
+ * byService: new Map([
219
+ * ["Standard", { flags: new Set<string>(), parcels: 10425n, waiting: 80n, hours: [776n, 2242n, 3579n, 2350n, 960n, 418n, 100n, 0n, 0n, 0n, 0n, 0n], exceptions: new Map([["Missort", 23n], ["Chute full", 15n]]) }],
220
+ * ["Priority", { flags: new Set(["At risk"]), parcels: 4390n, waiting: 34n, hours: [512n, 1186n, 1519n, 801n, 262n, 92n, 18n, 0n, 0n, 0n, 0n, 0n], exceptions: new Map([["Missort", 10n], ["Chute full", 6n]]) }],
221
+ * ["Economy", { flags: new Set<string>(), parcels: 2378n, waiting: 18n, hours: [134n, 438n, 787n, 583n, 268n, 132n, 36n, 0n, 0n, 0n, 0n, 0n], exceptions: new Map([["Missort", 5n], ["Chute full", 3n]]) }],
222
+ * ["International", { flags: new Set<string>(), parcels: 1097n, waiting: 8n, hours: [41n, 158n, 333n, 290n, 156n, 90n, 29n, 0n, 0n, 0n, 0n, 0n], exceptions: new Map([["Missort", 3n], ["Chute full", 2n]]) }],
223
+ * ]),
224
+ * }],
225
+ * ["SRD", {
226
+ * flags: new Set(["Fragile"]), equipment: new Set(["Conveyor"]), shifts: new Set(["Early", "Late"]),
227
+ * parcels: 17210n, waiting: 50n,
228
+ * hours: [861n, 2065n, 4303n, 4818n, 3098n, 1377n, 516n, 172n, 0n, 0n, 0n, 0n],
229
+ * service: new Map([["Standard", 9981n], ["Priority", 4303n], ["Economy", 2065n], ["International", 861n]]),
230
+ * exceptions: new Map([["Missort", 14n], ["Damaged packaging", 6n]]),
231
+ * byService: new Map([
232
+ * ["Standard", { flags: new Set(["Fragile"]), parcels: 9981n, waiting: 29n, hours: [441n, 1128n, 2467n, 2852n, 1863n, 827n, 305n, 98n, 0n, 0n, 0n, 0n], exceptions: new Map([["Missort", 8n], ["Damaged packaging", 3n]]) }],
233
+ * ["Priority", { flags: new Set<string>(), parcels: 4303n, waiting: 12n, hours: [341n, 701n, 1230n, 1141n, 598n, 213n, 63n, 16n, 0n, 0n, 0n, 0n], exceptions: new Map([["Missort", 3n], ["Damaged packaging", 2n]]) }],
234
+ * ["Economy", { flags: new Set<string>(), parcels: 2065n, waiting: 6n, hours: [63n, 183n, 453n, 591n, 434n, 218n, 90n, 33n, 0n, 0n, 0n, 0n], exceptions: new Map([["Missort", 2n], ["Damaged packaging", 1n]]) }],
235
+ * ["International", { flags: new Set<string>(), parcels: 861n, waiting: 3n, hours: [16n, 53n, 153n, 234n, 203n, 119n, 58n, 25n, 0n, 0n, 0n, 0n], exceptions: new Map([["Missort", 1n]]) }],
236
+ * ]),
237
+ * }],
238
+ * ["HLD", {
239
+ * flags: new Set(["Customs", "Hazmat", "At risk", "Cold chain", "Oversize"]), equipment: new Set(["Forklift", "X-ray", "Scanner"]), shifts: new Set(["Early", "Late"]),
240
+ * parcels: 1080n, waiting: 70n,
241
+ * hours: [0n, 11n, 22n, 54n, 97n, 151n, 183n, 162n, 173n, 130n, 65n, 32n],
242
+ * service: new Map([["Standard", 335n], ["Priority", 130n], ["Economy", 76n], ["International", 539n]]),
243
+ * exceptions: new Map([["Missing documents", 412n], ["Duty unpaid", 236n], ["Address check", 98n], ["Damaged packaging", 44n]]),
244
+ * byService: new Map([
245
+ * ["Standard", { flags: new Set(["Oversize"]), parcels: 335n, waiting: 22n, hours: [0n, 4n, 9n, 22n, 39n, 57n, 63n, 50n, 45n, 29n, 12n, 5n], exceptions: new Map([["Missing documents", 28n], ["Duty unpaid", 11n], ["Address check", 30n], ["Damaged packaging", 14n]]) }],
246
+ * ["Priority", { flags: new Set(["At risk", "Cold chain"]), parcels: 130n, waiting: 8n, hours: [0n, 5n, 8n, 15n, 22n, 26n, 23n, 14n, 10n, 5n, 2n, 0n], exceptions: new Map([["Missing documents", 11n], ["Duty unpaid", 4n], ["Address check", 12n], ["Damaged packaging", 5n]]) }],
247
+ * ["Economy", { flags: new Set(["Hazmat", "Oversize"]), parcels: 76n, waiting: 5n, hours: [0n, 1n, 1n, 3n, 7n, 11n, 14n, 12n, 12n, 9n, 4n, 2n], exceptions: new Map([["Missing documents", 7n], ["Duty unpaid", 3n], ["Address check", 7n], ["Damaged packaging", 3n]]) }],
248
+ * ["International", { flags: new Set(["Customs"]), parcels: 539n, waiting: 35n, hours: [0n, 1n, 4n, 14n, 29n, 57n, 83n, 86n, 106n, 87n, 47n, 25n], exceptions: new Map([["Missing documents", 366n], ["Duty unpaid", 218n], ["Address check", 49n], ["Damaged packaging", 22n]]) }],
249
+ * ]),
250
+ * }],
251
+ * ["CLR", {
252
+ * flags: new Set(["Customs"]), equipment: new Set(["Label printer", "Scanner", "X-ray"]), shifts: new Set(["Early", "Late"]),
253
+ * parcels: 18170n, waiting: 18n,
254
+ * hours: [1817n, 3634n, 4542n, 3634n, 2180n, 1454n, 727n, 182n, 0n, 0n, 0n, 0n],
255
+ * service: new Map([["Standard", 10175n], ["Priority", 4361n], ["Economy", 2362n], ["International", 1272n]]),
256
+ * exceptions: new Map([["Duty refund", 12n]]),
257
+ * byService: new Map([
258
+ * ["Standard", { flags: new Set<string>(), parcels: 10175n, waiting: 10n, hours: [943n, 1989n, 2575n, 2097n, 1257n, 823n, 397n, 94n, 0n, 0n, 0n, 0n], exceptions: new Map([["Duty refund", 4n]]) }],
259
+ * ["Priority", { flags: new Set<string>(), parcels: 4361n, waiting: 4n, hours: [663n, 1122n, 1166n, 762n, 367n, 193n, 74n, 14n, 0n, 0n, 0n, 0n], exceptions: new Map([["Duty refund", 2n]]) }],
260
+ * ["Economy", { flags: new Set<string>(), parcels: 2362n, waiting: 3n, hours: [159n, 377n, 551n, 506n, 342n, 253n, 137n, 37n, 0n, 0n, 0n, 0n], exceptions: new Map([["Duty refund", 1n]]) }],
261
+ * ["International", { flags: new Set(["Customs"]), parcels: 1272n, waiting: 1n, hours: [52n, 146n, 250n, 269n, 214n, 185n, 119n, 37n, 0n, 0n, 0n, 0n], exceptions: new Map([["Duty refund", 5n]]) }],
262
+ * ]),
263
+ * }],
264
+ * ["LDD", {
265
+ * flags: new Set(["Hazmat", "Oversize"]), equipment: new Set(["Forklift", "Scanner"]), shifts: new Set(["Early", "Late", "Night"]),
266
+ * parcels: 17030n, waiting: 210n,
267
+ * hours: [681n, 1362n, 2725n, 4088n, 3747n, 2384n, 1362n, 511n, 170n, 0n, 0n, 0n],
268
+ * service: new Map([["Standard", 9707n], ["Priority", 4087n], ["Economy", 2214n], ["International", 1022n]]),
269
+ * exceptions: new Map([["Vehicle late", 140n], ["Overweight", 31n]]),
270
+ * byService: new Map([
271
+ * ["Standard", { flags: new Set(["Oversize"]), parcels: 9707n, waiting: 120n, hours: [334n, 717n, 1515n, 2358n, 2205n, 1407n, 792n, 288n, 91n, 0n, 0n, 0n], exceptions: new Map([["Vehicle late", 75n], ["Overweight", 18n]]) }],
272
+ * ["Priority", { flags: new Set<string>(), parcels: 4087n, waiting: 50n, hours: [286n, 493n, 835n, 1043n, 782n, 401n, 181n, 53n, 13n, 0n, 0n, 0n], exceptions: new Map([["Vehicle late", 31n], ["Overweight", 7n]]) }],
273
+ * ["Economy", { flags: new Set(["Hazmat", "Oversize"]), parcels: 2214n, waiting: 27n, hours: [49n, 119n, 282n, 495n, 522n, 375n, 239n, 98n, 35n, 0n, 0n, 0n], exceptions: new Map([["Vehicle late", 26n], ["Overweight", 4n]]) }],
274
+ * ["International", { flags: new Set<string>(), parcels: 1022n, waiting: 13n, hours: [12n, 33n, 93n, 192n, 238n, 201n, 150n, 72n, 31n, 0n, 0n, 0n], exceptions: new Map([["Vehicle late", 8n], ["Overweight", 2n]]) }],
275
+ * ]),
276
+ * }],
277
+ * ["RCV", {
278
+ * flags: new Set(["Fragile"]), equipment: new Set(["Scanner"]), shifts: new Set(["Weekend"]),
279
+ * parcels: 640n, waiting: 25n,
280
+ * hours: [64n, 115n, 154n, 141n, 90n, 51n, 19n, 6n, 0n, 0n, 0n, 0n],
281
+ * service: new Map([["Standard", 435n], ["Priority", 128n], ["Economy", 77n]]),
282
+ * exceptions: new Map([["Missing documents", 18n]]),
283
+ * byService: new Map([
284
+ * ["Standard", { flags: new Set(["Fragile"]), parcels: 435n, waiting: 17n, hours: [39n, 75n, 104n, 98n, 64n, 37n, 14n, 4n, 0n, 0n, 0n, 0n], exceptions: new Map([["Missing documents", 12n]]) }],
285
+ * ["Priority", { flags: new Set<string>(), parcels: 128n, waiting: 5n, hours: [19n, 29n, 33n, 25n, 13n, 6n, 2n, 1n, 0n, 0n, 0n, 0n], exceptions: new Map([["Missing documents", 4n]]) }],
286
+ * ["Economy", { flags: new Set<string>(), parcels: 77n, waiting: 3n, hours: [6n, 11n, 17n, 18n, 13n, 8n, 3n, 1n, 0n, 0n, 0n, 0n], exceptions: new Map([["Missing documents", 2n]]) }],
287
+ * ]),
288
+ * }],
289
+ * ["INS", {
290
+ * flags: new Set(["At risk", "Customs"]), equipment: new Set(["X-ray"]), shifts: new Set(["Early"]),
291
+ * parcels: 640n, waiting: 30n,
292
+ * hours: [0n, 13n, 38n, 77n, 128n, 154n, 115n, 64n, 38n, 13n, 0n, 0n],
293
+ * service: new Map([["Standard", 435n], ["Priority", 128n], ["Economy", 77n]]),
294
+ * exceptions: new Map([["Damaged packaging", 27n]]),
295
+ * byService: new Map([
296
+ * ["Standard", { flags: new Set(["Customs"]), parcels: 435n, waiting: 20n, hours: [0n, 7n, 23n, 49n, 86n, 106n, 81n, 46n, 27n, 10n, 0n, 0n], exceptions: new Map([["Damaged packaging", 18n]]) }],
297
+ * ["Priority", { flags: new Set(["At risk"]), parcels: 128n, waiting: 6n, hours: [0n, 5n, 12n, 21n, 29n, 30n, 18n, 8n, 4n, 1n, 0n, 0n], exceptions: new Map([["Damaged packaging", 6n]]) }],
298
+ * ["Economy", { flags: new Set<string>(), parcels: 77n, waiting: 4n, hours: [0n, 1n, 3n, 7n, 13n, 18n, 16n, 10n, 7n, 2n, 0n, 0n], exceptions: new Map([["Damaged packaging", 3n]]) }],
299
+ * ]),
300
+ * }],
301
+ * ["RSD", {
302
+ * flags: new Set<string>(), equipment: new Set(["Scanner"]), shifts: new Set(["Early"]),
303
+ * parcels: 610n, waiting: 0n,
304
+ * hours: [122n, 183n, 159n, 85n, 43n, 18n, 0n, 0n, 0n, 0n, 0n, 0n],
305
+ * service: new Map([["Standard", 415n], ["Priority", 122n], ["Economy", 73n]]),
306
+ * exceptions: new Map<string, bigint>(),
307
+ * byService: new Map([
308
+ * ["Standard", { flags: new Set<string>(), parcels: 415n, waiting: 0n, hours: [78n, 123n, 110n, 60n, 31n, 13n, 0n, 0n, 0n, 0n, 0n, 0n], exceptions: new Map<string, bigint>() }],
309
+ * ["Priority", { flags: new Set<string>(), parcels: 122n, waiting: 0n, hours: [32n, 41n, 29n, 13n, 5n, 2n, 0n, 0n, 0n, 0n, 0n, 0n], exceptions: new Map<string, bigint>() }],
310
+ * ["Economy", { flags: new Set<string>(), parcels: 73n, waiting: 0n, hours: [12n, 19n, 20n, 12n, 7n, 3n, 0n, 0n, 0n, 0n, 0n, 0n], exceptions: new Map<string, bigint>() }],
311
+ * ]),
312
+ * }],
313
+ * ]),
314
+ * mutations: (mutation) => ({ patch: mutation.patch() }),
315
+ * // Each service's own figures, a range of the index by the service's name: what the rail's picks read.
316
+ * indexes: (index) => ({ flowchart_evidence_by_service: index.entries("byService") }),
317
+ * });
318
+ * // A row a transition with a volume: the in-place one and the one to Delivered have none, and their labels keep their evidence alone.
319
+ * export const moveEvidence = e3.record("flowchart_depot_move_evidence", DictType(StringType, MoveEvidence), {
320
+ * initial: new Map([
321
+ * ["l1", {
322
+ * region: new Map([["Metro", 8491n], ["Regional", 6092n], ["Remote", 2769n], ["Overseas", 1108n]]),
323
+ * service: new Map([["Standard", 10337n], ["Priority", 4615n], ["Economy", 2400n], ["International", 1108n]]),
324
+ * origins: new Map([["Air hub", { parcels: 5350n, late: 84n }], ["Harbour hub", { parcels: 4377n, late: 135n }], ["Rail yard", { parcels: 2233n, late: 27n }], ["Depot 02", { parcels: 1680n, late: 20n }], ["Depot 05", { parcels: 1349n, late: 9n }], ["Depot 07", { parcels: 995n, late: 13n }], ["Depot 11", { parcels: 730n, late: 4n }], ["City counter", { parcels: 619n, late: 7n }], ["Partner pickup", { parcels: 508n, late: 11n }], ["Returns desk", { parcels: 354n, late: 2n }], ["Locker bank", { parcels: 265n, late: 0n }]]),
325
+ * }],
326
+ * ["l2", {
327
+ * region: new Map([["Metro", 8459n], ["Regional", 6069n], ["Remote", 2759n], ["Overseas", 1103n]]),
328
+ * service: new Map([["Standard", 10298n], ["Priority", 4598n], ["Economy", 2391n], ["International", 1103n]]),
329
+ * origins: new Map([["Air hub", { parcels: 5330n, late: 84n }], ["Harbour hub", { parcels: 4361n, late: 134n }], ["Rail yard", { parcels: 2224n, late: 26n }], ["Depot 02", { parcels: 1674n, late: 20n }], ["Depot 05", { parcels: 1343n, late: 9n }], ["Depot 07", { parcels: 991n, late: 13n }], ["Depot 11", { parcels: 727n, late: 4n }], ["City counter", { parcels: 617n, late: 7n }], ["Partner pickup", { parcels: 507n, late: 11n }], ["Returns desk", { parcels: 352n, late: 2n }], ["Locker bank", { parcels: 264n, late: 0n }]]),
330
+ * }],
331
+ * ["l4", {
332
+ * region: new Map([["Metro", 8153n], ["Regional", 5726n], ["Remote", 2603n], ["Overseas", 868n]]),
333
+ * service: new Map([["Standard", 9889n], ["Priority", 4164n], ["Economy", 2256n], ["International", 1041n]]),
334
+ * origins: new Map([["Air hub", { parcels: 5029n, late: 79n }], ["Harbour hub", { parcels: 4114n, late: 127n }], ["Rail yard", { parcels: 2099n, late: 25n }], ["Depot 02", { parcels: 1579n, late: 19n }], ["Depot 05", { parcels: 1267n, late: 8n }], ["Depot 07", { parcels: 935n, late: 12n }], ["Depot 11", { parcels: 686n, late: 4n }], ["City counter", { parcels: 582n, late: 6n }], ["Partner pickup", { parcels: 478n, late: 10n }], ["Returns desk", { parcels: 332n, late: 2n }], ["Locker bank", { parcels: 249n, late: 0n }]]),
335
+ * }],
336
+ * ["l5", {
337
+ * region: new Map([["Metro", 8376n], ["Regional", 6009n], ["Remote", 2732n], ["Overseas", 1093n]]),
338
+ * service: new Map([["Standard", 10380n], ["Priority", 4370n], ["Economy", 2367n], ["International", 1093n]]),
339
+ * origins: new Map([["Air hub", { parcels: 5277n, late: 83n }], ["Harbour hub", { parcels: 4318n, late: 133n }], ["Rail yard", { parcels: 2203n, late: 26n }], ["Depot 02", { parcels: 1657n, late: 20n }], ["Depot 05", { parcels: 1330n, late: 9n }], ["Depot 07", { parcels: 981n, late: 13n }], ["Depot 11", { parcels: 720n, late: 4n }], ["City counter", { parcels: 611n, late: 7n }], ["Partner pickup", { parcels: 502n, late: 11n }], ["Returns desk", { parcels: 349n, late: 2n }], ["Locker bank", { parcels: 262n, late: 0n }]]),
340
+ * }],
341
+ * ["l6", {
342
+ * region: new Map([["Metro", 1179n], ["Regional", 758n], ["Remote", 421n], ["Overseas", 6062n]]),
343
+ * service: new Map([["Standard", 2610n], ["Priority", 1010n], ["Economy", 589n], ["International", 4211n]]),
344
+ * origins: new Map([["Air hub", { parcels: 2441n, late: 38n }], ["Harbour hub", { parcels: 1997n, late: 62n }], ["Rail yard", { parcels: 1018n, late: 12n }], ["Depot 02", { parcels: 766n, late: 9n }], ["Depot 05", { parcels: 615n, late: 4n }], ["Depot 07", { parcels: 454n, late: 6n }], ["Depot 11", { parcels: 333n, late: 2n }], ["City counter", { parcels: 282n, late: 3n }], ["Partner pickup", { parcels: 232n, late: 5n }], ["Returns desk", { parcels: 161n, late: 1n }], ["Locker bank", { parcels: 121n, late: 0n }]]),
345
+ * }],
346
+ * ["l7", {
347
+ * region: new Map([["Metro", 1169n], ["Regional", 752n], ["Remote", 418n], ["Overseas", 6011n]]),
348
+ * service: new Map([["Standard", 2589n], ["Priority", 1002n], ["Economy", 585n], ["International", 4174n]]),
349
+ * origins: new Map([["Air hub", { parcels: 2420n, late: 38n }], ["Harbour hub", { parcels: 1980n, late: 61n }], ["Rail yard", { parcels: 1010n, late: 12n }], ["Depot 02", { parcels: 760n, late: 9n }], ["Depot 05", { parcels: 610n, late: 4n }], ["Depot 07", { parcels: 450n, late: 6n }], ["Depot 11", { parcels: 330n, late: 2n }], ["City counter", { parcels: 280n, late: 3n }], ["Partner pickup", { parcels: 230n, late: 5n }], ["Returns desk", { parcels: 160n, late: 1n }], ["Locker bank", { parcels: 120n, late: 0n }]]),
350
+ * }],
351
+ * ["l8", {
352
+ * region: new Map([["Metro", 3296n], ["Regional", 2472n], ["Remote", 1154n], ["Overseas", 1318n]]),
353
+ * service: new Map([["Standard", 4120n], ["Priority", 1813n], ["Economy", 989n], ["International", 1318n]]),
354
+ * origins: new Map([["Air hub", { parcels: 2388n, late: 37n }], ["Harbour hub", { parcels: 1954n, late: 60n }], ["Rail yard", { parcels: 997n, late: 12n }], ["Depot 02", { parcels: 750n, late: 9n }], ["Depot 05", { parcels: 602n, late: 4n }], ["Depot 07", { parcels: 444n, late: 6n }], ["Depot 11", { parcels: 326n, late: 2n }], ["City counter", { parcels: 276n, late: 3n }], ["Partner pickup", { parcels: 227n, late: 5n }], ["Returns desk", { parcels: 158n, late: 1n }], ["Locker bank", { parcels: 118n, late: 0n }]]),
355
+ * }],
356
+ * ["l9", {
357
+ * region: new Map([["Metro", 8003n], ["Regional", 5620n], ["Remote", 2555n], ["Overseas", 852n]]),
358
+ * service: new Map([["Standard", 9876n], ["Priority", 4258n], ["Economy", 2044n], ["International", 852n]]),
359
+ * origins: new Map([["Air hub", { parcels: 4936n, late: 78n }], ["Harbour hub", { parcels: 4038n, late: 124n }], ["Rail yard", { parcels: 2060n, late: 24n }], ["Depot 02", { parcels: 1550n, late: 18n }], ["Depot 05", { parcels: 1244n, late: 8n }], ["Depot 07", { parcels: 918n, late: 12n }], ["Depot 11", { parcels: 673n, late: 4n }], ["City counter", { parcels: 571n, late: 6n }], ["Partner pickup", { parcels: 469n, late: 10n }], ["Returns desk", { parcels: 326n, late: 2n }], ["Locker bank", { parcels: 245n, late: 0n }]]),
360
+ * }],
361
+ * ["l11", {
362
+ * region: new Map([["Metro", 294n], ["Regional", 274n], ["Remote", 216n], ["Overseas", 196n]]),
363
+ * service: new Map([["Standard", 471n], ["Priority", 294n], ["Economy", 137n], ["International", 78n]]),
364
+ * origins: new Map([["Air hub", { parcels: 283n, late: 4n }], ["Harbour hub", { parcels: 232n, late: 7n }], ["Rail yard", { parcels: 119n, late: 1n }], ["Depot 02", { parcels: 89n, late: 1n }], ["Depot 05", { parcels: 72n, late: 0n }], ["Depot 07", { parcels: 53n, late: 1n }], ["Depot 11", { parcels: 39n, late: 0n }], ["City counter", { parcels: 33n, late: 0n }], ["Partner pickup", { parcels: 27n, late: 1n }], ["Returns desk", { parcels: 19n, late: 0n }], ["Locker bank", { parcels: 14n, late: 0n }]]),
365
+ * }],
366
+ * ["l12", {
367
+ * region: new Map([["Metro", 292n], ["Regional", 273n], ["Remote", 215n], ["Overseas", 195n]]),
368
+ * service: new Map([["Standard", 467n], ["Priority", 293n], ["Economy", 137n], ["International", 78n]]),
369
+ * origins: new Map([["Air hub", { parcels: 281n, late: 4n }], ["Harbour hub", { parcels: 231n, late: 7n }], ["Rail yard", { parcels: 118n, late: 1n }], ["Depot 02", { parcels: 89n, late: 1n }], ["Depot 05", { parcels: 71n, late: 0n }], ["Depot 07", { parcels: 53n, late: 1n }], ["Depot 11", { parcels: 39n, late: 0n }], ["City counter", { parcels: 33n, late: 0n }], ["Partner pickup", { parcels: 27n, late: 1n }], ["Returns desk", { parcels: 19n, late: 0n }], ["Locker bank", { parcels: 14n, late: 0n }]]),
370
+ * }],
371
+ * ["l13", {
372
+ * region: new Map([["Metro", 4570n], ["Regional", 2989n], ["Remote", 1055n], ["Overseas", 176n]]),
373
+ * service: new Map([["Standard", 5450n], ["Priority", 2285n], ["Economy", 1055n]]),
374
+ * origins: new Map([["Air hub", { parcels: 2549n, late: 40n }], ["Harbour hub", { parcels: 2084n, late: 64n }], ["Rail yard", { parcels: 1063n, late: 13n }], ["Depot 02", { parcels: 800n, late: 9n }], ["Depot 05", { parcels: 642n, late: 4n }], ["Depot 07", { parcels: 474n, late: 6n }], ["Depot 11", { parcels: 347n, late: 2n }], ["City counter", { parcels: 295n, late: 3n }], ["Partner pickup", { parcels: 242n, late: 5n }], ["Returns desk", { parcels: 168n, late: 1n }], ["Locker bank", { parcels: 126n, late: 0n }]]),
375
+ * }],
376
+ * ["r1", {
377
+ * region: new Map([["Metro", 371n], ["Regional", 192n], ["Remote", 77n]]),
378
+ * service: new Map([["Standard", 397n], ["Priority", 128n], ["Economy", 77n], ["International", 38n]]),
379
+ * origins: new Map([["Air hub", { parcels: 187n, late: 3n }], ["Harbour hub", { parcels: 152n, late: 5n }], ["Rail yard", { parcels: 77n, late: 1n }], ["Depot 02", { parcels: 58n, late: 1n }], ["Depot 05", { parcels: 47n, late: 0n }], ["Depot 07", { parcels: 34n, late: 0n }], ["Depot 11", { parcels: 25n, late: 0n }], ["City counter", { parcels: 21n, late: 0n }], ["Partner pickup", { parcels: 18n, late: 0n }], ["Returns desk", { parcels: 12n, late: 0n }], ["Locker bank", { parcels: 9n, late: 0n }]]),
380
+ * }],
381
+ * ["r2", {
382
+ * region: new Map([["Metro", 354n], ["Regional", 183n], ["Remote", 73n]]),
383
+ * service: new Map([["Standard", 378n], ["Priority", 122n], ["Economy", 73n], ["International", 37n]]),
384
+ * origins: new Map([["Air hub", { parcels: 175n, late: 3n }], ["Harbour hub", { parcels: 145n, late: 4n }], ["Rail yard", { parcels: 74n, late: 1n }], ["Depot 02", { parcels: 56n, late: 1n }], ["Depot 05", { parcels: 45n, late: 0n }], ["Depot 07", { parcels: 33n, late: 0n }], ["Depot 11", { parcels: 24n, late: 0n }], ["City counter", { parcels: 20n, late: 0n }], ["Partner pickup", { parcels: 17n, late: 0n }], ["Returns desk", { parcels: 12n, late: 0n }], ["Locker bank", { parcels: 9n, late: 0n }]]),
385
+ * }],
386
+ * ]),
387
+ * mutations: (mutation) => ({ patch: mutation.patch() }),
388
+ * });
389
+ * export const StepCard = StructType({
390
+ * name: StringType,
391
+ * group: StringType,
392
+ * values: StructType({ name: StringType, slots: OptionType(IntegerType), flow: StringType }),
393
+ * });
394
+ * export const MoveCard = StructType({
395
+ * name: StringType,
396
+ * group: StringType,
397
+ * values: StructType({
398
+ * kind: VariantType({ planned: NullType, observed: NullType }), trigger: OptionType(StringType),
399
+ * volume: OptionType(FloatType), n: OptionType(IntegerType), at: OptionType(DateTimeType), flow: StringType,
400
+ * }),
401
+ * });
402
+ * export const stepCards = e3.record("flowchart_step_cards", DictType(StringType, StepCard), {
403
+ * initial: new Map([
404
+ * ["scan", { name: "Scan point", group: "Intake", values: { name: "Scan point", slots: none, flow: "Parcels" } }],
405
+ * ["chutes", { name: "Sort chutes", group: "Sort", values: { name: "Sort chutes", slots: some(12n), flow: "Parcels" } }],
406
+ * ["desk", { name: "Exception desk", group: "Hold", values: { name: "Exception desk", slots: none, flow: "Parcels" } }],
407
+ * ]),
408
+ * indexes: (index) => ({ flowchart_step_cards_by_group: index.on(["group"]) }),
409
+ * });
410
+ * export const moveCards = e3.record("flowchart_move_cards", DictType(StringType, MoveCard), {
411
+ * initial: new Map([
412
+ * ["planned", { name: "Planned", group: "Kinds",
413
+ * values: { kind: variant("planned", null), trigger: none, volume: none, n: none, at: none, flow: "Parcels" } }],
414
+ * ["reroute", { name: "Observed reroute", group: "Kinds",
415
+ * values: { kind: variant("observed", null), trigger: none, volume: none, n: none, at: none, flow: "Parcels" } }],
416
+ * ["routed", { name: "Routed by the sort plan", group: "Decisions",
417
+ * values: { kind: variant("planned", null), trigger: some("route"), volume: none, n: none, at: none, flow: "Parcels" } }],
418
+ * ]),
419
+ * indexes: (index) => ({ flowchart_move_cards_by_group: index.on(["group"]) }),
420
+ * });
421
+ * export const LaneCard = StructType({ name: StringType, group: StringType, values: StructType({ label: StringType }) });
422
+ * export const laneCards = e3.record("flowchart_lane_cards", DictType(StringType, LaneCard), {
423
+ * initial: new Map([
424
+ * ["returns", { name: "Returns", group: "Lanes", values: { label: "Returns" } }],
425
+ * ["check", { name: "Quality check", group: "Lanes", values: { label: "Quality check" } }],
426
+ * ]),
427
+ * indexes: (index) => ({ flowchart_lane_cards_by_group: index.on(["group"]) }),
428
+ * });
429
+ * export const DecisionOwner = StructType({ name: StringType, desk: StringType });
430
+ * export const decisionOwners = e3.input("flowchart_decision_owners", DictType(StringType, DecisionOwner), variant("value", new Map([
431
+ * ["sp", { name: "sort-planner", desk: "Sort office" }],
432
+ * ["cd", { name: "customs-desk", desk: "Customs" }],
433
+ * ["ns", { name: "night-supervisor", desk: "Night shift" }],
434
+ * ])));
435
+ *
436
+ * const flowchartDepot = East.function([], UIComponentType, (_$) => (
437
+ * <Reactive>{$ => {
438
+ * // The states and the transitions: editable through their patch doors, read through their sources of the rail.
439
+ * const states = $.let(Record.bind(depotStates));
440
+ * const stateEntries = $.let(Data.bindPaged(depotStates));
441
+ * const transitions = $.let(Record.bind(depotTransitions));
442
+ * const transitionEntries = $.let(Data.bindPaged(depotTransitions));
443
+ * // The lanes and the decisions: small records, read whole.
444
+ * const lanes = $.let(Record.bind(depotLanes));
445
+ * const decisions = $.let(Record.bind(depotDecisions));
446
+ * // The details, read by the drawn rows' keys, as their kinds are read through their sources. The states'
447
+ * // evidence is bound once, its entries index listed: the rail's evidence source, and the details its picks weigh.
448
+ * const evidence = $.let(Data.bindPaged(stateEvidence, { indexes: ["flowchart_evidence_by_service"] }));
449
+ * const moveRows = $.let(Data.bindPaged(moveEvidence));
450
+ * const steps = $.let(Data.bind(stepCards));
451
+ * const moves = $.let(Data.bind(moveCards));
452
+ * const laneRows = $.let(Data.bind(laneCards));
453
+ * const owners = $.let(Data.bind(decisionOwners));
454
+ * // One rail: the states and the transitions by their flow — the states by their lane too — and each list of
455
+ * // cards by its group. The flowchart opens on the parcels' flow; a preset picks a flow for both at once.
456
+ * const slice = $.let(Slice.bindRecords("flowchart.depot", {
457
+ * states: {
458
+ * source: Data.bindPaged(depotStates, { indexes: ["flowchart_states_by_flow", "flowchart_states_by_lane"] }),
459
+ * icon: { prefix: "fas", name: "circle-nodes" },
460
+ * // Each field the rail offers is one an index answers: the flow, and the lane after it.
461
+ * fields: { flow: { label: "Flow", hints: ["Parcels", "Returns"] }, phase: { label: "Lane" } },
462
+ * initial: { flow: ["Parcels"] },
463
+ * },
464
+ * transitions: {
465
+ * source: Data.bindPaged(depotTransitions, { indexes: ["flowchart_transitions_by_flow"] }),
466
+ * icon: { prefix: "fas", name: "arrow-right-long" },
467
+ * fields: { flow: { label: "Flow", hints: ["Parcels", "Returns"] } },
468
+ * initial: { flow: ["Parcels"] },
469
+ * },
470
+ * // Each service's own figures: the services picked weigh the states' details, and narrow no row.
471
+ * evidence: {
472
+ * source: evidence,
473
+ * icon: { prefix: "fas", name: "boxes-stacked" },
474
+ * fields: { byService: { label: "Service", hints: ["Standard", "Priority", "Economy", "International"] } },
475
+ * },
476
+ * stepCards: { source: Data.bindPaged(stepCards, { indexes: ["flowchart_step_cards_by_group"] }), fields: { group: { label: "Group" } } },
477
+ * moveCards: { source: Data.bindPaged(moveCards, { indexes: ["flowchart_move_cards_by_group"] }), fields: { group: { label: "Group" } } },
478
+ * laneCards: { source: Data.bindPaged(laneCards, { indexes: ["flowchart_lane_cards_by_group"] }), fields: { group: { label: "Group" } } },
479
+ * }, { presets: [
480
+ * { id: "parcels", name: "Parcels", where: { states: { flow: ["Parcels"] }, transitions: { flow: ["Parcels"] } } },
481
+ * { id: "returns", name: "Returns", where: { states: { flow: ["Returns"] }, transitions: { flow: ["Returns"] } } },
482
+ * ] }));
483
+ * return (
484
+ * <Box height="640px">
485
+ * <Flowchart
486
+ * slice={{ slice }}
487
+ * states={Flowchart.states(states, {
488
+ * name: "State", icon: "circle-nodes", entries: stateEntries,
489
+ * label: "name", lane: "phase", order: "seq",
490
+ * members: (s) => s.slots,
491
+ * // Drawn in this order on each state's card and in the inspector, each where its show says — "all" unless given.
492
+ * // The services the rail picks weigh each read their figures hold, added up by kind; the equipment, the
493
+ * // shifts and the Service list, which they lack, draw the state's own.
494
+ * details: Flowchart.details(evidence, {
495
+ * source: "evidence",
496
+ * details: [
497
+ * Flowchart.figure("parcels", { label: "Parcels", unit: "parcels" }),
498
+ * Flowchart.figure("waiting", { label: "Still in state", show: "inspector" }),
499
+ * // each tag's look, as a Tag takes it — first defined, first shown
500
+ * Flowchart.tags("flags", {
501
+ * label: "Flags",
502
+ * colors: {
503
+ * "Hazmat": { colorPalette: "danger", variant: "solid" },
504
+ * "At risk": { colorPalette: "warning", variant: "subtle" },
505
+ * "Customs": { colorPalette: "brand", variant: "outline" },
506
+ * "Oversize": { colorPalette: "orange", variant: "subtle" },
507
+ * "Fragile": { colorPalette: "purple", variant: "subtle" },
508
+ * "Cold chain": { colorPalette: "info", variant: "subtle" },
509
+ * },
510
+ * legend: true, // the legend lists them, under "Flags"
511
+ * }),
512
+ * Flowchart.tags("equipment", {
513
+ * label: "Equipment",
514
+ * colors: {
515
+ * "Conveyor": { colorPalette: "teal" }, // subtle unless given
516
+ * "Scanner": { colorPalette: "blue" },
517
+ * "Forklift": { colorPalette: "gray", variant: "outline" },
518
+ * "Label printer": { colorPalette: "purple", variant: "outline" },
519
+ * "X-ray": { colorPalette: "info", variant: "outline" },
520
+ * },
521
+ * legend: true,
522
+ * }),
523
+ * Flowchart.tags("shifts", {
524
+ * label: "Shifts",
525
+ * colors: {
526
+ * "Early": { colorPalette: "yellow" },
527
+ * "Late": { colorPalette: "orange" },
528
+ * "Night": { colorPalette: "purple", variant: "solid" },
529
+ * "Weekend": { colorPalette: "gray" },
530
+ * },
531
+ * }),
532
+ * // the app's bins, in hours — a quarter hour apiece at first, then hours, days and a
533
+ * // week — a bar each whatever its span, on an axis naming 1h, 12h, 2d and 1w
534
+ * Flowchart.histogram("hours", {
535
+ * unit: "hours", label: "Time in state", counts: "parcels",
536
+ * bins: [0, 0.25, 0.5, 1, 2, 4, 8, 12, 24, 48, 96, 168],
537
+ * ticks: [1, 12, 48, 168],
538
+ * }),
539
+ * Flowchart.list("service", { label: "Service", top: 2, unit: "parcels" }),
540
+ * Flowchart.list("exceptions", { label: "Exceptions", unit: "parcels", show: "inspector" }),
541
+ * ],
542
+ * }),
543
+ * // the Steps tab's cards: a card dropped on a lane adds a state there, from its values
544
+ * templates: Flowchart.templates(steps.read(), {
545
+ * name: (c) => c.name, group: (c) => some(c.group), values: (c) => c.values, source: "stepCards",
546
+ * }),
547
+ * })}
548
+ * transitions={Flowchart.transitions(transitions, {
549
+ * name: "Transition", icon: "arrow-right-long", entries: transitionEntries,
550
+ * from: "src", to: "dst", decision: "trigger",
551
+ * kind: (t) => t.kind,
552
+ * evidence: (t) => some({ volume: t.volume, count: t.n, measuredAt: t.at, unit: some("parcels") }),
553
+ * // Evidence shows them, so the form leaves them out.
554
+ * fields: { volume: Fields.hidden(), n: Fields.hidden(), at: Fields.hidden() },
555
+ * // The label draws the region under its evidence; the inspector shows all three.
556
+ * details: Flowchart.details(moveRows, {
557
+ * details: [
558
+ * Flowchart.list("region", { label: "Region", top: 1, unit: "parcels" }),
559
+ * Flowchart.list("service", { label: "Service", unit: "parcels", show: "inspector" }),
560
+ * // a Dict of structs: its draw says which number is the value, and a note
561
+ * Flowchart.list("origins", { label: "Origin", unit: "parcels", show: "inspector" },
562
+ * (o) => ({ value: o.parcels, note: some(East.str`${o.late} late`) })),
563
+ * ],
564
+ * }),
565
+ * // the Transitions tab's cards: a card dropped on a transition gives it its values
566
+ * templates: Flowchart.templates(moves.read(), {
567
+ * name: (c) => c.name, group: (c) => some(c.group), values: (c) => c.values, source: "moveCards",
568
+ * }),
569
+ * })}
570
+ * lanes={Flowchart.lanes(lanes, {
571
+ * label: "label", order: "seq",
572
+ * // the Lanes tab's cards: one dropped between two lanes adds a lane there, from its values
573
+ * templates: Flowchart.templates(laneRows.read(), {
574
+ * name: (c) => c.name, group: (c) => some(c.group), values: (c) => c.values, source: "laneCards",
575
+ * }),
576
+ * })}
577
+ * decisions={Flowchart.decisions(decisions, { label: (d) => d.name, owner: (d) => some(d.owner) })}
578
+ * library={[
579
+ * Flowchart.library.states(), // Steps: the states' cards, by group
580
+ * Flowchart.library.transitions(), // Transitions: the transitions' cards
581
+ * Flowchart.library.lanes(), // Lanes: the lanes' cards
582
+ * Flowchart.library.tab(owners.read(), {
583
+ * name: "Owners", icon: "user-tie", label: (o) => o.name, meta: (o) => some(o.desk),
584
+ * // its patch is over a decision's row: dropped on a diamond, the card sets the decision's owner
585
+ * drop: (o) => Flowchart.patch(DepotDecision, { owner: o.name }),
586
+ * }),
587
+ * ]}
588
+ * freshness={{ label: "evidence-2026.06", date: new Date("2026-06-30T00:00:00Z") }}
589
+ * name="depot"
590
+ * />
591
+ * </Box>
592
+ * );
593
+ * }}</Reactive>
594
+ * ));
595
+ * ```
596
+ */
597
+ export function flowchartTemplates(rows, spec) {
598
+ const source = East.value(rows);
599
+ const type = Expr.type(source);
600
+ if (type.type !== "Dict" || !isTypeEqual(type.key, StringType)) {
601
+ throw new Error(`Flowchart.templates: the cards are a record's rows, keyed by String — a Dict, Data.bind(record).read() — and these are ${printType(type)}`);
602
+ }
603
+ const rowType = type.value;
604
+ const values = East.function([rowType, StringType], undefined, (_$, row, key) => spec.values(row, key));
605
+ const valuesType = Expr.type(values).output;
606
+ if (valuesType.type !== "Struct") {
607
+ throw new Error("Flowchart.templates: `values` returns a struct, every field of the row the card makes but what a drop writes");
608
+ }
609
+ const describe = East.function([rowType, StringType], FlowchartTemplateType, ($, row, key) => {
610
+ const initial = $.const(values);
611
+ return {
612
+ key,
613
+ name: spec.name(row, key),
614
+ group: spec.group === undefined ? East.value(none, OptionType(StringType)) : spec.group(row, key),
615
+ values: East.Blob.encodeBeast(initial(row, key), "v2"),
616
+ };
617
+ });
618
+ const items = source.toArray(($, row, key) => {
619
+ const card = $.const(describe);
620
+ return card(row, key);
621
+ });
622
+ return { [FLOWCHART_TEMPLATES]: true, valuesType, items, source: spec.source };
623
+ }
624
+ /**
625
+ * Whether a kind's `templates` is a list of cards over a record.
626
+ *
627
+ * @param templates - What a kind was given
628
+ * @returns Whether it is `Flowchart.templates`'
629
+ */
630
+ export function isFlowchartTemplates(templates) {
631
+ return typeof templates === "object" && templates !== null && FLOWCHART_TEMPLATES in templates;
632
+ }
633
+ /**
634
+ * Checks a kind's cards: `Flowchart.templates`', never a list written in the
635
+ * code, their values of the type a drop of the kind takes.
636
+ *
637
+ * @param templates - What the kind was given
638
+ * @param expected - The row's fields less what a drop writes
639
+ * @param placed - The fields a drop writes, which the values leave out
640
+ * @param where - The kind, as a refusal names it
641
+ * @returns The cards on the wire, and the source they follow; `undefined` for a kind with no cards
642
+ * @throws {Error} When they are not `Flowchart.templates`', or their values are of another type, naming both
643
+ */
644
+ export function checkedFlowchartTemplates(templates, expected, placed, where) {
645
+ if (templates === undefined)
646
+ return undefined;
647
+ if (!isFlowchartTemplates(templates)) {
648
+ throw new Error(`${where}: \`templates\` are records — Flowchart.templates(cards.read(), { name, values, source }) over a record of the app's, ` +
649
+ "its source one of the slice's");
650
+ }
651
+ if (!isTypeEqual(templates.valuesType, expected)) {
652
+ const named = placed.map((field) => `\`${field}\``);
653
+ const but = named.length === 0 ? "" : ` but ${named.length === 1 ? named[0] : `${named.slice(0, -1).join(", ")} and ${named.at(-1)}`}`;
654
+ throw new Error(`${where}: its cards' \`values\` give every field of the row${but} — ${printType(expected)} — and these give ${printType(templates.valuesType)}`);
655
+ }
656
+ return { items: templates.items, source: templates.source };
657
+ }
658
+ //# sourceMappingURL=templates.js.map