@tekibo/feedpulse-sdk 0.7.3 → 0.8.0

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 (38) hide show
  1. package/README.md +83 -83
  2. package/dist/core/cookies.d.ts +37 -0
  3. package/dist/core/struggle-detector.d.ts +33 -0
  4. package/dist/core/tracker.d.ts +38 -0
  5. package/dist/core/types.d.ts +59 -0
  6. package/dist/index.d.ts +3 -0
  7. package/dist/index.js +1 -1
  8. package/dist/index.mjs +127 -176
  9. package/dist/nuxt/BotPanel.vue.d.ts +17 -0
  10. package/dist/nuxt/FeedPulseBot.vue.d.ts +24 -0
  11. package/dist/nuxt/FeedPulseProvider.vue.d.ts +21 -0
  12. package/dist/nuxt/FeedPulseWidget.vue.d.ts +10 -0
  13. package/dist/nuxt/composables.d.ts +4 -0
  14. package/dist/nuxt/consent-banner.vue.d.ts +16 -0
  15. package/dist/nuxt/index.d.ts +5 -0
  16. package/dist/nuxt.d.ts +2 -0
  17. package/dist/nuxt.js +2 -2
  18. package/dist/nuxt.mjs +283 -336
  19. package/dist/react/FeedPulseBot.d.ts +21 -0
  20. package/dist/react/FeedPulseProvider.d.ts +13 -0
  21. package/dist/react/FeedPulseWidget.d.ts +8 -0
  22. package/dist/react/consent-banner.d.ts +11 -0
  23. package/dist/react/hooks.d.ts +1 -0
  24. package/dist/react/index.d.ts +4 -0
  25. package/dist/react.d.ts +2 -0
  26. package/dist/react.js +3 -3
  27. package/dist/react.mjs +275 -315
  28. package/dist/struggle-detector-CT3YShuG.js +1 -0
  29. package/dist/{struggle-detector-BqTHgw95.mjs → struggle-detector-Cwe3PD9s.mjs} +40 -25
  30. package/package.json +4 -11
  31. package/templates/nextjs-proxy.ts +36 -36
  32. package/templates/nuxt-bot-proxy.ts +60 -93
  33. package/templates/nuxt-proxy.ts +44 -44
  34. package/bin/feedpulse-bot-build.mjs +0 -121
  35. package/dist/server.js +0 -1
  36. package/dist/server.mjs +0 -18
  37. package/dist/struggle-detector-DV52qDLp.js +0 -1
  38. package/templates/nuxt-config-id-route.ts +0 -15
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"),P=require("./struggle-detector-DV52qDLp.js"),B=Symbol("feedpulse");function z(){return e.inject(B,null)}const $={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"}},I={style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 14px",borderBottom:"1px solid #374151",background:"#0f172a"}},A={style:{flex:1,overflowY:"auto",padding:"12px",display:"grid",gap:"10px"}},M={key:0,style:{display:"flex",gap:"8px"}},R=["onClick"],_=["onClick"],F={key:0,style:{display:"flex",alignItems:"center",gap:"5px",padding:"4px 0"}},q={key:1,style:{border:"1px solid #f59e0b",background:"#451a03",color:"#fde68a",borderRadius:"10px",padding:"10px",fontSize:"12px"}},Y={key:2,style:{margin:"8px 0",padding:"12px",background:"#f0f0ff",border:"1px solid #c7d2fe",borderRadius:"10px",fontSize:"13px",color:"#111827"}},j={style:{margin:"0 0 8px",fontWeight:"600"}},L={style:{display:"flex",gap:"8px"}},O={key:3,style:{margin:"0 0 8px",padding:"10px",background:"#ecfdf5",border:"1px solid #6ee7b7",borderRadius:"8px",fontSize:"13px",color:"#065f46"}},H={style:{display:"flex",gap:"8px"}},U=["disabled"],W=["disabled"],J=["href"],G=e.defineComponent({__name:"BotPanel",props:{botSessionId:{},config:{},configId:{},page:{},unavailable:{type:Boolean}},emits:["close","helpful","escalated"],setup(d,{emit:i}){const a=d,o=i,r=e.ref({}),t=e.ref([]),l=e.ref(""),m=e.ref(!1),x=e.ref(!1),u=e.ref(null),p=e.ref(null),g=new N.CursorActor,y=e.computed(()=>l.value.trim().length>0&&!m.value&&!a.unavailable&&!x.value);function k(){return t.value.map(b=>({role:b.role,content:b.content}))}async function f(b){if(b.preventDefault(),!y.value)return;const c=l.value.trim(),n=[...k(),{role:"user",content:c}];l.value="",t.value.push({id:`user-${Date.now()}`,role:"user",content:c});const s=`assistant-${Date.now()}`;t.value.push({id:s,role:"assistant",content:""}),m.value=!0,x.value=!1;try{const v=await fetch("/api/bot/chat-proxy",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({botSessionId:a.botSessionId,config:JSON.parse(JSON.stringify(a.config)),configId:a.configId,page:a.page,messages:n})});if(v.status===402){x.value=!0;const S=t.value.find(D=>D.id===s);S&&(S.content="Service temporarily unavailable.");return}if(!v.ok)throw new Error("Chat request failed");const w=await v.json(),E=t.value.find(S=>S.id===s);E&&(E.content=w.text||""),w.action&&(u.value=w.action)}catch{const v=t.value.find(w=>w.id===s);v&&!v.content&&(v.content="Sorry, I couldn't process that. Please try again.")}finally{m.value=!1}}function h(b,c){r.value[b]=c,o("helpful",c)}function V(){o("escalated")}async function C(b){if(!u.value)return;if(!b){u.value=null,p.value="No problem! Let me know if you need anything else.";return}const c=u.value;u.value=null;const n=await g.perform(c);p.value=n.message,setTimeout(()=>{p.value=null},3e3)}return e.watch(()=>a.botSessionId,()=>{r.value={},t.value=[],l.value="",x.value=!1,u.value=null,p.value=null}),(b,c)=>(e.openBlock(),e.createElementBlock("div",$,[e.createElementVNode("div",I,[c[4]||(c[4]=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]=n=>o("close"))}," × ")]),e.createElementVNode("div",A,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.value,n=>(e.openBlock(),e.createElementBlock("div",{key:n.id,style:e.normalizeStyle({display:"grid",justifyItems:n.role==="user"?"end":"start",gap:"6px"})},[e.createElementVNode("div",{style:e.normalizeStyle({maxWidth:"85%",padding:"9px 11px",borderRadius:n.role==="user"?"14px 14px 2px 14px":"14px 14px 14px 2px",background:n.role==="user"?"#4f46e5":"#1f2937",color:"#fff",fontSize:"13px",lineHeight:"1.4",whiteSpace:"pre-wrap"})},e.toDisplayString(n.content),5),n.role==="assistant"?(e.openBlock(),e.createElementBlock("div",M,[e.createElementVNode("button",{style:e.normalizeStyle({border:"1px solid #334155",background:r.value[n.id]===!0?"#16a34a":"#0f172a",color:"#e2e8f0",borderRadius:"8px",fontSize:"12px",padding:"4px 8px",cursor:"pointer"}),onClick:s=>h(n.id,!0)}," 👍 ",12,R),e.createElementVNode("button",{style:e.normalizeStyle({border:"1px solid #334155",background:r.value[n.id]===!1?"#dc2626":"#0f172a",color:"#e2e8f0",borderRadius:"8px",fontSize:"12px",padding:"4px 8px",cursor:"pointer"}),onClick:s=>h(n.id,!1)}," 👎 ",12,_)])):e.createCommentVNode("",!0)],4))),128)),m.value?(e.openBlock(),e.createElementBlock("div",F,[...c[5]||(c[5]=[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),d.unavailable||x.value?(e.openBlock(),e.createElementBlock("div",q," Service temporarily unavailable. ")):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("div",Y,[e.createElementVNode("p",j," Want me to "+e.toDisplayString(u.value.type)+' "'+e.toDisplayString(u.value.label)+'"? ',1),e.createElementVNode("div",L,[e.createElementVNode("button",{style:{padding:"6px 16px",background:"#6366f1",color:"#fff",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"12px"},onClick:c[1]||(c[1]=n=>C(!0))}," ✓ Yes, do it "),e.createElementVNode("button",{style:{padding:"6px 16px",background:"transparent",border:"1px solid #c7d2fe",borderRadius:"6px",cursor:"pointer",fontSize:"12px",color:"#111827"},onClick:c[2]||(c[2]=n=>C(!1))}," No thanks ")])])):e.createCommentVNode("",!0),p.value?(e.openBlock(),e.createElementBlock("div",O,e.toDisplayString(p.value),1)):e.createCommentVNode("",!0)]),e.createElementVNode("form",{style:{padding:"10px",borderTop:"1px solid #374151",display:"grid",gap:"8px"},onSubmit:f},[e.createElementVNode("div",H,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":c[3]||(c[3]=n=>l.value=n),disabled:m.value||d.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,U),[[e.vModelText,l.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,W)]),d.config.escalateTo?(e.openBlock(),e.createElementBlock("a",{key:0,href:d.config.escalateTo.url,style:{color:"#c4b5fd",fontSize:"12px",textDecoration:"none"},onClick:V},e.toDisplayString(d.config.escalateTo.label),9,J)):e.createCommentVNode("",!0)],32)]))}}),K=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:{},configId:{}},setup(d){const i=d,a=new N.CookieManager,o=e.ref(!1),r=e.ref(!1),t=e.ref(!1),l=e.ref(!1),m=e.ref(""),x=e.ref(""),u=e.ref(null),p=e.ref(!1);let g=null,y=null;const k=e.computed(()=>i.config??{pageContext:i.pageContext,systemPrompt:i.systemPrompt,faq:i.faq,canNavigate:i.canNavigate,navigableElements:i.navigableElements,canHelpForms:i.canHelpForms,formGuide:i.formGuide,features:i.features,escalateTo:i.escalateTo,initialMessage:i.initialMessage}),f=e.computed(()=>({position:"fixed",bottom:"24px",zIndex:"10000",...i.position==="bottom-left"?{left:"24px"}:{right:"24px"}}));function h(){if(typeof document>"u"||document.getElementById("fp-bot-animations"))return;const n=document.createElement("style");n.id="fp-bot-animations",n.textContent=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),N=require("./index.js"),T=require("./struggle-detector-CT3YShuG.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(n)}async function V(n,s){const v=a.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:n,triggerReasons:s,sessionId:v.sessionId,visitorId:v.userId,device:navigator.userAgent})});if(!w.ok){w.status===402&&(l.value=!0);return}const E=await w.json().catch(()=>null);E?.botSessionId&&(x.value=E.botSessionId)}catch{}}function C(n,s){r.value=!0,o.value=!0,l.value=!1,u.value=null,p.value=!1,V(n,s),y&&clearTimeout(y),y=setTimeout(()=>{o.value=!1},8e3)}function b(){t.value=!0,o.value=!1}async function c(){if(t.value=!1,!!x.value)try{await fetch("/api/bot/session-end-proxy",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({botSessionId:x.value,wasHelpful:u.value,escalated:p.value})})}catch{}}return e.onMounted(()=>{h(),m.value=window.location.pathname,g=new P.StruggleDetector({onTrigger:(n,s)=>{C(n,s)}}),g.start()}),e.onBeforeUnmount(()=>{g?.stop(),y&&clearTimeout(y)}),(n,s)=>(e.openBlock(),e.createElementBlock("div",{style:e.normalizeStyle(f.value)},[o.value&&!t.value?(e.openBlock(),e.createElementBlock("div",{key:0,style:e.normalizeStyle({position:"absolute",bottom:"62px",right:d.position==="bottom-right"?"0":"auto",left:d.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||d.initialMessage)+" ",1),s[2]||(s[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)),s[3]||(s[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),r.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},[...s[4]||(s[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&&x.value?(e.openBlock(),e.createBlock(G,{key:2,"bot-session-id":x.value,config:k.value,"config-id":d.configId,page:m.value,unavailable:l.value,onClose:c,onHelpful:s[0]||(s[0]=v=>u.value=v),onEscalated:s[1]||(s[1]=v=>p.value=!0)},null,8,["bot-session-id","config","config-id","page","unavailable"])):e.createCommentVNode("",!0)],4))}}),Q={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"}},X={style:{"max-width":"900px",margin:"0 auto"}},Z={key:0,style:{"margin-bottom":"12px","font-size":"13px"}},ee={style:{display:"flex","align-items":"center",gap:"8px","margin-bottom":"6px"}},te={style:{display:"flex","align-items":"center",gap:"8px"}},oe={style:{display:"flex",gap:"8px","flex-wrap":"wrap","align-items":"center"}},T=e.defineComponent({__name:"consent-banner",emits:["consent"],setup(d,{emit:i}){const a=i,o=new N.CookieManager,r=e.ref(!1),t=e.ref(!1),l=e.ref(!1),m=e.ref(!1);function x(){r.value=!0,t.value=!0}e.onMounted(()=>{const k=o.getConsent();r.value=!k||o.isConsentExpired(),k&&(l.value=k.analytics,m.value=k.marketing),typeof window<"u"&&(window.addEventListener("feedpulse:open-consent",x),window.addEventListener("feedpulse:withdraw-consent",y))});function u(){o.setConsent({analytics:!0,marketing:!0,version:"1.0"}),a("consent",{analytics:!0,marketing:!0,action:"accept_all"}),r.value=!1}function p(){o.setConsent({analytics:!1,marketing:!1,version:"1.0"}),o.clearAnalyticsCookies(),a("consent",{analytics:!1,marketing:!1,action:"reject_all"}),r.value=!1}function g(){o.setConsent({analytics:l.value,marketing:m.value,version:"1.0"}),l.value||o.clearAnalyticsCookies(),a("consent",{analytics:l.value,marketing:m.value,action:"custom"}),r.value=!1}function y(){o.setConsent({analytics:!1,marketing:!1,version:"1.0"}),o.clearAnalyticsCookies(),l.value=!1,m.value=!1,a("consent",{analytics:!1,marketing:!1,action:"withdraw"}),r.value=!0}return e.onBeforeUnmount(()=>{typeof window<"u"&&(window.removeEventListener("feedpulse:open-consent",x),window.removeEventListener("feedpulse:withdraw-consent",y))}),(k,f)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[r.value?(e.openBlock(),e.createElementBlock("div",Q,[e.createElementVNode("div",X,[f[6]||(f[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",Z,[f[5]||(f[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",ee,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[0]||(f[0]=h=>l.value=h),type:"checkbox"},null,512),[[e.vModelCheckbox,l.value]]),f[3]||(f[3]=e.createTextVNode(" Analytics ",-1))]),e.createElementVNode("label",te,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[1]||(f[1]=h=>m.value=h),type:"checkbox"},null,512),[[e.vModelCheckbox,m.value]]),f[4]||(f[4]=e.createTextVNode(" Marketing ",-1))])])):e.createCommentVNode("",!0),e.createElementVNode("div",oe,[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:u}," 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:p}," 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:f[2]||(f[2]=h=>t.value?g():t.value=!0)},e.toDisplayString(t.value?"Save Preferences":"Customize"),1)])])])):e.createCommentVNode("",!0)]))}}),ne=e.defineComponent({__name:"FeedPulseProvider",props:{proxyEndpoint:{default:"/api/fp-proxy"},debug:{type:Boolean},consentRequired:{type:Boolean,default:!0}},setup(d){const i=d,a=new N.CookieManager,o=new N.FeedPulseTracker({proxyEndpoint:i.proxyEndpoint,debug:i.debug});e.provide(B,o);function r(t){const l=a.setConsent({analytics:t.analytics,marketing:t.marketing,version:"1.0"});t.analytics||a.clearAnalyticsCookies(),o.updateCookieData(a.getAllData(t.analytics)),o.track("consent","__consent__",{analytics:t.analytics,marketing:t.marketing,action:t.action,userAgent:navigator.userAgent,version:l.version})}return e.onMounted(()=>{const t=a.getConsent();i.consentRequired===!1?(a.setConsent({analytics:!0,marketing:!0,version:"1.0"}),o.updateCookieData(a.getAllData(!0))):t&&!a.isConsentExpired()?o.updateCookieData(a.getAllData(t.analytics)):o.updateCookieData(a.getAllData(!1)),o.init()}),e.onBeforeUnmount(()=>o.destroy()),(t,l)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.renderSlot(t.$slots,"default"),d.consentRequired!==!1?(e.openBlock(),e.createBlock(T,{key:0,onConsent:r})):e.createCommentVNode("",!0)],64))}}),ae={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)"}},le={style:{margin:"0 0 12px","font-weight":"600",color:"#111"}},ie={style:{display:"flex",gap:"6px","margin-bottom":"12px"}},re=["onClick"],se={key:1,style:{"text-align":"center",padding:"16px",color:"#111"}},de=e.defineComponent({__name:"FeedPulseWidget",props:{id:{},placeholder:{},position:{default:"bottom-right"}},setup(d){const i=d,a=z(),o=e.ref(i.position==="inline"),r=e.ref(null),t=e.ref(""),l=e.ref(!1);function m(u){r.value=u}function x(){!r.value&&!t.value.trim()||(a?.trackFeedback(i.id??null,r.value,t.value||null),l.value=!0,setTimeout(()=>{o.value=i.position==="inline",l.value=!1,r.value=null,t.value=""},2e3))}return(u,p)=>(e.openBlock(),e.createElementBlock("div",{class:"feedpulse-widget",style:e.normalizeStyle(d.position!=="inline"?`position:fixed; ${d.position==="bottom-right"?"right:24px":"left:24px"}; bottom:24px; z-index:9999;`:"")},[d.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:p[0]||(p[0]=g=>o.value=!o.value)}," 💬 ")):e.createCommentVNode("",!0),o.value?(e.openBlock(),e.createElementBlock("div",ae,[l.value?(e.openBlock(),e.createElementBlock("div",se,[...p[2]||(p[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",le,e.toDisplayString(d.placeholder??"How was your experience?"),1),e.createElementVNode("div",ie,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(5,g=>e.createElementVNode("button",{key:g,style:e.normalizeStyle({background:"none",border:"none",cursor:"pointer",fontSize:"24px",opacity:r.value!==null&&g<=r.value?1:.3}),onClick:y=>m(g)}," ⭐ ",12,re)),64))]),e.withDirectives(e.createElementVNode("textarea",{"onUpdate:modelValue":p[1]||(p[1]=g=>t.value=g),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:x}," Submit Feedback ")],64))])):e.createCommentVNode("",!0)],4))}});exports.ConsentBanner=T;exports.FeedPulseBot=K;exports.FeedPulseProvider=ne;exports.FeedPulseWidget=de;exports.useFeedPulse=z;
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;