@tekibo/feedpulse-sdk 0.7.0 → 0.7.1

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.
Files changed (3) hide show
  1. package/dist/nuxt.js +2 -2
  2. package/dist/nuxt.mjs +190 -182
  3. package/package.json +1 -1
package/dist/nuxt.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),N=require("./index.js"),T=require("./struggle-detector-DV52qDLp.js"),S=Symbol("feedpulse");function B(){return e.inject(S,null)}const P={style:{width:"360px",height:"520px",background:"#111827",color:"#e5e7eb",borderRadius:"16px",border:"1px solid #374151",boxShadow:"0 20px 40px rgba(0,0,0,0.35)",display:"flex",flexDirection:"column",overflow:"hidden",animation:"fp-panel-open 300ms ease-out"}},D={style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 14px",borderBottom:"1px solid #374151",background:"#0f172a"}},$={style:{flex:1,overflowY:"auto",padding:"12px",display:"grid",gap:"10px"}},A={key:0,style:{display:"flex",gap:"8px"}},I=["onClick"],M=["onClick"],F={key:0,style:{display:"flex",alignItems:"center",gap:"5px",padding:"4px 0"}},_={key:1,style:{border:"1px solid #f59e0b",background:"#451a03",color:"#fde68a",borderRadius:"10px",padding:"10px",fontSize:"12px"}},R={style:{display:"flex",gap:"8px"}},q=["disabled"],Y=["disabled"],j=["href"],L=e.defineComponent({__name:"BotPanel",props:{botSessionId:{},config:{},unavailable:{type:Boolean}},emits:["close","helpful","escalated"],setup(r,{emit:u}){const i=r,o=u,a=e.ref({}),t=e.ref([]),n=e.ref(""),s=e.ref(!1),m=e.ref(!1),y=e.computed(()=>n.value.trim().length>0&&!s.value&&!i.unavailable&&!m.value);function x(){return t.value.map(l=>({role:l.role,content:l.content}))}async function f(l){if(l.preventDefault(),!y.value)return;const d=n.value.trim();n.value="",t.value.push({id:`user-${Date.now()}`,role:"user",content:d});const c=`assistant-${Date.now()}`;t.value.push({id:c,role:"assistant",content:""}),s.value=!0,m.value=!1;try{const v=await fetch("/api/bot/chat-proxy",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({botSessionId:i.botSessionId,config:i.config,messages:x()})});if(v.status===402){m.value=!0;const b=t.value.find(w=>w.id===c);b&&(b.content="Service temporarily unavailable.");return}if(!v.ok)throw new Error("Chat request failed");const E=v.body?.getReader();if(!E)throw new Error("Missing stream");const g=new TextDecoder;let p=!1;for(;!p;){const b=await E.read();if(p=b.done,b.value){const w=g.decode(b.value,{stream:!p}),C=t.value.find(z=>z.id===c);C&&(C.content+=w)}}}catch{const v=t.value.find(E=>E.id===c);v&&!v.content&&(v.content="Sorry, I couldn't process that. Please try again.")}finally{s.value=!1}}function h(l,d){a.value[l]=d,o("helpful",d)}function k(){o("escalated")}return e.watch(()=>i.botSessionId,()=>{a.value={},t.value=[],n.value="",m.value=!1}),(l,d)=>(e.openBlock(),e.createElementBlock("div",P,[e.createElementVNode("div",D,[d[2]||(d[2]=e.createElementVNode("div",{style:{display:"grid",gap:"2px"}},[e.createElementVNode("strong",{style:{fontSize:"14px",color:"#fff"}},"Pulse Bot"),e.createElementVNode("span",{style:{fontSize:"11px",color:"#94a3b8"}},"Powered by FeedPulse AI")],-1)),e.createElementVNode("button",{style:{border:"none",background:"transparent",color:"#cbd5e1",cursor:"pointer",fontSize:"18px",lineHeight:"1"},onClick:d[0]||(d[0]=c=>o("close"))}," × ")]),e.createElementVNode("div",$,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.value,c=>(e.openBlock(),e.createElementBlock("div",{key:c.id,style:e.normalizeStyle({display:"grid",justifyItems:c.role==="user"?"end":"start",gap:"6px"})},[e.createElementVNode("div",{style:e.normalizeStyle({maxWidth:"85%",padding:"9px 11px",borderRadius:c.role==="user"?"14px 14px 2px 14px":"14px 14px 14px 2px",background:c.role==="user"?"#4f46e5":"#1f2937",color:"#fff",fontSize:"13px",lineHeight:"1.4",whiteSpace:"pre-wrap"})},e.toDisplayString(c.content),5),c.role==="assistant"?(e.openBlock(),e.createElementBlock("div",A,[e.createElementVNode("button",{style:e.normalizeStyle({border:"1px solid #334155",background:a.value[c.id]===!0?"#16a34a":"#0f172a",color:"#e2e8f0",borderRadius:"8px",fontSize:"12px",padding:"4px 8px",cursor:"pointer"}),onClick:v=>h(c.id,!0)}," 👍 ",12,I),e.createElementVNode("button",{style:e.normalizeStyle({border:"1px solid #334155",background:a.value[c.id]===!1?"#dc2626":"#0f172a",color:"#e2e8f0",borderRadius:"8px",fontSize:"12px",padding:"4px 8px",cursor:"pointer"}),onClick:v=>h(c.id,!1)}," 👎 ",12,M)])):e.createCommentVNode("",!0)],4))),128)),s.value?(e.openBlock(),e.createElementBlock("div",F,[...d[3]||(d[3]=[e.createElementVNode("span",{style:{width:"8px",height:"8px",borderRadius:"999px",background:"#94a3b8",animation:"fp-dot 1s infinite 0ms"}},null,-1),e.createElementVNode("span",{style:{width:"8px",height:"8px",borderRadius:"999px",background:"#94a3b8",animation:"fp-dot 1s infinite 160ms"}},null,-1),e.createElementVNode("span",{style:{width:"8px",height:"8px",borderRadius:"999px",background:"#94a3b8",animation:"fp-dot 1s infinite 320ms"}},null,-1)])])):e.createCommentVNode("",!0),r.unavailable||m.value?(e.openBlock(),e.createElementBlock("div",_," Service temporarily unavailable. ")):e.createCommentVNode("",!0)]),e.createElementVNode("form",{style:{padding:"10px",borderTop:"1px solid #374151",display:"grid",gap:"8px"},onSubmit:f},[e.createElementVNode("div",R,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":d[1]||(d[1]=c=>n.value=c),disabled:s.value||r.unavailable,style:{flex:1,borderRadius:"10px",border:"1px solid #475569",background:"#0f172a",color:"#fff",fontSize:"13px",padding:"8px 10px",outline:"none"},placeholder:"Ask a question..."},null,8,q),[[e.vModelText,n.value]]),e.createElementVNode("button",{type:"submit",disabled:!y.value,style:e.normalizeStyle({border:"none",borderRadius:"10px",background:y.value?"#6366f1":"#334155",color:"#fff",fontWeight:"600",fontSize:"12px",padding:"0 14px",cursor:y.value?"pointer":"not-allowed"})}," Send ",12,Y)]),r.config.escalateTo?(e.openBlock(),e.createElementBlock("a",{key:0,href:r.config.escalateTo.url,style:{color:"#c4b5fd",fontSize:"12px",textDecoration:"none"},onClick:k},e.toDisplayString(r.config.escalateTo.label),9,j)):e.createCommentVNode("",!0)],32)]))}}),H=e.defineComponent({__name:"FeedPulseBot",props:{faq:{},pageContext:{},systemPrompt:{},canNavigate:{type:Boolean},canHelpForms:{type:Boolean},escalateTo:{},initialMessage:{default:"👋 Need help?"},position:{default:"bottom-right"}},setup(r){const u=r,i=new N.CookieManager,o=e.ref(!1),a=e.ref(!1),t=e.ref(!1),n=e.ref(!1),s=e.ref(""),m=e.ref(null),y=e.ref(!1);let x=null,f=null;const h=e.computed(()=>({faq:u.faq||[],pageContext:u.pageContext||"",systemPrompt:u.systemPrompt||"",canNavigate:u.canNavigate??!1,canHelpForms:u.canHelpForms??!1,escalateTo:u.escalateTo})),k=e.computed(()=>({position:"fixed",bottom:"24px",zIndex:"10000",...u.position==="bottom-left"?{left:"24px"}:{right:"24px"}}));function l(){if(typeof document>"u"||document.getElementById("fp-bot-animations"))return;const g=document.createElement("style");g.id="fp-bot-animations",g.textContent=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),N=require("./index.js"),T=require("./struggle-detector-DV52qDLp.js"),S=Symbol("feedpulse");function B(){return e.inject(S,null)}const P={style:{width:"360px",height:"520px",background:"#111827",color:"#e5e7eb",borderRadius:"16px",border:"1px solid #374151",boxShadow:"0 20px 40px rgba(0,0,0,0.35)",display:"flex",flexDirection:"column",overflow:"hidden",animation:"fp-panel-open 300ms ease-out"}},D={style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 14px",borderBottom:"1px solid #374151",background:"#0f172a"}},$={style:{flex:1,overflowY:"auto",padding:"12px",display:"grid",gap:"10px"}},M={key:0,style:{display:"flex",gap:"8px"}},A=["onClick"],I=["onClick"],F={key:0,style:{display:"flex",alignItems:"center",gap:"5px",padding:"4px 0"}},_={key:1,style:{border:"1px solid #f59e0b",background:"#451a03",color:"#fde68a",borderRadius:"10px",padding:"10px",fontSize:"12px"}},R={style:{display:"flex",gap:"8px"}},q=["disabled"],Y=["disabled"],j=["href"],L=e.defineComponent({__name:"BotPanel",props:{botSessionId:{},config:{},unavailable:{type:Boolean}},emits:["close","helpful","escalated"],setup(s,{emit:a}){const r=s,o=a,l=e.ref({}),t=e.ref([]),n=e.ref(""),d=e.ref(!1),m=e.ref(!1),g=e.computed(()=>n.value.trim().length>0&&!d.value&&!r.unavailable&&!m.value);function x(){return t.value.map(i=>({role:i.role,content:i.content}))}async function f(i){if(i.preventDefault(),!g.value)return;const c=n.value.trim();n.value="",t.value.push({id:`user-${Date.now()}`,role:"user",content:c});const p=`assistant-${Date.now()}`;t.value.push({id:p,role:"assistant",content:""}),d.value=!0,m.value=!1;try{const b=await fetch("/api/bot/chat-proxy",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({botSessionId:r.botSessionId,config:JSON.parse(JSON.stringify(r.config)),messages:x()})});if(b.status===402){m.value=!0;const v=t.value.find(w=>w.id===p);v&&(v.content="Service temporarily unavailable.");return}if(!b.ok)throw new Error("Chat request failed");const E=b.body?.getReader();if(!E)throw new Error("Missing stream");const y=new TextDecoder;let u=!1;for(;!u;){const v=await E.read();if(u=v.done,v.value){const w=y.decode(v.value,{stream:!u}),C=t.value.find(z=>z.id===p);C&&(C.content+=w)}}}catch{const b=t.value.find(E=>E.id===p);b&&!b.content&&(b.content="Sorry, I couldn't process that. Please try again.")}finally{d.value=!1}}function k(i,c){l.value[i]=c,o("helpful",c)}function h(){o("escalated")}return e.watch(()=>r.botSessionId,()=>{l.value={},t.value=[],n.value="",m.value=!1}),(i,c)=>(e.openBlock(),e.createElementBlock("div",P,[e.createElementVNode("div",D,[c[2]||(c[2]=e.createElementVNode("div",{style:{display:"grid",gap:"2px"}},[e.createElementVNode("strong",{style:{fontSize:"14px",color:"#fff"}},"Pulse Bot"),e.createElementVNode("span",{style:{fontSize:"11px",color:"#94a3b8"}},"Powered by FeedPulse AI")],-1)),e.createElementVNode("button",{style:{border:"none",background:"transparent",color:"#cbd5e1",cursor:"pointer",fontSize:"18px",lineHeight:"1"},onClick:c[0]||(c[0]=p=>o("close"))}," × ")]),e.createElementVNode("div",$,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.value,p=>(e.openBlock(),e.createElementBlock("div",{key:p.id,style:e.normalizeStyle({display:"grid",justifyItems:p.role==="user"?"end":"start",gap:"6px"})},[e.createElementVNode("div",{style:e.normalizeStyle({maxWidth:"85%",padding:"9px 11px",borderRadius:p.role==="user"?"14px 14px 2px 14px":"14px 14px 14px 2px",background:p.role==="user"?"#4f46e5":"#1f2937",color:"#fff",fontSize:"13px",lineHeight:"1.4",whiteSpace:"pre-wrap"})},e.toDisplayString(p.content),5),p.role==="assistant"?(e.openBlock(),e.createElementBlock("div",M,[e.createElementVNode("button",{style:e.normalizeStyle({border:"1px solid #334155",background:l.value[p.id]===!0?"#16a34a":"#0f172a",color:"#e2e8f0",borderRadius:"8px",fontSize:"12px",padding:"4px 8px",cursor:"pointer"}),onClick:b=>k(p.id,!0)}," 👍 ",12,A),e.createElementVNode("button",{style:e.normalizeStyle({border:"1px solid #334155",background:l.value[p.id]===!1?"#dc2626":"#0f172a",color:"#e2e8f0",borderRadius:"8px",fontSize:"12px",padding:"4px 8px",cursor:"pointer"}),onClick:b=>k(p.id,!1)}," 👎 ",12,I)])):e.createCommentVNode("",!0)],4))),128)),d.value?(e.openBlock(),e.createElementBlock("div",F,[...c[3]||(c[3]=[e.createElementVNode("span",{style:{width:"8px",height:"8px",borderRadius:"999px",background:"#94a3b8",animation:"fp-dot 1s infinite 0ms"}},null,-1),e.createElementVNode("span",{style:{width:"8px",height:"8px",borderRadius:"999px",background:"#94a3b8",animation:"fp-dot 1s infinite 160ms"}},null,-1),e.createElementVNode("span",{style:{width:"8px",height:"8px",borderRadius:"999px",background:"#94a3b8",animation:"fp-dot 1s infinite 320ms"}},null,-1)])])):e.createCommentVNode("",!0),s.unavailable||m.value?(e.openBlock(),e.createElementBlock("div",_," Service temporarily unavailable. ")):e.createCommentVNode("",!0)]),e.createElementVNode("form",{style:{padding:"10px",borderTop:"1px solid #374151",display:"grid",gap:"8px"},onSubmit:f},[e.createElementVNode("div",R,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":c[1]||(c[1]=p=>n.value=p),disabled:d.value||s.unavailable,style:{flex:1,borderRadius:"10px",border:"1px solid #475569",background:"#0f172a",color:"#fff",fontSize:"13px",padding:"8px 10px",outline:"none"},placeholder:"Ask a question..."},null,8,q),[[e.vModelText,n.value]]),e.createElementVNode("button",{type:"submit",disabled:!g.value,style:e.normalizeStyle({border:"none",borderRadius:"10px",background:g.value?"#6366f1":"#334155",color:"#fff",fontWeight:"600",fontSize:"12px",padding:"0 14px",cursor:g.value?"pointer":"not-allowed"})}," Send ",12,Y)]),s.config.escalateTo?(e.openBlock(),e.createElementBlock("a",{key:0,href:s.config.escalateTo.url,style:{color:"#c4b5fd",fontSize:"12px",textDecoration:"none"},onClick:h},e.toDisplayString(s.config.escalateTo.label),9,j)):e.createCommentVNode("",!0)],32)]))}}),O=e.defineComponent({__name:"FeedPulseBot",props:{faq:{},pageContext:{},systemPrompt:{},canNavigate:{type:Boolean},navigableElements:{},canHelpForms:{type:Boolean},formGuide:{},features:{},escalateTo:{},initialMessage:{default:"👋 Need help?"},position:{default:"bottom-right"},config:{}},setup(s){const a=s,r=new N.CookieManager,o=e.ref(!1),l=e.ref(!1),t=e.ref(!1),n=e.ref(!1),d=e.ref(""),m=e.ref(null),g=e.ref(!1);let x=null,f=null;const k=e.computed(()=>a.config??{pageContext:a.pageContext,systemPrompt:a.systemPrompt,faq:a.faq,canNavigate:a.canNavigate,navigableElements:a.navigableElements,canHelpForms:a.canHelpForms,formGuide:a.formGuide,features:a.features,escalateTo:a.escalateTo,initialMessage:a.initialMessage}),h=e.computed(()=>({position:"fixed",bottom:"24px",zIndex:"10000",...a.position==="bottom-left"?{left:"24px"}:{right:"24px"}}));function i(){if(typeof document>"u"||document.getElementById("fp-bot-animations"))return;const y=document.createElement("style");y.id="fp-bot-animations",y.textContent=`
2
2
  @keyframes fp-bubble-in {
3
3
  0% { opacity: 0; transform: scale(0.8) translateY(6px); }
4
4
  100% { opacity: 1; transform: scale(1) translateY(0); }
@@ -17,4 +17,4 @@
17
17
  50% { opacity: 1; transform: translateY(-3px); }
18
18
  100% { opacity: 0.2; transform: translateY(0); }
19
19
  }
20
- `,document.head.appendChild(g)}async function d(g,p){const b=i.getAllData(!0);try{const w=await fetch("/api/bot/session-proxy",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({page:window.location.pathname,triggerScore:g,triggerReasons:p,sessionId:b.sessionId,visitorId:b.userId,device:navigator.userAgent})});if(!w.ok){w.status===402&&(n.value=!0);return}const C=await w.json().catch(()=>null);C?.botSessionId&&(s.value=C.botSessionId)}catch{}}function c(g,p){a.value=!0,o.value=!0,n.value=!1,m.value=null,y.value=!1,d(g,p),f&&clearTimeout(f),f=setTimeout(()=>{o.value=!1},8e3)}function v(){t.value=!0,o.value=!1}async function E(){if(t.value=!1,!!s.value)try{await fetch("/api/bot/session-end-proxy",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({botSessionId:s.value,wasHelpful:m.value,escalated:y.value})})}catch{}}return e.onMounted(()=>{l(),x=new T.StruggleDetector({onTrigger:(g,p)=>{c(g,p)}}),x.start()}),e.onBeforeUnmount(()=>{x?.stop(),f&&clearTimeout(f)}),(g,p)=>(e.openBlock(),e.createElementBlock("div",{style:e.normalizeStyle(k.value)},[o.value&&!t.value?(e.openBlock(),e.createElementBlock("div",{key:0,style:e.normalizeStyle({position:"absolute",bottom:"62px",right:r.position==="bottom-right"?"0":"auto",left:r.position==="bottom-left"?"0":"auto",background:"#fff",border:"2px solid #6366f1",color:"#1f2937",borderRadius:"12px 12px 0 12px",padding:"10px 12px",maxWidth:"240px",fontSize:"13px",boxShadow:"0 10px 22px rgba(0,0,0,0.16)",animation:"fp-bubble-in 300ms ease-out"})},[e.createTextVNode(e.toDisplayString(r.initialMessage)+" ",1),p[2]||(p[2]=e.createElementVNode("span",{style:{position:"absolute",right:"10px",bottom:"-12px",width:"0",height:"0",borderLeft:"10px solid transparent",borderTop:"12px solid #6366f1"}},null,-1)),p[3]||(p[3]=e.createElementVNode("span",{style:{position:"absolute",right:"11px",bottom:"-9px",width:"0",height:"0",borderLeft:"9px solid transparent",borderTop:"11px solid #fff"}},null,-1))],4)):e.createCommentVNode("",!0),a.value&&!t.value?(e.openBlock(),e.createElementBlock("button",{key:1,style:{width:"48px",height:"48px",borderRadius:"999px",border:"none",background:"#6366f1",boxShadow:"0 12px 26px rgba(79,70,229,0.45)",cursor:"pointer",display:"grid",placeItems:"center",animation:"fp-bounce 600ms ease-out"},onClick:v},[...p[4]||(p[4]=[e.createStaticVNode('<svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2"><rect x="3" y="8" width="18" height="13" rx="2"></rect><path d="M12 8V5"></path><circle cx="12" cy="4" r="1"></circle><circle cx="8" cy="13" r="1.5" fill="white" stroke="none"></circle><circle cx="16" cy="13" r="1.5" fill="white" stroke="none"></circle><path d="M9 17h6" stroke-linecap="round"></path></svg>',1)])])):e.createCommentVNode("",!0),t.value&&s.value?(e.openBlock(),e.createBlock(L,{key:2,"bot-session-id":s.value,config:h.value,unavailable:n.value,onClose:E,onHelpful:p[0]||(p[0]=b=>m.value=b),onEscalated:p[1]||(p[1]=b=>y.value=!0)},null,8,["bot-session-id","config","unavailable"])):e.createCommentVNode("",!0)],4))}}),O={key:0,style:{position:"fixed",bottom:"0",left:"0",right:"0","z-index":"99999",background:"#1a1a1a",color:"#fff",padding:"20px 24px","border-top":"1px solid #333","font-family":"sans-serif"}},U={style:{"max-width":"900px",margin:"0 auto"}},W={key:0,style:{"margin-bottom":"12px","font-size":"13px"}},J={style:{display:"flex","align-items":"center",gap:"8px","margin-bottom":"6px"}},K={style:{display:"flex","align-items":"center",gap:"8px"}},G={style:{display:"flex",gap:"8px","flex-wrap":"wrap","align-items":"center"}},V=e.defineComponent({__name:"consent-banner",emits:["consent"],setup(r,{emit:u}){const i=u,o=new N.CookieManager,a=e.ref(!1),t=e.ref(!1),n=e.ref(!1),s=e.ref(!1);function m(){a.value=!0,t.value=!0}e.onMounted(()=>{const k=o.getConsent();a.value=!k||o.isConsentExpired(),k&&(n.value=k.analytics,s.value=k.marketing),typeof window<"u"&&(window.addEventListener("feedpulse:open-consent",m),window.addEventListener("feedpulse:withdraw-consent",h))});function y(){o.setConsent({analytics:!0,marketing:!0,version:"1.0"}),i("consent",{analytics:!0,marketing:!0,action:"accept_all"}),a.value=!1}function x(){o.setConsent({analytics:!1,marketing:!1,version:"1.0"}),o.clearAnalyticsCookies(),i("consent",{analytics:!1,marketing:!1,action:"reject_all"}),a.value=!1}function f(){o.setConsent({analytics:n.value,marketing:s.value,version:"1.0"}),n.value||o.clearAnalyticsCookies(),i("consent",{analytics:n.value,marketing:s.value,action:"custom"}),a.value=!1}function h(){o.setConsent({analytics:!1,marketing:!1,version:"1.0"}),o.clearAnalyticsCookies(),n.value=!1,s.value=!1,i("consent",{analytics:!1,marketing:!1,action:"withdraw"}),a.value=!0}return e.onBeforeUnmount(()=>{typeof window<"u"&&(window.removeEventListener("feedpulse:open-consent",m),window.removeEventListener("feedpulse:withdraw-consent",h))}),(k,l)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[a.value?(e.openBlock(),e.createElementBlock("div",O,[e.createElementVNode("div",U,[l[6]||(l[6]=e.createElementVNode("p",{style:{margin:"0 0 12px","font-size":"14px","line-height":"1.5"}},[e.createTextVNode(" We use cookies to improve reliability and understand usage. "),e.createElementVNode("a",{href:"/privacy",style:{color:"#818cf8"}},"Privacy Policy")],-1)),t.value?(e.openBlock(),e.createElementBlock("div",W,[l[5]||(l[5]=e.createElementVNode("label",{style:{display:"flex","align-items":"center",gap:"8px","margin-bottom":"6px",opacity:"0.75"}},[e.createElementVNode("input",{type:"checkbox",checked:"",disabled:""}),e.createTextVNode(" Necessary (always on) ")],-1)),e.createElementVNode("label",J,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":l[0]||(l[0]=d=>n.value=d),type:"checkbox"},null,512),[[e.vModelCheckbox,n.value]]),l[3]||(l[3]=e.createTextVNode(" Analytics ",-1))]),e.createElementVNode("label",K,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":l[1]||(l[1]=d=>s.value=d),type:"checkbox"},null,512),[[e.vModelCheckbox,s.value]]),l[4]||(l[4]=e.createTextVNode(" Marketing ",-1))])])):e.createCommentVNode("",!0),e.createElementVNode("div",G,[e.createElementVNode("button",{style:{width:"130px",padding:"9px 12px",background:"#4f46e5",color:"#fff",border:"1px solid #4f46e5","border-radius":"6px","font-size":"13px","font-weight":"600",cursor:"pointer"},onClick:y}," Accept All "),e.createElementVNode("button",{style:{width:"130px",padding:"9px 12px",background:"transparent",color:"#fff",border:"1px solid #555","border-radius":"6px","font-size":"13px","font-weight":"600",cursor:"pointer"},onClick:x}," Reject All "),e.createElementVNode("button",{style:{padding:"9px 16px",background:"transparent",color:"#aaa",border:"1px solid #333","border-radius":"6px","font-size":"13px",cursor:"pointer"},onClick:l[2]||(l[2]=d=>t.value?f():t.value=!0)},e.toDisplayString(t.value?"Save Preferences":"Customize"),1)])])])):e.createCommentVNode("",!0)]))}}),Q=e.defineComponent({__name:"FeedPulseProvider",props:{proxyEndpoint:{default:"/api/fp-proxy"},debug:{type:Boolean},consentRequired:{type:Boolean,default:!0}},setup(r){const u=r,i=new N.CookieManager,o=new N.FeedPulseTracker({proxyEndpoint:u.proxyEndpoint,debug:u.debug});e.provide(S,o);function a(t){const n=i.setConsent({analytics:t.analytics,marketing:t.marketing,version:"1.0"});t.analytics||i.clearAnalyticsCookies(),o.updateCookieData(i.getAllData(t.analytics)),o.track("consent","__consent__",{analytics:t.analytics,marketing:t.marketing,action:t.action,userAgent:navigator.userAgent,version:n.version})}return e.onMounted(()=>{const t=i.getConsent();u.consentRequired===!1?(i.setConsent({analytics:!0,marketing:!0,version:"1.0"}),o.updateCookieData(i.getAllData(!0))):t&&!i.isConsentExpired()?o.updateCookieData(i.getAllData(t.analytics)):o.updateCookieData(i.getAllData(!1)),o.init()}),e.onBeforeUnmount(()=>o.destroy()),(t,n)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.renderSlot(t.$slots,"default"),r.consentRequired!==!1?(e.openBlock(),e.createBlock(V,{key:0,onConsent:a})):e.createCommentVNode("",!0)],64))}}),X={key:1,style:{background:"#fff",border:"1px solid #e5e7eb","border-radius":"12px",padding:"16px",width:"280px","box-shadow":"0 10px 25px rgba(0,0,0,0.15)"}},Z={style:{margin:"0 0 12px","font-weight":"600",color:"#111"}},ee={style:{display:"flex",gap:"6px","margin-bottom":"12px"}},te=["onClick"],oe={key:1,style:{"text-align":"center",padding:"16px",color:"#111"}},ne=e.defineComponent({__name:"FeedPulseWidget",props:{id:{},placeholder:{},position:{default:"bottom-right"}},setup(r){const u=r,i=B(),o=e.ref(u.position==="inline"),a=e.ref(null),t=e.ref(""),n=e.ref(!1);function s(y){a.value=y}function m(){!a.value&&!t.value.trim()||(i?.trackFeedback(u.id??null,a.value,t.value||null),n.value=!0,setTimeout(()=>{o.value=u.position==="inline",n.value=!1,a.value=null,t.value=""},2e3))}return(y,x)=>(e.openBlock(),e.createElementBlock("div",{class:"feedpulse-widget",style:e.normalizeStyle(r.position!=="inline"?`position:fixed; ${r.position==="bottom-right"?"right:24px":"left:24px"}; bottom:24px; z-index:9999;`:"")},[r.position!=="inline"?(e.openBlock(),e.createElementBlock("button",{key:0,style:{background:"#6366f1",color:"#fff",border:"none","border-radius":"50%",width:"48px",height:"48px","font-size":"20px",cursor:"pointer"},onClick:x[0]||(x[0]=f=>o.value=!o.value)}," 💬 ")):e.createCommentVNode("",!0),o.value?(e.openBlock(),e.createElementBlock("div",X,[n.value?(e.openBlock(),e.createElementBlock("div",oe,[...x[2]||(x[2]=[e.createElementVNode("p",{style:{"font-size":"28px",margin:"0"}}," 🎉 ",-1),e.createElementVNode("p",{style:{margin:"8px 0 0","font-weight":"600"}}," Thanks for your feedback! ",-1)])])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("p",Z,e.toDisplayString(r.placeholder??"How was your experience?"),1),e.createElementVNode("div",ee,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(5,f=>e.createElementVNode("button",{key:f,style:e.normalizeStyle({background:"none",border:"none",cursor:"pointer",fontSize:"24px",opacity:a.value!==null&&f<=a.value?1:.3}),onClick:h=>s(f)}," ⭐ ",12,te)),64))]),e.withDirectives(e.createElementVNode("textarea",{"onUpdate:modelValue":x[1]||(x[1]=f=>t.value=f),placeholder:"Tell us more (optional)...",rows:"3",style:{width:"100%",padding:"8px",border:"1px solid #d1d5db","border-radius":"8px",resize:"none","font-size":"14px"}},null,512),[[e.vModelText,t.value]]),e.createElementVNode("button",{style:{"margin-top":"10px",width:"100%",background:"#6366f1",color:"#fff",border:"none","border-radius":"8px",padding:"10px","font-weight":"600",cursor:"pointer"},onClick:m}," Submit Feedback ")],64))])):e.createCommentVNode("",!0)],4))}});exports.ConsentBanner=V;exports.FeedPulseBot=H;exports.FeedPulseProvider=Q;exports.FeedPulseWidget=ne;exports.useFeedPulse=B;
20
+ `,document.head.appendChild(y)}async function c(y,u){const v=r.getAllData(!0);try{const w=await fetch("/api/bot/session-proxy",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({page:window.location.pathname,triggerScore:y,triggerReasons:u,sessionId:v.sessionId,visitorId:v.userId,device:navigator.userAgent})});if(!w.ok){w.status===402&&(n.value=!0);return}const C=await w.json().catch(()=>null);C?.botSessionId&&(d.value=C.botSessionId)}catch{}}function p(y,u){l.value=!0,o.value=!0,n.value=!1,m.value=null,g.value=!1,c(y,u),f&&clearTimeout(f),f=setTimeout(()=>{o.value=!1},8e3)}function b(){t.value=!0,o.value=!1}async function E(){if(t.value=!1,!!d.value)try{await fetch("/api/bot/session-end-proxy",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({botSessionId:d.value,wasHelpful:m.value,escalated:g.value})})}catch{}}return e.onMounted(()=>{i(),x=new T.StruggleDetector({onTrigger:(y,u)=>{p(y,u)}}),x.start()}),e.onBeforeUnmount(()=>{x?.stop(),f&&clearTimeout(f)}),(y,u)=>(e.openBlock(),e.createElementBlock("div",{style:e.normalizeStyle(h.value)},[o.value&&!t.value?(e.openBlock(),e.createElementBlock("div",{key:0,style:e.normalizeStyle({position:"absolute",bottom:"62px",right:s.position==="bottom-right"?"0":"auto",left:s.position==="bottom-left"?"0":"auto",background:"#fff",border:"2px solid #6366f1",color:"#1f2937",borderRadius:"12px 12px 0 12px",padding:"10px 12px",maxWidth:"240px",fontSize:"13px",boxShadow:"0 10px 22px rgba(0,0,0,0.16)",animation:"fp-bubble-in 300ms ease-out"})},[e.createTextVNode(e.toDisplayString(k.value.initialMessage||s.initialMessage)+" ",1),u[2]||(u[2]=e.createElementVNode("span",{style:{position:"absolute",right:"10px",bottom:"-12px",width:"0",height:"0",borderLeft:"10px solid transparent",borderTop:"12px solid #6366f1"}},null,-1)),u[3]||(u[3]=e.createElementVNode("span",{style:{position:"absolute",right:"11px",bottom:"-9px",width:"0",height:"0",borderLeft:"9px solid transparent",borderTop:"11px solid #fff"}},null,-1))],4)):e.createCommentVNode("",!0),l.value&&!t.value?(e.openBlock(),e.createElementBlock("button",{key:1,style:{width:"48px",height:"48px",borderRadius:"999px",border:"none",background:"#6366f1",boxShadow:"0 12px 26px rgba(79,70,229,0.45)",cursor:"pointer",display:"grid",placeItems:"center",animation:"fp-bounce 600ms ease-out"},onClick:b},[...u[4]||(u[4]=[e.createStaticVNode('<svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2"><rect x="3" y="8" width="18" height="13" rx="2"></rect><path d="M12 8V5"></path><circle cx="12" cy="4" r="1"></circle><circle cx="8" cy="13" r="1.5" fill="white" stroke="none"></circle><circle cx="16" cy="13" r="1.5" fill="white" stroke="none"></circle><path d="M9 17h6" stroke-linecap="round"></path></svg>',1)])])):e.createCommentVNode("",!0),t.value&&d.value?(e.openBlock(),e.createBlock(L,{key:2,"bot-session-id":d.value,config:k.value,unavailable:n.value,onClose:E,onHelpful:u[0]||(u[0]=v=>m.value=v),onEscalated:u[1]||(u[1]=v=>g.value=!0)},null,8,["bot-session-id","config","unavailable"])):e.createCommentVNode("",!0)],4))}}),H={key:0,style:{position:"fixed",bottom:"0",left:"0",right:"0","z-index":"99999",background:"#1a1a1a",color:"#fff",padding:"20px 24px","border-top":"1px solid #333","font-family":"sans-serif"}},U={style:{"max-width":"900px",margin:"0 auto"}},W={key:0,style:{"margin-bottom":"12px","font-size":"13px"}},J={style:{display:"flex","align-items":"center",gap:"8px","margin-bottom":"6px"}},G={style:{display:"flex","align-items":"center",gap:"8px"}},K={style:{display:"flex",gap:"8px","flex-wrap":"wrap","align-items":"center"}},V=e.defineComponent({__name:"consent-banner",emits:["consent"],setup(s,{emit:a}){const r=a,o=new N.CookieManager,l=e.ref(!1),t=e.ref(!1),n=e.ref(!1),d=e.ref(!1);function m(){l.value=!0,t.value=!0}e.onMounted(()=>{const h=o.getConsent();l.value=!h||o.isConsentExpired(),h&&(n.value=h.analytics,d.value=h.marketing),typeof window<"u"&&(window.addEventListener("feedpulse:open-consent",m),window.addEventListener("feedpulse:withdraw-consent",k))});function g(){o.setConsent({analytics:!0,marketing:!0,version:"1.0"}),r("consent",{analytics:!0,marketing:!0,action:"accept_all"}),l.value=!1}function x(){o.setConsent({analytics:!1,marketing:!1,version:"1.0"}),o.clearAnalyticsCookies(),r("consent",{analytics:!1,marketing:!1,action:"reject_all"}),l.value=!1}function f(){o.setConsent({analytics:n.value,marketing:d.value,version:"1.0"}),n.value||o.clearAnalyticsCookies(),r("consent",{analytics:n.value,marketing:d.value,action:"custom"}),l.value=!1}function k(){o.setConsent({analytics:!1,marketing:!1,version:"1.0"}),o.clearAnalyticsCookies(),n.value=!1,d.value=!1,r("consent",{analytics:!1,marketing:!1,action:"withdraw"}),l.value=!0}return e.onBeforeUnmount(()=>{typeof window<"u"&&(window.removeEventListener("feedpulse:open-consent",m),window.removeEventListener("feedpulse:withdraw-consent",k))}),(h,i)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[l.value?(e.openBlock(),e.createElementBlock("div",H,[e.createElementVNode("div",U,[i[6]||(i[6]=e.createElementVNode("p",{style:{margin:"0 0 12px","font-size":"14px","line-height":"1.5"}},[e.createTextVNode(" We use cookies to improve reliability and understand usage. "),e.createElementVNode("a",{href:"/privacy",style:{color:"#818cf8"}},"Privacy Policy")],-1)),t.value?(e.openBlock(),e.createElementBlock("div",W,[i[5]||(i[5]=e.createElementVNode("label",{style:{display:"flex","align-items":"center",gap:"8px","margin-bottom":"6px",opacity:"0.75"}},[e.createElementVNode("input",{type:"checkbox",checked:"",disabled:""}),e.createTextVNode(" Necessary (always on) ")],-1)),e.createElementVNode("label",J,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":i[0]||(i[0]=c=>n.value=c),type:"checkbox"},null,512),[[e.vModelCheckbox,n.value]]),i[3]||(i[3]=e.createTextVNode(" Analytics ",-1))]),e.createElementVNode("label",G,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":i[1]||(i[1]=c=>d.value=c),type:"checkbox"},null,512),[[e.vModelCheckbox,d.value]]),i[4]||(i[4]=e.createTextVNode(" Marketing ",-1))])])):e.createCommentVNode("",!0),e.createElementVNode("div",K,[e.createElementVNode("button",{style:{width:"130px",padding:"9px 12px",background:"#4f46e5",color:"#fff",border:"1px solid #4f46e5","border-radius":"6px","font-size":"13px","font-weight":"600",cursor:"pointer"},onClick:g}," Accept All "),e.createElementVNode("button",{style:{width:"130px",padding:"9px 12px",background:"transparent",color:"#fff",border:"1px solid #555","border-radius":"6px","font-size":"13px","font-weight":"600",cursor:"pointer"},onClick:x}," Reject All "),e.createElementVNode("button",{style:{padding:"9px 16px",background:"transparent",color:"#aaa",border:"1px solid #333","border-radius":"6px","font-size":"13px",cursor:"pointer"},onClick:i[2]||(i[2]=c=>t.value?f():t.value=!0)},e.toDisplayString(t.value?"Save Preferences":"Customize"),1)])])])):e.createCommentVNode("",!0)]))}}),Q=e.defineComponent({__name:"FeedPulseProvider",props:{proxyEndpoint:{default:"/api/fp-proxy"},debug:{type:Boolean},consentRequired:{type:Boolean,default:!0}},setup(s){const a=s,r=new N.CookieManager,o=new N.FeedPulseTracker({proxyEndpoint:a.proxyEndpoint,debug:a.debug});e.provide(S,o);function l(t){const n=r.setConsent({analytics:t.analytics,marketing:t.marketing,version:"1.0"});t.analytics||r.clearAnalyticsCookies(),o.updateCookieData(r.getAllData(t.analytics)),o.track("consent","__consent__",{analytics:t.analytics,marketing:t.marketing,action:t.action,userAgent:navigator.userAgent,version:n.version})}return e.onMounted(()=>{const t=r.getConsent();a.consentRequired===!1?(r.setConsent({analytics:!0,marketing:!0,version:"1.0"}),o.updateCookieData(r.getAllData(!0))):t&&!r.isConsentExpired()?o.updateCookieData(r.getAllData(t.analytics)):o.updateCookieData(r.getAllData(!1)),o.init()}),e.onBeforeUnmount(()=>o.destroy()),(t,n)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.renderSlot(t.$slots,"default"),s.consentRequired!==!1?(e.openBlock(),e.createBlock(V,{key:0,onConsent:l})):e.createCommentVNode("",!0)],64))}}),X={key:1,style:{background:"#fff",border:"1px solid #e5e7eb","border-radius":"12px",padding:"16px",width:"280px","box-shadow":"0 10px 25px rgba(0,0,0,0.15)"}},Z={style:{margin:"0 0 12px","font-weight":"600",color:"#111"}},ee={style:{display:"flex",gap:"6px","margin-bottom":"12px"}},te=["onClick"],oe={key:1,style:{"text-align":"center",padding:"16px",color:"#111"}},ne=e.defineComponent({__name:"FeedPulseWidget",props:{id:{},placeholder:{},position:{default:"bottom-right"}},setup(s){const a=s,r=B(),o=e.ref(a.position==="inline"),l=e.ref(null),t=e.ref(""),n=e.ref(!1);function d(g){l.value=g}function m(){!l.value&&!t.value.trim()||(r?.trackFeedback(a.id??null,l.value,t.value||null),n.value=!0,setTimeout(()=>{o.value=a.position==="inline",n.value=!1,l.value=null,t.value=""},2e3))}return(g,x)=>(e.openBlock(),e.createElementBlock("div",{class:"feedpulse-widget",style:e.normalizeStyle(s.position!=="inline"?`position:fixed; ${s.position==="bottom-right"?"right:24px":"left:24px"}; bottom:24px; z-index:9999;`:"")},[s.position!=="inline"?(e.openBlock(),e.createElementBlock("button",{key:0,style:{background:"#6366f1",color:"#fff",border:"none","border-radius":"50%",width:"48px",height:"48px","font-size":"20px",cursor:"pointer"},onClick:x[0]||(x[0]=f=>o.value=!o.value)}," 💬 ")):e.createCommentVNode("",!0),o.value?(e.openBlock(),e.createElementBlock("div",X,[n.value?(e.openBlock(),e.createElementBlock("div",oe,[...x[2]||(x[2]=[e.createElementVNode("p",{style:{"font-size":"28px",margin:"0"}}," 🎉 ",-1),e.createElementVNode("p",{style:{margin:"8px 0 0","font-weight":"600"}}," Thanks for your feedback! ",-1)])])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("p",Z,e.toDisplayString(s.placeholder??"How was your experience?"),1),e.createElementVNode("div",ee,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(5,f=>e.createElementVNode("button",{key:f,style:e.normalizeStyle({background:"none",border:"none",cursor:"pointer",fontSize:"24px",opacity:l.value!==null&&f<=l.value?1:.3}),onClick:k=>d(f)}," ⭐ ",12,te)),64))]),e.withDirectives(e.createElementVNode("textarea",{"onUpdate:modelValue":x[1]||(x[1]=f=>t.value=f),placeholder:"Tell us more (optional)...",rows:"3",style:{width:"100%",padding:"8px",border:"1px solid #d1d5db","border-radius":"8px",resize:"none","font-size":"14px"}},null,512),[[e.vModelText,t.value]]),e.createElementVNode("button",{style:{"margin-top":"10px",width:"100%",background:"#6366f1",color:"#fff",border:"none","border-radius":"8px",padding:"10px","font-weight":"600",cursor:"pointer"},onClick:m}," Submit Feedback ")],64))])):e.createCommentVNode("",!0)],4))}});exports.ConsentBanner=V;exports.FeedPulseBot=O;exports.FeedPulseProvider=Q;exports.FeedPulseWidget=ne;exports.useFeedPulse=B;
package/dist/nuxt.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import { inject as O, defineComponent as E, ref as f, computed as B, watch as U, createElementBlock as b, openBlock as l, createElementVNode as t, createCommentVNode as w, Fragment as _, renderList as L, normalizeStyle as P, toDisplayString as D, withDirectives as R, vModelText as q, onMounted as F, onBeforeUnmount as M, createBlock as N, createTextVNode as I, createStaticVNode as W, Teleport as J, vModelCheckbox as j, provide as K, renderSlot as G } from "vue";
1
+ import { inject as V, defineComponent as D, ref as x, computed as B, watch as U, createElementBlock as g, openBlock as r, createElementVNode as t, createCommentVNode as w, Fragment as _, renderList as L, normalizeStyle as T, toDisplayString as I, withDirectives as R, vModelText as O, onMounted as M, onBeforeUnmount as F, createBlock as N, createTextVNode as A, createStaticVNode as W, Teleport as J, vModelCheckbox as j, provide as G, renderSlot as K } from "vue";
2
2
  import { CookieManager as Y, FeedPulseTracker as Q } from "./index.mjs";
