/*! amazon-dtb-javascript-api - amzn_ads - v7.4.1 - 2018-05-24 16:22:39 */
!function(t){var e={};function n(a){if(e[a])return e[a].exports;var o=e[a]={i:a,l:!1,exports:{}};return t[a].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,a){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:a})},n.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=5)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};e.default=function(t,e,n,o){var r=!1;try{!function(){e=n.wrapFunction(e,"GdprCallback");var i=function(t){try{Object.keys(t.log).map(function(e){"string"==typeof t.log[e]&&-1!==t.log[e].indexOf("/")&&(t.log[e]=encodeURIComponent(t.log[e]))}),t.log=JSON.stringify(t.log)}catch(t){n.reportError(t,"__gdpr_stringify_log__")}e(t)};"object"===(void 0===t?"undefined":a(t))&&null!==t||(t={});var s={cmpGlobal:t.cmpGlobal,cmpTimeout:t.cmpTimeout,enabled:t.enabled};"string"!=typeof t.cmpGlobal&&(t.cmpGlobal="__cmp"),Number.isInteger(t.cmpTimeout)||(t.cmpTimeout=50);var c,d,u=(d={log:s},void 0===(c=t).enabled?d:!1===c.enabled?(d.enabled=0,d):(Number.isInteger(c.enabled)?d.enabled=c.enabled:d.enabled=1,"string"==typeof c.consent&&(d.consent=c.consent),d));!function(t,e){if(o.winHasProp(t.cmpGlobal)&&"function"==typeof window[t.cmpGlobal]){setTimeout(e,t.cmpTimeout,{timeout:!0},!0);try{window[t.cmpGlobal]("getVendorConsents",null,e)}catch(t){e({error:"cmp-internal-error"}),n.reportError(t,"__gdpr_cmp__")}}else e({error:"no-cmp"})}(t,function(t,e,o){if(!r){r=!0;try{return"object"===(void 0===e?"undefined":a(e))&&null!==e&&void 0!==e.error?(s.status=e.error,void i(t)):o&&"object"===(void 0===e?"undefined":a(e))&&null!==e?e.timeout?(s.status="cmp-timeout",void i(t)):e.gdprApplies?(t.enabled=1,t.consent=e.metadata,void i(t)):(t.enabled=0,delete t.consent,void i(t)):(s.status="cmp-error",void i(t))}catch(e){return n.reportError(e,"__gdpr_cmp_callback__"),s.status="func-error",void i(t)}}}.bind(null,u))}()}catch(t){r||e({log:'{"status":"global-func-error"}'}),r=!0,n.reportError(t,"__gdpr_global_func__")}}},,,,function(t,e,n){"use strict";var a,o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r=(a=n(0))&&a.__esModule?a:{default:a},i={log:'{"status":"cmp-in-flight"}'},s=!1,c=[],d={wrapFunction:function(t){return function(){try{return t.apply(null,arguments)}catch(t){return null}}},reportError:console.error},u={winHasProp:function(t){return Object.prototype.hasOwnProperty.call(window,t)}};(0,r.default)({},function(t){i=t,s=!0,c.map(function(t){try{t()}catch(t){}})},d,u),window.amznpassback=window.amznpassback||{},window.amznpassback.CPM_JS||(window.amznpassback.CSM_JS="//c.amazon-adsystem.com/aax2/csm.js.gz");var m=window.amznpassback;function l(t,e){t.write(e),t.close()}function p(t){var e=!1;function n(t){if(!e){e=!0;var n=document.createElement("iframe");n.style.display="none",n.src=t,document.body.appendChild(n)}}document.readyState&&"loading"==document.readyState?document.addEventListener?document.addEventListener("DOMContentLoaded",function(){n(t)},!1):document.attachEvent&&document.attachEvent("onreadystatechange",function(){"complete"==document.readyState&&n(t)}):n(t)}Date.now||(Date.now=function(){return(new Date).getTime()});var g=function(t,e,n){var a="https:"===e.location.protocol;t.latencyUtil=t.latencyUtil||null,t.protocol=a?"https://":"http://",t.DEFAULT_HOST="aax.amazon-adsystem.com",t.host=t.DEFAULT_HOST,t.dtb_svc="/e/dtb/bid",t.pb_svc="/x/getad",t.px_svc="/x/px/",t.debug_mode=t.debug_mode||!1,t.MIN_TIMEOUT=0,t.DEFAULT_TIMEOUT=1e3,t.targetingKey="amznslots",t.latencySamplingRate=1,t.vidKey="amzn_vid",t.tasks=t.tasks||[],t.VIEWABILITY_CUTOFF_AREA=t.VIEWABILITY_CUTOFF_AREA||.5,t.VIEWABILITY_CUTOFF_DURATION_SEC=t.VIEWABILITY_CUTOFF_DURATION_SEC||1,t.CSM_JS="//c.amazon-adsystem.com/aax2/csm.js.gz",t.vads={};var r=!1,d=new function(){this.metrics={},this.t0=Date.now(),this.i=0,this.addTimer=function(t,e){e||(e=Date.now()),this.metrics[t]=e-this.t0},this.set=function(t,e){this.metrics[t]=e},this.schedule=function(e,n){var a=this;e||(e=5e3),n||(n="PH"),n+="/",setTimeout(function(){a.metrics.i=a.i,a.metrics.t0=a.t0,a.metrics.site=a.getTopDomain(t);var e=JSON.stringify(a.metrics),o=t.protocol+t.host+t.px_svc+n+encodeURIComponent(e);(new Image).src=o,a.metrics={},a.t0=Date.now(),a.i++},e)},this.getTopDomain=function(t){var e=decodeURIComponent(t.getReferrerURL());return(e.indexOf("://")>-1?e.split("/")[2]:e.split("/")[0]).split(":")[0]}};function u(e,n,a,o,r){var i=null;r=r||{};try{n&&"function"==typeof n&&(i=t.handleCallBack(n,a))}catch(t){}r.to||(r.to=a),t.doGetAdsAsync(e,o,r,i)}function m(e,n,a){this.startTime=null,this.stopTime=null,this.sourceId=n,this.sync=e,this.mode=a,this.latency=null,m.prototype.startTimer=function(){this.startTime=Date.now()},m.prototype.stopTimer=function(){this.stopTime=Date.now()},m.prototype.stopTimerAndReportLatency=function(){this.stopTimer(),this.calculateLatency(),this.isThrottled()||this.reportLatency()},m.prototype.calculateLatency=function(){this.latency=this.stopTime-this.startTime},m.prototype.isThrottled=function(){var e=parseInt(t.latencySamplingRate,10);if(!isNaN(e)){if(0==e)return!0;if(100==e)return!1;if(100*Math.random()<=e)return!1}return!0},m.prototype.reportLatency=function(){if(null!==this.latency&&this.latency>0){var e='/{"c":"dtb","src":"'+this.sourceId+'","'+(this.sync?"bls":"bla")+'":"'+this.latency+'","m":"'+this.mode+'"}',n=t.protocol+t.host+t.px_svc+"PH"+e;(new Image).src=n}}}return d.addTimer("tlt"),t.ads||(t.ads={}),t.updateAds=function(e){if(e&&e.cmp&&""!=e.cmp&&"undefined"!=e.cmp&&p(e.cmp),r=!0,t.ads=e.ads,t.ev=e.ev,e.vads){var n;t.vads=e.vads,t.ads||(t.ads={});var a=!1;for(n in e.vads)e.vads.hasOwnProperty(n)&&-1!=n.indexOf("_d")&&(t.ads[n]=e.vads[n],t.amzn_vid=e.vads[n],a=!0);if(!a)for(n in e.vads)e.vads.hasOwnProperty(n)&&(t.ads[n]=e.vads[n],t.amzn_vid=e.vads[n])}t.doAllTasks(),t.tasks.push=function(e){t.doTask(e)};try{e.lsr&&(t.latencySamplingRate=e.lsr),e.rm&&(d.addTimer("br"),d.set("brs","1"),d.schedule(e.to,e.id)),null!==t.latencyUtil&&t.latencyUtil.stopTimerAndReportLatency()}catch(t){}},t.aaxPunt=function(t){try{t&&t.cmp&&""!=t.cmp&&"undefined"!=t.cmp&&p(t.cmp),r=!0,d.addTimer("br"),d.set("brs","0"),t&&t.rm&&d.schedule(t.to,t.id)}catch(t){}},t.saveAds=function(e){t.saved_ads=e.ads,t.updateAds(e)},t.getAdForSlot=function(n,a,o){t.src_id=n;var r=r||{},i=r.u;t.host=3e3==n?"aax-cpm.amazon-adsystem.com":t.host,i||(i=t.getReferrerURL()),i&&-1!==i.indexOf("amzn_debug_mode")&&(t.debug_mode=!0);var s="src="+t.src_id+"&slot_uuid="+a+"&c=100&u="+i+"&cb="+Math.round(1e7*Math.random()),c=t.protocol+t.host+t.pb_svc+"?jsd=1&"+s;o?t.appendScriptTag(c):l(e,"<script type='text/javascript' src='"+c+"'><\/script>")},t.getAdsCallback=function(t,e,n,a,o){o=o||{},s?u(t,e,n,a,o):c.push(u.bind(null,t,e,n,a,o))},t.getVideoAdsCallback=function(e,n,a,o,r){(r=r||{}).mt="V",t.getAdsCallback(e,n,a,o,r)},t.getDisplayAdsCallback=function(e,n,a,o,r){(r=r||{}).mt="D",t.getAdsCallback(e,n,a,o,r)},t.getAdsAsync=function(e,n,a){t.doGetAdsAsync(e,n,a)},t.getVideoAdsAsync=function(e,n,a){(a=a||{}).mt="V",t.getAdsAsync(e,n,a)},t.getDisplayAdsAsync=function(e,n,a){(a=a||{}).mt="D",t.getAdsAsync(e,n,a)},t.handleCallBack=function(e,a){var o=!1,r=null,i=function(t){if(!o){try{e(t),r&&clearTimeout(r),t||d.set("to","1")}catch(t){}o=!0}},s=t.getValidMilliseconds(a);return r=s?n.setTimeout(i,s):n.setTimeout(i,t.DEFAULT_TIMEOUT),i},t.getValidMilliseconds=function(e){if(!e)return!1;try{var n=~~Number(e);if(n>t.MIN_TIMEOUT)return n}catch(t){return!1}return!1},t.getAds=function(n,a,o,i){if(r=!1,i)t.doGetAdsAsync(n,a,o);else{var s=t.getScriptSource(n,a,o);try{t.latencyUtil=new m(!0,n,o&&o.mt?o.mt:"DV"),t.latencyUtil.startTimer(),d.addTimer("sb"),d.set("src",n)}catch(t){}s&&l(e,"<script type='text/javascript' src='"+s+"'><\/script>")}},t.getVideoAds=function(e,n,a,o){(a=a||{}).mt="V",t.getAds(e,n,a,o)},t.getDisplayAds=function(e,n,a,o){(a=a||{}).mt="D",t.getAds(e,n,a,o)},t.doGetAdsAsync=function(e,n,a,o){r=!1;var i=t.getScriptSource(e,n,a);try{t.latencyUtil=new m(!1,e,a&&a.mt?a.mt:"DV"),t.latencyUtil.startTimer(),d.addTimer("ab"),d.set("src",e)}catch(t){}t.appendScriptTag(i,o)},t.getScriptSource=function(n,a,r){if(!t.ssb){t.src_id=n;var s=(r=r||{}).u,c=r.d,u=r.to,m=r.mt;if(s||(s=t.getReferrerURL()),s&&-1!==s.indexOf("amzn_debug_mode")&&(t.debug_mode=!0),r.mt&&"V"!=r.mt&&"DV"!=r.mt||t.vads&&(t.vads={},delete t.amzn_vid),t.ads&&(t.clearTargetingFromGPTAsync(),t.ads={}),t.startTime&&o("number"==t.startTime)&&d.addTimer("st",t.startTime),t.saved_ads&&(t.ads=t.saved_ads),c)try{e.domain=c}catch(t){}var l="src="+n+"&u="+s+"&cb="+Math.round(1e7*Math.random());return a&&(l+="&sz="+a),u&&(l+="&t="+u),m&&(l+="&mt="+m),"object"===(void 0===i?"undefined":o(i))&&(p={enabled:"gdpre",consent:"gdprc",log:"gdprl"},Object.keys(p).filter(function(t){return void 0!==i[t]}).map(function(t){l+="&"+p[t]+"="+encodeURIComponent(i[t])})),t.protocol+t.host+t.dtb_svc+"?"+l}var p;t.ssb=!1},t.getReferrerURL=function(){var a=encodeURIComponent(e.documentURI);try{(a=encodeURIComponent(n.top.location.href))&&"undefined"!=a||(a=t.detectIframeAndGetURL())}catch(e){a=t.detectIframeAndGetURL()}return a},t.detectIframeAndGetURL=function(){try{if(n.top!==n.self)return encodeURIComponent(e.referrer)}catch(t){}return encodeURIComponent(e.documentURI)},t.appendScriptTag=function(t,n){if(t||!n||"function"!=typeof n){var a=e.getElementsByTagName("script")[0],o=e.createElement("script");o.type="text/javascript",o.async=!0,t&&(o.src=t);try{n&&"function"==typeof n&&(o.readyState?o.onreadystatechange=function(){"loaded"!=o.readyState&&"complete"!=o.readyState||(o.onreadystatechange=null,n(!0))}:o.onload=function(){n(!0)})}catch(t){}a.parentNode.insertBefore(o,a)}else n.apply(this,[!0])},t.renderAd=function(e,n){if(t.ads[n]){d.addTimer("imp");var a=t.ads[n];if(t.ev){var o="amznad"+Math.round(1e6*Math.random());a=(a=a.replace("window.top.amznads.detectViewability","window.amzncsm.rmD")).replace(/id=[^ ]*/,'id="'+o+'"');var r="<script type='text/javascript' src='"+t.CSM_JS+"'><\/script>\n";t.host!=t.DEFAULT_HOST&&(r+="<script type='text/javascript'>try{amzncsm.host=window.top.amznads.host;}catch(e){amzncsm.host=amznads.host;}<\/script>\n"),a=r+a}l(e,a)}else{d.set("kvm","1");var i={c:"dtb"};i.src=t.src_id,i.kvmismatch=1,i.pubReturnedKey=n,i.aaxReturnedKeys=t.getTokens(),i.cb=Math.round(1e7*Math.random());try{i.u=encodeURIComponent(location.host+location.pathname),navigator&&(i.ua=encodeURIComponent(navigator.userAgent))}catch(t){}var s=encodeURIComponent(JSON.stringify(i));l(e,"<img src='"+(t.protocol+t.host)+"/x/px/p/0/"+s+"'/>")}},t.hasAds=function(e){var n;if(!e)try{return Object.keys(t.ads).length>0}catch(e){for(n in t.ads)if(t.ads.hasOwnProperty(n))return!0}for(n in t.ads)if(t.ads.hasOwnProperty(n)&&n.indexOf(e)>0)return!0;return!1},t.getTargeting=function(){var e={},n=0;t.getTokens()&&t.getTokens().length>0?(n=1,e[t.targetingKey]=t.getTokens(),t.amzn_vid&&(e[t.vidKey]=t.amzn_vid)):r||(n=2);try{d.addTimer("gk"),d.set("gks",n)}catch(t){}return e},t.setTargeting=function(e,n){var a;for(a in t.ads)if(t.ads.hasOwnProperty(a)){if(n&&a.indexOf(n)<0)continue;e(a,"1")}},t.setTargetingForGPTAsync=function(e){try{if(e){t.targetingKey=e;var n=t.getTokens();void 0!==n&&n.length>0&&googletag.cmd.push(function(){googletag.pubads().setTargeting(e,n),t.amzn_vid&&googletag.pubads().setTargeting(t.vidKey,t.amzn_vid)})}else{var a;for(a in t.ads)t.ads.hasOwnProperty(a)&&function(){var e=a;googletag.cmd.push(function(){g.debug_mode,googletag.pubads().setTargeting(e,"1"),t.amzn_vid&&googletag.pubads().setTargeting(t.vidKey,t.amzn_vid)})}()}}catch(t){}},t.setTargetingForGPTSync=function(e){try{if(e){t.targetingKey=e;var n=t.getTokens();void 0!==n&&n.length>0&&(googletag.pubads().setTargeting(e,n),t.amzn_vid&&googletag.pubads().setTargeting(t.vidKey,t.amzn_vid))}else{var a;for(a in t.ads)t.ads.hasOwnProperty(a)&&(googletag.pubads().setTargeting(a,"1"),t.amzn_vid&&googletag.pubads().setTargeting(t.vidKey,t.amzn_vid))}}catch(t){}},t.clearTargetingFromGPTAsync=function(){try{googletag&&googletag.pubads()&&googletag.pubads().clearTargeting(t.targetingKey),googletag.pubads().clearTargeting(t.vidKey)}catch(t){}},t.appendTargetingToAdServerUrl=function(e){try{var n;-1===e.indexOf("?")&&(e+="?");for(n in t.ads)t.ads.hasOwnProperty(n)&&(e+="&"+n+"=1")}catch(t){}return e},t.appendTargetingToQueryString=function(e){try{var n;for(n in t.ads)t.ads.hasOwnProperty(n)&&(e+="&"+n+"=1")}catch(t){}return e},t.getTokens=function(e){var n,a=[];try{for(n in t.ads)if(t.ads.hasOwnProperty(n)){if(e&&n.indexOf(e)<0)continue;a.push(n)}}catch(t){}return a},t.getKeys=t.getTokens,t.getVid=function(){return t.amzn_vid},t.doAllTasks=function(){for(;t.tasks.length>0;){var e=t.tasks.shift();t.doTask(e)}},t.doTask=function(t){try{t.call()}catch(t){}},t.tryGetAdsAsync=function(){t.ssb&&t.__ads&&t.updateAds(t.__ads),t.asyncParams&&(t.startTime=t.asyncParams.startTime,t.getAdsCallback(t.asyncParams.id,t.asyncParams.callbackFn,t.asyncParams.timeout,t.asyncParams.size,t.asyncParams.data))},t}(window.amznads||{},document,window);g.tryGetAdsAsync(),window.amzn_ads=function(t){try{g.updateAds(t)}catch(t){}},window.amznads=g,window.aax_write=l,window.amznMatchCookie=p,window.aax_render_ad=function(t){if(t&&t.cmp&&""!=t.cmp&&"undefined"!=t.cmp&&p(t.cmp),t.passback)l(document,t.html);else{var e=t.slotSize;if(e){var n,a=e.indexOf("x"),o=e.substring(0,a),r=e.substring(a+1),i="amznad"+Math.round(1e6*Math.random());l(document,'<iframe id="'+i+'" width="'+o+'" height="'+r+'" src="javascript:\'\'" scrolling="no" frameborder="0" marginwidth="0" marginheight="0" bgcolor="#FFFFFF" topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0"></iframe>');try{var s=(n=document.getElementById(i)).contentWindow||n.contentDocument;s.document&&(s=s.document),l(s,t.html);try{t.iid&&(document.write('<script type="text/javascript" src="'+m.CSM_JS+'"><\/script>'),document.write('<script type="text/javascript">'),document.write('  amzncsm.host="aax.amazon-adsystem.com";\n'),document.write('  amzncsm.rmC(document.getElementById("'+i+'"), "'+t.iid+'", window, document);'),document.write("<\/script>"),document.close())}catch(t){console&&console.log}}catch(t){n&&(n.style.display="none")}}else l(document,t.html)}}},function(t,e,n){t.exports=n(4)}]);
//# sourceMappingURL=amzn_ads.js.map