@subiz/widget-v4 4.1.117 → 4.1.120
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/assets/less/base.less +1 -0
- package/assets/less/chatbox.less +2 -0
- package/assets/less/message.less +42 -22
- package/assets/less/message_input.less +2 -0
- package/assets/less/order.less +1 -1
- package/assets/less/widget.less +36 -18
- package/assets/less/widget_header.less +35 -36
- package/compiled_src/chatbox/AgentsAvatar.js +1 -1
- package/compiled_src/chatbox/Event.js +87 -13
- package/compiled_src/chatbox/Events.js +106 -19
- package/compiled_src/chatbox/Header.js +5 -4
- package/compiled_src/chatbox/InfoMessage.js +2 -13
- package/compiled_src/chatbox/MessageInput.js +19 -9
- package/compiled_src/chatbox/TextMessage.js +11 -2
- package/compiled_src/chatbox/Widget.js +28 -23
- package/compiled_src/chatbox/time.js +1 -0
- package/compiled_src/util/common.js +89 -0
- package/dist/185.js +19 -19
- package/dist/19641cfa41e.278.js +1 -0
- package/dist/19641cfa41e.app.js +1 -0
- package/dist/{195ec5442e3.index.html → 19641cfa41e.index.html} +1 -1
- package/dist/{195ec5442e3.library.html → 19641cfa41e.library.html} +1 -1
- package/dist/19641cfa41e.library.js +1 -0
- package/dist/{195ec5442e3.preview.html → 19641cfa41e.preview.html} +1 -1
- package/dist/19641cfa41e.preview.js +1 -0
- package/dist/19641cfa41e.webview.js +1 -0
- package/dist/278.js +1 -1
- package/dist/HASH +1 -1
- package/dist/screenshoot.js +562 -185
- package/package.json +2 -2
- package/src/chatbox/AgentsAvatar.js +1 -1
- package/src/chatbox/Event.js +88 -14
- package/src/chatbox/Events.js +93 -15
- package/src/chatbox/Header.js +3 -2
- package/src/chatbox/InfoMessage.js +0 -14
- package/src/chatbox/MessageInput.js +18 -7
- package/src/chatbox/TextMessage.js +13 -0
- package/src/chatbox/Widget.js +16 -18
- package/src/chatbox/time.js +12 -8
- package/src/util/common.js +121 -0
- package/up +33 -21
- package/compiled_src/chatbox/Typing.js +0 -77
- package/dist/195ec5442e3.278.js +0 -1
- package/dist/195ec5442e3.app.js +0 -1
- package/dist/195ec5442e3.library.js +0 -1
- package/dist/195ec5442e3.preview.js +0 -1
- package/dist/195ec5442e3.webview.js +0 -1
- package/src/chatbox/Typing.js +0 -72
- /package/dist/{195ec5442e3.127.js → 19641cfa41e.127.js} +0 -0
- /package/dist/{195ec5442e3.132.js → 19641cfa41e.132.js} +0 -0
- /package/dist/{195ec5442e3.185.js → 19641cfa41e.185.js} +0 -0
- /package/dist/{195ec5442e3.27.js → 19641cfa41e.27.js} +0 -0
- /package/dist/{195ec5442e3.459.js → 19641cfa41e.459.js} +0 -0
- /package/dist/{195ec5442e3.490.js → 19641cfa41e.490.js} +0 -0
- /package/dist/{195ec5442e3.74.js → 19641cfa41e.74.js} +0 -0
- /package/dist/{195ec5442e3.997.js → 19641cfa41e.997.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{var t,e,s={9:(t,e,i)=>{var s=i(9143);t.exports=function(t,e,i){var r=[],n="idle",o=function(t){var e=t.map((function(t){return t.payload})),s=i(e);s&&s.then||(s=Promise.resolve(s));var r=t.map((function(t){return t.rs}));return new Promise((function(t){s.then((function(e){r.map((function(t,i){t(e&&e[i])})),t()}))}))},a=function(){"executing"!==n&&(n="executing",s((function(){if(r.length<=t)return Promise.resolve(!1);var e=r.splice(0,t);return o(e).then((function(){return!0}))})).then((function(){if(0!==r.length){var t=e-(Date.now()-r[0].created);if(t>=1){if(n="idle",r[0].settedTimeout)return;return r[0].settedTimeout=!0,void setTimeout(a,t)}var i=r;r=[],o(i).then((function(){n="idle",a()}))}else n="idle"})))};return this.push=function(t,e){return new Promise((function(i){r.push({payload:t,priority:e,created:Date.now(),rs:i}),a()}))},this}},172:(t,e,i)=>{"use strict";i.d(e,{FK:()=>y,XX:()=>$,_3:()=>_,h:()=>f,uA:()=>b});var s,r,n,o,a,l,c,h={},u=[],d=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,p=Array.isArray;function m(t,e){for(var i in e)t[i]=e[i];return t}function g(t){var e=t.parentNode;e&&e.removeChild(t)}function f(t,e,i){var r,n,o,a={};for(o in e)"key"==o?r=e[o]:"ref"==o?n=e[o]:a[o]=e[o];if(arguments.length>2&&(a.children=arguments.length>3?s.call(arguments,2):i),"function"==typeof t&&null!=t.defaultProps)for(o in t.defaultProps)void 0===a[o]&&(a[o]=t.defaultProps[o]);return v(t,a,r,n,null)}function v(t,e,i,s,o){var a={type:t,props:e,key:i,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==o?++n:o,__i:-1,__u:0};return null==o&&null!=r.vnode&&r.vnode(a),a}function _(){return{current:null}}function y(t){return t.children}function b(t,e){this.props=t,this.context=e}function w(t,e){if(null==e)return t.__?w(t.__,t.__i+1):null;for(var i;e<t.__k.length;e++)if(null!=(i=t.__k[e])&&null!=i.__e)return i.__e;return"function"==typeof t.type?w(t):null}function A(t){var e,i;if(null!=(t=t.__)&&null!=t.__c){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if(null!=(i=t.__k[e])&&null!=i.__e){t.__e=t.__c.base=i.__e;break}return A(t)}}function k(t){(!t.__d&&(t.__d=!0)&&o.push(t)&&!x.__r++||a!==r.debounceRendering)&&((a=r.debounceRendering)||l)(x)}function x(){var t,e,i,s,n,a,l,h,u;for(o.sort(c);t=o.shift();)t.__d&&(e=o.length,s=void 0,a=(n=(i=t).__v).__e,h=[],u=[],(l=i.__P)&&((s=m({},n)).__v=n.__v+1,r.vnode&&r.vnode(s),T(l,s,n,i.__n,void 0!==l.ownerSVGElement,32&n.__u?[a]:null,h,null==a?w(n):a,!!(32&n.__u),u),s.__.__k[s.__i]=s,L(h,s,u),s.__e!=a&&A(s)),o.length>e&&o.sort(c));x.__r=0}function C(t,e,i,s,r,n,o,a,l,c,d){var p,m,g,f,v,_=s&&s.__k||u,y=e.length;for(i.__d=l,S(i,e,_),l=i.__d,p=0;p<y;p++)null!=(g=i.__k[p])&&"boolean"!=typeof g&&"function"!=typeof g&&(m=-1===g.__i?h:_[g.__i]||h,g.__i=p,T(t,g,m,r,n,o,a,l,c,d),f=g.__e,g.ref&&m.ref!=g.ref&&(m.ref&&z(m.ref,null,g),d.push(g.ref,g.__c||f,g)),null==v&&null!=f&&(v=f),65536&g.__u||m.__k===g.__k?l=M(g,l,t):"function"==typeof g.type&&void 0!==g.__d?l=g.__d:f&&(l=f.nextSibling),g.__d=void 0,g.__u&=-196609);i.__d=l,i.__e=v}function S(t,e,i){var s,r,n,o,a,l=e.length,c=i.length,h=c,u=0;for(t.__k=[],s=0;s<l;s++)null!=(r=t.__k[s]=null==(r=e[s])||"boolean"==typeof r||"function"==typeof r?null:"string"==typeof r||"number"==typeof r||"bigint"==typeof r||r.constructor==String?v(null,r,null,null,r):p(r)?v(y,{children:r},null,null,null):void 0===r.constructor&&r.__b>0?v(r.type,r.props,r.key,r.ref?r.ref:null,r.__v):r)?(r.__=t,r.__b=t.__b+1,a=I(r,i,o=s+u,h),r.__i=a,n=null,-1!==a&&(h--,(n=i[a])&&(n.__u|=131072)),null==n||null===n.__v?(-1==a&&u--,"function"!=typeof r.type&&(r.__u|=65536)):a!==o&&(a===o+1?u++:a>o?h>l-o?u+=a-o:u--:u=a<o&&a==o-1?a-o:0,a!==s+u&&(r.__u|=65536))):(n=i[s])&&null==n.key&&n.__e&&(n.__e==t.__d&&(t.__d=w(n)),R(n,n,!1),i[s]=null,h--);if(h)for(s=0;s<c;s++)null!=(n=i[s])&&!(131072&n.__u)&&(n.__e==t.__d&&(t.__d=w(n)),R(n,n))}function M(t,e,i){var s,r;if("function"==typeof t.type){for(s=t.__k,r=0;s&&r<s.length;r++)s[r]&&(s[r].__=t,e=M(s[r],e,i));return e}return t.__e!=e&&(i.insertBefore(t.__e,e||null),e=t.__e),e&&e.nextSibling}function I(t,e,i,s){var r=t.key,n=t.type,o=i-1,a=i+1,l=e[i];if(null===l||l&&r==l.key&&n===l.type)return i;if(s>(null==l||131072&l.__u?0:1))for(;o>=0||a<e.length;){if(o>=0){if((l=e[o])&&!(131072&l.__u)&&r==l.key&&n===l.type)return o;o--}if(a<e.length){if((l=e[a])&&!(131072&l.__u)&&r==l.key&&n===l.type)return a;a++}}return-1}function P(t,e,i){"-"===e[0]?t.setProperty(e,null==i?"":i):t[e]=null==i?"":"number"!=typeof i||d.test(e)?i:i+"px"}function D(t,e,i,s,r){var n;t:if("style"===e)if("string"==typeof i)t.style.cssText=i;else{if("string"==typeof s&&(t.style.cssText=s=""),s)for(e in s)i&&e in i||P(t.style,e,"");if(i)for(e in i)s&&i[e]===s[e]||P(t.style,e,i[e])}else if("o"===e[0]&&"n"===e[1])n=e!==(e=e.replace(/(PointerCapture)$|Capture$/,"$1")),e=e.toLowerCase()in t?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+n]=i,i?s?i.u=s.u:(i.u=Date.now(),t.addEventListener(e,n?E:j,n)):t.removeEventListener(e,n?E:j,n);else{if(r)e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==e&&"height"!==e&&"href"!==e&&"list"!==e&&"form"!==e&&"tabIndex"!==e&&"download"!==e&&"rowSpan"!==e&&"colSpan"!==e&&"role"!==e&&e in t)try{t[e]=null==i?"":i;break t}catch(t){}"function"==typeof i||(null==i||!1===i&&"-"!==e[4]?t.removeAttribute(e):t.setAttribute(e,i))}}function j(t){var e=this.l[t.type+!1];if(t.t){if(t.t<=e.u)return}else t.t=Date.now();return e(r.event?r.event(t):t)}function E(t){return this.l[t.type+!0](r.event?r.event(t):t)}function T(t,e,i,s,n,o,a,l,c,h){var u,d,g,f,v,_,w,A,k,x,S,M,I,P,D,j=e.type;if(void 0!==e.constructor)return null;128&i.__u&&(c=!!(32&i.__u),o=[l=e.__e=i.__e]),(u=r.__b)&&u(e);t:if("function"==typeof j)try{if(A=e.props,k=(u=j.contextType)&&s[u.__c],x=u?k?k.props.value:u.__:s,i.__c?w=(d=e.__c=i.__c).__=d.__E:("prototype"in j&&j.prototype.render?e.__c=d=new j(A,x):(e.__c=d=new b(A,x),d.constructor=j,d.render=O),k&&k.sub(d),d.props=A,d.state||(d.state={}),d.context=x,d.__n=s,g=d.__d=!0,d.__h=[],d._sb=[]),null==d.__s&&(d.__s=d.state),null!=j.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=m({},d.__s)),m(d.__s,j.getDerivedStateFromProps(A,d.__s))),f=d.props,v=d.state,d.__v=e,g)null==j.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(null==j.getDerivedStateFromProps&&A!==f&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(A,x),!d.__e&&(null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(A,d.__s,x)||e.__v===i.__v)){for(e.__v!==i.__v&&(d.props=A,d.state=d.__s,d.__d=!1),e.__e=i.__e,e.__k=i.__k,e.__k.forEach((function(t){t&&(t.__=e)})),S=0;S<d._sb.length;S++)d.__h.push(d._sb[S]);d._sb=[],d.__h.length&&a.push(d);break t}null!=d.componentWillUpdate&&d.componentWillUpdate(A,d.__s,x),null!=d.componentDidUpdate&&d.__h.push((function(){d.componentDidUpdate(f,v,_)}))}if(d.context=x,d.props=A,d.__P=t,d.__e=!1,M=r.__r,I=0,"prototype"in j&&j.prototype.render){for(d.state=d.__s,d.__d=!1,M&&M(e),u=d.render(d.props,d.state,d.context),P=0;P<d._sb.length;P++)d.__h.push(d._sb[P]);d._sb=[]}else do{d.__d=!1,M&&M(e),u=d.render(d.props,d.state,d.context),d.state=d.__s}while(d.__d&&++I<25);d.state=d.__s,null!=d.getChildContext&&(s=m(m({},s),d.getChildContext())),g||null==d.getSnapshotBeforeUpdate||(_=d.getSnapshotBeforeUpdate(f,v)),C(t,p(D=null!=u&&u.type===y&&null==u.key?u.props.children:u)?D:[D],e,i,s,n,o,a,l,c,h),d.base=e.__e,e.__u&=-161,d.__h.length&&a.push(d),w&&(d.__E=d.__=null)}catch(t){e.__v=null,c||null!=o?(e.__e=l,e.__u|=c?160:32,o[o.indexOf(l)]=null):(e.__e=i.__e,e.__k=i.__k),r.__e(t,e,i)}else null==o&&e.__v===i.__v?(e.__k=i.__k,e.__e=i.__e):e.__e=U(i.__e,e,i,s,n,o,a,c,h);(u=r.diffed)&&u(e)}function L(t,e,i){e.__d=void 0;for(var s=0;s<i.length;s++)z(i[s],i[++s],i[++s]);r.__c&&r.__c(e,t),t.some((function(e){try{t=e.__h,e.__h=[],t.some((function(t){t.call(e)}))}catch(t){r.__e(t,e.__v)}}))}function U(t,e,i,r,n,o,a,l,c){var u,d,m,f,v,_,y,b=i.props,A=e.props,k=e.type;if("svg"===k&&(n=!0),null!=o)for(u=0;u<o.length;u++)if((v=o[u])&&"setAttribute"in v==!!k&&(k?v.localName===k:3===v.nodeType)){t=v,o[u]=null;break}if(null==t){if(null===k)return document.createTextNode(A);t=n?document.createElementNS("http://www.w3.org/2000/svg",k):document.createElement(k,A.is&&A),o=null,l=!1}if(null===k)b===A||l&&t.data===A||(t.data=A);else{if(o=o&&s.call(t.childNodes),b=i.props||h,!l&&null!=o)for(b={},u=0;u<t.attributes.length;u++)b[(v=t.attributes[u]).name]=v.value;for(u in b)v=b[u],"children"==u||("dangerouslySetInnerHTML"==u?m=v:"key"===u||u in A||D(t,u,null,v,n));for(u in A)v=A[u],"children"==u?f=v:"dangerouslySetInnerHTML"==u?d=v:"value"==u?_=v:"checked"==u?y=v:"key"===u||l&&"function"!=typeof v||b[u]===v||D(t,u,v,b[u],n);if(d)l||m&&(d.__html===m.__html||d.__html===t.innerHTML)||(t.innerHTML=d.__html),e.__k=[];else if(m&&(t.innerHTML=""),C(t,p(f)?f:[f],e,i,r,n&&"foreignObject"!==k,o,a,o?o[0]:i.__k&&w(i,0),l,c),null!=o)for(u=o.length;u--;)null!=o[u]&&g(o[u]);l||(u="value",void 0!==_&&(_!==t[u]||"progress"===k&&!_||"option"===k&&_!==b[u])&&D(t,u,_,b[u],!1),u="checked",void 0!==y&&y!==t[u]&&D(t,u,y,b[u],!1))}return t}function z(t,e,i){try{"function"==typeof t?t(e):t.current=e}catch(t){r.__e(t,i)}}function R(t,e,i){var s,n;if(r.unmount&&r.unmount(t),(s=t.ref)&&(s.current&&s.current!==t.__e||z(s,null,e)),null!=(s=t.__c)){if(s.componentWillUnmount)try{s.componentWillUnmount()}catch(t){r.__e(t,e)}s.base=s.__P=null,t.__c=void 0}if(s=t.__k)for(n=0;n<s.length;n++)s[n]&&R(s[n],e,i||"function"!=typeof t.type);i||null==t.__e||g(t.__e),t.__=t.__e=t.__d=void 0}function O(t,e,i){return this.constructor(t,i)}function $(t,e,i){var n,o,a,l;r.__&&r.__(t,e),o=(n="function"==typeof i)?null:i&&i.__k||e.__k,a=[],l=[],T(e,t=(!n&&i||e).__k=f(y,null,[t]),o||h,h,void 0!==e.ownerSVGElement,!n&&i?[i]:o?null:e.firstChild?s.call(e.childNodes):null,a,!n&&i?i:o?o.__e:e.firstChild,n,l),L(a,t,l)}s=u.slice,r={__e:function(t,e,i,s){for(var r,n,o;e=e.__;)if((r=e.__c)&&!r.__)try{if((n=r.constructor)&&null!=n.getDerivedStateFromError&&(r.setState(n.getDerivedStateFromError(t)),o=r.__d),null!=r.componentDidCatch&&(r.componentDidCatch(t,s||{}),o=r.__d),o)return r.__E=r}catch(e){t=e}throw t}},n=0,b.prototype.setState=function(t,e){var i;i=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=m({},this.state),"function"==typeof t&&(t=t(m({},i),this.props)),t&&m(i,t),null!=t&&this.__v&&(e&&this._sb.push(e),k(this))},b.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),k(this))},b.prototype.render=y,o=[],l="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,c=function(t,e){return t.__v.__b-e.__v.__b},x.__r=0},318:t=>{var e="Content-Type",i="application/x-www-form-urlencoded",s="application/json; charset=utf-8";function r(t,e){return Object.assign(t.clone(),e)}var n={code:"network_error,retry",number:"SBZ-EQNETWORK",message:{En_US:"Can not connect to the server. Please check your internet connection.",Vi_VN:"Không thể kết nối tới máy chủ. Vui lòng kiểm tra lại kết nối mạng."}},o={code:"invalid_response,retry",number:"SBZ-EQRESPONSE",message:{En_US:"Server error, please try again later",Vi_VN:"Lỗi máy chủ, vui lòng thử lại sau"}},a={code:"not_200,retry",number:"SBZ-EQCN200",message:{En_US:"Error while connecting to the server, please try again later",Vi_VN:"Lỗi kết nối với máy chủ, vui lòng thử lại sau"}};function l(t){return(t||"").trim()}function c(t){return t&&"[object Function]"==={}.toString.call(t)}function h(t,e,i){if(!t||0===t.length)return i(e);var s=t.shift();if(!c(s))return h(t,e,i);s(e,(function(s){return!1===s?i(e):h(t,e,i)}))}function u(t){return encodeURIComponent(t).replace(/[!'()*]/g,(function(t){return"%"+t.charCodeAt(0).toString(16)}))}function d(t){if(!t)return"";for(var e=Object.keys(t),i=[],s=0;s<e.length;s++){var r=e[s],n="",o=t[r];if(void 0!==o){if(null===o)n=u(r);else if(Array.isArray(o)){for(var a=[],l=0;l<o.length;l++)void 0!==o[l]&&(a.push(p(r,o[l],a.length)),a.push(i));n=a.join("&")}else n=u(r)+"="+u(o);n.length>0&&i.push(n)}}return i.join("&")}function p(t,e){return null===e?u(t):[u(t),"=",u(e)].join("")}var m,g=(m={parser:"",beforehooks:[],afterhooks:[],baseurl:"",query:{},clone:function(){return Object.assign({},this,{query:Object.assign({},this.query)})},addQuery:function(t,e){var i=this.clone();return i.query[t]=e,i},removeQuery:function(t){var e=this.clone();return void 0!==e.query[t]&&(e.query[t]=void 0),e},withCredentials:function(t){return r(this,{_withCredentials:t})},setQuery:function(t){return r(this,{query:t})},clearHooks:function(){return r(this,{beforehooks:[],afterhooks:[]})},beforeHook:function(t){var e=this.beforehooks.slice();return e.push(t),r(this,{beforehooks:e})},afterHook:function(t){var e=this.afterhooks.slice();return e.push(t),r(this,{afterhooks:e})},setHeader:function(t){return(t=Object.assign({},this.headers,t))[e]=void 0,r(this,{headers:t})}},["put","head","patch","delete","post","get"].map((function(t){m[t]=function(u,p,m){return function(t,r,l){l=l||function(){},c(r)&&(l=r,r=void 0);var u,p=new Promise((function(t){u=function(e){try{l(e.error,e.body,e.code)}catch(t){}t(e)}}));return r&&((t=t.clone()).body=r,t.content_type===s&&(t.body=f.Jsonify(r)),t.content_type===i&&(t.body=d(r))),h(t.beforehooks.slice(),{request:t},(function(i){if(i.error)return u({body:{error:bq.error},code:0,error:i.error});!function(t,i){let s=d(t.query);if(s&&(s="?"+s),!f.XMLHttpRequest)return function(t,i,s){var r=Object.assign({},t.headers);t.content_type&&(r[e]=t.content_type),fetch(t.baseurl+s,{method:t.method,headers:r,credentials:t._withCredentials,body:t.body}).then((function(t){return t.text()})).then((function(t){i(void 0,t,res.status)})).catch((function(t){i("network_error",t,-1)}))}(t,i,s);var r=new f.XMLHttpRequest;for(var n in r.onreadystatechange=function(t){4===r.readyState&&(0===r.status?i("network_error",r.responseText,r.status):i(void 0,r.responseText,r.status))},r.open(t.method,t.baseurl+s),r.withCredentials=t._withCredentials,t.headers)r.setRequestHeader(n,t.headers[n]);t.content_type&&r.setRequestHeader(e,t.content_type),r.send(t.body)}(i.request,(function(e,i,s){h(t.afterhooks.slice(),{request:t,code:s,body:i,err:e},(function(e){var i=e.body;if("network_error"==r)return u({body:{error:n},code:e.code,error:n});if("json"==t.parser&&e.body)try{i=f.ParseJson(e.body)}catch(t){return u({body:{error:o,origin_body:e.body},code:e.code,error:o})}var r=e.err;if("network_error"==r)return u({body:{error:n},code:e.code,error:n});!r&&(s<200||s>299)&&(r=i&&i.error?i.error:a),u({body:r?i||{error:r}:i,code:e.code,error:r})}))}))})),p}(r(this,{method:t,baseurl:(g=this.baseurl,v=u,g=l(g),(v=l(v))&&g?v.startsWith("http://")||v.startsWith("https://")||v.startsWith("//")?v:(g.endsWith("/")||(g+="/"),v.startsWith("/")&&(v=v.substring(1)),g+v):g+v)}),p,m);var g,v}})),m.setBaseUrl=function(t){return r(this,{baseurl:t})},m.contentTypeJson=function(){return r(this,{content_type:s})},m.contentTypeForm=function(){return r(this,{content_type:i})},m.setContentType=function(t){return r(this,{content_type:l(t)})},m.setParser=function(t){return r(this,{parser:l(t)})},m.setBody=function(t){return r(this,{body:t})},m),f={Jsonify:JSON.stringify,ParseJson:JSON.parse};g.env=f,g.waterfall=h,t.exports=g},940:(t,e,i)=>{t.exports=i.p+"assets/img/rating--great.e3d712e.svg"},1108:(t,e,i)=>{t.exports=i.p+"assets/img/bubble_default.7d5e4ab.svg"},1139:(t,e,i)=>{"use strict";i.d(e,{A:()=>s});class s{constructor(t){this.isOpen=!0===t,this.cbs=[]}open(){this.isOpen=!0;let t=[];this.cbs.forEach((e=>{this.isOpen?e():t.push(e)})),this.cbs=t}close(){this.isOpen=!1}entry(t,e){return this.isOpen?(e&&(this.isOpen=!1),t&&t(),Promise.resolve()):new Promise((i=>{this.cbs.push((()=>{e&&(this.isOpen=!1),t&&t(),i()}))}))}}},1314:(t,e,i)=>{"use strict";i.d(e,{A:()=>s});const s=class{constructor(t,e){this.name=e,e+="_kv",this.dead=!1,this.db=t,this.cache={},this.initialized=!1,this.init()}refreshCache(){if(this.dead)return;let t={};this.db.all("items").forEach((function(e){t[e.key]=e.value})),this.cache=t}init(){if(this.initialized)return;let t={};console.time("KV"+this.name),this.db.all("items").forEach((function(e){t[e.key]=e.value})),this.cache=t;let e=Object.keys(this.cache);if(e.length>500){let t=250/e.lenth,s=[];for(var i=0;i<500;i++){if(Math.random()<=t)continue;let r=e[i];delete this.cache[r],s.push(r)}this.db.removes("items",[s])}this.initialized=!0,console.timeEnd("KV"+this.name)}all(){return this.dead?[]:this.initialized?this.cache:[]}match(t){if(!this.dead&&this.initialized&&t)return this.cache[t]}put(t,e){if(t){if(this.dead)return[];if(!this.initialized)throw new Error("uninitialized");this.cache[t]=e,this.db.put("items",t,{key:t,value:e})}}del(t){if(!this.dead){if(!this.initialized)throw new Error("uninitialized");delete this.cache[t],this.db.removes("items",[t])}}destroy(){this.db.clear("items"),this.dead=!0,this.db=void 0,this.cache=void 0,this.initialized=!1}}},1370:(t,e,i)=>{t.exports=i.p+"assets/img/convos_empty.2353007.svg"},1428:(t,e,i)=>{"use strict";i.d(e,{A:()=>n});let s=i(1554).A,r=window.requestIdleCallback||(t=>t());const n=class{constructor(t,e){if(this.localStorage=s,this.allkeys={},!e)try{window.localStorage.setItem("sbzstore1029","?"),window.localStorage.removeItem("sbzstore1029"),this.localStorage=window.localStorage}catch(t){}this.schema=t}all(t){let e=[];for(var i=0;i<this.localStorage.length;i++){let s=this.localStorage.key(i);s.startsWith(this.schema+"#"+t+"#")&&(this.allkeys[s]=!0,e.push(JSON.parse(this.localStorage.getItem(s))))}return e}removes(t,e){for(var i=0;i<e.length;i++)delete this.allkeys[this.schema+"#"+t+"#"+e[i]],this.localStorage.removeItem(this.schema+"#"+t+"#"+e[i])}clear(t){let e=[];for(var i=0;i<this.localStorage.length;i++){let s=this.localStorage.key(i);s.startsWith(this.schema+"#"+t+"#")&&e.push(s)}for(i=0;i<e.length;i++)this.localStorage.removeItem(e[i]);this.allkeys={}}put(t,e,i){this.allkeys[this.schema+"#"+t+"#"+e]=!0,Object.keys(this.allkeys).length>80&&this.clear(t),r((()=>{try{this.localStorage.setItem(this.schema+"#"+t+"#"+e,void 0===(s=i)?"null":JSON.stringify(s))}catch(e){this.clear(t)}var s}))}}},1554:(t,e,i)=>{"use strict";i.d(e,{A:()=>n});var s={},r={};s.length=0,s.getItem=function(t){return t in r?r[t]:null},s.setItem=function(t,e){void 0===e?s.removeItem(t):r[t]=""+e,s.length=Object.keys(r).length},s.removeItem=function(t){Object.prototype.hasOwnProperty.call(r,t)&&(delete r[t],s.length=Object.keys(r).length)},s.key=function(t){return Object.keys(r)[t]||null},s.clear=function(){r={},s.length=0};const n=s},1620:(t,e,i)=>{"use strict";i.d(e,{A:()=>a});var s=i(8150),r=i(2840),n=i(172),o=new s.A.Pubsub;s.A.setInterval((()=>o.publish("time")),2e4);class a extends r.Mw{constructor(t){super(t),this.setState({t:"",langCode:"en_US"})}updateTime(){var t="";let e="";this.props.t&&this.props.t.locale&&"function"==typeof this.props.t.locale&&(e=this.props.t.locale()),this.props.ago?(this.props.short,!t&&this.props.time>0&&(t=function(t,e,i){let s={s:"%d sec",m:"1 min",mm:"%d mins",h:"1 hour",hh:"%d hours",d:"1 day",dd:"%d days",M:"1 month",MM:"%d months",y:"1 year",yy:"%d years"};i&&(s={s:`%d ${i("second_short")}`,m:`1 ${i("minute_short")}`,mm:`%d ${i("minutes_short")}`,h:`1 ${i("hour_short")}`,hh:`%d ${i("hours_short")}`,d:`1 ${i("day_short")}`,dd:`%d ${i("days_short")}`,M:`1 ${i("month_short")}`,MM:`%d ${i("months_short")}`,y:`1 ${i("year_short")}`,yy:`%d ${i("years_short")}`});const r=s,n=[{l:"s",r:44,d:1e3},{l:"m",r:89},{l:"mm",r:44,d:6e4},{l:"h",r:89},{l:"hh",r:21,d:36e5},{l:"d",r:35},{l:"dd",r:25,d:864e5},{l:"M",r:45},{l:"MM",r:10,d:2592e6},{l:"y",r:17},{l:"yy",d:31536e6}],o=n.length;let a,l;for(let i=0;i<o;i+=1){let s=n[i];s.d&&(a=(t-e)/s.d);let o=Math.round(Math.abs(a));if(o<=s.r||!s.r){o<=1&&i>0&&(s=n[i-1]),l=r[s.l].replace("%d",o);break}}return l}(this.props.time,(new s.A.Date).getTime(),this.props.t))):t=s.A.shortTime(this.props.time,this.props.tzoffset,s.A.Date.now(),e),this.props.uppercase&&(t=t.toUpperCase()),t!==this.state.t&&this.setState({t})}componentDidMount(){o.on2(this,"time",(()=>this.updateTime())),this.updateTime()}render(){let t=s.A.get(navigator,"languages.0","en-US");this.props.t&&this.props.t.locale&&"function"==typeof this.props.t.locale&&(t=this.props.t.locale());let e=new Date(this.props.time).toLocaleString(t);return(0,n.h)("span",{class:this.props.class,style:this.props.style,title:e},this.state.t)}}},2538:(t,e,i)=>{t.exports=i.p+"assets/img/default_avatar.5b74dc1.png"},2839:(t,e,i)=>{var s=i(8193),{xhrsend:r,parseJSON:n,Pubsub:o}=i(7695);function a(t,e,i,o,a,d){a=a||r,e=e||{};var p=!1,m="";this.kill=function(){p=!0},d||(d="");var g=function(e){p||a("get",t+"poll?token="+m+"&account-id="+d,void 0,(function(s,r){if(!p){if(c(r))return setTimeout(g,l(e),e+1);if(200!==r)return p=!0,i("poll");(s=n(s)||{}).host&&(t=u(s.host));var a=s.sequential_token;return a?(m=a,o(s.events||[]),g(0)):setTimeout(g,l(e),e+1)}}))},f=s.batch(50,100,(function(r){if(p)return["dead"];if(r.length<=0)return[];var o=[];return s.loop((function(){return new Promise((function(s){var l="?token="+m;e.getAccessToken().then((function(f){e.user_ref?l+="&user_ref="+encodeURIComponent(e.user_ref):e.user_mask?l+="&user-mask="+encodeURIComponent(e.user_mask):f&&(l+="&access-token="+f);let v=t+"subs"+l+"&account-id="+encodeURIComponent(d||e.account_id);a("post",v,JSON.stringify({events:r}),(function(e,a){if(p)return o=h("dead",r.length),s(!1);if(c(a))return setTimeout(s,3e3,!0);if(200!==a)return p=!0,i("subscribe",e,a),o=h("dead",r.length),s(!1);if(m)return s(!1);var l=(e=n(e)||{}).initial_token;return l?(e.host&&(t=u(e.host)),m=l,g(0),s(!1)):setTimeout(s,3e3,!0)}))}))}))})).then((function(){return o}))}));this.subscribe=f.push.bind(f)}function l(t){if(!t||-1===t)return 0;var e=1e3*Math.pow(1.5,t);return Math.min(1e4,e)}function c(t){return t>=500&&t<600||0===t||-1===t||429===t}function h(t,e){for(var i=[],s=0;s<e;s++)i.push(t);return i}function u(t){return(t=t||"").startsWith("//")?"https:"+t:t}t.exports=function(t,e,i,s){("string"==typeof t||t instanceof String)&&(t=[t]),(e=e||{}).getAccessToken||(e.getAccessToken=function(){return Promise.resolve("")}),s||(s=e.account_id||"");var r,n=new o,l={},c=!1;this.stop=function(){r&&!c&&(c=!0,r.kill(),n.emit("interrupted"))},this.onEvent=function(t){return n.on("event",t)},this.onInterrupted=function(t){return n.on("interrupted",t)},this.subscribe=function(t){if(c)return Promise.resolve({});if("string"==typeof t&&(t=[t]),!Array.isArray(t))return Promise.resolve({error:"param should be an array or string"});for(var e=[],i=0;i<t.length;i++){var s=t[i];s&&(l[s]||e.push(r.subscribe(s)))}return 0===e.length?Promise.resolve({}):Promise.all(e).then((function(e){for(var i=0;i<e.length;i++)if(e[i])return{error:e[i]};for(var s=0;s<t.length;s++)l[t[s]]=!0;return{}}))};var h=function(){if(!c){for(var o=Object.keys(l),u=0;u<o.length;u++)l[o[u]]=!1;var d=t[Math.floor(Math.random()*t.length)];r=new a(d,e,(function(t,e,i){c||(n.emit("interrupted",t,e,i),setTimeout(h,2e3))}),(function(t){if(!c)for(var e=0;e<t.length;e++)n.emit("event",t[e])}),i,s);var p=Object.keys(l);for(u=0;u<p.length;u++)r.subscribe(p[u])}};h()}},2840:(t,e,i)=>{"use strict";i.d(e,{Dy:()=>h,JK:()=>a,Mw:()=>n,r9:()=>l,tW:()=>o});var s=i(172),r=i(8150);class n extends s.uA{constructor(t){super(t),this._isMounted=!0,r.A.setTimeout((()=>{if(this.componentWillUnmount){let t=this.componentWillUnmount.bind(this);this.componentWillUnmount=()=>{t(),this._isMounted=!1}}}),10)}}class o extends n{constructor(t){super(t),this.setWrapperRef=this.setWrapperRef.bind(this),this.onClick=this.onClick.bind(this)}componentDidMount(){document.addEventListener("mousedown",this.onClick)}componentWillUnmount(){document.removeEventListener("mousedown",this.onClick)}setWrapperRef(t){this.wrapperRef=t}onClick(t){this.wrapperRef&&!this.wrapperRef.contains(t.target)&&this.props.onClickaway&&this.props.onClickaway()}render(){return(0,s.h)("div",{ref:this.setWrapperRef},this.props.children)}}const a=(t,e)=>{e||(e="");let i=r.A.find(t.locales,(t=>t.toLowerCase().trim()===e.toLowerCase().trim()));return i||(i=r.A.find(t.locales,(t=>(t=t.replace("-","_").split("_")[0].trim().toLowerCase())==e.replace("-","_").split("_")[0].trim().toLowerCase())),i||t.locale||"en-US")};let l={},c=!1;function h(t,e,i){if(c)return new Promise((s=>r.A.setTimeout((()=>h(t,e,i).then(s)),100)));let s;return c=!0,"debug"===e||l[e]&&!i?(c=!1,Promise.resolve()):t.getLocaleContent(e).then((t=>{c=!1,s=r.A.get(t,"body.messages",[]),l[e]=s}))}},2876:(t,e,i)=>{t.exports=i.p+"assets/img/default.06e6ee0.jpg"},2959:(t,e,i)=>{"use strict";i.d(e,{A:()=>o});var s=i(8150),r=i(2840),n=i(172);class o extends r.Mw{render(){var t=this.props.emojiCode;if(s.A.size(t)<3)return null;var e=t.replace(/:/g,"");return(0,n.h)("i",{"data-tooltip":t,class:`emoji emoji--${e}`})}}},2988:(t,e,i)=>{"use strict";i.d(e,{A:()=>r});var s=i(8150);const r=class{constructor(t){this.duration=t.duration||100,this.breakingV=t.breakingV||7,this.maxY=t.maxY||500,this.minY=t.minY||0}play(t,e,i){var r;this.stop();var n=o=>{o||(o=(new s.A.Date).getTime());var a=o-r,[l,c]=this.calcY(t,e,a);if(i(l),c)return this.stop();this.animationframe=window.requestAnimationFrame(n)};this.animationframe=window.requestAnimationFrame((t=>{r=t||(new s.A.Date).getTime(),n(r)}))}calcY(t,e,i){var s,r=function(t,e,i,s){if(n(t,e))return t;var r=t+(e-t)/s*i;return(t<e&&r>e||e<t&&r<e)&&(r=e),r}(e,s=e>this.maxY?this.maxY:e<this.minY?this.minY:Math.abs(t)<this.breakingV?Math.abs(this.maxY-e)<Math.abs(this.minY-e)?this.maxY:this.minY:t<0?this.maxY:this.minY,i,this.duration);return[r,n(r,s)]}stop(){window.cancelAnimationFrame(this.animationframe)}};function n(t,e){return Math.abs(t-e)<=.001}},3118:(t,e,i)=>{"use strict";i.d(e,{A:()=>s});class s{constructor(t,e,i){this.schema=e+"_chain",this.dead=!1,this.db=t,this.anchorCache={},this.cache={},this.init()}init(){let t={};this.db.all("items").map((e=>{t[e.chain]=t[e.chain]||{},t[e.chain][e.id]={id:e.id,chain:e.chain,full_id:e.full_id,index:e.index,value:e.value}})),n(t,((e,i)=>{if(((s=e)?void 0!==s.length?s.length:Object.keys(s).length:0)<50)return;var s;let r=(o=n(e),a=["index"],l=[],n(o,(t=>l.push(t))),l.sort(((t,e)=>{if(t[a]===e[a])return 0;var i=t[a]<e[a]?-1:1;return-i})),l);var o,a,l;let c=[];for(var h=50;h<r.length;h++)c.push(r[h].full_id),delete e[r[h].id];this.db.removes("items",c),t[i]=e})),this.cache=t}destroy(){this.db.clear("items"),this.dead=!0,this.cache={},this.anchorCache={},this.db=void 0}put(t,e,i,s){if(this.dead)return;let n=this.cache[t]||{},o=(r(n)||{}).index||"z",a={id:e,index:i,value:s,chain:t,full_id:t+":"+e};delete n[a.id],o>a.index+""||(n[a.id]=a,this.cache[t]=n,this.db.put("items",a.full_id,a))}listM(t){if(this.dead)return{};let e=this.cache[t]||{},i={};return n(e,((t,e)=>{i[e]=t.value})),i}async fetchMore(t,e=20,i){if(this.dead)return{error:"dead"};if(!i)return{error:"no api"};let s=this.anchorCache[t]||"";var[r,n,o]=await i(t,s,e);if(o)return{error:o};if(this.dead)return{error:"dead"};let a=this.cache[t]||{};return 0===r.length?{end:!0}:(r.forEach((e=>{e.chain=t,e.full_id=t+":"+e.id,a[e.id]=e,this.db.put("items",e.full_id,e)})),this.anchorCache[t]=n,this.cache[t]=a,{})}del(t,e){if(this.dead)return;let i=t+":"+e;delete(this.cache[t]||{})[e],this.db.removes("items",[i])}match(t,e){return this.listM(t)[e]}async reload(t,e){if(this.dead)return;let i=function(t){if(!t)return;let e=Object.keys(t);if(!e.length)return;let i=-1/0,s=Object.keys(t)[0];for(var r=0;r<e.length;r++){let n=t[e[r]]&&t[e[r]].index||-1/0;n>i&&(i=n,s=e[r])}return t[e[s]]}(this.listM(t))||{},s=i.index;s||(s=Date.now());for(var o="",a={};;){if(this.dead)return;let[i,l,c]=await e(t,o,50);if(c)return;if(this.dead)return;if(i.map((e=>{a[e.id]=Object.assign({},e,{chain:t,full_id:t+":"+e.id})})),0===i.length||l===o)break;if(a.length>=200){let e=this.cache[t]||{},i=[];n(e,(e=>{e.chain===t&&i.push(e.full_id)})),this.db.removes("items",i),this.cache[t]={};break}if((r(a)||{}).index<=s){o=this.anchorCache[t]||l;break}o=l}for(var l=0;l<Object.keys(a).length;l++){let t=a[Object.keys(a)[l]];this.db.put("items",t.full_id,t),this.cache[t.chain]=this.cache[t.chain]||{},this.cache[t.chain][t.id]=t}this.anchorCache[t]=o}}function r(t){if(!t)return;let e=Object.keys(t);if(!e.length)return;let i=1/0,s=Object.keys(t)[0];for(var r=0;r<e.length;r++){let n=t[e[r]]&&t[e[r]].index||1/0;n<i&&(i=n,s=e[r])}return t[s]}function n(t,e){if(!t)return[];if(!e)return t;var i=[];if(Array.isArray(t)){for(let s=0;s<t.length;s++)i.push(e(t[s],s));return i}if("object"==typeof t){var s=Object.keys(t);for(let n=0;n<s.length;n++){var r=s[n];i.push(e(t[r],r))}return i}return i}},3259:(t,e,i)=>{"use strict";i.r(e),i.d(e,{get:()=>a,set:()=>l});var s=Object.prototype.toString,r=Array.isArray||function(t){return"[object Array]"===s.call(t)};function n(t){var e=parseInt(t);return e.toString()===t?e:t}function o(t,e){if(function(t,e){return"number"==typeof e&&r(t)||function(t,e){return null!=t&&Object.prototype.hasOwnProperty.call(t,e)}(t,e)}(t,e))return t[e]}function a(t,e,i){if("number"==typeof e&&(e=[e]),!e||0===e.length)return t;if(null==t)return i;if("string"==typeof e)return a(t,e.split("."),i);var s=n(e[0]),r=o(t,s);return void 0===r?i:1===e.length?r:a(t[s],e.slice(1),i)}function l(t,e,i){if("number"==typeof e&&(e=[e]),!e||0===e.length)return t;if("string"==typeof e)return l(t,e.split(".").map(n),i);var s=e[0],r=o(t,s);return 1===e.length?(t[s]=i,r):(void 0===r&&(t[s]="number"==typeof e[1]?[]:{}),l(t[s],e.slice(1),i))}},3266:(t,e,i)=>{t.exports=i.p+"assets/img/external-link.90577cc.svg"},3582:(t,e,i)=>{t.exports=i.p+"assets/img/image_default.be0698b.png"},4188:(t,e,i)=>{"use strict";i.d(e,{A:()=>o});var s=i(2840),r=i(172);const n=i(6973);class o extends s.Mw{render(){(this.props.mode+"").toLowerCase();let t=this.props.size||14,e=(Math.ceil(t/14),`width: ${t}px !important;height: ${t}px !important;`);return this.props.center?(0,r.h)("div",{class:"loading"},(0,r.h)("img",{alt:"loading",style:e,src:n})):(0,r.h)("img",{alt:"loading",style:e,src:n})}}},5180:t=>{t.exports={ApiURL:"https://api.sbz.vn/4.0",RealtimeURL:"https://api.sbz.vn/rt/0/",FileURL:"https://vcdn.subiz-cdn.com/file/",BaseURL:"https://widget.sbz.vn"}},5219:(t,e,i)=>{var s=i(9096);t.exports=function(t,e,i){if("number"==typeof e){let t=i;i=e,e=t}e||(e=function(){}),("number"!=typeof i||i<=0)&&(i=1);var r={};if(s.map(t,(function(t,e){r[e]=t})),i<=0&&(i=1),0===Object.keys(r).length)return Promise.resolve([]);Object.keys(r).length<i&&(i=Object.keys(r).length);var n={};return new Promise((function(t){let o=Object.keys(r).length;for(var a=function(){var i=Object.keys(r);if(0!==i.length){var l=i.shift(),c=r[l];delete r[l];var h=e(c,l);h&&h.then||(h=Promise.resolve(h)),h.then((function(e){if(n[l]=e,Object.keys(n).length===o)return t(s.map(n));a()}))}},l=0;l<i;l++)setTimeout(a,1)}))}},5369:(t,e,i)=>{"use strict";i.d(e,{A:()=>s});class s{constructor(){this.isOpen=!0,this.cbs=[]}_check(){if(!this.isOpen)return;let t=this.cbs.pop();t&&(this.isOpen=!1,t())}lock(){return new Promise((t=>{this.cbs.push(t),this._check()}))}unlock(){this.isOpen||(this.isOpen=!0,this._check())}}},5672:function(t){t.exports=function(){"use strict";var t=function(){return t.get.apply(t,arguments)},e=t.utils={isArray:Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},isPlainObject:function(t){return!!t&&"[object Object]"===Object.prototype.toString.call(t)},toArray:function(t){return Array.prototype.slice.call(t)},getKeys:Object.keys||function(t){var e=[],i="";for(i in t)t.hasOwnProperty(i)&&e.push(i);return e},encode:function(t){return String(t).replace(/[,;"\\=\s%]/g,(function(t){return encodeURIComponent(t)}))},decode:function(t){return decodeURIComponent(t)},retrieve:function(t,e){return null==t?e:t}};return t.defaults={},t.expiresMultiplier=86400,t.set=function(t,i,s){if(e.isPlainObject(t))for(var r in t)t.hasOwnProperty(r)&&this.set(r,t[r],i);else{var n=void 0!==(s=e.isPlainObject(s)?s:{expires:s}).expires?s.expires:this.defaults.expires||"",o=typeof n;"string"===o&&""!==n?n=new Date(n):"number"===o&&(n=new Date(+new Date+1e3*this.expiresMultiplier*n)),""!==n&&"toUTCString"in n&&(n=";expires="+n.toUTCString());var a=s.path||this.defaults.path;a=a?";path="+a:"";var l=s.domain||this.defaults.domain;l=l?";domain="+l:"";var c=s.secure||this.defaults.secure?";secure":"";!1===s.secure&&(c="");var h=s.sameSite||this.defaults.sameSite;h=h?";SameSite="+h:"",null===s.sameSite&&(h=""),document.cookie=e.encode(t)+"="+e.encode(i)+n+a+l+c+h}return this},t.setDefault=function(i,s,r){if(e.isPlainObject(i)){for(var n in i)void 0===this.get(n)&&this.set(n,i[n],s);return t}if(void 0===this.get(i))return this.set.apply(this,arguments)},t.remove=function(t){for(var i=0,s=(t=e.isArray(t)?t:e.toArray(arguments)).length;i<s;i++)this.set(t[i],"",-1);return this},t.removeSpecific=function(t,i){if(!i)return this.remove(t);t=e.isArray(t)?t:[t],i.expires=-1;for(var s=0,r=t.length;s<r;s++)this.set(t[s],"",i);return this},t.empty=function(){return this.remove(e.getKeys(this.all()))},t.get=function(t,i){var s=this.all();if(e.isArray(t)){for(var r={},n=0,o=t.length;n<o;n++){var a=t[n];r[a]=e.retrieve(s[a],i)}return r}return e.retrieve(s[t],i)},t.all=function(){if(""===document.cookie)return{};for(var t=document.cookie.split("; "),i={},s=0,r=t.length;s<r;s++){var n=t[s].split("="),o=e.decode(n.shift()),a=e.decode(n.join("="));i[o]=a}return i},t.enabled=function(){if(navigator.cookieEnabled)return!0;var e="_"===t.set("_","_").get("_");return t.remove("_"),e},t}()},6463:(t,e,i)=>{"use strict";i.d(e,{A:()=>n});var{filter:s,map:r}=i(9917);class n{constructor(){this.listeners={}}publish(t,e,i,n){this.listeners[t]=s(this.listeners[t],(t=>t.obj._isMounted)),r(this.listeners[t],(({cb:t})=>t(e,i,n)))}on2(t,e,i){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push({obj:t,cb:i})}}},6973:(t,e,i)=>{t.exports=i.p+"assets/img/loading_static.a27f0ac.svg"},7072:(t,e,i)=>{"use strict";i.d(e,{A:()=>a});var s=i(8150),r=i(2959),n=i(2840),o=i(172);class a extends n.Mw{constructor(t){super(t)}renderBlock(t){if(0==s.A.size(t))return null;let e={style:""};if(t.style&&s.A.map(t.style,((t,i)=>{e.style+=i+": "+t+";"})),e.attrs={},""!=t.title&&(e.attrs.title=t.title),""!=t.href&&(e.attrs.href=t.href),e.class=t.class,s.A.map(t.attrs,((t,i)=>{e.attrs[i]=t})),"bullet_list"!=t.type&&"ordered_list"!=t.type||("bullet_list"==t.type?e.tag="ol":e.tag="ul"),"list_item"==t.type&&(e.tag="li"),"heading"==t.type&&(t.level<1&&(t.level=1),t.level>6&&(t.level=6),e.tag="h"+t.level),"paragraph"!=t.type&&"section"!=t.type&&"div"!=t.type||(e.tag="div"),e.text=t.text,""!=t.type&&"text"!=t.type&&"dynamic-field"!=t.type||(e.tag="span",t.bold&&(e.tag="b"),t.italic&&("b"==e.tag?e.style+="font-style: italic;":e.tag="em"),t.underline&&(e.Style+="text-decoration:underline;"),t.strike_through&&(e.Style+="text-decoration: line-through;")),"dynamic-field"==t.type){let i=s.A.get(t.attrs,"key");e.text=s.A.get(this.props.data,[i],e.text)}if("link"==t.type&&(e.tag="a",e.attrs.href=t.href,e.attrs.target=t.target,e.attrs.title=t.title),"mention-agent"==t.type||"mention"==t.type){e.tag="span",e.class="mention";let i=t.attrs.id="";if("*"!=t.attrs.id&&"all"!=t.attrs.id||(e.text="@"+this.$t("all")),i.startsWith("ag")){let t=store.matchAgent(i),r=s.A.getAgentDisplayName(t,insert.mention.fullname);e.text="@"+r}}if("horizontal_rule"==t.type&&(e.tag="hr"),"emoji"==t.type){let i="";s.A.size(t.attrs)>0&&(i=t.attrs.code),""==i&&(i=t.Text),""!=i&&(e.tag="Emoji",e.attrs.emojiCode=i)}if("table"==t.type)return null;let i=null;switch(i=s.A.size(t.content)?s.A.map(t.content,(t=>this.renderBlock(t))):"text"===t.type?s.A.extractText(e.text).map((t=>{if("link"===t.type){let e=t.text||"";return e.startsWith("//")||e.startsWith("https://")||e.startsWith("http://")||e.startsWith("data:")||(e="//"+e),(0,o.h)("a",{href:e,target:"_blank",onClick:t=>this.props.onLink(t,e)},t.text)}return"phone"===t.type?(0,o.h)("a",{href:"tel:"+t.text},t.text):"email"===t.type?(0,o.h)("a",{href:"mailto:"+t.text},t.text):t.text})):e.text,e.tag){case"div":return(0,o.h)("div",null,i);case"h1":return(0,o.h)("h1",null,i);case"h2":return(0,o.h)("h2",null,i);case"h3":return(0,o.h)("h3",null,i);case"h4":return(0,o.h)("h4",null,i);case"h5":return(0,o.h)("h5",null,i);case"h6":return(0,o.h)("h6",null,i);case"ol":return(0,o.h)("ol",null,i);case"ul":return(0,o.h)("ul",null,i);case"span":return(0,o.h)("span",null,i);case"em":return(0,o.h)("em",null,i);case"b":return(0,o.h)("b",null,i);case"hr":return(0,o.h)("hr",null);case"a":return(0,o.h)("a",{href:e.attrs.href,target:e.attrs.target,title:e.attrs.title},i);case"Emoji":return(0,o.h)(r.A,{emojiCode:e.attrs.emojiCode})}return null}render(){return this.renderBlock(this.props.block)}}},7134:(t,e,i)=>{t.exports=i.p+"assets/img/rating--average.1ea492c.svg"},7695:t=>{function e(t){return t<10?`0${t}`:`${t}`}var i=function(t,e,i,s){if("undefined"==typeof XMLHttpRequest)return function(t,e,i,s){let r={};i&&(r["content-type"]="text/plain"),fetch(e,{method:t,headers:r,body:i}).then((t=>t.text().then((e=>s&&s(e,t.status))))).catch((t=>s&&s(t,-1)))}(t,e,i,s);var r=new XMLHttpRequest;r.onreadystatechange=function(t){4===r.readyState&&(s&&s(r.responseText,r.status),s=void 0)},r.onerror=function(){s&&s(r.responseText,-1),s=void 0},r.open(t,e),i&&r.setRequestHeader("content-type","text/plain"),r.send(i)};t.exports={xhrsend:i,parseJSON:function(t){try{return JSON.parse(t)}catch(t){}},Pubsub:function(){var t={};this.emit=function(e){for(var i=[],s=1;s<arguments.length;s++)i.push(arguments[s]);var r=t[e];if(r)for(s=0;s<r.length;s++)r[s].apply(void 0,i)},this.on=function(e,i){t[e]||(t[e]=[]),t[e].push(i)}},randomString:function(t,e){var i,s="";(!t||t<1)&&(t=10);for(var r=0;r<t;r++)e?s+=e[Math.floor(Math.random()*e.length)]:(i=Math.floor(25*Math.random()+97),s+=String.fromCharCode(i));return s},logError:function(t,s,r,n){let o=function(t){let i=t.getUTCFullYear().toString().substr(2,2),s=t.getUTCMonth()+1,r=t.getUTCDate(),n=t.getUTCHours(),o=t.getUTCMinutes(),a=t.getUTCSeconds();return`${i}-${e(s)}-${e(r)} ${e(n)}:${e(o)}:${e(a)}`}(new Date),a=JSON.stringify({id:Date.now(),class:400,code:"frontend_error",number:n.split("").map((t=>t.charCodeAt(0).toString(16).padStart(2,"0"))).join(""),fields:{message:JSON.stringify(r),user_id:s,url:JSON.stringify(location.href)}});i("POST","https://track.subiz.net/collect",`${o} app ERROR dashboard ${t} ${n} ${a}`)}}},8150:(t,e,i)=>{"use strict";i.d(e,{A:()=>m});var s={};i.r(s),i.d(s,{trackAreaClicked:()=>l,trackExitIntent:()=>o,trackInactivity:()=>c,trackScrollingPercentage:()=>a,trackTimeOnPage:()=>u});var r=i(9917),n=i(9917);function o(t){let e=i=>{i.clientY>10||(t&&t(),document.removeEventListener("mouseout",e))};document.addEventListener("mouseout",e)}function a(t,e){let i=s=>{let r=s.srcElement.scrollingElement?s.srcElement.scrollingElement.scrollTop:s.srcElement.scrollTop,n=s.srcElement.scrollingElement?s.srcElement.scrollingElement.scrollHeight:s.srcElement.scrollHeight;r>0&&n>0&&(r+window.innerHeight)/n>=t&&(e&&e(),window.removeEventListener("scroll",i,!1))};window.addEventListener("scroll",i,!1)}function l(t,e){t&&(t=t||"",n.map(t.split("\n"),(t=>{(t=n.trim(t))&&function(t,e,i){document.addEventListener("click",(function(t){let s=document.querySelectorAll(e),r=t.target;for(let e=0,n=s.length;e<n;e++){let n=r,o=s[e];for(;n&&n!==document;){if(n===o)return i.call(o,t);n=n.parentNode}}}))}(0,t,e)})))}function c(t=0,e){let i=["scroll","keyup","keydown","mousemove","mousewheel","mouseenter","mouseover","mousedown","touchstart","touchmove","touchenter"],s=0,r=()=>{s=0},o=n.setInterval((()=>{if(s++,!(s<t)){e&&e();for(let t of i)document.removeEventListener(t,r,!1);n.clearInterval(o)}}),1e3);for(let t of i)document.addEventListener(t,r,!1)}let h=0;function u(t=0,e){if(t<1)return n.setTimeout((function(){e(t)}),100);let i=n.setInterval((()=>{h<t||(e&&e(h),n.clearInterval(i))}),1e3)}n.setInterval((()=>{h+=5}),5e3);var d={};(d=Object.assign(d,r)).Gate=i(1139).A,d.Mutex=i(5369).A;var p=i(3259);d.get=p.get,d.set=p.set,d.Pubsub=i(6463).A;const m=d=Object.assign(d,s)},8193:(t,e,i)=>{var s=i(9798),r=i(9143),n=i(5219),o=i(9);t.exports={sleep:s,loop:r,map:n,batch:o}},8506:(t,e,i)=>{t.exports=i.p+"assets/img/send.6db52a9.svg"},9096:t=>{t.exports={map:function(t,e){if(!t)return[];e||(e=function(t){return t});var i=[];if(Array.isArray(t)){for(var s=0;s<t.length;s++)i.push(e(t[s],s));return i}if("object"==typeof t){var r=Object.keys(t);for(s=0;s<r.length;s++){var n=r[s];i.push(e(t[n],n))}return i}return i}}},9143:t=>{t.exports=function t(e){var i=e();if(!i||!i.then){var s=i;i={then:function(t){t(s)}}}return i.then((function(i){return i?t(e):Promise.resolve()}))}},9150:(t,e,i)=>{t.exports=i.p+"assets/img/done_gray.d7e8203.svg"},9419:(t,e,i)=>{t.exports=i.p+"assets/img/empty.29bed2d.svg"},9529:(t,e,i)=>{t.exports=i.p+"assets/img/subiz-mono.8fbc067.svg"},9798:t=>{t.exports=function(t){return new Promise((function(e){setTimeout(e,t)}))}},9801:(t,e,i)=>{t.exports=i.p+"assets/img/rating--poor.2938a25.svg"},9917:(t,e,s)=>{"use strict";s.r(e),s.d(e,{DEFVAL:()=>dt,DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL:()=>ut,Date:()=>y,XMLHttpRequest:()=>C,agentsOfConvo:()=>O,blockToText:()=>Lt,checkRunConditions:()=>gt,clearInterval:()=>k,clearTimeout:()=>x,cloneDeep:()=>D,convoOfEv:()=>S,convoToEv:()=>M,detectLang:()=>Mt,diffDay:()=>wt,diffYear:()=>At,each:()=>U,extract:()=>u,extractEmails:()=>c,extractEmojis:()=>a,extractLinks:()=>l,extractPhones:()=>h,extractText:()=>p,filter:()=>E,find:()=>H,formatCurrency:()=>Dt,getAgentDisplayName:()=>tt,getDayName:()=>ft,getMs:()=>St,getUrlParameter:()=>It,getUserAttr:()=>st,hslToRgb:()=>o,includes:()=>T,isConvoSeen:()=>R,isEmail:()=>K,isNumber:()=>Y,isPhone:()=>Q,isURL:()=>X,isUserBanned:()=>et,js2css:()=>pt,last:()=>Z,map:()=>L,merge:()=>P,noop:()=>nt,norm:()=>rt,offsetToMin:()=>bt,orderBy:()=>N,orderByF:()=>J,parseJSON:()=>m,pipeExtracts:()=>d,preloadImg:()=>yt,preloadWebfonts:()=>_t,randomString:()=>j,replaceAll:()=>q,replaceCssVariable:()=>lt,replaceCssVariablePlugin:()=>at,requestAnimationFrame:()=>b,rgbToHsl:()=>n,sameDay:()=>kt,scrollIntoViewIfNeeded:()=>Et,setCss:()=>ht,setInterval:()=>A,setTimeout:()=>w,setUserAttr:()=>it,shortTime:()=>xt,size:()=>F,sleep:()=>Pt,startsWith:()=>$,stringify:()=>v,throttle:()=>G,tokenize:()=>ct,trim:()=>W,trimStart:()=>B,unicodeToAscii:()=>jt,unixSec:()=>Ct,usersOfConvo:()=>z});var r=s(3259);function n(t,e,i){t/=255,e/=255,i/=255;var s,r,n=Math.max(t,e,i),o=Math.min(t,e,i),a=(n+o)/2;if(n==o)s=r=0;else{var l=n-o;switch(r=a>.5?l/(2-n-o):l/(n+o),n){case t:s=(e-i)/l+(e<i?6:0);break;case e:s=(i-t)/l+2;break;case i:s=(t-e)/l+4}s/=6}return[s,r,a]}function o(t,e,i){var s,r,n;if(0==e)s=r=n=i;else{function l(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}var o=i<.5?i*(1+e):i+e-i*e,a=2*i-o;s=l(a,o,t+1/3),r=l(a,o,t),n=l(a,o,t-1/3)}return[255*s,255*r,255*n]}function a(t){for(var e=[],i=0;i<t.length;i++)for(var s=0;s<zt.length;s++)if(t.indexOf(zt[s],i)===i){e.push({index:i,length:zt[s].length}),i+=zt[s].length-1;break}return e}function l(t){t=t||"";for(var e,i=/(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9@:%_\+.,~#?&//=]*)/gim,s=[];e=i.exec(t);)s.push({index:e.index,length:i.lastIndex-e.index});return s}function c(t){t=t||"";for(var e,i=/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/gim,s=[];e=i.exec(t);)s.push({index:e.index,length:i.lastIndex-e.index});return s}function h(t){t=t||"";for(var e="",i={},s=0;s<t.length;s++){var r=t.charAt(s);if("."===r||"-"===r||" "===r){var n=s>0?t.charAt(s-1):"-",o=s<t.length-1?t.charAt(s+1):"-";-1!=="0123456789".indexOf(n)&&-1!=="0123456789".indexOf(o)||(i[(e+=r).length-1]=s)}else i[(e+=r).length-1]=s}for(var a,l=/([0-9]{8,13})/gim,c=[];a=l.exec(e);)c.push({index:i[a.index],length:i[l.lastIndex-1]-i[a.index]+1});return c}function u(t,e,i){if(!t)return[];var s=[],r=0,n=e(t);if(0===F(n))return[{type:"text",text:t}];U(n,(e=>{s.push({type:"text",text:t.substr(r,e.index-r)}),s.push({type:i,text:t.substr(e.index,e.length)}),r=e.index+e.length}));var o=Z(n);return s.push({type:"text",text:t.substr(o.index+o.length,t.length-o.index+o.length)}),E(s,(t=>""!==t.text))}function d(t,e){var i=[];if(0===F(e))return[{type:"text",text:t}];var s=e.shift();return U(u(t,s,s.type),(t=>{if("text"!==t.type)return i.push(t);i=i.concat(d(t.text,e.slice()))})),i}function p(t){var e=l;e.type="link";var i=c;i.type="email";var s=h;s.type="phone";var r=a;return r.type="emoji",d(t,[e,i,s,r])}function m(t){try{return _(t)}catch(t){}}var g=document.createElement("iframe");g.style.display="none",document.documentElement.appendChild(g);const f=g.contentDocument.createElement("div");g.contentDocument.body.appendChild(f);var v=g.contentWindow.JSON.stringify,_=g.contentWindow.JSON.parse,y=g.contentWindow.Date,b=g.contentWindow.requestAnimationFrame,w=g.contentWindow.setTimeout.bind(g.contentWindow),A=g.contentWindow.setInterval.bind(g.contentWindow),k=g.contentWindow.clearInterval.bind(g.contentWindow),x=g.contentWindow.clearTimeout.bind(g.contentWindow),C=g.contentWindow.XMLHttpRequest;function S(t){return t?r.get(t,"data.conversation.id",r.get(t,"data.message.conversation_id")):""}function M(t,e){if(!e)return"";switch(e.type){case"message_sent":case"message_updated":case"message_pong":return r.set(e,"data.message.conversation_id",t);case"ticket_updated":return r.set(e,"data.ticket.conversation_id",t);default:return r.set(e,"data.conversation.id",t)}}function I(t){return t&&"object"==typeof t&&!Array.isArray(t)}function P(t,...e){if(!e.length)return t;const i=e.shift();if(I(t)&&I(i))for(const e in i)I(i[e])?(t[e]||Object.assign(t,{[e]:{}}),P(t[e],i[e])):Object.assign(t,{[e]:i[e]});return P(t,...e)}function D(t){if(t!==Object(t))return t;var e=v(t);return void 0!==e?_(e):void 0}function j(t){var e,i="";(!t||t<1)&&(t=10);for(var s=0;s<t;s++)e=Math.floor(25*Math.random()+97),i+=String.fromCharCode(e);return i}function E(t,e){if(!t)return[];if(!e)return t;var i=[];if(Array.isArray(t)){for(let s=0;s<t.length;s++)e(t[s],s)&&i.push(t[s]);return i}if("object"==typeof t){var s=Object.keys(t);for(let n=0;n<s.length;n++){var r=s[n];e(t[r],r)&&i.push(t[r])}return i}return i}function T(t,e){if(!t)return!1;var i="string"==typeof t||t instanceof String;return!(!Array.isArray(t)&&!i)&&t.includes(e)}function L(t,e){if(!t)return[];e||(e=t=>t);var i=[];if(Array.isArray(t)){for(let s=0;s<t.length;s++)i.push(e(t[s],s));return i}if("object"==typeof t){var s=Object.keys(t);for(let n=0;n<s.length;n++){var r=s[n];i.push(e(t[r],r))}return i}return i}function U(t,e){return L(t,e)}function z(t){return t?L(E(t.members,(t=>"user"===t.type)),(t=>t.id)):[]}function R(t,e){if("ended"===t.state)return!0;let i=t.last_message_sent;if(!i)return!0;if(r.get(i,"by.id")===e)return!0;let s=H(t.members,(t=>t.id===e));return!s||St(i.created)<St(s.seen_at)}function O(t,e){return t?L(E(t.members,(t=>e?"agent"===t.type||"bot"===t.type:"agent"===t.type)),(t=>t.id)):[]}function $(t,e){return((t||"")+"").startsWith(e)}function F(t){return t?void 0!==t.length?t.length:Object.keys(t).length:0}function q(t,e,i){return(t||"").split(e).join(i)}function W(t,e){return((t||"")+"").replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}function B(t,e){for(t=(t||"")+"";t.charAt(0)===e;)t=t.substr(1);return t}function G(t,e,i){var s,r,n,o=null,a=0;i||(i={});var l=function(){a=!1===i.leading?0:(new y).getTime(),o=null,n=t.apply(s,r),o||(s=r=null)};return function(){var c=(new y).getTime();a||!1!==i.leading||(a=c);var h=e-(c-a);return s=this,r=arguments,h<=0||h>e?(o&&(x(o),o=null),a=c,n=t.apply(s,r),o||(s=r=null)):o||!1===i.trailing||(o=w(l,h)),n}}function H(t,e){if(t)return t[V(t,e)]}function V(t,e){if(!t)return-1;if(!e)return-1;if(Array.isArray(t)){for(let i=0;i<t.length;i++)if(e(t[i],i))return i;return-1}if("object"==typeof t){var i=Object.keys(t);for(let r=0;r<i.length;r++){var s=i[r];if(e(t[s],s))return s}}return-1}function N(t,e,i){var s=[];return U(t,(t=>s.push(t))),s.sort(((t,s)=>{if(t[e]===s[e])return 0;var r=t[e]<s[e]?-1:1;return"desc"===i?-r:r})),s}function J(t,e,i){var s=[];return U(t,(t=>s.push(t))),s.sort(((t,s)=>{let r=e(t),n=e(s);if(r===n)return 0;var o=r<n?-1:1;return"desc"===i?-o:o})),s}function Q(t){return/^[\+]?[(]?[0-9]{2,3}[)]?[-\s\.]?[0-9]{3,4}[-\s\.]?[0-9]{4,6}$/im.test(String(t))}function X(t){return/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi.test(String(t).toLowerCase())}function Y(t){return/^\d+$/.test(String(t))}function K(t){return/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(t).toLowerCase())}function Z(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}function tt(t,e){return r.get(e,"fullname")||r.get(e,"email")||r.get(t,"name")||"Agent"}function et(t){return st(t,"is_ban","boolean")}function it(t,e){if(t&&r.get(e,"key")){t.attributes=t.attributes||[];var i=V(t.attributes,(t=>t&&t.key===e.key));-1!==i?t.attributes[i]=e:t.attributes.push(e)}}function st(t,e,i){if(!t||!t.attributes)return;let s;return U(t.attributes,(t=>{t&&t.key===e&&("datetime"===i&&(s=t.datetime),"boolean"===i&&(s=t.boolean),"number"===i&&(s=t.number),"text"===i&&(s=t.text),"list"===i&&(s=[t.text].concat(t.other_values)))})),s}function rt(t){return(t=t||"").trim().toLowerCase()}function nt(){}function ot(t){return("string"==typeof t||t instanceof String)&&(t=t.trim().replace(/;+$/,"")),t}function at(t,e){var i=[t];let s=e.spacer||10;e=Object.assign({},e,{spacer:s+"px",spacer0:s/2+"px",spacer2:2*s+"px",spacer3:3*s+"px"}),i=ct(i,"'@font_family'"),i=ct(i,"'@font_size'"),i=ct(i,"'@text_color'"),i=ct(i,"'@faded_text_color'"),i=ct(i,"'@primary_color'"),i=ct(i,"'@background'"),i=ct(i,"'@spacer'"),i=ct(i,"'@spacer0'"),i=ct(i,"'@spacer2'"),i=ct(i,"'@spacer3'");let a=Ut(r.get(e,"primary_color")||r.get(dt,"primary_color"));a||(a={red:238,blue:238,green:238});let l=n(a.red,a.green,a.blue)[0],[c,h,u]=o(l,.5,.95);dt.primary_color_faded=`rgb(${c},${h},${u})`;for(var d=[],p=0;p<i.length;p++){var m=i[p];if("string"!=typeof m){var g=m.type.substr(2,m.type.length-3),f=r.get(e,g)||r.get(dt,g)||"";d.push(f)}else d.push(m)}return d.join("")}function lt(t,e){var i=[t];i=ct(i,"'@primary_color'"),i=ct(i,"'@primary_color_faded'"),i=ct(i,"@esc-primary-color-esc"),i=ct(i,"'@secondary_color'"),i=ct(i,"'@background'"),i=ct(i,"'@text_color'"),i=ct(i,"'@width'"),i=ct(i,"'@height'"),i=ct(i,"'@desktop_button.width'"),i=ct(i,"'@desktop_button.height'"),i=ct(i,"'@desktop_button.background'"),i=ct(i,"'@desktop_button.border_radius'"),i=ct(i,"'@desktop_button.margin_x'"),i=ct(i,"'@desktop_button.margin_y'"),i=ct(i,"'@mobile_button.width'"),i=ct(i,"'@mobile_button.height'"),i=ct(i,"'@mobile_button.background'"),i=ct(i,"'@mobile_button.border_radius'"),i=ct(i,"'@mobile_button.margin_x'"),i=ct(i,"'@mobile_button.margin_y'"),i=ct(i,"'@widget_position'"),i=ct(i,"'@z_index'"),i=ct(i,"'@z_index_2'"),i=ct(i,"'@z_index_3'"),i=ct(i,"'@z_index_4'"),i=ct(i,"'@z_index_5'");let s=Ut(r.get(e,"primary_color")||r.get(dt,"primary_color"));s||(s={red:238,blue:238,green:238});let a=n(s.red,s.green,s.blue)[0],[l,c,h]=o(a,.5,.95);dt.primary_color_faded=`rgb(${l},${c},${h})`;for(var u=[],d=0;d<i.length;d++){var p=i[d];if("string"!=typeof p)if("@esc-primary-color-esc"!==p.type)if("'@z_index_2'"!==p.type)if("'@z_index_3'"!==p.type)if("'@z_index_4'"!==p.type)if("'@z_index_5'"!==p.type){var m=p.type.substr(2,p.type.length-3);g=ot(g=r.get(e,m)||r.get(dt,m)||""),["mobile_button.width","mobile_button.height","mobile_button.margin_x","mobile_button.margin_y","desktop_button.width","desktop_button.height","desktop_button.margin_x","desktop_button.margin_y","width","height"].includes(m)&&(g+="px"),"height"!==m||"full"!==r.get(e,"window_mode")?u.push(g):u.push("100%")}else g=r.get(e,"z_index")||r.get(dt,"z_index"),u.push(g+5);else g=r.get(e,"z_index")||r.get(dt,"z_index"),u.push(g+4);else{var g=r.get(e,"z_index")||r.get(dt,"z_index");u.push(g+3)}else{g=r.get(e,"z_index")||r.get(dt,"z_index");u.push(g+2)}else{g=r.get(e,"primary_color")||r.get(dt,"primary_color");u.push(encodeURIComponent(ot(g)))}else u.push(p)}return u.join("")}function ct(t,e){if(!t||!t.length)return[];var i=[];for(let n=0;n<t.length;n++){var s=t[n];if("string"==typeof s){var r=s.split(e);for(let t=0;t<r.length;t++)i.push(r[t]),i.push({type:e});i.pop()}else i.push(s)}return i}function ht(t,e,i){i=q(i,"#sbz92","#"+t),e.styleSheet?e.styleSheet.cssText=i:(e.innerHTML="",e.appendChild(document.createTextNode(i)))}const ut="https://vcdn.subiz-cdn.com/file/bubble_11.svg?v=5",dt={primary_color:"#0265FF",secondary_color:"#555555",background:"linear-gradient(280.16deg, #0053d3 22.03%, #0265ff 78.2%)",text_color:"white",width:375,height:705,window_mode:"mini",desktop_button:{width:.3,height:.3,border_radius:"100%",background_mask_url:ut,margin_x:.3,margin_y:.3},mobile_button:{width:.3,height:.3,border_radius:"100%",background_mask_url:ut,margin_x:.3,margin_y:.3},widget_position:"fixed",z_index:2e9};function pt(t,e,i){var s={};for(var r in t)t.hasOwnProperty(r)&&(e&&e.length>0&&-1===e.indexOf(r)||("string"==typeof t[r]?s[r]=W(t[r]):s[r]=t[r]));t=s;let n="";for(var r in t)if(t.hasOwnProperty(r)){var o="";if(t.blur&&(o+="blur("+t.blur+") "),t.grayscale&&(o+="grayscale("+t+") "),o&&(n+="filter: "+o+"!important;"),void 0!==t.rotate&&(n+="transform:rotate("+t.rotate+") !important;"),void 0!==t[r]){let e=t[r]+"";L(i,((t,i)=>{-1!==e.indexOf(i)&&(e=q(e,i,t))})),n+=q(r,"_","-")+":"+e+" !important;","color"===r&&(n+="-webkit-text-fill-color: "+e+" !important;")}}return n}function mt(){var t=!!window.opr&&!!opr.addons||!!window.opera||navigator.userAgent.indexOf(" OPR/")>=0,e="undefined"!=typeof InstallTrigger,i=(/constructor/i.test(window.HTMLElement)||(!window.safari||"undefined"!=typeof safari&&window.safari.pushNotification).toString(),!!document.documentMode),s=!i&&!!window.StyleMedia,r=!(!window.chrome||!window.chrome.webstore&&!window.chrome.runtime);r||(r=navigator.userAgent.indexOf("Chrome"));var n=r&&-1!=navigator.userAgent.indexOf("Edg"),o=(r||t)&&!!window.CSS;return t?"opera":e?"firefox":i?"ie":s||n?"edge":r?"chrome":o?"blink":"unknown"}function gt(t,e,i,s){var n=s.matchAccount()||{},o=s.matchLocation()||{};if(!function(t,e){return!(e&&(r.get(t,"once_per_user")||r.get(t,"once_per_session")&&kt(e.created,y.now())||r.get(t,"interval_sec")&&r.get(t,"interval_sec")>(y.now()-e.created)/1e3))}(t,i))return!1;for(let t=0;t<F(e);t++){var a=e[t];switch(a.key){case"url":let t=E(a.exclude_urls,(t=>rt(t)));if(F(t)>0&&H(t,(t=>rt(window.location.href).indexOf(rt(t))>-1)))return!1;let e=E(a.urls,(t=>rt(t)));if(F(e)>0&&!H(e,(t=>rt(window.location.href).indexOf(rt(t))>-1)))return!1;break;case"url_path":let i=E(a.exclude_url_paths,(t=>rt(t)));if(F(i)>0){let t=new URL(window.location.href).pathname||"";if("string"==typeof t&&t.endsWith("/")&&(t=t.substring(0,t.length-1)),H(i,(e=>("string"==typeof e&&e.endsWith("/")&&(e=e.substring(0,e.length-1)),t===e))))return!1}let u=E(a.url_paths,(t=>rt(t)));if(F(u)>0){let t=new URL(window.location.href).pathname||"";if("string"==typeof t&&t.endsWith("/")&&(t=t.substring(0,t.length-1)),!H(u,(e=>("string"==typeof e&&e.endsWith("/")&&(e=e.substring(0,e.length-1)),t===e))))return!1}break;case"browser":if(F(a.browsers)>0){var l=mt();if(!H(a.browsers,(t=>rt(t)===rt(l))))return!1}break;case"location":if(F(a.exclude_locations)>0&&H(a.exclude_locations,(t=>!(!t.city_name||!t.country_code||t.city_name!==o.city_name||t.country_code!==o.country_code)||!(!t.city_name||t.country_code||t.city_name!==o.city_name)||!(t.city_name||!t.country_code||t.country_code!==o.country_code)||void 0)))return!1;if(F(a.locations)>0&&!H(a.locations,(t=>!(!t.city_name||!t.country_code||t.city_name!==o.city_name||t.country_code!==o.country_code)||!(!t.city_name||t.country_code||t.city_name!==o.city_name)||!(t.city_name||!t.country_code||t.country_code!==o.country_code)||void 0)))return!1;break;case"returning_visitor":if(a.returning_visitor&&s.new_visitor)return!1;if(!a.returning_visitor&&!s.new_visitor)return!1;break;case"user_is_a_contact":let d=r.get(s.matchUser(),"attributes",[]),p=H(d,(t=>"emails"===t.key&&attr.text&&"related_email"===t.key&&attr.text)),g=H(d,(t=>"phones"===t.key&&attr.text&&"related_phone"===t.key&&attr.text)),f=p||g;if(a.user_is_a_contact&&!f)return!1;if(!a.user_is_a_contact&&f)return!1;break;case"device_type":if(F(a.device_types)>0){let t="desktop";if(s.isMobile()&&(t="mobile"),s.isTablet()&&(t="tablet"),!H(a.device_types,(e=>rt(e)===rt(t))))return!1}break;case"referer":if(F(a.exclude_referers)>0&&H(a.exclude_referers,(t=>rt(document.referrer).indexOf(rt(t))>-1)))return!1;if(F(a.urls)>0&&!H(a.referers,(t=>rt(document.referrer).indexOf(rt(t))>-1)))return!1;break;case"source":if(F(a.sources)>0){let t=s.matchTrafficSource()||"direct";if(!H(a.sources,(e=>rt(e)===rt(t))))return!1}break;case"user_attribute":case"user":let v,_=r.get(s.matchUser(),"attributes",[]),b=r.get(a,"user.operator");U(_,(t=>{t&&t.key===r.get(a,"user.key")&&(v=t.datetime||t.boolean||t.number||t.text||t.list)}));let w=!0;switch(b){case"cons":let t=m(a.value)||[];if(0===F(t))return!1;w=!!H(t,(t=>rt(v).indexOf(rt(t))>-1));break;case"notEmpty":w=!!v;break;case"empty":w=!v;break;case"true":w=!0===v||"true"===v;break;case"false":w=!v||!1===v||"false"===v}if(!w)return!1;break;case"timming":if("in"===a.business_hour&&!n.is_in_business_hour)return!1;if("notIn"===a.business_hour&&n.is_in_business_hour)return!1;if(F(a.days_of_week)>0&&!H(a.days_of_week,(t=>rt(ft((new y).getDay()))===rt(t))))return!1;if(F(a.minutes_of_day)>0&&F(a.minutes_of_day)%2==0){var c=new y,h=c.getMinutes()+60*c.getHours();let t=!1;for(let e=0;e<a.minutes_of_day.length;e+=2){if(a.minutes_of_day[e]<=h&&h<=a.minutes_of_day[e+1]){t=!0;break}if(a.minutes_of_day[e]>a.minutes_of_day[e+1]&&(h>=a.minutes_of_day[e]||h<=a.minutes_of_day[e+1])){t=!0;break}}if(!t)return!1}break;case"offline":if(!n.is_online!=!!a.offline)return!1}}return!0}function ft(t){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][t]}let vt={};function _t(t,e){for(var i=0;i<t.length;i++){let e=t[i];if(e&&!vt[e]){vt[e]=!0;for(var s=0;s<2;s++){let t=[400,500][s],i=document.createElement("div");i.innerHTML="@!-/#Chào mỪng1",i.style.position="absolute",i.style.display="block",i.style.opacity="0.1",i.style.color="transparent",i.style.fontSize="20px",i.style.height="0px",i.style.top="0px",i.style.width="0px",i.style.fontWeight=t,i.setAttribute("subiz-preload",e+":"+t),document.body.appendChild(i),i.style.fontFamily=e,w((()=>i.remove()),3e3)}}}}function yt(t,e){if(e||(e=()=>{}),!t)return e(),Promise.resolve(!0);let i=new Image;return t=function(t){let e="https://vcdn.subiz-cdn.com/file/";return t?$(t,"/")||$(t,"data:")?t:($(t,"http://")||$(t,"https://")||$(t,"//")||(t=W(e)+"/"+B(t,"/")),t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace("https://file-subiz.com/",e)).replace("http://file-subiz.com/",e)).replace("https://file-v4.subiz.com/",e)).replace("http://file-v4.subiz.com/",e)).replace("https://filev4.subiz.com/",e)).replace("http://filev4.subiz.com/",e)).replace("https://filev4-1.subiz.com/",e)).replace("http://filev4-1.subiz.com/",e)).replace("https://file.subiz.com/",e)).replace("http://file.subiz.com/",e)).replace("https://file.mysubiz.com/",e)).replace("http://file.mysubiz.com/",e)):""}(t),i.src=t,new Promise((t=>{i.onload=()=>{e(),t()}}))}function bt(t){if(!t)return 0;t.length<=2&&(t+=":00");let e=t.split(":");if(2!==e.length)return 0;let i=parseInt(e[0]);if(i<0||i>23)return 0;let s=parseInt(e[1]);return s<0||s>59?0:60*i+s}function wt(t,e,i){var s=-(new y).getTimezoneOffset();i&&(s=bt(i));var r=new y(t).getTime(),n=new y(e).getTime(),o=Math.ceil((r/60/1e3+s)/60/24),a=Math.ceil((n/60/1e3+s)/60/24);return Math.abs(o-a)}function At(t,e,i){var s=-(new y).getTimezoneOffset(),r=-(new y).getTimezoneOffset();i&&(r=bt(i));var n=new y(t).getTime()+60*(r-s)*1e3,o=new y(e).getTime()+60*(r-s)*1e3;return Math.abs(new y(n).getYear()-new y(o).getYear())}function kt(t,e,i){return 0===wt(t,e,i)}function xt(t,e,i,s){var n=-(new y).getTimezoneOffset(),o=n;e&&(o=bt(e));var a=new y(St(t));let l=new y(a);l.setMinutes(a.getMinutes()+o-n),i||(i=new y);let c=l.getHours(),h=l.getMinutes(),u=r.get(navigator,"languages.0","en-US");s&&(u=s);let d=l.toLocaleDateString(u,{weekday:"long"}),p=l.getFullYear(),m=l.getMonth()+1,g=l.toLocaleDateString(u,{month:"long"}),f=l.getDate();return c<10&&(c="0"+c),h<10&&(h="0"+h),kt(a,i,e)?c+":"+h:wt(a,i,e)<=5?d+", "+c+":"+h:0===At(a,i,e)?"vi-VN"===u?f+" "+g+", "+c+":"+h:g+" "+f+", "+c+":"+h:"vi-VN"===u?f+"/"+m+"/"+p+", "+c+":"+h:p+"/"+m+"/"+f+", "+c+":"+h}function Ct(t){return Math.floor(St(t)/1e3)}function St(t){return t?"number"!=typeof t&&(t=new y(t).getTime()):t=0,t>1e18?Math.floor(t/1e6):t>1e15?Math.floor(t/1e3):t>1e12?t:1e3*t}function Mt(){let t=It("sbz_locale"),e=document.getElementsByTagName("html")[0].getAttribute("xml:lang")||document.getElementsByTagName("html")[0].getAttribute("lang"),i=navigator.language;return t||e||i}function It(t){t=t.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var e=new RegExp("[\\?&]"+t+"=([^&#]*)").exec(location.search);return null===e?"":decodeURIComponent(e[1].replace(/\+/g," "))}var Pt=t=>new Promise((e=>w(e,t)));function Dt(t,e="VND"){let i=Tt.find((t=>t.code===e))||{name:"Dong",code:"VND",symbol:"₫"},s="",r="";return"VND"===e?(s="",r=" "+i.symbol):(s=i.symbol+" ",r=""),t?s+(t=Math.round(t)).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")+r:`${s}0${r}`}function jt(t){return(t=(t+="").replaceAll("đ","d").replaceAll("Đ","D")).normalize("NFD").replace(/[\u0300-\u036f]/g,"")}function Et(t){centerIfNeeded=0===arguments.length||!!centerIfNeeded;var e=t.parentNode,i=window.getComputedStyle(e,null),s=parseInt(i.getPropertyValue("border-top-width")),r=parseInt(i.getPropertyValue("border-left-width")),n=t.offsetTop-e.offsetTop<e.scrollTop,o=t.offsetTop-e.offsetTop+t.clientHeight-s>e.scrollTop+e.clientHeight,a=t.offsetLeft-e.offsetLeft<e.scrollLeft,l=t.offsetLeft-e.offsetLeft+t.clientWidth-r>e.scrollLeft+e.clientWidth,c=n&&!o;(n||o)&¢erIfNeeded&&(e.scrollTop=t.offsetTop-e.offsetTop-e.clientHeight/2-s+t.clientHeight/2),(a||l)&¢erIfNeeded&&(e.scrollLeft=t.offsetLeft-e.offsetLeft-e.clientWidth/2-r+t.clientWidth/2),(n||o||a||l)&&!centerIfNeeded&&t.scrollIntoView(c)}const Tt=[{code:"USD",symbol:"$"},{code:"VND",symbol:"₫"}];function Lt(t){return function(t){if(!t||!t.type)return"";let e="";if("bullet_list"==t.type||"ordered_list"==t.type)return L(t.content,(s=>{preifx="\n* ","ordered_list"==t.type&&(prefix=i+"\n. "),e+=prefix+Lt(s).trim()})),e;if("heading"!=t.type&&"paragraph"!=t.type||(e+="\n"),""==t.type||"text"==t.type||"link"==t.type||"mention-agent"==t.type||"dynamic-field"==t.type)return e+t.text;if("horizontal_rule"==t.type)return e+"\n---\n";if("emoji"==t.type){let i;if(F(t.attrs)>0&&(i=t.attrs.code),""==i&&(i=t.text),""!=i){let t=H(LEXICAL_EMOJI_LIST,(t=>t.code===i));r.get(t,"text",i)}return e}return L(t.content,(t=>{e+=Lt(t)})),e}(t).trim()}function Ut(t){if(!t||!t.split)return"";f.style.color=t;const e=g.contentWindow.getComputedStyle(f).color.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)/);return e?{red:parseInt(e[1]),green:parseInt(e[2]),blue:parseInt(e[3])}:null}let zt=["like","unlike","wink","tongue-out","tired","surprised","smiling","sleepy","sad","neutral","heart-eyes","grinning","crying","confused","angry","cry","heart_eyes","neutral_face","emoji--disappointed","smile","open_mouth","tired_face","stuck_out_tongue","moyai","thumbsdown","dislike","thumbsup","ok_hand","octopus","pig2","wave","mouse","mouse2","rat"];zt=L(zt,(t=>":"+t+":"))}},r={};function n(t){var e=r[t];if(void 0!==e)return e.exports;var i=r[t]={id:t,exports:{}};return s[t].call(i.exports,i,i.exports,n),i.exports}n.m=s,n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.f={},n.e=t=>Promise.all(Object.keys(n.f).reduce(((e,i)=>(n.f[i](t,e),e)),[])),n.u=t=>"19641cfa41e."+t+".js",n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),t={},e="@subiz/widget-v4:",n.l=(i,s,r,o)=>{if(t[i])t[i].push(s);else{var a,l;if(void 0!==r)for(var c=document.getElementsByTagName("script"),h=0;h<c.length;h++){var u=c[h];if(u.getAttribute("src")==i||u.getAttribute("data-webpack")==e+r){a=u;break}}a||(l=!0,(a=document.createElement("script")).charset="utf-8",a.timeout=120,n.nc&&a.setAttribute("nonce",n.nc),a.setAttribute("data-webpack",e+r),a.src=i),t[i]=[s];var d=(e,s)=>{a.onerror=a.onload=null,clearTimeout(p);var r=t[i];if(delete t[i],a.parentNode&&a.parentNode.removeChild(a),r&&r.forEach((t=>t(s))),e)return e(s)},p=setTimeout(d.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=d.bind(null,a.onerror),a.onload=d.bind(null,a.onload),l&&document.head.appendChild(a)}},n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.p="https://vcdn.subiz-cdn.com/widget-v4/public/",(()=>{var t={60:0};n.f.j=(e,i)=>{var s=n.o(t,e)?t[e]:void 0;if(0!==s)if(s)i.push(s[2]);else{var r=new Promise(((i,r)=>s=t[e]=[i,r]));i.push(s[2]=r);var o=n.p+n.u(e),a=new Error;n.l(o,(i=>{if(n.o(t,e)&&(0!==(s=t[e])&&(t[e]=void 0),s)){var r=i&&("load"===i.type?"missing":i.type),o=i&&i.target&&i.target.src;a.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",a.name="ChunkLoadError",a.type=r,a.request=o,s[1](a)}}),"chunk-"+e,e)}};var e=(e,i)=>{var s,r,[o,a,l]=i,c=0;if(o.some((e=>0!==t[e]))){for(s in a)n.o(a,s)&&(n.m[s]=a[s]);l&&l(n)}for(e&&e(i);c<o.length;c++)r=o[c],n.o(t,r)&&t[r]&&t[r][0](),t[r]=0},i=self.webpackChunk_subiz_widget_v4=self.webpackChunk_subiz_widget_v4||[];i.forEach(e.bind(null,0)),i.push=e.bind(null,i.push.bind(i))})(),(()=>{"use strict";var t=n(8150),e=n(1314).A,i=n(3118).A,s=n(1554).A;const r={kv:e,lsdb:n(1428).A,chain:i,inmem_localstorage:s};function o(t,e,i){return(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const a=n(318);function l(e,i){let s=e.request;"text/plain"===s.content_type&&void 0!==s.body&&(s.body=t.A.stringify(s.body)),i(!0)}a.env.XMLHttpRequest=t.A.XMLHttpRequest;const c=class{constructor(e,i){o(this,"listConversations",(t=>this.apireq.addQuery("user_id",this.uid).addQuery("integration_id",`${this.accid}.subizv4.subikon`).get(`/accounts/${this.accid}/conversations`))),o(this,"listMessages",((t,e,i)=>this.apireq.addQuery("limit",e).addQuery("start_id",i).get(`/accounts/${this.accid}/conversations/${t}/messages`))),o(this,"ajax",a),o(this,"start",(e=>{let i={touchpoint:{channel:"subiz",source:"web"}};return t.A.each(e,((t,e)=>{i[e]=t})),this.apireq.post(`/accounts/${this.accid}/conversations`,i)})),o(this,"sendConvoEvent",((e,i)=>this.apireq.addQuery("x-referer",t.A.get(location,"origin","")).post(`/accounts/${this.accid}/conversations/${e}/events`,i))),o(this,"createPostback",((t,e)=>this.apireq.post(`/accounts/${this.accid}/conversations/${t}/postbacks`,e))),o(this,"markAsReceived",((t,e)=>this.apireq.post(`/accounts/${this.accid}/conversations/${t}/messages/${e}/receive`))),o(this,"markAsSeen",((t,e)=>this.apireq.post(`/accounts/${this.accid}/conversations/${t}/messages/${e}/seen`))),o(this,"getConversation",(t=>this.apireq.get(`/accounts/${this.accid}/conversations/${t}`))),o(this,"getLocaleContent",(t=>this.apireq.get(`/accounts/${this.accid}/locales/${t}`))),o(this,"sendEvent",(e=>this.apireq.addQuery("shorten",!0).addQuery("x-referer",t.A.get(location,"origin","")).post(`/accounts/${this.accid}/users/${this.uid}/events`,e))),o(this,"submitForm",((e,i,s,r,n)=>this.apireq.addQuery("x-referer",t.A.get(location,"origin","")).post(`/accounts/${this.accid}/users/${this.uid}/events`,{by:{id:this.uid,device:s},type:"form_submitted",data:{user:n,form_submission:{user_id:this.uid,form_id:e,page_url:i,submitted_at:t.A.Date.now(),values:r}}}))),o(this,"sendTyping",(t=>this.apireq.post(`/accounts/${this.accid}/conversations/${t}/typing`))),o(this,"sendLostFocus",(()=>this.apireq.post(`/accounts/${this.accid}/focuses/${this.uid}/delete`))),o(this,"uploadToS3",(async t=>{let{body:e,error:i}=await this.apireq.post(`/accounts/${this.accid}/files`,{account_id:this.accid,description:"upload\n user-client: web-widget",name:t.name.replace(/\s+/g,"_"),size:t.size,type:t.type});if(i)return{body:e,error:i};let s,r=t.type||"application/octet-stream";return({error:i}=await a.setContentType(r).put(e.signed_url,t)),i?{error:i}:(({body:s,error:i}=await this.apireq.post(`/accounts/${this.accid}/files/${e.id}`,{account_id:this.accid})),i?{body:s,error:i}:{url:s.url})})),o(this,"time",(t=>a.setBaseUrl(this.ApiURL).withCredentials(!0).setParser("json").get("/time"))),o(this,"updateUser",(t=>this.apireq.post(`/accounts/${this.accid}/users/${this.uid}`,t))),o(this,"getUser",(t=>this.apireq.get(`/accounts/${this.accid}/users/${this.uid}`))),o(this,"getAccountSetting",(()=>this.apireq.get(`/accounts/${this.accid}/settings`))),o(this,"getIsOnline",(()=>this.apireq.get(`/accounts/${this.accid}/is_online`))),o(this,"sendImpression",(t=>this.apireq.post(`/accounts/${this.accid}/campaigns/${t.campaign_id}/impressions`,t))),o(this,"sendConversion",(t=>this.apireq.post(`/accounts/${this.accid}/campaigns/${t.campaign_id}/conversions`,t))),o(this,"lookupOrder",(t=>a.setBaseUrl(this.ApiURL).setContentType("text/plain").beforeHook(l).setParser("json").addQuery("x-signed-key",t).get("/orders/123"))),o(this,"getOrder",(t=>this.apireq.get(`/accounts/${this.accid}/orders/`+t))),o(this,"updateOrder",(t=>this.apireq.post(`/accounts/${this.accid}/orders/`+t.id,t))),o(this,"fetchShippingAddresses",(()=>this.apireq.get(`/accounts/${this.accid}/users/${this.uid}/shipping-addresses`))),o(this,"createShippingAddress",(t=>this.apireq.post(`/accounts/${this.accid}/users/${this.uid}/shipping-addresses`,t))),o(this,"list_provinces",(()=>this.apireq.get(`/accounts/${this.accid}/provinces`))),o(this,"list_districts",(t=>this.apireq.setQuery(t).get(`/accounts/${this.accid}/districts`))),o(this,"list_wards",(t=>this.apireq.setQuery(t).get(`/accounts/${this.accid}/wards`))),o(this,"suggest_address",(t=>this.apireq.setQuery({keyword:t}).get(`/accounts/${this.accid}/addresses`))),o(this,"create_ticket",(t=>this.apireq.post(`/accounts/${this.accid}/tickets`,t))),this.refreshLock=new t.A.Mutex,this.FileURL=i,this.ApiURL=e,this.apireq=a.setBaseUrl(e).withCredentials(!0).addQuery("v","6").setContentType("text/plain").beforeHook(l).setParser("json").beforeHook(((t,e)=>{if(!this.token_generator)return this.ref?t.request=t.request.addQuery("x-user-ref",this.ref):this.mask&&(t.request=t.request.addQuery("x-user-mask",this.mask)),e(!0);{let i=this.profile_id;this.token_generator().then((s=>i!=this.profile_id?e(!0):s?"error"==s?e(!1):(t.request=t.request.addQuery("x-access-token",s),e(!0)):e(!1)))}}))}setAgentId(t){this.agentid=t}async setAuth(e){if(e.accid&&(this.accid=e.accid),e.ref&&(this.ref=e.ref),this.mask=e.mask,this.profile_id=e.profile_id,e.ref){let e;for(let i=0;!(e=await a.setBaseUrl(this.ApiURL).withCredentials(!0).addQuery("v","6").addQuery("x-user-ref",this.ref).setParser("json").get(`/accounts/${this.accid}/users/${this.ref}`),e.error&&-1!=t.A.get(e,"body.error.code","").indexOf("locked_account")||t.A.get(e,"body.id"));i++){let e=Math.min(2e3+400*i,6e4);await t.A.sleep(e)}return e.error?t.A.get(e.body.code)?{error:e.body.code}:e:(this.uid=e.body.id,e.body)}if(e.tokenGenerator){let i=e.tokenGenerator;this.tokensession=this.tokensession||0,this.tokensession++;let s=this.tokensession;if(!this.accid||!t.A.startsWith(this.accid,"ac"))return{error:"invalid_account_id"};if(!this.profile_id)return{error:"invalid_profile_id"};if("function"!=typeof i)return{error:"invalid_token_generator"};let r,n=this.profile_id;this.token_generator=async e=>{if(await this.refreshLock.lock(),s!=this.tokensession)return void this.refreshLock.unlock();let r,o,a=(t.A.Date.now()-(this.last_token_at||0))/1e3;if(!e&&this.last_token&&a<1800)return this.refreshLock.unlock(),this.last_token;if(!e&&this.last_token&&a<3e3)return this.token_generator&&t.A.setTimeout((async()=>{let e,r;try{e=await i(n)}catch(t){r=t}s==this.tokensession?(this.last_token=r?"error":e,this.last_token_at=t.A.Date.now(),this.refreshLock.unlock()):this.refreshLock.unlock()})),this.last_token;try{r=await i(n)}catch(t){o=t}if(s==this.tokensession)return this.last_token=o?"error":r,this.last_token_at=t.A.Date.now(),this.refreshLock.unlock(),this.last_token;this.refreshLock.unlock()};for(let e=0;await this.token_generator(!0),s==this.tokensession&&(r=await a.setBaseUrl(this.ApiURL).withCredentials(!0).addQuery("v","6").addQuery("x-access-token",this.last_token).setParser("json").get(`/accounts/${this.accid}/users/${n}`),!t.A.get(r,"body.id"));e++){let i=Math.min(2e3+100*e,12e4);await t.A.sleep(i)}return r.error?t.A.get(r.body.code)?{error:r.body.code}:r:(this.uid=r.body.id,r.body)}if(this.mask){let t=this.mask.split("@");return this.uid=t[1],{id:this.uid}}return{error:"invalid_auth"}}sendContentView(t,e,i,s,r,n){return s||(s=void 0),r||(r=void 0),this.sendEvent({by:{id:this.uid,device:t},type:"content_viewed",data:{product:{id:s,source_id:r,url:e,name:i,title:i,sku:n}}})}};function h(t,e,i){return(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const u=n(318);function d(e,i){let s=e.request;"text/plain"===s.content_type&&void 0!==s.body&&(s.body=t.A.stringify(s.body)),i(!0)}u.env.XMLHttpRequest=window.XMLHttpRequest;const p=Promise.resolve({code:200}),m=class{constructor(e,i){h(this,"listConversations",(t=>{let e=g(this.accid,"csqwudlkftltnbebvq",this.uid,this.agentid);return Promise.resolve({body:{anchor:"",conversations:[e]},code:200})})),h(this,"listMessages",((t,e,i)=>{let s=function(t,e,i,s){let r=t+".subizv4.subikon",n={type:"user",id:i,last_page_view_url:"https://subiz.com.vn/",conversation_id:e,membership:"active",invited_by:{id:i,type:"user"}},o={type:"agent",conversation_id:e,id:s,membership:"active",invited_by:{id:i,type:"user"}};return[{id:"evqyiyjmxrjsylftvnrghrfmq",account_id:t,created:1616213202264,type:"conversation_invited",by:{id:i,type:"user"},data:{conversation:{id:e,account_id:t,members:[n],state:"pending"}}},{id:"evqyiyjmyqdgrouswczzawuzp",account_id:t,created:1616213202559,type:"conversation_invited",by:{id:i,type:"user"},data:{conversation:{id:e,account_id:t,members:[o],state:"pending",source:"https://subiz.com.vn/vi/"}}},{id:"evqyiyjmyzjpyehnngvmcyauf",account_id:t,created:1616213202668,type:"conversation_state_updated",by:{id:i,type:"user"},data:{conversation:{id:e,account_id:t,state:"active"}}},{id:"evqyiyjmzaozvqgbkljbwywdl",account_id:t,created:1616213202683,type:"conversation_joined",by:{id:i,type:"user"},data:{conversation:{id:e,members:[n]}}},{id:"evqyiyjmzatvtgpdmmpzwnwgn",account_id:t,created:1616213202685,type:"message_sent",by:{id:i,client_id:"clsubizapi",type:"user"},data:{message:{conversation_id:e,text:"Xin chào",format:"plaintext",idempotency_key:"wrueysyjbhqrkiwhsejpqrwqrdkkyaibajdw",integration_id:r,pongs:[{member_id:i,type:"seen",created:1616213203068}]}}},{id:"evqyiyjrhsfyuxtetszmvkkke",account_id:t,created:1616213237491,type:"conversation_joined",by:{id:i,type:"user"},data:{conversation:{id:e,members:[o]}}},{id:"evqyiyjrhtroknjyakrlrwhgr",account_id:t,created:1616213237508,type:"message_sent",by:{id:s,client_id:"dashboard",type:"agent"},data:{message:{conversation_id:e,text:"chào bạn, mình có thể giúp gì được cho bạn :grinning:",format:"plaintext",integration_id:r,pongs:[{member_id:i,type:"receive",created:1616213237742},{member_id:i,type:"seen",created:1616213240057}]}}},{id:"evqyiyjuvjinmclneroerxmrl",account_id:t,created:1616213265805,type:"message_sent",by:{id:i,client_id:"clsubizapi",type:"user"},data:{message:{conversation_id:e,text:"mình muốn hỏi giá sản phẩm IPhone X",format:"plaintext",integration_id:r,pongs:[{member_id:i,type:"seen",created:1616213267090}]}}},{id:"evqyiyjzjxzfcsexshcjbbnnf",account_id:t,created:1616213302432,type:"message_sent",by:{id:s,client_id:"dashboard",type:"agent"},data:{message:{conversation_id:e,text:"IPhone X hiện đang được bán tại cửa hàng với giá 12tr đồng nha bạn",format:"plaintext",integration_id:r,pongs:[{member_id:i,type:"receive",created:1616213302698},{member_id:i,type:"seen",created:1616213305071}]}}},{id:"evqyiykaoizbwnkaecwphttwk",account_id:t,created:1616213311830,type:"message_sent",by:{id:i,client_id:"clsubizapi",type:"user"},data:{message:{conversation_id:e,text:"ok cám ơn!",format:"plaintext",integration_id:r,pongs:[{member_id:i,type:"seen",created:1616213312110}]}}}]}(this.accid,"csqwudlkftltnbebvq",this.uid,this.agentid);return Promise.resolve({body:s,code:200})})),h(this,"ajax",u),h(this,"start",(t=>p)),h(this,"sendConvoEvent",((t,e)=>p)),h(this,"createPostback",((t,e)=>p)),h(this,"markAsReceived",((t,e)=>p)),h(this,"markAsSeen",((t,e)=>p)),h(this,"getConversation",(t=>Promise.resolve({body:g(this.accid,"csqwudlkftltnbebvq",this.uid,this.agentid),code:200}))),h(this,"getLocaleContent",(t=>this.apireq.get(`/accounts/${this.accid}/locales/${t}`))),h(this,"sendEvent",(t=>p)),h(this,"submitForm",((t,e,i,s,r)=>p)),h(this,"sendTyping",(t=>p)),h(this,"sendPresence",(t=>p)),h(this,"sendContent",(t=>p)),h(this,"sendLostFocus",(t=>p)),h(this,"sendContentView",(t=>p)),h(this,"uploadToS3",(async t=>p)),h(this,"time",(e=>Promise.resolve({code:200,body:(new t.A.Date).toISOString()}))),h(this,"updateUser",(t=>p)),h(this,"getUser",(t=>Promise.resolve({code:200,body:{id:"usqzgtgfake",attributes:[{key:"fullname",text:"Kiều Thanh"}]}}))),h(this,"getAccountSetting",(()=>this.apireq.get(`/accounts/${this.accid}/settings`))),h(this,"getIsOnline",(()=>this.apireq.get(`/accounts/${this.accid}/is_online`))),h(this,"sendImpression",(t=>p)),h(this,"sendConversion",(t=>p)),this.FileURL=i,this.apireq=u.setBaseUrl(e).setContentType("text/plain").beforeHook(d).setParser("json")}setAgentId(t){this.agentid=t}setAuth(t){return this.accid=t.accid,this.mask=t.mask,this.uid=t.uid,{account_id:this.accid,id:"usqzgtgfake",attributes:[{key:"fullname",text:"Kiều Thanh"}]}}};function g(t,e,i,s){return{id:e,account_id:t,created:1610452894916,members:[{type:"user",id:i,membership:"active",invited_by:{id:i,type:"user"}},{type:"agent",id:s,conversation_id:e,membership:"active",invited_by:{id:i,type:"user"}}],ended:1610454875505,state:"ended",actived:1610453070259,last_message_sent:{id:"evqyiykaoizbwnkaecwphttwk",account_id:t,created:1616213311830,type:"message_sent",by:{id:i,client_id:"clsubizapi",type:"user"},data:{message:{conversation_id:e,text:"ok cám ơn!",format:"plaintext",integration_id:t+".subizv4.subikon",pongs:[{member_id:i,type:"seen",created:1616213312110}]}}},assigned_to:{},first_message:"Xin chào",subject:"Chúc một ngày tốt lành",source:"https://subiz.com.vn/"}}const f=class{onEvent(){}onInterrupted(){}subscribe(){}stop(){}};function v(t,e,i){return(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}var _=n(8193),y=n(2839),b=n(5672);b.defaults.path="/",b.expiresMultiplier=86400,b.defaults.expires=3650;const w=t.A.Date.now();class A{constructor(e,i,s,n,o){if(v(this,"inmem",!1),v(this,"cookie",b),v(this,"_currentViewingProduct",{}),v(this,"new_visitor",!0),v(this,"matchUser",(()=>(this._touchAcc(),this.cache.match("user")))),v(this,"suggest_addresses",(t=>this.api.suggest_address(t))),v(this,"matchAccount",(()=>this.cache.match("account"))),v(this,"matchPaymentMethods",(()=>this.cache.match("payment_methods"))),v(this,"matchUnread",(()=>{let e=this.matchUser(),i=this.matchConvo("*"),s=0;return t.A.map(i,(i=>{t.A.isConvoSeen(i,e.id)||s++})),s})),v(this,"matchPlugin",(()=>t.A.size(this.forcePlugins)>0?t.A.cloneDeep(this.forcePlugins):t.A.cloneDeep(this.cache.match("plugin"))||{})),v(this,"device",{}),v(this,"browserVisibility","visible"),v(this,"matchAgent",(t=>{let e=this.cache.match("agent")||{};return"*"===t?e:e[t]})),v(this,"matchConvo",(e=>{if(e)return"*"===e?(this._touchAcc(),t.A.filter(this.cache.all(),((t,e)=>e.startsWith("convo_")))):(this.isInsync(e)||this.fetchConvo(e),this.cache.match("convo_"+e))})),v(this,"fetchConvo",(async t=>{if(this._die)return P;if(await this.readyGate.entry(),await this.reconnectGate.entry(void 0,!0),this.isInsync(t))return this.reconnectGate.open();this.markSync(t);let{body:e,error:i}=await this.api.getConversation(t);return e&&!i&&this._setConvo(e),this.reconnectGate.open()})),v(this,"list_provinces",(()=>this.api.list_provinces())),v(this,"list_districts",(t=>this.api.list_districts(t))),v(this,"list_wards",(t=>this.api.list_wards(t))),v(this,"outofmsgM",{}),v(this,"listEvents",(t=>{if(t&&"*"!==t&&"string"==typeof t)return this.chain.listM(t)})),v(this,"fetchMoreEvents",(async t=>{if(!this.isInsync("events"+t)){if(await this.readyGate.entry(),await this.reconnectGate.entry(void 0,!0),this.isInsync("events"+t))return this.reconnectGate.open(),{};this.markSync("events"+t),await this.chain.reload(t,(()=>[[],""]));let e=await this._doFetchMsg(t);return this.reconnectGate.open(),e}return this._doFetchMsg(t)})),v(this,"_doFetchMsg",(async t=>{let{error:e}=await this.chain.fetchMore(t,150,(async(e,i,s)=>{if(this.outofmsgM[t])return[[],""];let[r,n,o,a]=await this.listmessageapi(e,i,s);return a&&(this.outofmsgM[t]=!0),[r,n,o]}));return this.pubsub.publish("account"),{error:e}})),v(this,"matchLocation",(()=>this.cache.match("location")||{})),v(this,"matchBot",(()=>this.cache.match("bot")||{})),v(this,"readyGate",new t.A.Gate),v(this,"convoGate",new t.A.Gate(!0)),v(this,"reconnectGate",new t.A.Gate(!0)),v(this,"wsGate",new t.A.Gate(!0)),v(this,"matchLastview",(()=>{let t=this.kv.match("lastview")||{},e=this.cache.match("user")||{};return e.id?t.user_id!=e.id?{}:t:{}})),v(this,"matchIsOpen",(()=>!!this.kv.match("isopen"))),v(this,"matchHasManuallyClosed",(()=>!!this.kv.match("hasManuallyClosed"))),v(this,"matchClosePreviewAt",(()=>this.kv.match("close_preview_at")||0)),v(this,"sendPresence",t.A.throttle((async()=>this._die?P:(await this.readyGate.entry(),t.A.get(this.cache.match("user"),"id")&&!t.A.isUserBanned(this.cache.match("user"))&&this._track_page_view?"visible"===this.browserVisibility&&document.hasFocus()?void this.api.sendContentView(this.device,location.href,document.title,this._currentViewingProduct.id,this._currentViewingProduct.source_id,this._currentViewingProduct.sku):this.api.sendLostFocus():void 0)),1e3,{leading:!1})),v(this,"now",(()=>t.A.Date.now()+this.timeDiff)),v(this,"seenQueue",[]),v(this,"matchTrafficSource",(()=>this.kv.match("traffic_source"))),v(this,"_alreadyReceived",{}),v(this,"_typing",t.A.throttle((t=>this.api.sendTyping(t)),3e3,{trailing:!1})),v(this,"onConvoEvent",((t,e)=>this.pubsub.on2(t,"events",e))),v(this,"onWidgetClose",((t,e)=>this.pubsub.on2(t,"sbz_close_widget",e))),v(this,"seenConvo",(t=>{t&&"create"!==t&&this.seenQueue.push(t)})),v(this,"onUpdate",((t,e)=>this.pubsub.on2(t,"account",e))),v(this,"onResetCSS",((t,e)=>this.pubsub.on2(t,"resetCSS",e))),v(this,"onHighlight",((t,e)=>this.pubsub.on2(t,"highlight",e))),v(this,"setHasManuallyClosed",(()=>this.kv.put("hasManuallyClosed",!0))),v(this,"setIsOpen",(t=>{let e=this.kv.match("isopen");this.kv.put("isopen",t),!e&&t&&C("SUBIZ Chat","Opened","Subiz Windows")})),v(this,"closePreview",(()=>this.kv.put("close_preview_at",(new t.A.Date).getTime()))),v(this,"setLastview",((t,e)=>{let i=this.cache.match("user")||{};i.id&&this.kv.put("lastview",{user_id:i.id,view:t,opts:e})})),v(this,"timeDiff",0),this.g_sync={},this._die=!1,this.forceDevice=null,this.forcePlugins={},this.forceAcc={},this.forceChatbox={},this.RealtimeURL=s,this.fake=o,this.FileURL=i,this._track_page_view=!0,this.device_type="desktop",this.fake?this.api=new m(e,i):this.api=new c(e,i),!n)try{document.cookie,localStorage}catch(t){n=!0}n&&(this.inmem=n,this.cookie=x),S(),this.pubsub=new t.A.Pubsub,this.kv=new r.kv(new r.lsdb("sbz2023",this.inmem),"kv"),this.cache=new r.kv(new r.lsdb("sbz2023",!0),"kv"),this.chain=new r.chain(new r.lsdb("cbz2023",!0),"ch"),this.getLocaleContent=this.api.getLocaleContent,this.g_haveSentSeenM={},this.last_focused=t.A.Date.now(),window.addEventListener("blur",(()=>{this.last_focused=t.A.Date.now(),this.sendPresence()})),window.addEventListener("focus",(()=>{this.last_focused=0,this.sendPresence()})),window.addEventListener("beforeunload",(()=>this.api.sendLostFocus())),this.doNotStartBot=()=>{this._donotstartbot=!0},this.autoStartBot=()=>{this._donotstartbot=!1},this.matchAutoStartBot=()=>!this._donotstartbot,this._presenceInterval1=t.A.setInterval((()=>{if(this._die)return t.A.clearInterval(this._presenceInterval1);"visible"===this.browserVisibility&&document.hasFocus()&&this.sendPresence()}),2e4),this._presenceInterval2=t.A.setInterval((()=>{if(this._die)return t.A.clearInterval(this._presenceInterval2);"visible"===this.browserVisibility&&document.hasFocus()||this.last_focused&&t.A.Date.now()-this.last_focused>18e5||this.sendPresence()}),6e4),function(t){var e="hidden";function i(i){var s="visible",r="hidden",n={focus:s,focusin:s,pageshow:s,blur:r,focusout:r,pagehide:r};(i=i||window.event).type in n?t(n[i.type]):t(this[e]?"hidden":"visible")}e in document?document.addEventListener("visibilitychange",i):(e="mozHidden")in document?document.addEventListener("mozvisibilitychange",i):(e="webkitHidden")in document?document.addEventListener("webkitvisibilitychange",i):(e="msHidden")in document?document.addEventListener("msvisibilitychange",i):"onfocusin"in document?document.onfocusin=document.onfocusout=i:window.onpageshow=window.onpagehide=window.onfocus=window.onblur=i,void 0!==document[e]&&i({type:document[e]?"blur":"focus"})}((t=>{this._die||(this.browserVisibility=t,this.sendPresence())})),this.loopTime(),this.device=this.getDeviceInfo();const a=t.A.setInterval((()=>{let e=this.cache.match("user")||{};if(!e.id)return;var i=this.getDeviceInfo();if(!i.ga_tracking_ids||!i.ga_client_id)return;t.A.clearInterval(a),this.device=i;let s=i.ga_client_id;s!==t.A.getUserAttr(e,"ga_client_id","text")&&this.setUser({attributes:[{type:"text",text:s,key:"ga_client_id"}]})}),2e3)}linkProduct(t){t?(t.id&&(this._currentViewingProduct.id=(t.id+"").trim()),t.source_id&&(this._currentViewingProduct.source_id=(t.source_id+"").trim()),t.sku&&(this._currentViewingProduct.sku=(t.sku+"").trim())):this._currentViewingProduct={}}getTrackPageview(){return this._track_page_view}setTrackPageview(t){this._track_page_view=!!t}getLinkedProduct(){return t.A.cloneDeep(this._currentViewingProduct)}isInsync(e){return t.A.Date.now()-(this.g_sync[e]||0)<6e5}async fetchShippingAddresses(){let t=await this.api.fetchShippingAddresses();if(t.error)return null;this.cache.put("shipping_address",t.body.shipping_addresses)}matchShippingAddresses(){return this.cache.match("shipping_address")}updateOrder(t){return this.api.updateOrder(t)}createShippingAddress(t){return this.api.createShippingAddress(t)}createTicket(t){return this.api.create_ticket(t)}async overrideAcc(e){this.forceAcc=t.A.cloneDeep(e),await this.readyGate.entry(),this.disconnect("account"),this.reconnect()}async overrideChatbox(e){this.forceChatbox=e,await this.readyGate.entry(),this.disconnect("account"),await this.reconnect(),t.A.setTimeout(this.pubsub.publish("resetCSS"),10)}getDeviceInfo(){let t={screen_resolution:window.screen.width+"x"+window.screen.height,source_referrer:document.referrer,platform:window.navigator.platform,language:navigator.language,page_url:document.URL,page_title:document.title},e=function(){if(!window.ga)return;if(!window.ga.getAll)return;var t=window.ga.getAll()||[];let e="";return t.forEach((function(t){e=t.get("clientId")})),e}();e&&(t.ga_client_id=e);let i=(s=[],window.ga&&window.ga.getAll?window.ga&&window.ga.getAll?((window.ga.getAll()||[]).forEach((function(t){var e=t.get("trackingId");e&&s.push(e)})),s):[]:s);var s;return i.length>0&&(t.ga_tracking_ids=i),t}highlight(t,e){this.pubsub.publish("highlight",t,e)}emitConvoEvent(t){this.pubsub.publish("events",t)}setAIDevMode(t){this.ai_dev_mode=t}isAIDevMode(){return this.ai_dev_mode}overrideDeviceType(t){this.forceDevice=t,this.pubsub.publish("account")}isMobile(){return this.forceDevice?"mobile"===this.forceDevice:"mobile"==this.device_type||t.A.get(window,"screen.width",1e3)<576}isTablet(){return this.forceDevice?"tablet"===this.forceDevice:"tablet"==this.device_type}isDesktop(){return this.forceDevice?"desktop"===this.forceDevice:!this.isMobile()&&!this.isTable()}disconnect(t){this.g_sync[t]=0}pageLoaded(){return w}overridePlugin(e){if(this._die)return P;if(!Array.isArray(e))throw"plugins must be be an array";let i={};t.A.map(e,(function(t){i[t.id]=t})),this.forcePlugins=i,this.pubsub.publish("account"),this.pubsub.publish("resetCSS")}markSync(e){this.g_sync[e]=t.A.Date.now()}async _touchAcc(){this.isInsync("account")||(await this.readyGate.entry(),this.isInsync("account")||this.reconnect())}async init(e,i,s,r){if(this.readyGate.close(),e=(e||"").trim(),this.g_sync={},r&&r.use_subdomain_cookie||window&&window.location&&window.location.hostname&&(b.defaults.domain="."+window.location.hostname),!s){try{s=this.cookie.get("__sbref","")}catch(t){}if(!s){if(!i)try{i=this.cookie.get("__sbmask","")}catch(t){}i?(i.split("@")[0]!=e&&(s=t.A.randomString(40),this.new_visitor=!0),this.new_visitor=!1,this.cookie.set("__sbmask",i)):(s=t.A.randomString(40),this.new_visitor=!0)}}this.cookie.get("__sbref",s)!=s&&M(),this.api.setAuth({accid:e}),s&&this.cookie.set("__sbref",s);let n=await this.api.setAuth({accid:e,mask:i,ref:s});return n.error?console.error(n):(this.realtime&&this.realtime.stop(),this.fake?this.realtime=new f:this.realtime=new y(this.RealtimeURL,{account_id:e,user_ref:s,user_mask:i},I),this.realtime.onEvent(this.onWs.bind(this)),this.realtime.onInterrupted((()=>this.reconnectWs(e,n.id))),this.seenLoop(),await this.reconnect(),this.readyGate.open(),this.reconnectWs(e,n.id),n)}async login(t,e,i){if(this._die)return P;let s=await this.api.setAuth({accid:t,profile_id:e,tokenGenerator:i});return s.error||(this.clearBrowserData(),this.readyGate.close(),t=(t||"").trim(),this.g_sync={},this.new_visitor=!1,this.realtime&&this.realtime.stop(),this.fake?this.realtime=new f:this.realtime=new y(this.RealtimeURL,{getAccessToken:()=>this.api.token_generator()}),this.realtime.onEvent(this.onWs.bind(this)),this.realtime.onInterrupted((()=>this.reconnectWs(t,s.id))),this.seenLoop(),await this.reconnect(),this.readyGate.open(),this.reconnectWs(t,s.id)),s}logout(t){return this.api.setAuth({ref:t})}seenLoop(){this.seenQueue=[],t.A.clearInterval(this._seenInterval),this._seenInterval=t.A.setInterval((()=>{if(this._die)return t.A.clearInterval(this._seenInterval);this.seenQueue=[...new Set(this.seenQueue)];let e=this.cache.match("user")||{};t.A.map(this.seenQueue,(i=>{var s=this.listEvents(i);if(!s)return;if(0===t.A.size(s))return;var r=(s=t.A.filter(s,(t=>"message_sent"===t.type)))[t.A.size(s)-1];if(!r)return;if(this.g_haveSentSeenM[r.id])return;if(r.id===r.data.message.idempotency_key)return;this.api.markAsSeen(i,r.id),this.pubsub.publish("events",{created:t.A.Date.now(),type:"message_pong",by:{type:"user"},data:{message:{conversation_id:i,id:"*",pongs:[{type:"seen",created:t.A.Date.now()}]}}});let n=this.cache.match("convo_"+i)||{},o=t.A.find(n.members,(t=>t.id===e.id));o&&(o.seen_at=t.A.Date.now()),this._setConvo(n),this.g_haveSentSeenM[r.id]=!0})),this.seenQueue=[]}),1e3)}async reconnectWs(t,e){return await this.realtime.subscribe([`conversation_state_updated.account.${t}.user.${e}`,`conversation_joined.account.${t}.user.${e}`,`conversation_typing.account.${t}.user.${e}`,`message_sent.account.${t}.user.${e}`,`conversation_pending.account.${t}.user.${e}`,`user_info_updated.account.${t}.user.${e}`,`message_pong.account.${t}.user.${e}`,`conversation_rating_requested.account.${t}.user.${e}`,`conversation_rated.account.${t}.user.${e}`]),await this.readyGate.entry(),this.disconnect("account"),this.reconnect()}async reconnect(){if(this._die)return;if(await this.reconnectGate.entry(void 0,!0),this.isInsync("account"))return this.reconnectGate.open();this.markSync("account");let e=await Promise.all([this.api.getUser(),this.api.getAccountSetting(),this.api.getIsOnline()]),i=t.A.find(e,(t=>t.error));if(i)return console.error(i);let s=Object.assign(e[1].body,e[2].body);s.user=e[0].body,await this._setSetting(s);let r=await this.api.listConversations();i=r.error;let n=r.body;if(!i){let e=t.A.get(n,"conversations",[]);t.A.map(this.cache.all(),((e,i)=>{i.startsWith("convo_")&&this.now()-t.A.getMs(t.A.get(e,"actived"))>12096e5&&this.cache.del(i)})),t.A.map(e,(t=>this._setConvo(t)))}return this.reconnectGate.open()}async submitForm(t,e,i){return await this.readyGate.entry(),i&&await this.setUser(i),this.api.submitForm(t,document.URL,this.device,e,i)}async setUser(t){if(t)return await this.readyGate.entry(),this._setUser(t),this.api.updateUser(t)}async setUserDiff(t){if(!t)return;await this.readyGate.entry();let e=await this.api.updateUser(t);e&&200==e.code&&e.body.id&&this._setUser(e.body)}_setUser(e){e=t.A.cloneDeep(e);let i=this.cache.match("user")||{};var s=i.account_id||e.account_id,r=i.id||e.id;t.A.each(e.attributes,(e=>{e&&(i.attributes=t.A.filter(i.attributes,(t=>!!t&&t.key!==e.key)))})),i.attributes=i.attributes||[],i.attributes=i.attributes.concat(e.attributes),i.account_id=s,i.id=r,this.cache.put("user",i),this.pubsub.publish("account")}async setSetting(t){if(t)return await this.readyGate.entry(),this._setSetting(t)}async _setSetting(e){(e=t.A.cloneDeep(e)||{}).account=Object.assign({},e.account,this.forceAcc),e.account.logo_url||(e.account.logo_url="https://vcdn.subiz-cdn.com/file/fiqpezhkmeyesdscyetk-default_logo.jpg"),e.user&&(e.user.account_id=e.account.id,delete e.user.session,this._setUser(e.user)),e.account&&(e.account.is_online=e.is_online,e.account.is_in_business_hour=e.is_in_business_hour,this.cache.put("account",e.account),delete e.account);let i=t.A.get(e,"location",[]);this.cache.put("location",i);let s=t.A.get(e,"bots",[]),r={};t.A.map(s,(t=>{r[t.id]=t})),this.cache.put("bot",r),this.device_type=e.device_type||"desktop";let n=t.A.get(e,"plugins",[]),o={};t.A.map(n,(e=>{"chatbox"===e.type&&(e=t.A.merge(e,this.forceChatbox)),o[e.id]=e})),this.cache.put("plugin",o);var a=t.A.get(e,"agents",[]);if(t.A.size(a)>0){let e={};this.api.setAgentId(a[0].id),t.A.map(a,(t=>{e[t.id]=t})),this.cache.put("agent",e)}let l=t.A.get(e,"payment_methods",[]);this.cache.put("payment_methods",l),this.pubsub.publish("account")}async track(){let e=await this.api.sendContentView(this.device,location.href,document.title,this._currentViewingProduct.id,this._currentViewingProduct.source_id,this._currentViewingProduct.sku),i=t.A.get(e,"body.by.device.source","");i&&this.kv.put("traffic_source",i)}async onWs(t){await this.wsGate.entry(),this.wsGate.close(),await this._onWs(t),this.wsGate.open()}async _onWs(e){if(this._die)return;if(!e||!e.type)return;if(e.created=t.A.getMs(e.created),"user_info_updated"===e.type){let i=t.A.cloneDeep(this.cache.match("user")),s=t.A.get(e,"data.user.attributes")||[];return t.A.map(s,(e=>t.A.setUserAttr(i,e))),void this._setUser(i)}let i,s=this.cache.match("user")||{},r=t.A.convoOfEv(e),n=!1;if(r&&(i=this.cache.match("convo_"+r),!i||!i.id)){let{body:t,error:e}=await this.api.getConversation(r);if(!t)return;i=t,n=!0,this._setConvo(i)}if(!i)return;let o=t.A.get(e,"touchpoint.channel","");if(!o||"subiz"==o){if(this.pubsub.publish("events",e),"conversation_joined"===e.type){let s=t.A.get(e,"data.conversation.members",[]);if(t.A.find(s,(t=>t.id===this.cache.match("user").id))&&!n){let{body:t}=await this.api.getConversation(r);t&&(i=t,this._setConvo(i)),this.pubsub.publish("account")}}return"message_sent"===e.type&&t.A.get(e,"by.id")!==s.id&&(this._alreadyReceived[e.id]||(this._alreadyReceived[e.id]=!0,this.api.markAsReceived(r,e.id))),t.A.startsWith(e.type,"message_")||t.A.startsWith(e.type,"conversation_")?(this.restConvoEvent(e),void("message_sent"===e.type&&t.A.get(e,"by.id")!==s.id&&C("SUBIZ Chat","Received","User"))):void 0}}async restConvoEvent(e){let i=this.cache.match("user"),s=t.A.convoOfEv(e),r=this.cache.match("convo_"+s)||{};if("conversation_state_updated"===e.type){if(!t.A.get(r,"id")){let{body:t,error:e}=await this.api.getConversation(s);if(e)return}r=Object.assign(r,t.A.get(e,"data.conversation"))}if("message_pong"===e.type){var n=t.A.get(e,"data.message.id"),o=this.chain.match(s,n);if(!t.A.get(o,"data.message"))return;var a=t.A.get(o,"data.message.pongs",[]);let l=t.A.get(e,"data.message.pongs",[])||[];if(a=a.concat(l),1===l.length){let t=l[0].type;"like"!==t&&"remove_dislike"!==t||(a=a.filter((t=>"dislike"!==t.type))),"dislike"!==t&&"remove_like"!==t||(a=a.filter((t=>"like"!==t.type)))}o.data.message.pongs=a,t.A.map(a,(e=>{if(e.member_id==i.id&&"seen"===e.type){let s=t.A.find(r.members,(t=>t.id===i.id));s&&(s.seen_at=e.created)}})),this.chain.put(s,o.id,t.A.getMs(o.created),o),this.pubsub.publish("events",o)}if("message_sent"===e.type){let i=t.A.get(e,"data.message.idempotency_key"),n=t.A.find(this.listEvents(s),(t=>t.id===i));n&&(this.chain.del(s,n.id),e.created=n.created),r.last_message_sent=e}"message_pong"!==e.type&&"conversation_typing"!==e.type&&this.chain.put(s,e.id,t.A.getMs(e.created),e),this._setConvo(r),this.pubsub.publish("account")}emitCloseWidgetEvent(){this.pubsub.publish("sbz_close_widget",{type:"chatbox_closed"})}typing(t){t&&this._typing(t)}async startConvo(t){t||(t={}),await this.readyGate.entry(),this.convoGate.close(),t.source||(t.source=document.location.href);let{body:e,error:i}=await this.api.start(t);return this.convoGate.open(),i?{error:i}:(this._setConvo(e),{convo:e})}fetchOrder(t){return this.api.getOrder(t)}lookupOrder(t){return this.api.lookupOrder(t)}createPostback(t,e){return this.api.createPostback(t,e)}sendReaction(t,e){return this.api.sendConvoEvent(t,e)}async sendConvoEvent(e,i,s){await this.readyGate.entry();var r=t.A.randomString(36),n={id:r,by:{id:(this.cache.match("user")||{}).id,type:"user",device:this.device},data:s,type:i,created:this.now()};t.A.convoToEv(e,n);let o=[];if("message_sent"===i&&(n.data.message.idempotency_key=r,n.data.message.conversation_id=e,await _.map(n.data.message.attachments,2,(async(t,e)=>{var i;if("file"===t.type&&t._file&&(o.push(t),k.includes(t._file.type))){let{width:e,height:s,url:r}=await(i=t._file,new Promise((t=>{var e=new window.FileReader;e.onload=e=>{let i=e.target.result,s=new Image;s.onload=()=>{t({url:i,width:s.width,height:s.height})},s.src=i},e.readAsDataURL(i)})));t.url=r,t.width=e,t.height=s}}))),this.onWs(n),await this.convoGate.entry(),await _.map(o,1,(async e=>{const{body:i,url:s,error:r}=await this.api.uploadToS3(e._file);"invalid_field_size"==t.A.get(i,"code")&&(n._error_message="cannot_send_too_big_file"),n._error=r,e.url=s})),n._error)return this.onWs(n);let{body:a,error:l}=await this.api.sendConvoEvent(e,n);return l?(n._error=l,void this.onWs(n)):(this.onWs(a),C("SUBIZ Chat","Sent","User"),this.kv.match("last_msg_sent")||(window.dataLayer||[]).push({event:"SUBIZ Chat",event_action:"Sent",event_label:"User",first_interaction:1}),this.kv.put("last_msg_sent",t.A.Date.now()),a)}_setConvo(e){this.cache.match("user");let i=t.A.get(e,"touchpoint.channel","");if(i&&"subiz"!=i)return;let s={};if(t.A.map(this.cache.all(),((t,e)=>{e.startsWith("convo_")&&(s[e]=t)})),t.A.size(s)>18){s=t.A.orderBy(t.A.map(s),"created","desc");for(var r=18;r<t.A.size(s);r++){let t=s[r];this.cache.del("convo_"+t.id)}}this.markSync(e.id),this.pubsub.publish("account"),this.cache.put("convo_"+e.id,e)}matchLastPluginRun(t){return(this.kv.match("plugin_run_logs")||{})[t]}matchLastBotRun(t){return(this.kv.match("bot_run_logs")||{})[t]}logBotRun(t){let e=this.kv.match("bot_run_logs")||{};e[t]={bot_id:t,created:this.now()},this.kv.put("bot_run_logs",e)}sendImpression(t){let e=this.cache.match("user")||{},i=this.kv.match("plugin_run_logs")||{};return i[t]={web_plugin_id:t,created:this.now()},this.kv.put("plugin_run_logs",i),this.api.sendImpression({account_id:e.account_id,campaign_id:t,web_plugin_id:t,user_id:e.id,url:window.location.href,device:this.device})}sendConversion(e,i,s){let r=this.cache.match("user")||{},n={account_id:r.account_id,user_id:r.id,fields:i},o=this.kv.match("conversions")||{};return o[e]=!0,this.kv.put("conversions",o),this.api.sendConversion({account_id:r.account_id,web_plugin_id:e,campaign_id:e,user_id:t.A.get(r,"id"),url:window.location.href,device:this.device,submission:n,impression_token:s})}isConverted(t){return(this.kv.match("conversions")||{})[t]}async listmessageapi(e,i,s){let r=e,{body:n,code:o,error:a}=await this.api.listMessages(r,-s,i);if(a||200!==o)return[[],i,a];i=t.A.get(t.A.last(n),"id"),n=t.A.map(n,(e=>(e.created=t.A.getMs(e.created),{id:e.id,index:e.created,value:e})));let l=this.cache.match("user")||{};for(let e=0;e<n.length;e++){let i=n[e].value;if("message_sent"===i.type&&t.A.get(i,"by.id")!==l.id){if(t.A.find(t.A.get(i,"data.message.pongs"),(t=>t.member_id===l.id)))break;this._alreadyReceived[i.id]||(this._alreadyReceived[i.id]=!0,this.api.markAsReceived(r,i.id));break}}return[n,i,void 0,t.A.size(n)<s]}async loopTime(){if(this._die)return;let e=t.A.Date.now();if(!t.A.get(this.cache.match("user"),"id"))return t.A.setTimeout((()=>this.loopTime()),24e4);let{body:i,error:s}=await this.api.time();if(s)return t.A.setTimeout((()=>this.loopTime()),3e4);var r=Math.abs(t.A.Date.now()-e)/2,n=new t.A.Date(i).getTime()+r,o=t.A.Date.now();this.timeDiff=Math.floor(n-o),t.A.setTimeout((()=>this.loopTime()),24e4)}replaceFileUrl(e){return e?t.A.startsWith(e,"/")||t.A.startsWith(e,"data:")?e:(t.A.startsWith(e,"http://")||t.A.startsWith(e,"https://")||t.A.startsWith(e,"//")||(e=t.A.trim(this.FileURL,"/")+"/"+t.A.trimStart(e,"/")),e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace("https://file-subiz.com/",this.FileURL)).replace("http://file-subiz.com/",this.FileURL)).replace("https://file-v4.subiz.com/",this.FileURL)).replace("http://file-v4.subiz.com/",this.FileURL)).replace("https://filev4.subiz.com/",this.FileURL)).replace("http://filev4.subiz.com/",this.FileURL)).replace("https://filev4-1.subiz.com/",this.FileURL)).replace("http://filev4-1.subiz.com/",this.FileURL)).replace("https://file.subiz.com/",this.FileURL)).replace("http://file.subiz.com/",this.FileURL)).replace("https://file.mysubiz.com/",this.FileURL)).replace("http://file.mysubiz.com/",this.FileURL)):""}clearBrowserData(){t.A.each(this.cookie.all(),((t,e)=>{(e||"").startsWith("__sb")&&this.cookie.remove(e)})),this.kv.destroy(),this.kv=new r.kv(new r.lsdb("sbz2023",this.inmem),"kv"),this.chain.destroy(),this.chain=new r.chain(new r.lsdb("cbz2023",!0),"ch")}destroy(){this._die=!0,this.kv&&this.kv.destroy(),this.chain&&this.chain.destroy(),t.A.clearInterval(this._seenInterval),this.realtime&&this.realtime.stop(),this.readyGate.close(),window.removeEventListener("blur",this.sendPresence),window.removeEventListener("focus",this.sendPresence)}}const k=["image/gif","image/jpeg","image/png","image/svg+xml"],x={data:{},get(t,e){return this.data[t]||e},set(t,e){return this.data[t]=t},all(){return this.data},remove(t){delete this.data[t]}};function C(t,e,i){document.dispatchEvent(new CustomEvent("subiz",{detail:{category:t,action:e,label:i}})),function(t,e,i){window.sbz_no_gtag?console.log("SKIPSENT.",t,e,i):((window.dataLayer||[]).push({event:t,event_action:e,event_label:i}),window.gtag&&window.gtag("event",t,{Action:e,Label:i}),window.ga&&window.ga.getAll&&(window.ga.getAll()||[]).forEach((function(s){const r=s.get("name");window.ga(r+".send","event",t,e,i)})))}(t,e,i),function(t,e,i){window.fbq&&window.fbq("trackCustom",t,{action:e,label:i})}(t,e,i)}let S=()=>{try{localStorage}catch(t){return}t.A.setTimeout((()=>{for(var t in localStorage)t&&(t.startsWith("cbz2020")||t.startsWith("sbz2020"))&&localStorage.removeItem(t)}))},M=()=>{try{localStorage}catch(t){return}t.A.setTimeout((()=>{for(var t in localStorage)t&&(t.startsWith("cbz2020")||t.startsWith("sbz2020")||t.startsWith("sbz2022")||t.startsWith("sbz2023"))&&localStorage.removeItem(t)}))};var I=function(e,i,s,r){if(void 0===t.A.XMLHttpRequest)return function(t,e,i,s){let r={};i&&(r["content-type"]="text/plain"),fetch(e,{method:t,headers:r,body:i}).then((t=>t.text().then((e=>s&&s(e,t.status))))).catch((t=>s&&s(t,-1)))}(e,i,s,r);var n=new t.A.XMLHttpRequest;n.onreadystatechange=function(t){4===n.readyState&&(r&&r(n.responseText,n.status),r=void 0)},n.onerror=function(){r&&r(n.responseText,-1),r=void 0},n.open(e,i),s&&n.setRequestHeader("content-type","text/plain"),n.send(s)};const P=new Error("sdk unloaded");var D=n(2840),j=n(172),E=n(2959),T=n(7072),L=n(1108);let U=n(2538);class z extends D.Mw{constructor(e){super(e),this.setState({opacity:0,previewEvent:{},displayPreview:!1}),this.loadGreeting(),this.props.store.onUpdate(this,(t=>this.forceUpdate())),this.props.store.onConvoEvent(this,(e=>{if("message_sent"!==t.A.get(e,"type"))return;let i=t.A.get(e,"by.type");if("system"!==i&&"agent"!==i)return;let s=!1;if(t.A.map(t.A.get(e,"data.message.attachments",[]),(t=>{t&&"quick_replies"===t.type&&(s=!0)})),!s){var r=t.A.filter(t.A.map(this.renderMessagePreview(e),(e=>t.A.trim(e))),(t=>t));t.A.size(r)>0&&this.setState({displayPreview:!0,previewEvent:e})}}))}fixMissingSetting(e){return e=t.A.cloneDeep(e),t.A.get(e,"desktop_button.background_image_url")&&(e.desktop_button.background_image_url=this.props.store.replaceFileUrl(e.desktop_button.background_image_url)),t.A.get(e,"desktop_button.background_mask_url")&&(e.desktop_button.background_mask_url=this.props.store.replaceFileUrl(e.desktop_button.background_mask_url)),t.A.get(e,"mobile_button.background_image_url")&&(e.mobile_button.background_image_url=this.props.store.replaceFileUrl(e.mobile_button.background_image_url)),t.A.get(e,"mobile_button.background_mask_url")&&(e.mobile_button.background_mask_url=this.props.store.replaceFileUrl(e.mobile_button.background_mask_url)),e}render(){let e=this.props.plugin.chatbox,i=t.A.get(e,"desktop_button.position")||"right";if(this.props.store.isMobile()&&(i=t.A.get(e,"mobile_button.position")||i,t.A.get(e,"mobile_button.hidden")))return null;if(t.A.get(e,"desktop_button.hidden"))return null;let s="widget-layout widget-layout--"+i,r=this.state.opacity;return this.props.isShow||(s+=" widget-layout--hidden",r=0),(0,j.h)("div",{class:s,style:"opacity: "+r+" !important"},this.renderPreview(),this.renderButton())}ClearPreview(){this.setState({previewEvent:{}})}ClosePreview(){this.setState({displayPreview:!1})}ShowGreeting(){if(this.props.store.isMobile()&&"acqjeefqeaoiagyfprap"===t.A.get(this.props.plugin,"chatbox.account_id",{}))return;let e=t.A.get(this.props.plugin,"chatbox.greeting",{}),i=this.props.store.matchAgent("*"),s=e.agent_id;s||(s=function(e){var i=t.A.filter(e,(t=>"agent"===t.type));return i[Math.floor(Math.random()*t.A.size(i))]||{}}(i).id);let r=this.props.t.i18n(t.A.get(e,"greeting",{}))||e.message;this.setState({previewEvent:{by:{id:s,type:"agent"},data:{message:{text:r,format:"plaintext"}}},displayPreview:!0})}HideGreeting(){this.setState({previewEvent:{}})}loadGreeting(){let e=this.props.plugin.chatbox;if((new t.A.Date).getTime()-this.props.store.matchClosePreviewAt()<R)return;let i=t.A.get(e,"greeting",{}),s=this.props.t.i18n(t.A.get(i,"greeting",{}))||i.message,r=i.enabled;this.props.store.isMobile()&&(r=r&&!t.A.get(i,"mobile_disabled")),s&&r?this.ShowGreeting():this.setState({previewEvent:{}})}onClick(){let e=this.props.store.matchLastview();return t.A.get(e,"view")&&("list"!==e.view||t.A.size(this.props.store.matchConvo("*"))>0)?this.props.onClick&&this.props.onClick(Object.assign({},e.opts,{view:e.view})):this.onPreviewClick()}onPreviewClick(e){let i=t.A.convoOfEv(this.state.previewEvent);if(!i){let e=t.A.map(this.props.store.matchConvo("*")),s=t.A.find(e,(e=>!t.A.isConvoSeen(e,this.props.store.matchUser().id)));s||(s=e[0]||{}),i=s.id}this.closePreview(e),this.props.onClick&&this.props.onClick({view:"chat",cid:i})}renderUnread(){let t=this.props.store.matchUnread();return 0===t?null:(0,j.h)("div",{class:"chat-button--unread"},t)}renderPreview(){let e=this.props.store.matchAccount(),i=this.props.plugin.chatbox,s=t.A.get(this.state.previewEvent,"by.display_id",t.A.get(this.state.previewEvent,"by.id")),r=this.props.store.matchAgent(s);r||(r=this.props.store.matchAgent("*")[s]||{}),r=t.A.cloneDeep(r),r.fullname=r.fullname||t.A.get(e,"name")||this.props.t("agent"),r.avatar_url=r.avatar_url||U;let o=t.A.get(i,"desktop_button.position")||"right";this.props.store.isMobile()&&(o=t.A.get(i,"mobile_button.position")||o),i&&i.hide_agent_profile&&(r=Object.assign({},e,{avatar_url:e.logo_url||n(3582),fullname:e.name||this.props.t("agent")}));let a="widget-preview widget-preview--"+o;this.state.displayPreview||(a+=" widget-preview--hidden");var l=this.renderMessagePreview(this.state.previewEvent);return 0===t.A.size(l)&&(a+=" widget-preview--hidden"),(0,j.h)("div",{class:a},(0,j.h)("div",{class:"widget-preview--body"},(0,j.h)("img",{alt:"widget avatar",class:"widget-preview--avatar",src:this.props.store.replaceFileUrl(r.avatar_url),onError:t=>this.onProfileError(t),onload:t=>this.onProfileReady()}),(0,j.h)("div",{class:"widget-preview--content",onClick:t=>this.onPreviewClick(t)},(0,j.h)("div",{class:"widget-preview--title"},r.fullname),(0,j.h)("p",{class:"widget-preview--message"},l)),(0,j.h)("div",{class:"widget-preview--btn-close",onClick:t=>this.closePreview(t)})),(0,j.h)("div",{class:"widget-preview--action",onClick:t=>this.onPreviewClick(t)},(0,j.h)("div",{class:"widget-preview--action-text"},this.props.t("chat_now"))))}onProfileReady(){this._buttonLoaded&&this.setState({opacity:1}),this._profileLoaded=!0}onButtonReady(){this._profileLoaded&&this.setState({opacity:1}),this._buttonLoaded=!0}renderButton(){let e=this.props.plugin.chatbox;e=this.fixMissingSetting(e);let i=t.A.get(e,"desktop_button.background_image_url")||t.A.get(e,"desktop_button.background_mask_url")||L,s=t.A.get(e,"background")||$,r=t.A.get(e,"desktop_button.position")||"right",n=t.A.get(e,"desktop_button.background_image_url"),o=t.A.get(e,"desktop_button.background_mask_url"),a=t.A.get(e,"desktop_button.width")||70,l=t.A.get(e,"desktop_button.height")||70;if(this.props.store.isMobile()){i=t.A.get(e,"mobile_button.background_image_url")||t.A.get(e,"mobile_button.background_mask_url")||i,r=t.A.get(e,"mobile_button.position")||r;let s=t.A.get(e,"mobile_button.background_image_url"),c=t.A.get(e,"mobile_button.background_mask_url");a=t.A.get(e,"mobile_button.width")||70,l=t.A.get(e,"mobile_button.height")||70,(s||c)&&(n=s,o=c)}let c="chat-button--white-bg";!n&&o&&(c+=" chat-button--white-bg--mask-only");let h="";n=this.props.store.replaceFileUrl(n),i=this.props.store.replaceFileUrl(i),o=this.props.store.replaceFileUrl(o),n||o||(c+=" chat-button--white-bg--mask-only",h=`\n\t\t\t\t-webkit-mask-image: url("${encodeURI(O)}") !important;\n\t\t\t\t-o-mask-image: url("${encodeURI(O)}") !important;\n\t\t\t\t-moz-mask-image: url("${encodeURI(O)}") !important;\n\t\t\t\tmask-image: url("${encodeURI(O)}") !important;\n\t\t\t\theight: ${l}px !important;\n\t\t\t\twidth: ${a}px !important;\n\t\t\t\tbackground: ${s} !important;\n\t\t\t\tbackground: ${s} !important;\n mask-size: cover !important;\n -webkit-mask-size: cover !important;\n -o-mask-size: cover !important;\n -moz-mask-size: cover !important;\n mask-size: cover !important;\n\t\t\t`),n&&o&&(h=`\n\t\t\t\t-webkit-mask-image: url("${encodeURI(o)}") !important;\n\t\t\t\t-o-mask-image: url("${encodeURI(o)}") !important;\n\t\t\t\t-moz-mask-image: url("${encodeURI(o)}") !important;\n\t\t\t\tmask-image: url("${encodeURI(o)}") !important;\n\t\t\t\tbackground-image: url("${encodeURI(n)}") !important;\n\t\t\t\tbackground-repeat: no-repeat !important;\n -webkit-mask-size: cover !important;\n -o-mask-size: cover !important;\n -moz-mask-size: cover !important;\n mask-size: cover !important;\n\t\t\t`),n&&!o&&(h=`\n\t\t\t\tbackground-image: url("${encodeURI(n)}") !important;\n\t\t\t\tbackground-repeat: no-repeat !important;\n\t\t\t`),!n&&o&&(h=`\n\t\t\t\t-webkit-mask-image: url("${encodeURI(o)}") !important;\n\t\t\t\t-o-mask-image: url("${encodeURI(o)}") !important;\n\t\t\t\t-moz-mask-image: url("${encodeURI(o)}") !important;\n\t\t\t\tmask-image: url("${encodeURI(o)}") !important;\n\t\t\t\theight: ${l}px !important;\n\t\t\t\twidth: ${a}px !important;\n\t\t\t\tbackground: ${s} !important;\n -webkit-mask-size: cover !important;\n -o-mask-size: cover !important;\n -moz-mask-size: cover !important;\n mask-size: cover !important;\n\t\t\t`);let u="chat-button chat-button--"+r,d=`\n\t\t\twidth: ${a-4}px !important;\n\t\t\theight: ${l-4}px !important;\n\n `;return(0,j.h)("div",{class:u,onClick:t=>this.onClick(t)},(0,j.h)("div",{class:c,style:d}),(0,j.h)("div",{class:"chat-button--img-container",style:h},(0,j.h)("img",{width:"70",height:"70",alt:"chat button",class:"chat-button--img",onload:()=>this.onButtonReady(),src:i,onError:(t,e)=>this.onChatButtonError(t,e)})),this.renderUnread())}onProfileError(t){t.target.src=U,this.onProfileReady()}onChatButtonError(t){this._onChatButtonErrorExecuted||(this._onChatButtonErrorExecuted=!0,t.target.src=L)}renderMessagePreview(e,i){i=i||this.props.t("sent_you_a_message");var s=t.A.get(e,"data.message.format");let r=t.A.get(e,"data.message.block");if(r||"block"==s)return(0,j.h)(T.A,{block:r});let n=t.A.get(e,"data.message.text",i);return!n&&t.A.size(t.A.get(e,"data.message.attachments"))>0&&(n=i),n?(t.A.get(e,"by.type"),t.A.extractText(n).map((t=>"emoji"===t.type?(0,j.h)(E.A,{emojiCode:t.text}):t.text))):null}closePreview(t){t&&(t.preventDefault(),t.stopPropagation()),this.setState({displayPreview:!1}),this.props.store.closePreview(),this.forceUpdate()}}const R=18e5,O="https://vcdn.subiz-cdn.com/file/bubble_11.svg?v=5",$="linear-gradient(280.16deg, #0053d3 22.03%, #0265ff 78.2%)";var F=n(9529);function q(t){if(t.store.isMobile())return null;if(t.store.isAIDevMode())return null;let e=t.store.matchUser()||{};var i=`https://subiz.com.vn/?utm_source=${window.location.host||`id-${e.account_id}`}&utm_medium=widget&utm_campaign=widget_referral`;return(0,j.h)("div",{class:"poweredby"},(0,j.h)("a",{href:i,class:"poweredby--text",target:"_blank",title:"Subiz"},(0,j.h)("img",{width:"17",height:"12",class:"poweredby--subiz-logo",src:F,alt:"powerred by subiz"})," Subiz"))}function W(e){let i=e.plugin.chatbox,s=e.store.matchAccount()||{};var r=e.tooltipPos||"bottom",o=e.mode||"primary";if(i&&i.hide_agent_profile)return(0,j.h)("div",{class:`group-avatar group-avatar--${o}`},(0,j.h)("div",{class:"d-inline-block pos-relative","data-tooltip":s.name,"data-tooltip-position":r},(0,j.h)("img",{width:35,height:35,alt:"agent avatar left",class:"avatar group-avatar--agent-left",src:e.store.replaceFileUrl(s.logo_url)||n(3582)})));let a=e.store.matchAgent("*");var l=t.A.map(e.agent_ids,(t=>a[t]));if(void 0===e.agent_ids||0===t.A.size(e.agent_ids)){var c=t.A.get(i,"header.agent_ids",[]);l=0!==(c=t.A.filter(c,(t=>!!a[t]))).length?t.A.map(c,(t=>a[t])):t.A.filter(a,(t=>"agent"===t.type))}if(0===(l=t.A.filter(l,(t=>!!t))).length||void 0===e.agent_ids||0===t.A.size(e.agent_ids))return(0,j.h)("div",{class:`group-avatar group-avatar--${o}`},(0,j.h)("div",{class:"d-inline-block pos-relative","data-tooltip":s.name,"data-tooltip-position":r},(0,j.h)("img",{width:35,height:35,alt:"agent avatar left",class:"avatar group-avatar--agent-left",src:e.store.replaceFileUrl(s.logo_url)||n(3582)})));if(1===l.length){var h=l[0],u="primary"===o?"group-avatar--agent-middle":"group-avatar--agent-left";return(0,j.h)("div",{class:`group-avatar group-avatar--${o}`},(0,j.h)("div",{class:"d-inline-block pos-relative","data-tooltip":h.fullname||s.name,"data-tooltip-position":r},(0,j.h)("img",{width:35,height:35,class:`avatar ${u}`,alt:"agent avatar",src:e.store.replaceFileUrl(h.avatar_url)||n(2538)})))}if(2===l.length){let t=l[0],i=l[1];return(0,j.h)("div",{class:`group-avatar group-avatar--${o}`},(0,j.h)("div",{class:"d-inline-block pos-relative","data-tooltip":t.fullname||s.name,"data-tooltip-position":r},(0,j.h)("img",{width:35,height:35,alt:"agent avatar left",class:"avatar group-avatar--agent-left",src:e.store.replaceFileUrl(t.avatar_url)||n(2538)})),(0,j.h)("div",{class:"d-inline-block pos-relative","data-tooltip":i.fullname||s.name,"data-tooltip-position":r},(0,j.h)("img",{alt:"agent avatar right",width:35,height:35,class:"avatar group-avatar--agent-right",src:e.store.replaceFileUrl(i.avatar_url)||n(2538)})))}let d=l[0],p=l[1],m=l[2];return(0,j.h)("div",{class:`group-avatar group-avatar--${o}`},(0,j.h)("div",{class:"d-inline-block pos-relative","data-tooltip":d.fullname||s.name,"data-tooltip-position":r},(0,j.h)("img",{width:35,height:35,alt:"agent avatar left",class:"avatar group-avatar--agent-left",src:e.store.replaceFileUrl(d.avatar_url)||n(2538)})),(0,j.h)("div",{class:"d-inline-block pos-relative","data-tooltip":p.fullname||s.name,"data-tooltip-position":r},(0,j.h)("img",{alt:"agent avatar middle",width:35,height:35,class:"avatar group-avatar--agent-middle",src:e.store.replaceFileUrl(p.avatar_url)||n(2538)})),(0,j.h)("div",{class:"d-inline-block pos-relative","data-tooltip":m.fullname||s.name,"data-tooltip-position":r},(0,j.h)("img",{width:35,height:35,alt:"agent avatar right",class:"avatar group-avatar--agent-right",src:e.store.replaceFileUrl(m.avatar_url)||n(2538)})))}class B extends D.Mw{constructor(t){super(t)}render(){let e="widget-header",i=!1,s=!1,r=this.props.plugin.chatbox||{},n=t.A.get(r,"header.layout"),o="list"!==this.props.view&&!0,a=!o&&"classic"===n;return o||"classic"==n?e+=" widget-header--collapsed":(e+=" widget-header--convo-expanded",i="social"===n,s=!(i||a)),(0,j.h)("div",{class:e},this.renderCollapsedHeader(o||a,a),this.renderSocial(i),this.renderTeam(s))}renderCollapsedHeader(e,i){let s=this.props.plugin.chatbox||{},r=(this.props.store.matchAccount()||{}).is_online?this.props.t("agent_online"):this.props.t("agent_offline"),n=t.A.get(s,"tagline",{}),o=this.props.t.i18n(n)||s.introduction||r,a=(t.A.map(this.getAgentJoined(this.props.cid),(t=>t.id)),"widget-header--inner widget-header--inner--collapsed");e||(a+=" widget-header--inner--hidden");let l=null,c="";return i?c="padding-bottom: 75px !important;":l=this.renderBackButton(),(0,j.h)("div",{class:a,style:c},l,(0,j.h)("div",{class:"mr-2"}),(0,j.h)(W,{plugin:this.props.plugin,store:this.props.store,mode:"secondary"}),(0,j.h)("div",{class:"widget-header--title-container"},(0,j.h)("div",{class:"widget-header--title"},this.getTitle()),(0,j.h)("div",{class:"widget-header--description",title:o},o)),this.renderCloseButton())}renderSocial(e){let i=this.props.plugin.chatbox||{},s=this.props.store.matchAccount()||{},r=t.A.get(i,"header.links")||[],n=t.A.map(r,(t=>t.url&&t.type&&"subiz"!==t.type?"email"===t.type?(0,j.h)("div",null,(0,j.h)("a",{href:`mailto:${t.url}`,title:t.url},(0,j.h)("i",{class:`social__links-logo social__links-logo--${t.type}`}))):(0,j.h)("div",null,(0,j.h)("a",{href:t.url,target:"_blank",title:t.url},(0,j.h)("i",{class:`social__links-logo social__links-logo--${t.type}`}))):null)),o=t.A.get(i,"tagline",{});var a=this.props.t.i18n(o)||i.introduction||this.props.t("team_intro")||"Chúng tôi sẵn sàng trợ giúp :wave:.\nVui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi của bạn",l=t.A.extractText(a).map((t=>"emoji"===t.type?(0,j.h)(E.A,{emojiCode:t.text}):t.text));let c="widget-header--inner widget-header--inner--expanded";return e||(c+=" widget-header--inner--hidden"),(0,j.h)("div",{class:c},(0,j.h)("div",{class:"widget-header-expand-container"},(0,j.h)("div",{class:"widget-header--top-wrapper"},(0,j.h)("div",{class:"widget-header--title"},this.getTitle()),this.renderCloseButton()),(0,j.h)("div",{class:"widget_header__body widget_header__body__social"},(0,j.h)("img",{alt:"logo",class:"social__account_logo",src:this.props.store.replaceFileUrl(t.A.get(s,"logo_url"))}),(0,j.h)("div",null,(0,j.h)("div",{class:"social__introduction"},l),(0,j.h)("div",{class:"social__links"},n)))))}renderTeam(e){let i=this.props.plugin.chatbox||{},s=t.A.get(i,"tagline",{});var r=this.props.t.i18n(s)||i.introduction||this.props.t("team_intro")||"Chúng tôi sẵn sàng trợ giúp :wave:.\nVui lòng hỏi chúng tôi bất cứ điều gì hoặc chia sẻ phản hồi của bạn",n=t.A.extractText(r).map((t=>"emoji"===t.type?(0,j.h)(E.A,{emojiCode:t.text}):t.text));let o="widget-header--inner widget-header--inner--expanded";return e||(o+=" widget-header--inner--hidden"),(0,j.h)("div",{class:o},(0,j.h)("div",{class:"widget-header-expand-container"},(0,j.h)("div",{class:"widget-header--top-wrapper"},(0,j.h)("div",{class:"widget-header--title"},this.getTitle()),this.renderCloseButton()),(0,j.h)("div",{class:"widget_header__body"},(0,j.h)("div",{class:"widget-header--avatar-wrapper"},(0,j.h)(W,{plugin:this.props.plugin,store:this.props.store,mode:"primary"})),(0,j.h)("div",{class:"widget-header--title-container"},(0,j.h)("div",{class:"widget-header--description"},n)))))}getTitle(){let e=this.props.plugin.chatbox||{},i=this.props.store.matchAccount()||{},s=this.getAgentJoined(this.props.cid),r=t.A.get(this.props.plugin,"chatbox.caption",{}),n=this.props.t.i18n(r)||e.title;return G(s)||n||i.name||this.props.t("widget_title")}renderBackButton(){let e=this.props.store.matchConvo("*");if(0===t.A.size(e))return null;var i=null;let s=this.props.store.matchUser(),r=0;return t.A.map(e,(e=>{e.id!=this.props.cid&&(t.A.isConvoSeen(e,s.id)||r++)})),0!==r&&(i=(0,j.h)("span",{class:"widget-header--total-unread-convo"},r)),(0,j.h)("div",{class:"widget-header--wrap-button-back "+(r?"widget-header--has-convo-unred":""),onClick:t=>this.onBackClick(t)},(0,j.h)("div",{class:"widget-header--button-back","data-tooltip":this.props.t("menu_back")}),i)}renderCloseButton(){return(this.props.plugin.chatbox||{}).hide_close_button?null:(0,j.h)("div",{class:"widget-header--button-close","data-tooltip":this.props.t("close"),"data-tooltip-position":"bottom",onClick:t=>this.onCloseClick(t)},(0,j.h)("span",{class:"widget-header--button-close-icon"}))}onBackClick(t){t.stopPropagation(),t.preventDefault(),this.props.onGotoList&&this.props.onGotoList()}onCloseClick(t){t.stopPropagation(),t.preventDefault(),this.props.onClose&&this.props.onClose()}getAgentJoined(e){var i=this.props.store.matchConvo(e)||{};return t.A.filter(i.members,(t=>"agent"===t.type&&"active"===t.membership))}}let G=e=>(e=t.A.filter(e,(e=>t.A.trim(e.fullname)))).length?t.A.map(e,(t=>t.fullname)).join(", "):null;var H=n(4188);class V extends D.Mw{constructor(e){var i,s,r;super(e),i=this,s="onEnter",r=t.A.throttle((function(){this.submitMessage()}),50),(s=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(s))in i?Object.defineProperty(i,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):i[s]=r,this.refFileInput=(0,j._3)(),this.refMessageInput=(0,j._3)(),this.props.store.onUpdate(this,(t=>this.forceUpdate())),this.props.store.onConvoEvent(this,(e=>{t.A.convoOfEv(e)===this.props.cid&&this.forceUpdate()})),this.focus(),this._forceUpdate=t.A.throttle((()=>{this.forceUpdate()}),500),this.resizeInput=t.A.throttle((function(){const t=this.refMessageInput.current;t.style.setProperty("height","1em","important");const e=Math.min(200,t.scrollHeight);t.style.setProperty("height",`${e}px`,"important")}),5)}blur(){const t=this.refMessageInput.current;t&&t.blur()}render(){var e=(0,j.h)("div",{class:"d-flex flex-row align-self-end"},this.renderEmoji(),(0,j.h)("div",{"data-tooltip-poasition":"top-left",class:"message-input--button message-input--attachment-button",onClick:t=>this.selectFile(t)}));t.A.trim(this.state.msgValue).length>0&&(e=(0,j.h)("div",{class:"d-flex flex-row align-self-end"},this.renderEmoji(),(0,j.h)("div",{"data-tooltip-position":"top-left",class:"message-input--button message-input--send-button",onClick:()=>this.submitMessage()}))),this.props.is_loading&&(e=(0,j.h)("div",{class:"d-flex flex-row align-self-end"},(0,j.h)(H.A,{size:"32"})));var i="",s=this.hasUnfinishRequiredFormOrLock()||this.props.disabled;return(s||this.props.is_loading)&&(i="message-input--disabled"),(0,j.h)("div",{class:`message-input ${i}`,onClick:t=>{this.refMessageInput.current&&this.refMessageInput.current.focus()}},(0,j.h)("input",{class:"d-none",ref:this.refFileInput,type:"file",onChange:t=>this.sendFile(t),multiple:!0}),(0,j.h)("textarea",{disabled:s,class:"message-input--input",maxlength:"1024",placeholder:this.props.t("message_input_help").substr(0,25),ref:this.refMessageInput,rows:"1",value:this.state.msgValue,onInput:t=>this.onChange(t),onPaste:t=>this.pasteImage(t),"data-emojiable":"true",onKeydown:t=>this.onKeydown(t)}),e)}hasUnfinishRequiredFormOrLock(){let e=this.props.store.matchConvo(this.props.cid);if("ended"===t.A.get(e,"state"))return!1;let i=this.props.store.listEvents(this.props.cid);i=t.A.orderBy(i,"created","desc").filter((t=>"message_sent"===t.type));let s=t.A.get(i[0],"data.message.attachments",[]);if(t.A.find(s,(e=>t.A.get(e,"lock_input"))))return!0;var r;for(let e of i)if("user"!==t.A.get(e,"by.type")){r=e;break}s=t.A.get(r,"data.message.attachments",[]);let n=t.A.filter(s,(e=>{if(!e)return!1;if("form"!==e.type&&"ask_info_form"!==e.type)return!1;var i=e.form;return!(!i||!(t.A.parseJSON(i.state)||{}).require_finished&&"ask_info_form"!==e.type||function(e){let i=t.A.get(e,"fields")||[];return t.A.find(i,(t=>!!t.answered))}(e.form))}));return t.A.size(n)>0}renderEmojiPopup(){return this.state.openEmoji?(0,j.h)("div",{class:"emoji-picker","v-clickaway":t=>this.setState({openEmoji:!1})},(0,j.h)("div",{class:"emoji-picker-background-item"},(0,j.h)("div",{onClick:()=>this.emojiPick(":like:"),"data-tooltip":":like:",class:"emoji-picker--item emoji--like"})),(0,j.h)("div",{class:"emoji-picker-background-item"},(0,j.h)("div",{onClick:()=>this.emojiPick(":unlike:"),"data-tooltip":":unlike:",class:"emoji-picker--item emoji--unlike"})),(0,j.h)("div",{class:"emoji-picker-background-item"},(0,j.h)("div",{onClick:()=>this.emojiPick(":angry:"),"data-tooltip":":angry:",class:"emoji-picker--item emoji--angry"})),(0,j.h)("div",{class:"emoji-picker-background-item"},(0,j.h)("div",{onClick:()=>this.emojiPick(":confused:"),"data-tooltip":":confused:",class:"emoji-picker--item emoji--confused"})),(0,j.h)("div",{class:"emoji-picker-background-item"},(0,j.h)("div",{onClick:()=>this.emojiPick(":crying:"),"data-tooltip":":crying:",class:"emoji-picker--item emoji--crying"})),(0,j.h)("div",{class:"emoji-picker-background-item"},(0,j.h)("div",{onClick:()=>this.emojiPick(":grinning:"),"data-tooltip":":grinning:",class:"emoji-picker--item emoji--grinning"})),(0,j.h)("div",{class:"emoji-picker-background-item"},(0,j.h)("div",{onClick:()=>this.emojiPick(":heart-eyes:"),"data-tooltip":":heart-eyes:",class:"emoji-picker--item emoji--heart-eyes"})),(0,j.h)("div",{class:"emoji-picker-background-item"},(0,j.h)("div",{onClick:()=>this.emojiPick(":neutral:"),"data-tooltip":":neutral:",class:"emoji-picker--item emoji--neutral"})),(0,j.h)("div",{class:"emoji-picker-background-item"},(0,j.h)("div",{onClick:()=>this.emojiPick(":sad:"),"data-tooltip":":sad:",class:"emoji-picker--item emoji--sad"})),(0,j.h)("div",{class:"emoji-picker-background-item"},(0,j.h)("div",{onClick:()=>this.emojiPick(":sleepy:"),"data-tooltip":":sleepy:",class:"emoji-picker--item emoji--sleepy"})),(0,j.h)("div",{class:"emoji-picker-background-item"},(0,j.h)("div",{onClick:()=>this.emojiPick(":smiling:"),"data-tooltip":":smiling:",class:"emoji-picker--item emoji--smiling"})),(0,j.h)("div",{class:"emoji-picker-background-item"},(0,j.h)("div",{onClick:()=>this.emojiPick(":surprised:"),"data-tooltip":":surprised:",class:"emoji-picker--item emoji--surprised"})),(0,j.h)("div",{class:"emoji-picker-background-item"},(0,j.h)("div",{onClick:()=>this.emojiPick(":tired:"),"data-tooltip":":tired:",class:"emoji-picker--item emoji--tired"})),(0,j.h)("div",{class:"emoji-picker-background-item"},(0,j.h)("div",{onClick:()=>this.emojiPick(":tongue-out:"),"data-tooltip":":tongue-out:",class:"emoji-picker--item emoji--tongue-out"})),(0,j.h)("div",{class:"emoji-picker-background-item"},(0,j.h)("div",{onClick:()=>this.emojiPick(":wink:"),"data-tooltip":":wink:",class:"emoji-picker--item emoji--wink"}))):null}applyMessage(t){this.setState({msgValue:t}),this.resizeInput()}focus(){this.props.disabled||(this.refMessageInput.current&&this.refMessageInput.current.focus(),t.A.setTimeout((()=>{this.refMessageInput.current&&this.refMessageInput.current.focus()})),t.A.setTimeout((()=>{this.refMessageInput.current&&this.refMessageInput.current.focus()}),100))}renderEmoji(){return(0,j.h)("div",null,this.renderEmojiPopup(),(0,j.h)("div",{class:"message-input--button message-input--emoji-button",onClick:t=>this.toggleEmoji(t)}))}toggleEmoji(t){t.stopPropagation(),this.focus(),this.props.disabled||this.setState({openEmoji:!this.state.openEmoji})}emojiPick(t){const e=this.refMessageInput.current,i=e.selectionStart,s=this.state.msgValue||"";this.setState({openEmoji:!1,msgValue:[s.slice(0,i),t,s.slice(i)].join("")}),this.resizeInput(),e.focus()}onKeydown(t){if(13===t.keyCode&&!1===t.shiftKey)return this.onEnter(),t.preventDefault();this._forceUpdate(),this.sendTyping()}onChange(t){this.setState({msgValue:t.target.value}),this.resizeInput()}selectFile(){this.props.disabled||this.refFileInput.current.click()}sendFile(){let t=this.refFileInput.current;this._sendFile(t.files),t.value=""}_sendFile(e){if(0===t.A.size(e))return;if(this.props.disabled)return;let i=t.A.map(e,(t=>({type:"file",mimetype:t.type,name:t.name,_file:t,size:t.size})));this.props.onSend&&this.props.onSend({attachments:i})}async submitMessage(e){(e=e||t.A.trim(this.state.msgValue)||"")&&(this.props.disabled||(this.props.onSend&&await this.props.onSend({text:e,format:"plaintext"}),this.setState({openEmoji:!1,msgValue:""}),this.resizeInput()))}sendTyping(){if(this.props.cid)return this.props.store.typing(this.props.cid)}pasteImage(e){if(!(window.File&&window.FileReader&&window.FileList&&window.Blob))return;let i=new t.A.Date;const s=`Paste-image-${i.getFullYear()}-${i.getMonth()+1}-${i.getDate()}-${i.getHours()}-${i.getMinutes()}-${i.getSeconds()}`;let r=null;const n=e.clipboardData.items[0];if(0===n.type.indexOf("image")&&(r=n.getAsFile()),!r)return;const o=[r,new ArrayBuffer],a=new File(o,`${s}.png`,{type:"image/png"});this._sendFile([a])}}class N extends D.Mw{constructor(t){var e,i,s;super(t),e=this,i="containerRef",s=(0,j._3)(),(i=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(i))in e?Object.defineProperty(e,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[i]=s,this.setState({ready:!1,errorIndecies:[]})}componentDidMount(){this.setImageFrameDimension()}setImageFrameDimension(){let t=this.containerRef.current;this.frameWidth=t?t.parentNode.parentNode.offsetWidth:267,this.frameHeight=240,this.setState({ready:!0})}onErrorImage(t){let e=this.state.errorIndecies||[];e.push(t),e=[...e],this.setState({errorIndecies:e})}calculateImageDimension(t){if(!t.width||!t.height)return{width:this.frameWidth,height:this.frameHeight};if(t.width/t.height-this.frameWidth/this.frameHeight>=0){let e=this.frameWidth,i=t.height*this.frameWidth/t.width;return i=Math.round(i),{width:e,height:i}}{let e=this.frameHeight,i=t.width*this.frameHeight/t.height;return i=Math.round(i),{width:i,height:e}}}renderImage(e,i){if(!this.state.ready)return;let s=t.A.get(this.props.ev,"by.type");if(!e.width||!e.height)return(0,j.h)("div",{class:`image-attachment image-attachment--${s}`},(0,j.h)("a",{href:this.props.store.replaceFileUrl(e.url),target:"_blank"},(0,j.h)("img",{alt:!0,class:"image-attachment__img",src:this.props.store.replaceFileUrl(e.thumbnail_url||e.url),onload:t=>this.props.onLoad&&this.props.onLoad()})));let{width:r,height:o}=this.calculateImageDimension(e),a=this.props.store.replaceFileUrl(e.thumbnail_url||e.url),l=this.props.store.replaceFileUrl(e.url);return this.state.errorIndecies.includes(i)&&(a=n(2876),l=a),(0,j.h)("div",{class:`image-attachment image-attachment--${s}`},(0,j.h)("a",{href:l,target:"_blank"},(0,j.h)("img",{alt:!0,ref:t=>{t&&(t.style.setProperty("width",`${r}px`,"important"),t.style.setProperty("height",`${o}px`,"important"))},class:"image-attachment__img",src:a,onload:t=>this.props.onLoad&&this.props.onLoad(),onerror:t=>this.onErrorImage(i)})))}render(){var e=t.A.get(this.props.ev,"data.message.attachments",[]),i=[];let s=t.A.get(this.props.ev,"by.type");if(t.A.each(e,((e,s)=>{if(e&&t.A.includes(e.mimetype,"image")&&e.url){var r=e.url;r.startsWith("https://")||r.startsWith("http://")||r.startsWith("content://")||r.startsWith("data:")||(e.url=this.props.store.FileURL+r),i.push(e)}})),0===i.length)return null;let r=t.A.map(i,((t,e)=>this.renderImage(t,e)));return"agent"===s?(0,j.h)("div",{class:"message-agent",ref:this.containerRef},r):(0,j.h)("div",{class:"message-user message-user-images-container",ref:this.containerRef},r)}}function J(e){let i=t.A.get(e.ev,"by.type");var s=t.A.get(e.ev,"data.message.attachments",[]),r=[];if(t.A.each(s,((e,i)=>{e&&t.A.includes(e.mimetype,"audio")&&r.push(e)})),0===r.length)return null;var n=t.A.map(r,((t,s)=>(0,j.h)("div",{key:s,class:`audio-attachment audio-attachment--${i}`},(0,j.h)("audio",{class:"audio-attachment__audio",controls:!0},(0,j.h)("source",{src:e.store.replaceFileUrl(t.url),type:t.mimetype})))));return(0,j.h)("div",{class:`message-${i} message-${i}-audio`},n)}class Q extends D.Mw{render(){var e=t.A.get(this.props.ev,"by.type","agent"),i=t.A.get(this.props.ev,"data.message.attachments",[]),s=[];if(t.A.each(i,(e=>{e&&(e.url||e._file)&&(t.A.includes(e.mimetype,"video")||t.A.includes(e.mimetype,"audio")||t.A.includes(e.mimetype,"image")||"button"===e.type||"quick_replies"===e.type||"form"===e.type||"form_submit"===e.type||s.push(e))})),0===s.length)return null;var r=t.A.map(s,((t,i)=>(0,j.h)("div",{key:i,class:`file-attachment file-attachment--${e}`},(0,j.h)("a",{class:"file-attachment--link",href:this.props.store.replaceFileUrl(t.url),target:"_blank"},(0,j.h)("span",{class:"file-attachment--download mr-2"}),(0,j.h)("span",{class:"file-attachment--filename"},t.name)))));return(0,j.h)("div",{class:`message-${e}`},r)}}function X(e){if(0===t.A.size(e.buttons))return null;var i=t.A.map(e.buttons,((t,i)=>"call_button"===t.type?(0,j.h)("a",{class:"url-button-attachment",href:"tel:"+t.phone_number,key:i,title:t.title},e.t.i18n(t.i18n_title)||t.title):"url_button"===t.type?(0,j.h)("a",{class:"url-button-attachment",href:t.url,target:"_blank",key:i,title:t.title},e.t.i18n(t.i18n_title)||t.title||t.url):"postback_button"===t.type?(0,j.h)("a",{class:"url-button-attachment",href:"javascript:;",onClick:i=>e.onSelect(t)},e.t.i18n(t.i18n_title)||t.title):("widget_ask_desktop_notify_button"===t.type||t.type,null)));return(0,j.h)("div",{class:"button-attachments"},i)}function Y(e){if("user"===t.A.get(e.ev,"by.type"))return null;let i=[],s=t.A.get(e.ev,"data.message.attachments",[]);return t.A.each(s,((e,s)=>{e&&"button"===t.A.get(e,"type")&&t.A.each(t.A.get(e,"buttons")||[],(t=>i.push(t)))})),(0,j.h)(X,{store:e.store,buttons:i,t:e.t})}class K extends D.Mw{constructor(t){super(t)}render(){if("user"===t.A.get(this.props.ev,"by.type"))return null;let e=[];if(t.A.map(t.A.get(this.props.ev,"data.message.attachments",[]),(i=>{i&&"quick_replies"===i.type&&(e=t.A.get(i,"quick_replies",[]))})),e=t.A.filter(e,(t=>t.title)),0===e.length)return null;let i=t.A.convoOfEv(this.props.ev),s=this.props.store.matchConvo(i);if("ended"===t.A.get(s,"state"))return null;let r=t.A.map(this.props.store.listEvents(i));r=t.A.orderBy(r,"created","asc").filter((t=>"message_sent"===t.type));let n=0;for(var o=0;o<r.length;o++)if(r[o].id===this.props.ev.id){n=o;break}for(o=n+1;o<r.length;o++)if("user"===t.A.get(r[o],"by.type"))return null;let a=t.A.map(e,(t=>(0,j.h)("div",{class:"message_quick_reply",onClick:e=>this.props.onSelect(t)},t.title)));return(0,j.h)("div",{class:"message_quick_replies"},a)}}class Z extends D.Mw{constructor(t){super(t),this.setState({search:"",isShow:!1})}render(){let e=t.A.filter(this.props.items,(t=>{let e=this.state.search.toLowerCase();return(t||"").toLowerCase().indexOf(e)>-1})),i=t.A.map(e,(t=>(0,j.h)("li",{class:"custom-select--item-options",onClick:()=>this.add(t)},t))),s=t.A.map(this.props.selected,((t,e)=>(0,j.h)("div",{class:"custom-select--selected-item",onClick:t=>this.remove(t,e)},t,(0,j.h)("i",{class:"icn-delete delete-tag"})))),r=(0,j.h)("div",{class:"custom-select--wrap-options"},(0,j.h)("input",{onClick:t=>{t.preventDefault(),t.stopPropagation(),this.setState({isShow:!0})},type:"text",onInput:t=>this.setState({search:t.target.value}),value:this.state.search,placeholder:"Tìm kiếm",class:"custom-select--input-search"}),(0,j.h)("ul",{class:"custom-select--items-options"},i));return this.state.isShow||(r=null),(0,j.h)("div",{class:"form-control custom-select"},(0,j.h)(D.tW,{onClickaway:t=>this.clickaway()},(0,j.h)("div",{class:"custom-select--wrap-selected",onClick:()=>this.setState({isShow:!this.state.isShow})},(0,j.h)("div",{class:"custom-select--selected-items"},s),r,(0,j.h)("div",{class:"custom-select--icon-dropdown"},(0,j.h)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,j.h)("g",{opacity:"0.6"},(0,j.h)("path",{d:"M7 9.5L12 14.5L17 9.5H7Z",fill:"black"})))))))}clickaway(){this.setState({isShow:!1})}add(t){this.props.onAddItem&&this.props.onAddItem(t)}remove(t,e){t.preventDefault(),t.stopPropagation(),this.props.onRemoveItem&&this.props.onRemoveItem(e)}}class tt extends D.Mw{constructor(e){super(e),this.props.store.onUpdate(this,(t=>this.forceUpdate()));let i=this.props.store.matchUser(),s=t.A.get(this.props.form,"fields")||[],r=t.A.map(s,(e=>{let s=e.is_required||!1;var r=t.A.parseJSON(e.state)||{};s||(s=r.require||!1);var n=t.A.getUserAttr(i,e.name,r.type||"text");return{name:e.name,items:e.items,value:t.A.parseJSON(e.answer)||t.A.parseJSON(e.default_answer)||n,is_required:s,label:e.title,type:e.input_type}}));this.setState({formData:r})}isSummited(){return!!t.A.find(this.state.formData,(t=>!!t.answered))||"ended"===this.props.store.matchConvo(t.A.convoOfEv(this.props.ev)).state}render(){if(0===t.A.size(this.state.formData))return null;let e=this.renderFields(),i=null;return this.isSummited()||(i=(0,j.h)("div",{class:"mt-2"},(0,j.h)("button",{onClick:t=>this.submit(),type:"button",class:"form-attachment--submit-btn"},this.props.t("btn_submit_form_attachment")))),(0,j.h)("div",{class:"form-attachment",onClick:t=>t.stopPropagation()},this.props.t(this.props.form.title)||this.props.t("capture_lead_title"),e,i)}focus(){if(this.props.store.isPreview)return;if(0===t.A.size(this.state.formData))return;let e;if(this.isFormFilled()){var i=Object.keys(this.state.formData),s=i[t.A.size(i)-1];e=this["field."+et(this.state.formData[s].name)]}else{var r=this.firstUnfilledField();if(!r)return;e=this["field."+et(r.name)]}e&&e.focus()}firstUnfilledField(){return t.A.find(this.state.formData,(t=>null==t.value||""===t.value))}isFormFilled(){return!t.A.find(this.state.formData,(t=>null==t.value||""===t.value))}onInputChange(e,i){let s=t.A.cloneDeep(this.state.formData);s[e].value=i,this.setState({formData:s})}onListAddItem(e,i){let s=t.A.cloneDeep(this.state.formData),r=s[e];r.value=r.value||[],r.value.push(i),this.setState({formData:s})}onListRemoveItem(e,i){let s=t.A.cloneDeep(this.state.formData),r=s[e];r.value=r.value||[],r.value.splice(i,1),this.setState({formData:s})}renderFields(){if(0===t.A.size(this.state.formData))return null;let e=null;return e=t.A.map(this.state.formData,((e,i)=>{let s=null;var r=e.error?"input--error":"";if("text"===e.type)s=this.isSummited()?(0,j.h)("div",{class:"form-control--container"},(0,j.h)("input",{disabled:!0,ref:t=>{this["field."+et(e.name)]=t},value:e.value,onInput:t=>this.onInputChange(i,t.target.value),class:`form-control ${r}`,type:"text"}),(0,j.h)("i",{class:"form-control--check"})):(0,j.h)("input",{ref:t=>{this["field."+et(e.name)]=t},value:e.value,onInput:t=>this.onInputChange(i,t.target.value),class:`form-control ${r}`,type:"text"});else if("number"===e.type)s=this.isSummited()?(0,j.h)("div",{class:"form-control--container"},(0,j.h)("input",{disabled:!0,ref:t=>{this["field."+et(e.name)]=t},value:e.value,onInput:t=>this.onInputChange(i,t.target.value),class:`form-control ${r}`,type:"number"}),(0,j.h)("i",{class:"form-control--check"})):(0,j.h)("input",{ref:t=>{this["field."+et(e.name)]=t},value:e.value,onInput:t=>this.onInputChange(i,t.target.value),class:`form-control ${r}`,type:"number"});else if("boolean"===e.type)s=(0,j.h)("div",{class:"checkbox"},(0,j.h)("input",{ref:t=>{this["field."+et(e.name)]=t},type:"checkbox",id:"checkbox."+this.props.ev.id+"."+e.name,onChange:t=>this.onInputChange(i,ev.target.checked),checked:e.value}),(0,j.h)("label",{class:"checkbox--label",for:"checkbox."+this.props.ev.id+"."+e.name},e.label),(0,j.h)("div",{class:"checkbox--check"},(0,j.h)("div",null)));else if("list"===e.type){let r=e.value||[],n=t.A.filter(t.A.get(e,"items",[]),(t=>!r.includes(t)));s=(0,j.h)(Z,{selected:r,items:n,onAddItem:t=>this.onListAddItem(i,t),onRemoveItem:t=>this.onListRemoveItem(i,t)})}else"datetime"===e.type&&(s=(0,j.h)("input",{ref:t=>{this["field."+et(e.name)]=t},value:e.value,onInput:t=>this.onInputChange(i,t.target.value),class:`form-control ${r}`,type:"date"}));let n=e.label;return"fullname"===e.name?n=this.props.t("fullname"):"emails"===e.name?n=this.props.t("email"):"phones"===e.name&&(n=this.props.t("phones")),(0,j.h)("div",null,(0,j.h)("p",{class:"label mt-3"},n,e.is_required?(0,j.h)("span",{class:"ml-1 red"},"*"):""),e.error?(0,j.h)("div",{class:"form-control--valid-input--error"},e.error):"",s)})),(0,j.h)("div",null,e)}async submit(){var e=!1;if(t.A.map(this.state.formData,(i=>{i.is_required&&(void 0===i.value||""===i.value||0===t.A.size(i.value)&&Array.isArray(i.value))?(i.error=this.props.t("error_empty"),e=!0):i.error="","emails"===i.name&&i.value&&(t.A.isEmail(i.value)||(i.error=this.props.t("error_email_invalid"),e=!0))})),this.forceUpdate(),e)return;let i={},s=t.A.cloneDeep(this.state.formData);t.A.map(s,(e=>{var s={key:e.name};e.answered=(new t.A.Date).getTime(),"number"===e.type&&(s.number=parseInt(e.value),e.answer=t.A.stringify(s.number)),"datetime"===e.type&&(s.datetime=new t.A.Date(e.value).toISOString(),e.answer=t.A.stringify(s.datetime)),"list"===e.type&&(s.list=e.value,e.answer=t.A.stringify(s.list)),"text"!==e.type&&"boolean"!==e.type||(s[e.type]=e.value,e.answer=t.A.stringify(e.value)),t.A.setUserAttr(i,s)})),t.A.map(s,(e=>{let i=t.A.find(this.props.form.fields,(t=>t.name===e.name));i&&(i.answered=e.answered)})),this.setState({formData:s}),this.props.store.setUser(i);let r={attachments:[{type:"form_submit",form_submit:{state:'{"user_id":"'+this.props.store.matchUser().id+'"}',form_message_id:t.A.get(this.props.ev,"id"),fields:s}}]},n=t.A.convoOfEv(this.props.ev);this.props.store.sendConvoEvent(n,"message_sent",{message:r}),this.props.onSubmit&&this.props.onSubmit()}}function et(t){return btoa(t).split("=").join("")}class it extends D.Mw{constructor(t){super(t)}render(){if("user"===t.A.get(this.props.ev,"by.type"))return;let e=[],i=t.A.get(this.props.ev,"data.message.attachments")||[];t.A.each(i,(t=>{t&&("form"!==t.type&&"ask_info_form"!==t.type||(t.form._type=t.type,e.push(t.form)))}));let s=t.A.map(e,((t,e)=>(0,j.h)(tt,{store:this.props.store,onSubmit:this.props.onSubmit,ref:t=>{this["form."+e]=t},key:e,form:t,ev:this.props.ev,t:this.props.t})));return 0===s.length?null:(0,j.h)("div",{class:"message-agent"},s)}focus(){var t=this["form.0"];t&&t.focus()}}class st extends D.Mw{constructor(t){super(t)}render(){return null}}function rt(t){return t.touches&&t.touches.length?t.touches[0]:{}}class nt extends D.Mw{constructor(t){super(t),this.state={focusing:0},this.galleryRef=(0,j._3)()}componentDidMount(){this.bindDrag()}focus(t){this.setState({focusing:t}),this.galleryRef.current.scrollTo({left:220*t,behavior:"smooth"})}render(){if("user"===t.A.get(this.props.ev,"by.type"))return null;let e=t.A.get(this.props.ev,"data.message.attachments",[]),i=t.A.filter(e,(e=>"generic"===t.A.get(e,"type")));return 0===i.length?null:t.A.map(i,((i,s)=>{var r=t.A.map(i.elements,(t=>{let e=this.props.t.i18n(t.i18n_title)||t.title,i=this.props.t.i18n(t.i18n_subtitle)||t.subtitle,s=e?(0,j.h)("div",{class:"generic-attachment--element-title"},e):null,r=i?(0,j.h)("div",{class:"generic-attachment--element-subtitle"},i):null,o=this.props.store.replaceFileUrl(t.image_url);return t.image_url||(o=n(2876)),(0,j.h)("div",{class:"generic-attachment--element swiper-slide"},(0,j.h)("div",null,(0,j.h)("img",{alt:"generic attachment element",class:"generic-attachment--element-img",src:o})),(0,j.h)("div",{class:"generic-attachment--element-content"},s,r),(0,j.h)(X,{buttons:t.buttons,onSelect:t=>this.props.onSelect(t),t:this.props.t}))}));let o=t.A.get(e,"0.elements",[]),a="generic-attachment-navigator generic-attachment-navigator--left",l="generic-attachment-navigator generic-attachment-navigator--right";return 0===this.state.focusing&&(a+=" generic-attachment-navigator--disabled"),this.state.focusing===o.length-1&&(l+=" generic-attachment-navigator--disabled"),(0,j.h)("div",{class:"generic-attachment-container"},(0,j.h)("div",{class:"generic-attachment",ref:this.galleryRef},r),!this.props.store.isMobile()&&(0,j.h)(j.FK,null,(0,j.h)("div",{class:a,onClick:t=>this.focus(this.state.focusing-1)},(0,j.h)("span",{class:"generic-attachment-navigator-icon"},"‹")),(0,j.h)("div",{class:l,onClick:t=>this.focus(this.state.focusing+1)},(0,j.h)("span",{class:"generic-attachment-navigator-icon"},"›"))))}))}bindDrag(){if(!this.props.store.isMobile())return;let e=document.getElementsByClassName("generic-attachment");t.A.map(e,(t=>{var e,i,s;(e=t)&&(e.removeEventListener("touchstart",e.md,0),window.removeEventListener("touchend",e.mu,0),window.removeEventListener("touchmove",e.mm,0),e.md=function(t){let r=rt(t);e.hasAttribute("nochilddrag")&&document.elementFromPoint(r.pageX,r.pageY)||(s=1,i=r.clientX,t.preventDefault())},e.mu=()=>{s=0},e.mm=function(t){if(!s)return;let r=rt(t);e.scrollLeft-=-i+r.clientX,i=r.clientX},e.addEventListener("touchstart",e.md,{passive:!0}),window.addEventListener("touchend",e.mu,{passive:!0}),window.addEventListener("touchmove",e.mm,{passive:!0}))}))}}class ot extends D.Mw{render(){let e=t.A.get(this.props.ev,"by.type");if("user"===e)return null;let i=t.A.get(this.props.ev,"data.message.attachments",[]),s=t.A.filter(i,(e=>"product"===t.A.get(e,"type")||"product_preview"===t.A.get(e,"type")));if(s=s.filter((t=>t.product&&t.product.name)),0===s.length)return null;let r=this.props.store.matchAccount();return t.A.map(s,((i,s)=>{let o=i.product,a=[],l=o.url||o.mobile_url;this.props.store.isMobile()&&(l=o.mobile_url||o.url),l&&0==t.A.size(o.buttons)&&a.push((0,j.h)("a",{class:"product_attachment__btn",href:l,target:"_blank"},this.props.t("detail"),(0,j.h)("img",{src:n(3266),class:"product_attachment__btn_external_link"}))),console.log("P",o),t.A.size(o.buttons)>0&&(a=a.concat(t.A.map(o.buttons,((t,e)=>"call_button"===t.type?(0,j.h)("a",{class:"product_attachment__btn",href:"tel:"+t.phone_number,key:e,title:t.title},this.props.t.i18n(t.i18n_title)||t.title):"url_button"===t.type?(0,j.h)("a",{class:"product_attachment__btn",href:t.url,target:"_blank",key:e,title:t.title},this.props.t.i18n(t.i18n_title)||t.title||this.props.t("detail")," ",(0,j.h)("img",{src:n(3266),class:"product_attachment__btn_external_link"})):"postback_button"===t.type?(0,j.h)("a",{class:"product_attachment__btn",href:"javascript:;",onClick:e=>this.props.onPostback(t)},this.props.t.i18n(t.i18n_title)||t.title):void 0))));let c=(0,j.h)("a",{href:l,class:"product_attachment__title",target:"_blank"},o.name),h=null,u=o.description||o.long_description;u&&(h=(0,j.h)("div",{class:"product_attachment__subtitle"},u));let d=o.currency||t.A.get(r,"currency","VND"),p=null;o.price&&(p=(0,j.h)("div",{class:"product_attachment__price"},t.A.formatCurrency(o.price,d)));let m=this.props.store.replaceFileUrl(o.image);return o.image||(m=n(2876)),(0,j.h)("div",{class:"product_attachment product_attachment__"+e},(0,j.h)("div",null,(0,j.h)("a",{href:this.props.store.replaceFileUrl(o.image),target:"_blank"},(0,j.h)("img",{class:"product_attachment__img",src:m}))),c,h,p,(0,j.h)("div",{class:"product_attachment__btns"},a))}))}}class at extends D.Mw{constructor(t){super(t)}render(){let e=t.A.get(this.props.ev,"by.type");var i=t.A.get(this.props.ev,"data.message.attachments",[]),s=[];if(t.A.each(i,((e,i)=>{e&&t.A.includes(e.mimetype,"video")&&s.push(e)})),0===s.length)return null;var r=t.A.map(s,((t,i)=>(0,j.h)("div",{key:i,class:`video-attachment video-attachment--${e}`},(0,j.h)("video",{class:"video-attachment__video",src:this.props.store.replaceFileUrl(t.url),width:"100%",height:"",poster:this.props.store.replaceFileUrl(t.thumbnail_url),controls:"controls",preload:"metadata"}))));return(0,j.h)("div",{class:`message-${e}`},r)}}var lt=n(1620);class ct extends D.Mw{renderTime(){return this.props.showTime||this.props.isLast||this.props.isFirst?(0,j.h)("div",null,(0,j.h)(lt.A,{class:"inline-time",time:t.A.get(this.props.ev,"created",t.A.Date.now()),t:this.props.t})):null}render(){t.A.get(this.props.ev,"data.message.format","plaintext");let e=t.A.get(this.props.ev,"data.message.block");return e?this.renderBlock(e):this.renderPlainText()}renderPlainText(){var e=t.A.get(this.props.ev,"data.message.text");if(e=t.A.trim(e),0===t.A.size(e))return null;let i=new t.A.Date(t.A.get(this.props.ev,"created")).toLocaleString(),s=t.A.get(this.props.ev,"by.type");"user"!==s&&(s="agent");var r=t.A.extractText(e).map((t=>{if("emoji"===t.type)return(0,j.h)(E.A,{emojiCode:t.text,byType:s});if("link"===t.type){let e=t.text||"";return e.startsWith("//")||e.startsWith("https://")||e.startsWith("http://")||e.startsWith("data:")||(e="//"+e),(0,j.h)("a",{href:e,target:"_blank",onClick:t=>this.props.onLink(t,e)},t.text)}return"phone"===t.type?(0,j.h)("a",{href:"tel:"+t.text},t.text):"email"===t.type?(0,j.h)("a",{href:"mailto:"+t.text},t.text):t.text}));return 0===t.A.size(r)?null:"agent"===s?(0,j.h)("div",{class:"message-agent message-text--agent",title:i},r,this.renderTime()):(0,j.h)("div",{class:"message-user message-text--user",title:i},r)}renderBlock(e){if(ht(e))return null;let i=new t.A.Date(t.A.get(this.props.ev,"created")).toLocaleString(),s=t.A.get(this.props.ev,"by.type");return"user"!==s&&(s="agent"),"agent"===s?(0,j.h)("div",{class:"message-agent message-text--agent",title:i},(0,j.h)(T.A,{block:e,onLink:this.props.onLink}),this.renderTime()):(0,j.h)("div",{class:"message-user message-text--user",title:i},(0,j.h)(T.A,{block:e,onLink:this.props.onLink}))}}function ht(e){if(!e||!e.type)return!0;let i=t.A.size(t.A.filter(t.A.map(e.content,(t=>ht(t))),(t=>!t)))>0;return!t.A.trim(e.text)&&!i}class ut extends D.Mw{render(){let e=this.props.ev.ev;if("conversation_rated"===e.type){var i=t.A.get(e,"data.conversation.ratings.0",{no_rating:!0,rating:0});return i.no_rating?null:(0,j.h)("div",{class:"convo-event"},(0,j.h)("div",{class:"info-message"},this.props.t("rated_as")+" "+this.props.t(function(t){return t?t<2?"poor":t<4?"average":"great":"poor"}(i.rating)).toLowerCase()))}return"conversation_state_updated"===e.type&&"ended"===t.A.get(e,"data.conversation.state")?(0,j.h)("div",{class:"convo-event"},(0,j.h)("div",{class:"info-message"},this.props.t("conversation_ended"))):null}}let dt=!1;class pt extends D.Mw{constructor(e){super(e),this.props.store.onConvoEvent(this,(t=>this.onEvent(t))),this.refForm=(0,j._3)(),this.state={pongs:t.A.get(this.props.event,"ev.data.message.pongs")||[]}}render(){var e=t.A.get(this.props.event,"ev",{});switch(e.type){case"conversation_typing":return this.renderTyping();case"conversation_joined":break;case"message_sent":return this.props.event.is_typing?this.renderTyping():this.renderMessageSent();case"conversation_state_updated":case"conversation_rating_requested":case"conversation_rated":return t.A.startsWith(e.id,"ev")?(0,j.h)(ut,{t:this.props.t,store:this.props.store,ev:this.props.event}):null}return null}focus(){this.refForm.current&&this.refForm.current.focus()}onEvent(e){e.id===t.A.get(this.props.event,"ev.id")&&this.setState({pongs:t.A.get(e,"data.message.pongs")||[]})}hasLike(){let{pongs:e}=this.state;return!!t.A.find(e,(t=>"like"===t.type))}hasDislike(){let{pongs:e}=this.state;return!!t.A.find(e,(t=>"dislike"===t.type))}chooseQuickReply(e){let i=t.A.get(this.props.event,"ev",{}),s={text:e.title,format:"plaintext"};e.payload&&(s.attachments=[{type:"postback",postback:{event_id:i.id,payload:e.payload}}]),this.props.onSend(s)}choosePostbackBtn(e){let i=t.A.get(this.props.event,"ev",{}),s={text:e.title,format:"plaintext"};e.payload&&(s.attachments=[{type:"postback",postback:{event_id:i.id,payload:e.payload}}]),this.props.onSend(s)}renderAgentAvatar(e){let i=t.A.get(e,"by.type"),s=t.A.get(e,"by.display_id",t.A.get(e,"by.id"));if("user"===i)return null;var r=this.getSenderName(e);let o=this.props.store.matchAccount();var a=o.logo_url||n(3582);if(t.A.get(this.props,"chatbox.hide_agent_profile"))return(0,j.h)("div",{class:"message-sender"},(0,j.h)("img",{alt:"sender",class:"message-sender-avatar",src:this.props.store.replaceFileUrl(a)}),(0,j.h)("p",{class:"message-sender-name"},o.name));let l=this.props.store.matchAgent("*");return"system"!==s&&"dummy"!==i&&"workflow"!==i&&(a=t.A.get(l[s],"avatar_url")||o.logo_url||n(2538)),(0,j.h)("div",{class:"message-sender"},(0,j.h)("img",{alt:"sender",class:"message-sender-avatar",src:this.props.store.replaceFileUrl(a)}),(0,j.h)("p",{class:"message-sender-name"},r))}tryLoadOrder(e){if("user"!==t.A.get(e,"by.type")){this.props.store.matchAccount();var i=t.A.get(e,"data.message.attachments",[]);0!==t.A.filter(i,(t=>"order"===t.type&&t.order)).map((t=>t.order)).length&&(dt||t.A.setTimeout((async()=>{dt=(await n.e(127).then(n.bind(n,6127))).default})))}}renderTyping(){let t="data:text/html,"+encodeURIComponent('\n<html>\n <head>\n <style>\n .typing-container {\n width: 100vw;\n height: 100vh;\n display: flex;\n align-items: center;\n gap: 4px;\n justify-content: center;\n }\n .typing-dot {\n display: inline-block;\n vertical-align: middle;\n width: 8px;\n height: 8px;\n background: black;\n border-radius: 50%;\n animation: typing 0.5s infinite alternate;\n }\n .typing-dot:nth-of-type(2) {\n animation-delay: 0.2s;\n }\n .typing-dot:nth-of-type(3) {\n animation-delay: 0.6s;\n }\n @keyframes typing {\n 0% {\n opacity: 0.9;\n }\n 100% {\n opacity: 0.4;\n }\n }\n </style>\n </head>\n <body style="padding: 0; margin: 0">\n <div class="typing-container">\n <span class="typing-dot"></span>\n <span class="typing-dot"></span>\n <span class="typing-dot"></span>\n </div>\n </body>\n</html>\n');return(0,j.h)("div",{class:"convo-event agent-message"},(0,j.h)("div",{class:"agent-convo-event-wrapper"},(0,j.h)("div",{class:"agent-convo-event-inner"},(0,j.h)("div",{class:"message-agent message-text--agent",style:"opacity: 0.6 !important"},(0,j.h)("iframe",{src:t,style:"width: 35px !important; height: 20px !important; display: block !important; overflow: hidden !important; padding: 0 !important "})))))}renderMessageSent(){let e=this.props.event.ev;if(this.tryLoadOrder(e),new t.A.Date(e.created).toLocaleString(),"user"!==t.A.get(e,"by.type")){let t=null;"lead"===this.props.event.mode&&(t=this.renderAgentAvatar(e));let i="agent-convo-event-inner";return this.props.isLast&&(i+=" last"),(0,j.h)("div",{class:"convo-event agent-message"},t,(0,j.h)("div",{class:"agent-convo-event-wrapper"},(0,j.h)("div",{class:i},(0,j.h)(ct,{showTime:this.props.event.show_time,isLast:this.props.isLast,store:this.props.store,ev:e,onLink:this.props.onLink}),(0,j.h)(N,{store:this.props.store,ev:e}),(0,j.h)(J,{store:this.props.store,ev:e}),(0,j.h)(at,{store:this.props.store,ev:e}),(0,j.h)(Q,{store:this.props.store,ev:e}),(0,j.h)(Y,{store:this.props.store,ev:e,t:this.props.t}),(0,j.h)(it,{store:this.props.store,onSubmit:this.props.onFormSubmit,ref:this.refForm,ev:e,t:this.props.t}),(0,j.h)(st,{store:this.props.store,ev:e,t:this.props.t}),(0,j.h)(nt,{store:this.props.store,ev:e,onSelect:t=>this.choosePostbackBtn(t),t:this.props.t}),(0,j.h)(ot,{t:this.props.t,onPostback:t=>this.choosePostbackBtn(t),store:this.props.store,ev:e}),(0,j.h)(dt,{t:this.props.t,store:this.props.store,ev:e}),(0,j.h)(K,{store:this.props.store,ev:e,onSelect:t=>this.chooseQuickReply(t)}),this.renderReactions(),this.renderAIDevNote())))}t.A.get(e,"data.message.idempotency_key")===e.id&&this.props.store.now()-e.created<900&&t.A.setTimeout((()=>this.setState({refresh:this.state.refresh})),1e3);let i=(0,j.h)("div",{class:"sending_dot"});(this.props.store.now()-e.created<900||t.A.get(e,"data.message.idempotency_key")!==e.id)&&(i=(0,j.h)("div",{class:"sending_dot sending_dot__hide"}));let s=null;if(e._error&&"message_sent"===e.type){let t=this.props.t("error_send_message");e._error_message&&(t=this.props.t(e._error_message)),s=(0,j.h)("a",{class:"message_error",src:"javascript:;",onClick:t=>this.resendMessage()},(0,j.h)("div",{class:"message_error__text"},t),(0,j.h)("div",{class:"message_error__icon"}))}return(0,j.h)("div",{class:"convo-event user-message"},null,(0,j.h)("div",{class:"message-user__container"},i,(0,j.h)(ct,{store:this.props.store,ev:e,refresh:this.state.refresh,onLink:this.props.onLink}),(0,j.h)(N,{store:this.props.store,ev:e}),(0,j.h)(J,{store:this.props.store,ev:e}),(0,j.h)(at,{store:this.props.store,ev:e}),(0,j.h)(Q,{store:this.props.store,ev:e}),(0,j.h)(Y,{store:this.props.store,ev:e,t:this.props.t}),(0,j.h)(it,{store:this.props.store,onSubmit:this.props.onFormSubmit,ref:this.refForm,ev:e}),(0,j.h)(ot,{t:this.props.t,store:this.props.store,ev:e}),(0,j.h)(st,{store:this.props.store,ev:e})),s)}async onSendReaction(e){if(this._reacting)return;let i=this.props.event.ev,s=t.A.get(i,"data.message.conversation_id");i={type:"message_pong",data:{message:{id:i.id,pongs:[{type:e}],conversion_id:s}}},"dislike"==e&&this.props.store.isAIDevMode()&&this.props.store.emitConvoEvent({type:"bad_feedbacked",data:{event:i,id:i.id,conversion_id:s}});let{pongs:r}=this.state;"like"===e?(r=r.filter((t=>"dislike"!==t.type)),r.push({type:"like"})):"dislike"===e?(r=r.filter((t=>"like"!==t.type)),r.push({type:"dislike"})):"remove_like"===e?r=r.filter((t=>"like"!==t.type)):"remove_dislike"===e&&(r=r.filter((t=>"dislike"!==t.type))),this.setState({pongs:r}),this._reacting=!0,await this.props.store.sendReaction(s,i),this._reacting=!1}renderReactions(){if(this.props.store.isAIDevMode())return null;let e=t.A.get(this.props.event,"ev")||{},i=(t.A.get(e,"data.message.pongs"),this.hasLike()),s=this.hasDislike(),r="message-event-action-btn";i&&(r+=" active");let n="message-event-action-btn";return s&&(n+=" active"),(0,j.h)("div",{class:"message-event-actions"},(0,j.h)("div",{class:r,onClick:()=>this.onSendReaction(i?"remove_like":"like")},(0,j.h)("div",{class:"message-event-action-btn-svg like"})),(0,j.h)("div",{class:n,onClick:()=>this.onSendReaction(s?"remove_dislike":"dislike")},(0,j.h)("div",{class:"message-event-action-btn-svg dislike"})))}renderAIDevNote(){if(!this.props.isLast)return null;if(!this.props.store.isAIDevMode())return null;let e=t.A.get(this.props.event,"ev")||{},i=(t.A.get(e,"data.message.pongs"),this.hasLike()),s=this.hasDislike(),r="message-event-action-btn message-event-action-btn__dev message-event-action-btn_like";i&&(r+=" active");let n="message-event-action-btn message-event-action-btn__dev message-event-action-btn_dislike";return s&&(n+=" active"),(0,j.h)("div",{class:"message-event-actions"},(0,j.h)("div",{class:r,onClick:()=>this.onSendReaction(i?"remove_like":"like")},(0,j.h)("div",{class:"message-event-action-btn-svg like"})," Good"),(0,j.h)("div",{class:n,onClick:()=>this.onSendReaction(s?"remove_dislike":"dislike")},(0,j.h)("div",{class:"message-event-action-btn-svg dislike"})," Bad"))}renderUpdateConvo(e){var i=t.A.get(e,"data.conversation.state");return"active"===i||"pending"===i?null:(0,j.h)("div",{class:"message-system"},this.props.t("conversation_state_updated",{state:i}))}resendMessage(){let e=t.A.convoOfEv(this.props.event.ev);const i=t.A.get(this.props.event,"ev.data.message");this.props.store.sendConvoEvent(e,"message_sent",{message:i})}getSenderName(e){let i=t.A.get(e,"by.type"),s=t.A.get(e,"by.display_id",t.A.get(e,"by.id"));if("user"===i)return t.A.getUserDisplayName(this.props.store.matchUser());let r=this.props.store.matchAccount();if("agent"===i)return t.A.getAgentDisplayName(r,this.props.store.matchAgent(s));if("bot"===i){let t=this.props.store.matchBot()[s];return t&&t.fullname||"Bot"}return"system"===s||"dummy"===i||"workflow"===i?r.name||"system":r.name}}const mt=n(1370);class gt extends D.Mw{constructor(e){super(e),this.props.store.onUpdate(this,(t=>this.forceUpdate())),this.props.store.onConvoEvent(this,(t=>this.onEvent(t))),this.loadConvo(),this.refBody=null,this.checkAndSeen=t.A.throttle((()=>{this.props.isShow&&this.isBottom()&&"visible"===this.props.store.browserVisibility&&document.hasFocus()&&this.props.store.seenConvo(this.props.cid)}),500),this.checkAndSeen()}componentDidMount(){this.setState({isShowTyping:!1,typing_event:{}}),this.props.store.onConvoEvent(this,(e=>{if(t.A.convoOfEv(e)!==this.props.cid)return;if("user"===t.A.get(e,"by.type"))return;let i=t.A.get(this.state.typing_event,"by.id");return i&&t.A.get(e,"by.id")!==i?void 0:"message_sent"===t.A.get(e,"type")?(this.timer&&t.A.clearTimeout(this.timer),this.timer=null,void this.setState({isShowTyping:!1})):void("conversation_typing"===t.A.get(e,"type")&&("agent"!=(this.props.store.matchAgent(t.A.get(e,"by.id"))||{}).type||t.A.get(this.props.plugin,"chatbox.show_agent_typing"))&&(this.setState({typing_event:e,isShowTyping:!0}),this.timer&&t.A.clearTimeout(this.timer),this.timer=t.A.setTimeout((()=>{t.A.convoOfEv(e)===this.props.cid&&(this.timer=null,this.setState({isShowTyping:!1}))}),5e3)))}))}componentDidUpdate(t){t.cid!==this.props.cid&&this.loadConvo()}ShowTyping(){this.setState({isShowTyping:!0,typing_event:{id:"evzz"+t.A.Date.now(),created:t.A.Date.now(),by:{type:"agent"},type:"conversation_typing"}}),this.timer&&t.A.clearTimeout(this.timer),this.timer=t.A.setTimeout((()=>{this.timer=null,this.setState({isShowTyping:!1})}),5e3)}render(){if(this.state.error)return this.renderError();let e=t.A.map(this.props.store.listEvents(this.props.cid));if(!this.state.loading&&0===t.A.size(e))return(0,j.h)("div",{ref:t=>this.refBody=t,class:"widget-body--events-container"},(0,j.h)("div",{class:"widget-body--empty"},(0,j.h)("div",{class:"widget-body--empty-icon"}),(0,j.h)("div",{class:"widget-body--empty-text"},this.props.t("empty_convo_text"))),(0,j.h)(q,{store:this.props.store}));e=t.A.orderBy(e,"created","asc");let i=this.props.store.matchConvo(this.props.cid);if(e=t.A.map(e,(t=>({ev:t}))),this.state.isShowTyping){let i=this.state.typing_event||{id:"evzz"+t.A.Date.now(),created:t.A.Date.now(),by:{type:"agent"}},s={is_typing:!0,id:i.id,ev:{id:i.id,created:i.created,by:i.by,type:"message_sent",data:{message:{text:"...",conversation_id:this.props.cid}}}};console.log("FA",s),e.push(s)}!function(e,i){if(!((i=i.filter((t=>ft(t.ev)))).length<1)){for(var s,r=1;r<i.length;r++){let e=i[r],n=i[r-1];"user"==t.A.get(e,"ev.by.type")||e.is_typing||(s=e),ft(e.ev)&&t.A.unixSec(e.ev.created)-t.A.unixSec(n.ev.created)>120&&(e.show_time=!0)}for(s&&(s.show_time=!0),r=0;r<i.length;r++){let e=i[r];if("message_sent"===t.A.get(e,"ev.type")){e.show_time=!0;break}}for(r=0;r<i.length;r++){let e=i[r],s=i[r-1];"message_sent"!==e.ev.type||(e.mode="lead","message_sent"===t.A.get(s,"ev.type")&&t.A.get(s,"ev.by.id")===t.A.get(e,"ev.by.id")&&(e.mode="follow"))}}}(0,e);let s=t.A.map(e,(e=>{let s=e.ev.id===t.A.get(i,"last_message_sent.id");return(0,j.h)(pt,{isLast:s,chatbox:this.props.chatbox,onLink:this.props.onLink,store:this.props.store,onFormSubmit:this.props.onFormSubmit,onSend:this.props.onSend,onPostback:this.props.onPostback,event:e,t:this.props.t,key:e.ev.id})})),r=null,n="opacity: 1 !important";return this.props.creating&&(r=(0,j.h)(H.A,{static:!0,mode:t.A.get(this.props.chatbox,"primary_color","dark"),size:"120",center:!0}),n="opacity: 0 !important"),this.state.loading&&t.A.Date.now()-this.state.loading>500&&(r=(0,j.h)(H.A,{static:!0,mode:t.A.get(this.props.chatbox,"primary_color","dark"),size:"120",center:!0}),n="opacity: 0 !important"),(0,j.h)(j.FK,null,r,(0,j.h)("div",{style:n,ref:t=>this.refBody=t,class:"widget-body--events-container",onMouseOver:this.checkAndSeen},(0,j.h)("div",{class:"widget-body--events"},s),(0,j.h)(q,{store:this.props.store})))}renderError(){let t=(0,j.h)("a",{href:"#",onclick:t=>this.loadConvo()},this.props.t("try_again"));return this.state.loading&&(t=(0,j.h)(H.A,{size:"16",mode:"blue"})),(0,j.h)("div",{class:"widget-body--events-container widget-body--events-container__error"},(0,j.h)("img",{alt:"empty",src:mt}),(0,j.h)("div",{class:"widget_body__events__error_msg"},this.props.t("load_convo_error")),(0,j.h)("div",{class:"widget_body__events__error_retry"},t))}focus(){let e=this.props.store.listEvents(this.props.cid);var i;e=t.A.orderBy(t.A.map(e),"created","desc");for(let s of e)if("message_sent"===t.A.get(s,"type")&&"user"!==t.A.get(s,"by.type")){i=s;break}"user"===t.A.get(i,"by.type")&&(i=null);let s=t.A.get(i,"data.message.attachments",[]),r=this.props.store.matchConvo(this.props.cid);t.A.filter(s,(e=>{if(!e)return!1;if("form"!==e.type&&"ask_info_form"!==e.type)return!1;var i=e.form;return!(!i||!(t.A.parseJSON(i.state)||{}).require_finished&&"ask_info_form"!==e.type||function(e){let i=t.A.get(e,"fields")||[];return t.A.find(i,(t=>!!t.answered))}(e.form)||"ended"===r.state)}))}onEvent(e){if(t.A.convoOfEv(e)!==this.props.cid)return;let i=this.isBottom();var s=!1;"message_sent"===t.A.get(e,"type")&&e.id===t.A.get(e,"data.message.idempotency_key")&&(s=!0),(s||i)&&this.scrollToBottom()}async loadConvo(){if(!this.props.cid)return;this.lastContentOffsetY=0,this.setState({loading:!1});let e=this.props.store.listEvents(this.props.cid);if(0===t.A.size(e)){this.setState({loading:t.A.Date.now()}),t.A.setTimeout((()=>{this.forceUpdate()}),800);let e=this.props.cid,{error:i}=await this.props.store.fetchMoreEvents(e);if(this.setState({loading:!1}),e!==this.props.cid)return;if(i)return void this.setState({error:!0})}this.props.store.fetchMoreEvents(this.props.cid),this.setState({error:!1}),this.scrollToBottom()}isBottom(){let t=this.refBody;return!!t&&t.scrollHeight<t.scrollTop+t.offsetHeight+50}scrollToBottom(){t.A.setTimeout((()=>{const t=this.refBody;t&&(t.scrollTop=t.scrollHeight)})),t.A.setTimeout((()=>{const t=this.refBody;t&&(t.scrollTop=t.scrollHeight)}),100),this.props.isShow&&"visible"===this.props.store.browserVisibility&&document.hasFocus()&&this.props.store.seenConvo(this.props.cid)}}function ft(e){let i=t.A.get(e,"type");return"message_sent"===i||"conversation_state_updated"===i}var vt=n(2988);class _t extends D.Mw{constructor(t){var e,i,s;super(t),e=this,s={hide:!0,ratingHeight:0,overlayOpacity:.3,comment:""},(i=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(i="state"))in e?Object.defineProperty(e,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[i]=s,this.refComment=(0,j._3)(),this.refRating=(0,j._3)(),this.refHandle=(0,j._3)()}componentDidMount(){this.props.store.onUpdate(this,(()=>{this.shoudDisplay()&&this.open()})),this.props.store.onConvoEvent(this,(e=>{t.A.convoOfEv(e)===this.props.cid&&this.shoudDisplay()&&this.open()})),this.mouseUp=t=>this.onMouseUp(t),this.mouseMove=t=>this.onMouseMove(t),this.mouseDown=t=>this.onMouseDown(t);var e=this.refHandle.current;e.addEventListener("mousedown",this.mouseDown,{passive:!0}),e.addEventListener("touchstart",this.mouseDown,{passive:!0}),window.addEventListener("mouseup",this.mouseUp,{passive:!0}),window.addEventListener("touchend",this.mouseUp,{passive:!0}),window.addEventListener("mousemove",this.mouseMove,{passive:!0}),window.addEventListener("touchmove",this.mouseMove,{passive:!0}),this.animation=new vt.A({maxY:400,minY:0,duration:150}),this.close(),(this.shoudDisplay()||"rating"===this.props.forceView)&&this.open()}componentWillUnmount(){var t=this.refHandle.current;t.removeEventListener("mousedown",this.mouseDown,0),t.removeEventListener("touchstart",this.mouseDown,0),window.removeEventListener("mouseup",this.mouseUp,0),window.removeEventListener("touchend",this.mouseUp,0),window.removeEventListener("mousemove",this.mouseMove,0),window.removeEventListener("touchmove",this.mouseMove,0)}render(){let t=this.state.hide?"d-none":"";return(0,j.h)("div",{class:t},(0,j.h)("div",{class:"rating--overlay",style:`opacity: ${.5*this.state.overlayOpacity} !important;`}),(0,j.h)("div",{class:"rating",ref:this.refRating,style:`color:red; height: ${this.state.ratingHeight}px !important;`},(0,j.h)("div",{class:"rating--handle",ref:this.refHandle},(0,j.h)("div",{class:"rating--thumb"})),(0,j.h)("div",{class:"rating--content"},(0,j.h)("div",{class:"rating--heading"},this.props.t("rating_title"),(0,j.h)("div",{class:"rating--close-btn",onClick:t=>this.onCloseRating(t)})),(0,j.h)("div",{class:"rating--description"},this.props.t("rating_description")),(0,j.h)("textarea",{ref:this.refComment,type:"text",class:"rating--comment"}),(0,j.h)("div",{class:"rating-faces-container"},(0,j.h)("div",{class:"rating-face-container",onClick:t=>this.onRatingPoor(t)},(0,j.h)("img",{alt:"poor",src:n(9801)}),(0,j.h)("p",{class:"rating-face--text"},this.props.t("poor"))),(0,j.h)("div",{class:"rating-face-container",onClick:t=>this.onRatingAverage(t)},(0,j.h)("img",{alt:"average",src:n(7134)}),(0,j.h)("p",{class:"rating-face--text"},this.props.t("average"))),(0,j.h)("div",{class:"rating-face-container",onClick:t=>this.onRatingGreat(t)},(0,j.h)("img",{alt:"great",src:n(940)}),(0,j.h)("p",{class:"rating-face--text"},this.props.t("great")))),(0,j.h)("div",{class:"rating-no-thanks",onClick:t=>this.onCloseRating(t)},this.props.t("no_thanks")))))}shoudDisplay(){if(!this.props.cid)return!1;let e,i,s,r=0,n=this.props.store.matchUser(),o=!1;if(t.A.map(this.props.store.listEvents(this.props.cid),(a=>{a&&a.by&&("message_sent"===a.type&&("user"===t.A.get(a,"by.type")&&(o=!0),a.created>r&&(r=a.created)),"conversation_state_updated"===a.type&&"ended"===t.A.get(a,"data.conversation.state")&&(s=a),"conversation_rating_requested"===a.type&&(e=a),"conversation_rated"===a.type&&a.by.id===n.id&&(i=a))})),!o)return!1;if(i)return!1;let a=this.props.plugin.chatbox.auto_request_rating&&s;return a&&(a=!!r&&a&&Date.now()-r<9e5),e||a}onCloseRating(){this.props.onRate&&this.props.onRate({no_rating:!0,comment:this.refComment.current.value}),this.close()}onRatingPoor(){this.props.onRate&&this.props.onRate({rating:1,comment:this.refComment.current.value}),this.close()}onRatingAverage(){this.props.onRate&&this.props.onRate({rating:3,comment:this.refComment.current.value}),this.close()}onRatingGreat(){this.props.onRate&&this.props.onRate({rating:5,comment:this.refComment.current.value}),this.close()}open(){if(this.state.hide&&(this.setState({hide:!1}),this.refRating.current)){t.A.setTimeout((()=>{this.refComment.current&&this.refComment.current.focus()}),400),this.refComment.current.value="";var e=this.refRating.current.currentStyle||window.getComputedStyle(this.refRating.current),i=parseFloat(e.height);this.animation.play(-20,i,(t=>{this.setState({ratingHeight:t,overlayOpacity:Math.min(1,(t-0)/500)})}))}}close(){if(!this.state.hide&&this.refRating.current){var t=this.refRating.current.currentStyle||window.getComputedStyle(this.refRating.current),e=parseFloat(t.height);this.animation.play(20,e,(t=>{this.setState({ratingHeight:t,overlayOpacity:Math.min(1,(t-0)/500)}),t<10&&(this.state.hide||this.setState({hide:!0}))}))}}onMouseDown(t){this.mousePushed=!0,this.animation.stop(),t.preventDefault(),t.touches&&t.touches[0]&&(t=t.touches[0]),this.mousePushedDy=t.pageY-window.pageYOffset-this.refRating.current.getBoundingClientRect().y}onMouseUp(t){if(this.mousePushed){t.touches&&t.touches[0]&&(t=t.touches[0]),this.mousePushed=!1;var e=this.refRating.current.currentStyle||window.getComputedStyle(this.refRating.current),i=parseFloat(e.height);this.animation.play(this.mouseVelocity,i,(t=>{this.setState({ratingHeight:t,overlayOpacity:Math.min(1,(t-0)/500)}),t<10&&(this.state.hide||(this.setState({hide:!0}),this.props.onRate&&this.props.onRate({no_rating:!0})))}))}}onMouseMove(t){if(this.mousePushed){t.touches&&t.touches[0]&&(t=t.touches[0]);var e=t.pageY;this.mouseVelocity=e-this.lastMouseY,this.lastMouseY=e,e-=this.mousePushedDy;var i=this.refRating.current.getBoundingClientRect().bottom-e;i>400&&(i=500-1e4/(i+-300)),this.setState({ratingHeight:i,overlayOpacity:Math.min(1,(i-0)/500)})}}}function yt(t,e,i){return(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}var bt=n(8506),wt=n(9150),At=n(9419);let kt=!1;const xt="https://vcdn.subiz-cdn.com/file/fiqoahedjbgwclpouoml-avatar_default_baa8a1d7.png";class Ct extends D.Mw{constructor(e){super(e),yt(this,"msgInput",(0,j._3)()),yt(this,"formMounted",(e=>{let i=this.fillForm(e);(e.question_required||this.state.quickReplyMessage.text)&&(i.question={key:"question",is_required:!0,label:this.props.t.i18n(t.A.get(e,"i18n_question_label",{}))||e.question_label,type:"text",value:this.state.quickReplyMessage.text}),this.setState({formData:i}),this.props.store.isMobile()||e._updated||this.focusInput()})),yt(this,"sendMessage",(async e=>{let i=t.A.find(e.attachments,(t=>"postback"===t.type));if(this.isFormRequired()&&i)return this.onStartConvoClick(),void this.fillQuickReplyToQuestion(e);let s=e.text;if(!this.props.cid){this._creating=(this._creating||0)+1;let t=this._creating;this.setState({creating:!0});const{convo:i,error:r}=await this.props.store.startConvo({locale:this.props.t.locale(),message:s,initial_by:this.props.store.matchUser().id});if(t!=this._creating)return;if(r)return void this.setState({creating:!1});if(await this.props.store.sendConvoEvent(i.id,"message_sent",{message:e}),t!=this._creating)return;return this.props.onGo({view:"chat",cid:i.id}),void this.setState({creating:!1})}t.A.setTimeout((async()=>{await this.props.store.sendConvoEvent(this.props.cid,"message_sent",{message:e}),this.setState({creating:!1})}),1)})),yt(this,"onLink",((e,i)=>{if(!i)return e.preventDefault();let s=i.replace(/(^\w+:|^)\/\//,"");if(s.startsWith("widget.subiz.com.vn/orders/")){let i=s.substr(27);return i=i.split("/")[0],t.A.setTimeout((async()=>{kt||(kt=(await n.e(185).then(n.bind(n,4185))).default),this.setState({showOrder:!0,order_id:i})})),void e.preventDefault()}})),yt(this,"closeOrder",(t=>{this.setState({showOrder:!1,order_id:""}),this.focusInput()})),this.userSent={},this.wasFormInputed=!1,this.setState({creating:!1,clickedJoin:!1,formData:{},showOrder:!1,order_id:"",quickReplyMessage:{}}),this.props.store.onUpdate(this,(t=>this.forceUpdate())),this.refTyping=(0,j._3)()}componentDidMount(){this.props.store.isMobile()||this.focusInput(),this.updateFormDataFields()}applyMessage(t){this.focusInput(t)}componentDidUpdate(e){e.isShow!==this.props.isShow&&(this.props.isShow&&!this.props.store.isMobile()&&this.focusInput(),this.props.isShow&&this.props.store.isMobile()&&this.blur(),this.updateFormDataFields()),e.cid!==this.props.cid&&(this.closeOrder(),this.setState({clickedJoin:!1,quickReplyMessage:{}}),t.A.setTimeout((()=>{this.$events&&this.$events.focus(),this.props.store.isMobile()||this.focusInput()}),100),this.updateFormDataFields())}ShowTyping(){this.$events&&this.$events.ShowTyping()}shouldShowForm(){let e,i=this.props.plugin.chatbox||{},s=this.props.store.matchAccount()||{};t.A.get(i,"prechat_form.enabled")&&(e=i.prechat_form);let r=t.A.get(i,"offline_form.enabled");if(this.isOffline(s,i)&&r&&(e=i.offline_form),!this.hasSentMessage(this.props.cid)&&e&&(t.A.size(e.groups)||e.group_required))return!0;let n=this.isFormRequired();return n&&!this.props.cid||n&&this.props.cid&&this.state.clickedJoin}render(){let e,i=this.shouldShowForm(),s="",r=this.props.plugin.chatbox||{},n=this.props.store.matchAccount()||{},o=this.props.t("prechat_form_btn");t.A.get(r,"prechat_form.enabled")&&(e=r.prechat_form);let a=t.A.get(r,"offline_form.enabled");this.isOffline(n,r)&&a&&(e=r.offline_form,o=this.props.t("offline_form_btn"),s="offline"),"offline_form"===this.props.view&&(i=!0,e=r.offline_form,s="offline",o=this.props.t("offline_form_btn")),"prechat_form"===this.props.view&&(i=!0,e=r.prechat_form,o=this.props.t("prechat_form_btn"),s="prechat");let l=null;l="list"===this.props.view?this.renderConvoList():i?this.renderForm(e,o,s):this.renderChat();let c=t.A.get(r,"desktop_button.position")||"right";this.props.store.isMobile()&&(c=t.A.get(r,"mobile_button.position",c));let h="widget-container widget-container--"+c;var u;return this.props.store.isMobile()||"full"!==t.A.get(r,"window_mode")||(h+=" widget-container--full"),this.props.isShow||(h+=" widget-container--hide"),t.A.get(r,"header.hidden",!1)||(u=(0,j.h)(B,{t:this.props.t,plugin:this.props.plugin,store:this.props.store,cid:this.props.cid,view:this.props.view,onClose:this.props.onClose,onGotoList:()=>this.props.onGo({view:"list"})})),(0,j.h)("div",{class:h},u,l)}async submitPrechatForm(e,i){if(this.state.submiting)return;var s=!1;if(t.A.map(this.state.formData,((e,i)=>{if(e.is_required&&(void 0===e.value||""===e.value||0===t.A.size(e.value)&&Array.isArray(e.value))?(e.error=this.props.t("error_empty"),s=!0):e.error="","emails"===i.substr(5))if(e.is_required)t.A.isEmail(e.value)||(e.error=this.props.t("error_email_invalid"),s=!0);else{let i=e.value||"";"string"!=typeof i&&(i+=""),i.trim()&&!t.A.isEmail(e.value)&&(e.error=this.props.t("error_email_invalid"),s=!0)}if("phones"===i.substr(5))if(e.is_required)t.A.isPhone(e.value)||(e.error=this.props.t("error_phone_invalid"),s=!0);else{let i=e.value||"";"string"!=typeof i&&(i+=""),i.trim()&&!t.A.isPhone(e.value)&&(e.error=this.props.t("error_phone_invalid"),s=!0)}})),s)return this.forceUpdate();let r=t.A.cloneDeep(this.state.formData),n=t.A.cloneDeep(this.props.store.matchUser()),o=!1;t.A.map(r,((e,i)=>{if(i.startsWith("attr:")){var s={key:i.substr(5)};o=o||"emails"==i||"phones"==i,"number"===e.type&&(s.number=parseInt(e.value)),"datetime"===e.type&&(s.datetime=new t.A.Date(e.value).toISOString()),"list"===e.type&&(s.text=e.value),"text"!==e.type&&"boolean"!==e.type||(s[e.type]=e.value),t.A.setUserAttr(n,s)}})),o&&t.A.setUserAttr(n,{key:"lead_source",text:"widget"});let a=t.A.get(r,"question.value",this.props.t("get_started")),l=t.A.get(r,"group.value","");this._creating=(this._creating||0)+1;let c=this._creating;this.setState({creating:!0});let h=t.A.map(r,((e,i)=>({key:i,type:e.type,value:t.A.stringify(e.value)})));if(await this.props.store.submitForm("chatbox_"+i,h,n),await t.A.sleep(500),c!=this._creating)return;if(this.props.cid){if(this.setState({clickedJoin:!1}),await this.props.store.sendConvoEvent(this.props.cid,"message_sent",{message:{text:a,format:"plaintext",fields:[{key:"to_agent_group",value:t.A.stringify(l)}],attachments:this.state.quickReplyMessage.attachments}}),c!=this._creating)return;return this.setState({creating:!1,quickReplyMessage:{}}),e.end_conversation_after_submit&&await this.props.store.endConvo(this.props.cid),void this._creating}let u={text:a,format:"plaintext"},d={group_id:l,message:a,locale:this.props.t.locale(),initial_by:n.id};this.setState({creatingError:null});const{error:p,convo:m}=await this.props.store.startConvo(d);if(c!=this._creating)return;if(p)return void this.setState({creating:!1,creatingError:p});let g=m.id;this.userSent[g]=!0,await this.props.store.sendConvoEvent(g,"message_sent",{message:u}),c==this._creating&&(this.setState({creating:!1,clickedJoin:!1,quickReplyMessage:{}}),this.props.onGo({view:"chat",cid:g}),this.props.store.isMobile()||this.focusInput())}onBooleanChange(e,i){this.wasFormInputed=!0;let s=t.A.cloneDeep(this.state.formData),r=t.A.find(s,((t,i)=>i===e));r&&(r.value=i.target.checked,this.setState({formData:s}))}onKeywordField(t,e,i,s){"Enter"==t.code&&this.submitPrechatForm(e,i)}onInputChange(e,i){this.wasFormInputed=!0;let s=t.A.cloneDeep(this.state.formData),r=t.A.find(s,((t,i)=>i===e));r&&(r.value=i,this.setState({formData:s}))}onListAddItem(e,i){this.wasFormInputed=!0;let s=t.A.cloneDeep(this.state.formData),r=t.A.find(s,((t,i)=>i===e));r&&(r.value=r.value||[],r.value.push(i),this.setState({formData:s}))}onListRemoveItem(e,i){this.wasFormInputed=!0;let s=t.A.cloneDeep(this.state.formData),r=t.A.find(s,((t,i)=>i===e));r&&(r.value=r.value||[],r.value.splice(i,1),this.setState({formData:s}))}renderCheckboxField(e){let i=t.A.get(e,"def.items",[]),s=[],r=e.value||"";return r&&(s=r.split(",")),(0,j.h)("div",null,t.A.map(i,(t=>(0,j.h)("div",{class:"checkbox"},(0,j.h)("input",{type:"checkbox",id:"form-checkbox"+Mt(e.key)+t.value,onChange:i=>this.toggleCheckboxField(e.key,t.value),checked:s.includes(t.value)}),(0,j.h)("label",{class:"checkbox--label",for:"form-checkbox"+Mt(e.key)+t.value},this.props.t.i18n(t.i18n_label)||t.label||t.value),(0,j.h)("div",{class:"checkbox--check"},(0,j.h)("div",null))))))}toggleCheckboxField(e,i){this.wasFormInputed=!0;let s=t.A.cloneDeep(this.state.formData),r=t.A.find(s,((t,i)=>t.key===e));if(!r)return;let n=r.value||"",o=[];n&&(o=n.split(",")),o.includes(i)?o=t.A.filter(o,(t=>t!==i)):o.push(i),r.value=o.join(","),this.setState({formData:s})}renderRadioField(e){let i=t.A.get(e,"def.items",[]),s=e.value||"";return(0,j.h)("div",null,t.A.map(i,(t=>(0,j.h)("div",{class:"radio"},(0,j.h)("input",{type:"radio",name:"form-radio"+Mt(e.key),id:"form-radio"+Mt(e.key)+t.value,onChange:i=>this.toggleRadioField(e.key,t.value),checked:s===t.value}),(0,j.h)("label",{class:"radio--label",for:"form-radio"+Mt(e.key)+t.value},this.props.t.i18n(t.i18n_label)||t.label||t.value),(0,j.h)("div",{class:"radio--check"},(0,j.h)("div",null))))))}toggleRadioField(e,i){this.wasFormInputed=!0;let s=t.A.cloneDeep(this.state.formData),r=t.A.find(s,((t,i)=>t.key===e));r&&(r.value=i,this.setState({formData:s}))}selectDropdownField(e,i){this.wasFormInputed=!0;let s=t.A.cloneDeep(this.state.formData),r=t.A.find(s,((t,i)=>t.key===e));r&&(r.value=i,this.setState({formData:s}))}renderDropdownField(e){let i=t.A.get(e,"def.items",[]);return(0,j.h)("select",{class:"form-control",value:e.value,onChange:t=>this.selectDropdownField(e.key,t.target.value)},(0,j.h)("option",{value:""},"-- ",this.props.t("no_select")," --"),t.A.map(i,(t=>(0,j.h)("option",{value:t.value},this.props.t.i18n(t.i18n_label)||t.label||t.value))))}renderFields(e,i){if(0===t.A.size(this.state.formData))return null;let s=t.A.map(this.state.formData,((s,r)=>{if(this.state.quickReplyMessage.text&&"question"===r)return null;let n=null;var o=s.error?"input--error":"";if("text"===s.type)n="question"==r||t.A.get(s,"def.multiple_line")?(0,j.h)("textarea",{class:"form-control",ref:t=>{this["form_"+Mt(r)]=t},id:"form_"+Mt(r),value:s.value||"",onInput:t=>this.onInputChange(r,t.target.value),onChange:t=>this.onInputChange(r,t.target.value),row:"4",class:"form-control"}):"checkbox"===t.A.get(s,"def.select")?this.renderCheckboxField(s):"radio"===t.A.get(s,"def.select")?this.renderRadioField(s):"dropdown"===t.A.get(s,"def.select")?this.renderDropdownField(s):(0,j.h)("input",{id:"form_"+Mt(r),value:s.value||"",onInput:t=>this.onInputChange(r,t.target.value),onChange:t=>this.onInputChange(r,t.target.value),onKeyDown:t=>this.onKeywordField(t,e,i,r),ref:t=>{this["form_"+Mt(r)]=t},class:`form-control ${o}`,type:"text"});else if("number"===s.type)n=(0,j.h)("input",{id:"form_"+Mt(r),value:s.value,onInput:t=>this.onInputChange(r,t.target.value),ref:t=>{this["form_"+Mt(r)]=t},class:`form-control ${o}`,type:"number"});else if("boolean"===s.type)n=(0,j.h)("div",{class:"checkbox"},(0,j.h)("input",{type:"checkbox",id:"form-checkbox"+Mt(r),onInput:t=>this.onBooleanChange(r,t),checked:s.value}),(0,j.h)("label",{class:"checkbox--label",for:"form-checkbox"+Mt(r)},s.label),(0,j.h)("div",{class:"checkbox--check"},(0,j.h)("div",null)));else if("group"===s.type)n=t.A.map(s.list,(t=>(0,j.h)("div",{class:"radio"},(0,j.h)("input",{type:"radio",id:"form-radio"+Mt(r)+Mt(t.value),checked:s.value===t.value,onInput:e=>this.onInputChange(r,t.value)}),(0,j.h)("label",{class:"radio--label",for:"form-radio"+Mt(r)+Mt(t.value)},this.props.t.i18n(t.i18n_label)||t.label||t.value),(0,j.h)("div",{class:"radio--check"},(0,j.h)("div",{class:"inside"})))));else if("list"===s.type){let e=this.state.formData[r].value||[],i=t.A.filter(t.A.get(s,"list",[]),(i=>!t.A.includes(e,i)));n=(0,j.h)(Z,{selected:e,items:i,onAddItem:t=>this.onListAddItem(r,t),onRemoveItem:t=>this.onListRemoveItem(r,t)}),n=this.renderDropdownField(s)}else"datetime"===s.type&&(n=(0,j.h)("input",{id:"form_"+Mt(r),value:s.value,onInput:t=>this.onInputChange(r,t.target.value),class:`form-control ${o}`,type:"date"}));let a="";return"fullname"===s.key?a=this.props.t("fullname"):"emails"===s.key?a=this.props.t("email"):"phones"===s.key?a=this.props.t("phones"):"question"===s.key&&(a=s.label||this.props.t("your_question")),s.label&&(a=s.label),(0,j.h)("div",{key:"form_"+Mt(r)},(0,j.h)("label",{class:"label",for:"form_"+Mt(r)},a,s.is_required?(0,j.h)("span",{class:"ml-1 red"},"*"):""),s.error?(0,j.h)("div",{class:"form-control--valid-input--error"},s.error):"",n)}));return(0,j.h)("div",{class:"pt-2"},s)}renderForm(e,i,s){let r=this.props.t.i18n(t.A.get(e,"i18n_title",{}));return r||(r=t.A.get(e,"title",this.props.t("capture_lead_title"))),r=r.replace("↵",""),(0,j.h)("div",{class:"widget-body"},(0,j.h)(St,{key:e._updated,form:e,onMount:this.formMounted}),(0,j.h)("div",{class:"widget-body--content flex-grow-1 pl-3 pr-3 d-flex flex-column"},(0,j.h)("div",{class:"flex-grow-1"},(0,j.h)("div",{class:"form mt-3 pl-3 pr-3 pt-3 pb-3 d-flex flex-column"},(0,j.h)("div",null,r),this.renderFields(e,s))),(0,j.h)(q,{store:this.props.store,t:this.props.t})),(0,j.h)("div",{class:"message-input message-input--preform"},(0,j.h)("button",{class:"btn--start-convo",onClick:t=>this.submitPrechatForm(e,s),disabled:this.state.creating},i)))}goToConvo(t){this.props.onGo({view:"chat",cid:t})}renderConvoList(){let e=this.props.store.matchConvo("*");var i=t.A.map(e,(t=>this.props.store.matchConvo(t.id)));i=t.A.filter(i,(t=>!!t)),i=t.A.orderByF(i,(e=>t.A.get(e,"last_message_sent.created",e.actived)),"desc");var s=t.A.map(i,(e=>{let i=t.A.filter(e.members,(t=>"agent"===t.type&&"active"===t.membership||"bot"===t.type)),s=t.A.map(i,(t=>t.id));return s=s||t.A.agentsOfConvo(e)[0],(0,j.h)("div",{class:"convo-list--item",onClick:()=>this.goToConvo(e.id),key:e.id},(0,j.h)(W,{plugin:this.props.plugin,store:this.props.store,mode:"member",class:"d-flex flex-row",tooltipPos:"right",agent_ids:s}),this.renderConvoSummary(e))}));let r=(0,j.h)("div",{class:"convo-list--list"},s);return 0===t.A.size(i)&&(r=(0,j.h)("div",{class:"convo-list--list"},(0,j.h)("div",{class:"empty-container"},(0,j.h)("img",{alt:"empty",src:At}),(0,j.h)("div",{class:"empty-desc"},this.props.t("empty_convo"))))),(0,j.h)("div",{class:"convo-list"},(0,j.h)("div",{class:"convo-list--container"},(0,j.h)("div",{class:"convo-list--title"},this.props.t("conversations")),r),(0,j.h)("div",{class:"convo-list--footer"},(0,j.h)("button",{class:"btn--start-convo",onClick:t=>this.goToConvo("")},(0,j.h)("span",null,this.props.t("start_conversation")),(0,j.h)("img",{src:bt,alt:"send button",width:"26",height:"26"})),(0,j.h)(q,{store:this.props.store})))}blur(){if(!this.props.store.isPreview){var e=this.msgInput.current;e&&(t.A.setTimeout((()=>e&&e.blur())),t.A.setTimeout((()=>e&&e.blur()),300))}}focusInput(e){if(!this.props.store.isPreview){if(this.shouldShowForm()){let e="";return t.A.map(this.state.formData,((t,i)=>{"text"===t.type&&(e||t.value||(e=i))})),void t.A.setTimeout((()=>{var t=this["form_"+Mt(e)];t&&t.focus()}),300)}var i=this.msgInput.current;i&&(null!=e&&"string"==typeof e&&i.applyMessage(e),t.A.setTimeout((()=>i.focus())),t.A.setTimeout((()=>i.focus()),300))}}onRate(t){this.props.cid&&(this.props.store.sendConvoEvent(this.props.cid,"conversation_rated",{conversation:{ratings:[t]}}),this.focusInput())}fillQuickReplyToQuestion(e){let i=this.state.formData;i&&t.A.set(i,"question.value",e.text||this.props.t("get_started")),this.setState({formData:i,quickReplyMessage:e})}createPostback(t){this.props.store.createPostback(this.props.cid,t)}onChangeMessageInput(){this.wasFormInputed=!0}renderChat(){let t=(0,j.h)(V,{store:this.props.store,ref:this.msgInput,cid:this.props.cid,onChange:this.onChangeMessageInput,is_loading:this.state.creating,onSend:this.sendMessage,t:this.props.t}),e=this.props.store.matchConvo(this.props.cid)||{};return(this.isFormRequired()||"ended"===e.state)&&(t=(0,j.h)("div",{class:"message-input message-input--preform"},(0,j.h)("button",{class:"btn--start-convo",onClick:t=>this.onStartConvoClick(t)},this.props.t("offline_preform_btn")))),(0,j.h)("div",{class:"widget-body"},(0,j.h)("div",{class:"widget-body--content",onClick:t=>this.onContainerClick(t)},(0,j.h)(gt,{isShow:this.props.isShow,onLink:this.onLink,store:this.props.store,chatbox:this.props.plugin.chatbox||{},onFormSubmit:t=>this.onEventFormSubmit(t),ref:t=>this.$events=t,cid:this.props.cid,creating:this.creating,onSend:t=>this.sendMessage(t),onPostback:t=>this.createPostback(t),t:this.props.t,plugin:this.props.plugin})),(0,j.h)(_t,{forceView:this.props.view,plugin:this.props.plugin,store:this.props.store,onRate:t=>this.onRate(t),cid:this.props.cid,t:this.props.t}),(0,j.h)(kt,{forceView:this.props.view,plugin:this.props.plugin,show:this.state.showOrder,order_id:this.state.order_id,store:this.props.store,onClose:this.closeOrder,cid:this.props.cid,t:this.props.t}),t)}async onStartConvoClick(){if("ended"===(this.props.store.matchConvo(this.props.cid)||{}).state)return this.props.onGo({view:"chat",cid:""});this.setState({clickedJoin:!0,quickReplyMessage:{}})}onEventFormSubmit(){this.focusInput()}onContainerClick(){window.getSelection().toString().length>0||this.props.store.isMobile()||this.focusInput()}isFormRequired(){let e,i=this.props.plugin.chatbox||{},s=this.props.store.matchAccount()||{};t.A.get(i,"prechat_form.enabled")&&(e=i.prechat_form);let r=t.A.get(i,"offline_form.enabled");if(this.isOffline(s,i)&&r&&(e=i.offline_form),!e)return!1;let n=this.fillForm(e),o=this.props.store.matchConvo(this.props.cid)||{};if("ended"===o.state)return!0;o.state&&"pending"!==o.state&&delete n.group;let a=!0;return t.A.each(n,(t=>{t.value&&(a=!1)})),!(!a||this.userHasSent(this.props.cid))||!!t.A.find(n,(t=>t.is_required&&(null==t.value||""===t.value)))}renderConvoSummary(e){let i=this.props.plugin.chatbox||{},s=this.props.store.matchAgent("*"),r=t.A.filter(e.members,(t=>"agent"===t.type||"bot"===t.type)),n=t.A.map(r,(t=>t.id));n=n||t.A.agentsOfConvo(e)[0];let o=t.A.map(n,(t=>s[t]||{avatar_url:xt,fullname:"Offline Agent"}));var a=t.A.each(o,(t=>t.fullname)).join(", ");!i.hide_agent_profile&&a||(a=this.props.store.matchAccount().name),a||(a=this.props.t("agent"));var l=null;"user"===e.lastSenderType&&(l=(0,j.h)("span",null,this.props.t("you"),":"));let c=t.A.isConvoSeen(e,this.props.store.matchUser().id);var h=this.renderMessagePreview(e.last_message_sent),u=t.A.getMs(t.A.get(e,"last_message_sent.created"))||t.A.getMs(e.created);let d=c?null:(0,j.h)("div",{class:"convo-list--item-unread"});return"ended"===e.state&&(d=(0,j.h)("img",{alt:"conversation ended",class:"convo-list--convo-completed",src:wt,title:this.props.t("conversation_ended")})),(0,j.h)("div",{class:"convo-list--convo-last-info"},(0,j.h)("div",{class:"d-flex flex-row"},(0,j.h)("div",{class:"convo-list--convo-name"},a),(0,j.h)("div",{class:"convo-list--convo-time"},(0,j.h)(lt.A,{ago:!0,time:u,t:this.props.t,short:!0}))),(0,j.h)("div",{class:"d-flex flex-row"},(0,j.h)("div",{class:"convo-list--convo-last-message"},l,h),d))}agentsOfConvo(e){let i=this.props.store.matchAgent("*");var s=t.A.agentsOfConvo(e,!0);return t.A.map(s,(t=>i[t]||{avatar_url:xt,fullname:"Offline Agent"}))}renderMessagePreview(e){let i=this.props.t("sent_you_a_message"),s=t.A.get(e,"data.message.text");if("plaintext"!==t.A.get(e,"data.message.format")&&(s=i),!s&&t.A.size(t.A.get(e,"data.message.attachments"))>0&&(s=i),!s)return null;let r=t.A.get(e,"by.type");return(0,j.h)("div",{class:"convo-list--convo-last-mes"},t.A.map(t.A.extractText(s),(t=>"emoji"===t.type?(0,j.h)(E.A,{emojiCode:t.text,byType:r}):t.text)))}userHasSent(e){var i=this.props.store.matchConvo(e)||{};let s=this.props.store.matchUser();return!!this.userSent[e]||t.A.find(i.members,(t=>t.id===s.id&&("active"===t.membership||t.last_sent>0)))}hasSentMessage(e){if(this.userSent[e])return!0;let i=this.props.store.matchConvo(e)||{};return t.A.find(i.members,(t=>"bot"===t.type||t.last_sent))}isOffline(e,i){let s=t.A.get(i,"offline_form.enable_when"),r=!0;return"all_agents_offline"===s&&(r=e.is_online),"out_of_bussiness_hour"===s&&(r=e.is_in_business_hour),!r}updateFormDataFields(){let e,i=this.props.plugin.chatbox||{},s=this.props.store.matchAccount()||{};t.A.get(i,"prechat_form.enabled")&&(e=i.prechat_form);let r=t.A.get(i,"offline_form.enabled");if(this.isOffline(s,i)&&r&&(e=i.offline_form),"offline_form"===this.props.view&&(e=i.offline_form),"prechat_form"===this.props.view&&(e=i.prechat_form),0===t.A.size(e))return[];var n={};t.A.each(e.fields,(e=>{var i=Object.assign({},e);"list"===e.type&&(i.list=e.list),i.label=this.props.t.i18n(t.A.get(e,"i18n_label",{}))||e.label,n["attr:"+e.key]=i})),e.group_required&&t.A.size(e.groups)>0&&(n.group={key:"group",is_required:!!e.group_required,label:this.props.t.i18n(t.A.get(e,"i18n_group_label",{}))||e.group_label,type:"group",list:t.A.map(e.groups,(t=>({value:t.id,label:t.name,i18n_label:t.i18n_name})))}),e.question_required&&(n.question={key:"question",is_required:!0,label:this.props.t.i18n(t.A.get(e,"i18n_question_label",{}))||e.question_label,type:"text"}),this.isFormChanged(this.state.formData,n)&&this.setState({formData:n})}isFormChanged(e,i){let s=Object.keys(e),r=Object.keys(i);if(s.length!==r.length)return!0;for(let n=0;n<s.length;n++){if(t.A.get(e,`${s[n]}.label`)!==t.A.get(i,`${r[n]}.label`))return!0;if(t.A.get(e,`${s[n]}.is_required`)!==t.A.get(i,`${r[n]}.is_required`))return!0;if(t.A.stringify(t.A.get(e,`${s[n]}.list`))!==t.A.stringify(t.A.get(i,`${r[n]}.list`)))return!0}return!1}fillForm(e){if(0===t.A.size(e))return[];var i={};let s=this.props.store.matchUser();return t.A.each(e.fields,(e=>{var r=Object.assign({},e);r.value=t.A.getUserAttr(s,e.key,e.type),"emails"!=r.key||r.value||(r.value=t.A.getUserAttr(s,"related_email","text")),"phones"!=r.key||r.value||(r.value=t.A.getUserAttr(s,"related_phone","text")),"boolean"!==e.type||r.value||(r.value=!1),"datetime"===e.type&&r.value&&(r.value=new t.A.Date(i.value).toLocaleDateString("en-CA")),"list"===e.type&&(r.list=e.list),r.label=this.props.t.i18n(t.A.get(e,"i18n_label",{}))||e.label,i["attr:"+e.key]=r})),e.group_required&&t.A.size(e.groups)>0&&(i.group={key:"group",is_required:!!e.group_required,label:this.props.t.i18n(t.A.get(e,"i18n_group_label",{}))||e.group_label,type:"group",list:t.A.map(e.groups,(t=>({value:t.id,label:t.name})))}),i}}class St extends D.Mw{componentDidMount(){this.props.onMount(this.props.form)}}function Mt(t){return encodeURIComponent(t)}let It=n.e(278).then(n.bind(n,9278));class Pt extends D.Mw{constructor(t){super(t),this.refButton=(0,j._3)(),this.refWidget=(0,j._3)()}async refreshCSS(){let e=this.props.store.matchPlugin(),i=t.A.find(e,(t=>t.id===this.props.plugin.id));if(!i)return;let s=(await It).default.default.toString();var r=t.A.replaceCssVariable(s,i.chatbox);t.A.setCss(this.props.plugin.id,this.$cssStyleDiv,r)}componentWillUnmount(){t.A.setCss(this.props.plugin.id,this.$cssStyleDiv,"")}async componentDidMount(){if(this.$cssStyleDiv=document.getElementById("subiz-style-for-"+this.props.plugin.id),this.$cssStyleDiv||(this.$cssStyleDiv=document.createElement("style"),document.head.appendChild(this.$cssStyleDiv),this.$cssStyleDiv.type="text/css",this.$cssStyleDiv.id="subiz-style-for-"+this.props.plugin.id),this.setState({cssready:!1,isShowWidget:!1,widgetView:"",widgetConvoId:""}),this.checkExpand(),this.props.store.onResetCSS(this,(()=>this.refreshCSS())),this.props.store.onConvoEvent(this,(t=>this.onConvoEvent(t))),this.props.store.onUpdate(this,(t=>this.checkExpand())),await this.refreshCSS(),this.setState({cssready:!0}),this.props.store.matchIsOpen()&&this.props.store.matchLastview().view){if(this.props.store.isMobile())return;this.showWidget(Object.assign({},this.props.store.matchLastview().opts,{view:this.props.store.matchLastview().view}))}else Dt(),this.state.isShowWidget||this.hideWidget()}render(){return this.state.cssready?t.A.isUserBanned(this.props.store.matchUser())?null:this.props.t?(0,j.h)("div",{class:this.props.store.isMobile()?"mobile":"desktop"},(0,j.h)(z,{plugin:this.props.plugin,store:this.props.store,key:"chat_button",ref:this.refButton,isShow:!this.state.isShowWidget,onClick:t=>this.showWidget(t),t:this.props.t}),(0,j.h)(Ct,{plugin:this.props.plugin,store:this.props.store,view:this.state.widgetView,cid:this.state.widgetConvoId,isShow:this.state.isShowWidget,onClose:t=>this.onWidgetClose(t),onGo:t=>this.showWidget(t),t:this.props.t,ref:this.refWidget})):null:null}onConvoEvent(t){this.checkExpand(),this.checkShowBotConvo(t)}checkShowBotConvo(e){let i=this.refWidget.current;if(!i)return;if(i.wasFormInputed)return;if("message_sent"!==e.type)return;if(!this.state.isShowWidget)return;let s=t.A.get(e,"by.type");if(!(t.A.get(e,"by.id")||"").startsWith("bb")||"agent"!==s)return;let r=t.A.get(e,"data.message.conversation_id");r&&this.showWidget({cid:r,view:"chat"})}checkExpand(){if(this.props.store.isMobile())return;if(this.props.plugin._no_auto_expand)return;if(this.props.store.matchHasManuallyClosed())return;let e=this.props.store.matchConvo("*"),i=t.A.find(e,(e=>!t.A.isConvoSeen(e,this.props.store.matchUser().id)));i&&i.id&&(this.state.isShowWidget||this.showWidget({view:"chat",cid:i.id}))}getCurrentView(){return{is_show_widget:this.state.isShowWidget,conversation_id:this.state.widgetConvoId,view:this.state.widgetView}}async showWidget(e){if(this.refButton.current&&this.refButton.current.ClearPreview(),!e.view){let i=this.props.store.matchLastview()||{};e.view=t.A.get(i,"view"),e.cid=t.A.get(i,"opts.cid")}if(!(e=e||{}).view&&!e.cid){let i=this.props.store.matchConvo("*"),s=t.A.find(i,(e=>!t.A.isConvoSeen(e,this.props.store.matchUser().id)));e.cid=t.A.get(s,"id",t.A.get(i,"0.id")),e.view="chat"}this.props.store.isMobile()&&function(){document.body&&document.body.classList&&document.body.classList.add("sbz_no_scroll"),document.documentElement&&document.documentElement.classList&&document.documentElement.classList.add("sbz_no_scroll");let t=document.createElement("meta");t.httpEquiv="X-UA-Compatible",t.name="viewport",t.id="subiz-meta-viewport",t.content="maximum-scale=1.0, user-scalable=no, width=device-width, initial-scale=1.0",document.getElementsByTagName("head")[0].appendChild(t)}(),this.setState({widgetConvoId:e.cid,widgetView:e.view}),this.props.store.setIsOpen(!0),this.forceUpdate(),this.setState({isShowWidget:!0}),this.props.store.setLastview(e.view,{cid:e.cid})}applyMessage(t){this.refWidget.current&&this.refWidget.current.applyMessage(t)}showGreeting(){this.refButton.current&&this.refButton.current.ShowGreeting()}hideGreeting(){this.refButton.current&&this.refButton.current.HideGreeting()}showTyping(){this.refWidget.current&&this.refWidget.current.ShowTyping()}hideWidget(){Dt(),this.props.store.setIsOpen(!1),this.setState({isShowWidget:!1})}onWidgetClose(){this.refButton.current&&this.refButton.current.ClearPreview(),this.refButton.current&&this.refButton.current.ClosePreview(),this.props.store.setHasManuallyClosed(),this.hideWidget(),this.props.store.emitCloseWidgetEvent()}}function Dt(){document.body&&document.body.classList&&document.body.classList.remove("sbz_no_scroll"),document.documentElement&&document.documentElement.classList&&document.documentElement.classList.remove("sbz_no_scroll");let t=document.getElementById("subiz-meta-viewport");t&&t.remove()}function jt(e,i,s,r){if(!s)throw"$div must is a valid html node";var o=document.createElement("div");o.id=e.id;let a=i.matchAccount();o.setAttribute("sbz-plugin-type",e.type),o.setAttribute("sbz-plugin-account-id",a.id),s.appendChild(o);let l=D.JK(e,t.A.detectLang());var c,h=new t.A.Gate,u=0,d="hold",p=this;this.getState=()=>d;var m=async function(){if(A)return;if("hold"!==d)return;if("popup"===e.type&&i.isConverted(e.id))return;let s=i.matchLastPluginRun(e.id);"chatbox"!==e.type&&"notification"!==e.type||(s=void 0),e.enabled&&t.A.checkRunConditions(e.initiative_frequency,e.conditions,s,i)&&(d="running",await p.update(e))};this.forceRunPopup=async()=>{t.A.get(g,"current")?g.current.openPopup():w()};var g=(0,j._3)();let f=null,v=null,_=null;var y=t=>r.showWidget(t),b=()=>{u++,w()},w=async()=>{A||o&&("chatbox"===e.type&&(0,j.XX)((0,j.h)(Pt,{destroy:A,plugin:e,store:i,ref:g,t:this.t}),o),"popup"===e.type&&(f||(f=(await n.e(132).then(n.bind(n,132))).default),(0,j.XX)((0,j.h)(f,{destroy:A,t:this.t,highlight:c,mobile:i.isMobile(),plugin:e,store:i,ref:g,pageIndex:u,nextPage:b,showWidget:y}),o)),"notification"===e.type&&(_||(_=(await n.e(490).then(n.bind(n,1490))).default),(0,j.XX)((0,j.h)(_,{destroy:A,t:this.t,mobile:i.isMobile(),plugin:e,store:i,ref:g}),o)),"contact"===e.type&&(v||(v=(await n.e(74).then(n.bind(n,9074))).default),(0,j.XX)((0,j.h)(v,{destroy:A,t:this.t,plugin:e,store:i,ref:g}),o)),h.open())};this.call=(t,e)=>h.entry().then((()=>g.current[t](e)));var A=!1;this.destroy=()=>{A=!0,(0,j.XX)(null,o),o.parentNode.removeChild(o)},this.highlight=t=>{c=t,w()},this.update=t=>{A||(e=t,"hold"!==d&&"finished"!==d&&w())};let k=e=>{if("debug"===l)return`{{${e}}}`;let i=t.A.get(D.r9,l,[]),s=t.A.find(i,(t=>t.key===e));return t.A.get(s,"message",e)};k.i18n=t=>{if(!t)return"";let i=e.locale||a.locale||"vi-VN";return i=i.replace("-","_"),t[l.replace("-","_")]||t[i]},k.locale=()=>l,this.forceDownloadLanguage=async()=>{await D.Dy(i,l,!0),this.update(e)},this.setLocale=async t=>l===t?t:(this.t=null,w(),l=D.JK(e,t),await D.Dy(i,l),this.t=k,w(),l);let x={};t.A.map(t.A.get(e,"popup.pages"),(e=>{e&&t.A.map(e.components,(t=>{"image"===t.type&&t.image&&t.image.url&&t.image.url.startsWith("http")&&(x[t.image.url]=!0)}))})),t.A.size(x)>=0&&t.A.map(x,((e,i)=>t.A.preloadImg(i)));let C=t.A.get(e,"triggers")||[{type:"after_pageview",after_pageview_sec:0,disabled:!1}];for(var S=0;S<t.A.size(C);S++){var M=C[S];M&&(M.disabled||("exit_intent"===M.type&&t.A.trackExitIntent(m),"area_clicked"===M.type&&t.A.trackAreaClicked(M.area_clicked_css_selector,m),"scrolling_percentage"===M.type&&t.A.trackScrollingPercentage(M.scrolling_percentage,m),"inactivity_duration"===M.type&&t.A.trackInactivity(M.inactivity_sec,m),"after_pageview"===M.type&&t.A.trackTimeOnPage(M.after_pageview_sec,m)))}this.update(e),D.Dy(i,l).then((()=>{this.t=k,this.update(e)}))}class Et{constructor(e,i){this.refM={},this.lib=e,this.$div=i,this.pluginM={},this._destroy=!1,e.store.onHighlight({_isMounted:!0},((t,e)=>{let i=this.pluginM[t];i&&i.highlight(e)})),e.store.onUpdate({_isMounted:!0},(()=>{if(this._destroy)return;let s=this.lib.store.matchPlugin(),r=!1;t.A.each(s,(t=>{if("chatbox"===t.type){if(r)return;r=!0}this.pluginM[t.id]?this.pluginM[t.id].update(t):this.pluginM[t.id]=new jt(t,this.lib.store,i,e)})),t.A.each(this.pluginM,((t,e)=>{s[e]||(this.pluginM[e].destroy(),delete this.pluginM[e])}))}));let s=this.lib.store.matchPlugin(),r=!1;t.A.each(s,(t=>{if("chatbox"===t.type){if(r)return;r=!0}this.pluginM[t.id]||(this.pluginM[t.id]=new jt(t,this.lib.store,i,e))}))}findChatbox(){var e=this.lib.store.matchPlugin();let i=t.A.filter(this.pluginM,((t,i)=>"chatbox"===e[i].type));if(0===t.A.size(i))return void console.error("no chatbox found.");let s=t.A.find(i,(t=>"running"===t.getState()));if(s||(s=i[0]),s)return s;console.error("found no suitable chatbox to run.")}getCurrentView(){let t=this.findChatbox();if(t)return t.call("getCurrentView")}showCurrentChatbox(t){let e=this.findChatbox();if(e)return e.call("showWidget",t)}showCurrentChatboxTyping(){let t=this.findChatbox();if(t)return t.call("showTyping")}showCurrentGreeting(){let t=this.findChatbox();if(t)return t.call("showGreeting")}applyTextToCurrentChatbox(t){let e=this.findChatbox();if(e)return e.call("applyMessage",t)}hideCurrentGreeting(){let t=this.findChatbox();if(t)return t.call("hideGreeting")}hideCurrentChatbox(){let t=this.findChatbox();if(t)return t.call("hideWidget")}forceUpdateLang(t){let e=this.pluginM[t];if(e)return e.forceDownloadLanguage()}forceRunPopup(t){let e=this.pluginM[t];if(e)return e.forceRunPopup(t)}setPluginLocale(t,e){let i=this.pluginM[t];if(i)return i.setLocale(e)}setCurrentChatboxLocale(t){let e=this.findChatbox();if(e)return e.setLocale(t)}destroy(){t.A.map(this.pluginM,((t,e)=>{t.destroy(),delete this.pluginM[e]})),this._destroy=!0}}function Tt(t,e,i){return(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}var Lt=document.createElement("link");Lt.href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap",Lt.rel="stylesheet",document.head.append(Lt),t.A.preloadWebfonts(["Inter"],[400,500]);class Ut{constructor(e,i,s,r,n){Tt(this,"version",(()=>"4.5")),Tt(this,"setSetting",(t=>this.store.setSetting({account_setting:t}))),Tt(this,"getUser",(()=>t.A.parseJSON(t.A.stringify(this.store.matchUser())))),Tt(this,"setViewingProduct",(t=>this.store.linkProduct(t))),Tt(this,"getViewingProduct",(()=>this.store.getLinkedProduct())),Tt(this,"track",(()=>this.store.track())),this.impressionTokens={},this.domGate=new t.A.Gate,this.store=new A(e,i,s,r,n),window.sbz_store=this.store,this.subs=[],this.store.onConvoEvent({_isMounted:!0},(e=>t.A.map(this.subs,(t=>{t&&"function"==typeof t&&t(e)})))),this.store.onWidgetClose({_isMounted:!0},(e=>t.A.map(this.subs,(t=>{t&&"function"==typeof t&&t(e)}))))}async waitReady(t){await this.store.readyGate.entry(),t()}setAIDevMode(t){this.store.setAIDevMode(t)}setTrackPageView(t){this.store.setTrackPageview(t)}getTrackPageView(){return this.store.getTrackPageview()}async cleanLogin(t,e){}async login(e,i,s,r){let n=await this.store.login(e,i,s);r||(r=document.body),this.pluginMgr=new Et(this,r);let o=t.A.setInterval((()=>{r&&r.isConnected||(this.pluginMgr.destroy(),t.A.clearInterval(o))}),1e3);return this.domGate.open(),n}logout(t){return this.store.logout(t)}async init(e,i){let s=(e=e||{}).account_id,r=e.ref,n=await this.store.init(s,void 0,r,e);t.A.setTimeout((()=>window.postMessage({type:"widget_loaded",account_id:s},"*")),0),i||(i=document.body||document),this.pluginMgr=new Et(this,i);let o=t.A.setInterval((()=>{i&&i.isConnected||(this.pluginMgr.destroy(),t.A.clearInterval(o))}),1e3);return this.domGate.open(),n}async start(e,i,s,r){let n=(e=e||{}).account_id,o=await this.store.init(n,s,e.ref,e);t.A.setTimeout((()=>window.postMessage({type:"widget_loaded",account_id:n},"*")),0),i||(i=document.body||document),this.pluginMgr=new Et(this,i);let a=t.A.setInterval((()=>{i&&i.isConnected||(this.pluginMgr.destroy(),t.A.clearInterval(a))}),1e3);return this.domGate.open(),r&&r(o),o}async setAccount(e,i,s,r){let n=await this.store.init(e,s);t.A.setTimeout((()=>window.postMessage({type:"widget_loaded",account_id:e},"*")),0),i||(i=document.body||document),this.pluginMgr=new Et(this,i);let o=t.A.setInterval((()=>{i&&i.isConnected||(this.pluginMgr.destroy(),t.A.clearInterval(o))}),1e3);return this.domGate.open(),r&&r(n),n}_setAccount(t,e){return this.setAccount(t,e)}async updateUserAttributes(e){await this.store.setUser({attributes:e});var i=this.store.matchUser();return t.A.cloneDeep(i.attributes)}async getUserAttributes(){await this.store.readyGate.entry();var e=this.store.matchUser();return t.A.cloneDeep(t.A.get(e,"attributes",[]))}async getWidgetCurrentView(){return await this.domGate.entry(),this.pluginMgr.getCurrentView()}async createTicket(t){return await this.domGate.entry(),this.createTicket(t)}expandWidget(t,e){return this.showWidget(t,e)}shrinkWidget(){return this.hideWidget()}async sendMessage(t,e){if(!t){const{convo:i,error:s}=await this.store.startConvo({message:e.text,initial_by:this.store.matchUser().id});if(s)return{error:s};t=i.id}return this.store.sendConvoEvent(t,"message_sent",{message:e})}async viewForm(e){if(!e||!t.A.startsWith(e,"cp"))return;let i=this.impressionTokens[e];if(i)return i;let{body:s}=await this.store.sendImpression(e);return i=t.A.get(s,"impression_token")||"",this.impressionTokens[e]=i,i}async submitForm(e,i){if(!e||!t.A.startsWith(e,"cp"))return;let s=t.A.cloneDeep(this.store.matchUser()),r={id:s.id,account_id:s.account_id},n=!1;i=t.A.map(i,(e=>{let i=e.key;return"email"===i&&(i="emails"),"phone"===i&&(i="phones"),n=n||"emails"==i||"phones"==i,t.A.setUserAttr(r,{key:i,[e.type||"text"]:e.value}),{key:i,type:e.type||"text",value:t.A.stringify(e.value)}})),n&&t.A.setUserAttr(r,{key:"lead_source",text:"plugin."+e});let o=await this.viewForm(e);return this.store.setUserDiff(r),this.store.sendConversion(e,i,o)}startConvo(t){return this.store.startConvo(t)}async showGreeting(){await this.domGate.entry(),this.pluginMgr.showCurrentGreeting()}async hideGreeting(){await this.domGate.entry(),this.pluginMgr.hideCurrentGreeting()}async showWidget(t,e){await this.domGate.entry(),this.pluginMgr.showCurrentChatbox({view:t,cid:e})}async showTyping(){await this.domGate.entry(),this.pluginMgr.showCurrentChatboxTyping()}async hideWidget(){await this.domGate.entry(),this.pluginMgr.hideCurrentChatbox()}async setLocale(t){return await this.domGate.entry(),this.pluginMgr.setCurrentChatboxLocale(t)}async setLanguage(t){return await this.domGate.entry(),this.pluginMgr.setCurrentChatboxLocale(t)}async setPluginLocale(t,e){return await this.domGate.entry(),this.pluginMgr.setPluginLocale(t,e)}_overrideDeviceType(t){this.store.overrideDeviceType(t)}unload(){this.pluginMgr&&this.pluginMgr.destroy(),this.store.destroy()}async applyMessage(t){await this.domGate.entry(),this.pluginMgr.applyTextToCurrentChatbox(t)}_overridePlugin(t){this.store.overridePlugin(t)}_forceUpdateLang(t){this.pluginMgr.forceUpdateLang(t)}_highlight(t,e){this.store.highlight(t,e)}openPopup(t){this.pluginMgr.forceRunPopup(t)}unEvent(e){this.subs=t.A.filter(this.subs,(t=>t!==e))}async countUnreadMessages(){return await this.domGate.entry(),this.store.matchUnread()}onEvent(e){this.subs=t.A.filter(this.subs,(t=>t!==e)),this.subs.push(e)}overrideAccount(t){this.store.overrideAcc(t)}async overrideChatbox(e){await this.store.overrideChatbox(e),t.A.get(e,"chatbox.greeting.greeting")&&this.pluginMgr.showCurrentGreeting()}stopAutobot(){this.store.doNotStartBot()}}window.__sbz_WIDGET=Ut;const zt=Ut;n(318);var Rt=n(5180),Ot=new zt(Rt.ApiURL,Rt.FileURL,Rt.RealtimeURL);function $t(t){t=t||[];var e=[];if(Array.isArray(t))e=t;else{if("object"!=typeof t)return;for(var i=Object.keys(t),s=0;s<i.length;s++)e.push(t[i[s]])}if(!((t=e).length<1)){var r=t.shift();if("function"==typeof Ot[r])return Ot[r](...t)}}!function(){let e=window.subiz&&window.subiz.q||[];window.subiz=function(){return $t(arguments)},e.forEach($t),Ot.store.readyGate.entry().then((function(){Ot.store.track(),function(e){if(!e.matchAutoStartBot())return;let i=e.matchBot();0!==Object.keys(i).length&&t.A.each(i,(i=>{let s=async()=>{if(s=()=>!0,!t.A.checkRunConditions(i.initiative_frequency,i.conditions,e.matchLastBotRun(i.id),e))return;let{error:r}=await e.startConvo({initial_by:i.id,locale:D.JK(i,t.A.detectLang()),state:"active",members:[{type:"bot",id:i.id}]});if(r)return console.error(r);e.logBotRun(i.id)},r=t.A.get(i,"triggers")||[];for(let e of r){if(!e)continue;if(e.disabled)continue;let i=s;"area_clicked"===e.type&&t.A.trackAreaClicked(e.area_clicked_css_selector,i),"scrolling_percentage"===e.type&&t.A.trackScrollingPercentage(e.scrolling_percentage,i),"inactivity_duration"===e.type&&t.A.trackInactivity(e.inactivity_sec,i),"after_pageview"===e.type&&t.A.trackTimeOnPage(e.after_pageview_sec,i)}}))}(Ot.store)}))}()})()})();
|