@brainfish-ai/components 0.35.12 → 0.35.15

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.
@@ -5,9 +5,9 @@ return e.createElement(s,null,i&&!v&&/* @__PURE__ */e.createElement(m.div,{initi
5
5
  /* @__PURE__ */e.createElement(d,{className:"gap-2 p-3"},/* @__PURE__ */e.createElement(u,{className:"px-0"},/* @__PURE__ */e.createElement("p",null,c)))))}function k({className:t,children:a,doAnimation:n=!1,...r}){/* @__PURE__ */
6
6
  return e.createElement("div",{className:v("relative",t),...r},/* @__PURE__ */e.createElement(s,null,n&&/* @__PURE__ */e.createElement(e.Fragment,null,Array.from({length:8}).map((t,a)=>/* @__PURE__ */e.createElement(m.div,{key:a,className:"absolute top-1/2 left-1/2 origin-center pointer-events-none",initial:{opacity:0,scale:.3,x:0,y:0},animate:{opacity:[0,1,1,0],scale:[.3,1,1,0],x:[0,30*Math.cos(a*(Math.PI/4))],y:[0,30*Math.sin(a*(Math.PI/4))],rotate:[0,a%2?45:-45]},transition:{duration:1.2,ease:[.4,0,.2,1],times:[0,.3,.7,1],delay:.1*a}},
7
7
  /* @__PURE__ */e.createElement(i,{className:"size-4 text-rose-500",style:{filter:"drop-shadow(0 0 3px rgba(255, 75, 110, 0.8))",strokeWidth:2.5}}))),/* @__PURE__ */e.createElement(m.div,{className:"absolute inset-0 rounded-full bg-primary pointer-events-none",initial:{opacity:0,scale:.8},animate:{opacity:[0,.15,.15,0],scale:[.8,1.8,1.8,2]},transition:{duration:1.2,ease:"easeOut",times:[0,.3,.7,1]}}))),a)}function N({feedback:r,onFeedback:l,textConfig:i={},disabled:d=!1,feedbackReasonLength:u=500,feedbackReasonPlaceholder:p="What could we have done better? Your feedback is valuable to us...",onFeedbackReasonSubmit:f,feedbackReasonThankYouText:v="Thank you for your feedback!"}){const[N,w]=t(!1),[j,T]=t(!1),C=a(null);n(()=>{j&&C.current&&C.current.focus()},[j]);const z=e=>{l&&("accept"===e&&(w(!0),setTimeout(()=>w(!1),2e3)),l(e),"reject"===e&&T(!0))};/* @__PURE__ */
8
- return e.createElement("div",{className:"flex flex-col gap-2"},/* @__PURE__ */e.createElement("div",{className:"flex justify-end gap-2","data-name":"Feedback"},/* @__PURE__ */e.createElement(E,null,/* @__PURE__ */e.createElement(k,{doAnimation:N},/* @__PURE__ */e.createElement(b,null,/* @__PURE__ */e.createElement(g,{asChild:!0},/* @__PURE__ */e.createElement(h,{variant:"ghost",size:"sm",className:"rounded-md size-8 flex items-center justify-center transition-all duration-200 transform hover:scale-105 active:scale-95 "+("accept"===r?"bg-green-100 text-green-600 hover:bg-green-200":"text-dark-500"),onClick:()=>{z("accept"),T(!1)},disabled:d},
8
+ return e.createElement("div",{className:"flex flex-col gap-2"},/* @__PURE__ */e.createElement("div",{className:"flex justify-end gap-2","data-name":"Feedback"},/* @__PURE__ */e.createElement(E,null,/* @__PURE__ */e.createElement(k,{doAnimation:N},/* @__PURE__ */e.createElement(b,null,/* @__PURE__ */e.createElement(g,{asChild:!0},/* @__PURE__ */e.createElement(h,{variant:"ghost",size:"sm",className:"rounded-md size-9 flex items-center justify-center transition-all duration-200 transform hover:scale-105 active:scale-95 "+("accept"===r?"bg-green-100 text-green-600 hover:bg-green-200":"text-dark-500"),onClick:()=>{z("accept"),T(!1)},disabled:d},
9
9
  /* @__PURE__ */e.createElement(m.div,{initial:{scale:1},animate:{scale:"accept"===r?[1,1.2,1]:1},transition:{duration:.3}},
10
- /* @__PURE__ */e.createElement(o,{weight:"bold"})))),/* @__PURE__ */e.createElement(y,null,/* @__PURE__ */e.createElement("p",null,i.positiveAnswerText||"Helpful"))))),/* @__PURE__ */e.createElement(E,null,/* @__PURE__ */e.createElement(b,null,/* @__PURE__ */e.createElement(g,{asChild:!0},/* @__PURE__ */e.createElement(h,{variant:"ghost",size:"sm",className:"rounded-md size-8 flex items-center justify-center transition-all duration-200 transform hover:scale-105 active:scale-95 "+("reject"===r?"bg-red-100 text-red-600 hover:bg-red-200":"text-dark-500"),onClick:()=>z("reject"),disabled:d},
10
+ /* @__PURE__ */e.createElement(o,{weight:"bold"})))),/* @__PURE__ */e.createElement(y,null,/* @__PURE__ */e.createElement("p",null,i.positiveAnswerText||"Helpful"))))),/* @__PURE__ */e.createElement(E,null,/* @__PURE__ */e.createElement(b,null,/* @__PURE__ */e.createElement(g,{asChild:!0},/* @__PURE__ */e.createElement(h,{variant:"ghost",size:"sm",className:"rounded-md size-9 flex items-center justify-center transition-all duration-200 transform hover:scale-105 active:scale-95 "+("reject"===r?"bg-red-100 text-red-600 hover:bg-red-200":"text-dark-500"),onClick:()=>z("reject"),disabled:d},
11
11
  /* @__PURE__ */e.createElement(m.div,{initial:{scale:1},animate:{scale:"reject"===r?[1,1.2,1]:1},transition:{duration:.3}},
12
12
  /* @__PURE__ */e.createElement(c,{weight:"bold"})))),/* @__PURE__ */e.createElement(y,null,/* @__PURE__ */e.createElement("p",null,i.negativeAnswerText||"Not helpful"))))),/* @__PURE__ */e.createElement(s,null,j&&/* @__PURE__ */e.createElement(x,{open:j,onSubmit:f,thankYouText:v,placeholder:p,maxLength:u})))}export{N as F};
13
- //# sourceMappingURL=feedback.CbCOP40K.js.map
13
+ //# sourceMappingURL=feedback.aGVWiKHH.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"feedback.CbCOP40K.js","sources":["../../../src/components/feedback/feedback-reason.tsx","../../../src/components/love/love.tsx","../../../src/components/feedback/feedback.tsx"],"sourcesContent":["import React, { useRef, useEffect, useState } from 'react';\nimport { motion, AnimatePresence } from 'framer-motion';\nimport { PaperPlaneRight, X } from '@phosphor-icons/react';\n\nimport { Card, CardContent, CardFooter } from '@/components/ui/card';\nimport { Textarea } from '@/components/ui/textarea';\nimport { Button } from '@/components/ui/button';\n\ninterface FeedbackReasonProps {\n open: boolean;\n onSubmit?: (reason: string) => void;\n thankYouText?: string;\n placeholder?: string;\n maxLength?: number;\n}\n\nexport function FeedbackReason({\n open,\n onSubmit,\n thankYouText = 'Thank you for your feedback!',\n placeholder = 'What could we have done better? Your feedback is valuable to us...',\n maxLength = 500,\n}: FeedbackReasonProps) {\n const [reason, setReason] = useState('');\n const [submitted, setSubmitted] = useState(false);\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n useEffect(() => {\n if (open) {\n setReason('');\n setSubmitted(false);\n setTimeout(() => textareaRef.current?.focus(), 0);\n }\n }, [open]);\n\n const handleSubmit = () => {\n if (reason.trim()) {\n onSubmit?.(reason);\n setSubmitted(true);\n }\n };\n\n return (\n <AnimatePresence>\n {open && !submitted && (\n <motion.div\n initial={{ opacity: 0, y: 12 }}\n animate={{ opacity: 1, y: 0 }}\n exit={{ opacity: 0, y: 12 }}\n transition={{ duration: 0.25, ease: [0.4, 0, 0.2, 1] }}\n >\n <Card className=\"gap-2 p-3\">\n <CardContent className=\"px-0\">\n <Textarea\n ref={textareaRef}\n placeholder={placeholder}\n className=\"w-full border-none shadow-none focus-visible:ring-0 p-0\"\n maxLength={maxLength}\n value={reason}\n rows={4}\n onChange={(e) => setReason(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === 'Enter' && !e.shiftKey) {\n e.preventDefault();\n handleSubmit();\n }\n }}\n />\n <div className=\"flex justify-end mt-1\">\n <span className=\"text-xs text-muted-foreground select-none\">\n {maxLength - reason.length} characters remaining\n </span>\n </div>\n </CardContent>\n <CardFooter className=\"p-0 gap-2 flex-row-reverse\">\n <Button size=\"icon\" onClick={handleSubmit} disabled={!reason.length} aria-label=\"Submit feedback\">\n <PaperPlaneRight aria-hidden=\"true\" weight=\"bold\" />\n </Button>\n <Button\n size=\"icon\"\n variant=\"ghost\"\n onClick={() => {\n setReason('');\n textareaRef.current?.focus();\n }}\n aria-label=\"Cancel feedback\"\n >\n <X aria-hidden=\"true\" weight=\"bold\" />\n </Button>\n </CardFooter>\n </Card>\n </motion.div>\n )}\n {open && submitted && (\n <motion.div\n initial={{ opacity: 0, y: 12 }}\n animate={{ opacity: 1, y: 0 }}\n exit={{ opacity: 0, y: 12 }}\n transition={{ duration: 0.25, ease: [0.4, 0, 0.2, 1] }}\n >\n <Card className=\"gap-2 p-3\">\n <CardContent className=\"px-0\">\n <p>{thankYouText}</p>\n </CardContent>\n </Card>\n </motion.div>\n )}\n </AnimatePresence>\n );\n}\n","import { Heart } from '@phosphor-icons/react';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport React from 'react';\n\nimport { cn } from '@/lib/utils';\n\ninterface LoveProps extends React.HTMLAttributes<HTMLDivElement> {\n className?: string;\n doAnimation?: boolean;\n}\n\nexport function Love({ className, children, doAnimation = false, ...props }: LoveProps) {\n return (\n <div className={cn('relative', className)} {...props}>\n <AnimatePresence>\n {doAnimation && (\n <>\n {Array.from({ length: 8 }).map((_, i) => (\n <motion.div\n key={i}\n className=\"absolute top-1/2 left-1/2 origin-center pointer-events-none\"\n initial={{ opacity: 0, scale: 0.3, x: 0, y: 0 }}\n animate={{\n opacity: [0, 1, 1, 0],\n scale: [0.3, 1, 1, 0],\n x: [0, Math.cos(i * (Math.PI / 4)) * 30],\n y: [0, Math.sin(i * (Math.PI / 4)) * 30],\n rotate: [0, i % 2 ? 45 : -45],\n }}\n transition={{\n duration: 1.2,\n ease: [0.4, 0, 0.2, 1],\n times: [0, 0.3, 0.7, 1],\n delay: i * 0.1,\n }}\n >\n <Heart\n className=\"size-4 text-rose-500\"\n style={{\n filter: 'drop-shadow(0 0 3px rgba(255, 75, 110, 0.8))',\n strokeWidth: 2.5,\n }}\n />\n </motion.div>\n ))}\n <motion.div\n className=\"absolute inset-0 rounded-full bg-primary pointer-events-none\"\n initial={{ opacity: 0, scale: 0.8 }}\n animate={{\n opacity: [0, 0.15, 0.15, 0],\n scale: [0.8, 1.8, 1.8, 2],\n }}\n transition={{\n duration: 1.2,\n ease: 'easeOut',\n times: [0, 0.3, 0.7, 1],\n }}\n />\n </>\n )}\n </AnimatePresence>\n {children}\n </div>\n );\n}\n","import React, { useState, useRef, useEffect } from 'react';\nimport { ThumbsUp, ThumbsDown } from '@phosphor-icons/react';\nimport { motion, AnimatePresence } from 'framer-motion';\n\nimport { FeedbackReason } from './feedback-reason';\nimport { Love } from '../love';\n\nimport { Button } from '@/components/ui/button';\nimport { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';\n\nexport type FeedbackResponse = 'accept' | 'reject';\n\ninterface FeedbackProps {\n feedback?: FeedbackResponse;\n onFeedback?: (response: FeedbackResponse) => void;\n textConfig?: {\n positiveAnswerText?: string;\n negativeAnswerText?: string;\n };\n disabled?: boolean;\n feedbackReasonLength?: number;\n feedbackReasonPlaceholder?: string;\n onFeedbackReasonSubmit?: (reason: string) => void;\n feedbackReasonThankYouText?: string;\n}\n\nexport function Feedback({\n feedback,\n onFeedback,\n textConfig = {},\n disabled = false,\n feedbackReasonLength = 500,\n feedbackReasonPlaceholder = 'What could we have done better? Your feedback is valuable to us...',\n onFeedbackReasonSubmit,\n feedbackReasonThankYouText = 'Thank you for your feedback!',\n}: FeedbackProps) {\n const [showHearts, setShowHearts] = useState(false);\n const [showFeedbackReason, setShowFeedbackReason] = useState(false);\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n useEffect(() => {\n if (showFeedbackReason && textareaRef.current) {\n textareaRef.current.focus();\n }\n }, [showFeedbackReason]);\n\n const handleFeedback = (response: FeedbackResponse) => {\n if (onFeedback) {\n if (response === 'accept') {\n setShowHearts(true);\n setTimeout(() => setShowHearts(false), 2000);\n }\n onFeedback(response);\n if (response === 'reject') {\n setShowFeedbackReason(true);\n }\n }\n };\n\n return (\n <div className=\"flex flex-col gap-2\">\n <div className=\"flex justify-end gap-2\" data-name=\"Feedback\">\n <TooltipProvider>\n <Love doAnimation={showHearts}>\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n className={`rounded-md size-8 flex items-center justify-center transition-all duration-200 transform hover:scale-105 active:scale-95 ${\n feedback === 'accept' ? 'bg-green-100 text-green-600 hover:bg-green-200' : 'text-dark-500'\n }`}\n onClick={() => {\n handleFeedback('accept');\n setShowFeedbackReason(false);\n }}\n disabled={disabled}\n >\n <motion.div\n initial={{ scale: 1 }}\n animate={{ scale: feedback === 'accept' ? [1, 1.2, 1] : 1 }}\n transition={{ duration: 0.3 }}\n >\n <ThumbsUp weight=\"bold\" />\n </motion.div>\n </Button>\n </TooltipTrigger>\n <TooltipContent>\n <p>{textConfig.positiveAnswerText || 'Helpful'}</p>\n </TooltipContent>\n </Tooltip>\n </Love>\n </TooltipProvider>\n <TooltipProvider>\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n className={`rounded-md size-8 flex items-center justify-center transition-all duration-200 transform hover:scale-105 active:scale-95 ${\n feedback === 'reject' ? 'bg-red-100 text-red-600 hover:bg-red-200' : 'text-dark-500'\n }`}\n onClick={() => handleFeedback('reject')}\n disabled={disabled}\n >\n <motion.div\n initial={{ scale: 1 }}\n animate={{ scale: feedback === 'reject' ? [1, 1.2, 1] : 1 }}\n transition={{ duration: 0.3 }}\n >\n <ThumbsDown weight=\"bold\" />\n </motion.div>\n </Button>\n </TooltipTrigger>\n <TooltipContent>\n <p>{textConfig.negativeAnswerText || 'Not helpful'}</p>\n </TooltipContent>\n </Tooltip>\n </TooltipProvider>\n </div>\n <AnimatePresence>\n {showFeedbackReason && (\n <FeedbackReason\n open={showFeedbackReason}\n onSubmit={onFeedbackReasonSubmit}\n thankYouText={feedbackReasonThankYouText}\n placeholder={feedbackReasonPlaceholder}\n maxLength={feedbackReasonLength}\n />\n )}\n </AnimatePresence>\n </div>\n );\n}\n"],"names":["FeedbackReason","open","onSubmit","thankYouText","placeholder","maxLength","reason","setReason","useState","submitted","setSubmitted","textareaRef","useRef","useEffect","setTimeout","current","focus","handleSubmit","trim","React","createElement","AnimatePresence","motion","div","initial","opacity","y","animate","exit","transition","duration","ease","Card","className","CardContent","Textarea","ref","value","rows","onChange","e","target","onKeyDown","key","shiftKey","preventDefault","length","CardFooter","Button","size","onClick","disabled","PaperPlaneRight","weight","variant","X","Love","children","doAnimation","props","cn","Fragment","Array","from","map","_","i","scale","x","Math","cos","PI","sin","rotate","times","delay","Heart","style","filter","strokeWidth","Feedback","feedback","onFeedback","textConfig","feedbackReasonLength","feedbackReasonPlaceholder","onFeedbackReasonSubmit","feedbackReasonThankYouText","showHearts","setShowHearts","showFeedbackReason","setShowFeedbackReason","handleFeedback","response","TooltipProvider","Tooltip","TooltipTrigger","asChild","ThumbsUp","TooltipContent","positiveAnswerText","ThumbsDown","negativeAnswerText"],"mappings":"gjBAgBO,SAASA,GAAeC,KAC7BA,EAAAC,SACAA,EAAAC,aACAA,EAAe,+BAAAC,YACfA,EAAc,qEAAAC,UACdA,EAAY,MAEZ,MAAOC,EAAQC,GAAaC,EAAS,KAC9BC,EAAWC,GAAgBF,GAAS,GACrCG,EAAcC,EAA4B,MAEhDC,EAAU,KACJZ,IACFM,EAAU,IACVG,GAAa,GACbI,WAAW,IAAMH,EAAYI,SAASC,QAAS,KAEhD,CAACf,IAEJ,MAAMgB,EAAe,KACfX,EAAOY,SACThB,IAAWI,GACXI,GAAa;AAIjB,OACES,EAAAC,cAACC,EAAA,KACEpB,IAASQ,kBACRU,EAAAC,cAACE,EAAOC,IAAP,CACCC,QAAS,CAAEC,QAAS,EAAGC,EAAG,IAC1BC,QAAS,CAAEF,QAAS,EAAGC,EAAG,GAC1BE,KAAM,CAAEH,QAAS,EAAGC,EAAG,IACvBG,WAAY,CAAEC,SAAU,IAAMC,KAAM,CAAC,GAAK,EAAG,GAAK;+BAEjDC,EAAA,CAAKC,UAAU,4BACdd,EAAAC,cAACc,EAAA,CAAYD,UAAU,uBACrBd,EAAAC,cAACe,EAAA,CACCC,IAAKzB,EACLP,cACA6B,UAAU,0DACV5B,YACAgC,MAAO/B,EACPgC,KAAM,EACNC,SAAWC,GAAMjC,EAAUiC,EAAEC,OAAOJ,OACpCK,UAAYF,IACI,UAAVA,EAAEG,KAAoBH,EAAEI,WAC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,UAAW+E,KAMvB"}
1
+ {"version":3,"file":"feedback.aGVWiKHH.js","sources":["../../../src/components/feedback/feedback-reason.tsx","../../../src/components/love/love.tsx","../../../src/components/feedback/feedback.tsx"],"sourcesContent":["import React, { useRef, useEffect, useState } from 'react';\nimport { motion, AnimatePresence } from 'framer-motion';\nimport { PaperPlaneRight, X } from '@phosphor-icons/react';\n\nimport { Card, CardContent, CardFooter } from '@/components/ui/card';\nimport { Textarea } from '@/components/ui/textarea';\nimport { Button } from '@/components/ui/button';\n\ninterface FeedbackReasonProps {\n open: boolean;\n onSubmit?: (reason: string) => void;\n thankYouText?: string;\n placeholder?: string;\n maxLength?: number;\n}\n\nexport function FeedbackReason({\n open,\n onSubmit,\n thankYouText = 'Thank you for your feedback!',\n placeholder = 'What could we have done better? Your feedback is valuable to us...',\n maxLength = 500,\n}: FeedbackReasonProps) {\n const [reason, setReason] = useState('');\n const [submitted, setSubmitted] = useState(false);\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n useEffect(() => {\n if (open) {\n setReason('');\n setSubmitted(false);\n setTimeout(() => textareaRef.current?.focus(), 0);\n }\n }, [open]);\n\n const handleSubmit = () => {\n if (reason.trim()) {\n onSubmit?.(reason);\n setSubmitted(true);\n }\n };\n\n return (\n <AnimatePresence>\n {open && !submitted && (\n <motion.div\n initial={{ opacity: 0, y: 12 }}\n animate={{ opacity: 1, y: 0 }}\n exit={{ opacity: 0, y: 12 }}\n transition={{ duration: 0.25, ease: [0.4, 0, 0.2, 1] }}\n >\n <Card className=\"gap-2 p-3\">\n <CardContent className=\"px-0\">\n <Textarea\n ref={textareaRef}\n placeholder={placeholder}\n className=\"w-full border-none shadow-none focus-visible:ring-0 p-0\"\n maxLength={maxLength}\n value={reason}\n rows={4}\n onChange={(e) => setReason(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === 'Enter' && !e.shiftKey) {\n e.preventDefault();\n handleSubmit();\n }\n }}\n />\n <div className=\"flex justify-end mt-1\">\n <span className=\"text-xs text-muted-foreground select-none\">\n {maxLength - reason.length} characters remaining\n </span>\n </div>\n </CardContent>\n <CardFooter className=\"p-0 gap-2 flex-row-reverse\">\n <Button size=\"icon\" onClick={handleSubmit} disabled={!reason.length} aria-label=\"Submit feedback\">\n <PaperPlaneRight aria-hidden=\"true\" weight=\"bold\" />\n </Button>\n <Button\n size=\"icon\"\n variant=\"ghost\"\n onClick={() => {\n setReason('');\n textareaRef.current?.focus();\n }}\n aria-label=\"Cancel feedback\"\n >\n <X aria-hidden=\"true\" weight=\"bold\" />\n </Button>\n </CardFooter>\n </Card>\n </motion.div>\n )}\n {open && submitted && (\n <motion.div\n initial={{ opacity: 0, y: 12 }}\n animate={{ opacity: 1, y: 0 }}\n exit={{ opacity: 0, y: 12 }}\n transition={{ duration: 0.25, ease: [0.4, 0, 0.2, 1] }}\n >\n <Card className=\"gap-2 p-3\">\n <CardContent className=\"px-0\">\n <p>{thankYouText}</p>\n </CardContent>\n </Card>\n </motion.div>\n )}\n </AnimatePresence>\n );\n}\n","import { Heart } from '@phosphor-icons/react';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport React from 'react';\n\nimport { cn } from '@/lib/utils';\n\ninterface LoveProps extends React.HTMLAttributes<HTMLDivElement> {\n className?: string;\n doAnimation?: boolean;\n}\n\nexport function Love({ className, children, doAnimation = false, ...props }: LoveProps) {\n return (\n <div className={cn('relative', className)} {...props}>\n <AnimatePresence>\n {doAnimation && (\n <>\n {Array.from({ length: 8 }).map((_, i) => (\n <motion.div\n key={i}\n className=\"absolute top-1/2 left-1/2 origin-center pointer-events-none\"\n initial={{ opacity: 0, scale: 0.3, x: 0, y: 0 }}\n animate={{\n opacity: [0, 1, 1, 0],\n scale: [0.3, 1, 1, 0],\n x: [0, Math.cos(i * (Math.PI / 4)) * 30],\n y: [0, Math.sin(i * (Math.PI / 4)) * 30],\n rotate: [0, i % 2 ? 45 : -45],\n }}\n transition={{\n duration: 1.2,\n ease: [0.4, 0, 0.2, 1],\n times: [0, 0.3, 0.7, 1],\n delay: i * 0.1,\n }}\n >\n <Heart\n className=\"size-4 text-rose-500\"\n style={{\n filter: 'drop-shadow(0 0 3px rgba(255, 75, 110, 0.8))',\n strokeWidth: 2.5,\n }}\n />\n </motion.div>\n ))}\n <motion.div\n className=\"absolute inset-0 rounded-full bg-primary pointer-events-none\"\n initial={{ opacity: 0, scale: 0.8 }}\n animate={{\n opacity: [0, 0.15, 0.15, 0],\n scale: [0.8, 1.8, 1.8, 2],\n }}\n transition={{\n duration: 1.2,\n ease: 'easeOut',\n times: [0, 0.3, 0.7, 1],\n }}\n />\n </>\n )}\n </AnimatePresence>\n {children}\n </div>\n );\n}\n","import React, { useState, useRef, useEffect } from 'react';\nimport { ThumbsUp, ThumbsDown } from '@phosphor-icons/react';\nimport { motion, AnimatePresence } from 'framer-motion';\n\nimport { FeedbackReason } from './feedback-reason';\nimport { Love } from '../love';\n\nimport { Button } from '@/components/ui/button';\nimport { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';\n\nexport type FeedbackResponse = 'accept' | 'reject';\n\ninterface FeedbackProps {\n feedback?: FeedbackResponse;\n onFeedback?: (response: FeedbackResponse) => void;\n textConfig?: {\n positiveAnswerText?: string;\n negativeAnswerText?: string;\n };\n disabled?: boolean;\n feedbackReasonLength?: number;\n feedbackReasonPlaceholder?: string;\n onFeedbackReasonSubmit?: (reason: string) => void;\n feedbackReasonThankYouText?: string;\n}\n\nexport function Feedback({\n feedback,\n onFeedback,\n textConfig = {},\n disabled = false,\n feedbackReasonLength = 500,\n feedbackReasonPlaceholder = 'What could we have done better? Your feedback is valuable to us...',\n onFeedbackReasonSubmit,\n feedbackReasonThankYouText = 'Thank you for your feedback!',\n}: FeedbackProps) {\n const [showHearts, setShowHearts] = useState(false);\n const [showFeedbackReason, setShowFeedbackReason] = useState(false);\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n useEffect(() => {\n if (showFeedbackReason && textareaRef.current) {\n textareaRef.current.focus();\n }\n }, [showFeedbackReason]);\n\n const handleFeedback = (response: FeedbackResponse) => {\n if (onFeedback) {\n if (response === 'accept') {\n setShowHearts(true);\n setTimeout(() => setShowHearts(false), 2000);\n }\n onFeedback(response);\n if (response === 'reject') {\n setShowFeedbackReason(true);\n }\n }\n };\n\n return (\n <div className=\"flex flex-col gap-2\">\n <div className=\"flex justify-end gap-2\" data-name=\"Feedback\">\n <TooltipProvider>\n <Love doAnimation={showHearts}>\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n className={`rounded-md size-9 flex items-center justify-center transition-all duration-200 transform hover:scale-105 active:scale-95 ${\n feedback === 'accept' ? 'bg-green-100 text-green-600 hover:bg-green-200' : 'text-dark-500'\n }`}\n onClick={() => {\n handleFeedback('accept');\n setShowFeedbackReason(false);\n }}\n disabled={disabled}\n >\n <motion.div\n initial={{ scale: 1 }}\n animate={{ scale: feedback === 'accept' ? [1, 1.2, 1] : 1 }}\n transition={{ duration: 0.3 }}\n >\n <ThumbsUp weight=\"bold\" />\n </motion.div>\n </Button>\n </TooltipTrigger>\n <TooltipContent>\n <p>{textConfig.positiveAnswerText || 'Helpful'}</p>\n </TooltipContent>\n </Tooltip>\n </Love>\n </TooltipProvider>\n <TooltipProvider>\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n className={`rounded-md size-9 flex items-center justify-center transition-all duration-200 transform hover:scale-105 active:scale-95 ${\n feedback === 'reject' ? 'bg-red-100 text-red-600 hover:bg-red-200' : 'text-dark-500'\n }`}\n onClick={() => handleFeedback('reject')}\n disabled={disabled}\n >\n <motion.div\n initial={{ scale: 1 }}\n animate={{ scale: feedback === 'reject' ? [1, 1.2, 1] : 1 }}\n transition={{ duration: 0.3 }}\n >\n <ThumbsDown weight=\"bold\" />\n </motion.div>\n </Button>\n </TooltipTrigger>\n <TooltipContent>\n <p>{textConfig.negativeAnswerText || 'Not helpful'}</p>\n </TooltipContent>\n </Tooltip>\n </TooltipProvider>\n </div>\n <AnimatePresence>\n {showFeedbackReason && (\n <FeedbackReason\n open={showFeedbackReason}\n onSubmit={onFeedbackReasonSubmit}\n thankYouText={feedbackReasonThankYouText}\n placeholder={feedbackReasonPlaceholder}\n maxLength={feedbackReasonLength}\n />\n )}\n </AnimatePresence>\n </div>\n );\n}\n"],"names":["FeedbackReason","open","onSubmit","thankYouText","placeholder","maxLength","reason","setReason","useState","submitted","setSubmitted","textareaRef","useRef","useEffect","setTimeout","current","focus","handleSubmit","trim","React","createElement","AnimatePresence","motion","div","initial","opacity","y","animate","exit","transition","duration","ease","Card","className","CardContent","Textarea","ref","value","rows","onChange","e","target","onKeyDown","key","shiftKey","preventDefault","length","CardFooter","Button","size","onClick","disabled","PaperPlaneRight","weight","variant","X","Love","children","doAnimation","props","cn","Fragment","Array","from","map","_","i","scale","x","Math","cos","PI","sin","rotate","times","delay","Heart","style","filter","strokeWidth","Feedback","feedback","onFeedback","textConfig","feedbackReasonLength","feedbackReasonPlaceholder","onFeedbackReasonSubmit","feedbackReasonThankYouText","showHearts","setShowHearts","showFeedbackReason","setShowFeedbackReason","handleFeedback","response","TooltipProvider","Tooltip","TooltipTrigger","asChild","ThumbsUp","TooltipContent","positiveAnswerText","ThumbsDown","negativeAnswerText"],"mappings":"gjBAgBO,SAASA,GAAeC,KAC7BA,EAAAC,SACAA,EAAAC,aACAA,EAAe,+BAAAC,YACfA,EAAc,qEAAAC,UACdA,EAAY,MAEZ,MAAOC,EAAQC,GAAaC,EAAS,KAC9BC,EAAWC,GAAgBF,GAAS,GACrCG,EAAcC,EAA4B,MAEhDC,EAAU,KACJZ,IACFM,EAAU,IACVG,GAAa,GACbI,WAAW,IAAMH,EAAYI,SAASC,QAAS,KAEhD,CAACf,IAEJ,MAAMgB,EAAe,KACfX,EAAOY,SACThB,IAAWI,GACXI,GAAa;AAIjB,OACES,EAAAC,cAACC,EAAA,KACEpB,IAASQ,kBACRU,EAAAC,cAACE,EAAOC,IA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CAA6C,iBAEvE/B,QAAS,IAAM0C,EAAe,UAC9BzC;eAEAhC,EAAAC,cAACE,EAAOC,IAAP,CACCC,QAAS,CAAE2C,MAAO,GAClBxC,QAAS,CAAEwC,MAAoB,WAAbc,EAAwB,CAAC,EAAG,IAAK,GAAK,GACxDpD,WAAY,CAAEC,SAAU;eAExBX,EAAAC,cAACiF,EAAA,CAAWhD,OAAO,2BAIzBlC,EAAAC,cAAC+E,EAAA,oBACChF,EAAAC,cAAC,SAAG+D,EAAWmB,oBAAsB,kCAK7CnF,EAAAC,cAACC,OACEqE,kBACCvE,EAAAC,cAACpB,EAAA,CACCC,KAAMyF,EACNxF,SAAUoF,EACVnF,aAAcoF,EACdnF,YAAaiF,EACbhF,UAAW+E,KAMvB"}
@@ -1,2 +1,2 @@
1
- export{C as ChatSearch,a as ChatSearchProvider,N as NextBestActionType,R as ResolvedConversationFooter,u as useChatSearch,b as useIsChatSearchDirty,v as validateUrlString}from"../chunks/ChatSearch.Bf4y1_nr.js";
1
+ export{C as ChatSearch,a as ChatSearchProvider,N as NextBestActionType,R as ResolvedConversationFooter,u as useChatSearch,b as useIsChatSearchDirty,v as validateUrlString}from"../chunks/ChatSearch.DD63KIj6.js";
2
2
  //# sourceMappingURL=chat-search.js.map
@@ -1,28 +1,29 @@
1
- import e,{useState as t,useEffect as a,useRef as s,useMemo as r}from"react";import{S as n}from"../chunks/status-badge.BVWcC9Dt.js";import{ArrowSquareOut as l,CheckCircle as c,XCircle as i,ListMagnifyingGlass as m,UserCircle as o,Eye as d,UserFocus as u,Circle as p}from"@phosphor-icons/react";import{F as f}from"../chunks/FormattedMessage.CEEjawib.js";import{Spinner as g}from"./ui/spinner.js";import{B as E}from"../chunks/button.C7qRaFMP.js";import{useForm as h,Controller as v}from"react-hook-form";import{Select as N,SelectTrigger as x,SelectValue as b,SelectContent as w,SelectItem as y}from"./ui/select.js";import{Label as k}from"./ui/label.js";import{Textarea as j}from"./ui/textarea.js";import{Tooltip as C,TooltipTrigger as A,TooltipContent as _}from"./ui/tooltip.js";import{c as z}from"../chunks/utils.DtKoarLP.js";import{DivButton as O}from"./ui/div-button.js";import{ScrollArea as S}from"./ui/scroll-area.js";import{Sheet as D,SheetTrigger as F,SheetContent as R,SheetHeader as M,SheetTitle as I,SheetDescription as q}from"./ui/sheet.js";import{Badge as P}from"./ui/badge.js";import{G as T}from"../chunks/generating-star.DN8DVygp.js";import{Item as W,ItemHeader as B,ItemTitle as L,ItemContent as U,ItemDescription as G}from"./ui/item.js";import{Accordion as K,AccordionItem as H,AccordionTrigger as Z,AccordionContent as V}from"./ui/accordion.js";import{c as $,b as J}from"../chunks/formatDate.D2xEZm8f.js";import{createId as Q}from"@paralleldrive/cuid2";import{Table as X,TableHeader as Y,TableRow as ee,TableHead as te,TableBody as ae,TableCell as se}from"./ui/table.js";import '../global.css';import '../convos.css';/* empty css */import"@radix-ui/react-accordion";import"clsx";import"tailwind-merge";import"./ui/alert-dialog.js";import"./ui/alert.js";import"@radix-ui/react-avatar";import"./ui/button-group.js";import"./ui/calendar.js";import"./ui/card.js";import"@radix-ui/react-collapsible";import"./ui/command.js";import"./ui/dialog.js";import"./ui/dropdown-menu.js";import"./ui/icon.js";import"./ui/input.js";import"./ui/popover.js";import"./ui/progress.js";import"./ui/radio-group.js";import"react-resizable-panels";import"./ui/separator.js";import"./ui/switch.js";import"./ui/tabs.js";import"../logos/microsoft-teams-logo.js";import"../logos/slack-logo.js";import"../logos/microsoft-logo.js";import{d as re}from"../chunks/dark.DuW7JuAk.js";function ne({messageId:s}){const{fetchAnswerDiagnostics:r}=Ae(),[n,c]=t(null),[i,m]=t(!0);return a(()=>{r(s).then(e=>c(e)).finally(()=>m(!1))},[r,s]),/* @__PURE__ */e.createElement("div",{className:"flex flex-col gap-4 px-4 flex-shrink-0 bg-surface","data-name":"discard-dialog-answer-diagnostic"},i?/* @__PURE__ */e.createElement("div",{className:"flex items-center justify-center h-full"},/* @__PURE__ */e.createElement(g,null)):/* @__PURE__ */e.createElement(e.Fragment,null,n&&/* @__PURE__ */e.createElement(e.Fragment,null,/* @__PURE__ */e.createElement("dl",{className:"grid grid-cols-[1fr_2fr] grid-rows-2 gap-5"},/* @__PURE__ */e.createElement("div",{className:"flex flex-col gap-1"},/* @__PURE__ */e.createElement("dt",{className:"heading-xs"},"Confidence"),/* @__PURE__ */e.createElement("dd",{className:"text-sm"},n.confidence_score)),n.answer_generation_type&&/* @__PURE__ */e.createElement("div",{className:"flex flex-col gap-1"},/* @__PURE__ */e.createElement("dt",{className:"heading-xs"},"Answer Type"),/* @__PURE__ */e.createElement("dd",{className:"text-sm"},n.answer_generation_type)),n.query_context_relevance&&/* @__PURE__ */e.createElement("div",{className:"flex flex-col gap-1"},/* @__PURE__ */e.createElement("dt",{className:"heading-xs"},"Relevance"),/* @__PURE__ */e.createElement("dd",{className:"text-sm"},n.query_context_relevance)),n.context_sufficiency&&/* @__PURE__ */e.createElement("div",{className:"flex flex-col gap-1"},/* @__PURE__ */e.createElement("dt",{className:"heading-xs"},"Context"),/* @__PURE__ */e.createElement("dd",{className:"text-sm"},n.context_sufficiency))),n.confidence_justification&&/* @__PURE__ */e.createElement("div",{className:"flex flex-col gap-2","data-name":"diagnostic-justification"},/* @__PURE__ */e.createElement("span",{className:"heading-xs"},"Justification"),/* @__PURE__ */e.createElement("p",{className:"text-sm my-0"},n.confidence_justification)),n.evidence_from_context&&n.evidence_from_context.length>0&&/* @__PURE__ */e.createElement("div",{className:"flex flex-col gap-2","data-name":"diagnostic-evidence"},/* @__PURE__ */e.createElement("span",{className:"heading-xs"},"Evidence (from Knowledge Base)"),n.evidence_from_context.map((t,a)=>/* @__PURE__ */e.createElement("div",{key:a,className:"flex flex-col gap-1"},t.supporting_quote&&/* @__PURE__ */e.createElement("p",{className:"text-sm my-0"},t.supporting_quote),t.url&&/* @__PURE__ */e.createElement(E,{variant:"link",size:"sm",className:"flex gap-1 text-sm self-end items-center",asChild:!0},/* @__PURE__ */e.createElement("a",{href:t.url,target:"_blank",rel:"noopener noreferrer"},/* @__PURE__ */e.createElement("span",null,"Source"),/* @__PURE__ */e.createElement(l,{size:16})))))))))}var le=/* @__PURE__ */(e=>(e.INCORRECT_ANSWER="incorrect_answer",e.HALLUCINATED_ANSWER="hallucinated_answer",e.OVERSHARING="oversharing",e.WRONG_ARTICLE_SURFACED="wrong_article_surfaced",e.OTHER="other",e))(le||{});const ce={incorrect_answer:"Incorrect answer",hallucinated_answer:"Hallucinated answer",oversharing:"Oversharing",wrong_article_surfaced:"Wrong article surfaced",other:"Other"};function ie({discarded:r,discardedMeta:n,onSubmit:l,onApprove:m,selectOpenRef:o,className:d}){const[u,p]=t(r??!1),[f,g]=t(!1),[O,S]=t(r),D=s(null);a(()=>{S(r),r&&p(!0)},[r]);const F=e=>{g(e),o&&(o.current.isOpen=e)};a(()=>{o&&(o.current.close=()=>F(!1))},[o]);const{control:R,register:M,handleSubmit:I,reset:q,formState:{isSubmitting:P}}=h({defaultValues:{reason:n?.reason,preferredAnswer:n?.suggestedAnswer||""}});a(()=>{q({reason:n?.reason,preferredAnswer:n?.suggestedAnswer||""})},[n,q]),a(()=>{D.current&&(D.current.inert=!u)},[u]);const T=null!=O,W=!T||!1===O,B=!T||!0===O;/* @__PURE__ */
2
- return e.createElement("div",{className:z("space-y-4",d)},/* @__PURE__ */e.createElement("div",{className:"flex gap-2 px-4"},W&&/* @__PURE__ */e.createElement(C,null,/* @__PURE__ */e.createElement(A,{asChild:!0},/* @__PURE__ */e.createElement(E,{variant:"surface",elevation:"shadow",size:"sm",className:z("text-default !opacity-100",{"bg-green-600 text-dark-100":!1===O}),disabled:T,onClick:async()=>{try{await m(),S(!1),p(!1),F(!1)}catch(e){console.error("Failed to approve:",e)}}},
3
- /* @__PURE__ */e.createElement(c,null)," ",!1===O?"Approved":"Approve")),/* @__PURE__ */e.createElement(_,null,/* @__PURE__ */e.createElement("span",null,"Approve the answer"))),B&&/* @__PURE__ */e.createElement(C,null,/* @__PURE__ */e.createElement(A,{asChild:!0},/* @__PURE__ */e.createElement(E,{variant:"surface",elevation:"shadow",size:"sm",className:z("text-default !opacity-100",{"bg-red-600 text-dark-100":!0===O}),disabled:T,onClick:()=>p(!u)},
1
+ import e,{useState as t,useEffect as a,useRef as s,useMemo as r}from"react";import{S as n}from"../chunks/status-badge.BVWcC9Dt.js";import{ArrowSquareOut as l,CheckCircle as c,XCircle as i,ListMagnifyingGlass as m,UserCircle as o,Eye as d,UserFocus as u,Circle as p}from"@phosphor-icons/react";import{F as f}from"../chunks/FormattedMessage.CEEjawib.js";import{Spinner as g}from"./ui/spinner.js";import{B as E}from"../chunks/button.C7qRaFMP.js";import{useForm as h,Controller as N}from"react-hook-form";import{Select as v,SelectTrigger as x,SelectValue as b,SelectContent as w,SelectItem as k}from"./ui/select.js";import{Label as y}from"./ui/label.js";import{Textarea as j}from"./ui/textarea.js";import{Tooltip as C,TooltipTrigger as A,TooltipContent as _}from"./ui/tooltip.js";import{c as z}from"../chunks/utils.DtKoarLP.js";import{DivButton as O}from"./ui/div-button.js";import{ScrollArea as S}from"./ui/scroll-area.js";import{Sheet as D,SheetTrigger as F,SheetContent as R,SheetHeader as M,SheetTitle as I,SheetDescription as q}from"./ui/sheet.js";import{Badge as P}from"./ui/badge.js";import{A as U}from"../chunks/ai-logo.Bh2bhNcG.js";import{Item as T,ItemHeader as W,ItemTitle as B,ItemContent as L,ItemDescription as H}from"./ui/item.js";import{Accordion as K,AccordionItem as G,AccordionTrigger as Z,AccordionContent as $}from"./ui/accordion.js";import{c as V,b as J}from"../chunks/formatDate.D2xEZm8f.js";import{createId as Q}from"@paralleldrive/cuid2";import{Table as X,TableHeader as Y,TableRow as ee,TableHead as te,TableBody as ae,TableCell as se}from"./ui/table.js";import '../global.css';import '../convos.css';/* empty css */import"@radix-ui/react-accordion";import"clsx";import"tailwind-merge";import"./ui/alert-dialog.js";import"./ui/alert.js";import"@radix-ui/react-avatar";import"./ui/button-group.js";import"./ui/calendar.js";import"./ui/card.js";import"@radix-ui/react-collapsible";import"./ui/command.js";import"./ui/dialog.js";import"./ui/dropdown-menu.js";import"./ui/icon.js";import"./ui/input.js";import"./ui/popover.js";import"./ui/progress.js";import"./ui/radio-group.js";import"react-resizable-panels";import"./ui/separator.js";import"./ui/switch.js";import"./ui/tabs.js";import"../logos/microsoft-teams-logo.js";import"../logos/slack-logo.js";import"../logos/microsoft-logo.js";import{d as re}from"../chunks/dark.DuW7JuAk.js";import{G as ne}from"../chunks/generating-star.DN8DVygp.js";function le({messageId:s}){const{fetchAnswerDiagnostics:r}=ze(),[n,c]=t(null),[i,m]=t(!0);return a(()=>{r(s).then(e=>c(e)).finally(()=>m(!1))},[r,s]),/* @__PURE__ */e.createElement("div",{className:"flex flex-col gap-4 px-4 flex-shrink-0 bg-surface","data-name":"discard-dialog-answer-diagnostic"},i?/* @__PURE__ */e.createElement("div",{className:"flex items-center justify-center h-full"},/* @__PURE__ */e.createElement(g,null)):/* @__PURE__ */e.createElement(e.Fragment,null,n&&/* @__PURE__ */e.createElement(e.Fragment,null,/* @__PURE__ */e.createElement("dl",{className:"grid grid-cols-[1fr_2fr] grid-rows-2 gap-5"},/* @__PURE__ */e.createElement("div",{className:"flex flex-col gap-1"},/* @__PURE__ */e.createElement("dt",{className:"heading-xs"},"Confidence"),/* @__PURE__ */e.createElement("dd",{className:"text-sm"},n.confidence_score)),n.answer_generation_type&&/* @__PURE__ */e.createElement("div",{className:"flex flex-col gap-1"},/* @__PURE__ */e.createElement("dt",{className:"heading-xs"},"Answer Type"),/* @__PURE__ */e.createElement("dd",{className:"text-sm"},n.answer_generation_type)),n.query_context_relevance&&/* @__PURE__ */e.createElement("div",{className:"flex flex-col gap-1"},/* @__PURE__ */e.createElement("dt",{className:"heading-xs"},"Relevance"),/* @__PURE__ */e.createElement("dd",{className:"text-sm"},n.query_context_relevance)),n.context_sufficiency&&/* @__PURE__ */e.createElement("div",{className:"flex flex-col gap-1"},/* @__PURE__ */e.createElement("dt",{className:"heading-xs"},"Context"),/* @__PURE__ */e.createElement("dd",{className:"text-sm"},n.context_sufficiency))),n.confidence_justification&&/* @__PURE__ */e.createElement("div",{className:"flex flex-col gap-2","data-name":"diagnostic-justification"},/* @__PURE__ */e.createElement("span",{className:"heading-xs"},"Justification"),/* @__PURE__ */e.createElement("p",{className:"text-sm my-0"},n.confidence_justification)),n.evidence_from_context&&n.evidence_from_context.length>0&&/* @__PURE__ */e.createElement("div",{className:"flex flex-col gap-2","data-name":"diagnostic-evidence"},/* @__PURE__ */e.createElement("span",{className:"heading-xs"},"Evidence (from Knowledge Base)"),n.evidence_from_context.map((t,a)=>/* @__PURE__ */e.createElement("div",{key:a,className:"flex flex-col gap-1"},t.supporting_quote&&/* @__PURE__ */e.createElement("p",{className:"text-sm my-0"},t.supporting_quote),t.url&&/* @__PURE__ */e.createElement(E,{variant:"link",size:"sm",className:"flex gap-1 text-sm self-end items-center",asChild:!0},/* @__PURE__ */e.createElement("a",{href:t.url,target:"_blank",rel:"noopener noreferrer"},/* @__PURE__ */e.createElement("span",null,"Source"),/* @__PURE__ */e.createElement(l,{size:16})))))))))}var ce=/* @__PURE__ */(e=>(e.INCORRECT_ANSWER="incorrect_answer",e.HALLUCINATED_ANSWER="hallucinated_answer",e.OVERSHARING="oversharing",e.WRONG_ARTICLE_SURFACED="wrong_article_surfaced",e.OTHER="other",e))(ce||{});const ie={incorrect_answer:"Incorrect answer",hallucinated_answer:"Hallucinated answer",oversharing:"Oversharing",wrong_article_surfaced:"Wrong article surfaced",other:"Other"};function me({discarded:r,discardedMeta:n,onSubmit:l,onApprove:m,selectOpenRef:o,className:d}){const[u,p]=t(r??!1),[f,g]=t(!1),[O,S]=t(r),D=s(null);a(()=>{S(r),r&&p(!0)},[r]);const F=e=>{g(e),o&&(o.current.isOpen=e)};a(()=>{o&&(o.current.close=()=>F(!1))},[o]);const{control:R,register:M,handleSubmit:I,reset:q,formState:{isSubmitting:P}}=h({defaultValues:{reason:n?.reason,preferredAnswer:n?.suggestedAnswer||""}});a(()=>{q({reason:n?.reason,preferredAnswer:n?.suggestedAnswer||""})},[n,q]),a(()=>{D.current&&(D.current.inert=!u)},[u]);const U=null!=O,T=!U||!1===O,W=!U||!0===O;/* @__PURE__ */
2
+ return e.createElement("div",{className:z("space-y-4",d)},/* @__PURE__ */e.createElement("div",{className:"flex gap-2 px-4"},T&&/* @__PURE__ */e.createElement(C,null,/* @__PURE__ */e.createElement(A,{asChild:!0},/* @__PURE__ */e.createElement(E,{variant:"surface",elevation:"shadow",size:"sm",className:z("text-default !opacity-100",{"bg-green-600 text-dark-100":!1===O}),disabled:U,onClick:async()=>{try{await m(),S(!1),p(!1),F(!1)}catch(e){console.error("Failed to approve:",e)}}},
3
+ /* @__PURE__ */e.createElement(c,null)," ",!1===O?"Approved":"Approve")),/* @__PURE__ */e.createElement(_,null,/* @__PURE__ */e.createElement("span",null,"Approve the answer"))),W&&/* @__PURE__ */e.createElement(C,null,/* @__PURE__ */e.createElement(A,{asChild:!0},/* @__PURE__ */e.createElement(E,{variant:"surface",elevation:"shadow",size:"sm",className:z("text-default !opacity-100",{"bg-red-600 text-dark-100":!0===O}),disabled:U,onClick:()=>p(!u)},
4
4
  /* @__PURE__ */e.createElement(i,null),!0===O?"Discarded":"Discard")),/* @__PURE__ */e.createElement(_,null,/* @__PURE__ */e.createElement("span",null,"Discard the answer")))),/* @__PURE__ */e.createElement("div",{className:z("grid transition-[grid-template-rows] duration-300 ease-in-out",u?"grid-rows-[1fr]":"grid-rows-[0fr]")},O?/* @__PURE__ */e.createElement("div",{className:z("overflow-hidden min-h-0 px-4 bg-dark-200 space-y-4",u?"py-4 mb-4":"py-0"),"data-name":"discard-dialog-reason"},
5
- /* @__PURE__ */e.createElement("div",{className:"space-y-1"},/* @__PURE__ */e.createElement(k,{htmlFor:"reason",className:"text-sm"},"Reason"),/* @__PURE__ */e.createElement("span",{className:"text-sm block"},n?.reason&&ce[n.reason])),
6
- /* @__PURE__ */e.createElement("div",{className:"space-y-1"},/* @__PURE__ */e.createElement(k,{htmlFor:"preferredAnswer",className:"text-sm"},"Preferred answer"),/* @__PURE__ */e.createElement("span",{className:"text-sm block"},n?.suggestedAnswer))):/* @__PURE__ */e.createElement("form",{ref:D,onSubmit:I(async e=>{try{await l(e),S(!0),F(!1)}catch(t){console.error("Failed to discard:",t)}}),className:z("overflow-hidden min-h-0 px-4 bg-dark-200 transition-all duration-300 ease-in-out",u?"py-4 mb-4":"py-0")},
7
- /* @__PURE__ */e.createElement("fieldset",{className:"space-y-4","data-name":"discard-dialog-reason"},/* @__PURE__ */e.createElement("div",{className:"space-y-1"},/* @__PURE__ */e.createElement(k,{htmlFor:"reason",className:"heading-xs"},"Reason"),/* @__PURE__ */e.createElement(v,{control:R,name:"reason",rules:{required:!0},render:({field:t})=>/* @__PURE__ */e.createElement(N,{value:t.value,onValueChange:t.onChange,open:f,onOpenChange:F,required:!0},
5
+ /* @__PURE__ */e.createElement("div",{className:"space-y-1"},/* @__PURE__ */e.createElement(y,{htmlFor:"reason",className:"text-sm"},"Reason"),/* @__PURE__ */e.createElement("span",{className:"text-sm block"},n?.reason&&ie[n.reason])),
6
+ /* @__PURE__ */e.createElement("div",{className:"space-y-1"},/* @__PURE__ */e.createElement(y,{htmlFor:"preferredAnswer",className:"text-sm"},"Preferred answer"),/* @__PURE__ */e.createElement("span",{className:"text-sm block"},n?.suggestedAnswer))):/* @__PURE__ */e.createElement("form",{ref:D,onSubmit:I(async e=>{try{await l(e),S(!0),F(!1)}catch(t){console.error("Failed to discard:",t)}}),className:z("overflow-hidden min-h-0 px-4 bg-dark-200 transition-all duration-300 ease-in-out",u?"py-4 mb-4":"py-0")},
7
+ /* @__PURE__ */e.createElement("fieldset",{className:"space-y-4","data-name":"discard-dialog-reason"},/* @__PURE__ */e.createElement("div",{className:"space-y-1"},/* @__PURE__ */e.createElement(y,{htmlFor:"reason",className:"heading-xs"},"Reason"),/* @__PURE__ */e.createElement(N,{control:R,name:"reason",rules:{required:!0},render:({field:t})=>/* @__PURE__ */e.createElement(v,{value:t.value,onValueChange:t.onChange,open:f,onOpenChange:F,required:!0},
8
8
  /* @__PURE__ */e.createElement(x,{className:"border-dark-300 bg-surface"},/* @__PURE__ */e.createElement(b,{placeholder:"Select a reason"})),
9
- /* @__PURE__ */e.createElement(w,null,Object.values(le).map(t=>/* @__PURE__ */e.createElement(y,{key:t,value:t},ce[t]))))}),/* @__PURE__ */e.createElement("span",{className:"text-xs text-subtle ml-1 hidden"},"Give your ambient agent a descriptive name that reflects its purpose. This agent will learn from your content to provide personalized assistance.")),/* @__PURE__ */e.createElement("div",{className:"space-y-1"},/* @__PURE__ */e.createElement(k,{htmlFor:"preferredAnswer",className:"heading-xs"},"Preferred answer"),/* @__PURE__ */e.createElement(j,{id:"preferredAnswer",required:!0,minLength:10,placeholder:"Explain what you'd like Brainfish to do next time in this case....",rows:4,className:"h-52 resize-none bg-surface",...M("preferredAnswer")}),/* @__PURE__ */e.createElement("span",{className:"text-xs text-subtle ml-1 hidden"},"Tell Brainfish why this is the incorrect answer.")),/* @__PURE__ */e.createElement("div",{className:"flex gap-2 !mb-1 justify-end mr-1"},/* @__PURE__ */e.createElement(E,{variant:"link",size:"sm",type:"button",onClick:()=>{p(!1),F(!1),q()}},"Cancel"),/* @__PURE__ */e.createElement(E,{type:"submit",variant:"default",elevation:"shadow",size:"sm",disabled:P},P?"Submitting...":"Submit"))))))}function me({id:a,discarded:r,discardedMeta:n,open:l,onOpenChange:c,...i}){const{onDiscard:o,onApprove:d}=Ae(),[u,p]=t(!1),f=s({isOpen:!1,close:()=>{}}),g=l??u,E=c??p;/* @__PURE__ */
9
+ /* @__PURE__ */e.createElement(w,null,Object.values(ce).map(t=>/* @__PURE__ */e.createElement(k,{key:t,value:t},ie[t]))))}),/* @__PURE__ */e.createElement("span",{className:"text-xs text-subtle ml-1 hidden"},"Give your ambient agent a descriptive name that reflects its purpose. This agent will learn from your content to provide personalized assistance.")),/* @__PURE__ */e.createElement("div",{className:"space-y-1"},/* @__PURE__ */e.createElement(y,{htmlFor:"preferredAnswer",className:"heading-xs"},"Preferred answer"),/* @__PURE__ */e.createElement(j,{id:"preferredAnswer",required:!0,minLength:10,placeholder:"Explain what you'd like Brainfish to do next time in this case....",rows:4,className:"h-52 resize-none bg-surface",...M("preferredAnswer")}),/* @__PURE__ */e.createElement("span",{className:"text-xs text-subtle ml-1 hidden"},"Tell Brainfish why this is the incorrect answer.")),/* @__PURE__ */e.createElement("div",{className:"flex gap-2 !mb-1 justify-end mr-1"},/* @__PURE__ */e.createElement(E,{variant:"link",size:"sm",type:"button",onClick:()=>{p(!1),F(!1),q()}},"Cancel"),/* @__PURE__ */e.createElement(E,{type:"submit",variant:"default",elevation:"shadow",size:"sm",disabled:P},P?"Submitting...":"Submit"))))))}function oe({id:a,discarded:r,discardedMeta:n,open:l,onOpenChange:c,...i}){const{onDiscard:o,onApprove:d}=ze(),[u,p]=t(!1),f=s({isOpen:!1,close:()=>{}}),g=l??u,E=c??p;/* @__PURE__ */
10
10
  return e.createElement(D,{modal:!1,open:g,onOpenChange:E,...i},/* @__PURE__ */e.createElement(F,{asChild:!0,onClick:e=>e.stopPropagation(),onKeyUp:e=>e.stopPropagation()},/* @__PURE__ */e.createElement(O,{variant:"shadowSurface",size:"sm","aria-label":"Inspect answer information"},/* @__PURE__ */e.createElement(m,{className:"text-dark-600"})," Inspect")),/* @__PURE__ */e.createElement(R,{className:"space-y-4 px-0",onEscapeKeyDown:e=>{f.current.isOpen&&(e.preventDefault(),f.current.close())},onInteractOutside:e=>{f.current.isOpen&&e.preventDefault()}},
11
11
  /* @__PURE__ */e.createElement(M,{className:"px-4"},/* @__PURE__ */e.createElement(I,{className:"heading-sm m-0"},"Answer information"),/* @__PURE__ */e.createElement(q,{className:"sr-only"},"Shows answer diagnostics and allows you to provide feedback.")),
12
- /* @__PURE__ */e.createElement(S,{className:"h-[calc(100vh-4rem)] pb-4"},/* @__PURE__ */e.createElement(ie,{discarded:r,discardedMeta:n,onSubmit:async e=>{await o(a,e.reason,e.preferredAnswer).then(()=>E(!1))},onApprove:async()=>{await d(a)},selectOpenRef:f}),/* @__PURE__ */e.createElement(ne,{messageId:a}))))}const oe=({score:t})=>{const a=`${t}%`;return!t||t>100?/* @__PURE__ */e.createElement(P,{variant:"disabled"},"N/A"):t>=80?/* @__PURE__ */e.createElement(P,{variant:"success"},a):t>=40&&t<80?/* @__PURE__ */e.createElement(P,{variant:"warning"},a):/* @__PURE__ */e.createElement(P,{variant:"disabled"},"N/A")},de=/(```[\s\S]*?```|`[^`\n]+`|<(?:[a-zA-Z][a-zA-Z0-9+.-]*:|www\.)[^\s>]+>)/g,ue=/^<(?:[a-zA-Z][a-zA-Z0-9+.-]*:|www\.)[^\s>]+>$/;function pe(e){return e.split(de).map(e=>function(e){return e.startsWith("```")||e.startsWith("`")&&e.endsWith("`")||ue.test(e)}(e)?e:e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")).join("")}var fe=/* @__PURE__ */(e=>(e.ACTION="action",e.FEEDBACK="feedback",e.QUESTION="question",e.ANSWER="answer",e))(fe||{}),ge=/* @__PURE__ */(e=>(e.Positive="positive",e.Negative="negative",e))(ge||{});const Ee=e=>"answer"===e.type,he=e=>"question"===e.type,ve=e=>"feedback"===e.type,Ne=e=>"action"===e.type;function xe({attachments:t}){/* @__PURE__ */
13
- return e.createElement("div",{className:"flex gap-2 flex-wrap"},t.filter(e=>"image"===e.type).map((t,a)=>/* @__PURE__ */e.createElement("div",{key:a,className:"relative bg-dark-300 p-1 rounded shrink-0"},/* @__PURE__ */e.createElement("a",{href:t.url,target:"_blank",rel:"noopener noreferrer"},/* @__PURE__ */e.createElement("img",{src:t.url,alt:"",className:"size-14 object-cover rounded"})),/* @__PURE__ */e.createElement("div",{className:"absolute top-1.5 right-1.5 bg-dark-300 rounded-full p-0.5"},/* @__PURE__ */e.createElement(d,{size:8})))))}function be(t){const{id:a,content:s,timestamp:c,locale:i,isFeedbackDialogOpen:m,onFeedbackDialogChange:d}=t,u=r(()=>pe(s),[s]),{locale:p}=Ae(),g=$(c,i||p);if(Ee(t)){const{relatedArticles:s,discarded:r,discardedMeta:n,confidenceScore:c}=t;/* @__PURE__ */
14
- return e.createElement("li",{className:"relative before-line after-line list-none [&_a]:break-all"},/* @__PURE__ */e.createElement(W,{className:"message-item"},/* @__PURE__ */e.createElement(B,{className:"justify-start gap-0"},/* @__PURE__ */e.createElement(T,{variant:"gradient",className:"relative -left-[6px]"}),/* @__PURE__ */e.createElement(L,{className:"text-xs font-bold"},"Generated answer "+(r?"(Discarded)":""))),/* @__PURE__ */e.createElement(U,{className:z("message-ai-content",{"py-6":!s?.length,"pt-6 pb-0":s?.length})},
15
- /* @__PURE__ */e.createElement("div",{className:"message-content-wrapper"},/* @__PURE__ */e.createElement(f,{message:{content:u}}),/* @__PURE__ */e.createElement("div",{className:"flex gap-2 justify-between mt-2 items-center"},/* @__PURE__ */e.createElement("span",{className:"message-timestamp"},g),/* @__PURE__ */e.createElement("div",{className:"flex items-center gap-2"},c&&/* @__PURE__ */e.createElement(C,null,/* @__PURE__ */e.createElement(A,{asChild:!0},/* @__PURE__ */e.createElement(O,{variant:"outline",size:"sm",className:"text-xs p-1 h-auto"},c)),/* @__PURE__ */e.createElement(_,null,/* @__PURE__ */e.createElement("p",null,"Answer score: ",c))),/* @__PURE__ */e.createElement(me,{id:a,discarded:r,discardedMeta:n,open:m,onOpenChange:d})))),!!s?.length&&/* @__PURE__ */e.createElement(K,{type:"single",collapsible:!0,className:"p-0 custom-dashed-border-t-dark-300 w-full"},/* @__PURE__ */e.createElement(H,{value:"related-articles"},/* @__PURE__ */e.createElement(Z,{className:"px-6"},"Related articles"),/* @__PURE__ */e.createElement(V,null,/* @__PURE__ */e.createElement("ul",{className:"message-article-list"},s.map(t=>/* @__PURE__ */e.createElement("li",{key:t.id,className:"grid gap-2 grid-cols-[auto_1fr] items-center justify-items-start"},
16
- /* @__PURE__ */e.createElement(oe,{score:Math.round(100*t.score)}),
12
+ /* @__PURE__ */e.createElement(S,{className:"h-[calc(100vh-4rem)] pb-4"},/* @__PURE__ */e.createElement(me,{discarded:r,discardedMeta:n,onSubmit:async e=>{await o(a,e.reason,e.preferredAnswer).then(()=>E(!1))},onApprove:async()=>{await d(a)},selectOpenRef:f}),/* @__PURE__ */e.createElement(le,{messageId:a}))))}const de=({score:t})=>{const a=`${t}%`;return!t||t>100?/* @__PURE__ */e.createElement(P,{variant:"disabled"},"N/A"):t>=80?/* @__PURE__ */e.createElement(P,{variant:"success"},a):t>=40&&t<80?/* @__PURE__ */e.createElement(P,{variant:"warning"},a):/* @__PURE__ */e.createElement(P,{variant:"disabled"},"N/A")},ue=/(```[\s\S]*?```|`[^`\n]+`|<(?:[a-zA-Z][a-zA-Z0-9+.-]*:|www\.)[^\s>]+>)/g,pe=/^<(?:[a-zA-Z][a-zA-Z0-9+.-]*:|www\.)[^\s>]+>$/;function fe(e){return e.split(ue).map(e=>function(e){return e.startsWith("```")||e.startsWith("`")&&e.endsWith("`")||pe.test(e)}(e)?e:e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")).join("")}var ge=/* @__PURE__ */(e=>(e.ACTION="action",e.FEEDBACK="feedback",e.QUESTION="question",e.ANSWER="answer",e.HUMAN="human",e))(ge||{}),Ee=/* @__PURE__ */(e=>(e.Positive="positive",e.Negative="negative",e))(Ee||{});const he=e=>"answer"===e.type,Ne=e=>"question"===e.type,ve=e=>"feedback"===e.type,xe=e=>"action"===e.type,be=e=>"human"===e.type;function we({attachments:t}){/* @__PURE__ */
13
+ return e.createElement("div",{className:"flex gap-2 flex-wrap"},t.filter(e=>"image"===e.type).map((t,a)=>/* @__PURE__ */e.createElement("div",{key:a,className:"relative bg-dark-300 p-1 rounded shrink-0"},/* @__PURE__ */e.createElement("a",{href:t.url,target:"_blank",rel:"noopener noreferrer"},/* @__PURE__ */e.createElement("img",{src:t.url,alt:"",className:"size-14 object-cover rounded"})),/* @__PURE__ */e.createElement("div",{className:"absolute top-1.5 right-1.5 bg-dark-300 rounded-full p-0.5"},/* @__PURE__ */e.createElement(d,{size:8})))))}function ke(t){const{id:a,content:s,timestamp:c,locale:i,isFeedbackDialogOpen:m,onFeedbackDialogChange:d}=t,u=r(()=>fe(s),[s]),{locale:p}=ze(),g=V(c,i||p);if(he(t)){const{relatedArticles:s,discarded:r,discardedMeta:n,confidenceScore:c}=t;/* @__PURE__ */
14
+ return e.createElement("li",{className:"relative before-line after-line list-none [&_a]:break-all"},/* @__PURE__ */e.createElement(T,{className:"message-item"},/* @__PURE__ */e.createElement(W,{className:"justify-start gap-1.5"},/* @__PURE__ */e.createElement(U,{variant:"dark",width:16,height:16,className:"shrink-0"}),/* @__PURE__ */e.createElement(B,{className:"text-xs font-bold"},"AI generated "+(r?"(Discarded)":""))),/* @__PURE__ */e.createElement(L,{className:z("message-ai-content",{"py-6":!s?.length,"pt-6 pb-0":s?.length})},
15
+ /* @__PURE__ */e.createElement("div",{className:"message-content-wrapper"},/* @__PURE__ */e.createElement(f,{message:{content:u}}),/* @__PURE__ */e.createElement("div",{className:"flex gap-2 justify-between mt-2 items-center"},/* @__PURE__ */e.createElement("span",{className:"message-timestamp"},g),/* @__PURE__ */e.createElement("div",{className:"flex items-center gap-2"},c&&/* @__PURE__ */e.createElement(C,null,/* @__PURE__ */e.createElement(A,{asChild:!0},/* @__PURE__ */e.createElement(O,{variant:"outline",size:"sm",className:"text-xs p-1 h-auto"},c)),/* @__PURE__ */e.createElement(_,null,/* @__PURE__ */e.createElement("p",null,"Answer score: ",c))),/* @__PURE__ */e.createElement(oe,{id:a,discarded:r,discardedMeta:n,open:m,onOpenChange:d})))),!!s?.length&&/* @__PURE__ */e.createElement(K,{type:"single",collapsible:!0,className:"p-0 custom-dashed-border-t-dark-300 w-full"},/* @__PURE__ */e.createElement(G,{value:"related-articles"},/* @__PURE__ */e.createElement(Z,{className:"px-6"},"Related articles"),/* @__PURE__ */e.createElement($,null,/* @__PURE__ */e.createElement("ul",{className:"message-article-list"},s.map(t=>/* @__PURE__ */e.createElement("li",{key:t.id,className:"grid gap-2 grid-cols-[auto_1fr] items-center justify-items-start"},
16
+ /* @__PURE__ */e.createElement(de,{score:Math.round(100*t.score)}),
17
17
  /* @__PURE__ */e.createElement(E,{variant:"link",size:"xs",asChild:!0,className:"flex items-center gap-2 min-w-0 !justify-start w-full"},
18
- /* @__PURE__ */e.createElement("a",{href:t.url,target:"_blank",rel:"noopener noreferrer"},/* @__PURE__ */e.createElement("span",{className:"truncate"},t.title),/* @__PURE__ */e.createElement(l,{className:"size-4 flex-shrink-0",weight:"regular"}))))))))))))}const h=ve(t)?t.feedback:null;/* @__PURE__ */
19
- return e.createElement("li",{className:"relative list-none before-line--user after-line--user"},/* @__PURE__ */e.createElement(W,{className:"message-item"},/* @__PURE__ */e.createElement(B,{className:"basis-0"},/* @__PURE__ */e.createElement(o,{weight:"fill",size:24})),/* @__PURE__ */e.createElement(U,{className:"message-user-content"},he(t)&&/* @__PURE__ */e.createElement("div",{className:"flex flex-col gap-2"},t.attachments&&t.attachments.some(e=>"image"===e.type)&&/* @__PURE__ */e.createElement(xe,{attachments:t.attachments}),!t.onlyShowAttachments&&/* @__PURE__ */e.createElement(f,{message:{content:u}}),/* @__PURE__ */e.createElement("span",{className:"message-timestamp"},g)),ve(t)&&h&&/* @__PURE__ */e.createElement(e.Fragment,null,/* @__PURE__ */e.createElement("div",{className:"message-header"},/* @__PURE__ */e.createElement("div",{className:"message-feedback-text"},"positive"===h?"Upvoted as helpful":"Downvoted as not helpful"),/* @__PURE__ */e.createElement("div",{className:"message-meta"},/* @__PURE__ */e.createElement(n,{variant:"positive"===h?"success":"destructive"},"positive"===h?"Answered":"Unable to help"))),s&&/* @__PURE__ */e.createElement("div",{className:"text-base mb-1"},s),/* @__PURE__ */e.createElement("span",{className:"message-timestamp-simple"},g)),Ne(t)&&/* @__PURE__ */e.createElement("div",{className:"message-header"},/* @__PURE__ */e.createElement("div",{className:"flex flex-col gap-2"},/* @__PURE__ */e.createElement("span",{className:"text-subtle text-sm italic"},s),/* @__PURE__ */e.createElement("span",{className:"message-timestamp-simple"},g)),/* @__PURE__ */e.createElement("div",{className:"message-meta"},/* @__PURE__ */e.createElement(n,{variant:"warning"},"Action"))))))}function we({conversationId:s,open:r,onOpenChange:n,...l}){const[c,i]=t(),[m,o]=t(),{fetchAttributes:d}=Ae();return a(()=>{d(s).then(e=>{i(e),o(function(e){const t=["id","name","email","phone"];if(0===e.length)return[];const a=e=>{const a=t.indexOf(e);return-1===a?1/0:a};return Object.keys(e[0]).sort((e,t)=>a(e)-a(t))}(e))}).catch(()=>{})},[d,s]),c?.length?/* @__PURE__ */e.createElement(D,{modal:!1,open:r,onOpenChange:n,...l},/* @__PURE__ */e.createElement(C,null,/* @__PURE__ */e.createElement(A,{asChild:!0},/* @__PURE__ */e.createElement(F,{asChild:!0,onClick:e=>e.stopPropagation(),onKeyUp:e=>e.stopPropagation()},/* @__PURE__ */e.createElement(O,{variant:"ghost",size:"icon",className:"size-7 [&_svg]:size-6 text-dark-900","aria-label":"Open Custom attributes dialog"},
20
- /* @__PURE__ */e.createElement(u,{size:24})))),/* @__PURE__ */e.createElement(_,null,"Customer attributes")),/* @__PURE__ */e.createElement(R,{className:"space-y-4"},/* @__PURE__ */e.createElement(M,null,/* @__PURE__ */e.createElement(I,{className:"heading-sm m-0"},"Custom attributes"),/* @__PURE__ */e.createElement(q,{className:"sr-only"},"Custom attributes are used to store additional information about the conversation.")),m&&/* @__PURE__ */e.createElement(S,{className:"h-[calc(100vh-8rem)]"}," ",/* @__PURE__ */e.createElement(X,{className:"bg-surface","data-test-id":"attributes-table"},/* @__PURE__ */e.createElement(Y,null,/* @__PURE__ */e.createElement(ee,null,m.map(t=>/* @__PURE__ */e.createElement(te,{key:t,className:"capitalize font-bold"},t)))),/* @__PURE__ */e.createElement(ae,null,c.map(t=>/* @__PURE__ */e.createElement(ee,{key:t?.id??Q(),className:"border-none"},m.map(a=>/* @__PURE__ */e.createElement(se,{key:a,"data-title":a},"boolean"==typeof t[a]?String(t[a]):t[a]))))))))):null}const ye=e.forwardRef(({className:t,streamName:a,dotColor:s="transparent",...r},n)=>/* @__PURE__ */e.createElement(C,null,/* @__PURE__ */e.createElement(A,{asChild:!0},/* @__PURE__ */e.createElement("div",{ref:n,role:"button",className:z("flex items-center gap-1 rounded-full p-0",t),tabIndex:0},
21
- /* @__PURE__ */e.createElement(P,{...r,className:"bg-surface rounded-full border border-dark-300 text-subtle"},/* @__PURE__ */e.createElement("span",{className:"flex items-center gap-1"},/* @__PURE__ */e.createElement(p,{size:8,weight:"bold",className:"!size-2 rounded-full",style:{backgroundColor:s},color:"transparent"===s?re[300]:"transparent"}),/* @__PURE__ */e.createElement("span",{className:"max-w-32 truncate inline-block"},a))))),/* @__PURE__ */e.createElement(_,null,a)));ye.displayName="StreamBadge";const ke=({score:t,status:a,statusMessage:s})=>t?/* @__PURE__ */e.createElement(C,null,/* @__PURE__ */e.createElement(A,{asChild:!0},/* @__PURE__ */e.createElement(O,{variant:"ghost",size:"sm",className:"p-0 h-[26px]"},/* @__PURE__ */e.createElement(n,{variant:a,suffix:t},s))),/* @__PURE__ */e.createElement(_,null,/* @__PURE__ */e.createElement("p",null,"Conversation score: ",t))):/* @__PURE__ */e.createElement(n,{variant:a,suffix:t},s);function je({locale:a,value:s,question:r,timestamp:n,location:l,source:c,status:i,statusMessage:m,hasAttributes:o,onClick:d,className:u,score:p,...f}){const{getMessages:g,isLoading:E,locale:h}=Ae(),[v,N]=t(null),[x,b]=t(null),w=(e,t)=>a=>{a?(N(e),t&&b(t)):(N(null),b(null))},y=null!==v,k=a||h,j=g(s),C=E(s),A=[J(n,k),l].filter(Boolean).join(" • ");/* @__PURE__ */
22
- return e.createElement(H,{value:s,className:z('border border-dark-200 hover:border-dark-300 rounded-lg bg-dark-100 [&[data-state="open"]]:bg-surface [&[data-state="open"]]:border-dark-100',{"shadow-md shadow-dark-300":y},u),...f},
18
+ /* @__PURE__ */e.createElement("a",{href:t.url,target:"_blank",rel:"noopener noreferrer"},/* @__PURE__ */e.createElement("span",{className:"truncate"},t.title),/* @__PURE__ */e.createElement(l,{className:"size-4 flex-shrink-0",weight:"regular"}))))))))))))}if(be(t)){const{authorName:a,authorAvatarUrl:s,source:r}=t,n=function(e,t){const a=e?.trim()||"Support";return t?.trim()?`${a} (via ${t.charAt(0).toUpperCase()+t.slice(1)})`:a}(a,r);/* @__PURE__ */
19
+ return e.createElement("li",{className:"relative before-line after-line list-none [&_a]:break-all"},/* @__PURE__ */e.createElement(T,{className:"message-item"},/* @__PURE__ */e.createElement(W,{className:"justify-start gap-2"},s?/* @__PURE__ */e.createElement("img",{src:s,alt:"",className:"size-6 shrink-0 rounded-full object-cover"}):/* @__PURE__ */e.createElement(o,{weight:"fill",size:24,className:"shrink-0"}),/* @__PURE__ */e.createElement(B,{className:"text-xs font-bold"},n)),/* @__PURE__ */e.createElement(L,{className:"message-ai-content py-6"},/* @__PURE__ */e.createElement("div",{className:"message-content-wrapper"},/* @__PURE__ */e.createElement(f,{message:{content:u}}),/* @__PURE__ */e.createElement("span",{className:"message-timestamp"},g)))))}const h=ve(t)?t.feedback:null;/* @__PURE__ */
20
+ return e.createElement("li",{className:"relative list-none before-line--user after-line--user"},/* @__PURE__ */e.createElement(T,{className:"message-item"},/* @__PURE__ */e.createElement(W,{className:"basis-0"},/* @__PURE__ */e.createElement(o,{weight:"fill",size:24})),/* @__PURE__ */e.createElement(L,{className:"message-user-content"},Ne(t)&&/* @__PURE__ */e.createElement("div",{className:"flex flex-col gap-2"},t.attachments&&t.attachments.some(e=>"image"===e.type)&&/* @__PURE__ */e.createElement(we,{attachments:t.attachments}),!t.onlyShowAttachments&&/* @__PURE__ */e.createElement(f,{message:{content:u}}),/* @__PURE__ */e.createElement("span",{className:"message-timestamp"},g)),ve(t)&&h&&/* @__PURE__ */e.createElement(e.Fragment,null,/* @__PURE__ */e.createElement("div",{className:"message-header"},/* @__PURE__ */e.createElement("div",{className:"message-feedback-text"},"positive"===h?"Upvoted as helpful":"Downvoted as not helpful"),/* @__PURE__ */e.createElement("div",{className:"message-meta"},/* @__PURE__ */e.createElement(n,{variant:"positive"===h?"success":"destructive"},"positive"===h?"Answered":"Unable to help"))),s&&/* @__PURE__ */e.createElement("div",{className:"text-base mb-1"},s),/* @__PURE__ */e.createElement("span",{className:"message-timestamp-simple"},g)),xe(t)&&/* @__PURE__ */e.createElement("div",{className:"message-header"},/* @__PURE__ */e.createElement("div",{className:"flex flex-col gap-2"},/* @__PURE__ */e.createElement("span",{className:"text-subtle text-sm italic"},s),/* @__PURE__ */e.createElement("span",{className:"message-timestamp-simple"},g)),/* @__PURE__ */e.createElement("div",{className:"message-meta"},/* @__PURE__ */e.createElement(n,{variant:"warning"},"Action"))))))}function ye({conversationId:s,open:r,onOpenChange:n,...l}){const[c,i]=t(),[m,o]=t(),{fetchAttributes:d}=ze();return a(()=>{d(s).then(e=>{i(e),o(function(e){const t=["id","name","email","phone"];if(0===e.length)return[];const a=e=>{const a=t.indexOf(e);return-1===a?1/0:a};return Object.keys(e[0]).sort((e,t)=>a(e)-a(t))}(e))}).catch(()=>{})},[d,s]),c?.length?/* @__PURE__ */e.createElement(D,{modal:!1,open:r,onOpenChange:n,...l},/* @__PURE__ */e.createElement(C,null,/* @__PURE__ */e.createElement(A,{asChild:!0},/* @__PURE__ */e.createElement(F,{asChild:!0,onClick:e=>e.stopPropagation(),onKeyUp:e=>e.stopPropagation()},/* @__PURE__ */e.createElement(O,{variant:"ghost",size:"icon",className:"size-7 [&_svg]:size-6 text-dark-900","aria-label":"Open Custom attributes dialog"},
21
+ /* @__PURE__ */e.createElement(u,{size:24})))),/* @__PURE__ */e.createElement(_,null,"Customer attributes")),/* @__PURE__ */e.createElement(R,{className:"space-y-4"},/* @__PURE__ */e.createElement(M,null,/* @__PURE__ */e.createElement(I,{className:"heading-sm m-0"},"Custom attributes"),/* @__PURE__ */e.createElement(q,{className:"sr-only"},"Custom attributes are used to store additional information about the conversation.")),m&&/* @__PURE__ */e.createElement(S,{className:"h-[calc(100vh-8rem)]"}," ",/* @__PURE__ */e.createElement(X,{className:"bg-surface","data-test-id":"attributes-table"},/* @__PURE__ */e.createElement(Y,null,/* @__PURE__ */e.createElement(ee,null,m.map(t=>/* @__PURE__ */e.createElement(te,{key:t,className:"capitalize font-bold"},t)))),/* @__PURE__ */e.createElement(ae,null,c.map(t=>/* @__PURE__ */e.createElement(ee,{key:t?.id??Q(),className:"border-none"},m.map(a=>/* @__PURE__ */e.createElement(se,{key:a,"data-title":a},"boolean"==typeof t[a]?String(t[a]):t[a]))))))))):null}const je=e.forwardRef(({className:t,streamName:a,dotColor:s="transparent",...r},n)=>/* @__PURE__ */e.createElement(C,null,/* @__PURE__ */e.createElement(A,{asChild:!0},/* @__PURE__ */e.createElement("div",{ref:n,role:"button",className:z("flex items-center gap-1 rounded-full p-0",t),tabIndex:0},
22
+ /* @__PURE__ */e.createElement(P,{...r,className:"bg-surface rounded-full border border-dark-300 text-subtle"},/* @__PURE__ */e.createElement("span",{className:"flex items-center gap-1"},/* @__PURE__ */e.createElement(p,{size:8,weight:"bold",className:"!size-2 rounded-full",style:{backgroundColor:s},color:"transparent"===s?re[300]:"transparent"}),/* @__PURE__ */e.createElement("span",{className:"max-w-32 truncate inline-block"},a))))),/* @__PURE__ */e.createElement(_,null,a)));je.displayName="StreamBadge";const Ce=({score:t,status:a,statusMessage:s})=>t?/* @__PURE__ */e.createElement(C,null,/* @__PURE__ */e.createElement(A,{asChild:!0},/* @__PURE__ */e.createElement(O,{variant:"ghost",size:"sm",className:"p-0 h-[26px]"},/* @__PURE__ */e.createElement(n,{variant:a,suffix:t},s))),/* @__PURE__ */e.createElement(_,null,/* @__PURE__ */e.createElement("p",null,"Conversation score: ",t))):/* @__PURE__ */e.createElement(n,{variant:a,suffix:t},s);function Ae({locale:a,value:s,question:r,timestamp:n,location:l,source:c,status:i,statusMessage:m,hasAttributes:o,onClick:d,className:u,score:p,...f}){const{getMessages:g,isLoading:E,locale:h}=ze(),[N,v]=t(null),[x,b]=t(null),w=(e,t)=>a=>{a?(v(e),t&&b(t)):(v(null),b(null))},k=null!==N,y=a||h,j=g(s),C=E(s),A=[J(n,y),l].filter(Boolean).join(" • ");/* @__PURE__ */
23
+ return e.createElement(G,{value:s,className:z('border border-dark-200 hover:border-dark-300 rounded-lg bg-dark-100 [&[data-state="open"]]:bg-surface [&[data-state="open"]]:border-dark-100',{"shadow-md shadow-dark-300":k},u),...f},
23
24
  /* @__PURE__ */e.createElement(Z,{className:"flex-row-reverse px-4 gap-1 items-center [&[data-state=open]]:px-6",onClick:e=>{if(e.target.closest('[role="dialog"]'))return e.preventDefault(),void e.stopPropagation();d?.()}},
24
- /* @__PURE__ */e.createElement(W,{size:"sm",className:"flex-1 p-0 justify-between"},/* @__PURE__ */e.createElement(U,{className:"max-w-[400px]"},/* @__PURE__ */e.createElement(L,{className:"text-base text-default"},r),/* @__PURE__ */e.createElement(G,{className:"text-xs text-default flex items-center gap-1"},A,c&&/* @__PURE__ */e.createElement(ye,{streamName:c.name,dotColor:c.color}))),/* @__PURE__ */e.createElement("div",{className:"flex items-center gap-0"},o&&/* @__PURE__ */e.createElement(we,{conversationId:s,open:"attributes"===v,onOpenChange:w("attributes")}),i&&/* @__PURE__ */e.createElement(ke,{score:p,status:i,statusMessage:m})))),
25
- /* @__PURE__ */e.createElement(V,{className:"flex flex-col gap-4 text-balance px-5"},C?/* @__PURE__ */e.createElement("div",{className:"text-center text-subtle py-4"},"Loading messages..."):/* @__PURE__ */e.createElement("ul",{className:"list-none space-y-4"},j.map((t,a)=>{const s=he(t)?t:null,r=s?.attachments?.length?s.attachments:null;return 0===a?r?/* @__PURE__ */e.createElement(be,{key:t.id,...{...t,onlyShowAttachments:!0},isFeedbackDialogOpen:"feedback"===v&&x===t.id,onFeedbackDialogChange:w("feedback",t.id)}):null:/* @__PURE__ */e.createElement(be,{key:t.id,...t,isFeedbackDialogOpen:"feedback"===v&&x===t.id,onFeedbackDialogChange:w("feedback",t.id)})}))))}const Ce=e.createContext(void 0);function Ae(){const t=e.useContext(Ce);if(void 0===t)throw new Error("useConvosContext must be used within a ConvosProvider");return t}function _e({children:t,value:a}){/* @__PURE__ */
26
- return e.createElement(Ce.Provider,{value:a},t)}function ze({convos:t,fetchMessages:a,fetchAttributes:s,fetchAnswerDiagnostics:r,onDiscard:n,onApprove:l}){const[c,i]=e.useState({}),[m,o]=e.useState({}),d=e.useRef(/* @__PURE__ */new Set),u=e.useRef({}),p=e.useCallback(e=>{d.current.has(e)||u.current[e]||(u.current[e]=!0,o(t=>({...t,[e]:!0})),a(e).then(t=>{i(a=>({...a,[e]:t})),d.current.add(e)}).catch(()=>{}).finally(()=>{delete u.current[e],o(t=>{const a={...t};return delete a[e],a})}))},[a]),f=t[0]?.locale,g=e.useMemo(()=>({fetchMessages:a,fetchAttributes:s,getMessages:e=>c[e]||[],isLoading:e=>m[e]||!1,handleFetchMessages:p,locale:f,fetchAnswerDiagnostics:e=>r(e),onDiscard:n,onApprove:l}),[a,s,c,m,p,f,r,n,l]);/* @__PURE__ */
27
- return e.createElement(_e,{value:g},/* @__PURE__ */e.createElement(K,{type:"single",collapsible:!0,className:"w-full space-y-2"},t.map(t=>/* @__PURE__ */e.createElement(je,{...t,key:t.value,onClick:()=>p(t.value)}))))}const Oe=({children:t})=>/* @__PURE__ */e.createElement("div",{className:"flex flex-col items-center justify-center h-full w-full mt-40 gap-2"},/* @__PURE__ */e.createElement(T,{className:"size-8",variant:"disabled"}),/* @__PURE__ */e.createElement("div",{className:"text-subtlest text-sm w-96 text-center leading-5"},t));export{je as Convo,ze as Convos,_e as ConvosProvider,Oe as EmptyConvos,ge as Feedback,be as Message,xe as MessageAttachmentImageThumbnails,fe as MessageType,n as StatusBadge,Ee as isAIAnswer,Ne as isAction,ve as isFeedback,he as isUserQuestion,Ae as useConvosContext};
25
+ /* @__PURE__ */e.createElement(T,{size:"sm",className:"flex-1 p-0 justify-between"},/* @__PURE__ */e.createElement(L,{className:"max-w-[400px]"},/* @__PURE__ */e.createElement(B,{className:"text-base text-default"},r),/* @__PURE__ */e.createElement(H,{className:"text-xs text-default flex items-center gap-1"},A,c&&/* @__PURE__ */e.createElement(je,{streamName:c.name,dotColor:c.color}))),/* @__PURE__ */e.createElement("div",{className:"flex items-center gap-0"},o&&/* @__PURE__ */e.createElement(ye,{conversationId:s,open:"attributes"===N,onOpenChange:w("attributes")}),i&&/* @__PURE__ */e.createElement(Ce,{score:p,status:i,statusMessage:m})))),
26
+ /* @__PURE__ */e.createElement($,{className:"flex flex-col gap-4 text-balance px-5"},C?/* @__PURE__ */e.createElement("div",{className:"text-center text-subtle py-4"},"Loading messages..."):/* @__PURE__ */e.createElement("ul",{className:"list-none space-y-4"},j.map((t,a)=>{const s=Ne(t)?t:null,r=s?.attachments?.length?s.attachments:null;return 0===a?r?/* @__PURE__ */e.createElement(ke,{key:t.id,...{...t,onlyShowAttachments:!0},isFeedbackDialogOpen:"feedback"===N&&x===t.id,onFeedbackDialogChange:w("feedback",t.id)}):null:/* @__PURE__ */e.createElement(ke,{key:t.id,...t,isFeedbackDialogOpen:"feedback"===N&&x===t.id,onFeedbackDialogChange:w("feedback",t.id)})}))))}const _e=e.createContext(void 0);function ze(){const t=e.useContext(_e);if(void 0===t)throw new Error("useConvosContext must be used within a ConvosProvider");return t}function Oe({children:t,value:a}){/* @__PURE__ */
27
+ return e.createElement(_e.Provider,{value:a},t)}function Se({convos:t,fetchMessages:a,fetchAttributes:s,fetchAnswerDiagnostics:r,onDiscard:n,onApprove:l}){const[c,i]=e.useState({}),[m,o]=e.useState({}),d=e.useRef(/* @__PURE__ */new Set),u=e.useRef({}),p=e.useCallback(e=>{d.current.has(e)||u.current[e]||(u.current[e]=!0,o(t=>({...t,[e]:!0})),a(e).then(t=>{i(a=>({...a,[e]:t})),d.current.add(e)}).catch(()=>{}).finally(()=>{delete u.current[e],o(t=>{const a={...t};return delete a[e],a})}))},[a]),f=t[0]?.locale,g=e.useMemo(()=>({fetchMessages:a,fetchAttributes:s,getMessages:e=>c[e]||[],isLoading:e=>m[e]||!1,handleFetchMessages:p,locale:f,fetchAnswerDiagnostics:e=>r(e),onDiscard:n,onApprove:l}),[a,s,c,m,p,f,r,n,l]);/* @__PURE__ */
28
+ return e.createElement(Oe,{value:g},/* @__PURE__ */e.createElement(K,{type:"single",collapsible:!0,className:"w-full space-y-2"},t.map(t=>/* @__PURE__ */e.createElement(Ae,{...t,key:t.value,onClick:()=>p(t.value)}))))}const De=({children:t})=>/* @__PURE__ */e.createElement("div",{className:"flex flex-col items-center justify-center h-full w-full mt-40 gap-2"},/* @__PURE__ */e.createElement(ne,{className:"size-8",variant:"disabled"}),/* @__PURE__ */e.createElement("div",{className:"text-subtlest text-sm w-96 text-center leading-5"},t));export{Ae as Convo,Se as Convos,Oe as ConvosProvider,De as EmptyConvos,Ee as Feedback,ke as Message,we as MessageAttachmentImageThumbnails,ge as MessageType,n as StatusBadge,he as isAIAnswer,xe as isAction,ve as isFeedback,be as isHumanAgent,Ne as isUserQuestion,ze as useConvosContext};
28
29
  //# sourceMappingURL=convos.js.map