@timeax/digital-service-engine 0.3.4 → 0.3.5
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/core/index.cjs +29 -5
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +29 -5
- package/dist/core/index.js.map +1 -1
- package/dist/react/index.cjs +776 -628
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +68 -54
- package/dist/react/index.d.ts +68 -54
- package/dist/react/index.js +776 -628
- package/dist/react/index.js.map +1 -1
- package/dist/workspace/index.cjs +58 -0
- package/dist/workspace/index.cjs.map +1 -1
- package/dist/workspace/index.d.cts +131 -1
- package/dist/workspace/index.d.ts +131 -1
- package/dist/workspace/index.js +58 -0
- package/dist/workspace/index.js.map +1 -1
- package/package.json +1 -1
package/dist/react/index.cjs
CHANGED
|
@@ -69,8 +69,8 @@ var EventBus = class {
|
|
|
69
69
|
this.listeners = /* @__PURE__ */ new Map();
|
|
70
70
|
}
|
|
71
71
|
on(event, handler) {
|
|
72
|
-
var
|
|
73
|
-
const set = (
|
|
72
|
+
var _a;
|
|
73
|
+
const set = (_a = this.listeners.get(event)) != null ? _a : /* @__PURE__ */ new Set();
|
|
74
74
|
set.add(handler);
|
|
75
75
|
this.listeners.set(event, set);
|
|
76
76
|
return () => {
|
|
@@ -102,9 +102,9 @@ var RetryQueue = class {
|
|
|
102
102
|
constructor(opts = {}) {
|
|
103
103
|
this.jobs = /* @__PURE__ */ new Map();
|
|
104
104
|
this.paused = false;
|
|
105
|
-
var
|
|
105
|
+
var _a, _b, _c, _d, _e, _f;
|
|
106
106
|
this.opts = {
|
|
107
|
-
enabled: (
|
|
107
|
+
enabled: (_a = opts.enabled) != null ? _a : true,
|
|
108
108
|
maxAttempts: (_b = opts.maxAttempts) != null ? _b : 5,
|
|
109
109
|
baseDelayMs: (_c = opts.baseDelayMs) != null ? _c : 800,
|
|
110
110
|
maxDelayMs: (_d = opts.maxDelayMs) != null ? _d : 2e4,
|
|
@@ -121,11 +121,11 @@ var RetryQueue = class {
|
|
|
121
121
|
}
|
|
122
122
|
/** Enqueue or no-op if a job with same id already exists */
|
|
123
123
|
enqueue(job) {
|
|
124
|
-
var
|
|
124
|
+
var _a;
|
|
125
125
|
if (!this.opts.enabled) return false;
|
|
126
126
|
if (this.jobs.has(job.id)) return false;
|
|
127
127
|
this.jobs.set(job.id, { job, attempt: 0 });
|
|
128
|
-
(
|
|
128
|
+
(_a = job.onStatus) == null ? void 0 : _a.call(job, "scheduled", { attempt: 0 });
|
|
129
129
|
this.kick(job.id);
|
|
130
130
|
return true;
|
|
131
131
|
}
|
|
@@ -139,12 +139,12 @@ var RetryQueue = class {
|
|
|
139
139
|
return true;
|
|
140
140
|
}
|
|
141
141
|
cancel(id) {
|
|
142
|
-
var
|
|
142
|
+
var _a, _b;
|
|
143
143
|
const rec = this.jobs.get(id);
|
|
144
144
|
if (!rec) return false;
|
|
145
145
|
if (rec.timer) clearTimeout(rec.timer);
|
|
146
146
|
rec.cancelled = true;
|
|
147
|
-
(_b = (
|
|
147
|
+
(_b = (_a = rec.job).onStatus) == null ? void 0 : _b.call(_a, "cancelled", { attempt: rec.attempt });
|
|
148
148
|
this.jobs.delete(id);
|
|
149
149
|
return true;
|
|
150
150
|
}
|
|
@@ -158,11 +158,11 @@ var RetryQueue = class {
|
|
|
158
158
|
return this.jobs.has(id);
|
|
159
159
|
}
|
|
160
160
|
drain() {
|
|
161
|
-
var
|
|
161
|
+
var _a, _b;
|
|
162
162
|
for (const [id, rec] of this.jobs.entries()) {
|
|
163
163
|
if (rec.timer) clearTimeout(rec.timer);
|
|
164
164
|
rec.cancelled = true;
|
|
165
|
-
(_b = (
|
|
165
|
+
(_b = (_a = rec.job).onStatus) == null ? void 0 : _b.call(_a, "cancelled", { attempt: rec.attempt });
|
|
166
166
|
this.jobs.delete(id);
|
|
167
167
|
}
|
|
168
168
|
}
|
|
@@ -177,15 +177,15 @@ var RetryQueue = class {
|
|
|
177
177
|
return Math.min(maxDelayMs, Math.floor(exp * r));
|
|
178
178
|
}
|
|
179
179
|
async kick(id, immediate = false) {
|
|
180
|
-
var
|
|
180
|
+
var _a, _b;
|
|
181
181
|
const rec = this.jobs.get(id);
|
|
182
182
|
if (!rec || rec.cancelled) return;
|
|
183
183
|
if (this.paused && !immediate) return;
|
|
184
184
|
const attempt = rec.attempt + 1;
|
|
185
185
|
const run = async () => {
|
|
186
|
-
var
|
|
186
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
187
187
|
if (rec.cancelled) return;
|
|
188
|
-
(_b2 = (
|
|
188
|
+
(_b2 = (_a2 = rec.job).onStatus) == null ? void 0 : _b2.call(_a2, "retrying", { attempt });
|
|
189
189
|
try {
|
|
190
190
|
const ok = await rec.job.perform(attempt);
|
|
191
191
|
if (ok) {
|
|
@@ -210,7 +210,7 @@ var RetryQueue = class {
|
|
|
210
210
|
else {
|
|
211
211
|
const delay = this.opts.immediateFirst && attempt === 1 ? 0 : this.delayFor(attempt);
|
|
212
212
|
if (delay) {
|
|
213
|
-
(_b = (
|
|
213
|
+
(_b = (_a = rec.job).onStatus) == null ? void 0 : _b.call(_a, "scheduled", { attempt: 0, nextDelayMs: delay });
|
|
214
214
|
rec.timer = setTimeout(run, delay);
|
|
215
215
|
} else {
|
|
216
216
|
void run();
|
|
@@ -230,8 +230,8 @@ var CommentsAPI = class {
|
|
|
230
230
|
this.retry = new RetryQueue(deps.retry);
|
|
231
231
|
}
|
|
232
232
|
scope() {
|
|
233
|
-
var
|
|
234
|
-
return (_b = (
|
|
233
|
+
var _a, _b;
|
|
234
|
+
return (_b = (_a = this.deps).getScope) == null ? void 0 : _b.call(_a);
|
|
235
235
|
}
|
|
236
236
|
emitSync(op, threadId, messageId, status, meta) {
|
|
237
237
|
this.bus.emit("comment:sync", {
|
|
@@ -273,7 +273,7 @@ var CommentsAPI = class {
|
|
|
273
273
|
}
|
|
274
274
|
/* ─── Mutations (optimistic if backend present) ─────── */
|
|
275
275
|
async create(anchor, initialBody, meta) {
|
|
276
|
-
var
|
|
276
|
+
var _a, _b;
|
|
277
277
|
const now = Date.now();
|
|
278
278
|
const localId = newLocalId("t");
|
|
279
279
|
const msgId = newLocalId("m");
|
|
@@ -314,7 +314,7 @@ var CommentsAPI = class {
|
|
|
314
314
|
return serverId;
|
|
315
315
|
} catch (err) {
|
|
316
316
|
const scope = this.scope();
|
|
317
|
-
const branchKey = (
|
|
317
|
+
const branchKey = (_a = scope == null ? void 0 : scope.branchId) != null ? _a : "no_branch";
|
|
318
318
|
const jobId = `comments:create_thread:${branchKey}:${localId}`;
|
|
319
319
|
this.retry.enqueue({
|
|
320
320
|
id: jobId,
|
|
@@ -345,7 +345,7 @@ var CommentsAPI = class {
|
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
347
|
async reply(threadId, body, meta) {
|
|
348
|
-
var
|
|
348
|
+
var _a, _b, _c;
|
|
349
349
|
const th = this.ensure(threadId);
|
|
350
350
|
const now = Date.now();
|
|
351
351
|
const localMid = newLocalId("m");
|
|
@@ -358,7 +358,7 @@ var CommentsAPI = class {
|
|
|
358
358
|
};
|
|
359
359
|
th.messages.push(localMsg);
|
|
360
360
|
th.updatedAt = now;
|
|
361
|
-
(
|
|
361
|
+
(_a = th._sync) != null ? _a : th._sync = hasBackend ? "pending" : "synced";
|
|
362
362
|
this.bus.emit("comment:message:create", {
|
|
363
363
|
threadId,
|
|
364
364
|
message: localMsg
|
|
@@ -417,7 +417,7 @@ var CommentsAPI = class {
|
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
419
|
async editMessage(threadId, messageId, body) {
|
|
420
|
-
var
|
|
420
|
+
var _a, _b, _c;
|
|
421
421
|
const th = this.ensure(threadId);
|
|
422
422
|
const orig = th.messages.find((m) => m.id === messageId);
|
|
423
423
|
if (!orig) return;
|
|
@@ -426,7 +426,7 @@ var CommentsAPI = class {
|
|
|
426
426
|
orig.editedAt = Date.now();
|
|
427
427
|
th.updatedAt = orig.editedAt;
|
|
428
428
|
const hasBackend = Boolean(this.deps.backend && this.scope());
|
|
429
|
-
(
|
|
429
|
+
(_a = th._sync) != null ? _a : th._sync = hasBackend ? "pending" : "synced";
|
|
430
430
|
this.bus.emit("comment:thread:update", { thread: th });
|
|
431
431
|
if (!this.deps.backend) return;
|
|
432
432
|
const performOnce = async () => {
|
|
@@ -479,13 +479,13 @@ var CommentsAPI = class {
|
|
|
479
479
|
}
|
|
480
480
|
}
|
|
481
481
|
async deleteMessage(threadId, messageId) {
|
|
482
|
-
var
|
|
482
|
+
var _a, _b, _c;
|
|
483
483
|
const th = this.ensure(threadId);
|
|
484
484
|
const backup = [...th.messages];
|
|
485
485
|
th.messages = th.messages.filter((m) => m.id !== messageId);
|
|
486
486
|
th.updatedAt = Date.now();
|
|
487
487
|
const hasBackend = Boolean(this.deps.backend && this.scope());
|
|
488
|
-
(
|
|
488
|
+
(_a = th._sync) != null ? _a : th._sync = hasBackend ? "pending" : "synced";
|
|
489
489
|
this.bus.emit("comment:thread:update", { thread: th });
|
|
490
490
|
if (!this.deps.backend) return;
|
|
491
491
|
const performOnce = async () => {
|
|
@@ -534,13 +534,13 @@ var CommentsAPI = class {
|
|
|
534
534
|
}
|
|
535
535
|
}
|
|
536
536
|
async move(threadId, anchor) {
|
|
537
|
-
var
|
|
537
|
+
var _a, _b, _c;
|
|
538
538
|
const th = this.ensure(threadId);
|
|
539
539
|
const prev = th.anchor;
|
|
540
540
|
th.anchor = anchor;
|
|
541
541
|
th.updatedAt = Date.now();
|
|
542
542
|
const hasBackend = Boolean(this.deps.backend && this.scope());
|
|
543
|
-
(
|
|
543
|
+
(_a = th._sync) != null ? _a : th._sync = hasBackend ? "pending" : "synced";
|
|
544
544
|
this.bus.emit("comment:move", { thread: th });
|
|
545
545
|
this.bus.emit("comment:thread:update", { thread: th });
|
|
546
546
|
if (!this.deps.backend) return;
|
|
@@ -592,13 +592,13 @@ var CommentsAPI = class {
|
|
|
592
592
|
}
|
|
593
593
|
}
|
|
594
594
|
async resolve(threadId, value = true) {
|
|
595
|
-
var
|
|
595
|
+
var _a, _b, _c;
|
|
596
596
|
const th = this.ensure(threadId);
|
|
597
597
|
const prev = th.resolved;
|
|
598
598
|
th.resolved = value;
|
|
599
599
|
th.updatedAt = Date.now();
|
|
600
600
|
const hasBackend = Boolean(this.deps.backend && this.scope());
|
|
601
|
-
(
|
|
601
|
+
(_a = th._sync) != null ? _a : th._sync = hasBackend ? "pending" : "synced";
|
|
602
602
|
this.bus.emit("comment:resolve", { thread: th, resolved: value });
|
|
603
603
|
this.bus.emit("comment:thread:update", { thread: th });
|
|
604
604
|
if (!this.deps.backend) return;
|
|
@@ -650,7 +650,7 @@ var CommentsAPI = class {
|
|
|
650
650
|
}
|
|
651
651
|
}
|
|
652
652
|
async deleteThread(threadId) {
|
|
653
|
-
var
|
|
653
|
+
var _a, _b;
|
|
654
654
|
const prev = this.threads.get(threadId);
|
|
655
655
|
if (!prev) return;
|
|
656
656
|
this.threads.delete(threadId);
|
|
@@ -666,7 +666,7 @@ var CommentsAPI = class {
|
|
|
666
666
|
await performOnce();
|
|
667
667
|
} catch (err) {
|
|
668
668
|
const scope = this.scope();
|
|
669
|
-
const branchKey = (
|
|
669
|
+
const branchKey = (_a = scope == null ? void 0 : scope.branchId) != null ? _a : "no_branch";
|
|
670
670
|
const jobId = `comments:delete_thread:${branchKey}:${threadId}`;
|
|
671
671
|
this.retry.enqueue({
|
|
672
672
|
id: jobId,
|
|
@@ -719,8 +719,8 @@ var import_lodash_es4 = require("lodash-es");
|
|
|
719
719
|
// src/core/normalise.ts
|
|
720
720
|
var import_lodash_es = require("lodash-es");
|
|
721
721
|
function normalise(input, opts = {}) {
|
|
722
|
-
var
|
|
723
|
-
const defRole = (
|
|
722
|
+
var _a, _b;
|
|
723
|
+
const defRole = (_a = opts.defaultPricingRole) != null ? _a : "base";
|
|
724
724
|
const constraints = (_b = opts.constraints) != null ? _b : ["refill", "cancel", "dripfeed"];
|
|
725
725
|
const obj = toObject(input);
|
|
726
726
|
const rawFilters = Array.isArray(obj.filters) ? obj.filters : [];
|
|
@@ -770,10 +770,10 @@ function propagateConstraints(props, flagKeys) {
|
|
|
770
770
|
const starts = roots.length ? roots : tags;
|
|
771
771
|
const visited = /* @__PURE__ */ new Set();
|
|
772
772
|
const visit = (tag, inherited) => {
|
|
773
|
-
var
|
|
773
|
+
var _a, _b;
|
|
774
774
|
if (visited.has(tag.id)) return;
|
|
775
775
|
visited.add(tag.id);
|
|
776
|
-
const local = (0, import_lodash_es.cloneDeep)((
|
|
776
|
+
const local = (0, import_lodash_es.cloneDeep)((_a = tag.constraints) != null ? _a : {});
|
|
777
777
|
if (tag.constraints_overrides) {
|
|
778
778
|
for (const [k, over] of Object.entries(tag.constraints_overrides)) {
|
|
779
779
|
if (over) local[k] = over.from;
|
|
@@ -1055,8 +1055,8 @@ function isServiceIdRef(v) {
|
|
|
1055
1055
|
return typeof v === "string" && v.trim().length > 0 || typeof v === "number" && Number.isFinite(v);
|
|
1056
1056
|
}
|
|
1057
1057
|
function hasAnyServiceOption(f) {
|
|
1058
|
-
var
|
|
1059
|
-
return ((
|
|
1058
|
+
var _a;
|
|
1059
|
+
return ((_a = f.options) != null ? _a : []).some((o) => isServiceIdRef(o.service_id));
|
|
1060
1060
|
}
|
|
1061
1061
|
function getByPath(obj, path) {
|
|
1062
1062
|
if (!path) return void 0;
|
|
@@ -1086,12 +1086,12 @@ function includesValue(arr, needle) {
|
|
|
1086
1086
|
return false;
|
|
1087
1087
|
}
|
|
1088
1088
|
function matchesWhere(svc, where) {
|
|
1089
|
-
var
|
|
1089
|
+
var _a;
|
|
1090
1090
|
if (!where || where.length === 0) return true;
|
|
1091
1091
|
const root = { service: svc };
|
|
1092
1092
|
for (const clause of where) {
|
|
1093
1093
|
const path = clause.path;
|
|
1094
|
-
const op = (
|
|
1094
|
+
const op = (_a = clause.op) != null ? _a : "eq";
|
|
1095
1095
|
const value = clause.value;
|
|
1096
1096
|
const cur = getByPath(root, path);
|
|
1097
1097
|
if (op === "exists") {
|
|
@@ -1145,9 +1145,9 @@ function withAffected(details, ids) {
|
|
|
1145
1145
|
|
|
1146
1146
|
// src/core/node-map.ts
|
|
1147
1147
|
function buildNodeMap(props) {
|
|
1148
|
-
var
|
|
1148
|
+
var _a, _b, _c;
|
|
1149
1149
|
const map = /* @__PURE__ */ new Map();
|
|
1150
|
-
for (const t of (
|
|
1150
|
+
for (const t of (_a = props.filters) != null ? _a : []) {
|
|
1151
1151
|
if (!map.has(t.id)) map.set(t.id, { kind: "tag", id: t.id, node: t });
|
|
1152
1152
|
}
|
|
1153
1153
|
for (const f of (_b = props.fields) != null ? _b : []) {
|
|
@@ -1186,8 +1186,8 @@ function resolveTrigger(trigger, nodeMap) {
|
|
|
1186
1186
|
|
|
1187
1187
|
// src/core/visibility.ts
|
|
1188
1188
|
function visibleFieldIdsUnder(props, tagId, opts = {}) {
|
|
1189
|
-
var
|
|
1190
|
-
const tags = (
|
|
1189
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1190
|
+
const tags = (_a = props.filters) != null ? _a : [];
|
|
1191
1191
|
const fields = (_b = props.fields) != null ? _b : [];
|
|
1192
1192
|
const tagById = new Map(tags.map((t) => [t.id, t]));
|
|
1193
1193
|
const tag = tagById.get(tagId);
|
|
@@ -1304,9 +1304,9 @@ function visibleFieldIdsUnder(props, tagId, opts = {}) {
|
|
|
1304
1304
|
return base;
|
|
1305
1305
|
}
|
|
1306
1306
|
function visibleFieldsUnder(props, tagId, opts = {}) {
|
|
1307
|
-
var
|
|
1307
|
+
var _a;
|
|
1308
1308
|
const ids = visibleFieldIdsUnder(props, tagId, opts);
|
|
1309
|
-
const fieldById = new Map(((
|
|
1309
|
+
const fieldById = new Map(((_a = props.fields) != null ? _a : []).map((f) => [f.id, f]));
|
|
1310
1310
|
return ids.map((id) => fieldById.get(id)).filter(Boolean);
|
|
1311
1311
|
}
|
|
1312
1312
|
|
|
@@ -1326,7 +1326,7 @@ function resolveRootTags(tags) {
|
|
|
1326
1326
|
return roots.length ? roots : tags.slice(0, 1);
|
|
1327
1327
|
}
|
|
1328
1328
|
function collectSelectableTriggersInContext(v, tagId, selectedKeys, effectfulKeys) {
|
|
1329
|
-
var
|
|
1329
|
+
var _a;
|
|
1330
1330
|
const visible = visibleFieldsUnder(v.props, tagId, {
|
|
1331
1331
|
selectedKeys
|
|
1332
1332
|
});
|
|
@@ -1336,7 +1336,7 @@ function collectSelectableTriggersInContext(v, tagId, selectedKeys, effectfulKey
|
|
|
1336
1336
|
const t = f.id;
|
|
1337
1337
|
if (effectfulKeys.has(t)) triggers.push(t);
|
|
1338
1338
|
}
|
|
1339
|
-
for (const o of (
|
|
1339
|
+
for (const o of (_a = f.options) != null ? _a : []) {
|
|
1340
1340
|
const t = o.id;
|
|
1341
1341
|
if (effectfulKeys.has(t)) triggers.push(t);
|
|
1342
1342
|
}
|
|
@@ -1345,12 +1345,12 @@ function collectSelectableTriggersInContext(v, tagId, selectedKeys, effectfulKey
|
|
|
1345
1345
|
return triggers;
|
|
1346
1346
|
}
|
|
1347
1347
|
function runVisibilityRulesOnce(v) {
|
|
1348
|
-
var
|
|
1348
|
+
var _a, _b, _c, _d, _e;
|
|
1349
1349
|
for (const t of v.tags) {
|
|
1350
1350
|
const visible = v.fieldsVisibleUnder(t.id);
|
|
1351
1351
|
const seen = /* @__PURE__ */ new Map();
|
|
1352
1352
|
for (const f of visible) {
|
|
1353
|
-
const label = ((
|
|
1353
|
+
const label = ((_a = f.label) != null ? _a : "").trim();
|
|
1354
1354
|
if (!label) continue;
|
|
1355
1355
|
if (seen.has(label)) {
|
|
1356
1356
|
const otherId = seen.get(label);
|
|
@@ -1422,8 +1422,8 @@ function runVisibilityRulesOnce(v) {
|
|
|
1422
1422
|
function dedupeErrorsInPlace(v, startIndex) {
|
|
1423
1423
|
const seen = /* @__PURE__ */ new Set();
|
|
1424
1424
|
const keyOfErr = (e) => {
|
|
1425
|
-
var
|
|
1426
|
-
const tagId = (_e = (_d = (
|
|
1425
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1426
|
+
const tagId = (_e = (_d = (_a = e == null ? void 0 : e.details) == null ? void 0 : _a.tagId) != null ? _d : (_c = (_b = e == null ? void 0 : e.details) == null ? void 0 : _b.affected) == null ? void 0 : _c.tagId) != null ? _e : "";
|
|
1427
1427
|
const other = (_g = (_f = e == null ? void 0 : e.details) == null ? void 0 : _f.other) != null ? _g : "";
|
|
1428
1428
|
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 : ""}`;
|
|
1429
1429
|
};
|
|
@@ -1438,7 +1438,7 @@ function dedupeErrorsInPlace(v, startIndex) {
|
|
|
1438
1438
|
v.errors.splice(startIndex, v.errors.length - startIndex, ...kept);
|
|
1439
1439
|
}
|
|
1440
1440
|
function validateVisibility(v, options = {}) {
|
|
1441
|
-
var
|
|
1441
|
+
var _a, _b, _c, _d, _e;
|
|
1442
1442
|
v.simulatedVisibilityContexts = [];
|
|
1443
1443
|
const simulate = options.simulate === true;
|
|
1444
1444
|
if (!simulate) {
|
|
@@ -1452,7 +1452,7 @@ function validateVisibility(v, options = {}) {
|
|
|
1452
1452
|
}
|
|
1453
1453
|
return;
|
|
1454
1454
|
}
|
|
1455
|
-
const maxStates = Math.max(1, (
|
|
1455
|
+
const maxStates = Math.max(1, (_a = options.maxStates) != null ? _a : 500);
|
|
1456
1456
|
const maxDepth = Math.max(0, (_b = options.maxDepth) != null ? _b : 6);
|
|
1457
1457
|
const onlyEffectful = options.onlyEffectfulTriggers !== false;
|
|
1458
1458
|
const effectfulKeys = /* @__PURE__ */ new Set();
|
|
@@ -1542,11 +1542,11 @@ function validateStructure(v) {
|
|
|
1542
1542
|
const visiting = /* @__PURE__ */ new Set();
|
|
1543
1543
|
const visited = /* @__PURE__ */ new Set();
|
|
1544
1544
|
const hasCycleFrom = (id) => {
|
|
1545
|
-
var
|
|
1545
|
+
var _a;
|
|
1546
1546
|
if (visiting.has(id)) return true;
|
|
1547
1547
|
if (visited.has(id)) return false;
|
|
1548
1548
|
visiting.add(id);
|
|
1549
|
-
const parent = (
|
|
1549
|
+
const parent = (_a = v.tagById.get(id)) == null ? void 0 : _a.bind_id;
|
|
1550
1550
|
if (parent && v.tagById.has(parent) && hasCycleFrom(parent))
|
|
1551
1551
|
return true;
|
|
1552
1552
|
visiting.delete(id);
|
|
@@ -1607,7 +1607,7 @@ function validateStructure(v) {
|
|
|
1607
1607
|
|
|
1608
1608
|
// src/core/validate/steps/identity.ts
|
|
1609
1609
|
function validateIdentity(v) {
|
|
1610
|
-
var
|
|
1610
|
+
var _a, _b;
|
|
1611
1611
|
const tags = v.tags;
|
|
1612
1612
|
const fields = v.fields;
|
|
1613
1613
|
{
|
|
@@ -1629,7 +1629,7 @@ function validateIdentity(v) {
|
|
|
1629
1629
|
}
|
|
1630
1630
|
for (const f of fields) {
|
|
1631
1631
|
if (seen.has(f.id)) {
|
|
1632
|
-
const kind = (
|
|
1632
|
+
const kind = (_a = firstSeen.get(f.id)) != null ? _a : "tag/field";
|
|
1633
1633
|
v.errors.push({
|
|
1634
1634
|
code: "duplicate_id",
|
|
1635
1635
|
severity: "error",
|
|
@@ -1731,14 +1731,14 @@ function parseFieldOptionKey(key) {
|
|
|
1731
1731
|
return { fieldId, optionId };
|
|
1732
1732
|
}
|
|
1733
1733
|
function hasOption(v, fid, oid) {
|
|
1734
|
-
var
|
|
1734
|
+
var _a;
|
|
1735
1735
|
const f = v.fieldById.get(fid);
|
|
1736
1736
|
if (!f) return false;
|
|
1737
|
-
return !!((
|
|
1737
|
+
return !!((_a = f.options) != null ? _a : []).find((o) => o.id === oid);
|
|
1738
1738
|
}
|
|
1739
1739
|
function validateOptionMaps(v) {
|
|
1740
|
-
var
|
|
1741
|
-
const incMap = (
|
|
1740
|
+
var _a, _b;
|
|
1741
|
+
const incMap = (_a = v.props.includes_for_buttons) != null ? _a : {};
|
|
1742
1742
|
const excMap = (_b = v.props.excludes_for_buttons) != null ? _b : {};
|
|
1743
1743
|
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.`;
|
|
1744
1744
|
const validateTriggerKey = (key) => {
|
|
@@ -1852,8 +1852,8 @@ function normalizeSelectedOrderKindTriggers(selectedTriggerKeys, nodeMap) {
|
|
|
1852
1852
|
return out;
|
|
1853
1853
|
}
|
|
1854
1854
|
function resolveOrderKind(params) {
|
|
1855
|
-
var
|
|
1856
|
-
const nodeMap = (
|
|
1855
|
+
var _a, _b;
|
|
1856
|
+
const nodeMap = (_a = params.nodeMap) != null ? _a : buildNodeMap(params.props);
|
|
1857
1857
|
const orderKinds = (_b = params.props.orderKinds) != null ? _b : {};
|
|
1858
1858
|
const normalizedSelected = normalizeSelectedOrderKindTriggers(
|
|
1859
1859
|
params.selectedTriggerKeys,
|
|
@@ -1908,8 +1908,8 @@ function resolveOrderKind(params) {
|
|
|
1908
1908
|
|
|
1909
1909
|
// src/core/validate/steps/order-kinds.ts
|
|
1910
1910
|
function validateOrderKinds(v) {
|
|
1911
|
-
var
|
|
1912
|
-
const selectedTriggerKeys = Array.from((
|
|
1911
|
+
var _a, _b, _c;
|
|
1912
|
+
const selectedTriggerKeys = Array.from((_a = v.selectedKeys) != null ? _a : []);
|
|
1913
1913
|
if (!selectedTriggerKeys.length) return;
|
|
1914
1914
|
const resolved = resolveOrderKind({
|
|
1915
1915
|
props: v.props,
|
|
@@ -1935,8 +1935,8 @@ function validateOrderKinds(v) {
|
|
|
1935
1935
|
|
|
1936
1936
|
// src/core/validate/steps/service-vs-input.ts
|
|
1937
1937
|
function hasButtonTriggerMap(v, fieldId) {
|
|
1938
|
-
var
|
|
1939
|
-
const includes = (
|
|
1938
|
+
var _a, _b;
|
|
1939
|
+
const includes = (_a = v.props.includes_for_buttons) == null ? void 0 : _a[fieldId];
|
|
1940
1940
|
const excludes = (_b = v.props.excludes_for_buttons) == null ? void 0 : _b[fieldId];
|
|
1941
1941
|
return Array.isArray(includes) && includes.length > 0 || Array.isArray(excludes) && excludes.length > 0;
|
|
1942
1942
|
}
|
|
@@ -1981,7 +1981,7 @@ function validateServiceVsUserInput(v) {
|
|
|
1981
1981
|
|
|
1982
1982
|
// src/core/validate/steps/utility.ts
|
|
1983
1983
|
function validateUtilityMarkers(v) {
|
|
1984
|
-
var
|
|
1984
|
+
var _a, _b, _c, _d;
|
|
1985
1985
|
const ALLOWED_UTILITY_MODES = /* @__PURE__ */ new Set([
|
|
1986
1986
|
"flat",
|
|
1987
1987
|
"per_quantity",
|
|
@@ -1991,7 +1991,7 @@ function validateUtilityMarkers(v) {
|
|
|
1991
1991
|
for (const f of v.fields) {
|
|
1992
1992
|
const optsArr = Array.isArray(f.options) ? f.options : [];
|
|
1993
1993
|
for (const o of optsArr) {
|
|
1994
|
-
const role = (_b = (
|
|
1994
|
+
const role = (_b = (_a = o.pricing_role) != null ? _a : f.pricing_role) != null ? _b : "base";
|
|
1995
1995
|
const hasService = isServiceIdRef(o.service_id);
|
|
1996
1996
|
const util = (_c = o.meta) == null ? void 0 : _c.utility;
|
|
1997
1997
|
if (role === "utility" && hasService) {
|
|
@@ -2072,9 +2072,9 @@ function validateUtilityMarkers(v) {
|
|
|
2072
2072
|
|
|
2073
2073
|
// src/utils/index.ts
|
|
2074
2074
|
function isMultiField(f) {
|
|
2075
|
-
var
|
|
2075
|
+
var _a;
|
|
2076
2076
|
const t = (f.type || "").toLowerCase();
|
|
2077
|
-
const metaMulti = !!((
|
|
2077
|
+
const metaMulti = !!((_a = f.meta) == null ? void 0 : _a.multi);
|
|
2078
2078
|
return t === "multiselect" || t === "checkbox" || metaMulti;
|
|
2079
2079
|
}
|
|
2080
2080
|
|
|
@@ -2094,8 +2094,8 @@ function constraintFitOk(svcMap, candidate, constraints) {
|
|
|
2094
2094
|
return !(constraints.cancel === true && !cap.cancel);
|
|
2095
2095
|
}
|
|
2096
2096
|
function getServiceCapability(svcMap, candidate) {
|
|
2097
|
-
var
|
|
2098
|
-
return (
|
|
2097
|
+
var _a;
|
|
2098
|
+
return (_a = getServiceCapabilityEntry(svcMap, candidate)) == null ? void 0 : _a.capability;
|
|
2099
2099
|
}
|
|
2100
2100
|
function getServiceCapabilityCanonicalRef(svcMap, candidate) {
|
|
2101
2101
|
const entry = getServiceCapabilityEntry(svcMap, candidate);
|
|
@@ -2122,10 +2122,10 @@ function isSameServiceCapabilityRef(svcMap, left, right) {
|
|
|
2122
2122
|
return rightAliases.some((value) => leftAliases.has(String(value)));
|
|
2123
2123
|
}
|
|
2124
2124
|
function normalizeRatePolicy(policy) {
|
|
2125
|
-
var
|
|
2125
|
+
var _a;
|
|
2126
2126
|
if (!policy) return { kind: "lte_primary", pct: 5 };
|
|
2127
2127
|
if (policy.kind === "eq_primary") return policy;
|
|
2128
|
-
const pct = Math.max(0, Number((
|
|
2128
|
+
const pct = Math.max(0, Number((_a = policy.pct) != null ? _a : 0));
|
|
2129
2129
|
return { ...policy, pct };
|
|
2130
2130
|
}
|
|
2131
2131
|
function passesRatePolicy(policy, primaryRate, candidateRate) {
|
|
@@ -2226,12 +2226,12 @@ function normalizeServiceRef(value) {
|
|
|
2226
2226
|
|
|
2227
2227
|
// src/core/validate/steps/rates.ts
|
|
2228
2228
|
function validateRates(v) {
|
|
2229
|
-
var
|
|
2229
|
+
var _a, _b, _c;
|
|
2230
2230
|
const ratePolicy = normalizeRatePolicy(v.options.ratePolicy);
|
|
2231
2231
|
for (const f of v.fields) {
|
|
2232
2232
|
if (!isMultiField(f)) continue;
|
|
2233
2233
|
const baseRates = [];
|
|
2234
|
-
for (const o of (
|
|
2234
|
+
for (const o of (_a = f.options) != null ? _a : []) {
|
|
2235
2235
|
const role = (_c = (_b = o.pricing_role) != null ? _b : f.pricing_role) != null ? _c : "base";
|
|
2236
2236
|
if (role !== "base") continue;
|
|
2237
2237
|
const sid = o.service_id;
|
|
@@ -2284,7 +2284,7 @@ function validateRates(v) {
|
|
|
2284
2284
|
|
|
2285
2285
|
// src/core/rate-coherence.ts
|
|
2286
2286
|
function buildTriggerEffectMap(props) {
|
|
2287
|
-
var
|
|
2287
|
+
var _a, _b;
|
|
2288
2288
|
const map = /* @__PURE__ */ new Map();
|
|
2289
2289
|
const ensure = (key) => {
|
|
2290
2290
|
let item = map.get(key);
|
|
@@ -2294,7 +2294,7 @@ function buildTriggerEffectMap(props) {
|
|
|
2294
2294
|
}
|
|
2295
2295
|
return item;
|
|
2296
2296
|
};
|
|
2297
|
-
for (const [key, ids] of Object.entries((
|
|
2297
|
+
for (const [key, ids] of Object.entries((_a = props.includes_for_buttons) != null ? _a : {})) {
|
|
2298
2298
|
const item = ensure(key);
|
|
2299
2299
|
for (const id of ids != null ? ids : []) item.includes.add(id);
|
|
2300
2300
|
}
|
|
@@ -2334,7 +2334,7 @@ function getRate(serviceMap, serviceId) {
|
|
|
2334
2334
|
return rate;
|
|
2335
2335
|
}
|
|
2336
2336
|
function collectContextRefs(tag, visibleFields, serviceMap) {
|
|
2337
|
-
var
|
|
2337
|
+
var _a, _b, _c, _d, _e;
|
|
2338
2338
|
const serviceRefs = [];
|
|
2339
2339
|
let tagDefault;
|
|
2340
2340
|
if (tag.service_id !== void 0 && tag.service_id !== null) {
|
|
@@ -2346,7 +2346,7 @@ function collectContextRefs(tag, visibleFields, serviceMap) {
|
|
|
2346
2346
|
nodeKind: "tag",
|
|
2347
2347
|
serviceId: tag.service_id,
|
|
2348
2348
|
rate: tagRate,
|
|
2349
|
-
label: (
|
|
2349
|
+
label: (_a = tag.label) != null ? _a : tag.id,
|
|
2350
2350
|
pricingRole: "base"
|
|
2351
2351
|
};
|
|
2352
2352
|
}
|
|
@@ -2623,7 +2623,7 @@ function constraintKeysInChain(v, tagId) {
|
|
|
2623
2623
|
return keys;
|
|
2624
2624
|
}
|
|
2625
2625
|
function effectiveConstraints(v, tagId) {
|
|
2626
|
-
var
|
|
2626
|
+
var _a;
|
|
2627
2627
|
const out = {};
|
|
2628
2628
|
const keys = constraintKeysInChain(v, tagId);
|
|
2629
2629
|
for (const key of keys) {
|
|
@@ -2632,7 +2632,7 @@ function effectiveConstraints(v, tagId) {
|
|
|
2632
2632
|
while (cur && !seen.has(cur)) {
|
|
2633
2633
|
seen.add(cur);
|
|
2634
2634
|
const t = v.tagById.get(cur);
|
|
2635
|
-
const val = (
|
|
2635
|
+
const val = (_a = t == null ? void 0 : t.constraints) == null ? void 0 : _a[key];
|
|
2636
2636
|
if (val === true || val === false) {
|
|
2637
2637
|
out[key] = val;
|
|
2638
2638
|
break;
|
|
@@ -2643,7 +2643,7 @@ function effectiveConstraints(v, tagId) {
|
|
|
2643
2643
|
return out;
|
|
2644
2644
|
}
|
|
2645
2645
|
function validateConstraints(v) {
|
|
2646
|
-
var
|
|
2646
|
+
var _a, _b;
|
|
2647
2647
|
for (const t of v.tags) {
|
|
2648
2648
|
const eff = effectiveConstraints(v, t.id);
|
|
2649
2649
|
const hasAnyRequired = Object.values(eff).some(
|
|
@@ -2652,7 +2652,7 @@ function validateConstraints(v) {
|
|
|
2652
2652
|
if (!hasAnyRequired) continue;
|
|
2653
2653
|
const visible = v.fieldsVisibleUnder(t.id);
|
|
2654
2654
|
for (const f of visible) {
|
|
2655
|
-
for (const o of (
|
|
2655
|
+
for (const o of (_a = f.options) != null ? _a : []) {
|
|
2656
2656
|
if (!isServiceIdRef(o.service_id)) continue;
|
|
2657
2657
|
const svc = getServiceCapability(v.serviceMap, o.service_id);
|
|
2658
2658
|
if (!svc || typeof svc !== "object") continue;
|
|
@@ -2740,12 +2740,12 @@ function validateCustomFields(v) {
|
|
|
2740
2740
|
|
|
2741
2741
|
// src/core/validate/steps/global-utility-guard.ts
|
|
2742
2742
|
function validateGlobalUtilityGuard(v) {
|
|
2743
|
-
var
|
|
2743
|
+
var _a, _b, _c;
|
|
2744
2744
|
if (!v.options.globalUtilityGuard) return;
|
|
2745
2745
|
let hasUtility = false;
|
|
2746
2746
|
let hasBase = false;
|
|
2747
2747
|
for (const f of v.fields) {
|
|
2748
|
-
for (const o of (
|
|
2748
|
+
for (const o of (_a = f.options) != null ? _a : []) {
|
|
2749
2749
|
if (!isServiceIdRef(o.service_id)) continue;
|
|
2750
2750
|
const role = (_c = (_b = o.pricing_role) != null ? _b : f.pricing_role) != null ? _c : "base";
|
|
2751
2751
|
if (role === "base") hasBase = true;
|
|
@@ -2767,14 +2767,14 @@ function validateGlobalUtilityGuard(v) {
|
|
|
2767
2767
|
|
|
2768
2768
|
// src/core/validate/steps/unbound.ts
|
|
2769
2769
|
function validateUnboundFields(v) {
|
|
2770
|
-
var
|
|
2770
|
+
var _a, _b;
|
|
2771
2771
|
const boundFieldIds = /* @__PURE__ */ new Set();
|
|
2772
2772
|
for (const f of v.fields) {
|
|
2773
2773
|
if (f.bind_id) boundFieldIds.add(f.id);
|
|
2774
2774
|
}
|
|
2775
2775
|
const includedByTag = /* @__PURE__ */ new Set();
|
|
2776
2776
|
for (const t of v.tags) {
|
|
2777
|
-
for (const id of (
|
|
2777
|
+
for (const id of (_a = t.includes) != null ? _a : []) includedByTag.add(id);
|
|
2778
2778
|
}
|
|
2779
2779
|
const includedByOption = /* @__PURE__ */ new Set();
|
|
2780
2780
|
for (const arr of Object.values((_b = v.props.includes_for_buttons) != null ? _b : {})) {
|
|
@@ -2843,8 +2843,8 @@ function messageFor(code, d) {
|
|
|
2843
2843
|
}
|
|
2844
2844
|
}
|
|
2845
2845
|
function validateFallbacks(v) {
|
|
2846
|
-
var
|
|
2847
|
-
const mode = (_b = (
|
|
2846
|
+
var _a, _b, _c, _d;
|
|
2847
|
+
const mode = (_b = (_a = v.options.fallbackSettings) == null ? void 0 : _a.mode) != null ? _b : "strict";
|
|
2848
2848
|
if (!v.props.fallbacks) return;
|
|
2849
2849
|
const diags = collectFailedFallbacks(v.props, (_c = v.options.serviceMap) != null ? _c : {}, {
|
|
2850
2850
|
...v.options.fallbackSettings,
|
|
@@ -2905,7 +2905,7 @@ function svcSnapshot(serviceMap, sid) {
|
|
|
2905
2905
|
};
|
|
2906
2906
|
}
|
|
2907
2907
|
function pushItem(out, next) {
|
|
2908
|
-
var
|
|
2908
|
+
var _a;
|
|
2909
2909
|
const key = `${String(next.serviceId)}|${next.role}`;
|
|
2910
2910
|
const existing = out.get(key);
|
|
2911
2911
|
if (!existing) {
|
|
@@ -2926,13 +2926,13 @@ function pushItem(out, next) {
|
|
|
2926
2926
|
);
|
|
2927
2927
|
out.set(key, {
|
|
2928
2928
|
...existing,
|
|
2929
|
-
tagId: (
|
|
2929
|
+
tagId: (_a = existing.tagId) != null ? _a : next.tagId,
|
|
2930
2930
|
affectedIds: mergedIds
|
|
2931
2931
|
});
|
|
2932
2932
|
}
|
|
2933
2933
|
function fieldRoleOf(f, o) {
|
|
2934
|
-
var
|
|
2935
|
-
const roleRaw = (_b = (
|
|
2934
|
+
var _a, _b;
|
|
2935
|
+
const roleRaw = (_b = (_a = o == null ? void 0 : o.pricing_role) != null ? _a : f.pricing_role) != null ? _b : "base";
|
|
2936
2936
|
return roleRaw === "utility" ? "utility" : "base";
|
|
2937
2937
|
}
|
|
2938
2938
|
function applyFilterAllowLists(tagId, fieldId, filter) {
|
|
@@ -2949,9 +2949,9 @@ function applyFilterAllowLists(tagId, fieldId, filter) {
|
|
|
2949
2949
|
return true;
|
|
2950
2950
|
}
|
|
2951
2951
|
function collectServiceItems(args) {
|
|
2952
|
-
var
|
|
2952
|
+
var _a, _b, _c, _d, _e;
|
|
2953
2953
|
const filter = args.filter;
|
|
2954
|
-
const roleFilter = (
|
|
2954
|
+
const roleFilter = (_a = filter == null ? void 0 : filter.role) != null ? _a : "both";
|
|
2955
2955
|
const where = filter == null ? void 0 : filter.where;
|
|
2956
2956
|
const out = /* @__PURE__ */ new Map();
|
|
2957
2957
|
const addServiceRef = (ref) => {
|
|
@@ -3156,26 +3156,26 @@ function defaultPolicyMessage(rule) {
|
|
|
3156
3156
|
return `Policy "${rule.id}" violated`;
|
|
3157
3157
|
}
|
|
3158
3158
|
function affectedFromItems(items) {
|
|
3159
|
-
var
|
|
3159
|
+
var _a;
|
|
3160
3160
|
const ids = [];
|
|
3161
3161
|
for (const it of items) {
|
|
3162
|
-
for (const x of (
|
|
3162
|
+
for (const x of (_a = it.affectedIds) != null ? _a : []) ids.push(x);
|
|
3163
3163
|
ids.push(`service:${String(it.serviceId)}`);
|
|
3164
3164
|
}
|
|
3165
3165
|
return uniq(ids);
|
|
3166
3166
|
}
|
|
3167
3167
|
function visibleGroupNodeIds(tag, fields) {
|
|
3168
|
-
var
|
|
3168
|
+
var _a;
|
|
3169
3169
|
const ids = [tag.id];
|
|
3170
3170
|
for (const f of fields) {
|
|
3171
|
-
for (const o of (
|
|
3171
|
+
for (const o of (_a = f.options) != null ? _a : []) {
|
|
3172
3172
|
ids.push(o.id);
|
|
3173
3173
|
}
|
|
3174
3174
|
}
|
|
3175
3175
|
return uniq(ids);
|
|
3176
3176
|
}
|
|
3177
3177
|
function visibleGroupPrimaries(tag, fields) {
|
|
3178
|
-
var
|
|
3178
|
+
var _a;
|
|
3179
3179
|
const prim = [];
|
|
3180
3180
|
const tagSid = tag.service_id;
|
|
3181
3181
|
if (typeof tagSid === "string" || typeof tagSid === "number" && Number.isFinite(tagSid)) {
|
|
@@ -3186,7 +3186,7 @@ function visibleGroupPrimaries(tag, fields) {
|
|
|
3186
3186
|
if (typeof fsid === "string" || typeof fsid === "number" && Number.isFinite(fsid)) {
|
|
3187
3187
|
prim.push(fsid);
|
|
3188
3188
|
}
|
|
3189
|
-
for (const o of (
|
|
3189
|
+
for (const o of (_a = f.options) != null ? _a : []) {
|
|
3190
3190
|
const osid = o.service_id;
|
|
3191
3191
|
if (typeof osid === "string" || typeof osid === "number" && Number.isFinite(osid)) {
|
|
3192
3192
|
prim.push(osid);
|
|
@@ -3196,12 +3196,12 @@ function visibleGroupPrimaries(tag, fields) {
|
|
|
3196
3196
|
return uniq(prim);
|
|
3197
3197
|
}
|
|
3198
3198
|
function applyPolicies(errors, props, serviceMap, policies, fieldsVisibleUnder, tags) {
|
|
3199
|
-
var
|
|
3199
|
+
var _a, _b, _c, _d, _e;
|
|
3200
3200
|
if (!(policies == null ? void 0 : policies.length)) return;
|
|
3201
3201
|
const tagById = /* @__PURE__ */ new Map();
|
|
3202
3202
|
for (const t of tags) tagById.set(t.id, t);
|
|
3203
3203
|
for (const rule of policies) {
|
|
3204
|
-
const projPath = (
|
|
3204
|
+
const projPath = (_a = rule.projection) != null ? _a : "service.id";
|
|
3205
3205
|
const severity = stableSeverity(
|
|
3206
3206
|
rule.severity
|
|
3207
3207
|
);
|
|
@@ -3335,16 +3335,16 @@ function resolveGlobalRatePolicy(options) {
|
|
|
3335
3335
|
return normalizeRatePolicy(options.ratePolicy);
|
|
3336
3336
|
}
|
|
3337
3337
|
function resolveFallbackSettings(options) {
|
|
3338
|
-
var
|
|
3338
|
+
var _a;
|
|
3339
3339
|
return {
|
|
3340
3340
|
...DEFAULT_FALLBACK_SETTINGS,
|
|
3341
|
-
...(
|
|
3341
|
+
...(_a = options.fallbackSettings) != null ? _a : {}
|
|
3342
3342
|
};
|
|
3343
3343
|
}
|
|
3344
3344
|
function mergeValidatorOptions(defaults = {}, overrides = {}) {
|
|
3345
|
-
var
|
|
3345
|
+
var _a, _b, _c, _d;
|
|
3346
3346
|
const mergedFallbackSettings = {
|
|
3347
|
-
...(
|
|
3347
|
+
...(_a = defaults.fallbackSettings) != null ? _a : {},
|
|
3348
3348
|
...(_b = overrides.fallbackSettings) != null ? _b : {}
|
|
3349
3349
|
};
|
|
3350
3350
|
return {
|
|
@@ -3373,12 +3373,12 @@ function readVisibilitySimOpts(ctx) {
|
|
|
3373
3373
|
};
|
|
3374
3374
|
}
|
|
3375
3375
|
function validate(props, ctx = {}) {
|
|
3376
|
-
var
|
|
3376
|
+
var _a, _b, _c;
|
|
3377
3377
|
const options = mergeValidatorOptions({}, ctx);
|
|
3378
3378
|
const fallbackSettings = resolveFallbackSettings(options);
|
|
3379
3379
|
const ratePolicy = resolveGlobalRatePolicy(options);
|
|
3380
3380
|
const errors = [];
|
|
3381
|
-
const serviceMap = (
|
|
3381
|
+
const serviceMap = (_a = options.serviceMap) != null ? _a : {};
|
|
3382
3382
|
const selectedKeys = new Set(
|
|
3383
3383
|
(_b = options.selectedOptionKeys) != null ? _b : []
|
|
3384
3384
|
);
|
|
@@ -3477,16 +3477,16 @@ var BuilderImpl = class {
|
|
|
3477
3477
|
this.options = { ...this.options, ...patch };
|
|
3478
3478
|
}
|
|
3479
3479
|
getServiceMap() {
|
|
3480
|
-
var
|
|
3481
|
-
return (
|
|
3480
|
+
var _a;
|
|
3481
|
+
return (_a = this.options.serviceMap) != null ? _a : {};
|
|
3482
3482
|
}
|
|
3483
3483
|
getConstraints() {
|
|
3484
|
-
var
|
|
3484
|
+
var _a;
|
|
3485
3485
|
const serviceMap = this.getServiceMap();
|
|
3486
3486
|
const out = /* @__PURE__ */ new Set();
|
|
3487
3487
|
const guard = /* @__PURE__ */ new Set();
|
|
3488
3488
|
for (const svc of Object.values(serviceMap)) {
|
|
3489
|
-
const flags = (
|
|
3489
|
+
const flags = (_a = svc.flags) != null ? _a : {};
|
|
3490
3490
|
for (const flagId of Object.keys(flags)) {
|
|
3491
3491
|
if (guard.has(flagId)) continue;
|
|
3492
3492
|
guard.add(flagId);
|
|
@@ -3502,7 +3502,7 @@ var BuilderImpl = class {
|
|
|
3502
3502
|
}
|
|
3503
3503
|
/* ───── querying ─────────────────────────────────────────────────────── */
|
|
3504
3504
|
tree() {
|
|
3505
|
-
var
|
|
3505
|
+
var _a, _b, _c, _d;
|
|
3506
3506
|
const nodes = [];
|
|
3507
3507
|
const edges = [];
|
|
3508
3508
|
const showSet = toStringSet(this.options.showOptionNodes);
|
|
@@ -3559,7 +3559,7 @@ var BuilderImpl = class {
|
|
|
3559
3559
|
}
|
|
3560
3560
|
}
|
|
3561
3561
|
for (const t of this.props.filters) {
|
|
3562
|
-
for (const id of (
|
|
3562
|
+
for (const id of (_a = t.includes) != null ? _a : []) {
|
|
3563
3563
|
edges.push({ from: t.id, to: id, kind: "include" });
|
|
3564
3564
|
}
|
|
3565
3565
|
for (const id of (_b = t.excludes) != null ? _b : []) {
|
|
@@ -3569,9 +3569,9 @@ var BuilderImpl = class {
|
|
|
3569
3569
|
const incMap = (_c = this.props.includes_for_buttons) != null ? _c : {};
|
|
3570
3570
|
const excMap = (_d = this.props.excludes_for_buttons) != null ? _d : {};
|
|
3571
3571
|
const pushButtonEdge = (keyId, targetFieldId, kind) => {
|
|
3572
|
-
var
|
|
3572
|
+
var _a2;
|
|
3573
3573
|
const owner = this.optionOwnerById.get(keyId);
|
|
3574
|
-
const ownerFieldId = (
|
|
3574
|
+
const ownerFieldId = (_a2 = owner == null ? void 0 : owner.fieldId) != null ? _a2 : this.fieldById.has(keyId) ? keyId : void 0;
|
|
3575
3575
|
if (!ownerFieldId) return;
|
|
3576
3576
|
const fromNode = owner && showSet.has(owner.fieldId) ? keyId : ownerFieldId;
|
|
3577
3577
|
const meta = owner ? showSet.has(owner.fieldId) ? {
|
|
@@ -3597,14 +3597,14 @@ var BuilderImpl = class {
|
|
|
3597
3597
|
return { nodes, edges };
|
|
3598
3598
|
}
|
|
3599
3599
|
cleanedProps() {
|
|
3600
|
-
var
|
|
3600
|
+
var _a, _b, _c, _d, _e;
|
|
3601
3601
|
const fieldIds = new Set(this.props.fields.map((f) => f.id));
|
|
3602
3602
|
const optionIds = /* @__PURE__ */ new Set();
|
|
3603
3603
|
this.optionOwnerById.forEach((_v, oid) => optionIds.add(oid));
|
|
3604
3604
|
const includedByTag = /* @__PURE__ */ new Set();
|
|
3605
3605
|
const excludedAnywhere = /* @__PURE__ */ new Set();
|
|
3606
3606
|
for (const t of this.props.filters) {
|
|
3607
|
-
for (const id of (
|
|
3607
|
+
for (const id of (_a = t.includes) != null ? _a : []) includedByTag.add(id);
|
|
3608
3608
|
for (const id of (_b = t.excludes) != null ? _b : []) excludedAnywhere.add(id);
|
|
3609
3609
|
}
|
|
3610
3610
|
const incMap = (_c = this.props.includes_for_buttons) != null ? _c : {};
|
|
@@ -3635,8 +3635,8 @@ var BuilderImpl = class {
|
|
|
3635
3635
|
else if (typeof b === "string") boundIds.add(b);
|
|
3636
3636
|
}
|
|
3637
3637
|
const fields = this.props.fields.filter((f) => {
|
|
3638
|
-
var
|
|
3639
|
-
const isUtility = ((
|
|
3638
|
+
var _a2;
|
|
3639
|
+
const isUtility = ((_a2 = f.pricing_role) != null ? _a2 : "base") === "utility";
|
|
3640
3640
|
if (!isUtility) return true;
|
|
3641
3641
|
const bound = !!f.bind_id;
|
|
3642
3642
|
const included = includedByTag.has(f.id) || includedByButtons.has(f.id);
|
|
@@ -3683,10 +3683,10 @@ var BuilderImpl = class {
|
|
|
3683
3683
|
return (0, import_lodash_es2.cloneDeep)(this.options);
|
|
3684
3684
|
}
|
|
3685
3685
|
visibleFields(tagId, selectedKeys) {
|
|
3686
|
-
var
|
|
3686
|
+
var _a;
|
|
3687
3687
|
return visibleFieldIdsUnder(this.props, tagId, {
|
|
3688
3688
|
selectedKeys: new Set(
|
|
3689
|
-
(
|
|
3689
|
+
(_a = selectedKeys != null ? selectedKeys : this.options.selectedOptionKeys) != null ? _a : []
|
|
3690
3690
|
)
|
|
3691
3691
|
});
|
|
3692
3692
|
}
|
|
@@ -3724,10 +3724,10 @@ var DEFAULT_SETTINGS = {
|
|
|
3724
3724
|
mode: "strict"
|
|
3725
3725
|
};
|
|
3726
3726
|
function collectFailedFallbacks(props, services, settings) {
|
|
3727
|
-
var
|
|
3727
|
+
var _a, _b, _c;
|
|
3728
3728
|
const s = { ...DEFAULT_SETTINGS, ...settings != null ? settings : {} };
|
|
3729
3729
|
const out = [];
|
|
3730
|
-
const fb = (
|
|
3730
|
+
const fb = (_a = props.fallbacks) != null ? _a : {};
|
|
3731
3731
|
const primaryRate = (primary) => rateOf(services, primary);
|
|
3732
3732
|
for (const [nodeId, list] of Object.entries((_b = fb.nodes) != null ? _b : {})) {
|
|
3733
3733
|
const { primary, tagContexts } = primaryForNode(props, nodeId);
|
|
@@ -3835,9 +3835,9 @@ function collectFailedFallbacks(props, services, settings) {
|
|
|
3835
3835
|
return out;
|
|
3836
3836
|
}
|
|
3837
3837
|
function rateOf(map, id) {
|
|
3838
|
-
var
|
|
3838
|
+
var _a, _b;
|
|
3839
3839
|
if (id === void 0 || id === null) return void 0;
|
|
3840
|
-
return (_b = (
|
|
3840
|
+
return (_b = (_a = getCap(map, id)) == null ? void 0 : _a.rate) != null ? _b : void 0;
|
|
3841
3841
|
}
|
|
3842
3842
|
function passesRate(policy, primaryRate, candidateRate) {
|
|
3843
3843
|
if (typeof candidateRate !== "number" || !Number.isFinite(candidateRate)) {
|
|
@@ -3856,8 +3856,8 @@ function getCap(map, id) {
|
|
|
3856
3856
|
return getServiceCapability(map, id);
|
|
3857
3857
|
}
|
|
3858
3858
|
function isCapFlagEnabled(capability, flagId) {
|
|
3859
|
-
var
|
|
3860
|
-
const fromFlags = (_b = (
|
|
3859
|
+
var _a, _b;
|
|
3860
|
+
const fromFlags = (_b = (_a = capability.flags) == null ? void 0 : _a[flagId]) == null ? void 0 : _b.enabled;
|
|
3861
3861
|
if (fromFlags === true) return true;
|
|
3862
3862
|
if (fromFlags === false) return false;
|
|
3863
3863
|
const legacy = capability[flagId];
|
|
@@ -3896,8 +3896,8 @@ function bindIdsToArray(bind) {
|
|
|
3896
3896
|
return Array.isArray(bind) ? bind.slice() : [bind];
|
|
3897
3897
|
}
|
|
3898
3898
|
function getEligibleFallbacks(params) {
|
|
3899
|
-
var
|
|
3900
|
-
const s = { ...DEFAULT_SETTINGS, ...(
|
|
3899
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3900
|
+
const s = { ...DEFAULT_SETTINGS, ...(_a = params.settings) != null ? _a : {} };
|
|
3901
3901
|
const { primary, nodeId, tagId, services } = params;
|
|
3902
3902
|
const excludes = /* @__PURE__ */ new Set();
|
|
3903
3903
|
for (const ref of (_b = params.exclude) != null ? _b : []) {
|
|
@@ -3943,8 +3943,8 @@ function getEligibleFallbacks(params) {
|
|
|
3943
3943
|
}
|
|
3944
3944
|
if (s.selectionStrategy === "cheapest") {
|
|
3945
3945
|
eligible.sort((left, right) => {
|
|
3946
|
-
var
|
|
3947
|
-
const leftRate = (
|
|
3946
|
+
var _a2, _b2;
|
|
3947
|
+
const leftRate = (_a2 = rateOf(services, left)) != null ? _a2 : Infinity;
|
|
3948
3948
|
const rightRate = (_b2 = rateOf(services, right)) != null ? _b2 : Infinity;
|
|
3949
3949
|
return leftRate - rightRate;
|
|
3950
3950
|
});
|
|
@@ -3955,7 +3955,7 @@ function getEligibleFallbacks(params) {
|
|
|
3955
3955
|
return eligible;
|
|
3956
3956
|
}
|
|
3957
3957
|
function getAssignedServiceIds(params) {
|
|
3958
|
-
var
|
|
3958
|
+
var _a, _b, _c, _d, _e;
|
|
3959
3959
|
const seen = /* @__PURE__ */ new Set();
|
|
3960
3960
|
const out = [];
|
|
3961
3961
|
const push = (value) => {
|
|
@@ -3967,7 +3967,7 @@ function getAssignedServiceIds(params) {
|
|
|
3967
3967
|
};
|
|
3968
3968
|
const props = params.props;
|
|
3969
3969
|
if (props) {
|
|
3970
|
-
for (const tag of (
|
|
3970
|
+
for (const tag of (_a = props.filters) != null ? _a : []) {
|
|
3971
3971
|
push(tag.service_id);
|
|
3972
3972
|
}
|
|
3973
3973
|
for (const field of (_b = props.fields) != null ? _b : []) {
|
|
@@ -3999,9 +3999,9 @@ function getFallbackRegistrationInfo(props, nodeId) {
|
|
|
3999
3999
|
return { primary, tagContexts };
|
|
4000
4000
|
}
|
|
4001
4001
|
function listRegisteredFallbackCandidates(fallbacks, primary, nodeId, services) {
|
|
4002
|
-
var
|
|
4002
|
+
var _a, _b;
|
|
4003
4003
|
const lists = [];
|
|
4004
|
-
if (nodeId && ((
|
|
4004
|
+
if (nodeId && ((_a = fallbacks.nodes) == null ? void 0 : _a[nodeId])) {
|
|
4005
4005
|
lists.push(fallbacks.nodes[nodeId]);
|
|
4006
4006
|
}
|
|
4007
4007
|
for (const [registeredPrimary, list] of Object.entries((_b = fallbacks.global) != null ? _b : {})) {
|
|
@@ -4024,8 +4024,8 @@ function listServicePoolCandidates(services) {
|
|
|
4024
4024
|
return out;
|
|
4025
4025
|
}
|
|
4026
4026
|
function getServicePoolCandidateId(key, capability) {
|
|
4027
|
-
var
|
|
4028
|
-
return (
|
|
4027
|
+
var _a;
|
|
4028
|
+
return (_a = getServiceCapabilityCanonicalRef({ [key]: capability }, key)) != null ? _a : key;
|
|
4029
4029
|
}
|
|
4030
4030
|
function addComparableServiceRef(target, services, value) {
|
|
4031
4031
|
for (const ref of getComparableServiceRefs(services, value)) {
|
|
@@ -4060,10 +4060,10 @@ var toBindList = (b) => {
|
|
|
4060
4060
|
return typeof b === "string" ? [b] : [...b];
|
|
4061
4061
|
};
|
|
4062
4062
|
function createNodeIndex(builder) {
|
|
4063
|
-
var
|
|
4063
|
+
var _a, _b, _c, _d;
|
|
4064
4064
|
const props = builder.getProps();
|
|
4065
4065
|
const nodeMap = builder.getNodeMap();
|
|
4066
|
-
const tags = (
|
|
4066
|
+
const tags = (_a = props.filters) != null ? _a : [];
|
|
4067
4067
|
const fields = (_b = props.fields) != null ? _b : [];
|
|
4068
4068
|
const tagById = new Map(tags.map((t) => [t.id, t]));
|
|
4069
4069
|
const fieldById = new Map(fields.map((f) => [f.id, f]));
|
|
@@ -4206,12 +4206,12 @@ function createNodeIndex(builder) {
|
|
|
4206
4206
|
}
|
|
4207
4207
|
});
|
|
4208
4208
|
const getTag = (id) => {
|
|
4209
|
-
var
|
|
4209
|
+
var _a2, _b2;
|
|
4210
4210
|
const cached = tagNodeCache.get(id);
|
|
4211
4211
|
if (cached) return cached;
|
|
4212
4212
|
const raw = tagById.get(id);
|
|
4213
4213
|
if (!raw) return void 0;
|
|
4214
|
-
const includes = Object.freeze(new Set((
|
|
4214
|
+
const includes = Object.freeze(new Set((_a2 = raw.includes) != null ? _a2 : []));
|
|
4215
4215
|
const excludes = Object.freeze(new Set((_b2 = raw.excludes) != null ? _b2 : []));
|
|
4216
4216
|
const ancestryFn = makeAncestry([id]);
|
|
4217
4217
|
const node = {
|
|
@@ -4226,17 +4226,17 @@ function createNodeIndex(builder) {
|
|
|
4226
4226
|
return pid ? getTag(pid) : void 0;
|
|
4227
4227
|
},
|
|
4228
4228
|
children() {
|
|
4229
|
-
var
|
|
4229
|
+
var _a3;
|
|
4230
4230
|
const cachedChildren = tagChildrenCache.get(id);
|
|
4231
4231
|
if (cachedChildren) return cachedChildren;
|
|
4232
|
-
const childIds = (
|
|
4232
|
+
const childIds = (_a3 = childrenById.get(id)) != null ? _a3 : [];
|
|
4233
4233
|
const arr = childIds.map((cid) => getTag(cid)).filter(Boolean);
|
|
4234
4234
|
const frozen = Object.freeze(arr);
|
|
4235
4235
|
tagChildrenCache.set(id, frozen);
|
|
4236
4236
|
return frozen;
|
|
4237
4237
|
},
|
|
4238
4238
|
ancestors() {
|
|
4239
|
-
var
|
|
4239
|
+
var _a3;
|
|
4240
4240
|
const cachedAnc = tagAncestorsCache.get(id);
|
|
4241
4241
|
if (cachedAnc) return cachedAnc;
|
|
4242
4242
|
const rows = [];
|
|
@@ -4246,7 +4246,7 @@ function createNodeIndex(builder) {
|
|
|
4246
4246
|
while (cur && !guard.has(cur)) {
|
|
4247
4247
|
const n = getTag(cur);
|
|
4248
4248
|
if (!n) break;
|
|
4249
|
-
const p = (
|
|
4249
|
+
const p = (_a3 = pathBetween(id, cur)) != null ? _a3 : [id, cur];
|
|
4250
4250
|
rows.push({ node: n, direct: index === 1, index, path: p });
|
|
4251
4251
|
guard.add(cur);
|
|
4252
4252
|
cur = parentById.get(cur);
|
|
@@ -4289,13 +4289,13 @@ function createNodeIndex(builder) {
|
|
|
4289
4289
|
return node;
|
|
4290
4290
|
};
|
|
4291
4291
|
const getField = (id) => {
|
|
4292
|
-
var
|
|
4292
|
+
var _a2, _b2, _c2, _d2;
|
|
4293
4293
|
const cached = fieldNodeCache.get(id);
|
|
4294
4294
|
if (cached) return cached;
|
|
4295
4295
|
const raw = fieldById.get(id);
|
|
4296
4296
|
if (!raw) return void 0;
|
|
4297
4297
|
const isButton = raw.button === true;
|
|
4298
|
-
const includes = isButton ? Object.freeze(new Set((_b2 = (
|
|
4298
|
+
const includes = isButton ? Object.freeze(new Set((_b2 = (_a2 = props.includes_for_buttons) == null ? void 0 : _a2[id]) != null ? _b2 : [])) : emptySet;
|
|
4299
4299
|
const excludes = isButton ? Object.freeze(new Set((_d2 = (_c2 = props.excludes_for_buttons) == null ? void 0 : _c2[id]) != null ? _d2 : [])) : emptySet;
|
|
4300
4300
|
const bindIds = () => {
|
|
4301
4301
|
const cachedBind = fieldBindIdsCache.get(id);
|
|
@@ -4341,7 +4341,7 @@ function createNodeIndex(builder) {
|
|
|
4341
4341
|
return node;
|
|
4342
4342
|
};
|
|
4343
4343
|
const getOption = (id) => {
|
|
4344
|
-
var
|
|
4344
|
+
var _a2, _b2, _c2, _d2;
|
|
4345
4345
|
const cached = optionNodeCache.get(id);
|
|
4346
4346
|
if (cached) return cached;
|
|
4347
4347
|
const raw = optionById.get(id);
|
|
@@ -4350,7 +4350,7 @@ function createNodeIndex(builder) {
|
|
|
4350
4350
|
const owner = getField(ownerFieldId);
|
|
4351
4351
|
if (!owner) return void 0;
|
|
4352
4352
|
const includes = Object.freeze(
|
|
4353
|
-
new Set((_b2 = (
|
|
4353
|
+
new Set((_b2 = (_a2 = props.includes_for_buttons) == null ? void 0 : _a2[id]) != null ? _b2 : [])
|
|
4354
4354
|
);
|
|
4355
4355
|
const excludes = Object.freeze(
|
|
4356
4356
|
new Set((_d2 = (_c2 = props.excludes_for_buttons) == null ? void 0 : _c2[id]) != null ? _d2 : [])
|
|
@@ -4385,13 +4385,13 @@ function createNodeIndex(builder) {
|
|
|
4385
4385
|
return node;
|
|
4386
4386
|
};
|
|
4387
4387
|
const getNode2 = (input) => {
|
|
4388
|
-
var
|
|
4388
|
+
var _a2, _b2, _c2;
|
|
4389
4389
|
const id = typeof input === "object" ? input.id : input;
|
|
4390
4390
|
const cached = nodeCache.get(id);
|
|
4391
4391
|
if (cached) return cached;
|
|
4392
4392
|
const node = nodeMap.get(id);
|
|
4393
4393
|
if (!node) return mkUnknown(id);
|
|
4394
|
-
if (node.kind === "tag") return (
|
|
4394
|
+
if (node.kind === "tag") return (_a2 = getTag(id)) != null ? _a2 : mkUnknown(id);
|
|
4395
4395
|
if (node.kind == "field") return (_b2 = getField(id)) != null ? _b2 : mkUnknown(id);
|
|
4396
4396
|
if (node.kind == "option") return (_c2 = getOption(id)) != null ? _c2 : mkUnknown(id);
|
|
4397
4397
|
return mkUnknown(id);
|
|
@@ -4670,8 +4670,8 @@ function compilePolicies(raw) {
|
|
|
4670
4670
|
|
|
4671
4671
|
// src/core/service-filter.ts
|
|
4672
4672
|
function filterServicesForVisibleGroup(input, deps) {
|
|
4673
|
-
var
|
|
4674
|
-
const svcMap = (_c = (_b = (
|
|
4673
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
4674
|
+
const svcMap = (_c = (_b = (_a = deps.builder).getServiceMap) == null ? void 0 : _b.call(_a)) != null ? _c : {};
|
|
4675
4675
|
const builderOptions = (_e = (_d = deps.builder).getOptions) == null ? void 0 : _e.call(_d);
|
|
4676
4676
|
const { context } = input;
|
|
4677
4677
|
const usedSet = new Set(context.usedServiceIds.map(String));
|
|
@@ -4780,7 +4780,7 @@ function evaluatePoliciesRaw(raw, serviceIds, svcMap, tagId, visibleServiceIds)
|
|
|
4780
4780
|
};
|
|
4781
4781
|
}
|
|
4782
4782
|
function evaluateServicePolicies(rules, svcIds, svcMap, tagId, visibleServiceIds) {
|
|
4783
|
-
var
|
|
4783
|
+
var _a, _b, _c;
|
|
4784
4784
|
const errors = [];
|
|
4785
4785
|
const warnings = [];
|
|
4786
4786
|
if (!rules || !rules.length) return { ok: true, errors, warnings };
|
|
@@ -4831,7 +4831,7 @@ function evaluateServicePolicies(rules, svcIds, svcMap, tagId, visibleServiceIds
|
|
|
4831
4831
|
ok = true;
|
|
4832
4832
|
}
|
|
4833
4833
|
if (!ok) {
|
|
4834
|
-
if (((
|
|
4834
|
+
if (((_a = r.severity) != null ? _a : "error") === "error") {
|
|
4835
4835
|
errors.push((_b = r.id) != null ? _b : "policy_error");
|
|
4836
4836
|
} else {
|
|
4837
4837
|
warnings.push((_c = r.id) != null ? _c : "policy_warning");
|
|
@@ -4845,10 +4845,10 @@ function scopeServiceIdsForRule(serviceIds, rule, visibleServiceIds) {
|
|
|
4845
4845
|
return serviceIds.filter((id) => visibleServiceIds.has(String(id)));
|
|
4846
4846
|
}
|
|
4847
4847
|
function collectVisibleServiceIds(builder, tagId, selectedButtons) {
|
|
4848
|
-
var
|
|
4848
|
+
var _a, _b, _c;
|
|
4849
4849
|
const out = /* @__PURE__ */ new Set();
|
|
4850
4850
|
const props = builder.getProps();
|
|
4851
|
-
const tags = (
|
|
4851
|
+
const tags = (_a = props.filters) != null ? _a : [];
|
|
4852
4852
|
const fields = (_b = props.fields) != null ? _b : [];
|
|
4853
4853
|
const tag = tags.find((t) => t.id === tagId);
|
|
4854
4854
|
if ((tag == null ? void 0 : tag.service_id) != null) out.add(String(tag.service_id));
|
|
@@ -4886,10 +4886,10 @@ function toStrSet(v) {
|
|
|
4886
4886
|
return s;
|
|
4887
4887
|
}
|
|
4888
4888
|
function candidatePassesRateCoherence(builder, serviceMap, tagId, selectedKeys, usedServiceIds, candidateId, ratePolicy) {
|
|
4889
|
-
var
|
|
4889
|
+
var _a, _b, _c, _d;
|
|
4890
4890
|
if (usedServiceIds.length === 0) return true;
|
|
4891
4891
|
const props = builder.getProps();
|
|
4892
|
-
const baseFields = (
|
|
4892
|
+
const baseFields = (_a = props.fields) != null ? _a : [];
|
|
4893
4893
|
const candidateFieldId = syntheticServiceFieldId("candidate", candidateId, 0);
|
|
4894
4894
|
const syntheticFields = [
|
|
4895
4895
|
...usedServiceIds.map((serviceId, index) => ({
|
|
@@ -4966,10 +4966,10 @@ function syntheticServiceFieldId(kind, serviceId, index) {
|
|
|
4966
4966
|
return `__service_filter_${kind}__:${index}:${String(serviceId)}`;
|
|
4967
4967
|
}
|
|
4968
4968
|
function rateIssueAffectsCandidate(error, candidateId, candidateFieldId, primaryAnchorId) {
|
|
4969
|
-
var
|
|
4969
|
+
var _a, _b, _c, _d;
|
|
4970
4970
|
if (error.code !== "rate_coherence_violation") return false;
|
|
4971
4971
|
const candidateKey = String(candidateId);
|
|
4972
|
-
const details = (
|
|
4972
|
+
const details = (_a = error.details) != null ? _a : {};
|
|
4973
4973
|
const anchorKey = primaryAnchorId == null ? void 0 : String(primaryAnchorId);
|
|
4974
4974
|
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;
|
|
4975
4975
|
if (primaryMatchesAnchor && ((_d = details.affectedServiceIds) == null ? void 0 : _d.some(
|
|
@@ -4989,7 +4989,7 @@ function rateIssueAffectsCandidate(error, candidateId, candidateFieldId, primary
|
|
|
4989
4989
|
|
|
4990
4990
|
// src/utils/prune-fallbacks.ts
|
|
4991
4991
|
function pruneInvalidNodeFallbacks(props, services, settings) {
|
|
4992
|
-
var
|
|
4992
|
+
var _a, _b;
|
|
4993
4993
|
const fb = props.fallbacks;
|
|
4994
4994
|
if (!(fb == null ? void 0 : fb.nodes) || Object.keys(fb.nodes).length === 0) {
|
|
4995
4995
|
return { props, removed: [] };
|
|
@@ -5034,7 +5034,7 @@ function pruneInvalidNodeFallbacks(props, services, settings) {
|
|
|
5034
5034
|
const prunedNodes = {};
|
|
5035
5035
|
const removed = [];
|
|
5036
5036
|
for (const [nodeId, list] of Object.entries(fb.nodes)) {
|
|
5037
|
-
const contexts = (
|
|
5037
|
+
const contexts = (_a = nodeContexts.get(nodeId)) != null ? _a : [];
|
|
5038
5038
|
const totalContexts = Math.max(1, contexts.length);
|
|
5039
5039
|
const keep = [];
|
|
5040
5040
|
for (const cand of list) {
|
|
@@ -5075,7 +5075,7 @@ function toBindArray(bind) {
|
|
|
5075
5075
|
|
|
5076
5076
|
// src/utils/build-order-snapshot/fallbacks.ts
|
|
5077
5077
|
function pruneFallbacksConservative(fallbacks, env, svcMap, policy) {
|
|
5078
|
-
var
|
|
5078
|
+
var _a, _b;
|
|
5079
5079
|
if (!fallbacks) return { pruned: void 0, original: void 0 };
|
|
5080
5080
|
try {
|
|
5081
5081
|
const { props: prunedProps } = pruneInvalidNodeFallbacks(
|
|
@@ -5094,7 +5094,7 @@ function pruneFallbacksConservative(fallbacks, env, svcMap, policy) {
|
|
|
5094
5094
|
};
|
|
5095
5095
|
} catch {
|
|
5096
5096
|
const out = {};
|
|
5097
|
-
const requireFit = (
|
|
5097
|
+
const requireFit = (_a = policy.requireConstraintFit) != null ? _a : true;
|
|
5098
5098
|
if (fallbacks.nodes) {
|
|
5099
5099
|
const keptNodes = {};
|
|
5100
5100
|
for (const [nodeId, candidates] of Object.entries(
|
|
@@ -5154,17 +5154,37 @@ function toSelectedOptionKeys(byField) {
|
|
|
5154
5154
|
}
|
|
5155
5155
|
return keys;
|
|
5156
5156
|
}
|
|
5157
|
-
function getSelectedOptionsByFieldId(selection, fieldById) {
|
|
5158
|
-
|
|
5157
|
+
function getSelectedOptionsByFieldId(selection, fieldById, mode) {
|
|
5158
|
+
var _a, _b;
|
|
5159
|
+
const collected = {};
|
|
5159
5160
|
for (const visit of buildSelectedNodeVisitOrder(selection, fieldById)) {
|
|
5160
5161
|
if (visit.kind !== "option") continue;
|
|
5161
|
-
if (!
|
|
5162
|
-
|
|
5162
|
+
if (!collected[visit.fieldId]) collected[visit.fieldId] = [];
|
|
5163
|
+
collected[visit.fieldId].push(visit.optionId);
|
|
5164
|
+
}
|
|
5165
|
+
const out = {};
|
|
5166
|
+
for (const [fieldId, optionIds] of Object.entries(collected)) {
|
|
5167
|
+
const field = fieldById.get(fieldId);
|
|
5168
|
+
if (!field) continue;
|
|
5169
|
+
const validOptionIds = new Set(
|
|
5170
|
+
((_a = field.options) != null ? _a : []).map((option) => option.id)
|
|
5171
|
+
);
|
|
5172
|
+
const dedupedValid = [];
|
|
5173
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5174
|
+
for (const optionId of optionIds) {
|
|
5175
|
+
if (!validOptionIds.has(optionId)) continue;
|
|
5176
|
+
if (seen.has(optionId)) continue;
|
|
5177
|
+
seen.add(optionId);
|
|
5178
|
+
dedupedValid.push(optionId);
|
|
5179
|
+
}
|
|
5180
|
+
const isMulti = ((_b = field.meta) == null ? void 0 : _b.multi) === true;
|
|
5181
|
+
const normalized = mode === "prod" && !isMulti ? dedupedValid.length ? [dedupedValid[dedupedValid.length - 1]] : [] : dedupedValid;
|
|
5182
|
+
if (normalized.length) out[fieldId] = normalized;
|
|
5163
5183
|
}
|
|
5164
5184
|
return out;
|
|
5165
5185
|
}
|
|
5166
5186
|
function buildSelectedNodeVisitOrder(selection, fieldById) {
|
|
5167
|
-
var
|
|
5187
|
+
var _a, _b, _c;
|
|
5168
5188
|
const out = [];
|
|
5169
5189
|
const seen = /* @__PURE__ */ new Set();
|
|
5170
5190
|
function pushField(fieldId) {
|
|
@@ -5179,7 +5199,7 @@ function buildSelectedNodeVisitOrder(selection, fieldById) {
|
|
|
5179
5199
|
seen.add(key);
|
|
5180
5200
|
out.push({ kind: "option", fieldId, optionId });
|
|
5181
5201
|
}
|
|
5182
|
-
for (const item of (
|
|
5202
|
+
for (const item of (_a = selection.optionTraversalOrder) != null ? _a : []) {
|
|
5183
5203
|
pushOption(item.fieldId, item.optionId);
|
|
5184
5204
|
}
|
|
5185
5205
|
for (const rawKey of (_b = selection.selectedKeys) != null ? _b : []) {
|
|
@@ -5208,23 +5228,23 @@ function buildSelectedNodeVisitOrder(selection, fieldById) {
|
|
|
5208
5228
|
return out;
|
|
5209
5229
|
}
|
|
5210
5230
|
function findOptionOwnerField(optionId, fieldById) {
|
|
5211
|
-
var
|
|
5231
|
+
var _a;
|
|
5212
5232
|
for (const field of fieldById.values()) {
|
|
5213
|
-
if ((
|
|
5233
|
+
if ((_a = field.options) == null ? void 0 : _a.some((option) => option.id === optionId)) return field;
|
|
5214
5234
|
}
|
|
5215
5235
|
return void 0;
|
|
5216
5236
|
}
|
|
5217
5237
|
|
|
5218
5238
|
// src/utils/build-order-snapshot/services.ts
|
|
5219
5239
|
function isServiceBased(field) {
|
|
5220
|
-
var
|
|
5240
|
+
var _a;
|
|
5221
5241
|
if (field.service_id !== void 0 && field.service_id !== null) return true;
|
|
5222
|
-
return !!((
|
|
5242
|
+
return !!((_a = field.options) == null ? void 0 : _a.some(
|
|
5223
5243
|
(item) => item.service_id !== void 0 && item.service_id !== null
|
|
5224
5244
|
));
|
|
5225
5245
|
}
|
|
5226
5246
|
function resolveServices(tagId, visibleFieldIds, selection, tagById, fieldById, services) {
|
|
5227
|
-
var
|
|
5247
|
+
var _a, _b, _c, _d;
|
|
5228
5248
|
const serviceMap = {};
|
|
5229
5249
|
const visible = new Set(visibleFieldIds);
|
|
5230
5250
|
const selectedBaseServices = [];
|
|
@@ -5244,7 +5264,7 @@ function resolveServices(tagId, visibleFieldIds, selection, tagById, fieldById,
|
|
|
5244
5264
|
const field = fieldById.get(visit.fieldId);
|
|
5245
5265
|
if (!field) continue;
|
|
5246
5266
|
if (visit.kind === "field") {
|
|
5247
|
-
const role2 = (
|
|
5267
|
+
const role2 = (_a = field.pricing_role) != null ? _a : "base";
|
|
5248
5268
|
if (role2 === "utility") continue;
|
|
5249
5269
|
if (field.service_id !== void 0 && field.service_id !== null) {
|
|
5250
5270
|
addSelectedBaseService(field.id, field.service_id);
|
|
@@ -5282,12 +5302,12 @@ function pickHighestRatePrimary2(services) {
|
|
|
5282
5302
|
return best;
|
|
5283
5303
|
}
|
|
5284
5304
|
function getCap2(map, id) {
|
|
5285
|
-
var
|
|
5286
|
-
return (
|
|
5305
|
+
var _a;
|
|
5306
|
+
return (_a = map == null ? void 0 : map[id]) != null ? _a : map == null ? void 0 : map[String(id)];
|
|
5287
5307
|
}
|
|
5288
5308
|
function readServiceRate(services, sid) {
|
|
5289
|
-
var
|
|
5290
|
-
const rate = Number((
|
|
5309
|
+
var _a;
|
|
5310
|
+
const rate = Number((_a = getCap2(services, sid)) == null ? void 0 : _a.rate);
|
|
5291
5311
|
return Number.isFinite(rate) ? rate : Number.NEGATIVE_INFINITY;
|
|
5292
5312
|
}
|
|
5293
5313
|
function pushService(map, nodeId, sid) {
|
|
@@ -5327,8 +5347,8 @@ function buildInputs(visibleFieldIds, fieldById, selection, selectedOptionsByFie
|
|
|
5327
5347
|
|
|
5328
5348
|
// src/utils/build-order-snapshot/min-max.ts
|
|
5329
5349
|
function getCap3(map, id) {
|
|
5330
|
-
var
|
|
5331
|
-
return (
|
|
5350
|
+
var _a;
|
|
5351
|
+
return (_a = map == null ? void 0 : map[id]) != null ? _a : map == null ? void 0 : map[String(id)];
|
|
5332
5352
|
}
|
|
5333
5353
|
function resolveMinMax(servicesList, services) {
|
|
5334
5354
|
let min;
|
|
@@ -5348,20 +5368,20 @@ function resolveMinMax(servicesList, services) {
|
|
|
5348
5368
|
|
|
5349
5369
|
// src/utils/build-order-snapshot/policy.ts
|
|
5350
5370
|
function toSnapshotPolicy(settings) {
|
|
5351
|
-
var
|
|
5371
|
+
var _a;
|
|
5352
5372
|
return {
|
|
5353
5373
|
ratePolicy: normalizeRatePolicy(settings.ratePolicy),
|
|
5354
|
-
requireConstraintFit: (
|
|
5374
|
+
requireConstraintFit: (_a = settings.requireConstraintFit) != null ? _a : true
|
|
5355
5375
|
};
|
|
5356
5376
|
}
|
|
5357
5377
|
|
|
5358
5378
|
// src/utils/build-order-snapshot/quantity.ts
|
|
5359
5379
|
function resolveQuantity(visibleFieldIds, fieldById, tagById, selection, tagId, hostDefault) {
|
|
5360
|
-
var
|
|
5380
|
+
var _a;
|
|
5361
5381
|
for (const fid of visibleFieldIds) {
|
|
5362
5382
|
const field = fieldById.get(fid);
|
|
5363
5383
|
if (!field) continue;
|
|
5364
|
-
const rule = readQuantityRule((
|
|
5384
|
+
const rule = readQuantityRule((_a = field.meta) == null ? void 0 : _a.quantity);
|
|
5365
5385
|
if (!rule) continue;
|
|
5366
5386
|
const raw = selection.formValuesByFieldId[fid];
|
|
5367
5387
|
const evaluated = evaluateQuantityRule(rule, raw);
|
|
@@ -5384,14 +5404,14 @@ function resolveQuantity(visibleFieldIds, fieldById, tagById, selection, tagId,
|
|
|
5384
5404
|
return { quantity: hostDefault, source: { kind: "default", defaultedFromHost: true } };
|
|
5385
5405
|
}
|
|
5386
5406
|
function resolveNodeDefaultQuantity(visibleFieldIds, fieldById, tagById, selection, tagId) {
|
|
5387
|
-
var
|
|
5407
|
+
var _a, _b, _c;
|
|
5388
5408
|
const visible = new Set(visibleFieldIds);
|
|
5389
5409
|
const visits = buildSelectedNodeVisitOrder(selection, fieldById);
|
|
5390
5410
|
for (const visit of visits) {
|
|
5391
5411
|
if (visit.kind !== "option") continue;
|
|
5392
5412
|
if (!visible.has(visit.fieldId)) continue;
|
|
5393
5413
|
const field = fieldById.get(visit.fieldId);
|
|
5394
|
-
if (!((
|
|
5414
|
+
if (!((_a = field == null ? void 0 : field.options) == null ? void 0 : _a.length)) continue;
|
|
5395
5415
|
const option = field.options.find((item) => item.id === visit.optionId);
|
|
5396
5416
|
const quantity = readPositiveFiniteNumber((_b = option == null ? void 0 : option.meta) == null ? void 0 : _b.quantityDefault);
|
|
5397
5417
|
if (quantity !== void 0) {
|
|
@@ -5499,12 +5519,12 @@ function readPositiveFiniteNumber(value) {
|
|
|
5499
5519
|
|
|
5500
5520
|
// src/utils/build-order-snapshot/utilities.ts
|
|
5501
5521
|
function collectUtilityLineItems(visibleFieldIds, fieldById, selection, selectedOptionsByFieldId, quantity) {
|
|
5502
|
-
var
|
|
5522
|
+
var _a, _b, _c, _d, _e;
|
|
5503
5523
|
const items = [];
|
|
5504
5524
|
for (const fid of visibleFieldIds) {
|
|
5505
5525
|
const field = fieldById.get(fid);
|
|
5506
5526
|
if (!field) continue;
|
|
5507
|
-
const isUtilityField = ((
|
|
5527
|
+
const isUtilityField = ((_a = field.pricing_role) != null ? _a : "base") === "utility";
|
|
5508
5528
|
const marker = readUtilityMarker((_b = field.meta) == null ? void 0 : _b.utility);
|
|
5509
5529
|
if (isUtilityField && marker) {
|
|
5510
5530
|
const value = selection.formValuesByFieldId[field.id];
|
|
@@ -5550,7 +5570,7 @@ function readUtilityMarker(v) {
|
|
|
5550
5570
|
return out;
|
|
5551
5571
|
}
|
|
5552
5572
|
function buildUtilityItemFromMarker(nodeId, marker, quantity, value) {
|
|
5553
|
-
var
|
|
5573
|
+
var _a, _b;
|
|
5554
5574
|
const base = {
|
|
5555
5575
|
nodeId,
|
|
5556
5576
|
mode: marker.mode,
|
|
@@ -5560,7 +5580,7 @@ function buildUtilityItemFromMarker(nodeId, marker, quantity, value) {
|
|
|
5560
5580
|
inputs: { quantity }
|
|
5561
5581
|
};
|
|
5562
5582
|
if (marker.mode === "per_value") {
|
|
5563
|
-
base.inputs.valueBy = (
|
|
5583
|
+
base.inputs.valueBy = (_a = marker.valueBy) != null ? _a : "value";
|
|
5564
5584
|
if (marker.valueBy === "length") {
|
|
5565
5585
|
base.inputs.value = Array.isArray(value) ? value.length : typeof value === "string" ? value.length : 0;
|
|
5566
5586
|
} else {
|
|
@@ -5572,7 +5592,7 @@ function buildUtilityItemFromMarker(nodeId, marker, quantity, value) {
|
|
|
5572
5592
|
|
|
5573
5593
|
// src/utils/build-order-snapshot/context.ts
|
|
5574
5594
|
function buildNodeContexts(tagId, visibleFieldIds, fieldById, _selection, selectedOptionsByFieldId) {
|
|
5575
|
-
var
|
|
5595
|
+
var _a;
|
|
5576
5596
|
const ctx = {};
|
|
5577
5597
|
ctx[tagId] = tagId;
|
|
5578
5598
|
for (const fid of visibleFieldIds) {
|
|
@@ -5580,7 +5600,7 @@ function buildNodeContexts(tagId, visibleFieldIds, fieldById, _selection, select
|
|
|
5580
5600
|
if (!field) continue;
|
|
5581
5601
|
const binds = normalizeBindIds(field.bind_id);
|
|
5582
5602
|
const applicable = binds.has(tagId);
|
|
5583
|
-
const selectedOptionIds = (
|
|
5603
|
+
const selectedOptionIds = (_a = selectedOptionsByFieldId[fid]) != null ? _a : [];
|
|
5584
5604
|
for (const oid of selectedOptionIds) {
|
|
5585
5605
|
ctx[oid] = applicable ? tagId : null;
|
|
5586
5606
|
}
|
|
@@ -5632,8 +5652,8 @@ function buildDevWarnings(props, svcMap, originalFallbacks, fieldById, visibleFi
|
|
|
5632
5652
|
|
|
5633
5653
|
// src/utils/build-order-snapshot/index.ts
|
|
5634
5654
|
function buildOrderSnapshot(props, builder, selection, services, settings = {}) {
|
|
5635
|
-
var
|
|
5636
|
-
const mode = (
|
|
5655
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5656
|
+
const mode = (_a = settings.mode) != null ? _a : "prod";
|
|
5637
5657
|
const hostDefaultQty = Number.isFinite((_b = settings.hostDefaultQuantity) != null ? _b : 1) ? settings.hostDefaultQuantity : 1;
|
|
5638
5658
|
const fbSettings = {
|
|
5639
5659
|
requireConstraintFit: true,
|
|
@@ -5649,10 +5669,14 @@ function buildOrderSnapshot(props, builder, selection, services, settings = {})
|
|
|
5649
5669
|
const tagById = new Map(((_e = props.filters) != null ? _e : []).map((t) => [t.id, t]));
|
|
5650
5670
|
const fieldById = new Map(((_f = props.fields) != null ? _f : []).map((f) => [f.id, f]));
|
|
5651
5671
|
const tagConstraints = (_h = (_g = tagById.get(tagId)) == null ? void 0 : _g.constraints) != null ? _h : void 0;
|
|
5652
|
-
const selectedOptionsByFieldId = getSelectedOptionsByFieldId(
|
|
5672
|
+
const selectedOptionsByFieldId = getSelectedOptionsByFieldId(
|
|
5673
|
+
selection,
|
|
5674
|
+
fieldById,
|
|
5675
|
+
mode
|
|
5676
|
+
);
|
|
5653
5677
|
const selectionFields = visibleFieldIds.map((fid) => fieldById.get(fid)).filter((f) => !!f).map((f) => {
|
|
5654
|
-
var
|
|
5655
|
-
const optionIds = isOptionBased(f) ? (
|
|
5678
|
+
var _a2;
|
|
5679
|
+
const optionIds = isOptionBased(f) ? (_a2 = selectedOptionsByFieldId[f.id]) != null ? _a2 : [] : void 0;
|
|
5656
5680
|
return {
|
|
5657
5681
|
id: f.id,
|
|
5658
5682
|
type: String(f.type),
|
|
@@ -5754,12 +5778,12 @@ function buildOrderSnapshot(props, builder, selection, services, settings = {})
|
|
|
5754
5778
|
|
|
5755
5779
|
// src/core/fallback-editor.ts
|
|
5756
5780
|
function createFallbackEditor(options = {}) {
|
|
5757
|
-
var
|
|
5781
|
+
var _a, _b;
|
|
5758
5782
|
const original = cloneFallbacks(options.fallbacks);
|
|
5759
5783
|
let current = cloneFallbacks(options.fallbacks);
|
|
5760
5784
|
const props = options.props;
|
|
5761
5785
|
const snapshot = options.snapshot;
|
|
5762
|
-
const services = (
|
|
5786
|
+
const services = (_a = options.services) != null ? _a : {};
|
|
5763
5787
|
const settings = (_b = options.settings) != null ? _b : {};
|
|
5764
5788
|
function state() {
|
|
5765
5789
|
return {
|
|
@@ -5776,9 +5800,9 @@ function createFallbackEditor(options = {}) {
|
|
|
5776
5800
|
return state();
|
|
5777
5801
|
}
|
|
5778
5802
|
function get(serviceId) {
|
|
5779
|
-
var
|
|
5803
|
+
var _a2, _b2;
|
|
5780
5804
|
const out = [];
|
|
5781
|
-
for (const [primary, list] of Object.entries((
|
|
5805
|
+
for (const [primary, list] of Object.entries((_a2 = current.global) != null ? _a2 : {})) {
|
|
5782
5806
|
if (String(primary) !== String(serviceId)) continue;
|
|
5783
5807
|
out.push({
|
|
5784
5808
|
scope: "global",
|
|
@@ -5800,14 +5824,14 @@ function createFallbackEditor(options = {}) {
|
|
|
5800
5824
|
return out;
|
|
5801
5825
|
}
|
|
5802
5826
|
function getScope(context) {
|
|
5803
|
-
var
|
|
5827
|
+
var _a2, _b2, _c, _d;
|
|
5804
5828
|
if (context.scope === "global") {
|
|
5805
|
-
return [...(_b2 = (
|
|
5829
|
+
return [...(_b2 = (_a2 = current.global) == null ? void 0 : _a2[context.primary]) != null ? _b2 : []];
|
|
5806
5830
|
}
|
|
5807
5831
|
return [...(_d = (_c = current.nodes) == null ? void 0 : _c[context.nodeId]) != null ? _d : []];
|
|
5808
5832
|
}
|
|
5809
5833
|
function check(context, candidates) {
|
|
5810
|
-
var
|
|
5834
|
+
var _a2, _b2;
|
|
5811
5835
|
const normalized = normalizeCandidateList(
|
|
5812
5836
|
candidates != null ? candidates : getScope(context),
|
|
5813
5837
|
true
|
|
@@ -5826,7 +5850,7 @@ function createFallbackEditor(options = {}) {
|
|
|
5826
5850
|
}
|
|
5827
5851
|
const tempFallbacks = cloneFallbacks(current);
|
|
5828
5852
|
if (context.scope === "global") {
|
|
5829
|
-
(
|
|
5853
|
+
(_a2 = tempFallbacks.global) != null ? _a2 : tempFallbacks.global = {};
|
|
5830
5854
|
if (normalized.length)
|
|
5831
5855
|
tempFallbacks.global[context.primary] = normalized;
|
|
5832
5856
|
else delete tempFallbacks.global[context.primary];
|
|
@@ -5945,9 +5969,9 @@ function createFallbackEditor(options = {}) {
|
|
|
5945
5969
|
return writeScope(context, []);
|
|
5946
5970
|
}
|
|
5947
5971
|
function eligible(context, opt) {
|
|
5948
|
-
var
|
|
5972
|
+
var _a2, _b2;
|
|
5949
5973
|
if (!props) return [];
|
|
5950
|
-
const source = (
|
|
5974
|
+
const source = (_a2 = opt == null ? void 0 : opt.source) != null ? _a2 : "all_services";
|
|
5951
5975
|
const exclude2 = normalizeCandidateList(
|
|
5952
5976
|
[
|
|
5953
5977
|
...(_b2 = opt == null ? void 0 : opt.exclude) != null ? _b2 : [],
|
|
@@ -5992,10 +6016,10 @@ function createFallbackEditor(options = {}) {
|
|
|
5992
6016
|
});
|
|
5993
6017
|
}
|
|
5994
6018
|
function writeScope(context, nextList) {
|
|
5995
|
-
var
|
|
6019
|
+
var _a2, _b2;
|
|
5996
6020
|
const next = cloneFallbacks(current);
|
|
5997
6021
|
if (context.scope === "global") {
|
|
5998
|
-
(
|
|
6022
|
+
(_a2 = next.global) != null ? _a2 : next.global = {};
|
|
5999
6023
|
if (nextList.length) {
|
|
6000
6024
|
next.global[context.primary] = [...nextList];
|
|
6001
6025
|
} else {
|
|
@@ -6085,9 +6109,9 @@ function getNodeRegistrationInfo(props, nodeId) {
|
|
|
6085
6109
|
};
|
|
6086
6110
|
}
|
|
6087
6111
|
function findOptionOwner(fields, optionId) {
|
|
6088
|
-
var
|
|
6112
|
+
var _a;
|
|
6089
6113
|
for (const field of fields) {
|
|
6090
|
-
for (const option of (
|
|
6114
|
+
for (const option of (_a = field.options) != null ? _a : []) {
|
|
6091
6115
|
if (option.id === optionId) return { field, option };
|
|
6092
6116
|
}
|
|
6093
6117
|
}
|
|
@@ -6098,8 +6122,8 @@ function bindIdsToArray2(v) {
|
|
|
6098
6122
|
return v ? [v] : [];
|
|
6099
6123
|
}
|
|
6100
6124
|
function resolveNodeTagContext(params) {
|
|
6101
|
-
var
|
|
6102
|
-
const nodeContexts = (_c = (_b = (
|
|
6125
|
+
var _a, _b, _c;
|
|
6126
|
+
const nodeContexts = (_c = (_b = (_a = params.snapshot) == null ? void 0 : _a.meta) == null ? void 0 : _b.context) == null ? void 0 : _c.nodeContexts;
|
|
6103
6127
|
if (nodeContexts && Object.prototype.hasOwnProperty.call(nodeContexts, params.nodeId)) {
|
|
6104
6128
|
const tagId = nodeContexts[params.nodeId];
|
|
6105
6129
|
return typeof tagId === "string" && tagId.trim().length > 0 ? tagId : void 0;
|
|
@@ -6125,12 +6149,46 @@ function mapDiagReason(reason) {
|
|
|
6125
6149
|
}
|
|
6126
6150
|
}
|
|
6127
6151
|
|
|
6152
|
+
// src/react/inputs/registry.ts
|
|
6153
|
+
function createInputRegistry() {
|
|
6154
|
+
const store = /* @__PURE__ */ new Map();
|
|
6155
|
+
const get = (kind, variant) => {
|
|
6156
|
+
var _a;
|
|
6157
|
+
const vm = store.get(kind);
|
|
6158
|
+
if (!vm) return void 0;
|
|
6159
|
+
const v = variant != null ? variant : "default";
|
|
6160
|
+
return (_a = vm.get(v)) != null ? _a : vm.get("default");
|
|
6161
|
+
};
|
|
6162
|
+
const register = (kind, descriptor, variant) => {
|
|
6163
|
+
let vm = store.get(kind);
|
|
6164
|
+
if (!vm) {
|
|
6165
|
+
vm = /* @__PURE__ */ new Map();
|
|
6166
|
+
store.set(kind, vm);
|
|
6167
|
+
}
|
|
6168
|
+
vm.set(variant != null ? variant : "default", descriptor);
|
|
6169
|
+
};
|
|
6170
|
+
const unregister = (kind, variant) => {
|
|
6171
|
+
const vm = store.get(kind);
|
|
6172
|
+
if (!vm) return;
|
|
6173
|
+
const key = variant != null ? variant : "default";
|
|
6174
|
+
vm.delete(key);
|
|
6175
|
+
if (vm.size === 0) store.delete(kind);
|
|
6176
|
+
};
|
|
6177
|
+
const registerMany = (entries) => {
|
|
6178
|
+
for (const e of entries) register(e.kind, e.descriptor, e.variant);
|
|
6179
|
+
};
|
|
6180
|
+
return { get, register, unregister, registerMany, _store: store };
|
|
6181
|
+
}
|
|
6182
|
+
function resolveInputDescriptor(registry, kind, variant) {
|
|
6183
|
+
return registry.get(kind, variant);
|
|
6184
|
+
}
|
|
6185
|
+
|
|
6128
6186
|
// src/react/canvas/editor/editor-ids.ts
|
|
6129
6187
|
function uniqueId(ctx, base) {
|
|
6130
|
-
var
|
|
6188
|
+
var _a, _b;
|
|
6131
6189
|
const props = ctx.getProps();
|
|
6132
6190
|
const taken = /* @__PURE__ */ new Set([
|
|
6133
|
-
...((
|
|
6191
|
+
...((_a = props.filters) != null ? _a : []).map((t) => t.id),
|
|
6134
6192
|
...((_b = props.fields) != null ? _b : []).map((f) => f.id)
|
|
6135
6193
|
]);
|
|
6136
6194
|
let candidate = nextCopyId(base);
|
|
@@ -6138,9 +6196,9 @@ function uniqueId(ctx, base) {
|
|
|
6138
6196
|
return candidate;
|
|
6139
6197
|
}
|
|
6140
6198
|
function uniqueOptionId(ctx, fieldId, base) {
|
|
6141
|
-
var
|
|
6199
|
+
var _a, _b;
|
|
6142
6200
|
const props = ctx.getProps();
|
|
6143
|
-
const fld = ((
|
|
6201
|
+
const fld = ((_a = props.fields) != null ? _a : []).find((f) => f.id === fieldId);
|
|
6144
6202
|
const taken = new Set(((_b = fld == null ? void 0 : fld.options) != null ? _b : []).map((o) => o.id));
|
|
6145
6203
|
let candidate = base;
|
|
6146
6204
|
if (taken.has(candidate)) candidate = nextCopyId(candidate);
|
|
@@ -6148,14 +6206,14 @@ function uniqueOptionId(ctx, fieldId, base) {
|
|
|
6148
6206
|
return candidate;
|
|
6149
6207
|
}
|
|
6150
6208
|
function genId(ctx, prefix) {
|
|
6151
|
-
var
|
|
6209
|
+
var _a, _b, _c;
|
|
6152
6210
|
const props = ctx.getProps();
|
|
6153
6211
|
const taken = /* @__PURE__ */ new Set([
|
|
6154
|
-
...((
|
|
6212
|
+
...((_a = props.filters) != null ? _a : []).map((t) => t.id),
|
|
6155
6213
|
...((_b = props.fields) != null ? _b : []).map((f) => f.id),
|
|
6156
6214
|
...((_c = props.fields) != null ? _c : []).flatMap((f) => {
|
|
6157
|
-
var
|
|
6158
|
-
return (_b2 = (
|
|
6215
|
+
var _a2, _b2;
|
|
6216
|
+
return (_b2 = (_a2 = f.options) == null ? void 0 : _a2.map((o) => o.id)) != null ? _b2 : [];
|
|
6159
6217
|
})
|
|
6160
6218
|
]);
|
|
6161
6219
|
for (let i = 1; i < 1e4; i++) {
|
|
@@ -6217,11 +6275,11 @@ function duplicateMany(ctx, ids, opts = {}) {
|
|
|
6217
6275
|
try {
|
|
6218
6276
|
const created = [];
|
|
6219
6277
|
ctx.transact("duplicateMany", () => {
|
|
6220
|
-
var
|
|
6278
|
+
var _a, _b, _c;
|
|
6221
6279
|
const props = ctx.getProps();
|
|
6222
6280
|
const selectedFields = /* @__PURE__ */ new Set();
|
|
6223
6281
|
for (const id of ordered) {
|
|
6224
|
-
if (ctx.isFieldId(id) && ((
|
|
6282
|
+
if (ctx.isFieldId(id) && ((_a = props.fields) != null ? _a : []).some((f) => f.id === id)) {
|
|
6225
6283
|
selectedFields.add(id);
|
|
6226
6284
|
}
|
|
6227
6285
|
}
|
|
@@ -6270,8 +6328,8 @@ function duplicateInPlace(ctx, ref, opts = {}) {
|
|
|
6270
6328
|
return duplicateOption(ctx, ref.fieldId, ref.id, opts);
|
|
6271
6329
|
}
|
|
6272
6330
|
function ownerFieldOfOption(props, optionId) {
|
|
6273
|
-
var
|
|
6274
|
-
for (const field of (
|
|
6331
|
+
var _a, _b;
|
|
6332
|
+
for (const field of (_a = props.fields) != null ? _a : []) {
|
|
6275
6333
|
if (((_b = field.options) != null ? _b : []).some((o) => o.id === optionId)) {
|
|
6276
6334
|
return { fieldId: field.id };
|
|
6277
6335
|
}
|
|
@@ -6279,21 +6337,21 @@ function ownerFieldOfOption(props, optionId) {
|
|
|
6279
6337
|
return null;
|
|
6280
6338
|
}
|
|
6281
6339
|
function duplicateTag(ctx, tagId, opts) {
|
|
6282
|
-
var
|
|
6340
|
+
var _a, _b, _c, _d;
|
|
6283
6341
|
const props = ctx.getProps();
|
|
6284
|
-
const tags = (
|
|
6342
|
+
const tags = (_a = props.filters) != null ? _a : [];
|
|
6285
6343
|
const src = tags.find((t) => t.id === tagId);
|
|
6286
6344
|
if (!src) throw new Error(`Tag not found: ${tagId}`);
|
|
6287
6345
|
const id = (_b = opts.id) != null ? _b : ctx.uniqueId(src.id);
|
|
6288
6346
|
const label = ((_c = opts.labelStrategy) != null ? _c : nextCopyLabel)((_d = src.label) != null ? _d : id);
|
|
6289
6347
|
if (!opts.withChildren) {
|
|
6290
6348
|
ctx.patchProps((p) => {
|
|
6291
|
-
var
|
|
6349
|
+
var _a2;
|
|
6292
6350
|
const clone2 = { ...src, id, label };
|
|
6293
6351
|
clone2.bind_id = src.bind_id;
|
|
6294
6352
|
clone2.constraints_overrides = void 0;
|
|
6295
6353
|
clone2.constraints_origin = void 0;
|
|
6296
|
-
const arr = (
|
|
6354
|
+
const arr = (_a2 = p.filters) != null ? _a2 : [];
|
|
6297
6355
|
const idx = arr.findIndex((t) => t.id === tagId);
|
|
6298
6356
|
arr.splice(idx + 1, 0, clone2);
|
|
6299
6357
|
p.filters = arr;
|
|
@@ -6313,18 +6371,18 @@ function duplicateTag(ctx, tagId, opts) {
|
|
|
6313
6371
|
idMap.set(n.id, n.id === src.id ? id : ctx.uniqueId(n.id));
|
|
6314
6372
|
}
|
|
6315
6373
|
const clones = subtree.map((n) => {
|
|
6316
|
-
var
|
|
6374
|
+
var _a2, _b2, _c2;
|
|
6317
6375
|
const cloned = { ...n };
|
|
6318
6376
|
cloned.id = idMap.get(n.id);
|
|
6319
|
-
cloned.label = n.id === src.id ? label : ((
|
|
6377
|
+
cloned.label = n.id === src.id ? label : ((_a2 = opts.labelStrategy) != null ? _a2 : nextCopyLabel)((_b2 = n.label) != null ? _b2 : n.id);
|
|
6320
6378
|
cloned.bind_id = n.bind_id ? (_c2 = idMap.get(n.bind_id)) != null ? _c2 : n.bind_id : void 0;
|
|
6321
6379
|
cloned.constraints_origin = void 0;
|
|
6322
6380
|
cloned.constraints_overrides = void 0;
|
|
6323
6381
|
return cloned;
|
|
6324
6382
|
});
|
|
6325
6383
|
ctx.patchProps((p) => {
|
|
6326
|
-
var
|
|
6327
|
-
const arr = (
|
|
6384
|
+
var _a2;
|
|
6385
|
+
const arr = (_a2 = p.filters) != null ? _a2 : [];
|
|
6328
6386
|
const rootIdx = arr.findIndex((t) => t.id === tagId);
|
|
6329
6387
|
arr.splice(rootIdx + 1, 0, clones[0]);
|
|
6330
6388
|
for (const c of clones.slice(1)) arr.push(c);
|
|
@@ -6333,27 +6391,27 @@ function duplicateTag(ctx, tagId, opts) {
|
|
|
6333
6391
|
return id;
|
|
6334
6392
|
}
|
|
6335
6393
|
function duplicateField(ctx, fieldId, opts) {
|
|
6336
|
-
var
|
|
6394
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
6337
6395
|
const props = ctx.getProps();
|
|
6338
|
-
const fields = (
|
|
6396
|
+
const fields = (_a = props.fields) != null ? _a : [];
|
|
6339
6397
|
const src = fields.find((f) => f.id === fieldId);
|
|
6340
6398
|
if (!src) throw new Error(`Field not found: ${fieldId}`);
|
|
6341
6399
|
const id = (_b = opts.id) != null ? _b : ctx.uniqueId(src.id);
|
|
6342
6400
|
const label = ((_c = opts.labelStrategy) != null ? _c : nextCopyLabel)((_d = src.label) != null ? _d : id);
|
|
6343
6401
|
const name = opts.nameStrategy ? opts.nameStrategy(src.name) : nextCopyName(src.name);
|
|
6344
6402
|
const optId = (old) => {
|
|
6345
|
-
var
|
|
6403
|
+
var _a2;
|
|
6346
6404
|
return ctx.uniqueOptionId(
|
|
6347
6405
|
id,
|
|
6348
|
-
((
|
|
6406
|
+
((_a2 = opts.optionIdStrategy) != null ? _a2 : defaultOptionIdStrategy)(old)
|
|
6349
6407
|
);
|
|
6350
6408
|
};
|
|
6351
6409
|
const clonedOptions = ((_e = src.options) != null ? _e : []).map((o) => {
|
|
6352
|
-
var
|
|
6410
|
+
var _a2, _b2;
|
|
6353
6411
|
return {
|
|
6354
6412
|
...o,
|
|
6355
6413
|
id: optId(o.id),
|
|
6356
|
-
label: ((
|
|
6414
|
+
label: ((_a2 = opts.labelStrategy) != null ? _a2 : nextCopyLabel)((_b2 = o.label) != null ? _b2 : o.id)
|
|
6357
6415
|
};
|
|
6358
6416
|
});
|
|
6359
6417
|
const cloned = {
|
|
@@ -6366,13 +6424,13 @@ function duplicateField(ctx, fieldId, opts) {
|
|
|
6366
6424
|
};
|
|
6367
6425
|
const optionIdMap = /* @__PURE__ */ new Map();
|
|
6368
6426
|
((_g = src.options) != null ? _g : []).forEach((o, i) => {
|
|
6369
|
-
var
|
|
6370
|
-
const newOptId = (_b2 = (
|
|
6427
|
+
var _a2, _b2;
|
|
6428
|
+
const newOptId = (_b2 = (_a2 = clonedOptions[i]) == null ? void 0 : _a2.id) != null ? _b2 : o.id;
|
|
6371
6429
|
optionIdMap.set(o.id, newOptId);
|
|
6372
6430
|
});
|
|
6373
6431
|
ctx.patchProps((p) => {
|
|
6374
|
-
var
|
|
6375
|
-
const arr = (
|
|
6432
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
|
|
6433
|
+
const arr = (_a2 = p.fields) != null ? _a2 : [];
|
|
6376
6434
|
const idx = arr.findIndex((f) => f.id === fieldId);
|
|
6377
6435
|
arr.splice(idx + 1, 0, cloned);
|
|
6378
6436
|
p.fields = arr;
|
|
@@ -6420,9 +6478,9 @@ function duplicateField(ctx, fieldId, opts) {
|
|
|
6420
6478
|
return id;
|
|
6421
6479
|
}
|
|
6422
6480
|
function duplicateOption(ctx, fieldId, optionId, opts) {
|
|
6423
|
-
var
|
|
6481
|
+
var _a, _b, _c, _d, _e, _f;
|
|
6424
6482
|
const props = ctx.getProps();
|
|
6425
|
-
const fields = (
|
|
6483
|
+
const fields = (_a = props.fields) != null ? _a : [];
|
|
6426
6484
|
const f = fields.find((x) => x.id === fieldId);
|
|
6427
6485
|
if (!f) throw new Error(`Field not found: ${fieldId}`);
|
|
6428
6486
|
const optIdx = ((_b = f.options) != null ? _b : []).findIndex((o) => o.id === optionId);
|
|
@@ -6436,8 +6494,8 @@ function duplicateOption(ctx, fieldId, optionId, opts) {
|
|
|
6436
6494
|
);
|
|
6437
6495
|
const newLabel = ((_e = opts.labelStrategy) != null ? _e : nextCopyLabel)((_f = src.label) != null ? _f : src.id);
|
|
6438
6496
|
ctx.patchProps((p) => {
|
|
6439
|
-
var
|
|
6440
|
-
const fld = ((
|
|
6497
|
+
var _a2, _b2, _c2;
|
|
6498
|
+
const fld = ((_a2 = p.fields) != null ? _a2 : []).find((x) => x.id === fieldId);
|
|
6441
6499
|
const arr = (_b2 = fld.options) != null ? _b2 : [];
|
|
6442
6500
|
const clone2 = { ...src, id: newId, label: newLabel };
|
|
6443
6501
|
arr.splice(optIdx + 1, 0, clone2);
|
|
@@ -6462,8 +6520,8 @@ function duplicateOption(ctx, fieldId, optionId, opts) {
|
|
|
6462
6520
|
|
|
6463
6521
|
// src/react/canvas/editor/editor-notices.ts
|
|
6464
6522
|
function genNoticeId(ctx) {
|
|
6465
|
-
var
|
|
6466
|
-
const taken = new Set(((
|
|
6523
|
+
var _a;
|
|
6524
|
+
const taken = new Set(((_a = ctx.getProps().notices) != null ? _a : []).map((n) => n.id));
|
|
6467
6525
|
for (let i = 1; i < 1e4; i++) {
|
|
6468
6526
|
const id = `n:${i}`;
|
|
6469
6527
|
if (!taken.has(id)) return id;
|
|
@@ -6471,13 +6529,13 @@ function genNoticeId(ctx) {
|
|
|
6471
6529
|
throw new Error("Unable to generate notice id");
|
|
6472
6530
|
}
|
|
6473
6531
|
function addNotice(ctx, input) {
|
|
6474
|
-
var
|
|
6475
|
-
const id = (
|
|
6532
|
+
var _a;
|
|
6533
|
+
const id = (_a = input.id) != null ? _a : genNoticeId(ctx);
|
|
6476
6534
|
ctx.exec({
|
|
6477
6535
|
name: "addNotice",
|
|
6478
6536
|
do: () => ctx.patchProps((p) => {
|
|
6479
|
-
var
|
|
6480
|
-
const notices = (
|
|
6537
|
+
var _a2;
|
|
6538
|
+
const notices = (_a2 = p.notices) != null ? _a2 : p.notices = [];
|
|
6481
6539
|
if (notices.some((n) => n.id === id)) {
|
|
6482
6540
|
throw new Error(`Notice id '${id}' already exists`);
|
|
6483
6541
|
}
|
|
@@ -6505,8 +6563,8 @@ function removeNotice(ctx, id) {
|
|
|
6505
6563
|
ctx.exec({
|
|
6506
6564
|
name: "removeNotice",
|
|
6507
6565
|
do: () => ctx.patchProps((p) => {
|
|
6508
|
-
var
|
|
6509
|
-
if (!((
|
|
6566
|
+
var _a;
|
|
6567
|
+
if (!((_a = p.notices) == null ? void 0 : _a.length)) return;
|
|
6510
6568
|
p.notices = p.notices.filter((n) => n.id !== id);
|
|
6511
6569
|
if (!p.notices.length) delete p.notices;
|
|
6512
6570
|
}),
|
|
@@ -6519,8 +6577,8 @@ var import_lodash_es3 = require("lodash-es");
|
|
|
6519
6577
|
|
|
6520
6578
|
// src/react/canvas/editor/editor-utils.ts
|
|
6521
6579
|
function ownerOfOption(props, optionId) {
|
|
6522
|
-
var
|
|
6523
|
-
for (const f of (
|
|
6580
|
+
var _a, _b;
|
|
6581
|
+
for (const f of (_a = props.fields) != null ? _a : []) {
|
|
6524
6582
|
const idx = ((_b = f.options) != null ? _b : []).findIndex((o) => o.id === optionId);
|
|
6525
6583
|
if (idx >= 0) return { fieldId: f.id, index: idx };
|
|
6526
6584
|
}
|
|
@@ -6533,8 +6591,8 @@ function isActualButtonField(field) {
|
|
|
6533
6591
|
return (field == null ? void 0 : field.button) === true && !hasFieldOptions(field);
|
|
6534
6592
|
}
|
|
6535
6593
|
function clearFieldButtonReceiverMaps(props, fieldId) {
|
|
6536
|
-
var
|
|
6537
|
-
if ((
|
|
6594
|
+
var _a, _b;
|
|
6595
|
+
if ((_a = props.includes_for_buttons) == null ? void 0 : _a[fieldId]) {
|
|
6538
6596
|
delete props.includes_for_buttons[fieldId];
|
|
6539
6597
|
}
|
|
6540
6598
|
if ((_b = props.excludes_for_buttons) == null ? void 0 : _b[fieldId]) {
|
|
@@ -6575,8 +6633,8 @@ function stripDeletedIds(ids) {
|
|
|
6575
6633
|
return { ordered, set: new Set(ordered) };
|
|
6576
6634
|
}
|
|
6577
6635
|
function cleanTagRelationsForDeleted(p, deleted) {
|
|
6578
|
-
var
|
|
6579
|
-
for (const t of (
|
|
6636
|
+
var _a;
|
|
6637
|
+
for (const t of (_a = p.filters) != null ? _a : []) {
|
|
6580
6638
|
if (t.bind_id && deleted.has(String(t.bind_id))) delete t.bind_id;
|
|
6581
6639
|
if (t.includes) {
|
|
6582
6640
|
const next = t.includes.filter((x) => !deleted.has(String(x)));
|
|
@@ -6591,8 +6649,8 @@ function cleanTagRelationsForDeleted(p, deleted) {
|
|
|
6591
6649
|
}
|
|
6592
6650
|
}
|
|
6593
6651
|
function cleanFieldBindsForDeleted(p, deleted) {
|
|
6594
|
-
var
|
|
6595
|
-
for (const f of (
|
|
6652
|
+
var _a;
|
|
6653
|
+
for (const f of (_a = p.fields) != null ? _a : []) {
|
|
6596
6654
|
const bind = f.bind_id;
|
|
6597
6655
|
if (!bind) continue;
|
|
6598
6656
|
if (Array.isArray(bind)) {
|
|
@@ -6605,7 +6663,7 @@ function cleanFieldBindsForDeleted(p, deleted) {
|
|
|
6605
6663
|
}
|
|
6606
6664
|
}
|
|
6607
6665
|
function cleanRelationMapsForDeleted(p, deleted) {
|
|
6608
|
-
var
|
|
6666
|
+
var _a;
|
|
6609
6667
|
for (const key of RELATION_MAP_KEYS) {
|
|
6610
6668
|
const map = p[key];
|
|
6611
6669
|
if (!map) continue;
|
|
@@ -6614,7 +6672,7 @@ function cleanRelationMapsForDeleted(p, deleted) {
|
|
|
6614
6672
|
delete map[mapKey];
|
|
6615
6673
|
continue;
|
|
6616
6674
|
}
|
|
6617
|
-
const next = ((
|
|
6675
|
+
const next = ((_a = map[mapKey]) != null ? _a : []).filter(
|
|
6618
6676
|
(item) => !deleted.has(String(item))
|
|
6619
6677
|
);
|
|
6620
6678
|
if (next.length) map[mapKey] = next;
|
|
@@ -6624,10 +6682,10 @@ function cleanRelationMapsForDeleted(p, deleted) {
|
|
|
6624
6682
|
}
|
|
6625
6683
|
}
|
|
6626
6684
|
function cleanOrderForTagsForDeleted(p, deleted) {
|
|
6627
|
-
var
|
|
6685
|
+
var _a, _b;
|
|
6628
6686
|
const map = p.order_for_tags;
|
|
6629
6687
|
if (!map) return;
|
|
6630
|
-
const fieldIds = new Set(((
|
|
6688
|
+
const fieldIds = new Set(((_a = p.fields) != null ? _a : []).map((f) => String(f.id)));
|
|
6631
6689
|
for (const key of Object.keys(map)) {
|
|
6632
6690
|
if (deleted.has(String(key))) {
|
|
6633
6691
|
delete map[key];
|
|
@@ -6642,8 +6700,8 @@ function cleanOrderForTagsForDeleted(p, deleted) {
|
|
|
6642
6700
|
if (!Object.keys(map).length) delete p.order_for_tags;
|
|
6643
6701
|
}
|
|
6644
6702
|
function cleanNoticesForDeleted(p, deleted) {
|
|
6645
|
-
var
|
|
6646
|
-
if (!((
|
|
6703
|
+
var _a;
|
|
6704
|
+
if (!((_a = p.notices) == null ? void 0 : _a.length)) return;
|
|
6647
6705
|
p.notices = p.notices.filter((n) => {
|
|
6648
6706
|
const target = n.target;
|
|
6649
6707
|
if (!target || target.scope === "global") return true;
|
|
@@ -6662,18 +6720,18 @@ function applyDeleteCleanup(p, deleted) {
|
|
|
6662
6720
|
cleanNoticesForDeleted(p, deleted);
|
|
6663
6721
|
}
|
|
6664
6722
|
function removeOptionInPlace(p, optionId) {
|
|
6665
|
-
var
|
|
6723
|
+
var _a;
|
|
6666
6724
|
const owner = ownerOfOption(p, optionId);
|
|
6667
6725
|
if (!owner) return false;
|
|
6668
|
-
const f = ((
|
|
6726
|
+
const f = ((_a = p.fields) != null ? _a : []).find((x) => x.id === owner.fieldId);
|
|
6669
6727
|
if (!(f == null ? void 0 : f.options)) return false;
|
|
6670
6728
|
const before = f.options.length;
|
|
6671
6729
|
f.options = f.options.filter((o) => o.id !== optionId);
|
|
6672
6730
|
return f.options.length !== before;
|
|
6673
6731
|
}
|
|
6674
6732
|
function removeFieldInPlace(p, fieldId) {
|
|
6675
|
-
var
|
|
6676
|
-
const field = ((
|
|
6733
|
+
var _a, _b, _c, _d, _e;
|
|
6734
|
+
const field = ((_a = p.fields) != null ? _a : []).find((f) => f.id === fieldId);
|
|
6677
6735
|
if (!field) return [];
|
|
6678
6736
|
const deleted = [fieldId, ...((_b = field.options) != null ? _b : []).map((o) => String(o.id))];
|
|
6679
6737
|
const before = ((_c = p.fields) != null ? _c : []).length;
|
|
@@ -6682,8 +6740,8 @@ function removeFieldInPlace(p, fieldId) {
|
|
|
6682
6740
|
return ((_e = p.fields) != null ? _e : []).length !== before ? deleted : [];
|
|
6683
6741
|
}
|
|
6684
6742
|
function removeTagInPlace(p, tagId) {
|
|
6685
|
-
var
|
|
6686
|
-
const before = ((
|
|
6743
|
+
var _a, _b, _c;
|
|
6744
|
+
const before = ((_a = p.filters) != null ? _a : []).length;
|
|
6687
6745
|
p.filters = ((_b = p.filters) != null ? _b : []).filter((t) => t.id !== tagId);
|
|
6688
6746
|
return ((_c = p.filters) != null ? _c : []).length !== before;
|
|
6689
6747
|
}
|
|
@@ -6692,9 +6750,9 @@ function reLabel(ctx, id, nextLabel) {
|
|
|
6692
6750
|
ctx.exec({
|
|
6693
6751
|
name: "reLabel",
|
|
6694
6752
|
do: () => ctx.patchProps((p) => {
|
|
6695
|
-
var
|
|
6753
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
6696
6754
|
if (ctx.isTagId(id)) {
|
|
6697
|
-
const t = ((
|
|
6755
|
+
const t = ((_a = p.filters) != null ? _a : []).find((x) => x.id === id);
|
|
6698
6756
|
if (!t) return;
|
|
6699
6757
|
if (((_b = t.label) != null ? _b : "") === label) return;
|
|
6700
6758
|
t.label = label;
|
|
@@ -6727,8 +6785,8 @@ function setFieldName(ctx, fieldId, nextName) {
|
|
|
6727
6785
|
ctx.exec({
|
|
6728
6786
|
name: "setFieldName",
|
|
6729
6787
|
do: () => ctx.patchProps((p) => {
|
|
6730
|
-
var
|
|
6731
|
-
const fields = (
|
|
6788
|
+
var _a;
|
|
6789
|
+
const fields = (_a = p.fields) != null ? _a : [];
|
|
6732
6790
|
const f = fields.find((x) => x.id === fieldId);
|
|
6733
6791
|
if (!f) {
|
|
6734
6792
|
ctx.api.emit("error", {
|
|
@@ -6760,8 +6818,8 @@ function setFieldName(ctx, fieldId, nextName) {
|
|
|
6760
6818
|
}
|
|
6761
6819
|
const collision = fields.find(
|
|
6762
6820
|
(x) => {
|
|
6763
|
-
var
|
|
6764
|
-
return x.id !== fieldId && ((
|
|
6821
|
+
var _a2;
|
|
6822
|
+
return x.id !== fieldId && ((_a2 = x.name) != null ? _a2 : "") === name;
|
|
6765
6823
|
}
|
|
6766
6824
|
);
|
|
6767
6825
|
if (collision) {
|
|
@@ -6778,13 +6836,13 @@ function setFieldName(ctx, fieldId, nextName) {
|
|
|
6778
6836
|
});
|
|
6779
6837
|
}
|
|
6780
6838
|
function addOption(ctx, fieldId, input) {
|
|
6781
|
-
var
|
|
6782
|
-
const id = (
|
|
6839
|
+
var _a;
|
|
6840
|
+
const id = (_a = input.id) != null ? _a : ctx.genId("o");
|
|
6783
6841
|
ctx.exec({
|
|
6784
6842
|
name: "addOption",
|
|
6785
6843
|
do: () => ctx.patchProps((p) => {
|
|
6786
|
-
var
|
|
6787
|
-
const f = ((
|
|
6844
|
+
var _a2, _b;
|
|
6845
|
+
const f = ((_a2 = p.fields) != null ? _a2 : []).find((x) => x.id === fieldId);
|
|
6788
6846
|
if (!f) throw new Error(`addOption: field '${fieldId}' not found`);
|
|
6789
6847
|
const list = (_b = f.options) != null ? _b : f.options = [];
|
|
6790
6848
|
if (list.some((o) => o.id === id)) {
|
|
@@ -6803,10 +6861,10 @@ function updateOption(ctx, optionId, patch) {
|
|
|
6803
6861
|
ctx.exec({
|
|
6804
6862
|
name: "updateOption",
|
|
6805
6863
|
do: () => ctx.patchProps((p) => {
|
|
6806
|
-
var
|
|
6864
|
+
var _a;
|
|
6807
6865
|
const owner = ownerOfOption(p, optionId);
|
|
6808
6866
|
if (!owner) return;
|
|
6809
|
-
const f = ((
|
|
6867
|
+
const f = ((_a = p.fields) != null ? _a : []).find((x) => x.id === owner.fieldId);
|
|
6810
6868
|
if (!(f == null ? void 0 : f.options)) return;
|
|
6811
6869
|
const o = f.options.find((x) => x.id === optionId);
|
|
6812
6870
|
if (o) Object.assign(o, patch);
|
|
@@ -6834,9 +6892,9 @@ function editLabel(ctx, id, label) {
|
|
|
6834
6892
|
ctx.exec({
|
|
6835
6893
|
name: "editLabel",
|
|
6836
6894
|
do: () => ctx.patchProps((p) => {
|
|
6837
|
-
var
|
|
6895
|
+
var _a, _b, _c, _d;
|
|
6838
6896
|
if (ctx.isTagId(id)) {
|
|
6839
|
-
const t = ((
|
|
6897
|
+
const t = ((_a = p.filters) != null ? _a : []).find((x) => x.id === id);
|
|
6840
6898
|
if (t) t.label = next;
|
|
6841
6899
|
return;
|
|
6842
6900
|
}
|
|
@@ -6862,8 +6920,8 @@ function editName(ctx, fieldId, name) {
|
|
|
6862
6920
|
ctx.exec({
|
|
6863
6921
|
name: "editName",
|
|
6864
6922
|
do: () => ctx.patchProps((p) => {
|
|
6865
|
-
var
|
|
6866
|
-
const f = ((
|
|
6923
|
+
var _a;
|
|
6924
|
+
const f = ((_a = p.fields) != null ? _a : []).find((x) => x.id === fieldId);
|
|
6867
6925
|
if (!f) return;
|
|
6868
6926
|
f.name = name;
|
|
6869
6927
|
}),
|
|
@@ -6874,7 +6932,7 @@ function setService(ctx, id, input) {
|
|
|
6874
6932
|
ctx.exec({
|
|
6875
6933
|
name: "setService",
|
|
6876
6934
|
do: () => ctx.patchProps((p) => {
|
|
6877
|
-
var
|
|
6935
|
+
var _a, _b, _c, _d, _e, _f;
|
|
6878
6936
|
const hasSidKey = Object.prototype.hasOwnProperty.call(
|
|
6879
6937
|
input,
|
|
6880
6938
|
"service_id"
|
|
@@ -6883,7 +6941,7 @@ function setService(ctx, id, input) {
|
|
|
6883
6941
|
const sid = validId ? typeof input.service_id === "string" ? input.service_id.trim() : Number(input.service_id) : void 0;
|
|
6884
6942
|
const nextRole = input.pricing_role;
|
|
6885
6943
|
if (ctx.isTagId(id)) {
|
|
6886
|
-
const t = ((
|
|
6944
|
+
const t = ((_a = p.filters) != null ? _a : []).find((x) => x.id === id);
|
|
6887
6945
|
if (!t) return;
|
|
6888
6946
|
if (hasSidKey) {
|
|
6889
6947
|
if (sid === void 0) delete t.service_id;
|
|
@@ -6972,18 +7030,18 @@ function setService(ctx, id, input) {
|
|
|
6972
7030
|
});
|
|
6973
7031
|
}
|
|
6974
7032
|
function addTag(ctx, partial) {
|
|
6975
|
-
var
|
|
6976
|
-
const id = (
|
|
7033
|
+
var _a;
|
|
7034
|
+
const id = (_a = partial.id) != null ? _a : ctx.genId("t");
|
|
6977
7035
|
const payload = { ...partial, id };
|
|
6978
7036
|
ctx.exec({
|
|
6979
7037
|
name: "addTag",
|
|
6980
7038
|
do: () => ctx.patchProps((p) => {
|
|
6981
|
-
var
|
|
6982
|
-
p.filters = [...(
|
|
7039
|
+
var _a2;
|
|
7040
|
+
p.filters = [...(_a2 = p.filters) != null ? _a2 : [], payload];
|
|
6983
7041
|
}),
|
|
6984
7042
|
undo: () => ctx.patchProps((p) => {
|
|
6985
|
-
var
|
|
6986
|
-
p.filters = ((
|
|
7043
|
+
var _a2;
|
|
7044
|
+
p.filters = ((_a2 = p.filters) != null ? _a2 : []).filter((t) => t.id !== id);
|
|
6987
7045
|
})
|
|
6988
7046
|
});
|
|
6989
7047
|
}
|
|
@@ -6992,16 +7050,16 @@ function updateTag(ctx, id, patch) {
|
|
|
6992
7050
|
ctx.exec({
|
|
6993
7051
|
name: "updateTag",
|
|
6994
7052
|
do: () => ctx.patchProps((p) => {
|
|
6995
|
-
var
|
|
6996
|
-
p.filters = ((
|
|
7053
|
+
var _a;
|
|
7054
|
+
p.filters = ((_a = p.filters) != null ? _a : []).map((t) => {
|
|
6997
7055
|
if (t.id !== id) return t;
|
|
6998
7056
|
prev = t;
|
|
6999
7057
|
return { ...t, ...patch };
|
|
7000
7058
|
});
|
|
7001
7059
|
}),
|
|
7002
7060
|
undo: () => ctx.patchProps((p) => {
|
|
7003
|
-
var
|
|
7004
|
-
p.filters = ((
|
|
7061
|
+
var _a;
|
|
7062
|
+
p.filters = ((_a = p.filters) != null ? _a : []).map(
|
|
7005
7063
|
(t) => t.id === id && prev ? prev : t
|
|
7006
7064
|
);
|
|
7007
7065
|
})
|
|
@@ -7021,20 +7079,21 @@ function removeTag(ctx, id) {
|
|
|
7021
7079
|
});
|
|
7022
7080
|
}
|
|
7023
7081
|
function addField(ctx, partial) {
|
|
7024
|
-
var
|
|
7025
|
-
const id = (
|
|
7082
|
+
var _a;
|
|
7083
|
+
const id = (_a = partial.id) != null ? _a : ctx.genId("f");
|
|
7026
7084
|
const payload = { ...partial, id };
|
|
7027
7085
|
ctx.exec({
|
|
7028
7086
|
name: "addField",
|
|
7029
7087
|
do: () => ctx.patchProps((p) => {
|
|
7030
|
-
var
|
|
7031
|
-
p.fields = [...(
|
|
7088
|
+
var _a2;
|
|
7089
|
+
p.fields = [...(_a2 = p.fields) != null ? _a2 : [], payload];
|
|
7032
7090
|
}),
|
|
7033
7091
|
undo: () => ctx.patchProps((p) => {
|
|
7034
|
-
var
|
|
7035
|
-
p.fields = ((
|
|
7092
|
+
var _a2;
|
|
7093
|
+
p.fields = ((_a2 = p.fields) != null ? _a2 : []).filter((f) => f.id !== id);
|
|
7036
7094
|
})
|
|
7037
7095
|
});
|
|
7096
|
+
return id;
|
|
7038
7097
|
}
|
|
7039
7098
|
function updateField(ctx, id, patch) {
|
|
7040
7099
|
let prev;
|
|
@@ -7043,8 +7102,8 @@ function updateField(ctx, id, patch) {
|
|
|
7043
7102
|
ctx.exec({
|
|
7044
7103
|
name: "updateField",
|
|
7045
7104
|
do: () => ctx.patchProps((p) => {
|
|
7046
|
-
var
|
|
7047
|
-
prevIncludesForButton = ((
|
|
7105
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
7106
|
+
prevIncludesForButton = ((_a = p.includes_for_buttons) == null ? void 0 : _a[id]) ? [...(_c = (_b = p.includes_for_buttons) == null ? void 0 : _b[id]) != null ? _c : []] : void 0;
|
|
7048
7107
|
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;
|
|
7049
7108
|
p.fields = ((_g = p.fields) != null ? _g : []).map((f) => {
|
|
7050
7109
|
if (f.id !== id) return f;
|
|
@@ -7057,8 +7116,8 @@ function updateField(ctx, id, patch) {
|
|
|
7057
7116
|
});
|
|
7058
7117
|
}),
|
|
7059
7118
|
undo: () => ctx.patchProps((p) => {
|
|
7060
|
-
var
|
|
7061
|
-
p.fields = ((
|
|
7119
|
+
var _a, _b, _c;
|
|
7120
|
+
p.fields = ((_a = p.fields) != null ? _a : []).map(
|
|
7062
7121
|
(f) => f.id === id && prev ? prev : f
|
|
7063
7122
|
);
|
|
7064
7123
|
if (prevIncludesForButton) {
|
|
@@ -7136,13 +7195,13 @@ function removeMany(ctx, ids) {
|
|
|
7136
7195
|
if (!ordered.length) return;
|
|
7137
7196
|
ctx.transact("removeMany", () => {
|
|
7138
7197
|
ctx.patchProps((p) => {
|
|
7139
|
-
var
|
|
7140
|
-
const existingFieldIds = new Set(((
|
|
7198
|
+
var _a, _b, _c;
|
|
7199
|
+
const existingFieldIds = new Set(((_a = p.fields) != null ? _a : []).map((f) => String(f.id)));
|
|
7141
7200
|
const existingTagIds = new Set(((_b = p.filters) != null ? _b : []).map((t) => String(t.id)));
|
|
7142
7201
|
const existingOptionIds = new Set(
|
|
7143
7202
|
((_c = p.fields) != null ? _c : []).flatMap((f) => {
|
|
7144
|
-
var
|
|
7145
|
-
return ((
|
|
7203
|
+
var _a2;
|
|
7204
|
+
return ((_a2 = f.options) != null ? _a2 : []).map((o) => String(o.id));
|
|
7146
7205
|
})
|
|
7147
7206
|
);
|
|
7148
7207
|
const fieldIds = ordered.filter((id) => ctx.isFieldId(id) && existingFieldIds.has(id));
|
|
@@ -7171,10 +7230,10 @@ function removeMany(ctx, ids) {
|
|
|
7171
7230
|
});
|
|
7172
7231
|
}
|
|
7173
7232
|
function getNode(ctx, id) {
|
|
7174
|
-
var
|
|
7233
|
+
var _a, _b, _c, _d;
|
|
7175
7234
|
const props = ctx.getProps();
|
|
7176
7235
|
if (ctx.isTagId(id)) {
|
|
7177
|
-
const t = ((
|
|
7236
|
+
const t = ((_a = props.filters) != null ? _a : []).find((x) => x.id === id);
|
|
7178
7237
|
return {
|
|
7179
7238
|
kind: "tag",
|
|
7180
7239
|
data: t,
|
|
@@ -7205,8 +7264,8 @@ function setConstraint(ctx, tagId, flag, value) {
|
|
|
7205
7264
|
ctx.exec({
|
|
7206
7265
|
name: "setConstraint",
|
|
7207
7266
|
do: () => ctx.patchProps((p) => {
|
|
7208
|
-
var
|
|
7209
|
-
const t = ((
|
|
7267
|
+
var _a, _b;
|
|
7268
|
+
const t = ((_a = p.filters) != null ? _a : []).find((x) => x.id === tagId);
|
|
7210
7269
|
if (!t) return;
|
|
7211
7270
|
prev = (_b = t.constraints) == null ? void 0 : _b[flag];
|
|
7212
7271
|
if (!t.constraints) t.constraints = {};
|
|
@@ -7214,8 +7273,8 @@ function setConstraint(ctx, tagId, flag, value) {
|
|
|
7214
7273
|
else t.constraints[flag] = value;
|
|
7215
7274
|
}),
|
|
7216
7275
|
undo: () => ctx.patchProps((p) => {
|
|
7217
|
-
var
|
|
7218
|
-
const t = ((
|
|
7276
|
+
var _a;
|
|
7277
|
+
const t = ((_a = p.filters) != null ? _a : []).find((x) => x.id === tagId);
|
|
7219
7278
|
if (!t) return;
|
|
7220
7279
|
if (!t.constraints) t.constraints = {};
|
|
7221
7280
|
if (prev === void 0) delete t.constraints[flag];
|
|
@@ -7229,8 +7288,8 @@ function clearConstraintOverride(ctx, tagId, flag) {
|
|
|
7229
7288
|
ctx.exec({
|
|
7230
7289
|
name: "clearConstraintOverride",
|
|
7231
7290
|
do: () => ctx.patchProps((p) => {
|
|
7232
|
-
var
|
|
7233
|
-
const t = ((
|
|
7291
|
+
var _a, _b, _c;
|
|
7292
|
+
const t = ((_a = p.filters) != null ? _a : []).find((x) => x.id === tagId);
|
|
7234
7293
|
if (!t) return;
|
|
7235
7294
|
prev = (_b = t.constraints) == null ? void 0 : _b[flag];
|
|
7236
7295
|
prevOverride = (_c = t.constraints_overrides) == null ? void 0 : _c[flag];
|
|
@@ -7238,8 +7297,8 @@ function clearConstraintOverride(ctx, tagId, flag) {
|
|
|
7238
7297
|
if (t.constraints_overrides) delete t.constraints_overrides[flag];
|
|
7239
7298
|
}),
|
|
7240
7299
|
undo: () => ctx.patchProps((p) => {
|
|
7241
|
-
var
|
|
7242
|
-
const t = ((
|
|
7300
|
+
var _a;
|
|
7301
|
+
const t = ((_a = p.filters) != null ? _a : []).find((x) => x.id === tagId);
|
|
7243
7302
|
if (!t) return;
|
|
7244
7303
|
if (prev !== void 0) {
|
|
7245
7304
|
if (!t.constraints) t.constraints = {};
|
|
@@ -7256,8 +7315,8 @@ function clearConstraint(ctx, tagId, flag) {
|
|
|
7256
7315
|
ctx.exec({
|
|
7257
7316
|
name: "clearConstraint",
|
|
7258
7317
|
do: () => ctx.patchProps((p) => {
|
|
7259
|
-
var
|
|
7260
|
-
const tags = (
|
|
7318
|
+
var _a;
|
|
7319
|
+
const tags = (_a = p.filters) != null ? _a : [];
|
|
7261
7320
|
const byId = new Map(tags.map((t) => [t.id, t]));
|
|
7262
7321
|
const children = /* @__PURE__ */ new Map();
|
|
7263
7322
|
for (const t of tags) {
|
|
@@ -7267,10 +7326,10 @@ function clearConstraint(ctx, tagId, flag) {
|
|
|
7267
7326
|
}
|
|
7268
7327
|
}
|
|
7269
7328
|
const process = (id) => {
|
|
7270
|
-
var
|
|
7329
|
+
var _a2, _b, _c;
|
|
7271
7330
|
const t = byId.get(id);
|
|
7272
7331
|
if (!t) return;
|
|
7273
|
-
const override = (
|
|
7332
|
+
const override = (_a2 = t.constraints_overrides) == null ? void 0 : _a2[flag];
|
|
7274
7333
|
if (override) {
|
|
7275
7334
|
if (!t.constraints) t.constraints = {};
|
|
7276
7335
|
t.constraints[flag] = override.from;
|
|
@@ -7296,9 +7355,9 @@ function clearConstraint(ctx, tagId, flag) {
|
|
|
7296
7355
|
|
|
7297
7356
|
// src/react/canvas/editor/editor-field-rules.ts
|
|
7298
7357
|
function getFieldQuantityRule(ctx, id) {
|
|
7299
|
-
var
|
|
7358
|
+
var _a, _b;
|
|
7300
7359
|
const props = ctx.getProps();
|
|
7301
|
-
const f = ((
|
|
7360
|
+
const f = ((_a = props.fields) != null ? _a : []).find((x) => x.id === id);
|
|
7302
7361
|
if (!f) return void 0;
|
|
7303
7362
|
return normalizeQuantityRule((_b = f.meta) == null ? void 0 : _b.quantity);
|
|
7304
7363
|
}
|
|
@@ -7306,8 +7365,8 @@ function setFieldQuantityRule(ctx, id, rule) {
|
|
|
7306
7365
|
ctx.exec({
|
|
7307
7366
|
name: "setFieldQuantityRule",
|
|
7308
7367
|
do: () => ctx.patchProps((p) => {
|
|
7309
|
-
var
|
|
7310
|
-
const f = ((
|
|
7368
|
+
var _a, _b;
|
|
7369
|
+
const f = ((_a = p.fields) != null ? _a : []).find((x) => x.id === id);
|
|
7311
7370
|
if (!f) return;
|
|
7312
7371
|
const normalized = normalizeQuantityRule(rule);
|
|
7313
7372
|
if (!normalized) {
|
|
@@ -7331,8 +7390,8 @@ function clearFieldQuantityRule(ctx, id) {
|
|
|
7331
7390
|
ctx.exec({
|
|
7332
7391
|
name: "clearFieldQuantityRule",
|
|
7333
7392
|
do: () => ctx.patchProps((p) => {
|
|
7334
|
-
var
|
|
7335
|
-
const f = ((
|
|
7393
|
+
var _a, _b;
|
|
7394
|
+
const f = ((_a = p.fields) != null ? _a : []).find((x) => x.id === id);
|
|
7336
7395
|
if (!f || !((_b = f.meta) == null ? void 0 : _b.quantity)) return;
|
|
7337
7396
|
delete f.meta.quantity;
|
|
7338
7397
|
if (f.meta && Object.keys(f.meta).length === 0) {
|
|
@@ -7343,9 +7402,9 @@ function clearFieldQuantityRule(ctx, id) {
|
|
|
7343
7402
|
});
|
|
7344
7403
|
}
|
|
7345
7404
|
function getFieldValidation(ctx, id) {
|
|
7346
|
-
var
|
|
7405
|
+
var _a;
|
|
7347
7406
|
const props = ctx.getProps();
|
|
7348
|
-
const f = ((
|
|
7407
|
+
const f = ((_a = props.fields) != null ? _a : []).find((x) => x.id === id);
|
|
7349
7408
|
if (!f) return void 0;
|
|
7350
7409
|
return normalizeFieldValidation(f.validation);
|
|
7351
7410
|
}
|
|
@@ -7353,8 +7412,8 @@ function setFieldValidation(ctx, id, rules) {
|
|
|
7353
7412
|
ctx.exec({
|
|
7354
7413
|
name: "setFieldValidation",
|
|
7355
7414
|
do: () => ctx.patchProps((p) => {
|
|
7356
|
-
var
|
|
7357
|
-
const f = ((
|
|
7415
|
+
var _a;
|
|
7416
|
+
const f = ((_a = p.fields) != null ? _a : []).find((x) => x.id === id);
|
|
7358
7417
|
if (!f) return;
|
|
7359
7418
|
const normalized = normalizeFieldValidation(rules);
|
|
7360
7419
|
if (!normalized) {
|
|
@@ -7370,8 +7429,8 @@ function clearFieldValidation(ctx, id) {
|
|
|
7370
7429
|
ctx.exec({
|
|
7371
7430
|
name: "clearFieldValidation",
|
|
7372
7431
|
do: () => ctx.patchProps((p) => {
|
|
7373
|
-
var
|
|
7374
|
-
const f = ((
|
|
7432
|
+
var _a;
|
|
7433
|
+
const f = ((_a = p.fields) != null ? _a : []).find((x) => x.id === id);
|
|
7375
7434
|
if (!f || !f.validation) return;
|
|
7376
7435
|
delete f.validation;
|
|
7377
7436
|
}),
|
|
@@ -7490,9 +7549,9 @@ function pruneOrderKind(ctx, kind) {
|
|
|
7490
7549
|
|
|
7491
7550
|
// src/react/canvas/editor/editor-relations.ts
|
|
7492
7551
|
function wouldCreateTagCycle(_ctx, p, parentId, childId) {
|
|
7493
|
-
var
|
|
7552
|
+
var _a, _b;
|
|
7494
7553
|
if (parentId === childId) return true;
|
|
7495
|
-
const tagById = new Map(((
|
|
7554
|
+
const tagById = new Map(((_a = p.filters) != null ? _a : []).map((t) => [t.id, t]));
|
|
7496
7555
|
let cur = parentId;
|
|
7497
7556
|
const guard = /* @__PURE__ */ new Set();
|
|
7498
7557
|
while (cur) {
|
|
@@ -7506,9 +7565,9 @@ function wouldCreateTagCycle(_ctx, p, parentId, childId) {
|
|
|
7506
7565
|
function wouldCreateIncludeExcludeCycle(ctx, p, receiverId, targetId) {
|
|
7507
7566
|
if (receiverId === targetId) return true;
|
|
7508
7567
|
const getDirectRelations = (id) => {
|
|
7509
|
-
var
|
|
7568
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
7510
7569
|
if (ctx.isTagId(id)) {
|
|
7511
|
-
const t = ((
|
|
7570
|
+
const t = ((_a = p.filters) != null ? _a : []).find((x) => x.id === id);
|
|
7512
7571
|
return [...(_b = t == null ? void 0 : t.includes) != null ? _b : [], ...(_c = t == null ? void 0 : t.excludes) != null ? _c : []];
|
|
7513
7572
|
}
|
|
7514
7573
|
const inc = (_e = (_d = p.includes_for_buttons) == null ? void 0 : _d[id]) != null ? _e : [];
|
|
@@ -7530,12 +7589,12 @@ function include(ctx, receiverId, idOrIds) {
|
|
|
7530
7589
|
ctx.exec({
|
|
7531
7590
|
name: "include",
|
|
7532
7591
|
do: () => ctx.patchProps((p) => {
|
|
7533
|
-
var
|
|
7592
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
7534
7593
|
const receiver = ctx.getNode(receiverId);
|
|
7535
7594
|
const ids = Array.isArray(idOrIds) ? idOrIds : [idOrIds];
|
|
7536
7595
|
if (receiver.kind === "tag" || receiver.kind === "field" && isActualButtonField(receiver.data) || receiver.kind === "option") {
|
|
7537
7596
|
if (receiver.kind === "tag") {
|
|
7538
|
-
const t = ((
|
|
7597
|
+
const t = ((_a = p.filters) != null ? _a : []).find(
|
|
7539
7598
|
(x) => x.id === receiverId
|
|
7540
7599
|
);
|
|
7541
7600
|
if (t) {
|
|
@@ -7628,12 +7687,12 @@ function exclude(ctx, receiverId, idOrIds) {
|
|
|
7628
7687
|
ctx.exec({
|
|
7629
7688
|
name: "exclude",
|
|
7630
7689
|
do: () => ctx.patchProps((p) => {
|
|
7631
|
-
var
|
|
7690
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
7632
7691
|
const receiver = ctx.getNode(receiverId);
|
|
7633
7692
|
const ids = Array.isArray(idOrIds) ? idOrIds : [idOrIds];
|
|
7634
7693
|
if (receiver.kind === "tag" || receiver.kind === "field" && isActualButtonField(receiver.data) || receiver.kind === "option") {
|
|
7635
7694
|
if (receiver.kind === "tag") {
|
|
7636
|
-
const t = ((
|
|
7695
|
+
const t = ((_a = p.filters) != null ? _a : []).find(
|
|
7637
7696
|
(x) => x.id === receiverId
|
|
7638
7697
|
);
|
|
7639
7698
|
if (t) {
|
|
@@ -7726,7 +7785,7 @@ function connect(ctx, kind, fromId, toId2) {
|
|
|
7726
7785
|
ctx.exec({
|
|
7727
7786
|
name: `connect:${kind}`,
|
|
7728
7787
|
do: () => ctx.patchProps((p) => {
|
|
7729
|
-
var
|
|
7788
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7730
7789
|
if (kind === "bind") {
|
|
7731
7790
|
if (ctx.isTagId(fromId) && ctx.isTagId(toId2)) {
|
|
7732
7791
|
if (wouldCreateTagCycle(ctx, p, fromId, toId2)) {
|
|
@@ -7734,7 +7793,7 @@ function connect(ctx, kind, fromId, toId2) {
|
|
|
7734
7793
|
`bind would create a cycle: ${fromId} ? ${toId2}`
|
|
7735
7794
|
);
|
|
7736
7795
|
}
|
|
7737
|
-
const child = ((
|
|
7796
|
+
const child = ((_a = p.filters) != null ? _a : []).find(
|
|
7738
7797
|
(t) => t.id === toId2
|
|
7739
7798
|
);
|
|
7740
7799
|
if (child) child.bind_id = fromId;
|
|
@@ -7828,10 +7887,10 @@ function disconnect(ctx, kind, fromId, toId2) {
|
|
|
7828
7887
|
ctx.exec({
|
|
7829
7888
|
name: `disconnect:${kind}`,
|
|
7830
7889
|
do: () => ctx.patchProps((p) => {
|
|
7831
|
-
var
|
|
7890
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
7832
7891
|
if (kind === "bind") {
|
|
7833
7892
|
if (ctx.isTagId(fromId) && ctx.isTagId(toId2)) {
|
|
7834
|
-
const child = ((
|
|
7893
|
+
const child = ((_a = p.filters) != null ? _a : []).find(
|
|
7835
7894
|
(t) => t.id === toId2
|
|
7836
7895
|
);
|
|
7837
7896
|
if ((child == null ? void 0 : child.bind_id) === fromId) {
|
|
@@ -7923,8 +7982,8 @@ function disconnect(ctx, kind, fromId, toId2) {
|
|
|
7923
7982
|
});
|
|
7924
7983
|
}
|
|
7925
7984
|
function addMappedField(p, mapKey, fromId, toId2) {
|
|
7926
|
-
var
|
|
7927
|
-
const maps = (
|
|
7985
|
+
var _a, _b;
|
|
7986
|
+
const maps = (_a = p[mapKey]) != null ? _a : {};
|
|
7928
7987
|
const arr = (_b = maps[fromId]) != null ? _b : [];
|
|
7929
7988
|
if (!arr.includes(toId2)) {
|
|
7930
7989
|
maps[fromId] = [...arr, toId2];
|
|
@@ -7961,15 +8020,15 @@ function placeNode(ctx, id, opts) {
|
|
|
7961
8020
|
ctx.exec({
|
|
7962
8021
|
name: "placeTag",
|
|
7963
8022
|
do: () => ctx.patchProps((p) => {
|
|
7964
|
-
var
|
|
7965
|
-
const all = (
|
|
8023
|
+
var _a, _b, _c;
|
|
8024
|
+
const all = (_a = p.filters) != null ? _a : [];
|
|
7966
8025
|
const cur = all.find((t) => t.id === id);
|
|
7967
8026
|
if (!cur) return;
|
|
7968
8027
|
const groupKey = (_b = cur.bind_id) != null ? _b : "__root__";
|
|
7969
8028
|
const siblings = all.filter(
|
|
7970
8029
|
(t) => {
|
|
7971
|
-
var
|
|
7972
|
-
return ((
|
|
8030
|
+
var _a2;
|
|
8031
|
+
return ((_a2 = t.bind_id) != null ? _a2 : "__root__") === groupKey;
|
|
7973
8032
|
}
|
|
7974
8033
|
);
|
|
7975
8034
|
const curIdx = siblings.findIndex((t) => t.id === id);
|
|
@@ -8014,8 +8073,8 @@ function placeNode(ctx, id, opts) {
|
|
|
8014
8073
|
ctx.exec({
|
|
8015
8074
|
name: "placeField",
|
|
8016
8075
|
do: () => ctx.patchProps((p) => {
|
|
8017
|
-
var
|
|
8018
|
-
const map = (
|
|
8076
|
+
var _a, _b;
|
|
8077
|
+
const map = (_a = p.order_for_tags) != null ? _a : p.order_for_tags = {};
|
|
8019
8078
|
const arr = (_b = map[tagId]) != null ? _b : map[tagId] = [];
|
|
8020
8079
|
const curIdx = arr.indexOf(fieldId);
|
|
8021
8080
|
if (curIdx >= 0) arr.splice(curIdx, 1);
|
|
@@ -8044,10 +8103,10 @@ function placeOption(ctx, optionId, opts) {
|
|
|
8044
8103
|
ctx.exec({
|
|
8045
8104
|
name: "placeOption",
|
|
8046
8105
|
do: () => ctx.patchProps((p) => {
|
|
8047
|
-
var
|
|
8106
|
+
var _a;
|
|
8048
8107
|
const owner = ownerOfOption(p, optionId);
|
|
8049
8108
|
if (!owner) return;
|
|
8050
|
-
const f = ((
|
|
8109
|
+
const f = ((_a = p.fields) != null ? _a : []).find((x) => x.id === owner.fieldId);
|
|
8051
8110
|
if (!(f == null ? void 0 : f.options)) return;
|
|
8052
8111
|
const curIdx = f.options.findIndex((o) => o.id === optionId);
|
|
8053
8112
|
if (curIdx < 0) return;
|
|
@@ -8105,8 +8164,8 @@ function ensureCatalog(catalog) {
|
|
|
8105
8164
|
return clone(catalog != null ? catalog : createEmptyCatalog());
|
|
8106
8165
|
}
|
|
8107
8166
|
function createCatalogId(catalog, prefix = "cg") {
|
|
8108
|
-
var
|
|
8109
|
-
const taken = new Set(((
|
|
8167
|
+
var _a;
|
|
8168
|
+
const taken = new Set(((_a = catalog == null ? void 0 : catalog.nodes) != null ? _a : []).map((x) => x.id));
|
|
8110
8169
|
for (let i = 1; i < 1e4; i++) {
|
|
8111
8170
|
const id = `${prefix}:${i}`;
|
|
8112
8171
|
if (!taken.has(id)) return id;
|
|
@@ -8114,9 +8173,9 @@ function createCatalogId(catalog, prefix = "cg") {
|
|
|
8114
8173
|
throw new Error("Unable to generate catalog id");
|
|
8115
8174
|
}
|
|
8116
8175
|
function addCatalogGroup(catalog, input) {
|
|
8117
|
-
var
|
|
8176
|
+
var _a;
|
|
8118
8177
|
const next = ensureCatalog(catalog);
|
|
8119
|
-
const id = (
|
|
8178
|
+
const id = (_a = input.id) != null ? _a : createCatalogId(next, "cg");
|
|
8120
8179
|
next.nodes.push({
|
|
8121
8180
|
id,
|
|
8122
8181
|
kind: "group",
|
|
@@ -8133,9 +8192,9 @@ function addCatalogGroup(catalog, input) {
|
|
|
8133
8192
|
return next;
|
|
8134
8193
|
}
|
|
8135
8194
|
function addSmartCatalogGroup(catalog, input) {
|
|
8136
|
-
var
|
|
8195
|
+
var _a, _b, _c;
|
|
8137
8196
|
const next = ensureCatalog(catalog);
|
|
8138
|
-
const id = (
|
|
8197
|
+
const id = (_a = input.id) != null ? _a : createCatalogId(next, "csg");
|
|
8139
8198
|
next.nodes.push({
|
|
8140
8199
|
id,
|
|
8141
8200
|
kind: "smart-group",
|
|
@@ -8153,7 +8212,7 @@ function addSmartCatalogGroup(catalog, input) {
|
|
|
8153
8212
|
return next;
|
|
8154
8213
|
}
|
|
8155
8214
|
function updateCatalogNode(catalog, id, patch) {
|
|
8156
|
-
var
|
|
8215
|
+
var _a;
|
|
8157
8216
|
if (!catalog) return catalog;
|
|
8158
8217
|
const next = ensureCatalog(catalog);
|
|
8159
8218
|
const idx = next.nodes.findIndex((x) => x.id === id);
|
|
@@ -8163,7 +8222,7 @@ function updateCatalogNode(catalog, id, patch) {
|
|
|
8163
8222
|
...current,
|
|
8164
8223
|
...patch
|
|
8165
8224
|
};
|
|
8166
|
-
if (((
|
|
8225
|
+
if (((_a = next.nodes[idx]) == null ? void 0 : _a.kind) === "group") {
|
|
8167
8226
|
next.nodes[idx] = {
|
|
8168
8227
|
...next.nodes[idx],
|
|
8169
8228
|
serviceIds: normalizeServiceIds(
|
|
@@ -8189,27 +8248,27 @@ function setSelectedCatalogService(catalog, serviceId) {
|
|
|
8189
8248
|
return next;
|
|
8190
8249
|
}
|
|
8191
8250
|
function toggleCatalogExpanded(catalog, id) {
|
|
8192
|
-
var
|
|
8251
|
+
var _a;
|
|
8193
8252
|
const next = ensureCatalog(catalog);
|
|
8194
|
-
const expanded = new Set((
|
|
8253
|
+
const expanded = new Set((_a = next.expandedIds) != null ? _a : []);
|
|
8195
8254
|
if (expanded.has(id)) expanded.delete(id);
|
|
8196
8255
|
else expanded.add(id);
|
|
8197
8256
|
next.expandedIds = Array.from(expanded);
|
|
8198
8257
|
return next;
|
|
8199
8258
|
}
|
|
8200
8259
|
function setCatalogExpanded(catalog, id, expanded) {
|
|
8201
|
-
var
|
|
8260
|
+
var _a;
|
|
8202
8261
|
const next = ensureCatalog(catalog);
|
|
8203
|
-
const set = new Set((
|
|
8262
|
+
const set = new Set((_a = next.expandedIds) != null ? _a : []);
|
|
8204
8263
|
if (expanded) set.add(id);
|
|
8205
8264
|
else set.delete(id);
|
|
8206
8265
|
next.expandedIds = Array.from(set);
|
|
8207
8266
|
return next;
|
|
8208
8267
|
}
|
|
8209
8268
|
function toggleCatalogPinned(catalog, id) {
|
|
8210
|
-
var
|
|
8269
|
+
var _a;
|
|
8211
8270
|
const next = ensureCatalog(catalog);
|
|
8212
|
-
const pinned = new Set((
|
|
8271
|
+
const pinned = new Set((_a = next.pinnedNodeIds) != null ? _a : []);
|
|
8213
8272
|
if (pinned.has(id)) pinned.delete(id);
|
|
8214
8273
|
else pinned.add(id);
|
|
8215
8274
|
next.pinnedNodeIds = Array.from(pinned);
|
|
@@ -8238,7 +8297,7 @@ function assignServicesToCatalogGroup(catalog, nodeId, serviceIds, mode = "appen
|
|
|
8238
8297
|
return next;
|
|
8239
8298
|
}
|
|
8240
8299
|
function removeCatalogNode(catalog, id, opts) {
|
|
8241
|
-
var
|
|
8300
|
+
var _a, _b;
|
|
8242
8301
|
if (!catalog) return catalog;
|
|
8243
8302
|
const next = ensureCatalog(catalog);
|
|
8244
8303
|
const ids = /* @__PURE__ */ new Set([id]);
|
|
@@ -8260,7 +8319,7 @@ function removeCatalogNode(catalog, id, opts) {
|
|
|
8260
8319
|
if (next.activeNodeId && ids.has(next.activeNodeId)) {
|
|
8261
8320
|
next.activeNodeId = void 0;
|
|
8262
8321
|
}
|
|
8263
|
-
next.expandedIds = ((
|
|
8322
|
+
next.expandedIds = ((_a = next.expandedIds) != null ? _a : []).filter((x) => !ids.has(x));
|
|
8264
8323
|
next.pinnedNodeIds = ((_b = next.pinnedNodeIds) != null ? _b : []).filter((x) => !ids.has(x));
|
|
8265
8324
|
return next;
|
|
8266
8325
|
}
|
|
@@ -8271,8 +8330,8 @@ function moveCatalogNode(catalog, nodeId, opts) {
|
|
|
8271
8330
|
if (!node) return next;
|
|
8272
8331
|
node.parentId = opts.parentId;
|
|
8273
8332
|
const siblings = next.nodes.filter((x) => x.parentId === opts.parentId && x.id !== nodeId).sort((a, b) => {
|
|
8274
|
-
var
|
|
8275
|
-
return ((
|
|
8333
|
+
var _a, _b;
|
|
8334
|
+
return ((_a = a.order) != null ? _a : 0) - ((_b = b.order) != null ? _b : 0);
|
|
8276
8335
|
});
|
|
8277
8336
|
let dest = typeof opts.index === "number" ? opts.index : siblings.length;
|
|
8278
8337
|
if (opts.beforeId) {
|
|
@@ -8291,20 +8350,20 @@ function moveCatalogNode(catalog, nodeId, opts) {
|
|
|
8291
8350
|
return next;
|
|
8292
8351
|
}
|
|
8293
8352
|
function resolveSmartCatalogGroup(catalog, nodeId, candidates, matchers) {
|
|
8294
|
-
var
|
|
8353
|
+
var _a, _b;
|
|
8295
8354
|
if (!catalog) return catalog;
|
|
8296
8355
|
const next = ensureCatalog(catalog);
|
|
8297
8356
|
const node = next.nodes.find(
|
|
8298
8357
|
(x) => x.id === nodeId && x.kind === "smart-group"
|
|
8299
8358
|
);
|
|
8300
8359
|
if (!node) return next;
|
|
8301
|
-
const rules = (
|
|
8360
|
+
const rules = (_a = node.rules) != null ? _a : [];
|
|
8302
8361
|
const mode = (_b = node.match) != null ? _b : "all";
|
|
8303
8362
|
const resolved = candidates.filter((candidate) => {
|
|
8304
8363
|
const results = rules.map((rule) => {
|
|
8305
|
-
var
|
|
8364
|
+
var _a2, _b2, _c, _d, _e, _f;
|
|
8306
8365
|
if (rule.type === "service-field") {
|
|
8307
|
-
return (_b2 = (
|
|
8366
|
+
return (_b2 = (_a2 = matchers.serviceField) == null ? void 0 : _a2.call(matchers, candidate, rule)) != null ? _b2 : false;
|
|
8308
8367
|
}
|
|
8309
8368
|
if (rule.type === "policy-family") {
|
|
8310
8369
|
return (_d = (_c = matchers.policyFamily) == null ? void 0 : _c.call(matchers, candidate, rule)) != null ? _d : false;
|
|
@@ -8325,14 +8384,14 @@ var Editor = class {
|
|
|
8325
8384
|
this.history = [];
|
|
8326
8385
|
this.index = -1;
|
|
8327
8386
|
this.txnDepth = 0;
|
|
8328
|
-
var
|
|
8387
|
+
var _a, _b;
|
|
8329
8388
|
this.builder = builder;
|
|
8330
8389
|
this.api = api;
|
|
8331
8390
|
this.opts = {
|
|
8332
8391
|
...opts,
|
|
8333
8392
|
historyLimit: Math.max(
|
|
8334
8393
|
1,
|
|
8335
|
-
Math.min((
|
|
8394
|
+
Math.min((_a = opts.historyLimit) != null ? _a : MAX_LIMIT, 1e3)
|
|
8336
8395
|
),
|
|
8337
8396
|
validateAfterEach: (_b = opts.validateAfterEach) != null ? _b : false
|
|
8338
8397
|
};
|
|
@@ -8375,14 +8434,14 @@ var Editor = class {
|
|
|
8375
8434
|
}
|
|
8376
8435
|
}
|
|
8377
8436
|
exec(cmd) {
|
|
8378
|
-
var
|
|
8437
|
+
var _a;
|
|
8379
8438
|
try {
|
|
8380
8439
|
const before = this.makeSnapshot(cmd.name + ":before");
|
|
8381
8440
|
cmd.do();
|
|
8382
8441
|
this.afterMutation(cmd.name, before);
|
|
8383
8442
|
} catch (err) {
|
|
8384
8443
|
this.emit("editor:error", {
|
|
8385
|
-
message: (
|
|
8444
|
+
message: (_a = err == null ? void 0 : err.message) != null ? _a : String(err),
|
|
8386
8445
|
code: "command"
|
|
8387
8446
|
});
|
|
8388
8447
|
throw err;
|
|
@@ -8471,6 +8530,36 @@ var Editor = class {
|
|
|
8471
8530
|
addField(partial) {
|
|
8472
8531
|
return addField(this.moduleCtx(), partial);
|
|
8473
8532
|
}
|
|
8533
|
+
addFieldFromDescriptor(registry, partial, opts) {
|
|
8534
|
+
var _a, _b, _c, _d, _e;
|
|
8535
|
+
const variant = (_b = opts == null ? void 0 : opts.variant) != null ? _b : typeof ((_a = partial == null ? void 0 : partial.meta) == null ? void 0 : _a.variant) === "string" ? partial.meta.variant : void 0;
|
|
8536
|
+
const descriptor = resolveInputDescriptor(
|
|
8537
|
+
registry,
|
|
8538
|
+
String(partial.type),
|
|
8539
|
+
variant
|
|
8540
|
+
);
|
|
8541
|
+
const nextMeta = {
|
|
8542
|
+
...(_c = partial.meta) != null ? _c : {}
|
|
8543
|
+
};
|
|
8544
|
+
if (((_d = descriptor == null ? void 0 : descriptor.multi) == null ? void 0 : _d.autoEnable) === true) {
|
|
8545
|
+
nextMeta.multi = true;
|
|
8546
|
+
}
|
|
8547
|
+
const fieldInput = {
|
|
8548
|
+
...partial,
|
|
8549
|
+
...Object.keys(nextMeta).length ? { meta: nextMeta } : {}
|
|
8550
|
+
};
|
|
8551
|
+
const fieldId = this.addField(fieldInput);
|
|
8552
|
+
if (((_e = descriptor == null ? void 0 : descriptor.options) == null ? void 0 : _e.autoCreate) === true) {
|
|
8553
|
+
this.autoCreateOptionsMany([fieldId], () => {
|
|
8554
|
+
var _a2, _b2, _c2, _d2;
|
|
8555
|
+
return {
|
|
8556
|
+
label: (_b2 = (_a2 = descriptor.options) == null ? void 0 : _a2.defaultLabel) != null ? _b2 : "Option label",
|
|
8557
|
+
value: (_d2 = (_c2 = descriptor.options) == null ? void 0 : _c2.defaultValue) != null ? _d2 : "option"
|
|
8558
|
+
};
|
|
8559
|
+
});
|
|
8560
|
+
}
|
|
8561
|
+
return fieldId;
|
|
8562
|
+
}
|
|
8474
8563
|
updateField(id, patch) {
|
|
8475
8564
|
return updateField(this.moduleCtx(), id, patch);
|
|
8476
8565
|
}
|
|
@@ -8488,10 +8577,10 @@ var Editor = class {
|
|
|
8488
8577
|
if (!ordered.length) return;
|
|
8489
8578
|
this.transact("clearServiceMany", () => {
|
|
8490
8579
|
this.patchProps((p) => {
|
|
8491
|
-
var
|
|
8580
|
+
var _a, _b, _c, _d;
|
|
8492
8581
|
for (const id of ordered) {
|
|
8493
8582
|
if (this.isTagId(id)) {
|
|
8494
|
-
const t = ((
|
|
8583
|
+
const t = ((_a = p.filters) != null ? _a : []).find((x) => x.id === id);
|
|
8495
8584
|
if (t && "service_id" in t) delete t.service_id;
|
|
8496
8585
|
continue;
|
|
8497
8586
|
}
|
|
@@ -8516,8 +8605,8 @@ var Editor = class {
|
|
|
8516
8605
|
if (!ordered.length) return;
|
|
8517
8606
|
this.transact("rebindMany", () => {
|
|
8518
8607
|
this.patchProps((p) => {
|
|
8519
|
-
var
|
|
8520
|
-
const targetExists = ((
|
|
8608
|
+
var _a, _b, _c;
|
|
8609
|
+
const targetExists = ((_a = p.filters) != null ? _a : []).some((t) => t.id === targetTagId);
|
|
8521
8610
|
if (!targetExists) return;
|
|
8522
8611
|
for (const id of ordered) {
|
|
8523
8612
|
if (this.isFieldId(id)) {
|
|
@@ -8553,10 +8642,10 @@ var Editor = class {
|
|
|
8553
8642
|
if (!selected.size) return;
|
|
8554
8643
|
this.transact("clearRelationsMany", () => {
|
|
8555
8644
|
this.patchProps((p) => {
|
|
8556
|
-
var
|
|
8645
|
+
var _a, _b, _c;
|
|
8557
8646
|
const clearOwned = mode === "owned" || mode === "both";
|
|
8558
8647
|
const clearIncoming = mode === "incoming" || mode === "both";
|
|
8559
|
-
for (const t of (
|
|
8648
|
+
for (const t of (_a = p.filters) != null ? _a : []) {
|
|
8560
8649
|
if (clearOwned && selected.has(t.id)) {
|
|
8561
8650
|
delete t.includes;
|
|
8562
8651
|
delete t.excludes;
|
|
@@ -8597,17 +8686,17 @@ var Editor = class {
|
|
|
8597
8686
|
});
|
|
8598
8687
|
}
|
|
8599
8688
|
renameLabelsMany(ids, input) {
|
|
8600
|
-
var
|
|
8689
|
+
var _a, _b;
|
|
8601
8690
|
const ordered = Array.from(new Set((ids != null ? ids : []).map((id) => String(id))));
|
|
8602
8691
|
if (!ordered.length) return;
|
|
8603
|
-
const prefix = (
|
|
8692
|
+
const prefix = (_a = input.prefix) != null ? _a : "";
|
|
8604
8693
|
const suffix = (_b = input.suffix) != null ? _b : "";
|
|
8605
8694
|
this.transact("renameLabelsMany", () => {
|
|
8606
8695
|
this.patchProps((p) => {
|
|
8607
|
-
var
|
|
8696
|
+
var _a2, _b2, _c, _d, _e, _f, _g;
|
|
8608
8697
|
for (const id of ordered) {
|
|
8609
8698
|
if (this.isTagId(id)) {
|
|
8610
|
-
const t = ((
|
|
8699
|
+
const t = ((_a2 = p.filters) != null ? _a2 : []).find((x) => x.id === id);
|
|
8611
8700
|
if (t) t.label = `${prefix}${(_b2 = t.label) != null ? _b2 : ""}${suffix}`.trim();
|
|
8612
8701
|
continue;
|
|
8613
8702
|
}
|
|
@@ -8643,10 +8732,10 @@ var Editor = class {
|
|
|
8643
8732
|
if (!ordered.length) return;
|
|
8644
8733
|
this.transact("clearFieldDefaultsMany", () => {
|
|
8645
8734
|
this.patchProps((p) => {
|
|
8646
|
-
var
|
|
8735
|
+
var _a;
|
|
8647
8736
|
for (const id of ordered) {
|
|
8648
8737
|
if (!this.isFieldId(id)) continue;
|
|
8649
|
-
const f = ((
|
|
8738
|
+
const f = ((_a = p.fields) != null ? _a : []).find((x) => x.id === id);
|
|
8650
8739
|
if (f && "defaults" in f) delete f.defaults;
|
|
8651
8740
|
}
|
|
8652
8741
|
});
|
|
@@ -8657,24 +8746,46 @@ var Editor = class {
|
|
|
8657
8746
|
if (!ordered.length) return;
|
|
8658
8747
|
this.transact("clearFieldValidationMany", () => {
|
|
8659
8748
|
this.patchProps((p) => {
|
|
8660
|
-
var
|
|
8749
|
+
var _a;
|
|
8661
8750
|
for (const id of ordered) {
|
|
8662
8751
|
if (!this.isFieldId(id)) continue;
|
|
8663
|
-
const f = ((
|
|
8752
|
+
const f = ((_a = p.fields) != null ? _a : []).find((x) => x.id === id);
|
|
8664
8753
|
if (f && "validation" in f) delete f.validation;
|
|
8665
8754
|
}
|
|
8666
8755
|
});
|
|
8667
8756
|
});
|
|
8668
8757
|
}
|
|
8758
|
+
setFieldMulti(fieldId, enabled) {
|
|
8759
|
+
const flag = enabled === true;
|
|
8760
|
+
this.transact("setFieldMulti", () => {
|
|
8761
|
+
this.patchProps((p) => {
|
|
8762
|
+
var _a, _b;
|
|
8763
|
+
const f = ((_a = p.fields) != null ? _a : []).find((x) => x.id === fieldId);
|
|
8764
|
+
if (!f) return;
|
|
8765
|
+
const currentMeta = (_b = f.meta) != null ? _b : {};
|
|
8766
|
+
const nextMeta = { ...currentMeta };
|
|
8767
|
+
if (flag) {
|
|
8768
|
+
nextMeta.multi = true;
|
|
8769
|
+
} else {
|
|
8770
|
+
delete nextMeta.multi;
|
|
8771
|
+
}
|
|
8772
|
+
if (Object.keys(nextMeta).length === 0) {
|
|
8773
|
+
delete f.meta;
|
|
8774
|
+
} else {
|
|
8775
|
+
f.meta = nextMeta;
|
|
8776
|
+
}
|
|
8777
|
+
});
|
|
8778
|
+
});
|
|
8779
|
+
}
|
|
8669
8780
|
autoCreateOptionsMany(ids, makeOption) {
|
|
8670
8781
|
const ordered = Array.from(new Set((ids != null ? ids : []).map((id) => String(id))));
|
|
8671
8782
|
if (!ordered.length) return;
|
|
8672
8783
|
this.transact("autoCreateOptionsMany", () => {
|
|
8673
8784
|
this.patchProps((p) => {
|
|
8674
|
-
var
|
|
8785
|
+
var _a, _b, _c, _d;
|
|
8675
8786
|
for (const id of ordered) {
|
|
8676
8787
|
if (!this.isFieldId(id)) continue;
|
|
8677
|
-
const f = ((
|
|
8788
|
+
const f = ((_a = p.fields) != null ? _a : []).find((x) => x.id === id);
|
|
8678
8789
|
if (!f) continue;
|
|
8679
8790
|
const opts = (_b = f.options) != null ? _b : f.options = [];
|
|
8680
8791
|
if (opts.length > 0) continue;
|
|
@@ -8689,14 +8800,14 @@ var Editor = class {
|
|
|
8689
8800
|
});
|
|
8690
8801
|
}
|
|
8691
8802
|
clearAllOptionsMany(ids) {
|
|
8692
|
-
var
|
|
8803
|
+
var _a, _b;
|
|
8693
8804
|
const ordered = Array.from(new Set((ids != null ? ids : []).map((id) => String(id))));
|
|
8694
8805
|
if (!ordered.length) return;
|
|
8695
8806
|
const optionIds = [];
|
|
8696
8807
|
const props = this.getProps();
|
|
8697
8808
|
for (const id of ordered) {
|
|
8698
8809
|
if (!this.isFieldId(id)) continue;
|
|
8699
|
-
const f = ((
|
|
8810
|
+
const f = ((_a = props.fields) != null ? _a : []).find((x) => x.id === id);
|
|
8700
8811
|
for (const o of (_b = f == null ? void 0 : f.options) != null ? _b : []) optionIds.push(o.id);
|
|
8701
8812
|
}
|
|
8702
8813
|
if (!optionIds.length) return;
|
|
@@ -8707,8 +8818,8 @@ var Editor = class {
|
|
|
8707
8818
|
if (!selected.size) return;
|
|
8708
8819
|
this.transact("removeNoticesForNodes", () => {
|
|
8709
8820
|
this.patchProps((p) => {
|
|
8710
|
-
var
|
|
8711
|
-
if (!((
|
|
8821
|
+
var _a;
|
|
8822
|
+
if (!((_a = p.notices) == null ? void 0 : _a.length)) return;
|
|
8712
8823
|
p.notices = p.notices.filter((n) => {
|
|
8713
8824
|
const target = n.target;
|
|
8714
8825
|
if (!target || target.scope === "global") return true;
|
|
@@ -8724,8 +8835,8 @@ var Editor = class {
|
|
|
8724
8835
|
if (!selected.size) return;
|
|
8725
8836
|
this.transact("setNoticesVisibilityForNodes", () => {
|
|
8726
8837
|
this.patchProps((p) => {
|
|
8727
|
-
var
|
|
8728
|
-
for (const n of (
|
|
8838
|
+
var _a;
|
|
8839
|
+
for (const n of (_a = p.notices) != null ? _a : []) {
|
|
8729
8840
|
const target = n.target;
|
|
8730
8841
|
if ((target == null ? void 0 : target.scope) === "node" && selected.has(String(target.node_id))) {
|
|
8731
8842
|
n.type = type;
|
|
@@ -8886,7 +8997,7 @@ var Editor = class {
|
|
|
8886
8997
|
);
|
|
8887
8998
|
}
|
|
8888
8999
|
resolveSmartCatalogGroup(nodeId, candidates, matchers) {
|
|
8889
|
-
var
|
|
9000
|
+
var _a, _b;
|
|
8890
9001
|
const next = resolveSmartCatalogGroup(
|
|
8891
9002
|
this.catalog,
|
|
8892
9003
|
nodeId,
|
|
@@ -8897,7 +9008,7 @@ var Editor = class {
|
|
|
8897
9008
|
const node = next == null ? void 0 : next.nodes.find(
|
|
8898
9009
|
(x) => x.id === nodeId && x.kind === "smart-group"
|
|
8899
9010
|
);
|
|
8900
|
-
return (_b = (
|
|
9011
|
+
return (_b = (_a = node == null ? void 0 : node.resolvedServiceIds) == null ? void 0 : _a.slice()) != null ? _b : [];
|
|
8901
9012
|
}
|
|
8902
9013
|
replaceCatalog(next, reason = "catalog:set") {
|
|
8903
9014
|
this.catalog = (0, import_lodash_es4.cloneDeep)(next);
|
|
@@ -9098,9 +9209,9 @@ var Selection = class {
|
|
|
9098
9209
|
}
|
|
9099
9210
|
// ── Main: visible group snapshot (env-aware) ─────────────────────────────
|
|
9100
9211
|
visibleGroup() {
|
|
9101
|
-
var
|
|
9212
|
+
var _a;
|
|
9102
9213
|
const props = this.builder.getProps();
|
|
9103
|
-
if (((
|
|
9214
|
+
if (((_a = this.opts.env) != null ? _a : "client") === "workspace") {
|
|
9104
9215
|
const tagIds = Array.from(this.set).filter(
|
|
9105
9216
|
this.builder.isTagId.bind(this.builder)
|
|
9106
9217
|
);
|
|
@@ -9131,12 +9242,12 @@ var Selection = class {
|
|
|
9131
9242
|
* - de-dupes per field
|
|
9132
9243
|
*/
|
|
9133
9244
|
buttonSelectionsByFieldId() {
|
|
9134
|
-
var
|
|
9245
|
+
var _a, _b, _c, _d, _e;
|
|
9135
9246
|
const nodeMap = this.builder.getNodeMap();
|
|
9136
9247
|
const out = {};
|
|
9137
9248
|
const push = (fieldId, triggerKey) => {
|
|
9138
|
-
var
|
|
9139
|
-
const arr = (
|
|
9249
|
+
var _a2;
|
|
9250
|
+
const arr = (_a2 = out[fieldId]) != null ? _a2 : out[fieldId] = [];
|
|
9140
9251
|
if (!arr.includes(triggerKey)) arr.push(triggerKey);
|
|
9141
9252
|
};
|
|
9142
9253
|
for (const key of this.set) {
|
|
@@ -9153,7 +9264,7 @@ var Selection = class {
|
|
|
9153
9264
|
const ref = nodeMap.get(key);
|
|
9154
9265
|
if (!ref) continue;
|
|
9155
9266
|
if (ref.kind === "option" && typeof ref.fieldId === "string") {
|
|
9156
|
-
push(ref.fieldId, (
|
|
9267
|
+
push(ref.fieldId, (_a = ref.id) != null ? _a : key);
|
|
9157
9268
|
continue;
|
|
9158
9269
|
}
|
|
9159
9270
|
if (ref.kind === "field") {
|
|
@@ -9174,7 +9285,7 @@ var Selection = class {
|
|
|
9174
9285
|
* Excludes tags and non-button fields.
|
|
9175
9286
|
*/
|
|
9176
9287
|
selectedButtons() {
|
|
9177
|
-
var
|
|
9288
|
+
var _a, _b;
|
|
9178
9289
|
const nodeMap = this.builder.getNodeMap();
|
|
9179
9290
|
const out = [];
|
|
9180
9291
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -9200,7 +9311,7 @@ var Selection = class {
|
|
|
9200
9311
|
continue;
|
|
9201
9312
|
}
|
|
9202
9313
|
if (ref.kind === "field") {
|
|
9203
|
-
const field = (_b = (
|
|
9314
|
+
const field = (_b = (_a = ref.node) != null ? _a : ref.field) != null ? _b : ref;
|
|
9204
9315
|
if ((field == null ? void 0 : field.button) === true) push(key);
|
|
9205
9316
|
}
|
|
9206
9317
|
}
|
|
@@ -9215,9 +9326,9 @@ var Selection = class {
|
|
|
9215
9326
|
for (const fn of this.onChangeFns) fn(payload);
|
|
9216
9327
|
}
|
|
9217
9328
|
updateCurrentTagFrom(id) {
|
|
9218
|
-
var
|
|
9329
|
+
var _a, _b;
|
|
9219
9330
|
const props = this.builder.getProps();
|
|
9220
|
-
const tags = (
|
|
9331
|
+
const tags = (_a = props.filters) != null ? _a : [];
|
|
9221
9332
|
const fields = (_b = props.fields) != null ? _b : [];
|
|
9222
9333
|
if (tags.some((t) => t.id === id)) {
|
|
9223
9334
|
this.currentTagId = id;
|
|
@@ -9233,8 +9344,8 @@ var Selection = class {
|
|
|
9233
9344
|
if (this.builder.isOptionId(id)) {
|
|
9234
9345
|
return fields.find(
|
|
9235
9346
|
(x) => {
|
|
9236
|
-
var
|
|
9237
|
-
return ((
|
|
9347
|
+
var _a2;
|
|
9348
|
+
return ((_a2 = x.options) != null ? _a2 : []).some((o) => o.id === id);
|
|
9238
9349
|
}
|
|
9239
9350
|
);
|
|
9240
9351
|
}
|
|
@@ -9261,10 +9372,10 @@ var Selection = class {
|
|
|
9261
9372
|
if (fallbackTagId) this.currentTagId = fallbackTagId;
|
|
9262
9373
|
}
|
|
9263
9374
|
resolveTagContextId(props) {
|
|
9264
|
-
var
|
|
9375
|
+
var _a;
|
|
9265
9376
|
if (this.currentTagId) return this.currentTagId;
|
|
9266
9377
|
for (const id of this.set) if (this.builder.isTagId(id)) return id;
|
|
9267
|
-
const fields = (
|
|
9378
|
+
const fields = (_a = props.fields) != null ? _a : [];
|
|
9268
9379
|
for (const id of this.set) {
|
|
9269
9380
|
const f = fields.find((x) => x.id === id);
|
|
9270
9381
|
if (f == null ? void 0 : f.bind_id)
|
|
@@ -9274,8 +9385,8 @@ var Selection = class {
|
|
|
9274
9385
|
if (this.builder.isOptionId(id)) {
|
|
9275
9386
|
const host = fields.find(
|
|
9276
9387
|
(x) => {
|
|
9277
|
-
var
|
|
9278
|
-
return ((
|
|
9388
|
+
var _a2;
|
|
9389
|
+
return ((_a2 = x.options) != null ? _a2 : []).some((o) => o.id === id);
|
|
9279
9390
|
}
|
|
9280
9391
|
);
|
|
9281
9392
|
if (host == null ? void 0 : host.bind_id)
|
|
@@ -9291,8 +9402,8 @@ var Selection = class {
|
|
|
9291
9402
|
return this.opts.rootTagId;
|
|
9292
9403
|
}
|
|
9293
9404
|
computeGroupForTag(props, tagId) {
|
|
9294
|
-
var
|
|
9295
|
-
const tags = (
|
|
9405
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
9406
|
+
const tags = (_a = props.filters) != null ? _a : [];
|
|
9296
9407
|
const fields = (_b = props.fields) != null ? _b : [];
|
|
9297
9408
|
const tagById = new Map(tags.map((t) => [t.id, t]));
|
|
9298
9409
|
const tag = tagById.get(tagId);
|
|
@@ -9376,10 +9487,10 @@ var Selection = class {
|
|
|
9376
9487
|
return baseOverridden;
|
|
9377
9488
|
}
|
|
9378
9489
|
findOptionById(fields, selId) {
|
|
9379
|
-
var
|
|
9490
|
+
var _a, _b;
|
|
9380
9491
|
if (this.builder.isOptionId(selId)) {
|
|
9381
9492
|
for (const f of fields) {
|
|
9382
|
-
const o = (
|
|
9493
|
+
const o = (_a = f.options) == null ? void 0 : _a.find((x) => x.id === selId);
|
|
9383
9494
|
if (o) return o;
|
|
9384
9495
|
}
|
|
9385
9496
|
}
|
|
@@ -9404,9 +9515,9 @@ var CanvasAPI = class {
|
|
|
9404
9515
|
/* ─── Option-node visibility (per field) ───────────────────────────────── */
|
|
9405
9516
|
/** Internal mirror of which fields should show their options as nodes. */
|
|
9406
9517
|
this.shownOptionFields = /* @__PURE__ */ new Set();
|
|
9407
|
-
var
|
|
9518
|
+
var _a, _b, _c;
|
|
9408
9519
|
this.builder = builder;
|
|
9409
|
-
this.autoEmit = (
|
|
9520
|
+
this.autoEmit = (_a = opts.autoEmitState) != null ? _a : true;
|
|
9410
9521
|
this.selection = new Selection(builder, {
|
|
9411
9522
|
env: "workspace",
|
|
9412
9523
|
rootTagId: "t:root"
|
|
@@ -9633,14 +9744,14 @@ function useOptionalFormApi() {
|
|
|
9633
9744
|
}
|
|
9634
9745
|
function FormProvider({ children, schema, initial }) {
|
|
9635
9746
|
const [bag, setBag] = React.useState(() => {
|
|
9636
|
-
var
|
|
9747
|
+
var _a;
|
|
9637
9748
|
return {
|
|
9638
|
-
...(
|
|
9749
|
+
...(_a = initial == null ? void 0 : initial.values) != null ? _a : {}
|
|
9639
9750
|
};
|
|
9640
9751
|
});
|
|
9641
9752
|
const [selectionsBag, setSelectionsBag] = React.useState(() => {
|
|
9642
|
-
var
|
|
9643
|
-
return { ...(
|
|
9753
|
+
var _a;
|
|
9754
|
+
return { ...(_a = initial == null ? void 0 : initial.selections) != null ? _a : {} };
|
|
9644
9755
|
});
|
|
9645
9756
|
const listenersRef = React.useRef(/* @__PURE__ */ new Set());
|
|
9646
9757
|
const publish = React.useCallback(() => {
|
|
@@ -9666,9 +9777,9 @@ function FormProvider({ children, schema, initial }) {
|
|
|
9666
9777
|
return () => listenersRef.current.delete(fn);
|
|
9667
9778
|
},
|
|
9668
9779
|
get(fieldId) {
|
|
9669
|
-
var
|
|
9780
|
+
var _a, _b;
|
|
9670
9781
|
const core = coreRef.current;
|
|
9671
|
-
const live = (_b = (
|
|
9782
|
+
const live = (_b = (_a = core == null ? void 0 : core.values) == null ? void 0 : _a.call(core)) != null ? _b : void 0;
|
|
9672
9783
|
if (live && fieldId in live) return live[fieldId];
|
|
9673
9784
|
return bag[fieldId];
|
|
9674
9785
|
},
|
|
@@ -9683,8 +9794,8 @@ function FormProvider({ children, schema, initial }) {
|
|
|
9683
9794
|
},
|
|
9684
9795
|
// Legacy selections API (compat; no longer used by the new Wrapper)
|
|
9685
9796
|
getSelections(fieldId) {
|
|
9686
|
-
var
|
|
9687
|
-
return (
|
|
9797
|
+
var _a;
|
|
9798
|
+
return (_a = selectionsBag[fieldId]) != null ? _a : [];
|
|
9688
9799
|
},
|
|
9689
9800
|
setSelections(fieldId, optionIds) {
|
|
9690
9801
|
setSelectionsBag((prev) => ({
|
|
@@ -9695,8 +9806,8 @@ function FormProvider({ children, schema, initial }) {
|
|
|
9695
9806
|
},
|
|
9696
9807
|
toggleSelection(fieldId, optionId) {
|
|
9697
9808
|
setSelectionsBag((prev) => {
|
|
9698
|
-
var
|
|
9699
|
-
const current = new Set((
|
|
9809
|
+
var _a;
|
|
9810
|
+
const current = new Set((_a = prev[fieldId]) != null ? _a : []);
|
|
9700
9811
|
if (current.has(optionId)) current.delete(optionId);
|
|
9701
9812
|
else current.add(optionId);
|
|
9702
9813
|
return { ...prev, [fieldId]: Array.from(current) };
|
|
@@ -9707,17 +9818,17 @@ function FormProvider({ children, schema, initial }) {
|
|
|
9707
9818
|
const [fieldId, optionId] = String(token).split(":", 2);
|
|
9708
9819
|
if (!fieldId || !optionId) return;
|
|
9709
9820
|
setSelectionsBag((prev) => {
|
|
9710
|
-
var
|
|
9711
|
-
const current = new Set((
|
|
9821
|
+
var _a;
|
|
9822
|
+
const current = new Set((_a = prev[fieldId]) != null ? _a : []);
|
|
9712
9823
|
current.delete(optionId);
|
|
9713
9824
|
return { ...prev, [fieldId]: Array.from(current) };
|
|
9714
9825
|
});
|
|
9715
9826
|
publish();
|
|
9716
9827
|
},
|
|
9717
9828
|
snapshot() {
|
|
9718
|
-
var
|
|
9829
|
+
var _a, _b;
|
|
9719
9830
|
const core = coreRef.current;
|
|
9720
|
-
const live = (_b = (
|
|
9831
|
+
const live = (_b = (_a = core == null ? void 0 : core.values) == null ? void 0 : _a.call(core)) != null ? _b : {};
|
|
9721
9832
|
return live;
|
|
9722
9833
|
},
|
|
9723
9834
|
submit() {
|
|
@@ -9753,40 +9864,6 @@ function FormProvider({ children, schema, initial }) {
|
|
|
9753
9864
|
) });
|
|
9754
9865
|
}
|
|
9755
9866
|
|
|
9756
|
-
// src/react/inputs/registry.ts
|
|
9757
|
-
function createInputRegistry() {
|
|
9758
|
-
const store = /* @__PURE__ */ new Map();
|
|
9759
|
-
const get = (kind, variant) => {
|
|
9760
|
-
var _a2;
|
|
9761
|
-
const vm = store.get(kind);
|
|
9762
|
-
if (!vm) return void 0;
|
|
9763
|
-
const v = variant != null ? variant : "default";
|
|
9764
|
-
return (_a2 = vm.get(v)) != null ? _a2 : vm.get("default");
|
|
9765
|
-
};
|
|
9766
|
-
const register = (kind, descriptor, variant) => {
|
|
9767
|
-
let vm = store.get(kind);
|
|
9768
|
-
if (!vm) {
|
|
9769
|
-
vm = /* @__PURE__ */ new Map();
|
|
9770
|
-
store.set(kind, vm);
|
|
9771
|
-
}
|
|
9772
|
-
vm.set(variant != null ? variant : "default", descriptor);
|
|
9773
|
-
};
|
|
9774
|
-
const unregister = (kind, variant) => {
|
|
9775
|
-
const vm = store.get(kind);
|
|
9776
|
-
if (!vm) return;
|
|
9777
|
-
const key = variant != null ? variant : "default";
|
|
9778
|
-
vm.delete(key);
|
|
9779
|
-
if (vm.size === 0) store.delete(kind);
|
|
9780
|
-
};
|
|
9781
|
-
const registerMany = (entries) => {
|
|
9782
|
-
for (const e of entries) register(e.kind, e.descriptor, e.variant);
|
|
9783
|
-
};
|
|
9784
|
-
return { get, register, unregister, registerMany, _store: store };
|
|
9785
|
-
}
|
|
9786
|
-
function resolveInputDescriptor(registry, kind, variant) {
|
|
9787
|
-
return registry.get(kind, variant);
|
|
9788
|
-
}
|
|
9789
|
-
|
|
9790
9867
|
// src/react/inputs/provider.tsx
|
|
9791
9868
|
var import_react2 = require("react");
|
|
9792
9869
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
@@ -9846,9 +9923,9 @@ function findDefaultTagId(tags) {
|
|
|
9846
9923
|
return hasRoot ? ROOT_TAG_ID : tags[0].id;
|
|
9847
9924
|
}
|
|
9848
9925
|
function mapSnapshotFormToFieldIds(builder, snap) {
|
|
9849
|
-
var
|
|
9926
|
+
var _a, _b, _c, _d, _e;
|
|
9850
9927
|
const byFieldId = {};
|
|
9851
|
-
const form = (_b = (
|
|
9928
|
+
const form = (_b = (_a = snap.inputs) == null ? void 0 : _a.form) != null ? _b : {};
|
|
9852
9929
|
const fields = (_c = builder.getProps().fields) != null ? _c : [];
|
|
9853
9930
|
const nameToIds = /* @__PURE__ */ new Map();
|
|
9854
9931
|
for (const f of fields) {
|
|
@@ -9874,8 +9951,8 @@ function makeDefaultFallback(mode, patch) {
|
|
|
9874
9951
|
};
|
|
9875
9952
|
}
|
|
9876
9953
|
function normalizeInit(init) {
|
|
9877
|
-
var
|
|
9878
|
-
const mode = (
|
|
9954
|
+
var _a, _b, _c;
|
|
9955
|
+
const mode = (_a = init.mode) != null ? _a : "prod";
|
|
9879
9956
|
const hostDefaultQuantity = Number.isFinite((_b = init.hostDefaultQuantity) != null ? _b : 1) ? Number((_c = init.hostDefaultQuantity) != null ? _c : 1) : 1;
|
|
9880
9957
|
return { ...init, mode, hostDefaultQuantity };
|
|
9881
9958
|
}
|
|
@@ -9917,8 +9994,8 @@ var OrderFlowProvider = (0, import_react4.forwardRef)(function OrderFlowProvider
|
|
|
9917
9994
|
const bump = () => force((x) => x + 1);
|
|
9918
9995
|
const resolveBuilder = (0, import_react4.useCallback)(
|
|
9919
9996
|
(p) => {
|
|
9920
|
-
var
|
|
9921
|
-
if ((
|
|
9997
|
+
var _a, _b;
|
|
9998
|
+
if ((_a = p.flow) == null ? void 0 : _a.builder) return p.flow.builder;
|
|
9922
9999
|
if (p.builder) return p.builder;
|
|
9923
10000
|
if (p.serviceProps) {
|
|
9924
10001
|
const b = createBuilder((_b = p.builderOptions) != null ? _b : {});
|
|
@@ -9954,8 +10031,8 @@ var OrderFlowProvider = (0, import_react4.forwardRef)(function OrderFlowProvider
|
|
|
9954
10031
|
}, []);
|
|
9955
10032
|
const resolveSelection = (0, import_react4.useCallback)(
|
|
9956
10033
|
(b, nInit, p) => {
|
|
9957
|
-
var
|
|
9958
|
-
return (_c = (_b = (
|
|
10034
|
+
var _a, _b, _c;
|
|
10035
|
+
return (_c = (_b = (_a = p.flow) == null ? void 0 : _a.selection) != null ? _b : p.selection) != null ? _c : new Selection(b, {
|
|
9959
10036
|
env: "client",
|
|
9960
10037
|
rootTagId: ROOT_TAG_ID,
|
|
9961
10038
|
resolveService: nInit.resolveService
|
|
@@ -9985,7 +10062,7 @@ var OrderFlowProvider = (0, import_react4.forwardRef)(function OrderFlowProvider
|
|
|
9985
10062
|
}, []);
|
|
9986
10063
|
const initialize = (0, import_react4.useCallback)(
|
|
9987
10064
|
(params) => {
|
|
9988
|
-
var
|
|
10065
|
+
var _a, _b, _c, _d, _e, _f;
|
|
9989
10066
|
const b = resolveBuilder(params);
|
|
9990
10067
|
if (!b) {
|
|
9991
10068
|
throw new Error(
|
|
@@ -10005,7 +10082,7 @@ var OrderFlowProvider = (0, import_react4.forwardRef)(function OrderFlowProvider
|
|
|
10005
10082
|
unsubRef.current = sel.onChange(
|
|
10006
10083
|
() => setActiveTagId(sel.currentTag())
|
|
10007
10084
|
);
|
|
10008
|
-
const tags = (
|
|
10085
|
+
const tags = (_a = b.getProps().filters) != null ? _a : [];
|
|
10009
10086
|
const hydratedTag = (_c = (_b = nInit.hydrateFrom) == null ? void 0 : _b.selection) == null ? void 0 : _c.tag;
|
|
10010
10087
|
const initialTag = nInit.hydrateFrom ? hydratedTag : (_d = nInit.initialTagId) != null ? _d : findDefaultTagId(tags);
|
|
10011
10088
|
if (initialTag) sel.replace(initialTag);
|
|
@@ -10058,14 +10135,14 @@ var OrderFlowProvider = (0, import_react4.forwardRef)(function OrderFlowProvider
|
|
|
10058
10135
|
serviceProps
|
|
10059
10136
|
]);
|
|
10060
10137
|
(0, import_react4.useEffect)(() => {
|
|
10061
|
-
var
|
|
10138
|
+
var _a, _b, _c, _d, _e;
|
|
10062
10139
|
if (!serviceProps) return;
|
|
10063
10140
|
if (!ready()) return;
|
|
10064
10141
|
const currentBuilder = builderRef.current;
|
|
10065
10142
|
if (!currentBuilder || currentBuilder !== resolvedBuilder) return;
|
|
10066
10143
|
if (!sameServiceProps(currentBuilder.getProps(), serviceProps)) {
|
|
10067
10144
|
currentBuilder.load(serviceProps);
|
|
10068
|
-
const currentTag = (
|
|
10145
|
+
const currentTag = (_a = selectionRef.current) == null ? void 0 : _a.currentTag();
|
|
10069
10146
|
if (selectionRef.current && currentTag && !currentBuilder.isTagId(currentTag)) {
|
|
10070
10147
|
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;
|
|
10071
10148
|
if (nextTag) selectionRef.current.replace(nextTag);
|
|
@@ -10087,12 +10164,12 @@ var OrderFlowProvider = (0, import_react4.forwardRef)(function OrderFlowProvider
|
|
|
10087
10164
|
[ensureReady]
|
|
10088
10165
|
);
|
|
10089
10166
|
const clearAllFields = (0, import_react4.useCallback)(() => {
|
|
10090
|
-
var
|
|
10167
|
+
var _a;
|
|
10091
10168
|
const api = formApiRef.current;
|
|
10092
10169
|
if (!api) return;
|
|
10093
10170
|
const b = builderRef.current;
|
|
10094
10171
|
if (!b) return;
|
|
10095
|
-
const fields = (
|
|
10172
|
+
const fields = (_a = b.getProps().fields) != null ? _a : [];
|
|
10096
10173
|
for (const f of fields) {
|
|
10097
10174
|
api.set(f.id, void 0);
|
|
10098
10175
|
api.setSelections(f.id, []);
|
|
@@ -10100,11 +10177,11 @@ var OrderFlowProvider = (0, import_react4.forwardRef)(function OrderFlowProvider
|
|
|
10100
10177
|
}, []);
|
|
10101
10178
|
const setSnapshot = (0, import_react4.useCallback)(
|
|
10102
10179
|
(snap, opts) => {
|
|
10103
|
-
var
|
|
10180
|
+
var _a, _b, _c, _d;
|
|
10104
10181
|
const api = formApiRef.current;
|
|
10105
10182
|
if (!api) return;
|
|
10106
10183
|
const { builder, selection } = ensureReady("setSnapshot");
|
|
10107
|
-
const clearFirst = (
|
|
10184
|
+
const clearFirst = (_a = opts == null ? void 0 : opts.clearFirst) != null ? _a : true;
|
|
10108
10185
|
const tag = (_b = snap.selection) == null ? void 0 : _b.tag;
|
|
10109
10186
|
if (tag) selection.replace(tag);
|
|
10110
10187
|
if (clearFirst) clearAllFields();
|
|
@@ -10119,8 +10196,8 @@ var OrderFlowProvider = (0, import_react4.forwardRef)(function OrderFlowProvider
|
|
|
10119
10196
|
);
|
|
10120
10197
|
const reset = (0, import_react4.useCallback)(
|
|
10121
10198
|
(opts) => {
|
|
10122
|
-
var
|
|
10123
|
-
const keepTag = (
|
|
10199
|
+
var _a, _b, _c, _d;
|
|
10200
|
+
const keepTag = (_a = opts == null ? void 0 : opts.keepTag) != null ? _a : false;
|
|
10124
10201
|
const { builder, selection } = ensureReady("reset");
|
|
10125
10202
|
if (!keepTag) {
|
|
10126
10203
|
const tags = (_b = builder.getProps().filters) != null ? _b : [];
|
|
@@ -10150,10 +10227,10 @@ var OrderFlowProvider = (0, import_react4.forwardRef)(function OrderFlowProvider
|
|
|
10150
10227
|
return mapSnapshotFormToFieldIds(b, i.hydrateFrom);
|
|
10151
10228
|
}, [force]);
|
|
10152
10229
|
const initialSelections = (0, import_react4.useMemo)(() => {
|
|
10153
|
-
var
|
|
10230
|
+
var _a, _b;
|
|
10154
10231
|
const i = initRef.current;
|
|
10155
10232
|
if (!(i == null ? void 0 : i.hydrateFrom)) return {};
|
|
10156
|
-
return (_b = (
|
|
10233
|
+
return (_b = (_a = i.hydrateFrom.inputs) == null ? void 0 : _a.selections) != null ? _b : {};
|
|
10157
10234
|
}, [force]);
|
|
10158
10235
|
(0, import_react4.useImperativeHandle)(
|
|
10159
10236
|
ref,
|
|
@@ -10168,8 +10245,8 @@ var OrderFlowProvider = (0, import_react4.forwardRef)(function OrderFlowProvider
|
|
|
10168
10245
|
setSnapshot,
|
|
10169
10246
|
reset,
|
|
10170
10247
|
refresh: () => {
|
|
10171
|
-
var
|
|
10172
|
-
return setActiveTagId((
|
|
10248
|
+
var _a;
|
|
10249
|
+
return setActiveTagId((_a = selectionRef.current) == null ? void 0 : _a.currentTag());
|
|
10173
10250
|
}
|
|
10174
10251
|
}),
|
|
10175
10252
|
[
|
|
@@ -10218,8 +10295,8 @@ var OrderFlowProvider = (0, import_react4.forwardRef)(function OrderFlowProvider
|
|
|
10218
10295
|
|
|
10219
10296
|
// src/react/hooks/evalute-field-validation.ts
|
|
10220
10297
|
function evaluateFieldValidationRule(rule, raw) {
|
|
10221
|
-
var
|
|
10222
|
-
const valueBy = (
|
|
10298
|
+
var _a, _b;
|
|
10299
|
+
const valueBy = (_a = rule.valueBy) != null ? _a : "value";
|
|
10223
10300
|
let subject = raw;
|
|
10224
10301
|
if (valueBy === "length") {
|
|
10225
10302
|
if (typeof raw === "string" || Array.isArray(raw)) subject = raw.length;
|
|
@@ -10264,11 +10341,11 @@ function evaluateFieldValidationRule(rule, raw) {
|
|
|
10264
10341
|
}
|
|
10265
10342
|
}
|
|
10266
10343
|
function validateVisibleFields(visibleFieldIds, fieldById, formValuesByFieldId) {
|
|
10267
|
-
var
|
|
10344
|
+
var _a;
|
|
10268
10345
|
const out = [];
|
|
10269
10346
|
for (const fid of visibleFieldIds) {
|
|
10270
10347
|
const field = fieldById.get(fid);
|
|
10271
|
-
if (!((
|
|
10348
|
+
if (!((_a = field == null ? void 0 : field.validation) == null ? void 0 : _a.length)) continue;
|
|
10272
10349
|
const value = formValuesByFieldId[fid];
|
|
10273
10350
|
for (const rule of field.validation) {
|
|
10274
10351
|
const ok = evaluateFieldValidationRule(rule, value);
|
|
@@ -10288,7 +10365,7 @@ function validateVisibleFields(visibleFieldIds, fieldById, formValuesByFieldId)
|
|
|
10288
10365
|
// src/react/hooks/use-order-flow.ts
|
|
10289
10366
|
var ROOT_TAG_ID2 = "t:root";
|
|
10290
10367
|
function useOrderFlow() {
|
|
10291
|
-
var
|
|
10368
|
+
var _a, _b, _c;
|
|
10292
10369
|
const ctx = useOrderFlowContext();
|
|
10293
10370
|
const ready = ctx.ready();
|
|
10294
10371
|
const initialize = (0, import_react6.useCallback)(
|
|
@@ -10314,22 +10391,22 @@ function useOrderFlow() {
|
|
|
10314
10391
|
return ctx.formApi.subscribe(() => setFormTick((x) => x + 1));
|
|
10315
10392
|
}, [ctx.formApi]);
|
|
10316
10393
|
const visibleGroup = (0, import_react6.useMemo)(() => {
|
|
10317
|
-
var
|
|
10394
|
+
var _a2;
|
|
10318
10395
|
if (!ready) return null;
|
|
10319
10396
|
const sel = ctx.selection;
|
|
10320
10397
|
if (!sel) return null;
|
|
10321
10398
|
const vg = sel.visibleGroup();
|
|
10322
10399
|
if (vg.kind !== "single") return null;
|
|
10323
|
-
return (
|
|
10400
|
+
return (_a2 = vg.group) != null ? _a2 : null;
|
|
10324
10401
|
}, [ready, ctx.selection, selTick]);
|
|
10325
10402
|
const activeTagId = (0, import_react6.useMemo)(() => {
|
|
10326
|
-
var
|
|
10403
|
+
var _a2, _b2, _c2;
|
|
10327
10404
|
if (!ready) return void 0;
|
|
10328
|
-
return (_c2 = (_b2 = (
|
|
10405
|
+
return (_c2 = (_b2 = (_a2 = ctx.selection) == null ? void 0 : _a2.currentTag) == null ? void 0 : _b2.call(_a2)) != null ? _c2 : ctx.activeTagId;
|
|
10329
10406
|
}, [ready, ctx.selection, ctx.activeTagId, selTick]);
|
|
10330
10407
|
const formValuesByFieldId = (0, import_react6.useMemo)(() => {
|
|
10331
|
-
var
|
|
10332
|
-
const values = (_c2 = (_b2 = (
|
|
10408
|
+
var _a2, _b2, _c2;
|
|
10409
|
+
const values = (_c2 = (_b2 = (_a2 = ctx.formApi).snapshot) == null ? void 0 : _b2.call(_a2)) != null ? _c2 : {};
|
|
10333
10410
|
return values;
|
|
10334
10411
|
}, [ctx.formApi, formTick]);
|
|
10335
10412
|
const optionSelectionsByFieldId = (0, import_react6.useMemo)(
|
|
@@ -10337,7 +10414,7 @@ function useOrderFlow() {
|
|
|
10337
10414
|
[]
|
|
10338
10415
|
);
|
|
10339
10416
|
const previewSnapshot = (0, import_react6.useMemo)(() => {
|
|
10340
|
-
var
|
|
10417
|
+
var _a2, _b2, _c2;
|
|
10341
10418
|
if (!ready) {
|
|
10342
10419
|
return {
|
|
10343
10420
|
version: "1",
|
|
@@ -10352,7 +10429,7 @@ function useOrderFlow() {
|
|
|
10352
10429
|
max: 1,
|
|
10353
10430
|
serviceMap: {},
|
|
10354
10431
|
meta: {
|
|
10355
|
-
schema_version: (
|
|
10432
|
+
schema_version: (_a2 = propsRef.current) == null ? void 0 : _a2.schema_version,
|
|
10356
10433
|
context: {
|
|
10357
10434
|
tag: "unknown",
|
|
10358
10435
|
constraints: {},
|
|
@@ -10394,7 +10471,7 @@ function useOrderFlow() {
|
|
|
10394
10471
|
selTick
|
|
10395
10472
|
]);
|
|
10396
10473
|
const pricingPreview = (0, import_react6.useMemo)(() => {
|
|
10397
|
-
var
|
|
10474
|
+
var _a2, _b2, _c2, _d, _e, _f;
|
|
10398
10475
|
const empty = {
|
|
10399
10476
|
unitRate: 0,
|
|
10400
10477
|
base: 0,
|
|
@@ -10404,7 +10481,7 @@ function useOrderFlow() {
|
|
|
10404
10481
|
};
|
|
10405
10482
|
if (!ready) return empty;
|
|
10406
10483
|
const { init } = ctx.ensureReady("pricingPreview");
|
|
10407
|
-
const normalizeRate = (
|
|
10484
|
+
const normalizeRate = (_a2 = init.normalizeRate) != null ? _a2 : ((s) => Number(s == null ? void 0 : s.rate));
|
|
10408
10485
|
const quantity = Number((_b2 = previewSnapshot.quantity) != null ? _b2 : 1) || 1;
|
|
10409
10486
|
let bestId;
|
|
10410
10487
|
let bestRate = 0;
|
|
@@ -10462,18 +10539,80 @@ function useOrderFlow() {
|
|
|
10462
10539
|
}, [ready, ctx, previewSnapshot]);
|
|
10463
10540
|
const selectTag = (0, import_react6.useCallback)(
|
|
10464
10541
|
(tagId) => {
|
|
10465
|
-
var
|
|
10542
|
+
var _a2, _b2;
|
|
10466
10543
|
ctx.ensureReady("selectTag");
|
|
10467
|
-
(_b2 = (
|
|
10544
|
+
(_b2 = (_a2 = ctx.selection) == null ? void 0 : _a2.replace) == null ? void 0 : _b2.call(_a2, tagId);
|
|
10468
10545
|
ctx.setActiveTag(tagId);
|
|
10469
10546
|
},
|
|
10470
10547
|
[ctx]
|
|
10471
10548
|
);
|
|
10472
10549
|
const toggleOption = (0, import_react6.useCallback)(
|
|
10473
10550
|
(fieldId, optionId) => {
|
|
10474
|
-
var
|
|
10551
|
+
var _a2, _b2;
|
|
10475
10552
|
const token = optionId != null ? optionId : fieldId;
|
|
10476
|
-
(_b2 = (
|
|
10553
|
+
(_b2 = (_a2 = ctx.selection) == null ? void 0 : _a2.toggle) == null ? void 0 : _b2.call(_a2, token);
|
|
10554
|
+
},
|
|
10555
|
+
[ctx]
|
|
10556
|
+
);
|
|
10557
|
+
const setFieldOptions = (0, import_react6.useCallback)(
|
|
10558
|
+
(fieldId, optionIds) => {
|
|
10559
|
+
var _a2, _b2, _c2, _d;
|
|
10560
|
+
const { builder, selection, init } = ctx.ensureReady(
|
|
10561
|
+
"setFieldOptions"
|
|
10562
|
+
);
|
|
10563
|
+
const fields = (_a2 = builder.getProps().fields) != null ? _a2 : [];
|
|
10564
|
+
const field = fields.find((f) => f.id === fieldId);
|
|
10565
|
+
if (!field) return;
|
|
10566
|
+
const validOptionIds = new Set(
|
|
10567
|
+
((_b2 = field.options) != null ? _b2 : []).map((option) => String(option.id))
|
|
10568
|
+
);
|
|
10569
|
+
const dedupedValid = [];
|
|
10570
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10571
|
+
for (const rawOptionId of optionIds != null ? optionIds : []) {
|
|
10572
|
+
const optionId = String(rawOptionId);
|
|
10573
|
+
if (!validOptionIds.has(optionId)) continue;
|
|
10574
|
+
if (seen.has(optionId)) continue;
|
|
10575
|
+
seen.add(optionId);
|
|
10576
|
+
dedupedValid.push(optionId);
|
|
10577
|
+
}
|
|
10578
|
+
const mode = (_c2 = init.mode) != null ? _c2 : "prod";
|
|
10579
|
+
const isMulti = ((_d = field.meta) == null ? void 0 : _d.multi) === true;
|
|
10580
|
+
const normalized = mode === "prod" && !isMulti ? dedupedValid.length ? [dedupedValid[dedupedValid.length - 1]] : [] : dedupedValid;
|
|
10581
|
+
const fieldById = new Map(fields.map((f) => [f.id, f]));
|
|
10582
|
+
const nodeMap = builder.getNodeMap();
|
|
10583
|
+
const resolveOptionOwnerFieldId = (token) => {
|
|
10584
|
+
var _a3;
|
|
10585
|
+
if (!token) return void 0;
|
|
10586
|
+
if (token.includes("::")) {
|
|
10587
|
+
const [legacyFieldId, optionId] = token.split("::", 2);
|
|
10588
|
+
if (!optionId) return void 0;
|
|
10589
|
+
const optionRef2 = nodeMap.get(optionId);
|
|
10590
|
+
if ((optionRef2 == null ? void 0 : optionRef2.kind) === "option" && typeof optionRef2.fieldId === "string") {
|
|
10591
|
+
return optionRef2.fieldId;
|
|
10592
|
+
}
|
|
10593
|
+
if (legacyFieldId && fieldById.has(legacyFieldId)) {
|
|
10594
|
+
return legacyFieldId;
|
|
10595
|
+
}
|
|
10596
|
+
return void 0;
|
|
10597
|
+
}
|
|
10598
|
+
const optionRef = nodeMap.get(token);
|
|
10599
|
+
if ((optionRef == null ? void 0 : optionRef.kind) === "option" && typeof optionRef.fieldId === "string") {
|
|
10600
|
+
return optionRef.fieldId;
|
|
10601
|
+
}
|
|
10602
|
+
for (const f of fields) {
|
|
10603
|
+
if ((_a3 = f.options) == null ? void 0 : _a3.some((option) => option.id === token)) {
|
|
10604
|
+
return f.id;
|
|
10605
|
+
}
|
|
10606
|
+
}
|
|
10607
|
+
return void 0;
|
|
10608
|
+
};
|
|
10609
|
+
const retained = Array.from(selection.all()).filter(
|
|
10610
|
+
(token) => resolveOptionOwnerFieldId(token) !== fieldId
|
|
10611
|
+
);
|
|
10612
|
+
for (const optionId of normalized) {
|
|
10613
|
+
if (!retained.includes(optionId)) retained.push(optionId);
|
|
10614
|
+
}
|
|
10615
|
+
selection.many(retained, retained[retained.length - 1]);
|
|
10477
10616
|
},
|
|
10478
10617
|
[ctx]
|
|
10479
10618
|
);
|
|
@@ -10485,9 +10624,9 @@ function useOrderFlow() {
|
|
|
10485
10624
|
);
|
|
10486
10625
|
const clearField = (0, import_react6.useCallback)(
|
|
10487
10626
|
(fieldId) => {
|
|
10488
|
-
var
|
|
10627
|
+
var _a2, _b2;
|
|
10489
10628
|
ctx.formApi.set(fieldId, void 0);
|
|
10490
|
-
(_b2 = (
|
|
10629
|
+
(_b2 = (_a2 = ctx.selection) == null ? void 0 : _a2.remove) == null ? void 0 : _b2.call(_a2, fieldId);
|
|
10491
10630
|
},
|
|
10492
10631
|
[ctx]
|
|
10493
10632
|
);
|
|
@@ -10506,14 +10645,14 @@ function useOrderFlow() {
|
|
|
10506
10645
|
[ctx]
|
|
10507
10646
|
);
|
|
10508
10647
|
const buildSnapshot = (0, import_react6.useCallback)(() => {
|
|
10509
|
-
var
|
|
10648
|
+
var _a2, _b2, _c2, _d, _e, _f;
|
|
10510
10649
|
const { builder, selection, init } = ctx.ensureReady("buildSnapshot");
|
|
10511
10650
|
const tagId = selection.currentTag();
|
|
10512
10651
|
const selectedKeys = selection.selectedButtons();
|
|
10513
10652
|
if (!tagId) {
|
|
10514
10653
|
throw new Error("OrderFlow: no active tag/context selected");
|
|
10515
10654
|
}
|
|
10516
|
-
const mode = (
|
|
10655
|
+
const mode = (_a2 = init.mode) != null ? _a2 : "prod";
|
|
10517
10656
|
const hostDefaultQuantity = Number((_b2 = init.hostDefaultQuantity) != null ? _b2 : 1) || 1;
|
|
10518
10657
|
const submitted = ctx.formApi.submit();
|
|
10519
10658
|
const values = submitted.values;
|
|
@@ -10554,13 +10693,13 @@ function useOrderFlow() {
|
|
|
10554
10693
|
);
|
|
10555
10694
|
}, [ctx, optionSelectionsByFieldId]);
|
|
10556
10695
|
const raw = (0, import_react6.useMemo)(() => {
|
|
10557
|
-
var
|
|
10558
|
-
if (!ready) return (
|
|
10696
|
+
var _a2;
|
|
10697
|
+
if (!ready) return (_a2 = propsRef.current) != null ? _a2 : {};
|
|
10559
10698
|
return ctx.ensureReady("raw").builder.getProps();
|
|
10560
10699
|
}, [ctx, ready, selTick]);
|
|
10561
10700
|
const notices = (0, import_react6.useMemo)(() => {
|
|
10562
|
-
var
|
|
10563
|
-
return (
|
|
10701
|
+
var _a2;
|
|
10702
|
+
return (_a2 = raw.notices) != null ? _a2 : [];
|
|
10564
10703
|
}, [raw]);
|
|
10565
10704
|
return {
|
|
10566
10705
|
ready,
|
|
@@ -10575,10 +10714,11 @@ function useOrderFlow() {
|
|
|
10575
10714
|
services: previewSnapshot.services,
|
|
10576
10715
|
serviceMap: previewSnapshot.serviceMap,
|
|
10577
10716
|
pricingPreview,
|
|
10578
|
-
min: (
|
|
10717
|
+
min: (_a = previewSnapshot.min) != null ? _a : 1,
|
|
10579
10718
|
max: (_c = (_b = previewSnapshot.max) != null ? _b : previewSnapshot.min) != null ? _c : 1,
|
|
10580
10719
|
selectTag,
|
|
10581
10720
|
toggleOption,
|
|
10721
|
+
setFieldOptions,
|
|
10582
10722
|
setValue,
|
|
10583
10723
|
clearField,
|
|
10584
10724
|
reset,
|
|
@@ -10595,8 +10735,8 @@ function toKind(field) {
|
|
|
10595
10735
|
return field.type;
|
|
10596
10736
|
}
|
|
10597
10737
|
function toVariant(field) {
|
|
10598
|
-
var
|
|
10599
|
-
const v = (
|
|
10738
|
+
var _a;
|
|
10739
|
+
const v = (_a = field.meta) == null ? void 0 : _a.variant;
|
|
10600
10740
|
return typeof v === "string" && v.trim() ? v : void 0;
|
|
10601
10741
|
}
|
|
10602
10742
|
function getPath(ctx, path) {
|
|
@@ -10669,7 +10809,7 @@ function Wrapper({
|
|
|
10669
10809
|
ctxOverrides,
|
|
10670
10810
|
className = ""
|
|
10671
10811
|
}) {
|
|
10672
|
-
var
|
|
10812
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
10673
10813
|
const { registry } = useInputs();
|
|
10674
10814
|
const flow = useOrderFlow();
|
|
10675
10815
|
const kind = toKind(field);
|
|
@@ -10683,11 +10823,11 @@ function Wrapper({
|
|
|
10683
10823
|
return null;
|
|
10684
10824
|
}
|
|
10685
10825
|
const Component = descriptor.Component;
|
|
10686
|
-
const adapter = (
|
|
10826
|
+
const adapter = (_a = descriptor.adapter) != null ? _a : {};
|
|
10687
10827
|
const baseProps = (_b = descriptor.defaultProps) != null ? _b : {};
|
|
10688
10828
|
const defaultProps = (0, import_react7.useMemo)(() => {
|
|
10689
|
-
var
|
|
10690
|
-
return { ...baseProps, ...(
|
|
10829
|
+
var _a2;
|
|
10830
|
+
return { ...baseProps, ...(_a2 = field.defaults) != null ? _a2 : {} };
|
|
10691
10831
|
}, [baseProps, field.defaults]);
|
|
10692
10832
|
const valueProp = (_c = adapter.valueProp) != null ? _c : "value";
|
|
10693
10833
|
const changeProp = (_d = adapter.changeProp) != null ? _d : "onChange";
|
|
@@ -10702,23 +10842,19 @@ function Wrapper({
|
|
|
10702
10842
|
disabled: !!disabled
|
|
10703
10843
|
});
|
|
10704
10844
|
const optionIds = React4.useMemo(() => {
|
|
10705
|
-
var
|
|
10845
|
+
var _a2;
|
|
10706
10846
|
if (!isOptionBased2) return /* @__PURE__ */ new Set();
|
|
10707
|
-
return new Set(((
|
|
10847
|
+
return new Set(((_a2 = field.options) != null ? _a2 : []).map((o) => o.id));
|
|
10708
10848
|
}, [isOptionBased2, field.options]);
|
|
10709
|
-
const prevSelectedRef = React4.useRef([]);
|
|
10710
|
-
React4.useEffect(() => {
|
|
10711
|
-
prevSelectedRef.current = [];
|
|
10712
|
-
}, [field.id]);
|
|
10713
10849
|
const adapterCtx = React4.useMemo(
|
|
10714
10850
|
() => ({ field, props: flow.raw }),
|
|
10715
10851
|
[field, flow.raw]
|
|
10716
10852
|
);
|
|
10717
10853
|
const onHostChange = React4.useCallback(
|
|
10718
10854
|
(next) => {
|
|
10719
|
-
var
|
|
10855
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
10720
10856
|
const currentStored = next == null ? void 0 : next.value;
|
|
10721
|
-
const stored = (_c2 = (_b2 = (
|
|
10857
|
+
const stored = (_c2 = (_b2 = (_a2 = adapter.getValue) == null ? void 0 : _a2.call(adapter, next, currentStored, adapterCtx)) != null ? _b2 : currentStored) != null ? _c2 : next;
|
|
10722
10858
|
fp.setValue(stored);
|
|
10723
10859
|
if (isOptionBased2) {
|
|
10724
10860
|
if (!adapter.getSelectedOptions) {
|
|
@@ -10736,16 +10872,7 @@ function Wrapper({
|
|
|
10736
10872
|
(rawIds != null ? rawIds : []).map(String).filter((id) => optionIds.has(id))
|
|
10737
10873
|
)
|
|
10738
10874
|
);
|
|
10739
|
-
|
|
10740
|
-
prevSelectedRef.current = nextIds;
|
|
10741
|
-
const prevSet = new Set(prev);
|
|
10742
|
-
const nextSet = new Set(nextIds);
|
|
10743
|
-
for (const id of nextIds) {
|
|
10744
|
-
if (!prevSet.has(id)) flow.toggleOption(field.id, id);
|
|
10745
|
-
}
|
|
10746
|
-
for (const id of prev) {
|
|
10747
|
-
if (!nextSet.has(id)) flow.toggleOption(field.id, id);
|
|
10748
|
-
}
|
|
10875
|
+
flow.setFieldOptions(field.id, nextIds);
|
|
10749
10876
|
return;
|
|
10750
10877
|
}
|
|
10751
10878
|
if (isActionButton) {
|
|
@@ -10767,8 +10894,8 @@ function Wrapper({
|
|
|
10767
10894
|
]
|
|
10768
10895
|
);
|
|
10769
10896
|
const templateCtx = React4.useMemo(() => {
|
|
10770
|
-
var
|
|
10771
|
-
const ctxFromInit = (_b2 = (
|
|
10897
|
+
var _a2, _b2;
|
|
10898
|
+
const ctxFromInit = (_b2 = (_a2 = flow.init) == null ? void 0 : _a2.ctx) != null ? _b2 : {};
|
|
10772
10899
|
const ctx = ctxOverrides && typeof ctxOverrides === "object" ? { ...ctxFromInit, ...ctxOverrides } : ctxFromInit;
|
|
10773
10900
|
return {
|
|
10774
10901
|
...ctx,
|
|
@@ -11276,6 +11403,9 @@ var toggleGroupDescriptor = {
|
|
|
11276
11403
|
defaultLabel: "Option label",
|
|
11277
11404
|
defaultValue: "option"
|
|
11278
11405
|
},
|
|
11406
|
+
multi: {
|
|
11407
|
+
supported: true
|
|
11408
|
+
},
|
|
11279
11409
|
defaultProps: {
|
|
11280
11410
|
variant: "toggle-group",
|
|
11281
11411
|
// MUST
|
|
@@ -11799,6 +11929,10 @@ var treeSelectDescriptor = {
|
|
|
11799
11929
|
defaultLabel: "Option label",
|
|
11800
11930
|
defaultValue: "option"
|
|
11801
11931
|
},
|
|
11932
|
+
multi: {
|
|
11933
|
+
supported: true,
|
|
11934
|
+
autoEnable: true
|
|
11935
|
+
},
|
|
11802
11936
|
defaultProps: {
|
|
11803
11937
|
variant: "treeselect",
|
|
11804
11938
|
// MUST
|
|
@@ -11885,6 +12019,10 @@ var multiSelectDescriptor = {
|
|
|
11885
12019
|
defaultLabel: "Option label",
|
|
11886
12020
|
defaultValue: "option"
|
|
11887
12021
|
},
|
|
12022
|
+
multi: {
|
|
12023
|
+
supported: true,
|
|
12024
|
+
autoEnable: true
|
|
12025
|
+
},
|
|
11888
12026
|
defaultProps: {
|
|
11889
12027
|
variant: "multi-select",
|
|
11890
12028
|
// MUST
|
|
@@ -12003,7 +12141,15 @@ var radioDescriptor = {
|
|
|
12003
12141
|
|
|
12004
12142
|
// src/react/inputs/entries/checkbox.tsx
|
|
12005
12143
|
var import_form_palette15 = require("@timeax/form-palette");
|
|
12006
|
-
var
|
|
12144
|
+
var checkboxSingleUi = {
|
|
12145
|
+
size: sharedUi.size,
|
|
12146
|
+
tristate: {
|
|
12147
|
+
type: "boolean",
|
|
12148
|
+
label: "Tri-state",
|
|
12149
|
+
description: 'Enable tri-state behaviour (supports an internal "none" state).'
|
|
12150
|
+
}
|
|
12151
|
+
};
|
|
12152
|
+
var checkboxOptionsUi = {
|
|
12007
12153
|
size: sharedUi.size,
|
|
12008
12154
|
density: {
|
|
12009
12155
|
type: "anyOf",
|
|
@@ -12015,11 +12161,6 @@ var checkboxBaseUi = {
|
|
|
12015
12161
|
{ type: "string", title: "Loose", value: "loose" }
|
|
12016
12162
|
]
|
|
12017
12163
|
},
|
|
12018
|
-
single: {
|
|
12019
|
-
type: "boolean",
|
|
12020
|
-
label: "Single",
|
|
12021
|
-
description: "If enabled, behaves like a single checkbox (boolean). Otherwise renders a group (array)."
|
|
12022
|
-
},
|
|
12023
12164
|
tristate: {
|
|
12024
12165
|
type: "boolean",
|
|
12025
12166
|
label: "Tri-state",
|
|
@@ -12049,23 +12190,23 @@ var checkboxBaseUi = {
|
|
|
12049
12190
|
autoCap: {
|
|
12050
12191
|
type: "boolean",
|
|
12051
12192
|
label: "Auto capitalise",
|
|
12052
|
-
description: "Capitalise the first letter of labels
|
|
12193
|
+
description: "Capitalise the first letter of labels when the label resolves to a string."
|
|
12053
12194
|
},
|
|
12054
12195
|
options: {
|
|
12055
12196
|
type: "array",
|
|
12056
12197
|
label: "Options",
|
|
12057
|
-
description: "Checkbox options. Can be primitives
|
|
12198
|
+
description: "Checkbox options. Can be primitives or objects with label/value/description/disabled/tristate.",
|
|
12058
12199
|
editable: true,
|
|
12059
12200
|
item: {
|
|
12060
12201
|
type: "object",
|
|
12061
12202
|
label: "Option",
|
|
12062
|
-
description: "An option item for group mode.",
|
|
12203
|
+
description: "An option item for checkbox group mode.",
|
|
12063
12204
|
editable: true,
|
|
12064
12205
|
fields: {
|
|
12065
12206
|
value: {
|
|
12066
12207
|
type: "string",
|
|
12067
12208
|
label: "Value",
|
|
12068
|
-
description: "Unique option value
|
|
12209
|
+
description: "Unique option value."
|
|
12069
12210
|
},
|
|
12070
12211
|
label: {
|
|
12071
12212
|
type: "string",
|
|
@@ -12085,7 +12226,7 @@ var checkboxBaseUi = {
|
|
|
12085
12226
|
tristate: {
|
|
12086
12227
|
type: "boolean",
|
|
12087
12228
|
label: "Tri-state override",
|
|
12088
|
-
description: "Override tri-state behaviour for this option
|
|
12229
|
+
description: "Override tri-state behaviour for this option."
|
|
12089
12230
|
}
|
|
12090
12231
|
},
|
|
12091
12232
|
order: ["value", "label", "description", "disabled", "tristate"]
|
|
@@ -12106,35 +12247,42 @@ var checkboxDescriptor = {
|
|
|
12106
12247
|
Component: import_form_palette15.InputField,
|
|
12107
12248
|
defaultProps: {
|
|
12108
12249
|
variant: "checkbox",
|
|
12109
|
-
// MUST
|
|
12110
12250
|
single: true,
|
|
12111
12251
|
tristate: false,
|
|
12112
|
-
|
|
12113
|
-
columns: 2,
|
|
12114
|
-
itemGapPx: 8,
|
|
12115
|
-
size: "md",
|
|
12116
|
-
density: "comfortable",
|
|
12117
|
-
autoCap: false
|
|
12252
|
+
size: "md"
|
|
12118
12253
|
},
|
|
12119
|
-
adapter: {},
|
|
12120
12254
|
options: {
|
|
12121
12255
|
supported: false
|
|
12122
12256
|
},
|
|
12123
|
-
|
|
12257
|
+
multi: {
|
|
12258
|
+
supported: false
|
|
12259
|
+
},
|
|
12260
|
+
ui: checkboxSingleUi
|
|
12124
12261
|
};
|
|
12125
|
-
var _a;
|
|
12126
12262
|
var checkboxOptionsDescriptor = {
|
|
12127
|
-
|
|
12263
|
+
Component: import_form_palette15.InputField,
|
|
12128
12264
|
defaultProps: {
|
|
12129
|
-
|
|
12130
|
-
single: false
|
|
12265
|
+
variant: "checkbox",
|
|
12266
|
+
single: false,
|
|
12267
|
+
tristate: false,
|
|
12268
|
+
layout: "list",
|
|
12269
|
+
columns: 2,
|
|
12270
|
+
itemGapPx: 8,
|
|
12271
|
+
size: "md",
|
|
12272
|
+
density: "comfortable",
|
|
12273
|
+
autoCap: false
|
|
12131
12274
|
},
|
|
12132
12275
|
options: {
|
|
12133
12276
|
supported: true,
|
|
12134
12277
|
autoCreate: true,
|
|
12135
12278
|
defaultLabel: "Option label",
|
|
12136
12279
|
defaultValue: "option"
|
|
12137
|
-
}
|
|
12280
|
+
},
|
|
12281
|
+
multi: {
|
|
12282
|
+
supported: true,
|
|
12283
|
+
autoEnable: true
|
|
12284
|
+
},
|
|
12285
|
+
ui: checkboxOptionsUi
|
|
12138
12286
|
};
|
|
12139
12287
|
|
|
12140
12288
|
// src/react/inputs/entries/chips.tsx
|
|
@@ -12935,7 +13083,7 @@ var inputFieldUi = {
|
|
|
12935
13083
|
}
|
|
12936
13084
|
};
|
|
12937
13085
|
function withInputFieldUi(desc) {
|
|
12938
|
-
var
|
|
13086
|
+
var _a;
|
|
12939
13087
|
return {
|
|
12940
13088
|
...desc,
|
|
12941
13089
|
adapter: {
|
|
@@ -12945,7 +13093,7 @@ function withInputFieldUi(desc) {
|
|
|
12945
13093
|
valueProp: "value",
|
|
12946
13094
|
changeProp: "onChange",
|
|
12947
13095
|
getInputPropsFromField({ field, props }) {
|
|
12948
|
-
var
|
|
13096
|
+
var _a2, _b;
|
|
12949
13097
|
const severityPillClassMap = {
|
|
12950
13098
|
info: "border-blue-200 bg-blue-50 text-blue-700 ring-1 ring-inset ring-blue-200",
|
|
12951
13099
|
warning: "border-amber-200 bg-amber-50 text-amber-800 ring-1 ring-inset ring-amber-200",
|
|
@@ -12953,11 +13101,11 @@ function withInputFieldUi(desc) {
|
|
|
12953
13101
|
};
|
|
12954
13102
|
const pillBaseClassName = "inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-medium";
|
|
12955
13103
|
const toTagPill = (tag) => {
|
|
12956
|
-
var
|
|
13104
|
+
var _a3;
|
|
12957
13105
|
return {
|
|
12958
13106
|
label: tag.title,
|
|
12959
13107
|
bgColor: tag.color,
|
|
12960
|
-
className: `${pillBaseClassName} ${(
|
|
13108
|
+
className: `${pillBaseClassName} ${(_a3 = severityPillClassMap[tag.severity]) != null ? _a3 : severityPillClassMap.info}`
|
|
12961
13109
|
};
|
|
12962
13110
|
};
|
|
12963
13111
|
const matchesNotice = (target, notice) => {
|
|
@@ -12966,7 +13114,7 @@ function withInputFieldUi(desc) {
|
|
|
12966
13114
|
const isServiceMatch = !!target.service_id && String(target.service_id) === notice.id;
|
|
12967
13115
|
return isNodeTargetMatch || isLegacyGlobalIdMatch || isServiceMatch;
|
|
12968
13116
|
};
|
|
12969
|
-
const notices = (
|
|
13117
|
+
const notices = (_a2 = props.notices) != null ? _a2 : [];
|
|
12970
13118
|
const fieldNotices = notices.filter(
|
|
12971
13119
|
(notice) => matchesNotice(field, notice)
|
|
12972
13120
|
);
|
|
@@ -12988,8 +13136,8 @@ function withInputFieldUi(desc) {
|
|
|
12988
13136
|
};
|
|
12989
13137
|
},
|
|
12990
13138
|
getSelectedOptions(next, currentt, ctx) {
|
|
12991
|
-
var
|
|
12992
|
-
return (_c = (_b = (
|
|
13139
|
+
var _a2, _b, _c;
|
|
13140
|
+
return (_c = (_b = (_a2 = next == null ? void 0 : next.detail) == null ? void 0 : _a2.selectedOptions) != null ? _b : []) == null ? void 0 : _c.map(
|
|
12993
13141
|
(item) => item.id
|
|
12994
13142
|
);
|
|
12995
13143
|
},
|
|
@@ -12999,13 +13147,13 @@ function withInputFieldUi(desc) {
|
|
|
12999
13147
|
},
|
|
13000
13148
|
ui: {
|
|
13001
13149
|
...inputFieldUi,
|
|
13002
|
-
...(
|
|
13150
|
+
...(_a = desc.ui) != null ? _a : {}
|
|
13003
13151
|
}
|
|
13004
13152
|
};
|
|
13005
13153
|
}
|
|
13006
13154
|
function variantOf(desc) {
|
|
13007
|
-
var
|
|
13008
|
-
const v = (
|
|
13155
|
+
var _a;
|
|
13156
|
+
const v = (_a = desc.defaultProps) == null ? void 0 : _a.variant;
|
|
13009
13157
|
if (!v || typeof v !== "string") {
|
|
13010
13158
|
throw new Error(
|
|
13011
13159
|
`[inputs] Descriptor is missing defaultProps.variant: ${String(v)}`
|
|
@@ -13096,16 +13244,16 @@ function FallbackEditorProvider({
|
|
|
13096
13244
|
);
|
|
13097
13245
|
const resolvedEligibleServices = import_react9.default.useMemo(
|
|
13098
13246
|
() => {
|
|
13099
|
-
var
|
|
13100
|
-
return (
|
|
13247
|
+
var _a;
|
|
13248
|
+
return (_a = eligibleServices != null ? eligibleServices : primaryServices) != null ? _a : {};
|
|
13101
13249
|
},
|
|
13102
13250
|
[eligibleServices, primaryServices]
|
|
13103
13251
|
);
|
|
13104
13252
|
const editorRef = import_react9.default.useRef(null);
|
|
13105
13253
|
const buildEditor = import_react9.default.useCallback(
|
|
13106
13254
|
(next) => {
|
|
13107
|
-
var
|
|
13108
|
-
const currentValue = (
|
|
13255
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
13256
|
+
const currentValue = (_a = editorRef.current) == null ? void 0 : _a.value();
|
|
13109
13257
|
editorRef.current = createFallbackEditor({
|
|
13110
13258
|
fallbacks: (_d = (_c = (_b = next == null ? void 0 : next.fallbacks) != null ? _b : currentValue) != null ? _c : fallbacks) != null ? _d : {},
|
|
13111
13259
|
props: (_e = next == null ? void 0 : next.props) != null ? _e : props,
|
|
@@ -13496,7 +13644,7 @@ function VirtualServiceList({
|
|
|
13496
13644
|
style: { height },
|
|
13497
13645
|
onScroll: (e) => setScrollTop(e.currentTarget.scrollTop),
|
|
13498
13646
|
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "relative", style: { height: total * rowHeight }, children: visible.map((item, i) => {
|
|
13499
|
-
var
|
|
13647
|
+
var _a, _b;
|
|
13500
13648
|
const index = start + i;
|
|
13501
13649
|
const key = String(item.id);
|
|
13502
13650
|
const checked = selected.has(key);
|
|
@@ -13517,7 +13665,7 @@ function VirtualServiceList({
|
|
|
13517
13665
|
String(item.id),
|
|
13518
13666
|
" \xB7",
|
|
13519
13667
|
" ",
|
|
13520
|
-
(
|
|
13668
|
+
(_a = item.name) != null ? _a : "Unnamed"
|
|
13521
13669
|
] }),
|
|
13522
13670
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "mt-0.5 text-xs text-zinc-500 dark:text-zinc-400", children: [
|
|
13523
13671
|
(_b = item.platform) != null ? _b : "Unknown",
|
|
@@ -13547,7 +13695,7 @@ function VirtualServiceList({
|
|
|
13547
13695
|
var import_react18 = __toESM(require("react"), 1);
|
|
13548
13696
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
13549
13697
|
function FallbackDetailsPanel() {
|
|
13550
|
-
var
|
|
13698
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
13551
13699
|
const { activeServiceId, state, settings } = useFallbackEditor();
|
|
13552
13700
|
const services = usePrimaryServiceList();
|
|
13553
13701
|
const service = import_react18.default.useMemo(
|
|
@@ -13563,7 +13711,7 @@ function FallbackDetailsPanel() {
|
|
|
13563
13711
|
Detail,
|
|
13564
13712
|
{
|
|
13565
13713
|
label: "Name",
|
|
13566
|
-
value: (
|
|
13714
|
+
value: (_a = service.name) != null ? _a : "Unnamed"
|
|
13567
13715
|
}
|
|
13568
13716
|
),
|
|
13569
13717
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
@@ -13684,7 +13832,7 @@ var import_react19 = __toESM(require("react"), 1);
|
|
|
13684
13832
|
var import_form_palette23 = require("@timeax/form-palette");
|
|
13685
13833
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
13686
13834
|
function FallbackSettingsPanel() {
|
|
13687
|
-
var
|
|
13835
|
+
var _a, _b, _c;
|
|
13688
13836
|
const { settings, saveSettings, settingsSaving } = useFallbackEditorContext();
|
|
13689
13837
|
const [draft, setDraft] = import_react19.default.useState(settings);
|
|
13690
13838
|
const [error, setError] = import_react19.default.useState(null);
|
|
@@ -13713,7 +13861,7 @@ function FallbackSettingsPanel() {
|
|
|
13713
13861
|
ratePolicy: next
|
|
13714
13862
|
}));
|
|
13715
13863
|
}
|
|
13716
|
-
const ratePolicy = (
|
|
13864
|
+
const ratePolicy = (_a = draft.ratePolicy) != null ? _a : {
|
|
13717
13865
|
kind: "lte_primary",
|
|
13718
13866
|
pct: 5
|
|
13719
13867
|
};
|
|
@@ -13912,8 +14060,8 @@ function FallbackServiceSidebar() {
|
|
|
13912
14060
|
if (!q) return services;
|
|
13913
14061
|
return services.filter(
|
|
13914
14062
|
(service) => {
|
|
13915
|
-
var
|
|
13916
|
-
return String(service.id).includes(q) || String((
|
|
14063
|
+
var _a, _b;
|
|
14064
|
+
return String(service.id).includes(q) || String((_a = service.name) != null ? _a : "").toLowerCase().includes(q) || String((_b = service.platform) != null ? _b : "").toLowerCase().includes(q);
|
|
13917
14065
|
}
|
|
13918
14066
|
);
|
|
13919
14067
|
}, [query, services]);
|
|
@@ -13937,7 +14085,7 @@ function FallbackServiceSidebar() {
|
|
|
13937
14085
|
}
|
|
13938
14086
|
) }),
|
|
13939
14087
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "mt-3 flex-1 space-y-2 overflow-y-auto", children: filtered.map((service) => {
|
|
13940
|
-
var
|
|
14088
|
+
var _a, _b;
|
|
13941
14089
|
const active = String(service.id) === String(activeServiceId);
|
|
13942
14090
|
const count = get(service.id).length;
|
|
13943
14091
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
@@ -13956,7 +14104,7 @@ function FallbackServiceSidebar() {
|
|
|
13956
14104
|
String(service.id),
|
|
13957
14105
|
" \xB7",
|
|
13958
14106
|
" ",
|
|
13959
|
-
(
|
|
14107
|
+
(_a = service.name) != null ? _a : "Unnamed"
|
|
13960
14108
|
] }),
|
|
13961
14109
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "mt-1 text-xs text-zinc-500 dark:text-zinc-400", children: [
|
|
13962
14110
|
(_b = service.platform) != null ? _b : "Unknown",
|
|
@@ -14031,7 +14179,7 @@ function FallbackRegistrationsPanel() {
|
|
|
14031
14179
|
)
|
|
14032
14180
|
] }),
|
|
14033
14181
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "space-y-4", children: registrations.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("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) => {
|
|
14034
|
-
var
|
|
14182
|
+
var _a;
|
|
14035
14183
|
const context = makeContext(reg);
|
|
14036
14184
|
const candidates = reg.services;
|
|
14037
14185
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
@@ -14053,7 +14201,7 @@ function FallbackRegistrationsPanel() {
|
|
|
14053
14201
|
] })
|
|
14054
14202
|
] }),
|
|
14055
14203
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "mt-4 flex flex-wrap gap-2", children: candidates.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-xs text-zinc-500 dark:text-zinc-400", children: "No fallback services yet." }) : candidates.map((candidate) => {
|
|
14056
|
-
var
|
|
14204
|
+
var _a2;
|
|
14057
14205
|
const preview = check(context, [
|
|
14058
14206
|
candidate
|
|
14059
14207
|
]);
|
|
@@ -14067,7 +14215,7 @@ function FallbackRegistrationsPanel() {
|
|
|
14067
14215
|
{
|
|
14068
14216
|
className: `inline-flex items-center gap-2 rounded-xl border px-3 py-2 text-xs ${tone}`,
|
|
14069
14217
|
children: [
|
|
14070
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: service ? `#${String(service.id)} \xB7 ${(
|
|
14218
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: service ? `#${String(service.id)} \xB7 ${(_a2 = service.name) != null ? _a2 : "Unnamed"}` : `#${String(candidate)}` }),
|
|
14071
14219
|
rejected ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "rounded-full border border-current/20 px-2 py-0.5 text-[10px]", children: rejected.reasons.join(
|
|
14072
14220
|
", "
|
|
14073
14221
|
) }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "rounded-full border border-current/20 px-2 py-0.5 text-[10px]", children: "valid" }),
|
|
@@ -14113,7 +14261,7 @@ function FallbackRegistrationsPanel() {
|
|
|
14113
14261
|
] })
|
|
14114
14262
|
]
|
|
14115
14263
|
},
|
|
14116
|
-
`${reg.scope}:${String((
|
|
14264
|
+
`${reg.scope}:${String((_a = reg.scopeId) != null ? _a : "global")}:${index}`
|
|
14117
14265
|
);
|
|
14118
14266
|
}) })
|
|
14119
14267
|
] }),
|
|
@@ -14172,7 +14320,7 @@ function FallbackAddCandidatesDialog({
|
|
|
14172
14320
|
const items = import_react25.default.useMemo(() => {
|
|
14173
14321
|
const q = query.trim().toLowerCase();
|
|
14174
14322
|
return eligibleServices.filter((service) => {
|
|
14175
|
-
var
|
|
14323
|
+
var _a, _b;
|
|
14176
14324
|
if (primaryId !== void 0 && String(service.id) === String(primaryId)) {
|
|
14177
14325
|
return false;
|
|
14178
14326
|
}
|
|
@@ -14180,7 +14328,7 @@ function FallbackAddCandidatesDialog({
|
|
|
14180
14328
|
return false;
|
|
14181
14329
|
}
|
|
14182
14330
|
if (!q) return true;
|
|
14183
|
-
return String(service.id).includes(q) || String((
|
|
14331
|
+
return String(service.id).includes(q) || String((_a = service.name) != null ? _a : "").toLowerCase().includes(q) || String((_b = service.platform) != null ? _b : "").toLowerCase().includes(q);
|
|
14184
14332
|
});
|
|
14185
14333
|
}, [eligibleServices, allowedIds, query, primaryId]);
|
|
14186
14334
|
function toggle(id) {
|
|
@@ -14302,7 +14450,7 @@ function FallbackAddRegistrationDialog({
|
|
|
14302
14450
|
return registrations.some((r) => r.scope === "global");
|
|
14303
14451
|
}, [registrations]);
|
|
14304
14452
|
const nodeTargets = import_react26.default.useMemo(() => {
|
|
14305
|
-
var
|
|
14453
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
14306
14454
|
if (activeServiceId === void 0 || activeServiceId === null) {
|
|
14307
14455
|
return [];
|
|
14308
14456
|
}
|
|
@@ -14323,7 +14471,7 @@ function FallbackAddRegistrationDialog({
|
|
|
14323
14471
|
serviceId: activeServiceId
|
|
14324
14472
|
});
|
|
14325
14473
|
}
|
|
14326
|
-
const activeTagId = (
|
|
14474
|
+
const activeTagId = (_a = snapshot.selection) == null ? void 0 : _a.tag;
|
|
14327
14475
|
out.sort((a, b) => {
|
|
14328
14476
|
if (activeTagId && a.id === activeTagId && b.id !== activeTagId) {
|
|
14329
14477
|
return -1;
|
|
@@ -14403,7 +14551,7 @@ function FallbackAddRegistrationDialog({
|
|
|
14403
14551
|
}
|
|
14404
14552
|
}, [scope, nodeId, nodeTargets]);
|
|
14405
14553
|
function handleContinue() {
|
|
14406
|
-
var
|
|
14554
|
+
var _a;
|
|
14407
14555
|
if (activeServiceId === void 0 || activeServiceId === null) return;
|
|
14408
14556
|
if (scope === "global") {
|
|
14409
14557
|
onSelect(
|
|
@@ -14422,7 +14570,7 @@ function FallbackAddRegistrationDialog({
|
|
|
14422
14570
|
scope: "node",
|
|
14423
14571
|
nodeId
|
|
14424
14572
|
},
|
|
14425
|
-
(
|
|
14573
|
+
(_a = node == null ? void 0 : node.serviceId) != null ? _a : activeServiceId
|
|
14426
14574
|
);
|
|
14427
14575
|
}
|
|
14428
14576
|
if (!open) return null;
|
|
@@ -14502,11 +14650,11 @@ function FallbackAddRegistrationDialog({
|
|
|
14502
14650
|
] }) });
|
|
14503
14651
|
}
|
|
14504
14652
|
function resolveNodeMeta(props, nodeId) {
|
|
14505
|
-
var
|
|
14653
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
14506
14654
|
if (!props) {
|
|
14507
14655
|
return { kind: "node", label: nodeId };
|
|
14508
14656
|
}
|
|
14509
|
-
const tag = (
|
|
14657
|
+
const tag = (_a = props.filters) == null ? void 0 : _a.find((t) => t.id === nodeId);
|
|
14510
14658
|
if (tag) {
|
|
14511
14659
|
return {
|
|
14512
14660
|
kind: "tag",
|