@opencx/widget-react 5.0.0-beta.0 → 5.0.0-beta.2
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-BnzKZLOH.js → Chart.impl-CweIPST1.js} +2 -2
- package/dist/{Chart.impl-BnzKZLOH.js.map → Chart.impl-CweIPST1.js.map} +1 -1
- package/dist/{Chart.impl-DOSb1NJk.cjs → Chart.impl-DHCOnsVA.cjs} +2 -2
- package/dist/{Chart.impl-DOSb1NJk.cjs.map → Chart.impl-DHCOnsVA.cjs.map} +1 -1
- package/dist/{index-BCiFOCVT.js → index-CBGXjABY.js} +4609 -3675
- package/dist/index-CBGXjABY.js.map +1 -0
- package/dist/index-RZV2KNTv.cjs +343 -0
- package/dist/index-RZV2KNTv.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/package.json.d.ts +2 -1
- package/dist/src/WidgetImperativeHandler.d.ts.map +1 -1
- package/dist/src/__tests__/WidgetImperativeHandler.spec.d.ts +2 -0
- package/dist/src/__tests__/WidgetImperativeHandler.spec.d.ts.map +1 -0
- package/dist/src/__tests__/question-capabilities.spec.d.ts +2 -0
- package/dist/src/__tests__/question-capabilities.spec.d.ts.map +1 -0
- package/dist/src/companion/ChatPicker.d.ts +16 -0
- package/dist/src/companion/ChatPicker.d.ts.map +1 -0
- package/dist/src/companion/CompanionContent.d.ts +1 -3
- package/dist/src/companion/CompanionContent.d.ts.map +1 -1
- package/dist/src/companion/CompanionControlStyles.d.ts +4 -0
- package/dist/src/companion/CompanionControlStyles.d.ts.map +1 -0
- package/dist/src/companion/ConversationTitle.d.ts +4 -0
- package/dist/src/companion/ConversationTitle.d.ts.map +1 -0
- package/dist/src/companion/RestingPill.d.ts +7 -1
- package/dist/src/companion/RestingPill.d.ts.map +1 -1
- package/dist/src/companion/SessionCircles.d.ts +8 -0
- package/dist/src/companion/SessionCircles.d.ts.map +1 -0
- package/dist/src/companion/WidgetCompanion.d.ts.map +1 -1
- package/dist/src/companion/__tests__/companion-chats.spec.d.ts +2 -0
- package/dist/src/companion/__tests__/companion-chats.spec.d.ts.map +1 -0
- package/dist/src/companion/__tests__/companion-open-sync.spec.d.ts +2 -0
- package/dist/src/companion/__tests__/companion-open-sync.spec.d.ts.map +1 -0
- package/dist/src/companion/useChatPicker.d.ts +13 -0
- package/dist/src/companion/useChatPicker.d.ts.map +1 -0
- package/dist/src/companion/useCompanionOpenSync.d.ts +9 -0
- package/dist/src/companion/useCompanionOpenSync.d.ts.map +1 -0
- package/dist/src/companion/usePersistedPillDrag.d.ts.map +1 -1
- package/dist/src/companion/useSessionIdentity.d.ts +8 -0
- package/dist/src/companion/useSessionIdentity.d.ts.map +1 -0
- package/dist/src/components/Header.d.ts.map +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/motion.d.ts +1 -0
- package/dist/src/motion.d.ts.map +1 -1
- package/dist/src/screens/chat/ChatInput.d.ts.map +1 -1
- package/dist/src/screens/chat/__tests__/composer-draft.d.ts +17 -0
- package/dist/src/screens/chat/__tests__/composer-draft.d.ts.map +1 -0
- package/dist/src/screens/chat/useMentions.d.ts.map +1 -1
- package/package.json +4 -3
- package/dist/index-BCiFOCVT.js.map +0 -1
- package/dist/index-CqbztkwP.cjs +0 -234
- package/dist/index-CqbztkwP.cjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as s } from "react/jsx-runtime";
|
|
2
2
|
import d from "react";
|
|
3
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-
|
|
4
|
+
import { u as K } from "./index-CBGXjABY.js";
|
|
5
5
|
function A() {
|
|
6
6
|
const t = d.useRef(null), [n, c] = d.useState(0);
|
|
7
7
|
return d.useLayoutEffect(() => {
|
|
@@ -150,4 +150,4 @@ function T({ height: t }) {
|
|
|
150
150
|
export {
|
|
151
151
|
P as default
|
|
152
152
|
};
|
|
153
|
-
//# sourceMappingURL=Chart.impl-
|
|
153
|
+
//# sourceMappingURL=Chart.impl-CweIPST1.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chart.impl-
|
|
1
|
+
{"version":3,"file":"Chart.impl-CweIPST1.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,UAAM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("recharts"),j=require("./index-
|
|
2
|
-
//# sourceMappingURL=Chart.impl-
|
|
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-RZV2KNTv.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-DHCOnsVA.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chart.impl-
|
|
1
|
+
{"version":3,"file":"Chart.impl-DHCOnsVA.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,MAAMC,EAAIF,GAAU,IACd,CAAE,IAAAf,EAAK,MAAAE,CAAA,EAAUH,EAAA,EAEvB,OAAIe,EAAK,SAAW,EACXI,EAAAA,IAACC,EAAA,CAAW,OAAQF,CAAA,CAAG,QAI7B,MAAA,CAAI,IAAAjB,EAAU,UAAU,yBAAyB,MAAO,CAAE,OAAQiB,GAChE,SAAAf,EAAQ,IACNW,IAAS,aACPO,WAAA,CAAS,MAAAlB,EAAc,OAAQe,EAC9B,SAAA,CAAAC,EAAA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