@flexkit/studio 0.2.2 → 0.2.4
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/activity-nav-button-AESIPODJ.js +2 -0
- package/dist/activity-nav-button-AESIPODJ.js.map +1 -0
- package/dist/chat-page-S2YGOKO5.js +4 -0
- package/dist/{chat-page-YWENJEUP.js.map → chat-page-S2YGOKO5.js.map} +1 -1
- package/dist/chunk-2AHDTE5T.js +2 -0
- package/dist/{chunk-OFLU53AC.js.map → chunk-2AHDTE5T.js.map} +1 -1
- package/dist/chunk-32ZU4MLE.js +2 -0
- package/dist/{chunk-ODORXGGY.js.map → chunk-32ZU4MLE.js.map} +1 -1
- package/dist/chunk-3C2EG3SI.js +2 -0
- package/dist/{chunk-GW37ZTR2.js.map → chunk-3C2EG3SI.js.map} +1 -1
- package/dist/chunk-3TGCCDOR.js +2 -0
- package/dist/chunk-3TGCCDOR.js.map +1 -0
- package/dist/chunk-6NRQMG26.js +2 -0
- package/dist/chunk-6NRQMG26.js.map +1 -0
- package/dist/{chunk-LYGHDJ5A.js → chunk-6RDPFMLK.js} +2 -2
- package/dist/{chunk-LYGHDJ5A.js.map → chunk-6RDPFMLK.js.map} +1 -1
- package/dist/chunk-CKNFYN3O.js +3 -0
- package/dist/chunk-CKNFYN3O.js.map +1 -0
- package/dist/chunk-J2G4C6I5.js +2 -0
- package/dist/chunk-J2G4C6I5.js.map +1 -0
- package/dist/{chunk-7ZDMZVDA.js → chunk-KWS3NAYS.js} +5 -5
- package/dist/{chunk-7ZDMZVDA.js.map → chunk-KWS3NAYS.js.map} +1 -1
- package/dist/chunk-LN55VJ35.js +3 -0
- package/dist/chunk-LN55VJ35.js.map +1 -0
- package/dist/{chunk-Z6IEBNKV.js → chunk-NOFQHWES.js} +2 -2
- package/dist/{chunk-Z6IEBNKV.js.map → chunk-NOFQHWES.js.map} +1 -1
- package/dist/chunk-NYKATVPZ.js +4 -0
- package/dist/{chunk-3FIKCGSP.js.map → chunk-NYKATVPZ.js.map} +1 -1
- package/dist/chunk-PWQPA2QL.js +2 -0
- package/dist/chunk-PWQPA2QL.js.map +1 -0
- package/dist/chunk-SVZY7ZZD.js +8 -0
- package/dist/chunk-SVZY7ZZD.js.map +1 -0
- package/dist/chunk-TWMX2IQ2.js +3 -0
- package/dist/chunk-TWMX2IQ2.js.map +1 -0
- package/dist/chunk-U45E5X3H.js +2 -0
- package/dist/chunk-U45E5X3H.js.map +1 -0
- package/dist/chunk-USNXQOMJ.js +2 -0
- package/dist/chunk-USNXQOMJ.js.map +1 -0
- package/dist/chunk-YCCFUGWJ.js +7 -0
- package/dist/chunk-YCCFUGWJ.js.map +1 -0
- package/dist/index.css +41 -0
- package/dist/index.d.ts +11 -1
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/list-PNKQAYUK.js +2 -0
- package/dist/{list-3K2PBGML.js.map → list-PNKQAYUK.js.map} +1 -1
- package/dist/logo-JAWR6P43.js +2 -0
- package/dist/logo-JAWR6P43.js.map +1 -0
- package/dist/pages-KHFSZ3PH.js +3 -0
- package/dist/pages-KHFSZ3PH.js.map +1 -0
- package/dist/plugin-pages-SE52XFFW.js +2 -0
- package/dist/{plugin-pages-Q77CBW45.js.map → plugin-pages-SE52XFFW.js.map} +1 -1
- package/dist/root-44ZJLA4E.js +2 -0
- package/dist/root-44ZJLA4E.js.map +1 -0
- package/dist/root-BH3PQS2H.js +31 -0
- package/dist/{root-EZWV5VA4.js.map → root-BH3PQS2H.js.map} +1 -1
- package/dist/root-LFQA2VSE.js +2 -0
- package/dist/{root-4TME2KMP.js.map → root-LFQA2VSE.js.map} +1 -1
- package/dist/{root-4ZVGVCYY.js → root-X5NDURAN.js} +10 -10
- package/dist/{root-4ZVGVCYY.js.map → root-X5NDURAN.js.map} +1 -1
- package/dist/search-Q65IC67C.js +2 -0
- package/dist/{search-7NX232AW.js.map → search-Q65IC67C.js.map} +1 -1
- package/dist/skills-pages-TWOIIU5J.js +2 -0
- package/dist/{skills-pages-SMJ4EWZW.js.map → skills-pages-TWOIIU5J.js.map} +1 -1
- package/dist/spec-renderer-EX7SCFWH.js +2 -0
- package/dist/{spec-renderer-5YGDRF52.js.map → spec-renderer-EX7SCFWH.js.map} +1 -1
- package/dist/ui.js +1 -1
- package/dist/user-nav-QZTYBG45.js +2 -0
- package/dist/user-nav-QZTYBG45.js.map +1 -0
- package/package.json +3 -3
- package/dist/chat-page-YWENJEUP.js +0 -4
- package/dist/chunk-2FQWBOU6.js +0 -6
- package/dist/chunk-2FQWBOU6.js.map +0 -1
- package/dist/chunk-3FIKCGSP.js +0 -4
- package/dist/chunk-4BX7OJJ6.js +0 -2
- package/dist/chunk-4BX7OJJ6.js.map +0 -1
- package/dist/chunk-5DHOBLAE.js +0 -2
- package/dist/chunk-5DHOBLAE.js.map +0 -1
- package/dist/chunk-66N44IKJ.js +0 -3
- package/dist/chunk-66N44IKJ.js.map +0 -1
- package/dist/chunk-GW37ZTR2.js +0 -2
- package/dist/chunk-H6TOYVW2.js +0 -3
- package/dist/chunk-H6TOYVW2.js.map +0 -1
- package/dist/chunk-ODORXGGY.js +0 -2
- package/dist/chunk-OFLU53AC.js +0 -2
- package/dist/chunk-YIGEER6B.js +0 -7
- package/dist/chunk-YIGEER6B.js.map +0 -1
- package/dist/list-3K2PBGML.js +0 -2
- package/dist/logo-MU7MGYDH.js +0 -3
- package/dist/logo-MU7MGYDH.js.map +0 -1
- package/dist/pages-BDZ4ZXBS.js +0 -3
- package/dist/pages-BDZ4ZXBS.js.map +0 -1
- package/dist/plugin-pages-Q77CBW45.js +0 -2
- package/dist/root-4TME2KMP.js +0 -2
- package/dist/root-EZWV5VA4.js +0 -31
- package/dist/root-YKNISFWH.js +0 -2
- package/dist/root-YKNISFWH.js.map +0 -1
- package/dist/search-7NX232AW.js +0 -2
- package/dist/skills-pages-SMJ4EWZW.js +0 -2
- package/dist/spec-renderer-5YGDRF52.js +0 -2
- package/dist/user-nav-QZFCICK3.js +0 -2
- package/dist/user-nav-QZFCICK3.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/apps/ai/spec-renderer.tsx"],"names":["cardMaxWidthClasses","Card","children","element","props","maxWidthClass","centeredClass","jsxs","jsx","stackGapClasses","stackAlignClasses","stackJustifyClasses","Stack","directionClass","gapClass","alignClass","justifyClass","gridColumnClasses","gridGapClasses","Grid","columnClass","Separator","headingClasses","Heading","level","textClasses","Text","BadgeComponent","Badge","AlertIcon","type","CheckCircle2Icon","AlertTriangleIcon","XCircleIcon","InfoIcon","Alert","typeClass","Table","columns","rows","row","TableCaption","TableHeader","TableRow","column","index","TableHead","TableBody","rowIndex","cell","cellIndex","TableCell","Progress","max","percent","Skeleton","LinkComponent","ExternalLink","Image","Accordion","item","Tabs","tabs","TabsList","tab","TabsTrigger","TabContent","TabsContent","trendClasses","TrendIcon","trend","TrendingUpIcon","TrendingDownIcon","MinusIcon","Metric","calloutClasses","CalloutIcon","LightbulbIcon","OctagonAlertIcon","Callout","timelineDotClasses","Timeline","items","CHART_COLORS","chartTooltipStyle","chartTooltipItemStyle","chartTooltipLabelStyle","chartTick","toNumber","value","parsed","getChartPoints","data","groups","key","group","x","ChartFrame","height","title","ResponsiveContainer","BarChart","points","color","RechartsBarChart","CartesianGrid","XAxis","YAxis","RechartsTooltip","Bar","LineChart","RechartsLineChart","Line","PieChart","slices","RechartsPieChart","Pie","slice","Cell","Mermaid","chart","diagramId","useId","svg","setSvg","useState","error","setError","useEffect","isCancelled","mermaid","isDark","result","renderError","registry","fallback","getSanitizedChildren","childKeys","elements","seen","childKey","normalizedKey","haveChildrenChanged","original","sanitized","sanitizeSpec","spec","hasChanged","elementKey","elementChildren","hasChildrenChanged","SPEC_DATA_PART_TYPE","dedupeSpecParts","parts","seenPatchLines","deduped","part","payload","line","RunSpecPart","useMemo","builtSpec","buildSpecFromParts","stateKey","StateProvider","VisibilityProvider","ActionProvider","Renderer"],"mappings":"uuBA2DA,IAA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ACvF,IAAMP,CAAAA,CAAOc,QAAQ,IAAM,CACzB,IAAMC,CAAAA,CAAYC,kBAAAA,CAAmBV,EAAAA,CAAgBC,CAAK,CAAC,EAE3D,OAAOQ,CAAAA,CAAYhB,EAAAA,CAAagB,CAAS,CAAA,CAAI,IAC/C,CAAA,CAAG,CAACR,CAAK,CAAC,CAAA,CACJU,CAAAA,CAAWH,OAAAA,CAAQ,IAAM,IAAA,CAAK,SAAA,CAAUd,CAAAA,EAAM,KAAA,EAAS,EAAE,CAAA,CAAG,CAACA,CAAI,CAAC,CAAA,CAExE,OAAKA,CAAAA,CAKH1I,IAAC4J,aAAAA,CAAA,CAAc,YAAA,CAAclB,CAAAA,CAAK,KAAA,CAChC,QAAA,CAAA1I,GAAAA,CAAC6J,kBAAAA,CAAA,CACC,QAAA,CAAA7J,GAAAA,CAAC8J,cAAAA,CAAA,CACC,QAAA,CAAA9J,GAAAA,CAAC+J,QAAAA,CAAA,CAAS,SAAUhC,EAAAA,CAAU,QAAA,CAAUD,EAAAA,CAAU,IAAA,CAAMY,EAAM,CAAA,CAChE,CAAA,CACF,CAAA,CAAA,CAL4CiB,CAM9C,EAVO,IAYX","file":"spec-renderer-5YGDRF52.js","sourcesContent":["import type { JSX } from 'react';\nimport type { ComponentRegistry, ComponentRenderer, Spec } from '@json-render/react';\nimport { useEffect, useId, useMemo, useState } from 'react';\nimport { ActionProvider, Renderer, StateProvider, VisibilityProvider, buildSpecFromParts } from '@json-render/react';\nimport {\n AlertTriangleIcon,\n CheckCircle2Icon,\n InfoIcon,\n LightbulbIcon,\n MinusIcon,\n OctagonAlertIcon,\n TrendingDownIcon,\n TrendingUpIcon,\n XCircleIcon,\n} from 'lucide-react';\nimport {\n Bar,\n BarChart as RechartsBarChart,\n CartesianGrid,\n Cell,\n Line,\n LineChart as RechartsLineChart,\n Pie,\n PieChart as RechartsPieChart,\n ResponsiveContainer,\n Tooltip as RechartsTooltip,\n XAxis,\n YAxis,\n} from 'recharts';\nimport {\n Badge,\n ExternalLink,\n Separator as SeparatorPrimitive,\n Skeleton as SkeletonPrimitive,\n Table as TablePrimitive,\n TableBody,\n TableCaption,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n Tabs as TabsPrimitive,\n TabsContent,\n TabsList,\n TabsTrigger,\n} from '../../ui';\n\n// ---------------------------------------------------------------------------\n// Layout components\n// ---------------------------------------------------------------------------\n\ninterface CardProps {\n centered: boolean | null;\n className: string | null;\n description: string | null;\n maxWidth: 'sm' | 'md' | 'lg' | 'full' | null;\n title: string | null;\n}\n\nconst cardMaxWidthClasses = {\n sm: 'fk:max-w-sm',\n md: 'fk:max-w-md',\n lg: 'fk:max-w-lg',\n full: 'fk:max-w-full',\n};\n\nconst Card: ComponentRenderer<CardProps> = ({ children, element }) => {\n const { props } = element;\n const maxWidthClass = props.maxWidth ? cardMaxWidthClasses[props.maxWidth] : '';\n const centeredClass = props.centered ? 'fk:mx-auto' : '';\n\n return (\n <div\n className={`fk:w-full fk:rounded-lg fk:border fk:border-border fk:bg-card fk:p-4 fk:gap-2 fk:flex fk:flex-col ${maxWidthClass} ${centeredClass} ${props.className ?? ''} fk:corner-squircle`}\n >\n {props.title && <div className=\"fk:text-sm fk:font-medium\">{props.title}</div>}\n {props.description && <div className=\"fk:mt-0.5 fk:text-xs fk:text-muted-foreground\">{props.description}</div>}\n {(props.title ?? props.description) && children ? <div className=\"fk:mt-3\" /> : null}\n {children}\n </div>\n );\n};\n\ninterface StackProps {\n align: 'start' | 'center' | 'end' | 'stretch' | null;\n className: string | null;\n direction: 'horizontal' | 'vertical' | null;\n gap: 'none' | 'sm' | 'md' | 'lg' | 'xl' | null;\n justify: 'start' | 'center' | 'end' | 'between' | 'around' | null;\n}\n\nconst stackGapClasses = {\n none: 'fk:gap-0',\n sm: 'fk:gap-2',\n md: 'fk:gap-3',\n lg: 'fk:gap-4',\n xl: 'fk:gap-6',\n};\n\nconst stackAlignClasses = {\n start: 'fk:items-start',\n center: 'fk:items-center',\n end: 'fk:items-end',\n stretch: 'fk:items-stretch',\n};\n\nconst stackJustifyClasses = {\n start: 'fk:justify-start',\n center: 'fk:justify-center',\n end: 'fk:justify-end',\n between: 'fk:justify-between',\n around: 'fk:justify-around',\n};\n\nconst Stack: ComponentRenderer<StackProps> = ({ children, element }) => {\n const { props } = element;\n const directionClass = props.direction === 'horizontal' ? 'fk:flex-row fk:flex-wrap' : 'fk:flex-col';\n const gapClass = stackGapClasses[props.gap ?? 'md'];\n const alignClass = props.align ? stackAlignClasses[props.align] : '';\n const justifyClass = props.justify ? stackJustifyClasses[props.justify] : '';\n\n return (\n <div\n className={`fk:flex fk:w-full ${directionClass} ${gapClass} ${alignClass} ${justifyClass} ${props.className ?? ''}`}\n >\n {children}\n </div>\n );\n};\n\ninterface GridProps {\n className: string | null;\n columns: number | null;\n gap: 'sm' | 'md' | 'lg' | 'xl' | null;\n}\n\nconst gridColumnClasses: { [columns: number]: string } = {\n 1: 'fk:grid-cols-1',\n 2: 'fk:grid-cols-2',\n 3: 'fk:grid-cols-3',\n 4: 'fk:grid-cols-4',\n 5: 'fk:grid-cols-5',\n 6: 'fk:grid-cols-6',\n};\n\nconst gridGapClasses = {\n sm: 'fk:gap-2',\n md: 'fk:gap-3',\n lg: 'fk:gap-4',\n xl: 'fk:gap-6',\n};\n\nconst Grid: ComponentRenderer<GridProps> = ({ children, element }) => {\n const { props } = element;\n const columnClass = gridColumnClasses[props.columns ?? 1] ?? 'fk:grid-cols-1';\n const gapClass = gridGapClasses[props.gap ?? 'md'];\n\n return <div className={`fk:grid fk:w-full ${columnClass} ${gapClass} ${props.className ?? ''}`}>{children}</div>;\n};\n\nconst Separator: ComponentRenderer<{ orientation: 'horizontal' | 'vertical' | null }> = ({ element }) => (\n <SeparatorPrimitive orientation={element.props.orientation ?? 'horizontal'} />\n);\n\n// ---------------------------------------------------------------------------\n// Typography and content components\n// ---------------------------------------------------------------------------\n\ninterface HeadingProps {\n level: 'h1' | 'h2' | 'h3' | 'h4' | null;\n text: string;\n}\n\nconst headingClasses = {\n h1: 'fk:text-xl fk:font-semibold fk:tracking-tight',\n h2: 'fk:text-lg fk:font-semibold fk:tracking-tight',\n h3: 'fk:text-base fk:font-medium',\n h4: 'fk:text-sm fk:font-medium',\n};\n\nconst Heading: ComponentRenderer<HeadingProps> = ({ element }) => {\n const level = element.props.level ?? 'h2';\n const HeadingTag = level;\n\n return <HeadingTag className={headingClasses[level]}>{element.props.text}</HeadingTag>;\n};\n\ninterface TextProps {\n text: string;\n variant: 'body' | 'muted' | 'caption' | 'lead' | 'code' | null;\n}\n\nconst textClasses = {\n body: 'fk:text-sm',\n muted: 'fk:text-sm fk:text-muted-foreground',\n caption: 'fk:text-xs fk:text-muted-foreground',\n lead: 'fk:text-base',\n code: 'fk:rounded fk:bg-muted fk:px-1 fk:py-0.5 fk:font-mono fk:text-xs fk:corner-squircle',\n};\n\nconst Text: ComponentRenderer<TextProps> = ({ element }) => (\n <p className={textClasses[element.props.variant ?? 'body']}>{element.props.text}</p>\n);\n\ninterface BadgeProps {\n text: string;\n variant: 'default' | 'secondary' | 'destructive' | 'outline' | null;\n}\n\nconst BadgeComponent: ComponentRenderer<BadgeProps> = ({ element }) => (\n <Badge variant={element.props.variant ?? 'default'}>{element.props.text}</Badge>\n);\n\ninterface AlertProps {\n message: string | null;\n title: string;\n type: 'success' | 'info' | 'warning' | 'error' | null;\n}\n\nfunction AlertIcon({ type }: { type: AlertProps['type'] }): JSX.Element {\n switch (type) {\n case 'success':\n return <CheckCircle2Icon className=\"fk:size-4 fk:translate-y-0.5\" />;\n case 'warning':\n return <AlertTriangleIcon className=\"fk:size-4 fk:translate-y-0.5\" />;\n case 'error':\n return <XCircleIcon className=\"fk:size-4 fk:translate-y-0.5\" />;\n default:\n return <InfoIcon className=\"fk:size-4 fk:translate-y-0.5\" />;\n }\n}\n\nconst Alert: ComponentRenderer<AlertProps> = ({ element }) => {\n const { props } = element;\n const typeClass = props.type === 'error' ? 'fk:border-destructive/50 fk:text-destructive' : 'fk:text-foreground';\n\n return (\n <div\n className={`fk:flex fk:w-full fk:gap-3 fk:rounded-lg fk:border fk:bg-card fk:px-4 fk:py-3 fk:text-sm ${typeClass} fk:corner-squircle`}\n role=\"alert\"\n >\n <AlertIcon type={props.type} />\n <div className=\"fk:min-w-0\">\n <div className=\"fk:font-medium\">{props.title}</div>\n {props.message && <div className=\"fk:text-muted-foreground\">{props.message}</div>}\n </div>\n </div>\n );\n};\n\ninterface TableProps {\n caption: string | null;\n columns: string[];\n rows: string[][];\n}\n\nconst Table: ComponentRenderer<TableProps> = ({ element }) => {\n const columns = element.props.columns ?? [];\n const rows = (element.props.rows ?? []).map((row) => row.map(String));\n\n return (\n <div className=\"fk:w-full fk:overflow-hidden fk:rounded-md fk:mt-2 fk:corner-squircle\">\n <TablePrimitive>\n {element.props.caption && <TableCaption>{element.props.caption}</TableCaption>}\n <TableHeader>\n <TableRow>\n {columns.map((column, index) => (\n <TableHead key={`${index.toString()}-${column}`}>{column}</TableHead>\n ))}\n </TableRow>\n </TableHeader>\n <TableBody>\n {rows.map((row, rowIndex) => (\n <TableRow key={rowIndex}>\n {row.map((cell, cellIndex) => (\n <TableCell key={cellIndex}>{cell}</TableCell>\n ))}\n </TableRow>\n ))}\n </TableBody>\n </TablePrimitive>\n </div>\n );\n};\n\ninterface ProgressProps {\n label: string | null;\n max: number | null;\n value: number;\n}\n\nconst Progress: ComponentRenderer<ProgressProps> = ({ element }) => {\n const { props } = element;\n const max = props.max ?? 100;\n const percent = max > 0 ? Math.min(100, Math.max(0, (props.value / max) * 100)) : 0;\n\n return (\n <div className=\"fk:w-full\">\n {props.label && (\n <div className=\"fk:mb-1 fk:flex fk:items-center fk:justify-between fk:text-xs fk:text-muted-foreground\">\n <span>{props.label}</span>\n <span className=\"fk:tabular-nums\">{Math.round(percent)}%</span>\n </div>\n )}\n <div className=\"fk:h-2 fk:w-full fk:overflow-hidden fk:rounded-full fk:bg-secondary fk:corner-squircle\">\n <div className=\"fk:h-full fk:rounded-full fk:bg-primary fk:corner-squircle\" style={{ width: `${percent.toString()}%` }} />\n </div>\n </div>\n );\n};\n\nconst Skeleton: ComponentRenderer<{ height: string | null; rounded: boolean | null; width: string | null }> = ({\n element,\n}) => (\n <SkeletonPrimitive\n className={element.props.rounded ? 'fk:rounded-full fk:corner-squircle' : ''}\n style={{ height: element.props.height ?? '1rem', width: element.props.width ?? '100%' }}\n />\n);\n\nconst LinkComponent: ComponentRenderer<{ href: string; label: string }> = ({ element }) => (\n <ExternalLink href={element.props.href}>{element.props.label}</ExternalLink>\n);\n\nconst Image: ComponentRenderer<{\n alt: string;\n height: number | null;\n src: string | null;\n width: number | null;\n}> = ({ element }) => {\n if (!element.props.src) {\n return null;\n }\n\n return (\n <img\n alt={element.props.alt}\n className=\"fk:max-w-full fk:rounded-md fk:corner-squircle\"\n height={element.props.height ?? undefined}\n src={element.props.src}\n width={element.props.width ?? undefined}\n />\n );\n};\n\ninterface AccordionProps {\n items: { content: string; title: string }[];\n type: 'single' | 'multiple' | null;\n}\n\nconst Accordion: ComponentRenderer<AccordionProps> = ({ element }) => (\n <div className=\"fk:w-full fk:divide-y fk:divide-border fk:rounded-md fk:border fk:border-border fk:corner-squircle\">\n {(element.props.items ?? []).map((item, index) => (\n <details className=\"fk:group fk:px-4 fk:py-3\" key={index}>\n <summary className=\"fk:cursor-pointer fk:list-none fk:text-sm fk:font-medium\">{item.title}</summary>\n <p className=\"fk:mt-2 fk:text-sm fk:text-muted-foreground\">{item.content}</p>\n </details>\n ))}\n </div>\n);\n\n// ---------------------------------------------------------------------------\n// Tabs\n// ---------------------------------------------------------------------------\n\ninterface TabsProps {\n defaultValue: string | null;\n tabs: { label: string; value: string }[];\n value: string | null;\n}\n\nconst Tabs: ComponentRenderer<TabsProps> = ({ children, element }) => {\n const tabs = element.props.tabs ?? [];\n\n return (\n <TabsPrimitive defaultValue={element.props.value ?? element.props.defaultValue ?? tabs[0]?.value}>\n <TabsList>\n {tabs.map((tab) => (\n <TabsTrigger key={tab.value} value={tab.value}>\n {tab.label}\n </TabsTrigger>\n ))}\n </TabsList>\n {children}\n </TabsPrimitive>\n );\n};\n\nconst TabContent: ComponentRenderer<{ value: string }> = ({ children, element }) => (\n <TabsContent value={element.props.value}>{children}</TabsContent>\n);\n\n// ---------------------------------------------------------------------------\n// Result-focused components (Metric, Callout, Timeline)\n// ---------------------------------------------------------------------------\n\ninterface MetricProps {\n detail: string | null;\n label: string;\n trend: 'up' | 'down' | 'neutral' | null;\n value: string;\n}\n\nconst trendClasses = {\n up: 'fk:text-success',\n down: 'fk:text-destructive',\n neutral: 'fk:text-muted-foreground',\n};\n\nfunction TrendIcon({ trend }: { trend: 'up' | 'down' | 'neutral' }): JSX.Element {\n if (trend === 'up') {\n return <TrendingUpIcon className=\"fk:size-4\" />;\n }\n\n if (trend === 'down') {\n return <TrendingDownIcon className=\"fk:size-4\" />;\n }\n\n return <MinusIcon className=\"fk:size-4\" />;\n}\n\nconst Metric: ComponentRenderer<MetricProps> = ({ element }) => {\n const { props } = element;\n\n return (\n <div className=\"fk:w-full fk:rounded-lg fk:border fk:border-border fk:bg-card fk:p-4 fk:corner-squircle\">\n <div className=\"fk:text-xs fk:font-medium fk:text-muted-foreground\">{props.label}</div>\n <div className=\"fk:mt-1 fk:flex fk:items-center fk:gap-2\">\n <span className=\"fk:text-2xl fk:font-semibold fk:tabular-nums fk:tracking-tight\">{props.value}</span>\n {props.trend && (\n <span className={trendClasses[props.trend]}>\n <TrendIcon trend={props.trend} />\n </span>\n )}\n </div>\n {props.detail && <div className=\"fk:mt-1 fk:text-xs fk:text-muted-foreground\">{props.detail}</div>}\n </div>\n );\n};\n\ninterface CalloutProps {\n content: string;\n title: string | null;\n type: 'info' | 'tip' | 'warning' | 'important' | null;\n}\n\nconst calloutClasses = {\n info: 'fk:border-blue-500/30 fk:bg-blue-500/5 fk:text-blue-700 fk:dark:text-blue-400',\n tip: 'fk:border-emerald-500/30 fk:bg-emerald-500/5 fk:text-emerald-700 fk:dark:text-emerald-400',\n warning: 'fk:border-amber-500/30 fk:bg-amber-500/5 fk:text-amber-700 fk:dark:text-amber-400',\n important: 'fk:border-red-500/30 fk:bg-red-500/5 fk:text-red-700 fk:dark:text-red-400',\n};\n\nfunction CalloutIcon({ type }: { type: 'info' | 'tip' | 'warning' | 'important' }): JSX.Element {\n switch (type) {\n case 'tip':\n return <LightbulbIcon className=\"fk:size-4 fk:shrink-0 fk:translate-y-0.5\" />;\n case 'warning':\n return <AlertTriangleIcon className=\"fk:size-4 fk:shrink-0 fk:translate-y-0.5\" />;\n case 'important':\n return <OctagonAlertIcon className=\"fk:size-4 fk:shrink-0 fk:translate-y-0.5\" />;\n default:\n return <InfoIcon className=\"fk:size-4 fk:shrink-0 fk:translate-y-0.5\" />;\n }\n}\n\nconst Callout: ComponentRenderer<CalloutProps> = ({ element }) => {\n const { props } = element;\n const type = props.type ?? 'info';\n\n return (\n <div\n className={`fk:flex fk:w-full fk:gap-3 fk:rounded-lg fk:border fk:px-4 fk:py-3 fk:text-sm ${calloutClasses[type]} fk:corner-squircle`}\n >\n <CalloutIcon type={type} />\n <div className=\"fk:min-w-0\">\n {props.title && <div className=\"fk:font-medium\">{props.title}</div>}\n <div className=\"fk:text-foreground\">{props.content}</div>\n </div>\n </div>\n );\n};\n\ninterface TimelineProps {\n items: {\n date: string | null;\n description: string | null;\n status: 'completed' | 'current' | 'upcoming' | null;\n title: string;\n }[];\n}\n\nconst timelineDotClasses = {\n completed: 'fk:border-success fk:bg-success',\n current: 'fk:border-primary fk:bg-primary',\n upcoming: 'fk:border-border fk:bg-background',\n};\n\nconst Timeline: ComponentRenderer<TimelineProps> = ({ element }) => (\n <div className=\"fk:w-full\">\n {(element.props.items ?? []).map((item, index, items) => (\n <div className=\"fk:relative fk:flex fk:gap-3 fk:pb-4 fk:last:pb-0\" key={index}>\n {index < items.length - 1 && (\n <div className=\"fk:absolute fk:left-[5px] fk:top-4 fk:h-full fk:w-px fk:bg-border\" />\n )}\n <div\n className={`fk:mt-1 fk:size-[11px] fk:shrink-0 fk:rounded-full fk:border-2 ${timelineDotClasses[item.status ?? 'upcoming']} fk:corner-squircle`}\n />\n <div className=\"fk:min-w-0\">\n <div className=\"fk:flex fk:flex-wrap fk:items-baseline fk:gap-x-2\">\n <span className=\"fk:text-sm fk:font-medium\">{item.title}</span>\n {item.date && <span className=\"fk:text-xs fk:text-muted-foreground\">{item.date}</span>}\n </div>\n {item.description && <div className=\"fk:text-sm fk:text-muted-foreground\">{item.description}</div>}\n </div>\n </div>\n ))}\n </div>\n);\n\n// ---------------------------------------------------------------------------\n// Charts\n// ---------------------------------------------------------------------------\n\nconst CHART_COLORS = ['#6366f1', '#10b981', '#f59e0b', '#ef4444', '#06b6d4'];\n\nconst chartTooltipStyle = {\n background: 'hsl(var(--background))',\n border: '1px solid hsl(var(--border))',\n borderRadius: 6,\n color: 'hsl(var(--foreground))',\n fontSize: 12,\n};\n\nconst chartTooltipItemStyle = {\n color: 'hsl(var(--foreground))',\n};\n\nconst chartTooltipLabelStyle = {\n color: 'hsl(var(--foreground))',\n};\n\nconst chartTick = { fill: 'hsl(var(--muted-foreground))', fontSize: 11 };\n\ninterface ChartPoint {\n x: string;\n y: number;\n}\n\ninterface CartesianChartProps {\n aggregate: 'sum' | 'count' | 'avg' | null;\n color: string | null;\n data: { [key: string]: unknown }[];\n height: number | null;\n title: string | null;\n xKey: string;\n yKey: string;\n}\n\nfunction toNumber(value: unknown): number {\n const parsed = typeof value === 'number' ? value : Number(value);\n\n return Number.isFinite(parsed) ? parsed : 0;\n}\n\nfunction getChartPoints(props: CartesianChartProps): ChartPoint[] {\n const data = props.data ?? [];\n\n if (!props.aggregate) {\n return data.map((row) => ({\n x: String(row[props.xKey] ?? ''),\n y: toNumber(row[props.yKey]),\n }));\n }\n\n const groups = new Map<string, { count: number; sum: number }>();\n\n for (const row of data) {\n const key = String(row[props.xKey] ?? '');\n const group = groups.get(key) ?? { count: 0, sum: 0 };\n\n group.count += 1;\n group.sum += toNumber(row[props.yKey]);\n groups.set(key, group);\n }\n\n return Array.from(groups.entries()).map(([x, group]) => {\n if (props.aggregate === 'count') {\n return { x, y: group.count };\n }\n\n if (props.aggregate === 'avg') {\n return { x, y: group.count === 0 ? 0 : group.sum / group.count };\n }\n\n return { x, y: group.sum };\n });\n}\n\nfunction ChartFrame({\n children,\n height,\n title,\n}: {\n children: JSX.Element;\n height: number | null;\n title: string | null;\n}): JSX.Element {\n return (\n <div className=\"fk:w-full\">\n {title && <div className=\"fk:mb-2 fk:text-sm fk:font-medium\">{title}</div>}\n <div style={{ height: height ?? 256 }}>\n <ResponsiveContainer height=\"100%\" width=\"100%\">\n {children}\n </ResponsiveContainer>\n </div>\n </div>\n );\n}\n\nconst BarChart: ComponentRenderer<CartesianChartProps> = ({ element }) => {\n const points = getChartPoints(element.props);\n const color = element.props.color ?? CHART_COLORS[0];\n\n return (\n <ChartFrame height={element.props.height} title={element.props.title}>\n <RechartsBarChart data={points}>\n <CartesianGrid stroke=\"hsl(var(--border))\" vertical={false} />\n <XAxis axisLine={false} dataKey=\"x\" tick={chartTick} tickLine={false} tickMargin={8} />\n <YAxis axisLine={false} tick={chartTick} tickLine={false} width={40} />\n <RechartsTooltip\n contentStyle={chartTooltipStyle}\n cursor={{ fill: 'hsl(var(--muted))' }}\n itemStyle={chartTooltipItemStyle}\n labelStyle={chartTooltipLabelStyle}\n />\n <Bar dataKey=\"y\" fill={color} isAnimationActive={false} name={element.props.yKey} radius={4} />\n </RechartsBarChart>\n </ChartFrame>\n );\n};\n\nconst LineChart: ComponentRenderer<CartesianChartProps> = ({ element }) => {\n const points = getChartPoints(element.props);\n const color = element.props.color ?? CHART_COLORS[0];\n\n return (\n <ChartFrame height={element.props.height} title={element.props.title}>\n <RechartsLineChart data={points}>\n <CartesianGrid stroke=\"hsl(var(--border))\" vertical={false} />\n <XAxis axisLine={false} dataKey=\"x\" tick={chartTick} tickLine={false} tickMargin={8} />\n <YAxis axisLine={false} tick={chartTick} tickLine={false} width={40} />\n <RechartsTooltip\n contentStyle={chartTooltipStyle}\n itemStyle={chartTooltipItemStyle}\n labelStyle={chartTooltipLabelStyle}\n />\n <Line\n dataKey=\"y\"\n dot={false}\n isAnimationActive={false}\n name={element.props.yKey}\n stroke={color}\n strokeWidth={2}\n type=\"monotone\"\n />\n </RechartsLineChart>\n </ChartFrame>\n );\n};\n\ninterface PieChartProps {\n data: { [key: string]: unknown }[];\n height: number | null;\n nameKey: string;\n title: string | null;\n valueKey: string;\n}\n\nconst PieChart: ComponentRenderer<PieChartProps> = ({ element }) => {\n const slices = (element.props.data ?? []).map((row) => ({\n name: String(row[element.props.nameKey] ?? ''),\n value: toNumber(row[element.props.valueKey]),\n }));\n\n return (\n <ChartFrame height={element.props.height} title={element.props.title}>\n <RechartsPieChart>\n <RechartsTooltip\n contentStyle={chartTooltipStyle}\n itemStyle={chartTooltipItemStyle}\n labelStyle={chartTooltipLabelStyle}\n />\n <Pie data={slices} dataKey=\"value\" innerRadius=\"45%\" isAnimationActive={false} nameKey=\"name\">\n {slices.map((slice, index) => (\n <Cell fill={CHART_COLORS[index % CHART_COLORS.length]} key={`${slice.name}-${index.toString()}`} />\n ))}\n </Pie>\n </RechartsPieChart>\n </ChartFrame>\n );\n};\n\n// ---------------------------------------------------------------------------\n// Mermaid\n// ---------------------------------------------------------------------------\n\ninterface MermaidProps {\n chart: string;\n title: string | null;\n}\n\nconst Mermaid: ComponentRenderer<MermaidProps> = ({ element }) => {\n const { chart, title } = element.props;\n const diagramId = useId().replace(/[^a-zA-Z0-9]/g, '');\n const [svg, setSvg] = useState<string | null>(null);\n const [error, setError] = useState<string | null>(null);\n\n useEffect(() => {\n let isCancelled = false;\n\n const render = async (): Promise<void> => {\n try {\n const { default: mermaid } = await import('mermaid');\n const isDark = document.documentElement.classList.contains('dark');\n\n mermaid.initialize({ securityLevel: 'strict', startOnLoad: false, theme: isDark ? 'dark' : 'default' });\n\n const result = await mermaid.render(`fk-mermaid-${diagramId}`, chart);\n\n if (!isCancelled) {\n setSvg(result.svg);\n setError(null);\n }\n } catch (renderError) {\n if (!isCancelled) {\n setError(renderError instanceof Error ? renderError.message : 'Failed to render the diagram.');\n }\n }\n };\n\n void render();\n\n return () => {\n isCancelled = true;\n };\n }, [chart, diagramId]);\n\n return (\n <div className=\"fk:w-full fk:rounded-lg fk:border fk:border-border fk:bg-card fk:p-4 fk:corner-squircle\">\n {title && <div className=\"fk:mb-2 fk:text-sm fk:font-medium\">{title}</div>}\n {error ? (\n <pre className=\"fk:overflow-x-auto fk:whitespace-pre-wrap fk:text-xs fk:text-muted-foreground\">{chart}</pre>\n ) : null}\n {!error && svg ? (\n <div className=\"fk:flex fk:justify-center fk:overflow-x-auto\" dangerouslySetInnerHTML={{ __html: svg }} />\n ) : null}\n {!error && !svg ? <SkeletonPrimitive className=\"fk:h-40 fk:w-full\" /> : null}\n </div>\n );\n};\n\n// ---------------------------------------------------------------------------\n// Registry and spec rendering\n// ---------------------------------------------------------------------------\n\nconst registry: ComponentRegistry = {\n Accordion,\n Alert,\n Badge: BadgeComponent,\n BarChart,\n Callout,\n Card,\n Grid,\n Heading,\n Image,\n LineChart,\n Link: LinkComponent,\n Mermaid,\n Metric,\n PieChart,\n Progress,\n Separator,\n Skeleton,\n Stack,\n TabContent,\n Table,\n Tabs,\n Text,\n Timeline,\n};\n\nconst fallback: ComponentRenderer = ({ element }) => (\n <div className=\"fk:rounded-md fk:border fk:border-dashed fk:border-border fk:p-3 fk:text-sm fk:text-muted-foreground fk:corner-squircle\">\n Unsupported component: {element.type}\n </div>\n);\n\nfunction getSanitizedChildren(childKeys: string[] | undefined, elements: Spec['elements']): string[] {\n const seen = new Set<string>();\n const children: string[] = [];\n\n for (const childKey of childKeys ?? []) {\n const normalizedKey = String(childKey);\n\n if (seen.has(normalizedKey) || !elements[normalizedKey]) {\n continue;\n }\n\n seen.add(normalizedKey);\n children.push(normalizedKey);\n }\n\n return children;\n}\n\nfunction haveChildrenChanged(original: string[], sanitized: string[]): boolean {\n if (original.length !== sanitized.length) {\n return true;\n }\n\n return sanitized.some((childKey, index) => childKey !== original[index]);\n}\n\nfunction sanitizeSpec(spec: Spec): Spec | null {\n if (!spec.elements[spec.root]) {\n return null;\n }\n\n let hasChanged = false;\n const elements: Spec['elements'] = {};\n\n for (const elementKey of Object.keys(spec.elements)) {\n const element = spec.elements[elementKey];\n\n if (!element) {\n continue;\n }\n\n const elementChildren = element.children ?? [];\n const children = getSanitizedChildren(elementChildren, spec.elements);\n const hasChildrenChanged = haveChildrenChanged(elementChildren, children);\n\n if (hasChildrenChanged) {\n hasChanged = true;\n }\n\n elements[elementKey] = hasChildrenChanged ? { ...element, children } : element;\n }\n\n if (!hasChanged) {\n return spec;\n }\n\n return { ...spec, elements };\n}\n\ninterface SpecMessagePart {\n data?: unknown;\n text?: string;\n type: string;\n}\n\nconst SPEC_DATA_PART_TYPE = 'data-spec';\n\nfunction dedupeSpecParts(parts: SpecMessagePart[]): SpecMessagePart[] {\n const seenPatchLines = new Set<string>();\n const deduped: SpecMessagePart[] = [];\n\n for (const part of parts) {\n if (part.type !== SPEC_DATA_PART_TYPE) {\n continue;\n }\n\n const payload = part.data;\n\n if (payload && typeof payload === 'object' && 'type' in payload && payload.type === 'patch' && 'patch' in payload) {\n const line = JSON.stringify(payload.patch);\n\n if (seenPatchLines.has(line)) {\n continue;\n }\n\n seenPatchLines.add(line);\n }\n\n deduped.push(part);\n }\n\n return deduped;\n}\n\nexport function RunSpecPart({ parts }: { parts: SpecMessagePart[] }): JSX.Element | null {\n const spec = useMemo(() => {\n const builtSpec = buildSpecFromParts(dedupeSpecParts(parts));\n\n return builtSpec ? sanitizeSpec(builtSpec) : null;\n }, [parts]);\n const stateKey = useMemo(() => JSON.stringify(spec?.state ?? {}), [spec]);\n\n if (!spec) {\n return null;\n }\n\n return (\n <StateProvider initialState={spec.state} key={stateKey}>\n <VisibilityProvider>\n <ActionProvider>\n <Renderer fallback={fallback} registry={registry} spec={spec} />\n </ActionProvider>\n </VisibilityProvider>\n </StateProvider>\n );\n}\n\nexport type { SpecMessagePart };\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/apps/ai/spec-renderer.tsx"],"names":["cardMaxWidthClasses","Card","children","element","props","maxWidthClass","centeredClass","jsxs","jsx","stackGapClasses","stackAlignClasses","stackJustifyClasses","Stack","directionClass","gapClass","alignClass","justifyClass","gridColumnClasses","gridGapClasses","Grid","columnClass","Separator","headingClasses","Heading","level","textClasses","Text","BadgeComponent","Badge","AlertIcon","type","CheckCircle2Icon","AlertTriangleIcon","XCircleIcon","InfoIcon","Alert","typeClass","Table","columns","rows","row","TableCaption","TableHeader","TableRow","column","index","TableHead","TableBody","rowIndex","cell","cellIndex","TableCell","Progress","max","percent","Skeleton","LinkComponent","ExternalLink","Image","Accordion","item","Tabs","tabs","TabsList","tab","TabsTrigger","TabContent","TabsContent","trendClasses","TrendIcon","trend","TrendingUpIcon","TrendingDownIcon","MinusIcon","Metric","calloutClasses","CalloutIcon","LightbulbIcon","OctagonAlertIcon","Callout","timelineDotClasses","Timeline","items","CHART_COLORS","chartTooltipStyle","chartTooltipItemStyle","chartTooltipLabelStyle","chartTick","toNumber","value","parsed","getChartPoints","data","groups","key","group","x","ChartFrame","height","title","ResponsiveContainer","BarChart","points","color","RechartsBarChart","CartesianGrid","XAxis","YAxis","RechartsTooltip","Bar","LineChart","RechartsLineChart","Line","PieChart","slices","RechartsPieChart","Pie","slice","Cell","Mermaid","chart","diagramId","useId","svg","setSvg","useState","error","setError","useEffect","isCancelled","mermaid","isDark","result","renderError","registry","fallback","getSanitizedChildren","childKeys","elements","seen","childKey","normalizedKey","haveChildrenChanged","original","sanitized","sanitizeSpec","spec","hasChanged","elementKey","elementChildren","hasChildrenChanged","SPEC_DATA_PART_TYPE","dedupeSpecParts","parts","seenPatchLines","deduped","part","payload","line","RunSpecPart","useMemo","builtSpec","buildSpecFromParts","stateKey","StateProvider","VisibilityProvider","ActionProvider","Renderer"],"mappings":"6xBA2DA,IAAMA,EAAAA,CA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AAAA,CAAOc,QAAQ,IAAM,CACzB,IAAMC,CAAAA,CAAYC,kBAAAA,CAAmBV,EAAAA,CAAgBC,CAAK,CAAC,EAE3D,OAAOQ,CAAAA,CAAYhB,EAAAA,CAAagB,CAAS,CAAA,CAAI,IAC/C,CAAA,CAAG,CAACR,CAAK,CAAC,CAAA,CACJU,CAAAA,CAAWH,OAAAA,CAAQ,IAAM,IAAA,CAAK,SAAA,CAAUd,CAAAA,EAAM,KAAA,EAAS,EAAE,CAAA,CAAG,CAACA,CAAI,CAAC,CAAA,CAExE,OAAKA,CAAAA,CAKH1I,IAAC4J,aAAAA,CAAA,CAAc,YAAA,CAAclB,CAAAA,CAAK,KAAA,CAChC,QAAA,CAAA1I,GAAAA,CAAC6J,kBAAAA,CAAA,CACC,QAAA,CAAA7J,GAAAA,CAAC8J,cAAAA,CAAA,CACC,QAAA,CAAA9J,GAAAA,CAAC+J,QAAAA,CAAA,CAAS,SAAUhC,EAAAA,CAAU,QAAA,CAAUD,EAAAA,CAAU,IAAA,CAAMY,EAAM,CAAA,CAChE,CAAA,CACF,CAAA,CAAA,CAL4CiB,CAM9C,EAVO,IAYX","file":"spec-renderer-EX7SCFWH.js","sourcesContent":["import type { JSX } from 'react';\nimport type { ComponentRegistry, ComponentRenderer, Spec } from '@json-render/react';\nimport { useEffect, useId, useMemo, useState } from 'react';\nimport { ActionProvider, Renderer, StateProvider, VisibilityProvider, buildSpecFromParts } from '@json-render/react';\nimport {\n AlertTriangleIcon,\n CheckCircle2Icon,\n InfoIcon,\n LightbulbIcon,\n MinusIcon,\n OctagonAlertIcon,\n TrendingDownIcon,\n TrendingUpIcon,\n XCircleIcon,\n} from 'lucide-react';\nimport {\n Bar,\n BarChart as RechartsBarChart,\n CartesianGrid,\n Cell,\n Line,\n LineChart as RechartsLineChart,\n Pie,\n PieChart as RechartsPieChart,\n ResponsiveContainer,\n Tooltip as RechartsTooltip,\n XAxis,\n YAxis,\n} from 'recharts';\nimport {\n Badge,\n ExternalLink,\n Separator as SeparatorPrimitive,\n Skeleton as SkeletonPrimitive,\n Table as TablePrimitive,\n TableBody,\n TableCaption,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n Tabs as TabsPrimitive,\n TabsContent,\n TabsList,\n TabsTrigger,\n} from '../../ui';\n\n// ---------------------------------------------------------------------------\n// Layout components\n// ---------------------------------------------------------------------------\n\ninterface CardProps {\n centered: boolean | null;\n className: string | null;\n description: string | null;\n maxWidth: 'sm' | 'md' | 'lg' | 'full' | null;\n title: string | null;\n}\n\nconst cardMaxWidthClasses = {\n sm: 'fk:max-w-sm',\n md: 'fk:max-w-md',\n lg: 'fk:max-w-lg',\n full: 'fk:max-w-full',\n};\n\nconst Card: ComponentRenderer<CardProps> = ({ children, element }) => {\n const { props } = element;\n const maxWidthClass = props.maxWidth ? cardMaxWidthClasses[props.maxWidth] : '';\n const centeredClass = props.centered ? 'fk:mx-auto' : '';\n\n return (\n <div\n className={`fk:w-full fk:rounded-lg fk:border fk:border-border fk:bg-card fk:p-4 fk:gap-2 fk:flex fk:flex-col ${maxWidthClass} ${centeredClass} ${props.className ?? ''} fk:corner-squircle`}\n >\n {props.title && <div className=\"fk:text-sm fk:font-medium\">{props.title}</div>}\n {props.description && <div className=\"fk:mt-0.5 fk:text-xs fk:text-muted-foreground\">{props.description}</div>}\n {(props.title ?? props.description) && children ? <div className=\"fk:mt-3\" /> : null}\n {children}\n </div>\n );\n};\n\ninterface StackProps {\n align: 'start' | 'center' | 'end' | 'stretch' | null;\n className: string | null;\n direction: 'horizontal' | 'vertical' | null;\n gap: 'none' | 'sm' | 'md' | 'lg' | 'xl' | null;\n justify: 'start' | 'center' | 'end' | 'between' | 'around' | null;\n}\n\nconst stackGapClasses = {\n none: 'fk:gap-0',\n sm: 'fk:gap-2',\n md: 'fk:gap-3',\n lg: 'fk:gap-4',\n xl: 'fk:gap-6',\n};\n\nconst stackAlignClasses = {\n start: 'fk:items-start',\n center: 'fk:items-center',\n end: 'fk:items-end',\n stretch: 'fk:items-stretch',\n};\n\nconst stackJustifyClasses = {\n start: 'fk:justify-start',\n center: 'fk:justify-center',\n end: 'fk:justify-end',\n between: 'fk:justify-between',\n around: 'fk:justify-around',\n};\n\nconst Stack: ComponentRenderer<StackProps> = ({ children, element }) => {\n const { props } = element;\n const directionClass = props.direction === 'horizontal' ? 'fk:flex-row fk:flex-wrap' : 'fk:flex-col';\n const gapClass = stackGapClasses[props.gap ?? 'md'];\n const alignClass = props.align ? stackAlignClasses[props.align] : '';\n const justifyClass = props.justify ? stackJustifyClasses[props.justify] : '';\n\n return (\n <div\n className={`fk:flex fk:w-full ${directionClass} ${gapClass} ${alignClass} ${justifyClass} ${props.className ?? ''}`}\n >\n {children}\n </div>\n );\n};\n\ninterface GridProps {\n className: string | null;\n columns: number | null;\n gap: 'sm' | 'md' | 'lg' | 'xl' | null;\n}\n\nconst gridColumnClasses: { [columns: number]: string } = {\n 1: 'fk:grid-cols-1',\n 2: 'fk:grid-cols-2',\n 3: 'fk:grid-cols-3',\n 4: 'fk:grid-cols-4',\n 5: 'fk:grid-cols-5',\n 6: 'fk:grid-cols-6',\n};\n\nconst gridGapClasses = {\n sm: 'fk:gap-2',\n md: 'fk:gap-3',\n lg: 'fk:gap-4',\n xl: 'fk:gap-6',\n};\n\nconst Grid: ComponentRenderer<GridProps> = ({ children, element }) => {\n const { props } = element;\n const columnClass = gridColumnClasses[props.columns ?? 1] ?? 'fk:grid-cols-1';\n const gapClass = gridGapClasses[props.gap ?? 'md'];\n\n return <div className={`fk:grid fk:w-full ${columnClass} ${gapClass} ${props.className ?? ''}`}>{children}</div>;\n};\n\nconst Separator: ComponentRenderer<{ orientation: 'horizontal' | 'vertical' | null }> = ({ element }) => (\n <SeparatorPrimitive orientation={element.props.orientation ?? 'horizontal'} />\n);\n\n// ---------------------------------------------------------------------------\n// Typography and content components\n// ---------------------------------------------------------------------------\n\ninterface HeadingProps {\n level: 'h1' | 'h2' | 'h3' | 'h4' | null;\n text: string;\n}\n\nconst headingClasses = {\n h1: 'fk:text-xl fk:font-semibold fk:tracking-tight',\n h2: 'fk:text-lg fk:font-semibold fk:tracking-tight',\n h3: 'fk:text-base fk:font-medium',\n h4: 'fk:text-sm fk:font-medium',\n};\n\nconst Heading: ComponentRenderer<HeadingProps> = ({ element }) => {\n const level = element.props.level ?? 'h2';\n const HeadingTag = level;\n\n return <HeadingTag className={headingClasses[level]}>{element.props.text}</HeadingTag>;\n};\n\ninterface TextProps {\n text: string;\n variant: 'body' | 'muted' | 'caption' | 'lead' | 'code' | null;\n}\n\nconst textClasses = {\n body: 'fk:text-sm',\n muted: 'fk:text-sm fk:text-muted-foreground',\n caption: 'fk:text-xs fk:text-muted-foreground',\n lead: 'fk:text-base',\n code: 'fk:rounded fk:bg-muted fk:px-1 fk:py-0.5 fk:font-mono fk:text-xs fk:corner-squircle',\n};\n\nconst Text: ComponentRenderer<TextProps> = ({ element }) => (\n <p className={textClasses[element.props.variant ?? 'body']}>{element.props.text}</p>\n);\n\ninterface BadgeProps {\n text: string;\n variant: 'default' | 'secondary' | 'destructive' | 'outline' | null;\n}\n\nconst BadgeComponent: ComponentRenderer<BadgeProps> = ({ element }) => (\n <Badge variant={element.props.variant ?? 'default'}>{element.props.text}</Badge>\n);\n\ninterface AlertProps {\n message: string | null;\n title: string;\n type: 'success' | 'info' | 'warning' | 'error' | null;\n}\n\nfunction AlertIcon({ type }: { type: AlertProps['type'] }): JSX.Element {\n switch (type) {\n case 'success':\n return <CheckCircle2Icon className=\"fk:size-4 fk:translate-y-0.5\" />;\n case 'warning':\n return <AlertTriangleIcon className=\"fk:size-4 fk:translate-y-0.5\" />;\n case 'error':\n return <XCircleIcon className=\"fk:size-4 fk:translate-y-0.5\" />;\n default:\n return <InfoIcon className=\"fk:size-4 fk:translate-y-0.5\" />;\n }\n}\n\nconst Alert: ComponentRenderer<AlertProps> = ({ element }) => {\n const { props } = element;\n const typeClass = props.type === 'error' ? 'fk:border-destructive/50 fk:text-destructive' : 'fk:text-foreground';\n\n return (\n <div\n className={`fk:flex fk:w-full fk:gap-3 fk:rounded-lg fk:border fk:bg-card fk:px-4 fk:py-3 fk:text-sm ${typeClass} fk:corner-squircle`}\n role=\"alert\"\n >\n <AlertIcon type={props.type} />\n <div className=\"fk:min-w-0\">\n <div className=\"fk:font-medium\">{props.title}</div>\n {props.message && <div className=\"fk:text-muted-foreground\">{props.message}</div>}\n </div>\n </div>\n );\n};\n\ninterface TableProps {\n caption: string | null;\n columns: string[];\n rows: string[][];\n}\n\nconst Table: ComponentRenderer<TableProps> = ({ element }) => {\n const columns = element.props.columns ?? [];\n const rows = (element.props.rows ?? []).map((row) => row.map(String));\n\n return (\n <div className=\"fk:w-full fk:overflow-hidden fk:rounded-md fk:mt-2 fk:corner-squircle\">\n <TablePrimitive>\n {element.props.caption && <TableCaption>{element.props.caption}</TableCaption>}\n <TableHeader>\n <TableRow>\n {columns.map((column, index) => (\n <TableHead key={`${index.toString()}-${column}`}>{column}</TableHead>\n ))}\n </TableRow>\n </TableHeader>\n <TableBody>\n {rows.map((row, rowIndex) => (\n <TableRow key={rowIndex}>\n {row.map((cell, cellIndex) => (\n <TableCell key={cellIndex}>{cell}</TableCell>\n ))}\n </TableRow>\n ))}\n </TableBody>\n </TablePrimitive>\n </div>\n );\n};\n\ninterface ProgressProps {\n label: string | null;\n max: number | null;\n value: number;\n}\n\nconst Progress: ComponentRenderer<ProgressProps> = ({ element }) => {\n const { props } = element;\n const max = props.max ?? 100;\n const percent = max > 0 ? Math.min(100, Math.max(0, (props.value / max) * 100)) : 0;\n\n return (\n <div className=\"fk:w-full\">\n {props.label && (\n <div className=\"fk:mb-1 fk:flex fk:items-center fk:justify-between fk:text-xs fk:text-muted-foreground\">\n <span>{props.label}</span>\n <span className=\"fk:tabular-nums\">{Math.round(percent)}%</span>\n </div>\n )}\n <div className=\"fk:h-2 fk:w-full fk:overflow-hidden fk:rounded-full fk:bg-secondary fk:corner-squircle\">\n <div className=\"fk:h-full fk:rounded-full fk:bg-primary fk:corner-squircle\" style={{ width: `${percent.toString()}%` }} />\n </div>\n </div>\n );\n};\n\nconst Skeleton: ComponentRenderer<{ height: string | null; rounded: boolean | null; width: string | null }> = ({\n element,\n}) => (\n <SkeletonPrimitive\n className={element.props.rounded ? 'fk:rounded-full fk:corner-squircle' : ''}\n style={{ height: element.props.height ?? '1rem', width: element.props.width ?? '100%' }}\n />\n);\n\nconst LinkComponent: ComponentRenderer<{ href: string; label: string }> = ({ element }) => (\n <ExternalLink href={element.props.href}>{element.props.label}</ExternalLink>\n);\n\nconst Image: ComponentRenderer<{\n alt: string;\n height: number | null;\n src: string | null;\n width: number | null;\n}> = ({ element }) => {\n if (!element.props.src) {\n return null;\n }\n\n return (\n <img\n alt={element.props.alt}\n className=\"fk:max-w-full fk:rounded-md fk:corner-squircle\"\n height={element.props.height ?? undefined}\n src={element.props.src}\n width={element.props.width ?? undefined}\n />\n );\n};\n\ninterface AccordionProps {\n items: { content: string; title: string }[];\n type: 'single' | 'multiple' | null;\n}\n\nconst Accordion: ComponentRenderer<AccordionProps> = ({ element }) => (\n <div className=\"fk:w-full fk:divide-y fk:divide-border fk:rounded-md fk:border fk:border-border fk:corner-squircle\">\n {(element.props.items ?? []).map((item, index) => (\n <details className=\"fk:group fk:px-4 fk:py-3\" key={index}>\n <summary className=\"fk:cursor-pointer fk:list-none fk:text-sm fk:font-medium\">{item.title}</summary>\n <p className=\"fk:mt-2 fk:text-sm fk:text-muted-foreground\">{item.content}</p>\n </details>\n ))}\n </div>\n);\n\n// ---------------------------------------------------------------------------\n// Tabs\n// ---------------------------------------------------------------------------\n\ninterface TabsProps {\n defaultValue: string | null;\n tabs: { label: string; value: string }[];\n value: string | null;\n}\n\nconst Tabs: ComponentRenderer<TabsProps> = ({ children, element }) => {\n const tabs = element.props.tabs ?? [];\n\n return (\n <TabsPrimitive defaultValue={element.props.value ?? element.props.defaultValue ?? tabs[0]?.value}>\n <TabsList>\n {tabs.map((tab) => (\n <TabsTrigger key={tab.value} value={tab.value}>\n {tab.label}\n </TabsTrigger>\n ))}\n </TabsList>\n {children}\n </TabsPrimitive>\n );\n};\n\nconst TabContent: ComponentRenderer<{ value: string }> = ({ children, element }) => (\n <TabsContent value={element.props.value}>{children}</TabsContent>\n);\n\n// ---------------------------------------------------------------------------\n// Result-focused components (Metric, Callout, Timeline)\n// ---------------------------------------------------------------------------\n\ninterface MetricProps {\n detail: string | null;\n label: string;\n trend: 'up' | 'down' | 'neutral' | null;\n value: string;\n}\n\nconst trendClasses = {\n up: 'fk:text-success',\n down: 'fk:text-destructive',\n neutral: 'fk:text-muted-foreground',\n};\n\nfunction TrendIcon({ trend }: { trend: 'up' | 'down' | 'neutral' }): JSX.Element {\n if (trend === 'up') {\n return <TrendingUpIcon className=\"fk:size-4\" />;\n }\n\n if (trend === 'down') {\n return <TrendingDownIcon className=\"fk:size-4\" />;\n }\n\n return <MinusIcon className=\"fk:size-4\" />;\n}\n\nconst Metric: ComponentRenderer<MetricProps> = ({ element }) => {\n const { props } = element;\n\n return (\n <div className=\"fk:w-full fk:rounded-lg fk:border fk:border-border fk:bg-card fk:p-4 fk:corner-squircle\">\n <div className=\"fk:text-xs fk:font-medium fk:text-muted-foreground\">{props.label}</div>\n <div className=\"fk:mt-1 fk:flex fk:items-center fk:gap-2\">\n <span className=\"fk:text-2xl fk:font-semibold fk:tabular-nums fk:tracking-tight\">{props.value}</span>\n {props.trend && (\n <span className={trendClasses[props.trend]}>\n <TrendIcon trend={props.trend} />\n </span>\n )}\n </div>\n {props.detail && <div className=\"fk:mt-1 fk:text-xs fk:text-muted-foreground\">{props.detail}</div>}\n </div>\n );\n};\n\ninterface CalloutProps {\n content: string;\n title: string | null;\n type: 'info' | 'tip' | 'warning' | 'important' | null;\n}\n\nconst calloutClasses = {\n info: 'fk:border-blue-500/30 fk:bg-blue-500/5 fk:text-blue-700 fk:dark:text-blue-400',\n tip: 'fk:border-emerald-500/30 fk:bg-emerald-500/5 fk:text-emerald-700 fk:dark:text-emerald-400',\n warning: 'fk:border-amber-500/30 fk:bg-amber-500/5 fk:text-amber-700 fk:dark:text-amber-400',\n important: 'fk:border-red-500/30 fk:bg-red-500/5 fk:text-red-700 fk:dark:text-red-400',\n};\n\nfunction CalloutIcon({ type }: { type: 'info' | 'tip' | 'warning' | 'important' }): JSX.Element {\n switch (type) {\n case 'tip':\n return <LightbulbIcon className=\"fk:size-4 fk:shrink-0 fk:translate-y-0.5\" />;\n case 'warning':\n return <AlertTriangleIcon className=\"fk:size-4 fk:shrink-0 fk:translate-y-0.5\" />;\n case 'important':\n return <OctagonAlertIcon className=\"fk:size-4 fk:shrink-0 fk:translate-y-0.5\" />;\n default:\n return <InfoIcon className=\"fk:size-4 fk:shrink-0 fk:translate-y-0.5\" />;\n }\n}\n\nconst Callout: ComponentRenderer<CalloutProps> = ({ element }) => {\n const { props } = element;\n const type = props.type ?? 'info';\n\n return (\n <div\n className={`fk:flex fk:w-full fk:gap-3 fk:rounded-lg fk:border fk:px-4 fk:py-3 fk:text-sm ${calloutClasses[type]} fk:corner-squircle`}\n >\n <CalloutIcon type={type} />\n <div className=\"fk:min-w-0\">\n {props.title && <div className=\"fk:font-medium\">{props.title}</div>}\n <div className=\"fk:text-foreground\">{props.content}</div>\n </div>\n </div>\n );\n};\n\ninterface TimelineProps {\n items: {\n date: string | null;\n description: string | null;\n status: 'completed' | 'current' | 'upcoming' | null;\n title: string;\n }[];\n}\n\nconst timelineDotClasses = {\n completed: 'fk:border-success fk:bg-success',\n current: 'fk:border-primary fk:bg-primary',\n upcoming: 'fk:border-border fk:bg-background',\n};\n\nconst Timeline: ComponentRenderer<TimelineProps> = ({ element }) => (\n <div className=\"fk:w-full\">\n {(element.props.items ?? []).map((item, index, items) => (\n <div className=\"fk:relative fk:flex fk:gap-3 fk:pb-4 fk:last:pb-0\" key={index}>\n {index < items.length - 1 && (\n <div className=\"fk:absolute fk:left-[5px] fk:top-4 fk:h-full fk:w-px fk:bg-border\" />\n )}\n <div\n className={`fk:mt-1 fk:size-[11px] fk:shrink-0 fk:rounded-full fk:border-2 ${timelineDotClasses[item.status ?? 'upcoming']} fk:corner-squircle`}\n />\n <div className=\"fk:min-w-0\">\n <div className=\"fk:flex fk:flex-wrap fk:items-baseline fk:gap-x-2\">\n <span className=\"fk:text-sm fk:font-medium\">{item.title}</span>\n {item.date && <span className=\"fk:text-xs fk:text-muted-foreground\">{item.date}</span>}\n </div>\n {item.description && <div className=\"fk:text-sm fk:text-muted-foreground\">{item.description}</div>}\n </div>\n </div>\n ))}\n </div>\n);\n\n// ---------------------------------------------------------------------------\n// Charts\n// ---------------------------------------------------------------------------\n\nconst CHART_COLORS = ['#6366f1', '#10b981', '#f59e0b', '#ef4444', '#06b6d4'];\n\nconst chartTooltipStyle = {\n background: 'hsl(var(--background))',\n border: '1px solid hsl(var(--border))',\n borderRadius: 6,\n color: 'hsl(var(--foreground))',\n fontSize: 12,\n};\n\nconst chartTooltipItemStyle = {\n color: 'hsl(var(--foreground))',\n};\n\nconst chartTooltipLabelStyle = {\n color: 'hsl(var(--foreground))',\n};\n\nconst chartTick = { fill: 'hsl(var(--muted-foreground))', fontSize: 11 };\n\ninterface ChartPoint {\n x: string;\n y: number;\n}\n\ninterface CartesianChartProps {\n aggregate: 'sum' | 'count' | 'avg' | null;\n color: string | null;\n data: { [key: string]: unknown }[];\n height: number | null;\n title: string | null;\n xKey: string;\n yKey: string;\n}\n\nfunction toNumber(value: unknown): number {\n const parsed = typeof value === 'number' ? value : Number(value);\n\n return Number.isFinite(parsed) ? parsed : 0;\n}\n\nfunction getChartPoints(props: CartesianChartProps): ChartPoint[] {\n const data = props.data ?? [];\n\n if (!props.aggregate) {\n return data.map((row) => ({\n x: String(row[props.xKey] ?? ''),\n y: toNumber(row[props.yKey]),\n }));\n }\n\n const groups = new Map<string, { count: number; sum: number }>();\n\n for (const row of data) {\n const key = String(row[props.xKey] ?? '');\n const group = groups.get(key) ?? { count: 0, sum: 0 };\n\n group.count += 1;\n group.sum += toNumber(row[props.yKey]);\n groups.set(key, group);\n }\n\n return Array.from(groups.entries()).map(([x, group]) => {\n if (props.aggregate === 'count') {\n return { x, y: group.count };\n }\n\n if (props.aggregate === 'avg') {\n return { x, y: group.count === 0 ? 0 : group.sum / group.count };\n }\n\n return { x, y: group.sum };\n });\n}\n\nfunction ChartFrame({\n children,\n height,\n title,\n}: {\n children: JSX.Element;\n height: number | null;\n title: string | null;\n}): JSX.Element {\n return (\n <div className=\"fk:w-full\">\n {title && <div className=\"fk:mb-2 fk:text-sm fk:font-medium\">{title}</div>}\n <div style={{ height: height ?? 256 }}>\n <ResponsiveContainer height=\"100%\" width=\"100%\">\n {children}\n </ResponsiveContainer>\n </div>\n </div>\n );\n}\n\nconst BarChart: ComponentRenderer<CartesianChartProps> = ({ element }) => {\n const points = getChartPoints(element.props);\n const color = element.props.color ?? CHART_COLORS[0];\n\n return (\n <ChartFrame height={element.props.height} title={element.props.title}>\n <RechartsBarChart data={points}>\n <CartesianGrid stroke=\"hsl(var(--border))\" vertical={false} />\n <XAxis axisLine={false} dataKey=\"x\" tick={chartTick} tickLine={false} tickMargin={8} />\n <YAxis axisLine={false} tick={chartTick} tickLine={false} width={40} />\n <RechartsTooltip\n contentStyle={chartTooltipStyle}\n cursor={{ fill: 'hsl(var(--muted))' }}\n itemStyle={chartTooltipItemStyle}\n labelStyle={chartTooltipLabelStyle}\n />\n <Bar dataKey=\"y\" fill={color} isAnimationActive={false} name={element.props.yKey} radius={4} />\n </RechartsBarChart>\n </ChartFrame>\n );\n};\n\nconst LineChart: ComponentRenderer<CartesianChartProps> = ({ element }) => {\n const points = getChartPoints(element.props);\n const color = element.props.color ?? CHART_COLORS[0];\n\n return (\n <ChartFrame height={element.props.height} title={element.props.title}>\n <RechartsLineChart data={points}>\n <CartesianGrid stroke=\"hsl(var(--border))\" vertical={false} />\n <XAxis axisLine={false} dataKey=\"x\" tick={chartTick} tickLine={false} tickMargin={8} />\n <YAxis axisLine={false} tick={chartTick} tickLine={false} width={40} />\n <RechartsTooltip\n contentStyle={chartTooltipStyle}\n itemStyle={chartTooltipItemStyle}\n labelStyle={chartTooltipLabelStyle}\n />\n <Line\n dataKey=\"y\"\n dot={false}\n isAnimationActive={false}\n name={element.props.yKey}\n stroke={color}\n strokeWidth={2}\n type=\"monotone\"\n />\n </RechartsLineChart>\n </ChartFrame>\n );\n};\n\ninterface PieChartProps {\n data: { [key: string]: unknown }[];\n height: number | null;\n nameKey: string;\n title: string | null;\n valueKey: string;\n}\n\nconst PieChart: ComponentRenderer<PieChartProps> = ({ element }) => {\n const slices = (element.props.data ?? []).map((row) => ({\n name: String(row[element.props.nameKey] ?? ''),\n value: toNumber(row[element.props.valueKey]),\n }));\n\n return (\n <ChartFrame height={element.props.height} title={element.props.title}>\n <RechartsPieChart>\n <RechartsTooltip\n contentStyle={chartTooltipStyle}\n itemStyle={chartTooltipItemStyle}\n labelStyle={chartTooltipLabelStyle}\n />\n <Pie data={slices} dataKey=\"value\" innerRadius=\"45%\" isAnimationActive={false} nameKey=\"name\">\n {slices.map((slice, index) => (\n <Cell fill={CHART_COLORS[index % CHART_COLORS.length]} key={`${slice.name}-${index.toString()}`} />\n ))}\n </Pie>\n </RechartsPieChart>\n </ChartFrame>\n );\n};\n\n// ---------------------------------------------------------------------------\n// Mermaid\n// ---------------------------------------------------------------------------\n\ninterface MermaidProps {\n chart: string;\n title: string | null;\n}\n\nconst Mermaid: ComponentRenderer<MermaidProps> = ({ element }) => {\n const { chart, title } = element.props;\n const diagramId = useId().replace(/[^a-zA-Z0-9]/g, '');\n const [svg, setSvg] = useState<string | null>(null);\n const [error, setError] = useState<string | null>(null);\n\n useEffect(() => {\n let isCancelled = false;\n\n const render = async (): Promise<void> => {\n try {\n const { default: mermaid } = await import('mermaid');\n const isDark = document.documentElement.classList.contains('dark');\n\n mermaid.initialize({ securityLevel: 'strict', startOnLoad: false, theme: isDark ? 'dark' : 'default' });\n\n const result = await mermaid.render(`fk-mermaid-${diagramId}`, chart);\n\n if (!isCancelled) {\n setSvg(result.svg);\n setError(null);\n }\n } catch (renderError) {\n if (!isCancelled) {\n setError(renderError instanceof Error ? renderError.message : 'Failed to render the diagram.');\n }\n }\n };\n\n void render();\n\n return () => {\n isCancelled = true;\n };\n }, [chart, diagramId]);\n\n return (\n <div className=\"fk:w-full fk:rounded-lg fk:border fk:border-border fk:bg-card fk:p-4 fk:corner-squircle\">\n {title && <div className=\"fk:mb-2 fk:text-sm fk:font-medium\">{title}</div>}\n {error ? (\n <pre className=\"fk:overflow-x-auto fk:whitespace-pre-wrap fk:text-xs fk:text-muted-foreground\">{chart}</pre>\n ) : null}\n {!error && svg ? (\n <div className=\"fk:flex fk:justify-center fk:overflow-x-auto\" dangerouslySetInnerHTML={{ __html: svg }} />\n ) : null}\n {!error && !svg ? <SkeletonPrimitive className=\"fk:h-40 fk:w-full\" /> : null}\n </div>\n );\n};\n\n// ---------------------------------------------------------------------------\n// Registry and spec rendering\n// ---------------------------------------------------------------------------\n\nconst registry: ComponentRegistry = {\n Accordion,\n Alert,\n Badge: BadgeComponent,\n BarChart,\n Callout,\n Card,\n Grid,\n Heading,\n Image,\n LineChart,\n Link: LinkComponent,\n Mermaid,\n Metric,\n PieChart,\n Progress,\n Separator,\n Skeleton,\n Stack,\n TabContent,\n Table,\n Tabs,\n Text,\n Timeline,\n};\n\nconst fallback: ComponentRenderer = ({ element }) => (\n <div className=\"fk:rounded-md fk:border fk:border-dashed fk:border-border fk:p-3 fk:text-sm fk:text-muted-foreground fk:corner-squircle\">\n Unsupported component: {element.type}\n </div>\n);\n\nfunction getSanitizedChildren(childKeys: string[] | undefined, elements: Spec['elements']): string[] {\n const seen = new Set<string>();\n const children: string[] = [];\n\n for (const childKey of childKeys ?? []) {\n const normalizedKey = String(childKey);\n\n if (seen.has(normalizedKey) || !elements[normalizedKey]) {\n continue;\n }\n\n seen.add(normalizedKey);\n children.push(normalizedKey);\n }\n\n return children;\n}\n\nfunction haveChildrenChanged(original: string[], sanitized: string[]): boolean {\n if (original.length !== sanitized.length) {\n return true;\n }\n\n return sanitized.some((childKey, index) => childKey !== original[index]);\n}\n\nfunction sanitizeSpec(spec: Spec): Spec | null {\n if (!spec.elements[spec.root]) {\n return null;\n }\n\n let hasChanged = false;\n const elements: Spec['elements'] = {};\n\n for (const elementKey of Object.keys(spec.elements)) {\n const element = spec.elements[elementKey];\n\n if (!element) {\n continue;\n }\n\n const elementChildren = element.children ?? [];\n const children = getSanitizedChildren(elementChildren, spec.elements);\n const hasChildrenChanged = haveChildrenChanged(elementChildren, children);\n\n if (hasChildrenChanged) {\n hasChanged = true;\n }\n\n elements[elementKey] = hasChildrenChanged ? { ...element, children } : element;\n }\n\n if (!hasChanged) {\n return spec;\n }\n\n return { ...spec, elements };\n}\n\ninterface SpecMessagePart {\n data?: unknown;\n text?: string;\n type: string;\n}\n\nconst SPEC_DATA_PART_TYPE = 'data-spec';\n\nfunction dedupeSpecParts(parts: SpecMessagePart[]): SpecMessagePart[] {\n const seenPatchLines = new Set<string>();\n const deduped: SpecMessagePart[] = [];\n\n for (const part of parts) {\n if (part.type !== SPEC_DATA_PART_TYPE) {\n continue;\n }\n\n const payload = part.data;\n\n if (payload && typeof payload === 'object' && 'type' in payload && payload.type === 'patch' && 'patch' in payload) {\n const line = JSON.stringify(payload.patch);\n\n if (seenPatchLines.has(line)) {\n continue;\n }\n\n seenPatchLines.add(line);\n }\n\n deduped.push(part);\n }\n\n return deduped;\n}\n\nexport function RunSpecPart({ parts }: { parts: SpecMessagePart[] }): JSX.Element | null {\n const spec = useMemo(() => {\n const builtSpec = buildSpecFromParts(dedupeSpecParts(parts));\n\n return builtSpec ? sanitizeSpec(builtSpec) : null;\n }, [parts]);\n const stateKey = useMemo(() => JSON.stringify(spec?.state ?? {}), [spec]);\n\n if (!spec) {\n return null;\n }\n\n return (\n <StateProvider initialState={spec.state} key={stateKey}>\n <VisibilityProvider>\n <ActionProvider>\n <Renderer fallback={fallback} registry={registry} spec={spec} />\n </ActionProvider>\n </VisibilityProvider>\n </StateProvider>\n );\n}\n\nexport type { SpecMessagePart };\n"]}
|
package/dist/ui.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import'./index.css';export{
|
|
1
|
+
import'./index.css';export{Rc as Alert,Tc as AlertDescription,Sc as AlertTitle,Eb as Attachment,Kb as AttachmentAction,Jb as AttachmentActions,Gb as AttachmentContent,Ib as AttachmentDescription,La as AttachmentEmpty,Mb as AttachmentGroup,Ia as AttachmentHoverCard,Ka as AttachmentHoverCardContent,Ja as AttachmentHoverCardTrigger,Ga as AttachmentInfo,Fb as AttachmentMedia,Fa as AttachmentPreview,Ha as AttachmentRemove,Hb as AttachmentTitle,Lb as AttachmentTrigger,Ea as Attachments,o as Checkbox,Ta as CodeBlock,Ra as CodeBlockActions,Na as CodeBlockContainer,Sa as CodeBlockContent,Ua as CodeBlockCopyButton,Qa as CodeBlockFilename,Oa as CodeBlockHeader,Va as CodeBlockLanguageSelector,Ya as CodeBlockLanguageSelectorContent,Za as CodeBlockLanguageSelectorItem,Wa as CodeBlockLanguageSelectorTrigger,Xa as CodeBlockLanguageSelectorValue,Pa as CodeBlockTitle,p as Collapsible,r as CollapsibleContent,q as CollapsibleTrigger,_a as Conversation,$a as ConversationContent,db as ConversationDownload,ab as ConversationEmptyState,bb as ConversationScrollButton,na as DrawerModal,f as ExternalLink,g as Form,l as FormControl,m as FormDescription,h as FormField,j as FormItem,k as FormLabel,n as FormMessage,qa as HoverCard,sa as HoverCardContent,ra as HoverCardTrigger,s as Input,ua as InputGroup,va as InputGroupAddon,wa as InputGroupButton,ya as InputGroupInput,xa as InputGroupText,za as InputGroupTextarea,la as InsufficientPermissionsTooltipContent,e as Label,Rb as LocalReferencedSourcesContext,eb as Message,hb as MessageAction,gb as MessageActions,ib as MessageBranch,jb as MessageBranchContent,mb as MessageBranchNext,nb as MessageBranchPage,lb as MessageBranchPrevious,kb as MessageBranchSelector,fb as MessageContent,ob as MessageResponse,pb as MessageToolbar,qb as ModelSelector,sb as ModelSelectorContent,tb as ModelSelectorDialog,wb as ModelSelectorEmpty,xb as ModelSelectorGroup,ub as ModelSelectorInput,yb as ModelSelectorItem,vb as ModelSelectorList,Bb as ModelSelectorLogo,Cb as ModelSelectorLogoGroup,Db as ModelSelectorName,Ab as ModelSelectorSeparator,zb as ModelSelectorShortcut,rb as ModelSelectorTrigger,ma as PermissionTooltip,t as Popover,w as PopoverAnchor,v as PopoverContent,u as PopoverTrigger,Vb as PromptInput,Tb as PromptInputActionAddAttachments,Ub as PromptInputActionAddScreenshot,ac as PromptInputActionMenu,cc as PromptInputActionMenuContent,dc as PromptInputActionMenuItem,bc as PromptInputActionMenuTrigger,Wb as PromptInputBody,$b as PromptInputButton,sc as PromptInputCommand,vc as PromptInputCommandEmpty,wc as PromptInputCommandGroup,tc as PromptInputCommandInput,xc as PromptInputCommandItem,uc as PromptInputCommandList,yc as PromptInputCommandSeparator,Zb as PromptInputFooter,Yb as PromptInputHeader,kc as PromptInputHoverCard,mc as PromptInputHoverCardContent,lc as PromptInputHoverCardTrigger,Pb as PromptInputProvider,fc as PromptInputSelect,hc as PromptInputSelectContent,ic as PromptInputSelectItem,gc as PromptInputSelectTrigger,jc as PromptInputSelectValue,ec as PromptInputSubmit,oc as PromptInputTab,qc as PromptInputTabBody,rc as PromptInputTabItem,pc as PromptInputTabLabel,nc as PromptInputTabsList,Xb as PromptInputTextarea,_b as PromptInputTools,Bc as Reasoning,Dc as ReasoningContent,Cc as ReasoningTrigger,z as ResizableHandle,y as ResizablePanel,x as ResizablePanelGroup,A as Sheet,C as SheetClose,F as SheetContent,J as SheetDescription,H as SheetFooter,G as SheetHeader,E as SheetOverlay,D as SheetPortal,I as SheetTitle,B as SheetTrigger,zc as Shimmer,Y as Sidebar,Q as SidebarContent,R as SidebarGroup,T as SidebarGroupContent,S as SidebarGroupLabel,P as SidebarInset,U as SidebarMenu,W as SidebarMenuButton,V as SidebarMenuItem,M as SidebarPanel,L as SidebarProvider,O as SidebarRail,N as SidebarTrigger,Hc as Source,Ec as Sources,Gc as SourcesContent,Fc as SourcesTrigger,Ic as SpeechInput,ta as Spinner,Kc as Suggestion,Jc as Suggestions,Z as Switch,_ as Table,aa as TableBody,fa as TableCaption,ea as TableCell,ba as TableFooter,da as TableHead,$ as TableHeader,ca as TableRow,ga as Tabs,ja as TabsContent,ha as TabsList,ia as TabsTrigger,ka as Textarea,pa as Toaster,b as Toggle,c as ToggleGroup,d as ToggleGroupItem,Lc as Tool,Oc as ToolContent,Nc as ToolHeader,Pc as ToolInput,Qc as ToolOutput,Ba as getAttachmentLabel,Aa as getMediaCategory,Mc as getStatusBadge,Ma as highlightCode,cb as messagesToMarkdown,oa as toast,a as toggleVariants,Da as useAttachmentContext,Ca as useAttachmentsContext,i as useFormField,Qb as usePromptInputAttachments,Nb as usePromptInputController,Sb as usePromptInputReferencedSources,Ob as useProviderAttachments,Ac as useReasoning,K as useSidebar}from'./chunk-YCCFUGWJ.js';export{b as Badge,z as ButtonGroup,B as ButtonGroupSeparator,A as ButtonGroupText,m as Command,n as CommandDialog,q as CommandEmpty,r as CommandGroup,o as CommandInput,t as CommandItem,p as CommandList,s as CommandSeparator,u as CommandShortcut,c as Dialog,f as DialogClose,h as DialogContent,l as DialogDescription,j as DialogFooter,i as DialogHeader,g as DialogOverlay,e as DialogPortal,k as DialogTitle,d as DialogTrigger,w as ScrollArea,x as ScrollBar,v as Separator,a as badgeVariants,y as buttonGroupVariants}from'./chunk-32ZU4MLE.js';export{a as Select,e as SelectContent,b as SelectGroup,g as SelectItem,f as SelectLabel,j as SelectScrollDownButton,i as SelectScrollUpButton,h as SelectSeparator,d as SelectTrigger,c as SelectValue}from'./chunk-HDOIOXMP.js';export{a as Avatar,c as AvatarFallback,d as AvatarGroup,b as AvatarImage,e as DropdownMenu,k as DropdownMenuCheckboxItem,h as DropdownMenuContent,i as DropdownMenuGroup,j as DropdownMenuItem,n as DropdownMenuLabel,f as DropdownMenuPortal,l as DropdownMenuRadioGroup,m as DropdownMenuRadioItem,o as DropdownMenuSeparator,p as DropdownMenuShortcut,q as DropdownMenuSub,s as DropdownMenuSubContent,r as DropdownMenuSubTrigger,g as DropdownMenuTrigger,t as Skeleton}from'./chunk-SZEGGBOC.js';import'./chunk-U45E5X3H.js';export{b as Tooltip,e as TooltipContent,d as TooltipPortal,a as TooltipProvider,c as TooltipTrigger}from'./chunk-USNXQOMJ.js';export{b as Button,a as buttonVariants}from'./chunk-6NRQMG26.js';import'./chunk-O2QMYUPS.js';//# sourceMappingURL=ui.js.map
|
|
2
2
|
//# sourceMappingURL=ui.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import'./index.css';import {h}from'./chunk-NNA4MLFC.js';import {t,e,g,a,b as b$2,c,h as h$1,n,o,k,j,p}from'./chunk-SZEGGBOC.js';import {b}from'./chunk-U45E5X3H.js';import {b as b$1}from'./chunk-6NRQMG26.js';import'./chunk-O2QMYUPS.js';import v from'boring-avatars';import {Monitor,Moon,Sun}from'lucide-react';import {jsx,jsxs}from'react/jsx-runtime';var A=["#06d9b6","#a4f479","#d4d323","#fb468f","#0ec4f1"];function F({projectId:D}){let{theme:r,setTheme:t$1}=b(),[C,n$1]=h();return C?jsx(t,{className:"fk:h-8 fk:w-8 fk:rounded-full"}):jsxs(e,{children:[jsx(g,{asChild:true,children:jsx(b$1,{className:"fk:relative fk:h-8 fk:w-8 fk:rounded-full",variant:"ghost",children:jsxs(a,{className:"fk:h-8 fk:w-8",children:[n$1.user?.avatar_url?jsx(b$2,{alt:n$1.user.display_name,src:n$1.user.avatar_url}):null,jsx(c,{className:"fk:bg-transparent",children:jsx(v,{className:"fk:size-8",colors:A,name:n$1.user?.id??"user",size:32,variant:"marble"})})]})})}),jsxs(h$1,{align:"end",className:"fk:w-56",forceMount:true,children:[jsx(n,{className:"font-normal",children:jsxs("div",{className:"fk:flex fk:flex-col fk:space-y-1",children:[jsx("p",{className:"fk:text-sm fk:font-medium fk:leading-none",children:n$1.user?.display_name}),jsx("p",{className:"fk:text-xs fk:leading-none fk:text-muted-foreground",children:n$1.user?.email})]})}),jsx(o,{}),jsx(n,{children:"Theme"}),jsxs(k,{checked:r==="system",onCheckedChange:()=>{t$1("system");},children:[jsx(Monitor,{className:"fk:mr-2 fk:h-4 fk:w-4"}),jsx("span",{children:"System"})]}),jsxs(k,{checked:r==="dark",onCheckedChange:()=>{t$1("dark");},children:[jsx(Moon,{className:"fk:mr-2 fk:h-4 fk:w-4"}),jsx("span",{children:"Dark"})]}),jsxs(k,{checked:r==="light",onCheckedChange:()=>{t$1("light");},children:[jsx(Sun,{className:"fk:mr-2 fk:h-4 fk:w-4"}),jsx("span",{children:"Light"})]}),jsx(o,{}),jsxs(j,{onClick:()=>{n$1.logout(D).then(()=>{}).catch(()=>{});},children:["Log out",jsx(p,{children:"\u21E7\u2318Q"})]})]})]})}export{F as UserNav};//# sourceMappingURL=user-nav-QZTYBG45.js.map
|
|
2
|
+
//# sourceMappingURL=user-nav-QZTYBG45.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ui/components/user-nav.tsx"],"names":["AVATAR_COLORS","UserNav","projectId","theme","setTheme","useTheme","isLoading","auth","useAuth","jsx","Skeleton","jsxs","DropdownMenu","DropdownMenuTrigger","Button","Avatar","AvatarImage","AvatarFallback","BoringAvatar","DropdownMenuContent","DropdownMenuLabel","DropdownMenuSeparator","DropdownMenuCheckboxItem","Monitor","Moon","Sun","DropdownMenuItem","DropdownMenuShortcut"],"mappings":"8VAmBA,IAAMA,CAAAA,CAAgB,CAAC,SAAA,CAAW,SAAA,CAAW,SAAA,CAAW,UAAW,SAAS,CAAA,CAMrE,SAASC,CAAAA,CAAQ,CAAE,SAAA,CAAAC,CAAU,CAAA,CAAuB,CACzD,GAAM,CAAE,KAAA,CAAAC,CAAAA,CAAO,QAAA,CAAAC,GAAS,CAAA,CAAIC,CAAAA,EAAS,CAC/B,CAACC,CAAAA,CAAWC,GAAI,CAAA,CAAIC,CAAAA,EAAQ,CAElC,OAAIF,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AAS,IAAM,CACbnB,GAAAA,CACG,MAAA,CAAOL,CAAS,CAAA,CAChB,KAAK,IAAM,CAEZ,CAAC,CAAA,CACA,KAAA,CAAM,IAAM,CAEb,CAAC,EACL,CAAA,CACD,QAAA,CAAA,CAAA,SAAA,CAECO,GAAAA,CAACkB,CAAAA,CAAA,CAAqB,QAAA,CAAA,eAAA,CAAG,CAAA,CAAA,CAC3B,CAAA,CAAA,CACF,GACF,CAEJ","file":"user-nav-QZTYBG45.js","sourcesContent":["import type { JSX } from 'react';\nimport BoringAvatar from 'boring-avatars';\nimport { Monitor, Moon, Sun } from 'lucide-react';\nimport { useTheme } from '../theme-context';\nimport { Avatar, AvatarFallback, AvatarImage } from '../primitives/avatar';\nimport { Button } from '../primitives/button';\nimport { Skeleton } from '../primitives/skeleton';\nimport {\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuShortcut,\n DropdownMenuTrigger,\n} from '../primitives/dropdown-menu';\nimport { useAuth } from '../../auth/auth-context';\n\nconst AVATAR_COLORS = ['#06d9b6', '#a4f479', '#d4d323', '#fb468f', '#0ec4f1'];\n\ntype Props = {\n projectId: string;\n};\n\nexport function UserNav({ projectId }: Props): JSX.Element {\n const { theme, setTheme } = useTheme();\n const [isLoading, auth] = useAuth();\n\n if (isLoading) {\n return <Skeleton className=\"fk:h-8 fk:w-8 fk:rounded-full\" />;\n }\n\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button className=\"fk:relative fk:h-8 fk:w-8 fk:rounded-full\" variant=\"ghost\">\n <Avatar className=\"fk:h-8 fk:w-8\">\n {auth.user?.avatar_url ? <AvatarImage alt={auth.user.display_name} src={auth.user.avatar_url} /> : null}\n <AvatarFallback className=\"fk:bg-transparent\">\n <BoringAvatar\n className=\"fk:size-8\"\n colors={AVATAR_COLORS}\n name={auth.user?.id ?? 'user'}\n size={32}\n variant=\"marble\"\n />\n </AvatarFallback>\n </Avatar>\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"fk:w-56\" forceMount>\n <DropdownMenuLabel className=\"font-normal\">\n <div className=\"fk:flex fk:flex-col fk:space-y-1\">\n <p className=\"fk:text-sm fk:font-medium fk:leading-none\">{auth.user?.display_name}</p>\n <p className=\"fk:text-xs fk:leading-none fk:text-muted-foreground\">{auth.user?.email}</p>\n </div>\n </DropdownMenuLabel>\n <DropdownMenuSeparator />\n <DropdownMenuLabel>Theme</DropdownMenuLabel>\n <DropdownMenuCheckboxItem\n checked={theme === 'system'}\n onCheckedChange={() => {\n setTheme('system');\n }}\n >\n <Monitor className=\"fk:mr-2 fk:h-4 fk:w-4\" />\n <span>System</span>\n </DropdownMenuCheckboxItem>\n <DropdownMenuCheckboxItem\n checked={theme === 'dark'}\n onCheckedChange={() => {\n setTheme('dark');\n }}\n >\n <Moon className=\"fk:mr-2 fk:h-4 fk:w-4\" />\n <span>Dark</span>\n </DropdownMenuCheckboxItem>\n <DropdownMenuCheckboxItem\n checked={theme === 'light'}\n onCheckedChange={() => {\n setTheme('light');\n }}\n >\n <Sun className=\"fk:mr-2 fk:h-4 fk:w-4\" />\n <span>Light</span>\n </DropdownMenuCheckboxItem>\n <DropdownMenuSeparator />\n <DropdownMenuItem\n onClick={() => {\n auth\n .logout(projectId)\n .then(() => {\n //\n })\n .catch(() => {\n //\n });\n }}\n >\n Log out\n <DropdownMenuShortcut>⇧⌘Q</DropdownMenuShortcut>\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flexkit/studio",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Flexkit Studio - Build custom internal tools like PIMs, CRMs, and ERPs with a flexible React UI and a graph-backed API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"flexkit",
|
|
@@ -157,8 +157,8 @@
|
|
|
157
157
|
"uuid": "^9.0.1",
|
|
158
158
|
"vaul": "1.1.2",
|
|
159
159
|
"zod": "4.4.3",
|
|
160
|
-
"@flexkit/agent-protocol": "^0.3.
|
|
161
|
-
"@flexkit/schema": "0.2.
|
|
160
|
+
"@flexkit/agent-protocol": "^0.3.3",
|
|
161
|
+
"@flexkit/schema": "0.2.4"
|
|
162
162
|
},
|
|
163
163
|
"peerDependencies": {
|
|
164
164
|
"react": "^19.0.0",
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import'./index.css';import {a}from'./chunk-OFLU53AC.js';import {f as f$2,b,c,g as g$1,a as a$1,e,d as d$1}from'./chunk-CSUHZFEP.js';import {p,s,z,l,j,i,k,m,q,n,d as d$2,y,v as v$1,t,f as f$3,g as g$2,e as e$1,r,x,A,w,o}from'./chunk-2FQWBOU6.js';import {g,f as f$1,a as a$3}from'./chunk-H6TOYVW2.js';import {f}from'./chunk-66N44IKJ.js';import'./chunk-NNA4MLFC.js';import {Ub,L,M,S,O,Sb,db,eb,gb,_b,bc,$b,ac,cc,dc,fc,gc,hc,Yb,kc,lc,oc,mc,nc,Nc,jc}from'./chunk-YIGEER6B.js';import {v}from'./chunk-ODORXGGY.js';import'./chunk-SZEGGBOC.js';import {d}from'./chunk-5DHOBLAE.js';import'./chunk-HDOIOXMP.js';import {a as a$2}from'./chunk-O2QMYUPS.js';import {useRef,useMemo,useState,useEffect,useLayoutEffect}from'react';import {LoaderCircle,CornerDownRightIcon,CheckIcon,CopyIcon,PencilIcon}from'lucide-react';import {useParams,useNavigate}from'react-router-dom';import ie,{useSWRConfig}from'swr';import {jsx,jsxs}from'react/jsx-runtime';function wt(e,t){let r=Date.parse(e.createdAt)-Date.parse(t.createdAt);return Number.isFinite(r)&&r!==0?r:e.createdAt!==t.createdAt?e.createdAt<t.createdAt?-1:1:e.id===t.id?0:e.id<t.id?-1:1}function re(e){return [...new Map(e.map(r=>[r.id,r])).values()].sort(wt)}function Ae(e,t){if(!t)return e;if(!e)return t;let r=new Set(t.messages.map(d=>d.id)),a=t.messages[t.messages.length-1],s=e.messages.filter(d=>!r.has(d.id)&&(!a||wt(d,a)>0));return s.length===0?t:{...t,messages:re([...t.messages,...s])}}var Jt="flexkit:agent:draft:";function xt(){return typeof localStorage>"u"?null:localStorage}function Pt(e,t){return `${Jt}${e}:${t??"new"}`}function bt(e,t=xt()){try{return t?.getItem(e)??""}catch{return ""}}function Dt(e,t,r=xt()){try{t.trim().length===0?r?.removeItem(e):r?.setItem(e,t);}catch{}}function qt(e){return e==="pending"||e==="streaming"||e==="awaiting_approval"}function Et(e){return e==="queued"||e==="steering"}function ke(e){for(let t=e.length-1;t>=0;t--){let r=e[t];if(r.role==="assistant"){if(!qt(r.status))break;return {after:e.slice(t+1),before:e.slice(0,t),live:r}}}return {after:[],before:e,live:null}}function Rt(e){return e==="steering"?"Picked up at the next step":e==="queued"?"Sends when this turn ends":null}function Nt(e){let t=new Set;for(let r of e)if(!(r.role!=="assistant"||!Array.isArray(r.parts)))for(let a of r.parts){let s=a.type==="data-mid-turn-message"?a.data?.messageId:null;typeof s=="string"&&t.add(s);}return t}function Ce(e){return e.find(t=>t.role==="user"&&t.status==="queued")??null}function _t(e){return e.streaming&&!e.hasDraft?"stop":"send"}var rn=6e4;function sn(e){if(!e)return 0;if(ke(e.messages).live||Ce(e.messages))return q;if(!e.messages.some(a=>a.role==="assistant"&&a.status==="complete"))return 0;let r=new Date(e.chat.lastMessageAt??e.chat.updatedAt).getTime();return Date.now()-r<rn?q:0}function an(e,t,r){return {chat:{createdAt:r,id:e,lastMessageAt:r,modelId:t,title:null,updatedAt:r},messages:[],pendingApproval:null}}function Ut(e,t,r,a,s,d){return e||(t?{chat:t,messages:[],pendingApproval:null}:r||an(a,s,d))}function Lt(e,t){let r=new Set([t.userMessage.id,t.assistantMessage.id]);return {...e,messages:re([...e.messages.filter(a=>!r.has(a.id)),t.userMessage,t.assistantMessage])}}function on(e,t){return {...e,messages:re([...e.messages.filter(r=>r.id!==t.id),t])}}function ln(e,t,r){return t?Ae(e[t],r):r}function un(e){return e==="awaiting_approval"?"awaiting_approval":e==="complete"?"success":e==="failed"?"failed":"running"}function Ne({attachments:e=[],label:t,text:r}){let{textInput:a}=Sb(),[s,d$1]=useState(false),c=r.trim().length>0;async function v(){await navigator.clipboard.writeText(r),d$1(true),setTimeout(()=>d$1(false),1500);}return jsxs("div",{className:"fk:group fk:ml-auto fk:flex fk:w-fit fk:max-w-[70%] fk:flex-col fk:items-end fk:gap-1",children:[jsx(o,{attachments:e}),c?jsx("div",{className:"fk:whitespace-pre-wrap fk:rounded-xl fk:bg-muted fk:dark:bg-white/20 fk:px-3.5 fk:py-2 fk:text-base fk:corner-squircle",children:r}):null,t?jsxs("span",{className:"fk:inline-flex fk:items-center fk:gap-1 fk:text-xs fk:text-muted-foreground",children:[jsx(CornerDownRightIcon,{className:"fk:size-3 fk:shrink-0"}),t]}):null,jsxs("div",{className:c?"fk:flex fk:gap-0.5 fk:opacity-0 fk:transition-opacity fk:group-hover:opacity-100":"fk:hidden",children:[jsxs(L,{children:[jsx(M,{asChild:true,children:jsx(d,{"aria-label":"Copy prompt",className:"fk:size-6 fk:text-muted-foreground",size:"icon",variant:"ghost",onClick:()=>{v();},children:s?jsx(CheckIcon,{className:"fk:size-3.5"}):jsx(CopyIcon,{className:"fk:size-3.5"})})}),jsx(O,{children:"Copy"})]}),jsxs(L,{children:[jsx(M,{asChild:true,children:jsx(d,{"aria-label":"Edit prompt",className:"fk:size-6 fk:text-muted-foreground",size:"icon",variant:"ghost",onClick:()=>a.setInput(r),children:jsx(PencilIcon,{className:"fk:size-3.5"})})}),jsx(O,{children:"Edit"})]})]})]})}function Bt(e){let r=e.find(a=>a.type==="data-suggested-prompt")?.data?.prompt;return typeof r=="string"&&r.trim()?r:null}function Ot({prompt:e}){let{textInput:t}=Sb();return jsx("div",{className:"fk:flex fk:justify-start",children:jsxs("button",{className:"fk:inline-flex fk:max-w-full fk:items-center fk:gap-1.5 fk:rounded-full fk:border fk:border-border/70 fk:bg-muted/40 fk:px-3 fk:py-1.5 fk:text-left fk:text-sm fk:text-muted-foreground fk:transition-colors fk:hover:border-border fk:hover:bg-muted fk:hover:ext-foreground fk:corner-squircle",title:"Use as your next message",type:"button",onClick:()=>t.setInput(e),children:[jsx(CornerDownRightIcon,{className:"fk:size-3 fk:shrink-0"}),jsx("span",{className:"fk:truncate",children:e})]})})}function dn({api:e,part:t,partIndex:r,parts:a}){return t.type.startsWith("tool-")?t.state==="output-error"?jsx(y,{message:t.errorText??"The tool call failed."}):null:jsx(x,{api:e,part:t,partIndex:r,parts:a})}function Ft({api:e,message:t,showSuggestion:r=false}){if(t.role==="user")return jsx(Ne,{attachments:n(t.parts),label:Rt(t.status),text:t.textContent});let a=(Array.isArray(t.parts)?t.parts:[]).filter(c=>!d$2(c)&&!(c.type.startsWith("tool-")&&c.state!=="output-error")),s=a.some(c=>c.type==="data-turn-error"),d=r&&!t.error?Bt(a):null;return a.length===0&&!t.error?null:jsxs("div",{className:"fk:w-full fk:min-w-0 fk:space-y-8",children:[a.map((c,v)=>jsx(dn,{api:e,part:c,partIndex:v,parts:a},c.toolCallId??`${t.id}-${v.toString()}`)),t.error&&!s?jsx(y,{message:t.error}):null,d?jsx(Ot,{prompt:d}):null]})}function fn({api:e,chatId:t$1,detail:r$1,message:a,onMidTurnDelivered:s,onStatusChange:d,onTurnUpdated:c}){let v=un(a.status),S=a.workflowRunId?e.getAgentChatStreamUrl(t$1,a.workflowRunId):"",[O,U]=useState(0),[p,M]=useState(false),[h,I]=useState({}),x$1=useRef(null),{message:A$1,status:m}=v$1(S,{decidedApprovals:h,recordStatus:v,resumeToken:O,suppressApprovalPause:p}),L=useMemo(()=>A$1?[{...A$1,parts:A$1.parts.filter(g=>!d$2(g))}]:[],[A$1]),b=t(L),j=useRef(c);j.current=c;let X=useRef(d);X.current=d;let F=useMemo(()=>({onApprovalDecided:(g,z)=>{g&&z&&z!=="pending"&&I(B=>({...B,[g]:z})),!(g&&x$1.current===g)&&(g&&(x$1.current=g),M(true),U(B=>B+1),j.current());}}),[]);useEffect(()=>{U(0),M(false),x$1.current=null,I({});},[a.id]),useEffect(()=>{p&&a.status==="streaming"&&M(false);},[a.status,p]),useEffect(()=>{(m==="finished"||m==="paused")&&j.current();},[m]);let u=(A$1?.parts??[]).filter(g=>g.type==="data-mid-turn-message").map(g=>String(g.data?.messageId??"")).join(`
|
|
2
|
-
`),i=useRef(s);i.current=s,useEffect(()=>{u&&i.current(u.split(`
|
|
3
|
-
`));},[u]);let D=!p&&a.status!=="streaming"&&(a.status==="awaiting_approval"||m==="paused"||f$3(A$1)),N=useMemo(()=>new Set(g$2(A$1)),[A$1]),_=r$1.pendingApproval&&!N.has(r$1.pendingApproval.id)?r$1.pendingApproval:null,Q=A$1?.parts[A$1.parts.length-1],ue=Q?.type==="text"&&Q.state==="streaming",K=D?"Awaiting approval":e$1(A$1)??"Thinking",H=D?m!=="finished"&&m!=="error":m==="streaming"&&!ue;useEffect(()=>{X.current({label:K,visible:H});},[K,H]);let E=!!_&&D,G=m==="finished"?Bt(b.flatMap(g=>g.parts)):null;return b.length===0&&!E?jsx(r.Provider,{value:F,children:null}):jsx(r.Provider,{value:F,children:jsxs("div",{className:"fk:w-full fk:min-w-0 fk:space-y-8",children:[b.map(g=>jsx("div",{className:"fk:space-y-8 fk:min-w-0",children:g.parts.map((z,B)=>jsx(x,{api:e,part:z,partIndex:B,parts:g.parts},B))},g.id)),_&&E?jsx(A,{api:e,message:w(_)}):null,G?jsx(Ot,{prompt:G}):null]})})}function cn({draftKey:e}){let{textInput:t}=Sb(),{setInput:r,value:a}=t,s=useRef(null);return useLayoutEffect(()=>{if(s.current===e){Dt(e,a);return}s.current=e;let d=bt(e);d!==a&&r(d);},[e,r,a]),null}function gn({api:e$1,effort:t,modelKey:r,modelPending:a,models:s,onEffortChange:d,onError:c$1,onModelChange:v,onSend:S,onStop:O,placeholder:U,sending:p,streaming:M}){let{attachments:h,textInput:I}=Sb(),x=l(e$1,c$1),A=useRef(false),m$1=s.filter(i=>!i.deprecated||b(i)===r),L=c(s,r),b$1=e(L),j$1=d$1(L,t),X=I.value.trim().length>0||h.files.length>0,F=_t({hasDraft:X,streaming:M}),u=X&&!x.isUploading&&!p&&!a;return jsxs(_b,{accept:k,className:"fk:mx-auto fk:max-w-4xl",maxFileSize:i,maxFiles:j,multiple:true,onError:i=>c$1(i.message),onSubmit:({text:i})=>{let D=i?.trim()??"",N=x.getUploaded(h.files.map(_=>_.id));return !D&&N.length===0||x.isUploading||p||A.current||a?Promise.reject(new Error("The message cannot be sent right now.")):(A.current=true,I.clear(),S(D,N).catch(_=>{throw I.setInput(i),_}).finally(()=>{A.current=false;}))},children:[h.files.length>0?jsx(bc,{children:jsx(m,{uploads:x})}):null,jsx($b,{children:jsx(ac,{disabled:p,placeholder:U})}),jsxs(cc,{children:[jsxs(dc,{children:[jsxs(fc,{children:[jsx(gc,{"aria-label":"Add attachments",className:"fk:border-0 fk:bg-border fk:corner-round",disabled:p,tooltip:"Add photos or files"}),jsx(hc,{children:jsx(Yb,{})})]}),m$1.length>0?jsxs(kc,{value:r??void 0,onValueChange:v,children:[jsx(lc,{"aria-label":"Model",className:"fk:min-w-44",children:jsx(oc,{placeholder:"Model"})}),jsx(mc,{children:m$1.map(i=>jsx(nc,{value:b(i),children:i.name},b(i)))})]}):null,b$1.length>1&&j$1?jsxs(kc,{value:j$1,onValueChange:d,children:[jsx(lc,{"aria-label":"Reasoning effort",className:"fk:min-w-28",children:jsx(oc,{placeholder:"Effort"})}),jsx(mc,{children:b$1.map(i=>jsx(nc,{value:i.value,children:i.label},i.value))})]}):null]}),jsxs("div",{className:"fk:flex fk:items-center fk:gap-3",children:[jsx(Nc,{disabled:p,onAudioRecorded:async(i,D)=>{let{text:N}=await e$1.transcribeAgentAudio(i,D);return N},onError:i=>c$1(i.message),onTranscriptionChange:i=>{c$1(null),I.setInput(a$3(I.value,i));}}),jsx(jc,{className:"fk:corner-round",disabled:F==="stop"?false:!u,status:F==="stop"?"streaming":void 0,onStop:()=>{O();}})]})]})]})}var Re={chatId:null,error:null,loading:false,older:[],page:null},pn=3e3;function mn({api:e,chatId:t,projectId:r,pendingFollowUp:a,pendingMessage:s,resolveDetail:d$1}){let{data:c,mutate:v}=ie(t?g(r).agentChat(t):null,f$1,{refreshInterval:0}),S=d$1(c),[O,U]=useState(Re),p=O.chatId===t?O:Re,M=useRef(t);M.current=t;let h=(o,C)=>U(y=>{if(y.chatId!==o&&M.current!==o)return y;let k=y.chatId===o?y:{...Re,chatId:o};return {...k,...C(k)}}),I=useRef({chatId:null,messages:[]}),x=S?.messages;useEffect(()=>{let o=I.current,C=x??[];if(I.current={chatId:t,messages:C},!t||o.chatId!==t)return;let y=new Set(C.map(T=>T.id)),k=o.messages.filter(T=>!y.has(T.id));k.length>0&&h(t,T=>({older:re([...T.older,...k])}));},[t,x]);let A=new Set(S?.messages.map(o=>o.id)??[]),m=[...p.older.filter(o=>!A.has(o.id)),...S?.messages??[]],L=useRef(S);L.current=S;let b=useRef(void 0);ie(t?`${g(r).agentChat(t)}?view=status`:null,f$1,{refreshInterval:()=>sn(L.current),onSuccess:o=>{let C=JSON.stringify(o),y=b.current;b.current=C;let{current:k}=L,T=k?[...k.messages].reverse().find(ve=>ve.role==="assistant"):void 0;(y&&y!==C||T&&o.latestMessage&&(T.id!==o.latestMessage.id||T.status!==o.latestMessage.status||T.workflowRunId!==o.latestMessage.workflowRunId||k?.chat.updatedAt!==o.chat.updatedAt))&&v();}});let j=async()=>{let o=p.page?.cursor??S?.nextCursor;if(!t||!o||p.loading)return;let C=t;h(C,()=>({error:null,loading:true}));try{let y=await f$1(`${g(r).agentChat(C)}?before=${encodeURIComponent(o)}`);h(C,k=>({loading:!1,older:re([...y.messages,...k.older]),page:{cursor:y.nextCursor??null,hasMore:y.hasMore??!1}}));}catch{h(C,()=>({error:"Could not load earlier messages. Try again.",loading:false}));}},{after:X,before:F,live:u}=ke(m),[i,D]=useState({ids:[],messageId:""}),N=Nt(m);for(let o of u&&i.messageId===u.id?i.ids:[])N.add(o);let _=X.filter(o=>Et(o.status)&&!N.has(o.id)),Q=F.filter(o=>!N.has(o.id)),K=(!u&&!s?Ce(m):null)?.id??null,[H,E]=useState(0),G=useRef(null);useEffect(()=>{if(!t||!K||G.current===K)return;G.current=K;let o=false,C=null;return e.startQueuedAgentChatMessage(t,K).then(()=>{},()=>{C=setTimeout(()=>{o||E(y=>y+1);},pn);}).finally(()=>{G.current=null,v();}),()=>{o=true,C&&clearTimeout(C);}},[e,t,v,K,H]);let[g$1,z$1]=useState(null),B=u&&g$1?.messageId===u.id?g$1.status:null;if(t&&!S&&!s)return jsxs("div",{className:"fk:flex fk:flex-1 fk:items-center fk:justify-center fk:gap-2 fk:text-sm fk:text-muted-foreground",children:[jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}),"Loading chat..."]});let se=!!s||!!u,Y=[...Q].reverse().find(o=>o.role==="assistant")?.id??null,V=u?B?.label??"Thinking":"Sending",de=u?B?.visible??true:true;return jsxs(db,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:[jsx(eb,{className:"fk:gap-0 fk:p-0",children:jsxs("div",{className:"fk:mx-auto fk:w-full fk:max-w-4xl fk:space-y-5 fk:pb-6 fk:pr-4",children:[p.page?.hasMore??S?.hasMore?jsx(d,{variant:"ghost",disabled:p.loading,onClick:()=>{j();},children:p.loading?"Loading\u2026":"Load earlier messages"}):null,p.error?jsx("p",{role:"alert",children:p.error}):null,Q.map(o=>jsx(Ft,{api:e,message:o,showSuggestion:!se&&o.id===Y},o.id)),u&&t&&S?jsx(fn,{api:e,chatId:t,detail:S,message:u,onMidTurnDelivered:o=>D({ids:o,messageId:u.id}),onStatusChange:o=>z$1({messageId:u.id,status:o}),onTurnUpdated:()=>{v();}}):null,s&&!u?jsx(Ne,{attachments:s.attachments,text:s.text}):null,se?jsx(z,{label:V,visible:de}):null,_.map(o=>jsx(Ft,{api:e,message:o},o.id)),a&&u?jsx(Ne,{attachments:a.attachments,text:a.text}):null]})}),jsx(gb,{})]})}var Kt=["Where should we begin?","Ready when you are","What\u2019s on the agenda today?","What\u2019s on your mind today?"];function hn(e){return [`How can I help, ${e}?`,`Good to see you, ${e}.`,`Hey, ${e}. Ready to dive in?`]}function An(e){let t=e?[...Kt,...hn(e)]:Kt;return t[Math.floor(Math.random()*t.length)]??"How can I help?"}var jt="flexkit-ai:lastModelId",_e="flexkit-ai:lastEffort";function kn(){if(typeof localStorage>"u")return null;try{let e=localStorage.getItem(jt);return e?{effort:localStorage.getItem(_e),modelKey:e}:null}catch{return null}}function Cn(e){return e.selectedModelKey?{effort:e.selectedEffort,modelKey:e.selectedModelKey}:e.awaitingChatModel?{effort:null,modelKey:null}:e.chatSelection?{effort:e.selectedEffort??e.chatSelection.effort,modelKey:e.chatSelection.modelKey}:e.lastUsed?{effort:e.selectedEffort??e.lastUsed.effort,modelKey:e.lastUsed.modelKey}:{effort:e.selectedEffort,modelKey:e.defaultModelKey}}function vn(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(jt,e.modelKey),e.effort?localStorage.setItem(_e,e.effort):localStorage.removeItem(_e);}catch{}}function Sn({projectId:e}){let{data:t,isLoading:r}=ie(g(e).agentProfile(),f$1),a=useMemo(()=>r?null:An(t?.preferredName??null),[t,r]);return jsx("div",{className:"fk:flex fk:flex-col fk:items-center fk:pb-2 fk:text-center",children:jsx("h2",{className:"fk:text-2xl fk:font-semibold",children:a??"\xA0"})})}function On(){let{api:e,projectId:t}=p(),{currentProject:r,projectSummaries:a$3}=f(),{chatId:s$1}=useParams(),d=useNavigate(),c$1=a(),{mutate:v$1}=useSWRConfig(),{data:S$1}=ie(t?g(t).tools():null,f$1),{data:O$1}=ie(t&&s$1?g(t).agentChat(s$1):null,f$1),U=useRef({});function p$1(l){return ln(U.current,s$1,l)}let M$1=p$1(O$1),h=useMemo(()=>S$1?.tools.models??[],[S$1]),[I,x]=useState(null),[A,m]=useState(null),L$1=useRef(null),[b$1,j]=useState(kn),[X,F]=useState(false),u=useRef(false),[i,D]=useState(null),N=i&&i.chatId===s$1?i:void 0,[_,Q]=useState(null),ue=_&&_.chatId===s$1?_:void 0,[K,H]=useState(null),E=M$1?.chat.modelId??null,G=!!s$1&&M$1===void 0,g$2=useMemo(()=>f$2(E,h)??(E?{effort:null,modelKey:E}:null),[E,h]),z=useMemo(()=>{let l=h.find(J=>!J.deprecated);return l?b(l):null},[h]),B=useMemo(()=>{let l=c(h,b$1?.modelKey??null);return b$1&&l&&!l.deprecated?b$1:null},[h,b$1]),{effort:se,modelKey:Y}=Cn({awaitingChatModel:G,chatSelection:g$2,defaultModelKey:z,lastUsed:B,selectedEffort:A,selectedModelKey:I}),V=Y?g$1({effort:se,modelKey:Y},h):null,de=G&&!I;useEffect(()=>{L$1.current=null,x(null),m(null),H(null);},[s$1]),useEffect(()=>{I===a$1&&E&&E!==a$1&&E!==L$1.current&&(x(null),m(null));},[E,I]);function o(l){j(l),vn(l);}function C(l){L$1.current=l===a$1?E:null,x(l),m(null),o({effort:null,modelKey:l});}function y(l){m(l),Y&&o({effort:l,modelKey:Y});}if(!t||!e)return jsx("div",{className:"fk:flex fk:h-full fk:items-center fk:justify-center fk:text-sm fk:text-muted-foreground",children:"Select a project to chat with the agent."});let k=e,T=t,ve=r?.title??a$3.find(l=>l.id===t)?.name??"your project",Ue=!s$1&&!N,fe=!!(M$1&&ke(M$1.messages).live);async function $t(l,J,te){Q({attachments:te,chatId:l,text:J});try{let w=await k.sendAgentChatFollowUp(l,{attachments:te,content:J,modelId:V});await v$1(g(T).agentChat(l),ne=>{let ae=Ut(Ae(U.current[l],ne),null,O$1,l,V,"turn"in w?w.turn.userMessage.createdAt:w.followUp.message.createdAt),Z="turn"in w?Lt(ae,w.turn):on(ae,w.followUp.message);return U.current[l]=Z,Z},{revalidate:!1});}finally{Q(null);}}async function Xt(l,J){if(u.current)throw new Error("A message is already being sent.");if(de)throw new Error("This chat is still loading.");u.current=true,F(true),H(null);let te=M$1?Ce(M$1.messages):null;if(s$1&&(fe||te)){try{!fe&&te&&await k.startQueuedAgentChatMessage(s$1,te.id).catch(()=>{}),await $t(s$1,l,J);}catch(w){throw H(w instanceof Error?w.message:"Failed to send the message."),w}finally{u.current=false,F(false);}return}D({attachments:J,chatId:s$1,text:l});try{let w=s$1?{chat:null,turn:await k.sendAgentChatMessage(s$1,{attachments:J,content:l,modelId:V})}:await k.startAgentChat({attachments:J,content:l,modelId:V}),{chat:ne,turn:ae}=w,Z=s$1??ne.id;await v$1(g(T).agentChat(Z),zt=>{let Le=Lt(Ut(Ae(U.current[Z],zt),ne,O$1,Z,V,ae.userMessage.createdAt),ae);return U.current[Z]=Le,Le},{revalidate:!1}),ne&&d(`${c$1}/chats/${ne.id}`),D(null);}catch(w){throw D(null),H(w instanceof Error?w.message:"Failed to send the message."),w}finally{u.current=false,F(false);}}async function Gt(){if(s$1)try{await k.stopAgentChat(s$1);}catch(l){H(l instanceof Error?l.message:"Failed to stop the turn.");}finally{await v$1(g(T).agentChat(s$1));}}return jsxs(Ub,{children:[jsx(cn,{draftKey:Pt(T,s$1)}),jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:flex-col fk:gap-2",children:[jsxs("div",{className:"fk:mb-2 fk:flex fk:shrink-0 fk:items-start fk:gap-2",children:[jsxs(L,{children:[jsx(M,{asChild:true,children:jsx(S,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(O,{children:"Toggle Sidebar"})]}),jsx(v,{orientation:"vertical",className:"fk:mt-1 fk:h-4"}),jsx("div",{className:"fk:flex fk:flex-1 fk:items-center fk:gap-2",children:jsx("h1",{className:"fk:truncate fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",children:s$1?M$1?.chat.title?.trim()??"Chat":"Agent"})})]}),jsx("div",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:gap-4",children:jsxs("div",{className:a$2("fk:flex fk:min-h-0 fk:min-w-0 fk:flex-1 fk:flex-col fk:gap-3",Ue&&"fk:justify-center fk:pb-[12vh]"),children:[Ue?jsx(Sn,{projectId:T}):jsx(s.Provider,{value:true,children:jsx(mn,{api:k,chatId:s$1??null,pendingFollowUp:ue,pendingMessage:N,projectId:t,resolveDetail:p$1})}),jsxs("div",{className:"fk:shrink-0 fk:pb-3",children:[K?jsx("p",{className:"fk:mx-auto fk:mb-2 fk:max-w-4xl fk:text-xs fk:text-destructive",children:K}):null,jsx(gn,{api:k,effort:se,modelKey:Y,modelPending:de,models:h,sending:X,streaming:fe,onEffortChange:y,onError:H,onModelChange:C,onSend:Xt,onStop:Gt,placeholder:fe?"Add context or steer the agent...":`Ask Flexkit anything about ${ve}...`})]})]})})]})]})}export{On as AgentChatPage};//# sourceMappingURL=chat-page-YWENJEUP.js.map
|
|
4
|
-
//# sourceMappingURL=chat-page-YWENJEUP.js.map
|
package/dist/chunk-2FQWBOU6.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import'./index.css';import {g,d,f as f$1}from'./chunk-H6TOYVW2.js';import {f,d as d$2}from'./chunk-66N44IKJ.js';import {sa,Sb,Vb,tb,o,pa,ya,da,ea,ha,ia,fa,ja as ja$1}from'./chunk-YIGEER6B.js';import {b,c,h,i,k,l,j,f as f$2}from'./chunk-ODORXGGY.js';import {d as d$1}from'./chunk-5DHOBLAE.js';import {lazy,createContext,useCallback,useRef,useState,useEffect,useMemo,useContext,useTransition,useId,Suspense}from'react';import Ra,{useSWRConfig}from'swr';import {formatDistance,format}from'date-fns';import {BotIcon,XCircleIcon,LoaderCircle,XIcon,CheckIcon,CloudUploadIcon,FileTextIcon,DownloadIcon,LinkIcon,MessageSquareIcon,SendIcon,CheckCircle2Icon,CircleSlashIcon,ShieldIcon,DatabaseZapIcon,ShieldCheckIcon,TriangleAlertIcon,ArrowRightIcon,FileIcon,CornerDownRightIcon,MoveRightIcon}from'lucide-react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {pipeJsonRender}from'@json-render/core';import {useLocation,Link}from'react-router-dom';import {readUIMessageStream,parseJsonEventStream,uiMessageChunkSchema}from'ai';function je(){let{currentProjectId:e}=f(),{mutate:t}=useSWRConfig();return useCallback(n=>{if(!e)return;let a=g(e).approvalsCount;n?t(a,n,{revalidate:true}):t(a);},[e,t])}var St=5e3,At=150,pe=new Set;function Nt(e){return async()=>{let t=await fetch(e,{credentials:"include",mode:"cors"});return t.status===404?"missing":t.ok?(await t.json()).approval??"missing":null}}function Tt(e,t,n=d$2){return !e||e.kind!=="schema"||e.status!=="approved"||e.error?false:e.executedAt?(n(t),false):true}function re({approvalId:e,approvalUrl:t,fetchApproval:n,projectId:a,revalidate:r=d$2,sleep:s=l=>new Promise(u=>setTimeout(u,l))}){let l=`${a}:${e}`,u=n??(t?Nt(t):null);!u||pe.has(l)||(pe.add(l),(async()=>{try{for(let p=0;p<At;p+=1){let f=null;try{f=await u();}catch{f=null;}if(f==="missing"||f!==null&&!Tt(f,a,r))return;await s(St);}}finally{pe.delete(l);}})());}var Et={approved:"fk:bg-success/20 fk:text-success",cancelled:"fk:bg-secondary fk:text-secondary-foreground",expired:"fk:bg-secondary fk:text-secondary-foreground",pending:"fk:bg-amber-500/20 fk:text-amber-600",rejected:"fk:bg-destructive/15 fk:text-destructive"};function $t({status:e}){return jsx(b,{className:`fk:border-none fk:h-4.75 fk:text-[0.6875rem] fk:leading-4.5 fk:tracking-wide ${Et[e]}`,variant:"secondary",children:e})}function M(e){return e==null?"\u2014":typeof e=="object"?JSON.stringify(e):String(e)}function Je({after:e,before:t}){let n=M(t),a=M(e);return n===a?jsx("span",{className:"fk:text-muted-foreground",children:n}):jsxs("span",{className:"fk:inline-flex fk:flex-wrap fk:items-center fk:gap-1.5",children:[jsx("span",{className:"fk:rounded fk:bg-destructive/10 fk:px-1 fk:text-destructive fk:line-through fk:corner-squircle",children:n}),jsx(MoveRightIcon,{className:"fk:size-3 fk:shrink-0 fk:text-muted-foreground"}),jsx("span",{className:"fk:rounded fk:bg-success/15 fk:px-1 fk:text-success fk:corner-squircle",children:a})]})}function _t(e){let t=e.entity??"entities",n=e.affectedCount!==null?` \xB7 ${e.affectedCount.toString()} affected`:"";return e.kind==="create"?`Create ${t}${n}`:e.kind==="update"?`Update ${t}${n}`:e.kind==="delete"?`Delete ${t}${n}`:`Mutation on ${t}${n}`}function Lt({operation:e}){if(e.rows.length===0)return null;let t=(e.contextColumns??[]).filter(a=>a!=="_id");if(e.kind==="delete")return jsxs(da,{children:[jsx(ea,{children:jsxs(ha,{children:[jsx(ia,{children:"Records to delete"}),t.map(a=>jsx(ia,{children:a},a))]})}),jsx(fa,{children:e.rows.map((a,r)=>jsxs(ha,{className:"fk:bg-destructive/5",children:[jsx(ja$1,{className:"fk:font-mono fk:text-xs fk:text-destructive",children:a.id??M(a.before?._id)}),t.map(s=>jsx(ja$1,{className:"fk:text-xs fk:text-muted-foreground",children:M(a.before?.[s])},s))]},a.id??r.toString()))})]});let n=e.columns.filter(a=>a!=="_id"&&!t.includes(a));return jsxs(da,{children:[jsx(ea,{children:jsxs(ha,{children:[jsx(ia,{children:"ID"}),t.map(a=>jsx(ia,{children:a},a)),n.map(a=>jsx(ia,{children:a},a))]})}),jsx(fa,{children:e.rows.map((a,r)=>jsxs(ha,{children:[jsx(ja$1,{className:"fk:font-mono fk:text-xs fk:text-muted-foreground",children:a.id??"\u2014"}),t.map(s=>jsx(ja$1,{className:"fk:max-w-72 fk:text-xs fk:text-muted-foreground",children:jsx("span",{className:"fk:line-clamp-3",children:M(a.before?.[s])})},s)),n.map(s=>jsx(ja$1,{className:"fk:text-xs",children:e.kind==="create"?jsx("span",{className:"fk:rounded fk:bg-success/15 fk:px-1 fk:text-success fk:corner-squircle",children:M(a.after?.[s])}):jsx(Je,{after:a.after?.[s],before:a.before?.[s]})},s))]},a.id??r.toString()))})]})}function jt({operations:e,plugin:t,chat:n,title:a}){return jsxs("details",{className:"fk:rounded-md fk:border fk:border-border fk:corner-squircle",children:[jsx("summary",{className:"fk:cursor-pointer fk:px-3 fk:py-2 fk:text-xs fk:font-medium fk:text-muted-foreground",children:a??(n?"Action details":t?"Plugin tool and arguments":`GraphQL documents (${e.length})`)}),jsx("div",{className:"fk:space-y-3 fk:border-t fk:border-border fk:p-3",children:e.map((r,s)=>jsxs("div",{className:"fk:space-y-2",children:[jsx("pre",{className:"fk:overflow-x-auto fk:rounded-md fk:bg-muted fk:p-3 fk:text-xs fk:corner-squircle",children:r.query}),r.variables&&Object.keys(r.variables).length>0?jsx("pre",{className:"fk:overflow-x-auto fk:rounded-md fk:bg-muted/60 fk:p-3 fk:text-xs fk:corner-squircle",children:JSON.stringify(r.variables,null,2)}):null]},s.toString()))})]})}function Xe(e){if(e.kind!=="plugin")return null;let n=e.operations[0]?.query.split(`
|
|
2
|
-
`)[0]?.trim()?.split("/"),a=n?.at(-1),r=n?.[0];if(!a||!r||n?.length<2)return null;let s=a.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").toLowerCase(),l=r.replace(/[_-]+/g," ").replace(/\b\w/g,c=>c.toUpperCase()),u=e.operations[0]?.query??"",p=/^Connection:\s*(Project|Personal)\s+—\s+(.+)$/m.exec(u);if(p?.[1]&&p[2])return {action:s,app:l,account:p[2].trim(),scope:p[1]==="Project"?"project":"personal"};let f=/^Connection:.*?([^\s<>]+@[^\s<>]+)\s*$/m.exec(u)?.[1];return {action:s,app:l,account:f}}function zt(e){let t=Xe(e);return t?`${t.action.charAt(0).toUpperCase()}${t.action.slice(1)} in ${t.app}`:e.kind==="exec"?"Run a sandbox command":e.kind==="schema"?e.operationsSummary.replace(/^Schema: /,""):e.kind==="plugin"?"Use a connected app":e.operationsSummary}function Ot({operation:e}){if(e.rows.length===0)return null;let t=a=>a!=null&&a!==false,n=e.columns.filter(a=>e.rows.some(s=>t(s.before?.[a])||t(s.after?.[a]))?e.kind!=="update"?true:e.rows.some(s=>M(s.before?.[a])!==M(s.after?.[a])):false);return jsx("div",{className:"fk:overflow-x-auto fk:rounded-md fk:border fk:border-border fk:corner-squircle",children:jsxs(da,{className:"fk:text-xs",children:[jsx(ea,{children:jsxs(ha,{children:[jsx(ia,{className:"fk:h-8",children:e.entity==="scopes"||e.entity==="spaces"||e.entity==="studio"?"Setting":"Attribute"}),n.map(a=>jsx(ia,{className:"fk:h-8",children:a},a))]})}),jsx(fa,{children:e.rows.map((a,r)=>jsxs(ha,{children:[jsxs(ja$1,{className:"fk:py-1.5 fk:font-mono fk:text-[0.7rem]",children:[e.kind==="delete"?jsx("span",{className:"fk:line-through fk:text-destructive",children:a.id}):a.id,e.kind==="update"&&a.before===null?jsx(b,{className:"fk:ml-2",variant:"secondary",children:"new"}):null,e.kind==="update"&&a.after===null?jsx(b,{className:"fk:ml-2",variant:"destructive",children:"removed"}):null]}),n.map(s=>jsx(ja$1,{className:"fk:py-1.5",children:e.kind==="create"?jsx("span",{children:M(a.after?.[s])}):e.kind==="delete"?jsx("span",{className:"fk:text-muted-foreground",children:M(a.before?.[s])}):jsx(Je,{after:a.after?.[s],before:a.before?.[s]})},s))]},a.id??r.toString()))})]})})}function Ut(e){let t=e.entity??"schema";return t==="scopes"||t==="spaces"||t==="studio"?`Change ${t==="studio"?"Studio settings":t}`:e.kind==="create"?`Add entity ${t} \xB7 ${e.rows.length.toString()} attribute${e.rows.length===1?"":"s"}`:e.kind==="delete"?`Remove entity ${t}`:`Change entity ${t}`}function Bt({preview:e}){let t=e.schema;return jsxs("div",{className:"fk:space-y-4",children:[t&&t.breakingChanges.length>0?jsxs("div",{className:"fk:rounded-md fk:border fk:border-destructive/30 fk:bg-destructive/5 fk:p-3 fk:text-sm fk:corner-squircle",children:[jsxs("div",{className:"fk:mb-1 fk:flex fk:items-center fk:gap-2 fk:font-medium fk:text-destructive",children:[jsx(TriangleAlertIcon,{className:"fk:size-4"}),"Breaking changes: existing data becomes inaccessible"]}),jsx("ul",{className:"fk:list-disc fk:pl-5 fk:text-destructive",children:t.breakingChanges.map(n=>jsx("li",{children:n},n))})]}):null,t&&t.warnings.length>0?jsx("div",{className:"fk:rounded-md fk:border fk:border-amber-500/40 fk:bg-amber-500/10 fk:p-3 fk:text-sm fk:corner-squircle",children:jsx("ul",{className:"fk:list-disc fk:pl-5",children:t.warnings.map(n=>jsx("li",{children:n},n))})}):null,e.operations.map((n,a)=>jsxs("div",{className:"fk:space-y-2",children:[jsx("div",{className:`fk:text-sm fk:font-medium ${n.kind==="delete"?"fk:text-destructive":""}`,children:Ut(n)}),jsx(Ot,{operation:n})]},`${n.entity??""}-${a.toString()}`)),e.operations.length===0?jsx("div",{className:"fk:rounded-md fk:border fk:border-dashed fk:p-3 fk:text-xs fk:text-muted-foreground fk:corner-squircle",children:"No visible entity changes. Review the operations below."}):null]})}function qt(e,t){return e.id===t.id&&e.status===t.status&&e.decidedAt===t.decidedAt&&e.decidedBy===t.decidedBy&&e.executedAt===t.executedAt&&e.error===t.error&&e.reason===t.reason&&e.expiresAt===t.expiresAt&&e.operationsSummary===t.operationsSummary&&e.affectedCount===t.affectedCount&&JSON.stringify(e.preview)===JSON.stringify(t.preview)}function Fe({api:e,approval:t,onDecided:n}){let[a,r]=useState(t),[s,l]=useState(t),[u,p]=useState(""),[f,c]=useTransition(),[g$1,R]=useState(false),[v,b]=useState(false),[d,w]=useState(""),A=je();t!==s&&(l(t),qt(t,s)||a.id===t.id&&a.status!=="pending"&&t.status==="pending"||r(t));function N(h){r(h),A(),h.kind==="schema"&&h.status==="approved"&&re({approvalId:h.id,approvalUrl:g(h.projectId).approval(h.id),projectId:h.projectId}),n?.(h);}function V({approved:h,force:T=false,reason:$,remember:P=false}){c(async()=>{p("");try{let S=await e.decideApproval(a.id,{approved:h,force:T,reason:$,remember:P});if(S.errorCode==="stale_preview"){b(!0),S.approval&&r(S.approval);return}if(b(!1),R(!1),S.approval?N(S.approval):S.success?N({...a,decidedAt:a.decidedAt??new Date().toISOString(),reason:$??a.reason,status:h?"approved":"rejected"}):S.errorCode==="already_decided"&&n?.(a),!S.success&&(S.errorCode!=="already_decided"||!S.approval)){let _=Array.isArray(S.errorMessage)?S.errorMessage.join(", "):S.errorMessage;p(_||"Failed to submit the decision.");}}catch(S){p(S instanceof Error?S.message:"Failed to submit the decision.");}});}return {approval:a,decide:V,errorMessage:u,isDeciding:f,isPending:a.status==="pending",isRejectDialogOpen:g$1,isStale:v,rejectReason:d,setIsRejectDialogOpen:R,setRejectReason:w}}function He({allowRemember:e=false,askForRejectionReason:t,decide:n,isDeciding:a,isRejectDialogOpen:r,isStale:s,rejectReason:l$1,setIsRejectDialogOpen:u,setRejectReason:p,variant:f}){let c$1=f==="header",g=c$1?"fk:px-8 fk:min-w-32":void 0,R=c$1?"default":"sm",[v,b]=useState(false),d=useId();return jsxs(Fragment,{children:[jsxs("div",{className:"fk:flex fk:flex-nowrap fk:items-center fk:gap-2",children:[jsxs(d$1,{className:g,disabled:a,size:R,onClick:()=>n({approved:true,force:s,remember:e&&v}),children:[a?jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}):jsx(CheckIcon,{className:"fk:size-4"}),s?"Approve anyway":"Approve"]}),jsxs(d$1,{className:g,disabled:a,size:R,variant:"outline",onClick:()=>{t?(p(""),u(true)):n({approved:false});},children:[jsx(XIcon,{className:"fk:size-4"}),"Reject"]}),e?jsxs("label",{className:"fk:ml-1 fk:flex fk:cursor-pointer fk:items-center fk:gap-1.5 fk:whitespace-nowrap fk:text-xs fk:text-muted-foreground",htmlFor:d,children:[jsx(o,{checked:v,id:d,onCheckedChange:w=>b(w===true)}),"Always allow this tool for this automation"]}):null]}),t?jsx(c,{open:r,onOpenChange:u,children:jsxs(h,{children:[jsxs(i,{children:[jsx(k,{children:"Reject this proposal?"}),jsx(l,{children:"The mutation will not be executed. The agent receives your reason and can adapt its plan."})]}),jsx(pa,{placeholder:"Optional reason for the agent...",value:l$1,onChange:w=>p(w.target.value)}),jsxs(j,{children:[jsx(d$1,{disabled:a,size:"sm",variant:"outline",onClick:()=>u(false),children:"Cancel"}),jsxs(d$1,{disabled:a,size:"sm",variant:"destructive",onClick:()=>n({approved:false,reason:l$1.trim()||void 0}),children:[a?jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}):jsx(ArrowRightIcon,{className:"fk:size-4"}),"Reject proposal"]})]})]})}):null]})}function Ge({approval:e,chat:t,errorMessage:n,isPending:a,isStale:r}){let{preview:s}=e,l=t?Xe(e):null;return jsxs("div",{className:"fk:min-w-0 fk:max-w-full fk:space-y-4",children:[jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-2",children:[jsx($t,{status:e.status}),e.kind==="schema"?jsx(b,{variant:"outline",children:"Schema change"}):null,jsx("span",{className:"fk:text-sm fk:font-medium",children:t?zt(e):e.operationsSummary})]}),jsxs("div",{className:"fk:text-xs fk:text-muted-foreground",children:[e.automationName?`${e.automationName} \xB7 `:"","requested ",formatDistance(new Date(e.requestedAt),new Date,{addSuffix:true}),a?` \xB7 expires ${formatDistance(new Date(e.expiresAt),new Date,{addSuffix:true})}`:"",e.decidedAt?` \xB7 decided ${format(new Date(e.decidedAt),"PPpp")}`:""]}),r?jsxs("div",{className:"fk:flex fk:items-start fk:gap-2 fk:rounded-md fk:border fk:border-amber-500/40 fk:bg-amber-500/10 fk:p-3 fk:text-sm fk:corner-squircle",children:[jsx(TriangleAlertIcon,{className:"fk:mt-0.5 fk:size-4 fk:shrink-0 fk:text-amber-600"}),jsx("span",{children:"The affected data changed since this proposal was created. The preview below has been refreshed \u2014 review it and approve again to proceed."})]}):null,e.kind==="schema"&&s?jsx(Bt,{preview:s}):s&&s.operations.length>0?jsx("div",{className:"fk:space-y-4",children:s.operations.map((u,p)=>jsxs("div",{className:"fk:space-y-2",children:[jsx("div",{className:"fk:text-sm fk:font-medium",children:_t(u)}),u.kind==="delete"&&u.affectedCount!==null?jsxs("div",{className:"fk:rounded-md fk:border fk:border-destructive/30 fk:bg-destructive/5 fk:p-3 fk:text-sm fk:text-destructive fk:corner-squircle",children:[u.affectedCount.toString()," record",u.affectedCount===1?"":"s"," will be permanently deleted."]}):null,jsx(Lt,{operation:u}),u.truncated?jsxs("div",{className:"fk:text-xs fk:text-muted-foreground",children:["Preview limited to the first ",u.rows.length.toString()," rows."]}):null]},p.toString()))}):jsx("div",{className:"fk:rounded-md fk:border fk:border-dashed fk:p-3 fk:text-xs fk:text-muted-foreground fk:corner-squircle",children:t?l?`This action uses ${l.scope==="project"?"the project's":"your"} ${l.app} account${l.account?` (${l.account})`:""}. Check the details before deciding.`:"The assistant wants to make this change. Check the details before deciding.":e.kind==="plugin"?"Review the account, tool, and arguments before allowing this external call.":e.kind==="exec"?"This command runs inside the run's ephemeral sandbox but may send data out or reach other hosts. Review the command line before allowing it.":"No structured preview is available for this proposal. Review the raw GraphQL documents below."}),jsx(jt,{chat:t,operations:e.operations,plugin:e.kind==="plugin"||e.kind==="exec",title:e.kind==="exec"?"Command and options":e.kind==="schema"?"Operations":void 0}),e.reason?jsxs("div",{className:"fk:text-sm",children:[jsx("span",{className:"fk:font-medium",children:"Reason:"})," ",e.reason]}):null,e.error?jsxs("div",{className:"fk:rounded-md fk:border fk:border-destructive/30 fk:bg-destructive/5 fk:p-3 fk:text-sm fk:corner-squircle",children:["Execution failed: ",e.error]}):null,e.executedAt&&!e.error?jsxs("div",{className:"fk:flex fk:items-center fk:gap-2 fk:text-sm fk:text-success",children:[jsx(CheckIcon,{className:"fk:size-4"}),"Executed ",format(new Date(e.executedAt),"PPpp")]}):null,n?jsx("div",{className:"fk:text-sm fk:text-destructive",children:n}):null]})}function Ve({api:e,approval:t,chat:n,onDecided:a}){let{approval:r,decide:s,errorMessage:l,isDeciding:u,isPending:p,isRejectDialogOpen:f,isStale:c,rejectReason:g,setIsRejectDialogOpen:R,setRejectReason:v}=Fe({api:e,approval:t,onDecided:a});return jsxs(Fragment,{children:[jsx(Ge,{approval:r,chat:n,errorMessage:l,isPending:p,isStale:c}),p?jsx("div",{className:"fk:mt-4",children:jsx(He,{allowRemember:!n&&r.kind==="plugin"&&!!r.automationId,askForRejectionReason:!n,decide:s,isDeciding:u,isRejectDialogOpen:f,isStale:c,rejectReason:g,setIsRejectDialogOpen:R,setRejectReason:v,variant:"inline"})}):null]})}function gn({api:e,approval:t,onClose:n,onDecided:a}){let{approval:r,decide:s,errorMessage:l,isDeciding:u,isPending:p,isRejectDialogOpen:f,isStale:c,rejectReason:g,setIsRejectDialogOpen:R,setRejectReason:v}=Fe({api:e,approval:t,onDecided:a});return jsx(sa,{actions:p?jsx(He,{allowRemember:r.kind==="plugin"&&!!r.automationId,askForRejectionReason:true,decide:s,isDeciding:u,isRejectDialogOpen:f,isStale:c,rejectReason:g,setIsRejectDialogOpen:R,setRejectReason:v,variant:"header"}):null,depth:0,isFocused:true,onClose:n,title:"Mutation proposal",children:jsx(Ge,{approval:r,chat:false,errorMessage:l,isPending:p,isStale:c})})}var Jt="Approved by Flexkit Jev policy",Xt="Approved by automation tool allow rule",Ft=new Set(["data-create-sandbox","data-execute-graphql","data-load-skill","data-plan","data-plugin-call","data-run-command","data-search-schema","data-update-memory","data-validate-graphql","data-web-search"]);function Y(e){return Ft.has(e)}function y(e){return e.data}function me(e){return !e.decidedBy&&!!(e.reason?.startsWith(Jt)||e.reason?.startsWith(Xt))}function J(e,t=72){let n=e.trim();if(n.length<=t)return n;let a=n.slice(0,t),r=a.lastIndexOf(" ");return `${(r>=Math.floor(t*.6)?a.slice(0,r):a).trimEnd()}\u2026`}function Ht(e){return e.replace(/^#{1,6}\s+/,"").replace(/^(?:[-*+]|\d+[.)])\s+/,"").replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/(\*\*|__)(.*?)\1/g,"$2").replace(/(\*|_)(.*?)\1/g,"$2").replace(/`([^`]*)`/g,"$1").replace(/[*_`#>]/g,"").replace(/\s+/g," ").trim().replace(/[.:]+$/,"")}function Gt(e){let t=e.lastIndexOf(`
|
|
3
|
-
`),n=-1,a=/[.!?](?=\s)/g,r;for(;(r=a.exec(e))!==null;)n=r.index;let s=Math.max(t,n);return s<0?"":e.slice(0,s+1)}function Vt(e,t){let a=(Gt(e)).split(/\r?\n/).map(p=>p.trim()).filter(Boolean),r=a[a.length-1];if(!r)return null;let l=/^\*\*(.+?)\*\*:?$/.exec(r)?.[1]??/^#{1,6}\s+(.+)$/.exec(r)?.[1]??/^(.+?[.!?])(?:\s|$)/.exec(r)?.[1]??r,u=Ht(l);return !u||/^reasoning$/i.test(u)?null:J(u)}function Ye(e){return e.replace(/[_-]+/g," ").trim()}function Wt(e){if(e.type==="data-load-skill"){let t=y(e);return t.status!=="loading"?null:t.skillName?J(`Loading skill "${t.skillName}"`):"Loading skill"}if(e.type==="data-search-schema")return y(e).status==="loading"?"Searching schema":null;if(e.type==="data-validate-graphql")return y(e).status==="loading"?"Validating GraphQL query":null;if(e.type==="data-execute-graphql"){let t=y(e);return t.status!=="loading"?null:t.operationType==="mutation"?"Executing GraphQL mutation":"Executing GraphQL query"}if(e.type==="data-update-memory")return y(e).status==="loading"?"Updating memory":null;if(e.type==="data-web-search"){let t=y(e);return t.status!=="loading"?null:t.query?J(`Searching the web for "${t.query}"`):"Searching the web"}if(e.type==="data-run-command"){let t=y(e);return ["executing","running","waiting"].includes(t.status)?J(`Running ${[t.command,...t.args].join(" ")}`):null}if(e.type==="data-create-sandbox")return y(e).status==="loading"?"Creating sandbox":null;if(e.type==="data-plugin-call"){let t=y(e);return t.status!=="loading"?null:J(`Calling ${t.pluginId}: ${Ye(t.tool)}`)}if(e.type==="data-subtask"){let t=y(e);return t.status==="running"?J(`Running subtask: ${t.title}`):null}return null}var Yt=new Set(["data-execute-graphql","data-search-schema","data-validate-graphql"]);function oe(e){if(!Y(e.type)||e.type==="data-plan"||Yt.has(e.type))return null;let t=y(e);if(t.status!=="error")return null;if(t.error?.message)return t.error.message;switch(e.type){case "data-web-search":return "Failed to search the web";case "data-run-command":return `Command failed: ${String(t.command??"")}`.trim();case "data-create-sandbox":return "Failed to create sandbox";case "data-load-skill":return "Failed to load skill";case "data-update-memory":return "Failed to update memory";case "data-plugin-call":return `Plugin call failed: ${String(t.pluginId??"")}: ${Ye(String(t.tool??""))}`;default:return "The tool call failed"}}function ie(e){if(e.type==="step-start"||e.type==="reasoning")return true;if(Y(e.type))return oe(e)===null;if(e.type==="data-mutation-approval"){let t=y(e);return me(t)&&t.status!=="error"}return false}function se(e){if(!e)return null;for(let t=e.parts.length-1;t>=0;t--){let n=e.parts[t];if(n?.type!=="data-plan")continue;let a=y(n),r=a.steps.findIndex(s=>s.status==="in_progress");return r<0?null:J(`Step ${(r+1).toString()} of ${a.steps.length.toString()}: ${a.steps[r].step}`)}return null}function Qt(e){if(!e)return null;for(let t=e.parts.length-1;t>=0;t--){let n=e.parts[t];if(!(!n||n.type==="step-start"))return n.type==="reasoning"?n.state==="streaming"?Vt(n.text)??se(e):se(e):n.type==="data-mutation-approval"?y(n).status==="pending"?"Awaiting approval":se(e):n.type==="text"?null:Wt(n)??se(e)}return null}function ke(e){return e?e.parts.some(t=>t.type!=="data-mutation-approval"?false:y(t).status==="pending"):false}function ge(e,t={}){let n=false,a=[];for(let r of e.parts){if(r.type!=="data-mutation-approval"){a.push(r);continue}let s=y(r);if(s.status!=="pending"){a.push(r);continue}n=true;let l=t[s.approvalId];l&&l!=="pending"&&a.push({...r,data:{...s,status:l}});}return n?{...e,parts:a}:e}function Qe(e,t){if(!e)return [];let n=[],a=t?.pendingOnly??false;for(let r of e.parts){if(r.type!=="data-mutation-approval")continue;let s=y(r);a&&s.status!=="pending"||n.push(s.approvalId);}return n}function Kt(e){return Qe(e,{pendingOnly:true})}var Ke=20*1024*1024,An=10,et=new Set(["css","csv","gif","gql","graphql","htm","html","jpeg","jpg","js","json","jsx","log","markdown","md","mjs","ndjson","pdf","png","py","sql","ts","tsv","tsx","txt","webp","xml","yaml","yml"]),tt=new Set(["application/pdf","image/gif","image/jpeg","image/png","image/webp"]),Nn=[...[...et].map(e=>`.${e}`),...tt].join(",");function at(e){let t=e.lastIndexOf(".");return t<=0?"":e.slice(t+1).toLowerCase()}function aa(e){let t=at(e.name);return (t?et.has(t):tt.has(e.type))?e.size===0?`"${e.name}" is empty.`:e.size>Ke?`"${e.name}" exceeds the ${String(Math.round(Ke/(1024*1024)))} MB limit.`:null:`"${e.name}" is not supported. Attach images, PDFs, or text files.`}async function na(e){let n=await(await fetch(e.url)).blob();return new File([n],e.filename??"file",{type:e.mediaType||n.type})}function Tn(e,t){let{attachments:n}=Sb(),a=useRef({}),[,r]=useState(0),s=useCallback(()=>r(f=>f+1),[]),l=useRef(n.remove);l.current=n.remove;let u=useRef(t);u.current=t,useEffect(()=>{let f=new Set(n.files.map(c=>c.id));for(let[c,g]of Object.entries(a.current))f.has(c)||(g.controller.abort(),delete a.current[c]);for(let c of n.files){if(a.current[c.id])continue;let g=new AbortController,R={controller:g,status:"uploading"};a.current[c.id]=R,(async()=>{try{let v=await na(c),b=aa(v);if(b)throw new Error(b);let d=await e.uploadAgentChatAttachment(v,g.signal);if(g.signal.aborted)return;R.attachment=d,R.status="done";}catch(v){if(g.signal.aborted)return;R.status="error",delete a.current[c.id],l.current(c.id),u.current(v instanceof Error?v.message:"The file could not be uploaded.");}finally{s();}})();}s();},[e,n.files,s]);let p=Object.values(a.current).some(f=>f.status==="uploading");return {getUploaded:f=>f.map(c=>a.current[c]?.attachment).filter(c=>!!c),isUploading:p,isUploadingFile:f=>a.current[f]?.status==="uploading"}}function ye(e){return !!e?.startsWith("image/")}function nt({image:e,onClose:t}){return jsx(c,{onOpenChange:n=>n?void 0:t(),open:e!==null,children:jsxs(h,{className:"fk:h-dvh fk:w-dvw fk:max-w-none fk:sm:max-w-none fk:rounded-none fk:border-0 fk:bg-black/90 fk:p-4 fk:shadow-none fk:flex fk:items-center fk:justify-center fk:corner-squircle",showCloseButton:false,children:[jsx(k,{className:"fk:sr-only",children:e?.filename??"Image preview"}),e?jsx("img",{alt:e.filename,className:"fk:block fk:h-auto fk:w-auto fk:max-h-full fk:max-w-full fk:object-contain",src:e.url}):null,jsx(f$2,{"aria-label":"Close preview",className:"fk:absolute fk:top-4 fk:right-4 fk:flex fk:size-9 fk:items-center fk:justify-center fk:rounded-full fk:bg-white/10 fk:text-white fk:transition-colors fk:hover:bg-white/20 fk:focus-visible:outline-none fk:focus-visible:ring-2 fk:focus-visible:ring-white/60 fk:corner-squircle",children:jsx(XIcon,{className:"fk:size-5"})})]})})}function rt({label:e,onRemove:t}){return jsx("button",{"aria-label":e,className:"fk:absolute fk:top-1 fk:right-1 fk:z-10 fk:flex fk:size-5 fk:items-center fk:justify-center fk:rounded-full fk:border fk:border-border fk:bg-background fk:text-foreground fk:shadow-sm fk:transition-colors fk:hover:bg-accent fk:focus-visible:outline-none fk:focus-visible:ring-2 fk:focus-visible:ring-ring fk:corner-squircle",onClick:n=>{n.stopPropagation(),t();},type:"button",children:jsx(XIcon,{className:"fk:size-3"})})}function st({image:e,isUploading:t=false,onOpen:n,onRemove:a,sizeClassName:r}){return jsxs("div",{className:`fk:relative fk:shrink-0 fk:overflow-hidden fk:rounded-xl fk:bg-muted ${r} fk:corner-squircle`,children:[jsx("button",{"aria-label":`Preview ${e.filename}`,className:"fk:block fk:size-full fk:cursor-zoom-in fk:focus-visible:outline-none fk:focus-visible:ring-2 fk:focus-visible:ring-ring",onClick:n,type:"button",children:jsx("img",{alt:e.filename,className:"fk:size-full fk:object-cover",src:e.url})}),t?jsx("div",{className:"fk:pointer-events-none fk:absolute fk:inset-0 fk:flex fk:items-center fk:justify-center fk:bg-background/60",children:jsx(ya,{className:"fk:size-4"})}):null,a?jsx(rt,{label:`Remove ${e.filename}`,onRemove:a}):null]})}function ra(e,t){let n=at(e);if(n)return n.toUpperCase();let a=t?.split("/")[1]?.split("+")[0];return a?a.toUpperCase():"FILE"}function ot({file:e,href:t,isUploading:n=false,onRemove:a}){let r=jsxs(Fragment,{children:[jsx("div",{className:"fk:flex fk:size-10 fk:shrink-0 fk:items-center fk:justify-center fk:rounded-lg fk:bg-muted fk:text-muted-foreground fk:corner-squircle",children:n?jsx(ya,{className:"fk:size-4"}):jsx(FileIcon,{className:"fk:size-5"})}),jsxs("div",{className:"fk:min-w-0 fk:pr-4 fk:text-left",children:[jsx("div",{className:"fk:truncate fk:text-sm fk:font-medium fk:text-foreground",children:e.filename}),jsx("div",{className:"fk:truncate fk:text-xs fk:text-muted-foreground",children:ra(e.filename,e.mediaType)})]})]}),s="fk:flex fk:h-14 fk:max-w-64 fk:items-center fk:gap-2.5 fk:rounded-xl fk:border fk:border-border fk:bg-background fk:px-2 fk:corner-squircle";return jsxs("div",{className:"fk:relative fk:shrink-0",children:[t?jsx("a",{className:`${s} fk:transition-colors fk:hover:bg-accent/50 fk:focus-visible:outline-none fk:focus-visible:ring-2 fk:focus-visible:ring-ring`,href:t,rel:"noreferrer",target:"_blank",children:r}):jsx("div",{className:s,children:r}),a?jsx(rt,{label:`Remove ${e.filename}`,onRemove:a}):null]})}function Pn({uploads:e}){let t=Vb(),[n,a]=useState(null);return t.files.length===0?null:jsxs(Fragment,{children:[jsx("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-2",children:t.files.map(r=>{if(ye(r.mediaType)&&r.url){let s={filename:r.filename??"Image",url:r.url};return jsx(st,{image:s,isUploading:e.isUploadingFile(r.id),onOpen:()=>a(s),onRemove:()=>t.remove(r.id),sizeClassName:"fk:size-14"},r.id)}return jsx(ot,{file:{filename:r.filename??"file",mediaType:r.mediaType},isUploading:e.isUploadingFile(r.id),onRemove:()=>t.remove(r.id)},r.id)})}),jsx(nt,{image:n,onClose:()=>a(null)})]})}function Cn(e){return Array.isArray(e)?e.filter(t=>t.type==="file"&&typeof t.url=="string").map(t=>({filename:t.filename??"file",mediaType:t.mediaType??"application/octet-stream",sizeBytes:t.sizeBytes??0,url:t.url??""})):[]}function it({attachments:e}){let[t,n]=useState(null);if(e.length===0)return null;let a=e.filter(s=>ye(s.mediaType)),r=e.filter(s=>!ye(s.mediaType));return jsxs("div",{className:"fk:flex fk:flex-col fk:items-end fk:gap-2",children:[a.length>0?jsx("div",{className:"fk:flex fk:flex-wrap fk:justify-end fk:gap-2",children:a.map(s=>jsx(st,{image:s,onOpen:()=>n(s),sizeClassName:"fk:size-24"},s.url))}):null,jsx(nt,{image:t,onClose:()=>n(null)}),r.length>0?jsx("div",{className:"fk:flex fk:flex-wrap fk:justify-end fk:gap-2",children:r.map(s=>jsx(ot,{file:s,href:s.url},s.url))}):null]})}var H=class extends Error{},le=class extends Error{};function ut({url:e,signal:t,state:n,onState:a,wake:r,fetchStream:s=fetch,retryMs:l=2e3}){let u=0,p=0,f=new TransformStream,c=f.writable.getWriter(),g=new AbortController;c.closed.catch(d=>g.abort(d));let R=()=>{g.abort(t.reason),c.abort(t.reason).catch(()=>{});};t.addEventListener("abort",R,{once:true}),t.aborted&&R();let v=()=>new Promise(d=>{let w=()=>{clearTimeout(A),g.signal.removeEventListener("abort",w),r?.removeEventListener("wake",w),d();},A=setTimeout(w,l);g.signal.addEventListener("abort",w,{once:true}),r?.addEventListener("wake",w,{once:true}),g.signal.aborted&&w();});async function b(){try{for(await c.write({type:"start"});!g.signal.aborted;){try{let d=await s(`${e}${e.includes("?")?"&":"?"}wire=2&startIndex=${u}`,{credentials:"include",signal:g.signal});if(d.status===404){a("unavailable"),await c.close();return}if(d.status===401||d.status===403)throw new le("Stream access denied");if(!d.ok||!d.body)throw new Error(`Stream request failed: ${d.status}`);if(d.headers.get("x-flexkit-stream-version")!=="2")throw await d.body.cancel(),new H("Backend uses legacy replay");a("streaming");let w=d.body.pipeThrough(new TextDecoderStream).getReader(),A="",N=!1;try{for(;!g.signal.aborted;){let{value:V,done:h}=await w.read();if(h)break;A+=V;let T;for(;(T=A.indexOf(`
|
|
4
|
-
`))>=0;){let $=A.slice(0,T);if(A=A.slice(T+1),!$)continue;let P=JSON.parse($);if(!Number.isSafeInteger(P.index)||P.index<0)throw new Error("Invalid replay cursor");if(!(P.index<u)){if(P.index!==u)throw new Error("Replay cursor gap");P.chunk&&await c.write(P.chunk),u=P.index+1,p=0,P.chunk?.type==="finish"&&P.chunk.messageMetadata?.flexkitTerminal&&(N=!0);}}if(A.length>2e6)throw new Error("Oversized replay frame");if(N)break}}finally{await w.cancel().catch(()=>{}),w.releaseLock();}if(N||n().terminal&&!A){await c.write({type:"finish"}),await c.close(),a("finished");return}}catch(d){if(g.signal.aborted||d instanceof H||d instanceof le||++p>=5)throw d}do a(n().paused?"paused":"streaming"),await v();while(!g.signal.aborted&&n().paused&&!n().terminal)}}catch(d){await c.abort(d).catch(()=>{});}finally{t.removeEventListener("abort",R),c.releaseLock();}}return b(),pipeJsonRender(f.readable)}var Aa=lazy(()=>import('./spec-renderer-5YGDRF52.js').then(e=>({default:e.RunSpecPart})));function Na(e){return jsx(Suspense,{fallback:null,children:jsx(Aa,{...e})})}function Ta(){let{currentProjectId:e}=f();return {api:useMemo(()=>e?d(e):null,[e]),projectId:e}}var dt=5,yt=2e3,bt=120,he="data-spec",Pa=createContext(null),Ca=createContext(false);function Da(e){return new Promise(t=>window.setTimeout(t,e))}function Ma(e){return e instanceof Error?e.name==="AbortError"||e.message.toLowerCase().includes("aborted"):false}function Ia(e){return e.some(t=>!ie(t))}function Ea(e){let t=new Set;for(let n of e)for(let a of n.parts)a.type==="data-user-message"&&a.id&&t.add(a.id);return t}function $a(e){let t=Ea(e),n=[];for(let a of e){if(a.role==="user"){t.has(a.id)||n.push(a);continue}if(a.role!=="assistant"){n.push(a);continue}let r=[],s=0,l=()=>{Ia(r)&&n.push({...a,id:`${a.id}-${s.toString()}`,parts:r}),s++,r=[];};for(let u of a.parts){if(u.type==="data-user-message"){let p=y(u);l(),n.push({id:u.id??crypto.randomUUID(),parts:p.parts,role:"user"});continue}r.push(u);}l();}return n}function Wn(e){return useMemo(()=>$a(e),[e])}function G(e){return e==="success"||e==="failed"||e==="cancelled"||e==="skipped"}function ht({latestMessage:e,recordStatus:t,suppressApprovalPause:n}){return G(t)||n||t==="running"?false:t==="awaiting_approval"?true:ke(e)}function Yn(e,t){let[n,a]=useState(false),r=_a(n?e:"",t),[s,l]=useState(),[u,p]=useState("streaming"),f=useRef(t);f.current=t;let c=useRef(null);c.current||(c.current=new EventTarget);let g=c.current,R=t?.resumeToken;return useEffect(()=>{g.dispatchEvent(new Event("wake"));},[R,g]),useEffect(()=>{if(a(false),l(void 0),!e){p("unavailable");return}let v=new AbortController,b,d,w=()=>{b=void 0,d&&!v.signal.aborted&&l({...d});},A=ut({url:e,signal:v.signal,state:()=>({terminal:G(f.current?.recordStatus),paused:ht({latestMessage:d,recordStatus:f.current?.recordStatus,suppressApprovalPause:f.current?.suppressApprovalPause??false})}),onState:N=>{v.signal.aborted||p(N);},wake:g});return (async()=>{try{for await(let N of readUIMessageStream({stream:A,terminateOnError:!0}))d=N,b||(b=setTimeout(w,bt));w();}catch(N){if(v.signal.aborted)return;N instanceof H?a(true):(console.error("Run stream error",N),p("error"));}})(),()=>{v.abort(),b&&clearTimeout(b);}},[e,g]),n?r:{message:s?ge(s,t?.decidedApprovals??{}):void 0,status:u}}function _a(e,t){let[n,a]=useState(),[r,s]=useState("streaming"),l=t?.recordStatus,u=t?.resumeToken??0,p=useRef(t?.decidedApprovals??{});p.current=t?.decidedApprovals??{};let f=useRef(t?.suppressApprovalPause??false);f.current=t?.suppressApprovalPause??false;let c=useRef(e),g=useRef(n);return g.current=n,useEffect(()=>{let R=c.current!==e;if(c.current=e,!e){a(void 0),s("unavailable");return}let v=new AbortController,b=R?void 0:g.current,d=R?0:b?.parts.length??0;if(R)a(void 0);else if(b&&(l==="running"||G(l))){let h=ge(b,p.current);h!==b&&(b=h,a(h));}s("streaming");let w=e.includes("?")?"&":"?",A=async()=>{let h=await fetch(`${e}${w}startIndex=0`,{credentials:"include",signal:v.signal});if(h.status===404)return "unavailable";if(!h.ok||!h.body)throw new Error(`Failed to fetch the run stream (status ${h.status.toString()})`);let T=false,P=parseJsonEventStream({schema:uiMessageChunkSchema,stream:h.body}).pipeThrough(new TransformStream({transform:(D,xt)=>{if(!D.success)throw D.error;D.value.type==="finish"&&(T=true),xt.enqueue(D.value);}})),S=readUIMessageStream({onError:D=>{v.signal.aborted||console.error("Run stream chunk error",D);},stream:P}),_=null,ce=d===0,Se=(D=false)=>{v.signal.aborted||!b||!ce&&(ce=D||b.parts.length>=d,!ce)||a({...b});};try{for await(let D of S){if(v.signal.aborted)break;b=D,_===null&&(_=window.setTimeout(()=>{_=null,Se();},bt));}}finally{_!==null&&(window.clearTimeout(_),_=null),Se(true);}return T?"finished":"incomplete"},N=async()=>{let h=0;for(;!v.signal.aborted;){h>0&&await Da(yt);try{let T=await A();if(v.signal.aborted)return;if(T==="unavailable"){s("unavailable");return}if(T==="finished"&&G(l)){s("finished");return}if(G(l)){s("finished");return}if(ht({latestMessage:b,recordStatus:l,suppressApprovalPause:f.current})){s("paused");return}if(!(l==="running"||f.current)&&h>=dt-1){s("error");return}}catch(T){if(v.signal.aborted||Ma(T))return;if(console.error("Run stream error",T),G(l)){s("finished");return}if(!(l==="running"||f.current)&&h>=dt-1){s("error");return}}h+=1;}},V=window.setTimeout(()=>{N();},0);return ()=>{window.clearTimeout(V),v.abort("Run replay unmounted");}},[l,u,e]),{message:n,status:r}}function Qn(e){return {affectedCount:e.affectedCount,approvalId:e.id,decidedBy:e.decidedBy??void 0,operationsSummary:e.operationsSummary,reason:e.reason??void 0,status:e.status}}function La(e){let t=e.trim();return t?t.split(`
|
|
5
|
-
`).every(n=>/^`{3,}[\w-]*$/.test(n.trim())):false}function ja({attachments:e,text:t}){return jsxs("div",{className:"fk:ml-auto fk:flex fk:w-fit fk:max-w-[70%] fk:flex-col fk:items-end fk:gap-1",children:[jsx(it,{attachments:e}),t.trim()?jsx("div",{className:"fk:whitespace-pre-wrap fk:rounded-xl fk:bg-muted fk:dark:bg-white/20 fk:px-3.5 fk:py-2 fk:text-base fk:corner-squircle",children:t}):null,jsxs("span",{className:"fk:inline-flex fk:items-center fk:gap-1 fk:text-xs fk:text-muted-foreground",children:[jsx(CornerDownRightIcon,{className:"fk:size-3 fk:shrink-0"}),"Added while the agent was working"]})]})}function Kn({api:e,part:t,partIndex:n,parts:a}){if(ie(t))return null;if(Y(t.type)){let r=oe(t);return r?jsx(Oa,{message:r}):null}if(t.type==="text")return La(t.text)&&a.some(s=>s.type===he)?null:jsx(za,{part:t});if(t.type==="data-generating-files")return jsx(Xa,{message:y(t)});if(t.type==="data-run-artifact")return jsx(Fa,{api:e,message:y(t)});if(t.type==="data-tool-delivery")return jsx(Ha,{message:y(t)});if(t.type==="data-run-summary")return jsx(Ga,{message:y(t)});if(t.type==="data-subtask"){let r=y(t),s=r.status==="running"?`Running "${r.title}"`:r.status==="done"?`Completed "${r.title}"${typeof r.stepsUsed=="number"?` in ${r.stepsUsed.toString()} steps`:""}`:`"${r.title}" failed: ${r.error?.message??"unknown error"}`;return jsxs(E,{children:[jsxs(O,{children:[jsx(BotIcon,{className:"fk:size-3.5"}),"Subtask"]}),jsxs("div",{className:"fk:relative fk:min-h-5 fk:pl-6",children:[jsx("span",{className:"fk:absolute fk:left-0 fk:top-0",children:jsx(ue,{isError:r.status==="error",loading:r.status==="running"})}),jsx("span",{className:"fk:text-xs",children:s}),r.resultPreview?jsx("p",{className:"fk:mt-1 fk:text-xs fk:text-muted-foreground",children:r.resultPreview}):null]})]})}if(t.type==="data-mid-turn-message"){let r=y(t);return jsx(ja,{attachments:r.attachments,text:r.text})}if(t.type==="data-context-compaction"){let r=y(t);return jsxs("p",{className:"fk:text-xs fk:text-muted-foreground",children:["Earlier messages (",r.summarizedMessageCount.toString(),") were summarized to keep this conversation within the model's context. Details may need to be re-fetched."]})}if(t.type==="data-plugin-connection"){let r=y(t);return jsx(en,{pluginId:r.pluginId})}if(t.type==="data-suggested-prompt")return null;if(t.type==="data-turn-error"){let r=y(t);return jsxs(E,{className:"fk:border-red-700/40",children:[jsxs(O,{children:[jsx(XCircleIcon,{className:"fk:size-3.5 fk:text-red-700"}),jsx("span",{children:"Turn failed"})]}),jsx("p",{className:"fk:whitespace-pre-wrap fk:text-xs",children:r.message})]})}if(t.type==="data-mutation-approval"){let r=y(t);return me(r)?jsx(Wa,{message:r}):jsx(Va,{api:e,message:r})}return t.type==="data-bulk-graphql-action"?jsx(Ya,{message:y(t)}):t.type===he?a.slice(n+1).find(s=>s.type===he)?null:jsx(Na,{parts:a}):t.type.startsWith("data-")?jsx(Qa,{part:t}):null}function za({part:e}){return jsx(tb,{className:"fk:min-w-0 fk:max-w-full fk:overflow-x-auto fk:text-base fk:leading-relaxed fk:text-foreground",isAnimating:e.state==="streaming",children:e.text})}function Oa({message:e}){return jsxs("div",{className:"fk:flex fk:items-start fk:gap-2 fk:rounded-xl fk:border fk:border-red-700/40 fk:bg-destructive/5 fk:px-3.5 fk:py-3 fk:text-sm fk:corner-squircle",children:[jsx(XCircleIcon,{className:"fk:mt-0.5 fk:size-3.5 fk:shrink-0 fk:text-red-700"}),jsx("span",{className:"fk:whitespace-pre-wrap fk:text-xs",children:e})]})}var Ua=1e3;function Ba({text:e}){let t=useRef(typeof performance>"u"?0:performance.now()),n=()=>-(((typeof performance>"u"?0:performance.now())-t.current)%Ua),[a,r]=useState({current:e,currentDelayMs:0,key:0,previous:null,previousDelayMs:0});return useEffect(()=>{r(s=>s.current===e?s:{current:e,currentDelayMs:n(),key:s.key+1,previous:s.current,previousDelayMs:s.currentDelayMs});},[e]),jsxs("span",{className:"fk:relative fk:block fk:h-5 fk:min-w-0 fk:flex-1 fk:overflow-hidden",children:[a.previous?jsx("span",{"aria-hidden":true,className:"fk:absolute fk:inset-x-0 fk:top-0 fk:block fk:animate-roll-up-out",children:jsx("span",{className:"fk:block fk:truncate fk:shimmer fk:shimmer-duration-1000",style:{animationDelay:`${a.previousDelayMs.toString()}ms`},children:a.previous})},`previous-${a.key.toString()}`):null,jsx("span",{className:a.previous?"fk:block fk:animate-roll-up-in":"fk:block",role:"status",children:jsx("span",{className:"fk:block fk:truncate fk:shimmer fk:shimmer-duration-1000",style:{animationDelay:`${a.currentDelayMs.toString()}ms`},children:a.current})},`current-${a.key.toString()}`)]})}var qa=1e3;function Ja(e,t){let n=qa,[a,r]=useState(e),s=useRef(Date.now()),l=useRef(e);return l.current=e,useEffect(()=>{if(e===a)return;let u=Math.max(0,n-(Date.now()-s.current)),p=window.setTimeout(()=>{s.current=Date.now(),r(l.current);},u);return ()=>{window.clearTimeout(p);}},[a,e,n]),a}function Zn({label:e,visible:t}){let n=Ja(e);return jsx("div",{"aria-hidden":!t,className:`fk:flex fk:h-9 fk:items-center fk:text-sm fk:text-muted-foreground fk:transition-[opacity,visibility] fk:duration-200 ${t?"fk:visible fk:opacity-100":"fk:invisible fk:opacity-0"}`,children:jsx(Ba,{text:n})})}function E({children:e,className:t=""}){return jsx("div",{className:`fk:min-w-0 fk:max-w-full fk:overflow-x-auto fk:rounded-xl fk:border fk:border-border fk:bg-background fk:px-3.5 fk:py-3 fk:text-sm ${t} fk:corner-squircle`,children:e})}function O({children:e}){return jsx("div",{className:"fk:flex fk:items-center fk:gap-2 fk:font-medium fk:text-muted-foreground",children:e})}function ue({isError:e,loading:t}){return t?jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}):e?jsx(XIcon,{className:"fk:size-4 fk:text-red-700"}):jsx(CheckIcon,{className:"fk:size-4"})}function we({error:e,icon:t,loading:n,message:a,title:r}){return jsxs(E,{children:[jsxs(O,{children:[t,r]}),jsxs("div",{className:"fk:relative fk:min-h-5 fk:pl-6",children:[jsx("span",{className:"fk:absolute fk:left-0 fk:top-0",children:jsx(ue,{isError:!!e,loading:n})}),jsx("span",{className:"fk:text-xs",children:a})]})]})}function Xa({message:e}){let t=["error","uploading","generating"].includes(e.status),n=t?e.paths.slice(0,e.paths.length-1):e.paths,a=t?e.paths[e.paths.length-1]??"":null;return jsxs(E,{children:[jsxs(O,{children:[jsx(CloudUploadIcon,{className:"fk:size-3.5"}),jsx("span",{children:e.status==="done"?"Uploaded files":"Generating files"})]}),jsxs("div",{className:"fk:space-y-1 fk:text-sm",children:[n.map((r,s)=>jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(CheckIcon,{className:"fk:size-4"}),jsx("span",{className:"fk:whitespace-pre-wrap",children:r})]},`${r}-${s.toString()}`)),typeof a=="string"?jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(ue,{isError:e.status==="error",loading:e.status!=="error"}),jsx("span",{children:e.status==="error"?e.error?.message??a:a})]}):null]})]})}function Fa({api:e,message:t}){let n=t.status==="done"&&t.artifactId,a=n?e.getArtifactUrl(t.artifactId??""):"",r=n?e.getArtifactUrl(t.artifactId??"",{download:true}):"",s=Ka(t.sizeBytes);return jsxs(E,{children:[jsxs(O,{children:[jsx(FileTextIcon,{className:"fk:size-3.5"}),t.status==="done"?"Published artifact":"Publishing artifact"]}),jsxs("div",{className:"fk:relative fk:min-h-5 fk:pl-6",children:[jsx("span",{className:"fk:absolute fk:left-0 fk:top-0",children:jsx(ue,{isError:t.status==="error",loading:t.status==="uploading"})}),jsxs("div",{className:"fk:min-w-0 fk:space-y-2",children:[jsxs("div",{className:"fk:min-w-0",children:[jsx("div",{className:"fk:truncate fk:font-medium",children:t.filename}),jsxs("div",{className:"fk:text-xs fk:text-muted-foreground",children:[t.status==="uploading"&&"Uploading to artifacts",t.status==="done"&&[Za(t),s].filter(Boolean).join(" \xB7 "),t.status==="error"&&(t.error?.message??"Failed to publish artifact")]})]}),n?jsxs("div",{className:"fk:flex fk:flex-wrap fk:gap-2",children:[jsx(d$1,{asChild:true,size:"sm",variant:"outline",children:jsx("a",{href:a,rel:"noreferrer",target:"_blank",children:"Preview"})}),jsx(d$1,{asChild:true,size:"sm",variant:"outline",children:jsxs("a",{href:r,children:[jsx(DownloadIcon,{className:"fk:size-3"}),"Download"]})}),t.url?jsx(d$1,{asChild:true,size:"sm",variant:"outline",children:jsxs("a",{href:t.url,rel:"noreferrer",target:"_blank",children:[jsx(LinkIcon,{className:"fk:size-3"}),"Permanent link"]})}):null]}):null]})]})]})}function Ha({message:e}){let t=e.provider==="slack"?"Slack":"Microsoft Teams",n=e.provider==="slack"?jsx(MessageSquareIcon,{className:"fk:size-3.5"}):jsx(SendIcon,{className:"fk:size-3.5"});return jsx(we,{error:e.error?.message,icon:n,loading:e.status==="loading",message:e.status==="error"?e.error?.message??`Failed to send result to ${e.channelName}`:`${e.status==="done"?"Sent":"Sending"} result to ${e.channelName}`,title:`${t} Delivery`})}function Ga({message:e}){let t=e.status==="success"?jsx(CheckCircle2Icon,{className:"fk:size-3.5 fk:text-green-700"}):e.status==="skipped"?jsx(CircleSlashIcon,{className:"fk:size-3.5"}):jsx(XCircleIcon,{className:"fk:size-3.5 fk:text-red-700"}),n=e.status==="success"?"Run completed":e.status==="skipped"?"Run skipped":"Run failed";return jsxs(E,{className:e.status==="failed"?"fk:border-red-700/40":"fk:border-green-700/40",children:[jsxs(O,{children:[t,jsx("span",{children:n})]}),e.status==="failed"?jsx("p",{className:"fk:whitespace-pre-wrap fk:text-xs",children:e.summary}):null]})}function Va({api:e,message:t}){let{projectId:n}=Ta(),a=useContext(Pa),r=useContext(Ca),s=useRef(void 0),{data:l,error:u,isValidating:p,mutate:f}=Ra(n?g(n).approval(t.approvalId):null,f$1,{refreshInterval:d=>t.status!=="pending"||d?.approval?.status&&d.approval.status!=="pending"?0:yt}),c=l?.approval?.status,g$1=(c??t.status)==="pending",R=l?.approval?.kind==="schema"&&l.approval.status==="approved";useEffect(()=>{!R||!n||re({approvalId:t.approvalId,approvalUrl:g(n).approval(t.approvalId),projectId:n});},[R,t.approvalId,n]),useEffect(()=>{f();},[t.status,f]),useEffect(()=>{let d=s.current;s.current=c,!(t.status!=="pending"||!c||c==="pending")&&d==="pending"&&a?.onApprovalDecided(l?.approval?.id??t.approvalId,c);},[c,l?.approval?.id,t.approvalId,t.status,a]);function v(d){d.status!=="pending"&&(s.current=d.status),f(),a?.onApprovalDecided(d.id,d.status);}let b;if(l?.approval)b=jsx(Ve,{api:e,approval:l.approval,chat:r,onDecided:v},l.approval.status);else if(u&&!p){let d=u instanceof Error&&u.message?u.message:"Request failed";b=jsxs("div",{className:"fk:space-y-2",children:[jsxs("p",{className:"fk:text-xs fk:text-destructive",children:["Failed to load proposal ",t.operationsSummary,": ",d]}),jsx(d$1,{size:"sm",variant:"outline",onClick:()=>{f();},children:"Retry"})]});}else b=jsxs("div",{className:"fk:flex fk:items-center fk:gap-2 fk:text-xs fk:text-muted-foreground",children:[jsx(LoaderCircle,{className:"fk:size-3.5 fk:animate-spin"}),jsxs("span",{children:["Loading proposal ",t.operationsSummary,"..."]})]});return jsxs(E,{children:[jsxs(O,{children:[r?jsx(ShieldIcon,{className:"fk:size-3.5"}):jsx(DatabaseZapIcon,{className:"fk:size-3.5"}),r?"Approval request":"Mutation approval",g$1?jsx(LoaderCircle,{className:"fk:ml-1 fk:size-3.5 fk:animate-spin"}):null]}),jsx("div",{className:"fk:mt-2",children:b}),t.status==="error"&&t.error?jsx("p",{className:"fk:mt-2 fk:text-xs fk:text-destructive",children:t.error.message}):null]})}function Wa({message:e}){let t=e.operationsSummary.replace(/^Call /,"");return jsx(we,{error:e.status==="error"?e.error?.message??"The call failed.":void 0,icon:jsx(ShieldCheckIcon,{className:"fk:size-3.5"}),loading:false,message:e.status==="error"?`${t}: ${e.error?.message??"The call failed."}`:`${t} \xB7 Auto-approved by Jev`,title:"Plugin call"})}function Ya({message:e}){let t=[typeof e.processedItems=="number"?`${e.processedItems.toString()} processed`:"",typeof e.changedItems=="number"?`${e.changedItems.toString()} changed`:"",typeof e.failedItems=="number"?`${e.failedItems.toString()} failed`:"",typeof e.totalItems=="number"?`${e.totalItems.toString()} total`:""].filter(Boolean);return jsx(we,{error:e.error?.message,icon:jsx(DatabaseZapIcon,{className:"fk:size-3.5"}),loading:e.status==="loading"||e.status==="running",message:e.status==="error"?e.error?.message??`Failed bulk ${e.operationName}`:`${e.status==="done"?"Completed":"Running"} ${e.operationName}${t.length>0?` (${t.join(", ")})`:""}`,title:"Bulk GraphQL action"})}function Qa({part:e}){return jsxs(E,{className:"fk:bg-muted/30",children:[jsxs(O,{children:[jsx(CheckCircle2Icon,{className:"fk:size-3.5"}),e.type.replace(/^data-/,"").replaceAll("-"," ")]}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"This run emitted a structured event that is not yet rendered by Studio."})]})}function Ka(e){if(typeof e!="number")return "";if(e<1024)return `${e.toString()} B`;let t=e/1024;return t<1024?`${t.toFixed(1)} KB`:`${(t/1024).toFixed(1)} MB`}function Za(e){return e.kind==="pdf"?"PDF artifact":e.kind==="html"?"HTML artifact":"Artifact"}function en({pluginId:e}){let{pathname:t}=useLocation(),[n]=t.split("/ai/");return jsxs(E,{children:[jsxs("p",{className:"fk:text-sm",children:["Connect ",e," to use it in this conversation."]}),jsx(d$1,{asChild:true,size:"sm",variant:"outline",children:jsxs(Link,{to:`${n}/ai/plugins/${encodeURIComponent(e)}`,children:["Connect ",e]})})]})}export{Va as A,je as a,$t as b,gn as c,ie as d,Qt as e,ke as f,Qe as g,Kt as h,Ke as i,An as j,Nn as k,Tn as l,Pn as m,Cn as n,it as o,Ta as p,yt as q,Pa as r,Ca as s,Wn as t,G as u,Yn as v,Qn as w,Kn as x,Oa as y,Zn as z};//# sourceMappingURL=chunk-2FQWBOU6.js.map
|
|
6
|
-
//# sourceMappingURL=chunk-2FQWBOU6.js.map
|