@pstdio/workbench 0.12.0 → 0.35.0

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