!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ycloudSDK=t():e.ycloudSDK=t()}("undefined"!=typeof self?self:this,function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:o})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(1);const i={getAppFrame:()=>document.getElementById("ycloud-sdk-widget"),createFrame:e=>{if(i.getAppFrame())return;Object(o.b)();const t=`/#/?shopName=${e}`;const n="http://localhost:8011"===window.location.origin?window.location.origin+t:"https://sdk.ycloud.com/growth-tool/"+t,d=document.createElement("div");d.id="ycloud-sdk";const r=document.createElement("iframe");r.id="ycloud-sdk-widget",r.src=n,d.appendChild(r),document.getElementsByTagName("body")[0].appendChild(d);let s=!1;document.addEventListener("click",e=>{let t=document.querySelector("#ycloud-sdk"),n=e.target;if(t===n||t.contains(n));else{if(s)return void setTimeout(()=>{s=!1},100);i.sendMessage({close:!0})}}),i.onMessage();const a=window._YCLOUD.openChat;window._YCLOUD.openChat=(()=>{s=!0,a()})},onMessage:()=>{window.onmessage=(e=>{if("string"!=typeof e.data||0!==e.data.indexOf("ycloud-sdk:"))return;const t=JSON.parse(e.data.replace("ycloud-sdk:",""));i.initFrameStyle(t),i.showSdk(t)})},sendMessage:e=>{i.getAppFrame().contentWindow.postMessage(`ycloud-sdk:${JSON.stringify(e)}`,"*")},initFrameStyle:e=>{const t=Object(o.a)(),n=i.getAppFrame();let{chatOpen:d,position:r,xPadding:s,yPadding:a,showBubble:c,bubbleHeight:p}=e,l=Number(s)-20,u=Number(a)-20,h=window.innerHeight-u,m="";m=d?t?"width: 100%;height: 100%;":"width: 400px;height: "+(h<=200?200:h>=570?570:h)+"px;":c?t?"width: 100%;height: "+p+"px;":"width: 525px;height: "+p+"px;":"width: 100px;height: 100px;";let g="";!t||t&&!d?(g="bottom:"+u+"px;",g+="right"===r?"right:"+l+"px;":"left:"+l+"px;"):g="bottom: 0;right: 0;left: 0;";let f=m+g;n.setAttribute("style",f)},showSdk:e=>{i.getAppFrame().style.display="block"},emptyClose:e=>{}};t.IFrameHelper=i,window._YCLOUD={init:i.createFrame,openChat:()=>{i.sendMessage({openChat:!0})},closeChat:()=>{i.sendMessage({close:!0})}}},function(e,t,n){"use strict";var o=n(2);t.b=(()=>{const e=document.createElement("style");e.type="text/css",e.innerHTML=`${o.a}`,document.body.appendChild(e)});t.a=(()=>{let e=window.navigator.userAgent.toLowerCase();return/mobile|android|iphone|ipad|phone/i.test(e)||window.innerWidth<600})},function(e,t,n){"use strict";t.a="\n#ycloud-sdk-widget {\n border: none;\n width: 100%;\n max-width: 100vw;\n max-height: 100vh;\n position: fixed;\n top: auto;\n left: auto;\n z-index: 999999999 !important;\n}\n"}])});