@telnyx/ai-chat-widget 2.4.1 → 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1 -4
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +1 -4
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -775,9 +775,6 @@ React keys must be passed directly to JSX without using spread:
|
|
|
775
775
|
.items-center {
|
|
776
776
|
align-items: center;
|
|
777
777
|
}
|
|
778
|
-
.items-end {
|
|
779
|
-
align-items: flex-end;
|
|
780
|
-
}
|
|
781
778
|
.items-start {
|
|
782
779
|
align-items: flex-start;
|
|
783
780
|
}
|
|
@@ -2538,7 +2535,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
2538
2535
|
*
|
|
2539
2536
|
* This source code is licensed under the ISC license.
|
|
2540
2537
|
* See the LICENSE file in the root directory of this source tree.
|
|
2541
|
-
*/const nF=vE("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function rF(e){const t=e+"CollectionProvider",[n,r]=aa(t),[a,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=m=>{const{scope:v,children:h}=m,b=O.useRef(null),y=O.useRef(new Map).current;return w.jsx(a,{scope:v,itemMap:y,collectionRef:b,children:h})};o.displayName=t;const s=e+"CollectionSlot",l=Vs(s),u=O.forwardRef((m,v)=>{const{scope:h,children:b}=m,y=i(s,h),S=Xt(v,y.collectionRef);return w.jsx(l,{ref:S,children:b})});u.displayName=s;const c=e+"CollectionItemSlot",d="data-radix-collection-item",p=Vs(c),f=O.forwardRef((m,v)=>{const{scope:h,children:b,...y}=m,S=O.useRef(null),x=Xt(v,S),E=i(c,h);return O.useEffect(()=>(E.itemMap.set(S,{ref:S,...y}),()=>void E.itemMap.delete(S))),w.jsx(p,{[d]:"",ref:x,children:b})});f.displayName=c;function g(m){const v=i(e+"CollectionConsumer",m);return O.useCallback(()=>{const b=v.collectionRef.current;if(!b)return[];const y=Array.from(b.querySelectorAll(`[${d}]`));return Array.from(v.itemMap.values()).sort((E,T)=>y.indexOf(E.ref.current)-y.indexOf(T.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:o,Slot:u,ItemSlot:f},g,r]}var aF=N.createContext(void 0);function EE(e){const t=N.useContext(aF);return e||t||"ltr"}var dl="rovingFocusGroup.onEntryFocus",iF={bubbles:!1,cancelable:!0},da="RovingFocusGroup",[pl,wE,oF]=rF(da),[sF,SE]=aa(da,[oF]),[lF,uF]=sF(da),xE=N.forwardRef((e,t)=>w.jsx(pl.Provider,{scope:e.__scopeRovingFocusGroup,children:w.jsx(pl.Slot,{scope:e.__scopeRovingFocusGroup,children:w.jsx(cF,{...e,ref:t})})}));xE.displayName=da;var cF=N.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:c=!1,...d}=e,p=N.useRef(null),f=Xt(t,p),g=EE(i),[m,v]=ua({prop:o,defaultProp:s??null,onChange:l,caller:da}),[h,b]=N.useState(!1),y=ia(u),S=wE(n),x=N.useRef(!1),[E,T]=N.useState(0);return N.useEffect(()=>{const k=p.current;if(k)return k.addEventListener(dl,y),()=>k.removeEventListener(dl,y)},[y]),w.jsx(lF,{scope:n,orientation:r,dir:g,loop:a,currentTabStopId:m,onItemFocus:N.useCallback(k=>v(k),[v]),onItemShiftTab:N.useCallback(()=>b(!0),[]),onFocusableItemAdd:N.useCallback(()=>T(k=>k+1),[]),onFocusableItemRemove:N.useCallback(()=>T(k=>k-1),[]),children:w.jsx(Dt.div,{tabIndex:h||E===0?-1:0,"data-orientation":r,...d,ref:f,style:{outline:"none",...e.style},onMouseDown:at(e.onMouseDown,()=>{x.current=!0}),onFocus:at(e.onFocus,k=>{const C=!x.current;if(k.target===k.currentTarget&&C&&!h){const I=new CustomEvent(dl,iF);if(k.currentTarget.dispatchEvent(I),!I.defaultPrevented){const D=S().filter(H=>H.focusable),B=D.find(H=>H.active),P=D.find(H=>H.id===m),z=[B,P,...D].filter(Boolean).map(H=>H.ref.current);kE(z,c)}}x.current=!1}),onBlur:at(e.onBlur,()=>b(!1))})})}),TE="RovingFocusGroupItem",AE=N.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:i,children:o,...s}=e,l=Sv(),u=i||l,c=uF(TE,n),d=c.currentTabStopId===u,p=wE(n),{onFocusableItemAdd:f,onFocusableItemRemove:g,currentTabStopId:m}=c;return N.useEffect(()=>{if(r)return f(),()=>g()},[r,f,g]),w.jsx(pl.ItemSlot,{scope:n,id:u,focusable:r,active:a,children:w.jsx(Dt.span,{tabIndex:d?0:-1,"data-orientation":c.orientation,...s,ref:t,onMouseDown:at(e.onMouseDown,v=>{r?c.onItemFocus(u):v.preventDefault()}),onFocus:at(e.onFocus,()=>c.onItemFocus(u)),onKeyDown:at(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){c.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const h=fF(v,c.orientation,c.dir);if(h!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let y=p().filter(S=>S.focusable).map(S=>S.ref.current);if(h==="last")y.reverse();else if(h==="prev"||h==="next"){h==="prev"&&y.reverse();const S=y.indexOf(v.currentTarget);y=c.loop?gF(y,S+1):y.slice(S+1)}setTimeout(()=>kE(y))}}),children:typeof o=="function"?o({isCurrentTabStop:d,hasTabStop:m!=null}):o})})});AE.displayName=TE;var dF={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function pF(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function fF(e,t,n){const r=pF(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return dF[r]}function kE(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function gF(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var mF=xE,hF=AE,RE="Toggle",IE=N.forwardRef((e,t)=>{const{pressed:n,defaultPressed:r,onPressedChange:a,...i}=e,[o,s]=ua({prop:n,onChange:a,defaultProp:r??!1,caller:RE});return w.jsx(Dt.button,{type:"button","aria-pressed":o,"data-state":o?"on":"off","data-disabled":e.disabled?"":void 0,...i,ref:t,onClick:at(e.onClick,()=>{e.disabled||s(!o)})})});IE.displayName=RE;var Tn="ToggleGroup",[CE,O$]=aa(Tn,[SE]),_E=SE(),fl=O.forwardRef((e,t)=>{const{type:n,...r}=e;if(n==="single"){const a=r;return w.jsx(bF,{...a,ref:t})}if(n==="multiple"){const a=r;return w.jsx(yF,{...a,ref:t})}throw new Error(`Missing prop \`type\` expected on \`${Tn}\``)});fl.displayName=Tn;var[NE,OE]=CE(Tn),bF=O.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:a=()=>{},...i}=e,[o,s]=ua({prop:n,defaultProp:r??"",onChange:a,caller:Tn});return w.jsx(NE,{scope:e.__scopeToggleGroup,type:"single",value:O.useMemo(()=>o?[o]:[],[o]),onItemActivate:s,onItemDeactivate:O.useCallback(()=>s(""),[s]),children:w.jsx(LE,{...i,ref:t})})}),yF=O.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:a=()=>{},...i}=e,[o,s]=ua({prop:n,defaultProp:r??[],onChange:a,caller:Tn}),l=O.useCallback(c=>s((d=[])=>[...d,c]),[s]),u=O.useCallback(c=>s((d=[])=>d.filter(p=>p!==c)),[s]);return w.jsx(NE,{scope:e.__scopeToggleGroup,type:"multiple",value:o,onItemActivate:l,onItemDeactivate:u,children:w.jsx(LE,{...i,ref:t})})});fl.displayName=Tn;var[vF,EF]=CE(Tn),LE=O.forwardRef((e,t)=>{const{__scopeToggleGroup:n,disabled:r=!1,rovingFocus:a=!0,orientation:i,dir:o,loop:s=!0,...l}=e,u=_E(n),c=EE(o),d={role:"group",dir:c,...l};return w.jsx(vF,{scope:n,rovingFocus:a,disabled:r,children:a?w.jsx(mF,{asChild:!0,...u,orientation:i,dir:c,loop:s,children:w.jsx(Dt.div,{...d,ref:t})}):w.jsx(Dt.div,{...d,ref:t})})}),Ii="ToggleGroupItem",DE=O.forwardRef((e,t)=>{const n=OE(Ii,e.__scopeToggleGroup),r=EF(Ii,e.__scopeToggleGroup),a=_E(e.__scopeToggleGroup),i=n.value.includes(e.value),o=r.disabled||e.disabled,s={...e,pressed:i,disabled:o},l=O.useRef(null);return r.rovingFocus?w.jsx(hF,{asChild:!0,...a,focusable:!o,active:i,ref:l,children:w.jsx(ME,{...s,ref:t})}):w.jsx(ME,{...s,ref:t})});DE.displayName=Ii;var ME=O.forwardRef((e,t)=>{const{__scopeToggleGroup:n,value:r,...a}=e,i=OE(Ii,n),o={role:"radio","aria-checked":e.pressed,"aria-pressed":void 0},s=i.type==="single"?o:void 0;return w.jsx(IE,{...s,...a,ref:t,onPressedChange:l=>{l?i.onItemActivate(r):i.onItemDeactivate(r)}})}),wF=fl,SF=DE;const PE=N.createContext({size:"default",variant:"default"}),FE=N.forwardRef(({className:e,size:t="default",variant:n="default",children:r,...a},i)=>w.jsx(wF,{ref:i,className:ee("flex items-center gap-1",e),...a,children:w.jsx(PE.Provider,{value:{size:t,variant:n},children:r})}));FE.displayName="ToggleGroup";const gl={base:"inline-flex flex-1 items-center justify-center gap-1.5 rounded-full text-xs font-medium transition-all cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",variant:{default:"bg-transparent text-gray-500 hover:bg-gray-100 hover:text-gray-700 data-[state=on]:bg-black data-[state=on]:text-white",outline:"border border-neutral-500 bg-transparent text-neutral-500 hover:bg-telnyx-cream hover:text-gray-700 data-[state=on]:border-black data-[state=on]:bg-black data-[state=on]:text-white",telnyx:"border border-black bg-transparent text-black hover:bg-telnyx-cream hover:text-gray-700 data-[state=on]:border-black data-[state=on]:bg-black data-[state=on]:text-telnyx-green"},size:{default:"px-3 py-1.5",xs:"px-1.5 py-0.5",sm:"px-2.5 py-1",lg:"px-4 py-2"}},ml=N.forwardRef(({className:e,children:t,variant:n,size:r,...a},i)=>{const o=N.useContext(PE),s=n||o.variant||"default",l=r||o.size||"default";return w.jsx(SF,{ref:i,className:ee(gl.base,gl.variant[s],gl.size[l],e),...a,children:t})});ml.displayName="ToggleGroupItem";const xF=200;function TF(){const[e,t]=O.useState(!1),n=O.useRef(null),r=J(p=>p.endpoint),a=J(p=>p.setEndpoint),i=J(p=>p.botState),o=i==="loading"||i==="streaming",s=p=>{p&&a(p)},l=()=>{n.current=setTimeout(()=>{t(!0)},xF)},u=()=>{n.current&&(clearTimeout(n.current),n.current=null),t(!1)},c=Ts[Ee.FLOW],d=Ts[Ee.AIDA];return w.jsx(fe.div,{className:ee("relative z-0","border-2 border-black bg-telnyx-dark-cream","rounded-t-xl","px-1 pt-0.5 pb-3.5","transition-[padding]",o&&"hidden"),onHoverStart:l,onHoverEnd:u,animate:{y:14},transition:{duration:.2,ease:"easeOut"},children:w.jsxs(FE,{type:"single",value:r,onValueChange:s,disabled:o,className:ee("flex items-center justify-between","transition-[gap] duration-200 ease-out",e?"gap-1":"gap-0"),children:[w.jsxs(tn,{children:[w.jsx(nn,{asChild:!0,children:w.jsx("span",{className:ee("flex flex-1",!e&&r!==Ee.FLOW&&"hidden"),children:w.jsxs(ml,{value:Ee.FLOW,"aria-label":"Instant mode",variant:"telnyx",className:ee("flex-1 transition-all duration-200 ease-out",e?"px-2.5 py-1 text-xs":"px-2 py-0.5 text-[8px]"),children:[w.jsx(nF,{className:ee("transition-all duration-200",e?"size-3":"size-2")}),w.jsx("span",{children:"Instant"})]})})}),w.jsx(Vt,{side:"top",align:"start",className:"p-0",children:w.jsxs("div",{className:"p-3 max-w-[220px] space-y-2",children:[w.jsx("p",{className:"font-semibold text-sm",children:c.tooltip.title}),w.jsx("ul",{className:"space-y-1",children:c.tooltip.capabilities.map(p=>w.jsxs("li",{className:"text-xs flex items-center gap-1.5",children:[w.jsx("span",{className:"text-green-400",children:"✓"}),w.jsx("span",{children:p})]},p))}),w.jsxs("div",{className:"text-xs flex items-center gap-1.5 text-gray-300",children:[w.jsx("span",{children:"⏱"}),w.jsx("span",{children:c.tooltip.timing})]})]})})]}),w.jsxs(tn,{children:[w.jsx(nn,{asChild:!0,children:w.jsx("span",{className:ee("flex flex-1",!e&&r!==Ee.AIDA&&"hidden"),children:w.jsxs(ml,{value:Ee.AIDA,"aria-label":"Heavy thinking mode",variant:"telnyx",className:ee("flex-1 transition-all duration-200 ease-out",e?"px-2.5 py-1 text-xs":"px-2 py-0.5 text-[8px]"),children:[w.jsx(tF,{className:ee("transition-all duration-200",e?"size-3":"size-2")}),w.jsx("span",{children:"Heavy thinking"})]})})}),w.jsx(Vt,{side:"top",align:"end",className:"p-0",children:w.jsxs("div",{className:"p-3 max-w-[220px] space-y-2",children:[w.jsx("p",{className:"font-semibold text-sm",children:d.tooltip.title}),w.jsx("ul",{className:"space-y-1",children:d.tooltip.capabilities.map(p=>w.jsxs("li",{className:"text-xs flex items-center gap-1.5",children:[w.jsx("span",{className:"text-green-400",children:"✓"}),w.jsx("span",{children:p})]},p))}),w.jsxs("div",{className:"text-xs flex items-center gap-1.5 text-gray-300",children:[w.jsx("span",{children:"⏱"}),w.jsx("span",{children:d.tooltip.timing})]})]})})]})]})})}const AF=fe.create(pv),kF=fe.create(gE),BE=e=>({open:t=>({opacity:e==="outline"?t?0:1:t?1:0,top:"50%",left:"50%",x:"calc(-50% + 1px)",y:"calc(-50% - 1px)",rotate:"-45deg"})}),RF=({question:e,handleSendMessage:t})=>{const n=J(i=>i.botState),r=!!e,a=n==="loading"||n==="streaming";return w.jsxs(fe.button,{disabled:!r||a,className:ee("bg-telnyx-light-green relative rounded-full p-2 size-8 overflow-clip","cursor-pointer disabled:cursor-default",r&&"shadow-md"),whileHover:r?{scale:.9}:{},whileTap:r?{scale:.7}:{},onClick:t,children:[w.jsx(AF,{className:"absolute size-4.5",initial:!1,variants:BE("outline"),custom:r,animate:"open"}),w.jsx(kF,{className:"absolute size-4.5",initial:!1,variants:BE("solid"),custom:r,animate:"open"})]})},UE=O.forwardRef(({message:e,handleInput:t,placeholders:n,handleSendMessage:r},a)=>{const i=J(h=>h.setCustomOpen),o=J(h=>h.botState),s=o==="loading"||o==="streaming",[l,u]=O.useState(0),c=O.useRef(null),d=O.useRef(0),p=O.useRef(null),f=!!i,g=O.useCallback(h=>{p.current=h,typeof a=="function"?a(h):a&&(a.current=h)},[a]);hE(p,"Enter",h=>{var b;h.shiftKey||(h.preventDefault(),r(),(b=p.current)==null||b.blur())},{enabled:!s,shiftKey:!1}),hE(p,"Escape",()=>{var h;(h=p.current)==null||h.blur()});const m=O.useCallback(()=>{if(document.visibilityState!=="visible"&&c.current)return;const h=b=>{b-d.current>=3e3&&(u(y=>(y+1)%n.length),d.current=b),c.current=requestAnimationFrame(h)};d.current=performance.now(),c.current=requestAnimationFrame(h)},[n.length]),v=O.useCallback(()=>{document.visibilityState!=="visible"&&c.current?(cancelAnimationFrame(c.current),c.current=null):document.visibilityState==="visible"&&m()},[m]);return O.useEffect(()=>(m(),document.addEventListener("visibilitychange",v),()=>{c.current&&cancelAnimationFrame(c.current),document.removeEventListener("visibilitychange",v)}),[n,m,v]),w.jsxs("div",{className:"flex flex-col",children:[w.jsx(TF,{}),w.jsx("div",{className:ee("flex flex-col rounded-xl border-2 border-black bg-telnyx-cream","transition-all focus-within:ring-1 focus-within:ring-black focus-within:ring-offset-0.5 focus-within:bg-telnyx-dark-cream","relative z-10",s&&"opacity-50"),children:w.jsxs("div",{className:"flex",children:[w.jsxs("div",{className:"pl-4 pt-3 pb-2 flex-1 relative",children:[w.jsx("textarea",{id:"user-message-input",ref:g,value:e,onInput:t,disabled:s,"aria-disabled":s,className:ee("w-full max-h-24 bg-transparent text-sm resize-none overflow-y-auto focus:outline-hidden focus:placeholder-black","scrollbar scrollbar-w-1 scrollbar-thumb-rounded-full scrollbar-track-transparent scrollbar-thumb-telnyx-gray-hover-light"),rows:1}),w.jsx("div",{className:"absolute inset-0 flex items-center pointer-events-none",children:w.jsx(Kt,{mode:"wait",children:!e&&w.jsx(fe.p,{initial:{y:5,opacity:0},animate:{y:0,opacity:1},exit:{y:-15,opacity:0},transition:{duration:.3,ease:"linear"},className:"text-neutral-500 text-sm pl-4 text-left w-[calc(100%-32px)] truncate",children:n[l]},`current-placeholder-${l}`)})})]}),w.jsx("span",{className:"w-12 flex items-end justify-center mb-0",children:f&&w.jsx(RF,{question:e,handleSendMessage:r})})]})})]})});UE.displayName="FooterTextInput";const IF={[fr.HAS_NOT_BEEN_OPENED]:{y:0},[fr.HAS_BEEN_OPENED]:{y:[0,-3,0],scale:[1,1.01,1],filter:["blur(0px)","blur(5px)","blur(0px)"],opacity:[1,.8,1]}};function CF({text:e,className:t}){const n=J(r=>r.hasWidgetBeenOpened);return e.split("").map((r,a)=>w.jsx(fe.span,{initial:!1,animate:n,variants:IF,transition:{duration:.5,delay:a*.05},className:ee("inline-block whitespace-pre font-sans tracking-tight",t),children:r},`${r}-${a}`))}const _F=()=>w.jsxs("div",{className:"flex justify-center text-xs pb-0.5 mt-2",children:[w.jsx(Ri,{className:"h-4 w-4 mr-1"}),w.jsx(CF,{className:"translate-y-0.5 font-pp-formula",text:"Powered by Telnyx"})]}),NF={[lt.INITIAL]:{y:0},[lt.USER_HAS_TYPED]:{y:0,transition:{duration:.2}}},jE=O.forwardRef(({question:e,handleInput:t,handleSendMessage:n},r)=>{const a=J(f=>f.chatVisualState),i=J(f=>f.onHelpAction),o=J(f=>f.botState),s=J(f=>f.getLastMessage()),l=(s==null?void 0:s.show_help_action)===!0,u=a===lt.USER_HAS_TYPED,c=J(f=>f.placeholders),d=o==="error"?["Error!","Please try again."]:c,p=l&&i!==null;return w.jsx("div",{className:ee("mt-2 pt-1",u&&"mt-0 mb-2 pt-0"),children:w.jsxs(fe.div,{initial:"initial",animate:a,variants:NF,className:"space-y-1",children:[p&&w.jsx(OF,{onHelpAction:i}),w.jsx(UE,{ref:r,message:e,handleInput:t,handleSendMessage:n,placeholders:d}),!u&&w.jsx(_F,{})]})})});jE.displayName="Footer";const OF=({onHelpAction:e})=>w.jsx("div",{className:"flex items-center justify-center mb-0.5",children:w.jsxs(fe.button,{initial:{scale:.5,opacity:0,y:10},animate:{scale:.75,opacity:1,y:0,transition:{duration:.2}},exit:{scale:.5,y:10,transition:{duration:.2}},whileHover:{scale:.8,transition:{duration:.2}},whileTap:{scale:.7,transition:{duration:.2}},className:ee("flex items-center gap-1 rounded-full p-2","bg-black text-white cursor-pointer"),onClick:e,children:[w.jsx("p",{className:"text-sm font-medium text-white",children:"Chat to support"}),w.jsx(BP,{className:"size-5 text-white"})]})}),LF=({children:e,className:t,containerClassName:n})=>{const r=Ss(0),a=Ss(0),i={default:`url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' width='16' height='16' fill='none'%3E%3Ccircle fill='%23404040' id='pattern-circle' cx='10' cy='10' r='2.5'%3E%3C/circle%3E%3C/svg%3E")`,hover:`url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' width='16' height='16' fill='none'%3E%3Ccircle fill='%2300E3AA' id='pattern-circle' cx='10' cy='10' r='2.5'%3E%3C/circle%3E%3C/svg%3E")`};function o({currentTarget:s,clientX:l,clientY:u}){if(!s)return;const{left:c,top:d}=s.getBoundingClientRect();r.set(l-c),a.set(u-d)}return w.jsxs("div",{className:ee("group relative h-full w-full items-center bg-black",n),onMouseMove:o,children:[w.jsx("div",{className:"pointer-events-none absolute inset-0",style:{backgroundImage:i.default}}),w.jsx(fe.div,{className:"pointer-events-none absolute inset-0 opacity-0 transition duration-300 group-hover:opacity-100",style:{backgroundImage:i.hover,WebkitMaskImage:Ey`
|
|
2538
|
+
*/const nF=vE("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function rF(e){const t=e+"CollectionProvider",[n,r]=aa(t),[a,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=m=>{const{scope:v,children:h}=m,b=O.useRef(null),y=O.useRef(new Map).current;return w.jsx(a,{scope:v,itemMap:y,collectionRef:b,children:h})};o.displayName=t;const s=e+"CollectionSlot",l=Vs(s),u=O.forwardRef((m,v)=>{const{scope:h,children:b}=m,y=i(s,h),S=Xt(v,y.collectionRef);return w.jsx(l,{ref:S,children:b})});u.displayName=s;const c=e+"CollectionItemSlot",d="data-radix-collection-item",p=Vs(c),f=O.forwardRef((m,v)=>{const{scope:h,children:b,...y}=m,S=O.useRef(null),x=Xt(v,S),E=i(c,h);return O.useEffect(()=>(E.itemMap.set(S,{ref:S,...y}),()=>void E.itemMap.delete(S))),w.jsx(p,{[d]:"",ref:x,children:b})});f.displayName=c;function g(m){const v=i(e+"CollectionConsumer",m);return O.useCallback(()=>{const b=v.collectionRef.current;if(!b)return[];const y=Array.from(b.querySelectorAll(`[${d}]`));return Array.from(v.itemMap.values()).sort((E,T)=>y.indexOf(E.ref.current)-y.indexOf(T.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:o,Slot:u,ItemSlot:f},g,r]}var aF=N.createContext(void 0);function EE(e){const t=N.useContext(aF);return e||t||"ltr"}var dl="rovingFocusGroup.onEntryFocus",iF={bubbles:!1,cancelable:!0},da="RovingFocusGroup",[pl,wE,oF]=rF(da),[sF,SE]=aa(da,[oF]),[lF,uF]=sF(da),xE=N.forwardRef((e,t)=>w.jsx(pl.Provider,{scope:e.__scopeRovingFocusGroup,children:w.jsx(pl.Slot,{scope:e.__scopeRovingFocusGroup,children:w.jsx(cF,{...e,ref:t})})}));xE.displayName=da;var cF=N.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:c=!1,...d}=e,p=N.useRef(null),f=Xt(t,p),g=EE(i),[m,v]=ua({prop:o,defaultProp:s??null,onChange:l,caller:da}),[h,b]=N.useState(!1),y=ia(u),S=wE(n),x=N.useRef(!1),[E,T]=N.useState(0);return N.useEffect(()=>{const k=p.current;if(k)return k.addEventListener(dl,y),()=>k.removeEventListener(dl,y)},[y]),w.jsx(lF,{scope:n,orientation:r,dir:g,loop:a,currentTabStopId:m,onItemFocus:N.useCallback(k=>v(k),[v]),onItemShiftTab:N.useCallback(()=>b(!0),[]),onFocusableItemAdd:N.useCallback(()=>T(k=>k+1),[]),onFocusableItemRemove:N.useCallback(()=>T(k=>k-1),[]),children:w.jsx(Dt.div,{tabIndex:h||E===0?-1:0,"data-orientation":r,...d,ref:f,style:{outline:"none",...e.style},onMouseDown:at(e.onMouseDown,()=>{x.current=!0}),onFocus:at(e.onFocus,k=>{const C=!x.current;if(k.target===k.currentTarget&&C&&!h){const I=new CustomEvent(dl,iF);if(k.currentTarget.dispatchEvent(I),!I.defaultPrevented){const D=S().filter(H=>H.focusable),B=D.find(H=>H.active),P=D.find(H=>H.id===m),z=[B,P,...D].filter(Boolean).map(H=>H.ref.current);kE(z,c)}}x.current=!1}),onBlur:at(e.onBlur,()=>b(!1))})})}),TE="RovingFocusGroupItem",AE=N.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:i,children:o,...s}=e,l=Sv(),u=i||l,c=uF(TE,n),d=c.currentTabStopId===u,p=wE(n),{onFocusableItemAdd:f,onFocusableItemRemove:g,currentTabStopId:m}=c;return N.useEffect(()=>{if(r)return f(),()=>g()},[r,f,g]),w.jsx(pl.ItemSlot,{scope:n,id:u,focusable:r,active:a,children:w.jsx(Dt.span,{tabIndex:d?0:-1,"data-orientation":c.orientation,...s,ref:t,onMouseDown:at(e.onMouseDown,v=>{r?c.onItemFocus(u):v.preventDefault()}),onFocus:at(e.onFocus,()=>c.onItemFocus(u)),onKeyDown:at(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){c.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const h=fF(v,c.orientation,c.dir);if(h!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let y=p().filter(S=>S.focusable).map(S=>S.ref.current);if(h==="last")y.reverse();else if(h==="prev"||h==="next"){h==="prev"&&y.reverse();const S=y.indexOf(v.currentTarget);y=c.loop?gF(y,S+1):y.slice(S+1)}setTimeout(()=>kE(y))}}),children:typeof o=="function"?o({isCurrentTabStop:d,hasTabStop:m!=null}):o})})});AE.displayName=TE;var dF={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function pF(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function fF(e,t,n){const r=pF(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return dF[r]}function kE(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function gF(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var mF=xE,hF=AE,RE="Toggle",IE=N.forwardRef((e,t)=>{const{pressed:n,defaultPressed:r,onPressedChange:a,...i}=e,[o,s]=ua({prop:n,onChange:a,defaultProp:r??!1,caller:RE});return w.jsx(Dt.button,{type:"button","aria-pressed":o,"data-state":o?"on":"off","data-disabled":e.disabled?"":void 0,...i,ref:t,onClick:at(e.onClick,()=>{e.disabled||s(!o)})})});IE.displayName=RE;var Tn="ToggleGroup",[CE,O$]=aa(Tn,[SE]),_E=SE(),fl=O.forwardRef((e,t)=>{const{type:n,...r}=e;if(n==="single"){const a=r;return w.jsx(bF,{...a,ref:t})}if(n==="multiple"){const a=r;return w.jsx(yF,{...a,ref:t})}throw new Error(`Missing prop \`type\` expected on \`${Tn}\``)});fl.displayName=Tn;var[NE,OE]=CE(Tn),bF=O.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:a=()=>{},...i}=e,[o,s]=ua({prop:n,defaultProp:r??"",onChange:a,caller:Tn});return w.jsx(NE,{scope:e.__scopeToggleGroup,type:"single",value:O.useMemo(()=>o?[o]:[],[o]),onItemActivate:s,onItemDeactivate:O.useCallback(()=>s(""),[s]),children:w.jsx(LE,{...i,ref:t})})}),yF=O.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:a=()=>{},...i}=e,[o,s]=ua({prop:n,defaultProp:r??[],onChange:a,caller:Tn}),l=O.useCallback(c=>s((d=[])=>[...d,c]),[s]),u=O.useCallback(c=>s((d=[])=>d.filter(p=>p!==c)),[s]);return w.jsx(NE,{scope:e.__scopeToggleGroup,type:"multiple",value:o,onItemActivate:l,onItemDeactivate:u,children:w.jsx(LE,{...i,ref:t})})});fl.displayName=Tn;var[vF,EF]=CE(Tn),LE=O.forwardRef((e,t)=>{const{__scopeToggleGroup:n,disabled:r=!1,rovingFocus:a=!0,orientation:i,dir:o,loop:s=!0,...l}=e,u=_E(n),c=EE(o),d={role:"group",dir:c,...l};return w.jsx(vF,{scope:n,rovingFocus:a,disabled:r,children:a?w.jsx(mF,{asChild:!0,...u,orientation:i,dir:c,loop:s,children:w.jsx(Dt.div,{...d,ref:t})}):w.jsx(Dt.div,{...d,ref:t})})}),Ii="ToggleGroupItem",DE=O.forwardRef((e,t)=>{const n=OE(Ii,e.__scopeToggleGroup),r=EF(Ii,e.__scopeToggleGroup),a=_E(e.__scopeToggleGroup),i=n.value.includes(e.value),o=r.disabled||e.disabled,s={...e,pressed:i,disabled:o},l=O.useRef(null);return r.rovingFocus?w.jsx(hF,{asChild:!0,...a,focusable:!o,active:i,ref:l,children:w.jsx(ME,{...s,ref:t})}):w.jsx(ME,{...s,ref:t})});DE.displayName=Ii;var ME=O.forwardRef((e,t)=>{const{__scopeToggleGroup:n,value:r,...a}=e,i=OE(Ii,n),o={role:"radio","aria-checked":e.pressed,"aria-pressed":void 0},s=i.type==="single"?o:void 0;return w.jsx(IE,{...s,...a,ref:t,onPressedChange:l=>{l?i.onItemActivate(r):i.onItemDeactivate(r)}})}),wF=fl,SF=DE;const PE=N.createContext({size:"default",variant:"default"}),FE=N.forwardRef(({className:e,size:t="default",variant:n="default",children:r,...a},i)=>w.jsx(wF,{ref:i,className:ee("flex items-center gap-1",e),...a,children:w.jsx(PE.Provider,{value:{size:t,variant:n},children:r})}));FE.displayName="ToggleGroup";const gl={base:"inline-flex flex-1 items-center justify-center gap-1.5 rounded-full text-xs font-medium transition-all cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",variant:{default:"bg-transparent text-gray-500 hover:bg-gray-100 hover:text-gray-700 data-[state=on]:bg-black data-[state=on]:text-white",outline:"border border-neutral-500 bg-transparent text-neutral-500 hover:bg-telnyx-cream hover:text-gray-700 data-[state=on]:border-black data-[state=on]:bg-black data-[state=on]:text-white",telnyx:"border border-black bg-transparent text-black hover:bg-telnyx-cream hover:text-gray-700 data-[state=on]:border-black data-[state=on]:bg-black data-[state=on]:text-telnyx-green"},size:{default:"px-3 py-1.5",xs:"px-1.5 py-0.5",sm:"px-2.5 py-1",lg:"px-4 py-2"}},ml=N.forwardRef(({className:e,children:t,variant:n,size:r,...a},i)=>{const o=N.useContext(PE),s=n||o.variant||"default",l=r||o.size||"default";return w.jsx(SF,{ref:i,className:ee(gl.base,gl.variant[s],gl.size[l],e),...a,children:t})});ml.displayName="ToggleGroupItem";const xF=200;function TF(){const[e,t]=O.useState(!1),n=O.useRef(null),r=J(p=>p.endpoint),a=J(p=>p.setEndpoint),i=J(p=>p.botState),o=i==="loading"||i==="streaming",s=p=>{p&&a(p)},l=()=>{n.current=setTimeout(()=>{t(!0)},xF)},u=()=>{n.current&&(clearTimeout(n.current),n.current=null),t(!1)},c=Ts[Ee.FLOW],d=Ts[Ee.AIDA];return w.jsx(fe.div,{className:ee("relative z-0","border-2 border-black bg-telnyx-dark-cream","rounded-t-xl","px-1 pt-0.5 pb-3.5","transition-[padding]",o&&"hidden"),onHoverStart:l,onHoverEnd:u,animate:{y:14},transition:{duration:.2,ease:"easeOut"},children:w.jsxs(FE,{type:"single",value:r,onValueChange:s,disabled:o,className:ee("flex items-center justify-between","transition-[gap] duration-200 ease-out",e?"gap-1":"gap-0"),children:[w.jsxs(tn,{children:[w.jsx(nn,{asChild:!0,children:w.jsx("span",{className:ee("flex flex-1",!e&&r!==Ee.FLOW&&"hidden"),children:w.jsxs(ml,{value:Ee.FLOW,"aria-label":"Instant mode",variant:"telnyx",className:ee("flex-1 transition-all duration-200 ease-out",e?"px-2.5 py-1 text-xs":"px-2 py-0.5 text-[8px]"),children:[w.jsx(nF,{className:ee("transition-all duration-200",e?"size-3":"size-2")}),w.jsx("span",{children:"Instant"})]})})}),w.jsx(Vt,{side:"top",align:"start",className:"p-0",children:w.jsxs("div",{className:"p-3 max-w-[220px] space-y-2",children:[w.jsx("p",{className:"font-semibold text-sm",children:c.tooltip.title}),w.jsx("ul",{className:"space-y-1",children:c.tooltip.capabilities.map(p=>w.jsxs("li",{className:"text-xs flex items-center gap-1.5",children:[w.jsx("span",{className:"text-green-400",children:"✓"}),w.jsx("span",{children:p})]},p))}),w.jsxs("div",{className:"text-xs flex items-center gap-1.5 text-gray-300",children:[w.jsx("span",{children:"⏱"}),w.jsx("span",{children:c.tooltip.timing})]})]})})]}),w.jsxs(tn,{children:[w.jsx(nn,{asChild:!0,children:w.jsx("span",{className:ee("flex flex-1",!e&&r!==Ee.AIDA&&"hidden"),children:w.jsxs(ml,{value:Ee.AIDA,"aria-label":"Heavy thinking mode",variant:"telnyx",className:ee("flex-1 transition-all duration-200 ease-out",e?"px-2.5 py-1 text-xs":"px-2 py-0.5 text-[8px]"),children:[w.jsx(tF,{className:ee("transition-all duration-200",e?"size-3":"size-2")}),w.jsx("span",{children:"Heavy thinking"})]})})}),w.jsx(Vt,{side:"top",align:"end",className:"p-0",children:w.jsxs("div",{className:"p-3 max-w-[220px] space-y-2",children:[w.jsx("p",{className:"font-semibold text-sm",children:d.tooltip.title}),w.jsx("ul",{className:"space-y-1",children:d.tooltip.capabilities.map(p=>w.jsxs("li",{className:"text-xs flex items-center gap-1.5",children:[w.jsx("span",{className:"text-green-400",children:"✓"}),w.jsx("span",{children:p})]},p))}),w.jsxs("div",{className:"text-xs flex items-center gap-1.5 text-gray-300",children:[w.jsx("span",{children:"⏱"}),w.jsx("span",{children:d.tooltip.timing})]})]})})]})]})})}const AF=fe.create(pv),kF=fe.create(gE),BE=e=>({open:t=>({opacity:e==="outline"?t?0:1:t?1:0,top:"50%",left:"50%",x:"calc(-50% + 1px)",y:"calc(-50% - 1px)",rotate:"-45deg"})}),RF=({question:e,handleSendMessage:t})=>{const n=J(i=>i.botState),r=!!e,a=n==="loading"||n==="streaming";return w.jsxs(fe.button,{disabled:!r||a,className:ee("bg-telnyx-light-green relative rounded-full p-2 size-8 overflow-clip","cursor-pointer disabled:cursor-default",r&&"shadow-md"),whileHover:r?{scale:.9}:{},whileTap:r?{scale:.7}:{},onClick:t,children:[w.jsx(AF,{className:"absolute size-4.5",initial:!1,variants:BE("outline"),custom:r,animate:"open"}),w.jsx(kF,{className:"absolute size-4.5",initial:!1,variants:BE("solid"),custom:r,animate:"open"})]})},UE=O.forwardRef(({message:e,handleInput:t,placeholders:n,handleSendMessage:r},a)=>{const i=J(h=>h.setCustomOpen),o=J(h=>h.botState),s=o==="loading"||o==="streaming",[l,u]=O.useState(0),c=O.useRef(null),d=O.useRef(0),p=O.useRef(null),f=!!i,g=O.useCallback(h=>{p.current=h,typeof a=="function"?a(h):a&&(a.current=h)},[a]);hE(p,"Enter",h=>{var b;h.shiftKey||(h.preventDefault(),r(),(b=p.current)==null||b.blur())},{enabled:!s,shiftKey:!1}),hE(p,"Escape",()=>{var h;(h=p.current)==null||h.blur()});const m=O.useCallback(()=>{if(document.visibilityState!=="visible"&&c.current)return;const h=b=>{b-d.current>=3e3&&(u(y=>(y+1)%n.length),d.current=b),c.current=requestAnimationFrame(h)};d.current=performance.now(),c.current=requestAnimationFrame(h)},[n.length]),v=O.useCallback(()=>{document.visibilityState!=="visible"&&c.current?(cancelAnimationFrame(c.current),c.current=null):document.visibilityState==="visible"&&m()},[m]);return O.useEffect(()=>(m(),document.addEventListener("visibilitychange",v),()=>{c.current&&cancelAnimationFrame(c.current),document.removeEventListener("visibilitychange",v)}),[n,m,v]),w.jsxs("div",{className:"flex flex-col",children:[w.jsx(TF,{}),w.jsx("div",{className:ee("flex flex-col rounded-xl border-2 border-black bg-telnyx-cream","transition-all focus-within:ring-1 focus-within:ring-black focus-within:ring-offset-0.5 focus-within:bg-telnyx-dark-cream","relative z-10",s&&"opacity-50"),children:w.jsxs("div",{className:"flex",children:[w.jsxs("div",{className:"pl-4 pt-3 pb-2 flex-1 relative",children:[w.jsx("textarea",{id:"user-message-input",ref:g,value:e,onInput:t,disabled:s,"aria-disabled":s,className:ee("w-full max-h-24 bg-transparent text-sm resize-none overflow-y-auto focus:outline-hidden focus:placeholder-black","scrollbar scrollbar-w-1 scrollbar-thumb-rounded-full scrollbar-track-transparent scrollbar-thumb-telnyx-gray-hover-light"),rows:1}),w.jsx("div",{className:"absolute inset-0 flex items-center pointer-events-none",children:w.jsx(Kt,{mode:"wait",children:!e&&w.jsx(fe.p,{initial:{y:5,opacity:0},animate:{y:0,opacity:1},exit:{y:-15,opacity:0},transition:{duration:.3,ease:"linear"},className:"text-neutral-500 text-sm pl-4 text-left w-[calc(100%-32px)] truncate",children:n[l]},`current-placeholder-${l}`)})})]}),w.jsx("span",{className:"w-12 flex items-center justify-center mb-0",children:f&&w.jsx(RF,{question:e,handleSendMessage:r})})]})})]})});UE.displayName="FooterTextInput";const IF={[fr.HAS_NOT_BEEN_OPENED]:{y:0},[fr.HAS_BEEN_OPENED]:{y:[0,-3,0],scale:[1,1.01,1],filter:["blur(0px)","blur(5px)","blur(0px)"],opacity:[1,.8,1]}};function CF({text:e,className:t}){const n=J(r=>r.hasWidgetBeenOpened);return e.split("").map((r,a)=>w.jsx(fe.span,{initial:!1,animate:n,variants:IF,transition:{duration:.5,delay:a*.05},className:ee("inline-block whitespace-pre font-sans tracking-tight",t),children:r},`${r}-${a}`))}const _F=()=>w.jsxs("div",{className:"flex justify-center text-xs pb-0.5 mt-2",children:[w.jsx(Ri,{className:"h-4 w-4 mr-1"}),w.jsx(CF,{className:"translate-y-0.5 font-pp-formula",text:"Powered by Telnyx"})]}),NF={[lt.INITIAL]:{y:0},[lt.USER_HAS_TYPED]:{y:0,transition:{duration:.2}}},jE=O.forwardRef(({question:e,handleInput:t,handleSendMessage:n},r)=>{const a=J(f=>f.chatVisualState),i=J(f=>f.onHelpAction),o=J(f=>f.botState),s=J(f=>f.getLastMessage()),l=(s==null?void 0:s.show_help_action)===!0,u=a===lt.USER_HAS_TYPED,c=J(f=>f.placeholders),d=o==="error"?["Error!","Please try again."]:c,p=l&&i!==null;return w.jsx("div",{className:ee("mt-2 pt-1",u&&"mt-0 mb-2 pt-0"),children:w.jsxs(fe.div,{initial:"initial",animate:a,variants:NF,className:"space-y-1",children:[p&&w.jsx(OF,{onHelpAction:i}),w.jsx(UE,{ref:r,message:e,handleInput:t,handleSendMessage:n,placeholders:d}),!u&&w.jsx(_F,{})]})})});jE.displayName="Footer";const OF=({onHelpAction:e})=>w.jsx("div",{className:"flex items-center justify-center mb-0.5",children:w.jsxs(fe.button,{initial:{scale:.5,opacity:0,y:10},animate:{scale:.75,opacity:1,y:0,transition:{duration:.2}},exit:{scale:.5,y:10,transition:{duration:.2}},whileHover:{scale:.8,transition:{duration:.2}},whileTap:{scale:.7,transition:{duration:.2}},className:ee("flex items-center gap-1 rounded-full p-2","bg-black text-white cursor-pointer"),onClick:e,children:[w.jsx("p",{className:"text-sm font-medium text-white",children:"Chat to support"}),w.jsx(BP,{className:"size-5 text-white"})]})}),LF=({children:e,className:t,containerClassName:n})=>{const r=Ss(0),a=Ss(0),i={default:`url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' width='16' height='16' fill='none'%3E%3Ccircle fill='%23404040' id='pattern-circle' cx='10' cy='10' r='2.5'%3E%3C/circle%3E%3C/svg%3E")`,hover:`url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' width='16' height='16' fill='none'%3E%3Ccircle fill='%2300E3AA' id='pattern-circle' cx='10' cy='10' r='2.5'%3E%3C/circle%3E%3C/svg%3E")`};function o({currentTarget:s,clientX:l,clientY:u}){if(!s)return;const{left:c,top:d}=s.getBoundingClientRect();r.set(l-c),a.set(u-d)}return w.jsxs("div",{className:ee("group relative h-full w-full items-center bg-black",n),onMouseMove:o,children:[w.jsx("div",{className:"pointer-events-none absolute inset-0",style:{backgroundImage:i.default}}),w.jsx(fe.div,{className:"pointer-events-none absolute inset-0 opacity-0 transition duration-300 group-hover:opacity-100",style:{backgroundImage:i.hover,WebkitMaskImage:Ey`
|
|
2542
2539
|
radial-gradient(
|
|
2543
2540
|
50px circle at ${r}px ${a}px,
|
|
2544
2541
|
black 0%,
|