@pstdio/workbench 0.44.0-nightly.20261018030230 → 0.44.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 (30) hide show
  1. package/dist/extensions.d.ts +163 -1040
  2. package/dist/extensions.js +1194 -808
  3. package/dist/extensions.js.map +1 -1
  4. package/dist/{file-renderer-view-BsLjjvTU.js → file-renderer-view-C5dyoQQW.js} +211 -214
  5. package/dist/file-renderer-view-C5dyoQQW.js.map +1 -0
  6. package/dist/{index-JZ3eu6uE.d.ts → index-8x-QT7wg.d.ts} +1992 -533
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.js +2041 -2003
  9. package/dist/index.js.map +1 -1
  10. package/dist/{kanban-presentation-CmFF6y9I.d.ts → kanban-presentation-pexk_oCY.d.ts} +1 -1
  11. package/dist/layout-tab-presentation-Bz6EgFEa.js +15 -0
  12. package/dist/layout-tab-presentation-Bz6EgFEa.js.map +1 -0
  13. package/dist/{navigation-tree-registry-CIwRvLFJ.js → navigation-tree-registry-C5l3eO3n.js} +2 -2
  14. package/dist/{navigation-tree-registry-CIwRvLFJ.js.map → navigation-tree-registry-C5l3eO3n.js.map} +1 -1
  15. package/dist/react-C-HbdPSw.js +8881 -0
  16. package/dist/react-C-HbdPSw.js.map +1 -0
  17. package/dist/react.d.ts +75 -29
  18. package/dist/react.js +2 -2
  19. package/dist/storage.d.ts +3 -2
  20. package/dist/storage.js +142 -123
  21. package/dist/storage.js.map +1 -1
  22. package/dist/webview-runtime.js +1 -1
  23. package/dist/workbench-renderers-Bz_dLyHW.js +4775 -0
  24. package/dist/workbench-renderers-Bz_dLyHW.js.map +1 -0
  25. package/package.json +3 -3
  26. package/dist/file-renderer-view-BsLjjvTU.js.map +0 -1
  27. package/dist/react-B3WmSI5Y.js +0 -11192
  28. package/dist/react-B3WmSI5Y.js.map +0 -1
  29. package/dist/workbench-renderers-Bj4sazP5.js +0 -976
  30. package/dist/workbench-renderers-Bj4sazP5.js.map +0 -1
