@primmel/primmel 1.5.2 → 1.5.3

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.
Files changed (2) hide show
  1. package/dist-browser/index.mjs +202 -219
  2. package/package.json +1 -1
@@ -249,15 +249,14 @@ var m = function(e) {
249
249
  let n = r(e), i = 0;
250
250
  for (; i < n.length;) {
251
251
  let e = n[i++];
252
- if (i < n.length) {
253
- if (e === "title") t.title = a(n[i++]);
254
- else if (e === "schema") t.schema = a(n[i++]);
255
- else if (e === "edition") t.edition = a(n[i++]);
256
- else if (e === "author") t.author = a(n[i++]);
257
- else if (e === "namespace") t.namespace = a(n[i++]);
258
- else if (e === "shortname") t.shortname = a(n[i++]);
259
- else throw Error("Parsing error: metadata. Unknown keyword " + e);
260
- } else throw Error("Parsing error: metadata. Expecting value for " + e);
252
+ if (i < n.length) if (e === "title") t.title = a(n[i++]);
253
+ else if (e === "schema") t.schema = a(n[i++]);
254
+ else if (e === "edition") t.edition = a(n[i++]);
255
+ else if (e === "author") t.author = a(n[i++]);
256
+ else if (e === "namespace") t.namespace = a(n[i++]);
257
+ else if (e === "shortname") t.shortname = a(n[i++]);
258
+ else throw Error("Parsing error: metadata. Unknown keyword " + e);
259
+ else throw Error("Parsing error: metadata. Expecting value for " + e);
261
260
  }
262
261
  }
263
262
  return (e) => (e.metadata = t, e);
@@ -475,16 +474,14 @@ function re(e) {
475
474
  let t = r(e.trim().replace(/^[[{]/, "").replace(/[\]}]$/, "")), n = [], o = 0;
476
475
  for (; o < t.length;) {
477
476
  let e = a(t[o++].replace(/,$/, ""));
478
- if (e) {
479
- if (o < t.length && t[o].startsWith("{")) {
480
- let s = r(i(t[o++])), c = "";
481
- for (let e = 0; e + 1 < s.length; e += 2) s[e] === "label" && (c = a(s[e + 1]));
482
- n.push({
483
- value: e,
484
- label: c
485
- });
486
- } else n.push(e);
487
- }
477
+ if (e) if (o < t.length && t[o].startsWith("{")) {
478
+ let s = r(i(t[o++])), c = "";
479
+ for (let e = 0; e + 1 < s.length; e += 2) s[e] === "label" && (c = a(s[e + 1]));
480
+ n.push({
481
+ value: e,
482
+ label: c
483
+ });
484
+ } else n.push(e);
488
485
  }
489
486
  return n;
490
487
  }
@@ -731,15 +728,13 @@ function de(e, t) {
731
728
  let e = n(t), o = 0;
732
729
  for (; o < e.length;) {
733
730
  let t = e[o++];
734
- if (o < e.length) {
735
- if (t === "parameters") {
736
- let t = n(i(e[o++])), s = 0;
737
- for (; s < t.length;) {
738
- let e = A(t[s++]);
739
- s < t.length && (t[s] === ":" && s++, s < t.length && (r.parameters[e] = a(t[s++])));
740
- }
741
- } else t === "applicability" ? r.applicability = P(i(e[o++])) : i(e[o++]);
742
- }
731
+ if (o < e.length) if (t === "parameters") {
732
+ let t = n(i(e[o++])), s = 0;
733
+ for (; s < t.length;) {
734
+ let e = A(t[s++]);
735
+ s < t.length && (t[s] === ":" && s++, s < t.length && (r.parameters[e] = a(t[s++])));
736
+ }
737
+ } else t === "applicability" ? r.applicability = P(i(e[o++])) : i(e[o++]);
743
738
  }
744
739
  }
745
740
  return r;
@@ -1970,7 +1965,7 @@ function Vt(e) {
1970
1965
  let s = a.text.trim().slice(1, a.text.lastIndexOf("]")), c = [];
1971
1966
  for (let e of n(s)) e.startsWith("{") && c.push(Bt(i(e)));
1972
1967
  t[e] = c;
1973
- } else t[e] = r[o].startsWith("{") ? Bt(i(r[o++])) : Rt(a(r[o++]));
1968
+ } else r[o].startsWith("{") ? t[e] = Bt(i(r[o++])) : t[e] = Rt(a(r[o++]));
1974
1969
  }
