(function(){function z(a,c,b,e){c||(c=1E3);var f;return function(){var g=e||this,d=arguments;b&&!f&&a.apply(g,d);k.clearTimeout(f);f=k.setTimeout(function(){!b&&a.apply(g,d);f=null},c)}}function s(a,c){var b=c?l.NODE_LIST:l.NODE_ITEM;try{var e=document.evaluate(a,document,null,b,null);switch(e.resultType){case l.NODE_ITEM:return e.singleNodeValue;case l.NODE_LIST:for(var b=[],f=0,g=e.snapshotLength;f<g;f++)b.push(e.snapshotItem(f));return b;default:q&&console.warn("[tmr-dyn-goals] Error#1","Unsupported XPathResultType",
e.resultType)}}catch(d){q&&console.warn("[tmr-dyn-goals] Error#2",d)}return null}function t(a){a=a.textContent.replace(/\s+/g,"").match("(^(?:\\d+(?:\\,|\\.)?\\d*)|(?:\\d*(?:\\,|\\.)?\\d+))(?:[^0-9]*$)|(?:^[^0-9]*)((?:\\d+(?:\\,|\\.)?\\d*)|(?:\\d*(?:\\,|\\.)?\\d+))(?:[^0-9]*$)");if(!a||void 0===a[1]&&void 0===a[2])return null;a=(a[1]||a[2]).split(/\,|\./);a=parseFloat((a[0]||0)+"."+(a[1]||0));return isNaN(a)?null:a}function u(){for(var a=0,c=m.length;a<c;a++){var b=m[a],e=s(b.conditions.target,!0);
if(e){b._node=b._node||{};b._node.target=b._node.target||[];for(var f=0,g=e.length;f<g;f++){var d=e[f],h;b:{h=b._node.target;for(var k=0,l=h.length;k<l;k++)if(h[k]===d){h=!0;break b}h=!1}h||(b._node.target.push(d),A(b,d))}}}}function A(a,c){c.addEventListener("click",B.bind(this,a))}function B(a){if(!r){for(var c={id:a.id,type:"reachGoal",goal:a.goal},b=0,e=n.length;b<e;b++){var f=c,g=a,d=n[b],h=g._node[d.key];!g._node[d.key]&&g.conditions[d.key]&&(h=s(g.conditions[d.key]),!v&&h&&(g._node[d.key]=
h));if(h){g._data=g._data||{};var l=g._data[d.key];l||(l=d.parseFn(h),!v&&l&&(g._data[d.key]=l));l&&d.pushFn(f,l)}}q&&console.info("[tmr-dyn-goals]: Reach goal",c);(k._tmr||(k._tmr=[])).push(c)}}function C(a){if(!r){a:{for(var c={},b=0,e=a.length;b<e;b++){var f=a[b];f.addedNodes&&f.addedNodes.length&&(c.added=!0);!p&&(f.removedNodes&&f.removedNodes.length)&&(c.removed=!0);if(c.added&&(p||c.removed)){a=c;break a}}a=c}a.added&&u();if(!p&&a.removed){a=0;for(c=m.length;a<c;a++)if(b=m[a],b._node){var g=
f=e=void 0,d=b._node.target;if(d&&d.length){e=0;for(f=d.length;e<f;e++)g=d[e],w(g)||(d.splice(e,1),e--,f--)}e=0;for(f=n.length;e<f;e++){var g=b,d=n[e],h=g._node[d.key];h&&!w(h)&&(delete g._node[d.key],g._data[d.key]&&delete g._data[d.key])}}}}}var k=window,x=document,y=location,q="string"===typeof y.search&&-1!=y.search.search(/[?&]tmr_debug=1(?:&|$)/),v=!0,p=!1,m=[],r=!1,l={NODE_ITEM:XPathResult.FIRST_ORDERED_NODE_TYPE,NODE_LIST:XPathResult.ORDERED_NODE_SNAPSHOT_TYPE},n=[{key:"value",parseFn:t,
pushFn:function(a,c){a.value=c}},{key:"productid",parseFn:t,pushFn:function(a,c){a.params={product_id:c}}}];if(!p)var w=function(a){try{return x.body.contains(a)}catch(c){}return!0};u();(function(){try{if(k.MutationObserver){var a=z(C,200,!1);(new MutationObserver(a)).observe(x.body,{childList:!0,subtree:!0})}}catch(c){}})();(function(){var a=k.JSON&&k.JSON.parse?k.JSON.parse.bind(k.JSON):function(a){return{}};k.addEventListener("message",function(c){var b=null;try{b=c.data;c=typeof b;if("number"===
c||"boolean"===c||"string"===c||b.nodeType||b===b.window)b=a(b);"LOAD_BUTTONS_SCRIPT"===b.type&&(r=!0)}catch(e){}})})()})();
