@pie-element/placement-ordering 14.1.2-next.12 → 14.1.2-next.13

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.
@@ -8,26 +8,20 @@ var a = i("pie-elements:placement-ordering:ordering"), o = (e, t, n) => {
8
8
  r,
9
9
  ...i.slice(n)
10
10
  ];
11
- }, s = (e, n, r) => {
12
- if (a("[swap]", e, n, r), !e || e.length <= 1 || n === void 0 || r === void 0) throw Error(`swap requires a non-empty array, fromIndex, toIndex: ${e}, ${n} ${r}`);
13
- let i = t(e), o = e[r];
14
- return i[r] = i[n], i[n] = o, i;
15
11
  };
16
- function c(e, n) {
12
+ function s(e, n) {
17
13
  let r = t(e.response);
18
14
  if (r[n.index] === n.id) r[n.index] = void 0;
19
15
  else throw Error(`Tried to remove from index: ${n.index}, but the id doesn't match: array: ${r}, target: ${n.id}`);
20
16
  return r;
21
17
  }
22
- function l(e, n, r) {
23
- let { response: i, opts: c } = e, l = t(i);
24
- if (c.includeTargets) return n.type === "choice" && r.type === "target" ? (l[r.index] = n.id, l) : n.type === "target" && r.type === "choice" ? (l[n.index] = void 0, l) : n.type === "target" && r.type === "target" ? s(i, n.index, r.index) : (a("do nothing to the response"), i);
25
- {
26
- let t = e.response.findIndex((e) => e !== void 0 && e === n.id), i = e.response.findIndex((e) => e !== void 0 && e === r.id);
27
- return a("fromIndex: ", t, "toIndex:", i), o(e.response, t, i);
28
- }
18
+ function c(e, n, r) {
19
+ let { response: i, opts: s } = e, c = t(i);
20
+ if (s.includeTargets) return n.type === "choice" && r.type === "target" ? (c[r.index] = n.id, c) : n.type === "target" && r.type === "choice" ? (c[n.index] = void 0, c) : n.type === "target" && r.type === "target" ? (c[r.index] = n.id, c[n.index] = void 0, c) : (a("do nothing to the response"), i);
21
+ let l = e.response.findIndex((e) => e !== void 0 && e === n.id), u = e.response.findIndex((e) => e !== void 0 && e === r.id);
22
+ return a("fromIndex: ", l, "toIndex:", u), o(e.response, l, u);
29
23
  }
30
- function u(e, t, n, r) {
24
+ function l(e, t, n, r) {
31
25
  if (r.includeTargets) {
32
26
  let i = [];
33
27
  for (let r = 0; r < t.length; r++) {
@@ -62,26 +56,26 @@ function u(e, t, n, r) {
62
56
  return i === 0 && t.push(a), t.push(o, a), t;
63
57
  }, []);
64
58
  }
65
- function d(t, i, a, o) {
59
+ function u(t, i, a, o) {
66
60
  return o = e({ includeTargets: !0 }, o), a ||= [], i = !i || n(i) ? o.includeTargets ? Array(t.length) : r(t, (e) => e.id) : i, {
67
61
  choices: t,
68
62
  response: i,
69
63
  opts: o,
70
64
  outcomes: a,
71
- tiles: u(t, i, a, o)
65
+ tiles: l(t, i, a, o)
72
66
  };
73
67
  }
74
- function f(e, t) {
68
+ function d(e, t) {
75
69
  switch (e.type) {
76
70
  case "move": {
77
- let { from: n, to: r } = e, i = l(t, n, r), a = u(t.choices, i, t.outcomes, t.opts);
71
+ let { from: n, to: r } = e, i = c(t, n, r), a = l(t.choices, i, t.outcomes, t.opts);
78
72
  return Object.assign({}, t, {
79
73
  response: i,
80
74
  tiles: a
81
75
  });
82
76
  }
83
77
  case "remove": {
84
- let { target: n } = e, r = c(t, n), i = u(t.choices, r, t.outcomes, t.opts);
78
+ let { target: n } = e, r = s(t, n), i = l(t.choices, r, t.outcomes, t.opts);
85
79
  return Object.assign({}, t, {
86
80
  response: r,
87
81
  tiles: i
@@ -91,4 +85,4 @@ function f(e, t) {
91
85
  return t;
92
86
  }
93
87
  //#endregion
94
- export { d as buildState, o as push, f as reducer, s as swap };
88
+ export { u as buildState, o as push, d as reducer };