1975
1970
  return t;
1976
1971
  }
@@ -2046,33 +2041,32 @@ var Gt = function(e, t) {
2046
2041
  let s = r(t), c = 0;
2047
2042
  for (; c < s.length;) {
2048
2043
  let t = s[c++];
2049
- if (c < s.length) {
2050
- if (t === "title") o.title = i(s[c++]);
2051
- else if (t === "description") o.description = a(s[c++]);
2052
- else if (t === "columns") {
2053
- let e = s[c++];
2054
- e.startsWith("{") ? o.columnDefs = zt(i(e)) : o.columns = i(e);
2055
- } else if (t === "display") o.display = i(s[c++]);
2056
- else if (t === "source") {
2057
- let e = N(i(s[c++]));
2058
- o.sourceRef ||= e, (o.sourceRefs ??= []).push(e);
2059
- } else if (t === "source_discrepancy") o.sourceDiscrepancy = E(i(s[c++]));
2060
- else if (t === "overrides") o.overrides = Wt(i(s[c++]));
2061
- else if (t === "profiles") {
2062
- let e = n(i(s[c++])), t = [], r = 0;
2063
- for (; r < e.length;) if (e[r] === "profile") {
2064
- r++;
2065
- let t = a(e[r++]), n = r < e.length ? i(e[r++]) : "";
2066
- o.profileDefs = o.profileDefs ?? [], o.profileDefs.push(Ht(t, n));
2067
- } else t.push(e[r++]);
2068
- t.length > 0 && (o.profiles = Ut(t.join(" ")));
2069
- } else if (t === "domain") o.domain = i(s[c++]);
2070
- else if (t === "data") o.data = Kt(i(s[c++]));
2071
- else if (t === "ref") {
2072
- let e = b(s, c, a, i);
2073
- w(o, e.ref) || (o.refs ??= []).push(e.ref), c = e.next;
2074
- } else c++;
2075
- } else throw Error(`Parsing error: table. ID ${e}: Expecting value for ${t}`);
2044
+ if (c < s.length) if (t === "title") o.title = i(s[c++]);
2045
+ else if (t === "description") o.description = a(s[c++]);
2046
+ else if (t === "columns") {
2047
+ let e = s[c++];
2048
+ e.startsWith("{") ? o.columnDefs = zt(i(e)) : o.columns = i(e);
2049
+ } else if (t === "display") o.display = i(s[c++]);
2050
+ else if (t === "source") {
2051
+ let e = N(i(s[c++]));
2052
+ o.sourceRef ||= e, (o.sourceRefs ??= []).push(e);
2053
+ } else if (t === "source_discrepancy") o.sourceDiscrepancy = E(i(s[c++]));
2054
+ else if (t === "overrides") o.overrides = Wt(i(s[c++]));
2055
+ else if (t === "profiles") {
2056
+ let e = n(i(s[c++])), t = [], r = 0;
2057
+ for (; r < e.length;) if (e[r] === "profile") {
2058
+ r++;
2059
+ let t = a(e[r++]), n = r < e.length ? i(e[r++]) : "";
2060
+ o.profileDefs = o.profileDefs ?? [], o.profileDefs.push(Ht(t, n));
2061
+ } else t.push(e[r++]);
2062
+ t.length > 0 && (o.profiles = Ut(t.join(" ")));
2063
+ } else if (t === "domain") o.domain = i(s[c++]);
2064
+ else if (t === "data") o.data = Kt(i(s[c++]));
2065
+ else if (t === "ref") {
2066
+ let e = b(s, c, a, i);
2067
+ w(o, e.ref) || (o.refs ??= []).push(e.ref), c = e.next;
2068
+ } else c++;
2069
+ else throw Error(`Parsing error: table. ID ${e}: Expecting value for ${t}`);
2076
2070
  }
2077
2071
  }
2078
2072
  return (t) => (t.tables[e] = o, t);
