@opencx/widget-react 5.0.0-beta.7 → 5.0.0-beta.9
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/Chart.impl-BOItNccb.js +207 -0
- package/dist/Chart.impl-BOItNccb.js.map +1 -0
- package/dist/Chart.impl-DfwpmxVg.cjs +2 -0
- package/dist/Chart.impl-DfwpmxVg.cjs.map +1 -0
- package/dist/index-BQvciEuH.cjs +347 -0
- package/dist/index-BQvciEuH.cjs.map +1 -0
- package/dist/{index-D_f1MZUH.js → index-CYVpvKPr.js} +5894 -5191
- package/dist/index-CYVpvKPr.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/package.json.d.ts +1 -1
- package/dist/src/components/PageActionCard.d.ts +17 -0
- package/dist/src/components/PageActionCard.d.ts.map +1 -0
- package/dist/src/components/StreamingTurn.d.ts +7 -1
- package/dist/src/components/StreamingTurn.d.ts.map +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/json-render/Chart.impl.d.ts.map +1 -1
- package/dist/src/json-render/SpecRenderer.d.ts +6 -1
- package/dist/src/json-render/SpecRenderer.d.ts.map +1 -1
- package/dist/src/json-render/StreamingShimmer.d.ts +12 -0
- package/dist/src/json-render/StreamingShimmer.d.ts.map +1 -0
- package/dist/src/json-render/chart-axis.d.ts +30 -0
- package/dist/src/json-render/chart-axis.d.ts.map +1 -0
- package/dist/src/json-render/registry.d.ts.map +1 -1
- package/dist/src/json-render/segment-content.d.ts +14 -6
- package/dist/src/json-render/segment-content.d.ts.map +1 -1
- package/dist/src/page-controls/accessible-name.d.ts +23 -0
- package/dist/src/page-controls/accessible-name.d.ts.map +1 -0
- package/dist/src/page-controls/act-input.d.ts +18 -0
- package/dist/src/page-controls/act-input.d.ts.map +1 -0
- package/dist/src/page-controls/act-types.d.ts +43 -0
- package/dist/src/page-controls/act-types.d.ts.map +1 -0
- package/dist/src/page-controls/act.d.ts +8 -0
- package/dist/src/page-controls/act.d.ts.map +1 -0
- package/dist/src/page-controls/control-ref.d.ts +28 -0
- package/dist/src/page-controls/control-ref.d.ts.map +1 -0
- package/dist/src/page-controls/cursor.d.ts +72 -0
- package/dist/src/page-controls/cursor.d.ts.map +1 -0
- package/dist/src/page-controls/guard.d.ts +47 -0
- package/dist/src/page-controls/guard.d.ts.map +1 -0
- package/dist/src/page-controls/native-setter.d.ts +16 -0
- package/dist/src/page-controls/native-setter.d.ts.map +1 -0
- package/dist/src/page-controls/needs-consent.d.ts +15 -0
- package/dist/src/page-controls/needs-consent.d.ts.map +1 -0
- package/dist/src/page-controls/off-limits.d.ts +16 -0
- package/dist/src/page-controls/off-limits.d.ts.map +1 -0
- package/dist/src/page-controls/pointer-sequence.d.ts +14 -0
- package/dist/src/page-controls/pointer-sequence.d.ts.map +1 -0
- package/dist/src/page-controls/read-controls.d.ts +4 -0
- package/dist/src/page-controls/read-controls.d.ts.map +1 -0
- package/dist/src/page-controls/send-context.d.ts +20 -0
- package/dist/src/page-controls/send-context.d.ts.map +1 -0
- package/dist/src/page-controls/types.d.ts +52 -0
- package/dist/src/page-controls/types.d.ts.map +1 -0
- package/dist/src/page-marks/agent-mark.d.ts +6 -5
- package/dist/src/page-marks/agent-mark.d.ts.map +1 -1
- package/dist/src/screens/chat/ChatInput.d.ts.map +1 -1
- package/dist/src/screens/chat/agent/AgentChatPageActions.d.ts +13 -0
- package/dist/src/screens/chat/agent/AgentChatPageActions.d.ts.map +1 -0
- package/dist/src/screens/chat/agent/AgentChatPageEffects.d.ts.map +1 -1
- package/dist/src/screens/chat/agent/useStreamFollow.d.ts +4 -0
- package/dist/src/screens/chat/agent/useStreamFollow.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/Chart.impl-C-1c9nkk.js +0 -153
- package/dist/Chart.impl-C-1c9nkk.js.map +0 -1
- package/dist/Chart.impl-Ck7Md2bC.cjs +0 -2
- package/dist/Chart.impl-Ck7Md2bC.cjs.map +0 -1
- package/dist/index-B3pRBUF2.cjs +0 -343
- package/dist/index-B3pRBUF2.cjs.map +0 -1
- package/dist/index-D_f1MZUH.js.map +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the agent knows about the controls on the customer's page.
|
|
3
|
+
*
|
|
4
|
+
* The widget reads the page itself and sends NAMES. The elements never
|
|
5
|
+
* leave the browser: each one is held here behind an opaque reference, and
|
|
6
|
+
* every later instruction — point at this, click that — comes back as one of
|
|
7
|
+
* those references. Nothing the agent says can name a node we did not offer
|
|
8
|
+
* it in this turn.
|
|
9
|
+
*
|
|
10
|
+
* What is deliberately absent: values. Not the text in a field, not the
|
|
11
|
+
* option a select is on, not a password, not a file name. A support agent
|
|
12
|
+
* needs to know that a "Change plan" button exists and is greyed out; it
|
|
13
|
+
* never needs to know what the visitor typed into "Card number".
|
|
14
|
+
*/
|
|
15
|
+
/** One control on the host page, as the agent reads it. */
|
|
16
|
+
export type PageControl = {
|
|
17
|
+
/** Opaque handle for this turn. The agent points with it; only we resolve it. */
|
|
18
|
+
ref: string;
|
|
19
|
+
/** What the control IS: button, link, textbox, checkbox, … (ARIA role). */
|
|
20
|
+
role: string;
|
|
21
|
+
/** The control's accessible name — the words a screen reader would say. */
|
|
22
|
+
name: string;
|
|
23
|
+
/** Present and true only when the control cannot be used right now. */
|
|
24
|
+
disabled?: true;
|
|
25
|
+
};
|
|
26
|
+
/** One turn's reading of the page: the controls, and the table behind them. */
|
|
27
|
+
export type PageControlSnapshot = {
|
|
28
|
+
controls: PageControl[];
|
|
29
|
+
/** Whether the page had more controls than the cap allowed us to send. */
|
|
30
|
+
truncated: boolean;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Attribute a customer puts on any part of their page the agent must never
|
|
34
|
+
* read. Everything inside is skipped whole — the control, its name, its
|
|
35
|
+
* existence. The one thing a page owner can say that the reader obeys
|
|
36
|
+
* without interpretation.
|
|
37
|
+
*/
|
|
38
|
+
export declare const PRIVATE_REGION_ATTRIBUTE = "data-opencx-private";
|
|
39
|
+
/**
|
|
40
|
+
* Input types the reader refuses on sight, whatever else is true about them:
|
|
41
|
+
* a password is never described, and a file picker's name can carry the
|
|
42
|
+
* visitor's own file names.
|
|
43
|
+
*/
|
|
44
|
+
export declare const NEVER_READ_INPUT_TYPES: Set<string>;
|
|
45
|
+
/**
|
|
46
|
+
* How many controls one message carries. A page with more than this is read
|
|
47
|
+
* in full (so the cap applies to the busiest part, not a random prefix) but
|
|
48
|
+
* sends only the first `MAX_CONTROLS` in document order, and says so.
|
|
49
|
+
* Chosen against the prompt, not the DOM: 300 names is roughly 3k tokens.
|
|
50
|
+
*/
|
|
51
|
+
export declare const MAX_CONTROLS = 300;
|
|
52
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/page-controls/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,2DAA2D;AAC3D,MAAM,MAAM,WAAW,GAAG;IACxB,iFAAiF;IACjF,GAAG,EAAE,MAAM,CAAC;IACZ,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAC;IACb,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,QAAQ,CAAC,EAAE,IAAI,CAAC;CACjB,CAAC;AAEF,+EAA+E;AAC/E,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,0EAA0E;IAC1E,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,wBAAwB,CAAC;AAE9D;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,aAA0C,CAAC;AAE9E;;;;;GAKG;AACH,eAAO,MAAM,YAAY,MAAM,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const highlightElementInputSchema: z.ZodObject<{
|
|
3
|
-
|
|
4
|
-
text: z.ZodOptional<z.ZodString>;
|
|
3
|
+
ref: z.ZodString;
|
|
5
4
|
label: z.ZodOptional<z.ZodString>;
|
|
6
5
|
type: z.ZodCatch<z.ZodOptional<z.ZodEnum<{
|
|
7
6
|
circle: "circle";
|
|
@@ -22,10 +21,12 @@ export declare function dismissActiveHighlight(): void;
|
|
|
22
21
|
* smooth scroll), and float an optional pointing callout. The page stays fully
|
|
23
22
|
* interactive throughout — nothing is dimmed and no click is trapped.
|
|
24
23
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* Takes the element, not a way of finding one: WHICH element is the caller's
|
|
25
|
+
* decision (`guardRef` — the reference the reader handed out, checked to be
|
|
26
|
+
* the same node, on screen and not covered). The pen only draws. Returns
|
|
27
|
+
* false when the ink could not be laid down at all.
|
|
27
28
|
*/
|
|
28
|
-
export declare function highlightElementOnHostPage(input: HighlightElementInput, { accentColor, surfaceColor, foregroundColor, zIndex, durationMs, seed, }?: {
|
|
29
|
+
export declare function highlightElementOnHostPage(el: HTMLElement, input: Omit<HighlightElementInput, 'ref'>, { accentColor, surfaceColor, foregroundColor, zIndex, durationMs, seed, }?: {
|
|
29
30
|
accentColor?: string;
|
|
30
31
|
surfaceColor?: string;
|
|
31
32
|
foregroundColor?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-mark.d.ts","sourceRoot":"","sources":["../../../src/page-marks/agent-mark.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-mark.d.ts","sourceRoot":"","sources":["../../../src/page-marks/agent-mark.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAuCxB,eAAO,MAAM,2BAA2B;;;;;;;;;;iBAetC,CAAC;AAEH,KAAK,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEzE,2FAA2F;AAC3F,eAAO,MAAM,6BAA6B,OAAO,CAAC;AA2BlD,yEAAyE;AACzE,wBAAgB,sBAAsB,SAErC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CACxC,EAAE,EAAE,WAAW,EACf,KAAK,EAAE,IAAI,CAAC,qBAAqB,EAAE,KAAK,CAAC,EACzC,EACE,WAA4B,EAC5B,YAA6B,EAC7B,eAAiC,EACjC,MAAmB,EACnB,UAA0C,EAC1C,IAAI,GACL,GAAE;IACD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;CACV,GACL,OAAO,CAsLT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatInput.d.ts","sourceRoot":"","sources":["../../../../src/screens/chat/ChatInput.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAuD,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ChatInput.d.ts","sourceRoot":"","sources":["../../../../src/screens/chat/ChatInput.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAuD,MAAM,OAAO,CAAC;AA8C5E;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,EACxB,eAAe,EACf,WAAW,EACX,eAAe,GAChB,GAAE;IACD;;;;OAIG;IACH,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAClC;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CACtB,qBA2qBL"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The agent's hands on the host page.
|
|
3
|
+
*
|
|
4
|
+
* Three things happen here and nowhere else: the visitor is asked before
|
|
5
|
+
* anything that commits, the action is performed against the element the
|
|
6
|
+
* reference resolves to, and the turn is told what actually happened.
|
|
7
|
+
*
|
|
8
|
+
* Every path answers the waiting call exactly once. A refusal, a decline, a
|
|
9
|
+
* click that changed nothing — all of them are answers, because the one
|
|
10
|
+
* thing the agent must never do is fill a silence with a success.
|
|
11
|
+
*/
|
|
12
|
+
export declare function AgentChatPageActions(): null;
|
|
13
|
+
//# sourceMappingURL=AgentChatPageActions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentChatPageActions.d.ts","sourceRoot":"","sources":["../../../../../src/screens/chat/agent/AgentChatPageActions.tsx"],"names":[],"mappings":"AAaA;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,SA2EnC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentChatPageEffects.d.ts","sourceRoot":"","sources":["../../../../../src/screens/chat/agent/AgentChatPageEffects.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AgentChatPageEffects.d.ts","sourceRoot":"","sources":["../../../../../src/screens/chat/agent/AgentChatPageEffects.tsx"],"names":[],"mappings":"AAeA;;;;;;GAMG;AACH,wBAAgB,oBAAoB,SAsGnC"}
|
|
@@ -18,6 +18,10 @@ export type StreamFollow = {
|
|
|
18
18
|
*
|
|
19
19
|
* `followKey` is the dependency list whose changes represent "new content"
|
|
20
20
|
* (e.g. `[messages, liveItems]`); the follow effect re-runs on each change.
|
|
21
|
+
* Content that grows WITHOUT a `followKey` change — a lazily loaded chart
|
|
22
|
+
* chunk resolving, an image decoding, a reopened session's historical turn
|
|
23
|
+
* source landing from its own fetch — is followed through a `ResizeObserver`
|
|
24
|
+
* on the container's rows (below), never through timers.
|
|
21
25
|
*/
|
|
22
26
|
export declare function useStreamFollow(followKey: DependencyList): StreamFollow;
|
|
23
27
|
//# sourceMappingURL=useStreamFollow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStreamFollow.d.ts","sourceRoot":"","sources":["../../../../../src/screens/chat/agent/useStreamFollow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;AAGf,MAAM,MAAM,YAAY,GAAG;IACzB,sCAAsC;IACtC,YAAY,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAC/C,4CAA4C;IAC5C,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB;+CAC2C;IAC3C,cAAc,EAAE,OAAO,CAAC;IACxB,2EAA2E;IAC3E,cAAc,EAAE,MAAM,IAAI,CAAC;CAC5B,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"useStreamFollow.d.ts","sourceRoot":"","sources":["../../../../../src/screens/chat/agent/useStreamFollow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;AAGf,MAAM,MAAM,YAAY,GAAG;IACzB,sCAAsC;IACtC,YAAY,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAC/C,4CAA4C;IAC5C,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB;+CAC2C;IAC3C,cAAc,EAAE,OAAO,CAAC;IACxB,2EAA2E;IAC3E,cAAc,EAAE,MAAM,IAAI,CAAC;CAC5B,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,cAAc,GAAG,YAAY,CAgFvE"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opencx/widget-react",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "5.0.0-beta.
|
|
4
|
+
"version": "5.0.0-beta.9",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"tailwind-merge": "^2.4.0",
|
|
41
41
|
"tinycolor2": "^1.6.0",
|
|
42
42
|
"zod": "^4.3.6",
|
|
43
|
-
"@opencx/widget-
|
|
44
|
-
"@opencx/widget-
|
|
43
|
+
"@opencx/widget-react-headless": "5.0.0-beta.9",
|
|
44
|
+
"@opencx/widget-core": "5.0.0-beta.9"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@types/react": ">=18 <20",
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { jsx as e, jsxs as s } from "react/jsx-runtime";
|
|
2
|
-
import d from "react";
|
|
3
|
-
import { PieChart as b, Tooltip as f, Legend as S, Pie as k, Cell as C, Label as R, LineChart as v, CartesianGrid as p, XAxis as y, YAxis as g, Line as z, BarChart as O, Bar as _ } from "recharts";
|
|
4
|
-
import { u as K } from "./index-D_f1MZUH.js";
|
|
5
|
-
function A() {
|
|
6
|
-
const t = d.useRef(null), [n, c] = d.useState(0);
|
|
7
|
-
return d.useLayoutEffect(() => {
|
|
8
|
-
const r = t.current;
|
|
9
|
-
if (!r) return;
|
|
10
|
-
const i = () => c(r.clientWidth);
|
|
11
|
-
i();
|
|
12
|
-
const l = new ResizeObserver(i);
|
|
13
|
-
return l.observe(r), () => l.disconnect();
|
|
14
|
-
}, []), { ref: t, width: n };
|
|
15
|
-
}
|
|
16
|
-
const L = "hsl(var(--opencx-foreground, 240 10% 20%))", x = [90, 70, 50, 30].map(
|
|
17
|
-
(t) => `color-mix(in oklch, ${L} ${t}%, transparent)`
|
|
18
|
-
), u = (t) => x[t % x.length] ?? L, h = {
|
|
19
|
-
borderRadius: 8,
|
|
20
|
-
border: "1px solid color-mix(in oklch, currentColor 15%, transparent)",
|
|
21
|
-
fontSize: 12
|
|
22
|
-
};
|
|
23
|
-
function P({
|
|
24
|
-
type: t,
|
|
25
|
-
data: n,
|
|
26
|
-
height: c,
|
|
27
|
-
centerLabel: r
|
|
28
|
-
}) {
|
|
29
|
-
const i = c ?? 220, { ref: l, width: a } = A();
|
|
30
|
-
return n.length === 0 ? /* @__PURE__ */ e(T, { height: i }) : /* @__PURE__ */ e("div", { ref: l, className: "w-full text-foreground", style: { height: i }, children: a > 0 && (t === "pie" ? /* @__PURE__ */ s(b, { width: a, height: i, children: [
|
|
31
|
-
/* @__PURE__ */ e(f, { contentStyle: h }),
|
|
32
|
-
/* @__PURE__ */ e(
|
|
33
|
-
S,
|
|
34
|
-
{
|
|
35
|
-
verticalAlign: "bottom",
|
|
36
|
-
iconType: "circle",
|
|
37
|
-
iconSize: 8,
|
|
38
|
-
wrapperStyle: { fontSize: 12 }
|
|
39
|
-
}
|
|
40
|
-
),
|
|
41
|
-
/* @__PURE__ */ s(
|
|
42
|
-
k,
|
|
43
|
-
{
|
|
44
|
-
data: n,
|
|
45
|
-
dataKey: "value",
|
|
46
|
-
nameKey: "label",
|
|
47
|
-
outerRadius: "85%",
|
|
48
|
-
innerRadius: "60%",
|
|
49
|
-
children: [
|
|
50
|
-
n.map((o, m) => /* @__PURE__ */ e(C, { fill: u(m) }, m)),
|
|
51
|
-
r && /* @__PURE__ */ e(
|
|
52
|
-
R,
|
|
53
|
-
{
|
|
54
|
-
position: "center",
|
|
55
|
-
content: ({ viewBox: o }) => {
|
|
56
|
-
if (o && "cx" in o && "cy" in o)
|
|
57
|
-
return /* @__PURE__ */ e(
|
|
58
|
-
"text",
|
|
59
|
-
{
|
|
60
|
-
x: o.cx,
|
|
61
|
-
y: o.cy,
|
|
62
|
-
textAnchor: "middle",
|
|
63
|
-
dominantBaseline: "middle",
|
|
64
|
-
className: "fill-foreground text-2xl font-medium",
|
|
65
|
-
children: r
|
|
66
|
-
}
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
)
|
|
71
|
-
]
|
|
72
|
-
}
|
|
73
|
-
)
|
|
74
|
-
] }) : t === "line" ? /* @__PURE__ */ s(
|
|
75
|
-
v,
|
|
76
|
-
{
|
|
77
|
-
width: a,
|
|
78
|
-
height: i,
|
|
79
|
-
data: n,
|
|
80
|
-
margin: { top: 8, right: 8, bottom: 0, left: -16 },
|
|
81
|
-
children: [
|
|
82
|
-
/* @__PURE__ */ e(p, { strokeOpacity: 0.15, vertical: !1 }),
|
|
83
|
-
/* @__PURE__ */ e(
|
|
84
|
-
y,
|
|
85
|
-
{
|
|
86
|
-
dataKey: "label",
|
|
87
|
-
tickLine: !1,
|
|
88
|
-
axisLine: !1,
|
|
89
|
-
tickMargin: 10,
|
|
90
|
-
fontSize: 11
|
|
91
|
-
}
|
|
92
|
-
),
|
|
93
|
-
/* @__PURE__ */ e(g, { tickLine: !1, axisLine: !1, fontSize: 11, width: 32 }),
|
|
94
|
-
/* @__PURE__ */ e(f, { contentStyle: h }),
|
|
95
|
-
/* @__PURE__ */ e(
|
|
96
|
-
z,
|
|
97
|
-
{
|
|
98
|
-
type: "monotone",
|
|
99
|
-
dataKey: "value",
|
|
100
|
-
stroke: u(0),
|
|
101
|
-
strokeWidth: 2,
|
|
102
|
-
dot: !1
|
|
103
|
-
}
|
|
104
|
-
)
|
|
105
|
-
]
|
|
106
|
-
}
|
|
107
|
-
) : /* @__PURE__ */ s(
|
|
108
|
-
O,
|
|
109
|
-
{
|
|
110
|
-
width: a,
|
|
111
|
-
height: i,
|
|
112
|
-
data: n,
|
|
113
|
-
margin: { top: 8, right: 8, bottom: 0, left: -16 },
|
|
114
|
-
children: [
|
|
115
|
-
/* @__PURE__ */ e(p, { strokeOpacity: 0.15, vertical: !1 }),
|
|
116
|
-
/* @__PURE__ */ e(
|
|
117
|
-
y,
|
|
118
|
-
{
|
|
119
|
-
dataKey: "label",
|
|
120
|
-
tickLine: !1,
|
|
121
|
-
axisLine: !1,
|
|
122
|
-
tickMargin: 10,
|
|
123
|
-
fontSize: 11
|
|
124
|
-
}
|
|
125
|
-
),
|
|
126
|
-
/* @__PURE__ */ e(g, { tickLine: !1, axisLine: !1, fontSize: 11, width: 32 }),
|
|
127
|
-
/* @__PURE__ */ e(
|
|
128
|
-
f,
|
|
129
|
-
{
|
|
130
|
-
contentStyle: h,
|
|
131
|
-
cursor: { fillOpacity: 0.06 }
|
|
132
|
-
}
|
|
133
|
-
),
|
|
134
|
-
/* @__PURE__ */ e(_, { dataKey: "value", fill: u(0), radius: [4, 4, 0, 0] })
|
|
135
|
-
]
|
|
136
|
-
}
|
|
137
|
-
)) });
|
|
138
|
-
}
|
|
139
|
-
function T({ height: t }) {
|
|
140
|
-
const { t: n } = K();
|
|
141
|
-
return /* @__PURE__ */ e(
|
|
142
|
-
"div",
|
|
143
|
-
{
|
|
144
|
-
className: "flex w-full items-center justify-center rounded-lg border border-muted-foreground/15 text-xs text-muted-foreground",
|
|
145
|
-
style: { height: t },
|
|
146
|
-
children: n("json_no_chart_data")
|
|
147
|
-
}
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
export {
|
|
151
|
-
P as default
|
|
152
|
-
};
|
|
153
|
-
//# sourceMappingURL=Chart.impl-C-1c9nkk.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Chart.impl-C-1c9nkk.js","sources":["../src/json-render/Chart.impl.tsx"],"sourcesContent":["import React from 'react';\nimport {\n Bar,\n BarChart,\n CartesianGrid,\n Cell,\n Label,\n Legend,\n Line,\n LineChart,\n Pie,\n PieChart,\n Tooltip,\n XAxis,\n YAxis,\n} from 'recharts';\nimport type { ChartProps } from './props';\nimport { useJsonRenderHost } from './host';\n\n/**\n * Measure the wrapper width ourselves instead of relying on recharts'\n * `ResponsiveContainer`. On recharts 2.12 that container renders an empty,\n * svg-less box whenever it mounts measuring 0 — which is exactly this case: the\n * chart is a `React.lazy` chunk that mounts after the widget popover has laid\n * out, and it never re-measures on its own. Feeding recharts an explicit numeric\n * width sidesteps the trap; the `ResizeObserver` keeps it in sync when the embed\n * is resized.\n */\nfunction useContainerWidth(): {\n ref: React.RefObject<HTMLDivElement | null>;\n width: number;\n} {\n const ref = React.useRef<HTMLDivElement>(null);\n const [width, setWidth] = React.useState(0);\n React.useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n const update = () => setWidth(el.clientWidth);\n update();\n const observer = new ResizeObserver(update);\n observer.observe(el);\n return () => observer.disconnect();\n }, []);\n return { ref, width };\n}\n\n/**\n * The actual chart renderer. Loaded lazily (see `Chart.tsx`) so recharts — the\n * one heavy dependency in the registry — is a separate chunk that only downloads\n * when the agent actually emits a Chart.\n *\n * Styled to match the companion/Impact-Dashboard charts: a monochrome ramp of\n * the theme foreground (90/70/50/30% alpha), donut pie with an optional center\n * label + legend, and clean axes (no tick/axis lines). The ramp reads the\n * widget's `--opencx-foreground` token so charts follow the embed theme, with\n * a neutral fallback for any context where the token is missing.\n */\n\nconst FOREGROUND = 'hsl(var(--opencx-foreground, 240 10% 20%))';\n// Same ramp as the dashboard's REPORTS_COLOR (surface-foreground at 90/70/50/30%).\nconst RAMP = [90, 70, 50, 30].map(\n (pct) => `color-mix(in oklch, ${FOREGROUND} ${pct}%, transparent)`,\n);\nconst rampColor = (i: number): string => RAMP[i % RAMP.length] ?? FOREGROUND;\n\nconst TOOLTIP_STYLE: React.CSSProperties = {\n borderRadius: 8,\n border: '1px solid color-mix(in oklch, currentColor 15%, transparent)',\n fontSize: 12,\n};\n\nexport default function ChartImpl({\n type,\n data,\n height,\n centerLabel,\n}: ChartProps) {\n const h = height ?? 220;\n const { ref, width } = useContainerWidth();\n\n if (data.length === 0) {\n return <ChartEmpty height={h} />;\n }\n\n return (\n <div ref={ref} className=\"w-full text-foreground\" style={{ height: h }}>\n {width > 0 &&\n (type === 'pie' ? (\n <PieChart width={width} height={h}>\n <Tooltip contentStyle={TOOLTIP_STYLE} />\n <Legend\n verticalAlign=\"bottom\"\n iconType=\"circle\"\n iconSize={8}\n wrapperStyle={{ fontSize: 12 }}\n />\n <Pie\n data={data}\n dataKey=\"value\"\n nameKey=\"label\"\n outerRadius=\"85%\"\n innerRadius=\"60%\"\n >\n {data.map((_, i) => (\n <Cell key={i} fill={rampColor(i)} />\n ))}\n {centerLabel && (\n <Label\n position=\"center\"\n content={({ viewBox }) => {\n if (viewBox && 'cx' in viewBox && 'cy' in viewBox) {\n return (\n <text\n x={viewBox.cx}\n y={viewBox.cy}\n textAnchor=\"middle\"\n dominantBaseline=\"middle\"\n className=\"fill-foreground text-2xl font-medium\"\n >\n {centerLabel}\n </text>\n );\n }\n }}\n />\n )}\n </Pie>\n </PieChart>\n ) : type === 'line' ? (\n <LineChart\n width={width}\n height={h}\n data={data}\n margin={{ top: 8, right: 8, bottom: 0, left: -16 }}\n >\n <CartesianGrid strokeOpacity={0.15} vertical={false} />\n <XAxis\n dataKey=\"label\"\n tickLine={false}\n axisLine={false}\n tickMargin={10}\n fontSize={11}\n />\n <YAxis tickLine={false} axisLine={false} fontSize={11} width={32} />\n <Tooltip contentStyle={TOOLTIP_STYLE} />\n <Line\n type=\"monotone\"\n dataKey=\"value\"\n stroke={rampColor(0)}\n strokeWidth={2}\n dot={false}\n />\n </LineChart>\n ) : (\n <BarChart\n width={width}\n height={h}\n data={data}\n margin={{ top: 8, right: 8, bottom: 0, left: -16 }}\n >\n <CartesianGrid strokeOpacity={0.15} vertical={false} />\n <XAxis\n dataKey=\"label\"\n tickLine={false}\n axisLine={false}\n tickMargin={10}\n fontSize={11}\n />\n <YAxis tickLine={false} axisLine={false} fontSize={11} width={32} />\n <Tooltip\n contentStyle={TOOLTIP_STYLE}\n cursor={{ fillOpacity: 0.06 }}\n />\n <Bar dataKey=\"value\" fill={rampColor(0)} radius={[4, 4, 0, 0]} />\n </BarChart>\n ))}\n </div>\n );\n}\n\nfunction ChartEmpty({ height }: { height: number }) {\n const { t } = useJsonRenderHost();\n return (\n <div\n className=\"flex w-full items-center justify-center rounded-lg border border-muted-foreground/15 text-xs text-muted-foreground\"\n style={{ height }}\n >\n {t('json_no_chart_data')}\n </div>\n );\n}\n"],"names":["useContainerWidth","ref","React","width","setWidth","el","update","observer","FOREGROUND","RAMP","pct","rampColor","i","TOOLTIP_STYLE","ChartImpl","type","data","height","centerLabel","h","jsx","ChartEmpty","PieChart","Tooltip","Legend","jsxs","Pie","_","Cell","Label","viewBox","LineChart","CartesianGrid","XAxis","YAxis","Line","BarChart","Bar","t","useJsonRenderHost"],"mappings":";;;;AA4BA,SAASA,IAGP;AACA,QAAMC,IAAMC,EAAM,OAAuB,IAAI,GACvC,CAACC,GAAOC,CAAQ,IAAIF,EAAM,SAAS,CAAC;AAC1CA,SAAAA,EAAM,gBAAgB,MAAM;AAC1B,UAAMG,IAAKJ,EAAI;AACf,QAAI,CAACI,EAAI;AACT,UAAMC,IAAS,MAAMF,EAASC,EAAG,WAAW;AAC5C,IAAAC,EAAA;AACA,UAAMC,IAAW,IAAI,eAAeD,CAAM;AAC1C,WAAAC,EAAS,QAAQF,CAAE,GACZ,MAAME,EAAS,WAAA;AAAA,EACxB,GAAG,CAAA,CAAE,GACE,EAAE,KAAAN,GAAK,OAAAE,EAAA;AAChB;AAcA,MAAMK,IAAa,8CAEbC,IAAO,CAAC,IAAI,IAAI,IAAI,EAAE,EAAE;AAAA,EAC5B,CAACC,MAAQ,uBAAuBF,CAAU,IAAIE,CAAG;AACnD,GACMC,IAAY,CAACC,MAAsBH,EAAKG,IAAIH,EAAK,MAAM,KAAKD,GAE5DK,IAAqC;AAAA,EACzC,cAAc;AAAA,EACd,QAAQ;AAAA,EACR,UAAU;AACZ;AAEA,SAAwBC,EAAU;AAAA,EAChC,MAAAC;AAAA,EACA,MAAAC;AAAA,EACA,QAAAC;AAAA,EACA,aAAAC;AACF,GAAe;AACb,QAAMC,IAAIF,KAAU,KACd,EAAE,KAAAhB,GAAK,OAAAE,EAAA,IAAUH,EAAA;AAEvB,SAAIgB,EAAK,WAAW,IACX,gBAAAI,EAACC,GAAA,EAAW,QAAQF,EAAA,CAAG,sBAI7B,OAAA,EAAI,KAAAlB,GAAU,WAAU,0BAAyB,OAAO,EAAE,QAAQk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AAM1B,EAAU,CAAC,GAAG,QAAQ,CAAC,GAAG,GAAG,GAAG,CAAC,EAAA,CAAG;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,IAGvE;AAEJ;AAEA,SAASU,EAAW,EAAE,QAAAJ,KAA8B;AAClD,QAAM,EAAE,GAAAqB,EAAA,IAAMC,EAAA;AACd,SACE,gBAAAnB;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAU;AAAA,MACV,OAAO,EAAE,QAAAH,EAAA;AAAA,MAER,YAAE,oBAAoB;AAAA,IAAA;AAAA,EAAA;AAG7B;"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("react"),t=require("recharts"),j=require("./index-B3pRBUF2.cjs");function p(){const i=d.useRef(null),[n,c]=d.useState(0);return d.useLayoutEffect(()=>{const s=i.current;if(!s)return;const r=()=>c(s.clientWidth);r();const l=new ResizeObserver(r);return l.observe(s),()=>l.disconnect()},[]),{ref:i,width:n}}const m="hsl(var(--opencx-foreground, 240 10% 20%))",h=[90,70,50,30].map(i=>`color-mix(in oklch, ${m} ${i}%, transparent)`),u=i=>h[i%h.length]??m,f={borderRadius:8,border:"1px solid color-mix(in oklch, currentColor 15%, transparent)",fontSize:12};function y({type:i,data:n,height:c,centerLabel:s}){const r=c??220,{ref:l,width:a}=p();return n.length===0?e.jsx(g,{height:r}):e.jsx("div",{ref:l,className:"w-full text-foreground",style:{height:r},children:a>0&&(i==="pie"?e.jsxs(t.PieChart,{width:a,height:r,children:[e.jsx(t.Tooltip,{contentStyle:f}),e.jsx(t.Legend,{verticalAlign:"bottom",iconType:"circle",iconSize:8,wrapperStyle:{fontSize:12}}),e.jsxs(t.Pie,{data:n,dataKey:"value",nameKey:"label",outerRadius:"85%",innerRadius:"60%",children:[n.map((o,x)=>e.jsx(t.Cell,{fill:u(x)},x)),s&&e.jsx(t.Label,{position:"center",content:({viewBox:o})=>{if(o&&"cx"in o&&"cy"in o)return e.jsx("text",{x:o.cx,y:o.cy,textAnchor:"middle",dominantBaseline:"middle",className:"fill-foreground text-2xl font-medium",children:s})}})]})]}):i==="line"?e.jsxs(t.LineChart,{width:a,height:r,data:n,margin:{top:8,right:8,bottom:0,left:-16},children:[e.jsx(t.CartesianGrid,{strokeOpacity:.15,vertical:!1}),e.jsx(t.XAxis,{dataKey:"label",tickLine:!1,axisLine:!1,tickMargin:10,fontSize:11}),e.jsx(t.YAxis,{tickLine:!1,axisLine:!1,fontSize:11,width:32}),e.jsx(t.Tooltip,{contentStyle:f}),e.jsx(t.Line,{type:"monotone",dataKey:"value",stroke:u(0),strokeWidth:2,dot:!1})]}):e.jsxs(t.BarChart,{width:a,height:r,data:n,margin:{top:8,right:8,bottom:0,left:-16},children:[e.jsx(t.CartesianGrid,{strokeOpacity:.15,vertical:!1}),e.jsx(t.XAxis,{dataKey:"label",tickLine:!1,axisLine:!1,tickMargin:10,fontSize:11}),e.jsx(t.YAxis,{tickLine:!1,axisLine:!1,fontSize:11,width:32}),e.jsx(t.Tooltip,{contentStyle:f,cursor:{fillOpacity:.06}}),e.jsx(t.Bar,{dataKey:"value",fill:u(0),radius:[4,4,0,0]})]}))})}function g({height:i}){const{t:n}=j.useJsonRenderHost();return e.jsx("div",{className:"flex w-full items-center justify-center rounded-lg border border-muted-foreground/15 text-xs text-muted-foreground",style:{height:i},children:n("json_no_chart_data")})}exports.default=y;
|
|
2
|
-
//# sourceMappingURL=Chart.impl-Ck7Md2bC.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Chart.impl-Ck7Md2bC.cjs","sources":["../src/json-render/Chart.impl.tsx"],"sourcesContent":["import React from 'react';\nimport {\n Bar,\n BarChart,\n CartesianGrid,\n Cell,\n Label,\n Legend,\n Line,\n LineChart,\n Pie,\n PieChart,\n Tooltip,\n XAxis,\n YAxis,\n} from 'recharts';\nimport type { ChartProps } from './props';\nimport { useJsonRenderHost } from './host';\n\n/**\n * Measure the wrapper width ourselves instead of relying on recharts'\n * `ResponsiveContainer`. On recharts 2.12 that container renders an empty,\n * svg-less box whenever it mounts measuring 0 — which is exactly this case: the\n * chart is a `React.lazy` chunk that mounts after the widget popover has laid\n * out, and it never re-measures on its own. Feeding recharts an explicit numeric\n * width sidesteps the trap; the `ResizeObserver` keeps it in sync when the embed\n * is resized.\n */\nfunction useContainerWidth(): {\n ref: React.RefObject<HTMLDivElement | null>;\n width: number;\n} {\n const ref = React.useRef<HTMLDivElement>(null);\n const [width, setWidth] = React.useState(0);\n React.useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n const update = () => setWidth(el.clientWidth);\n update();\n const observer = new ResizeObserver(update);\n observer.observe(el);\n return () => observer.disconnect();\n }, []);\n return { ref, width };\n}\n\n/**\n * The actual chart renderer. Loaded lazily (see `Chart.tsx`) so recharts — the\n * one heavy dependency in the registry — is a separate chunk that only downloads\n * when the agent actually emits a Chart.\n *\n * Styled to match the companion/Impact-Dashboard charts: a monochrome ramp of\n * the theme foreground (90/70/50/30% alpha), donut pie with an optional center\n * label + legend, and clean axes (no tick/axis lines). The ramp reads the\n * widget's `--opencx-foreground` token so charts follow the embed theme, with\n * a neutral fallback for any context where the token is missing.\n */\n\nconst FOREGROUND = 'hsl(var(--opencx-foreground, 240 10% 20%))';\n// Same ramp as the dashboard's REPORTS_COLOR (surface-foreground at 90/70/50/30%).\nconst RAMP = [90, 70, 50, 30].map(\n (pct) => `color-mix(in oklch, ${FOREGROUND} ${pct}%, transparent)`,\n);\nconst rampColor = (i: number): string => RAMP[i % RAMP.length] ?? FOREGROUND;\n\nconst TOOLTIP_STYLE: React.CSSProperties = {\n borderRadius: 8,\n border: '1px solid color-mix(in oklch, currentColor 15%, transparent)',\n fontSize: 12,\n};\n\nexport default function ChartImpl({\n type,\n data,\n height,\n centerLabel,\n}: ChartProps) {\n const h = height ?? 220;\n const { ref, width } = useContainerWidth();\n\n if (data.length === 0) {\n return <ChartEmpty height={h} />;\n }\n\n return (\n <div ref={ref} className=\"w-full text-foreground\" style={{ height: h }}>\n {width > 0 &&\n (type === 'pie' ? (\n <PieChart width={width} height={h}>\n <Tooltip contentStyle={TOOLTIP_STYLE} />\n <Legend\n verticalAlign=\"bottom\"\n iconType=\"circle\"\n iconSize={8}\n wrapperStyle={{ fontSize: 12 }}\n />\n <Pie\n data={data}\n dataKey=\"value\"\n nameKey=\"label\"\n outerRadius=\"85%\"\n innerRadius=\"60%\"\n >\n {data.map((_, i) => (\n <Cell key={i} fill={rampColor(i)} />\n ))}\n {centerLabel && (\n <Label\n position=\"center\"\n content={({ viewBox }) => {\n if (viewBox && 'cx' in viewBox && 'cy' in viewBox) {\n return (\n <text\n x={viewBox.cx}\n y={viewBox.cy}\n textAnchor=\"middle\"\n dominantBaseline=\"middle\"\n className=\"fill-foreground text-2xl font-medium\"\n >\n {centerLabel}\n </text>\n );\n }\n }}\n />\n )}\n </Pie>\n </PieChart>\n ) : type === 'line' ? (\n <LineChart\n width={width}\n height={h}\n data={data}\n margin={{ top: 8, right: 8, bottom: 0, left: -16 }}\n >\n <CartesianGrid strokeOpacity={0.15} vertical={false} />\n <XAxis\n dataKey=\"label\"\n tickLine={false}\n axisLine={false}\n tickMargin={10}\n fontSize={11}\n />\n <YAxis tickLine={false} axisLine={false} fontSize={11} width={32} />\n <Tooltip contentStyle={TOOLTIP_STYLE} />\n <Line\n type=\"monotone\"\n dataKey=\"value\"\n stroke={rampColor(0)}\n strokeWidth={2}\n dot={false}\n />\n </LineChart>\n ) : (\n <BarChart\n width={width}\n height={h}\n data={data}\n margin={{ top: 8, right: 8, bottom: 0, left: -16 }}\n >\n <CartesianGrid strokeOpacity={0.15} vertical={false} />\n <XAxis\n dataKey=\"label\"\n tickLine={false}\n axisLine={false}\n tickMargin={10}\n fontSize={11}\n />\n <YAxis tickLine={false} axisLine={false} fontSize={11} width={32} />\n <Tooltip\n contentStyle={TOOLTIP_STYLE}\n cursor={{ fillOpacity: 0.06 }}\n />\n <Bar dataKey=\"value\" fill={rampColor(0)} radius={[4, 4, 0, 0]} />\n </BarChart>\n ))}\n </div>\n );\n}\n\nfunction ChartEmpty({ height }: { height: number }) {\n const { t } = useJsonRenderHost();\n return (\n <div\n className=\"flex w-full items-center justify-center rounded-lg border border-muted-foreground/15 text-xs text-muted-foreground\"\n style={{ height }}\n >\n {t('json_no_chart_data')}\n </div>\n );\n}\n"],"names":["useContainerWidth","ref","React","width","setWidth","el","update","observer","FOREGROUND","RAMP","pct","rampColor","TOOLTIP_STYLE","ChartImpl","type","data","height","centerLabel","h","jsx","ChartEmpty","PieChart","Tooltip","Legend","jsxs","Pie","_","i","Cell","Label","viewBox","LineChart","CartesianGrid","XAxis","YAxis","Line","BarChart","Bar","t","useJsonRenderHost"],"mappings":"gMA4BA,SAASA,GAGP,CACA,MAAMC,EAAMC,EAAM,OAAuB,IAAI,EACvC,CAACC,EAAOC,CAAQ,EAAIF,EAAM,SAAS,CAAC,EAC1C,OAAAA,EAAM,gBAAgB,IAAM,CAC1B,MAAMG,EAAKJ,EAAI,QACf,GAAI,CAACI,EAAI,OACT,MAAMC,EAAS,IAAMF,EAASC,EAAG,WAAW,EAC5CC,EAAA,EACA,MAAMC,EAAW,IAAI,eAAeD,CAAM,EAC1C,OAAAC,EAAS,QAAQF,CAAE,EACZ,IAAME,EAAS,WAAA,CACxB,EAAG,CAAA,CAAE,EACE,CAAE,IAAAN,EAAK,MAAAE,CAAA,CAChB,CAcA,MAAMK,EAAa,6CAEbC,EAAO,CAAC,GAAI,GAAI,GAAI,EAAE,EAAE,IAC3BC,GAAQ,uBAAuBF,CAAU,IAAIE,CAAG,iBACnD,EACMC,EAAa,GAAsBF,EAAK,EAAIA,EAAK,MAAM,GAAKD,EAE5DI,EAAqC,CACzC,aAAc,EACd,OAAQ,+DACR,SAAU,EACZ,EAEA,SAAwBC,EAAU,CAChC,KAAAC,EACA,KAAAC,EACA,OAAAC,EACA,YAAAC,CACF,EAAe,CACb,M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