@dialecte/scl 0.2.3 → 0.2.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.
@@ -1,6 +1,6 @@
1
- import { toRawRecord as d, isElementOf as T } from "@dialecte/core/helpers";
2
- import { invariant as I } from "@dialecte/core/utils";
3
- const H = [
1
+ import { toRawRecord as p, isElementOf as M, isChildOf as I, stripAttributes as Ce } from "@dialecte/core/helpers";
2
+ import { invariant as F } from "@dialecte/core/utils";
3
+ const ge = [
4
4
  "AccessControl",
5
5
  "AccessPoint",
6
6
  "Address",
@@ -211,7 +211,7 @@ const H = [
211
211
  "VariableRef",
212
212
  "Voltage",
213
213
  "VoltageLevel"
214
- ], W = {
214
+ ], ve = {
215
215
  AccessControl: [],
216
216
  AccessPoint: [
217
217
  "Text",
@@ -779,7 +779,7 @@ const H = [
779
779
  "ProcessResources",
780
780
  "Variable"
781
781
  ]
782
- }, K = {
782
+ }, Te = {
783
783
  AccessControl: ["LDevice"],
784
784
  AccessPoint: ["IED"],
785
785
  Address: ["ConnectedAP", "GSE", "SMV"],
@@ -3255,7 +3255,7 @@ const H = [
3255
3255
  "VariableRef",
3256
3256
  "Voltage"
3257
3257
  ]
3258
- }, Q = {
3258
+ }, he = {
3259
3259
  AccessControl: ["AccessPoint", "IED", "LDevice", "SCL", "Server"],
3260
3260
  AccessPoint: ["IED", "SCL"],
3261
3261
  Address: ["Communication", "ConnectedAP", "GSE", "SCL", "SMV", "SubNetwork"],
@@ -4933,13 +4933,13 @@ const H = [
4933
4933
  ],
4934
4934
  Voltage: ["Line", "Process", "SCL", "Substation", "VoltageLevel"],
4935
4935
  VoltageLevel: ["Process", "SCL", "Substation"]
4936
- }, Y = "SCL", j = [
4936
+ }, Ne = "SCL", Ie = [
4937
4937
  "Communication",
4938
4938
  "DataTypeTemplates",
4939
4939
  "Header",
4940
4940
  "History",
4941
4941
  "SCL"
4942
- ], w = {
4942
+ ], Q = {
4943
4943
  AccessControl: {},
4944
4944
  AccessPoint: {
4945
4945
  clock: "",
@@ -6256,7 +6256,7 @@ const H = [
6256
6256
  templateUuid: "",
6257
6257
  uuid: ""
6258
6258
  }
6259
- }, D = {
6259
+ }, G = {
6260
6260
  AccessControl: {
6261
6261
  tag: "AccessControl",
6262
6262
  namespace: { prefix: "", uri: "http://www.iec.ch/61850/2003/SCL" },
@@ -21145,133 +21145,133 @@ const H = [
21145
21145
  ]
21146
21146
  }
21147
21147
  };
21148
- async function $(a) {
21149
- const { childRecord: e, parentRecord: t, query: i } = a;
21150
- if (e.namespace.prefix === P.namespaces.default.prefix)
21148
+ async function we(e) {
21149
+ const { childRecord: a, parentRecord: t, query: i } = e;
21150
+ if (a.namespace.prefix === P.namespaces.default.prefix)
21151
21151
  return [];
21152
- const n = t.tagName === "Private", u = t.namespace.prefix === P.namespaces.default.prefix;
21153
- if (!n && !u)
21152
+ const n = t.tagName === "Private", r = t.namespace.prefix === P.namespaces.default.prefix;
21153
+ if (!n && !r)
21154
21154
  return [];
21155
- const r = t.children.find((o) => o.tagName === "Private"), s = {
21155
+ const s = t.children.find((l) => l.tagName === "Private"), u = {
21156
21156
  ...t,
21157
- children: t.children.filter((o) => o.id !== e.id)
21157
+ children: t.children.filter((l) => l.id !== a.id)
21158
21158
  };
21159
- return n ? J({ parentRecord: t, childRecord: e, query: i }) : r ? ee({
21160
- existingPrivateRef: r,
21159
+ return n ? De({ parentRecord: t, childRecord: a, query: i }) : s ? Fe({
21160
+ existingPrivateRef: s,
21161
21161
  parentRecord: t,
21162
- updatedParentRecord: s,
21163
- childRecord: e,
21162
+ updatedParentRecord: u,
21163
+ childRecord: a,
21164
21164
  query: i
21165
21165
  }) : (await i.findAncestors(t)).some(
21166
- (o) => o.tagName === "Private" && o.attributes.some(
21167
- (p) => p.name === "type" && p.value === e.namespace.prefix
21166
+ (l) => l.tagName === "Private" && l.attributes.some(
21167
+ (d) => d.name === "type" && d.value === a.namespace.prefix
21168
21168
  )
21169
- ) ? [] : te({ parentRecord: t, updatedParentRecord: s, childRecord: e });
21169
+ ) ? [] : ye({ parentRecord: t, updatedParentRecord: u, childRecord: a });
21170
21170
  }
21171
- async function J(a) {
21172
- const { parentRecord: e, childRecord: t, query: i } = a, n = e;
21171
+ async function De(e) {
21172
+ const { parentRecord: a, childRecord: t, query: i } = e, n = a;
21173
21173
  if (t.parent?.id === n.id && t.parent?.tagName === "Private")
21174
21174
  return [];
21175
- const u = await F({ privateId: n.id, query: i });
21176
- I(u, {
21175
+ const r = await Y({ privateId: n.id, query: i });
21176
+ F(r, {
21177
21177
  detail: "Latest private record not found",
21178
21178
  key: "ELEMENT_NOT_FOUND"
21179
21179
  });
21180
- const { childRecord: r, privateRecord: s } = q({
21181
- privateRecord: u,
21180
+ const { childRecord: s, privateRecord: u } = j({
21181
+ privateRecord: r,
21182
21182
  childRecord: t
21183
21183
  });
21184
21184
  return [
21185
21185
  {
21186
21186
  status: "updated",
21187
- oldRecord: d(t),
21188
- newRecord: d(r)
21187
+ oldRecord: p(t),
21188
+ newRecord: p(s)
21189
21189
  },
21190
21190
  {
21191
21191
  status: "updated",
21192
- oldRecord: d(u),
21193
- newRecord: d(s)
21192
+ oldRecord: p(r),
21193
+ newRecord: p(u)
21194
21194
  }
21195
21195
  ];
21196
21196
  }
21197
- async function ee(a) {
21198
- const { existingPrivateRef: e, parentRecord: t, updatedParentRecord: i, childRecord: n, query: u } = a, r = await F({
21199
- privateId: e.id,
21200
- query: u
21197
+ async function Fe(e) {
21198
+ const { existingPrivateRef: a, parentRecord: t, updatedParentRecord: i, childRecord: n, query: r } = e, s = await Y({
21199
+ privateId: a.id,
21200
+ query: r
21201
21201
  });
21202
- if (I(r, {
21202
+ if (F(s, {
21203
21203
  detail: "Latest private record not found",
21204
21204
  key: "ELEMENT_NOT_FOUND"
21205
- }), !r.attributes.some(
21206
- (o) => o.name === "type" && o.value === n.namespace.prefix
21205
+ }), !s.attributes.some(
21206
+ (l) => l.name === "type" && l.value === n.namespace.prefix
21207
21207
  )) return [];
21208
- const { childRecord: c, privateRecord: l } = q({
21209
- privateRecord: r,
21208
+ const { childRecord: c, privateRecord: o } = j({
21209
+ privateRecord: s,
21210
21210
  childRecord: n
21211
21211
  });
21212
21212
  return [
21213
21213
  {
21214
21214
  status: "updated",
21215
- oldRecord: d(n),
21216
- newRecord: d(c)
21215
+ oldRecord: p(n),
21216
+ newRecord: p(c)
21217
21217
  },
21218
21218
  {
21219
21219
  status: "updated",
21220
- oldRecord: d(r),
21221
- newRecord: d(l)
21220
+ oldRecord: p(s),
21221
+ newRecord: p(o)
21222
21222
  },
21223
21223
  {
21224
21224
  status: "updated",
21225
- oldRecord: d(t),
21226
- newRecord: d(i)
21225
+ oldRecord: p(t),
21226
+ newRecord: p(i)
21227
21227
  }
21228
21228
  ];
21229
21229
  }
21230
- function te(a) {
21231
- const { parentRecord: e, updatedParentRecord: t, childRecord: i } = a, n = {
21230
+ function ye(e) {
21231
+ const { parentRecord: a, updatedParentRecord: t, childRecord: i } = e, n = {
21232
21232
  id: crypto.randomUUID(),
21233
21233
  tagName: "Private",
21234
21234
  namespace: P.namespaces.default,
21235
21235
  attributes: [{ name: "type", value: i.namespace.prefix }],
21236
21236
  value: "",
21237
- parent: { id: e.id, tagName: e.tagName },
21237
+ parent: { id: a.id, tagName: a.tagName },
21238
21238
  children: [{ id: i.id, tagName: i.tagName }]
21239
- }, u = {
21239
+ }, r = {
21240
21240
  ...i,
21241
21241
  parent: { id: n.id, tagName: "Private" }
21242
- }, r = {
21242
+ }, s = {
21243
21243
  ...t,
21244
21244
  children: [...t.children, { id: n.id, tagName: "Private" }]
21245
21245
  };
21246
21246
  return [
21247
- { status: "created", oldRecord: void 0, newRecord: d(n) },
21247
+ { status: "created", oldRecord: void 0, newRecord: p(n) },
21248
21248
  {
21249
21249
  status: "updated",
21250
- oldRecord: d(i),
21251
- newRecord: d(u)
21250
+ oldRecord: p(i),
21251
+ newRecord: p(r)
21252
21252
  },
21253
21253
  {
21254
21254
  status: "updated",
21255
- oldRecord: d(e),
21256
- newRecord: d(r)
21255
+ oldRecord: p(a),
21256
+ newRecord: p(s)
21257
21257
  }
21258
21258
  ];
21259
21259
  }
21260
- async function F(a) {
21261
- const { privateId: e, query: t } = a;
21262
- return await t.getRecord({ id: e, tagName: "Private" });
21260
+ async function Y(e) {
21261
+ const { privateId: a, query: t } = e;
21262
+ return await t.getRecord({ id: a, tagName: "Private" });
21263
21263
  }
21264
- function q(a) {
21265
- const { privateRecord: e, childRecord: t } = a, i = {
21264
+ function j(e) {
21265
+ const { privateRecord: a, childRecord: t } = e, i = {
21266
21266
  ...t,
21267
- parent: { id: e.id, tagName: "Private" }
21267
+ parent: { id: a.id, tagName: "Private" }
21268
21268
  }, n = {
21269
- ...e,
21270
- children: [...e.children, { id: t.id, tagName: t.tagName }]
21269
+ ...a,
21270
+ children: [...a.children, { id: t.id, tagName: t.tagName }]
21271
21271
  };
21272
21272
  return { childRecord: i, privateRecord: n };
21273
21273
  }
21274
- const y = {
21274
+ const $ = {
21275
21275
  // Transparent - do not contribute a path segment
21276
21276
  AccessPoint: { type: "transparent" },
21277
21277
  Server: { type: "transparent" },
@@ -21329,17 +21329,17 @@ const y = {
21329
21329
  PowerSystemRelation: { type: "name" },
21330
21330
  Variable: { type: "name" },
21331
21331
  Process: { type: "name" }
21332
- }, ae = ["lnClass", "prefix", "inst", "lnInst"], ie = new Set(
21333
- Object.values(y).flatMap((a) => {
21334
- switch (a.type) {
21332
+ }, qe = ["lnClass", "prefix", "inst", "lnInst"], xe = new Set(
21333
+ Object.values($).flatMap((e) => {
21334
+ switch (e.type) {
21335
21335
  case "transparent":
21336
21336
  return [];
21337
21337
  case "name":
21338
21338
  return ["name"];
21339
21339
  case "lnClass":
21340
- return [...ae];
21340
+ return [...qe];
21341
21341
  case "attribute":
21342
- return [a.attr];
21342
+ return [e.attr];
21343
21343
  case "sourceRef":
21344
21344
  return ["input", "inputInst", "pDA"];
21345
21345
  case "controlRef":
@@ -21347,308 +21347,308 @@ const y = {
21347
21347
  }
21348
21348
  })
21349
21349
  );
21350
- function ne(a) {
21351
- switch (a.type) {
21350
+ function Oe(e) {
21351
+ switch (e.type) {
21352
21352
  case "transparent":
21353
21353
  return () => null;
21354
21354
  case "name": {
21355
- const e = a.separator ?? "/";
21355
+ const a = e.separator ?? "/";
21356
21356
  return (t) => {
21357
- const i = b(t, "name");
21358
- return i ? { segment: i, separator: e } : null;
21357
+ const i = R(t, "name");
21358
+ return i ? { segment: i, separator: a } : null;
21359
21359
  };
21360
21360
  }
21361
21361
  case "lnClass":
21362
- return (e) => {
21363
- const t = b(e, "lnClass");
21362
+ return (a) => {
21363
+ const t = R(a, "lnClass");
21364
21364
  if (!t) return null;
21365
- const i = b(e, "prefix") ?? "", n = b(e, "inst") ?? b(e, "lnInst") ?? "";
21365
+ const i = R(a, "prefix") ?? "", n = R(a, "inst") ?? R(a, "lnInst") ?? "";
21366
21366
  return { segment: `${i}${t}${n}`, separator: "/" };
21367
21367
  };
21368
21368
  case "attribute":
21369
- return (e) => {
21370
- const t = b(e, a.attr);
21371
- return t ? { segment: t, separator: a.separator } : null;
21369
+ return (a) => {
21370
+ const t = R(a, e.attr);
21371
+ return t ? { segment: t, separator: e.separator } : null;
21372
21372
  };
21373
21373
  case "sourceRef":
21374
- return (e) => {
21375
- const t = b(e, "input");
21374
+ return (a) => {
21375
+ const t = R(a, "input");
21376
21376
  if (!t) return null;
21377
21377
  let i = t;
21378
- const n = b(e, "inputInst");
21378
+ const n = R(a, "inputInst");
21379
21379
  n && n !== "1" && (i += `(${n})`);
21380
- const u = b(e, "pDA");
21381
- return u && (i += `.${u}`), { segment: i, separator: "." };
21380
+ const r = R(a, "pDA");
21381
+ return r && (i += `.${r}`), { segment: i, separator: "." };
21382
21382
  };
21383
21383
  case "controlRef":
21384
- return (e) => {
21385
- const t = b(e, "output");
21384
+ return (a) => {
21385
+ const t = R(a, "output");
21386
21386
  if (!t) return null;
21387
21387
  let i = t;
21388
- const n = b(e, "outputInst");
21388
+ const n = R(a, "outputInst");
21389
21389
  return n && n !== "1" && (i += `(${n})`), { segment: i, separator: "." };
21390
21390
  };
21391
21391
  }
21392
21392
  }
21393
- const re = Object.fromEntries(
21394
- Object.entries(y).map(([a, e]) => [a, ne(e)])
21393
+ const Ee = Object.fromEntries(
21394
+ Object.entries($).map(([e, a]) => [e, Oe(a)])
21395
21395
  );
21396
- function L(a) {
21397
- const e = re[a.tagName];
21398
- return e ? e(a) : null;
21396
+ function A(e) {
21397
+ const a = Ee[e.tagName];
21398
+ return a ? a(e) : null;
21399
21399
  }
21400
- function x(a) {
21401
- const { record: e, ancestry: t } = a, i = [];
21402
- for (const u of t) {
21403
- const r = L(u);
21404
- r && i.push({ ...r, ref: { tagName: u.tagName, id: u.id } });
21400
+ function J(e) {
21401
+ const { record: a, ancestry: t } = e, i = [];
21402
+ for (const r of t) {
21403
+ const s = A(r);
21404
+ s && i.push({ ...s, ref: { tagName: r.tagName, id: r.id } });
21405
21405
  }
21406
- const n = L(e);
21407
- return n && i.push({ ...n, ref: { tagName: e.tagName, id: e.id } }), i.length === 0 ? null : { path: O(i), segments: i };
21406
+ const n = A(a);
21407
+ return n && i.push({ ...n, ref: { tagName: a.tagName, id: a.id } }), i.length === 0 ? null : { path: ee(i), segments: i };
21408
21408
  }
21409
- function b(a, e) {
21410
- return a.attributes.find((t) => t.name === e)?.value;
21409
+ function R(e, a) {
21410
+ return e.attributes.find((t) => t.name === a)?.value;
21411
21411
  }
21412
- function O(a) {
21413
- let e = a[0].segment;
21414
- for (let t = 1; t < a.length; t++)
21415
- e += a[t].separator + a[t].segment;
21416
- return e;
21412
+ function ee(e) {
21413
+ let a = e[0].segment;
21414
+ for (let t = 1; t < e.length; t++)
21415
+ a += e[t].separator + e[t].segment;
21416
+ return a;
21417
21417
  }
21418
- async function E(a, e) {
21419
- const t = await a.getRecord(e);
21418
+ async function te(e, a) {
21419
+ const t = await e.getRecord(a);
21420
21420
  if (!t) return null;
21421
- const i = await a.findAncestors(e, { order: "top-down" });
21422
- return x({
21423
- record: d(t),
21424
- ancestry: i.map(d)
21421
+ const i = await e.findAncestors(a, { order: "top-down" });
21422
+ return J({
21423
+ record: p(t),
21424
+ ancestry: i.map(p)
21425
21425
  });
21426
21426
  }
21427
- function k(a) {
21428
- if (!a) return [];
21429
- const e = [];
21427
+ function ae(e) {
21428
+ if (!e) return [];
21429
+ const a = [];
21430
21430
  let t = "", i = "/";
21431
- for (const n of a)
21432
- n === "/" || n === "." ? (t && e.push({ segment: t, separator: i }), i = n, t = "") : t += n;
21433
- return t && e.push({ segment: t, separator: i }), e;
21431
+ for (const n of e)
21432
+ n === "/" || n === "." ? (t && a.push({ segment: t, separator: i }), i = n, t = "") : t += n;
21433
+ return t && a.push({ segment: t, separator: i }), a;
21434
21434
  }
21435
- function V(a) {
21436
- const e = a.split("/"), t = e[e.length - 1], i = t.indexOf(".");
21437
- if (i === -1) return { path: a };
21438
- const n = t.substring(0, i), u = t.substring(i + 1);
21439
- return { path: [...e.slice(0, -1), n].join("/"), qualifier: u || void 0 };
21435
+ function ie(e) {
21436
+ const a = e.split("/"), t = a[a.length - 1], i = t.indexOf(".");
21437
+ if (i === -1) return { path: e };
21438
+ const n = t.substring(0, i), r = t.substring(i + 1);
21439
+ return { path: [...a.slice(0, -1), n].join("/"), qualifier: r || void 0 };
21440
21440
  }
21441
- function Z(a, e, t, i) {
21442
- return !a || a === f.unsupported ? null : a === f.direct ? { lookupKey: t } : a === f.iedAddress ? se(t, i) : a === f.lnode ? ue(t) : a === f.behaviorDescription ? ce(e, t, i) : null;
21441
+ function ne(e, a, t, i) {
21442
+ return !e || e === b.unsupported ? null : e === b.direct ? { lookupKey: t } : e === b.iedAddress ? Ve(t, i) : e === b.lnode ? ke(t) : e === b.behaviorDescription ? Ze(a, t, i) : null;
21443
21443
  }
21444
- function ue(a) {
21445
- const { path: e, qualifier: t } = V(a);
21446
- return { lookupKey: e, qualifier: t };
21444
+ function ke(e) {
21445
+ const { path: a, qualifier: t } = ie(e);
21446
+ return { lookupKey: a, qualifier: t };
21447
21447
  }
21448
- function se(a, e) {
21449
- if (e) {
21450
- const t = de(e);
21448
+ function Ve(e, a) {
21449
+ if (a) {
21450
+ const t = Be(a);
21451
21451
  if (t)
21452
- return { lookupKey: a, fallbackLookupKey: `${t}/${a}` };
21452
+ return { lookupKey: e, fallbackLookupKey: `${t}/${e}` };
21453
21453
  }
21454
- return { lookupKey: a };
21454
+ return { lookupKey: e };
21455
21455
  }
21456
- function ce(a, e, t) {
21456
+ function Ze(e, a, t) {
21457
21457
  if (!t) return null;
21458
- const i = oe(t);
21458
+ const i = Me(t);
21459
21459
  if (!i) return null;
21460
- if (a === "dataName")
21461
- return { lookupKey: i, qualifier: e };
21462
- if (a === "inputName" || a === "outputName") {
21463
- const n = le(e);
21460
+ if (e === "dataName")
21461
+ return { lookupKey: i, qualifier: a };
21462
+ if (e === "inputName" || e === "outputName") {
21463
+ const n = Ge(a);
21464
21464
  return { lookupKey: `${i}.${n}` };
21465
21465
  }
21466
21466
  return null;
21467
21467
  }
21468
- function oe(a) {
21469
- let e = -1;
21470
- for (let i = a.length - 1; i >= 0; i--)
21471
- if (a[i].tagName === "BehaviorDescription") {
21472
- e = i;
21468
+ function Me(e) {
21469
+ let a = -1;
21470
+ for (let i = e.length - 1; i >= 0; i--)
21471
+ if (e[i].tagName === "BehaviorDescription") {
21472
+ a = i;
21473
21473
  break;
21474
21474
  }
21475
- if (e === -1) return null;
21475
+ if (a === -1) return null;
21476
21476
  const t = [];
21477
- for (let i = 0; i < e; i++) {
21478
- const n = L(a[i]);
21477
+ for (let i = 0; i < a; i++) {
21478
+ const n = A(e[i]);
21479
21479
  n && t.push(n);
21480
21480
  }
21481
- return t.length === 0 ? null : O(t);
21481
+ return t.length === 0 ? null : ee(t);
21482
21482
  }
21483
- function le(a) {
21484
- const e = a.indexOf("("), t = a.indexOf(".");
21485
- return e !== -1 ? a.substring(0, e) : t !== -1 ? a.substring(0, t) : a;
21483
+ function Ge(e) {
21484
+ const a = e.indexOf("("), t = e.indexOf(".");
21485
+ return a !== -1 ? e.substring(0, a) : t !== -1 ? e.substring(0, t) : e;
21486
21486
  }
21487
- function de(a) {
21488
- for (let e = a.length - 1; e >= 0; e--)
21489
- if (a[e].tagName === "LNode")
21490
- return a[e].attributes.find((t) => t.name === "iedName")?.value ?? null;
21487
+ function Be(e) {
21488
+ for (let a = e.length - 1; a >= 0; a--)
21489
+ if (e[a].tagName === "LNode")
21490
+ return e[a].attributes.find((t) => t.name === "iedName")?.value ?? null;
21491
21491
  return null;
21492
21492
  }
21493
- async function M(a, e) {
21494
- const { reference: t, target: i } = e, n = pe(t.tagName, i.tagName);
21493
+ async function re(e, a) {
21494
+ const { reference: t, target: i } = a, n = Ue(t.tagName, i.tagName);
21495
21495
  if (!n) return null;
21496
- const u = n.resolution;
21497
- if (u === f.unsupported) return null;
21498
- if (u === f.behaviorDescription) {
21499
- const c = await a.getRecord(i);
21500
- return c ? L(d(c))?.segment ?? null : null;
21496
+ const r = n.resolution;
21497
+ if (r === b.unsupported) return null;
21498
+ if (r === b.behaviorDescription) {
21499
+ const c = await e.getRecord(i);
21500
+ return c ? A(p(c))?.segment ?? null : null;
21501
21501
  }
21502
- const r = await E(a, i);
21503
- if (!r) return null;
21504
- const s = r.path;
21505
- if (u === f.lnode) {
21506
- const c = await a.getRecord(t);
21507
- if (!c) return s;
21508
- const l = c.attributes.find((p) => p.name === n.attribute.path)?.value;
21509
- if (!l) return s;
21510
- const { qualifier: o } = V(l);
21511
- return o ? `${s}.${o}` : s;
21502
+ const s = await te(e, i);
21503
+ if (!s) return null;
21504
+ const u = s.path;
21505
+ if (r === b.lnode) {
21506
+ const c = await e.getRecord(t);
21507
+ if (!c) return u;
21508
+ const o = c.attributes.find((d) => d.name === n.attribute.path)?.value;
21509
+ if (!o) return u;
21510
+ const { qualifier: l } = ie(o);
21511
+ return l ? `${u}.${l}` : u;
21512
21512
  }
21513
- return s;
21513
+ return u;
21514
21514
  }
21515
- function pe(a, e) {
21516
- const t = m[a];
21517
- return t ? t.find((i) => i.target.includes(e)) ?? null : null;
21515
+ function Ue(e, a) {
21516
+ const t = m[e];
21517
+ return t ? t.find((i) => i.target.includes(a)) ?? null : null;
21518
21518
  }
21519
- async function Se(a, e, t) {
21520
- const i = fe(e.tagName, t);
21519
+ async function ze(e, a, t) {
21520
+ const i = _e(a.tagName, t);
21521
21521
  if (!i) return;
21522
- const n = e.attributes.find((p) => p.name === t)?.value;
21522
+ const n = a.attributes.find((d) => d.name === t)?.value;
21523
21523
  if (!n) return;
21524
- let u;
21525
- (i.resolution === f.behaviorDescription || i.resolution === f.iedAddress) && (u = (await a.findAncestors(e, { order: "top-down" })).map((R) => d(R)));
21526
- const r = Z(
21524
+ let r;
21525
+ (i.resolution === b.behaviorDescription || i.resolution === b.iedAddress) && (r = (await e.findAncestors(a, { order: "top-down" })).map((f) => p(f)));
21526
+ const s = ne(
21527
21527
  i.resolution,
21528
21528
  t,
21529
21529
  n,
21530
- u
21530
+ r
21531
21531
  );
21532
- if (!r) return;
21533
- const s = k(r.lookupKey);
21534
- if (s.length === 0) return;
21535
- const c = s[s.length - 1], l = s.slice(0, -1), o = await Le({
21536
- query: a,
21532
+ if (!s) return;
21533
+ const u = ae(s.lookupKey);
21534
+ if (u.length === 0) return;
21535
+ const c = u[u.length - 1], o = u.slice(0, -1), l = await Xe({
21536
+ query: e,
21537
21537
  targets: i.target,
21538
21538
  segment: c,
21539
- expectedAncestry: l
21539
+ expectedAncestry: o
21540
21540
  });
21541
- if (o)
21542
- return { record: o, qualifier: r.qualifier };
21541
+ if (l)
21542
+ return { record: l, qualifier: s.qualifier };
21543
21543
  }
21544
- function fe(a, e) {
21545
- const t = m[a];
21544
+ function _e(e, a) {
21545
+ const t = m[e];
21546
21546
  if (t)
21547
- return t.find((i) => i.attribute.path === e);
21547
+ return t.find((i) => i.attribute.path === a);
21548
21548
  }
21549
- const me = new Set(
21550
- D.LNode.attributes.details.lnClass.facets.enumeration
21551
- ), be = {
21549
+ const He = new Set(
21550
+ G.LNode.attributes.details.lnClass.facets.enumeration
21551
+ ), We = {
21552
21552
  LNode: "lnInst",
21553
21553
  LN: "inst",
21554
21554
  LN0: "inst"
21555
21555
  };
21556
- function Re(a) {
21557
- for (let e = 0; e <= a.length - 4; e++) {
21558
- const t = a.substring(e, e + 4);
21559
- if (me.has(t))
21556
+ function Ke(e) {
21557
+ for (let a = 0; a <= e.length - 4; a++) {
21558
+ const t = e.substring(a, a + 4);
21559
+ if (He.has(t))
21560
21560
  return {
21561
- prefix: a.substring(0, e),
21561
+ prefix: e.substring(0, a),
21562
21562
  lnClass: t,
21563
- inst: a.substring(e + 4)
21563
+ inst: e.substring(a + 4)
21564
21564
  };
21565
21565
  }
21566
21566
  return null;
21567
21567
  }
21568
- async function Le(a) {
21569
- const { query: e, targets: t, segment: i, expectedAncestry: n } = a;
21570
- for (const u of t) {
21571
- const r = be[u];
21572
- if (r) {
21573
- const s = await Pe({
21574
- query: e,
21575
- tagName: u,
21568
+ async function Xe(e) {
21569
+ const { query: a, targets: t, segment: i, expectedAncestry: n } = e;
21570
+ for (const r of t) {
21571
+ const s = We[r];
21572
+ if (s) {
21573
+ const u = await Qe({
21574
+ query: a,
21575
+ tagName: r,
21576
21576
  segment: i,
21577
- instAttr: r,
21577
+ instAttr: s,
21578
21578
  expectedAncestry: n
21579
21579
  });
21580
- if (s) return s;
21580
+ if (u) return u;
21581
21581
  } else {
21582
- const s = await Ce({
21583
- query: e,
21584
- tagName: u,
21582
+ const u = await Ye({
21583
+ query: a,
21584
+ tagName: r,
21585
21585
  segment: i,
21586
21586
  expectedAncestry: n
21587
21587
  });
21588
- if (s) return s;
21588
+ if (u) return u;
21589
21589
  }
21590
21590
  }
21591
21591
  }
21592
- async function Pe(a) {
21593
- const { query: e, tagName: t, segment: i, instAttr: n, expectedAncestry: u } = a, r = Re(i.segment);
21594
- if (!r) return;
21595
- const s = await e.findByAttributes({
21592
+ async function Qe(e) {
21593
+ const { query: a, tagName: t, segment: i, instAttr: n, expectedAncestry: r } = e, s = Ke(i.segment);
21594
+ if (!s) return;
21595
+ const u = await a.findByAttributes({
21596
21596
  tagName: t,
21597
- attributes: { lnClass: r.lnClass }
21597
+ attributes: { lnClass: s.lnClass }
21598
21598
  });
21599
- for (const c of s) {
21600
- const l = c.attributes.find((p) => p.name === "prefix")?.value ?? "", o = c.attributes.find((p) => p.name === n)?.value ?? "";
21601
- if (!(l !== r.prefix || o !== r.inst) && await G(e, c, u))
21599
+ for (const c of u) {
21600
+ const o = c.attributes.find((d) => d.name === "prefix")?.value ?? "", l = c.attributes.find((d) => d.name === n)?.value ?? "";
21601
+ if (!(o !== s.prefix || l !== s.inst) && await se(a, c, r))
21602
21602
  return c;
21603
21603
  }
21604
21604
  }
21605
- async function Ce(a) {
21606
- const { query: e, tagName: t, segment: i, expectedAncestry: n } = a, u = await e.getRecordsByTagName(t);
21607
- for (const r of u) {
21608
- const s = L(d(r));
21609
- if (!(!s || s.segment !== i.segment) && await G(e, r, n))
21610
- return r;
21605
+ async function Ye(e) {
21606
+ const { query: a, tagName: t, segment: i, expectedAncestry: n } = e, r = await a.getRecordsByTagName(t);
21607
+ for (const s of r) {
21608
+ const u = A(p(s));
21609
+ if (!(!u || u.segment !== i.segment) && await se(a, s, n))
21610
+ return s;
21611
21611
  }
21612
21612
  }
21613
- async function G(a, e, t) {
21613
+ async function se(e, a, t) {
21614
21614
  if (t.length === 0) return !0;
21615
- const i = await a.findAncestors(e), n = [];
21616
- for (let u = i.length - 1; u >= 0; u--) {
21617
- const r = L(d(i[u]));
21618
- r && n.push(r);
21615
+ const i = await e.findAncestors(a), n = [];
21616
+ for (let r = i.length - 1; r >= 0; r--) {
21617
+ const s = A(p(i[r]));
21618
+ s && n.push(s);
21619
21619
  }
21620
- return n.length !== t.length ? !1 : n.every((u, r) => u.segment === t[r].segment);
21620
+ return n.length !== t.length ? !1 : n.every((r, s) => r.segment === t[s].segment);
21621
21621
  }
21622
- async function Ae(a, e) {
21623
- const t = k(e);
21622
+ async function je(e, a) {
21623
+ const t = ae(a);
21624
21624
  if (t.length === 0) return;
21625
- const i = await a.getRoot();
21626
- return v({
21627
- query: a,
21625
+ const i = await e.getRoot();
21626
+ return k({
21627
+ query: e,
21628
21628
  current: i,
21629
21629
  segments: t,
21630
21630
  index: 0
21631
21631
  });
21632
21632
  }
21633
- async function v(a) {
21634
- const { query: e, current: t, segments: i, index: n } = a;
21633
+ async function k(e) {
21634
+ const { query: a, current: t, segments: i, index: n } = e;
21635
21635
  if (n >= i.length) return t;
21636
- const u = t.children ?? [];
21637
- if (u.length === 0) return;
21638
- const r = await e.getRecords(u), s = i[n];
21639
- for (const c of r) {
21636
+ const r = t.children ?? [];
21637
+ if (r.length === 0) return;
21638
+ const s = await a.getRecords(r), u = i[n];
21639
+ for (const c of s) {
21640
21640
  if (!c) continue;
21641
- const l = L(d(c));
21642
- if (!l) {
21643
- const o = await v({ query: e, current: c, segments: i, index: n });
21644
- if (o) return o;
21641
+ const o = A(p(c));
21642
+ if (!o) {
21643
+ const l = await k({ query: a, current: c, segments: i, index: n });
21644
+ if (l) return l;
21645
21645
  continue;
21646
21646
  }
21647
- if (l.segment === s.segment && l.separator === s.separator)
21648
- return v({ query: e, current: c, segments: i, index: n + 1 });
21647
+ if (o.segment === u.segment && o.separator === u.separator)
21648
+ return k({ query: a, current: c, segments: i, index: n + 1 });
21649
21649
  }
21650
21650
  }
21651
- const f = {
21651
+ const b = {
21652
21652
  direct: "direct",
21653
21653
  lnode: "lnode",
21654
21654
  iedAddress: "ied-address",
@@ -21945,26 +21945,26 @@ const f = {
21945
21945
  }
21946
21946
  ]
21947
21947
  };
21948
- function ge(a) {
21949
- const e = {};
21950
- for (const [t, i] of Object.entries(a))
21948
+ function $e(e) {
21949
+ const a = {};
21950
+ for (const [t, i] of Object.entries(e))
21951
21951
  for (const n of i) {
21952
- const u = e[n.resolution] ??= /* @__PURE__ */ new Map();
21953
- for (const r of n.target) {
21954
- const s = u.get(r) ?? [];
21955
- s.push({
21952
+ const r = a[n.resolution] ??= /* @__PURE__ */ new Map();
21953
+ for (const s of n.target) {
21954
+ const u = r.get(s) ?? [];
21955
+ u.push({
21956
21956
  refTagName: t,
21957
21957
  uuidAttr: n.attribute.uuid,
21958
21958
  pathAttr: n.attribute.path
21959
- }), u.set(r, s);
21959
+ }), r.set(s, u);
21960
21960
  }
21961
21961
  }
21962
- return e;
21962
+ return a;
21963
21963
  }
21964
- function ve(a) {
21965
- const e = /* @__PURE__ */ new Map();
21966
- for (const [t, i] of Object.entries(a))
21967
- e.set(
21964
+ function Je(e) {
21965
+ const a = /* @__PURE__ */ new Map();
21966
+ for (const [t, i] of Object.entries(e))
21967
+ a.set(
21968
21968
  t,
21969
21969
  i.map((n) => ({
21970
21970
  uuidAttr: n.attribute.uuid,
@@ -21973,255 +21973,255 @@ function ve(a) {
21973
21973
  targetTagNames: n.target
21974
21974
  }))
21975
21975
  );
21976
- return e;
21976
+ return a;
21977
21977
  }
21978
- const B = ge(m), U = [
21979
- f.direct,
21980
- f.lnode,
21981
- f.iedAddress,
21982
- f.behaviorDescription
21983
- ], Te = ve(m);
21978
+ const ue = $e(m), ce = [
21979
+ b.direct,
21980
+ b.lnode,
21981
+ b.iedAddress,
21982
+ b.behaviorDescription
21983
+ ], et = Je(m);
21984
21984
  [
21985
21985
  ...new Set(
21986
21986
  Object.values(m).flatMap(
21987
- (a) => a.map((e) => e.attribute.uuid)
21987
+ (e) => e.map((a) => a.attribute.uuid)
21988
21988
  )
21989
21989
  )
21990
21990
  ];
21991
- const he = /* @__PURE__ */ new Set(["SourceRef", "ControlRef", "DOS", "SDS", "DAS", "InputVar", "OutputVar", "ProcessEcho"]), bt = {
21991
+ const oe = /* @__PURE__ */ new Set(["SourceRef", "ControlRef", "DOS", "SDS", "DAS", "InputVar", "OutputVar", "ProcessEcho"]), tt = {
21992
21992
  FunctionCatRef: ["SubCategory", "FunctionCategory"],
21993
21993
  PowerSystemRelation: ["PowerSystemRelations"],
21994
21994
  Resource: ["ProcessResource", "ProcessResources"],
21995
21995
  VariableApplyTo: ["Variable"]
21996
21996
  };
21997
- async function Ne(a, e) {
21998
- const { target: t, containerTagName: i } = e, n = await a.getRecord(t);
21997
+ async function at(e, a) {
21998
+ const { target: t, containerTagName: i } = a, n = await e.getRecord(t);
21999
21999
  if (!n) return [];
22000
- const u = n.attributes.find((c) => c.name === "uuid")?.value;
22001
- if (!u) return [];
22002
- const r = Ie(n.tagName);
22003
- if (r.length === 0) return [];
22004
- const s = [];
22005
- for (const c of r) {
22006
- if (!T(c.refTagName, P)) continue;
22007
- const l = await a.findByAttributes({
22000
+ const r = n.attributes.find((c) => c.name === "uuid")?.value;
22001
+ if (!r) return [];
22002
+ const s = it(n.tagName);
22003
+ if (s.length === 0) return [];
22004
+ const u = [];
22005
+ for (const c of s) {
22006
+ if (!M(c.refTagName, P)) continue;
22007
+ const o = await e.findByAttributes({
22008
22008
  tagName: c.refTagName,
22009
- attributes: { [c.uuidAttr]: u }
22009
+ attributes: { [c.uuidAttr]: r }
22010
22010
  });
22011
- for (const o of l) {
22012
- const p = i ? await we(a, o, i) : void 0;
22013
- s.push({ ref: o, container: p });
22011
+ for (const l of o) {
22012
+ const d = i ? await nt(e, l, i) : void 0;
22013
+ u.push({ ref: l, container: d });
22014
22014
  }
22015
22015
  }
22016
- return s;
22016
+ return u;
22017
22017
  }
22018
- function Ie(a) {
22019
- const e = [];
22020
- for (const t of U) {
22021
- const i = B[t].get(a);
22022
- i && e.push(...i);
22018
+ function it(e) {
22019
+ const a = [];
22020
+ for (const t of ce) {
22021
+ const i = ue[t].get(e);
22022
+ i && a.push(...i);
22023
22023
  }
22024
- return e;
22024
+ return a;
22025
22025
  }
22026
- async function we(a, e, t) {
22027
- return (await a.findAncestors(e, { stopAtTagName: t })).find((n) => n.tagName === t);
22026
+ async function nt(e, a, t) {
22027
+ return (await e.findAncestors(a, { stopAtTagName: t })).find((n) => n.tagName === t);
22028
22028
  }
22029
- const De = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
22029
+ const rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
22030
22030
  __proto__: null,
22031
- buildElementPath: E,
22032
- buildReferencePath: M,
22033
- findRefsPointingTo: Ne,
22034
- resolveElementPath: Ae,
22035
- resolveReferencePath: Se
22036
- }, Symbol.toStringTag, { value: "Module" })), z = {
22037
- query: De
22031
+ buildElementPath: te,
22032
+ buildReferencePath: re,
22033
+ findRefsPointingTo: at,
22034
+ resolveElementPath: je,
22035
+ resolveReferencePath: ze
22036
+ }, Symbol.toStringTag, { value: "Module" })), T = {
22037
+ query: rt
22038
22038
  };
22039
- async function h(a) {
22040
- const { uuid: e, entry: t, target: i, query: n } = a;
22041
- if (!T(t.refTagName, P)) return [];
22042
- const u = await n.getRecordsByTagName(t.refTagName), r = [];
22043
- for (const s of u) {
22044
- if (s.attributes.find(
22039
+ async function B(e) {
22040
+ const { uuid: a, entry: t, target: i, query: n } = e;
22041
+ if (!M(t.refTagName, P)) return [];
22042
+ const r = await n.getRecordsByTagName(t.refTagName), s = [];
22043
+ for (const u of r) {
22044
+ if (u.attributes.find(
22045
22045
  (S) => S.name === t.uuidAttr
22046
- )?.value !== e) continue;
22047
- const l = { tagName: s.tagName, id: s.id }, o = await z.query.buildReferencePath(n, { reference: l, target: i });
22048
- if (!o || s.attributes.find(
22046
+ )?.value !== a) continue;
22047
+ const o = { tagName: u.tagName, id: u.id }, l = await T.query.buildReferencePath(n, { reference: o, target: i });
22048
+ if (!l || u.attributes.find(
22049
22049
  (S) => S.name === t.pathAttr
22050
- )?.value === o) continue;
22051
- const R = s.attributes.map(
22052
- (S) => S.name === t.pathAttr ? { ...S, value: o } : S
22050
+ )?.value === l) continue;
22051
+ const f = u.attributes.map(
22052
+ (S) => S.name === t.pathAttr ? { ...S, value: l } : S
22053
22053
  );
22054
- r.push({
22054
+ s.push({
22055
22055
  status: "updated",
22056
- oldRecord: d(s),
22057
- newRecord: d({ ...s, attributes: R })
22056
+ oldRecord: p(u),
22057
+ newRecord: p({ ...u, attributes: f })
22058
22058
  });
22059
22059
  }
22060
- return r;
22060
+ return s;
22061
22061
  }
22062
- function N(a) {
22063
- const e = [];
22064
- for (const t of U) {
22065
- const i = B[t].get(a);
22066
- i && e.push(...i);
22062
+ function U(e) {
22063
+ const a = [];
22064
+ for (const t of ce) {
22065
+ const i = ue[t].get(e);
22066
+ i && a.push(...i);
22067
22067
  }
22068
- return e;
22068
+ return a;
22069
22069
  }
22070
- async function Fe(a) {
22071
- const { childRecord: e, query: t } = a, i = await qe({ childRecord: e, query: t }), n = await Oe({ childRecord: e, query: t });
22070
+ async function st(e) {
22071
+ const { childRecord: a, query: t } = e, i = await ut({ childRecord: a, query: t }), n = await lt({ childRecord: a, query: t });
22072
22072
  return [...i, ...n];
22073
22073
  }
22074
- async function qe(a) {
22075
- const { childRecord: e, query: t } = a, i = Te.get(e.tagName);
22074
+ async function ut(e) {
22075
+ const { childRecord: a, query: t } = e, i = et.get(a.tagName);
22076
22076
  if (!i?.length) return [];
22077
22077
  const n = [];
22078
- for (const u of i) {
22079
- const r = await ye({ childRecord: e, pair: u, query: t });
22080
- r && n.push(r);
22078
+ for (const r of i) {
22079
+ const s = await ct({ childRecord: a, pair: r, query: t });
22080
+ s && n.push(s);
22081
22081
  }
22082
22082
  return n;
22083
22083
  }
22084
- async function ye(a) {
22085
- const { childRecord: e, pair: t, query: i } = a, n = e.attributes.find((o) => o.name === t.uuidAttr)?.value;
22084
+ async function ct(e) {
22085
+ const { childRecord: a, pair: t, query: i } = e, n = a.attributes.find((l) => l.name === t.uuidAttr)?.value;
22086
22086
  if (!n) return null;
22087
- const u = await xe({
22087
+ const r = await ot({
22088
22088
  uuidValue: n,
22089
22089
  targetTagNames: t.targetTagNames,
22090
22090
  query: i
22091
22091
  });
22092
- if (!u) return null;
22093
- const r = { tagName: e.tagName, id: e.id }, s = { tagName: u.tagName, id: u.id }, c = await M(i, { reference: r, target: s });
22092
+ if (!r) return null;
22093
+ const s = { tagName: a.tagName, id: a.id }, u = { tagName: r.tagName, id: r.id }, c = await re(i, { reference: s, target: u });
22094
22094
  if (!c) return null;
22095
- const l = e.attributes.map(
22096
- (o) => o.name === t.pathAttr ? { ...o, value: c } : o
22095
+ const o = a.attributes.map(
22096
+ (l) => l.name === t.pathAttr ? { ...l, value: c } : l
22097
22097
  );
22098
22098
  return {
22099
22099
  status: "updated",
22100
- oldRecord: e,
22100
+ oldRecord: a,
22101
22101
  newRecord: {
22102
- ...e,
22103
- attributes: l
22102
+ ...a,
22103
+ attributes: o
22104
22104
  }
22105
22105
  };
22106
22106
  }
22107
- async function xe(a) {
22108
- const { uuidValue: e, targetTagNames: t, query: i } = a;
22107
+ async function ot(e) {
22108
+ const { uuidValue: a, targetTagNames: t, query: i } = e;
22109
22109
  for (const n of t) {
22110
- if (!T(n, P)) continue;
22111
- const r = (await i.getRecordsByTagName(n)).find(
22112
- (s) => s.attributes.find((c) => c.name === "uuid")?.value === e
22110
+ if (!M(n, P)) continue;
22111
+ const s = (await i.getRecordsByTagName(n)).find(
22112
+ (u) => u.attributes.find((c) => c.name === "uuid")?.value === a
22113
22113
  );
22114
- if (r) return { tagName: r.tagName, id: r.id };
22114
+ if (s) return { tagName: s.tagName, id: s.id };
22115
22115
  }
22116
22116
  return null;
22117
22117
  }
22118
- async function Oe(a) {
22119
- const { childRecord: e, query: t } = a, i = e.attributes.find((s) => s.name === "uuid")?.value;
22118
+ async function lt(e) {
22119
+ const { childRecord: a, query: t } = e, i = a.attributes.find((u) => u.name === "uuid")?.value;
22120
22120
  if (!i) return [];
22121
- const n = N(e.tagName);
22121
+ const n = U(a.tagName);
22122
22122
  if (n.length === 0) return [];
22123
- const u = { tagName: e.tagName, id: e.id }, r = [];
22124
- for (const s of n) {
22125
- const c = await h({ uuid: i, entry: s, target: u, query: t });
22126
- r.push(...c);
22123
+ const r = { tagName: a.tagName, id: a.id }, s = [];
22124
+ for (const u of n) {
22125
+ const c = await B({ uuid: i, entry: u, target: r, query: t });
22126
+ s.push(...c);
22127
22127
  }
22128
- return r;
22128
+ return s;
22129
22129
  }
22130
- async function Ee(a) {
22131
- const { childRecord: e, parentRecord: t, query: i } = a, n = await $({ childRecord: e, parentRecord: t, query: i }), u = await Fe({ childRecord: e, query: i });
22132
- return [...n, ...u];
22130
+ async function dt(e) {
22131
+ const { childRecord: a, parentRecord: t, query: i } = e, n = await we({ childRecord: a, parentRecord: t, query: i }), r = await st({ childRecord: a, query: i });
22132
+ return [...n, ...r];
22133
22133
  }
22134
- async function ke(a) {
22135
- const { cumulativeCloneMappings: e, query: t } = a, { uuidMap: i, uuidToRef: n } = await Ve(e, t);
22134
+ async function pt(e) {
22135
+ const { cumulativeCloneMappings: a, query: t } = e, { uuidMap: i, uuidToRef: n } = await St(a, t);
22136
22136
  if (i.size === 0) return [];
22137
- const u = [];
22138
- for (const { target: r } of e) {
22139
- const s = await Me({ target: r, uuidMap: i, uuidToRef: n, query: t });
22140
- s && u.push(s);
22137
+ const r = [];
22138
+ for (const { target: s } of a) {
22139
+ const u = await mt({ target: s, uuidMap: i, uuidToRef: n, query: t });
22140
+ u && r.push(u);
22141
22141
  }
22142
- return u;
22142
+ return r;
22143
22143
  }
22144
- async function Ve(a, e) {
22144
+ async function St(e, a) {
22145
22145
  const t = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
22146
- for (const { source: n, target: u } of a)
22147
- await Ze({ source: n, target: u, query: e, uuidMap: t, uuidToRef: i });
22146
+ for (const { source: n, target: r } of e)
22147
+ await ft({ source: n, target: r, query: a, uuidMap: t, uuidToRef: i });
22148
22148
  return { uuidMap: t, uuidToRef: i };
22149
22149
  }
22150
- async function Ze(a) {
22151
- const { source: e, target: t, query: i, uuidMap: n, uuidToRef: u } = a, r = await i.getRecord(t);
22152
- if (!r) return;
22153
- const s = e.attributes.find((l) => l.name === "uuid")?.value, c = r.attributes.find((l) => l.name === "uuid")?.value;
22154
- !s || !c || (n.set(s, c), u.set(c, { tagName: r.tagName, id: r.id }));
22150
+ async function ft(e) {
22151
+ const { source: a, target: t, query: i, uuidMap: n, uuidToRef: r } = e, s = await i.getRecord(t);
22152
+ if (!s) return;
22153
+ const u = a.attributes.find((o) => o.name === "uuid")?.value, c = s.attributes.find((o) => o.name === "uuid")?.value;
22154
+ !u || !c || (n.set(u, c), r.set(c, { tagName: s.tagName, id: s.id }));
22155
22155
  }
22156
- async function Me(a) {
22157
- const { target: e, uuidMap: t, uuidToRef: i, query: n } = a, u = e.tagName;
22158
- if (!(u in m)) return null;
22159
- const r = await n.getRecord(e);
22160
- if (!r) return null;
22161
- const s = m[u];
22162
- let c = [...r.attributes], l = !1;
22163
- for (const o of s) {
22164
- const p = await Ge({
22165
- pair: o,
22166
- tagName: u,
22167
- refId: r.id,
22156
+ async function mt(e) {
22157
+ const { target: a, uuidMap: t, uuidToRef: i, query: n } = e, r = a.tagName;
22158
+ if (!(r in m)) return null;
22159
+ const s = await n.getRecord(a);
22160
+ if (!s) return null;
22161
+ const u = m[r];
22162
+ let c = [...s.attributes], o = !1;
22163
+ for (const l of u) {
22164
+ const d = await bt({
22165
+ pair: l,
22166
+ tagName: r,
22167
+ refId: s.id,
22168
22168
  updatedAttributes: c,
22169
22169
  uuidMap: t,
22170
22170
  uuidToRef: i,
22171
22171
  query: n
22172
22172
  });
22173
- p && (c = p, l = !0);
22173
+ d && (c = d, o = !0);
22174
22174
  }
22175
- return l ? {
22175
+ return o ? {
22176
22176
  status: "updated",
22177
- oldRecord: d(r),
22178
- newRecord: d({ ...r, attributes: c })
22177
+ oldRecord: p(s),
22178
+ newRecord: p({ ...s, attributes: c })
22179
22179
  } : null;
22180
22180
  }
22181
- async function Ge(a) {
22182
- const { pair: e, tagName: t, refId: i, uuidMap: n, uuidToRef: u, query: r } = a;
22183
- let s = [...a.updatedAttributes];
22184
- const c = s.find((S) => S.name === e.attribute.uuid)?.value;
22181
+ async function bt(e) {
22182
+ const { pair: a, tagName: t, refId: i, uuidMap: n, uuidToRef: r, query: s } = e;
22183
+ let u = [...e.updatedAttributes];
22184
+ const c = u.find((S) => S.name === a.attribute.uuid)?.value;
22185
22185
  if (!c) return null;
22186
- const l = n.get(c);
22187
- if (!l) return null;
22188
- let o = !1;
22189
- const p = Be(s, e.attribute.uuid, c, l);
22190
- p && (s = p, o = !0);
22191
- const R = await Ue({
22192
- attributes: s,
22193
- pathAttrName: e.attribute.path,
22194
- newUuid: l,
22195
- uuidToRef: u,
22186
+ const o = n.get(c);
22187
+ if (!o) return null;
22188
+ let l = !1;
22189
+ const d = Rt(u, a.attribute.uuid, c, o);
22190
+ d && (u = d, l = !0);
22191
+ const f = await Lt({
22192
+ attributes: u,
22193
+ pathAttrName: a.attribute.path,
22194
+ newUuid: o,
22195
+ uuidToRef: r,
22196
22196
  tagName: t,
22197
22197
  refId: i,
22198
- query: r
22198
+ query: s
22199
22199
  });
22200
- return R && (s = R, o = !0), o ? s : null;
22200
+ return f && (u = f, l = !0), l ? u : null;
22201
22201
  }
22202
- function Be(a, e, t, i) {
22203
- return i === t ? null : a.map((n) => n.name === e ? { ...n, value: i } : n);
22202
+ function Rt(e, a, t, i) {
22203
+ return i === t ? null : e.map((n) => n.name === a ? { ...n, value: i } : n);
22204
22204
  }
22205
- async function Ue(a) {
22206
- const { attributes: e, pathAttrName: t, newUuid: i, uuidToRef: n, tagName: u, refId: r, query: s } = a, c = n.get(i);
22205
+ async function Lt(e) {
22206
+ const { attributes: a, pathAttrName: t, newUuid: i, uuidToRef: n, tagName: r, refId: s, query: u } = e, c = n.get(i);
22207
22207
  if (!c) return null;
22208
- const l = await z.query.buildReferencePath(s, {
22209
- reference: { tagName: u, id: r },
22208
+ const o = await T.query.buildReferencePath(u, {
22209
+ reference: { tagName: r, id: s },
22210
22210
  target: { tagName: c.tagName, id: c.id }
22211
22211
  });
22212
- return !l || e.find((p) => p.name === t)?.value === l ? null : e.map((p) => p.name === t ? { ...p, value: l } : p);
22212
+ return !o || a.find((d) => d.name === t)?.value === o ? null : a.map((d) => d.name === t ? { ...d, value: o } : d);
22213
22213
  }
22214
- async function ze(a) {
22215
- return ke(a);
22214
+ async function At(e) {
22215
+ return pt(e);
22216
22216
  }
22217
- function _e(a) {
22218
- const { record: e } = a, { tagName: t, attributes: i } = e, n = P.definition[t];
22219
- if (!("uuid" in n.attributes.details) || i.find((o) => o.name === "uuid")?.value) return e;
22220
- const c = n.attributes.details.uuid?.namespace, l = i.filter((o) => o.name !== "uuid");
22217
+ function Pt(e) {
22218
+ const { record: a } = e, { tagName: t, attributes: i } = a, n = P.definition[t];
22219
+ if (!("uuid" in n.attributes.details) || i.find((l) => l.name === "uuid")?.value) return a;
22220
+ const c = n.attributes.details.uuid?.namespace, o = i.filter((l) => l.name !== "uuid");
22221
22221
  return {
22222
- ...e,
22222
+ ...a,
22223
22223
  attributes: [
22224
- ...l,
22224
+ ...o,
22225
22225
  {
22226
22226
  name: "uuid",
22227
22227
  value: crypto.randomUUID(),
@@ -22230,240 +22230,240 @@ function _e(a) {
22230
22230
  ]
22231
22231
  };
22232
22232
  }
22233
- function He(a) {
22234
- return _e(a);
22233
+ function Ct(e) {
22234
+ return Pt(e);
22235
22235
  }
22236
- async function We(a) {
22237
- const { oldRecord: e, newRecord: t, query: i } = a, n = [], u = t.attributes.find((r) => r.name === "uuid")?.value;
22238
- if (u) {
22239
- const r = N(t.tagName), s = { tagName: t.tagName, id: t.id };
22240
- for (const c of r) {
22241
- const l = await h({ uuid: u, entry: c, target: s, query: i });
22242
- n.push(...l);
22236
+ async function gt(e) {
22237
+ const { oldRecord: a, newRecord: t, query: i } = e, n = [], r = t.attributes.find((s) => s.name === "uuid")?.value;
22238
+ if (r) {
22239
+ const s = U(t.tagName), u = { tagName: t.tagName, id: t.id };
22240
+ for (const c of s) {
22241
+ const o = await B({ uuid: r, entry: c, target: u, query: i });
22242
+ n.push(...o);
22243
22243
  }
22244
22244
  }
22245
- if (Ke(e, t)) {
22246
- const r = await Xe({ newRecord: t, query: i });
22247
- n.push(...r);
22245
+ if (vt(a, t)) {
22246
+ const s = await Tt({ newRecord: t, query: i });
22247
+ n.push(...s);
22248
22248
  }
22249
22249
  return n;
22250
22250
  }
22251
- function Ke(a, e) {
22252
- for (const t of ie) {
22253
- const i = a.attributes.find((u) => u.name === t)?.value, n = e.attributes.find((u) => u.name === t)?.value;
22251
+ function vt(e, a) {
22252
+ for (const t of xe) {
22253
+ const i = e.attributes.find((r) => r.name === t)?.value, n = a.attributes.find((r) => r.name === t)?.value;
22254
22254
  if (i !== n) return !0;
22255
22255
  }
22256
22256
  return !1;
22257
22257
  }
22258
- async function Xe(a) {
22259
- const { newRecord: e, query: t } = a, i = { tagName: e.tagName, id: e.id }, n = await t.findDescendants(i), u = [];
22260
- for (const r of Object.values(n))
22261
- for (const s of r) {
22262
- if (s.id === e.id) continue;
22263
- const c = await t.any.getAttribute(s, { name: "uuid" });
22258
+ async function Tt(e) {
22259
+ const { newRecord: a, query: t } = e, i = { tagName: a.tagName, id: a.id }, n = await t.findDescendants(i), r = [];
22260
+ for (const s of Object.values(n))
22261
+ for (const u of s) {
22262
+ if (u.id === a.id) continue;
22263
+ const c = await t.any.getAttribute(u, { name: "uuid" });
22264
22264
  if (!c) continue;
22265
- const l = N(s.tagName);
22266
- if (l.length === 0) continue;
22267
- const o = { tagName: s.tagName, id: s.id };
22268
- for (const p of l) {
22269
- const R = await h({ uuid: c, entry: p, target: o, query: t });
22270
- u.push(...R);
22265
+ const o = U(u.tagName);
22266
+ if (o.length === 0) continue;
22267
+ const l = { tagName: u.tagName, id: u.id };
22268
+ for (const d of o) {
22269
+ const f = await B({ uuid: c, entry: d, target: l, query: t });
22270
+ r.push(...f);
22271
22271
  }
22272
22272
  }
22273
- return u;
22273
+ return r;
22274
22274
  }
22275
- async function Qe(a) {
22276
- return We(a);
22275
+ async function ht(e) {
22276
+ return gt(e);
22277
22277
  }
22278
- function Ye(a) {
22279
- const { record: e } = a;
22278
+ function Nt(e) {
22279
+ const { record: a } = e;
22280
22280
  let t = !0;
22281
- e.tagName === "Private" && !e.tree.length && (t = !1);
22282
- const i = e.attributes.filter(
22281
+ a.tagName === "Private" && !a.tree.length && (t = !1);
22282
+ const i = a.attributes.filter(
22283
22283
  (n) => n.name !== "uuid"
22284
22284
  );
22285
22285
  return {
22286
22286
  shouldBeCloned: t,
22287
22287
  transformedRecord: {
22288
- ...e,
22288
+ ...a,
22289
22289
  attributes: i
22290
22290
  }
22291
22291
  };
22292
22292
  }
22293
- async function je(a) {
22294
- const { record: e, query: t } = a, i = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
22295
- if (await _({ record: e, query: t, ids: i, uuids: n }), n.size === 0) return [];
22296
- const u = [], r = Object.keys(m);
22297
- for (const s of r) {
22298
- const c = await $e({ refTagName: s, subtreeIds: i, subtreeUuids: n, query: t });
22299
- u.push(...c);
22293
+ async function It(e) {
22294
+ const { record: a, query: t } = e, i = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
22295
+ if (await le({ record: a, query: t, ids: i, uuids: n }), n.size === 0) return [];
22296
+ const r = [], s = Object.keys(m);
22297
+ for (const u of s) {
22298
+ const c = await wt({ refTagName: u, subtreeIds: i, subtreeUuids: n, query: t });
22299
+ r.push(...c);
22300
22300
  }
22301
- return u;
22301
+ return r;
22302
22302
  }
22303
- async function $e(a) {
22304
- const { refTagName: e, subtreeIds: t, subtreeUuids: i, query: n } = a, u = m[e], r = await n.getRecordsByTagName(e), s = [];
22305
- for (const c of r) {
22303
+ async function wt(e) {
22304
+ const { refTagName: a, subtreeIds: t, subtreeUuids: i, query: n } = e, r = m[a], s = await n.getRecordsByTagName(a), u = [];
22305
+ for (const c of s) {
22306
22306
  if (t.has(c.id)) continue;
22307
- const l = await Je({ refTagName: e, refRecord: c, refPairs: u, subtreeUuids: i, query: n });
22308
- s.push(...l);
22307
+ const o = await Dt({ refTagName: a, refRecord: c, refPairs: r, subtreeUuids: i, query: n });
22308
+ u.push(...o);
22309
22309
  }
22310
- return s;
22310
+ return u;
22311
22311
  }
22312
- async function Je(a) {
22313
- const { refTagName: e, refRecord: t, refPairs: i, subtreeUuids: n, query: u } = a, r = et({ refPairs: i, refRecord: t, subtreeUuids: n });
22314
- return r.size === 0 ? [] : he.has(e) ? [tt(t, r)] : at(t, u);
22312
+ async function Dt(e) {
22313
+ const { refTagName: a, refRecord: t, refPairs: i, subtreeUuids: n, query: r } = e, s = Ft({ refPairs: i, refRecord: t, subtreeUuids: n });
22314
+ return s.size === 0 ? [] : oe.has(a) ? [yt(t, s)] : qt(t, r);
22315
22315
  }
22316
- function et(a) {
22317
- const { refPairs: e, refRecord: t, subtreeUuids: i } = a, n = /* @__PURE__ */ new Set();
22318
- for (const u of e) {
22319
- const r = t.attributes.find(
22320
- (s) => s.name === u.attribute.uuid
22316
+ function Ft(e) {
22317
+ const { refPairs: a, refRecord: t, subtreeUuids: i } = e, n = /* @__PURE__ */ new Set();
22318
+ for (const r of a) {
22319
+ const s = t.attributes.find(
22320
+ (u) => u.name === r.attribute.uuid
22321
22321
  )?.value;
22322
- if (!(!r || !i.has(r))) {
22323
- n.add(u.attribute.uuid), n.add(u.attribute.path);
22324
- for (const s of u.companions)
22325
- n.add(s.name);
22322
+ if (!(!s || !i.has(s))) {
22323
+ n.add(r.attribute.uuid), n.add(r.attribute.path);
22324
+ for (const u of r.companions)
22325
+ n.add(u.name);
22326
22326
  }
22327
22327
  }
22328
22328
  return n;
22329
22329
  }
22330
- function tt(a, e) {
22331
- const t = a.attributes.filter(
22332
- (i) => !e.has(i.name)
22330
+ function yt(e, a) {
22331
+ const t = e.attributes.filter(
22332
+ (i) => !a.has(i.name)
22333
22333
  );
22334
22334
  return {
22335
22335
  status: "updated",
22336
- oldRecord: d(a),
22337
- newRecord: d({ ...a, attributes: t })
22336
+ oldRecord: p(e),
22337
+ newRecord: p({ ...e, attributes: t })
22338
22338
  };
22339
22339
  }
22340
- async function at(a, e) {
22340
+ async function qt(e, a) {
22341
22341
  const t = [
22342
- { status: "deleted", oldRecord: d(a), newRecord: void 0 }
22342
+ { status: "deleted", oldRecord: p(e), newRecord: void 0 }
22343
22343
  ];
22344
- if (a.parent) {
22345
- const i = await e.getRecord(a.parent);
22344
+ if (e.parent) {
22345
+ const i = await a.getRecord(e.parent);
22346
22346
  if (i) {
22347
22347
  const n = {
22348
22348
  ...i,
22349
- children: i.children.filter((u) => u.id !== a.id)
22349
+ children: i.children.filter((r) => r.id !== e.id)
22350
22350
  };
22351
22351
  t.push({
22352
22352
  status: "updated",
22353
- oldRecord: d(i),
22354
- newRecord: d(n)
22353
+ oldRecord: p(i),
22354
+ newRecord: p(n)
22355
22355
  });
22356
22356
  }
22357
22357
  }
22358
22358
  return t;
22359
22359
  }
22360
- async function _(a) {
22361
- const { record: e, query: t, ids: i, uuids: n } = a;
22362
- i.add(e.id);
22363
- const u = e.attributes.find((r) => r.name === "uuid")?.value;
22364
- u && n.add(u);
22365
- for (const r of e.children) {
22366
- const s = await t.getRecord(r);
22367
- s && await _({ record: s, query: t, ids: i, uuids: n });
22360
+ async function le(e) {
22361
+ const { record: a, query: t, ids: i, uuids: n } = e;
22362
+ i.add(a.id);
22363
+ const r = a.attributes.find((s) => s.name === "uuid")?.value;
22364
+ r && n.add(r);
22365
+ for (const s of a.children) {
22366
+ const u = await t.getRecord(s);
22367
+ u && await le({ record: u, query: t, ids: i, uuids: n });
22368
22368
  }
22369
22369
  }
22370
- async function it(a) {
22371
- return je(a);
22370
+ async function xt(e) {
22371
+ return It(e);
22372
22372
  }
22373
- function nt() {
22374
- const a = /* @__PURE__ */ new Map(), e = [], t = [];
22373
+ function Ot() {
22374
+ const e = /* @__PURE__ */ new Map(), a = [], t = [];
22375
22375
  return {
22376
- beforeImportRecord: (u) => {
22377
- const { record: r, ancestry: s } = u, { tagName: c } = r, l = ct(r);
22378
- if (l && st.has(c)) {
22379
- const S = x({ record: r, ancestry: s });
22380
- S && a.set(S.path, l);
22381
- }
22382
- if (!ut.has(c)) return;
22383
- const R = m[c];
22384
- for (const S of R) {
22385
- const C = r.attributes.find(
22386
- (g) => g.name === S.attribute.path
22376
+ beforeImportRecord: (r) => {
22377
+ const { record: s, ancestry: u } = r, { tagName: c } = s, o = Zt(s);
22378
+ if (o && Vt.has(c)) {
22379
+ const S = J({ record: s, ancestry: u });
22380
+ S && e.set(S.path, o);
22381
+ }
22382
+ if (!kt.has(c)) return;
22383
+ const f = m[c];
22384
+ for (const S of f) {
22385
+ const L = s.attributes.find(
22386
+ (C) => C.name === S.attribute.path
22387
22387
  )?.value;
22388
- if (!C || r.attributes.find(
22389
- (g) => g.name === S.attribute.uuid
22388
+ if (!L || s.attributes.find(
22389
+ (C) => C.name === S.attribute.uuid
22390
22390
  )?.value) continue;
22391
- const A = Z(S.resolution, S.attribute.path, C, s);
22392
- if (!A) {
22393
- S.resolution === f.unsupported && t.push({
22391
+ const N = ne(S.resolution, S.attribute.path, L, u);
22392
+ if (!N) {
22393
+ S.resolution === b.unsupported && t.push({
22394
22394
  type: "unsupported-xpath-reference",
22395
- recordId: r.id,
22395
+ recordId: s.id,
22396
22396
  details: {
22397
22397
  elementTag: c,
22398
22398
  pathAttribute: S.attribute.path,
22399
22399
  uuidAttribute: S.attribute.uuid,
22400
- pathValue: C
22400
+ pathValue: L
22401
22401
  }
22402
22402
  });
22403
22403
  continue;
22404
22404
  }
22405
- e.push({
22406
- recordId: r.id,
22405
+ a.push({
22406
+ recordId: s.id,
22407
22407
  elementTag: c,
22408
22408
  uuidAttributeName: S.attribute.uuid,
22409
- pathValue: C,
22410
- lookupKey: A.lookupKey,
22411
- fallbackLookupKey: A.fallbackLookupKey
22409
+ pathValue: L,
22410
+ lookupKey: N.lookupKey,
22411
+ fallbackLookupKey: N.fallbackLookupKey
22412
22412
  });
22413
22413
  }
22414
22414
  },
22415
22415
  afterImport: async () => {
22416
- const u = [], r = [...t];
22417
- for (const s of e) {
22418
- const c = a.get(s.lookupKey) ?? (s.fallbackLookupKey ? a.get(s.fallbackLookupKey) : void 0);
22416
+ const r = [], s = [...t];
22417
+ for (const u of a) {
22418
+ const c = e.get(u.lookupKey) ?? (u.fallbackLookupKey ? e.get(u.fallbackLookupKey) : void 0);
22419
22419
  if (!c) {
22420
- r.push({
22420
+ s.push({
22421
22421
  type: "unresolved-reference",
22422
- recordId: s.recordId,
22422
+ recordId: u.recordId,
22423
22423
  details: {
22424
- elementTag: s.elementTag,
22425
- uuidAttribute: s.uuidAttributeName,
22426
- pathValue: s.pathValue,
22427
- triedKeys: s.fallbackLookupKey ? [s.lookupKey, s.fallbackLookupKey] : [s.lookupKey]
22424
+ elementTag: u.elementTag,
22425
+ uuidAttribute: u.uuidAttributeName,
22426
+ pathValue: u.pathValue,
22427
+ triedKeys: u.fallbackLookupKey ? [u.lookupKey, u.fallbackLookupKey] : [u.lookupKey]
22428
22428
  }
22429
22429
  });
22430
22430
  continue;
22431
22431
  }
22432
- u.push({
22433
- recordId: s.recordId,
22434
- attributes: [{ name: s.uuidAttributeName, value: c }]
22432
+ r.push({
22433
+ recordId: u.recordId,
22434
+ attributes: [{ name: u.uuidAttributeName, value: c }]
22435
22435
  });
22436
22436
  }
22437
- return a.clear(), e.length = 0, t.length = 0, {
22438
- updates: u,
22439
- warnings: r.length > 0 ? r : void 0
22437
+ return e.clear(), a.length = 0, t.length = 0, {
22438
+ updates: r,
22439
+ warnings: s.length > 0 ? s : void 0
22440
22440
  };
22441
22441
  }
22442
22442
  };
22443
22443
  }
22444
- const rt = new Set(
22445
- Object.entries(w).filter(([, a]) => "uuid" in a).map(([a]) => a)
22446
- ), ut = new Set(Object.keys(m)), st = new Set(
22447
- Object.values(m).flatMap((a) => a.flatMap((e) => e.target))
22444
+ const Et = new Set(
22445
+ Object.entries(Q).filter(([, e]) => "uuid" in e).map(([e]) => e)
22446
+ ), kt = new Set(Object.keys(m)), Vt = new Set(
22447
+ Object.values(m).flatMap((e) => e.flatMap((a) => a.target))
22448
22448
  );
22449
- function ct(a) {
22450
- if (!rt.has(a.tagName)) return;
22451
- const e = a.attributes.find((i) => i.name === "uuid");
22452
- if (e) return e.value;
22449
+ function Zt(e) {
22450
+ if (!Et.has(e.tagName)) return;
22451
+ const a = e.attributes.find((i) => i.name === "uuid");
22452
+ if (a) return a.value;
22453
22453
  const t = crypto.randomUUID();
22454
- return a.attributes.push({ name: "uuid", value: t }), t;
22454
+ return e.attributes.push({ name: "uuid", value: t }), t;
22455
22455
  }
22456
- const Rt = {
22457
- beforeClone: Ye,
22458
- afterStandardizedRecord: He,
22459
- afterCreated: Ee,
22460
- afterDeepClone: ze,
22461
- afterUpdated: Qe,
22462
- beforeDelete: it
22463
- }, ot = nt(), lt = {
22456
+ const ga = {
22457
+ beforeClone: Nt,
22458
+ afterStandardizedRecord: Ct,
22459
+ afterCreated: dt,
22460
+ afterDeepClone: At,
22461
+ afterUpdated: ht,
22462
+ beforeDelete: xt
22463
+ }, Mt = Ot(), Gt = {
22464
22464
  supportedFileExtensions: [".fsd", ".asd", ".ssd", ".scd", ".isd", ".xml"],
22465
- hooks: ot
22466
- }, dt = {
22465
+ hooks: Mt
22466
+ }, Bt = {
22467
22467
  recordSchema: {
22468
22468
  primaryKey: "id",
22469
22469
  indexes: ["tagName", "parent.id", "parent.tagName"],
@@ -22482,37 +22482,604 @@ const Rt = {
22482
22482
  }
22483
22483
  }
22484
22484
  }
22485
- }, pt = {
22485
+ }, Ut = {
22486
22486
  default: { uri: "http://www.iec.ch/61850/2003/SCL", prefix: "" },
22487
22487
  v2019C1: {
22488
22488
  uri: "http://www.iec.ch/61850/2019/SCL/6-100",
22489
22489
  prefix: "eIEC61850-6-100"
22490
22490
  }
22491
22491
  }, P = {
22492
- rootElementName: Y,
22493
- singletonElements: j,
22492
+ rootElementName: Ne,
22493
+ singletonElements: Ie,
22494
22494
  transparentElements: ["Private"],
22495
- elements: H,
22496
- namespaces: pt,
22497
- attributes: w,
22498
- children: W,
22499
- parents: K,
22495
+ elements: ge,
22496
+ namespaces: Ut,
22497
+ attributes: Q,
22498
+ children: ve,
22499
+ parents: Te,
22500
22500
  descendants: X,
22501
- ancestors: Q,
22502
- database: dt,
22503
- io: lt,
22504
- definition: D
22501
+ ancestors: he,
22502
+ database: Bt,
22503
+ io: Gt,
22504
+ definition: G
22505
+ };
22506
+ async function zt(e) {
22507
+ const a = await e.getRecordsByTagName("LNode");
22508
+ for (const t of a) {
22509
+ const i = await e.getAttribute(t, { name: "iedName" });
22510
+ if (!i || i === "None") continue;
22511
+ const [n] = await e.findByAttributes({
22512
+ tagName: "IED",
22513
+ attributes: { name: i }
22514
+ });
22515
+ n || await _t(e, t);
22516
+ }
22517
+ }
22518
+ async function _t(e, a) {
22519
+ const t = await e.getChild(a, "LNodeSpecNaming");
22520
+ if (t) {
22521
+ const i = await e.getAttribute(t, { name: "sLnClass" }), n = await e.getAttribute(t, { name: "sLnInst" }), r = await e.getAttribute(t, { name: "sPrefix" });
22522
+ await e.update(t, {
22523
+ attributes: { sIedName: "None", sLdInst: void 0 }
22524
+ }), await e.update(a, {
22525
+ attributes: {
22526
+ iedName: "None",
22527
+ ldInst: void 0,
22528
+ lnUuid: void 0,
22529
+ templateUuid: void 0,
22530
+ lnClass: i || void 0,
22531
+ lnInst: n || void 0,
22532
+ prefix: r || void 0
22533
+ }
22534
+ });
22535
+ } else
22536
+ await e.update(a, {
22537
+ attributes: {
22538
+ iedName: "None",
22539
+ ldInst: void 0,
22540
+ lnUuid: void 0,
22541
+ templateUuid: void 0,
22542
+ lnClass: void 0,
22543
+ lnInst: void 0,
22544
+ prefix: void 0
22545
+ }
22546
+ });
22547
+ }
22548
+ async function Ht(e) {
22549
+ const a = [...Object.values(tt).flat(), "Private"];
22550
+ for (const t of a) {
22551
+ const i = await e.getRecordsByTagName(t);
22552
+ for (const n of i)
22553
+ n.children.length === 0 && await e.delete(n);
22554
+ }
22555
+ }
22556
+ async function Wt(e) {
22557
+ const a = Object.keys(m);
22558
+ for (const t of a) {
22559
+ const i = m[t], n = await e.getRecordsByTagName(t);
22560
+ for (const r of n) {
22561
+ let s = !1, u = !1;
22562
+ const c = {};
22563
+ for (const d of i) {
22564
+ const f = await e.getAttribute(r, {
22565
+ name: d.attribute.uuid
22566
+ });
22567
+ if (!f) continue;
22568
+ if (s = !0, await Kt(e, f, d.target))
22569
+ u = !0;
22570
+ else {
22571
+ c[d.attribute.uuid] = void 0, c[d.attribute.path] = void 0;
22572
+ for (const L of d.companions)
22573
+ c[L.name] = void 0;
22574
+ }
22575
+ }
22576
+ Object.keys(c).length > 0 && await e.update(r, { attributes: c });
22577
+ const o = oe.has(t);
22578
+ s && !u && !o && await e.delete(r);
22579
+ }
22580
+ }
22581
+ }
22582
+ async function Kt(e, a, t) {
22583
+ for (const i of t) {
22584
+ const [n] = await e.findByAttributes({
22585
+ tagName: i,
22586
+ attributes: { uuid: a }
22587
+ });
22588
+ if (n) return !0;
22589
+ }
22590
+ return !1;
22591
+ }
22592
+ const Xt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
22593
+ __proto__: null,
22594
+ orphanUuidRefs: Wt,
22595
+ pruneEmptyContainers: Ht,
22596
+ resetLNode: zt
22597
+ }, Symbol.toStringTag, { value: "Module" })), w = {
22598
+ transaction: Xt
22599
+ };
22600
+ async function de(e, a) {
22601
+ const { records: t } = a, i = {
22602
+ lnodeTypes: /* @__PURE__ */ new Map(),
22603
+ doTypes: /* @__PURE__ */ new Map(),
22604
+ daTypes: /* @__PURE__ */ new Map(),
22605
+ enumTypes: /* @__PURE__ */ new Map()
22606
+ };
22607
+ for (const n of t) {
22608
+ const r = await e.getAttribute(n, { name: "lnType" });
22609
+ if (!r) continue;
22610
+ const [s] = await e.findByAttributes({
22611
+ tagName: "LNodeType",
22612
+ attributes: { id: r }
22613
+ });
22614
+ if (F(s, {
22615
+ key: "ELEMENT_NOT_FOUND",
22616
+ detail: `LNodeType not found for lnType="${r}"`
22617
+ }), !v(i.lnodeTypes, r, s)) continue;
22618
+ const u = s.children.filter((o) => I(o, "DO")), c = await e.getRecords(u);
22619
+ for (const o of c) {
22620
+ if (!o) continue;
22621
+ const l = await e.getAttribute(o, { name: "type" });
22622
+ if (!l) continue;
22623
+ const [d] = await e.findByAttributes({
22624
+ tagName: "DOType",
22625
+ attributes: { id: l }
22626
+ });
22627
+ d && v(i.doTypes, l, d) && await V({ query: e, parent: d, dataModelMap: i });
22628
+ }
22629
+ }
22630
+ return {
22631
+ lnodeTypes: Array.from(i.lnodeTypes.values()),
22632
+ doTypes: Array.from(i.doTypes.values()),
22633
+ daTypes: Array.from(i.daTypes.values()),
22634
+ enumTypes: Array.from(i.enumTypes.values())
22635
+ };
22636
+ }
22637
+ function v(e, a, t) {
22638
+ return e.has(a) ? !1 : (e.set(a, t), !0);
22639
+ }
22640
+ async function V(e) {
22641
+ const { query: a, parent: t, dataModelMap: i } = e, n = t.tagName === "DOType" ? await a.getRecords(t.children.filter((r) => I(r, "DA"))) : await a.getRecords(t.children.filter((r) => I(r, "BDA")));
22642
+ for (const r of n) {
22643
+ if (!r) continue;
22644
+ const s = await a.getAttribute(r, { name: "bType" }), u = await a.getAttribute(r, { name: "type" });
22645
+ if (u) {
22646
+ if (s === "Enum") {
22647
+ const [c] = await a.findByAttributes({
22648
+ tagName: "EnumType",
22649
+ attributes: { id: u }
22650
+ });
22651
+ c && v(i.enumTypes, u, c);
22652
+ } else if (s === "Struct") {
22653
+ const [c] = await a.findByAttributes({
22654
+ tagName: "DAType",
22655
+ attributes: { id: u }
22656
+ });
22657
+ c && v(i.daTypes, u, c) && await V({ query: a, parent: c, dataModelMap: i });
22658
+ }
22659
+ }
22660
+ }
22661
+ if (t.tagName === "DOType") {
22662
+ const r = t.children.filter((u) => I(u, "SDO")), s = await a.getRecords(r);
22663
+ for (const u of s) {
22664
+ const c = await a.getAttribute(u, { name: "type" });
22665
+ if (!c) continue;
22666
+ const [o] = await a.findByAttributes({
22667
+ tagName: "DOType",
22668
+ attributes: { id: c }
22669
+ });
22670
+ o && v(i.doTypes, c, o) && await V({ query: a, parent: o, dataModelMap: i });
22671
+ }
22672
+ }
22673
+ }
22674
+ const Qt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
22675
+ __proto__: null,
22676
+ resolve: de
22677
+ }, Symbol.toStringTag, { value: "Module" }));
22678
+ async function Yt(e, a) {
22679
+ const { sourceQuery: t, records: i } = a, n = await de(t, { records: i }), r = jt(n), s = await e.getRoot(), u = await e.ensureChild(s, {
22680
+ tagName: "DataTypeTemplates",
22681
+ attributes: {}
22682
+ });
22683
+ for (const c of r) {
22684
+ const o = await t.getAttribute(c, { name: "id" });
22685
+ if (!o) continue;
22686
+ const [l] = await e.findByAttributes({
22687
+ tagName: c.tagName,
22688
+ attributes: { id: o }
22689
+ });
22690
+ if (l) continue;
22691
+ const d = await t.getTree(c);
22692
+ d && await e.deepClone(u, d);
22693
+ }
22694
+ }
22695
+ function jt(e) {
22696
+ return [...e.lnodeTypes, ...e.doTypes, ...e.daTypes, ...e.enumTypes];
22697
+ }
22698
+ const $t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
22699
+ __proto__: null,
22700
+ extract: Yt
22701
+ }, Symbol.toStringTag, { value: "Module" })), pe = {
22702
+ query: Qt,
22703
+ transaction: $t
22704
+ };
22705
+ async function Se(e) {
22706
+ const a = await e.getRecord({ tagName: "History" });
22707
+ if (!a) return [];
22708
+ const { Hitem: t = [] } = await e.findDescendants(a, { collect: "Hitem" });
22709
+ function i(r, s) {
22710
+ return Number(r.attributes.find((u) => u.name === s)?.value || 0);
22711
+ }
22712
+ return [...t].sort((r, s) => {
22713
+ const u = i(r, "version") - i(s, "version");
22714
+ return u !== 0 ? u : i(r, "revision") - i(s, "revision");
22715
+ });
22716
+ }
22717
+ async function fe(e) {
22718
+ return (await Se(e)).at(-1);
22719
+ }
22720
+ const Jt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
22721
+ __proto__: null,
22722
+ getLatestHitem: fe,
22723
+ getSortedHitems: Se
22724
+ }, Symbol.toStringTag, { value: "Module" }));
22725
+ async function ea(e, a) {
22726
+ const { filename: t, header: i, item: n } = a, { id: r, fileType: s, nameStructure: u, version: c, tool: o } = i, { who: l, what: d, why: f } = n, S = await e.getRoot(), h = await e.getRecord({ tagName: "Header" }) ?? await e.addChild(S, {
22727
+ tagName: "Header",
22728
+ attributes: {
22729
+ id: r ?? t.replace(/\.[^.]+$/, "").toLowerCase().replace(/\s+/g, "_"),
22730
+ toolID: o,
22731
+ fileType: s,
22732
+ ...u ? { nameStructure: u } : {},
22733
+ version: "0",
22734
+ revision: "1",
22735
+ uuid: crypto.randomUUID()
22736
+ }
22737
+ }), C = await e.getRecord({ tagName: "History" }) ?? await e.addChild(h, { tagName: "History", attributes: {} }), H = await fe(e), q = H?.attributes.find((E) => E.name === "version")?.value, W = H?.attributes.find((E) => E.name === "revision")?.value, x = c === "keep" ? q ?? "0" : q ? String(Number(q) + 1) : "0", O = W ? String(Number(W) + 1) : "1";
22738
+ await e.update(h, {
22739
+ attributes: { version: x, revision: O }
22740
+ });
22741
+ const K = /* @__PURE__ */ new Date(), g = K.toString().split(" "), Ae = K.toLocaleString("en", { timeZoneName: "short" }).split(" ").pop(), Pe = `${g[0]} ${g[1]} ${g[2]} ${g[4]} ${Ae} ${g[3]}`;
22742
+ await e.addChild(C, {
22743
+ tagName: "Hitem",
22744
+ attributes: {
22745
+ version: x,
22746
+ revision: O,
22747
+ when: Pe,
22748
+ who: l,
22749
+ what: d,
22750
+ why: f
22751
+ }
22752
+ }), await e.update(h, {
22753
+ attributes: { version: x, revision: O }
22754
+ });
22755
+ }
22756
+ const ta = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
22757
+ __proto__: null,
22758
+ addEntry: ea
22759
+ }, Symbol.toStringTag, { value: "Module" })), z = {
22760
+ query: Jt,
22761
+ transaction: ta
22762
+ }, aa = {
22763
+ LNode: ["prefix", "lnClass", "lnInst"],
22764
+ LN: ["prefix", "lnClass", "inst"],
22765
+ LN0: ["prefix", "lnClass", "inst"],
22766
+ LDevice: ["inst"],
22767
+ ConnectedAP: ["iedName", "apName"],
22768
+ GSE: ["ldInst", "cbName"],
22769
+ SMV: ["ldInst", "cbName"],
22770
+ Private: ["type"],
22771
+ EnumVal: ["ord"],
22772
+ Association: ["associationID"],
22773
+ ConnectivityNode: ["pathName"],
22774
+ ControlRef: ["output", "outputInst"],
22775
+ SourceRef: ["input", "inputInst"],
22776
+ FunctionRoleContent: ["roleInst"],
22777
+ Resource: ["resInst"],
22778
+ Hitem: ["version", "revision"],
22779
+ History: ["version", "revision"]
22780
+ }, ia = {
22781
+ ConnectedAP: " / ",
22782
+ GSE: "/",
22783
+ SMV: "/",
22784
+ Hitem: ".",
22785
+ History: ".",
22786
+ ControlRef: "/",
22787
+ SourceRef: "/"
22788
+ };
22789
+ async function na(e, a) {
22790
+ const t = await e.getRecord(a);
22791
+ if (!t) return "";
22792
+ const i = t.tagName, n = await e.any.getAttributes(t), r = aa[i];
22793
+ if (r) {
22794
+ const o = ia[i] ?? "", l = r.map((d) => n[d]).filter(Boolean);
22795
+ return l.length > 0 ? l.join(o) : i;
22796
+ }
22797
+ const u = G[i]?.attributes?.identityFields, c = u?.find((o) => o === "name" || o === "id") ?? u?.[0];
22798
+ return c ? n[c] || i : n.name || i;
22799
+ }
22800
+ const ra = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
22801
+ __proto__: null,
22802
+ extractElementTitle: na
22803
+ }, Symbol.toStringTag, { value: "Module" })), sa = {
22804
+ query: ra
22805
+ };
22806
+ async function _(e) {
22807
+ const a = await e.getRoot(), t = await e.ensureChild(a, {
22808
+ tagName: "Substation",
22809
+ attributes: { name: "TEMPLATE" }
22810
+ }), i = await e.ensureChild(t, {
22811
+ tagName: "VoltageLevel",
22812
+ attributes: { name: "TEMPLATE" }
22813
+ }), n = await e.ensureChild(i, {
22814
+ tagName: "Bay",
22815
+ attributes: { name: "TEMPLATE" }
22816
+ });
22817
+ return {
22818
+ Substation: t,
22819
+ VoltageLevel: i,
22820
+ Bay: n
22821
+ };
22822
+ }
22823
+ const ua = {
22824
+ scope: "tree",
22825
+ attributes: ["templateUuid", "originUuid"]
22826
+ };
22827
+ async function y(e, a) {
22828
+ const { sourceQuery: t, ref: i, targetParent: n, omit: r, promoteRoot: s, strip: u = ua } = a, c = await t.getTree(i, { omit: r });
22829
+ if (!c) return;
22830
+ const o = s && c.tagName === s.from ? { ...c, tagName: s.to } : c;
22831
+ let l = o;
22832
+ u && (l = u.scope === "tree" ? Ce(o, u.attributes) : {
22833
+ ...o,
22834
+ attributes: o.attributes.filter((d) => !u.attributes.includes(d.name))
22835
+ }), await e.deepClone(n, l);
22836
+ }
22837
+ async function ca(e, a) {
22838
+ const { sourceQuery: t, scopeRef: i } = a, { LNode: n = [] } = await t.findDescendants(i, {
22839
+ collect: "LNode"
22840
+ });
22841
+ n.length > 0 && await pe.transaction.extract(e, { sourceQuery: t, records: n });
22842
+ }
22843
+ async function Z(e, a, t) {
22844
+ const n = (await e.findAncestors(a, { stopAtTagName: "Substation" })).find((s) => s.tagName in t);
22845
+ F(n, {
22846
+ key: "ELEMENT_NOT_FOUND",
22847
+ detail: `No Substation/VoltageLevel/Bay ancestor found for ${a.tagName}`
22848
+ });
22849
+ const r = t[n.tagName];
22850
+ return { tagName: r.tagName, id: r.id };
22851
+ }
22852
+ async function me(e, a) {
22853
+ const { sourceQuery: t, functionRef: i, targetParentRef: n, omit: r, stripRootAttributes: s } = a, u = s?.length ? { scope: "root", attributes: [...s] } : !1;
22854
+ await y(e, {
22855
+ sourceQuery: t,
22856
+ ref: i,
22857
+ targetParent: n,
22858
+ omit: r,
22859
+ promoteRoot: { from: "SubFunction", to: "Function" },
22860
+ strip: u
22861
+ }), await ca(e, { sourceQuery: t, scopeRef: i });
22862
+ }
22863
+ async function be(e, a) {
22864
+ const { sourceQuery: t, functionRef: i, structure: n, stripCategoriesUuid: r = !0 } = a, s = await oa(t, i);
22865
+ for (const u of s) {
22866
+ if (await da(e, t, u)) continue;
22867
+ const o = { tagName: "FunctionCategory", id: u }, l = await Z(t, o, n);
22868
+ await y(e, {
22869
+ sourceQuery: t,
22870
+ ref: o,
22871
+ targetParent: l,
22872
+ ...r ? {} : { strip: !1 }
22873
+ });
22874
+ }
22875
+ }
22876
+ async function oa(e, a) {
22877
+ const t = await la(e, a), i = /* @__PURE__ */ new Set();
22878
+ for (const { container: n } of t)
22879
+ n && i.add(n.id);
22880
+ return i;
22881
+ }
22882
+ async function la(e, a) {
22883
+ const t = await T.query.findRefsPointingTo(e, {
22884
+ target: a,
22885
+ containerTagName: "FunctionCategory"
22886
+ }), { SubFunction: i = [] } = await e.findDescendants(a, {
22887
+ collect: "SubFunction"
22888
+ });
22889
+ for (const n of i) {
22890
+ const r = await T.query.findRefsPointingTo(e, {
22891
+ target: { tagName: "SubFunction", id: n.id },
22892
+ containerTagName: "FunctionCategory"
22893
+ });
22894
+ t.push(...r);
22895
+ }
22896
+ return t;
22897
+ }
22898
+ async function da(e, a, t) {
22899
+ const i = await a.getRecord({
22900
+ tagName: "FunctionCategory",
22901
+ id: t
22902
+ });
22903
+ if (!i) return !1;
22904
+ const n = await a.getAttribute(i, { name: "name" });
22905
+ if (!n) return !1;
22906
+ const [r] = await e.findByAttributes({
22907
+ tagName: "FunctionCategory",
22908
+ attributes: { name: n }
22909
+ });
22910
+ return !!r;
22911
+ }
22912
+ async function Re(e, a) {
22913
+ const { sourceQuery: t, scopeRef: i, refTagName: n, targetTagName: r } = a, s = m[n][0].attribute.uuid, u = await t.findDescendants(i, {
22914
+ collect: n
22915
+ }), { [n]: c = [] } = u, o = /* @__PURE__ */ new Set();
22916
+ for (const d of c) {
22917
+ const f = d.attributes.find(
22918
+ (S) => S.name === s
22919
+ )?.value;
22920
+ f && o.add(f);
22921
+ }
22922
+ const l = [];
22923
+ for (const d of o) {
22924
+ const f = { uuid: d }, [S] = await e.findByAttributes({ tagName: r, attributes: f });
22925
+ if (S) continue;
22926
+ const [L] = await t.findByAttributes({
22927
+ tagName: r,
22928
+ attributes: f
22929
+ });
22930
+ L && l.push({ tagName: r, id: L.id });
22931
+ }
22932
+ return l;
22933
+ }
22934
+ async function pa(e, a) {
22935
+ const { sourceQuery: t, scopeRef: i, refTagName: n, targetTagName: r, targetParent: s, omit: u } = a, c = await Re(e, {
22936
+ sourceQuery: t,
22937
+ scopeRef: i,
22938
+ refTagName: n,
22939
+ targetTagName: r
22940
+ });
22941
+ for (const o of c)
22942
+ await y(e, { sourceQuery: t, ref: o, targetParent: s, omit: u });
22943
+ }
22944
+ async function Sa(e, a) {
22945
+ const { sourceQuery: t, scopeTagName: i, scopeRef: n, targetParent: r, skip: s = /* @__PURE__ */ new Set(), omit: u } = a, c = X[i].filter(
22946
+ (l) => l in m && !s.has(l)
22947
+ ), o = pa;
22948
+ for (const l of c)
22949
+ for (const d of m[l])
22950
+ for (const f of d.target)
22951
+ await o(e, {
22952
+ sourceQuery: t,
22953
+ scopeRef: n,
22954
+ refTagName: l,
22955
+ targetTagName: f,
22956
+ targetParent: r,
22957
+ omit: u
22958
+ });
22959
+ }
22960
+ const D = [
22961
+ "FunctionSclRef",
22962
+ "ApplicationSclRef",
22963
+ "GeneralEquipment",
22964
+ "ConductingEquipment"
22965
+ ], fa = [
22966
+ ...D,
22967
+ "DOS",
22968
+ "Labels",
22969
+ "LNodeInputs",
22970
+ "LNodeOutputs",
22971
+ "ProcessResources",
22972
+ "PowerSystemRelations",
22973
+ "BehaviorDescription",
22974
+ "Variable"
22975
+ ];
22976
+ async function ma(e, a) {
22977
+ const { sourceQuery: t, applicationRef: i, structure: n } = a, r = {
22978
+ tagName: "Substation",
22979
+ id: n.Substation.id
22980
+ }, s = await Re(e, {
22981
+ sourceQuery: t,
22982
+ scopeRef: i,
22983
+ refTagName: "FunctionRef",
22984
+ targetTagName: "Function"
22985
+ });
22986
+ for (const o of s) {
22987
+ const l = await Z(t, o, n);
22988
+ await me(e, {
22989
+ sourceQuery: t,
22990
+ functionRef: o,
22991
+ targetParentRef: l,
22992
+ omit: D
22993
+ });
22994
+ }
22995
+ for (const o of s)
22996
+ await be(e, {
22997
+ sourceQuery: t,
22998
+ functionRef: o,
22999
+ structure: n,
23000
+ stripCategoriesUuid: !1
23001
+ });
23002
+ await Sa(e, {
23003
+ sourceQuery: t,
23004
+ scopeTagName: "Application",
23005
+ scopeRef: i,
23006
+ targetParent: r,
23007
+ skip: /* @__PURE__ */ new Set(["FunctionRef", "FunctionCategoryRef"]),
23008
+ omit: D
23009
+ });
23010
+ const c = await Z(t, i, n);
23011
+ await y(e, { sourceQuery: t, ref: i, targetParent: c, omit: D });
23012
+ }
23013
+ async function Le(e) {
23014
+ await w.transaction.orphanUuidRefs(e), await w.transaction.resetLNode(e), await w.transaction.pruneEmptyContainers(e);
23015
+ }
23016
+ async function ba(e, a) {
23017
+ const { sourceQuery: t, applicationRef: i, tool: n, who: r, nameStructure: s } = a, u = await _(e), c = await e.getAttribute(i, { name: "name" }) || "Unnamed Application";
23018
+ await z.transaction.addEntry(e, {
23019
+ filename: `ASD_${c.replace(/\s+/g, "_")}`,
23020
+ header: {
23021
+ fileType: "ASD",
23022
+ version: "keep",
23023
+ tool: n,
23024
+ ...s ? { nameStructure: s } : {}
23025
+ },
23026
+ item: {
23027
+ who: r,
23028
+ what: "ASD initialization",
23029
+ why: "Application was extracted from a previous file"
23030
+ }
23031
+ }), await ma(e, { sourceQuery: t, applicationRef: i, structure: u }), await Le(e);
23032
+ }
23033
+ async function Ra(e, a) {
23034
+ const { sourceQuery: t, functionRef: i, tool: n, who: r, nameStructure: s } = a, u = await _(e), c = {
23035
+ tagName: u.Substation.tagName,
23036
+ id: u.Substation.id
23037
+ }, o = await t.getAttribute(i, { name: "name" }) || "Unnamed Function";
23038
+ await z.transaction.addEntry(e, {
23039
+ filename: `FSD_${o.replace(/\s+/g, "_")}`,
23040
+ header: {
23041
+ fileType: "FSD",
23042
+ version: "keep",
23043
+ tool: n,
23044
+ ...s ? { nameStructure: s } : {}
23045
+ },
23046
+ item: {
23047
+ who: r,
23048
+ what: "FSD initialization",
23049
+ why: "Function was extracted from a previous file"
23050
+ }
23051
+ }), await me(e, {
23052
+ sourceQuery: t,
23053
+ functionRef: i,
23054
+ targetParentRef: c,
23055
+ omit: fa,
23056
+ stripRootAttributes: ["templateUuid"]
23057
+ }), await be(e, {
23058
+ sourceQuery: t,
23059
+ functionRef: i,
23060
+ structure: u
23061
+ }), await Le(e);
23062
+ }
23063
+ const La = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
23064
+ __proto__: null,
23065
+ ensureSubstationTemplateStructure: _,
23066
+ extractToAsd: ba,
23067
+ extractToFsd: Ra
23068
+ }, Symbol.toStringTag, { value: "Module" })), Aa = {
23069
+ transaction: La
23070
+ }, va = {
23071
+ cleanUp: w,
23072
+ dataModel: pe,
23073
+ history: z,
23074
+ reference: T,
23075
+ template: Aa,
23076
+ presentation: sa
22505
23077
  };
22506
23078
  export {
22507
- D,
22508
- Rt as H,
22509
- he as K,
22510
- bt as R,
22511
- P as S,
22512
- m as U,
22513
- X as a,
22514
- dt as b,
22515
- lt as c,
22516
- pt as d,
22517
- z as r
23079
+ ga as H,
23080
+ va as S,
23081
+ P as a,
23082
+ Bt as b,
23083
+ Gt as c,
23084
+ Ut as d
22518
23085
  };