@loomcycle/explorer 0.14.0 → 0.16.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.
package/dist/index.js CHANGED
@@ -1219,7 +1219,7 @@ function qe(e) {
1219
1219
  }
1220
1220
  //#endregion
1221
1221
  //#region src/lib/clipboard.ts
1222
- async function Je(e) {
1222
+ async function $(e) {
1223
1223
  try {
1224
1224
  return typeof navigator > "u" || !navigator.clipboard ? !1 : (await navigator.clipboard.writeText(e), !0);
1225
1225
  } catch {
@@ -1228,10 +1228,10 @@ async function Je(e) {
1228
1228
  }
1229
1229
  //#endregion
1230
1230
  //#region src/components/IdCopy.tsx
1231
- function $({ value: e, label: t, compact: n, title: r }) {
1231
+ function Je({ value: e, label: t, compact: n, title: r }) {
1232
1232
  let [i, a] = o("idle"), s = async (t) => {
1233
1233
  t.stopPropagation(), t.preventDefault();
1234
- let n = await Je(e);
1234
+ let n = await $(e);
1235
1235
  a(n ? "copied" : "error"), window.setTimeout(() => a("idle"), n ? 1200 : 1500);
1236
1236
  }, c = i === "copied" ? "✓" : i === "error" ? "✗" : "⎘", d = r ?? `Copy ${t ?? "id"}: ${e}`, f = /* @__PURE__ */ l("button", {
1237
1237
  type: "button",
@@ -1384,7 +1384,7 @@ function et({ node: e, expanded: t, toggle: n, selectedId: r, onSelect: i, tintS
1384
1384
  })
1385
1385
  ]
1386
1386
  }),
1387
- /* @__PURE__ */ l($, {
1387
+ /* @__PURE__ */ l(Je, {
1388
1388
  value: e.row.id,
1389
1389
  compact: !0,
1390
1390
  title: `Copy chunk id: ${e.row.id}`
@@ -2877,8 +2877,75 @@ function Bt(e, t) {
2877
2877
  return n.length > 30 ? n.slice(0, 29) + "…" : n;
2878
2878
  }
2879
2879
  //#endregion
2880
+ //#region src/components/StackSplitter.tsx
2881
+ var Vt = 6;
2882
+ function Ht(e, t, n, r) {
2883
+ let i = Math.max(r, t - n - Vt);
2884
+ return Math.round(Math.max(r, Math.min(e, i)));
2885
+ }
2886
+ function Ut({ children: e, defaultBottomHeight: n = 240, minTopHeight: i = 96, minBottomHeight: s = 48, storageKey: c, className: d }) {
2887
+ let [f, p] = o(() => {
2888
+ if (c) try {
2889
+ let e = parseInt(localStorage.getItem(c) ?? "", 10);
2890
+ if (Number.isFinite(e) && e >= s) return e;
2891
+ } catch {}
2892
+ return n;
2893
+ }), m = a(null), [h, g] = o(!1);
2894
+ r(() => {
2895
+ if (c && !h) try {
2896
+ localStorage.setItem(c, String(f));
2897
+ } catch {}
2898
+ }, [
2899
+ c,
2900
+ f,
2901
+ h
2902
+ ]);
2903
+ let _ = t((e) => {
2904
+ e.preventDefault(), g(!0), e.target.setPointerCapture(e.pointerId);
2905
+ }, []), v = t((e) => {
2906
+ if (!h || !m.current) return;
2907
+ let t = m.current.getBoundingClientRect();
2908
+ p(Ht(t.bottom - e.clientY, t.height, i, s));
2909
+ }, [
2910
+ h,
2911
+ i,
2912
+ s
2913
+ ]), y = t((e) => {
2914
+ g(!1);
2915
+ try {
2916
+ e.target.releasePointerCapture(e.pointerId);
2917
+ } catch {}
2918
+ }, []);
2919
+ return /* @__PURE__ */ u("div", {
2920
+ ref: m,
2921
+ className: `stack-splitter ${d ?? ""} ${h ? "dragging" : ""}`,
2922
+ style: { gridTemplateRows: `minmax(${i}px, 1fr) ${Vt}px min(${f}px, calc(100% - ${i + Vt}px))` },
2923
+ children: [
2924
+ /* @__PURE__ */ l("div", {
2925
+ className: "stack-splitter-pane stack-splitter-top",
2926
+ children: e[0]
2927
+ }),
2928
+ /* @__PURE__ */ l("div", {
2929
+ className: "stack-splitter-handle",
2930
+ role: "separator",
2931
+ "aria-orientation": "horizontal",
2932
+ "aria-valuenow": f,
2933
+ title: "Drag to share the space between the text and its links",
2934
+ onPointerDown: _,
2935
+ onPointerMove: v,
2936
+ onPointerUp: y,
2937
+ onPointerCancel: y
2938
+ }),
2939
+ /* @__PURE__ */ l("div", {
2940
+ className: "stack-splitter-pane stack-splitter-bottom",
2941
+ children: e[1]
2942
+ })
2943
+ ]
2944
+ });
2945
+ }
2946
+ //#endregion
2880
2947
  //#region src/components/DocUnavailable.tsx
2881
- function Vt({ documentId: e, scope: t, detail: n }) {
2948
+ function Wt({ documentId: e, scope: t, detail: n }) {
2882
2949
  return /* @__PURE__ */ u("div", {
2883
2950
  className: "doc-unavailable",
2884
2951
  role: "alert",
@@ -2901,11 +2968,11 @@ function Vt({ documentId: e, scope: t, detail: n }) {
2901
2968
  }
2902
2969
  //#endregion
2903
2970
  //#region src/components/HistoryModal.tsx
2904
- function Ht(e) {
2971
+ function Gt(e) {
2905
2972
  let t = typeof e == "number" ? e / 1e6 : Date.parse(String(e));
2906
2973
  return !Number.isFinite(t) || t <= 0 ? String(e ?? "") : new Date(t).toLocaleString();
2907
2974
  }
2908
- function Ut({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
2975
+ function Kt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
2909
2976
  let s = M(), [d, f] = o([]), [p, m] = o(!0), [h, g] = o(null), [_, v] = o("none"), [y, b] = o(null), [x, S] = o(""), [C, w] = o(!1), [T, E] = o(null), [D, O] = o(null), [k, A] = o("");
2910
2977
  r(() => {
2911
2978
  let t = !1;
@@ -2990,7 +3057,7 @@ function Ut({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
2990
3057
  }),
2991
3058
  /* @__PURE__ */ l("span", {
2992
3059
  className: "doc-hist-rev-time",
2993
- children: Ht(e.created_at)
3060
+ children: Gt(e.created_at)
2994
3061
  }),
2995
3062
  /* @__PURE__ */ l("span", {
2996
3063
  className: "doc-hist-rev-actor",
@@ -3038,7 +3105,7 @@ function Ut({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
3038
3105
  children: C ? /* @__PURE__ */ l("p", {
3039
3106
  className: "doc-empty-body",
3040
3107
  children: "loading…"
3041
- }) : _ === "diff" ? /* @__PURE__ */ l(Wt, { text: k }) : _ === "version" ? /* @__PURE__ */ l("pre", {
3108
+ }) : _ === "diff" ? /* @__PURE__ */ l(qt, { text: k }) : _ === "version" ? /* @__PURE__ */ l("pre", {
3042
3109
  className: "md-pre doc-hist-version",
3043
3110
  children: /* @__PURE__ */ l("code", { children: x || "(empty)" })
3044
3111
  }) : /* @__PURE__ */ l("p", {
@@ -3051,7 +3118,7 @@ function Ut({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
3051
3118
  })
3052
3119
  });
3053
3120
  }
3054
- function Wt({ text: e }) {
3121
+ function qt({ text: e }) {
3055
3122
  if (!e.trim()) return /* @__PURE__ */ l("p", {
3056
3123
  className: "doc-empty-body",
3057
3124
  children: "(no differences)"
@@ -3070,17 +3137,17 @@ function Wt({ text: e }) {
3070
3137
  }
3071
3138
  //#endregion
3072
3139
  //#region src/components/Markdown.tsx
3073
- function Gt({ source: e }) {
3140
+ function Jt({ source: e }) {
3074
3141
  return /* @__PURE__ */ l("div", {
3075
3142
  className: "md",
3076
3143
  children: /* @__PURE__ */ l(f, {
3077
3144
  remarkPlugins: [p],
3078
- components: Kt,
3145
+ components: Yt,
3079
3146
  children: e
3080
3147
  })
3081
3148
  });
3082
3149
  }
3083
- var Kt = {
3150
+ var Yt = {
3084
3151
  a({ href: e, children: t }) {
3085
3152
  let n = e ?? "", r = /^https?:\/\//i.test(n);
3086
3153
  return /* @__PURE__ */ l("a", {
@@ -3106,11 +3173,11 @@ var Kt = {
3106
3173
  };
3107
3174
  //#endregion
3108
3175
  //#region src/components/DocumentViewerBody.tsx
3109
- function qt(e) {
3176
+ function Xt(e) {
3110
3177
  let t = e.fields ?? {};
3111
3178
  return typeof t.alt == "string" && t.alt.trim() !== "" ? t.alt : e.title || "image";
3112
3179
  }
3113
- function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, renderAssistant: p, initialChunkId: m, onOpenDocument: h, onTitle: g, onChunkSelect: v, focusChunk: y }) {
3180
+ function Zt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, renderAssistant: p, initialChunkId: m, onOpenDocument: h, onTitle: g, onChunkSelect: v, focusChunk: y }) {
3114
3181
  let b = M(), x = i(() => d && (d.scopeId || d.tenant) ? {
3115
3182
  scopeId: d.scopeId,
3116
3183
  tenant: d.tenant
@@ -3205,18 +3272,20 @@ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3205
3272
  b,
3206
3273
  n,
3207
3274
  x
3208
- ]), Je = i(() => Fe(b, n), [b, n]), Xe = i(() => Ie(K, e), [K, e]), $e = t(() => Te((e) => e + 1), []), et = i(() => Le(Je, Xe, Ce, $e), [
3209
- Je,
3275
+ ]), $ = i(() => Fe(b, n), [b, n]), Xe = i(() => Ie(K, e), [K, e]), $e = t(() => Te((e) => e + 1), []), et = i(() => Le($, Xe, Ce, $e), [
3276
+ $,
3210
3277
  Xe,
3211
3278
  Ce,
3212
3279
  $e
3213
3280
  ]), tt = y?.seq, nt = a(y);
3214
3281
  nt.current = y;
3215
3282
  let ot = a(X);
3216
- ot.current = X, r(() => {
3283
+ ot.current = X;
3284
+ let st = a(S);
3285
+ st.current = S, r(() => {
3217
3286
  if (tt === void 0) return;
3218
- let e = nt.current?.chunkId ?? ot.current;
3219
- e && T(e);
3287
+ let e = nt.current?.chunkId, t = st.current.length > 0 ? U(st.current, e) : e ?? ot.current;
3288
+ t && T(t);
3220
3289
  }, [tt]), r(() => {
3221
3290
  T(void 0), D(null), j(null), k("chunks"), ge(null), Se([]), we(!1), De(0), ke(void 0);
3222
3291
  }, [e, n]), r(() => {
@@ -3288,7 +3357,7 @@ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3288
3357
  fe,
3289
3358
  x
3290
3359
  ]);
3291
- let st = t((e) => T(e.row.id), []), ct = t((t, n, r) => h?.({
3360
+ let ct = t((e) => T(e.row.id), []), lt = t((t, n, r) => h?.({
3292
3361
  documentId: t,
3293
3362
  chunkId: n,
3294
3363
  title: r
@@ -3301,7 +3370,7 @@ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3301
3370
  e,
3302
3371
  w,
3303
3372
  Ne
3304
- ]), lt = t(async () => {
3373
+ ]), ut = t(async () => {
3305
3374
  try {
3306
3375
  let t = await b.documentExportMd(e, n, !0, x), r = new Blob([t.markdown], { type: "text/markdown" }), i = URL.createObjectURL(r), a = document.createElement("a");
3307
3376
  a.href = i, a.download = (t.title || "document").replace(/[^\w.-]+/g, "_") + ".md", a.click(), URL.revokeObjectURL(i);
@@ -3313,7 +3382,7 @@ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3313
3382
  e,
3314
3383
  n,
3315
3384
  x
3316
- ]), ut = t(async () => {
3385
+ ]), dt = t(async () => {
3317
3386
  try {
3318
3387
  let t = await b.documentExportCanvas(e, n, x), r = new Blob([JSON.stringify(t.canvas, null, 2)], { type: "application/json" }), i = URL.createObjectURL(r), a = document.createElement("a");
3319
3388
  a.href = i, a.download = (Ne || "document").replace(/[^\w.-]+/g, "_") + ".canvas", a.click(), URL.revokeObjectURL(i);
@@ -3326,7 +3395,7 @@ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3326
3395
  n,
3327
3396
  x,
3328
3397
  Ne
3329
- ]), dt = !!b.documentCreateChunk && !!X, ft = t(async (t) => {
3398
+ ]), ft = !!b.documentCreateChunk && !!X, pt = t(async (t) => {
3330
3399
  if (!b.documentCreateChunk || !b.documentSetAsset) return;
3331
3400
  let r = w || X;
3332
3401
  if (r) {
@@ -3349,7 +3418,7 @@ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3349
3418
  w,
3350
3419
  X,
3351
3420
  J
3352
- ]), pt = t(async () => {
3421
+ ]), mt = t(async () => {
3353
3422
  if (!b.documentCreateChunk) return;
3354
3423
  let t = w || X;
3355
3424
  if (t) {
@@ -3373,7 +3442,7 @@ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3373
3442
  w,
3374
3443
  X,
3375
3444
  J
3376
- ]), mt = t(async () => {
3445
+ ]), ht = t(async () => {
3377
3446
  if (!b.documentCreateChunk) return;
3378
3447
  let t = w && !Y ? w : void 0, r = w || X;
3379
3448
  if (r) {
@@ -3397,7 +3466,7 @@ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3397
3466
  Y,
3398
3467
  X,
3399
3468
  J
3400
- ]), ht = t(async () => {
3469
+ ]), gt = t(async () => {
3401
3470
  if (b.documentCreateChunk && w) {
3402
3471
  z(null);
3403
3472
  try {
@@ -3417,7 +3486,7 @@ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3417
3486
  x,
3418
3487
  w,
3419
3488
  J
3420
- ]), gt = i(() => {
3489
+ ]), _t = i(() => {
3421
3490
  if (!E || Y) return {
3422
3491
  canUp: !1,
3423
3492
  canDown: !1
@@ -3431,7 +3500,7 @@ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3431
3500
  S,
3432
3501
  E,
3433
3502
  Y
3434
- ]), _t = t(async (e) => {
3503
+ ]), vt = t(async (e) => {
3435
3504
  if (b.documentReorderChunk && w) {
3436
3505
  z(null);
3437
3506
  try {
@@ -3446,7 +3515,7 @@ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3446
3515
  n,
3447
3516
  x,
3448
3517
  J
3449
- ]), vt = t(async () => {
3518
+ ]), bt = t(async () => {
3450
3519
  if (!b.documentDeleteChunk || !E) return;
3451
3520
  z(null);
3452
3521
  let e = E.parent_id;
@@ -3464,20 +3533,20 @@ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3464
3533
  J
3465
3534
  ]);
3466
3535
  return r(() => {
3467
- if (!dt) return;
3536
+ if (!ft) return;
3468
3537
  let e = (e) => {
3469
3538
  if (ne || G) return;
3470
3539
  let t = document.activeElement, n = t?.tagName;
3471
3540
  if (n === "INPUT" || n === "TEXTAREA" || t?.isContentEditable) return;
3472
3541
  let r = ve(e.clipboardData?.items);
3473
- r && (e.preventDefault(), ft(r));
3542
+ r && (e.preventDefault(), pt(r));
3474
3543
  };
3475
3544
  return window.addEventListener("paste", e), () => window.removeEventListener("paste", e);
3476
3545
  }, [
3477
- dt,
3546
+ ft,
3478
3547
  ne,
3479
3548
  G,
3480
- ft
3549
+ pt
3481
3550
  ]), /* @__PURE__ */ u("div", {
3482
3551
  className: "doc-viewer",
3483
3552
  children: [
@@ -3488,7 +3557,7 @@ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3488
3557
  style: { display: "none" },
3489
3558
  onChange: (e) => {
3490
3559
  let t = e.target.files?.[0];
3491
- e.target.value = "", t && ft(t);
3560
+ e.target.value = "", t && pt(t);
3492
3561
  }
3493
3562
  }),
3494
3563
  /* @__PURE__ */ u("div", {
@@ -3500,23 +3569,23 @@ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3500
3569
  title: Ne,
3501
3570
  children: Ne
3502
3571
  }),
3503
- /* @__PURE__ */ l($, {
3572
+ /* @__PURE__ */ l(Je, {
3504
3573
  value: e,
3505
3574
  label: "doc"
3506
3575
  }),
3507
3576
  /* @__PURE__ */ u("div", {
3508
3577
  className: "doc-toolbar-actions",
3509
3578
  children: [
3510
- dt && /* @__PURE__ */ u(c, { children: [
3579
+ ft && /* @__PURE__ */ u(c, { children: [
3511
3580
  /* @__PURE__ */ l("button", {
3512
3581
  type: "button",
3513
- onClick: () => void mt(),
3582
+ onClick: () => void ht(),
3514
3583
  title: "Add a text chunk AFTER the selected chunk, at the same level",
3515
3584
  children: "+ text"
3516
3585
  }),
3517
3586
  /* @__PURE__ */ l("button", {
3518
3587
  type: "button",
3519
- onClick: () => void ht(),
3588
+ onClick: () => void gt(),
3520
3589
  disabled: !w,
3521
3590
  title: w ? "Add a chunk NESTED UNDER the selected chunk (in the ontology, a child is a subclass)" : "Select a chunk first — this nests a new chunk under it",
3522
3591
  children: "+ child"
@@ -3529,7 +3598,7 @@ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3529
3598
  }),
3530
3599
  /* @__PURE__ */ l("button", {
3531
3600
  type: "button",
3532
- onClick: () => void pt(),
3601
+ onClick: () => void mt(),
3533
3602
  title: "Add a Mermaid diagram chunk",
3534
3603
  children: "+ diagram"
3535
3604
  })
@@ -3551,13 +3620,13 @@ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3551
3620
  }),
3552
3621
  /* @__PURE__ */ l("button", {
3553
3622
  type: "button",
3554
- onClick: () => void lt(),
3623
+ onClick: () => void ut(),
3555
3624
  title: "Download the whole document as Markdown (.md)",
3556
3625
  children: "↓ .md"
3557
3626
  }),
3558
3627
  /* @__PURE__ */ l("button", {
3559
3628
  type: "button",
3560
- onClick: () => void ut(),
3629
+ onClick: () => void dt(),
3561
3630
  title: "Download the whole document as a node/edge canvas graph (.canvas)",
3562
3631
  children: "↓ .canvas"
3563
3632
  }),
@@ -3591,7 +3660,7 @@ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3591
3660
  onClose: () => De(0),
3592
3661
  onChanged: J
3593
3662
  }, `${n}:${e}`),
3594
- We ? /* @__PURE__ */ l(Vt, {
3663
+ We ? /* @__PURE__ */ l(Wt, {
3595
3664
  documentId: e,
3596
3665
  scope: n,
3597
3666
  detail: de ?? void 0
@@ -3609,7 +3678,7 @@ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3609
3678
  }) : /* @__PURE__ */ l(Qe, {
3610
3679
  tree: Me,
3611
3680
  selectedId: w,
3612
- onSelect: st,
3681
+ onSelect: ct,
3613
3682
  colorEnabled: Z,
3614
3683
  scheme: W?.color_scheme,
3615
3684
  documentColor: He,
@@ -3617,129 +3686,130 @@ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3617
3686
  })
3618
3687
  }), /* @__PURE__ */ l("div", {
3619
3688
  className: "doc-content",
3620
- children: E ? /* @__PURE__ */ u(c, { children: [
3621
- /* @__PURE__ */ u("div", {
3622
- className: "doc-content-head",
3623
- children: [
3624
- Pe.length > 0 && /* @__PURE__ */ u("nav", {
3625
- className: "chunk-ancestry",
3626
- "aria-label": "Chunks above this one",
3627
- children: [/* @__PURE__ */ l("button", {
3628
- type: "button",
3629
- className: "chunk-ancestry-up",
3630
- onClick: () => T(Pe[Pe.length - 1].id),
3631
- title: `Up to ${Pe[Pe.length - 1].title || "(untitled)"}`,
3632
- children: "↰ Up"
3633
- }), /* @__PURE__ */ u("ol", {
3634
- className: "doc-trail-list",
3635
- children: [Pe.map((e) => /* @__PURE__ */ l("li", {
3636
- className: "doc-trail-item",
3637
- children: /* @__PURE__ */ l("button", {
3638
- type: "button",
3639
- className: "doc-trail-crumb",
3640
- onClick: () => T(e.id),
3641
- title: e.title || "(untitled)",
3642
- children: e.title || "(untitled)"
3643
- })
3644
- }, e.id)), /* @__PURE__ */ l("li", {
3645
- className: "doc-trail-item",
3646
- children: /* @__PURE__ */ l("span", {
3647
- className: "doc-trail-current",
3648
- "aria-current": "location",
3649
- title: E.title || "(untitled)",
3650
- children: E.title || "(untitled)"
3651
- })
3652
- })]
3653
- })]
3654
- }),
3655
- /* @__PURE__ */ l("h3", { children: E.title || "(untitled)" }),
3656
- /* @__PURE__ */ u("div", {
3657
- className: "doc-content-meta",
3658
- children: [
3659
- E.type && /* @__PURE__ */ l("span", {
3660
- className: "chunk-badge",
3661
- children: E.type
3662
- }),
3663
- E.status && /* @__PURE__ */ l("span", {
3664
- className: "chunk-badge chunk-status",
3665
- children: E.status
3666
- }),
3667
- /* @__PURE__ */ u("span", {
3668
- className: "chunk-rev",
3669
- children: ["rev ", E.revision]
3670
- }),
3671
- E.tags?.map((e) => /* @__PURE__ */ l("span", {
3672
- className: "chunk-tag",
3673
- children: e
3674
- }, e)),
3675
- /* @__PURE__ */ l($, {
3676
- value: E.id,
3677
- label: "chunk"
3678
- })
3679
- ]
3680
- }),
3681
- /* @__PURE__ */ u("div", {
3682
- className: "doc-content-controls",
3683
- children: [
3684
- /* @__PURE__ */ u("div", {
3685
- className: "doc-mode-toggle",
3686
- children: [/* @__PURE__ */ l("button", {
3687
- type: "button",
3688
- className: O === "chunks" ? "active" : "",
3689
- onClick: () => k("chunks"),
3690
- title: "This chunk's own content",
3691
- children: "chunk"
3692
- }), /* @__PURE__ */ l("button", {
3693
- type: "button",
3694
- className: O === "markdown" ? "active" : "",
3695
- onClick: () => k("markdown"),
3696
- title: Y ? "Whole document as Markdown" : "This chunk + its sub-chunks as Markdown",
3697
- children: "markdown"
3698
- })]
3699
- }),
3700
- /* @__PURE__ */ l("button", {
3701
- type: "button",
3702
- className: "chunk-edit",
3703
- onClick: () => re(E),
3704
- children: "edit"
3705
- }),
3706
- b.documentEntityTypes && _(E) && /* @__PURE__ */ l("button", {
3707
- type: "button",
3708
- onClick: () => ae(E),
3709
- title: "Change this subject's type to another type in force",
3710
- children: "change type"
3711
- }),
3712
- /* @__PURE__ */ l("button", {
3689
+ children: E ? /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ u("div", {
3690
+ className: "doc-content-head",
3691
+ children: [
3692
+ Pe.length > 0 && /* @__PURE__ */ u("nav", {
3693
+ className: "chunk-ancestry",
3694
+ "aria-label": "Chunks above this one",
3695
+ children: [/* @__PURE__ */ l("button", {
3696
+ type: "button",
3697
+ className: "chunk-ancestry-up",
3698
+ onClick: () => T(Pe[Pe.length - 1].id),
3699
+ title: `Up to ${Pe[Pe.length - 1].title || "(untitled)"}`,
3700
+ children: "↰ Up"
3701
+ }), /* @__PURE__ */ u("ol", {
3702
+ className: "doc-trail-list",
3703
+ children: [Pe.map((e) => /* @__PURE__ */ l("li", {
3704
+ className: "doc-trail-item",
3705
+ children: /* @__PURE__ */ l("button", {
3713
3706
  type: "button",
3714
- onClick: () => L(!0),
3715
- title: "View this chunk's edit history + diffs",
3716
- children: "history"
3717
- }),
3718
- !Y && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("button", {
3707
+ className: "doc-trail-crumb",
3708
+ onClick: () => T(e.id),
3709
+ title: e.title || "(untitled)",
3710
+ children: e.title || "(untitled)"
3711
+ })
3712
+ }, e.id)), /* @__PURE__ */ l("li", {
3713
+ className: "doc-trail-item",
3714
+ children: /* @__PURE__ */ l("span", {
3715
+ className: "doc-trail-current",
3716
+ "aria-current": "location",
3717
+ title: E.title || "(untitled)",
3718
+ children: E.title || "(untitled)"
3719
+ })
3720
+ })]
3721
+ })]
3722
+ }),
3723
+ /* @__PURE__ */ l("h3", { children: E.title || "(untitled)" }),
3724
+ /* @__PURE__ */ u("div", {
3725
+ className: "doc-content-meta",
3726
+ children: [
3727
+ E.type && /* @__PURE__ */ l("span", {
3728
+ className: "chunk-badge",
3729
+ children: E.type
3730
+ }),
3731
+ E.status && /* @__PURE__ */ l("span", {
3732
+ className: "chunk-badge chunk-status",
3733
+ children: E.status
3734
+ }),
3735
+ /* @__PURE__ */ u("span", {
3736
+ className: "chunk-rev",
3737
+ children: ["rev ", E.revision]
3738
+ }),
3739
+ E.tags?.map((e) => /* @__PURE__ */ l("span", {
3740
+ className: "chunk-tag",
3741
+ children: e
3742
+ }, e)),
3743
+ /* @__PURE__ */ l(Je, {
3744
+ value: E.id,
3745
+ label: "chunk"
3746
+ })
3747
+ ]
3748
+ }),
3749
+ /* @__PURE__ */ u("div", {
3750
+ className: "doc-content-controls",
3751
+ children: [
3752
+ /* @__PURE__ */ u("div", {
3753
+ className: "doc-mode-toggle",
3754
+ children: [/* @__PURE__ */ l("button", {
3719
3755
  type: "button",
3720
- onClick: () => void _t("up"),
3721
- disabled: !gt.canUp,
3722
- title: "Move this chunk up within its level",
3723
- children: "↑"
3756
+ className: O === "chunks" ? "active" : "",
3757
+ onClick: () => k("chunks"),
3758
+ title: "This chunk's own content",
3759
+ children: "chunk"
3724
3760
  }), /* @__PURE__ */ l("button", {
3725
3761
  type: "button",
3726
- onClick: () => void _t("down"),
3727
- disabled: !gt.canDown,
3728
- title: "Move this chunk down within its level",
3729
- children: "↓"
3730
- })] }),
3731
- !Y && /* @__PURE__ */ l("button", {
3732
- type: "button",
3733
- className: "danger",
3734
- onClick: () => se(!0),
3735
- title: "Delete this chunk and its sub-chunks",
3736
- children: "delete"
3737
- })
3738
- ]
3739
- })
3740
- ]
3741
- }),
3742
- /* @__PURE__ */ l("div", {
3762
+ className: O === "markdown" ? "active" : "",
3763
+ onClick: () => k("markdown"),
3764
+ title: Y ? "Whole document as Markdown" : "This chunk + its sub-chunks as Markdown",
3765
+ children: "markdown"
3766
+ })]
3767
+ }),
3768
+ /* @__PURE__ */ l("button", {
3769
+ type: "button",
3770
+ className: "chunk-edit",
3771
+ onClick: () => re(E),
3772
+ children: "edit"
3773
+ }),
3774
+ b.documentEntityTypes && _(E) && /* @__PURE__ */ l("button", {
3775
+ type: "button",
3776
+ onClick: () => ae(E),
3777
+ title: "Change this subject's type to another type in force",
3778
+ children: "change type"
3779
+ }),
3780
+ /* @__PURE__ */ l("button", {
3781
+ type: "button",
3782
+ onClick: () => L(!0),
3783
+ title: "View this chunk's edit history + diffs",
3784
+ children: "history"
3785
+ }),
3786
+ !Y && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("button", {
3787
+ type: "button",
3788
+ onClick: () => void vt("up"),
3789
+ disabled: !_t.canUp,
3790
+ title: "Move this chunk up within its level",
3791
+ children: "↑"
3792
+ }), /* @__PURE__ */ l("button", {
3793
+ type: "button",
3794
+ onClick: () => void vt("down"),
3795
+ disabled: !_t.canDown,
3796
+ title: "Move this chunk down within its level",
3797
+ children: "↓"
3798
+ })] }),
3799
+ !Y && /* @__PURE__ */ l("button", {
3800
+ type: "button",
3801
+ className: "danger",
3802
+ onClick: () => se(!0),
3803
+ title: "Delete this chunk and its sub-chunks",
3804
+ children: "delete"
3805
+ })
3806
+ ]
3807
+ })
3808
+ ]
3809
+ }), /* @__PURE__ */ u(Ut, {
3810
+ storageKey: "loomcycle.explorer.doc-links-height",
3811
+ className: "doc-content-split",
3812
+ children: [/* @__PURE__ */ l("div", {
3743
3813
  className: "doc-content-body",
3744
3814
  children: E.type === "mermaid" ? E.body ? /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(rt, { code: E.body }), O === "markdown" && /* @__PURE__ */ l("pre", {
3745
3815
  className: "md-pre doc-mermaid-source",
@@ -3754,7 +3824,7 @@ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3754
3824
  className: "doc-image",
3755
3825
  children: [/* @__PURE__ */ l("img", {
3756
3826
  src: N,
3757
- alt: qt(E)
3827
+ alt: Xt(E)
3758
3828
  }), E.body && /* @__PURE__ */ l("figcaption", { children: E.body })]
3759
3829
  }) : /* @__PURE__ */ l("p", {
3760
3830
  className: "doc-empty-body",
@@ -3762,31 +3832,32 @@ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3762
3832
  }) : O === "markdown" ? A === null ? /* @__PURE__ */ l("p", {
3763
3833
  className: "doc-empty-body",
3764
3834
  children: "Assembling Markdown…"
3765
- }) : /* @__PURE__ */ l(Gt, { source: A }) : E.body ? /* @__PURE__ */ l(Gt, { source: E.body }) : /* @__PURE__ */ l("p", {
3835
+ }) : /* @__PURE__ */ l(Jt, { source: A }) : E.body ? /* @__PURE__ */ l(Jt, { source: E.body }) : /* @__PURE__ */ l("p", {
3766
3836
  className: "doc-empty-body",
3767
3837
  children: "(empty chunk)"
3768
3838
  })
3769
- }),
3770
- /* @__PURE__ */ l(Ft, {
3771
- edges: K,
3772
- incomplete: Ce,
3773
- documentId: e,
3774
- selectedId: w,
3775
- onSelectChunk: T,
3776
- onOpenDocument: h ? ct : void 0,
3777
- onRuleStatement: qe
3778
- }),
3779
- /* @__PURE__ */ l(Nt, {
3780
- documentId: e,
3781
- selectedId: w,
3782
- scope: n,
3783
- browse: x,
3784
- onSelectChunk: T,
3785
- onOpenDocument: h ? ct : void 0,
3786
- refreshKey: q,
3787
- review: et
3788
- })
3789
- ] }) : /* @__PURE__ */ l("div", {
3839
+ }), /* @__PURE__ */ u("div", {
3840
+ className: "doc-links-pane",
3841
+ children: [/* @__PURE__ */ l(Ft, {
3842
+ edges: K,
3843
+ incomplete: Ce,
3844
+ documentId: e,
3845
+ selectedId: w,
3846
+ onSelectChunk: T,
3847
+ onOpenDocument: h ? lt : void 0,
3848
+ onRuleStatement: qe
3849
+ }), /* @__PURE__ */ l(Nt, {
3850
+ documentId: e,
3851
+ selectedId: w,
3852
+ scope: n,
3853
+ browse: x,
3854
+ onSelectChunk: T,
3855
+ onOpenDocument: h ? lt : void 0,
3856
+ refreshKey: q,
3857
+ review: et
3858
+ })]
3859
+ })]
3860
+ })] }) : /* @__PURE__ */ l("div", {
3790
3861
  className: "empty",
3791
3862
  children: /* @__PURE__ */ l("p", { children: "Select a chunk on the left." })
3792
3863
  })
@@ -3815,7 +3886,7 @@ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3815
3886
  onClose: () => ae(null),
3816
3887
  onSaved: J
3817
3888
  }),
3818
- I && E && /* @__PURE__ */ l(Ut, {
3889
+ I && E && /* @__PURE__ */ l(Kt, {
3819
3890
  chunkId: E.id,
3820
3891
  chunkTitle: E.title,
3821
3892
  scope: n,
@@ -3858,7 +3929,7 @@ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3858
3929
  }), /* @__PURE__ */ l("button", {
3859
3930
  type: "button",
3860
3931
  className: "danger",
3861
- onClick: () => void vt(),
3932
+ onClick: () => void bt(),
3862
3933
  children: "delete"
3863
3934
  })]
3864
3935
  })
@@ -3870,7 +3941,7 @@ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3870
3941
  }
3871
3942
  //#endregion
3872
3943
  //#region src/components/PathTree.tsx
3873
- function Yt(e, t = "") {
3944
+ function Qt(e, t = "") {
3874
3945
  let n = e.get(t);
3875
3946
  if (!n) return [];
3876
3947
  let r = n.entries.map((n) => {
@@ -3881,7 +3952,7 @@ function Yt(e, t = "") {
3881
3952
  kind: n.kind,
3882
3953
  resourceRef: n.resource_ref,
3883
3954
  listing: r ? e.get(n.full_path) : void 0,
3884
- children: r ? Yt(e, n.full_path) : []
3955
+ children: r ? Qt(e, n.full_path) : []
3885
3956
  };
3886
3957
  });
3887
3958
  return r.sort((e, t) => {
@@ -3889,13 +3960,13 @@ function Yt(e, t = "") {
3889
3960
  return n === (t.kind === "directory") ? e.name.localeCompare(t.name) : n ? -1 : 1;
3890
3961
  }), r;
3891
3962
  }
3892
- var Xt = {
3963
+ var $t = {
3893
3964
  directory: "📁",
3894
3965
  document: "📄",
3895
3966
  volume_mount: "💾",
3896
3967
  memory_entry: "🧠"
3897
3968
  };
3898
- function Zt(e) {
3969
+ function en(e) {
3899
3970
  let { tree: t, root: n } = e;
3900
3971
  return !n || !n.loaded && n.loading ? /* @__PURE__ */ l("div", {
3901
3972
  className: "empty",
@@ -3905,17 +3976,17 @@ function Zt(e) {
3905
3976
  children: /* @__PURE__ */ l("p", { children: "This tree is empty. Create a folder or document to begin." })
3906
3977
  }) : /* @__PURE__ */ u("ul", {
3907
3978
  className: "tree path-tree",
3908
- children: [t.map((t) => /* @__PURE__ */ l(en, {
3979
+ children: [t.map((t) => /* @__PURE__ */ l(rn, {
3909
3980
  node: t,
3910
3981
  ...e
3911
- }, t.fullPath)), /* @__PURE__ */ l(Qt, {
3982
+ }, t.fullPath)), /* @__PURE__ */ l(tn, {
3912
3983
  dir: "",
3913
3984
  listing: n,
3914
3985
  ...e
3915
3986
  })]
3916
3987
  });
3917
3988
  }
3918
- function Qt({ dir: e, listing: t, onLoadMore: n, onRetry: r }) {
3989
+ function tn({ dir: e, listing: t, onLoadMore: n, onRetry: r }) {
3919
3990
  let i = [];
3920
3991
  return !t || t.loading && t.entries.length === 0 ? i.push(/* @__PURE__ */ l("li", {
3921
3992
  className: "node path-status",
@@ -3955,13 +4026,13 @@ function Qt({ dir: e, listing: t, onLoadMore: n, onRetry: r }) {
3955
4026
  })
3956
4027
  }, "more")), /* @__PURE__ */ l(c, { children: i });
3957
4028
  }
3958
- function $t(e, t) {
4029
+ function nn(e, t) {
3959
4030
  if (e.kind !== "document" || !t) return;
3960
4031
  let n = e.resourceRef;
3961
4032
  return n?.document_id ? t.get(n.document_id) : void 0;
3962
4033
  }
3963
- function en(e) {
3964
- let { node: t, expanded: n, onToggle: r, selectedPath: i, onSelect: a, summaries: o } = e, s = t.kind === "directory", c = s && n.has(t.fullPath), d = i === t.fullPath, f = $t(t, o), p = f && f.color_enabled ? Ge(Ve(f.type, f.status, Be(f.color_scheme))) : void 0;
4034
+ function rn(e) {
4035
+ let { node: t, expanded: n, onToggle: r, selectedPath: i, onSelect: a, summaries: o } = e, s = t.kind === "directory", c = s && n.has(t.fullPath), d = i === t.fullPath, f = nn(t, o), p = f && f.color_enabled ? Ge(Ve(f.type, f.status, Be(f.color_scheme))) : void 0;
3965
4036
  return /* @__PURE__ */ u("li", {
3966
4037
  className: `node path-node kind-${t.kind} ${d ? "selected" : ""}`,
3967
4038
  children: [/* @__PURE__ */ u("div", {
@@ -3986,7 +4057,7 @@ function en(e) {
3986
4057
  /* @__PURE__ */ l("span", {
3987
4058
  className: "path-kind-icon",
3988
4059
  "aria-hidden": !0,
3989
- children: Xt[t.kind] ?? "•"
4060
+ children: $t[t.kind] ?? "•"
3990
4061
  }),
3991
4062
  /* @__PURE__ */ l("span", {
3992
4063
  className: "path-name",
@@ -4004,10 +4075,10 @@ function en(e) {
4004
4075
  })]
4005
4076
  }), c && /* @__PURE__ */ u("ul", {
4006
4077
  className: "children path-children",
4007
- children: [t.children.map((t) => /* @__PURE__ */ l(en, {
4078
+ children: [t.children.map((t) => /* @__PURE__ */ l(rn, {
4008
4079
  ...e,
4009
4080
  node: t
4010
- }, t.fullPath)), /* @__PURE__ */ l(Qt, {
4081
+ }, t.fullPath)), /* @__PURE__ */ l(tn, {
4011
4082
  ...e,
4012
4083
  dir: t.fullPath,
4013
4084
  listing: t.listing
@@ -4017,23 +4088,23 @@ function en(e) {
4017
4088
  }
4018
4089
  //#endregion
4019
4090
  //#region src/PathExplorer.tsx
4020
- var tn = /^[A-Za-z0-9._-]+$/;
4021
- function nn(e, t) {
4091
+ var an = /^[A-Za-z0-9._-]+$/;
4092
+ function on(e, t) {
4022
4093
  return `${e}/${t}`;
4023
4094
  }
4024
- function rn(e, t) {
4095
+ function sn(e, t) {
4025
4096
  for (let n of e) {
4026
4097
  if (n.fullPath === t) return n;
4027
- let e = rn(n.children, t);
4098
+ let e = sn(n.children, t);
4028
4099
  if (e) return e;
4029
4100
  }
4030
4101
  }
4031
- function an(e) {
4102
+ function cn(e) {
4032
4103
  let { theme: t, defaultScope: n, path: r, onPathChange: i, browse: a, principal: o, renderAssistant: s, renderNavigator: c, navigator: u, onError: d } = e, f = R(e);
4033
4104
  return /* @__PURE__ */ l(z, {
4034
4105
  theme: t,
4035
4106
  dataLayer: f,
4036
- children: /* @__PURE__ */ l(on, {
4107
+ children: /* @__PURE__ */ l(ln, {
4037
4108
  defaultScope: n,
4038
4109
  path: r,
4039
4110
  onPathChange: i,
@@ -4046,7 +4117,7 @@ function an(e) {
4046
4117
  })
4047
4118
  });
4048
4119
  }
4049
- function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p, renderAssistant: m, renderNavigator: _, navigator: v, onError: y }) {
4120
+ function ln({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p, renderAssistant: m, renderNavigator: _, navigator: v, onError: y }) {
4050
4121
  let b = M(), [x, S] = o(e ?? "user"), [C, w] = o(void 0), [T, E] = o(null), [D, O] = o(null), [k, A] = o(null), [j, N] = o(() => /* @__PURE__ */ new Set()), P = n === void 0 ? C : n, te = a(d);
4051
4122
  r(() => {
4052
4123
  te.current = d;
@@ -4111,7 +4182,6 @@ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4111
4182
  P,
4112
4183
  U
4113
4184
  ]), r(() => {
4114
- if (x === "tenant") return;
4115
4185
  let e = [];
4116
4186
  for (let t of H.values()) for (let n of ae(t.entries)) De.current.has(n) || (De.current.add(n), e.push(n));
4117
4187
  let t = Oe.current;
@@ -4128,7 +4198,7 @@ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4128
4198
  x,
4129
4199
  B
4130
4200
  ]);
4131
- let je = i(() => Yt(H), [H]), Me = t(async () => {
4201
+ let je = i(() => Qt(H), [H]), Me = t(async () => {
4132
4202
  E(null), ke(), xe((e) => e + 1), await V.refresh(j).catch(U), P && await V.reveal(P).catch(U);
4133
4203
  }, [
4134
4204
  V,
@@ -4143,7 +4213,7 @@ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4143
4213
  });
4144
4214
  }, []), Y = t((e) => V.loadMore(e).catch(U), [V, U]), Pe = t((e) => {
4145
4215
  (V.getSnapshot().get(e)?.loaded ? V.loadMore(e) : V.loadDir(e)).catch(U);
4146
- }, [V, U]), X = i(() => P ? rn(je, P) : void 0, [je, P]), Fe = H.get("")?.error, Ie = X?.kind === "directory" ? X.fullPath : void 0, [Le, Re] = o(null);
4216
+ }, [V, U]), X = i(() => P ? sn(je, P) : void 0, [je, P]), Fe = H.get("")?.error, Ie = X?.kind === "directory" ? X.fullPath : void 0, [Le, Re] = o(null);
4147
4217
  r(() => {
4148
4218
  if (!Ie || !b.pathIsStored) return;
4149
4219
  let e = !1;
@@ -4161,7 +4231,7 @@ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4161
4231
  x,
4162
4232
  B
4163
4233
  ]);
4164
- let ze = X ? X.kind === "directory" ? Le?.path === X.fullPath ? Le.explicit ? "yes" : "implicit (no entry)" : void 0 : "yes" : void 0, Z = i(() => X ? X.kind === "directory" ? X.fullPath : F(X.fullPath) : "", [X]), Q = Z || "/", Be = x !== "tenant", Ve = t(() => {
4234
+ let ze = X ? X.kind === "directory" ? Le?.path === X.fullPath ? Le.explicit ? "yes" : "implicit (no entry)" : void 0 : "yes" : void 0, Z = i(() => X ? X.kind === "directory" ? X.fullPath : F(X.fullPath) : "", [X]), Q = Z || "/", Be = t(() => {
4165
4235
  O({
4166
4236
  title: `New folder in ${Q}`,
4167
4237
  fields: [{
@@ -4172,8 +4242,8 @@ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4172
4242
  submitLabel: "Create",
4173
4243
  onSubmit: async (e) => {
4174
4244
  let t = e.name.trim();
4175
- if (!tn.test(t)) throw Error("name may contain only [A-Za-z0-9._-]");
4176
- let n = nn(Z, t);
4245
+ if (!an.test(t)) throw Error("name may contain only [A-Za-z0-9._-]");
4246
+ let n = on(Z, t);
4177
4247
  await b.pathMkdir(n, x, B), await q(n).catch(U), z(n);
4178
4248
  }
4179
4249
  });
@@ -4186,7 +4256,7 @@ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4186
4256
  B,
4187
4257
  U,
4188
4258
  z
4189
- ]), He = t(() => {
4259
+ ]), Ve = t(() => {
4190
4260
  O({
4191
4261
  title: `New document in ${Q}`,
4192
4262
  fields: [{
@@ -4201,8 +4271,8 @@ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4201
4271
  submitLabel: "Create",
4202
4272
  onSubmit: async (e) => {
4203
4273
  let t = e.name.trim();
4204
- if (!tn.test(t)) throw Error("name may contain only [A-Za-z0-9._-]");
4205
- let n = e.title.trim() || t, r = nn(Z, t);
4274
+ if (!an.test(t)) throw Error("name may contain only [A-Za-z0-9._-]");
4275
+ let n = e.title.trim() || t, r = on(Z, t);
4206
4276
  await b.documentCreate(n, r, x, B), await q(r).catch(U), z(r);
4207
4277
  }
4208
4278
  });
@@ -4215,7 +4285,7 @@ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4215
4285
  B,
4216
4286
  U,
4217
4287
  z
4218
- ]), Ue = t(() => {
4288
+ ]), He = t(() => {
4219
4289
  X && O({
4220
4290
  title: `Rename / move ${X.fullPath}`,
4221
4291
  fields: [{
@@ -4238,7 +4308,7 @@ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4238
4308
  B,
4239
4309
  U,
4240
4310
  z
4241
- ]), We = t(() => {
4311
+ ]), Ue = t(() => {
4242
4312
  if (!X) return;
4243
4313
  if (X.kind === "document") {
4244
4314
  let e = X.resourceRef?.document_id;
@@ -4264,7 +4334,7 @@ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4264
4334
  E(`could not list ${e.fullPath} for delete: ${t instanceof Error ? t.message : String(t)}`);
4265
4335
  return;
4266
4336
  }
4267
- let n = x === "tenant" ? [] : ae(t);
4337
+ let n = ae(t);
4268
4338
  O({
4269
4339
  title: `Delete branch ${e.fullPath}`,
4270
4340
  message: t.length === 0 ? "This removes the (empty) folder." : "This removes the folder and everything under it" + (n.length > 0 ? ` — including ${n.length} document(s), whose chunks are deleted.` : "."),
@@ -4285,7 +4355,7 @@ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4285
4355
  B,
4286
4356
  U,
4287
4357
  z
4288
- ]), Ge = X && (X.kind === "directory" || X.kind === "document"), Ke = !!b.documentsTransfer && !!Ge, qe = t(() => {
4358
+ ]), We = X && (X.kind === "directory" || X.kind === "document"), Ge = !!b.documentsTransfer && !!We, Ke = t(() => {
4289
4359
  if (X) {
4290
4360
  if (X.kind === "document") {
4291
4361
  let e = X.resourceRef?.document_id;
@@ -4302,7 +4372,7 @@ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4302
4372
  fromPath: X.fullPath
4303
4373
  });
4304
4374
  }
4305
- }, [X]), Je = t((e) => {
4375
+ }, [X]), qe = t((e) => {
4306
4376
  e.op === "move" ? (q(e.from, { dropSubtree: !0 }).catch(U), L([]), z(void 0)) : e.toScope === x && q(e.to).catch(U);
4307
4377
  }, [
4308
4378
  q,
@@ -4316,7 +4386,7 @@ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4316
4386
  path: X.fullPath,
4317
4387
  title: X.name
4318
4388
  };
4319
- }, [I, X]), Ye = t((e, t) => {
4389
+ }, [I, X]), Je = t((e, t) => {
4320
4390
  let n = ++oe.current, r = fe(V.getSnapshot(), e.documentId);
4321
4391
  L(ce(I, {
4322
4392
  ...t,
@@ -4335,10 +4405,10 @@ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4335
4405
  x,
4336
4406
  B,
4337
4407
  R
4338
- ]), Xe = t((e) => {
4408
+ ]), Ye = t((e) => {
4339
4409
  let t = le(I, e);
4340
4410
  t !== I && (oe.current++, L(t), R(t[t.length - 1].path));
4341
- }, [I, R]), Ze = t((e, t) => L((n) => ue(n, e, { title: t })), []), Qe = t((e) => {
4411
+ }, [I, R]), Xe = t((e, t) => L((n) => ue(n, e, { title: t })), []), Ze = t((e) => {
4342
4412
  we((t) => ({
4343
4413
  documentId: e.documentId,
4344
4414
  chunkId: e.chunkId,
@@ -4351,7 +4421,7 @@ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4351
4421
  $?.documentId,
4352
4422
  z,
4353
4423
  R
4354
- ]), $e = i(() => ({
4424
+ ]), Qe = i(() => ({
4355
4425
  scope: x,
4356
4426
  browse: B,
4357
4427
  selection: {
@@ -4359,7 +4429,7 @@ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4359
4429
  chunkId: K && K.documentId === $?.documentId ? K.chunkId : void 0,
4360
4430
  path: $?.path
4361
4431
  },
4362
- onSelect: Qe,
4432
+ onSelect: Ze,
4363
4433
  reloadToken: be,
4364
4434
  maximized: ve,
4365
4435
  onToggleMaximize: () => ye((e) => !e),
@@ -4370,11 +4440,11 @@ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4370
4440
  $?.documentId,
4371
4441
  $?.path,
4372
4442
  K,
4373
- Qe,
4443
+ Ze,
4374
4444
  be,
4375
4445
  ve,
4376
4446
  p?.subject
4377
- ]), et = Ce && $ && Ce.documentId === $.documentId ? Ce : void 0, tt = !!$?.path && X?.kind === "document" && X.fullPath === $.path;
4447
+ ]), $e = Ce && $ && Ce.documentId === $.documentId ? Ce : void 0, et = !!$?.path && X?.kind === "document" && X.fullPath === $.path;
4378
4448
  return /* @__PURE__ */ u(c, { children: [
4379
4449
  /* @__PURE__ */ u(he, {
4380
4450
  className: G ? "paths-view paths-view--stars" : "paths-view",
@@ -4434,14 +4504,13 @@ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4434
4504
  className: "paths-toolbar-actions",
4435
4505
  children: [!G && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("button", {
4436
4506
  type: "button",
4437
- onClick: Ve,
4507
+ onClick: Be,
4438
4508
  title: `New folder in ${Q}`,
4439
4509
  children: "+ folder"
4440
4510
  }), /* @__PURE__ */ l("button", {
4441
4511
  type: "button",
4442
- onClick: He,
4443
- disabled: !Be,
4444
- title: Be ? `New document in ${Q}` : "Documents are agent/user scope only",
4512
+ onClick: Ve,
4513
+ title: `New document in ${Q}`,
4445
4514
  children: "+ document"
4446
4515
  })] }), /* @__PURE__ */ l("button", {
4447
4516
  type: "button",
@@ -4475,8 +4544,8 @@ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4475
4544
  }),
4476
4545
  G && _ ? /* @__PURE__ */ l("div", {
4477
4546
  className: "paths-navigator",
4478
- children: _($e)
4479
- }) : /* @__PURE__ */ l(Zt, {
4547
+ children: _(Qe)
4548
+ }) : /* @__PURE__ */ l(en, {
4480
4549
  tree: je,
4481
4550
  root: H.get(""),
4482
4551
  expanded: j,
@@ -4495,7 +4564,7 @@ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4495
4564
  children: [
4496
4565
  /* @__PURE__ */ l(pe, {
4497
4566
  trail: I,
4498
- onJump: Xe
4567
+ onJump: Ye
4499
4568
  }),
4500
4569
  /* @__PURE__ */ u("div", {
4501
4570
  className: "paths-doc-head",
@@ -4510,44 +4579,44 @@ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4510
4579
  " ",
4511
4580
  /* @__PURE__ */ l("em", { children: "· opened by id, not in the tree" })
4512
4581
  ]
4513
- }), tt && /* @__PURE__ */ u("div", {
4582
+ }), et && /* @__PURE__ */ u("div", {
4514
4583
  className: "paths-detail-actions",
4515
4584
  children: [
4516
4585
  /* @__PURE__ */ l("button", {
4517
4586
  type: "button",
4518
- onClick: Ue,
4587
+ onClick: He,
4519
4588
  children: "rename / move"
4520
4589
  }),
4521
- Ke && /* @__PURE__ */ l("button", {
4590
+ Ge && /* @__PURE__ */ l("button", {
4522
4591
  type: "button",
4523
- onClick: qe,
4592
+ onClick: Ke,
4524
4593
  title: "Copy or move to another scope",
4525
4594
  children: "copy / move to…"
4526
4595
  }),
4527
4596
  /* @__PURE__ */ l("button", {
4528
4597
  type: "button",
4529
4598
  className: "danger",
4530
- onClick: We,
4599
+ onClick: Ue,
4531
4600
  children: "delete"
4532
4601
  })
4533
4602
  ]
4534
4603
  })]
4535
4604
  }),
4536
- /* @__PURE__ */ l(Jt, {
4605
+ /* @__PURE__ */ l(Zt, {
4537
4606
  documentId: $.documentId,
4538
4607
  scope: x,
4539
4608
  titleHint: $.title,
4540
4609
  browse: B,
4541
4610
  principal: p,
4542
4611
  renderAssistant: m,
4543
- initialChunkId: $.chunkId ?? et?.chunkId,
4544
- onOpenDocument: Ye,
4545
- onTitle: Ze,
4612
+ initialChunkId: $.chunkId ?? $e?.chunkId,
4613
+ onOpenDocument: Je,
4614
+ onTitle: Xe,
4546
4615
  onChunkSelect: (e) => Se({
4547
4616
  documentId: $.documentId,
4548
4617
  chunkId: e
4549
4618
  }),
4550
- focusChunk: et
4619
+ focusChunk: $e
4551
4620
  }, I.length)
4552
4621
  ]
4553
4622
  }) : X ? /* @__PURE__ */ u("div", {
@@ -4565,24 +4634,24 @@ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4565
4634
  ze && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("dt", { children: "stored" }), /* @__PURE__ */ l("dd", { children: ze })] })
4566
4635
  ]
4567
4636
  }),
4568
- Ge ? /* @__PURE__ */ u("div", {
4637
+ We ? /* @__PURE__ */ u("div", {
4569
4638
  className: "paths-detail-actions",
4570
4639
  children: [
4571
4640
  /* @__PURE__ */ l("button", {
4572
4641
  type: "button",
4573
- onClick: Ue,
4642
+ onClick: He,
4574
4643
  children: "rename / move"
4575
4644
  }),
4576
- Ke && /* @__PURE__ */ l("button", {
4645
+ Ge && /* @__PURE__ */ l("button", {
4577
4646
  type: "button",
4578
- onClick: qe,
4647
+ onClick: Ke,
4579
4648
  title: "Copy or move to another scope",
4580
4649
  children: "copy / move to…"
4581
4650
  }),
4582
4651
  /* @__PURE__ */ l("button", {
4583
4652
  type: "button",
4584
4653
  className: "danger",
4585
- onClick: We,
4654
+ onClick: Ue,
4586
4655
  children: "delete"
4587
4656
  })
4588
4657
  ]
@@ -4601,7 +4670,7 @@ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4601
4670
  })
4602
4671
  })]
4603
4672
  }),
4604
- D && /* @__PURE__ */ l(sn, {
4673
+ D && /* @__PURE__ */ l(un, {
4605
4674
  state: D,
4606
4675
  onClose: () => O(null)
4607
4676
  }),
@@ -4613,11 +4682,11 @@ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4613
4682
  underPath: k.underPath,
4614
4683
  fromPath: k.fromPath,
4615
4684
  onClose: () => A(null),
4616
- onDone: Je
4685
+ onDone: qe
4617
4686
  })
4618
4687
  ] });
4619
4688
  }
4620
- function sn({ state: e, onClose: t }) {
4689
+ function un({ state: e, onClose: t }) {
4621
4690
  let [n, r] = o(() => Object.fromEntries(e.fields.map((e) => [e.key, e.value ?? ""]))), [i, a] = o(!1), [s, c] = o(null);
4622
4691
  return /* @__PURE__ */ l("div", {
4623
4692
  className: "modal-overlay",
@@ -4678,34 +4747,42 @@ function sn({ state: e, onClose: t }) {
4678
4747
  }
4679
4748
  //#endregion
4680
4749
  //#region src/DocumentViewer.tsx
4681
- function cn(e) {
4750
+ function dn(e) {
4682
4751
  let { documentId: t, scope: n, browse: r, theme: i } = e, a = R(e);
4683
4752
  return /* @__PURE__ */ l(z, {
4684
4753
  theme: i,
4685
4754
  dataLayer: a,
4686
- children: /* @__PURE__ */ l(ln, { ...e }, `${n}:${t}:${r?.scopeId ?? ""}:${r?.tenant ?? ""}`)
4755
+ children: /* @__PURE__ */ l(fn, { ...e }, `${n}:${t}:${r?.scopeId ?? ""}:${r?.tenant ?? ""}`)
4687
4756
  });
4688
4757
  }
4689
- function ln({ documentId: e, scope: n, titleHint: r, browse: i, principal: a, renderAssistant: s, onOpenDocument: d }) {
4690
- let [f, p] = o([]), m = f[f.length - 1], h = t((e, t) => {
4691
- d ? d(e, t) : p((n) => ce(n, t, e));
4692
- }, [d]), g = t((e) => p((t) => le(t, e)), []), _ = t((e, t) => p((n) => ue(n, e, { title: t })), []);
4758
+ function fn({ documentId: e, chunkId: n, scope: i, titleHint: s, browse: d, principal: f, renderAssistant: p, onOpenDocument: m }) {
4759
+ let [h, g] = o([]), _ = h[h.length - 1], [v, y] = o(), b = a(n);
4760
+ r(() => {
4761
+ n !== b.current && (b.current = n, h.length > 0 ? (y(void 0), g([])) : y((e) => ({
4762
+ chunkId: n,
4763
+ seq: (e?.seq ?? 0) + 1
4764
+ })));
4765
+ }, [n]);
4766
+ let x = t((e, t) => {
4767
+ m ? m(e, t) : g((n) => ce(n, t, e));
4768
+ }, [m]), S = t((e) => g((t) => le(t, e)), []), C = t((e, t) => g((n) => ue(n, e, { title: t })), []);
4693
4769
  return /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(pe, {
4694
- trail: f,
4695
- onJump: g
4696
- }), /* @__PURE__ */ l(Jt, {
4697
- documentId: m?.documentId ?? e,
4698
- scope: n,
4699
- titleHint: m ? m.title : r,
4700
- browse: i,
4701
- principal: a,
4702
- renderAssistant: s,
4703
- initialChunkId: m?.chunkId,
4704
- onOpenDocument: h,
4705
- onTitle: _
4706
- }, f.length)] });
4770
+ trail: h,
4771
+ onJump: S
4772
+ }), /* @__PURE__ */ l(Zt, {
4773
+ documentId: _?.documentId ?? e,
4774
+ scope: i,
4775
+ titleHint: _ ? _.title : s,
4776
+ browse: d,
4777
+ principal: f,
4778
+ renderAssistant: p,
4779
+ initialChunkId: _ ? _.chunkId : n,
4780
+ focusChunk: _ ? void 0 : v,
4781
+ onOpenDocument: x,
4782
+ onTitle: C
4783
+ }, h.length)] });
4707
4784
  }
4708
4785
  //#endregion
4709
- export { Z as DEFAULT_SCHEME, cn as DocumentViewer, ye as EDGE_PAGE_CAP, an as PathExplorer, Ae as QUEUE_CHANGED_RETRIES, J as RULING_CHUNK, oe as RequestError, L as assetFetchFromConnection, He as chunkColor, Pe as chunkCount, Ue as chunkInheritsDocColor, qe as chunkRowStyle, I as createLoomcycleClient, O as dataLayerFromClient, Ve as docColor, Be as effectiveScheme, We as hexToTint, Me as isQueueChanged, se as jsonPostFromConnection, be as loadDocumentEdges, Ne as runRuling, Ge as tintStyle, b as transferInput, Y as undoRulings, Ke as washStyle };
4786
+ export { Z as DEFAULT_SCHEME, dn as DocumentViewer, ye as EDGE_PAGE_CAP, cn as PathExplorer, Ae as QUEUE_CHANGED_RETRIES, J as RULING_CHUNK, oe as RequestError, L as assetFetchFromConnection, He as chunkColor, Pe as chunkCount, Ue as chunkInheritsDocColor, qe as chunkRowStyle, I as createLoomcycleClient, O as dataLayerFromClient, Ve as docColor, Be as effectiveScheme, We as hexToTint, Me as isQueueChanged, se as jsonPostFromConnection, be as loadDocumentEdges, Ne as runRuling, Ge as tintStyle, b as transferInput, Y as undoRulings, Ke as washStyle };
4710
4787
 
4711
4788
  //# sourceMappingURL=index.js.map