@@ -2160,13 +2154,12 @@ var Yt = function(e) {
2160
2154
  let a = r(t), o = 0;
2161
2155
  for (; o < a.length;) {
2162
2156
  let t = a[o++];
2163
- if (o < a.length) {
2164
- if (t === "type" || t === "kind") {
2165
- let t = a[o++];
2166
- if (!Qt.includes(t)) throw Error(`Parsing error: link. ID ${e}: Unknown kind ${t} (valid: ${Qt.join(", ")})`);
2167
- n.kind = t;
2168
- } else t === "target" || t === "path" || t === "url" ? n.target = i(a[o++]) : t === "namespace" || t === "ns" ? n.namespace = i(a[o++]) : o++;
2169
- } else throw Error(`Parsing error: link. ID ${e}: Expecting value for ${t}`);
2157
+ if (o < a.length) if (t === "type" || t === "kind") {
2158
+ let t = a[o++];
2159
+ if (!Qt.includes(t)) throw Error(`Parsing error: link. ID ${e}: Unknown kind ${t} (valid: ${Qt.join(", ")})`);
2160
+ n.kind = t;
2161
+ } else t === "target" || t === "path" || t === "url" ? n.target = i(a[o++]) : t === "namespace" || t === "ns" ? n.namespace = i(a[o++]) : o++;
2162
+ else throw Error(`Parsing error: link. ID ${e}: Expecting value for ${t}`);
2170
2163
  }
2171
2164
  }
2172
2165
  return (t) => (t.links[e] = n, t);
@@ -2188,7 +2181,7 @@ var Yt = function(e) {
2188
2181
  let e = r(t), a = 0;
2189
2182
  for (; a < e.length;) {
2190
2183
  let t = e[a++];
2191
- t === "on" ? n.on = e[a++] : t === "author" || t === "username" ? n.author = i(e[a++]) : t === "timestamp" ? n.timestamp = i(e[a++]) : t === "text" || t === "message" ? n.text = i(e[a++]) : t === "reply_to" ? n.replyTo = e[a++] : t === "feedback" ? n._feedback = r(i(e[a++])) : t === "resolved" ? n.resolved = a < e.length && (e[a] === "true" || e[a] === "false") ? e[a++] === "true" : !0 : a++;
2184
+ t === "on" ? n.on = e[a++] : t === "author" || t === "username" ? n.author = i(e[a++]) : t === "timestamp" ? n.timestamp = i(e[a++]) : t === "text" || t === "message" ? n.text = i(e[a++]) : t === "reply_to" ? n.replyTo = e[a++] : t === "feedback" ? n._feedback = r(i(e[a++])) : t === "resolved" ? a < e.length && (e[a] === "true" || e[a] === "false") ? n.resolved = e[a++] === "true" : n.resolved = !0 : a++;
2192
2185
  }
2193
2186
  }
2194
2187
  return (t) => (t.comments[e] = n, t);
