@pstdio/workbench 0.11.4 → 0.12.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.
@@ -1,7 +1,7 @@
1
1
  import { resourceKey as v } from "@pstdio/sdk/extensions";
2
2
  import { devtools as z } from "zustand/middleware";
3
3
  import { createStore as F } from "zustand/vanilla";
4
- const y = (e) => {
4
+ const b = (e) => {
5
5
  let t = !1;
6
6
  return {
7
7
  dispose() {
@@ -17,51 +17,51 @@ function R(e, t) {
17
17
  return;
18
18
  }
19
19
  }
20
- let b = 0;
20
+ let y = 0;
21
21
  const m = /* @__PURE__ */ new Map(), D = (e, t) => {
22
- if (b === 0) {
22
+ if (y === 0) {
23
23
  R("store subscriber", t);
24
24
  return;
25
25
  }
26
26
  m.has(e) || m.set(e, t);
27
27
  }, we = (e) => {
28
- b++;
28
+ y++;
29
29
  try {
30
30
  return e();
31
31
  } finally {
32
- if (b--, b === 0) {
33
- b++;
32
+ if (y--, y === 0) {
33
+ y++;
34
34
  try {
35
35
  for (; m.size; ) {
36
36
  const [t, n] = m.entries().next().value;
37
37
  m.delete(t), R("store subscriber", n);
38
38
  }
39
39
  } finally {
40
- b--;
40
+ y--;
41
41
  }
42
42
  }
43
43
  }
44
44
  }, N = (e, t) => Object.is(e, t), O = (e) => {
45
45
  const t = F()(z(() => e.initialState, {
46
46
  name: e.name ?? "workbench.store"
47
- })), n = (r) => {
48
- const s = {};
49
- return t.subscribe((o, a) => D(s, () => r(t.getState(), a)));
50
- }, i = (r, s, o = {}) => {
51
- const a = o.equalityFn ?? N;
52
- let c = r(t.getState());
53
- return o.fireImmediately && s(c, c), n((d) => {
54
- const l = r(d);
47
+ })), n = (i) => {
48
+ const o = {};
49
+ return t.subscribe((s, a) => D(o, () => i(t.getState(), a)));
50
+ }, r = (i, o, s = {}) => {
51
+ const a = s.equalityFn ?? N;
52
+ let c = i(t.getState());
53
+ return s.fireImmediately && o(c, c), n((d) => {
54
+ const l = i(d);
55
55
  if (a(c, l)) return;
56
56
  const g = c;
57
- c = l, s(l, g);
57
+ c = l, o(l, g);
58
58
  });
59
59
  };
60
60
  return {
61
61
  getState: t.getState,
62
62
  getInitialState: t.getInitialState,
63
63
  subscribe: n,
64
- subscribeSelector: i,
64
+ subscribeSelector: r,
65
65
  setState: t.setState,
66
66
  api: t
67
67
  };
@@ -87,54 +87,54 @@ const m = /* @__PURE__ */ new Map(), D = (e, t) => {
87
87
  "side-right-menu": "side"
88
88
  }, pe = (e) => U[e], T = (e, t, n = t) => {
89
89
  if (!e.has(n)) return n;
90
- let i = 1;
91
- for (; e.has(`${t}:${i}`); ) i += 1;
92
- return `${t}:${i}`;
90
+ let r = 1;
91
+ for (; e.has(`${t}:${r}`); ) r += 1;
92
+ return `${t}:${r}`;
93
93
  }, We = (e, t) => {
94
94
  for (const n of Object.values(e.regions)) {
95
- const i = n.widgets.findIndex((r) => r.contributionId === t);
96
- if (i >= 0) return {
95
+ const r = n.widgets.findIndex((i) => i.contributionId === t);
96
+ if (r >= 0) return {
97
97
  regionId: n.id,
98
- index: i,
99
- placement: n.widgets[i]
98
+ index: r,
99
+ placement: n.widgets[r]
100
100
  };
101
101
  }
102
102
  }, Se = (e, t, n) => {
103
- for (const i of Object.values(e.regions)) {
104
- const r = i.widgets.findIndex((s) => s.contributionId === t && s.resourceKey === n);
105
- if (r >= 0) return {
106
- regionId: i.id,
107
- index: r,
108
- placement: i.widgets[r]
103
+ for (const r of Object.values(e.regions)) {
104
+ const i = r.widgets.findIndex((o) => o.contributionId === t && o.resourceKey === n);
105
+ if (i >= 0) return {
106
+ regionId: r.id,
107
+ index: i,
108
+ placement: r.widgets[i]
109
109
  };
110
110
  }
111
111
  }, Z = (e, t) => {
112
112
  for (const n of Object.values(e.regions)) {
113
- const i = n.widgets.findIndex((r) => r.widgetId === t);
114
- if (i >= 0) return {
113
+ const r = n.widgets.findIndex((i) => i.widgetId === t);
114
+ if (r >= 0) return {
115
115
  regionId: n.id,
116
- index: i,
117
- placement: n.widgets[i]
116
+ index: r,
117
+ placement: n.widgets[r]
118
118
  };
119
119
  }
120
120
  }, ke = (e, t) => {
121
- const n = new Set(Object.values(e.regions).flatMap((i) => i.widgets.map((r) => r.widgetId)));
121
+ const n = new Set(Object.values(e.regions).flatMap((r) => r.widgets.map((i) => i.widgetId)));
122
122
  return T(n, t);
123
- }, L = (e) => e.widgets.find((t) => t.widgetId === e.activeWidgetId) ?? e.widgets[0], p = (e) => e.role === "location", $ = (e) => e.resourceKey ?? `${e.contributionId}:${e.widgetId}`, x = (e, t, n, i) => {
123
+ }, L = (e) => e.widgets.find((t) => t.widgetId === e.activeWidgetId) ?? e.widgets[0], p = (e) => e.role === "location", $ = (e) => e.resourceKey ?? `${e.contributionId}:${e.widgetId}`, x = (e, t, n, r) => {
124
124
  if (!t) return e;
125
- const r = $(t), o = {
126
- ...e.locationSubPanelSelections?.[r] ?? {}
125
+ const i = $(t), s = {
126
+ ...e.locationSubPanelSelections?.[i] ?? {}
127
127
  };
128
- return i ? o[n] = i : delete o[n], {
128
+ return r ? s[n] = r : delete s[n], {
129
129
  ...e,
130
130
  locationSubPanelSelections: {
131
131
  ...e.locationSubPanelSelections,
132
- [r]: o
132
+ [i]: s
133
133
  }
134
134
  };
135
135
  }, E = (e, t) => {
136
136
  if (!e.locationSubPanelSelections) return e;
137
- const n = Object.fromEntries(Object.entries(e.locationSubPanelSelections).map(([i, r]) => [i, Object.fromEntries(Object.entries(r).filter(([, s]) => s !== t))]));
137
+ const n = Object.fromEntries(Object.entries(e.locationSubPanelSelections).map(([r, i]) => [r, Object.fromEntries(Object.entries(i).filter(([, o]) => o !== t))]));
138
138
  return {
139
139
  ...e,
140
140
  locationSubPanelSelections: n
@@ -142,55 +142,55 @@ const m = /* @__PURE__ */ new Map(), D = (e, t) => {
142
142
  }, I = (e) => {
143
143
  const t = e.regions.main.widgets.filter(p);
144
144
  return t.find((n) => n.widgetId === e.activeLocationWidgetId) ?? t.at(-1);
145
- }, Pe = (e, t, n, i = {}) => {
146
- const r = e.regions[t], s = n(r.widgets), o = i.activeWidgetId !== void 0 ? i.activeWidgetId : i.clearActiveWidget ? void 0 : r.activeWidgetId;
145
+ }, Pe = (e, t, n, r = {}) => {
146
+ const i = e.regions[t], o = n(i.widgets), s = r.activeWidgetId !== void 0 ? r.activeWidgetId : r.clearActiveWidget ? void 0 : i.activeWidgetId;
147
147
  return {
148
148
  ...e,
149
- activeLocationWidgetId: t === "main" && !s.some((a) => a.widgetId === e.activeLocationWidgetId) ? s.filter(p).at(-1)?.widgetId : e.activeLocationWidgetId,
149
+ activeLocationWidgetId: t === "main" && !o.some((a) => a.widgetId === e.activeLocationWidgetId) ? o.filter(p).at(-1)?.widgetId : e.activeLocationWidgetId,
150
150
  regions: {
151
151
  ...e.regions,
152
152
  [t]: {
153
- ...r,
154
- widgets: s,
155
- activeWidgetId: o
153
+ ...i,
154
+ widgets: o,
155
+ activeWidgetId: s
156
156
  }
157
157
  }
158
158
  };
159
159
  }, Ke = (e, t) => {
160
160
  let n = e;
161
- for (const r of Object.values(e.regions)) {
162
- const s = r.widgets.filter((c) => c.contributionId === t), o = r.widgets.filter((c) => c.contributionId !== t);
163
- if (o.length === r.widgets.length) continue;
164
- const a = r.activeWidgetId && !o.some((c) => c.widgetId === r.activeWidgetId) ? void 0 : r.activeWidgetId;
161
+ for (const i of Object.values(e.regions)) {
162
+ const o = i.widgets.filter((c) => c.contributionId === t), s = i.widgets.filter((c) => c.contributionId !== t);
163
+ if (s.length === i.widgets.length) continue;
164
+ const a = i.activeWidgetId && !s.some((c) => c.widgetId === i.activeWidgetId) ? void 0 : i.activeWidgetId;
165
165
  n = {
166
166
  ...n,
167
167
  regions: {
168
168
  ...n.regions,
169
- [r.id]: {
170
- ...r,
171
- widgets: o,
169
+ [i.id]: {
170
+ ...i,
171
+ widgets: s,
172
172
  activeWidgetId: a
173
173
  }
174
174
  }
175
175
  };
176
- for (const c of s)
176
+ for (const c of o)
177
177
  n = E(n, c.widgetId);
178
178
  }
179
- const i = Object.values(n.regions).some((r) => r.widgets.some((s) => s.widgetId === n.activeWidgetId));
180
- return n.activeWidgetId && (!i || n.activeWidgetId.startsWith(`${t}:`) || n.activeWidgetId === t) && (n = {
179
+ const r = Object.values(n.regions).some((i) => i.widgets.some((o) => o.widgetId === n.activeWidgetId));
180
+ return n.activeWidgetId && (!r || n.activeWidgetId.startsWith(`${t}:`) || n.activeWidgetId === t) && (n = {
181
181
  ...n,
182
182
  activeWidgetId: void 0,
183
183
  activeResourceKey: void 0
184
- }), n.activeLocationWidgetId && !n.regions.main.widgets.some((r) => r.widgetId === n.activeLocationWidgetId) && (n = {
184
+ }), n.activeLocationWidgetId && !n.regions.main.widgets.some((i) => i.widgetId === n.activeLocationWidgetId) && (n = {
185
185
  ...n,
186
186
  activeLocationWidgetId: n.regions.main.widgets.filter(p).at(-1)?.widgetId
187
187
  }), n;
188
188
  }, Re = (e, t) => {
189
189
  const n = Z(e, t);
190
190
  if (!n) return;
191
- const i = e.regions[n.regionId], r = i.widgets.filter((g) => g.widgetId !== t), s = i.activeWidgetId === t || !i.activeWidgetId && n.index === 0, a = (n.placement.role === "sub-panel" ? r.find((g) => g.role === "sub-panel" && g.ownerResourceKey === n.placement.ownerResourceKey) : void 0) ?? (n.placement.role === "sub-panel" && n.regionId === "main" ? I(e) : r[n.index] ?? r[n.index - 1]), c = s ? a?.widgetId : i.activeWidgetId, d = {
192
- ...i,
193
- widgets: r,
191
+ const r = e.regions[n.regionId], i = r.widgets.filter((g) => g.widgetId !== t), o = r.activeWidgetId === t || !r.activeWidgetId && n.index === 0, a = (n.placement.role === "sub-panel" ? i.find((g) => g.role === "sub-panel" && g.ownerResourceKey === n.placement.ownerResourceKey) : void 0) ?? (n.placement.role === "sub-panel" && n.regionId === "main" ? I(e) : i[n.index] ?? i[n.index - 1]), c = o ? a?.widgetId : r.activeWidgetId, d = {
192
+ ...r,
193
+ widgets: i,
194
194
  activeWidgetId: c
195
195
  };
196
196
  let l = E({
@@ -198,10 +198,10 @@ const m = /* @__PURE__ */ new Map(), D = (e, t) => {
198
198
  activeLocationWidgetId: e.activeLocationWidgetId === t ? e.regions.main.widgets.filter((g) => g.widgetId !== t && p(g)).at(-1)?.widgetId : e.activeLocationWidgetId,
199
199
  regions: {
200
200
  ...e.regions,
201
- [i.id]: d
201
+ [r.id]: d
202
202
  }
203
203
  }, t);
204
- return s && n.regionId !== "side" && w.includes(n.regionId) && (l = x(l, I(l), n.regionId, a?.role === "sub-panel" ? a.widgetId : void 0)), e.activeWidgetId === t && (l = {
204
+ return o && n.regionId !== "side" && w.includes(n.regionId) && (l = x(l, I(l), n.regionId, a?.role === "sub-panel" ? a.widgetId : void 0)), e.activeWidgetId === t && (l = {
205
205
  ...l,
206
206
  activeWidgetId: a?.widgetId,
207
207
  activeResourceKey: a?.resourceKey
@@ -212,9 +212,9 @@ const m = /* @__PURE__ */ new Map(), D = (e, t) => {
212
212
  layout: l
213
213
  };
214
214
  }, Oe = (e, t, n) => {
215
- const i = e.regions[t];
215
+ const r = e.regions[t];
216
216
  if (t === "main" && p(n)) {
217
- const s = e.locationSubPanelSelections?.[$(n)] ?? {}, o = Object.fromEntries(Object.entries(e.regions).map(([a, c]) => [a, {
217
+ const o = e.locationSubPanelSelections?.[$(n)] ?? {}, s = Object.fromEntries(Object.entries(e.regions).map(([a, c]) => [a, {
218
218
  ...c,
219
219
  widgets: c.widgets.map((d) => !n.resource || d.widgetId === n.widgetId || d.ownerResourceKey !== n.resourceKey || d.resourceKey !== n.resourceKey ? d : {
220
220
  ...d,
@@ -222,8 +222,8 @@ const m = /* @__PURE__ */ new Map(), D = (e, t) => {
222
222
  })
223
223
  }]));
224
224
  for (const a of w) {
225
- const c = o[a], d = s[a], l = c.widgets.find((g) => g.widgetId === d && g.role === "sub-panel" && (!g.ownerResourceKey || g.ownerResourceKey === n.resourceKey));
226
- o[a] = {
225
+ const c = s[a], d = o[a], l = c.widgets.find((g) => g.widgetId === d && g.role === "sub-panel" && (!g.ownerResourceKey || g.ownerResourceKey === n.resourceKey));
226
+ s[a] = {
227
227
  ...c,
228
228
  activeWidgetId: a === "side" ? c.activeWidgetId : l?.widgetId ?? (a === "main" ? n.widgetId : void 0)
229
229
  };
@@ -233,54 +233,54 @@ const m = /* @__PURE__ */ new Map(), D = (e, t) => {
233
233
  activeWidgetId: n.widgetId,
234
234
  activeLocationWidgetId: n.widgetId,
235
235
  activeResourceKey: n.resourceKey,
236
- regions: o
236
+ regions: s
237
237
  };
238
238
  }
239
- const r = n.role === "sub-panel" && t !== "side" && w.includes(t) ? x(e, I(e), t, n.widgetId) : e;
239
+ const i = n.role === "sub-panel" && t !== "side" && w.includes(t) ? x(e, I(e), t, n.widgetId) : e;
240
240
  return {
241
- ...r,
241
+ ...i,
242
242
  activeWidgetId: n.widgetId,
243
243
  activeLocationWidgetId: e.activeLocationWidgetId,
244
244
  activeResourceKey: n.resourceKey,
245
245
  regions: {
246
- ...r.regions,
246
+ ...i.regions,
247
247
  [t]: {
248
- ...i,
248
+ ...r,
249
249
  activeWidgetId: n.widgetId
250
250
  }
251
251
  }
252
252
  };
253
253
  }, Le = (e, t, n) => {
254
- const i = e.regions[t], r = n ? i.widgets.find((a) => a.widgetId === n) : void 0;
255
- if (n && !r) throw new Error(`Widget placement not found in ${t}: ${n}`);
256
- if (i.activeWidgetId === n) return;
257
- const s = e.activeWidgetId === i.activeWidgetId, o = {
254
+ const r = e.regions[t], i = n ? r.widgets.find((a) => a.widgetId === n) : void 0;
255
+ if (n && !i) throw new Error(`Widget placement not found in ${t}: ${n}`);
256
+ if (r.activeWidgetId === n) return;
257
+ const o = e.activeWidgetId === r.activeWidgetId, s = {
258
258
  ...e,
259
- activeWidgetId: s ? r?.widgetId : e.activeWidgetId,
260
- activeResourceKey: s ? r?.resourceKey : e.activeResourceKey,
261
- activeLocationWidgetId: t === "main" && r?.role === "location" ? r.widgetId : e.activeLocationWidgetId,
259
+ activeWidgetId: o ? i?.widgetId : e.activeWidgetId,
260
+ activeResourceKey: o ? i?.resourceKey : e.activeResourceKey,
261
+ activeLocationWidgetId: t === "main" && i?.role === "location" ? i.widgetId : e.activeLocationWidgetId,
262
262
  regions: {
263
263
  ...e.regions,
264
264
  [t]: {
265
- ...i,
266
- activeWidgetId: r?.widgetId
265
+ ...r,
266
+ activeWidgetId: i?.widgetId
267
267
  }
268
268
  }
269
269
  };
270
- return t === "side" || !w.includes(t) ? o : x(o, I(o), t, r?.role === "sub-panel" ? r.widgetId : void 0);
271
- }, G = (e, t) => !(e.resourceKinds?.length && (!t || !e.resourceKinds.includes(t.type)) || e.canOpen && (!t || !e.canOpen(t))), xe = (e, t, n, i = {}) => {
272
- const r = e.regions[t];
273
- return r.widgets.find((s) => s.widgetId === r.activeWidgetId && s.role === "sub-panel" && (i.ignoreOwnerResourceKey || !s.ownerResourceKey || s.ownerResourceKey === v(n)));
274
- }, je = (e) => I(e), J = (e, t, n, i, r) => {
275
- const s = e.eligibleLocations;
276
- return !(!V(e, n) || s?.resourceKinds?.length && (!t || !s.resourceKinds.includes(t.type)) || s?.resourceIds?.length && (!t?.id || !s.resourceIds.includes(t.id)) || s?.canOpen && (!t || !s.canOpen(t)) || s?.canOpenLocation && !s.canOpenLocation({
270
+ return t === "side" || !w.includes(t) ? s : x(s, I(s), t, i?.role === "sub-panel" ? i.widgetId : void 0);
271
+ }, G = (e, t) => !(e.resourceKinds?.length && (!t || !e.resourceKinds.includes(t.type)) || e.canOpen && (!t || !e.canOpen(t))), xe = (e, t, n, r = {}) => {
272
+ const i = e.regions[t];
273
+ return i.widgets.find((o) => o.widgetId === i.activeWidgetId && o.role === "sub-panel" && (r.ignoreOwnerResourceKey || !o.ownerResourceKey || o.ownerResourceKey === v(n)));
274
+ }, je = (e) => I(e), J = (e, t, n, r, i) => {
275
+ const o = e.eligibleLocations;
276
+ return !(!V(e, n) || o?.resourceKinds?.length && (!t || !o.resourceKinds.includes(t.type)) || o?.resourceIds?.length && (!t?.id || !o.resourceIds.includes(t.id)) || o?.canOpen && (!t || !o.canOpen(t)) || o?.canOpenLocation && !o.canOpenLocation({
277
277
  resource: t,
278
- viewId: r?.viewId
279
- }) || i?.ownerResourceKey && i.ownerResourceKey !== v(t));
278
+ viewId: i?.viewId
279
+ }) || r?.ownerResourceKey && r.ownerResourceKey !== v(t));
280
280
  }, V = (e, t) => {
281
281
  const n = e.eligibleLocations?.modeIds;
282
282
  return !n?.length || t !== void 0 && n.includes(t);
283
- }, Ce = (e, t, n, i, r = {}) => G(e, i?.resource ?? t) ? r.ignoreResourceLocation ? V(e, n) : J(e, t, n, i, r.location) : !1, Me = (e, t) => {
283
+ }, Ce = (e, t, n, r, i = {}) => G(e, r?.resource ?? t) ? i.ignoreResourceLocation ? V(e, n) : J(e, t, n, r, i.location) : !1, Me = (e, t) => {
284
284
  const n = e.panelMenuOwner ?? {
285
285
  level: "panel"
286
286
  };
@@ -292,28 +292,28 @@ const m = /* @__PURE__ */ new Map(), D = (e, t) => {
292
292
  }), W = (e, t) => t.priority - e.priority || e.ownerId.localeCompare(t.ownerId), Ae = (e = {}, t) => {
293
293
  const {
294
294
  strategy: n,
295
- ...i
296
- } = e, r = i.resource && i.viewId === void 0 ? {
297
- ...i,
295
+ ...r
296
+ } = e, i = r.resource && r.viewId === void 0 ? {
297
+ ...r,
298
298
  viewId: null
299
- } : i;
299
+ } : r;
300
300
  return n ? n.kind === "persistent" ? {
301
- ...r,
301
+ ...i,
302
302
  tabPosition: n.position,
303
303
  tabRetention: "persistent"
304
304
  } : n.kind === "replace-active" ? {
305
- ...r,
305
+ ...i,
306
306
  replaceActive: !0
307
307
  } : n.kind === "replace-panel" ? {
308
- ...r,
308
+ ...i,
309
309
  replaceWidgetId: n.instanceId,
310
310
  tabRetention: n.retention
311
311
  } : {
312
- ...r,
312
+ ...i,
313
313
  tabRetention: "preview",
314
314
  tabPosition: n.position
315
315
  } : {
316
- ...r,
316
+ ...i,
317
317
  tabRetention: t
318
318
  };
319
319
  }, $e = (e) => ({
@@ -338,9 +338,9 @@ const m = /* @__PURE__ */ new Map(), D = (e, t) => {
338
338
  const {
339
339
  closable: t,
340
340
  ownedPanelMenuIds: n,
341
- ...i
341
+ ...r
342
342
  } = e;
343
- return i;
343
+ return r;
344
344
  }, h = {
345
345
  main: ["main-header", "main-left-menu", "main", "main-right-menu"],
346
346
  secondary: ["secondary-header", "secondary-left-menu", "secondary", "secondary-right-menu"],
@@ -349,7 +349,7 @@ const m = /* @__PURE__ */ new Map(), D = (e, t) => {
349
349
  if (t)
350
350
  return Object.values(e.regions).flatMap((n) => n.widgets).find((n) => n.widgetId === t);
351
351
  }, K = (e, t) => {
352
- const n = t.find((i) => i && f(e, i.widgetId));
352
+ const n = t.find((r) => r && f(e, r.widgetId));
353
353
  return {
354
354
  ...e,
355
355
  activeWidgetId: n?.widgetId,
@@ -357,33 +357,33 @@ const m = /* @__PURE__ */ new Map(), D = (e, t) => {
357
357
  };
358
358
  }, Y = (e, t) => {
359
359
  if (t.length === 0) return e;
360
- const n = new Set(Object.keys(h).filter((c) => h[c].some((d) => t.includes(d)))), i = t.some((c) => {
360
+ const n = new Set(Object.keys(h).filter((c) => h[c].some((d) => t.includes(d)))), r = t.some((c) => {
361
361
  const d = e.regions[c];
362
362
  return d.widgets.length > 0 || d.activeWidgetId !== void 0 || d.visible;
363
- }), r = Object.values(e.locationSubPanelSelections ?? {}).some((c) => Object.keys(c).some((d) => n.has(d)));
364
- if (!i && !r) return e;
365
- const s = {
363
+ }), i = Object.values(e.locationSubPanelSelections ?? {}).some((c) => Object.keys(c).some((d) => n.has(d)));
364
+ if (!r && !i) return e;
365
+ const o = {
366
366
  ...e.regions
367
367
  };
368
368
  for (const c of t)
369
- s[c] = {
370
- ...s[c],
369
+ o[c] = {
370
+ ...o[c],
371
371
  widgets: [],
372
372
  activeWidgetId: void 0,
373
373
  visible: !1
374
374
  };
375
- const o = Object.fromEntries(Object.entries(e.locationSubPanelSelections ?? {}).map(([c, d]) => [c, Object.fromEntries(Object.entries(d).filter(([l]) => !n.has(l)))])), a = {
375
+ const s = Object.fromEntries(Object.entries(e.locationSubPanelSelections ?? {}).map(([c, d]) => [c, Object.fromEntries(Object.entries(d).filter(([l]) => !n.has(l)))])), a = {
376
376
  ...e,
377
- regions: s
377
+ regions: o
378
378
  };
379
379
  return {
380
380
  ...K(a, [f(a, e.activeWidgetId)]),
381
381
  activeLocationWidgetId: f(a, e.activeLocationWidgetId)?.widgetId,
382
- locationSubPanelSelections: o
382
+ locationSubPanelSelections: s
383
383
  };
384
384
  }, M = (e, t) => {
385
- const n = new Set(t), i = Object.keys(h).filter((r) => !n.has(r)).flatMap((r) => h[r]);
386
- return Y(e, i);
385
+ const n = new Set(t), r = Object.keys(h).filter((i) => !n.has(i)).flatMap((i) => h[i]);
386
+ return Y(e, r);
387
387
  }, He = (e, t, n) => {
388
388
  if (!t) {
389
389
  const a = {
@@ -406,17 +406,17 @@ const m = /* @__PURE__ */ new Map(), D = (e, t) => {
406
406
  activeLocationWidgetId: f(c, e.activeLocationWidgetId)?.widgetId
407
407
  }, n);
408
408
  }
409
- const i = {
409
+ const r = {
410
410
  ...e.regions
411
411
  };
412
- for (const a of C) i[a] = t.regions[a];
413
- const r = M({
412
+ for (const a of C) r[a] = t.regions[a];
413
+ const i = M({
414
414
  ...e,
415
- regions: i
416
- }, n), s = f(r, t.activeWidgetId), o = f(r, e.activeWidgetId);
415
+ regions: r
416
+ }, n), o = f(i, t.activeWidgetId), s = f(i, e.activeWidgetId);
417
417
  return {
418
- ...K(r, [s, o]),
419
- activeLocationWidgetId: f(r, t.activeLocationWidgetId)?.widgetId ?? f(r, e.activeLocationWidgetId)?.widgetId,
418
+ ...K(i, [o, s]),
419
+ activeLocationWidgetId: f(i, t.activeLocationWidgetId)?.widgetId ?? f(i, e.activeLocationWidgetId)?.widgetId,
420
420
  locationSubPanelSelections: t.locationSubPanelSelections
421
421
  };
422
422
  }, Be = (e) => {
@@ -436,19 +436,19 @@ const m = /* @__PURE__ */ new Map(), D = (e, t) => {
436
436
  });
437
437
  return {
438
438
  store: t,
439
- registerKeybinding(n, i) {
439
+ registerKeybinding(n, r) {
440
440
  if (n.action.kind === "command" && !e.commands.getCommand(n.action.commandId))
441
441
  throw new Error(`Keybinding command not registered: ${n.action.commandId}`);
442
- const r = {
443
- ..._(i),
442
+ const i = {
443
+ ..._(r),
444
444
  ...n,
445
445
  keybinding: te(n.keybinding)
446
- }, s = t.getState();
446
+ }, o = t.getState();
447
447
  return t.setState({
448
- keybindings: [...s.keybindings, r]
449
- }, !1, "registerKeybinding"), y(() => {
450
- const o = t.getState(), a = o.keybindings.filter((c) => c !== r);
451
- a.length !== o.keybindings.length && t.setState({
448
+ keybindings: [...o.keybindings, i]
449
+ }, !1, "registerKeybinding"), b(() => {
450
+ const s = t.getState(), a = s.keybindings.filter((c) => c !== i);
451
+ a.length !== s.keybindings.length && t.setState({
452
452
  keybindings: a
453
453
  }, !1, "unregisterKeybinding");
454
454
  });
@@ -502,45 +502,45 @@ const m = /* @__PURE__ */ new Map(), D = (e, t) => {
502
502
  "side-left-menu": u(["attached"]),
503
503
  side: P("attached", "detached", "scoped"),
504
504
  "side-right-menu": u(["attached"])
505
- }, re = (e) => j[e], se = () => A.filter((e) => j[e].role === "anchor"), oe = (e) => {
505
+ }, re = (e) => j[e], oe = () => A.filter((e) => j[e].role === "anchor"), se = (e) => {
506
506
  const t = A.find((n) => {
507
- const i = j[n];
508
- return i.role === "anchor" && i.anchor === e;
507
+ const r = j[n];
508
+ return r.role === "anchor" && r.anchor === e;
509
509
  });
510
510
  if (!t) throw new Error(`No region hosts anchor: ${e}`);
511
511
  return t;
512
- }, Fe = (e, t) => L(e.regions[oe(t)])?.resource, De = ({
512
+ }, Fe = (e, t) => L(e.regions[se(t)])?.resource, De = ({
513
513
  layout: e,
514
514
  primary: t,
515
515
  isInScope: n
516
516
  }) => {
517
- const i = [];
518
- for (const r of se()) {
519
- const s = re(r);
520
- if (s.role !== "anchor" || s.persistence === "primary") continue;
521
- const o = L(e.regions[r]);
522
- if (o?.resource) {
523
- if (o.role === "sub-panel" && o.ownerResourceKey) {
524
- i.push({
525
- region: r,
517
+ const r = [];
518
+ for (const i of oe()) {
519
+ const o = re(i);
520
+ if (o.role !== "anchor" || o.persistence === "primary") continue;
521
+ const s = L(e.regions[i]);
522
+ if (s?.resource) {
523
+ if (s.role === "sub-panel" && s.ownerResourceKey) {
524
+ r.push({
525
+ region: i,
526
526
  action: "keep"
527
527
  });
528
528
  continue;
529
529
  }
530
- if (s.persistence === "derived") {
531
- i.push({
532
- region: r,
530
+ if (o.persistence === "derived") {
531
+ r.push({
532
+ region: i,
533
533
  action: "clear"
534
534
  });
535
535
  continue;
536
536
  }
537
- i.push({
538
- region: r,
539
- action: n(o.resource, t) ? "keep" : "clear"
537
+ r.push({
538
+ region: i,
539
+ action: n(s.resource, t) ? "keep" : "clear"
540
540
  });
541
541
  }
542
542
  }
543
- return i;
543
+ return r;
544
544
  }, Ne = {
545
545
  project: "folder-root",
546
546
  workspace: "computer",
@@ -548,32 +548,32 @@ const m = /* @__PURE__ */ new Map(), D = (e, t) => {
548
548
  settings: "settings",
549
549
  kanbanRenderer: "table-properties"
550
550
  }, S = (e) => "viewId" in e && e.type === "view", ce = "resource_hierarchy_cycle", H = (e) => [...e].sort((t, n) => n.priority - t.priority || t.id.localeCompare(n.id)), ae = (e, t, n) => {
551
- const i = H(e), r = [t], s = /* @__PURE__ */ new Set([`resource:${v(t)}`]);
552
- let o = t;
551
+ const r = H(e), i = [t], o = /* @__PURE__ */ new Set([`resource:${v(t)}`]);
552
+ let s = t;
553
553
  for (; ; ) {
554
- const c = i.find((l) => l.canResolve(o))?.getParent(o);
554
+ const c = r.find((l) => l.canResolve(s))?.getParent(s);
555
555
  if (!c) break;
556
556
  const d = S(c) ? `view:${c.viewId}` : `resource:${v(c)}`;
557
- if (s.has(d)) {
557
+ if (o.has(d)) {
558
558
  n({
559
559
  code: ce,
560
- path: [...r],
560
+ path: [...i],
561
561
  repeatedUri: S(c) ? d : v(c)
562
562
  });
563
563
  break;
564
564
  }
565
- if (r.unshift(c), s.add(d), S(c)) break;
566
- o = c;
565
+ if (i.unshift(c), o.add(d), S(c)) break;
566
+ s = c;
567
567
  }
568
- return r;
568
+ return i;
569
569
  }, de = "workbench.resource.type", le = "workbench.resource.id", ge = (e) => `workbench.resource.metadata.${e}`, B = "workbench.selectionResourceKey", ue = (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean", Ue = (e) => {
570
570
  if (!e) return {};
571
571
  const t = {
572
572
  [de]: e.type,
573
573
  [le]: e.id
574
574
  };
575
- for (const [n, i] of Object.entries(e.metadata ?? {}))
576
- ue(i) && (t[ge(n)] = i);
575
+ for (const [n, r] of Object.entries(e.metadata ?? {}))
576
+ ue(r) && (t[ge(n)] = r);
577
577
  return t;
578
578
  }, Te = (e) => ({
579
579
  [B]: v(e)
@@ -582,7 +582,7 @@ const m = /* @__PURE__ */ new Map(), D = (e, t) => {
582
582
  const t = e.metadata?.[B];
583
583
  return typeof t != "string" || t === v(e) ? [v(e)] : [v(e), t];
584
584
  }, Ge = (e = {}) => {
585
- const t = /* @__PURE__ */ new Set(), n = O({
585
+ const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = O({
586
586
  name: "workbench.resources",
587
587
  initialState: {
588
588
  kinds: {},
@@ -591,131 +591,137 @@ const m = /* @__PURE__ */ new Map(), D = (e, t) => {
591
591
  }
592
592
  });
593
593
  return {
594
- store: n,
595
- registerKind(i, r) {
596
- const s = n.getState();
594
+ store: r,
595
+ removed(i) {
596
+ e.remove?.(i, [...t].flatMap((o) => o(i)));
597
+ },
598
+ onWillRemove(i) {
599
+ return t.add(i), b(() => t.delete(i));
600
+ },
601
+ registerKind(i, o) {
602
+ const s = r.getState();
597
603
  if (s.kinds[i.kind]) throw new Error(`Resource kind already registered: ${i.kind}`);
598
- const o = {
599
- ..._(r),
604
+ const a = {
605
+ ..._(o),
600
606
  ...i
601
607
  };
602
- return n.setState({
608
+ return r.setState({
603
609
  ...s,
604
610
  kinds: {
605
611
  ...s.kinds,
606
- [i.kind]: o
612
+ [i.kind]: a
607
613
  }
608
- }, !1, "registerKind"), y(() => {
609
- const a = n.getState();
610
- if (a.kinds[i.kind] !== o) return;
614
+ }, !1, "registerKind"), b(() => {
615
+ const c = r.getState();
616
+ if (c.kinds[i.kind] !== a) return;
611
617
  const {
612
- [i.kind]: c,
613
- ...d
614
- } = a.kinds;
615
- n.setState({
616
- ...a,
617
- kinds: d
618
+ [i.kind]: d,
619
+ ...l
620
+ } = c.kinds;
621
+ r.setState({
622
+ ...c,
623
+ kinds: l
618
624
  }, !1, "unregisterKind");
619
625
  });
620
626
  },
621
627
  getKind(i) {
622
- return n.getState().kinds[i];
628
+ return r.getState().kinds[i];
623
629
  },
624
630
  listKinds() {
625
- return Object.values(n.getState().kinds).sort(W);
631
+ return Object.values(r.getState().kinds).sort(W);
626
632
  },
627
633
  registerProvider(i) {
628
- const r = n.getState();
629
- if (r.providers[i.id]) throw new Error(`Resource provider already registered: ${i.id}`);
630
- return n.setState({
631
- ...r,
634
+ const o = r.getState();
635
+ if (o.providers[i.id]) throw new Error(`Resource provider already registered: ${i.id}`);
636
+ return r.setState({
637
+ ...o,
632
638
  providers: {
633
- ...r.providers,
639
+ ...o.providers,
634
640
  [i.id]: i
635
641
  }
636
- }, !1, "registerProvider"), y(() => {
637
- const s = n.getState();
642
+ }, !1, "registerProvider"), b(() => {
643
+ const s = r.getState();
638
644
  if (s.providers[i.id] !== i) return;
639
645
  const {
640
- [i.id]: o,
641
- ...a
646
+ [i.id]: a,
647
+ ...c
642
648
  } = s.providers;
643
- n.setState({
649
+ r.setState({
644
650
  ...s,
645
- providers: a
651
+ providers: c
646
652
  }, !1, "unregisterProvider");
647
653
  });
648
654
  },
649
655
  listProviders() {
650
- return Object.values(n.getState().providers);
656
+ return Object.values(r.getState().providers);
651
657
  },
652
658
  listResources(i) {
653
- const r = {
659
+ const o = {
654
660
  primary: e.getPrimary?.()
655
661
  }, s = [];
656
- for (const o of Object.values(n.getState().providers))
657
- s.push(...o.list(i, r));
662
+ for (const a of Object.values(r.getState().providers))
663
+ s.push(...a.list(i, o));
658
664
  return s;
659
665
  },
660
666
  registerHierarchyProvider(i) {
661
- const r = n.getState();
662
- if (r.hierarchyProviders[i.id])
667
+ const o = r.getState();
668
+ if (o.hierarchyProviders[i.id])
663
669
  throw new Error(`Resource hierarchy provider already registered: ${i.id}`);
664
670
  const s = {
665
671
  ...i,
666
672
  priority: i.priority ?? 0
667
673
  };
668
- return n.setState({
669
- ...r,
674
+ return r.setState({
675
+ ...o,
670
676
  hierarchyProviders: {
671
- ...r.hierarchyProviders,
677
+ ...o.hierarchyProviders,
672
678
  [i.id]: s
673
679
  }
674
- }, !1, "registerHierarchyProvider"), y(() => {
675
- const o = n.getState();
676
- if (o.hierarchyProviders[i.id] !== s) return;
680
+ }, !1, "registerHierarchyProvider"), b(() => {
681
+ const a = r.getState();
682
+ if (a.hierarchyProviders[i.id] !== s) return;
677
683
  const {
678
- [i.id]: a,
679
- ...c
680
- } = o.hierarchyProviders;
681
- n.setState({
682
- ...o,
683
- hierarchyProviders: c
684
+ [i.id]: c,
685
+ ...d
686
+ } = a.hierarchyProviders;
687
+ r.setState({
688
+ ...a,
689
+ hierarchyProviders: d
684
690
  }, !1, "unregisterHierarchyProvider");
685
691
  });
686
692
  },
687
693
  listHierarchyProviders() {
688
- return H(Object.values(n.getState().hierarchyProviders));
694
+ return H(Object.values(r.getState().hierarchyProviders));
689
695
  },
690
696
  walkHierarchy(i) {
691
- return i ? ae(Object.values(n.getState().hierarchyProviders), i, (s) => {
692
- for (const o of t) o(s);
697
+ return i ? ae(Object.values(r.getState().hierarchyProviders), i, (s) => {
698
+ for (const a of n) a(s);
693
699
  }).map((s) => {
694
700
  if (!S(s)) return s;
695
- const o = e.resolveView?.(s.viewId);
696
- return o ? {
701
+ const a = e.resolveView?.(s.viewId);
702
+ return a ? {
697
703
  ...s,
698
- label: o.label,
699
- icon: o.icon
704
+ label: a.label,
705
+ icon: a.icon
700
706
  } : s;
701
707
  }) : [];
702
708
  },
703
709
  onDidDetectHierarchyCycle(i) {
704
- return t.add(i), y(() => {
705
- t.delete(i);
710
+ return n.add(i), b(() => {
711
+ n.delete(i);
706
712
  });
707
713
  }
708
714
  };
709
715
  }, fe = (e) => e.replace(/^['"]|['"]$/g, ""), ve = (e, t) => {
710
716
  const n = t.trim();
711
717
  if (n.length === 0) return !0;
712
- const i = n.match(/^([A-Za-z0-9_.-]+)\s*(==|!=)\s*(.+)$/);
713
- if (i) {
714
- const [, r, s, o] = i, a = e[r ?? ""], c = fe(o ?? "");
715
- return s === "==" ? String(a) === c : String(a) !== c;
718
+ const r = n.match(/^([A-Za-z0-9_.-]+)\s*(==|!=)\s*(.+)$/);
719
+ if (r) {
720
+ const [, i, o, s] = r, a = e[i ?? ""], c = fe(s ?? "");
721
+ return o === "==" ? String(a) === c : String(a) !== c;
716
722
  }
717
723
  return n.startsWith("!") ? !e[n.slice(1)] : !!e[n];
718
- }, he = (e, t) => t ? t.split("||").some((n) => n.split("&&").every((i) => ve(e, i))) : !0, Je = () => {
724
+ }, he = (e, t) => t ? t.split("||").some((n) => n.split("&&").every((r) => ve(e, r))) : !0, Je = () => {
719
725
  const e = O({
720
726
  name: "workbench.context",
721
727
  initialState: {
@@ -723,80 +729,80 @@ const m = /* @__PURE__ */ new Map(), D = (e, t) => {
723
729
  }
724
730
  });
725
731
  let t = {};
726
- const n = /* @__PURE__ */ new Map(), i = () => {
727
- const s = {
732
+ const n = /* @__PURE__ */ new Map(), r = () => {
733
+ const o = {
728
734
  ...t
729
735
  };
730
- for (const o of n.values()) Object.assign(s, o);
731
- return s;
732
- }, r = (s) => {
736
+ for (const s of n.values()) Object.assign(o, s);
737
+ return o;
738
+ }, i = (o) => {
733
739
  e.setState({
734
- values: i()
735
- }, !1, s);
740
+ values: r()
741
+ }, !1, o);
736
742
  };
737
743
  return {
738
744
  store: e,
739
- set(s, o) {
740
- t[s] !== o && (t = {
745
+ set(o, s) {
746
+ t[o] !== s && (t = {
741
747
  ...t,
742
- [s]: o
743
- }, r("setContextKey"));
748
+ [o]: s
749
+ }, i("setContextKey"));
744
750
  },
745
- get(s) {
746
- return e.getState().values[s];
751
+ get(o) {
752
+ return e.getState().values[o];
747
753
  },
748
- delete(s) {
749
- if (!(s in t)) return;
754
+ delete(o) {
755
+ if (!(o in t)) return;
750
756
  const {
751
- [s]: o,
757
+ [o]: s,
752
758
  ...a
753
759
  } = t;
754
- t = a, r("deleteContextKey");
760
+ t = a, i("deleteContextKey");
755
761
  },
756
- createScope(s) {
757
- n.set(s, n.get(s) ?? {});
758
- let o = !1;
762
+ createScope(o) {
763
+ n.set(o, n.get(o) ?? {});
764
+ let s = !1;
759
765
  const a = () => {
760
- if (o) throw new Error(`Context key scope disposed: ${s}`);
766
+ if (s) throw new Error(`Context key scope disposed: ${o}`);
761
767
  };
762
768
  return {
763
- ownerId: s,
769
+ ownerId: o,
764
770
  set(c, d) {
765
771
  a();
766
- const l = n.get(s) ?? {};
767
- l[c] !== d && (n.set(s, {
772
+ const l = n.get(o) ?? {};
773
+ l[c] !== d && (n.set(o, {
768
774
  ...l,
769
775
  [c]: d
770
- }), r("setScopedContextKey"));
776
+ }), i("setScopedContextKey"));
771
777
  },
772
778
  get(c) {
773
- return a(), n.get(s)?.[c];
779
+ return a(), n.get(o)?.[c];
774
780
  },
775
781
  delete(c) {
776
782
  a();
777
- const d = n.get(s);
783
+ const d = n.get(o);
778
784
  if (!d || !(c in d)) return;
779
785
  const {
780
786
  [c]: l,
781
787
  ...g
782
788
  } = d;
783
- n.set(s, g), r("deleteScopedContextKey");
789
+ n.set(o, g), i("deleteScopedContextKey");
784
790
  },
785
791
  dispose() {
786
- o || (o = !0, n.delete(s) && r("disposeContextKeyScope"));
792
+ s || (s = !0, n.delete(o) && i("disposeContextKeyScope"));
787
793
  }
788
794
  };
789
795
  },
790
- deleteOwner(s) {
791
- n.delete(s) && r("deleteContextKeyOwner");
796
+ deleteOwner(o) {
797
+ n.delete(o) && i("deleteContextKeyOwner");
792
798
  },
793
799
  snapshot() {
794
800
  return {
795
801
  ...e.getState().values
796
802
  };
797
803
  },
798
- matches(s) {
799
- return he(e.getState().values, s);
804
+ matches(o) {
805
+ return he(e.getState().values, o);
800
806
  }
801
807
  };
802
808
  }, q = /* @__PURE__ */ new WeakMap(), Qe = (e, t) => {
@@ -816,7 +822,7 @@ export {
816
822
  Ce as F,
817
823
  we as G,
818
824
  D as H,
819
- oe as I,
825
+ se as I,
820
826
  De as J,
821
827
  Je as K,
822
828
  Ge as L,
@@ -835,7 +841,7 @@ export {
835
841
  ge as Y,
836
842
  de as Z,
837
843
  B as _,
838
- y as a,
844
+ b as a,
839
845
  Xe as a0,
840
846
  xe as a1,
841
847
  pe as a2,
@@ -868,4 +874,4 @@ export {
868
874
  Oe as y,
869
875
  Be as z
870
876
  };
871
- //# sourceMappingURL=workbench-renderers-BhgHQ-Ne.js.map
877
+ //# sourceMappingURL=workbench-renderers-BAPxtfpZ.js.map