@tekibo/feedpulse-sdk 0.6.1 → 0.7.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.
package/dist/react.js CHANGED
@@ -1,6 +1,25 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),N=require("./index.js");var j={exports:{}},_={};var Y;function se(){if(Y)return _;Y=1;var d=Symbol.for("react.transitional.element"),x=Symbol.for("react.fragment");function n(b,a,i){var m=null;if(i!==void 0&&(m=""+i),a.key!==void 0&&(m=""+a.key),"key"in a){i={};for(var g in a)g!=="key"&&(i[g]=a[g])}else i=a;return a=i.ref,{$$typeof:d,type:b,key:m,ref:a!==void 0?a:null,props:i}}return _.Fragment=x,_.jsx=n,_.jsxs=n,_}var R={};var $;function ie(){return $||($=1,process.env.NODE_ENV!=="production"&&(function(){function d(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ne?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case S:return"Fragment";case X:return"Profiler";case G:return"StrictMode";case K:return"Suspense";case ee:return"SuspenseList";case re:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case J:return"Portal";case Z:return e.displayName||"Context";case H:return(e._context.displayName||"Context")+".Consumer";case Q:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case te:return t=e.displayName||null,t!==null?t:d(e.type)||"Memo";case T:t=e._payload,e=e._init;try{return d(e(t))}catch{}}return null}function x(e){return""+e}function n(e){try{x(e);var t=!1}catch{t=!0}if(t){t=console;var s=t.error,l=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return s.call(t,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",l),x(e)}}function b(e){if(e===S)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===T)return"<...>";try{var t=d(e);return t?"<"+t+">":"<...>"}catch{return"<...>"}}function a(){var e=A.A;return e===null?null:e.getOwner()}function i(){return Error("react-stack-top-frame")}function m(e){if(F.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function g(e,t){function s(){D||(D=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}s.isReactWarning=!0,Object.defineProperty(e,"key",{get:s,configurable:!0})}function y(){var e=d(this.type);return I[e]||(I[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function o(e,t,s,l,w,C){var c=s.ref;return e={$$typeof:v,type:e,key:t,props:s,_owner:l},(c!==void 0?c:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:y}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:w}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:C}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function p(e,t,s,l,w,C){var c=t.children;if(c!==void 0)if(l)if(ae(c)){for(l=0;l<c.length;l++)k(c[l]);Object.freeze&&Object.freeze(c)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else k(c);if(F.call(t,"key")){c=d(e);var E=Object.keys(t).filter(function(oe){return oe!=="key"});l=0<E.length?"{key: someKey, "+E.join(": ..., ")+": ...}":"{key: someKey}",z[c+l]||(E=0<E.length?"{"+E.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),G=require("./index.js"),se=require("./struggle-detector-DV52qDLp.js");var q={exports:{}},W={};var Q;function ie(){if(Q)return W;Q=1;var a=Symbol.for("react.transitional.element"),m=Symbol.for("react.fragment");function s(h,i,l){var b=null;if(l!==void 0&&(b=""+l),i.key!==void 0&&(b=""+i.key),"key"in i){l={};for(var x in i)x!=="key"&&(l[x]=i[x])}else l=i;return i=l.ref,{$$typeof:a,type:h,key:b,ref:i!==void 0?i:null,props:l}}return W.Fragment=m,W.jsx=s,W.jsxs=s,W}var L={};var K;function le(){return K||(K=1,process.env.NODE_ENV!=="production"&&(function(){function a(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===I?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case D:return"Fragment";case Y:return"Profiler";case H:return"StrictMode";case F:return"Suspense";case B:return"SuspenseList";case J:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case P:return"Portal";case $:return e.displayName||"Context";case X:return(e._context.displayName||"Context")+".Consumer";case O:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case C:return r=e.displayName||null,r!==null?r:a(e.type)||"Memo";case j:r=e._payload,e=e._init;try{return a(e(r))}catch{}}return null}function m(e){return""+e}function s(e){try{m(e);var r=!1}catch{r=!0}if(r){r=console;var n=r.error,p=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",p),m(e)}}function h(e){if(e===D)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===j)return"<...>";try{var r=a(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function i(){var e=N.A;return e===null?null:e.getOwner()}function l(){return Error("react-stack-top-frame")}function b(e){if(R.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function x(e,r){function n(){U||(U=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}function k(){var e=a(this.type);return V[e]||(V[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function d(e,r,n,p,E,v){var c=n.ref;return e={$$typeof:w,type:e,key:r,props:n,_owner:p},(c!==void 0?c:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:k}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:E}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:v}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function f(e,r,n,p,E,v){var c=r.children;if(c!==void 0)if(p)if(Z(c)){for(p=0;p<c.length;p++)y(c[p]);Object.freeze&&Object.freeze(c)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else y(c);if(R.call(r,"key")){c=a(e);var _=Object.keys(r).filter(function(ae){return ae!=="key"});p=0<_.length?"{key: someKey, "+_.join(": ..., ")+": ...}":"{key: someKey}",A[c+p]||(_=0<_.length?"{"+_.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
2
  let props = %s;
3
3
  <%s {...props} />
4
4
  React keys must be passed directly to JSX without using spread:
5
5
  let props = %s;
6
- <%s key={someKey} {...props} />`,l,c,E,c),z[c+l]=!0)}if(c=null,s!==void 0&&(n(s),c=""+s),m(t)&&(n(t.key),c=""+t.key),"key"in t){s={};for(var O in t)O!=="key"&&(s[O]=t[O])}else s=t;return c&&g(s,typeof e=="function"?e.displayName||e.name||"Unknown":e),o(e,c,s,a(),w,C)}function k(e){h(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===T&&(e._payload.status==="fulfilled"?h(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function h(e){return typeof e=="object"&&e!==null&&e.$$typeof===v}var f=u,v=Symbol.for("react.transitional.element"),J=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),G=Symbol.for("react.strict_mode"),X=Symbol.for("react.profiler"),H=Symbol.for("react.consumer"),Z=Symbol.for("react.context"),Q=Symbol.for("react.forward_ref"),K=Symbol.for("react.suspense"),ee=Symbol.for("react.suspense_list"),te=Symbol.for("react.memo"),T=Symbol.for("react.lazy"),re=Symbol.for("react.activity"),ne=Symbol.for("react.client.reference"),A=f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=Object.prototype.hasOwnProperty,ae=Array.isArray,P=console.createTask?console.createTask:function(){return null};f={react_stack_bottom_frame:function(e){return e()}};var D,I={},M=f.react_stack_bottom_frame.bind(f,i)(),W=P(b(i)),z={};R.Fragment=S,R.jsx=function(e,t,s){var l=1e4>A.recentlyCreatedOwnerStacks++;return p(e,t,s,!1,l?Error("react-stack-top-frame"):M,l?P(b(e)):W)},R.jsxs=function(e,t,s){var l=1e4>A.recentlyCreatedOwnerStacks++;return p(e,t,s,!0,l?Error("react-stack-top-frame"):M,l?P(b(e)):W)}})()),R}var L;function le(){return L||(L=1,process.env.NODE_ENV==="production"?j.exports=se():j.exports=ie()),j.exports}var r=le();const U=new N.CookieManager;function V({onConsent:d}){const[x,n]=u.useState(!1),[b,a]=u.useState(!1),[i,m]=u.useState(!1),[g,y]=u.useState(!1);u.useEffect(()=>{const f=U.getConsent();n(!f||U.isConsentExpired()),f&&(m(f.analytics),y(f.marketing))},[]);const o=()=>{d({analytics:!0,marketing:!0,action:"accept_all"}),n(!1)},p=()=>{d({analytics:!1,marketing:!1,action:"reject_all"}),n(!1)},k=()=>{d({analytics:i,marketing:g,action:"custom"}),n(!1)},h=u.useCallback(()=>{d({analytics:!1,marketing:!1,action:"withdraw"}),m(!1),y(!1),n(!0)},[d]);return u.useEffect(()=>{const f=()=>{n(!0),a(!0)};return window.addEventListener("feedpulse:open-consent",f),window.addEventListener("feedpulse:withdraw-consent",h),()=>{window.removeEventListener("feedpulse:open-consent",f),window.removeEventListener("feedpulse:withdraw-consent",h)}},[h]),x?r.jsx("div",{style:{position:"fixed",bottom:0,left:0,right:0,zIndex:99999,background:"#1a1a1a",color:"#fff",padding:"20px 24px",borderTop:"1px solid #333",fontFamily:"sans-serif"},children:r.jsxs("div",{style:{maxWidth:900,margin:"0 auto"},children:[r.jsxs("p",{style:{margin:"0 0 12px",fontSize:14,lineHeight:1.5},children:["We use cookies to improve reliability and understand usage."," ",r.jsx("a",{href:"/privacy",style:{color:"#818cf8"},children:"Privacy Policy"})]}),b&&r.jsxs("div",{style:{marginBottom:12,fontSize:13},children:[r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6,opacity:.75},children:[r.jsx("input",{type:"checkbox",checked:!0,disabled:!0}),"Necessary (always on)"]}),r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[r.jsx("input",{type:"checkbox",checked:i,onChange:f=>m(f.target.checked)}),"Analytics"]}),r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8},children:[r.jsx("input",{type:"checkbox",checked:g,onChange:f=>y(f.target.checked)}),"Marketing"]})]}),r.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"center"},children:[r.jsx("button",{type:"button",style:{width:130,padding:"9px 12px",background:"#4f46e5",color:"#fff",border:"1px solid #4f46e5",borderRadius:6,fontSize:13,fontWeight:600,cursor:"pointer"},onClick:o,children:"Accept All"}),r.jsx("button",{type:"button",style:{width:130,padding:"9px 12px",background:"transparent",color:"#fff",border:"1px solid #555",borderRadius:6,fontSize:13,fontWeight:600,cursor:"pointer"},onClick:p,children:"Reject All"}),r.jsx("button",{type:"button",style:{padding:"9px 16px",background:"transparent",color:"#aaa",border:"1px solid #333",borderRadius:6,fontSize:13,cursor:"pointer"},onClick:()=>b?k():a(!0),children:b?"Save Preferences":"Customize"})]})]})}):null}const q=u.createContext({tracker:null});function ce({proxyEndpoint:d="/api/fp-proxy",debug:x,consentRequired:n=!0,children:b}){const a=u.useRef(null),i=u.useRef(new N.CookieManager),[m,g]=u.useState(null),y=u.useCallback(o=>{const p=i.current,k=p.setConsent({analytics:o.analytics,marketing:o.marketing,version:"1.0"});o.analytics||p.clearAnalyticsCookies(),a.current?.updateCookieData(p.getAllData(o.analytics)),a.current?.track("consent","__consent__",{analytics:o.analytics,marketing:o.marketing,action:o.action,userAgent:navigator.userAgent,version:k.version})},[]);return u.useEffect(()=>{const o=new N.FeedPulseTracker({proxyEndpoint:d,debug:x});a.current=o,g(o);const p=i.current,k=p.getConsent();return n?k&&!p.isConsentExpired()?o.updateCookieData(p.getAllData(k.analytics)):o.updateCookieData(p.getAllData(!1)):(p.setConsent({analytics:!0,marketing:!0,version:"1.0"}),o.updateCookieData(p.getAllData(!0))),o.init(),()=>{o.destroy(),a.current=null,g(null)}},[d,x,n]),r.jsxs(q.Provider,{value:{tracker:m},children:[b,n&&r.jsx(V,{onConsent:y})]})}function B(){return u.useContext(q)}function ue({id:d,placeholder:x,position:n="bottom-right"}){const{tracker:b}=B(),[a,i]=u.useState(n==="inline"),[m,g]=u.useState(null),[y,o]=u.useState(""),[p,k]=u.useState(!1),h=()=>{!m&&!y.trim()||(b?.trackFeedback(d??null,m,y||null),k(!0),setTimeout(()=>{i(n==="inline"),k(!1),g(null),o("")},2e3))},f=n!=="inline"?{position:"fixed",bottom:24,[n==="bottom-right"?"right":"left"]:24,zIndex:9999}:{};return r.jsxs("div",{style:f,children:[n!=="inline"&&r.jsx("button",{onClick:()=>i(!a),style:{background:"#6366f1",color:"#fff",border:"none",borderRadius:"50%",width:48,height:48,fontSize:20,cursor:"pointer"},children:"💬"}),a&&r.jsx("div",{style:{background:"#fff",border:"1px solid #e5e7eb",borderRadius:12,padding:16,width:280,boxShadow:"0 10px 25px rgba(0,0,0,0.15)"},children:p?r.jsxs("div",{style:{textAlign:"center",padding:16},children:[r.jsx("p",{style:{fontSize:28,margin:0},children:"🎉"}),r.jsx("p",{style:{margin:"8px 0 0",fontWeight:600},children:"Thanks for your feedback!"})]}):r.jsxs(r.Fragment,{children:[r.jsx("p",{style:{margin:"0 0 12px",fontWeight:600},children:x??"How was your experience?"}),r.jsx("div",{style:{display:"flex",gap:6,marginBottom:12},children:[1,2,3,4,5].map(v=>r.jsx("button",{onClick:()=>g(v),style:{background:"none",border:"none",cursor:"pointer",fontSize:24,opacity:m!==null&&v<=m?1:.3},children:"⭐"},v))}),r.jsx("textarea",{value:y,onChange:v=>o(v.target.value),placeholder:"Tell us more (optional)...",rows:3,style:{width:"100%",padding:8,border:"1px solid #d1d5db",borderRadius:8,resize:"none",fontSize:14}}),r.jsx("button",{onClick:h,style:{marginTop:10,width:"100%",background:"#6366f1",color:"#fff",border:"none",borderRadius:8,padding:10,fontWeight:600,cursor:"pointer"},children:"Submit Feedback"})]})})]})}exports.ConsentBanner=V;exports.FeedPulseProvider=ce;exports.FeedPulseWidget=ue;exports.useFeedPulse=B;
6
+ <%s key={someKey} {...props} />`,p,c,_,c),A[c+p]=!0)}if(c=null,n!==void 0&&(s(n),c=""+n),b(r)&&(s(r.key),c=""+r.key),"key"in r){n={};for(var T in r)T!=="key"&&(n[T]=r[T])}else n=r;return c&&x(n,typeof e=="function"?e.displayName||e.name||"Unknown":e),d(e,c,n,i(),E,v)}function y(e){S(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===j&&(e._payload.status==="fulfilled"?S(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function S(e){return typeof e=="object"&&e!==null&&e.$$typeof===w}var u=o,w=Symbol.for("react.transitional.element"),P=Symbol.for("react.portal"),D=Symbol.for("react.fragment"),H=Symbol.for("react.strict_mode"),Y=Symbol.for("react.profiler"),X=Symbol.for("react.consumer"),$=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),F=Symbol.for("react.suspense"),B=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),J=Symbol.for("react.activity"),I=Symbol.for("react.client.reference"),N=u.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R=Object.prototype.hasOwnProperty,Z=Array.isArray,M=console.createTask?console.createTask:function(){return null};u={react_stack_bottom_frame:function(e){return e()}};var U,V={},g=u.react_stack_bottom_frame.bind(u,l)(),z=M(h(l)),A={};L.Fragment=D,L.jsx=function(e,r,n){var p=1e4>N.recentlyCreatedOwnerStacks++;return f(e,r,n,!1,p?Error("react-stack-top-frame"):g,p?M(h(e)):z)},L.jsxs=function(e,r,n){var p=1e4>N.recentlyCreatedOwnerStacks++;return f(e,r,n,!0,p?Error("react-stack-top-frame"):g,p?M(h(e)):z)}})()),L}var ee;function ce(){return ee||(ee=1,process.env.NODE_ENV==="production"?q.exports=ie():q.exports=le()),q.exports}var t=ce();const te=new G.CookieManager;function re({onConsent:a}){const[m,s]=o.useState(!1),[h,i]=o.useState(!1),[l,b]=o.useState(!1),[x,k]=o.useState(!1);o.useEffect(()=>{const u=te.getConsent();s(!u||te.isConsentExpired()),u&&(b(u.analytics),k(u.marketing))},[]);const d=()=>{a({analytics:!0,marketing:!0,action:"accept_all"}),s(!1)},f=()=>{a({analytics:!1,marketing:!1,action:"reject_all"}),s(!1)},y=()=>{a({analytics:l,marketing:x,action:"custom"}),s(!1)},S=o.useCallback(()=>{a({analytics:!1,marketing:!1,action:"withdraw"}),b(!1),k(!1),s(!0)},[a]);return o.useEffect(()=>{const u=()=>{s(!0),i(!0)};return window.addEventListener("feedpulse:open-consent",u),window.addEventListener("feedpulse:withdraw-consent",S),()=>{window.removeEventListener("feedpulse:open-consent",u),window.removeEventListener("feedpulse:withdraw-consent",S)}},[S]),m?t.jsx("div",{style:{position:"fixed",bottom:0,left:0,right:0,zIndex:99999,background:"#1a1a1a",color:"#fff",padding:"20px 24px",borderTop:"1px solid #333",fontFamily:"sans-serif"},children:t.jsxs("div",{style:{maxWidth:900,margin:"0 auto"},children:[t.jsxs("p",{style:{margin:"0 0 12px",fontSize:14,lineHeight:1.5},children:["We use cookies to improve reliability and understand usage."," ",t.jsx("a",{href:"/privacy",style:{color:"#818cf8"},children:"Privacy Policy"})]}),h&&t.jsxs("div",{style:{marginBottom:12,fontSize:13},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6,opacity:.75},children:[t.jsx("input",{type:"checkbox",checked:!0,disabled:!0}),"Necessary (always on)"]}),t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[t.jsx("input",{type:"checkbox",checked:l,onChange:u=>b(u.target.checked)}),"Analytics"]}),t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("input",{type:"checkbox",checked:x,onChange:u=>k(u.target.checked)}),"Marketing"]})]}),t.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"center"},children:[t.jsx("button",{type:"button",style:{width:130,padding:"9px 12px",background:"#4f46e5",color:"#fff",border:"1px solid #4f46e5",borderRadius:6,fontSize:13,fontWeight:600,cursor:"pointer"},onClick:d,children:"Accept All"}),t.jsx("button",{type:"button",style:{width:130,padding:"9px 12px",background:"transparent",color:"#fff",border:"1px solid #555",borderRadius:6,fontSize:13,fontWeight:600,cursor:"pointer"},onClick:f,children:"Reject All"}),t.jsx("button",{type:"button",style:{padding:"9px 16px",background:"transparent",color:"#aaa",border:"1px solid #333",borderRadius:6,fontSize:13,cursor:"pointer"},onClick:()=>h?y():i(!0),children:h?"Save Preferences":"Customize"})]})]})}):null}function de(){if(typeof document>"u"||document.getElementById("fp-bot-animations"))return;const a=document.createElement("style");a.id="fp-bot-animations",a.textContent=`
7
+ @keyframes fp-bubble-in {
8
+ 0% { opacity: 0; transform: scale(0.8) translateY(6px); }
9
+ 100% { opacity: 1; transform: scale(1) translateY(0); }
10
+ }
11
+ @keyframes fp-bounce {
12
+ 0% { transform: translateY(0); }
13
+ 50% { transform: translateY(-8px); }
14
+ 100% { transform: translateY(0); }
15
+ }
16
+ @keyframes fp-panel-open {
17
+ 0% { opacity: 0; transform: translateY(40px); }
18
+ 100% { opacity: 1; transform: translateY(0); }
19
+ }
20
+ @keyframes fp-dot {
21
+ 0% { opacity: 0.2; transform: translateY(0); }
22
+ 50% { opacity: 1; transform: translateY(-3px); }
23
+ 100% { opacity: 0.2; transform: translateY(0); }
24
+ }
25
+ `,document.head.appendChild(a)}function ue({faq:a=[],pageContext:m="",systemPrompt:s="",canNavigate:h=!1,canHelpForms:i=!1,escalateTo:l,initialMessage:b="👋 Need help?",position:x="bottom-right"}){const k=o.useRef(new G.CookieManager),[d,f]=o.useState(!1),[y,S]=o.useState(!1),[u,w]=o.useState(!1),[P,D]=o.useState(""),[H,Y]=o.useState(null),[X,$]=o.useState(!1),[O,F]=o.useState(!1),[B,C]=o.useState([]),[j,J]=o.useState(""),[I,N]=o.useState(!1),R=o.useRef(null),Z=o.useMemo(()=>({faq:a,pageContext:m,systemPrompt:s,canNavigate:h,canHelpForms:i,escalateTo:l}),[a,m,s,h,i,l]);o.useEffect(()=>{de();const g=new se.StruggleDetector({onTrigger:async(z,A)=>{S(!0),f(!0),Y(null),$(!1),F(!1),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>f(!1),8e3);try{const e=k.current.getAllData(!0),r=await fetch("/api/bot/session-proxy",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({page:window.location.pathname,triggerScore:z,triggerReasons:A,sessionId:e.sessionId,visitorId:e.userId,device:navigator.userAgent})});if(r.status===402){F(!0);return}const n=await r.json().catch(()=>null);n?.botSessionId&&D(n.botSessionId)}catch{}}});return g.start(),()=>{g.stop(),R.current&&clearTimeout(R.current)}},[]);const M={position:"fixed",bottom:24,zIndex:1e4,...x==="bottom-left"?{left:24}:{right:24}},U=g=>{if(g.preventDefault(),!j.trim()||O||I||!P)return;const z=j.trim();J("");const A={id:`user-${Date.now()}`,role:"user",content:z},e=`assistant-${Date.now()}`;C(r=>[...r,A,{id:e,role:"assistant",content:""}]),N(!0),(async()=>{try{const r=await fetch("/api/bot/chat-proxy",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({botSessionId:P,config:Z,messages:[...B,A].map(v=>({role:v.role,content:v.content}))})});if(r.status===402){F(!0),C(v=>v.map(c=>c.id===e?{...c,content:"Service temporarily unavailable."}:c));return}if(!r.ok)throw new Error("chat failed");const n=r.body?.getReader();if(!n)throw new Error("no body");const p=new TextDecoder;let E=!1;for(;!E;){const v=await n.read();if(E=v.done,v.value){const c=p.decode(v.value,{stream:!E});C(_=>_.map(T=>T.id===e?{...T,content:T.content+c}:T))}}}catch{C(r=>r.map(n=>n.id===e&&!n.content?{...n,content:"Sorry, I couldn't process that. Please try again."}:n))}finally{N(!1)}})()},V=async()=>{if(w(!1),!!P){try{await fetch("/api/bot/session-end-proxy",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({botSessionId:P,wasHelpful:H,escalated:X})})}catch{}C([])}};return t.jsxs("div",{style:M,children:[d&&!u&&t.jsx("div",{style:{position:"absolute",bottom:62,right:x==="bottom-right"?0:void 0,left:x==="bottom-left"?0:void 0,background:"#fff",border:"2px solid #6366f1",color:"#1f2937",borderRadius:"12px 12px 0 12px",padding:"10px 12px",maxWidth:240,fontSize:13,boxShadow:"0 10px 22px rgba(0,0,0,0.16)",animation:"fp-bubble-in 300ms ease-out"},children:b}),y&&!u&&t.jsx("button",{style:{width:48,height:48,borderRadius:999,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:()=>{w(!0),f(!1)},children:t.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",children:[t.jsx("rect",{x:"3",y:"8",width:"18",height:"13",rx:"2"}),t.jsx("path",{d:"M12 8V5"}),t.jsx("circle",{cx:"12",cy:"4",r:"1"}),t.jsx("circle",{cx:"8",cy:"13",r:"1.5",fill:"white",stroke:"none"}),t.jsx("circle",{cx:"16",cy:"13",r:"1.5",fill:"white",stroke:"none"}),t.jsx("path",{d:"M9 17h6",strokeLinecap:"round"})]})}),u&&!!P&&t.jsxs("div",{style:{width:360,height:520,background:"#111827",color:"#e5e7eb",borderRadius:16,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"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 14px",borderBottom:"1px solid #374151",background:"#0f172a"},children:[t.jsxs("div",{style:{display:"grid",gap:2},children:[t.jsx("strong",{style:{fontSize:14,color:"#fff"},children:"Pulse Bot"}),t.jsx("span",{style:{fontSize:11,color:"#94a3b8"},children:"Powered by FeedPulse AI"})]}),t.jsx("button",{style:{border:"none",background:"transparent",color:"#cbd5e1",cursor:"pointer",fontSize:18},onClick:V,children:"×"})]}),t.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12,display:"grid",gap:10},children:[B.map(g=>t.jsxs("div",{style:{display:"grid",justifyItems:g.role==="user"?"end":"start",gap:6},children:[t.jsx("div",{style:{maxWidth:"85%",padding:"9px 11px",borderRadius:g.role==="user"?"14px 14px 2px 14px":"14px 14px 14px 2px",background:g.role==="user"?"#4f46e5":"#1f2937",color:"#fff",fontSize:13,whiteSpace:"pre-wrap"},children:g.content}),g.role==="assistant"&&t.jsxs("div",{style:{display:"flex",gap:8},children:[t.jsx("button",{style:{border:"1px solid #334155",background:"#0f172a",color:"#e2e8f0",borderRadius:8,fontSize:12,padding:"4px 8px",cursor:"pointer"},onClick:()=>Y(!0),children:"👍"}),t.jsx("button",{style:{border:"1px solid #334155",background:"#0f172a",color:"#e2e8f0",borderRadius:8,fontSize:12,padding:"4px 8px",cursor:"pointer"},onClick:()=>Y(!1),children:"👎"})]})]},g.id)),I&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5},children:[t.jsx("span",{style:{width:8,height:8,borderRadius:999,background:"#94a3b8",animation:"fp-dot 1s infinite 0ms"}}),t.jsx("span",{style:{width:8,height:8,borderRadius:999,background:"#94a3b8",animation:"fp-dot 1s infinite 160ms"}}),t.jsx("span",{style:{width:8,height:8,borderRadius:999,background:"#94a3b8",animation:"fp-dot 1s infinite 320ms"}})]}),O&&t.jsx("div",{style:{border:"1px solid #f59e0b",background:"#451a03",color:"#fde68a",borderRadius:10,padding:10,fontSize:12},children:"Service temporarily unavailable."})]}),t.jsxs("form",{style:{padding:10,borderTop:"1px solid #374151",display:"grid",gap:8},onSubmit:U,children:[t.jsxs("div",{style:{display:"flex",gap:8},children:[t.jsx("input",{value:j,disabled:I||O,onChange:g=>J(g.target.value),style:{flex:1,borderRadius:10,border:"1px solid #475569",background:"#0f172a",color:"#fff",fontSize:13,padding:"8px 10px",outline:"none"},placeholder:"Ask a question..."}),t.jsx("button",{type:"submit",disabled:!j.trim()||I||O,style:{border:"none",borderRadius:10,background:"#6366f1",color:"#fff",fontWeight:600,fontSize:12,padding:"0 14px",cursor:"pointer"},children:"Send"})]}),l&&t.jsx("a",{href:l.url,style:{color:"#c4b5fd",fontSize:12,textDecoration:"none"},onClick:()=>$(!0),children:l.label})]})]})]})}const ne=o.createContext({tracker:null});function fe({proxyEndpoint:a="/api/fp-proxy",debug:m,consentRequired:s=!0,children:h}){const i=o.useRef(null),l=o.useRef(new G.CookieManager),[b,x]=o.useState(null),k=o.useCallback(d=>{const f=l.current,y=f.setConsent({analytics:d.analytics,marketing:d.marketing,version:"1.0"});d.analytics||f.clearAnalyticsCookies(),i.current?.updateCookieData(f.getAllData(d.analytics)),i.current?.track("consent","__consent__",{analytics:d.analytics,marketing:d.marketing,action:d.action,userAgent:navigator.userAgent,version:y.version})},[]);return o.useEffect(()=>{const d=new G.FeedPulseTracker({proxyEndpoint:a,debug:m});i.current=d,x(d);const f=l.current,y=f.getConsent();return s?y&&!f.isConsentExpired()?d.updateCookieData(f.getAllData(y.analytics)):d.updateCookieData(f.getAllData(!1)):(f.setConsent({analytics:!0,marketing:!0,version:"1.0"}),d.updateCookieData(f.getAllData(!0))),d.init(),()=>{d.destroy(),i.current=null,x(null)}},[a,m,s]),t.jsxs(ne.Provider,{value:{tracker:b},children:[h,s&&t.jsx(re,{onConsent:k})]})}function oe(){return o.useContext(ne)}function pe({id:a,placeholder:m,position:s="bottom-right"}){const{tracker:h}=oe(),[i,l]=o.useState(s==="inline"),[b,x]=o.useState(null),[k,d]=o.useState(""),[f,y]=o.useState(!1),S=()=>{!b&&!k.trim()||(h?.trackFeedback(a??null,b,k||null),y(!0),setTimeout(()=>{l(s==="inline"),y(!1),x(null),d("")},2e3))},u=s!=="inline"?{position:"fixed",bottom:24,[s==="bottom-right"?"right":"left"]:24,zIndex:9999}:{};return t.jsxs("div",{style:u,children:[s!=="inline"&&t.jsx("button",{onClick:()=>l(!i),style:{background:"#6366f1",color:"#fff",border:"none",borderRadius:"50%",width:48,height:48,fontSize:20,cursor:"pointer"},children:"💬"}),i&&t.jsx("div",{style:{background:"#fff",border:"1px solid #e5e7eb",borderRadius:12,padding:16,width:280,boxShadow:"0 10px 25px rgba(0,0,0,0.15)"},children:f?t.jsxs("div",{style:{textAlign:"center",padding:16},children:[t.jsx("p",{style:{fontSize:28,margin:0},children:"🎉"}),t.jsx("p",{style:{margin:"8px 0 0",fontWeight:600},children:"Thanks for your feedback!"})]}):t.jsxs(t.Fragment,{children:[t.jsx("p",{style:{margin:"0 0 12px",fontWeight:600},children:m??"How was your experience?"}),t.jsx("div",{style:{display:"flex",gap:6,marginBottom:12},children:[1,2,3,4,5].map(w=>t.jsx("button",{onClick:()=>x(w),style:{background:"none",border:"none",cursor:"pointer",fontSize:24,opacity:b!==null&&w<=b?1:.3},children:"⭐"},w))}),t.jsx("textarea",{value:k,onChange:w=>d(w.target.value),placeholder:"Tell us more (optional)...",rows:3,style:{width:"100%",padding:8,border:"1px solid #d1d5db",borderRadius:8,resize:"none",fontSize:14}}),t.jsx("button",{onClick:S,style:{marginTop:10,width:"100%",background:"#6366f1",color:"#fff",border:"none",borderRadius:8,padding:10,fontWeight:600,cursor:"pointer"},children:"Submit Feedback"})]})})]})}exports.ConsentBanner=re;exports.FeedPulseBot=ue;exports.FeedPulseProvider=fe;exports.FeedPulseWidget=pe;exports.useFeedPulse=oe;