lulichat 1.0.7 → 1.0.8
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/lulichat-support.es.js +1156 -890
- package/dist/lulichat-support.umd.js +11 -10
- package/dist/style.css +1 -1
- package/dist/types/index.d.ts +94 -12
- package/package.json +4 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(a,A){typeof exports=="object"&&typeof module<"u"?module.exports=A(require("react"),require("socket.io-client"),require("marked"),require("dompurify")):typeof define=="function"&&define.amd?define(["react","socket.io-client","marked","dompurify"],A):(a=typeof globalThis<"u"?globalThis:a||self,a.LulichatSupport=A(a.React,a.openSocket,a.marked,a.DOMPurify))})(this,function(a,A,Y,Xe){"use strict";var Vt=Object.defineProperty;var Ht=(a,A,Y)=>A in a?Vt(a,A,{enumerable:!0,configurable:!0,writable:!0,value:Y}):a[A]=Y;var $=(a,A,Y)=>Ht(a,typeof A!="symbol"?A+"":A,Y);var de={exports:{}},X={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var je;function Qe(){if(je)return X;je=1;var n=a,s=Symbol.for("react.element"),o=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,c=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function m(h,d,b){var p,E={},g=null,T=null;b!==void 0&&(g=""+b),d.key!==void 0&&(g=""+d.key),d.ref!==void 0&&(T=d.ref);for(p in d)l.call(d,p)&&!u.hasOwnProperty(p)&&(E[p]=d[p]);if(h&&h.defaultProps)for(p in d=h.defaultProps,d)E[p]===void 0&&(E[p]=d[p]);return{$$typeof:s,type:h,key:g,ref:T,props:E,_owner:c.current}}return X.Fragment=o,X.jsx=m,X.jsxs=m,X}var Q={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,17 +14,18 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
18
|
-
`+
|
|
19
|
-
`),
|
|
20
|
-
`),
|
|
21
|
-
`+
|
|
17
|
+
*/var ke;function et(){return ke||(ke=1,process.env.NODE_ENV!=="production"&&function(){var n=a,s=Symbol.for("react.element"),o=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),c=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),m=Symbol.for("react.provider"),h=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),b=Symbol.for("react.suspense"),p=Symbol.for("react.suspense_list"),E=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),T=Symbol.for("react.offscreen"),_=Symbol.iterator,w="@@iterator";function S(e){if(e===null||typeof e!="object")return null;var r=_&&e[_]||e[w];return typeof r=="function"?r:null}var N=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function j(e){{for(var r=arguments.length,i=new Array(r>1?r-1:0),f=1;f<r;f++)i[f-1]=arguments[f];te("error",e,i)}}function te(e,r,i){{var f=N.ReactDebugCurrentFrame,k=f.getStackAddendum();k!==""&&(r+="%s",i=i.concat([k]));var C=i.map(function(x){return String(x)});C.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,C)}}var R=!1,B=!1,G=!1,z=!1,y=!1,I;I=Symbol.for("react.module.reference");function D(e){return!!(typeof e=="string"||typeof e=="function"||e===l||e===u||y||e===c||e===b||e===p||z||e===T||R||B||G||typeof e=="object"&&e!==null&&(e.$$typeof===g||e.$$typeof===E||e.$$typeof===m||e.$$typeof===h||e.$$typeof===d||e.$$typeof===I||e.getModuleId!==void 0))}function W(e,r,i){var f=e.displayName;if(f)return f;var k=r.displayName||r.name||"";return k!==""?i+"("+k+")":i}function oe(e){return e.displayName||"Context"}function L(e){if(e==null)return null;if(typeof e.tag=="number"&&j("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case l:return"Fragment";case o:return"Portal";case u:return"Profiler";case c:return"StrictMode";case b:return"Suspense";case p:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case h:var r=e;return oe(r)+".Consumer";case m:var i=e;return oe(i._context)+".Provider";case d:return W(e,e.render,"ForwardRef");case E:var f=e.displayName||null;return f!==null?f:L(e.type)||"Memo";case g:{var k=e,C=k._payload,x=k._init;try{return L(x(C))}catch{return null}}}return null}var V=Object.assign,re=0,Ne,Oe,Me,De,Re,Ie,Le;function Fe(){}Fe.__reactDisabledLog=!0;function vt(){{if(re===0){Ne=console.log,Oe=console.info,Me=console.warn,De=console.error,Re=console.group,Ie=console.groupCollapsed,Le=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Fe,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}re++}}function yt(){{if(re--,re===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:V({},e,{value:Ne}),info:V({},e,{value:Oe}),warn:V({},e,{value:Me}),error:V({},e,{value:De}),group:V({},e,{value:Re}),groupCollapsed:V({},e,{value:Ie}),groupEnd:V({},e,{value:Le})})}re<0&&j("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var he=N.ReactCurrentDispatcher,me;function ie(e,r,i){{if(me===void 0)try{throw Error()}catch(k){var f=k.stack.trim().match(/\n( *(at )?)/);me=f&&f[1]||""}return`
|
|
18
|
+
`+me+e}}var ge=!1,le;{var xt=typeof WeakMap=="function"?WeakMap:Map;le=new xt}function Pe(e,r){if(!e||ge)return"";{var i=le.get(e);if(i!==void 0)return i}var f;ge=!0;var k=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var C;C=he.current,he.current=null,vt();try{if(r){var x=function(){throw Error()};if(Object.defineProperty(x.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(x,[])}catch(P){f=P}Reflect.construct(e,[],x)}else{try{x.call()}catch(P){f=P}e.call(x.prototype)}}else{try{throw Error()}catch(P){f=P}e()}}catch(P){if(P&&f&&typeof P.stack=="string"){for(var v=P.stack.split(`
|
|
19
|
+
`),F=f.stack.split(`
|
|
20
|
+
`),O=v.length-1,M=F.length-1;O>=1&&M>=0&&v[O]!==F[M];)M--;for(;O>=1&&M>=0;O--,M--)if(v[O]!==F[M]){if(O!==1||M!==1)do if(O--,M--,M<0||v[O]!==F[M]){var q=`
|
|
21
|
+
`+v[O].replace(" at new "," at ");return e.displayName&&q.includes("<anonymous>")&&(q=q.replace("<anonymous>",e.displayName)),typeof e=="function"&&le.set(e,q),q}while(O>=1&&M>=0);break}}}finally{ge=!1,he.current=C,yt(),Error.prepareStackTrace=k}var Z=e?e.displayName||e.name:"",H=Z?ie(Z):"";return typeof e=="function"&&le.set(e,H),H}function bt(e,r,i){return Pe(e,!1)}function jt(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function ce(e,r,i){if(e==null)return"";if(typeof e=="function")return Pe(e,jt(e));if(typeof e=="string")return ie(e);switch(e){case b:return ie("Suspense");case p:return ie("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case d:return bt(e.render);case E:return ce(e.type,r,i);case g:{var f=e,k=f._payload,C=f._init;try{return ce(C(k),r,i)}catch{}}}return""}var se=Object.prototype.hasOwnProperty,Ae={},qe=N.ReactDebugCurrentFrame;function ue(e){if(e){var r=e._owner,i=ce(e.type,e._source,r?r.type:null);qe.setExtraStackFrame(i)}else qe.setExtraStackFrame(null)}function kt(e,r,i,f,k){{var C=Function.call.bind(se);for(var x in e)if(C(e,x)){var v=void 0;try{if(typeof e[x]!="function"){var F=Error((f||"React class")+": "+i+" type `"+x+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[x]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw F.name="Invariant Violation",F}v=e[x](r,x,f,i,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(O){v=O}v&&!(v instanceof Error)&&(ue(k),j("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",f||"React class",i,x,typeof v),ue(null)),v instanceof Error&&!(v.message in Ae)&&(Ae[v.message]=!0,ue(k),j("Failed %s type: %s",i,v.message),ue(null))}}}var wt=Array.isArray;function pe(e){return wt(e)}function Ct(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,i=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return i}}function Et(e){try{return $e(e),!1}catch{return!0}}function $e(e){return""+e}function We(e){if(Et(e))return j("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ct(e)),$e(e)}var Be=N.ReactCurrentOwner,St={key:!0,ref:!0,__self:!0,__source:!0},ze,Ve;function _t(e){if(se.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function Tt(e){if(se.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function Nt(e,r){typeof e.ref=="string"&&Be.current}function Ot(e,r){{var i=function(){ze||(ze=!0,j("%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://reactjs.org/link/special-props)",r))};i.isReactWarning=!0,Object.defineProperty(e,"key",{get:i,configurable:!0})}}function Mt(e,r){{var i=function(){Ve||(Ve=!0,j("%s: `ref` 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://reactjs.org/link/special-props)",r))};i.isReactWarning=!0,Object.defineProperty(e,"ref",{get:i,configurable:!0})}}var Dt=function(e,r,i,f,k,C,x){var v={$$typeof:s,type:e,key:r,ref:i,props:x,_owner:C};return v._store={},Object.defineProperty(v._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(v,"_self",{configurable:!1,enumerable:!1,writable:!1,value:f}),Object.defineProperty(v,"_source",{configurable:!1,enumerable:!1,writable:!1,value:k}),Object.freeze&&(Object.freeze(v.props),Object.freeze(v)),v};function Rt(e,r,i,f,k){{var C,x={},v=null,F=null;i!==void 0&&(We(i),v=""+i),Tt(r)&&(We(r.key),v=""+r.key),_t(r)&&(F=r.ref,Nt(r,k));for(C in r)se.call(r,C)&&!St.hasOwnProperty(C)&&(x[C]=r[C]);if(e&&e.defaultProps){var O=e.defaultProps;for(C in O)x[C]===void 0&&(x[C]=O[C])}if(v||F){var M=typeof e=="function"?e.displayName||e.name||"Unknown":e;v&&Ot(x,M),F&&Mt(x,M)}return Dt(e,v,F,k,f,Be.current,x)}}var ve=N.ReactCurrentOwner,He=N.ReactDebugCurrentFrame;function J(e){if(e){var r=e._owner,i=ce(e.type,e._source,r?r.type:null);He.setExtraStackFrame(i)}else He.setExtraStackFrame(null)}var ye;ye=!1;function xe(e){return typeof e=="object"&&e!==null&&e.$$typeof===s}function Ye(){{if(ve.current){var e=L(ve.current.type);if(e)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+e+"`."}return""}}function
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function It(e){return""}var Ue={};function Lt(e){{var r=Ye();if(!r){var i=typeof e=="string"?e:e.displayName||e.name;i&&(r=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+
|
|
25
|
+
Check the top-level render call using <`+i+">.")}return r}}function Ke(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var i=Lt(r);if(Ue[i])return;Ue[i]=!0;var f="";e&&e._owner&&e._owner!==ve.current&&(f=" It was passed a child from "+L(e._owner.type)+"."),J(e),j('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',i,f),J(null)}}function Ge(e,r){{if(typeof e!="object")return;if(pe(e))for(var i=0;i<e.length;i++){var f=e[i];xe(f)&&Ke(f,r)}else if(xe(e))e._store&&(e._store.validated=!0);else if(e){var k=S(e);if(typeof k=="function"&&k!==e.entries)for(var C=k.call(e),x;!(x=C.next()).done;)xe(x.value)&&Ke(x.value,r)}}}function Ft(e){{var r=e.type;if(r==null||typeof r=="string")return;var i;if(typeof r=="function")i=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===d||r.$$typeof===E))i=r.propTypes;else return;if(i){var f=L(r);kt(i,e.props,"prop",f,e)}else if(r.PropTypes!==void 0&&!ye){ye=!0;var k=L(r);j("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",k||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&j("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Pt(e){{for(var r=Object.keys(e.props),i=0;i<r.length;i++){var f=r[i];if(f!=="children"&&f!=="key"){J(e),j("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",f),J(null);break}}e.ref!==null&&(J(e),j("Invalid attribute `ref` supplied to `React.Fragment`."),J(null))}}var Je={};function Ze(e,r,i,f,k,C){{var x=D(e);if(!x){var v="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(v+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var F=It();F?v+=F:v+=Ye();var O;e===null?O="null":pe(e)?O="array":e!==void 0&&e.$$typeof===s?(O="<"+(L(e.type)||"Unknown")+" />",v=" Did you accidentally export a JSX literal instead of a component?"):O=typeof e,j("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",O,v)}var M=Rt(e,r,i,k,C);if(M==null)return M;if(x){var q=r.children;if(q!==void 0)if(f)if(pe(q)){for(var Z=0;Z<q.length;Z++)Ge(q[Z],e);Object.freeze&&Object.freeze(q)}else j("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 Ge(q,e)}if(se.call(r,"key")){var H=L(e),P=Object.keys(r).filter(function(zt){return zt!=="key"}),be=P.length>0?"{key: someKey, "+P.join(": ..., ")+": ...}":"{key: someKey}";if(!Je[H+be]){var Bt=P.length>0?"{"+P.join(": ..., ")+": ...}":"{}";j(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,le,V,Pt,V),$e[V+le]=!0}}return e===l?Nt(E):_t(E),E}}function Rt(e,r,n){return We(e,r,n,!0)}function Tt(e,r,n){return We(e,r,n,!1)}var Ot=Tt,Dt=Rt;H.Fragment=l,H.jsx=Ot,H.jsxs=Dt}()),H}process.env.NODE_ENV==="production"?M.exports=ze():M.exports=Ve();var t=M.exports;class Be{constructor(o){F(this,"config");F(this,"baseUrl");this.config=o,this.baseUrl=o.baseUrl||"http://localhost:8000"}async getCompanyInfo(){try{const o=await fetch(`${this.baseUrl}/companies/e/info`,{headers:{Authorization:`Bearer ${this.config.apiKey}`,"Content-Type":"application/json"}});if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);return await o.json()}catch(o){throw console.error("Failed to fetch company info:",o),o}}async submitContactInfo(o){try{const u=await fetch(`${this.baseUrl}/companies/e/chat/init`,{method:"POST",headers:{Authorization:`Bearer ${this.config.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify(o||{})});if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return await u.json()}catch(u){throw console.error("Failed to submit contact info:",u),u}}async startAnonymousChat(){return this.submitContactInfo()}}function fe(...s){return R.clsx(s)}const G=i.forwardRef((s,o)=>t.jsx("input",{...s,autoComplete:s.autoComplete||s.name||"off",ref:o,className:fe("lulichat-input",s.className)}));i.forwardRef((s,o)=>t.jsx("input",{className:"",...s,ref:o}));const de=i.createContext(void 0),B=i.forwardRef(({children:s,onValuesChange:o,initialValues:u,...l},p)=>{const h=i.useRef(u||{}),b=i.useRef(null),j=i.useCallback((m,g)=>{h.current[m]=g,o&&o({...h.current})},[o]),f={getValues:()=>h.current,getFieldValue:m=>{var g;return(g=h.current)==null?void 0:g[m]},elementRef:()=>b.current,setFieldValue:j};return i.useImperativeHandle(p,()=>f),t.jsx(de.Provider,{value:f,children:t.jsx("form",{...l,ref:b,onSubmit:l.onSubmit,children:s})})}),Ye=i.forwardRef(({name:s,children:o,...u},l)=>{const p=i.useContext(de),h=function(f){var m,g;p&&s&&p.setFieldValue(s,f.target.value),(g=(m=this.props).onChange)==null||g.call(m,f)},b=i.Children.map(o,f=>{if(i.isValidElement(f)&&s&&f.type===G){let m=f;return i.cloneElement(m,{...m.props,name:s,value:(p==null?void 0:p.getFieldValue(s))??"",onChange:h.bind(m),required:u.required})}return f}),j=Object.create(u);return delete j.required,delete j.label,t.jsxs("div",{className:"lulichat-form-item",ref:l,...j,children:[u.label&&t.jsx(he,{htmlFor:s,required:u.required,children:u.label}),b,u.error&&t.jsx("p",{className:"error",children:u.error})]})}),he=i.forwardRef((s,o)=>{const u=s.required,l=s.children;return t.jsxs("label",{...s,className:fe("lulichat-form-label",s.className),ref:o,children:[l,u&&t.jsx("b",{style:{color:"red"},children:"*"})]})}),qe=s=>{const o=i.useRef(s||{}),u=i.useRef(null),l=i.useCallback((h,b)=>{o.current[h]=b},[]);return[{getValues:()=>o.current,getFieldValue:h=>{var b;return(b=o.current)==null?void 0:b[h]},elementRef:()=>u.current,setFieldValue:l}]};B.Item=Ye,B.Label=he,B.useForm=qe;const Ue=s=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 18 18",...s,children:t.jsx("path",{fill:"none",stroke:"currentColor",strokeDasharray:"10",strokeDashoffset:"10",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 15l-5 -5M12 15l5 -5",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"0.3s",values:"10;0"})})}),He=s=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",...s,children:[t.jsx("mask",{id:"lineMdFileDocumentFilled0",children:t.jsxs("g",{fill:"none",stroke:"#fff",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[t.jsxs("path",{fill:"#fff",fillOpacity:"0",strokeDasharray:"64",strokeDashoffset:"64",d:"M13.5 3l5.5 5.5v11.5c0 0.55 -0.45 1 -1 1h-12c-0.55 0 -1 -0.45 -1 -1v-16c0 -0.55 0.45 -1 1 -1Z",children:[t.jsx("animate",{fill:"freeze",attributeName:"fill-opacity",begin:"0.6s",dur:"0.5s",values:"0;1"}),t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"0.6s",values:"64;0"})]}),t.jsx("path",{fill:"#000",stroke:"#000",d:"M14.5 3.5l0 4.5l4.5 0z",opacity:"0",children:t.jsx("set",{fill:"freeze",attributeName:"opacity",begin:"0.6s",to:"1"})}),t.jsx("path",{d:"M13.5 3l5.5 5.5",opacity:"0",children:t.jsx("set",{fill:"freeze",attributeName:"opacity",begin:"0.6s",to:"1"})}),t.jsx("path",{stroke:"#000",strokeDasharray:"12",strokeDashoffset:"12",d:"M7 13h10",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"1.1s",dur:"0.2s",values:"12;0"})}),t.jsx("path",{stroke:"#000",strokeDasharray:"8",strokeDashoffset:"8",d:"M7 17h7",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"1.3s",dur:"0.2s",values:"8;0"})})]})}),t.jsx("rect",{width:"24",height:"24",fill:"currentColor",mask:"url(#lineMdFileDocumentFilled0)"})]}),Je=s=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 22 22",...s,children:t.jsx("path",{fill:"currentColor",d:"M1.5 4v1.5c0 4.15 2.21 7.78 5.5 9.8V20h15v-2c0-2.66-5.33-4-8-4h-.25C9 14 5 10 5 5.5V4m9 0a4 4 0 0 0-4 4a4 4 0 0 0 4 4a4 4 0 0 0 4-4a4 4 0 0 0-4-4"})}),Ke=s=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",...s,children:t.jsx("path",{fill:"currentColor",d:"M12 2.25A9.75 9.75 0 0 0 2.25 12v5q0 .04.004.08v.05c-.003 1.278.602 2.682 1.963 3.25l.071.03c.11.044.22.12.362.25c.07.064.138.132.22.213l.008.008c.08.08.175.175.277.265c.204.183.474.388.83.506c.37.122.77.131 1.208.022c.723-.18 1.266-.752 1.469-1.454c.089-.309.089-.668.088-1.084v-4.094c0-.285 0-.528-.01-.728a2.3 2.3 0 0 0-.107-.627c-.23-.683-.786-1.223-1.504-1.377a2.25 2.25 0 0 0-1.264.065c-.37.133-.652.354-.87.558c-.12.11-.269.267-.391.396l-.164.17a1.8 1.8 0 0 1-.427.338q-.136.07-.263.152V12a8.25 8.25 0 1 1 16.5 0v1.864a3 3 0 0 0-.538-.274a1.2 1.2 0 0 1-.362-.25c-.07-.064-.138-.132-.22-.213l-.008-.008a7 7 0 0 0-.277-.265a2.4 2.4 0 0 0-.83-.506q-.553-.184-1.208-.022c-.723.18-1.266.752-1.469 1.454c-.089.309-.088.668-.088 1.085v4.093c0 .285 0 .528.01.728c.012.208.037.418.107.627c.23.683.786 1.223 1.504 1.377c.463.1.883.073 1.264-.065c.37-.133.652-.354.87-.558c.12-.11.269-.267.391-.395c.065-.069.123-.13.164-.17a1.8 1.8 0 0 1 .427-.34c1.11-.573 1.755-1.724 1.758-2.936v-.143L21.75 17v-5A9.75 9.75 0 0 0 12 2.25"})}),Ge=s=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",...s,children:t.jsxs("g",{fill:"none",stroke:"currentColor",strokeDasharray:"28",strokeDashoffset:"28",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[t.jsx("path",{d:"M4 21v-1c0 -3.31 2.69 -6 6 -6h4c3.31 0 6 2.69 6 6v1",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"0.4s",values:"28;0"})}),t.jsx("path",{d:"M12 11c-2.21 0 -4 -1.79 -4 -4c0 -2.21 1.79 -4 4 -4c2.21 0 4 1.79 4 4c0 2.21 -1.79 4 -4 4Z",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"0.4s",dur:"0.4s",values:"28;0"})})]})}),me=()=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",children:t.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11zm7.318-19.539l-10.94 10.939"})}),ve=s=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",...s,children:t.jsxs("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[t.jsxs("path",{strokeDasharray:"16",strokeDashoffset:"16",d:"M12 3c4.97 0 9 4.03 9 9",children:[t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"0.3s",values:"16;0"}),t.jsx("animateTransform",{attributeName:"transform",dur:"1.5s",repeatCount:"indefinite",type:"rotate",values:"0 12 12;360 12 12"})]}),t.jsx("path",{strokeDasharray:"64",strokeDashoffset:"64",strokeOpacity:"0.3",d:"M12 3c4.97 0 9 4.03 9 9c0 4.97 -4.03 9 -9 9c-4.97 0 -9 -4.03 -9 -9c0 -4.97 4.03 -9 9 -9Z",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"1.2s",values:"64;0"})})]})}),Ze=s=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",...s,children:[t.jsxs("mask",{id:"lineMdChatRoundDotsFilled0",children:[t.jsxs("path",{fill:"#fff",fillOpacity:"0",d:"M5 15.5c1 1 2.5 2 4 2.5c-0.71 -0.24 -1.43 -0.59 -2.09 -1c-0.72 -0.45 -1.39 -0.98 -1.91 -1.5Z",children:[t.jsx("animate",{fill:"freeze",attributeName:"d",begin:"0.6s",dur:"0.2s",values:"M5 15.5c1 1 2.5 2 4 2.5c-0.71 -0.24 -1.43 -0.59 -2.09 -1c-0.72 -0.45 -1.39 -0.98 -1.91 -1.5Z;M5 15.5c1 1 2.5 2 4 2.5c-2 2 -5 3 -7 3c2 -2 3 -3.5 3 -5.5Z"}),t.jsx("set",{fill:"freeze",attributeName:"fill-opacity",begin:"0.6s",to:"1"})]}),t.jsxs("g",{fill:"none",stroke:"#fff",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[t.jsxs("path",{fill:"transparent",fillOpacity:"0",strokeDasharray:"56",strokeDashoffset:"56",d:"M7 16.82c-2.41 -1.25 -4 -3.39 -4 -5.82c0 -3.87 4.03 -7 9 -7c4.97 0 9 3.13 9 7c0 3.87 -4.03 7 -9 7c-1.85 0 -3.57 -0.43 -5 -1.18Z",children:[t.jsx("animate",{fill:"freeze",attributeName:"fill-opacity",begin:"0.9s",dur:"0.5s",values:"0;1"}),t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"0.6s",values:"56;0"})]}),t.jsx("path",{stroke:"currentColor",strokeDasharray:"2",strokeDashoffset:"2",d:"M8 11h0.01",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"1.4s",dur:"0.2s",values:"2;0"})}),t.jsx("path",{stroke:"currentColor",strokeDasharray:"2",strokeDashoffset:"2",d:"M12 11h0.01",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"1.7s",dur:"0.2s",values:"2;0"})}),t.jsx("path",{stroke:"currentColor",strokeDasharray:"2",strokeDashoffset:"2",d:"M16 11h0.01",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"2s",dur:"0.2s",values:"2;0"})})]})]}),t.jsx("rect",{width:"24",height:"24",fill:"currentColor",mask:"url(#lineMdChatRoundDotsFilled0)"})]}),$=i.forwardRef(({className:s,variant:o="outline",size:u="md",shape:l="rounded",...p},h)=>t.jsx("button",{className:R("lulichat-btn",`lulichat-btn-${o}`,`lulichat-btn-${u}`,`lulichat-btn-${l}`,s),ref:h,...p}));$.displayName="Button";const Xe=({companyName:s,onSubmit:o,onSkip:u,allowAnonymous:l,isLoading:p})=>{const[h,b]=i.useState(!1),[j,f]=i.useState({name:"",email:"",phone:"",company:""}),[m,g]=i.useState({}),[S,_]=i.useState({email:"",name:""}),O=()=>{const w={};return j.name.trim()||(w.name="Name is required"),j.email.trim()?/\S+@\S+\.\S+/.test(j.email)||(w.email="Email is invalid"):w.email="Email is required",g(w),Object.keys(w).length===0},A=w=>{w.preventDefault(),O()&&o(j)},I=(w,D)=>{f(a=>({...a,[w]:D})),m[w]&&g(a=>({...a,[w]:void 0}))};return t.jsxs(B,{autoComplete:"off",onSubmit:A,onValuesChange:_,className:"lulichat-contact-form",children:[t.jsxs("div",{className:"lulichat-form-header",children:[t.jsxs("div",{style:{marginBottom:"20px",display:"flex",alignItems:"end",columnGap:8},children:[t.jsx(Je,{style:{display:"block"},color:"#DEDEDE6A",height:40,width:50}),t.jsx("h3",{style:{fontWeight:500},children:"Hello,"})]}),t.jsxs("h3",{style:{marginBottom:8},className:"lulichat-title",children:["Welcome to ",s," Live Chat"]}),t.jsxs("p",{role:"button",onClickCapture:()=>b(!h),style:{textDecoration:"underline",lineHeight:"1rem",cursor:"pointer"},children:["Please provide your details for a better support experience"," ",t.jsx(Ue,{style:{display:"inline-block",marginBottom:-2},height:20,width:20})]})]}),t.jsxs("div",{className:`lulichat-form-group${h?" open":""}`,children:[t.jsx(B.Item,{error:m.name,label:"Name (Optional)",name:"name",children:t.jsx(G,{id:"name",placeholder:"Enter your name",type:"text",value:j.name,onChange:w=>I("name",w.target.value),className:"transparent"+(m.name?" error":"")})}),t.jsx(B.Item,{name:"email",error:m.email,label:"Email",children:t.jsx(G,{id:"email",type:"email",placeholder:"Enter your valid email",value:j.email,onChange:w=>I("email",w.target.value),className:"transparent"+(m.name?" error":"")})}),t.jsx($,{type:"submit",disabled:p||!S.email,style:{width:"100%",marginTop:10},className:"lulichat-contact-form-btn",children:p?t.jsxs(t.Fragment,{children:[t.jsx(ve,{}),"Submitting..."]}):"Submit"})]})]})};class Qe{constructor(o,u,l="wss://ws.lulichat.com"){F(this,"socket",null);F(this,"token");F(this,"sessionId");F(this,"onMessageCallback");F(this,"onStatusCallback");F(this,"reconnectAttempts",0);F(this,"maxReconnectAttempts",5);this.token=o,this.sessionId=u,this.connect(l)}connect(o){var u;try{this.socket=new WebSocket(`${o}/chat?token=${this.token}&session=${this.sessionId}`),this.socket.onopen=()=>{var l;console.log("Socket connected"),this.reconnectAttempts=0,(l=this.onStatusCallback)==null||l.call(this,"connected")},this.socket.onmessage=l=>{var p;try{const h=JSON.parse(l.data);(p=this.onMessageCallback)==null||p.call(this,h)}catch(h){console.error("Failed to parse message:",h)}},this.socket.onclose=()=>{var l;console.log("Socket disconnected"),(l=this.onStatusCallback)==null||l.call(this,"disconnected"),this.handleReconnect(o)},this.socket.onerror=l=>{var p;console.error("Socket error:",l),(p=this.onStatusCallback)==null||p.call(this,"error")}}catch(l){console.error("Failed to connect socket:",l),(u=this.onStatusCallback)==null||u.call(this,"error")}}handleReconnect(o){this.reconnectAttempts<this.maxReconnectAttempts&&(this.reconnectAttempts++,setTimeout(()=>{console.log(`Reconnecting... attempt ${this.reconnectAttempts}`),this.connect(o)},2e3*this.reconnectAttempts))}sendMessage(o){var u;if(((u=this.socket)==null?void 0:u.readyState)===WebSocket.OPEN){const l={type:"message",content:o,timestamp:new Date().toISOString()};this.socket.send(JSON.stringify(l))}}onMessage(o){this.onMessageCallback=o}onStatus(o){this.onStatusCallback=o}disconnect(){this.socket&&(this.socket.close(),this.socket=null)}}const et=({session:s,companyInfo:o,onClose:u})=>{const[l,p]=i.useState([]),[h,b]=i.useState(""),[j,f]=i.useState(!1),[m,g]=i.useState("disconnected"),S=i.useRef(null),_=i.useRef(null);i.useEffect(()=>(_.current=new Qe(s.token,s.id),_.current.onMessage(k=>{p(W=>[...W,k]),f(!1)}),_.current.onStatus(k=>{g(k)}),p([{id:"welcome",content:"",timestamp:new Date,sender:"system"}]),()=>{var k;(k=_.current)==null||k.disconnect()}),[s,o]),i.useEffect(()=>{O()},[l]);const O=()=>{var a;(a=S.current)==null||a.scrollIntoView({behavior:"smooth"})},A=()=>{var k;if(!h.trim()||m!=="connected")return;const a={id:Date.now().toString(),content:h,timestamp:new Date,sender:"user"};p(W=>[...W,a]),(k=_.current)==null||k.sendMessage(h),b(""),f(!0)},I=a=>{a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),A())},w=a=>new Intl.DateTimeFormat("en-US",{hour:"2-digit",minute:"2-digit"}).format(a),D=a=>{switch(a){case"agent":return t.jsx(Ke,{className:"w-4 h-4"});case"user":return t.jsx(Ge,{className:"w-4 h-4"});default:return null}};return t.jsxs("div",{className:"flex flex-col h-full",children:[t.jsxs("div",{className:"bg-primary text-primary-foreground p-4 rounded-t-lg",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("div",{className:"w-2 h-2 rounded-full bg-green-400"}),t.jsx("span",{className:"font-medium",children:o.name})]}),t.jsx($,{variant:"ghost",size:"sm",onClick:u,className:"text-primary-foreground hover:bg-primary-foreground/20",children:"×"})]}),t.jsx("div",{className:"text-xs opacity-80 mt-1",children:m==="connected"?"Online":"Connecting..."})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 bg-background",children:[l.map(a=>t.jsx("div",{className:`flex ${a.sender==="user"?"justify-end":"justify-start"}`,children:t.jsxs("div",{className:`max-w-xs lg:max-w-md px-4 py-2 rounded-lg ${a.sender==="user"?"bg-primary text-primary-foreground":a.sender==="system"?"bg-muted text-muted-foreground text-center":"bg-muted text-foreground"}`,children:[a.sender!=="system"&&t.jsxs("div",{className:"flex items-center space-x-1 mb-1",children:[D(a.sender),t.jsx("span",{className:"text-xs opacity-70",children:a.senderName||(a.sender==="user"?"You":"Support")})]}),t.jsx("p",{className:"text-sm",children:a.content}),t.jsx("p",{className:"text-xs opacity-60 mt-1",children:w(a.timestamp)})]})},a.id)),j&&t.jsx("div",{className:"flex justify-start",children:t.jsx("div",{className:"bg-muted text-foreground px-4 py-2 rounded-lg",children:t.jsxs("div",{className:"flex space-x-1",children:[t.jsx("div",{className:"w-2 h-2 bg-current rounded-full animate-bounce"}),t.jsx("div",{className:"w-2 h-2 bg-current rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),t.jsx("div",{className:"w-2 h-2 bg-current rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})})}),t.jsx("div",{ref:S})]}),t.jsxs("div",{className:"p-4 border-t bg-background",children:[t.jsxs("div",{className:"flex space-x-2",children:[t.jsx("input",{value:h,onChange:a=>b(a.target.value),onKeyPress:I,placeholder:"Type your message...",disabled:m!=="connected",className:"flex-1"}),t.jsx($,{onClick:A,disabled:!h.trim()||m!=="connected",size:"icon",children:t.jsx(me,{className:"w-4 h-4"})})]}),m!=="connected"&&t.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:m==="error"?"Connection error. Retrying...":"Connecting..."})]})]})},tt=({config:s})=>{const[o,u]=i.useState("contact-form"),[l,p]=i.useState(null),[h,b]=i.useState(null),[j,f]=i.useState(!1),[m,g]=i.useState(null),[S,_]=i.useState(!1),O=new Be(s);i.useEffect(()=>{A()},[s]);const A=async()=>{try{const a=await O.getCompanyInfo();p(a.data)}catch(a){g("Failed to load chat configuration"),console.error("Failed to load company info:",a)}},I=async a=>{f(!0);try{const k=await O.submitContactInfo(a),W={id:k.sessionId,token:k.token,isActive:!0};b(W),u("chat")}catch(k){g("Failed to start chat. Please try again."),console.error("Failed to submit contact info:",k)}finally{f(!1)}},w=async()=>{f(!0);try{const a=await O.startAnonymousChat(),k={id:a.sessionId,token:a.token,isActive:!0};b(k),u("chat")}catch(a){g("Failed to start chat. Please try again."),console.error("Failed to start anonymous chat:",a)}finally{f(!1)}},D=()=>{u("closed"),b(null),g(null)};return console.log({companyInfo:l}),t.jsxs("div",{className:`lulichat lulichat-${s.position}`,children:[S&&t.jsxs("div",{className:"lulichat-main",children:[m&&t.jsxs("div",{className:"p-4 bg-destructive/10 border-b",children:[t.jsx("p",{className:"text-sm text-destructive",children:m}),t.jsx("button",{onClick:()=>g(null),className:"mt-2",children:"Retry"})]}),t.jsx(Xe,{companyName:l==null?void 0:l.name,onSubmit:I,onSkip:s.allowAnonymous?w:void 0,allowAnonymous:s.allowAnonymous||!1,isLoading:j}),t.jsxs("div",{style:{padding:16},children:[t.jsx("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:l==null?void 0:l.queues.map(a=>{var k;return t.jsx("div",{className:"lulichat-tag",children:(k=a.name)==null?void 0:k.toLocaleLowerCase()},a.id)})}),t.jsx("div",{style:{height:2,backgroundColor:"hsl(var(--border))",marginBlock:16}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",columnGap:10},className:"form-control",children:[t.jsx(G,{name:"message",autoComplete:"off",style:{border:"none",paddingInline:0},placeholder:"What can we help you with ?."}),t.jsxs("div",{className:"lulichat-btn-group",children:[t.jsx($,{style:{color:"#00000080"},size:"icon",children:t.jsx(He,{height:24})}),t.jsx($,{style:{color:"#00000080"},size:"icon",children:t.jsx(me,{})})]})]})]}),o==="chat"&&h&&l&&t.jsx(et,{session:h,companyInfo:l,onClose:D})]}),t.jsx($,{onClick:()=>_(!S),className:"",shape:"circle",size:"icon",style:{backgroundColor:s.primaryColor,height:"4rem",width:"4rem",padding:0,color:"#fff",alignSelf:"end"},disabled:!l&&!m,children:!l&&!m?t.jsx(ve,{}):t.jsx(Ze,{height:40,width:40})})]})};return({apiKey:s,baseUrl:o,position:u="bottom-right",primaryColor:l="#007bff",companyName:p="Support",welcomeMessage:h="Hello! How can we help you today?",requireContactInfo:b=!0,allowAnonymous:j=!0})=>{const f={apiKey:s,baseUrl:o,position:u,primaryColor:l,companyName:p,welcomeMessage:h,requireContactInfo:b,allowAnonymous:j};return s?t.jsx(tt,{config:f}):(console.error("LuliChat: API key is required"),null)}});
|
|
30
|
+
<%s key={someKey} {...props} />`,be,H,Bt,H),Je[H+be]=!0}}return e===l?Pt(M):Ft(M),M}}function At(e,r,i){return Ze(e,r,i,!0)}function qt(e,r,i){return Ze(e,r,i,!1)}var $t=qt,Wt=At;Q.Fragment=l,Q.jsx=$t,Q.jsxs=Wt}()),Q}process.env.NODE_ENV==="production"?de.exports=Qe():de.exports=et();var t=de.exports;class tt{constructor(s){$(this,"config");$(this,"baseUrl");$(this,"abortControllers",{});this.config=s,this.baseUrl=s.baseUrl||"https://api.lulichat.com"}abort(s){var o;(o=this.abortControllers[s])==null||o.abort()}useRequest(){const[s,o]=a.useState(!1),[l,c]=a.useState("");let u;return{loading:s,error:l,getOptions:async h=>{try{u&&this.abort(u),u=(Math.random()*9999999999).toString(16),o(!0);const d=await this.getOptions(h,u);return o(!1),d}catch(d){c(d.message||"Error getting options")}finally{}},setLoading:o}}async request(s,o={}){const{body:l,headers:c,key:u}=o;try{const m=new AbortController;u&&(this.abortControllers[u]=m);const h=await fetch(`${this.baseUrl}${s}`,{body:l?JSON.stringify(l):void 0,method:l?"POST":"GET",headers:{Authorization:`Bearer ${this.config.apiKey}`,"Content-Type":"application/json",...c},signal:m.signal});if(!h.ok)throw new Error(`HTTP error! status: ${h.status}`);return await h.json()}catch(m){throw console.error("Failed to fetch company info:",m),m}}async getCompanyInfo(){return this.request("/companies/e/info")}async getOptions(s,o){const l=Object.keys(s).reduce((c,u)=>(c.push(`${u}=${s[u]}`),c),[]).join("&");return this.request("/queue-options/external?"+l,{key:o})}async submitContactInfo(s,o){return this.request("/help/create-ticket/external",{body:s,key:o})}async getTicketMessages(s,o=1){return this.request(`/messages/${s}/external?pageNumber=${o}`)}async getSession(s){return this.request(`/help/${s}/session`)}}function ee(...n){return n.filter(Boolean).map(s=>s==null?void 0:s.toString().trim()).join(" ")}function we(n=32){return Array.from(crypto.getRandomValues(new Uint8Array(n))).map(s=>s.toString(36)).join("").slice(0,n)}function rt(n,s){const o=new Set,l=[];for(const c of n){const u=s(c);o.has(u)||(o.add(u),l.push(c))}return l}const ne=a.forwardRef((n,s)=>t.jsx("input",{...n,autoComplete:n.autoComplete||n.name||"off",ref:s,className:ee("lulichat-input",n.className)}));a.forwardRef((n,s)=>t.jsx("input",{className:"",...n,ref:s}));const Ce=a.createContext(void 0),U=a.forwardRef(({children:n,onValuesChange:s,initialValues:o,...l},c)=>{const u=a.useRef(o||{}),m=a.useRef(null),h=a.useCallback((b,p)=>{u.current[b]=p,s&&s({...u.current})},[s]),d={getValues:()=>u.current,getFieldValue:b=>{var p;return(p=u.current)==null?void 0:p[b]},elementRef:()=>m.current,setFieldValue:h};return a.useImperativeHandle(c,()=>d),t.jsx(Ce.Provider,{value:d,children:t.jsx("form",{...l,ref:m,onSubmit:l.onSubmit,children:n})})}),st=a.forwardRef(({name:n,children:s,...o},l)=>{const c=a.useContext(Ce),u=function(d){var b,p;c&&n&&c.setFieldValue(n,d.target.value),(p=(b=this.props).onChange)==null||p.call(b,d)},m=a.Children.map(s,d=>{if(a.isValidElement(d)&&n&&d.type===ne){let b=d;return a.cloneElement(b,{...b.props,name:n,value:(c==null?void 0:c.getFieldValue(n))??"",onChange:u.bind(b),required:o.required})}return d}),h=Object.create(o);return delete h.required,delete h.label,t.jsxs("div",{className:"lulichat-form-item",ref:l,...h,children:[o.label&&t.jsx(Ee,{htmlFor:n,required:o.required,children:o.label}),m,o.error&&t.jsx("p",{className:"error",children:o.error})]})}),Ee=a.forwardRef((n,s)=>{const o=n.required,l=n.children;return t.jsxs("label",{...n,className:ee("lulichat-form-label",n.className),ref:s,children:[l,o&&t.jsx("b",{style:{color:"red"},children:"*"})]})}),nt=n=>{const s=a.useRef(n||{}),o=a.useRef(null),l=a.useCallback((u,m)=>{s.current[u]=m},[]);return[{getValues:()=>s.current,getFieldValue:u=>{var m;return(m=s.current)==null?void 0:m[u]},elementRef:()=>o.current,setFieldValue:l}]};U.Item=st,U.Label=Ee,U.useForm=nt;const at=n=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",...n,children:t.jsxs("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[t.jsx("path",{strokeDasharray:"14",strokeDashoffset:"14",d:"M15 7h-11.5M9 17h11.5",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"0.3s",values:"14;0"})}),t.jsx("path",{strokeDasharray:"8",strokeDashoffset:"8",d:"M3 7l4 4M3 7l4 -4M21 17l-4 4M21 17l-4 -4",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"0.3s",dur:"0.2s",values:"8;0"})})]})}),ot=n=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 18 18",...n,children:t.jsx("path",{fill:"none",stroke:"currentColor",strokeDasharray:"10",strokeDashoffset:"10",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 15l-5 -5M12 15l5 -5",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"0.3s",values:"10;0"})})}),it=n=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",...n,children:[t.jsx("mask",{id:"lineMdFileDocumentFilled0",children:t.jsxs("g",{fill:"none",stroke:"#fff",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[t.jsxs("path",{fill:"#fff",fillOpacity:"0",strokeDasharray:"64",strokeDashoffset:"64",d:"M13.5 3l5.5 5.5v11.5c0 0.55 -0.45 1 -1 1h-12c-0.55 0 -1 -0.45 -1 -1v-16c0 -0.55 0.45 -1 1 -1Z",children:[t.jsx("animate",{fill:"freeze",attributeName:"fill-opacity",begin:"0.6s",dur:"0.5s",values:"0;1"}),t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"0.6s",values:"64;0"})]}),t.jsx("path",{fill:"#000",stroke:"#000",d:"M14.5 3.5l0 4.5l4.5 0z",opacity:"0",children:t.jsx("set",{fill:"freeze",attributeName:"opacity",begin:"0.6s",to:"1"})}),t.jsx("path",{d:"M13.5 3l5.5 5.5",opacity:"0",children:t.jsx("set",{fill:"freeze",attributeName:"opacity",begin:"0.6s",to:"1"})}),t.jsx("path",{stroke:"#000",strokeDasharray:"12",strokeDashoffset:"12",d:"M7 13h10",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"1.1s",dur:"0.2s",values:"12;0"})}),t.jsx("path",{stroke:"#000",strokeDasharray:"8",strokeDashoffset:"8",d:"M7 17h7",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"1.3s",dur:"0.2s",values:"8;0"})})]})}),t.jsx("rect",{width:"24",height:"24",fill:"currentColor",mask:"url(#lineMdFileDocumentFilled0)"})]}),Se=n=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",...n,children:t.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 5L12 5L19 5M5 12H19M5 19L12 19L19 19",children:t.jsx("animate",{fill:"freeze",attributeName:"d",dur:"0.4s",values:"M5 5L12 5L19 5M5 12H19M5 19L12 19L19 19;M5 5L12 12L19 5M12 12H12M5 19L12 12L19 19"})})}),lt=n=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 22 22",...n,children:t.jsx("path",{fill:"currentColor",d:"M1.5 4v1.5c0 4.15 2.21 7.78 5.5 9.8V20h15v-2c0-2.66-5.33-4-8-4h-.25C9 14 5 10 5 5.5V4m9 0a4 4 0 0 0-4 4a4 4 0 0 0 4 4a4 4 0 0 0 4-4a4 4 0 0 0-4-4"})}),ct=n=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",...n,children:t.jsx("path",{fill:"currentColor",d:"M12 2.25A9.75 9.75 0 0 0 2.25 12v5q0 .04.004.08v.05c-.003 1.278.602 2.682 1.963 3.25l.071.03c.11.044.22.12.362.25c.07.064.138.132.22.213l.008.008c.08.08.175.175.277.265c.204.183.474.388.83.506c.37.122.77.131 1.208.022c.723-.18 1.266-.752 1.469-1.454c.089-.309.089-.668.088-1.084v-4.094c0-.285 0-.528-.01-.728a2.3 2.3 0 0 0-.107-.627c-.23-.683-.786-1.223-1.504-1.377a2.25 2.25 0 0 0-1.264.065c-.37.133-.652.354-.87.558c-.12.11-.269.267-.391.396l-.164.17a1.8 1.8 0 0 1-.427.338q-.136.07-.263.152V12a8.25 8.25 0 1 1 16.5 0v1.864a3 3 0 0 0-.538-.274a1.2 1.2 0 0 1-.362-.25c-.07-.064-.138-.132-.22-.213l-.008-.008a7 7 0 0 0-.277-.265a2.4 2.4 0 0 0-.83-.506q-.553-.184-1.208-.022c-.723.18-1.266.752-1.469 1.454c-.089.309-.088.668-.088 1.085v4.093c0 .285 0 .528.01.728c.012.208.037.418.107.627c.23.683.786 1.223 1.504 1.377c.463.1.883.073 1.264-.065c.37-.133.652-.354.87-.558c.12-.11.269-.267.391-.395c.065-.069.123-.13.164-.17a1.8 1.8 0 0 1 .427-.34c1.11-.573 1.755-1.724 1.758-2.936v-.143L21.75 17v-5A9.75 9.75 0 0 0 12 2.25"})}),_e=()=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",children:t.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11zm7.318-19.539l-10.94 10.939"})}),ae=n=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",...n,children:t.jsxs("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[t.jsxs("path",{strokeDasharray:"16",strokeDashoffset:"16",d:"M12 3c4.97 0 9 4.03 9 9",children:[t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"0.3s",values:"16;0"}),t.jsx("animateTransform",{attributeName:"transform",dur:"1.5s",repeatCount:"indefinite",type:"rotate",values:"0 12 12;360 12 12"})]}),t.jsx("path",{strokeDasharray:"64",strokeDashoffset:"64",strokeOpacity:"0.3",d:"M12 3c4.97 0 9 4.03 9 9c0 4.97 -4.03 9 -9 9c-4.97 0 -9 -4.03 -9 -9c0 -4.97 4.03 -9 9 -9Z",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"1.2s",values:"64;0"})})]})}),ut=n=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",...n,children:[t.jsxs("mask",{id:"lineMdChatRoundDotsFilled0",children:[t.jsxs("path",{fill:"#fff",fillOpacity:"0",d:"M5 15.5c1 1 2.5 2 4 2.5c-0.71 -0.24 -1.43 -0.59 -2.09 -1c-0.72 -0.45 -1.39 -0.98 -1.91 -1.5Z",children:[t.jsx("animate",{fill:"freeze",attributeName:"d",begin:"0.6s",dur:"0.2s",values:"M5 15.5c1 1 2.5 2 4 2.5c-0.71 -0.24 -1.43 -0.59 -2.09 -1c-0.72 -0.45 -1.39 -0.98 -1.91 -1.5Z;M5 15.5c1 1 2.5 2 4 2.5c-2 2 -5 3 -7 3c2 -2 3 -3.5 3 -5.5Z"}),t.jsx("set",{fill:"freeze",attributeName:"fill-opacity",begin:"0.6s",to:"1"})]}),t.jsxs("g",{fill:"none",stroke:"#fff",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[t.jsxs("path",{fill:"transparent",fillOpacity:"0",strokeDasharray:"56",strokeDashoffset:"56",d:"M7 16.82c-2.41 -1.25 -4 -3.39 -4 -5.82c0 -3.87 4.03 -7 9 -7c4.97 0 9 3.13 9 7c0 3.87 -4.03 7 -9 7c-1.85 0 -3.57 -0.43 -5 -1.18Z",children:[t.jsx("animate",{fill:"freeze",attributeName:"fill-opacity",begin:"0.9s",dur:"0.5s",values:"0;1"}),t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"0.6s",values:"56;0"})]}),t.jsx("path",{stroke:"currentColor",strokeDasharray:"2",strokeDashoffset:"2",d:"M8 11h0.01",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"1.4s",dur:"0.2s",values:"2;0"})}),t.jsx("path",{stroke:"currentColor",strokeDasharray:"2",strokeDashoffset:"2",d:"M12 11h0.01",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"1.7s",dur:"0.2s",values:"2;0"})}),t.jsx("path",{stroke:"currentColor",strokeDasharray:"2",strokeDashoffset:"2",d:"M16 11h0.01",children:t.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"2s",dur:"0.2s",values:"2;0"})})]})]}),t.jsx("rect",{width:"24",height:"24",fill:"currentColor",mask:"url(#lineMdChatRoundDotsFilled0)"})]}),K=a.forwardRef(({className:n,variant:s="outline",size:o="md",shape:l="rounded",...c},u)=>t.jsx("button",{className:ee("lulichat-btn",`lulichat-btn-${s}`,`lulichat-btn-${o}`,`lulichat-btn-${l}`,n),ref:u,...c}));K.displayName="Button";const dt=a.forwardRef((n,s)=>{const{companyName:o,isLoading:l,allowAnonymous:c}=n,[u,m]=a.useState(!0),[h,d]=a.useState({name:"",email:""}),[b,p]=a.useState({}),[E,g]=a.useState(!1),T=()=>{var N,j;const S={};return!c&&!((N=h.name)!=null&&N.trim())&&(S.name="Name is required"),c||((j=h.email)!=null&&j.trim()?/\S+@\S+\.\S+/.test(h.email)||(S.email="Email is invalid"):S.email="Email is required"),p(S),Object.keys(S).length===0},_=S=>{S.preventDefault(),T()&&(g(!0),m(!1))},w=(S,N)=>{d(j=>({...j,[S]:N})),b[S]&&p(j=>({...j,[S]:void 0}))};return a.useImperativeHandle(s,()=>({getValues:()=>h}),[h]),console.log({formData:h,submitted:E}),t.jsxs(U,{autoComplete:"off",onSubmit:_,onValuesChange:d,className:"lulichat-contact-form",children:[t.jsxs("div",{className:"lulichat-form-header",children:[t.jsxs("div",{style:{marginBottom:"20px",display:"flex",alignItems:"end",columnGap:8},children:[t.jsx(lt,{style:{display:"block"},color:"#DEDEDE6A",height:40,width:50}),t.jsx("h3",{style:{fontWeight:500},children:"Hello,"})]}),t.jsxs("h3",{style:{marginBottom:8},className:"lulichat-title",children:["Welcome to ",o," Live Chat"]}),E?t.jsxs("div",{children:[t.jsxs("p",{children:["Name: ",t.jsx("b",{children:h.name})]}),t.jsxs("p",{children:["Email: ",t.jsx("b",{children:h.email})]})]}):t.jsxs("p",{role:"button",onClickCapture:()=>m(!u),style:{textDecoration:"underline",lineHeight:"1rem",cursor:"pointer"},children:["Please provide your details for a better support experience"," ",t.jsx(ot,{style:{display:"inline-block",marginBottom:-2},height:20,width:20})]})]}),t.jsxs("div",{className:`lulichat-form-group${u?" open":""}`,children:[t.jsx(U.Item,{error:b.name,label:"Name (Optional)",name:"name",children:t.jsx(ne,{id:"name",placeholder:"Enter your name",type:"text",value:h.name,onChange:S=>w("name",S.target.value),className:"transparent"+(b.name?" error":"")})}),t.jsx(U.Item,{name:"email",error:b.email,label:"Email",children:t.jsx(ne,{id:"email",type:"email",placeholder:"Enter your valid email",value:h.email,onChange:S=>w("email",S.target.value),className:"transparent"+(b.name?" error":"")})}),t.jsx(K,{type:"submit",disabled:l||!h.email,style:{width:"100%",marginBlock:10},className:"lulichat-contact-form-btn",children:l?t.jsxs(t.Fragment,{children:[t.jsx(ae,{}),"Submitting..."]}):"Submit"})]})]})});class ft{constructor(s,o="wss://ws.lulichat.com",l){$(this,"socket",null);$(this,"token");$(this,"ticket");$(this,"onMessageCallback");$(this,"onStatusCallback");$(this,"reconnectAttempts",0);$(this,"maxReconnectAttempts",5);this.token=s,this.ticket=l,this.connect(o)}connect(s){var o;try{this.socket=A(`${s}`,{transports:["websocket"],pingTimeout:18e3,pingInterval:18e3,query:{token:this.token}}),this.socket.on("connect",()=>{var l,c;console.log("Socket connected"),this.reconnectAttempts=0,(l=this.socket)==null||l.emit("joinChatBox",this.ticket.id),(c=this.onStatusCallback)==null||c.call(this,"connected")}),this.socket.on(`company-${this.ticket.companyId}-appMessage`,l=>{var c;(c=this.onMessageCallback)==null||c.call(this,l.message)}),this.socket.onAny((l,...c)=>{console.debug({event:l,args:c})}),this.socket.on("disconnect",(l,c)=>{var u;console.log("Socket disconnected"),console.log({reason:l,details:c}),(u=this.onStatusCallback)==null||u.call(this,"disconnected")}),this.socket.on("connect_error",l=>{var c;console.error("Socket error:",l.message),(c=this.onStatusCallback)==null||c.call(this,"error")})}catch(l){console.error("Failed to connect socket:",l),(o=this.onStatusCallback)==null||o.call(this,"error")}}sendMessage(s){var o;(o=this.socket)!=null&&o.connected&&this.socket.emit("message",s)}onMessage(s){this.onMessageCallback=s}onStatus(s){this.onStatusCallback=s}disconnect(){this.socket&&(this.socket.close(),this.socket=null)}}function Te(n){const s=Xe(),o=Y.marked.parse(n||"");return s.sanitize(o)}const ht=n=>{var z;const{session:s,companyInfo:o,onClose:l,api:c}=n,[u,m]=a.useState([]),[h,d]=a.useState(""),[b,p]=a.useState(!1),[E,g]=a.useState("disconnected"),T=a.useRef(null),_=a.useRef(null),[w,S]=a.useState(),{ticket:N}=s,j=a.useCallback(async()=>{const y=await c.getTicketMessages(s.ticket.id);m(I=>rt([...I,...y.messages],D=>D.id).sort((D,W)=>+new Date(D.createdAt)-+new Date(W.createdAt))),S(y)},[s.ticket.id]);a.useEffect(()=>{j()},[j]),a.useEffect(()=>{const{token:y,ticket:I}=s;return _.current=new ft(y,c.baseUrl,I),_.current.onMessage(D=>{m(W=>[...W,D]),p(!1)}),_.current.onStatus(D=>{g(D)}),()=>{var D;(D=_.current)==null||D.disconnect()}},[s,o]),a.useEffect(()=>{te()},[u]);const te=()=>{var y;(y=T.current)==null||y.scrollIntoView({behavior:"smooth"})},R=()=>{var I;if(!h.trim()||E!=="connected")return;const y={id:we(32),ticketId:N.id,body:h,contactId:N.contact.id,queueId:N.queueId,companyId:N.companyId};(I=_.current)==null||I.sendMessage(y),d(""),p(!0)},B=y=>{y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),R())},G=y=>new Intl.DateTimeFormat("en-US",{hour:"2-digit",minute:"2-digit"}).format(y);return t.jsxs("div",{className:"lulichat-room",children:[t.jsx("div",{className:"lulichat-room-header",children:t.jsxs("div",{className:"lulichat-flex lulichat-space-x-2",children:[t.jsxs("div",{className:"lulichat-flex lulichat-space-x-2",children:[t.jsx("div",{style:{width:"0.5rem",height:"0.5rem",borderRadius:"9999px",background:"#22c55e"}}),t.jsx("span",{className:"font-medium",children:((z=N.contact)==null?void 0:z.name)||"Anonymous"}),t.jsx(at,{height:24,width:24}),t.jsx("span",{className:"font-medium",children:o.name})]}),t.jsx(K,{variant:"ghost",size:"sm",onClick:l,className:"",children:t.jsx(Se,{height:16,width:16})})]})}),t.jsxs("div",{className:"lulichat-flex-1 lulichat-p-4 lulichat-bg-background",style:{overflowY:"auto",flex:1},children:[u.map((y,I)=>{var W;const D=(W=u[I-1])==null?void 0:W.fromMe;return t.jsx("div",{className:ee("lulichat-message",y.fromMe?"agent":"user"),children:t.jsxs("div",{className:"lulichat-message-content",children:[y.fromMe&&!D&&t.jsxs("div",{className:"lulichat-message-header",children:[t.jsx(ct,{width:16,height:16}),t.jsx("span",{className:"lulichat-message-sender",children:"Support"})]}),t.jsxs("p",{className:ee("lulichat-message-body",y.fromMe?"support":"user"),children:[t.jsx("span",{dangerouslySetInnerHTML:{__html:Te(y.body)}}),t.jsx("p",{className:"lulichat-message-time",children:G(new Date(y.createdAt))})]})]})},y.id)}),b&&t.jsx("div",{className:"lulichat-typing",children:t.jsx("div",{className:"lulichat-typing-bubble",children:t.jsxs("div",{className:"lulichat-typing-dots",children:[t.jsx("div",{className:"lulichat-typing-dot"}),t.jsx("div",{className:"lulichat-typing-dot"}),t.jsx("div",{className:"lulichat-typing-dot"})]})})}),t.jsx("div",{ref:T})]}),t.jsxs("div",{className:"lulichat-input-wrapper",children:[t.jsxs("div",{className:"lulichat-input-container",children:[t.jsx("input",{value:h,onChange:y=>d(y.target.value),onKeyPress:B,placeholder:"Type your message...",disabled:E!=="connected",className:"lulichat-input"}),t.jsx("button",{onClick:R,disabled:!h.trim()||E!=="connected",className:"lulichat-send-button",children:t.jsx(_e,{width:16,height:16})})]}),E!=="connected"&&t.jsx("p",{className:"lulichat-connection-status",children:E==="error"?"Connection error. Retrying...":"Connecting..."})]})]})},mt=a.forwardRef((n,s)=>{const[o,l]=a.useState([]),[c,u]=a.useState(n.queues),m=a.useRef(null),h=a.useRef("auto"),d=n.api.useRequest(),b=a.useCallback(async g=>{if(!g.length){u(n.queues);return}u([]);const T=g[g.length-1],_=T.type=="queue",w=await d.getOptions({[_?"queueId":"queueOptionId"]:T.id,parentId:_?-1:T.id});w!=null&&w.length&&(E(),u(w))},[]);a.useEffect(()=>{b(o)},[o]),a.useImperativeHandle(s,()=>({getTags:()=>o}),[o]);const p=o[o.length-1];a.useEffect(()=>{if(!m.current)return;const g=m.current,T=g.offsetHeight;g.style.height=`${T}px`,requestAnimationFrame(()=>{if(!m.current)return;const _=g.scrollHeight;if(T===_){g.style.height="auto";return}g.offsetHeight,g.style.height=`${_}px`;const w=()=>{m.current&&(m.current.style.height="auto"),g.removeEventListener("transitionend",w)};g.addEventListener("transitionend",w)})},[o,n.message]);const E=a.useCallback(()=>{var g;m.current&&(h.current=(g=m.current)==null?void 0:g.offsetHeight)},[]);return a.useEffect(E,[c,o]),console.log({loading:d.loading}),t.jsxs("div",{className:"wrap",ref:m,style:{overflow:"hidden",transition:"height 200ms ease"},children:[(p||n.message)&&t.jsx("div",{className:"lulichat-queue-message",style:{background:"#EBEBEBFF",padding:10,marginBottom:10,fontSize:".79rem",borderRadius:"0.5rem"},dangerouslySetInnerHTML:{__html:Te((p==null?void 0:p.message)||(p==null?void 0:p.greetingMessage)||n.message)}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"start",gap:10,flexWrap:"wrap"},children:[o.map((g,T)=>{g.name;const _=g.name||g.title,w=T==o.length-1,S=w&&d.loading;return t.jsxs("button",{onClick:w?()=>{E(),l(N=>[...N].filter(j=>j.id!=g.id?g.type!=j.type:!1))}:void 0,disabled:!w,className:"lulichat-tag"+(w?" selected":""),children:[S&&t.jsx(ae,{height:14,width:14}),_==null?void 0:_.toLocaleLowerCase(),w&&t.jsx(Se,{style:{marginLeft:4},height:14,width:14})]},g.id)}),c.map(g=>{const T=g.name?"queue":"option",_=o.find(S=>S.id==g.id&&S.type==T),w=g.name||g.title;return t.jsx("button",{onClick:()=>l([...o,{...g,type:T}]),className:"lulichat-tag"+(_?" selected":""),children:w==null?void 0:w.toLocaleLowerCase()},g.id)})]})]})}),fe="luli-g-id",gt=({config:n})=>{const[s,o]=a.useState(null),[l,c]=a.useState(null),[u,m]=a.useState(!1),[h,d]=a.useState(null),[b,p]=a.useState(!1),[E,g]=a.useState(localStorage.getItem(fe)||we()),T=a.useRef(null),_=a.useRef(null),w=new tt(n);a.useEffect(()=>{S(),j()},[n]);const S=async()=>{try{const R=await w.getCompanyInfo();o(R.data)}catch(R){d("Failed to load chat configuration"),console.error("Failed to load company info:",R)}},N=async R=>{var B,G;m(!0);try{const z=((B=T.current)==null?void 0:B.getValues())||{},y=((G=_.current)==null?void 0:G.getTags())||[],I=y[0],D=(y==null?void 0:y.length)>1?y[y.length-1]:void 0,W={...z,...R,message:`${y.map(L=>`*${(L==null?void 0:L.name)||(L==null?void 0:L.title)}*`)}
|
|
31
|
+
${R.message}`,queueId:I==null?void 0:I.id,queueOptionId:D==null?void 0:D.id,guestId:E},oe=await w.submitContactInfo(W);localStorage.setItem(fe,E),c(oe.data)}catch(z){d("Failed to start chat. Please try again."),console.error("Failed to submit contact info:",z)}finally{m(!1)}},j=a.useCallback(async()=>{var B;const R=await w.getSession(E);(B=R.data)!=null&&B.ticket&&R.data.token&&(c(R.data),p(!0))},[fe]),te=()=>{c(null),d(null)};return s?t.jsxs("div",{className:`lulichat lulichat-${n.position}`,children:[b&&t.jsxs("div",{className:"lulichat-main",children:[!l&&t.jsxs(a.Fragment,{children:[t.jsx(dt,{companyName:s==null?void 0:s.name,allowAnonymous:n.allowAnonymous||!1,isLoading:u,ref:T}),t.jsxs("div",{style:{padding:16},children:[t.jsx(mt,{message:n.welcomeMessage,api:w,queues:s==null?void 0:s.queues,ref:_}),t.jsx("div",{style:{height:2,backgroundColor:"hsl(var(--border))",marginBlock:16}}),t.jsx(pt,{isLoading:u,handleSubmit:N})]})]}),l&&t.jsx(ht,{session:l,companyInfo:s,onClose:te,api:w})]}),t.jsx(K,{onClick:()=>p(!b),className:"",shape:"circle",size:"icon",style:{backgroundColor:n.primaryColor,height:"4rem",width:"4rem",padding:0,color:"#fff",alignSelf:"end"},disabled:!s&&!h,children:!s&&!h?t.jsx(ae,{}):t.jsx(ut,{height:40,width:40})})]}):t.jsx(t.Fragment,{})},pt=n=>{const[s,o]=a.useState({message:"",files:null}),l=a.useRef(null);return t.jsxs("div",{style:{display:"flex",alignItems:"center",columnGap:10},className:"form-control",children:[t.jsx(ne,{name:"message",autoComplete:"off",style:{border:"none",paddingInline:0},placeholder:"What can we help you with ?.",onChange:c=>o({...s,message:c.target.value})}),n.isLoading?t.jsx(ae,{}):t.jsxs("div",{className:"lulichat-btn-group",children:[t.jsxs(K,{onClick:()=>{var c;return(c=l.current)==null?void 0:c.click()},style:{color:"#00000080"},size:"icon",children:[t.jsx(it,{height:24}),t.jsx("input",{ref:l,hidden:!0,type:"file",multiple:!1,onChange:c=>o({...s,files:c.target.files}),accept:"image/jpeg,image/png"})]}),t.jsx(K,{onClick:s.message?()=>{n.handleSubmit(s)}:void 0,disabled:!s.message,style:{color:"#00000080"},size:"icon",children:t.jsx(_e,{})})]})]})};return({apiKey:n,baseUrl:s,position:o="bottom-right",primaryColor:l="#007bff",companyName:c="Support",welcomeMessage:u="Hello! How can we help you today?",requireContactInfo:m=!0,allowAnonymous:h=!0})=>{const d={apiKey:n,baseUrl:s,position:o,primaryColor:l,companyName:c,welcomeMessage:u,requireContactInfo:m,allowAnonymous:h};return n?t.jsx(gt,{config:d}):(console.error("LuliChat: API key is required"),null)}});
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@import"https://fonts.googleapis.com/css2?family=Inclusive+Sans:ital@0;1&family=Outfit:wght@100..900&display=swap";:root{--background: 0 0% 100%;--foreground: 222.2 84% 4.9%;--card: 0 0% 100%;--card-foreground: 222.2 84% 4.9%;--popover: 0 0% 100%;--popover-foreground: 222.2 84% 4.9%;--primary-color: #755ae2;--primary: 251.91deg 70.1% 61.96%;--primary-foreground: 210 40% 98%;--secondary: 210 40% 96.1%;--secondary-foreground: 222.2 47.4% 11.2%;--muted: 210 40% 96.1%;--muted-foreground: 215.4 16.3% 46.9%;--accent: 210 40% 96.1%;--accent-foreground: 222.2 47.4% 11.2%;--destructive: 0 84.2% 60.2%;--destructive-foreground: 210 40% 98%;--border: 214.3 31.8% 91.4%;--input: 214.3 31.8% 91.4%;--ring: 222.2 84% 4.9%;--radius: .5rem}.dark{--background: 222.2 84% 4.9%;--foreground: 210 40% 98%;--card: 222.2 84% 4.9%;--card-foreground: 210 40% 98%;--popover: 222.2 84% 4.9%;--popover-foreground: 210 40% 98%;--primary: 210 40% 98%;--primary-foreground: 222.2 47.4% 11.2%;--secondary: 217.2 32.6% 17.5%;--secondary-foreground: 210 40% 98%;--muted: 217.2 32.6% 17.5%;--muted-foreground: 215 20.2% 65.1%;--accent: 217.2 32.6% 17.5%;--accent-foreground: 210 40% 98%;--destructive: 0 62.8% 30.6%;--destructive-foreground: 210 40% 98%;--border: 217.2 32.6% 17.5%;--input: 217.2 32.6% 17.5%;--ring: 212.7 26.8% 83.9%}.lulichat,.lulichat *{box-sizing:border-box;margin:0;padding:0;border:none;outline:none}.lulichat button{-moz-appearance:none;appearance:none;-webkit-appearance:none;outline:none}.lulichat{position:fixed;z-index:50;display:flex;flex-direction:column;row-gap:10px;font-family:Outfit,sans-serif;font-optical-sizing:auto;font-weight:
|
|
1
|
+
@import"https://fonts.googleapis.com/css2?family=Inclusive+Sans:ital@0;1&family=Outfit:wght@100..900&display=swap";:root{--background: 0 0% 100%;--foreground: 222.2 84% 4.9%;--card: 0 0% 100%;--card-foreground: 222.2 84% 4.9%;--popover: 0 0% 100%;--popover-foreground: 222.2 84% 4.9%;--primary-color: #755ae2;--primary: 251.91deg 70.1% 61.96%;--primary-foreground: 210 40% 98%;--secondary: 210 40% 96.1%;--secondary-foreground: 222.2 47.4% 11.2%;--muted: 210 40% 96.1%;--muted-foreground: 215.4 16.3% 46.9%;--accent: 210 40% 96.1%;--accent-foreground: 222.2 47.4% 11.2%;--destructive: 0 84.2% 60.2%;--destructive-foreground: 210 40% 98%;--border: 214.3 31.8% 91.4%;--input: 214.3 31.8% 91.4%;--ring: 222.2 84% 4.9%;--radius: .5rem}.dark{--background: 222.2 84% 4.9%;--foreground: 210 40% 98%;--card: 222.2 84% 4.9%;--card-foreground: 210 40% 98%;--popover: 222.2 84% 4.9%;--popover-foreground: 210 40% 98%;--primary: 210 40% 98%;--primary-foreground: 222.2 47.4% 11.2%;--secondary: 217.2 32.6% 17.5%;--secondary-foreground: 210 40% 98%;--muted: 217.2 32.6% 17.5%;--muted-foreground: 215 20.2% 65.1%;--accent: 217.2 32.6% 17.5%;--accent-foreground: 210 40% 98%;--destructive: 0 62.8% 30.6%;--destructive-foreground: 210 40% 98%;--border: 217.2 32.6% 17.5%;--input: 217.2 32.6% 17.5%;--ring: 212.7 26.8% 83.9%}.lulichat,.lulichat *{box-sizing:border-box;margin:0;padding:0;border:none;outline:none}.lulichat button{-moz-appearance:none;appearance:none;-webkit-appearance:none;outline:none}.lulichat{position:fixed;z-index:50;display:flex;flex-direction:column;row-gap:10px;font-family:Outfit,sans-serif;font-optical-sizing:auto;font-weight:400;max-width:400px}.lulichat-main{background-color:hsl(var(--background));color:hsl(var(--foreground));border-radius:12px;border:4px solid hsl(var(--primary));box-shadow:4px 4px 20px 4px #0000001a;display:flex;flex-direction:column;overflow:hidden;width:400px}.lulichat-bottom-right{bottom:1rem;right:1rem}.lulichat-bottom-left{bottom:1rem;left:1rem}.lulichat-top-right{top:1rem;right:1rem}.lulichat-container-top-left{top:1rem;left:1rem}.lulichat-btn{display:inline-flex;align-items:center;justify-content:center;gap:.5rem;white-space:nowrap;font-size:1rem;font-weight:500;transition:background-color .2s,color .2s;outline:none;cursor:pointer}.lulichat-btn.lulichat-contact-form-btn{background-color:#fff;color:hsl(var(--primary))}.lulichat-btn-group{display:flex;gap:.4rem}.lulichat-btn:disabled{cursor:not-allowed;opacity:.5}.lulichat-btn-rounded{border-radius:1.5rem}.lulichat-btn-none{border-radius:0rem}.lulichat-btn-circle{border-radius:50%}.lulichat-btn:focus-visible{outline:2px solid var(--ring);outline-offset:2px}.lulichat-btn:disabled{pointer-events:none;opacity:.5}.lulichat-btn-primary{background-color:hsl(var(--primary));color:#fff}.lulichat-btn-primary:hover:not(:disabled){background-color:#000}.lulichat-btn-default{background:hsl(var(--primary));color:hsl(var(--primary-foreground))}.lulichat-btn-default:hover{background:rgba(var(--primary),.9)}.lulichat-btn-destructive{background:hsl(var(--destructive));color:hsl(var(--destructive-foreground))}.lulichat-btn-destructive:hover{background:rgba(var(--destructive),.9)}.lulichat-btn-outline{border:1px solid hsl(var(--border));background:hsl(var(--background));color:inherit}.lulichat-btn-outline:hover{background:hsl(var(--accent));color:hsl(var(--accent-foreground))}.lulichat-btn-secondary{background:hsl(var(--secondary));color:hsl(var(--secondary-foreground))}.lulichat-btn-secondary:hover{background:hsl(var(--accent))}.lulichat-btn-ghost:hover{background:hsl(var(--accent));color:hsl(var(--accent-foreground))}.lulichat-btn-link{color:hsl(var(--primary));text-underline-offset:4px}.lulichat-btn-link:hover{text-decoration:underline}.lulichat-btn-md{height:2.5rem;padding:.5rem 1rem}.lulichat-btn-sm{height:1.5rem;padding:0 .55rem}.lulichat-btn-lg{height:2.75rem;padding:0 2rem}.lulichat-btn-icon{height:2.5rem;width:2.5rem}.lulichat-contact-form{background-color:hsl(var(--primary));padding:8px 16px;color:#fff}.lulichat-form-group{max-height:0;opacity:0;overflow:hidden;transition:max-height .7s cubic-bezier(.22,1,.36,1),opacity .7s cubic-bezier(.22,1,.36,1)}.lulichat-form-group.open{opacity:1;max-height:500px}.lulichat-form-header{margin-bottom:1.5rem}.lulichat-form-item{margin-bottom:.7rem;display:block;flex-direction:column;gap:.5rem}.lulichat-form-label{font-size:1rem;font-weight:500;display:block;margin-bottom:.25rem}.lulichat-form-item input,.lulichat-form-item textarea,.lulichat-input{padding:.7rem .75rem;border:1px solid #d1d5db;border-radius:.5rem;font-size:1rem;width:100%;transition:border-color .2s;transition:background-color .5s;background-color:#fff;color:#222}input:-internal-autofill-selected,textarea:-webkit-autofill{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:#0003!important;color:fieldtext!important}.lulichat-form-item input.transparent{background-color:#0003!important;color:#fff}.lulichat-form-item input.error{border-color:red}.lulichat-form-item input.transparent:hover,.lulichat-form-item input.transparent:focus{background-color:#0006!important}.lulichat-form-item input.transparent::placeholder{color:#fff}.lulichat-form-item input:focus,.lulichat-form-item textarea:focus{border-color:#ceced2;outline:none}.lulichat-form-item input:focus::placeholder,.lulichat-form-item textarea:focus::placeholder{opacity:.5}.lulichat-form-item input[aria-invalid=true],.lulichat-form-item textarea[aria-invalid=true]{border-color:#ef4444}.lulichat-form-item .error{color:#fd8989;font-size:.875rem;margin-top:.25rem;font-weight:400}.lulichat-queue-message{transition:height .2s,min-height .2s,opacity .1s}.lulichat-tag{padding:5px 8px;font-weight:500;border-radius:24px;font-size:.75rem;text-transform:capitalize!important;background-color:#e7e6e6;transition:background-color .1s,color 50ms;display:flex;align-items:center;column-gap:2px}.lulichat-tag.selected{background-color:var(--primary-color);color:#fff}.lulichat-tag:disabled{cursor:not-allowed}.lulichat-tag:not(:disabled):hover{background-color:var(--primary-color);color:#fff;cursor:pointer}.lulichat-room{display:flex;flex-direction:column;height:100%;height:450px;width:400px;background:#fff;font-family:sans-serif}.lulichat-room-header{padding:1rem;border-bottom:1px solid #e5e7eb;background:#f9fafb}.lulichat-room-header .status{font-size:.75rem;opacity:.8;margin-top:.25rem}.lulichat-message{display:flex;margin-top:.5rem}.lulichat-message.user{justify-content:flex-end}.lulichat-message.agent{justify-content:flex-start}.lulichat-message.user .lulichat-message-time{text-align:right}.lulichat-message-content{max-width:80%;border-radius:.5rem}.lulichat-message-header{display:flex;align-items:center;gap:.25rem;margin-bottom:.25rem}.lulichat-message-sender{font-size:.75rem;opacity:.7}.lulichat-message-body{font-size:.875rem;color:#fff;padding:.5rem .6rem;color:var(--primary-color);border-radius:10px;line-height:1rem}.lulichat-message-body.support{background-color:#f4f4f4}.lulichat-message-body.user{background-color:#755ae220}.lulichat-message-time{font-size:.7rem;opacity:.6;margin-top:.25rem}.lulichat-typing{display:flex;justify-content:flex-start}.lulichat-typing-bubble{background:#f3f4f6;color:#374151;padding:.5rem 1rem;border-radius:.5rem}.lulichat-typing-dots{display:flex;gap:.25rem}.lulichat-typing-dot{width:.5rem;height:.5rem;background:currentColor;border-radius:9999px;animation:lulichat-bounce 1s infinite}.lulichat-typing-dot:nth-child(2){animation-delay:.1s}.lulichat-typing-dot:nth-child(3){animation-delay:.2s}@keyframes lulichat-bounce{0%,to{transform:translateY(0)}50%{transform:translateY(-.25rem)}}.lulichat-input-wrapper{padding:1rem;border-top:1px solid #e5e7eb;background:#fff}.lulichat-input-container{display:flex;gap:.5rem}.lulichat-input{flex:1;padding:.5rem .75rem;border:1px solid #d1d5db;border-radius:.375rem;font-size:.875rem}.lulichat-send-button{padding:.5rem;background:#3b82f6;border:none;border-radius:.375rem;color:#fff;cursor:pointer}.lulichat-send-button:disabled{background:#93c5fd;cursor:not-allowed}.lulichat-connection-status{font-size:.75rem;color:#6b7280;margin-top:.5rem}.lulichat-flex{display:flex;align-items:center;justify-content:space-between}.lulichat-space-x-2>*+*{margin-left:.5rem}.lulichat-space-y-4>*+*{margin-top:1rem}.lulichat-p-4{padding:1rem}.lulichat-bg-background{background:#fff}.lulichat-text-primary-foreground{color:#fff}.lulichat-bg-primary{background:#3b82f6}.lulichat-text-xs{font-size:.75rem}.lulichat-text-sm{font-size:.875rem}.lulichat-rounded-lg{border-radius:.5rem}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -9,28 +9,98 @@ export interface LuliChatConfig {
|
|
|
9
9
|
allowAnonymous?: boolean;
|
|
10
10
|
}
|
|
11
11
|
export interface ContactInfo {
|
|
12
|
-
name
|
|
13
|
-
email
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
name?: string;
|
|
13
|
+
email?: string;
|
|
14
|
+
queueId?: string | number;
|
|
15
|
+
queueOptionId?: string | number;
|
|
16
|
+
guestId?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface AppMessagePayload {
|
|
19
|
+
action: string;
|
|
20
|
+
message: ChatMessage;
|
|
21
|
+
ticket: Ticket;
|
|
22
|
+
contact: Contact;
|
|
16
23
|
}
|
|
17
24
|
export interface ChatMessage {
|
|
25
|
+
mediaUrl: null;
|
|
18
26
|
id: string;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
uuid: string;
|
|
28
|
+
remoteJid: null;
|
|
29
|
+
participant: null;
|
|
30
|
+
dataJson: null;
|
|
31
|
+
ack: number;
|
|
32
|
+
read: boolean;
|
|
33
|
+
fromMe: boolean;
|
|
34
|
+
body: string;
|
|
35
|
+
mediaType: null;
|
|
36
|
+
isDeleted: boolean;
|
|
37
|
+
createdAt: string;
|
|
38
|
+
updatedAt: string;
|
|
39
|
+
quotedMsgId: null;
|
|
40
|
+
ticketId: number;
|
|
41
|
+
contactId: number;
|
|
42
|
+
companyId: number;
|
|
43
|
+
queueId: number;
|
|
44
|
+
isEdited: boolean;
|
|
45
|
+
contact: Contact;
|
|
46
|
+
ticket: Ticket;
|
|
47
|
+
quotedMsg: null;
|
|
48
|
+
status: string;
|
|
49
|
+
isCampaign: boolean;
|
|
50
|
+
}
|
|
51
|
+
interface Schedule {
|
|
52
|
+
endTime: string;
|
|
53
|
+
startTime: string;
|
|
54
|
+
weekdayEn: string;
|
|
23
55
|
}
|
|
24
56
|
export interface ChatSession {
|
|
25
|
-
id: string;
|
|
26
57
|
token: string;
|
|
27
|
-
|
|
58
|
+
ticket: Ticket;
|
|
59
|
+
isActive?: boolean;
|
|
28
60
|
agentInfo?: {
|
|
29
61
|
name: string;
|
|
30
62
|
avatar?: string;
|
|
31
63
|
status: "online" | "away" | "busy";
|
|
32
64
|
};
|
|
33
65
|
}
|
|
66
|
+
export interface Ticket {
|
|
67
|
+
id: number;
|
|
68
|
+
status: string;
|
|
69
|
+
unreadMessages: null;
|
|
70
|
+
lastMessage: string;
|
|
71
|
+
isGroup: boolean;
|
|
72
|
+
userId: null;
|
|
73
|
+
contactId: number;
|
|
74
|
+
platform: string;
|
|
75
|
+
queueId: null | number;
|
|
76
|
+
chatbot: boolean;
|
|
77
|
+
queueOptionId: null | number;
|
|
78
|
+
companyId: number;
|
|
79
|
+
fromCompanyId: null;
|
|
80
|
+
uuid: string;
|
|
81
|
+
useIntegration: boolean;
|
|
82
|
+
promptId: null;
|
|
83
|
+
fromMe: boolean;
|
|
84
|
+
amountUsedBotQueues: number;
|
|
85
|
+
createdAt: string;
|
|
86
|
+
updatedAt: string;
|
|
87
|
+
contact: Contact;
|
|
88
|
+
queue: {
|
|
89
|
+
id: number;
|
|
90
|
+
name: string;
|
|
91
|
+
color: string;
|
|
92
|
+
};
|
|
93
|
+
user: null;
|
|
94
|
+
tags: any[];
|
|
95
|
+
}
|
|
96
|
+
interface Contact {
|
|
97
|
+
id: number;
|
|
98
|
+
name: string;
|
|
99
|
+
number: string;
|
|
100
|
+
email: string;
|
|
101
|
+
chatId: string;
|
|
102
|
+
profilePicUrl: null;
|
|
103
|
+
}
|
|
34
104
|
export interface CompanyInfo {
|
|
35
105
|
status: string;
|
|
36
106
|
success: boolean;
|
|
@@ -46,7 +116,7 @@ interface Data {
|
|
|
46
116
|
plan: null;
|
|
47
117
|
queues: Queue[];
|
|
48
118
|
}
|
|
49
|
-
interface Queue {
|
|
119
|
+
export interface Queue {
|
|
50
120
|
id: number;
|
|
51
121
|
name: string;
|
|
52
122
|
color: string;
|
|
@@ -56,7 +126,19 @@ interface Queue {
|
|
|
56
126
|
companyId: number;
|
|
57
127
|
orderQueue: null | number;
|
|
58
128
|
leadId: null | number;
|
|
59
|
-
mediaId: null;
|
|
129
|
+
mediaId: null | number;
|
|
130
|
+
createdAt: string;
|
|
131
|
+
updatedAt: string;
|
|
132
|
+
}
|
|
133
|
+
export interface QueueOption {
|
|
134
|
+
id: number;
|
|
135
|
+
title: string;
|
|
136
|
+
message: string;
|
|
137
|
+
option: string;
|
|
138
|
+
queueId: number;
|
|
139
|
+
parentId: null;
|
|
140
|
+
leadId: null | number;
|
|
141
|
+
mediaId: null | number;
|
|
60
142
|
createdAt: string;
|
|
61
143
|
updatedAt: string;
|
|
62
144
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lulichat",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "A React library for integrating a support chat feature into web applications.",
|
|
5
5
|
"main": "dist/lulichat-support.umd.js",
|
|
6
6
|
"module": "dist/lulichat-support.es.js",
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
"author": "Timi James",
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
|
+
"dompurify": "^3.2.6",
|
|
26
|
+
"marked": "^16.1.1",
|
|
25
27
|
"react": "^18.0.0",
|
|
26
28
|
"react-dom": "^18.0.0",
|
|
27
29
|
"socket.io-client": "^4.5.0"
|
|
@@ -42,7 +44,7 @@
|
|
|
42
44
|
"eslint-plugin-react-refresh": "^0.4.9",
|
|
43
45
|
"jest": "^29.0.0",
|
|
44
46
|
"jest-environment-jsdom": "^30.0.4",
|
|
45
|
-
"lulichat": "^1.0.
|
|
47
|
+
"lulichat": "^1.0.7",
|
|
46
48
|
"typescript": "^5.5.3",
|
|
47
49
|
"vite": "^5.4.1"
|
|
48
50
|
},
|