@forgeroute/ui 0.4.81 → 0.4.82

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.
@@ -5,6 +5,7 @@ import { Subject, defer, firstValueFrom, from, of, throwError, timer } from "rxj
5
5
  import { ConfirmService, SidePanelComponent, ToastService, UiLabelsService, uiText } from "@forgeroute/ui";
6
6
  import { HttpClient, HttpContextToken, HttpErrorResponse, HttpHeaders, HttpParams, HttpResponse } from "@angular/common/http";
7
7
  import { catchError, finalize, retry, switchMap, tap, timeout } from "rxjs/operators";
8
+ const IDEMPOTENCY_IN_PROGRESS_CODE = "IDEMPOTENCY_IN_PROGRESS";
8
9
  const OFFLINE_SUPPORT_CONFIG = new InjectionToken("OFFLINE_SUPPORT_CONFIG");
9
10
  const OFFLINE_REPLAY_HEADER = "X-Offline-Replay";
10
11
  const IDEMPOTENCY_HEADER = "Idempotency-Key";
@@ -65,9 +66,43 @@ function resolveConfig(cfg) {
65
66
  cacheTtl: cfg.cacheTtl ?? null,
66
67
  maxQueue: positive(cfg.maxQueue, 500),
67
68
  maxAttempts: positive(cfg.maxAttempts, 5),
68
- createdId: cfg.createdId ? safeCreatedId(cfg.createdId) : defaultCreatedId
69
+ createdId: cfg.createdId ? safeCreatedId(cfg.createdId) : defaultCreatedId,
70
+ conflictStampFields: Array.isArray(cfg.conflictStampFields) ? [...new Set(cfg.conflictStampFields.filter((f) => typeof f === "string" && f.trim() !== ""))] : [],
71
+ idempotencyInProgressCode: typeof cfg.idempotencyInProgressCode === "string" && cfg.idempotencyInProgressCode.trim() !== "" ? cfg.idempotencyInProgressCode.trim() : IDEMPOTENCY_IN_PROGRESS_CODE
69
72
  };
70
73
  }
