@pstdio/workbench 0.39.0 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,670 @@
1
+ import { c as e, t } from "./workbench-renderers-CUHzLWMx.js";
2
+ import { a as n, o as r, s as i, st as a } from "./react-B-rd34kK.js";
3
+ import { resourceKey as o } from "@pstdio/sdk/extensions";
4
+ import { c as s } from "react/compiler-runtime";
5
+ import { Box as c, Button as l, Center as u, Flex as d, Image as f, Spinner as p, Text as m } from "@chakra-ui/react";
6
+ import { AlertMessage as h, EmptyState as g, Header as _, resolveFileIconElement as v, useFileIconThemePreference as y } from "@pstdio/ui";
7
+ import { jsx as b, jsxs as x } from "react/jsx-runtime";
8
+ import { useEffect as S, useLayoutEffect as C, useRef as w, useState as T } from "react";
9
+ import { CodeEditor as E } from "@pstdio/ui/diff";
10
+ import { MarkdownEditor as ee } from "@pstdio/ui/rich-text";
11
+ //#region src/core/registries/renderers/file-section-navigation.ts
12
+ var D = "pstdio.fileSectionNavigation", O = (e) => {
13
+ if (!e || typeof e != "object") return !1;
14
+ let t = e, n = t.occurrence === void 0 || typeof t.occurrence == "number" && Number.isInteger(t.occurrence) && t.occurrence >= 0;
15
+ return typeof t.id == "string" && typeof t.heading == "string" && n;
16
+ }, k = (e) => {
17
+ let t = e?.metadata?.[D];
18
+ if (!t || typeof t != "object") return;
19
+ let n = t;
20
+ if (typeof n.treeId == "string" && typeof n.targetNodeId == "string" && Array.isArray(n.anchors) && n.anchors.every(O)) return {
21
+ treeId: n.treeId,
22
+ targetNodeId: n.targetNodeId,
23
+ anchors: n.anchors
24
+ };
25
+ }, A = (e, t) => t && e.anchors.some((e) => e.id === t) ? t : e.targetNodeId, j = (e) => {
26
+ let { previous: t, current: n, currentResourceKey: r, selectedNodeId: i } = e;
27
+ return !t || !i || !t.anchorIds.includes(i) || n?.targetNodeId === i ? !1 : !n || t.treeId !== n.treeId || t.resourceKey !== r;
28
+ }, te = /* @__PURE__ */ new Set([
29
+ "png",
30
+ "jpg",
31
+ "jpeg",
32
+ "gif",
33
+ "webp",
34
+ "svg",
35
+ "avif",
36
+ "bmp",
37
+ "ico"
38
+ ]), M = /* @__PURE__ */ new Set([
39
+ "md",
40
+ "markdown",
41
+ "txt"
42
+ ]), N = {
43
+ ts: "typescript",
44
+ tsx: "typescript",
45
+ js: "javascript",
46
+ jsx: "javascript",
47
+ mjs: "javascript",
48
+ cjs: "javascript",
49
+ json: "json",
50
+ jsonc: "json",
51
+ py: "python",
52
+ rb: "ruby",
53
+ rs: "rust",
54
+ go: "go",
55
+ java: "java",
56
+ kt: "kotlin",
57
+ c: "c",
58
+ h: "c",
59
+ cpp: "cpp",
60
+ cc: "cpp",
61
+ hpp: "cpp",
62
+ cs: "csharp",
63
+ php: "php",
64
+ swift: "swift",
65
+ sh: "shell",
66
+ bash: "shell",
67
+ zsh: "shell",
68
+ sql: "sql",
69
+ css: "css",
70
+ scss: "scss",
71
+ less: "less",
72
+ html: "html",
73
+ xml: "xml",
74
+ yml: "yaml",
75
+ yaml: "yaml",
76
+ toml: "ini",
77
+ ini: "ini",
78
+ dockerfile: "dockerfile",
79
+ graphql: "graphql",
80
+ gql: "graphql",
81
+ md: "markdown",
82
+ markdown: "markdown",
83
+ txt: "plaintext"
84
+ }, P = (e) => {
85
+ if (!e) return "";
86
+ let t = e.lastIndexOf(".");
87
+ return t < 0 || t === e.length - 1 ? "" : e.slice(t + 1).toLowerCase();
88
+ }, F = (e, t) => t?.startsWith("image/") ? !0 : te.has(P(e)), I = (e, t) => {
89
+ if (F(e, t)) return "image";
90
+ let n = P(e);
91
+ return !M.has(n) && n in N ? "code" : "markdown";
92
+ }, L = (e) => N[P(e)] ?? "plaintext", ne = (e, t) => {
93
+ if (e.emptyState) return {
94
+ kind: "empty",
95
+ isEditable: !1
96
+ };
97
+ let n = I(e.fileName, e.mimeType);
98
+ if (n === "image") return {
99
+ kind: "image",
100
+ isEditable: !1
101
+ };
102
+ let r = t && e.editable !== !1;
103
+ return n === "code" || e.textRenderer === "monaco" ? {
104
+ kind: "code",
105
+ isEditable: r,
106
+ language: L(e.fileName)
107
+ } : {
108
+ kind: "markdown",
109
+ isEditable: r
110
+ };
111
+ }, re = (e) => {
112
+ let t = s(49), { content: n, position: r, editorKey: i, errorNotice: a, contributionCanSave: o, onActiveSectionChange: l, onChange: p, rendererRef: _, sectionNavigation: v, title: y } = e, S;
113
+ t[0] !== n || t[1] !== o ? (S = ne(n, o), t[0] = n, t[1] = o, t[2] = S) : S = t[2];
114
+ let C = S, w;
115
+ t[3] !== r || t[4] !== C.kind ? (w = r && C.kind !== "code" && C.kind !== "empty" ? /* @__PURE__ */ b(h, {
116
+ status: "info",
117
+ title: "Source location unavailable",
118
+ children: "This preview does not support source line selection."
119
+ }) : null, t[3] = r, t[4] = C.kind, t[5] = w) : w = t[5];
120
+ let T = w;
121
+ if (C.kind === "empty") {
122
+ let e = n.emptyState?.title ?? "Select a file", r = n.emptyState?.description, i;
123
+ t[6] !== e || t[7] !== r ? (i = /* @__PURE__ */ b(g, {
124
+ flex: "1",
125
+ minH: "0",
126
+ title: e,
127
+ description: r
128
+ }), t[6] = e, t[7] = r, t[8] = i) : i = t[8];
129
+ let o;
130
+ return t[9] !== a || t[10] !== T || t[11] !== i ? (o = /* @__PURE__ */ x(d, {
131
+ direction: "column",
132
+ h: "full",
133
+ minH: "0",
134
+ bg: "bg",
135
+ children: [
136
+ a,
137
+ T,
138
+ i
139
+ ]
140
+ }), t[9] = a, t[10] = T, t[11] = i, t[12] = o) : o = t[12], o;
141
+ }
142
+ if (C.kind === "image") {
143
+ if (!n.dataUrl) {
144
+ let e;
145
+ return t[13] === Symbol.for("react.memo_cache_sentinel") ? (e = /* @__PURE__ */ b(u, {
146
+ h: "full",
147
+ minH: "0",
148
+ bg: "bg",
149
+ p: "md",
150
+ children: /* @__PURE__ */ b(m, {
151
+ color: "fg.muted",
152
+ children: "This image preview is unavailable."
153
+ })
154
+ }), t[13] = e) : e = t[13], e;
155
+ }
156
+ let e = n.fileName ?? y, r;
157
+ t[14] !== n.dataUrl || t[15] !== e ? (r = /* @__PURE__ */ b(f, {
158
+ src: n.dataUrl,
159
+ alt: e,
160
+ maxW: "100%",
161
+ maxH: "100%",
162
+ objectFit: "contain"
163
+ }), t[14] = n.dataUrl, t[15] = e, t[16] = r) : r = t[16];
164
+ let i;
165
+ t[17] !== _ || t[18] !== r ? (i = /* @__PURE__ */ b(u, {
166
+ ref: _,
167
+ flex: "1",
168
+ minH: "0",
169
+ p: "md",
170
+ overflow: "auto",
171
+ children: r
172
+ }), t[17] = _, t[18] = r, t[19] = i) : i = t[19];
173
+ let o;
174
+ return t[20] !== a || t[21] !== T || t[22] !== i ? (o = /* @__PURE__ */ x(d, {
175
+ direction: "column",
176
+ h: "full",
177
+ minH: "0",
178
+ bg: "bg",
179
+ children: [
180
+ a,
181
+ T,
182
+ i
183
+ ]
184
+ }), t[20] = a, t[21] = T, t[22] = i, t[23] = o) : o = t[23], o;
185
+ }
186
+ if (C.kind === "code") {
187
+ let e = n.content ?? "", o = C.isEditable ? p : void 0, s;
188
+ t[24] !== n.fileName || t[25] !== i || t[26] !== r || t[27] !== C.isEditable || t[28] !== C.language || t[29] !== e || t[30] !== o ? (s = /* @__PURE__ */ b(c, {
189
+ flex: "1",
190
+ minH: "0",
191
+ children: /* @__PURE__ */ b(E, {
192
+ language: C.language,
193
+ position: r,
194
+ fileName: n.fileName,
195
+ defaultCode: e,
196
+ isEditable: C.isEditable,
197
+ showLineNumbers: !0,
198
+ onChange: o
199
+ }, i)
200
+ }), t[24] = n.fileName, t[25] = i, t[26] = r, t[27] = C.isEditable, t[28] = C.language, t[29] = e, t[30] = o, t[31] = s) : s = t[31];
201
+ let l;
202
+ return t[32] !== a || t[33] !== T || t[34] !== s ? (l = /* @__PURE__ */ x(d, {
203
+ direction: "column",
204
+ h: "full",
205
+ minH: "0",
206
+ bg: "bg",
207
+ children: [
208
+ a,
209
+ T,
210
+ s
211
+ ]
212
+ }), t[32] = a, t[33] = T, t[34] = s, t[35] = l) : l = t[35], l;
213
+ }
214
+ let D = n.content ?? "", O = C.isEditable ? n.placeholder ?? "Write…" : void 0, k = C.isEditable ? p : void 0, A;
215
+ t[36] !== i || t[37] !== l || t[38] !== C.isEditable || t[39] !== v || t[40] !== D || t[41] !== O || t[42] !== k ? (A = /* @__PURE__ */ b(c, {
216
+ flex: "1",
217
+ minH: "0",
218
+ overflowY: "auto",
219
+ children: /* @__PURE__ */ b(ee, {
220
+ defaultState: D,
221
+ isEditable: C.isEditable,
222
+ sectionNavigation: v,
223
+ placeholder: O,
224
+ onActiveSectionChange: l,
225
+ onChange: k
226
+ }, i)
227
+ }), t[36] = i, t[37] = l, t[38] = C.isEditable, t[39] = v, t[40] = D, t[41] = O, t[42] = k, t[43] = A) : A = t[43];
228
+ let j;
229
+ return t[44] !== a || t[45] !== T || t[46] !== _ || t[47] !== A ? (j = /* @__PURE__ */ x(d, {
230
+ ref: _,
231
+ direction: "column",
232
+ h: "full",
233
+ minH: "0",
234
+ overflow: "hidden",
235
+ bg: "bg",
236
+ children: [
237
+ a,
238
+ T,
239
+ A
240
+ ]
241
+ }), t[44] = a, t[45] = T, t[46] = _, t[47] = A, t[48] = j) : j = t[48], j;
242
+ }, ie = (e) => {
243
+ let t, n = !1, r, i = null, a = null, o, s, c = !1, l = null, u = 0, d = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set(), p = (e) => e instanceof Error ? e.message : "Failed to save file.", m = () => ({
244
+ dirty: i !== null || a !== null && a.value !== t,
245
+ saving: a !== null,
246
+ ...o ? { saveError: o } : {},
247
+ ...n ? { removed: !0 } : {}
248
+ }), h = () => e.onStateChange?.(m()), g = () => {
249
+ l !== null && (clearTimeout(l), l = null);
250
+ }, _ = () => e.createOperationId?.() ?? `file-save-${Date.now()}-${++u}`, v = () => i !== null || a !== null || l !== null || !!o, y = (e) => {
251
+ e.revision && (!s || e.revision.localeCompare(s) > 0) && (s = e.revision), e.revision || (c = !0);
252
+ }, b = (t) => {
253
+ let n = t.origin?.operationId;
254
+ return !n || t.origin?.rendererId !== e.binding.rendererId || t.origin.instanceId !== e.binding.instanceId ? !1 : a?.origin.operationId === n || f.has(n);
255
+ }, x = (t) => {
256
+ if (i !== null || a) return;
257
+ let n = s, r = c;
258
+ if (s = void 0, c = !1, n && (!t || n.localeCompare(t) > 0)) {
259
+ e.load({
260
+ resourceKey: e.binding.resourceKey,
261
+ revision: n
262
+ });
263
+ return;
264
+ }
265
+ r && e.load({ resourceKey: e.binding.resourceKey });
266
+ }, S = () => {
267
+ if (n || i === null || a || o) return;
268
+ let s = i;
269
+ i = null;
270
+ let c = {
271
+ rendererId: e.binding.rendererId,
272
+ instanceId: e.binding.instanceId,
273
+ operationId: _()
274
+ };
275
+ a = {
276
+ value: s,
277
+ origin: c
278
+ }, h(), Promise.resolve(e.save(s, c)).then((e) => {
279
+ if (a?.origin.operationId === c.operationId) {
280
+ if (a = null, f.add(c.operationId), f.size > 20 && f.delete(f.values().next().value), t = s, r = e?.revision ?? r, i === t && (i = null, g()), h(), i !== null) {
281
+ C();
282
+ return;
283
+ }
284
+ x(e?.revision);
285
+ }
286
+ }).catch((e) => {
287
+ n || a?.origin.operationId === c.operationId && (a = null, i === null && (i = s), o = p(e), h());
288
+ });
289
+ }, C = () => {
290
+ g(), l = setTimeout(() => {
291
+ l = null, S();
292
+ }, e.debounceMs);
293
+ };
294
+ return {
295
+ getDraft() {
296
+ return i ?? a?.value ?? t;
297
+ },
298
+ markRemoved() {
299
+ let e = v();
300
+ return n = !0, i = i ?? a?.value ?? null, a = null, g(), h(), e;
301
+ },
302
+ getBaseline() {
303
+ return t;
304
+ },
305
+ getState: m,
306
+ setBaseline(e, n) {
307
+ t = e, r = n, h();
308
+ },
309
+ acceptLoaded(e, i) {
310
+ if (n) return null;
311
+ if (v()) return y(i ? { revision: i } : {}), null;
312
+ let a = t;
313
+ return t = e, r = i, h(), { shown: a };
314
+ },
315
+ handleChange(e) {
316
+ if (n) {
317
+ i = e, h();
318
+ return;
319
+ }
320
+ if (!(o && e === i)) {
321
+ if (o = void 0, e === t && !a) {
322
+ i = null, g(), h();
323
+ return;
324
+ }
325
+ if (a?.value === e) {
326
+ i = null, g(), h();
327
+ return;
328
+ }
329
+ i = e, C(), h();
330
+ }
331
+ },
332
+ handleRefreshEvent(t = {}) {
333
+ if (!n && !(t.resourceKey && t.resourceKey !== e.binding.resourceKey) && !b(t) && !(t.revision && d.has(t.revision))) {
334
+ if (t.revision && d.add(t.revision), v()) {
335
+ y(t);
336
+ return;
337
+ }
338
+ t.revision && r && t.revision.localeCompare(r) <= 0 || e.load(t);
339
+ }
340
+ },
341
+ retry() {
342
+ o && i !== null && !a && (o = void 0, h(), S());
343
+ },
344
+ retryLoad() {
345
+ n || e.load({ resourceKey: e.binding.resourceKey });
346
+ },
347
+ flush() {
348
+ g(), S();
349
+ }
350
+ };
351
+ }, ae = (e) => {
352
+ let t = s(7), { message: n, onRetry: r } = e, i;
353
+ t[0] === n ? i = t[1] : (i = /* @__PURE__ */ b(m, {
354
+ color: "fg.muted",
355
+ textStyle: "label/S/regular",
356
+ children: n
357
+ }), t[0] = n, t[1] = i);
358
+ let a;
359
+ t[2] === r ? a = t[3] : (a = r ? /* @__PURE__ */ b(l, {
360
+ size: "2xs",
361
+ variant: "subtle",
362
+ onClick: r,
363
+ children: "Retry"
364
+ }) : null, t[2] = r, t[3] = a);
365
+ let o;
366
+ return t[4] !== i || t[5] !== a ? (o = /* @__PURE__ */ x(d, {
367
+ flex: "none",
368
+ alignItems: "center",
369
+ justifyContent: "space-between",
370
+ gap: "sm",
371
+ borderBottomWidth: "1px",
372
+ borderColor: "border.muted",
373
+ bg: "bg.muted",
374
+ px: "sm",
375
+ py: "xs",
376
+ children: [i, a]
377
+ }), t[4] = i, t[5] = a, t[6] = o) : o = t[6], o;
378
+ }, R = (e) => Array.isArray(e) ? e.map(R) : !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, t]) => [e, R(t)])), oe = (e) => {
379
+ let { fileRendererId: t, resource: n } = e, r = n ? R({
380
+ id: n.id,
381
+ type: n.type,
382
+ metadata: n.metadata
383
+ }) : null;
384
+ return `${JSON.stringify(o(n))}:${t}:${JSON.stringify(r)}`;
385
+ }, se = (e, t) => e?.loadKey === t, z = (e) => {
386
+ let t = s(9), { fileName: n, filePath: r } = e, { activeFileIconTheme: i } = y(), a;
387
+ t[0] !== i || t[1] !== n ? (a = v(n, { theme: i }), t[0] = i, t[1] = n, t[2] = a) : a = t[2];
388
+ let o = `File path ${r}`, c;
389
+ t[3] !== r || t[4] !== o ? (c = /* @__PURE__ */ b(m, {
390
+ "aria-label": o,
391
+ textStyle: "label/S/regular",
392
+ color: "fg.muted",
393
+ truncate: !0,
394
+ children: r
395
+ }), t[3] = r, t[4] = o, t[5] = c) : c = t[5];
396
+ let l;
397
+ return t[6] !== a || t[7] !== c ? (l = /* @__PURE__ */ x(_, {
398
+ variant: "narrow",
399
+ flexShrink: 0,
400
+ gap: "2xs",
401
+ bg: "bg",
402
+ children: [a, c]
403
+ }), t[6] = a, t[7] = c, t[8] = l) : l = t[8], l;
404
+ }, ce = 600, le = (e) => e instanceof Error ? e.message : "Failed to load file.", ue = (e) => {
405
+ let { workbench: n, navigation: r, sectionId: i } = e;
406
+ if (!r || !t(n).getTreeRenderer(r.treeId)) return;
407
+ if (i && r.anchors.some((e) => e.id === i)) {
408
+ t(n).setSelectedNode(r.treeId, i);
409
+ return;
410
+ }
411
+ let a = t(n).getTreeState(r.treeId).selectedNodeId;
412
+ a && r.anchors.some((e) => e.id === a) && t(n).setSelectedNode(r.treeId, void 0);
413
+ }, de = (e, n) => {
414
+ if (!n) return;
415
+ let r = t(e).getTreeRenderer(n.treeId) ? t(e).getTreeState(n.treeId).selectedNodeId : void 0;
416
+ return {
417
+ anchors: n.anchors,
418
+ targetId: A(n, r)
419
+ };
420
+ }, fe = (e, t) => {
421
+ let n = s(2), r;
422
+ return n[0] === t ? r = n[1] : (r = (e) => {
423
+ let n = e.location;
424
+ if (!n?.position || o(n.resource) !== o(t)) return;
425
+ let r = Object.values(e.pages).find((e) => e.ref.id === n.page.id && e.ref.extensionId === n.page.extensionId)?.document?.metadataKey;
426
+ if (r && n.resource?.metadata?.[r] === t?.metadata?.[r]) return n.position;
427
+ }, n[0] = t, n[1] = r), a(e.pages.store, r);
428
+ }, pe = (e) => {
429
+ let t = s(3), { file: n } = e, r;
430
+ return t[0] !== n.fileName || t[1] !== n.filePath ? (r = n.filePath ? /* @__PURE__ */ b(z, {
431
+ fileName: n.fileName ?? n.filePath,
432
+ filePath: n.filePath
433
+ }) : null, t[0] = n.fileName, t[1] = n.filePath, t[2] = r) : r = t[2], r;
434
+ }, B = (a) => {
435
+ let f = s(71), { workbench: h, contribution: g } = a, _ = a.placement?.resource, v = fe(h, _), y, E;
436
+ f[0] !== _ || f[1] !== h ? (y = k(_), E = de(h, y), f[0] = _, f[1] = h, f[2] = y, f[3] = E) : (y = f[2], E = f[3]);
437
+ let ee = E, D = oe({
438
+ fileRendererId: g.id,
439
+ resource: _
440
+ }), [O, A] = T(null), [te, M] = T(null), N;
441
+ f[4] === Symbol.for("react.memo_cache_sentinel") ? (N = {
442
+ dirty: !1,
443
+ saving: !1
444
+ }, f[4] = N) : N = f[4];
445
+ let [P, F] = T(N), I = w(null), L = w(void 0), ne = w(null), R = w(null), z, B;
446
+ f[5] !== _ || f[6] !== y || f[7] !== h ? (z = () => {
447
+ let e = R.current, n = e && t(h).getTreeRenderer(e.treeId) ? t(h).getTreeState(e.treeId).selectedNodeId : void 0;
448
+ j({
449
+ previous: e,
450
+ current: y,
451
+ currentResourceKey: o(_),
452
+ selectedNodeId: n
453
+ }) && e && t(h).setSelectedNode(e.treeId, void 0), R.current = y ? {
454
+ resourceKey: o(_),
455
+ treeId: y.treeId,
456
+ anchorIds: y.anchors.map(me)
457
+ } : null;
458
+ }, B = [
459
+ _,
460
+ y,
461
+ h
462
+ ], f[5] = _, f[6] = y, f[7] = h, f[8] = z, f[9] = B) : (z = f[8], B = f[9]), S(z, B);
463
+ let he = w(g), V = w(_), ge = w(a.placement), H;
464
+ f[10] !== g || f[11] !== a.placement || f[12] !== _ ? (H = () => {
465
+ he.current = g, V.current = _, ge.current = a.placement;
466
+ }, f[10] = g, f[11] = a.placement, f[12] = _, f[13] = H) : H = f[13], S(H);
467
+ let U = g.id, W = !!g.save, G = a.placement ? e(a.placement) : JSON.stringify([
468
+ "file",
469
+ U,
470
+ D
471
+ ]), K = a.placement?.instanceId ?? U, q;
472
+ f[14] !== U || f[15] !== W || f[16] !== K || f[17] !== D || f[18] !== G || f[19] !== F || f[20] !== M || f[21] !== A || f[22] !== h ? (q = () => {
473
+ let e = !1, a = !1, s = V.current, c = he.current, l = h.views.reads.bind(G), u = null;
474
+ M(null);
475
+ let d = r(D);
476
+ A(d ? {
477
+ ...d,
478
+ editorRevision: 1,
479
+ loadKey: D
480
+ } : null);
481
+ let f = (t) => {
482
+ let r = t === void 0 ? "refresh" : t;
483
+ l.request({
484
+ queryKey: D,
485
+ load: (e) => he.current.load(V.current, e),
486
+ onValue: (t) => {
487
+ if (e || a) return;
488
+ let r = n(t, D, u);
489
+ r && (M(null), A(r));
490
+ },
491
+ onError: (t) => {
492
+ e || a || M({
493
+ loadKey: D,
494
+ message: le(t)
495
+ });
496
+ }
497
+ }, r);
498
+ };
499
+ L.current = () => f("retry"), u = W ? ie({
500
+ binding: {
501
+ rendererId: U,
502
+ instanceId: K,
503
+ resourceKey: o(V.current)
504
+ },
505
+ debounceMs: ce,
506
+ load: () => f(),
507
+ onStateChange: (t) => {
508
+ e || F(t);
509
+ },
510
+ save: (e, t) => Promise.resolve(c.save?.(s, e, t)).then((t) => {
511
+ let n = r(D);
512
+ return n && !a && i(D, {
513
+ ...n,
514
+ content: e
515
+ }), t ?? void 0;
516
+ })
517
+ }) : null, I.current = u, d && I.current?.setBaseline(d.content, d.revision), F({
518
+ dirty: !1,
519
+ saving: !1
520
+ }), f();
521
+ let p = h.resources.onWillRemove((e) => {
522
+ if (o(e) !== o(V.current)) return [];
523
+ a = !0;
524
+ let t = I.current?.markRemoved(), n = ge.current?.placementIdentity;
525
+ return t && n ? [n] : [];
526
+ }), m = t(h).onDidRefreshFileRenderer((e) => {
527
+ if (a || e.fileRendererId !== U) return;
528
+ let t = I.current;
529
+ t ? t.handleRefreshEvent(e) : f();
530
+ });
531
+ return () => {
532
+ e = !0, l.dispose(), L.current = void 0, m.dispose(), p.dispose(), u?.flush(), I.current === u && (I.current = null);
533
+ };
534
+ }, f[14] = U, f[15] = W, f[16] = K, f[17] = D, f[18] = G, f[19] = F, f[20] = M, f[21] = A, f[22] = h, f[23] = q) : q = f[23];
535
+ let _e;
536
+ f[24] !== U || f[25] !== W || f[26] !== K || f[27] !== D || f[28] !== G || f[29] !== h ? (_e = [
537
+ U,
538
+ W,
539
+ h,
540
+ D,
541
+ G,
542
+ K
543
+ ], f[24] = U, f[25] = W, f[26] = K, f[27] = D, f[28] = G, f[29] = h, f[30] = _e) : _e = f[30], S(q, _e);
544
+ let ve, ye;
545
+ f[31] === Symbol.for("react.memo_cache_sentinel") ? (ve = () => {
546
+ let e = () => I.current?.flush(), t = () => {
547
+ document.visibilityState === "hidden" && e();
548
+ };
549
+ return window.addEventListener("beforeunload", e), document.addEventListener("visibilitychange", t), () => {
550
+ window.removeEventListener("beforeunload", e), document.removeEventListener("visibilitychange", t);
551
+ };
552
+ }, ye = [], f[31] = ve, f[32] = ye) : (ve = f[31], ye = f[32]), S(ve, ye);
553
+ let be;
554
+ f[33] === Symbol.for("react.memo_cache_sentinel") ? (be = (e) => {
555
+ I.current?.handleChange(e);
556
+ }, f[33] = be) : be = f[33];
557
+ let xe = be, Se;
558
+ f[34] !== D || f[35] !== O ? (Se = se(O, D) ? O : null, f[34] = D, f[35] = O, f[36] = Se) : Se = f[36];
559
+ let J = Se, Ce = J ? `${J.loadKey}:${J.editorRevision}` : "", we, Te;
560
+ f[37] !== Ce || f[38] !== y ? (we = () => {
561
+ if (!Ce || y) return;
562
+ let e = ne.current;
563
+ e && requestAnimationFrame(() => {
564
+ let t = e.parentElement;
565
+ for (; t;) {
566
+ let e = getComputedStyle(t).overflowY;
567
+ [
568
+ "auto",
569
+ "scroll",
570
+ "overlay"
571
+ ].includes(e) && t.scrollHeight > t.clientHeight && (t.scrollTop = 0), t = t.parentElement;
572
+ }
573
+ });
574
+ }, Te = [Ce, y], f[37] = Ce, f[38] = y, f[39] = we, f[40] = Te) : (we = f[39], Te = f[40]), C(we, Te);
575
+ let Y = te?.loadKey === D ? te.message : void 0;
576
+ if (Y && !J) {
577
+ let e;
578
+ f[41] === Y ? e = f[42] : (e = /* @__PURE__ */ b(m, {
579
+ color: "fg.muted",
580
+ children: Y
581
+ }), f[41] = Y, f[42] = e);
582
+ let t;
583
+ f[43] === Symbol.for("react.memo_cache_sentinel") ? (t = /* @__PURE__ */ b(l, {
584
+ size: "xs",
585
+ variant: "subtle",
586
+ onClick: () => L.current?.(),
587
+ children: "Retry"
588
+ }), f[43] = t) : t = f[43];
589
+ let n;
590
+ return f[44] === e ? n = f[45] : (n = /* @__PURE__ */ x(u, {
591
+ h: "full",
592
+ minH: "0",
593
+ bg: "bg",
594
+ p: "md",
595
+ flexDirection: "column",
596
+ gap: "sm",
597
+ children: [e, t]
598
+ }), f[44] = e, f[45] = n), n;
599
+ }
600
+ if (!J) {
601
+ let e;
602
+ return f[46] === Symbol.for("react.memo_cache_sentinel") ? (e = /* @__PURE__ */ b(u, {
603
+ h: "full",
604
+ minH: "0",
605
+ bg: "bg",
606
+ children: /* @__PURE__ */ b(p, { size: "sm" })
607
+ }), f[46] = e) : e = f[46], e;
608
+ }
609
+ let Ee = `${J.loadKey}:${J.editorRevision}`, X = null;
610
+ if (P.removed) {
611
+ let e;
612
+ f[47] === Symbol.for("react.memo_cache_sentinel") ? (e = /* @__PURE__ */ b(ae, { message: "This resource was removed. Your draft is kept here. Copy it before closing this tab." }), f[47] = e) : e = f[47], X = e;
613
+ } else if (Y) {
614
+ let e;
615
+ f[48] === Symbol.for("react.memo_cache_sentinel") ? (e = () => L.current?.(), f[48] = e) : e = f[48];
616
+ let t;
617
+ f[49] === Y ? t = f[50] : (t = /* @__PURE__ */ b(ae, {
618
+ message: Y,
619
+ onRetry: e
620
+ }), f[49] = Y, f[50] = t), X = t;
621
+ } else if (P.saveError) {
622
+ let e;
623
+ f[51] === Symbol.for("react.memo_cache_sentinel") ? (e = () => I.current?.retry(), f[51] = e) : e = f[51];
624
+ let t;
625
+ f[52] === P.saveError ? t = f[53] : (t = /* @__PURE__ */ b(ae, {
626
+ message: P.saveError,
627
+ onRetry: e
628
+ }), f[52] = P.saveError, f[53] = t), X = t;
629
+ }
630
+ let Z;
631
+ f[54] === J ? Z = f[55] : (Z = /* @__PURE__ */ b(pe, { file: J }), f[54] = J, f[55] = Z);
632
+ let De = X, Oe = !!g.save, Q;
633
+ f[56] !== y || f[57] !== h ? (Q = y ? (e) => ue({
634
+ workbench: h,
635
+ navigation: y,
636
+ sectionId: e
637
+ }) : void 0, f[56] = y, f[57] = h, f[58] = Q) : Q = f[58];
638
+ let $;
639
+ f[59] !== g.title || f[60] !== J || f[61] !== Ee || f[62] !== ee || f[63] !== X || f[64] !== v || f[65] !== Oe || f[66] !== Q ? ($ = /* @__PURE__ */ b(c, {
640
+ flex: "1",
641
+ minH: "0",
642
+ children: /* @__PURE__ */ b(re, {
643
+ content: J,
644
+ position: v,
645
+ editorKey: Ee,
646
+ errorNotice: De,
647
+ contributionCanSave: Oe,
648
+ onActiveSectionChange: Q,
649
+ onChange: xe,
650
+ rendererRef: ne,
651
+ sectionNavigation: ee,
652
+ title: g.title
653
+ })
654
+ }), f[59] = g.title, f[60] = J, f[61] = Ee, f[62] = ee, f[63] = X, f[64] = v, f[65] = Oe, f[66] = Q, f[67] = $) : $ = f[67];
655
+ let ke;
656
+ return f[68] !== Z || f[69] !== $ ? (ke = /* @__PURE__ */ x(d, {
657
+ direction: "column",
658
+ h: "full",
659
+ minH: "0",
660
+ bg: "bg",
661
+ children: [Z, $]
662
+ }), f[68] = Z, f[69] = $, f[70] = ke) : ke = f[70], ke;
663
+ };
664
+ function me(e) {
665
+ return e.id;
666
+ }
667
+ //#endregion
668
+ export { B as WorkbenchFileRendererView };
669
+
670
+ //# sourceMappingURL=file-renderer-view-CiuJ_aMB.js.map