@knkcs/contenthub-ui 0.3.0 → 0.4.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/testing.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as e, C as t, D as n, M as r, N as i, S as a, T as o, _ as s, b as c, f as l, g as u, h as d, i as f, j as p, n as m, o as ee, r as h, s as te, t as ne, u as re, v as ie, w as g, x as ae, y as _ } from "./heads-dBmqNcOB.js";
1
+ import { C as e, D as t, E as n, F as r, M as i, N as a, P as o, S as s, T as c, _ as l, b as u, f as d, g as f, h as p, i as ee, k as m, n as h, o as te, r as g, s as ne, t as re, u as ie, v as ae, w as _, x as oe, y as se } from "./heads-DqHmAW0n.js";
2
2
  import { Code as v, ConnectError as y } from "@connectrpc/connect";
3
3
  import { createHostMembers as b } from "@knkcs/anker/host";
4
4
  //#region src/testing/fixtures.ts
@@ -18,7 +18,7 @@ function T() {
18
18
  }])
19
19
  };
20
20
  }
21
- function oe() {
21
+ function ce() {
22
22
  return [{
23
23
  id: "br_author",
24
24
  name: "Being revised by the author",
@@ -31,12 +31,13 @@ function oe() {
31
31
  updateTime: w
32
32
  }];
33
33
  }
34
- function E() {
34
+ function le() {
35
35
  return [
36
36
  {
37
37
  slug: "in_progress",
38
38
  name: "In Bearbeitung",
39
- color: "steelblue"
39
+ color: "steelblue",
40
+ isDefault: !0
40
41
  },
41
42
  {
42
43
  slug: "in_review",
@@ -55,7 +56,7 @@ function E() {
55
56
  }
56
57
  ];
57
58
  }
58
- function se() {
59
+ function ue() {
59
60
  return {
60
61
  in_progress: ["in_review", "on_hold"],
61
62
  in_review: [
@@ -67,7 +68,7 @@ function se() {
67
68
  on_hold: ["in_progress"]
68
69
  };
69
70
  }
70
- function ce() {
71
+ function de() {
71
72
  return [
72
73
  {
73
74
  id: "cs_bgbl_270",
@@ -193,7 +194,7 @@ function ce() {
193
194
  }
194
195
  ];
195
196
  }
196
- function le() {
197
+ function fe() {
197
198
  return [{
198
199
  id: "rc_print",
199
200
  name: "Druckprobe",
@@ -208,7 +209,7 @@ function le() {
208
209
  independent: !0
209
210
  }];
210
211
  }
211
- function ue() {
212
+ function pe() {
212
213
  return [
213
214
  {
214
215
  id: "col_bgb",
@@ -236,7 +237,7 @@ function ue() {
236
237
  }
237
238
  ];
238
239
  }
239
- function de() {
240
+ function me() {
240
241
  return [
241
242
  {
242
243
  id: "bp_commentary",
@@ -252,7 +253,7 @@ function de() {
252
253
  }
253
254
  ];
254
255
  }
255
- function fe() {
256
+ function he() {
256
257
  return [
257
258
  {
258
259
  id: "bpr_paragraph_2",
@@ -274,7 +275,7 @@ function fe() {
274
275
  }
275
276
  ];
276
277
  }
277
- function pe() {
278
+ function ge() {
278
279
  let e = (e, t) => ({
279
280
  field_type: "text",
280
281
  config: {
@@ -286,6 +287,7 @@ function pe() {
286
287
  system: !1
287
288
  }), t = {
288
289
  displayName: "Paragraph",
290
+ accessor: "paragraph",
289
291
  dated: !0,
290
292
  fields: [e("number", "Number"), e("heading", "Heading")],
291
293
  parts: {}
@@ -295,13 +297,51 @@ function pe() {
295
297
  bpr_paragraph_2: t,
296
298
  bpr_footnote_1: {
297
299
  displayName: "Footnote",
300
+ accessor: "footnote",
298
301
  dated: !0,
299
302
  fields: [e("text", "Text")],
300
303
  parts: {}
304
+ },
305
+ bpr_note_1: {
306
+ displayName: "Note",
307
+ accessor: "note",
308
+ dated: !1,
309
+ fields: [e("title", "Title")],
310
+ parts: {}
301
311
  }
302
312
  };
303
313
  }
304
- function D() {
314
+ function E() {
315
+ let e = "2026-09-01T08:00:00.000Z";
316
+ return {
317
+ id: "content_note_1",
318
+ blueprintId: "bp_note",
319
+ blueprintReleaseId: "bpr_note_1",
320
+ collectionIds: [],
321
+ main: {
322
+ revisionId: "rev_note1_main",
323
+ data: { title: "Hinweis" },
324
+ revisionCreateTime: e
325
+ },
326
+ inForce: {
327
+ revisionId: "rev_note1_main",
328
+ data: { title: "Hinweis" },
329
+ revisionCreateTime: e,
330
+ releaseId: "rls_note1_1"
331
+ },
332
+ branches: {},
333
+ timeline: [{
334
+ ordinal: 1,
335
+ releaseId: "rls_note1_1",
336
+ kind: "revision",
337
+ revisionId: "rev_note1_main",
338
+ blueprintReleaseId: "bpr_note_1",
339
+ publishTime: e,
340
+ first: !0
341
+ }]
342
+ };
343
+ }
344
+ function _e() {
305
345
  let e = "2001-11-01T08:00:00.000Z";
306
346
  return {
307
347
  id: "content_para_3",
@@ -332,7 +372,7 @@ function D() {
332
372
  }]
333
373
  };
334
374
  }
335
- function me() {
375
+ function ve() {
336
376
  let e = "2026-09-01T08:00:00.000Z";
337
377
  return [
338
378
  {
@@ -585,7 +625,7 @@ function me() {
585
625
  }
586
626
  //#endregion
587
627
  //#region src/testing/stub-blueprint-source.ts
588
- function he(e = de(), t = fe()) {
628
+ function D(e = me(), t = he()) {
589
629
  return {
590
630
  async searchBlueprints({ query: t }) {
591
631
  let n = t.trim().toLocaleLowerCase();
@@ -604,37 +644,37 @@ function he(e = de(), t = fe()) {
604
644
  }
605
645
  //#endregion
606
646
  //#region src/testing/stub-client.ts
607
- function ge(e, t) {
647
+ function ye(e, t) {
608
648
  let n = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
609
649
  return n.setUTCDate(n.getUTCDate() + t), n.toISOString().slice(0, 10);
610
650
  }
611
651
  function O(e, t, n) {
612
652
  let r = e.trim();
613
- if (r === "") throw new a(`${t} is required`);
614
- if ([...r].length > n) throw new a(`${t} is at most ${n} characters`);
615
- if (/[\u0000-\u001f\u007f]/.test(r)) throw new a(`${t} is one line of text`);
653
+ if (r === "") throw new _(`${t} is required`);
654
+ if ([...r].length > n) throw new _(`${t} is at most ${n} characters`);
655
+ if (/[\u0000-\u001f\u007f]/.test(r)) throw new _(`${t} is one line of text`);
616
656
  return r;
617
657
  }
618
- function _e(e) {
619
- if (!/^\d{4}-\d{2}-\d{2}$/.test(e.date.trim())) throw new a(`source.date "${e.date}" is not a day as YYYY-MM-DD`);
658
+ function be(e) {
659
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(e.date.trim())) throw new _(`source.date "${e.date}" is not a day as YYYY-MM-DD`);
620
660
  return {
621
661
  date: e.date.trim(),
622
662
  reference: O(e.reference, "source.reference", 500)
623
663
  };
624
664
  }
625
- function ve(e) {
665
+ function xe(e) {
626
666
  let t = e.trim();
627
- if (t === "") throw new a("a Block Reason needs a name");
628
- if ([...t].length > 200) throw new a("a Block Reason's name is at most 200 characters");
629
- if (/[\u0000-\u001f\u007f]/.test(t)) throw new a("a Block Reason's name is one line of text");
667
+ if (t === "") throw new _("a Block Reason needs a name");
668
+ if ([...t].length > 200) throw new _("a Block Reason's name is at most 200 characters");
669
+ if (/[\u0000-\u001f\u007f]/.test(t)) throw new _("a Block Reason's name is one line of text");
630
670
  return t;
631
671
  }
632
- function ye(e) {
672
+ function Se(e) {
633
673
  let t = O(e.name, "a Required Check's name", 200);
634
- if (e.scope !== "branch" && e.scope !== "change_set") throw new a("a Required Check's scope is Branch or Change Set");
674
+ if (e.scope !== "branch" && e.scope !== "change_set") throw new _("a Required Check's scope is Branch or Change Set");
635
675
  let n = e.blueprintAccessors.map((e) => {
636
676
  let t = e.trim();
637
- if (t === "" || [...t].length > 200 || /[\u0000-\u001f\u007f]/.test(t)) throw new a(`"${t}" is not a Blueprint accessor`);
677
+ if (t === "" || [...t].length > 200 || /[\u0000-\u001f\u007f]/.test(t)) throw new _(`"${t}" is not a Blueprint accessor`);
638
678
  return t;
639
679
  });
640
680
  return {
@@ -644,7 +684,7 @@ function ye(e) {
644
684
  independent: e.independent
645
685
  };
646
686
  }
647
- var be = "who records a Required Check can be narrowed only in authz.mode guardian: in workspace mode every member records every check (ADR 0017)", xe = "this Change Set holds work you can't see: publishing, discarding or updating all of it needs you to see every Content in it", Se = "Restricted Collections need authz.mode guardian: in workspace mode a restriction could not be enforced (ADR 0017)";
687
+ var Ce = "who records a Required Check can be narrowed only in authz.mode guardian: in workspace mode every member records every check (ADR 0017)", we = "this Change Set holds work you can't see: publishing, discarding or updating all of it needs you to see every Content in it", Te = "Restricted Collections need authz.mode guardian: in workspace mode a restriction could not be enforced (ADR 0017)";
648
688
  function k(e, t) {
649
689
  return new y(`${e} ${t}: not found`, v.NotFound);
650
690
  }
@@ -670,25 +710,40 @@ function j(e, t = {}) {
670
710
  };
671
711
  }
672
712
  function M(v = {}) {
673
- let y = v.now ?? (() => "2026-10-01T09:00:00.000Z"), b = v.userId ?? "user_stub", x = v.statuses ?? E(), S = v.statusTransitions ?? se(), C = (v.blockReasons ?? oe()).map((e) => ({ ...e })), w = (v.changeSets ?? ce()).map(A), T = (v.collections ?? ue()).map((e) => ({ ...e })), D = structuredClone(v.contents ?? me()), he = v.blueprints ?? de(), M = v.blueprintReleases ?? fe(), P = v.resolvedReleases ?? pe(), F = structuredClone(v.requiredChecks ?? le()), I = v.authzMode ?? "guardian", Ce = new Set(v.withheld ?? []), L = (e) => {
674
- if (Ce.has(e)) throw new i(xe);
675
- }, R = new Map(Object.entries(structuredClone(v.collectionGrants ?? {}))), z = new Map(Object.entries(structuredClone(v.recorders ?? {}))), we = (e) => z.get(e) ?? {
713
+ let y = v.now ?? (() => "2026-10-01T09:00:00.000Z"), b = v.userId ?? "user_stub", x = v.statuses ?? le(), S = v.statusTransitions ?? ue(), C = (v.blockReasons ?? ce()).map((e) => ({ ...e })), w = (v.changeSets ?? de()).map(A), T = (v.collections ?? pe()).map((e) => ({ ...e })), E = structuredClone(v.contents ?? ve()), _e = v.blueprints ?? me(), D = v.blueprintReleases ?? he(), M = v.resolvedReleases ?? ge(), N = structuredClone(v.requiredChecks ?? fe()), P = v.authzMode ?? "guardian", De = new Set(v.withheld ?? []), F = (e) => {
714
+ if (De.has(e)) throw new r(we);
715
+ }, I = new Map(Object.entries(structuredClone(v.collectionGrants ?? {}))), L = new Map(Object.entries(structuredClone(v.recorders ?? {}))), Oe = (e) => L.get(e) ?? {
676
716
  everyMember: !0,
677
717
  userIds: []
678
- }, Te = v.memberIds ?? ["user_stub", "user_ben"], Ee = v.admin ?? !0, De = structuredClone(v.checkResults ?? []), Oe = v.publishBlockers ?? {}, ke = v.pendingMerges ?? {}, Ae = structuredClone(v.conflicts ?? {}), B = /* @__PURE__ */ new Map(), je = /* @__PURE__ */ new Map(), V = async (e, t, n) => {
718
+ }, ke = v.memberIds ?? ["user_stub", "user_ben"], Ae = v.admin ?? !0, R = structuredClone(v.editingSettings ?? {
719
+ editingMode: "change_sets",
720
+ editingBlock: !1
721
+ }), z = structuredClone(v.editingOverrides ?? []), je = (e) => ({
722
+ editingMode: e?.editingMode ?? R.editingMode,
723
+ editingBlock: e?.editingBlock ?? R.editingBlock
724
+ }), Me = (e) => ({
725
+ ...structuredClone(e),
726
+ effective: je(e)
727
+ }), Ne = [
728
+ "direct_edits",
729
+ "change_sets",
730
+ "both"
731
+ ], Pe = () => {
732
+ if (!Ae) throw new ne("permission denied");
733
+ }, Fe = structuredClone(v.checkResults ?? []), Ie = v.publishBlockers ?? {}, Le = v.pendingMerges ?? {}, Re = structuredClone(v.conflicts ?? {}), B = /* @__PURE__ */ new Map(), ze = /* @__PURE__ */ new Map(), V = async (e, t, n) => {
679
734
  if (!e) return n();
680
- let r = JSON.stringify(t), i = je.get(e);
735
+ let r = JSON.stringify(t), i = ze.get(e);
681
736
  if (i) {
682
- if (i.asked !== r) throw new a(`idempotency key ${e} names another request`);
737
+ if (i.asked !== r) throw new _(`idempotency key ${e} names another request`);
683
738
  return structuredClone(i.answer);
684
739
  }
685
- let o = await n();
686
- return je.set(e, {
740
+ let a = await n();
741
+ return ze.set(e, {
687
742
  asked: r,
688
- answer: structuredClone(o)
689
- }), o;
690
- }, Me = /* @__PURE__ */ new Map(), Ne = /* @__PURE__ */ new Map(), H = 1, U = (e) => {
691
- let t = D.find((t) => t.id === e);
743
+ answer: structuredClone(a)
744
+ }), a;
745
+ }, Be = /* @__PURE__ */ new Map(), Ve = /* @__PURE__ */ new Map(), H = 1, U = (e) => {
746
+ let t = E.find((t) => t.id === e);
692
747
  if (!t) throw k("Content", e);
693
748
  return t;
694
749
  }, W = (e) => structuredClone({
@@ -696,7 +751,7 @@ function M(v = {}) {
696
751
  assigneeIds: e.assigneeIds ?? [],
697
752
  block: e.block,
698
753
  archiveTime: e.archiveTime
699
- }), Pe = () => y().slice(0, 10), G = (e) => P[e.blueprintReleaseId]?.dated ?? !1, K = (e) => {
754
+ }), He = () => y().slice(0, 10), G = (e) => M[e.blueprintReleaseId]?.dated ?? !1, K = (e) => {
700
755
  let t = [...e.revisions ?? []], n = [...Object.entries(e.branches).map(([e, t]) => ({
701
756
  ...t,
702
757
  changeSetId: e
@@ -723,58 +778,58 @@ function M(v = {}) {
723
778
  e.main,
724
779
  e.inForce,
725
780
  ...Object.values(e.branches)
726
- ].find((e) => e?.revisionId === t)?.data ?? e.revisions?.find((e) => e.id === t)?.data, Fe = (e, t) => {
781
+ ].find((e) => e?.revisionId === t)?.data ?? e.revisions?.find((e) => e.id === t)?.data, Ue = (e, t) => {
727
782
  let n = (e) => e == null || e === "" || Array.isArray(e) && e.length === 0;
728
783
  return (e ?? []).filter((e) => e.config.required === !0 && n(t[e.config.api_accessor])).map((e) => e.config.api_accessor);
729
784
  }, J = (e) => {
730
- if (e.archiveTime) throw new s(e.id);
731
- if (e.block && !e.block.allowedUserIds.includes(b)) throw new ie(e.id, e.block.blockReasonId);
732
- }, Ie = (e) => D.flatMap((t) => (t.edges ?? []).filter((n) => n.targetContentId === e && n.pinReleaseId === "" && t.inForce?.revisionId === n.sourceRevisionId).map((e) => ({
785
+ if (e.archiveTime) throw new l(e.id);
786
+ if (e.block && !e.block.allowedUserIds.includes(b)) throw new ae(e.id, e.block.blockReasonId);
787
+ }, We = (e) => E.flatMap((t) => (t.edges ?? []).filter((n) => n.targetContentId === e && n.pinReleaseId === "" && t.inForce?.revisionId === n.sourceRevisionId).map((e) => ({
733
788
  edge: { ...e },
734
789
  releaseId: t.inForce?.releaseId ?? ""
735
- }))), Le = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id), Re = (e, t) => C.some((n) => n.name === e && n.id !== t), ze = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id), Y = (e) => {
790
+ }))), Ge = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id), Ke = (e, t) => C.some((n) => n.name === e && n.id !== t), qe = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id), Y = (e) => {
736
791
  let t = T.find((t) => t.id === e);
737
792
  if (!t) throw k("Collection", e);
738
793
  return t;
739
- }, Be = (e, t, n) => T.some((r) => r.parentId === e && r.name === t && r.id !== n), Ve = (e) => {
740
- if (I === "workspace") throw new n(Se);
741
- if (!Y(e).restricted) throw new a(`Collection ${e} is open: only a Restricted Collection takes grants`);
742
- let t = (R.get(e) ?? []).some((e) => e.userId === b && e.level === "owner");
743
- if (!Ee && !t) throw new te("only its owner or a workspace admin manages its grants");
744
- }, He = (e) => {
745
- if (I === "workspace") throw new ae("required_check_recorders", be);
746
- if (!Ee) throw new te("permission denied");
747
- if (e === "") throw new a("required_check_id is required");
748
- if (!F.some((t) => t.id === e)) throw k("Required Check", e);
749
- return we(e);
750
- }, Ue = async ({ changeSetId: t, branchId: n, expectedHeadId: r, data: i, fieldMask: o }) => {
751
- let s = Z(t).chains.find((e) => e.branches.some((e) => e.id === n)), c = s?.branches.find((e) => e.id === n);
752
- if (!s || !c) throw k("Branch", n);
753
- let l = U(s.contentId);
754
- if (J(l), B.has(n)) throw new a("a Pending Merge waits on this Branch: resolve or abort it first");
755
- if (r === "") throw new a("expected_head_id is required");
756
- if (c.headRevisionId !== r) throw new e({
757
- contentId: l.id,
758
- branchId: n,
759
- expectedHeadId: r,
760
- currentHeadId: c.headRevisionId
794
+ }, Je = (e, t, n) => T.some((r) => r.parentId === e && r.name === t && r.id !== n), Ye = (e) => {
795
+ if (P === "workspace") throw new m(Te);
796
+ if (!Y(e).restricted) throw new _(`Collection ${e} is open: only a Restricted Collection takes grants`);
797
+ let t = (I.get(e) ?? []).some((e) => e.userId === b && e.level === "owner");
798
+ if (!Ae && !t) throw new ne("only its owner or a workspace admin manages its grants");
799
+ }, Xe = (t) => {
800
+ if (P === "workspace") throw new e("required_check_recorders", Ce);
801
+ if (!Ae) throw new ne("permission denied");
802
+ if (t === "") throw new _("required_check_id is required");
803
+ if (!N.some((e) => e.id === t)) throw k("Required Check", t);
804
+ return Oe(t);
805
+ }, Ze = async ({ changeSetId: e, branchId: t, expectedHeadId: n, data: r, fieldMask: a }) => {
806
+ let o = Z(e).chains.find((e) => e.branches.some((e) => e.id === t)), s = o?.branches.find((e) => e.id === t);
807
+ if (!o || !s) throw k("Branch", t);
808
+ let c = U(o.contentId);
809
+ if (J(c), B.has(t)) throw new _("a Pending Merge waits on this Branch: resolve or abort it first");
810
+ if (n === "") throw new _("expected_head_id is required");
811
+ if (s.headRevisionId !== n) throw new i({
812
+ contentId: c.id,
813
+ branchId: t,
814
+ expectedHeadId: n,
815
+ currentHeadId: s.headRevisionId
761
816
  });
762
- let u = q(l, c.headRevisionId) ?? {}, d = JSON.parse(JSON.stringify(i)), f;
763
- if (o) {
764
- let e = Object.keys(d).filter((e) => !o.includes(e));
765
- if (e.length > 0) throw new a(`data holds ${e.join(", ")}, which the mask doesn't name`);
766
- f = structuredClone(u);
767
- for (let e of o) e in d ? f[e] = d[e] : delete f[e];
768
- } else f = d;
769
- return We({
770
- changeSetId: t,
771
- chain: s,
772
- branch: c,
773
- c: l,
774
- data: f,
817
+ let l = q(c, s.headRevisionId) ?? {}, u = JSON.parse(JSON.stringify(r)), d;
818
+ if (a) {
819
+ let e = Object.keys(u).filter((e) => !a.includes(e));
820
+ if (e.length > 0) throw new _(`data holds ${e.join(", ")}, which the mask doesn't name`);
821
+ d = structuredClone(l);
822
+ for (let e of a) e in u ? d[e] = u[e] : delete d[e];
823
+ } else d = u;
824
+ return Qe({
825
+ changeSetId: e,
826
+ chain: o,
827
+ branch: s,
828
+ c,
829
+ data: d,
775
830
  cause: "save"
776
831
  });
777
- }, We = ({ changeSetId: e, chain: t, branch: n, c: r, data: i, cause: a, secondParentId: o = "" }) => {
832
+ }, Qe = ({ changeSetId: e, chain: t, branch: n, c: r, data: i, cause: a, secondParentId: o = "" }) => {
778
833
  let s = n.id, c = `rev_stub_${H++}`, l = y();
779
834
  return r.revisions = [{
780
835
  id: c,
@@ -804,7 +859,7 @@ function M(v = {}) {
804
859
  revisionCreateTime: l,
805
860
  releaseId: ""
806
861
  };
807
- }, Ge = (e, t) => {
862
+ }, $e = (e, t) => {
808
863
  let n = Z(e), r = n.chains.find((e) => e.branches.some((e) => e.id === t)), i = r?.branches.find((e) => e.id === t);
809
864
  if (!r || !i) throw k("Branch", t);
810
865
  return {
@@ -813,7 +868,7 @@ function M(v = {}) {
813
868
  branch: i,
814
869
  c: U(r.contentId)
815
870
  };
816
- }, Ke = (e, t) => {
871
+ }, et = (e, t) => {
817
872
  for (let n of w) for (let r of n.chains) {
818
873
  let n = r.branches.find((t) => t.id === e);
819
874
  if (!n) continue;
@@ -827,33 +882,33 @@ function M(v = {}) {
827
882
  fields: structuredClone(t.fields),
828
883
  merged: structuredClone(t.merged)
829
884
  };
830
- B.set(e, i), n.hasPendingMerge = !0, delete Ae[e];
885
+ B.set(e, i), n.hasPendingMerge = !0, delete Re[e];
831
886
  return;
832
887
  }
833
888
  throw k("Branch", e);
834
- }, qe = (e) => {
889
+ }, tt = (e) => {
835
890
  B.delete(e);
836
891
  for (let t of w) for (let n of t.chains) {
837
892
  let t = n.branches.find((t) => t.id === e);
838
893
  t && (t.hasPendingMerge = !1);
839
894
  }
840
- }, Je = (e, t) => {
895
+ }, nt = (e, t) => {
841
896
  let n = t.validityPeriod;
842
897
  if (G(e)) {
843
- if (!n || !h.test(n.firstDay)) throw new a("validity_period.first_day is required for Dated Content");
844
- if (n.lastDay !== "" && (!h.test(n.lastDay) || n.lastDay < n.firstDay)) throw new a("validity_period.last_day is a day on or after first_day");
845
- } else if (n) throw new a("validity_period is refused for undated Content");
846
- let r = Fe(P[e.blueprintReleaseId]?.releaseSpec, t.releaseSpec ?? {}).map((e) => ({
898
+ if (!n || !g.test(n.firstDay)) throw new _("validity_period.first_day is required for Dated Content");
899
+ if (n.lastDay !== "" && (!g.test(n.lastDay) || n.lastDay < n.firstDay)) throw new _("validity_period.last_day is a day on or after first_day");
900
+ } else if (n) throw new _("validity_period is refused for undated Content");
901
+ let r = Ue(M[e.blueprintReleaseId]?.releaseSpec, t.releaseSpec ?? {}).map((e) => ({
847
902
  source: "fieldkit",
848
903
  code: "required",
849
904
  path: `/${e}`
850
905
  }));
851
- if (r.length > 0) throw new _("the Release Spec values break the Blueprint Release", r);
906
+ if (r.length > 0) throw new se("the Release Spec values break the Blueprint Release", r);
852
907
  if (n && n.lastDay !== "") {
853
908
  let r = (e.timeline ?? []).filter((e) => e.validityPeriod && e.validityPeriod.lastDay !== "" && n.firstDay <= e.validityPeriod.firstDay && e.validityPeriod.lastDay <= n.lastDay && !t.supersedesReleaseIds.includes(e.releaseId)).map((e) => e.releaseId);
854
- if (r.length > 0) throw new c(e.id, r);
909
+ if (r.length > 0) throw new u(e.id, r);
855
910
  }
856
- }, Ye = (e, t) => {
911
+ }, rt = (e, t) => {
857
912
  let n = e.plannedReleases.filter((e) => e.contentId === t.id && e.proposed), r = e.plannedReleases.filter((e) => !(e.contentId === t.id && e.proposed)), i = [], a = (e, r, a) => {
858
913
  let o = n.find((t) => t.proposedForReleaseId === e.releaseId && t.splitFromReleaseId === a);
859
914
  i.push({
@@ -876,9 +931,9 @@ function M(v = {}) {
876
931
  let t = r.validityPeriod;
877
932
  t && !e.supersedesReleaseIds.includes(r.releaseId) && t.firstDay < n.firstDay && (t.lastDay === "" || t.lastDay >= n.firstDay) && (a(r, {
878
933
  firstDay: t.firstDay,
879
- lastDay: ge(n.firstDay, -1)
934
+ lastDay: ye(n.firstDay, -1)
880
935
  }, ""), n.lastDay !== "" && (t.lastDay === "" || t.lastDay > n.lastDay) && a(r, {
881
- firstDay: ge(n.lastDay, 1),
936
+ firstDay: ye(n.lastDay, 1),
882
937
  lastDay: t.lastDay
883
938
  }, r.releaseId));
884
939
  }
@@ -890,9 +945,9 @@ function M(v = {}) {
890
945
  return t;
891
946
  }, Z = (e) => {
892
947
  let t = X(e);
893
- if (t.state !== "open") throw new d(t.state);
948
+ if (t.state !== "open") throw new p(t.state);
894
949
  return t;
895
- }, Xe = (e) => x.find((t) => t.slug === e)?.name ?? e, Ze = (e, t, n = /* @__PURE__ */ new Set()) => e === t || !n.has(e) && (n.add(e), (w.find((t) => t.id === e)?.dependsOnChangeSetIds ?? []).some((e) => Ze(e, t, n))), Qe = (e) => [...e.chains.flatMap((e) => e.branches.map((t) => ({
950
+ }, it = (e) => x.find((t) => t.slug === e)?.name ?? e, at = (e, t, n = /* @__PURE__ */ new Set()) => e === t || !n.has(e) && (n.add(e), (w.find((t) => t.id === e)?.dependsOnChangeSetIds ?? []).some((e) => at(e, t, n))), ot = (e) => [...e.chains.flatMap((e) => e.branches.map((t) => ({
896
951
  key: t.id,
897
952
  branchless: !1,
898
953
  contentId: e.contentId,
@@ -902,9 +957,9 @@ function M(v = {}) {
902
957
  branchless: !0,
903
958
  contentId: e.contentId,
904
959
  revision: e.revisionId
905
- }))], $e = (e) => D.find((t) => t.id === e)?.blueprintId, et = (e, t) => e.blueprintAccessors.length === 0 || e.blueprintAccessors.includes($e(t) ?? ""), tt = (e) => {
906
- let t = Qe(e), n = (t, n) => De.filter((n) => n.changeSetId === e.id && n.requiredCheckId === t.id).filter((e) => (t.scope === "change_set" ? "" : Object.keys(e.heads)[0]) === n).reverse().map(({ changeSetId: e, ...t }) => structuredClone(t)), r = (e, t, n) => {
907
- let r = n[0], i = r ? !m(r.heads, t.heads) : !1;
960
+ }))], st = (e) => E.find((t) => t.id === e)?.blueprintId, ct = (e, t) => e.blueprintAccessors.length === 0 || e.blueprintAccessors.includes(st(t) ?? ""), lt = (e) => {
961
+ let t = ot(e), n = (t, n) => Fe.filter((n) => n.changeSetId === e.id && n.requiredCheckId === t.id).filter((e) => (t.scope === "change_set" ? "" : Object.keys(e.heads)[0]) === n).reverse().map(({ changeSetId: e, ...t }) => structuredClone(t)), r = (e, t, n) => {
962
+ let r = n[0], i = r ? !h(r.heads, t.heads) : !1;
908
963
  return {
909
964
  check: structuredClone(e),
910
965
  ...t,
@@ -913,8 +968,8 @@ function M(v = {}) {
913
968
  cleared: !!r && !i && r.outcome !== "failed"
914
969
  };
915
970
  }, i = [], a = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id);
916
- for (let e of [...F].sort(a)) {
917
- let a = t.filter((t) => et(e, t.contentId));
971
+ for (let e of [...N].sort(a)) {
972
+ let a = t.filter((t) => ct(e, t.contentId));
918
973
  if (e.scope === "change_set") {
919
974
  if (a.length === 0) continue;
920
975
  let o = Object.fromEntries(t.map((e) => [e.key, e.revision]));
@@ -934,8 +989,8 @@ function M(v = {}) {
934
989
  }, n(e, t.key)));
935
990
  }
936
991
  return i;
937
- }, nt = (e, t) => {
938
- let n = [], r = ne(e);
992
+ }, ut = (e, t) => {
993
+ let n = [], r = re(e);
939
994
  for (let r of e.chains) for (let e of r.branches) t[e.id] !== e.headRevisionId && n.push(j("moved_head", {
940
995
  contentId: r.contentId,
941
996
  branchId: e.id,
@@ -950,26 +1005,26 @@ function M(v = {}) {
950
1005
  let e = w.find((e) => e.id === t)?.state;
951
1006
  e === "open" ? n.push(j("unpublished_dependency", { dependencyChangeSetId: t })) : e === "discarded" && n.push(j("discarded_dependency", { dependencyChangeSetId: t }));
952
1007
  }
953
- for (let t of tt(e)) t.cleared || n.push(j("outstanding_check", {
1008
+ for (let t of lt(e)) t.cleared || n.push(j("outstanding_check", {
954
1009
  requiredCheckId: t.check.id,
955
1010
  contentId: t.contentId,
956
1011
  branchId: t.branchId,
957
1012
  releaseId: t.releaseId
958
1013
  }));
959
1014
  for (let t of e.chains) {
960
- let e = D.find((e) => e.id === t.contentId);
1015
+ let e = E.find((e) => e.id === t.contentId);
961
1016
  for (let r of t.branches) {
962
1017
  let t = e && q(e, r.headRevisionId);
963
- if (e && t) for (let i of Fe(P[e.blueprintReleaseId]?.fields, t)) n.push(j("missing_required_field", {
1018
+ if (e && t) for (let i of Ue(M[e.blueprintReleaseId]?.fields, t)) n.push(j("missing_required_field", {
964
1019
  contentId: e.id,
965
1020
  revisionId: r.headRevisionId,
966
1021
  path: `/${i}`
967
1022
  }));
968
1023
  }
969
1024
  }
970
- return [...n, ...structuredClone(Oe[e.id] ?? [])];
1025
+ return [...n, ...structuredClone(Ie[e.id] ?? [])];
971
1026
  }, Q = (e) => {
972
- let t = ne(e);
1027
+ let t = re(e);
973
1028
  return e.plannedReleases.filter((e) => !e.withheld).map((n) => ({
974
1029
  id: n.id,
975
1030
  contentId: n.contentId,
@@ -981,14 +1036,14 @@ function M(v = {}) {
981
1036
  validityPeriod: n.validityPeriod ? { ...n.validityPeriod } : void 0
982
1037
  }));
983
1038
  };
984
- for (let [e, t] of Object.entries(Ae)) t.pending && Ke(e, t);
985
- return {
1039
+ for (let [e, t] of Object.entries(Re)) t.pending && et(e, t);
1040
+ let $ = {
986
1041
  async listBlockReasons() {
987
- return [...C].sort(Le).map((e) => ({ ...e }));
1042
+ return [...C].sort(Ge).map((e) => ({ ...e }));
988
1043
  },
989
1044
  async createBlockReason({ name: e }) {
990
- let t = ve(e);
991
- if (Re(t)) throw new re(t);
1045
+ let t = xe(e);
1046
+ if (Ke(t)) throw new ie(t);
992
1047
  let n = {
993
1048
  id: `br_stub_${H++}`,
994
1049
  name: t,
@@ -998,9 +1053,9 @@ function M(v = {}) {
998
1053
  return C.push(n), { ...n };
999
1054
  },
1000
1055
  async renameBlockReason({ id: e, name: t }) {
1001
- let n = ve(t), r = C.find((t) => t.id === e);
1056
+ let n = xe(t), r = C.find((t) => t.id === e);
1002
1057
  if (!r) throw k("Block Reason", e);
1003
- if (Re(n, e)) throw new re(n);
1058
+ if (Ke(n, e)) throw new ie(n);
1004
1059
  return r.name = n, r.updateTime = y(), { ...r };
1005
1060
  },
1006
1061
  async deleteBlockReason({ id: e }) {
@@ -1008,7 +1063,7 @@ function M(v = {}) {
1008
1063
  C = C.filter((t) => t.id !== e);
1009
1064
  },
1010
1065
  async listChangeSets(e = {}) {
1011
- let t = w.filter((t) => (!e.state || t.state === e.state) && (!e.assigneeId || t.assigneeIds.includes(e.assigneeId)) && (!e.contentId || t.chains.some((t) => t.contentId === e.contentId))), n = Math.min(e.pageSize || 50, 200), r = e.pageToken ? Number(e.pageToken) : 0;
1066
+ let t = w.filter((t) => (!e.state || t.state === e.state) && (!e.assigneeId || t.assigneeIds.includes(e.assigneeId)) && (!e.contentId || t.chains.some((t) => t.contentId === e.contentId)) && (!e.kind || (t.kind ?? "change_set") === e.kind) && (!e.editorId || t.editorId === e.editorId)), n = Math.min(e.pageSize || 50, 200), r = e.pageToken ? Number(e.pageToken) : 0;
1012
1067
  return {
1013
1068
  changeSets: t.slice(r, r + n).map((e) => ({
1014
1069
  ...A(e),
@@ -1020,7 +1075,7 @@ function M(v = {}) {
1020
1075
  };
1021
1076
  },
1022
1077
  async createChangeSet({ name: e, source: t }) {
1023
- let n = O(e, "name", 200), r = t ? _e(t) : void 0, i = {
1078
+ let n = O(e, "name", 200), r = t ? be(t) : void 0, i = {
1024
1079
  id: `cs_stub_${H++}`,
1025
1080
  name: n,
1026
1081
  source: r,
@@ -1040,33 +1095,33 @@ function M(v = {}) {
1040
1095
  },
1041
1096
  async updateChangeSet({ id: e, updateMask: t, name: n, source: r }) {
1042
1097
  let i = Z(e);
1043
- if (t.length === 0) throw new a("update_mask is required");
1044
- let o = t.includes("name") ? O(n ?? "", "name", 200) : i.name, s = i.source;
1045
- return t.includes("source") && (s = r ? _e(r) : void 0), i.name = o, i.source = s, A(i);
1098
+ if (t.length === 0) throw new _("update_mask is required");
1099
+ let a = t.includes("name") ? O(n ?? "", "name", 200) : i.name, o = i.source;
1100
+ return t.includes("source") && (o = r ? be(r) : void 0), i.name = a, i.source = o, A(i);
1046
1101
  },
1047
1102
  async setChangeSetStatus({ id: e, expectedStatus: t, status: n }) {
1048
- let i = Z(e);
1049
- if (i.status !== t) throw new p(i.status);
1050
- if (i.status === n) return A(i);
1051
- if (!x.some((e) => e.slug === n)) throw new a(`status "${n}" is not in the workspace's catalogue`);
1052
- if (x.some((e) => e.slug === i.status) && !(S[i.status] ?? []).includes(n)) throw new r({
1053
- fromStatus: i.status,
1103
+ let r = Z(e);
1104
+ if (r.status !== t) throw new a(r.status);
1105
+ if (r.status === n) return A(r);
1106
+ if (!x.some((e) => e.slug === n)) throw new _(`status "${n}" is not in the workspace's catalogue`);
1107
+ if (x.some((e) => e.slug === r.status) && !(S[r.status] ?? []).includes(n)) throw new o({
1108
+ fromStatus: r.status,
1054
1109
  toStatus: n,
1055
- reason: `There is no transition from ${Xe(i.status)} to ${Xe(n)}.`,
1110
+ reason: `There is no transition from ${it(r.status)} to ${it(n)}.`,
1056
1111
  requiresPermission: !1
1057
1112
  });
1058
- return i.status = n, A(i);
1113
+ return r.status = n, A(r);
1059
1114
  },
1060
1115
  async setChangeSetAssignees({ id: e, assigneeIds: t }) {
1061
1116
  let n = X(e);
1062
- if (new Set(t).size !== t.length) throw new a("each assignee is given once");
1063
- if (t.length > 50) throw new a("at most 50 assignees");
1117
+ if (new Set(t).size !== t.length) throw new _("each assignee is given once");
1118
+ if (t.length > 50) throw new _("at most 50 assignees");
1064
1119
  return n.assigneeIds = [...t], A(n);
1065
1120
  },
1066
1121
  async addDependency({ id: e, dependsOnId: t }) {
1067
1122
  let n = Z(e), r = X(t);
1068
- if (r.state !== "open") throw new a(`Change Set ${t} is ${r.state}`);
1069
- if (Ze(t, e)) throw new a("the dependency would close a cycle");
1123
+ if (r.state !== "open") throw new _(`Change Set ${t} is ${r.state}`);
1124
+ if (at(t, e)) throw new _("the dependency would close a cycle");
1070
1125
  return n.dependsOnChangeSetIds.includes(t) || n.dependsOnChangeSetIds.push(t), A(n);
1071
1126
  },
1072
1127
  async removeDependency({ id: e, dependsOnId: t }) {
@@ -1076,39 +1131,102 @@ function M(v = {}) {
1076
1131
  },
1077
1132
  async validatePublish({ id: e, reviewedHeads: t }) {
1078
1133
  let n = X(e);
1079
- L(e);
1080
- let r = Me.get(e);
1081
- if (r && m(r, t)) return {
1134
+ F(e);
1135
+ let r = Be.get(e);
1136
+ if (r && h(r, t)) return {
1082
1137
  blockers: [],
1083
1138
  releases: Q(n),
1084
1139
  published: !0
1085
1140
  };
1086
- if (n.state !== "open") throw new d(n.state);
1141
+ if (n.state !== "open") throw new p(n.state);
1087
1142
  return {
1088
- blockers: nt(n, t),
1143
+ blockers: ut(n, t),
1089
1144
  releases: Q(n),
1090
1145
  published: !1
1091
1146
  };
1092
1147
  },
1093
- async publish({ id: e, reviewedHeads: t }) {
1094
- let n = X(e);
1095
- L(e);
1096
- let r = Me.get(e);
1097
- if (r && m(r, t)) return {
1098
- changeSet: A(n),
1099
- publishTime: n.closeTime ?? y(),
1100
- releases: Q(n)
1148
+ async publish({ id: e, reviewedHeads: n }) {
1149
+ let r = X(e);
1150
+ F(e);
1151
+ let i = Be.get(e);
1152
+ if (i && h(i, n)) return {
1153
+ changeSet: A(r),
1154
+ publishTime: r.closeTime ?? y(),
1155
+ releases: Q(r)
1101
1156
  };
1102
- if (n.state !== "open") throw new d(n.state);
1103
- let i = nt(n, t);
1104
- if (i.length > 0) throw new o(i);
1105
- let a = Q(n);
1106
- return n.state = "published", n.closeTime = y(), Me.set(e, { ...t }), {
1107
- changeSet: A(n),
1108
- publishTime: n.closeTime,
1109
- releases: a
1157
+ if (r.state !== "open") throw new p(r.state);
1158
+ let a = ut(r, n);
1159
+ if (a.length > 0) throw new t(a);
1160
+ let o = Q(r);
1161
+ return r.state = "published", r.closeTime = y(), Be.set(e, { ...n }), {
1162
+ changeSet: A(r),
1163
+ publishTime: r.closeTime,
1164
+ releases: o
1110
1165
  };
1111
1166
  },
1167
+ async changeValidity({ releaseId: e, validityPeriod: n, changeSetName: r, idempotencyKey: i }) {
1168
+ return V(i, [
1169
+ "changeValidity",
1170
+ e,
1171
+ n,
1172
+ r
1173
+ ], async () => {
1174
+ let i = E.find((t) => (t.timeline ?? []).some((t) => t.releaseId === e));
1175
+ if (!i) throw k("Release", e);
1176
+ J(i);
1177
+ let a = i.timeline ?? [], o = a.find((t) => t.releaseId === e);
1178
+ if (!o?.validityPeriod || !G(i)) throw new _("undated Releases carry no Validity Period");
1179
+ let { firstDay: c, lastDay: l = "" } = n;
1180
+ if (!g.test(c) || l !== "" && (!g.test(l) || l < c)) throw new _("validity_period is YYYY-MM-DD, the last day not before the first");
1181
+ let d = M[i.blueprintReleaseId]?.accessor ?? "", f = z.find((e) => e.blueprintAccessor === d);
1182
+ if (je(f).editingMode === "change_sets") throw new s(i.id, d);
1183
+ let p = a.filter((t) => t.releaseId !== e && t.validityPeriod && c <= t.validityPeriod.firstDay && (l === "" || t.validityPeriod.lastDay !== "" && t.validityPeriod.lastDay <= l)).map((e) => e.releaseId);
1184
+ if (p.length > 0) throw new u(i.id, p, !0);
1185
+ let ee = {
1186
+ id: `rls_stub_${H++}`,
1187
+ contentId: i.id,
1188
+ kind: "date_only",
1189
+ branchId: "",
1190
+ revisionId: o.revisionId,
1191
+ validityPeriod: {
1192
+ firstDay: c,
1193
+ lastDay: l
1194
+ },
1195
+ supersedesReleaseIds: [e],
1196
+ proposed: !1,
1197
+ proposedForReleaseId: "",
1198
+ splitFromReleaseId: "",
1199
+ withheld: !1
1200
+ }, m = {
1201
+ id: `cs_stub_${H++}`,
1202
+ name: r?.trim() || `Change of validity of ${i.id}`,
1203
+ state: "open",
1204
+ createdBy: b,
1205
+ createTime: y(),
1206
+ chains: [],
1207
+ dependsOnChangeSetIds: [],
1208
+ status: "",
1209
+ assigneeIds: [],
1210
+ plannedReleases: [ee]
1211
+ }, h = ut(m, {});
1212
+ if (h.length > 0) throw new t(h);
1213
+ let te = Q(m);
1214
+ return m.state = "published", m.closeTime = y(), w.unshift(m), Be.set(m.id, {}), i.timeline = a.map((t) => t.releaseId === e ? {
1215
+ ...t,
1216
+ releaseId: ee.id,
1217
+ kind: "date_only",
1218
+ validityPeriod: {
1219
+ firstDay: c,
1220
+ lastDay: l
1221
+ },
1222
+ publishTime: m.closeTime ?? y()
1223
+ } : t), {
1224
+ changeSet: A(m),
1225
+ publishTime: m.closeTime,
1226
+ releases: te
1227
+ };
1228
+ });
1229
+ },
1112
1230
  async updateFromMain({ id: e, chainId: t, idempotencyKey: n }) {
1113
1231
  return V(n, [
1114
1232
  "updateFromMain",
@@ -1116,16 +1234,16 @@ function M(v = {}) {
1116
1234
  t
1117
1235
  ], async () => {
1118
1236
  let n = Z(e);
1119
- t || L(e);
1237
+ t || F(e);
1120
1238
  let r = t ? n.chains.filter((e) => e.id === t) : n.chains;
1121
1239
  if (t && r.length === 0) throw k("Chain", t);
1122
- let i = structuredClone(ke[e] ?? []), a = [];
1240
+ let i = structuredClone(Le[e] ?? []), a = [];
1123
1241
  for (let e of r) for (let t of e.branches) {
1124
1242
  let n = {
1125
1243
  branchId: t.id,
1126
1244
  contentId: e.contentId
1127
- }, r = Ae[t.id];
1128
- B.has(t.id) ? a.push(n) : r && (Ke(t.id, r), i.push(n));
1245
+ }, r = Re[t.id];
1246
+ B.has(t.id) ? a.push(n) : r && (et(t.id, r), i.push(n));
1129
1247
  }
1130
1248
  return {
1131
1249
  changeSet: A(n),
@@ -1138,90 +1256,126 @@ function M(v = {}) {
1138
1256
  },
1139
1257
  async discardChangeSet(e) {
1140
1258
  let t = Z(e);
1141
- return L(e), t.state = "discarded", t.closeTime = y(), t.chains = [], A(t);
1259
+ return F(e), t.state = "discarded", t.closeTime = y(), t.chains = [], A(t);
1142
1260
  },
1143
1261
  async listCheckResults(e) {
1144
- return tt(X(e));
1145
- },
1146
- async recordCheckResult({ changeSetId: t, requiredCheckId: n, heads: r, outcome: i, note: o }) {
1147
- let s = Z(t);
1148
- if (i === "waived" && o.trim() === "") throw new a("a waived result needs a note saying why");
1149
- if ([...o].length > 2e3) throw new a(`a note is at most ${l} characters`);
1150
- let c = F.find((e) => e.id === n);
1151
- if (!c) throw k("Required Check", n);
1152
- let d = we(n);
1153
- if (I === "guardian" && !d.everyMember && !d.userIds.includes(b)) throw new u(`recording results of Required Check ${n} needs its recorder relation`);
1154
- let f = Qe(s), p = Object.keys(r);
1155
- if (c.scope === "branch" && p.length !== 1) throw new a("a Branch-scope result names one head");
1156
- if (c.scope === "change_set" && p.length !== f.length) throw new a("a Change Set-scope result names every head of the Change Set");
1157
- for (let t of p) {
1158
- let n = f.find((e) => e.key === t);
1159
- if (!n) throw new a(`heads name ${t}, which this Change Set doesn't hold`);
1160
- if (n.revision !== r[t]) throw new e({
1161
- contentId: n.contentId,
1162
- branchId: n.branchless ? "" : n.key,
1163
- expectedHeadId: r[t],
1164
- currentHeadId: n.revision
1262
+ return lt(X(e));
1263
+ },
1264
+ async recordCheckResult({ changeSetId: e, requiredCheckId: t, heads: n, outcome: r, note: a }) {
1265
+ let o = Z(e);
1266
+ if (r === "waived" && a.trim() === "") throw new _("a waived result needs a note saying why");
1267
+ if ([...a].length > 2e3) throw new _(`a note is at most ${d} characters`);
1268
+ let s = N.find((e) => e.id === t);
1269
+ if (!s) throw k("Required Check", t);
1270
+ let c = Oe(t);
1271
+ if (P === "guardian" && !c.everyMember && !c.userIds.includes(b)) throw new f(`recording results of Required Check ${t} needs its recorder relation`);
1272
+ let l = ot(o), u = Object.keys(n);
1273
+ if (s.scope === "branch" && u.length !== 1) throw new _("a Branch-scope result names one head");
1274
+ if (s.scope === "change_set" && u.length !== l.length) throw new _("a Change Set-scope result names every head of the Change Set");
1275
+ for (let e of u) {
1276
+ let t = l.find((t) => t.key === e);
1277
+ if (!t) throw new _(`heads name ${e}, which this Change Set doesn't hold`);
1278
+ if (t.revision !== n[e]) throw new i({
1279
+ contentId: t.contentId,
1280
+ branchId: t.branchless ? "" : t.key,
1281
+ expectedHeadId: n[e],
1282
+ currentHeadId: t.revision
1165
1283
  });
1166
1284
  }
1167
- let m = {
1285
+ let p = {
1168
1286
  id: `cr_stub_${H++}`,
1169
- requiredCheckId: n,
1170
- heads: { ...r },
1171
- outcome: i,
1172
- note: o,
1287
+ requiredCheckId: t,
1288
+ heads: { ...n },
1289
+ outcome: r,
1290
+ note: a,
1173
1291
  recordedBy: b,
1174
1292
  recordTime: y()
1175
1293
  };
1176
- return De.push({
1177
- ...m,
1178
- changeSetId: t
1179
- }), structuredClone(m);
1294
+ return Fe.push({
1295
+ ...p,
1296
+ changeSetId: e
1297
+ }), structuredClone(p);
1298
+ },
1299
+ async getEditingSettings() {
1300
+ let e = [...z].sort((e, t) => e.blueprintAccessor < t.blueprintAccessor ? -1 : 1);
1301
+ return {
1302
+ workspace: { ...R },
1303
+ overrides: e.map(Me)
1304
+ };
1305
+ },
1306
+ async getEffectiveEditingSettings(e) {
1307
+ let t = z.find((t) => t.blueprintAccessor === e.trim());
1308
+ return {
1309
+ effective: je(t),
1310
+ editingModeOverridden: (t?.editingMode ?? null) !== null,
1311
+ editingBlockOverridden: (t?.editingBlock ?? null) !== null
1312
+ };
1313
+ },
1314
+ async setEditingSettings(e) {
1315
+ if (Pe(), !Ne.includes(e.editingMode)) throw new _("the workspace's editing settings need an Editing Mode");
1316
+ return R = { ...e }, { ...R };
1317
+ },
1318
+ async setBlueprintEditingOverride({ blueprintAccessor: e, editingMode: t, editingBlock: n }) {
1319
+ Pe();
1320
+ let r = O(e, "a Blueprint accessor", 200);
1321
+ if (t === null && n === null) throw new _(`an override of "${r}" sets the Editing Mode, the Editing Block or both`);
1322
+ let i = {
1323
+ blueprintAccessor: r,
1324
+ editingMode: t,
1325
+ editingBlock: n
1326
+ };
1327
+ return z = [...z.filter((e) => e.blueprintAccessor !== r), i], Me(i);
1328
+ },
1329
+ async deleteBlueprintEditingOverride({ blueprintAccessor: e }) {
1330
+ Pe();
1331
+ let t = e.trim();
1332
+ if (!z.some((e) => e.blueprintAccessor === t)) throw k("an editing override of", t);
1333
+ z = z.filter((e) => e.blueprintAccessor !== t);
1180
1334
  },
1181
1335
  async listRequiredChecks() {
1182
1336
  let e = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id);
1183
- return structuredClone([...F].sort(e));
1337
+ return structuredClone([...N].sort(e));
1184
1338
  },
1185
1339
  async createRequiredCheck(e) {
1186
- let t = ye(e);
1187
- if (F.some((e) => e.name === t.name)) throw new g(t.name);
1188
- let n = {
1340
+ let t = Se(e);
1341
+ if (N.some((e) => e.name === t.name)) throw new n(t.name);
1342
+ let r = {
1189
1343
  id: `rc_stub_${H++}`,
1190
1344
  ...t
1191
1345
  };
1192
- return F.push(n), structuredClone(n);
1346
+ return N.push(r), structuredClone(r);
1193
1347
  },
1194
1348
  async updateRequiredCheck({ id: e, ...t }) {
1195
- let n = ye(t), r = F.find((t) => t.id === e);
1196
- if (!r) throw k("Required Check", e);
1197
- if (F.some((t) => t.name === n.name && t.id !== e)) throw new g(n.name);
1198
- return Object.assign(r, n), structuredClone(r);
1349
+ let r = Se(t), i = N.find((t) => t.id === e);
1350
+ if (!i) throw k("Required Check", e);
1351
+ if (N.some((t) => t.name === r.name && t.id !== e)) throw new n(r.name);
1352
+ return Object.assign(i, r), structuredClone(i);
1199
1353
  },
1200
1354
  async deleteRequiredCheck({ id: e }) {
1201
- if (!F.some((t) => t.id === e)) throw k("Required Check", e);
1202
- F = F.filter((t) => t.id !== e), z.delete(e);
1355
+ if (!N.some((t) => t.id === e)) throw k("Required Check", e);
1356
+ N = N.filter((t) => t.id !== e), L.delete(e);
1203
1357
  },
1204
1358
  async listRequiredCheckRecorders(e) {
1205
- return structuredClone(He(e));
1359
+ return structuredClone(Xe(e));
1206
1360
  },
1207
1361
  async grantRequiredCheckRecorder({ requiredCheckId: e, recorder: t }) {
1208
- let n = He(e);
1362
+ let n = Xe(e);
1209
1363
  if ("everyMember" in t) {
1210
- z.set(e, {
1364
+ L.set(e, {
1211
1365
  ...n,
1212
1366
  everyMember: !0
1213
1367
  });
1214
1368
  return;
1215
1369
  }
1216
- if (!Te.includes(t.userId)) throw new a(`user ${t.userId} is not a member of the workspace`);
1217
- z.set(e, {
1370
+ if (!ke.includes(t.userId)) throw new _(`user ${t.userId} is not a member of the workspace`);
1371
+ L.set(e, {
1218
1372
  ...n,
1219
1373
  userIds: [.../* @__PURE__ */ new Set([...n.userIds, t.userId])].sort()
1220
1374
  });
1221
1375
  },
1222
1376
  async revokeRequiredCheckRecorder({ requiredCheckId: e, recorder: t }) {
1223
- let n = He(e);
1224
- z.set(e, "everyMember" in t ? {
1377
+ let n = Xe(e);
1378
+ L.set(e, "everyMember" in t ? {
1225
1379
  ...n,
1226
1380
  everyMember: !1
1227
1381
  } : {
@@ -1232,7 +1386,7 @@ function M(v = {}) {
1232
1386
  async searchBlueprints({ query: e }) {
1233
1387
  let t = e.trim().toLocaleLowerCase();
1234
1388
  return {
1235
- blueprints: he.filter((e) => !e.archived).filter((e) => e.name.toLocaleLowerCase().includes(t)).filter((e) => M.some((t) => t.blueprintId === e.id)).map((e) => ({
1389
+ blueprints: _e.filter((e) => !e.archived).filter((e) => e.name.toLocaleLowerCase().includes(t)).filter((e) => D.some((t) => t.blueprintId === e.id)).map((e) => ({
1236
1390
  id: e.id,
1237
1391
  name: e.name
1238
1392
  })),
@@ -1240,14 +1394,14 @@ function M(v = {}) {
1240
1394
  };
1241
1395
  },
1242
1396
  async getBlueprints(e) {
1243
- if (e.length > 1e3) throw new a(`at most ${t} Blueprint ids`);
1244
- return he.filter((t) => e.includes(t.id)).map((e) => ({
1397
+ if (e.length > 1e3) throw new _(`at most ${c} Blueprint ids`);
1398
+ return _e.filter((t) => e.includes(t.id)).map((e) => ({
1245
1399
  id: e.id,
1246
1400
  name: e.name
1247
1401
  }));
1248
1402
  },
1249
1403
  async listBlueprintReleases(e) {
1250
- return M.filter((t) => t.blueprintId === e).map((e) => ({
1404
+ return D.filter((t) => t.blueprintId === e).map((e) => ({
1251
1405
  id: e.id,
1252
1406
  blueprintId: e.blueprintId,
1253
1407
  name: e.name ?? e.id,
@@ -1256,94 +1410,94 @@ function M(v = {}) {
1256
1410
  }));
1257
1411
  },
1258
1412
  async listCollections() {
1259
- return [...T].sort(ze).map((e) => ({ ...e }));
1413
+ return [...T].sort(qe).map((e) => ({ ...e }));
1260
1414
  },
1261
1415
  async createCollection({ name: e, parentId: t = "", restricted: r = !1 }) {
1262
1416
  let i = O(e, "a Collection's name", 200);
1263
- if (t !== "" && Y(t), r && I === "workspace") throw new n(Se);
1264
- if (Be(t, i)) throw new g(i);
1417
+ if (t !== "" && Y(t), r && P === "workspace") throw new m(Te);
1418
+ if (Je(t, i)) throw new n(i);
1265
1419
  let a = {
1266
1420
  id: `col_stub_${H++}`,
1267
1421
  name: i,
1268
1422
  parentId: t,
1269
1423
  restricted: r
1270
1424
  };
1271
- return T.push(a), r && R.set(a.id, [{
1425
+ return T.push(a), r && I.set(a.id, [{
1272
1426
  userId: b,
1273
1427
  level: "owner"
1274
1428
  }]), { ...a };
1275
1429
  },
1276
1430
  async renameCollection({ id: e, name: t }) {
1277
- let n = O(t, "a Collection's name", 200), r = Y(e);
1278
- if (Be(r.parentId, n, e)) throw new g(n);
1279
- return r.name = n, { ...r };
1431
+ let r = O(t, "a Collection's name", 200), i = Y(e);
1432
+ if (Je(i.parentId, r, e)) throw new n(r);
1433
+ return i.name = r, { ...i };
1280
1434
  },
1281
1435
  async moveCollection({ id: e, parentId: t }) {
1282
- let n = Y(e);
1283
- for (let n = t; n !== ""; n = Y(n).parentId) if (n === e) throw new a(`Collection ${e} can't move under itself or a Collection under it`);
1284
- if (Be(t, n.name, e)) throw new g("");
1285
- return n.parentId = t, { ...n };
1436
+ let r = Y(e);
1437
+ for (let n = t; n !== ""; n = Y(n).parentId) if (n === e) throw new _(`Collection ${e} can't move under itself or a Collection under it`);
1438
+ if (Je(t, r.name, e)) throw new n("");
1439
+ return r.parentId = t, { ...r };
1286
1440
  },
1287
1441
  async removeCollection({ id: e }) {
1288
- if (Y(e), T.some((t) => t.parentId === e)) throw new a(`Collection ${e} has Collections under it: remove or move those first`);
1289
- T.splice(T.findIndex((t) => t.id === e), 1), R.delete(e);
1442
+ if (Y(e), T.some((t) => t.parentId === e)) throw new _(`Collection ${e} has Collections under it: remove or move those first`);
1443
+ T.splice(T.findIndex((t) => t.id === e), 1), I.delete(e);
1290
1444
  let t = [];
1291
- for (let n of D) n.collectionIds.includes(e) && (n.collectionIds = n.collectionIds.filter((t) => t !== e), t.push(n.id));
1445
+ for (let n of E) n.collectionIds.includes(e) && (n.collectionIds = n.collectionIds.filter((t) => t !== e), t.push(n.id));
1292
1446
  return t;
1293
1447
  },
1294
- async setCollectionRestricted({ id: e, restricted: t, acknowledgeDisclosure: r = !1 }) {
1295
- if (t && I === "workspace") throw new n(Se);
1296
- let i = Y(e);
1297
- if (i.restricted === t) return { ...i };
1298
- if (!t && !r) throw new a(`unrestricting Collection ${e} discloses its Content to every viewer: confirm it with acknowledge_disclosure`);
1299
- return i.restricted = t, t ? R.set(e, [{
1448
+ async setCollectionRestricted({ id: e, restricted: t, acknowledgeDisclosure: n = !1 }) {
1449
+ if (t && P === "workspace") throw new m(Te);
1450
+ let r = Y(e);
1451
+ if (r.restricted === t) return { ...r };
1452
+ if (!t && !n) throw new _(`unrestricting Collection ${e} discloses its Content to every viewer: confirm it with acknowledge_disclosure`);
1453
+ return r.restricted = t, t ? I.set(e, [{
1300
1454
  userId: b,
1301
1455
  level: "owner"
1302
- }]) : R.delete(e), { ...i };
1456
+ }]) : I.delete(e), { ...r };
1303
1457
  },
1304
1458
  async listCollectionGrants(e) {
1305
- return Ve(e), structuredClone(R.get(e) ?? []).sort((e, t) => e.userId < t.userId ? -1 : +(e.userId > t.userId));
1459
+ return Ye(e), structuredClone(I.get(e) ?? []).sort((e, t) => e.userId < t.userId ? -1 : +(e.userId > t.userId));
1306
1460
  },
1307
1461
  async grantCollectionAccess({ collectionId: e, userId: t, level: n }) {
1308
- if (Ve(e), n !== "viewer" && n !== "editor") throw new a("a grant is viewer or editor");
1309
- if (!Te.includes(t)) throw new a(`${t} is not a member of the workspace`);
1310
- let r = R.get(e) ?? [];
1311
- r.some((e) => e.level === "owner" && e.userId === t) || R.set(e, [...r.filter((e) => e.userId !== t), {
1462
+ if (Ye(e), n !== "viewer" && n !== "editor") throw new _("a grant is viewer or editor");
1463
+ if (!ke.includes(t)) throw new _(`${t} is not a member of the workspace`);
1464
+ let r = I.get(e) ?? [];
1465
+ r.some((e) => e.level === "owner" && e.userId === t) || I.set(e, [...r.filter((e) => e.userId !== t), {
1312
1466
  userId: t,
1313
1467
  level: n
1314
1468
  }]);
1315
1469
  },
1316
1470
  async revokeCollectionAccess({ collectionId: e, userId: t }) {
1317
- Ve(e), R.set(e, (R.get(e) ?? []).filter((e) => e.userId !== t || e.level === "owner"));
1471
+ Ye(e), I.set(e, (I.get(e) ?? []).filter((e) => e.userId !== t || e.level === "owner"));
1318
1472
  },
1319
1473
  async listContents(e = {}) {
1320
1474
  let t = e.view ?? { kind: "main" }, n = (e.search ?? "").trim();
1321
- if (n !== "" && t.kind === "in_force") throw new a("filter.search: Editor Search covers Main and open Branch heads, never Releases");
1322
- if ([...n].length > 200) throw new a("filter.search is at most 200 characters");
1475
+ if (n !== "" && t.kind === "in_force") throw new _("filter.search: Editor Search covers Main and open Branch heads, never Releases");
1476
+ if ([...n].length > 200) throw new _("filter.search is at most 200 characters");
1323
1477
  if (e.collectionId && !T.some((t) => t.id === e.collectionId)) throw k("Collection", e.collectionId);
1324
1478
  t.kind === "change_set" && X(t.changeSetId);
1325
- let r = D.filter((e) => !e.archiveTime).filter((t) => !e.collectionId || t.collectionIds.includes(e.collectionId)).filter((t) => !e.blueprintIds?.length || e.blueprintIds.includes(t.blueprintId)).filter((t) => !e.assigneeId || (t.assigneeIds ?? []).includes(e.assigneeId)).sort((e, t) => e.id < t.id ? -1 : +(e.id > t.id)).flatMap((e) => $(e, t, n)), i = Math.min(e.pageSize || 50, 200), o = e.pageToken ? Number(e.pageToken) : 0;
1479
+ let r = E.filter((e) => !e.archiveTime).filter((t) => !e.collectionId || t.collectionIds.includes(e.collectionId)).filter((t) => !e.blueprintIds?.length || e.blueprintIds.includes(t.blueprintId)).filter((t) => !e.assigneeId || (t.assigneeIds ?? []).includes(e.assigneeId)).sort((e, t) => e.id < t.id ? -1 : +(e.id > t.id)).flatMap((e) => ft(e, t, n)), i = Math.min(e.pageSize || 50, 200), a = e.pageToken ? Number(e.pageToken) : 0;
1326
1480
  return {
1327
- contents: r.slice(o, o + i),
1328
- nextPageToken: o + i < r.length ? String(o + i) : ""
1481
+ contents: r.slice(a, a + i),
1482
+ nextPageToken: a + i < r.length ? String(a + i) : ""
1329
1483
  };
1330
1484
  },
1331
1485
  async createContent({ changeSetId: e, blueprintReleaseId: t, copyFrom: n }) {
1332
1486
  let r = Z(e), i = {}, a = t;
1333
1487
  if (n) {
1334
- let e = "revisionId" in n ? n.revisionId : D.find((e) => e.inForce?.releaseId === n.releaseId)?.inForce?.revisionId, r = D.find((t) => e && q(t, e));
1488
+ let e = "revisionId" in n ? n.revisionId : E.find((e) => e.inForce?.releaseId === n.releaseId)?.inForce?.revisionId, r = E.find((t) => e && q(t, e));
1335
1489
  if (!r || !e) throw k("copy source", JSON.stringify(n));
1336
1490
  i = structuredClone(q(r, e) ?? {}), a = t || r.blueprintReleaseId;
1337
1491
  }
1338
- let o = M.find((e) => e.id === a);
1339
- if (!o) throw new _(`Blueprint Release ${a} can't be loaded`, [{
1492
+ let o = D.find((e) => e.id === a);
1493
+ if (!o) throw new se(`Blueprint Release ${a} can't be loaded`, [{
1340
1494
  source: "contenthub",
1341
1495
  code: "release_not_found",
1342
1496
  path: ""
1343
1497
  }]);
1344
- if (o.refusals?.length) throw new _(`Blueprint Release ${a} can't be loaded`, o.refusals.map((e) => ({ ...e })));
1498
+ if (o.refusals?.length) throw new se(`Blueprint Release ${a} can't be loaded`, o.refusals.map((e) => ({ ...e })));
1345
1499
  let s = H++, c = `content_stub_${s}`, l = `br_stub_${s}`, u = `rev_stub_${s}`;
1346
- return D.push({
1500
+ return E.push({
1347
1501
  id: c,
1348
1502
  blueprintId: o.blueprintId,
1349
1503
  blueprintReleaseId: a,
@@ -1377,29 +1531,43 @@ function M(v = {}) {
1377
1531
  };
1378
1532
  },
1379
1533
  async saveRevision({ idempotencyKey: e, ...t }) {
1380
- if (!e) return Ue(t);
1381
- let n = JSON.stringify(t), r = Ne.get(e);
1534
+ if (!e) return Ze(t);
1535
+ let n = JSON.stringify(t), r = Ve.get(e);
1382
1536
  if (r) {
1383
- if (r.asked !== n) throw new a(`idempotency key ${e} names another save`);
1537
+ if (r.asked !== n) throw new _(`idempotency key ${e} names another save`);
1384
1538
  return structuredClone(r.content);
1385
1539
  }
1386
- let i = await Ue(t);
1387
- return Ne.set(e, {
1540
+ let i = await Ze(t);
1541
+ return Ve.set(e, {
1388
1542
  asked: n,
1389
1543
  content: structuredClone(i)
1390
1544
  }), i;
1391
1545
  },
1392
- async getContent({ id: e, changeSetId: t }) {
1393
- let n = U(e), [r] = $(n, t ? {
1546
+ async getContent({ id: e, changeSetId: t, branchId: n }) {
1547
+ let r = U(e), i = t ? {
1394
1548
  kind: "change_set",
1395
1549
  changeSetId: t
1396
- } : { kind: "main" }, "");
1397
- if (!r) throw k("Content", e);
1398
- let i = P[n.blueprintReleaseId];
1550
+ } : { kind: "main" };
1551
+ if (n && !t) throw new _("branch_id names a Branch of a Change Set: give its change_set_id too");
1552
+ let [a] = ft(r, i, "");
1553
+ if (!a) throw k("Content", e);
1554
+ if (n && n !== a.branchId) {
1555
+ let i = w.find((e) => e.id === t)?.chains.find((t) => t.contentId === e)?.branches.find((e) => e.id === n);
1556
+ if (!i) throw k("Branch", n);
1557
+ let o = K(r).find((e) => e.id === i.headRevisionId), s = o?.data ?? (r.main?.revisionId === i.headRevisionId ? r.main.data : {});
1558
+ a = {
1559
+ ...a,
1560
+ revisionId: i.headRevisionId,
1561
+ data: structuredClone(s),
1562
+ branchId: n,
1563
+ revisionCreateTime: o?.createTime ?? a.revisionCreateTime
1564
+ };
1565
+ }
1566
+ let o = M[r.blueprintReleaseId];
1399
1567
  return {
1400
- content: r,
1401
- blueprintRelease: i ? structuredClone(i) : void 0,
1402
- attributes: W(n)
1568
+ content: a,
1569
+ blueprintRelease: o ? structuredClone(o) : void 0,
1570
+ attributes: W(r)
1403
1571
  };
1404
1572
  },
1405
1573
  async getTimeline(e) {
@@ -1416,7 +1584,7 @@ function M(v = {}) {
1416
1584
  if (!t.main) throw k("Content", e.contentId);
1417
1585
  r = K(t);
1418
1586
  } else {
1419
- let t = D.find((t) => K(t).some((t) => t.branchId === e.branchId));
1587
+ let t = E.find((t) => K(t).some((t) => t.branchId === e.branchId));
1420
1588
  if (!t) throw k("Branch", e.branchId);
1421
1589
  r = K(t).filter((t) => t.branchId === e.branchId);
1422
1590
  }
@@ -1427,36 +1595,36 @@ function M(v = {}) {
1427
1595
  };
1428
1596
  },
1429
1597
  async compare({ revisionId: e, base: t }) {
1430
- let n = D.find((t) => K(t).some((t) => t.id === e));
1598
+ let n = E.find((t) => K(t).some((t) => t.id === e));
1431
1599
  if (!n) throw k("Revision", e);
1432
- let r = K(n), i = r.find((t) => t.id === e), o;
1433
- if (t.kind === "revision") o = t.revisionId;
1600
+ let r = K(n), i = r.find((t) => t.id === e), a;
1601
+ if (t.kind === "revision") a = t.revisionId;
1434
1602
  else if (t.kind === "main_head") {
1435
- if (!n.main) throw new a("the Content is not published: it has no Main Branch");
1436
- o = n.main.revisionId;
1437
- } else o = r.find((e) => e.branchId === t.branchId)?.parentId ?? "";
1438
- let s = r.find((e) => e.id === o);
1439
- if (!s) throw k("Revision", o);
1440
- let c = q(n, i.id) ?? {}, l = q(n, s.id) ?? {}, u = [];
1441
- for (let e of [.../* @__PURE__ */ new Set([...Object.keys(c), ...Object.keys(l)])]) e in l ? e in c ? JSON.stringify(c[e]) !== JSON.stringify(l[e]) && u.push({
1603
+ if (!n.main) throw new _("the Content is not published: it has no Main Branch");
1604
+ a = n.main.revisionId;
1605
+ } else a = r.find((e) => e.branchId === t.branchId)?.parentId ?? "";
1606
+ let o = r.find((e) => e.id === a);
1607
+ if (!o) throw k("Revision", a);
1608
+ let s = q(n, i.id) ?? {}, c = q(n, o.id) ?? {}, l = [];
1609
+ for (let e of [.../* @__PURE__ */ new Set([...Object.keys(s), ...Object.keys(c)])]) e in c ? e in s ? JSON.stringify(s[e]) !== JSON.stringify(c[e]) && l.push({
1442
1610
  path: `/${e}`,
1443
1611
  kind: "changed",
1444
- before: l[e],
1445
- after: c[e]
1446
- }) : u.push({
1612
+ before: c[e],
1613
+ after: s[e]
1614
+ }) : l.push({
1447
1615
  path: `/${e}`,
1448
1616
  kind: "removed",
1449
- before: l[e]
1450
- }) : u.push({
1617
+ before: c[e]
1618
+ }) : l.push({
1451
1619
  path: `/${e}`,
1452
1620
  kind: "added",
1453
- after: c[e]
1621
+ after: s[e]
1454
1622
  });
1455
- let d = ({ data: e, ...t }) => t;
1623
+ let u = ({ data: e, ...t }) => t;
1456
1624
  return {
1457
- base: d(s),
1458
- revision: d(i),
1459
- changes: u
1625
+ base: u(o),
1626
+ revision: u(i),
1627
+ changes: l
1460
1628
  };
1461
1629
  },
1462
1630
  async listReferences({ contentId: e, revisionId: t }) {
@@ -1470,14 +1638,14 @@ function M(v = {}) {
1470
1638
  referrers: e.slice(i, i + t),
1471
1639
  nextPageToken: i + t < e.length ? String(i + t) : ""
1472
1640
  };
1473
- }, a = D.flatMap((t) => (t.edges ?? []).filter((n) => n.targetContentId === e && t.inForce?.revisionId === n.sourceRevisionId).map((e) => ({
1641
+ }, a = E.flatMap((t) => (t.edges ?? []).filter((n) => n.targetContentId === e && t.inForce?.revisionId === n.sourceRevisionId).map((e) => ({
1474
1642
  edge: { ...e },
1475
1643
  releaseId: t.inForce?.releaseId ?? "",
1476
1644
  changeSetId: "",
1477
1645
  branchId: ""
1478
1646
  })));
1479
1647
  if (!t) return i(a);
1480
- let o = D.flatMap((t) => Object.entries(t.branches).flatMap(([n, r]) => w.find((e) => e.id === n)?.state === "open" ? (t.edges ?? []).filter((t) => t.targetContentId === e && t.sourceRevisionId === r.revisionId).map((e) => ({
1648
+ let o = E.flatMap((t) => Object.entries(t.branches).flatMap(([n, r]) => w.find((e) => e.id === n)?.state === "open" ? (t.edges ?? []).filter((t) => t.targetContentId === e && t.sourceRevisionId === r.revisionId).map((e) => ({
1481
1649
  edge: { ...e },
1482
1650
  releaseId: "",
1483
1651
  changeSetId: n,
@@ -1489,14 +1657,14 @@ function M(v = {}) {
1489
1657
  let t;
1490
1658
  if ("revisionId" in e) t = e.revisionId;
1491
1659
  else {
1492
- for (let n of D) {
1660
+ for (let n of E) {
1493
1661
  let r = Object.values(n.branches).find((t) => t.branchId === e.branchId);
1494
1662
  r && (t = r.revisionId);
1495
1663
  }
1496
1664
  if (!t) throw k("Branch", e.branchId);
1497
1665
  }
1498
- return D.flatMap((e) => (e.edges ?? []).filter((e) => e.sourceRevisionId === t)).filter((e) => e.pinReleaseId !== "").flatMap((e) => {
1499
- let t = D.find((t) => t.id === e.targetContentId)?.inForce?.releaseId ?? "";
1666
+ return E.flatMap((e) => (e.edges ?? []).filter((e) => e.sourceRevisionId === t)).filter((e) => e.pinReleaseId !== "").flatMap((e) => {
1667
+ let t = E.find((t) => t.id === e.targetContentId)?.inForce?.releaseId ?? "";
1500
1668
  return t === e.pinReleaseId ? [] : [{
1501
1669
  edge: { ...e },
1502
1670
  supersededByReleaseId: t,
@@ -1506,20 +1674,20 @@ function M(v = {}) {
1506
1674
  },
1507
1675
  async setContentCollections({ contentId: e, collectionIds: t }) {
1508
1676
  let n = U(e), r = [...new Set(t)];
1509
- if (r.length > 100) throw new a("at most 100 Collections");
1677
+ if (r.length > 100) throw new _("at most 100 Collections");
1510
1678
  for (let e of r) if (!T.some((t) => t.id === e)) throw k("Collection", e);
1511
1679
  return n.collectionIds = r.sort(), [...n.collectionIds];
1512
1680
  },
1513
1681
  async setContentAssignees({ contentId: e, assigneeIds: t }) {
1514
1682
  let n = U(e);
1515
- if (new Set(t).size !== t.length) throw new a("each assignee is given once");
1516
- if (t.length > 50) throw new a("at most 50 assignees");
1683
+ if (new Set(t).size !== t.length) throw new _("each assignee is given once");
1684
+ if (t.length > 50) throw new _("at most 50 assignees");
1517
1685
  return n.assigneeIds = [...t], W(n);
1518
1686
  },
1519
1687
  async blockContent({ contentId: e, blockReasonId: t, allowedUserIds: n }) {
1520
1688
  let r = U(e);
1521
1689
  if (!C.some((e) => e.id === t)) throw k("Block Reason", t);
1522
- if (new Set(n).size !== n.length) throw new a("each allowed user is given once");
1690
+ if (new Set(n).size !== n.length) throw new _("each allowed user is given once");
1523
1691
  return r.block = {
1524
1692
  blockReasonId: t,
1525
1693
  allowedUserIds: [...n],
@@ -1534,25 +1702,96 @@ function M(v = {}) {
1534
1702
  async archiveContent(e) {
1535
1703
  let t = U(e);
1536
1704
  if (t.archiveTime) return W(t);
1537
- if (!t.main) throw new a(`Content ${e} is not published: discard its Change Set instead of archiving it`);
1538
- if (f(t.timeline ?? [], Pe())) throw new a(`Content ${e} has a Release In Force today or later: end its force first`);
1705
+ if (!t.main) throw new _(`Content ${e} is not published: discard its Change Set instead of archiving it`);
1706
+ if (ee(t.timeline ?? [], He())) throw new _(`Content ${e} has a Release In Force today or later: end its force first`);
1539
1707
  return t.archiveTime = y(), W(t);
1540
1708
  },
1541
1709
  async unarchiveContent(e) {
1542
1710
  let t = U(e);
1543
1711
  return t.archiveTime = void 0, W(t);
1544
1712
  },
1713
+ async openDirectEdit({ contentId: e, idempotencyKey: t }) {
1714
+ return V(t, ["openDirectEdit", e], async () => {
1715
+ let t = U(e), n = w.find((t) => t.kind === "direct_edit" && t.state === "open" && t.editorId === b && t.chains[0]?.contentId === e);
1716
+ if (n) {
1717
+ let [e] = ft(t, {
1718
+ kind: "change_set",
1719
+ changeSetId: n.id
1720
+ }, "");
1721
+ return {
1722
+ changeSet: A(n),
1723
+ content: e,
1724
+ reopened: !0
1725
+ };
1726
+ }
1727
+ if (t.main && G(t)) throw new oe("dated_content", `Content ${e} is Dated: change it in a Change Set`, e);
1728
+ let r = M[t.blueprintReleaseId]?.accessor || t.blueprintId, i = je(z.find((e) => e.blueprintAccessor === r)).editingMode;
1729
+ if (t.main && i === "change_sets") throw new s(e, r, i);
1730
+ let a = await $.startEditing({
1731
+ contentId: e,
1732
+ changeSetName: `Direct Edit of ${e}`
1733
+ }), o = X(a.changeSet.id);
1734
+ return o.kind = "direct_edit", o.editorId = b, {
1735
+ changeSet: A(o),
1736
+ content: a.content,
1737
+ reopened: !1
1738
+ };
1739
+ });
1740
+ },
1741
+ async publishDirectEdit({ id: e, expectedHeadId: t, idempotencyKey: n }) {
1742
+ return V(n, [
1743
+ "publishDirectEdit",
1744
+ e,
1745
+ t
1746
+ ], async () => {
1747
+ let n = X(e);
1748
+ if (n.kind !== "direct_edit") throw new oe("not_a_direct_edit", `Change Set ${e} is not a Direct Edit`);
1749
+ let r = n.chains[0], i = r?.branches[0];
1750
+ if (!r || !i) throw Error(`Direct Edit ${e} has no Branch`);
1751
+ n.state === "open" && !n.plannedReleases.some((e) => e.branchId === i.id) && await $.planRelease({
1752
+ changeSetId: e,
1753
+ branchId: i.id
1754
+ });
1755
+ let a = await $.publish({
1756
+ id: e,
1757
+ reviewedHeads: { [i.id]: t }
1758
+ }), o = U(r.contentId), s = o.branches[e], c = a.releases.find((e) => e.branchId === i.id);
1759
+ if (s && c && o.main?.revisionId !== s.revisionId) {
1760
+ let { branchId: e, ...t } = structuredClone(s);
1761
+ o.main = t, o.inForce = {
1762
+ ...structuredClone(t),
1763
+ releaseId: c.id
1764
+ }, o.timeline = [...o.timeline ?? [], {
1765
+ ordinal: (o.timeline?.length ?? 0) + 1,
1766
+ releaseId: c.id,
1767
+ kind: "revision",
1768
+ revisionId: s.revisionId,
1769
+ blueprintReleaseId: o.blueprintReleaseId,
1770
+ publishTime: a.publishTime,
1771
+ first: !1
1772
+ }];
1773
+ }
1774
+ return a;
1775
+ });
1776
+ },
1777
+ async discardDirectEdit({ id: e, idempotencyKey: t }) {
1778
+ return V(t, ["discardDirectEdit", e], async () => {
1779
+ if (X(e).kind !== "direct_edit") throw new oe("not_a_direct_edit", `Change Set ${e} is not a Direct Edit`);
1780
+ return $.discardChangeSet(e);
1781
+ });
1782
+ },
1545
1783
  async startEditing({ contentId: e, changeSetId: t, effectiveOn: n = "", changeSetName: r = "" }) {
1546
1784
  let i = U(e);
1547
- if (!i.main) throw new a(`Content ${e} is not published`);
1548
- if (J(i), G(i) && !h.test(n)) throw new a("effective_on is required for Dated Content, as YYYY-MM-DD");
1549
- if (!G(i) && n !== "") throw new a("effective_on is refused for undated Content");
1550
- let o;
1785
+ if (!i.main) throw new _(`Content ${e} is not published`);
1786
+ if (J(i), G(i) && !g.test(n)) throw new _("effective_on is required for Dated Content, as YYYY-MM-DD");
1787
+ if (!G(i) && n !== "") throw new _("effective_on is refused for undated Content");
1788
+ let a;
1551
1789
  if (t) {
1552
- if (o = Z(t), o.chains.some((t) => t.contentId === e)) throw new a(`Content ${e} already has a Chain in this Change Set`);
1790
+ if (a = Z(t), a.kind === "direct_edit") throw new oe("one_branch", `Change Set ${t} is a Direct Edit`);
1791
+ if (a.chains.some((t) => t.contentId === e)) throw new _(`Content ${e} already has a Chain in this Change Set`);
1553
1792
  } else {
1554
1793
  let t = Object.values(i.main.data).filter((e) => typeof e == "string").slice(0, 2).join(" ");
1555
- o = {
1794
+ a = {
1556
1795
  id: `cs_stub_${H++}`,
1557
1796
  name: r.trim() ? O(r, "change_set_name", 200) : t || e,
1558
1797
  state: "open",
@@ -1563,56 +1802,56 @@ function M(v = {}) {
1563
1802
  status: "",
1564
1803
  assigneeIds: [],
1565
1804
  plannedReleases: []
1566
- }, w.unshift(o);
1805
+ }, w.unshift(a);
1567
1806
  }
1568
- let s = H++, c = `br_stub_${s}`, l = {
1807
+ let o = H++, s = `br_stub_${o}`, c = {
1569
1808
  ...structuredClone(i.main),
1570
- branchId: c
1809
+ branchId: s
1571
1810
  };
1572
- i.branches[o.id] = l, o.chains.push({
1573
- id: `chain_stub_${s}`,
1811
+ i.branches[a.id] = c, a.chains.push({
1812
+ id: `chain_stub_${o}`,
1574
1813
  contentId: e,
1575
1814
  born: !1,
1576
1815
  branches: [{
1577
- id: c,
1816
+ id: s,
1578
1817
  position: 0,
1579
1818
  kind: "editorial",
1580
- headRevisionId: l.revisionId
1819
+ headRevisionId: c.revisionId
1581
1820
  }]
1582
1821
  });
1583
- let [u] = $(i, {
1822
+ let [l] = ft(i, {
1584
1823
  kind: "change_set",
1585
- changeSetId: o.id
1824
+ changeSetId: a.id
1586
1825
  }, "");
1587
1826
  return {
1588
- changeSet: A(o),
1589
- content: u
1827
+ changeSet: A(a),
1828
+ content: l
1590
1829
  };
1591
1830
  },
1592
1831
  async previewChain({ changeSetId: e, contentId: t, effectiveOn: n, validityPeriod: r }) {
1593
1832
  Z(e);
1594
1833
  let i = U(t);
1595
- if (!i.main) throw new a(`Content ${t} is not published`);
1596
- if (!G(i)) throw new a("undated Content's Chain takes no date");
1597
- if (!h.test(n)) throw new a("effective_on is YYYY-MM-DD");
1598
- let o = i.timeline ?? [], s = o.find((e) => e.validityPeriod && e.validityPeriod.firstDay <= n && (e.validityPeriod.lastDay === "" || n <= e.validityPeriod.lastDay));
1834
+ if (!i.main) throw new _(`Content ${t} is not published`);
1835
+ if (!G(i)) throw new _("undated Content's Chain takes no date");
1836
+ if (!g.test(n)) throw new _("effective_on is YYYY-MM-DD");
1837
+ let a = i.timeline ?? [], o = a.find((e) => e.validityPeriod && e.validityPeriod.firstDay <= n && (e.validityPeriod.lastDay === "" || n <= e.validityPeriod.lastDay));
1599
1838
  return {
1600
- forkReleaseId: s?.releaseId ?? "",
1601
- carryForwardReleaseIds: o.filter((e) => e.validityPeriod && e.validityPeriod.firstDay > n).map((e) => e.releaseId),
1839
+ forkReleaseId: o?.releaseId ?? "",
1840
+ carryForwardReleaseIds: a.filter((e) => e.validityPeriod && e.validityPeriod.firstDay > n).map((e) => e.releaseId),
1602
1841
  mergesMain: !1,
1603
- cutIntoReleaseIds: s ? [s.releaseId] : [],
1604
- coveredReleaseIds: r && r.lastDay !== "" ? o.filter((e) => e.validityPeriod && e.validityPeriod.lastDay !== "" && r.firstDay <= e.validityPeriod.firstDay && e.validityPeriod.lastDay <= r.lastDay).map((e) => e.releaseId) : []
1842
+ cutIntoReleaseIds: o ? [o.releaseId] : [],
1843
+ coveredReleaseIds: r && r.lastDay !== "" ? a.filter((e) => e.validityPeriod && e.validityPeriod.lastDay !== "" && r.firstDay <= e.validityPeriod.firstDay && e.validityPeriod.lastDay <= r.lastDay).map((e) => e.releaseId) : []
1605
1844
  };
1606
1845
  },
1607
1846
  async planRepeal({ changeSetId: e, contentId: t, lastDay: n }) {
1608
1847
  Z(e);
1609
1848
  let r = U(t);
1610
- if (J(r), !G(r)) throw new a("a Repeal is for Dated Content");
1611
- if (!h.test(n)) throw new a("last_day is YYYY-MM-DD");
1612
- return rt(r, e, {
1849
+ if (J(r), !G(r)) throw new _("a Repeal is for Dated Content");
1850
+ if (!g.test(n)) throw new _("last_day is YYYY-MM-DD");
1851
+ return dt(r, e, {
1613
1852
  kind: "repeal",
1614
1853
  validityPeriod: {
1615
- firstDay: ee(r.timeline ?? [], n)?.validityPeriod?.firstDay ?? n,
1854
+ firstDay: te(r.timeline ?? [], n)?.validityPeriod?.firstDay ?? n,
1616
1855
  lastDay: n
1617
1856
  }
1618
1857
  });
@@ -1620,71 +1859,71 @@ function M(v = {}) {
1620
1859
  async planWithdrawal({ changeSetId: e, contentId: t }) {
1621
1860
  Z(e);
1622
1861
  let n = U(t);
1623
- if (J(n), G(n)) throw new a("a Withdrawal is for undated Content");
1624
- return rt(n, e, { kind: "withdrawal" });
1862
+ if (J(n), G(n)) throw new _("a Withdrawal is for undated Content");
1863
+ return dt(n, e, { kind: "withdrawal" });
1625
1864
  },
1626
1865
  async planRelease({ idempotencyKey: e, ...t }) {
1627
1866
  return V(e, ["planRelease", t], async () => {
1628
- let { changeSetId: e, branchId: n, validityPeriod: r, releaseSpec: i, supersedesReleaseIds: o } = t, { cs: s, chain: c, branch: l, c: u } = Ge(e, n);
1629
- if (J(u), l.kind !== "editorial") throw new a("only an editorial Branch's head is released");
1630
- if (s.plannedReleases.some((e) => e.branchId === n)) throw new a(`Branch ${n} is planned already`);
1631
- let d = {
1867
+ let { changeSetId: e, branchId: n, validityPeriod: r, releaseSpec: i, supersedesReleaseIds: a } = t, { cs: o, chain: s, branch: c, c: l } = $e(e, n);
1868
+ if (J(l), c.kind !== "editorial") throw new _("only an editorial Branch's head is released");
1869
+ if (o.plannedReleases.some((e) => e.branchId === n)) throw new _(`Branch ${n} is planned already`);
1870
+ let u = {
1632
1871
  id: `rls_stub_${H++}`,
1633
- contentId: c.contentId,
1872
+ contentId: s.contentId,
1634
1873
  kind: "revision",
1635
1874
  branchId: n,
1636
1875
  revisionId: "",
1637
1876
  validityPeriod: r ? { ...r } : void 0,
1638
1877
  releaseSpec: structuredClone(i ?? {}),
1639
- supersedesReleaseIds: [...o ?? []],
1878
+ supersedesReleaseIds: [...a ?? []],
1640
1879
  proposed: !1,
1641
1880
  proposedForReleaseId: "",
1642
1881
  splitFromReleaseId: "",
1643
1882
  withheld: !1
1644
1883
  };
1645
- return Je(u, d), s.plannedReleases.push(d), Ye(s, u), structuredClone(d);
1884
+ return nt(l, u), o.plannedReleases.push(u), rt(o, l), structuredClone(u);
1646
1885
  });
1647
1886
  },
1648
1887
  async updatePlannedRelease({ idempotencyKey: e, ...t }) {
1649
1888
  return V(e, ["updatePlannedRelease", t], async () => {
1650
- let { changeSetId: e, plannedReleaseId: n, validityPeriod: r, releaseSpec: i, supersedesReleaseIds: o } = t, s = Z(e), c = s.plannedReleases.findIndex((e) => e.id === n);
1651
- if (c < 0) throw k("Planned Release", n);
1652
- let l = s.plannedReleases[c];
1653
- if (l.proposed) throw new a("a proposal is derived from the plans and can't be set");
1654
- let u = U(l.contentId);
1655
- J(u);
1656
- let d = {
1657
- ...structuredClone(l),
1889
+ let { changeSetId: e, plannedReleaseId: n, validityPeriod: r, releaseSpec: i, supersedesReleaseIds: a } = t, o = Z(e), s = o.plannedReleases.findIndex((e) => e.id === n);
1890
+ if (s < 0) throw k("Planned Release", n);
1891
+ let c = o.plannedReleases[s];
1892
+ if (c.proposed) throw new _("a proposal is derived from the plans and can't be set");
1893
+ let l = U(c.contentId);
1894
+ J(l);
1895
+ let u = {
1896
+ ...structuredClone(c),
1658
1897
  ...r ? { validityPeriod: { ...r } } : {},
1659
1898
  ...i ? { releaseSpec: structuredClone(i) } : {},
1660
- ...o ? { supersedesReleaseIds: [...o] } : {}
1899
+ ...a ? { supersedesReleaseIds: [...a] } : {}
1661
1900
  };
1662
- return Je(u, d), s.plannedReleases[c] = d, Ye(s, u), structuredClone(d);
1901
+ return nt(l, u), o.plannedReleases[s] = u, rt(o, l), structuredClone(u);
1663
1902
  });
1664
1903
  },
1665
1904
  async appendBranch({ idempotencyKey: e, ...t }) {
1666
1905
  return V(e, ["appendBranch", t], async () => {
1667
- let { changeSetId: e, chainId: n, effectiveOn: r } = t, i = Z(e), o = i.chains.find((e) => e.id === n);
1668
- if (!o) throw k("Chain", n);
1669
- let s = U(o.contentId);
1670
- if (o.born || !G(s)) throw new a("only a Chain on published Dated Content takes dates");
1671
- let c = o.branches.filter((e) => e.kind === "editorial").at(-1);
1672
- if (!h.test(r) || c?.effectiveOn && r <= c.effectiveOn) throw new a("effective_on is a day after the Chain's last editorial Branch's");
1673
- let l = o.branches.at(-1), u = `br_stub_${H++}`;
1674
- o.branches.push({
1675
- id: u,
1676
- position: o.branches.length,
1906
+ let { changeSetId: e, chainId: n, effectiveOn: r } = t, i = Z(e), a = i.chains.find((e) => e.id === n);
1907
+ if (!a) throw k("Chain", n);
1908
+ let o = U(a.contentId);
1909
+ if (a.born || !G(o)) throw new _("only a Chain on published Dated Content takes dates");
1910
+ let s = a.branches.filter((e) => e.kind === "editorial").at(-1);
1911
+ if (!g.test(r) || s?.effectiveOn && r <= s.effectiveOn) throw new _("effective_on is a day after the Chain's last editorial Branch's");
1912
+ let c = a.branches.at(-1), l = `br_stub_${H++}`;
1913
+ a.branches.push({
1914
+ id: l,
1915
+ position: a.branches.length,
1677
1916
  kind: "editorial",
1678
- headRevisionId: l?.headRevisionId ?? "",
1917
+ headRevisionId: c?.headRevisionId ?? "",
1679
1918
  effectiveOn: r
1680
1919
  });
1681
- let d = s.branches[e];
1682
- return d && (s.branches[e] = {
1683
- ...d,
1684
- branchId: u
1920
+ let u = o.branches[e];
1921
+ return u && (o.branches[e] = {
1922
+ ...u,
1923
+ branchId: l
1685
1924
  }), {
1686
1925
  changeSet: A(i),
1687
- branchId: u
1926
+ branchId: l
1688
1927
  };
1689
1928
  });
1690
1929
  },
@@ -1692,8 +1931,8 @@ function M(v = {}) {
1692
1931
  return V(e, ["dropChain", t], async () => {
1693
1932
  let { changeSetId: e, chainId: n } = t, r = Z(e), i = r.chains.find((e) => e.id === n);
1694
1933
  if (!i) throw k("Chain", n);
1695
- if (i.born) throw new a("the Chain of Content born in the Change Set can't be dropped: discard the Change Set");
1696
- for (let e of i.branches) qe(e.id);
1934
+ if (i.born) throw new _("the Chain of Content born in the Change Set can't be dropped: discard the Change Set");
1935
+ for (let e of i.branches) tt(e.id);
1697
1936
  return r.chains = r.chains.filter((e) => e.id !== n), r.plannedReleases = r.plannedReleases.filter((e) => e.contentId !== i.contentId), delete U(i.contentId).branches[e], A(r);
1698
1937
  });
1699
1938
  },
@@ -1701,43 +1940,43 @@ function M(v = {}) {
1701
1940
  let t = B.get(e);
1702
1941
  return t ? structuredClone(t) : null;
1703
1942
  },
1704
- async resolveMerge({ idempotencyKey: t, ...n }) {
1705
- return V(t, ["resolveMerge", n], async () => {
1706
- let { changeSetId: t, branchId: r, expectedHeadId: i, resolutions: o } = n, { chain: s, branch: c, c: l } = Ge(t, r), u = B.get(r);
1707
- if (!u) throw new a(`Branch ${r} has no Pending Merge`);
1708
- if (c.headRevisionId !== i) throw new e({
1709
- contentId: l.id,
1710
- branchId: r,
1711
- expectedHeadId: i,
1712
- currentHeadId: c.headRevisionId
1943
+ async resolveMerge({ idempotencyKey: e, ...t }) {
1944
+ return V(e, ["resolveMerge", t], async () => {
1945
+ let { changeSetId: e, branchId: n, expectedHeadId: r, resolutions: a } = t, { chain: o, branch: s, c } = $e(e, n), l = B.get(n);
1946
+ if (!l) throw new _(`Branch ${n} has no Pending Merge`);
1947
+ if (s.headRevisionId !== r) throw new i({
1948
+ contentId: c.id,
1949
+ branchId: n,
1950
+ expectedHeadId: r,
1951
+ currentHeadId: s.headRevisionId
1713
1952
  });
1714
- let d = o.map((e) => e.path), f = u.fields.map((e) => e.path);
1715
- if (new Set(d).size !== d.length || d.some((e) => !f.includes(e)) || f.some((e) => !d.includes(e))) throw new a("decide every field the Pending Merge lists, once");
1716
- let p = structuredClone(u.merged);
1717
- for (let e of o) {
1718
- let t = u.fields.find((t) => t.path === e.path), n = "side" in e ? e.side === "ours" ? t.ours : t.theirs : e.value, r = e.path.replace(/^\//, "");
1719
- n === void 0 ? delete p[r] : p[r] = structuredClone(n);
1953
+ let u = a.map((e) => e.path), d = l.fields.map((e) => e.path);
1954
+ if (new Set(u).size !== u.length || u.some((e) => !d.includes(e)) || d.some((e) => !u.includes(e))) throw new _("decide every field the Pending Merge lists, once");
1955
+ let f = structuredClone(l.merged);
1956
+ for (let e of a) {
1957
+ let t = l.fields.find((t) => t.path === e.path), n = "side" in e ? e.side === "ours" ? t.ours : t.theirs : e.value, r = e.path.replace(/^\//, "");
1958
+ n === void 0 ? delete f[r] : f[r] = structuredClone(n);
1720
1959
  }
1721
- let m = We({
1722
- changeSetId: t,
1723
- chain: s,
1724
- branch: c,
1725
- c: l,
1726
- data: p,
1960
+ let p = Qe({
1961
+ changeSetId: e,
1962
+ chain: o,
1963
+ branch: s,
1964
+ c,
1965
+ data: f,
1727
1966
  cause: "resolve",
1728
- secondParentId: u.theirsRevisionId
1967
+ secondParentId: l.theirsRevisionId
1729
1968
  });
1730
- return qe(r), m;
1969
+ return tt(n), p;
1731
1970
  });
1732
1971
  },
1733
1972
  async abortMerge({ idempotencyKey: e, ...t }) {
1734
1973
  return V(e, ["abortMerge", t], async () => {
1735
- if (Ge(t.changeSetId, t.branchId), !B.has(t.branchId)) throw new a(`Branch ${t.branchId} has no Pending Merge`);
1736
- qe(t.branchId);
1974
+ if ($e(t.changeSetId, t.branchId), !B.has(t.branchId)) throw new _(`Branch ${t.branchId} has no Pending Merge`);
1975
+ tt(t.branchId);
1737
1976
  });
1738
1977
  },
1739
1978
  async previewInForce({ contentId: e, changeSetId: t, validOn: n }) {
1740
- let r = Z(t), i = U(e), a = n || Pe(), o = r.chains.find((t) => t.contentId === e), s = (e) => !e.validityPeriod || e.validityPeriod.firstDay <= a && (e.validityPeriod.lastDay === "" || a <= e.validityPeriod.lastDay), c = r.plannedReleases.find((t) => t.contentId === e && t.kind !== "repeal" && s(t));
1979
+ let r = Z(t), i = U(e), a = n || He(), o = r.chains.find((t) => t.contentId === e), s = (e) => !e.validityPeriod || e.validityPeriod.firstDay <= a && (e.validityPeriod.lastDay === "" || a <= e.validityPeriod.lastDay), c = r.plannedReleases.find((t) => t.contentId === e && t.kind !== "repeal" && s(t));
1741
1980
  if (c) {
1742
1981
  let e = c.branchId ? o?.branches.find((e) => e.id === c.branchId)?.headRevisionId ?? "" : c.revisionId;
1743
1982
  return {
@@ -1749,7 +1988,7 @@ function M(v = {}) {
1749
1988
  data: structuredClone(q(i, e) ?? {})
1750
1989
  };
1751
1990
  }
1752
- let l = ee(i.timeline ?? [], a);
1991
+ let l = te(i.timeline ?? [], a);
1753
1992
  return l ? {
1754
1993
  releaseId: l.releaseId,
1755
1994
  revisionId: l.revisionId,
@@ -1760,7 +1999,8 @@ function M(v = {}) {
1760
1999
  } : null;
1761
2000
  }
1762
2001
  };
1763
- function rt(e, t, n) {
2002
+ return $;
2003
+ function dt(e, t, n) {
1764
2004
  let r = {
1765
2005
  id: `rls_stub_${H++}`,
1766
2006
  contentId: e.id,
@@ -1778,10 +2018,10 @@ function M(v = {}) {
1778
2018
  plannedRelease: r
1779
2019
  }], structuredClone({
1780
2020
  plannedRelease: r,
1781
- gapReferrers: Ie(e.id)
2021
+ gapReferrers: We(e.id)
1782
2022
  });
1783
2023
  }
1784
- function $(e, t, n) {
2024
+ function ft(e, t, n) {
1785
2025
  let r = (t, n) => ({
1786
2026
  id: e.id,
1787
2027
  blueprintId: e.blueprintId,
@@ -1796,33 +2036,33 @@ function M(v = {}) {
1796
2036
  if (t.kind === "in_force") return e.inForce ? [r(e.inForce, { releaseId: e.inForce.releaseId })] : [];
1797
2037
  if (t.kind === "change_set") {
1798
2038
  let i = e.branches[t.changeSetId];
1799
- return !i || n && !N(i.data, n) ? [] : [r(i, {
2039
+ return !i || n && !Ee(i.data, n) ? [] : [r(i, {
1800
2040
  changeSetId: t.changeSetId,
1801
2041
  branchId: i.branchId
1802
2042
  })];
1803
2043
  }
1804
2044
  if (!n) return e.main ? [r(e.main, {})] : [];
1805
2045
  let i = [];
1806
- e.main && N(e.main.data, n) && i.push(r(e.main, {}));
1807
- for (let [t, a] of Object.entries(e.branches).sort(([, e], [, t]) => e.branchId < t.branchId ? -1 : 1)) w.find((e) => e.id === t)?.state === "open" && N(a.data, n) && i.push(r(a, {
2046
+ e.main && Ee(e.main.data, n) && i.push(r(e.main, {}));
2047
+ for (let [t, a] of Object.entries(e.branches).sort(([, e], [, t]) => e.branchId < t.branchId ? -1 : 1)) w.find((e) => e.id === t)?.state === "open" && Ee(a.data, n) && i.push(r(a, {
1808
2048
  changeSetId: t,
1809
2049
  branchId: a.branchId
1810
2050
  }));
1811
2051
  return i;
1812
2052
  }
1813
2053
  }
1814
- function N(e, t) {
2054
+ function Ee(e, t) {
1815
2055
  let n = (e) => e.toLocaleLowerCase().replace(/\s+/g, " "), r = n(t);
1816
2056
  return Object.values(e).some((e) => typeof e == "string" && n(e).includes(r));
1817
2057
  }
1818
2058
  //#endregion
1819
2059
  //#region src/testing/stub-status-source.ts
1820
- function P(e = E()) {
2060
+ function N(e = le()) {
1821
2061
  return { async listChangeSetStatuses() {
1822
2062
  return e.map((e) => ({ ...e }));
1823
2063
  } };
1824
2064
  }
1825
2065
  //#endregion
1826
- export { w as STUB_NOW, C as STUB_OTHER_USER_ID, S as STUB_USER_ID, x as STUB_WORKSPACE_ID, he as createStubBlueprintSource, M as createStubContenthubClient, P as createStubStatusSource, oe as stubBlockReasons, j as stubBlocker, fe as stubBlueprintReleases, de as stubBlueprints, E as stubChangeSetStatuses, ce as stubChangeSets, ue as stubCollections, me as stubContents, T as stubIdentity, D as stubRepealedContent, le as stubRequiredChecks, pe as stubResolvedReleases, se as stubStatusTransitions };
2066
+ export { w as STUB_NOW, C as STUB_OTHER_USER_ID, S as STUB_USER_ID, x as STUB_WORKSPACE_ID, D as createStubBlueprintSource, M as createStubContenthubClient, N as createStubStatusSource, ce as stubBlockReasons, j as stubBlocker, he as stubBlueprintReleases, me as stubBlueprints, le as stubChangeSetStatuses, de as stubChangeSets, pe as stubCollections, ve as stubContents, T as stubIdentity, _e as stubRepealedContent, fe as stubRequiredChecks, ge as stubResolvedReleases, ue as stubStatusTransitions, E as stubUndatedContent };
1827
2067
 
1828
2068
  //# sourceMappingURL=testing.js.map