@ronak27/superwise-chatbot-package 1.0.9 → 1.0.10
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-chatbot.es.js
CHANGED
|
@@ -399,10 +399,12 @@ const m = {
|
|
|
399
399
|
position: "fixed",
|
|
400
400
|
top: "0px",
|
|
401
401
|
left: "0px",
|
|
402
|
+
right: "0px",
|
|
403
|
+
bottom: "0px",
|
|
402
404
|
zIndex: 999999,
|
|
403
405
|
fontFamily: "'Inter', sans-serif",
|
|
404
|
-
width: "
|
|
405
|
-
height: "
|
|
406
|
+
width: "100%",
|
|
407
|
+
height: "100%",
|
|
406
408
|
display: "flex",
|
|
407
409
|
flexDirection: "column",
|
|
408
410
|
borderRadius: "0",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,b,k,_,k),de[k+b]=!0)}if(k=null,y!==void 0&&(a(y),k=""+y),i(c)&&(a(c.key),k=""+c.key),"key"in c){y={};for(var T in c)T!=="key"&&(y[T]=c[T])}else y=c;return k&&w(y,typeof t=="function"?t.displayName||t.name||"Unknown":t),C(t,k,y,o(),N,L)}function E(t){I(t)?t._store&&(t._store.validated=1):typeof t=="object"&&t!==null&&t.$$typeof===H&&(t._payload.status==="fulfilled"?I(t._payload.value)&&t._payload.value._store&&(t._payload.value._store.validated=1):t._store&&(t._store.validated=1))}function I(t){return typeof t=="object"&&t!==null&&t.$$typeof===u}var f=l,u=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),A=Symbol.for("react.strict_mode"),W=Symbol.for("react.profiler"),z=Symbol.for("react.consumer"),q=Symbol.for("react.context"),ee=Symbol.for("react.forward_ref"),te=Symbol.for("react.suspense"),re=Symbol.for("react.suspense_list"),ne=Symbol.for("react.memo"),H=Symbol.for("react.lazy"),M=Symbol.for("react.activity"),oe=Symbol.for("react.client.reference"),se=f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=Object.prototype.hasOwnProperty,B=Array.isArray,P=console.createTask?console.createTask:function(){return null};f={react_stack_bottom_frame:function(t){return t()}};var J,ae={},D=f.react_stack_bottom_frame.bind(f,d)(),U=P(m(d)),de={};G.Fragment=R,G.jsx=function(t,c,y){var b=1e4>se.recentlyCreatedOwnerStacks++;return g(t,c,y,!1,b?Error("react-stack-top-frame"):D,b?P(m(t)):U)},G.jsxs=function(t,c,y){var b=1e4>se.recentlyCreatedOwnerStacks++;return g(t,c,y,!0,b?Error("react-stack-top-frame"):D,b?P(m(t)):U)}}()),G}process.env.NODE_ENV==="production"?ie.exports=ke():ie.exports=ve();var e=ie.exports;const Ee=["Parameters:","additional_parameter_company_name:","additional_parameter_company_size:","additional_parameter_user_role:","additional_parameter_use_case:"];function Se(r){if(typeof r!="string"||r.length===0)return r;let n=r;for(const a of Ee)for(;;){const m=n.indexOf(a);if(m===-1)break;const o=n.indexOf("{",m);if(o===-1)break;let d=0,i=-1;for(let C=o;C<n.length;C++){const g=n[C];if(g==="{")d++;else if(g==="}"&&(d--,d===0)){i=C;break}}if(i===-1)break;const w=n.slice(0,m).trim(),p=n.slice(i+1).trim();n=w+(p.length>0?" "+p:"")}return n.includes("Parameters:")&&(n=n.split("Parameters:")[0].trim()),n}async function je(r,n=[],a=[],m="",o="",d=null){var g,E,I;const w="https://sage-api-ttyw-stage.superwise.ai/api/v1/"+"chat",p=Array.isArray(n)?n.map(f=>({role:f.role,message:f.content!=null?f.content:""})):[],C={user_input:r,chat_history:p,mql_df:Array.isArray(a)?a:[],agent_id:m,discovery_agent_id:o,utm_source:"Web",utm_medium:"chatbot"};console.log("Sending payload:",C);try{const f=await fetch(w,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(C),signal:d??void 0});if(console.log("Response status:",f.status),console.log("Response headers:",f.headers),!f.ok){const W=await f.text();return console.error("API Error Response:",W),{reply:`❌ API Error ${f.status}: ${W}`,mqlDf:[]}}const u=await f.json();console.log("API Response Data:",u);let j="⚠️ No reply from server.",R=[],A=!1;return u.chat_response?j=u.chat_response:u.success&&((g=u.data)!=null&&g.chat_response)?j=u.data.chat_response:u.message&&(j=u.message),u.mql_df?R=u.mql_df:(E=u.data)!=null&&E.mql_df&&(R=u.data.mql_df),(u.chat_history_limit_exceeded===!0||((I=u.data)==null?void 0:I.chat_history_limit_exceeded)===!0)&&(A=!0),j=Se(j),{reply:j,mqlDf:R,chatHistoryLimitExceeded:A}}catch(f){if(console.error("API call failed:",f),f.name==="AbortError")throw f;return f.name==="TypeError"&&f.message.includes("fetch")?{reply:"⚠️ Network error. Please check your connection.",mqlDf:[]}:{reply:`⚠️ API request failed: ${f.message}`,mqlDf:[]}}}async function Le(r,n=null,a=[]){const o="https://sage-api-ttyw-stage.superwise.ai/api/v1/"+"pdf",d=Array.isArray(r)&&r.length>0?r[0]:n||{name:"User",email:"user@example.com",summary:"Chat conversation summary"},i=Array.isArray(a)?a.map(p=>({role:p.role,message:p.content!=null?p.content:""})):[],w={lead_row:d,chat_history:i};console.log("Downloading PDF with payload:",w);try{const p=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/pdf"},body:JSON.stringify(w)});if(console.log("PDF Response status:",p.status),!p.ok){const I=await p.text();throw console.error("PDF API Error Response:",I),new Error(`PDF API Error ${p.status}: ${I}`)}const C=await p.blob(),g=window.URL.createObjectURL(C),E=document.createElement("a");return E.href=g,E.download=`chatbot-report-${new Date().toISOString().split("T")[0]}.pdf`,document.body.appendChild(E),E.click(),document.body.removeChild(E),window.URL.revokeObjectURL(g),!0}catch(p){throw console.error("PDF download failed:",p),p}}const h={container:{position:"fixed",bottom:"0px",right:"20px",zIndex:999999,fontFamily:"'Inter', sans-serif",maxWidth:"400px",width:"80vw",maxHeight:"75vh",height:"75vh",display:"flex",flexDirection:"column",borderRadius:"1rem",background:"white",boxShadow:"0 0 8rem 0 rgba(0, 0, 0, 0.1), 0rem 2rem 4rem -3rem rgba(0, 0, 0, 0.5)",boxSizing:"border-box"},containerExpanded:{position:"fixed",top:"0px",left:"0px",zIndex:999999,fontFamily:"'Inter', sans-serif",width:"
|
|
22
|
+
<%s key={someKey} {...props} />`,b,k,_,k),de[k+b]=!0)}if(k=null,y!==void 0&&(a(y),k=""+y),i(c)&&(a(c.key),k=""+c.key),"key"in c){y={};for(var T in c)T!=="key"&&(y[T]=c[T])}else y=c;return k&&w(y,typeof t=="function"?t.displayName||t.name||"Unknown":t),C(t,k,y,o(),N,L)}function E(t){I(t)?t._store&&(t._store.validated=1):typeof t=="object"&&t!==null&&t.$$typeof===H&&(t._payload.status==="fulfilled"?I(t._payload.value)&&t._payload.value._store&&(t._payload.value._store.validated=1):t._store&&(t._store.validated=1))}function I(t){return typeof t=="object"&&t!==null&&t.$$typeof===u}var f=l,u=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),A=Symbol.for("react.strict_mode"),W=Symbol.for("react.profiler"),z=Symbol.for("react.consumer"),q=Symbol.for("react.context"),ee=Symbol.for("react.forward_ref"),te=Symbol.for("react.suspense"),re=Symbol.for("react.suspense_list"),ne=Symbol.for("react.memo"),H=Symbol.for("react.lazy"),M=Symbol.for("react.activity"),oe=Symbol.for("react.client.reference"),se=f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=Object.prototype.hasOwnProperty,B=Array.isArray,P=console.createTask?console.createTask:function(){return null};f={react_stack_bottom_frame:function(t){return t()}};var J,ae={},D=f.react_stack_bottom_frame.bind(f,d)(),U=P(m(d)),de={};G.Fragment=R,G.jsx=function(t,c,y){var b=1e4>se.recentlyCreatedOwnerStacks++;return g(t,c,y,!1,b?Error("react-stack-top-frame"):D,b?P(m(t)):U)},G.jsxs=function(t,c,y){var b=1e4>se.recentlyCreatedOwnerStacks++;return g(t,c,y,!0,b?Error("react-stack-top-frame"):D,b?P(m(t)):U)}}()),G}process.env.NODE_ENV==="production"?ie.exports=ke():ie.exports=ve();var e=ie.exports;const Ee=["Parameters:","additional_parameter_company_name:","additional_parameter_company_size:","additional_parameter_user_role:","additional_parameter_use_case:"];function Se(r){if(typeof r!="string"||r.length===0)return r;let n=r;for(const a of Ee)for(;;){const m=n.indexOf(a);if(m===-1)break;const o=n.indexOf("{",m);if(o===-1)break;let d=0,i=-1;for(let C=o;C<n.length;C++){const g=n[C];if(g==="{")d++;else if(g==="}"&&(d--,d===0)){i=C;break}}if(i===-1)break;const w=n.slice(0,m).trim(),p=n.slice(i+1).trim();n=w+(p.length>0?" "+p:"")}return n.includes("Parameters:")&&(n=n.split("Parameters:")[0].trim()),n}async function je(r,n=[],a=[],m="",o="",d=null){var g,E,I;const w="https://sage-api-ttyw-stage.superwise.ai/api/v1/"+"chat",p=Array.isArray(n)?n.map(f=>({role:f.role,message:f.content!=null?f.content:""})):[],C={user_input:r,chat_history:p,mql_df:Array.isArray(a)?a:[],agent_id:m,discovery_agent_id:o,utm_source:"Web",utm_medium:"chatbot"};console.log("Sending payload:",C);try{const f=await fetch(w,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(C),signal:d??void 0});if(console.log("Response status:",f.status),console.log("Response headers:",f.headers),!f.ok){const W=await f.text();return console.error("API Error Response:",W),{reply:`❌ API Error ${f.status}: ${W}`,mqlDf:[]}}const u=await f.json();console.log("API Response Data:",u);let j="⚠️ No reply from server.",R=[],A=!1;return u.chat_response?j=u.chat_response:u.success&&((g=u.data)!=null&&g.chat_response)?j=u.data.chat_response:u.message&&(j=u.message),u.mql_df?R=u.mql_df:(E=u.data)!=null&&E.mql_df&&(R=u.data.mql_df),(u.chat_history_limit_exceeded===!0||((I=u.data)==null?void 0:I.chat_history_limit_exceeded)===!0)&&(A=!0),j=Se(j),{reply:j,mqlDf:R,chatHistoryLimitExceeded:A}}catch(f){if(console.error("API call failed:",f),f.name==="AbortError")throw f;return f.name==="TypeError"&&f.message.includes("fetch")?{reply:"⚠️ Network error. Please check your connection.",mqlDf:[]}:{reply:`⚠️ API request failed: ${f.message}`,mqlDf:[]}}}async function Le(r,n=null,a=[]){const o="https://sage-api-ttyw-stage.superwise.ai/api/v1/"+"pdf",d=Array.isArray(r)&&r.length>0?r[0]:n||{name:"User",email:"user@example.com",summary:"Chat conversation summary"},i=Array.isArray(a)?a.map(p=>({role:p.role,message:p.content!=null?p.content:""})):[],w={lead_row:d,chat_history:i};console.log("Downloading PDF with payload:",w);try{const p=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/pdf"},body:JSON.stringify(w)});if(console.log("PDF Response status:",p.status),!p.ok){const I=await p.text();throw console.error("PDF API Error Response:",I),new Error(`PDF API Error ${p.status}: ${I}`)}const C=await p.blob(),g=window.URL.createObjectURL(C),E=document.createElement("a");return E.href=g,E.download=`chatbot-report-${new Date().toISOString().split("T")[0]}.pdf`,document.body.appendChild(E),E.click(),document.body.removeChild(E),window.URL.revokeObjectURL(g),!0}catch(p){throw console.error("PDF download failed:",p),p}}const h={container:{position:"fixed",bottom:"0px",right:"20px",zIndex:999999,fontFamily:"'Inter', sans-serif",maxWidth:"400px",width:"80vw",maxHeight:"75vh",height:"75vh",display:"flex",flexDirection:"column",borderRadius:"1rem",background:"white",boxShadow:"0 0 8rem 0 rgba(0, 0, 0, 0.1), 0rem 2rem 4rem -3rem rgba(0, 0, 0, 0.5)",boxSizing:"border-box"},containerExpanded:{position:"fixed",top:"0px",left:"0px",right:"0px",bottom:"0px",zIndex:999999,fontFamily:"'Inter', sans-serif",width:"100%",height:"100%",display:"flex",flexDirection:"column",borderRadius:"0",background:"white",boxShadow:"0 0 8rem 0 rgba(0, 0, 0, 0.1), 0rem 2rem 4rem -3rem rgba(0, 0, 0, 0.5)",boxSizing:"border-box"},containerMinimized:{position:"fixed",bottom:"20px",right:"20px",zIndex:999999,fontFamily:"'Inter', sans-serif",width:"auto",minWidth:"250px",maxWidth:"350px",height:"auto",display:"flex",flexDirection:"row",borderRadius:"25px",background:"#000000",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",boxSizing:"border-box",padding:"12px 16px",alignItems:"center",cursor:"pointer"},header:{position:"relative",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px",background:"var(--swttyw-primary-color)",color:"#fff",borderRadius:"10px 10px 0 0",fontFamily:"'Inter', sans-serif",flexShrink:0,boxSizing:"border-box"},name:{fontWeight:500,fontSize:"var(--swttyw-header-font-size)",color:"#fff",flexGrow:1,marginBottom:"0.125rem",wordBreak:"break-all"},headerActions:{display:"flex",alignItems:"center",gap:"8px"},headerButton:{background:"transparent",border:"none",color:"#fff",cursor:"pointer",padding:"4px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",textDecoration:"none",transition:"opacity 0.3s ease"},chatSection:{padding:"1rem",backgroundColor:"var(--swttyw-background-color)",flexGrow:1,overflowY:"auto",overflowX:"hidden",display:"flex",flexDirection:"column",boxShadow:"inset 0 2rem 2rem -2rem rgba(0, 0, 0, 0.05), inset 0 -2rem 2rem -2rem rgba(0, 0, 0, 0.05)",height:"calc(50vh - 200px)"},inputSection:{boxSizing:"border-box",flexBasis:"4rem",flexShrink:0,display:"flex",alignItems:"center",boxShadow:"0 0 1rem rgba(0, 0, 0, 0.1), 0rem 1rem 1rem -1rem rgba(0, 0, 0, 0.2)",margin:"0.50rem"},textarea:{border:"none",backgroundImage:"none",backgroundColor:"white",padding:"0.5rem 1rem",marginRight:"1rem",borderRadius:"10px",flexGrow:2,fontFamily:"'Inter', sans-serif",fontWeight:400,letterSpacing:"0.025em",resize:"none",fontSize:"16px",outline:"none"},inputFooter:{display:"flex",flexDirection:"column",justifyContent:"space-between",padding:"5px"},sendButton:{background:"transparent",border:"0px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"#000000"},characterCount:{fontSize:"12px",color:"var(--swttyw-primary-color)",textAlign:"center"},modalOverlay:{position:"absolute",background:"#ffffffe8",height:"calc(100% - 85px)",width:"100%",top:"48px",display:"flex",justifyContent:"center",alignItems:"center"},modalBody:{textAlign:"center"},modalActions:{display:"flex",justifyContent:"center"},footer:{flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--swttyw-primary-color)",borderRadius:"0 0 10px 10px",paddingBottom:"6px",paddingTop:"6px",marginTop:"0px",color:"#f8f9fa",fontSize:"var(--swttyw-footer-font-size)",borderTop:"3px solid var(--swttyw-primary-color)",padding:"15px 0px",fontFamily:"'Inter', sans-serif"},message:{boxSizing:"border-box",padding:"0.5rem 1rem",margin:"1rem",background:"#FFF",borderRadius:"1.125rem 1.125rem 1.125rem 0",minHeight:"2.25rem",width:"fit-content",boxShadow:"0 0 2rem rgba(0, 0, 0, 0.075), 0rem 1rem 1rem -1rem rgba(0, 0, 0, 0.1)",fontSize:"15px",wordBreak:"break-word",fontFamily:"'Inter', sans-serif",display:"table",alignItems:"flex-start",gap:"8px",position:"relative"},messageSelf:{margin:"1rem 1rem 1rem auto",borderRadius:"1.125rem 1.125rem 0 1.125rem",background:"#000000",color:"white",position:"relative",maxWidth:"80%",fontSize:"var(--swttyw-body-font-size)",flexDirection:"row-reverse"},messageOther:{position:"relative",fontSize:"var(--swttyw-body-font-size)"},messageAvatar:{width:"24px",height:"24px",borderRadius:"50%",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:"bold",position:"absolute",top:"5px"},messageContent:{flex:1,marginLeft:"32px",marginRight:"8px"},minimizedContent:{display:"flex",alignItems:"center",gap:"12px",color:"white",flex:1},chatIcon:{width:"20px",height:"20px",flexShrink:0},minimizedTitle:{color:"white",fontSize:"16px",fontWeight:"500",margin:0}},Ie=`@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap');\r
|
|
23
23
|
\r
|
|
24
24
|
.sw-ttyw-chatbot {\r
|
|
25
25
|
--swttyw-primary-color: #000;\r
|