ui-router-devtools 0.0.0-stage → 0.1.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 (223) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +160 -2
  3. package/dist/console.d.ts +5 -0
  4. package/dist/console.d.ts.map +1 -0
  5. package/dist/console.js +47 -0
  6. package/dist/console.js.map +1 -0
  7. package/dist/define.d.ts +8 -0
  8. package/dist/define.d.ts.map +1 -0
  9. package/dist/define.js +4 -0
  10. package/dist/define.js.map +1 -0
  11. package/dist/edges.d.ts +25 -0
  12. package/dist/edges.d.ts.map +1 -0
  13. package/dist/edges.js +28 -0
  14. package/dist/edges.js.map +1 -0
  15. package/dist/element/chips.d.ts +17 -0
  16. package/dist/element/chips.d.ts.map +1 -0
  17. package/dist/element/chips.js +134 -0
  18. package/dist/element/chips.js.map +1 -0
  19. package/dist/element/glyphs.d.ts +34 -0
  20. package/dist/element/glyphs.d.ts.map +1 -0
  21. package/dist/element/glyphs.js +107 -0
  22. package/dist/element/glyphs.js.map +1 -0
  23. package/dist/element/inspector.d.ts +7 -0
  24. package/dist/element/inspector.d.ts.map +1 -0
  25. package/dist/element/inspector.js +183 -0
  26. package/dist/element/inspector.js.map +1 -0
  27. package/dist/element/links.d.ts +4 -0
  28. package/dist/element/links.d.ts.map +1 -0
  29. package/dist/element/links.js +87 -0
  30. package/dist/element/links.js.map +1 -0
  31. package/dist/element/log.d.ts +12 -0
  32. package/dist/element/log.d.ts.map +1 -0
  33. package/dist/element/log.js +272 -0
  34. package/dist/element/log.js.map +1 -0
  35. package/dist/element/map.d.ts +5 -0
  36. package/dist/element/map.d.ts.map +1 -0
  37. package/dist/element/map.js +5 -0
  38. package/dist/element/map.js.map +1 -0
  39. package/dist/element/mapview.d.ts +17 -0
  40. package/dist/element/mapview.d.ts.map +1 -0
  41. package/dist/element/mapview.js +158 -0
  42. package/dist/element/mapview.js.map +1 -0
  43. package/dist/element/measure.d.ts +3 -0
  44. package/dist/element/measure.d.ts.map +1 -0
  45. package/dist/element/measure.js +9 -0
  46. package/dist/element/measure.js.map +1 -0
  47. package/dist/element/nested.d.ts +45 -0
  48. package/dist/element/nested.d.ts.map +1 -0
  49. package/dist/element/nested.js +686 -0
  50. package/dist/element/nested.js.map +1 -0
  51. package/dist/element/pack.d.ts +75 -0
  52. package/dist/element/pack.d.ts.map +1 -0
  53. package/dist/element/pack.js +281 -0
  54. package/dist/element/pack.js.map +1 -0
  55. package/dist/element/panel.d.ts +159 -0
  56. package/dist/element/panel.d.ts.map +1 -0
  57. package/dist/element/panel.js +1542 -0
  58. package/dist/element/panel.js.map +1 -0
  59. package/dist/element/popover.d.ts +12 -0
  60. package/dist/element/popover.d.ts.map +1 -0
  61. package/dist/element/popover.js +38 -0
  62. package/dist/element/popover.js.map +1 -0
  63. package/dist/element/route.d.ts +75 -0
  64. package/dist/element/route.d.ts.map +1 -0
  65. package/dist/element/route.js +883 -0
  66. package/dist/element/route.js.map +1 -0
  67. package/dist/element/scrubber.d.ts +4 -0
  68. package/dist/element/scrubber.d.ts.map +1 -0
  69. package/dist/element/scrubber.js +67 -0
  70. package/dist/element/scrubber.js.map +1 -0
  71. package/dist/element/styles.d.ts +3 -0
  72. package/dist/element/styles.d.ts.map +1 -0
  73. package/dist/element/styles.js +2084 -0
  74. package/dist/element/styles.js.map +1 -0
  75. package/dist/element/timeline-styles.d.ts +3 -0
  76. package/dist/element/timeline-styles.d.ts.map +1 -0
  77. package/dist/element/timeline-styles.js +286 -0
  78. package/dist/element/timeline-styles.js.map +1 -0
  79. package/dist/element/timeline.d.ts +9 -0
  80. package/dist/element/timeline.d.ts.map +1 -0
  81. package/dist/element/timeline.js +225 -0
  82. package/dist/element/timeline.js.map +1 -0
  83. package/dist/element/tree.d.ts +24 -0
  84. package/dist/element/tree.d.ts.map +1 -0
  85. package/dist/element/tree.js +149 -0
  86. package/dist/element/tree.js.map +1 -0
  87. package/dist/element/viewmap-styles.d.ts +3 -0
  88. package/dist/element/viewmap-styles.d.ts.map +1 -0
  89. package/dist/element/viewmap-styles.js +282 -0
  90. package/dist/element/viewmap-styles.js.map +1 -0
  91. package/dist/element/viewmap.d.ts +39 -0
  92. package/dist/element/viewmap.d.ts.map +1 -0
  93. package/dist/element/viewmap.js +406 -0
  94. package/dist/element/viewmap.js.map +1 -0
  95. package/dist/element/viewport.d.ts +31 -0
  96. package/dist/element/viewport.d.ts.map +1 -0
  97. package/dist/element/viewport.js +37 -0
  98. package/dist/element/viewport.js.map +1 -0
  99. package/dist/element/waterfall.d.ts +85 -0
  100. package/dist/element/waterfall.d.ts.map +1 -0
  101. package/dist/element/waterfall.js +284 -0
  102. package/dist/element/waterfall.js.map +1 -0
  103. package/dist/fold.d.ts +27 -0
  104. package/dist/fold.d.ts.map +1 -0
  105. package/dist/fold.js +104 -0
  106. package/dist/fold.js.map +1 -0
  107. package/dist/index.d.ts +6 -0
  108. package/dist/index.d.ts.map +1 -0
  109. package/dist/index.js +6 -0
  110. package/dist/index.js.map +1 -0
  111. package/dist/lit-ui-router.d.ts +24 -0
  112. package/dist/lit-ui-router.d.ts.map +1 -0
  113. package/dist/lit-ui-router.js +102 -0
  114. package/dist/lit-ui-router.js.map +1 -0
  115. package/dist/notation.d.ts +28 -0
  116. package/dist/notation.d.ts.map +1 -0
  117. package/dist/notation.js +105 -0
  118. package/dist/notation.js.map +1 -0
  119. package/dist/performance.d.ts +5 -0
  120. package/dist/performance.d.ts.map +1 -0
  121. package/dist/performance.js +66 -0
  122. package/dist/performance.js.map +1 -0
  123. package/dist/plugin.d.ts +32 -0
  124. package/dist/plugin.d.ts.map +1 -0
  125. package/dist/plugin.js +21 -0
  126. package/dist/plugin.js.map +1 -0
  127. package/dist/recorder.d.ts +30 -0
  128. package/dist/recorder.d.ts.map +1 -0
  129. package/dist/recorder.js +117 -0
  130. package/dist/recorder.js.map +1 -0
  131. package/dist/schema.d.ts +2 -0
  132. package/dist/schema.d.ts.map +1 -0
  133. package/dist/schema.js +2 -0
  134. package/dist/schema.js.map +1 -0
  135. package/dist/session-schema.d.ts +31 -0
  136. package/dist/session-schema.d.ts.map +1 -0
  137. package/dist/session-schema.js +314 -0
  138. package/dist/session-schema.js.map +1 -0
  139. package/dist/session.schema.json +1172 -0
  140. package/dist/shared/event-schema.d.ts +225 -0
  141. package/dist/shared/event-schema.d.ts.map +1 -0
  142. package/dist/shared/event-schema.js +2 -0
  143. package/dist/shared/event-schema.js.map +1 -0
  144. package/dist/shared/redaction.d.ts +19 -0
  145. package/dist/shared/redaction.d.ts.map +1 -0
  146. package/dist/shared/redaction.js +56 -0
  147. package/dist/shared/redaction.js.map +1 -0
  148. package/dist/shared/resolve-timing.d.ts +6 -0
  149. package/dist/shared/resolve-timing.d.ts.map +1 -0
  150. package/dist/shared/resolve-timing.js +61 -0
  151. package/dist/shared/resolve-timing.js.map +1 -0
  152. package/dist/shared/router-events.d.ts +10 -0
  153. package/dist/shared/router-events.d.ts.map +1 -0
  154. package/dist/shared/router-events.js +296 -0
  155. package/dist/shared/router-events.js.map +1 -0
  156. package/dist/shared/thrown.d.ts +5 -0
  157. package/dist/shared/thrown.d.ts.map +1 -0
  158. package/dist/shared/thrown.js +12 -0
  159. package/dist/shared/thrown.js.map +1 -0
  160. package/dist/shared/transition-source.d.ts +4 -0
  161. package/dist/shared/transition-source.d.ts.map +1 -0
  162. package/dist/shared/transition-source.js +2 -0
  163. package/dist/shared/transition-source.js.map +1 -0
  164. package/dist/shared/views.d.ts +10 -0
  165. package/dist/shared/views.d.ts.map +1 -0
  166. package/dist/shared/views.js +67 -0
  167. package/dist/shared/views.js.map +1 -0
  168. package/dist/spans.d.ts +15 -0
  169. package/dist/spans.d.ts.map +1 -0
  170. package/dist/spans.js +24 -0
  171. package/dist/spans.js.map +1 -0
  172. package/dist/testing.d.ts +32 -0
  173. package/dist/testing.d.ts.map +1 -0
  174. package/dist/testing.js +28 -0
  175. package/dist/testing.js.map +1 -0
  176. package/dist/ui-router-devtools.d.ts +36 -0
  177. package/dist/ui-router-devtools.d.ts.map +1 -0
  178. package/dist/ui-router-devtools.js +3 -0
  179. package/dist/ui-router-devtools.js.map +1 -0
  180. package/dist/views.d.ts +44 -0
  181. package/dist/views.d.ts.map +1 -0
  182. package/dist/views.js +43 -0
  183. package/dist/views.js.map +1 -0
  184. package/package.json +118 -3
  185. package/src/console.ts +104 -0
  186. package/src/define.ts +12 -0
  187. package/src/edges.ts +64 -0
  188. package/src/element/chips.ts +187 -0
  189. package/src/element/glyphs.ts +218 -0
  190. package/src/element/inspector.ts +315 -0
  191. package/src/element/links.ts +136 -0
  192. package/src/element/log.ts +410 -0
  193. package/src/element/map.ts +22 -0
  194. package/src/element/mapview.ts +224 -0
  195. package/src/element/measure.ts +13 -0
  196. package/src/element/nested.ts +1124 -0
  197. package/src/element/pack.ts +526 -0
  198. package/src/element/panel.ts +2378 -0
  199. package/src/element/popover.ts +64 -0
  200. package/src/element/route.ts +1481 -0
  201. package/src/element/scrubber.ts +103 -0
  202. package/src/element/styles.ts +2084 -0
  203. package/src/element/timeline-styles.ts +287 -0
  204. package/src/element/timeline.ts +392 -0
  205. package/src/element/tree.ts +271 -0
  206. package/src/element/viewmap-styles.ts +283 -0
  207. package/src/element/viewmap.ts +733 -0
  208. package/src/element/viewport.ts +112 -0
  209. package/src/element/waterfall.ts +585 -0
  210. package/src/fold.ts +151 -0
  211. package/src/index.ts +40 -0
  212. package/src/lit-ui-router.ts +194 -0
  213. package/src/notation.ts +181 -0
  214. package/src/performance.ts +142 -0
  215. package/src/plugin.ts +57 -0
  216. package/src/recorder.ts +228 -0
  217. package/src/schema.ts +32 -0
  218. package/src/session-schema.ts +362 -0
  219. package/src/spans.ts +53 -0
  220. package/src/testing.ts +74 -0
  221. package/src/types/import-meta-env.d.ts +9 -0
  222. package/src/ui-router-devtools.ts +39 -0
  223. package/src/views.ts +116 -0
