@brainfish-ai/components 0.35.12 → 0.35.14

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/convos.d.ts CHANGED
@@ -124,12 +124,23 @@ export declare enum Feedback {
124
124
  Negative = "negative"
125
125
  }
126
126
 
127
+ export declare interface HumanAgentMessage extends BaseMessage {
128
+ type: MessageType.HUMAN;
129
+ role: 'human';
130
+ content: string;
131
+ authorName?: string;
132
+ authorAvatarUrl?: string;
133
+ source?: string;
134
+ }
135
+
127
136
  export declare const isAction: (msg: MessageProps) => msg is UserActionMessage;
128
137
 
129
138
  export declare const isAIAnswer: (msg: MessageProps) => msg is AIAnswerMessage;
130
139
 
131
140
  export declare const isFeedback: (msg: MessageProps) => msg is UserFeedbackMessage;
132
141
 
142
+ export declare const isHumanAgent: (msg: MessageProps) => msg is HumanAgentMessage;
143
+
133
144
  export declare const isUserQuestion: (msg: MessageProps) => msg is UserQuestionMessage;
134
145
 
135
146
  export declare function Message(props: MessageProps): default_2.JSX.Element;
@@ -138,13 +149,14 @@ export declare function MessageAttachmentImageThumbnails({ attachments }: {
138
149
  attachments: Attachment[];
139
150
  }): default_2.JSX.Element;
140
151
 
141
- export declare type MessageProps = AIAnswerMessage | UserQuestionMessage | UserFeedbackMessage | UserActionMessage;
152
+ export declare type MessageProps = AIAnswerMessage | UserQuestionMessage | UserFeedbackMessage | UserActionMessage | HumanAgentMessage;
142
153
 
143
154
  export declare enum MessageType {
144
155
  ACTION = "action",// user action like 'Next Best Action clicks'
145
156
  FEEDBACK = "feedback",// feedback for up/down vote
146
157
  QUESTION = "question",// user question
147
- ANSWER = "answer"
158
+ ANSWER = "answer",// ai generated answer
159
+ HUMAN = "human"
148
160
  }
149
161
 
