kyt-chat 1.0.2 β†’ 1.0.5

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.
@@ -483,4 +483,4 @@ Error generating stack: `+e.message+`
483
483
  }
484
484
  .kyt-bubble-btn { bottom: 16px; right: 16px; }
485
485
  }
486
- `}var f=!1;function p(e){if(f)return;f=!0;let t=document.createElement(`style`);t.setAttribute(`data-kyt`,`1`),t.textContent=d(e),document.head.appendChild(t)}function m(){return Math.random().toString(36).slice(2)}function h(e){let[t,n]=(0,u.useState)([]),[r,i]=(0,u.useState)(!1),[a,o]=(0,u.useState)(null),s=(0,u.useRef)(null);return{messages:t,loading:r,error:a,sendMessage:(0,u.useCallback)(async t=>{let a=t.trim();if(!(!a||r)){o(null),n(e=>[...e,{id:m(),role:`user`,text:a}]),i(!0),s.current?.abort(),s.current=new AbortController;try{let t=await(await fetch(e.queryUrl,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({input:a,...e.topicId?{topic_id:e.topicId}:{}}),signal:s.current.signal})).json();n(e=>[...e,{id:m(),role:`assistant`,text:t.answer??`No response.`,confidence:t.confidence,sources:t.sources,extra_sources:t.extra_sources}])}catch(e){if(e.name===`AbortError`)return;let t=e instanceof Error?e.message:`Something went wrong.`;o(t),n(e=>[...e,{id:m(),role:`assistant`,text:t,confidence:`low`}])}finally{i(!1)}}},[e,r]),reset:(0,u.useCallback)(()=>{s.current?.abort(),n([]),o(null),i(!1)},[])}}var g=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),_=t(((e,t)=>{t.exports=g()}))();function v(e){let t=Math.floor(e);return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}function y({url:e,label:t}){return e?(0,_.jsxs)(`a`,{className:`kyt-source-btn`,href:e,target:`_blank`,rel:`noopener noreferrer`,children:[(0,_.jsxs)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,children:[(0,_.jsx)(`path`,{d:`M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6`}),(0,_.jsx)(`polyline`,{points:`15 3 21 3 21 9`}),(0,_.jsx)(`line`,{x1:`10`,y1:`14`,x2:`21`,y2:`3`})]}),t]}):null}function b({s:e}){let t=e.source_type===`external`,n=e.url??``,r=n.includes(`#`)?`Jump to section`:`Go to source`;return(0,_.jsxs)(`div`,{className:`kyt-source-card`,children:[(0,_.jsxs)(`div`,{className:`kyt-card-header`,children:[(0,_.jsx)(`span`,{className:`kyt-card-type kyt-t-${t?`external`:`website`}`,children:t?`EXTERNAL`:`WEBSITE`}),(0,_.jsx)(`span`,{className:`kyt-card-label`,children:e.source_label.replace(/_/g,` `)})]}),(0,_.jsxs)(`div`,{className:`kyt-card-body`,children:[e.summary&&(0,_.jsx)(`div`,{className:`kyt-card-summary`,children:e.summary}),(0,_.jsx)(`div`,{className:`kyt-card-actions`,children:(0,_.jsx)(y,{url:n,label:r})})]})]})}function x({s:e}){let t=e.url||e.storage_url||void 0;return(0,_.jsxs)(`div`,{className:`kyt-source-card`,children:[(0,_.jsxs)(`div`,{className:`kyt-card-header`,children:[(0,_.jsx)(`span`,{className:`kyt-card-type kyt-t-pdf`,children:`PDF`}),(0,_.jsx)(`span`,{className:`kyt-card-label`,children:e.source_label.replace(/_/g,` `)})]}),(0,_.jsxs)(`div`,{className:`kyt-card-body`,children:[e.summary&&(0,_.jsx)(`div`,{className:`kyt-card-summary`,children:e.summary}),(0,_.jsxs)(`div`,{className:`kyt-card-actions`,children:[e.pdf_page!=null&&(0,_.jsxs)(`span`,{className:`kyt-pdf-page-badge`,children:[`πŸ“„ Page `,e.pdf_page]}),(0,_.jsx)(y,{url:t,label:e.pdf_page==null?`Open PDF`:`Open page ${e.pdf_page}`})]})]})]})}function ee({s:e}){let t=e.start_time===null||e.start_time===void 0,n=t?0:e.start_time??0,r=e.drive_embed_url??``;r&&(r=r.split(`?`)[0].split(`#`)[0],!t&&n>0&&(r=r.includes(`drive.google.com`)?`${r}?start=${n}`:`${r}#t=${n}`));let i=r.includes(`drive.google.com`),a=t?`Watch video`:`Jump to ${v(n)}`;return(0,_.jsxs)(`div`,{className:`kyt-source-card`,children:[(0,_.jsxs)(`div`,{className:`kyt-card-header`,children:[(0,_.jsx)(`span`,{className:`kyt-card-type kyt-t-video`,children:`VIDEO`}),(0,_.jsx)(`span`,{className:`kyt-card-label`,children:e.source_label.replace(/_/g,` `)})]}),(0,_.jsxs)(`div`,{className:`kyt-card-body`,children:[r&&(0,_.jsx)(`div`,{className:`kyt-video-embed-wrapper`,children:i?(0,_.jsx)(`iframe`,{src:r,allowFullScreen:!0,loading:`lazy`,allow:`fullscreen`,style:{border:0}}):(0,_.jsx)(`video`,{controls:!0,preload:`none`,"data-start":!t&&n>0?n:void 0,children:(0,_.jsx)(`source`,{src:r})})}),(0,_.jsxs)(`div`,{className:`kyt-card-actions`,children:[!t&&n>0&&(0,_.jsxs)(`span`,{className:`kyt-timestamp-chip`,children:[`⏱ `,v(n)]}),(0,_.jsx)(y,{url:r||void 0,label:a}),e.url&&e.url!==r&&(0,_.jsx)(y,{url:e.url,label:`Go to source`})]}),e.content_snippet&&(0,_.jsxs)(`div`,{className:`kyt-transcript-snippet`,children:[`"`,e.content_snippet,`…"`]})]})]})}function S({s:e}){let t=e.storage_url??void 0,n=e.storage_url??e.url??``;return(0,_.jsxs)(`div`,{className:`kyt-source-card`,children:[(0,_.jsxs)(`div`,{className:`kyt-card-header`,children:[(0,_.jsx)(`span`,{className:`kyt-card-type kyt-t-social`,children:`IMAGE`}),(0,_.jsx)(`span`,{className:`kyt-card-label`,children:e.source_label.replace(/_/g,` `)})]}),(0,_.jsxs)(`div`,{className:`kyt-card-body`,children:[t&&(0,_.jsx)(`div`,{className:`kyt-card-img-wrap`,children:(0,_.jsx)(`img`,{src:t,alt:e.source_label})}),e.summary&&(0,_.jsx)(`div`,{className:`kyt-card-summary`,children:e.summary}),(0,_.jsx)(`div`,{className:`kyt-card-actions`,children:(0,_.jsx)(y,{url:n||void 0,label:`View image`})})]})]})}function C({s:e}){let t=(e.source_label??``).toLowerCase(),n=t.includes(`x`)||t.includes(`twitter`)?`𝕏`:t.includes(`linkedin`)?`in`:`β—Ž`,r=e.content_snippet??e.summary??``;return(0,_.jsxs)(`div`,{className:`kyt-source-card`,children:[(0,_.jsxs)(`div`,{className:`kyt-card-header`,children:[(0,_.jsxs)(`span`,{className:`kyt-card-type kyt-t-social`,children:[n,` SOCIAL`]}),(0,_.jsx)(`span`,{className:`kyt-card-label`,children:e.source_label.replace(/_/g,` `)})]}),(0,_.jsxs)(`div`,{className:`kyt-card-body`,children:[r&&(0,_.jsx)(`div`,{className:`kyt-card-summary`,children:r}),(0,_.jsx)(`div`,{className:`kyt-card-actions`,children:(0,_.jsx)(y,{url:e.url,label:`View post`})})]})]})}function te({s:e}){return e.source_type===`video`?(0,_.jsx)(ee,{s:e}):e.source_type===`pdf`?(0,_.jsx)(x,{s:e}):e.source_type===`image`?(0,_.jsx)(S,{s:e}):e.source_type===`social`?(0,_.jsx)(C,{s:e}):(0,_.jsx)(b,{s:e})}function ne(e){return e.source_type===`video`?`video::${e.source_label}::${e.start_time??`desc`}`:e.source_type===`pdf`?`pdf::${e.source_label}::${e.pdf_page??`all`}`:e.source_type===`image`?`image::${e.storage_url??e.url??e.source_label}`:`${e.source_type}::${e.url??e.source_label}`}function re(e){let t=new Set;return e.filter(e=>{let n=ne(e);return t.has(n)?!1:(t.add(n),!0)})}function w({sources:e,extra_sources:t=[]}){let[n,r]=(0,u.useState)(!1),i=re(e),a=re(t);return i.length?(0,_.jsxs)(`div`,{className:`kyt-sources-row`,children:[(0,_.jsxs)(`div`,{className:`kyt-sources-header`,children:[`Sources (`,i.length,a.length?`+`:``,`)`]}),(0,_.jsxs)(`div`,{className:`kyt-source-cards`,children:[i.map((e,t)=>(0,_.jsx)(te,{s:e},t)),a.length>0&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`button`,{className:`kyt-extra-toggle`,onClick:()=>r(e=>!e),children:n?`Show less`:`+ ${a.length} more source${a.length>1?`s`:``}`}),n&&(0,_.jsx)(`div`,{className:`kyt-extra-cards`,children:a.map((e,t)=>(0,_.jsx)(te,{s:e},t))})]})]})]}):null}function ie(e){return e.replace(/\*\*(.*?)\*\*/g,`<strong>$1</strong>`).replace(/\n/g,`<br>`)}function ae({config:e,onClose:t,showHeader:n=!0,bubbleMode:r=!1,pendingFaq:i,onFaqSent:a}){let{messages:o,loading:s,sendMessage:c}=h(e),[l,d]=(0,u.useState)(``),f=(0,u.useRef)(null),p=(0,u.useRef)(null),m=e.theme??`dark`,g=e.faqs??[],v=e.title??`Ask anything`,y=e.placeholder??`Type your question…`,b=e.welcomeMessage??`Ask a question to get started.`,x=e.avatarLabel??`AI`,ee=e.hint??``;(0,u.useEffect)(()=>{f.current?.scrollIntoView({behavior:`smooth`})},[o,s]);let S=(0,u.useRef)(void 0);(0,u.useEffect)(()=>{i&&i!==S.current&&(S.current=i,c(i),a?.())},[i,c,a]);let C=()=>{!l.trim()||s||(c(l),d(``),p.current?.focus())},te=e=>{c(e),d(``)};return(0,_.jsx)(`div`,{className:`kyt-root${m===`light`?` kyt-light`:``}`,style:{height:`100%`,display:`flex`,flexDirection:`column`},children:(0,_.jsxs)(`div`,{className:`kyt-page`,children:[n&&(0,_.jsxs)(`header`,{className:`kyt-header`,children:[(0,_.jsx)(`span`,{className:`kyt-header-title`,children:v}),(0,_.jsxs)(`div`,{className:`kyt-header-right`,children:[(0,_.jsxs)(`div`,{className:`kyt-live`,children:[(0,_.jsx)(`div`,{className:`kyt-live-dot`}),`Live`]}),t&&(0,_.jsx)(`button`,{className:`kyt-hdr-btn`,onClick:t,"aria-label":`Close chat`,children:(0,_.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`white`,children:(0,_.jsx)(`path`,{d:`M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z`})})})]})]}),(0,_.jsxs)(`div`,{className:`kyt-body`,children:[!r&&g.length>0&&(0,_.jsxs)(`aside`,{className:`kyt-sidebar`,children:[(0,_.jsx)(`div`,{className:`kyt-sidebar-label`,children:`Suggested Questions`}),(0,_.jsx)(`div`,{className:`kyt-faq-list`,children:g.map((e,t)=>(0,_.jsx)(`button`,{className:`kyt-faq-btn`,onClick:()=>te(e),children:e},t))})]}),(0,_.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,_.jsxs)(`div`,{className:`kyt-messages`,children:[o.length===0&&(0,_.jsxs)(`div`,{className:`kyt-welcome`,children:[(0,_.jsx)(`div`,{className:`kyt-welcome-icon`,children:(0,_.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`28`,height:`28`,fill:`white`,children:(0,_.jsx)(`path`,{d:`M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-2 12H6v-2h12v2zm0-3H6V9h12v2zm0-3H6V6h12v2z`})})}),(0,_.jsx)(`h2`,{children:v}),(0,_.jsx)(`p`,{children:b})]}),o.map(e=>(0,_.jsx)(oe,{msg:e,avatarLabel:x},e.id)),s&&(0,_.jsxs)(`div`,{className:`kyt-msg kyt-msg-assistant`,children:[(0,_.jsx)(`div`,{className:`kyt-avatar`,children:x[0]}),(0,_.jsxs)(`div`,{className:`kyt-typing`,children:[(0,_.jsx)(`div`,{className:`kyt-dot`}),(0,_.jsx)(`div`,{className:`kyt-dot`}),(0,_.jsx)(`div`,{className:`kyt-dot`})]})]}),(0,_.jsx)(`div`,{ref:f})]}),(0,_.jsxs)(`div`,{className:`kyt-input-bar`,children:[(0,_.jsxs)(`div`,{className:`kyt-input-row`,children:[(0,_.jsx)(`input`,{ref:p,className:`kyt-input`,value:l,placeholder:y,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),C())},disabled:s}),(0,_.jsx)(`button`,{className:`kyt-send-btn`,onClick:C,disabled:s||!l.trim(),"aria-label":`Send`,children:(0,_.jsx)(`svg`,{viewBox:`0 0 24 24`,children:(0,_.jsx)(`path`,{d:`M2 21l21-9L2 3v7l15 2-15 2z`})})})]}),ee&&(0,_.jsx)(`div`,{className:`kyt-hint`,children:ee})]})]})]})]})})}function oe({msg:e,avatarLabel:t}){if(e.role===`user`)return(0,_.jsx)(`div`,{className:`kyt-msg kyt-msg-user`,children:(0,_.jsx)(`div`,{className:`kyt-bubble kyt-bubble-user`,dangerouslySetInnerHTML:{__html:ie(e.text)}})});let n=e.confidence===`high`?`kyt-conf kyt-conf-high`:e.confidence===`low`?`kyt-conf kyt-conf-low`:`kyt-conf kyt-conf-medium`;return(0,_.jsxs)(`div`,{className:`kyt-msg kyt-msg-assistant`,style:{flexDirection:`column`},children:[(0,_.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:10},children:[(0,_.jsx)(`div`,{className:`kyt-avatar`,children:t[0]}),(0,_.jsxs)(`div`,{className:`kyt-bubble kyt-bubble-assistant`,children:[(0,_.jsx)(`span`,{dangerouslySetInnerHTML:{__html:ie(e.text)}}),e.confidence&&(0,_.jsx)(`span`,{className:n,children:e.confidence.toUpperCase()})]})]}),e.sources&&e.sources.length>0&&(0,_.jsx)(w,{sources:e.sources,extra_sources:e.extra_sources})]})}function se({config:e}){let[t,n]=(0,u.useState)(!1),[r,i]=(0,u.useState)(!1),[a,o]=(0,u.useState)(!1),[s,c]=(0,u.useState)(),l=e.primaryColor??`#1565c0`,d=e.faqs??[];(0,u.useEffect)(()=>{p(l)},[l]);let f=()=>{n(!1),i(!1),o(!1)},m=e=>{c({text:e,id:Date.now()}),o(!1)};return(0,_.jsxs)(`div`,{className:`kyt-root`,children:[t&&r&&(0,_.jsx)(`div`,{className:`kyt-bubble-expanded-backdrop`,onClick:f}),t&&(0,_.jsxs)(`div`,{className:r?`kyt-bubble-expanded`:`kyt-bubble-compact`,children:[(0,_.jsxs)(`div`,{className:`kyt-bubble-header`,style:{background:l},children:[(0,_.jsx)(`span`,{className:`kyt-bubble-header-title`,children:e.title??`Ask anything`}),(0,_.jsxs)(`div`,{className:`kyt-bubble-header-actions`,children:[(0,_.jsxs)(`div`,{className:`kyt-live`,style:{marginRight:4},children:[(0,_.jsx)(`div`,{className:`kyt-live-dot`}),`Live`]}),d.length>0&&(0,_.jsx)(`button`,{className:`kyt-hdr-btn`,onClick:()=>o(e=>!e),title:`Suggested questions`,"aria-label":`Suggested questions`,children:`πŸ’‘`}),(0,_.jsx)(`button`,{className:`kyt-hdr-btn`,onClick:()=>i(e=>!e),title:r?`Compact`:`Expand`,"aria-label":r?`Compact`:`Expand`,children:r?(0,_.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`white`,children:(0,_.jsx)(`path`,{d:`M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z`})}):(0,_.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`white`,children:(0,_.jsx)(`path`,{d:`M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z`})})}),(0,_.jsx)(`button`,{className:`kyt-hdr-btn`,onClick:f,"aria-label":`Close chat`,children:(0,_.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`white`,children:(0,_.jsx)(`path`,{d:`M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z`})})})]})]}),(0,_.jsxs)(`div`,{style:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`,position:`relative`},children:[(0,_.jsx)(ae,{config:e,showHeader:!1,bubbleMode:!0,pendingFaq:s?.text,onFaqSent:()=>c(void 0)}),a&&d.length>0&&(0,_.jsxs)(`div`,{className:`kyt-faq-drawer`,children:[(0,_.jsxs)(`div`,{className:`kyt-faq-drawer-header`,children:[(0,_.jsx)(`span`,{className:`kyt-faq-drawer-label`,children:`Suggested`}),(0,_.jsx)(`button`,{className:`kyt-faq-drawer-close`,onClick:()=>o(!1),"aria-label":`Close`,children:`βœ•`})]}),(0,_.jsx)(`div`,{className:`kyt-faq-drawer-list`,children:d.map((e,t)=>(0,_.jsx)(`button`,{className:`kyt-faq-drawer-btn`,onClick:()=>m(e),children:e},t))})]})]})]}),!r&&(0,_.jsx)(`button`,{className:`kyt-bubble-btn`,style:{background:l},onClick:()=>n(e=>!e),"aria-label":t?`Close chat`:`Open chat`,children:t?(0,_.jsx)(`svg`,{viewBox:`0 0 24 24`,children:(0,_.jsx)(`path`,{d:`M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z`})}):(0,_.jsx)(`svg`,{viewBox:`0 0 24 24`,children:(0,_.jsx)(`path`,{d:`M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-2 12H6v-2h12v2zm0-3H6V9h12v2zm0-3H6V6h12v2z`})})})]})}function ce({config:e,style:t,className:n}){return(0,u.useEffect)(()=>{p(e.primaryColor??`#1565c0`)},[e.primaryColor]),(0,_.jsx)(`div`,{style:{height:`100%`,width:`100%`,...t},className:n,children:(0,_.jsx)(ae,{config:e,showHeader:!0})})}function le(e){let t=document.querySelector(e);if(!t)throw Error(`kyt-chat: no element found for selector "${e}"`);return t}function ue(e,t){p(e.primaryColor??`#1565c0`),(0,l.createRoot)(le(t)).render((0,u.createElement)(se,{config:e}))}function T(e,t){p(e.primaryColor??`#1565c0`);let n=le(t);n.style.height=n.style.height||`100vh`,n.style.display=`flex`,n.style.flexDirection=`column`,(0,l.createRoot)(n).render((0,u.createElement)(ce,{config:e,style:{height:`100%`,flex:1}}))}function E(e,t,n=`bubble`){n===`chat`?T(e,t):ue(e,t)}return e.mount=E,e.mountBubble=ue,e.mountChat=T,e})({});
486
+ `}var f=!1;function p(e){if(f)return;f=!0;let t=document.createElement(`style`);t.setAttribute(`data-kyt`,`1`),t.textContent=d(e),document.head.appendChild(t)}function m(){return Math.random().toString(36).slice(2)}var h=new Map;function g(e){return e.topicId??e.queryUrl}function _(e){let t=g(e),[n,r]=(0,u.useState)(()=>h.get(t)??[]),[i,a]=(0,u.useState)(!1),[o,s]=(0,u.useState)(null),c=(0,u.useRef)(null),l=(0,u.useCallback)(e=>{r(n=>{let r=e(n);return h.set(t,r),r})},[t]);return{messages:n,loading:i,error:o,sendMessage:(0,u.useCallback)(async t=>{let n=t.trim();if(!(!n||i)){s(null),l(e=>[...e,{id:m(),role:`user`,text:n}]),a(!0),c.current?.abort(),c.current=new AbortController;try{let t=await(await fetch(e.queryUrl,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({input:n,...e.topicId?{topic_id:e.topicId}:{}}),signal:c.current.signal})).json();l(e=>[...e,{id:m(),role:`assistant`,text:t.answer??`No response.`,confidence:t.confidence,sources:t.sources,extra_sources:t.extra_sources}])}catch(e){if(e.name===`AbortError`)return;let t=e instanceof Error?e.message:`Something went wrong.`;s(t),l(e=>[...e,{id:m(),role:`assistant`,text:t,confidence:`low`}])}finally{a(!1)}}},[e,i]),reset:(0,u.useCallback)(()=>{c.current?.abort(),h.delete(t),r([]),s(null),a(!1)},[t])}}var v=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),y=t(((e,t)=>{t.exports=v()}))();function b(e){let t=Math.floor(e);return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}function x({url:e,label:t}){return e?(0,y.jsxs)(`a`,{className:`kyt-source-btn`,href:e,target:`_blank`,rel:`noopener noreferrer`,children:[(0,y.jsxs)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,children:[(0,y.jsx)(`path`,{d:`M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6`}),(0,y.jsx)(`polyline`,{points:`15 3 21 3 21 9`}),(0,y.jsx)(`line`,{x1:`10`,y1:`14`,x2:`21`,y2:`3`})]}),t]}):null}function ee({s:e}){let t=e.source_type===`external`,n=e.url??``,r=n.includes(`#`)?`Jump to section`:`Go to source`;return(0,y.jsxs)(`div`,{className:`kyt-source-card`,children:[(0,y.jsxs)(`div`,{className:`kyt-card-header`,children:[(0,y.jsx)(`span`,{className:`kyt-card-type kyt-t-${t?`external`:`website`}`,children:t?`EXTERNAL`:`WEBSITE`}),(0,y.jsx)(`span`,{className:`kyt-card-label`,children:e.source_label.replace(/_/g,` `)})]}),(0,y.jsxs)(`div`,{className:`kyt-card-body`,children:[e.summary&&(0,y.jsx)(`div`,{className:`kyt-card-summary`,children:e.summary}),(0,y.jsx)(`div`,{className:`kyt-card-actions`,children:(0,y.jsx)(x,{url:n,label:r})})]})]})}function S({s:e}){let t=e.url||e.storage_url||void 0;return(0,y.jsxs)(`div`,{className:`kyt-source-card`,children:[(0,y.jsxs)(`div`,{className:`kyt-card-header`,children:[(0,y.jsx)(`span`,{className:`kyt-card-type kyt-t-pdf`,children:`PDF`}),(0,y.jsx)(`span`,{className:`kyt-card-label`,children:e.source_label.replace(/_/g,` `)})]}),(0,y.jsxs)(`div`,{className:`kyt-card-body`,children:[e.summary&&(0,y.jsx)(`div`,{className:`kyt-card-summary`,children:e.summary}),(0,y.jsxs)(`div`,{className:`kyt-card-actions`,children:[e.pdf_page!=null&&(0,y.jsxs)(`span`,{className:`kyt-pdf-page-badge`,children:[`πŸ“„ Page `,e.pdf_page]}),(0,y.jsx)(x,{url:t,label:e.pdf_page==null?`Open PDF`:`Open page ${e.pdf_page}`})]})]})]})}function C({s:e}){let t=e.start_time===null||e.start_time===void 0,n=t?0:e.start_time??0,r=e.drive_embed_url??``;r&&(r=r.split(`?`)[0].split(`#`)[0],!t&&n>0&&(r=r.includes(`drive.google.com`)?`${r}?start=${n}`:`${r}#t=${n}`));let i=r.includes(`drive.google.com`),a=t?`Watch video`:`Jump to ${b(n)}`;return(0,y.jsxs)(`div`,{className:`kyt-source-card`,children:[(0,y.jsxs)(`div`,{className:`kyt-card-header`,children:[(0,y.jsx)(`span`,{className:`kyt-card-type kyt-t-video`,children:`VIDEO`}),(0,y.jsx)(`span`,{className:`kyt-card-label`,children:e.source_label.replace(/_/g,` `)})]}),(0,y.jsxs)(`div`,{className:`kyt-card-body`,children:[r&&(0,y.jsx)(`div`,{className:`kyt-video-embed-wrapper`,children:i?(0,y.jsx)(`iframe`,{src:r,allowFullScreen:!0,loading:`lazy`,allow:`fullscreen`,style:{border:0}}):(0,y.jsx)(`video`,{controls:!0,preload:`none`,"data-start":!t&&n>0?n:void 0,children:(0,y.jsx)(`source`,{src:r})})}),(0,y.jsxs)(`div`,{className:`kyt-card-actions`,children:[!t&&n>0&&(0,y.jsxs)(`span`,{className:`kyt-timestamp-chip`,children:[`⏱ `,b(n)]}),(0,y.jsx)(x,{url:r||void 0,label:a}),e.url&&e.url!==r&&(0,y.jsx)(x,{url:e.url,label:`Go to source`})]}),e.content_snippet&&(0,y.jsxs)(`div`,{className:`kyt-transcript-snippet`,children:[`"`,e.content_snippet,`…"`]})]})]})}function te({s:e}){let t=e.storage_url??void 0,n=e.storage_url??e.url??``;return(0,y.jsxs)(`div`,{className:`kyt-source-card`,children:[(0,y.jsxs)(`div`,{className:`kyt-card-header`,children:[(0,y.jsx)(`span`,{className:`kyt-card-type kyt-t-social`,children:`IMAGE`}),(0,y.jsx)(`span`,{className:`kyt-card-label`,children:e.source_label.replace(/_/g,` `)})]}),(0,y.jsxs)(`div`,{className:`kyt-card-body`,children:[t&&(0,y.jsx)(`div`,{className:`kyt-card-img-wrap`,children:(0,y.jsx)(`img`,{src:t,alt:e.source_label})}),e.summary&&(0,y.jsx)(`div`,{className:`kyt-card-summary`,children:e.summary}),(0,y.jsx)(`div`,{className:`kyt-card-actions`,children:(0,y.jsx)(x,{url:n||void 0,label:`View image`})})]})]})}function ne({s:e}){let t=(e.source_label??``).toLowerCase(),n=t.includes(`x`)||t.includes(`twitter`)?`𝕏`:t.includes(`linkedin`)?`in`:`β—Ž`,r=e.content_snippet??e.summary??``;return(0,y.jsxs)(`div`,{className:`kyt-source-card`,children:[(0,y.jsxs)(`div`,{className:`kyt-card-header`,children:[(0,y.jsxs)(`span`,{className:`kyt-card-type kyt-t-social`,children:[n,` SOCIAL`]}),(0,y.jsx)(`span`,{className:`kyt-card-label`,children:e.source_label.replace(/_/g,` `)})]}),(0,y.jsxs)(`div`,{className:`kyt-card-body`,children:[r&&(0,y.jsx)(`div`,{className:`kyt-card-summary`,children:r}),(0,y.jsx)(`div`,{className:`kyt-card-actions`,children:(0,y.jsx)(x,{url:e.url,label:`View post`})})]})]})}function re({s:e}){return e.source_type===`video`?(0,y.jsx)(C,{s:e}):e.source_type===`pdf`?(0,y.jsx)(S,{s:e}):e.source_type===`image`?(0,y.jsx)(te,{s:e}):e.source_type===`social`?(0,y.jsx)(ne,{s:e}):(0,y.jsx)(ee,{s:e})}function w(e){return e.source_type===`video`?`video::${e.source_label}::${e.start_time??`desc`}`:e.source_type===`pdf`?`pdf::${e.source_label}::${e.pdf_page??`all`}`:e.source_type===`image`?`image::${e.storage_url??e.url??e.source_label}`:`${e.source_type}::${e.url??e.source_label}`}function ie(e){let t=new Set;return e.filter(e=>{let n=w(e);return t.has(n)?!1:(t.add(n),!0)})}function ae({sources:e,extra_sources:t=[]}){let[n,r]=(0,u.useState)(!1),i=ie(e),a=ie(t);return i.length?(0,y.jsxs)(`div`,{className:`kyt-sources-row`,children:[(0,y.jsxs)(`div`,{className:`kyt-sources-header`,children:[`Sources (`,i.length,a.length?`+`:``,`)`]}),(0,y.jsxs)(`div`,{className:`kyt-source-cards`,children:[i.map((e,t)=>(0,y.jsx)(re,{s:e},t)),a.length>0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`button`,{className:`kyt-extra-toggle`,onClick:()=>r(e=>!e),children:n?`Show less`:`+ ${a.length} more source${a.length>1?`s`:``}`}),n&&(0,y.jsx)(`div`,{className:`kyt-extra-cards`,children:a.map((e,t)=>(0,y.jsx)(re,{s:e},t))})]})]})]}):null}function oe(e){return e.replace(/\*\*(.*?)\*\*/g,`<strong>$1</strong>`).replace(/\n/g,`<br>`)}function se({config:e,onClose:t,showHeader:n=!0,bubbleMode:r=!1,pendingFaq:i,onFaqSent:a}){let{messages:o,loading:s,sendMessage:c,reset:l}=_(e),[d,f]=(0,u.useState)(``),p=(0,u.useRef)(null),m=(0,u.useRef)(null),h=e.theme??`dark`,g=e.faqs??[],v=e.title??`Ask anything`,b=e.placeholder??`Type your question…`,x=e.welcomeMessage??`Ask a question to get started.`,ee=e.avatarLabel??`AI`,S=e.hint??``;(0,u.useEffect)(()=>{p.current?.scrollIntoView({behavior:`smooth`})},[o,s]);let C=(0,u.useRef)(void 0);(0,u.useEffect)(()=>{i&&i!==C.current&&(C.current=i,c(i),a?.())},[i,c,a]);let te=()=>{!d.trim()||s||(c(d),f(``),m.current?.focus())},ne=e=>{c(e),f(``)};return(0,y.jsx)(`div`,{className:`kyt-root${h===`light`?` kyt-light`:``}`,style:{height:`100%`,display:`flex`,flexDirection:`column`},children:(0,y.jsxs)(`div`,{className:`kyt-page`,children:[n&&(0,y.jsxs)(`header`,{className:`kyt-header`,children:[(0,y.jsx)(`span`,{className:`kyt-header-title`,children:v}),(0,y.jsxs)(`div`,{className:`kyt-header-right`,children:[(0,y.jsxs)(`div`,{className:`kyt-live`,children:[(0,y.jsx)(`div`,{className:`kyt-live-dot`}),`Live`]}),(0,y.jsx)(`button`,{className:`kyt-hdr-btn`,onClick:l,title:`Clear chat`,"aria-label":`Clear chat`,children:(0,y.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`white`,children:(0,y.jsx)(`path`,{d:`M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z`})})}),t&&(0,y.jsx)(`button`,{className:`kyt-hdr-btn`,onClick:t,"aria-label":`Close chat`,children:(0,y.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`white`,children:(0,y.jsx)(`path`,{d:`M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z`})})})]})]}),(0,y.jsxs)(`div`,{className:`kyt-body`,children:[!r&&g.length>0&&(0,y.jsxs)(`aside`,{className:`kyt-sidebar`,children:[(0,y.jsx)(`div`,{className:`kyt-sidebar-label`,children:`Suggested Questions`}),(0,y.jsx)(`div`,{className:`kyt-faq-list`,children:g.map((e,t)=>(0,y.jsx)(`button`,{className:`kyt-faq-btn`,onClick:()=>ne(e),children:e},t))})]}),(0,y.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,overflow:`hidden`},children:[(0,y.jsxs)(`div`,{className:`kyt-messages`,children:[o.length===0&&(0,y.jsxs)(`div`,{className:`kyt-welcome`,children:[(0,y.jsx)(`div`,{className:`kyt-welcome-icon`,children:(0,y.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`28`,height:`28`,fill:`white`,children:(0,y.jsx)(`path`,{d:`M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-2 12H6v-2h12v2zm0-3H6V9h12v2zm0-3H6V6h12v2z`})})}),(0,y.jsx)(`h2`,{children:v}),(0,y.jsx)(`p`,{children:x})]}),o.map(e=>(0,y.jsx)(ce,{msg:e,avatarLabel:ee},e.id)),s&&(0,y.jsxs)(`div`,{className:`kyt-msg kyt-msg-assistant`,children:[(0,y.jsx)(`div`,{className:`kyt-avatar`,children:ee[0]}),(0,y.jsxs)(`div`,{className:`kyt-typing`,children:[(0,y.jsx)(`div`,{className:`kyt-dot`}),(0,y.jsx)(`div`,{className:`kyt-dot`}),(0,y.jsx)(`div`,{className:`kyt-dot`})]})]}),(0,y.jsx)(`div`,{ref:p})]}),(0,y.jsxs)(`div`,{className:`kyt-input-bar`,children:[(0,y.jsxs)(`div`,{className:`kyt-input-row`,children:[(0,y.jsx)(`input`,{ref:m,className:`kyt-input`,value:d,placeholder:b,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),te())},disabled:s}),(0,y.jsx)(`button`,{className:`kyt-send-btn`,onClick:te,disabled:s||!d.trim(),"aria-label":`Send`,children:(0,y.jsx)(`svg`,{viewBox:`0 0 24 24`,children:(0,y.jsx)(`path`,{d:`M2 21l21-9L2 3v7l15 2-15 2z`})})})]}),S&&(0,y.jsx)(`div`,{className:`kyt-hint`,children:S})]})]})]})]})})}function ce({msg:e,avatarLabel:t}){if(e.role===`user`)return(0,y.jsx)(`div`,{className:`kyt-msg kyt-msg-user`,children:(0,y.jsx)(`div`,{className:`kyt-bubble kyt-bubble-user`,dangerouslySetInnerHTML:{__html:oe(e.text)}})});let n=e.confidence===`high`?`kyt-conf kyt-conf-high`:e.confidence===`low`?`kyt-conf kyt-conf-low`:`kyt-conf kyt-conf-medium`;return(0,y.jsxs)(`div`,{className:`kyt-msg kyt-msg-assistant`,style:{flexDirection:`column`},children:[(0,y.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:10},children:[(0,y.jsx)(`div`,{className:`kyt-avatar`,children:t[0]}),(0,y.jsxs)(`div`,{className:`kyt-bubble kyt-bubble-assistant`,children:[(0,y.jsx)(`span`,{dangerouslySetInnerHTML:{__html:oe(e.text)}}),e.confidence&&(0,y.jsx)(`span`,{className:n,children:e.confidence.toUpperCase()})]})]}),e.sources&&e.sources.length>0&&(0,y.jsx)(ae,{sources:e.sources,extra_sources:e.extra_sources})]})}function le({config:e}){let[t,n]=(0,u.useState)(!1),[r,i]=(0,u.useState)(!1),[a,o]=(0,u.useState)(!1),[s,c]=(0,u.useState)(),l=e.primaryColor??`#1565c0`,d=e.faqs??[],{reset:f}=_(e);(0,u.useEffect)(()=>{p(l)},[l]);let m=()=>{n(!1),i(!1),o(!1)},h=e=>{c({text:e,id:Date.now()}),o(!1)};return(0,y.jsxs)(`div`,{className:`kyt-root`,children:[t&&r&&(0,y.jsx)(`div`,{className:`kyt-bubble-expanded-backdrop`,onClick:m}),t&&(0,y.jsxs)(`div`,{className:r?`kyt-bubble-expanded`:`kyt-bubble-compact`,children:[(0,y.jsxs)(`div`,{className:`kyt-bubble-header`,style:{background:l},children:[(0,y.jsx)(`span`,{className:`kyt-bubble-header-title`,children:e.title??`Ask anything`}),(0,y.jsxs)(`div`,{className:`kyt-bubble-header-actions`,children:[(0,y.jsxs)(`div`,{className:`kyt-live`,style:{marginRight:4},children:[(0,y.jsx)(`div`,{className:`kyt-live-dot`}),`Live`]}),(0,y.jsx)(`button`,{className:`kyt-hdr-btn`,onClick:f,title:`Clear chat`,"aria-label":`Clear chat`,children:(0,y.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`white`,children:(0,y.jsx)(`path`,{d:`M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z`})})}),d.length>0&&(0,y.jsx)(`button`,{className:`kyt-hdr-btn`,onClick:()=>o(e=>!e),title:`Suggested questions`,"aria-label":`Suggested questions`,children:`πŸ’‘`}),(0,y.jsx)(`button`,{className:`kyt-hdr-btn`,onClick:()=>i(e=>!e),title:r?`Compact`:`Expand`,"aria-label":r?`Compact`:`Expand`,children:r?(0,y.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`white`,children:(0,y.jsx)(`path`,{d:`M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z`})}):(0,y.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`white`,children:(0,y.jsx)(`path`,{d:`M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z`})})}),(0,y.jsx)(`button`,{className:`kyt-hdr-btn`,onClick:m,"aria-label":`Close chat`,children:(0,y.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`white`,children:(0,y.jsx)(`path`,{d:`M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z`})})})]})]}),(0,y.jsxs)(`div`,{style:{flex:1,overflow:`hidden`,display:`flex`,flexDirection:`column`,position:`relative`},children:[(0,y.jsx)(se,{config:e,showHeader:!1,bubbleMode:!0,pendingFaq:s?.text,onFaqSent:()=>c(void 0)}),a&&d.length>0&&(0,y.jsxs)(`div`,{className:`kyt-faq-drawer`,children:[(0,y.jsxs)(`div`,{className:`kyt-faq-drawer-header`,children:[(0,y.jsx)(`span`,{className:`kyt-faq-drawer-label`,children:`Suggested`}),(0,y.jsx)(`button`,{className:`kyt-faq-drawer-close`,onClick:()=>o(!1),"aria-label":`Close`,children:`βœ•`})]}),(0,y.jsx)(`div`,{className:`kyt-faq-drawer-list`,children:d.map((e,t)=>(0,y.jsx)(`button`,{className:`kyt-faq-drawer-btn`,onClick:()=>h(e),children:e},t))})]})]})]}),!r&&(0,y.jsx)(`button`,{className:`kyt-bubble-btn`,style:{background:l},onClick:()=>n(e=>!e),"aria-label":t?`Close chat`:`Open chat`,children:t?(0,y.jsx)(`svg`,{viewBox:`0 0 24 24`,children:(0,y.jsx)(`path`,{d:`M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z`})}):(0,y.jsx)(`svg`,{viewBox:`0 0 24 24`,children:(0,y.jsx)(`path`,{d:`M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-2 12H6v-2h12v2zm0-3H6V9h12v2zm0-3H6V6h12v2z`})})})]})}function ue({config:e,style:t,className:n}){return(0,u.useEffect)(()=>{p(e.primaryColor??`#1565c0`)},[e.primaryColor]),(0,y.jsx)(`div`,{style:{height:`100%`,width:`100%`,...t},className:n,children:(0,y.jsx)(se,{config:e,showHeader:!0})})}function T(e){let t=document.querySelector(e);if(!t)throw Error(`kyt-chat: no element found for selector "${e}"`);return t}function E(e,t){p(e.primaryColor??`#1565c0`),(0,l.createRoot)(T(t)).render((0,u.createElement)(le,{config:e}))}function de(e,t){p(e.primaryColor??`#1565c0`);let n=T(t);n.style.height=n.style.height||`100vh`,n.style.display=`flex`,n.style.flexDirection=`column`,(0,l.createRoot)(n).render((0,u.createElement)(ue,{config:e,style:{height:`100%`,flex:1}}))}function fe(e,t,n=`bubble`){n===`chat`?de(e,t):E(e,t)}return e.mount=fe,e.mountBubble=E,e.mountChat=de,e})({});
package/dist/kyt-chat.js CHANGED
@@ -8486,31 +8486,40 @@ function f(e) {
8486
8486
  function p() {
8487
8487
  return Math.random().toString(36).slice(2);
8488
8488
  }
8489
- function m(e) {
8490
- let [t, n] = (0, l.useState)([]), [r, i] = (0, l.useState)(!1), [a, o] = (0, l.useState)(null), s = (0, l.useRef)(null);
8489
+ var m = /* @__PURE__ */ new Map();
8490
+ function h(e) {
8491
+ return e.topicId ?? e.queryUrl;
8492
+ }
8493
+ function g(e) {
8494
+ let t = h(e), [n, r] = (0, l.useState)(() => m.get(t) ?? []), [i, a] = (0, l.useState)(!1), [o, s] = (0, l.useState)(null), c = (0, l.useRef)(null), u = (0, l.useCallback)((e) => {
8495
+ r((n) => {
8496
+ let r = e(n);
8497
+ return m.set(t, r), r;
8498
+ });
8499
+ }, [t]);
8491
8500
  return {
8492
- messages: t,
8493
- loading: r,
8494
- error: a,
8501
+ messages: n,
8502
+ loading: i,
8503
+ error: o,
8495
8504
  sendMessage: (0, l.useCallback)(async (t) => {
8496
- let a = t.trim();
8497
- if (!(!a || r)) {
8498
- o(null), n((e) => [...e, {
8505
+ let n = t.trim();
8506
+ if (!(!n || i)) {
8507
+ s(null), u((e) => [...e, {
8499
8508
  id: p(),
8500
8509
  role: "user",
8501
- text: a
8502
- }]), i(!0), s.current?.abort(), s.current = new AbortController();
8510
+ text: n
8511
+ }]), a(!0), c.current?.abort(), c.current = new AbortController();
8503
8512
  try {
8504
8513
  let t = await (await fetch(e.queryUrl, {
8505
8514
  method: "POST",
8506
8515
  headers: { "Content-Type": "application/json" },
8507
8516
  body: JSON.stringify({
8508
- input: a,
8517
+ input: n,
8509
8518
  ...e.topicId ? { topic_id: e.topicId } : {}
8510
8519
  }),
8511
- signal: s.current.signal
8520
+ signal: c.current.signal
8512
8521
  })).json();
8513
- n((e) => [...e, {
8522
+ u((e) => [...e, {
8514
8523
  id: p(),
8515
8524
  role: "assistant",
8516
8525
  text: t.answer ?? "No response.",
@@ -8521,25 +8530,25 @@ function m(e) {
8521
8530
  } catch (e) {
8522
8531
  if (e.name === "AbortError") return;
8523
8532
  let t = e instanceof Error ? e.message : "Something went wrong.";
8524
- o(t), n((e) => [...e, {
8533
+ s(t), u((e) => [...e, {
8525
8534
  id: p(),
8526
8535
  role: "assistant",
8527
8536
  text: t,
8528
8537
  confidence: "low"
8529
8538
  }]);
8530
8539
  } finally {
8531
- i(!1);
8540
+ a(!1);
8532
8541
  }
8533
8542
  }
8534
- }, [e, r]),
8543
+ }, [e, i]),
8535
8544
  reset: (0, l.useCallback)(() => {
8536
- s.current?.abort(), n([]), o(null), i(!1);
8537
- }, [])
8545
+ c.current?.abort(), m.delete(t), r([]), s(null), a(!1);
8546
+ }, [t])
8538
8547
  };
8539
8548
  }
8540
8549
  //#endregion
8541
8550
  //#region node_modules/react/cjs/react-jsx-runtime.production.js
8542
- var h = /* @__PURE__ */ e(((e) => {
8551
+ var _ = /* @__PURE__ */ e(((e) => {
8543
8552
  var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
8544
8553
  function r(e, n, r) {
8545
8554
  var i = null;
@@ -8554,20 +8563,20 @@ var h = /* @__PURE__ */ e(((e) => {
8554
8563
  };
8555
8564
  }
8556
8565
  e.Fragment = n, e.jsx = r, e.jsxs = r;
8557
- })), g = (/* @__PURE__ */ e(((e, t) => {
8558
- t.exports = h();
8566
+ })), v = (/* @__PURE__ */ e(((e, t) => {
8567
+ t.exports = _();
8559
8568
  })))();
8560
- function _(e) {
8569
+ function y(e) {
8561
8570
  let t = Math.floor(e);
8562
8571
  return `${Math.floor(t / 60)}:${String(t % 60).padStart(2, "0")}`;
8563
8572
  }
8564
- function v({ url: e, label: t }) {
8565
- return e ? /* @__PURE__ */ (0, g.jsxs)("a", {
8573
+ function b({ url: e, label: t }) {
8574
+ return e ? /* @__PURE__ */ (0, v.jsxs)("a", {
8566
8575
  className: "kyt-source-btn",
8567
8576
  href: e,
8568
8577
  target: "_blank",
8569
8578
  rel: "noopener noreferrer",
8570
- children: [/* @__PURE__ */ (0, g.jsxs)("svg", {
8579
+ children: [/* @__PURE__ */ (0, v.jsxs)("svg", {
8571
8580
  width: "11",
8572
8581
  height: "11",
8573
8582
  viewBox: "0 0 24 24",
@@ -8575,9 +8584,9 @@ function v({ url: e, label: t }) {
8575
8584
  stroke: "currentColor",
8576
8585
  strokeWidth: "2.5",
8577
8586
  children: [
8578
- /* @__PURE__ */ (0, g.jsx)("path", { d: "M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6" }),
8579
- /* @__PURE__ */ (0, g.jsx)("polyline", { points: "15 3 21 3 21 9" }),
8580
- /* @__PURE__ */ (0, g.jsx)("line", {
8587
+ /* @__PURE__ */ (0, v.jsx)("path", { d: "M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6" }),
8588
+ /* @__PURE__ */ (0, v.jsx)("polyline", { points: "15 3 21 3 21 9" }),
8589
+ /* @__PURE__ */ (0, v.jsx)("line", {
8581
8590
  x1: "10",
8582
8591
  y1: "14",
8583
8592
  x2: "21",
@@ -8587,27 +8596,27 @@ function v({ url: e, label: t }) {
8587
8596
  }), t]
8588
8597
  }) : null;
8589
8598
  }
8590
- function y({ s: e }) {
8599
+ function x({ s: e }) {
8591
8600
  let t = e.source_type === "external", n = e.url ?? "", r = n.includes("#") ? "Jump to section" : "Go to source";
8592
- return /* @__PURE__ */ (0, g.jsxs)("div", {
8601
+ return /* @__PURE__ */ (0, v.jsxs)("div", {
8593
8602
  className: "kyt-source-card",
8594
- children: [/* @__PURE__ */ (0, g.jsxs)("div", {
8603
+ children: [/* @__PURE__ */ (0, v.jsxs)("div", {
8595
8604
  className: "kyt-card-header",
8596
- children: [/* @__PURE__ */ (0, g.jsx)("span", {
8605
+ children: [/* @__PURE__ */ (0, v.jsx)("span", {
8597
8606
  className: `kyt-card-type kyt-t-${t ? "external" : "website"}`,
8598
8607
  children: t ? "EXTERNAL" : "WEBSITE"
8599
- }), /* @__PURE__ */ (0, g.jsx)("span", {
8608
+ }), /* @__PURE__ */ (0, v.jsx)("span", {
8600
8609
  className: "kyt-card-label",
8601
8610
  children: e.source_label.replace(/_/g, " ")
8602
8611
  })]
8603
- }), /* @__PURE__ */ (0, g.jsxs)("div", {
8612
+ }), /* @__PURE__ */ (0, v.jsxs)("div", {
8604
8613
  className: "kyt-card-body",
8605
- children: [e.summary && /* @__PURE__ */ (0, g.jsx)("div", {
8614
+ children: [e.summary && /* @__PURE__ */ (0, v.jsx)("div", {
8606
8615
  className: "kyt-card-summary",
8607
8616
  children: e.summary
8608
- }), /* @__PURE__ */ (0, g.jsx)("div", {
8617
+ }), /* @__PURE__ */ (0, v.jsx)("div", {
8609
8618
  className: "kyt-card-actions",
8610
- children: /* @__PURE__ */ (0, g.jsx)(v, {
8619
+ children: /* @__PURE__ */ (0, v.jsx)(b, {
8611
8620
  url: n,
8612
8621
  label: r
8613
8622
  })
@@ -8615,30 +8624,30 @@ function y({ s: e }) {
8615
8624
  })]
8616
8625
  });
8617
8626
  }
8618
- function b({ s: e }) {
8627
+ function ee({ s: e }) {
8619
8628
  let t = e.url || e.storage_url || void 0;
8620
- return /* @__PURE__ */ (0, g.jsxs)("div", {
8629
+ return /* @__PURE__ */ (0, v.jsxs)("div", {
8621
8630
  className: "kyt-source-card",
8622
- children: [/* @__PURE__ */ (0, g.jsxs)("div", {
8631
+ children: [/* @__PURE__ */ (0, v.jsxs)("div", {
8623
8632
  className: "kyt-card-header",
8624
- children: [/* @__PURE__ */ (0, g.jsx)("span", {
8633
+ children: [/* @__PURE__ */ (0, v.jsx)("span", {
8625
8634
  className: "kyt-card-type kyt-t-pdf",
8626
8635
  children: "PDF"
8627
- }), /* @__PURE__ */ (0, g.jsx)("span", {
8636
+ }), /* @__PURE__ */ (0, v.jsx)("span", {
8628
8637
  className: "kyt-card-label",
8629
8638
  children: e.source_label.replace(/_/g, " ")
8630
8639
  })]
8631
- }), /* @__PURE__ */ (0, g.jsxs)("div", {
8640
+ }), /* @__PURE__ */ (0, v.jsxs)("div", {
8632
8641
  className: "kyt-card-body",
8633
- children: [e.summary && /* @__PURE__ */ (0, g.jsx)("div", {
8642
+ children: [e.summary && /* @__PURE__ */ (0, v.jsx)("div", {
8634
8643
  className: "kyt-card-summary",
8635
8644
  children: e.summary
8636
- }), /* @__PURE__ */ (0, g.jsxs)("div", {
8645
+ }), /* @__PURE__ */ (0, v.jsxs)("div", {
8637
8646
  className: "kyt-card-actions",
8638
- children: [e.pdf_page != null && /* @__PURE__ */ (0, g.jsxs)("span", {
8647
+ children: [e.pdf_page != null && /* @__PURE__ */ (0, v.jsxs)("span", {
8639
8648
  className: "kyt-pdf-page-badge",
8640
8649
  children: ["πŸ“„ Page ", e.pdf_page]
8641
- }), /* @__PURE__ */ (0, g.jsx)(v, {
8650
+ }), /* @__PURE__ */ (0, v.jsx)(b, {
8642
8651
  url: t,
8643
8652
  label: e.pdf_page == null ? "Open PDF" : `Open page ${e.pdf_page}`
8644
8653
  })]
@@ -8646,57 +8655,57 @@ function b({ s: e }) {
8646
8655
  })]
8647
8656
  });
8648
8657
  }
8649
- function x({ s: e }) {
8658
+ function S({ s: e }) {
8650
8659
  let t = e.start_time === null || e.start_time === void 0, n = t ? 0 : e.start_time ?? 0, r = e.drive_embed_url ?? "";
8651
8660
  r && (r = r.split("?")[0].split("#")[0], !t && n > 0 && (r = r.includes("drive.google.com") ? `${r}?start=${n}` : `${r}#t=${n}`));
8652
- let i = r.includes("drive.google.com"), a = t ? "Watch video" : `Jump to ${_(n)}`;
8653
- return /* @__PURE__ */ (0, g.jsxs)("div", {
8661
+ let i = r.includes("drive.google.com"), a = t ? "Watch video" : `Jump to ${y(n)}`;
8662
+ return /* @__PURE__ */ (0, v.jsxs)("div", {
8654
8663
  className: "kyt-source-card",
8655
- children: [/* @__PURE__ */ (0, g.jsxs)("div", {
8664
+ children: [/* @__PURE__ */ (0, v.jsxs)("div", {
8656
8665
  className: "kyt-card-header",
8657
- children: [/* @__PURE__ */ (0, g.jsx)("span", {
8666
+ children: [/* @__PURE__ */ (0, v.jsx)("span", {
8658
8667
  className: "kyt-card-type kyt-t-video",
8659
8668
  children: "VIDEO"
8660
- }), /* @__PURE__ */ (0, g.jsx)("span", {
8669
+ }), /* @__PURE__ */ (0, v.jsx)("span", {
8661
8670
  className: "kyt-card-label",
8662
8671
  children: e.source_label.replace(/_/g, " ")
8663
8672
  })]
8664
- }), /* @__PURE__ */ (0, g.jsxs)("div", {
8673
+ }), /* @__PURE__ */ (0, v.jsxs)("div", {
8665
8674
  className: "kyt-card-body",
8666
8675
  children: [
8667
- r && /* @__PURE__ */ (0, g.jsx)("div", {
8676
+ r && /* @__PURE__ */ (0, v.jsx)("div", {
8668
8677
  className: "kyt-video-embed-wrapper",
8669
- children: i ? /* @__PURE__ */ (0, g.jsx)("iframe", {
8678
+ children: i ? /* @__PURE__ */ (0, v.jsx)("iframe", {
8670
8679
  src: r,
8671
8680
  allowFullScreen: !0,
8672
8681
  loading: "lazy",
8673
8682
  allow: "fullscreen",
8674
8683
  style: { border: 0 }
8675
- }) : /* @__PURE__ */ (0, g.jsx)("video", {
8684
+ }) : /* @__PURE__ */ (0, v.jsx)("video", {
8676
8685
  controls: !0,
8677
8686
  preload: "none",
8678
8687
  "data-start": !t && n > 0 ? n : void 0,
8679
- children: /* @__PURE__ */ (0, g.jsx)("source", { src: r })
8688
+ children: /* @__PURE__ */ (0, v.jsx)("source", { src: r })
8680
8689
  })
8681
8690
  }),
8682
- /* @__PURE__ */ (0, g.jsxs)("div", {
8691
+ /* @__PURE__ */ (0, v.jsxs)("div", {
8683
8692
  className: "kyt-card-actions",
8684
8693
  children: [
8685
- !t && n > 0 && /* @__PURE__ */ (0, g.jsxs)("span", {
8694
+ !t && n > 0 && /* @__PURE__ */ (0, v.jsxs)("span", {
8686
8695
  className: "kyt-timestamp-chip",
8687
- children: ["⏱ ", _(n)]
8696
+ children: ["⏱ ", y(n)]
8688
8697
  }),
8689
- /* @__PURE__ */ (0, g.jsx)(v, {
8698
+ /* @__PURE__ */ (0, v.jsx)(b, {
8690
8699
  url: r || void 0,
8691
8700
  label: a
8692
8701
  }),
8693
- e.url && e.url !== r && /* @__PURE__ */ (0, g.jsx)(v, {
8702
+ e.url && e.url !== r && /* @__PURE__ */ (0, v.jsx)(b, {
8694
8703
  url: e.url,
8695
8704
  label: "Go to source"
8696
8705
  })
8697
8706
  ]
8698
8707
  }),
8699
- e.content_snippet && /* @__PURE__ */ (0, g.jsxs)("div", {
8708
+ e.content_snippet && /* @__PURE__ */ (0, v.jsxs)("div", {
8700
8709
  className: "kyt-transcript-snippet",
8701
8710
  children: [
8702
8711
  "\"",
@@ -8708,36 +8717,36 @@ function x({ s: e }) {
8708
8717
  })]
8709
8718
  });
8710
8719
  }
8711
- function ee({ s: e }) {
8720
+ function C({ s: e }) {
8712
8721
  let t = e.storage_url ?? void 0, n = e.storage_url ?? e.url ?? "";
8713
- return /* @__PURE__ */ (0, g.jsxs)("div", {
8722
+ return /* @__PURE__ */ (0, v.jsxs)("div", {
8714
8723
  className: "kyt-source-card",
8715
- children: [/* @__PURE__ */ (0, g.jsxs)("div", {
8724
+ children: [/* @__PURE__ */ (0, v.jsxs)("div", {
8716
8725
  className: "kyt-card-header",
8717
- children: [/* @__PURE__ */ (0, g.jsx)("span", {
8726
+ children: [/* @__PURE__ */ (0, v.jsx)("span", {
8718
8727
  className: "kyt-card-type kyt-t-social",
8719
8728
  children: "IMAGE"
8720
- }), /* @__PURE__ */ (0, g.jsx)("span", {
8729
+ }), /* @__PURE__ */ (0, v.jsx)("span", {
8721
8730
  className: "kyt-card-label",
8722
8731
  children: e.source_label.replace(/_/g, " ")
8723
8732
  })]
8724
- }), /* @__PURE__ */ (0, g.jsxs)("div", {
8733
+ }), /* @__PURE__ */ (0, v.jsxs)("div", {
8725
8734
  className: "kyt-card-body",
8726
8735
  children: [
8727
- t && /* @__PURE__ */ (0, g.jsx)("div", {
8736
+ t && /* @__PURE__ */ (0, v.jsx)("div", {
8728
8737
  className: "kyt-card-img-wrap",
8729
- children: /* @__PURE__ */ (0, g.jsx)("img", {
8738
+ children: /* @__PURE__ */ (0, v.jsx)("img", {
8730
8739
  src: t,
8731
8740
  alt: e.source_label
8732
8741
  })
8733
8742
  }),
8734
- e.summary && /* @__PURE__ */ (0, g.jsx)("div", {
8743
+ e.summary && /* @__PURE__ */ (0, v.jsx)("div", {
8735
8744
  className: "kyt-card-summary",
8736
8745
  children: e.summary
8737
8746
  }),
8738
- /* @__PURE__ */ (0, g.jsx)("div", {
8747
+ /* @__PURE__ */ (0, v.jsx)("div", {
8739
8748
  className: "kyt-card-actions",
8740
- children: /* @__PURE__ */ (0, g.jsx)(v, {
8749
+ children: /* @__PURE__ */ (0, v.jsx)(b, {
8741
8750
  url: n || void 0,
8742
8751
  label: "View image"
8743
8752
  })
@@ -8746,27 +8755,27 @@ function ee({ s: e }) {
8746
8755
  })]
8747
8756
  });
8748
8757
  }
8749
- function S({ s: e }) {
8758
+ function te({ s: e }) {
8750
8759
  let t = (e.source_label ?? "").toLowerCase(), n = t.includes("x") || t.includes("twitter") ? "𝕏" : t.includes("linkedin") ? "in" : "β—Ž", r = e.content_snippet ?? e.summary ?? "";
8751
- return /* @__PURE__ */ (0, g.jsxs)("div", {
8760
+ return /* @__PURE__ */ (0, v.jsxs)("div", {
8752
8761
  className: "kyt-source-card",
8753
- children: [/* @__PURE__ */ (0, g.jsxs)("div", {
8762
+ children: [/* @__PURE__ */ (0, v.jsxs)("div", {
8754
8763
  className: "kyt-card-header",
8755
- children: [/* @__PURE__ */ (0, g.jsxs)("span", {
8764
+ children: [/* @__PURE__ */ (0, v.jsxs)("span", {
8756
8765
  className: "kyt-card-type kyt-t-social",
8757
8766
  children: [n, " SOCIAL"]
8758
- }), /* @__PURE__ */ (0, g.jsx)("span", {
8767
+ }), /* @__PURE__ */ (0, v.jsx)("span", {
8759
8768
  className: "kyt-card-label",
8760
8769
  children: e.source_label.replace(/_/g, " ")
8761
8770
  })]
8762
- }), /* @__PURE__ */ (0, g.jsxs)("div", {
8771
+ }), /* @__PURE__ */ (0, v.jsxs)("div", {
8763
8772
  className: "kyt-card-body",
8764
- children: [r && /* @__PURE__ */ (0, g.jsx)("div", {
8773
+ children: [r && /* @__PURE__ */ (0, v.jsx)("div", {
8765
8774
  className: "kyt-card-summary",
8766
8775
  children: r
8767
- }), /* @__PURE__ */ (0, g.jsx)("div", {
8776
+ }), /* @__PURE__ */ (0, v.jsx)("div", {
8768
8777
  className: "kyt-card-actions",
8769
- children: /* @__PURE__ */ (0, g.jsx)(v, {
8778
+ children: /* @__PURE__ */ (0, v.jsx)(b, {
8770
8779
  url: e.url,
8771
8780
  label: "View post"
8772
8781
  })
@@ -8774,24 +8783,24 @@ function S({ s: e }) {
8774
8783
  })]
8775
8784
  });
8776
8785
  }
8777
- function C({ s: e }) {
8778
- return e.source_type === "video" ? /* @__PURE__ */ (0, g.jsx)(x, { s: e }) : e.source_type === "pdf" ? /* @__PURE__ */ (0, g.jsx)(b, { s: e }) : e.source_type === "image" ? /* @__PURE__ */ (0, g.jsx)(ee, { s: e }) : e.source_type === "social" ? /* @__PURE__ */ (0, g.jsx)(S, { s: e }) : /* @__PURE__ */ (0, g.jsx)(y, { s: e });
8786
+ function ne({ s: e }) {
8787
+ return e.source_type === "video" ? /* @__PURE__ */ (0, v.jsx)(S, { s: e }) : e.source_type === "pdf" ? /* @__PURE__ */ (0, v.jsx)(ee, { s: e }) : e.source_type === "image" ? /* @__PURE__ */ (0, v.jsx)(C, { s: e }) : e.source_type === "social" ? /* @__PURE__ */ (0, v.jsx)(te, { s: e }) : /* @__PURE__ */ (0, v.jsx)(x, { s: e });
8779
8788
  }
8780
- function te(e) {
8789
+ function re(e) {
8781
8790
  return e.source_type === "video" ? `video::${e.source_label}::${e.start_time ?? "desc"}` : e.source_type === "pdf" ? `pdf::${e.source_label}::${e.pdf_page ?? "all"}` : e.source_type === "image" ? `image::${e.storage_url ?? e.url ?? e.source_label}` : `${e.source_type}::${e.url ?? e.source_label}`;
8782
8791
  }
8783
- function ne(e) {
8792
+ function w(e) {
8784
8793
  let t = /* @__PURE__ */ new Set();
8785
8794
  return e.filter((e) => {
8786
- let n = te(e);
8795
+ let n = re(e);
8787
8796
  return t.has(n) ? !1 : (t.add(n), !0);
8788
8797
  });
8789
8798
  }
8790
- function re({ sources: e, extra_sources: t = [] }) {
8791
- let [n, r] = (0, l.useState)(!1), i = ne(e), a = ne(t);
8792
- return i.length ? /* @__PURE__ */ (0, g.jsxs)("div", {
8799
+ function ie({ sources: e, extra_sources: t = [] }) {
8800
+ let [n, r] = (0, l.useState)(!1), i = w(e), a = w(t);
8801
+ return i.length ? /* @__PURE__ */ (0, v.jsxs)("div", {
8793
8802
  className: "kyt-sources-row",
8794
- children: [/* @__PURE__ */ (0, g.jsxs)("div", {
8803
+ children: [/* @__PURE__ */ (0, v.jsxs)("div", {
8795
8804
  className: "kyt-sources-header",
8796
8805
  children: [
8797
8806
  "Sources (",
@@ -8799,163 +8808,179 @@ function re({ sources: e, extra_sources: t = [] }) {
8799
8808
  a.length ? "+" : "",
8800
8809
  ")"
8801
8810
  ]
8802
- }), /* @__PURE__ */ (0, g.jsxs)("div", {
8811
+ }), /* @__PURE__ */ (0, v.jsxs)("div", {
8803
8812
  className: "kyt-source-cards",
8804
- children: [i.map((e, t) => /* @__PURE__ */ (0, g.jsx)(C, { s: e }, t)), a.length > 0 && /* @__PURE__ */ (0, g.jsxs)(g.Fragment, { children: [/* @__PURE__ */ (0, g.jsx)("button", {
8813
+ children: [i.map((e, t) => /* @__PURE__ */ (0, v.jsx)(ne, { s: e }, t)), a.length > 0 && /* @__PURE__ */ (0, v.jsxs)(v.Fragment, { children: [/* @__PURE__ */ (0, v.jsx)("button", {
8805
8814
  className: "kyt-extra-toggle",
8806
8815
  onClick: () => r((e) => !e),
8807
8816
  children: n ? "Show less" : `+ ${a.length} more source${a.length > 1 ? "s" : ""}`
8808
- }), n && /* @__PURE__ */ (0, g.jsx)("div", {
8817
+ }), n && /* @__PURE__ */ (0, v.jsx)("div", {
8809
8818
  className: "kyt-extra-cards",
8810
- children: a.map((e, t) => /* @__PURE__ */ (0, g.jsx)(C, { s: e }, t))
8819
+ children: a.map((e, t) => /* @__PURE__ */ (0, v.jsx)(ne, { s: e }, t))
8811
8820
  })] })]
8812
8821
  })]
8813
8822
  }) : null;
8814
8823
  }
8815
8824
  //#endregion
8816
8825
  //#region ../../src/components/ChatCore.tsx
8817
- function w(e) {
8826
+ function ae(e) {
8818
8827
  return e.replace(/\*\*(.*?)\*\*/g, "<strong>$1</strong>").replace(/\n/g, "<br>");
8819
8828
  }
8820
- function ie({ config: e, onClose: t, showHeader: n = !0, bubbleMode: r = !1, pendingFaq: i, onFaqSent: a }) {
8821
- let { messages: o, loading: s, sendMessage: c } = m(e), [u, d] = (0, l.useState)(""), f = (0, l.useRef)(null), p = (0, l.useRef)(null), h = e.theme ?? "dark", _ = e.faqs ?? [], v = e.title ?? "Ask anything", y = e.placeholder ?? "Type your question…", b = e.welcomeMessage ?? "Ask a question to get started.", x = e.avatarLabel ?? "AI", ee = e.hint ?? "";
8829
+ function oe({ config: e, onClose: t, showHeader: n = !0, bubbleMode: r = !1, pendingFaq: i, onFaqSent: a }) {
8830
+ let { messages: o, loading: s, sendMessage: c, reset: u } = g(e), [d, f] = (0, l.useState)(""), p = (0, l.useRef)(null), m = (0, l.useRef)(null), h = e.theme ?? "dark", _ = e.faqs ?? [], y = e.title ?? "Ask anything", b = e.placeholder ?? "Type your question…", x = e.welcomeMessage ?? "Ask a question to get started.", ee = e.avatarLabel ?? "AI", S = e.hint ?? "";
8822
8831
  (0, l.useEffect)(() => {
8823
- f.current?.scrollIntoView({ behavior: "smooth" });
8832
+ p.current?.scrollIntoView({ behavior: "smooth" });
8824
8833
  }, [o, s]);
8825
- let S = (0, l.useRef)(void 0);
8834
+ let C = (0, l.useRef)(void 0);
8826
8835
  (0, l.useEffect)(() => {
8827
- i && i !== S.current && (S.current = i, c(i), a?.());
8836
+ i && i !== C.current && (C.current = i, c(i), a?.());
8828
8837
  }, [
8829
8838
  i,
8830
8839
  c,
8831
8840
  a
8832
8841
  ]);
8833
- let C = () => {
8834
- !u.trim() || s || (c(u), d(""), p.current?.focus());
8835
- }, te = (e) => {
8836
- c(e), d("");
8842
+ let te = () => {
8843
+ !d.trim() || s || (c(d), f(""), m.current?.focus());
8844
+ }, ne = (e) => {
8845
+ c(e), f("");
8837
8846
  };
8838
- return /* @__PURE__ */ (0, g.jsx)("div", {
8847
+ return /* @__PURE__ */ (0, v.jsx)("div", {
8839
8848
  className: `kyt-root${h === "light" ? " kyt-light" : ""}`,
8840
8849
  style: {
8841
8850
  height: "100%",
8842
8851
  display: "flex",
8843
8852
  flexDirection: "column"
8844
8853
  },
8845
- children: /* @__PURE__ */ (0, g.jsxs)("div", {
8854
+ children: /* @__PURE__ */ (0, v.jsxs)("div", {
8846
8855
  className: "kyt-page",
8847
- children: [n && /* @__PURE__ */ (0, g.jsxs)("header", {
8856
+ children: [n && /* @__PURE__ */ (0, v.jsxs)("header", {
8848
8857
  className: "kyt-header",
8849
- children: [/* @__PURE__ */ (0, g.jsx)("span", {
8858
+ children: [/* @__PURE__ */ (0, v.jsx)("span", {
8850
8859
  className: "kyt-header-title",
8851
- children: v
8852
- }), /* @__PURE__ */ (0, g.jsxs)("div", {
8860
+ children: y
8861
+ }), /* @__PURE__ */ (0, v.jsxs)("div", {
8853
8862
  className: "kyt-header-right",
8854
- children: [/* @__PURE__ */ (0, g.jsxs)("div", {
8855
- className: "kyt-live",
8856
- children: [/* @__PURE__ */ (0, g.jsx)("div", { className: "kyt-live-dot" }), "Live"]
8857
- }), t && /* @__PURE__ */ (0, g.jsx)("button", {
8858
- className: "kyt-hdr-btn",
8859
- onClick: t,
8860
- "aria-label": "Close chat",
8861
- children: /* @__PURE__ */ (0, g.jsx)("svg", {
8862
- viewBox: "0 0 24 24",
8863
- width: "14",
8864
- height: "14",
8865
- fill: "white",
8866
- children: /* @__PURE__ */ (0, g.jsx)("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" })
8863
+ children: [
8864
+ /* @__PURE__ */ (0, v.jsxs)("div", {
8865
+ className: "kyt-live",
8866
+ children: [/* @__PURE__ */ (0, v.jsx)("div", { className: "kyt-live-dot" }), "Live"]
8867
+ }),
8868
+ /* @__PURE__ */ (0, v.jsx)("button", {
8869
+ className: "kyt-hdr-btn",
8870
+ onClick: u,
8871
+ title: "Clear chat",
8872
+ "aria-label": "Clear chat",
8873
+ children: /* @__PURE__ */ (0, v.jsx)("svg", {
8874
+ viewBox: "0 0 24 24",
8875
+ width: "14",
8876
+ height: "14",
8877
+ fill: "white",
8878
+ children: /* @__PURE__ */ (0, v.jsx)("path", { d: "M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z" })
8879
+ })
8880
+ }),
8881
+ t && /* @__PURE__ */ (0, v.jsx)("button", {
8882
+ className: "kyt-hdr-btn",
8883
+ onClick: t,
8884
+ "aria-label": "Close chat",
8885
+ children: /* @__PURE__ */ (0, v.jsx)("svg", {
8886
+ viewBox: "0 0 24 24",
8887
+ width: "14",
8888
+ height: "14",
8889
+ fill: "white",
8890
+ children: /* @__PURE__ */ (0, v.jsx)("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" })
8891
+ })
8867
8892
  })
8868
- })]
8893
+ ]
8869
8894
  })]
8870
- }), /* @__PURE__ */ (0, g.jsxs)("div", {
8895
+ }), /* @__PURE__ */ (0, v.jsxs)("div", {
8871
8896
  className: "kyt-body",
8872
- children: [!r && _.length > 0 && /* @__PURE__ */ (0, g.jsxs)("aside", {
8897
+ children: [!r && _.length > 0 && /* @__PURE__ */ (0, v.jsxs)("aside", {
8873
8898
  className: "kyt-sidebar",
8874
- children: [/* @__PURE__ */ (0, g.jsx)("div", {
8899
+ children: [/* @__PURE__ */ (0, v.jsx)("div", {
8875
8900
  className: "kyt-sidebar-label",
8876
8901
  children: "Suggested Questions"
8877
- }), /* @__PURE__ */ (0, g.jsx)("div", {
8902
+ }), /* @__PURE__ */ (0, v.jsx)("div", {
8878
8903
  className: "kyt-faq-list",
8879
- children: _.map((e, t) => /* @__PURE__ */ (0, g.jsx)("button", {
8904
+ children: _.map((e, t) => /* @__PURE__ */ (0, v.jsx)("button", {
8880
8905
  className: "kyt-faq-btn",
8881
- onClick: () => te(e),
8906
+ onClick: () => ne(e),
8882
8907
  children: e
8883
8908
  }, t))
8884
8909
  })]
8885
- }), /* @__PURE__ */ (0, g.jsxs)("div", {
8910
+ }), /* @__PURE__ */ (0, v.jsxs)("div", {
8886
8911
  style: {
8887
8912
  flex: 1,
8888
8913
  display: "flex",
8889
8914
  flexDirection: "column",
8890
8915
  overflow: "hidden"
8891
8916
  },
8892
- children: [/* @__PURE__ */ (0, g.jsxs)("div", {
8917
+ children: [/* @__PURE__ */ (0, v.jsxs)("div", {
8893
8918
  className: "kyt-messages",
8894
8919
  children: [
8895
- o.length === 0 && /* @__PURE__ */ (0, g.jsxs)("div", {
8920
+ o.length === 0 && /* @__PURE__ */ (0, v.jsxs)("div", {
8896
8921
  className: "kyt-welcome",
8897
8922
  children: [
8898
- /* @__PURE__ */ (0, g.jsx)("div", {
8923
+ /* @__PURE__ */ (0, v.jsx)("div", {
8899
8924
  className: "kyt-welcome-icon",
8900
- children: /* @__PURE__ */ (0, g.jsx)("svg", {
8925
+ children: /* @__PURE__ */ (0, v.jsx)("svg", {
8901
8926
  viewBox: "0 0 24 24",
8902
8927
  width: "28",
8903
8928
  height: "28",
8904
8929
  fill: "white",
8905
- children: /* @__PURE__ */ (0, g.jsx)("path", { d: "M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-2 12H6v-2h12v2zm0-3H6V9h12v2zm0-3H6V6h12v2z" })
8930
+ children: /* @__PURE__ */ (0, v.jsx)("path", { d: "M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-2 12H6v-2h12v2zm0-3H6V9h12v2zm0-3H6V6h12v2z" })
8906
8931
  })
8907
8932
  }),
8908
- /* @__PURE__ */ (0, g.jsx)("h2", { children: v }),
8909
- /* @__PURE__ */ (0, g.jsx)("p", { children: b })
8933
+ /* @__PURE__ */ (0, v.jsx)("h2", { children: y }),
8934
+ /* @__PURE__ */ (0, v.jsx)("p", { children: x })
8910
8935
  ]
8911
8936
  }),
8912
- o.map((e) => /* @__PURE__ */ (0, g.jsx)(ae, {
8937
+ o.map((e) => /* @__PURE__ */ (0, v.jsx)(se, {
8913
8938
  msg: e,
8914
- avatarLabel: x
8939
+ avatarLabel: ee
8915
8940
  }, e.id)),
8916
- s && /* @__PURE__ */ (0, g.jsxs)("div", {
8941
+ s && /* @__PURE__ */ (0, v.jsxs)("div", {
8917
8942
  className: "kyt-msg kyt-msg-assistant",
8918
- children: [/* @__PURE__ */ (0, g.jsx)("div", {
8943
+ children: [/* @__PURE__ */ (0, v.jsx)("div", {
8919
8944
  className: "kyt-avatar",
8920
- children: x[0]
8921
- }), /* @__PURE__ */ (0, g.jsxs)("div", {
8945
+ children: ee[0]
8946
+ }), /* @__PURE__ */ (0, v.jsxs)("div", {
8922
8947
  className: "kyt-typing",
8923
8948
  children: [
8924
- /* @__PURE__ */ (0, g.jsx)("div", { className: "kyt-dot" }),
8925
- /* @__PURE__ */ (0, g.jsx)("div", { className: "kyt-dot" }),
8926
- /* @__PURE__ */ (0, g.jsx)("div", { className: "kyt-dot" })
8949
+ /* @__PURE__ */ (0, v.jsx)("div", { className: "kyt-dot" }),
8950
+ /* @__PURE__ */ (0, v.jsx)("div", { className: "kyt-dot" }),
8951
+ /* @__PURE__ */ (0, v.jsx)("div", { className: "kyt-dot" })
8927
8952
  ]
8928
8953
  })]
8929
8954
  }),
8930
- /* @__PURE__ */ (0, g.jsx)("div", { ref: f })
8955
+ /* @__PURE__ */ (0, v.jsx)("div", { ref: p })
8931
8956
  ]
8932
- }), /* @__PURE__ */ (0, g.jsxs)("div", {
8957
+ }), /* @__PURE__ */ (0, v.jsxs)("div", {
8933
8958
  className: "kyt-input-bar",
8934
- children: [/* @__PURE__ */ (0, g.jsxs)("div", {
8959
+ children: [/* @__PURE__ */ (0, v.jsxs)("div", {
8935
8960
  className: "kyt-input-row",
8936
- children: [/* @__PURE__ */ (0, g.jsx)("input", {
8937
- ref: p,
8961
+ children: [/* @__PURE__ */ (0, v.jsx)("input", {
8962
+ ref: m,
8938
8963
  className: "kyt-input",
8939
- value: u,
8940
- placeholder: y,
8941
- onChange: (e) => d(e.target.value),
8964
+ value: d,
8965
+ placeholder: b,
8966
+ onChange: (e) => f(e.target.value),
8942
8967
  onKeyDown: (e) => {
8943
- e.key === "Enter" && !e.shiftKey && (e.preventDefault(), C());
8968
+ e.key === "Enter" && !e.shiftKey && (e.preventDefault(), te());
8944
8969
  },
8945
8970
  disabled: s
8946
- }), /* @__PURE__ */ (0, g.jsx)("button", {
8971
+ }), /* @__PURE__ */ (0, v.jsx)("button", {
8947
8972
  className: "kyt-send-btn",
8948
- onClick: C,
8949
- disabled: s || !u.trim(),
8973
+ onClick: te,
8974
+ disabled: s || !d.trim(),
8950
8975
  "aria-label": "Send",
8951
- children: /* @__PURE__ */ (0, g.jsx)("svg", {
8976
+ children: /* @__PURE__ */ (0, v.jsx)("svg", {
8952
8977
  viewBox: "0 0 24 24",
8953
- children: /* @__PURE__ */ (0, g.jsx)("path", { d: "M2 21l21-9L2 3v7l15 2-15 2z" })
8978
+ children: /* @__PURE__ */ (0, v.jsx)("path", { d: "M2 21l21-9L2 3v7l15 2-15 2z" })
8954
8979
  })
8955
8980
  })]
8956
- }), ee && /* @__PURE__ */ (0, g.jsx)("div", {
8981
+ }), S && /* @__PURE__ */ (0, v.jsx)("div", {
8957
8982
  className: "kyt-hint",
8958
- children: ee
8983
+ children: S
8959
8984
  })]
8960
8985
  })]
8961
8986
  })]
@@ -8963,35 +8988,35 @@ function ie({ config: e, onClose: t, showHeader: n = !0, bubbleMode: r = !1, pen
8963
8988
  })
8964
8989
  });
8965
8990
  }
8966
- function ae({ msg: e, avatarLabel: t }) {
8967
- if (e.role === "user") return /* @__PURE__ */ (0, g.jsx)("div", {
8991
+ function se({ msg: e, avatarLabel: t }) {
8992
+ if (e.role === "user") return /* @__PURE__ */ (0, v.jsx)("div", {
8968
8993
  className: "kyt-msg kyt-msg-user",
8969
- children: /* @__PURE__ */ (0, g.jsx)("div", {
8994
+ children: /* @__PURE__ */ (0, v.jsx)("div", {
8970
8995
  className: "kyt-bubble kyt-bubble-user",
8971
- dangerouslySetInnerHTML: { __html: w(e.text) }
8996
+ dangerouslySetInnerHTML: { __html: ae(e.text) }
8972
8997
  })
8973
8998
  });
8974
8999
  let n = e.confidence === "high" ? "kyt-conf kyt-conf-high" : e.confidence === "low" ? "kyt-conf kyt-conf-low" : "kyt-conf kyt-conf-medium";
8975
- return /* @__PURE__ */ (0, g.jsxs)("div", {
9000
+ return /* @__PURE__ */ (0, v.jsxs)("div", {
8976
9001
  className: "kyt-msg kyt-msg-assistant",
8977
9002
  style: { flexDirection: "column" },
8978
- children: [/* @__PURE__ */ (0, g.jsxs)("div", {
9003
+ children: [/* @__PURE__ */ (0, v.jsxs)("div", {
8979
9004
  style: {
8980
9005
  display: "flex",
8981
9006
  alignItems: "flex-start",
8982
9007
  gap: 10
8983
9008
  },
8984
- children: [/* @__PURE__ */ (0, g.jsx)("div", {
9009
+ children: [/* @__PURE__ */ (0, v.jsx)("div", {
8985
9010
  className: "kyt-avatar",
8986
9011
  children: t[0]
8987
- }), /* @__PURE__ */ (0, g.jsxs)("div", {
9012
+ }), /* @__PURE__ */ (0, v.jsxs)("div", {
8988
9013
  className: "kyt-bubble kyt-bubble-assistant",
8989
- children: [/* @__PURE__ */ (0, g.jsx)("span", { dangerouslySetInnerHTML: { __html: w(e.text) } }), e.confidence && /* @__PURE__ */ (0, g.jsx)("span", {
9014
+ children: [/* @__PURE__ */ (0, v.jsx)("span", { dangerouslySetInnerHTML: { __html: ae(e.text) } }), e.confidence && /* @__PURE__ */ (0, v.jsx)("span", {
8990
9015
  className: n,
8991
9016
  children: e.confidence.toUpperCase()
8992
9017
  })]
8993
9018
  })]
8994
- }), e.sources && e.sources.length > 0 && /* @__PURE__ */ (0, g.jsx)(re, {
9019
+ }), e.sources && e.sources.length > 0 && /* @__PURE__ */ (0, v.jsx)(ie, {
8995
9020
  sources: e.sources,
8996
9021
  extra_sources: e.extra_sources
8997
9022
  })]
@@ -8999,83 +9024,96 @@ function ae({ msg: e, avatarLabel: t }) {
8999
9024
  }
9000
9025
  //#endregion
9001
9026
  //#region ../../src/components/KytChatBubble.tsx
9002
- function oe({ config: e }) {
9003
- let [t, n] = (0, l.useState)(!1), [r, i] = (0, l.useState)(!1), [a, o] = (0, l.useState)(!1), [s, c] = (0, l.useState)(), u = e.primaryColor ?? "#1565c0", d = e.faqs ?? [];
9027
+ function ce({ config: e }) {
9028
+ let [t, n] = (0, l.useState)(!1), [r, i] = (0, l.useState)(!1), [a, o] = (0, l.useState)(!1), [s, c] = (0, l.useState)(), u = e.primaryColor ?? "#1565c0", d = e.faqs ?? [], { reset: p } = g(e);
9004
9029
  (0, l.useEffect)(() => {
9005
9030
  f(u);
9006
9031
  }, [u]);
9007
- let p = () => {
9032
+ let m = () => {
9008
9033
  n(!1), i(!1), o(!1);
9009
- }, m = (e) => {
9034
+ }, h = (e) => {
9010
9035
  c({
9011
9036
  text: e,
9012
9037
  id: Date.now()
9013
9038
  }), o(!1);
9014
9039
  };
9015
- return /* @__PURE__ */ (0, g.jsxs)("div", {
9040
+ return /* @__PURE__ */ (0, v.jsxs)("div", {
9016
9041
  className: "kyt-root",
9017
9042
  children: [
9018
- t && r && /* @__PURE__ */ (0, g.jsx)("div", {
9043
+ t && r && /* @__PURE__ */ (0, v.jsx)("div", {
9019
9044
  className: "kyt-bubble-expanded-backdrop",
9020
- onClick: p
9045
+ onClick: m
9021
9046
  }),
9022
- t && /* @__PURE__ */ (0, g.jsxs)("div", {
9047
+ t && /* @__PURE__ */ (0, v.jsxs)("div", {
9023
9048
  className: r ? "kyt-bubble-expanded" : "kyt-bubble-compact",
9024
- children: [/* @__PURE__ */ (0, g.jsxs)("div", {
9049
+ children: [/* @__PURE__ */ (0, v.jsxs)("div", {
9025
9050
  className: "kyt-bubble-header",
9026
9051
  style: { background: u },
9027
- children: [/* @__PURE__ */ (0, g.jsx)("span", {
9052
+ children: [/* @__PURE__ */ (0, v.jsx)("span", {
9028
9053
  className: "kyt-bubble-header-title",
9029
9054
  children: e.title ?? "Ask anything"
9030
- }), /* @__PURE__ */ (0, g.jsxs)("div", {
9055
+ }), /* @__PURE__ */ (0, v.jsxs)("div", {
9031
9056
  className: "kyt-bubble-header-actions",
9032
9057
  children: [
9033
- /* @__PURE__ */ (0, g.jsxs)("div", {
9058
+ /* @__PURE__ */ (0, v.jsxs)("div", {
9034
9059
  className: "kyt-live",
9035
9060
  style: { marginRight: 4 },
9036
- children: [/* @__PURE__ */ (0, g.jsx)("div", { className: "kyt-live-dot" }), "Live"]
9061
+ children: [/* @__PURE__ */ (0, v.jsx)("div", { className: "kyt-live-dot" }), "Live"]
9062
+ }),
9063
+ /* @__PURE__ */ (0, v.jsx)("button", {
9064
+ className: "kyt-hdr-btn",
9065
+ onClick: p,
9066
+ title: "Clear chat",
9067
+ "aria-label": "Clear chat",
9068
+ children: /* @__PURE__ */ (0, v.jsx)("svg", {
9069
+ viewBox: "0 0 24 24",
9070
+ width: "14",
9071
+ height: "14",
9072
+ fill: "white",
9073
+ children: /* @__PURE__ */ (0, v.jsx)("path", { d: "M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z" })
9074
+ })
9037
9075
  }),
9038
- d.length > 0 && /* @__PURE__ */ (0, g.jsx)("button", {
9076
+ d.length > 0 && /* @__PURE__ */ (0, v.jsx)("button", {
9039
9077
  className: "kyt-hdr-btn",
9040
9078
  onClick: () => o((e) => !e),
9041
9079
  title: "Suggested questions",
9042
9080
  "aria-label": "Suggested questions",
9043
9081
  children: "πŸ’‘"
9044
9082
  }),
9045
- /* @__PURE__ */ (0, g.jsx)("button", {
9083
+ /* @__PURE__ */ (0, v.jsx)("button", {
9046
9084
  className: "kyt-hdr-btn",
9047
9085
  onClick: () => i((e) => !e),
9048
9086
  title: r ? "Compact" : "Expand",
9049
9087
  "aria-label": r ? "Compact" : "Expand",
9050
- children: r ? /* @__PURE__ */ (0, g.jsx)("svg", {
9088
+ children: r ? /* @__PURE__ */ (0, v.jsx)("svg", {
9051
9089
  viewBox: "0 0 24 24",
9052
9090
  width: "14",
9053
9091
  height: "14",
9054
9092
  fill: "white",
9055
- children: /* @__PURE__ */ (0, g.jsx)("path", { d: "M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z" })
9056
- }) : /* @__PURE__ */ (0, g.jsx)("svg", {
9093
+ children: /* @__PURE__ */ (0, v.jsx)("path", { d: "M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z" })
9094
+ }) : /* @__PURE__ */ (0, v.jsx)("svg", {
9057
9095
  viewBox: "0 0 24 24",
9058
9096
  width: "14",
9059
9097
  height: "14",
9060
9098
  fill: "white",
9061
- children: /* @__PURE__ */ (0, g.jsx)("path", { d: "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" })
9099
+ children: /* @__PURE__ */ (0, v.jsx)("path", { d: "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" })
9062
9100
  })
9063
9101
  }),
9064
- /* @__PURE__ */ (0, g.jsx)("button", {
9102
+ /* @__PURE__ */ (0, v.jsx)("button", {
9065
9103
  className: "kyt-hdr-btn",
9066
- onClick: p,
9104
+ onClick: m,
9067
9105
  "aria-label": "Close chat",
9068
- children: /* @__PURE__ */ (0, g.jsx)("svg", {
9106
+ children: /* @__PURE__ */ (0, v.jsx)("svg", {
9069
9107
  viewBox: "0 0 24 24",
9070
9108
  width: "14",
9071
9109
  height: "14",
9072
9110
  fill: "white",
9073
- children: /* @__PURE__ */ (0, g.jsx)("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" })
9111
+ children: /* @__PURE__ */ (0, v.jsx)("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" })
9074
9112
  })
9075
9113
  })
9076
9114
  ]
9077
9115
  })]
9078
- }), /* @__PURE__ */ (0, g.jsxs)("div", {
9116
+ }), /* @__PURE__ */ (0, v.jsxs)("div", {
9079
9117
  style: {
9080
9118
  flex: 1,
9081
9119
  overflow: "hidden",
@@ -9083,47 +9121,47 @@ function oe({ config: e }) {
9083
9121
  flexDirection: "column",
9084
9122
  position: "relative"
9085
9123
  },
9086
- children: [/* @__PURE__ */ (0, g.jsx)(ie, {
9124
+ children: [/* @__PURE__ */ (0, v.jsx)(oe, {
9087
9125
  config: e,
9088
9126
  showHeader: !1,
9089
9127
  bubbleMode: !0,
9090
9128
  pendingFaq: s?.text,
9091
9129
  onFaqSent: () => c(void 0)
9092
- }), a && d.length > 0 && /* @__PURE__ */ (0, g.jsxs)("div", {
9130
+ }), a && d.length > 0 && /* @__PURE__ */ (0, v.jsxs)("div", {
9093
9131
  className: "kyt-faq-drawer",
9094
- children: [/* @__PURE__ */ (0, g.jsxs)("div", {
9132
+ children: [/* @__PURE__ */ (0, v.jsxs)("div", {
9095
9133
  className: "kyt-faq-drawer-header",
9096
- children: [/* @__PURE__ */ (0, g.jsx)("span", {
9134
+ children: [/* @__PURE__ */ (0, v.jsx)("span", {
9097
9135
  className: "kyt-faq-drawer-label",
9098
9136
  children: "Suggested"
9099
- }), /* @__PURE__ */ (0, g.jsx)("button", {
9137
+ }), /* @__PURE__ */ (0, v.jsx)("button", {
9100
9138
  className: "kyt-faq-drawer-close",
9101
9139
  onClick: () => o(!1),
9102
9140
  "aria-label": "Close",
9103
9141
  children: "βœ•"
9104
9142
  })]
9105
- }), /* @__PURE__ */ (0, g.jsx)("div", {
9143
+ }), /* @__PURE__ */ (0, v.jsx)("div", {
9106
9144
  className: "kyt-faq-drawer-list",
9107
- children: d.map((e, t) => /* @__PURE__ */ (0, g.jsx)("button", {
9145
+ children: d.map((e, t) => /* @__PURE__ */ (0, v.jsx)("button", {
9108
9146
  className: "kyt-faq-drawer-btn",
9109
- onClick: () => m(e),
9147
+ onClick: () => h(e),
9110
9148
  children: e
9111
9149
  }, t))
9112
9150
  })]
9113
9151
  })]
9114
9152
  })]
9115
9153
  }),
9116
- !r && /* @__PURE__ */ (0, g.jsx)("button", {
9154
+ !r && /* @__PURE__ */ (0, v.jsx)("button", {
9117
9155
  className: "kyt-bubble-btn",
9118
9156
  style: { background: u },
9119
9157
  onClick: () => n((e) => !e),
9120
9158
  "aria-label": t ? "Close chat" : "Open chat",
9121
- children: t ? /* @__PURE__ */ (0, g.jsx)("svg", {
9159
+ children: t ? /* @__PURE__ */ (0, v.jsx)("svg", {
9122
9160
  viewBox: "0 0 24 24",
9123
- children: /* @__PURE__ */ (0, g.jsx)("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" })
9124
- }) : /* @__PURE__ */ (0, g.jsx)("svg", {
9161
+ children: /* @__PURE__ */ (0, v.jsx)("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" })
9162
+ }) : /* @__PURE__ */ (0, v.jsx)("svg", {
9125
9163
  viewBox: "0 0 24 24",
9126
- children: /* @__PURE__ */ (0, g.jsx)("path", { d: "M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-2 12H6v-2h12v2zm0-3H6V9h12v2zm0-3H6V6h12v2z" })
9164
+ children: /* @__PURE__ */ (0, v.jsx)("path", { d: "M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-2 12H6v-2h12v2zm0-3H6V9h12v2zm0-3H6V6h12v2z" })
9127
9165
  })
9128
9166
  })
9129
9167
  ]
@@ -9131,17 +9169,17 @@ function oe({ config: e }) {
9131
9169
  }
9132
9170
  //#endregion
9133
9171
  //#region ../../src/components/KytChat.tsx
9134
- function se({ config: e, style: t, className: n }) {
9172
+ function le({ config: e, style: t, className: n }) {
9135
9173
  return (0, l.useEffect)(() => {
9136
9174
  f(e.primaryColor ?? "#1565c0");
9137
- }, [e.primaryColor]), /* @__PURE__ */ (0, g.jsx)("div", {
9175
+ }, [e.primaryColor]), /* @__PURE__ */ (0, v.jsx)("div", {
9138
9176
  style: {
9139
9177
  height: "100%",
9140
9178
  width: "100%",
9141
9179
  ...t
9142
9180
  },
9143
9181
  className: n,
9144
- children: /* @__PURE__ */ (0, g.jsx)(ie, {
9182
+ children: /* @__PURE__ */ (0, v.jsx)(oe, {
9145
9183
  config: e,
9146
9184
  showHeader: !0
9147
9185
  })
@@ -9149,23 +9187,23 @@ function se({ config: e, style: t, className: n }) {
9149
9187
  }
9150
9188
  //#endregion
9151
9189
  //#region index.ts
9152
- function ce(e) {
9190
+ function ue(e) {
9153
9191
  let t = document.querySelector(e);
9154
9192
  if (!t) throw Error(`kyt-chat: no element found for selector "${e}"`);
9155
9193
  return t;
9156
9194
  }
9157
- function le(e, t) {
9158
- (0, c.createRoot)(ce(t)).render((0, l.createElement)(oe, { config: e }));
9195
+ function T(e, t) {
9196
+ (0, c.createRoot)(ue(t)).render((0, l.createElement)(ce, { config: e }));
9159
9197
  }
9160
- function ue(e, t) {
9161
- let n = ce(t);
9162
- n.style.height || (n.style.height = "100vh"), (0, c.createRoot)(n).render((0, l.createElement)(se, {
9198
+ function E(e, t) {
9199
+ let n = ue(t);
9200
+ n.style.height || (n.style.height = "100vh"), (0, c.createRoot)(n).render((0, l.createElement)(le, {
9163
9201
  config: e,
9164
9202
  style: { height: "100%" }
9165
9203
  }));
9166
9204
  }
9167
- function T(e, t, n = "bubble") {
9168
- n === "chat" ? ue(e, t) : le(e, t);
9205
+ function de(e, t, n = "bubble") {
9206
+ n === "chat" ? E(e, t) : T(e, t);
9169
9207
  }
9170
9208
  //#endregion
9171
- export { se as KytChat, oe as KytChatBubble, re as SourceCards, T as mount, le as mountBubble, ue as mountChat, m as useKytChat };
9209
+ export { le as KytChat, ce as KytChatBubble, ie as SourceCards, de as mount, T as mountBubble, E as mountChat, g as useKytChat };
@@ -1 +1 @@
1
- {"version":3,"file":"ChatCore.d.ts","sourceRoot":"","sources":["../../../../../src/components/ChatCore.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAW,MAAM,UAAU,CAAA;AAIlD,UAAU,KAAK;IACb,MAAM,EAAE,SAAS,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,+DAA+D;IAC/D,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;CACvB;AAQD,wBAAgB,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,UAAiB,EAAE,UAAkB,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,KAAK,2CAmJhH"}
1
+ {"version":3,"file":"ChatCore.d.ts","sourceRoot":"","sources":["../../../../../src/components/ChatCore.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAW,MAAM,UAAU,CAAA;AAIlD,UAAU,KAAK;IACb,MAAM,EAAE,SAAS,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,+DAA+D;IAC/D,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;CACvB;AAQD,wBAAgB,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,UAAiB,EAAE,UAAkB,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,KAAK,2CA2JhH"}
@@ -1 +1 @@
1
- {"version":3,"file":"KytChatBubble.d.ts","sourceRoot":"","sources":["../../../../../src/components/KytChatBubble.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAIzC,UAAU,KAAK;IACb,MAAM,EAAE,SAAS,CAAA;CAClB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,EAAE,MAAM,EAAE,EAAE,KAAK,2CAsH9C"}
1
+ {"version":3,"file":"KytChatBubble.d.ts","sourceRoot":"","sources":["../../../../../src/components/KytChatBubble.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAKzC,UAAU,KAAK;IACb,MAAM,EAAE,SAAS,CAAA;CAClB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,EAAE,MAAM,EAAE,EAAE,KAAK,2CA+H9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"useKytChat.d.ts","sourceRoot":"","sources":["../../../../src/useKytChat.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAiB,MAAM,SAAS,CAAA;AAMhE,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS;;;;yBAO1B,MAAM;;EA6DvB"}
1
+ {"version":3,"file":"useKytChat.d.ts","sourceRoot":"","sources":["../../../../src/useKytChat.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAiB,MAAM,SAAS,CAAA;AAahE,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS;;;;yBAiB1B,MAAM;;EA8DvB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kyt-chat",
3
- "version": "1.0.2",
3
+ "version": "1.0.5",
4
4
  "description": "Embeddable KYT chat widget β€” self-contained, no React required by host",
5
5
  "license": "MIT",
6
6
  "type": "module",