define(["jquery","pubsub"],function(d,f){return new function(){var a=this,c=f.topicNames||{},e=function(b,a){window._eeq=window._eeq||[];3==b?a.type=b:a={type:b,data:a||{}};_eeq.push(a)};a.cartAddSuccess=function(b){b=b||{};var a=b.childSKUs&&b.childSKUs[0];if(a&&b.orderQuantity){var c=a.salePrice;b=[{n:1,v:""+b.orderQuantity},{n:2,v:""+a.listPrice}];c&&b.push({n:3,v:""+c});e(1,b)}};a.cartUpdated=function(b){b&&b.currency&&e(-1,b.currency)};a.pageLayoutLoaded=function(b){b=b&&b.data||{};var a=b.page&&
b.page.confirmation;if(a){b=a.priceInfo;a=a.shoppingCart&&a.shoppingCart&&a.shoppingCart.items;var c=0;a&&b&&b.currencyCode&&(d.each(a,function(a,b){c+=parseInt(b.quantity,10)}),e(2,{currencyCode:b.currencyCode,data:[{n:4,v:""+b.total},{n:1,v:""+c}]}))}};a.ccMetricMetadata=function(a){a&&a.logEEQ&&e(3,a.logEEQ)};a.ccMetricUnhook=function(){a.hooksAdded=0;d.Topic(c.CART_UPDATED).unsubscribe(a.cartUpdated);d.Topic(c.CART_ADD_SUCCESS).unsubscribe(a.cartAddSuccess);d.Topic(c.PAGE_LAYOUT_LOADED).unsubscribe(a.pageLayoutLoaded);
c.REGION_METADATA_CHANGED&&d.Topic(c.REGION_METADATA_CHANGED).unsubscribe(a.ccMetricMetadata)};a.ccMetricAddHooks=function(){a.hooksAdded||(d.Topic(c.CART_UPDATED).subscribe(a.cartUpdated),d.Topic(c.CART_ADD_SUCCESS).subscribe(a.cartAddSuccess),d.Topic(c.PAGE_LAYOUT_LOADED).subscribe(a.pageLayoutLoaded),c.REGION_METADATA_CHANGED&&d.Topic(c.REGION_METADATA_CHANGED).subscribe(a.ccMetricMetadata),a.hooksAdded=1)};a.ccMetricAddHooks()}});