@@ -2366,41 +2359,40 @@ var un = function(e, t) {
2366
2359
  let s = r(t), c = 0;
2367
2360
  for (; c < s.length;) {
2368
2361
  let t = s[c++];
2369
- if (c < s.length) {
2370
- if (t === "name") o.name = a(s[c++]);
2371
- else if (t === "description") o.description = a(s[c++]);
2372
- else if (t === "data_class") o.dataClassId = a(s[c++]);
2373
- else if (t === "header") o.headerFormId = a(s[c++]);
2374
- else if (t === "section") o.section = a(s[c++]);
2375
- else if (t === "requirements") o.requirements = r(s[c++]).map(a);
2376
- else if (t === "note") o.formNotes.push(a(s[c++]));
2377
- else if (t === "scope") o.scope = a(s[c++]);
2378
- else if (t === "report_rows") {
2379
- let e = n(i(s[c++])), t = {
2380
- field: "",
2381
- itemKey: ""
2382
- };
2383
- for (let n = 0; n + 1 < e.length; n += 2) e[n] === "field" ? t.field = a(e[n + 1]) : e[n] === "item_key" && (t.itemKey = a(e[n + 1]));
2384
- o.reportRows = t;
2385
- } else if (t === "references") o.formReferences = pe(i(s[c++]));
2386
- else if (t === "ref") {
2387
- let e = b(s, c, a, i);
2388
- w(o, e.ref) || (o.refs = [...o.refs ?? [], e.ref]), c = e.next;
2389
- } else if (t === "calculation_context") o.calculationContext = hn(i(s[c++]));
2390
- else if (t === "instances") o.formInstances = gn(i(s[c++]));
2391
- else if (t === "constraints") o.formConstraints = _n(i(s[c++]));
2392
- else if (t === "conformance_process") {
2393
- let e = s[c++];
2394
- e.startsWith("{") ? (o.conformanceProcessIds = n(i(e)).map(a), o.conformanceProcessId = o.conformanceProcessIds[0] ?? "") : o.conformanceProcessId = a(e);
2395
- } else if (t === "applicability") o.applicability = P(i(s[c++]));
2396
- else if (t === "field") {
2397
- let e = oe(s, c);
2398
- e ? (o.fields.push(se(e.name, e.block, e.type || void 0)), c = e.next) : c++;
2399
- } else if (t === "subform_ref") {
2400
- let e = s[c++], t = c < s.length ? i(s[c++]) : "";
2401
- o.fields.push(bn(e, t));
2402
- } else t === "pass_fail" ? o.passFail = vn(i(s[c++])) : t === "reference" ? o.referenceIds = r(s[c++]).map(a) : c++;
2403
- } else throw Error(`Parsing error: form. ID ${e}: Expecting value for ${t}`);
2362
+ if (c < s.length) if (t === "name") o.name = a(s[c++]);
2363
+ else if (t === "description") o.description = a(s[c++]);
2364
+ else if (t === "data_class") o.dataClassId = a(s[c++]);
2365
+ else if (t === "header") o.headerFormId = a(s[c++]);
2366
+ else if (t === "section") o.section = a(s[c++]);
2367
+ else if (t === "requirements") o.requirements = r(s[c++]).map(a);
2368
+ else if (t === "note") o.formNotes.push(a(s[c++]));
2369
+ else if (t === "scope") o.scope = a(s[c++]);
2370
+ else if (t === "report_rows") {
2371
+ let e = n(i(s[c++])), t = {
2372
+ field: "",
2373
+ itemKey: ""
2374
+ };
2375
+ for (let n = 0; n + 1 < e.length; n += 2) e[n] === "field" ? t.field = a(e[n + 1]) : e[n] === "item_key" && (t.itemKey = a(e[n + 1]));
2376
+ o.reportRows = t;
2377
+ } else if (t === "references") o.formReferences = pe(i(s[c++]));
2378
+ else if (t === "ref") {
2379
+ let e = b(s, c, a, i);
2380
+ w(o, e.ref) || (o.refs = [...o.refs ?? [], e.ref]), c = e.next;
2381
+ } else if (t === "calculation_context") o.calculationContext = hn(i(s[c++]));
2382
+ else if (t === "instances") o.formInstances = gn(i(s[c++]));
2383
+ else if (t === "constraints") o.formConstraints = _n(i(s[c++]));
2384
+ else if (t === "conformance_process") {
2385
+ let e = s[c++];
2386
+ e.startsWith("{") ? (o.conformanceProcessIds = n(i(e)).map(a), o.conformanceProcessId = o.conformanceProcessIds[0] ?? "") : o.conformanceProcessId = a(e);
2387
+ } else if (t === "applicability") o.applicability = P(i(s[c++]));
2388
+ else if (t === "field") {
2389
+ let e = oe(s, c);
2390
+ e ? (o.fields.push(se(e.name, e.block, e.type || void 0)), c = e.next) : c++;
2391
+ } else if (t === "subform_ref") {
2392
+ let e = s[c++], t = c < s.length ? i(s[c++]) : "";
2393
+ o.fields.push(bn(e, t));
2394
+ } else t === "pass_fail" ? o.passFail = vn(i(s[c++])) : t === "reference" ? o.referenceIds = r(s[c++]).map(a) : c++;
2395
+ else throw Error(`Parsing error: form. ID ${e}: Expecting value for ${t}`);
2404
2396
  }
2405
2397
  }
2406
2398
  return (t) => (t.forms[e] = o, t);
