@gemina/elements 0.12.0 → 0.13.1

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.
@@ -45,7 +45,7 @@ async function readErrorEnvelope(error) {
45
45
  }
46
46
 
47
47
  // src/version.ts
48
- var VERSION = "0.12.0";
48
+ var VERSION = "0.13.1";
49
49
 
50
50
  export {
51
51
  getResponseLike,
@@ -53,4 +53,4 @@ export {
53
53
  readErrorEnvelope,
54
54
  VERSION
55
55
  };
56
- //# sourceMappingURL=chunk-Z3OLTR2S.js.map
56
+ //# sourceMappingURL=chunk-X5TSIIUP.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/internal/response-like.ts","../src/version.ts"],"sourcesContent":["/**\n * Shared transport-error helpers for the widgets (chat + verification).\n *\n * Extracted verbatim from chat.tsx so both components read thrown SDK errors\n * the same way. Pure and dependency-free: no React, no DOM.\n */\n\n/**\n * The response-like object carried by a thrown transport error. We pull it off\n * by shape rather than `instanceof ResponseError` — robust against duplicated\n * `@gemina/sdk` copies in a bundle (class identity is not shared across\n * copies). On the fetch transport this is the raw `Response`, so `status`,\n * `headers`, and the JSON body are all reachable from here.\n */\nexport interface ResponseLike {\n status?: number;\n headers?: { get?: (name: string) => string | null };\n json?: () => Promise<unknown>;\n clone?: () => ResponseLike;\n}\n\nexport function getResponseLike(error: unknown): ResponseLike | undefined {\n if (error !== null && typeof error === 'object' && 'response' in error) {\n const response = (error as { response?: unknown }).response;\n if (response !== null && typeof response === 'object') {\n return response as ResponseLike;\n }\n }\n return undefined;\n}\n\n/** Extract an HTTP status from a thrown value, or `undefined`. */\nexport function httpStatus(error: unknown): number | undefined {\n const status = getResponseLike(error)?.status;\n return typeof status === 'number' ? status : undefined;\n}\n\n/** What the standard backend error envelope reliably carries. */\nexport interface ErrorEnvelope {\n status: number | undefined;\n /** Stable backend `errors[0].error_code`. */\n errorCode: string | undefined;\n /** Human-readable server fallback (`errors[0].description`). */\n description: string | undefined;\n}\n\n/**\n * Read what the backend actually sent on an error. Only the HTTP status and\n * the stable `errors[0].error_code` / `description` are reliable across\n * environments — production strips `errors[0].detail`, so we never touch it.\n * The fetch body can be read once, so we clone defensively; if that fails\n * (non-JSON, empty, or already consumed) the status still stands.\n */\nexport async function readErrorEnvelope(error: unknown): Promise<ErrorEnvelope> {\n const response = getResponseLike(error);\n const info: ErrorEnvelope = {\n status: typeof response?.status === 'number' ? response.status : undefined,\n errorCode: undefined,\n description: undefined,\n };\n if (response === undefined) {\n return info;\n }\n\n let body: unknown;\n try {\n const source = typeof response.clone === 'function' ? response.clone() : response;\n body = typeof source.json === 'function' ? await source.json() : undefined;\n } catch {\n body = undefined;\n }\n if (body !== null && typeof body === 'object') {\n const errors = (body as { errors?: unknown }).errors;\n if (\n Array.isArray(errors) &&\n errors.length > 0 &&\n errors[0] !== null &&\n typeof errors[0] === 'object'\n ) {\n const first = errors[0] as { error_code?: unknown; description?: unknown };\n if (typeof first.error_code === 'string') {\n info.errorCode = first.error_code;\n }\n if (typeof first.description === 'string') {\n info.description = first.description;\n }\n }\n }\n return info;\n}\n","/** Package version. Keep in sync with package.json. */\nexport const VERSION = '0.12.0';\n"],"mappings":";AAqBO,SAAS,gBAAgB,OAA0C;AACxE,MAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,cAAc,OAAO;AACtE,UAAM,WAAY,MAAiC;AACnD,QAAI,aAAa,QAAQ,OAAO,aAAa,UAAU;AACrD,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAGO,SAAS,WAAW,OAAoC;AAC7D,QAAM,SAAS,gBAAgB,KAAK,GAAG;AACvC,SAAO,OAAO,WAAW,WAAW,SAAS;AAC/C;AAkBA,eAAsB,kBAAkB,OAAwC;AAC9E,QAAM,WAAW,gBAAgB,KAAK;AACtC,QAAM,OAAsB;AAAA,IAC1B,QAAQ,OAAO,UAAU,WAAW,WAAW,SAAS,SAAS;AAAA,IACjE,WAAW;AAAA,IACX,aAAa;AAAA,EACf;AACA,MAAI,aAAa,QAAW;AAC1B,WAAO;AAAA,EACT;AAEA,MAAI;AACJ,MAAI;AACF,UAAM,SAAS,OAAO,SAAS,UAAU,aAAa,SAAS,MAAM,IAAI;AACzE,WAAO,OAAO,OAAO,SAAS,aAAa,MAAM,OAAO,KAAK,IAAI;AAAA,EACnE,QAAQ;AACN,WAAO;AAAA,EACT;AACA,MAAI,SAAS,QAAQ,OAAO,SAAS,UAAU;AAC7C,UAAM,SAAU,KAA8B;AAC9C,QACE,MAAM,QAAQ,MAAM,KACpB,OAAO,SAAS,KAChB,OAAO,CAAC,MAAM,QACd,OAAO,OAAO,CAAC,MAAM,UACrB;AACA,YAAM,QAAQ,OAAO,CAAC;AACtB,UAAI,OAAO,MAAM,eAAe,UAAU;AACxC,aAAK,YAAY,MAAM;AAAA,MACzB;AACA,UAAI,OAAO,MAAM,gBAAgB,UAAU;AACzC,aAAK,cAAc,MAAM;AAAA,MAC3B;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;;;ACxFO,IAAM,UAAU;","names":[]}
1
+ {"version":3,"sources":["../src/internal/response-like.ts","../src/version.ts"],"sourcesContent":["/**\n * Shared transport-error helpers for the widgets (chat + verification).\n *\n * Extracted verbatim from chat.tsx so both components read thrown SDK errors\n * the same way. Pure and dependency-free: no React, no DOM.\n */\n\n/**\n * The response-like object carried by a thrown transport error. We pull it off\n * by shape rather than `instanceof ResponseError` — robust against duplicated\n * `@gemina/sdk` copies in a bundle (class identity is not shared across\n * copies). On the fetch transport this is the raw `Response`, so `status`,\n * `headers`, and the JSON body are all reachable from here.\n */\nexport interface ResponseLike {\n status?: number;\n headers?: { get?: (name: string) => string | null };\n json?: () => Promise<unknown>;\n clone?: () => ResponseLike;\n}\n\nexport function getResponseLike(error: unknown): ResponseLike | undefined {\n if (error !== null && typeof error === 'object' && 'response' in error) {\n const response = (error as { response?: unknown }).response;\n if (response !== null && typeof response === 'object') {\n return response as ResponseLike;\n }\n }\n return undefined;\n}\n\n/** Extract an HTTP status from a thrown value, or `undefined`. */\nexport function httpStatus(error: unknown): number | undefined {\n const status = getResponseLike(error)?.status;\n return typeof status === 'number' ? status : undefined;\n}\n\n/** What the standard backend error envelope reliably carries. */\nexport interface ErrorEnvelope {\n status: number | undefined;\n /** Stable backend `errors[0].error_code`. */\n errorCode: string | undefined;\n /** Human-readable server fallback (`errors[0].description`). */\n description: string | undefined;\n}\n\n/**\n * Read what the backend actually sent on an error. Only the HTTP status and\n * the stable `errors[0].error_code` / `description` are reliable across\n * environments — production strips `errors[0].detail`, so we never touch it.\n * The fetch body can be read once, so we clone defensively; if that fails\n * (non-JSON, empty, or already consumed) the status still stands.\n */\nexport async function readErrorEnvelope(error: unknown): Promise<ErrorEnvelope> {\n const response = getResponseLike(error);\n const info: ErrorEnvelope = {\n status: typeof response?.status === 'number' ? response.status : undefined,\n errorCode: undefined,\n description: undefined,\n };\n if (response === undefined) {\n return info;\n }\n\n let body: unknown;\n try {\n const source = typeof response.clone === 'function' ? response.clone() : response;\n body = typeof source.json === 'function' ? await source.json() : undefined;\n } catch {\n body = undefined;\n }\n if (body !== null && typeof body === 'object') {\n const errors = (body as { errors?: unknown }).errors;\n if (\n Array.isArray(errors) &&\n errors.length > 0 &&\n errors[0] !== null &&\n typeof errors[0] === 'object'\n ) {\n const first = errors[0] as { error_code?: unknown; description?: unknown };\n if (typeof first.error_code === 'string') {\n info.errorCode = first.error_code;\n }\n if (typeof first.description === 'string') {\n info.description = first.description;\n }\n }\n }\n return info;\n}\n","/** Package version. Keep in sync with package.json. */\nexport const VERSION = '0.13.1';\n"],"mappings":";AAqBO,SAAS,gBAAgB,OAA0C;AACxE,MAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,cAAc,OAAO;AACtE,UAAM,WAAY,MAAiC;AACnD,QAAI,aAAa,QAAQ,OAAO,aAAa,UAAU;AACrD,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAGO,SAAS,WAAW,OAAoC;AAC7D,QAAM,SAAS,gBAAgB,KAAK,GAAG;AACvC,SAAO,OAAO,WAAW,WAAW,SAAS;AAC/C;AAkBA,eAAsB,kBAAkB,OAAwC;AAC9E,QAAM,WAAW,gBAAgB,KAAK;AACtC,QAAM,OAAsB;AAAA,IAC1B,QAAQ,OAAO,UAAU,WAAW,WAAW,SAAS,SAAS;AAAA,IACjE,WAAW;AAAA,IACX,aAAa;AAAA,EACf;AACA,MAAI,aAAa,QAAW;AAC1B,WAAO;AAAA,EACT;AAEA,MAAI;AACJ,MAAI;AACF,UAAM,SAAS,OAAO,SAAS,UAAU,aAAa,SAAS,MAAM,IAAI;AACzE,WAAO,OAAO,OAAO,SAAS,aAAa,MAAM,OAAO,KAAK,IAAI;AAAA,EACnE,QAAQ;AACN,WAAO;AAAA,EACT;AACA,MAAI,SAAS,QAAQ,OAAO,SAAS,UAAU;AAC7C,UAAM,SAAU,KAA8B;AAC9C,QACE,MAAM,QAAQ,MAAM,KACpB,OAAO,SAAS,KAChB,OAAO,CAAC,MAAM,QACd,OAAO,OAAO,CAAC,MAAM,UACrB;AACA,YAAM,QAAQ,OAAO,CAAC;AACtB,UAAI,OAAO,MAAM,eAAe,UAAU;AACxC,aAAK,YAAY,MAAM;AAAA,MACzB;AACA,UAAI,OAAO,MAAM,gBAAgB,UAAU;AACzC,aAAK,cAAc,MAAM;AAAA,MAC3B;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;;;ACxFO,IAAM,UAAU;","names":[]}
package/dist/index.cjs CHANGED
@@ -221,7 +221,7 @@ async function readErrorEnvelope(error) {
221
221
  }
222
222
 
223
223
  // src/version.ts
224
- var VERSION = "0.12.0";
224
+ var VERSION = "0.13.1";
225
225
 
226
226
  // src/chat.tsx
227
227
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -1695,6 +1695,101 @@ function pruneEmptyAddedRows(plannedTables, edits) {
1695
1695
  // src/verification/form.tsx
1696
1696
  var import_react4 = __toESM(require("react"), 1);
1697
1697
 
1698
+ // src/verification/review-filter.ts
1699
+ function isHighConfidence(confidence) {
1700
+ return (confidence?.level ?? "").toLowerCase() === "high";
1701
+ }
1702
+ var NOTHING_HIDDEN = {
1703
+ fields: /* @__PURE__ */ new Set(),
1704
+ rows: /* @__PURE__ */ new Set()
1705
+ };
1706
+ var unplannedRowKey = (tablePointer, index) => `${tablePointer}/${index}`;
1707
+ function forEachFieldUnit(classified, visit) {
1708
+ for (const header of classified.headers) visit(header.pointer, header.confidence);
1709
+ for (const list of classified.simpleLists) {
1710
+ for (const item of list.items) visit(item.pointer, item.confidence);
1711
+ }
1712
+ for (const entity of classified.entities) {
1713
+ for (const item of entity.items) {
1714
+ for (const cell of Object.values(item)) visit(cell.pointer, cell.confidence);
1715
+ }
1716
+ }
1717
+ }
1718
+ function forEachRowUnit(tables, plannedTables, visit) {
1719
+ const confidenceOf = (row) => {
1720
+ const meta = row?.[ROW_META_KEY];
1721
+ return meta?.confidence ?? null;
1722
+ };
1723
+ for (const table of tables) {
1724
+ const planned = plannedTables.get(table.pointer);
1725
+ if (planned) {
1726
+ for (const row of planned) {
1727
+ const { source } = row.entry;
1728
+ visit(row.entry.id, source === null ? null : confidenceOf(table.rows[source]), source === null);
1729
+ }
1730
+ continue;
1731
+ }
1732
+ table.rows.forEach((row, index) => {
1733
+ visit(unplannedRowKey(table.pointer, index), confidenceOf(row), false);
1734
+ });
1735
+ }
1736
+ }
1737
+ function computeHidden(input) {
1738
+ const {
1739
+ classified,
1740
+ tables,
1741
+ plannedTables,
1742
+ cellViews,
1743
+ bindingIndex,
1744
+ edits,
1745
+ pairErrors,
1746
+ suppressed
1747
+ } = input;
1748
+ const fields = /* @__PURE__ */ new Set();
1749
+ const rows = /* @__PURE__ */ new Set();
1750
+ const touched = (editKey) => edits.has(editKey) || pairErrors.has(editKey);
1751
+ const editKeysByRow = /* @__PURE__ */ new Map();
1752
+ for (const view of cellViews) {
1753
+ const list = editKeysByRow.get(view.rowKey);
1754
+ if (list) list.push(view.editKey);
1755
+ else editKeysByRow.set(view.rowKey, [view.editKey]);
1756
+ }
1757
+ forEachFieldUnit(classified, (pointer, confidence) => {
1758
+ if (suppressed.has(pointer) || !isHighConfidence(confidence)) return;
1759
+ const editKey = bindingIndex.get(pointer)?.key.raw;
1760
+ if (editKey === void 0 || touched(editKey)) return;
1761
+ fields.add(pointer);
1762
+ });
1763
+ forEachRowUnit(tables, plannedTables, (rowKey, confidence, added) => {
1764
+ if (added || !isHighConfidence(confidence)) return;
1765
+ if ((editKeysByRow.get(rowKey) ?? []).some(touched)) return;
1766
+ rows.add(rowKey);
1767
+ });
1768
+ if (fields.size === 0 && rows.size === 0) return NOTHING_HIDDEN;
1769
+ return { fields, rows };
1770
+ }
1771
+ function countUnits(classified, tables, plannedTables, suppressed) {
1772
+ let total = 0;
1773
+ forEachFieldUnit(classified, (pointer) => {
1774
+ if (!suppressed.has(pointer)) total += 1;
1775
+ });
1776
+ forEachRowUnit(tables, plannedTables, () => {
1777
+ total += 1;
1778
+ });
1779
+ return total;
1780
+ }
1781
+ function hasAnyConfidence(classified, tables, plannedTables) {
1782
+ let found = false;
1783
+ forEachFieldUnit(classified, (_pointer, confidence) => {
1784
+ if (confidence?.level) found = true;
1785
+ });
1786
+ if (found) return true;
1787
+ forEachRowUnit(tables, plannedTables, (_rowKey, confidence) => {
1788
+ if (confidence?.level) found = true;
1789
+ });
1790
+ return found;
1791
+ }
1792
+
1698
1793
  // src/verification/tip.tsx
1699
1794
  var import_react2 = require("react");
1700
1795
  var import_react_dom = require("react-dom");
@@ -2708,13 +2803,15 @@ function FieldPair(props) {
2708
2803
  }
2709
2804
  function HeaderSection(props) {
2710
2805
  const { headers, simpleLists, shared } = props;
2711
- if (headers.length === 0 && simpleLists.length === 0) {
2806
+ const visibleHeaders = headers.filter((field) => !shared.hidden.fields.has(field.pointer));
2807
+ const visibleLists = simpleLists.map((list) => ({ ...list, items: list.items.filter((item) => !shared.hidden.fields.has(item.pointer)) })).filter((list) => list.items.length > 0);
2808
+ if (visibleHeaders.length === 0 && visibleLists.length === 0) {
2712
2809
  return null;
2713
2810
  }
2714
2811
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { className: "gemina-verification__section", "aria-label": "Details", children: [
2715
2812
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__section-header", children: "Details" }),
2716
2813
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("dl", { className: "gemina-verification__dl", children: [
2717
- headers.map((field) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2814
+ visibleHeaders.map((field) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2718
2815
  FieldPair,
2719
2816
  {
2720
2817
  label: formatLabel(field.key),
@@ -2724,7 +2821,7 @@ function HeaderSection(props) {
2724
2821
  },
2725
2822
  field.pointer
2726
2823
  )),
2727
- simpleLists.map((list) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react4.default.Fragment, { children: [
2824
+ visibleLists.map((list) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react4.default.Fragment, { children: [
2728
2825
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dt", { className: "gemina-verification__dt", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: formatLabel(list.key) }) }),
2729
2826
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dd", { className: "gemina-verification__dd", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { className: "gemina-verification__list", children: list.items.map((item, index) => {
2730
2827
  const binding = shared.bindingIndex.get(item.pointer);
@@ -2760,16 +2857,19 @@ function HeaderSection(props) {
2760
2857
  }
2761
2858
  function EntitySection(props) {
2762
2859
  const { entity, shared } = props;
2860
+ const visibleItems = entity.items.map((item) => Object.fromEntries(
2861
+ Object.entries(item).filter(([, cellValue]) => !shared.hidden.fields.has(cellValue.pointer))
2862
+ )).filter((item) => Object.keys(item).length > 0);
2763
2863
  const label = formatLabel(entity.key);
2764
2864
  const singular = label.replace(/s$/, "");
2765
2865
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { className: "gemina-verification__section", "aria-label": label, children: [
2766
2866
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "gemina-verification__section-header", children: [
2767
2867
  label,
2768
2868
  " (",
2769
- entity.items.length,
2869
+ visibleItems.length,
2770
2870
  ")"
2771
2871
  ] }),
2772
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__section-body", children: entity.items.map((item, itemIndex) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "gemina-verification__card", children: [
2872
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__section-body", children: visibleItems.map((item, itemIndex) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "gemina-verification__card", children: [
2773
2873
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "gemina-verification__card-header", children: [
2774
2874
  singular,
2775
2875
  " ",
@@ -2824,7 +2924,7 @@ function TableRowView(props) {
2824
2924
  return { classified, binding, editKey: binding?.key.raw };
2825
2925
  };
2826
2926
  const firstRect = rects.length > 0 ? rects[0] : null;
2827
- const showControls = planned !== void 0 && tablePointer !== void 0 && !readOnly;
2927
+ const showControls = planned !== void 0 && tablePointer !== void 0 && !readOnly && !shared.filterOn;
2828
2928
  const rowLevel = (row?.[ROW_META_KEY]?.confidence?.level ?? "").toLowerCase();
2829
2929
  const rowClass = rowLevel === "low" || rowLevel === "medium" ? `gemina-verification__row--${rowLevel}` : void 0;
2830
2930
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("tr", { onClick: handleRowClick, className: rowClass, children: [
@@ -2873,7 +2973,7 @@ function TableRowView(props) {
2873
2973
  ] });
2874
2974
  }
2875
2975
  function areRowPropsEqual(prev, next) {
2876
- if (prev.row !== next.row || prev.rowIndex !== next.rowIndex || prev.columns !== next.columns || prev.tableLabel !== next.tableLabel || prev.hasCoords !== next.hasCoords || prev.hasRowConfidence !== next.hasRowConfidence || prev.planned !== next.planned || prev.tablePointer !== next.tablePointer || prev.shared.bindingIndex !== next.shared.bindingIndex || prev.shared.onEdit !== next.shared.onEdit || prev.shared.onFlash !== next.shared.onFlash || prev.shared.readOnly !== next.shared.readOnly) {
2976
+ if (prev.row !== next.row || prev.rowIndex !== next.rowIndex || prev.columns !== next.columns || prev.tableLabel !== next.tableLabel || prev.hasCoords !== next.hasCoords || prev.hasRowConfidence !== next.hasRowConfidence || prev.planned !== next.planned || prev.tablePointer !== next.tablePointer || prev.shared.bindingIndex !== next.shared.bindingIndex || prev.shared.onEdit !== next.shared.onEdit || prev.shared.onFlash !== next.shared.onFlash || prev.shared.readOnly !== next.shared.readOnly || prev.shared.filterOn !== next.shared.filterOn) {
2877
2977
  return false;
2878
2978
  }
2879
2979
  if (prev.shared.edits === next.shared.edits) {
@@ -2961,7 +3061,11 @@ function TableSection(props) {
2961
3061
  }).length,
2962
3062
  [table.rows]
2963
3063
  );
2964
- const showControls = planned !== void 0 && mutable !== void 0 && !shared.readOnly;
3064
+ const showControls = planned !== void 0 && mutable !== void 0 && !shared.readOnly && !shared.filterOn;
3065
+ const visiblePlanned = planned?.map((plannedRow, position) => ({ plannedRow, position })).filter(({ plannedRow }) => !shared.hidden.rows.has(plannedRow.entry.id));
3066
+ const visibleRowIndices = planned ? [] : table.rows.map((_row, index) => index).filter((index) => !shared.hidden.rows.has(unplannedRowKey(table.pointer, index)));
3067
+ const visibleCount = visiblePlanned ? visiblePlanned.length : visibleRowIndices.length;
3068
+ const allHidden = visibleCount === 0 && rowCount > 0;
2965
3069
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { className: "gemina-verification__section", "aria-label": label, children: [
2966
3070
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "gemina-verification__section-header", children: [
2967
3071
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
@@ -2977,7 +3081,11 @@ function TableSection(props) {
2977
3081
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ConfidenceDot, { confidence: table.overallConfidence })
2978
3082
  ] }) : null
2979
3083
  ] }),
2980
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__table-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("table", { className: "gemina-verification__table", children: [
3084
+ allHidden ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { className: "gemina-verification__all-scored", children: [
3085
+ "All ",
3086
+ rowCount,
3087
+ " rows scored high"
3088
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__table-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("table", { className: "gemina-verification__table", children: [
2981
3089
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("tr", { children: [
2982
3090
  hasCoords ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("th", { "aria-label": "Show row on document" }) : null,
2983
3091
  hasRowConfidence ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("th", { "aria-label": "Row confidence" }) : null,
@@ -2990,7 +3098,7 @@ function TableSection(props) {
2990
3098
  ) }, column)),
2991
3099
  showControls ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("th", { "aria-label": "Row actions" }) : null
2992
3100
  ] }) }),
2993
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("tbody", { children: planned ? planned.map((plannedRow, position) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
3101
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("tbody", { children: visiblePlanned ? visiblePlanned.map(({ plannedRow, position }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2994
3102
  TableRow,
2995
3103
  {
2996
3104
  row: plannedRow.entry.source === null ? void 0 : table.rows[plannedRow.entry.source],
@@ -3004,10 +3112,10 @@ function TableSection(props) {
3004
3112
  tablePointer: mutable.pointer
3005
3113
  },
3006
3114
  plannedRow.entry.id
3007
- )) : table.rows.map((row, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
3115
+ )) : visibleRowIndices.map((rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
3008
3116
  TableRow,
3009
3117
  {
3010
- row,
3118
+ row: table.rows[rowIndex],
3011
3119
  rowIndex,
3012
3120
  columns,
3013
3121
  tableLabel: label,
@@ -3078,7 +3186,9 @@ function VerificationForm(props) {
3078
3186
  rowMutableTables,
3079
3187
  plannedTables,
3080
3188
  onAddRow,
3081
- onRemoveRow
3189
+ onRemoveRow,
3190
+ hidden,
3191
+ filterOn
3082
3192
  } = props;
3083
3193
  const { tables: promotedTables, suppressed } = import_react4.default.useMemo(
3084
3194
  () => withEmptyMutableTables(classified, rowMutableTables ?? NO_TABLES),
@@ -3094,7 +3204,9 @@ function VerificationForm(props) {
3094
3204
  rowMutableTables: rowMutableTables ?? NO_TABLES,
3095
3205
  plannedTables: plannedTables ?? NO_PLANNED,
3096
3206
  onAddRow: onAddRow ?? NOOP_ROW,
3097
- onRemoveRow: onRemoveRow ?? NOOP_ROW
3207
+ onRemoveRow: onRemoveRow ?? NOOP_ROW,
3208
+ hidden: hidden ?? NOTHING_HIDDEN,
3209
+ filterOn: filterOn ?? false
3098
3210
  };
3099
3211
  return (
3100
3212
  // A real, labeled <form> (role "form" landmark): AT users can jump
@@ -3662,6 +3774,11 @@ var VERIFICATION_CSS = `
3662
3774
  }
3663
3775
  .gemina-verification__footer {
3664
3776
  display: flex;
3777
+ /* Wraps because the review filter adds two more items to this row, and at
3778
+ 320 the four together overflow: Submit was pushed 28px past the inline
3779
+ start and clipped. Measured RTL, where the overflow runs the other way
3780
+ and a scrollWidth-minus-clientWidth check on the document never sees it. */
3781
+ flex-wrap: wrap;
3665
3782
  align-items: center;
3666
3783
  gap: 10px;
3667
3784
  padding-block-start: 12px;
@@ -3678,6 +3795,41 @@ var VERIFICATION_CSS = `
3678
3795
  cursor: pointer;
3679
3796
  }
3680
3797
  .gemina-verification__submit:disabled { opacity: 0.5; cursor: default; }
3798
+ /* The review filter is a VIEW MODE, not an action, so it stays quiet: an
3799
+ outline control in the muted color, next to the one loud thing in the
3800
+ footer. Turning it on fills it from the same accent token \u2014 the state has
3801
+ to be unmistakable, because the form is hiding content while it is on. */
3802
+ .gemina-verification__review-filter {
3803
+ font: inherit;
3804
+ font-size: 12px;
3805
+ padding: 4px 12px;
3806
+ border-radius: var(--gemina-verification-radius);
3807
+ border: 1px solid var(--gemina-verification-border);
3808
+ background: transparent;
3809
+ color: var(--gemina-verification-muted);
3810
+ cursor: pointer;
3811
+ }
3812
+ .gemina-verification__review-filter:hover {
3813
+ color: var(--gemina-verification-accent);
3814
+ border-color: var(--gemina-verification-accent);
3815
+ }
3816
+ .gemina-verification__review-filter[aria-checked='true'] {
3817
+ background: var(--gemina-verification-accent);
3818
+ border-color: var(--gemina-verification-accent);
3819
+ color: var(--gemina-verification-accent-fg);
3820
+ }
3821
+ /* Stands in for a table's grid when every row of it scored high. Muted and
3822
+ unemphatic on purpose \u2014 it reports an absence, it is not a finding. */
3823
+ .gemina-verification__filter-count {
3824
+ font-size: 12px;
3825
+ color: var(--gemina-verification-muted);
3826
+ }
3827
+ .gemina-verification__all-scored {
3828
+ margin: 0;
3829
+ padding: 12px;
3830
+ color: var(--gemina-verification-muted);
3831
+ font-size: 13px;
3832
+ }
3681
3833
  .gemina-verification__retry {
3682
3834
  font: inherit;
3683
3835
  font-size: 12px;
@@ -4035,6 +4187,7 @@ function GeminaVerification(props) {
4035
4187
  const [imageUrl, setImageUrl] = (0, import_react5.useState)(null);
4036
4188
  const [flashRects, setFlashRects] = (0, import_react5.useState)(null);
4037
4189
  const [stacked, setStacked] = (0, import_react5.useState)(false);
4190
+ const [filterOn, setFilterOn] = (0, import_react5.useState)(false);
4038
4191
  const rootRef = (0, import_react5.useRef)(null);
4039
4192
  const mountedRef = (0, import_react5.useRef)(false);
4040
4193
  const loadSeqRef = (0, import_react5.useRef)(0);
@@ -4111,6 +4264,7 @@ function GeminaVerification(props) {
4111
4264
  rowMutableTables: readRowMutableTables(view.meta.validationFeedback?.rowMutableTables)
4112
4265
  });
4113
4266
  setEdits(NO_EDITS);
4267
+ setFilterOn(false);
4114
4268
  setRowPlans(seedRowPlans(readRowMutableTables(view.meta.validationFeedback?.rowMutableTables), view.values));
4115
4269
  const url = view.document.imageUrl;
4116
4270
  setImageUrl(typeof url === "string" && url.length > 0 ? url : null);
@@ -4172,19 +4326,19 @@ function GeminaVerification(props) {
4172
4326
  return map;
4173
4327
  }, [bindings]);
4174
4328
  const unmatched = (0, import_react5.useMemo)(() => {
4175
- const rendered = /* @__PURE__ */ new Set();
4329
+ const rendered2 = /* @__PURE__ */ new Set();
4176
4330
  for (const field of classified.headers) {
4177
- rendered.add(field.pointer);
4331
+ rendered2.add(field.pointer);
4178
4332
  }
4179
4333
  for (const list of classified.simpleLists) {
4180
4334
  for (const item of list.items) {
4181
- rendered.add(item.pointer);
4335
+ rendered2.add(item.pointer);
4182
4336
  }
4183
4337
  }
4184
4338
  for (const entity of classified.entities) {
4185
4339
  for (const item of entity.items) {
4186
4340
  for (const cell of Object.values(item)) {
4187
- rendered.add(cell.pointer);
4341
+ rendered2.add(cell.pointer);
4188
4342
  }
4189
4343
  }
4190
4344
  }
@@ -4192,12 +4346,12 @@ function GeminaVerification(props) {
4192
4346
  for (const row of table.rows) {
4193
4347
  for (const [key, cell] of Object.entries(row)) {
4194
4348
  if (key !== ROW_META_KEY) {
4195
- rendered.add(cell.pointer);
4349
+ rendered2.add(cell.pointer);
4196
4350
  }
4197
4351
  }
4198
4352
  }
4199
4353
  }
4200
- return bindings.filter((binding) => !rendered.has(binding.fieldPointer));
4354
+ return bindings.filter((binding) => !rendered2.has(binding.fieldPointer));
4201
4355
  }, [classified, bindings]);
4202
4356
  const overlayRects = (0, import_react5.useMemo)(() => {
4203
4357
  const rects = [];
@@ -4362,6 +4516,32 @@ function GeminaVerification(props) {
4362
4516
  });
4363
4517
  }, []);
4364
4518
  const pairErrors = (0, import_react5.useMemo)(() => unitSizePairErrors(cellViews, edits), [cellViews, edits]);
4519
+ const rendered = (0, import_react5.useMemo)(
4520
+ () => withEmptyMutableTables(classified, loaded?.rowMutableTables ?? []),
4521
+ [classified, loaded?.rowMutableTables]
4522
+ );
4523
+ const canFilter = (0, import_react5.useMemo)(
4524
+ () => hasAnyConfidence(classified, rendered.tables, plannedTables),
4525
+ [classified, rendered, plannedTables]
4526
+ );
4527
+ const hidden = (0, import_react5.useMemo)(
4528
+ () => filterOn && canFilter ? computeHidden({
4529
+ classified,
4530
+ tables: rendered.tables,
4531
+ plannedTables,
4532
+ cellViews,
4533
+ bindingIndex,
4534
+ edits,
4535
+ pairErrors,
4536
+ suppressed: rendered.suppressed
4537
+ }) : NOTHING_HIDDEN,
4538
+ [filterOn, canFilter, classified, rendered, plannedTables, cellViews, bindingIndex, edits, pairErrors]
4539
+ );
4540
+ const totalUnits = (0, import_react5.useMemo)(
4541
+ () => countUnits(classified, rendered.tables, plannedTables, rendered.suppressed) + unmatched.length,
4542
+ [classified, rendered, plannedTables, unmatched]
4543
+ );
4544
+ const visibleUnits = totalUnits - hidden.fields.size - hidden.rows.size;
4365
4545
  const invalidCount = (0, import_react5.useMemo)(() => {
4366
4546
  const rowLevel = pairErrors.size;
4367
4547
  if (edits.size === 0) {
@@ -4534,6 +4714,8 @@ function GeminaVerification(props) {
4534
4714
  onFlash: handleFlash,
4535
4715
  pairErrors,
4536
4716
  rowMutableTables: loaded?.rowMutableTables,
4717
+ hidden,
4718
+ filterOn,
4537
4719
  plannedTables,
4538
4720
  onAddRow: handleAddRow,
4539
4721
  onRemoveRow: handleRemoveRow
@@ -4562,6 +4744,20 @@ function GeminaVerification(props) {
4562
4744
  ),
4563
4745
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "gemina-verification__footer", children: [
4564
4746
  !alreadyValidated && (invalidCount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "gemina-verification__attention", "aria-live": "polite", children: invalidCount === 1 ? "1 field needs attention" : `${invalidCount} fields need attention` }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "gemina-verification__progress", "aria-live": "polite", children: `${submission.confirmed} confirmed \xB7 ${submission.corrected} corrected` })),
4747
+ canFilter && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
4748
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4749
+ "button",
4750
+ {
4751
+ type: "button",
4752
+ role: "switch",
4753
+ "aria-checked": filterOn,
4754
+ className: "gemina-verification__review-filter",
4755
+ onClick: () => setFilterOn((on) => !on),
4756
+ children: "Hide high-confidence fields"
4757
+ }
4758
+ ),
4759
+ filterOn && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "gemina-verification__filter-count", "aria-live": "polite", children: `Showing ${visibleUnits} of ${totalUnits}` })
4760
+ ] }),
4565
4761
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4566
4762
  "button",
4567
4763
  {