@updog/data-editor 0.1.50 → 0.1.52

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 (4) hide show
  1. package/index.css +1 -1
  2. package/index.d.ts +6 -0
  3. package/index.js +882 -629
  4. package/package.json +1 -1
package/index.js CHANGED
@@ -413,6 +413,7 @@ var Ur = {
413
413
  steps: {
414
414
  selectFiles: "Select files",
415
415
  sheetSelection: "Select sheet",
416
+ headerSelection: "Header selection",
416
417
  matchColumns: "Match columns",
417
418
  matchValues: "Match values",
418
419
  primaryKey: "Primary key"
@@ -432,12 +433,15 @@ var Ur = {
432
433
  emptyData: "The source returned no data",
433
434
  fetchError: "Failed to load data"
434
435
  },
436
+ headerSelection: { noHeaderLabel: "My data has no header row" },
435
437
  matchColumns: {
436
438
  banner: "Some columns could not be automatically matched",
437
439
  importedColumns: "Imported columns",
438
440
  matchedCount: "{{matched}}/{{total}} matched",
439
441
  targetColumns: "Target columns",
440
442
  selectColumnPlaceholder: "Select column",
443
+ syntheticColumn: "C{{index}}",
444
+ syntheticColumnValue: "C{{index}}: {{value}}",
441
445
  bestMatch: "Best match",
442
446
  createColumn: "Create column",
443
447
  createColumnNameLabel: "Column name",
@@ -13112,17 +13116,17 @@ function ff(e, t, n) {
13112
13116
  }
13113
13117
  //#endregion
13114
13118
  //#region src/components/PreviewTable/index.tsx
13115
- var pf = 15, mf = { width: 1 }, hf = { height: 1 }, gf = ({ headers: e, rows: t, lockedColumns: n, displayRows: r = pf, blur: a = !0, scrollbars: o = !0, className: s }) => {
13116
- let c = e.length, l = Array.from({ length: r }, (e, n) => t[n]), u = o === !0, d = o === !0 || o === "empty", f = y(null), p = y(null), h = y(null), g = y(null), _ = y(null), x = y(null), [T, D] = b(!1), [O, k] = b(!1);
13119
+ var pf = 15, mf = { width: 1 }, hf = { height: 1 }, gf = ({ headers: e, rows: t, lockedColumns: n, displayRows: r = pf, blur: i = !0, scrollbars: a = !0, selectedRow: o, onSelectRow: s, className: c }) => {
13120
+ let l = e ? e.length : Math.max(0, ...t.map((e) => e?.length ?? 0)), u = Array.from({ length: r }, (e, n) => t[n]), d = a === !0, p = a === !0 || a === "empty", h = y(null), g = y(null), _ = y(null), x = y(null), T = y(null), D = y(null), [O, k] = b(!1), [A, j] = b(!1);
13117
13121
  m(() => {
13118
- if (!u) return;
13119
- let e = f.current, t = h.current, n = g.current, r = _.current, i = x.current;
13122
+ if (!d) return;
13123
+ let e = h.current, t = _.current, n = x.current, r = T.current, i = D.current;
13120
13124
  if (!e) return;
13121
13125
  let a = () => {
13122
13126
  let a = e.scrollHeight - e.clientHeight, o = e.scrollWidth - e.clientWidth;
13123
- t && r && (r.style.height = a + t.clientHeight + "px"), n && i && (i.style.width = o + n.clientWidth + "px"), k(a > 0), D(o > 0);
13127
+ t && r && (r.style.height = a + t.clientHeight + "px"), n && i && (i.style.width = o + n.clientWidth + "px"), j(a > 0), k(o > 0);
13124
13128
  }, o = new ResizeObserver(a);
13125
- o.observe(e), p.current && o.observe(p.current), a();
13129
+ o.observe(e), g.current && o.observe(g.current), a();
13126
13130
  let s = (e) => {
13127
13131
  e.preventDefault(), t && (t.scrollTop += e.deltaY), n && (n.scrollLeft += e.deltaX);
13128
13132
  };
@@ -13135,59 +13139,71 @@ var pf = 15, mf = { width: 1 }, hf = { height: 1 }, gf = ({ headers: e, rows: t,
13135
13139
  return t?.addEventListener("scroll", c, { passive: !0 }), n?.addEventListener("scroll", l, { passive: !0 }), () => {
13136
13140
  o.disconnect(), e.removeEventListener("wheel", s), t?.removeEventListener("scroll", c), n?.removeEventListener("scroll", l);
13137
13141
  };
13138
- }, [u]);
13139
- let A = v(() => ({ gridTemplateColumns: `var(--marker-width) repeat(${Math.max(c, 1)}, auto)` }), [c]);
13142
+ }, [d]);
13143
+ let M = f((e) => {
13144
+ s?.(Number(e.currentTarget.dataset.rowIndex));
13145
+ }, [s]), N = f((e) => {
13146
+ e.key !== "Enter" && e.key !== " " || (e.preventDefault(), s?.(Number(e.currentTarget.dataset.rowIndex)));
13147
+ }, [s]), P = v(() => ({ gridTemplateColumns: `var(--marker-width) repeat(${Math.max(l, 1)}, auto)` }), [l]);
13140
13148
  return /* @__PURE__ */ w("div", {
13141
- className: E("updog__preview-table", o === !1 ? "updog__preview-table--scrollbars-none" : o === "empty" ? "updog__preview-table--scrollbars-empty" : "updog__preview-table--scrollbars-show", u && !T && "updog__preview-table--no-hscroll", u && !O && "updog__preview-table--no-vscroll", s),
13149
+ className: E("updog__preview-table", a === !1 ? "updog__preview-table--scrollbars-none" : a === "empty" ? "updog__preview-table--scrollbars-empty" : "updog__preview-table--scrollbars-show", d && !O && "updog__preview-table--no-hscroll", d && !A && "updog__preview-table--no-vscroll", c),
13142
13150
  children: [
13143
13151
  /* @__PURE__ */ C("div", {
13144
13152
  className: "updog__preview-table__canvas-wrap",
13145
13153
  children: /* @__PURE__ */ C("div", {
13146
13154
  className: "updog__preview-table__scroll",
13147
- ref: f,
13155
+ ref: h,
13148
13156
  children: /* @__PURE__ */ w("div", {
13149
13157
  className: "updog__preview-table__grid",
13150
- style: A,
13151
- ref: p,
13152
- children: [
13153
- /* @__PURE__ */ C("div", { className: "updog__preview-table-marker" }),
13154
- c === 0 ? /* @__PURE__ */ C("div", { className: E("updog__preview-table-th", "updog__preview-table-cell--last-col") }) : e.map((e, t) => /* @__PURE__ */ w("div", {
13155
- className: E("updog__preview-table-th", t === c - 1 && "updog__preview-table-cell--last-col"),
13156
- children: [/* @__PURE__ */ C("span", {
13157
- className: "updog__preview-table-th__label",
13158
- children: e
13159
- }), n?.[t] && /* @__PURE__ */ C(ge, {
13160
- size: "0.875rem",
13161
- className: "updog__preview-table-th__lock-icon"
13162
- })]
13163
- }, t)),
13164
- l.map((t, n) => /* @__PURE__ */ w(i, { children: [/* @__PURE__ */ C("div", {
13165
- className: E("updog__preview-table-marker", n === r - 1 && "updog__preview-table-cell--last-row"),
13166
- children: n + 1
13167
- }), c === 0 ? /* @__PURE__ */ C("div", { className: E("updog__preview-table-td", "updog__preview-table-cell--last-col", n === r - 1 && "updog__preview-table-cell--last-row") }) : e.map((e, i) => /* @__PURE__ */ C("div", {
13168
- className: E("updog__preview-table-td", i === c - 1 && "updog__preview-table-cell--last-col", n === r - 1 && "updog__preview-table-cell--last-row"),
13169
- children: t?.[i] ?? ""
13170
- }, i))] }, n))
13171
- ]
13158
+ style: P,
13159
+ ref: g,
13160
+ children: [e !== void 0 && /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C("div", { className: "updog__preview-table-marker" }), l === 0 ? /* @__PURE__ */ C("div", { className: E("updog__preview-table-th", "updog__preview-table-cell--last-col") }) : e.map((e, t) => /* @__PURE__ */ w("div", {
13161
+ className: E("updog__preview-table-th", t === l - 1 && "updog__preview-table-cell--last-col"),
13162
+ children: [/* @__PURE__ */ C("span", {
13163
+ className: "updog__preview-table-th__label",
13164
+ children: e
13165
+ }), n?.[t] && /* @__PURE__ */ C(ge, {
13166
+ size: "0.875rem",
13167
+ className: "updog__preview-table-th__lock-icon"
13168
+ })]
13169
+ }, t))] }), u.map((e, t) => {
13170
+ let n = t === r - 1, i = !!s && e !== void 0, a = o === t;
13171
+ return /* @__PURE__ */ w("div", {
13172
+ className: E("updog__preview-table-row", i && "updog__preview-table-row--interactive", a && "updog__preview-table-row--selected"),
13173
+ "data-row-index": t,
13174
+ role: i ? "row" : void 0,
13175
+ tabIndex: i ? 0 : void 0,
13176
+ "aria-selected": i ? a : void 0,
13177
+ onClick: i ? M : void 0,
13178
+ onKeyDown: i ? N : void 0,
13179
+ children: [/* @__PURE__ */ C("div", {
13180
+ className: E("updog__preview-table-marker", n && "updog__preview-table-cell--last-row"),
13181
+ children: t + 1
13182
+ }), l === 0 ? /* @__PURE__ */ C("div", { className: E("updog__preview-table-td", "updog__preview-table-cell--last-col", n && "updog__preview-table-cell--last-row") }) : Array.from({ length: l }, (t, r) => /* @__PURE__ */ C("div", {
13183
+ className: E("updog__preview-table-td", r === l - 1 && "updog__preview-table-cell--last-col", n && "updog__preview-table-cell--last-row"),
13184
+ children: e?.[r] ?? ""
13185
+ }, r))]
13186
+ }, t);
13187
+ })]
13172
13188
  })
13173
13189
  })
13174
13190
  }),
13175
- d && /* @__PURE__ */ w(S, { children: [
13191
+ p && /* @__PURE__ */ w(S, { children: [
13176
13192
  /* @__PURE__ */ C("div", {
13177
13193
  className: "updog__preview-table__vtrack",
13178
- ref: h,
13194
+ ref: _,
13179
13195
  tabIndex: -1,
13180
13196
  children: /* @__PURE__ */ C("div", {
13181
- ref: _,
13197
+ ref: T,
13182
13198
  style: mf
13183
13199
  })
13184
13200
  }),
13185
13201
  /* @__PURE__ */ C("div", {
13186
13202
  className: "updog__preview-table__htrack",
13187
- ref: g,
13203
+ ref: x,
13188
13204
  tabIndex: -1,
13189
13205
  children: /* @__PURE__ */ C("div", {
13190
- ref: x,
13206
+ ref: D,
13191
13207
  style: hf
13192
13208
  })
13193
13209
  }),
@@ -13195,8 +13211,8 @@ var pf = 15, mf = { width: 1 }, hf = { height: 1 }, gf = ({ headers: e, rows: t,
13195
13211
  /* @__PURE__ */ C("div", { className: "updog__preview-table__corner updog__preview-table__corner--bottom-left" }),
13196
13212
  /* @__PURE__ */ C("div", { className: "updog__preview-table__corner updog__preview-table__corner--bottom-right" })
13197
13213
  ] }),
13198
- a && /* @__PURE__ */ C("div", { className: "updog__preview-table-blur-vertical" }),
13199
- a && /* @__PURE__ */ C("div", { className: "updog__preview-table-blur-horizontal" })
13214
+ i && /* @__PURE__ */ C("div", { className: "updog__preview-table-blur-vertical" }),
13215
+ i && /* @__PURE__ */ C("div", { className: "updog__preview-table-blur-horizontal" })
13200
13216
  ]
13201
13217
  });
13202
13218
  }, _f = s(null);
@@ -20892,7 +20908,7 @@ var ov = ({ text: e, onSelect: t }) => /* @__PURE__ */ C(J, {
20892
20908
  return this.state.hasError ? /* @__PURE__ */ C(_v, { error: vv }) : this.props.children;
20893
20909
  }
20894
20910
  }, bv = ({ leftSlot: e }) => {
20895
- let { variant: t, setShowUploader: n } = X(), { t: r } = K(), { isFirstStep: i, isLastStep: a, nextStep: o, prevStep: s, onImport: c, parsedCsv: l, xlsxFile: u, isParsing: d, isImporting: p, steps: m, activeStepIndex: h, selectedSheet: g, handleSheetConfirmed: _, remoteSourceLoading: v } = hb(), y = i && t === "editor", b = f(() => {
20911
+ let { variant: t, setShowUploader: n } = X(), { t: r } = K(), { isFirstStep: i, isLastStep: a, nextStep: o, prevStep: s, onImport: c, parsedCsv: l, xlsxFile: u, isParsing: d, isImporting: p, steps: m, activeStepIndex: h, selectedSheet: g, handleSheetConfirmed: _, remoteSourceLoading: v } = Bb(), y = i && t === "editor", b = f(() => {
20896
20912
  n(!1);
20897
20913
  }, [n]), x = m[h]?.id === "sheet-selection", S = f(() => {
20898
20914
  a ? c() : x ? _() : o();
@@ -21661,15 +21677,17 @@ var ov = ({ text: e, onSelect: t }) => /* @__PURE__ */ C(J, {
21661
21677
  }
21662
21678
  return i;
21663
21679
  }, Hv = () => {
21664
- let { columns: e, enableCreateColumn: t, synonyms: n } = X(), { t: r } = K(), { parsedCsv: i, columnMapping: a, updateColumnMapping: o, pendingColumns: s, setPendingColumns: c } = hb(), [l, u] = b(null), d = y(null), p = i?.headers ?? [], m = y(null);
21665
- m.current === null && (m.current = Vv(p, e, n));
21666
- let h = f((e, t) => {
21680
+ let { columns: e, enableCreateColumn: t, synonyms: n } = X(), { t: r } = K(), { headers: i, columnMapping: a, updateColumnMapping: o, pendingColumns: s, setPendingColumns: c } = Bb(), [l, u] = b(null), d = y(null), p = v(() => Vv(i, e, n), [
21681
+ i,
21682
+ e,
21683
+ n
21684
+ ]), m = f((e, t) => {
21667
21685
  if (t === "action:create") {
21668
21686
  d.current = e, u({ title: e });
21669
21687
  return;
21670
21688
  }
21671
21689
  o(e, t);
21672
- }, [o]), g = f((e) => {
21690
+ }, [o]), h = f((e) => {
21673
21691
  if (d.current === null) return;
21674
21692
  let t = Math.random().toString(36).slice(2, 7), n = `${Go}${e.title}-${t}`;
21675
21693
  c((t) => [...t, {
@@ -21677,59 +21695,64 @@ var ov = ({ text: e, onSelect: t }) => /* @__PURE__ */ C(J, {
21677
21695
  id: n,
21678
21696
  size: 150
21679
21697
  }]), o(d.current, n), d.current = null, u(null);
21680
- }, [o, c]), _ = f(() => {
21698
+ }, [o, c]), g = f(() => {
21681
21699
  d.current = null, u(null);
21682
- }, []), x = v(() => [...e.map((e) => e.title), ...s.map((e) => e.title)], [e, s]), S = v(() => {
21700
+ }, []), _ = v(() => [...e.map((e) => e.title), ...s.map((e) => e.title)], [e, s]), x = v(() => {
21683
21701
  let n = {
21684
21702
  text: r("dataEditor.uploader.matchColumns.bestMatch"),
21685
21703
  color: "green"
21686
- }, i = {
21704
+ }, a = {
21687
21705
  text: r("dataEditor.uploader.matchColumns.newColumnTag"),
21688
21706
  color: "blue"
21689
- }, a = r("dataEditor.uploader.matchColumns.createColumn");
21690
- return Object.fromEntries(p.map((r) => {
21691
- let o = m.current?.[r], c = e.map((e) => ({
21707
+ }, o = r("dataEditor.uploader.matchColumns.createColumn");
21708
+ return Object.fromEntries(i.map((r) => {
21709
+ let i = p[r], c = e.map((e) => ({
21692
21710
  id: e.id,
21693
21711
  text: e.title,
21694
- ...e.id === o && { tag: n }
21712
+ ...e.id === i && { tag: n }
21695
21713
  }));
21696
21714
  for (let e of s) c.push({
21697
21715
  id: e.id,
21698
21716
  text: e.title,
21699
- tag: i
21717
+ tag: a
21700
21718
  });
21701
21719
  return t && c.push({
21702
21720
  id: `${r}_d`,
21703
21721
  type: "divider"
21704
21722
  }, {
21705
21723
  id: Lv,
21706
- text: a,
21724
+ text: o,
21707
21725
  icon: /* @__PURE__ */ C(Ce, { size: "1rem" })
21708
21726
  }), [r, c];
21709
21727
  }));
21710
21728
  }, [
21711
- p,
21729
+ i,
21712
21730
  e,
21713
21731
  s,
21714
21732
  r,
21715
- t
21716
- ]), w = v(() => p.filter((e) => a[e]).length, [p, a]);
21733
+ t,
21734
+ p
21735
+ ]), S = v(() => i.filter((e) => a[e]).length, [i, a]);
21717
21736
  return {
21718
- headers: p,
21719
- matchedCount: w,
21720
- allMatched: w === p.length,
21737
+ headers: i,
21738
+ matchedCount: S,
21739
+ allMatched: S === i.length,
21721
21740
  placeholder: r("dataEditor.uploader.matchColumns.selectColumnPlaceholder"),
21722
- existingNames: x,
21741
+ existingNames: _,
21723
21742
  createModalValues: l,
21724
21743
  getRowData: f((e) => ({
21725
21744
  mappedValue: a[e],
21726
- options: S[e],
21727
- autoMatchId: m.current?.[e]
21728
- }), [a, S]),
21729
- onSelectChange: h,
21745
+ options: x[e],
21746
+ autoMatchId: p[e]
21747
+ }), [
21748
+ a,
21749
+ x,
21750
+ p
21751
+ ]),
21752
+ onSelectChange: m,
21730
21753
  onClear: o,
21731
- submitCreate: g,
21732
- closeCreate: _
21754
+ submitCreate: h,
21755
+ closeCreate: g
21733
21756
  };
21734
21757
  }, Uv = s(null);
21735
21758
  function Wv({ children: e }) {
@@ -21873,12 +21896,208 @@ var Gv = () => {
21873
21896
  /* @__PURE__ */ C(Yv, {})
21874
21897
  ]
21875
21898
  }), Zv = () => {
21876
- let { parsedCsv: e } = hb();
21899
+ let { parsedCsv: e } = Bb();
21877
21900
  return e ? /* @__PURE__ */ C(Xl, { children: /* @__PURE__ */ w(Jl, { children: [/* @__PURE__ */ C("div", {
21878
21901
  className: "updog__step-column-matching__content updog__scrollbar",
21879
21902
  children: /* @__PURE__ */ C(Wv, { children: /* @__PURE__ */ C(Xv, {}) })
21880
21903
  }), /* @__PURE__ */ C(bv, {})] }) }) : null;
21881
- }, Qv = ({ open: e, existingOptions: t, initialName: n, onClose: r, onSubmit: i }) => {
21904
+ }, Qv = new Set([
21905
+ "true",
21906
+ "false",
21907
+ "yes",
21908
+ "no"
21909
+ ]), $v = /^\d{1,4}[-/.]\d{1,2}[-/.]\d{1,4}$/, ey = /^[-+]?(\d{1,3}([ ,.]\d{3})+|\d+)([.,]\d+)?%?$/, ty = new Set([
21910
+ "number",
21911
+ "date",
21912
+ "bool"
21913
+ ]);
21914
+ function ny(e) {
21915
+ if (e == null) return "empty";
21916
+ let t = String(e).trim();
21917
+ return t.length === 0 ? "empty" : Qv.has(t.toLowerCase()) ? "bool" : $v.test(t) ? "date" : ey.test(t) ? "number" : "text";
21918
+ }
21919
+ function ry(e) {
21920
+ return e.filter((e) => e != null && String(e).trim().length > 0).length;
21921
+ }
21922
+ function iy(e) {
21923
+ let t = /* @__PURE__ */ new Map(), n = 0, r = 0;
21924
+ for (let i of e) {
21925
+ let e = ry(i);
21926
+ if (e === 0) continue;
21927
+ let a = (t.get(e) ?? 0) + 1;
21928
+ t.set(e, a), a > n && (n = a, r = e);
21929
+ }
21930
+ return r;
21931
+ }
21932
+ function ay(e) {
21933
+ let t = 0;
21934
+ for (let n of e) t = Math.max(t, n.length);
21935
+ return t;
21936
+ }
21937
+ function oy(e, t, n) {
21938
+ if (t <= 0) return 0;
21939
+ let r = -1, i = 0;
21940
+ for (let a = 0; a < e.length; a++) if (ry(e[a]) === t) {
21941
+ if (r < 0 && (r = a), i++, i >= n) return r;
21942
+ } else r = -1, i = 0;
21943
+ for (let n = 0; n < e.length; n++) if (ry(e[n]) === t) return n;
21944
+ return 0;
21945
+ }
21946
+ function sy(e, t, n, r) {
21947
+ let i = /* @__PURE__ */ new Map();
21948
+ for (let a = t; a < n; a++) {
21949
+ let t = ny(e[a]?.[r]);
21950
+ t !== "empty" && i.set(t, (i.get(t) ?? 0) + 1);
21951
+ }
21952
+ let a = "empty", o = 0;
21953
+ for (let [e, t] of i) t > o && (o = t, a = e);
21954
+ return a;
21955
+ }
21956
+ function cy(e, t, n, r) {
21957
+ let i = 0, a = 0;
21958
+ for (let o = 0; o < r; o++) {
21959
+ let r = sy(e, t + 1, n, o);
21960
+ r !== "empty" && (a++, ny(e[t]?.[o]) === "text" && ty.has(r) && i++);
21961
+ }
21962
+ return a === 0 ? 0 : i / a;
21963
+ }
21964
+ function ly(e, t, n, r) {
21965
+ let i = 0, a = 0;
21966
+ for (let o = 0; o < r; o++) {
21967
+ let r = sy(e, t, n, o);
21968
+ if (r !== "empty") for (let s = t; s < n; s++) {
21969
+ let t = ny(e[s]?.[o]);
21970
+ t !== "empty" && (a++, t === r && i++);
21971
+ }
21972
+ }
21973
+ return a === 0 ? 0 : i / a;
21974
+ }
21975
+ function uy(e) {
21976
+ let t = e.map(ny).filter((e) => e !== "empty");
21977
+ return t.length === 0 ? 0 : 1 - t.filter((e) => e !== "text").length / t.length;
21978
+ }
21979
+ function dy(e, t) {
21980
+ if (t <= 0) return 0;
21981
+ let n = ry(e);
21982
+ return Math.max(0, 1 - Math.abs(n - t) / t);
21983
+ }
21984
+ function fy(e) {
21985
+ let t = e.map((e) => String(e ?? "").trim().toLowerCase()).filter((e) => e.length > 0);
21986
+ return t.length === 0 ? 0 : new Set(t).size / t.length;
21987
+ }
21988
+ function py(e, t, n, r, i) {
21989
+ return .45 * cy(e, t, n, r) + .25 * ly(e, t + 1, n, r) + .15 * uy(e[t] ?? []) + .1 * dy(e[t] ?? [], i) + .05 * fy(e[t] ?? []);
21990
+ }
21991
+ function my(e, t = 100) {
21992
+ if (e.length === 0) return {
21993
+ headerRowIndex: 0,
21994
+ dataStartIndex: 0,
21995
+ confidence: 0,
21996
+ mode: "header",
21997
+ review: { kind: "none" }
21998
+ };
21999
+ let n = Math.min(t, e.length), r = e.slice(0, n), i = ay(r), a = iy(r), o = oy(r, a, 3), s = e[o] ?? [], c = cy(e, o, n, i), l = ly(e, o + 1, n, i), u = ry(s) > 0 && uy(s) === 0, d = Math.round(Math.max(0, py(e, o, n, i, a)) * 100) / 100;
22000
+ if (u && c <= .15 && l >= .7) return {
22001
+ headerRowIndex: -1,
22002
+ dataStartIndex: o,
22003
+ confidence: d,
22004
+ mode: "no-header",
22005
+ review: { kind: "no-header" }
22006
+ };
22007
+ let f = d >= .55 ? { kind: "none" } : {
22008
+ kind: "ambiguous-row",
22009
+ confidence: d
22010
+ };
22011
+ return {
22012
+ headerRowIndex: o,
22013
+ dataStartIndex: o + 1,
22014
+ confidence: d,
22015
+ mode: "header",
22016
+ review: f
22017
+ };
22018
+ }
22019
+ function hy(e) {
22020
+ let t = /* @__PURE__ */ new Set();
22021
+ return e.map((e) => {
22022
+ let n = e, r = 2;
22023
+ for (; t.has(n);) n = `${e} (${r})`, r++;
22024
+ return t.add(n), n;
22025
+ });
22026
+ }
22027
+ //#endregion
22028
+ //#region src/components/DataUploader/components/StepHeaderSelection/context/useViewModel.tsx
22029
+ function gy(e, t, n, r) {
22030
+ return v(() => ({
22031
+ sample: e,
22032
+ selectedRow: t,
22033
+ selectRow: n,
22034
+ noHeader: r
22035
+ }), [
22036
+ e,
22037
+ t,
22038
+ n,
22039
+ r
22040
+ ]);
22041
+ }
22042
+ //#endregion
22043
+ //#region src/components/DataUploader/components/StepHeaderSelection/context/index.tsx
22044
+ var _y = s(null);
22045
+ function vy({ sample: e, selectedRow: t, selectRow: n, noHeader: r, children: i }) {
22046
+ let a = gy(e, t, n, r);
22047
+ return /* @__PURE__ */ C(_y.Provider, {
22048
+ value: a,
22049
+ children: i
22050
+ });
22051
+ }
22052
+ var yy = () => {
22053
+ let e = p(_y);
22054
+ if (!e) throw Error("useHeaderSelection must be used within HeaderSelectionProvider");
22055
+ return e;
22056
+ }, by = () => {
22057
+ let { sample: e, selectedRow: t, selectRow: n, noHeader: r } = yy(), { headers: i } = Bb(), { headers: a, rows: o } = v(() => {
22058
+ let t = i.length;
22059
+ return {
22060
+ headers: i.map((e) => r ? e : ""),
22061
+ rows: e.map((e) => Array.from({ length: t }, (t, n) => String(e[n] ?? "")))
22062
+ };
22063
+ }, [
22064
+ e,
22065
+ i,
22066
+ r
22067
+ ]);
22068
+ return /* @__PURE__ */ C(gf, {
22069
+ className: "updog__step-header-selection__preview",
22070
+ headers: a,
22071
+ rows: o,
22072
+ displayRows: e.length,
22073
+ blur: !1,
22074
+ selectedRow: r ? void 0 : t,
22075
+ onSelectRow: r ? void 0 : n
22076
+ });
22077
+ }, xy = () => {
22078
+ let { t: e } = K(), { parsedCsv: t, headerRowIndex: n, setHeaderRowIndex: r } = Bb(), i = f((e) => {
22079
+ r(e ? -1 : Math.max(0, t?.detection.headerRowIndex ?? 0));
22080
+ }, [r, t]);
22081
+ if (!t) return null;
22082
+ let a = t.rawRows.slice(0, 50), o = n < 0;
22083
+ return /* @__PURE__ */ C(Xl, { children: /* @__PURE__ */ C(Jl, { children: /* @__PURE__ */ w(vy, {
22084
+ sample: a,
22085
+ selectedRow: o ? void 0 : n,
22086
+ selectRow: r,
22087
+ noHeader: o,
22088
+ children: [/* @__PURE__ */ w("div", {
22089
+ className: "updog__step-header-selection__content updog__scrollbar",
22090
+ children: [/* @__PURE__ */ C("div", {
22091
+ className: "updog__step-header-selection__noHeadersWrapper",
22092
+ children: /* @__PURE__ */ C(Ni, {
22093
+ checked: o,
22094
+ onChange: i,
22095
+ label: e("dataEditor.uploader.headerSelection.noHeaderLabel")
22096
+ })
22097
+ }), /* @__PURE__ */ C(by, {})]
22098
+ }), /* @__PURE__ */ C(bv, {})]
22099
+ }) }) });
22100
+ }, Sy = ({ open: e, existingOptions: t, initialName: n, onClose: r, onSubmit: i }) => {
21882
22101
  let { t: a } = K();
21883
22102
  return /* @__PURE__ */ C(Vi, {
21884
22103
  open: e,
@@ -21891,13 +22110,13 @@ var Gv = () => {
21891
22110
  onSubmit: i
21892
22111
  })
21893
22112
  });
21894
- }, $v = [
22113
+ }, Cy = [
21895
22114
  ",",
21896
22115
  ";",
21897
22116
  "|",
21898
22117
  "\n",
21899
22118
  " "
21900
- ], ey = (e, t, n) => {
22119
+ ], wy = (e, t, n) => {
21901
22120
  let r = new Set(n.map((e) => e.trim().toLowerCase())), i = (e) => r.has(e.trim().toLowerCase());
21902
22121
  if (e.trim() === "") return [];
21903
22122
  if (i(e)) return [e.trim()];
@@ -21909,80 +22128,144 @@ var Gv = () => {
21909
22128
  a.push(e);
21910
22129
  continue;
21911
22130
  }
21912
- a.push(...ty(e, t, i));
22131
+ a.push(...Ty(e, t, i));
21913
22132
  }
21914
22133
  }
21915
22134
  return a;
21916
- }, ty = (e, t, n) => {
21917
- for (let r of $v) {
22135
+ }, Ty = (e, t, n) => {
22136
+ for (let r of Cy) {
21918
22137
  if (r === t || !e.includes(r)) continue;
21919
22138
  let i = e.split(r).map((e) => e.trim()).filter((e) => e !== "");
21920
22139
  if (i.length >= 2 && i.every(n)) return i;
21921
22140
  }
21922
22141
  return [e];
21923
- }, ny = (e, t, n, r) => {
21924
- let i = /* @__PURE__ */ new Set();
21925
- for (let a of e) {
21926
- let e = a[t];
21927
- if (!(e === void 0 || e === "")) if (r) for (let t of ey(e, r, n)) i.add(t);
21928
- else i.add(e);
21929
- }
21930
- return [...i];
21931
- }, ry = () => {
21932
- let { columns: e } = X(), { t } = K(), { parsedCsv: n, columnMapping: r, valueMapping: i, autoValueMapping: a, updateValueMapping: o, multiselectDelimiters: s, setMultiselectDelimiter: c, reapplyMultiselectDelimiter: l, pendingOptions: u, addPendingOption: d } = hb(), [p, h] = b({}), [g, _] = b({}), [x, S] = b(null), w = y(!1), T = v(() => {
22142
+ }, Ey = (e, t, n) => {
22143
+ let r = /* @__PURE__ */ new Set();
22144
+ for (let i of e) if (i !== "") if (n) for (let e of wy(i, n, t)) r.add(e);
22145
+ else r.add(i);
22146
+ return [...r];
22147
+ }, Dy = (e) => !e.some((e) => e != null && String(e).trim() !== ""), Oy = (e, t) => {
22148
+ let n = 0;
22149
+ for (let r = t; r < e.length; r++) n = Math.max(n, e[r].length);
22150
+ return n;
22151
+ }, ky = 50, Ay = (e, t, n) => {
22152
+ let r = Math.min(e.length, t + ky);
22153
+ for (let i = t; i < r; i++) {
22154
+ let t = e[i];
22155
+ if (!t || Dy(t)) continue;
22156
+ let r = !0;
22157
+ for (let e = 0; e < n; e++) {
22158
+ let n = t[e];
22159
+ if (n == null || String(n).trim() === "") {
22160
+ r = !1;
22161
+ break;
22162
+ }
22163
+ }
22164
+ if (r) return Array.from({ length: n }, (e, n) => String(t[n]).trim());
22165
+ }
22166
+ return Array.from({ length: n }, (n, i) => {
22167
+ for (let n = t; n < r; n++) {
22168
+ let t = e[n];
22169
+ if (!t || Dy(t)) continue;
22170
+ let r = t[i], a = r == null ? "" : String(r).trim();
22171
+ if (a !== "") return a;
22172
+ }
22173
+ return "";
22174
+ });
22175
+ }, jy = (e, t) => t === e.headerRowIndex ? e.dataStartIndex : t + 1, My = (e, t, n, r) => {
22176
+ if (t < 0) {
22177
+ let t = Oy(e, n), i = Ay(e, n, t);
22178
+ return Array.from({ length: t }, (e, t) => r(t, i[t]));
22179
+ }
22180
+ return hy((e[t] ?? []).map((e) => String(e ?? "").trim()));
22181
+ }, Ny = () => ({
22182
+ headerRowIndex: 0,
22183
+ dataStartIndex: 1,
22184
+ confidence: 1,
22185
+ mode: "header",
22186
+ review: { kind: "none" }
22187
+ }), Py = (e, t) => {
22188
+ let n = [e];
22189
+ for (let r of t) n.push(e.map((e) => r[e] ?? ""));
22190
+ return n;
22191
+ }, Fy = (e) => {
22192
+ let t = /* @__PURE__ */ new Map();
22193
+ for (let n = 0; n < e.length; n++) t.set(e[n], n);
22194
+ return t;
22195
+ }, Iy = (e, t, n) => {
22196
+ let r = [];
22197
+ for (let i = t; i < e.length; i++) {
22198
+ let t = e[i];
22199
+ if (Dy(t)) continue;
22200
+ let a = t[n], o = a == null ? "" : String(a);
22201
+ o !== "" && r.push(o);
22202
+ }
22203
+ return r;
22204
+ }, Ly = (e, t) => {
22205
+ let n = {};
22206
+ for (let r = 0; r < t.length; r++) n[t[r]] = String(e[r] ?? "");
22207
+ return n;
22208
+ }, Ry = (e, t, n, r) => {
22209
+ let i = [];
22210
+ for (let a = n; a < e.length && i.length < r; a++) Dy(e[a]) || i.push(Ly(e[a], t));
22211
+ return i;
22212
+ }, zy = () => {
22213
+ let { columns: e } = X(), { t } = K(), { parsedCsv: n, headers: r, dataStartIndex: i, columnMapping: a, valueMapping: o, autoValueMapping: s, updateValueMapping: c, multiselectDelimiters: l, setMultiselectDelimiter: u, reapplyMultiselectDelimiter: d, pendingOptions: p, addPendingOption: h } = Bb(), [g, _] = b({}), [x, S] = b({}), [w, T] = b(null), E = y(!1), D = v(() => {
21933
22214
  if (!n) return [];
21934
- let t = [];
21935
- for (let [a, o] of Object.entries(r)) {
21936
- if (!o) continue;
21937
- let r = e.find((e) => e.id === o);
21938
- if (!r?.editor) continue;
21939
- let c = r.editor.type;
21940
- if (c !== "select" && c !== "multiselect") continue;
21941
- let l = r.editor.options, u = i[o] ?? {}, d = c === "multiselect", f = d ? s[o] ?? null : null, p = ny(n.rows, a, l, f).map((e) => ({
22215
+ let t = [], s = Fy(r);
22216
+ for (let [r, c] of Object.entries(a)) {
22217
+ if (!c) continue;
22218
+ let a = e.find((e) => e.id === c);
22219
+ if (!a?.editor) continue;
22220
+ let u = a.editor.type;
22221
+ if (u !== "select" && u !== "multiselect") continue;
22222
+ let d = a.editor.options, f = o[c] ?? {}, p = u === "multiselect", m = p ? l[c] ?? null : null, h = s.get(r), g = Ey(h === void 0 ? [] : Iy(n.rawRows, i, h), d, m).map((e) => ({
21942
22223
  imported: e,
21943
- mapped: u[e]
22224
+ mapped: f[e]
21944
22225
  }));
21945
- p.sort((e, t) => e.imported.localeCompare(t.imported));
21946
- let m = p.filter((e) => e.mapped !== void 0).length;
22226
+ g.sort((e, t) => e.imported.localeCompare(t.imported));
22227
+ let _ = g.filter((e) => e.mapped !== void 0).length;
21947
22228
  t.push({
21948
- columnId: o,
21949
- columnTitle: r.title,
21950
- options: l,
21951
- enableCustomValue: r.editor.enableCustomValue !== !1,
21952
- isMultiselect: d,
21953
- delimiter: f,
21954
- values: p,
21955
- matchedCount: m,
21956
- allMatched: m === p.length
22229
+ columnId: c,
22230
+ columnTitle: a.title,
22231
+ options: d,
22232
+ enableCustomValue: a.editor.enableCustomValue !== !1,
22233
+ isMultiselect: p,
22234
+ delimiter: m,
22235
+ values: g,
22236
+ matchedCount: _,
22237
+ allMatched: _ === g.length
21957
22238
  });
21958
22239
  }
21959
22240
  return t;
21960
22241
  }, [
21961
22242
  n,
21962
22243
  r,
21963
- e,
21964
22244
  i,
21965
- s
22245
+ a,
22246
+ e,
22247
+ o,
22248
+ l
21966
22249
  ]);
21967
22250
  m(() => {
21968
- if (w.current || T.length === 0) return;
21969
- w.current = !0;
22251
+ if (E.current || D.length === 0) return;
22252
+ E.current = !0;
21970
22253
  let e = {};
21971
- for (let t of T) t.allMatched && (e[t.columnId] = !0);
21972
- _(e);
21973
- }, [T]);
21974
- let E = v(() => {
22254
+ for (let t of D) t.allMatched && (e[t.columnId] = !0);
22255
+ S(e);
22256
+ }, [D]);
22257
+ let O = v(() => {
21975
22258
  let e = {
21976
22259
  text: t("dataEditor.uploader.matchColumns.bestMatch"),
21977
22260
  color: "green"
21978
22261
  }, n = t("dataEditor.uploader.matchValues.createOption"), r = {};
21979
- for (let t of T) {
21980
- let i = u[t.columnId] ?? [], o = {};
22262
+ for (let t of D) {
22263
+ let i = p[t.columnId] ?? [], a = {};
21981
22264
  for (let r of t.values) {
21982
- let s = a[t.columnId]?.[r.imported], c = new Set(t.options), l = t.options.map((t) => ({
22265
+ let o = s[t.columnId]?.[r.imported], c = new Set(t.options), l = t.options.map((t) => ({
21983
22266
  id: t,
21984
22267
  text: t,
21985
- ...t === s && { tag: e }
22268
+ ...t === o && { tag: e }
21986
22269
  }));
21987
22270
  if (t.enableCustomValue) {
21988
22271
  for (let e of i) c.has(e) || (l.push({
@@ -21998,81 +22281,81 @@ var Gv = () => {
21998
22281
  icon: /* @__PURE__ */ C(Ce, { size: "1rem" })
21999
22282
  });
22000
22283
  }
22001
- o[r.imported] = l;
22284
+ a[r.imported] = l;
22002
22285
  }
22003
- r[t.columnId] = o;
22286
+ r[t.columnId] = a;
22004
22287
  }
22005
22288
  return r;
22006
22289
  }, [
22007
- T,
22008
- a,
22009
- u,
22290
+ D,
22291
+ s,
22292
+ p,
22010
22293
  t
22011
- ]), D = f((e) => p[e] ?? !0, [p]), O = f((e) => g[e] ?? !1, [g]), k = f((e) => {
22012
- let t = p[e.columnId] ?? !0;
22294
+ ]), k = f((e) => g[e] ?? !0, [g]), A = f((e) => x[e] ?? !1, [x]), j = f((e) => {
22295
+ let t = g[e.columnId] ?? !0;
22013
22296
  return e.values.filter((e) => t || e.mapped === void 0);
22014
- }, [p]), A = f((e, t) => E[e]?.[t] ?? [], [E]), j = f((e, t) => {
22015
- h((n) => ({
22297
+ }, [g]), M = f((e, t) => O[e]?.[t] ?? [], [O]), N = f((e, t) => {
22298
+ _((n) => ({
22016
22299
  ...n,
22017
22300
  [e]: t
22018
22301
  }));
22019
- }, []), M = f((e) => {
22020
- _((t) => ({
22302
+ }, []), P = f((e) => {
22303
+ S((t) => ({
22021
22304
  ...t,
22022
22305
  [e]: !t[e]
22023
22306
  }));
22024
- }, []), N = f((e, t, n) => {
22307
+ }, []), F = f((e, t, n) => {
22025
22308
  if (n === "action:create-option") {
22026
- S({
22309
+ T({
22027
22310
  columnId: e,
22028
22311
  imported: t
22029
22312
  });
22030
22313
  return;
22031
22314
  }
22032
- o(e, t, n);
22033
- }, [o]), P = f((e, t) => {
22034
- c(e, t === "" ? null : t);
22035
- }, [c]), F = f((e) => {
22036
- l(e);
22037
- }, [l]), I = f((e) => {
22038
- x && (d(x.columnId, e), o(x.columnId, x.imported, e), S(null));
22315
+ c(e, t, n);
22316
+ }, [c]), I = f((e, t) => {
22317
+ u(e, t === "" ? null : t);
22318
+ }, [u]), L = f((e) => {
22319
+ d(e);
22320
+ }, [d]), R = f((e) => {
22321
+ w && (h(w.columnId, e), c(w.columnId, w.imported, e), T(null));
22039
22322
  }, [
22040
- x,
22041
- d,
22042
- o
22043
- ]), L = f(() => S(null), []);
22323
+ w,
22324
+ h,
22325
+ c
22326
+ ]), z = f(() => T(null), []);
22044
22327
  return {
22045
- sections: T,
22046
- selectOptionsByValue: E,
22047
- createForOptions: v(() => T.find((e) => e.columnId === x?.columnId)?.options ?? [], [T, x]),
22048
- hasCreateTarget: x !== null,
22049
- createInitialName: x?.imported ?? "",
22050
- isShowMatched: D,
22051
- isCollapsed: O,
22052
- getVisibleValues: k,
22053
- getSelectOptions: A,
22054
- setShowMatched: j,
22055
- toggleCollapsed: M,
22056
- selectValue: N,
22057
- changeDelimiter: P,
22058
- reapplyDelimiter: F,
22059
- submitCreate: I,
22060
- closeCreate: L
22328
+ sections: D,
22329
+ selectOptionsByValue: O,
22330
+ createForOptions: v(() => D.find((e) => e.columnId === w?.columnId)?.options ?? [], [D, w]),
22331
+ hasCreateTarget: w !== null,
22332
+ createInitialName: w?.imported ?? "",
22333
+ isShowMatched: k,
22334
+ isCollapsed: A,
22335
+ getVisibleValues: j,
22336
+ getSelectOptions: M,
22337
+ setShowMatched: N,
22338
+ toggleCollapsed: P,
22339
+ selectValue: F,
22340
+ changeDelimiter: I,
22341
+ reapplyDelimiter: L,
22342
+ submitCreate: R,
22343
+ closeCreate: z
22061
22344
  };
22062
- }, iy = s(null);
22063
- function ay({ children: e }) {
22064
- let t = ry();
22065
- return /* @__PURE__ */ C(iy.Provider, {
22345
+ }, By = s(null);
22346
+ function Vy({ children: e }) {
22347
+ let t = zy();
22348
+ return /* @__PURE__ */ C(By.Provider, {
22066
22349
  value: t,
22067
22350
  children: e
22068
22351
  });
22069
22352
  }
22070
- var oy = () => {
22071
- let e = p(iy);
22353
+ var Hy = () => {
22354
+ let e = p(By);
22072
22355
  if (!e) throw Error("useValueMatching must be used within ValueMatchingProvider");
22073
22356
  return e;
22074
- }, sy = ({ section: e }) => {
22075
- let { t } = K(), { isShowMatched: n, isCollapsed: r, setShowMatched: i, toggleCollapsed: a } = oy(), o = r(e.columnId), s = t(o ? "dataEditor.common.expand" : "dataEditor.common.collapse"), c = f((t) => i(e.columnId, t), [i, e.columnId]), l = f(() => a(e.columnId), [a, e.columnId]);
22357
+ }, Uy = ({ section: e }) => {
22358
+ let { t } = K(), { isShowMatched: n, isCollapsed: r, setShowMatched: i, toggleCollapsed: a } = Hy(), o = r(e.columnId), s = t(o ? "dataEditor.common.expand" : "dataEditor.common.collapse"), c = f((t) => i(e.columnId, t), [i, e.columnId]), l = f(() => a(e.columnId), [a, e.columnId]);
22076
22359
  return /* @__PURE__ */ w("header", {
22077
22360
  className: "updog__value-matching__section-header",
22078
22361
  children: [/* @__PURE__ */ C("div", {
@@ -22116,14 +22399,14 @@ var oy = () => {
22116
22399
  })
22117
22400
  })]
22118
22401
  });
22119
- }, cy = {
22402
+ }, Wy = {
22120
22403
  ",": ",",
22121
22404
  ";": ";",
22122
22405
  "|": "|",
22123
22406
  "\n": "\\n",
22124
22407
  " ": "\\t"
22125
- }, ly = (e) => e === null ? "" : cy[e] ?? e, uy = ({ section: e }) => {
22126
- let { t } = K(), { changeDelimiter: n, reapplyDelimiter: r } = oy(), i = y(e.delimiter), a = ly(e.delimiter), [o, s] = b(a), { debouncedValue: c } = za(o, 300), l = y(a);
22408
+ }, Gy = (e) => e === null ? "" : Wy[e] ?? e, Ky = ({ section: e }) => {
22409
+ let { t } = K(), { changeDelimiter: n, reapplyDelimiter: r } = Hy(), i = y(e.delimiter), a = Gy(e.delimiter), [o, s] = b(a), { debouncedValue: c } = za(o, 300), l = y(a);
22127
22410
  m(() => {
22128
22411
  s(a), l.current = a;
22129
22412
  }, [a]), m(() => {
@@ -22166,8 +22449,8 @@ var oy = () => {
22166
22449
  })
22167
22450
  ]
22168
22451
  });
22169
- }, dy = ({ section: e, val: t }) => {
22170
- let { t: n } = K(), { getSelectOptions: r, selectValue: i } = oy(), a = t.mapped === void 0, o = f((n) => i(e.columnId, t.imported, n), [
22452
+ }, qy = ({ section: e, val: t }) => {
22453
+ let { t: n } = K(), { getSelectOptions: r, selectValue: i } = Hy(), a = t.mapped === void 0, o = f((n) => i(e.columnId, t.imported, n), [
22171
22454
  i,
22172
22455
  e.columnId,
22173
22456
  t.imported
@@ -22219,8 +22502,8 @@ var oy = () => {
22219
22502
  })
22220
22503
  ]
22221
22504
  });
22222
- }, fy = ({ section: e }) => {
22223
- let { t } = K(), { getVisibleValues: n } = oy(), r = n(e);
22505
+ }, Jy = ({ section: e }) => {
22506
+ let { t } = K(), { getVisibleValues: n } = Hy(), r = n(e);
22224
22507
  return /* @__PURE__ */ w("div", {
22225
22508
  className: "updog__value-matching__table",
22226
22509
  children: [r.length === 0 ? /* @__PURE__ */ C("div", {
@@ -22240,7 +22523,7 @@ var oy = () => {
22240
22523
  size: "sm",
22241
22524
  weight: "medium",
22242
22525
  children: t("dataEditor.uploader.matchValues.importedValues")
22243
- }), e.isMultiselect && /* @__PURE__ */ C(uy, { section: e })]
22526
+ }), e.isMultiselect && /* @__PURE__ */ C(Ky, { section: e })]
22244
22527
  }),
22245
22528
  /* @__PURE__ */ C("div", { className: "updog__value-matching__arrow-spacer" }),
22246
22529
  /* @__PURE__ */ C(q, {
@@ -22252,25 +22535,25 @@ var oy = () => {
22252
22535
  }),
22253
22536
  /* @__PURE__ */ C("div", { className: "updog__value-matching__action" })
22254
22537
  ]
22255
- }), r.map((t) => /* @__PURE__ */ C(dy, {
22538
+ }), r.map((t) => /* @__PURE__ */ C(qy, {
22256
22539
  section: e,
22257
22540
  val: t
22258
22541
  }, t.imported))]
22259
22542
  });
22260
- }, py = ({ section: e }) => {
22261
- let { isCollapsed: t } = oy(), n = !t(e.columnId);
22543
+ }, Yy = ({ section: e }) => {
22544
+ let { isCollapsed: t } = Hy(), n = !t(e.columnId);
22262
22545
  return /* @__PURE__ */ w("div", {
22263
22546
  className: "updog__value-matching__section",
22264
- children: [/* @__PURE__ */ C(sy, { section: e }), /* @__PURE__ */ C("div", {
22547
+ children: [/* @__PURE__ */ C(Uy, { section: e }), /* @__PURE__ */ C("div", {
22265
22548
  className: E("updog__value-matching__collapsible", n && "updog__value-matching__collapsible--expanded"),
22266
- children: /* @__PURE__ */ C(fy, { section: e })
22549
+ children: /* @__PURE__ */ C(Jy, { section: e })
22267
22550
  })]
22268
22551
  });
22269
- }, my = () => {
22270
- let { sections: e, hasCreateTarget: t, createForOptions: n, createInitialName: r, submitCreate: i, closeCreate: a } = oy();
22552
+ }, Xy = () => {
22553
+ let { sections: e, hasCreateTarget: t, createForOptions: n, createInitialName: r, submitCreate: i, closeCreate: a } = Hy();
22271
22554
  return /* @__PURE__ */ w("div", {
22272
22555
  className: "updog__value-matching",
22273
- children: [e.map((e) => /* @__PURE__ */ C(py, { section: e }, e.columnId)), t && /* @__PURE__ */ C(Qv, {
22556
+ children: [e.map((e) => /* @__PURE__ */ C(Yy, { section: e }, e.columnId)), t && /* @__PURE__ */ C(Sy, {
22274
22557
  open: !0,
22275
22558
  existingOptions: n,
22276
22559
  initialName: r,
@@ -22278,22 +22561,26 @@ var oy = () => {
22278
22561
  onSubmit: i
22279
22562
  })]
22280
22563
  });
22281
- }, hy = () => /* @__PURE__ */ C(Xl, { children: /* @__PURE__ */ w(Jl, { children: [/* @__PURE__ */ C("div", {
22564
+ }, Zy = () => /* @__PURE__ */ C(Xl, { children: /* @__PURE__ */ w(Jl, { children: [/* @__PURE__ */ C("div", {
22282
22565
  className: "updog__step-match-values__content updog__scrollbar",
22283
- children: /* @__PURE__ */ C(ay, { children: /* @__PURE__ */ C(my, {}) })
22284
- }), /* @__PURE__ */ C(bv, {})] }) }), gy = 20, _y = () => {
22285
- let { store: e } = X(), { t } = K(), { primaryKey: n, onPrimaryKeyChange: r, parsedCsv: i, columnMapping: a, primaryKeyColumns: o } = hb(), s = e.isClient(), c = f(() => r(null), [r]), l = v(() => {
22566
+ children: /* @__PURE__ */ C(Vy, { children: /* @__PURE__ */ C(Xy, {}) })
22567
+ }), /* @__PURE__ */ C(bv, {})] }) }), Qy = 20, $y = () => {
22568
+ let { store: e } = X(), { t } = K(), { primaryKey: n, onPrimaryKeyChange: r, parsedCsv: i, headers: a, dataStartIndex: o, columnMapping: s, primaryKeyColumns: c } = Bb(), l = e.isClient(), u = f(() => r(null), [r]), d = v(() => {
22286
22569
  let e = {};
22287
- for (let [t, n] of Object.entries(a)) n && (e[n] = t);
22570
+ for (let [t, n] of Object.entries(s)) n && (e[n] = t);
22288
22571
  return e;
22289
- }, [a]), u = i?.rows.slice(0, gy) ?? [];
22572
+ }, [s]), p = v(() => i ? Ry(i.rawRows, a, o, Qy) : [], [
22573
+ i,
22574
+ a,
22575
+ o
22576
+ ]);
22290
22577
  return /* @__PURE__ */ w("div", {
22291
22578
  className: "updog__primary-key-selection updog__scrollbar",
22292
- children: [s && /* @__PURE__ */ w(Ra, {
22579
+ children: [l && /* @__PURE__ */ w(Ra, {
22293
22580
  name: "primaryKey",
22294
22581
  value: "",
22295
22582
  checked: n === null,
22296
- onChange: c,
22583
+ onChange: u,
22297
22584
  radioPosition: "end",
22298
22585
  className: E("updog__primary-key-selection__card", n === null && "updog__primary-key-selection__card--selected"),
22299
22586
  children: [/* @__PURE__ */ C(q, {
@@ -22306,8 +22593,8 @@ var oy = () => {
22306
22593
  className: "updog__primary-key-selection__value-text updog__primary-key-selection__value-none",
22307
22594
  children: t("dataEditor.uploader.primaryKey.noneHint")
22308
22595
  })]
22309
- }), o.map((e) => {
22310
- let t = l[e.id], i = t ? u.map((e) => e[t] ?? "") : [];
22596
+ }), c.map((e) => {
22597
+ let t = d[e.id], i = t ? p.map((e) => e[t] ?? "") : [];
22311
22598
  return /* @__PURE__ */ w(Ra, {
22312
22599
  name: "primaryKey",
22313
22600
  value: e.id,
@@ -22334,8 +22621,8 @@ var oy = () => {
22334
22621
  }, e.id);
22335
22622
  })]
22336
22623
  });
22337
- }, vy = () => /* @__PURE__ */ C(Xl, { children: /* @__PURE__ */ w(Jl, { children: [/* @__PURE__ */ C(_y, {}), /* @__PURE__ */ C(bv, {})] }) }), yy = () => {
22338
- let { columns: e, importFormats: t, remoteSources: n, sampleData: r } = X(), i = t === !1 ? [] : t, { t: a } = K(), { parsedCsv: o, xlsxFile: s, handleFileRemoved: c, parseFile: l, isParsing: u, remoteSourceLoading: d, remoteSourceError: p, handleRemoteSourceSelect: m } = hb(), h = [
22624
+ }, eb = () => /* @__PURE__ */ C(Xl, { children: /* @__PURE__ */ w(Jl, { children: [/* @__PURE__ */ C($y, {}), /* @__PURE__ */ C(bv, {})] }) }), tb = () => {
22625
+ let { columns: e, importFormats: t, remoteSources: n, sampleData: r } = X(), i = t === !1 ? [] : t, { t: a } = K(), { parsedCsv: o, xlsxFile: s, handleFileRemoved: c, parseFile: l, isParsing: u, remoteSourceLoading: d, remoteSourceError: p, handleRemoteSourceSelect: m } = Bb(), h = [
22339
22626
  {
22340
22627
  id: "csv",
22341
22628
  format: "csv",
@@ -22393,20 +22680,20 @@ var oy = () => {
22393
22680
  }, [c]),
22394
22681
  handleRemoteSourceSelect: m
22395
22682
  };
22396
- }, by = s(null);
22397
- function xy({ children: e }) {
22398
- let t = yy();
22399
- return /* @__PURE__ */ C(by.Provider, {
22683
+ }, nb = s(null);
22684
+ function rb({ children: e }) {
22685
+ let t = tb();
22686
+ return /* @__PURE__ */ C(nb.Provider, {
22400
22687
  value: t,
22401
22688
  children: e
22402
22689
  });
22403
22690
  }
22404
- var Sy = () => {
22405
- let e = p(by);
22691
+ var ib = () => {
22692
+ let e = p(nb);
22406
22693
  if (!e) throw Error("useSelectFiles must be used within SelectFilesProvider");
22407
22694
  return e;
22408
- }, Cy = () => {
22409
- let { t: e } = K(), { exampleMenuOptions: t, onExampleDownload: n } = Sy();
22695
+ }, ab = () => {
22696
+ let { t: e } = K(), { exampleMenuOptions: t, onExampleDownload: n } = ib();
22410
22697
  return /* @__PURE__ */ C(Fa, {
22411
22698
  options: t,
22412
22699
  onSelect: n,
@@ -22418,7 +22705,7 @@ var Sy = () => {
22418
22705
  children: e("dataEditor.uploader.uploadFile.downloadExample")
22419
22706
  })
22420
22707
  });
22421
- }, wy = ({ source: e }) => e.icon.trimStart().startsWith("<") ? /* @__PURE__ */ C("span", {
22708
+ }, ob = ({ source: e }) => e.icon.trimStart().startsWith("<") ? /* @__PURE__ */ C("span", {
22422
22709
  className: "updog__remote-source-btn__icon",
22423
22710
  dangerouslySetInnerHTML: { __html: e.icon }
22424
22711
  }) : /* @__PURE__ */ C("span", {
@@ -22427,7 +22714,7 @@ var Sy = () => {
22427
22714
  src: e.icon,
22428
22715
  alt: e.label
22429
22716
  })
22430
- }), Ty = ({ source: e, loading: t, disabled: n, onSelect: r }) => /* @__PURE__ */ C(J, {
22717
+ }), sb = ({ source: e, loading: t, disabled: n, onSelect: r }) => /* @__PURE__ */ C(J, {
22431
22718
  variant: "filled",
22432
22719
  color: "neutral",
22433
22720
  size: "sm",
@@ -22437,11 +22724,11 @@ var Sy = () => {
22437
22724
  disabled: !t && n,
22438
22725
  loading: t,
22439
22726
  spinnerPosition: "start",
22440
- startIcon: /* @__PURE__ */ C(wy, { source: e }),
22727
+ startIcon: /* @__PURE__ */ C(ob, { source: e }),
22441
22728
  title: e.description,
22442
22729
  children: e.label
22443
- }), Ey = () => {
22444
- let { t: e } = K(), { importFormats: t, remoteSources: n, remoteSourceLoading: r, remoteSourceError: i, handleRemoteSourceSelect: a } = Sy(), o = n.length > 0;
22730
+ }), cb = () => {
22731
+ let { t: e } = K(), { importFormats: t, remoteSources: n, remoteSourceLoading: r, remoteSourceError: i, handleRemoteSourceSelect: a } = ib(), o = n.length > 0;
22445
22732
  return /* @__PURE__ */ w("div", {
22446
22733
  className: "updog__source-picker",
22447
22734
  children: [
@@ -22468,7 +22755,7 @@ var Sy = () => {
22468
22755
  }),
22469
22756
  o && /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(Oa, {}), /* @__PURE__ */ C("div", {
22470
22757
  className: "updog__source-picker__sources-list",
22471
- children: n.map((e) => /* @__PURE__ */ C(Ty, {
22758
+ children: n.map((e) => /* @__PURE__ */ C(sb, {
22472
22759
  source: e,
22473
22760
  loading: r === e.id,
22474
22761
  disabled: !!r,
@@ -22482,7 +22769,7 @@ var Sy = () => {
22482
22769
  })
22483
22770
  ]
22484
22771
  });
22485
- }, Dy = () => {
22772
+ }, lb = () => {
22486
22773
  let { t: e } = K();
22487
22774
  return /* @__PURE__ */ w("div", {
22488
22775
  className: "updog__uploading-state",
@@ -22495,12 +22782,12 @@ var Sy = () => {
22495
22782
  children: e("dataEditor.uploader.uploadFile.uploading")
22496
22783
  })]
22497
22784
  });
22498
- }, Oy = () => {
22499
- let { t: e } = K(), { isBlocked: t, isParsing: n, hasFile: r, fileName: i, open: a, onRemoveClick: o } = Sy();
22785
+ }, ub = () => {
22786
+ let { t: e } = K(), { isBlocked: t, isParsing: n, hasFile: r, fileName: i, open: a, onRemoveClick: o } = ib();
22500
22787
  return /* @__PURE__ */ C("div", {
22501
22788
  className: E("updog__step-select-files__upload-area", t && "updog__step-select-files__upload-area--disabled"),
22502
22789
  onClick: t ? void 0 : a,
22503
- children: n ? /* @__PURE__ */ C(Dy, {}) : /* @__PURE__ */ w(S, { children: [
22790
+ children: n ? /* @__PURE__ */ C(lb, {}) : /* @__PURE__ */ w(S, { children: [
22504
22791
  /* @__PURE__ */ C("div", {
22505
22792
  className: "updog__step-select-files__icon-container",
22506
22793
  children: r ? /* @__PURE__ */ C(I, {
@@ -22511,7 +22798,7 @@ var Sy = () => {
22511
22798
  className: "updog__step-select-files__icon"
22512
22799
  })
22513
22800
  }),
22514
- !r && /* @__PURE__ */ C(Ey, {}),
22801
+ !r && /* @__PURE__ */ C(cb, {}),
22515
22802
  r && /* @__PURE__ */ w("div", {
22516
22803
  className: "updog__step-select-files__info",
22517
22804
  children: [/* @__PURE__ */ C(q, {
@@ -22528,21 +22815,21 @@ var Sy = () => {
22528
22815
  })
22529
22816
  ] })
22530
22817
  });
22531
- }, ky = () => {
22532
- let { getRootProps: e, getInputProps: t, isDragActive: n } = Sy();
22818
+ }, db = () => {
22819
+ let { getRootProps: e, getInputProps: t, isDragActive: n } = ib();
22533
22820
  return /* @__PURE__ */ C(Xl, { children: /* @__PURE__ */ w("div", {
22534
22821
  className: "updog__step-select-files__dropzone",
22535
22822
  ...e(),
22536
22823
  children: [
22537
22824
  /* @__PURE__ */ C("input", { ...t() }),
22538
- /* @__PURE__ */ w(Jl, { children: [/* @__PURE__ */ C(Oy, {}), /* @__PURE__ */ C(bv, { leftSlot: /* @__PURE__ */ C(Cy, {}) })] }),
22825
+ /* @__PURE__ */ w(Jl, { children: [/* @__PURE__ */ C(ub, {}), /* @__PURE__ */ C(bv, { leftSlot: /* @__PURE__ */ C(ab, {}) })] }),
22539
22826
  n && /* @__PURE__ */ C(Yl, {})
22540
22827
  ]
22541
22828
  }) });
22542
- }, Ay = () => /* @__PURE__ */ C(xy, { children: /* @__PURE__ */ C(ky, {}) }), jy = ({ preview: e }) => {
22543
- let { selectedSheet: t, setSelectedSheet: n } = hb(), { t: r } = K(), i = Math.max(0, e.totalRows), a = t === e.name, o = v(() => {
22829
+ }, fb = () => /* @__PURE__ */ C(rb, { children: /* @__PURE__ */ C(db, {}) }), pb = ({ preview: e }) => {
22830
+ let { selectedSheet: t, setSelectedSheet: n } = Bb(), { t: r } = K(), i = Math.max(0, e.totalRows), a = t === e.name, o = v(() => {
22544
22831
  let { headers: t, rows: n } = e;
22545
- return n.map((e) => t.map((t) => e[t] ?? ""));
22832
+ return [t, ...n.map((e) => t.map((t) => e[t] ?? ""))];
22546
22833
  }, [e]);
22547
22834
  return /* @__PURE__ */ C(Ra, {
22548
22835
  name: "sheetSelection",
@@ -22570,23 +22857,22 @@ var Sy = () => {
22570
22857
  className: "updog__sheet-preview-emptyText",
22571
22858
  children: r("dataEditor.uploader.sheetSelection.emptySheet")
22572
22859
  }) : /* @__PURE__ */ C(gf, {
22573
- headers: e.headers,
22574
22860
  rows: o,
22575
22861
  scrollbars: !1
22576
22862
  })
22577
22863
  })]
22578
22864
  })
22579
22865
  });
22580
- }, My = () => {
22581
- let { sheetPreviews: e } = hb();
22866
+ }, mb = () => {
22867
+ let { sheetPreviews: e } = Bb();
22582
22868
  return /* @__PURE__ */ C(Xl, { children: /* @__PURE__ */ w(Jl, { children: [/* @__PURE__ */ C("div", {
22583
22869
  className: "updog__sheet-preview-wrapper updog__scrollbar",
22584
22870
  children: /* @__PURE__ */ C("div", {
22585
22871
  className: "updog__sheet-preview-grid",
22586
- children: e.map((e) => /* @__PURE__ */ C(jy, { preview: e }, e.name))
22872
+ children: e.map((e) => /* @__PURE__ */ C(pb, { preview: e }, e.name))
22587
22873
  })
22588
22874
  }), /* @__PURE__ */ C(bv, {})] }) });
22589
- }, Ny = (e, t, n) => {
22875
+ }, hb = (e, t, n) => {
22590
22876
  let r = new Map(t.map((e) => [e.id, e])), i = [];
22591
22877
  for (let [t, a] of Object.entries(e)) a && i.push({
22592
22878
  csvHeader: t,
@@ -22594,11 +22880,11 @@ var Sy = () => {
22594
22880
  column: n.has(a) ? void 0 : r.get(a)
22595
22881
  });
22596
22882
  return i;
22597
- }, Py = (e) => {
22883
+ }, gb = (e) => {
22598
22884
  let t = [];
22599
22885
  for (let { csvHeader: n, column: r } of e) r?.editor?.type === "number" && t.push(n);
22600
22886
  return t;
22601
- }, Fy = (e, t, n) => {
22887
+ }, _b = (e, t, n) => {
22602
22888
  let r = {};
22603
22889
  for (let { csvHeader: i, columnId: a, column: o } of t) {
22604
22890
  let t = e[i] ?? "";
@@ -22613,7 +22899,7 @@ var Sy = () => {
22613
22899
  continue;
22614
22900
  }
22615
22901
  if (s === "multiselect") {
22616
- let e = n.multiselectDelimiters[a], i = o.editor.options ?? [], s = e ? ey(t, e, i) : t === "" ? [] : [t], c = [], l = /* @__PURE__ */ new Set();
22902
+ let e = n.multiselectDelimiters[a], i = o.editor.options ?? [], s = e ? wy(t, e, i) : t === "" ? [] : [t], c = [], l = /* @__PURE__ */ new Set();
22617
22903
  for (let e of s) {
22618
22904
  let t = n.valueMapping[a]?.[e.trim()];
22619
22905
  t !== void 0 && !l.has(t) && (l.add(t), c.push(t));
@@ -22625,88 +22911,16 @@ var Sy = () => {
22625
22911
  r[a] = o.transformer ? o.transformer(c) : c;
22626
22912
  }
22627
22913
  return r;
22628
- }, Iy = /^-?\d+([.,]\d+)?%?$/, Ly = /^\d{1,4}[-/.]\d{1,2}[-/.]\d{1,4}$/, Ry = new Set([
22629
- "true",
22630
- "false",
22631
- "yes",
22632
- "no"
22633
- ]), zy = 50;
22634
- function By(e) {
22635
- return !!(Iy.test(e) || Ly.test(e) || Ry.has(e.toLowerCase()));
22636
- }
22637
- function Vy(e) {
22638
- return e.filter((e) => e != null && String(e).trim().length > 0).length;
22639
- }
22640
- function Hy(e) {
22641
- let t = /* @__PURE__ */ new Map(), n = 0, r = 0;
22642
- for (let i of e) {
22643
- let e = Vy(i);
22644
- if (e === 0) continue;
22645
- let a = (t.get(e) ?? 0) + 1;
22646
- t.set(e, a), a > n && (n = a, r = e);
22647
- }
22648
- return r;
22649
- }
22650
- function Uy(e, t) {
22651
- let n = e.map((e) => String(e ?? "").trim()), r = n.filter((e) => e.length > 0);
22652
- if (r.length === 0) return 0;
22653
- let i = r.filter((e) => By(e)).length === 0 ? 1 : 0, a = r.length / Math.max(n.length, 1), o = new Set(r.map((e) => e.toLowerCase())).size / r.length, s = r.filter((e) => e.length <= zy).length / r.length, c = t > 0 ? 1 - Math.abs(r.length - t) / t : 0;
22654
- return .3 * i + .25 * a + .2 * o + .15 * s + .1 * Math.max(0, c);
22655
- }
22656
- function Wy(e, t = 100) {
22657
- if (e.length === 0) return {
22658
- headerRowIndex: 0,
22659
- confidence: 0
22660
- };
22661
- if (e.length === 1) return {
22662
- headerRowIndex: 0,
22663
- confidence: 1
22664
- };
22665
- let n = Math.min(t, e.length), r = Hy(e.slice(0, n)), i = 0, a = -1;
22666
- for (let t = 0; t < n; t++) {
22667
- let n = Uy(e[t], r);
22668
- if (n > a && (a = n, i = t), t === 0 && n > .85 && Vy(e[0]) === r) break;
22669
- }
22670
- return {
22671
- headerRowIndex: i,
22672
- confidence: Math.round(a * 100) / 100
22673
- };
22674
- }
22675
- function Gy(e) {
22676
- let t = /* @__PURE__ */ new Set();
22677
- return e.map((e) => {
22678
- let n = e, r = 2;
22679
- for (; t.has(n);) n = `${e} (${r})`, r++;
22680
- return t.add(n), n;
22681
- });
22682
- }
22683
- function Ky(e) {
22684
- let { headerRowIndex: t } = Wy(e), n = Gy((e[t] ?? []).map((e) => String(e ?? "").trim())), r = [], i = [];
22685
- for (let a of e.slice(t + 1)) {
22686
- if (!a.some((e) => e != null && String(e).trim() !== "")) continue;
22687
- let e = {};
22688
- for (let t = 0; t < n.length; t++) e[n[t]] = String(a[t] ?? "");
22689
- r.push(e), i.push(a.length === n.length ? null : a.map((e) => String(e ?? "")));
22690
- }
22691
- return {
22692
- headerRowIndex: t,
22693
- headers: n,
22694
- rows: r,
22695
- rawCells: i
22696
- };
22697
- }
22698
- //#endregion
22699
- //#region src/components/DataUploader/utils/detectMultiValueDelimiter.ts
22700
- var qy = 200, Jy = (e, t, n) => {
22914
+ }, vb = 200, yb = (e, t, n) => {
22701
22915
  if (n) return n;
22702
22916
  let r = new Set(t.map((e) => e.trim().toLowerCase())), i = (e) => r.has(e.trim().toLowerCase()), a = /* @__PURE__ */ new Set(), o = [];
22703
22917
  for (let t of e) {
22704
22918
  let e = t.trim();
22705
- if (!(e === "" || a.has(e)) && (a.add(e), o.push(e), o.length >= qy)) break;
22919
+ if (!(e === "" || a.has(e)) && (a.add(e), o.push(e), o.length >= vb)) break;
22706
22920
  }
22707
22921
  if (o.length === 0) return null;
22708
22922
  let s = null, c = 0, l = 0;
22709
- for (let e of $v) {
22923
+ for (let e of Cy) {
22710
22924
  let n = 0, r = 0;
22711
22925
  for (let a of o) {
22712
22926
  if (i(a) || !a.includes(e)) continue;
@@ -22719,7 +22933,7 @@ var qy = 200, Jy = (e, t, n) => {
22719
22933
  (n > c || n === c && n > 0 && r > l) && (s = e, c = n, l = r);
22720
22934
  }
22721
22935
  return c > 0 ? s : null;
22722
- }, Yy = (e) => {
22936
+ }, bb = (e) => {
22723
22937
  let t = /* @__PURE__ */ new Map();
22724
22938
  for (let [n, r] of Object.entries(e)) {
22725
22939
  let e = wv(n), i = t.get(e) ?? /* @__PURE__ */ new Set();
@@ -22727,8 +22941,8 @@ var qy = 200, Jy = (e, t, n) => {
22727
22941
  t.set(e, i);
22728
22942
  }
22729
22943
  return t;
22730
- }, Xy = (e, t, n, r) => {
22731
- let i = Yy(r), a = (e, t) => i.get(wv(e))?.has(wv(t)) ?? !1, o = new Map(n.map((e) => [e.id, e])), s = (e, t) => (n, r) => {
22944
+ }, xb = (e, t, n, r) => {
22945
+ let i = bb(r), a = (e, t) => i.get(wv(e))?.has(wv(t)) ?? !1, o = new Map(n.map((e) => [e.id, e])), s = (e, t) => (n, r) => {
22732
22946
  if (wv(n) === wv(r) || a(r, n)) return;
22733
22947
  let i = `${n} ${r}`;
22734
22948
  t.has(i) || (t.add(i), e.push({
@@ -22748,16 +22962,16 @@ var qy = 200, Jy = (e, t, n) => {
22748
22962
  for (let e of Object.values(t)) for (let [t, n] of Object.entries(e)) n && u(t, n);
22749
22963
  return c;
22750
22964
  };
22751
- function Zy(e, t, n) {
22965
+ function Sb(e, t, n) {
22752
22966
  let r = e.length, i = t;
22753
- return i <= 0 ? [] : r === i ? [{ cells: [...e] }] : (r < i ? Qy(i, i - r) : Qy(r - 1, i - 1)) > 1e3 ? [] : r < i ? $y(e, i) : eb(e, i, n);
22967
+ return i <= 0 ? [] : r === i ? [{ cells: [...e] }] : (r < i ? Cb(i, i - r) : Cb(r - 1, i - 1)) > 1e3 ? [] : r < i ? wb(e, i) : Tb(e, i, n);
22754
22968
  }
22755
- function Qy(e, t) {
22969
+ function Cb(e, t) {
22756
22970
  let n = Math.min(t, e - t), r = 1;
22757
22971
  for (let t = 1; t <= n; t++) if (r = r * (e - n + t) / t, r > 1e3) return r;
22758
22972
  return r;
22759
22973
  }
22760
- function $y(e, t) {
22974
+ function wb(e, t) {
22761
22975
  let n = e.length, r = [], i = [], a = (o) => {
22762
22976
  if (i.length === n) {
22763
22977
  let a = Array(t).fill("");
@@ -22769,7 +22983,7 @@ function $y(e, t) {
22769
22983
  };
22770
22984
  return a(0), r;
22771
22985
  }
22772
- function eb(e, t, n) {
22986
+ function Tb(e, t, n) {
22773
22987
  let r = e.length, i = [], a = [], o = (s) => {
22774
22988
  if (a.length === t - 1) {
22775
22989
  let o = [
@@ -22787,27 +23001,27 @@ function eb(e, t, n) {
22787
23001
  }
22788
23002
  //#endregion
22789
23003
  //#region src/components/DataUploader/utils/raggedRows/pruneByValidators.ts
22790
- var tb = {};
22791
- function nb(e, t) {
23004
+ var Eb = {};
23005
+ function Db(e, t) {
22792
23006
  for (let n of t.validators ?? []) if (n.type !== "expression") {
22793
23007
  if (n.type === "function") {
22794
- if (n.fn(e, tb) != null) return !1;
23008
+ if (n.fn(e, Eb) != null) return !1;
22795
23009
  continue;
22796
23010
  }
22797
- if (Al(n, e, tb) != null) return !1;
23011
+ if (Al(n, e, Eb) != null) return !1;
22798
23012
  }
22799
23013
  return !0;
22800
23014
  }
22801
- function rb(e, t) {
22802
- for (let n = 0; n < t.length; n++) if (!nb(e.cells[n] ?? "", t[n])) return !1;
23015
+ function Ob(e, t) {
23016
+ for (let n = 0; n < t.length; n++) if (!Db(e.cells[n] ?? "", t[n])) return !1;
22803
23017
  return !0;
22804
23018
  }
22805
- function ib(e, t) {
22806
- return e.filter((e) => rb(e, t));
23019
+ function kb(e, t) {
23020
+ return e.filter((e) => Ob(e, t));
22807
23021
  }
22808
23022
  //#endregion
22809
23023
  //#region src/components/DataUploader/utils/raggedRows/computeDisputeSpans.ts
22810
- function ab(e) {
23024
+ function Ab(e) {
22811
23025
  if (e.length <= 1) return [];
22812
23026
  let t = e[0].cells.length, n = [], r = -1;
22813
23027
  for (let i = 0; i < t; i++) {
@@ -22824,25 +23038,25 @@ function ab(e) {
22824
23038
  }
22825
23039
  //#endregion
22826
23040
  //#region src/components/DataUploader/utils/raggedRows/alignRow.ts
22827
- function ob(e, t, n) {
22828
- let r = Zy(e, t.length, n), i = ib(r, t);
23041
+ function jb(e, t, n) {
23042
+ let r = Sb(e, t.length, n), i = kb(r, t);
22829
23043
  return i.length === 1 ? {
22830
23044
  kind: "confident",
22831
23045
  alignment: i[0]
22832
23046
  } : i.length > 1 ? {
22833
23047
  kind: "ambiguous",
22834
23048
  candidates: i,
22835
- disputeSpans: ab(i)
23049
+ disputeSpans: Ab(i)
22836
23050
  } : {
22837
23051
  kind: "invalid",
22838
23052
  candidates: r,
22839
- disputeSpans: ab(r)
23053
+ disputeSpans: Ab(r)
22840
23054
  };
22841
23055
  }
22842
23056
  //#endregion
22843
23057
  //#region src/components/DataUploader/utils/raggedRows/resolveRaggedRow.ts
22844
- function sb(e, t, n) {
22845
- let r = ob(e, t, n);
23058
+ function Mb(e, t, n) {
23059
+ let r = jb(e, t, n);
22846
23060
  if (r.kind === "confident") return {
22847
23061
  cells: r.alignment.cells,
22848
23062
  conflictColumns: []
@@ -22861,111 +23075,131 @@ function sb(e, t, n) {
22861
23075
  }
22862
23076
  //#endregion
22863
23077
  //#region src/components/DataUploader/context/useViewModel.tsx
22864
- var cb = 5e3, lb = 15, ub = 20, db = new Set([
23078
+ var Nb = 5e3, Pb = 15, Fb = 20, Ib = new Set([
22865
23079
  "xlsx",
22866
23080
  "xls",
22867
23081
  "xlsb",
22868
23082
  "ods"
22869
23083
  ]);
22870
- function fb() {
23084
+ function Lb() {
22871
23085
  let { store: e, validator: t, columns: n, primaryKey: r, setShowUploader: i, pendingImportFile: a, setPendingImportFile: o, onColumnMatch: s, onValueMatch: c, synonyms: l, addDynamicColumns: u, scaleClient: d } = X(), { t: p } = K(), [h, g] = b(0), [_, x] = b(0), [S, w] = b(null), [T, E] = b({}), D = v(() => {
22872
23086
  let e = new Set(Object.values(T).filter(Boolean));
22873
23087
  return n.filter((t) => t.unique && e.has(t.id));
22874
- }, [T, n]), [O, k] = b(() => r), [A, j] = b(!1), [M, N] = b(!1), [P, F] = b(null), [I, L] = b([]), [R, z] = b(null), [B, V] = b([]), [ee, te] = b({}), [H, ne] = b([]), [re, ie] = b({}), ae = y(null), [oe, se] = b(0), ce = f((e) => {
23088
+ }, [T, n]), [O, k] = b(() => r), [A, j] = b(!1), [M, N] = b(!1), [P, F] = b(null), [I, L] = b([]), [R, z] = b(null), [B, V] = b([]), [ee, te] = b({}), [H, ne] = b([]), [re, ie] = b({}), ae = y(null), [oe, se] = b(-1), ce = f((e, t) => t ? p("dataEditor.uploader.matchColumns.syntheticColumnValue", {
23089
+ index: e + 1,
23090
+ value: t
23091
+ }) : p("dataEditor.uploader.matchColumns.syntheticColumn", { index: e + 1 }), [p]), le = v(() => S ? jy(S.detection, oe) : 0, [S, oe]), ue = v(() => S ? My(S.rawRows, oe, le, ce) : [], [
23092
+ S,
23093
+ oe,
23094
+ le,
23095
+ ce
23096
+ ]), de = f((e) => {
22875
23097
  M || k(e);
22876
- }, [M]), le = y(null);
22877
- le.current ||= new $l();
22878
- let ue = le.current;
22879
- m(() => () => ue.dispose(), [ue]);
22880
- let de = v(() => {
23098
+ }, [M]), fe = y(null);
23099
+ fe.current ||= new $l();
23100
+ let pe = fe.current;
23101
+ m(() => () => pe.dispose(), [pe]);
23102
+ let me = v(() => {
22881
23103
  let e = new Set(Object.values(T).filter(Boolean));
22882
23104
  return n.some((t) => t.editor?.type === "select" && e.has(t.id));
22883
- }, [T, n]), [fe] = b(() => e.getLocalRowCount() > 0), pe = v(() => {
23105
+ }, [T, n]), [he] = b(() => e.getLocalRowCount() > 0), ge = v(() => {
22884
23106
  let e = [{
22885
23107
  id: "select-files",
22886
23108
  title: p("dataEditor.uploader.steps.selectFiles"),
22887
- content: /* @__PURE__ */ C(Ay, {})
23109
+ content: /* @__PURE__ */ C(fb, {})
22888
23110
  }];
22889
23111
  return I.length > 1 && e.push({
22890
23112
  id: "sheet-selection",
22891
23113
  title: p("dataEditor.uploader.steps.sheetSelection"),
22892
- content: /* @__PURE__ */ C(My, {})
23114
+ content: /* @__PURE__ */ C(mb, {})
23115
+ }), S && S.detection.review.kind !== "none" && e.push({
23116
+ id: "header-selection",
23117
+ title: p("dataEditor.uploader.steps.headerSelection"),
23118
+ content: /* @__PURE__ */ C(xy, {})
22893
23119
  }), e.push({
22894
23120
  id: "column-matching",
22895
23121
  title: p("dataEditor.uploader.steps.matchColumns"),
22896
23122
  content: /* @__PURE__ */ C(Zv, {})
22897
- }), de && e.push({
23123
+ }), me && e.push({
22898
23124
  id: "match-values",
22899
23125
  title: p("dataEditor.uploader.steps.matchValues"),
22900
- content: /* @__PURE__ */ C(hy, {})
22901
- }), D.length > 0 && fe && e.push({
23126
+ content: /* @__PURE__ */ C(Zy, {})
23127
+ }), D.length > 0 && he && e.push({
22902
23128
  id: "primary-key",
22903
23129
  title: p("dataEditor.uploader.steps.primaryKey"),
22904
- content: /* @__PURE__ */ C(vy, {})
23130
+ content: /* @__PURE__ */ C(eb, {})
22905
23131
  }), e;
22906
23132
  }, [
22907
23133
  D.length,
22908
23134
  I.length,
22909
- de,
22910
- fe,
23135
+ me,
23136
+ he,
23137
+ S,
22911
23138
  p
22912
- ]), me = f((e) => {
22913
- e >= 0 && e < pe.length && g(e);
22914
- }, [pe.length]), he = f(() => {
23139
+ ]), _e = f((e) => {
23140
+ e >= 0 && e < ge.length && g(e);
23141
+ }, [ge.length]), ve = f(() => {
22915
23142
  g((e) => {
22916
- let t = Math.min(e + 1, pe.length - 1);
23143
+ let t = Math.min(e + 1, ge.length - 1);
22917
23144
  return x((e) => Math.max(e, t)), t;
22918
23145
  });
22919
- }, [pe.length]), ge = f(() => {
23146
+ }, [ge.length]), ye = f(() => {
22920
23147
  g((e) => Math.max(e - 1, 0));
22921
- }, []), _e = h === 0, ve = h === pe.length - 1, ye = f((e) => {
22922
- w(e), j(!1), Bv(e.headers, n, s, l).then(E);
23148
+ }, []), be = h === 0, xe = h === ge.length - 1, Se = f((e) => {
23149
+ w(e), j(!1);
23150
+ }, []), Ce = y(0);
23151
+ m(() => {
23152
+ if (!S || ue.length === 0) return;
23153
+ let e = ++Ce.current;
23154
+ Bv(ue, n, s, l).then((t) => {
23155
+ Ce.current === e && E(t);
23156
+ });
22923
23157
  }, [
23158
+ S,
23159
+ ue,
22924
23160
  n,
22925
23161
  s,
22926
23162
  l
22927
- ]), be = f(() => {
22928
- ue.cancel(), w(null), j(!1), E({}), ne([]), ie({}), ae.current = null, se(0), F(null), L([]), z(null), V([]);
22929
- }, [ue]), xe = f((e, t, n) => {
23163
+ ]);
23164
+ let we = f(() => {
23165
+ pe.cancel(), w(null), j(!1), E({}), ne([]), ie({}), ae.current = null, se(-1), F(null), L([]), z(null), V([]);
23166
+ }, [pe]), Te = f((e, t, n) => {
22930
23167
  F(e), L(t), z(t[0]), V(n), j(!1);
22931
- }, []), Se = f(() => {
22932
- !P || !R || (j(!0), ue.parse(P, {
23168
+ }, []), Ee = f(() => {
23169
+ !P || !R || (j(!0), pe.parse(P, {
22933
23170
  format: "xlsx",
22934
23171
  sheetName: R
22935
23172
  }).then((e) => {
22936
23173
  if (e.kind !== "rows") return;
22937
- let t = Ky(e.rows);
22938
- se(t.headerRowIndex), ye({
23174
+ let t = my(e.rows);
23175
+ se(t.headerRowIndex), Se({
22939
23176
  fileName: P.name,
22940
- headers: t.headers,
22941
- rows: t.rows,
22942
- isParsing: !1,
22943
- rawCells: t.rawCells,
23177
+ rawRows: e.rows,
23178
+ detection: t,
22944
23179
  delimiter: ","
22945
- }), he();
23180
+ }), ve();
22946
23181
  }).catch(() => {
22947
23182
  j(!1);
22948
23183
  }));
22949
23184
  }, [
22950
23185
  P,
22951
23186
  R,
22952
- ue,
22953
- ye,
22954
- he
22955
- ]), Ce = f(async (t) => {
23187
+ pe,
23188
+ Se,
23189
+ ve,
23190
+ ce
23191
+ ]), De = f(async (t) => {
22956
23192
  try {
22957
- let e = await ue.parse(t, { format: "csv" });
23193
+ let e = await pe.parse(t, { format: "csv" });
22958
23194
  if (e.kind !== "rows") {
22959
23195
  j(!1);
22960
23196
  return;
22961
23197
  }
22962
- let n = Ky(e.rows);
22963
- if (se(n.headerRowIndex), ye({
23198
+ let n = my(e.rows);
23199
+ if (se(n.headerRowIndex), Se({
22964
23200
  fileName: t.name,
22965
- headers: n.headers,
22966
- rows: n.rows,
22967
- isParsing: !1,
22968
- rawCells: n.rawCells,
23201
+ rawRows: e.rows,
23202
+ detection: n,
22969
23203
  delimiter: e.delimiter
22970
23204
  }), e.errors.length > 0) {
22971
23205
  let t = e.errors.slice(0, 3).map((e) => e.row == null ? "?" : String(e.row + 1)).join(", ");
@@ -22983,20 +23217,20 @@ function fb() {
22983
23217
  });
22984
23218
  }
22985
23219
  }, [
22986
- ue,
22987
- ye,
23220
+ pe,
23221
+ Se,
22988
23222
  j,
22989
23223
  e,
22990
- p
22991
- ]), we = f(async (t) => {
23224
+ p,
23225
+ ce
23226
+ ]), Oe = f(async (t) => {
22992
23227
  try {
22993
- let e = await ue.parse(t, { format: "json" });
23228
+ let e = await pe.parse(t, { format: "json" });
22994
23229
  if (e.kind !== "records") return;
22995
- ye({
23230
+ se(0), Se({
22996
23231
  fileName: t.name,
22997
- headers: e.headers,
22998
- rows: e.rows,
22999
- isParsing: !1
23232
+ rawRows: Py(e.headers, e.rows),
23233
+ detection: Ny()
23000
23234
  });
23001
23235
  } catch (t) {
23002
23236
  j(!1), e.errorHandler.handleError({
@@ -23007,19 +23241,18 @@ function fb() {
23007
23241
  });
23008
23242
  }
23009
23243
  }, [
23010
- ue,
23011
- ye,
23244
+ pe,
23245
+ Se,
23012
23246
  j,
23013
23247
  e
23014
- ]), Te = f(async (t) => {
23248
+ ]), ke = f(async (t) => {
23015
23249
  try {
23016
- let e = await ue.parse(t, { format: "xml" });
23250
+ let e = await pe.parse(t, { format: "xml" });
23017
23251
  if (e.kind !== "records") return;
23018
- ye({
23252
+ se(0), Se({
23019
23253
  fileName: t.name,
23020
- headers: e.headers,
23021
- rows: e.rows,
23022
- isParsing: !1
23254
+ rawRows: Py(e.headers, e.rows),
23255
+ detection: Ny()
23023
23256
  });
23024
23257
  } catch (t) {
23025
23258
  j(!1), e.errorHandler.handleError({
@@ -23030,33 +23263,31 @@ function fb() {
23030
23263
  });
23031
23264
  }
23032
23265
  }, [
23033
- ue,
23034
- ye,
23266
+ pe,
23267
+ Se,
23035
23268
  j,
23036
23269
  e
23037
- ]), Ee = f((t) => {
23038
- ue.parse(t, { format: "xlsx" }).then((e) => {
23270
+ ]), Ae = f((t) => {
23271
+ pe.parse(t, { format: "xlsx" }).then((e) => {
23039
23272
  if (e.kind === "sheets") {
23040
23273
  let n = e.sheets.map((e) => {
23041
- let { headers: t, rows: n } = Ky(e.rows);
23274
+ let t = my(e.rows), n = jy(t, t.headerRowIndex), r = My(e.rows, t.headerRowIndex, n, ce);
23042
23275
  return {
23043
23276
  name: e.name,
23044
- headers: t,
23045
- rows: n.slice(0, lb),
23277
+ headers: r,
23278
+ rows: Ry(e.rows, r, n, Pb),
23046
23279
  totalRows: e.totalRows - 1
23047
23280
  };
23048
23281
  });
23049
- xe(t, e.sheets.map((e) => e.name), n);
23282
+ Te(t, e.sheets.map((e) => e.name), n);
23050
23283
  return;
23051
23284
  }
23052
23285
  if (e.kind !== "rows") return;
23053
- let n = Ky(e.rows);
23054
- se(n.headerRowIndex), ye({
23286
+ let n = my(e.rows);
23287
+ se(n.headerRowIndex), Se({
23055
23288
  fileName: t.name,
23056
- headers: n.headers,
23057
- rows: n.rows,
23058
- isParsing: !1,
23059
- rawCells: n.rawCells,
23289
+ rawRows: e.rows,
23290
+ detection: n,
23060
23291
  delimiter: ","
23061
23292
  });
23062
23293
  }).catch((t) => {
@@ -23068,39 +23299,40 @@ function fb() {
23068
23299
  }), j(!1);
23069
23300
  });
23070
23301
  }, [
23071
- ue,
23072
- ye,
23073
- xe,
23302
+ pe,
23303
+ Se,
23304
+ Te,
23074
23305
  j,
23075
- e
23076
- ]), De = f((e) => {
23306
+ e,
23307
+ ce
23308
+ ]), je = f((e) => {
23077
23309
  j(!0), ae.current = e;
23078
23310
  let t = e.name.split(".").pop()?.toLowerCase();
23079
- t && db.has(t) ? Ee(e) : t === "json" ? we(e) : t === "xml" ? Te(e) : Ce(e);
23311
+ t && Ib.has(t) ? Ae(e) : t === "json" ? Oe(e) : t === "xml" ? ke(e) : De(e);
23080
23312
  }, [
23081
- Ce,
23082
- we,
23083
- Ee,
23084
- Te,
23313
+ De,
23314
+ Oe,
23315
+ Ae,
23316
+ ke,
23085
23317
  j
23086
23318
  ]);
23087
23319
  m(() => {
23088
- a && (De(a), o(null));
23320
+ a && (je(a), o(null));
23089
23321
  }, [
23090
23322
  a,
23091
23323
  o,
23092
- De
23324
+ je
23093
23325
  ]);
23094
- let [Oe, ke] = b(null), [Ae, je] = b(null), Me = f(() => {
23095
- je(null);
23096
- }, []), Ne = f(async (e) => {
23097
- ke(e.id), je(null);
23326
+ let [Me, Ne] = b(null), [Pe, Fe] = b(null), Ie = f(() => {
23327
+ Fe(null);
23328
+ }, []), Le = f(async (e) => {
23329
+ Ne(e.id), Fe(null);
23098
23330
  try {
23099
23331
  let t = await e.fetch();
23100
- if (t instanceof File) De(t);
23332
+ if (t instanceof File) je(t);
23101
23333
  else if (Array.isArray(t)) {
23102
23334
  if (t.length === 0) {
23103
- je(p("dataEditor.uploader.remoteSources.emptyData"));
23335
+ Fe(p("dataEditor.uploader.remoteSources.emptyData"));
23104
23336
  return;
23105
23337
  }
23106
23338
  let n = Object.keys(t[0]), r = t.map((e) => {
@@ -23111,23 +23343,22 @@ function fb() {
23111
23343
  }
23112
23344
  return t;
23113
23345
  });
23114
- ye({
23346
+ se(0), Se({
23115
23347
  fileName: e.label,
23116
- headers: n,
23117
- rows: r,
23118
- isParsing: !1
23348
+ rawRows: Py(n, r),
23349
+ detection: Ny()
23119
23350
  });
23120
23351
  }
23121
23352
  } catch (e) {
23122
- je(e instanceof Error ? e.message : String(e));
23353
+ Fe(e instanceof Error ? e.message : String(e));
23123
23354
  } finally {
23124
- ke(null);
23355
+ Ne(null);
23125
23356
  }
23126
23357
  }, [
23127
- De,
23128
- ye,
23358
+ je,
23359
+ Se,
23129
23360
  p
23130
- ]), Pe = f((e, t) => {
23361
+ ]), Re = f((e, t) => {
23131
23362
  E((n) => {
23132
23363
  let r = {
23133
23364
  ...n,
@@ -23136,52 +23367,50 @@ function fb() {
23136
23367
  if (t) for (let n in r) n !== e && r[n] === t && (r[n] = void 0);
23137
23368
  return r;
23138
23369
  });
23139
- }, []), [Fe, Ie] = b({}), [Le, Re] = b({}), ze = y(0);
23370
+ }, []), [ze, Be] = b({}), [Ve, He] = b({}), Ue = y(0);
23140
23371
  m(() => {
23141
23372
  if (!S) {
23142
- Ie({}), Re({});
23373
+ Be({}), He({});
23143
23374
  return;
23144
23375
  }
23145
23376
  if (M) return;
23146
- let e = {}, t = {};
23147
- for (let [r, i] of Object.entries(T)) {
23148
- if (!i) continue;
23149
- let a = n.find((e) => e.id === i);
23150
- if (!a?.editor) continue;
23151
- let o = a.editor.type;
23152
- if (o !== "select" && o !== "multiselect") continue;
23153
- let s = a.editor.options, c = [];
23154
- for (let e of S.rows) {
23155
- let t = e[r];
23156
- t === void 0 || t === "" || c.push(t);
23157
- }
23158
- if (o === "multiselect") {
23159
- let n = a.editor.delimiter, r = Jy(c, s, n);
23160
- t[i] = r;
23161
- let o = new Set(s.map((e) => e.trim().toLowerCase())), l = /* @__PURE__ */ new Set();
23162
- for (let e of c) {
23163
- let t = o.has(e.trim().toLowerCase()), n = r && !t ? e.split(r) : [e];
23377
+ let e = {}, t = {}, r = Fy(ue);
23378
+ for (let [i, a] of Object.entries(T)) {
23379
+ if (!a) continue;
23380
+ let o = n.find((e) => e.id === a);
23381
+ if (!o?.editor) continue;
23382
+ let s = o.editor.type;
23383
+ if (s !== "select" && s !== "multiselect") continue;
23384
+ let c = o.editor.options, l = r.get(i);
23385
+ if (l === void 0) continue;
23386
+ let u = Iy(S.rawRows, le, l);
23387
+ if (s === "multiselect") {
23388
+ let n = o.editor.delimiter, r = yb(u, c, n);
23389
+ t[a] = r;
23390
+ let i = new Set(c.map((e) => e.trim().toLowerCase())), s = /* @__PURE__ */ new Set();
23391
+ for (let e of u) {
23392
+ let t = i.has(e.trim().toLowerCase()), n = r && !t ? e.split(r) : [e];
23164
23393
  for (let e of n) {
23165
23394
  let t = e.trim();
23166
- t !== "" && l.add(t);
23395
+ t !== "" && s.add(t);
23167
23396
  }
23168
23397
  }
23169
- e[i] = {
23170
- importedValues: Array.from(l),
23171
- options: s
23398
+ e[a] = {
23399
+ importedValues: Array.from(s),
23400
+ options: c
23172
23401
  };
23173
- } else e[i] = {
23174
- importedValues: Array.from(new Set(c)),
23175
- options: s
23402
+ } else e[a] = {
23403
+ importedValues: Array.from(new Set(u)),
23404
+ options: c
23176
23405
  };
23177
23406
  }
23178
- if (Re(t), Object.keys(e).length === 0) {
23179
- Ie({});
23407
+ if (He(t), Object.keys(e).length === 0) {
23408
+ Be({});
23180
23409
  return;
23181
23410
  }
23182
- let r = ++ze.current;
23411
+ let i = ++Ue.current;
23183
23412
  Iv(e, c, l).then((e) => {
23184
- ze.current === r && Ie(e);
23413
+ Ue.current === i && Be(e);
23185
23414
  });
23186
23415
  }, [
23187
23416
  S,
@@ -23189,16 +23418,18 @@ function fb() {
23189
23418
  n,
23190
23419
  c,
23191
23420
  l,
23192
- M
23421
+ M,
23422
+ ue,
23423
+ le
23193
23424
  ]);
23194
- let Be = v(() => {
23425
+ let We = v(() => {
23195
23426
  let e = {};
23196
- for (let [t, n] of Object.entries(Fe)) e[t] = {
23427
+ for (let [t, n] of Object.entries(ze)) e[t] = {
23197
23428
  ...n,
23198
23429
  ...ee[t]
23199
23430
  };
23200
23431
  return e;
23201
- }, [Fe, ee]), Ve = f((e, t, n) => {
23432
+ }, [ze, ee]), Ge = f((e, t, n) => {
23202
23433
  te((r) => ({
23203
23434
  ...r,
23204
23435
  [e]: {
@@ -23206,30 +23437,29 @@ function fb() {
23206
23437
  [t]: n
23207
23438
  }
23208
23439
  }));
23209
- }, []), He = f((e, t) => {
23210
- Re((n) => ({
23440
+ }, []), Ke = f((e, t) => {
23441
+ He((n) => ({
23211
23442
  ...n,
23212
23443
  [e]: t
23213
23444
  }));
23214
- }, []), Ue = f((e) => {
23445
+ }, []), qe = f((e) => {
23215
23446
  if (!S) return;
23216
23447
  let t = Object.keys(T).find((t) => T[t] === e);
23217
23448
  if (!t) return;
23218
23449
  let r = n.find((t) => t.id === e);
23219
23450
  if (r?.editor?.type !== "multiselect") return;
23220
- let i = [];
23221
- for (let e of S.rows) {
23222
- let n = e[t];
23223
- n !== void 0 && n !== "" && i.push(n);
23224
- }
23225
- let a = r.editor.delimiter;
23226
- He(e, Jy(i, r.editor.options, a));
23451
+ let i = Fy(ue).get(t);
23452
+ if (i === void 0) return;
23453
+ let a = Iy(S.rawRows, le, i), o = r.editor.delimiter;
23454
+ Ke(e, yb(a, r.editor.options, o));
23227
23455
  }, [
23228
23456
  S,
23229
23457
  T,
23230
23458
  n,
23231
- He
23232
- ]), We = f((e, t) => {
23459
+ Ke,
23460
+ ue,
23461
+ le
23462
+ ]), Je = f((e, t) => {
23233
23463
  ie((n) => {
23234
23464
  let r = n[e] ?? [];
23235
23465
  return r.includes(t) ? n : {
@@ -23237,36 +23467,38 @@ function fb() {
23237
23467
  [e]: [...r, t]
23238
23468
  };
23239
23469
  });
23240
- }, []), Ge = f((e) => {
23470
+ }, []), Ye = f((e) => {
23241
23471
  let t = [];
23242
23472
  for (let [r, i] of Object.entries(T)) !i || e.has(i) || n.find((e) => e.id === i)?.editor?.type === "date" && t.push(r);
23243
23473
  return t;
23244
- }, [T, n]), Ke = f(() => {
23245
- let e = new Set(H.map((e) => e.id)), t = Ny(T, n, e), i = tc(S?.rows ?? [], Py(t)), a = Ge(e), o = oc(S?.rows ?? [], a);
23474
+ }, [T, n]), Xe = f(() => {
23475
+ let e = new Set(H.map((e) => e.id)), t = hb(T, n, e), i = S ? Ry(S.rawRows, ue, le, 1e3) : [], a = tc(i, gb(t)), o = oc(i, Ye(e));
23246
23476
  return {
23247
23477
  columnMapping: T,
23248
- valueMapping: Be,
23478
+ valueMapping: We,
23249
23479
  primaryKey: O ?? r,
23250
23480
  selectedSheet: R ?? void 0,
23251
23481
  headerRowIndex: oe,
23252
- numberFormat: i,
23482
+ numberFormat: a,
23253
23483
  dateFormat: o,
23254
23484
  newColumns: H
23255
23485
  };
23256
23486
  }, [
23257
23487
  S,
23258
23488
  T,
23259
- Be,
23489
+ We,
23260
23490
  O,
23261
23491
  R,
23262
23492
  r,
23263
23493
  oe,
23494
+ ue,
23495
+ le,
23264
23496
  H,
23265
23497
  n,
23266
- Ge
23267
- ]), qe = f(async () => {
23498
+ Ye
23499
+ ]), Ze = f(async () => {
23268
23500
  if (!ae.current || !d?.onFileImport) return;
23269
- let t = new AbortController(), n = Ke();
23501
+ let t = new AbortController(), n = Xe();
23270
23502
  await d.onFileImport({
23271
23503
  file: ae.current,
23272
23504
  mappings: n,
@@ -23275,49 +23507,59 @@ function fb() {
23275
23507
  }), e.reloadServerData();
23276
23508
  }, [
23277
23509
  d,
23278
- Ke,
23510
+ Xe,
23279
23511
  e
23280
- ]), Je = f(async () => {
23512
+ ]), Qe = f(async () => {
23281
23513
  if (!S || !d?.onRowsImport) return;
23282
23514
  let t = S;
23283
23515
  w(null);
23284
- let r = crypto.randomUUID(), i = Ke(), a = new AbortController(), o = d.importChunkSize ?? cb, s = Ny(T, n, new Set(H.map((e) => e.id))), c = {
23516
+ let r = crypto.randomUUID(), i = Xe(), a = new AbortController(), o = d.importChunkSize ?? Nb, s = hb(T, n, new Set(H.map((e) => e.id))), c = {
23285
23517
  numberFormat: i.numberFormat,
23286
23518
  dateFormat: i.dateFormat,
23287
23519
  monthTable: ic(p),
23288
- valueMapping: Be,
23289
- multiselectDelimiters: Le
23290
- }, l = t.rows, u = 0;
23291
- for (; u < l.length;) {
23292
- let e = Math.min(u + o, l.length), n = [];
23293
- for (let t = u; t < e; t++) n.push(Fy(l[t], s, c));
23294
- let f = e >= l.length, p = Math.floor(u / o);
23520
+ valueMapping: We,
23521
+ multiselectDelimiters: Ve
23522
+ }, l = ue, u = t.rawRows, f = [];
23523
+ for (let e = le; e < u.length; e++) {
23524
+ let t = u[e];
23525
+ t && !Dy(t) && f.push(e);
23526
+ }
23527
+ let m = 0;
23528
+ for (; m < f.length;) {
23529
+ let e = Math.min(m + o, f.length), n = [];
23530
+ for (let t = m; t < e; t++) {
23531
+ let e = Ly(u[f[t]] ?? [], l);
23532
+ n.push(_b(e, s, c));
23533
+ }
23534
+ let p = e >= f.length, h = Math.floor(m / o);
23295
23535
  await d.onRowsImport({
23296
23536
  importId: r,
23297
23537
  sourceName: t.fileName,
23298
- chunkIndex: p,
23299
- isLastChunk: f,
23538
+ chunkIndex: h,
23539
+ isLastChunk: p,
23300
23540
  rows: n,
23301
- newColumns: p === 0 && H.length > 0 ? H : void 0,
23541
+ newColumns: h === 0 && H.length > 0 ? H : void 0,
23302
23542
  primaryKey: i.primaryKey,
23303
23543
  signal: a.signal
23304
23544
  });
23305
- for (let t = u; t < e; t++) l[t] = null;
23306
- u = e;
23545
+ for (let t = m; t < e; t++) u[f[t]] = void 0;
23546
+ m = e;
23307
23547
  }
23308
23548
  e.reloadServerData();
23309
23549
  }, [
23310
23550
  S,
23311
23551
  d,
23312
- Ke,
23552
+ Xe,
23313
23553
  T,
23314
23554
  H,
23315
23555
  n,
23316
- Be,
23317
- Le,
23556
+ ue,
23557
+ le,
23558
+ We,
23559
+ Ve,
23318
23560
  e,
23319
23561
  p
23320
- ]), Ye = f(() => new Promise((r) => {
23562
+ ]), $e = f(() => new Promise((r) => {
23321
23563
  if (!S) {
23322
23564
  r();
23323
23565
  return;
@@ -23328,47 +23570,52 @@ function fb() {
23328
23570
  H.length > 0 && u(H);
23329
23571
  for (let [t, n] of Object.entries(re)) e.addColumnOptions(t, n);
23330
23572
  let o = e.registerSource({ name: i.fileName });
23331
- e.setSourceLoading(o, !0), e.recordLearnedSynonyms(Xy(T, Be, [...n, ...H], Sv(xv, l)));
23332
- let s = Ny(T, n, a), c = {
23333
- numberFormat: tc(i.rows, Py(s)),
23334
- dateFormat: oc(i.rows, Ge(a)),
23573
+ e.setSourceLoading(o, !0), e.recordLearnedSynonyms(xb(T, We, [...n, ...H], Sv(xv, l)));
23574
+ let s = ue, c = i.delimiter ?? ",", d = i.rawRows, f = [];
23575
+ for (let e = le; e < d.length; e++) {
23576
+ let t = d[e];
23577
+ t && !Dy(t) && f.push(e);
23578
+ }
23579
+ let m = Ry(i.rawRows, s, le, 1e3), h = hb(T, n, a), g = {
23580
+ numberFormat: tc(m, gb(h)),
23581
+ dateFormat: oc(m, Ye(a)),
23335
23582
  monthTable: ic(p),
23336
- valueMapping: Be,
23337
- multiselectDelimiters: Le
23338
- }, d = i.rows, f = i.rawCells ?? [], m = i.delimiter ?? ",", h = i.headers, g = h.map((e) => {
23583
+ valueMapping: We,
23584
+ multiselectDelimiters: Ve
23585
+ }, _ = s.map((e) => {
23339
23586
  let t = T[e];
23340
23587
  return (t ? n.find((e) => e.id === t) : void 0) ?? {
23341
23588
  id: e,
23342
23589
  title: e
23343
23590
  };
23344
- }), _ = 0, v = () => {
23345
- let n = Math.min(_ + cb, d.length), i = [], a = [];
23346
- for (let e = _; e < n; e++) {
23347
- let t = d[e], n = f[e];
23348
- if (n) {
23349
- let { cells: r, conflictColumns: i } = sb(n, g, m);
23591
+ }), v = 0, y = () => {
23592
+ let n = Math.min(v + Nb, f.length), i = [], a = [];
23593
+ for (let e = v; e < n; e++) {
23594
+ let t = d[f[e]] ?? [], n = Ly(t, s);
23595
+ if (t.length !== s.length) {
23596
+ let { cells: r, conflictColumns: i } = Mb(t.map((e) => String(e ?? "")), _, c);
23350
23597
  if (r.length) {
23351
23598
  let e = {};
23352
- for (let t = 0; t < h.length; t++) e[h[t]] = r[t] ?? "";
23353
- t = e;
23599
+ for (let t = 0; t < s.length; t++) e[s[t]] = r[t] ?? "";
23600
+ n = e;
23354
23601
  }
23355
23602
  if (i.length) {
23356
23603
  let t = [];
23357
23604
  for (let e of i) {
23358
- let n = T[h[e]];
23605
+ let n = T[s[e]];
23359
23606
  n && t.push(n);
23360
23607
  }
23361
23608
  t.length && a.push({
23362
- localIndex: e - _,
23609
+ localIndex: e - v,
23363
23610
  columnIds: t
23364
23611
  });
23365
23612
  }
23366
23613
  }
23367
- i.push(Fy(t, s, c));
23614
+ i.push(_b(n, h, g));
23368
23615
  }
23369
23616
  let { rows: l, rowIds: u } = e.upsertRows(o, i, { anchorKey: O ?? void 0 });
23370
- for (let e = _; e < n; e++) e < ub || (d[e] = null, e < f.length && (f[e] = null));
23371
- _ = n, setTimeout(() => {
23617
+ for (let e = v; e < n; e++) e < Fb || (d[f[e]] = void 0);
23618
+ v = n, setTimeout(() => {
23372
23619
  t.validateRows(l, u);
23373
23620
  for (let { localIndex: t, columnIds: n } of a) {
23374
23621
  let r = u[t];
@@ -23381,11 +23628,11 @@ function fb() {
23381
23628
  }
23382
23629
  }
23383
23630
  a.length > 0 && e.notify();
23384
- }, 0), _ < d.length ? setTimeout(v, 0) : e.finalizeSource(o).then(() => {
23631
+ }, 0), v < f.length ? setTimeout(y, 0) : e.finalizeSource(o).then(() => {
23385
23632
  t.validateUniqueness(), r();
23386
23633
  });
23387
23634
  };
23388
- v();
23635
+ y();
23389
23636
  }, 0);
23390
23637
  }), [
23391
23638
  S,
@@ -23397,43 +23644,45 @@ function fb() {
23397
23644
  t,
23398
23645
  n,
23399
23646
  u,
23400
- Be,
23401
- Le,
23647
+ We,
23648
+ Ve,
23402
23649
  l,
23403
- Ge,
23650
+ Ye,
23651
+ ue,
23652
+ le,
23404
23653
  p
23405
23654
  ]);
23406
23655
  return {
23407
- steps: pe,
23656
+ steps: ge,
23408
23657
  activeStepIndex: h,
23409
23658
  currentStepIndex: _,
23410
- isFirstStep: _e,
23411
- isLastStep: ve,
23412
- goToStep: me,
23413
- nextStep: he,
23414
- prevStep: ge,
23659
+ isFirstStep: be,
23660
+ isLastStep: xe,
23661
+ goToStep: _e,
23662
+ nextStep: ve,
23663
+ prevStep: ye,
23415
23664
  parsedCsv: S,
23416
23665
  columnMapping: T,
23417
- handleFileParsed: ye,
23418
- handleFileRemoved: be,
23419
- updateColumnMapping: Pe,
23420
- valueMapping: Be,
23421
- autoValueMapping: Fe,
23422
- updateValueMapping: Ve,
23423
- multiselectDelimiters: Le,
23424
- setMultiselectDelimiter: He,
23425
- reapplyMultiselectDelimiter: Ue,
23666
+ handleFileParsed: Se,
23667
+ handleFileRemoved: we,
23668
+ updateColumnMapping: Re,
23669
+ valueMapping: We,
23670
+ autoValueMapping: ze,
23671
+ updateValueMapping: Ge,
23672
+ multiselectDelimiters: Ve,
23673
+ setMultiselectDelimiter: Ke,
23674
+ reapplyMultiselectDelimiter: qe,
23426
23675
  pendingOptions: re,
23427
- addPendingOption: We,
23676
+ addPendingOption: Je,
23428
23677
  xlsxFile: P,
23429
23678
  sheetNames: I,
23430
23679
  selectedSheet: R,
23431
23680
  setSelectedSheet: z,
23432
- handleSheetConfirmed: Se,
23433
- handleXlsxMultiSheet: xe,
23681
+ handleSheetConfirmed: Ee,
23682
+ handleXlsxMultiSheet: Te,
23434
23683
  sheetPreviews: B,
23435
23684
  primaryKey: O,
23436
- onPrimaryKeyChange: ce,
23685
+ onPrimaryKeyChange: de,
23437
23686
  primaryKeyColumns: D,
23438
23687
  pendingColumns: H,
23439
23688
  setPendingColumns: ne,
@@ -23445,7 +23694,7 @@ function fb() {
23445
23694
  N(!0);
23446
23695
  try {
23447
23696
  await Yo(e, "importing", Infinity, async () => {
23448
- d?.onFileImport ? await qe() : d?.onRowsImport ? await Je() : await Ye();
23697
+ d?.onFileImport ? await Ze() : d?.onRowsImport ? await Qe() : await $e();
23449
23698
  });
23450
23699
  } finally {
23451
23700
  w(null), N(!1), i(!1);
@@ -23455,34 +23704,38 @@ function fb() {
23455
23704
  S,
23456
23705
  e,
23457
23706
  d,
23458
- qe,
23459
- Je,
23460
- Ye,
23707
+ Ze,
23708
+ Qe,
23709
+ $e,
23461
23710
  i
23462
23711
  ]),
23463
- parseFile: De,
23464
- remoteSourceLoading: Oe,
23465
- remoteSourceError: Ae,
23466
- clearRemoteSourceError: Me,
23467
- handleRemoteSourceSelect: Ne
23712
+ parseFile: je,
23713
+ remoteSourceLoading: Me,
23714
+ remoteSourceError: Pe,
23715
+ clearRemoteSourceError: Ie,
23716
+ handleRemoteSourceSelect: Le,
23717
+ headerRowIndex: oe,
23718
+ setHeaderRowIndex: se,
23719
+ headers: ue,
23720
+ dataStartIndex: le
23468
23721
  };
23469
23722
  }
23470
23723
  //#endregion
23471
23724
  //#region src/components/DataUploader/context/index.tsx
23472
- var pb = s(null);
23473
- function mb({ children: e }) {
23474
- let t = fb();
23475
- return /* @__PURE__ */ C(pb.Provider, {
23725
+ var Rb = s(null);
23726
+ function zb({ children: e }) {
23727
+ let t = Lb();
23728
+ return /* @__PURE__ */ C(Rb.Provider, {
23476
23729
  value: t,
23477
23730
  children: e
23478
23731
  });
23479
23732
  }
23480
- var hb = () => {
23481
- let e = p(pb);
23733
+ var Bb = () => {
23734
+ let e = p(Rb);
23482
23735
  if (!e) throw Error("useDataUploaderContext must be used within DataUploaderProvider");
23483
23736
  return e;
23484
- }, gb = () => {
23485
- let { steps: e, activeStepIndex: t, currentStepIndex: n, goToStep: r } = hb();
23737
+ }, Vb = () => {
23738
+ let { steps: e, activeStepIndex: t, currentStepIndex: n, goToStep: r } = Bb();
23486
23739
  return /* @__PURE__ */ C(co, {
23487
23740
  steps: e,
23488
23741
  activeStepIndex: t,
@@ -23490,79 +23743,79 @@ var hb = () => {
23490
23743
  onStepChange: r,
23491
23744
  isProgressive: !0
23492
23745
  });
23493
- }, _b = () => /* @__PURE__ */ C(mb, { children: /* @__PURE__ */ C(gb, {}) }), vb = {
23746
+ }, Hb = () => /* @__PURE__ */ C(zb, { children: /* @__PURE__ */ C(Vb, {}) }), Ub = {
23494
23747
  kty: "EC",
23495
23748
  crv: "P-256",
23496
23749
  x: "wZO1Jxr21FEBDsVMzbTbF8blU2CP17c_eQY7gorO13U",
23497
23750
  y: "Nwr-tXatJZ3DxZqpUG_gOWzmpU6szTqrEL7Gnh5UGwo"
23498
- }, yb = "updog_license_grant", bb = new Set([
23751
+ }, Wb = "updog_license_grant", Gb = new Set([
23499
23752
  "updog.tech",
23500
23753
  "landing.updog.tech",
23501
23754
  "demo.updog.tech"
23502
23755
  ]);
23503
- function xb() {
23504
- return bb.has(window.location.hostname);
23756
+ function Kb() {
23757
+ return Gb.has(window.location.hostname);
23505
23758
  }
23506
- function Sb() {
23759
+ function qb() {
23507
23760
  return !1;
23508
23761
  }
23509
- function Cb() {
23762
+ function Jb() {
23510
23763
  return "https://api.updog.tech";
23511
23764
  }
23512
- function wb(e) {
23765
+ function Yb(e) {
23513
23766
  let t = e.replace(/-/g, "+").replace(/_/g, "/"), n = t + "=".repeat((4 - t.length % 4) % 4), r = atob(n), i = new Uint8Array(r.length);
23514
23767
  for (let e = 0; e < r.length; e++) i[e] = r.charCodeAt(e);
23515
23768
  return i;
23516
23769
  }
23517
- async function Tb(e) {
23770
+ async function Xb(e) {
23518
23771
  let t = new TextEncoder().encode(e), n = await crypto.subtle.digest("SHA-256", t);
23519
23772
  return Array.from(new Uint8Array(n)).map((e) => e.toString(16).padStart(2, "0")).join("");
23520
23773
  }
23521
- var Eb = null;
23522
- async function Db() {
23523
- return Eb || (Eb = await crypto.subtle.importKey("jwk", vb, {
23774
+ var Zb = null;
23775
+ async function Qb() {
23776
+ return Zb || (Zb = await crypto.subtle.importKey("jwk", Ub, {
23524
23777
  name: "ECDSA",
23525
23778
  namedCurve: "P-256"
23526
- }, !1, ["verify"]), Eb);
23779
+ }, !1, ["verify"]), Zb);
23527
23780
  }
23528
- function Ob() {
23781
+ function $b() {
23529
23782
  try {
23530
- return localStorage.getItem(yb);
23783
+ return localStorage.getItem(Wb);
23531
23784
  } catch {
23532
23785
  return null;
23533
23786
  }
23534
23787
  }
23535
- function kb(e) {
23788
+ function ex(e) {
23536
23789
  try {
23537
- localStorage.setItem(yb, e);
23790
+ localStorage.setItem(Wb, e);
23538
23791
  } catch {}
23539
23792
  }
23540
- function Ab() {
23793
+ function tx() {
23541
23794
  try {
23542
- localStorage.removeItem(yb);
23795
+ localStorage.removeItem(Wb);
23543
23796
  } catch {}
23544
23797
  }
23545
- async function jb(e, t, n) {
23798
+ async function nx(e, t, n) {
23546
23799
  let r = e.indexOf(".");
23547
23800
  if (r === -1) return !1;
23548
- let i = e.slice(0, r), a = e.slice(r + 1), o = wb(i), s = wb(a), c = await Db();
23801
+ let i = e.slice(0, r), a = e.slice(r + 1), o = Yb(i), s = Yb(a), c = await Qb();
23549
23802
  if (!await crypto.subtle.verify({
23550
23803
  name: "ECDSA",
23551
23804
  hash: "SHA-256"
23552
23805
  }, c, new Uint8Array(s), new Uint8Array(o))) return !1;
23553
23806
  let l = JSON.parse(new TextDecoder().decode(o));
23554
23807
  if (l.exp <= Math.floor(Date.now() / 1e3)) return !1;
23555
- let u = await Tb(t);
23808
+ let u = await Xb(t);
23556
23809
  return !(l.key !== u || l.domain !== n);
23557
23810
  }
23558
- async function Mb(e) {
23559
- let t = Ob();
23811
+ async function rx(e) {
23812
+ let t = $b();
23560
23813
  if (!t) return {
23561
23814
  valid: !1,
23562
23815
  errorCode: "license.invalid"
23563
23816
  };
23564
23817
  try {
23565
- if (await jb(t, e, window.location.hostname.toLowerCase().trim())) return {
23818
+ if (await nx(t, e, window.location.hostname.toLowerCase().trim())) return {
23566
23819
  valid: !0,
23567
23820
  errorCode: null
23568
23821
  };
@@ -23572,23 +23825,23 @@ async function Mb(e) {
23572
23825
  errorCode: "license.invalid"
23573
23826
  };
23574
23827
  }
23575
- async function Nb(e, t = !0) {
23576
- if (xb() || Sb()) return {
23828
+ async function ix(e, t = !0) {
23829
+ if (Kb() || qb()) return {
23577
23830
  valid: !0,
23578
23831
  errorCode: null
23579
23832
  };
23580
- let n = Cb();
23833
+ let n = Jb();
23581
23834
  try {
23582
23835
  let r = await fetch(`${n}/v1/validate`, { headers: { "X-API-Key": e } });
23583
23836
  if (r.ok) {
23584
23837
  let e = await r.json();
23585
- return t && e.grant && kb(e.grant), {
23838
+ return t && e.grant && ex(e.grant), {
23586
23839
  valid: !0,
23587
23840
  errorCode: null
23588
23841
  };
23589
23842
  }
23590
23843
  if (r.status >= 400 && r.status < 500) {
23591
- t && Ab();
23844
+ t && tx();
23592
23845
  try {
23593
23846
  return await r.json();
23594
23847
  } catch {
@@ -23600,7 +23853,7 @@ async function Nb(e, t = !0) {
23600
23853
  }
23601
23854
  throw Error(`Server error: ${r.status}`);
23602
23855
  } catch {
23603
- return t ? Mb(e) : {
23856
+ return t ? rx(e) : {
23604
23857
  valid: !1,
23605
23858
  errorCode: "license.invalid"
23606
23859
  };
@@ -23608,7 +23861,7 @@ async function Nb(e, t = !0) {
23608
23861
  }
23609
23862
  //#endregion
23610
23863
  //#region src/hooks/useLicenseValidation.ts
23611
- function Pb(e, t, n = !0) {
23864
+ function ax(e, t, n = !0) {
23612
23865
  let [r, i] = b({
23613
23866
  isValidating: t,
23614
23867
  isValid: !1,
@@ -23628,7 +23881,7 @@ function Pb(e, t, n = !0) {
23628
23881
  isValidating: !0,
23629
23882
  isValid: !1,
23630
23883
  errorCode: null
23631
- }), Nb(e, n).then((e) => {
23884
+ }), ix(e, n).then((e) => {
23632
23885
  r || i({
23633
23886
  isValidating: !1,
23634
23887
  isValid: e.valid,
@@ -23651,7 +23904,7 @@ function Pb(e, t, n = !0) {
23651
23904
  }
23652
23905
  //#endregion
23653
23906
  //#region src/server/auth/AuthState.ts
23654
- var Fb = class {
23907
+ var ox = class {
23655
23908
  token = null;
23656
23909
  get() {
23657
23910
  return this.token;
@@ -23662,13 +23915,13 @@ var Fb = class {
23662
23915
  clear() {
23663
23916
  this.token = null;
23664
23917
  }
23665
- }, Ib = class extends Error {
23918
+ }, sx = class extends Error {
23666
23919
  status;
23667
23920
  code;
23668
23921
  constructor(e) {
23669
23922
  super(e.message), this.name = "ScaleHttpError", this.status = e.status, this.code = e.code;
23670
23923
  }
23671
- }, Lb = class {
23924
+ }, cx = class {
23672
23925
  baseUrl;
23673
23926
  apiKey;
23674
23927
  auth;
@@ -23698,7 +23951,7 @@ var Fb = class {
23698
23951
  signal: r?.signal
23699
23952
  });
23700
23953
  } catch (e) {
23701
- this.notify(new Ib({
23954
+ this.notify(new sx({
23702
23955
  status: 0,
23703
23956
  code: "network",
23704
23957
  message: e instanceof Error ? e.message : String(e)
@@ -23709,7 +23962,7 @@ var Fb = class {
23709
23962
  try {
23710
23963
  e = await s.json();
23711
23964
  } catch {}
23712
- this.notify(new Ib({
23965
+ this.notify(new sx({
23713
23966
  status: s.status,
23714
23967
  code: e.error ?? `http_${s.status}`,
23715
23968
  message: e.message ?? s.statusText
@@ -23720,23 +23973,23 @@ var Fb = class {
23720
23973
  };
23721
23974
  //#endregion
23722
23975
  //#region src/server/endpoints/workspaces.ts
23723
- async function Rb(e, t) {
23976
+ async function lx(e, t) {
23724
23977
  return e.post("/workspaces", {
23725
23978
  primaryKey: t.primaryKey,
23726
23979
  columns: t.columns
23727
23980
  }, { signal: t.signal });
23728
23981
  }
23729
- async function zb(e) {
23982
+ async function ux(e) {
23730
23983
  try {
23731
23984
  await e.http.delete(`/workspaces/${e.workspaceId}`, { signal: e.signal });
23732
23985
  } catch (e) {
23733
- if (e instanceof Ib && e.status === 404) return;
23986
+ if (e instanceof sx && e.status === 404) return;
23734
23987
  throw e;
23735
23988
  }
23736
23989
  }
23737
23990
  //#endregion
23738
23991
  //#region src/server/endpoints/query.ts
23739
- async function Bb(e, t) {
23992
+ async function dx(e, t) {
23740
23993
  let n = await e.http.post(`/workspaces/${e.workspaceId}/query`, {
23741
23994
  page: {
23742
23995
  limit: t.limit,
@@ -23754,12 +24007,12 @@ async function Bb(e, t) {
23754
24007
  }
23755
24008
  //#endregion
23756
24009
  //#region src/server/ScaleClient.ts
23757
- var Vb = class {
24010
+ var fx = class {
23758
24011
  disposed = !1;
23759
24012
  constructor(e) {
23760
24013
  this.deps = e;
23761
24014
  }
23762
- onQuery = (e) => Bb(this.deps, e);
24015
+ onQuery = (e) => dx(this.deps, e);
23763
24016
  onEdit = async (e) => ({
23764
24017
  rejected: !0,
23765
24018
  reason: "Edits are not yet supported in server mode (v0)."
@@ -23776,7 +24029,7 @@ var Vb = class {
23776
24029
  pageSize = void 0;
23777
24030
  scrollSensitivity = void 0;
23778
24031
  dispose = async () => {
23779
- this.disposed || (this.disposed = !0, await zb({
24032
+ this.disposed || (this.disposed = !0, await ux({
23780
24033
  http: this.deps.http,
23781
24034
  workspaceId: this.deps.workspaceId
23782
24035
  }));
@@ -23784,25 +24037,25 @@ var Vb = class {
23784
24037
  };
23785
24038
  //#endregion
23786
24039
  //#region src/server/createScaleClient.ts
23787
- async function Hb(e) {
23788
- let t = new Fb(), n = new Lb({
24040
+ async function px(e) {
24041
+ let t = new ox(), n = new cx({
23789
24042
  baseUrl: e.url,
23790
24043
  apiKey: e.apiKey,
23791
24044
  auth: t,
23792
24045
  onDegraded: e.onDegraded
23793
- }), { workspaceId: r, accessToken: i } = await Rb(n, {
24046
+ }), { workspaceId: r, accessToken: i } = await lx(n, {
23794
24047
  primaryKey: e.primaryKey,
23795
24048
  columns: e.columns,
23796
24049
  signal: e.signal
23797
24050
  });
23798
- return t.set(i), new Vb({
24051
+ return t.set(i), new fx({
23799
24052
  workspaceId: r,
23800
24053
  http: n
23801
24054
  });
23802
24055
  }
23803
24056
  //#endregion
23804
24057
  //#region src/server/errors.ts
23805
- function Ub(e, t, n) {
24058
+ function mx(e, t, n) {
23806
24059
  return {
23807
24060
  code: e,
23808
24061
  message: t,
@@ -23812,7 +24065,7 @@ function Ub(e, t, n) {
23812
24065
  }
23813
24066
  //#endregion
23814
24067
  //#region src/hooks/useScaleClient.ts
23815
- function Wb(e) {
24068
+ function hx(e) {
23816
24069
  let [t, n] = b({ status: "idle" }), r = y(e.columns), i = y(e.primaryKey);
23817
24070
  return m(() => {
23818
24071
  if (!e.enabled) {
@@ -23821,7 +24074,7 @@ function Wb(e) {
23821
24074
  }
23822
24075
  n({ status: "bootstrapping" });
23823
24076
  let t = new AbortController(), a = null;
23824
- return Hb({
24077
+ return px({
23825
24078
  url: e.url,
23826
24079
  apiKey: e.apiKey,
23827
24080
  primaryKey: i.current,
@@ -23830,7 +24083,7 @@ function Wb(e) {
23830
24083
  onDegraded: (e) => {
23831
24084
  t.signal.aborted || n({
23832
24085
  status: "failed",
23833
- error: Kb(e)
24086
+ error: _x(e)
23834
24087
  });
23835
24088
  }
23836
24089
  }).then((e) => {
@@ -23845,7 +24098,7 @@ function Wb(e) {
23845
24098
  }).catch((e) => {
23846
24099
  t.signal.aborted || n({
23847
24100
  status: "failed",
23848
- error: Gb(e)
24101
+ error: gx(e)
23849
24102
  });
23850
24103
  }), () => {
23851
24104
  t.abort(), a?.dispose().catch(() => {});
@@ -23856,30 +24109,30 @@ function Wb(e) {
23856
24109
  e.apiKey
23857
24110
  ]), t;
23858
24111
  }
23859
- function Gb(e) {
23860
- return e instanceof Ib ? e.status === 401 ? Ub(e.code.startsWith("license.") ? e.code : "license.invalid", e.message, e) : e.status === 0 ? Ub("scale.unreachable", e.message, e) : e.status >= 500 ? Ub("scale.server_error", e.message, e) : Ub("scale.bootstrap_failed", e.message, e) : Ub("scale.bootstrap_failed", e instanceof Error ? e.message : String(e), e);
24112
+ function gx(e) {
24113
+ return e instanceof sx ? e.status === 401 ? mx(e.code.startsWith("license.") ? e.code : "license.invalid", e.message, e) : e.status === 0 ? mx("scale.unreachable", e.message, e) : e.status >= 500 ? mx("scale.server_error", e.message, e) : mx("scale.bootstrap_failed", e.message, e) : mx("scale.bootstrap_failed", e instanceof Error ? e.message : String(e), e);
23861
24114
  }
23862
- function Kb(e) {
23863
- return e.status === 0 ? Ub("scale.unreachable", e.message, e) : e.status === 404 ? Ub("scale.workspace_lost", e.message, e) : Ub("scale.server_error", e.message, e);
24115
+ function _x(e) {
24116
+ return e.status === 0 ? mx("scale.unreachable", e.message, e) : e.status === 404 ? mx("scale.workspace_lost", e.message, e) : mx("scale.server_error", e.message, e);
23864
24117
  }
23865
24118
  //#endregion
23866
24119
  //#region src/index.tsx
23867
- function qb(e) {
24120
+ function vx(e) {
23868
24121
  return e === !1 ? { licenseGrant: !1 } : { licenseGrant: e?.licenseGrant ?? !0 };
23869
24122
  }
23870
- function Jb(e) {
24123
+ function yx(e) {
23871
24124
  let t = v(() => new Bo(e.onError), [e.onError]);
23872
24125
  return /* @__PURE__ */ C(yv, {
23873
24126
  errorHandler: t,
23874
24127
  children: /* @__PURE__ */ C(Wl, {
23875
24128
  ...e,
23876
24129
  errorHandler: t,
23877
- children: e.showUploader ? /* @__PURE__ */ C(_b, {}) : /* @__PURE__ */ C(hv, {})
24130
+ children: e.showUploader ? /* @__PURE__ */ C(Hb, {}) : /* @__PURE__ */ C(hv, {})
23878
24131
  })
23879
24132
  });
23880
24133
  }
23881
- function Yb(e) {
23882
- let t = e.mode ?? "modal", { t: n, rtl: r } = K(), i = r ? "rtl" : "ltr", a = qb(e.localStorage), o = t === "modal" ? e.open : !0, { isValidating: s, isValid: c, errorCode: l } = Pb(e.apiKey, t === "modal" ? o : !0, a.licenseGrant), u = e.__server != null, d = Wb({
24134
+ function bx(e) {
24135
+ let t = e.mode ?? "modal", { t: n, rtl: r } = K(), i = r ? "rtl" : "ltr", a = vx(e.localStorage), o = t === "modal" ? e.open : !0, { isValidating: s, isValid: c, errorCode: l } = ax(e.apiKey, t === "modal" ? o : !0, a.licenseGrant), u = e.__server != null, d = hx({
23883
24136
  enabled: !s && c && u,
23884
24137
  url: e.__server?.url ?? "",
23885
24138
  apiKey: e.apiKey,
@@ -23934,7 +24187,7 @@ function Yb(e) {
23934
24187
  code: e,
23935
24188
  message: "License validation failed",
23936
24189
  source: "license"
23937
- } }), M = () => s ? A(n("dataEditor.license.loading")) : c ? u && d.status === "bootstrapping" ? A(n("dataEditor.connecting.label")) : u && d.status === "failed" ? /* @__PURE__ */ C(_v, { error: d.error }) : /* @__PURE__ */ C(Jb, { ...k }) : j(l ?? "license.invalid");
24190
+ } }), M = () => s ? A(n("dataEditor.license.loading")) : c ? u && d.status === "bootstrapping" ? A(n("dataEditor.connecting.label")) : u && d.status === "failed" ? /* @__PURE__ */ C(_v, { error: d.error }) : /* @__PURE__ */ C(yx, { ...k }) : j(l ?? "license.invalid");
23938
24191
  return t === "inline" ? /* @__PURE__ */ C("div", {
23939
24192
  className: "updog__data-editor updog__data-editor-inline",
23940
24193
  dir: i,
@@ -23954,14 +24207,14 @@ function Yb(e) {
23954
24207
  submitText: n("dataEditor.confirmClose.action")
23955
24208
  })] });
23956
24209
  }
23957
- function Xb(e) {
24210
+ function xx(e) {
23958
24211
  let { translations: t, rtl: n = !1, locale: r = "en", className: i, ...a } = e;
23959
24212
  return /* @__PURE__ */ C(Zr, {
23960
24213
  translations: t,
23961
24214
  rtl: n,
23962
24215
  locale: r,
23963
- children: /* @__PURE__ */ C(Yb, { ...a })
24216
+ children: /* @__PURE__ */ C(bx, { ...a })
23964
24217
  });
23965
24218
  }
23966
24219
  //#endregion
23967
- export { Xb as DataEditor, ou as downloadExampleFile, su as exportDataEditor };
24220
+ export { xx as DataEditor, ou as downloadExampleFile, su as exportDataEditor };