3
3
  import { S as X } from "./struggle-detector-BqTHgw95.mjs";
4
- const H = /* @__PURE__ */ Symbol("feedpulse");
4
+ const q = /* @__PURE__ */ Symbol("feedpulse");
5
5
  function Z() {
6
- return O(H, null);
6
+ return V(q, null);
7
7
  }
8
8
  const ee = { style: {
9
9
  width: "360px",
@@ -40,7 +40,7 @@ const ee = { style: {
40
40
  padding: "10px",
41
41
  fontSize: "12px"
42
42
  }
43
- }, re = { style: { display: "flex", gap: "8px" } }, de = ["disabled"], ue = ["disabled"], pe = ["href"], ce = /* @__PURE__ */ E({
43
+ }, re = { style: { display: "flex", gap: "8px" } }, de = ["disabled"], ue = ["disabled"], pe = ["href"], ce = /* @__PURE__ */ D({
44
44
  __name: "BotPanel",
45
45
  props: {
46
46
  botSessionId: {},
@@ -48,42 +48,42 @@ const ee = { style: {
48
48
  unavailable: { type: Boolean }
49
49
  },
50
50
  emits: ["close", "helpful", "escalated"],
51
- setup(r, { emit: x }) {
52
- const s = r, o = x, a = f({}), e = f([]), n = f(""), d = f(!1), g = f(!1), m = B(() => n.value.trim().length > 0 && !d.value && !s.unavailable && !g.value);
51
+ setup(d, { emit: a }) {
52
+ const l = d, o = a, i = x({}), e = x([]), n = x(""), u = x(!1), y = x(!1), m = B(() => n.value.trim().length > 0 && !u.value && !l.unavailable && !y.value);
53
53
  function v() {
54
- return e.value.map((i) => ({
55
- role: i.role,
56
- content: i.content
54
+ return e.value.map((s) => ({
55
+ role: s.role,
56
+ content: s.content
57
57
  }));
58
58
  }
59
- async function y(i) {
60
- if (i.preventDefault(), !m.value)
59
+ async function b(s) {
60
+ if (s.preventDefault(), !m.value)
61
61
  return;
62
- const u = n.value.trim();
62
+ const p = n.value.trim();
63
63
  n.value = "", e.value.push({
64
64
  id: `user-${Date.now()}`,
65
65
  role: "user",
66
- content: u
66
+ content: p
67
67
  });
68
- const p = `assistant-${Date.now()}`;
68
+ const c = `assistant-${Date.now()}`;
69
69
  e.value.push({
70
- id: p,
70
+ id: c,
71
71
  role: "assistant",
72
72
  content: ""
73
- }), d.value = !0, g.value = !1;
73
+ }), u.value = !0, y.value = !1;
74
74
  try {
75
75
  const S = await fetch("/api/bot/chat-proxy", {
76
76
  method: "POST",
77
77
  headers: { "content-type": "application/json" },
78
78
  body: JSON.stringify({
79
- botSessionId: s.botSessionId,
80
- config: s.config,
79
+ botSessionId: l.botSessionId,
80
+ config: JSON.parse(JSON.stringify(l.config)),
81
81
  messages: v()
82
82
  })
83
83
  });
84
84
  if (S.status === 402) {
85
- g.value = !0;
86
- const k = e.value.find((z) => z.id === p);
85
+ y.value = !0;
86
+ const k = e.value.find((z) => z.id === c);
87
87
  k && (k.content = "Service temporarily unavailable.");
88
88
  return;
89
89
  }
@@ -93,32 +93,32 @@ const ee = { style: {
93
93
  if (!$)
94
94
  throw new Error("Missing stream");
95
95
  const h = new TextDecoder();
96
- let c = !1;
97
- for (; !c; ) {
96
+ let f = !1;
97
+ for (; !f; ) {
98
98
  const k = await $.read();
99
- if (c = k.done, k.value) {
100
- const z = h.decode(k.value, { stream: !c }), A = e.value.find((V) => V.id === p);
101
- A && (A.content += z);
99
+ if (f = k.done, k.value) {
100
+ const z = h.decode(k.value, { stream: !f }), E = e.value.find((H) => H.id === c);
101
+ E && (E.content += z);
102
102
  }
103
103
  }
104
104
  } catch {
105
- const S = e.value.find(($) => $.id === p);
105
+ const S = e.value.find(($) => $.id === c);
106
106
  S && !S.content && (S.content = "Sorry, I couldn't process that. Please try again.");
107
107
  } finally {
108
- d.value = !1;
108
+ u.value = !1;
109
109
  }
110
110
  }
111
- function T(i, u) {
112
- a.value[i] = u, o("helpful", u);
111
+ function C(s, p) {
112
+ i.value[s] = p, o("helpful", p);
113
113
  }
114
- function C() {
114
+ function P() {
115
115
  o("escalated");
116
116
  }
117
- return U(() => s.botSessionId, () => {
118
- a.value = {}, e.value = [], n.value = "", g.value = !1;
119
- }), (i, u) => (l(), b("div", ee, [
117
+ return U(() => l.botSessionId, () => {
118
+ i.value = {}, e.value = [], n.value = "", y.value = !1;
119
+ }), (s, p) => (r(), g("div", ee, [
120
120
  t("div", te, [
121
- u[2] || (u[2] = t("div", { style: { display: "grid", gap: "2px" } }, [
121
+ p[2] || (p[2] = t("div", { style: { display: "grid", gap: "2px" } }, [
122
122
  t("strong", { style: { fontSize: "14px", color: "#fff" } }, "Pulse Bot"),
123
123
  t("span", { style: { fontSize: "11px", color: "#94a3b8" } }, "Powered by FeedPulse AI")
124
124
  ], -1)),
@@ -131,72 +131,72 @@ const ee = { style: {
131
131
  fontSize: "18px",
132
132
  lineHeight: "1"
133
133
  },
134
- onClick: u[0] || (u[0] = (p) => o("close"))
134
+ onClick: p[0] || (p[0] = (c) => o("close"))
135
135
  }, " × ")
136
136
  ]),
137
137
  t("div", oe, [
138
- (l(!0), b(_, null, L(e.value, (p) => (l(), b("div", {
139
- key: p.id,
140
- style: P({
138
+ (r(!0), g(_, null, L(e.value, (c) => (r(), g("div", {
139
+ key: c.id,
140
+ style: T({
141
141
  display: "grid",
142
- justifyItems: p.role === "user" ? "end" : "start",
142
+ justifyItems: c.role === "user" ? "end" : "start",
143
143
  gap: "6px"
144
144
  })
145
145
  }, [
146
146
  t("div", {
147
- style: P({
147
+ style: T({
148
148
  maxWidth: "85%",
149
149
  padding: "9px 11px",
150
- borderRadius: p.role === "user" ? "14px 14px 2px 14px" : "14px 14px 14px 2px",
151
- background: p.role === "user" ? "#4f46e5" : "#1f2937",
150
+ borderRadius: c.role === "user" ? "14px 14px 2px 14px" : "14px 14px 14px 2px",
151
+ background: c.role === "user" ? "#4f46e5" : "#1f2937",
152
152
  color: "#fff",
153
153
  fontSize: "13px",
154
154
  lineHeight: "1.4",
155
155
  whiteSpace: "pre-wrap"
156
156
  })
157
- }, D(p.content), 5),
158
- p.role === "assistant" ? (l(), b("div", ne, [
157
+ }, I(c.content), 5),
158
+ c.role === "assistant" ? (r(), g("div", ne, [
159
159
  t("button", {
160
- style: P({
160
+ style: T({
161
161
  border: "1px solid #334155",
162
- background: a.value[p.id] === !0 ? "#16a34a" : "#0f172a",
162
+ background: i.value[c.id] === !0 ? "#16a34a" : "#0f172a",
163
163
  color: "#e2e8f0",
164
164
  borderRadius: "8px",
165
165
  fontSize: "12px",
166
166
  padding: "4px 8px",
167
167
  cursor: "pointer"
168
168
  }),
169
- onClick: (S) => T(p.id, !0)
169
+ onClick: (S) => C(c.id, !0)
170
170
  }, " 👍 ", 12, ae),
171
171
  t("button", {
172
- style: P({
172
+ style: T({
173
173
  border: "1px solid #334155",
174
- background: a.value[p.id] === !1 ? "#dc2626" : "#0f172a",
174
+ background: i.value[c.id] === !1 ? "#dc2626" : "#0f172a",
175
175
  color: "#e2e8f0",
176
176
  borderRadius: "8px",
177
177
  fontSize: "12px",
178
178
  padding: "4px 8px",
179
179
  cursor: "pointer"
180
180
  }),
181
- onClick: (S) => T(p.id, !1)
181
+ onClick: (S) => C(c.id, !1)
182
182
  }, " 👎 ", 12, ie)
183
183
  ])) : w("", !0)
184
184
  ], 4))), 128)),
185
- d.value ? (l(), b("div", se, [...u[3] || (u[3] = [
185
+ u.value ? (r(), g("div", se, [...p[3] || (p[3] = [
186
186
  t("span", { style: { width: "8px", height: "8px", borderRadius: "999px", background: "#94a3b8", animation: "fp-dot 1s infinite 0ms" } }, null, -1),
187
187
  t("span", { style: { width: "8px", height: "8px", borderRadius: "999px", background: "#94a3b8", animation: "fp-dot 1s infinite 160ms" } }, null, -1),
188
188
  t("span", { style: { width: "8px", height: "8px", borderRadius: "999px", background: "#94a3b8", animation: "fp-dot 1s infinite 320ms" } }, null, -1)
189
189
  ])])) : w("", !0),
190
- r.unavailable || g.value ? (l(), b("div", le, " Service temporarily unavailable. ")) : w("", !0)
190
+ d.unavailable || y.value ? (r(), g("div", le, " Service temporarily unavailable. ")) : w("", !0)
191
191
  ]),
192
192
  t("form", {
193
193
  style: { padding: "10px", borderTop: "1px solid #374151", display: "grid", gap: "8px" },
194
- onSubmit: y
194
+ onSubmit: b
195
195
  }, [
196
196
  t("div", re, [
197
197
  R(t("input", {
198
- "onUpdate:modelValue": u[1] || (u[1] = (p) => n.value = p),
199
- disabled: d.value || r.unavailable,
198
+ "onUpdate:modelValue": p[1] || (p[1] = (c) => n.value = c),
199
+ disabled: u.value || d.unavailable,
200
200
  style: {
201
201
  flex: 1,
202
202
  borderRadius: "10px",
@@ -209,12 +209,12 @@ const ee = { style: {
209
209
  },
210
210
  placeholder: "Ask a question..."
211
211
  }, null, 8, de), [
212
- [q, n.value]
212
+ [O, n.value]
213
213
  ]),
214
214
  t("button", {
215
215
  type: "submit",
216
216
  disabled: !m.value,
217
- style: P({
217
+ style: T({
218
218
  border: "none",
219
219
  borderRadius: "10px",
220
220
  background: m.value ? "#6366f1" : "#334155",
@@ -226,44 +226,52 @@ const ee = { style: {
226
226
  })
227
227
  }, " Send ", 12, ue)
228
228
  ]),
229
- r.config.escalateTo ? (l(), b("a", {
229
+ d.config.escalateTo ? (r(), g("a", {
230
230
  key: 0,
231
- href: r.config.escalateTo.url,
231
+ href: d.config.escalateTo.url,
232
232
  style: { color: "#c4b5fd", fontSize: "12px", textDecoration: "none" },
233
- onClick: C
234
- }, D(r.config.escalateTo.label), 9, pe)) : w("", !0)
233
+ onClick: P
234
+ }, I(d.config.escalateTo.label), 9, pe)) : w("", !0)
235
235
  ], 32)
236
236
  ]));
237
237
  }
238
- }), $e = /* @__PURE__ */ E({
238
+ }), $e = /* @__PURE__ */ D({
239
239
  __name: "FeedPulseBot",
240
240
  props: {
241
241
  faq: {},
242
242
  pageContext: {},
243
243
  systemPrompt: {},
244
244
  canNavigate: { type: Boolean },
245
+ navigableElements: {},
245
246
  canHelpForms: { type: Boolean },
247
+ formGuide: {},
248
+ features: {},
246
249
  escalateTo: {},
247
250
  initialMessage: { default: "👋 Need help?" },
248
- position: { default: "bottom-right" }
251
+ position: { default: "bottom-right" },
252
+ config: {}
249
253
  },
250
- setup(r) {
251
- const x = r, s = new Y(), o = f(!1), a = f(!1), e = f(!1), n = f(!1), d = f(""), g = f(null), m = f(!1);
252
- let v = null, y = null;
253
- const T = B(() => ({
254
- faq: x.faq || [],
255
- pageContext: x.pageContext || "",
256
- systemPrompt: x.systemPrompt || "",
257
- canNavigate: x.canNavigate ?? !1,
258
- canHelpForms: x.canHelpForms ?? !1,
259
- escalateTo: x.escalateTo
260
- })), C = B(() => ({
254
+ setup(d) {
255
+ const a = d, l = new Y(), o = x(!1), i = x(!1), e = x(!1), n = x(!1), u = x(""), y = x(null), m = x(!1);
256
+ let v = null, b = null;
257
+ const C = B(() => a.config ?? {
258
+ pageContext: a.pageContext,
259
+ systemPrompt: a.systemPrompt,
260
+ faq: a.faq,
261
+ canNavigate: a.canNavigate,
262
+ navigableElements: a.navigableElements,
263
+ canHelpForms: a.canHelpForms,
264
+ formGuide: a.formGuide,
265
+ features: a.features,
266
+ escalateTo: a.escalateTo,
267
+ initialMessage: a.initialMessage
268
+ }), P = B(() => ({
261
269
  position: "fixed",
262
270
  bottom: "24px",
263
271
  zIndex: "10000",
264
- ...x.position === "bottom-left" ? { left: "24px" } : { right: "24px" }
272
+ ...a.position === "bottom-left" ? { left: "24px" } : { right: "24px" }
265
273
  }));
266
- function i() {
274
+ function s() {
267
275
  if (typeof document > "u" || document.getElementById("fp-bot-animations"))
268
276
  return;
269
277
  const h = document.createElement("style");
@@ -288,8 +296,8 @@ const ee = { style: {
288
296
  }
289
297
  `, document.head.appendChild(h);
290
298
  }
291
- async function u(h, c) {
292
- const k = s.getAllData(!0);
299
+ async function p(h, f) {
300
+ const k = l.getAllData(!0);
293
301
  try {
294
302
  const z = await fetch("/api/bot/session-proxy", {
295
303
  method: "POST",
@@ -297,7 +305,7 @@ const ee = { style: {
297
305
  body: JSON.stringify({
298
306
  page: window.location.pathname,
299
307
  triggerScore: h,
300
- triggerReasons: c,
308
+ triggerReasons: f,
301
309
  sessionId: k.sessionId,
302
310
  visitorId: k.userId,
303
311
  device: navigator.userAgent
@@ -307,13 +315,13 @@ const ee = { style: {
307
315
  z.status === 402 && (n.value = !0);
308
316
  return;
309
317
  }
310
- const A = await z.json().catch(() => null);
311
- A?.botSessionId && (d.value = A.botSessionId);
318
+ const E = await z.json().catch(() => null);
319
+ E?.botSessionId && (u.value = E.botSessionId);
312
320
  } catch {
313
321
  }
314
322
  }
315
- function p(h, c) {
316
- a.value = !0, o.value = !0, n.value = !1, g.value = null, m.value = !1, u(h, c), y && clearTimeout(y), y = setTimeout(() => {
323
+ function c(h, f) {
324
+ i.value = !0, o.value = !0, n.value = !1, y.value = null, m.value = !1, p(h, f), b && clearTimeout(b), b = setTimeout(() => {
317
325
  o.value = !1;
318
326
  }, 8e3);
319
327
  }
@@ -321,38 +329,38 @@ const ee = { style: {
321
329
  e.value = !0, o.value = !1;
322
330
  }
323
331
  async function $() {
324
- if (e.value = !1, !!d.value)
332
+ if (e.value = !1, !!u.value)
325
333
  try {
326
334
  await fetch("/api/bot/session-end-proxy", {
327
335
  method: "POST",
328
336
  headers: { "content-type": "application/json" },
329
337
  body: JSON.stringify({
330
- botSessionId: d.value,
331
- wasHelpful: g.value,
338
+ botSessionId: u.value,
339
+ wasHelpful: y.value,
332
340
  escalated: m.value
333
341
  })
334
342
  });
335
343
  } catch {
336
344
  }
337
345
  }
338
- return F(() => {
339
- i(), v = new X({
340
- onTrigger: (h, c) => {
341
- p(h, c);
346
+ return M(() => {
347
+ s(), v = new X({
348
+ onTrigger: (h, f) => {
349
+ c(h, f);
342
350
  }
343
351
  }), v.start();
344
- }), M(() => {
345
- v?.stop(), y && clearTimeout(y);
346
- }), (h, c) => (l(), b("div", {
347
- style: P(C.value)
352
+ }), F(() => {
353
+ v?.stop(), b && clearTimeout(b);
354
+ }), (h, f) => (r(), g("div", {
355
+ style: T(P.value)
348
356
  }, [
349
- o.value && !e.value ? (l(), b("div", {
357
+ o.value && !e.value ? (r(), g("div", {
350
358
  key: 0,
351
- style: P({
359
+ style: T({
352
360
  position: "absolute",
353
361
  bottom: "62px",
354
- right: r.position === "bottom-right" ? "0" : "auto",
355
- left: r.position === "bottom-left" ? "0" : "auto",
362
+ right: d.position === "bottom-right" ? "0" : "auto",
363
+ left: d.position === "bottom-left" ? "0" : "auto",
356
364
  background: "#fff",
357
365
  border: "2px solid #6366f1",
358
366
  color: "#1f2937",
@@ -364,8 +372,8 @@ const ee = { style: {
364
372
  animation: "fp-bubble-in 300ms ease-out"
365
373
  })
366
374
  }, [
367
- I(D(r.initialMessage) + " ", 1),
368
- c[2] || (c[2] = t("span", { style: {
375
+ A(I(C.value.initialMessage || d.initialMessage) + " ", 1),
376
+ f[2] || (f[2] = t("span", { style: {
369
377
  position: "absolute",
370
378
  right: "10px",
371
379
  bottom: "-12px",
@@ -374,7 +382,7 @@ const ee = { style: {
374
382
  borderLeft: "10px solid transparent",
375
383
  borderTop: "12px solid #6366f1"
376
384
  } }, null, -1)),
377
- c[3] || (c[3] = t("span", { style: {
385
+ f[3] || (f[3] = t("span", { style: {
378
386
  position: "absolute",
379
387
  right: "11px",
380
388
  bottom: "-9px",
@@ -384,7 +392,7 @@ const ee = { style: {
384
392
  borderTop: "11px solid #fff"
385
393
  } }, null, -1))
386
394
  ], 4)) : w("", !0),
387
- a.value && !e.value ? (l(), b("button", {
395
+ i.value && !e.value ? (r(), g("button", {
388
396
  key: 1,
389
397
  style: {
390
398
  width: "48px",
@@ -399,88 +407,88 @@ const ee = { style: {
399
407
  animation: "fp-bounce 600ms ease-out"
400
408
  },
401
409
  onClick: S
402
- }, [...c[4] || (c[4] = [
410
+ }, [...f[4] || (f[4] = [
403
411
  W('<svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2"><rect x="3" y="8" width="18" height="13" rx="2"></rect><path d="M12 8V5"></path><circle cx="12" cy="4" r="1"></circle><circle cx="8" cy="13" r="1.5" fill="white" stroke="none"></circle><circle cx="16" cy="13" r="1.5" fill="white" stroke="none"></circle><path d="M9 17h6" stroke-linecap="round"></path></svg>', 1)
404
412
  ])])) : w("", !0),
405
- e.value && d.value ? (l(), N(ce, {
413
+ e.value && u.value ? (r(), N(ce, {
406
414
  key: 2,
407
- "bot-session-id": d.value,
408
- config: T.value,
415
+ "bot-session-id": u.value,
416
+ config: C.value,
409
417
  unavailable: n.value,
410
418
  onClose: $,
411
- onHelpful: c[0] || (c[0] = (k) => g.value = k),
412
- onEscalated: c[1] || (c[1] = (k) => m.value = !0)
419
+ onHelpful: f[0] || (f[0] = (k) => y.value = k),
420
+ onEscalated: f[1] || (f[1] = (k) => m.value = !0)
413
421
  }, null, 8, ["bot-session-id", "config", "unavailable"])) : w("", !0)
414
422
  ], 4));
415
423
  }
416
424
  }), fe = {
417
425
  key: 0,
418
426
  style: { position: "fixed", bottom: "0", left: "0", right: "0", "z-index": "99999", background: "#1a1a1a", color: "#fff", padding: "20px 24px", "border-top": "1px solid #333", "font-family": "sans-serif" }
419
- }, xe = { style: { "max-width": "900px", margin: "0 auto" } }, be = {
427
+ }, xe = { style: { "max-width": "900px", margin: "0 auto" } }, ge = {
420
428
  key: 0,
421
429
  style: { "margin-bottom": "12px", "font-size": "13px" }
422
- }, ye = { style: { display: "flex", "align-items": "center", gap: "8px", "margin-bottom": "6px" } }, ge = { style: { display: "flex", "align-items": "center", gap: "8px" } }, ve = { style: { display: "flex", gap: "8px", "flex-wrap": "wrap", "align-items": "center" } }, me = /* @__PURE__ */ E({
430
+ }, be = { style: { display: "flex", "align-items": "center", gap: "8px", "margin-bottom": "6px" } }, ye = { style: { display: "flex", "align-items": "center", gap: "8px" } }, ve = { style: { display: "flex", gap: "8px", "flex-wrap": "wrap", "align-items": "center" } }, me = /* @__PURE__ */ D({
423
431
  __name: "consent-banner",
424
432
  emits: ["consent"],
425
- setup(r, { emit: x }) {
426
- const s = x, o = new Y(), a = f(!1), e = f(!1), n = f(!1), d = f(!1);
427
- function g() {
428
- a.value = !0, e.value = !0;
433
+ setup(d, { emit: a }) {
434
+ const l = a, o = new Y(), i = x(!1), e = x(!1), n = x(!1), u = x(!1);
435
+ function y() {
436
+ i.value = !0, e.value = !0;
429
437
  }
430
- F(() => {
431
- const C = o.getConsent();
432
- a.value = !C || o.isConsentExpired(), C && (n.value = C.analytics, d.value = C.marketing), typeof window < "u" && (window.addEventListener("feedpulse:open-consent", g), window.addEventListener("feedpulse:withdraw-consent", T));
438
+ M(() => {
439
+ const P = o.getConsent();
440
+ i.value = !P || o.isConsentExpired(), P && (n.value = P.analytics, u.value = P.marketing), typeof window < "u" && (window.addEventListener("feedpulse:open-consent", y), window.addEventListener("feedpulse:withdraw-consent", C));
433
441
  });
434
442
  function m() {
435
- o.setConsent({ analytics: !0, marketing: !0, version: "1.0" }), s("consent", { analytics: !0, marketing: !0, action: "accept_all" }), a.value = !1;
443
+ o.setConsent({ analytics: !0, marketing: !0, version: "1.0" }), l("consent", { analytics: !0, marketing: !0, action: "accept_all" }), i.value = !1;
436
444
  }
437
445
  function v() {
438
- o.setConsent({ analytics: !1, marketing: !1, version: "1.0" }), o.clearAnalyticsCookies(), s("consent", { analytics: !1, marketing: !1, action: "reject_all" }), a.value = !1;
446
+ o.setConsent({ analytics: !1, marketing: !1, version: "1.0" }), o.clearAnalyticsCookies(), l("consent", { analytics: !1, marketing: !1, action: "reject_all" }), i.value = !1;
439
447
  }
440
- function y() {
441
- o.setConsent({ analytics: n.value, marketing: d.value, version: "1.0" }), n.value || o.clearAnalyticsCookies(), s("consent", { analytics: n.value, marketing: d.value, action: "custom" }), a.value = !1;
448
+ function b() {
449
+ o.setConsent({ analytics: n.value, marketing: u.value, version: "1.0" }), n.value || o.clearAnalyticsCookies(), l("consent", { analytics: n.value, marketing: u.value, action: "custom" }), i.value = !1;
442
450
  }
443
- function T() {
444
- o.setConsent({ analytics: !1, marketing: !1, version: "1.0" }), o.clearAnalyticsCookies(), n.value = !1, d.value = !1, s("consent", { analytics: !1, marketing: !1, action: "withdraw" }), a.value = !0;
451
+ function C() {
452
+ o.setConsent({ analytics: !1, marketing: !1, version: "1.0" }), o.clearAnalyticsCookies(), n.value = !1, u.value = !1, l("consent", { analytics: !1, marketing: !1, action: "withdraw" }), i.value = !0;
445
453
  }
446
- return M(() => {
447
- typeof window < "u" && (window.removeEventListener("feedpulse:open-consent", g), window.removeEventListener("feedpulse:withdraw-consent", T));
448
- }), (C, i) => (l(), N(J, { to: "body" }, [
449
- a.value ? (l(), b("div", fe, [
454
+ return F(() => {
455
+ typeof window < "u" && (window.removeEventListener("feedpulse:open-consent", y), window.removeEventListener("feedpulse:withdraw-consent", C));
456
+ }), (P, s) => (r(), N(J, { to: "body" }, [
457
+ i.value ? (r(), g("div", fe, [
450
458
  t("div", xe, [
451
- i[6] || (i[6] = t("p", { style: { margin: "0 0 12px", "font-size": "14px", "line-height": "1.5" } }, [
452
- I(" We use cookies to improve reliability and understand usage. "),
459
+ s[6] || (s[6] = t("p", { style: { margin: "0 0 12px", "font-size": "14px", "line-height": "1.5" } }, [
460
+ A(" We use cookies to improve reliability and understand usage. "),
453
461
  t("a", {
454
462
  href: "/privacy",
455
463
  style: { color: "#818cf8" }
456
464
  }, "Privacy Policy")
457
465
  ], -1)),
458
- e.value ? (l(), b("div", be, [
459
- i[5] || (i[5] = t("label", { style: { display: "flex", "align-items": "center", gap: "8px", "margin-bottom": "6px", opacity: "0.75" } }, [
466
+ e.value ? (r(), g("div", ge, [
467
+ s[5] || (s[5] = t("label", { style: { display: "flex", "align-items": "center", gap: "8px", "margin-bottom": "6px", opacity: "0.75" } }, [
460
468
  t("input", {
461
469
  type: "checkbox",
462
470
  checked: "",
463
471
  disabled: ""
464
472
  }),
465
- I(" Necessary (always on) ")
473
+ A(" Necessary (always on) ")
466
474
  ], -1)),
467
- t("label", ye, [
475
+ t("label", be, [
468
476
  R(t("input", {
469
- "onUpdate:modelValue": i[0] || (i[0] = (u) => n.value = u),
477
+ "onUpdate:modelValue": s[0] || (s[0] = (p) => n.value = p),
470
478
  type: "checkbox"
471
479
  }, null, 512), [
472
480
  [j, n.value]
473
481
  ]),
474
- i[3] || (i[3] = I(" Analytics ", -1))
482
+ s[3] || (s[3] = A(" Analytics ", -1))
475
483
  ]),
476
- t("label", ge, [
484
+ t("label", ye, [
477
485
  R(t("input", {
478
- "onUpdate:modelValue": i[1] || (i[1] = (u) => d.value = u),
486
+ "onUpdate:modelValue": s[1] || (s[1] = (p) => u.value = p),
479
487
  type: "checkbox"
480
488
  }, null, 512), [
481
- [j, d.value]
489
+ [j, u.value]
482
490
  ]),
483
- i[4] || (i[4] = I(" Marketing ", -1))
491
+ s[4] || (s[4] = A(" Marketing ", -1))
484
492
  ])
485
493
  ])) : w("", !0),
486
494
  t("div", ve, [
@@ -494,33 +502,33 @@ const ee = { style: {
494
502
  }, " Reject All "),
495
503
  t("button", {
496
504
  style: { padding: "9px 16px", background: "transparent", color: "#aaa", border: "1px solid #333", "border-radius": "6px", "font-size": "13px", cursor: "pointer" },
497
- onClick: i[2] || (i[2] = (u) => e.value ? y() : e.value = !0)
498
- }, D(e.value ? "Save Preferences" : "Customize"), 1)
505
+ onClick: s[2] || (s[2] = (p) => e.value ? b() : e.value = !0)
506
+ }, I(e.value ? "Save Preferences" : "Customize"), 1)
499
507
  ])
500
508
  ])
501
509
  ])) : w("", !0)
502
510
  ]));
503
511
  }
504
- }), Ae = /* @__PURE__ */ E({
512
+ }), Ee = /* @__PURE__ */ D({
505
513
  __name: "FeedPulseProvider",
506
514
  props: {
507
515
  proxyEndpoint: { default: "/api/fp-proxy" },
508
516
  debug: { type: Boolean },
509
517
  consentRequired: { type: Boolean, default: !0 }
510
518
  },
511
- setup(r) {
512
- const x = r, s = new Y(), o = new Q({
513
- proxyEndpoint: x.proxyEndpoint,
514
- debug: x.debug
519
+ setup(d) {
520
+ const a = d, l = new Y(), o = new Q({
521
+ proxyEndpoint: a.proxyEndpoint,
522
+ debug: a.debug
515
523
  });
516
- K(H, o);
517
- function a(e) {
518
- const n = s.setConsent({
524
+ G(q, o);
525
+ function i(e) {
526
+ const n = l.setConsent({
519
527
  analytics: e.analytics,
520
528
  marketing: e.marketing,
521
529
  version: "1.0"
522
530
  });
523
- e.analytics || s.clearAnalyticsCookies(), o.updateCookieData(s.getAllData(e.analytics)), o.track("consent", "__consent__", {
531
+ e.analytics || l.clearAnalyticsCookies(), o.updateCookieData(l.getAllData(e.analytics)), o.track("consent", "__consent__", {
524
532
  analytics: e.analytics,
525
533
  marketing: e.marketing,
526
534
  action: e.action,
@@ -528,14 +536,14 @@ const ee = { style: {
528
536
  version: n.version
529
537
  });
530
538
  }
531
- return F(() => {
532
- const e = s.getConsent();
533
- x.consentRequired === !1 ? (s.setConsent({ analytics: !0, marketing: !0, version: "1.0" }), o.updateCookieData(s.getAllData(!0))) : e && !s.isConsentExpired() ? o.updateCookieData(s.getAllData(e.analytics)) : o.updateCookieData(s.getAllData(!1)), o.init();
534
- }), M(() => o.destroy()), (e, n) => (l(), b(_, null, [
535
- G(e.$slots, "default"),
536
- r.consentRequired !== !1 ? (l(), N(me, {
539
+ return M(() => {
540
+ const e = l.getConsent();
541
+ a.consentRequired === !1 ? (l.setConsent({ analytics: !0, marketing: !0, version: "1.0" }), o.updateCookieData(l.getAllData(!0))) : e && !l.isConsentExpired() ? o.updateCookieData(l.getAllData(e.analytics)) : o.updateCookieData(l.getAllData(!1)), o.init();
542
+ }), F(() => o.destroy()), (e, n) => (r(), g(_, null, [
543
+ K(e.$slots, "default"),
544
+ d.consentRequired !== !1 ? (r(), N(me, {
537
545
  key: 0,
538
- onConsent: a
546
+ onConsent: i
539
547
  })) : w("", !0)
540
548
  ], 64));
541
549
  }
@@ -545,56 +553,56 @@ const ee = { style: {
545
553
  }, ke = { style: { margin: "0 0 12px", "font-weight": "600", color: "#111" } }, we = { style: { display: "flex", gap: "6px", "margin-bottom": "12px" } }, Se = ["onClick"], Ce = {
546
554
  key: 1,
547
555
  style: { "text-align": "center", padding: "16px", color: "#111" }
548
- }, Ie = /* @__PURE__ */ E({
556
+ }, Ae = /* @__PURE__ */ D({
549
557
  __name: "FeedPulseWidget",
550
558
  props: {
551
559
  id: {},
552
560
  placeholder: {},
553
561
  position: { default: "bottom-right" }
554
562
  },
555
- setup(r) {
556
- const x = r, s = Z(), o = f(x.position === "inline"), a = f(null), e = f(""), n = f(!1);
557
- function d(m) {
558
- a.value = m;
563
+ setup(d) {
564
+ const a = d, l = Z(), o = x(a.position === "inline"), i = x(null), e = x(""), n = x(!1);
565
+ function u(m) {
566
+ i.value = m;
559
567
  }
560
- function g() {
561
- !a.value && !e.value.trim() || (s?.trackFeedback(x.id ?? null, a.value, e.value || null), n.value = !0, setTimeout(() => {
562
- o.value = x.position === "inline", n.value = !1, a.value = null, e.value = "";
568
+ function y() {
569
+ !i.value && !e.value.trim() || (l?.trackFeedback(a.id ?? null, i.value, e.value || null), n.value = !0, setTimeout(() => {
570
+ o.value = a.position === "inline", n.value = !1, i.value = null, e.value = "";
563
571
  }, 2e3));
564
572
  }
565
- return (m, v) => (l(), b("div", {
573
+ return (m, v) => (r(), g("div", {
566
574
  class: "feedpulse-widget",
567
- style: P(r.position !== "inline" ? `position:fixed; ${r.position === "bottom-right" ? "right:24px" : "left:24px"}; bottom:24px; z-index:9999;` : "")
575
+ style: T(d.position !== "inline" ? `position:fixed; ${d.position === "bottom-right" ? "right:24px" : "left:24px"}; bottom:24px; z-index:9999;` : "")
568
576
  }, [
569
- r.position !== "inline" ? (l(), b("button", {
577
+ d.position !== "inline" ? (r(), g("button", {
570
578
  key: 0,
571
579
  style: { background: "#6366f1", color: "#fff", border: "none", "border-radius": "50%", width: "48px", height: "48px", "font-size": "20px", cursor: "pointer" },
572
- onClick: v[0] || (v[0] = (y) => o.value = !o.value)
580
+ onClick: v[0] || (v[0] = (b) => o.value = !o.value)
573
581
  }, " 💬 ")) : w("", !0),
574
- o.value ? (l(), b("div", he, [
575
- n.value ? (l(), b("div", Ce, [...v[2] || (v[2] = [
582
+ o.value ? (r(), g("div", he, [
583
+ n.value ? (r(), g("div", Ce, [...v[2] || (v[2] = [
576
584
  t("p", { style: { "font-size": "28px", margin: "0" } }, " 🎉 ", -1),
577
585
  t("p", { style: { margin: "8px 0 0", "font-weight": "600" } }, " Thanks for your feedback! ", -1)
578
- ])])) : (l(), b(_, { key: 0 }, [
579
- t("p", ke, D(r.placeholder ?? "How was your experience?"), 1),
586
+ ])])) : (r(), g(_, { key: 0 }, [
587
+ t("p", ke, I(d.placeholder ?? "How was your experience?"), 1),
580
588
  t("div", we, [
581
- (l(), b(_, null, L(5, (y) => t("button", {
582
- key: y,
583
- style: P({ background: "none", border: "none", cursor: "pointer", fontSize: "24px", opacity: a.value !== null && y <= a.value ? 1 : 0.3 }),
584
- onClick: (T) => d(y)
589
+ (r(), g(_, null, L(5, (b) => t("button", {
590
+ key: b,
591
+ style: T({ background: "none", border: "none", cursor: "pointer", fontSize: "24px", opacity: i.value !== null && b <= i.value ? 1 : 0.3 }),
592
+ onClick: (C) => u(b)
585
593
  }, " ⭐ ", 12, Se)), 64))
586
594
  ]),
587
595
  R(t("textarea", {
588
- "onUpdate:modelValue": v[1] || (v[1] = (y) => e.value = y),
596
+ "onUpdate:modelValue": v[1] || (v[1] = (b) => e.value = b),
589
597
  placeholder: "Tell us more (optional)...",
590
598
  rows: "3",
591
599
  style: { width: "100%", padding: "8px", border: "1px solid #d1d5db", "border-radius": "8px", resize: "none", "font-size": "14px" }
592
600
  }, null, 512), [
593
- [q, e.value]
601
+ [O, e.value]
594
602
  ]),
595
603
  t("button", {
596
604
  style: { "margin-top": "10px", width: "100%", background: "#6366f1", color: "#fff", border: "none", "border-radius": "8px", padding: "10px", "font-weight": "600", cursor: "pointer" },
597
- onClick: g
605
+ onClick: y
598
606
  }, " Submit Feedback ")
599
607
  ], 64))
600
608
  ])) : w("", !0)
@@ -604,7 +612,7 @@ const ee = { style: {
604
612
  export {
605
613
  me as ConsentBanner,
606
614
  $e as FeedPulseBot,
607
- Ae as FeedPulseProvider,
608
- Ie as FeedPulseWidget,
615
+ Ee as FeedPulseProvider,
616
+ Ae as FeedPulseWidget,
609
617
  Z as useFeedPulse
610
618
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekibo/feedpulse-sdk",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Embeddable analytics and feedback SDK for FeedPulse",
5
5
  "exports": {
6
6
  ".": {