@timeax/digital-service-engine 0.3.0 → 0.3.2
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/react/index.cjs +1182 -728
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +34 -1
- package/dist/react/index.d.ts +34 -1
- package/dist/react/index.js +1181 -728
- package/dist/react/index.js.map +1 -1
- package/dist/workspace/index.cjs +665 -121
- package/dist/workspace/index.cjs.map +1 -1
- package/dist/workspace/index.d.cts +40 -3
- package/dist/workspace/index.d.ts +40 -3
- package/dist/workspace/index.js +664 -121
- package/dist/workspace/index.js.map +1 -1
- package/package.json +2 -2
package/dist/react/index.js
CHANGED
|
@@ -4,8 +4,8 @@ var EventBus = class {
|
|
|
4
4
|
this.listeners = /* @__PURE__ */ new Map();
|
|
5
5
|
}
|
|
6
6
|
on(event, handler) {
|
|
7
|
-
var
|
|
8
|
-
const set = (
|
|
7
|
+
var _a2;
|
|
8
|
+
const set = (_a2 = this.listeners.get(event)) != null ? _a2 : /* @__PURE__ */ new Set();
|
|
9
9
|
set.add(handler);
|
|
10
10
|
this.listeners.set(event, set);
|
|
11
11
|
return () => {
|
|
@@ -37,9 +37,9 @@ var RetryQueue = class {
|
|
|
37
37
|
constructor(opts = {}) {
|
|
38
38
|
this.jobs = /* @__PURE__ */ new Map();
|
|
39
39
|
this.paused = false;
|
|
40
|
-
var
|
|
40
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
41
41
|
this.opts = {
|
|
42
|
-
enabled: (
|
|
42
|
+
enabled: (_a2 = opts.enabled) != null ? _a2 : true,
|
|
43
43
|
maxAttempts: (_b = opts.maxAttempts) != null ? _b : 5,
|
|
44
44
|
baseDelayMs: (_c = opts.baseDelayMs) != null ? _c : 800,
|
|
45
45
|
maxDelayMs: (_d = opts.maxDelayMs) != null ? _d : 2e4,
|
|
@@ -56,11 +56,11 @@ var RetryQueue = class {
|
|
|
56
56
|
}
|
|
57
57
|
/** Enqueue or no-op if a job with same id already exists */
|
|
58
58
|
enqueue(job) {
|
|
59
|
-
var
|
|
59
|
+
var _a2;
|
|
60
60
|
if (!this.opts.enabled) return false;
|
|
61
61
|
if (this.jobs.has(job.id)) return false;
|
|
62
62
|
this.jobs.set(job.id, { job, attempt: 0 });
|
|
63
|
-
(
|
|
63
|
+
(_a2 = job.onStatus) == null ? void 0 : _a2.call(job, "scheduled", { attempt: 0 });
|
|
64
64
|
this.kick(job.id);
|
|
65
65
|
return true;
|
|
66
66
|
}
|
|
@@ -74,12 +74,12 @@ var RetryQueue = class {
|
|
|
74
74
|
return true;
|
|
75
75
|
}
|
|
76
76
|
cancel(id) {
|
|
77
|
-
var
|
|
77
|
+
var _a2, _b;
|
|
78
78
|
const rec = this.jobs.get(id);
|
|
79
79
|
if (!rec) return false;
|
|
80
80
|
if (rec.timer) clearTimeout(rec.timer);
|
|
81
81
|
rec.cancelled = true;
|
|
82
|
-
(_b = (
|
|
82
|
+
(_b = (_a2 = rec.job).onStatus) == null ? void 0 : _b.call(_a2, "cancelled", { attempt: rec.attempt });
|
|
83
83
|
this.jobs.delete(id);
|
|
84
84
|
return true;
|
|
85
85
|
}
|
|
@@ -93,11 +93,11 @@ var RetryQueue = class {
|
|
|
93
93
|
return this.jobs.has(id);
|
|
94
94
|
}
|
|
95
95
|
drain() {
|
|
96
|
-
var
|
|
96
|
+
var _a2, _b;
|
|
97
97
|
for (const [id, rec] of this.jobs.entries()) {
|
|
98
98
|
if (rec.timer) clearTimeout(rec.timer);
|
|
99
99
|
rec.cancelled = true;
|
|
100
|
-
(_b = (
|
|
100
|
+
(_b = (_a2 = rec.job).onStatus) == null ? void 0 : _b.call(_a2, "cancelled", { attempt: rec.attempt });
|
|
101
101
|
this.jobs.delete(id);
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -112,15 +112,15 @@ var RetryQueue = class {
|
|
|
112
112
|
return Math.min(maxDelayMs, Math.floor(exp * r));
|
|
113
113
|
}
|
|
114
114
|
async kick(id, immediate = false) {
|
|
115
|
-
var
|
|
115
|
+
var _a2, _b;
|
|
116
116
|
const rec = this.jobs.get(id);
|
|
117
117
|
if (!rec || rec.cancelled) return;
|
|
118
118
|
if (this.paused && !immediate) return;
|
|
119
119
|
const attempt = rec.attempt + 1;
|
|
120
120
|
const run = async () => {
|
|
121
|
-
var
|
|
121
|
+
var _a3, _b2, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
122
122
|
if (rec.cancelled) return;
|
|
123
|
-
(_b2 = (
|
|
123
|
+
(_b2 = (_a3 = rec.job).onStatus) == null ? void 0 : _b2.call(_a3, "retrying", { attempt });
|
|
124
124
|
try {
|
|
125
125
|
const ok = await rec.job.perform(attempt);
|
|
126
126
|
if (ok) {
|
|
@@ -145,7 +145,7 @@ var RetryQueue = class {
|
|
|
145
145
|
else {
|
|
146
146
|
const delay = this.opts.immediateFirst && attempt === 1 ? 0 : this.delayFor(attempt);
|
|
147
147
|
if (delay) {
|
|
148
|
-
(_b = (
|
|
148
|
+
(_b = (_a2 = rec.job).onStatus) == null ? void 0 : _b.call(_a2, "scheduled", { attempt: 0, nextDelayMs: delay });
|
|
149
149
|
rec.timer = setTimeout(run, delay);
|
|
150
150
|
} else {
|
|
151
151
|
void run();
|
|
@@ -165,8 +165,8 @@ var CommentsAPI = class {
|
|
|
165
165
|
this.retry = new RetryQueue(deps.retry);
|
|
166
166
|
}
|
|
167
167
|
scope() {
|
|
168
|
-
var
|
|
169
|
-
return (_b = (
|
|
168
|
+
var _a2, _b;
|
|
169
|
+
return (_b = (_a2 = this.deps).getScope) == null ? void 0 : _b.call(_a2);
|
|
170
170
|
}
|
|
171
171
|
emitSync(op, threadId, messageId, status, meta) {
|
|
172
172
|
this.bus.emit("comment:sync", {
|
|
@@ -208,7 +208,7 @@ var CommentsAPI = class {
|
|
|
208
208
|
}
|
|
209
209
|
/* ─── Mutations (optimistic if backend present) ─────── */
|
|
210
210
|
async create(anchor, initialBody, meta) {
|
|
211
|
-
var
|
|
211
|
+
var _a2, _b;
|
|
212
212
|
const now = Date.now();
|
|
213
213
|
const localId = newLocalId("t");
|
|
214
214
|
const msgId = newLocalId("m");
|
|
@@ -249,7 +249,7 @@ var CommentsAPI = class {
|
|
|
249
249
|
return serverId;
|
|
250
250
|
} catch (err) {
|
|
251
251
|
const scope = this.scope();
|
|
252
|
-
const branchKey = (
|
|
252
|
+
const branchKey = (_a2 = scope == null ? void 0 : scope.branchId) != null ? _a2 : "no_branch";
|
|
253
253
|
const jobId = `comments:create_thread:${branchKey}:${localId}`;
|
|
254
254
|
this.retry.enqueue({
|
|
255
255
|
id: jobId,
|
|
@@ -280,7 +280,7 @@ var CommentsAPI = class {
|
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
282
|
async reply(threadId, body, meta) {
|
|
283
|
-
var
|
|
283
|
+
var _a2, _b, _c;
|
|
284
284
|
const th = this.ensure(threadId);
|
|
285
285
|
const now = Date.now();
|
|
286
286
|
const localMid = newLocalId("m");
|
|
@@ -293,7 +293,7 @@ var CommentsAPI = class {
|
|
|
293
293
|
};
|
|
294
294
|
th.messages.push(localMsg);
|
|
295
295
|
th.updatedAt = now;
|
|
296
|
-
(
|
|
296
|
+
(_a2 = th._sync) != null ? _a2 : th._sync = hasBackend ? "pending" : "synced";
|
|
297
297
|
this.bus.emit("comment:message:create", {
|
|
298
298
|
threadId,
|
|
299
299
|
message: localMsg
|
|
@@ -352,7 +352,7 @@ var CommentsAPI = class {
|
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
354
|
async editMessage(threadId, messageId, body) {
|
|
355
|
-
var
|
|
355
|
+
var _a2, _b, _c;
|
|
356
356
|
const th = this.ensure(threadId);
|
|
357
357
|
const orig = th.messages.find((m) => m.id === messageId);
|
|
358
358
|
if (!orig) return;
|
|
@@ -361,7 +361,7 @@ var CommentsAPI = class {
|
|
|
361
361
|
orig.editedAt = Date.now();
|
|
362
362
|
th.updatedAt = orig.editedAt;
|
|
363
363
|
const hasBackend = Boolean(this.deps.backend && this.scope());
|
|
364
|
-
(
|
|
364
|
+
(_a2 = th._sync) != null ? _a2 : th._sync = hasBackend ? "pending" : "synced";
|
|
365
365
|
this.bus.emit("comment:thread:update", { thread: th });
|
|
366
366
|
if (!this.deps.backend) return;
|
|
367
367
|
const performOnce = async () => {
|
|
@@ -414,13 +414,13 @@ var CommentsAPI = class {
|
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
416
|
async deleteMessage(threadId, messageId) {
|
|
417
|
-
var
|
|
417
|
+
var _a2, _b, _c;
|
|
418
418
|
const th = this.ensure(threadId);
|
|
419
419
|
const backup = [...th.messages];
|
|
420
420
|
th.messages = th.messages.filter((m) => m.id !== messageId);
|
|
421
421
|
th.updatedAt = Date.now();
|
|
422
422
|
const hasBackend = Boolean(this.deps.backend && this.scope());
|
|
423
|
-
(
|
|
423
|
+
(_a2 = th._sync) != null ? _a2 : th._sync = hasBackend ? "pending" : "synced";
|
|
424
424
|
this.bus.emit("comment:thread:update", { thread: th });
|
|
425
425
|
if (!this.deps.backend) return;
|
|
426
426
|
const performOnce = async () => {
|
|
@@ -469,13 +469,13 @@ var CommentsAPI = class {
|
|
|
469
469
|
}
|
|
470
470
|
}
|
|
471
471
|
async move(threadId, anchor) {
|
|
472
|
-
var
|
|
472
|
+
var _a2, _b, _c;
|
|
473
473
|
const th = this.ensure(threadId);
|
|
474
474
|
const prev = th.anchor;
|
|
475
475
|
th.anchor = anchor;
|
|
476
476
|
th.updatedAt = Date.now();
|
|
477
477
|
const hasBackend = Boolean(this.deps.backend && this.scope());
|
|
478
|
-
(
|
|
478
|
+
(_a2 = th._sync) != null ? _a2 : th._sync = hasBackend ? "pending" : "synced";
|
|
479
479
|
this.bus.emit("comment:move", { thread: th });
|
|
480
480
|
this.bus.emit("comment:thread:update", { thread: th });
|
|
481
481
|
if (!this.deps.backend) return;
|
|
@@ -527,13 +527,13 @@ var CommentsAPI = class {
|
|
|
527
527
|
}
|
|
528
528
|
}
|
|
529
529
|
async resolve(threadId, value = true) {
|
|
530
|
-
var
|
|
530
|
+
var _a2, _b, _c;
|
|
531
531
|
const th = this.ensure(threadId);
|
|
532
532
|
const prev = th.resolved;
|
|
533
533
|
th.resolved = value;
|
|
534
534
|
th.updatedAt = Date.now();
|
|
535
535
|
const hasBackend = Boolean(this.deps.backend && this.scope());
|
|
536
|
-
(
|
|
536
|
+
(_a2 = th._sync) != null ? _a2 : th._sync = hasBackend ? "pending" : "synced";
|
|
537
537
|
this.bus.emit("comment:resolve", { thread: th, resolved: value });
|
|
538
538
|
this.bus.emit("comment:thread:update", { thread: th });
|
|
539
539
|
if (!this.deps.backend) return;
|
|
@@ -585,7 +585,7 @@ var CommentsAPI = class {
|
|
|
585
585
|
}
|
|
586
586
|
}
|
|
587
587
|
async deleteThread(threadId) {
|
|
588
|
-
var
|
|
588
|
+
var _a2, _b;
|
|
589
589
|
const prev = this.threads.get(threadId);
|
|
590
590
|
if (!prev) return;
|
|
591
591
|
this.threads.delete(threadId);
|
|
@@ -601,7 +601,7 @@ var CommentsAPI = class {
|
|
|
601
601
|
await performOnce();
|
|
602
602
|
} catch (err) {
|
|
603
603
|
const scope = this.scope();
|
|
604
|
-
const branchKey = (
|
|
604
|
+
const branchKey = (_a2 = scope == null ? void 0 : scope.branchId) != null ? _a2 : "no_branch";
|
|
605
605
|
const jobId = `comments:delete_thread:${branchKey}:${threadId}`;
|
|
606
606
|
this.retry.enqueue({
|
|
607
607
|
id: jobId,
|
|
@@ -654,8 +654,8 @@ import { cloneDeep as cloneDeep4 } from "lodash-es";
|
|
|
654
654
|
// src/core/normalise.ts
|
|
655
655
|
import { cloneDeep } from "lodash-es";
|
|
656
656
|
function normalise(input, opts = {}) {
|
|
657
|
-
var
|
|
658
|
-
const defRole = (
|
|
657
|
+
var _a2, _b;
|
|
658
|
+
const defRole = (_a2 = opts.defaultPricingRole) != null ? _a2 : "base";
|
|
659
659
|
const constraints = (_b = opts.constraints) != null ? _b : ["refill", "cancel", "dripfeed"];
|
|
660
660
|
const obj = toObject(input);
|
|
661
661
|
const rawFilters = Array.isArray(obj.filters) ? obj.filters : [];
|
|
@@ -705,10 +705,10 @@ function propagateConstraints(props, flagKeys) {
|
|
|
705
705
|
const starts = roots.length ? roots : tags;
|
|
706
706
|
const visited = /* @__PURE__ */ new Set();
|
|
707
707
|
const visit = (tag, inherited) => {
|
|
708
|
-
var
|
|
708
|
+
var _a2, _b;
|
|
709
709
|
if (visited.has(tag.id)) return;
|
|
710
710
|
visited.add(tag.id);
|
|
711
|
-
const local = cloneDeep((
|
|
711
|
+
const local = cloneDeep((_a2 = tag.constraints) != null ? _a2 : {});
|
|
712
712
|
if (tag.constraints_overrides) {
|
|
713
713
|
for (const [k, over] of Object.entries(tag.constraints_overrides)) {
|
|
714
714
|
if (over) local[k] = over.from;
|
|
@@ -990,8 +990,8 @@ function isServiceIdRef(v) {
|
|
|
990
990
|
return typeof v === "string" && v.trim().length > 0 || typeof v === "number" && Number.isFinite(v);
|
|
991
991
|
}
|
|
992
992
|
function hasAnyServiceOption(f) {
|
|
993
|
-
var
|
|
994
|
-
return ((
|
|
993
|
+
var _a2;
|
|
994
|
+
return ((_a2 = f.options) != null ? _a2 : []).some((o) => isServiceIdRef(o.service_id));
|
|
995
995
|
}
|
|
996
996
|
function getByPath(obj, path) {
|
|
997
997
|
if (!path) return void 0;
|
|
@@ -1021,12 +1021,12 @@ function includesValue(arr, needle) {
|
|
|
1021
1021
|
return false;
|
|
1022
1022
|
}
|
|
1023
1023
|
function matchesWhere(svc, where) {
|
|
1024
|
-
var
|
|
1024
|
+
var _a2;
|
|
1025
1025
|
if (!where || where.length === 0) return true;
|
|
1026
1026
|
const root = { service: svc };
|
|
1027
1027
|
for (const clause of where) {
|
|
1028
1028
|
const path = clause.path;
|
|
1029
|
-
const op = (
|
|
1029
|
+
const op = (_a2 = clause.op) != null ? _a2 : "eq";
|
|
1030
1030
|
const value = clause.value;
|
|
1031
1031
|
const cur = getByPath(root, path);
|
|
1032
1032
|
if (op === "exists") {
|
|
@@ -1080,9 +1080,9 @@ function withAffected(details, ids) {
|
|
|
1080
1080
|
|
|
1081
1081
|
// src/core/node-map.ts
|
|
1082
1082
|
function buildNodeMap(props) {
|
|
1083
|
-
var
|
|
1083
|
+
var _a2, _b, _c;
|
|
1084
1084
|
const map = /* @__PURE__ */ new Map();
|
|
1085
|
-
for (const t of (
|
|
1085
|
+
for (const t of (_a2 = props.filters) != null ? _a2 : []) {
|
|
1086
1086
|
if (!map.has(t.id)) map.set(t.id, { kind: "tag", id: t.id, node: t });
|
|
1087
1087
|
}
|
|
1088
1088
|
for (const f of (_b = props.fields) != null ? _b : []) {
|
|
@@ -1121,8 +1121,8 @@ function resolveTrigger(trigger, nodeMap) {
|
|
|
1121
1121
|
|
|
1122
1122
|
// src/core/visibility.ts
|
|
1123
1123
|
function visibleFieldIdsUnder(props, tagId, opts = {}) {
|
|
1124
|
-
var
|
|
1125
|
-
const tags = (
|
|
1124
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1125
|
+
const tags = (_a2 = props.filters) != null ? _a2 : [];
|
|
1126
1126
|
const fields = (_b = props.fields) != null ? _b : [];
|
|
1127
1127
|
const tagById = new Map(tags.map((t) => [t.id, t]));
|
|
1128
1128
|
const tag = tagById.get(tagId);
|
|
@@ -1239,9 +1239,9 @@ function visibleFieldIdsUnder(props, tagId, opts = {}) {
|
|
|
1239
1239
|
return base;
|
|
1240
1240
|
}
|
|
1241
1241
|
function visibleFieldsUnder(props, tagId, opts = {}) {
|
|
1242
|
-
var
|
|
1242
|
+
var _a2;
|
|
1243
1243
|
const ids = visibleFieldIdsUnder(props, tagId, opts);
|
|
1244
|
-
const fieldById = new Map(((
|
|
1244
|
+
const fieldById = new Map(((_a2 = props.fields) != null ? _a2 : []).map((f) => [f.id, f]));
|
|
1245
1245
|
return ids.map((id) => fieldById.get(id)).filter(Boolean);
|
|
1246
1246
|
}
|
|
1247
1247
|
|
|
@@ -1261,7 +1261,7 @@ function resolveRootTags(tags) {
|
|
|
1261
1261
|
return roots.length ? roots : tags.slice(0, 1);
|
|
1262
1262
|
}
|
|
1263
1263
|
function collectSelectableTriggersInContext(v, tagId, selectedKeys, effectfulKeys) {
|
|
1264
|
-
var
|
|
1264
|
+
var _a2;
|
|
1265
1265
|
const visible = visibleFieldsUnder(v.props, tagId, {
|
|
1266
1266
|
selectedKeys
|
|
1267
1267
|
});
|
|
@@ -1271,7 +1271,7 @@ function collectSelectableTriggersInContext(v, tagId, selectedKeys, effectfulKey
|
|
|
1271
1271
|
const t = f.id;
|
|
1272
1272
|
if (effectfulKeys.has(t)) triggers.push(t);
|
|
1273
1273
|
}
|
|
1274
|
-
for (const o of (
|
|
1274
|
+
for (const o of (_a2 = f.options) != null ? _a2 : []) {
|
|
1275
1275
|
const t = o.id;
|
|
1276
1276
|
if (effectfulKeys.has(t)) triggers.push(t);
|
|
1277
1277
|
}
|
|
@@ -1280,12 +1280,12 @@ function collectSelectableTriggersInContext(v, tagId, selectedKeys, effectfulKey
|
|
|
1280
1280
|
return triggers;
|
|
1281
1281
|
}
|
|
1282
1282
|
function runVisibilityRulesOnce(v) {
|
|
1283
|
-
var
|
|
1283
|
+
var _a2, _b, _c, _d, _e;
|
|
1284
1284
|
for (const t of v.tags) {
|
|
1285
1285
|
const visible = v.fieldsVisibleUnder(t.id);
|
|
1286
1286
|
const seen = /* @__PURE__ */ new Map();
|
|
1287
1287
|
for (const f of visible) {
|
|
1288
|
-
const label = ((
|
|
1288
|
+
const label = ((_a2 = f.label) != null ? _a2 : "").trim();
|
|
1289
1289
|
if (!label) continue;
|
|
1290
1290
|
if (seen.has(label)) {
|
|
1291
1291
|
const otherId = seen.get(label);
|
|
@@ -1357,8 +1357,8 @@ function runVisibilityRulesOnce(v) {
|
|
|
1357
1357
|
function dedupeErrorsInPlace(v, startIndex) {
|
|
1358
1358
|
const seen = /* @__PURE__ */ new Set();
|
|
1359
1359
|
const keyOfErr = (e) => {
|
|
1360
|
-
var
|
|
1361
|
-
const tagId = (_e = (_d = (
|
|
1360
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1361
|
+
const tagId = (_e = (_d = (_a2 = e == null ? void 0 : e.details) == null ? void 0 : _a2.tagId) != null ? _d : (_c = (_b = e == null ? void 0 : e.details) == null ? void 0 : _b.affected) == null ? void 0 : _c.tagId) != null ? _e : "";
|
|
1362
1362
|
const other = (_g = (_f = e == null ? void 0 : e.details) == null ? void 0 : _f.other) != null ? _g : "";
|
|
1363
1363
|
return `${(_h = e == null ? void 0 : e.code) != null ? _h : ""}::${(_i = e == null ? void 0 : e.nodeId) != null ? _i : ""}::${tagId}::${other}::${(_j = e == null ? void 0 : e.message) != null ? _j : ""}`;
|
|
1364
1364
|
};
|
|
@@ -1373,7 +1373,7 @@ function dedupeErrorsInPlace(v, startIndex) {
|
|
|
1373
1373
|
v.errors.splice(startIndex, v.errors.length - startIndex, ...kept);
|
|
1374
1374
|
}
|
|
1375
1375
|
function validateVisibility(v, options = {}) {
|
|
1376
|
-
var
|
|
1376
|
+
var _a2, _b, _c, _d, _e;
|
|
1377
1377
|
v.simulatedVisibilityContexts = [];
|
|
1378
1378
|
const simulate = options.simulate === true;
|
|
1379
1379
|
if (!simulate) {
|
|
@@ -1387,7 +1387,7 @@ function validateVisibility(v, options = {}) {
|
|
|
1387
1387
|
}
|
|
1388
1388
|
return;
|
|
1389
1389
|
}
|
|
1390
|
-
const maxStates = Math.max(1, (
|
|
1390
|
+
const maxStates = Math.max(1, (_a2 = options.maxStates) != null ? _a2 : 500);
|
|
1391
1391
|
const maxDepth = Math.max(0, (_b = options.maxDepth) != null ? _b : 6);
|
|
1392
1392
|
const onlyEffectful = options.onlyEffectfulTriggers !== false;
|
|
1393
1393
|
const effectfulKeys = /* @__PURE__ */ new Set();
|
|
@@ -1477,11 +1477,11 @@ function validateStructure(v) {
|
|
|
1477
1477
|
const visiting = /* @__PURE__ */ new Set();
|
|
1478
1478
|
const visited = /* @__PURE__ */ new Set();
|
|
1479
1479
|
const hasCycleFrom = (id) => {
|
|
1480
|
-
var
|
|
1480
|
+
var _a2;
|
|
1481
1481
|
if (visiting.has(id)) return true;
|
|
1482
1482
|
if (visited.has(id)) return false;
|
|
1483
1483
|
visiting.add(id);
|
|
1484
|
-
const parent = (
|
|
1484
|
+
const parent = (_a2 = v.tagById.get(id)) == null ? void 0 : _a2.bind_id;
|
|
1485
1485
|
if (parent && v.tagById.has(parent) && hasCycleFrom(parent))
|
|
1486
1486
|
return true;
|
|
1487
1487
|
visiting.delete(id);
|
|
@@ -1542,7 +1542,7 @@ function validateStructure(v) {
|
|
|
1542
1542
|
|
|
1543
1543
|
// src/core/validate/steps/identity.ts
|
|
1544
1544
|
function validateIdentity(v) {
|
|
1545
|
-
var
|
|
1545
|
+
var _a2, _b;
|
|
1546
1546
|
const tags = v.tags;
|
|
1547
1547
|
const fields = v.fields;
|
|
1548
1548
|
{
|
|
@@ -1564,7 +1564,7 @@ function validateIdentity(v) {
|
|
|
1564
1564
|
}
|
|
1565
1565
|
for (const f of fields) {
|
|
1566
1566
|
if (seen.has(f.id)) {
|
|
1567
|
-
const kind = (
|
|
1567
|
+
const kind = (_a2 = firstSeen.get(f.id)) != null ? _a2 : "tag/field";
|
|
1568
1568
|
v.errors.push({
|
|
1569
1569
|
code: "duplicate_id",
|
|
1570
1570
|
severity: "error",
|
|
@@ -1666,14 +1666,14 @@ function parseFieldOptionKey(key) {
|
|
|
1666
1666
|
return { fieldId, optionId };
|
|
1667
1667
|
}
|
|
1668
1668
|
function hasOption(v, fid, oid) {
|
|
1669
|
-
var
|
|
1669
|
+
var _a2;
|
|
1670
1670
|
const f = v.fieldById.get(fid);
|
|
1671
1671
|
if (!f) return false;
|
|
1672
|
-
return !!((
|
|
1672
|
+
return !!((_a2 = f.options) != null ? _a2 : []).find((o) => o.id === oid);
|
|
1673
1673
|
}
|
|
1674
1674
|
function validateOptionMaps(v) {
|
|
1675
|
-
var
|
|
1676
|
-
const incMap = (
|
|
1675
|
+
var _a2, _b;
|
|
1676
|
+
const incMap = (_a2 = v.props.includes_for_buttons) != null ? _a2 : {};
|
|
1677
1677
|
const excMap = (_b = v.props.excludes_for_buttons) != null ? _b : {};
|
|
1678
1678
|
const badKeyMessage = (key) => `Invalid trigger-map key "${key}". Expected a known node id (option or button-field), or "fieldId::optionId" pointing to an existing option.`;
|
|
1679
1679
|
const validateTriggerKey = (key) => {
|
|
@@ -1787,8 +1787,8 @@ function normalizeSelectedOrderKindTriggers(selectedTriggerKeys, nodeMap) {
|
|
|
1787
1787
|
return out;
|
|
1788
1788
|
}
|
|
1789
1789
|
function resolveOrderKind(params) {
|
|
1790
|
-
var
|
|
1791
|
-
const nodeMap = (
|
|
1790
|
+
var _a2, _b;
|
|
1791
|
+
const nodeMap = (_a2 = params.nodeMap) != null ? _a2 : buildNodeMap(params.props);
|
|
1792
1792
|
const orderKinds = (_b = params.props.orderKinds) != null ? _b : {};
|
|
1793
1793
|
const normalizedSelected = normalizeSelectedOrderKindTriggers(
|
|
1794
1794
|
params.selectedTriggerKeys,
|
|
@@ -1843,8 +1843,8 @@ function resolveOrderKind(params) {
|
|
|
1843
1843
|
|
|
1844
1844
|
// src/core/validate/steps/order-kinds.ts
|
|
1845
1845
|
function validateOrderKinds(v) {
|
|
1846
|
-
var
|
|
1847
|
-
const selectedTriggerKeys = Array.from((
|
|
1846
|
+
var _a2, _b, _c;
|
|
1847
|
+
const selectedTriggerKeys = Array.from((_a2 = v.selectedKeys) != null ? _a2 : []);
|
|
1848
1848
|
if (!selectedTriggerKeys.length) return;
|
|
1849
1849
|
const resolved = resolveOrderKind({
|
|
1850
1850
|
props: v.props,
|
|
@@ -1870,8 +1870,8 @@ function validateOrderKinds(v) {
|
|
|
1870
1870
|
|
|
1871
1871
|
// src/core/validate/steps/service-vs-input.ts
|
|
1872
1872
|
function hasButtonTriggerMap(v, fieldId) {
|
|
1873
|
-
var
|
|
1874
|
-
const includes = (
|
|
1873
|
+
var _a2, _b;
|
|
1874
|
+
const includes = (_a2 = v.props.includes_for_buttons) == null ? void 0 : _a2[fieldId];
|
|
1875
1875
|
const excludes = (_b = v.props.excludes_for_buttons) == null ? void 0 : _b[fieldId];
|
|
1876
1876
|
return Array.isArray(includes) && includes.length > 0 || Array.isArray(excludes) && excludes.length > 0;
|
|
1877
1877
|
}
|
|
@@ -1916,7 +1916,7 @@ function validateServiceVsUserInput(v) {
|
|
|
1916
1916
|
|
|
1917
1917
|
// src/core/validate/steps/utility.ts
|
|
1918
1918
|
function validateUtilityMarkers(v) {
|
|
1919
|
-
var
|
|
1919
|
+
var _a2, _b, _c, _d;
|
|
1920
1920
|
const ALLOWED_UTILITY_MODES = /* @__PURE__ */ new Set([
|
|
1921
1921
|
"flat",
|
|
1922
1922
|
"per_quantity",
|
|
@@ -1926,7 +1926,7 @@ function validateUtilityMarkers(v) {
|
|
|
1926
1926
|
for (const f of v.fields) {
|
|
1927
1927
|
const optsArr = Array.isArray(f.options) ? f.options : [];
|
|
1928
1928
|
for (const o of optsArr) {
|
|
1929
|
-
const role = (_b = (
|
|
1929
|
+
const role = (_b = (_a2 = o.pricing_role) != null ? _a2 : f.pricing_role) != null ? _b : "base";
|
|
1930
1930
|
const hasService = isServiceIdRef(o.service_id);
|
|
1931
1931
|
const util = (_c = o.meta) == null ? void 0 : _c.utility;
|
|
1932
1932
|
if (role === "utility" && hasService) {
|
|
@@ -2007,9 +2007,9 @@ function validateUtilityMarkers(v) {
|
|
|
2007
2007
|
|
|
2008
2008
|
// src/utils/index.ts
|
|
2009
2009
|
function isMultiField(f) {
|
|
2010
|
-
var
|
|
2010
|
+
var _a2;
|
|
2011
2011
|
const t = (f.type || "").toLowerCase();
|
|
2012
|
-
const metaMulti = !!((
|
|
2012
|
+
const metaMulti = !!((_a2 = f.meta) == null ? void 0 : _a2.multi);
|
|
2013
2013
|
return t === "multiselect" || t === "checkbox" || metaMulti;
|
|
2014
2014
|
}
|
|
2015
2015
|
|
|
@@ -2029,8 +2029,8 @@ function constraintFitOk(svcMap, candidate, constraints) {
|
|
|
2029
2029
|
return !(constraints.cancel === true && !cap.cancel);
|
|
2030
2030
|
}
|
|
2031
2031
|
function getServiceCapability(svcMap, candidate) {
|
|
2032
|
-
var
|
|
2033
|
-
return (
|
|
2032
|
+
var _a2;
|
|
2033
|
+
return (_a2 = getServiceCapabilityEntry(svcMap, candidate)) == null ? void 0 : _a2.capability;
|
|
2034
2034
|
}
|
|
2035
2035
|
function getServiceCapabilityCanonicalRef(svcMap, candidate) {
|
|
2036
2036
|
const entry = getServiceCapabilityEntry(svcMap, candidate);
|
|
@@ -2057,10 +2057,10 @@ function isSameServiceCapabilityRef(svcMap, left, right) {
|
|
|
2057
2057
|
return rightAliases.some((value) => leftAliases.has(String(value)));
|
|
2058
2058
|
}
|
|
2059
2059
|
function normalizeRatePolicy(policy) {
|
|
2060
|
-
var
|
|
2060
|
+
var _a2;
|
|
2061
2061
|
if (!policy) return { kind: "lte_primary", pct: 5 };
|
|
2062
2062
|
if (policy.kind === "eq_primary") return policy;
|
|
2063
|
-
const pct = Math.max(0, Number((
|
|
2063
|
+
const pct = Math.max(0, Number((_a2 = policy.pct) != null ? _a2 : 0));
|
|
2064
2064
|
return { ...policy, pct };
|
|
2065
2065
|
}
|
|
2066
2066
|
function passesRatePolicy(policy, primaryRate, candidateRate) {
|
|
@@ -2161,12 +2161,12 @@ function normalizeServiceRef(value) {
|
|
|
2161
2161
|
|
|
2162
2162
|
// src/core/validate/steps/rates.ts
|
|
2163
2163
|
function validateRates(v) {
|
|
2164
|
-
var
|
|
2164
|
+
var _a2, _b, _c;
|
|
2165
2165
|
const ratePolicy = normalizeRatePolicy(v.options.ratePolicy);
|
|
2166
2166
|
for (const f of v.fields) {
|
|
2167
2167
|
if (!isMultiField(f)) continue;
|
|
2168
2168
|
const baseRates = [];
|
|
2169
|
-
for (const o of (
|
|
2169
|
+
for (const o of (_a2 = f.options) != null ? _a2 : []) {
|
|
2170
2170
|
const role = (_c = (_b = o.pricing_role) != null ? _b : f.pricing_role) != null ? _c : "base";
|
|
2171
2171
|
if (role !== "base") continue;
|
|
2172
2172
|
const sid = o.service_id;
|
|
@@ -2219,7 +2219,7 @@ function validateRates(v) {
|
|
|
2219
2219
|
|
|
2220
2220
|
// src/core/rate-coherence.ts
|
|
2221
2221
|
function buildTriggerEffectMap(props) {
|
|
2222
|
-
var
|
|
2222
|
+
var _a2, _b;
|
|
2223
2223
|
const map = /* @__PURE__ */ new Map();
|
|
2224
2224
|
const ensure = (key) => {
|
|
2225
2225
|
let item = map.get(key);
|
|
@@ -2229,7 +2229,7 @@ function buildTriggerEffectMap(props) {
|
|
|
2229
2229
|
}
|
|
2230
2230
|
return item;
|
|
2231
2231
|
};
|
|
2232
|
-
for (const [key, ids] of Object.entries((
|
|
2232
|
+
for (const [key, ids] of Object.entries((_a2 = props.includes_for_buttons) != null ? _a2 : {})) {
|
|
2233
2233
|
const item = ensure(key);
|
|
2234
2234
|
for (const id of ids != null ? ids : []) item.includes.add(id);
|
|
2235
2235
|
}
|
|
@@ -2269,7 +2269,7 @@ function getRate(serviceMap, serviceId) {
|
|
|
2269
2269
|
return rate;
|
|
2270
2270
|
}
|
|
2271
2271
|
function collectContextRefs(tag, visibleFields, serviceMap) {
|
|
2272
|
-
var
|
|
2272
|
+
var _a2, _b, _c, _d, _e;
|
|
2273
2273
|
const serviceRefs = [];
|
|
2274
2274
|
let tagDefault;
|
|
2275
2275
|
if (tag.service_id !== void 0 && tag.service_id !== null) {
|
|
@@ -2281,7 +2281,7 @@ function collectContextRefs(tag, visibleFields, serviceMap) {
|
|
|
2281
2281
|
nodeKind: "tag",
|
|
2282
2282
|
serviceId: tag.service_id,
|
|
2283
2283
|
rate: tagRate,
|
|
2284
|
-
label: (
|
|
2284
|
+
label: (_a2 = tag.label) != null ? _a2 : tag.id,
|
|
2285
2285
|
pricingRole: "base"
|
|
2286
2286
|
};
|
|
2287
2287
|
}
|
|
@@ -2558,7 +2558,7 @@ function constraintKeysInChain(v, tagId) {
|
|
|
2558
2558
|
return keys;
|
|
2559
2559
|
}
|
|
2560
2560
|
function effectiveConstraints(v, tagId) {
|
|
2561
|
-
var
|
|
2561
|
+
var _a2;
|
|
2562
2562
|
const out = {};
|
|
2563
2563
|
const keys = constraintKeysInChain(v, tagId);
|
|
2564
2564
|
for (const key of keys) {
|
|
@@ -2567,7 +2567,7 @@ function effectiveConstraints(v, tagId) {
|
|
|
2567
2567
|
while (cur && !seen.has(cur)) {
|
|
2568
2568
|
seen.add(cur);
|
|
2569
2569
|
const t = v.tagById.get(cur);
|
|
2570
|
-
const val = (
|
|
2570
|
+
const val = (_a2 = t == null ? void 0 : t.constraints) == null ? void 0 : _a2[key];
|
|
2571
2571
|
if (val === true || val === false) {
|
|
2572
2572
|
out[key] = val;
|
|
2573
2573
|
break;
|
|
@@ -2578,7 +2578,7 @@ function effectiveConstraints(v, tagId) {
|
|
|
2578
2578
|
return out;
|
|
2579
2579
|
}
|
|
2580
2580
|
function validateConstraints(v) {
|
|
2581
|
-
var
|
|
2581
|
+
var _a2, _b;
|
|
2582
2582
|
for (const t of v.tags) {
|
|
2583
2583
|
const eff = effectiveConstraints(v, t.id);
|
|
2584
2584
|
const hasAnyRequired = Object.values(eff).some(
|
|
@@ -2587,7 +2587,7 @@ function validateConstraints(v) {
|
|
|
2587
2587
|
if (!hasAnyRequired) continue;
|
|
2588
2588
|
const visible = v.fieldsVisibleUnder(t.id);
|
|
2589
2589
|
for (const f of visible) {
|
|
2590
|
-
for (const o of (
|
|
2590
|
+
for (const o of (_a2 = f.options) != null ? _a2 : []) {
|
|
2591
2591
|
if (!isServiceIdRef(o.service_id)) continue;
|
|
2592
2592
|
const svc = getServiceCapability(v.serviceMap, o.service_id);
|
|
2593
2593
|
if (!svc || typeof svc !== "object") continue;
|
|
@@ -2675,12 +2675,12 @@ function validateCustomFields(v) {
|
|
|
2675
2675
|
|
|
2676
2676
|
// src/core/validate/steps/global-utility-guard.ts
|
|
2677
2677
|
function validateGlobalUtilityGuard(v) {
|
|
2678
|
-
var
|
|
2678
|
+
var _a2, _b, _c;
|
|
2679
2679
|
if (!v.options.globalUtilityGuard) return;
|
|
2680
2680
|
let hasUtility = false;
|
|
2681
2681
|
let hasBase = false;
|
|
2682
2682
|
for (const f of v.fields) {
|
|
2683
|
-
for (const o of (
|
|
2683
|
+
for (const o of (_a2 = f.options) != null ? _a2 : []) {
|
|
2684
2684
|
if (!isServiceIdRef(o.service_id)) continue;
|
|
2685
2685
|
const role = (_c = (_b = o.pricing_role) != null ? _b : f.pricing_role) != null ? _c : "base";
|
|
2686
2686
|
if (role === "base") hasBase = true;
|
|
@@ -2702,14 +2702,14 @@ function validateGlobalUtilityGuard(v) {
|
|
|
2702
2702
|
|
|
2703
2703
|
// src/core/validate/steps/unbound.ts
|
|
2704
2704
|
function validateUnboundFields(v) {
|
|
2705
|
-
var
|
|
2705
|
+
var _a2, _b;
|
|
2706
2706
|
const boundFieldIds = /* @__PURE__ */ new Set();
|
|
2707
2707
|
for (const f of v.fields) {
|
|
2708
2708
|
if (f.bind_id) boundFieldIds.add(f.id);
|
|
2709
2709
|
}
|
|
2710
2710
|
const includedByTag = /* @__PURE__ */ new Set();
|
|
2711
2711
|
for (const t of v.tags) {
|
|
2712
|
-
for (const id of (
|
|
2712
|
+
for (const id of (_a2 = t.includes) != null ? _a2 : []) includedByTag.add(id);
|
|
2713
2713
|
}
|
|
2714
2714
|
const includedByOption = /* @__PURE__ */ new Set();
|
|
2715
2715
|
for (const arr of Object.values((_b = v.props.includes_for_buttons) != null ? _b : {})) {
|
|
@@ -2778,8 +2778,8 @@ function messageFor(code, d) {
|
|
|
2778
2778
|
}
|
|
2779
2779
|
}
|
|
2780
2780
|
function validateFallbacks(v) {
|
|
2781
|
-
var
|
|
2782
|
-
const mode = (_b = (
|
|
2781
|
+
var _a2, _b, _c, _d;
|
|
2782
|
+
const mode = (_b = (_a2 = v.options.fallbackSettings) == null ? void 0 : _a2.mode) != null ? _b : "strict";
|
|
2783
2783
|
if (!v.props.fallbacks) return;
|
|
2784
2784
|
const diags = collectFailedFallbacks(v.props, (_c = v.options.serviceMap) != null ? _c : {}, {
|
|
2785
2785
|
...v.options.fallbackSettings,
|
|
@@ -2840,7 +2840,7 @@ function svcSnapshot(serviceMap, sid) {
|
|
|
2840
2840
|
};
|
|
2841
2841
|
}
|
|
2842
2842
|
function pushItem(out, next) {
|
|
2843
|
-
var
|
|
2843
|
+
var _a2;
|
|
2844
2844
|
const key = `${String(next.serviceId)}|${next.role}`;
|
|
2845
2845
|
const existing = out.get(key);
|
|
2846
2846
|
if (!existing) {
|
|
@@ -2861,13 +2861,13 @@ function pushItem(out, next) {
|
|
|
2861
2861
|
);
|
|
2862
2862
|
out.set(key, {
|
|
2863
2863
|
...existing,
|
|
2864
|
-
tagId: (
|
|
2864
|
+
tagId: (_a2 = existing.tagId) != null ? _a2 : next.tagId,
|
|
2865
2865
|
affectedIds: mergedIds
|
|
2866
2866
|
});
|
|
2867
2867
|
}
|
|
2868
2868
|
function fieldRoleOf(f, o) {
|
|
2869
|
-
var
|
|
2870
|
-
const roleRaw = (_b = (
|
|
2869
|
+
var _a2, _b;
|
|
2870
|
+
const roleRaw = (_b = (_a2 = o == null ? void 0 : o.pricing_role) != null ? _a2 : f.pricing_role) != null ? _b : "base";
|
|
2871
2871
|
return roleRaw === "utility" ? "utility" : "base";
|
|
2872
2872
|
}
|
|
2873
2873
|
function applyFilterAllowLists(tagId, fieldId, filter) {
|
|
@@ -2884,9 +2884,9 @@ function applyFilterAllowLists(tagId, fieldId, filter) {
|
|
|
2884
2884
|
return true;
|
|
2885
2885
|
}
|
|
2886
2886
|
function collectServiceItems(args) {
|
|
2887
|
-
var
|
|
2887
|
+
var _a2, _b, _c, _d, _e;
|
|
2888
2888
|
const filter = args.filter;
|
|
2889
|
-
const roleFilter = (
|
|
2889
|
+
const roleFilter = (_a2 = filter == null ? void 0 : filter.role) != null ? _a2 : "both";
|
|
2890
2890
|
const where = filter == null ? void 0 : filter.where;
|
|
2891
2891
|
const out = /* @__PURE__ */ new Map();
|
|
2892
2892
|
const addServiceRef = (ref) => {
|
|
@@ -3091,26 +3091,26 @@ function defaultPolicyMessage(rule) {
|
|
|
3091
3091
|
return `Policy "${rule.id}" violated`;
|
|
3092
3092
|
}
|
|
3093
3093
|
function affectedFromItems(items) {
|
|
3094
|
-
var
|
|
3094
|
+
var _a2;
|
|
3095
3095
|
const ids = [];
|
|
3096
3096
|
for (const it of items) {
|
|
3097
|
-
for (const x of (
|
|
3097
|
+
for (const x of (_a2 = it.affectedIds) != null ? _a2 : []) ids.push(x);
|
|
3098
3098
|
ids.push(`service:${String(it.serviceId)}`);
|
|
3099
3099
|
}
|
|
3100
3100
|
return uniq(ids);
|
|
3101
3101
|
}
|
|
3102
3102
|
function visibleGroupNodeIds(tag, fields) {
|
|
3103
|
-
var
|
|
3103
|
+
var _a2;
|
|
3104
3104
|
const ids = [tag.id];
|
|
3105
3105
|
for (const f of fields) {
|
|
3106
|
-
for (const o of (
|
|
3106
|
+
for (const o of (_a2 = f.options) != null ? _a2 : []) {
|
|
3107
3107
|
ids.push(o.id);
|
|
3108
3108
|
}
|
|
3109
3109
|
}
|
|
3110
3110
|
return uniq(ids);
|
|
3111
3111
|
}
|
|
3112
3112
|
function visibleGroupPrimaries(tag, fields) {
|
|
3113
|
-
var
|
|
3113
|
+
var _a2;
|
|
3114
3114
|
const prim = [];
|
|
3115
3115
|
const tagSid = tag.service_id;
|
|
3116
3116
|
if (typeof tagSid === "string" || typeof tagSid === "number" && Number.isFinite(tagSid)) {
|
|
@@ -3121,7 +3121,7 @@ function visibleGroupPrimaries(tag, fields) {
|
|
|
3121
3121
|
if (typeof fsid === "string" || typeof fsid === "number" && Number.isFinite(fsid)) {
|
|
3122
3122
|
prim.push(fsid);
|
|
3123
3123
|
}
|
|
3124
|
-
for (const o of (
|
|
3124
|
+
for (const o of (_a2 = f.options) != null ? _a2 : []) {
|
|
3125
3125
|
const osid = o.service_id;
|
|
3126
3126
|
if (typeof osid === "string" || typeof osid === "number" && Number.isFinite(osid)) {
|
|
3127
3127
|
prim.push(osid);
|
|
@@ -3131,12 +3131,12 @@ function visibleGroupPrimaries(tag, fields) {
|
|
|
3131
3131
|
return uniq(prim);
|
|
3132
3132
|
}
|
|
3133
3133
|
function applyPolicies(errors, props, serviceMap, policies, fieldsVisibleUnder, tags) {
|
|
3134
|
-
var
|
|
3134
|
+
var _a2, _b, _c, _d, _e;
|
|
3135
3135
|
if (!(policies == null ? void 0 : policies.length)) return;
|
|
3136
3136
|
const tagById = /* @__PURE__ */ new Map();
|
|
3137
3137
|
for (const t of tags) tagById.set(t.id, t);
|
|
3138
3138
|
for (const rule of policies) {
|
|
3139
|
-
const projPath = (
|
|
3139
|
+
const projPath = (_a2 = rule.projection) != null ? _a2 : "service.id";
|
|
3140
3140
|
const severity = stableSeverity(
|
|
3141
3141
|
rule.severity
|
|
3142
3142
|
);
|
|
@@ -3270,16 +3270,16 @@ function resolveGlobalRatePolicy(options) {
|
|
|
3270
3270
|
return normalizeRatePolicy(options.ratePolicy);
|
|
3271
3271
|
}
|
|
3272
3272
|
function resolveFallbackSettings(options) {
|
|
3273
|
-
var
|
|
3273
|
+
var _a2;
|
|
3274
3274
|
return {
|
|
3275
3275
|
...DEFAULT_FALLBACK_SETTINGS,
|
|
3276
|
-
...(
|
|
3276
|
+
...(_a2 = options.fallbackSettings) != null ? _a2 : {}
|
|
3277
3277
|
};
|
|
3278
3278
|
}
|
|
3279
3279
|
function mergeValidatorOptions(defaults = {}, overrides = {}) {
|
|
3280
|
-
var
|
|
3280
|
+
var _a2, _b, _c, _d;
|
|
3281
3281
|
const mergedFallbackSettings = {
|
|
3282
|
-
...(
|
|
3282
|
+
...(_a2 = defaults.fallbackSettings) != null ? _a2 : {},
|
|
3283
3283
|
...(_b = overrides.fallbackSettings) != null ? _b : {}
|
|
3284
3284
|
};
|
|
3285
3285
|
return {
|
|
@@ -3308,12 +3308,12 @@ function readVisibilitySimOpts(ctx) {
|
|
|
3308
3308
|
};
|
|
3309
3309
|
}
|
|
3310
3310
|
function validate(props, ctx = {}) {
|
|
3311
|
-
var
|
|
3311
|
+
var _a2, _b, _c;
|
|
3312
3312
|
const options = mergeValidatorOptions({}, ctx);
|
|
3313
3313
|
const fallbackSettings = resolveFallbackSettings(options);
|
|
3314
3314
|
const ratePolicy = resolveGlobalRatePolicy(options);
|
|
3315
3315
|
const errors = [];
|
|
3316
|
-
const serviceMap = (
|
|
3316
|
+
const serviceMap = (_a2 = options.serviceMap) != null ? _a2 : {};
|
|
3317
3317
|
const selectedKeys = new Set(
|
|
3318
3318
|
(_b = options.selectedOptionKeys) != null ? _b : []
|
|
3319
3319
|
);
|
|
@@ -3412,16 +3412,16 @@ var BuilderImpl = class {
|
|
|
3412
3412
|
this.options = { ...this.options, ...patch };
|
|
3413
3413
|
}
|
|
3414
3414
|
getServiceMap() {
|
|
3415
|
-
var
|
|
3416
|
-
return (
|
|
3415
|
+
var _a2;
|
|
3416
|
+
return (_a2 = this.options.serviceMap) != null ? _a2 : {};
|
|
3417
3417
|
}
|
|
3418
3418
|
getConstraints() {
|
|
3419
|
-
var
|
|
3419
|
+
var _a2;
|
|
3420
3420
|
const serviceMap = this.getServiceMap();
|
|
3421
3421
|
const out = /* @__PURE__ */ new Set();
|
|
3422
3422
|
const guard = /* @__PURE__ */ new Set();
|
|
3423
3423
|
for (const svc of Object.values(serviceMap)) {
|
|
3424
|
-
const flags = (
|
|
3424
|
+
const flags = (_a2 = svc.flags) != null ? _a2 : {};
|
|
3425
3425
|
for (const flagId of Object.keys(flags)) {
|
|
3426
3426
|
if (guard.has(flagId)) continue;
|
|
3427
3427
|
guard.add(flagId);
|
|
@@ -3437,7 +3437,7 @@ var BuilderImpl = class {
|
|
|
3437
3437
|
}
|
|
3438
3438
|
/* ───── querying ─────────────────────────────────────────────────────── */
|
|
3439
3439
|
tree() {
|
|
3440
|
-
var
|
|
3440
|
+
var _a2, _b, _c, _d;
|
|
3441
3441
|
const nodes = [];
|
|
3442
3442
|
const edges = [];
|
|
3443
3443
|
const showSet = toStringSet(this.options.showOptionNodes);
|
|
@@ -3494,7 +3494,7 @@ var BuilderImpl = class {
|
|
|
3494
3494
|
}
|
|
3495
3495
|
}
|
|
3496
3496
|
for (const t of this.props.filters) {
|
|
3497
|
-
for (const id of (
|
|
3497
|
+
for (const id of (_a2 = t.includes) != null ? _a2 : []) {
|
|
3498
3498
|
edges.push({ from: t.id, to: id, kind: "include" });
|
|
3499
3499
|
}
|
|
3500
3500
|
for (const id of (_b = t.excludes) != null ? _b : []) {
|
|
@@ -3504,9 +3504,9 @@ var BuilderImpl = class {
|
|
|
3504
3504
|
const incMap = (_c = this.props.includes_for_buttons) != null ? _c : {};
|
|
3505
3505
|
const excMap = (_d = this.props.excludes_for_buttons) != null ? _d : {};
|
|
3506
3506
|
const pushButtonEdge = (keyId, targetFieldId, kind) => {
|
|
3507
|
-
var
|
|
3507
|
+
var _a3;
|
|
3508
3508
|
const owner = this.optionOwnerById.get(keyId);
|
|
3509
|
-
const ownerFieldId = (
|
|
3509
|
+
const ownerFieldId = (_a3 = owner == null ? void 0 : owner.fieldId) != null ? _a3 : this.fieldById.has(keyId) ? keyId : void 0;
|
|
3510
3510
|
if (!ownerFieldId) return;
|
|
3511
3511
|
const fromNode = owner && showSet.has(owner.fieldId) ? keyId : ownerFieldId;
|
|
3512
3512
|
const meta = owner ? showSet.has(owner.fieldId) ? {
|
|
@@ -3532,14 +3532,14 @@ var BuilderImpl = class {
|
|
|
3532
3532
|
return { nodes, edges };
|
|
3533
3533
|
}
|
|
3534
3534
|
cleanedProps() {
|
|
3535
|
-
var
|
|
3535
|
+
var _a2, _b, _c, _d, _e;
|
|
3536
3536
|
const fieldIds = new Set(this.props.fields.map((f) => f.id));
|
|
3537
3537
|
const optionIds = /* @__PURE__ */ new Set();
|
|
3538
3538
|
this.optionOwnerById.forEach((_v, oid) => optionIds.add(oid));
|
|
3539
3539
|
const includedByTag = /* @__PURE__ */ new Set();
|
|
3540
3540
|
const excludedAnywhere = /* @__PURE__ */ new Set();
|
|
3541
3541
|
for (const t of this.props.filters) {
|
|
3542
|
-
for (const id of (
|
|
3542
|
+
for (const id of (_a2 = t.includes) != null ? _a2 : []) includedByTag.add(id);
|
|
3543
3543
|
for (const id of (_b = t.excludes) != null ? _b : []) excludedAnywhere.add(id);
|
|
3544
3544
|
}
|
|
3545
3545
|
const incMap = (_c = this.props.includes_for_buttons) != null ? _c : {};
|
|
@@ -3570,8 +3570,8 @@ var BuilderImpl = class {
|
|
|
3570
3570
|
else if (typeof b === "string") boundIds.add(b);
|
|
3571
3571
|
}
|
|
3572
3572
|
const fields = this.props.fields.filter((f) => {
|
|
3573
|
-
var
|
|
3574
|
-
const isUtility = ((
|
|
3573
|
+
var _a3;
|
|
3574
|
+
const isUtility = ((_a3 = f.pricing_role) != null ? _a3 : "base") === "utility";
|
|
3575
3575
|
if (!isUtility) return true;
|
|
3576
3576
|
const bound = !!f.bind_id;
|
|
3577
3577
|
const included = includedByTag.has(f.id) || includedByButtons.has(f.id);
|
|
@@ -3618,10 +3618,10 @@ var BuilderImpl = class {
|
|
|
3618
3618
|
return cloneDeep2(this.options);
|
|
3619
3619
|
}
|
|
3620
3620
|
visibleFields(tagId, selectedKeys) {
|
|
3621
|
-
var
|
|
3621
|
+
var _a2;
|
|
3622
3622
|
return visibleFieldIdsUnder(this.props, tagId, {
|
|
3623
3623
|
selectedKeys: new Set(
|
|
3624
|
-
(
|
|
3624
|
+
(_a2 = selectedKeys != null ? selectedKeys : this.options.selectedOptionKeys) != null ? _a2 : []
|
|
3625
3625
|
)
|
|
3626
3626
|
});
|
|
3627
3627
|
}
|
|
@@ -3659,10 +3659,10 @@ var DEFAULT_SETTINGS = {
|
|
|
3659
3659
|
mode: "strict"
|
|
3660
3660
|
};
|
|
3661
3661
|
function collectFailedFallbacks(props, services, settings) {
|
|
3662
|
-
var
|
|
3662
|
+
var _a2, _b, _c;
|
|
3663
3663
|
const s = { ...DEFAULT_SETTINGS, ...settings != null ? settings : {} };
|
|
3664
3664
|
const out = [];
|
|
3665
|
-
const fb = (
|
|
3665
|
+
const fb = (_a2 = props.fallbacks) != null ? _a2 : {};
|
|
3666
3666
|
const primaryRate = (primary) => rateOf(services, primary);
|
|
3667
3667
|
for (const [nodeId, list] of Object.entries((_b = fb.nodes) != null ? _b : {})) {
|
|
3668
3668
|
const { primary, tagContexts } = primaryForNode(props, nodeId);
|
|
@@ -3770,9 +3770,9 @@ function collectFailedFallbacks(props, services, settings) {
|
|
|
3770
3770
|
return out;
|
|
3771
3771
|
}
|
|
3772
3772
|
function rateOf(map, id) {
|
|
3773
|
-
var
|
|
3773
|
+
var _a2, _b;
|
|
3774
3774
|
if (id === void 0 || id === null) return void 0;
|
|
3775
|
-
return (_b = (
|
|
3775
|
+
return (_b = (_a2 = getCap(map, id)) == null ? void 0 : _a2.rate) != null ? _b : void 0;
|
|
3776
3776
|
}
|
|
3777
3777
|
function passesRate(policy, primaryRate, candidateRate) {
|
|
3778
3778
|
if (typeof candidateRate !== "number" || !Number.isFinite(candidateRate)) {
|
|
@@ -3791,8 +3791,8 @@ function getCap(map, id) {
|
|
|
3791
3791
|
return getServiceCapability(map, id);
|
|
3792
3792
|
}
|
|
3793
3793
|
function isCapFlagEnabled(capability, flagId) {
|
|
3794
|
-
var
|
|
3795
|
-
const fromFlags = (_b = (
|
|
3794
|
+
var _a2, _b;
|
|
3795
|
+
const fromFlags = (_b = (_a2 = capability.flags) == null ? void 0 : _a2[flagId]) == null ? void 0 : _b.enabled;
|
|
3796
3796
|
if (fromFlags === true) return true;
|
|
3797
3797
|
if (fromFlags === false) return false;
|
|
3798
3798
|
const legacy = capability[flagId];
|
|
@@ -3831,8 +3831,8 @@ function bindIdsToArray(bind) {
|
|
|
3831
3831
|
return Array.isArray(bind) ? bind.slice() : [bind];
|
|
3832
3832
|
}
|
|
3833
3833
|
function getEligibleFallbacks(params) {
|
|
3834
|
-
var
|
|
3835
|
-
const s = { ...DEFAULT_SETTINGS, ...(
|
|
3834
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
3835
|
+
const s = { ...DEFAULT_SETTINGS, ...(_a2 = params.settings) != null ? _a2 : {} };
|
|
3836
3836
|
const { primary, nodeId, tagId, services } = params;
|
|
3837
3837
|
const excludes = /* @__PURE__ */ new Set();
|
|
3838
3838
|
for (const ref of (_b = params.exclude) != null ? _b : []) {
|
|
@@ -3878,8 +3878,8 @@ function getEligibleFallbacks(params) {
|
|
|
3878
3878
|
}
|
|
3879
3879
|
if (s.selectionStrategy === "cheapest") {
|
|
3880
3880
|
eligible.sort((left, right) => {
|
|
3881
|
-
var
|
|
3882
|
-
const leftRate = (
|
|
3881
|
+
var _a3, _b2;
|
|
3882
|
+
const leftRate = (_a3 = rateOf(services, left)) != null ? _a3 : Infinity;
|
|
3883
3883
|
const rightRate = (_b2 = rateOf(services, right)) != null ? _b2 : Infinity;
|
|
3884
3884
|
return leftRate - rightRate;
|
|
3885
3885
|
});
|
|
@@ -3890,7 +3890,7 @@ function getEligibleFallbacks(params) {
|
|
|
3890
3890
|
return eligible;
|
|
3891
3891
|
}
|
|
3892
3892
|
function getAssignedServiceIds(params) {
|
|
3893
|
-
var
|
|
3893
|
+
var _a2, _b, _c, _d, _e;
|
|
3894
3894
|
const seen = /* @__PURE__ */ new Set();
|
|
3895
3895
|
const out = [];
|
|
3896
3896
|
const push = (value) => {
|
|
@@ -3902,7 +3902,7 @@ function getAssignedServiceIds(params) {
|
|
|
3902
3902
|
};
|
|
3903
3903
|
const props = params.props;
|
|
3904
3904
|
if (props) {
|
|
3905
|
-
for (const tag of (
|
|
3905
|
+
for (const tag of (_a2 = props.filters) != null ? _a2 : []) {
|
|
3906
3906
|
push(tag.service_id);
|
|
3907
3907
|
}
|
|
3908
3908
|
for (const field of (_b = props.fields) != null ? _b : []) {
|
|
@@ -3934,9 +3934,9 @@ function getFallbackRegistrationInfo(props, nodeId) {
|
|
|
3934
3934
|
return { primary, tagContexts };
|
|
3935
3935
|
}
|
|
3936
3936
|
function listRegisteredFallbackCandidates(fallbacks, primary, nodeId, services) {
|
|
3937
|
-
var
|
|
3937
|
+
var _a2, _b;
|
|
3938
3938
|
const lists = [];
|
|
3939
|
-
if (nodeId && ((
|
|
3939
|
+
if (nodeId && ((_a2 = fallbacks.nodes) == null ? void 0 : _a2[nodeId])) {
|
|
3940
3940
|
lists.push(fallbacks.nodes[nodeId]);
|
|
3941
3941
|
}
|
|
3942
3942
|
for (const [registeredPrimary, list] of Object.entries((_b = fallbacks.global) != null ? _b : {})) {
|
|
@@ -3959,8 +3959,8 @@ function listServicePoolCandidates(services) {
|
|
|
3959
3959
|
return out;
|
|
3960
3960
|
}
|
|
3961
3961
|
function getServicePoolCandidateId(key, capability) {
|
|
3962
|
-
var
|
|
3963
|
-
return (
|
|
3962
|
+
var _a2;
|
|
3963
|
+
return (_a2 = getServiceCapabilityCanonicalRef({ [key]: capability }, key)) != null ? _a2 : key;
|
|
3964
3964
|
}
|
|
3965
3965
|
function addComparableServiceRef(target, services, value) {
|
|
3966
3966
|
for (const ref of getComparableServiceRefs(services, value)) {
|
|
@@ -3995,10 +3995,10 @@ var toBindList = (b) => {
|
|
|
3995
3995
|
return typeof b === "string" ? [b] : [...b];
|
|
3996
3996
|
};
|
|
3997
3997
|
function createNodeIndex(builder) {
|
|
3998
|
-
var
|
|
3998
|
+
var _a2, _b, _c, _d;
|
|
3999
3999
|
const props = builder.getProps();
|
|
4000
4000
|
const nodeMap = builder.getNodeMap();
|
|
4001
|
-
const tags = (
|
|
4001
|
+
const tags = (_a2 = props.filters) != null ? _a2 : [];
|
|
4002
4002
|
const fields = (_b = props.fields) != null ? _b : [];
|
|
4003
4003
|
const tagById = new Map(tags.map((t) => [t.id, t]));
|
|
4004
4004
|
const fieldById = new Map(fields.map((f) => [f.id, f]));
|
|
@@ -4141,12 +4141,12 @@ function createNodeIndex(builder) {
|
|
|
4141
4141
|
}
|
|
4142
4142
|
});
|
|
4143
4143
|
const getTag = (id) => {
|
|
4144
|
-
var
|
|
4144
|
+
var _a3, _b2;
|
|
4145
4145
|
const cached = tagNodeCache.get(id);
|
|
4146
4146
|
if (cached) return cached;
|
|
4147
4147
|
const raw = tagById.get(id);
|
|
4148
4148
|
if (!raw) return void 0;
|
|
4149
|
-
const includes = Object.freeze(new Set((
|
|
4149
|
+
const includes = Object.freeze(new Set((_a3 = raw.includes) != null ? _a3 : []));
|
|
4150
4150
|
const excludes = Object.freeze(new Set((_b2 = raw.excludes) != null ? _b2 : []));
|
|
4151
4151
|
const ancestryFn = makeAncestry([id]);
|
|
4152
4152
|
const node = {
|
|
@@ -4161,17 +4161,17 @@ function createNodeIndex(builder) {
|
|
|
4161
4161
|
return pid ? getTag(pid) : void 0;
|
|
4162
4162
|
},
|
|
4163
4163
|
children() {
|
|
4164
|
-
var
|
|
4164
|
+
var _a4;
|
|
4165
4165
|
const cachedChildren = tagChildrenCache.get(id);
|
|
4166
4166
|
if (cachedChildren) return cachedChildren;
|
|
4167
|
-
const childIds = (
|
|
4167
|
+
const childIds = (_a4 = childrenById.get(id)) != null ? _a4 : [];
|
|
4168
4168
|
const arr = childIds.map((cid) => getTag(cid)).filter(Boolean);
|
|
4169
4169
|
const frozen = Object.freeze(arr);
|
|
4170
4170
|
tagChildrenCache.set(id, frozen);
|
|
4171
4171
|
return frozen;
|
|
4172
4172
|
},
|
|
4173
4173
|
ancestors() {
|
|
4174
|
-
var
|
|
4174
|
+
var _a4;
|
|
4175
4175
|
const cachedAnc = tagAncestorsCache.get(id);
|
|
4176
4176
|
if (cachedAnc) return cachedAnc;
|
|
4177
4177
|
const rows = [];
|
|
@@ -4181,7 +4181,7 @@ function createNodeIndex(builder) {
|
|
|
4181
4181
|
while (cur && !guard.has(cur)) {
|
|
4182
4182
|
const n = getTag(cur);
|
|
4183
4183
|
if (!n) break;
|
|
4184
|
-
const p = (
|
|
4184
|
+
const p = (_a4 = pathBetween(id, cur)) != null ? _a4 : [id, cur];
|
|
4185
4185
|
rows.push({ node: n, direct: index === 1, index, path: p });
|
|
4186
4186
|
guard.add(cur);
|
|
4187
4187
|
cur = parentById.get(cur);
|
|
@@ -4224,13 +4224,13 @@ function createNodeIndex(builder) {
|
|
|
4224
4224
|
return node;
|
|
4225
4225
|
};
|
|
4226
4226
|
const getField = (id) => {
|
|
4227
|
-
var
|
|
4227
|
+
var _a3, _b2, _c2, _d2;
|
|
4228
4228
|
const cached = fieldNodeCache.get(id);
|
|
4229
4229
|
if (cached) return cached;
|
|
4230
4230
|
const raw = fieldById.get(id);
|
|
4231
4231
|
if (!raw) return void 0;
|
|
4232
4232
|
const isButton = raw.button === true;
|
|
4233
|
-
const includes = isButton ? Object.freeze(new Set((_b2 = (
|
|
4233
|
+
const includes = isButton ? Object.freeze(new Set((_b2 = (_a3 = props.includes_for_buttons) == null ? void 0 : _a3[id]) != null ? _b2 : [])) : emptySet;
|
|
4234
4234
|
const excludes = isButton ? Object.freeze(new Set((_d2 = (_c2 = props.excludes_for_buttons) == null ? void 0 : _c2[id]) != null ? _d2 : [])) : emptySet;
|
|
4235
4235
|
const bindIds = () => {
|
|
4236
4236
|
const cachedBind = fieldBindIdsCache.get(id);
|
|
@@ -4276,7 +4276,7 @@ function createNodeIndex(builder) {
|
|
|
4276
4276
|
return node;
|
|
4277
4277
|
};
|
|
4278
4278
|
const getOption = (id) => {
|
|
4279
|
-
var
|
|
4279
|
+
var _a3, _b2, _c2, _d2;
|
|
4280
4280
|
const cached = optionNodeCache.get(id);
|
|
4281
4281
|
if (cached) return cached;
|
|
4282
4282
|
const raw = optionById.get(id);
|
|
@@ -4285,7 +4285,7 @@ function createNodeIndex(builder) {
|
|
|
4285
4285
|
const owner = getField(ownerFieldId);
|
|
4286
4286
|
if (!owner) return void 0;
|
|
4287
4287
|
const includes = Object.freeze(
|
|
4288
|
-
new Set((_b2 = (
|
|
4288
|
+
new Set((_b2 = (_a3 = props.includes_for_buttons) == null ? void 0 : _a3[id]) != null ? _b2 : [])
|
|
4289
4289
|
);
|
|
4290
4290
|
const excludes = Object.freeze(
|
|
4291
4291
|
new Set((_d2 = (_c2 = props.excludes_for_buttons) == null ? void 0 : _c2[id]) != null ? _d2 : [])
|
|
@@ -4320,13 +4320,13 @@ function createNodeIndex(builder) {
|
|
|
4320
4320
|
return node;
|
|
4321
4321
|
};
|
|
4322
4322
|
const getNode2 = (input) => {
|
|
4323
|
-
var
|
|
4323
|
+
var _a3, _b2, _c2;
|
|
4324
4324
|
const id = typeof input === "object" ? input.id : input;
|
|
4325
4325
|
const cached = nodeCache.get(id);
|
|
4326
4326
|
if (cached) return cached;
|
|
4327
4327
|
const node = nodeMap.get(id);
|
|
4328
4328
|
if (!node) return mkUnknown(id);
|
|
4329
|
-
if (node.kind === "tag") return (
|
|
4329
|
+
if (node.kind === "tag") return (_a3 = getTag(id)) != null ? _a3 : mkUnknown(id);
|
|
4330
4330
|
if (node.kind == "field") return (_b2 = getField(id)) != null ? _b2 : mkUnknown(id);
|
|
4331
4331
|
if (node.kind == "option") return (_c2 = getOption(id)) != null ? _c2 : mkUnknown(id);
|
|
4332
4332
|
return mkUnknown(id);
|
|
@@ -4605,8 +4605,8 @@ function compilePolicies(raw) {
|
|
|
4605
4605
|
|
|
4606
4606
|
// src/core/service-filter.ts
|
|
4607
4607
|
function filterServicesForVisibleGroup(input, deps) {
|
|
4608
|
-
var
|
|
4609
|
-
const svcMap = (_c = (_b = (
|
|
4608
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
4609
|
+
const svcMap = (_c = (_b = (_a2 = deps.builder).getServiceMap) == null ? void 0 : _b.call(_a2)) != null ? _c : {};
|
|
4610
4610
|
const builderOptions = (_e = (_d = deps.builder).getOptions) == null ? void 0 : _e.call(_d);
|
|
4611
4611
|
const { context } = input;
|
|
4612
4612
|
const usedSet = new Set(context.usedServiceIds.map(String));
|
|
@@ -4715,7 +4715,7 @@ function evaluatePoliciesRaw(raw, serviceIds, svcMap, tagId, visibleServiceIds)
|
|
|
4715
4715
|
};
|
|
4716
4716
|
}
|
|
4717
4717
|
function evaluateServicePolicies(rules, svcIds, svcMap, tagId, visibleServiceIds) {
|
|
4718
|
-
var
|
|
4718
|
+
var _a2, _b, _c;
|
|
4719
4719
|
const errors = [];
|
|
4720
4720
|
const warnings = [];
|
|
4721
4721
|
if (!rules || !rules.length) return { ok: true, errors, warnings };
|
|
@@ -4766,7 +4766,7 @@ function evaluateServicePolicies(rules, svcIds, svcMap, tagId, visibleServiceIds
|
|
|
4766
4766
|
ok = true;
|
|
4767
4767
|
}
|
|
4768
4768
|
if (!ok) {
|
|
4769
|
-
if (((
|
|
4769
|
+
if (((_a2 = r.severity) != null ? _a2 : "error") === "error") {
|
|
4770
4770
|
errors.push((_b = r.id) != null ? _b : "policy_error");
|
|
4771
4771
|
} else {
|
|
4772
4772
|
warnings.push((_c = r.id) != null ? _c : "policy_warning");
|
|
@@ -4780,10 +4780,10 @@ function scopeServiceIdsForRule(serviceIds, rule, visibleServiceIds) {
|
|
|
4780
4780
|
return serviceIds.filter((id) => visibleServiceIds.has(String(id)));
|
|
4781
4781
|
}
|
|
4782
4782
|
function collectVisibleServiceIds(builder, tagId, selectedButtons) {
|
|
4783
|
-
var
|
|
4783
|
+
var _a2, _b, _c;
|
|
4784
4784
|
const out = /* @__PURE__ */ new Set();
|
|
4785
4785
|
const props = builder.getProps();
|
|
4786
|
-
const tags = (
|
|
4786
|
+
const tags = (_a2 = props.filters) != null ? _a2 : [];
|
|
4787
4787
|
const fields = (_b = props.fields) != null ? _b : [];
|
|
4788
4788
|
const tag = tags.find((t) => t.id === tagId);
|
|
4789
4789
|
if ((tag == null ? void 0 : tag.service_id) != null) out.add(String(tag.service_id));
|
|
@@ -4821,10 +4821,10 @@ function toStrSet(v) {
|
|
|
4821
4821
|
return s;
|
|
4822
4822
|
}
|
|
4823
4823
|
function candidatePassesRateCoherence(builder, serviceMap, tagId, selectedKeys, usedServiceIds, candidateId, ratePolicy) {
|
|
4824
|
-
var
|
|
4824
|
+
var _a2, _b, _c, _d;
|
|
4825
4825
|
if (usedServiceIds.length === 0) return true;
|
|
4826
4826
|
const props = builder.getProps();
|
|
4827
|
-
const baseFields = (
|
|
4827
|
+
const baseFields = (_a2 = props.fields) != null ? _a2 : [];
|
|
4828
4828
|
const candidateFieldId = syntheticServiceFieldId("candidate", candidateId, 0);
|
|
4829
4829
|
const syntheticFields = [
|
|
4830
4830
|
...usedServiceIds.map((serviceId, index) => ({
|
|
@@ -4901,10 +4901,10 @@ function syntheticServiceFieldId(kind, serviceId, index) {
|
|
|
4901
4901
|
return `__service_filter_${kind}__:${index}:${String(serviceId)}`;
|
|
4902
4902
|
}
|
|
4903
4903
|
function rateIssueAffectsCandidate(error, candidateId, candidateFieldId, primaryAnchorId) {
|
|
4904
|
-
var
|
|
4904
|
+
var _a2, _b, _c, _d;
|
|
4905
4905
|
if (error.code !== "rate_coherence_violation") return false;
|
|
4906
4906
|
const candidateKey = String(candidateId);
|
|
4907
|
-
const details = (
|
|
4907
|
+
const details = (_a2 = error.details) != null ? _a2 : {};
|
|
4908
4908
|
const anchorKey = primaryAnchorId == null ? void 0 : String(primaryAnchorId);
|
|
4909
4909
|
const primaryMatchesAnchor = anchorKey == null || String((_b = details.primary) == null ? void 0 : _b.serviceId) === anchorKey || String((_c = details.primary) == null ? void 0 : _c.service_id) === anchorKey;
|
|
4910
4910
|
if (primaryMatchesAnchor && ((_d = details.affectedServiceIds) == null ? void 0 : _d.some(
|
|
@@ -4924,7 +4924,7 @@ function rateIssueAffectsCandidate(error, candidateId, candidateFieldId, primary
|
|
|
4924
4924
|
|
|
4925
4925
|
// src/utils/prune-fallbacks.ts
|
|
4926
4926
|
function pruneInvalidNodeFallbacks(props, services, settings) {
|
|
4927
|
-
var
|
|
4927
|
+
var _a2, _b;
|
|
4928
4928
|
const fb = props.fallbacks;
|
|
4929
4929
|
if (!(fb == null ? void 0 : fb.nodes) || Object.keys(fb.nodes).length === 0) {
|
|
4930
4930
|
return { props, removed: [] };
|
|
@@ -4969,7 +4969,7 @@ function pruneInvalidNodeFallbacks(props, services, settings) {
|
|
|
4969
4969
|
const prunedNodes = {};
|
|
4970
4970
|
const removed = [];
|
|
4971
4971
|
for (const [nodeId, list] of Object.entries(fb.nodes)) {
|
|
4972
|
-
const contexts = (
|
|
4972
|
+
const contexts = (_a2 = nodeContexts.get(nodeId)) != null ? _a2 : [];
|
|
4973
4973
|
const totalContexts = Math.max(1, contexts.length);
|
|
4974
4974
|
const keep = [];
|
|
4975
4975
|
for (const cand of list) {
|
|
@@ -5010,8 +5010,8 @@ function toBindArray(bind) {
|
|
|
5010
5010
|
|
|
5011
5011
|
// src/utils/build-order-snapshot.ts
|
|
5012
5012
|
function buildOrderSnapshot(props, builder, selection, services, settings = {}) {
|
|
5013
|
-
var
|
|
5014
|
-
const mode = (
|
|
5013
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
5014
|
+
const mode = (_a2 = settings.mode) != null ? _a2 : "prod";
|
|
5015
5015
|
const hostDefaultQty = Number.isFinite(
|
|
5016
5016
|
(_b = settings.hostDefaultQuantity) != null ? _b : 1
|
|
5017
5017
|
) ? settings.hostDefaultQuantity : 1;
|
|
@@ -5037,8 +5037,8 @@ function buildOrderSnapshot(props, builder, selection, services, settings = {})
|
|
|
5037
5037
|
);
|
|
5038
5038
|
const tagConstraints = (_h = (_g = tagById.get(tagId)) == null ? void 0 : _g.constraints) != null ? _h : void 0;
|
|
5039
5039
|
const selectionFields = visibleFieldIds.map((fid) => fieldById.get(fid)).filter((f) => !!f).map((f) => {
|
|
5040
|
-
var
|
|
5041
|
-
const optIds = isOptionBased(f) ? (
|
|
5040
|
+
var _a3;
|
|
5041
|
+
const optIds = isOptionBased(f) ? (_a3 = selection.optionSelectionsByFieldId[f.id]) != null ? _a3 : [] : void 0;
|
|
5042
5042
|
return {
|
|
5043
5043
|
id: f.id,
|
|
5044
5044
|
type: String(f.type),
|
|
@@ -5180,12 +5180,12 @@ function buildInputs(visibleFieldIds, fieldById, selection) {
|
|
|
5180
5180
|
return { formValues, selections };
|
|
5181
5181
|
}
|
|
5182
5182
|
function resolveQuantity(visibleFieldIds, fieldById, tagById, selection, tagId, hostDefault) {
|
|
5183
|
-
var
|
|
5183
|
+
var _a2;
|
|
5184
5184
|
for (const fid of visibleFieldIds) {
|
|
5185
5185
|
const f = fieldById.get(fid);
|
|
5186
5186
|
if (!f) continue;
|
|
5187
5187
|
const rule = readQuantityRule(
|
|
5188
|
-
(
|
|
5188
|
+
(_a2 = f.meta) == null ? void 0 : _a2.quantity
|
|
5189
5189
|
);
|
|
5190
5190
|
if (!rule) continue;
|
|
5191
5191
|
const raw = selection.formValuesByFieldId[fid];
|
|
@@ -5295,12 +5295,12 @@ function applyClamp(value, clamp2) {
|
|
|
5295
5295
|
return next;
|
|
5296
5296
|
}
|
|
5297
5297
|
function resolveNodeDefaultQuantity(visibleFieldIds, fieldById, tagById, selection, tagId) {
|
|
5298
|
-
var
|
|
5298
|
+
var _a2, _b, _c, _d;
|
|
5299
5299
|
const optionVisit = buildOptionVisitOrder(selection, fieldById);
|
|
5300
5300
|
for (const { fieldId, optionId } of optionVisit) {
|
|
5301
5301
|
if (!visibleFieldIds.includes(fieldId)) continue;
|
|
5302
5302
|
const field = fieldById.get(fieldId);
|
|
5303
|
-
const option = (
|
|
5303
|
+
const option = (_a2 = field == null ? void 0 : field.options) == null ? void 0 : _a2.find((item) => item.id === optionId);
|
|
5304
5304
|
const quantityDefault = readQuantityDefault(
|
|
5305
5305
|
(_b = option == null ? void 0 : option.meta) == null ? void 0 : _b.quantityDefault
|
|
5306
5306
|
);
|
|
@@ -5341,7 +5341,7 @@ function readQuantityDefault(value) {
|
|
|
5341
5341
|
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
|
|
5342
5342
|
}
|
|
5343
5343
|
function resolveServices(tagId, visibleFieldIds, selection, tagById, fieldById) {
|
|
5344
|
-
var
|
|
5344
|
+
var _a2;
|
|
5345
5345
|
const serviceMap = {};
|
|
5346
5346
|
const ordered = [];
|
|
5347
5347
|
const tag = tagById.get(tagId);
|
|
@@ -5358,7 +5358,7 @@ function resolveServices(tagId, visibleFieldIds, selection, tagById, fieldById)
|
|
|
5358
5358
|
if (!f || !Array.isArray(f.options)) continue;
|
|
5359
5359
|
const opt = f.options.find((o) => o.id === optionId);
|
|
5360
5360
|
if (!opt) continue;
|
|
5361
|
-
const role = (
|
|
5361
|
+
const role = (_a2 = opt.pricing_role) != null ? _a2 : "base";
|
|
5362
5362
|
const sid = opt.service_id;
|
|
5363
5363
|
if (role === "utility") continue;
|
|
5364
5364
|
if (sid !== void 0) {
|
|
@@ -5382,13 +5382,13 @@ function resolveServices(tagId, visibleFieldIds, selection, tagById, fieldById)
|
|
|
5382
5382
|
return { serviceMap, servicesList };
|
|
5383
5383
|
}
|
|
5384
5384
|
function buildOptionVisitOrder(selection, fieldById) {
|
|
5385
|
-
var
|
|
5385
|
+
var _a2;
|
|
5386
5386
|
if (selection.optionTraversalOrder && selection.optionTraversalOrder.length) {
|
|
5387
5387
|
return selection.optionTraversalOrder.slice();
|
|
5388
5388
|
}
|
|
5389
5389
|
const out = [];
|
|
5390
5390
|
for (const [fid, optIds] of Object.entries(
|
|
5391
|
-
(
|
|
5391
|
+
(_a2 = selection.optionSelectionsByFieldId) != null ? _a2 : {}
|
|
5392
5392
|
)) {
|
|
5393
5393
|
const f = fieldById.get(fid);
|
|
5394
5394
|
if (!f) continue;
|
|
@@ -5413,7 +5413,7 @@ function dedupeByString(arr) {
|
|
|
5413
5413
|
return out;
|
|
5414
5414
|
}
|
|
5415
5415
|
function pruneFallbacksConservative(fallbacks, env, svcMap, policy) {
|
|
5416
|
-
var
|
|
5416
|
+
var _a2, _b;
|
|
5417
5417
|
if (!fallbacks) return { pruned: void 0, original: void 0 };
|
|
5418
5418
|
try {
|
|
5419
5419
|
const { props: prunedProps } = pruneInvalidNodeFallbacks(
|
|
@@ -5432,7 +5432,7 @@ function pruneFallbacksConservative(fallbacks, env, svcMap, policy) {
|
|
|
5432
5432
|
};
|
|
5433
5433
|
} catch {
|
|
5434
5434
|
const out = {};
|
|
5435
|
-
const requireFit = (
|
|
5435
|
+
const requireFit = (_a2 = policy.requireConstraintFit) != null ? _a2 : true;
|
|
5436
5436
|
if (fallbacks.nodes) {
|
|
5437
5437
|
const keptNodes = {};
|
|
5438
5438
|
for (const [nodeId, candidates] of Object.entries(
|
|
@@ -5481,12 +5481,12 @@ function isFiniteNumber2(v) {
|
|
|
5481
5481
|
return typeof v === "number" && Number.isFinite(v);
|
|
5482
5482
|
}
|
|
5483
5483
|
function collectUtilityLineItems(visibleFieldIds, fieldById, selection, quantity) {
|
|
5484
|
-
var
|
|
5484
|
+
var _a2, _b, _c, _d, _e;
|
|
5485
5485
|
const items = [];
|
|
5486
5486
|
for (const fid of visibleFieldIds) {
|
|
5487
5487
|
const f = fieldById.get(fid);
|
|
5488
5488
|
if (!f) continue;
|
|
5489
|
-
const isUtilityField = ((
|
|
5489
|
+
const isUtilityField = ((_a2 = f.pricing_role) != null ? _a2 : "base") === "utility";
|
|
5490
5490
|
const marker = readUtilityMarker((_b = f.meta) == null ? void 0 : _b.utility);
|
|
5491
5491
|
if (isUtilityField && marker) {
|
|
5492
5492
|
const val = selection.formValuesByFieldId[f.id];
|
|
@@ -5543,7 +5543,7 @@ function readUtilityMarker(v) {
|
|
|
5543
5543
|
return out;
|
|
5544
5544
|
}
|
|
5545
5545
|
function buildUtilityItemFromMarker(nodeId, marker, quantity, value) {
|
|
5546
|
-
var
|
|
5546
|
+
var _a2, _b;
|
|
5547
5547
|
const base = {
|
|
5548
5548
|
nodeId,
|
|
5549
5549
|
mode: marker.mode,
|
|
@@ -5553,7 +5553,7 @@ function buildUtilityItemFromMarker(nodeId, marker, quantity, value) {
|
|
|
5553
5553
|
inputs: { quantity }
|
|
5554
5554
|
};
|
|
5555
5555
|
if (marker.mode === "per_value") {
|
|
5556
|
-
base.inputs.valueBy = (
|
|
5556
|
+
base.inputs.valueBy = (_a2 = marker.valueBy) != null ? _a2 : "value";
|
|
5557
5557
|
if (marker.valueBy === "length") {
|
|
5558
5558
|
base.inputs.value = Array.isArray(value) ? value.length : typeof value === "string" ? value.length : 0;
|
|
5559
5559
|
} else {
|
|
@@ -5563,7 +5563,7 @@ function buildUtilityItemFromMarker(nodeId, marker, quantity, value) {
|
|
|
5563
5563
|
return base;
|
|
5564
5564
|
}
|
|
5565
5565
|
function buildNodeContexts(tagId, visibleFieldIds, fieldById, selection) {
|
|
5566
|
-
var
|
|
5566
|
+
var _a2;
|
|
5567
5567
|
const ctx = {};
|
|
5568
5568
|
ctx[tagId] = tagId;
|
|
5569
5569
|
for (const fid of visibleFieldIds) {
|
|
@@ -5571,7 +5571,7 @@ function buildNodeContexts(tagId, visibleFieldIds, fieldById, selection) {
|
|
|
5571
5571
|
if (!f) continue;
|
|
5572
5572
|
const binds = normalizeBindIds(f.bind_id);
|
|
5573
5573
|
const applicable = binds.has(tagId);
|
|
5574
|
-
const selectedOptIds = (
|
|
5574
|
+
const selectedOptIds = (_a2 = selection.optionSelectionsByFieldId[fid]) != null ? _a2 : [];
|
|
5575
5575
|
for (const oid of selectedOptIds) {
|
|
5576
5576
|
ctx[oid] = applicable ? tagId : null;
|
|
5577
5577
|
}
|
|
@@ -5626,8 +5626,8 @@ function buildDevWarnings(props, svcMap, _tagId, _snapshotServiceMap, originalFa
|
|
|
5626
5626
|
return out;
|
|
5627
5627
|
}
|
|
5628
5628
|
function toSnapshotPolicy(settings) {
|
|
5629
|
-
var
|
|
5630
|
-
const requireConstraintFit = (
|
|
5629
|
+
var _a2;
|
|
5630
|
+
const requireConstraintFit = (_a2 = settings.requireConstraintFit) != null ? _a2 : true;
|
|
5631
5631
|
const rp = normalizeRatePolicy(settings.ratePolicy);
|
|
5632
5632
|
return { ratePolicy: rp, requireConstraintFit };
|
|
5633
5633
|
}
|
|
@@ -5652,12 +5652,12 @@ function resolveMinMax(servicesList, services) {
|
|
|
5652
5652
|
|
|
5653
5653
|
// src/core/fallback-editor.ts
|
|
5654
5654
|
function createFallbackEditor(options = {}) {
|
|
5655
|
-
var
|
|
5655
|
+
var _a2, _b;
|
|
5656
5656
|
const original = cloneFallbacks(options.fallbacks);
|
|
5657
5657
|
let current = cloneFallbacks(options.fallbacks);
|
|
5658
5658
|
const props = options.props;
|
|
5659
5659
|
const snapshot = options.snapshot;
|
|
5660
|
-
const services = (
|
|
5660
|
+
const services = (_a2 = options.services) != null ? _a2 : {};
|
|
5661
5661
|
const settings = (_b = options.settings) != null ? _b : {};
|
|
5662
5662
|
function state() {
|
|
5663
5663
|
return {
|
|
@@ -5674,9 +5674,9 @@ function createFallbackEditor(options = {}) {
|
|
|
5674
5674
|
return state();
|
|
5675
5675
|
}
|
|
5676
5676
|
function get(serviceId) {
|
|
5677
|
-
var
|
|
5677
|
+
var _a3, _b2;
|
|
5678
5678
|
const out = [];
|
|
5679
|
-
for (const [primary, list] of Object.entries((
|
|
5679
|
+
for (const [primary, list] of Object.entries((_a3 = current.global) != null ? _a3 : {})) {
|
|
5680
5680
|
if (String(primary) !== String(serviceId)) continue;
|
|
5681
5681
|
out.push({
|
|
5682
5682
|
scope: "global",
|
|
@@ -5698,14 +5698,14 @@ function createFallbackEditor(options = {}) {
|
|
|
5698
5698
|
return out;
|
|
5699
5699
|
}
|
|
5700
5700
|
function getScope(context) {
|
|
5701
|
-
var
|
|
5701
|
+
var _a3, _b2, _c, _d;
|
|
5702
5702
|
if (context.scope === "global") {
|
|
5703
|
-
return [...(_b2 = (
|
|
5703
|
+
return [...(_b2 = (_a3 = current.global) == null ? void 0 : _a3[context.primary]) != null ? _b2 : []];
|
|
5704
5704
|
}
|
|
5705
5705
|
return [...(_d = (_c = current.nodes) == null ? void 0 : _c[context.nodeId]) != null ? _d : []];
|
|
5706
5706
|
}
|
|
5707
5707
|
function check(context, candidates) {
|
|
5708
|
-
var
|
|
5708
|
+
var _a3, _b2;
|
|
5709
5709
|
const normalized = normalizeCandidateList(
|
|
5710
5710
|
candidates != null ? candidates : getScope(context),
|
|
5711
5711
|
true
|
|
@@ -5724,7 +5724,7 @@ function createFallbackEditor(options = {}) {
|
|
|
5724
5724
|
}
|
|
5725
5725
|
const tempFallbacks = cloneFallbacks(current);
|
|
5726
5726
|
if (context.scope === "global") {
|
|
5727
|
-
(
|
|
5727
|
+
(_a3 = tempFallbacks.global) != null ? _a3 : tempFallbacks.global = {};
|
|
5728
5728
|
if (normalized.length)
|
|
5729
5729
|
tempFallbacks.global[context.primary] = normalized;
|
|
5730
5730
|
else delete tempFallbacks.global[context.primary];
|
|
@@ -5843,9 +5843,9 @@ function createFallbackEditor(options = {}) {
|
|
|
5843
5843
|
return writeScope(context, []);
|
|
5844
5844
|
}
|
|
5845
5845
|
function eligible(context, opt) {
|
|
5846
|
-
var
|
|
5846
|
+
var _a3, _b2;
|
|
5847
5847
|
if (!props) return [];
|
|
5848
|
-
const source = (
|
|
5848
|
+
const source = (_a3 = opt == null ? void 0 : opt.source) != null ? _a3 : "all_services";
|
|
5849
5849
|
const exclude2 = normalizeCandidateList(
|
|
5850
5850
|
[
|
|
5851
5851
|
...(_b2 = opt == null ? void 0 : opt.exclude) != null ? _b2 : [],
|
|
@@ -5890,10 +5890,10 @@ function createFallbackEditor(options = {}) {
|
|
|
5890
5890
|
});
|
|
5891
5891
|
}
|
|
5892
5892
|
function writeScope(context, nextList) {
|
|
5893
|
-
var
|
|
5893
|
+
var _a3, _b2;
|
|
5894
5894
|
const next = cloneFallbacks(current);
|
|
5895
5895
|
if (context.scope === "global") {
|
|
5896
|
-
(
|
|
5896
|
+
(_a3 = next.global) != null ? _a3 : next.global = {};
|
|
5897
5897
|
if (nextList.length) {
|
|
5898
5898
|
next.global[context.primary] = [...nextList];
|
|
5899
5899
|
} else {
|
|
@@ -5983,9 +5983,9 @@ function getNodeRegistrationInfo(props, nodeId) {
|
|
|
5983
5983
|
};
|
|
5984
5984
|
}
|
|
5985
5985
|
function findOptionOwner(fields, optionId) {
|
|
5986
|
-
var
|
|
5986
|
+
var _a2;
|
|
5987
5987
|
for (const field of fields) {
|
|
5988
|
-
for (const option of (
|
|
5988
|
+
for (const option of (_a2 = field.options) != null ? _a2 : []) {
|
|
5989
5989
|
if (option.id === optionId) return { field, option };
|
|
5990
5990
|
}
|
|
5991
5991
|
}
|
|
@@ -5996,8 +5996,8 @@ function bindIdsToArray2(v) {
|
|
|
5996
5996
|
return v ? [v] : [];
|
|
5997
5997
|
}
|
|
5998
5998
|
function resolveNodeTagContext(params) {
|
|
5999
|
-
var
|
|
6000
|
-
const nodeContexts = (_c = (_b = (
|
|
5999
|
+
var _a2, _b, _c;
|
|
6000
|
+
const nodeContexts = (_c = (_b = (_a2 = params.snapshot) == null ? void 0 : _a2.meta) == null ? void 0 : _b.context) == null ? void 0 : _c.nodeContexts;
|
|
6001
6001
|
if (nodeContexts && Object.prototype.hasOwnProperty.call(nodeContexts, params.nodeId)) {
|
|
6002
6002
|
const tagId = nodeContexts[params.nodeId];
|
|
6003
6003
|
return typeof tagId === "string" && tagId.trim().length > 0 ? tagId : void 0;
|
|
@@ -6025,10 +6025,10 @@ function mapDiagReason(reason) {
|
|
|
6025
6025
|
|
|
6026
6026
|
// src/react/canvas/editor/editor-ids.ts
|
|
6027
6027
|
function uniqueId(ctx, base) {
|
|
6028
|
-
var
|
|
6028
|
+
var _a2, _b;
|
|
6029
6029
|
const props = ctx.getProps();
|
|
6030
6030
|
const taken = /* @__PURE__ */ new Set([
|
|
6031
|
-
...((
|
|
6031
|
+
...((_a2 = props.filters) != null ? _a2 : []).map((t) => t.id),
|
|
6032
6032
|
...((_b = props.fields) != null ? _b : []).map((f) => f.id)
|
|
6033
6033
|
]);
|
|
6034
6034
|
let candidate = nextCopyId(base);
|
|
@@ -6036,9 +6036,9 @@ function uniqueId(ctx, base) {
|
|
|
6036
6036
|
return candidate;
|
|
6037
6037
|
}
|
|
6038
6038
|
function uniqueOptionId(ctx, fieldId, base) {
|
|
6039
|
-
var
|
|
6039
|
+
var _a2, _b;
|
|
6040
6040
|
const props = ctx.getProps();
|
|
6041
|
-
const fld = ((
|
|
6041
|
+
const fld = ((_a2 = props.fields) != null ? _a2 : []).find((f) => f.id === fieldId);
|
|
6042
6042
|
const taken = new Set(((_b = fld == null ? void 0 : fld.options) != null ? _b : []).map((o) => o.id));
|
|
6043
6043
|
let candidate = base;
|
|
6044
6044
|
if (taken.has(candidate)) candidate = nextCopyId(candidate);
|
|
@@ -6046,14 +6046,14 @@ function uniqueOptionId(ctx, fieldId, base) {
|
|
|
6046
6046
|
return candidate;
|
|
6047
6047
|
}
|
|
6048
6048
|
function genId(ctx, prefix) {
|
|
6049
|
-
var
|
|
6049
|
+
var _a2, _b, _c;
|
|
6050
6050
|
const props = ctx.getProps();
|
|
6051
6051
|
const taken = /* @__PURE__ */ new Set([
|
|
6052
|
-
...((
|
|
6052
|
+
...((_a2 = props.filters) != null ? _a2 : []).map((t) => t.id),
|
|
6053
6053
|
...((_b = props.fields) != null ? _b : []).map((f) => f.id),
|
|
6054
6054
|
...((_c = props.fields) != null ? _c : []).flatMap((f) => {
|
|
6055
|
-
var
|
|
6056
|
-
return (_b2 = (
|
|
6055
|
+
var _a3, _b2;
|
|
6056
|
+
return (_b2 = (_a3 = f.options) == null ? void 0 : _a3.map((o) => o.id)) != null ? _b2 : [];
|
|
6057
6057
|
})
|
|
6058
6058
|
]);
|
|
6059
6059
|
for (let i = 1; i < 1e4; i++) {
|
|
@@ -6100,13 +6100,7 @@ function duplicate(ctx, ref, opts = {}) {
|
|
|
6100
6100
|
try {
|
|
6101
6101
|
let newId = "";
|
|
6102
6102
|
ctx.transact("duplicate", () => {
|
|
6103
|
-
|
|
6104
|
-
newId = duplicateTag(ctx, ref.id, opts);
|
|
6105
|
-
} else if (ref.kind === "field") {
|
|
6106
|
-
newId = duplicateField(ctx, ref.id, opts);
|
|
6107
|
-
} else {
|
|
6108
|
-
newId = duplicateOption(ctx, ref.fieldId, ref.id, opts);
|
|
6109
|
-
}
|
|
6103
|
+
newId = duplicateInPlace(ctx, ref, opts);
|
|
6110
6104
|
});
|
|
6111
6105
|
return newId;
|
|
6112
6106
|
} catch (err) {
|
|
@@ -6114,22 +6108,90 @@ function duplicate(ctx, ref, opts = {}) {
|
|
|
6114
6108
|
throw err;
|
|
6115
6109
|
}
|
|
6116
6110
|
}
|
|
6111
|
+
function duplicateMany(ctx, ids, opts = {}) {
|
|
6112
|
+
const ordered = Array.from(new Set((ids != null ? ids : []).map((id) => String(id))));
|
|
6113
|
+
if (!ordered.length) return [];
|
|
6114
|
+
const snapBefore = ctx.makeSnapshot("duplicateMany:before");
|
|
6115
|
+
try {
|
|
6116
|
+
const created = [];
|
|
6117
|
+
ctx.transact("duplicateMany", () => {
|
|
6118
|
+
var _a2, _b, _c;
|
|
6119
|
+
const props = ctx.getProps();
|
|
6120
|
+
const selectedFields = /* @__PURE__ */ new Set();
|
|
6121
|
+
for (const id of ordered) {
|
|
6122
|
+
if (ctx.isFieldId(id) && ((_a2 = props.fields) != null ? _a2 : []).some((f) => f.id === id)) {
|
|
6123
|
+
selectedFields.add(id);
|
|
6124
|
+
}
|
|
6125
|
+
}
|
|
6126
|
+
for (const id of ordered) {
|
|
6127
|
+
if (ctx.isTagId(id)) {
|
|
6128
|
+
if (!((_b = ctx.getProps().filters) != null ? _b : []).some((t) => t.id === id)) continue;
|
|
6129
|
+
created.push(
|
|
6130
|
+
duplicateInPlace(ctx, { kind: "tag", id }, opts)
|
|
6131
|
+
);
|
|
6132
|
+
continue;
|
|
6133
|
+
}
|
|
6134
|
+
if (ctx.isFieldId(id)) {
|
|
6135
|
+
if (!((_c = ctx.getProps().fields) != null ? _c : []).some((f) => f.id === id)) continue;
|
|
6136
|
+
created.push(
|
|
6137
|
+
duplicateInPlace(ctx, { kind: "field", id }, opts)
|
|
6138
|
+
);
|
|
6139
|
+
continue;
|
|
6140
|
+
}
|
|
6141
|
+
if (ctx.isOptionId(id)) {
|
|
6142
|
+
const owner = ownerFieldOfOption(ctx.getProps(), id);
|
|
6143
|
+
if (!owner) continue;
|
|
6144
|
+
if (selectedFields.has(owner.fieldId)) continue;
|
|
6145
|
+
created.push(
|
|
6146
|
+
duplicateInPlace(
|
|
6147
|
+
ctx,
|
|
6148
|
+
{ kind: "option", fieldId: owner.fieldId, id },
|
|
6149
|
+
opts
|
|
6150
|
+
)
|
|
6151
|
+
);
|
|
6152
|
+
}
|
|
6153
|
+
}
|
|
6154
|
+
});
|
|
6155
|
+
return created;
|
|
6156
|
+
} catch (err) {
|
|
6157
|
+
ctx.loadSnapshot(snapBefore, "undo");
|
|
6158
|
+
throw err;
|
|
6159
|
+
}
|
|
6160
|
+
}
|
|
6161
|
+
function duplicateInPlace(ctx, ref, opts = {}) {
|
|
6162
|
+
if (ref.kind === "tag") {
|
|
6163
|
+
return duplicateTag(ctx, ref.id, opts);
|
|
6164
|
+
}
|
|
6165
|
+
if (ref.kind === "field") {
|
|
6166
|
+
return duplicateField(ctx, ref.id, opts);
|
|
6167
|
+
}
|
|
6168
|
+
return duplicateOption(ctx, ref.fieldId, ref.id, opts);
|
|
6169
|
+
}
|
|
6170
|
+
function ownerFieldOfOption(props, optionId) {
|
|
6171
|
+
var _a2, _b;
|
|
6172
|
+
for (const field of (_a2 = props.fields) != null ? _a2 : []) {
|
|
6173
|
+
if (((_b = field.options) != null ? _b : []).some((o) => o.id === optionId)) {
|
|
6174
|
+
return { fieldId: field.id };
|
|
6175
|
+
}
|
|
6176
|
+
}
|
|
6177
|
+
return null;
|
|
6178
|
+
}
|
|
6117
6179
|
function duplicateTag(ctx, tagId, opts) {
|
|
6118
|
-
var
|
|
6180
|
+
var _a2, _b, _c, _d;
|
|
6119
6181
|
const props = ctx.getProps();
|
|
6120
|
-
const tags = (
|
|
6182
|
+
const tags = (_a2 = props.filters) != null ? _a2 : [];
|
|
6121
6183
|
const src = tags.find((t) => t.id === tagId);
|
|
6122
6184
|
if (!src) throw new Error(`Tag not found: ${tagId}`);
|
|
6123
6185
|
const id = (_b = opts.id) != null ? _b : ctx.uniqueId(src.id);
|
|
6124
6186
|
const label = ((_c = opts.labelStrategy) != null ? _c : nextCopyLabel)((_d = src.label) != null ? _d : id);
|
|
6125
6187
|
if (!opts.withChildren) {
|
|
6126
6188
|
ctx.patchProps((p) => {
|
|
6127
|
-
var
|
|
6189
|
+
var _a3;
|
|
6128
6190
|
const clone2 = { ...src, id, label };
|
|
6129
6191
|
clone2.bind_id = src.bind_id;
|
|
6130
6192
|
clone2.constraints_overrides = void 0;
|
|
6131
6193
|
clone2.constraints_origin = void 0;
|
|
6132
|
-
const arr = (
|
|
6194
|
+
const arr = (_a3 = p.filters) != null ? _a3 : [];
|
|
6133
6195
|
const idx = arr.findIndex((t) => t.id === tagId);
|
|
6134
6196
|
arr.splice(idx + 1, 0, clone2);
|
|
6135
6197
|
p.filters = arr;
|
|
@@ -6149,18 +6211,18 @@ function duplicateTag(ctx, tagId, opts) {
|
|
|
6149
6211
|
idMap.set(n.id, n.id === src.id ? id : ctx.uniqueId(n.id));
|
|
6150
6212
|
}
|
|
6151
6213
|
const clones = subtree.map((n) => {
|
|
6152
|
-
var
|
|
6214
|
+
var _a3, _b2, _c2;
|
|
6153
6215
|
const cloned = { ...n };
|
|
6154
6216
|
cloned.id = idMap.get(n.id);
|
|
6155
|
-
cloned.label = n.id === src.id ? label : ((
|
|
6217
|
+
cloned.label = n.id === src.id ? label : ((_a3 = opts.labelStrategy) != null ? _a3 : nextCopyLabel)((_b2 = n.label) != null ? _b2 : n.id);
|
|
6156
6218
|
cloned.bind_id = n.bind_id ? (_c2 = idMap.get(n.bind_id)) != null ? _c2 : n.bind_id : void 0;
|
|
6157
6219
|
cloned.constraints_origin = void 0;
|
|
6158
6220
|
cloned.constraints_overrides = void 0;
|
|
6159
6221
|
return cloned;
|
|
6160
6222
|
});
|
|
6161
6223
|
ctx.patchProps((p) => {
|
|
6162
|
-
var
|
|
6163
|
-
const arr = (
|
|
6224
|
+
var _a3;
|
|
6225
|
+
const arr = (_a3 = p.filters) != null ? _a3 : [];
|
|
6164
6226
|
const rootIdx = arr.findIndex((t) => t.id === tagId);
|
|
6165
6227
|
arr.splice(rootIdx + 1, 0, clones[0]);
|
|
6166
6228
|
for (const c of clones.slice(1)) arr.push(c);
|
|
@@ -6169,27 +6231,27 @@ function duplicateTag(ctx, tagId, opts) {
|
|
|
6169
6231
|
return id;
|
|
6170
6232
|
}
|
|
6171
6233
|
function duplicateField(ctx, fieldId, opts) {
|
|
6172
|
-
var
|
|
6234
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
6173
6235
|
const props = ctx.getProps();
|
|
6174
|
-
const fields = (
|
|
6236
|
+
const fields = (_a2 = props.fields) != null ? _a2 : [];
|
|
6175
6237
|
const src = fields.find((f) => f.id === fieldId);
|
|
6176
6238
|
if (!src) throw new Error(`Field not found: ${fieldId}`);
|
|
6177
6239
|
const id = (_b = opts.id) != null ? _b : ctx.uniqueId(src.id);
|
|
6178
6240
|
const label = ((_c = opts.labelStrategy) != null ? _c : nextCopyLabel)((_d = src.label) != null ? _d : id);
|
|
6179
6241
|
const name = opts.nameStrategy ? opts.nameStrategy(src.name) : nextCopyName(src.name);
|
|
6180
6242
|
const optId = (old) => {
|
|
6181
|
-
var
|
|
6243
|
+
var _a3;
|
|
6182
6244
|
return ctx.uniqueOptionId(
|
|
6183
6245
|
id,
|
|
6184
|
-
((
|
|
6246
|
+
((_a3 = opts.optionIdStrategy) != null ? _a3 : defaultOptionIdStrategy)(old)
|
|
6185
6247
|
);
|
|
6186
6248
|
};
|
|
6187
6249
|
const clonedOptions = ((_e = src.options) != null ? _e : []).map((o) => {
|
|
6188
|
-
var
|
|
6250
|
+
var _a3, _b2;
|
|
6189
6251
|
return {
|
|
6190
6252
|
...o,
|
|
6191
6253
|
id: optId(o.id),
|
|
6192
|
-
label: ((
|
|
6254
|
+
label: ((_a3 = opts.labelStrategy) != null ? _a3 : nextCopyLabel)((_b2 = o.label) != null ? _b2 : o.id)
|
|
6193
6255
|
};
|
|
6194
6256
|
});
|
|
6195
6257
|
const cloned = {
|
|
@@ -6202,13 +6264,13 @@ function duplicateField(ctx, fieldId, opts) {
|
|
|
6202
6264
|
};
|
|
6203
6265
|
const optionIdMap = /* @__PURE__ */ new Map();
|
|
6204
6266
|
((_g = src.options) != null ? _g : []).forEach((o, i) => {
|
|
6205
|
-
var
|
|
6206
|
-
const newOptId = (_b2 = (
|
|
6267
|
+
var _a3, _b2;
|
|
6268
|
+
const newOptId = (_b2 = (_a3 = clonedOptions[i]) == null ? void 0 : _a3.id) != null ? _b2 : o.id;
|
|
6207
6269
|
optionIdMap.set(o.id, newOptId);
|
|
6208
6270
|
});
|
|
6209
6271
|
ctx.patchProps((p) => {
|
|
6210
|
-
var
|
|
6211
|
-
const arr = (
|
|
6272
|
+
var _a3, _b2, _c2, _d2, _e2, _f2, _g2;
|
|
6273
|
+
const arr = (_a3 = p.fields) != null ? _a3 : [];
|
|
6212
6274
|
const idx = arr.findIndex((f) => f.id === fieldId);
|
|
6213
6275
|
arr.splice(idx + 1, 0, cloned);
|
|
6214
6276
|
p.fields = arr;
|
|
@@ -6256,9 +6318,9 @@ function duplicateField(ctx, fieldId, opts) {
|
|
|
6256
6318
|
return id;
|
|
6257
6319
|
}
|
|
6258
6320
|
function duplicateOption(ctx, fieldId, optionId, opts) {
|
|
6259
|
-
var
|
|
6321
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
6260
6322
|
const props = ctx.getProps();
|
|
6261
|
-
const fields = (
|
|
6323
|
+
const fields = (_a2 = props.fields) != null ? _a2 : [];
|
|
6262
6324
|
const f = fields.find((x) => x.id === fieldId);
|
|
6263
6325
|
if (!f) throw new Error(`Field not found: ${fieldId}`);
|
|
6264
6326
|
const optIdx = ((_b = f.options) != null ? _b : []).findIndex((o) => o.id === optionId);
|
|
@@ -6272,8 +6334,8 @@ function duplicateOption(ctx, fieldId, optionId, opts) {
|
|
|
6272
6334
|
);
|
|
6273
6335
|
const newLabel = ((_e = opts.labelStrategy) != null ? _e : nextCopyLabel)((_f = src.label) != null ? _f : src.id);
|
|
6274
6336
|
ctx.patchProps((p) => {
|
|
6275
|
-
var
|
|
6276
|
-
const fld = ((
|
|
6337
|
+
var _a3, _b2, _c2;
|
|
6338
|
+
const fld = ((_a3 = p.fields) != null ? _a3 : []).find((x) => x.id === fieldId);
|
|
6277
6339
|
const arr = (_b2 = fld.options) != null ? _b2 : [];
|
|
6278
6340
|
const clone2 = { ...src, id: newId, label: newLabel };
|
|
6279
6341
|
arr.splice(optIdx + 1, 0, clone2);
|
|
@@ -6298,8 +6360,8 @@ function duplicateOption(ctx, fieldId, optionId, opts) {
|
|
|
6298
6360
|
|
|
6299
6361
|
// src/react/canvas/editor/editor-notices.ts
|
|
6300
6362
|
function genNoticeId(ctx) {
|
|
6301
|
-
var
|
|
6302
|
-
const taken = new Set(((
|
|
6363
|
+
var _a2;
|
|
6364
|
+
const taken = new Set(((_a2 = ctx.getProps().notices) != null ? _a2 : []).map((n) => n.id));
|
|
6303
6365
|
for (let i = 1; i < 1e4; i++) {
|
|
6304
6366
|
const id = `n:${i}`;
|
|
6305
6367
|
if (!taken.has(id)) return id;
|
|
@@ -6307,13 +6369,13 @@ function genNoticeId(ctx) {
|
|
|
6307
6369
|
throw new Error("Unable to generate notice id");
|
|
6308
6370
|
}
|
|
6309
6371
|
function addNotice(ctx, input) {
|
|
6310
|
-
var
|
|
6311
|
-
const id = (
|
|
6372
|
+
var _a2;
|
|
6373
|
+
const id = (_a2 = input.id) != null ? _a2 : genNoticeId(ctx);
|
|
6312
6374
|
ctx.exec({
|
|
6313
6375
|
name: "addNotice",
|
|
6314
6376
|
do: () => ctx.patchProps((p) => {
|
|
6315
|
-
var
|
|
6316
|
-
const notices = (
|
|
6377
|
+
var _a3;
|
|
6378
|
+
const notices = (_a3 = p.notices) != null ? _a3 : p.notices = [];
|
|
6317
6379
|
if (notices.some((n) => n.id === id)) {
|
|
6318
6380
|
throw new Error(`Notice id '${id}' already exists`);
|
|
6319
6381
|
}
|
|
@@ -6341,8 +6403,8 @@ function removeNotice(ctx, id) {
|
|
|
6341
6403
|
ctx.exec({
|
|
6342
6404
|
name: "removeNotice",
|
|
6343
6405
|
do: () => ctx.patchProps((p) => {
|
|
6344
|
-
var
|
|
6345
|
-
if (!((
|
|
6406
|
+
var _a2;
|
|
6407
|
+
if (!((_a2 = p.notices) == null ? void 0 : _a2.length)) return;
|
|
6346
6408
|
p.notices = p.notices.filter((n) => n.id !== id);
|
|
6347
6409
|
if (!p.notices.length) delete p.notices;
|
|
6348
6410
|
}),
|
|
@@ -6355,8 +6417,8 @@ import { cloneDeep as cloneDeep3 } from "lodash-es";
|
|
|
6355
6417
|
|
|
6356
6418
|
// src/react/canvas/editor/editor-utils.ts
|
|
6357
6419
|
function ownerOfOption(props, optionId) {
|
|
6358
|
-
var
|
|
6359
|
-
for (const f of (
|
|
6420
|
+
var _a2, _b;
|
|
6421
|
+
for (const f of (_a2 = props.fields) != null ? _a2 : []) {
|
|
6360
6422
|
const idx = ((_b = f.options) != null ? _b : []).findIndex((o) => o.id === optionId);
|
|
6361
6423
|
if (idx >= 0) return { fieldId: f.id, index: idx };
|
|
6362
6424
|
}
|
|
@@ -6369,8 +6431,8 @@ function isActualButtonField(field) {
|
|
|
6369
6431
|
return (field == null ? void 0 : field.button) === true && !hasFieldOptions(field);
|
|
6370
6432
|
}
|
|
6371
6433
|
function clearFieldButtonReceiverMaps(props, fieldId) {
|
|
6372
|
-
var
|
|
6373
|
-
if ((
|
|
6434
|
+
var _a2, _b;
|
|
6435
|
+
if ((_a2 = props.includes_for_buttons) == null ? void 0 : _a2[fieldId]) {
|
|
6374
6436
|
delete props.includes_for_buttons[fieldId];
|
|
6375
6437
|
}
|
|
6376
6438
|
if ((_b = props.excludes_for_buttons) == null ? void 0 : _b[fieldId]) {
|
|
@@ -6400,14 +6462,137 @@ function ensureServiceExists(opts, id) {
|
|
|
6400
6462
|
}
|
|
6401
6463
|
|
|
6402
6464
|
// src/react/canvas/editor/editor-nodes.ts
|
|
6465
|
+
var RELATION_MAP_KEYS = [
|
|
6466
|
+
"includes_for_buttons",
|
|
6467
|
+
"excludes_for_buttons",
|
|
6468
|
+
"includes_for_options",
|
|
6469
|
+
"excludes_for_options"
|
|
6470
|
+
];
|
|
6471
|
+
function stripDeletedIds(ids) {
|
|
6472
|
+
const ordered = Array.from(new Set((ids != null ? ids : []).map((id) => String(id))));
|
|
6473
|
+
return { ordered, set: new Set(ordered) };
|
|
6474
|
+
}
|
|
6475
|
+
function cleanTagRelationsForDeleted(p, deleted) {
|
|
6476
|
+
var _a2;
|
|
6477
|
+
for (const t of (_a2 = p.filters) != null ? _a2 : []) {
|
|
6478
|
+
if (t.bind_id && deleted.has(String(t.bind_id))) delete t.bind_id;
|
|
6479
|
+
if (t.includes) {
|
|
6480
|
+
const next = t.includes.filter((x) => !deleted.has(String(x)));
|
|
6481
|
+
if (next.length) t.includes = next;
|
|
6482
|
+
else delete t.includes;
|
|
6483
|
+
}
|
|
6484
|
+
if (t.excludes) {
|
|
6485
|
+
const next = t.excludes.filter((x) => !deleted.has(String(x)));
|
|
6486
|
+
if (next.length) t.excludes = next;
|
|
6487
|
+
else delete t.excludes;
|
|
6488
|
+
}
|
|
6489
|
+
}
|
|
6490
|
+
}
|
|
6491
|
+
function cleanFieldBindsForDeleted(p, deleted) {
|
|
6492
|
+
var _a2;
|
|
6493
|
+
for (const f of (_a2 = p.fields) != null ? _a2 : []) {
|
|
6494
|
+
const bind = f.bind_id;
|
|
6495
|
+
if (!bind) continue;
|
|
6496
|
+
if (Array.isArray(bind)) {
|
|
6497
|
+
const next = bind.filter((x) => !deleted.has(String(x)));
|
|
6498
|
+
if (next.length) f.bind_id = next;
|
|
6499
|
+
else delete f.bind_id;
|
|
6500
|
+
continue;
|
|
6501
|
+
}
|
|
6502
|
+
if (deleted.has(String(bind))) delete f.bind_id;
|
|
6503
|
+
}
|
|
6504
|
+
}
|
|
6505
|
+
function cleanRelationMapsForDeleted(p, deleted) {
|
|
6506
|
+
var _a2;
|
|
6507
|
+
for (const key of RELATION_MAP_KEYS) {
|
|
6508
|
+
const map = p[key];
|
|
6509
|
+
if (!map) continue;
|
|
6510
|
+
for (const mapKey of Object.keys(map)) {
|
|
6511
|
+
if (deleted.has(String(mapKey))) {
|
|
6512
|
+
delete map[mapKey];
|
|
6513
|
+
continue;
|
|
6514
|
+
}
|
|
6515
|
+
const next = ((_a2 = map[mapKey]) != null ? _a2 : []).filter(
|
|
6516
|
+
(item) => !deleted.has(String(item))
|
|
6517
|
+
);
|
|
6518
|
+
if (next.length) map[mapKey] = next;
|
|
6519
|
+
else delete map[mapKey];
|
|
6520
|
+
}
|
|
6521
|
+
if (!Object.keys(map).length) delete p[key];
|
|
6522
|
+
}
|
|
6523
|
+
}
|
|
6524
|
+
function cleanOrderForTagsForDeleted(p, deleted) {
|
|
6525
|
+
var _a2, _b;
|
|
6526
|
+
const map = p.order_for_tags;
|
|
6527
|
+
if (!map) return;
|
|
6528
|
+
const fieldIds = new Set(((_a2 = p.fields) != null ? _a2 : []).map((f) => String(f.id)));
|
|
6529
|
+
for (const key of Object.keys(map)) {
|
|
6530
|
+
if (deleted.has(String(key))) {
|
|
6531
|
+
delete map[key];
|
|
6532
|
+
continue;
|
|
6533
|
+
}
|
|
6534
|
+
const next = ((_b = map[key]) != null ? _b : []).filter(
|
|
6535
|
+
(fid) => !deleted.has(String(fid)) && fieldIds.has(String(fid))
|
|
6536
|
+
);
|
|
6537
|
+
if (next.length) map[key] = next;
|
|
6538
|
+
else delete map[key];
|
|
6539
|
+
}
|
|
6540
|
+
if (!Object.keys(map).length) delete p.order_for_tags;
|
|
6541
|
+
}
|
|
6542
|
+
function cleanNoticesForDeleted(p, deleted) {
|
|
6543
|
+
var _a2;
|
|
6544
|
+
if (!((_a2 = p.notices) == null ? void 0 : _a2.length)) return;
|
|
6545
|
+
p.notices = p.notices.filter((n) => {
|
|
6546
|
+
const target = n.target;
|
|
6547
|
+
if (!target || target.scope === "global") return true;
|
|
6548
|
+
if (target.scope === "node" && deleted.has(String(target.node_id))) {
|
|
6549
|
+
return false;
|
|
6550
|
+
}
|
|
6551
|
+
return true;
|
|
6552
|
+
});
|
|
6553
|
+
if (!p.notices.length) delete p.notices;
|
|
6554
|
+
}
|
|
6555
|
+
function applyDeleteCleanup(p, deleted) {
|
|
6556
|
+
cleanTagRelationsForDeleted(p, deleted);
|
|
6557
|
+
cleanFieldBindsForDeleted(p, deleted);
|
|
6558
|
+
cleanRelationMapsForDeleted(p, deleted);
|
|
6559
|
+
cleanOrderForTagsForDeleted(p, deleted);
|
|
6560
|
+
cleanNoticesForDeleted(p, deleted);
|
|
6561
|
+
}
|
|
6562
|
+
function removeOptionInPlace(p, optionId) {
|
|
6563
|
+
var _a2;
|
|
6564
|
+
const owner = ownerOfOption(p, optionId);
|
|
6565
|
+
if (!owner) return false;
|
|
6566
|
+
const f = ((_a2 = p.fields) != null ? _a2 : []).find((x) => x.id === owner.fieldId);
|
|
6567
|
+
if (!(f == null ? void 0 : f.options)) return false;
|
|
6568
|
+
const before = f.options.length;
|
|
6569
|
+
f.options = f.options.filter((o) => o.id !== optionId);
|
|
6570
|
+
return f.options.length !== before;
|
|
6571
|
+
}
|
|
6572
|
+
function removeFieldInPlace(p, fieldId) {
|
|
6573
|
+
var _a2, _b, _c, _d, _e;
|
|
6574
|
+
const field = ((_a2 = p.fields) != null ? _a2 : []).find((f) => f.id === fieldId);
|
|
6575
|
+
if (!field) return [];
|
|
6576
|
+
const deleted = [fieldId, ...((_b = field.options) != null ? _b : []).map((o) => String(o.id))];
|
|
6577
|
+
const before = ((_c = p.fields) != null ? _c : []).length;
|
|
6578
|
+
p.fields = ((_d = p.fields) != null ? _d : []).filter((f) => f.id !== fieldId);
|
|
6579
|
+
clearFieldButtonReceiverMaps(p, fieldId);
|
|
6580
|
+
return ((_e = p.fields) != null ? _e : []).length !== before ? deleted : [];
|
|
6581
|
+
}
|
|
6582
|
+
function removeTagInPlace(p, tagId) {
|
|
6583
|
+
var _a2, _b, _c;
|
|
6584
|
+
const before = ((_a2 = p.filters) != null ? _a2 : []).length;
|
|
6585
|
+
p.filters = ((_b = p.filters) != null ? _b : []).filter((t) => t.id !== tagId);
|
|
6586
|
+
return ((_c = p.filters) != null ? _c : []).length !== before;
|
|
6587
|
+
}
|
|
6403
6588
|
function reLabel(ctx, id, nextLabel) {
|
|
6404
6589
|
const label = String(nextLabel != null ? nextLabel : "").trim();
|
|
6405
6590
|
ctx.exec({
|
|
6406
6591
|
name: "reLabel",
|
|
6407
6592
|
do: () => ctx.patchProps((p) => {
|
|
6408
|
-
var
|
|
6593
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
6409
6594
|
if (ctx.isTagId(id)) {
|
|
6410
|
-
const t = ((
|
|
6595
|
+
const t = ((_a2 = p.filters) != null ? _a2 : []).find((x) => x.id === id);
|
|
6411
6596
|
if (!t) return;
|
|
6412
6597
|
if (((_b = t.label) != null ? _b : "") === label) return;
|
|
6413
6598
|
t.label = label;
|
|
@@ -6440,8 +6625,8 @@ function setFieldName(ctx, fieldId, nextName) {
|
|
|
6440
6625
|
ctx.exec({
|
|
6441
6626
|
name: "setFieldName",
|
|
6442
6627
|
do: () => ctx.patchProps((p) => {
|
|
6443
|
-
var
|
|
6444
|
-
const fields = (
|
|
6628
|
+
var _a2;
|
|
6629
|
+
const fields = (_a2 = p.fields) != null ? _a2 : [];
|
|
6445
6630
|
const f = fields.find((x) => x.id === fieldId);
|
|
6446
6631
|
if (!f) {
|
|
6447
6632
|
ctx.api.emit("error", {
|
|
@@ -6473,8 +6658,8 @@ function setFieldName(ctx, fieldId, nextName) {
|
|
|
6473
6658
|
}
|
|
6474
6659
|
const collision = fields.find(
|
|
6475
6660
|
(x) => {
|
|
6476
|
-
var
|
|
6477
|
-
return x.id !== fieldId && ((
|
|
6661
|
+
var _a3;
|
|
6662
|
+
return x.id !== fieldId && ((_a3 = x.name) != null ? _a3 : "") === name;
|
|
6478
6663
|
}
|
|
6479
6664
|
);
|
|
6480
6665
|
if (collision) {
|
|
@@ -6491,13 +6676,13 @@ function setFieldName(ctx, fieldId, nextName) {
|
|
|
6491
6676
|
});
|
|
6492
6677
|
}
|
|
6493
6678
|
function addOption(ctx, fieldId, input) {
|
|
6494
|
-
var
|
|
6495
|
-
const id = (
|
|
6679
|
+
var _a2;
|
|
6680
|
+
const id = (_a2 = input.id) != null ? _a2 : ctx.genId("o");
|
|
6496
6681
|
ctx.exec({
|
|
6497
6682
|
name: "addOption",
|
|
6498
6683
|
do: () => ctx.patchProps((p) => {
|
|
6499
|
-
var
|
|
6500
|
-
const f = ((
|
|
6684
|
+
var _a3, _b;
|
|
6685
|
+
const f = ((_a3 = p.fields) != null ? _a3 : []).find((x) => x.id === fieldId);
|
|
6501
6686
|
if (!f) throw new Error(`addOption: field '${fieldId}' not found`);
|
|
6502
6687
|
const list = (_b = f.options) != null ? _b : f.options = [];
|
|
6503
6688
|
if (list.some((o) => o.id === id)) {
|
|
@@ -6516,10 +6701,10 @@ function updateOption(ctx, optionId, patch) {
|
|
|
6516
6701
|
ctx.exec({
|
|
6517
6702
|
name: "updateOption",
|
|
6518
6703
|
do: () => ctx.patchProps((p) => {
|
|
6519
|
-
var
|
|
6704
|
+
var _a2;
|
|
6520
6705
|
const owner = ownerOfOption(p, optionId);
|
|
6521
6706
|
if (!owner) return;
|
|
6522
|
-
const f = ((
|
|
6707
|
+
const f = ((_a2 = p.fields) != null ? _a2 : []).find((x) => x.id === owner.fieldId);
|
|
6523
6708
|
if (!(f == null ? void 0 : f.options)) return;
|
|
6524
6709
|
const o = f.options.find((x) => x.id === optionId);
|
|
6525
6710
|
if (o) Object.assign(o, patch);
|
|
@@ -6534,22 +6719,9 @@ function removeOption(ctx, optionId) {
|
|
|
6534
6719
|
ctx.exec({
|
|
6535
6720
|
name: "removeOption",
|
|
6536
6721
|
do: () => ctx.patchProps((p) => {
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
const f = ((_a = p.fields) != null ? _a : []).find((x) => x.id === owner.fieldId);
|
|
6541
|
-
if (!(f == null ? void 0 : f.options)) return;
|
|
6542
|
-
f.options = f.options.filter((o) => o.id !== optionId);
|
|
6543
|
-
const maps = [
|
|
6544
|
-
"includes_for_options",
|
|
6545
|
-
"excludes_for_options"
|
|
6546
|
-
];
|
|
6547
|
-
for (const m of maps) {
|
|
6548
|
-
const map = p[m];
|
|
6549
|
-
if (!map) continue;
|
|
6550
|
-
if (map[optionId]) delete map[optionId];
|
|
6551
|
-
if (!Object.keys(map).length) delete p[m];
|
|
6552
|
-
}
|
|
6722
|
+
const removed = removeOptionInPlace(p, optionId);
|
|
6723
|
+
if (!removed) return;
|
|
6724
|
+
applyDeleteCleanup(p, /* @__PURE__ */ new Set([optionId]));
|
|
6553
6725
|
}),
|
|
6554
6726
|
undo: () => ctx.undo()
|
|
6555
6727
|
});
|
|
@@ -6560,9 +6732,9 @@ function editLabel(ctx, id, label) {
|
|
|
6560
6732
|
ctx.exec({
|
|
6561
6733
|
name: "editLabel",
|
|
6562
6734
|
do: () => ctx.patchProps((p) => {
|
|
6563
|
-
var
|
|
6735
|
+
var _a2, _b, _c, _d;
|
|
6564
6736
|
if (ctx.isTagId(id)) {
|
|
6565
|
-
const t = ((
|
|
6737
|
+
const t = ((_a2 = p.filters) != null ? _a2 : []).find((x) => x.id === id);
|
|
6566
6738
|
if (t) t.label = next;
|
|
6567
6739
|
return;
|
|
6568
6740
|
}
|
|
@@ -6588,8 +6760,8 @@ function editName(ctx, fieldId, name) {
|
|
|
6588
6760
|
ctx.exec({
|
|
6589
6761
|
name: "editName",
|
|
6590
6762
|
do: () => ctx.patchProps((p) => {
|
|
6591
|
-
var
|
|
6592
|
-
const f = ((
|
|
6763
|
+
var _a2;
|
|
6764
|
+
const f = ((_a2 = p.fields) != null ? _a2 : []).find((x) => x.id === fieldId);
|
|
6593
6765
|
if (!f) return;
|
|
6594
6766
|
f.name = name;
|
|
6595
6767
|
}),
|
|
@@ -6600,7 +6772,7 @@ function setService(ctx, id, input) {
|
|
|
6600
6772
|
ctx.exec({
|
|
6601
6773
|
name: "setService",
|
|
6602
6774
|
do: () => ctx.patchProps((p) => {
|
|
6603
|
-
var
|
|
6775
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
6604
6776
|
const hasSidKey = Object.prototype.hasOwnProperty.call(
|
|
6605
6777
|
input,
|
|
6606
6778
|
"service_id"
|
|
@@ -6609,7 +6781,7 @@ function setService(ctx, id, input) {
|
|
|
6609
6781
|
const sid = validId ? typeof input.service_id === "string" ? input.service_id.trim() : Number(input.service_id) : void 0;
|
|
6610
6782
|
const nextRole = input.pricing_role;
|
|
6611
6783
|
if (ctx.isTagId(id)) {
|
|
6612
|
-
const t = ((
|
|
6784
|
+
const t = ((_a2 = p.filters) != null ? _a2 : []).find((x) => x.id === id);
|
|
6613
6785
|
if (!t) return;
|
|
6614
6786
|
if (hasSidKey) {
|
|
6615
6787
|
if (sid === void 0) delete t.service_id;
|
|
@@ -6698,18 +6870,18 @@ function setService(ctx, id, input) {
|
|
|
6698
6870
|
});
|
|
6699
6871
|
}
|
|
6700
6872
|
function addTag(ctx, partial) {
|
|
6701
|
-
var
|
|
6702
|
-
const id = (
|
|
6873
|
+
var _a2;
|
|
6874
|
+
const id = (_a2 = partial.id) != null ? _a2 : ctx.genId("t");
|
|
6703
6875
|
const payload = { ...partial, id };
|
|
6704
6876
|
ctx.exec({
|
|
6705
6877
|
name: "addTag",
|
|
6706
6878
|
do: () => ctx.patchProps((p) => {
|
|
6707
|
-
var
|
|
6708
|
-
p.filters = [...(
|
|
6879
|
+
var _a3;
|
|
6880
|
+
p.filters = [...(_a3 = p.filters) != null ? _a3 : [], payload];
|
|
6709
6881
|
}),
|
|
6710
6882
|
undo: () => ctx.patchProps((p) => {
|
|
6711
|
-
var
|
|
6712
|
-
p.filters = ((
|
|
6883
|
+
var _a3;
|
|
6884
|
+
p.filters = ((_a3 = p.filters) != null ? _a3 : []).filter((t) => t.id !== id);
|
|
6713
6885
|
})
|
|
6714
6886
|
});
|
|
6715
6887
|
}
|
|
@@ -6718,16 +6890,16 @@ function updateTag(ctx, id, patch) {
|
|
|
6718
6890
|
ctx.exec({
|
|
6719
6891
|
name: "updateTag",
|
|
6720
6892
|
do: () => ctx.patchProps((p) => {
|
|
6721
|
-
var
|
|
6722
|
-
p.filters = ((
|
|
6893
|
+
var _a2;
|
|
6894
|
+
p.filters = ((_a2 = p.filters) != null ? _a2 : []).map((t) => {
|
|
6723
6895
|
if (t.id !== id) return t;
|
|
6724
6896
|
prev = t;
|
|
6725
6897
|
return { ...t, ...patch };
|
|
6726
6898
|
});
|
|
6727
6899
|
}),
|
|
6728
6900
|
undo: () => ctx.patchProps((p) => {
|
|
6729
|
-
var
|
|
6730
|
-
p.filters = ((
|
|
6901
|
+
var _a2;
|
|
6902
|
+
p.filters = ((_a2 = p.filters) != null ? _a2 : []).map(
|
|
6731
6903
|
(t) => t.id === id && prev ? prev : t
|
|
6732
6904
|
);
|
|
6733
6905
|
})
|
|
@@ -6738,38 +6910,27 @@ function removeTag(ctx, id) {
|
|
|
6738
6910
|
ctx.exec({
|
|
6739
6911
|
name: "removeTag",
|
|
6740
6912
|
do: () => ctx.patchProps((p) => {
|
|
6741
|
-
var _a, _b, _c, _d, _e;
|
|
6742
6913
|
prevSlice = cloneDeep3(p);
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
t.includes = ((_c = t.includes) != null ? _c : []).filter((x) => x !== id);
|
|
6747
|
-
t.excludes = ((_d = t.excludes) != null ? _d : []).filter((x) => x !== id);
|
|
6748
|
-
}
|
|
6749
|
-
for (const f of (_e = p.fields) != null ? _e : []) {
|
|
6750
|
-
if (Array.isArray(f.bind_id)) {
|
|
6751
|
-
f.bind_id = f.bind_id.filter((x) => x !== id);
|
|
6752
|
-
} else if (f.bind_id === id) {
|
|
6753
|
-
delete f.bind_id;
|
|
6754
|
-
}
|
|
6755
|
-
}
|
|
6914
|
+
const removed = removeTagInPlace(p, id);
|
|
6915
|
+
if (!removed) return;
|
|
6916
|
+
applyDeleteCleanup(p, /* @__PURE__ */ new Set([id]));
|
|
6756
6917
|
}),
|
|
6757
6918
|
undo: () => ctx.replaceProps(prevSlice)
|
|
6758
6919
|
});
|
|
6759
6920
|
}
|
|
6760
6921
|
function addField(ctx, partial) {
|
|
6761
|
-
var
|
|
6762
|
-
const id = (
|
|
6922
|
+
var _a2;
|
|
6923
|
+
const id = (_a2 = partial.id) != null ? _a2 : ctx.genId("f");
|
|
6763
6924
|
const payload = { ...partial, id };
|
|
6764
6925
|
ctx.exec({
|
|
6765
6926
|
name: "addField",
|
|
6766
6927
|
do: () => ctx.patchProps((p) => {
|
|
6767
|
-
var
|
|
6768
|
-
p.fields = [...(
|
|
6928
|
+
var _a3;
|
|
6929
|
+
p.fields = [...(_a3 = p.fields) != null ? _a3 : [], payload];
|
|
6769
6930
|
}),
|
|
6770
6931
|
undo: () => ctx.patchProps((p) => {
|
|
6771
|
-
var
|
|
6772
|
-
p.fields = ((
|
|
6932
|
+
var _a3;
|
|
6933
|
+
p.fields = ((_a3 = p.fields) != null ? _a3 : []).filter((f) => f.id !== id);
|
|
6773
6934
|
})
|
|
6774
6935
|
});
|
|
6775
6936
|
}
|
|
@@ -6780,8 +6941,8 @@ function updateField(ctx, id, patch) {
|
|
|
6780
6941
|
ctx.exec({
|
|
6781
6942
|
name: "updateField",
|
|
6782
6943
|
do: () => ctx.patchProps((p) => {
|
|
6783
|
-
var
|
|
6784
|
-
prevIncludesForButton = ((
|
|
6944
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
6945
|
+
prevIncludesForButton = ((_a2 = p.includes_for_buttons) == null ? void 0 : _a2[id]) ? [...(_c = (_b = p.includes_for_buttons) == null ? void 0 : _b[id]) != null ? _c : []] : void 0;
|
|
6785
6946
|
prevExcludesForButton = ((_d = p.excludes_for_buttons) == null ? void 0 : _d[id]) ? [...(_f = (_e = p.excludes_for_buttons) == null ? void 0 : _e[id]) != null ? _f : []] : void 0;
|
|
6786
6947
|
p.fields = ((_g = p.fields) != null ? _g : []).map((f) => {
|
|
6787
6948
|
if (f.id !== id) return f;
|
|
@@ -6794,8 +6955,8 @@ function updateField(ctx, id, patch) {
|
|
|
6794
6955
|
});
|
|
6795
6956
|
}),
|
|
6796
6957
|
undo: () => ctx.patchProps((p) => {
|
|
6797
|
-
var
|
|
6798
|
-
p.fields = ((
|
|
6958
|
+
var _a2, _b, _c;
|
|
6959
|
+
p.fields = ((_a2 = p.fields) != null ? _a2 : []).map(
|
|
6799
6960
|
(f) => f.id === id && prev ? prev : f
|
|
6800
6961
|
);
|
|
6801
6962
|
if (prevIncludesForButton) {
|
|
@@ -6820,58 +6981,23 @@ function removeField(ctx, id) {
|
|
|
6820
6981
|
ctx.exec({
|
|
6821
6982
|
name: "removeField",
|
|
6822
6983
|
do: () => ctx.patchProps((p) => {
|
|
6823
|
-
var _a, _b, _c, _d, _e, _f;
|
|
6824
6984
|
prevSlice = cloneDeep3(p);
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
"includes_for_buttons",
|
|
6829
|
-
"excludes_for_buttons"
|
|
6830
|
-
]) {
|
|
6831
|
-
const m = p[mapKey];
|
|
6832
|
-
if (!m) continue;
|
|
6833
|
-
for (const k of Object.keys(m)) {
|
|
6834
|
-
m[k] = ((_b = m[k]) != null ? _b : []).filter((fid) => fid !== id);
|
|
6835
|
-
if (!((_c = m[k]) == null ? void 0 : _c.length)) delete m[k];
|
|
6836
|
-
}
|
|
6837
|
-
}
|
|
6838
|
-
for (const t of (_d = p.filters) != null ? _d : []) {
|
|
6839
|
-
t.includes = ((_e = t.includes) != null ? _e : []).filter((x) => x !== id);
|
|
6840
|
-
t.excludes = ((_f = t.excludes) != null ? _f : []).filter((x) => x !== id);
|
|
6841
|
-
}
|
|
6985
|
+
const removedIds = removeFieldInPlace(p, id);
|
|
6986
|
+
if (!removedIds.length) return;
|
|
6987
|
+
applyDeleteCleanup(p, new Set(removedIds));
|
|
6842
6988
|
}),
|
|
6843
6989
|
undo: () => ctx.replaceProps(prevSlice)
|
|
6844
6990
|
});
|
|
6845
6991
|
}
|
|
6846
6992
|
function remove(ctx, id) {
|
|
6993
|
+
const key = String(id);
|
|
6847
6994
|
if (ctx.isTagId(id)) {
|
|
6848
6995
|
ctx.exec({
|
|
6849
6996
|
name: "removeTag",
|
|
6850
6997
|
do: () => ctx.patchProps((p) => {
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
if (t.bind_id === id) delete t.bind_id;
|
|
6855
|
-
t.includes = ((_c = t.includes) != null ? _c : []).filter((x) => x !== id);
|
|
6856
|
-
t.excludes = ((_d = t.excludes) != null ? _d : []).filter((x) => x !== id);
|
|
6857
|
-
}
|
|
6858
|
-
for (const f of (_e = p.fields) != null ? _e : []) {
|
|
6859
|
-
if (Array.isArray(f.bind_id)) {
|
|
6860
|
-
f.bind_id = f.bind_id.filter((x) => x !== id);
|
|
6861
|
-
} else if (f.bind_id === id) {
|
|
6862
|
-
delete f.bind_id;
|
|
6863
|
-
}
|
|
6864
|
-
}
|
|
6865
|
-
if ((_f = p.order_for_tags) == null ? void 0 : _f[id]) delete p.order_for_tags[id];
|
|
6866
|
-
for (const k of Object.keys((_g = p.order_for_tags) != null ? _g : {})) {
|
|
6867
|
-
p.order_for_tags[k] = ((_h = p.order_for_tags[k]) != null ? _h : []).filter(
|
|
6868
|
-
(fid) => {
|
|
6869
|
-
var _a2;
|
|
6870
|
-
return ((_a2 = p.fields) != null ? _a2 : []).some((f) => f.id === fid);
|
|
6871
|
-
}
|
|
6872
|
-
);
|
|
6873
|
-
if (!p.order_for_tags[k].length) delete p.order_for_tags[k];
|
|
6874
|
-
}
|
|
6998
|
+
const removed = removeTagInPlace(p, key);
|
|
6999
|
+
if (!removed) return;
|
|
7000
|
+
applyDeleteCleanup(p, /* @__PURE__ */ new Set([key]));
|
|
6875
7001
|
}),
|
|
6876
7002
|
undo: () => ctx.undo()
|
|
6877
7003
|
});
|
|
@@ -6881,47 +7007,72 @@ function remove(ctx, id) {
|
|
|
6881
7007
|
ctx.exec({
|
|
6882
7008
|
name: "removeField",
|
|
6883
7009
|
do: () => ctx.patchProps((p) => {
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
t.includes = ((_c = t.includes) != null ? _c : []).filter((x) => x !== id);
|
|
6888
|
-
t.excludes = ((_d = t.excludes) != null ? _d : []).filter((x) => x !== id);
|
|
6889
|
-
}
|
|
6890
|
-
for (const k of Object.keys((_e = p.order_for_tags) != null ? _e : {})) {
|
|
6891
|
-
p.order_for_tags[k] = ((_f = p.order_for_tags[k]) != null ? _f : []).filter(
|
|
6892
|
-
(fid) => fid !== id
|
|
6893
|
-
);
|
|
6894
|
-
if (!p.order_for_tags[k].length) delete p.order_for_tags[k];
|
|
6895
|
-
}
|
|
6896
|
-
const maps = [
|
|
6897
|
-
"includes_for_options",
|
|
6898
|
-
"excludes_for_options"
|
|
6899
|
-
];
|
|
6900
|
-
for (const m of maps) {
|
|
6901
|
-
const map = p[m];
|
|
6902
|
-
if (!map) continue;
|
|
6903
|
-
for (const key of Object.keys(map)) {
|
|
6904
|
-
map[key] = ((_g = map[key]) != null ? _g : []).filter((fid) => fid !== id);
|
|
6905
|
-
if (!((_h = map[key]) == null ? void 0 : _h.length)) delete map[key];
|
|
6906
|
-
}
|
|
6907
|
-
if (!Object.keys(map).length) delete p[m];
|
|
6908
|
-
}
|
|
7010
|
+
const removedIds = removeFieldInPlace(p, key);
|
|
7011
|
+
if (!removedIds.length) return;
|
|
7012
|
+
applyDeleteCleanup(p, new Set(removedIds));
|
|
6909
7013
|
}),
|
|
6910
7014
|
undo: () => ctx.undo()
|
|
6911
7015
|
});
|
|
6912
7016
|
return;
|
|
6913
7017
|
}
|
|
6914
7018
|
if (ctx.isOptionId(id)) {
|
|
6915
|
-
|
|
7019
|
+
ctx.exec({
|
|
7020
|
+
name: "removeOption",
|
|
7021
|
+
do: () => ctx.patchProps((p) => {
|
|
7022
|
+
const removed = removeOptionInPlace(p, key);
|
|
7023
|
+
if (!removed) return;
|
|
7024
|
+
applyDeleteCleanup(p, /* @__PURE__ */ new Set([key]));
|
|
7025
|
+
}),
|
|
7026
|
+
undo: () => ctx.undo()
|
|
7027
|
+
});
|
|
6916
7028
|
return;
|
|
6917
7029
|
}
|
|
6918
7030
|
throw new Error("remove: unknown id prefix");
|
|
6919
7031
|
}
|
|
7032
|
+
function removeMany(ctx, ids) {
|
|
7033
|
+
const { ordered } = stripDeletedIds(ids);
|
|
7034
|
+
if (!ordered.length) return;
|
|
7035
|
+
ctx.transact("removeMany", () => {
|
|
7036
|
+
ctx.patchProps((p) => {
|
|
7037
|
+
var _a2, _b, _c;
|
|
7038
|
+
const existingFieldIds = new Set(((_a2 = p.fields) != null ? _a2 : []).map((f) => String(f.id)));
|
|
7039
|
+
const existingTagIds = new Set(((_b = p.filters) != null ? _b : []).map((t) => String(t.id)));
|
|
7040
|
+
const existingOptionIds = new Set(
|
|
7041
|
+
((_c = p.fields) != null ? _c : []).flatMap((f) => {
|
|
7042
|
+
var _a3;
|
|
7043
|
+
return ((_a3 = f.options) != null ? _a3 : []).map((o) => String(o.id));
|
|
7044
|
+
})
|
|
7045
|
+
);
|
|
7046
|
+
const fieldIds = ordered.filter((id) => ctx.isFieldId(id) && existingFieldIds.has(id));
|
|
7047
|
+
const fieldIdSet = new Set(fieldIds);
|
|
7048
|
+
const tagIds = ordered.filter((id) => ctx.isTagId(id) && existingTagIds.has(id));
|
|
7049
|
+
const optionIds = ordered.filter((id) => {
|
|
7050
|
+
if (!ctx.isOptionId(id) || !existingOptionIds.has(id)) return false;
|
|
7051
|
+
const owner = ownerOfOption(p, id);
|
|
7052
|
+
if (!owner) return false;
|
|
7053
|
+
return !fieldIdSet.has(String(owner.fieldId));
|
|
7054
|
+
});
|
|
7055
|
+
const deleted = /* @__PURE__ */ new Set();
|
|
7056
|
+
for (const optionId of optionIds) {
|
|
7057
|
+
if (removeOptionInPlace(p, optionId)) deleted.add(optionId);
|
|
7058
|
+
}
|
|
7059
|
+
for (const fieldId of fieldIds) {
|
|
7060
|
+
const removedIds = removeFieldInPlace(p, fieldId);
|
|
7061
|
+
for (const rid of removedIds) deleted.add(rid);
|
|
7062
|
+
}
|
|
7063
|
+
for (const tagId of tagIds) {
|
|
7064
|
+
if (removeTagInPlace(p, tagId)) deleted.add(tagId);
|
|
7065
|
+
}
|
|
7066
|
+
if (!deleted.size) return;
|
|
7067
|
+
applyDeleteCleanup(p, deleted);
|
|
7068
|
+
});
|
|
7069
|
+
});
|
|
7070
|
+
}
|
|
6920
7071
|
function getNode(ctx, id) {
|
|
6921
|
-
var
|
|
7072
|
+
var _a2, _b, _c, _d;
|
|
6922
7073
|
const props = ctx.getProps();
|
|
6923
7074
|
if (ctx.isTagId(id)) {
|
|
6924
|
-
const t = ((
|
|
7075
|
+
const t = ((_a2 = props.filters) != null ? _a2 : []).find((x) => x.id === id);
|
|
6925
7076
|
return {
|
|
6926
7077
|
kind: "tag",
|
|
6927
7078
|
data: t,
|
|
@@ -6952,8 +7103,8 @@ function setConstraint(ctx, tagId, flag, value) {
|
|
|
6952
7103
|
ctx.exec({
|
|
6953
7104
|
name: "setConstraint",
|
|
6954
7105
|
do: () => ctx.patchProps((p) => {
|
|
6955
|
-
var
|
|
6956
|
-
const t = ((
|
|
7106
|
+
var _a2, _b;
|
|
7107
|
+
const t = ((_a2 = p.filters) != null ? _a2 : []).find((x) => x.id === tagId);
|
|
6957
7108
|
if (!t) return;
|
|
6958
7109
|
prev = (_b = t.constraints) == null ? void 0 : _b[flag];
|
|
6959
7110
|
if (!t.constraints) t.constraints = {};
|
|
@@ -6961,8 +7112,8 @@ function setConstraint(ctx, tagId, flag, value) {
|
|
|
6961
7112
|
else t.constraints[flag] = value;
|
|
6962
7113
|
}),
|
|
6963
7114
|
undo: () => ctx.patchProps((p) => {
|
|
6964
|
-
var
|
|
6965
|
-
const t = ((
|
|
7115
|
+
var _a2;
|
|
7116
|
+
const t = ((_a2 = p.filters) != null ? _a2 : []).find((x) => x.id === tagId);
|
|
6966
7117
|
if (!t) return;
|
|
6967
7118
|
if (!t.constraints) t.constraints = {};
|
|
6968
7119
|
if (prev === void 0) delete t.constraints[flag];
|
|
@@ -6976,8 +7127,8 @@ function clearConstraintOverride(ctx, tagId, flag) {
|
|
|
6976
7127
|
ctx.exec({
|
|
6977
7128
|
name: "clearConstraintOverride",
|
|
6978
7129
|
do: () => ctx.patchProps((p) => {
|
|
6979
|
-
var
|
|
6980
|
-
const t = ((
|
|
7130
|
+
var _a2, _b, _c;
|
|
7131
|
+
const t = ((_a2 = p.filters) != null ? _a2 : []).find((x) => x.id === tagId);
|
|
6981
7132
|
if (!t) return;
|
|
6982
7133
|
prev = (_b = t.constraints) == null ? void 0 : _b[flag];
|
|
6983
7134
|
prevOverride = (_c = t.constraints_overrides) == null ? void 0 : _c[flag];
|
|
@@ -6985,8 +7136,8 @@ function clearConstraintOverride(ctx, tagId, flag) {
|
|
|
6985
7136
|
if (t.constraints_overrides) delete t.constraints_overrides[flag];
|
|
6986
7137
|
}),
|
|
6987
7138
|
undo: () => ctx.patchProps((p) => {
|
|
6988
|
-
var
|
|
6989
|
-
const t = ((
|
|
7139
|
+
var _a2;
|
|
7140
|
+
const t = ((_a2 = p.filters) != null ? _a2 : []).find((x) => x.id === tagId);
|
|
6990
7141
|
if (!t) return;
|
|
6991
7142
|
if (prev !== void 0) {
|
|
6992
7143
|
if (!t.constraints) t.constraints = {};
|
|
@@ -7003,8 +7154,8 @@ function clearConstraint(ctx, tagId, flag) {
|
|
|
7003
7154
|
ctx.exec({
|
|
7004
7155
|
name: "clearConstraint",
|
|
7005
7156
|
do: () => ctx.patchProps((p) => {
|
|
7006
|
-
var
|
|
7007
|
-
const tags = (
|
|
7157
|
+
var _a2;
|
|
7158
|
+
const tags = (_a2 = p.filters) != null ? _a2 : [];
|
|
7008
7159
|
const byId = new Map(tags.map((t) => [t.id, t]));
|
|
7009
7160
|
const children = /* @__PURE__ */ new Map();
|
|
7010
7161
|
for (const t of tags) {
|
|
@@ -7014,10 +7165,10 @@ function clearConstraint(ctx, tagId, flag) {
|
|
|
7014
7165
|
}
|
|
7015
7166
|
}
|
|
7016
7167
|
const process = (id) => {
|
|
7017
|
-
var
|
|
7168
|
+
var _a3, _b, _c;
|
|
7018
7169
|
const t = byId.get(id);
|
|
7019
7170
|
if (!t) return;
|
|
7020
|
-
const override = (
|
|
7171
|
+
const override = (_a3 = t.constraints_overrides) == null ? void 0 : _a3[flag];
|
|
7021
7172
|
if (override) {
|
|
7022
7173
|
if (!t.constraints) t.constraints = {};
|
|
7023
7174
|
t.constraints[flag] = override.from;
|
|
@@ -7043,9 +7194,9 @@ function clearConstraint(ctx, tagId, flag) {
|
|
|
7043
7194
|
|
|
7044
7195
|
// src/react/canvas/editor/editor-field-rules.ts
|
|
7045
7196
|
function getFieldQuantityRule(ctx, id) {
|
|
7046
|
-
var
|
|
7197
|
+
var _a2, _b;
|
|
7047
7198
|
const props = ctx.getProps();
|
|
7048
|
-
const f = ((
|
|
7199
|
+
const f = ((_a2 = props.fields) != null ? _a2 : []).find((x) => x.id === id);
|
|
7049
7200
|
if (!f) return void 0;
|
|
7050
7201
|
return normalizeQuantityRule((_b = f.meta) == null ? void 0 : _b.quantity);
|
|
7051
7202
|
}
|
|
@@ -7053,8 +7204,8 @@ function setFieldQuantityRule(ctx, id, rule) {
|
|
|
7053
7204
|
ctx.exec({
|
|
7054
7205
|
name: "setFieldQuantityRule",
|
|
7055
7206
|
do: () => ctx.patchProps((p) => {
|
|
7056
|
-
var
|
|
7057
|
-
const f = ((
|
|
7207
|
+
var _a2, _b;
|
|
7208
|
+
const f = ((_a2 = p.fields) != null ? _a2 : []).find((x) => x.id === id);
|
|
7058
7209
|
if (!f) return;
|
|
7059
7210
|
const normalized = normalizeQuantityRule(rule);
|
|
7060
7211
|
if (!normalized) {
|
|
@@ -7078,8 +7229,8 @@ function clearFieldQuantityRule(ctx, id) {
|
|
|
7078
7229
|
ctx.exec({
|
|
7079
7230
|
name: "clearFieldQuantityRule",
|
|
7080
7231
|
do: () => ctx.patchProps((p) => {
|
|
7081
|
-
var
|
|
7082
|
-
const f = ((
|
|
7232
|
+
var _a2, _b;
|
|
7233
|
+
const f = ((_a2 = p.fields) != null ? _a2 : []).find((x) => x.id === id);
|
|
7083
7234
|
if (!f || !((_b = f.meta) == null ? void 0 : _b.quantity)) return;
|
|
7084
7235
|
delete f.meta.quantity;
|
|
7085
7236
|
if (f.meta && Object.keys(f.meta).length === 0) {
|
|
@@ -7090,9 +7241,9 @@ function clearFieldQuantityRule(ctx, id) {
|
|
|
7090
7241
|
});
|
|
7091
7242
|
}
|
|
7092
7243
|
function getFieldValidation(ctx, id) {
|
|
7093
|
-
var
|
|
7244
|
+
var _a2;
|
|
7094
7245
|
const props = ctx.getProps();
|
|
7095
|
-
const f = ((
|
|
7246
|
+
const f = ((_a2 = props.fields) != null ? _a2 : []).find((x) => x.id === id);
|
|
7096
7247
|
if (!f) return void 0;
|
|
7097
7248
|
return normalizeFieldValidation(f.validation);
|
|
7098
7249
|
}
|
|
@@ -7100,8 +7251,8 @@ function setFieldValidation(ctx, id, rules) {
|
|
|
7100
7251
|
ctx.exec({
|
|
7101
7252
|
name: "setFieldValidation",
|
|
7102
7253
|
do: () => ctx.patchProps((p) => {
|
|
7103
|
-
var
|
|
7104
|
-
const f = ((
|
|
7254
|
+
var _a2;
|
|
7255
|
+
const f = ((_a2 = p.fields) != null ? _a2 : []).find((x) => x.id === id);
|
|
7105
7256
|
if (!f) return;
|
|
7106
7257
|
const normalized = normalizeFieldValidation(rules);
|
|
7107
7258
|
if (!normalized) {
|
|
@@ -7117,8 +7268,8 @@ function clearFieldValidation(ctx, id) {
|
|
|
7117
7268
|
ctx.exec({
|
|
7118
7269
|
name: "clearFieldValidation",
|
|
7119
7270
|
do: () => ctx.patchProps((p) => {
|
|
7120
|
-
var
|
|
7121
|
-
const f = ((
|
|
7271
|
+
var _a2;
|
|
7272
|
+
const f = ((_a2 = p.fields) != null ? _a2 : []).find((x) => x.id === id);
|
|
7122
7273
|
if (!f || !f.validation) return;
|
|
7123
7274
|
delete f.validation;
|
|
7124
7275
|
}),
|
|
@@ -7237,9 +7388,9 @@ function pruneOrderKind(ctx, kind) {
|
|
|
7237
7388
|
|
|
7238
7389
|
// src/react/canvas/editor/editor-relations.ts
|
|
7239
7390
|
function wouldCreateTagCycle(_ctx, p, parentId, childId) {
|
|
7240
|
-
var
|
|
7391
|
+
var _a2, _b;
|
|
7241
7392
|
if (parentId === childId) return true;
|
|
7242
|
-
const tagById = new Map(((
|
|
7393
|
+
const tagById = new Map(((_a2 = p.filters) != null ? _a2 : []).map((t) => [t.id, t]));
|
|
7243
7394
|
let cur = parentId;
|
|
7244
7395
|
const guard = /* @__PURE__ */ new Set();
|
|
7245
7396
|
while (cur) {
|
|
@@ -7253,9 +7404,9 @@ function wouldCreateTagCycle(_ctx, p, parentId, childId) {
|
|
|
7253
7404
|
function wouldCreateIncludeExcludeCycle(ctx, p, receiverId, targetId) {
|
|
7254
7405
|
if (receiverId === targetId) return true;
|
|
7255
7406
|
const getDirectRelations = (id) => {
|
|
7256
|
-
var
|
|
7407
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
7257
7408
|
if (ctx.isTagId(id)) {
|
|
7258
|
-
const t = ((
|
|
7409
|
+
const t = ((_a2 = p.filters) != null ? _a2 : []).find((x) => x.id === id);
|
|
7259
7410
|
return [...(_b = t == null ? void 0 : t.includes) != null ? _b : [], ...(_c = t == null ? void 0 : t.excludes) != null ? _c : []];
|
|
7260
7411
|
}
|
|
7261
7412
|
const inc = (_e = (_d = p.includes_for_buttons) == null ? void 0 : _d[id]) != null ? _e : [];
|
|
@@ -7277,12 +7428,12 @@ function include(ctx, receiverId, idOrIds) {
|
|
|
7277
7428
|
ctx.exec({
|
|
7278
7429
|
name: "include",
|
|
7279
7430
|
do: () => ctx.patchProps((p) => {
|
|
7280
|
-
var
|
|
7431
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
7281
7432
|
const receiver = ctx.getNode(receiverId);
|
|
7282
7433
|
const ids = Array.isArray(idOrIds) ? idOrIds : [idOrIds];
|
|
7283
7434
|
if (receiver.kind === "tag" || receiver.kind === "field" && isActualButtonField(receiver.data) || receiver.kind === "option") {
|
|
7284
7435
|
if (receiver.kind === "tag") {
|
|
7285
|
-
const t = ((
|
|
7436
|
+
const t = ((_a2 = p.filters) != null ? _a2 : []).find(
|
|
7286
7437
|
(x) => x.id === receiverId
|
|
7287
7438
|
);
|
|
7288
7439
|
if (t) {
|
|
@@ -7375,12 +7526,12 @@ function exclude(ctx, receiverId, idOrIds) {
|
|
|
7375
7526
|
ctx.exec({
|
|
7376
7527
|
name: "exclude",
|
|
7377
7528
|
do: () => ctx.patchProps((p) => {
|
|
7378
|
-
var
|
|
7529
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
7379
7530
|
const receiver = ctx.getNode(receiverId);
|
|
7380
7531
|
const ids = Array.isArray(idOrIds) ? idOrIds : [idOrIds];
|
|
7381
7532
|
if (receiver.kind === "tag" || receiver.kind === "field" && isActualButtonField(receiver.data) || receiver.kind === "option") {
|
|
7382
7533
|
if (receiver.kind === "tag") {
|
|
7383
|
-
const t = ((
|
|
7534
|
+
const t = ((_a2 = p.filters) != null ? _a2 : []).find(
|
|
7384
7535
|
(x) => x.id === receiverId
|
|
7385
7536
|
);
|
|
7386
7537
|
if (t) {
|
|
@@ -7473,7 +7624,7 @@ function connect(ctx, kind, fromId, toId2) {
|
|
|
7473
7624
|
ctx.exec({
|
|
7474
7625
|
name: `connect:${kind}`,
|
|
7475
7626
|
do: () => ctx.patchProps((p) => {
|
|
7476
|
-
var
|
|
7627
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
7477
7628
|
if (kind === "bind") {
|
|
7478
7629
|
if (ctx.isTagId(fromId) && ctx.isTagId(toId2)) {
|
|
7479
7630
|
if (wouldCreateTagCycle(ctx, p, fromId, toId2)) {
|
|
@@ -7481,7 +7632,7 @@ function connect(ctx, kind, fromId, toId2) {
|
|
|
7481
7632
|
`bind would create a cycle: ${fromId} ? ${toId2}`
|
|
7482
7633
|
);
|
|
7483
7634
|
}
|
|
7484
|
-
const child = ((
|
|
7635
|
+
const child = ((_a2 = p.filters) != null ? _a2 : []).find(
|
|
7485
7636
|
(t) => t.id === toId2
|
|
7486
7637
|
);
|
|
7487
7638
|
if (child) child.bind_id = fromId;
|
|
@@ -7575,10 +7726,10 @@ function disconnect(ctx, kind, fromId, toId2) {
|
|
|
7575
7726
|
ctx.exec({
|
|
7576
7727
|
name: `disconnect:${kind}`,
|
|
7577
7728
|
do: () => ctx.patchProps((p) => {
|
|
7578
|
-
var
|
|
7729
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
7579
7730
|
if (kind === "bind") {
|
|
7580
7731
|
if (ctx.isTagId(fromId) && ctx.isTagId(toId2)) {
|
|
7581
|
-
const child = ((
|
|
7732
|
+
const child = ((_a2 = p.filters) != null ? _a2 : []).find(
|
|
7582
7733
|
(t) => t.id === toId2
|
|
7583
7734
|
);
|
|
7584
7735
|
if ((child == null ? void 0 : child.bind_id) === fromId) {
|
|
@@ -7670,8 +7821,8 @@ function disconnect(ctx, kind, fromId, toId2) {
|
|
|
7670
7821
|
});
|
|
7671
7822
|
}
|
|
7672
7823
|
function addMappedField(p, mapKey, fromId, toId2) {
|
|
7673
|
-
var
|
|
7674
|
-
const maps = (
|
|
7824
|
+
var _a2, _b;
|
|
7825
|
+
const maps = (_a2 = p[mapKey]) != null ? _a2 : {};
|
|
7675
7826
|
const arr = (_b = maps[fromId]) != null ? _b : [];
|
|
7676
7827
|
if (!arr.includes(toId2)) {
|
|
7677
7828
|
maps[fromId] = [...arr, toId2];
|
|
@@ -7708,15 +7859,15 @@ function placeNode(ctx, id, opts) {
|
|
|
7708
7859
|
ctx.exec({
|
|
7709
7860
|
name: "placeTag",
|
|
7710
7861
|
do: () => ctx.patchProps((p) => {
|
|
7711
|
-
var
|
|
7712
|
-
const all = (
|
|
7862
|
+
var _a2, _b, _c;
|
|
7863
|
+
const all = (_a2 = p.filters) != null ? _a2 : [];
|
|
7713
7864
|
const cur = all.find((t) => t.id === id);
|
|
7714
7865
|
if (!cur) return;
|
|
7715
7866
|
const groupKey = (_b = cur.bind_id) != null ? _b : "__root__";
|
|
7716
7867
|
const siblings = all.filter(
|
|
7717
7868
|
(t) => {
|
|
7718
|
-
var
|
|
7719
|
-
return ((
|
|
7869
|
+
var _a3;
|
|
7870
|
+
return ((_a3 = t.bind_id) != null ? _a3 : "__root__") === groupKey;
|
|
7720
7871
|
}
|
|
7721
7872
|
);
|
|
7722
7873
|
const curIdx = siblings.findIndex((t) => t.id === id);
|
|
@@ -7761,8 +7912,8 @@ function placeNode(ctx, id, opts) {
|
|
|
7761
7912
|
ctx.exec({
|
|
7762
7913
|
name: "placeField",
|
|
7763
7914
|
do: () => ctx.patchProps((p) => {
|
|
7764
|
-
var
|
|
7765
|
-
const map = (
|
|
7915
|
+
var _a2, _b;
|
|
7916
|
+
const map = (_a2 = p.order_for_tags) != null ? _a2 : p.order_for_tags = {};
|
|
7766
7917
|
const arr = (_b = map[tagId]) != null ? _b : map[tagId] = [];
|
|
7767
7918
|
const curIdx = arr.indexOf(fieldId);
|
|
7768
7919
|
if (curIdx >= 0) arr.splice(curIdx, 1);
|
|
@@ -7791,10 +7942,10 @@ function placeOption(ctx, optionId, opts) {
|
|
|
7791
7942
|
ctx.exec({
|
|
7792
7943
|
name: "placeOption",
|
|
7793
7944
|
do: () => ctx.patchProps((p) => {
|
|
7794
|
-
var
|
|
7945
|
+
var _a2;
|
|
7795
7946
|
const owner = ownerOfOption(p, optionId);
|
|
7796
7947
|
if (!owner) return;
|
|
7797
|
-
const f = ((
|
|
7948
|
+
const f = ((_a2 = p.fields) != null ? _a2 : []).find((x) => x.id === owner.fieldId);
|
|
7798
7949
|
if (!(f == null ? void 0 : f.options)) return;
|
|
7799
7950
|
const curIdx = f.options.findIndex((o) => o.id === optionId);
|
|
7800
7951
|
if (curIdx < 0) return;
|
|
@@ -7852,8 +8003,8 @@ function ensureCatalog(catalog) {
|
|
|
7852
8003
|
return clone(catalog != null ? catalog : createEmptyCatalog());
|
|
7853
8004
|
}
|
|
7854
8005
|
function createCatalogId(catalog, prefix = "cg") {
|
|
7855
|
-
var
|
|
7856
|
-
const taken = new Set(((
|
|
8006
|
+
var _a2;
|
|
8007
|
+
const taken = new Set(((_a2 = catalog == null ? void 0 : catalog.nodes) != null ? _a2 : []).map((x) => x.id));
|
|
7857
8008
|
for (let i = 1; i < 1e4; i++) {
|
|
7858
8009
|
const id = `${prefix}:${i}`;
|
|
7859
8010
|
if (!taken.has(id)) return id;
|
|
@@ -7861,9 +8012,9 @@ function createCatalogId(catalog, prefix = "cg") {
|
|
|
7861
8012
|
throw new Error("Unable to generate catalog id");
|
|
7862
8013
|
}
|
|
7863
8014
|
function addCatalogGroup(catalog, input) {
|
|
7864
|
-
var
|
|
8015
|
+
var _a2;
|
|
7865
8016
|
const next = ensureCatalog(catalog);
|
|
7866
|
-
const id = (
|
|
8017
|
+
const id = (_a2 = input.id) != null ? _a2 : createCatalogId(next, "cg");
|
|
7867
8018
|
next.nodes.push({
|
|
7868
8019
|
id,
|
|
7869
8020
|
kind: "group",
|
|
@@ -7880,9 +8031,9 @@ function addCatalogGroup(catalog, input) {
|
|
|
7880
8031
|
return next;
|
|
7881
8032
|
}
|
|
7882
8033
|
function addSmartCatalogGroup(catalog, input) {
|
|
7883
|
-
var
|
|
8034
|
+
var _a2, _b, _c;
|
|
7884
8035
|
const next = ensureCatalog(catalog);
|
|
7885
|
-
const id = (
|
|
8036
|
+
const id = (_a2 = input.id) != null ? _a2 : createCatalogId(next, "csg");
|
|
7886
8037
|
next.nodes.push({
|
|
7887
8038
|
id,
|
|
7888
8039
|
kind: "smart-group",
|
|
@@ -7900,7 +8051,7 @@ function addSmartCatalogGroup(catalog, input) {
|
|
|
7900
8051
|
return next;
|
|
7901
8052
|
}
|
|
7902
8053
|
function updateCatalogNode(catalog, id, patch) {
|
|
7903
|
-
var
|
|
8054
|
+
var _a2;
|
|
7904
8055
|
if (!catalog) return catalog;
|
|
7905
8056
|
const next = ensureCatalog(catalog);
|
|
7906
8057
|
const idx = next.nodes.findIndex((x) => x.id === id);
|
|
@@ -7910,7 +8061,7 @@ function updateCatalogNode(catalog, id, patch) {
|
|
|
7910
8061
|
...current,
|
|
7911
8062
|
...patch
|
|
7912
8063
|
};
|
|
7913
|
-
if (((
|
|
8064
|
+
if (((_a2 = next.nodes[idx]) == null ? void 0 : _a2.kind) === "group") {
|
|
7914
8065
|
next.nodes[idx] = {
|
|
7915
8066
|
...next.nodes[idx],
|
|
7916
8067
|
serviceIds: normalizeServiceIds(
|
|
@@ -7936,27 +8087,27 @@ function setSelectedCatalogService(catalog, serviceId) {
|
|
|
7936
8087
|
return next;
|
|
7937
8088
|
}
|
|
7938
8089
|
function toggleCatalogExpanded(catalog, id) {
|
|
7939
|
-
var
|
|
8090
|
+
var _a2;
|
|
7940
8091
|
const next = ensureCatalog(catalog);
|
|
7941
|
-
const expanded = new Set((
|
|
8092
|
+
const expanded = new Set((_a2 = next.expandedIds) != null ? _a2 : []);
|
|
7942
8093
|
if (expanded.has(id)) expanded.delete(id);
|
|
7943
8094
|
else expanded.add(id);
|
|
7944
8095
|
next.expandedIds = Array.from(expanded);
|
|
7945
8096
|
return next;
|
|
7946
8097
|
}
|
|
7947
8098
|
function setCatalogExpanded(catalog, id, expanded) {
|
|
7948
|
-
var
|
|
8099
|
+
var _a2;
|
|
7949
8100
|
const next = ensureCatalog(catalog);
|
|
7950
|
-
const set = new Set((
|
|
8101
|
+
const set = new Set((_a2 = next.expandedIds) != null ? _a2 : []);
|
|
7951
8102
|
if (expanded) set.add(id);
|
|
7952
8103
|
else set.delete(id);
|
|
7953
8104
|
next.expandedIds = Array.from(set);
|
|
7954
8105
|
return next;
|
|
7955
8106
|
}
|
|
7956
8107
|
function toggleCatalogPinned(catalog, id) {
|
|
7957
|
-
var
|
|
8108
|
+
var _a2;
|
|
7958
8109
|
const next = ensureCatalog(catalog);
|
|
7959
|
-
const pinned = new Set((
|
|
8110
|
+
const pinned = new Set((_a2 = next.pinnedNodeIds) != null ? _a2 : []);
|
|
7960
8111
|
if (pinned.has(id)) pinned.delete(id);
|
|
7961
8112
|
else pinned.add(id);
|
|
7962
8113
|
next.pinnedNodeIds = Array.from(pinned);
|
|
@@ -7985,7 +8136,7 @@ function assignServicesToCatalogGroup(catalog, nodeId, serviceIds, mode = "appen
|
|
|
7985
8136
|
return next;
|
|
7986
8137
|
}
|
|
7987
8138
|
function removeCatalogNode(catalog, id, opts) {
|
|
7988
|
-
var
|
|
8139
|
+
var _a2, _b;
|
|
7989
8140
|
if (!catalog) return catalog;
|
|
7990
8141
|
const next = ensureCatalog(catalog);
|
|
7991
8142
|
const ids = /* @__PURE__ */ new Set([id]);
|
|
@@ -8007,7 +8158,7 @@ function removeCatalogNode(catalog, id, opts) {
|
|
|
8007
8158
|
if (next.activeNodeId && ids.has(next.activeNodeId)) {
|
|
8008
8159
|
next.activeNodeId = void 0;
|
|
8009
8160
|
}
|
|
8010
|
-
next.expandedIds = ((
|
|
8161
|
+
next.expandedIds = ((_a2 = next.expandedIds) != null ? _a2 : []).filter((x) => !ids.has(x));
|
|
8011
8162
|
next.pinnedNodeIds = ((_b = next.pinnedNodeIds) != null ? _b : []).filter((x) => !ids.has(x));
|
|
8012
8163
|
return next;
|
|
8013
8164
|
}
|
|
@@ -8018,8 +8169,8 @@ function moveCatalogNode(catalog, nodeId, opts) {
|
|
|
8018
8169
|
if (!node) return next;
|
|
8019
8170
|
node.parentId = opts.parentId;
|
|
8020
8171
|
const siblings = next.nodes.filter((x) => x.parentId === opts.parentId && x.id !== nodeId).sort((a, b) => {
|
|
8021
|
-
var
|
|
8022
|
-
return ((
|
|
8172
|
+
var _a2, _b;
|
|
8173
|
+
return ((_a2 = a.order) != null ? _a2 : 0) - ((_b = b.order) != null ? _b : 0);
|
|
8023
8174
|
});
|
|
8024
8175
|
let dest = typeof opts.index === "number" ? opts.index : siblings.length;
|
|
8025
8176
|
if (opts.beforeId) {
|
|
@@ -8038,20 +8189,20 @@ function moveCatalogNode(catalog, nodeId, opts) {
|
|
|
8038
8189
|
return next;
|
|
8039
8190
|
}
|
|
8040
8191
|
function resolveSmartCatalogGroup(catalog, nodeId, candidates, matchers) {
|
|
8041
|
-
var
|
|
8192
|
+
var _a2, _b;
|
|
8042
8193
|
if (!catalog) return catalog;
|
|
8043
8194
|
const next = ensureCatalog(catalog);
|
|
8044
8195
|
const node = next.nodes.find(
|
|
8045
8196
|
(x) => x.id === nodeId && x.kind === "smart-group"
|
|
8046
8197
|
);
|
|
8047
8198
|
if (!node) return next;
|
|
8048
|
-
const rules = (
|
|
8199
|
+
const rules = (_a2 = node.rules) != null ? _a2 : [];
|
|
8049
8200
|
const mode = (_b = node.match) != null ? _b : "all";
|
|
8050
8201
|
const resolved = candidates.filter((candidate) => {
|
|
8051
8202
|
const results = rules.map((rule) => {
|
|
8052
|
-
var
|
|
8203
|
+
var _a3, _b2, _c, _d, _e, _f;
|
|
8053
8204
|
if (rule.type === "service-field") {
|
|
8054
|
-
return (_b2 = (
|
|
8205
|
+
return (_b2 = (_a3 = matchers.serviceField) == null ? void 0 : _a3.call(matchers, candidate, rule)) != null ? _b2 : false;
|
|
8055
8206
|
}
|
|
8056
8207
|
if (rule.type === "policy-family") {
|
|
8057
8208
|
return (_d = (_c = matchers.policyFamily) == null ? void 0 : _c.call(matchers, candidate, rule)) != null ? _d : false;
|
|
@@ -8072,14 +8223,14 @@ var Editor = class {
|
|
|
8072
8223
|
this.history = [];
|
|
8073
8224
|
this.index = -1;
|
|
8074
8225
|
this.txnDepth = 0;
|
|
8075
|
-
var
|
|
8226
|
+
var _a2, _b;
|
|
8076
8227
|
this.builder = builder;
|
|
8077
8228
|
this.api = api;
|
|
8078
8229
|
this.opts = {
|
|
8079
8230
|
...opts,
|
|
8080
8231
|
historyLimit: Math.max(
|
|
8081
8232
|
1,
|
|
8082
|
-
Math.min((
|
|
8233
|
+
Math.min((_a2 = opts.historyLimit) != null ? _a2 : MAX_LIMIT, 1e3)
|
|
8083
8234
|
),
|
|
8084
8235
|
validateAfterEach: (_b = opts.validateAfterEach) != null ? _b : false
|
|
8085
8236
|
};
|
|
@@ -8122,14 +8273,14 @@ var Editor = class {
|
|
|
8122
8273
|
}
|
|
8123
8274
|
}
|
|
8124
8275
|
exec(cmd) {
|
|
8125
|
-
var
|
|
8276
|
+
var _a2;
|
|
8126
8277
|
try {
|
|
8127
8278
|
const before = this.makeSnapshot(cmd.name + ":before");
|
|
8128
8279
|
cmd.do();
|
|
8129
8280
|
this.afterMutation(cmd.name, before);
|
|
8130
8281
|
} catch (err) {
|
|
8131
8282
|
this.emit("editor:error", {
|
|
8132
|
-
message: (
|
|
8283
|
+
message: (_a2 = err == null ? void 0 : err.message) != null ? _a2 : String(err),
|
|
8133
8284
|
code: "command"
|
|
8134
8285
|
});
|
|
8135
8286
|
throw err;
|
|
@@ -8161,6 +8312,9 @@ var Editor = class {
|
|
|
8161
8312
|
duplicate(ref, opts = {}) {
|
|
8162
8313
|
return duplicate(this.moduleCtx(), ref, opts);
|
|
8163
8314
|
}
|
|
8315
|
+
duplicateMany(ids, opts = {}) {
|
|
8316
|
+
return duplicateMany(this.moduleCtx(), ids, opts);
|
|
8317
|
+
}
|
|
8164
8318
|
reLabel(id, nextLabel) {
|
|
8165
8319
|
return reLabel(this.moduleCtx(), id, nextLabel);
|
|
8166
8320
|
}
|
|
@@ -8224,6 +8378,260 @@ var Editor = class {
|
|
|
8224
8378
|
remove(id) {
|
|
8225
8379
|
return remove(this.moduleCtx(), id);
|
|
8226
8380
|
}
|
|
8381
|
+
removeMany(ids) {
|
|
8382
|
+
return removeMany(this.moduleCtx(), ids);
|
|
8383
|
+
}
|
|
8384
|
+
clearServiceMany(ids) {
|
|
8385
|
+
const ordered = Array.from(new Set((ids != null ? ids : []).map((id) => String(id))));
|
|
8386
|
+
if (!ordered.length) return;
|
|
8387
|
+
this.transact("clearServiceMany", () => {
|
|
8388
|
+
this.patchProps((p) => {
|
|
8389
|
+
var _a2, _b, _c, _d;
|
|
8390
|
+
for (const id of ordered) {
|
|
8391
|
+
if (this.isTagId(id)) {
|
|
8392
|
+
const t = ((_a2 = p.filters) != null ? _a2 : []).find((x) => x.id === id);
|
|
8393
|
+
if (t && "service_id" in t) delete t.service_id;
|
|
8394
|
+
continue;
|
|
8395
|
+
}
|
|
8396
|
+
if (this.isFieldId(id)) {
|
|
8397
|
+
const f = ((_b = p.fields) != null ? _b : []).find((x) => x.id === id);
|
|
8398
|
+
if (f && "service_id" in f) delete f.service_id;
|
|
8399
|
+
continue;
|
|
8400
|
+
}
|
|
8401
|
+
if (this.isOptionId(id)) {
|
|
8402
|
+
const own = ownerOfOption(p, id);
|
|
8403
|
+
if (!own) continue;
|
|
8404
|
+
const f = ((_c = p.fields) != null ? _c : []).find((x) => x.id === own.fieldId);
|
|
8405
|
+
const o = (_d = f == null ? void 0 : f.options) == null ? void 0 : _d.find((x) => x.id === id);
|
|
8406
|
+
if (o && "service_id" in o) delete o.service_id;
|
|
8407
|
+
}
|
|
8408
|
+
}
|
|
8409
|
+
});
|
|
8410
|
+
});
|
|
8411
|
+
}
|
|
8412
|
+
rebindMany(ids, targetTagId, opts) {
|
|
8413
|
+
const ordered = Array.from(new Set((ids != null ? ids : []).map((id) => String(id))));
|
|
8414
|
+
if (!ordered.length) return;
|
|
8415
|
+
this.transact("rebindMany", () => {
|
|
8416
|
+
this.patchProps((p) => {
|
|
8417
|
+
var _a2, _b, _c;
|
|
8418
|
+
const targetExists = ((_a2 = p.filters) != null ? _a2 : []).some((t) => t.id === targetTagId);
|
|
8419
|
+
if (!targetExists) return;
|
|
8420
|
+
for (const id of ordered) {
|
|
8421
|
+
if (this.isFieldId(id)) {
|
|
8422
|
+
const f = ((_b = p.fields) != null ? _b : []).find((x) => x.id === id);
|
|
8423
|
+
if (!f) continue;
|
|
8424
|
+
f.bind_id = targetTagId;
|
|
8425
|
+
continue;
|
|
8426
|
+
}
|
|
8427
|
+
if (this.isTagId(id)) {
|
|
8428
|
+
const t = ((_c = p.filters) != null ? _c : []).find((x) => x.id === id);
|
|
8429
|
+
if (!t) continue;
|
|
8430
|
+
if (!(opts == null ? void 0 : opts.allowTagCycles) && wouldCreateTagCycle(this.moduleCtx(), p, targetTagId, id)) {
|
|
8431
|
+
continue;
|
|
8432
|
+
}
|
|
8433
|
+
t.bind_id = targetTagId;
|
|
8434
|
+
}
|
|
8435
|
+
}
|
|
8436
|
+
});
|
|
8437
|
+
});
|
|
8438
|
+
}
|
|
8439
|
+
includeMany(receiverId, ids) {
|
|
8440
|
+
const accepted = Array.from(new Set((ids != null ? ids : []).map((id) => String(id)))).filter((id) => id !== receiverId).filter((id) => this.getNode(id).data != null);
|
|
8441
|
+
if (!accepted.length) return;
|
|
8442
|
+
include(this.moduleCtx(), receiverId, accepted);
|
|
8443
|
+
}
|
|
8444
|
+
excludeMany(receiverId, ids) {
|
|
8445
|
+
const accepted = Array.from(new Set((ids != null ? ids : []).map((id) => String(id)))).filter((id) => id !== receiverId).filter((id) => this.getNode(id).data != null);
|
|
8446
|
+
if (!accepted.length) return;
|
|
8447
|
+
exclude(this.moduleCtx(), receiverId, accepted);
|
|
8448
|
+
}
|
|
8449
|
+
clearRelationsMany(ids, mode = "both") {
|
|
8450
|
+
const selected = new Set(Array.from(new Set((ids != null ? ids : []).map((id) => String(id)))));
|
|
8451
|
+
if (!selected.size) return;
|
|
8452
|
+
this.transact("clearRelationsMany", () => {
|
|
8453
|
+
this.patchProps((p) => {
|
|
8454
|
+
var _a2, _b, _c;
|
|
8455
|
+
const clearOwned = mode === "owned" || mode === "both";
|
|
8456
|
+
const clearIncoming = mode === "incoming" || mode === "both";
|
|
8457
|
+
for (const t of (_a2 = p.filters) != null ? _a2 : []) {
|
|
8458
|
+
if (clearOwned && selected.has(t.id)) {
|
|
8459
|
+
delete t.includes;
|
|
8460
|
+
delete t.excludes;
|
|
8461
|
+
}
|
|
8462
|
+
if (clearIncoming) {
|
|
8463
|
+
if (t.includes) {
|
|
8464
|
+
t.includes = t.includes.filter((x) => !selected.has(String(x)));
|
|
8465
|
+
if (!t.includes.length) delete t.includes;
|
|
8466
|
+
}
|
|
8467
|
+
if (t.excludes) {
|
|
8468
|
+
t.excludes = t.excludes.filter((x) => !selected.has(String(x)));
|
|
8469
|
+
if (!t.excludes.length) delete t.excludes;
|
|
8470
|
+
}
|
|
8471
|
+
}
|
|
8472
|
+
}
|
|
8473
|
+
const maps = [
|
|
8474
|
+
"includes_for_buttons",
|
|
8475
|
+
"excludes_for_buttons",
|
|
8476
|
+
"includes_for_options",
|
|
8477
|
+
"excludes_for_options"
|
|
8478
|
+
];
|
|
8479
|
+
for (const k of maps) {
|
|
8480
|
+
const map = p[k];
|
|
8481
|
+
if (!map) continue;
|
|
8482
|
+
for (const key of Object.keys(map)) {
|
|
8483
|
+
if (clearOwned && selected.has(String(key))) {
|
|
8484
|
+
delete map[key];
|
|
8485
|
+
continue;
|
|
8486
|
+
}
|
|
8487
|
+
if (clearIncoming) {
|
|
8488
|
+
map[key] = ((_b = map[key]) != null ? _b : []).filter((x) => !selected.has(String(x)));
|
|
8489
|
+
if (!((_c = map[key]) == null ? void 0 : _c.length)) delete map[key];
|
|
8490
|
+
}
|
|
8491
|
+
}
|
|
8492
|
+
if (!Object.keys(map).length) delete p[k];
|
|
8493
|
+
}
|
|
8494
|
+
});
|
|
8495
|
+
});
|
|
8496
|
+
}
|
|
8497
|
+
renameLabelsMany(ids, input) {
|
|
8498
|
+
var _a2, _b;
|
|
8499
|
+
const ordered = Array.from(new Set((ids != null ? ids : []).map((id) => String(id))));
|
|
8500
|
+
if (!ordered.length) return;
|
|
8501
|
+
const prefix = (_a2 = input.prefix) != null ? _a2 : "";
|
|
8502
|
+
const suffix = (_b = input.suffix) != null ? _b : "";
|
|
8503
|
+
this.transact("renameLabelsMany", () => {
|
|
8504
|
+
this.patchProps((p) => {
|
|
8505
|
+
var _a3, _b2, _c, _d, _e, _f, _g;
|
|
8506
|
+
for (const id of ordered) {
|
|
8507
|
+
if (this.isTagId(id)) {
|
|
8508
|
+
const t = ((_a3 = p.filters) != null ? _a3 : []).find((x) => x.id === id);
|
|
8509
|
+
if (t) t.label = `${prefix}${(_b2 = t.label) != null ? _b2 : ""}${suffix}`.trim();
|
|
8510
|
+
continue;
|
|
8511
|
+
}
|
|
8512
|
+
if (this.isFieldId(id)) {
|
|
8513
|
+
const f = ((_c = p.fields) != null ? _c : []).find((x) => x.id === id);
|
|
8514
|
+
if (f) f.label = `${prefix}${(_d = f.label) != null ? _d : ""}${suffix}`.trim();
|
|
8515
|
+
continue;
|
|
8516
|
+
}
|
|
8517
|
+
if (this.isOptionId(id)) {
|
|
8518
|
+
const own = ownerOfOption(p, id);
|
|
8519
|
+
if (!own) continue;
|
|
8520
|
+
const f = ((_e = p.fields) != null ? _e : []).find((x) => x.id === own.fieldId);
|
|
8521
|
+
const o = (_f = f == null ? void 0 : f.options) == null ? void 0 : _f.find((x) => x.id === id);
|
|
8522
|
+
if (o) o.label = `${prefix}${(_g = o.label) != null ? _g : ""}${suffix}`.trim();
|
|
8523
|
+
}
|
|
8524
|
+
}
|
|
8525
|
+
});
|
|
8526
|
+
});
|
|
8527
|
+
}
|
|
8528
|
+
setPricingRoleMany(ids, role) {
|
|
8529
|
+
const ordered = Array.from(new Set((ids != null ? ids : []).map((id) => String(id))));
|
|
8530
|
+
if (!ordered.length) return;
|
|
8531
|
+
this.transact("setPricingRoleMany", () => {
|
|
8532
|
+
for (const id of ordered) {
|
|
8533
|
+
if (this.isFieldId(id) || this.isOptionId(id)) {
|
|
8534
|
+
this.setService(id, { pricing_role: role });
|
|
8535
|
+
}
|
|
8536
|
+
}
|
|
8537
|
+
});
|
|
8538
|
+
}
|
|
8539
|
+
clearFieldDefaultsMany(ids) {
|
|
8540
|
+
const ordered = Array.from(new Set((ids != null ? ids : []).map((id) => String(id))));
|
|
8541
|
+
if (!ordered.length) return;
|
|
8542
|
+
this.transact("clearFieldDefaultsMany", () => {
|
|
8543
|
+
this.patchProps((p) => {
|
|
8544
|
+
var _a2;
|
|
8545
|
+
for (const id of ordered) {
|
|
8546
|
+
if (!this.isFieldId(id)) continue;
|
|
8547
|
+
const f = ((_a2 = p.fields) != null ? _a2 : []).find((x) => x.id === id);
|
|
8548
|
+
if (f && "defaults" in f) delete f.defaults;
|
|
8549
|
+
}
|
|
8550
|
+
});
|
|
8551
|
+
});
|
|
8552
|
+
}
|
|
8553
|
+
clearFieldValidationMany(ids) {
|
|
8554
|
+
const ordered = Array.from(new Set((ids != null ? ids : []).map((id) => String(id))));
|
|
8555
|
+
if (!ordered.length) return;
|
|
8556
|
+
this.transact("clearFieldValidationMany", () => {
|
|
8557
|
+
this.patchProps((p) => {
|
|
8558
|
+
var _a2;
|
|
8559
|
+
for (const id of ordered) {
|
|
8560
|
+
if (!this.isFieldId(id)) continue;
|
|
8561
|
+
const f = ((_a2 = p.fields) != null ? _a2 : []).find((x) => x.id === id);
|
|
8562
|
+
if (f && "validation" in f) delete f.validation;
|
|
8563
|
+
}
|
|
8564
|
+
});
|
|
8565
|
+
});
|
|
8566
|
+
}
|
|
8567
|
+
autoCreateOptionsMany(ids, makeOption) {
|
|
8568
|
+
const ordered = Array.from(new Set((ids != null ? ids : []).map((id) => String(id))));
|
|
8569
|
+
if (!ordered.length) return;
|
|
8570
|
+
this.transact("autoCreateOptionsMany", () => {
|
|
8571
|
+
this.patchProps((p) => {
|
|
8572
|
+
var _a2, _b, _c, _d;
|
|
8573
|
+
for (const id of ordered) {
|
|
8574
|
+
if (!this.isFieldId(id)) continue;
|
|
8575
|
+
const f = ((_a2 = p.fields) != null ? _a2 : []).find((x) => x.id === id);
|
|
8576
|
+
if (!f) continue;
|
|
8577
|
+
const opts = (_b = f.options) != null ? _b : f.options = [];
|
|
8578
|
+
if (opts.length > 0) continue;
|
|
8579
|
+
const next = (_c = makeOption == null ? void 0 : makeOption(id)) != null ? _c : { label: "Option label", value: "option" };
|
|
8580
|
+
opts.push({
|
|
8581
|
+
id: (_d = next.id) != null ? _d : this.moduleCtx().genId("o"),
|
|
8582
|
+
label: next.label,
|
|
8583
|
+
value: next.value
|
|
8584
|
+
});
|
|
8585
|
+
}
|
|
8586
|
+
});
|
|
8587
|
+
});
|
|
8588
|
+
}
|
|
8589
|
+
clearAllOptionsMany(ids) {
|
|
8590
|
+
var _a2, _b;
|
|
8591
|
+
const ordered = Array.from(new Set((ids != null ? ids : []).map((id) => String(id))));
|
|
8592
|
+
if (!ordered.length) return;
|
|
8593
|
+
const optionIds = [];
|
|
8594
|
+
const props = this.getProps();
|
|
8595
|
+
for (const id of ordered) {
|
|
8596
|
+
if (!this.isFieldId(id)) continue;
|
|
8597
|
+
const f = ((_a2 = props.fields) != null ? _a2 : []).find((x) => x.id === id);
|
|
8598
|
+
for (const o of (_b = f == null ? void 0 : f.options) != null ? _b : []) optionIds.push(o.id);
|
|
8599
|
+
}
|
|
8600
|
+
if (!optionIds.length) return;
|
|
8601
|
+
removeMany(this.moduleCtx(), optionIds);
|
|
8602
|
+
}
|
|
8603
|
+
removeNoticesForNodes(ids) {
|
|
8604
|
+
const selected = new Set(Array.from(new Set((ids != null ? ids : []).map((id) => String(id)))));
|
|
8605
|
+
if (!selected.size) return;
|
|
8606
|
+
this.transact("removeNoticesForNodes", () => {
|
|
8607
|
+
this.patchProps((p) => {
|
|
8608
|
+
var _a2;
|
|
8609
|
+
if (!((_a2 = p.notices) == null ? void 0 : _a2.length)) return;
|
|
8610
|
+
p.notices = p.notices.filter((n) => {
|
|
8611
|
+
const target = n.target;
|
|
8612
|
+
if (!target || target.scope === "global") return true;
|
|
8613
|
+
if (target.scope === "node") return !selected.has(String(target.node_id));
|
|
8614
|
+
return true;
|
|
8615
|
+
});
|
|
8616
|
+
if (!p.notices.length) delete p.notices;
|
|
8617
|
+
});
|
|
8618
|
+
});
|
|
8619
|
+
}
|
|
8620
|
+
setNoticesVisibilityForNodes(ids, type) {
|
|
8621
|
+
const selected = new Set(Array.from(new Set((ids != null ? ids : []).map((id) => String(id)))));
|
|
8622
|
+
if (!selected.size) return;
|
|
8623
|
+
this.transact("setNoticesVisibilityForNodes", () => {
|
|
8624
|
+
this.patchProps((p) => {
|
|
8625
|
+
var _a2;
|
|
8626
|
+
for (const n of (_a2 = p.notices) != null ? _a2 : []) {
|
|
8627
|
+
const target = n.target;
|
|
8628
|
+
if ((target == null ? void 0 : target.scope) === "node" && selected.has(String(target.node_id))) {
|
|
8629
|
+
n.type = type;
|
|
8630
|
+
}
|
|
8631
|
+
}
|
|
8632
|
+
});
|
|
8633
|
+
});
|
|
8634
|
+
}
|
|
8227
8635
|
getNode(id) {
|
|
8228
8636
|
return getNode(this.moduleCtx(), id);
|
|
8229
8637
|
}
|
|
@@ -8376,7 +8784,7 @@ var Editor = class {
|
|
|
8376
8784
|
);
|
|
8377
8785
|
}
|
|
8378
8786
|
resolveSmartCatalogGroup(nodeId, candidates, matchers) {
|
|
8379
|
-
var
|
|
8787
|
+
var _a2, _b;
|
|
8380
8788
|
const next = resolveSmartCatalogGroup(
|
|
8381
8789
|
this.catalog,
|
|
8382
8790
|
nodeId,
|
|
@@ -8387,7 +8795,7 @@ var Editor = class {
|
|
|
8387
8795
|
const node = next == null ? void 0 : next.nodes.find(
|
|
8388
8796
|
(x) => x.id === nodeId && x.kind === "smart-group"
|
|
8389
8797
|
);
|
|
8390
|
-
return (_b = (
|
|
8798
|
+
return (_b = (_a2 = node == null ? void 0 : node.resolvedServiceIds) == null ? void 0 : _a2.slice()) != null ? _b : [];
|
|
8391
8799
|
}
|
|
8392
8800
|
replaceCatalog(next, reason = "catalog:set") {
|
|
8393
8801
|
this.catalog = cloneDeep4(next);
|
|
@@ -8467,9 +8875,8 @@ var Editor = class {
|
|
|
8467
8875
|
Array.isArray(canvas.selection) ? canvas.selection : Array.from(canvas.selection)
|
|
8468
8876
|
);
|
|
8469
8877
|
}
|
|
8470
|
-
} else {
|
|
8471
|
-
this.api.refreshGraph();
|
|
8472
8878
|
}
|
|
8879
|
+
this.api.refreshGraph();
|
|
8473
8880
|
this.emit("editor:change", { props: s.props, reason, snapshot: s });
|
|
8474
8881
|
}
|
|
8475
8882
|
pushHistory(snap) {
|
|
@@ -8589,9 +8996,9 @@ var Selection = class {
|
|
|
8589
8996
|
}
|
|
8590
8997
|
// ── Main: visible group snapshot (env-aware) ─────────────────────────────
|
|
8591
8998
|
visibleGroup() {
|
|
8592
|
-
var
|
|
8999
|
+
var _a2;
|
|
8593
9000
|
const props = this.builder.getProps();
|
|
8594
|
-
if (((
|
|
9001
|
+
if (((_a2 = this.opts.env) != null ? _a2 : "client") === "workspace") {
|
|
8595
9002
|
const tagIds = Array.from(this.set).filter(
|
|
8596
9003
|
this.builder.isTagId.bind(this.builder)
|
|
8597
9004
|
);
|
|
@@ -8622,12 +9029,12 @@ var Selection = class {
|
|
|
8622
9029
|
* - de-dupes per field
|
|
8623
9030
|
*/
|
|
8624
9031
|
buttonSelectionsByFieldId() {
|
|
8625
|
-
var
|
|
9032
|
+
var _a2, _b, _c, _d, _e;
|
|
8626
9033
|
const nodeMap = this.builder.getNodeMap();
|
|
8627
9034
|
const out = {};
|
|
8628
9035
|
const push = (fieldId, triggerKey) => {
|
|
8629
|
-
var
|
|
8630
|
-
const arr = (
|
|
9036
|
+
var _a3;
|
|
9037
|
+
const arr = (_a3 = out[fieldId]) != null ? _a3 : out[fieldId] = [];
|
|
8631
9038
|
if (!arr.includes(triggerKey)) arr.push(triggerKey);
|
|
8632
9039
|
};
|
|
8633
9040
|
for (const key of this.set) {
|
|
@@ -8644,7 +9051,7 @@ var Selection = class {
|
|
|
8644
9051
|
const ref = nodeMap.get(key);
|
|
8645
9052
|
if (!ref) continue;
|
|
8646
9053
|
if (ref.kind === "option" && typeof ref.fieldId === "string") {
|
|
8647
|
-
push(ref.fieldId, (
|
|
9054
|
+
push(ref.fieldId, (_a2 = ref.id) != null ? _a2 : key);
|
|
8648
9055
|
continue;
|
|
8649
9056
|
}
|
|
8650
9057
|
if (ref.kind === "field") {
|
|
@@ -8665,7 +9072,7 @@ var Selection = class {
|
|
|
8665
9072
|
* Excludes tags and non-button fields.
|
|
8666
9073
|
*/
|
|
8667
9074
|
selectedButtons() {
|
|
8668
|
-
var
|
|
9075
|
+
var _a2, _b;
|
|
8669
9076
|
const nodeMap = this.builder.getNodeMap();
|
|
8670
9077
|
const out = [];
|
|
8671
9078
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -8691,7 +9098,7 @@ var Selection = class {
|
|
|
8691
9098
|
continue;
|
|
8692
9099
|
}
|
|
8693
9100
|
if (ref.kind === "field") {
|
|
8694
|
-
const field = (_b = (
|
|
9101
|
+
const field = (_b = (_a2 = ref.node) != null ? _a2 : ref.field) != null ? _b : ref;
|
|
8695
9102
|
if ((field == null ? void 0 : field.button) === true) push(key);
|
|
8696
9103
|
}
|
|
8697
9104
|
}
|
|
@@ -8706,9 +9113,9 @@ var Selection = class {
|
|
|
8706
9113
|
for (const fn of this.onChangeFns) fn(payload);
|
|
8707
9114
|
}
|
|
8708
9115
|
updateCurrentTagFrom(id) {
|
|
8709
|
-
var
|
|
9116
|
+
var _a2, _b;
|
|
8710
9117
|
const props = this.builder.getProps();
|
|
8711
|
-
const tags = (
|
|
9118
|
+
const tags = (_a2 = props.filters) != null ? _a2 : [];
|
|
8712
9119
|
const fields = (_b = props.fields) != null ? _b : [];
|
|
8713
9120
|
if (tags.some((t) => t.id === id)) {
|
|
8714
9121
|
this.currentTagId = id;
|
|
@@ -8724,8 +9131,8 @@ var Selection = class {
|
|
|
8724
9131
|
if (this.builder.isOptionId(id)) {
|
|
8725
9132
|
return fields.find(
|
|
8726
9133
|
(x) => {
|
|
8727
|
-
var
|
|
8728
|
-
return ((
|
|
9134
|
+
var _a3;
|
|
9135
|
+
return ((_a3 = x.options) != null ? _a3 : []).some((o) => o.id === id);
|
|
8729
9136
|
}
|
|
8730
9137
|
);
|
|
8731
9138
|
}
|
|
@@ -8752,10 +9159,10 @@ var Selection = class {
|
|
|
8752
9159
|
if (fallbackTagId) this.currentTagId = fallbackTagId;
|
|
8753
9160
|
}
|
|
8754
9161
|
resolveTagContextId(props) {
|
|
8755
|
-
var
|
|
9162
|
+
var _a2;
|
|
8756
9163
|
if (this.currentTagId) return this.currentTagId;
|
|
8757
9164
|
for (const id of this.set) if (this.builder.isTagId(id)) return id;
|
|
8758
|
-
const fields = (
|
|
9165
|
+
const fields = (_a2 = props.fields) != null ? _a2 : [];
|
|
8759
9166
|
for (const id of this.set) {
|
|
8760
9167
|
const f = fields.find((x) => x.id === id);
|
|
8761
9168
|
if (f == null ? void 0 : f.bind_id)
|
|
@@ -8765,8 +9172,8 @@ var Selection = class {
|
|
|
8765
9172
|
if (this.builder.isOptionId(id)) {
|
|
8766
9173
|
const host = fields.find(
|
|
8767
9174
|
(x) => {
|
|
8768
|
-
var
|
|
8769
|
-
return ((
|
|
9175
|
+
var _a3;
|
|
9176
|
+
return ((_a3 = x.options) != null ? _a3 : []).some((o) => o.id === id);
|
|
8770
9177
|
}
|
|
8771
9178
|
);
|
|
8772
9179
|
if (host == null ? void 0 : host.bind_id)
|
|
@@ -8782,8 +9189,8 @@ var Selection = class {
|
|
|
8782
9189
|
return this.opts.rootTagId;
|
|
8783
9190
|
}
|
|
8784
9191
|
computeGroupForTag(props, tagId) {
|
|
8785
|
-
var
|
|
8786
|
-
const tags = (
|
|
9192
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
9193
|
+
const tags = (_a2 = props.filters) != null ? _a2 : [];
|
|
8787
9194
|
const fields = (_b = props.fields) != null ? _b : [];
|
|
8788
9195
|
const tagById = new Map(tags.map((t) => [t.id, t]));
|
|
8789
9196
|
const tag = tagById.get(tagId);
|
|
@@ -8867,10 +9274,10 @@ var Selection = class {
|
|
|
8867
9274
|
return baseOverridden;
|
|
8868
9275
|
}
|
|
8869
9276
|
findOptionById(fields, selId) {
|
|
8870
|
-
var
|
|
9277
|
+
var _a2, _b;
|
|
8871
9278
|
if (this.builder.isOptionId(selId)) {
|
|
8872
9279
|
for (const f of fields) {
|
|
8873
|
-
const o = (
|
|
9280
|
+
const o = (_a2 = f.options) == null ? void 0 : _a2.find((x) => x.id === selId);
|
|
8874
9281
|
if (o) return o;
|
|
8875
9282
|
}
|
|
8876
9283
|
}
|
|
@@ -8895,9 +9302,9 @@ var CanvasAPI = class {
|
|
|
8895
9302
|
/* ─── Option-node visibility (per field) ───────────────────────────────── */
|
|
8896
9303
|
/** Internal mirror of which fields should show their options as nodes. */
|
|
8897
9304
|
this.shownOptionFields = /* @__PURE__ */ new Set();
|
|
8898
|
-
var
|
|
9305
|
+
var _a2, _b, _c;
|
|
8899
9306
|
this.builder = builder;
|
|
8900
|
-
this.autoEmit = (
|
|
9307
|
+
this.autoEmit = (_a2 = opts.autoEmitState) != null ? _a2 : true;
|
|
8901
9308
|
this.selection = new Selection(builder, {
|
|
8902
9309
|
env: "workspace",
|
|
8903
9310
|
rootTagId: "t:root"
|
|
@@ -9124,14 +9531,14 @@ function useOptionalFormApi() {
|
|
|
9124
9531
|
}
|
|
9125
9532
|
function FormProvider({ children, schema, initial }) {
|
|
9126
9533
|
const [bag, setBag] = React.useState(() => {
|
|
9127
|
-
var
|
|
9534
|
+
var _a2;
|
|
9128
9535
|
return {
|
|
9129
|
-
...(
|
|
9536
|
+
...(_a2 = initial == null ? void 0 : initial.values) != null ? _a2 : {}
|
|
9130
9537
|
};
|
|
9131
9538
|
});
|
|
9132
9539
|
const [selectionsBag, setSelectionsBag] = React.useState(() => {
|
|
9133
|
-
var
|
|
9134
|
-
return { ...(
|
|
9540
|
+
var _a2;
|
|
9541
|
+
return { ...(_a2 = initial == null ? void 0 : initial.selections) != null ? _a2 : {} };
|
|
9135
9542
|
});
|
|
9136
9543
|
const listenersRef = React.useRef(/* @__PURE__ */ new Set());
|
|
9137
9544
|
const publish = React.useCallback(() => {
|
|
@@ -9157,9 +9564,9 @@ function FormProvider({ children, schema, initial }) {
|
|
|
9157
9564
|
return () => listenersRef.current.delete(fn);
|
|
9158
9565
|
},
|
|
9159
9566
|
get(fieldId) {
|
|
9160
|
-
var
|
|
9567
|
+
var _a2, _b;
|
|
9161
9568
|
const core = coreRef.current;
|
|
9162
|
-
const live = (_b = (
|
|
9569
|
+
const live = (_b = (_a2 = core == null ? void 0 : core.values) == null ? void 0 : _a2.call(core)) != null ? _b : void 0;
|
|
9163
9570
|
if (live && fieldId in live) return live[fieldId];
|
|
9164
9571
|
return bag[fieldId];
|
|
9165
9572
|
},
|
|
@@ -9174,8 +9581,8 @@ function FormProvider({ children, schema, initial }) {
|
|
|
9174
9581
|
},
|
|
9175
9582
|
// Legacy selections API (compat; no longer used by the new Wrapper)
|
|
9176
9583
|
getSelections(fieldId) {
|
|
9177
|
-
var
|
|
9178
|
-
return (
|
|
9584
|
+
var _a2;
|
|
9585
|
+
return (_a2 = selectionsBag[fieldId]) != null ? _a2 : [];
|
|
9179
9586
|
},
|
|
9180
9587
|
setSelections(fieldId, optionIds) {
|
|
9181
9588
|
setSelectionsBag((prev) => ({
|
|
@@ -9186,8 +9593,8 @@ function FormProvider({ children, schema, initial }) {
|
|
|
9186
9593
|
},
|
|
9187
9594
|
toggleSelection(fieldId, optionId) {
|
|
9188
9595
|
setSelectionsBag((prev) => {
|
|
9189
|
-
var
|
|
9190
|
-
const current = new Set((
|
|
9596
|
+
var _a2;
|
|
9597
|
+
const current = new Set((_a2 = prev[fieldId]) != null ? _a2 : []);
|
|
9191
9598
|
if (current.has(optionId)) current.delete(optionId);
|
|
9192
9599
|
else current.add(optionId);
|
|
9193
9600
|
return { ...prev, [fieldId]: Array.from(current) };
|
|
@@ -9198,17 +9605,17 @@ function FormProvider({ children, schema, initial }) {
|
|
|
9198
9605
|
const [fieldId, optionId] = String(token).split(":", 2);
|
|
9199
9606
|
if (!fieldId || !optionId) return;
|
|
9200
9607
|
setSelectionsBag((prev) => {
|
|
9201
|
-
var
|
|
9202
|
-
const current = new Set((
|
|
9608
|
+
var _a2;
|
|
9609
|
+
const current = new Set((_a2 = prev[fieldId]) != null ? _a2 : []);
|
|
9203
9610
|
current.delete(optionId);
|
|
9204
9611
|
return { ...prev, [fieldId]: Array.from(current) };
|
|
9205
9612
|
});
|
|
9206
9613
|
publish();
|
|
9207
9614
|
},
|
|
9208
9615
|
snapshot() {
|
|
9209
|
-
var
|
|
9616
|
+
var _a2, _b;
|
|
9210
9617
|
const core = coreRef.current;
|
|
9211
|
-
const live = (_b = (
|
|
9618
|
+
const live = (_b = (_a2 = core == null ? void 0 : core.values) == null ? void 0 : _a2.call(core)) != null ? _b : {};
|
|
9212
9619
|
return live;
|
|
9213
9620
|
},
|
|
9214
9621
|
submit() {
|
|
@@ -9248,11 +9655,11 @@ function FormProvider({ children, schema, initial }) {
|
|
|
9248
9655
|
function createInputRegistry() {
|
|
9249
9656
|
const store = /* @__PURE__ */ new Map();
|
|
9250
9657
|
const get = (kind, variant) => {
|
|
9251
|
-
var
|
|
9658
|
+
var _a2;
|
|
9252
9659
|
const vm = store.get(kind);
|
|
9253
9660
|
if (!vm) return void 0;
|
|
9254
9661
|
const v = variant != null ? variant : "default";
|
|
9255
|
-
return (
|
|
9662
|
+
return (_a2 = vm.get(v)) != null ? _a2 : vm.get("default");
|
|
9256
9663
|
};
|
|
9257
9664
|
const register = (kind, descriptor, variant) => {
|
|
9258
9665
|
let vm = store.get(kind);
|
|
@@ -9306,6 +9713,9 @@ function useInputs() {
|
|
|
9306
9713
|
if (!v) throw new Error("useInputs() must be used within <InputsProvider>");
|
|
9307
9714
|
return v;
|
|
9308
9715
|
}
|
|
9716
|
+
function useInputsMaybe() {
|
|
9717
|
+
return useContext2(Ctx2);
|
|
9718
|
+
}
|
|
9309
9719
|
|
|
9310
9720
|
// src/react/inputs/wrapper.tsx
|
|
9311
9721
|
import * as React4 from "react";
|
|
@@ -9344,9 +9754,9 @@ function findDefaultTagId(tags) {
|
|
|
9344
9754
|
return hasRoot ? ROOT_TAG_ID : tags[0].id;
|
|
9345
9755
|
}
|
|
9346
9756
|
function mapSnapshotFormToFieldIds(builder, snap) {
|
|
9347
|
-
var
|
|
9757
|
+
var _a2, _b, _c, _d, _e;
|
|
9348
9758
|
const byFieldId = {};
|
|
9349
|
-
const form = (_b = (
|
|
9759
|
+
const form = (_b = (_a2 = snap.inputs) == null ? void 0 : _a2.form) != null ? _b : {};
|
|
9350
9760
|
const fields = (_c = builder.getProps().fields) != null ? _c : [];
|
|
9351
9761
|
const nameToIds = /* @__PURE__ */ new Map();
|
|
9352
9762
|
for (const f of fields) {
|
|
@@ -9372,8 +9782,8 @@ function makeDefaultFallback(mode, patch) {
|
|
|
9372
9782
|
};
|
|
9373
9783
|
}
|
|
9374
9784
|
function normalizeInit(init) {
|
|
9375
|
-
var
|
|
9376
|
-
const mode = (
|
|
9785
|
+
var _a2, _b, _c;
|
|
9786
|
+
const mode = (_a2 = init.mode) != null ? _a2 : "prod";
|
|
9377
9787
|
const hostDefaultQuantity = Number.isFinite((_b = init.hostDefaultQuantity) != null ? _b : 1) ? Number((_c = init.hostDefaultQuantity) != null ? _c : 1) : 1;
|
|
9378
9788
|
return { ...init, mode, hostDefaultQuantity };
|
|
9379
9789
|
}
|
|
@@ -9415,8 +9825,8 @@ var OrderFlowProvider = forwardRef(function OrderFlowProvider2({
|
|
|
9415
9825
|
const bump = () => force((x) => x + 1);
|
|
9416
9826
|
const resolveBuilder = useCallback2(
|
|
9417
9827
|
(p) => {
|
|
9418
|
-
var
|
|
9419
|
-
if ((
|
|
9828
|
+
var _a2, _b;
|
|
9829
|
+
if ((_a2 = p.flow) == null ? void 0 : _a2.builder) return p.flow.builder;
|
|
9420
9830
|
if (p.builder) return p.builder;
|
|
9421
9831
|
if (p.serviceProps) {
|
|
9422
9832
|
const b = createBuilder((_b = p.builderOptions) != null ? _b : {});
|
|
@@ -9452,8 +9862,8 @@ var OrderFlowProvider = forwardRef(function OrderFlowProvider2({
|
|
|
9452
9862
|
}, []);
|
|
9453
9863
|
const resolveSelection = useCallback2(
|
|
9454
9864
|
(b, nInit, p) => {
|
|
9455
|
-
var
|
|
9456
|
-
return (_c = (_b = (
|
|
9865
|
+
var _a2, _b, _c;
|
|
9866
|
+
return (_c = (_b = (_a2 = p.flow) == null ? void 0 : _a2.selection) != null ? _b : p.selection) != null ? _c : new Selection(b, {
|
|
9457
9867
|
env: "client",
|
|
9458
9868
|
rootTagId: ROOT_TAG_ID,
|
|
9459
9869
|
resolveService: nInit.resolveService
|
|
@@ -9483,7 +9893,7 @@ var OrderFlowProvider = forwardRef(function OrderFlowProvider2({
|
|
|
9483
9893
|
}, []);
|
|
9484
9894
|
const initialize = useCallback2(
|
|
9485
9895
|
(params) => {
|
|
9486
|
-
var
|
|
9896
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
9487
9897
|
const b = resolveBuilder(params);
|
|
9488
9898
|
if (!b) {
|
|
9489
9899
|
throw new Error(
|
|
@@ -9503,7 +9913,7 @@ var OrderFlowProvider = forwardRef(function OrderFlowProvider2({
|
|
|
9503
9913
|
unsubRef.current = sel.onChange(
|
|
9504
9914
|
() => setActiveTagId(sel.currentTag())
|
|
9505
9915
|
);
|
|
9506
|
-
const tags = (
|
|
9916
|
+
const tags = (_a2 = b.getProps().filters) != null ? _a2 : [];
|
|
9507
9917
|
const hydratedTag = (_c = (_b = nInit.hydrateFrom) == null ? void 0 : _b.selection) == null ? void 0 : _c.tag;
|
|
9508
9918
|
const initialTag = nInit.hydrateFrom ? hydratedTag : (_d = nInit.initialTagId) != null ? _d : findDefaultTagId(tags);
|
|
9509
9919
|
if (initialTag) sel.replace(initialTag);
|
|
@@ -9556,14 +9966,14 @@ var OrderFlowProvider = forwardRef(function OrderFlowProvider2({
|
|
|
9556
9966
|
serviceProps
|
|
9557
9967
|
]);
|
|
9558
9968
|
useEffect2(() => {
|
|
9559
|
-
var
|
|
9969
|
+
var _a2, _b, _c, _d, _e;
|
|
9560
9970
|
if (!serviceProps) return;
|
|
9561
9971
|
if (!ready()) return;
|
|
9562
9972
|
const currentBuilder = builderRef.current;
|
|
9563
9973
|
if (!currentBuilder || currentBuilder !== resolvedBuilder) return;
|
|
9564
9974
|
if (!sameServiceProps(currentBuilder.getProps(), serviceProps)) {
|
|
9565
9975
|
currentBuilder.load(serviceProps);
|
|
9566
|
-
const currentTag = (
|
|
9976
|
+
const currentTag = (_a2 = selectionRef.current) == null ? void 0 : _a2.currentTag();
|
|
9567
9977
|
if (selectionRef.current && currentTag && !currentBuilder.isTagId(currentTag)) {
|
|
9568
9978
|
const nextTag = (_e = findDefaultTagId((_b = currentBuilder.getProps().filters) != null ? _b : [])) != null ? _e : (_d = (_c = currentBuilder.getProps().filters) == null ? void 0 : _c[0]) == null ? void 0 : _d.id;
|
|
9569
9979
|
if (nextTag) selectionRef.current.replace(nextTag);
|
|
@@ -9585,12 +9995,12 @@ var OrderFlowProvider = forwardRef(function OrderFlowProvider2({
|
|
|
9585
9995
|
[ensureReady]
|
|
9586
9996
|
);
|
|
9587
9997
|
const clearAllFields = useCallback2(() => {
|
|
9588
|
-
var
|
|
9998
|
+
var _a2;
|
|
9589
9999
|
const api = formApiRef.current;
|
|
9590
10000
|
if (!api) return;
|
|
9591
10001
|
const b = builderRef.current;
|
|
9592
10002
|
if (!b) return;
|
|
9593
|
-
const fields = (
|
|
10003
|
+
const fields = (_a2 = b.getProps().fields) != null ? _a2 : [];
|
|
9594
10004
|
for (const f of fields) {
|
|
9595
10005
|
api.set(f.id, void 0);
|
|
9596
10006
|
api.setSelections(f.id, []);
|
|
@@ -9598,11 +10008,11 @@ var OrderFlowProvider = forwardRef(function OrderFlowProvider2({
|
|
|
9598
10008
|
}, []);
|
|
9599
10009
|
const setSnapshot = useCallback2(
|
|
9600
10010
|
(snap, opts) => {
|
|
9601
|
-
var
|
|
10011
|
+
var _a2, _b, _c, _d;
|
|
9602
10012
|
const api = formApiRef.current;
|
|
9603
10013
|
if (!api) return;
|
|
9604
10014
|
const { builder, selection } = ensureReady("setSnapshot");
|
|
9605
|
-
const clearFirst = (
|
|
10015
|
+
const clearFirst = (_a2 = opts == null ? void 0 : opts.clearFirst) != null ? _a2 : true;
|
|
9606
10016
|
const tag = (_b = snap.selection) == null ? void 0 : _b.tag;
|
|
9607
10017
|
if (tag) selection.replace(tag);
|
|
9608
10018
|
if (clearFirst) clearAllFields();
|
|
@@ -9617,8 +10027,8 @@ var OrderFlowProvider = forwardRef(function OrderFlowProvider2({
|
|
|
9617
10027
|
);
|
|
9618
10028
|
const reset = useCallback2(
|
|
9619
10029
|
(opts) => {
|
|
9620
|
-
var
|
|
9621
|
-
const keepTag = (
|
|
10030
|
+
var _a2, _b, _c, _d;
|
|
10031
|
+
const keepTag = (_a2 = opts == null ? void 0 : opts.keepTag) != null ? _a2 : false;
|
|
9622
10032
|
const { builder, selection } = ensureReady("reset");
|
|
9623
10033
|
if (!keepTag) {
|
|
9624
10034
|
const tags = (_b = builder.getProps().filters) != null ? _b : [];
|
|
@@ -9648,10 +10058,10 @@ var OrderFlowProvider = forwardRef(function OrderFlowProvider2({
|
|
|
9648
10058
|
return mapSnapshotFormToFieldIds(b, i.hydrateFrom);
|
|
9649
10059
|
}, [force]);
|
|
9650
10060
|
const initialSelections = useMemo3(() => {
|
|
9651
|
-
var
|
|
10061
|
+
var _a2, _b;
|
|
9652
10062
|
const i = initRef.current;
|
|
9653
10063
|
if (!(i == null ? void 0 : i.hydrateFrom)) return {};
|
|
9654
|
-
return (_b = (
|
|
10064
|
+
return (_b = (_a2 = i.hydrateFrom.inputs) == null ? void 0 : _a2.selections) != null ? _b : {};
|
|
9655
10065
|
}, [force]);
|
|
9656
10066
|
useImperativeHandle(
|
|
9657
10067
|
ref,
|
|
@@ -9666,8 +10076,8 @@ var OrderFlowProvider = forwardRef(function OrderFlowProvider2({
|
|
|
9666
10076
|
setSnapshot,
|
|
9667
10077
|
reset,
|
|
9668
10078
|
refresh: () => {
|
|
9669
|
-
var
|
|
9670
|
-
return setActiveTagId((
|
|
10079
|
+
var _a2;
|
|
10080
|
+
return setActiveTagId((_a2 = selectionRef.current) == null ? void 0 : _a2.currentTag());
|
|
9671
10081
|
}
|
|
9672
10082
|
}),
|
|
9673
10083
|
[
|
|
@@ -9716,8 +10126,8 @@ var OrderFlowProvider = forwardRef(function OrderFlowProvider2({
|
|
|
9716
10126
|
|
|
9717
10127
|
// src/react/hooks/evalute-field-validation.ts
|
|
9718
10128
|
function evaluateFieldValidationRule(rule, raw) {
|
|
9719
|
-
var
|
|
9720
|
-
const valueBy = (
|
|
10129
|
+
var _a2, _b;
|
|
10130
|
+
const valueBy = (_a2 = rule.valueBy) != null ? _a2 : "value";
|
|
9721
10131
|
let subject = raw;
|
|
9722
10132
|
if (valueBy === "length") {
|
|
9723
10133
|
if (typeof raw === "string" || Array.isArray(raw)) subject = raw.length;
|
|
@@ -9762,11 +10172,11 @@ function evaluateFieldValidationRule(rule, raw) {
|
|
|
9762
10172
|
}
|
|
9763
10173
|
}
|
|
9764
10174
|
function validateVisibleFields(visibleFieldIds, fieldById, formValuesByFieldId) {
|
|
9765
|
-
var
|
|
10175
|
+
var _a2;
|
|
9766
10176
|
const out = [];
|
|
9767
10177
|
for (const fid of visibleFieldIds) {
|
|
9768
10178
|
const field = fieldById.get(fid);
|
|
9769
|
-
if (!((
|
|
10179
|
+
if (!((_a2 = field == null ? void 0 : field.validation) == null ? void 0 : _a2.length)) continue;
|
|
9770
10180
|
const value = formValuesByFieldId[fid];
|
|
9771
10181
|
for (const rule of field.validation) {
|
|
9772
10182
|
const ok = evaluateFieldValidationRule(rule, value);
|
|
@@ -9786,7 +10196,7 @@ function validateVisibleFields(visibleFieldIds, fieldById, formValuesByFieldId)
|
|
|
9786
10196
|
// src/react/hooks/use-order-flow.ts
|
|
9787
10197
|
var ROOT_TAG_ID2 = "t:root";
|
|
9788
10198
|
function useOrderFlow() {
|
|
9789
|
-
var
|
|
10199
|
+
var _a2, _b, _c;
|
|
9790
10200
|
const ctx = useOrderFlowContext();
|
|
9791
10201
|
const ready = ctx.ready();
|
|
9792
10202
|
const initialize = useCallback3(
|
|
@@ -9812,22 +10222,22 @@ function useOrderFlow() {
|
|
|
9812
10222
|
return ctx.formApi.subscribe(() => setFormTick((x) => x + 1));
|
|
9813
10223
|
}, [ctx.formApi]);
|
|
9814
10224
|
const visibleGroup = useMemo4(() => {
|
|
9815
|
-
var
|
|
10225
|
+
var _a3;
|
|
9816
10226
|
if (!ready) return null;
|
|
9817
10227
|
const sel = ctx.selection;
|
|
9818
10228
|
if (!sel) return null;
|
|
9819
10229
|
const vg = sel.visibleGroup();
|
|
9820
10230
|
if (vg.kind !== "single") return null;
|
|
9821
|
-
return (
|
|
10231
|
+
return (_a3 = vg.group) != null ? _a3 : null;
|
|
9822
10232
|
}, [ready, ctx.selection, selTick]);
|
|
9823
10233
|
const activeTagId = useMemo4(() => {
|
|
9824
|
-
var
|
|
10234
|
+
var _a3, _b2, _c2;
|
|
9825
10235
|
if (!ready) return void 0;
|
|
9826
|
-
return (_c2 = (_b2 = (
|
|
10236
|
+
return (_c2 = (_b2 = (_a3 = ctx.selection) == null ? void 0 : _a3.currentTag) == null ? void 0 : _b2.call(_a3)) != null ? _c2 : ctx.activeTagId;
|
|
9827
10237
|
}, [ready, ctx.selection, ctx.activeTagId, selTick]);
|
|
9828
10238
|
const formValuesByFieldId = useMemo4(() => {
|
|
9829
|
-
var
|
|
9830
|
-
const values = (_c2 = (_b2 = (
|
|
10239
|
+
var _a3, _b2, _c2;
|
|
10240
|
+
const values = (_c2 = (_b2 = (_a3 = ctx.formApi).snapshot) == null ? void 0 : _b2.call(_a3)) != null ? _c2 : {};
|
|
9831
10241
|
return values;
|
|
9832
10242
|
}, [ctx.formApi, formTick]);
|
|
9833
10243
|
const optionSelectionsByFieldId = useMemo4(
|
|
@@ -9835,7 +10245,7 @@ function useOrderFlow() {
|
|
|
9835
10245
|
[]
|
|
9836
10246
|
);
|
|
9837
10247
|
const previewSnapshot = useMemo4(() => {
|
|
9838
|
-
var
|
|
10248
|
+
var _a3, _b2, _c2;
|
|
9839
10249
|
if (!ready) {
|
|
9840
10250
|
return {
|
|
9841
10251
|
version: "1",
|
|
@@ -9850,7 +10260,7 @@ function useOrderFlow() {
|
|
|
9850
10260
|
max: 1,
|
|
9851
10261
|
serviceMap: {},
|
|
9852
10262
|
meta: {
|
|
9853
|
-
schema_version: (
|
|
10263
|
+
schema_version: (_a3 = propsRef.current) == null ? void 0 : _a3.schema_version,
|
|
9854
10264
|
context: {
|
|
9855
10265
|
tag: "unknown",
|
|
9856
10266
|
constraints: {},
|
|
@@ -9892,7 +10302,7 @@ function useOrderFlow() {
|
|
|
9892
10302
|
selTick
|
|
9893
10303
|
]);
|
|
9894
10304
|
const pricingPreview = useMemo4(() => {
|
|
9895
|
-
var
|
|
10305
|
+
var _a3, _b2, _c2, _d, _e, _f;
|
|
9896
10306
|
const empty = {
|
|
9897
10307
|
unitRate: 0,
|
|
9898
10308
|
base: 0,
|
|
@@ -9902,7 +10312,7 @@ function useOrderFlow() {
|
|
|
9902
10312
|
};
|
|
9903
10313
|
if (!ready) return empty;
|
|
9904
10314
|
const { init } = ctx.ensureReady("pricingPreview");
|
|
9905
|
-
const normalizeRate = (
|
|
10315
|
+
const normalizeRate = (_a3 = init.normalizeRate) != null ? _a3 : ((s) => Number(s == null ? void 0 : s.rate));
|
|
9906
10316
|
const quantity = Number((_b2 = previewSnapshot.quantity) != null ? _b2 : 1) || 1;
|
|
9907
10317
|
let bestId;
|
|
9908
10318
|
let bestRate = 0;
|
|
@@ -9960,18 +10370,18 @@ function useOrderFlow() {
|
|
|
9960
10370
|
}, [ready, ctx, previewSnapshot]);
|
|
9961
10371
|
const selectTag = useCallback3(
|
|
9962
10372
|
(tagId) => {
|
|
9963
|
-
var
|
|
10373
|
+
var _a3, _b2;
|
|
9964
10374
|
ctx.ensureReady("selectTag");
|
|
9965
|
-
(_b2 = (
|
|
10375
|
+
(_b2 = (_a3 = ctx.selection) == null ? void 0 : _a3.replace) == null ? void 0 : _b2.call(_a3, tagId);
|
|
9966
10376
|
ctx.setActiveTag(tagId);
|
|
9967
10377
|
},
|
|
9968
10378
|
[ctx]
|
|
9969
10379
|
);
|
|
9970
10380
|
const toggleOption = useCallback3(
|
|
9971
10381
|
(fieldId, optionId) => {
|
|
9972
|
-
var
|
|
10382
|
+
var _a3, _b2;
|
|
9973
10383
|
const token = optionId != null ? optionId : fieldId;
|
|
9974
|
-
(_b2 = (
|
|
10384
|
+
(_b2 = (_a3 = ctx.selection) == null ? void 0 : _a3.toggle) == null ? void 0 : _b2.call(_a3, token);
|
|
9975
10385
|
},
|
|
9976
10386
|
[ctx]
|
|
9977
10387
|
);
|
|
@@ -9983,9 +10393,9 @@ function useOrderFlow() {
|
|
|
9983
10393
|
);
|
|
9984
10394
|
const clearField = useCallback3(
|
|
9985
10395
|
(fieldId) => {
|
|
9986
|
-
var
|
|
10396
|
+
var _a3, _b2;
|
|
9987
10397
|
ctx.formApi.set(fieldId, void 0);
|
|
9988
|
-
(_b2 = (
|
|
10398
|
+
(_b2 = (_a3 = ctx.selection) == null ? void 0 : _a3.remove) == null ? void 0 : _b2.call(_a3, fieldId);
|
|
9989
10399
|
},
|
|
9990
10400
|
[ctx]
|
|
9991
10401
|
);
|
|
@@ -10004,14 +10414,14 @@ function useOrderFlow() {
|
|
|
10004
10414
|
[ctx]
|
|
10005
10415
|
);
|
|
10006
10416
|
const buildSnapshot = useCallback3(() => {
|
|
10007
|
-
var
|
|
10417
|
+
var _a3, _b2, _c2, _d, _e, _f;
|
|
10008
10418
|
const { builder, selection, init } = ctx.ensureReady("buildSnapshot");
|
|
10009
10419
|
const tagId = selection.currentTag();
|
|
10010
10420
|
const selectedKeys = selection.selectedButtons();
|
|
10011
10421
|
if (!tagId) {
|
|
10012
10422
|
throw new Error("OrderFlow: no active tag/context selected");
|
|
10013
10423
|
}
|
|
10014
|
-
const mode = (
|
|
10424
|
+
const mode = (_a3 = init.mode) != null ? _a3 : "prod";
|
|
10015
10425
|
const hostDefaultQuantity = Number((_b2 = init.hostDefaultQuantity) != null ? _b2 : 1) || 1;
|
|
10016
10426
|
const submitted = ctx.formApi.submit();
|
|
10017
10427
|
const values = submitted.values;
|
|
@@ -10052,13 +10462,13 @@ function useOrderFlow() {
|
|
|
10052
10462
|
);
|
|
10053
10463
|
}, [ctx, optionSelectionsByFieldId]);
|
|
10054
10464
|
const raw = useMemo4(() => {
|
|
10055
|
-
var
|
|
10056
|
-
if (!ready) return (
|
|
10465
|
+
var _a3;
|
|
10466
|
+
if (!ready) return (_a3 = propsRef.current) != null ? _a3 : {};
|
|
10057
10467
|
return ctx.ensureReady("raw").builder.getProps();
|
|
10058
10468
|
}, [ctx, ready, selTick]);
|
|
10059
10469
|
const notices = useMemo4(() => {
|
|
10060
|
-
var
|
|
10061
|
-
return (
|
|
10470
|
+
var _a3;
|
|
10471
|
+
return (_a3 = raw.notices) != null ? _a3 : [];
|
|
10062
10472
|
}, [raw]);
|
|
10063
10473
|
return {
|
|
10064
10474
|
ready,
|
|
@@ -10073,7 +10483,7 @@ function useOrderFlow() {
|
|
|
10073
10483
|
services: previewSnapshot.services,
|
|
10074
10484
|
serviceMap: previewSnapshot.serviceMap,
|
|
10075
10485
|
pricingPreview,
|
|
10076
|
-
min: (
|
|
10486
|
+
min: (_a2 = previewSnapshot.min) != null ? _a2 : 1,
|
|
10077
10487
|
max: (_c = (_b = previewSnapshot.max) != null ? _b : previewSnapshot.min) != null ? _c : 1,
|
|
10078
10488
|
selectTag,
|
|
10079
10489
|
toggleOption,
|
|
@@ -10093,8 +10503,8 @@ function toKind(field) {
|
|
|
10093
10503
|
return field.type;
|
|
10094
10504
|
}
|
|
10095
10505
|
function toVariant(field) {
|
|
10096
|
-
var
|
|
10097
|
-
const v = (
|
|
10506
|
+
var _a2;
|
|
10507
|
+
const v = (_a2 = field.meta) == null ? void 0 : _a2.variant;
|
|
10098
10508
|
return typeof v === "string" && v.trim() ? v : void 0;
|
|
10099
10509
|
}
|
|
10100
10510
|
function getPath(ctx, path) {
|
|
@@ -10167,7 +10577,7 @@ function Wrapper({
|
|
|
10167
10577
|
ctxOverrides,
|
|
10168
10578
|
className = ""
|
|
10169
10579
|
}) {
|
|
10170
|
-
var
|
|
10580
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
10171
10581
|
const { registry } = useInputs();
|
|
10172
10582
|
const flow = useOrderFlow();
|
|
10173
10583
|
const kind = toKind(field);
|
|
@@ -10181,11 +10591,11 @@ function Wrapper({
|
|
|
10181
10591
|
return null;
|
|
10182
10592
|
}
|
|
10183
10593
|
const Component = descriptor.Component;
|
|
10184
|
-
const adapter = (
|
|
10594
|
+
const adapter = (_a2 = descriptor.adapter) != null ? _a2 : {};
|
|
10185
10595
|
const baseProps = (_b = descriptor.defaultProps) != null ? _b : {};
|
|
10186
10596
|
const defaultProps = useMemo6(() => {
|
|
10187
|
-
var
|
|
10188
|
-
return { ...baseProps, ...(
|
|
10597
|
+
var _a3;
|
|
10598
|
+
return { ...baseProps, ...(_a3 = field.defaults) != null ? _a3 : {} };
|
|
10189
10599
|
}, [baseProps, field.defaults]);
|
|
10190
10600
|
const valueProp = (_c = adapter.valueProp) != null ? _c : "value";
|
|
10191
10601
|
const changeProp = (_d = adapter.changeProp) != null ? _d : "onChange";
|
|
@@ -10200,9 +10610,9 @@ function Wrapper({
|
|
|
10200
10610
|
disabled: !!disabled
|
|
10201
10611
|
});
|
|
10202
10612
|
const optionIds = React4.useMemo(() => {
|
|
10203
|
-
var
|
|
10613
|
+
var _a3;
|
|
10204
10614
|
if (!isOptionBased2) return /* @__PURE__ */ new Set();
|
|
10205
|
-
return new Set(((
|
|
10615
|
+
return new Set(((_a3 = field.options) != null ? _a3 : []).map((o) => o.id));
|
|
10206
10616
|
}, [isOptionBased2, field.options]);
|
|
10207
10617
|
const prevSelectedRef = React4.useRef([]);
|
|
10208
10618
|
React4.useEffect(() => {
|
|
@@ -10214,9 +10624,9 @@ function Wrapper({
|
|
|
10214
10624
|
);
|
|
10215
10625
|
const onHostChange = React4.useCallback(
|
|
10216
10626
|
(next) => {
|
|
10217
|
-
var
|
|
10627
|
+
var _a3, _b2, _c2, _d2, _e2;
|
|
10218
10628
|
const currentStored = next == null ? void 0 : next.value;
|
|
10219
|
-
const stored = (_c2 = (_b2 = (
|
|
10629
|
+
const stored = (_c2 = (_b2 = (_a3 = adapter.getValue) == null ? void 0 : _a3.call(adapter, next, currentStored, adapterCtx)) != null ? _b2 : currentStored) != null ? _c2 : next;
|
|
10220
10630
|
fp.setValue(stored);
|
|
10221
10631
|
if (isOptionBased2) {
|
|
10222
10632
|
if (!adapter.getSelectedOptions) {
|
|
@@ -10265,8 +10675,8 @@ function Wrapper({
|
|
|
10265
10675
|
]
|
|
10266
10676
|
);
|
|
10267
10677
|
const templateCtx = React4.useMemo(() => {
|
|
10268
|
-
var
|
|
10269
|
-
const ctxFromInit = (_b2 = (
|
|
10678
|
+
var _a3, _b2;
|
|
10679
|
+
const ctxFromInit = (_b2 = (_a3 = flow.init) == null ? void 0 : _a3.ctx) != null ? _b2 : {};
|
|
10270
10680
|
const ctx = ctxOverrides && typeof ctxOverrides === "object" ? { ...ctxFromInit, ...ctxOverrides } : ctxFromInit;
|
|
10271
10681
|
return {
|
|
10272
10682
|
...ctx,
|
|
@@ -10768,6 +11178,12 @@ var phoneDescriptor = {
|
|
|
10768
11178
|
import { InputField as InputField4 } from "@timeax/form-palette";
|
|
10769
11179
|
var toggleGroupDescriptor = {
|
|
10770
11180
|
Component: InputField4,
|
|
11181
|
+
options: {
|
|
11182
|
+
supported: true,
|
|
11183
|
+
autoCreate: true,
|
|
11184
|
+
defaultLabel: "Option label",
|
|
11185
|
+
defaultValue: "option"
|
|
11186
|
+
},
|
|
10771
11187
|
defaultProps: {
|
|
10772
11188
|
variant: "toggle-group",
|
|
10773
11189
|
// MUST
|
|
@@ -11285,6 +11701,12 @@ var toggleDescriptor = {
|
|
|
11285
11701
|
import { InputField as InputField9 } from "@timeax/form-palette";
|
|
11286
11702
|
var treeSelectDescriptor = {
|
|
11287
11703
|
Component: InputField9,
|
|
11704
|
+
options: {
|
|
11705
|
+
supported: true,
|
|
11706
|
+
autoCreate: true,
|
|
11707
|
+
defaultLabel: "Option label",
|
|
11708
|
+
defaultValue: "option"
|
|
11709
|
+
},
|
|
11288
11710
|
defaultProps: {
|
|
11289
11711
|
variant: "treeselect",
|
|
11290
11712
|
// MUST
|
|
@@ -11365,6 +11787,12 @@ var treeSelectDescriptor = {
|
|
|
11365
11787
|
import { InputField as InputField10 } from "@timeax/form-palette";
|
|
11366
11788
|
var multiSelectDescriptor = {
|
|
11367
11789
|
Component: InputField10,
|
|
11790
|
+
options: {
|
|
11791
|
+
supported: true,
|
|
11792
|
+
autoCreate: true,
|
|
11793
|
+
defaultLabel: "Option label",
|
|
11794
|
+
defaultValue: "option"
|
|
11795
|
+
},
|
|
11368
11796
|
defaultProps: {
|
|
11369
11797
|
variant: "multi-select",
|
|
11370
11798
|
// MUST
|
|
@@ -11411,6 +11839,12 @@ var multiSelectDescriptor = {
|
|
|
11411
11839
|
import { InputField as InputField11 } from "@timeax/form-palette";
|
|
11412
11840
|
var selectDescriptor = {
|
|
11413
11841
|
Component: InputField11,
|
|
11842
|
+
options: {
|
|
11843
|
+
supported: true,
|
|
11844
|
+
autoCreate: true,
|
|
11845
|
+
defaultLabel: "Option label",
|
|
11846
|
+
defaultValue: "option"
|
|
11847
|
+
},
|
|
11414
11848
|
defaultProps: {
|
|
11415
11849
|
variant: "select",
|
|
11416
11850
|
// MUST
|
|
@@ -11445,6 +11879,12 @@ var selectDescriptor = {
|
|
|
11445
11879
|
import { InputField as InputField12 } from "@timeax/form-palette";
|
|
11446
11880
|
var radioDescriptor = {
|
|
11447
11881
|
Component: InputField12,
|
|
11882
|
+
options: {
|
|
11883
|
+
supported: true,
|
|
11884
|
+
autoCreate: true,
|
|
11885
|
+
defaultLabel: "Option label",
|
|
11886
|
+
defaultValue: "option"
|
|
11887
|
+
},
|
|
11448
11888
|
defaultProps: {
|
|
11449
11889
|
variant: "radio",
|
|
11450
11890
|
// MUST
|
|
@@ -11471,12 +11911,111 @@ var radioDescriptor = {
|
|
|
11471
11911
|
|
|
11472
11912
|
// src/react/inputs/entries/checkbox.tsx
|
|
11473
11913
|
import { InputField as InputField13 } from "@timeax/form-palette";
|
|
11914
|
+
var checkboxBaseUi = {
|
|
11915
|
+
size: sharedUi.size,
|
|
11916
|
+
density: {
|
|
11917
|
+
type: "anyOf",
|
|
11918
|
+
label: "Density",
|
|
11919
|
+
description: "Vertical density of each option row.",
|
|
11920
|
+
items: [
|
|
11921
|
+
{ type: "string", title: "Compact", value: "compact" },
|
|
11922
|
+
{ type: "string", title: "Comfortable", value: "comfortable" },
|
|
11923
|
+
{ type: "string", title: "Loose", value: "loose" }
|
|
11924
|
+
]
|
|
11925
|
+
},
|
|
11926
|
+
single: {
|
|
11927
|
+
type: "boolean",
|
|
11928
|
+
label: "Single",
|
|
11929
|
+
description: "If enabled, behaves like a single checkbox (boolean). Otherwise renders a group (array)."
|
|
11930
|
+
},
|
|
11931
|
+
tristate: {
|
|
11932
|
+
type: "boolean",
|
|
11933
|
+
label: "Tri-state",
|
|
11934
|
+
description: 'Enable tri-state behaviour (supports an internal "none" state).'
|
|
11935
|
+
},
|
|
11936
|
+
layout: {
|
|
11937
|
+
type: "anyOf",
|
|
11938
|
+
label: "Layout",
|
|
11939
|
+
description: "Arrange options as a vertical list or grid.",
|
|
11940
|
+
items: [
|
|
11941
|
+
{ type: "string", title: "List", value: "list" },
|
|
11942
|
+
{ type: "string", title: "Grid", value: "grid" }
|
|
11943
|
+
]
|
|
11944
|
+
},
|
|
11945
|
+
columns: {
|
|
11946
|
+
type: "number",
|
|
11947
|
+
label: "Columns",
|
|
11948
|
+
description: "Number of columns when layout is grid.",
|
|
11949
|
+
minimum: 1
|
|
11950
|
+
},
|
|
11951
|
+
itemGapPx: {
|
|
11952
|
+
type: "number",
|
|
11953
|
+
label: "Item gap (px)",
|
|
11954
|
+
description: "Gap between option rows/items in pixels.",
|
|
11955
|
+
minimum: 0
|
|
11956
|
+
},
|
|
11957
|
+
autoCap: {
|
|
11958
|
+
type: "boolean",
|
|
11959
|
+
label: "Auto capitalise",
|
|
11960
|
+
description: "Capitalise the first letter of labels (only when label resolves to a string)."
|
|
11961
|
+
},
|
|
11962
|
+
options: {
|
|
11963
|
+
type: "array",
|
|
11964
|
+
label: "Options",
|
|
11965
|
+
description: "Checkbox options. Can be primitives (string/number/boolean) or objects (label/value/description/disabled/tristate).",
|
|
11966
|
+
editable: true,
|
|
11967
|
+
item: {
|
|
11968
|
+
type: "object",
|
|
11969
|
+
label: "Option",
|
|
11970
|
+
description: "An option item for group mode.",
|
|
11971
|
+
editable: true,
|
|
11972
|
+
fields: {
|
|
11973
|
+
value: {
|
|
11974
|
+
type: "string",
|
|
11975
|
+
label: "Value",
|
|
11976
|
+
description: "Unique option value (string)."
|
|
11977
|
+
},
|
|
11978
|
+
label: {
|
|
11979
|
+
type: "string",
|
|
11980
|
+
label: "Label",
|
|
11981
|
+
description: "Display label for the option."
|
|
11982
|
+
},
|
|
11983
|
+
description: {
|
|
11984
|
+
type: "string",
|
|
11985
|
+
label: "Description",
|
|
11986
|
+
description: "Optional helper text under the label."
|
|
11987
|
+
},
|
|
11988
|
+
disabled: {
|
|
11989
|
+
type: "boolean",
|
|
11990
|
+
label: "Disabled",
|
|
11991
|
+
description: "Disable this option."
|
|
11992
|
+
},
|
|
11993
|
+
tristate: {
|
|
11994
|
+
type: "boolean",
|
|
11995
|
+
label: "Tri-state override",
|
|
11996
|
+
description: "Override tri-state behaviour for this option (if unset, uses variant tristate)."
|
|
11997
|
+
}
|
|
11998
|
+
},
|
|
11999
|
+
order: ["value", "label", "description", "disabled", "tristate"]
|
|
12000
|
+
}
|
|
12001
|
+
},
|
|
12002
|
+
optionValue: {
|
|
12003
|
+
type: "string",
|
|
12004
|
+
label: "Option value key",
|
|
12005
|
+
description: "Property name to read the option value from when using custom option objects."
|
|
12006
|
+
},
|
|
12007
|
+
optionLabel: {
|
|
12008
|
+
type: "string",
|
|
12009
|
+
label: "Option label key",
|
|
12010
|
+
description: "Property name to read the option label from when using custom option objects."
|
|
12011
|
+
}
|
|
12012
|
+
};
|
|
11474
12013
|
var checkboxDescriptor = {
|
|
11475
12014
|
Component: InputField13,
|
|
11476
12015
|
defaultProps: {
|
|
11477
12016
|
variant: "checkbox",
|
|
11478
12017
|
// MUST
|
|
11479
|
-
single:
|
|
12018
|
+
single: true,
|
|
11480
12019
|
tristate: false,
|
|
11481
12020
|
layout: "list",
|
|
11482
12021
|
columns: 2,
|
|
@@ -11486,120 +12025,23 @@ var checkboxDescriptor = {
|
|
|
11486
12025
|
autoCap: false
|
|
11487
12026
|
},
|
|
11488
12027
|
adapter: {},
|
|
11489
|
-
|
|
11490
|
-
|
|
11491
|
-
|
|
11492
|
-
|
|
11493
|
-
|
|
11494
|
-
|
|
11495
|
-
|
|
11496
|
-
|
|
11497
|
-
|
|
11498
|
-
|
|
11499
|
-
|
|
11500
|
-
|
|
11501
|
-
|
|
11502
|
-
|
|
11503
|
-
|
|
11504
|
-
|
|
11505
|
-
|
|
11506
|
-
},
|
|
11507
|
-
tristate: {
|
|
11508
|
-
type: "boolean",
|
|
11509
|
-
label: "Tri-state",
|
|
11510
|
-
description: 'Enable tri-state behaviour (supports an internal "none" state).'
|
|
11511
|
-
},
|
|
11512
|
-
// layout
|
|
11513
|
-
layout: {
|
|
11514
|
-
type: "anyOf",
|
|
11515
|
-
label: "Layout",
|
|
11516
|
-
description: "Arrange options as a vertical list or grid.",
|
|
11517
|
-
items: [
|
|
11518
|
-
{ type: "string", title: "List", value: "list" },
|
|
11519
|
-
{ type: "string", title: "Grid", value: "grid" }
|
|
11520
|
-
]
|
|
11521
|
-
},
|
|
11522
|
-
columns: {
|
|
11523
|
-
type: "number",
|
|
11524
|
-
label: "Columns",
|
|
11525
|
-
description: "Number of columns when layout is grid.",
|
|
11526
|
-
minimum: 1
|
|
11527
|
-
},
|
|
11528
|
-
itemGapPx: {
|
|
11529
|
-
type: "number",
|
|
11530
|
-
label: "Item gap (px)",
|
|
11531
|
-
description: "Gap between option rows/items in pixels.",
|
|
11532
|
-
minimum: 0
|
|
11533
|
-
},
|
|
11534
|
-
autoCap: {
|
|
11535
|
-
type: "boolean",
|
|
11536
|
-
label: "Auto capitalise",
|
|
11537
|
-
description: "Capitalise the first letter of labels (only when label resolves to a string)."
|
|
11538
|
-
},
|
|
11539
|
-
// options (primitive arrays or object arrays)
|
|
11540
|
-
options: {
|
|
11541
|
-
type: "array",
|
|
11542
|
-
label: "Options",
|
|
11543
|
-
description: "Checkbox options. Can be primitives (string/number/boolean) or objects (label/value/description/disabled/tristate).",
|
|
11544
|
-
editable: true,
|
|
11545
|
-
item: {
|
|
11546
|
-
type: "object",
|
|
11547
|
-
label: "Option",
|
|
11548
|
-
description: "An option item for group mode.",
|
|
11549
|
-
editable: true,
|
|
11550
|
-
fields: {
|
|
11551
|
-
value: {
|
|
11552
|
-
type: "string",
|
|
11553
|
-
label: "Value",
|
|
11554
|
-
description: "Unique option value (string)."
|
|
11555
|
-
},
|
|
11556
|
-
label: {
|
|
11557
|
-
type: "string",
|
|
11558
|
-
label: "Label",
|
|
11559
|
-
description: "Display label for the option."
|
|
11560
|
-
},
|
|
11561
|
-
description: {
|
|
11562
|
-
type: "string",
|
|
11563
|
-
label: "Description",
|
|
11564
|
-
description: "Optional helper text under the label."
|
|
11565
|
-
},
|
|
11566
|
-
disabled: {
|
|
11567
|
-
type: "boolean",
|
|
11568
|
-
label: "Disabled",
|
|
11569
|
-
description: "Disable this option."
|
|
11570
|
-
},
|
|
11571
|
-
tristate: {
|
|
11572
|
-
type: "boolean",
|
|
11573
|
-
label: "Tri-state override",
|
|
11574
|
-
description: "Override tri-state behaviour for this option (if unset, uses variant tristate)."
|
|
11575
|
-
}
|
|
11576
|
-
},
|
|
11577
|
-
order: [
|
|
11578
|
-
"value",
|
|
11579
|
-
"label",
|
|
11580
|
-
"description",
|
|
11581
|
-
"disabled",
|
|
11582
|
-
"tristate"
|
|
11583
|
-
]
|
|
11584
|
-
}
|
|
11585
|
-
},
|
|
11586
|
-
// mapping keys (for custom item shapes)
|
|
11587
|
-
optionValue: {
|
|
11588
|
-
type: "string",
|
|
11589
|
-
label: "Option value key",
|
|
11590
|
-
description: "Property name to read the option value from when using custom option objects."
|
|
11591
|
-
},
|
|
11592
|
-
optionLabel: {
|
|
11593
|
-
type: "string",
|
|
11594
|
-
label: "Option label key",
|
|
11595
|
-
description: "Property name to read the option label from when using custom option objects."
|
|
11596
|
-
}
|
|
11597
|
-
// intentionally excluded:
|
|
11598
|
-
// - items (alias to options; keeping one is enough for builder)
|
|
11599
|
-
// - mappers (functions)
|
|
11600
|
-
// - renderOption (function)
|
|
11601
|
-
// - singleLabel/singleDescription (ReactNode)
|
|
11602
|
-
// - all *ClassName props (not allowed)
|
|
12028
|
+
options: {
|
|
12029
|
+
supported: false
|
|
12030
|
+
},
|
|
12031
|
+
ui: checkboxBaseUi
|
|
12032
|
+
};
|
|
12033
|
+
var _a;
|
|
12034
|
+
var checkboxOptionsDescriptor = {
|
|
12035
|
+
...checkboxDescriptor,
|
|
12036
|
+
defaultProps: {
|
|
12037
|
+
...(_a = checkboxDescriptor.defaultProps) != null ? _a : {},
|
|
12038
|
+
single: false
|
|
12039
|
+
},
|
|
12040
|
+
options: {
|
|
12041
|
+
supported: true,
|
|
12042
|
+
autoCreate: true,
|
|
12043
|
+
defaultLabel: "Option label",
|
|
12044
|
+
defaultValue: "option"
|
|
11603
12045
|
}
|
|
11604
12046
|
};
|
|
11605
12047
|
|
|
@@ -11607,6 +12049,9 @@ var checkboxDescriptor = {
|
|
|
11607
12049
|
import { InputField as InputField14 } from "@timeax/form-palette";
|
|
11608
12050
|
var chipsDescriptor = {
|
|
11609
12051
|
Component: InputField14,
|
|
12052
|
+
options: {
|
|
12053
|
+
supported: false
|
|
12054
|
+
},
|
|
11610
12055
|
defaultProps: {
|
|
11611
12056
|
variant: "chips",
|
|
11612
12057
|
// MUST
|
|
@@ -12398,7 +12843,7 @@ var inputFieldUi = {
|
|
|
12398
12843
|
}
|
|
12399
12844
|
};
|
|
12400
12845
|
function withInputFieldUi(desc) {
|
|
12401
|
-
var
|
|
12846
|
+
var _a2;
|
|
12402
12847
|
return {
|
|
12403
12848
|
...desc,
|
|
12404
12849
|
adapter: {
|
|
@@ -12408,7 +12853,7 @@ function withInputFieldUi(desc) {
|
|
|
12408
12853
|
valueProp: "value",
|
|
12409
12854
|
changeProp: "onChange",
|
|
12410
12855
|
getInputPropsFromField({ field, props }) {
|
|
12411
|
-
var
|
|
12856
|
+
var _a3, _b;
|
|
12412
12857
|
const severityPillClassMap = {
|
|
12413
12858
|
info: "border-blue-200 bg-blue-50 text-blue-700 ring-1 ring-inset ring-blue-200",
|
|
12414
12859
|
warning: "border-amber-200 bg-amber-50 text-amber-800 ring-1 ring-inset ring-amber-200",
|
|
@@ -12416,11 +12861,11 @@ function withInputFieldUi(desc) {
|
|
|
12416
12861
|
};
|
|
12417
12862
|
const pillBaseClassName = "inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-medium";
|
|
12418
12863
|
const toTagPill = (tag) => {
|
|
12419
|
-
var
|
|
12864
|
+
var _a4;
|
|
12420
12865
|
return {
|
|
12421
12866
|
label: tag.title,
|
|
12422
12867
|
bgColor: tag.color,
|
|
12423
|
-
className: `${pillBaseClassName} ${(
|
|
12868
|
+
className: `${pillBaseClassName} ${(_a4 = severityPillClassMap[tag.severity]) != null ? _a4 : severityPillClassMap.info}`
|
|
12424
12869
|
};
|
|
12425
12870
|
};
|
|
12426
12871
|
const matchesNotice = (target, notice) => {
|
|
@@ -12429,7 +12874,7 @@ function withInputFieldUi(desc) {
|
|
|
12429
12874
|
const isServiceMatch = !!target.service_id && String(target.service_id) === notice.id;
|
|
12430
12875
|
return isNodeTargetMatch || isLegacyGlobalIdMatch || isServiceMatch;
|
|
12431
12876
|
};
|
|
12432
|
-
const notices = (
|
|
12877
|
+
const notices = (_a3 = props.notices) != null ? _a3 : [];
|
|
12433
12878
|
const fieldNotices = notices.filter(
|
|
12434
12879
|
(notice) => matchesNotice(field, notice)
|
|
12435
12880
|
);
|
|
@@ -12451,8 +12896,8 @@ function withInputFieldUi(desc) {
|
|
|
12451
12896
|
};
|
|
12452
12897
|
},
|
|
12453
12898
|
getSelectedOptions(next, currentt, ctx) {
|
|
12454
|
-
var
|
|
12455
|
-
return (_c = (_b = (
|
|
12899
|
+
var _a3, _b, _c;
|
|
12900
|
+
return (_c = (_b = (_a3 = next == null ? void 0 : next.detail) == null ? void 0 : _a3.selectedOptions) != null ? _b : []) == null ? void 0 : _c.map(
|
|
12456
12901
|
(item) => item.id
|
|
12457
12902
|
);
|
|
12458
12903
|
},
|
|
@@ -12462,13 +12907,13 @@ function withInputFieldUi(desc) {
|
|
|
12462
12907
|
},
|
|
12463
12908
|
ui: {
|
|
12464
12909
|
...inputFieldUi,
|
|
12465
|
-
...(
|
|
12910
|
+
...(_a2 = desc.ui) != null ? _a2 : {}
|
|
12466
12911
|
}
|
|
12467
12912
|
};
|
|
12468
12913
|
}
|
|
12469
12914
|
function variantOf(desc) {
|
|
12470
|
-
var
|
|
12471
|
-
const v = (
|
|
12915
|
+
var _a2;
|
|
12916
|
+
const v = (_a2 = desc.defaultProps) == null ? void 0 : _a2.variant;
|
|
12472
12917
|
if (!v || typeof v !== "string") {
|
|
12473
12918
|
throw new Error(
|
|
12474
12919
|
`[inputs] Descriptor is missing defaultProps.variant: ${String(v)}`
|
|
@@ -12499,16 +12944,23 @@ function registerEntries(registry) {
|
|
|
12499
12944
|
listerDescriptor,
|
|
12500
12945
|
fileDescriptor
|
|
12501
12946
|
];
|
|
12502
|
-
|
|
12503
|
-
|
|
12504
|
-
|
|
12505
|
-
|
|
12506
|
-
|
|
12507
|
-
|
|
12508
|
-
|
|
12509
|
-
|
|
12510
|
-
|
|
12511
|
-
|
|
12947
|
+
const baseEntries = entries.map((descriptor) => {
|
|
12948
|
+
const finalDescriptor = withInputFieldUi(descriptor);
|
|
12949
|
+
const variant = variantOf(finalDescriptor);
|
|
12950
|
+
return {
|
|
12951
|
+
kind: variant,
|
|
12952
|
+
descriptor: finalDescriptor
|
|
12953
|
+
};
|
|
12954
|
+
});
|
|
12955
|
+
const checkboxOptions = withInputFieldUi(checkboxOptionsDescriptor);
|
|
12956
|
+
registry.registerMany([
|
|
12957
|
+
...baseEntries,
|
|
12958
|
+
{
|
|
12959
|
+
kind: "checkbox",
|
|
12960
|
+
descriptor: checkboxOptions,
|
|
12961
|
+
variant: "options"
|
|
12962
|
+
}
|
|
12963
|
+
]);
|
|
12512
12964
|
}
|
|
12513
12965
|
|
|
12514
12966
|
// src/react/fallback-editor/useFallbackEditor.ts
|
|
@@ -12552,16 +13004,16 @@ function FallbackEditorProvider({
|
|
|
12552
13004
|
);
|
|
12553
13005
|
const resolvedEligibleServices = React5.useMemo(
|
|
12554
13006
|
() => {
|
|
12555
|
-
var
|
|
12556
|
-
return (
|
|
13007
|
+
var _a2;
|
|
13008
|
+
return (_a2 = eligibleServices != null ? eligibleServices : primaryServices) != null ? _a2 : {};
|
|
12557
13009
|
},
|
|
12558
13010
|
[eligibleServices, primaryServices]
|
|
12559
13011
|
);
|
|
12560
13012
|
const editorRef = React5.useRef(null);
|
|
12561
13013
|
const buildEditor = React5.useCallback(
|
|
12562
13014
|
(next) => {
|
|
12563
|
-
var
|
|
12564
|
-
const currentValue = (
|
|
13015
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
13016
|
+
const currentValue = (_a2 = editorRef.current) == null ? void 0 : _a2.value();
|
|
12565
13017
|
editorRef.current = createFallbackEditor({
|
|
12566
13018
|
fallbacks: (_d = (_c = (_b = next == null ? void 0 : next.fallbacks) != null ? _b : currentValue) != null ? _c : fallbacks) != null ? _d : {},
|
|
12567
13019
|
props: (_e = next == null ? void 0 : next.props) != null ? _e : props,
|
|
@@ -12952,7 +13404,7 @@ function VirtualServiceList({
|
|
|
12952
13404
|
style: { height },
|
|
12953
13405
|
onScroll: (e) => setScrollTop(e.currentTarget.scrollTop),
|
|
12954
13406
|
children: /* @__PURE__ */ jsx7("div", { className: "relative", style: { height: total * rowHeight }, children: visible.map((item, i) => {
|
|
12955
|
-
var
|
|
13407
|
+
var _a2, _b;
|
|
12956
13408
|
const index = start + i;
|
|
12957
13409
|
const key = String(item.id);
|
|
12958
13410
|
const checked = selected.has(key);
|
|
@@ -12973,7 +13425,7 @@ function VirtualServiceList({
|
|
|
12973
13425
|
String(item.id),
|
|
12974
13426
|
" \xB7",
|
|
12975
13427
|
" ",
|
|
12976
|
-
(
|
|
13428
|
+
(_a2 = item.name) != null ? _a2 : "Unnamed"
|
|
12977
13429
|
] }),
|
|
12978
13430
|
/* @__PURE__ */ jsxs3("div", { className: "mt-0.5 text-xs text-zinc-500 dark:text-zinc-400", children: [
|
|
12979
13431
|
(_b = item.platform) != null ? _b : "Unknown",
|
|
@@ -13003,7 +13455,7 @@ function VirtualServiceList({
|
|
|
13003
13455
|
import React8 from "react";
|
|
13004
13456
|
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
13005
13457
|
function FallbackDetailsPanel() {
|
|
13006
|
-
var
|
|
13458
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
13007
13459
|
const { activeServiceId, state, settings } = useFallbackEditor();
|
|
13008
13460
|
const services = usePrimaryServiceList();
|
|
13009
13461
|
const service = React8.useMemo(
|
|
@@ -13019,7 +13471,7 @@ function FallbackDetailsPanel() {
|
|
|
13019
13471
|
Detail,
|
|
13020
13472
|
{
|
|
13021
13473
|
label: "Name",
|
|
13022
|
-
value: (
|
|
13474
|
+
value: (_a2 = service.name) != null ? _a2 : "Unnamed"
|
|
13023
13475
|
}
|
|
13024
13476
|
),
|
|
13025
13477
|
/* @__PURE__ */ jsx8(
|
|
@@ -13140,7 +13592,7 @@ import React9 from "react";
|
|
|
13140
13592
|
import { InputField as InputField21 } from "@timeax/form-palette";
|
|
13141
13593
|
import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
13142
13594
|
function FallbackSettingsPanel() {
|
|
13143
|
-
var
|
|
13595
|
+
var _a2, _b, _c;
|
|
13144
13596
|
const { settings, saveSettings, settingsSaving } = useFallbackEditorContext();
|
|
13145
13597
|
const [draft, setDraft] = React9.useState(settings);
|
|
13146
13598
|
const [error, setError] = React9.useState(null);
|
|
@@ -13169,7 +13621,7 @@ function FallbackSettingsPanel() {
|
|
|
13169
13621
|
ratePolicy: next
|
|
13170
13622
|
}));
|
|
13171
13623
|
}
|
|
13172
|
-
const ratePolicy = (
|
|
13624
|
+
const ratePolicy = (_a2 = draft.ratePolicy) != null ? _a2 : {
|
|
13173
13625
|
kind: "lte_primary",
|
|
13174
13626
|
pct: 5
|
|
13175
13627
|
};
|
|
@@ -13368,8 +13820,8 @@ function FallbackServiceSidebar() {
|
|
|
13368
13820
|
if (!q) return services;
|
|
13369
13821
|
return services.filter(
|
|
13370
13822
|
(service) => {
|
|
13371
|
-
var
|
|
13372
|
-
return String(service.id).includes(q) || String((
|
|
13823
|
+
var _a2, _b;
|
|
13824
|
+
return String(service.id).includes(q) || String((_a2 = service.name) != null ? _a2 : "").toLowerCase().includes(q) || String((_b = service.platform) != null ? _b : "").toLowerCase().includes(q);
|
|
13373
13825
|
}
|
|
13374
13826
|
);
|
|
13375
13827
|
}, [query, services]);
|
|
@@ -13393,7 +13845,7 @@ function FallbackServiceSidebar() {
|
|
|
13393
13845
|
}
|
|
13394
13846
|
) }),
|
|
13395
13847
|
/* @__PURE__ */ jsx11("div", { className: "mt-3 flex-1 space-y-2 overflow-y-auto", children: filtered.map((service) => {
|
|
13396
|
-
var
|
|
13848
|
+
var _a2, _b;
|
|
13397
13849
|
const active = String(service.id) === String(activeServiceId);
|
|
13398
13850
|
const count = get(service.id).length;
|
|
13399
13851
|
return /* @__PURE__ */ jsx11(
|
|
@@ -13412,7 +13864,7 @@ function FallbackServiceSidebar() {
|
|
|
13412
13864
|
String(service.id),
|
|
13413
13865
|
" \xB7",
|
|
13414
13866
|
" ",
|
|
13415
|
-
(
|
|
13867
|
+
(_a2 = service.name) != null ? _a2 : "Unnamed"
|
|
13416
13868
|
] }),
|
|
13417
13869
|
/* @__PURE__ */ jsxs7("div", { className: "mt-1 text-xs text-zinc-500 dark:text-zinc-400", children: [
|
|
13418
13870
|
(_b = service.platform) != null ? _b : "Unknown",
|
|
@@ -13487,7 +13939,7 @@ function FallbackRegistrationsPanel() {
|
|
|
13487
13939
|
)
|
|
13488
13940
|
] }),
|
|
13489
13941
|
/* @__PURE__ */ jsx12("div", { className: "space-y-4", children: registrations.length === 0 ? /* @__PURE__ */ jsx12("div", { className: "rounded-2xl border border-dashed border-zinc-300 p-6 text-sm text-zinc-500 dark:border-zinc-700 dark:text-zinc-400", children: "No registrations yet for this primary service." }) : registrations.map((reg, index) => {
|
|
13490
|
-
var
|
|
13942
|
+
var _a2;
|
|
13491
13943
|
const context = makeContext(reg);
|
|
13492
13944
|
const candidates = reg.services;
|
|
13493
13945
|
return /* @__PURE__ */ jsxs8(
|
|
@@ -13509,7 +13961,7 @@ function FallbackRegistrationsPanel() {
|
|
|
13509
13961
|
] })
|
|
13510
13962
|
] }),
|
|
13511
13963
|
/* @__PURE__ */ jsx12("div", { className: "mt-4 flex flex-wrap gap-2", children: candidates.length === 0 ? /* @__PURE__ */ jsx12("span", { className: "text-xs text-zinc-500 dark:text-zinc-400", children: "No fallback services yet." }) : candidates.map((candidate) => {
|
|
13512
|
-
var
|
|
13964
|
+
var _a3;
|
|
13513
13965
|
const preview = check(context, [
|
|
13514
13966
|
candidate
|
|
13515
13967
|
]);
|
|
@@ -13523,7 +13975,7 @@ function FallbackRegistrationsPanel() {
|
|
|
13523
13975
|
{
|
|
13524
13976
|
className: `inline-flex items-center gap-2 rounded-xl border px-3 py-2 text-xs ${tone}`,
|
|
13525
13977
|
children: [
|
|
13526
|
-
/* @__PURE__ */ jsx12("span", { children: service ? `#${String(service.id)} \xB7 ${(
|
|
13978
|
+
/* @__PURE__ */ jsx12("span", { children: service ? `#${String(service.id)} \xB7 ${(_a3 = service.name) != null ? _a3 : "Unnamed"}` : `#${String(candidate)}` }),
|
|
13527
13979
|
rejected ? /* @__PURE__ */ jsx12("span", { className: "rounded-full border border-current/20 px-2 py-0.5 text-[10px]", children: rejected.reasons.join(
|
|
13528
13980
|
", "
|
|
13529
13981
|
) }) : /* @__PURE__ */ jsx12("span", { className: "rounded-full border border-current/20 px-2 py-0.5 text-[10px]", children: "valid" }),
|
|
@@ -13569,7 +14021,7 @@ function FallbackRegistrationsPanel() {
|
|
|
13569
14021
|
] })
|
|
13570
14022
|
]
|
|
13571
14023
|
},
|
|
13572
|
-
`${reg.scope}:${String((
|
|
14024
|
+
`${reg.scope}:${String((_a2 = reg.scopeId) != null ? _a2 : "global")}:${index}`
|
|
13573
14025
|
);
|
|
13574
14026
|
}) })
|
|
13575
14027
|
] }),
|
|
@@ -13628,7 +14080,7 @@ function FallbackAddCandidatesDialog({
|
|
|
13628
14080
|
const items = React12.useMemo(() => {
|
|
13629
14081
|
const q = query.trim().toLowerCase();
|
|
13630
14082
|
return eligibleServices.filter((service) => {
|
|
13631
|
-
var
|
|
14083
|
+
var _a2, _b;
|
|
13632
14084
|
if (primaryId !== void 0 && String(service.id) === String(primaryId)) {
|
|
13633
14085
|
return false;
|
|
13634
14086
|
}
|
|
@@ -13636,7 +14088,7 @@ function FallbackAddCandidatesDialog({
|
|
|
13636
14088
|
return false;
|
|
13637
14089
|
}
|
|
13638
14090
|
if (!q) return true;
|
|
13639
|
-
return String(service.id).includes(q) || String((
|
|
14091
|
+
return String(service.id).includes(q) || String((_a2 = service.name) != null ? _a2 : "").toLowerCase().includes(q) || String((_b = service.platform) != null ? _b : "").toLowerCase().includes(q);
|
|
13640
14092
|
});
|
|
13641
14093
|
}, [eligibleServices, allowedIds, query, primaryId]);
|
|
13642
14094
|
function toggle(id) {
|
|
@@ -13758,7 +14210,7 @@ function FallbackAddRegistrationDialog({
|
|
|
13758
14210
|
return registrations.some((r) => r.scope === "global");
|
|
13759
14211
|
}, [registrations]);
|
|
13760
14212
|
const nodeTargets = React13.useMemo(() => {
|
|
13761
|
-
var
|
|
14213
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
13762
14214
|
if (activeServiceId === void 0 || activeServiceId === null) {
|
|
13763
14215
|
return [];
|
|
13764
14216
|
}
|
|
@@ -13779,7 +14231,7 @@ function FallbackAddRegistrationDialog({
|
|
|
13779
14231
|
serviceId: activeServiceId
|
|
13780
14232
|
});
|
|
13781
14233
|
}
|
|
13782
|
-
const activeTagId = (
|
|
14234
|
+
const activeTagId = (_a2 = snapshot.selection) == null ? void 0 : _a2.tag;
|
|
13783
14235
|
out.sort((a, b) => {
|
|
13784
14236
|
if (activeTagId && a.id === activeTagId && b.id !== activeTagId) {
|
|
13785
14237
|
return -1;
|
|
@@ -13859,7 +14311,7 @@ function FallbackAddRegistrationDialog({
|
|
|
13859
14311
|
}
|
|
13860
14312
|
}, [scope, nodeId, nodeTargets]);
|
|
13861
14313
|
function handleContinue() {
|
|
13862
|
-
var
|
|
14314
|
+
var _a2;
|
|
13863
14315
|
if (activeServiceId === void 0 || activeServiceId === null) return;
|
|
13864
14316
|
if (scope === "global") {
|
|
13865
14317
|
onSelect(
|
|
@@ -13878,7 +14330,7 @@ function FallbackAddRegistrationDialog({
|
|
|
13878
14330
|
scope: "node",
|
|
13879
14331
|
nodeId
|
|
13880
14332
|
},
|
|
13881
|
-
(
|
|
14333
|
+
(_a2 = node == null ? void 0 : node.serviceId) != null ? _a2 : activeServiceId
|
|
13882
14334
|
);
|
|
13883
14335
|
}
|
|
13884
14336
|
if (!open) return null;
|
|
@@ -13958,11 +14410,11 @@ function FallbackAddRegistrationDialog({
|
|
|
13958
14410
|
] }) });
|
|
13959
14411
|
}
|
|
13960
14412
|
function resolveNodeMeta(props, nodeId) {
|
|
13961
|
-
var
|
|
14413
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
13962
14414
|
if (!props) {
|
|
13963
14415
|
return { kind: "node", label: nodeId };
|
|
13964
14416
|
}
|
|
13965
|
-
const tag = (
|
|
14417
|
+
const tag = (_a2 = props.filters) == null ? void 0 : _a2.find((t) => t.id === nodeId);
|
|
13966
14418
|
if (tag) {
|
|
13967
14419
|
return {
|
|
13968
14420
|
kind: "tag",
|
|
@@ -14013,6 +14465,7 @@ export {
|
|
|
14013
14465
|
useFallbackEditorContext,
|
|
14014
14466
|
useFormApi,
|
|
14015
14467
|
useInputs,
|
|
14468
|
+
useInputsMaybe,
|
|
14016
14469
|
useOptionalFormApi,
|
|
14017
14470
|
useOrderFlow,
|
|
14018
14471
|
useOrderFlowContext,
|