smooch
Version:
Smooch.io powered web messaging
3 lines • 8.3 kB
JavaScript
/*! For license information please see index.js.LICENSE.txt */
(()=>{var t={988:(t,e,n)=>{var o=n(755),r=n(665).each;function i(t,e){this.query=t,this.isUnconditional=e,this.handlers=[],this.mql=window.matchMedia(t);var n=this;this.listener=function(t){n.mql=t.currentTarget||t,n.assess()},this.mql.addListener(this.listener)}i.prototype={constuctor:i,addHandler:function(t){var e=new o(t);this.handlers.push(e),this.matches()&&e.on()},removeHandler:function(t){var e=this.handlers;r(e,(function(n,o){if(n.equals(t))return n.destroy(),!e.splice(o,1)}))},matches:function(){return this.mql.matches||this.isUnconditional},clear:function(){r(this.handlers,(function(t){t.destroy()})),this.mql.removeListener(this.listener),this.handlers.length=0},assess:function(){var t=this.matches()?"on":"off";r(this.handlers,(function(e){e[t]()}))}},t.exports=i},177:(t,e,n)=>{var o=n(988),r=n(665),i=r.each,a=r.isFunction,s=r.isArray;function c(){if(!window.matchMedia)throw new Error("matchMedia not present, legacy browsers require a polyfill");this.queries={},this.browserIsIncapable=!window.matchMedia("only all").matches}c.prototype={constructor:c,register:function(t,e,n){var r=this.queries,c=n&&this.browserIsIncapable;return r[t]||(r[t]=new o(t,c)),a(e)&&(e={match:e}),s(e)||(e=[e]),i(e,(function(e){a(e)&&(e={match:e}),r[t].addHandler(e)})),this},unregister:function(t,e){var n=this.queries[t];return n&&(e?n.removeHandler(e):(n.clear(),delete this.queries[t])),this}},t.exports=c},755:t=>{function e(t){this.options=t,!t.deferSetup&&this.setup()}e.prototype={constructor:e,setup:function(){this.options.setup&&this.options.setup(),this.initialised=!0},on:function(){!this.initialised&&this.setup(),this.options.match&&this.options.match()},off:function(){this.options.unmatch&&this.options.unmatch()},destroy:function(){this.options.destroy?this.options.destroy():this.off()},equals:function(t){return this.options===t||this.options.match===t}},t.exports=e},665:t=>{t.exports={isFunction:function(t){return"function"==typeof t},isArray:function(t){return"[object Array]"===Object.prototype.toString.apply(t)},each:function(t,e){for(var n=0,o=t.length;n<o&&!1!==e(t[n],n);n++);}}},974:(t,e,n)=>{var o=n(177);t.exports=new o}},e={};function n(o){var r=e[o];if(void 0!==r)return r.exports;var i=e[o]={exports:{}};return t[o](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};(()=>{"use strict";n.r(o),n.d(o,{default:()=>j});function t(t){"complete"!==document.readyState&&"loaded"!==document.readyState&&"interactive"!==document.readyState||!document.body?document.addEventListener("DOMContentLoaded",(function(){t()})):t()}function e(t){var e=["screen"];return t.minHeight&&e.push("(min-height: ".concat(t.minHeight,"px)")),t.maxHeight&&e.push("(max-height: ".concat(t.maxHeight,"px)")),t.minWidth&&e.push("(min-width: ".concat(t.minWidth,"px)")),t.maxWidth&&e.push("(max-width: ".concat(t.maxWidth,"px)")),e.join(" and ")}var r=n(974),i=n.n(r),a={lg:{minHeight:668,minWidth:1200},md:[{minHeight:508,minWidth:768,maxWidth:1199},{minHeight:508,maxHeight:667,minWidth:768}],sm:{maxHeight:507,minWidth:768},xs:{maxWidth:767}},s=["lg","md","sm","xs"];function c(t){for(var e=0;e<s.length;e++){var n=s[e],o=a[n];"[object Array]"!==Object.prototype.toString.call(o)&&(o=[o]);for(var r=0;r<o.length;r++)t({rule:o[r],size:n})}}var d="web-messenger-container";function h(){return h=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)({}).hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},h.apply(null,arguments)}function u(t){return function(t){if(Array.isArray(t))return l(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return l(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?l(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=Array(e);n<e;n++)o[n]=t[n];return o}var p,f,m,v,y,g={},b=[],w=[],x=/lebo|awle|pide|obo|rawli|dsbo/i.test(navigator.userAgent),_=/PhantomJS/.test(navigator.userAgent)&&!0,S=["init","login","on","off","logout","sendMessage","triggerPostback","createConversation","updateConversation","updateUser","getDisplayedConversation","getConversationById","getConversations","getMoreConversations","hasMoreConversations","getUser","open","close","isOpened","loadConversation","setDelegate","markAllAsRead","showNotificationChannelPrompt","setPredefinedMessage","startTyping","stopTyping"];if(x){var C=document.createElement("a");C.href="https://smooch.io/live-web-chat/?utm_source=widget",C.text="Powered by Zendesk Sunshine",t((function(){document.body.appendChild(C)}))}function A(t){var n;window.__onWebMessengerFrameReady__=function(){},p=t,m||(n=f,c((function(t){var o=t.rule,r=t.size;i().register(e(o),(function(){n.contentWindow.postMessage({type:"sizeChange",value:r},"".concat(location.protocol,"//").concat(location.host))}))})));for(var o=S[0],r=0;r<S.length;o=S[++r])g[o]=p[o];if(w){for(var a=w[0],s=0;s<w.length;a=w[++s]){var d;(d=p).on.apply(d,u(a.args))}w=void 0}if(y){var h,l=(h=p).init.apply(h,u(y));y=void 0;for(var v=b[0],x=0;x<b.length;v=b[++x])l="then"===v.type?l.then(v.next):l.catch(v.next);b=[]}}var M=function(t){return t.contentWindow&&t.contentWindow.document};var O={VERSION:"5.7.15",on:function(){w||(w=[]);for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];w.push({args:e})},init:function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];y=n,m=n.length>0&&!!n[0].embedded,x||_||t((function(){var t;(t=document.createElement("link")).rel="stylesheet",t.type="text/css",t.href="https://cdn.smooch.io/smooch.5.7.15.css",document.body.appendChild(t),function(){if(!f){var t=null,e=!1;(f=document.createElement("iframe")).id=d,f.frameBorder=0,f.allowFullscreen=!0,f.allowTransparency=!0,f.title="Chat box",f.scrolling="no",f.className="sLpKhIF7eEv-snNG6Miz1Q==";var n=function(){e=!0,clearInterval(t),delete f.onload;var n=void 0!==window.__webpack_nonce__?window.__webpack_nonce__:null,o=n?'nonce="'.concat(n,'"'):"",r="\n <!DOCTYPE html>\n <html>\n <head>\n ".concat("",'\n <link rel="stylesheet" href="').concat("https://cdn.smooch.io/frame.5.7.15.css",'" type="text/css" ').concat(o,' />\n <script src="').concat("https://cdn.smooch.io/frame.5.7.15.min.js",'" async crossorigin="anonymous" ').concat(o,'><\/script>\n </head>\n <body>\n <div id="mount"></div>\n </body>\n </html>\n ');if("srcdoc"in f)f.srcdoc=r;else{var i=M(f);i.open(),i.write(r),i.close()}};t=setInterval((function(){var t=M(f);e||!t||"complete"!==t.readyState&&"interactive"!==t.readyState||n()}),1e3),f.onload=function(){e||n()}}m?v&&(v.appendChild(f),v=void 0):document.body.appendChild(f)}()}));var r={then:function(t){return b.push({type:"then",next:t}),r},catch:function(t){return b.push({type:"catch",next:t}),r}};return r},render:function(t){f?t.appendChild(f):v=t},destroy:function(){p&&(p.destroy(),f.remove?f.remove():f.parentNode.removeChild(f),c((function(t){var n=t.rule;i().unregister(e(n))})),W())}};function W(){if(!document.getElementById(d)){p=void 0,f=void 0,window.__onWebMessengerFrameReady__=A;for(var t=S[0],e=0;e<S.length;t=S[++e])g[t]&&delete g[t];h(g,O)}}W();const j=g})(),module.exports=o})();
//# sourceMappingURL=index.js.map