/** * Copyright since 2007 PrestaShop SA and Contributors * PrestaShop is an International Registered Trademark & Property of PrestaShop SA * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to https://devdocs.prestashop.com/ for more information. * * @author PrestaShop SA and Contributors * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ import{_ as c,o as f,p as I,q as k,u as N,v as b,w as S,x as g,C as P,y as O,z as m,A as E,B as F,D as z,E as L,P as M,F as R,G as B,H as Q,I as W}from"./sentry-96f4e833.js";import{i as G}from"./is-plan-event-enabled-a83d33b8.js";import"./dom-utils-d77254b8.js";function C(n){return n.toLowerCase().replace(".","").replace(/\s+/g,"-")}function D(n,t){return t===void 0&&(t=!1),t?btoa(n).replace(/=/g,""):void 0}function H(n){return("Integration"in n?n.Integration:n).prototype.name}function T(n,t,i){var r,a;try{var e=((a=(r=window==null?void 0:window.performance)===null||r===void 0?void 0:r.getEntriesByName(n,"resource"))!==null&&a!==void 0?a:[])[0];e&&t.stats.gauge("legacy_destination_time",Math.round(e.duration),b([i],e.duration<100?["cached"]:[],!0))}catch{}}function U(n,t,i){var r;if("Integration"in n){var a={user:function(){return i.user()},addIntegration:function(){}};n(a),r=n.Integration}else r=n;var e=new r(t);return e.analytics=i,e}function V(n,t,i,r){return c(this,void 0,void 0,function(){var a,e,s,u,o,d;return f(this,function(v){switch(v.label){case 0:a=C(t),e=D(a,r),s=k(),u="".concat(s,"/integrations/").concat(e??a,"/").concat(i,"/").concat(e??a,".dynamic.js.gz"),v.label=1;case 1:return v.trys.push([1,3,,4]),[4,I(u)];case 2:return v.sent(),T(u,n,t),[3,4];case 3:throw o=v.sent(),n.stats.gauge("legacy_destination_time",-1,["plugin:".concat(t),"failed"]),o;case 4:return d=window["".concat(a,"Deps")],[4,Promise.all(d.map(function(h){return I(s+h+".gz")}))];case 5:return v.sent(),window["".concat(a,"Loader")](),[2,window["".concat(a,"Integration")]]}})})}function J(n,t,i){return c(this,void 0,void 0,function(){var r,a,e,s;return f(this,function(u){return r=k(),a=C(n),e=D(n,i),s="".concat(r,"/integrations/").concat(e??a,"/").concat(t,"/").concat(e??a,".dynamic.js.gz"),[2,N(s)]})})}function K(n){var t,i,r,a;return(a=(i=(t=n==null?void 0:n.versionSettings)===null||t===void 0?void 0:t.override)!==null&&i!==void 0?i:(r=n==null?void 0:n.versionSettings)===null||r===void 0?void 0:r.version)!==null&&a!==void 0?a:"latest"}var X=function(n,t){var i,r=t.type,a=t.bundlingStatus,e=t.versionSettings,s=a!=="unbundled"&&(r==="browser"||((i=e==null?void 0:e.componentTypes)===null||i===void 0?void 0:i.includes("browser")));return!n.startsWith("Segment")&&n!=="Iterable"&&s},Y=function(n,t){var i=t.All===!1&&t[n]===void 0;return t[n]===!1||i};function Z(n,t){return c(this,void 0,void 0,function(){var i,r=this;return f(this,function(a){switch(a.label){case 0:return i=[],S()?[2,t]:[4,L(function(){return t.length>0&&Q()},function(){return c(r,void 0,void 0,function(){var e,s,u;return f(this,function(o){switch(o.label){case 0:return e=t.pop(),e?[4,B(e,n)]:[2];case 1:return s=o.sent(),u=s instanceof W,u||i.push(e),[2]}})})})];case 1:return a.sent(),i.map(function(e){return t.pushWithBackoff(e)}),[2,t]}})})}var $=function(){function n(t,i,r,a,e){r===void 0&&(r={}),this.options={},this.type="destination",this.middleware=[],this._ready=!1,this._initialized=!1,this.flushing=!1,this.name=t,this.version=i,this.settings=g({},r),this.disableAutoISOConversion=a.disableAutoISOConversion||!1,this.integrationSource=e,this.settings.type&&this.settings.type==="browser"&&delete this.settings.type,this.options=a,this.buffer=a.disableClientPersistence?new M(4,[]):new R(4,"dest-".concat(t)),this.scheduleFlush()}return n.prototype.isLoaded=function(){return this._ready},n.prototype.ready=function(){var t;return(t=this.onReady)!==null&&t!==void 0?t:Promise.resolve()},n.prototype.load=function(t,i){var r;return c(this,void 0,void 0,function(){var a,e,s=this;return f(this,function(u){switch(u.label){case 0:return this._ready||this.onReady!==void 0?[2]:(r=this.integrationSource)!==null&&r!==void 0?(e=r,[3,3]):[3,1];case 1:return[4,V(t,this.name,this.version,this.options.obfuscate)];case 2:e=u.sent(),u.label=3;case 3:a=e,this.integration=U(a,this.settings,i),this.onReady=new Promise(function(o){var d=function(){s._ready=!0,o(!0)};s.integration.once("ready",d)}),this.onInitialize=new Promise(function(o){var d=function(){s._initialized=!0,o(!0)};s.integration.on("initialize",d)});try{t.stats.increment("analytics_js.integration.invoke",1,["method:initialize","integration_name:".concat(this.name)]),this.integration.initialize()}catch(o){throw t.stats.increment("analytics_js.integration.invoke.error",1,["method:initialize","integration_name:".concat(this.name)]),o}return[2]}})})},n.prototype.unload=function(t,i){return J(this.name,this.version,this.options.obfuscate)},n.prototype.addMiddleware=function(){for(var t,i=[],r=0;r0&&this.scheduleFlush(),[2]}})})},Math.random()*5e3)},n}();function nt(n,t,i,r,a){var e,s;if(t===void 0&&(t={}),i===void 0&&(i={}),E())return[];n.plan&&(i=i??{},i.plan=n.plan);var u=(s=(e=n.middlewareSettings)===null||e===void 0?void 0:e.routingRules)!==null&&s!==void 0?s:[],o=n.integrations,d=i.integrations,v=F(n,i??{}),h=a==null?void 0:a.reduce(function(l,w){var y;return g(g({},l),(y={},y[H(w)]=w,y))},{}),p=new Set(b(b([],Object.keys(o).filter(function(l){return X(l,o[l])}),!0),Object.keys(h||{}).filter(function(l){return z(o[l])||z(d==null?void 0:d[l])}),!0));return Array.from(p).filter(function(l){return!Y(l,t)}).map(function(l){var w=o[l],y=K(w),_=new $(l,y,v[l],i,h==null?void 0:h[l]),j=u.filter(function(A){return A.destinationName===l});return j.length>0&&r&&_.addMiddleware(r),_})}export{$ as LegacyDestination,nt as ajsDestinations};