!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;t.length>n;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,a,o=[],i=!0,u=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);i=!0);}catch(e){u=!0,a=e}finally{try{i||null==n.return||n.return()}finally{if(u)throw a}}return o}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);t>n;n++)r[n]=e[n];return r}var u=/^(?:.*[@(])?(.*):(\d+):(\d+)\)?$/,c=/at\s+(.*?)\s+\((.*?):(\d+):(\d+)\)/,l=/at\s+(.*?):(\d+):(\d+)/;function s(e){var t=e.lineno,n=e.stack?e:e.error;if(t)return window.__APP_CODE__?{type:"app-code-block",appKey:window.__APP_CODE__.getAppKey(t)}:{type:"all"};if(n){var r=function(e){try{var t=e.split("\n").filter(Boolean).map((function(e){var t=e.match(c);if(t)return{line:e,functionName:t[1],fileName:t[2],lineNumber:parseInt(t[3]),columnNumber:parseInt(t[4])};var n=e.match(l);if(n)return{line:e,functionName:"",fileName:n[1],lineNumber:parseInt(n[2]),columnNumber:parseInt(n[3])};var r=e.match(u);if(!r)return{line:e};var a=o(r,4);return{line:e,fileName:a[1],lineNumber:a[2],columnNumber:a[3]}})),n=null==t?void 0:t.find((function(e){return!!e.fileName}));return null==n?void 0:n.fileName}catch(e){return console.error(e),null}}(""+n.stack);if(r)try{var a=document.querySelector('script[src="'.concat(r,'"')),i=null==a?void 0:a.getAttribute("org");if(a&&i)return{type:i.startsWith("ST_")?"script-tag":"app-extension",appKey:i}}catch(e){return console.error(e),{type:"all"}}}return{type:"all"}}var p=new(function(){function e(){t(this,e),this.queue=[],this.extraData={},this.loop()}return r(e,[{key:"loop",value:function(){var e,t=this;setTimeout((function(){t.queue.length&&t.report(JSON.stringify(t.queue)),t.queue=[],t.loop()}),(null===(e=window.__ENV__)||void 0===e?void 0:e.SL_TRACK_REPORT_DELAY)||5e3)}},{key:"info",value:function(e,t){this.pushQueue("info",e,t)}},{key:"error",value:function(e,t){this.pushQueue("error",e,t)}},{key:"setExtraData",value:function(e,t){this.extraData[e]=t}},{key:"pushQueue",value:function(e,t,n){var r,a,o,i,u,c,l={domainCode:t,payload:{level:e,url:window.location.href,ua:null===(r=window)||void 0===r||null===(a=r.navigator)||void 0===a?void 0:a.userAgent,data:n,timestamp:Date.now(),extraData:this.extraData,themeId:null===(o=window.Shopline)||void 0===o?void 0:o.themeId,themeName:null===(i=window.Shopline)||void 0===i?void 0:i.themeName,themeVersion:null===(u=window.Shopline)||void 0===u?void 0:u.themeVersion,themeTypeVersion:window.Shopline.themeTypeVersion,updateMode:null===(c=window.Shopline)||void 0===c?void 0:c.updateMode}};this.queue.push(l)}},{key:"report",value:function(e){var t=new XMLHttpRequest;t.onreadystatechange=function(){},t.open("POST","".concat(window.__SL_Track_Url__||"","/capture/exception")),t.setRequestHeader("content-type","application/json; charset=UTF-8"),t.send(e)}}]),e}());function d(e,t){var n=t.message,r=t.stack;setTimeout((function(){var t=s(e),a=t.appKey;p.error(a?t.type:"all",{appKey:a,error:{message:n,stack:r}})}))}window.__SL_Track__||(window.__SL_Track__=p);var f=0;function h(){return f>0}function v(){f+=1,setTimeout((function(){f-=1}))}function y(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;if("function"!=typeof e)return e;try{if(e.__track__)return e;if(e.__track_wrapped__)return e.__track_wrapped__}catch(t){return e}var r=function(){var r=Array.prototype.slice.call(arguments);try{n&&"function"==typeof n&&n.apply(this,arguments);var a=r.map((function(e){return y(e,t)}));return e.handleEvent?e.handleEvent.apply(this,a):e.apply(this,a)}catch(e){throw v(),d(e,{message:null==e?void 0:e.message,stack:null==e?void 0:e.stack}),e}};try{for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=e[a])}catch(e){}e.prototype=e.prototype||{},r.prototype=e.prototype,Object.defineProperty(e,"__track_wrapped__",{enumerable:!1,value:r}),Object.defineProperties(r,{__track__:{enumerable:!1,value:!0},__track_original__:{enumerable:!1,value:e}});try{var o=Object.getOwnPropertyDescriptor(r,"name");o.configurable&&Object.defineProperty(r,"name",{get:function(){return e.name}})}catch(e){}return r}function m(){return window}window.addEventListener("error",(function(e){var t;if(!h()){var n=(null==e?void 0:e.stack)||(null==e||null===(t=e.error)||void 0===t?void 0:t.stack);d(e,{message:null==e?void 0:e.message,stack:n})}})),window.addEventListener("unhandledrejection",(function(e){var t,n;h()||d(e,{message:null===(t=e.reason)||void 0===t?void 0:t.message,stack:null===(n=e.reason)||void 0===n?void 0:n.stack})}));var _="";function w(e){try{return e&&"function"==typeof e&&e.name||_}catch(e){return _}}function b(e,t,n){if(t in e){var r=e[t],a=n(r);if("function"==typeof a)try{a.prototype=a.prototype||{},Object.defineProperties(a,{__track_original__:{enumerable:!1,value:r}})}catch(e){}e[t]=a}}var g=["EventTarget","Window","Node","ApplicationCache","AudioTrackList","ChannelMergerNode","CryptoOperation","EventSource","FileReader","HTMLUnknownElement","IDBDatabase","IDBRequest","IDBTransaction","KeyOperation","MediaController","MessagePort","ModalWindow","Notification","SVGElementInstance","Screen","TextTrack","TextTrackCue","TextTrackList","WebSocket","WebSocketWorker","Worker","XMLHttpRequest","XMLHttpRequestEventTarget","XMLHttpRequestUpload"],k=function(){function n(r){t(this,n),this.name=n.id,this._options=void 0,this._options=function(t){for(var n=1;arguments.length>n;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?e(Object(r),!0).forEach((function(e){a(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({XMLHttpRequest:!0,eventTarget:!0,requestAnimationFrame:!0,setInterval:!0,setTimeout:!0},r)}return r(n,[{key:"setupOnce",value:function(){var e=m();(this._options.setTimeout&&b(e,"setTimeout",this._wrapTimeFunction.bind(this)),this._options.setInterval&&b(e,"setInterval",this._wrapTimeFunction.bind(this)),this._options.requestAnimationFrame&&b(e,"requestAnimationFrame",this._wrapRAF.bind(this)),this._options.XMLHttpRequest&&"XMLHttpRequest"in e&&b(XMLHttpRequest.prototype,"send",this._wrapXHR.bind(this)),this._options.eventTarget)&&(Array.isArray(this._options.eventTarget)?this._options.eventTarget:g).forEach(this._wrapEventTarget.bind(this))}},{key:"_wrapTimeFunction",value:function(e){return function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];var a=n[0];return n[0]=y(a,{mechanism:{data:{function:w(e)},handled:!0,type:"instrument"}}),e.apply(this,n)}}},{key:"_wrapRAF",value:function(e){return function(t){return e.call(this,y(t,{mechanism:{data:{function:"requestAnimationFrame",handler:w(e)},handled:!0,type:"instrument"}}))}}},{key:"_wrapEventTarget",value:function(e){var t=m(),n=t[e]&&t[e].prototype;n&&n.hasOwnProperty&&n.hasOwnProperty("addEventListener")&&(b(n,"addEventListener",(function(t){return function(n,r,a){try{"function"==typeof r.handleEvent&&(r.handleEvent=y(r.handleEvent.bind(r),{mechanism:{data:{function:"handleEvent",handler:w(r),target:e},handled:!0,type:"instrument"}}))}catch(e){}return t.call(this,n,y(r,{mechanism:{data:{function:"addEventListener",handler:w(r),target:e},handled:!0,type:"instrument"}}),a)}})),b(n,"removeEventListener",(function(e){return function(t,n,r){var a=n;try{var o=null==a?void 0:a.__track_wrapped__;o&&e.call(this,t,o,r)}catch(e){}return e.call(this,t,a,r)}})))}},{key:"_wrapXHR",value:function(e){return function(){var t=this,n=["onload","onerror","onprogress","onreadystatechange"];n.forEach((function(e){e in t&&"function"==typeof t[e]&&b(t,e,(function(t){var n={mechanism:{data:{function:e,handler:w(t)},handled:!0,type:"instrument"}};return t.__track_original__&&(n.mechanism.data.handler=w(t.__track_original__)),y(t,n)}))}));for(var r=arguments.length,a=Array(r),o=0;r>o;o++)a[o]=arguments[o];return e.apply(this,a)}}}]),n}();k.id="TryCatch",(new k).setupOnce()}));