@@ -2592,18 +2584,17 @@ var Cn = function(e, t) {
2592
2584
  let o = r(t), s = 0;
2593
2585
  for (; s < o.length;) {
2594
2586
  let t = o[s++];
2595
- if (s < o.length) {
2596
- if (t === "description") n.description = a(o[s++]);
2597
- else if (t === "type") {
2598
- let t = o[s++];
2599
- if (t === "object" || t === "array") n.shapeType = t;
2600
- else throw Error(`Parsing error: subform. ID ${e}: type must be object or array (got ${t})`);
2601
- } else if (t === "parameters") n.parameters = wn(i(o[s++]));
2602
- else if (t === "field") {
2603
- let e = oe(o, s);
2604
- e ? (n.fields.push(se(e.name, e.block, e.type || void 0)), s = e.next) : s++;
2605
- } else s++;
2606
- } else throw Error(`Parsing error: subform. ID ${e}: Expecting value for ${t}`);
2587
+ if (s < o.length) if (t === "description") n.description = a(o[s++]);
2588
+ else if (t === "type") {
2589
+ let t = o[s++];
2590
+ if (t === "object" || t === "array") n.shapeType = t;
2591
+ else throw Error(`Parsing error: subform. ID ${e}: type must be object or array (got ${t})`);
2592
+ } else if (t === "parameters") n.parameters = wn(i(o[s++]));
2593
+ else if (t === "field") {
2594
+ let e = oe(o, s);
2595
+ e ? (n.fields.push(se(e.name, e.block, e.type || void 0)), s = e.next) : s++;
2596
+ } else s++;
2597
+ else throw Error(`Parsing error: subform. ID ${e}: Expecting value for ${t}`);
2607
2598
  }
2608
2599
  }
2609
2600
  return (t) => (t.subforms[e] = n, t);
@@ -2619,19 +2610,17 @@ function wn(e) {
2619
2610
  let e = r(i(o[s++])), t = 0;
2620
2611
  for (; t < e.length;) {
2621
2612
  let r = e[t++];
2622
- if (t < e.length) {
2623
- if (r === "description") l = a(e[t++]);
2624
- else if (r === "default") d = a(e[t++]), u = !0;
2625
- else if (r === "mapping") {
2626
- let r = i(e[t++]);
2627
- f = {};
2628
- let o = n(r), s = 0;
2629
- for (; s < o.length;) {
2630
- let e = A(o[s++]);
2631
- s < o.length && (o[s] === ":" && s++, s < o.length && (f[e] = a(o[s++])));
2632
- }
2633
- } else t++;
2634
- }
2613
+ if (t < e.length) if (r === "description") l = a(e[t++]);
2614
+ else if (r === "default") d = a(e[t++]), u = !0;
2615
+ else if (r === "mapping") {
2616
+ let r = i(e[t++]);
2617
+ f = {};
2618
+ let o = n(r), s = 0;
2619
+ for (; s < o.length;) {
2620
+ let e = A(o[s++]);
2621
+ s < o.length && (o[s] === ":" && s++, s < o.length && (f[e] = a(o[s++])));
2622
+ }
2623
+ } else t++;
2635
2624
  }
2636
2625
  }