@@ -0,0 +1,4775 @@
1
+ import { z as e } from "zod";
2
+ import { devtools as t } from "zustand/middleware";
3
+ import { createStore as n } from "zustand/vanilla";
4
+ import { dockedWorkbenchRegions as r, isFileSourcePosition as i, resourceKey as a } from "@pstdio/sdk/extensions";
5
+ //#region ../pstdio-api-contracts/src/activity.ts
6
+ var o = e.string(), s = e.enum([
7
+ "user",
8
+ "agent",
9
+ "system"
10
+ ]), c = e.enum([
11
+ "ui",
12
+ "api",
13
+ "hook",
14
+ "system",
15
+ "agent"
16
+ ]), l = e.object({
17
+ id: e.string(),
18
+ project_id: e.string(),
19
+ resource_type: o,
20
+ resource_id: e.string(),
21
+ source_extension_id: e.string().nullable(),
22
+ event_type: e.string(),
23
+ actor_type: s,
24
+ actor_id: e.string().nullable(),
25
+ source: c,
26
+ summary: e.string(),
27
+ payload_json: e.record(e.string(), e.unknown()),
28
+ created_at: e.string()
29
+ });
30
+ e.object({
31
+ eventType: e.string().optional(),
32
+ event_type: e.string().optional(),
33
+ from: e.string().optional(),
34
+ to: e.string().optional(),
35
+ cursor: e.string().optional(),
36
+ limit: e.coerce.number().int().optional()
37
+ }).extend({ resource_type: o.optional() }), e.object({
38
+ events: e.array(l),
39
+ next_cursor: e.string().nullable()
40
+ });
41
+ var u = e.object({
42
+ id: e.string(),
43
+ projectId: e.string(),
44
+ resourceType: e.string(),
45
+ resourceId: e.string(),
46
+ sourceExtensionId: e.string().nullable(),
47
+ eventType: e.string(),
48
+ actorType: s,
49
+ actorId: e.string().nullable(),
50
+ source: c,
51
+ summary: e.string(),
52
+ payloadJson: e.record(e.string(), e.unknown()),
53
+ createdAt: e.string()
54
+ });
55
+ e.object({
56
+ items: e.array(u),
57
+ nextCursor: e.string().nullable()
58
+ });
59
+ //#endregion
60
+ //#region ../pstdio-api-contracts/src/harness.ts
61
+ var d = [
62
+ "SessionFork",
63
+ "ContextUsage",
64
+ "Approvals",
65
+ "SessionReattach",
66
+ "Attachments"
67
+ ], f = e.enum(["INSTALLED", "NOT_FOUND"]), p = e.object({
68
+ dir: e.string(),
69
+ global_dir: e.string()
70
+ }), m = e.union([e.string(), e.object({
71
+ $l10n: e.string(),
72
+ default: e.string().optional()
73
+ })]), h = e.object({
74
+ control: e.literal("command").optional(),
75
+ label: m.optional(),
76
+ description: m.optional(),
77
+ required: e.boolean().optional(),
78
+ metadata: e.record(e.string(), e.unknown()).optional()
79
+ }), ee = e.object({
80
+ label: e.string(),
81
+ value: e.string(),
82
+ icon: e.string().optional()
83
+ }), te = h.extend({
84
+ type: e.literal("select"),
85
+ defaultValue: e.string().optional(),
86
+ options: e.array(ee)
87
+ }), ne = h.extend({
88
+ type: e.literal("boolean"),
89
+ defaultValue: e.boolean().optional()
90
+ }), re = e.union([te, ne]), ie = e.record(e.string(), re), ae = e.object({
91
+ id: e.string(),
92
+ name: e.string(),
93
+ availability: e.object({
94
+ type: f,
95
+ reason: e.string().optional()
96
+ }),
97
+ skills: p.optional(),
98
+ params: ie.optional(),
99
+ capabilities: e.array(e.enum(d)),
100
+ supportsModels: e.boolean()
101
+ });
102
+ e.object({
103
+ id: e.string(),
104
+ label: e.string().optional(),
105
+ description: e.string().optional(),
106
+ isDefault: e.boolean().optional(),
107
+ paramOverrides: e.record(e.string(), re.nullable()).optional()
108
+ }), ae.extend({ skills: p.extend({ globalDir: e.string() }).optional() }), e.strictObject({
109
+ release: e.string().min(1),
110
+ protocolVersions: e.array(e.number().int().positive()).min(1),
111
+ supportedFeatures: e.array(e.string().min(1)),
112
+ requiredFeatures: e.array(e.string().min(1))
113
+ });
114
+ //#endregion
115
+ //#region ../pstdio-sync-contracts/src/json.ts
116
+ function oe(e) {
117
+ try {
118
+ JSON.stringify(e);
119
+ } catch {
120
+ return !1;
121
+ }
122
+ let t = [e], n = /* @__PURE__ */ new Set();
123
+ for (; t.length;) {
124
+ let e = t.pop();
125
+ if (e !== null && typeof e != "string" && typeof e != "boolean" && !(typeof e == "number" && Number.isFinite(e))) {
126
+ if (typeof e != "object" || !e) return !1;
127
+ if (!n.has(e)) {
128
+ if (n.add(e), Array.isArray(e)) t.push(...e);
129
+ else {
130
+ let n = Object.getPrototypeOf(e);
131
+ if (n !== Object.prototype && n !== null) return !1;
132
+ t.push(...Object.values(e));
133
+ }
134
+ }
135
+ }
136
+ }
137
+ return !0;
138
+ }
139
+ var se = e.custom(oe, "Expected a JSON value without loss of object keys");
140
+ function ce(t) {
141
+ return e.custom((e) => typeof e == "object" && !!e && !Array.isArray(e) && Object.values(e).every((e) => t.safeParse(e).success), "Invalid dictionary");
142
+ }
143
+ //#endregion
144
+ //#region ../pstdio-sync-contracts/src/wire.ts
145
+ var g = e.string().min(1), _ = e.number().int().nonnegative(), v = e.string().regex(/^[a-f0-9]{64}$/), le = e.strictObject({
146
+ accountId: g,
147
+ workbenchId: g,
148
+ extensionId: g
149
+ }), y = e.strictObject({
150
+ sha256: v,
151
+ byteLength: _,
152
+ mediaType: g
153
+ }), ue = e.discriminatedUnion("kind", [
154
+ e.strictObject({
155
+ kind: e.literal("text"),
156
+ update: e.string().min(1)
157
+ }),
158
+ e.strictObject({
159
+ kind: e.literal("list"),
160
+ update: e.string().min(1)
161
+ }),
162
+ e.strictObject({
163
+ kind: e.literal("map"),
164
+ entries: e.array(e.strictObject({
165
+ key: e.string(),
166
+ expected: v,
167
+ next: e.discriminatedUnion("kind", [e.strictObject({
168
+ kind: e.literal("set"),
169
+ value: se
170
+ }), e.strictObject({ kind: e.literal("delete") })])
171
+ })).min(1)
172
+ })
173
+ ]), de = e.strictObject({
174
+ recordId: g,
175
+ expectedRevision: _,
176
+ baseDeleted: e.boolean(),
177
+ shared: ue.optional(),
178
+ value: e.strictObject({
179
+ expected: v,
180
+ next: se
181
+ }).optional(),
182
+ asset: e.strictObject({
183
+ base: y.nullable(),
184
+ next: y.nullable()
185
+ }).optional(),
186
+ deleted: e.boolean().optional()
187
+ }), fe = e.strictObject({
188
+ conflictId: g,
189
+ expectedConflicts: e.array(e.strictObject({
190
+ conflictId: g,
191
+ revision: _
192
+ })).min(1),
193
+ capturedOperationIds: e.array(g).min(1),
194
+ expectedInputs: e.array(e.strictObject({
195
+ recordId: g,
196
+ revision: _
197
+ })).min(1),
198
+ handler: e.strictObject({
199
+ publishedRevision: g,
200
+ handlerId: g
201
+ }).optional()
202
+ }), pe = e.strictObject({
203
+ protocolVersion: e.literal(1),
204
+ scope: le,
205
+ environmentId: g,
206
+ operationId: g,
207
+ parents: e.array(g),
208
+ changes: e.array(de).min(1),
209
+ resolution: fe.optional()
210
+ });
211
+ pe.omit({
212
+ protocolVersion: !0,
213
+ scope: !0
214
+ }).superRefine(he);
215
+ var me = pe.extend({ fingerprint: v }).superRefine(he);
216
+ function he(e, t) {
217
+ let n = (e) => new Set(e).size === e.length, r = e.changes.map((e) => e.recordId);
218
+ (!n(r) || !n(e.parents) || e.parents.includes(e.operationId)) && t.addIssue({
219
+ code: "custom",
220
+ message: "Records and parents must be unique; operations cannot depend on themselves"
221
+ });
222
+ for (let r of e.changes) !r.shared && !r.value && !r.asset && r.deleted === void 0 && t.addIssue({
223
+ code: "custom",
224
+ message: "A record change must contain an edit"
225
+ }), r.shared?.kind === "map" && !n(r.shared.entries.map((e) => e.key)) && t.addIssue({
226
+ code: "custom",
227
+ message: "Map keys must be unique within a change"
228
+ });
229
+ let i = e.resolution;
230
+ if (!i) return;
231
+ let a = i.expectedInputs.map((e) => e.recordId);
232
+ (!n(i.expectedConflicts.map((e) => e.conflictId)) || !i.expectedConflicts.some((e) => e.conflictId === i.conflictId) || !n(a) || a.length !== r.length || r.some((e) => !a.includes(e)) || !n(i.capturedOperationIds) || i.capturedOperationIds.some((t) => !e.parents.includes(t))) && t.addIssue({
233
+ code: "custom",
234
+ message: "Resolution inputs must cover the whole group and captured operations must be parents"
235
+ });
236
+ }
237
+ //#endregion
238
+ //#region ../pstdio-sync-contracts/src/fingerprint.ts
239
+ function ge(e) {
240
+ return Array.isArray(e) ? `[${e.map(ge).join(",")}]` : typeof e == "object" && e ? `{${Object.keys(e).filter((t) => e[t] !== void 0).sort().map((t) => `${JSON.stringify(t)}:${ge(e[t])}`).join(",")}}` : JSON.stringify(e);
241
+ }
242
+ //#endregion
243
+ //#region ../pstdio-sync-contracts/src/identity.ts
244
+ var _e = e.strictObject({ environmentId: g });
245
+ _e.extend({
246
+ workbenchId: g,
247
+ workspaceId: g
248
+ });
249
+ //#endregion
250
+ //#region ../pstdio-sync-contracts/src/state.ts
251
+ var b = e.strictObject({
252
+ epoch: g,
253
+ sequence: _
254
+ }), ve = e.strictObject({
255
+ recordId: g,
256
+ revision: _,
257
+ deleted: e.boolean(),
258
+ primitive: e.enum([
259
+ "text",
260
+ "list",
261
+ "map"
262
+ ]).nullable(),
263
+ shared: e.strictObject({
264
+ kind: e.enum(["text", "list"]),
265
+ update: e.string()
266
+ }).optional(),
267
+ map: ce(se),
268
+ value: se,
269
+ asset: y.nullable()
270
+ }), ye = e.strictObject({
271
+ conflictId: g,
272
+ revision: _,
273
+ recordIds: e.array(g).min(1),
274
+ alternativeOperationIds: e.array(g).min(1),
275
+ resolvedBy: g.optional()
276
+ }), be = e.strictObject({
277
+ order: _,
278
+ operationId: g,
279
+ fingerprint: v,
280
+ mutation: me,
281
+ status: e.enum([
282
+ "accepted",
283
+ "conflict",
284
+ "pending"
285
+ ]),
286
+ reason: e.string().optional(),
287
+ checkpoint: b.nullable(),
288
+ conflictId: g.optional(),
289
+ recoveryProof: v.optional()
290
+ }).superRefine((e, t) => {
291
+ let n = e.operationId === e.mutation.operationId && e.fingerprint === e.mutation.fingerprint, r = e.status === "accepted";
292
+ (!n || r !== (e.checkpoint !== null) || e.status === "conflict" && !e.conflictId) && t.addIssue({
293
+ code: "custom",
294
+ message: "Receipt identity, fingerprint, outcome and checkpoint must agree"
295
+ });
296
+ });
297
+ e.strictObject({
298
+ protocolVersion: e.literal(1),
299
+ scope: le,
300
+ journalSequence: _,
301
+ checkpoint: b,
302
+ records: ce(ve),
303
+ receipts: ce(be),
304
+ conflicts: ce(ye),
305
+ publishedRevision: g
306
+ }), e.discriminatedUnion("status", [
307
+ e.strictObject({
308
+ status: e.literal("saved-locally"),
309
+ operationId: g
310
+ }),
311
+ e.strictObject({
312
+ status: e.literal("pending"),
313
+ operationId: g,
314
+ reason: e.string()
315
+ }),
316
+ e.strictObject({
317
+ status: e.literal("synchronized"),
318
+ operationId: g,
319
+ checkpoint: b
320
+ }),
321
+ e.strictObject({
322
+ status: e.literal("conflict"),
323
+ operationId: g,
324
+ conflictId: g,
325
+ conflictRevision: _
326
+ })
327
+ ]);
328
+ //#endregion
329
+ //#region ../pstdio-sync-contracts/src/replay.ts
330
+ var xe = e.strictObject({
331
+ protocolVersion: e.literal(1),
332
+ scope: le,
333
+ after: b,
334
+ through: b,
335
+ groups: e.array(be)
336
+ }).superRefine((e, t) => {
337
+ let n = e.after.epoch === e.through.epoch, r = e.through.sequence - e.after.sequence === e.groups.length, i = e.groups.every((t, n) => t.status === "accepted" && t.checkpoint?.epoch === e.through.epoch && t.checkpoint.sequence === e.after.sequence + n + 1 && ge(t.mutation.scope) === ge(e.scope)), a = new Set(e.groups.map((e) => e.operationId)).size === e.groups.length;
338
+ (!n || !r || !i || !a) && t.addIssue({
339
+ code: "custom",
340
+ message: "Replay must contain contiguous complete accepted groups in one scope and epoch"
341
+ });
342
+ });
343
+ e.enum([
344
+ "initialize",
345
+ "snapshot",
346
+ "replay",
347
+ "submit",
348
+ "recover",
349
+ "changes",
350
+ "assets/begin",
351
+ "assets/part",
352
+ "assets/finish",
353
+ "assets/cancel",
354
+ "assets/read"
355
+ ]), e.strictObject({
356
+ mutation: me,
357
+ proof: v
358
+ }), e.strictObject({
359
+ workbenchId: g,
360
+ extensionId: g
361
+ }), e.discriminatedUnion("status", [e.strictObject({
362
+ status: e.literal("replay"),
363
+ batch: xe
364
+ }), e.strictObject({
365
+ status: e.literal("snapshot-required"),
366
+ checkpoint: b
367
+ })]);
368
+ var Se = e.number().int().nonnegative().max(2 ** 53 - 1);
369
+ e.strictObject({
370
+ uploadId: g,
371
+ asset: y
372
+ }), e.strictObject({ uploadId: g }), e.strictObject({
373
+ uploadId: g,
374
+ number: e.number().int().min(1).max(1e4),
375
+ sha256: v,
376
+ byteLength: Se
377
+ }), e.strictObject({
378
+ asset: y,
379
+ offset: Se
380
+ }).refine(({ asset: e, offset: t }) => t <= e.byteLength, "Offset exceeds the asset"), e.strictObject({
381
+ asset: y,
382
+ partSize: e.number().int().positive(),
383
+ completed: e.boolean(),
384
+ parts: e.array(e.strictObject({
385
+ number: e.number().int().positive(),
386
+ sha256: v,
387
+ byteLength: Se
388
+ }))
389
+ }), e.strictObject({
390
+ protocolVersion: e.literal(1),
391
+ type: e.enum(["ready", "changed"])
392
+ }), e.strictObject({ publishedRevision: g });
393
+ //#endregion
394
+ //#region ../pstdio-api-contracts/src/assets.ts
395
+ var Ce = y;
396
+ e.strictObject({
397
+ workbenchId: g,
398
+ extensionId: g
399
+ }), e.discriminatedUnion("status", [
400
+ e.strictObject({
401
+ status: e.literal("staging"),
402
+ operationId: g,
403
+ expected: Ce,
404
+ uploadedByteLength: _
405
+ }),
406
+ e.strictObject({
407
+ status: e.literal("complete"),
408
+ operationId: g,
409
+ asset: Ce
410
+ }),
411
+ e.strictObject({
412
+ status: e.literal("cancelled"),
413
+ operationId: g,
414
+ expected: Ce
415
+ })
416
+ ]);
417
+ //#endregion
418
+ //#region ../pstdio-api-contracts/src/extensions/common.ts
419
+ var x = e.record(e.string(), e.unknown()), S = e.record(e.string(), e.json()).meta({
420
+ type: "object",
421
+ additionalProperties: !0
422
+ }), we = e.object({
423
+ $l10n: e.string(),
424
+ default: e.string().optional()
425
+ }), C = e.union([e.string(), we]), Te = e.enum(["global", "project"]), Ee = e.enum([
426
+ "boolean",
427
+ "number",
428
+ "string",
429
+ "array",
430
+ "object"
431
+ ]), De = e.enum(["stored", "default"]), Oe = e.enum([
432
+ "info",
433
+ "warning",
434
+ "error"
435
+ ]), ke = e.object({
436
+ code: e.string(),
437
+ severity: Oe,
438
+ message: e.string(),
439
+ extensionId: e.string().optional(),
440
+ commandId: e.string().optional(),
441
+ sourcePath: e.string().optional(),
442
+ metadata: x.optional()
443
+ }), Ae = e.object({
444
+ id: e.string(),
445
+ name: e.string(),
446
+ displayName: e.string(),
447
+ extensionInstanceId: e.string().optional(),
448
+ installedExtensionId: e.string().optional(),
449
+ installName: e.string().optional(),
450
+ version: e.string().optional(),
451
+ description: e.string().optional(),
452
+ sourcePath: e.string()
453
+ }), je = e.object({
454
+ kind: e.literal("package-asset"),
455
+ path: e.string(),
456
+ baseUrl: e.string()
457
+ }), Me = e.enum([
458
+ "first",
459
+ "default",
460
+ "last"
461
+ ]), Ne = e.enum([
462
+ "menu",
463
+ "panel",
464
+ "settings",
465
+ "renderer",
466
+ "kanbanRenderer",
467
+ "dataTableRenderer"
468
+ ]), Pe = e.enum([
469
+ "cli",
470
+ "dashboard",
471
+ "api",
472
+ "schedule",
473
+ "event",
474
+ "automation",
475
+ "command-panel"
476
+ ]), Fe = e.object({
477
+ mode: e.union([e.string(), e.array(e.string())]).optional(),
478
+ source: e.array(Pe).optional(),
479
+ viewId: e.union([e.string(), e.array(e.string())]).optional(),
480
+ resourceType: e.array(e.string()).optional(),
481
+ metadata: x.optional()
482
+ }), Ie = e.object({
483
+ entry: je,
484
+ title: C.optional(),
485
+ capabilities: e.array(e.string()).optional()
486
+ }), Le = Ie.extend({
487
+ runtimeUrl: e.string(),
488
+ moduleUrl: e.string(),
489
+ styles: e.array(e.string()).optional()
490
+ }), Re = e.object({
491
+ id: e.string(),
492
+ extensionId: e.string(),
493
+ title: C,
494
+ description: C.optional(),
495
+ format: e.literal("vscode-color-theme"),
496
+ mode: e.enum(["light", "dark"]),
497
+ source: je,
498
+ tokens: e.record(e.string(), e.string()),
499
+ monacoTheme: e.object({
500
+ base: e.enum(["vs", "vs-dark"]),
501
+ inherit: e.literal(!0),
502
+ rules: e.array(e.record(e.string(), e.unknown())),
503
+ colors: e.record(e.string(), e.string())
504
+ })
505
+ }), ze = e.object({
506
+ id: e.string(),
507
+ extensionId: e.string(),
508
+ title: C,
509
+ description: C.optional(),
510
+ format: e.literal("vscode-file-icon-theme"),
511
+ source: je,
512
+ definitions: x,
513
+ fileExtensions: e.record(e.string(), e.string()),
514
+ fileNames: e.record(e.string(), e.string()),
515
+ defaults: e.object({
516
+ file: e.string().optional(),
517
+ folder: e.string().optional()
518
+ }).default({}),
519
+ fonts: e.array(e.object({
520
+ fontFamily: e.string(),
521
+ src: e.array(e.object({
522
+ url: e.string(),
523
+ format: e.string().optional()
524
+ })),
525
+ weight: e.string().optional(),
526
+ style: e.string().optional()
527
+ })).default([])
528
+ }), Be = e.object({
529
+ extensionId: e.string(),
530
+ defaultLocale: e.string(),
531
+ bundles: e.record(e.string(), e.record(e.string(), e.string()))
532
+ }), Ve = e.object({
533
+ id: e.string(),
534
+ extensionId: e.string(),
535
+ relativePath: e.string(),
536
+ fullPath: e.string(),
537
+ label: C,
538
+ watch: e.boolean()
539
+ }), He = ["workbench.nav.actions", "workbench.nav.overflow"], Ue = [
540
+ "workbench.left.tree",
541
+ "workbench.main.left.tree",
542
+ "workbench.main.right.tree"
543
+ ], We = [
544
+ "nav",
545
+ "activity",
546
+ "sidenav",
547
+ "main-header",
548
+ "main",
549
+ "secondary-header",
550
+ "secondary",
551
+ "side-header",
552
+ "side",
553
+ "status",
554
+ "overlay"
555
+ ], Ge = [
556
+ "workbench.main",
557
+ "workbench.main.left",
558
+ "workbench.main.right",
559
+ "workbench.secondary"
560
+ ], Ke = ["workbench.settings"], qe = ["project", "global"], Je = [
561
+ "workbench.left",
562
+ "workbench.main.left",
563
+ "workbench.main",
564
+ "workbench.main.right",
565
+ "workbench.secondary"
566
+ ], Ye = e.enum(He), Xe = e.enum(Ue);
567
+ e.enum(We);
568
+ var Ze = e.enum(Ge), Qe = e.enum(Ke);
569
+ e.enum(Je);
570
+ var $e = e.union([
571
+ Ye,
572
+ Xe,
573
+ Ze,
574
+ Qe
575
+ ]), et = e.enum(qe), tt = e.object({
576
+ type: e.string(),
577
+ description: C.optional()
578
+ }).catchall(e.unknown()), nt = e.object({
579
+ id: e.string(),
580
+ extensionId: e.string(),
581
+ title: C,
582
+ description: C.optional(),
583
+ cliPath: e.string().optional(),
584
+ cliAliases: e.array(e.string()).optional(),
585
+ examples: e.array(e.string()).optional(),
586
+ automation: e.boolean().optional(),
587
+ mutating: e.boolean().optional(),
588
+ resourceMutation: e.discriminatedUnion("kind", [e.object({
589
+ kind: e.literal("rename"),
590
+ resourceType: e.string(),
591
+ idParam: e.string(),
592
+ labelParam: e.string()
593
+ }), e.object({
594
+ kind: e.literal("remove"),
595
+ resourceType: e.string(),
596
+ idParam: e.string()
597
+ })]).optional(),
598
+ params: e.record(e.string(), tt).optional()
599
+ }), rt = e.record(e.string(), tt), it = e.object({
600
+ id: e.string(),
601
+ extensionId: e.string(),
602
+ commandId: e.string()
603
+ }), at = e.object({
604
+ id: e.string(),
605
+ extensionId: e.string(),
606
+ eventId: e.string()
607
+ }), ot = e.object({
608
+ id: e.string(),
609
+ extensionId: e.string(),
610
+ cron: e.string(),
611
+ commandId: e.string()
612
+ }), st = e.object({
613
+ id: e.string(),
614
+ localId: e.string(),
615
+ extensionId: e.string(),
616
+ extensionInstanceId: e.string().optional(),
617
+ title: C,
618
+ cron: e.string(),
619
+ commandId: e.string(),
620
+ enabled: e.boolean()
621
+ }), ct = e.object({
622
+ id: e.string(),
623
+ extensionId: e.string(),
624
+ commandId: e.string(),
625
+ slotId: e.string(),
626
+ target: Ye.optional(),
627
+ label: C,
628
+ group: e.string().optional(),
629
+ placement: Me.optional(),
630
+ icon: e.string().optional(),
631
+ presentation: e.enum([
632
+ "menu-item",
633
+ "button",
634
+ "icon-button"
635
+ ]).optional(),
636
+ params: x.optional(),
637
+ when: Fe.optional(),
638
+ disabledWhen: Fe.optional(),
639
+ disabledReason: C.optional()
640
+ }), lt = e.object({
641
+ id: e.string(),
642
+ extensionId: e.string(),
643
+ commandId: e.string(),
644
+ label: C,
645
+ group: e.string().optional(),
646
+ placement: Me.optional(),
647
+ icon: e.string().optional(),
648
+ params: x.optional(),
649
+ when: Fe.optional()
650
+ }), ut = e.object({
651
+ version: e.number().int().positive(),
652
+ since: e.string().optional()
653
+ }), dt = e.object({
654
+ host: e.literal("dashboard"),
655
+ hostVersion: e.string(),
656
+ capabilities: e.record(e.string(), ut)
657
+ }), ft = e.object({
658
+ status: e.enum(["verified", "unverified"]),
659
+ host: dt.optional(),
660
+ diagnostics: e.array(ke)
661
+ }), pt = [
662
+ "sidenav",
663
+ "main",
664
+ "secondary",
665
+ "side"
666
+ ], mt = [
667
+ "main",
668
+ "secondary",
669
+ "side"
670
+ ], ht = e.object({
671
+ id: e.string(),
672
+ localId: e.string(),
673
+ extensionId: e.string(),
674
+ label: C,
675
+ authType: e.enum(["bearer", "header"]),
676
+ supportsCheck: e.boolean()
677
+ }), gt = e.object({
678
+ id: e.string(),
679
+ extensionId: e.string(),
680
+ connectionId: e.string(),
681
+ baseUrl: e.string(),
682
+ authType: e.enum(["bearer", "header"]),
683
+ configured: e.boolean(),
684
+ lastCheck: e.object({
685
+ ok: e.boolean(),
686
+ status: e.number().int().nullable(),
687
+ error: e.string().nullable(),
688
+ checkedAt: e.string()
689
+ }).nullable(),
690
+ updatedAt: e.string()
691
+ });
692
+ e.object({
693
+ baseUrl: e.url(),
694
+ secret: e.string().optional()
695
+ }), e.object({ connections: e.array(gt) });
696
+ //#endregion
697
+ //#region ../pstdio-api-contracts/src/extension-kernel/navigation-href.ts
698
+ var _t = (e) => {
699
+ if (typeof e != "string") return !1;
700
+ try {
701
+ let { protocol: t } = new URL(e);
702
+ return t === "https:" || t === "http:";
703
+ } catch {
704
+ return !1;
705
+ }
706
+ }, vt = (e) => {
707
+ if (!e || typeof e != "object" || Array.isArray(e)) return !1;
708
+ let t = e, n = (e) => typeof e == "number" && Number.isSafeInteger(e) && e > 0;
709
+ if (!n(t.line)) return !1;
710
+ for (let e of [
711
+ "column",
712
+ "endLine",
713
+ "endColumn"
714
+ ]) if (t[e] !== void 0 && !n(t[e])) return !1;
715
+ return !(t.endColumn !== void 0 && t.endLine === void 0 || t.endLine !== void 0 && (t.endLine < t.line || t.endLine === t.line && (t.endColumn ?? 1) < (t.column ?? 1)));
716
+ }, yt = /* @__PURE__ */ new Set([
717
+ "resource",
718
+ "section",
719
+ "document",
720
+ "line",
721
+ "column",
722
+ "endLine",
723
+ "endColumn"
724
+ ]), w = (e) => /* @__PURE__ */ Error(`page_param_invalid: ${e}`), bt = (e, t) => JSON.stringify(e) === JSON.stringify(t), xt = (e, t) => e.type === "string[]" ? Array.isArray(t) && t.every((e) => typeof e == "string") : e.type === "string" ? typeof t == "string" && (!e.values || e.values.includes(t)) : e.type === "number" ? typeof t == "number" && Number.isFinite(t) : typeof t == "boolean", St = (e = {}) => {
725
+ if (Object.keys(e).length > 32) throw w("at most 32 params");
726
+ for (let [t, n] of Object.entries(e)) {
727
+ if (t.length > 64 || !/^[a-z][a-z0-9-]*$/.test(t) || yt.has(t)) throw Error(`page_param_reserved: ${t}`);
728
+ if (n.default !== void 0 && !xt(n, n.default)) throw w(t);
729
+ }
730
+ }, Ct = (e, t) => {
731
+ for (let n of Object.keys(t)) if (!Object.hasOwn(e, n)) throw w(n);
732
+ }, wt = (e = {}, t = {}, n = !0) => {
733
+ let r = {};
734
+ n && Ct(e, t);
735
+ for (let i of Object.keys(e)) {
736
+ if (!Object.hasOwn(t, i)) continue;
737
+ let a = t[i], o = e[i];
738
+ if (!xt(o, a)) {
739
+ if (n) throw w(i);
740
+ continue;
741
+ }
742
+ bt(a, o.default) || Array.isArray(a) && !a.length || (r[i] = Array.isArray(a) ? Object.freeze([...a]) : a);
743
+ }
744
+ let i = Object.keys(r).length ? Object.freeze(r) : void 0;
745
+ if (Et(e, i).toString().length > 2048) {
746
+ if (n) throw w("query exceeds 2048 characters");
747
+ return;
748
+ }
749
+ return i;
750
+ }, Tt = (e = {}, t) => {
751
+ let n = {};
752
+ for (let [t, r] of Object.entries(e)) r.default !== void 0 && (n[t] = Array.isArray(r.default) ? Object.freeze([...r.default]) : r.default);
753
+ return Object.freeze({
754
+ ...n,
755
+ ...t
756
+ });
757
+ }, Et = (e = {}, t) => {
758
+ let n = new URLSearchParams();
759
+ for (let r of Object.keys(e)) {
760
+ let e = t?.[r];
761
+ if (e !== void 0) for (let t of Array.isArray(e) ? e : [e]) n.append(r, String(t));
762
+ }
763
+ return n;
764
+ }, Dt = (e = {}, t) => {
765
+ let n = {};
766
+ for (let [r, i] of Object.entries(e)) {
767
+ let e = t.getAll(r);
768
+ if (!e.length || i.type !== "string[]" && e.length !== 1) continue;
769
+ let a = e[0];
770
+ i.type === "string[]" ? n[r] = e : i.type === "number" ? String(Number(a)) === a && (n[r] = Number(a)) : i.type === "boolean" ? (a === "true" || a === "false") && (n[r] = a === "true") : n[r] = a;
771
+ }
772
+ let r = wt(e, n, !1);
773
+ return Et(e, r).toString().length <= 2048 ? r : void 0;
774
+ }, Ot = e.union([
775
+ e.string(),
776
+ e.number(),
777
+ e.boolean(),
778
+ e.array(e.string())
779
+ ]), kt = e.record(e.string(), e.discriminatedUnion("type", [
780
+ e.object({
781
+ type: e.literal("string"),
782
+ default: e.string().optional(),
783
+ values: e.array(e.string()).readonly().optional()
784
+ }).strict(),
785
+ e.object({
786
+ type: e.literal("number"),
787
+ default: e.number().optional()
788
+ }).strict(),
789
+ e.object({
790
+ type: e.literal("boolean"),
791
+ default: e.boolean().optional()
792
+ }).strict(),
793
+ e.object({
794
+ type: e.literal("string[]"),
795
+ default: e.array(e.string()).readonly().optional()
796
+ }).strict()
797
+ ])).superRefine((e, t) => {
798
+ try {
799
+ St(e);
800
+ } catch (e) {
801
+ t.addIssue({
802
+ code: "custom",
803
+ message: String(e)
804
+ });
805
+ }
806
+ }), T = e.object({
807
+ shorthand: e.string().optional(),
808
+ type: e.string(),
809
+ id: e.string(),
810
+ projectId: e.string().optional(),
811
+ label: e.string().optional(),
812
+ icon: e.string().optional(),
813
+ extensionId: e.string().optional(),
814
+ metadata: S.optional()
815
+ }), E = (t) => e.object({
816
+ extensionId: e.string(),
817
+ kind: e.literal(t),
818
+ id: e.string()
819
+ }), At = E("page"), jt = E("placement"), Mt = E("mode"), Nt = E("view"), Pt = E("resource-kind"), Ft = e.object({
820
+ kind: e.literal("page-slot"),
821
+ page: At,
822
+ id: e.string()
823
+ }), It = e.union([jt, Ft]), Lt = e.object({
824
+ command: E("command"),
825
+ params: S.optional()
826
+ }), Rt = e.object({
827
+ line: e.number().int().positive(),
828
+ column: e.number().int().positive().optional(),
829
+ endLine: e.number().int().positive().optional(),
830
+ endColumn: e.number().int().positive().optional()
831
+ }).refine(vt, "Expected ordered source coordinates"), zt = e.object({ anchors: e.array(e.object({
832
+ id: e.string(),
833
+ heading: e.string(),
834
+ occurrence: e.number().int().nonnegative().optional()
835
+ })) }), Bt = e.lazy(() => e.object({
836
+ kind: e.literal("page"),
837
+ page: At,
838
+ resource: T.optional(),
839
+ open: e.enum(["preview", "pin"]).optional(),
840
+ section: zt.optional(),
841
+ position: Rt.optional(),
842
+ params: e.record(e.string(), Ot).optional(),
843
+ parent: Bt.optional()
844
+ }).refine((e) => !(e.position && e.section), "Choose a source position or a heading section")).meta({ id: "WorkbenchMetadataPageTarget" }), Vt = e.union([Bt, e.object({
845
+ kind: e.literal("panel"),
846
+ panel: It,
847
+ resource: T.optional(),
848
+ open: e.enum(["preview", "pin"]).optional()
849
+ })]), Ht = e.union([
850
+ Vt,
851
+ e.object({
852
+ kind: e.literal("command"),
853
+ target: Lt
854
+ }),
855
+ e.object({
856
+ kind: e.literal("href"),
857
+ href: e.string().refine(_t, "Expected an HTTP or HTTPS URL")
858
+ }),
859
+ e.object({
860
+ kind: e.literal("compound"),
861
+ targets: e.array(Vt).min(1)
862
+ })
863
+ ]), Ut = e.object({
864
+ type: e.enum([
865
+ "info",
866
+ "success",
867
+ "warning",
868
+ "error"
869
+ ]),
870
+ title: e.string().optional(),
871
+ message: e.string(),
872
+ metadata: S.optional()
873
+ }), Wt = e.object({
874
+ code: e.string(),
875
+ message: e.string(),
876
+ severity: e.enum([
877
+ "info",
878
+ "warning",
879
+ "error"
880
+ ]),
881
+ extensionId: e.string().optional(),
882
+ commandId: e.string().optional(),
883
+ metadata: S.optional()
884
+ }), Gt = (t) => {
885
+ let n = e.object({
886
+ name: e.string().optional(),
887
+ message: e.string(),
888
+ stack: e.string().optional(),
889
+ cause: t.optional()
890
+ }), r = {
891
+ notices: e.array(Ut).optional(),
892
+ diagnostics: e.array(Wt).optional()
893
+ }, i = {
894
+ ...r,
895
+ ok: e.literal(!1),
896
+ code: e.string().optional(),
897
+ reason: e.string(),
898
+ data: S.optional(),
899
+ cause: t.optional(),
900
+ error: n.optional()
901
+ }, a = Ht;
902
+ return e.discriminatedUnion("status", [
903
+ e.object({
904
+ ...r,
905
+ ok: e.literal(!0),
906
+ status: e.literal("success"),
907
+ value: e.unknown().optional(),
908
+ navigationRequests: e.array(a).optional()
909
+ }).transform((e) => ({
910
+ ...e,
911
+ value: e.value
912
+ })),
913
+ e.object({
914
+ ...i,
915
+ status: e.literal("rejected")
916
+ }),
917
+ e.object({
918
+ ...i,
919
+ status: e.literal("error")
920
+ })
921
+ ]);
922
+ }, Kt = Gt(e.json()), qt = e.object({
923
+ id: e.string(),
924
+ kind: Ne,
925
+ context: x
926
+ }), Jt = e.object({
927
+ target: $e,
928
+ mode: e.string().optional(),
929
+ projectId: e.string().optional(),
930
+ resource: T.optional()
931
+ });
932
+ e.object({
933
+ rendererId: e.string(),
934
+ pageParams: e.record(e.string(), Ot).optional(),
935
+ projectId: e.string().optional(),
936
+ modeId: e.string().optional(),
937
+ resource: T.optional(),
938
+ invocation: e.object({ placement: e.enum(["visible", "background"]) }).optional()
939
+ }), e.object({
940
+ projectId: e.string().min(1),
941
+ workspaceId: e.string().optional(),
942
+ params: x.optional(),
943
+ resource: T.optional(),
944
+ attachment: Jt.optional(),
945
+ slot: qt.optional(),
946
+ source: Pe.optional(),
947
+ metadata: x.optional()
948
+ }), e.object({
949
+ workspaceId: e.string().optional(),
950
+ params: x.optional(),
951
+ resource: T.optional(),
952
+ attachment: Jt.optional(),
953
+ slot: qt.optional(),
954
+ source: Pe.optional(),
955
+ metadata: x.optional()
956
+ }), e.object({
957
+ eventId: e.string().min(1),
958
+ payload: x
959
+ }).strict();
960
+ var Yt = Ht, Xt = e.object({
961
+ ok: e.boolean(),
962
+ status: e.enum([
963
+ "success",
964
+ "rejected",
965
+ "error"
966
+ ]),
967
+ value: e.unknown().optional(),
968
+ navigationRequests: e.array(Yt).optional(),
969
+ code: e.string().optional(),
970
+ reason: e.string().optional(),
971
+ data: x.optional(),
972
+ error: e.object({
973
+ name: e.string().optional(),
974
+ message: e.string(),
975
+ stack: e.string().optional()
976
+ }).optional(),
977
+ notices: e.array(e.object({
978
+ type: e.enum([
979
+ "info",
980
+ "success",
981
+ "warning",
982
+ "error"
983
+ ]),
984
+ title: e.string().optional(),
985
+ message: e.string(),
986
+ metadata: x.optional()
987
+ })).optional(),
988
+ diagnostics: e.array(e.object({
989
+ code: e.string(),
990
+ message: e.string(),
991
+ severity: e.enum([
992
+ "info",
993
+ "warning",
994
+ "error"
995
+ ]),
996
+ extensionId: e.string().optional(),
997
+ commandId: e.string().optional(),
998
+ metadata: x.optional()
999
+ })).optional()
1000
+ }), Zt = {
1001
+ commandId: e.string(),
1002
+ extensionId: e.string(),
1003
+ eventIds: e.array(e.string()).optional()
1004
+ };
1005
+ e.object({
1006
+ ...Zt,
1007
+ outcome: Xt
1008
+ });
1009
+ var Qt = ((t) => e.object({
1010
+ ...Zt,
1011
+ outcome: Gt(t)
1012
+ }))(e.json()), D = {
1013
+ id: e.string(),
1014
+ name: e.string(),
1015
+ description: e.string().optional(),
1016
+ readOnly: e.boolean().optional()
1017
+ }, $t = {
1018
+ min: e.number().optional(),
1019
+ max: e.number().optional(),
1020
+ step: e.number().optional()
1021
+ }, en = e.strictObject({
1022
+ x: e.number(),
1023
+ y: e.number()
1024
+ }), tn = e.tuple([e.number(), e.number()]), nn = e.strictObject({
1025
+ harnessId: e.string().min(1),
1026
+ model: e.string().optional(),
1027
+ params: e.record(e.string(), e.union([e.string(), e.boolean()])).optional()
1028
+ }), rn = e.union([e.string(), e.array(e.string())]), an = e.strictObject({
1029
+ id: e.string(),
1030
+ name: e.string(),
1031
+ icon: e.string().optional(),
1032
+ color: e.string().optional(),
1033
+ description: e.string().optional(),
1034
+ disabled: e.boolean().optional()
1035
+ }), on = {
1036
+ placeholder: e.string().optional(),
1037
+ searchable: e.boolean().optional(),
1038
+ searchPlaceholder: e.string().optional(),
1039
+ emptyText: e.string().optional(),
1040
+ disabled: e.boolean().optional()
1041
+ }, sn = e.strictObject({
1042
+ src: e.string(),
1043
+ alt: e.string()
1044
+ }), cn = e.union([
1045
+ e.string(),
1046
+ e.number(),
1047
+ e.boolean(),
1048
+ e.null()
1049
+ ]), ln = e.union([
1050
+ cn,
1051
+ e.array(cn),
1052
+ sn.extend({ type: e.literal("image") }),
1053
+ e.strictObject({
1054
+ type: e.literal("image-gallery"),
1055
+ images: e.array(sn)
1056
+ })
1057
+ ]), un = e.union([
1058
+ cn,
1059
+ e.array(e.string()),
1060
+ tn,
1061
+ en,
1062
+ nn
1063
+ ]), dn = e.record(e.string(), un), fn = e.discriminatedUnion("type", [
1064
+ e.strictObject({
1065
+ ...D,
1066
+ type: e.literal("harness"),
1067
+ defaultValue: nn
1068
+ }),
1069
+ e.strictObject({
1070
+ ...D,
1071
+ ...$t,
1072
+ type: e.literal("number"),
1073
+ defaultValue: e.number()
1074
+ }),
1075
+ e.strictObject({
1076
+ ...D,
1077
+ type: e.literal("boolean"),
1078
+ defaultValue: e.boolean()
1079
+ }),
1080
+ e.strictObject({
1081
+ ...D,
1082
+ type: e.literal("text"),
1083
+ defaultValue: e.string(),
1084
+ singleLine: e.boolean().optional()
1085
+ }),
1086
+ e.strictObject({
1087
+ ...D,
1088
+ type: e.literal("markdown"),
1089
+ defaultValue: e.string(),
1090
+ placeholder: e.string().optional()
1091
+ }),
1092
+ e.strictObject({
1093
+ ...D,
1094
+ ...on,
1095
+ type: e.literal("selection"),
1096
+ allowCustomValues: e.boolean().optional(),
1097
+ defaultValue: rn,
1098
+ options: e.array(an),
1099
+ multiSelect: e.boolean().optional(),
1100
+ clearable: e.boolean().optional(),
1101
+ group: e.strictObject({
1102
+ id: e.string(),
1103
+ name: e.string(),
1104
+ defaultValue: e.string(),
1105
+ options: e.array(an),
1106
+ ...on
1107
+ }).optional()
1108
+ }),
1109
+ e.strictObject({
1110
+ ...D,
1111
+ type: e.literal("date"),
1112
+ defaultValue: e.string(),
1113
+ min: e.string().optional(),
1114
+ max: e.string().optional()
1115
+ }),
1116
+ e.strictObject({
1117
+ ...D,
1118
+ type: e.literal("color"),
1119
+ defaultValue: e.string()
1120
+ }),
1121
+ e.strictObject({
1122
+ ...D,
1123
+ type: e.literal("readOnly"),
1124
+ value: ln
1125
+ }),
1126
+ e.strictObject({
1127
+ ...D,
1128
+ type: e.literal("resource"),
1129
+ defaultValue: rn,
1130
+ options: e.array(e.strictObject({
1131
+ id: e.string(),
1132
+ name: e.string(),
1133
+ icon: e.string().optional(),
1134
+ color: e.string().optional(),
1135
+ description: e.string().optional(),
1136
+ href: e.string().optional(),
1137
+ ref: T.optional(),
1138
+ copyText: e.string().optional()
1139
+ })),
1140
+ multiSelect: e.boolean().optional(),
1141
+ editable: e.boolean().optional(),
1142
+ placeholder: e.string().optional(),
1143
+ emptyText: e.string().optional()
1144
+ }),
1145
+ e.strictObject({
1146
+ ...D,
1147
+ ...$t,
1148
+ type: e.literal("range"),
1149
+ defaultValue: tn,
1150
+ min: e.number(),
1151
+ max: e.number(),
1152
+ unit: e.string().optional(),
1153
+ markerCount: e.number().optional()
1154
+ }),
1155
+ e.strictObject({
1156
+ ...D,
1157
+ type: e.literal("segmented"),
1158
+ defaultValue: e.string(),
1159
+ variant: e.enum(["default", "dots"]).optional(),
1160
+ options: e.array(e.strictObject({
1161
+ id: e.string(),
1162
+ name: e.string(),
1163
+ icon: e.string().optional(),
1164
+ indicatorColor: e.string().optional()
1165
+ }))
1166
+ }),
1167
+ e.strictObject({
1168
+ ...D,
1169
+ type: e.literal("actions"),
1170
+ defaultValue: e.string().optional(),
1171
+ options: e.array(e.strictObject({
1172
+ id: e.string(),
1173
+ name: e.string(),
1174
+ icon: e.string().optional(),
1175
+ disabled: e.boolean().optional()
1176
+ }))
1177
+ }),
1178
+ e.strictObject({
1179
+ ...D,
1180
+ type: e.literal("anchorGrid"),
1181
+ defaultValue: e.enum([
1182
+ "top-left",
1183
+ "top",
1184
+ "top-right",
1185
+ "left",
1186
+ "center",
1187
+ "right",
1188
+ "bottom-left",
1189
+ "bottom",
1190
+ "bottom-right"
1191
+ ])
1192
+ }),
1193
+ e.strictObject({
1194
+ ...D,
1195
+ ...$t,
1196
+ type: e.literal("vector"),
1197
+ defaultValue: en,
1198
+ coordinateMode: e.enum(["cartesian", "screen"]).optional(),
1199
+ xLabel: e.string().optional(),
1200
+ yLabel: e.string().optional()
1201
+ })
1202
+ ]), pn = e.strictObject({
1203
+ id: e.string(),
1204
+ title: e.string(),
1205
+ description: e.string().optional(),
1206
+ params: e.array(fn),
1207
+ collapsible: e.boolean().optional(),
1208
+ defaultCollapsed: e.boolean().optional()
1209
+ }), mn = e.strictObject({
1210
+ params: e.array(fn).optional(),
1211
+ groups: e.array(pn).optional(),
1212
+ values: dn.optional(),
1213
+ readOnly: e.boolean().optional()
1214
+ }), hn = e.object({
1215
+ id: e.string(),
1216
+ extensionId: e.string(),
1217
+ title: C,
1218
+ icon: e.string().optional(),
1219
+ resourceKind: e.string().optional(),
1220
+ refreshEventIds: e.array(e.string().min(1)).optional(),
1221
+ emptyTitle: C.optional(),
1222
+ emptyDescription: C.optional()
1223
+ }), gn = hn.extend({
1224
+ searchable: e.boolean().optional(),
1225
+ searchPlaceholder: C.optional(),
1226
+ headerHandlerId: e.string().optional(),
1227
+ bodyHandlerId: e.string(),
1228
+ childrenHandlerId: e.string().optional(),
1229
+ moveHandlerId: e.string().optional(),
1230
+ footerHandlerId: e.string().optional(),
1231
+ defaultExpandedSectionIds: e.array(e.string()).optional(),
1232
+ defaultExpandedNodeIds: e.array(e.string()).optional()
1233
+ }), _n = hn.extend({
1234
+ loadHandlerId: e.string(),
1235
+ saveHandlerId: e.string().optional()
1236
+ }), vn = hn.extend({
1237
+ queryHandlerId: e.string(),
1238
+ valueChangeHandlerId: e.string().optional(),
1239
+ applyHandlerId: e.string().optional(),
1240
+ resetHandlerId: e.string().optional(),
1241
+ defaultValues: dn.optional()
1242
+ }), yn = [
1243
+ "is-any-of",
1244
+ "is-none-of",
1245
+ "is-empty",
1246
+ "is-not-empty"
1247
+ ], bn = {
1248
+ boolean: [
1249
+ "is",
1250
+ "is-not",
1251
+ "is-empty",
1252
+ "is-not-empty"
1253
+ ],
1254
+ string: [
1255
+ "contains",
1256
+ "does-not-contain",
1257
+ "is",
1258
+ "is-not",
1259
+ "is-empty",
1260
+ "is-not-empty"
1261
+ ],
1262
+ number: [
1263
+ "is",
1264
+ "is-not",
1265
+ "gt",
1266
+ "gte",
1267
+ "lt",
1268
+ "lte",
1269
+ "is-empty",
1270
+ "is-not-empty"
1271
+ ],
1272
+ date: [
1273
+ "is",
1274
+ "is-before",
1275
+ "is-after",
1276
+ "is-on-or-before",
1277
+ "is-on-or-after",
1278
+ "is-empty",
1279
+ "is-not-empty"
1280
+ ],
1281
+ enum: yn,
1282
+ status: yn,
1283
+ user: yn,
1284
+ "enum-multi": [
1285
+ "has-any-of",
1286
+ "has-all-of",
1287
+ "has-none-of",
1288
+ "is-empty",
1289
+ "is-not-empty"
1290
+ ]
1291
+ }, xn = {
1292
+ conjunction: "and",
1293
+ rules: []
1294
+ }, Sn = [...new Set(Object.values(bn).flat())], Cn = e.enum(Sn), wn = e.object({
1295
+ attributeId: e.string().min(1),
1296
+ condition: Cn,
1297
+ value: e.union([
1298
+ e.boolean(),
1299
+ e.string(),
1300
+ e.number(),
1301
+ e.array(e.string())
1302
+ ]).optional()
1303
+ }), Tn = e.strictObject({
1304
+ conjunction: e.enum(["and", "or"]),
1305
+ rules: e.array(wn)
1306
+ }), O = Tn.extend({ groups: e.array(Tn).optional() }).refine((e) => !e.groups?.length || e.conjunction === "and", { message: "Normal rules and advanced groups combine using AND" }), En = e.object({
1307
+ attributeId: e.string().min(1),
1308
+ direction: e.enum(["asc", "desc"])
1309
+ }), k = e.array(En).max(1, "A view allows only one sort"), Dn = e.object({
1310
+ id: e.string(),
1311
+ label: C,
1312
+ icon: e.string().optional(),
1313
+ presentation: e.enum(["primary", "secondary"]).optional(),
1314
+ params: x.optional(),
1315
+ input: rt.optional(),
1316
+ submitLabel: e.string().optional(),
1317
+ when: e.string().optional(),
1318
+ disabled: e.boolean().optional()
1319
+ }), On = Dn.extend({ commandId: e.string() }), kn = e.object({
1320
+ light: e.string(),
1321
+ dark: e.string(),
1322
+ foreground: e.object({
1323
+ light: e.string(),
1324
+ dark: e.string()
1325
+ }).optional()
1326
+ }), An = e.discriminatedUnion("type", [
1327
+ e.object({ type: e.literal("unique") }),
1328
+ e.object({
1329
+ type: e.literal("histogram"),
1330
+ bins: e.number().int().positive().optional()
1331
+ }),
1332
+ e.object({
1333
+ type: e.literal("top-values"),
1334
+ limit: e.number().int().positive().optional()
1335
+ })
1336
+ ]), jn = e.discriminatedUnion("type", [
1337
+ e.object({ type: e.literal("json") }),
1338
+ e.object({
1339
+ type: e.literal("color-scale"),
1340
+ stops: e.array(e.object({
1341
+ value: e.number(),
1342
+ color: kn
1343
+ }))
1344
+ }),
1345
+ e.object({
1346
+ type: e.literal("categorical-color"),
1347
+ categories: e.array(e.object({
1348
+ value: e.union([
1349
+ e.string(),
1350
+ e.number(),
1351
+ e.boolean(),
1352
+ e.null()
1353
+ ]),
1354
+ color: kn
1355
+ }))
1356
+ })
1357
+ ]), Mn = e.object({
1358
+ id: e.string(),
1359
+ label: C.optional(),
1360
+ type: e.enum([
1361
+ "string",
1362
+ "number",
1363
+ "boolean",
1364
+ "date"
1365
+ ]).optional(),
1366
+ groupable: e.boolean().optional(),
1367
+ filterable: e.boolean().optional(),
1368
+ description: C.optional(),
1369
+ icon: e.string().optional(),
1370
+ hidden: e.boolean().optional(),
1371
+ stat: An.optional(),
1372
+ renderer: jn.optional()
1373
+ }), Nn = e.object({
1374
+ grouping: e.string(),
1375
+ rowNumbers: e.boolean(),
1376
+ wrapRows: e.boolean(),
1377
+ showStats: e.boolean(),
1378
+ hiddenColumns: e.array(e.string()),
1379
+ columnOrder: e.array(e.string())
1380
+ }), Pn = e.object({
1381
+ id: e.string(),
1382
+ title: C,
1383
+ settings: Nn.partial().optional(),
1384
+ filter: O.optional(),
1385
+ sorts: k.optional()
1386
+ }), Fn = e.object({
1387
+ id: e.string(),
1388
+ label: C,
1389
+ icon: e.string().optional(),
1390
+ destructive: e.boolean().optional(),
1391
+ commandId: e.string()
1392
+ }), In = e.object({
1393
+ id: e.string(),
1394
+ label: C,
1395
+ icon: e.string().optional(),
1396
+ destructive: e.boolean().optional(),
1397
+ commandId: e.string()
1398
+ }), Ln = hn.extend({
1399
+ toolbarActions: e.array(On).optional(),
1400
+ columns: e.array(Mn).optional(),
1401
+ queryHandlerId: e.string(),
1402
+ selectionMode: e.enum(["none", "multiple"]).optional(),
1403
+ selectionActions: e.array(In).optional(),
1404
+ rowActions: e.array(Fn).optional(),
1405
+ rowActivationHandlerId: e.string().optional(),
1406
+ initialPageSize: e.number().int().positive().optional(),
1407
+ pageSizeOptions: e.array(e.number().int().positive()).optional(),
1408
+ defaultSettings: Nn.partial().optional(),
1409
+ defaultFilter: O.optional(),
1410
+ defaultSorts: k.optional(),
1411
+ defaultViews: e.array(Pn).optional(),
1412
+ defaultActiveViewId: e.string().optional()
1413
+ }), Rn = e.object({
1414
+ value: e.string(),
1415
+ label: C,
1416
+ color: e.string().optional(),
1417
+ icon: e.string().nullable().optional()
1418
+ }), zn = e.discriminatedUnion("kind", [
1419
+ e.object({
1420
+ kind: e.literal("enum"),
1421
+ options: e.array(Rn)
1422
+ }),
1423
+ e.object({
1424
+ kind: e.literal("enum-multi"),
1425
+ options: e.array(Rn)
1426
+ }),
1427
+ e.object({
1428
+ kind: e.literal("boolean"),
1429
+ legacyValues: e.record(e.string(), e.boolean()).optional()
1430
+ }),
1431
+ e.object({ kind: e.literal("string") }),
1432
+ e.object({ kind: e.literal("date") }),
1433
+ e.object({ kind: e.literal("number") }),
1434
+ e.object({ kind: e.literal("user") })
1435
+ ]), Bn = e.union([e.object({
1436
+ kind: e.literal("badge-list"),
1437
+ itemsAttributeId: e.string()
1438
+ }), e.object({ kind: e.string() }).passthrough().refine((e) => e.kind !== "badge-list")]), Vn = e.object({
1439
+ id: e.string(),
1440
+ label: C,
1441
+ type: zn,
1442
+ filterable: e.boolean().optional(),
1443
+ groupable: e.boolean().optional(),
1444
+ sortable: e.boolean().optional(),
1445
+ displayable: e.boolean().optional(),
1446
+ editable: e.boolean().optional(),
1447
+ display: Bn.optional()
1448
+ }), Hn = e.object({
1449
+ viewMode: e.enum(["board", "list"]),
1450
+ columnGrouping: e.string(),
1451
+ rowGrouping: e.string(),
1452
+ displayProperties: e.array(e.string())
1453
+ }), Un = e.object({
1454
+ id: e.string(),
1455
+ title: C,
1456
+ settings: Hn,
1457
+ filter: O,
1458
+ sorts: k
1459
+ }), Wn = e.object({
1460
+ commandId: e.string(),
1461
+ title: C.optional(),
1462
+ submitLabel: C.optional(),
1463
+ columnParam: e.string().optional(),
1464
+ params: rt.optional(),
1465
+ attributesParam: e.string().optional(),
1466
+ attachments: e.object({
1467
+ commandId: e.string(),
1468
+ resourceParam: e.string(),
1469
+ fileParam: e.string()
1470
+ }).optional(),
1471
+ labels: e.object({
1472
+ cancel: C.optional(),
1473
+ properties: C.optional(),
1474
+ submitError: C.optional(),
1475
+ removeFile: C.optional()
1476
+ }).optional()
1477
+ }), Gn = e.object({
1478
+ id: e.string(),
1479
+ label: C,
1480
+ icon: e.string().optional(),
1481
+ commandId: e.string(),
1482
+ destructive: e.boolean().optional()
1483
+ }), Kn = hn.extend({
1484
+ toolbarActions: e.array(On).optional(),
1485
+ extensionInstanceId: e.string().optional(),
1486
+ attributes: e.array(Vn).optional(),
1487
+ queryHandlerId: e.string(),
1488
+ attributeChangeHandlerId: e.string().optional(),
1489
+ moveHandlerId: e.string().optional(),
1490
+ schemaRefreshEventIds: e.array(e.string()).optional(),
1491
+ columnActionHandlerId: e.string().optional(),
1492
+ createRow: Wn.optional(),
1493
+ rowActions: e.array(Gn).optional(),
1494
+ rowActivationHandlerId: e.string().optional(),
1495
+ defaultSettings: Hn.partial().optional(),
1496
+ defaultFilter: O.optional(),
1497
+ defaultSorts: k.optional(),
1498
+ defaultViews: e.array(Un).optional(),
1499
+ defaultActiveViewId: e.string().optional(),
1500
+ hideToolbar: e.boolean().optional()
1501
+ }), qn = e.object({
1502
+ id: e.string(),
1503
+ extensionId: e.string(),
1504
+ title: C,
1505
+ resourceKind: e.string().optional(),
1506
+ queryHandlerId: e.string(),
1507
+ refreshEventIds: e.array(e.string().min(1)).optional()
1508
+ }), Jn = e.object({
1509
+ key: e.string(),
1510
+ ctrl: e.boolean(),
1511
+ shift: e.boolean(),
1512
+ alt: e.boolean(),
1513
+ meta: e.boolean(),
1514
+ modifiers: e.array(e.string())
1515
+ }), Yn = e.object({
1516
+ id: e.string(),
1517
+ extensionId: e.string(),
1518
+ action: Ht,
1519
+ key: e.string(),
1520
+ canonicalChord: e.string(),
1521
+ parsed: Jn,
1522
+ platformOverrides: e.object({
1523
+ mac: e.string().optional(),
1524
+ linux: e.string().optional(),
1525
+ win: e.string().optional()
1526
+ }).optional(),
1527
+ when: Fe.optional()
1528
+ }), Xn = e.object({
1529
+ mountStrategy: e.enum(["active", "keep-mounted"]).optional(),
1530
+ hiddenByDefault: e.boolean().optional(),
1531
+ headerBorderBottom: e.boolean().optional(),
1532
+ tab: e.object({
1533
+ queryHandlerId: e.string(),
1534
+ refreshEventIds: e.array(e.string()).optional()
1535
+ }).optional()
1536
+ }), Zn = e.enum([
1537
+ "fixed",
1538
+ "open",
1539
+ "closed"
1540
+ ]), Qn = e.object({
1541
+ defaultPx: e.number().optional(),
1542
+ minPx: e.number().optional(),
1543
+ maxPx: e.number().optional()
1544
+ }), $n = e.object({
1545
+ showHeader: e.boolean().optional(),
1546
+ size: Qn.optional(),
1547
+ collapsible: e.boolean().optional(),
1548
+ alwaysShowTabs: e.boolean().optional()
1549
+ }), er = e.object({ kinds: e.array(Pt).min(1) }).strict(), tr = er.extend({
1550
+ view: Nt,
1551
+ cardinality: e.enum(["one", "many"]),
1552
+ add: Ht.optional()
1553
+ }), nr = e.discriminatedUnion("kind", [e.object({
1554
+ kind: e.literal("view"),
1555
+ view: Nt,
1556
+ presence: Zn
1557
+ }).strict(), e.object({
1558
+ kind: e.literal("binding"),
1559
+ binding: tr
1560
+ }).strict()]), rr = e.discriminatedUnion("kind", [Xn.extend({
1561
+ kind: e.literal("view"),
1562
+ view: Nt,
1563
+ cardinality: e.enum(["one", "many"])
1564
+ }).strict(), e.object({
1565
+ kind: e.literal("panels"),
1566
+ empty: Nt
1567
+ }).strict()]), ir = Xn.extend({
1568
+ id: e.string(),
1569
+ region: e.enum([
1570
+ "main",
1571
+ "secondary",
1572
+ "side"
1573
+ ]),
1574
+ order: e.number().optional(),
1575
+ item: nr,
1576
+ openOn: e.literal("page-resource").optional()
1577
+ }).strict(), ar = e.object({
1578
+ id: e.string(),
1579
+ localId: e.string(),
1580
+ extensionId: e.string(),
1581
+ title: C,
1582
+ icon: e.string().optional(),
1583
+ path: e.string(),
1584
+ params: kt.optional(),
1585
+ document: e.object({ metadataKey: e.string().refine((e) => e.trim().length > 0) }).optional(),
1586
+ mode: Mt,
1587
+ parent: At.optional(),
1588
+ resource: er.optional(),
1589
+ main: rr,
1590
+ slots: e.array(ir)
1591
+ }), or = e.object({
1592
+ id: e.string(),
1593
+ extensionId: e.string(),
1594
+ extensionInstanceId: e.string().optional(),
1595
+ installedExtensionId: e.string().optional(),
1596
+ installName: e.string().optional(),
1597
+ slotId: e.string(),
1598
+ target: Qe.optional(),
1599
+ scope: et.optional(),
1600
+ title: C,
1601
+ icon: e.string().optional(),
1602
+ section: e.string().optional(),
1603
+ webview: Ie
1604
+ }), sr = e.object({
1605
+ commandId: e.string(),
1606
+ valueField: e.string(),
1607
+ labelField: e.string(),
1608
+ params: e.record(e.string(), e.unknown()).optional()
1609
+ }), cr = e.object({
1610
+ key: e.string(),
1611
+ extensionId: e.string(),
1612
+ type: Ee,
1613
+ scope: Te,
1614
+ default: e.unknown().optional(),
1615
+ enum: e.array(e.unknown()).optional(),
1616
+ options: sr.optional(),
1617
+ title: C.optional(),
1618
+ description: C.optional()
1619
+ }), lr = cr.extend({
1620
+ value: e.unknown().optional(),
1621
+ source: De
1622
+ });
1623
+ e.object({ settings: e.array(lr) }), e.object({ value: e.unknown() }), or.extend({ webview: Le });
1624
+ var ur = e.object({
1625
+ id: e.string(),
1626
+ extensionId: e.string(),
1627
+ title: C,
1628
+ scope: et.optional(),
1629
+ order: e.number().optional()
1630
+ }), A = (t) => e.object({
1631
+ extensionId: e.string(),
1632
+ kind: e.literal(t),
1633
+ id: e.string()
1634
+ }), j = A("command"), M = A("mode"), dr = A("page"), fr = A("resource-kind"), pr = A("settings-section"), N = A("view"), mr = e.object({
1635
+ mode: e.union([M, e.array(M)]).optional(),
1636
+ source: e.array(e.enum([
1637
+ "cli",
1638
+ "dashboard",
1639
+ "api",
1640
+ "schedule",
1641
+ "event",
1642
+ "automation",
1643
+ "command-panel"
1644
+ ])).optional(),
1645
+ view: e.union([N, e.array(N)]).optional(),
1646
+ resourceType: e.array(fr).optional(),
1647
+ metadata: x.optional()
1648
+ }), hr = {
1649
+ id: !0,
1650
+ extensionId: !0,
1651
+ title: !0,
1652
+ icon: !0
1653
+ }, gr = e.object({
1654
+ id: e.string(),
1655
+ label: C,
1656
+ icon: e.string().optional(),
1657
+ destructive: e.boolean().optional(),
1658
+ command: j
1659
+ }), _r = e.object({
1660
+ command: j,
1661
+ title: C.optional(),
1662
+ submitLabel: C.optional(),
1663
+ columnParam: e.string().optional(),
1664
+ params: e.record(e.string(), e.unknown()).optional(),
1665
+ attributesParam: e.string().optional(),
1666
+ attachments: e.object({
1667
+ command: j,
1668
+ resourceParam: e.string(),
1669
+ fileParam: e.string()
1670
+ }).optional(),
1671
+ labels: e.object({
1672
+ cancel: C.optional(),
1673
+ properties: C.optional(),
1674
+ submitError: C.optional(),
1675
+ removeFile: C.optional()
1676
+ }).optional()
1677
+ }), vr = e.object({
1678
+ kind: e.literal("webview"),
1679
+ webview: Le
1680
+ }), yr = gn.omit(hr).extend({ kind: e.literal("tree") }), br = _n.omit(hr).extend({ kind: e.literal("file") }), xr = vn.omit(hr).extend({ kind: e.literal("controls") }), Sr = Kn.omit({
1681
+ ...hr,
1682
+ createRow: !0,
1683
+ rowActions: !0,
1684
+ toolbarActions: !0
1685
+ }).extend({
1686
+ kind: e.literal("kanban"),
1687
+ createRow: _r.optional(),
1688
+ rowActions: e.array(gr).optional(),
1689
+ toolbarActions: e.array(Dn.extend({ command: j })).optional()
1690
+ }), Cr = Ln.omit({
1691
+ ...hr,
1692
+ selectionActions: !0,
1693
+ rowActions: !0,
1694
+ toolbarActions: !0
1695
+ }).extend({
1696
+ kind: e.literal("dataTable"),
1697
+ selectionActions: e.array(gr).optional(),
1698
+ rowActions: e.array(gr).optional(),
1699
+ toolbarActions: e.array(Dn.extend({ command: j })).optional()
1700
+ }), wr = e.discriminatedUnion("kind", [
1701
+ vr,
1702
+ yr,
1703
+ br,
1704
+ xr,
1705
+ Sr,
1706
+ Cr
1707
+ ]), Tr = e.object({
1708
+ id: e.string(),
1709
+ localId: e.string(),
1710
+ extensionId: e.string(),
1711
+ title: C,
1712
+ icon: e.string().optional(),
1713
+ body: wr
1714
+ }), Er = e.object({
1715
+ id: e.string(),
1716
+ localId: e.string(),
1717
+ extensionId: e.string(),
1718
+ label: C,
1719
+ icon: e.string().optional(),
1720
+ regions: e.array(e.enum(mt)),
1721
+ floatingPanels: e.enum(["visible", "hidden"]).optional(),
1722
+ regionSettings: e.partialRecord(e.enum(pt), $n).optional(),
1723
+ defaultTheme: A("theme").optional(),
1724
+ chrome: e.partialRecord(e.enum([
1725
+ "nav",
1726
+ "sidenav",
1727
+ "activity",
1728
+ "status"
1729
+ ]), e.union([N, e.literal(!1)])).optional()
1730
+ }), Dr = Xn.extend({
1731
+ id: e.string(),
1732
+ localId: e.string(),
1733
+ extensionId: e.string(),
1734
+ mode: M,
1735
+ item: nr,
1736
+ region: e.enum(mt),
1737
+ order: e.number().optional(),
1738
+ movableTo: e.array(e.enum(mt)).optional()
1739
+ }), Or = e.object({
1740
+ id: e.string(),
1741
+ extensionId: e.string(),
1742
+ owner: N,
1743
+ view: N,
1744
+ side: e.enum(["left", "right"]),
1745
+ group: e.string().optional(),
1746
+ placement: e.enum([
1747
+ "first",
1748
+ "default",
1749
+ "last"
1750
+ ]).optional(),
1751
+ hostTreeHeader: e.enum(["default", "none"]).optional(),
1752
+ hostTreeFooter: e.enum(["default", "none"]).optional()
1753
+ }), kr = e.object({
1754
+ id: e.string(),
1755
+ extensionId: e.string(),
1756
+ owner: e.union([M, dr]),
1757
+ slot: e.enum([
1758
+ "header",
1759
+ "content",
1760
+ "footer"
1761
+ ]),
1762
+ label: C,
1763
+ icon: e.string().optional(),
1764
+ group: e.string().optional(),
1765
+ when: mr.optional(),
1766
+ action: Ht
1767
+ }), Ar = e.object({
1768
+ id: e.string(),
1769
+ extensionId: e.string(),
1770
+ owner: e.union([M, dr]),
1771
+ slot: e.enum([
1772
+ "header",
1773
+ "content",
1774
+ "footer"
1775
+ ]),
1776
+ view: N,
1777
+ resourceScope: e.enum(["project", "selection"]).optional()
1778
+ }), jr = e.object({
1779
+ id: e.string(),
1780
+ localId: e.string(),
1781
+ extensionId: e.string(),
1782
+ label: C.optional(),
1783
+ icon: e.string().optional(),
1784
+ resolveCommand: e.string().optional(),
1785
+ resolveManyCommand: e.string().optional(),
1786
+ relatedOpeningsCommand: e.string().optional(),
1787
+ paths: e.array(e.object({
1788
+ prefix: e.string(),
1789
+ resolveCommand: e.string()
1790
+ })).optional(),
1791
+ menuSlots: e.array(e.object({
1792
+ id: e.string(),
1793
+ placement: e.enum([
1794
+ "header-primary",
1795
+ "header-overflow",
1796
+ "context-menu"
1797
+ ]),
1798
+ label: C.optional(),
1799
+ access: e.enum(["owner", "public"]),
1800
+ order: e.number().optional()
1801
+ })).optional()
1802
+ }), Mr = e.object({
1803
+ id: e.string(),
1804
+ extensionId: e.string(),
1805
+ view: N,
1806
+ slot: e.object({ id: e.string() }),
1807
+ section: pr.optional()
1808
+ }), Nr = e.object({
1809
+ id: e.string(),
1810
+ extensionId: e.string(),
1811
+ view: N,
1812
+ slot: e.object({ id: e.string() }),
1813
+ order: e.number().optional(),
1814
+ when: mr.optional()
1815
+ }), Pr = e.object({
1816
+ extensions: e.array(Ae),
1817
+ commands: e.array(nt),
1818
+ menuContributions: e.array(ct),
1819
+ commandPaletteContributions: e.array(lt).optional(),
1820
+ modes: e.array(Er),
1821
+ pages: e.array(ar),
1822
+ views: e.array(Tr),
1823
+ viewMenus: e.array(Or),
1824
+ placements: e.array(Dr),
1825
+ resourceKinds: e.array(jr),
1826
+ resourceHierarchyProviders: e.array(e.object({
1827
+ id: e.string(),
1828
+ extensionId: e.string(),
1829
+ resourceKind: fr
1830
+ })).optional(),
1831
+ navigationItems: e.array(kr),
1832
+ navigationTrees: e.array(Ar),
1833
+ statusBarItems: e.array(Nr),
1834
+ activityItems: e.array(e.object({
1835
+ id: e.string(),
1836
+ extensionId: e.string(),
1837
+ title: C,
1838
+ icon: e.string(),
1839
+ modes: e.array(M),
1840
+ placement: e.enum([
1841
+ "first",
1842
+ "default",
1843
+ "last"
1844
+ ]).optional(),
1845
+ command: j,
1846
+ params: x.optional()
1847
+ })).optional(),
1848
+ settingsSections: e.array(ur).optional(),
1849
+ settingsPanels: e.array(Mr),
1850
+ commandPaletteResources: e.array(qn).optional(),
1851
+ keybindings: e.array(Yn).optional(),
1852
+ settingsDefinitions: e.array(cr).optional(),
1853
+ automations: e.array(st).optional(),
1854
+ connections: e.array(ht).optional(),
1855
+ harnesses: e.array(e.object({
1856
+ id: e.string(),
1857
+ localId: e.string(),
1858
+ extensionId: e.string(),
1859
+ label: C.optional()
1860
+ })).optional(),
1861
+ skills: e.array(e.object({
1862
+ id: e.string(),
1863
+ localId: e.string(),
1864
+ extensionId: e.string(),
1865
+ title: C.optional()
1866
+ })).optional(),
1867
+ templates: e.array(e.object({
1868
+ id: e.string(),
1869
+ localId: e.string(),
1870
+ extensionId: e.string(),
1871
+ title: C.optional()
1872
+ })).optional(),
1873
+ templateTypes: e.array(e.object({
1874
+ id: e.string(),
1875
+ localId: e.string(),
1876
+ extensionId: e.string(),
1877
+ label: C,
1878
+ description: C.optional(),
1879
+ order: e.number().optional(),
1880
+ commands: e.object({
1881
+ list: e.string(),
1882
+ read: e.string(),
1883
+ save: e.string(),
1884
+ delete: e.string()
1885
+ }).optional()
1886
+ })).optional(),
1887
+ themes: e.array(e.object({
1888
+ id: e.string(),
1889
+ localId: e.string(),
1890
+ extensionId: e.string(),
1891
+ title: C.optional()
1892
+ })).optional(),
1893
+ diagnostics: e.array(ke)
1894
+ }), Fr = e.object({
1895
+ id: e.string(),
1896
+ extensionId: e.string()
1897
+ }), Ir = Pr.pick({
1898
+ extensions: !0,
1899
+ commands: !0,
1900
+ menuContributions: !0,
1901
+ commandPaletteContributions: !0,
1902
+ modes: !0,
1903
+ pages: !0,
1904
+ views: !0,
1905
+ viewMenus: !0,
1906
+ placements: !0,
1907
+ resourceKinds: !0,
1908
+ resourceHierarchyProviders: !0,
1909
+ navigationItems: !0,
1910
+ navigationTrees: !0,
1911
+ statusBarItems: !0,
1912
+ activityItems: !0,
1913
+ settingsSections: !0,
1914
+ settingsPanels: !0,
1915
+ commandPaletteResources: !0,
1916
+ keybindings: !0,
1917
+ settingsDefinitions: !0,
1918
+ diagnostics: !0
1919
+ }).extend({
1920
+ extensionsRoot: e.string(),
1921
+ extensionsRootExists: e.boolean(),
1922
+ errorCount: e.number().int().nonnegative(),
1923
+ warningCount: e.number().int().nonnegative(),
1924
+ middlewares: e.array(it),
1925
+ hooks: e.array(at),
1926
+ schedules: e.array(ot),
1927
+ artifactMounts: e.array(Ve),
1928
+ themes: e.array(Re),
1929
+ fileIconThemes: e.array(ze),
1930
+ templates: e.array(Fr),
1931
+ skills: e.array(Fr),
1932
+ hostCompatibility: ft
1933
+ });
1934
+ e.object({
1935
+ commands: Pr.shape.commands,
1936
+ translations: e.array(Be).optional(),
1937
+ diagnostics: Pr.shape.diagnostics
1938
+ }), e.object({
1939
+ themes: e.array(Re),
1940
+ fileIconThemes: e.array(ze),
1941
+ translations: e.array(Be),
1942
+ diagnostics: Pr.shape.diagnostics
1943
+ });
1944
+ //#endregion
1945
+ //#region ../pstdio-api-contracts/src/extension-kernel/types/data-table-renderer.ts
1946
+ var Lr = {
1947
+ grouping: "none",
1948
+ rowNumbers: !0,
1949
+ wrapRows: !1,
1950
+ showStats: !0,
1951
+ hiddenColumns: [],
1952
+ columnOrder: []
1953
+ }, Rr = {
1954
+ viewMode: "board",
1955
+ columnGrouping: "none",
1956
+ rowGrouping: "none",
1957
+ displayProperties: []
1958
+ }, zr = (e, t) => {
1959
+ let n = {
1960
+ ...e,
1961
+ ...t.defaultSettings
1962
+ };
1963
+ return t.defaultViews?.length ? {
1964
+ settings: n,
1965
+ views: t.defaultViews.map((e) => ({
1966
+ ...e,
1967
+ settings: {
1968
+ ...n,
1969
+ ...e.settings
1970
+ },
1971
+ filter: e.filter ?? xn,
1972
+ sorts: e.sorts ?? [],
1973
+ builtIn: !0
1974
+ }))
1975
+ } : {
1976
+ settings: n,
1977
+ views: [{
1978
+ id: "default",
1979
+ title: "All",
1980
+ settings: n,
1981
+ filter: t.defaultFilter ?? xn,
1982
+ sorts: t.defaultSorts ?? [],
1983
+ builtIn: !0
1984
+ }]
1985
+ };
1986
+ }, Br = (e) => zr(Rr, e), Vr = (e) => zr(Lr, e);
1987
+ e.object({
1988
+ displayName: e.string(),
1989
+ extensionId: e.string(),
1990
+ manifest: x,
1991
+ name: e.string(),
1992
+ sourceHash: e.string().nullable().optional(),
1993
+ sourceKind: e.enum([
1994
+ "local_path",
1995
+ "git",
1996
+ "registry"
1997
+ ]),
1998
+ sourcePath: e.string(),
1999
+ sourceRef: e.string().nullable().optional(),
2000
+ version: e.string().nullable().optional()
2001
+ }), e.object({
2002
+ enabled: e.literal(!0),
2003
+ installName: e.string(),
2004
+ installedExtensionId: e.string(),
2005
+ instanceId: e.string(),
2006
+ name: e.string(),
2007
+ projectId: e.string()
2008
+ });
2009
+ var Hr = e.object({
2010
+ id: e.string(),
2011
+ projectId: e.string(),
2012
+ extensionId: e.string(),
2013
+ installedExtensionId: e.string(),
2014
+ installName: e.string(),
2015
+ name: e.string(),
2016
+ displayName: e.string(),
2017
+ version: e.string().nullable().optional(),
2018
+ description: e.string().optional(),
2019
+ sourcePath: e.string(),
2020
+ scope: e.enum(["repo", "global"]),
2021
+ status: e.enum([
2022
+ "pending",
2023
+ "loaded",
2024
+ "error",
2025
+ "missing",
2026
+ "disabled"
2027
+ ]),
2028
+ lastLoadedAt: e.string().nullable().optional(),
2029
+ lastError: x.nullable().optional(),
2030
+ enabled: e.boolean(),
2031
+ config: e.record(e.string(), e.unknown()),
2032
+ canUpgrade: e.boolean(),
2033
+ updateAvailable: e.boolean()
2034
+ }), Ur = e.object({
2035
+ installName: e.string(),
2036
+ displayName: e.string(),
2037
+ description: e.string(),
2038
+ installed: e.boolean(),
2039
+ origin: e.object({
2040
+ kind: e.literal("git"),
2041
+ url: e.string(),
2042
+ path: e.string(),
2043
+ ref: e.string()
2044
+ }),
2045
+ publisher: e.string().optional()
2046
+ });
2047
+ e.object({
2048
+ extensions: e.array(Hr),
2049
+ marketplace: e.array(Ur)
2050
+ }), e.object({ enabled: e.boolean() }), e.object({ enabled: e.boolean() }), e.object({
2051
+ changed: e.boolean(),
2052
+ extension: Hr
2053
+ }), e.object({ extension: Hr }), e.object({
2054
+ name: e.string().min(1),
2055
+ files: e.preprocess((e) => Array.isArray(e) ? e : [e], e.array(e.instanceof(File).meta({
2056
+ type: "string",
2057
+ format: "binary"
2058
+ })).min(1))
2059
+ }), e.object({ extension: Hr }), e.object({
2060
+ extensionId: e.string(),
2061
+ name: e.string(),
2062
+ installName: e.string(),
2063
+ installedSkills: e.array(e.object({
2064
+ id: e.string(),
2065
+ extensionId: e.string(),
2066
+ skillKey: e.string(),
2067
+ installedAgents: e.array(e.string())
2068
+ }))
2069
+ });
2070
+ //#endregion
2071
+ //#region ../pstdio-api-contracts/src/extensions/installation.ts
2072
+ var Wr = e.string().min(1).refine((e) => e !== "." && e !== ".." && !/[\\/:]/.test(e) && e.trim().length > 0, "Install name must be one folder name.");
2073
+ e.object({
2074
+ source: e.discriminatedUnion("kind", [e.object({
2075
+ kind: e.literal("catalog"),
2076
+ name: e.string().min(1),
2077
+ ref: e.string().min(1).optional()
2078
+ }).strict(), e.object({
2079
+ kind: e.literal("project-folder"),
2080
+ path: e.string().min(1),
2081
+ development: e.boolean().optional()
2082
+ }).strict()]),
2083
+ installName: Wr.optional(),
2084
+ force: e.boolean().optional(),
2085
+ skipInstall: e.boolean().optional()
2086
+ }).strict();
2087
+ var Gr = e.enum(["true", "false"]).optional().transform((e) => e === "true");
2088
+ e.object({
2089
+ kind: e.literal("upload"),
2090
+ installName: Wr.optional(),
2091
+ folderName: Wr,
2092
+ files: e.preprocess((e) => Array.isArray(e) ? e : [e], e.array(e.instanceof(File).meta({
2093
+ type: "string",
2094
+ format: "binary"
2095
+ })).min(1)),
2096
+ force: Gr,
2097
+ skipInstall: Gr,
2098
+ development: Gr
2099
+ }).strict();
2100
+ var Kr = e.object({
2101
+ check: Ir,
2102
+ installName: e.string(),
2103
+ manifest: e.record(e.string(), e.unknown()),
2104
+ metadata: e.object({
2105
+ id: e.string(),
2106
+ name: e.string(),
2107
+ displayName: e.string(),
2108
+ version: e.string(),
2109
+ description: e.string().optional(),
2110
+ enginesPstdio: e.string()
2111
+ }),
2112
+ source: e.discriminatedUnion("kind", [e.object({
2113
+ kind: e.literal("local"),
2114
+ path: e.string(),
2115
+ ref: e.string().optional()
2116
+ }), e.object({
2117
+ kind: e.literal("named"),
2118
+ name: e.string(),
2119
+ ref: e.string()
2120
+ })]),
2121
+ sourceHash: e.string(),
2122
+ targetPath: e.string()
2123
+ });
2124
+ e.object({
2125
+ source: Kr,
2126
+ extension: Hr
2127
+ }), e.object({ roots: e.array(e.object({
2128
+ scope: e.enum(["repo", "user"]),
2129
+ path: e.string(),
2130
+ check: Ir
2131
+ })) });
2132
+ //#endregion
2133
+ //#region ../pstdio-api-contracts/src/extensions/related-resource-opening.ts
2134
+ var qr = e.object({
2135
+ resource: T,
2136
+ autoOpen: e.boolean().optional(),
2137
+ region: e.enum(mt),
2138
+ open: e.enum(["preview", "pin"]).optional()
2139
+ }), Jr = e.enum([
2140
+ "queued",
2141
+ "running",
2142
+ "succeeded",
2143
+ "failed",
2144
+ "cancelled",
2145
+ "rejected"
2146
+ ]);
2147
+ e.object({
2148
+ name: e.string().trim().min(1).max(120),
2149
+ projectId: e.string().min(1),
2150
+ principalId: e.string().uuid().optional(),
2151
+ commandScopes: e.array(e.string().min(1)).min(1),
2152
+ expiresInSeconds: e.number().int().positive().max(31536e3)
2153
+ }).strict();
2154
+ var Yr = e.object({
2155
+ id: e.string(),
2156
+ principalId: e.string(),
2157
+ name: e.string(),
2158
+ tokenPrefix: e.string(),
2159
+ projectId: e.string(),
2160
+ commandScopes: e.array(e.string()),
2161
+ expiresAt: e.string(),
2162
+ lastUsedAt: e.string().nullable(),
2163
+ revokedAt: e.string().nullable(),
2164
+ createdAt: e.string()
2165
+ });
2166
+ Yr.extend({ token: e.string() }), e.object({ tokens: e.array(Yr) }), e.object({
2167
+ commandId: e.string().min(1),
2168
+ input: e.object({
2169
+ workspaceId: e.string().optional(),
2170
+ params: x.optional(),
2171
+ resource: T.optional(),
2172
+ metadata: x.optional()
2173
+ }).strict()
2174
+ }).strict();
2175
+ var Xr = e.object({
2176
+ code: e.string(),
2177
+ message: e.string(),
2178
+ retryable: e.boolean()
2179
+ });
2180
+ e.object({
2181
+ id: e.string(),
2182
+ projectId: e.string(),
2183
+ commandId: e.string(),
2184
+ status: Jr,
2185
+ createdAt: e.string(),
2186
+ startedAt: e.string().nullable(),
2187
+ finishedAt: e.string().nullable(),
2188
+ result: e.unknown().nullable(),
2189
+ error: Xr.nullable()
2190
+ });
2191
+ var Zr = e.object({
2192
+ cursor: e.number().int().nonnegative(),
2193
+ runId: e.string(),
2194
+ type: e.string(),
2195
+ payload: x,
2196
+ createdAt: e.string()
2197
+ });
2198
+ e.object({ events: e.array(Zr) });
2199
+ //#endregion
2200
+ //#region ../pstdio-api-contracts/src/board-views.ts
2201
+ var Qr = e.object({
2202
+ id: e.string(),
2203
+ label: e.string(),
2204
+ kind: e.enum([
2205
+ "enum",
2206
+ "enum-multi",
2207
+ "status",
2208
+ "string",
2209
+ "date",
2210
+ "number",
2211
+ "boolean",
2212
+ "user"
2213
+ ]),
2214
+ conditions: e.array(Cn),
2215
+ filterable: e.boolean(),
2216
+ groupable: e.boolean(),
2217
+ sortable: e.boolean(),
2218
+ displayable: e.boolean(),
2219
+ legacyValues: e.record(e.string(), e.boolean()).optional(),
2220
+ options: e.array(e.object({
2221
+ value: e.string(),
2222
+ label: e.string()
2223
+ })).optional()
2224
+ });
2225
+ e.object({
2226
+ id: e.string(),
2227
+ title: e.string(),
2228
+ kind: e.enum(["kanban", "dataTable"]),
2229
+ extensionId: e.string().nullable(),
2230
+ fields: e.array(Qr)
2231
+ });
2232
+ var $r = e.union([Hn, Nn]), ei = e.object({
2233
+ id: e.string(),
2234
+ boardId: e.string(),
2235
+ title: e.string(),
2236
+ settings: $r,
2237
+ filter: O,
2238
+ sorts: k,
2239
+ builtIn: e.boolean()
2240
+ });
2241
+ e.object({
2242
+ views: e.array(ei),
2243
+ defaultViewId: e.string()
2244
+ }), e.object({
2245
+ title: e.string().trim().min(1).optional(),
2246
+ settings: e.union([Hn.partial().strict(), Nn.partial().strict()]).optional(),
2247
+ filter: O.optional(),
2248
+ sorts: k.optional()
2249
+ }).strict().extend({
2250
+ title: e.string().trim().min(1),
2251
+ copyFrom: e.string().optional()
2252
+ });
2253
+ //#endregion
2254
+ //#region ../pstdio-api-contracts/src/projects.ts
2255
+ var ti = e.object({
2256
+ provider_id: e.string().min(1),
2257
+ params: S.default({})
2258
+ }), ni = e.object({
2259
+ code: e.literal("extension_setup_failed"),
2260
+ extension: e.string(),
2261
+ message: e.string()
2262
+ });
2263
+ e.object({
2264
+ id: e.string(),
2265
+ name: e.string(),
2266
+ shorthand: e.string(),
2267
+ default_agent_id: e.string().nullable(),
2268
+ default_agent_model: e.string().nullable(),
2269
+ startup_script: e.string().nullable(),
2270
+ created_at: e.string(),
2271
+ updated_at: e.string(),
2272
+ deleted_at: e.string().nullable(),
2273
+ extension_warnings: e.array(ni).optional()
2274
+ });
2275
+ var ri = e.object({
2276
+ name: e.string().trim().min(1).optional(),
2277
+ initial_workspace: ti,
2278
+ agents: e.array(e.string().min(1)).min(1).optional()
2279
+ });
2280
+ e.object({
2281
+ name: e.string().trim().min(1).optional(),
2282
+ default_agent_id: e.string().min(1).nullable().optional(),
2283
+ default_agent_model: e.string().min(1).nullable().optional()
2284
+ }).refine((e) => Object.keys(e).length > 0, { message: "At least one field must be provided" }), e.object({
2285
+ id: e.string(),
2286
+ name: e.string(),
2287
+ shorthand: e.string(),
2288
+ defaultAgentId: e.string().nullable(),
2289
+ defaultAgentModel: e.string().nullable(),
2290
+ startupScript: e.string().nullable(),
2291
+ createdAt: e.string(),
2292
+ updatedAt: e.string(),
2293
+ deletedAt: e.string().nullable(),
2294
+ extensionWarnings: e.array(ni).optional()
2295
+ });
2296
+ var ii = e.object({
2297
+ providerId: e.string().min(1),
2298
+ params: S.default({})
2299
+ });
2300
+ ri.omit({ initial_workspace: !0 }).extend({ initialWorkspace: ii }), e.object({
2301
+ name: e.string().trim().min(1).optional(),
2302
+ defaultAgentId: e.string().min(1).nullable().optional(),
2303
+ defaultAgentModel: e.string().min(1).nullable().optional()
2304
+ }).strict().refine((e) => Object.keys(e).length > 0, { message: "At least one field must be provided" });
2305
+ //#endregion
2306
+ //#region ../pstdio-api-contracts/src/workspaces.ts
2307
+ var ai = {
2308
+ version: e.number().int().positive(),
2309
+ data: x
2310
+ }, oi = e.object(ai), si = e.enum([
2311
+ "provisioning",
2312
+ "ready",
2313
+ "failed",
2314
+ "cancelled",
2315
+ "archiving",
2316
+ "archived",
2317
+ "deleting",
2318
+ "provider_missing"
2319
+ ]), ci = e.enum(["local", "remote"]), li = e.object({
2320
+ files: e.enum([
2321
+ "none",
2322
+ "read",
2323
+ "write"
2324
+ ]),
2325
+ diff: e.boolean(),
2326
+ merge: e.boolean(),
2327
+ rebase: e.boolean(),
2328
+ delete: e.boolean()
2329
+ }), ui = e.object({
2330
+ code: e.string(),
2331
+ message: e.string(),
2332
+ retryable: e.boolean(),
2333
+ occurred_at: e.string()
2334
+ });
2335
+ e.string(), e.boolean(), e.string(), e.string().nullable(), e.string(), e.string().nullable(), e.string().nullable(), e.string(), e.string();
2336
+ var di = T.extend({ role: e.enum([
2337
+ "primary",
2338
+ "context",
2339
+ "source",
2340
+ "result"
2341
+ ]).optional() }), fi = e.object({
2342
+ id: e.string(),
2343
+ project_id: e.string(),
2344
+ name: e.string(),
2345
+ branch: e.string().nullable(),
2346
+ root_path: e.string().nullable(),
2347
+ provider_id: e.string(),
2348
+ provider_params_json: x,
2349
+ provider_ref_json: oi.nullable(),
2350
+ provider_state: si,
2351
+ execution_kind: ci,
2352
+ provider_operation_id: e.string().nullable(),
2353
+ provider_operation_kind: e.enum([
2354
+ "create",
2355
+ "cancel",
2356
+ "archive",
2357
+ "delete"
2358
+ ]).describe("The \"archive\" value is deprecated; use \"delete\". Historical archive operations remain readable until 0.45.").nullable(),
2359
+ provider_error_json: ui.nullable(),
2360
+ provider_capabilities_json: li,
2361
+ display_path: e.string().nullable(),
2362
+ is_default: e.boolean(),
2363
+ archived: e.boolean(),
2364
+ initializing: e.boolean(),
2365
+ setup_error: e.string().nullable(),
2366
+ workspace_shorthand: e.string(),
2367
+ startup_log_file_id: e.string().nullable(),
2368
+ anchors_json: e.array(di),
2369
+ created_at: e.string(),
2370
+ updated_at: e.string(),
2371
+ deleted_at: e.string().nullable()
2372
+ });
2373
+ e.object({
2374
+ project_id: e.string().min(1),
2375
+ provider_id: e.string().min(1),
2376
+ params: x.optional(),
2377
+ anchors: e.array(di).optional(),
2378
+ shorthand_base: e.string().trim().min(1).optional()
2379
+ }), e.object({
2380
+ projectId: e.string().min(1),
2381
+ providerId: e.string().min(1),
2382
+ shorthandBase: e.string().trim().min(1).optional(),
2383
+ params: x.optional(),
2384
+ anchors: e.array(di).optional()
2385
+ }), e.object({ name: e.string().trim().min(1, "Workspace name is required").max(120, "Workspace name must be 120 characters or less") }), e.object({ removed: e.boolean() });
2386
+ var pi = e.object({
2387
+ path: e.string(),
2388
+ name: e.string(),
2389
+ type: e.enum(["file", "directory"]),
2390
+ size: e.number().int().nonnegative().optional(),
2391
+ modified_at: e.string().optional()
2392
+ });
2393
+ e.object({
2394
+ workspace_id: e.string(),
2395
+ path: e.string(),
2396
+ entries: e.array(pi),
2397
+ truncated: e.boolean()
2398
+ }), e.object({
2399
+ workspace_id: e.string(),
2400
+ path: e.string(),
2401
+ file_name: e.string(),
2402
+ mime_type: e.string().optional(),
2403
+ size: e.number().int().nonnegative(),
2404
+ encoding: e.enum(["utf8", "base64"]),
2405
+ content: e.string().optional(),
2406
+ data_url: e.string().optional(),
2407
+ editable: e.boolean()
2408
+ }), e.object({ content: e.string() }), e.object({ destination_path: e.string().min(1) }), e.object({
2409
+ path: e.string().optional(),
2410
+ query: e.string().optional(),
2411
+ limit: e.number().int().positive().max(500).optional()
2412
+ }), e.object({
2413
+ id: e.string(),
2414
+ label: C,
2415
+ icon: e.string().optional(),
2416
+ description: C.optional(),
2417
+ params: rt
2418
+ }), e.object({ destinationPath: e.string().min(1) }), _e.extend({
2419
+ name: e.string().trim().min(1),
2420
+ initial_workspace: ti
2421
+ }), _e.extend({
2422
+ workbenchId: e.string().min(1),
2423
+ workspace: fi
2424
+ });
2425
+ //#endregion
2426
+ //#region ../pstdio-api-contracts/src/extension-kernel/api-versions.ts
2427
+ var mi = "(?:0|[1-9]\\d*)";
2428
+ RegExp(`^\\^(${mi}\\.${mi}\\.${mi})$`);
2429
+ //#endregion
2430
+ //#region ../pstdio-api-contracts/src/extension-kernel/builtin-refs.ts
2431
+ var P = (e, t) => ({
2432
+ extensionId: "pstdio",
2433
+ kind: e,
2434
+ id: t
2435
+ }), F = {
2436
+ project: P("mode", "project"),
2437
+ sessions: P("mode", "sessions"),
2438
+ settings: P("mode", "settings")
2439
+ };
2440
+ F.project, F.sessions, F.settings;
2441
+ var hi = (e, t, n) => ({
2442
+ id: e,
2443
+ ref: P("resource-kind", e),
2444
+ label: t,
2445
+ menuSlots: n
2446
+ }), gi = [{
2447
+ id: "headerPrimary",
2448
+ placement: "header-primary",
2449
+ access: "public"
2450
+ }, {
2451
+ id: "headerOverflow",
2452
+ placement: "header-overflow",
2453
+ access: "public"
2454
+ }], _i = {
2455
+ project: hi("project", "Extension", gi),
2456
+ session: hi("session", "Session", gi),
2457
+ workspace: hi("workspace", "Workspace", gi)
2458
+ }, I = {
2459
+ project: _i.project.ref,
2460
+ session: _i.session.ref,
2461
+ workspace: _i.workspace.ref
2462
+ }, vi = {
2463
+ start: P("page", "start"),
2464
+ sessions: P("page", "sessions"),
2465
+ session: P("page", "session"),
2466
+ workspaces: P("page", "workspaces"),
2467
+ workspace: P("page", "workspace")
2468
+ };
2469
+ vi.start, F.project, vi.sessions, F.sessions, vi.session, F.sessions, vi.workspaces, F.project, vi.workspace, F.project, { projectSession: P("placement", "project-session") }.projectSession, F.project;
2470
+ //#endregion
2471
+ //#region ../pstdio-api-contracts/src/extension-kernel/refs.ts
2472
+ var yi = (e) => ({
2473
+ ...e,
2474
+ kind: "command"
2475
+ });
2476
+ Object.assign(yi, { forExtension: (e) => (t) => yi({
2477
+ extensionId: `${e.publisher}.${e.name}`,
2478
+ id: t
2479
+ }) });
2480
+ var bi = (e) => ({
2481
+ ...e,
2482
+ kind: "event"
2483
+ }), xi = (e, t) => ({
2484
+ id: e,
2485
+ kind: t.kind,
2486
+ label: t.label,
2487
+ description: t.description,
2488
+ metadata: t.metadata
2489
+ }), L = (e) => bi({
2490
+ extensionId: "pstdio",
2491
+ id: e
2492
+ }), R = (e, t) => xi(`${e.id}.${t}`, { kind: "menu" });
2493
+ xi("project.sidenav", { kind: "panel" }), R(I.project, "headerPrimary"), R(I.project, "headerOverflow"), xi("project.settings", { kind: "settings" }), R(I.session, "headerPrimary"), R(I.session, "headerOverflow"), R(I.workspace, "headerPrimary"), R(I.workspace, "headerOverflow"), xi("workspace.sidenav", { kind: "panel" }), L("project.opened"), L("view.board-views.changed"), L("view.resource-anchors.changed"), L("view.sessions.changed"), L("view.workspaces.changed"), L("view.repositories.changed"), L("session.started"), L("session.resumed"), L("session.awaitingInput"), L("session.succeeded"), L("session.failed"), L("session.completed"), L("workspace.created"), L("workspace.provision"), L("workspace.ready"), L("workspace.deleted"), L("worktree.removed"), L("git.committed"), L("git.rebased"), L("git.merged"), L("git.conflicted");
2494
+ //#endregion
2495
+ //#region ../pstdio-api-contracts/src/extension-kernel/page-url.ts
2496
+ var Si = "pstdio", Ci = (e) => `${e.extensionId ?? ""}:page:${e.id}`, wi = (e, t) => e.find((e) => Ci(e.ref) === Ci(t)), Ti = (e) => e.split("/").filter(Boolean).map((e) => encodeURIComponent(e)).join("/"), Ei = (e, t) => {
2497
+ let n = `/projects/${encodeURIComponent(e)}`, r = Ti(t.path);
2498
+ if (t.ref.extensionId === Si) return r ? `${n}/${r}` : n;
2499
+ if (!t.ref.extensionId) throw Error(`Page "${t.id}" has no extension id`);
2500
+ return `${n}/extensions/${encodeURIComponent(t.ref.extensionId)}/${r}`;
2501
+ }, Di = (e) => {
2502
+ if (!e || typeof e != "object" || !Array.isArray(e.anchors)) return;
2503
+ let t = e.anchors;
2504
+ if (!t.some((e) => !e || typeof e != "object" || typeof e.id != "string" || typeof e.heading != "string" || e.occurrence !== void 0 && (!Number.isInteger(e.occurrence) || Number(e.occurrence) < 0))) return { anchors: t.map((e) => {
2505
+ let t = e;
2506
+ return {
2507
+ id: t.id,
2508
+ heading: t.heading,
2509
+ ...t.occurrence === void 0 ? {} : { occurrence: t.occurrence }
2510
+ };
2511
+ }) };
2512
+ }, Oi = (e) => {
2513
+ let t = Di(e);
2514
+ if (!t) throw Error("Page location has an invalid section");
2515
+ return JSON.stringify(t);
2516
+ }, ki = (e) => {
2517
+ try {
2518
+ return Di(JSON.parse(e));
2519
+ } catch {
2520
+ return;
2521
+ }
2522
+ }, Ai = (e) => {
2523
+ let t = wi(e.pages, e.location.page);
2524
+ if (!t) throw Error(`Unknown page ref: ${Ci(e.location.page)}`);
2525
+ let n = new URLSearchParams();
2526
+ e.location.resource && n.set("resource", e.resources.toUri(e.resources.normalize(e.location.resource)));
2527
+ let r = t.document && e.location.resource?.metadata?.[t.document.metadataKey];
2528
+ if (r !== void 0) {
2529
+ if (typeof r != "string" || !r) throw Error("Page location has an invalid document");
2530
+ n.set("document", r);
2531
+ }
2532
+ if (e.location.position) {
2533
+ if (!t.document || typeof r != "string" || !r || e.location.section || !vt(e.location.position)) throw Error("Page location has an invalid source position");
2534
+ for (let t of [
2535
+ "line",
2536
+ "column",
2537
+ "endLine",
2538
+ "endColumn"
2539
+ ]) {
2540
+ let r = e.location.position[t];
2541
+ r !== void 0 && n.set(t, String(r));
2542
+ }
2543
+ }
2544
+ e.location.section && n.set("section", Oi(e.location.section));
2545
+ let i = wt(t.params, e.location.params);
2546
+ for (let [e, r] of Et(t.params, i)) n.append(e, r);
2547
+ let a = n.toString(), o = Ei(e.projectId, t);
2548
+ return a ? `${o}?${a}` : o;
2549
+ }, ji = (e) => {
2550
+ try {
2551
+ return e.split("/").filter(Boolean).map((e) => decodeURIComponent(e));
2552
+ } catch {
2553
+ return;
2554
+ }
2555
+ }, Mi = (e, t) => {
2556
+ try {
2557
+ let n = ji(new URL(e, "http://workbench.local").pathname);
2558
+ return !!(n && n[0] === "projects" && n[1] === t);
2559
+ } catch {
2560
+ return !1;
2561
+ }
2562
+ }, Ni = (e, t, n) => e.find((e) => e.ref.extensionId === t && e.path === n), Pi = (e, t) => {
2563
+ try {
2564
+ let n = t.fromUri(e);
2565
+ return n ? t.normalize(n) : void 0;
2566
+ } catch {
2567
+ return;
2568
+ }
2569
+ }, Fi = (e, t, n, r) => {
2570
+ let i = Object.fromEntries([
2571
+ "line",
2572
+ "column",
2573
+ "endLine",
2574
+ "endColumn"
2575
+ ].filter((t) => e.searchParams.has(t)).map((t) => {
2576
+ let n = e.searchParams.get(t);
2577
+ return [t, /^[1-9]\d*$/.test(n) ? Number(n) : NaN];
2578
+ })), a;
2579
+ if (Object.keys(i).length) {
2580
+ if (!t.document || n === null || r || !vt(i)) return !1;
2581
+ a = i;
2582
+ }
2583
+ return a;
2584
+ }, Ii = (e, t, n) => {
2585
+ let r = ji(e.pathname);
2586
+ if (!r || r[0] !== "projects" || r[1] !== t) return;
2587
+ let i = r.slice(2), a = i[0] === "extensions", o = a ? i[1] : Si, s = (a ? i.slice(2) : i).join("/");
2588
+ if (!(!o || a && !s)) return Ni(n, o, s);
2589
+ }, Li = (e) => {
2590
+ let t;
2591
+ try {
2592
+ t = new URL(e.url, "http://workbench.local");
2593
+ } catch {
2594
+ return;
2595
+ }
2596
+ let n = Ii(t, e.projectId, e.pages);
2597
+ if (!n) return;
2598
+ for (let e of [
2599
+ "resource",
2600
+ "document",
2601
+ "section",
2602
+ "line",
2603
+ "column",
2604
+ "endLine",
2605
+ "endColumn"
2606
+ ]) if (t.searchParams.getAll(e).length > 1) return;
2607
+ let r = t.searchParams.get("resource"), i = r ? Pi(r, e.resources) : void 0;
2608
+ if (r !== null && !i) return;
2609
+ let a = t.searchParams.get("document");
2610
+ if (a !== null) {
2611
+ if (!a || !n.document || !i) return;
2612
+ i = {
2613
+ ...i,
2614
+ metadata: { [n.document.metadataKey]: a }
2615
+ };
2616
+ }
2617
+ let o = t.searchParams.get("section"), s = o ? ki(o) : void 0;
2618
+ if (o !== null && !s) return;
2619
+ let c = Fi(t, n, a, s);
2620
+ if (c === !1) return;
2621
+ let l = Dt(n.params, t.searchParams);
2622
+ return {
2623
+ pageId: n.id,
2624
+ ...l ? { params: l } : {},
2625
+ ...i ? { resource: i } : {},
2626
+ ...s ? { section: s } : {},
2627
+ ...c ? { position: c } : {}
2628
+ };
2629
+ }, Ri = [
2630
+ "clipboard.write",
2631
+ "commands.execute",
2632
+ "commands.stream",
2633
+ "navigation.open",
2634
+ "page.params.update",
2635
+ "placement.close",
2636
+ "notification.show",
2637
+ "notification.action",
2638
+ "notification.resolve",
2639
+ "notification.dismiss",
2640
+ "preferences.get",
2641
+ "preferences.set",
2642
+ "extension.settings.all",
2643
+ "extension.settings.get",
2644
+ "extension.settings.set",
2645
+ "extension.settings.delete",
2646
+ "terminal.session",
2647
+ "files.upload",
2648
+ "files.list",
2649
+ "files.delete"
2650
+ ], zi = ["artifacts.read"], Bi = [...Ri.filter((e) => e !== "clipboard.write"), ...zi];
2651
+ e.object({
2652
+ id: e.string(),
2653
+ project_id: e.string(),
2654
+ file_name: e.string(),
2655
+ file_kind: e.string(),
2656
+ storage_path: e.string(),
2657
+ mime_type: e.string().nullable(),
2658
+ size_bytes: e.number(),
2659
+ hash: e.string().nullable(),
2660
+ created_at: e.string(),
2661
+ updated_at: e.string()
2662
+ });
2663
+ //#endregion
2664
+ //#region ../pstdio-api-contracts/src/harness-commands.ts
2665
+ var Vi = e.object({
2666
+ name: e.string(),
2667
+ description: e.string(),
2668
+ argumentHelp: e.string().optional(),
2669
+ composer: e.object({
2670
+ label: e.string(),
2671
+ modeId: e.string().optional(),
2672
+ reservedArguments: e.array(e.string()).optional()
2673
+ }).optional(),
2674
+ disabledReason: e.string().optional()
2675
+ }), Hi = e.object({
2676
+ id: e.string(),
2677
+ label: e.string(),
2678
+ icon: e.string().optional(),
2679
+ argument: e.object({
2680
+ label: e.string(),
2681
+ value: e.string().optional()
2682
+ }).optional()
2683
+ }), Ui = e.object({
2684
+ id: e.string(),
2685
+ label: e.string(),
2686
+ description: e.string(),
2687
+ state: e.string(),
2688
+ indicator: e.object({
2689
+ label: e.string(),
2690
+ tone: e.enum([
2691
+ "neutral",
2692
+ "info",
2693
+ "success",
2694
+ "warning",
2695
+ "error"
2696
+ ])
2697
+ }).optional(),
2698
+ tagText: e.string().optional(),
2699
+ closeActionId: e.string().optional(),
2700
+ confirmation: e.object({
2701
+ id: e.string(),
2702
+ title: e.string(),
2703
+ actionId: e.string(),
2704
+ cancelLabel: e.string().optional(),
2705
+ model: e.string().optional()
2706
+ }).optional(),
2707
+ actions: e.array(Hi)
2708
+ });
2709
+ e.object({
2710
+ commands: e.array(Vi),
2711
+ modes: e.array(Ui),
2712
+ slashCommands: e.boolean()
2713
+ });
2714
+ var Wi = e.discriminatedUnion("kind", [e.object({
2715
+ kind: e.literal("command"),
2716
+ text: e.string().min(1)
2717
+ }).strict(), e.object({
2718
+ kind: e.literal("mode-action"),
2719
+ modeId: e.string(),
2720
+ actionId: e.string(),
2721
+ argument: e.string().optional()
2722
+ }).strict()]);
2723
+ e.object({
2724
+ project_id: e.string().min(1),
2725
+ agent: e.string().min(1),
2726
+ workspace_id: e.string().optional(),
2727
+ model: e.string().optional(),
2728
+ params: e.record(e.string(), e.union([e.string(), e.boolean()])).optional()
2729
+ }).strict();
2730
+ var Gi = e.object({
2731
+ status: e.enum(["completed", "started"]),
2732
+ message: e.string().optional()
2733
+ });
2734
+ e.object({
2735
+ cursor: e.string().optional(),
2736
+ limit: e.coerce.number().optional()
2737
+ });
2738
+ //#endregion
2739
+ //#region ../pstdio-api-contracts/src/session-request-values.ts
2740
+ var Ki = e.union([e.string(), e.boolean()]), z = e.record(e.string(), Ki), qi = e.object({ file_id: e.string().min(1) }), Ji = e.object({
2741
+ queuePosition: e.number().int().positive(),
2742
+ revision: e.string().min(1),
2743
+ prompt: e.string(),
2744
+ steeringUnavailableReason: e.string().nullable().optional(),
2745
+ steeringDelivery: e.object({
2746
+ id: e.string(),
2747
+ runStartedAt: e.string()
2748
+ }).nullable(),
2749
+ model: e.string().nullable(),
2750
+ params: z,
2751
+ attachments: e.array(qi)
2752
+ });
2753
+ e.object({
2754
+ prompt: e.string().trim().min(1),
2755
+ expectedRevision: e.string().min(1).optional(),
2756
+ model: e.string().min(1).nullable().optional(),
2757
+ params: z.nullable().optional(),
2758
+ attachments: e.array(qi).optional()
2759
+ }), e.object({
2760
+ sourcePosition: e.number().int().positive(),
2761
+ sourceRevision: e.string().min(1),
2762
+ targetRevision: e.string().min(1)
2763
+ }), e.object({
2764
+ ok: e.literal(!0),
2765
+ request: Ji
2766
+ });
2767
+ var Yi = e.object({
2768
+ requests: e.array(Ji),
2769
+ activeRunStartedAt: e.string().nullable(),
2770
+ steeringAvailable: e.boolean(),
2771
+ steeringUnavailableReason: e.string().nullable()
2772
+ });
2773
+ e.object({
2774
+ expectedRevision: e.string().min(1),
2775
+ expectedRunStartedAt: e.string().min(1)
2776
+ }), e.discriminatedUnion("status", [
2777
+ e.object({
2778
+ status: e.literal("accepted"),
2779
+ deliveryId: e.string()
2780
+ }),
2781
+ e.object({
2782
+ status: e.literal("rejected"),
2783
+ reason: e.enum([
2784
+ "unsupported",
2785
+ "inactive",
2786
+ "stale_run",
2787
+ "blocking_input",
2788
+ "missing",
2789
+ "stale_revision",
2790
+ "different_settings",
2791
+ "delivery_failed",
2792
+ "invalid_attachments"
2793
+ ]),
2794
+ message: e.string()
2795
+ }),
2796
+ e.object({
2797
+ status: e.literal("uncertain"),
2798
+ deliveryId: e.string(),
2799
+ message: e.string()
2800
+ })
2801
+ ]);
2802
+ //#endregion
2803
+ //#region ../pstdio-api-contracts/src/resource-anchors.ts
2804
+ var B = T.extend({
2805
+ type: e.string().min(1),
2806
+ id: e.string().min(1),
2807
+ projectId: e.string().min(1).optional(),
2808
+ extensionId: e.string().min(1).optional()
2809
+ }), Xi = B.extend({ role: e.enum([
2810
+ "primary",
2811
+ "context",
2812
+ "source",
2813
+ "result"
2814
+ ]).optional() });
2815
+ e.object({
2816
+ resource: B,
2817
+ anchors: e.array(Xi).max(100)
2818
+ }), e.object({
2819
+ resource: B,
2820
+ refs: e.array(B).max(100)
2821
+ }), e.object({
2822
+ resource: B,
2823
+ direction: e.enum([
2824
+ "outgoing",
2825
+ "incoming",
2826
+ "both"
2827
+ ]).optional(),
2828
+ role: e.enum([
2829
+ "primary",
2830
+ "context",
2831
+ "source",
2832
+ "result"
2833
+ ]).optional(),
2834
+ cursor: e.string().optional(),
2835
+ limit: e.number().int().min(1).max(100).optional()
2836
+ }), e.object({
2837
+ items: e.array(e.object({
2838
+ source: B,
2839
+ target: Xi
2840
+ })),
2841
+ nextCursor: e.string().optional()
2842
+ }).extend({ nextCursor: e.string().nullable() }), Object.keys({
2843
+ c: "text/plain",
2844
+ cc: "text/plain",
2845
+ cpp: "text/plain",
2846
+ cs: "text/plain",
2847
+ css: "text/css",
2848
+ csv: "text/csv",
2849
+ cxx: "text/plain",
2850
+ go: "text/plain",
2851
+ h: "text/plain",
2852
+ hpp: "text/plain",
2853
+ html: "text/html",
2854
+ java: "text/plain",
2855
+ js: "application/javascript",
2856
+ jsx: "text/plain",
2857
+ json: "application/json",
2858
+ jsonc: "application/json",
2859
+ kt: "text/plain",
2860
+ kts: "text/plain",
2861
+ lua: "text/plain",
2862
+ markdown: "text/markdown",
2863
+ md: "text/markdown",
2864
+ mjs: "application/javascript",
2865
+ pdf: "application/pdf",
2866
+ php: "text/plain",
2867
+ png: "image/png",
2868
+ py: "text/plain",
2869
+ rb: "text/plain",
2870
+ rs: "text/plain",
2871
+ sh: "text/plain",
2872
+ sql: "text/plain",
2873
+ svg: "image/svg+xml",
2874
+ swift: "text/plain",
2875
+ toml: "text/plain",
2876
+ ts: "text/plain",
2877
+ tsx: "text/plain",
2878
+ txt: "text/plain",
2879
+ vue: "text/plain",
2880
+ xml: "text/xml",
2881
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
2882
+ yaml: "text/plain",
2883
+ yml: "text/plain"
2884
+ }).map((e) => `.${e}`).join(",");
2885
+ //#endregion
2886
+ //#region ../pstdio-api-contracts/src/session-messages.ts
2887
+ var Zi = e.object({
2888
+ type: e.literal("text"),
2889
+ text: e.string()
2890
+ }), Qi = e.object({
2891
+ type: e.literal("reasoning"),
2892
+ text: e.string()
2893
+ }), $i = e.enum([
2894
+ "read",
2895
+ "write",
2896
+ "execute",
2897
+ "network",
2898
+ "other"
2899
+ ]), ea = e.enum([
2900
+ "pending",
2901
+ "running",
2902
+ "completed",
2903
+ "failed",
2904
+ "denied"
2905
+ ]), ta = e.object({
2906
+ type: e.literal("tool"),
2907
+ tool: e.string(),
2908
+ callId: e.string().optional(),
2909
+ actionType: $i.optional(),
2910
+ status: ea.optional(),
2911
+ state: e.object({
2912
+ status: e.string().optional(),
2913
+ input: e.unknown().optional(),
2914
+ output: e.unknown().optional(),
2915
+ errorText: e.string().optional(),
2916
+ metadata: e.unknown().optional()
2917
+ }).optional()
2918
+ }), na = e.object({
2919
+ type: e.literal("step-start"),
2920
+ snapshot: e.string().optional()
2921
+ }), ra = e.object({
2922
+ type: e.literal("step-finish"),
2923
+ reason: e.string().optional(),
2924
+ snapshot: e.string().optional(),
2925
+ cost: e.number().optional(),
2926
+ tokens: e.unknown().optional()
2927
+ }), ia = e.object({
2928
+ type: e.literal("patch"),
2929
+ hash: e.string().optional(),
2930
+ files: e.unknown().optional()
2931
+ }), aa = e.object({
2932
+ type: e.literal("file"),
2933
+ fileId: e.string().optional(),
2934
+ mediaType: e.string().optional(),
2935
+ filename: e.string().optional(),
2936
+ size: e.number().optional(),
2937
+ url: e.string()
2938
+ }), oa = e.object({ type: e.literal("loading") }), sa = e.object({
2939
+ type: e.literal("error"),
2940
+ errorType: e.enum([
2941
+ "timeout",
2942
+ "crash",
2943
+ "permission",
2944
+ "other"
2945
+ ]),
2946
+ message: e.string().optional()
2947
+ }), ca = e.object({
2948
+ type: e.literal("token_usage"),
2949
+ inputTokens: e.number(),
2950
+ outputTokens: e.number(),
2951
+ cacheReadTokens: e.number().optional(),
2952
+ cacheWriteTokens: e.number().optional()
2953
+ }), la = e.union([
2954
+ Zi,
2955
+ Qi,
2956
+ ta,
2957
+ na,
2958
+ ra,
2959
+ ia,
2960
+ aa,
2961
+ oa,
2962
+ sa,
2963
+ ca
2964
+ ]), ua = e.enum([
2965
+ "user",
2966
+ "assistant",
2967
+ "tool",
2968
+ "system",
2969
+ "developer"
2970
+ ]), da = e.object({
2971
+ id: e.string(),
2972
+ role: ua,
2973
+ parts: e.array(la),
2974
+ index: e.number().optional(),
2975
+ createdAt: e.number().optional(),
2976
+ modelId: e.string().optional(),
2977
+ providerId: e.string().optional(),
2978
+ tokens: e.object({
2979
+ input: e.number().optional(),
2980
+ output: e.number().optional(),
2981
+ reasoning: e.number().optional(),
2982
+ cache: e.object({
2983
+ read: e.number().optional(),
2984
+ write: e.number().optional()
2985
+ }).optional()
2986
+ }).optional()
2987
+ }), fa = e.enum([
2988
+ "in_progress",
2989
+ "awaiting_input",
2990
+ "queued",
2991
+ "completed",
2992
+ "failed",
2993
+ "cancelled",
2994
+ "disconnected"
2995
+ ]), pa = e.object({
2996
+ input_tokens: e.number(),
2997
+ output_tokens: e.number(),
2998
+ cache_read_tokens: e.number(),
2999
+ cache_write_tokens: e.number()
3000
+ }), ma = e.object({
3001
+ cause: e.enum([
3002
+ "completed",
3003
+ "user_stop",
3004
+ "request_aborted",
3005
+ "worker_lost",
3006
+ "host_shutdown",
3007
+ "timeout",
3008
+ "failed",
3009
+ "unknown"
3010
+ ]),
3011
+ startedAt: e.string().nullable(),
3012
+ endedAt: e.string()
3013
+ }), ha = e.object({
3014
+ id: e.string(),
3015
+ title: e.string(),
3016
+ status: fa,
3017
+ archived: e.boolean(),
3018
+ agent: e.string().nullable(),
3019
+ cwd: e.string().nullable(),
3020
+ lastSelectedModel: e.string().nullable(),
3021
+ workspaceId: e.string().nullable(),
3022
+ originalSessionId: e.string().nullable(),
3023
+ createdAt: e.string(),
3024
+ updatedAt: e.string(),
3025
+ lastRequestStarted: e.string().nullable(),
3026
+ lastRequestEnded: e.string().nullable(),
3027
+ lastExit: ma.nullable().optional(),
3028
+ usage: e.object({
3029
+ inputTokens: e.number(),
3030
+ outputTokens: e.number(),
3031
+ cacheReadTokens: e.number(),
3032
+ cacheWriteTokens: e.number()
3033
+ }).nullable()
3034
+ }), ga = e.object({
3035
+ id: e.string(),
3036
+ project_id: e.string().nullable(),
3037
+ title: e.string(),
3038
+ status: fa,
3039
+ archived: e.boolean(),
3040
+ last_request_started: e.string().nullable(),
3041
+ last_request_ended: e.string().nullable(),
3042
+ agent: e.string().nullable(),
3043
+ last_selected_model: e.string().nullable(),
3044
+ agent_session_id: e.string().nullable(),
3045
+ session_file_id: e.string().nullable(),
3046
+ original_session_id: e.string().nullable(),
3047
+ cwd: e.string().nullable(),
3048
+ params_json: z.nullable(),
3049
+ usage_json: pa.nullable().optional(),
3050
+ workspace_id: e.string().nullable().optional(),
3051
+ anchors_json: e.array(T),
3052
+ created_at: e.string(),
3053
+ updated_at: e.string()
3054
+ }), _a = ha.extend({
3055
+ projectId: e.string().nullable(),
3056
+ agentSessionId: e.string().nullable(),
3057
+ sessionFileId: e.string().nullable(),
3058
+ params: z.nullable()
3059
+ });
3060
+ ga.extend(ha.shape).extend({ operation_result: Gi.optional() }).extend(_a.shape).extend({ operationResult: Gi.optional() });
3061
+ var va = e.object({
3062
+ file_id: e.string(),
3063
+ name: e.string(),
3064
+ mime_type: e.string().nullable(),
3065
+ size_bytes: e.number(),
3066
+ hash: e.string().nullable(),
3067
+ url: e.string(),
3068
+ created_at: e.string(),
3069
+ updated_at: e.string()
3070
+ }), ya = e.object({
3071
+ project_id: e.string().min(1),
3072
+ title: e.string().min(1),
3073
+ prompt: e.string().optional(),
3074
+ operation: Wi.optional(),
3075
+ agent: e.string().min(1).optional(),
3076
+ workspace_id: e.string().optional(),
3077
+ anchors: e.array(T).optional(),
3078
+ attachments: e.array(qi).optional(),
3079
+ model: e.string().optional(),
3080
+ params: z.optional(),
3081
+ original_session_id: e.string().optional()
3082
+ }), ba = e.object({
3083
+ answers: e.array(e.array(e.string())),
3084
+ callId: e.string().min(1).optional()
3085
+ }), xa = e.object({
3086
+ prompt: e.string().min(1).optional(),
3087
+ agent: e.string().optional(),
3088
+ model: e.string().optional(),
3089
+ question_response: ba.optional(),
3090
+ params: z.optional(),
3091
+ summary_from_session_id: e.string().optional(),
3092
+ summary_format: e.enum(["brief", "detailed"]).default("brief").optional(),
3093
+ summary_role: e.enum(["assistant", "all"]).default("assistant").optional(),
3094
+ attachments: e.array(qi).optional()
3095
+ });
3096
+ e.object({
3097
+ id: e.string().min(1),
3098
+ decision: e.enum(["approve", "deny"])
3099
+ });
3100
+ var Sa = e.union([e.object({ status: e.literal("dispatched") }), e.object({
3101
+ status: e.literal("queued"),
3102
+ queue_position: e.number().int()
3103
+ })]), Ca = ga.extend({ follow_up: Sa });
3104
+ e.object({
3105
+ messages: e.array(da),
3106
+ queue: Yi.optional()
3107
+ }), e.object({
3108
+ checkpoint: e.array(da).nullable(),
3109
+ native: e.array(da).nullable(),
3110
+ checkpointError: e.string().nullable(),
3111
+ nativeError: e.string().nullable()
3112
+ }), e.object({
3113
+ session: ga,
3114
+ messages: e.array(da)
3115
+ }), e.object({
3116
+ agent: e.string(),
3117
+ agent_session_id: e.string(),
3118
+ cwd: e.string().optional()
3119
+ }), e.object({ session_id: e.string().nullable() }), ya.omit({
3120
+ project_id: !0,
3121
+ workspace_id: !0,
3122
+ original_session_id: !0,
3123
+ attachments: !0
3124
+ }).extend({
3125
+ attachments: e.array(e.object({ fileId: e.string().min(1) })).optional(),
3126
+ projectId: e.string().min(1),
3127
+ workspaceId: e.string().optional(),
3128
+ originalSessionId: e.string().optional()
3129
+ }), va.omit({
3130
+ file_id: !0,
3131
+ mime_type: !0,
3132
+ size_bytes: !0,
3133
+ created_at: !0,
3134
+ updated_at: !0
3135
+ }).extend({
3136
+ fileId: e.string(),
3137
+ mimeType: e.string().nullable(),
3138
+ sizeBytes: e.number(),
3139
+ createdAt: e.string(),
3140
+ updatedAt: e.string()
3141
+ }), xa.omit({
3142
+ question_response: !0,
3143
+ summary_from_session_id: !0,
3144
+ summary_format: !0,
3145
+ summary_role: !0,
3146
+ attachments: !0
3147
+ }).extend({
3148
+ questionResponse: ba.optional(),
3149
+ summaryFromSessionId: e.string().optional(),
3150
+ summaryFormat: e.enum(["brief", "detailed"]).optional(),
3151
+ summaryRole: e.enum(["assistant", "all"]).optional(),
3152
+ attachments: e.array(e.object({ fileId: e.string().min(1) })).optional()
3153
+ });
3154
+ var wa = e.union([e.object({ status: e.literal("dispatched") }), e.object({
3155
+ status: e.literal("queued"),
3156
+ queuePosition: e.number().int()
3157
+ })]);
3158
+ Ca.extend(_a.shape).extend({ followUp: wa }), e.object({
3159
+ notifications_enabled: e.boolean(),
3160
+ machine_tokens_enabled: e.boolean(),
3161
+ max_concurrent_sessions: e.number().int().min(1).nullable()
3162
+ }), e.object({
3163
+ notifications_enabled: e.boolean().optional(),
3164
+ machine_tokens_enabled: e.boolean().optional(),
3165
+ max_concurrent_sessions: e.number().int().min(1).nullable().optional()
3166
+ }).strict().refine((e) => Object.keys(e).length > 0, { message: "Expected at least one setting" });
3167
+ //#endregion
3168
+ //#region ../pstdio-api-contracts/src/skills.ts
3169
+ var Ta = e.object({
3170
+ path: e.string(),
3171
+ content: e.string(),
3172
+ encoding: e.literal("utf8")
3173
+ }), Ea = e.enum(["project", "extension"]), Da = e.object({
3174
+ agent_id: e.string(),
3175
+ agent_name: e.string(),
3176
+ installed_version: e.string().nullable()
3177
+ }), Oa = e.object({
3178
+ id: e.string(),
3179
+ project_id: e.string(),
3180
+ name: e.string(),
3181
+ title: e.string(),
3182
+ description: e.string(),
3183
+ source_kind: Ea,
3184
+ files: e.array(Ta),
3185
+ editable: e.boolean(),
3186
+ extension_instance_id: e.string().optional(),
3187
+ extension_id: e.string().optional(),
3188
+ installed_extension_id: e.string().optional(),
3189
+ install_name: e.string().optional(),
3190
+ key: e.string().optional(),
3191
+ source: je.optional(),
3192
+ enabled: e.boolean().optional(),
3193
+ created_at: e.string(),
3194
+ updated_at: e.string(),
3195
+ deleted_at: e.string().nullable()
3196
+ });
3197
+ Oa.extend({
3198
+ installed_agents: e.array(e.string()),
3199
+ agent_installations: e.array(Da)
3200
+ }), e.object({
3201
+ enabled: e.boolean().optional(),
3202
+ title: e.string().min(1).optional(),
3203
+ description: e.string().optional()
3204
+ });
3205
+ var ka = Oa.omit({
3206
+ project_id: !0,
3207
+ source_kind: !0,
3208
+ extension_instance_id: !0,
3209
+ extension_id: !0,
3210
+ installed_extension_id: !0,
3211
+ install_name: !0,
3212
+ created_at: !0,
3213
+ updated_at: !0,
3214
+ deleted_at: !0
3215
+ }).extend({
3216
+ projectId: e.string(),
3217
+ sourceKind: Ea,
3218
+ extensionInstanceId: e.string().optional(),
3219
+ extensionId: e.string().optional(),
3220
+ installedExtensionId: e.string().optional(),
3221
+ installName: e.string().optional(),
3222
+ createdAt: e.string(),
3223
+ updatedAt: e.string(),
3224
+ deletedAt: e.string().nullable()
3225
+ }), Aa = e.object({
3226
+ agentId: e.string(),
3227
+ agentName: e.string(),
3228
+ installedVersion: e.string().nullable()
3229
+ });
3230
+ ka.extend({
3231
+ installedAgents: e.array(e.string()),
3232
+ agentInstallations: e.array(Aa)
3233
+ });
3234
+ //#endregion
3235
+ //#region ../pstdio-api-contracts/src/workspace-diffs.ts
3236
+ var ja = e.object({
3237
+ filePath: e.string(),
3238
+ change: e.enum([
3239
+ "added",
3240
+ "deleted",
3241
+ "modified",
3242
+ "renamed",
3243
+ "copied",
3244
+ "permissionChange"
3245
+ ]),
3246
+ additions: e.number(),
3247
+ deletions: e.number(),
3248
+ oldContent: e.string(),
3249
+ newContent: e.string(),
3250
+ oldPath: e.string().optional(),
3251
+ newPath: e.string().optional()
3252
+ }), Ma = ja.omit({
3253
+ oldContent: !0,
3254
+ newContent: !0
3255
+ });
3256
+ e.object({
3257
+ workspace_id: e.string(),
3258
+ base_ref: e.string(),
3259
+ head_ref: e.string(),
3260
+ files: e.array(ja),
3261
+ totals: e.object({
3262
+ additions: e.number(),
3263
+ deletions: e.number(),
3264
+ file_count: e.number()
3265
+ })
3266
+ }).extend({ files: e.array(Ma) }), e.object({
3267
+ workspace_id: e.string(),
3268
+ additions: e.number(),
3269
+ deletions: e.number(),
3270
+ file_count: e.number()
3271
+ });
3272
+ //#endregion
3273
+ //#region src/core/shared/disposable.ts
3274
+ var V = (e) => {
3275
+ let t = !1;
3276
+ return { dispose() {
3277
+ t || (t = !0, e());
3278
+ } };
3279
+ };
3280
+ //#endregion
3281
+ //#region src/core/shared/workbench-effect.ts
3282
+ function Na(e, t) {
3283
+ try {
3284
+ return t();
3285
+ } catch (t) {
3286
+ console.error(`Workbench effect failed (${e})`, t);
3287
+ return;
3288
+ }
3289
+ }
3290
+ //#endregion
3291
+ //#region src/core/shared/store/workbench-batch.ts
3292
+ var H = 0, Pa = /* @__PURE__ */ new Map(), Fa = (e, t) => {
3293
+ if (H === 0) {
3294
+ Na("store subscriber", t);
3295
+ return;
3296
+ }
3297
+ Pa.has(e) || Pa.set(e, t);
3298
+ }, Ia = (e) => {
3299
+ H++;
3300
+ try {
3301
+ return e();
3302
+ } finally {
3303
+ if (H--, H === 0) {
3304
+ H++;
3305
+ try {
3306
+ for (; Pa.size;) {
3307
+ let [e, t] = Pa.entries().next().value;
3308
+ Pa.delete(e), Na("store subscriber", t);
3309
+ }
3310
+ } finally {
3311
+ H--;
3312
+ }
3313
+ }
3314
+ }
3315
+ }, La = (e, t) => Object.is(e, t), Ra = (e) => {
3316
+ let r = n()(t(() => e.initialState, { name: e.name ?? "workbench.store" })), i = (e) => {
3317
+ let t = {};
3318
+ return r.subscribe((n, i) => Fa(t, () => e(r.getState(), i)));
3319
+ };
3320
+ return {
3321
+ getState: r.getState,
3322
+ getInitialState: r.getInitialState,
3323
+ subscribe: i,
3324
+ subscribeSelector: (e, t, n = {}) => {
3325
+ let a = n.equalityFn ?? La, o = e(r.getState());
3326
+ return n.fireImmediately && t(o, o), i((n) => {
3327
+ let r = e(n);
3328
+ if (a(o, r)) return;
3329
+ let i = o;
3330
+ o = r, t(r, i);
3331
+ });
3332
+ },
3333
+ setState: r.setState,
3334
+ api: r
3335
+ };
3336
+ }, U = [
3337
+ "nav",
3338
+ "activity",
3339
+ "sidenav",
3340
+ "main-header",
3341
+ "main-left-menu",
3342
+ "main",
3343
+ "main-right-menu",
3344
+ "secondary-header",
3345
+ "secondary-left-menu",
3346
+ "secondary",
3347
+ "secondary-right-menu",
3348
+ "side-header",
3349
+ "side-left-menu",
3350
+ "side",
3351
+ "side-right-menu",
3352
+ "status",
3353
+ "overlay"
3354
+ ], za = [
3355
+ "main",
3356
+ "secondary",
3357
+ "side"
3358
+ ], Ba = {
3359
+ main: {
3360
+ left: "main-left-menu",
3361
+ right: "main-right-menu"
3362
+ },
3363
+ secondary: {
3364
+ left: "secondary-left-menu",
3365
+ right: "secondary-right-menu"
3366
+ },
3367
+ side: {
3368
+ left: "side-left-menu",
3369
+ right: "side-right-menu"
3370
+ }
3371
+ }, Va = {
3372
+ "main-left-menu": "main",
3373
+ "main-right-menu": "main",
3374
+ "secondary-left-menu": "secondary",
3375
+ "secondary-right-menu": "secondary",
3376
+ "side-left-menu": "side",
3377
+ "side-right-menu": "side"
3378
+ }, Ha = (e) => Va[e], Ua = (e, t) => {
3379
+ let n = e.filter((e) => e.tabRetention === "preview"), r = n.find((e) => e.widgetId === t) ?? n[0];
3380
+ return {
3381
+ widgets: [...r ? [r] : [], ...e.filter((e) => e.tabRetention !== "preview")],
3382
+ replaced: n.filter((e) => e !== r)
3383
+ };
3384
+ }, Wa = (e, t, n = "end") => {
3385
+ let r = e.filter((e) => e.widgetId !== t.widgetId), i = n === "start" ? 0 : r.length;
3386
+ if (typeof n == "object") {
3387
+ let e = "beforeWidgetId" in n, t = e ? n.beforeWidgetId : n.afterWidgetId, a = r.findIndex((e) => e.widgetId === t);
3388
+ a >= 0 && (i = a + +!e);
3389
+ }
3390
+ return r.splice(i, 0, t), Ua(r, t.tabRetention === "preview" ? t.widgetId : void 0);
3391
+ }, Ga = (e, t, n = "end") => Wa(e, t.tabRetention === "preview" ? {
3392
+ ...t,
3393
+ pinned: !0,
3394
+ tabRetention: "persistent"
3395
+ } : t, n), Ka = (e, t, n = t) => {
3396
+ if (!e.has(n)) return n;
3397
+ let r = 1;
3398
+ for (; e.has(`${t}:${r}`);) r += 1;
3399
+ return `${t}:${r}`;
3400
+ }, qa = (e, t) => {
3401
+ for (let n of Object.values(e.regions)) {
3402
+ let e = n.widgets.findIndex((e) => e.contributionId === t);
3403
+ if (e >= 0) return {
3404
+ regionId: n.id,
3405
+ index: e,
3406
+ placement: n.widgets[e]
3407
+ };
3408
+ }
3409
+ }, Ja = (e, t, n) => {
3410
+ for (let r of Object.values(e.regions)) {
3411
+ let e = r.widgets.findIndex((e) => e.contributionId === t && e.resourceKey === n);
3412
+ if (e >= 0) return {
3413
+ regionId: r.id,
3414
+ index: e,
3415
+ placement: r.widgets[e]
3416
+ };
3417
+ }
3418
+ }, W = (e, t) => {
3419
+ for (let n of Object.values(e.regions)) {
3420
+ let e = n.widgets.findIndex((e) => e.widgetId === t);
3421
+ if (e >= 0) return {
3422
+ regionId: n.id,
3423
+ index: e,
3424
+ placement: n.widgets[e]
3425
+ };
3426
+ }
3427
+ }, Ya = (e, t) => Ka(new Set(Object.values(e.regions).flatMap((e) => e.widgets.map((e) => e.widgetId))), t), Xa = (e) => e.widgets.find((t) => t.widgetId === e.activeWidgetId) ?? e.widgets[0], Za = (e) => e.role === "location", Qa = (e) => e.resourceKey ?? `${e.contributionId}:${e.widgetId}`, $a = (e, t, n, r) => {
3428
+ if (!t) return e;
3429
+ let i = Qa(t), a = { ...e.locationSubPanelSelections?.[i] ?? {} };
3430
+ return r ? a[n] = r : delete a[n], {
3431
+ ...e,
3432
+ locationSubPanelSelections: {
3433
+ ...e.locationSubPanelSelections,
3434
+ [i]: a
3435
+ }
3436
+ };
3437
+ }, eo = (e, t) => {
3438
+ if (!e.locationSubPanelSelections) return e;
3439
+ let n = Object.fromEntries(Object.entries(e.locationSubPanelSelections).map(([e, n]) => [e, Object.fromEntries(Object.entries(n).filter(([, e]) => e !== t))]));
3440
+ return {
3441
+ ...e,
3442
+ locationSubPanelSelections: n
3443
+ };
3444
+ }, G = (e) => {
3445
+ let t = Object.values(e.regions).flatMap((e) => e.widgets).filter(Za);
3446
+ return t.find((t) => t.widgetId === e.activeLocationWidgetId) ?? t.at(-1);
3447
+ }, to = (e, t, n, r = {}) => {
3448
+ let i = e.regions[t], a = n(i.widgets), o = r.activeWidgetId ?? (r.clearActiveWidget ? void 0 : i.activeWidgetId);
3449
+ return {
3450
+ ...e,
3451
+ activeLocationWidgetId: i.widgets.some((t) => t.widgetId === e.activeLocationWidgetId) && !a.some((t) => t.widgetId === e.activeLocationWidgetId) ? Object.values(e.regions).flatMap((e) => e.id === t ? a : e.widgets).filter(Za).at(-1)?.widgetId : e.activeLocationWidgetId,
3452
+ regions: {
3453
+ ...e.regions,
3454
+ [t]: {
3455
+ ...i,
3456
+ widgets: a,
3457
+ activeWidgetId: o
3458
+ }
3459
+ }
3460
+ };
3461
+ }, no = (e, t) => {
3462
+ let n = e;
3463
+ for (let r of Object.values(e.regions)) {
3464
+ let e = r.widgets.filter((e) => e.contributionId === t), i = r.widgets.filter((e) => e.contributionId !== t);
3465
+ if (i.length === r.widgets.length) continue;
3466
+ let a = r.activeWidgetId && !i.some((e) => e.widgetId === r.activeWidgetId) ? void 0 : r.activeWidgetId;
3467
+ n = {
3468
+ ...n,
3469
+ regions: {
3470
+ ...n.regions,
3471
+ [r.id]: {
3472
+ ...r,
3473
+ widgets: i,
3474
+ activeWidgetId: a
3475
+ }
3476
+ }
3477
+ };
3478
+ for (let t of e) n = eo(n, t.widgetId);
3479
+ }
3480
+ let r = Object.values(n.regions).some((e) => e.widgets.some((e) => e.widgetId === n.activeWidgetId));
3481
+ return n.activeWidgetId && (!r || n.activeWidgetId.startsWith(`${t}:`) || n.activeWidgetId === t) && (n = {
3482
+ ...n,
3483
+ activeWidgetId: void 0,
3484
+ activeResourceKey: void 0
3485
+ }), n.activeLocationWidgetId && !W(n, n.activeLocationWidgetId) && (n = {
3486
+ ...n,
3487
+ activeLocationWidgetId: G(n)?.widgetId
3488
+ }), n;
3489
+ }, ro = (e, t) => {
3490
+ let n = W(e, t);
3491
+ if (!n) return;
3492
+ 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" ? i.find(Za) : void 0) ?? i[n.index] ?? i[n.index - 1], s = a ? o?.widgetId : r.activeWidgetId, c = {
3493
+ ...r,
3494
+ widgets: i,
3495
+ activeWidgetId: s,
3496
+ visible: i.length === 0 && (r.id === "side" || r.id === "secondary") ? !1 : r.visible
3497
+ }, l = e.activeLocationWidgetId;
3498
+ e.activeWidgetId === t && o?.role === "location" ? l = o.widgetId : l === t && (l = Object.values(e.regions).flatMap((e) => e.widgets).filter((e) => e.widgetId !== t && Za(e)).at(-1)?.widgetId);
3499
+ let u = eo({
3500
+ ...e,
3501
+ activeLocationWidgetId: l,
3502
+ regions: {
3503
+ ...e.regions,
3504
+ [r.id]: c
3505
+ }
3506
+ }, t);
3507
+ return a && n.regionId !== "side" && za.includes(n.regionId) && (u = $a(u, G(u), n.regionId, o?.role === "sub-panel" ? o.widgetId : void 0)), e.activeWidgetId === t && (u = {
3508
+ ...u,
3509
+ activeWidgetId: o?.widgetId,
3510
+ activeResourceKey: o?.resourceKey
3511
+ }), {
3512
+ regionId: n.regionId,
3513
+ closedPlacement: n.placement,
3514
+ activePlacement: Xa(c),
3515
+ layout: u
3516
+ };
3517
+ }, io = (e, t, n) => {
3518
+ let r = e.regions[t];
3519
+ if (Za(n)) {
3520
+ let r = e.locationSubPanelSelections?.[Qa(n)] ?? {}, i = { ...e.regions };
3521
+ for (let e of za) {
3522
+ let a = i[e], o = r[e], s = a.widgets.find((e) => e.widgetId === o && e.role === "sub-panel" && (!e.ownerResourceKey || e.ownerResourceKey === n.resourceKey));
3523
+ i[e] = {
3524
+ ...a,
3525
+ activeWidgetId: (e === "side" || e === "secondary") && e !== t ? a.activeWidgetId : s?.widgetId ?? (e === t ? n.widgetId : void 0)
3526
+ };
3527
+ }
3528
+ return {
3529
+ ...e,
3530
+ activeWidgetId: n.widgetId,
3531
+ activeLocationWidgetId: n.widgetId,
3532
+ activeResourceKey: n.resourceKey,
3533
+ regions: i
3534
+ };
3535
+ }
3536
+ let i = n.role === "sub-panel" && t === "main" ? $a(e, G(e), t, n.widgetId) : e;
3537
+ return {
3538
+ ...i,
3539
+ activeWidgetId: n.widgetId,
3540
+ activeLocationWidgetId: e.activeLocationWidgetId,
3541
+ activeResourceKey: n.resourceKey,
3542
+ regions: {
3543
+ ...i.regions,
3544
+ [t]: {
3545
+ ...r,
3546
+ activeWidgetId: n.widgetId
3547
+ }
3548
+ }
3549
+ };
3550
+ }, ao = (e, t, n) => {
3551
+ let r = e.regions[t], i = n ? r.widgets.find((e) => e.widgetId === n) : void 0;
3552
+ if (n && !i) throw Error(`Widget placement not found in ${t}: ${n}`);
3553
+ if (r.activeWidgetId === n) return;
3554
+ let a = e.activeWidgetId === r.activeWidgetId, o = {
3555
+ ...e,
3556
+ activeWidgetId: a ? i?.widgetId : e.activeWidgetId,
3557
+ activeResourceKey: a ? i?.resourceKey : e.activeResourceKey,
3558
+ activeLocationWidgetId: i?.role === "location" ? i.widgetId : e.activeLocationWidgetId,
3559
+ regions: {
3560
+ ...e.regions,
3561
+ [t]: {
3562
+ ...r,
3563
+ activeWidgetId: i?.widgetId
3564
+ }
3565
+ }
3566
+ };
3567
+ return t === "side" || !za.includes(t) ? o : $a(o, G(o), t, i?.role === "sub-panel" ? i.widgetId : void 0);
3568
+ }, oo = (e, t) => !(e.resourceKinds?.length && (!t || !e.resourceKinds.includes(t.type)) || e.canOpen && (!t || !e.canOpen(t))), so = (e, t, n, r = {}) => {
3569
+ let i = e.regions[t];
3570
+ return i.widgets.find((e) => e.widgetId === i.activeWidgetId && e.role === "sub-panel" && (r.ignoreOwnerResourceKey || !e.ownerResourceKey || e.ownerResourceKey === a(n)));
3571
+ }, co = (e) => G(e), lo = (e, t, n, r, i) => {
3572
+ let o = e.eligibleLocations;
3573
+ return !(!uo(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({
3574
+ resource: t,
3575
+ viewId: i?.viewId
3576
+ }) || r?.ownerResourceKey && r.ownerResourceKey !== a(t));
3577
+ }, uo = (e, t) => {
3578
+ let n = e.eligibleLocations?.modeIds;
3579
+ return !n?.length || t !== void 0 && n.includes(t);
3580
+ }, fo = (e, t, n, r, i = {}) => oo(e, r?.resource ?? t) ? i.ignoreResourceLocation ? uo(e, n) : lo(e, t, n, r, i.location) : !1, po = (e, t) => {
3581
+ let n = e.panelMenuOwner ?? { level: "panel" };
3582
+ return n.contributionId ? (t.subPanel ?? t.locationPanel)?.contributionId === n.contributionId : t.subPanel ? n.level === "sub-panel" : n.level === "panel";
3583
+ }, mo = "workbench.core", ho = (e = {}) => ({
3584
+ source: e.source ?? "module",
3585
+ ownerId: e.ownerId ?? mo,
3586
+ priority: e.priority ?? 0
3587
+ }), go = (e, t) => t.priority - e.priority || e.ownerId.localeCompare(t.ownerId), _o = (e = {}, t) => {
3588
+ let { strategy: n, ...r } = e, i = r.resource && r.viewId === void 0 ? {
3589
+ ...r,
3590
+ viewId: null
3591
+ } : r;
3592
+ return n ? n.kind === "persistent" ? {
3593
+ ...i,
3594
+ tabPosition: n.position,
3595
+ tabRetention: "persistent"
3596
+ } : n.kind === "replace-active" ? {
3597
+ ...i,
3598
+ replaceActive: !0
3599
+ } : n.kind === "replace-panel" ? {
3600
+ ...i,
3601
+ replaceWidgetId: n.instanceId,
3602
+ tabRetention: n.retention
3603
+ } : {
3604
+ ...i,
3605
+ tabRetention: "preview",
3606
+ tabPosition: n.position
3607
+ } : {
3608
+ ...i,
3609
+ tabRetention: t
3610
+ };
3611
+ }, vo = (e) => ({
3612
+ instanceId: e.widgetId,
3613
+ panelId: e.contributionId,
3614
+ placementIdentity: e.placementIdentity,
3615
+ viewId: e.viewId,
3616
+ ownerId: e.ownerId,
3617
+ source: e.source,
3618
+ resource: e.resource,
3619
+ section: e.section,
3620
+ resourceKey: e.resourceKey,
3621
+ ownerResourceKey: e.ownerResourceKey,
3622
+ title: e.title,
3623
+ pinned: e.pinned,
3624
+ closable: e.closable === !0,
3625
+ mountStrategy: e.mountStrategy,
3626
+ hiddenByDefault: e.hiddenByDefault,
3627
+ tabRetention: e.tabRetention,
3628
+ tab: e.tab
3629
+ }), yo = (e) => {
3630
+ let { closable: t, ownedPanelMenuIds: n, ...r } = e;
3631
+ return r;
3632
+ }, K = {
3633
+ main: [
3634
+ "main-header",
3635
+ "main-left-menu",
3636
+ "main",
3637
+ "main-right-menu"
3638
+ ],
3639
+ secondary: [
3640
+ "secondary-header",
3641
+ "secondary-left-menu",
3642
+ "secondary",
3643
+ "secondary-right-menu"
3644
+ ],
3645
+ side: [
3646
+ "side-header",
3647
+ "side-left-menu",
3648
+ "side",
3649
+ "side-right-menu"
3650
+ ]
3651
+ }, bo = Object.values(K).flat(), xo = (e) => e.panels ?? za, So = (e) => Object.keys(K).find((t) => K[t].some((t) => t === e)), Co = (e, t) => !e || xo(e).includes(t), q = (e, t) => {
3652
+ if (t) return Object.values(e.regions).flatMap((e) => e.widgets).find((e) => e.widgetId === t);
3653
+ }, wo = (e, t) => {
3654
+ let n = t.find((t) => t && q(e, t.widgetId));
3655
+ return {
3656
+ ...e,
3657
+ activeWidgetId: n?.widgetId,
3658
+ activeResourceKey: n?.resourceKey
3659
+ };
3660
+ }, To = (e, t) => {
3661
+ if (t.length === 0) return e;
3662
+ let n = new Set(Object.keys(K).filter((e) => K[e].some((e) => t.includes(e)))), r = t.some((t) => {
3663
+ let n = e.regions[t];
3664
+ return n.widgets.length > 0 || n.activeWidgetId !== void 0 || n.visible;
3665
+ }), i = Object.values(e.locationSubPanelSelections ?? {}).some((e) => Object.keys(e).some((e) => n.has(e)));
3666
+ if (!r && !i) return e;
3667
+ let a = { ...e.regions };
3668
+ for (let e of t) a[e] = {
3669
+ ...a[e],
3670
+ widgets: [],
3671
+ activeWidgetId: void 0,
3672
+ visible: !1
3673
+ };
3674
+ let o = Object.fromEntries(Object.entries(e.locationSubPanelSelections ?? {}).map(([e, t]) => [e, Object.fromEntries(Object.entries(t).filter(([e]) => !n.has(e)))])), s = {
3675
+ ...e,
3676
+ regions: a
3677
+ };
3678
+ return {
3679
+ ...wo(s, [q(s, e.activeWidgetId)]),
3680
+ activeLocationWidgetId: q(s, e.activeLocationWidgetId)?.widgetId,
3681
+ locationSubPanelSelections: o
3682
+ };
3683
+ }, Eo = (e, t) => {
3684
+ let n = new Set(t);
3685
+ return To(e, Object.keys(K).filter((e) => !n.has(e)).flatMap((e) => K[e]));
3686
+ }, Do = (e, t, n, r) => {
3687
+ if (!t) {
3688
+ let t = To(e, bo), i = { ...t.regions };
3689
+ for (let e of bo) i[e] = r.regions[e];
3690
+ return Eo({
3691
+ ...t,
3692
+ regions: i
3693
+ }, n);
3694
+ }
3695
+ let i = { ...e.regions };
3696
+ for (let e of bo) i[e] = t.regions[e];
3697
+ let a = Eo({
3698
+ ...e,
3699
+ regions: i
3700
+ }, n);
3701
+ return {
3702
+ ...wo(a, [q(a, t.activeWidgetId), q(a, e.activeWidgetId)]),
3703
+ activeLocationWidgetId: q(a, t.activeLocationWidgetId)?.widgetId ?? q(a, e.activeLocationWidgetId)?.widgetId,
3704
+ locationSubPanelSelections: t.locationSubPanelSelections
3705
+ };
3706
+ }, Oo = (e) => {
3707
+ for (let t = e.length - 1; t >= 0; --t) Na("mode disposal", () => e[t]?.dispose());
3708
+ }, ko = (e, t) => {
3709
+ t !== e.layout.getLayout() && e.layout.restoreLayout(t);
3710
+ }, J = (e) => `${e.extensionId ?? ""}:page:${e.id}`, Ao = (e, t) => e.find((e) => J(e.ref) === J(t)), jo = (e, t) => e.find((e) => e.id === t), Mo = (e) => {
3711
+ if (!e) return;
3712
+ let t = e.anchors.map((e) => Object.freeze({
3713
+ id: e.id,
3714
+ heading: e.heading,
3715
+ ...e.occurrence === void 0 ? {} : { occurrence: e.occurrence }
3716
+ }));
3717
+ return Object.freeze({ anchors: Object.freeze(t) });
3718
+ }, No = (e) => {
3719
+ if (e) return JSON.parse(JSON.stringify(e));
3720
+ }, Po = (e, t) => {
3721
+ if (!e) return;
3722
+ let n = t.normalize(e);
3723
+ if (!n.type || !n.id) throw Error("Page resource has no canonical type or id");
3724
+ let r = {
3725
+ type: n.type,
3726
+ id: n.id,
3727
+ ...n.projectId ? { projectId: n.projectId } : {},
3728
+ ...n.label ? { label: n.label } : {},
3729
+ ...n.icon ? { icon: n.icon } : {},
3730
+ ...n.extensionId ? { extensionId: n.extensionId } : {},
3731
+ ...n.metadata ? { metadata: No(n.metadata) } : {}
3732
+ };
3733
+ return Object.freeze(r);
3734
+ }, Fo = (e) => Object.freeze({
3735
+ extensionId: e.ref.extensionId,
3736
+ kind: "page",
3737
+ id: e.ref.id
3738
+ }), Io = (e) => e ? JSON.stringify(e) : "", Lo = (e, t) => e.resource ? t.toUri(t.normalize(e.resource)) : "", Ro = (e, t, n) => J(e.page) === J(t.page) && Lo(e, n) === Lo(t, n), Y = (e, t, n = []) => {
3739
+ let r = Ao(n, e.page)?.document, i = r ? e.resource?.metadata?.[r.metadataKey] : void 0;
3740
+ return JSON.stringify([
3741
+ J(e.page),
3742
+ Lo(e, t),
3743
+ i ?? null,
3744
+ e.position ? [
3745
+ e.position.line,
3746
+ e.position.column ?? 1,
3747
+ e.position.endLine ?? null,
3748
+ e.position.endColumn ?? null
3749
+ ] : null,
3750
+ Io(e.section)
3751
+ ]);
3752
+ }, zo = (e, t, n = []) => {
3753
+ let r = Y(e, t, n);
3754
+ return e.parent ? `${r}>${zo(e.parent, t, n)}` : r;
3755
+ }, Bo = (e, t, n, r = []) => {
3756
+ let i = e, a = t;
3757
+ for (; i && a;) {
3758
+ if (Y(i, n, r) !== Y(a, n, r) || JSON.stringify(i.params ?? {}) !== JSON.stringify(a.params ?? {})) return !1;
3759
+ i = i.parent, a = a.parent;
3760
+ }
3761
+ return i === a;
3762
+ }, Vo = (e) => Object.isFrozen(e) ? e : Object.freeze({
3763
+ line: e.line,
3764
+ ...e.column === void 0 ? {} : { column: e.column },
3765
+ ...e.endLine === void 0 ? {} : { endLine: e.endLine },
3766
+ ...e.endColumn === void 0 ? {} : { endColumn: e.endColumn }
3767
+ }), Ho = (e) => {
3768
+ let t = e.page.document?.metadataKey, n = t ? e.resource?.metadata?.[t] : void 0;
3769
+ if (n !== void 0 && (typeof n != "string" || !n)) throw Error("Page location has an invalid document");
3770
+ if (e.position && (!t || !n || e.section || !i(e.position))) throw Error("Page location has an invalid source position");
3771
+ return Object.freeze({
3772
+ page: Fo(e.page),
3773
+ ...e.params ? { params: e.params } : {},
3774
+ ...e.resource ? { resource: Po(e.resource, e.resources) } : {},
3775
+ ...e.section ? { section: Mo(e.section) } : {},
3776
+ ...e.position ? { position: Vo(e.position) } : {},
3777
+ ...e.parent ? { parent: e.parent } : {}
3778
+ });
3779
+ }, Uo = (e) => {
3780
+ if (!e.page.parentId) return;
3781
+ let t = jo(e.pages, e.page.parentId);
3782
+ if (!t) throw Error(`Unknown parent page: ${e.page.parentId}`);
3783
+ return Go({
3784
+ page: t,
3785
+ pages: e.pages,
3786
+ resources: e.resources,
3787
+ seen: e.seen
3788
+ });
3789
+ }, Wo = (e) => ({
3790
+ resource: e.resource,
3791
+ section: e.section,
3792
+ position: e.position,
3793
+ params: e.params
3794
+ }), Go = (e) => {
3795
+ let t = Ho({
3796
+ page: e.page,
3797
+ resources: e.resources,
3798
+ ...e.resource ? { resource: e.resource } : {},
3799
+ ...e.section ? { section: e.section } : {},
3800
+ ...e.position ? { position: e.position } : {},
3801
+ ...e.params ? { params: e.params } : {}
3802
+ }), n = Y(t, e.resources, e.pages);
3803
+ if (e.seen.has(n)) throw Error(`Page location parent cycle reaches ${e.page.id}`);
3804
+ let r = new Set(e.seen).add(n), i = e.parent ?? Uo({
3805
+ page: e.page,
3806
+ pages: e.pages,
3807
+ resources: e.resources,
3808
+ seen: r
3809
+ });
3810
+ return Ho({
3811
+ page: e.page,
3812
+ resources: e.resources,
3813
+ ...t.resource ? { resource: t.resource } : {},
3814
+ ...t.section ? { section: t.section } : {},
3815
+ ...t.position ? { position: t.position } : {},
3816
+ ...t.params ? { params: t.params } : {},
3817
+ ...i ? { parent: i } : {}
3818
+ });
3819
+ }, Ko = (e, t, n) => t?.parent && Ro(e, t, n) ? t.parent : void 0, qo = (e) => {
3820
+ let t = Ao(e.pages, e.target.page);
3821
+ if (!t) throw Error(`Unknown page: ${J(e.target.page)}`);
3822
+ let n = Ho({
3823
+ page: t,
3824
+ resources: e.resources,
3825
+ ...e.target.resource ? { resource: e.target.resource } : {},
3826
+ ...e.target.section ? { section: e.target.section } : {},
3827
+ ...e.target.position ? { position: { ...e.target.position } } : {},
3828
+ params: wt(t.params, e.target.params)
3829
+ }), r = Y(n, e.resources, e.pages);
3830
+ if (e.seen.has(r)) throw Error(`Page location parent cycle reaches ${t.id}`);
3831
+ let i = new Set(e.seen).add(r), a = e.target.parent ? qo({
3832
+ target: e.target.parent,
3833
+ pages: e.pages,
3834
+ resources: e.resources,
3835
+ seen: i
3836
+ }).location : Ko(n, e.active, e.resources), o = Go({
3837
+ page: t,
3838
+ pages: e.pages,
3839
+ resources: e.resources,
3840
+ seen: e.seen,
3841
+ ...n.resource ? { resource: n.resource } : {},
3842
+ ...n.section ? { section: n.section } : {},
3843
+ ...n.position ? { position: n.position } : {},
3844
+ ...n.params ? { params: n.params } : {},
3845
+ ...a ? { parent: a } : {}
3846
+ });
3847
+ return {
3848
+ pageId: t.id,
3849
+ location: o,
3850
+ ...e.target.open ? { open: e.target.open } : {}
3851
+ };
3852
+ }, Jo = (e) => qo({
3853
+ ...e,
3854
+ seen: /* @__PURE__ */ new Set()
3855
+ }), Yo = (e) => {
3856
+ let t = (n, r) => {
3857
+ let i = Ao(e.pages, n.page);
3858
+ if (!i) throw Error(`Unknown page: ${J(n.page)}`);
3859
+ let a = Ho({
3860
+ page: i,
3861
+ resources: e.resources,
3862
+ ...n.resource ? { resource: n.resource } : {},
3863
+ ...n.section ? { section: n.section } : {},
3864
+ ...n.position ? { position: n.position } : {},
3865
+ params: wt(i.params, n.params, !1)
3866
+ }), o = Y(a, e.resources, e.pages);
3867
+ if (r.has(o)) throw Error(`Page location parent cycle reaches ${i.id}`);
3868
+ let s = new Set(r).add(o), c = n.parent ? t(n.parent, s).location : void 0;
3869
+ return {
3870
+ pageId: i.id,
3871
+ location: Go({
3872
+ page: i,
3873
+ pages: e.pages,
3874
+ resources: e.resources,
3875
+ seen: r,
3876
+ ...Wo(a),
3877
+ ...c ? { parent: c } : {}
3878
+ })
3879
+ };
3880
+ };
3881
+ return t(e.location, /* @__PURE__ */ new Set());
3882
+ }, Xo = (e) => {
3883
+ let t = jo(e.pages, e.pageId);
3884
+ if (!t) throw Error(`Unknown page: ${e.pageId}`);
3885
+ return {
3886
+ pageId: t.id,
3887
+ location: Go({
3888
+ page: t,
3889
+ pages: e.pages,
3890
+ resources: e.resources,
3891
+ seen: /* @__PURE__ */ new Set(),
3892
+ ...e.resource ? { resource: e.resource } : {},
3893
+ ...e.section ? { section: e.section } : {},
3894
+ ...e.position ? { position: e.position } : {},
3895
+ ...e.params ? { params: e.params } : {}
3896
+ })
3897
+ };
3898
+ }, Zo = (e, t) => e < t ? -1 : +(e > t), Qo = (e) => e.kind === "shell" ? `shell\0${e.placementId}` : e.kind === "mode" ? `mode\0${e.modeId}\0${e.placementId}` : `page\0${e.pageId}\0${e.slotId}`, X = (e) => e.kind === "shell" ? JSON.stringify([
3899
+ "shell",
3900
+ e.placementId,
3901
+ e.instanceKey
3902
+ ]) : e.kind === "mode" ? JSON.stringify([
3903
+ "mode",
3904
+ e.modeId,
3905
+ e.placementId,
3906
+ e.instanceKey
3907
+ ]) : JSON.stringify([
3908
+ "page",
3909
+ e.pageId,
3910
+ e.slotId,
3911
+ e.instanceKey
3912
+ ]), Z = (e, t) => {
3913
+ let n = Zo(Qo(e.identity), Qo(t.identity));
3914
+ return n === 0 ? Zo(e.identity.instanceKey, t.identity.instanceKey) : n;
3915
+ }, $o = (e, t) => e.order - t.order || Z(e, t), es = (e, t) => {
3916
+ if (t.identity.kind === e) return;
3917
+ let n = `${e[0]?.toUpperCase()}${e.slice(1)}`;
3918
+ throw Error(`${n} placement must have a ${e} owner`);
3919
+ }, ts = (e) => {
3920
+ let t = [], n = /* @__PURE__ */ new Set(), r = (e, r) => {
3921
+ for (let i of r) {
3922
+ if (es(e, i), !Number.isFinite(i.order)) throw Error("Placement order must be a finite number");
3923
+ let r = X(i.identity);
3924
+ if (n.has(r)) throw Error(`Duplicate placement identity: ${r}`);
3925
+ n.add(r), t.push(i);
3926
+ }
3927
+ };
3928
+ if (r("shell", e.shell), r("mode", e.mode ?? []), r("page", e.page ?? []), new Set((e.mode ?? []).map((e) => e.identity.kind === "mode" ? e.identity.modeId : "invalid-mode-owner")).size > 1) throw Error("Mode placements must belong to one active mode");
3929
+ return t;
3930
+ }, ns = () => U.reduce((e, t) => (e[t] = [], e), {}), rs = (e) => {
3931
+ let t = ts(e), n = new Set((e.closed ?? []).map(X)), r = [], i = ns();
3932
+ for (let e of t) {
3933
+ if (n.has(X(e.identity))) {
3934
+ r.push(e);
3935
+ continue;
3936
+ }
3937
+ i[e.region].push(e);
3938
+ }
3939
+ for (let e of U) i[e].sort($o);
3940
+ return r.sort(Z), {
3941
+ placements: U.flatMap((e) => i[e]),
3942
+ closed: r,
3943
+ regions: i,
3944
+ visibleRegions: new Set(U.filter((e) => i[e].length > 0))
3945
+ };
3946
+ }, is = (e) => {
3947
+ let t = /* @__PURE__ */ new Map();
3948
+ for (let n of e) {
3949
+ let e = X(n.identity);
3950
+ if (t.has(e)) throw Error(`Duplicate placement identity: ${e}`);
3951
+ t.set(e, n);
3952
+ }
3953
+ return t;
3954
+ }, as = (e, t, n) => e.region === t.region && e.order === t.order && n(e.value, t.value), os = (e) => {
3955
+ let t = is(e.current), n = is(e.desired), r = [], i = [], a = [], o = [];
3956
+ for (let [o, s] of n) {
3957
+ let n = t.get(o);
3958
+ n ? as(n, s, e.valuesEqual) ? i.push(s) : a.push({
3959
+ current: n,
3960
+ desired: s
3961
+ }) : r.push(s);
3962
+ }
3963
+ for (let [e, r] of t) n.has(e) || o.push(r);
3964
+ let s = new Set((e.activate ?? []).map(X)), c = Array.from(s, (e) => {
3965
+ let t = n.get(e);
3966
+ if (!t) throw Error(`Cannot activate missing placement: ${e}`);
3967
+ return t;
3968
+ });
3969
+ return r.sort(Z), i.sort(Z), a.sort((e, t) => Z(e.desired, t.desired)), c.sort(Z), o.sort(Z), {
3970
+ add: r,
3971
+ retain: i,
3972
+ update: a,
3973
+ activate: c,
3974
+ remove: o,
3975
+ ...e.destinations?.length ? { destinations: e.destinations } : {}
3976
+ };
3977
+ }, ss = "$main", cs = (e) => e.item.kind === "view" ? e.item.presence !== "fixed" : e.role !== "primary" || e.item.binding.cardinality === "many", ls = (e) => {
3978
+ if (e.main.kind !== "view") return;
3979
+ let { kind: t, view: n, cardinality: r, ...i } = e.main, a = e.resource ? {
3980
+ ...e.resource,
3981
+ view: n,
3982
+ cardinality: r
3983
+ } : void 0;
3984
+ return {
3985
+ ...i,
3986
+ id: ss,
3987
+ role: "primary",
3988
+ region: "main",
3989
+ item: a ? {
3990
+ kind: "binding",
3991
+ binding: a
3992
+ } : {
3993
+ kind: "view",
3994
+ view: n,
3995
+ presence: "fixed"
3996
+ }
3997
+ };
3998
+ }, us = (e) => {
3999
+ let t = ls(e);
4000
+ return [...t ? [t] : [], ...e.slots.map((e) => ({
4001
+ ...e,
4002
+ role: "auxiliary"
4003
+ }))];
4004
+ }, ds = (e, t) => {
4005
+ let n = us(e).find((e) => e.id === t);
4006
+ if (!n) throw Error(`Unknown page slot: ${e.id}.${t}`);
4007
+ return n;
4008
+ }, fs = (e) => {
4009
+ if (e.main.kind === "panels") return {
4010
+ id: ss,
4011
+ role: "primary",
4012
+ region: "main",
4013
+ item: {
4014
+ kind: "view",
4015
+ view: e.main.empty,
4016
+ presence: "fixed"
4017
+ }
4018
+ };
4019
+ }, ps = (e) => {
4020
+ let t = fs(e);
4021
+ return [...us(e), ...t ? [t] : []];
4022
+ }, ms = (e, t, n) => e.resource && t ? `${e.id}|${JSON.stringify([n.toUri(n.normalize(t)), e.document ? t.metadata?.[e.document.metadataKey] : null])}` : e.id, hs = (e, t, n) => e.resource && t ? ms(e, t, n) : "default", gs = (e, t, n) => {
4023
+ let r = n === "default" ? t : n;
4024
+ return e === r || e.startsWith(`${r}|`);
4025
+ }, _s = (e, t, n) => e.resource ? ms(e, t?.resource, n) : e.main.kind === "panels" && t ? `${e.id}|${zo({
4026
+ ...t,
4027
+ position: void 0
4028
+ }, n)}` : e.id, vs = (e, t) => Object.fromEntries(Object.entries(e).filter(([e]) => e !== t && !e.startsWith(`${t}|`))), ys = (e) => e.replace(/^['"]|['"]$/g, ""), bs = (e, t) => {
4029
+ let n = t.trim();
4030
+ if (n.length === 0) return !0;
4031
+ let r = n.match(/^([A-Za-z0-9_.-]+)\s*(==|!=)\s*(.+)$/);
4032
+ if (r) {
4033
+ let [, t, n, i] = r, a = e[t ?? ""], o = ys(i ?? "");
4034
+ return n === "==" ? String(a) === o : String(a) !== o;
4035
+ }
4036
+ return n.startsWith("!") ? !e[n.slice(1)] : !!e[n];
4037
+ }, xs = (e, t) => !t || t.split("||").some((t) => t.split("&&").every((t) => bs(e, t))), Ss = () => {
4038
+ let e = Ra({
4039
+ name: "workbench.context",
4040
+ initialState: { values: {} }
4041
+ }), t = {}, n = /* @__PURE__ */ new Map(), r = () => {
4042
+ let e = { ...t };
4043
+ for (let t of n.values()) Object.assign(e, t);
4044
+ return e;
4045
+ }, i = (t) => {
4046
+ e.setState({ values: r() }, !1, t);
4047
+ };
4048
+ return {
4049
+ store: e,
4050
+ set(e, n) {
4051
+ t[e] !== n && (t = {
4052
+ ...t,
4053
+ [e]: n
4054
+ }, i("setContextKey"));
4055
+ },
4056
+ get(t) {
4057
+ return e.getState().values[t];
4058
+ },
4059
+ delete(e) {
4060
+ if (!(e in t)) return;
4061
+ let { [e]: n, ...r } = t;
4062
+ t = r, i("deleteContextKey");
4063
+ },
4064
+ createScope(e) {
4065
+ n.set(e, n.get(e) ?? {});
4066
+ let t = !1, r = () => {
4067
+ if (t) throw Error(`Context key scope disposed: ${e}`);
4068
+ };
4069
+ return {
4070
+ ownerId: e,
4071
+ set(t, a) {
4072
+ r();
4073
+ let o = n.get(e) ?? {};
4074
+ o[t] !== a && (n.set(e, {
4075
+ ...o,
4076
+ [t]: a
4077
+ }), i("setScopedContextKey"));
4078
+ },
4079
+ get(t) {
4080
+ return r(), n.get(e)?.[t];
4081
+ },
4082
+ delete(t) {
4083
+ r();
4084
+ let a = n.get(e);
4085
+ if (!a || !(t in a)) return;
4086
+ let { [t]: o, ...s } = a;
4087
+ n.set(e, s), i("deleteScopedContextKey");
4088
+ },
4089
+ dispose() {
4090
+ t || (t = !0, n.delete(e) && i("disposeContextKeyScope"));
4091
+ }
4092
+ };
4093
+ },
4094
+ deleteOwner(e) {
4095
+ n.delete(e) && i("deleteContextKeyOwner");
4096
+ },
4097
+ snapshot() {
4098
+ return { ...e.getState().values };
4099
+ },
4100
+ matches(t) {
4101
+ return xs(e.getState().values, t);
4102
+ }
4103
+ };
4104
+ }, Cs = (e, t) => {
4105
+ let n = e;
4106
+ for (let r of t.values()) a(r.resource) === a(e) && (n = "removed" in r.change ? void 0 : {
4107
+ ...e,
4108
+ label: r.change.label
4109
+ });
4110
+ return n;
4111
+ }, ws = () => {
4112
+ let e = Ra({
4113
+ name: "workbench.resource-preview",
4114
+ initialState: { changes: /* @__PURE__ */ new Map() }
4115
+ }), t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = (t) => {
4116
+ let n = new Map(e.getState().changes);
4117
+ n.delete(t), e.setState({ changes: n });
4118
+ };
4119
+ return {
4120
+ store: e,
4121
+ resolve(t) {
4122
+ return Cs(t, e.getState().changes);
4123
+ },
4124
+ persist(e, n) {
4125
+ let r = a(e), i = (t.get(r) ?? Promise.resolve()).catch(() => void 0).then(n);
4126
+ return t.set(r, i), i.finally(() => {
4127
+ t.get(r) === i && t.delete(r);
4128
+ }).catch(() => void 0), i;
4129
+ },
4130
+ subscribeRefresh(e) {
4131
+ return n.add(e), V(() => n.delete(e));
4132
+ },
4133
+ begin(t, i) {
4134
+ let a = Symbol("resource mutation");
4135
+ return e.setState({ changes: new Map([...e.getState().changes, [a, {
4136
+ resource: t,
4137
+ change: i
4138
+ }]]) }), {
4139
+ rollback: () => r(a),
4140
+ async commit() {
4141
+ await Promise.allSettled([...n].map((e) => e(t))), r(a);
4142
+ }
4143
+ };
4144
+ }
4145
+ };
4146
+ }, Ts = (e) => "viewId" in e && e.type === "view", Es = "resource_hierarchy_cycle", Ds = (e) => [...e].sort((e, t) => t.priority - e.priority || e.id.localeCompare(t.id)), Os = (e, t, n) => {
4147
+ let r = Ds(e), i = [t], o = /* @__PURE__ */ new Set([`resource:${a(t)}`]), s = t;
4148
+ for (;;) {
4149
+ let e = r.find((e) => e.canResolve(s))?.getParent(s);
4150
+ if (!e) break;
4151
+ let t = Ts(e) ? `view:${e.viewId}` : `resource:${a(e)}`;
4152
+ if (o.has(t)) {
4153
+ n({
4154
+ code: Es,
4155
+ path: [...i],
4156
+ repeatedUri: Ts(e) ? t : a(e)
4157
+ });
4158
+ break;
4159
+ }
4160
+ if (i.unshift(e), o.add(t), Ts(e)) break;
4161
+ s = e;
4162
+ }
4163
+ return i;
4164
+ }, ks = "workbench.resource.type", As = "workbench.resource.extensionId", js = "workbench.resource.id", Ms = (e) => `workbench.resource.metadata.${e}`, Ns = "workbench.selectionResourceKey", Ps = (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean", Fs = (e) => {
4165
+ if (!e) return {};
4166
+ let t = {
4167
+ [ks]: e.type,
4168
+ [js]: e.id,
4169
+ [As]: e.extensionId
4170
+ };
4171
+ for (let [n, r] of Object.entries(e.metadata ?? {})) Ps(r) && (t[Ms(n)] = r);
4172
+ return t;
4173
+ }, Is = (e) => e === "workbench.resource.type" || e === "workbench.resource.extensionId" || e === "workbench.resource.id" || e.startsWith(Ms("")), Ls = (e, t) => {
4174
+ let n = {};
4175
+ for (let [t, r] of Object.entries(e)) Is(t) || (n[t] = r);
4176
+ return {
4177
+ ...n,
4178
+ ...Fs(t)
4179
+ };
4180
+ }, Rs = (e) => ({ [Ns]: a(e) }), zs = (e) => {
4181
+ if (!e) return [];
4182
+ let t = e.metadata?.[Ns];
4183
+ return typeof t != "string" || t === a(e) ? [a(e)] : [a(e), t];
4184
+ }, Bs = (e = {}) => {
4185
+ let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = Ra({
4186
+ name: "workbench.resources",
4187
+ initialState: {
4188
+ kinds: {},
4189
+ providers: {},
4190
+ hierarchyProviders: {}
4191
+ }
4192
+ });
4193
+ return {
4194
+ store: r,
4195
+ preview: ws(),
4196
+ removed(n) {
4197
+ e.remove?.(n, [...t].flatMap((e) => e(n)));
4198
+ },
4199
+ onWillRemove(e) {
4200
+ return t.add(e), V(() => t.delete(e));
4201
+ },
4202
+ registerKind(e, t) {
4203
+ let n = r.getState(), i = e.extensionId ? `${e.extensionId}:${e.kind}` : e.kind;
4204
+ if (n.kinds[i]) throw Error(`Resource kind already registered: ${i}`);
4205
+ let a = {
4206
+ ...ho(t),
4207
+ ...e
4208
+ };
4209
+ return r.setState({
4210
+ ...n,
4211
+ kinds: {
4212
+ ...n.kinds,
4213
+ [i]: a
4214
+ }
4215
+ }, !1, "registerKind"), V(() => {
4216
+ let e = r.getState();
4217
+ if (e.kinds[i] !== a) return;
4218
+ let { [i]: t, ...n } = e.kinds;
4219
+ r.setState({
4220
+ ...e,
4221
+ kinds: n
4222
+ }, !1, "unregisterKind");
4223
+ });
4224
+ },
4225
+ getKind(e, t) {
4226
+ let n = r.getState().kinds;
4227
+ return t ? n[`${t}:${e}`] ?? n[e] : n[e] ?? Object.values(n).find((t) => t.kind === e);
4228
+ },
4229
+ listKinds() {
4230
+ return Object.values(r.getState().kinds).sort(go);
4231
+ },
4232
+ registerProvider(e) {
4233
+ let t = r.getState();
4234
+ if (t.providers[e.id]) throw Error(`Resource provider already registered: ${e.id}`);
4235
+ return r.setState({
4236
+ ...t,
4237
+ providers: {
4238
+ ...t.providers,
4239
+ [e.id]: e
4240
+ }
4241
+ }, !1, "registerProvider"), V(() => {
4242
+ let t = r.getState();
4243
+ if (t.providers[e.id] !== e) return;
4244
+ let { [e.id]: n, ...i } = t.providers;
4245
+ r.setState({
4246
+ ...t,
4247
+ providers: i
4248
+ }, !1, "unregisterProvider");
4249
+ });
4250
+ },
4251
+ listProviders() {
4252
+ return Object.values(r.getState().providers);
4253
+ },
4254
+ listResources(t) {
4255
+ let n = { primary: e.getPrimary?.() }, i = [];
4256
+ for (let e of Object.values(r.getState().providers)) i.push(...e.list(t, n));
4257
+ return i;
4258
+ },
4259
+ listRelatedResources(e) {
4260
+ return Object.values(r.getState().providers).flatMap((t) => t.related?.(e) ?? []);
4261
+ },
4262
+ registerHierarchyProvider(e) {
4263
+ let t = r.getState();
4264
+ if (t.hierarchyProviders[e.id]) throw Error(`Resource hierarchy provider already registered: ${e.id}`);
4265
+ let n = {
4266
+ ...e,
4267
+ priority: e.priority ?? 0
4268
+ };
4269
+ return r.setState({
4270
+ ...t,
4271
+ hierarchyProviders: {
4272
+ ...t.hierarchyProviders,
4273
+ [e.id]: n
4274
+ }
4275
+ }, !1, "registerHierarchyProvider"), V(() => {
4276
+ let t = r.getState();
4277
+ if (t.hierarchyProviders[e.id] !== n) return;
4278
+ let { [e.id]: i, ...a } = t.hierarchyProviders;
4279
+ r.setState({
4280
+ ...t,
4281
+ hierarchyProviders: a
4282
+ }, !1, "unregisterHierarchyProvider");
4283
+ });
4284
+ },
4285
+ listHierarchyProviders() {
4286
+ return Ds(Object.values(r.getState().hierarchyProviders));
4287
+ },
4288
+ walkHierarchy(t) {
4289
+ return t ? Os(Object.values(r.getState().hierarchyProviders), t, (e) => {
4290
+ for (let t of n) t(e);
4291
+ }).map((t) => {
4292
+ if (!Ts(t)) return t;
4293
+ let n = e.resolveView?.(t.viewId);
4294
+ return n ? {
4295
+ ...t,
4296
+ label: n.label,
4297
+ icon: n.icon
4298
+ } : t;
4299
+ }) : [];
4300
+ },
4301
+ onDidDetectHierarchyCycle(e) {
4302
+ return n.add(e), V(() => {
4303
+ n.delete(e);
4304
+ });
4305
+ }
4306
+ };
4307
+ }, Vs = (e) => Array.isArray(e) ? e : e.trim().split(/\s+/).filter(Boolean), Hs = (e) => {
4308
+ let t = Vs(e);
4309
+ return t.length === 1 ? t[0] ?? "" : t;
4310
+ }, Us = (e) => {
4311
+ let t = Ra({
4312
+ name: "workbench.keybindings",
4313
+ initialState: { keybindings: [] }
4314
+ });
4315
+ return {
4316
+ store: t,
4317
+ registerKeybinding(n, r) {
4318
+ if (n.action.kind === "command" && !e.commands.getCommand(n.action.commandId)) throw Error(`Keybinding command not registered: ${n.action.commandId}`);
4319
+ let i = {
4320
+ ...ho(r),
4321
+ ...n,
4322
+ keybinding: Hs(n.keybinding)
4323
+ }, a = t.getState();
4324
+ return t.setState({ keybindings: [...a.keybindings, i] }, !1, "registerKeybinding"), V(() => {
4325
+ let e = t.getState(), n = e.keybindings.filter((e) => e !== i);
4326
+ n.length !== e.keybindings.length && t.setState({ keybindings: n }, !1, "unregisterKeybinding");
4327
+ });
4328
+ },
4329
+ listKeybindings() {
4330
+ return [...t.getState().keybindings].sort(go);
4331
+ },
4332
+ listActiveKeybindings() {
4333
+ return t.getState().keybindings.filter((t) => e.context.matches(t.when)).sort(go);
4334
+ },
4335
+ listCommandKeybindings() {
4336
+ return [...t.getState().keybindings].sort(go).flatMap((e) => e.action.kind === "command" ? [{
4337
+ commandId: e.action.commandId,
4338
+ keybinding: e.keybinding
4339
+ }] : []);
4340
+ }
4341
+ };
4342
+ }, Ws = (e, t, n) => ({
4343
+ role: "anchor",
4344
+ anchor: e,
4345
+ persistence: t,
4346
+ candidates: n
4347
+ }), Q = (e, t = !1) => t ? {
4348
+ role: "projection",
4349
+ reads: e,
4350
+ navigator: t
4351
+ } : {
4352
+ role: "projection",
4353
+ reads: e
4354
+ }, Gs = {
4355
+ nav: Q(["primary", "attached"]),
4356
+ activity: { role: "chrome" },
4357
+ sidenav: Q(["primary"], !0),
4358
+ "main-header": Q(["primary"]),
4359
+ "main-left-menu": Q(["primary"]),
4360
+ main: Ws("primary", "primary", "global"),
4361
+ "main-right-menu": Q(["primary"]),
4362
+ "secondary-header": Q(["primary"]),
4363
+ "secondary-left-menu": Q(["secondary"]),
4364
+ secondary: Ws("secondary", "derived", "scoped"),
4365
+ "secondary-right-menu": Q(["secondary"]),
4366
+ status: Q(["primary", "attached"]),
4367
+ overlay: { role: "transient" },
4368
+ "side-header": Q(["attached"]),
4369
+ "side-left-menu": Q(["attached"]),
4370
+ side: Ws("attached", "detached", "scoped"),
4371
+ "side-right-menu": Q(["attached"])
4372
+ }, Ks = (e) => Gs[e], qs = () => U.filter((e) => Gs[e].role === "anchor"), Js = (e) => {
4373
+ let t = U.find((t) => {
4374
+ let n = Gs[t];
4375
+ return n.role === "anchor" && n.anchor === e;
4376
+ });
4377
+ if (!t) throw Error(`No region hosts anchor: ${e}`);
4378
+ return t;
4379
+ }, Ys = (e, t) => {
4380
+ let n = Xa(e.regions[Js(t)]);
4381
+ if (t !== "primary") return n?.resource;
4382
+ let r = G(e);
4383
+ return r ? r.resource : n?.role === "sub-panel" ? void 0 : n?.resource;
4384
+ }, Xs = ({ layout: e, primary: t, isInScope: n }) => {
4385
+ let r = [];
4386
+ for (let i of qs()) {
4387
+ let a = Ks(i);
4388
+ if (a.role === "anchor" && a.persistence !== "primary") for (let o of e.regions[i].widgets) {
4389
+ if (!o.resource) continue;
4390
+ let e = o.role === "location" || o.role === "sub-panel" && (!!o.ownerResourceKey || o.placementIdentity?.kind === "shell" || o.placementIdentity?.kind === "mode") || a.persistence !== "derived" && n(o.resource, t);
4391
+ r.push({
4392
+ region: i,
4393
+ widgetId: o.widgetId,
4394
+ action: e ? "keep" : "clear"
4395
+ });
4396
+ }
4397
+ }
4398
+ return r;
4399
+ }, Zs = (e) => [
4400
+ "workbench",
4401
+ "header",
4402
+ e,
4403
+ "leading"
4404
+ ], Qs = (e) => [
4405
+ "workbench",
4406
+ "header",
4407
+ e,
4408
+ "trailing"
4409
+ ], $s = (e) => [
4410
+ "workbench",
4411
+ "regionTabs",
4412
+ e,
4413
+ "leading"
4414
+ ], ec = (e) => [
4415
+ "workbench",
4416
+ "regionTabs",
4417
+ e,
4418
+ "add"
4419
+ ], tc = ["workbench", "commandPalette"], nc = Zs("nav"), rc = Qs("nav"), ic = [
4420
+ "workbench",
4421
+ "breadcrumb",
4422
+ "location"
4423
+ ], ac = (e) => [
4424
+ "workbench",
4425
+ "resource",
4426
+ e,
4427
+ "context"
4428
+ ], oc = (e, t) => e.kinds.some((e) => e.id === t.type && (!t.extensionId || !e.extensionId || t.extensionId === e.extensionId)), sc = (e) => Array.isArray(e) ? e.map(sc) : e && typeof e == "object" ? Object.fromEntries(Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, t]) => [e, sc(t)])) : e, cc = (e) => {
4429
+ if (e.kind === "command" && e.args && typeof e.args == "object" && !Array.isArray(e.args) && Object.keys(e.args).length === 0) {
4430
+ let { args: t, ...n } = e;
4431
+ return JSON.stringify(sc(n));
4432
+ }
4433
+ return JSON.stringify(sc(e));
4434
+ }, lc = /* @__PURE__ */ new WeakMap(), uc = (e, t) => {
4435
+ lc.set(e, t);
4436
+ }, dc = (e, t) => {
4437
+ let n = lc.get(e);
4438
+ return t && n?.registryToken !== t ? void 0 : n;
4439
+ }, fc = (e, t) => JSON.stringify([a(t), e?.document ? t?.metadata?.[e.document.metadataKey] ?? null : null]), pc = (e, t, n) => {
4440
+ let r = n.normalize(t);
4441
+ return e.document && e.resource && oc(e.resource, r) ? ms(e, r, n) : n.toUri(r);
4442
+ }, mc = {
4443
+ project: "folder-root",
4444
+ workspace: "computer",
4445
+ worktree: "git-pull-request-draft",
4446
+ settings: "settings",
4447
+ kanbanRenderer: "table-properties"
4448
+ }, hc = (e, t = "view") => JSON.stringify([t, e.placementIdentity ? X(e.placementIdentity) : e.instanceId]), gc = async (e, t) => {
4449
+ let n = new AbortController(), r = () => n.abort(t?.reason);
4450
+ t?.aborted ? r() : t?.addEventListener("abort", r, { once: !0 });
4451
+ let i;
4452
+ try {
4453
+ let r = await Promise.allSettled(e.map(async (e) => {
4454
+ try {
4455
+ return n.signal.throwIfAborted(), await e(n.signal);
4456
+ } catch (e) {
4457
+ throw i ??= e, n.abort(e), e;
4458
+ }
4459
+ }));
4460
+ if (i !== void 0) throw i;
4461
+ return t?.throwIfAborted(), r.map((e) => {
4462
+ if (e.status === "rejected") throw e.reason;
4463
+ return e.value;
4464
+ });
4465
+ } finally {
4466
+ t?.removeEventListener("abort", r);
4467
+ }
4468
+ }, _c = (e, t, n) => {
4469
+ e.notifications.show({
4470
+ level: "error",
4471
+ title: `${t} failed`,
4472
+ message: n instanceof Error ? n.message : String(n)
4473
+ });
4474
+ }, vc = async (e, t, n) => {
4475
+ try {
4476
+ await n();
4477
+ } catch (n) {
4478
+ _c(e, t, n);
4479
+ }
4480
+ }, yc = (e, t, n) => Object.fromEntries(Object.entries(e).map(([e, r]) => {
4481
+ if (e !== t.pageId && !e.startsWith(`${t.pageId}|`)) return [e, r];
4482
+ let i = (r.resourceInstances[t.slotId] ?? []).flatMap((e) => e.instanceKey === t.instanceKey ? n.kind === "close" ? [] : [{
4483
+ ...e,
4484
+ open: n.open
4485
+ }] : [e]);
4486
+ return [e, {
4487
+ ...r,
4488
+ openStaticSlotIds: n.kind === "close" && gs(e, t.pageId, t.instanceKey) ? r.openStaticSlotIds.filter((e) => e !== t.slotId) : r.openStaticSlotIds,
4489
+ resourceInstances: {
4490
+ ...r.resourceInstances,
4491
+ [t.slotId]: i
4492
+ },
4493
+ activePrimaryInstanceKey: n.kind === "close" && r.activePrimaryInstanceKey === t.instanceKey ? i.at(-1)?.instanceKey : r.activePrimaryInstanceKey
4494
+ }];
4495
+ })), bc = (e) => e.value.role === "sub-panel" && e.identity.kind === "page", xc = (e, t, n) => bc(e) ? e.value.ownerResourceKey ?? t?.ownerResourceKey ?? n?.ownerResourceKey : e.value.ownerResourceKey, Sc = (e) => {
4496
+ let t = /* @__PURE__ */ new Map();
4497
+ for (let n of Object.values(e.regions)) for (let e of n.widgets) {
4498
+ if (!e.placementIdentity) continue;
4499
+ let r = X(e.placementIdentity);
4500
+ if (t.has(r)) throw Error(`Duplicate rendered placement identity: ${r}`);
4501
+ t.set(r, {
4502
+ region: n.id,
4503
+ placement: e
4504
+ });
4505
+ }
4506
+ return t;
4507
+ }, Cc = (e) => {
4508
+ if (e.desired.identity.kind !== "mode") return;
4509
+ let t = e.desired.identity;
4510
+ return [...e.current.entries()].find(([n, r]) => !e.desiredKeys.has(n) && !e.transferredCurrentKeys.has(n) && r.placement.placementIdentity?.kind === "mode" && (r.placement.placementIdentity.modeId !== t.modeId || r.placement.placementIdentity.placementId !== t.placementId) && r.region === e.desired.region && r.placement.contributionId === e.desired.value.contributionId && r.placement.viewId === e.desired.value.viewId);
4511
+ }, wc = (e) => {
4512
+ let t = /* @__PURE__ */ new Map();
4513
+ for (let n of Object.values(e.regions)) for (let e of n.widgets) {
4514
+ if (t.has(e.widgetId)) throw Error(`Duplicate rendered widget ID: ${e.widgetId}`);
4515
+ t.set(e.widgetId, e.placementIdentity ? X(e.placementIdentity) : null);
4516
+ }
4517
+ return t;
4518
+ }, Tc = (e, t, n, r) => {
4519
+ let i = new Set(e.map((e) => e.widgetId)), a = [...e, ...t.filter((e) => !i.has(e.widgetId) && e.placementIdentity && n.has(X(e.placementIdentity)))];
4520
+ if (!r) return a;
4521
+ let o = new Map(r.map((e, t) => [e, t])), s = a.sort((e, t) => (o.get(e.widgetId) ?? r.length) - (o.get(t.widgetId) ?? r.length)), c = new Map(t.map((e, t) => [e.widgetId, t])), l = s.filter((e) => e.placementIdentity?.kind !== "page").sort((e, n) => (c.get(e.widgetId) ?? t.length) - (c.get(n.widgetId) ?? t.length)), u = 0;
4522
+ return s.map((e) => e.placementIdentity?.kind === "page" ? e : l[u++]);
4523
+ }, Ec = (e, t) => {
4524
+ let n = [], r = /* @__PURE__ */ new Set(), i = wc(e.layout), a = e.modeLayout ? Sc(e.modeLayout) : /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), s = new Map(e.destinations?.map((e) => [X(e.identity), e.region])), c = rs({
4525
+ shell: e.placements.filter((e) => e.identity.kind === "shell"),
4526
+ mode: e.placements.filter((e) => e.identity.kind === "mode"),
4527
+ page: e.placements.filter((e) => e.identity.kind === "page")
4528
+ }).placements, l = new Set(c.map((e) => X(e.identity))), u = /* @__PURE__ */ new Set();
4529
+ for (let e of c) {
4530
+ let c = X(e.identity);
4531
+ if (r.has(c)) throw Error(`Duplicate desired placement identity: ${c}`);
4532
+ r.add(c);
4533
+ let d = t.get(c) ?? a.get(c), f = d ? void 0 : Cc({
4534
+ current: t,
4535
+ desired: e,
4536
+ desiredKeys: l,
4537
+ transferredCurrentKeys: u
4538
+ }), p = f?.[0];
4539
+ p && u.add(p);
4540
+ let m = d?.placement.widgetId ?? f?.[1].placement.widgetId ?? e.value.widgetId, h = i.get(m);
4541
+ if (h !== void 0 && h !== c && h !== p) throw Error(`Rendered widget ID belongs to another placement: ${m}`);
4542
+ if (o.has(m)) throw Error(`Duplicate desired widget ID: ${m}`);
4543
+ o.add(m);
4544
+ let ee = xc(e, d?.placement, f?.[1].placement);
4545
+ n.push({
4546
+ identity: e.identity,
4547
+ region: s.get(c) ?? d?.region ?? e.region,
4548
+ placement: {
4549
+ ...e.value,
4550
+ widgetId: m,
4551
+ placementIdentity: e.identity,
4552
+ ...ee ? { ownerResourceKey: ee } : {}
4553
+ },
4554
+ ...p ? { transferredFromKey: p } : {}
4555
+ });
4556
+ }
4557
+ return n;
4558
+ }, Dc = (e, t, n, i) => {
4559
+ let a = new Set(r.filter((e) => e !== "side")), o = { ...e.regions }, s = new Map(t.map((e) => [X(e.identity), e])), c = new Set(t.flatMap((e) => e.transferredFromKey ?? []));
4560
+ for (let r of U) {
4561
+ let l = e.regions[r], u = t.some((e) => e.region === r && e.identity.kind === "page" && e.placement.role === "location"), d = /* @__PURE__ */ new Set(), f = Tc(l.widgets, i?.regions[r].widgets ?? [], s, l.savedWidgetOrder).flatMap((e) => {
4562
+ if (!e.placementIdentity) return r === "main" && u && e.role === "location" ? [] : [e];
4563
+ let t = X(e.placementIdentity), i = s.get(t);
4564
+ return i ? i.region === r ? (d.add(t), [i.placement]) : [] : n.has(t) || c.has(t) ? [] : [e];
4565
+ });
4566
+ for (let e of t) {
4567
+ let t = X(e.identity);
4568
+ e.region === r && !d.has(t) && f.push(e.placement);
4569
+ }
4570
+ let p = Ua(f, t.find((e) => e.region === r && e.placement.tabRetention === "preview")?.placement.widgetId ?? l.activeWidgetId), m = l.widgets.find((e) => e.widgetId === l.activeWidgetId), h = [
4571
+ l.activeWidgetId,
4572
+ m?.tabRetention === "preview" ? p.widgets.find((e) => e.tabRetention === "preview")?.widgetId : void 0,
4573
+ i?.regions[r].activeWidgetId
4574
+ ].find((e) => p.widgets.some((t) => t.widgetId === e)) ?? p.widgets[0]?.widgetId, ee = l.widgets.length === 0 && f.some((e) => !e.hiddenByDefault), te = (r === "side" || r === "secondary") && l.widgets.length > 0 && f.length === 0;
4575
+ o[r] = {
4576
+ ...l,
4577
+ widgets: p.widgets,
4578
+ savedWidgetOrder: void 0,
4579
+ activeWidgetId: h,
4580
+ ...a.has(r) ? { visible: l.visible || ee } : {},
4581
+ ...te ? { visible: !1 } : {}
4582
+ };
4583
+ }
4584
+ return {
4585
+ ...e,
4586
+ regions: o
4587
+ };
4588
+ }, Oc = (e) => {
4589
+ let t = new Set(e.desired.flatMap((e) => e.transferredFromKey ?? [])), n = e.layout;
4590
+ for (let [r, i] of e.current) e.removedKeys.has(r) && !t.has(r) && (n = eo(n, i.placement.widgetId));
4591
+ let r = n.activeLocationWidgetId ? W(n, n.activeLocationWidgetId)?.placement : void 0, i = G(n), a = r?.widgetId ?? i?.widgetId, o = n.activeWidgetId ? W(n, n.activeWidgetId)?.placement : void 0, s = a ? W(n, a)?.placement : Object.values(n.regions).flatMap((e) => e.widgets)[0];
4592
+ return {
4593
+ ...n,
4594
+ activeWidgetId: o?.widgetId ?? s?.widgetId,
4595
+ activeLocationWidgetId: a,
4596
+ activeResourceKey: o?.resourceKey ?? s?.resourceKey
4597
+ };
4598
+ }, kc = (e, t) => {
4599
+ let n = G(e)?.resourceKey;
4600
+ if (!n) return e;
4601
+ let r = new Map(t.map((e) => [X(e.identity), e])), i = Object.fromEntries(Object.entries(e.regions).map(([e, t]) => [e, {
4602
+ ...t,
4603
+ widgets: t.widgets.map((e) => {
4604
+ if (e.role !== "sub-panel" || !e.placementIdentity) return e;
4605
+ let t = r.get(X(e.placementIdentity));
4606
+ return !t || t.identity.kind !== "page" ? e : {
4607
+ ...e,
4608
+ ownerResourceKey: n
4609
+ };
4610
+ })
4611
+ }]));
4612
+ return {
4613
+ ...e,
4614
+ regions: i
4615
+ };
4616
+ }, Ac = (e, t) => {
4617
+ if (e.placements.length === 0 && t.size === 0 && (e.activate?.length ?? 0) === 0) return e.layout;
4618
+ let n = Sc(e.layout), r = Ec(e, n), i = Oc({
4619
+ current: n,
4620
+ desired: r,
4621
+ removedKeys: t,
4622
+ layout: Dc(e.layout, r, t, e.modeLayout)
4623
+ }), a = new Map(r.map((e) => [X(e.identity), e]));
4624
+ for (let t of e.activate ?? []) {
4625
+ let e = a.get(X(t));
4626
+ if (!e) throw Error(`Cannot activate missing rendered placement: ${X(t)}`);
4627
+ i = io(i, e.region, e.placement);
4628
+ }
4629
+ return kc(i, r);
4630
+ }, jc = (e) => {
4631
+ let t = new Set(e.placements.map((e) => X(e.identity))), n = Sc(e.layout);
4632
+ return Ac(e, new Set([...n.keys()].filter((e) => !t.has(e))));
4633
+ }, Mc = (e) => Ac(e, new Set(e.remove.map(X))), Nc = (e, t, n) => {
4634
+ let r = e.placementIdentity;
4635
+ if (r?.kind !== "page") return !1;
4636
+ let i = (e, t) => gs(e, r.pageId, r.instanceKey) && t?.openStaticSlotIds.includes(r.slotId) || t?.resourceInstances[r.slotId]?.some((e) => e.instanceKey === r.instanceKey);
4637
+ return Object.entries(n.pageStates).some(([e, n]) => (e === r.pageId || e.startsWith(`${r.pageId}|`)) && i(e, n) && !i(e, t.pageStates[e]));
4638
+ }, Pc = (e) => ({
4639
+ projectId: e.projectId,
4640
+ modeId: e.activeModeId,
4641
+ pageId: e.activePageId,
4642
+ resource: e.location?.resource
4643
+ }), $ = (e, t) => e.projectId !== t.projectId || e.activeModeId !== t.activeModeId || e.activePageId !== t.activePageId || fc(e.pages[e.activePageId ?? ""], e.location?.resource) !== fc(t.pages[t.activePageId ?? ""], t.location?.resource), Fc = (e, t) => new Set(Object.values(e?.regions ?? {}).flatMap((e) => e.widgets.flatMap((n) => e.id === "main" === t && n.placementIdentity ? [X(n.placementIdentity)] : []))), Ic = (e, t, n) => {
4644
+ let r = e.placementIdentity;
4645
+ if (!r) return !1;
4646
+ if (r.kind !== "page") return n;
4647
+ if (r.pageId !== t.activePageId) return !0;
4648
+ let i = t.pages[r.pageId], a = i && ps(i).find((e) => e.id === r.slotId), o = a?.item.kind === "binding" ? a.item.binding : i?.resource;
4649
+ return o && (!e.resource || !oc(o, e.resource)) ? !1 : !!(i?.resource && fc(i, e.resource) !== fc(i, t.location?.resource));
4650
+ }, Lc = (e, t, n) => {
4651
+ let { state: r, previous: i, layout: a, pageLayout: o } = e, s = $(r, i), c = new Set(r.reconciliation.activate.map((e) => X(e.identity))), l = [...t], u = s ? o?.regions.main.widgets : a.regions.main.widgets;
4652
+ for (let [t, a] of (u ?? []).entries()) {
4653
+ let o = a.placementIdentity;
4654
+ if (!o || !e.getWidget(a.contributionId) || Nc(a, r, i) || !Ic(a, r, s)) continue;
4655
+ let u = X(o);
4656
+ if (n.has(u)) continue;
4657
+ let d = l.find((e) => X(e.identity) === u);
4658
+ l = l.filter((e) => X(e.identity) !== u), l.push({
4659
+ identity: o,
4660
+ region: "main",
4661
+ order: t,
4662
+ value: c.has(u) && d ? d.value : a
4663
+ });
4664
+ }
4665
+ return l;
4666
+ }, Rc = (e, t) => {
4667
+ let n = t.placementIdentity;
4668
+ if (n?.kind !== "page" || !t.resource) return t;
4669
+ let r = Object.entries(e.state.pageStates).filter(([e]) => e === n.pageId || e.startsWith(`${n.pageId}|`)).flatMap(([, e]) => e.resourceInstances[n.slotId] ?? []).find((e) => e.instanceKey === n.instanceKey && a(e.resource) === a(t.resource));
4670
+ return r ? {
4671
+ ...t,
4672
+ resource: r.resource,
4673
+ title: r.resource.label ?? e.getWidget(t.contributionId)?.title ?? t.title
4674
+ } : t;
4675
+ }, zc = (e, t) => {
4676
+ let n = X(t.placementIdentity), r = e.state.reconciliation.activate.find((e) => X(e.identity) === n);
4677
+ return r ? {
4678
+ ...r.value,
4679
+ widgetId: t.widgetId
4680
+ } : Rc(e, t);
4681
+ }, Bc = (e, t, n) => {
4682
+ let r = t.placementIdentity;
4683
+ return r?.kind === "page" && !!e.getWidget(t.contributionId) && e.state.pages[r.pageId]?.modeId === e.state.activeModeId && !(n && t.tabRetention === "preview") && !Nc(t, e.state, e.previous);
4684
+ }, Vc = (e, t, n) => {
4685
+ let { state: r, previous: i } = e, a = $(r, i) && r.projectId === i.projectId && r.activeModeId === i.activeModeId, o = [...t];
4686
+ for (let t of Object.values(n?.regions ?? {})) if (t.id === "side" || t.id === "secondary") for (let [n, r] of t.widgets.entries()) {
4687
+ let i = r.placementIdentity;
4688
+ if (!i || !Bc(e, r, a)) continue;
4689
+ let s = X(i);
4690
+ o = o.filter((e) => X(e.identity) !== s), o.push({
4691
+ identity: i,
4692
+ region: t.id,
4693
+ order: n,
4694
+ value: zc(e, r)
4695
+ });
4696
+ }
4697
+ return o;
4698
+ }, Hc = (e) => {
4699
+ let { state: t, previous: n, layout: r, modeLayout: i } = e;
4700
+ if (!t.activePageId) return t;
4701
+ let a = $(t, n), o = t.projectId === n.projectId && t.activeModeId === n.activeModeId ? r : i, s = n.activePageId ? Fc(r, !0) : /* @__PURE__ */ new Set(), c = Fc(o, !1), l = new Set(t.reconciliation.activate.map((e) => X(e.identity))), u = Vc(e, Lc(e, t.placements.filter((e) => {
4702
+ let t = X(e.identity);
4703
+ return !a || !s.has(t) || c.has(t) || l.has(t);
4704
+ }), c), o);
4705
+ return {
4706
+ ...t,
4707
+ placements: u,
4708
+ reconciliation: os({
4709
+ current: n.placements,
4710
+ desired: u,
4711
+ destinations: t.reconciliation.destinations,
4712
+ activate: t.reconciliation.activate.filter((e) => u.some((t) => X(t.identity) === X(e.identity))).map((e) => e.identity),
4713
+ valuesEqual: (e, t) => JSON.stringify(e) === JSON.stringify(t)
4714
+ })
4715
+ };
4716
+ }, Uc = (e, t, n, r) => {
4717
+ let i = Ec({
4718
+ layout: n,
4719
+ modeLayout: r,
4720
+ placements: e.placements,
4721
+ destinations: e.reconciliation.destinations
4722
+ }, Sc(n)), a = [
4723
+ ...e.reconciliation.activate,
4724
+ ...e.reconciliation.add,
4725
+ ...e.reconciliation.update.map((e) => e.desired)
4726
+ ].filter((e) => e.value.tabRetention === "preview").map((e) => X(e.identity)), o = /* @__PURE__ */ new Set();
4727
+ for (let e of Object.values(n.regions)) {
4728
+ let t = i.filter((t) => t.region === e.id), n = a.map((e) => t.find((t) => X(t.identity) === e)).find(Boolean), r = Ua(t.map((e) => e.placement), n?.placement.widgetId ?? e.activeWidgetId);
4729
+ for (let e of r.replaced) e.placementIdentity && o.add(X(e.placementIdentity));
4730
+ }
4731
+ return Wc(e, t, o);
4732
+ }, Wc = (e, t, n) => {
4733
+ if (!n.size) return e;
4734
+ let r = e.placements.filter((e) => !n.has(X(e.identity))), i = e.pageStates;
4735
+ for (let t of e.placements) {
4736
+ let e = t.identity;
4737
+ e.kind === "page" && n.has(X(e)) && (i = yc(i, e, { kind: "close" }));
4738
+ }
4739
+ return {
4740
+ ...e,
4741
+ placements: r,
4742
+ pageStates: i,
4743
+ reconciliation: os({
4744
+ current: t.placements,
4745
+ desired: r,
4746
+ destinations: e.reconciliation.destinations,
4747
+ activate: e.reconciliation.activate.filter((e) => !n.has(X(e.identity))).map((e) => e.identity),
4748
+ valuesEqual: (e, t) => JSON.stringify(e) === JSON.stringify(t)
4749
+ })
4750
+ };
4751
+ }, Gc = (e, t, n) => !t.activePageId || t.projectId !== e.projectId || t.activeModeId !== e.activeModeId || !$(e, t) ? [] : Object.values(n.regions).flatMap((e) => e.widgets.filter((e) => e.tabRetention === "preview")), Kc = (e, t, n) => {
4752
+ let r = Gc(e, t, n), i = Wc(e, t, new Set(r.flatMap((t) => {
4753
+ if (!t.placementIdentity) return [];
4754
+ let n = X(t.placementIdentity), r = e.placements.find((e) => X(e.identity) === n);
4755
+ return r?.value.tabRetention === "preview" && a(r.value.resource) === a(t.resource) ? [n] : [];
4756
+ }))), o = i.pageStates;
4757
+ for (let e of r) {
4758
+ let t = e.placementIdentity;
4759
+ t?.kind === "page" && (o = yc(o, t, { kind: "close" }));
4760
+ }
4761
+ return r.length ? {
4762
+ ...i,
4763
+ pageStates: o
4764
+ } : i;
4765
+ }, qc = /* @__PURE__ */ new WeakMap(), Jc = (e, t) => {
4766
+ qc.set(e, t);
4767
+ }, Yc = (e) => {
4768
+ let t = qc.get(e);
4769
+ if (!t) throw Error("Workbench renderers are not initialized");
4770
+ return t;
4771
+ };
4772
+ //#endregion
4773
+ export { _s as $, U as $t, $s as A, fo as At, Rs as B, Xa as Bt, oc as C, vt as Cn, _o as Ct, ic as D, ho as Dt, ac as E, go as Et, Js as F, Ya as Ft, As as G, $a as Gt, Ls as H, no as Ht, Us as I, qa as It, Ts as J, Wa as Jt, ks as K, Ka as Kt, Vs as L, W as Lt, rc as M, po as Mt, Ys as N, io as Nt, tc as O, co as Ot, Xs as P, ro as Pt, xs as Q, za as Qt, Bs as R, Ja as Rt, cc as S, St as Sn, Do as St, Qs as T, x as Tn, vo as Tt, js as U, to as Ut, zs as V, eo as Vt, Ms as W, ao as Wt, Cs as X, Ha as Xt, Es as Y, Ua as Yt, Ss as Z, Ba as Zt, mc as _, Kt as _n, Oo as _t, Wc as a, Ri as an, us as at, dc as b, wt as bn, xo as bt, Pc as c, Mi as cn, rs as ct, jc as d, qr as dn, Xo as dt, Ra as en, vs as et, yc as f, Vr as fn, Yo as ft, hc as g, Qt as gn, Eo as gt, gc as h, mn as hn, Bo as ht, Gc as i, V as in, ps as it, nc as j, uo as jt, ec as k, so as kt, Hc as l, Li as ln, X as lt, vc as m, un as mn, Y as mt, Jc as n, Fa as nn, ss as nt, Uc as o, Bi as on, ls as ot, _c as p, Br as pn, Jo as pt, Ns as q, Ga as qt, Kc as r, Na as rn, cs as rt, $ as s, zi as sn, ds as st, Yc as t, Ia as tn, hs as tt, Mc as u, Ai as un, os as ut, fc as v, T as vn, So as vt, Zs as w, _t as wn, yo as wt, uc as x, Tt as xn, ko as xt, pc as y, Ot as yn, Co as yt, Fs as z, G as zt };
4774
+
4775
+ //# sourceMappingURL=workbench-renderers-Bz_dLyHW.js.map