74
+ function isPlainObject(v) {
75
+ if (v === null || typeof v !== "object" || Array.isArray(v)) return false;
76
+ const proto = Object.getPrototypeOf(v);
77
+ return proto === Object.prototype || proto === null;
78
+ }
79
+ function jsonObjectBody(body) {
80
+ if (isPlainObject(body)) return {
81
+ obj: body,
82
+ wasString: false
83
+ };
84
+ if (typeof body === "string") try {
85
+ const parsed = JSON.parse(body);
86
+ return isPlainObject(parsed) ? {
87
+ obj: parsed,
88
+ wasString: true
89
+ } : null;
90
+ } catch {
91
+ return null;
92
+ }
93
+ return null;
94
+ }
95
+ function hasStampField(body, fields) {
96
+ const j = jsonObjectBody(body);
97
+ return !!j && fields.some((f) => Object.prototype.hasOwnProperty.call(j.obj, f));
98
+ }
99
+ function stripStampFields(body, fields) {
100
+ const j = jsonObjectBody(body);
101
+ if (!j || !fields.some((f) => Object.prototype.hasOwnProperty.call(j.obj, f))) return body;
102
+ const copy = {};
103
+ for (const k of Object.keys(j.obj)) if (!fields.includes(k)) copy[k] = j.obj[k];
104
+ return j.wasString ? JSON.stringify(copy) : copy;
105
+ }
71
106
  function pathAndQuery(url) {
72
107
  const m = /^[a-z][a-z0-9+.-]*:\/\/[^/?#]+(.*)$/i.exec(url);
73
108
  const noHash = (m ? m[1] : url).split("#")[0];
@@ -652,6 +687,56 @@ var OfflineStore = class OfflineStore {
652
687
  if (reset) this.mutated$.next();
653
688
  return reset;
654
689
  }
690
+ async resetForKeepMine(id, userId, fields, newKey) {
691
+ if (!await this.ensureReady()) return null;
692
+ const reset = await this.runTx([MUTATIONS], "readwrite", (s, resolveWith) => {
693
+ resolveWith(null);
694
+ const req = s[MUTATIONS].get(id);
695
+ req.onsuccess = () => {
696
+ const row = req.result;
697
+ if (!row || row.userId !== userId || row.status !== "conflict" || !hasStampField(row.body, fields)) return;
698
+ const next = {
699
+ ...row,
700
+ body: stripStampFields(row.body, fields),
701
+ key: newKey,
702
+ status: "pending",
703
+ attempts: 0,
704
+ overwrite: true
705
+ };
706
+ delete next.nextAttemptAt;
707
+ delete next.lastError;
708
+ delete next.claimOwner;
709
+ delete next.claimAt;
710
+ s[MUTATIONS].put(next);
711
+ resolveWith(next);
712
+ };
713
+ });
714
+ if (reset) this.mutated$.next();
715
+ return reset;
716
+ }
717
+ async stripStampsAfter(userId, entityType, entityId, afterSeq, fields) {
718
+ if (!await this.ensureReady()) return 0;
719
+ const changed = await this.runTx([MUTATIONS], "readwrite", (s, resolveWith) => {
720
+ resolveWith(0);
721
+ const all = s[MUTATIONS].index("userId").getAll(userId);
722
+ all.onsuccess = () => {
723
+ let n = 0;
724
+ for (const r of all.result) {
725
+ if (r.userId !== userId || r.seq <= afterSeq || r.status !== "pending") continue;
726
+ if (r.entityType !== entityType || r.entityId !== entityId || !hasStampField(r.body, fields)) continue;
727
+ s[MUTATIONS].put({
728
+ ...r,
729
+ body: stripStampFields(r.body, fields),
730
+ overwrite: true
731
+ });
732
+ n++;
733
+ }
734
+ resolveWith(n);
735
+ };
736
+ });
737
+ if (changed > 0) this.mutated$.next();
738
+ return changed;
739
+ }
655
740
  async get(id) {
656
741
  if (!await this.ensureReady()) return null;
657
742
  return this.runTx([MUTATIONS], "readonly", (s, resolveWith) => {
@@ -1174,7 +1259,22 @@ const BACKOFF_CAP_MS = 3e5;
1174
1259
  function backoffMs(attempts) {
1175
1260
  return Math.min(BACKOFF_BASE_MS * 2 ** Math.max(0, attempts - 1), BACKOFF_CAP_MS);
1176
1261
  }
1177
- function classifyReplay(err) {
1262
+ function retryAfterMs(err) {
1263
+ const raw = err.headers?.get("Retry-After");
1264
+ if (raw === null || raw === void 0 || !/^\s*\d+\s*$/.test(raw)) return void 0;
1265
+ const seconds = Number(raw);
1266
+ return seconds >= 1 && seconds <= BACKOFF_CAP_MS / 1e3 ? seconds * 1e3 : void 0;
1267
+ }
1268
+ function isInProgress409(err, code) {
1269
+ let body = err.error;
1270
+ if (typeof body === "string") try {
1271
+ body = JSON.parse(body);
1272
+ } catch {
1273
+ return false;
1274
+ }
1275
+ return !!body && typeof body === "object" && body.code === code;
1276
+ }
1277
+ function classifyReplay(err, inProgressCode = IDEMPOTENCY_IN_PROGRESS_CODE) {
1178
1278
  if (isRequestTimeoutError(err)) return {
1179
1279
  action: "retry",
1180
1280
  kind: "timeout",
@@ -1196,10 +1296,23 @@ function classifyReplay(err) {
1196
1296
  action: "auth",
1197
1297
  status: s
1198
1298
  };
1199
- if (s === 409) return {
1200
- action: "conflict",
1201
- status: s
1202
- };
1299
+ if (s === 409) {
1300
+ if (!isInProgress409(err, inProgressCode)) return {
1301
+ action: "conflict",
1302
+ status: s
1303
+ };
1304
+ const wait = retryAfterMs(err);
1305
+ return wait === void 0 ? {
1306
+ action: "retry",
1307
+ kind: "server",
1308
+ status: s
1309
+ } : {
1310
+ action: "retry",
1311
+ kind: "server",
1312
+ status: s,
1313
+ retryAfterMs: wait
1314
+ };
1315
+ }
1203
1316
  if (s === 408 || s === 429) return {
1204
1317
  action: "retry",
1205
1318
  kind: "server",
@@ -1244,6 +1357,7 @@ var OfflineReplayer = class OfflineReplayer {
1244
1357
  this.authBlocked = this._authBlocked.asReadonly();
1245
1358
  this.lastResult = this._lastResult.asReadonly();
1246
1359
  this.runCompleted$ = new Subject();
1360
+ this.discardDrains = /* @__PURE__ */ new Set();
1247
1361
  }
1248
1362
  replayAll(trigger) {
1249
1363
  if (this.running) return this.running;
@@ -1257,6 +1371,41 @@ var OfflineReplayer = class OfflineReplayer {
1257
1371
  if (this.running) await this.running;
1258
1372
  return this.start(() => this.run("manual", id));
1259
1373
  }
1374
+ async keepMineOne(id) {
1375
+ await this.store.init();
1376
+ const userId = this.cfg.getUserId();
1377
+ const fields = this.cfg.conflictStampFields;
1378
+ if (!userId || fields.length === 0) return {
1379
+ applied: false,
1380
+ result: null,
1381
+ followUp: null,
1382
+ outcome: null
1383
+ };
1384
+ if (!await this.store.resetForKeepMine(id, userId, fields, generateUuid())) return {
1385
+ applied: false,
1386
+ result: null,
1387
+ followUp: null,
1388
+ outcome: null
1389
+ };
1390
+ if (this.running) await this.running;
1391
+ const result = await this.start(() => this.run("manual", id));
1392
+ const after = await this.store.get(id);
1393
+ let followUp = null;
1394
+ const delivered = !!result && result.synced > 0 && after === null;
1395
+ if (delivered) followUp = await this.replayAll("online");
1396
+ return {
1397
+ applied: true,
1398
+ result,
1399
+ followUp,
1400
+ outcome: this.keepMineOutcome(delivered, result, after)
1401
+ };
1402
+ }
1403
+ keepMineOutcome(delivered, result, after) {
1404
+ if (delivered) return "sent";
1405
+ if (!after) return "sent";
1406
+ if (!result) return "shortly";
1407
+ return after.status === "pending" || after.status === "syncing" ? "shortly" : "failed";
1408
+ }
1260
1409
  async discard(id) {
1261
1410
  await this.store.init();
1262
1411
  const userId = this.cfg.getUserId();
@@ -1265,6 +1414,22 @@ var OfflineReplayer = class OfflineReplayer {
1265
1414
  if (!row || row.userId !== userId) return;
1266
1415
  await this.store.delete(id);
1267
1416
  await this.refreshCounts();
1417
+ if ((row.status === "failed" || row.status === "conflict") && row.entityType && row.entityId) try {
1418
+ if ((await this.store.list(userId)).some((r) => r.id !== id && r.status === "pending" && r.entityType === row.entityType && r.entityId === row.entityId)) {
1419
+ const drain = this.drainAfterDiscard().catch(() => {}).finally(() => {
1420
+ this.discardDrains.delete(drain);
1421
+ });
1422
+ this.discardDrains.add(drain);
1423
+ }
1424
+ } catch {}
1425
+ }
1426
+ async drainSettled() {
1427
+ while (this.discardDrains.size > 0) await Promise.all([...this.discardDrains]);
1428
+ }
1429
+ async drainAfterDiscard() {
1430
+ const inFlight = this.running;
1431
+ await this.replayAll("online");
1432
+ if (inFlight) await this.replayAll("online");
1268
1433
  }
1269
1434
  async discardAll() {
1270
1435
  await this.store.init();
@@ -1420,7 +1585,12 @@ var OfflineReplayer = class OfflineReplayer {
1420
1585
  attempted++;
1421
1586
  const outcome = dependency === "fail" ? { action: "dependency" } : await this.send(claimed, idMap);
1422
1587
  const stop = await this.apply(claimed, outcome, result, idMap);
1423
- if (outcome.action === "ok") changed = true;
1588
+ if (outcome.action === "ok") {
1589
+ changed = true;
1590
+ if (claimed.overwrite && claimed.entityType && claimed.entityId && this.cfg.conflictStampFields.length > 0) try {
1591
+ await this.store.stripStampsAfter(userId, claimed.entityType, claimed.entityId, claimed.seq, this.cfg.conflictStampFields);
1592
+ } catch {}
1593
+ }
1424
1594
  if (outcome.action !== "ok" && ek) blocked.add(ek);
1425
1595
  if (stop) break;
1426
1596
  }
@@ -1488,7 +1658,7 @@ var OfflineReplayer = class OfflineReplayer {
1488
1658
  text: typeof response.body === "string" ? response.body : void 0
1489
1659
  };
1490
1660
  } catch (err) {
1491
- return classifyReplay(err);
1661
+ return classifyReplay(err, this.cfg.idempotencyInProgressCode);
1492
1662
  }
1493
1663
  }
1494
1664
  async apply(row, outcome, result, idMap) {
@@ -1581,7 +1751,7 @@ var OfflineReplayer = class OfflineReplayer {
1581
1751
  status: "pending",
1582
1752
  ...release,
1583
1753
  attempts,
1584
- nextAttemptAt: Date.now() + backoffMs(attempts),
1754
+ nextAttemptAt: Date.now() + (outcome.retryAfterMs ?? backoffMs(attempts)),
1585
1755
  lastError
1586
1756
  }, owner);
1587
1757
  return outcome.kind !== "server";
@@ -1633,6 +1803,7 @@ i0.ɵɵngDeclareClassMetadata({
1633
1803
  }]
1634
1804
  });
1635
1805
  const REQUEST_TIMEOUT_MS = new HttpContextToken(() => null);
1806
+ const REQUEST_LONG = new HttpContextToken(() => false);
1636
1807
  const idempotencyInterceptor = (req, next) => {
1637
1808
  const raw = inject(OFFLINE_SUPPORT_CONFIG, { optional: true });
1638
1809
  if (!raw) return next(req);
@@ -1657,7 +1828,7 @@ const connectionInterceptor = (req, next) => {
1657
1828
  const labels = inject(UiLabelsService);
1658
1829
  const method = req.method.toUpperCase();
1659
1830
  const isRead = method === "GET" || method === "HEAD" || method === "OPTIONS";
1660
- const long = req.responseType === "blob" || req.responseType === "arraybuffer" || req.reportProgress || typeof FormData !== "undefined" && req.body instanceof FormData || matchesAny(req.url, cfg.longRequests);
1831
+ const long = req.responseType === "blob" || req.responseType === "arraybuffer" || req.reportProgress || typeof FormData !== "undefined" && req.body instanceof FormData || matchesAny(req.url, cfg.longRequests) || req.context.get(REQUEST_LONG) === true;
1661
1832
  const override = req.context.get(REQUEST_TIMEOUT_MS);
1662
1833
  const timeoutMs = override !== null && override !== void 0 ? override : long ? cfg.timeouts.long : isRead ? cfg.timeouts.read : cfg.timeouts.write;
1663
1834
  const outgoing = req.headers.has("X-Offline-Replay") ? req.clone({ headers: req.headers.delete(OFFLINE_REPLAY_HEADER) }) : req;
@@ -1715,6 +1886,14 @@ function createChannel(name) {
1715
1886
  return null;
1716
1887
  }
1717
1888
  }
1889
+ var KeepMineError = class KeepMineError extends Error {
1890
+ constructor(reason, message) {
1891
+ super(message);
1892
+ this.reason = reason;
1893
+ this.name = "KeepMineError";
1894
+ Object.setPrototypeOf(this, KeepMineError.prototype);
1895
+ }
1896
+ };
1718
1897
  var OfflineSupportService = class OfflineSupportService {
1719
1898
  constructor() {
1720
1899
  this.cfg = resolveConfig(inject(OFFLINE_SUPPORT_CONFIG, { optional: true }) ?? { getUserId: () => null });
@@ -1877,6 +2056,22 @@ var OfflineSupportService = class OfflineSupportService {
1877
2056
  await this.replayer.retryOne(id);
1878
2057
  await this.refresh();
1879
2058
  }
2059
+ canKeepMine(row) {
2060
+ return this.cfg.conflictStampFields.length > 0 && row.status === "conflict" && hasStampField(row.body, this.cfg.conflictStampFields);
2061
+ }
2062
+ async keepMine(id) {
2063
+ if (this.cfg.conflictStampFields.length === 0) throw new KeepMineError("disabled", this.labels.t("connection.conflict.error.disabled"));
2064
+ const userId = this.cfg.getUserId();
2065
+ await this.store.init();
2066
+ const row = userId ? await this.store.get(id) : null;
2067
+ if (!row || row.userId !== userId) throw new KeepMineError("notFound", this.labels.t("connection.conflict.error.notFound"));
2068
+ if (row.status !== "conflict") throw new KeepMineError("notConflict", this.labels.t("connection.conflict.error.notConflict"));
2069
+ if (!hasStampField(row.body, this.cfg.conflictStampFields)) throw new KeepMineError("noStamp", this.labels.t("connection.conflict.error.noStamp"));
2070
+ const { applied, outcome } = await this.replayer.keepMineOne(id);
2071
+ await this.refresh();
2072
+ if (!applied || !outcome) throw new KeepMineError("notConflict", this.labels.t("connection.conflict.error.notConflict"));
2073
+ return outcome;
2074
+ }
1880
2075
  async discard(id) {
1881
2076
  await this.replayer.discard(id);
1882
2077
  await this.refresh();
@@ -2564,6 +2759,7 @@ var PendingChangesDrawerComponent = class PendingChangesDrawerComponent {
2564
2759
  this.rows = computed(() => this.support.rows(), ...ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []);
2565
2760
  this.announcement = signal("", ...ngDevMode ? [{ debugName: "announcement" }] : /* istanbul ignore next */ []);
2566
2761
  this.now = signal(Date.now(), ...ngDevMode ? [{ debugName: "now" }] : /* istanbul ignore next */ []);
2762
+ this.busyIds = signal(/* @__PURE__ */ new Set(), ...ngDevMode ? [{ debugName: "busyIds" }] : /* istanbul ignore next */ []);
2567
2763
  const timer = setInterval(() => this.now.set(Date.now()), 3e4);
2568
2764
  inject(DestroyRef).onDestroy(() => clearInterval(timer));
2569
2765
  }
@@ -2576,7 +2772,8 @@ var PendingChangesDrawerComponent = class PendingChangesDrawerComponent {
2576
2772
  }
2577
2773
  }
2578
2774
  errorText(row) {
2579
- const kind = row.lastError?.kind ?? (row.status === "conflict" ? "conflict" : void 0);
2775
+ if (row.status === "conflict") return this.labels.t("connection.conflict.rowText");
2776
+ const kind = row.lastError?.kind;
2580
2777
  if (kind && kind in ERROR_KEYS) return this.labels.t(ERROR_KEYS[kind]);
2581
2778
  if (row.status === "failed" || row.lastError) return this.labels.t("connection.error.unknown");
2582
2779
  return "";
@@ -2584,6 +2781,12 @@ var PendingChangesDrawerComponent = class PendingChangesDrawerComponent {
2584
2781
  canRetry(row) {
2585
2782
  return row.status === "failed" || row.status === "conflict" || row.status === "pending" && !!row.lastError;
2586
2783
  }
2784
+ discardText(row) {
2785
+ return this.labels.t(row.status === "conflict" ? "connection.conflict.discard" : "connection.discard");
2786
+ }
2787
+ discardName(row) {
2788
+ return row.status === "conflict" ? this.labels.t("connection.conflict.discardNamed", { label: row.label }) : this.labels.t("connection.discardNamed", { label: row.label });
2789
+ }
2587
2790
  iso(row) {
2588
2791
  return new Date(row.createdAt).toISOString();
2589
2792
  }
@@ -2594,12 +2797,56 @@ var PendingChangesDrawerComponent = class PendingChangesDrawerComponent {
2594
2797
  const time = formatRelativeTime(row.createdAt, this.now(), this.labels.t("connection.time.justNow"), pageLocale(this.doc, this.labels.locale()));
2595
2798
  return this.labels.t("connection.savedAt", { time });
2596
2799
  }
2800
+ isBusy(row) {
2801
+ return this.busyIds().has(row.id);
2802
+ }
2803
+ setBusy(id, busy) {
2804
+ this.busyIds.update((set) => {
2805
+ const next = new Set(set);
2806
+ if (busy) next.add(id);
2807
+ else next.delete(id);
2808
+ return next;
2809
+ });
2810
+ }
2597
2811
  async retry(row) {
2598
- this.announcement.set(this.labels.t("connection.result.retrying", { label: row.label }));
2812
+ if (this.isBusy(row)) return;
2813
+ this.setBusy(row.id, true);
2599
2814
  try {
2600
- await this.support.retry(row.id);
2601
- } catch {
2602
- this.announceFailure();
2815
+ this.announcement.set(this.labels.t("connection.result.retrying", { label: row.label }));
2816
+ try {
2817
+ await this.support.retry(row.id);
2818
+ } catch {
2819
+ this.announceFailure();
2820
+ }
2821
+ } finally {
2822
+ this.setBusy(row.id, false);
2823
+ }
2824
+ }
2825
+ async keepMine(row) {
2826
+ if (this.isBusy(row)) return;
2827
+ this.setBusy(row.id, true);
2828
+ try {
2829
+ const index = this.rows().findIndex((r) => r.id === row.id);
2830
+ if (!await this.confirmService.confirm({
2831
+ title: this.labels.t("connection.conflict.confirmTitle"),
2832
+ message: this.labels.t("connection.conflict.confirmMessage"),
2833
+ confirmLabel: this.labels.t("connection.conflict.keepMine"),
2834
+ cancelLabel: this.labels.t("toolbar.cancel"),
2835
+ variant: "danger"
2836
+ })) return;
2837
+ this.announcement.set(this.labels.t("connection.conflict.result.keeping", { label: row.label }));
2838
+ let outcome;
2839
+ try {
2840
+ outcome = await this.support.keepMine(row.id);
2841
+ } catch (e) {
2842
+ this.announcement.set(e instanceof KeepMineError ? e.message : this.labels.t("connection.conflict.error.unknown"));
2843
+ return;
2844
+ }
2845
+ this.announcement.set(outcome === "sent" ? this.labels.t("connection.conflict.result.sent", { label: row.label }) : outcome === "shortly" ? this.labels.t("connection.conflict.result.shortly", { label: row.label }) : this.labels.t("connection.conflict.error.unknown"));
2846
+ this.cdr.detectChanges();
2847
+ if (!this.rows().some((r) => r.id === row.id)) this.focusAfterRemoval(index);
2848
+ } finally {
2849
+ this.setBusy(row.id, false);
2603
2850
  }
2604
2851
  }
2605
2852
  async syncAll() {
@@ -2630,7 +2877,7 @@ var PendingChangesDrawerComponent = class PendingChangesDrawerComponent {
2630
2877
  if (!await this.confirmService.confirm({
2631
2878
  title: this.labels.t("connection.discard.title"),
2632
2879
  message,
2633
- confirmLabel: this.labels.t("connection.discard"),
2880
+ confirmLabel: this.discardText(row),
2634
2881
  cancelLabel: this.labels.t("toolbar.cancel"),
2635
2882
  variant: "danger"
2636
2883
  })) return;
@@ -2728,12 +2975,16 @@ var PendingChangesDrawerComponent = class PendingChangesDrawerComponent {
2728
2975
  <p class="pcd-error" [attr.data-testid]="'pending-row-error-' + row.id">{{ err }}</p>
2729
2976
  }
2730
2977
  <div class="pcd-actions">
2731
- @if (canRetry(row)) {
2978
+ @if (support.canKeepMine(row)) {
2979
+ <button type="button" class="pcd-btn pcd-btn-primary" [attr.data-testid]="'pending-row-keep-mine-' + row.id"
2980
+ [attr.aria-label]="labels.t('connection.conflict.keepMineNamed', { label: row.label })" [attr.aria-disabled]="isBusy(row) ? 'true' : null" [attr.aria-busy]="isBusy(row) ? 'true' : null" [class.pcd-btn-busy]="isBusy(row)" (click)="keepMine(row)">{{ labels.t('connection.conflict.keepMine') }}</button>
2981
+ }
2982
+ @if (canRetry(row) && !support.canKeepMine(row)) {
2732
2983
  <button type="button" class="pcd-btn" [attr.data-testid]="'pending-row-retry-' + row.id"
2733
- [attr.aria-label]="labels.t('connection.retryNamed', { label: row.label })" (click)="retry(row)">{{ labels.t('connection.retry') }}</button>
2984
+ [attr.aria-label]="labels.t('connection.retryNamed', { label: row.label })" [attr.aria-disabled]="isBusy(row) ? 'true' : null" [attr.aria-busy]="isBusy(row) ? 'true' : null" [class.pcd-btn-busy]="isBusy(row)" (click)="retry(row)">{{ labels.t('connection.retry') }}</button>
2734
2985
  }
2735
2986
  <button type="button" class="pcd-btn pcd-btn-danger" [attr.data-testid]="'pending-row-discard-' + row.id" [disabled]="row.status === 'syncing'"
2736
- [attr.aria-label]="labels.t('connection.discardNamed', { label: row.label })" (click)="discard(row)">{{ labels.t('connection.discard') }}</button>
2987
+ [attr.aria-label]="discardName(row)" (click)="discard(row)">{{ discardText(row) }}</button>
2737
2988
  </div>
2738
2989
  </li>
2739
2990
  }
@@ -2744,7 +2995,7 @@ var PendingChangesDrawerComponent = class PendingChangesDrawerComponent {
2744
2995
  </ui-side-panel>
2745
2996
  `,
2746
2997
  isInline: true,
2747
- styles: [":host{display:contents}.pcd-live{position:absolute;inline-size:1px;block-size:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}.pcd-auth{margin:0 0 16px;padding:12px 14px;border-radius:8px;border:1px solid #b91c1c;background:#fee2e2;color:#7f1d1d;font-size:.875rem}.pcd-empty{margin:0;padding:24px 0;color:#475569;font-size:.9375rem;text-align:center}.pcd-empty:focus{outline:none}.pcd-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:12px}.pcd-row{padding:12px 14px;border:1px solid #e2e8f0;border-radius:10px;background:#fff;display:flex;flex-direction:column;gap:6px}.pcd-main{display:flex;flex-wrap:wrap;justify-content:space-between;gap:4px 12px}.pcd-label{font-weight:600;color:#0f172a;overflow-wrap:anywhere;min-inline-size:0}.pcd-status{font-size:.8125rem;color:#334155}.pcd-time{font-size:.8125rem;color:#475569}.pcd-error{margin:0;font-size:.875rem;color:#7f1d1d}.pcd-row[data-status=conflict] .pcd-error,.pcd-row[data-status=failed] .pcd-error{color:#78350f}.pcd-actions{display:flex;flex-wrap:wrap;gap:8px;margin-block-start:4px}.pcd-btn{min-block-size:44px;min-inline-size:44px;padding:0 16px;border-radius:8px;border:1px solid #334155;background:#fff;color:#0f172a;font:inherit;font-size:.875rem;font-weight:600;cursor:pointer;-webkit-appearance:none;appearance:none}.pcd-btn-danger{border-color:#b91c1c;color:#b91c1c}.pcd-btn:disabled{opacity:.5;cursor:not-allowed}.pcd-btn:focus{outline:3px solid #1d4ed8;outline-offset:2px}.pcd-btn:focus:not(:focus-visible){outline:none}@media(max-width:480px){.pcd-actions{flex-direction:column}.pcd-btn{inline-size:100%}}@media(forced-colors:active){.pcd-row,.pcd-auth,.pcd-btn{border:1px solid CanvasText;background:Canvas;color:CanvasText}}\n"],
2998
+ styles: [":host{display:contents}.pcd-live{position:absolute;inline-size:1px;block-size:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}.pcd-auth{margin:0 0 16px;padding:12px 14px;border-radius:8px;border:1px solid #b91c1c;background:#fee2e2;color:#7f1d1d;font-size:.875rem}.pcd-empty{margin:0;padding:24px 0;color:#475569;font-size:.9375rem;text-align:center}.pcd-empty:focus{outline:none}.pcd-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:12px}.pcd-row{padding:12px 14px;border:1px solid #e2e8f0;border-radius:10px;background:#fff;display:flex;flex-direction:column;gap:6px}.pcd-main{display:flex;flex-wrap:wrap;justify-content:space-between;gap:4px 12px}.pcd-label{font-weight:600;color:#0f172a;overflow-wrap:anywhere;min-inline-size:0}.pcd-status{font-size:.8125rem;color:#334155}.pcd-time{font-size:.8125rem;color:#475569}.pcd-error{margin:0;font-size:.875rem;color:#7f1d1d}.pcd-row[data-status=conflict] .pcd-error,.pcd-row[data-status=failed] .pcd-error{color:#78350f}.pcd-actions{display:flex;flex-wrap:wrap;gap:8px;margin-block-start:4px}.pcd-btn{min-block-size:44px;min-inline-size:44px;padding:0 16px;border-radius:8px;border:1px solid #334155;background:#fff;color:#0f172a;font:inherit;font-size:.875rem;font-weight:600;cursor:pointer;-webkit-appearance:none;appearance:none}.pcd-btn-primary{border-color:#1d4ed8;background:#1d4ed8;color:#fff}.pcd-btn-danger{border-color:#b91c1c;color:#b91c1c}.pcd-btn:disabled,.pcd-btn-busy{opacity:.5;cursor:not-allowed}.pcd-btn:focus{outline:3px solid #1d4ed8;outline-offset:2px}.pcd-btn:focus:not(:focus-visible){outline:none}@media(max-width:480px){.pcd-actions{flex-direction:column}.pcd-btn{inline-size:100%}}@media(forced-colors:active){.pcd-row,.pcd-auth,.pcd-btn{border:1px solid CanvasText;background:Canvas;color:CanvasText}}\n"],
2748
2999
  dependencies: [{
2749
3000
  kind: "component",
2750
3001
  type: SidePanelComponent,
@@ -2812,12 +3063,16 @@ i0.ɵɵngDeclareClassMetadata({
2812
3063
  <p class="pcd-error" [attr.data-testid]="'pending-row-error-' + row.id">{{ err }}</p>
2813
3064
  }
2814
3065
  <div class="pcd-actions">
2815
- @if (canRetry(row)) {
3066
+ @if (support.canKeepMine(row)) {
3067
+ <button type="button" class="pcd-btn pcd-btn-primary" [attr.data-testid]="'pending-row-keep-mine-' + row.id"
3068
+ [attr.aria-label]="labels.t('connection.conflict.keepMineNamed', { label: row.label })" [attr.aria-disabled]="isBusy(row) ? 'true' : null" [attr.aria-busy]="isBusy(row) ? 'true' : null" [class.pcd-btn-busy]="isBusy(row)" (click)="keepMine(row)">{{ labels.t('connection.conflict.keepMine') }}</button>
3069
+ }
3070
+ @if (canRetry(row) && !support.canKeepMine(row)) {
2816
3071
  <button type="button" class="pcd-btn" [attr.data-testid]="'pending-row-retry-' + row.id"
2817
- [attr.aria-label]="labels.t('connection.retryNamed', { label: row.label })" (click)="retry(row)">{{ labels.t('connection.retry') }}</button>
3072
+ [attr.aria-label]="labels.t('connection.retryNamed', { label: row.label })" [attr.aria-disabled]="isBusy(row) ? 'true' : null" [attr.aria-busy]="isBusy(row) ? 'true' : null" [class.pcd-btn-busy]="isBusy(row)" (click)="retry(row)">{{ labels.t('connection.retry') }}</button>
2818
3073
  }
2819
3074
  <button type="button" class="pcd-btn pcd-btn-danger" [attr.data-testid]="'pending-row-discard-' + row.id" [disabled]="row.status === 'syncing'"
2820
- [attr.aria-label]="labels.t('connection.discardNamed', { label: row.label })" (click)="discard(row)">{{ labels.t('connection.discard') }}</button>
3075
+ [attr.aria-label]="discardName(row)" (click)="discard(row)">{{ discardText(row) }}</button>
2821
3076
  </div>
2822
3077
  </li>
2823
3078
  }
@@ -2827,7 +3082,7 @@ i0.ɵɵngDeclareClassMetadata({
2827
3082
  [disabled]="rows().length === 0 || support.syncing()" (click)="discardAll()">{{ labels.t('connection.discardAll') }}</button>
2828
3083
  </ui-side-panel>
2829
3084
  `,
2830
- styles: [":host{display:contents}.pcd-live{position:absolute;inline-size:1px;block-size:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}.pcd-auth{margin:0 0 16px;padding:12px 14px;border-radius:8px;border:1px solid #b91c1c;background:#fee2e2;color:#7f1d1d;font-size:.875rem}.pcd-empty{margin:0;padding:24px 0;color:#475569;font-size:.9375rem;text-align:center}.pcd-empty:focus{outline:none}.pcd-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:12px}.pcd-row{padding:12px 14px;border:1px solid #e2e8f0;border-radius:10px;background:#fff;display:flex;flex-direction:column;gap:6px}.pcd-main{display:flex;flex-wrap:wrap;justify-content:space-between;gap:4px 12px}.pcd-label{font-weight:600;color:#0f172a;overflow-wrap:anywhere;min-inline-size:0}.pcd-status{font-size:.8125rem;color:#334155}.pcd-time{font-size:.8125rem;color:#475569}.pcd-error{margin:0;font-size:.875rem;color:#7f1d1d}.pcd-row[data-status=conflict] .pcd-error,.pcd-row[data-status=failed] .pcd-error{color:#78350f}.pcd-actions{display:flex;flex-wrap:wrap;gap:8px;margin-block-start:4px}.pcd-btn{min-block-size:44px;min-inline-size:44px;padding:0 16px;border-radius:8px;border:1px solid #334155;background:#fff;color:#0f172a;font:inherit;font-size:.875rem;font-weight:600;cursor:pointer;-webkit-appearance:none;appearance:none}.pcd-btn-danger{border-color:#b91c1c;color:#b91c1c}.pcd-btn:disabled{opacity:.5;cursor:not-allowed}.pcd-btn:focus{outline:3px solid #1d4ed8;outline-offset:2px}.pcd-btn:focus:not(:focus-visible){outline:none}@media(max-width:480px){.pcd-actions{flex-direction:column}.pcd-btn{inline-size:100%}}@media(forced-colors:active){.pcd-row,.pcd-auth,.pcd-btn{border:1px solid CanvasText;background:Canvas;color:CanvasText}}\n"]
3085
+ styles: [":host{display:contents}.pcd-live{position:absolute;inline-size:1px;block-size:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}.pcd-auth{margin:0 0 16px;padding:12px 14px;border-radius:8px;border:1px solid #b91c1c;background:#fee2e2;color:#7f1d1d;font-size:.875rem}.pcd-empty{margin:0;padding:24px 0;color:#475569;font-size:.9375rem;text-align:center}.pcd-empty:focus{outline:none}.pcd-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:12px}.pcd-row{padding:12px 14px;border:1px solid #e2e8f0;border-radius:10px;background:#fff;display:flex;flex-direction:column;gap:6px}.pcd-main{display:flex;flex-wrap:wrap;justify-content:space-between;gap:4px 12px}.pcd-label{font-weight:600;color:#0f172a;overflow-wrap:anywhere;min-inline-size:0}.pcd-status{font-size:.8125rem;color:#334155}.pcd-time{font-size:.8125rem;color:#475569}.pcd-error{margin:0;font-size:.875rem;color:#7f1d1d}.pcd-row[data-status=conflict] .pcd-error,.pcd-row[data-status=failed] .pcd-error{color:#78350f}.pcd-actions{display:flex;flex-wrap:wrap;gap:8px;margin-block-start:4px}.pcd-btn{min-block-size:44px;min-inline-size:44px;padding:0 16px;border-radius:8px;border:1px solid #334155;background:#fff;color:#0f172a;font:inherit;font-size:.875rem;font-weight:600;cursor:pointer;-webkit-appearance:none;appearance:none}.pcd-btn-primary{border-color:#1d4ed8;background:#1d4ed8;color:#fff}.pcd-btn-danger{border-color:#b91c1c;color:#b91c1c}.pcd-btn:disabled,.pcd-btn-busy{opacity:.5;cursor:not-allowed}.pcd-btn:focus{outline:3px solid #1d4ed8;outline-offset:2px}.pcd-btn:focus:not(:focus-visible){outline:none}@media(max-width:480px){.pcd-actions{flex-direction:column}.pcd-btn{inline-size:100%}}@media(forced-colors:active){.pcd-row,.pcd-auth,.pcd-btn{border:1px solid CanvasText;background:Canvas;color:CanvasText}}\n"]
2831
3086
  }]
2832
3087
  }],
2833
3088
  ctorParameters: () => [],
@@ -3031,6 +3286,6 @@ i0.ɵɵngDeclareClassMetadata({
3031
3286
  }]
3032
3287
  }
3033
3288
  });
3034
- export { ConnectionBannerComponent, ConnectionStateService, DEFAULT_DETAIL_TTL_MS, DEFAULT_LIST_TTL_MS, FROM_CACHE_HEADER, IDEMPOTENCY_HEADER, IDMAP_TTL_MS, LEASE_TTL_MS, OFFLINE_IDB_FACTORY, OFFLINE_LEASE_STORAGE, OFFLINE_LOCK_MANAGER, OFFLINE_REPLAY_HEADER, OFFLINE_SUPPORT_CONFIG, ONLINE_DEBOUNCE_MS, OfflineBlockedError, OfflineReplayer, OfflineStore, OfflineSupportService, PendingChangesDrawerComponent, QueueFullError, REQUEST_TIMEOUT_MS, RequestTimeoutError, STALE_CLAIM_MS, SYNCED_FLASH_MS, StaleDataChipComponent, StaleDataService, StillWorkingComponent, StorageUnavailableError, backoffMs, classifyReplay, connectionInterceptor, createChannel, defaultCreatedId, deriveEntity, generateUuid, idempotencyInterceptor, invalidationPrefix, isClaimable, isInScope, isMutationMethod, isOfflineBlockedError, isQuotaError, isRequestTimeoutError, lastSegmentIsId, matchesAny, matchesUrl, offlineHttpInterceptors, offlineInterceptor, pathAndQuery, pathOnly, provideOfflineSupport, resolveConfig, resolveConfigCached };
3289
+ export { ConnectionBannerComponent, ConnectionStateService, DEFAULT_DETAIL_TTL_MS, DEFAULT_LIST_TTL_MS, FROM_CACHE_HEADER, IDEMPOTENCY_HEADER, IDEMPOTENCY_IN_PROGRESS_CODE, IDMAP_TTL_MS, KeepMineError, LEASE_TTL_MS, OFFLINE_IDB_FACTORY, OFFLINE_LEASE_STORAGE, OFFLINE_LOCK_MANAGER, OFFLINE_REPLAY_HEADER, OFFLINE_SUPPORT_CONFIG, ONLINE_DEBOUNCE_MS, OfflineBlockedError, OfflineReplayer, OfflineStore, OfflineSupportService, PendingChangesDrawerComponent, QueueFullError, REQUEST_LONG, REQUEST_TIMEOUT_MS, RequestTimeoutError, STALE_CLAIM_MS, SYNCED_FLASH_MS, StaleDataChipComponent, StaleDataService, StillWorkingComponent, StorageUnavailableError, backoffMs, classifyReplay, connectionInterceptor, createChannel, defaultCreatedId, deriveEntity, generateUuid, hasStampField, idempotencyInterceptor, invalidationPrefix, isClaimable, isInScope, isMutationMethod, isOfflineBlockedError, isQuotaError, isRequestTimeoutError, lastSegmentIsId, matchesAny, matchesUrl, offlineHttpInterceptors, offlineInterceptor, pathAndQuery, pathOnly, provideOfflineSupport, resolveConfig, resolveConfigCached, stripStampFields };
3035
3290
 
3036
3291
  //# sourceMappingURL=forgeroute-ui-offline.mjs.map