@tetrascience-npm/tetrascience-react-ui 0.6.0-beta.82.1 → 0.6.0-beta.84.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.
- package/dist/components/charts/AreaGraph/AreaGraph.cjs +1 -1
- package/dist/components/charts/AreaGraph/AreaGraph.cjs.map +1 -1
- package/dist/components/charts/AreaGraph/AreaGraph.js +132 -98
- package/dist/components/charts/AreaGraph/AreaGraph.js.map +1 -1
- package/dist/components/charts/BarGraph/BarGraph.cjs +1 -1
- package/dist/components/charts/BarGraph/BarGraph.cjs.map +1 -1
- package/dist/components/charts/BarGraph/BarGraph.js +63 -57
- package/dist/components/charts/BarGraph/BarGraph.js.map +1 -1
- package/dist/components/charts/Boxplot/Boxplot.cjs +1 -1
- package/dist/components/charts/Boxplot/Boxplot.cjs.map +1 -1
- package/dist/components/charts/Boxplot/Boxplot.js +83 -74
- package/dist/components/charts/Boxplot/Boxplot.js.map +1 -1
- package/dist/components/charts/ChartTooltip/ChartTooltip.cjs +2 -0
- package/dist/components/charts/ChartTooltip/ChartTooltip.cjs.map +1 -0
- package/dist/components/charts/ChartTooltip/ChartTooltip.js +163 -0
- package/dist/components/charts/ChartTooltip/ChartTooltip.js.map +1 -0
- package/dist/components/charts/ChartTooltip/lines.cjs +2 -0
- package/dist/components/charts/ChartTooltip/lines.cjs.map +1 -0
- package/dist/components/charts/ChartTooltip/lines.js +29 -0
- package/dist/components/charts/ChartTooltip/lines.js.map +1 -0
- package/dist/components/charts/Chromatogram/Chromatogram.cjs +1 -1
- package/dist/components/charts/Chromatogram/Chromatogram.cjs.map +1 -1
- package/dist/components/charts/Chromatogram/Chromatogram.js +75 -61
- package/dist/components/charts/Chromatogram/Chromatogram.js.map +1 -1
- package/dist/components/charts/ChromatogramChart/ChromatogramChart.cjs +1 -1
- package/dist/components/charts/ChromatogramChart/ChromatogramChart.cjs.map +1 -1
- package/dist/components/charts/ChromatogramChart/ChromatogramChart.js +116 -108
- package/dist/components/charts/ChromatogramChart/ChromatogramChart.js.map +1 -1
- package/dist/components/charts/ChromatogramChart/annotations.cjs +1 -1
- package/dist/components/charts/ChromatogramChart/annotations.cjs.map +1 -1
- package/dist/components/charts/ChromatogramChart/annotations.js +32 -32
- package/dist/components/charts/ChromatogramChart/annotations.js.map +1 -1
- package/dist/components/charts/ChromatogramChart/boundaryMarkers.cjs +1 -1
- package/dist/components/charts/ChromatogramChart/boundaryMarkers.cjs.map +1 -1
- package/dist/components/charts/ChromatogramChart/boundaryMarkers.js +6 -6
- package/dist/components/charts/ChromatogramChart/boundaryMarkers.js.map +1 -1
- package/dist/components/charts/ChromatogramChart/constants.cjs +1 -1
- package/dist/components/charts/ChromatogramChart/constants.cjs.map +1 -1
- package/dist/components/charts/ChromatogramChart/constants.js +11 -5
- package/dist/components/charts/ChromatogramChart/constants.js.map +1 -1
- package/dist/components/charts/ChromatogramChart/dataProcessing.cjs +1 -1
- package/dist/components/charts/ChromatogramChart/dataProcessing.cjs.map +1 -1
- package/dist/components/charts/ChromatogramChart/dataProcessing.js +38 -49
- package/dist/components/charts/ChromatogramChart/dataProcessing.js.map +1 -1
- package/dist/components/charts/DotPlot/DotPlot.cjs +1 -1
- package/dist/components/charts/DotPlot/DotPlot.cjs.map +1 -1
- package/dist/components/charts/DotPlot/DotPlot.js +57 -63
- package/dist/components/charts/DotPlot/DotPlot.js.map +1 -1
- package/dist/components/charts/Histogram/Histogram.cjs +1 -1
- package/dist/components/charts/Histogram/Histogram.cjs.map +1 -1
- package/dist/components/charts/Histogram/Histogram.js +98 -104
- package/dist/components/charts/Histogram/Histogram.js.map +1 -1
- package/dist/components/charts/LineGraph/LineGraph.cjs +1 -1
- package/dist/components/charts/LineGraph/LineGraph.cjs.map +1 -1
- package/dist/components/charts/LineGraph/LineGraph.js +97 -88
- package/dist/components/charts/LineGraph/LineGraph.js.map +1 -1
- package/dist/components/charts/PieChart/PieChart.cjs +1 -1
- package/dist/components/charts/PieChart/PieChart.cjs.map +1 -1
- package/dist/components/charts/PieChart/PieChart.js +65 -68
- package/dist/components/charts/PieChart/PieChart.js.map +1 -1
- package/dist/components/charts/PlateMap/PlateMap.cjs +1 -1
- package/dist/components/charts/PlateMap/PlateMap.cjs.map +1 -1
- package/dist/components/charts/PlateMap/PlateMap.js +271 -256
- package/dist/components/charts/PlateMap/PlateMap.js.map +1 -1
- package/dist/components/charts/PlateMap/constants.cjs +1 -1
- package/dist/components/charts/PlateMap/constants.cjs.map +1 -1
- package/dist/components/charts/PlateMap/constants.js +20 -29
- package/dist/components/charts/PlateMap/constants.js.map +1 -1
- package/dist/components/charts/ScatterGraph/ScatterGraph.cjs +1 -1
- package/dist/components/charts/ScatterGraph/ScatterGraph.cjs.map +1 -1
- package/dist/components/charts/ScatterGraph/ScatterGraph.js +113 -89
- package/dist/components/charts/ScatterGraph/ScatterGraph.js.map +1 -1
- package/dist/hooks/use-plotly-theme.cjs +1 -1
- package/dist/hooks/use-plotly-theme.cjs.map +1 -1
- package/dist/hooks/use-plotly-theme.js +4 -2
- package/dist/hooks/use-plotly-theme.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +156 -76
- package/dist/index.js +587 -581
- package/dist/index.js.map +1 -1
- package/dist/index.tailwind.css +1 -1
- package/dist/utils/colors.cjs +1 -1
- package/dist/utils/colors.cjs.map +1 -1
- package/dist/utils/colors.js +38 -93
- package/dist/utils/colors.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const x = -5,
|
|
3
|
-
function
|
|
1
|
+
import { seriesColor as m } from "../../../utils/colors.js";
|
|
2
|
+
const x = -5, l = -12, c = -16;
|
|
3
|
+
function d(o, e, t, r) {
|
|
4
4
|
return t === "none" ? [] : [
|
|
5
5
|
{
|
|
6
6
|
x: [o],
|
|
@@ -20,10 +20,10 @@ function i(o, e, t, r) {
|
|
|
20
20
|
function E(o) {
|
|
21
21
|
const e = [];
|
|
22
22
|
for (const { peaks: t, seriesIndex: r, x: s } of o) {
|
|
23
|
-
const a =
|
|
23
|
+
const a = m(r), i = x + r * c, k = l + r * c;
|
|
24
24
|
for (const n of t) {
|
|
25
|
-
const p = n._computed?.startIndex ?? 0,
|
|
26
|
-
e.push(...
|
|
25
|
+
const p = n._computed?.startIndex ?? 0, u = n._computed?.endIndex ?? 0, M = s[p], R = s[u], _ = n.startMarker ?? "triangle", f = n.endMarker ?? "diamond";
|
|
26
|
+
e.push(...d(M, i, _, a)), e.push(...d(R, k, f, a));
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
return e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boundaryMarkers.js","sources":["../../../../src/components/charts/ChromatogramChart/boundaryMarkers.ts"],"sourcesContent":["/**\n * Boundary marker utilities for ChromatogramChart\n */\n\nimport {
|
|
1
|
+
{"version":3,"file":"boundaryMarkers.js","sources":["../../../../src/components/charts/ChromatogramChart/boundaryMarkers.ts"],"sourcesContent":["/**\n * Boundary marker utilities for ChromatogramChart\n */\n\nimport { seriesColor } from \"../../../utils/colors\";\n\nimport type { PeakAnnotation, BoundaryMarkerType } from \"./types\";\nimport type Plotly from \"plotly.js-dist\";\n\n/** Base Y position for start boundary markers (below the x-axis) */\nconst BOUNDARY_MARKER_START_Y = -5;\n/** Y position for end boundary markers (below start markers) */\nconst BOUNDARY_MARKER_END_Y = -12;\n/** Y offset between series to prevent overlap */\nconst BOUNDARY_MARKER_SERIES_OFFSET = -16;\n\n/**\n * Create a marker trace for a boundary point.\n * Markers are placed on the x-axis below 0, staggered by series index.\n */\nfunction createMarkerTrace(\n xPos: number,\n yPos: number,\n markerType: BoundaryMarkerType,\n color: string\n): Plotly.Data[] {\n if (markerType === \"none\") {\n return [];\n }\n\n return [\n {\n x: [xPos],\n y: [yPos],\n type: \"scatter\" as const,\n mode: \"markers\" as const,\n marker: {\n symbol: markerType === \"diamond\" ? (\"diamond\" as const) : (\"triangle-up\" as const),\n size: 8,\n color,\n },\n showlegend: false,\n hoverinfo: \"skip\" as const,\n },\n ];\n}\n\n/**\n * Create boundary marker traces for peaks.\n * Uses per-peak startMarker/endMarker settings with defaults:\n * - startMarker: \"triangle\" (default)\n * - endMarker: \"diamond\" (default)\n */\nexport function createBoundaryMarkerTraces(\n allPeaks: {\n peaks: PeakAnnotation[];\n seriesIndex: number;\n x: number[];\n y: number[];\n }[]\n): Plotly.Data[] {\n const traces: Plotly.Data[] = [];\n\n for (const { peaks, seriesIndex, x } of allPeaks) {\n const color = seriesColor(seriesIndex);\n // Separate y positions for start vs end markers to prevent overlap when peaks are adjacent\n // Also stagger by series index to prevent overlap between different traces\n const startMarkerY = BOUNDARY_MARKER_START_Y + seriesIndex * BOUNDARY_MARKER_SERIES_OFFSET;\n const endMarkerY = BOUNDARY_MARKER_END_Y + seriesIndex * BOUNDARY_MARKER_SERIES_OFFSET;\n\n for (const peak of peaks) {\n const startIdx = peak._computed?.startIndex ?? 0;\n const endIdx = peak._computed?.endIndex ?? 0;\n const startX = x[startIdx];\n const endX = x[endIdx];\n\n // Get marker types with defaults: triangle at start, diamond at end\n const startMarkerType = peak.startMarker ?? \"triangle\";\n const endMarkerType = peak.endMarker ?? \"diamond\";\n\n // Create start boundary marker (upper row, staggered by series)\n traces.push(...createMarkerTrace(startX, startMarkerY, startMarkerType, color));\n\n // Create end boundary marker (lower row, staggered by series)\n traces.push(...createMarkerTrace(endX, endMarkerY, endMarkerType, color));\n }\n }\n\n return traces;\n}\n\n"],"names":["BOUNDARY_MARKER_START_Y","BOUNDARY_MARKER_END_Y","BOUNDARY_MARKER_SERIES_OFFSET","createMarkerTrace","xPos","yPos","markerType","color","createBoundaryMarkerTraces","allPeaks","traces","peaks","seriesIndex","x","seriesColor","startMarkerY","endMarkerY","peak","startIdx","endIdx","startX","endX","startMarkerType","endMarkerType"],"mappings":";AAUA,MAAMA,IAA0B,IAE1BC,IAAwB,KAExBC,IAAgC;AAMtC,SAASC,EACPC,GACAC,GACAC,GACAC,GACe;AACf,SAAID,MAAe,SACV,CAAA,IAGF;AAAA,IACL;AAAA,MACE,GAAG,CAACF,CAAI;AAAA,MACR,GAAG,CAACC,CAAI;AAAA,MACR,MAAM;AAAA,MACN,MAAM;AAAA,MACN,QAAQ;AAAA,QACN,QAAQC,MAAe,YAAa,YAAuB;AAAA,QAC3D,MAAM;AAAA,QACN,OAAAC;AAAA,MAAA;AAAA,MAEF,YAAY;AAAA,MACZ,WAAW;AAAA,IAAA;AAAA,EACb;AAEJ;AAQO,SAASC,EACdC,GAMe;AACf,QAAMC,IAAwB,CAAA;AAE9B,aAAW,EAAE,OAAAC,GAAO,aAAAC,GAAa,GAAAC,EAAA,KAAOJ,GAAU;AAChD,UAAMF,IAAQO,EAAYF,CAAW,GAG/BG,IAAef,IAA0BY,IAAcV,GACvDc,IAAaf,IAAwBW,IAAcV;AAEzD,eAAWe,KAAQN,GAAO;AACxB,YAAMO,IAAWD,EAAK,WAAW,cAAc,GACzCE,IAASF,EAAK,WAAW,YAAY,GACrCG,IAASP,EAAEK,CAAQ,GACnBG,IAAOR,EAAEM,CAAM,GAGfG,IAAkBL,EAAK,eAAe,YACtCM,IAAgBN,EAAK,aAAa;AAGxC,MAAAP,EAAO,KAAK,GAAGP,EAAkBiB,GAAQL,GAAcO,GAAiBf,CAAK,CAAC,GAG9EG,EAAO,KAAK,GAAGP,EAAkBkB,GAAML,GAAYO,GAAehB,CAAK,CAAC;AAAA,IAC1E;AAAA,EACF;AAEA,SAAOG;AACT;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O={MARGIN_LEFT:70,MARGIN_RIGHT:30,MARGIN_BOTTOM:60,MARGIN_TOP_WITH_TITLE:50,MARGIN_TOP_NO_TITLE:30,MARGIN_PAD:5},T={USER_ANNOTATION_FONT_SIZE:11,AUTO_ANNOTATION_FONT_SIZE:10,USER_ANNOTATION_COLOR:"rgba(100, 116, 139, 1)",USER_ANNOTATION_TEXT_COLOR:"rgba(26, 26, 26, 1)",BACKGROUND_COLOR:"#ffffff"};exports.CHROMATOGRAM_ANNOTATION=T;exports.CHROMATOGRAM_LAYOUT=O;
|
|
2
2
|
//# sourceMappingURL=constants.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.cjs","sources":["../../../../src/components/charts/ChromatogramChart/constants.ts"],"sourcesContent":["/**\n * Constants for ChromatogramChart component\n */\n\n/**\n * Layout constants for chart margins and spacing\n */\nexport const CHROMATOGRAM_LAYOUT = {\n /** Left margin in pixels */\n MARGIN_LEFT: 70,\n /** Right margin in pixels */\n MARGIN_RIGHT: 30,\n /** Bottom margin in pixels */\n MARGIN_BOTTOM: 60,\n /** Top margin with title in pixels */\n MARGIN_TOP_WITH_TITLE: 50,\n /** Top margin without title in pixels */\n MARGIN_TOP_NO_TITLE: 30,\n /** Padding around plot area */\n MARGIN_PAD: 5,\n} as const;\n\n/**\n * Annotation constants for peak labels and markers\n */\nexport const CHROMATOGRAM_ANNOTATION = {\n /** Default vertical offset for annotation arrows (negative = above point) */\n DEFAULT_ARROW_OFFSET_Y: -30,\n /** Font size for user-defined annotations */\n USER_ANNOTATION_FONT_SIZE: 11,\n /** Font size for auto-detected peak annotations */\n AUTO_ANNOTATION_FONT_SIZE: 10,\n} as const;\n\n"],"names":["CHROMATOGRAM_LAYOUT","CHROMATOGRAM_ANNOTATION"],"mappings":"gFAOO,MAAMA,EAAsB,CAEjC,YAAa,GAEb,aAAc,GAEd,cAAe,GAEf,sBAAuB,GAEvB,oBAAqB,GAErB,WAAY,CACd,EAKaC,EAA0B,CAIrC,0BAA2B,GAE3B,0BAA2B,
|
|
1
|
+
{"version":3,"file":"constants.cjs","sources":["../../../../src/components/charts/ChromatogramChart/constants.ts"],"sourcesContent":["/**\n * Constants for ChromatogramChart component\n */\n\n/**\n * Layout constants for chart margins and spacing\n */\nexport const CHROMATOGRAM_LAYOUT = {\n /** Left margin in pixels */\n MARGIN_LEFT: 70,\n /** Right margin in pixels */\n MARGIN_RIGHT: 30,\n /** Bottom margin in pixels */\n MARGIN_BOTTOM: 60,\n /** Top margin with title in pixels */\n MARGIN_TOP_WITH_TITLE: 50,\n /** Top margin without title in pixels */\n MARGIN_TOP_NO_TITLE: 30,\n /** Padding around plot area */\n MARGIN_PAD: 5,\n} as const;\n\n/**\n * Annotation constants for peak labels and markers\n */\nexport const CHROMATOGRAM_ANNOTATION = {\n /** Default vertical offset for annotation arrows (negative = above point) */\n DEFAULT_ARROW_OFFSET_Y: -30,\n /** Font size for user-defined annotations */\n USER_ANNOTATION_FONT_SIZE: 11,\n /** Font size for auto-detected peak annotations */\n AUTO_ANNOTATION_FONT_SIZE: 10,\n /** Arrow color for user-defined annotations (grey 500) */\n USER_ANNOTATION_COLOR: \"rgba(100, 116, 139, 1)\",\n /** Text color for user-defined annotations (black 900) */\n USER_ANNOTATION_TEXT_COLOR: \"rgba(26, 26, 26, 1)\",\n /** Background color behind annotation text */\n BACKGROUND_COLOR: \"#ffffff\",\n} as const;\n\n"],"names":["CHROMATOGRAM_LAYOUT","CHROMATOGRAM_ANNOTATION"],"mappings":"gFAOO,MAAMA,EAAsB,CAEjC,YAAa,GAEb,aAAc,GAEd,cAAe,GAEf,sBAAuB,GAEvB,oBAAqB,GAErB,WAAY,CACd,EAKaC,EAA0B,CAIrC,0BAA2B,GAE3B,0BAA2B,GAE3B,sBAAuB,yBAEvB,2BAA4B,sBAE5B,iBAAkB,SACpB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const O = {
|
|
2
2
|
/** Left margin in pixels */
|
|
3
3
|
MARGIN_LEFT: 70,
|
|
4
4
|
/** Right margin in pixels */
|
|
@@ -11,14 +11,20 @@ const T = {
|
|
|
11
11
|
MARGIN_TOP_NO_TITLE: 30,
|
|
12
12
|
/** Padding around plot area */
|
|
13
13
|
MARGIN_PAD: 5
|
|
14
|
-
},
|
|
14
|
+
}, T = {
|
|
15
15
|
/** Font size for user-defined annotations */
|
|
16
16
|
USER_ANNOTATION_FONT_SIZE: 11,
|
|
17
17
|
/** Font size for auto-detected peak annotations */
|
|
18
|
-
AUTO_ANNOTATION_FONT_SIZE: 10
|
|
18
|
+
AUTO_ANNOTATION_FONT_SIZE: 10,
|
|
19
|
+
/** Arrow color for user-defined annotations (grey 500) */
|
|
20
|
+
USER_ANNOTATION_COLOR: "rgba(100, 116, 139, 1)",
|
|
21
|
+
/** Text color for user-defined annotations (black 900) */
|
|
22
|
+
USER_ANNOTATION_TEXT_COLOR: "rgba(26, 26, 26, 1)",
|
|
23
|
+
/** Background color behind annotation text */
|
|
24
|
+
BACKGROUND_COLOR: "#ffffff"
|
|
19
25
|
};
|
|
20
26
|
export {
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
T as CHROMATOGRAM_ANNOTATION,
|
|
28
|
+
O as CHROMATOGRAM_LAYOUT
|
|
23
29
|
};
|
|
24
30
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../../src/components/charts/ChromatogramChart/constants.ts"],"sourcesContent":["/**\n * Constants for ChromatogramChart component\n */\n\n/**\n * Layout constants for chart margins and spacing\n */\nexport const CHROMATOGRAM_LAYOUT = {\n /** Left margin in pixels */\n MARGIN_LEFT: 70,\n /** Right margin in pixels */\n MARGIN_RIGHT: 30,\n /** Bottom margin in pixels */\n MARGIN_BOTTOM: 60,\n /** Top margin with title in pixels */\n MARGIN_TOP_WITH_TITLE: 50,\n /** Top margin without title in pixels */\n MARGIN_TOP_NO_TITLE: 30,\n /** Padding around plot area */\n MARGIN_PAD: 5,\n} as const;\n\n/**\n * Annotation constants for peak labels and markers\n */\nexport const CHROMATOGRAM_ANNOTATION = {\n /** Default vertical offset for annotation arrows (negative = above point) */\n DEFAULT_ARROW_OFFSET_Y: -30,\n /** Font size for user-defined annotations */\n USER_ANNOTATION_FONT_SIZE: 11,\n /** Font size for auto-detected peak annotations */\n AUTO_ANNOTATION_FONT_SIZE: 10,\n} as const;\n\n"],"names":["CHROMATOGRAM_LAYOUT","CHROMATOGRAM_ANNOTATION"],"mappings":"AAOO,MAAMA,IAAsB;AAAA;AAAA,EAEjC,aAAa;AAAA;AAAA,EAEb,cAAc;AAAA;AAAA,EAEd,eAAe;AAAA;AAAA,EAEf,uBAAuB;AAAA;AAAA,EAEvB,qBAAqB;AAAA;AAAA,EAErB,YAAY;AACd,GAKaC,IAA0B;AAAA;AAAA,EAIrC,2BAA2B;AAAA;AAAA,EAE3B,2BAA2B;
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../src/components/charts/ChromatogramChart/constants.ts"],"sourcesContent":["/**\n * Constants for ChromatogramChart component\n */\n\n/**\n * Layout constants for chart margins and spacing\n */\nexport const CHROMATOGRAM_LAYOUT = {\n /** Left margin in pixels */\n MARGIN_LEFT: 70,\n /** Right margin in pixels */\n MARGIN_RIGHT: 30,\n /** Bottom margin in pixels */\n MARGIN_BOTTOM: 60,\n /** Top margin with title in pixels */\n MARGIN_TOP_WITH_TITLE: 50,\n /** Top margin without title in pixels */\n MARGIN_TOP_NO_TITLE: 30,\n /** Padding around plot area */\n MARGIN_PAD: 5,\n} as const;\n\n/**\n * Annotation constants for peak labels and markers\n */\nexport const CHROMATOGRAM_ANNOTATION = {\n /** Default vertical offset for annotation arrows (negative = above point) */\n DEFAULT_ARROW_OFFSET_Y: -30,\n /** Font size for user-defined annotations */\n USER_ANNOTATION_FONT_SIZE: 11,\n /** Font size for auto-detected peak annotations */\n AUTO_ANNOTATION_FONT_SIZE: 10,\n /** Arrow color for user-defined annotations (grey 500) */\n USER_ANNOTATION_COLOR: \"rgba(100, 116, 139, 1)\",\n /** Text color for user-defined annotations (black 900) */\n USER_ANNOTATION_TEXT_COLOR: \"rgba(26, 26, 26, 1)\",\n /** Background color behind annotation text */\n BACKGROUND_COLOR: \"#ffffff\",\n} as const;\n\n"],"names":["CHROMATOGRAM_LAYOUT","CHROMATOGRAM_ANNOTATION"],"mappings":"AAOO,MAAMA,IAAsB;AAAA;AAAA,EAEjC,aAAa;AAAA;AAAA,EAEb,cAAc;AAAA;AAAA,EAEd,eAAe;AAAA;AAAA,EAEf,uBAAuB;AAAA;AAAA,EAEvB,qBAAqB;AAAA;AAAA,EAErB,YAAY;AACd,GAKaC,IAA0B;AAAA;AAAA,EAIrC,2BAA2B;AAAA;AAAA,EAE3B,2BAA2B;AAAA;AAAA,EAE3B,uBAAuB;AAAA;AAAA,EAEvB,4BAA4B;AAAA;AAAA,EAE5B,kBAAkB;AACpB;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./peakDetection.cjs");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./peakDetection.cjs");function c(t,o){if(t.length===0||t.length===1)return 0;let n=0,e=t.length-1;for(;n<e;){const l=Math.floor((n+e)/2);t[l]<o?n=l+1:e=l}return n>0&&Math.abs(t[n-1]-o)<Math.abs(t[n]-o)?n-1:n}function d(t,o,n){return t.map(e=>{if(e.startX!==void 0&&e.endX!==void 0){const l=c(o,e.startX),i=c(o,e.endX),a=c(o,e.x),s=e._computed?.area??u.calculatePeakArea(o,n,l,i);return{...e,_computed:{...e._computed,index:a,startIndex:l,endIndex:i,area:s}}}return e})}function h(t,o,n){const e=[];t.forEach(({peaks:i,seriesIndex:a})=>{e.push({peaks:i,seriesIndex:a,x:n[a].x,y:n[a].y})});const l=o.filter(i=>i._computed?.startIndex!==void 0&&i._computed?.endIndex!==void 0);return l.length>0&&n.length>0&&e.push({peaks:l,seriesIndex:0,x:n[0].x,y:n[0].y}),e}function f(t,o){const n=Math.min(t.length,o.length),e=t.slice(0,n),i=o.slice(0,n).map(s=>Number.isFinite(s)?s:0);return{x:e.map(s=>Number.isFinite(s)?s:0),y:i}}function p(t,o,n=50){if(o==="none"||t.length===0)return t;if(o==="linear"){if(t.length===1)return[0];const e=(t[t.length-1]-t[0])/(t.length-1);return t.map((l,i)=>l-(t[0]+e*i))}if(o==="rolling"){const e=[],l=Math.floor(n/2);for(let i=0;i<t.length;i++){const a=Math.max(0,i-l),s=Math.min(t.length,i+l+1),r=t.slice(a,s);e.push(Math.min(...r))}return t.map((i,a)=>i-e[a])}return t}exports.applyBaselineCorrection=p;exports.collectPeaksWithBoundaryData=h;exports.findClosestIndex=c;exports.processUserAnnotations=d;exports.validateSeriesData=f;
|
|
2
2
|
//# sourceMappingURL=dataProcessing.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataProcessing.cjs","sources":["../../../../src/components/charts/ChromatogramChart/dataProcessing.ts"],"sourcesContent":["/**\n * Data processing utilities for ChromatogramChart\n */\n\nimport { calculatePeakArea } from \"./peakDetection\";\n\nimport type { BaselineCorrectionMethod, PeakAnnotation } from \"./types\";\n\n/**\n * Data structure for peaks with their associated series data\n */\nexport type PeakDataWithSeries = {\n peaks: PeakAnnotation[];\n seriesIndex: number;\n x: number[];\n y: number[];\n};\n\n/**\n * Find the closest index in an array for a given target value.\n * Uses binary search for efficiency.\n */\nexport function findClosestIndex(arr: number[], target: number): number {\n if (arr.length === 0) return 0;\n if (arr.length === 1) return 0;\n\n let left = 0;\n let right = arr.length - 1;\n\n while (left < right) {\n const mid = Math.floor((left + right) / 2);\n if (arr[mid] < target) {\n left = mid + 1;\n } else {\n right = mid;\n }\n }\n\n // Check if left-1 is closer\n if (left > 0 && Math.abs(arr[left - 1] - target) < Math.abs(arr[left] - target)) {\n return left - 1;\n }\n return left;\n}\n\n/**\n * Process user annotations to convert startX/endX to startIndex/endIndex\n * and compute area if boundaries are provided.\n */\nexport function processUserAnnotations(\n annotations: PeakAnnotation[],\n xArray: number[],\n yArray: number[]\n): PeakAnnotation[] {\n return annotations.map((ann) => {\n // If startX/endX are provided, convert to indices\n if (ann.startX !== undefined && ann.endX !== undefined) {\n const startIndex = findClosestIndex(xArray, ann.startX);\n const endIndex = findClosestIndex(xArray, ann.endX);\n const index = findClosestIndex(xArray, ann.x);\n\n // Calculate area if not provided\n const area = ann._computed?.area ?? calculatePeakArea(xArray, yArray, startIndex, endIndex);\n\n return {\n ...ann,\n _computed: {\n ...ann._computed,\n index,\n startIndex,\n endIndex,\n area,\n },\n };\n }\n return ann;\n });\n}\n\n/**\n * Collect peaks with boundary information from both auto-detected peaks and user-provided annotations.\n * User-provided annotations with startIndex/endIndex or startX/endX are included for boundary marker rendering.\n */\nexport function collectPeaksWithBoundaryData(\n allDetectedPeaks: { peaks: PeakAnnotation[]; seriesIndex: number }[],\n annotations: PeakAnnotation[],\n processedSeries: { x: number[]; y: number[] }[]\n): PeakDataWithSeries[] {\n const peaksWithData: PeakDataWithSeries[] = [];\n\n // Add auto-detected peaks\n allDetectedPeaks.forEach(({ peaks, seriesIndex }) => {\n peaksWithData.push({\n peaks,\n seriesIndex,\n x: processedSeries[seriesIndex].x,\n y: processedSeries[seriesIndex].y,\n });\n });\n\n // Add user-provided annotations that have boundary info (_computed.startIndex and _computed.endIndex)\n // Note: annotations with startX/endX should already be processed to have _computed fields\n const annotationsWithBoundaries = annotations.filter(\n (ann) => ann._computed?.startIndex !== undefined && ann._computed?.endIndex !== undefined\n );\n if (annotationsWithBoundaries.length > 0 && processedSeries.length > 0) {\n peaksWithData.push({\n peaks: annotationsWithBoundaries,\n seriesIndex: 0, // User annotations apply to first series by default\n x: processedSeries[0].x,\n y: processedSeries[0].y,\n });\n }\n\n return peaksWithData;\n}\n\n/**\n * Build the extra content for Plotly hovertemplate from series metadata.\n * Displays all metadata fields as key: value pairs.\n */\nexport function buildHoverExtraContent(\n seriesName: string,\n metadata?: Record<string, unknown>\n): string {\n if (!metadata) return seriesName;\n\n const metaLines: string[] = [];\n for (const [key, value] of Object.entries(metadata)) {\n if (value !== undefined && value !== null && value !== \"\") {\n // Format the key as Title Case (e.g., \"sampleName\" -> \"Sample Name\")\n const formattedKey = key\n .replace(/([A-Z])/g, \" $1\")\n .replace(/^./, (s) => s.toUpperCase())\n .trim();\n metaLines.push(`${formattedKey}: ${String(value)}`);\n }\n }\n\n if (metaLines.length > 0) {\n return `${seriesName}<br>${metaLines.join(\"<br>\")}`;\n }\n return seriesName;\n}\n\n/**\n * Validate and sanitize series data.\n * - Ensures x and y arrays have the same length (truncates to shorter)\n * - Replaces NaN and Infinity values with 0\n */\nexport function validateSeriesData(\n x: number[],\n y: number[]\n): { x: number[]; y: number[] } {\n // Ensure arrays have same length\n const length = Math.min(x.length, y.length);\n const validX = x.slice(0, length);\n const validY = y.slice(0, length);\n\n // Sanitize NaN and Infinity values\n const sanitizedY = validY.map((val) => (Number.isFinite(val) ? val : 0));\n const sanitizedX = validX.map((val) => (Number.isFinite(val) ? val : 0));\n\n return { x: sanitizedX, y: sanitizedY };\n}\n\n/**\n * Apply baseline correction to signal data\n */\nexport function applyBaselineCorrection(\n y: number[],\n method: BaselineCorrectionMethod,\n windowSize: number = 50\n): number[] {\n if (method === \"none\" || y.length === 0) return y;\n\n if (method === \"linear\") {\n // Linear baseline from first to last point\n // Handle single-point case to avoid division by zero\n if (y.length === 1) {\n return [0]; // Single point baseline-corrected to zero\n }\n const slope = (y[y.length - 1] - y[0]) / (y.length - 1);\n return y.map((val, i) => val - (y[0] + slope * i));\n }\n\n if (method === \"rolling\") {\n // Rolling minimum baseline\n const baseline: number[] = [];\n const halfWindow = Math.floor(windowSize / 2);\n\n for (let i = 0; i < y.length; i++) {\n const start = Math.max(0, i - halfWindow);\n const end = Math.min(y.length, i + halfWindow + 1);\n const windowSlice = y.slice(start, end);\n baseline.push(Math.min(...windowSlice));\n }\n\n return y.map((val, i) => val - baseline[i]);\n }\n\n return y;\n}\n\n"],"names":["findClosestIndex","arr","target","left","right","mid","processUserAnnotations","annotations","xArray","yArray","ann","startIndex","endIndex","index","area","calculatePeakArea","collectPeaksWithBoundaryData","allDetectedPeaks","processedSeries","peaksWithData","peaks","seriesIndex","annotationsWithBoundaries","
|
|
1
|
+
{"version":3,"file":"dataProcessing.cjs","sources":["../../../../src/components/charts/ChromatogramChart/dataProcessing.ts"],"sourcesContent":["/**\n * Data processing utilities for ChromatogramChart\n */\n\nimport { calculatePeakArea } from \"./peakDetection\";\n\nimport type { BaselineCorrectionMethod, PeakAnnotation } from \"./types\";\n\n/**\n * Data structure for peaks with their associated series data\n */\nexport type PeakDataWithSeries = {\n peaks: PeakAnnotation[];\n seriesIndex: number;\n x: number[];\n y: number[];\n};\n\n/**\n * Find the closest index in an array for a given target value.\n * Uses binary search for efficiency.\n */\nexport function findClosestIndex(arr: number[], target: number): number {\n if (arr.length === 0) return 0;\n if (arr.length === 1) return 0;\n\n let left = 0;\n let right = arr.length - 1;\n\n while (left < right) {\n const mid = Math.floor((left + right) / 2);\n if (arr[mid] < target) {\n left = mid + 1;\n } else {\n right = mid;\n }\n }\n\n // Check if left-1 is closer\n if (left > 0 && Math.abs(arr[left - 1] - target) < Math.abs(arr[left] - target)) {\n return left - 1;\n }\n return left;\n}\n\n/**\n * Process user annotations to convert startX/endX to startIndex/endIndex\n * and compute area if boundaries are provided.\n */\nexport function processUserAnnotations(\n annotations: PeakAnnotation[],\n xArray: number[],\n yArray: number[]\n): PeakAnnotation[] {\n return annotations.map((ann) => {\n // If startX/endX are provided, convert to indices\n if (ann.startX !== undefined && ann.endX !== undefined) {\n const startIndex = findClosestIndex(xArray, ann.startX);\n const endIndex = findClosestIndex(xArray, ann.endX);\n const index = findClosestIndex(xArray, ann.x);\n\n // Calculate area if not provided\n const area = ann._computed?.area ?? calculatePeakArea(xArray, yArray, startIndex, endIndex);\n\n return {\n ...ann,\n _computed: {\n ...ann._computed,\n index,\n startIndex,\n endIndex,\n area,\n },\n };\n }\n return ann;\n });\n}\n\n/**\n * Collect peaks with boundary information from both auto-detected peaks and user-provided annotations.\n * User-provided annotations with startIndex/endIndex or startX/endX are included for boundary marker rendering.\n */\nexport function collectPeaksWithBoundaryData(\n allDetectedPeaks: { peaks: PeakAnnotation[]; seriesIndex: number }[],\n annotations: PeakAnnotation[],\n processedSeries: { x: number[]; y: number[] }[]\n): PeakDataWithSeries[] {\n const peaksWithData: PeakDataWithSeries[] = [];\n\n // Add auto-detected peaks\n allDetectedPeaks.forEach(({ peaks, seriesIndex }) => {\n peaksWithData.push({\n peaks,\n seriesIndex,\n x: processedSeries[seriesIndex].x,\n y: processedSeries[seriesIndex].y,\n });\n });\n\n // Add user-provided annotations that have boundary info (_computed.startIndex and _computed.endIndex)\n // Note: annotations with startX/endX should already be processed to have _computed fields\n const annotationsWithBoundaries = annotations.filter(\n (ann) => ann._computed?.startIndex !== undefined && ann._computed?.endIndex !== undefined\n );\n if (annotationsWithBoundaries.length > 0 && processedSeries.length > 0) {\n peaksWithData.push({\n peaks: annotationsWithBoundaries,\n seriesIndex: 0, // User annotations apply to first series by default\n x: processedSeries[0].x,\n y: processedSeries[0].y,\n });\n }\n\n return peaksWithData;\n}\n\n/**\n * Build the extra content for Plotly hovertemplate from series metadata.\n * Displays all metadata fields as key: value pairs.\n */\nexport function buildHoverExtraContent(\n seriesName: string,\n metadata?: Record<string, unknown>\n): string {\n if (!metadata) return seriesName;\n\n const metaLines: string[] = [];\n for (const [key, value] of Object.entries(metadata)) {\n if (value !== undefined && value !== null && value !== \"\") {\n // Format the key as Title Case (e.g., \"sampleName\" -> \"Sample Name\")\n const formattedKey = key\n .replace(/([A-Z])/g, \" $1\")\n .replace(/^./, (s) => s.toUpperCase())\n .trim();\n metaLines.push(`${formattedKey}: ${String(value)}`);\n }\n }\n\n if (metaLines.length > 0) {\n return `${seriesName}<br>${metaLines.join(\"<br>\")}`;\n }\n return seriesName;\n}\n\n/**\n * Validate and sanitize series data.\n * - Ensures x and y arrays have the same length (truncates to shorter)\n * - Replaces NaN and Infinity values with 0\n */\nexport function validateSeriesData(\n x: number[],\n y: number[]\n): { x: number[]; y: number[] } {\n // Ensure arrays have same length\n const length = Math.min(x.length, y.length);\n const validX = x.slice(0, length);\n const validY = y.slice(0, length);\n\n // Sanitize NaN and Infinity values\n const sanitizedY = validY.map((val) => (Number.isFinite(val) ? val : 0));\n const sanitizedX = validX.map((val) => (Number.isFinite(val) ? val : 0));\n\n return { x: sanitizedX, y: sanitizedY };\n}\n\n/**\n * Apply baseline correction to signal data\n */\nexport function applyBaselineCorrection(\n y: number[],\n method: BaselineCorrectionMethod,\n windowSize: number = 50\n): number[] {\n if (method === \"none\" || y.length === 0) return y;\n\n if (method === \"linear\") {\n // Linear baseline from first to last point\n // Handle single-point case to avoid division by zero\n if (y.length === 1) {\n return [0]; // Single point baseline-corrected to zero\n }\n const slope = (y[y.length - 1] - y[0]) / (y.length - 1);\n return y.map((val, i) => val - (y[0] + slope * i));\n }\n\n if (method === \"rolling\") {\n // Rolling minimum baseline\n const baseline: number[] = [];\n const halfWindow = Math.floor(windowSize / 2);\n\n for (let i = 0; i < y.length; i++) {\n const start = Math.max(0, i - halfWindow);\n const end = Math.min(y.length, i + halfWindow + 1);\n const windowSlice = y.slice(start, end);\n baseline.push(Math.min(...windowSlice));\n }\n\n return y.map((val, i) => val - baseline[i]);\n }\n\n return y;\n}\n\n"],"names":["findClosestIndex","arr","target","left","right","mid","processUserAnnotations","annotations","xArray","yArray","ann","startIndex","endIndex","index","area","calculatePeakArea","collectPeaksWithBoundaryData","allDetectedPeaks","processedSeries","peaksWithData","peaks","seriesIndex","annotationsWithBoundaries","validateSeriesData","x","y","length","validX","sanitizedY","val","applyBaselineCorrection","method","windowSize","slope","baseline","halfWindow","start","end","windowSlice","i"],"mappings":"uHAsBO,SAASA,EAAiBC,EAAeC,EAAwB,CAEtE,GADID,EAAI,SAAW,GACfA,EAAI,SAAW,EAAG,MAAO,GAE7B,IAAIE,EAAO,EACPC,EAAQH,EAAI,OAAS,EAEzB,KAAOE,EAAOC,GAAO,CACnB,MAAMC,EAAM,KAAK,OAA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calculatePeakArea as h } from "./peakDetection.js";
|
|
2
|
+
function c(t, o) {
|
|
3
3
|
if (t.length === 0 || t.length === 1) return 0;
|
|
4
4
|
let e = 0, n = t.length - 1;
|
|
5
5
|
for (; e < n; ) {
|
|
6
|
-
const
|
|
7
|
-
t[
|
|
6
|
+
const l = Math.floor((e + n) / 2);
|
|
7
|
+
t[l] < o ? e = l + 1 : n = l;
|
|
8
8
|
}
|
|
9
|
-
return e > 0 && Math.abs(t[e - 1] -
|
|
9
|
+
return e > 0 && Math.abs(t[e - 1] - o) < Math.abs(t[e] - o) ? e - 1 : e;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function d(t, o, e) {
|
|
12
12
|
return t.map((n) => {
|
|
13
13
|
if (n.startX !== void 0 && n.endX !== void 0) {
|
|
14
|
-
const
|
|
14
|
+
const l = c(o, n.startX), i = c(o, n.endX), s = c(o, n.x), a = n._computed?.area ?? h(o, e, l, i);
|
|
15
15
|
return {
|
|
16
16
|
...n,
|
|
17
17
|
_computed: {
|
|
18
18
|
...n._computed,
|
|
19
|
-
index:
|
|
20
|
-
startIndex:
|
|
21
|
-
endIndex:
|
|
22
|
-
area:
|
|
19
|
+
index: s,
|
|
20
|
+
startIndex: l,
|
|
21
|
+
endIndex: i,
|
|
22
|
+
area: a
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
return n;
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function f(t, o, e) {
|
|
30
30
|
const n = [];
|
|
31
|
-
t.forEach(({ peaks:
|
|
31
|
+
t.forEach(({ peaks: i, seriesIndex: s }) => {
|
|
32
32
|
n.push({
|
|
33
|
-
peaks:
|
|
34
|
-
seriesIndex:
|
|
35
|
-
x: e[
|
|
36
|
-
y: e[
|
|
33
|
+
peaks: i,
|
|
34
|
+
seriesIndex: s,
|
|
35
|
+
x: e[s].x,
|
|
36
|
+
y: e[s].y
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
|
-
const
|
|
40
|
-
(
|
|
39
|
+
const l = o.filter(
|
|
40
|
+
(i) => i._computed?.startIndex !== void 0 && i._computed?.endIndex !== void 0
|
|
41
41
|
);
|
|
42
|
-
return
|
|
43
|
-
peaks:
|
|
42
|
+
return l.length > 0 && e.length > 0 && n.push({
|
|
43
|
+
peaks: l,
|
|
44
44
|
seriesIndex: 0,
|
|
45
45
|
// User annotations apply to first series by default
|
|
46
46
|
x: e[0].x,
|
|
47
47
|
y: e[0].y
|
|
48
48
|
}), n;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
for (const [n, o] of Object.entries(i))
|
|
54
|
-
if (o != null && o !== "") {
|
|
55
|
-
const l = n.replace(/([A-Z])/g, " $1").replace(/^./, (r) => r.toUpperCase()).trim();
|
|
56
|
-
e.push(`${l}: ${String(o)}`);
|
|
57
|
-
}
|
|
58
|
-
return e.length > 0 ? `${t}<br>${e.join("<br>")}` : t;
|
|
59
|
-
}
|
|
60
|
-
function g(t, i) {
|
|
61
|
-
const e = Math.min(t.length, i.length), n = t.slice(0, e), l = i.slice(0, e).map((c) => Number.isFinite(c) ? c : 0);
|
|
62
|
-
return { x: n.map((c) => Number.isFinite(c) ? c : 0), y: l };
|
|
50
|
+
function m(t, o) {
|
|
51
|
+
const e = Math.min(t.length, o.length), n = t.slice(0, e), i = o.slice(0, e).map((a) => Number.isFinite(a) ? a : 0);
|
|
52
|
+
return { x: n.map((a) => Number.isFinite(a) ? a : 0), y: i };
|
|
63
53
|
}
|
|
64
|
-
function
|
|
65
|
-
if (
|
|
66
|
-
if (
|
|
54
|
+
function p(t, o, e = 50) {
|
|
55
|
+
if (o === "none" || t.length === 0) return t;
|
|
56
|
+
if (o === "linear") {
|
|
67
57
|
if (t.length === 1)
|
|
68
58
|
return [0];
|
|
69
59
|
const n = (t[t.length - 1] - t[0]) / (t.length - 1);
|
|
70
|
-
return t.map((
|
|
60
|
+
return t.map((l, i) => l - (t[0] + n * i));
|
|
71
61
|
}
|
|
72
|
-
if (
|
|
73
|
-
const n = [],
|
|
74
|
-
for (let
|
|
75
|
-
const
|
|
62
|
+
if (o === "rolling") {
|
|
63
|
+
const n = [], l = Math.floor(e / 2);
|
|
64
|
+
for (let i = 0; i < t.length; i++) {
|
|
65
|
+
const s = Math.max(0, i - l), a = Math.min(t.length, i + l + 1), u = t.slice(s, a);
|
|
76
66
|
n.push(Math.min(...u));
|
|
77
67
|
}
|
|
78
|
-
return t.map((
|
|
68
|
+
return t.map((i, s) => i - n[s]);
|
|
79
69
|
}
|
|
80
70
|
return t;
|
|
81
71
|
}
|
|
82
72
|
export {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
g as validateSeriesData
|
|
73
|
+
p as applyBaselineCorrection,
|
|
74
|
+
f as collectPeaksWithBoundaryData,
|
|
75
|
+
c as findClosestIndex,
|
|
76
|
+
d as processUserAnnotations,
|
|
77
|
+
m as validateSeriesData
|
|
89
78
|
};
|
|
90
79
|
//# sourceMappingURL=dataProcessing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataProcessing.js","sources":["../../../../src/components/charts/ChromatogramChart/dataProcessing.ts"],"sourcesContent":["/**\n * Data processing utilities for ChromatogramChart\n */\n\nimport { calculatePeakArea } from \"./peakDetection\";\n\nimport type { BaselineCorrectionMethod, PeakAnnotation } from \"./types\";\n\n/**\n * Data structure for peaks with their associated series data\n */\nexport type PeakDataWithSeries = {\n peaks: PeakAnnotation[];\n seriesIndex: number;\n x: number[];\n y: number[];\n};\n\n/**\n * Find the closest index in an array for a given target value.\n * Uses binary search for efficiency.\n */\nexport function findClosestIndex(arr: number[], target: number): number {\n if (arr.length === 0) return 0;\n if (arr.length === 1) return 0;\n\n let left = 0;\n let right = arr.length - 1;\n\n while (left < right) {\n const mid = Math.floor((left + right) / 2);\n if (arr[mid] < target) {\n left = mid + 1;\n } else {\n right = mid;\n }\n }\n\n // Check if left-1 is closer\n if (left > 0 && Math.abs(arr[left - 1] - target) < Math.abs(arr[left] - target)) {\n return left - 1;\n }\n return left;\n}\n\n/**\n * Process user annotations to convert startX/endX to startIndex/endIndex\n * and compute area if boundaries are provided.\n */\nexport function processUserAnnotations(\n annotations: PeakAnnotation[],\n xArray: number[],\n yArray: number[]\n): PeakAnnotation[] {\n return annotations.map((ann) => {\n // If startX/endX are provided, convert to indices\n if (ann.startX !== undefined && ann.endX !== undefined) {\n const startIndex = findClosestIndex(xArray, ann.startX);\n const endIndex = findClosestIndex(xArray, ann.endX);\n const index = findClosestIndex(xArray, ann.x);\n\n // Calculate area if not provided\n const area = ann._computed?.area ?? calculatePeakArea(xArray, yArray, startIndex, endIndex);\n\n return {\n ...ann,\n _computed: {\n ...ann._computed,\n index,\n startIndex,\n endIndex,\n area,\n },\n };\n }\n return ann;\n });\n}\n\n/**\n * Collect peaks with boundary information from both auto-detected peaks and user-provided annotations.\n * User-provided annotations with startIndex/endIndex or startX/endX are included for boundary marker rendering.\n */\nexport function collectPeaksWithBoundaryData(\n allDetectedPeaks: { peaks: PeakAnnotation[]; seriesIndex: number }[],\n annotations: PeakAnnotation[],\n processedSeries: { x: number[]; y: number[] }[]\n): PeakDataWithSeries[] {\n const peaksWithData: PeakDataWithSeries[] = [];\n\n // Add auto-detected peaks\n allDetectedPeaks.forEach(({ peaks, seriesIndex }) => {\n peaksWithData.push({\n peaks,\n seriesIndex,\n x: processedSeries[seriesIndex].x,\n y: processedSeries[seriesIndex].y,\n });\n });\n\n // Add user-provided annotations that have boundary info (_computed.startIndex and _computed.endIndex)\n // Note: annotations with startX/endX should already be processed to have _computed fields\n const annotationsWithBoundaries = annotations.filter(\n (ann) => ann._computed?.startIndex !== undefined && ann._computed?.endIndex !== undefined\n );\n if (annotationsWithBoundaries.length > 0 && processedSeries.length > 0) {\n peaksWithData.push({\n peaks: annotationsWithBoundaries,\n seriesIndex: 0, // User annotations apply to first series by default\n x: processedSeries[0].x,\n y: processedSeries[0].y,\n });\n }\n\n return peaksWithData;\n}\n\n/**\n * Build the extra content for Plotly hovertemplate from series metadata.\n * Displays all metadata fields as key: value pairs.\n */\nexport function buildHoverExtraContent(\n seriesName: string,\n metadata?: Record<string, unknown>\n): string {\n if (!metadata) return seriesName;\n\n const metaLines: string[] = [];\n for (const [key, value] of Object.entries(metadata)) {\n if (value !== undefined && value !== null && value !== \"\") {\n // Format the key as Title Case (e.g., \"sampleName\" -> \"Sample Name\")\n const formattedKey = key\n .replace(/([A-Z])/g, \" $1\")\n .replace(/^./, (s) => s.toUpperCase())\n .trim();\n metaLines.push(`${formattedKey}: ${String(value)}`);\n }\n }\n\n if (metaLines.length > 0) {\n return `${seriesName}<br>${metaLines.join(\"<br>\")}`;\n }\n return seriesName;\n}\n\n/**\n * Validate and sanitize series data.\n * - Ensures x and y arrays have the same length (truncates to shorter)\n * - Replaces NaN and Infinity values with 0\n */\nexport function validateSeriesData(\n x: number[],\n y: number[]\n): { x: number[]; y: number[] } {\n // Ensure arrays have same length\n const length = Math.min(x.length, y.length);\n const validX = x.slice(0, length);\n const validY = y.slice(0, length);\n\n // Sanitize NaN and Infinity values\n const sanitizedY = validY.map((val) => (Number.isFinite(val) ? val : 0));\n const sanitizedX = validX.map((val) => (Number.isFinite(val) ? val : 0));\n\n return { x: sanitizedX, y: sanitizedY };\n}\n\n/**\n * Apply baseline correction to signal data\n */\nexport function applyBaselineCorrection(\n y: number[],\n method: BaselineCorrectionMethod,\n windowSize: number = 50\n): number[] {\n if (method === \"none\" || y.length === 0) return y;\n\n if (method === \"linear\") {\n // Linear baseline from first to last point\n // Handle single-point case to avoid division by zero\n if (y.length === 1) {\n return [0]; // Single point baseline-corrected to zero\n }\n const slope = (y[y.length - 1] - y[0]) / (y.length - 1);\n return y.map((val, i) => val - (y[0] + slope * i));\n }\n\n if (method === \"rolling\") {\n // Rolling minimum baseline\n const baseline: number[] = [];\n const halfWindow = Math.floor(windowSize / 2);\n\n for (let i = 0; i < y.length; i++) {\n const start = Math.max(0, i - halfWindow);\n const end = Math.min(y.length, i + halfWindow + 1);\n const windowSlice = y.slice(start, end);\n baseline.push(Math.min(...windowSlice));\n }\n\n return y.map((val, i) => val - baseline[i]);\n }\n\n return y;\n}\n\n"],"names":["findClosestIndex","arr","target","left","right","mid","processUserAnnotations","annotations","xArray","yArray","ann","startIndex","endIndex","index","area","calculatePeakArea","collectPeaksWithBoundaryData","allDetectedPeaks","processedSeries","peaksWithData","peaks","seriesIndex","annotationsWithBoundaries","
|
|
1
|
+
{"version":3,"file":"dataProcessing.js","sources":["../../../../src/components/charts/ChromatogramChart/dataProcessing.ts"],"sourcesContent":["/**\n * Data processing utilities for ChromatogramChart\n */\n\nimport { calculatePeakArea } from \"./peakDetection\";\n\nimport type { BaselineCorrectionMethod, PeakAnnotation } from \"./types\";\n\n/**\n * Data structure for peaks with their associated series data\n */\nexport type PeakDataWithSeries = {\n peaks: PeakAnnotation[];\n seriesIndex: number;\n x: number[];\n y: number[];\n};\n\n/**\n * Find the closest index in an array for a given target value.\n * Uses binary search for efficiency.\n */\nexport function findClosestIndex(arr: number[], target: number): number {\n if (arr.length === 0) return 0;\n if (arr.length === 1) return 0;\n\n let left = 0;\n let right = arr.length - 1;\n\n while (left < right) {\n const mid = Math.floor((left + right) / 2);\n if (arr[mid] < target) {\n left = mid + 1;\n } else {\n right = mid;\n }\n }\n\n // Check if left-1 is closer\n if (left > 0 && Math.abs(arr[left - 1] - target) < Math.abs(arr[left] - target)) {\n return left - 1;\n }\n return left;\n}\n\n/**\n * Process user annotations to convert startX/endX to startIndex/endIndex\n * and compute area if boundaries are provided.\n */\nexport function processUserAnnotations(\n annotations: PeakAnnotation[],\n xArray: number[],\n yArray: number[]\n): PeakAnnotation[] {\n return annotations.map((ann) => {\n // If startX/endX are provided, convert to indices\n if (ann.startX !== undefined && ann.endX !== undefined) {\n const startIndex = findClosestIndex(xArray, ann.startX);\n const endIndex = findClosestIndex(xArray, ann.endX);\n const index = findClosestIndex(xArray, ann.x);\n\n // Calculate area if not provided\n const area = ann._computed?.area ?? calculatePeakArea(xArray, yArray, startIndex, endIndex);\n\n return {\n ...ann,\n _computed: {\n ...ann._computed,\n index,\n startIndex,\n endIndex,\n area,\n },\n };\n }\n return ann;\n });\n}\n\n/**\n * Collect peaks with boundary information from both auto-detected peaks and user-provided annotations.\n * User-provided annotations with startIndex/endIndex or startX/endX are included for boundary marker rendering.\n */\nexport function collectPeaksWithBoundaryData(\n allDetectedPeaks: { peaks: PeakAnnotation[]; seriesIndex: number }[],\n annotations: PeakAnnotation[],\n processedSeries: { x: number[]; y: number[] }[]\n): PeakDataWithSeries[] {\n const peaksWithData: PeakDataWithSeries[] = [];\n\n // Add auto-detected peaks\n allDetectedPeaks.forEach(({ peaks, seriesIndex }) => {\n peaksWithData.push({\n peaks,\n seriesIndex,\n x: processedSeries[seriesIndex].x,\n y: processedSeries[seriesIndex].y,\n });\n });\n\n // Add user-provided annotations that have boundary info (_computed.startIndex and _computed.endIndex)\n // Note: annotations with startX/endX should already be processed to have _computed fields\n const annotationsWithBoundaries = annotations.filter(\n (ann) => ann._computed?.startIndex !== undefined && ann._computed?.endIndex !== undefined\n );\n if (annotationsWithBoundaries.length > 0 && processedSeries.length > 0) {\n peaksWithData.push({\n peaks: annotationsWithBoundaries,\n seriesIndex: 0, // User annotations apply to first series by default\n x: processedSeries[0].x,\n y: processedSeries[0].y,\n });\n }\n\n return peaksWithData;\n}\n\n/**\n * Build the extra content for Plotly hovertemplate from series metadata.\n * Displays all metadata fields as key: value pairs.\n */\nexport function buildHoverExtraContent(\n seriesName: string,\n metadata?: Record<string, unknown>\n): string {\n if (!metadata) return seriesName;\n\n const metaLines: string[] = [];\n for (const [key, value] of Object.entries(metadata)) {\n if (value !== undefined && value !== null && value !== \"\") {\n // Format the key as Title Case (e.g., \"sampleName\" -> \"Sample Name\")\n const formattedKey = key\n .replace(/([A-Z])/g, \" $1\")\n .replace(/^./, (s) => s.toUpperCase())\n .trim();\n metaLines.push(`${formattedKey}: ${String(value)}`);\n }\n }\n\n if (metaLines.length > 0) {\n return `${seriesName}<br>${metaLines.join(\"<br>\")}`;\n }\n return seriesName;\n}\n\n/**\n * Validate and sanitize series data.\n * - Ensures x and y arrays have the same length (truncates to shorter)\n * - Replaces NaN and Infinity values with 0\n */\nexport function validateSeriesData(\n x: number[],\n y: number[]\n): { x: number[]; y: number[] } {\n // Ensure arrays have same length\n const length = Math.min(x.length, y.length);\n const validX = x.slice(0, length);\n const validY = y.slice(0, length);\n\n // Sanitize NaN and Infinity values\n const sanitizedY = validY.map((val) => (Number.isFinite(val) ? val : 0));\n const sanitizedX = validX.map((val) => (Number.isFinite(val) ? val : 0));\n\n return { x: sanitizedX, y: sanitizedY };\n}\n\n/**\n * Apply baseline correction to signal data\n */\nexport function applyBaselineCorrection(\n y: number[],\n method: BaselineCorrectionMethod,\n windowSize: number = 50\n): number[] {\n if (method === \"none\" || y.length === 0) return y;\n\n if (method === \"linear\") {\n // Linear baseline from first to last point\n // Handle single-point case to avoid division by zero\n if (y.length === 1) {\n return [0]; // Single point baseline-corrected to zero\n }\n const slope = (y[y.length - 1] - y[0]) / (y.length - 1);\n return y.map((val, i) => val - (y[0] + slope * i));\n }\n\n if (method === \"rolling\") {\n // Rolling minimum baseline\n const baseline: number[] = [];\n const halfWindow = Math.floor(windowSize / 2);\n\n for (let i = 0; i < y.length; i++) {\n const start = Math.max(0, i - halfWindow);\n const end = Math.min(y.length, i + halfWindow + 1);\n const windowSlice = y.slice(start, end);\n baseline.push(Math.min(...windowSlice));\n }\n\n return y.map((val, i) => val - baseline[i]);\n }\n\n return y;\n}\n\n"],"names":["findClosestIndex","arr","target","left","right","mid","processUserAnnotations","annotations","xArray","yArray","ann","startIndex","endIndex","index","area","calculatePeakArea","collectPeaksWithBoundaryData","allDetectedPeaks","processedSeries","peaksWithData","peaks","seriesIndex","annotationsWithBoundaries","validateSeriesData","x","y","length","validX","sanitizedY","val","applyBaselineCorrection","method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,IAAI,GAAG,IAAIP,EAAE,QAAQ,KAAK;AACjC,YAAMW,IAAQ,KAAK,IAAI,GAAG,IAAID,CAAU,GAClCE,IAAM,KAAK,IAAIZ,EAAE,QAAQ,IAAIU,IAAa,CAAC,GAC3CG,IAAcb,EAAE,MAAMW,GAAOC,CAAG;AACtC,MAAAH,EAAS,KAAK,KAAK,IAAI,GAAGI,CAAW,CAAC;AAAA,IACxC;AAEA,WAAOb,EAAE,IAAI,CAACI,GAAKU,MAAMV,IAAMK,EAASK,CAAC,CAAC;AAAA,EAC5C;AAEA,SAAOd;AACT;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("react/jsx-runtime"),P=require("plotly.js-dist"),e=require("react"),q=require("../ChartTooltip/ChartTooltip.cjs"),R=require("../../../hooks/use-plotly-theme.cjs"),I=require("../../../utils/colors.cjs"),v=({dataSeries:l,width:i=1e3,height:p=600,title:d="Dot Plot",xTitle:c="Columns",yTitle:a="Rows",variant:g="default",markerSize:u=8})=>{const r=e.useRef(null),t=R.usePlotlyTheme(),{bindTooltip:h,tooltipElement:k}=q.useChartTooltip({xLabel:c,yLabel:a}),x=e.useMemo(()=>Array.isArray(l)?l:[l],[l]),n=I.CHART_COLORS,f=e.useMemo(()=>["circle","square","diamond","triangle-up","triangle-down","star"],[]),b=e.useMemo(()=>x.map((o,s)=>g==="default"?{...o,color:o.color||n[0],symbol:"circle",size:o.size||u}:{...o,color:o.color||n[s%n.length],symbol:o.symbol||f[s%f.length],size:o.size||u}),[x,g,u,n,f]),m=t.gridColor,C=e.useMemo(()=>b.map(o=>({type:"scatter",x:o.x,y:o.y,mode:"markers",name:o.name,marker:{color:o.color,size:o.size,symbol:o.symbol,line:{color:t.paperBg,width:1}},hoverinfo:"none"})),[b,t]),y=e.useMemo(()=>({tickcolor:t.tickColor,ticklen:12,tickwidth:1,ticks:"outside",tickfont:{size:16,color:t.textColor,family:"Inter, sans-serif",weight:400},linecolor:t.lineColor,linewidth:1,position:0,zeroline:!1}),[t]),w=e.useMemo(()=>({text:d,x:.5,y:.95,xanchor:"center",yanchor:"top",font:{size:32,weight:600,family:"Inter, sans-serif",color:t.textColor,lineheight:1.2,standoff:30}}),[d,t]);return e.useEffect(()=>{if(!r.current)return;const o={width:i,height:p,font:{family:"Inter, sans-serif"},title:w,margin:{l:80,r:40,b:80,t:80,pad:0},showlegend:!0,legend:{x:.5,y:-.2,xanchor:"center",yanchor:"top",orientation:"h",font:{size:13,color:t.legendColor,family:"Inter, sans-serif",weight:500,lineheight:18}},xaxis:{title:{text:c,font:{size:16,color:t.textSecondary,family:"Inter, sans-serif",weight:400},standoff:15},gridcolor:m,...y},yaxis:{title:{text:a,font:{size:16,color:t.textSecondary,family:"Inter, sans-serif",weight:400},standoff:15},gridcolor:m,...y},paper_bgcolor:t.paperBg,plot_bgcolor:t.plotBg},s={responsive:!0,displayModeBar:!1,displaylogo:!1};P.newPlot(r.current,C,o,s),h(r.current);const z=r.current;return()=>{z&&P.purge(z)}},[i,p,c,a,C,w,y,m,t,h]),M.jsxs("div",{className:"dotplot-container relative",style:{width:i},children:[M.jsx("div",{ref:r,style:{width:"100%",height:"100%",margin:"0"}}),k]})};exports.DotPlot=v;
|
|
2
2
|
//# sourceMappingURL=DotPlot.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DotPlot.cjs","sources":["../../../../src/components/charts/DotPlot/DotPlot.tsx"],"sourcesContent":["import Plotly from \"plotly.js-dist\";\nimport React, { useEffect, useRef, useMemo } from \"react\";\n\nimport { usePlotlyTheme } from \"@/hooks/use-plotly-theme\";\nimport {
|
|
1
|
+
{"version":3,"file":"DotPlot.cjs","sources":["../../../../src/components/charts/DotPlot/DotPlot.tsx"],"sourcesContent":["import Plotly from \"plotly.js-dist\";\nimport React, { useEffect, useRef, useMemo } from \"react\";\n\nimport { useChartTooltip } from \"../ChartTooltip\";\n\nimport { usePlotlyTheme } from \"@/hooks/use-plotly-theme\";\nimport { CHART_COLORS } from \"@/utils/colors\";\n\ntype MarkerSymbol =\n | \"circle\"\n | \"square\"\n | \"diamond\"\n | \"triangle-up\"\n | \"triangle-down\"\n | \"star\";\n\ninterface DotPlotDataSeries {\n x: number[];\n y: number[];\n name: string;\n color?: string;\n symbol?: MarkerSymbol;\n size?: number;\n}\n\ntype DotPlotVariant = \"default\" | \"stacked\";\n\ntype DotPlotProps = {\n dataSeries: DotPlotDataSeries | DotPlotDataSeries[];\n width?: number;\n height?: number;\n title?: string;\n xTitle?: string;\n yTitle?: string;\n variant?: DotPlotVariant;\n markerSize?: number;\n};\n\nconst DotPlot: React.FC<DotPlotProps> = ({\n dataSeries,\n width = 1000,\n height = 600,\n title = \"Dot Plot\",\n xTitle = \"Columns\",\n yTitle = \"Rows\",\n variant = \"default\",\n markerSize = 8,\n}) => {\n const plotRef = useRef<HTMLDivElement>(null);\n const theme = usePlotlyTheme();\n const { bindTooltip, tooltipElement } = useChartTooltip({ xLabel: xTitle, yLabel: yTitle });\n const seriesArray = useMemo(\n () => (Array.isArray(dataSeries) ? dataSeries : [dataSeries]),\n [dataSeries],\n );\n\n const defaultColors = CHART_COLORS;\n\n const defaultSymbols: MarkerSymbol[] = useMemo(\n () => [\n \"circle\",\n \"square\",\n \"diamond\",\n \"triangle-up\",\n \"triangle-down\",\n \"star\",\n ],\n [],\n );\n\n const seriesWithColors = useMemo(() => {\n return seriesArray.map((series, index) => {\n if (variant === \"default\") {\n // Default variant: all circles, use first color or series color\n return {\n ...series,\n color: series.color || defaultColors[0],\n symbol: \"circle\" as MarkerSymbol,\n size: series.size || markerSize,\n };\n } else {\n // Stacked variant: different symbols and colors for each series\n return {\n ...series,\n color: series.color || defaultColors[index % defaultColors.length],\n symbol:\n series.symbol || defaultSymbols[index % defaultSymbols.length],\n size: series.size || markerSize,\n };\n }\n });\n }, [seriesArray, variant, markerSize, defaultColors, defaultSymbols]);\n\n const gridColor = theme.gridColor;\n\n const plotData = useMemo(\n () =>\n seriesWithColors.map((series) => ({\n type: \"scatter\" as const,\n x: series.x,\n y: series.y,\n mode: \"markers\" as const,\n name: series.name,\n marker: {\n color: series.color,\n size: series.size,\n symbol: series.symbol,\n line: {\n color: theme.paperBg,\n width: 1,\n },\n },\n hoverinfo: \"none\" as const,\n })),\n [seriesWithColors, theme],\n );\n\n const tickOptions = useMemo(\n () => ({\n tickcolor: theme.tickColor,\n ticklen: 12,\n tickwidth: 1,\n ticks: \"outside\" as const,\n tickfont: {\n size: 16,\n color: theme.textColor,\n family: \"Inter, sans-serif\",\n weight: 400,\n },\n linecolor: theme.lineColor,\n linewidth: 1,\n position: 0,\n zeroline: false,\n }),\n [theme],\n );\n\n const titleOptions = useMemo(\n () => ({\n text: title,\n x: 0.5,\n y: 0.95,\n xanchor: \"center\" as const,\n yanchor: \"top\" as const,\n font: {\n size: 32,\n weight: 600,\n family: \"Inter, sans-serif\",\n color: theme.textColor,\n lineheight: 1.2,\n standoff: 30,\n },\n }),\n [title, theme],\n );\n\n useEffect(() => {\n if (!plotRef.current) return;\n\n const layout = {\n width,\n height,\n font: {\n family: \"Inter, sans-serif\",\n },\n title: titleOptions,\n margin: { l: 80, r: 40, b: 80, t: 80, pad: 0 },\n showlegend: true,\n legend: {\n x: 0.5,\n y: -0.2,\n xanchor: \"center\" as const,\n yanchor: \"top\" as const,\n orientation: \"h\" as const,\n font: {\n size: 13,\n color: theme.legendColor,\n family: \"Inter, sans-serif\",\n weight: 500,\n lineheight: 18,\n },\n },\n xaxis: {\n title: {\n text: xTitle,\n font: {\n size: 16,\n color: theme.textSecondary,\n family: \"Inter, sans-serif\",\n weight: 400,\n },\n standoff: 15,\n },\n gridcolor: gridColor,\n ...tickOptions,\n },\n yaxis: {\n title: {\n text: yTitle,\n font: {\n size: 16,\n color: theme.textSecondary,\n family: \"Inter, sans-serif\",\n weight: 400,\n },\n standoff: 15,\n },\n gridcolor: gridColor,\n ...tickOptions,\n },\n paper_bgcolor: theme.paperBg,\n plot_bgcolor: theme.plotBg,\n };\n\n const config = {\n responsive: true,\n displayModeBar: false,\n displaylogo: false,\n };\n\n Plotly.newPlot(plotRef.current, plotData, layout, config);\n bindTooltip(plotRef.current);\n\n // Capture ref value for cleanup\n const plotElement = plotRef.current;\n\n return () => {\n if (plotElement) {\n Plotly.purge(plotElement);\n }\n };\n }, [width, height, xTitle, yTitle, plotData, titleOptions, tickOptions, gridColor, theme, bindTooltip]);\n\n return (\n <div className=\"dotplot-container relative\" style={{ width: width }}>\n <div\n ref={plotRef}\n style={{\n width: \"100%\",\n height: \"100%\",\n margin: \"0\",\n }}\n />\n {tooltipElement}\n </div>\n );\n};\n\nexport { DotPlot };\nexport type { DotPlotDataSeries, DotPlotProps, DotPlotVariant, MarkerSymbol };\n"],"names":["DotPlot","dataSeries","width","height","title","xTitle","yTitle","variant","markerSize","plotRef","useRef","theme","usePlotlyTheme","bindTooltip","tooltipElement","useChartTooltip","seriesArray","useMemo","defaultColors","CHART_COLORS","defaultSymbols","seriesWithColors","series","index","gridColor","plotData","tickOptions","titleOptions","useEffect","layout","config","Plotly","plotElement","jsx"],"mappings":"0SAsCMA,EAAkC,CAAC,CACvC,WAAAC,EACA,MAAAC,EAAQ,IACR,OAAAC,EAAS,IACT,MAAAC,EAAQ,WACR,OAAAC,EAAS,UACT,OAAAC,EAAS,OACT,QAAAC,EAAU,UACV,WAAAC,EAAa,CACf,IAAM,CACJ,MAAMC,EAAUC,EAAAA,OAAuB,IAAI,EACrCC,EAAQC,EAAAA,eAAA,EACR,CAAE,YAAAC,EAAa,eAAAC,CAAA,EAAmBC,EAAAA,gBAAgB,CAAE,OAAQV,EAAQ,OAAQC,EAAQ,EACpFU,EAAcC,EAAAA,QAClB,IAAO,MAAM,QAAQhB,CAAU,EAAIA,EAAa,CAACA,CAAU,EAC3D,CAACA,CAAU,CAAA,EAGPiB,EAAgBC,EAAAA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