150
162
  declare interface Props {
@@ -1,4 +1,4 @@
1
- import e,{useState as t,useCallback as r,useMemo as n,useContext as a,createContext as s,useEffect as o,useRef as i,forwardRef as c,useImperativeHandle as l}from"react";import{motion as d,AnimatePresence as u}from"framer-motion";import m from"rehype-raw";import p from"remark-gfm";import{TooltipProvider as h,Tooltip as f,TooltipTrigger as g,TooltipContent as y}from"../components/ui/tooltip.js";import{B as v}from"./button.C7qRaFMP.js";import{XCircle as w,X as b,Check as E,Copy as $,CaretDown as x,ArrowSquareOut as _,CaretRight as k,ArrowsVertical as N,Globe as C,LockSimple as I,MagnifyingGlass as S,Image as P,ArrowRight as A,ArrowLeft as T,ArrowsInSimple as R,ArrowsOutSimple as j,ClockCounterClockwise as O}from"@phosphor-icons/react";import{F as D,a as z,M as L}from"./FormattedMessage.CEEjawib.js";import{appendErrors as F,useForm as U,Controller as Q}from"react-hook-form";import{validateFieldsNatively as M,toNestErrors as V}from"@hookform/resolvers";import q from"ajv";import{g as K}from"./_commonjsHelpers.lGe4XDVY.js";import{Input as H}from"../components/ui/input.js";import{Label as B}from"../components/ui/label.js";import{Textarea as G}from"../components/ui/textarea.js";import{S as W}from"./simpleSelect.BiNOqq3j.js";import{c as J,i as Z}from"./utils.DtKoarLP.js";import{D as X}from"./date-picker.Bto-A8WE.js";import{createId as Y}from"@paralleldrive/cuid2";import{useImmerReducer as ee}from"use-immer";import{useSearchParam as te,useEffectOnce as re}from"react-use";import{a as ne}from"./ripple-status.BiOlScXz.js";import{MemoizedIcon as ae}from"../components/ui/icon.js";import{Collapsible as se,CollapsibleTrigger as oe,CollapsibleContent as ie}from"../components/ui/collapsible.js";import{F as ce}from"./feedback.CbCOP40K.js";import{getCountry as le}from"countries-and-timezones";import{Switch as de}from"../components/ui/switch.js";import{C as ue}from"./combobox.DKotd4uC.js";import{T as me}from"./two-level-combobox.CWKR1tXX.js";import{u as pe,F as he}from"./feature-flags.DOcVlPHk.js";import{l as fe,c as ge,a as ye,f as ve,m as we,b as be,d as Ee,s as $e,e as xe,g as _e,h as ke,i as Ne}from"./hooks.DjDPgQm6.js";import{X as Ce}from"lucide-react";import{C as Ie}from"./chat-logo.F_m9SJrM.js";import{ScrollArea as Se}from"../components/ui/scroll-area.js";import '../ChatSearch.css';function Pe({suggestions:t,onQuestionClick:r,title:n="Suggested questions"}){return t&&0!==t.length?/* @__PURE__ */e.createElement("div",{className:"w-full p-3 md:p-0","data-name":"Suggestions"},/* @__PURE__ */e.createElement("h3",{className:"text-base font-medium mb-4 text-foreground"},n),/* @__PURE__ */e.createElement("div",{className:"flex flex-wrap gap-2"},t.map(t=>/* @__PURE__ */e.createElement(v,{key:t.id,onClick:()=>r(t),variant:"outline",className:"border-border font-normal whitespace-normal h-auto text-left"},void 0!==t.messageCount&&/* @__PURE__ */e.createElement(h,null,/* @__PURE__ */e.createElement(f,null,/* @__PURE__ */e.createElement(g,{asChild:!0},/* @__PURE__ */e.createElement("span",{className:"bg-gray-100 text-gray-600 px-2 py-0.5 rounded-full text-xs min-w-[20px] border flex items-center justify-center border-border"},t.messageCount)),/* @__PURE__ */e.createElement(y,null,/* @__PURE__ */e.createElement("p",null,t.messageCount," messages in this conversation")))),
1
+ import e,{useState as t,useCallback as r,useMemo as n,useContext as a,createContext as s,useEffect as o,useRef as i,forwardRef as c,useImperativeHandle as l}from"react";import{motion as d,AnimatePresence as u}from"framer-motion";import m from"rehype-raw";import p from"remark-gfm";import{TooltipProvider as h,Tooltip as f,TooltipTrigger as g,TooltipContent as y}from"../components/ui/tooltip.js";import{B as v}from"./button.C7qRaFMP.js";import{XCircle as w,X as b,Check as E,Copy as $,CaretDown as x,ArrowSquareOut as _,CaretRight as k,ArrowsVertical as N,Globe as C,LockSimple as I,MagnifyingGlass as S,Image as P,ArrowRight as A,ArrowLeft as T,ArrowsInSimple as R,ArrowsOutSimple as j,ClockCounterClockwise as O}from"@phosphor-icons/react";import{F as D,a as z,M as L}from"./FormattedMessage.CEEjawib.js";import{appendErrors as F,useForm as U,Controller as Q}from"react-hook-form";import{validateFieldsNatively as M,toNestErrors as V}from"@hookform/resolvers";import q from"ajv";import{g as K}from"./_commonjsHelpers.lGe4XDVY.js";import{Input as H}from"../components/ui/input.js";import{Label as B}from"../components/ui/label.js";import{Textarea as G}from"../components/ui/textarea.js";import{S as W}from"./simpleSelect.BiNOqq3j.js";import{c as J,i as Z}from"./utils.DtKoarLP.js";import{D as X}from"./date-picker.Bto-A8WE.js";import{createId as Y}from"@paralleldrive/cuid2";import{useImmerReducer as ee}from"use-immer";import{useSearchParam as te,useEffectOnce as re}from"react-use";import{a as ne}from"./ripple-status.BiOlScXz.js";import{MemoizedIcon as ae}from"../components/ui/icon.js";import{Collapsible as se,CollapsibleTrigger as oe,CollapsibleContent as ie}from"../components/ui/collapsible.js";import{F as ce}from"./feedback.aGVWiKHH.js";import{getCountry as le}from"countries-and-timezones";import{Switch as de}from"../components/ui/switch.js";import{C as ue}from"./combobox.DKotd4uC.js";import{T as me}from"./two-level-combobox.CWKR1tXX.js";import{u as pe,F as he}from"./feature-flags.DOcVlPHk.js";import{l as fe,c as ge,a as ye,f as ve,m as we,b as be,d as Ee,s as $e,e as xe,g as _e,h as ke,i as Ne}from"./hooks.DjDPgQm6.js";import{X as Ce}from"lucide-react";import{C as Ie}from"./chat-logo.F_m9SJrM.js";import{ScrollArea as Se}from"../components/ui/scroll-area.js";import '../ChatSearch.css';function Pe({suggestions:t,onQuestionClick:r,title:n="Suggested questions"}){return t&&0!==t.length?/* @__PURE__ */e.createElement("div",{className:"w-full p-3 md:p-0","data-name":"Suggestions"},/* @__PURE__ */e.createElement("h3",{className:"text-base font-medium mb-4 text-foreground"},n),/* @__PURE__ */e.createElement("div",{className:"flex flex-wrap gap-2"},t.map(t=>/* @__PURE__ */e.createElement(v,{key:t.id,onClick:()=>r(t),variant:"outline",className:"border-border font-normal whitespace-normal h-auto text-left"},void 0!==t.messageCount&&/* @__PURE__ */e.createElement(h,null,/* @__PURE__ */e.createElement(f,null,/* @__PURE__ */e.createElement(g,{asChild:!0},/* @__PURE__ */e.createElement("span",{className:"bg-gray-100 text-gray-600 px-2 py-0.5 rounded-full text-xs min-w-[20px] border flex items-center justify-center border-border"},t.messageCount)),/* @__PURE__ */e.createElement(y,null,/* @__PURE__ */e.createElement("p",null,t.messageCount," messages in this conversation")))),
2
2
  /* @__PURE__ */e.createElement("span",{className:""},t.question))))):null}var Ae,Te={exports:{}},Re={},je={};function Oe(){return Ae||(Ae=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class t{}e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=r;class n extends t{constructor(e){super(),this._items="string"==typeof e?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const e=this._items[0];return""===e||'""'===e}get str(){var e;return null!==(e=this._str)&&void 0!==e?e:this._str=this._items.reduce((e,t)=>`${e}${t}`,"")}get names(){var e;return null!==(e=this._names)&&void 0!==e?e:this._names=this._items.reduce((e,t)=>(t instanceof r&&(e[t.str]=(e[t.str]||0)+1),e),{})}}function a(e,...t){const r=[e[0]];let a=0;for(;a<t.length;)i(r,t[a]),r.push(e[++a]);return new n(r)}e._Code=n,e.nil=new n(""),e._=a;const s=new n("+");function o(e,...t){const r=[l(e[0])];let a=0;for(;a<t.length;)r.push(s),i(r,t[a]),r.push(s,l(e[++a]));return function(e){let t=1;for(;t<e.length-1;){if(e[t]===s){const r=c(e[t-1],e[t+1]);if(void 0!==r){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}(r),new n(r)}function i(e,t){var a;t instanceof n?e.push(...t._items):t instanceof r?e.push(t):e.push("number"==typeof(a=t)||"boolean"==typeof a||null===a?a:l(Array.isArray(a)?a.join(","):a))}function c(e,t){if('""'===t)return e;if('""'===e)return t;if("string"==typeof e){if(t instanceof r||'"'!==e[e.length-1])return;return"string"!=typeof t?`${e.slice(0,-1)}${t}"`:'"'===t[0]?e.slice(0,-1)+t.slice(1):void 0}return"string"!=typeof t||'"'!==t[0]||e instanceof r?void 0:`"${e}${t.slice(1)}`}function l(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}e.str=o,e.addCodeArg=i,e.strConcat=function(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`},e.stringify=function(e){return new n(l(e))},e.safeStringify=l,e.getProperty=function(t){return"string"==typeof t&&e.IDENTIFIER.test(t)?new n(`.${t}`):a`[${t}]`},e.getEsmExportName=function(t){if("string"==typeof t&&e.IDENTIFIER.test(t))return new n(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)},e.regexpCode=function(e){return new n(e.toString())}}(je)),je}var De,ze,Le={};function Fe(){return De||(De=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;const t=/*@__PURE__*/Oe();class r extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}}var n;!function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"}(n||(e.UsedValueState=n={})),e.varKinds={const:new t.Name("const"),let:new t.Name("let"),var:new t.Name("var")};class a{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){return`${e}${(this._names[e]||this._nameGroup(e)).index++}`}_nameGroup(e){var t,r;if((null===(r=null===(t=this._parent)||void 0===t?void 0:t._prefixes)||void 0===r?void 0:r.has(e))||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}}e.Scope=a;class s extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=t._`.${new t.Name(r)}[${n}]`}}e.ValueScopeName=s;const o=t._`\n`;e.ValueScope=class extends a{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new s(e,this._newName(e))}value(e,t){var r;if(void 0===t.ref)throw new Error("CodeGen: ref must be passed in value");const n=this.toName(e),{prefix:a}=n,s=null!==(r=t.key)&&void 0!==r?r:t.ref;let o=this._values[a];if(o){const e=o.get(s);if(e)return e}else o=this._values[a]=new Map;o.set(s,n);const i=this._scope[a]||(this._scope[a]=[]),c=i.length;return i[c]=t.ref,n.setValue(t,{property:a,itemIndex:c}),n}getValue(e,t){const r=this._values[e];if(r)return r.get(t)}scopeRefs(e,r=this._values){return this._reduceValues(r,r=>{if(void 0===r.scopePath)throw new Error(`CodeGen: name "${r}" has no value`);return t._`${e}${r.scopePath}`})}scopeCode(e=this._values,t,r){return this._reduceValues(e,e=>{if(void 0===e.value)throw new Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,r)}_reduceValues(a,s,o={},i){let c=t.nil;for(const l in a){const d=a[l];if(!d)continue;const u=o[l]=o[l]||new Map;d.forEach(a=>{if(u.has(a))return;u.set(a,n.Started);let o=s(a);if(o){const r=this.opts.es5?e.varKinds.var:e.varKinds.const;c=t._`${c}${r} ${a} = ${o};${this.opts._n}`}else{if(!(o=null==i?void 0:i(a)))throw new r(a);c=t._`${c}${o}${this.opts._n}`}u.set(a,n.Completed)})}return c}}}(Le)),Le}function Ue(){return ze||(ze=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=/*@__PURE__*/Oe(),r=/*@__PURE__*/Fe();var n=/*@__PURE__*/Oe();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}});var a=/*@__PURE__*/Fe();Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return a.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return a.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return a.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return a.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class s{optimizeNodes(){return this}optimizeNames(e,t){return this}}class o extends s{constructor(e,t,r){super(),this.varKind=e,this.name=t,this.rhs=r}render({es5:e,_n:t}){const n=e?r.varKinds.var:this.varKind,a=void 0===this.rhs?"":` = ${this.rhs}`;return`${n} ${this.name}${a};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&(this.rhs=S(this.rhs,e,t)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class i extends s{constructor(e,t,r){super(),this.lhs=e,this.rhs=t,this.sideEffects=r}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof t.Name)||e[this.lhs.str]||this.sideEffects)return this.rhs=S(this.rhs,e,r),this}get names(){return I(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}}class c extends i{constructor(e,t,r,n){super(e,r,n),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}}class l extends s{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}}class d extends s{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}}class u extends s{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}}class m extends s{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=S(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}}class p extends s{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,r)=>t+r.render(e),"")}optimizeNodes(){const{nodes:e}=this;let t=e.length;for(;t--;){const r=e[t].optimizeNodes();Array.isArray(r)?e.splice(t,1,...r):r?e[t]=r:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){const{nodes:r}=this;let n=r.length;for(;n--;){const a=r[n];a.optimizeNames(e,t)||(P(e,a.names),r.splice(n,1))}return r.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>C(e,t.names),{})}}class h extends p{render(e){return"{"+e._n+super.render(e)+"}"+e._n}}class f extends p{}class g extends h{}g.kind="else";class y extends h{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+="else "+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();const e=this.condition;if(!0===e)return this.nodes;let t=this.else;if(t){const e=t.optimizeNodes();t=this.else=Array.isArray(e)?new g(e):e}return t?!1===e?t instanceof y?t:t.nodes:this.nodes.length?this:new y(A(e),t instanceof y?[t]:t.nodes):!1!==e&&this.nodes.length?this:void 0}optimizeNames(e,t){var r;if(this.else=null===(r=this.else)||void 0===r?void 0:r.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=S(this.condition,e,t),this}get names(){const e=super.names;return I(e,this.condition),this.else&&C(e,this.else.names),e}}y.kind="if";class v extends h{}v.kind="for";class w extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=S(this.iteration,e,t),this}get names(){return C(super.names,this.iteration.names)}}class b extends v{constructor(e,t,r,n){super(),this.varKind=e,this.name=t,this.from=r,this.to=n}render(e){const t=e.es5?r.varKinds.var:this.varKind,{name:n,from:a,to:s}=this;return`for(${t} ${n}=${a}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){const e=I(super.names,this.from);return I(e,this.to)}}class E extends v{constructor(e,t,r,n){super(),this.loop=e,this.varKind=t,this.name=r,this.iterable=n}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=S(this.iterable,e,t),this}get names(){return C(super.names,this.iterable.names)}}class $ extends h{constructor(e,t,r){super(),this.name=e,this.args=t,this.async=r}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}}$.kind="func";class x extends p{render(e){return"return "+super.render(e)}}x.kind="return";class _ extends h{render(e){let t="try"+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),null===(e=this.catch)||void 0===e||e.optimizeNodes(),null===(t=this.finally)||void 0===t||t.optimizeNodes(),this}optimizeNames(e,t){var r,n;return super.optimizeNames(e,t),null===(r=this.catch)||void 0===r||r.optimizeNames(e,t),null===(n=this.finally)||void 0===n||n.optimizeNames(e,t),this}get names(){const e=super.names;return this.catch&&C(e,this.catch.names),this.finally&&C(e,this.finally.names),e}}class k extends h{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}}k.kind="catch";class N extends h{render(e){return"finally"+super.render(e)}}N.kind="finally";function C(e,t){for(const r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function I(e,r){return r instanceof t._CodeOrName?C(e,r.names):e}function S(e,r,n){return e instanceof t.Name?s(e):(a=e)instanceof t._Code&&a._items.some(e=>e instanceof t.Name&&1===r[e.str]&&void 0!==n[e.str])?new t._Code(e._items.reduce((e,r)=>(r instanceof t.Name&&(r=s(r)),r instanceof t._Code?e.push(...r._items):e.push(r),e),[])):e;var a;function s(e){const t=n[e.str];return void 0===t||1!==r[e.str]?e:(delete r[e.str],t)}}function P(e,t){for(const r in t)e[r]=(e[r]||0)-(t[r]||0)}function A(e){return"boolean"==typeof e||"number"==typeof e||null===e?!e:t._`!${O(e)}`}e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?"\n":""},this._extScope=e,this._scope=new r.Scope({parent:e}),this._nodes=[new f]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){const r=this._extScope.value(e,t);return(this._values[r.prefix]||(this._values[r.prefix]=new Set)).add(r),r}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,r,n){const a=this._scope.toName(t);return void 0!==r&&n&&(this._constants[a.str]=r),this._leafNode(new o(e,a,r)),a}const(e,t,n){return this._def(r.varKinds.const,e,t,n)}let(e,t,n){return this._def(r.varKinds.let,e,t,n)}var(e,t,n){return this._def(r.varKinds.var,e,t,n)}assign(e,t,r){return this._leafNode(new i(e,t,r))}add(t,r){return this._leafNode(new c(t,e.operators.ADD,r))}code(e){return"function"==typeof e?e():e!==t.nil&&this._leafNode(new m(e)),this}object(...e){const r=["{"];for(const[n,a]of e)r.length>1&&r.push(","),r.push(n),(n!==a||this.opts.es5)&&(r.push(":"),(0,t.addCodeArg)(r,a));return r.push("}"),new t._Code(r)}if(e,t,r){if(this._blockNode(new y(e)),t&&r)this.code(t).else().code(r).endIf();else if(t)this.code(t).endIf();else if(r)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new y(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(y,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new w(e),t)}forRange(e,t,n,a,s=(this.opts.es5?r.varKinds.var:r.varKinds.let)){const o=this._scope.toName(e);return this._for(new b(s,o,t,n),()=>a(o))}forOf(e,n,a,s=r.varKinds.const){const o=this._scope.toName(e);if(this.opts.es5){const e=n instanceof t.Name?n:this.var("_arr",n);return this.forRange("_i",0,t._`${e}.length`,r=>{this.var(o,t._`${e}[${r}]`),a(o)})}return this._for(new E("of",s,o,n),()=>a(o))}forIn(e,n,a,s=(this.opts.es5?r.varKinds.var:r.varKinds.const)){if(this.opts.ownProperties)return this.forOf(e,t._`Object.keys(${n})`,a);const o=this._scope.toName(e);return this._for(new E("in",s,o,n),()=>a(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new d(e))}return(e){const t=new x;if(this._blockNode(t),this.code(e),1!==t.nodes.length)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(x)}try(e,t,r){if(!t&&!r)throw new Error('CodeGen: "try" without "catch" and "finally"');const n=new _;if(this._blockNode(n),this.code(e),t){const e=this.name("e");this._currNode=n.catch=new k(e),t(e)}return r&&(this._currNode=n.finally=new N,this.code(r)),this._endBlockNode(k,N)}throw(e){return this._leafNode(new u(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){const t=this._blockStarts.pop();if(void 0===t)throw new Error("CodeGen: not in self-balancing block");const r=this._nodes.length-t;if(r<0||void 0!==e&&r!==e)throw new Error(`CodeGen: wrong number of nodes: ${r} vs ${e} expected`);return this._nodes.length=t,this}func(e,r=t.nil,n,a){return this._blockNode(new $(e,r,n)),a&&this.code(a).endFunc(),this}endFunc(){return this._endBlockNode($)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){const r=this._currNode;if(r instanceof e||t&&r instanceof t)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){const t=this._currNode;if(!(t instanceof y))throw new Error('CodeGen: "else" without "if"');return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){const e=this._nodes;return e[e.length-1]}set _currNode(e){const t=this._nodes;t[t.length-1]=e}},e.not=A;const T=j(e.operators.AND);e.and=function(...e){return e.reduce(T)};const R=j(e.operators.OR);function j(e){return(r,n)=>r===t.nil?n:n===t.nil?r:t._`${O(r)} ${e} ${O(n)}`}function O(e){return e instanceof t.Name?e:t._`(${e})`}e.or=function(...e){return e.reduce(R)}}(Re)),Re}var Qe,Me={},Ve={},qe={},Ke={};function He(){if(Qe)return Ke;Qe=1,Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.checkStrictMode=Ke.getErrorPath=Ke.Type=Ke.useFunc=Ke.setEvaluated=Ke.evaluatedPropsToName=Ke.mergeEvaluated=Ke.eachItem=Ke.unescapeJsonPointer=Ke.escapeJsonPointer=Ke.escapeFragment=Ke.unescapeFragment=Ke.schemaRefOrVal=Ke.schemaHasRulesButRef=Ke.schemaHasRules=Ke.checkUnknownRules=Ke.alwaysValidSchema=Ke.toHash=void 0;const e=/*@__PURE__*/Ue(),t=/*@__PURE__*/Oe();function r(e,t=e.schema){const{opts:r,self:n}=e;if(!r.strictSchema)return;if("boolean"==typeof t)return;const a=n.RULES.keywords;for(const s in t)a[s]||u(e,`unknown keyword: "${s}"`)}function n(e,t){if("boolean"==typeof e)return!e;for(const r in e)if(t[r])return!0;return!1}function a(e){return"number"==typeof e?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}function s(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function o({mergeNames:t,mergeToName:r,mergeValues:n,resultToName:a}){return(s,o,i,c)=>{const l=void 0===i?o:i instanceof e.Name?(o instanceof e.Name?t(s,o,i):r(s,o,i),i):o instanceof e.Name?(r(s,i,o),o):n(o,i);return c!==e.Name||l instanceof e.Name?l:a(s,l)}}function i(t,r){if(!0===r)return t.var("props",!0);const n=t.var("props",e._`{}`);return void 0!==r&&c(t,n,r),n}function c(t,r,n){Object.keys(n).forEach(n=>t.assign(e._`${r}${(0,e.getProperty)(n)}`,!0))}Ke.toHash=function(e){const t={};for(const r of e)t[r]=!0;return t},Ke.alwaysValidSchema=function(e,t){return"boolean"==typeof t?t:0===Object.keys(t).length||(r(e,t),!n(t,e.self.RULES.all))},Ke.checkUnknownRules=r,Ke.schemaHasRules=n,Ke.schemaHasRulesButRef=function(e,t){if("boolean"==typeof e)return!e;for(const r in e)if("$ref"!==r&&t.all[r])return!0;return!1},Ke.schemaRefOrVal=function({topSchemaRef:t,schemaPath:r},n,a,s){if(!s){if("number"==typeof n||"boolean"==typeof n)return n;if("string"==typeof n)return e._`${n}`}return e._`${t}${r}${(0,e.getProperty)(a)}`},Ke.unescapeFragment=function(e){return s(decodeURIComponent(e))},Ke.escapeFragment=function(e){return encodeURIComponent(a(e))},Ke.escapeJsonPointer=a,Ke.unescapeJsonPointer=s,Ke.eachItem=function(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)},Ke.mergeEvaluated={props:o({mergeNames:(t,r,n)=>t.if(e._`${n} !== true && ${r} !== undefined`,()=>{t.if(e._`${r} === true`,()=>t.assign(n,!0),()=>t.assign(n,e._`${n} || {}`).code(e._`Object.assign(${n}, ${r})`))}),mergeToName:(t,r,n)=>t.if(e._`${n} !== true`,()=>{!0===r?t.assign(n,!0):(t.assign(n,e._`${n} || {}`),c(t,n,r))}),mergeValues:(e,t)=>!0===e||{...e,...t},resultToName:i}),items:o({mergeNames:(t,r,n)=>t.if(e._`${n} !== true && ${r} !== undefined`,()=>t.assign(n,e._`${r} === true ? true : ${n} > ${r} ? ${n} : ${r}`)),mergeToName:(t,r,n)=>t.if(e._`${n} !== true`,()=>t.assign(n,!0===r||e._`${n} > ${r} ? ${n} : ${r}`)),mergeValues:(e,t)=>!0===e||Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})},Ke.evaluatedPropsToName=i,Ke.setEvaluated=c;const l={};var d;function u(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,!0===r)throw new Error(t);e.self.logger.warn(t)}}return Ke.useFunc=function(e,r){return e.scopeValue("func",{ref:r,code:l[r.code]||(l[r.code]=new t._Code(r.code))})},function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"}(d||(Ke.Type=d={})),Ke.getErrorPath=function(t,r,n){if(t instanceof e.Name){const a=r===d.Num;return n?a?e._`"[" + ${t} + "]"`:e._`"['" + ${t} + "']"`:a?e._`"/" + ${t}`:e._`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return n?(0,e.getProperty)(t).toString():"/"+a(t)},Ke.checkStrictMode=u,Ke}var Be,Ge,We,Je={};function Ze(){if(Be)return Je;Be=1,Object.defineProperty(Je,"__esModule",{value:!0});const e=/*@__PURE__*/Ue(),t={data:new e.Name("data"),valCxt:new e.Name("valCxt"),instancePath:new e.Name("instancePath"),parentData:new e.Name("parentData"),parentDataProperty:new e.Name("parentDataProperty"),rootData:new e.Name("rootData"),dynamicAnchors:new e.Name("dynamicAnchors"),vErrors:new e.Name("vErrors"),errors:new e.Name("errors"),this:new e.Name("this"),self:new e.Name("self"),scope:new e.Name("scope"),json:new e.Name("json"),jsonPos:new e.Name("jsonPos"),jsonLen:new e.Name("jsonLen"),jsonPart:new e.Name("jsonPart")};return Je.default=t,Je}function Xe(){return Ge||(Ge=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;const t=/*@__PURE__*/Ue(),r=/*@__PURE__*/He(),n=/*@__PURE__*/Ze();function a(e,r){const a=e.const("err",r);e.if(t._`${n.default.vErrors} === null`,()=>e.assign(n.default.vErrors,t._`[${a}]`),t._`${n.default.vErrors}.push(${a})`),e.code(t._`${n.default.errors}++`)}function s(e,r){const{gen:n,validateName:a,schemaEnv:s}=e;s.$async?n.throw(t._`new ${e.ValidationError}(${r})`):(n.assign(t._`${a}.errors`,r),n.return(!1))}e.keywordError={message:({keyword:e})=>t.str`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:r})=>r?t.str`"${e}" keyword must be ${r} ($data)`:t.str`"${e}" keyword is invalid ($data)`},e.reportError=function(r,n=e.keywordError,o,c){const{it:l}=r,{gen:d,compositeRule:u,allErrors:m}=l,p=i(r,n,o);(null!=c?c:u||m)?a(d,p):s(l,t._`[${p}]`)},e.reportExtraError=function(t,r=e.keywordError,o){const{it:c}=t,{gen:l,compositeRule:d,allErrors:u}=c;a(l,i(t,r,o)),d||u||s(c,n.default.vErrors)},e.resetErrorsCount=function(e,r){e.assign(n.default.errors,r),e.if(t._`${n.default.vErrors} !== null`,()=>e.if(r,()=>e.assign(t._`${n.default.vErrors}.length`,r),()=>e.assign(n.default.vErrors,null)))},e.extendErrors=function({gen:e,keyword:r,schemaValue:a,data:s,errsCount:o,it:i}){if(void 0===o)throw new Error("ajv implementation error");const c=e.name("err");e.forRange("i",o,n.default.errors,o=>{e.const(c,t._`${n.default.vErrors}[${o}]`),e.if(t._`${c}.instancePath === undefined`,()=>e.assign(t._`${c}.instancePath`,(0,t.strConcat)(n.default.instancePath,i.errorPath))),e.assign(t._`${c}.schemaPath`,t.str`${i.errSchemaPath}/${r}`),i.opts.verbose&&(e.assign(t._`${c}.schema`,a),e.assign(t._`${c}.data`,s))})};const o={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function i(e,r,a){const{createErrors:s}=e.it;return!1===s?t._`{}`:function(e,r,a={}){const{gen:s,it:i}=e,d=[c(i,a),l(e,a)];return function(e,{params:r,message:a},s){const{keyword:i,data:c,schemaValue:l,it:d}=e,{opts:u,propertyName:m,topSchemaRef:p,schemaPath:h}=d;s.push([o.keyword,i],[o.params,"function"==typeof r?r(e):r||t._`{}`]),u.messages&&s.push([o.message,"function"==typeof a?a(e):a]);u.verbose&&s.push([o.schema,l],[o.parentSchema,t._`${p}${h}`],[n.default.data,c]);m&&s.push([o.propertyName,m])}(e,r,d),s.object(...d)}(e,r,a)}function c({errorPath:e},{instancePath:a}){const s=a?t.str`${e}${(0,r.getErrorPath)(a,r.Type.Str)}`:e;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,s)]}function l({keyword:e,it:{errSchemaPath:n}},{schemaPath:a,parentSchema:s}){let i=s?n:t.str`${n}/${e}`;return a&&(i=t.str`${i}${(0,r.getErrorPath)(a,r.Type.Str)}`),[o.schemaPath,i]}}(qe)),qe}function Ye(){if(We)return Ve;We=1,Object.defineProperty(Ve,"__esModule",{value:!0}),Ve.boolOrEmptySchema=Ve.topBoolOrEmptySchema=void 0;const e=/*@__PURE__*/Xe(),t=/*@__PURE__*/Ue(),r=/*@__PURE__*/Ze(),n={message:"boolean schema is false"};function a(t,r){const{gen:a,data:s}=t,o={gen:a,keyword:"false schema",data:s,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,e.reportError)(o,n,void 0,r)}return Ve.topBoolOrEmptySchema=function(e){const{gen:n,schema:s,validateName:o}=e;!1===s?a(e,!1):"object"==typeof s&&!0===s.$async?n.return(r.default.data):(n.assign(t._`${o}.errors`,null),n.return(!0))},Ve.boolOrEmptySchema=function(e,t){const{gen:r,schema:n}=e;!1===n?(r.var(t,!1),a(e)):r.var(t,!0)},Ve}var et,tt={},rt={};function nt(){if(et)return rt;et=1,Object.defineProperty(rt,"__esModule",{value:!0}),rt.getRules=rt.isJSONType=void 0;const e=new Set(["string","number","integer","boolean","null","object","array"]);return rt.isJSONType=function(t){return"string"==typeof t&&e.has(t)},rt.getRules=function(){const e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}},rt}var at,st,ot={};function it(){if(at)return ot;function e(e,r){return r.rules.some(r=>t(e,r))}function t(e,t){var r;return void 0!==e[t.keyword]||(null===(r=t.definition.implements)||void 0===r?void 0:r.some(t=>void 0!==e[t]))}return at=1,Object.defineProperty(ot,"__esModule",{value:!0}),ot.shouldUseRule=ot.shouldUseGroup=ot.schemaHasRulesForType=void 0,ot.schemaHasRulesForType=function({schema:t,self:r},n){const a=r.RULES.types[n];return a&&!0!==a&&e(t,a)},ot.shouldUseGroup=e,ot.shouldUseRule=t,ot}function ct(){if(st)return tt;st=1,Object.defineProperty(tt,"__esModule",{value:!0}),tt.reportTypeError=tt.checkDataTypes=tt.checkDataType=tt.coerceAndCheckDataType=tt.getJSONTypes=tt.getSchemaTypes=tt.DataType=void 0;const e=/*@__PURE__*/nt(),t=/*@__PURE__*/it(),r=/*@__PURE__*/Xe(),n=/*@__PURE__*/Ue(),a=/*@__PURE__*/He();var s;function o(t){const r=Array.isArray(t)?t:t?[t]:[];if(r.every(e.isJSONType))return r;throw new Error("type must be JSONType or JSONType[]: "+r.join(","))}!function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"}(s||(tt.DataType=s={})),tt.getSchemaTypes=function(e){const t=o(e.type);if(t.includes("null")){if(!1===e.nullable)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&void 0!==e.nullable)throw new Error('"nullable" cannot be used without "type"');!0===e.nullable&&t.push("null")}return t},tt.getJSONTypes=o,tt.coerceAndCheckDataType=function(e,r){const{gen:a,data:o,opts:c}=e,d=function(e,t){return t?e.filter(e=>i.has(e)||"array"===t&&"array"===e):[]}(r,c.coerceTypes),m=r.length>0&&!(0===d.length&&1===r.length&&(0,t.schemaHasRulesForType)(e,r[0]));if(m){const t=l(r,o,c.strictNumbers,s.Wrong);a.if(t,()=>{d.length?function(e,t,r){const{gen:a,data:s,opts:o}=e,c=a.let("dataType",n._`typeof ${s}`),d=a.let("coerced",n._`undefined`);"array"===o.coerceTypes&&a.if(n._`${c} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>a.assign(s,n._`${s}[0]`).assign(c,n._`typeof ${s}`).if(l(t,s,o.strictNumbers),()=>a.assign(d,s)));a.if(n._`${d} !== undefined`);for(const n of r)(i.has(n)||"array"===n&&"array"===o.coerceTypes)&&m(n);function m(e){switch(e){case"string":return void a.elseIf(n._`${c} == "number" || ${c} == "boolean"`).assign(d,n._`"" + ${s}`).elseIf(n._`${s} === null`).assign(d,n._`""`);case"number":return void a.elseIf(n._`${c} == "boolean" || ${s} === null
3
3
  || (${c} == "string" && ${s} && ${s} == +${s})`).assign(d,n._`+${s}`);case"integer":return void a.elseIf(n._`${c} === "boolean" || ${s} === null
4
4
  || (${c} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(d,n._`+${s}`);case"boolean":return void a.elseIf(n._`${s} === "false" || ${s} === 0 || ${s} === null`).assign(d,!1).elseIf(n._`${s} === "true" || ${s} === 1`).assign(d,!0);case"null":return a.elseIf(n._`${s} === "" || ${s} === 0 || ${s} === false`),void a.assign(d,null);case"array":a.elseIf(n._`${c} === "string" || ${c} === "number"
@@ -27,8 +27,8 @@ return e.createElement(Lr,{key:s,icon:"CalendarBlank",label:t.label,index:n,onCl
27
27
  return e.createElement(Lr,{key:s,icon:"ArrowCircleRight",label:t.label,index:n,onClick:()=>a(),showArrowOut:!0})}}))):null,Qr=["text","textarea","email"];function Mr(e){if(!Array.isArray(e))return[];const t=[];for(const r of e){if(50===t.length)break;r&&"string"==typeof r.id&&(Qr.includes(r.type)&&(t.some(e=>e.id===r.id)||t.push({id:r.id,label:"string"==typeof r.label&&r.label&&r.label!==r.id?r.label:"",type:r.type,..."string"==typeof r.helpText&&r.helpText?{helpText:r.helpText}:{}})))}return t}const Vr=({actions:r,nextBestActions:n,isLastAnswer:a,handleActionClick:s,searchQueryId:o,searchIntentId:i,question:c,answer:l})=>{const d=r&&r.length>0,u=n&&a&&n.length>0,[m,p]=t(d||u);if(!m)return null;let h=[];if(d&&(h=r.map(e=>{const t={...e,searchIntentId:i},r=(e=>{const t={[Rr.CallPhone]:{type:Or.Phone,icon:"Phone",getValue:e=>e.action?.options?.phoneNumber||e.id,getLabel:e=>e.action?.options?.title||e.type},[Rr.SendEmail]:{type:Or.Email,icon:"EnvelopeSimple",getValue:e=>e.action?.options?.to||e.id,getLabel:e=>e.action?.options?.title||e.type},[Rr.OpenUrl]:{type:Or.Link,icon:"Link",getValue:e=>e.action?.options?.url||e.id,getLabel:e=>e.action?.options?.title||e.type},[Rr.RunCallback]:{type:Or.Callback,icon:"Sparkle",getValue:e=>JSON.stringify({actionId:e.id,searchIntentId:e.searchIntentId}),getLabel:e=>e.action?.options?.title||"Run Action"},[Rr.LaunchZendeskChat]:{type:Or.ZendeskChat,icon:"ChatCircleDots",getValue:e=>e.action?.options?.embedKey||e.id,getLabel:e=>e.action?.options?.title||"Chat with us"},[Rr.LaunchZendeskMessenger]:{type:Or.ZendeskMessenger,icon:"ChatCircleDots",getValue:e=>e.action?.options?.embedKey||e.id,getLabel:e=>e.action?.options?.title||"Chat with us"},[Rr.LaunchIntercomChat]:{type:Or.IntercomChat,icon:"ChatCircleDots",getValue:e=>e.action?.options?.appId||e.id,getLabel:e=>e.action?.options?.title||"Chat with us"},[Rr.LaunchFreshdesk]:{type:Or.Freshdesk,icon:"ChatCircleDots",getValue:e=>e.action?.options?.token||e.id,getLabel:e=>e.action?.options?.title||"Chat with us"},[Rr.LaunchSupportTicketForm]:{type:Or.Link,icon:"Notepad",getValue:e=>e.action?.options?.formUrl||e.id,getLabel:e=>e.action?.options?.title||"Submit a ticket"},[Rr.LaunchZendeskSunshineChat]:{type:Or.ZendeskSunshineChat,icon:"CalendarBlank",getValue:e=>JSON.stringify({actionId:e.id,enableSupportTicket:Boolean(e.action?.options?.enableSupportTicket),preChatForm:Mr(e.action?.options?.preChatForm)}),getLabel:e=>e.action?.options?.title||"Speak to an expert"},[Rr.LaunchWebhookHandoff]:{type:Or.WebhookHandoff,icon:"CalendarBlank",getValue:e=>JSON.stringify({actionId:e.id}),getLabel:e=>e.action?.options?.title||"Talk to a human"}},r=t[e.type]||{type:Or.Link,icon:"Link",getValue:e=>e.action?.options?.url||e.id,getLabel:e=>e.action?.options?.title||e.type};return r})(t);return{id:e.id,label:r.getLabel(t),type:r.type,icon:r.icon,value:r.getValue(t)}})),u){const e=n.filter(e=>!h.some(t=>t.type===e.type));h=h.concat(e)}/* @__PURE__ */
28
28
  return e.createElement("div",{className:"p-4"},/* @__PURE__ */e.createElement(Ur,{nextBestActions:h,onActionClick:(e,t)=>{e&&(p(!1),s?.({action:e,searchQueryId:o||"",query:c,answer:l,success:t}))}}))};function qr({index:r,blocks:n=[],question:a,searchResults:s,state:o="completed",searchQueryId:i,searchIntentId:c,hideCitations:l=!1,feedback:d,onFeedback:u,disableFeedback:m=!1,textConfig:p={},redirectRules:w,attachments:b=[],actions:k,handleActionClick:N,nextBestActions:C,isLastAnswer:I,onFeedbackReasonSubmit:S,hasError:P=!1,knowledgeSourceGroups:A,onKnowledgeGroupSelect:T,statusMessage:R}){const[j,O]=t(!1),[D,L]=t(!1),F=Ut(n),U="awaiting-knowledge-group"===o,Q=("fetching-search-results"===o||"fetching-stream"===o)&&(1===n.length||Boolean(R)),M="fetching-search-results"===o,V="completed"===o,q=P&&V,K=n.length>0,H=R??p.loadingAnswerText,B=M?p.loadingSearchText:H,G=Q&&Boolean(R);/* @__PURE__ */
29
29
  return e.createElement("div",{className:"rounded-lg relative mx-auto overflow-hidden bg-card border border-primary","data-name":"SearchResults","data-index":r},
30
- /* @__PURE__ */e.createElement("div",{className:"px-4 pt-4 pb-2"},/* @__PURE__ */e.createElement("div",{className:"flex items-start justify-between gap-2 min-h-9"},/* @__PURE__ */e.createElement("h2",{className:"leading-normal font-semibold m-0 text-foreground self-center text-lg"},a),V&&K&&!q&&/* @__PURE__ */e.createElement(h,null,/* @__PURE__ */e.createElement(f,null,/* @__PURE__ */e.createElement(g,{asChild:!0},/* @__PURE__ */e.createElement(v,{variant:"ghost",size:"icon",onClick:()=>{(async()=>{try{await navigator.clipboard.writeText(F)}catch(e){console.warn("Clipboard API failed, using fallback:",e);const r=document.createElement("textarea");r.value=F,r.style.position="fixed",r.style.opacity="0",document.body.appendChild(r),r.focus(),r.select();try{document.execCommand("copy")}catch(t){console.error("Fallback: Oops, unable to copy",t)}document.body.removeChild(r)}O(!0),setTimeout(()=>O(!1),2e3)})()},className:"-mt-1 flex-shrink-0"},j?/* @__PURE__ */e.createElement(E,{className:"text-feedback-positive",weight:"bold"}):/* @__PURE__ */e.createElement($,{className:"text-secondary-foreground",weight:"bold"}))),/* @__PURE__ */e.createElement(y,null,/* @__PURE__ */e.createElement("p",null,j?"Copied!":"Copy"))))),/* @__PURE__ */e.createElement(Pr,{items:b.map((e,t)=>({id:`${t}`,src:e.url,url:e.url,alt:e.filename})),size:"xs",className:"mt-2"})),Q&&/* @__PURE__ */e.createElement("div",{className:"px-4 pt-0 pb-2"},/* @__PURE__ */e.createElement(Ir,{text:B??""})),U&&A&&T?/* @__PURE__ */e.createElement(Tr,{groups:A,onGroupSelect:T}):/* @__PURE__ */e.createElement("div",{className:"flex flex-col"},!G&&n?.map((t,r)=>/* @__PURE__ */e.createElement("div",{key:r,className:J("px-4 pt-0 pb-2 border-b last:border-b-0 border-dashed",q&&"text-muted-foreground")},
31
- /* @__PURE__ */e.createElement(Cr,{block:t,redirectRules:w,state:o})))),V&&K&&!q&&/* @__PURE__ */e.createElement(Vr,{actions:k,nextBestActions:C,isLastAnswer:I,handleActionClick:N,searchQueryId:i||"",searchIntentId:c,question:a,answer:F}),V&&K&&!m&&!q&&/* @__PURE__ */e.createElement("div",{className:"p-4 pt-0"},/* @__PURE__ */e.createElement(ce,{feedback:d,onFeedback:e=>{u&&i&&u(e)},textConfig:p,disabled:m,feedbackReasonLength:500,feedbackReasonPlaceholder:"What could we have done better? Your feedback is valuable to us...",onFeedbackReasonSubmit:S,feedbackReasonThankYouText:"Thank you for your feedback!"})),!l&&s&&s.length>0&&/* @__PURE__ */e.createElement("div",{className:"overflow-hidden bg-card border-dashed border-0 border-t-2"},/* @__PURE__ */e.createElement(se,{open:D,onOpenChange:L,className:"w-full"},/* @__PURE__ */e.createElement("div",null,/* @__PURE__ */e.createElement(oe,{asChild:!0},/* @__PURE__ */e.createElement(v,{variant:"secondary",className:"w-full justify-between h-11","data-name":"RelatedSources"},/* @__PURE__ */e.createElement("div",{className:"flex items-center gap-2"},/* @__PURE__ */e.createElement("span",{className:"font-medium truncate text-base"},"Sources")),/* @__PURE__ */e.createElement(x,{className:"size-4 flex-shrink-0 transition-transform duration-200 text-secondary-foreground "+(D?"rotate-180":""),weight:"bold"}),/* @__PURE__ */e.createElement("span",{className:"sr-only"},"Toggle")))),/* @__PURE__ */e.createElement(ie,{className:"divide-y divide-dark-300 overflow-hidden CollapsibleContent"},s.map(t=>/* @__PURE__ */e.createElement("a",{key:t.id,href:z(t.url),target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-3 transition-colors duration-200 hover:bg-accent bg-card text-foreground"},
30
+ /* @__PURE__ */e.createElement("div",{className:"px-4 pt-4 pb-2"},/* @__PURE__ */e.createElement("div",{className:"flex items-start justify-between gap-2 min-h-9"},/* @__PURE__ */e.createElement("h2",{className:"leading-normal font-semibold m-0 text-foreground self-center text-lg"},a)),/* @__PURE__ */e.createElement(Pr,{items:b.map((e,t)=>({id:`${t}`,src:e.url,url:e.url,alt:e.filename})),size:"xs",className:"mt-2"})),Q&&/* @__PURE__ */e.createElement("div",{className:"px-4 pt-0 pb-2"},/* @__PURE__ */e.createElement(Ir,{text:B??""})),U&&A&&T?/* @__PURE__ */e.createElement(Tr,{groups:A,onGroupSelect:T}):/* @__PURE__ */e.createElement("div",{className:"flex flex-col"},!G&&n?.map((t,r)=>/* @__PURE__ */e.createElement("div",{key:r,className:J("px-4 pt-0 pb-2 border-b last:border-b-0 border-dashed",q&&"text-muted-foreground")},
31
+ /* @__PURE__ */e.createElement(Cr,{block:t,redirectRules:w,state:o})))),V&&K&&!q&&/* @__PURE__ */e.createElement(Vr,{actions:k,nextBestActions:C,isLastAnswer:I,handleActionClick:N,searchQueryId:i||"",searchIntentId:c,question:a,answer:F}),V&&K&&!q&&/* @__PURE__ */e.createElement("div",{className:"p-4 pt-0 flex items-baseline gap-2"},/* @__PURE__ */e.createElement(h,null,/* @__PURE__ */e.createElement(f,null,/* @__PURE__ */e.createElement(g,{asChild:!0},/* @__PURE__ */e.createElement(v,{variant:"ghost",size:"icon",onClick:()=>{(async()=>{try{await navigator.clipboard.writeText(F)}catch(e){console.warn("Clipboard API failed, using fallback:",e);const r=document.createElement("textarea");r.value=F,r.style.position="fixed",r.style.opacity="0",document.body.appendChild(r),r.focus(),r.select();try{document.execCommand("copy")}catch(t){console.error("Fallback: Oops, unable to copy",t)}document.body.removeChild(r)}O(!0),setTimeout(()=>O(!1),2e3)})()},className:"-mt-1 flex-shrink-0"},j?/* @__PURE__ */e.createElement(E,{className:"text-feedback-positive",weight:"bold"}):/* @__PURE__ */e.createElement($,{className:"text-dark-500",weight:"bold"}))),/* @__PURE__ */e.createElement(y,null,/* @__PURE__ */e.createElement("p",null,j?"Copied!":"Copy")))),!m&&/* @__PURE__ */e.createElement(ce,{feedback:d,onFeedback:e=>{u&&i&&u(e)},textConfig:p,disabled:m,feedbackReasonLength:500,feedbackReasonPlaceholder:"What could we have done better? Your feedback is valuable to us...",onFeedbackReasonSubmit:S,feedbackReasonThankYouText:"Thank you for your feedback!"})),!l&&s&&s.length>0&&/* @__PURE__ */e.createElement("div",{className:"overflow-hidden bg-card border-dashed border-0 border-t-2"},/* @__PURE__ */e.createElement(se,{open:D,onOpenChange:L,className:"w-full"},/* @__PURE__ */e.createElement("div",null,/* @__PURE__ */e.createElement(oe,{asChild:!0},/* @__PURE__ */e.createElement(v,{variant:"secondary",className:"w-full justify-between h-11","data-name":"RelatedSources"},/* @__PURE__ */e.createElement("div",{className:"flex items-center gap-2"},/* @__PURE__ */e.createElement("span",{className:"font-medium truncate text-base"},"Sources")),/* @__PURE__ */e.createElement(x,{className:"size-4 flex-shrink-0 transition-transform duration-200 text-secondary-foreground "+(D?"rotate-180":""),weight:"bold"}),/* @__PURE__ */e.createElement("span",{className:"sr-only"},"Toggle")))),/* @__PURE__ */e.createElement(ie,{className:"divide-y divide-dark-300 overflow-hidden CollapsibleContent"},s.map(t=>/* @__PURE__ */e.createElement("a",{key:t.id,href:z(t.url),target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-3 transition-colors duration-200 hover:bg-accent bg-card text-foreground"},
32
32
  /* @__PURE__ */e.createElement("span",{className:"flex-grow truncate"},t.title),
33
33
  /* @__PURE__ */e.createElement(_,{className:"size-4 flex-shrink-0 text-secondary-foreground",weight:"bold"})))))))}const Kr=d(v);function Hr({questions:t,onQuestionClick:r}){return t.length?/* @__PURE__ */e.createElement(d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"w-full"},
34
34
  /* @__PURE__ */e.createElement("div",{className:"rounded-lg overflow-hidden bg-card border"},/* @__PURE__ */e.createElement("h3",{className:"px-4 py-3 border-b border-b-dark-300 font-bold"},"Follow-up questions"),t.map((t,n)=>n<3?/* @__PURE__ */e.createElement(Kr,{key:n,initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.1*n},onClick:()=>r(t),variant:"ghost",className:"w-full text-left"},
@@ -93,4 +93,4 @@ return e.createElement(d.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},t
93
93
  /* @__PURE__ */e.createElement("div",{ref:ut})),Ce&&rt&&!bt&&!W&&!ft&&(()=>{const t=ie.some(e=>"awaiting-knowledge-group"===e.state);/* @__PURE__ */
94
94
  return e.createElement(Zr,{ref:dt,initialQuery:ue,onQueryChange:me,isSearching:he,handleFollowUpSearch:Vt,textConfig:Le,enableFileAttachment:Ue,attachedFiles:He,isUploading:Be,onAddFiles:Ge,onRemoveFile:We,disabled:t})})(),Ce&&bt&&!ft&&/* @__PURE__ */e.createElement(fn,{onStartNewConversation:()=>Qt()}),!ft&&!bt&&W)});bn.displayName="ChatSearch";const En=c(({featureFlags:t,...r},n)=>/* @__PURE__ */e.createElement(he,{flags:t},/* @__PURE__ */e.createElement(_r,{searchPath:r.searchPath,contentTypeEndpoint:r.contentTypeEndpoint,widgetKey:r.apiKey},
95
95
  /* @__PURE__ */e.createElement(bn,{...r,ref:n}))));En.displayName="ChatSearch";export{En as C,Or as N,fn as R,_r as a,Xr as b,kr as u,jr as v};
96
- //# sourceMappingURL=ChatSearch.Bf4y1_nr.js.map
96
+ //# sourceMappingURL=ChatSearch.BsZMeeqP.js.map