@pstdio/workbench 0.11.4 → 0.35.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.
@@ -0,0 +1,803 @@
1
+ import { resourceKey as e } from "@pstdio/sdk/extensions";
2
+ import { devtools as t } from "zustand/middleware";
3
+ import { createStore as n } from "zustand/vanilla";
4
+ //#region src/core/shared/disposable.ts
5
+ var r = (e) => {
6
+ let t = !1;
7
+ return { dispose() {
8
+ t || (t = !0, e());
9
+ } };
10
+ };
11
+ //#endregion
12
+ //#region src/core/shared/workbench-effect.ts
13
+ function i(e, t) {
14
+ try {
15
+ return t();
16
+ } catch (t) {
17
+ console.error(`Workbench effect failed (${e})`, t);
18
+ return;
19
+ }
20
+ }
21
+ //#endregion
22
+ //#region src/core/shared/store/workbench-batch.ts
23
+ var a = 0, o = /* @__PURE__ */ new Map(), s = (e, t) => {
24
+ if (a === 0) {
25
+ i("store subscriber", t);
26
+ return;
27
+ }
28
+ o.has(e) || o.set(e, t);
29
+ }, c = (e) => {
30
+ a++;
31
+ try {
32
+ return e();
33
+ } finally {
34
+ if (a--, a === 0) {
35
+ a++;
36
+ try {
37
+ for (; o.size;) {
38
+ let [e, t] = o.entries().next().value;
39
+ o.delete(e), i("store subscriber", t);
40
+ }
41
+ } finally {
42
+ a--;
43
+ }
44
+ }
45
+ }
46
+ }, l = (e, t) => Object.is(e, t), u = (e) => {
47
+ let r = n()(t(() => e.initialState, { name: e.name ?? "workbench.store" })), i = (e) => {
48
+ let t = {};
49
+ return r.subscribe((n, i) => s(t, () => e(r.getState(), i)));
50
+ };
51
+ return {
52
+ getState: r.getState,
53
+ getInitialState: r.getInitialState,
54
+ subscribe: i,
55
+ subscribeSelector: (e, t, n = {}) => {
56
+ let a = n.equalityFn ?? l, o = e(r.getState());
57
+ return n.fireImmediately && t(o, o), i((n) => {
58
+ let r = e(n);
59
+ if (a(o, r)) return;
60
+ let i = o;
61
+ o = r, t(r, i);
62
+ });
63
+ },
64
+ setState: r.setState,
65
+ api: r
66
+ };
67
+ }, d = [
68
+ "nav",
69
+ "activity",
70
+ "sidenav",
71
+ "main-header",
72
+ "main-left-menu",
73
+ "main",
74
+ "main-right-menu",
75
+ "secondary-header",
76
+ "secondary-left-menu",
77
+ "secondary",
78
+ "secondary-right-menu",
79
+ "side-header",
80
+ "side-left-menu",
81
+ "side",
82
+ "side-right-menu",
83
+ "status",
84
+ "overlay"
85
+ ], f = [
86
+ "main",
87
+ "secondary",
88
+ "side"
89
+ ], ee = {
90
+ main: {
91
+ left: "main-left-menu",
92
+ right: "main-right-menu"
93
+ },
94
+ secondary: {
95
+ left: "secondary-left-menu",
96
+ right: "secondary-right-menu"
97
+ },
98
+ side: {
99
+ left: "side-left-menu",
100
+ right: "side-right-menu"
101
+ }
102
+ }, te = {
103
+ "main-left-menu": "main",
104
+ "main-right-menu": "main",
105
+ "secondary-left-menu": "secondary",
106
+ "secondary-right-menu": "secondary",
107
+ "side-left-menu": "side",
108
+ "side-right-menu": "side"
109
+ }, ne = (e) => te[e], p = (e, t, n = t) => {
110
+ if (!e.has(n)) return n;
111
+ let r = 1;
112
+ for (; e.has(`${t}:${r}`);) r += 1;
113
+ return `${t}:${r}`;
114
+ }, re = (e, t) => {
115
+ for (let n of Object.values(e.regions)) {
116
+ let e = n.widgets.findIndex((e) => e.contributionId === t);
117
+ if (e >= 0) return {
118
+ regionId: n.id,
119
+ index: e,
120
+ placement: n.widgets[e]
121
+ };
122
+ }
123
+ }, ie = (e, t, n) => {
124
+ for (let r of Object.values(e.regions)) {
125
+ let e = r.widgets.findIndex((e) => e.contributionId === t && e.resourceKey === n);
126
+ if (e >= 0) return {
127
+ regionId: r.id,
128
+ index: e,
129
+ placement: r.widgets[e]
130
+ };
131
+ }
132
+ }, m = (e, t) => {
133
+ for (let n of Object.values(e.regions)) {
134
+ let e = n.widgets.findIndex((e) => e.widgetId === t);
135
+ if (e >= 0) return {
136
+ regionId: n.id,
137
+ index: e,
138
+ placement: n.widgets[e]
139
+ };
140
+ }
141
+ }, ae = (e, t) => p(new Set(Object.values(e.regions).flatMap((e) => e.widgets.map((e) => e.widgetId))), t), h = (e) => e.widgets.find((t) => t.widgetId === e.activeWidgetId) ?? e.widgets[0], g = (e) => e.role === "location", _ = (e) => e.resourceKey ?? `${e.contributionId}:${e.widgetId}`, v = (e, t, n, r) => {
142
+ if (!t) return e;
143
+ let i = _(t), a = { ...e.locationSubPanelSelections?.[i] ?? {} };
144
+ return r ? a[n] = r : delete a[n], {
145
+ ...e,
146
+ locationSubPanelSelections: {
147
+ ...e.locationSubPanelSelections,
148
+ [i]: a
149
+ }
150
+ };
151
+ }, y = (e, t) => {
152
+ if (!e.locationSubPanelSelections) return e;
153
+ let n = Object.fromEntries(Object.entries(e.locationSubPanelSelections).map(([e, n]) => [e, Object.fromEntries(Object.entries(n).filter(([, e]) => e !== t))]));
154
+ return {
155
+ ...e,
156
+ locationSubPanelSelections: n
157
+ };
158
+ }, b = (e) => {
159
+ let t = e.regions.main.widgets.filter(g);
160
+ return t.find((t) => t.widgetId === e.activeLocationWidgetId) ?? t.at(-1);
161
+ }, x = (e, t, n, r = {}) => {
162
+ let i = e.regions[t], a = n(i.widgets), o = r.activeWidgetId === void 0 ? r.clearActiveWidget ? void 0 : i.activeWidgetId : r.activeWidgetId;
163
+ return {
164
+ ...e,
165
+ activeLocationWidgetId: t === "main" && !a.some((t) => t.widgetId === e.activeLocationWidgetId) ? a.filter(g).at(-1)?.widgetId : e.activeLocationWidgetId,
166
+ regions: {
167
+ ...e.regions,
168
+ [t]: {
169
+ ...i,
170
+ widgets: a,
171
+ activeWidgetId: o
172
+ }
173
+ }
174
+ };
175
+ }, S = (e, t) => {
176
+ let n = e;
177
+ for (let r of Object.values(e.regions)) {
178
+ let e = r.widgets.filter((e) => e.contributionId === t), i = r.widgets.filter((e) => e.contributionId !== t);
179
+ if (i.length === r.widgets.length) continue;
180
+ let a = r.activeWidgetId && !i.some((e) => e.widgetId === r.activeWidgetId) ? void 0 : r.activeWidgetId;
181
+ n = {
182
+ ...n,
183
+ regions: {
184
+ ...n.regions,
185
+ [r.id]: {
186
+ ...r,
187
+ widgets: i,
188
+ activeWidgetId: a
189
+ }
190
+ }
191
+ };
192
+ for (let t of e) n = y(n, t.widgetId);
193
+ }
194
+ let r = Object.values(n.regions).some((e) => e.widgets.some((e) => e.widgetId === n.activeWidgetId));
195
+ return n.activeWidgetId && (!r || n.activeWidgetId.startsWith(`${t}:`) || n.activeWidgetId === t) && (n = {
196
+ ...n,
197
+ activeWidgetId: void 0,
198
+ activeResourceKey: void 0
199
+ }), n.activeLocationWidgetId && !n.regions.main.widgets.some((e) => e.widgetId === n.activeLocationWidgetId) && (n = {
200
+ ...n,
201
+ activeLocationWidgetId: n.regions.main.widgets.filter(g).at(-1)?.widgetId
202
+ }), n;
203
+ }, C = (e, t) => {
204
+ let n = m(e, t);
205
+ if (!n) return;
206
+ let r = e.regions[n.regionId], i = r.widgets.filter((e) => e.widgetId !== t), a = r.activeWidgetId === t || !r.activeWidgetId && n.index === 0, o = (n.placement.role === "sub-panel" ? i.find((e) => e.role === "sub-panel" && e.ownerResourceKey === n.placement.ownerResourceKey) : void 0) ?? (n.placement.role === "sub-panel" && n.regionId === "main" ? b(e) : i[n.index] ?? i[n.index - 1]), s = a ? o?.widgetId : r.activeWidgetId, c = {
207
+ ...r,
208
+ widgets: i,
209
+ activeWidgetId: s
210
+ }, l = y({
211
+ ...e,
212
+ activeLocationWidgetId: e.activeLocationWidgetId === t ? e.regions.main.widgets.filter((e) => e.widgetId !== t && g(e)).at(-1)?.widgetId : e.activeLocationWidgetId,
213
+ regions: {
214
+ ...e.regions,
215
+ [r.id]: c
216
+ }
217
+ }, t);
218
+ return a && n.regionId !== "side" && f.includes(n.regionId) && (l = v(l, b(l), n.regionId, o?.role === "sub-panel" ? o.widgetId : void 0)), e.activeWidgetId === t && (l = {
219
+ ...l,
220
+ activeWidgetId: o?.widgetId,
221
+ activeResourceKey: o?.resourceKey
222
+ }), {
223
+ regionId: n.regionId,
224
+ closedPlacement: n.placement,
225
+ activePlacement: h(c),
226
+ layout: l
227
+ };
228
+ }, oe = (e, t, n) => {
229
+ let r = e.regions[t];
230
+ if (t === "main" && g(n)) {
231
+ let t = e.locationSubPanelSelections?.[_(n)] ?? {}, r = Object.fromEntries(Object.entries(e.regions).map(([e, t]) => [e, {
232
+ ...t,
233
+ widgets: t.widgets.map((e) => !n.resource || e.widgetId === n.widgetId || e.ownerResourceKey !== n.resourceKey || e.resourceKey !== n.resourceKey ? e : {
234
+ ...e,
235
+ resource: n.resource
236
+ })
237
+ }]));
238
+ for (let e of f) {
239
+ let i = r[e], a = t[e], o = i.widgets.find((e) => e.widgetId === a && e.role === "sub-panel" && (!e.ownerResourceKey || e.ownerResourceKey === n.resourceKey));
240
+ r[e] = {
241
+ ...i,
242
+ activeWidgetId: e === "side" ? i.activeWidgetId : o?.widgetId ?? (e === "main" ? n.widgetId : void 0)
243
+ };
244
+ }
245
+ return {
246
+ ...e,
247
+ activeWidgetId: n.widgetId,
248
+ activeLocationWidgetId: n.widgetId,
249
+ activeResourceKey: n.resourceKey,
250
+ regions: r
251
+ };
252
+ }
253
+ let i = n.role === "sub-panel" && t !== "side" && f.includes(t) ? v(e, b(e), t, n.widgetId) : e;
254
+ return {
255
+ ...i,
256
+ activeWidgetId: n.widgetId,
257
+ activeLocationWidgetId: e.activeLocationWidgetId,
258
+ activeResourceKey: n.resourceKey,
259
+ regions: {
260
+ ...i.regions,
261
+ [t]: {
262
+ ...r,
263
+ activeWidgetId: n.widgetId
264
+ }
265
+ }
266
+ };
267
+ }, se = (e, t, n) => {
268
+ let r = e.regions[t], i = n ? r.widgets.find((e) => e.widgetId === n) : void 0;
269
+ if (n && !i) throw Error(`Widget placement not found in ${t}: ${n}`);
270
+ if (r.activeWidgetId === n) return;
271
+ let a = e.activeWidgetId === r.activeWidgetId, o = {
272
+ ...e,
273
+ activeWidgetId: a ? i?.widgetId : e.activeWidgetId,
274
+ activeResourceKey: a ? i?.resourceKey : e.activeResourceKey,
275
+ activeLocationWidgetId: t === "main" && i?.role === "location" ? i.widgetId : e.activeLocationWidgetId,
276
+ regions: {
277
+ ...e.regions,
278
+ [t]: {
279
+ ...r,
280
+ activeWidgetId: i?.widgetId
281
+ }
282
+ }
283
+ };
284
+ return t === "side" || !f.includes(t) ? o : v(o, b(o), t, i?.role === "sub-panel" ? i.widgetId : void 0);
285
+ }, ce = (e, t) => !(e.resourceKinds?.length && (!t || !e.resourceKinds.includes(t.type)) || e.canOpen && (!t || !e.canOpen(t))), le = (t, n, r, i = {}) => {
286
+ let a = t.regions[n];
287
+ return a.widgets.find((t) => t.widgetId === a.activeWidgetId && t.role === "sub-panel" && (i.ignoreOwnerResourceKey || !t.ownerResourceKey || t.ownerResourceKey === e(r)));
288
+ }, ue = (e) => b(e), de = (t, n, r, i, a) => {
289
+ let o = t.eligibleLocations;
290
+ return !(!w(t, r) || o?.resourceKinds?.length && (!n || !o.resourceKinds.includes(n.type)) || o?.resourceIds?.length && (!n?.id || !o.resourceIds.includes(n.id)) || o?.canOpen && (!n || !o.canOpen(n)) || o?.canOpenLocation && !o.canOpenLocation({
291
+ resource: n,
292
+ viewId: a?.viewId
293
+ }) || i?.ownerResourceKey && i.ownerResourceKey !== e(n));
294
+ }, w = (e, t) => {
295
+ let n = e.eligibleLocations?.modeIds;
296
+ return !n?.length || t !== void 0 && n.includes(t);
297
+ }, fe = (e, t, n, r, i = {}) => ce(e, r?.resource ?? t) ? i.ignoreResourceLocation ? w(e, n) : de(e, t, n, r, i.location) : !1, pe = (e, t) => {
298
+ let n = e.panelMenuOwner ?? { level: "panel" };
299
+ return n.contributionId ? (t.subPanel ?? t.locationPanel)?.contributionId === n.contributionId : t.subPanel ? n.level === "sub-panel" : n.level === "panel";
300
+ }, me = "workbench.core", T = (e = {}) => ({
301
+ source: e.source ?? "module",
302
+ ownerId: e.ownerId ?? me,
303
+ priority: e.priority ?? 0
304
+ }), E = (e, t) => t.priority - e.priority || e.ownerId.localeCompare(t.ownerId), he = (e = {}, t) => {
305
+ let { strategy: n, ...r } = e, i = r.resource && r.viewId === void 0 ? {
306
+ ...r,
307
+ viewId: null
308
+ } : r;
309
+ return n ? n.kind === "persistent" ? {
310
+ ...i,
311
+ tabPosition: n.position,
312
+ tabRetention: "persistent"
313
+ } : n.kind === "replace-active" ? {
314
+ ...i,
315
+ replaceActive: !0
316
+ } : n.kind === "replace-panel" ? {
317
+ ...i,
318
+ replaceWidgetId: n.instanceId,
319
+ tabRetention: n.retention
320
+ } : {
321
+ ...i,
322
+ tabRetention: "preview",
323
+ tabPosition: n.position
324
+ } : {
325
+ ...i,
326
+ tabRetention: t
327
+ };
328
+ }, ge = (e) => ({
329
+ instanceId: e.widgetId,
330
+ panelId: e.contributionId,
331
+ placementIdentity: e.placementIdentity,
332
+ viewId: e.viewId,
333
+ ownerId: e.ownerId,
334
+ source: e.source,
335
+ resource: e.resource,
336
+ section: e.section,
337
+ resourceKey: e.resourceKey,
338
+ ownerResourceKey: e.ownerResourceKey,
339
+ title: e.title,
340
+ pinned: e.pinned,
341
+ closable: e.closable === !0,
342
+ mountStrategy: e.mountStrategy,
343
+ hiddenByDefault: e.hiddenByDefault,
344
+ tabRetention: e.tabRetention,
345
+ tab: e.tab
346
+ }), _e = (e) => {
347
+ let { closable: t, ownedPanelMenuIds: n, ...r } = e;
348
+ return r;
349
+ }, D = {
350
+ main: [
351
+ "main-header",
352
+ "main-left-menu",
353
+ "main",
354
+ "main-right-menu"
355
+ ],
356
+ secondary: [
357
+ "secondary-header",
358
+ "secondary-left-menu",
359
+ "secondary",
360
+ "secondary-right-menu"
361
+ ],
362
+ side: [
363
+ "side-header",
364
+ "side-left-menu",
365
+ "side",
366
+ "side-right-menu"
367
+ ]
368
+ }, O = Object.values(D).flat(), k = (e) => e.panels ?? f, A = (e) => Object.keys(D).find((t) => D[t].some((t) => t === e)), j = (e, t) => !e || k(e).includes(t), M = (e, t) => {
369
+ if (t) return Object.values(e.regions).flatMap((e) => e.widgets).find((e) => e.widgetId === t);
370
+ }, N = (e, t) => {
371
+ let n = t.find((t) => t && M(e, t.widgetId));
372
+ return {
373
+ ...e,
374
+ activeWidgetId: n?.widgetId,
375
+ activeResourceKey: n?.resourceKey
376
+ };
377
+ }, P = (e, t) => {
378
+ if (t.length === 0) return e;
379
+ let n = new Set(Object.keys(D).filter((e) => D[e].some((e) => t.includes(e)))), r = t.some((t) => {
380
+ let n = e.regions[t];
381
+ return n.widgets.length > 0 || n.activeWidgetId !== void 0 || n.visible;
382
+ }), i = Object.values(e.locationSubPanelSelections ?? {}).some((e) => Object.keys(e).some((e) => n.has(e)));
383
+ if (!r && !i) return e;
384
+ let a = { ...e.regions };
385
+ for (let e of t) a[e] = {
386
+ ...a[e],
387
+ widgets: [],
388
+ activeWidgetId: void 0,
389
+ visible: !1
390
+ };
391
+ let o = Object.fromEntries(Object.entries(e.locationSubPanelSelections ?? {}).map(([e, t]) => [e, Object.fromEntries(Object.entries(t).filter(([e]) => !n.has(e)))])), s = {
392
+ ...e,
393
+ regions: a
394
+ };
395
+ return {
396
+ ...N(s, [M(s, e.activeWidgetId)]),
397
+ activeLocationWidgetId: M(s, e.activeLocationWidgetId)?.widgetId,
398
+ locationSubPanelSelections: o
399
+ };
400
+ }, F = (e, t) => {
401
+ let n = new Set(t);
402
+ return P(e, Object.keys(D).filter((e) => !n.has(e)).flatMap((e) => D[e]));
403
+ }, I = (e, t, n) => {
404
+ if (!t) {
405
+ let t = { ...e.regions };
406
+ for (let e of O) {
407
+ let n = t[e], r = n.widgets.filter((e) => e.role !== "content");
408
+ t[e] = {
409
+ ...n,
410
+ widgets: r,
411
+ activeWidgetId: r.some((e) => e.widgetId === n.activeWidgetId) ? n.activeWidgetId : void 0
412
+ };
413
+ }
414
+ let r = {
415
+ ...e,
416
+ regions: t
417
+ };
418
+ return F({
419
+ ...N(r, [M(r, e.activeWidgetId)]),
420
+ activeLocationWidgetId: M(r, e.activeLocationWidgetId)?.widgetId
421
+ }, n);
422
+ }
423
+ let r = { ...e.regions };
424
+ for (let e of O) r[e] = t.regions[e];
425
+ let i = F({
426
+ ...e,
427
+ regions: r
428
+ }, n);
429
+ return {
430
+ ...N(i, [M(i, t.activeWidgetId), M(i, e.activeWidgetId)]),
431
+ activeLocationWidgetId: M(i, t.activeLocationWidgetId)?.widgetId ?? M(i, e.activeLocationWidgetId)?.widgetId,
432
+ locationSubPanelSelections: t.locationSubPanelSelections
433
+ };
434
+ }, ve = (e) => {
435
+ for (let t = e.length - 1; t >= 0; --t) i("mode disposal", () => e[t]?.dispose());
436
+ }, ye = (e, t) => {
437
+ t !== e.layout.getLayout() && e.layout.restoreLayout(t);
438
+ }, L = (e) => Array.isArray(e) ? e : e.trim().split(/\s+/).filter(Boolean), be = (e) => {
439
+ let t = L(e);
440
+ return t.length === 1 ? t[0] ?? "" : t;
441
+ }, xe = (e) => {
442
+ let t = u({
443
+ name: "workbench.keybindings",
444
+ initialState: { keybindings: [] }
445
+ });
446
+ return {
447
+ store: t,
448
+ registerKeybinding(n, i) {
449
+ if (n.action.kind === "command" && !e.commands.getCommand(n.action.commandId)) throw Error(`Keybinding command not registered: ${n.action.commandId}`);
450
+ let a = {
451
+ ...T(i),
452
+ ...n,
453
+ keybinding: be(n.keybinding)
454
+ }, o = t.getState();
455
+ return t.setState({ keybindings: [...o.keybindings, a] }, !1, "registerKeybinding"), r(() => {
456
+ let e = t.getState(), n = e.keybindings.filter((e) => e !== a);
457
+ n.length !== e.keybindings.length && t.setState({ keybindings: n }, !1, "unregisterKeybinding");
458
+ });
459
+ },
460
+ listKeybindings() {
461
+ return [...t.getState().keybindings].sort(E);
462
+ },
463
+ listActiveKeybindings() {
464
+ return t.getState().keybindings.filter((t) => e.context.matches(t.when)).sort(E);
465
+ },
466
+ listCommandKeybindings() {
467
+ return [...t.getState().keybindings].sort(E).flatMap((e) => e.action.kind === "command" ? [{
468
+ commandId: e.action.commandId,
469
+ keybinding: e.keybinding
470
+ }] : []);
471
+ }
472
+ };
473
+ }, R = (e, t, n) => ({
474
+ role: "anchor",
475
+ anchor: e,
476
+ persistence: t,
477
+ candidates: n
478
+ }), z = (e, t = !1) => t ? {
479
+ role: "projection",
480
+ reads: e,
481
+ navigator: t
482
+ } : {
483
+ role: "projection",
484
+ reads: e
485
+ }, B = {
486
+ nav: z(["primary", "attached"]),
487
+ activity: { role: "chrome" },
488
+ sidenav: z(["primary"], !0),
489
+ "main-header": z(["primary"]),
490
+ "main-left-menu": z(["primary"]),
491
+ main: R("primary", "primary", "global"),
492
+ "main-right-menu": z(["primary"]),
493
+ "secondary-header": z(["primary"]),
494
+ "secondary-left-menu": z(["secondary"]),
495
+ secondary: R("secondary", "derived", "scoped"),
496
+ "secondary-right-menu": z(["secondary"]),
497
+ status: z(["primary", "attached"]),
498
+ overlay: { role: "transient" },
499
+ "side-header": z(["attached"]),
500
+ "side-left-menu": z(["attached"]),
501
+ side: R("attached", "detached", "scoped"),
502
+ "side-right-menu": z(["attached"])
503
+ }, Se = (e) => B[e], Ce = () => d.filter((e) => B[e].role === "anchor"), V = (e) => {
504
+ let t = d.find((t) => {
505
+ let n = B[t];
506
+ return n.role === "anchor" && n.anchor === e;
507
+ });
508
+ if (!t) throw Error(`No region hosts anchor: ${e}`);
509
+ return t;
510
+ }, we = (e, t) => h(e.regions[V(t)])?.resource, Te = ({ layout: e, primary: t, isInScope: n }) => {
511
+ let r = [];
512
+ for (let i of Ce()) {
513
+ let a = Se(i);
514
+ if (a.role !== "anchor" || a.persistence === "primary") continue;
515
+ let o = h(e.regions[i]);
516
+ if (o?.resource) {
517
+ if (o.role === "sub-panel" && o.ownerResourceKey) {
518
+ r.push({
519
+ region: i,
520
+ action: "keep"
521
+ });
522
+ continue;
523
+ }
524
+ if (a.persistence === "derived") {
525
+ r.push({
526
+ region: i,
527
+ action: "clear"
528
+ });
529
+ continue;
530
+ }
531
+ r.push({
532
+ region: i,
533
+ action: n(o.resource, t) ? "keep" : "clear"
534
+ });
535
+ }
536
+ }
537
+ return r;
538
+ }, H = (e) => [
539
+ "workbench",
540
+ "header",
541
+ e,
542
+ "leading"
543
+ ], U = (e) => [
544
+ "workbench",
545
+ "header",
546
+ e,
547
+ "trailing"
548
+ ], Ee = (e) => [
549
+ "workbench",
550
+ "regionTabs",
551
+ e,
552
+ "leading"
553
+ ], De = (e) => [
554
+ "workbench",
555
+ "regionTabs",
556
+ e,
557
+ "add"
558
+ ], Oe = ["workbench", "commandPalette"], ke = H("nav"), Ae = U("nav"), je = (e) => [
559
+ "workbench",
560
+ "resource",
561
+ e,
562
+ "context"
563
+ ], Me = {
564
+ project: "folder-root",
565
+ workspace: "computer",
566
+ worktree: "git-pull-request-draft",
567
+ settings: "settings",
568
+ kanbanRenderer: "table-properties"
569
+ }, W = (e) => "viewId" in e && e.type === "view", G = "resource_hierarchy_cycle", K = (e) => [...e].sort((e, t) => t.priority - e.priority || e.id.localeCompare(t.id)), Ne = (t, n, r) => {
570
+ let i = K(t), a = [n], o = /* @__PURE__ */ new Set([`resource:${e(n)}`]), s = n;
571
+ for (;;) {
572
+ let t = i.find((e) => e.canResolve(s))?.getParent(s);
573
+ if (!t) break;
574
+ let n = W(t) ? `view:${t.viewId}` : `resource:${e(t)}`;
575
+ if (o.has(n)) {
576
+ r({
577
+ code: G,
578
+ path: [...a],
579
+ repeatedUri: W(t) ? n : e(t)
580
+ });
581
+ break;
582
+ }
583
+ if (a.unshift(t), o.add(n), W(t)) break;
584
+ s = t;
585
+ }
586
+ return a;
587
+ }, q = "workbench.resource.type", J = "workbench.resource.id", Y = (e) => `workbench.resource.metadata.${e}`, X = "workbench.selectionResourceKey", Pe = (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean", Fe = (e) => {
588
+ if (!e) return {};
589
+ let t = {
590
+ [q]: e.type,
591
+ [J]: e.id
592
+ };
593
+ for (let [n, r] of Object.entries(e.metadata ?? {})) Pe(r) && (t[Y(n)] = r);
594
+ return t;
595
+ }, Ie = (t) => ({ [X]: e(t) }), Le = (t) => {
596
+ if (!t) return [];
597
+ let n = t.metadata?.[X];
598
+ return typeof n != "string" || n === e(t) ? [e(t)] : [e(t), n];
599
+ }, Re = (e = {}) => {
600
+ let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), i = u({
601
+ name: "workbench.resources",
602
+ initialState: {
603
+ kinds: {},
604
+ providers: {},
605
+ hierarchyProviders: {}
606
+ }
607
+ });
608
+ return {
609
+ store: i,
610
+ removed(n) {
611
+ e.remove?.(n, [...t].flatMap((e) => e(n)));
612
+ },
613
+ onWillRemove(e) {
614
+ return t.add(e), r(() => t.delete(e));
615
+ },
616
+ registerKind(e, t) {
617
+ let n = i.getState();
618
+ if (n.kinds[e.kind]) throw Error(`Resource kind already registered: ${e.kind}`);
619
+ let a = {
620
+ ...T(t),
621
+ ...e
622
+ };
623
+ return i.setState({
624
+ ...n,
625
+ kinds: {
626
+ ...n.kinds,
627
+ [e.kind]: a
628
+ }
629
+ }, !1, "registerKind"), r(() => {
630
+ let t = i.getState();
631
+ if (t.kinds[e.kind] !== a) return;
632
+ let { [e.kind]: n, ...r } = t.kinds;
633
+ i.setState({
634
+ ...t,
635
+ kinds: r
636
+ }, !1, "unregisterKind");
637
+ });
638
+ },
639
+ getKind(e) {
640
+ return i.getState().kinds[e];
641
+ },
642
+ listKinds() {
643
+ return Object.values(i.getState().kinds).sort(E);
644
+ },
645
+ registerProvider(e) {
646
+ let t = i.getState();
647
+ if (t.providers[e.id]) throw Error(`Resource provider already registered: ${e.id}`);
648
+ return i.setState({
649
+ ...t,
650
+ providers: {
651
+ ...t.providers,
652
+ [e.id]: e
653
+ }
654
+ }, !1, "registerProvider"), r(() => {
655
+ let t = i.getState();
656
+ if (t.providers[e.id] !== e) return;
657
+ let { [e.id]: n, ...r } = t.providers;
658
+ i.setState({
659
+ ...t,
660
+ providers: r
661
+ }, !1, "unregisterProvider");
662
+ });
663
+ },
664
+ listProviders() {
665
+ return Object.values(i.getState().providers);
666
+ },
667
+ listResources(t) {
668
+ let n = { primary: e.getPrimary?.() }, r = [];
669
+ for (let e of Object.values(i.getState().providers)) r.push(...e.list(t, n));
670
+ return r;
671
+ },
672
+ registerHierarchyProvider(e) {
673
+ let t = i.getState();
674
+ if (t.hierarchyProviders[e.id]) throw Error(`Resource hierarchy provider already registered: ${e.id}`);
675
+ let n = {
676
+ ...e,
677
+ priority: e.priority ?? 0
678
+ };
679
+ return i.setState({
680
+ ...t,
681
+ hierarchyProviders: {
682
+ ...t.hierarchyProviders,
683
+ [e.id]: n
684
+ }
685
+ }, !1, "registerHierarchyProvider"), r(() => {
686
+ let t = i.getState();
687
+ if (t.hierarchyProviders[e.id] !== n) return;
688
+ let { [e.id]: r, ...a } = t.hierarchyProviders;
689
+ i.setState({
690
+ ...t,
691
+ hierarchyProviders: a
692
+ }, !1, "unregisterHierarchyProvider");
693
+ });
694
+ },
695
+ listHierarchyProviders() {
696
+ return K(Object.values(i.getState().hierarchyProviders));
697
+ },
698
+ walkHierarchy(t) {
699
+ return t ? Ne(Object.values(i.getState().hierarchyProviders), t, (e) => {
700
+ for (let t of n) t(e);
701
+ }).map((t) => {
702
+ if (!W(t)) return t;
703
+ let n = e.resolveView?.(t.viewId);
704
+ return n ? {
705
+ ...t,
706
+ label: n.label,
707
+ icon: n.icon
708
+ } : t;
709
+ }) : [];
710
+ },
711
+ onDidDetectHierarchyCycle(e) {
712
+ return n.add(e), r(() => {
713
+ n.delete(e);
714
+ });
715
+ }
716
+ };
717
+ }, ze = (e) => e.replace(/^['"]|['"]$/g, ""), Z = (e, t) => {
718
+ let n = t.trim();
719
+ if (n.length === 0) return !0;
720
+ let r = n.match(/^([A-Za-z0-9_.-]+)\s*(==|!=)\s*(.+)$/);
721
+ if (r) {
722
+ let [, t, n, i] = r, a = e[t ?? ""], o = ze(i ?? "");
723
+ return n === "==" ? String(a) === o : String(a) !== o;
724
+ }
725
+ return n.startsWith("!") ? !e[n.slice(1)] : !!e[n];
726
+ }, Q = (e, t) => !t || t.split("||").some((t) => t.split("&&").every((t) => Z(e, t))), Be = () => {
727
+ let e = u({
728
+ name: "workbench.context",
729
+ initialState: { values: {} }
730
+ }), t = {}, n = /* @__PURE__ */ new Map(), r = () => {
731
+ let e = { ...t };
732
+ for (let t of n.values()) Object.assign(e, t);
733
+ return e;
734
+ }, i = (t) => {
735
+ e.setState({ values: r() }, !1, t);
736
+ };
737
+ return {
738
+ store: e,
739
+ set(e, n) {
740
+ t[e] !== n && (t = {
741
+ ...t,
742
+ [e]: n
743
+ }, i("setContextKey"));
744
+ },
745
+ get(t) {
746
+ return e.getState().values[t];
747
+ },
748
+ delete(e) {
749
+ if (!(e in t)) return;
750
+ let { [e]: n, ...r } = t;
751
+ t = r, i("deleteContextKey");
752
+ },
753
+ createScope(e) {
754
+ n.set(e, n.get(e) ?? {});
755
+ let t = !1, r = () => {
756
+ if (t) throw Error(`Context key scope disposed: ${e}`);
757
+ };
758
+ return {
759
+ ownerId: e,
760
+ set(t, a) {
761
+ r();
762
+ let o = n.get(e) ?? {};
763
+ o[t] !== a && (n.set(e, {
764
+ ...o,
765
+ [t]: a
766
+ }), i("setScopedContextKey"));
767
+ },
768
+ get(t) {
769
+ return r(), n.get(e)?.[t];
770
+ },
771
+ delete(t) {
772
+ r();
773
+ let a = n.get(e);
774
+ if (!a || !(t in a)) return;
775
+ let { [t]: o, ...s } = a;
776
+ n.set(e, s), i("deleteScopedContextKey");
777
+ },
778
+ dispose() {
779
+ t || (t = !0, n.delete(e) && i("disposeContextKeyScope"));
780
+ }
781
+ };
782
+ },
783
+ deleteOwner(e) {
784
+ n.delete(e) && i("deleteContextKeyOwner");
785
+ },
786
+ snapshot() {
787
+ return { ...e.getState().values };
788
+ },
789
+ matches(t) {
790
+ return Q(e.getState().values, t);
791
+ }
792
+ };
793
+ }, $ = /* @__PURE__ */ new WeakMap(), Ve = (e, t) => {
794
+ $.set(e, t);
795
+ }, He = (e) => {
796
+ let t = $.get(e);
797
+ if (!t) throw Error("Workbench renderers are not initialized");
798
+ return t;
799
+ };
800
+ //#endregion
801
+ export { h as $, ve as A, T as B, Ae as C, xe as D, V as E, I as F, pe as G, le as H, he as I, ae as J, oe as K, _e as L, j as M, k as N, L as O, ye as P, b as Q, ge as R, ke as S, Te as T, fe as U, ue as V, w as W, m as X, re as Y, ie as Z, U as _, Re as a, p as at, De as b, Le as c, f as ct, q as d, c as dt, y as et, X as f, s as ft, H as g, Me as h, Q as i, v as it, A as j, F as k, J as l, d as lt, G as m, r as mt, Ve as n, x as nt, Fe as o, ne as ot, W as p, i as pt, C as q, Be as r, se as rt, Ie as s, ee as st, He as t, S as tt, Y as u, u as ut, je as v, we as w, Ee as x, Oe as y, E as z };
802
+
803
+ //# sourceMappingURL=workbench-renderers-BK6g8mG_.js.map