@@ -0,0 +1,1542 @@
1
+ import { adoptStyles, html, LitElement, nothing } from "lit";
2
+ import { record } from "../recorder.js";
3
+ import { ancestorsOf, apply, bareName, durationOf, emptyModel, fold, originOf } from "../fold.js";
4
+ import { ms, resultLine, seq } from "../notation.js";
5
+ import { defaultRedaction, redactionOf, redactSession } from "../shared/redaction.js";
6
+ import { SCHEMA_VERSION } from "../schema.js";
7
+ import { spansDuring, upsertSpan } from "../spans.js";
8
+ import { closeGlyph, depthClass, maxGlyph, minGlyph, statusGlyph, statusLabel, took } from "./glyphs.js";
9
+ import { styles } from "./styles.js";
10
+ import { renderOutline } from "./tree.js";
11
+ import { placeBeside } from "./popover.js";
12
+ import { renderScrubber } from "./scrubber.js";
13
+ import { renderLog } from "./log.js";
14
+ import { renderRouterCard, renderStateInspector, renderTxInspector } from "./inspector.js";
15
+ const SNAPSHOTS = new Set([
16
+ "config",
17
+ "states",
18
+ "current",
19
+ "views"
20
+ ]);
21
+ const MAP_FAILED = "The Map did not load. Switch views to retry.";
22
+ const TIMELINE_FAILED = "The Timeline did not load. Switch views to retry.";
23
+ const VIEWS_FAILED = "The Views did not load. Switch views to retry.";
24
+ const HEADINGS = {
25
+ outline: "States",
26
+ map: "States",
27
+ timeline: "Timeline",
28
+ views: "Views"
29
+ };
30
+ const NESTED_MIN_WIDTH = 560;
31
+ const SETTLE = 200;
32
+ const ASIDE = 320;
33
+ const MARGIN = 12;
34
+ const DRAG = 4;
35
+ const EASE_OUT = "cubic-bezier(0.23, 1, 0.32, 1)";
36
+ const FLIP = "uird-flip";
37
+ const RESCALE = "uird-rescale";
38
+ const LAYOUT_KEY = "ui-router-devtools:map-layout";
39
+ const storedLayout = () => {
40
+ try {
41
+ return localStorage.getItem(LAYOUT_KEY) === "tree" ? "tree" : "nested";
42
+ } catch {
43
+ return "nested";
44
+ }
45
+ };
46
+ const storeLayout = (layout) => {
47
+ try {
48
+ localStorage.setItem(LAYOUT_KEY, layout);
49
+ } catch {}
50
+ };
51
+ const VIEWS_KEY = "ui-router-devtools:map-views";
52
+ const storedViews = () => {
53
+ try {
54
+ return localStorage.getItem(VIEWS_KEY) !== "off";
55
+ } catch {
56
+ return true;
57
+ }
58
+ };
59
+ const storeViews = (shown) => {
60
+ try {
61
+ localStorage.setItem(VIEWS_KEY, shown ? "on" : "off");
62
+ } catch {}
63
+ };
64
+ const rectOf = (element, origin) => {
65
+ const rect = element.getBoundingClientRect();
66
+ return {
67
+ x: Math.round(rect.x - origin.x),
68
+ y: Math.round(rect.y - origin.y),
69
+ width: Math.round(rect.width),
70
+ height: Math.round(rect.height)
71
+ };
72
+ };
73
+ const popBounds = (origin) => ({
74
+ x: 8,
75
+ y: 34,
76
+ width: origin.width - 16,
77
+ height: origin.height - 70
78
+ });
79
+ const MOVERS = ":is(.nested, .map), [data-name]";
80
+ const moverKey = (element) => element.dataset.name ?? "";
81
+ const ROOM = " room";
82
+ const rescale = (root, was, shift) => {
83
+ const now = root.getBoundingClientRect();
84
+ const from = `translate(${was.x + shift.x - now.x}px, ${was.y + shift.y - now.y}px) scale(${was.width / now.width}, ${was.height / now.height})`;
85
+ root.animate([{
86
+ transformOrigin: "0 0",
87
+ transform: from
88
+ }, {
89
+ transformOrigin: "0 0",
90
+ transform: "none"
91
+ }], {
92
+ id: RESCALE,
93
+ duration: SETTLE,
94
+ easing: EASE_OUT
95
+ });
96
+ };
97
+ const alike = (a, b) => Math.abs(Math.log(a.width * b.height / (a.height * b.width || 1))) < .1;
98
+ const holdInside = (box, rtl) => {
99
+ const head = box.querySelector(":scope > .head");
100
+ const width = `${head?.offsetWidth ?? 0}px`;
101
+ const timing = {
102
+ id: FLIP,
103
+ duration: SETTLE
104
+ };
105
+ const clipPath = rtl ? "inset(-4px -24px -4px -4px)" : "inset(-4px -4px -4px -24px)";
106
+ return () => {
107
+ head?.animate([{ minWidth: width }, { minWidth: width }], timing);
108
+ box.animate([{ clipPath }, { clipPath }], timing);
109
+ };
110
+ };
111
+ const sizeOf = (rect) => ({
112
+ width: `${rect.width}px`,
113
+ height: `${rect.height}px`
114
+ });
115
+ const ease = (element, was, now, { x, y, rtl }) => {
116
+ const grows = element.matches(".box") && (Math.abs(was.width - now.width) >= 1 || Math.abs(was.height - now.height) >= 1);
117
+ if (!grows && Math.abs(x) < 1 && Math.abs(y) < 1) return;
118
+ const hold = grows ? holdInside(element, rtl) : undefined;
119
+ const from = { transform: `translate(${x}px, ${y}px)` };
120
+ const to = { transform: "none" };
121
+ if (grows) {
122
+ Object.assign(from, sizeOf(was));
123
+ Object.assign(to, sizeOf(now));
124
+ }
125
+ element.animate([from, to], {
126
+ id: FLIP,
127
+ duration: SETTLE,
128
+ easing: EASE_OUT
129
+ });
130
+ hold?.();
131
+ };
132
+ const elide = (name) => {
133
+ if (name.length <= 28) return name;
134
+ return `…${name.split(".").slice(-2).join(".")}`;
135
+ };
136
+ export class DevtoolsPanel extends LitElement {
137
+ static {
138
+ this.styles = styles;
139
+ }
140
+ static {
141
+ this.properties = {
142
+ router: { attribute: false },
143
+ history: { type: Number },
144
+ timeResolves: {
145
+ type: Boolean,
146
+ attribute: "time-resolves"
147
+ },
148
+ redaction: { attribute: false },
149
+ viewLocator: { attribute: false },
150
+ _live: { state: true },
151
+ _imported: { state: true },
152
+ _tab: { state: true },
153
+ _view: { state: true },
154
+ _layoutPref: { state: true },
155
+ _mapViews: { state: true },
156
+ _pathFocus: { state: true },
157
+ _max: { state: true },
158
+ _mapSize: { state: true },
159
+ _mapOpen: { state: true },
160
+ _mapFailed: { state: true },
161
+ _mapPan: { state: true },
162
+ _mapZoom: { state: true },
163
+ _selectedTx: { state: true },
164
+ _previewTx: { state: true },
165
+ _selectedState: { state: true },
166
+ _inspect: { state: true },
167
+ _focusState: { state: true },
168
+ _collapsed: { state: true },
169
+ _announcement: { state: true },
170
+ _copied: { state: true },
171
+ _now: { state: true },
172
+ _keepValues: { state: true },
173
+ _keepMessages: { state: true },
174
+ _notice: { state: true },
175
+ _timelineFailed: { state: true },
176
+ _timelineFocus: { state: true },
177
+ _timelineSelected: { state: true },
178
+ _timelineCollapsed: { state: true },
179
+ _spanCount: { state: true },
180
+ _viewsFailed: { state: true },
181
+ _viewFocus: { state: true },
182
+ _viewSelected: { state: true }
183
+ };
184
+ }
185
+ #timelineLoading;
186
+ #viewsLoading;
187
+ #pathFrom;
188
+ #statesSeen;
189
+ #pathFocused;
190
+ #pointedView;
191
+ #markedView;
192
+ #adopted;
193
+ #spans;
194
+ #mapLoading;
195
+ #geometry;
196
+ #before;
197
+ #layout;
198
+ #direct;
199
+ #onWheel;
200
+ #step;
201
+ #resized;
202
+ #resize;
203
+ #observed;
204
+ #recorder;
205
+ #attached;
206
+ #unsubscribe;
207
+ #ticker;
208
+ #newestTick;
209
+ #press;
210
+ constructor() {
211
+ super();
212
+ this._pressed = null;
213
+ this._mapWidths = new Map();
214
+ this._moveFocus = false;
215
+ this._importReader = () => import("../session-schema.js");
216
+ this._importMap = () => import("./map.js");
217
+ this._importTimeline = () => import("./timeline.js");
218
+ this.#timelineLoading = false;
219
+ this._importViews = () => import("./viewmap.js");
220
+ this.#viewsLoading = false;
221
+ this.#pathFrom = null;
222
+ this.#pathFocused = null;
223
+ this.#pointedView = null;
224
+ this.#markedView = null;
225
+ this.#adopted = new Set();
226
+ this.#spans = new Map();
227
+ this.#mapLoading = false;
228
+ this.#geometry = [];
229
+ this.#before = null;
230
+ this.#layout = null;
231
+ this.#direct = false;
232
+ this.#onWheel = {
233
+ handleEvent: (event) => this._map?.wheelPan(this, event),
234
+ passive: false
235
+ };
236
+ this.#resized = false;
237
+ this.#observed = null;
238
+ this.history = 500;
239
+ this.timeResolves = false;
240
+ this.redaction = defaultRedaction();
241
+ this._live = emptyModel();
242
+ this._imported = null;
243
+ this._tab = "tree";
244
+ this._view = "outline";
245
+ this._layoutPref = storedLayout();
246
+ this._mapViews = storedViews();
247
+ this._pathFocus = null;
248
+ this._max = false;
249
+ this._mapSize = {
250
+ width: 0,
251
+ height: 0
252
+ };
253
+ this._mapFailed = false;
254
+ this._mapOpen = new Map();
255
+ this._mapPan = null;
256
+ this._mapZoom = null;
257
+ this._inspect = "none";
258
+ this.#resetSelection();
259
+ this._collapsed = new Set();
260
+ this._announcement = "";
261
+ this._copied = null;
262
+ this._now = performance.now();
263
+ this._notice = null;
264
+ this._timelineFailed = false;
265
+ this._timelineCollapsed = new Set();
266
+ this._spanCount = 0;
267
+ this._viewsFailed = false;
268
+ }
269
+ get recorder() {
270
+ return this.#recorder;
271
+ }
272
+ get spans() {
273
+ return [...this.#spans.values()];
274
+ }
275
+ set spans(spans) {
276
+ this.#spans = new Map();
277
+ for (const span of spans) upsertSpan(this.#spans, span);
278
+ this._spanCount += 1;
279
+ }
280
+ addSpan(span) {
281
+ upsertSpan(this.#spans, span);
282
+ this._spanCount += 1;
283
+ }
284
+ _spanList() {
285
+ return this._imported ? this._imported.session.spans ?? [] : this.spans;
286
+ }
287
+ get _timeOrigin() {
288
+ return this._imported?.session.timeOrigin ?? performance.timeOrigin;
289
+ }
290
+ _timelineInput() {
291
+ const model = this._model;
292
+ return {
293
+ txs: model.txs,
294
+ states: model.states,
295
+ clock: this._clock,
296
+ timeResolves: this._imported?.session.timeResolves ?? this.timeResolves,
297
+ spans: this._spanList(),
298
+ timeOrigin: this._timeOrigin
299
+ };
300
+ }
301
+ get _model() {
302
+ return this._imported?.model ?? this._live;
303
+ }
304
+ get _clock() {
305
+ return this._imported?.session.t ?? this._now;
306
+ }
307
+ connectedCallback() {
308
+ super.connectedCallback();
309
+ for (const sheet of this.shadowRoot?.adoptedStyleSheets ?? []) sheet.media.mediaText = String(sheet.media);
310
+ if (this.router && !this.#recorder) this.#attach(this.router);
311
+ if (this.hasUpdated) this.#pill?.showPopover();
312
+ }
313
+ disconnectedCallback() {
314
+ super.disconnectedCallback();
315
+ this.#mark(null);
316
+ this.#detach();
317
+ this.#resize?.disconnect();
318
+ this.#observed = null;
319
+ }
320
+ willUpdate(changed) {
321
+ if (changed.has("redaction")) {
322
+ this._keepValues = this.redaction.params === "all";
323
+ this._keepMessages = this.redaction.messages;
324
+ }
325
+ if (changed.has("router") && this.#attached !== this.router) {
326
+ this.#detach();
327
+ this._live = emptyModel();
328
+ this.#resetSelection();
329
+ if (this.router && this.isConnected) this.#attach(this.router);
330
+ }
331
+ this.#followGoneStates();
332
+ this.#forgetGoneViews();
333
+ this.#dropStrandedView();
334
+ this.#loadViews(changed);
335
+ this.#followMap(changed);
336
+ this.#syncTicker();
337
+ }
338
+ #syncTicker() {
339
+ const running = Boolean(this.#recorder) && !this._imported && (this._live.txs.some((tx) => !tx.result) || this._view === "timeline" && this.spans.some((span) => span.endTime === undefined));
340
+ if (running && !this.#ticker) this.#ticker = setInterval(() => this._now = performance.now(), 100);
341
+ if (!running && this.#ticker) {
342
+ clearInterval(this.#ticker);
343
+ this.#ticker = undefined;
344
+ }
345
+ }
346
+ #loadViews(changed) {
347
+ const retry = changed.has("_view") || changed.has("_mapViews");
348
+ const due = (shown, loaded, loading, failed) => shown && !loaded && !loading && (!failed || retry);
349
+ if (due(this._view === "map", Boolean(this._map), this.#mapLoading, this._mapFailed)) this.#loadMap();
350
+ if (due(this._view === "timeline", Boolean(this._timeline), this.#timelineLoading, this._timelineFailed)) this.#loadTimeline();
351
+ const views = this._view === "views" || this._view === "map" && this._mapViews && this.#holdsViews();
352
+ if (due(views, Boolean(this._viewMap), this.#viewsLoading, this._viewsFailed)) this.#loadViewMap();
353
+ }
354
+ #loadViewMap() {
355
+ this.#viewsLoading = true;
356
+ this._viewsFailed = false;
357
+ if (this._announcement === VIEWS_FAILED) this._announcement = "";
358
+ void this._importViews().then((views) => {
359
+ this._viewMap = views;
360
+ this.#viewsLoading = false;
361
+ this.#adopt(views.viewMapStyles);
362
+ this.requestUpdate();
363
+ }, () => {
364
+ this._viewsFailed = true;
365
+ this.#viewsLoading = false;
366
+ this._announcement = VIEWS_FAILED;
367
+ });
368
+ }
369
+ #loadMap() {
370
+ this.#mapLoading = true;
371
+ this._mapFailed = false;
372
+ if (this._announcement === MAP_FAILED) this._announcement = "";
373
+ void this._importMap().then((map) => {
374
+ this._map = map;
375
+ this.#mapLoading = false;
376
+ this.requestUpdate();
377
+ }, () => {
378
+ this._mapFailed = true;
379
+ this.#mapLoading = false;
380
+ this._announcement = MAP_FAILED;
381
+ });
382
+ }
383
+ #loadTimeline() {
384
+ this.#timelineLoading = true;
385
+ this._timelineFailed = false;
386
+ if (this._announcement === TIMELINE_FAILED) this._announcement = "";
387
+ void this._importTimeline().then((timeline) => {
388
+ this._timeline = timeline;
389
+ this.#timelineLoading = false;
390
+ this.#adopt(timeline.timelineStyles);
391
+ this.requestUpdate();
392
+ }, () => {
393
+ this._timelineFailed = true;
394
+ this.#timelineLoading = false;
395
+ this._announcement = TIMELINE_FAILED;
396
+ });
397
+ }
398
+ #adopt(styles) {
399
+ this.#adopted.add(styles);
400
+ adoptStyles(this.renderRoot, [...DevtoolsPanel.elementStyles, ...this.#adopted]);
401
+ }
402
+ #followMap(changed) {
403
+ const nested = this._view === "map" ? this._nested() : null;
404
+ const last = this.#layout;
405
+ const pan = this._mapPan;
406
+ this.#layout = nested;
407
+ if (!nested || !this._map) return;
408
+ if (pan && last && last !== nested) this._mapPan = changed.has("_mapZoom") ? this._map.zoomView(pan, last.placed, nested.placed, this._room(nested)) : this.#anchored(pan, last, nested);
409
+ if (this._moveFocus && this._focusState) this._reveal(nested, this._focusState);
410
+ }
411
+ #anchored(pan, last, nested) {
412
+ const name = this._focusState ?? this._selectedState ?? "";
413
+ const was = last.rects.get(name);
414
+ const now = nested.rects.get(name);
415
+ return was && now ? {
416
+ x: pan.x + was.x - now.x,
417
+ y: pan.y + was.y - now.y
418
+ } : pan;
419
+ }
420
+ update(changed) {
421
+ const focused = this.shadowRoot?.activeElement;
422
+ if (focused?.matches(".box > .head")) this._moveFocus = true;
423
+ const dropped = !focused && document.activeElement === document.body && this.#pathFocused?.isConnected === false;
424
+ if (!dropped) this.#pathFocused = focused?.closest(".vp") ? focused : null;
425
+ this.#before = this.#mapMoved() ? this.#measureMovers() : null;
426
+ super.update(changed);
427
+ }
428
+ #mapMoved() {
429
+ const nested = this._view === "map" ? this._nested() : null;
430
+ const geometry = this.#drawnGeometry(nested);
431
+ const direct = this.#direct;
432
+ const moved = geometry.length !== this.#geometry.length || geometry.some((part, index) => part !== this.#geometry[index]);
433
+ const drawn = this.#geometry.length > 0;
434
+ this.#direct = false;
435
+ this.#geometry = geometry;
436
+ this.#resized = Boolean(this.#step && nested && this.#step !== nested.metrics);
437
+ this.#step = nested?.metrics;
438
+ return moved && drawn && !direct && geometry.length > 0 && !matchMedia("(prefers-reduced-motion: reduce)").matches;
439
+ }
440
+ #drawnGeometry(nested) {
441
+ if (this._view !== "map") return [];
442
+ const view = nested && this._viewOf(nested);
443
+ return [
444
+ nested?.placed ?? this._layoutPref,
445
+ this._max,
446
+ view?.x,
447
+ view?.y
448
+ ];
449
+ }
450
+ get #movers() {
451
+ return [...this.renderRoot.querySelector(".map-scroll")?.querySelectorAll(MOVERS) ?? []];
452
+ }
453
+ #measureMovers() {
454
+ const room = this.renderRoot.querySelector(".map-scroll");
455
+ return new Map([...this.#movers.map((element) => [moverKey(element), element.getBoundingClientRect()]), ...room ? [[ROOM, room.getBoundingClientRect()]] : []]);
456
+ }
457
+ #roomShift(before) {
458
+ const was = before.get(ROOM);
459
+ const now = this.renderRoot.querySelector(".map-scroll")?.getBoundingClientRect();
460
+ return was && now ? {
461
+ x: now.x + now.width / 2 - was.x - was.width / 2,
462
+ y: now.y + now.height / 2 - was.y - was.height / 2
463
+ } : {
464
+ x: 0,
465
+ y: 0
466
+ };
467
+ }
468
+ #rescaled(root, outline, shift) {
469
+ const rescaling = this.#resized || root?.getAnimations().some((animation) => animation.id === RESCALE);
470
+ for (const element of this.renderRoot.querySelectorAll(".map-scroll *")) for (const animation of element.getAnimations()) if (animation.id === FLIP || animation.id === RESCALE) animation.cancel();
471
+ if (!rescaling || !root?.matches(".nested") || !outline?.width) return false;
472
+ if (!alike(outline, root.getBoundingClientRect())) return false;
473
+ rescale(root, outline, shift);
474
+ return true;
475
+ }
476
+ #flip(before) {
477
+ const movers = this.#movers;
478
+ const room = this.#roomShift(before);
479
+ if (this.#rescaled(movers[0], before.get(""), room)) return;
480
+ const rtl = getComputedStyle(this).direction === "rtl";
481
+ const edge = (rect) => rtl ? rect.right : rect.x;
482
+ const shifts = new Map();
483
+ const plans = movers.map((element) => {
484
+ const read = before.get(moverKey(element));
485
+ const now = element.getBoundingClientRect();
486
+ const was = read && new DOMRect(read.x + room.x, read.y + room.y, read.width, read.height);
487
+ const carried = shifts.get(element.parentElement?.closest(MOVERS) ?? element) ?? {
488
+ x: 0,
489
+ y: 0
490
+ };
491
+ const shift = was ? {
492
+ x: edge(was) - edge(now),
493
+ y: was.y - now.y
494
+ } : carried;
495
+ shifts.set(element, shift);
496
+ return {
497
+ element,
498
+ was: was ?? now,
499
+ now,
500
+ by: {
501
+ x: shift.x - carried.x,
502
+ y: shift.y - carried.y,
503
+ rtl
504
+ }
505
+ };
506
+ });
507
+ for (const { element, was, now, by } of plans) ease(element, was, now, by);
508
+ }
509
+ firstUpdated() {
510
+ if (this.isConnected) this.#pill?.showPopover();
511
+ }
512
+ updated() {
513
+ this.#observeMap();
514
+ this.#markPointed();
515
+ if (this._view === "views") this._viewMap?.measureViewMap(this);
516
+ this.#measureMap();
517
+ this.#placePopover();
518
+ this.#showTick();
519
+ if (this.#before) this.#flip(this.#before);
520
+ this.#before = null;
521
+ this.#keepPathFocus();
522
+ if (!this._moveFocus) return;
523
+ this._moveFocus = false;
524
+ this.renderRoot.querySelector("[role=\"treeitem\"][tabindex=\"0\"]")?.focus();
525
+ }
526
+ #keepPathFocus() {
527
+ if (!this.#pathFocused) return;
528
+ if (!this._pathShown()) {
529
+ this.#pathFocused = null;
530
+ return;
531
+ }
532
+ const stop = this.renderRoot.querySelector(".vp [tabindex=\"0\"]");
533
+ if (!stop) return;
534
+ this.#pathFocused = stop;
535
+ if (this.shadowRoot?.activeElement !== stop) stop.focus();
536
+ }
537
+ #observeMap() {
538
+ const scroller = this.renderRoot.querySelector(".map-scroll, .vm-main");
539
+ if (scroller === this.#observed) return;
540
+ this.#resize ??= new ResizeObserver(([entry]) => {
541
+ const width = Math.floor(entry.contentRect.width);
542
+ const height = Math.floor(entry.contentRect.height);
543
+ if (width !== this._mapSize.width || height !== this._mapSize.height) this._mapSize = {
544
+ width,
545
+ height
546
+ };
547
+ });
548
+ this.#resize.disconnect();
549
+ this.#observed = scroller;
550
+ if (scroller) this.#resize.observe(scroller);
551
+ }
552
+ #placePopover() {
553
+ const panel = this.#panel;
554
+ const popover = this.renderRoot.querySelector(".inspector-pane");
555
+ if (!panel || !popover || this._view !== "map" || this._max) return;
556
+ const origin = panel.getBoundingClientRect();
557
+ const place = this._inspect === "view" ? this.#viewPlace(popover.getBoundingClientRect(), origin) : this.#anchoredPlace(popover, origin);
558
+ if (!place) return;
559
+ panel.style.setProperty("--uird-pop-x", `${place.x}px`);
560
+ panel.style.setProperty("--uird-pop-y", `${place.y}px`);
561
+ }
562
+ #anchoredPlace(popover, origin) {
563
+ const root = this.renderRoot.querySelector(".nested");
564
+ const nested = root && this._nested();
565
+ const marked = [...this.renderRoot.querySelectorAll(".map-node.anchor, .brand.anchor")].at(-1);
566
+ const drawn = root?.getBoundingClientRect();
567
+ const at = drawn ? {
568
+ x: drawn.x - origin.x,
569
+ y: drawn.y - origin.y
570
+ } : {
571
+ x: 0,
572
+ y: 0
573
+ };
574
+ const inPanel = (rect) => ({
575
+ ...rect,
576
+ x: rect.x + at.x,
577
+ y: rect.y + at.y
578
+ });
579
+ const box = nested && this._map?.anchorRect(this, nested);
580
+ const anchor = box ? inPanel(box) : marked && rectOf(marked, origin);
581
+ if (!anchor) return undefined;
582
+ return this.#popoverPlace(anchor, popover.getBoundingClientRect(), origin, nested && box ? {
583
+ nested,
584
+ at
585
+ } : undefined);
586
+ }
587
+ #viewPlace(size, origin) {
588
+ const item = this.renderRoot.querySelector(".vp-chip[aria-pressed=\"true\"]");
589
+ if (!item) return undefined;
590
+ const anchor = rectOf(item, origin);
591
+ return placeBeside(anchor, size, popBounds(origin), [{
592
+ ...anchor,
593
+ weight: 1e3
594
+ }, ...this.#chips(origin)]);
595
+ }
596
+ #chips(origin) {
597
+ return [...this.renderRoot.querySelectorAll(".vp-chip")].map((chip) => ({
598
+ ...rectOf(chip, origin),
599
+ weight: 1
600
+ }));
601
+ }
602
+ #besidePlace(size, origin) {
603
+ const rtl = getComputedStyle(this).direction === "rtl";
604
+ return {
605
+ x: rtl ? MARGIN : origin.width - MARGIN - size.width,
606
+ y: 38
607
+ };
608
+ }
609
+ #popoverPlace(anchor, size, origin, map) {
610
+ const bounds = popBounds(origin);
611
+ if (!map) return placeBeside(anchor, size, bounds);
612
+ if (this._beside(map.nested)) return this.#besidePlace(size, origin);
613
+ const clear = this._map?.keepClear(this, map.nested) ?? [];
614
+ return placeBeside(anchor, size, bounds, [
615
+ {
616
+ ...anchor,
617
+ weight: 1e3
618
+ },
619
+ ...clear.map((rect) => ({
620
+ ...rect,
621
+ x: rect.x + map.at.x,
622
+ y: rect.y + map.at.y
623
+ })),
624
+ ...this.#chips(origin)
625
+ ]);
626
+ }
627
+ #showTick() {
628
+ const ticks = this.renderRoot.querySelector(".ticks");
629
+ const tick = ticks?.querySelector(".tick.on");
630
+ if (!ticks) return;
631
+ if (!tick) {
632
+ const id = this._model.txs.at(-1)?.id;
633
+ const seen = this.#newestTick;
634
+ if (!ticks.clientWidth || seen?.ticks === ticks && seen.id === id) return;
635
+ this.#newestTick = {
636
+ ticks,
637
+ id
638
+ };
639
+ ticks.scrollLeft = ticks.scrollWidth * (ticks.matches(":dir(rtl)") ? -1 : 1);
640
+ return;
641
+ }
642
+ const box = ticks.getBoundingClientRect();
643
+ const rect = tick.getBoundingClientRect();
644
+ if (rect.left < box.left) ticks.scrollLeft -= box.left - rect.left;
645
+ else if (rect.right > box.right) ticks.scrollLeft += rect.right - box.right;
646
+ }
647
+ #measureMap() {
648
+ let changed = false;
649
+ for (const node of this.renderRoot.querySelectorAll(".map-node")) {
650
+ const name = node.dataset.name;
651
+ const width = Math.ceil(node.getBoundingClientRect().width);
652
+ if (width && this._mapWidths.get(name) !== width) {
653
+ this._mapWidths.set(name, width);
654
+ changed = true;
655
+ }
656
+ }
657
+ if (changed) this.requestUpdate();
658
+ }
659
+ get #pill() {
660
+ return this.renderRoot.querySelector(".pill");
661
+ }
662
+ get #panel() {
663
+ return this.renderRoot.querySelector(".panel");
664
+ }
665
+ #followGoneStates() {
666
+ const { states } = this._model;
667
+ if (states === this.#statesSeen) return;
668
+ this.#statesSeen = states;
669
+ const names = new Set(states.map((state) => state.name));
670
+ const follow = (name) => {
671
+ if (name === null || names.has(name)) return name;
672
+ const loaded = bareName(name);
673
+ return names.has(loaded) ? loaded : null;
674
+ };
675
+ this._focusState = follow(this._focusState);
676
+ this.#pathFrom = follow(this.#pathFrom);
677
+ const selected = follow(this._selectedState);
678
+ if (selected === this._selectedState) return;
679
+ this._selectedState = selected;
680
+ if (selected === null && this._inspect === "state") this._inspect = "none";
681
+ }
682
+ #resetSelection() {
683
+ this._selectedTx = null;
684
+ this._previewTx = null;
685
+ this._selectedState = null;
686
+ this._focusState = null;
687
+ this._timelineFocus = null;
688
+ this._timelineSelected = null;
689
+ this._viewFocus = null;
690
+ this._viewSelected = null;
691
+ if (this._inspect !== "router") this._inspect = "none";
692
+ }
693
+ #attach(router) {
694
+ this.#attached = router;
695
+ const recorder = record(router, {
696
+ limit: this.history * 40,
697
+ timeResolves: this.timeResolves
698
+ });
699
+ this.#recorder = recorder;
700
+ this._live = fold(recorder.session({ params: "all" }).events);
701
+ this.#unsubscribe = recorder.subscribe((event) => {
702
+ const next = apply(this._live, event);
703
+ this._live = next.txs.length > this.history ? {
704
+ ...next,
705
+ txs: next.txs.slice(-this.history)
706
+ } : next;
707
+ if (event.type === "result" || event.type === "invalid") this.#announce(event.type === "result" ? event.id : -event.seq);
708
+ });
709
+ }
710
+ #detach() {
711
+ this.#unsubscribe?.();
712
+ this.#recorder?.stop();
713
+ this.#recorder = undefined;
714
+ this.#attached = undefined;
715
+ this.#unsubscribe = undefined;
716
+ clearInterval(this.#ticker);
717
+ this.#ticker = undefined;
718
+ }
719
+ _tx(id) {
720
+ return id == null ? undefined : this._model.txs.find((tx) => tx.id === id);
721
+ }
722
+ _origin(tx) {
723
+ return originOf(this._model.txs, tx);
724
+ }
725
+ _duration(tx) {
726
+ return durationOf(this._model.txs, tx, this._clock);
727
+ }
728
+ #announce(id) {
729
+ if (this._imported) return;
730
+ const tx = this._live.txs.find((t) => t.id === id);
731
+ const outcome = tx?.result?.outcome;
732
+ if (!tx || !outcome || ![
733
+ "success",
734
+ "error",
735
+ "invalid"
736
+ ].includes(outcome)) return;
737
+ this._announcement = outcome === "success" ? `Transition ${tx.id} succeeded: ${tx.to}, ${ms(this._duration(tx))}` : `${tx.id < 0 ? "Target" : `Transition ${tx.id}`} failed: ${tx.to}. ${resultLine(tx)}`;
738
+ }
739
+ #open() {
740
+ this.#pill?.hidePopover();
741
+ this.#panel?.showPopover();
742
+ this.#markPointed();
743
+ void this.updateComplete.then(() => this.renderRoot.querySelector(".close")?.focus());
744
+ }
745
+ #close() {
746
+ this.#panel?.hidePopover();
747
+ this.#markPointed();
748
+ this.#pill?.showPopover();
749
+ this.#pill?.focus();
750
+ }
751
+ #dropView() {
752
+ if (this._inspect === "view") this._viewSelected = null;
753
+ }
754
+ _selectTx(id) {
755
+ this.#dropView();
756
+ this._selectedTx = id;
757
+ this._inspect = id === null ? "none" : "tx";
758
+ }
759
+ _selectState(name, keep = false) {
760
+ this.#dropView();
761
+ this._selectedState = keep || this._selectedState !== name ? name : null;
762
+ this._focusState = name;
763
+ this._inspect = this._selectedState ? "state" : "none";
764
+ }
765
+ _canGo(state) {
766
+ return !this._imported && !state.abstract && (state.future || state.params.every((p) => p.optional)) && !!this.router;
767
+ }
768
+ _go(state) {
769
+ if (this._canGo(state)) void this.router?.stateService.go(bareName(state.name)).catch(() => {});
770
+ }
771
+ _keepText(event) {
772
+ if (event.detail > 1) event.preventDefault();
773
+ }
774
+ _goState(name) {
775
+ const state = this._model.states.find((s) => s.name === name);
776
+ this._selectState(name, true);
777
+ if (state) this._go(state);
778
+ }
779
+ _revealState(name) {
780
+ const hidden = new Set(ancestorsOf(this._model.states, name));
781
+ this.#dropView();
782
+ this._selectedState = name;
783
+ this._focusState = name;
784
+ this._inspect = "state";
785
+ this._collapsed = new Set([...this._collapsed].filter((state) => !hidden.has(state)));
786
+ this._mapOpen = new Map([...this._mapOpen].filter(([state]) => !hidden.has(state)));
787
+ this._moveFocus = true;
788
+ }
789
+ _selectView(id) {
790
+ const map = this._view === "map";
791
+ const again = id === this._viewSelected && (!map || this._inspect === "view");
792
+ this._viewSelected = again ? null : id;
793
+ if (id !== null) this._viewFocus = id;
794
+ if (!map) return;
795
+ if (this._inspect !== "view") this.#pathFrom = this._pathState();
796
+ this._selectedState = null;
797
+ this._selectedTx = null;
798
+ this._inspect = this._viewSelected === null ? "none" : "view";
799
+ }
800
+ _pointView(id) {
801
+ this.#pointedView = id;
802
+ this.#markPointed();
803
+ }
804
+ _showState(name) {
805
+ if (this._view !== "map") this._view = "outline";
806
+ this._revealState(name);
807
+ }
808
+ #markPointed() {
809
+ const tab = this._view === "views";
810
+ const beside = this._view === "map" && this._pathShown();
811
+ const shown = (tab || beside) && !this._imported && Boolean(this.#panel?.matches(":popover-open"));
812
+ const chosen = tab || this._inspect === "view" ? this._viewSelected : null;
813
+ const id = shown ? this.#pointedView ?? chosen : null;
814
+ const view = this.#viewOf(id);
815
+ if (view !== this.#markedView) this.#mark(view);
816
+ }
817
+ #viewOf(id) {
818
+ return this._model.views?.views.find((view) => view.id === id) ?? null;
819
+ }
820
+ #mark(view) {
821
+ this.#markedView = view;
822
+ this.viewLocator?.highlight(view);
823
+ }
824
+ #forgetGoneViews() {
825
+ if (this.#viewOf(this._viewSelected) === null) {
826
+ this._viewSelected = null;
827
+ if (this._inspect === "view") this._inspect = "none";
828
+ }
829
+ if (this.#viewOf(this.#pointedView) === null) this.#pointedView = null;
830
+ }
831
+ #dropStrandedView() {
832
+ if (this._inspect !== "view") return;
833
+ if (this._view === "map" && this._pathShown()) return;
834
+ if (this._view !== "views") this._viewSelected = null;
835
+ this._inspect = "none";
836
+ }
837
+ _linkedStates() {
838
+ const view = this._inspect === "view" && this.#viewOf(this._viewSelected);
839
+ if (!view) return new Map();
840
+ const ties = [[view.context, "created the selected view"], [view.fill?.state ?? "", "fills the selected view"]];
841
+ return new Map(ties.filter(([name]) => name));
842
+ }
843
+ _clearSelection() {
844
+ this.#dropView();
845
+ this._selectedState = null;
846
+ this._selectedTx = null;
847
+ this._inspect = "none";
848
+ }
849
+ _dismiss() {
850
+ const from = this.#selectionSources();
851
+ const held = this.shadowRoot?.activeElement?.closest(".inspector-pane, .router-pane");
852
+ this._clearSelection();
853
+ if (!held) return;
854
+ void this.updateComplete.then(() => from.find((element) => element?.isConnected && element.checkVisibility())?.focus());
855
+ }
856
+ #selectionSources() {
857
+ const find = (selector) => this.renderRoot.querySelector(selector);
858
+ const tx = this._inspect === "tx";
859
+ return [
860
+ this._inspect === "router" ? find(".brand") : null,
861
+ tx ? find(".ticks") : null,
862
+ tx ? find(".log .tx.selected > .line") : null,
863
+ this._inspect === "state" ? find(".map-node.selected") : null,
864
+ this._inspect === "view" ? find(".vp-chip[aria-pressed=\"true\"]") : null,
865
+ find("[role=\"treeitem\"][tabindex=\"0\"]"),
866
+ find(".map-node"),
867
+ find(".tabs [aria-selected=\"true\"]")
868
+ ];
869
+ }
870
+ #onKey(event) {
871
+ const target = event.target;
872
+ if (event.key !== "Escape" || event.defaultPrevented || this._inspect === "none" || target.closest("input, textarea, select, [contenteditable]")) return;
873
+ event.preventDefault();
874
+ this._dismiss();
875
+ }
876
+ #onMapClick(event) {
877
+ const press = this.#press;
878
+ const target = event.target;
879
+ this.#press = undefined;
880
+ if (this._inspect === "none" || !target.matches(".map-scroll, .nested, .map") || press && Math.hypot(event.clientX - press.x, event.clientY - press.y) >= DRAG) return;
881
+ this._dismiss();
882
+ }
883
+ get _anchorState() {
884
+ if (this._inspect === "state") return this._selectedState;
885
+ return this._inspect === "tx" ? this._tx(this._selectedTx)?.to ?? null : null;
886
+ }
887
+ _beside(nested) {
888
+ return !this._max && this._mapSize.width - nested.placed.width >= ASIDE;
889
+ }
890
+ _reserve(nested) {
891
+ if (!this._beside(nested)) return 0;
892
+ const spare = this._mapSize.width - nested.placed.width;
893
+ return Math.max(0, Math.min(ASIDE, ASIDE * 2 - spare));
894
+ }
895
+ _room(nested) {
896
+ return {
897
+ ...this._mapSize,
898
+ reserve: this._reserve(nested),
899
+ slack: this._max || this._beside(nested) ? 0 : ASIDE,
900
+ foot: this._map?.MINI_FOOT ?? 0,
901
+ rtl: nested.rtl
902
+ };
903
+ }
904
+ _viewOf(nested) {
905
+ const map = this._map;
906
+ const room = this._room(nested);
907
+ const size = nested.placed;
908
+ if (!map) return {
909
+ x: 0,
910
+ y: 0
911
+ };
912
+ if (this._mapPan) return map.clampView(this._mapPan, size, room);
913
+ const current = nested.rects.get(this._model.current.name);
914
+ return current && map.overflows(size, room) ? map.centreView(current, size, room) : map.fitView(size, room);
915
+ }
916
+ _pans(nested) {
917
+ return Boolean(this._map?.overflows(nested.placed, this._mapSize));
918
+ }
919
+ _panTo(nested, view, eased) {
920
+ const now = this._viewOf(nested);
921
+ const next = this._map?.clampView(view, nested.placed, this._room(nested)) ?? now;
922
+ if (next.x === now.x && next.y === now.y) return false;
923
+ this.#direct = !eased;
924
+ this._mapPan = next;
925
+ return true;
926
+ }
927
+ _reveal(nested, name) {
928
+ const rect = nested.rects.get(name);
929
+ if (!rect || !this._map) return;
930
+ const view = this._map.revealView(this._viewOf(nested), rect, nested.placed, this._room(nested));
931
+ this._panTo(nested, view, true);
932
+ }
933
+ _zoomBy(nested, steps) {
934
+ const last = (this._map?.ZOOMS.length ?? 1) - 1;
935
+ const step = Math.min(last, Math.max(0, nested.step + steps));
936
+ if (step !== nested.step) this._mapZoom = step;
937
+ }
938
+ _fit() {
939
+ this._mapPan = null;
940
+ this._mapZoom = null;
941
+ }
942
+ _depthClass(name) {
943
+ return depthClass(ancestorsOf(this._model.states, name).length + 1);
944
+ }
945
+ get #mode() {
946
+ if (this._focusTx) return "tx";
947
+ return this._inspect === "state" ? "state" : "rest";
948
+ }
949
+ _nested() {
950
+ if (!this._map || this._view !== "map" || this._layoutPref !== "nested" || this._mapSize.width < NESTED_MIN_WIDTH) return null;
951
+ return this._map.layoutNested(this);
952
+ }
953
+ _pathShown() {
954
+ return this._view === "map" && this._mapViews && Boolean(this._viewMap) && this.#holdsViews();
955
+ }
956
+ _pathState() {
957
+ if (this._inspect === "state" && this._selectedState !== null) return this._selectedState;
958
+ if (this._inspect === "view" && this.#pathFrom !== null) return this.#pathFrom;
959
+ return this._model.current.name;
960
+ }
961
+ #chooseLayout(layout) {
962
+ this._layoutPref = layout;
963
+ storeLayout(layout);
964
+ }
965
+ #chooseViews(shown) {
966
+ this._mapViews = shown;
967
+ storeViews(shown);
968
+ }
969
+ session(redaction) {
970
+ const session = this._imported?.session ?? this.#liveSession();
971
+ return session && redactSession(session, redactionOf({
972
+ ...this.redaction,
973
+ ...redaction
974
+ }));
975
+ }
976
+ #liveSession() {
977
+ const session = this.#recorder?.session({ params: "all" });
978
+ if (!session || !this.#spans.size) return session;
979
+ const spans = spansDuring(this.spans, fold(session.events).txs, session.timeOrigin, session.t);
980
+ return spans.length ? {
981
+ ...session,
982
+ spans
983
+ } : session;
984
+ }
985
+ importSession(session) {
986
+ if (session.v !== SCHEMA_VERSION) throw new Error(`Unsupported session version ${String(session.v)}; expected ${String(SCHEMA_VERSION)}`);
987
+ this._imported = {
988
+ session,
989
+ model: fold(session.events)
990
+ };
991
+ this.#resetSelection();
992
+ this._announcement = `Imported session ${session.routerId}, ${this._imported.model.txs.length} transitions. Live updates paused.`;
993
+ }
994
+ _sessionFacts() {
995
+ const imported = this._imported?.session;
996
+ if (imported) return {
997
+ routerId: imported.routerId,
998
+ events: imported.events.filter((event) => !SNAPSHOTS.has(event.type)).length,
999
+ dropped: imported.dropped
1000
+ };
1001
+ const recorder = this.#recorder;
1002
+ return {
1003
+ routerId: recorder?.routerId ?? "",
1004
+ events: recorder?.events.length ?? 0,
1005
+ dropped: recorder?.dropped ?? 0
1006
+ };
1007
+ }
1008
+ #goLive() {
1009
+ this._imported = null;
1010
+ this._notice = null;
1011
+ this.#resetSelection();
1012
+ this._announcement = "Showing the live router.";
1013
+ }
1014
+ _exportSession() {
1015
+ const configured = this.redaction.params;
1016
+ return this.session({
1017
+ params: this._keepValues ? "all" : configured === "all" ? [] : configured,
1018
+ messages: this._keepMessages
1019
+ });
1020
+ }
1021
+ #export() {
1022
+ const session = this._exportSession();
1023
+ if (!session) return;
1024
+ const blob = new Blob([JSON.stringify(session, null, 1)], { type: "application/json" });
1025
+ const link = document.createElement("a");
1026
+ link.href = URL.createObjectURL(blob);
1027
+ link.download = `ui-router-session-${session.routerId}-${new Date().toISOString().replace(/[:.]/g, "-")}.json`;
1028
+ link.click();
1029
+ setTimeout(() => URL.revokeObjectURL(link.href));
1030
+ }
1031
+ #fail(text) {
1032
+ this._notice = {
1033
+ text,
1034
+ fault: true
1035
+ };
1036
+ this._announcement = text;
1037
+ }
1038
+ async #readFile(file) {
1039
+ if (!file) return;
1040
+ this._notice = null;
1041
+ let json;
1042
+ try {
1043
+ json = JSON.parse(await file.text());
1044
+ } catch {
1045
+ this.#fail(`Import failed: ${file.name} is not JSON.`);
1046
+ return;
1047
+ }
1048
+ let reader;
1049
+ try {
1050
+ reader = await this._importReader();
1051
+ } catch {
1052
+ this.#fail("Import failed: the session reader did not load. Try again.");
1053
+ return;
1054
+ }
1055
+ const read = reader.readSession(json);
1056
+ if (!read.ok) {
1057
+ this.#fail(`Import failed: ${read.error}`);
1058
+ return;
1059
+ }
1060
+ this.importSession(read.session);
1061
+ const skipped = [...read.skipped ? [`${read.skipped} ${read.skipped === 1 ? "event" : "events"} of a kind this version does not read`] : [], ...read.skippedSpans ? [`${read.skippedSpans} ${read.skippedSpans === 1 ? "span" : "spans"} that did not read`] : []];
1062
+ if (skipped.length) this._notice = {
1063
+ text: `${skipped.join(" and ")} skipped`,
1064
+ fault: false
1065
+ };
1066
+ }
1067
+ #onDrop(event) {
1068
+ event.preventDefault();
1069
+ void this.#readFile(event.dataTransfer?.files[0]);
1070
+ }
1071
+ get _runningTx() {
1072
+ return this._model.txs.findLast((tx) => !tx.result);
1073
+ }
1074
+ get _focusTx() {
1075
+ return this._tx(this._previewTx) ?? this._tx(this._selectedTx) ?? this._runningTx;
1076
+ }
1077
+ #erroredState(tx) {
1078
+ if (tx.result?.outcome !== "error") return null;
1079
+ return tx.resolves.find((r) => !r.ok)?.state ?? tx.to;
1080
+ }
1081
+ _role(state) {
1082
+ const tx = this._focusTx;
1083
+ if (tx) {
1084
+ if (this.#erroredState(tx) === state.name) return "errored";
1085
+ if (tx.entering.includes(state.name)) return "entering";
1086
+ if (tx.exiting.includes(state.name)) return "exiting";
1087
+ if (tx.retained.includes(state.name)) return "retained";
1088
+ }
1089
+ const { states, current } = this._model;
1090
+ if (state.name === current.name) return "current";
1091
+ if (ancestorsOf(states, current.name).includes(state.name)) return "ancestor";
1092
+ return state.future ? "future" : "inactive";
1093
+ }
1094
+ _children() {
1095
+ const known = new Set(this._model.states.map((s) => s.name));
1096
+ const children = new Map();
1097
+ for (const state of this._model.states) {
1098
+ const parent = state.parent && known.has(state.parent) ? state.parent : null;
1099
+ children.set(parent, [...children.get(parent) ?? [], state]);
1100
+ }
1101
+ return children;
1102
+ }
1103
+ _rows() {
1104
+ const children = this._children();
1105
+ const rows = [];
1106
+ const walk = (parent, depth) => {
1107
+ const kids = children.get(parent) ?? [];
1108
+ kids.forEach((state, index) => {
1109
+ const hasChildren = (children.get(state.name) ?? []).length > 0;
1110
+ rows.push({
1111
+ state,
1112
+ depth,
1113
+ hasChildren,
1114
+ setsize: kids.length,
1115
+ posinset: index + 1
1116
+ });
1117
+ if (hasChildren && !this._collapsed.has(state.name)) walk(state.name, depth + 1);
1118
+ });
1119
+ };
1120
+ walk(null, 1);
1121
+ return rows;
1122
+ }
1123
+ _paramBase(tx) {
1124
+ const first = (this._origin(tx) ?? tx).id;
1125
+ return this._model.txs.findLast((t) => t.id >= 0 && t.id < first && t.result?.outcome === "success")?.toParams ?? tx.fromParams;
1126
+ }
1127
+ render() {
1128
+ const inspected = this._inspect === "tx" ? this._tx(this._selectedTx) : undefined;
1129
+ const imported = Boolean(this._imported);
1130
+ return html`
1131
+ ${this.#renderPill()}
1132
+ <div
1133
+ class="panel"
1134
+ popover="manual"
1135
+ role="region"
1136
+ aria-label="Router devtools"
1137
+ data-tab=${this._tab}
1138
+ data-view=${this._view}
1139
+ data-inspect=${this._inspect}
1140
+ data-mode=${this.#mode}
1141
+ ?data-max=${this._max}
1142
+ ?data-imported=${imported}
1143
+ @dragover=${(e) => e.preventDefault()}
1144
+ @drop=${this.#onDrop}
1145
+ @keydown=${this.#onKey}
1146
+ >
1147
+ ${this.#renderTitle()}
1148
+ <div class="body">
1149
+ <section
1150
+ class="pane tree-pane"
1151
+ id="pane-tree"
1152
+ role="tabpanel"
1153
+ aria-labelledby="h-states"
1154
+ >
1155
+ ${this.#sectionHead("1", HEADINGS[this._view], "h-states")}
1156
+ <div class="pane-switch">${this.#renderSwitch()}</div>
1157
+ ${this.#renderStates()}
1158
+ </section>
1159
+ ${this._view === "outline" ? nothing : renderScrubber(this)}
1160
+ <section
1161
+ class="pane log-pane"
1162
+ id="pane-log"
1163
+ role="tabpanel"
1164
+ aria-labelledby="h-log"
1165
+ >
1166
+ ${this.#sectionHead("2", "Transitions", "h-log")}
1167
+ <div class="scroll">${renderLog(this)}</div>
1168
+ </section>
1169
+ <section class="pane inspector-pane" aria-labelledby="h-insp">
1170
+ ${this.#sectionHead("3", "Inspector", "h-insp", inspected ? seq(inspected.id) || "Invalid target" : this.#inspectorAside())}${this._inspect === "none" ? nothing : html`<button
1171
+ class="icon dismiss"
1172
+ aria-label="Close inspector"
1173
+ title="Close (Esc)"
1174
+ @click=${() => this._dismiss()}
1175
+ >
1176
+ ${closeGlyph}
1177
+ </button>`}
1178
+ <div
1179
+ class="scroll"
1180
+ tabindex="0"
1181
+ role="group"
1182
+ aria-labelledby="h-insp"
1183
+ >
1184
+ ${this.#renderInspector(inspected)}
1185
+ </div>
1186
+ </section>
1187
+ <section
1188
+ class="pane router-pane"
1189
+ id="pane-router"
1190
+ role="tabpanel"
1191
+ aria-labelledby="h-router"
1192
+ >
1193
+ ${this.#sectionHead("3", "Router", "h-router")}
1194
+ <div
1195
+ class="scroll"
1196
+ tabindex="0"
1197
+ role="group"
1198
+ aria-labelledby="h-router"
1199
+ >
1200
+ ${renderRouterCard(this, true)}
1201
+ </div>
1202
+ </section>
1203
+ </div>
1204
+ </div>
1205
+ <input
1206
+ class="file visually-hidden"
1207
+ type="file"
1208
+ accept=".json,application/json"
1209
+ tabindex="-1"
1210
+ aria-hidden="true"
1211
+ @change=${(e) => {
1212
+ const input = e.currentTarget;
1213
+ void this.#readFile(input.files?.[0]).then(() => input.value = "");
1214
+ }}
1215
+ />
1216
+ <div class="visually-hidden" role="status" aria-live="polite">
1217
+ ${this._announcement}
1218
+ </div>
1219
+ `;
1220
+ }
1221
+ #renderStates() {
1222
+ if (this._view === "outline") return html`<div class="scroll outline-scroll">
1223
+ ${renderOutline(this)}
1224
+ </div>`;
1225
+ if (this._view === "timeline") return html`<div class="scroll timeline-scroll">
1226
+ ${this._timeline ? this._timeline.renderTimeline(this) : this._timelineFailed ? html`<p class="empty">${TIMELINE_FAILED}</p>` : nothing}
1227
+ </div>`;
1228
+ if (this._view === "views") return html`<div class="scroll views-scroll">
1229
+ ${this._viewMap ? this._viewMap.renderViewMap(this) : this._viewsFailed ? html`<p class="empty">${VIEWS_FAILED}</p>` : nothing}
1230
+ </div>`;
1231
+ const nested = this._nested();
1232
+ const map = this._map;
1233
+ return html`<div
1234
+ class="scroll map-scroll"
1235
+ ?data-pan=${nested && this._pans(nested)}
1236
+ @pointerdown=${(event) => {
1237
+ this.#press = {
1238
+ x: event.clientX,
1239
+ y: event.clientY
1240
+ };
1241
+ map?.startPan(this, event);
1242
+ }}
1243
+ @click=${this.#onMapClick}
1244
+ @wheel=${this.#onWheel}
1245
+ >
1246
+ ${map ? nested ? map.renderNested(this, nested) : map.renderMap(this) : this.#mapNotice()}
1247
+ </div>
1248
+ ${this._pathShown() ? this._viewMap.renderPath(this) : nothing}`;
1249
+ }
1250
+ #mapNotice() {
1251
+ return this._mapFailed ? html`<p class="empty">${MAP_FAILED}</p>` : nothing;
1252
+ }
1253
+ #renderSwitch() {
1254
+ const map = this._view === "map";
1255
+ const layout = this._nested();
1256
+ const nested = Boolean(layout);
1257
+ const narrow = this._mapSize.width < NESTED_MIN_WIDTH;
1258
+ const why = `Nested boxes need ${NESTED_MIN_WIDTH}px of width`;
1259
+ return html`<div class="switch" role="group" aria-label="State view">
1260
+ ${[
1261
+ "outline",
1262
+ "map",
1263
+ "timeline",
1264
+ "views"
1265
+ ].map((view) => html`<button
1266
+ aria-pressed=${this._view === view}
1267
+ @click=${() => this._view = view}
1268
+ >
1269
+ ${view}
1270
+ </button>`)}
1271
+ </div>
1272
+ ${map ? html`<div class="switch" role="group" aria-label="Map layout">
1273
+ <button
1274
+ aria-pressed=${nested}
1275
+ ?disabled=${narrow}
1276
+ title=${narrow ? why : "Child states inside their parent"}
1277
+ @click=${() => this.#chooseLayout("nested")}
1278
+ >
1279
+ Nested
1280
+ </button>
1281
+ <button
1282
+ aria-pressed=${!nested}
1283
+ title="Node-link tree"
1284
+ @click=${() => this.#chooseLayout("tree")}
1285
+ >
1286
+ Tree
1287
+ </button>
1288
+ </div>
1289
+ ${layout ? this.#renderViewTools(layout) : nothing}
1290
+ ${this.#holdsViews() ? this.#renderViewsToggle() : nothing}` : nothing}`;
1291
+ }
1292
+ #renderViewsToggle() {
1293
+ const failed = this._mapViews && this._viewsFailed;
1294
+ return html`<div class="switch" role="group" aria-label="Under the Map">
1295
+ <button
1296
+ aria-pressed=${this._mapViews && !failed}
1297
+ ?disabled=${failed}
1298
+ title=${failed ? VIEWS_FAILED : this._mapViews ? "Hide the view path under the Map" : "Show the view path under the Map"}
1299
+ @click=${() => this.#chooseViews(!this._mapViews)}
1300
+ >
1301
+ View path
1302
+ </button>
1303
+ </div>`;
1304
+ }
1305
+ #holdsViews() {
1306
+ return Boolean(this._model.views?.views.length);
1307
+ }
1308
+ #renderViewTools(layout) {
1309
+ const last = (this._map?.ZOOMS.length ?? 1) - 1;
1310
+ const fitted = this._mapPan === null && this._mapZoom === null;
1311
+ return html`<div
1312
+ class="switch view-tools"
1313
+ role="group"
1314
+ aria-label="Map view"
1315
+ >
1316
+ <button
1317
+ class="step"
1318
+ aria-label="Zoom out"
1319
+ title="Smaller type (−)"
1320
+ ?disabled=${layout.step <= 0}
1321
+ @click=${() => this._zoomBy(layout, -1)}
1322
+ >
1323
+ −
1324
+ </button>
1325
+ <button
1326
+ class="step"
1327
+ aria-label="Zoom in"
1328
+ title="Larger type (+)"
1329
+ ?disabled=${layout.step >= last}
1330
+ @click=${() => this._zoomBy(layout, 1)}
1331
+ >
1332
+ +
1333
+ </button>
1334
+ <button
1335
+ title="Fit the map to the panel (0)"
1336
+ ?disabled=${fitted}
1337
+ @click=${() => this._fit()}
1338
+ >
1339
+ Fit
1340
+ </button>
1341
+ </div>`;
1342
+ }
1343
+ #inspectorAside() {
1344
+ if (this._inspect === "state") return undefined;
1345
+ if (this._inspect === "view") return "View";
1346
+ return this._inspect === "none" || this._inspect === "router" ? "Router" : undefined;
1347
+ }
1348
+ #renderInspector(inspected) {
1349
+ if (inspected) return renderTxInspector(this, inspected);
1350
+ if (this._inspect === "state") return renderStateInspector(this);
1351
+ if (this._inspect === "view") return this._viewMap.renderViewInspector(this);
1352
+ return renderRouterCard(this);
1353
+ }
1354
+ #sectionHead(n, title, id, aside) {
1355
+ return html`<h2 class="section" id=${id}>
1356
+ <span class="num">${n}</span
1357
+ ><span class="title">${title}</span
1358
+ >${aside ? html`<span class="aside">${aside}</span>` : nothing}
1359
+ </h2>`;
1360
+ }
1361
+ #summary() {
1362
+ const running = this._runningTx;
1363
+ const last = this._model.txs.findLast((tx) => tx.result?.outcome !== "ignored");
1364
+ const status = running ? "running" : last?.result?.outcome ?? "success";
1365
+ const tx = running ?? last;
1366
+ const name = running?.to ?? (last && last.result?.outcome !== "success" ? last.to : this._model.current.name);
1367
+ return {
1368
+ status,
1369
+ name: name || "(root)",
1370
+ took: tx && tx.id >= 0 ? took(this._duration(tx)) : nothing
1371
+ };
1372
+ }
1373
+ #renderPill() {
1374
+ const { status, name, took } = this.#summary();
1375
+ return html`<button
1376
+ class="pill status-${status}"
1377
+ popover="manual"
1378
+ @click=${this.#open}
1379
+ >
1380
+ ${statusGlyph(status)}<span class="visually-hidden"
1381
+ >Router ${statusLabel[status]}:</span
1382
+ ><span class="pill-name">${elide(name)}</span
1383
+ >${took === nothing ? nothing : html`<span class="num">${took}</span>`}${this._imported ? html`<span class="tag">Imported</span>` : nothing}
1384
+ </button>`;
1385
+ }
1386
+ #toggleRouter() {
1387
+ this.#dropView();
1388
+ this._inspect = this._inspect === "router" ? "none" : "router";
1389
+ this._selectedTx = null;
1390
+ this._selectedState = null;
1391
+ }
1392
+ #showTab(tab) {
1393
+ if (tab === "router") {
1394
+ this._inspect = "router";
1395
+ return;
1396
+ }
1397
+ this._tab = tab;
1398
+ if (this._inspect === "router") this._inspect = "none";
1399
+ }
1400
+ #renderTabs() {
1401
+ const router = this._inspect === "router";
1402
+ const tabs = [
1403
+ [
1404
+ "tree",
1405
+ "1",
1406
+ "States",
1407
+ "pane-tree",
1408
+ !router && this._tab === "tree"
1409
+ ],
1410
+ [
1411
+ "log",
1412
+ "2",
1413
+ "Transitions",
1414
+ "pane-log",
1415
+ !router && this._tab === "log"
1416
+ ],
1417
+ [
1418
+ "router",
1419
+ "3",
1420
+ "Router",
1421
+ "pane-router",
1422
+ router
1423
+ ]
1424
+ ];
1425
+ return html`<div class="tabs" role="tablist" aria-label="Devtools views">
1426
+ ${tabs.map(([tab, n, label, id, selected]) => html`<button
1427
+ role="tab"
1428
+ aria-selected=${selected}
1429
+ aria-controls=${id}
1430
+ @click=${() => this.#showTab(tab)}
1431
+ >
1432
+ <span class="num">${n}</span><span class="label">${label}</span>
1433
+ </button>`)}
1434
+ </div>`;
1435
+ }
1436
+ _exportToggles() {
1437
+ return html`<div class="switch" role="group" aria-label="Export keeps">
1438
+ <button
1439
+ aria-pressed=${this._keepValues}
1440
+ title=${this._keepValues ? "Export keeps param values" : "Export redacts param values; keys stay"}
1441
+ @click=${() => this._keepValues = !this._keepValues}
1442
+ >
1443
+ Param values
1444
+ </button>
1445
+ <button
1446
+ aria-pressed=${this._keepMessages}
1447
+ title=${this._keepMessages ? "Export keeps error messages" : "Export drops error messages"}
1448
+ @click=${() => this._keepMessages = !this._keepMessages}
1449
+ >
1450
+ Messages
1451
+ </button>
1452
+ </div>`;
1453
+ }
1454
+ _sessionButtons() {
1455
+ return html`<button
1456
+ @click=${this.#export}
1457
+ aria-label="Export session as JSON"
1458
+ >
1459
+ Export</button
1460
+ >${this._imported ? html`<button
1461
+ @click=${this.#goLive}
1462
+ aria-label="Live: return to the live router"
1463
+ >
1464
+ Live
1465
+ </button>` : html`<button
1466
+ @click=${() => this.renderRoot.querySelector(".file")?.click()}
1467
+ aria-label="Import session from JSON"
1468
+ >
1469
+ Import
1470
+ </button>`}`;
1471
+ }
1472
+ #renderTitle() {
1473
+ const count = (outcome) => this._model.txs.filter((tx) => tx.result?.outcome === outcome).length;
1474
+ const counts = [
1475
+ [
1476
+ "success",
1477
+ count("success"),
1478
+ "succeeded"
1479
+ ],
1480
+ [
1481
+ "error",
1482
+ count("error") + count("invalid"),
1483
+ "failed"
1484
+ ],
1485
+ [
1486
+ "redirected",
1487
+ count("redirected"),
1488
+ "redirected"
1489
+ ]
1490
+ ];
1491
+ const imported = this._imported;
1492
+ return html`<div class="titlestrip">
1493
+ <button
1494
+ class="brand ${this._inspect === "router" || this._inspect === "tx" ? "anchor" : ""}"
1495
+ aria-pressed=${this._inspect === "router"}
1496
+ title="Router configuration"
1497
+ @click=${this.#toggleRouter}
1498
+ >
1499
+ Router
1500
+ </button>
1501
+ <div class="strip-switch">${this.#renderSwitch()}</div>
1502
+ ${this.#renderTabs()}
1503
+ ${imported ? html`<span class="imported tag" title=${imported.session.routerId}>Imported</span>` : nothing}
1504
+ <span class="spacer"
1505
+ >${this._notice ? html`<span
1506
+ class="notice ${this._notice.fault ? "fault" : ""}"
1507
+ title=${this._notice.text}
1508
+ >${this._notice.text}</span
1509
+ >` : nothing}</span
1510
+ >
1511
+ <span class="counts">
1512
+ ${counts.map(([status, n, label]) => html`<span
1513
+ class="count status-${status} ${n ? "" : "zero"}"
1514
+ title="${n} ${label}"
1515
+ >${statusGlyph(status)}<span class="num">${n}</span
1516
+ ><span class="visually-hidden">${label}</span></span
1517
+ >`)}
1518
+ </span>
1519
+ <span class="session">${this._sessionButtons()}</span>
1520
+ <button
1521
+ class="icon max"
1522
+ aria-pressed=${this._max}
1523
+ aria-label="Maximise devtools"
1524
+ title=${this._max ? "Restore the dock" : "Maximise"}
1525
+ @click=${() => {
1526
+ this._max = !this._max;
1527
+ this._fit();
1528
+ }}
1529
+ >
1530
+ ${this._max ? minGlyph : maxGlyph}
1531
+ </button>
1532
+ <button
1533
+ class="icon close"
1534
+ aria-label="Collapse devtools"
1535
+ @click=${this.#close}
1536
+ >
1537
+ ${closeGlyph}
1538
+ </button>
1539
+ </div>`;
1540
+ }
1541
+ }
1542
+ //# sourceMappingURL=panel.js.map