2637
2626
  t.push({
@@ -2781,31 +2770,30 @@ var Tn = function(e) {
2781
2770
  let s = r(t), c = 0;
2782
2771
  for (; c < s.length;) {
2783
2772
  let t = s[c++];
2784
- if (c < s.length) {
2785
- if (t === "name") o.name = i(s[c++]);
2786
- else if (t === "identifier") o.identifier = a(s[c++]);
2787
- else if (t === "type") o.ruleType = a(s[c++]);
2788
- else if (t === "category") o.category = a(s[c++]);
2789
- else if (t === "label") o.label = a(s[c++]);
2790
- else if (t === "description") o.description = i(s[c++]);
2791
- else if (t === "expression") o.expression = i(s[c++]);
2792
- else if (t === "reference") o._relations.ref = r(s[c++]);
2793
- else if (t === "ref") {
2794
- let e = b(s, c, a, i);
2795
- w(o, e.ref) || (o.refs ??= []).push(e.ref), c = e.next;
2796
- } else if (t === "source") {
2797
- let e = n(i(s[c++])), t = {
2798
- doc: "",
2799
- clause: ""
2800
- };
2801
- for (let n = 0; n + 1 < e.length; n += 2) e[n] === "doc" ? t.doc = a(e[n + 1]) : e[n] === "clause" ? t.clause = a(e[n + 1]) : e[n] === "fragment" && (t.fragment = a(e[n + 1]));
2802
- o.sourceRef ||= t, (o.sourceRefs ??= []).push(t);
2803
- } else if (t === "inputs") o.inputs = jn(i(s[c++]));
2804
- else if (t === "output") {
2805
- let e = "";
2806
- s[c] === ":" && (e += s[c++]), c < s.length && !s[c].startsWith("{") && (e += " " + s[c++]), c < s.length && s[c].startsWith("{") && (e += " " + s[c++]), o.output = Mn(e);
2807
- } else t === "params" ? o.params = n(a(s[c++])).map(a).filter((e) => e.length > 0) : t === "lookup" ? o.lookup = Nn(i(s[c++])) : t === "profile" ? o.profile = a(s[c++]) : c++;
2808
- } else throw Error(`Parsing error: calculation. ID ${e}: Expecting value for ${t}`);
2773
+ if (c < s.length) if (t === "name") o.name = i(s[c++]);
2774
+ else if (t === "identifier") o.identifier = a(s[c++]);
2775
+ else if (t === "type") o.ruleType = a(s[c++]);
2776
+ else if (t === "category") o.category = a(s[c++]);
2777
+ else if (t === "label") o.label = a(s[c++]);
2778
+ else if (t === "description") o.description = i(s[c++]);
2779
+ else if (t === "expression") o.expression = i(s[c++]);
2780
+ else if (t === "reference") o._relations.ref = r(s[c++]);
2781
+ else if (t === "ref") {
2782
+ let e = b(s, c, a, i);
2783
+ w(o, e.ref) || (o.refs ??= []).push(e.ref), c = e.next;
2784
+ } else if (t === "source") {
2785
+ let e = n(i(s[c++])), t = {
2786
+ doc: "",
2787
+ clause: ""
2788
+ };
2789
+ for (let n = 0; n + 1 < e.length; n += 2) e[n] === "doc" ? t.doc = a(e[n + 1]) : e[n] === "clause" ? t.clause = a(e[n + 1]) : e[n] === "fragment" && (t.fragment = a(e[n + 1]));
2790
+ o.sourceRef ||= t, (o.sourceRefs ??= []).push(t);
2791
+ } else if (t === "inputs") o.inputs = jn(i(s[c++]));
2792
+ else if (t === "output") {
2793
+ let e = "";
2794
+ s[c] === ":" && (e += s[c++]), c < s.length && !s[c].startsWith("{") && (e += " " + s[c++]), c < s.length && s[c].startsWith("{") && (e += " " + s[c++]), o.output = Mn(e);
2795
+ } else t === "params" ? o.params = n(a(s[c++])).map(a).filter((e) => e.length > 0) : t === "lookup" ? o.lookup = Nn(i(s[c++])) : t === "profile" ? o.profile = a(s[c++]) : c++;
2796
+ else throw Error(`Parsing error: calculation. ID ${e}: Expecting value for ${t}`);
2809
2797
  }
2810
2798
  }
2811
2799
  return (t) => (t.calculations[e] = o, t);
@@ -2919,55 +2907,52 @@ var Pn = function(e, t) {
2919
2907
  let a = r(t), o = 0;
2920
2908
  for (; o < a.length;) {
2921
2909
  let t = a[o++];
2922
- if (o < a.length) {
2923
- if (t === "kind") {
2924
- let t = a[o++];
2925
- if (t !== "lifecycle" && t !== "operational") throw Error(`Parsing error: state_machine. Entity ${e}: Unknown kind ${t} (valid: lifecycle, operational)`);
2926
- n.kind = t;
2927
- } else if (t === "initial") n.initialState = a[o++];
2928
- else if (t === "states") {
2929
- let e = i(a[o++]);
2930
- for (let t of e.split(/\s+/).filter((e) => e.length > 0)) n.states.push({ name: t });
2931
- } else if (t === "transition") {
2932
- let e = [], t = a[o++];
2933
- if (t.startsWith("[")) {
2934
- let n = t;
2935
- for (; !n.includes("]") && o < a.length;) n += " " + a[o++];
2936
- e = n.replace(/^\[/, "").replace(/\]$/, "").split(/[,\s]+/).filter((e) => e.length > 0);
2937
- } else e = [t];
2938
- o < a.length && (a[o] === "->" || a[o] === "→") && o++;
2939
- let s = o < a.length ? a[o++] : "", c = "";
2940
- o < a.length && a[o] === "action" && (o++, o < a.length && (c = a[o++]));
2941
- let l = "", u = [], d = [];
2942
- if (o < a.length && a[o].startsWith("{")) {
2943
- let e = r(i(a[o++])), t = 0;
2944
- for (; t < e.length;) {
2910
+ if (o < a.length) if (t === "kind") {
2911
+ let t = a[o++];
2912
+ if (t !== "lifecycle" && t !== "operational") throw Error(`Parsing error: state_machine. Entity ${e}: Unknown kind ${t} (valid: lifecycle, operational)`);
2913
+ n.kind = t;
2914
+ } else if (t === "initial") n.initialState = a[o++];
2915
+ else if (t === "states") {
2916
+ let e = i(a[o++]);
2917
+ for (let t of e.split(/\s+/).filter((e) => e.length > 0)) n.states.push({ name: t });
2918
+ } else if (t === "transition") {
2919
+ let e = [], t = a[o++];
2920
+ if (t.startsWith("[")) {
2921
+ let n = t;
2922
+ for (; !n.includes("]") && o < a.length;) n += " " + a[o++];
2923
+ e = n.replace(/^\[/, "").replace(/\]$/, "").split(/[,\s]+/).filter((e) => e.length > 0);
2924
+ } else e = [t];
2925
+ o < a.length && (a[o] === "->" || a[o] === "→") && o++;
2926
+ let s = o < a.length ? a[o++] : "", c = "";
2927
+ o < a.length && a[o] === "action" && (o++, o < a.length && (c = a[o++]));
2928
+ let l = "", u = [], d = [];
2929
+ if (o < a.length && a[o].startsWith("{")) {
2930
+ let e = r(i(a[o++])), t = 0;
2931
+ for (; t < e.length;) {
2932
+ let n = e[t++];
2933
+ if (t < e.length) if (n === "guard") l = i(e[t++]);
2934
+ else if (n === "cascade") {
2945
2935
  let n = e[t++];
2946
2936
  if (t < e.length) {
2947
- if (n === "guard") l = i(e[t++]);
2948
- else if (n === "cascade") {
2949
- let n = e[t++];
2950
- if (t < e.length) {
2951
- let r = i(e[t++]);
2952
- u.push(Rn(n, r));
2953
- }
2954
- } else n === "reference" ? d.push(...r(e[t++])) : i(e[t++]);
2937
+ let r = i(e[t++]);
2938
+ u.push(Rn(n, r));
2955
2939
  }
2956
- }
2957
- }
2958
- for (let t of e) {
2959
- let e = {
2960
- from: t,
2961
- to: s,
2962
- actionName: c,
2963
- guard: l,
2964
- cascades: u,
2965
- referenceIds: d
2966
- };
2967
- n.transitions.push(e);
2940
+ } else n === "reference" ? d.push(...r(e[t++])) : i(e[t++]);
2968
2941
  }
2969
- } else t === "reference" ? n.referenceIds.push(...r(a[o++])) : o++;
2970
- } else throw Error(`Parsing error: state_machine. Entity ${e}: Expecting value for ${t}`);
2942
+ }
2943
+ for (let t of e) {
2944
+ let e = {
2945
+ from: t,
2946
+ to: s,
2947
+ actionName: c,
2948
+ guard: l,
2949
+ cascades: u,
2950
+ referenceIds: d
2951
+ };
2952
+ n.transitions.push(e);
2953
+ }
2954
+ } else t === "reference" ? n.referenceIds.push(...r(a[o++])) : o++;
2955
+ else throw Error(`Parsing error: state_machine. Entity ${e}: Expecting value for ${t}`);
2971
2956
  }
2972
2957
  }
2973
2958
  return (t) => (t.stateMachines[e] = n, t);
@@ -2984,28 +2969,26 @@ function Rn(e, t) {
2984
2969
  }, s = r(t), c = 0;
2985
2970
  for (; c < s.length;) {
2986
2971
  let e = s[c++];
2987
- if (c < s.length) {
2988
- if (e === "action") {
2989
- let e = s[c++];
2990
- if (!In.includes(e)) throw Error(`Parsing error: state_machine cascade. Unknown action ${e} (valid: ${In.join(", ")})`);
2991
- o.action = e;
2992
- } else if (e === "where") o.where = i(s[c++]);
2993
- else if (e === "via") o.via = s[c++];
2994
- else if (e === "with") o.with = zn(s[c++]);
2995
- else if (e === "set") {
2996
- let e = n(i(s[c++])), t = 0;
2997
- for (; t < e.length;) {
2998
- let n = A(e[t++]);
2999
- if (t < e.length && (e[t] === ":" && t++, t < e.length)) {
3000
- let r = {
3001
- field: n,
3002
- value: a(e[t++])
3003
- };
3004
- o.set.push(r);
3005
- }
2972
+ if (c < s.length) if (e === "action") {
2973
+ let e = s[c++];
2974
+ if (!In.includes(e)) throw Error(`Parsing error: state_machine cascade. Unknown action ${e} (valid: ${In.join(", ")})`);
2975
+ o.action = e;
2976
+ } else if (e === "where") o.where = i(s[c++]);
2977
+ else if (e === "via") o.via = s[c++];
2978
+ else if (e === "with") o.with = zn(s[c++]);
2979
+ else if (e === "set") {
2980
+ let e = n(i(s[c++])), t = 0;
2981
+ for (; t < e.length;) {
2982
+ let n = A(e[t++]);
2983
+ if (t < e.length && (e[t] === ":" && t++, t < e.length)) {
2984
+ let r = {
2985
+ field: n,
2986
+ value: a(e[t++])
2987
+ };
2988
+ o.set.push(r);
3006
2989
  }
3007
- } else e === "create" ? o.create = zn(s[c++]) : i(s[c++]);
3008
- }
2990
+ }
2991
+ } else e === "create" ? o.create = zn(s[c++]) : i(s[c++]);
3009
2992
  }
3010
2993
  if (o.action && (o.set.length > 0 || o.create !== null)) throw Error(`Parsing error: state_machine cascade. Target ${e} mixes action with set/create — the two forms are mutually exclusive (schema oneOf)`);
3011
2994
  return o;
@@ -6142,13 +6125,13 @@ var za = function(e, t) {
6142
6125
  else if (e === "content_contract") n.contentContract = Ra(i(o[s++]));
6143
6126
  else if (e === "produced_when") {
6144
6127
  let e = a(o[s++] ?? "");
6145
- n.producedWhen = e === "per_interval" ? {
6128
+ e === "per_interval" ? n.producedWhen = {
6146
6129
  kind: e,
6147
6130
  interval: a(o[s++] ?? "")
6148
- } : e === "on_event" ? {
6131
+ } : e === "on_event" ? n.producedWhen = {
6149
6132
  kind: e,
6150
6133
  event: a(o[s++] ?? "")
6151
- } : { kind: e };
6134
+ } : n.producedWhen = { kind: e };
6152
6135
  } else if (e === "retention") n.retention = a(o[s++]);
6153
6136
  else if (e === "source") {
6154
6137
  let e = N(i(o[s++]));
@@ -8005,7 +7988,7 @@ function As(e) {
8005
7988
  let i = /* @__PURE__ */ new Set();
8006
7989
  return t.filter((e) => {
8007
7990
  let t = js(e);
8008
- return !i.has(t) && (i.add(t), !0);
7991
+ return i.has(t) ? !1 : (i.add(t), !0);
8009
7992
  });
8010
7993
  }
8011
7994
  function js(e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primmel/primmel",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "description": "Primmel — parser, types, and serializer for the Primmel modelling language (successor to MMEL)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",