diff --git a/build/dist/prebid.js b/build/dist/prebid.js index d245942030f..ce34252e889 100644 --- a/build/dist/prebid.js +++ b/build/dist/prebid.js @@ -1,5 +1,5 @@ -/* prebid.js v0.34.1 -Updated : 2017-12-07 */ +/* prebid.js v0.34.9 +Updated : 2018-05-02 */ /******/ (function(modules) { // webpackBootstrap /******/ // install a JSONP callback for chunk loading /******/ var parentJsonpFunction = window["pbjsChunk"]; @@ -36,7 +36,7 @@ Updated : 2017-12-07 */ /******/ /******/ // objects to store loaded and loading chunks /******/ var installedChunks = { -/******/ 122: 0 +/******/ 127: 0 /******/ }; /******/ /******/ // The require function @@ -63,11 +63,6 @@ Updated : 2017-12-07 */ /******/ return module.exports; /******/ } /******/ -/******/ // This file contains only the entry chunk. -/******/ // The chunk loading function for additional chunks -/******/ __webpack_require__.e = function requireEnsure(chunkId) { -/******/ -/******/ }; /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; @@ -105,13 +100,12 @@ Updated : 2017-12-07 */ /******/ __webpack_require__.oe = function(err) { console.error(err); throw err; }; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 339); +/******/ return __webpack_require__(__webpack_require__.s = 393); /******/ }) /************************************************************************/ -/******/ ({ - -/***/ 0: -/***/ (function(module, exports, __webpack_require__) { +/******/ ([ +/* 0 */ +/***/ ((function(module, exports, __webpack_require__) { "use strict"; @@ -152,9 +146,9 @@ exports.getDefinedParams = getDefinedParams; exports.isValidMediaTypes = isValidMediaTypes; exports.unsupportedBidderMessage = unsupportedBidderMessage; -var _config = __webpack_require__(9); +var _config = __webpack_require__(8); -var _justClone = __webpack_require__(46); +var _justClone = __webpack_require__(60); var _justClone2 = _interopRequireDefault(_justClone); @@ -162,7 +156,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'd function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } -var CONSTANTS = __webpack_require__(4); +var CONSTANTS = __webpack_require__(3); var _loggingChecked = false; @@ -985,9 +979,8 @@ function unsupportedBidderMessage(adUnit, unSupportedBidders) { return '\n ' + adUnit.code + ' is a ' + mediaType + ' ad unit\n containing bidders that don\'t support ' + mediaType + ': ' + unSupportedBidders.join(', ') + '.\n ' + plural + ' won\'t fetch demand.\n '; } -/***/ }), - -/***/ 1: +/***/ })), +/* 1 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -997,14 +990,14 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument var _utils = __webpack_require__(0); -var _sizeMapping = __webpack_require__(47); +var _sizeMapping = __webpack_require__(61); var _native = __webpack_require__(15); var _bidderFactory = __webpack_require__(6); var utils = __webpack_require__(0); -var CONSTANTS = __webpack_require__(4); +var CONSTANTS = __webpack_require__(3); var events = __webpack_require__(11); var s2sTestingModule = void 0; // store s2sTesting module if it's loaded @@ -1349,8 +1342,7 @@ exports.setS2STestingModule = function (module) { }; /***/ }), - -/***/ 11: +/* 2 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -1358,580 +1350,672 @@ exports.setS2STestingModule = function (module) { var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; -/** - * events.js - */ -var utils = __webpack_require__(0); -var CONSTANTS = __webpack_require__(4); -var slice = Array.prototype.slice; -var push = Array.prototype.push; +var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; })(); -// define entire events -// var allEvents = ['bidRequested','bidResponse','bidWon','bidTimeout']; -var allEvents = utils._map(CONSTANTS.EVENTS, (function (v) { - return v; -})); +var _utils = __webpack_require__(0); -var idPaths = CONSTANTS.EVENT_ID_PATHS; +var _cpmBucketManager = __webpack_require__(34); -// keep a record of all events fired -var eventsFired = []; +var _native = __webpack_require__(15); -module.exports = (function () { - var _handlers = {}; - var _public = {}; +var _video = __webpack_require__(35); - /** - * - * @param {String} eventString The name of the event. - * @param {Array} args The payload emitted with the event. - * @private - */ - function _dispatch(eventString, args) { - utils.logMessage('Emitting event for: ' + eventString); +var _videoCache = __webpack_require__(62); - var eventPayload = args[0] || {}; - var idPath = idPaths[eventString]; - var key = eventPayload[idPath]; - var event = _handlers[eventString] || { que: [] }; - var eventKeys = utils._map(event, (function (v, k) { - return k; - })); +var _Renderer = __webpack_require__(17); - var callbacks = []; +var _config = __webpack_require__(8); - // record the event: - eventsFired.push({ - eventType: eventString, - args: eventPayload, - id: key - }); +var _hook = __webpack_require__(63); - /** Push each specific callback to the `callbacks` array. - * If the `event` map has a key that matches the value of the - * event payload id path, e.g. `eventPayload[idPath]`, then apply - * each function in the `que` array as an argument to push to the - * `callbacks` array - * */ - if (key && utils.contains(eventKeys, key)) { - push.apply(callbacks, event[key].que); - } +var CONSTANTS = __webpack_require__(3); +var AUCTION_END = CONSTANTS.EVENTS.AUCTION_END; +var utils = __webpack_require__(0); +var events = __webpack_require__(11); - /** Push each general callback to the `callbacks` array. */ - push.apply(callbacks, event.que); +var externalCallbacks = { byAdUnit: [], all: [], oneTime: null, timer: false }; +var defaultBidderSettingsMap = {}; - /** call each of the callbacks */ - utils._each(callbacks, (function (fn) { - if (!fn) return; - try { - fn.apply(null, args); - } catch (e) { - utils.logError('Error executing handler:', 'events.js', e); - } - })); - } +/** + * Returns a list of bidders that we haven't received a response yet + * @return {array} [description] + */ +exports.getTimedOutBidders = function () { + return pbjs._bidsRequested.map(getBidderCode).filter(_utils.uniques).filter((function (bidder) { + return pbjs._bidsReceived.map(getBidders).filter(_utils.uniques).indexOf(bidder) < 0; + })); +}; - function _checkAvailableEvent(event) { - return utils.contains(allEvents, event); - } +function timestamp() { + return new Date().getTime(); +} - _public.on = function (eventString, handler, id) { - // check whether available event or not - if (_checkAvailableEvent(eventString)) { - var event = _handlers[eventString] || { que: [] }; +function getBidderCode(bidSet) { + return bidSet.bidderCode; +} - if (id) { - event[id] = event[id] || { que: [] }; - event[id].que.push(handler); - } else { - event.que.push(handler); - } +function getBidders(bid) { + return bid.bidder; +} - _handlers[eventString] = event; - } else { - utils.logError('Wrong event name : ' + eventString + ' Valid event names :' + allEvents); - } - }; +function bidsBackAdUnit(adUnitCode) { + var _this = this; - _public.emit = function (event) { - var args = slice.call(arguments, 1); - _dispatch(event, args); - }; + var requested = pbjs._bidsRequested.map((function (request) { + return request.bids.filter(_utils.adUnitsFilter.bind(_this, pbjs._adUnitCodes)).filter((function (bid) { + return bid.placementCode === adUnitCode; + })); + })).reduce(_utils.flatten, []).map((function (bid) { + return bid.bidder === 'indexExchange' ? bid.sizes.length : 1; + })).reduce(add, 0); - _public.off = function (eventString, handler, id) { - var event = _handlers[eventString]; + var received = pbjs._bidsReceived.filter((function (bid) { + return bid.adUnitCode === adUnitCode; + })).length; + return requested === received; +} - if (utils.isEmpty(event) || utils.isEmpty(event.que) && utils.isEmpty(event[id])) { - return; - } +function add(a, b) { + return a + b; +} - if (id && (utils.isEmpty(event[id]) || utils.isEmpty(event[id].que))) { - return; - } +function bidsBackAll() { + var requested = pbjs._bidsRequested.map((function (request) { + return request.bids; + })).reduce(_utils.flatten, []).filter(_utils.adUnitsFilter.bind(this, pbjs._adUnitCodes)).map((function (bid) { + return bid.bidder === 'indexExchange' ? bid.sizes.length : 1; + })).reduce((function (a, b) { + return a + b; + }), 0); - if (id) { - utils._each(event[id].que, (function (_handler) { - var que = event[id].que; - if (_handler === handler) { - que.splice(utils.indexOf.call(que, _handler), 1); - } - })); - } else { - utils._each(event.que, (function (_handler) { - var que = event.que; - if (_handler === handler) { - que.splice(utils.indexOf.call(que, _handler), 1); - } - })); - } + var received = pbjs._bidsReceived.filter(_utils.adUnitsFilter.bind(this, pbjs._adUnitCodes)).length; - _handlers[eventString] = event; - }; + return requested === received; +} - _public.get = function () { - return _handlers; - }; +exports.bidsBackAll = function () { + return bidsBackAll(); +}; - /** - * This method can return a copy of all the events fired - * @return {Array} array of events fired - */ - _public.getEvents = function () { - var arrayCopy = []; - utils._each(eventsFired, (function (value) { - var newProp = _extends({}, value); - arrayCopy.push(newProp); - })); +// Validate the arguments sent to us by the adapter. If this returns false, the bid should be totally ignored. +function isValidBid(bid, adUnitCode) { + function errorMessage(msg) { + return 'Invalid bid from ' + bid.bidderCode + '. Ignoring bid: ' + msg; + } - return arrayCopy; - }; + if (!bid) { + utils.logError('Some adapter tried to add an undefined bid for ' + adUnitCode + '.'); + return false; + } + if (!adUnitCode) { + utils.logError(errorMessage('No adUnitCode was supplied to addBidResponse.')); + return false; + } - return _public; -})(); + var bidRequest = (0, _utils.getBidderRequest)(bid.bidderCode, adUnitCode); + if (!bidRequest.start) { + utils.logError(errorMessage('Cannot find valid matching bid request.')); + return false; + } -/***/ }), + if (bid.mediaType === 'native' && !(0, _native.nativeBidIsValid)(bid)) { + utils.logError(errorMessage('Native bid missing some required properties.')); + return false; + } + if (bid.mediaType === 'video' && !(0, _video.isValidVideoBid)(bid)) { + utils.logError(errorMessage('Video bid does not have required vastUrl or renderer property')); + return false; + } + if (bid.mediaType === 'banner' && !validBidSize(bid, adUnitCode)) { + utils.logError(errorMessage('Banner bids require a width and height')); + return false; + } -/***/ 12: -/***/ (function(module, exports, __webpack_require__) { + return true; +} -"use strict"; +// check that the bid has a width and height set +function validBidSize(bid, adUnitCode) { + if ((bid.width || bid.width === 0) && (bid.height || bid.height === 0)) { + return true; + } + var adUnit = (0, _utils.getBidderRequest)(bid.bidderCode, adUnitCode); + var sizes = adUnit && adUnit.bids && adUnit.bids[0] && adUnit.bids[0].sizes; + var parsedSizes = utils.parseSizesInput(sizes); -Object.defineProperty(exports, "__esModule", { - value: true -}); + // if a banner impression has one valid size, we assign that size to any bid + // response that does not explicitly set width or height + if (parsedSizes.length === 1) { + var _parsedSizes$0$split = parsedSizes[0].split('x'), + _parsedSizes$0$split2 = _slicedToArray(_parsedSizes$0$split, 2), + width = _parsedSizes$0$split2[0], + height = _parsedSizes$0$split2[1]; -var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; })(); + bid.width = width; + bid.height = height; + return true; + } -exports.parseQS = parseQS; -exports.formatQS = formatQS; -exports.parse = parse; -exports.format = format; -function parseQS(query) { - return !query ? {} : query.replace(/^\?/, '').split('&').reduce((function (acc, criteria) { - var _criteria$split = criteria.split('='), - _criteria$split2 = _slicedToArray(_criteria$split, 2), - k = _criteria$split2[0], - v = _criteria$split2[1]; - - if (/\[\]$/.test(k)) { - k = k.replace('[]', ''); - acc[k] = acc[k] || []; - acc[k].push(v); - } else { - acc[k] = v || ''; - } - return acc; - }), {}); + return false; } -function formatQS(query) { - return Object.keys(query).map((function (k) { - return Array.isArray(query[k]) ? query[k].map((function (v) { - return k + '[]=' + v; - })).join('&') : k + '=' + query[k]; - })).join('&'); -} +// Postprocess the bids so that all the universal properties exist, no matter which bidder they came from. +// This should be called before addBidToAuction(). +function prepareBidForAuction(bid, adUnitCode) { + var bidRequest = (0, _utils.getBidderRequest)(bid.bidderCode, adUnitCode); -function parse(url, options) { - var parsed = document.createElement('a'); - if (options && 'noDecodeWholeURL' in options && options.noDecodeWholeURL) { - parsed.href = url; - } else { - parsed.href = decodeURIComponent(url); + _extends(bid, { + requestId: bidRequest.requestId, + responseTimestamp: timestamp(), + requestTimestamp: bidRequest.start, + cpm: parseFloat(bid.cpm) || 0, + bidder: bid.bidderCode, + adUnitCode: adUnitCode + }); + + bid.timeToRespond = bid.responseTimestamp - bid.requestTimestamp; + + // Let listeners know that now is the time to adjust the bid, if they want to. + // + // CAREFUL: Publishers rely on certain bid properties to be available (like cpm), + // but others to not be set yet (like priceStrings). See #1372 and #1389. + events.emit(CONSTANTS.EVENTS.BID_ADJUSTMENT, bid); + + // a publisher-defined renderer can be used to render bids + var adUnitRenderer = bidRequest.bids && bidRequest.bids[0] && bidRequest.bids[0].renderer; + + if (adUnitRenderer) { + bid.renderer = _Renderer.Renderer.install({ url: adUnitRenderer.url }); + bid.renderer.setRender(adUnitRenderer.render); } - return { - protocol: (parsed.protocol || '').replace(/:$/, ''), - hostname: parsed.hostname, - port: +parsed.port, - pathname: parsed.pathname.replace(/^(?!\/)/, '/'), - search: parseQS(parsed.search || ''), - hash: (parsed.hash || '').replace(/^#/, ''), - host: parsed.host || window.location.host - }; + + var priceStringsObj = (0, _cpmBucketManager.getPriceBucketString)(bid.cpm, _config.config.getConfig('customPriceBucket'), _config.config.getConfig('currency.granularityMultiplier')); + bid.pbLg = priceStringsObj.low; + bid.pbMg = priceStringsObj.med; + bid.pbHg = priceStringsObj.high; + bid.pbAg = priceStringsObj.auto; + bid.pbDg = priceStringsObj.dense; + bid.pbCg = priceStringsObj.custom; + + // if there is any key value pairs to map do here + var keyValues; + if (bid.bidderCode && (bid.cpm > 0 || bid.dealId)) { + keyValues = getKeyValueTargetingPairs(bid.bidderCode, bid); + } + + // use any targeting provided as defaults, otherwise just set from getKeyValueTargetingPairs + bid.adserverTargeting = _extends(bid.adserverTargeting || {}, keyValues); } -function format(obj) { - return (obj.protocol || 'http') + '://' + (obj.host || obj.hostname + (obj.port ? ':' + obj.port : '')) + (obj.pathname || '') + (obj.search ? '?' + formatQS(obj.search || '') : '') + (obj.hash ? '#' + obj.hash : ''); +function doCallbacksIfNeeded(bid) { + if (bid.timeToRespond > pbjs.cbTimeout + pbjs.timeoutBuffer) { + var timedOut = true; + exports.executeCallback(timedOut); + } } -/***/ }), +// Add a bid to the auction. +function addBidToAuction(bid) { + events.emit(CONSTANTS.EVENTS.BID_RESPONSE, bid); -/***/ 13: -/***/ (function(module, exports, __webpack_require__) { + pbjs._bidsReceived.push(bid); -"use strict"; + if (bid.adUnitCode && bidsBackAdUnit(bid.adUnitCode)) { + triggerAdUnitCallbacks(bid.adUnitCode); + } + if (bidsBackAll()) { + exports.executeCallback(); + } +} -Object.defineProperty(exports, "__esModule", { - value: true -}); -/** - * This file contains the valid Media Types in Prebid. - * - * All adapters are assumed to support banner ads. Other media types are specified by Adapters when they - * register themselves with prebid-core. - */ +// Video bids may fail if the cache is down, or there's trouble on the network. +function tryAddVideoBid(bid) { + if (_config.config.getConfig('usePrebidCache') && !bid.videoCacheKey) { + (0, _videoCache.store)([bid], (function (error, cacheIds) { + if (error) { + utils.logWarn('Failed to save to the video cache: ' + error + '. Video bid must be discarded.'); + } else { + bid.videoCacheKey = cacheIds[0].uuid; + if (!bid.vastUrl) { + bid.vastUrl = (0, _videoCache.getCacheUrl)(bid.videoCacheKey); + } + addBidToAuction(bid); + } + doCallbacksIfNeeded(bid); + })); + } else { + addBidToAuction(bid); + doCallbacksIfNeeded(bid); + } +} -/** - * @typedef {('native'|'video'|'banner')} MediaType +/* + * This function should be called to by the bidder adapter to register a bid response */ +exports.addBidResponse = (0, _hook.createHook)('asyncSeries', (function (adUnitCode, bid) { + if (!isValidBid(bid, adUnitCode)) { + return; + } + prepareBidForAuction(bid, adUnitCode); -/** @type MediaType */ -var NATIVE = exports.NATIVE = 'native'; -/** @type MediaType */ -var VIDEO = exports.VIDEO = 'video'; -/** @type MediaType */ -var BANNER = exports.BANNER = 'banner'; - -/***/ }), + if (bid.mediaType === 'video') { + tryAddVideoBid(bid); + } else { + addBidToAuction(bid); + doCallbacksIfNeeded(bid); + } +})); -/***/ 14: -/***/ (function(module, exports) { +function getKeyValueTargetingPairs(bidderCode, custBidObj) { + var keyValues = {}; + var bidder_settings = pbjs.bidderSettings; -var core = module.exports = { version: '2.5.1' }; -if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef + // 1) set the keys from "standard" setting or from prebid defaults + if (custBidObj && bidder_settings) { + // initialize default if not set + var standardSettings = getStandardBidderSettings(); + setKeys(keyValues, standardSettings, custBidObj); + } + if (bidderCode && custBidObj && bidder_settings && bidder_settings[bidderCode] && bidder_settings[bidderCode][CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING]) { + // 2) set keys from specific bidder setting override if they exist + setKeys(keyValues, bidder_settings[bidderCode], custBidObj); + custBidObj.alwaysUseBid = bidder_settings[bidderCode].alwaysUseBid; + custBidObj.sendStandardTargeting = bidder_settings[bidderCode].sendStandardTargeting; + } else if (defaultBidderSettingsMap[bidderCode]) { + // 2) set keys from standard setting. NOTE: this API doesn't seem to be in use by any Adapter + setKeys(keyValues, defaultBidderSettingsMap[bidderCode], custBidObj); + custBidObj.alwaysUseBid = defaultBidderSettingsMap[bidderCode].alwaysUseBid; + custBidObj.sendStandardTargeting = defaultBidderSettingsMap[bidderCode].sendStandardTargeting; + } -/***/ }), + if (custBidObj['native']) { + keyValues = _extends({}, keyValues, (0, _native.getNativeTargeting)(custBidObj)); + } -/***/ 15: -/***/ (function(module, exports, __webpack_require__) { + return keyValues; +} -"use strict"; +exports.getKeyValueTargetingPairs = function () { + return getKeyValueTargetingPairs.apply(undefined, arguments); +}; +function setKeys(keyValues, bidderSettings, custBidObj) { + var targeting = bidderSettings[CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING]; + custBidObj.size = custBidObj.getSize(); -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.hasNonNativeBidder = exports.nativeBidder = exports.nativeAdUnit = exports.NATIVE_TARGETING_KEYS = exports.NATIVE_KEYS = exports.nativeAdapters = undefined; + utils._each(targeting, (function (kvPair) { + var key = kvPair.key; + var value = kvPair.val; -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + if (keyValues[key]) { + utils.logWarn('The key: ' + key + ' is getting ovewritten'); + } -exports.processNativeAdUnitParams = processNativeAdUnitParams; -exports.nativeBidIsValid = nativeBidIsValid; -exports.fireNativeTrackers = fireNativeTrackers; -exports.getNativeTargeting = getNativeTargeting; + if (utils.isFn(value)) { + try { + value = value(custBidObj); + } catch (e) { + utils.logError('bidmanager', 'ERROR', e); + } + } -var _utils = __webpack_require__(0); + if ((typeof bidderSettings.suppressEmptyKeys !== 'undefined' && bidderSettings.suppressEmptyKeys === true || key === 'hb_deal') && ( // hb_deal is suppressed automatically if not set + utils.isEmptyStr(value) || value === null || value === undefined)) { + utils.logInfo("suppressing empty key '" + key + "' from adserver targeting"); + } else { + keyValues[key] = value; + } + })); -var nativeAdapters = exports.nativeAdapters = []; + return keyValues; +} -var NATIVE_KEYS = exports.NATIVE_KEYS = { - title: 'hb_native_title', - body: 'hb_native_body', - sponsoredBy: 'hb_native_brand', - image: 'hb_native_image', - icon: 'hb_native_icon', - clickUrl: 'hb_native_linkurl', - cta: 'hb_native_cta' +exports.registerDefaultBidderSetting = function (bidderCode, defaultSetting) { + defaultBidderSettingsMap[bidderCode] = defaultSetting; }; -var NATIVE_TARGETING_KEYS = exports.NATIVE_TARGETING_KEYS = Object.keys(NATIVE_KEYS).map((function (key) { - return NATIVE_KEYS[key]; -})); +exports.executeCallback = function (timedOut) { + // if there's still a timeout running, clear it now + if (!timedOut && externalCallbacks.timer) { + clearTimeout(externalCallbacks.timer); + } -var IMAGE = { - image: { required: true }, - title: { required: true }, - sponsoredBy: { required: true }, - clickUrl: { required: true }, - body: { required: false }, - icon: { required: false } -}; + if (externalCallbacks.all.called !== true) { + processCallbacks(externalCallbacks.all); + externalCallbacks.all.called = true; -var SUPPORTED_TYPES = { - image: IMAGE -}; + if (timedOut) { + var timedOutBidders = exports.getTimedOutBidders(); -/** - * Recieves nativeParams from an adUnit. If the params were not of type 'type', - * passes them on directly. If they were of type 'type', translate - * them into the predefined specific asset requests for that type of native ad. - */ -function processNativeAdUnitParams(params) { - if (params && params.type && typeIsSupported(params.type)) { - return SUPPORTED_TYPES[params.type]; + if (timedOutBidders.length) { + events.emit(CONSTANTS.EVENTS.BID_TIMEOUT, timedOutBidders); + } + } } - return params; + // execute one time callback + if (externalCallbacks.oneTime) { + events.emit(AUCTION_END); + try { + processCallbacks([externalCallbacks.oneTime]); + } catch (e) { + utils.logError('Error executing bidsBackHandler', null, e); + } finally { + externalCallbacks.oneTime = null; + externalCallbacks.timer = false; + pbjs.clearAuction(); + } + } +}; + +exports.externalCallbackReset = function () { + externalCallbacks.all.called = false; +}; + +function triggerAdUnitCallbacks(adUnitCode) { + // todo : get bid responses and send in args + var singleAdUnitCode = [adUnitCode]; + processCallbacks(externalCallbacks.byAdUnit, singleAdUnitCode); +} + +function processCallbacks(callbackQueue, singleAdUnitCode) { + var _this2 = this; + + if (utils.isArray(callbackQueue)) { + callbackQueue.forEach((function (callback) { + var adUnitCodes = singleAdUnitCode || pbjs._adUnitCodes; + var bids = [pbjs._bidsReceived.filter(_utils.adUnitsFilter.bind(_this2, adUnitCodes)).reduce(groupByPlacement, {})]; + + callback.apply(pbjs, bids); + })); + } } /** - * Check if the native type specified in the adUnit is supported by Prebid. + * groupByPlacement is a reduce function that converts an array of Bid objects + * to an object with placement codes as keys, with each key representing an object + * with an array of `Bid` objects for that placement + * @returns {*} as { [adUnitCode]: { bids: [Bid, Bid, Bid] } } */ -function typeIsSupported(type) { - if (!(type && Object.keys(SUPPORTED_TYPES).includes(type))) { - (0, _utils.logError)(type + ' nativeParam is not supported'); - return false; +function groupByPlacement(bidsByPlacement, bid) { + if (!bidsByPlacement[bid.adUnitCode]) { + bidsByPlacement[bid.adUnitCode] = { bids: [] }; } - return true; + bidsByPlacement[bid.adUnitCode].bids.push(bid); + + return bidsByPlacement; } /** - * Helper functions for working with native-enabled adUnits - * TODO: abstract this and the video helper functions into general - * adunit validation helper functions + * Add a one time callback, that is discarded after it is called + * @param {Function} callback + * @param timer Timer to clear if callback is triggered before timer time's out */ -var nativeAdUnit = exports.nativeAdUnit = function nativeAdUnit(adUnit) { - var mediaType = adUnit.mediaType === 'native'; - var mediaTypes = (0, _utils.deepAccess)(adUnit, 'mediaTypes.native'); - return mediaType || mediaTypes; -}; -var nativeBidder = exports.nativeBidder = function nativeBidder(bid) { - return nativeAdapters.includes(bid.bidder); -}; -var hasNonNativeBidder = exports.hasNonNativeBidder = function hasNonNativeBidder(adUnit) { - return adUnit.bids.filter((function (bid) { - return !nativeBidder(bid); - })).length; +exports.addOneTimeCallback = function (callback, timer) { + externalCallbacks.oneTime = callback; + externalCallbacks.timer = timer; }; -/* - * Validate that the native assets on this bid contain all assets that were - * marked as required in the adUnit configuration. - */ -function nativeBidIsValid(bid) { - var bidRequest = (0, _utils.getBidRequest)(bid.adId); - if (!bidRequest) { - return false; +exports.addCallback = function (id, callback, cbEvent) { + callback.id = id; + if (CONSTANTS.CB.TYPE.ALL_BIDS_BACK === cbEvent) { + externalCallbacks.all.push(callback); + } else if (CONSTANTS.CB.TYPE.AD_UNIT_BIDS_BACK === cbEvent) { + externalCallbacks.byAdUnit.push(callback); } +}; - // all native bid responses must define a landing page url - if (!(0, _utils.deepAccess)(bid, 'native.clickUrl')) { - return false; - } +// register event for bid adjustment +events.on(CONSTANTS.EVENTS.BID_ADJUSTMENT, (function (bid) { + adjustBids(bid); +})); - var requestedAssets = bidRequest.nativeParams; - if (!requestedAssets) { - return true; +function adjustBids(bid) { + var code = bid.bidderCode; + var bidPriceAdjusted = bid.cpm; + var bidCpmAdjustment = void 0; + if (pbjs.bidderSettings) { + if (code && pbjs.bidderSettings[code] && typeof pbjs.bidderSettings[code].bidCpmAdjustment === 'function') { + bidCpmAdjustment = pbjs.bidderSettings[code].bidCpmAdjustment; + } else if (pbjs.bidderSettings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD] && typeof pbjs.bidderSettings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD].bidCpmAdjustment === 'function') { + bidCpmAdjustment = pbjs.bidderSettings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD].bidCpmAdjustment; + } + if (bidCpmAdjustment) { + try { + bidPriceAdjusted = bidCpmAdjustment(bid.cpm, _extends({}, bid)); + } catch (e) { + utils.logError('Error during bid adjustment', 'bidmanager.js', e); + } + } } - var requiredAssets = Object.keys(requestedAssets).filter((function (key) { - return requestedAssets[key].required; - })); - var returnedAssets = Object.keys(bid['native']).filter((function (key) { - return bid['native'][key]; - })); - - return requiredAssets.every((function (asset) { - return returnedAssets.includes(asset); - })); + if (bidPriceAdjusted >= 0) { + bid.cpm = bidPriceAdjusted; + } } -/* - * Native responses may have associated impression or click trackers. - * This retrieves the appropriate tracker urls for the given ad object and - * fires them. As a native creatives may be in a cross-origin frame, it may be - * necessary to invoke this function via postMessage. secureCreatives is - * configured to fire this function when it receives a `message` of 'Prebid Native' - * and an `adId` with the value of the `bid.adId`. When a message is posted with - * these parameters, impression trackers are fired. To fire click trackers, the - * message should contain an `action` set to 'click'. - * - * // Native creative template example usage - * - * %%PATTERN:hb_native_title%% - * - * - * - */ -function fireNativeTrackers(message, adObject) { - var trackers = void 0; +exports.adjustBids = function () { + return adjustBids.apply(undefined, arguments); +}; - if (message.action === 'click') { - trackers = adObject['native'] && adObject['native'].clickTrackers; - } else { - trackers = adObject['native'] && adObject['native'].impressionTrackers; +function getStandardBidderSettings() { + var granularity = _config.config.getConfig('priceGranularity'); + var bidder_settings = pbjs.bidderSettings; + if (!bidder_settings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD]) { + bidder_settings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD] = {}; + } + if (!bidder_settings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD][CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING]) { + bidder_settings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD][CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING] = [{ + key: 'hb_bidder', + val: function val(bidResponse) { + return bidResponse.bidderCode; + } + }, { + key: 'hb_adid', + val: function val(bidResponse) { + return bidResponse.adId; + } + }, { + key: 'hb_pb', + val: function val(bidResponse) { + if (granularity === CONSTANTS.GRANULARITY_OPTIONS.AUTO) { + return bidResponse.pbAg; + } else if (granularity === CONSTANTS.GRANULARITY_OPTIONS.DENSE) { + return bidResponse.pbDg; + } else if (granularity === CONSTANTS.GRANULARITY_OPTIONS.LOW) { + return bidResponse.pbLg; + } else if (granularity === CONSTANTS.GRANULARITY_OPTIONS.MEDIUM) { + return bidResponse.pbMg; + } else if (granularity === CONSTANTS.GRANULARITY_OPTIONS.HIGH) { + return bidResponse.pbHg; + } else if (granularity === CONSTANTS.GRANULARITY_OPTIONS.CUSTOM) { + return bidResponse.pbCg; + } + } + }, { + key: 'hb_size', + val: function val(bidResponse) { + return bidResponse.size; + } + }, { + key: 'hb_deal', + val: function val(bidResponse) { + return bidResponse.dealId; + } + }]; } + return bidder_settings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD]; +} - (trackers || []).forEach(_utils.triggerPixel); +function getStandardBidderAdServerTargeting() { + return getStandardBidderSettings()[CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING]; } -/** - * Gets native targeting key-value paris - * @param {Object} bid - * @return {Object} targeting - */ -function getNativeTargeting(bid) { - var keyValues = {}; +exports.getStandardBidderAdServerTargeting = getStandardBidderAdServerTargeting; - Object.keys(bid['native']).forEach((function (asset) { - var key = NATIVE_KEYS[asset]; - var value = bid['native'][asset]; +/***/ }), +/* 3 */ +/***/ (function(module, exports) { - // native image-type assets can be a string or an object with a url prop - if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value.url) { - value = value.url; - } +module.exports = {"JSON_MAPPING":{"PL_CODE":"code","PL_SIZE":"sizes","PL_BIDS":"bids","BD_BIDDER":"bidder","BD_ID":"paramsd","BD_PL_ID":"placementId","ADSERVER_TARGETING":"adserverTargeting","BD_SETTING_STANDARD":"standard"},"REPO_AND_VERSION":"prebid_prebid_0.34.9","DEBUG_MODE":"pbjs_debug","STATUS":{"GOOD":1,"NO_BID":2},"CB":{"TYPE":{"ALL_BIDS_BACK":"allRequestedBidsBack","AD_UNIT_BIDS_BACK":"adUnitBidsBack","BID_WON":"bidWon","REQUEST_BIDS":"requestBids"}},"EVENTS":{"AUCTION_INIT":"auctionInit","AUCTION_END":"auctionEnd","BID_ADJUSTMENT":"bidAdjustment","BID_TIMEOUT":"bidTimeout","BID_REQUESTED":"bidRequested","BID_RESPONSE":"bidResponse","BID_WON":"bidWon","SET_TARGETING":"setTargeting","REQUEST_BIDS":"requestBids","ADD_AD_UNITS":"addAdUnits"},"EVENT_ID_PATHS":{"bidWon":"adUnitCode"},"GRANULARITY_OPTIONS":{"LOW":"low","MEDIUM":"medium","HIGH":"high","AUTO":"auto","DENSE":"dense","CUSTOM":"custom"},"TARGETING_KEYS":["hb_bidder","hb_adid","hb_pb","hb_size","hb_deal"],"S2S":{"DEFAULT_ENDPOINT":"https://prebid.adnxs.com/pbs/v1/auction","SRC":"s2s","ADAPTER":"prebidServer","SYNC_ENDPOINT":"https://prebid.adnxs.com/pbs/v1/cookie_sync","SYNCED_BIDDERS_KEY":"pbjsSyncs"}} - if (key) { - keyValues[key] = value; - } - })); +/***/ }), +/* 4 */ +/***/ (function(module, exports, __webpack_require__) { - return keyValues; -} +"use strict"; -/***/ }), -/***/ 16: -/***/ (function(module, exports) { - -// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 -var global = module.exports = typeof window != 'undefined' && window.Math == Math - ? window : typeof self != 'undefined' && self.Math == Math ? self - // eslint-disable-next-line no-new-func - : Function('return this')(); -if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef - - -/***/ }), - -/***/ 17: -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.Renderer = Renderer; - -var _adloader = __webpack_require__(5); - -var _utils = __webpack_require__(0); - -var utils = _interopRequireWildcard(_utils); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } } +var utils = __webpack_require__(0); /** - * @typedef {object} Renderer - * - * A Renderer stores some functions which are used to render a particular Bid. - * These are used in Outstream Video Bids, returned on the Bid by the adapter, and will - * be used to render that bid unless the Publisher overrides them. + Required paramaters + bidderCode, + height, + width, + statusCode + Optional paramaters + adId, + cpm, + ad, + adUrl, + dealId, + priceKeyString; */ +function Bid(statusCode, bidRequest) { + var _bidId = bidRequest && bidRequest.bidId || utils.getUniqueIdentifierStr(); + var _statusCode = statusCode || 0; -function Renderer(options) { - var _this = this; - - var url = options.url, - config = options.config, - id = options.id, - callback = options.callback, - loaded = options.loaded; - - this.url = url; - this.config = config; - this.handlers = {}; - this.id = id; + this.bidderCode = bidRequest && bidRequest.bidder || ''; + this.width = 0; + this.height = 0; + this.statusMessage = _getStatus(); + this.adId = _bidId; + this.mediaType = 'banner'; - // a renderer may push to the command queue to delay rendering until the - // render function is loaded by loadScript, at which point the the command - // queue will be processed - this.loaded = loaded; - this.cmd = []; - this.push = function (func) { - if (typeof func !== 'function') { - utils.logError('Commands given to Renderer.push must be wrapped in a function'); - return; + function _getStatus() { + switch (_statusCode) { + case 0: + return 'Pending'; + case 1: + return 'Bid available'; + case 2: + return 'Bid returned empty or error response'; + case 3: + return 'Bid timed out'; } - _this.loaded ? func.call() : _this.cmd.push(func); - }; + } - // bidders may override this with the `callback` property given to `install` - this.callback = callback || function () { - _this.loaded = true; - _this.process(); + this.getStatusCode = function () { + return _statusCode; }; - // we expect to load a renderer url once only so cache the request to load script - (0, _adloader.loadScript)(url, this.callback, true); + // returns the size of the bid creative. Concatenation of width and height by ‘x’. + this.getSize = function () { + return this.width + 'x' + this.height; + }; } -Renderer.install = function (_ref) { - var url = _ref.url, - config = _ref.config, - id = _ref.id, - callback = _ref.callback, - loaded = _ref.loaded; - - return new Renderer({ url: url, config: config, id: id, callback: callback, loaded: loaded }); +// Bid factory function. +exports.createBid = function (statusCode, bidRequest) { + return new Bid(statusCode, bidRequest); }; -Renderer.prototype.getConfig = function () { - return this.config; -}; +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { -Renderer.prototype.setRender = function (fn) { - this.render = fn; -}; +"use strict"; -Renderer.prototype.setEventHandlers = function (handlers) { - this.handlers = handlers; -}; -Renderer.prototype.handleVideoEvent = function (_ref2) { - var id = _ref2.id, - eventName = _ref2.eventName; +var utils = __webpack_require__(0); +var _requestCache = {}; - if (typeof this.handlers[eventName] === 'function') { - this.handlers[eventName](); +// add a script tag to the page, used to add /jpt call to page +exports.loadScript = function (tagSrc, callback, cacheRequest) { + // var noop = () => {}; + // + // callback = callback || noop; + if (!tagSrc) { + utils.logError('Error attempting to request empty URL', 'adloader.js:loadScript'); + return; } - utils.logMessage('Prebid Renderer event for id ' + id + ' type ' + eventName); -}; + if (cacheRequest) { + if (_requestCache[tagSrc]) { + if (callback && typeof callback === 'function') { + if (_requestCache[tagSrc].loaded) { + // invokeCallbacks immediately + callback(); + } else { + // queue the callback + _requestCache[tagSrc].callbacks.push(callback); + } + } + } else { + _requestCache[tagSrc] = { + loaded: false, + callbacks: [] + }; + if (callback && typeof callback === 'function') { + _requestCache[tagSrc].callbacks.push(callback); + } -/* - * Calls functions that were pushed to the command queue before the - * renderer was loaded by `loadScript` - */ -Renderer.prototype.process = function () { - while (this.cmd.length > 0) { - try { - this.cmd.shift().call(); - } catch (error) { - utils.logError('Error processing Renderer command: ', error); + requestResource(tagSrc, (function () { + _requestCache[tagSrc].loaded = true; + try { + for (var i = 0; i < _requestCache[tagSrc].callbacks.length; i++) { + _requestCache[tagSrc].callbacks[i](); + } + } catch (e) { + utils.logError('Error executing callback', 'adloader.js:loadScript', e); + } + })); } + } else { + // trigger one time request + requestResource(tagSrc, callback); } }; -/***/ }), +function requestResource(tagSrc, callback) { + var jptScript = document.createElement('script'); + jptScript.type = 'text/javascript'; + jptScript.async = true; + + // Execute a callback if necessary + if (callback && typeof callback === 'function') { + if (jptScript.readyState) { + jptScript.onreadystatechange = function () { + if (jptScript.readyState === 'loaded' || jptScript.readyState === 'complete') { + jptScript.onreadystatechange = null; + callback(); + } + }; + } else { + jptScript.onload = function () { + callback(); + }; + } + } + + jptScript.src = tagSrc; + + // add the new script tag to the page + var elToAppend = document.getElementsByTagName('head'); + elToAppend = elToAppend.length ? elToAppend : document.getElementsByTagName('body'); + if (elToAppend.length) { + elToAppend = elToAppend[0]; + elToAppend.insertBefore(jptScript, elToAppend.firstChild); + } +} -/***/ 18: +/***/ }), +/* 6 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -1940,1118 +2024,1118 @@ Renderer.prototype.process = function () { Object.defineProperty(exports, "__esModule", { value: true }); -exports.userSync = undefined; -var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; })(); +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; -exports.newUserSync = newUserSync; +exports.registerBidder = registerBidder; +exports.newBidder = newBidder; -var _utils = __webpack_require__(0); +var _adapter = __webpack_require__(9); -var utils = _interopRequireWildcard(_utils); +var _adapter2 = _interopRequireDefault(_adapter); -var _config = __webpack_require__(9); +var _adaptermanager = __webpack_require__(1); -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } } +var _adaptermanager2 = _interopRequireDefault(_adaptermanager); -// Set userSync default values -_config.config.setDefaults({ - 'userSync': { - syncEnabled: true, - pixelEnabled: true, - syncsPerBidder: 5, - syncDelay: 3000 - } -}); +var _config = __webpack_require__(8); -/** - * Factory function which creates a new UserSyncPool. - * - * @param {UserSyncDependencies} userSyncDependencies Configuration options and dependencies which the - * UserSync object needs in order to behave properly. - */ -function newUserSync(userSyncDependencies) { - var publicApi = {}; - // A queue of user syncs for each adapter - // Let getDefaultQueue() set the defaults - var queue = getDefaultQueue(); +var _ajax = __webpack_require__(7); - // Whether or not user syncs have been trigger on this page load - var hasFired = false; - // How many bids for each adapter - var numAdapterBids = {}; +var _bidmanager = __webpack_require__(2); - // Use what is in config by default - var usConfig = userSyncDependencies.config; - // Update if it's (re)set - _config.config.getConfig('userSync', (function (conf) { - usConfig = _extends(usConfig, conf.userSync); - })); - - /** - * @function getDefaultQueue - * @summary Returns the default empty queue - * @private - * @return {object} A queue with no syncs - */ - function getDefaultQueue() { - return { - image: [], - iframe: [] - }; - } - - /** - * @function fireSyncs - * @summary Trigger all user syncs in the queue - * @private - */ - function fireSyncs() { - if (!usConfig.syncEnabled || !userSyncDependencies.browserSupportsCookies || hasFired) { - return; - } - - try { - // Image pixels - fireImagePixels(); - // Iframe syncs - loadIframes(); - } catch (e) { - return utils.logError('Error firing user syncs', e); - } - // Reset the user sync queue - queue = getDefaultQueue(); - hasFired = true; - } - - /** - * @function fireImagePixels - * @summary Loops through user sync pixels and fires each one - * @private - */ - function fireImagePixels() { - if (!usConfig.pixelEnabled) { - return; - } - // Randomize the order of the pixels before firing - // This is to avoid giving any bidder who has registered multiple syncs - // any preferential treatment and balancing them out - utils.shuffle(queue.image).forEach((function (sync) { - var _sync = _slicedToArray(sync, 2), - bidderName = _sync[0], - trackingPixelUrl = _sync[1]; - - utils.logMessage('Invoking image pixel user sync for bidder: ' + bidderName); - // Create image object and add the src url - utils.triggerPixel(trackingPixelUrl); - })); - } +var _bidmanager2 = _interopRequireDefault(_bidmanager); - /** - * @function loadIframes - * @summary Loops through iframe syncs and loads an iframe element into the page - * @private - */ - function loadIframes() { - if (!usConfig.iframeEnabled) { - return; - } - // Randomize the order of these syncs just like the pixels above - utils.shuffle(queue.iframe).forEach((function (sync) { - var _sync2 = _slicedToArray(sync, 2), - bidderName = _sync2[0], - iframeUrl = _sync2[1]; +var _bidfactory = __webpack_require__(4); - utils.logMessage('Invoking iframe user sync for bidder: ' + bidderName); - // Insert iframe into DOM - utils.insertUserSyncIframe(iframeUrl); - })); - } +var _bidfactory2 = _interopRequireDefault(_bidfactory); - /** - * @function incrementAdapterBids - * @summary Increment the count of user syncs queue for the adapter - * @private - * @params {object} numAdapterBids The object contain counts for all adapters - * @params {string} bidder The name of the bidder adding a sync - * @returns {object} The updated version of numAdapterBids - */ - function incrementAdapterBids(numAdapterBids, bidder) { - if (!numAdapterBids[bidder]) { - numAdapterBids[bidder] = 1; - } else { - numAdapterBids[bidder] += 1; - } - return numAdapterBids; - } +var _constants = __webpack_require__(3); - /** - * @function registerSync - * @summary Add sync for this bidder to a queue to be fired later - * @public - * @params {string} type The type of the sync including image, iframe - * @params {string} bidder The name of the adapter. e.g. "rubicon" - * @params {string} url Either the pixel url or iframe url depending on the type - * @example Using Image Sync - * // registerSync(type, adapter, pixelUrl) - * userSync.registerSync('image', 'rubicon', 'http://example.com/pixel') - */ - publicApi.registerSync = function (type, bidder, url) { - if (!usConfig.syncEnabled || !utils.isArray(queue[type])) { - return utils.logWarn('User sync type "' + type + '" not supported'); - } - if (!bidder) { - return utils.logWarn('Bidder is required for registering sync'); - } - if (Number(numAdapterBids[bidder]) >= usConfig.syncsPerBidder) { - return utils.logWarn('Number of user syncs exceeded for "{$bidder}"'); - } - // All bidders are enabled by default. If specified only register for enabled bidders. - var hasEnabledBidders = usConfig.enabledBidders && usConfig.enabledBidders.length; - if (hasEnabledBidders && usConfig.enabledBidders.indexOf(bidder) < 0) { - return utils.logWarn('Bidder "' + bidder + '" not supported'); - } - queue[type].push([bidder, url]); - numAdapterBids = incrementAdapterBids(numAdapterBids, bidder); - }; +var _userSync = __webpack_require__(18); - /** - * @function syncUsers - * @summary Trigger all the user syncs based on publisher-defined timeout - * @public - * @params {int} timeout The delay in ms before syncing data - default 0 - */ - publicApi.syncUsers = function () { - var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; +var _utils = __webpack_require__(0); - if (timeout) { - return window.setTimeout(fireSyncs, Number(timeout)); - } - fireSyncs(); - }; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - /** - * @function triggerUserSyncs - * @summary A `syncUsers` wrapper for determining if enableOverride has been turned on - * @public - */ - publicApi.triggerUserSyncs = function () { - if (usConfig.enableOverride) { - publicApi.syncUsers(); - } - }; +/** + * This file aims to support Adapters during the Prebid 0.x -> 1.x transition. + * + * Prebid 1.x and Prebid 0.x will be in separate branches--perhaps for a long time. + * This function defines an API for adapter construction which is compatible with both versions. + * Adapters which use it can maintain their code in master, and only this file will need to change + * in the 1.x branch. + * + * Typical usage looks something like: + * + * const adapter = registerBidder({ + * code: 'myBidderCode', + * aliases: ['alias1', 'alias2'], + * supportedMediaTypes: ['video', 'native'], + * isBidRequestValid: function(paramsObject) { return true/false }, + * buildRequests: function(bidRequests, bidderRequest) { return some ServerRequest(s) }, + * interpretResponse: function(oneServerResponse) { return some Bids, or throw an error. } + * }); + * + * @see BidderSpec for the full API and more thorough descriptions. + */ - return publicApi; -} +/** + * @typedef {object} BidderSpec An object containing the adapter-specific functions needed to + * make a Bidder. + * + * @property {string} code A code which will be used to uniquely identify this bidder. This should be the same + * one as is used in the call to registerBidAdapter + * @property {string[]} [aliases] A list of aliases which should also resolve to this bidder. + * @property {MediaType[]} [supportedMediaTypes]: A list of Media Types which the adapter supports. + * @property {function(object): boolean} isBidRequestValid Determines whether or not the given bid has all the params + * needed to make a valid request. + * @property {function(BidRequest[], bidderRequest): ServerRequest|ServerRequest[]} buildRequests Build the request to the Server + * which requests Bids for the given array of Requests. Each BidRequest in the argument array is guaranteed to have + * passed the isBidRequestValid() test. + * @property {function(ServerResponse, BidRequest): Bid[]} interpretResponse Given a successful response from the Server, + * interpret it and return the Bid objects. This function will be run inside a try/catch. + * If it throws any errors, your bids will be discarded. + * @property {function(SyncOptions, ServerResponse[]): UserSync[]} [getUserSyncs] Given an array of all the responses + * from the server, determine which user syncs should occur. The argument array will contain every element + * which has been sent through to interpretResponse. The order of syncs in this array matters. The most + * important ones should come first, since publishers may limit how many are dropped on their page. + */ -var browserSupportsCookies = !utils.isSafariBrowser() && utils.cookiesAreEnabled(); +/** + * @typedef {object} BidRequest + * + * @property {string} bidId A string which uniquely identifies this BidRequest in the current Auction. + * @property {object} params Any bidder-specific params which the publisher used in their bid request. + */ -var userSync = exports.userSync = newUserSync({ - config: _config.config.getConfig('userSync'), - browserSupportsCookies: browserSupportsCookies -}); +/** + * @typedef {object} ServerRequest + * + * @property {('GET'|'POST')} method The type of request which this is. + * @property {string} url The endpoint for the request. For example, "//bids.example.com". + * @property {string|object} data Data to be sent in the request. + * @property {object} options Content-Type set in the header of the bid request, overrides default 'text/plain'. + * If this is a GET request, they'll become query params. If it's a POST request, they'll be added to the body. + * Strings will be added as-is. Objects will be unpacked into query params based on key/value mappings, or + * JSON-serialized into the Request body. + */ /** - * @typedef {Object} UserSyncDependencies + * @typedef {object} ServerResponse * - * @property {UserSyncConfig} config - * @property {boolean} browserSupportsCookies True if the current browser supports cookies, and false otherwise. + * @property {*} body The response body. If this is legal JSON, then it will be parsed. Otherwise it'll be a + * string with the body's content. + * @property {{get: function(string): string} headers The response headers. + * Call this like `ServerResponse.headers.get("Content-Type")` */ /** - * @typedef {Object} UserSyncConfig + * @typedef {object} Bid * - * @property {boolean} enableOverride - * @property {boolean} syncEnabled - * @property {boolean} pixelEnabled - * @property {boolean} iframeEnabled - * @property {int} syncsPerBidder - * @property {string[]} enabledBidders + * @property {string} requestId The specific BidRequest which this bid is aimed at. + * This should match the BidRequest.bidId which this Bid targets. + * @property {string} ad A URL which can be used to load this ad, if it's chosen by the publisher. + * @property {string} currency The currency code for the cpm value + * @property {number} cpm The bid price, in US cents per thousand impressions. + * @property {number} ttl Time-to-live - how long (in seconds) Prebid can use this bid. + * @property {boolean} netRevenue Boolean defining whether the bid is Net or Gross. The default is true (Net). + * @property {number} height The height of the ad, in pixels. + * @property {number} width The width of the ad, in pixels. + * + * @property [Renderer] renderer A Renderer which can be used as a default for this bid, + * if the publisher doesn't override it. This is only relevant for Outstream Video bids. */ -/***/ }), +/** + * @typedef {Object} SyncOptions + * + * An object containing information about usersyncs which the adapter should obey. + * + * @property {boolean} iframeEnabled True if iframe usersyncs are allowed, and false otherwise + * @property {boolean} pixelEnabled True if image usersyncs are allowed, and false otherwise + */ -/***/ 19: -/***/ (function(module, exports, __webpack_require__) { +/** + * TODO: Move this to the UserSync module after that PR is merged. + * + * @typedef {object} UserSync + * + * @property {('image'|'iframe')} type The type of user sync to be done. + * @property {string} url The URL which makes the sync happen. + */ -var global = __webpack_require__(16); -var core = __webpack_require__(14); -var hide = __webpack_require__(22); -var redefine = __webpack_require__(350); -var ctx = __webpack_require__(33); -var PROTOTYPE = 'prototype'; +// common params for all mediaTypes +var COMMON_BID_RESPONSE_KEYS = ['requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency']; -var $export = function (type, name, source) { - var IS_FORCED = type & $export.F; - var IS_GLOBAL = type & $export.G; - var IS_STATIC = type & $export.S; - var IS_PROTO = type & $export.P; - var IS_BIND = type & $export.B; - var target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE]; - var exports = IS_GLOBAL ? core : core[name] || (core[name] = {}); - var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {}); - var key, own, out, exp; - if (IS_GLOBAL) source = name; - for (key in source) { - // contains in native - own = !IS_FORCED && target && target[key] !== undefined; - // export native or passed - out = (own ? target : source)[key]; - // bind timers to global for call from export context - exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; - // extend global - if (target) redefine(target, key, out, type & $export.U); - // export - if (exports[key] != out) hide(exports, key, exp); - if (IS_PROTO && expProto[key] != out) expProto[key] = out; +/** + * Register a bidder with prebid, using the given spec. + * + * If possible, Adapter modules should use this function instead of adaptermanager.registerBidAdapter(). + * + * @param {BidderSpec} spec An object containing the bare-bones functions we need to make a Bidder. + */ +function registerBidder(spec) { + var mediaTypes = Array.isArray(spec.supportedMediaTypes) ? { supportedMediaTypes: spec.supportedMediaTypes } : undefined; + function putBidder(spec) { + var bidder = newBidder(spec); + _adaptermanager2['default'].registerBidAdapter(bidder, spec.code, mediaTypes); } -}; -global.core = core; -// type bitmap -$export.F = 1; // forced -$export.G = 2; // global -$export.S = 4; // static -$export.P = 8; // proto -$export.B = 16; // bind -$export.W = 32; // wrap -$export.U = 64; // safe -$export.R = 128; // real proto method for `library` -module.exports = $export; - - -/***/ }), -/***/ 2: -/***/ (function(module, exports, __webpack_require__) { + putBidder(spec); + if (Array.isArray(spec.aliases)) { + spec.aliases.forEach((function (alias) { + putBidder(_extends({}, spec, { code: alias })); + })); + } +} -"use strict"; +/** + * Make a new bidder from the given spec. This is exported mainly for testing. + * Adapters will probably find it more convenient to use registerBidder instead. + * + * @param {BidderSpec} spec + */ +function newBidder(spec) { + return _extends(new _adapter2['default'](spec.code), { + getSpec: function getSpec() { + return Object.freeze(spec); + }, + registerSyncs: registerSyncs, + callBids: function callBids(bidderRequest) { + if (!Array.isArray(bidderRequest.bids)) { + return; + } + // callBids must add a NO_BID response for _every_ AdUnit code, in order for the auction to + // end properly. This map stores placement codes which we've made _real_ bids on. + // + // As we add _real_ bids to the bidmanager, we'll log the ad unit codes here too. Once all the real + // bids have been added, fillNoBids() can be called to add NO_BID bids for any extra ad units, which + // will end the auction. + // + // In Prebid 1.0, this will be simplified to use the `addBidResponse` and `done` callbacks. + var adUnitCodesHandled = {}; + function addBidWithCode(adUnitCode, bid) { + adUnitCodesHandled[adUnitCode] = true; + addBid(adUnitCode, bid); + } + function fillNoBids() { + bidderRequest.bids.map((function (bidRequest) { + return bidRequest.placementCode; + })).forEach((function (adUnitCode) { + if (adUnitCode && !adUnitCodesHandled[adUnitCode]) { + addBid(adUnitCode, newEmptyBid()); + } + })); + } -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + function addBid(code, bid) { + try { + _bidmanager2['default'].addBidResponse(code, bid); + } catch (err) { + (0, _utils.logError)('Error adding bid', code, err); + } + } -var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; })(); + // After all the responses have come back, fill up the "no bid" bids and + // register any required usersync pixels. + var responses = []; + function afterAllResponses() { + fillNoBids(); + registerSyncs(responses); + } -var _utils = __webpack_require__(0); + var validBidRequests = bidderRequest.bids.filter(filterAndWarn); + if (validBidRequests.length === 0) { + afterAllResponses(); + return; + } + var bidRequestMap = {}; + validBidRequests.forEach((function (bid) { + bidRequestMap[bid.bidId] = bid; + // Delete this once we are 1.0 + if (!bid.adUnitCode) { + bid.adUnitCode = bid.placementCode; + } + })); -var _cpmBucketManager = __webpack_require__(28); + var requests = spec.buildRequests(validBidRequests, bidderRequest); + if (!requests || requests.length === 0) { + afterAllResponses(); + return; + } + if (!Array.isArray(requests)) { + requests = [requests]; + } -var _native = __webpack_require__(15); + // Callbacks don't compose as nicely as Promises. We should call fillNoBids() once _all_ the + // Server requests have returned and been processed. Since `ajax` accepts a single callback, + // we need to rig up a function which only executes after all the requests have been responded. + var onResponse = (0, _utils.delayExecution)(afterAllResponses, requests.length); + requests.forEach(processRequest); -var _video = __webpack_require__(29); + function formatGetParameters(data) { + if (data) { + return '?' + ((typeof data === 'undefined' ? 'undefined' : _typeof(data)) === 'object' ? (0, _utils.parseQueryStringParameters)(data) : data); + } -var _videoCache = __webpack_require__(48); + return ''; + } -var _Renderer = __webpack_require__(17); + function processRequest(request) { + switch (request.method) { + case 'GET': + (0, _ajax.ajax)('' + request.url + formatGetParameters(request.data), { + success: onSuccess, + error: onFailure + }, undefined, _extends({ + method: 'GET', + withCredentials: true + }, request.options)); + break; + case 'POST': + (0, _ajax.ajax)(request.url, { + success: onSuccess, + error: onFailure + }, typeof request.data === 'string' ? request.data : JSON.stringify(request.data), _extends({ + method: 'POST', + contentType: 'text/plain', + withCredentials: true + }, request.options)); + break; + default: + (0, _utils.logWarn)('Skipping invalid request from ' + spec.code + '. Request type ' + request.type + ' must be GET or POST'); + onResponse(); + } -var _config = __webpack_require__(9); + // If the server responds successfully, use the adapter code to unpack the Bids from it. + // If the adapter code fails, no bids should be added. After all the bids have been added, make + // sure to call the `onResponse` function so that we're one step closer to calling fillNoBids(). + function onSuccess(response, responseObj) { + try { + response = JSON.parse(response); + } catch (e) {} /* response might not be JSON... that's ok. */ -var _hook = __webpack_require__(49); + // Make response headers available for #1742. These are lazy-loaded because most adapters won't need them. + response = { + body: response, + headers: headerParser(responseObj) + }; + responses.push(response); -var CONSTANTS = __webpack_require__(4); -var AUCTION_END = CONSTANTS.EVENTS.AUCTION_END; -var utils = __webpack_require__(0); -var events = __webpack_require__(11); + var bids = void 0; + try { + bids = spec.interpretResponse(response, request); + } catch (err) { + (0, _utils.logError)('Bidder ' + spec.code + ' failed to interpret the server\'s response. Continuing without bids', null, err); + onResponse(); + return; + } -var externalCallbacks = { byAdUnit: [], all: [], oneTime: null, timer: false }; -var defaultBidderSettingsMap = {}; + if (bids) { + if (bids.forEach) { + bids.forEach(addBidUsingRequestMap); + } else { + addBidUsingRequestMap(bids); + } + } + onResponse(); -/** - * Returns a list of bidders that we haven't received a response yet - * @return {array} [description] - */ -exports.getTimedOutBidders = function () { - return pbjs._bidsRequested.map(getBidderCode).filter(_utils.uniques).filter((function (bidder) { - return pbjs._bidsReceived.map(getBidders).filter(_utils.uniques).indexOf(bidder) < 0; - })); -}; + function addBidUsingRequestMap(bid) { + // In Prebid 1.0 all the validation logic from bidmanager will move here, as of now we are only validating new params so that adapters dont miss adding them. + if (hasValidKeys(bid)) { + var bidRequest = bidRequestMap[bid.requestId]; + if (bidRequest) { + var prebidBid = _extends(_bidfactory2['default'].createBid(_constants.STATUS.GOOD, bidRequest), bid); + addBidWithCode(bidRequest.placementCode, prebidBid); + } else { + (0, _utils.logWarn)('Bidder ' + spec.code + ' made bid for unknown request ID: ' + bid.requestId + '. Ignoring.'); + } + } else { + (0, _utils.logError)('Bidder ' + spec.code + ' is missing required params. Check http://prebid.org/dev-docs/bidder-adapter-1.html for list of params.'); + } + } -function timestamp() { - return new Date().getTime(); -} + function headerParser(xmlHttpResponse) { + return { + get: responseObj.getResponseHeader.bind(responseObj) + }; + } + } -function getBidderCode(bidSet) { - return bidSet.bidderCode; -} + // If the server responds with an error, there's not much we can do. Log it, and make sure to + // call onResponse() so that we're one step closer to calling fillNoBids(). + function onFailure(err) { + (0, _utils.logError)('Server call for ' + spec.code + ' failed: ' + err + '. Continuing without bids.'); + onResponse(); + } + } + } + }); -function getBidders(bid) { - return bid.bidder; -} + function registerSyncs(responses) { + if (spec.getUserSyncs) { + var syncs = spec.getUserSyncs({ + iframeEnabled: _config.config.getConfig('userSync.iframeEnabled'), + pixelEnabled: _config.config.getConfig('userSync.pixelEnabled') + }, responses); + if (syncs) { + if (!Array.isArray(syncs)) { + syncs = [syncs]; + } + syncs.forEach((function (sync) { + _userSync.userSync.registerSync(sync.type, spec.code, sync.url); + })); + } + } + } -function bidsBackAdUnit(adUnitCode) { - var _this = this; + function filterAndWarn(bid) { + if (!spec.isBidRequestValid(bid)) { + (0, _utils.logWarn)('Invalid bid sent to bidder ' + spec.code + ': ' + JSON.stringify(bid)); + return false; + } + return true; + } - var requested = pbjs._bidsRequested.map((function (request) { - return request.bids.filter(_utils.adUnitsFilter.bind(_this, pbjs._adUnitCodes)).filter((function (bid) { - return bid.placementCode === adUnitCode; + function hasValidKeys(bid) { + var bidKeys = Object.keys(bid); + return COMMON_BID_RESPONSE_KEYS.every((function (key) { + return bidKeys.includes(key); })); - })).reduce(_utils.flatten, []).map((function (bid) { - return bid.bidder === 'indexExchange' ? bid.sizes.length : 1; - })).reduce(add, 0); + } - var received = pbjs._bidsReceived.filter((function (bid) { - return bid.adUnitCode === adUnitCode; - })).length; - return requested === received; + function newEmptyBid() { + var bid = _bidfactory2['default'].createBid(_constants.STATUS.NO_BID); + bid.code = spec.code; + bid.bidderCode = spec.code; + return bid; + } } -function add(a, b) { - return a + b; -} +/***/ }), +/* 7 */ +/***/ (function(module, exports, __webpack_require__) { -function bidsBackAll() { - var requested = pbjs._bidsRequested.map((function (request) { - return request.bids; - })).reduce(_utils.flatten, []).filter(_utils.adUnitsFilter.bind(this, pbjs._adUnitCodes)).map((function (bid) { - return bid.bidder === 'indexExchange' ? bid.sizes.length : 1; - })).reduce((function (a, b) { - return a + b; - }), 0); +"use strict"; - var received = pbjs._bidsReceived.filter(_utils.adUnitsFilter.bind(this, pbjs._adUnitCodes)).length; - return requested === received; -} +Object.defineProperty(exports, "__esModule", { + value: true +}); -exports.bidsBackAll = function () { - return bidsBackAll(); -}; +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; -// Validate the arguments sent to us by the adapter. If this returns false, the bid should be totally ignored. -function isValidBid(bid, adUnitCode) { - function errorMessage(msg) { - return 'Invalid bid from ' + bid.bidderCode + '. Ignoring bid: ' + msg; - } +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - if (!bid) { - utils.logError('Some adapter tried to add an undefined bid for ' + adUnitCode + '.'); - return false; - } - if (!adUnitCode) { - utils.logError(errorMessage('No adUnitCode was supplied to addBidResponse.')); - return false; - } +exports.setAjaxTimeout = setAjaxTimeout; +exports.ajax = ajax; - var bidRequest = (0, _utils.getBidderRequest)(bid.bidderCode, adUnitCode); - if (!bidRequest.start) { - utils.logError(errorMessage('Cannot find valid matching bid request.')); - return false; - } +var _url = __webpack_require__(13); - if (bid.mediaType === 'native' && !(0, _native.nativeBidIsValid)(bid)) { - utils.logError(errorMessage('Native bid missing some required properties.')); - return false; - } - if (bid.mediaType === 'video' && !(0, _video.isValidVideoBid)(bid)) { - utils.logError(errorMessage('Video bid does not have required vastUrl or renderer property')); - return false; - } - if (bid.mediaType === 'banner' && !validBidSize(bid, adUnitCode)) { - utils.logError(errorMessage('Banner bids require a width and height')); - return false; - } +var utils = __webpack_require__(0); - return true; -} +var XHR_DONE = 4; +var _timeout = 3000; -// check that the bid has a width and height set -function validBidSize(bid, adUnitCode) { - if ((bid.width || bid.width === 0) && (bid.height || bid.height === 0)) { - return true; - } +/** + * Simple IE9+ and cross-browser ajax request function + * Note: x-domain requests in IE9 do not support the use of cookies + * + * @param url string url + * @param callback {object | function} callback + * @param data mixed data + * @param options object + */ +function setAjaxTimeout(timeout) { + _timeout = timeout; +} - var adUnit = (0, _utils.getBidderRequest)(bid.bidderCode, adUnitCode); - var sizes = adUnit && adUnit.bids && adUnit.bids[0] && adUnit.bids[0].sizes; - var parsedSizes = utils.parseSizesInput(sizes); +function ajax(url, callback, data) { + var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; - // if a banner impression has one valid size, we assign that size to any bid - // response that does not explicitly set width or height - if (parsedSizes.length === 1) { - var _parsedSizes$0$split = parsedSizes[0].split('x'), - _parsedSizes$0$split2 = _slicedToArray(_parsedSizes$0$split, 2), - width = _parsedSizes$0$split2[0], - height = _parsedSizes$0$split2[1]; + try { + var x = void 0; + var useXDomainRequest = false; + var method = options.method || (data ? 'POST' : 'GET'); - bid.width = width; - bid.height = height; - return true; - } + var callbacks = (typeof callback === 'undefined' ? 'undefined' : _typeof(callback)) === 'object' ? callback : { + success: function success() { + utils.logMessage('xhr success'); + }, + error: function error(e) { + utils.logError('xhr error', null, e); + } + }; - return false; -} + if (typeof callback === 'function') { + callbacks.success = callback; + } -// Postprocess the bids so that all the universal properties exist, no matter which bidder they came from. -// This should be called before addBidToAuction(). -function prepareBidForAuction(bid, adUnitCode) { - var bidRequest = (0, _utils.getBidderRequest)(bid.bidderCode, adUnitCode); + if (!window.XMLHttpRequest) { + useXDomainRequest = true; + } else { + x = new window.XMLHttpRequest(); + if (x.responseType === undefined) { + useXDomainRequest = true; + } + } - _extends(bid, { - requestId: bidRequest.requestId, - responseTimestamp: timestamp(), - requestTimestamp: bidRequest.start, - cpm: parseFloat(bid.cpm) || 0, - bidder: bid.bidderCode, - adUnitCode: adUnitCode - }); + if (useXDomainRequest) { + x = new window.XDomainRequest(); + x.onload = function () { + callbacks.success(x.responseText, x); + }; - bid.timeToRespond = bid.responseTimestamp - bid.requestTimestamp; + // http://stackoverflow.com/questions/15786966/xdomainrequest-aborts-post-on-ie-9 + x.onerror = function () { + callbacks.error('error', x); + }; + x.ontimeout = function () { + callbacks.error('timeout', x); + }; + x.onprogress = function () { + utils.logMessage('xhr onprogress'); + }; + } else { + x.onreadystatechange = function () { + if (x.readyState === XHR_DONE) { + var status = x.status; + if (status >= 200 && status < 300 || status === 304) { + callbacks.success(x.responseText, x); + } else { + callbacks.error(x.statusText, x); + } + } + }; + } - // Let listeners know that now is the time to adjust the bid, if they want to. - // - // CAREFUL: Publishers rely on certain bid properties to be available (like cpm), - // but others to not be set yet (like priceStrings). See #1372 and #1389. - events.emit(CONSTANTS.EVENTS.BID_ADJUSTMENT, bid); + if (method === 'GET' && data) { + var urlInfo = (0, _url.parse)(url, options); + _extends(urlInfo.search, data); + url = (0, _url.format)(urlInfo); + } - // a publisher-defined renderer can be used to render bids - var adUnitRenderer = bidRequest.bids && bidRequest.bids[0] && bidRequest.bids[0].renderer; + x.open(method, url); + // IE needs timoeut to be set after open - see #1410 + x.timeout = _timeout; - if (adUnitRenderer) { - bid.renderer = _Renderer.Renderer.install({ url: adUnitRenderer.url }); - bid.renderer.setRender(adUnitRenderer.render); + if (!useXDomainRequest) { + if (options.withCredentials) { + x.withCredentials = true; + } + utils._each(options.customHeaders, (function (value, header) { + x.setRequestHeader(header, value); + })); + if (options.preflight) { + x.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); + } + x.setRequestHeader('Content-Type', options.contentType || 'text/plain'); + } + x.send(method === 'POST' && data); + } catch (error) { + utils.logError('xhr construction', error); } +} - var priceStringsObj = (0, _cpmBucketManager.getPriceBucketString)(bid.cpm, _config.config.getConfig('customPriceBucket'), _config.config.getConfig('currency.granularityMultiplier')); - bid.pbLg = priceStringsObj.low; - bid.pbMg = priceStringsObj.med; - bid.pbHg = priceStringsObj.high; - bid.pbAg = priceStringsObj.auto; - bid.pbDg = priceStringsObj.dense; - bid.pbCg = priceStringsObj.custom; - - // if there is any key value pairs to map do here - var keyValues; - if (bid.bidderCode && (bid.cpm > 0 || bid.dealId)) { - keyValues = getKeyValueTargetingPairs(bid.bidderCode, bid); - } - - // use any targeting provided as defaults, otherwise just set from getKeyValueTargetingPairs - bid.adserverTargeting = _extends(bid.adserverTargeting || {}, keyValues); -} - -function doCallbacksIfNeeded(bid) { - if (bid.timeToRespond > pbjs.cbTimeout + pbjs.timeoutBuffer) { - var timedOut = true; - exports.executeCallback(timedOut); - } -} - -// Add a bid to the auction. -function addBidToAuction(bid) { - events.emit(CONSTANTS.EVENTS.BID_RESPONSE, bid); +/***/ }), +/* 8 */ +/***/ (function(module, exports, __webpack_require__) { - pbjs._bidsReceived.push(bid); +"use strict"; - if (bid.adUnitCode && bidsBackAdUnit(bid.adUnitCode)) { - triggerAdUnitCallbacks(bid.adUnitCode); - } - if (bidsBackAll()) { - exports.executeCallback(); - } -} +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.config = undefined; -// Video bids may fail if the cache is down, or there's trouble on the network. -function tryAddVideoBid(bid) { - if (_config.config.getConfig('usePrebidCache')) { - (0, _videoCache.store)([bid], (function (error, cacheIds) { - if (error) { - utils.logWarn('Failed to save to the video cache: ' + error + '. Video bid must be discarded.'); - } else { - bid.videoCacheKey = cacheIds[0].uuid; - if (!bid.vastUrl) { - bid.vastUrl = (0, _videoCache.getCacheUrl)(bid.videoCacheKey); - } - addBidToAuction(bid); - } - doCallbacksIfNeeded(bid); - })); - } else { - addBidToAuction(bid); - doCallbacksIfNeeded(bid); - } -} +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; -/* - * This function should be called to by the bidder adapter to register a bid response - */ -exports.addBidResponse = (0, _hook.createHook)('asyncSeries', (function (adUnitCode, bid) { - if (!isValidBid(bid, adUnitCode)) { - return; - } - prepareBidForAuction(bid, adUnitCode); +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /* + * Module for getting and setting Prebid configuration. + * + * Prebid previously defined these properties directly on the global object: + * pbjs.logging = true; + * + * Defining and access properties in this way is now deprecated, but these will + * continue to work during a deprecation window. + */ - if (bid.mediaType === 'video') { - tryAddVideoBid(bid); - } else { - addBidToAuction(bid); - doCallbacksIfNeeded(bid); - } -})); -function getKeyValueTargetingPairs(bidderCode, custBidObj) { - var keyValues = {}; - var bidder_settings = pbjs.bidderSettings; +exports.newConfig = newConfig; - // 1) set the keys from "standard" setting or from prebid defaults - if (custBidObj && bidder_settings) { - // initialize default if not set - var standardSettings = getStandardBidderSettings(); - setKeys(keyValues, standardSettings, custBidObj); - } +var _cpmBucketManager = __webpack_require__(34); - if (bidderCode && custBidObj && bidder_settings && bidder_settings[bidderCode] && bidder_settings[bidderCode][CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING]) { - // 2) set keys from specific bidder setting override if they exist - setKeys(keyValues, bidder_settings[bidderCode], custBidObj); - custBidObj.alwaysUseBid = bidder_settings[bidderCode].alwaysUseBid; - custBidObj.sendStandardTargeting = bidder_settings[bidderCode].sendStandardTargeting; - } else if (defaultBidderSettingsMap[bidderCode]) { - // 2) set keys from standard setting. NOTE: this API doesn't seem to be in use by any Adapter - setKeys(keyValues, defaultBidderSettingsMap[bidderCode], custBidObj); - custBidObj.alwaysUseBid = defaultBidderSettingsMap[bidderCode].alwaysUseBid; - custBidObj.sendStandardTargeting = defaultBidderSettingsMap[bidderCode].sendStandardTargeting; - } +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } - if (custBidObj['native']) { - keyValues = _extends({}, keyValues, (0, _native.getNativeTargeting)(custBidObj)); - } +var utils = __webpack_require__(0); - return keyValues; -} +var DEFAULT_DEBUG = false; +var DEFAULT_BIDDER_TIMEOUT = 3000; +var DEFAULT_PUBLISHER_DOMAIN = window.location.origin; +var DEFAULT_COOKIESYNC_DELAY = 100; +var DEFAULT_ENABLE_SEND_ALL_BIDS = false; -exports.getKeyValueTargetingPairs = function () { - return getKeyValueTargetingPairs.apply(undefined, arguments); +var GRANULARITY_OPTIONS = { + LOW: 'low', + MEDIUM: 'medium', + HIGH: 'high', + AUTO: 'auto', + DENSE: 'dense', + CUSTOM: 'custom' }; -function setKeys(keyValues, bidderSettings, custBidObj) { - var targeting = bidderSettings[CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING]; - custBidObj.size = custBidObj.getSize(); +var ALL_TOPICS = '*'; - utils._each(targeting, (function (kvPair) { - var key = kvPair.key; - var value = kvPair.val; +/** + * @typedef {object} PrebidConfig + * + * @property {bool} usePrebidCache True if we should use prebid-cache to store video bids before adding + * bids to the auction, and false otherwise. **NOTE** This must be true if you want to use the + * dfpAdServerVideo module. + */ - if (keyValues[key]) { - utils.logWarn('The key: ' + key + ' is getting ovewritten'); - } +function newConfig() { + var listeners = []; - if (utils.isFn(value)) { - try { - value = value(custBidObj); - } catch (e) { - utils.logError('bidmanager', 'ERROR', e); + var defaults = {}; + + var config = { + // `debug` is equivalent to legacy `pbjs.logging` property + _debug: DEFAULT_DEBUG, + get debug() { + if (pbjs.logging || pbjs.logging === false) { + return pbjs.logging; } - } + return this._debug; + }, + set debug(val) { + this._debug = val; + }, - if ((typeof bidderSettings.suppressEmptyKeys !== 'undefined' && bidderSettings.suppressEmptyKeys === true || key === 'hb_deal') && ( // hb_deal is suppressed automatically if not set - utils.isEmptyStr(value) || value === null || value === undefined)) { - utils.logInfo("suppressing empty key '" + key + "' from adserver targeting"); - } else { - keyValues[key] = value; - } - })); + // default timeout for all bids + _bidderTimeout: DEFAULT_BIDDER_TIMEOUT, + get bidderTimeout() { + return pbjs.bidderTimeout || this._bidderTimeout; + }, + set bidderTimeout(val) { + this._bidderTimeout = val; + }, - return keyValues; -} + // domain where prebid is running for cross domain iframe communication + _publisherDomain: DEFAULT_PUBLISHER_DOMAIN, + get publisherDomain() { + return pbjs.publisherDomain || this._publisherDomain; + }, + set publisherDomain(val) { + this._publisherDomain = val; + }, -exports.registerDefaultBidderSetting = function (bidderCode, defaultSetting) { - defaultBidderSettingsMap[bidderCode] = defaultSetting; -}; + // delay to request cookie sync to stay out of critical path + _cookieSyncDelay: DEFAULT_COOKIESYNC_DELAY, + get cookieSyncDelay() { + return pbjs.cookieSyncDelay || this._cookieSyncDelay; + }, + set cookieSyncDelay(val) { + this._cookieSyncDelay = val; + }, -exports.executeCallback = function (timedOut) { - // if there's still a timeout running, clear it now - if (!timedOut && externalCallbacks.timer) { - clearTimeout(externalCallbacks.timer); - } + // calls existing function which may be moved after deprecation + _priceGranularity: GRANULARITY_OPTIONS.MEDIUM, + set priceGranularity(val) { + if (validatePriceGranularity(val)) { + if (typeof val === 'string') { + this._priceGranularity = hasGranularity(val) ? val : GRANULARITY_OPTIONS.MEDIUM; + } else if ((typeof val === 'undefined' ? 'undefined' : _typeof(val)) === 'object') { + this._customPriceBucket = val; + this._priceGranularity = GRANULARITY_OPTIONS.CUSTOM; + utils.logMessage('Using custom price granularity'); + } + } + }, + get priceGranularity() { + return this._priceGranularity; + }, - if (externalCallbacks.all.called !== true) { - processCallbacks(externalCallbacks.all); - externalCallbacks.all.called = true; + _customPriceBucket: {}, + get customPriceBucket() { + return this._customPriceBucket; + }, - if (timedOut) { - var timedOutBidders = exports.getTimedOutBidders(); + _sendAllBids: DEFAULT_ENABLE_SEND_ALL_BIDS, + get enableSendAllBids() { + return this._sendAllBids; + }, + set enableSendAllBids(val) { + this._sendAllBids = val; + }, - if (timedOutBidders.length) { - events.emit(CONSTANTS.EVENTS.BID_TIMEOUT, timedOutBidders); - } + // calls existing function which may be moved after deprecation + set bidderSequence(val) { + pbjs.setBidderSequence(val); + }, + + // calls existing function which may be moved after deprecation + set s2sConfig(val) { + pbjs.setS2SConfig(val); } + }; + + function hasGranularity(val) { + return Object.keys(GRANULARITY_OPTIONS).find((function (option) { + return val === GRANULARITY_OPTIONS[option]; + })); } - // execute one time callback - if (externalCallbacks.oneTime) { - events.emit(AUCTION_END); - try { - processCallbacks([externalCallbacks.oneTime]); - } catch (e) { - utils.logError('Error executing bidsBackHandler', null, e); - } finally { - externalCallbacks.oneTime = null; - externalCallbacks.timer = false; - pbjs.clearAuction(); + function validatePriceGranularity(val) { + if (!val) { + utils.logError('Prebid Error: no value passed to `setPriceGranularity()`'); + return false; + } + if (typeof val === 'string') { + if (!hasGranularity(val)) { + utils.logWarn('Prebid Warning: setPriceGranularity was called with invalid setting, using `medium` as default.'); + } + } else if ((typeof val === 'undefined' ? 'undefined' : _typeof(val)) === 'object') { + if (!(0, _cpmBucketManager.isValidPriceConfig)(val)) { + utils.logError('Invalid custom price value passed to `setPriceGranularity()`'); + return false; + } } + return true; } -}; -exports.externalCallbackReset = function () { - externalCallbacks.all.called = false; -}; + /* + * Returns configuration object if called without parameters, + * or single configuration property if given a string matching a configuration + * property name. Allows deep access e.g. getConfig('currency.adServerCurrency') + * + * If called with callback parameter, or a string and a callback parameter, + * subscribes to configuration updates. See `subscribe` function for usage. + */ + function getConfig() { + if (arguments.length <= 1 && typeof (arguments.length <= 0 ? undefined : arguments[0]) !== 'function') { + var option = arguments.length <= 0 ? undefined : arguments[0]; + return option ? utils.deepAccess(config, option) : config; + } -function triggerAdUnitCallbacks(adUnitCode) { - // todo : get bid responses and send in args - var singleAdUnitCode = [adUnitCode]; - processCallbacks(externalCallbacks.byAdUnit, singleAdUnitCode); -} + return subscribe.apply(undefined, arguments); + } -function processCallbacks(callbackQueue, singleAdUnitCode) { - var _this2 = this; + /* + * Sets configuration given an object containing key-value pairs and calls + * listeners that were added by the `subscribe` function + */ + function setConfig(options) { + if ((typeof options === 'undefined' ? 'undefined' : _typeof(options)) !== 'object') { + utils.logError('setConfig options must be an object'); + return; + } - if (utils.isArray(callbackQueue)) { - callbackQueue.forEach((function (callback) { - var adUnitCodes = singleAdUnitCode || pbjs._adUnitCodes; - var bids = [pbjs._bidsReceived.filter(_utils.adUnitsFilter.bind(_this2, adUnitCodes)).reduce(groupByPlacement, {})]; + var topics = Object.keys(options); + var topicalConfig = {}; - callback.apply(pbjs, bids); - })); - } -} + topics.forEach((function (topic) { + var option = options[topic]; -/** - * groupByPlacement is a reduce function that converts an array of Bid objects - * to an object with placement codes as keys, with each key representing an object - * with an array of `Bid` objects for that placement - * @returns {*} as { [adUnitCode]: { bids: [Bid, Bid, Bid] } } - */ -function groupByPlacement(bidsByPlacement, bid) { - if (!bidsByPlacement[bid.adUnitCode]) { - bidsByPlacement[bid.adUnitCode] = { bids: [] }; - } + if (_typeof(defaults[topic]) === 'object' && (typeof option === 'undefined' ? 'undefined' : _typeof(option)) === 'object') { + option = _extends({}, defaults[topic], option); + } - bidsByPlacement[bid.adUnitCode].bids.push(bid); + topicalConfig[topic] = config[topic] = option; + })); - return bidsByPlacement; -} + callSubscribers(topicalConfig); + } -/** - * Add a one time callback, that is discarded after it is called - * @param {Function} callback - * @param timer Timer to clear if callback is triggered before timer time's out - */ -exports.addOneTimeCallback = function (callback, timer) { - externalCallbacks.oneTime = callback; - externalCallbacks.timer = timer; -}; + /** + * Sets configuration defaults which setConfig values can be applied on top of + * @param {object} options + */ + function setDefaults(options) { + if ((typeof defaults === 'undefined' ? 'undefined' : _typeof(defaults)) !== 'object') { + utils.logError('defaults must be an object'); + return; + } -exports.addCallback = function (id, callback, cbEvent) { - callback.id = id; - if (CONSTANTS.CB.TYPE.ALL_BIDS_BACK === cbEvent) { - externalCallbacks.all.push(callback); - } else if (CONSTANTS.CB.TYPE.AD_UNIT_BIDS_BACK === cbEvent) { - externalCallbacks.byAdUnit.push(callback); + _extends(defaults, options); + // Add default values to config as well + _extends(config, options); } -}; -// register event for bid adjustment -events.on(CONSTANTS.EVENTS.BID_ADJUSTMENT, (function (bid) { - adjustBids(bid); -})); + /* + * Adds a function to a set of listeners that are invoked whenever `setConfig` + * is called. The subscribed function will be passed the options object that + * was used in the `setConfig` call. Topics can be subscribed to to only get + * updates when specific properties are updated by passing a topic string as + * the first parameter. + * + * Returns an `unsubscribe` function for removing the subscriber from the + * set of listeners + * + * Example use: + * // subscribe to all configuration changes + * subscribe((config) => console.log('config set:', config)); + * + * // subscribe to only 'logging' changes + * subscribe('logging', (config) => console.log('logging set:', config)); + * + * // unsubscribe + * const unsubscribe = subscribe(...); + * unsubscribe(); // no longer listening + */ + function subscribe(topic, listener) { + var callback = listener; -function adjustBids(bid) { - var code = bid.bidderCode; - var bidPriceAdjusted = bid.cpm; - var bidCpmAdjustment = void 0; - if (pbjs.bidderSettings) { - if (code && pbjs.bidderSettings[code] && typeof pbjs.bidderSettings[code].bidCpmAdjustment === 'function') { - bidCpmAdjustment = pbjs.bidderSettings[code].bidCpmAdjustment; - } else if (pbjs.bidderSettings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD] && typeof pbjs.bidderSettings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD].bidCpmAdjustment === 'function') { - bidCpmAdjustment = pbjs.bidderSettings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD].bidCpmAdjustment; + if (typeof topic !== 'string') { + // first param should be callback function in this case, + // meaning it gets called for any config change + callback = topic; + topic = ALL_TOPICS; } - if (bidCpmAdjustment) { - try { - bidPriceAdjusted = bidCpmAdjustment(bid.cpm, _extends({}, bid)); - } catch (e) { - utils.logError('Error during bid adjustment', 'bidmanager.js', e); - } + + if (typeof callback !== 'function') { + utils.logError('listener must be a function'); + return; } - } - if (bidPriceAdjusted >= 0) { - bid.cpm = bidPriceAdjusted; + listeners.push({ topic: topic, callback: callback }); + + // save and call this function to remove the listener + return function unsubscribe() { + listeners.splice(listeners.indexOf(listener), 1); + }; } -} -exports.adjustBids = function () { - return adjustBids.apply(undefined, arguments); -}; + /* + * Calls listeners that were added by the `subscribe` function + */ + function callSubscribers(options) { + var TOPICS = Object.keys(options); -function getStandardBidderSettings() { - var granularity = _config.config.getConfig('priceGranularity'); - var bidder_settings = pbjs.bidderSettings; - if (!bidder_settings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD]) { - bidder_settings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD] = {}; - } - if (!bidder_settings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD][CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING]) { - bidder_settings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD][CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING] = [{ - key: 'hb_bidder', - val: function val(bidResponse) { - return bidResponse.bidderCode; - } - }, { - key: 'hb_adid', - val: function val(bidResponse) { - return bidResponse.adId; - } - }, { - key: 'hb_pb', - val: function val(bidResponse) { - if (granularity === CONSTANTS.GRANULARITY_OPTIONS.AUTO) { - return bidResponse.pbAg; - } else if (granularity === CONSTANTS.GRANULARITY_OPTIONS.DENSE) { - return bidResponse.pbDg; - } else if (granularity === CONSTANTS.GRANULARITY_OPTIONS.LOW) { - return bidResponse.pbLg; - } else if (granularity === CONSTANTS.GRANULARITY_OPTIONS.MEDIUM) { - return bidResponse.pbMg; - } else if (granularity === CONSTANTS.GRANULARITY_OPTIONS.HIGH) { - return bidResponse.pbHg; - } else if (granularity === CONSTANTS.GRANULARITY_OPTIONS.CUSTOM) { - return bidResponse.pbCg; - } - } - }, { - key: 'hb_size', - val: function val(bidResponse) { - return bidResponse.size; - } - }, { - key: 'hb_deal', - val: function val(bidResponse) { - return bidResponse.dealId; - } - }]; + // call subscribers of a specific topic, passing only that configuration + listeners.filter((function (listener) { + return TOPICS.includes(listener.topic); + })).forEach((function (listener) { + listener.callback(_defineProperty({}, listener.topic, options[listener.topic])); + })); + + // call subscribers that didn't give a topic, passing everything that was set + listeners.filter((function (listener) { + return listener.topic === ALL_TOPICS; + })).forEach((function (listener) { + return listener.callback(options); + })); } - return bidder_settings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD]; -} -function getStandardBidderAdServerTargeting() { - return getStandardBidderSettings()[CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING]; + return { + getConfig: getConfig, + setConfig: setConfig, + setDefaults: setDefaults + }; } -exports.getStandardBidderAdServerTargeting = getStandardBidderAdServerTargeting; +var config = exports.config = newConfig(); /***/ }), +/* 9 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ 20: -/***/ (function(module, exports) { +"use strict"; -module.exports = function (it) { - return typeof it === 'object' ? it !== null : typeof it === 'function'; -}; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports["default"] = Adapter; +function Adapter(code) { + var bidderCode = code; -/***/ }), + function setBidderCode(code) { + bidderCode = code; + } -/***/ 21: -/***/ (function(module, exports, __webpack_require__) { + function getBidderCode() { + return bidderCode; + } -"use strict"; + function callBids() {} + return { + callBids: callBids, + setBidderCode: setBidderCode, + getBidderCode: getBidderCode + }; +} -var _utils = __webpack_require__(0); +/***/ }), +/* 10 */, +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { -var _config = __webpack_require__(9); +"use strict"; -var _native = __webpack_require__(15); -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; -var bidmanager = __webpack_require__(2); +/** + * events.js + */ var utils = __webpack_require__(0); -var CONSTANTS = __webpack_require__(4); +var CONSTANTS = __webpack_require__(3); +var slice = Array.prototype.slice; +var push = Array.prototype.push; -var targeting = exports; -var pbTargetingKeys = []; +// define entire events +// var allEvents = ['bidRequested','bidResponse','bidWon','bidTimeout']; +var allEvents = utils._map(CONSTANTS.EVENTS, (function (v) { + return v; +})); -targeting.resetPresetTargeting = function (adUnitCode) { - if ((0, _utils.isGptPubadsDefined)()) { - var adUnitCodes = getAdUnitCodes(adUnitCode); - var adUnits = pbjs.adUnits.filter((function (adUnit) { - return adUnitCodes.includes(adUnit.code); - })); - window.googletag.pubads().getSlots().forEach((function (slot) { - pbTargetingKeys.forEach((function (key) { - // reset only registered adunits - adUnits.forEach((function (unit) { - if (unit.code === slot.getAdUnitPath() || unit.code === slot.getSlotElementId()) { - slot.setTargeting(key, null); - } - })); - })); - })); - } -}; +var idPaths = CONSTANTS.EVENT_ID_PATHS; -targeting.getAllTargeting = function (adUnitCode) { - var adUnitCodes = getAdUnitCodes(adUnitCode); +// keep a record of all events fired +var eventsFired = []; - // Get targeting for the winning bid. Add targeting for any bids that have - // `alwaysUseBid=true`. If sending all bids is enabled, add targeting for losing bids. - var targeting = getWinningBidTargeting(adUnitCodes).concat(getAlwaysUseBidTargeting(adUnitCodes)).concat(_config.config.getConfig('enableSendAllBids') ? getBidLandscapeTargeting(adUnitCodes) : []); +module.exports = (function () { + var _handlers = {}; + var _public = {}; - // store a reference of the targeting keys - targeting.map((function (adUnitCode) { - Object.keys(adUnitCode).map((function (key) { - adUnitCode[key].map((function (targetKey) { - if (pbTargetingKeys.indexOf(Object.keys(targetKey)[0]) === -1) { - pbTargetingKeys = Object.keys(targetKey).concat(pbTargetingKeys); - } - })); - })); - })); - return targeting; -}; + /** + * + * @param {String} eventString The name of the event. + * @param {Array} args The payload emitted with the event. + * @private + */ + function _dispatch(eventString, args) { + utils.logMessage('Emitting event for: ' + eventString); -targeting.setTargeting = function (targetingConfig) { - window.googletag.pubads().getSlots().forEach((function (slot) { - targetingConfig.filter((function (targeting) { - return Object.keys(targeting)[0] === slot.getAdUnitPath() || Object.keys(targeting)[0] === slot.getSlotElementId(); - })).forEach((function (targeting) { - return targeting[Object.keys(targeting)[0]].forEach((function (key) { - key[Object.keys(key)[0]].map((function (value) { - utils.logMessage('Attempting to set key value for slot: ' + slot.getSlotElementId() + ' key: ' + Object.keys(key)[0] + ' value: ' + value); - return value; - })).forEach((function (value) { - slot.setTargeting(Object.keys(key)[0], value); - })); - })); + var eventPayload = args[0] || {}; + var idPath = idPaths[eventString]; + var key = eventPayload[idPath]; + var event = _handlers[eventString] || { que: [] }; + var eventKeys = utils._map(event, (function (v, k) { + return k; })); - })); -}; -/** - * normlizes input to a `adUnit.code` array - * @param {(string|string[])} adUnitCode [description] - * @return {string[]} AdUnit code array - */ -function getAdUnitCodes(adUnitCode) { - if (typeof adUnitCode === 'string') { - return [adUnitCode]; - } else if (utils.isArray(adUnitCode)) { - return adUnitCode; - } - return pbjs._adUnitCodes || []; -} + var callbacks = []; -/** - * Returns top bids for a given adUnit or set of adUnits. - * @param {(string|string[])} adUnitCode adUnitCode or array of adUnitCodes - * @return {[type]} [description] - */ -targeting.getWinningBids = function (adUnitCode) { - var adUnitCodes = getAdUnitCodes(adUnitCode); + // record the event: + eventsFired.push({ + eventType: eventString, + args: eventPayload, + id: key + }); - return pbjs._bidsReceived.filter((function (bid) { - return adUnitCodes.includes(bid.adUnitCode); - })).filter((function (bid) { - return bid.cpm > 0; - })).map((function (bid) { - return bid.adUnitCode; - })).filter(_utils.uniques).map((function (adUnitCode) { - return pbjs._bidsReceived.filter((function (bid) { - return bid.adUnitCode === adUnitCode ? bid : null; - })).reduce(_utils.getHighestCpm, getEmptyBid(adUnitCode)); - })); -}; + /** Push each specific callback to the `callbacks` array. + * If the `event` map has a key that matches the value of the + * event payload id path, e.g. `eventPayload[idPath]`, then apply + * each function in the `que` array as an argument to push to the + * `callbacks` array + * */ + if (key && utils.contains(eventKeys, key)) { + push.apply(callbacks, event[key].que); + } -targeting.setTargetingForAst = function () { - var targeting = pbjs.getAdserverTargeting(); - Object.keys(targeting).forEach((function (targetId) { - return Object.keys(targeting[targetId]).forEach((function (key) { - utils.logMessage('Attempting to set targeting for targetId: ' + targetId + ' key: ' + key + ' value: ' + targeting[targetId][key]); - // setKeywords supports string and array as value - if (utils.isStr(targeting[targetId][key]) || utils.isArray(targeting[targetId][key])) { - var keywordsObj = {}; - var input = 'hb_adid'; - var nKey = key.substring(0, input.length) === input ? key.toUpperCase() : key; - keywordsObj[nKey] = targeting[targetId][key]; - window.apntag.setKeywords(targetId, keywordsObj); + /** Push each general callback to the `callbacks` array. */ + push.apply(callbacks, event.que); + + /** call each of the callbacks */ + utils._each(callbacks, (function (fn) { + if (!fn) return; + try { + fn.apply(null, args); + } catch (e) { + utils.logError('Error executing handler:', 'events.js', e); } })); - })); -}; + } -function getWinningBidTargeting(adUnitCodes) { - var winners = targeting.getWinningBids(adUnitCodes); - var standardKeys = getStandardKeys(); + function _checkAvailableEvent(event) { + return utils.contains(allEvents, event); + } - winners = winners.map((function (winner) { - return _defineProperty({}, winner.adUnitCode, Object.keys(winner.adserverTargeting).filter((function (key) { - return typeof winner.sendStandardTargeting === 'undefined' || winner.sendStandardTargeting || standardKeys.indexOf(key) === -1; - })).map((function (key) { - return _defineProperty({}, key.substring(0, 20), [winner.adserverTargeting[key]]); - }))); - })); + _public.on = function (eventString, handler, id) { + // check whether available event or not + if (_checkAvailableEvent(eventString)) { + var event = _handlers[eventString] || { que: [] }; - return winners; -} + if (id) { + event[id] = event[id] || { que: [] }; + event[id].que.push(handler); + } else { + event.que.push(handler); + } -function getStandardKeys() { - return bidmanager.getStandardBidderAdServerTargeting() // in case using a custom standard key set - .map((function (targeting) { - return targeting.key; - })).concat(CONSTANTS.TARGETING_KEYS).filter(_utils.uniques); // standard keys defined in the library. -} + _handlers[eventString] = event; + } else { + utils.logError('Wrong event name : ' + eventString + ' Valid event names :' + allEvents); + } + }; -/** - * Get custom targeting keys for bids that have `alwaysUseBid=true`. - */ -function getAlwaysUseBidTargeting(adUnitCodes) { - var standardKeys = getStandardKeys(); - return pbjs._bidsReceived.filter(_utils.adUnitsFilter.bind(this, adUnitCodes)).map((function (bid) { - if (bid.alwaysUseBid) { - return _defineProperty({}, bid.adUnitCode, Object.keys(bid.adserverTargeting).map((function (key) { - // Get only the non-standard keys of the losing bids, since we - // don't want to override the standard keys of the winning bid. - if (standardKeys.indexOf(key) > -1) { - return; - } + _public.emit = function (event) { + var args = slice.call(arguments, 1); + _dispatch(event, args); + }; - return _defineProperty({}, key.substring(0, 20), [bid.adserverTargeting[key]]); - })).filter((function (key) { - return key; - }))); + _public.off = function (eventString, handler, id) { + var event = _handlers[eventString]; + + if (utils.isEmpty(event) || utils.isEmpty(event.que) && utils.isEmpty(event[id])) { + return; } - })).filter((function (bid) { - return bid; - })); // removes empty elements in array; -} -function getBidLandscapeTargeting(adUnitCodes) { - var standardKeys = CONSTANTS.TARGETING_KEYS.concat(_native.NATIVE_TARGETING_KEYS); - var bids = []; - // bucket by adUnitcode - var buckets = (0, _utils.groupBy)(pbjs._bidsReceived, 'adUnitCode'); - // filter top bid for each bucket by bidder - Object.keys(buckets).forEach((function (bucketKey) { - var bidsByBidder = (0, _utils.groupBy)(buckets[bucketKey], 'bidderCode'); - Object.keys(bidsByBidder).forEach((function (key) { - return bids.push(bidsByBidder[key].reduce(_utils.getHighestCpm, getEmptyBid())); - })); - })); - // populate targeting keys for the remaining bids - return bids.map((function (bid) { - if (bid.adserverTargeting) { - return _defineProperty({}, bid.adUnitCode, getTargetingMap(bid, standardKeys.filter((function (key) { - return typeof bid.adserverTargeting[key] !== 'undefined'; - })))); + if (id && (utils.isEmpty(event[id]) || utils.isEmpty(event[id].que))) { + return; } - })).filter((function (bid) { - return bid; - })); // removes empty elements in array -} - -function getTargetingMap(bid, keys) { - return keys.map((function (key) { - return _defineProperty({}, (key + '_' + bid.bidderCode).substring(0, 20), [bid.adserverTargeting[key]]); - })); -} -targeting.isApntagDefined = function () { - if (window.apntag && utils.isFn(window.apntag.setKeywords)) { - return true; - } -}; + if (id) { + utils._each(event[id].que, (function (_handler) { + var que = event[id].que; + if (_handler === handler) { + que.splice(utils.indexOf.call(que, _handler), 1); + } + })); + } else { + utils._each(event.que, (function (_handler) { + var que = event.que; + if (_handler === handler) { + que.splice(utils.indexOf.call(que, _handler), 1); + } + })); + } -function getEmptyBid(adUnitCode) { - return { - adUnitCode: adUnitCode, - cpm: 0, - adserverTargeting: {}, - timeToRespond: 0 + _handlers[eventString] = event; }; -} -/***/ }), + _public.get = function () { + return _handlers; + }; -/***/ 22: -/***/ (function(module, exports, __webpack_require__) { + /** + * This method can return a copy of all the events fired + * @return {Array} array of events fired + */ + _public.getEvents = function () { + var arrayCopy = []; + utils._each(eventsFired, (function (value) { + var newProp = _extends({}, value); + arrayCopy.push(newProp); + })); -var dP = __webpack_require__(344); -var createDesc = __webpack_require__(349); -module.exports = __webpack_require__(23) ? function (object, key, value) { - return dP.f(object, key, createDesc(1, value)); -} : function (object, key, value) { - object[key] = value; - return object; -}; + return arrayCopy; + }; + return _public; +})(); /***/ }), - -/***/ 23: +/* 12 */ /***/ (function(module, exports, __webpack_require__) { -// Thank's IE8 for his funny defineProperty -module.exports = !__webpack_require__(24)((function () { - return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7; -})); - +"use strict"; -/***/ }), -/***/ 24: -/***/ (function(module, exports) { +Object.defineProperty(exports, "__esModule", { + value: true +}); +/** + * This file contains the valid Media Types in Prebid. + * + * All adapters are assumed to support banner ads. Other media types are specified by Adapters when they + * register themselves with prebid-core. + */ -module.exports = function (exec) { - try { - return !!exec(); - } catch (e) { - return true; - } -}; +/** + * @typedef {('native'|'video'|'banner')} MediaType + */ +/** @type MediaType */ +var NATIVE = exports.NATIVE = 'native'; +/** @type MediaType */ +var VIDEO = exports.VIDEO = 'video'; +/** @type MediaType */ +var BANNER = exports.BANNER = 'banner'; /***/ }), +/* 13 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ 25: -/***/ (function(module, exports) { +"use strict"; -var id = 0; -var px = Math.random(); -module.exports = function (key) { - return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); -}; +Object.defineProperty(exports, "__esModule", { + value: true +}); -/***/ }), +var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; })(); -/***/ 26: -/***/ (function(module, exports, __webpack_require__) { +exports.parseQS = parseQS; +exports.formatQS = formatQS; +exports.parse = parse; +exports.format = format; +function parseQS(query) { + return !query ? {} : query.replace(/^\?/, '').split('&').reduce((function (acc, criteria) { + var _criteria$split = criteria.split('='), + _criteria$split2 = _slicedToArray(_criteria$split, 2), + k = _criteria$split2[0], + v = _criteria$split2[1]; -// fallback for non-array-like ES3 and non-enumerable old V8 strings -var cof = __webpack_require__(35); -// eslint-disable-next-line no-prototype-builtins -module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) { - return cof(it) == 'String' ? it.split('') : Object(it); -}; + if (/\[\]$/.test(k)) { + k = k.replace('[]', ''); + acc[k] = acc[k] || []; + acc[k].push(v); + } else { + acc[k] = v || ''; + } + return acc; + }), {}); +} +function formatQS(query) { + return Object.keys(query).map((function (k) { + return Array.isArray(query[k]) ? query[k].map((function (v) { + return k + '[]=' + v; + })).join('&') : k + '=' + query[k]; + })).join('&'); +} -/***/ }), +function parse(url, options) { + var parsed = document.createElement('a'); + if (options && 'noDecodeWholeURL' in options && options.noDecodeWholeURL) { + parsed.href = url; + } else { + parsed.href = decodeURIComponent(url); + } + return { + protocol: (parsed.protocol || '').replace(/:$/, ''), + hostname: parsed.hostname, + port: +parsed.port, + pathname: parsed.pathname.replace(/^(?!\/)/, '/'), + search: parseQS(parsed.search || ''), + hash: (parsed.hash || '').replace(/^#/, ''), + host: parsed.host || window.location.host + }; +} -/***/ 27: -/***/ (function(module, exports, __webpack_require__) { +function format(obj) { + return (obj.protocol || 'http') + '://' + (obj.host || obj.hostname + (obj.port ? ':' + obj.port : '')) + (obj.pathname || '') + (obj.search ? '?' + formatQS(obj.search || '') : '') + (obj.hash ? '#' + obj.hash : ''); +} -// 22.1.3.31 Array.prototype[@@unscopables] -var UNSCOPABLES = __webpack_require__(40)('unscopables'); -var ArrayProto = Array.prototype; -if (ArrayProto[UNSCOPABLES] == undefined) __webpack_require__(22)(ArrayProto, UNSCOPABLES, {}); -module.exports = function (key) { - ArrayProto[UNSCOPABLES][key] = true; -}; +/***/ }), +/* 14 */ +/***/ (function(module, exports) { +var core = module.exports = { version: '2.5.5' }; +if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef -/***/ }), -/***/ 28: +/***/ }), +/* 15 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -3060,137 +3144,199 @@ module.exports = function (key) { Object.defineProperty(exports, "__esModule", { value: true }); -var utils = __webpack_require__(0); +exports.hasNonNativeBidder = exports.nativeBidder = exports.nativeAdUnit = exports.NATIVE_TARGETING_KEYS = exports.NATIVE_KEYS = exports.nativeAdapters = undefined; -var _defaultPrecision = 2; -var _lgPriceConfig = { - 'buckets': [{ - 'min': 0, - 'max': 5, - 'increment': 0.5 - }] +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +exports.processNativeAdUnitParams = processNativeAdUnitParams; +exports.nativeBidIsValid = nativeBidIsValid; +exports.fireNativeTrackers = fireNativeTrackers; +exports.getNativeTargeting = getNativeTargeting; + +var _utils = __webpack_require__(0); + +var nativeAdapters = exports.nativeAdapters = []; + +var NATIVE_KEYS = exports.NATIVE_KEYS = { + title: 'hb_native_title', + body: 'hb_native_body', + sponsoredBy: 'hb_native_brand', + image: 'hb_native_image', + icon: 'hb_native_icon', + clickUrl: 'hb_native_linkurl', + cta: 'hb_native_cta' }; -var _mgPriceConfig = { - 'buckets': [{ - 'min': 0, - 'max': 20, - 'increment': 0.1 - }] + +var NATIVE_TARGETING_KEYS = exports.NATIVE_TARGETING_KEYS = Object.keys(NATIVE_KEYS).map((function (key) { + return NATIVE_KEYS[key]; +})); + +var IMAGE = { + image: { required: true }, + title: { required: true }, + sponsoredBy: { required: true }, + clickUrl: { required: true }, + body: { required: false }, + icon: { required: false } }; -var _hgPriceConfig = { - 'buckets': [{ - 'min': 0, - 'max': 20, - 'increment': 0.01 - }] -}; -var _densePriceConfig = { - 'buckets': [{ - 'min': 0, - 'max': 3, - 'increment': 0.01 - }, { - 'min': 3, - 'max': 8, - 'increment': 0.05 - }, { - 'min': 8, - 'max': 20, - 'increment': 0.5 - }] -}; -var _autoPriceConfig = { - 'buckets': [{ - 'min': 0, - 'max': 5, - 'increment': 0.05 - }, { - 'min': 5, - 'max': 10, - 'increment': 0.1 - }, { - 'min': 10, - 'max': 20, - 'increment': 0.5 - }] + +var SUPPORTED_TYPES = { + image: IMAGE }; -function getPriceBucketString(cpm, customConfig) { - var granularityMultiplier = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; - - var cpmFloat = parseFloat(cpm); - if (isNaN(cpmFloat)) { - cpmFloat = ''; +/** + * Recieves nativeParams from an adUnit. If the params were not of type 'type', + * passes them on directly. If they were of type 'type', translate + * them into the predefined specific asset requests for that type of native ad. + */ +function processNativeAdUnitParams(params) { + if (params && params.type && typeIsSupported(params.type)) { + return SUPPORTED_TYPES[params.type]; } - return { - low: cpmFloat === '' ? '' : getCpmStringValue(cpm, _lgPriceConfig, granularityMultiplier), - med: cpmFloat === '' ? '' : getCpmStringValue(cpm, _mgPriceConfig, granularityMultiplier), - high: cpmFloat === '' ? '' : getCpmStringValue(cpm, _hgPriceConfig, granularityMultiplier), - auto: cpmFloat === '' ? '' : getCpmStringValue(cpm, _autoPriceConfig, granularityMultiplier), - dense: cpmFloat === '' ? '' : getCpmStringValue(cpm, _densePriceConfig, granularityMultiplier), - custom: cpmFloat === '' ? '' : getCpmStringValue(cpm, customConfig, granularityMultiplier) - }; + return params; } -function getCpmStringValue(cpm, config, granularityMultiplier) { - var cpmStr = ''; - if (!isValidPriceConfig(config)) { - return cpmStr; - } - var cap = config.buckets.reduce((function (prev, curr) { - if (prev.max > curr.max) { - return prev; - } - return curr; - }), { - 'max': 0 - }); - var bucket = config.buckets.find((function (bucket) { - if (cpm > cap.max * granularityMultiplier) { - // cpm exceeds cap, just return the cap. - var precision = bucket.precision; - if (typeof precision === 'undefined') { - precision = _defaultPrecision; - } - cpmStr = (bucket.max * granularityMultiplier).toFixed(precision); - } else if (cpm <= bucket.max * granularityMultiplier && cpm >= bucket.min * granularityMultiplier) { - return bucket; - } - })); - if (bucket) { - cpmStr = getCpmTarget(cpm, bucket.increment, bucket.precision, granularityMultiplier); +/** + * Check if the native type specified in the adUnit is supported by Prebid. + */ +function typeIsSupported(type) { + if (!(type && Object.keys(SUPPORTED_TYPES).includes(type))) { + (0, _utils.logError)(type + ' nativeParam is not supported'); + return false; } - return cpmStr; + + return true; } -function isValidPriceConfig(config) { - if (utils.isEmpty(config) || !config.buckets || !Array.isArray(config.buckets)) { +/** + * Helper functions for working with native-enabled adUnits + * TODO: abstract this and the video helper functions into general + * adunit validation helper functions + */ +var nativeAdUnit = exports.nativeAdUnit = function nativeAdUnit(adUnit) { + var mediaType = adUnit.mediaType === 'native'; + var mediaTypes = (0, _utils.deepAccess)(adUnit, 'mediaTypes.native'); + return mediaType || mediaTypes; +}; +var nativeBidder = exports.nativeBidder = function nativeBidder(bid) { + return nativeAdapters.includes(bid.bidder); +}; +var hasNonNativeBidder = exports.hasNonNativeBidder = function hasNonNativeBidder(adUnit) { + return adUnit.bids.filter((function (bid) { + return !nativeBidder(bid); + })).length; +}; + +/* + * Validate that the native assets on this bid contain all assets that were + * marked as required in the adUnit configuration. + */ +function nativeBidIsValid(bid) { + var bidRequest = (0, _utils.getBidRequest)(bid.adId); + if (!bidRequest) { return false; } - var isValid = true; - config.buckets.forEach((function (bucket) { - if (typeof bucket.min === 'undefined' || !bucket.max || !bucket.increment) { - isValid = false; - } + + // all native bid responses must define a landing page url + if (!(0, _utils.deepAccess)(bid, 'native.clickUrl')) { + return false; + } + + var requestedAssets = bidRequest.nativeParams; + if (!requestedAssets) { + return true; + } + + var requiredAssets = Object.keys(requestedAssets).filter((function (key) { + return requestedAssets[key].required; + })); + var returnedAssets = Object.keys(bid['native']).filter((function (key) { + return bid['native'][key]; + })); + + return requiredAssets.every((function (asset) { + return returnedAssets.includes(asset); })); - return isValid; } -function getCpmTarget(cpm, increment, precision, granularityMultiplier) { - if (typeof precision === 'undefined') { - precision = _defaultPrecision; +/* + * Native responses may have associated impression or click trackers. + * This retrieves the appropriate tracker urls for the given ad object and + * fires them. As a native creatives may be in a cross-origin frame, it may be + * necessary to invoke this function via postMessage. secureCreatives is + * configured to fire this function when it receives a `message` of 'Prebid Native' + * and an `adId` with the value of the `bid.adId`. When a message is posted with + * these parameters, impression trackers are fired. To fire click trackers, the + * message should contain an `action` set to 'click'. + * + * // Native creative template example usage + * + * %%PATTERN:hb_native_title%% + * + * + * + */ +function fireNativeTrackers(message, adObject) { + var trackers = void 0; + + if (message.action === 'click') { + trackers = adObject['native'] && adObject['native'].clickTrackers; + } else { + trackers = adObject['native'] && adObject['native'].impressionTrackers; } - var bucketSize = 1 / (increment * granularityMultiplier); - return (Math.floor(cpm * bucketSize) / bucketSize).toFixed(precision); + + (trackers || []).forEach(_utils.triggerPixel); } -exports.getPriceBucketString = getPriceBucketString; -exports.isValidPriceConfig = isValidPriceConfig; +/** + * Gets native targeting key-value paris + * @param {Object} bid + * @return {Object} targeting + */ +function getNativeTargeting(bid) { + var keyValues = {}; + + Object.keys(bid['native']).forEach((function (asset) { + var key = NATIVE_KEYS[asset]; + var value = bid['native'][asset]; + + // native image-type assets can be a string or an object with a url prop + if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value.url) { + value = value.url; + } + + if (key) { + keyValues[key] = value; + } + })); + + return keyValues; +} /***/ }), +/* 16 */ +/***/ (function(module, exports) { + +// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 +var global = module.exports = typeof window != 'undefined' && window.Math == Math + ? window : typeof self != 'undefined' && self.Math == Math ? self + // eslint-disable-next-line no-new-func + : Function('return this')(); +if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef -/***/ 29: + +/***/ }), +/* 17 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -3199,165 +3345,110 @@ exports.isValidPriceConfig = isValidPriceConfig; Object.defineProperty(exports, "__esModule", { value: true }); -exports.hasNonVideoBidder = exports.videoBidder = exports.videoAdUnit = undefined; -exports.isValidVideoBid = isValidVideoBid; +exports.Renderer = Renderer; -var _adaptermanager = __webpack_require__(1); +var _adloader = __webpack_require__(5); var _utils = __webpack_require__(0); -var _config = __webpack_require__(9); +var utils = _interopRequireWildcard(_utils); -var VIDEO_MEDIA_TYPE = 'video'; -var OUTSTREAM = 'outstream'; +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } } /** - * Helper functions for working with video-enabled adUnits + * @typedef {object} Renderer + * + * A Renderer stores some functions which are used to render a particular Bid. + * These are used in Outstream Video Bids, returned on the Bid by the adapter, and will + * be used to render that bid unless the Publisher overrides them. */ -var videoAdUnit = exports.videoAdUnit = function videoAdUnit(adUnit) { - var mediaType = adUnit.mediaType === VIDEO_MEDIA_TYPE; - var mediaTypes = (0, _utils.deepAccess)(adUnit, 'mediaTypes.video'); - return mediaType || mediaTypes; -}; -var videoBidder = exports.videoBidder = function videoBidder(bid) { - return _adaptermanager.videoAdapters.includes(bid.bidder); -}; -var hasNonVideoBidder = exports.hasNonVideoBidder = function hasNonVideoBidder(adUnit) { - return adUnit.bids.filter((function (bid) { - return !videoBidder(bid); - })).length; -}; -/** - * @typedef {object} VideoBid - * @property {string} adId id of the bid - */ +function Renderer(options) { + var _this = this; -/** - * Validate that the assets required for video context are present on the bid - * @param {VideoBid} bid video bid to validate - * @return {boolean} If object is valid - */ -function isValidVideoBid(bid) { - var bidRequest = (0, _utils.getBidRequest)(bid.adId); + var url = options.url, + config = options.config, + id = options.id, + callback = options.callback, + loaded = options.loaded; - var videoMediaType = bidRequest && (0, _utils.deepAccess)(bidRequest, 'mediaTypes.video'); - var context = videoMediaType && (0, _utils.deepAccess)(videoMediaType, 'context'); + this.url = url; + this.config = config; + this.handlers = {}; + this.id = id; - // if context not defined assume default 'instream' for video bids - // instream bids require a vast url or vast xml content - if (!bidRequest || videoMediaType && context !== OUTSTREAM) { - // xml-only video bids require prebid-cache to be enabled - if (!_config.config.getConfig('usePrebidCache') && bid.vastXml && !bid.vastUrl) { - (0, _utils.logError)('\n This bid contains only vastXml and will not work when prebid-cache is disabled.\n Try enabling prebid-cache with pbjs.setConfig({ usePrebidCache: true });\n '); - return false; + // a renderer may push to the command queue to delay rendering until the + // render function is loaded by loadScript, at which point the the command + // queue will be processed + this.loaded = loaded; + this.cmd = []; + this.push = function (func) { + if (typeof func !== 'function') { + utils.logError('Commands given to Renderer.push must be wrapped in a function'); + return; } + _this.loaded ? func.call() : _this.cmd.push(func); + }; - return !!(bid.vastUrl || bid.vastXml); - } - - // outstream bids require a renderer on the bid or pub-defined on adunit - if (context === OUTSTREAM) { - return !!(bid.renderer || bidRequest.renderer); - } + // bidders may override this with the `callback` property given to `install` + this.callback = callback || function () { + _this.loaded = true; + _this.process(); + }; - return true; + // we expect to load a renderer url once only so cache the request to load script + (0, _adloader.loadScript)(url, this.callback, true); } -/***/ }), - -/***/ 3: -/***/ (function(module, exports, __webpack_require__) { +Renderer.install = function (_ref) { + var url = _ref.url, + config = _ref.config, + id = _ref.id, + callback = _ref.callback, + loaded = _ref.loaded; -"use strict"; + return new Renderer({ url: url, config: config, id: id, callback: callback, loaded: loaded }); +}; +Renderer.prototype.getConfig = function () { + return this.config; +}; -var utils = __webpack_require__(0); +Renderer.prototype.setRender = function (fn) { + this.render = fn; +}; -/** - Required paramaters - bidderCode, - height, - width, - statusCode - Optional paramaters - adId, - cpm, - ad, - adUrl, - dealId, - priceKeyString; - */ -function Bid(statusCode, bidRequest) { - var _bidId = bidRequest && bidRequest.bidId || utils.getUniqueIdentifierStr(); - var _statusCode = statusCode || 0; +Renderer.prototype.setEventHandlers = function (handlers) { + this.handlers = handlers; +}; - this.bidderCode = bidRequest && bidRequest.bidder || ''; - this.width = 0; - this.height = 0; - this.statusMessage = _getStatus(); - this.adId = _bidId; - this.mediaType = 'banner'; +Renderer.prototype.handleVideoEvent = function (_ref2) { + var id = _ref2.id, + eventName = _ref2.eventName; - function _getStatus() { - switch (_statusCode) { - case 0: - return 'Pending'; - case 1: - return 'Bid available'; - case 2: - return 'Bid returned empty or error response'; - case 3: - return 'Bid timed out'; - } + if (typeof this.handlers[eventName] === 'function') { + this.handlers[eventName](); } - this.getStatusCode = function () { - return _statusCode; - }; - - // returns the size of the bid creative. Concatenation of width and height by ‘x’. - this.getSize = function () { - return this.width + 'x' + this.height; - }; -} - -// Bid factory function. -exports.createBid = function (statusCode, bidRequest) { - return new Bid(statusCode, bidRequest); + utils.logMessage('Prebid Renderer event for id ' + id + ' type ' + eventName); }; -/***/ }), - -/***/ 30: -/***/ (function(module, exports) { - -var g; - -// This works in non-strict mode -g = (function() { - return this; -})(); - -try { - // This works if eval is allowed (see CSP) - g = g || Function("return this")() || (1,eval)("this"); -} catch(e) { - // This works if the window reference is available - if(typeof window === "object") - g = window; -} - -// g can still be undefined, but nothing to do about it... -// We return undefined, instead of nothing here, so it's -// easier to handle this case. if(!global) { ...} - -module.exports = g; - +/* + * Calls functions that were pushed to the command queue before the + * renderer was loaded by `loadScript` + */ +Renderer.prototype.process = function () { + while (this.cmd.length > 0) { + try { + this.cmd.shift().call(); + } catch (error) { + utils.logError('Error processing Renderer command: ', error); + } + } +}; /***/ }), - -/***/ 31: +/* 18 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -3366,3221 +3457,3699 @@ module.exports = g; Object.defineProperty(exports, "__esModule", { value: true }); -exports.getGlobal = getGlobal; -// if pbjs already exists in global document scope, use it, if not, create the object -// global defination should happen BEFORE imports to avoid global undefined errors. -window.pbjs = window.pbjs || {}; -window.pbjs.cmd = window.pbjs.cmd || []; -window.pbjs.que = window.pbjs.que || []; +exports.userSync = undefined; -function getGlobal() { - return window.pbjs; -} +var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; })(); -/***/ }), +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; -/***/ 32: -/***/ (function(module, exports) { +exports.newUserSync = newUserSync; -var hasOwnProperty = {}.hasOwnProperty; -module.exports = function (it, key) { - return hasOwnProperty.call(it, key); -}; +var _utils = __webpack_require__(0); +var utils = _interopRequireWildcard(_utils); -/***/ }), +var _config = __webpack_require__(8); -/***/ 33: -/***/ (function(module, exports, __webpack_require__) { +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } } -// optional / simple context binding -var aFunction = __webpack_require__(351); -module.exports = function (fn, that, length) { - aFunction(fn); - if (that === undefined) return fn; - switch (length) { - case 1: return function (a) { - return fn.call(that, a); - }; - case 2: return function (a, b) { - return fn.call(that, a, b); - }; - case 3: return function (a, b, c) { - return fn.call(that, a, b, c); - }; +// Set userSync default values +_config.config.setDefaults({ + 'userSync': { + syncEnabled: true, + pixelEnabled: true, + syncsPerBidder: 5, + syncDelay: 3000 } - return function (/* ...args */) { - return fn.apply(that, arguments); - }; -}; - - -/***/ }), +}); -/***/ 339: -/***/ (function(module, exports, __webpack_require__) { +/** + * Factory function which creates a new UserSyncPool. + * + * @param {UserSyncDependencies} userSyncDependencies Configuration options and dependencies which the + * UserSync object needs in order to behave properly. + */ +function newUserSync(userSyncDependencies) { + var publicApi = {}; + // A queue of user syncs for each adapter + // Let getDefaultQueue() set the defaults + var queue = getDefaultQueue(); -module.exports = __webpack_require__(340); + // Whether or not user syncs have been trigger on this page load + var hasFired = false; + // How many bids for each adapter + var numAdapterBids = {}; + // Use what is in config by default + var usConfig = userSyncDependencies.config; + // Update if it's (re)set + _config.config.getConfig('userSync', (function (conf) { + usConfig = _extends(usConfig, conf.userSync); + })); -/***/ }), + /** + * @function getDefaultQueue + * @summary Returns the default empty queue + * @private + * @return {object} A queue with no syncs + */ + function getDefaultQueue() { + return { + image: [], + iframe: [] + }; + } -/***/ 34: -/***/ (function(module, exports, __webpack_require__) { + /** + * @function fireSyncs + * @summary Trigger all user syncs in the queue + * @private + */ + function fireSyncs() { + if (!usConfig.syncEnabled || !userSyncDependencies.browserSupportsCookies || hasFired) { + return; + } -// 0 -> Array#forEach -// 1 -> Array#map -// 2 -> Array#filter -// 3 -> Array#some -// 4 -> Array#every -// 5 -> Array#find -// 6 -> Array#findIndex -var ctx = __webpack_require__(33); -var IObject = __webpack_require__(26); -var toObject = __webpack_require__(36); -var toLength = __webpack_require__(38); -var asc = __webpack_require__(352); -module.exports = function (TYPE, $create) { - var IS_MAP = TYPE == 1; - var IS_FILTER = TYPE == 2; - var IS_SOME = TYPE == 3; - var IS_EVERY = TYPE == 4; - var IS_FIND_INDEX = TYPE == 6; - var NO_HOLES = TYPE == 5 || IS_FIND_INDEX; - var create = $create || asc; - return function ($this, callbackfn, that) { - var O = toObject($this); - var self = IObject(O); - var f = ctx(callbackfn, that, 3); - var length = toLength(self.length); - var index = 0; - var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined; - var val, res; - for (;length > index; index++) if (NO_HOLES || index in self) { - val = self[index]; - res = f(val, index, O); - if (TYPE) { - if (IS_MAP) result[index] = res; // map - else if (res) switch (TYPE) { - case 3: return true; // some - case 5: return val; // find - case 6: return index; // findIndex - case 2: result.push(val); // filter - } else if (IS_EVERY) return false; // every - } + try { + // Image pixels + fireImagePixels(); + // Iframe syncs + loadIframes(); + } catch (e) { + return utils.logError('Error firing user syncs', e); } - return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result; - }; -}; - - -/***/ }), - -/***/ 340: -/***/ (function(module, exports, __webpack_require__) { + // Reset the user sync queue + queue = getDefaultQueue(); + hasFired = true; + } -"use strict"; + /** + * @function fireImagePixels + * @summary Loops through user sync pixels and fires each one + * @private + */ + function fireImagePixels() { + if (!usConfig.pixelEnabled) { + return; + } + // Randomize the order of the pixels before firing + // This is to avoid giving any bidder who has registered multiple syncs + // any preferential treatment and balancing them out + utils.shuffle(queue.image).forEach((function (sync) { + var _sync = _slicedToArray(sync, 2), + bidderName = _sync[0], + trackingPixelUrl = _sync[1]; + utils.logMessage('Invoking image pixel user sync for bidder: ' + bidderName); + // Create image object and add the src url + utils.triggerPixel(trackingPixelUrl); + })); + } -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + /** + * @function loadIframes + * @summary Loops through iframe syncs and loads an iframe element into the page + * @private + */ + function loadIframes() { + if (!usConfig.iframeEnabled) { + return; + } + // Randomize the order of these syncs just like the pixels above + utils.shuffle(queue.iframe).forEach((function (sync) { + var _sync2 = _slicedToArray(sync, 2), + bidderName = _sync2[0], + iframeUrl = _sync2[1]; -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + utils.logMessage('Invoking iframe user sync for bidder: ' + bidderName); + // Insert iframe into DOM + utils.insertUserSyncIframe(iframeUrl); + })); + } -var _prebidGlobal = __webpack_require__(31); + /** + * @function incrementAdapterBids + * @summary Increment the count of user syncs queue for the adapter + * @private + * @params {object} numAdapterBids The object contain counts for all adapters + * @params {string} bidder The name of the bidder adding a sync + * @returns {object} The updated version of numAdapterBids + */ + function incrementAdapterBids(numAdapterBids, bidder) { + if (!numAdapterBids[bidder]) { + numAdapterBids[bidder] = 1; + } else { + numAdapterBids[bidder] += 1; + } + return numAdapterBids; + } -var _utils = __webpack_require__(0); + /** + * @function registerSync + * @summary Add sync for this bidder to a queue to be fired later + * @public + * @params {string} type The type of the sync including image, iframe + * @params {string} bidder The name of the adapter. e.g. "rubicon" + * @params {string} url Either the pixel url or iframe url depending on the type + * @example Using Image Sync + * // registerSync(type, adapter, pixelUrl) + * userSync.registerSync('image', 'rubicon', 'http://example.com/pixel') + */ + publicApi.registerSync = function (type, bidder, url) { + if (!usConfig.syncEnabled || !utils.isArray(queue[type])) { + return utils.logWarn('User sync type "' + type + '" not supported'); + } + if (!bidder) { + return utils.logWarn('Bidder is required for registering sync'); + } + if (Number(numAdapterBids[bidder]) >= usConfig.syncsPerBidder) { + return utils.logWarn('Number of user syncs exceeded for "{$bidder}"'); + } + // All bidders are enabled by default. If specified only register for enabled bidders. + var hasEnabledBidders = usConfig.enabledBidders && usConfig.enabledBidders.length; + if (hasEnabledBidders && usConfig.enabledBidders.indexOf(bidder) < 0) { + return utils.logWarn('Bidder "' + bidder + '" not supported'); + } + queue[type].push([bidder, url]); + numAdapterBids = incrementAdapterBids(numAdapterBids, bidder); + }; -var _video = __webpack_require__(29); + /** + * @function syncUsers + * @summary Trigger all the user syncs based on publisher-defined timeout + * @public + * @params {int} timeout The delay in ms before syncing data - default 0 + */ + publicApi.syncUsers = function () { + var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; -var _native = __webpack_require__(15); + if (timeout) { + return window.setTimeout(fireSyncs, Number(timeout)); + } + fireSyncs(); + }; -__webpack_require__(341); + /** + * @function triggerUserSyncs + * @summary A `syncUsers` wrapper for determining if enableOverride has been turned on + * @public + */ + publicApi.triggerUserSyncs = function () { + if (usConfig.enableOverride) { + publicApi.syncUsers(); + } + }; -var _url = __webpack_require__(12); + return publicApi; +} -var _secureCreatives = __webpack_require__(369); +var browserSupportsCookies = !utils.isSafariBrowser() && utils.cookiesAreEnabled(); -var _userSync = __webpack_require__(18); +var userSync = exports.userSync = newUserSync({ + config: _config.config.getConfig('userSync'), + browserSupportsCookies: browserSupportsCookies +}); -var _adloader = __webpack_require__(5); +/** + * @typedef {Object} UserSyncDependencies + * + * @property {UserSyncConfig} config + * @property {boolean} browserSupportsCookies True if the current browser supports cookies, and false otherwise. + */ -var _ajax = __webpack_require__(7); +/** + * @typedef {Object} UserSyncConfig + * + * @property {boolean} enableOverride + * @property {boolean} syncEnabled + * @property {boolean} pixelEnabled + * @property {boolean} iframeEnabled + * @property {int} syncsPerBidder + * @property {string[]} enabledBidders + */ -var _config = __webpack_require__(9); +/***/ }), +/* 19 */ +/***/ (function(module, exports) { -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /** @module pbjs */ +// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 +var global = module.exports = typeof window != 'undefined' && window.Math == Math + ? window : typeof self != 'undefined' && self.Math == Math ? self + // eslint-disable-next-line no-new-func + : Function('return this')(); +if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef -var pbjs = (0, _prebidGlobal.getGlobal)(); -var CONSTANTS = __webpack_require__(4); -var utils = __webpack_require__(0); -var bidmanager = __webpack_require__(2); -var adaptermanager = __webpack_require__(1); -var bidfactory = __webpack_require__(3); -var events = __webpack_require__(11); -var adserver = __webpack_require__(370); -var targeting = __webpack_require__(21); -var syncUsers = _userSync.userSync.syncUsers, - triggerUserSyncs = _userSync.userSync.triggerUserSyncs; +/***/ }), +/* 20 */ +/***/ (function(module, exports) { -/* private variables */ +var core = module.exports = { version: '2.5.5' }; +if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef -var BID_WON = CONSTANTS.EVENTS.BID_WON; -var SET_TARGETING = CONSTANTS.EVENTS.SET_TARGETING; -var ADD_AD_UNITS = CONSTANTS.EVENTS.ADD_AD_UNITS; -var auctionRunning = false; -var bidRequestQueue = []; +/***/ }), +/* 21 */ +/***/ (function(module, exports) { -var eventValidators = { - bidWon: checkDefinedPlacement +module.exports = function (it) { + return typeof it === 'object' ? it !== null : typeof it === 'function'; }; -/* Public vars */ - -pbjs._bidsRequested = []; -pbjs._bidsReceived = []; -// _adUnitCodes stores the current filter to use for adUnits as an array of adUnitCodes -pbjs._adUnitCodes = []; -pbjs._winningBids = []; -pbjs._adsReceived = []; - -pbjs.bidderSettings = pbjs.bidderSettings || {}; - -/** @deprecated - use pbjs.setConfig({ bidderTimeout: }) */ -pbjs.bidderTimeout = pbjs.bidderTimeout; - -// current timeout set in `requestBids` or to default `bidderTimeout` -pbjs.cbTimeout = pbjs.cbTimeout || 200; - -// timeout buffer to adjust for bidder CDN latency -pbjs.timeoutBuffer = 200; - -/** @deprecated - use pbjs.setConfig({ debug: }) */ -pbjs.logging = pbjs.logging; - -/** @deprecated - use pbjs.setConfig({ publisherDomain: ) */ -pbjs.publisherDomain = pbjs.publisherDomain; - -// let the world know we are loaded -pbjs.libLoaded = true; -// version auto generated from build -pbjs.version = 'v0.34.1'; -utils.logInfo('Prebid.js v0.34.1 loaded'); +/***/ }), +/* 22 */ +/***/ (function(module, exports, __webpack_require__) { -// create adUnit array -pbjs.adUnits = pbjs.adUnits || []; +var global = __webpack_require__(16); +var core = __webpack_require__(14); +var hide = __webpack_require__(28); +var redefine = __webpack_require__(404); +var ctx = __webpack_require__(47); +var PROTOTYPE = 'prototype'; -// Allow publishers who enable user sync override to trigger their sync -pbjs.triggerUserSyncs = triggerUserSyncs; - -function checkDefinedPlacement(id) { - var placementCodes = pbjs._bidsRequested.map((function (bidSet) { - return bidSet.bids.map((function (bid) { - return bid.placementCode; - })); - })).reduce(_utils.flatten).filter(_utils.uniques); - - if (!utils.contains(placementCodes, id)) { - utils.logError('The "' + id + '" placement is not defined.'); - return; +var $export = function (type, name, source) { + var IS_FORCED = type & $export.F; + var IS_GLOBAL = type & $export.G; + var IS_STATIC = type & $export.S; + var IS_PROTO = type & $export.P; + var IS_BIND = type & $export.B; + var target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE]; + var exports = IS_GLOBAL ? core : core[name] || (core[name] = {}); + var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {}); + var key, own, out, exp; + if (IS_GLOBAL) source = name; + for (key in source) { + // contains in native + own = !IS_FORCED && target && target[key] !== undefined; + // export native or passed + out = (own ? target : source)[key]; + // bind timers to global for call from export context + exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; + // extend global + if (target) redefine(target, key, out, type & $export.U); + // export + if (exports[key] != out) hide(exports, key, exp); + if (IS_PROTO && expProto[key] != out) expProto[key] = out; } +}; +global.core = core; +// type bitmap +$export.F = 1; // forced +$export.G = 2; // global +$export.S = 4; // static +$export.P = 8; // proto +$export.B = 16; // bind +$export.W = 32; // wrap +$export.U = 64; // safe +$export.R = 128; // real proto method for `library` +module.exports = $export; - return true; -} -/** - * When a request for bids is made any stale bids remaining will be cleared for - * a placement included in the outgoing bid request. - */ -function clearPlacements() { - pbjs._bidsRequested = []; +/***/ }), +/* 23 */ +/***/ (function(module, exports) { - // leave bids received for ad slots not in this bid request - pbjs._bidsReceived = pbjs._bidsReceived.filter((function (bid) { - return !pbjs._adUnitCodes.includes(bid.adUnitCode); - })); -} +module.exports = function (it) { + return typeof it === 'object' ? it !== null : typeof it === 'function'; +}; -function setRenderSize(doc, width, height) { - if (doc.defaultView && doc.defaultView.frameElement) { - doc.defaultView.frameElement.width = width; - doc.defaultView.frameElement.height = height; - } -} -/// /////////////////////////////// -// // -// Start Public APIs // -// // -/// /////////////////////////////// +/***/ }), +/* 24 */ +/***/ (function(module, exports, __webpack_require__) { -/** - * This function returns the query string targeting parameters available at this moment for a given ad unit. Note that some bidder's response may not have been received if you call this function too quickly after the requests are sent. - * @param {string} [adunitCode] adUnitCode to get the bid responses for - * @alias module:pbjs.getAdserverTargetingForAdUnitCodeStr - * @return {Array} returnObj return bids array - */ -pbjs.getAdserverTargetingForAdUnitCodeStr = function (adunitCode) { - utils.logInfo('Invoking pbjs.getAdserverTargetingForAdUnitCodeStr', arguments); +var global = __webpack_require__(19); +var core = __webpack_require__(20); +var ctx = __webpack_require__(36); +var hide = __webpack_require__(102); +var has = __webpack_require__(109); +var PROTOTYPE = 'prototype'; - // call to retrieve bids array - if (adunitCode) { - var res = pbjs.getAdserverTargetingForAdUnitCode(adunitCode); - return utils.transformAdServerTargetingObj(res); - } else { - utils.logMessage('Need to call getAdserverTargetingForAdUnitCodeStr with adunitCode'); +var $export = function (type, name, source) { + var IS_FORCED = type & $export.F; + var IS_GLOBAL = type & $export.G; + var IS_STATIC = type & $export.S; + var IS_PROTO = type & $export.P; + var IS_BIND = type & $export.B; + var IS_WRAP = type & $export.W; + var exports = IS_GLOBAL ? core : core[name] || (core[name] = {}); + var expProto = exports[PROTOTYPE]; + var target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE]; + var key, own, out; + if (IS_GLOBAL) source = name; + for (key in source) { + // contains in native + own = !IS_FORCED && target && target[key] !== undefined; + if (own && has(exports, key)) continue; + // export native or passed + out = own ? target[key] : source[key]; + // prevent global pollution for namespaces + exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key] + // bind timers to global for call from export context + : IS_BIND && own ? ctx(out, global) + // wrap global constructors for prevent change them in library + : IS_WRAP && target[key] == out ? (function (C) { + var F = function (a, b, c) { + if (this instanceof C) { + switch (arguments.length) { + case 0: return new C(); + case 1: return new C(a); + case 2: return new C(a, b); + } return new C(a, b, c); + } return C.apply(this, arguments); + }; + F[PROTOTYPE] = C[PROTOTYPE]; + return F; + // make static versions for prototype methods + })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; + // export proto methods to core.%CONSTRUCTOR%.methods.%NAME% + if (IS_PROTO) { + (exports.virtual || (exports.virtual = {}))[key] = out; + // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME% + if (type & $export.R && expProto && !expProto[key]) hide(expProto, key, out); + } } }; +// type bitmap +$export.F = 1; // forced +$export.G = 2; // global +$export.S = 4; // static +$export.P = 8; // proto +$export.B = 16; // bind +$export.W = 32; // wrap +$export.U = 64; // safe +$export.R = 128; // real proto method for `library` +module.exports = $export; -/** - * This function returns the query string targeting parameters available at this moment for a given ad unit. Note that some bidder's response may not have been received if you call this function too quickly after the requests are sent. - * @param adUnitCode {string} adUnitCode to get the bid responses for - * @alias module:pbjs.getAdserverTargetingForAdUnitCode - * @returns {Object} returnObj return bids - */ -pbjs.getAdserverTargetingForAdUnitCode = function (adUnitCode) { - return pbjs.getAdserverTargeting(adUnitCode)[adUnitCode]; -}; -/** - * returns all ad server targeting for all ad units - * @return {Object} Map of adUnitCodes and targeting values [] - * @alias module:pbjs.getAdserverTargeting - */ +/***/ }), +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { -pbjs.getAdserverTargeting = function (adUnitCode) { - utils.logInfo('Invoking pbjs.getAdserverTargeting', arguments); - return targeting.getAllTargeting(adUnitCode).map((function (targeting) { - return _defineProperty({}, Object.keys(targeting)[0], targeting[Object.keys(targeting)[0]].map((function (target) { - return _defineProperty({}, Object.keys(target)[0], target[Object.keys(target)[0]].join(', ')); - })).reduce((function (p, c) { - return _extends(c, p); - }), {})); - })).reduce((function (accumulator, targeting) { - var key = Object.keys(targeting)[0]; - accumulator[key] = _extends({}, accumulator[key], targeting[key]); - return accumulator; - }), {}); -}; +// Thank's IE8 for his funny defineProperty +module.exports = !__webpack_require__(37)((function () { + return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7; +})); -/** - * This function returns the bid responses at the given moment. - * @alias module:pbjs.getBidResponses - * @return {Object} map | object that contains the bidResponses - */ -pbjs.getBidResponses = function () { - utils.logInfo('Invoking pbjs.getBidResponses', arguments); - var responses = pbjs._bidsReceived.filter(_utils.adUnitsFilter.bind(this, pbjs._adUnitCodes)); +/***/ }), +/* 26 */ +/***/ (function(module, exports) { - // find the last requested id to get responses for most recent auction only - var currentRequestId = responses && responses.length && responses[responses.length - 1].requestId; +module.exports = function () { /* empty */ }; - return responses.map((function (bid) { - return bid.adUnitCode; - })).filter(_utils.uniques).map((function (adUnitCode) { - return responses.filter((function (bid) { - return bid.requestId === currentRequestId && bid.adUnitCode === adUnitCode; - })); - })).filter((function (bids) { - return bids && bids[0] && bids[0].adUnitCode; - })).map((function (bids) { - return _defineProperty({}, bids[0].adUnitCode, { bids: bids }); - })).reduce((function (a, b) { - return _extends(a, b); - }), {}); -}; -/** - * Returns bidResponses for the specified adUnitCode - * @param {string} adUnitCode adUnitCode - * @alias module:pbjs.getBidResponsesForAdUnitCode - * @return {Object} bidResponse object - */ +/***/ }), +/* 27 */ +/***/ (function(module, exports, __webpack_require__) { -pbjs.getBidResponsesForAdUnitCode = function (adUnitCode) { - var bids = pbjs._bidsReceived.filter((function (bid) { - return bid.adUnitCode === adUnitCode; - })); - return { - bids: bids - }; -}; +"use strict"; -/** - * Set query string targeting on one or more GPT ad units. - * @param {(string|string[])} adUnit a single `adUnit.code` or multiple. - * @alias module:pbjs.setTargetingForGPTAsync - */ -pbjs.setTargetingForGPTAsync = function (adUnit) { - utils.logInfo('Invoking pbjs.setTargetingForGPTAsync', arguments); - if (!(0, _utils.isGptPubadsDefined)()) { - utils.logError('window.googletag is not defined on the page'); - return; - } - // get our ad unit codes - var targetingSet = targeting.getAllTargeting(adUnit); +var _utils = __webpack_require__(0); - // first reset any old targeting - targeting.resetPresetTargeting(adUnit); +var _config = __webpack_require__(8); - // now set new targeting keys - targeting.setTargeting(targetingSet); +var _native = __webpack_require__(15); - // emit event - events.emit(SET_TARGETING); -}; +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } -/** - * Set query string targeting on all AST (AppNexus Seller Tag) ad units. Note that this function has to be called after all ad units on page are defined. For working example code, see [Using Prebid.js with AppNexus Publisher Ad Server](http://prebid.org/dev-docs/examples/use-prebid-with-appnexus-ad-server.html). - * @alias module:pbjs.setTargetingForAst - */ -pbjs.setTargetingForAst = function () { - utils.logInfo('Invoking pbjs.setTargetingForAn', arguments); - if (!targeting.isApntagDefined()) { - utils.logError('window.apntag is not defined on the page'); - return; - } +var bidmanager = __webpack_require__(2); +var utils = __webpack_require__(0); +var CONSTANTS = __webpack_require__(3); - targeting.setTargetingForAst(); +var targeting = exports; +var pbTargetingKeys = []; - // emit event - events.emit(SET_TARGETING); +targeting.resetPresetTargeting = function (adUnitCode) { + if ((0, _utils.isGptPubadsDefined)()) { + var adUnitCodes = getAdUnitCodes(adUnitCode); + var adUnits = pbjs.adUnits.filter((function (adUnit) { + return adUnitCodes.includes(adUnit.code); + })); + window.googletag.pubads().getSlots().forEach((function (slot) { + pbTargetingKeys.forEach((function (key) { + // reset only registered adunits + adUnits.forEach((function (unit) { + if (unit.code === slot.getAdUnitPath() || unit.code === slot.getSlotElementId()) { + slot.setTargeting(key, null); + } + })); + })); + })); + } }; -/** - * Returns a bool if all the bids have returned or timed out - * @alias module:pbjs.allBidsAvailable - * @return {bool} all bids available - * - * @deprecated This function will be removed in Prebid 1.0 - * Alternative solution is in progress. - * See https://github.com/prebid/Prebid.js/issues/1087 for more details. - */ -pbjs.allBidsAvailable = function () { - utils.logWarn('pbjs.allBidsAvailable will be removed in Prebid 1.0. Alternative solution is in progress. See https://github.com/prebid/Prebid.js/issues/1087 for more details.'); - utils.logInfo('Invoking pbjs.allBidsAvailable', arguments); - return bidmanager.bidsBackAll(); -}; - -/** - * This function will render the ad (based on params) in the given iframe document passed through. - * Note that doc SHOULD NOT be the parent document page as we can't doc.write() asynchronously - * @param {HTMLDocument} doc document - * @param {string} id bid id to locate the ad - * @alias module:pbjs.renderAd - */ -pbjs.renderAd = function (doc, id) { - utils.logInfo('Invoking pbjs.renderAd', arguments); - utils.logMessage('Calling renderAd with adId :' + id); - if (doc && id) { - try { - // lookup ad by ad Id - var bid = pbjs._bidsReceived.find((function (bid) { - return bid.adId === id; - })); - if (bid) { - // replace macros according to openRTB with price paid = bid.cpm - bid.ad = utils.replaceAuctionPrice(bid.ad, bid.cpm); - bid.adUrl = utils.replaceAuctionPrice(bid.adUrl, bid.cpm); - // save winning bids - pbjs._winningBids.push(bid); - - // emit 'bid won' event here - events.emit(BID_WON, bid); - - var height = bid.height, - width = bid.width, - ad = bid.ad, - mediaType = bid.mediaType, - adUrl = bid.adUrl, - renderer = bid.renderer; - +targeting.getAllTargeting = function (adUnitCode) { + var adUnitCodes = getAdUnitCodes(adUnitCode); - if (renderer && renderer.url) { - renderer.render(bid); - } else if (doc === document && !utils.inIframe() || mediaType === 'video') { - utils.logError('Error trying to write ad. Ad render call ad id ' + id + ' was prevented from writing to the main document.'); - } else if (ad) { - doc.write(ad); - doc.close(); - setRenderSize(doc, width, height); - } else if (adUrl) { - var iframe = utils.createInvisibleIframe(); - iframe.height = height; - iframe.width = width; - iframe.style.display = 'inline'; - iframe.style.overflow = 'hidden'; - iframe.src = adUrl; + // Get targeting for the winning bid. Add targeting for any bids that have + // `alwaysUseBid=true`. If sending all bids is enabled, add targeting for losing bids. + var targeting = getWinningBidTargeting(adUnitCodes).concat(getAlwaysUseBidTargeting(adUnitCodes)).concat(_config.config.getConfig('enableSendAllBids') ? getBidLandscapeTargeting(adUnitCodes) : []); - utils.insertElement(iframe, doc, 'body'); - setRenderSize(doc, width, height); - } else { - utils.logError('Error trying to write ad. No ad for bid response id: ' + id); + // store a reference of the targeting keys + targeting.map((function (adUnitCode) { + Object.keys(adUnitCode).map((function (key) { + adUnitCode[key].map((function (targetKey) { + if (pbTargetingKeys.indexOf(Object.keys(targetKey)[0]) === -1) { + pbTargetingKeys = Object.keys(targetKey).concat(pbTargetingKeys); } - } else { - utils.logError('Error trying to write ad. Cannot find ad by given id : ' + id); - } - } catch (e) { - utils.logError('Error trying to write ad Id :' + id + ' to the page:' + e.message); - } - } else { - utils.logError('Error trying to write ad Id :' + id + ' to the page. Missing document or adId'); - } + })); + })); + })); + return targeting; }; -/** - * Remove adUnit from the pbjs configuration - * @param {string} adUnitCode the adUnitCode to remove - * @alias module:pbjs.removeAdUnit - */ -pbjs.removeAdUnit = function (adUnitCode) { - utils.logInfo('Invoking pbjs.removeAdUnit', arguments); - if (adUnitCode) { - for (var i = 0; i < pbjs.adUnits.length; i++) { - if (pbjs.adUnits[i].code === adUnitCode) { - pbjs.adUnits.splice(i, 1); - } - } - } +targeting.setTargeting = function (targetingConfig) { + window.googletag.pubads().getSlots().forEach((function (slot) { + targetingConfig.filter((function (targeting) { + return Object.keys(targeting)[0] === slot.getAdUnitPath() || Object.keys(targeting)[0] === slot.getSlotElementId(); + })).forEach((function (targeting) { + return targeting[Object.keys(targeting)[0]].forEach((function (key) { + key[Object.keys(key)[0]].map((function (value) { + utils.logMessage('Attempting to set key value for slot: ' + slot.getSlotElementId() + ' key: ' + Object.keys(key)[0] + ' value: ' + value); + return value; + })).forEach((function (value) { + slot.setTargeting(Object.keys(key)[0], value); + })); + })); + })); + })); }; /** - * @alias module:pbjs.clearAuction + * normlizes input to a `adUnit.code` array + * @param {(string|string[])} adUnitCode [description] + * @return {string[]} AdUnit code array */ -pbjs.clearAuction = function () { - auctionRunning = false; - // Only automatically sync if the publisher has not chosen to "enableOverride" - var userSyncConfig = _config.config.getConfig('userSync') || {}; - if (!userSyncConfig.enableOverride) { - // Delay the auto sync by the config delay - syncUsers(userSyncConfig.syncDelay); - } - - utils.logMessage('Prebid auction cleared'); - if (bidRequestQueue.length) { - bidRequestQueue.shift()(); +function getAdUnitCodes(adUnitCode) { + if (typeof adUnitCode === 'string') { + return [adUnitCode]; + } else if (utils.isArray(adUnitCode)) { + return adUnitCode; } -}; + return pbjs._adUnitCodes || []; +} /** - * @param {Object} requestOptions - * @param {function} requestOptions.bidsBackHandler - * @param {number} requestOptions.timeout - * @param {Array} requestOptions.adUnits - * @param {Array} requestOptions.adUnitCodes - * @alias module:pbjs.requestBids + * Returns top bids for a given adUnit or set of adUnits. + * @param {(string|string[])} adUnitCode adUnitCode or array of adUnitCodes + * @return {[type]} [description] */ -pbjs.requestBids = function () { - var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, - bidsBackHandler = _ref4.bidsBackHandler, - timeout = _ref4.timeout, - adUnits = _ref4.adUnits, - adUnitCodes = _ref4.adUnitCodes; - - events.emit('requestBids'); - var cbTimeout = pbjs.cbTimeout = timeout || _config.config.getConfig('bidderTimeout'); - adUnits = adUnits || pbjs.adUnits; - - utils.logInfo('Invoking pbjs.requestBids', arguments); +targeting.getWinningBids = function (adUnitCode) { + var adUnitCodes = getAdUnitCodes(adUnitCode); - if (adUnitCodes && adUnitCodes.length) { - // if specific adUnitCodes supplied filter adUnits for those codes - adUnits = adUnits.filter((function (unit) { - return adUnitCodes.includes(unit.code); - })); - } else { - // otherwise derive adUnitCodes from adUnits - adUnitCodes = adUnits && adUnits.map((function (unit) { - return unit.code; - })); - } + return pbjs._bidsReceived.filter((function (bid) { + return adUnitCodes.includes(bid.adUnitCode); + })).filter((function (bid) { + return bid.cpm > 0; + })).map((function (bid) { + return bid.adUnitCode; + })).filter(_utils.uniques).map((function (adUnitCode) { + return pbjs._bidsReceived.filter((function (bid) { + return bid.adUnitCode === adUnitCode ? bid : null; + })).reduce(_utils.getHighestCpm, getEmptyBid(adUnitCode)); + })); +}; - // for video-enabled adUnits, only request bids for bidders that support video - adUnits.filter(_video.videoAdUnit).filter(_video.hasNonVideoBidder).forEach((function (adUnit) { - var nonVideoBidders = adUnit.bids.filter((function (bid) { - return !(0, _video.videoBidder)(bid); - })).map((function (bid) { - return bid.bidder; +targeting.setTargetingForAst = function () { + var targeting = pbjs.getAdserverTargeting(); + Object.keys(targeting).forEach((function (targetId) { + return Object.keys(targeting[targetId]).forEach((function (key) { + utils.logMessage('Attempting to set targeting for targetId: ' + targetId + ' key: ' + key + ' value: ' + targeting[targetId][key]); + // setKeywords supports string and array as value + if (utils.isStr(targeting[targetId][key]) || utils.isArray(targeting[targetId][key])) { + var keywordsObj = {}; + keywordsObj[key.toUpperCase()] = targeting[targetId][key]; + window.apntag.setKeywords(targetId, keywordsObj); + } })); - - utils.logWarn(utils.unsupportedBidderMessage(adUnit, nonVideoBidders)); - adUnit.bids = adUnit.bids.filter(_video.videoBidder); })); +}; - // for native-enabled adUnits, only request bids for bidders that support native - adUnits.filter(_native.nativeAdUnit).filter(_native.hasNonNativeBidder).forEach((function (adUnit) { - var nonNativeBidders = adUnit.bids.filter((function (bid) { - return !(0, _native.nativeBidder)(bid); - })).map((function (bid) { - return bid.bidder; - })); +function getWinningBidTargeting(adUnitCodes) { + var winners = targeting.getWinningBids(adUnitCodes); + var standardKeys = getStandardKeys(); - utils.logWarn(utils.unsupportedBidderMessage(adUnit, nonNativeBidders)); - adUnit.bids = adUnit.bids.filter(_native.nativeBidder); + winners = winners.map((function (winner) { + return _defineProperty({}, winner.adUnitCode, Object.keys(winner.adserverTargeting).filter((function (key) { + return typeof winner.sendStandardTargeting === 'undefined' || winner.sendStandardTargeting || standardKeys.indexOf(key) === -1; + })).map((function (key) { + return _defineProperty({}, key.substring(0, 20), [winner.adserverTargeting[key]]); + }))); })); - if (auctionRunning) { - bidRequestQueue.push((function () { - pbjs.requestBids({ bidsBackHandler: bidsBackHandler, timeout: cbTimeout, adUnits: adUnits, adUnitCodes: adUnitCodes }); - })); - return; - } + return winners; +} - auctionRunning = true; +function getStandardKeys() { + return bidmanager.getStandardBidderAdServerTargeting() // in case using a custom standard key set + .map((function (targeting) { + return targeting.key; + })).concat(CONSTANTS.TARGETING_KEYS).filter(_utils.uniques); // standard keys defined in the library. +} - // we will use adUnitCodes for filtering the current auction - pbjs._adUnitCodes = adUnitCodes; +/** + * Get custom targeting keys for bids that have `alwaysUseBid=true`. + */ +function getAlwaysUseBidTargeting(adUnitCodes) { + var standardKeys = getStandardKeys(); + return pbjs._bidsReceived.filter(_utils.adUnitsFilter.bind(this, adUnitCodes)).map((function (bid) { + if (bid.alwaysUseBid) { + return _defineProperty({}, bid.adUnitCode, Object.keys(bid.adserverTargeting).map((function (key) { + // Get only the non-standard keys of the losing bids, since we + // don't want to override the standard keys of the winning bid. + if (standardKeys.indexOf(key) > -1) { + return; + } - bidmanager.externalCallbackReset(); - clearPlacements(); - - if (!adUnits || adUnits.length === 0) { - utils.logMessage('No adUnits configured. No bids requested.'); - if (typeof bidsBackHandler === 'function') { - bidmanager.addOneTimeCallback(bidsBackHandler, false); + return _defineProperty({}, key.substring(0, 20), [bid.adserverTargeting[key]]); + })).filter((function (key) { + return key; + }))); } - bidmanager.executeCallback(); - return; - } + })).filter((function (bid) { + return bid; + })); // removes empty elements in array; +} - // set timeout for all bids - var timedOut = true; - var timeoutCallback = bidmanager.executeCallback.bind(bidmanager, timedOut); - var timer = setTimeout(timeoutCallback, cbTimeout); - (0, _ajax.setAjaxTimeout)(cbTimeout); - if (typeof bidsBackHandler === 'function') { - bidmanager.addOneTimeCallback(bidsBackHandler, timer); - } +function getBidLandscapeTargeting(adUnitCodes) { + var standardKeys = CONSTANTS.TARGETING_KEYS.concat(_native.NATIVE_TARGETING_KEYS); + var bids = []; + // bucket by adUnitcode + var buckets = (0, _utils.groupBy)(pbjs._bidsReceived, 'adUnitCode'); + // filter top bid for each bucket by bidder + Object.keys(buckets).forEach((function (bucketKey) { + var bidsByBidder = (0, _utils.groupBy)(buckets[bucketKey], 'bidderCode'); + Object.keys(bidsByBidder).forEach((function (key) { + return bids.push(bidsByBidder[key].reduce(_utils.getHighestCpm, getEmptyBid())); + })); + })); + // populate targeting keys for the remaining bids + return bids.map((function (bid) { + if (bid.adserverTargeting) { + return _defineProperty({}, bid.adUnitCode, getTargetingMap(bid, standardKeys.filter((function (key) { + return typeof bid.adserverTargeting[key] !== 'undefined'; + })))); + } + })).filter((function (bid) { + return bid; + })); // removes empty elements in array +} - adaptermanager.callBids({ adUnits: adUnits, adUnitCodes: adUnitCodes, cbTimeout: cbTimeout }); - if (pbjs._bidsRequested.length === 0) { - bidmanager.executeCallback(); - } -}; +function getTargetingMap(bid, keys) { + return keys.map((function (key) { + return _defineProperty({}, (key + '_' + bid.bidderCode).substring(0, 20), [bid.adserverTargeting[key]]); + })); +} -/** - * - * Add adunit(s) - * @param {Array|Object} adUnitArr Array of adUnits or single adUnit Object. - * @alias module:pbjs.addAdUnits - */ -pbjs.addAdUnits = function (adUnitArr) { - utils.logInfo('Invoking pbjs.addAdUnits', arguments); - if (utils.isArray(adUnitArr)) { - // generate transactionid for each new adUnits - // Append array to existing - adUnitArr.forEach((function (adUnit) { - return adUnit.transactionId = utils.generateUUID(); - })); - pbjs.adUnits.push.apply(pbjs.adUnits, adUnitArr); - } else if ((typeof adUnitArr === 'undefined' ? 'undefined' : _typeof(adUnitArr)) === 'object') { - // Generate the transaction id for the adunit - adUnitArr.transactionId = utils.generateUUID(); - pbjs.adUnits.push(adUnitArr); +targeting.isApntagDefined = function () { + if (window.apntag && utils.isFn(window.apntag.setKeywords)) { + return true; } - // emit event - events.emit(ADD_AD_UNITS); }; -/** - * @param {string} event the name of the event - * @param {Function} handler a callback to set on event - * @param {string} id an identifier in the context of the event - * @alias module:pbjs.onEvent - * - * This API call allows you to register a callback to handle a Prebid.js event. - * An optional `id` parameter provides more finely-grained event callback registration. - * This makes it possible to register callback events for a specific item in the - * event context. For example, `bidWon` events will accept an `id` for ad unit code. - * `bidWon` callbacks registered with an ad unit code id will be called when a bid - * for that ad unit code wins the auction. Without an `id` this method registers the - * callback for every `bidWon` event. - * - * Currently `bidWon` is the only event that accepts an `id` parameter. - */ -pbjs.onEvent = function (event, handler, id) { - utils.logInfo('Invoking pbjs.onEvent', arguments); - if (!utils.isFn(handler)) { - utils.logError('The event handler provided is not a function and was not set on event "' + event + '".'); - return; - } +function getEmptyBid(adUnitCode) { + return { + adUnitCode: adUnitCode, + cpm: 0, + adserverTargeting: {}, + timeToRespond: 0 + }; +} - if (id && !eventValidators[event].call(null, id)) { - utils.logError('The id provided is not valid for event "' + event + '" and no handler was set.'); - return; - } +/***/ }), +/* 28 */ +/***/ (function(module, exports, __webpack_require__) { - events.on(event, handler, id); +var dP = __webpack_require__(398); +var createDesc = __webpack_require__(403); +module.exports = __webpack_require__(29) ? function (object, key, value) { + return dP.f(object, key, createDesc(1, value)); +} : function (object, key, value) { + object[key] = value; + return object; }; -/** - * @param {string} event the name of the event - * @param {Function} handler a callback to remove from the event - * @param {string} id an identifier in the context of the event (see `pbjs.onEvent`) - * @alias module:pbjs.offEvent - */ -pbjs.offEvent = function (event, handler, id) { - utils.logInfo('Invoking pbjs.offEvent', arguments); - if (id && !eventValidators[event].call(null, id)) { - return; - } - events.off(event, handler, id); -}; +/***/ }), +/* 29 */ +/***/ (function(module, exports, __webpack_require__) { -/** - * Add a callback event - * @param {string} eventStr event to attach callback to Options: "allRequestedBidsBack" | "adUnitBidsBack" - * @param {Function} func function to execute. Parameters passed into the function: (bidResObj), [adUnitCode]); - * @alias module:pbjs.addCallback - * @returns {string} id for callback - * - * @deprecated This function will be removed in Prebid 1.0 - * Please use onEvent instead. - */ -pbjs.addCallback = function (eventStr, func) { - utils.logWarn('pbjs.addCallback will be removed in Prebid 1.0. Please use onEvent instead'); - utils.logInfo('Invoking pbjs.addCallback', arguments); - var id = null; - if (!eventStr || !func || typeof func !== 'function') { - utils.logError('error registering callback. Check method signature'); - return id; - } +// Thank's IE8 for his funny defineProperty +module.exports = !__webpack_require__(30)((function () { + return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7; +})); - id = utils.getUniqueIdentifierStr; - bidmanager.addCallback(id, func, eventStr); - return id; -}; -/** - * Remove a callback event - * //@param {string} cbId id of the callback to remove - * @alias module:pbjs.removeCallback - * @returns {string} id for callback - * - * @deprecated This function will be removed in Prebid 1.0 - * Please use offEvent instead. - */ -pbjs.removeCallback = function () /* cbId */{ - // todo - utils.logWarn('pbjs.removeCallback will be removed in Prebid 1.0. Please use offEvent instead.'); - return null; -}; +/***/ }), +/* 30 */ +/***/ (function(module, exports) { -/** - * Wrapper to register bidderAdapter externally (adaptermanager.registerBidAdapter()) - * @param {Function} bidderAdaptor [description] - * @param {string} bidderCode [description] - * @alias module:pbjs.registerBidAdapter - */ -pbjs.registerBidAdapter = function (bidderAdaptor, bidderCode) { - utils.logInfo('Invoking pbjs.registerBidAdapter', arguments); +module.exports = function (exec) { try { - adaptermanager.registerBidAdapter(bidderAdaptor(), bidderCode); + return !!exec(); } catch (e) { - utils.logError('Error registering bidder adapter : ' + e.message); + return true; } }; -/** - * Wrapper to register analyticsAdapter externally (adaptermanager.registerAnalyticsAdapter()) - * @param {Object} options [description] - * @alias module:pbjs.registerAnalyticsAdapter - */ -pbjs.registerAnalyticsAdapter = function (options) { - utils.logInfo('Invoking pbjs.registerAnalyticsAdapter', arguments); - try { - adaptermanager.registerAnalyticsAdapter(options); - } catch (e) { - utils.logError('Error registering analytics adapter : ' + e.message); - } -}; -/** - * @alias module:pbjs.bidsAvailableForAdapter -*/ -pbjs.bidsAvailableForAdapter = function (bidderCode) { - utils.logInfo('Invoking pbjs.bidsAvailableForAdapter', arguments); +/***/ }), +/* 31 */ +/***/ (function(module, exports) { - pbjs._bidsRequested.find((function (bidderRequest) { - return bidderRequest.bidderCode === bidderCode; - })).bids.map((function (bid) { - return _extends(bid, bidfactory.createBid(1), { - bidderCode: bidderCode, - adUnitCode: bid.placementCode - }); - })).map((function (bid) { - return pbjs._bidsReceived.push(bid); - })); +var id = 0; +var px = Math.random(); +module.exports = function (key) { + return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); }; -/** - * Wrapper to bidfactory.createBid() - * @param {string} statusCode [description] - * @alias module:pbjs.createBid - * @return {Object} bidResponse [description] - */ -pbjs.createBid = function (statusCode) { - utils.logInfo('Invoking pbjs.createBid', arguments); - return bidfactory.createBid(statusCode); -}; -/** - * Wrapper to bidmanager.addBidResponse - * @param {string} adUnitCode [description] - * @param {Object} bid [description] - * @alias module:pbjs.addBidResponse - * @deprecated This function will be removed in Prebid 1.0 - * Each bidder will be passed a reference to addBidResponse function in callBids as an argument. - * See https://github.com/prebid/Prebid.js/issues/1087 for more details. - */ -pbjs.addBidResponse = function (adUnitCode, bid) { - utils.logWarn('pbjs.addBidResponse will be removed in Prebid 1.0. Each bidder will be passed a reference to addBidResponse function in callBids as an argument. See https://github.com/prebid/Prebid.js/issues/1087 for more details.'); - utils.logInfo('Invoking pbjs.addBidResponse', arguments); - bidmanager.addBidResponse(adUnitCode, bid); +/***/ }), +/* 32 */ +/***/ (function(module, exports, __webpack_require__) { + +// fallback for non-array-like ES3 and non-enumerable old V8 strings +var cof = __webpack_require__(49); +// eslint-disable-next-line no-prototype-builtins +module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) { + return cof(it) == 'String' ? it.split('') : Object(it); }; -/** - * Wrapper to adloader.loadScript - * @param {string} tagSrc [description] - * @param {Function} callback [description] - * @alias module:pbjs.loadScript - */ -pbjs.loadScript = function (tagSrc, callback, useCache) { - utils.logInfo('Invoking pbjs.loadScript', arguments); - (0, _adloader.loadScript)(tagSrc, callback, useCache); + +/***/ }), +/* 33 */ +/***/ (function(module, exports, __webpack_require__) { + +// 22.1.3.31 Array.prototype[@@unscopables] +var UNSCOPABLES = __webpack_require__(54)('unscopables'); +var ArrayProto = Array.prototype; +if (ArrayProto[UNSCOPABLES] == undefined) __webpack_require__(28)(ArrayProto, UNSCOPABLES, {}); +module.exports = function (key) { + ArrayProto[UNSCOPABLES][key] = true; +}; + + +/***/ }), +/* 34 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +var utils = __webpack_require__(0); + +var _defaultPrecision = 2; +var _lgPriceConfig = { + 'buckets': [{ + 'min': 0, + 'max': 5, + 'increment': 0.5 + }] +}; +var _mgPriceConfig = { + 'buckets': [{ + 'min': 0, + 'max': 20, + 'increment': 0.1 + }] +}; +var _hgPriceConfig = { + 'buckets': [{ + 'min': 0, + 'max': 20, + 'increment': 0.01 + }] +}; +var _densePriceConfig = { + 'buckets': [{ + 'min': 0, + 'max': 3, + 'increment': 0.01 + }, { + 'min': 3, + 'max': 8, + 'increment': 0.05 + }, { + 'min': 8, + 'max': 20, + 'increment': 0.5 + }] +}; +var _autoPriceConfig = { + 'buckets': [{ + 'min': 0, + 'max': 5, + 'increment': 0.05 + }, { + 'min': 5, + 'max': 10, + 'increment': 0.1 + }, { + 'min': 10, + 'max': 20, + 'increment': 0.5 + }] }; +function getPriceBucketString(cpm, customConfig) { + var granularityMultiplier = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; + + var cpmFloat = parseFloat(cpm); + if (isNaN(cpmFloat)) { + cpmFloat = ''; + } + + return { + low: cpmFloat === '' ? '' : getCpmStringValue(cpm, _lgPriceConfig, granularityMultiplier), + med: cpmFloat === '' ? '' : getCpmStringValue(cpm, _mgPriceConfig, granularityMultiplier), + high: cpmFloat === '' ? '' : getCpmStringValue(cpm, _hgPriceConfig, granularityMultiplier), + auto: cpmFloat === '' ? '' : getCpmStringValue(cpm, _autoPriceConfig, granularityMultiplier), + dense: cpmFloat === '' ? '' : getCpmStringValue(cpm, _densePriceConfig, granularityMultiplier), + custom: cpmFloat === '' ? '' : getCpmStringValue(cpm, customConfig, granularityMultiplier) + }; +} + +function getCpmStringValue(cpm, config, granularityMultiplier) { + var cpmStr = ''; + if (!isValidPriceConfig(config)) { + return cpmStr; + } + var cap = config.buckets.reduce((function (prev, curr) { + if (prev.max > curr.max) { + return prev; + } + return curr; + }), { + 'max': 0 + }); + var bucket = config.buckets.find((function (bucket) { + if (cpm > cap.max * granularityMultiplier) { + // cpm exceeds cap, just return the cap. + var precision = bucket.precision; + if (typeof precision === 'undefined') { + precision = _defaultPrecision; + } + cpmStr = (bucket.max * granularityMultiplier).toFixed(precision); + } else if (cpm <= bucket.max * granularityMultiplier && cpm >= bucket.min * granularityMultiplier) { + return bucket; + } + })); + if (bucket) { + cpmStr = getCpmTarget(cpm, bucket.increment, bucket.precision, granularityMultiplier); + } + return cpmStr; +} + +function isValidPriceConfig(config) { + if (utils.isEmpty(config) || !config.buckets || !Array.isArray(config.buckets)) { + return false; + } + var isValid = true; + config.buckets.forEach((function (bucket) { + if (typeof bucket.min === 'undefined' || !bucket.max || !bucket.increment) { + isValid = false; + } + })); + return isValid; +} + +function getCpmTarget(cpm, increment, precision, granularityMultiplier) { + if (typeof precision === 'undefined') { + precision = _defaultPrecision; + } + var bucketSize = 1 / (increment * granularityMultiplier); + return (Math.floor(cpm * bucketSize) / bucketSize).toFixed(precision); +} + +exports.getPriceBucketString = getPriceBucketString; +exports.isValidPriceConfig = isValidPriceConfig; + +/***/ }), +/* 35 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.hasNonVideoBidder = exports.videoBidder = exports.videoAdUnit = undefined; +exports.isValidVideoBid = isValidVideoBid; + +var _adaptermanager = __webpack_require__(1); + +var _utils = __webpack_require__(0); + +var _config = __webpack_require__(8); + +var VIDEO_MEDIA_TYPE = 'video'; +var OUTSTREAM = 'outstream'; + /** - * Enable sending analytics data to the analytics provider of your - * choice. - * - * For usage, see [Integrate with the Prebid Analytics - * API](http://prebid.org/dev-docs/integrate-with-the-prebid-analytics-api.html). - * - * For a list of analytics adapters, see [Analytics for - * Prebid](http://prebid.org/overview/analytics.html). - * @param {Object} config - * @param {string} config.provider The name of the provider, e.g., `"ga"` for Google Analytics. - * @param {Object} config.options The options for this particular analytics adapter. This will likely vary between adapters. - * @alias module:pbjs.enableAnalytics + * Helper functions for working with video-enabled adUnits */ -pbjs.enableAnalytics = function (config) { - if (config && !utils.isEmpty(config)) { - utils.logInfo('Invoking pbjs.enableAnalytics for: ', config); - adaptermanager.enableAnalytics(config); - } else { - utils.logError('pbjs.enableAnalytics should be called with option {}'); - } +var videoAdUnit = exports.videoAdUnit = function videoAdUnit(adUnit) { + var mediaType = adUnit.mediaType === VIDEO_MEDIA_TYPE; + var mediaTypes = (0, _utils.deepAccess)(adUnit, 'mediaTypes.video'); + return mediaType || mediaTypes; +}; +var videoBidder = exports.videoBidder = function videoBidder(bid) { + return _adaptermanager.videoAdapters.includes(bid.bidder); +}; +var hasNonVideoBidder = exports.hasNonVideoBidder = function hasNonVideoBidder(adUnit) { + return adUnit.bids.filter((function (bid) { + return !videoBidder(bid); + })).length; }; /** - * @alias module:pbjs.aliasBidder + * @typedef {object} VideoBid + * @property {string} adId id of the bid */ -pbjs.aliasBidder = function (bidderCode, alias) { - utils.logInfo('Invoking pbjs.aliasBidder', arguments); - if (bidderCode && alias) { - adaptermanager.aliasBidAdapter(bidderCode, alias); - } else { - utils.logError('bidderCode and alias must be passed as arguments', 'pbjs.aliasBidder'); - } -}; /** - * Sets a default price granularity scheme. - * @param {string|Object} granularity - the granularity scheme. - * @alias module:pbjs.setPriceGranularity - * @deprecated - use pbjs.setConfig({ priceGranularity: }) - * "low": $0.50 increments, capped at $5 CPM - * "medium": $0.10 increments, capped at $20 CPM (the default) - * "high": $0.01 increments, capped at $20 CPM - * "auto": Applies a sliding scale to determine granularity - * "dense": Like "auto", but the bid price granularity uses smaller increments, especially at lower CPMs - * - * Alternatively a custom object can be specified: - * { "buckets" : [{"min" : 0,"max" : 20,"increment" : 0.1,"cap" : true}]}; - * See http://prebid.org/dev-docs/publisher-api-reference.html#module_pbjs.setPriceGranularity for more details + * Validate that the assets required for video context are present on the bid + * @param {VideoBid} bid video bid to validate + * @return {boolean} If object is valid */ -pbjs.setPriceGranularity = function (granularity) { - utils.logWarn('pbjs.setPriceGranularity will be removed in Prebid 1.0. Use pbjs.setConfig({ priceGranularity: }) instead.'); - utils.logInfo('Invoking pbjs.setPriceGranularity', arguments); - _config.config.setConfig({ priceGranularity: granularity }); +function isValidVideoBid(bid) { + var bidRequest = (0, _utils.getBidRequest)(bid.adId); + + var videoMediaType = bidRequest && (0, _utils.deepAccess)(bidRequest, 'mediaTypes.video'); + var context = videoMediaType && (0, _utils.deepAccess)(videoMediaType, 'context'); + + // if context not defined assume default 'instream' for video bids + // instream bids require a vast url or vast xml content + if (!bidRequest || videoMediaType && context !== OUTSTREAM) { + // xml-only video bids require prebid-cache to be enabled + if (!_config.config.getConfig('usePrebidCache') && bid.vastXml && !bid.vastUrl) { + (0, _utils.logError)('\n This bid contains only vastXml and will not work when prebid-cache is disabled.\n Try enabling prebid-cache with pbjs.setConfig({ usePrebidCache: true });\n '); + return false; + } + + return !!(bid.vastUrl || bid.vastXml); + } + + // outstream bids require a renderer on the bid or pub-defined on adunit + if (context === OUTSTREAM) { + return !!(bid.renderer || bidRequest.renderer); + } + + return true; +} + +/***/ }), +/* 36 */ +/***/ (function(module, exports, __webpack_require__) { + +// optional / simple context binding +var aFunction = __webpack_require__(101); +module.exports = function (fn, that, length) { + aFunction(fn); + if (that === undefined) return fn; + switch (length) { + case 1: return function (a) { + return fn.call(that, a); + }; + case 2: return function (a, b) { + return fn.call(that, a, b); + }; + case 3: return function (a, b, c) { + return fn.call(that, a, b, c); + }; + } + return function (/* ...args */) { + return fn.apply(that, arguments); + }; +}; + + +/***/ }), +/* 37 */ +/***/ (function(module, exports) { + +module.exports = function (exec) { + try { + return !!exec(); + } catch (e) { + return true; + } }; -/** - * @alias module:pbjs.enableSendAllBids - * @deprecated - use pbjs.setConfig({ enableSendAllBids: }) -*/ -pbjs.enableSendAllBids = function () { - _config.config.setConfig({ enableSendAllBids: true }); + +/***/ }), +/* 38 */, +/* 39 */ +/***/ (function(module, exports, __webpack_require__) { + +// fallback for non-array-like ES3 and non-enumerable old V8 strings +var cof = __webpack_require__(40); +// eslint-disable-next-line no-prototype-builtins +module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) { + return cof(it) == 'String' ? it.split('') : Object(it); }; -/** - * @alias module:pbjs.getAllWinningBids - * The bid response object returned by an external bidder adapter during the auction. - * @typedef {Object} AdapterBidResponse - * @property {string} pbAg Auto granularity price bucket; CPM <= 5 ? increment = 0.05 : CPM > 5 && CPM <= 10 ? increment = 0.10 : CPM > 10 && CPM <= 20 ? increment = 0.50 : CPM > 20 ? priceCap = 20.00. Example: `"0.80"`. - * @property {string} pbCg Custom price bucket. For example setup, see {@link setPriceGranularity}. Example: `"0.84"`. - * @property {string} pbDg Dense granularity price bucket; CPM <= 3 ? increment = 0.01 : CPM > 3 && CPM <= 8 ? increment = 0.05 : CPM > 8 && CPM <= 20 ? increment = 0.50 : CPM > 20? priceCap = 20.00. Example: `"0.84"`. - * @property {string} pbLg Low granularity price bucket; $0.50 increment, capped at $5, floored to two decimal places. Example: `"0.50"`. - * @property {string} pbMg Medium granularity price bucket; $0.10 increment, capped at $20, floored to two decimal places. Example: `"0.80"`. - * @property {string} pbHg High granularity price bucket; $0.01 increment, capped at $20, floored to two decimal places. Example: `"0.84"`. - * - * @property {string} bidder The string name of the bidder. This *may* be the same as the `bidderCode`. For For a list of all bidders and their codes, see [Bidders' Params](http://prebid.org/dev-docs/bidders.html). - * @property {string} bidderCode The unique string that identifies this bidder. For a list of all bidders and their codes, see [Bidders' Params](http://prebid.org/dev-docs/bidders.html). - * - * @property {string} requestId The [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier) representing the bid request. - * @property {number} requestTimestamp The time at which the bid request was sent out, expressed in milliseconds. - * @property {number} responseTimestamp The time at which the bid response was received, expressed in milliseconds. - * @property {number} timeToRespond How long it took for the bidder to respond with this bid, expressed in milliseconds. - * - * @property {string} size The size of the ad creative, expressed in `"AxB"` format, where A and B are numbers of pixels. Example: `"320x50"`. - * @property {string} width The width of the ad creative in pixels. Example: `"320"`. - * @property {string} height The height of the ad creative in pixels. Example: `"50"`. - * - * @property {string} ad The actual ad creative content, often HTML with CSS, JavaScript, and/or links to additional content. Example: `"",`. - * @property {number} ad_id The ad ID of the creative, as understood by the bidder's system. Used by the line item's [creative in the ad server](http://prebid.org/adops/send-all-bids-adops.html#step-3-add-a-creative). - * @property {string} adUnitCode The code used to uniquely identify the ad unit on the publisher's page. - * - * @property {string} statusMessage The status of the bid. Allowed values: `"Bid available"` or `"Bid returned empty or error response"`. - * @property {number} cpm The exact bid price from the bidder, expressed to the thousandths place. Example: `"0.849"`. - * - * @property {Object} adserverTargeting An object whose values represent the ad server's targeting on the bid. - * @property {string} adserverTargeting.hb_adid The ad ID of the creative, as understood by the ad server. - * @property {string} adserverTargeting.hb_pb The price paid to show the creative, as logged in the ad server. - * @property {string} adserverTargeting.hb_bidder The winning bidder whose ad creative will be served by the ad server. -*/ -/** - * Get all of the bids that have won their respective auctions. Useful for [troubleshooting your integration](http://prebid.org/dev-docs/prebid-troubleshooting-guide.html). - * @return {Array} A list of bids that have won their respective auctions. -*/ -pbjs.getAllWinningBids = function () { - return pbjs._winningBids; +/***/ }), +/* 40 */ +/***/ (function(module, exports) { + +var toString = {}.toString; + +module.exports = function (it) { + return toString.call(it).slice(8, -1); }; -/** - * Build master video tag from publishers adserver tag - * @param {string} adserverTag default url - * @param {Object} options options for video tag - * @alias module:pbjs.buildMasterVideoTagFromAdserverTag - * @deprecated Include the dfpVideoSupport module in your build, and use the pbjs.adservers.dfp.buildVideoAdUrl function instead. - * This function will be removed in Prebid 1.0. - */ -pbjs.buildMasterVideoTagFromAdserverTag = function (adserverTag, options) { - utils.logWarn('pbjs.buildMasterVideoTagFromAdserverTag will be removed in Prebid 1.0. Include the dfpVideoSupport module in your build, and use the pbjs.adservers.dfp.buildVideoAdUrl function instead'); - utils.logInfo('Invoking pbjs.buildMasterVideoTagFromAdserverTag', arguments); - var urlComponents = (0, _url.parse)(adserverTag); - // return original adserverTag if no bids received - if (pbjs._bidsReceived.length === 0) { - return adserverTag; - } +/***/ }), +/* 41 */ +/***/ (function(module, exports) { - var masterTag = ''; - if (options.adserver.toLowerCase() === 'dfp') { - var dfpAdserverObj = adserver.dfpAdserver(options, urlComponents); - if (!dfpAdserverObj.verifyAdserverTag()) { - utils.logError('Invalid adserverTag, required google params are missing in query string'); - } - dfpAdserverObj.appendQueryParams(); - masterTag = (0, _url.format)(dfpAdserverObj.urlComponents); - } else { - utils.logError('Only DFP adserver is supported'); - return; - } - return masterTag; +// 7.2.1 RequireObjectCoercible(argument) +module.exports = function (it) { + if (it == undefined) throw TypeError("Can't call method on " + it); + return it; }; -/** - * Set the order bidders are called in. Valid values are: - * - * "fixed": Bidders will be called in the order in which they were defined within the adUnit.bids array. - * "random": Bidders will be called in random order. - * - * If never called, Prebid will use "random" as the default. - * - * @param {string} order One of the valid orders, described above. - * @alias module:pbjs.setBidderSequence - * @deprecated - use pbjs.setConfig({ bidderSequence: }) - */ -pbjs.setBidderSequence = adaptermanager.setBidderSequence; -/** - * Get array of highest cpm bids for all adUnits, or highest cpm bid - * object for the given adUnit - * @param {string} adUnitCode - optional ad unit code - * @alias module:pbjs.getHighestCpmBids - * @return {Array} array containing highest cpm bid object(s) - */ -pbjs.getHighestCpmBids = function (adUnitCode) { - return targeting.getWinningBids(adUnitCode); +/***/ }), +/* 42 */ +/***/ (function(module, exports, __webpack_require__) { + +// 7.1.15 ToLength +var toInteger = __webpack_require__(43); +var min = Math.min; +module.exports = function (it) { + return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 }; -/** - * Set config for server to server header bidding - * @deprecated - use pbjs.setConfig({ s2sConfig: }) - * @typedef {Object} options - required - * @property {boolean} enabled enables S2S bidding - * @property {string[]} bidders bidders to request S2S - * === optional params below === - * @property {string} [endpoint] endpoint to contact - * @property {number} [timeout] timeout for S2S bidders - should be lower than `pbjs.requestBids({timeout})` - * @property {string} [adapter] adapter code to use for S2S - * @property {string} [syncEndpoint] endpoint URL for syncing cookies - * @property {boolean} [cookieSet] enables cookieSet functionality - * @alias module:pbjs.setS2SConfig - */ -pbjs.setS2SConfig = function (options) { - if (!utils.contains(Object.keys(options), 'accountId')) { - utils.logError('accountId missing in Server to Server config'); - return; - } - if (!utils.contains(Object.keys(options), 'bidders')) { - utils.logError('bidders missing in Server to Server config'); - return; - } +/***/ }), +/* 43 */ +/***/ (function(module, exports) { - var config = _extends({ - enabled: false, - endpoint: CONSTANTS.S2S.DEFAULT_ENDPOINT, - timeout: 1000, - maxBids: 1, - adapter: CONSTANTS.S2S.ADAPTER, - syncEndpoint: CONSTANTS.S2S.SYNC_ENDPOINT, - cookieSet: true, - bidders: [] - }, options); - adaptermanager.setS2SConfig(config); +// 7.1.4 ToInteger +var ceil = Math.ceil; +var floor = Math.floor; +module.exports = function (it) { + return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); }; -/** - * Get Prebid config options - * @param {Object} options - * @alias module:pbjs.getConfig - */ -pbjs.getConfig = _config.config.getConfig; -/** - * Set Prebid config options. - * (Added in version 0.27.0). - * - * `setConfig` is designed to allow for advanced configuration while - * reducing the surface area of the public API. For more information - * about the move to `setConfig` (and the resulting deprecations of - * some other public methods), see [the Prebid 1.0 public API - * proposal](https://gist.github.com/mkendall07/51ee5f6b9f2df01a89162cf6de7fe5b6). - * - * #### Troubleshooting your configuration - * - * If you call `pbjs.setConfig` without an object, e.g., - * - * `pbjs.setConfig('debug', 'true'))` - * - * then Prebid.js will print an error to the console that says: - * - * ``` - * ERROR: setConfig options must be an object - * ``` - * - * If you don't see that message, you can assume the config object is valid. - * - * @param {Object} options Global Prebid configuration object. Must be JSON - no JavaScript functions are allowed. - * @param {string} options.bidderSequence The order in which bidders are called. Example: `pbjs.setConfig({ bidderSequence: "fixed" })`. Allowed values: `"fixed"` (order defined in `adUnit.bids` array on page), `"random"`. - * @param {boolean} options.debug Turn debug logging on/off. Example: `pbjs.setConfig({ debug: true })`. - * @param {string} options.priceGranularity The bid price granularity to use. Example: `pbjs.setConfig({ priceGranularity: "medium" })`. Allowed values: `"low"` ($0.50), `"medium"` ($0.10), `"high"` ($0.01), `"auto"` (sliding scale), `"dense"` (like `"auto"`, with smaller increments at lower CPMs), or a custom price bucket object, e.g., `{ "buckets" : [{"min" : 0,"max" : 20,"increment" : 0.1,"cap" : true}]}`. - * @param {boolean} options.enableSendAllBids Turn "send all bids" mode on/off. Example: `pbjs.setConfig({ enableSendAllBids: true })`. - * @param {number} options.bidderTimeout Set a global bidder timeout, in milliseconds. Example: `pbjs.setConfig({ bidderTimeout: 3000 })`. Note that it's still possible for a bid to get into the auction that responds after this timeout. This is due to how [`setTimeout`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout) works in JS: it queues the callback in the event loop in an approximate location that should execute after this time but it is not guaranteed. For more information about the asynchronous event loop and `setTimeout`, see [How JavaScript Timers Work](https://johnresig.com/blog/how-javascript-timers-work/). - * @param {string} options.publisherDomain The publisher's domain where Prebid is running, for cross-domain iFrame communication. Example: `pbjs.setConfig({ publisherDomain: "https://www.theverge.com" })`. - * @param {number} options.cookieSyncDelay A delay (in milliseconds) for requesting cookie sync to stay out of the critical path of page load. Example: `pbjs.setConfig({ cookieSyncDelay: 100 })`. - * @param {Object} options.s2sConfig The configuration object for [server-to-server header bidding](http://prebid.org/dev-docs/get-started-with-prebid-server.html). Example: - * @alias module:pbjs.setConfig - * ``` - * pbjs.setConfig({ - * s2sConfig: { - * accountId: '1', - * enabled: true, - * bidders: ['appnexus', 'pubmatic'], - * timeout: 1000, - * adapter: 'prebidServer', - * endpoint: 'https://prebid.adnxs.com/pbs/v1/auction' - * } - * }) - * ``` - */ -pbjs.setConfig = _config.config.setConfig; +/***/ }), +/* 44 */ +/***/ (function(module, exports) { + +var g; + +// This works in non-strict mode +g = (function() { + return this; +})(); + +try { + // This works if eval is allowed (see CSP) + g = g || Function("return this")() || (1,eval)("this"); +} catch(e) { + // This works if the window reference is available + if(typeof window === "object") + g = window; +} + +// g can still be undefined, but nothing to do about it... +// We return undefined, instead of nothing here, so it's +// easier to handle this case. if(!global) { ...} + +module.exports = g; + + +/***/ }), +/* 45 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.getGlobal = getGlobal; +// if pbjs already exists in global document scope, use it, if not, create the object +// global defination should happen BEFORE imports to avoid global undefined errors. +window.pbjs = window.pbjs || {}; +window.pbjs.cmd = window.pbjs.cmd || []; +window.pbjs.que = window.pbjs.que || []; -pbjs.que.push((function () { - return (0, _secureCreatives.listenMessagesFromCreative)(); -})); +function getGlobal() { + return window.pbjs; +} -/** - * This queue lets users load Prebid asynchronously, but run functions the same way regardless of whether it gets loaded - * before or after their script executes. For example, given the code: - * - * - * - * - * If the page's script runs before prebid loads, then their function gets added to the queue, and executed - * by prebid once it's done loading. If it runs after prebid loads, then this monkey-patch causes their - * function to execute immediately. - * - * @memberof pbjs - * @param {function} command A function which takes no arguments. This is guaranteed to run exactly once, and only after - * the Prebid script has been fully loaded. - * @alias module:pbjs.cmd.push - */ -pbjs.cmd.push = function (command) { - if (typeof command === 'function') { - try { - command.call(); - } catch (e) { - utils.logError('Error processing command :', e.message, e.stack); - } - } else { - utils.logError('Commands written into pbjs.cmd.push must be wrapped in a function'); +/***/ }), +/* 46 */ +/***/ (function(module, exports) { + +var hasOwnProperty = {}.hasOwnProperty; +module.exports = function (it, key) { + return hasOwnProperty.call(it, key); +}; + + +/***/ }), +/* 47 */ +/***/ (function(module, exports, __webpack_require__) { + +// optional / simple context binding +var aFunction = __webpack_require__(405); +module.exports = function (fn, that, length) { + aFunction(fn); + if (that === undefined) return fn; + switch (length) { + case 1: return function (a) { + return fn.call(that, a); + }; + case 2: return function (a, b) { + return fn.call(that, a, b); + }; + case 3: return function (a, b, c) { + return fn.call(that, a, b, c); + }; } + return function (/* ...args */) { + return fn.apply(that, arguments); + }; }; -pbjs.que.push = pbjs.cmd.push; -function processQueue(queue) { - queue.forEach((function (cmd) { - if (typeof cmd.called === 'undefined') { - try { - cmd.call(); - cmd.called = true; - } catch (e) { - utils.logError('Error processing command :', 'prebid.js', e); +/***/ }), +/* 48 */ +/***/ (function(module, exports, __webpack_require__) { + +// 0 -> Array#forEach +// 1 -> Array#map +// 2 -> Array#filter +// 3 -> Array#some +// 4 -> Array#every +// 5 -> Array#find +// 6 -> Array#findIndex +var ctx = __webpack_require__(47); +var IObject = __webpack_require__(32); +var toObject = __webpack_require__(50); +var toLength = __webpack_require__(52); +var asc = __webpack_require__(406); +module.exports = function (TYPE, $create) { + var IS_MAP = TYPE == 1; + var IS_FILTER = TYPE == 2; + var IS_SOME = TYPE == 3; + var IS_EVERY = TYPE == 4; + var IS_FIND_INDEX = TYPE == 6; + var NO_HOLES = TYPE == 5 || IS_FIND_INDEX; + var create = $create || asc; + return function ($this, callbackfn, that) { + var O = toObject($this); + var self = IObject(O); + var f = ctx(callbackfn, that, 3); + var length = toLength(self.length); + var index = 0; + var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined; + var val, res; + for (;length > index; index++) if (NO_HOLES || index in self) { + val = self[index]; + res = f(val, index, O); + if (TYPE) { + if (IS_MAP) result[index] = res; // map + else if (res) switch (TYPE) { + case 3: return true; // some + case 5: return val; // find + case 6: return index; // findIndex + case 2: result.push(val); // filter + } else if (IS_EVERY) return false; // every } } - })); -} - -/** - * @alias module:pbjs.processQueue - */ -pbjs.processQueue = function () { - processQueue(pbjs.que); - processQueue(pbjs.cmd); + return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result; + }; }; + /***/ }), +/* 49 */ +/***/ (function(module, exports) { -/***/ 341: -/***/ (function(module, exports, __webpack_require__) { +var toString = {}.toString; -"use strict"; +module.exports = function (it) { + return toString.call(it).slice(8, -1); +}; -/** @module polyfill -Misc polyfills -*/ -__webpack_require__(342); -__webpack_require__(355); -__webpack_require__(357); -__webpack_require__(360); +/***/ }), +/* 50 */ +/***/ (function(module, exports, __webpack_require__) { -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger -Number.isInteger = Number.isInteger || function (value) { - return typeof value === 'number' && isFinite(value) && Math.floor(value) === value; +// 7.1.13 ToObject(argument) +var defined = __webpack_require__(51); +module.exports = function (it) { + return Object(defined(it)); }; + /***/ }), +/* 51 */ +/***/ (function(module, exports) { -/***/ 342: +// 7.2.1 RequireObjectCoercible(argument) +module.exports = function (it) { + if (it == undefined) throw TypeError("Can't call method on " + it); + return it; +}; + + +/***/ }), +/* 52 */ /***/ (function(module, exports, __webpack_require__) { -__webpack_require__(343); -module.exports = __webpack_require__(14).Array.find; +// 7.1.15 ToLength +var toInteger = __webpack_require__(53); +var min = Math.min; +module.exports = function (it) { + return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 +}; /***/ }), +/* 53 */ +/***/ (function(module, exports) { + +// 7.1.4 ToInteger +var ceil = Math.ceil; +var floor = Math.floor; +module.exports = function (it) { + return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); +}; -/***/ 343: + +/***/ }), +/* 54 */ /***/ (function(module, exports, __webpack_require__) { -"use strict"; +var store = __webpack_require__(55)('wks'); +var uid = __webpack_require__(31); +var Symbol = __webpack_require__(16).Symbol; +var USE_SYMBOL = typeof Symbol == 'function'; -// 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined) -var $export = __webpack_require__(19); -var $find = __webpack_require__(34)(5); -var KEY = 'find'; -var forced = true; -// Shouldn't skip holes -if (KEY in []) Array(1)[KEY]((function () { forced = false; })); -$export($export.P + $export.F * forced, 'Array', { - find: function find(callbackfn /* , that = undefined */) { - return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); - } -}); -__webpack_require__(27)(KEY); +var $exports = module.exports = function (name) { + return store[name] || (store[name] = + USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name)); +}; + +$exports.store = store; /***/ }), +/* 55 */ +/***/ (function(module, exports, __webpack_require__) { + +var global = __webpack_require__(16); +var SHARED = '__core-js_shared__'; +var store = global[SHARED] || (global[SHARED] = {}); +module.exports = function (key) { + return store[key] || (store[key] = {}); +}; + -/***/ 344: +/***/ }), +/* 56 */ /***/ (function(module, exports, __webpack_require__) { -var anObject = __webpack_require__(345); -var IE8_DOM_DEFINE = __webpack_require__(346); -var toPrimitive = __webpack_require__(348); -var dP = Object.defineProperty; +// false -> Array#indexOf +// true -> Array#includes +var toIObject = __webpack_require__(57); +var toLength = __webpack_require__(52); +var toAbsoluteIndex = __webpack_require__(413); +module.exports = function (IS_INCLUDES) { + return function ($this, el, fromIndex) { + var O = toIObject($this); + var length = toLength(O.length); + var index = toAbsoluteIndex(fromIndex, length); + var value; + // Array#includes uses SameValueZero equality algorithm + // eslint-disable-next-line no-self-compare + if (IS_INCLUDES && el != el) while (length > index) { + value = O[index++]; + // eslint-disable-next-line no-self-compare + if (value != value) return true; + // Array#indexOf ignores holes, Array#includes - not + } else for (;length > index; index++) if (IS_INCLUDES || index in O) { + if (O[index] === el) return IS_INCLUDES || index || 0; + } return !IS_INCLUDES && -1; + }; +}; -exports.f = __webpack_require__(23) ? Object.defineProperty : function defineProperty(O, P, Attributes) { - anObject(O); - P = toPrimitive(P, true); - anObject(Attributes); - if (IE8_DOM_DEFINE) try { - return dP(O, P, Attributes); - } catch (e) { /* empty */ } - if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!'); - if ('value' in Attributes) O[P] = Attributes.value; - return O; + +/***/ }), +/* 57 */ +/***/ (function(module, exports, __webpack_require__) { + +// to indexed object, toObject with fallback for non-array-like ES3 strings +var IObject = __webpack_require__(32); +var defined = __webpack_require__(51); +module.exports = function (it) { + return IObject(defined(it)); }; /***/ }), - -/***/ 345: +/* 58 */, +/* 59 */, +/* 60 */ +/***/ (function(module, exports) { + +module.exports = clone; + +/* + Identical to `just-extend(true, {}, obj1)` + + var arr = [1, 2, 3]; + var subObj = {aa: 1}; + var obj = {a: 3, b: 5, c: arr, d: subObj}; + var objClone = clone(obj); + arr.push(4); + subObj.bb = 2; + obj; // {a: 3, b: 5, c: [1, 2, 3, 4], d: {aa: 1}} + objClone; // {a: 3, b: 5, c: [1, 2, 3], d: {aa: 1, bb: 2}} +*/ + +function clone(obj) { + var result = Array.isArray(obj) ? [] : {}; + for (var key in obj) { + // include prototype properties + var value = obj[key]; + if (value && typeof value == 'object') { + result[key] = clone(value); + } else { + result[key] = value; + } + } + return result; +} + + +/***/ }), +/* 61 */ /***/ (function(module, exports, __webpack_require__) { -var isObject = __webpack_require__(20); -module.exports = function (it) { - if (!isObject(it)) throw TypeError(it + ' is not an object!'); - return it; -}; +"use strict"; -/***/ }), +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.setWindow = exports.getScreenWidth = exports.mapSizes = undefined; -/***/ 346: -/***/ (function(module, exports, __webpack_require__) { +var _utils = __webpack_require__(0); -module.exports = !__webpack_require__(23) && !__webpack_require__(24)((function () { - return Object.defineProperty(__webpack_require__(347)('div'), 'a', { get: function () { return 7; } }).a != 7; -})); +var utils = _interopRequireWildcard(_utils); +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } } -/***/ }), +var _win = void 0; /** + * @module sizeMapping + */ -/***/ 347: -/***/ (function(module, exports, __webpack_require__) { -var isObject = __webpack_require__(20); -var document = __webpack_require__(16).document; -// typeof document.createElement is 'object' in old IE -var is = isObject(document) && isObject(document.createElement); -module.exports = function (it) { - return is ? document.createElement(it) : {}; -}; +function mapSizes(adUnit) { + if (!isSizeMappingValid(adUnit.sizeMapping)) { + return adUnit.sizes; + } + var width = getScreenWidth(); + if (!width) { + // size not detected - get largest value set for desktop + var _mapping = adUnit.sizeMapping.reduce((function (prev, curr) { + return prev.minWidth < curr.minWidth ? curr : prev; + })); + if (_mapping.sizes && _mapping.sizes.length) { + return _mapping.sizes; + } + return adUnit.sizes; + } + var sizes = ''; + var mapping = adUnit.sizeMapping.find((function (sizeMapping) { + return width >= sizeMapping.minWidth; + })); + if (mapping && mapping.sizes && mapping.sizes.length) { + sizes = mapping.sizes; + utils.logMessage('AdUnit : ' + adUnit.code + ' resized based on device width to : ' + sizes); + } else { + utils.logMessage('AdUnit : ' + adUnit.code + ' not mapped to any sizes for device width. This request will be suppressed.'); + } + return sizes; +} +function isSizeMappingValid(sizeMapping) { + if (utils.isArray(sizeMapping) && sizeMapping.length > 0) { + return true; + } + utils.logInfo('No size mapping defined'); + return false; +} -/***/ }), +function getScreenWidth(win) { + var w = win || _win || window; + var d = w.document; -/***/ 348: -/***/ (function(module, exports, __webpack_require__) { + if (w.innerWidth) { + return w.innerWidth; + } else if (d.body.clientWidth) { + return d.body.clientWidth; + } else if (d.documentElement.clientWidth) { + return d.documentElement.clientWidth; + } + return 0; +} -// 7.1.1 ToPrimitive(input [, PreferredType]) -var isObject = __webpack_require__(20); -// instead of the ES6 spec version, we didn't implement @@toPrimitive case -// and the second argument - flag - preferred type is a string -module.exports = function (it, S) { - if (!isObject(it)) return it; - var fn, val; - if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; - if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val; - if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; - throw TypeError("Can't convert object to primitive value"); -}; +function setWindow(win) { + _win = win; +} +exports.mapSizes = mapSizes; +exports.getScreenWidth = getScreenWidth; +exports.setWindow = setWindow; /***/ }), +/* 62 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ 349: -/***/ (function(module, exports) { - -module.exports = function (bitmap, value) { - return { - enumerable: !(bitmap & 1), - configurable: !(bitmap & 2), - writable: !(bitmap & 4), - value: value - }; -}; +"use strict"; -/***/ }), +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.store = store; +exports.getCacheUrl = getCacheUrl; -/***/ 35: -/***/ (function(module, exports) { +var _ajax = __webpack_require__(7); -var toString = {}.toString; +var BASE_URL = 'https://prebid.adnxs.com/pbc/v1/cache'; -module.exports = function (it) { - return toString.call(it).slice(8, -1); -}; +/** + * @typedef {object} CacheableUrlBid + * @property {string} vastUrl A URL which loads some valid VAST XML. + */ +/** + * @typedef {object} CacheablePayloadBid + * @property {string} vastXml Some VAST XML which loads an ad in a video player. + */ -/***/ }), +/** + * A CacheableBid describes the types which the videoCache can store. + * + * @typedef {CacheableUrlBid|CacheablePayloadBid} CacheableBid + */ -/***/ 350: -/***/ (function(module, exports, __webpack_require__) { +/** + * Function which wraps a URI that serves VAST XML, so that it can be loaded. + * + * @param {string} uri The URI where the VAST content can be found. + * @return A VAST URL which loads XML from the given URI. + */ +/** + * This module interacts with the server used to cache video ad content to be restored later. + * At a high level, the expected workflow goes like this: + * + * - Request video ads from Bidders + * - Generate IDs for each valid bid, and cache the key/value pair on the server. + * - Return these IDs so that publishers can use them to fetch the bids later. + * + * This trickery helps integrate with ad servers, which set character limits on request params. + */ -var global = __webpack_require__(16); -var hide = __webpack_require__(22); -var has = __webpack_require__(32); -var SRC = __webpack_require__(25)('src'); -var TO_STRING = 'toString'; -var $toString = Function[TO_STRING]; -var TPL = ('' + $toString).split(TO_STRING); +function wrapURI(uri) { + // Technically, this is vulnerable to cross-script injection by sketchy vastUrl bids. + // We could make sure it's a valid URI... but since we're loading VAST XML from the + // URL they provide anyway, that's probably not a big deal. + return '\n \n \n prebid.org wrapper\n \n \n \n \n \n '; +} -__webpack_require__(14).inspectSource = function (it) { - return $toString.call(it); -}; +/** + * Wraps a bid in the format expected by the prebid-server endpoints, or returns null if + * the bid can't be converted cleanly. + * + * @param {CacheableBid} bid + */ +function toStorageRequest(bid) { + var vastValue = bid.vastXml ? bid.vastXml : wrapURI(bid.vastUrl); + return { + type: 'xml', + value: vastValue + }; +} -(module.exports = function (O, key, val, safe) { - var isFunction = typeof val == 'function'; - if (isFunction) has(val, 'name') || hide(val, 'name', key); - if (O[key] === val) return; - if (isFunction) has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key))); - if (O === global) { - O[key] = val; - } else if (!safe) { - delete O[key]; - hide(O, key, val); - } else if (O[key]) { - O[key] = val; - } else { - hide(O, key, val); - } -// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative -})(Function.prototype, TO_STRING, (function toString() { - return typeof this == 'function' && this[SRC] || $toString.call(this); -})); +/** + * A function which should be called with the results of the storage operation. + * + * @callback videoCacheStoreCallback + * + * @param {Error} [error] The error, if one occurred. + * @param {?string[]} uuids An array of unique IDs. The array will have one element for each bid we were asked + * to store. It may include null elements if some of the bids were malformed, or an error occurred. + * Each non-null element in this array is a valid input into the retrieve function, which will fetch + * some VAST XML which can be used to render this bid's ad. + */ +/** + * A function which bridges the APIs between the videoCacheStoreCallback and our ajax function's API. + * + * @param {videoCacheStoreCallback} done A callback to the "store" function. + * @return {Function} A callback which interprets the cache server's responses, and makes up the right + * arguments for our callback. + */ +function shimStorageCallback(done) { + return { + success: function success(responseBody) { + var ids = void 0; + try { + ids = JSON.parse(responseBody).responses; + } catch (e) { + done(e, []); + return; + } -/***/ }), + if (ids) { + done(null, ids); + } else { + done(new Error("The cache server didn't respond with a responses property."), []); + } + }, + error: function error(statusText, responseBody) { + done(new Error('Error storing video ad in the cache: ' + statusText + ': ' + JSON.stringify(responseBody)), []); + } + }; +} -/***/ 351: -/***/ (function(module, exports) { +/** + * If the given bid is for a Video ad, generate a unique ID and cache it somewhere server-side. + * + * @param {CacheableBid[]} bids A list of bid objects which should be cached. + * @param {videoCacheStoreCallback} [done] An optional callback which should be executed after + * the data has been stored in the cache. + */ +function store(bids, done) { + var requestData = { + puts: bids.map(toStorageRequest) + }; -module.exports = function (it) { - if (typeof it != 'function') throw TypeError(it + ' is not a function!'); - return it; -}; + (0, _ajax.ajax)(BASE_URL, shimStorageCallback(done), JSON.stringify(requestData), { + contentType: 'text/plain', + withCredentials: true + }); +} +function getCacheUrl(id) { + return BASE_URL + '?uuid=' + id; +} /***/ }), - -/***/ 352: +/* 63 */ /***/ (function(module, exports, __webpack_require__) { -// 9.4.2.3 ArraySpeciesCreate(originalArray, length) -var speciesConstructor = __webpack_require__(353); - -module.exports = function (original, length) { - return new (speciesConstructor(original))(length); -}; - +"use strict"; -/***/ }), -/***/ 353: -/***/ (function(module, exports, __webpack_require__) { +Object.defineProperty(exports, "__esModule", { + value: true +}); -var isObject = __webpack_require__(20); -var isArray = __webpack_require__(354); -var SPECIES = __webpack_require__(40)('species'); +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; -module.exports = function (original) { - var C; - if (isArray(original)) { - C = original.constructor; - // cross-realm fallback - if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined; - if (isObject(C)) { - C = C[SPECIES]; - if (C === null) C = undefined; - } - } return C === undefined ? Array : C; -}; +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; +exports.createHook = createHook; -/***/ }), +/** + * @typedef {function} HookedFunction + * @property {function(function(), [number])} addHook A method that takes a new function to attach as a hook + * to the HookedFunction + * @property {function(function())} removeHook A method to remove attached hooks + */ -/***/ 354: -/***/ (function(module, exports, __webpack_require__) { +/** + * A map of global hook methods to allow easy extension of hooked functions that are intended to be extended globally + * @type {{}} + */ +var hooks = exports.hooks = {}; -// 7.2.2 IsArray(argument) -var cof = __webpack_require__(35); -module.exports = Array.isArray || function isArray(arg) { - return cof(arg) == 'Array'; -}; +/** + * A utility function for allowing a regular function to be extensible with additional hook functions + * @param {string} type The method for applying all attached hooks when this hooked function is called + * @param {function()} fn The function to make hookable + * @param {string} hookName If provided this allows you to register a name for a global hook to have easy access to + * the addHook and removeHook methods for that hook (which are usually accessed as methods on the function itself) + * @returns {HookedFunction} A new function that implements the HookedFunction interface + */ +function createHook(type, fn, hookName) { + var _hooks = [{ fn: fn, priority: 0 }]; + var types = { + sync: function sync() { + var _this = this; -/***/ }), + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } -/***/ 355: -/***/ (function(module, exports, __webpack_require__) { + _hooks.forEach((function (hook) { + hook.fn.apply(_this, args); + })); + }, + asyncSeries: function asyncSeries() { + var _this2 = this; -__webpack_require__(356); -module.exports = __webpack_require__(14).Array.findIndex; + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + var curr = 0; -/***/ }), + var asyncSeriesNext = function asyncSeriesNext() { + for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } -/***/ 356: -/***/ (function(module, exports, __webpack_require__) { + var hook = _hooks[++curr]; + if ((typeof hook === 'undefined' ? 'undefined' : _typeof(hook)) === 'object' && typeof hook.fn === 'function') { + return hook.fn.apply(_this2, args.concat(asyncSeriesNext)); + } + }; -"use strict"; + return _hooks[curr].fn.apply(this, args.concat(asyncSeriesNext)); + } + }; -// 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined) -var $export = __webpack_require__(19); -var $find = __webpack_require__(34)(6); -var KEY = 'findIndex'; -var forced = true; -// Shouldn't skip holes -if (KEY in []) Array(1)[KEY]((function () { forced = false; })); -$export($export.P + $export.F * forced, 'Array', { - findIndex: function findIndex(callbackfn /* , that = undefined */) { - return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); + if (!types[type]) { + throw 'invalid hook type'; } -}); -__webpack_require__(27)(KEY); + var methods = { + addHook: function addHook(fn) { + var priority = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10; -/***/ }), - -/***/ 357: -/***/ (function(module, exports, __webpack_require__) { - -__webpack_require__(358); -module.exports = __webpack_require__(14).Array.includes; - - -/***/ }), - -/***/ 358: -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; + if (typeof fn === 'function') { + _hooks.push({ + fn: fn, + priority: priority + }); -// https://github.com/tc39/Array.prototype.includes -var $export = __webpack_require__(19); -var $includes = __webpack_require__(42)(true); + _hooks.sort((function (a, b) { + return b.priority - a.priority; + })); + } + }, + removeHook: function removeHook(removeFn) { + _hooks = _hooks.filter((function (hook) { + return hook.fn === fn || hook.fn !== removeFn; + })); + } + }; -$export($export.P, 'Array', { - includes: function includes(el /* , fromIndex = 0 */) { - return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined); + if (typeof hookName === 'string') { + hooks[hookName] = methods; } -}); - -__webpack_require__(27)('includes'); - -/***/ }), - -/***/ 359: -/***/ (function(module, exports, __webpack_require__) { + function hookedFn() { + for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { + args[_key4] = arguments[_key4]; + } -var toInteger = __webpack_require__(39); -var max = Math.max; -var min = Math.min; -module.exports = function (index, length) { - index = toInteger(index); - return index < 0 ? max(index + length, 0) : min(index, length); -}; + if (_hooks.length === 0) { + return fn.apply(this, args); + } + return types[type].apply(this, args); + } + return _extends(hookedFn, methods); +} /***/ }), +/* 64 */, +/* 65 */, +/* 66 */, +/* 67 */, +/* 68 */, +/* 69 */, +/* 70 */, +/* 71 */, +/* 72 */, +/* 73 */, +/* 74 */, +/* 75 */, +/* 76 */, +/* 77 */, +/* 78 */, +/* 79 */, +/* 80 */, +/* 81 */, +/* 82 */, +/* 83 */, +/* 84 */, +/* 85 */, +/* 86 */, +/* 87 */, +/* 88 */, +/* 89 */, +/* 90 */, +/* 91 */, +/* 92 */, +/* 93 */, +/* 94 */, +/* 95 */, +/* 96 */, +/* 97 */, +/* 98 */, +/* 99 */, +/* 100 */, +/* 101 */ +/***/ (function(module, exports) { -/***/ 36: -/***/ (function(module, exports, __webpack_require__) { - -// 7.1.13 ToObject(argument) -var defined = __webpack_require__(37); module.exports = function (it) { - return Object(defined(it)); + if (typeof it != 'function') throw TypeError(it + ' is not a function!'); + return it; }; /***/ }), - -/***/ 360: -/***/ (function(module, exports, __webpack_require__) { - -__webpack_require__(361); -module.exports = __webpack_require__(14).Object.assign; - - -/***/ }), - -/***/ 361: +/* 102 */ /***/ (function(module, exports, __webpack_require__) { -// 19.1.3.1 Object.assign(target, source) -var $export = __webpack_require__(19); - -$export($export.S + $export.F, 'Object', { assign: __webpack_require__(362) }); +var dP = __webpack_require__(103); +var createDesc = __webpack_require__(108); +module.exports = __webpack_require__(25) ? function (object, key, value) { + return dP.f(object, key, createDesc(1, value)); +} : function (object, key, value) { + object[key] = value; + return object; +}; /***/ }), - -/***/ 362: +/* 103 */ /***/ (function(module, exports, __webpack_require__) { -"use strict"; - -// 19.1.2.1 Object.assign(target, source, ...) -var getKeys = __webpack_require__(363); -var gOPS = __webpack_require__(367); -var pIE = __webpack_require__(368); -var toObject = __webpack_require__(36); -var IObject = __webpack_require__(26); -var $assign = Object.assign; +var anObject = __webpack_require__(104); +var IE8_DOM_DEFINE = __webpack_require__(105); +var toPrimitive = __webpack_require__(107); +var dP = Object.defineProperty; -// should work with symbols and should have deterministic property order (V8 bug) -module.exports = !$assign || __webpack_require__(24)((function () { - var A = {}; - var B = {}; - // eslint-disable-next-line no-undef - var S = Symbol(); - var K = 'abcdefghijklmnopqrst'; - A[S] = 7; - K.split('').forEach((function (k) { B[k] = k; })); - return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K; -})) ? function assign(target, source) { // eslint-disable-line no-unused-vars - var T = toObject(target); - var aLen = arguments.length; - var index = 1; - var getSymbols = gOPS.f; - var isEnum = pIE.f; - while (aLen > index) { - var S = IObject(arguments[index++]); - var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S); - var length = keys.length; - var j = 0; - var key; - while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key]; - } return T; -} : $assign; +exports.f = __webpack_require__(25) ? Object.defineProperty : function defineProperty(O, P, Attributes) { + anObject(O); + P = toPrimitive(P, true); + anObject(Attributes); + if (IE8_DOM_DEFINE) try { + return dP(O, P, Attributes); + } catch (e) { /* empty */ } + if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!'); + if ('value' in Attributes) O[P] = Attributes.value; + return O; +}; /***/ }), - -/***/ 363: +/* 104 */ /***/ (function(module, exports, __webpack_require__) { -// 19.1.2.14 / 15.2.3.14 Object.keys(O) -var $keys = __webpack_require__(364); -var enumBugKeys = __webpack_require__(366); - -module.exports = Object.keys || function keys(O) { - return $keys(O, enumBugKeys); +var isObject = __webpack_require__(21); +module.exports = function (it) { + if (!isObject(it)) throw TypeError(it + ' is not an object!'); + return it; }; /***/ }), - -/***/ 364: +/* 105 */ /***/ (function(module, exports, __webpack_require__) { -var has = __webpack_require__(32); -var toIObject = __webpack_require__(43); -var arrayIndexOf = __webpack_require__(42)(false); -var IE_PROTO = __webpack_require__(365)('IE_PROTO'); +module.exports = !__webpack_require__(25) && !__webpack_require__(37)((function () { + return Object.defineProperty(__webpack_require__(106)('div'), 'a', { get: function () { return 7; } }).a != 7; +})); -module.exports = function (object, names) { - var O = toIObject(object); - var i = 0; - var result = []; - var key; - for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key); - // Don't enum bug & hidden keys - while (names.length > i) if (has(O, key = names[i++])) { - ~arrayIndexOf(result, key) || result.push(key); - } - return result; + +/***/ }), +/* 106 */ +/***/ (function(module, exports, __webpack_require__) { + +var isObject = __webpack_require__(21); +var document = __webpack_require__(19).document; +// typeof document.createElement is 'object' in old IE +var is = isObject(document) && isObject(document.createElement); +module.exports = function (it) { + return is ? document.createElement(it) : {}; }; /***/ }), - -/***/ 365: +/* 107 */ /***/ (function(module, exports, __webpack_require__) { -var shared = __webpack_require__(41)('keys'); -var uid = __webpack_require__(25); -module.exports = function (key) { - return shared[key] || (shared[key] = uid(key)); +// 7.1.1 ToPrimitive(input [, PreferredType]) +var isObject = __webpack_require__(21); +// instead of the ES6 spec version, we didn't implement @@toPrimitive case +// and the second argument - flag - preferred type is a string +module.exports = function (it, S) { + if (!isObject(it)) return it; + var fn, val; + if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; + if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val; + if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; + throw TypeError("Can't convert object to primitive value"); }; /***/ }), - -/***/ 366: +/* 108 */ /***/ (function(module, exports) { -// IE 8- don't enum bug keys -module.exports = ( - 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf' -).split(','); +module.exports = function (bitmap, value) { + return { + enumerable: !(bitmap & 1), + configurable: !(bitmap & 2), + writable: !(bitmap & 4), + value: value + }; +}; /***/ }), - -/***/ 367: +/* 109 */ /***/ (function(module, exports) { -exports.f = Object.getOwnPropertySymbols; +var hasOwnProperty = {}.hasOwnProperty; +module.exports = function (it, key) { + return hasOwnProperty.call(it, key); +}; /***/ }), +/* 110 */, +/* 111 */, +/* 112 */, +/* 113 */, +/* 114 */, +/* 115 */, +/* 116 */, +/* 117 */, +/* 118 */, +/* 119 */, +/* 120 */, +/* 121 */, +/* 122 */, +/* 123 */, +/* 124 */, +/* 125 */, +/* 126 */, +/* 127 */, +/* 128 */, +/* 129 */, +/* 130 */, +/* 131 */, +/* 132 */, +/* 133 */, +/* 134 */, +/* 135 */, +/* 136 */, +/* 137 */, +/* 138 */, +/* 139 */, +/* 140 */, +/* 141 */, +/* 142 */, +/* 143 */, +/* 144 */, +/* 145 */, +/* 146 */, +/* 147 */, +/* 148 */, +/* 149 */, +/* 150 */, +/* 151 */, +/* 152 */, +/* 153 */, +/* 154 */, +/* 155 */, +/* 156 */, +/* 157 */, +/* 158 */, +/* 159 */, +/* 160 */, +/* 161 */, +/* 162 */, +/* 163 */, +/* 164 */, +/* 165 */, +/* 166 */, +/* 167 */, +/* 168 */, +/* 169 */, +/* 170 */, +/* 171 */, +/* 172 */, +/* 173 */, +/* 174 */, +/* 175 */, +/* 176 */, +/* 177 */, +/* 178 */, +/* 179 */, +/* 180 */, +/* 181 */, +/* 182 */, +/* 183 */, +/* 184 */, +/* 185 */, +/* 186 */, +/* 187 */, +/* 188 */, +/* 189 */, +/* 190 */, +/* 191 */, +/* 192 */, +/* 193 */, +/* 194 */, +/* 195 */, +/* 196 */, +/* 197 */, +/* 198 */, +/* 199 */, +/* 200 */, +/* 201 */, +/* 202 */, +/* 203 */, +/* 204 */, +/* 205 */, +/* 206 */, +/* 207 */, +/* 208 */, +/* 209 */, +/* 210 */, +/* 211 */, +/* 212 */, +/* 213 */, +/* 214 */, +/* 215 */, +/* 216 */, +/* 217 */, +/* 218 */, +/* 219 */, +/* 220 */, +/* 221 */, +/* 222 */, +/* 223 */, +/* 224 */, +/* 225 */, +/* 226 */, +/* 227 */, +/* 228 */, +/* 229 */, +/* 230 */, +/* 231 */, +/* 232 */, +/* 233 */, +/* 234 */, +/* 235 */, +/* 236 */, +/* 237 */, +/* 238 */, +/* 239 */, +/* 240 */, +/* 241 */, +/* 242 */, +/* 243 */, +/* 244 */, +/* 245 */, +/* 246 */, +/* 247 */, +/* 248 */, +/* 249 */, +/* 250 */, +/* 251 */, +/* 252 */, +/* 253 */, +/* 254 */, +/* 255 */, +/* 256 */, +/* 257 */, +/* 258 */, +/* 259 */, +/* 260 */, +/* 261 */, +/* 262 */, +/* 263 */, +/* 264 */, +/* 265 */, +/* 266 */, +/* 267 */, +/* 268 */, +/* 269 */, +/* 270 */, +/* 271 */, +/* 272 */, +/* 273 */, +/* 274 */, +/* 275 */, +/* 276 */, +/* 277 */, +/* 278 */, +/* 279 */, +/* 280 */, +/* 281 */, +/* 282 */, +/* 283 */, +/* 284 */, +/* 285 */, +/* 286 */, +/* 287 */, +/* 288 */, +/* 289 */, +/* 290 */, +/* 291 */, +/* 292 */, +/* 293 */, +/* 294 */, +/* 295 */, +/* 296 */, +/* 297 */, +/* 298 */, +/* 299 */, +/* 300 */, +/* 301 */, +/* 302 */, +/* 303 */, +/* 304 */, +/* 305 */, +/* 306 */, +/* 307 */, +/* 308 */, +/* 309 */, +/* 310 */, +/* 311 */, +/* 312 */, +/* 313 */, +/* 314 */, +/* 315 */, +/* 316 */, +/* 317 */, +/* 318 */, +/* 319 */, +/* 320 */, +/* 321 */, +/* 322 */, +/* 323 */, +/* 324 */, +/* 325 */, +/* 326 */, +/* 327 */, +/* 328 */, +/* 329 */, +/* 330 */, +/* 331 */, +/* 332 */, +/* 333 */, +/* 334 */, +/* 335 */, +/* 336 */, +/* 337 */, +/* 338 */, +/* 339 */, +/* 340 */, +/* 341 */, +/* 342 */, +/* 343 */, +/* 344 */, +/* 345 */, +/* 346 */, +/* 347 */, +/* 348 */, +/* 349 */, +/* 350 */, +/* 351 */, +/* 352 */, +/* 353 */, +/* 354 */, +/* 355 */, +/* 356 */, +/* 357 */, +/* 358 */, +/* 359 */, +/* 360 */, +/* 361 */, +/* 362 */, +/* 363 */, +/* 364 */, +/* 365 */, +/* 366 */, +/* 367 */, +/* 368 */, +/* 369 */, +/* 370 */, +/* 371 */, +/* 372 */, +/* 373 */, +/* 374 */, +/* 375 */, +/* 376 */, +/* 377 */, +/* 378 */, +/* 379 */, +/* 380 */, +/* 381 */, +/* 382 */, +/* 383 */, +/* 384 */, +/* 385 */, +/* 386 */, +/* 387 */, +/* 388 */, +/* 389 */, +/* 390 */, +/* 391 */, +/* 392 */, +/* 393 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ 368: -/***/ (function(module, exports) { - -exports.f = {}.propertyIsEnumerable; +module.exports = __webpack_require__(394); /***/ }), - -/***/ 369: +/* 394 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.listenMessagesFromCreative = listenMessagesFromCreative; +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; -var _events = __webpack_require__(11); +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; -var _events2 = _interopRequireDefault(_events); +var _prebidGlobal = __webpack_require__(45); + +var _utils = __webpack_require__(0); + +var _video = __webpack_require__(35); var _native = __webpack_require__(15); -var _constants = __webpack_require__(4); +__webpack_require__(395); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } +var _url = __webpack_require__(13); -var BID_WON = _constants.EVENTS.BID_WON; /* Secure Creatives - Provides support for rendering creatives into cross domain iframes such as SafeFrame to prevent - access to a publisher page from creative payloads. - */ +var _secureCreatives = __webpack_require__(423); -function listenMessagesFromCreative() { - addEventListener('message', receiveMessage, false); -} +var _userSync = __webpack_require__(18); -function receiveMessage(ev) { - var key = ev.message ? 'message' : 'data'; - var data = {}; - try { - data = JSON.parse(ev[key]); - } catch (e) { - return; - } +var _adloader = __webpack_require__(5); - if (data.adId) { - var adObject = pbjs._bidsReceived.find((function (bid) { - return bid.adId === data.adId; - })); +var _ajax = __webpack_require__(7); - if (data.message === 'Prebid Request') { - sendAdToCreative(adObject, data.adServerDomain, ev.source); +var _config = __webpack_require__(8); - // save winning bids - pbjs._winningBids.push(adObject); +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /** @module pbjs */ - _events2['default'].emit(BID_WON, adObject); - } +var pbjs = (0, _prebidGlobal.getGlobal)(); - // handle this script from native template in an ad server - // window.parent.postMessage(JSON.stringify({ - // message: 'Prebid Native', - // adId: '%%PATTERN:hb_adid%%' - // }), '*'); - if (data.message === 'Prebid Native') { - (0, _native.fireNativeTrackers)(data, adObject); - pbjs._winningBids.push(adObject); - _events2['default'].emit(BID_WON, adObject); - } - } -} +var CONSTANTS = __webpack_require__(3); +var utils = __webpack_require__(0); +var bidmanager = __webpack_require__(2); +var adaptermanager = __webpack_require__(1); +var bidfactory = __webpack_require__(4); +var events = __webpack_require__(11); +var adserver = __webpack_require__(424); +var targeting = __webpack_require__(27); +var syncUsers = _userSync.userSync.syncUsers, + triggerUserSyncs = _userSync.userSync.triggerUserSyncs; -function sendAdToCreative(adObject, remoteDomain, source) { - var adId = adObject.adId, - ad = adObject.ad, - adUrl = adObject.adUrl, - width = adObject.width, - height = adObject.height; +/* private variables */ +var BID_WON = CONSTANTS.EVENTS.BID_WON; +var SET_TARGETING = CONSTANTS.EVENTS.SET_TARGETING; +var ADD_AD_UNITS = CONSTANTS.EVENTS.ADD_AD_UNITS; - if (adId) { - resizeRemoteCreative(adObject); - source.postMessage(JSON.stringify({ - message: 'Prebid Response', - ad: ad, - adUrl: adUrl, - adId: adId, - width: width, - height: height - }), remoteDomain); - } -} +var auctionRunning = false; +var bidRequestQueue = []; -function resizeRemoteCreative(_ref) { - var adUnitCode = _ref.adUnitCode, - width = _ref.width, - height = _ref.height; +var eventValidators = { + bidWon: checkDefinedPlacement +}; - var iframe = document.getElementById(window.googletag.pubads().getSlots().find((function (slot) { - return slot.getAdUnitPath() === adUnitCode || slot.getSlotElementId() === adUnitCode; - })).getSlotElementId()).querySelector('iframe'); +/* Public vars */ - iframe.width = '' + width; - iframe.height = '' + height; -} +pbjs._bidsRequested = []; +pbjs._bidsReceived = []; +// _adUnitCodes stores the current filter to use for adUnits as an array of adUnitCodes +pbjs._adUnitCodes = []; +pbjs._winningBids = []; +pbjs._adsReceived = []; -/***/ }), +pbjs.bidderSettings = pbjs.bidderSettings || {}; -/***/ 37: -/***/ (function(module, exports) { +/** @deprecated - use pbjs.setConfig({ bidderTimeout: }) */ +pbjs.bidderTimeout = pbjs.bidderTimeout; -// 7.2.1 RequireObjectCoercible(argument) -module.exports = function (it) { - if (it == undefined) throw TypeError("Can't call method on " + it); - return it; -}; +// current timeout set in `requestBids` or to default `bidderTimeout` +pbjs.cbTimeout = pbjs.cbTimeout || 200; +// timeout buffer to adjust for bidder CDN latency +pbjs.timeoutBuffer = 200; -/***/ }), +/** @deprecated - use pbjs.setConfig({ debug: }) */ +pbjs.logging = pbjs.logging; -/***/ 370: -/***/ (function(module, exports, __webpack_require__) { +/** @deprecated - use pbjs.setConfig({ publisherDomain: ) */ +pbjs.publisherDomain = pbjs.publisherDomain; -"use strict"; +// let the world know we are loaded +pbjs.libLoaded = true; +// version auto generated from build +pbjs.version = 'v0.34.9'; +utils.logInfo('Prebid.js v0.34.9 loaded'); -var _url = __webpack_require__(12); +// create adUnit array +pbjs.adUnits = pbjs.adUnits || []; -var _targeting = __webpack_require__(21); +// Allow publishers who enable user sync override to trigger their sync +pbjs.triggerUserSyncs = triggerUserSyncs; -// Adserver parent class -var AdServer = function AdServer(attr) { - this.name = attr.adserver; - this.code = attr.code; - this.getWinningBidByCode = function () { - return (0, _targeting.getWinningBids)(this.code)[0]; - }; -}; +function checkDefinedPlacement(id) { + var placementCodes = pbjs._bidsRequested.map((function (bidSet) { + return bidSet.bids.map((function (bid) { + return bid.placementCode; + })); + })).reduce(_utils.flatten).filter(_utils.uniques); -// DFP ad server -exports.dfpAdserver = function (options, urlComponents) { - var adserver = new AdServer(options); - adserver.urlComponents = urlComponents; + if (!utils.contains(placementCodes, id)) { + utils.logError('The "' + id + '" placement is not defined.'); + return; + } - var dfpReqParams = { - 'env': 'vp', - 'gdfp_req': '1', - 'impl': 's', - 'unviewed_position_start': '1' - }; + return true; +} - var dfpParamsWithVariableValue = ['output', 'iu', 'sz', 'url', 'correlator', 'description_url', 'hl']; +/** + * When a request for bids is made any stale bids remaining will be cleared for + * a placement included in the outgoing bid request. + */ +function clearPlacements() { + pbjs._bidsRequested = []; - var getCustomParams = function getCustomParams(targeting) { - return encodeURIComponent((0, _url.formatQS)(targeting)); - }; + // leave bids received for ad slots not in this bid request + pbjs._bidsReceived = pbjs._bidsReceived.filter((function (bid) { + return !pbjs._adUnitCodes.includes(bid.adUnitCode); + })); +} - adserver.appendQueryParams = function () { - var bid = adserver.getWinningBidByCode(); - if (bid) { - this.urlComponents.search.description_url = encodeURIComponent(bid.vastUrl); - this.urlComponents.search.cust_params = getCustomParams(bid.adserverTargeting); - this.urlComponents.search.correlator = Date.now(); - } - }; +function setRenderSize(doc, width, height) { + if (doc.defaultView && doc.defaultView.frameElement) { + doc.defaultView.frameElement.width = width; + doc.defaultView.frameElement.height = height; + } +} - adserver.verifyAdserverTag = function () { - for (var key in dfpReqParams) { - if (!this.urlComponents.search.hasOwnProperty(key) || this.urlComponents.search[key] !== dfpReqParams[key]) { - return false; - } - } - for (var i in dfpParamsWithVariableValue) { - if (!this.urlComponents.search.hasOwnProperty(dfpParamsWithVariableValue[i])) { - return false; - } - } - return true; - }; +/// /////////////////////////////// +// // +// Start Public APIs // +// // +/// /////////////////////////////// + +/** + * This function returns the query string targeting parameters available at this moment for a given ad unit. Note that some bidder's response may not have been received if you call this function too quickly after the requests are sent. + * @param {string} [adunitCode] adUnitCode to get the bid responses for + * @alias module:pbjs.getAdserverTargetingForAdUnitCodeStr + * @return {Array} returnObj return bids array + */ +pbjs.getAdserverTargetingForAdUnitCodeStr = function (adunitCode) { + utils.logInfo('Invoking pbjs.getAdserverTargetingForAdUnitCodeStr', arguments); - return adserver; + // call to retrieve bids array + if (adunitCode) { + var res = pbjs.getAdserverTargetingForAdUnitCode(adunitCode); + return utils.transformAdServerTargetingObj(res); + } else { + utils.logMessage('Need to call getAdserverTargetingForAdUnitCodeStr with adunitCode'); + } }; -/***/ }), +/** + * This function returns the query string targeting parameters available at this moment for a given ad unit. Note that some bidder's response may not have been received if you call this function too quickly after the requests are sent. + * @param adUnitCode {string} adUnitCode to get the bid responses for + * @alias module:pbjs.getAdserverTargetingForAdUnitCode + * @returns {Object} returnObj return bids + */ +pbjs.getAdserverTargetingForAdUnitCode = function (adUnitCode) { + return pbjs.getAdserverTargeting(adUnitCode)[adUnitCode]; +}; -/***/ 38: -/***/ (function(module, exports, __webpack_require__) { +/** + * returns all ad server targeting for all ad units + * @return {Object} Map of adUnitCodes and targeting values [] + * @alias module:pbjs.getAdserverTargeting + */ -// 7.1.15 ToLength -var toInteger = __webpack_require__(39); -var min = Math.min; -module.exports = function (it) { - return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 +pbjs.getAdserverTargeting = function (adUnitCode) { + utils.logInfo('Invoking pbjs.getAdserverTargeting', arguments); + return targeting.getAllTargeting(adUnitCode).map((function (targeting) { + return _defineProperty({}, Object.keys(targeting)[0], targeting[Object.keys(targeting)[0]].map((function (target) { + return _defineProperty({}, Object.keys(target)[0], target[Object.keys(target)[0]].join(', ')); + })).reduce((function (p, c) { + return _extends(c, p); + }), {})); + })).reduce((function (accumulator, targeting) { + var key = Object.keys(targeting)[0]; + accumulator[key] = _extends({}, accumulator[key], targeting[key]); + return accumulator; + }), {}); }; +/** + * This function returns the bid responses at the given moment. + * @alias module:pbjs.getBidResponses + * @return {Object} map | object that contains the bidResponses + */ -/***/ }), +pbjs.getBidResponses = function () { + utils.logInfo('Invoking pbjs.getBidResponses', arguments); + var responses = pbjs._bidsReceived.filter(_utils.adUnitsFilter.bind(this, pbjs._adUnitCodes)); -/***/ 39: -/***/ (function(module, exports) { + // find the last requested id to get responses for most recent auction only + var currentRequestId = responses && responses.length && responses[responses.length - 1].requestId; -// 7.1.4 ToInteger -var ceil = Math.ceil; -var floor = Math.floor; -module.exports = function (it) { - return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); + return responses.map((function (bid) { + return bid.adUnitCode; + })).filter(_utils.uniques).map((function (adUnitCode) { + return responses.filter((function (bid) { + return bid.requestId === currentRequestId && bid.adUnitCode === adUnitCode; + })); + })).filter((function (bids) { + return bids && bids[0] && bids[0].adUnitCode; + })).map((function (bids) { + return _defineProperty({}, bids[0].adUnitCode, { bids: bids }); + })).reduce((function (a, b) { + return _extends(a, b); + }), {}); }; +/** + * Returns bidResponses for the specified adUnitCode + * @param {string} adUnitCode adUnitCode + * @alias module:pbjs.getBidResponsesForAdUnitCode + * @return {Object} bidResponse object + */ -/***/ }), - -/***/ 4: -/***/ (function(module, exports) { +pbjs.getBidResponsesForAdUnitCode = function (adUnitCode) { + var bids = pbjs._bidsReceived.filter((function (bid) { + return bid.adUnitCode === adUnitCode; + })); + return { + bids: bids + }; +}; -module.exports = {"JSON_MAPPING":{"PL_CODE":"code","PL_SIZE":"sizes","PL_BIDS":"bids","BD_BIDDER":"bidder","BD_ID":"paramsd","BD_PL_ID":"placementId","ADSERVER_TARGETING":"adserverTargeting","BD_SETTING_STANDARD":"standard"},"REPO_AND_VERSION":"prebid_prebid_0.34.1","DEBUG_MODE":"pbjs_debug","STATUS":{"GOOD":1,"NO_BID":2},"CB":{"TYPE":{"ALL_BIDS_BACK":"allRequestedBidsBack","AD_UNIT_BIDS_BACK":"adUnitBidsBack","BID_WON":"bidWon","REQUEST_BIDS":"requestBids"}},"EVENTS":{"AUCTION_INIT":"auctionInit","AUCTION_END":"auctionEnd","BID_ADJUSTMENT":"bidAdjustment","BID_TIMEOUT":"bidTimeout","BID_REQUESTED":"bidRequested","BID_RESPONSE":"bidResponse","BID_WON":"bidWon","SET_TARGETING":"setTargeting","REQUEST_BIDS":"requestBids","ADD_AD_UNITS":"addAdUnits"},"EVENT_ID_PATHS":{"bidWon":"adUnitCode"},"GRANULARITY_OPTIONS":{"LOW":"low","MEDIUM":"medium","HIGH":"high","AUTO":"auto","DENSE":"dense","CUSTOM":"custom"},"TARGETING_KEYS":["hb_bidder","hb_adid","hb_pb","hb_size","hb_deal"],"S2S":{"DEFAULT_ENDPOINT":"https://prebid.adnxs.com/pbs/v1/auction","SRC":"s2s","ADAPTER":"prebidServer","SYNC_ENDPOINT":"https://prebid.adnxs.com/pbs/v1/cookie_sync","SYNCED_BIDDERS_KEY":"pbjsSyncs"}} +/** + * Set query string targeting on one or more GPT ad units. + * @param {(string|string[])} adUnit a single `adUnit.code` or multiple. + * @alias module:pbjs.setTargetingForGPTAsync + */ +pbjs.setTargetingForGPTAsync = function (adUnit) { + utils.logInfo('Invoking pbjs.setTargetingForGPTAsync', arguments); + if (!(0, _utils.isGptPubadsDefined)()) { + utils.logError('window.googletag is not defined on the page'); + return; + } -/***/ }), + // get our ad unit codes + var targetingSet = targeting.getAllTargeting(adUnit); -/***/ 40: -/***/ (function(module, exports, __webpack_require__) { + // first reset any old targeting + targeting.resetPresetTargeting(adUnit); -var store = __webpack_require__(41)('wks'); -var uid = __webpack_require__(25); -var Symbol = __webpack_require__(16).Symbol; -var USE_SYMBOL = typeof Symbol == 'function'; + // now set new targeting keys + targeting.setTargeting(targetingSet); -var $exports = module.exports = function (name) { - return store[name] || (store[name] = - USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name)); + // emit event + events.emit(SET_TARGETING); }; -$exports.store = store; - - -/***/ }), +/** + * Set query string targeting on all AST (AppNexus Seller Tag) ad units. Note that this function has to be called after all ad units on page are defined. For working example code, see [Using Prebid.js with AppNexus Publisher Ad Server](http://prebid.org/dev-docs/examples/use-prebid-with-appnexus-ad-server.html). + * @alias module:pbjs.setTargetingForAst + */ +pbjs.setTargetingForAst = function () { + utils.logInfo('Invoking pbjs.setTargetingForAn', arguments); + if (!targeting.isApntagDefined()) { + utils.logError('window.apntag is not defined on the page'); + return; + } -/***/ 41: -/***/ (function(module, exports, __webpack_require__) { + targeting.setTargetingForAst(); -var global = __webpack_require__(16); -var SHARED = '__core-js_shared__'; -var store = global[SHARED] || (global[SHARED] = {}); -module.exports = function (key) { - return store[key] || (store[key] = {}); + // emit event + events.emit(SET_TARGETING); }; +/** + * Returns a bool if all the bids have returned or timed out + * @alias module:pbjs.allBidsAvailable + * @return {bool} all bids available + * + * @deprecated This function will be removed in Prebid 1.0 + * Alternative solution is in progress. + * See https://github.com/prebid/Prebid.js/issues/1087 for more details. + */ +pbjs.allBidsAvailable = function () { + utils.logWarn('pbjs.allBidsAvailable will be removed in Prebid 1.0. Alternative solution is in progress. See https://github.com/prebid/Prebid.js/issues/1087 for more details.'); + utils.logInfo('Invoking pbjs.allBidsAvailable', arguments); + return bidmanager.bidsBackAll(); +}; -/***/ }), +/** + * This function will render the ad (based on params) in the given iframe document passed through. + * Note that doc SHOULD NOT be the parent document page as we can't doc.write() asynchronously + * @param {HTMLDocument} doc document + * @param {string} id bid id to locate the ad + * @alias module:pbjs.renderAd + */ +pbjs.renderAd = function (doc, id) { + utils.logInfo('Invoking pbjs.renderAd', arguments); + utils.logMessage('Calling renderAd with adId :' + id); + if (doc && id) { + try { + // lookup ad by ad Id + var bid = pbjs._bidsReceived.find((function (bid) { + return bid.adId === id; + })); + if (bid) { + // replace macros according to openRTB with price paid = bid.cpm + bid.ad = utils.replaceAuctionPrice(bid.ad, bid.cpm); + bid.adUrl = utils.replaceAuctionPrice(bid.adUrl, bid.cpm); + // save winning bids + pbjs._winningBids.push(bid); -/***/ 42: -/***/ (function(module, exports, __webpack_require__) { + // emit 'bid won' event here + events.emit(BID_WON, bid); -// false -> Array#indexOf -// true -> Array#includes -var toIObject = __webpack_require__(43); -var toLength = __webpack_require__(38); -var toAbsoluteIndex = __webpack_require__(359); -module.exports = function (IS_INCLUDES) { - return function ($this, el, fromIndex) { - var O = toIObject($this); - var length = toLength(O.length); - var index = toAbsoluteIndex(fromIndex, length); - var value; - // Array#includes uses SameValueZero equality algorithm - // eslint-disable-next-line no-self-compare - if (IS_INCLUDES && el != el) while (length > index) { - value = O[index++]; - // eslint-disable-next-line no-self-compare - if (value != value) return true; - // Array#indexOf ignores holes, Array#includes - not - } else for (;length > index; index++) if (IS_INCLUDES || index in O) { - if (O[index] === el) return IS_INCLUDES || index || 0; - } return !IS_INCLUDES && -1; - }; -}; + var height = bid.height, + width = bid.width, + ad = bid.ad, + mediaType = bid.mediaType, + adUrl = bid.adUrl, + renderer = bid.renderer; -/***/ }), + if (renderer && renderer.url) { + renderer.render(bid); + } else if (doc === document && !utils.inIframe() || mediaType === 'video') { + utils.logError('Error trying to write ad. Ad render call ad id ' + id + ' was prevented from writing to the main document.'); + } else if (ad) { + doc.write(ad); + doc.close(); + setRenderSize(doc, width, height); + } else if (adUrl) { + var iframe = utils.createInvisibleIframe(); + iframe.height = height; + iframe.width = width; + iframe.style.display = 'inline'; + iframe.style.overflow = 'hidden'; + iframe.src = adUrl; -/***/ 43: -/***/ (function(module, exports, __webpack_require__) { + utils.insertElement(iframe, doc, 'body'); + setRenderSize(doc, width, height); + } else { + utils.logError('Error trying to write ad. No ad for bid response id: ' + id); + } + } else { + utils.logError('Error trying to write ad. Cannot find ad by given id : ' + id); + } + } catch (e) { + utils.logError('Error trying to write ad Id :' + id + ' to the page:' + e.message); + } + } else { + utils.logError('Error trying to write ad Id :' + id + ' to the page. Missing document or adId'); + } +}; -// to indexed object, toObject with fallback for non-array-like ES3 strings -var IObject = __webpack_require__(26); -var defined = __webpack_require__(37); -module.exports = function (it) { - return IObject(defined(it)); +/** + * Remove adUnit from the pbjs configuration + * @param {string} adUnitCode the adUnitCode to remove + * @alias module:pbjs.removeAdUnit + */ +pbjs.removeAdUnit = function (adUnitCode) { + utils.logInfo('Invoking pbjs.removeAdUnit', arguments); + if (adUnitCode) { + for (var i = 0; i < pbjs.adUnits.length; i++) { + if (pbjs.adUnits[i].code === adUnitCode) { + pbjs.adUnits.splice(i, 1); + } + } + } }; +/** + * @alias module:pbjs.clearAuction + */ +pbjs.clearAuction = function () { + auctionRunning = false; + // Only automatically sync if the publisher has not chosen to "enableOverride" + var userSyncConfig = _config.config.getConfig('userSync') || {}; + if (!userSyncConfig.enableOverride) { + // Delay the auto sync by the config delay + syncUsers(userSyncConfig.syncDelay); + } -/***/ }), - -/***/ 46: -/***/ (function(module, exports) { + utils.logMessage('Prebid auction cleared'); + if (bidRequestQueue.length) { + bidRequestQueue.shift()(); + } +}; -module.exports = clone; +/** + * @param {Object} requestOptions + * @param {function} requestOptions.bidsBackHandler + * @param {number} requestOptions.timeout + * @param {Array} requestOptions.adUnits + * @param {Array} requestOptions.adUnitCodes + * @alias module:pbjs.requestBids + */ +pbjs.requestBids = function () { + var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + bidsBackHandler = _ref4.bidsBackHandler, + timeout = _ref4.timeout, + adUnits = _ref4.adUnits, + adUnitCodes = _ref4.adUnitCodes; -/* - Identical to `just-extend(true, {}, obj1)` + events.emit('requestBids'); + var cbTimeout = pbjs.cbTimeout = timeout || _config.config.getConfig('bidderTimeout'); + adUnits = adUnits || pbjs.adUnits; - var arr = [1, 2, 3]; - var subObj = {aa: 1}; - var obj = {a: 3, b: 5, c: arr, d: subObj}; - var objClone = clone(obj); - arr.push(4); - subObj.bb = 2; - obj; // {a: 3, b: 5, c: [1, 2, 3, 4], d: {aa: 1}} - objClone; // {a: 3, b: 5, c: [1, 2, 3], d: {aa: 1, bb: 2}} -*/ + utils.logInfo('Invoking pbjs.requestBids', arguments); -function clone(obj) { - var result = Array.isArray(obj) ? [] : {}; - for (var key in obj) { - // include prototype properties - var value = obj[key]; - if (value && typeof value == 'object') { - result[key] = clone(value); - } else { - result[key] = value; - } + if (adUnitCodes && adUnitCodes.length) { + // if specific adUnitCodes supplied filter adUnits for those codes + adUnits = adUnits.filter((function (unit) { + return adUnitCodes.includes(unit.code); + })); + } else { + // otherwise derive adUnitCodes from adUnits + adUnitCodes = adUnits && adUnits.map((function (unit) { + return unit.code; + })); } - return result; -} - -/***/ }), + // for video-enabled adUnits, only request bids for bidders that support video + adUnits.filter(_video.videoAdUnit).filter(_video.hasNonVideoBidder).forEach((function (adUnit) { + var nonVideoBidders = adUnit.bids.filter((function (bid) { + return !(0, _video.videoBidder)(bid); + })).map((function (bid) { + return bid.bidder; + })); -/***/ 47: -/***/ (function(module, exports, __webpack_require__) { + utils.logWarn(utils.unsupportedBidderMessage(adUnit, nonVideoBidders)); + adUnit.bids = adUnit.bids.filter(_video.videoBidder); + })); -"use strict"; + // for native-enabled adUnits, only request bids for bidders that support native + adUnits.filter(_native.nativeAdUnit).filter(_native.hasNonNativeBidder).forEach((function (adUnit) { + var nonNativeBidders = adUnit.bids.filter((function (bid) { + return !(0, _native.nativeBidder)(bid); + })).map((function (bid) { + return bid.bidder; + })); + utils.logWarn(utils.unsupportedBidderMessage(adUnit, nonNativeBidders)); + adUnit.bids = adUnit.bids.filter(_native.nativeBidder); + })); -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.setWindow = exports.getScreenWidth = exports.mapSizes = undefined; + if (auctionRunning) { + bidRequestQueue.push((function () { + pbjs.requestBids({ bidsBackHandler: bidsBackHandler, timeout: cbTimeout, adUnits: adUnits, adUnitCodes: adUnitCodes }); + })); + return; + } -var _utils = __webpack_require__(0); + auctionRunning = true; -var utils = _interopRequireWildcard(_utils); + // we will use adUnitCodes for filtering the current auction + pbjs._adUnitCodes = adUnitCodes; -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } } + bidmanager.externalCallbackReset(); + clearPlacements(); -var _win = void 0; /** - * @module sizeMapping - */ + if (!adUnits || adUnits.length === 0) { + utils.logMessage('No adUnits configured. No bids requested.'); + if (typeof bidsBackHandler === 'function') { + bidmanager.addOneTimeCallback(bidsBackHandler, false); + } + bidmanager.executeCallback(); + return; + } + // set timeout for all bids + var timedOut = true; + var timeoutCallback = bidmanager.executeCallback.bind(bidmanager, timedOut); + var timer = setTimeout(timeoutCallback, cbTimeout); + (0, _ajax.setAjaxTimeout)(cbTimeout); + if (typeof bidsBackHandler === 'function') { + bidmanager.addOneTimeCallback(bidsBackHandler, timer); + } -function mapSizes(adUnit) { - if (!isSizeMappingValid(adUnit.sizeMapping)) { - return adUnit.sizes; + adaptermanager.callBids({ adUnits: adUnits, adUnitCodes: adUnitCodes, cbTimeout: cbTimeout }); + if (pbjs._bidsRequested.length === 0) { + bidmanager.executeCallback(); } - var width = getScreenWidth(); - if (!width) { - // size not detected - get largest value set for desktop - var _mapping = adUnit.sizeMapping.reduce((function (prev, curr) { - return prev.minWidth < curr.minWidth ? curr : prev; +}; + +/** + * + * Add adunit(s) + * @param {Array|Object} adUnitArr Array of adUnits or single adUnit Object. + * @alias module:pbjs.addAdUnits + */ +pbjs.addAdUnits = function (adUnitArr) { + utils.logInfo('Invoking pbjs.addAdUnits', arguments); + if (utils.isArray(adUnitArr)) { + // generate transactionid for each new adUnits + // Append array to existing + adUnitArr.forEach((function (adUnit) { + return adUnit.transactionId = utils.generateUUID(); })); - if (_mapping.sizes && _mapping.sizes.length) { - return _mapping.sizes; - } - return adUnit.sizes; + pbjs.adUnits.push.apply(pbjs.adUnits, adUnitArr); + } else if ((typeof adUnitArr === 'undefined' ? 'undefined' : _typeof(adUnitArr)) === 'object') { + // Generate the transaction id for the adunit + adUnitArr.transactionId = utils.generateUUID(); + pbjs.adUnits.push(adUnitArr); } - var sizes = ''; - var mapping = adUnit.sizeMapping.find((function (sizeMapping) { - return width >= sizeMapping.minWidth; - })); - if (mapping && mapping.sizes && mapping.sizes.length) { - sizes = mapping.sizes; - utils.logMessage('AdUnit : ' + adUnit.code + ' resized based on device width to : ' + sizes); - } else { - utils.logMessage('AdUnit : ' + adUnit.code + ' not mapped to any sizes for device width. This request will be suppressed.'); + // emit event + events.emit(ADD_AD_UNITS); +}; + +/** + * @param {string} event the name of the event + * @param {Function} handler a callback to set on event + * @param {string} id an identifier in the context of the event + * @alias module:pbjs.onEvent + * + * This API call allows you to register a callback to handle a Prebid.js event. + * An optional `id` parameter provides more finely-grained event callback registration. + * This makes it possible to register callback events for a specific item in the + * event context. For example, `bidWon` events will accept an `id` for ad unit code. + * `bidWon` callbacks registered with an ad unit code id will be called when a bid + * for that ad unit code wins the auction. Without an `id` this method registers the + * callback for every `bidWon` event. + * + * Currently `bidWon` is the only event that accepts an `id` parameter. + */ +pbjs.onEvent = function (event, handler, id) { + utils.logInfo('Invoking pbjs.onEvent', arguments); + if (!utils.isFn(handler)) { + utils.logError('The event handler provided is not a function and was not set on event "' + event + '".'); + return; } - return sizes; -} -function isSizeMappingValid(sizeMapping) { - if (utils.isArray(sizeMapping) && sizeMapping.length > 0) { - return true; + if (id && !eventValidators[event].call(null, id)) { + utils.logError('The id provided is not valid for event "' + event + '" and no handler was set.'); + return; } - utils.logInfo('No size mapping defined'); - return false; -} -function getScreenWidth(win) { - var w = win || _win || window; - var d = w.document; + events.on(event, handler, id); +}; - if (w.innerWidth) { - return w.innerWidth; - } else if (d.body.clientWidth) { - return d.body.clientWidth; - } else if (d.documentElement.clientWidth) { - return d.documentElement.clientWidth; +/** + * @param {string} event the name of the event + * @param {Function} handler a callback to remove from the event + * @param {string} id an identifier in the context of the event (see `pbjs.onEvent`) + * @alias module:pbjs.offEvent + */ +pbjs.offEvent = function (event, handler, id) { + utils.logInfo('Invoking pbjs.offEvent', arguments); + if (id && !eventValidators[event].call(null, id)) { + return; + } + + events.off(event, handler, id); +}; + +/** + * Add a callback event + * @param {string} eventStr event to attach callback to Options: "allRequestedBidsBack" | "adUnitBidsBack" + * @param {Function} func function to execute. Parameters passed into the function: (bidResObj), [adUnitCode]); + * @alias module:pbjs.addCallback + * @returns {string} id for callback + * + * @deprecated This function will be removed in Prebid 1.0 + * Please use onEvent instead. + */ +pbjs.addCallback = function (eventStr, func) { + utils.logWarn('pbjs.addCallback will be removed in Prebid 1.0. Please use onEvent instead'); + utils.logInfo('Invoking pbjs.addCallback', arguments); + var id = null; + if (!eventStr || !func || typeof func !== 'function') { + utils.logError('error registering callback. Check method signature'); + return id; } - return 0; -} - -function setWindow(win) { - _win = win; -} - -exports.mapSizes = mapSizes; -exports.getScreenWidth = getScreenWidth; -exports.setWindow = setWindow; -/***/ }), + id = utils.getUniqueIdentifierStr; + bidmanager.addCallback(id, func, eventStr); + return id; +}; -/***/ 48: -/***/ (function(module, exports, __webpack_require__) { +/** + * Remove a callback event + * //@param {string} cbId id of the callback to remove + * @alias module:pbjs.removeCallback + * @returns {string} id for callback + * + * @deprecated This function will be removed in Prebid 1.0 + * Please use offEvent instead. + */ +pbjs.removeCallback = function () /* cbId */{ + // todo + utils.logWarn('pbjs.removeCallback will be removed in Prebid 1.0. Please use offEvent instead.'); + return null; +}; -"use strict"; +/** + * Wrapper to register bidderAdapter externally (adaptermanager.registerBidAdapter()) + * @param {Function} bidderAdaptor [description] + * @param {string} bidderCode [description] + * @alias module:pbjs.registerBidAdapter + */ +pbjs.registerBidAdapter = function (bidderAdaptor, bidderCode) { + utils.logInfo('Invoking pbjs.registerBidAdapter', arguments); + try { + adaptermanager.registerBidAdapter(bidderAdaptor(), bidderCode); + } catch (e) { + utils.logError('Error registering bidder adapter : ' + e.message); + } +}; +/** + * Wrapper to register analyticsAdapter externally (adaptermanager.registerAnalyticsAdapter()) + * @param {Object} options [description] + * @alias module:pbjs.registerAnalyticsAdapter + */ +pbjs.registerAnalyticsAdapter = function (options) { + utils.logInfo('Invoking pbjs.registerAnalyticsAdapter', arguments); + try { + adaptermanager.registerAnalyticsAdapter(options); + } catch (e) { + utils.logError('Error registering analytics adapter : ' + e.message); + } +}; -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.store = store; -exports.getCacheUrl = getCacheUrl; +/** + * @alias module:pbjs.bidsAvailableForAdapter +*/ +pbjs.bidsAvailableForAdapter = function (bidderCode) { + utils.logInfo('Invoking pbjs.bidsAvailableForAdapter', arguments); -var _ajax = __webpack_require__(7); + pbjs._bidsRequested.find((function (bidderRequest) { + return bidderRequest.bidderCode === bidderCode; + })).bids.map((function (bid) { + return _extends(bid, bidfactory.createBid(1), { + bidderCode: bidderCode, + adUnitCode: bid.placementCode + }); + })).map((function (bid) { + return pbjs._bidsReceived.push(bid); + })); +}; -var BASE_URL = 'https://prebid.adnxs.com/pbc/v1/cache'; +/** + * Wrapper to bidfactory.createBid() + * @param {string} statusCode [description] + * @alias module:pbjs.createBid + * @return {Object} bidResponse [description] + */ +pbjs.createBid = function (statusCode) { + utils.logInfo('Invoking pbjs.createBid', arguments); + return bidfactory.createBid(statusCode); +}; /** - * @typedef {object} CacheableUrlBid - * @property {string} vastUrl A URL which loads some valid VAST XML. + * Wrapper to bidmanager.addBidResponse + * @param {string} adUnitCode [description] + * @param {Object} bid [description] + * @alias module:pbjs.addBidResponse + * @deprecated This function will be removed in Prebid 1.0 + * Each bidder will be passed a reference to addBidResponse function in callBids as an argument. + * See https://github.com/prebid/Prebid.js/issues/1087 for more details. */ +pbjs.addBidResponse = function (adUnitCode, bid) { + utils.logWarn('pbjs.addBidResponse will be removed in Prebid 1.0. Each bidder will be passed a reference to addBidResponse function in callBids as an argument. See https://github.com/prebid/Prebid.js/issues/1087 for more details.'); + utils.logInfo('Invoking pbjs.addBidResponse', arguments); + bidmanager.addBidResponse(adUnitCode, bid); +}; /** - * @typedef {object} CacheablePayloadBid - * @property {string} vastXml Some VAST XML which loads an ad in a video player. + * Wrapper to adloader.loadScript + * @param {string} tagSrc [description] + * @param {Function} callback [description] + * @alias module:pbjs.loadScript */ +pbjs.loadScript = function (tagSrc, callback, useCache) { + utils.logInfo('Invoking pbjs.loadScript', arguments); + (0, _adloader.loadScript)(tagSrc, callback, useCache); +}; /** - * A CacheableBid describes the types which the videoCache can store. + * Enable sending analytics data to the analytics provider of your + * choice. * - * @typedef {CacheableUrlBid|CacheablePayloadBid} CacheableBid + * For usage, see [Integrate with the Prebid Analytics + * API](http://prebid.org/dev-docs/integrate-with-the-prebid-analytics-api.html). + * + * For a list of analytics adapters, see [Analytics for + * Prebid](http://prebid.org/overview/analytics.html). + * @param {Object} config + * @param {string} config.provider The name of the provider, e.g., `"ga"` for Google Analytics. + * @param {Object} config.options The options for this particular analytics adapter. This will likely vary between adapters. + * @alias module:pbjs.enableAnalytics */ +pbjs.enableAnalytics = function (config) { + if (config && !utils.isEmpty(config)) { + utils.logInfo('Invoking pbjs.enableAnalytics for: ', config); + adaptermanager.enableAnalytics(config); + } else { + utils.logError('pbjs.enableAnalytics should be called with option {}'); + } +}; /** - * Function which wraps a URI that serves VAST XML, so that it can be loaded. + * @alias module:pbjs.aliasBidder + */ +pbjs.aliasBidder = function (bidderCode, alias) { + utils.logInfo('Invoking pbjs.aliasBidder', arguments); + if (bidderCode && alias) { + adaptermanager.aliasBidAdapter(bidderCode, alias); + } else { + utils.logError('bidderCode and alias must be passed as arguments', 'pbjs.aliasBidder'); + } +}; + +/** + * Sets a default price granularity scheme. + * @param {string|Object} granularity - the granularity scheme. + * @alias module:pbjs.setPriceGranularity + * @deprecated - use pbjs.setConfig({ priceGranularity: }) + * "low": $0.50 increments, capped at $5 CPM + * "medium": $0.10 increments, capped at $20 CPM (the default) + * "high": $0.01 increments, capped at $20 CPM + * "auto": Applies a sliding scale to determine granularity + * "dense": Like "auto", but the bid price granularity uses smaller increments, especially at lower CPMs * - * @param {string} uri The URI where the VAST content can be found. - * @return A VAST URL which loads XML from the given URI. + * Alternatively a custom object can be specified: + * { "buckets" : [{"min" : 0,"max" : 20,"increment" : 0.1,"cap" : true}]}; + * See http://prebid.org/dev-docs/publisher-api-reference.html#module_pbjs.setPriceGranularity for more details */ +pbjs.setPriceGranularity = function (granularity) { + utils.logWarn('pbjs.setPriceGranularity will be removed in Prebid 1.0. Use pbjs.setConfig({ priceGranularity: }) instead.'); + utils.logInfo('Invoking pbjs.setPriceGranularity', arguments); + _config.config.setConfig({ priceGranularity: granularity }); +}; + /** - * This module interacts with the server used to cache video ad content to be restored later. - * At a high level, the expected workflow goes like this: + * @alias module:pbjs.enableSendAllBids + * @deprecated - use pbjs.setConfig({ enableSendAllBids: }) +*/ +pbjs.enableSendAllBids = function () { + _config.config.setConfig({ enableSendAllBids: true }); +}; + +/** + * @alias module:pbjs.getAllWinningBids + * The bid response object returned by an external bidder adapter during the auction. + * @typedef {Object} AdapterBidResponse + * @property {string} pbAg Auto granularity price bucket; CPM <= 5 ? increment = 0.05 : CPM > 5 && CPM <= 10 ? increment = 0.10 : CPM > 10 && CPM <= 20 ? increment = 0.50 : CPM > 20 ? priceCap = 20.00. Example: `"0.80"`. + * @property {string} pbCg Custom price bucket. For example setup, see {@link setPriceGranularity}. Example: `"0.84"`. + * @property {string} pbDg Dense granularity price bucket; CPM <= 3 ? increment = 0.01 : CPM > 3 && CPM <= 8 ? increment = 0.05 : CPM > 8 && CPM <= 20 ? increment = 0.50 : CPM > 20? priceCap = 20.00. Example: `"0.84"`. + * @property {string} pbLg Low granularity price bucket; $0.50 increment, capped at $5, floored to two decimal places. Example: `"0.50"`. + * @property {string} pbMg Medium granularity price bucket; $0.10 increment, capped at $20, floored to two decimal places. Example: `"0.80"`. + * @property {string} pbHg High granularity price bucket; $0.01 increment, capped at $20, floored to two decimal places. Example: `"0.84"`. * - * - Request video ads from Bidders - * - Generate IDs for each valid bid, and cache the key/value pair on the server. - * - Return these IDs so that publishers can use them to fetch the bids later. + * @property {string} bidder The string name of the bidder. This *may* be the same as the `bidderCode`. For For a list of all bidders and their codes, see [Bidders' Params](http://prebid.org/dev-docs/bidders.html). + * @property {string} bidderCode The unique string that identifies this bidder. For a list of all bidders and their codes, see [Bidders' Params](http://prebid.org/dev-docs/bidders.html). * - * This trickery helps integrate with ad servers, which set character limits on request params. + * @property {string} requestId The [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier) representing the bid request. + * @property {number} requestTimestamp The time at which the bid request was sent out, expressed in milliseconds. + * @property {number} responseTimestamp The time at which the bid response was received, expressed in milliseconds. + * @property {number} timeToRespond How long it took for the bidder to respond with this bid, expressed in milliseconds. + * + * @property {string} size The size of the ad creative, expressed in `"AxB"` format, where A and B are numbers of pixels. Example: `"320x50"`. + * @property {string} width The width of the ad creative in pixels. Example: `"320"`. + * @property {string} height The height of the ad creative in pixels. Example: `"50"`. + * + * @property {string} ad The actual ad creative content, often HTML with CSS, JavaScript, and/or links to additional content. Example: `"",`. + * @property {number} ad_id The ad ID of the creative, as understood by the bidder's system. Used by the line item's [creative in the ad server](http://prebid.org/adops/send-all-bids-adops.html#step-3-add-a-creative). + * @property {string} adUnitCode The code used to uniquely identify the ad unit on the publisher's page. + * + * @property {string} statusMessage The status of the bid. Allowed values: `"Bid available"` or `"Bid returned empty or error response"`. + * @property {number} cpm The exact bid price from the bidder, expressed to the thousandths place. Example: `"0.849"`. + * + * @property {Object} adserverTargeting An object whose values represent the ad server's targeting on the bid. + * @property {string} adserverTargeting.hb_adid The ad ID of the creative, as understood by the ad server. + * @property {string} adserverTargeting.hb_pb The price paid to show the creative, as logged in the ad server. + * @property {string} adserverTargeting.hb_bidder The winning bidder whose ad creative will be served by the ad server. +*/ + +/** + * Get all of the bids that have won their respective auctions. Useful for [troubleshooting your integration](http://prebid.org/dev-docs/prebid-troubleshooting-guide.html). + * @return {Array} A list of bids that have won their respective auctions. +*/ +pbjs.getAllWinningBids = function () { + return pbjs._winningBids; +}; + +/** + * Build master video tag from publishers adserver tag + * @param {string} adserverTag default url + * @param {Object} options options for video tag + * @alias module:pbjs.buildMasterVideoTagFromAdserverTag + * @deprecated Include the dfpVideoSupport module in your build, and use the pbjs.adservers.dfp.buildVideoAdUrl function instead. + * This function will be removed in Prebid 1.0. */ +pbjs.buildMasterVideoTagFromAdserverTag = function (adserverTag, options) { + utils.logWarn('pbjs.buildMasterVideoTagFromAdserverTag will be removed in Prebid 1.0. Include the dfpVideoSupport module in your build, and use the pbjs.adservers.dfp.buildVideoAdUrl function instead'); + utils.logInfo('Invoking pbjs.buildMasterVideoTagFromAdserverTag', arguments); + var urlComponents = (0, _url.parse)(adserverTag); -function wrapURI(uri) { - // Technically, this is vulnerable to cross-script injection by sketchy vastUrl bids. - // We could make sure it's a valid URI... but since we're loading VAST XML from the - // URL they provide anyway, that's probably not a big deal. - return '\n \n \n prebid.org wrapper\n \n \n \n \n \n '; -} + // return original adserverTag if no bids received + if (pbjs._bidsReceived.length === 0) { + return adserverTag; + } + + var masterTag = ''; + if (options.adserver.toLowerCase() === 'dfp') { + var dfpAdserverObj = adserver.dfpAdserver(options, urlComponents); + if (!dfpAdserverObj.verifyAdserverTag()) { + utils.logError('Invalid adserverTag, required google params are missing in query string'); + } + dfpAdserverObj.appendQueryParams(); + masterTag = (0, _url.format)(dfpAdserverObj.urlComponents); + } else { + utils.logError('Only DFP adserver is supported'); + return; + } + return masterTag; +}; /** - * Wraps a bid in the format expected by the prebid-server endpoints, or returns null if - * the bid can't be converted cleanly. + * Set the order bidders are called in. Valid values are: * - * @param {CacheableBid} bid - */ -function toStorageRequest(bid) { - var vastValue = bid.vastXml ? bid.vastXml : wrapURI(bid.vastUrl); - return { - type: 'xml', - value: vastValue - }; -} - -/** - * A function which should be called with the results of the storage operation. + * "fixed": Bidders will be called in the order in which they were defined within the adUnit.bids array. + * "random": Bidders will be called in random order. * - * @callback videoCacheStoreCallback + * If never called, Prebid will use "random" as the default. * - * @param {Error} [error] The error, if one occurred. - * @param {?string[]} uuids An array of unique IDs. The array will have one element for each bid we were asked - * to store. It may include null elements if some of the bids were malformed, or an error occurred. - * Each non-null element in this array is a valid input into the retrieve function, which will fetch - * some VAST XML which can be used to render this bid's ad. + * @param {string} order One of the valid orders, described above. + * @alias module:pbjs.setBidderSequence + * @deprecated - use pbjs.setConfig({ bidderSequence: }) */ +pbjs.setBidderSequence = adaptermanager.setBidderSequence; /** - * A function which bridges the APIs between the videoCacheStoreCallback and our ajax function's API. - * - * @param {videoCacheStoreCallback} done A callback to the "store" function. - * @return {Function} A callback which interprets the cache server's responses, and makes up the right - * arguments for our callback. + * Get array of highest cpm bids for all adUnits, or highest cpm bid + * object for the given adUnit + * @param {string} adUnitCode - optional ad unit code + * @alias module:pbjs.getHighestCpmBids + * @return {Array} array containing highest cpm bid object(s) */ -function shimStorageCallback(done) { - return { - success: function success(responseBody) { - var ids = void 0; - try { - ids = JSON.parse(responseBody).responses; - } catch (e) { - done(e, []); - return; - } - - if (ids) { - done(null, ids); - } else { - done(new Error("The cache server didn't respond with a responses property."), []); - } - }, - error: function error(statusText, responseBody) { - done(new Error('Error storing video ad in the cache: ' + statusText + ': ' + JSON.stringify(responseBody)), []); - } - }; -} +pbjs.getHighestCpmBids = function (adUnitCode) { + return targeting.getWinningBids(adUnitCode); +}; /** - * If the given bid is for a Video ad, generate a unique ID and cache it somewhere server-side. - * - * @param {CacheableBid[]} bids A list of bid objects which should be cached. - * @param {videoCacheStoreCallback} [done] An optional callback which should be executed after - * the data has been stored in the cache. + * Set config for server to server header bidding + * @deprecated - use pbjs.setConfig({ s2sConfig: }) + * @typedef {Object} options - required + * @property {boolean} enabled enables S2S bidding + * @property {string[]} bidders bidders to request S2S + * === optional params below === + * @property {string} [endpoint] endpoint to contact + * @property {number} [timeout] timeout for S2S bidders - should be lower than `pbjs.requestBids({timeout})` + * @property {string} [adapter] adapter code to use for S2S + * @property {string} [syncEndpoint] endpoint URL for syncing cookies + * @property {boolean} [cookieSet] enables cookieSet functionality + * @alias module:pbjs.setS2SConfig */ -function store(bids, done) { - var requestData = { - puts: bids.map(toStorageRequest) - }; - - (0, _ajax.ajax)(BASE_URL, shimStorageCallback(done), JSON.stringify(requestData), { - contentType: 'text/plain', - withCredentials: true - }); -} - -function getCacheUrl(id) { - return BASE_URL + '?uuid=' + id; -} - -/***/ }), - -/***/ 49: -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; +pbjs.setS2SConfig = function (options) { + if (!utils.contains(Object.keys(options), 'accountId')) { + utils.logError('accountId missing in Server to Server config'); + return; + } -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + if (!utils.contains(Object.keys(options), 'bidders')) { + utils.logError('bidders missing in Server to Server config'); + return; + } -exports.createHook = createHook; + var config = _extends({ + enabled: false, + endpoint: CONSTANTS.S2S.DEFAULT_ENDPOINT, + timeout: 1000, + maxBids: 1, + adapter: CONSTANTS.S2S.ADAPTER, + syncEndpoint: CONSTANTS.S2S.SYNC_ENDPOINT, + cookieSet: true, + bidders: [] + }, options); + adaptermanager.setS2SConfig(config); +}; /** - * @typedef {function} HookedFunction - * @property {function(function(), [number])} addHook A method that takes a new function to attach as a hook - * to the HookedFunction - * @property {function(function())} removeHook A method to remove attached hooks + * Get Prebid config options + * @param {Object} options + * @alias module:pbjs.getConfig */ +pbjs.getConfig = _config.config.getConfig; /** - * A map of global hook methods to allow easy extension of hooked functions that are intended to be extended globally - * @type {{}} + * Set Prebid config options. + * (Added in version 0.27.0). + * + * `setConfig` is designed to allow for advanced configuration while + * reducing the surface area of the public API. For more information + * about the move to `setConfig` (and the resulting deprecations of + * some other public methods), see [the Prebid 1.0 public API + * proposal](https://gist.github.com/mkendall07/51ee5f6b9f2df01a89162cf6de7fe5b6). + * + * #### Troubleshooting your configuration + * + * If you call `pbjs.setConfig` without an object, e.g., + * + * `pbjs.setConfig('debug', 'true'))` + * + * then Prebid.js will print an error to the console that says: + * + * ``` + * ERROR: setConfig options must be an object + * ``` + * + * If you don't see that message, you can assume the config object is valid. + * + * @param {Object} options Global Prebid configuration object. Must be JSON - no JavaScript functions are allowed. + * @param {string} options.bidderSequence The order in which bidders are called. Example: `pbjs.setConfig({ bidderSequence: "fixed" })`. Allowed values: `"fixed"` (order defined in `adUnit.bids` array on page), `"random"`. + * @param {boolean} options.debug Turn debug logging on/off. Example: `pbjs.setConfig({ debug: true })`. + * @param {string} options.priceGranularity The bid price granularity to use. Example: `pbjs.setConfig({ priceGranularity: "medium" })`. Allowed values: `"low"` ($0.50), `"medium"` ($0.10), `"high"` ($0.01), `"auto"` (sliding scale), `"dense"` (like `"auto"`, with smaller increments at lower CPMs), or a custom price bucket object, e.g., `{ "buckets" : [{"min" : 0,"max" : 20,"increment" : 0.1,"cap" : true}]}`. + * @param {boolean} options.enableSendAllBids Turn "send all bids" mode on/off. Example: `pbjs.setConfig({ enableSendAllBids: true })`. + * @param {number} options.bidderTimeout Set a global bidder timeout, in milliseconds. Example: `pbjs.setConfig({ bidderTimeout: 3000 })`. Note that it's still possible for a bid to get into the auction that responds after this timeout. This is due to how [`setTimeout`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout) works in JS: it queues the callback in the event loop in an approximate location that should execute after this time but it is not guaranteed. For more information about the asynchronous event loop and `setTimeout`, see [How JavaScript Timers Work](https://johnresig.com/blog/how-javascript-timers-work/). + * @param {string} options.publisherDomain The publisher's domain where Prebid is running, for cross-domain iFrame communication. Example: `pbjs.setConfig({ publisherDomain: "https://www.theverge.com" })`. + * @param {number} options.cookieSyncDelay A delay (in milliseconds) for requesting cookie sync to stay out of the critical path of page load. Example: `pbjs.setConfig({ cookieSyncDelay: 100 })`. + * @param {Object} options.s2sConfig The configuration object for [server-to-server header bidding](http://prebid.org/dev-docs/get-started-with-prebid-server.html). Example: + * @alias module:pbjs.setConfig + * ``` + * pbjs.setConfig({ + * s2sConfig: { + * accountId: '1', + * enabled: true, + * bidders: ['appnexus', 'pubmatic'], + * timeout: 1000, + * adapter: 'prebidServer', + * endpoint: 'https://prebid.adnxs.com/pbs/v1/auction' + * } + * }) + * ``` */ -var hooks = exports.hooks = {}; +pbjs.setConfig = _config.config.setConfig; + +pbjs.que.push((function () { + return (0, _secureCreatives.listenMessagesFromCreative)(); +})); /** - * A utility function for allowing a regular function to be extensible with additional hook functions - * @param {string} type The method for applying all attached hooks when this hooked function is called - * @param {function()} fn The function to make hookable - * @param {string} hookName If provided this allows you to register a name for a global hook to have easy access to - * the addHook and removeHook methods for that hook (which are usually accessed as methods on the function itself) - * @returns {HookedFunction} A new function that implements the HookedFunction interface + * This queue lets users load Prebid asynchronously, but run functions the same way regardless of whether it gets loaded + * before or after their script executes. For example, given the code: + * + * + * + * + * If the page's script runs before prebid loads, then their function gets added to the queue, and executed + * by prebid once it's done loading. If it runs after prebid loads, then this monkey-patch causes their + * function to execute immediately. + * + * @memberof pbjs + * @param {function} command A function which takes no arguments. This is guaranteed to run exactly once, and only after + * the Prebid script has been fully loaded. + * @alias module:pbjs.cmd.push */ -function createHook(type, fn, hookName) { - var _hooks = [{ fn: fn, priority: 0 }]; - - var types = { - sync: function sync() { - var _this = this; - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - _hooks.forEach((function (hook) { - hook.fn.apply(_this, args); - })); - }, - asyncSeries: function asyncSeries() { - var _this2 = this; - - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - var curr = 0; - - var asyncSeriesNext = function asyncSeriesNext() { - for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { - args[_key3] = arguments[_key3]; - } - - var hook = _hooks[++curr]; - if ((typeof hook === 'undefined' ? 'undefined' : _typeof(hook)) === 'object' && typeof hook.fn === 'function') { - return hook.fn.apply(_this2, args.concat(asyncSeriesNext)); - } - }; - - return _hooks[curr].fn.apply(this, args.concat(asyncSeriesNext)); +pbjs.cmd.push = function (command) { + if (typeof command === 'function') { + try { + command.call(); + } catch (e) { + utils.logError('Error processing command :', e.message, e.stack); } - }; - - if (!types[type]) { - throw 'invalid hook type'; + } else { + utils.logError('Commands written into pbjs.cmd.push must be wrapped in a function'); } +}; - var methods = { - addHook: function addHook(fn) { - var priority = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10; - - if (typeof fn === 'function') { - _hooks.push({ - fn: fn, - priority: priority - }); +pbjs.que.push = pbjs.cmd.push; - _hooks.sort((function (a, b) { - return b.priority - a.priority; - })); +function processQueue(queue) { + queue.forEach((function (cmd) { + if (typeof cmd.called === 'undefined') { + try { + cmd.call(); + cmd.called = true; + } catch (e) { + utils.logError('Error processing command :', 'prebid.js', e); } - }, - removeHook: function removeHook(removeFn) { - _hooks = _hooks.filter((function (hook) { - return hook.fn === fn || hook.fn !== removeFn; - })); - } - }; - - if (typeof hookName === 'string') { - hooks[hookName] = methods; - } - - function hookedFn() { - for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { - args[_key4] = arguments[_key4]; - } - - if (_hooks.length === 0) { - return fn.apply(this, args); } - return types[type].apply(this, args); - } - - return _extends(hookedFn, methods); + })); } -/***/ }), +/** + * @alias module:pbjs.processQueue + */ +pbjs.processQueue = function () { + processQueue(pbjs.que); + processQueue(pbjs.cmd); +}; -/***/ 5: +/***/ }), +/* 395 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var utils = __webpack_require__(0); -var _requestCache = {}; - -// add a script tag to the page, used to add /jpt call to page -exports.loadScript = function (tagSrc, callback, cacheRequest) { - // var noop = () => {}; - // - // callback = callback || noop; - if (!tagSrc) { - utils.logError('Error attempting to request empty URL', 'adloader.js:loadScript'); - return; - } - - if (cacheRequest) { - if (_requestCache[tagSrc]) { - if (callback && typeof callback === 'function') { - if (_requestCache[tagSrc].loaded) { - // invokeCallbacks immediately - callback(); - } else { - // queue the callback - _requestCache[tagSrc].callbacks.push(callback); - } - } - } else { - _requestCache[tagSrc] = { - loaded: false, - callbacks: [] - }; - if (callback && typeof callback === 'function') { - _requestCache[tagSrc].callbacks.push(callback); - } +/** @module polyfill +Misc polyfills +*/ +__webpack_require__(396); +__webpack_require__(409); +__webpack_require__(411); +__webpack_require__(414); - requestResource(tagSrc, (function () { - _requestCache[tagSrc].loaded = true; - try { - for (var i = 0; i < _requestCache[tagSrc].callbacks.length; i++) { - _requestCache[tagSrc].callbacks[i](); - } - } catch (e) { - utils.logError('Error executing callback', 'adloader.js:loadScript', e); - } - })); - } - } else { - // trigger one time request - requestResource(tagSrc, callback); - } +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger +Number.isInteger = Number.isInteger || function (value) { + return typeof value === 'number' && isFinite(value) && Math.floor(value) === value; }; -function requestResource(tagSrc, callback) { - var jptScript = document.createElement('script'); - jptScript.type = 'text/javascript'; - jptScript.async = true; - - // Execute a callback if necessary - if (callback && typeof callback === 'function') { - if (jptScript.readyState) { - jptScript.onreadystatechange = function () { - if (jptScript.readyState === 'loaded' || jptScript.readyState === 'complete') { - jptScript.onreadystatechange = null; - callback(); - } - }; - } else { - jptScript.onload = function () { - callback(); - }; - } - } +/***/ }), +/* 396 */ +/***/ (function(module, exports, __webpack_require__) { - jptScript.src = tagSrc; +__webpack_require__(397); +module.exports = __webpack_require__(14).Array.find; - // add the new script tag to the page - var elToAppend = document.getElementsByTagName('head'); - elToAppend = elToAppend.length ? elToAppend : document.getElementsByTagName('body'); - if (elToAppend.length) { - elToAppend = elToAppend[0]; - elToAppend.insertBefore(jptScript, elToAppend.firstChild); - } -} /***/ }), - -/***/ 6: +/* 397 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true +// 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined) +var $export = __webpack_require__(22); +var $find = __webpack_require__(48)(5); +var KEY = 'find'; +var forced = true; +// Shouldn't skip holes +if (KEY in []) Array(1)[KEY]((function () { forced = false; })); +$export($export.P + $export.F * forced, 'Array', { + find: function find(callbackfn /* , that = undefined */) { + return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); + } }); +__webpack_require__(33)(KEY); -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -exports.registerBidder = registerBidder; -exports.newBidder = newBidder; - -var _adapter = __webpack_require__(8); - -var _adapter2 = _interopRequireDefault(_adapter); - -var _adaptermanager = __webpack_require__(1); -var _adaptermanager2 = _interopRequireDefault(_adaptermanager); +/***/ }), +/* 398 */ +/***/ (function(module, exports, __webpack_require__) { -var _config = __webpack_require__(9); +var anObject = __webpack_require__(399); +var IE8_DOM_DEFINE = __webpack_require__(400); +var toPrimitive = __webpack_require__(402); +var dP = Object.defineProperty; -var _ajax = __webpack_require__(7); +exports.f = __webpack_require__(29) ? Object.defineProperty : function defineProperty(O, P, Attributes) { + anObject(O); + P = toPrimitive(P, true); + anObject(Attributes); + if (IE8_DOM_DEFINE) try { + return dP(O, P, Attributes); + } catch (e) { /* empty */ } + if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!'); + if ('value' in Attributes) O[P] = Attributes.value; + return O; +}; -var _bidmanager = __webpack_require__(2); -var _bidmanager2 = _interopRequireDefault(_bidmanager); +/***/ }), +/* 399 */ +/***/ (function(module, exports, __webpack_require__) { -var _bidfactory = __webpack_require__(3); +var isObject = __webpack_require__(23); +module.exports = function (it) { + if (!isObject(it)) throw TypeError(it + ' is not an object!'); + return it; +}; -var _bidfactory2 = _interopRequireDefault(_bidfactory); -var _constants = __webpack_require__(4); +/***/ }), +/* 400 */ +/***/ (function(module, exports, __webpack_require__) { -var _userSync = __webpack_require__(18); +module.exports = !__webpack_require__(29) && !__webpack_require__(30)((function () { + return Object.defineProperty(__webpack_require__(401)('div'), 'a', { get: function () { return 7; } }).a != 7; +})); -var _utils = __webpack_require__(0); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } +/***/ }), +/* 401 */ +/***/ (function(module, exports, __webpack_require__) { -/** - * This file aims to support Adapters during the Prebid 0.x -> 1.x transition. - * - * Prebid 1.x and Prebid 0.x will be in separate branches--perhaps for a long time. - * This function defines an API for adapter construction which is compatible with both versions. - * Adapters which use it can maintain their code in master, and only this file will need to change - * in the 1.x branch. - * - * Typical usage looks something like: - * - * const adapter = registerBidder({ - * code: 'myBidderCode', - * aliases: ['alias1', 'alias2'], - * supportedMediaTypes: ['video', 'native'], - * isBidRequestValid: function(paramsObject) { return true/false }, - * buildRequests: function(bidRequests, bidderRequest) { return some ServerRequest(s) }, - * interpretResponse: function(oneServerResponse) { return some Bids, or throw an error. } - * }); - * - * @see BidderSpec for the full API and more thorough descriptions. - */ +var isObject = __webpack_require__(23); +var document = __webpack_require__(16).document; +// typeof document.createElement is 'object' in old IE +var is = isObject(document) && isObject(document.createElement); +module.exports = function (it) { + return is ? document.createElement(it) : {}; +}; -/** - * @typedef {object} BidderSpec An object containing the adapter-specific functions needed to - * make a Bidder. - * - * @property {string} code A code which will be used to uniquely identify this bidder. This should be the same - * one as is used in the call to registerBidAdapter - * @property {string[]} [aliases] A list of aliases which should also resolve to this bidder. - * @property {MediaType[]} [supportedMediaTypes]: A list of Media Types which the adapter supports. - * @property {function(object): boolean} isBidRequestValid Determines whether or not the given bid has all the params - * needed to make a valid request. - * @property {function(BidRequest[], bidderRequest): ServerRequest|ServerRequest[]} buildRequests Build the request to the Server - * which requests Bids for the given array of Requests. Each BidRequest in the argument array is guaranteed to have - * passed the isBidRequestValid() test. - * @property {function(ServerResponse, BidRequest): Bid[]} interpretResponse Given a successful response from the Server, - * interpret it and return the Bid objects. This function will be run inside a try/catch. - * If it throws any errors, your bids will be discarded. - * @property {function(SyncOptions, ServerResponse[]): UserSync[]} [getUserSyncs] Given an array of all the responses - * from the server, determine which user syncs should occur. The argument array will contain every element - * which has been sent through to interpretResponse. The order of syncs in this array matters. The most - * important ones should come first, since publishers may limit how many are dropped on their page. - */ -/** - * @typedef {object} BidRequest - * - * @property {string} bidId A string which uniquely identifies this BidRequest in the current Auction. - * @property {object} params Any bidder-specific params which the publisher used in their bid request. - */ +/***/ }), +/* 402 */ +/***/ (function(module, exports, __webpack_require__) { -/** - * @typedef {object} ServerRequest - * - * @property {('GET'|'POST')} method The type of request which this is. - * @property {string} url The endpoint for the request. For example, "//bids.example.com". - * @property {string|object} data Data to be sent in the request. - * @property {object} options Content-Type set in the header of the bid request, overrides default 'text/plain'. - * If this is a GET request, they'll become query params. If it's a POST request, they'll be added to the body. - * Strings will be added as-is. Objects will be unpacked into query params based on key/value mappings, or - * JSON-serialized into the Request body. - */ +// 7.1.1 ToPrimitive(input [, PreferredType]) +var isObject = __webpack_require__(23); +// instead of the ES6 spec version, we didn't implement @@toPrimitive case +// and the second argument - flag - preferred type is a string +module.exports = function (it, S) { + if (!isObject(it)) return it; + var fn, val; + if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; + if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val; + if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; + throw TypeError("Can't convert object to primitive value"); +}; -/** - * @typedef {object} ServerResponse - * - * @property {*} body The response body. If this is legal JSON, then it will be parsed. Otherwise it'll be a - * string with the body's content. - * @property {{get: function(string): string} headers The response headers. - * Call this like `ServerResponse.headers.get("Content-Type")` - */ -/** - * @typedef {object} Bid - * - * @property {string} requestId The specific BidRequest which this bid is aimed at. - * This should match the BidRequest.bidId which this Bid targets. - * @property {string} ad A URL which can be used to load this ad, if it's chosen by the publisher. - * @property {string} currency The currency code for the cpm value - * @property {number} cpm The bid price, in US cents per thousand impressions. - * @property {number} ttl Time-to-live - how long (in seconds) Prebid can use this bid. - * @property {boolean} netRevenue Boolean defining whether the bid is Net or Gross. The default is true (Net). - * @property {number} height The height of the ad, in pixels. - * @property {number} width The width of the ad, in pixels. - * - * @property [Renderer] renderer A Renderer which can be used as a default for this bid, - * if the publisher doesn't override it. This is only relevant for Outstream Video bids. - */ +/***/ }), +/* 403 */ +/***/ (function(module, exports) { -/** - * @typedef {Object} SyncOptions - * - * An object containing information about usersyncs which the adapter should obey. - * - * @property {boolean} iframeEnabled True if iframe usersyncs are allowed, and false otherwise - * @property {boolean} pixelEnabled True if image usersyncs are allowed, and false otherwise - */ +module.exports = function (bitmap, value) { + return { + enumerable: !(bitmap & 1), + configurable: !(bitmap & 2), + writable: !(bitmap & 4), + value: value + }; +}; -/** - * TODO: Move this to the UserSync module after that PR is merged. - * - * @typedef {object} UserSync - * - * @property {('image'|'iframe')} type The type of user sync to be done. - * @property {string} url The URL which makes the sync happen. - */ -// common params for all mediaTypes -var COMMON_BID_RESPONSE_KEYS = ['requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency']; +/***/ }), +/* 404 */ +/***/ (function(module, exports, __webpack_require__) { -/** - * Register a bidder with prebid, using the given spec. - * - * If possible, Adapter modules should use this function instead of adaptermanager.registerBidAdapter(). - * - * @param {BidderSpec} spec An object containing the bare-bones functions we need to make a Bidder. - */ -function registerBidder(spec) { - var mediaTypes = Array.isArray(spec.supportedMediaTypes) ? { supportedMediaTypes: spec.supportedMediaTypes } : undefined; - function putBidder(spec) { - var bidder = newBidder(spec); - _adaptermanager2['default'].registerBidAdapter(bidder, spec.code, mediaTypes); - } +var global = __webpack_require__(16); +var hide = __webpack_require__(28); +var has = __webpack_require__(46); +var SRC = __webpack_require__(31)('src'); +var TO_STRING = 'toString'; +var $toString = Function[TO_STRING]; +var TPL = ('' + $toString).split(TO_STRING); - putBidder(spec); - if (Array.isArray(spec.aliases)) { - spec.aliases.forEach((function (alias) { - putBidder(_extends({}, spec, { code: alias })); - })); +__webpack_require__(14).inspectSource = function (it) { + return $toString.call(it); +}; + +(module.exports = function (O, key, val, safe) { + var isFunction = typeof val == 'function'; + if (isFunction) has(val, 'name') || hide(val, 'name', key); + if (O[key] === val) return; + if (isFunction) has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key))); + if (O === global) { + O[key] = val; + } else if (!safe) { + delete O[key]; + hide(O, key, val); + } else if (O[key]) { + O[key] = val; + } else { + hide(O, key, val); } -} +// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative +})(Function.prototype, TO_STRING, (function toString() { + return typeof this == 'function' && this[SRC] || $toString.call(this); +})); -/** - * Make a new bidder from the given spec. This is exported mainly for testing. - * Adapters will probably find it more convenient to use registerBidder instead. - * - * @param {BidderSpec} spec - */ -function newBidder(spec) { - return _extends(new _adapter2['default'](spec.code), { - getSpec: function getSpec() { - return Object.freeze(spec); - }, - registerSyncs: registerSyncs, - callBids: function callBids(bidderRequest) { - if (!Array.isArray(bidderRequest.bids)) { - return; - } - // callBids must add a NO_BID response for _every_ AdUnit code, in order for the auction to - // end properly. This map stores placement codes which we've made _real_ bids on. - // - // As we add _real_ bids to the bidmanager, we'll log the ad unit codes here too. Once all the real - // bids have been added, fillNoBids() can be called to add NO_BID bids for any extra ad units, which - // will end the auction. - // - // In Prebid 1.0, this will be simplified to use the `addBidResponse` and `done` callbacks. - var adUnitCodesHandled = {}; - function addBidWithCode(adUnitCode, bid) { - adUnitCodesHandled[adUnitCode] = true; - addBid(adUnitCode, bid); - } - function fillNoBids() { - bidderRequest.bids.map((function (bidRequest) { - return bidRequest.placementCode; - })).forEach((function (adUnitCode) { - if (adUnitCode && !adUnitCodesHandled[adUnitCode]) { - addBid(adUnitCode, newEmptyBid()); - } - })); - } +/***/ }), +/* 405 */ +/***/ (function(module, exports) { - function addBid(code, bid) { - try { - _bidmanager2['default'].addBidResponse(code, bid); - } catch (err) { - (0, _utils.logError)('Error adding bid', code, err); - } - } +module.exports = function (it) { + if (typeof it != 'function') throw TypeError(it + ' is not a function!'); + return it; +}; - // After all the responses have come back, fill up the "no bid" bids and - // register any required usersync pixels. - var responses = []; - function afterAllResponses() { - fillNoBids(); - registerSyncs(responses); - } - var validBidRequests = bidderRequest.bids.filter(filterAndWarn); - if (validBidRequests.length === 0) { - afterAllResponses(); - return; - } - var bidRequestMap = {}; - validBidRequests.forEach((function (bid) { - bidRequestMap[bid.bidId] = bid; - // Delete this once we are 1.0 - if (!bid.adUnitCode) { - bid.adUnitCode = bid.placementCode; - } - })); +/***/ }), +/* 406 */ +/***/ (function(module, exports, __webpack_require__) { - var requests = spec.buildRequests(validBidRequests, bidderRequest); - if (!requests || requests.length === 0) { - afterAllResponses(); - return; - } - if (!Array.isArray(requests)) { - requests = [requests]; - } +// 9.4.2.3 ArraySpeciesCreate(originalArray, length) +var speciesConstructor = __webpack_require__(407); - // Callbacks don't compose as nicely as Promises. We should call fillNoBids() once _all_ the - // Server requests have returned and been processed. Since `ajax` accepts a single callback, - // we need to rig up a function which only executes after all the requests have been responded. - var onResponse = (0, _utils.delayExecution)(afterAllResponses, requests.length); - requests.forEach(processRequest); +module.exports = function (original, length) { + return new (speciesConstructor(original))(length); +}; - function formatGetParameters(data) { - if (data) { - return '?' + ((typeof data === 'undefined' ? 'undefined' : _typeof(data)) === 'object' ? (0, _utils.parseQueryStringParameters)(data) : data); - } - return ''; - } +/***/ }), +/* 407 */ +/***/ (function(module, exports, __webpack_require__) { - function processRequest(request) { - switch (request.method) { - case 'GET': - (0, _ajax.ajax)('' + request.url + formatGetParameters(request.data), { - success: onSuccess, - error: onFailure - }, undefined, _extends({ - method: 'GET', - withCredentials: true - }, request.options)); - break; - case 'POST': - (0, _ajax.ajax)(request.url, { - success: onSuccess, - error: onFailure - }, typeof request.data === 'string' ? request.data : JSON.stringify(request.data), _extends({ - method: 'POST', - contentType: 'text/plain', - withCredentials: true - }, request.options)); - break; - default: - (0, _utils.logWarn)('Skipping invalid request from ' + spec.code + '. Request type ' + request.type + ' must be GET or POST'); - onResponse(); - } +var isObject = __webpack_require__(23); +var isArray = __webpack_require__(408); +var SPECIES = __webpack_require__(54)('species'); + +module.exports = function (original) { + var C; + if (isArray(original)) { + C = original.constructor; + // cross-realm fallback + if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined; + if (isObject(C)) { + C = C[SPECIES]; + if (C === null) C = undefined; + } + } return C === undefined ? Array : C; +}; - // If the server responds successfully, use the adapter code to unpack the Bids from it. - // If the adapter code fails, no bids should be added. After all the bids have been added, make - // sure to call the `onResponse` function so that we're one step closer to calling fillNoBids(). - function onSuccess(response, responseObj) { - try { - response = JSON.parse(response); - } catch (e) {} /* response might not be JSON... that's ok. */ - // Make response headers available for #1742. These are lazy-loaded because most adapters won't need them. - response = { - body: response, - headers: headerParser(responseObj) - }; - responses.push(response); +/***/ }), +/* 408 */ +/***/ (function(module, exports, __webpack_require__) { - var bids = void 0; - try { - bids = spec.interpretResponse(response, request); - } catch (err) { - (0, _utils.logError)('Bidder ' + spec.code + ' failed to interpret the server\'s response. Continuing without bids', null, err); - onResponse(); - return; - } +// 7.2.2 IsArray(argument) +var cof = __webpack_require__(49); +module.exports = Array.isArray || function isArray(arg) { + return cof(arg) == 'Array'; +}; - if (bids) { - if (bids.forEach) { - bids.forEach(addBidUsingRequestMap); - } else { - addBidUsingRequestMap(bids); - } - } - onResponse(); - function addBidUsingRequestMap(bid) { - // In Prebid 1.0 all the validation logic from bidmanager will move here, as of now we are only validating new params so that adapters dont miss adding them. - if (hasValidKeys(bid)) { - var bidRequest = bidRequestMap[bid.requestId]; - if (bidRequest) { - var prebidBid = _extends(_bidfactory2['default'].createBid(_constants.STATUS.GOOD, bidRequest), bid); - addBidWithCode(bidRequest.placementCode, prebidBid); - } else { - (0, _utils.logWarn)('Bidder ' + spec.code + ' made bid for unknown request ID: ' + bid.requestId + '. Ignoring.'); - } - } else { - (0, _utils.logError)('Bidder ' + spec.code + ' is missing required params. Check http://prebid.org/dev-docs/bidder-adapter-1.html for list of params.'); - } - } +/***/ }), +/* 409 */ +/***/ (function(module, exports, __webpack_require__) { - function headerParser(xmlHttpResponse) { - return { - get: responseObj.getResponseHeader.bind(responseObj) - }; - } - } +__webpack_require__(410); +module.exports = __webpack_require__(14).Array.findIndex; - // If the server responds with an error, there's not much we can do. Log it, and make sure to - // call onResponse() so that we're one step closer to calling fillNoBids(). - function onFailure(err) { - (0, _utils.logError)('Server call for ' + spec.code + ' failed: ' + err + '. Continuing without bids.'); - onResponse(); - } - } - } - }); - function registerSyncs(responses) { - if (spec.getUserSyncs) { - var syncs = spec.getUserSyncs({ - iframeEnabled: _config.config.getConfig('userSync.iframeEnabled'), - pixelEnabled: _config.config.getConfig('userSync.pixelEnabled') - }, responses); - if (syncs) { - if (!Array.isArray(syncs)) { - syncs = [syncs]; - } - syncs.forEach((function (sync) { - _userSync.userSync.registerSync(sync.type, spec.code, sync.url); - })); - } - } - } +/***/ }), +/* 410 */ +/***/ (function(module, exports, __webpack_require__) { - function filterAndWarn(bid) { - if (!spec.isBidRequestValid(bid)) { - (0, _utils.logWarn)('Invalid bid sent to bidder ' + spec.code + ': ' + JSON.stringify(bid)); - return false; - } - return true; - } +"use strict"; - function hasValidKeys(bid) { - var bidKeys = Object.keys(bid); - return COMMON_BID_RESPONSE_KEYS.every((function (key) { - return bidKeys.includes(key); - })); +// 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined) +var $export = __webpack_require__(22); +var $find = __webpack_require__(48)(6); +var KEY = 'findIndex'; +var forced = true; +// Shouldn't skip holes +if (KEY in []) Array(1)[KEY]((function () { forced = false; })); +$export($export.P + $export.F * forced, 'Array', { + findIndex: function findIndex(callbackfn /* , that = undefined */) { + return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); } +}); +__webpack_require__(33)(KEY); - function newEmptyBid() { - var bid = _bidfactory2['default'].createBid(_constants.STATUS.NO_BID); - bid.code = spec.code; - bid.bidderCode = spec.code; - return bid; - } -} /***/ }), +/* 411 */ +/***/ (function(module, exports, __webpack_require__) { -/***/ 7: +__webpack_require__(412); +module.exports = __webpack_require__(14).Array.includes; + + +/***/ }), +/* 412 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; +// https://github.com/tc39/Array.prototype.includes +var $export = __webpack_require__(22); +var $includes = __webpack_require__(56)(true); -Object.defineProperty(exports, "__esModule", { - value: true +$export($export.P, 'Array', { + includes: function includes(el /* , fromIndex = 0 */) { + return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined); + } }); -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; +__webpack_require__(33)('includes'); -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; -exports.setAjaxTimeout = setAjaxTimeout; -exports.ajax = ajax; +/***/ }), +/* 413 */ +/***/ (function(module, exports, __webpack_require__) { -var _url = __webpack_require__(12); +var toInteger = __webpack_require__(53); +var max = Math.max; +var min = Math.min; +module.exports = function (index, length) { + index = toInteger(index); + return index < 0 ? max(index + length, 0) : min(index, length); +}; -var utils = __webpack_require__(0); -var XHR_DONE = 4; -var _timeout = 3000; +/***/ }), +/* 414 */ +/***/ (function(module, exports, __webpack_require__) { -/** - * Simple IE9+ and cross-browser ajax request function - * Note: x-domain requests in IE9 do not support the use of cookies - * - * @param url string url - * @param callback {object | function} callback - * @param data mixed data - * @param options object - */ -function setAjaxTimeout(timeout) { - _timeout = timeout; -} +__webpack_require__(415); +module.exports = __webpack_require__(14).Object.assign; -function ajax(url, callback, data) { - var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; - try { - var x = void 0; - var useXDomainRequest = false; - var method = options.method || (data ? 'POST' : 'GET'); +/***/ }), +/* 415 */ +/***/ (function(module, exports, __webpack_require__) { - var callbacks = (typeof callback === 'undefined' ? 'undefined' : _typeof(callback)) === 'object' ? callback : { - success: function success() { - utils.logMessage('xhr success'); - }, - error: function error(e) { - utils.logError('xhr error', null, e); - } - }; +// 19.1.3.1 Object.assign(target, source) +var $export = __webpack_require__(22); - if (typeof callback === 'function') { - callbacks.success = callback; - } +$export($export.S + $export.F, 'Object', { assign: __webpack_require__(416) }); - if (!window.XMLHttpRequest) { - useXDomainRequest = true; - } else { - x = new window.XMLHttpRequest(); - if (x.responseType === undefined) { - useXDomainRequest = true; - } - } - if (useXDomainRequest) { - x = new window.XDomainRequest(); - x.onload = function () { - callbacks.success(x.responseText, x); - }; +/***/ }), +/* 416 */ +/***/ (function(module, exports, __webpack_require__) { - // http://stackoverflow.com/questions/15786966/xdomainrequest-aborts-post-on-ie-9 - x.onerror = function () { - callbacks.error('error', x); - }; - x.ontimeout = function () { - callbacks.error('timeout', x); - }; - x.onprogress = function () { - utils.logMessage('xhr onprogress'); - }; - } else { - x.onreadystatechange = function () { - if (x.readyState === XHR_DONE) { - var status = x.status; - if (status >= 200 && status < 300 || status === 304) { - callbacks.success(x.responseText, x); - } else { - callbacks.error(x.statusText, x); - } - } - }; - } +"use strict"; - if (method === 'GET' && data) { - var urlInfo = (0, _url.parse)(url, options); - _extends(urlInfo.search, data); - url = (0, _url.format)(urlInfo); - } +// 19.1.2.1 Object.assign(target, source, ...) +var getKeys = __webpack_require__(417); +var gOPS = __webpack_require__(421); +var pIE = __webpack_require__(422); +var toObject = __webpack_require__(50); +var IObject = __webpack_require__(32); +var $assign = Object.assign; - x.open(method, url); - // IE needs timoeut to be set after open - see #1410 - x.timeout = _timeout; +// should work with symbols and should have deterministic property order (V8 bug) +module.exports = !$assign || __webpack_require__(30)((function () { + var A = {}; + var B = {}; + // eslint-disable-next-line no-undef + var S = Symbol(); + var K = 'abcdefghijklmnopqrst'; + A[S] = 7; + K.split('').forEach((function (k) { B[k] = k; })); + return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K; +})) ? function assign(target, source) { // eslint-disable-line no-unused-vars + var T = toObject(target); + var aLen = arguments.length; + var index = 1; + var getSymbols = gOPS.f; + var isEnum = pIE.f; + while (aLen > index) { + var S = IObject(arguments[index++]); + var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S); + var length = keys.length; + var j = 0; + var key; + while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key]; + } return T; +} : $assign; - if (!useXDomainRequest) { - if (options.withCredentials) { - x.withCredentials = true; - } - utils._each(options.customHeaders, (function (value, header) { - x.setRequestHeader(header, value); - })); - if (options.preflight) { - x.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); - } - x.setRequestHeader('Content-Type', options.contentType || 'text/plain'); - } - x.send(method === 'POST' && data); - } catch (error) { - utils.logError('xhr construction', error); - } -} /***/ }), - -/***/ 8: +/* 417 */ /***/ (function(module, exports, __webpack_require__) { -"use strict"; +// 19.1.2.14 / 15.2.3.14 Object.keys(O) +var $keys = __webpack_require__(418); +var enumBugKeys = __webpack_require__(420); +module.exports = Object.keys || function keys(O) { + return $keys(O, enumBugKeys); +}; -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports["default"] = Adapter; -function Adapter(code) { - var bidderCode = code; - function setBidderCode(code) { - bidderCode = code; - } +/***/ }), +/* 418 */ +/***/ (function(module, exports, __webpack_require__) { - function getBidderCode() { - return bidderCode; - } +var has = __webpack_require__(46); +var toIObject = __webpack_require__(57); +var arrayIndexOf = __webpack_require__(56)(false); +var IE_PROTO = __webpack_require__(419)('IE_PROTO'); - function callBids() {} +module.exports = function (object, names) { + var O = toIObject(object); + var i = 0; + var result = []; + var key; + for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key); + // Don't enum bug & hidden keys + while (names.length > i) if (has(O, key = names[i++])) { + ~arrayIndexOf(result, key) || result.push(key); + } + return result; +}; - return { - callBids: callBids, - setBidderCode: setBidderCode, - getBidderCode: getBidderCode - }; -} /***/ }), - -/***/ 9: +/* 419 */ /***/ (function(module, exports, __webpack_require__) { -"use strict"; +var shared = __webpack_require__(55)('keys'); +var uid = __webpack_require__(31); +module.exports = function (key) { + return shared[key] || (shared[key] = uid(key)); +}; -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.config = undefined; +/***/ }), +/* 420 */ +/***/ (function(module, exports) { -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; +// IE 8- don't enum bug keys +module.exports = ( + 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf' +).split(','); -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /* - * Module for getting and setting Prebid configuration. - * - * Prebid previously defined these properties directly on the global object: - * pbjs.logging = true; - * - * Defining and access properties in this way is now deprecated, but these will - * continue to work during a deprecation window. - */ +/***/ }), +/* 421 */ +/***/ (function(module, exports) { -exports.newConfig = newConfig; +exports.f = Object.getOwnPropertySymbols; -var _cpmBucketManager = __webpack_require__(28); -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } +/***/ }), +/* 422 */ +/***/ (function(module, exports) { -var utils = __webpack_require__(0); +exports.f = {}.propertyIsEnumerable; -var DEFAULT_DEBUG = false; -var DEFAULT_BIDDER_TIMEOUT = 3000; -var DEFAULT_PUBLISHER_DOMAIN = window.location.origin; -var DEFAULT_COOKIESYNC_DELAY = 100; -var DEFAULT_ENABLE_SEND_ALL_BIDS = false; -var GRANULARITY_OPTIONS = { - LOW: 'low', - MEDIUM: 'medium', - HIGH: 'high', - AUTO: 'auto', - DENSE: 'dense', - CUSTOM: 'custom' -}; +/***/ }), +/* 423 */ +/***/ (function(module, exports, __webpack_require__) { -var ALL_TOPICS = '*'; +"use strict"; -/** - * @typedef {object} PrebidConfig - * - * @property {bool} usePrebidCache True if we should use prebid-cache to store video bids before adding - * bids to the auction, and false otherwise. **NOTE** This must be true if you want to use the - * dfpAdServerVideo module. - */ -function newConfig() { - var listeners = []; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.listenMessagesFromCreative = listenMessagesFromCreative; - var defaults = {}; +var _events = __webpack_require__(11); - var config = { - // `debug` is equivalent to legacy `pbjs.logging` property - _debug: DEFAULT_DEBUG, - get debug() { - if (pbjs.logging || pbjs.logging === false) { - return pbjs.logging; - } - return this._debug; - }, - set debug(val) { - this._debug = val; - }, +var _events2 = _interopRequireDefault(_events); - // default timeout for all bids - _bidderTimeout: DEFAULT_BIDDER_TIMEOUT, - get bidderTimeout() { - return pbjs.bidderTimeout || this._bidderTimeout; - }, - set bidderTimeout(val) { - this._bidderTimeout = val; - }, +var _native = __webpack_require__(15); - // domain where prebid is running for cross domain iframe communication - _publisherDomain: DEFAULT_PUBLISHER_DOMAIN, - get publisherDomain() { - return pbjs.publisherDomain || this._publisherDomain; - }, - set publisherDomain(val) { - this._publisherDomain = val; - }, +var _constants = __webpack_require__(3); - // delay to request cookie sync to stay out of critical path - _cookieSyncDelay: DEFAULT_COOKIESYNC_DELAY, - get cookieSyncDelay() { - return pbjs.cookieSyncDelay || this._cookieSyncDelay; - }, - set cookieSyncDelay(val) { - this._cookieSyncDelay = val; - }, +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - // calls existing function which may be moved after deprecation - _priceGranularity: GRANULARITY_OPTIONS.MEDIUM, - set priceGranularity(val) { - if (validatePriceGranularity(val)) { - if (typeof val === 'string') { - this._priceGranularity = hasGranularity(val) ? val : GRANULARITY_OPTIONS.MEDIUM; - } else if ((typeof val === 'undefined' ? 'undefined' : _typeof(val)) === 'object') { - this._customPriceBucket = val; - this._priceGranularity = GRANULARITY_OPTIONS.CUSTOM; - utils.logMessage('Using custom price granularity'); - } - } - }, - get priceGranularity() { - return this._priceGranularity; - }, +var BID_WON = _constants.EVENTS.BID_WON; /* Secure Creatives + Provides support for rendering creatives into cross domain iframes such as SafeFrame to prevent + access to a publisher page from creative payloads. + */ - _customPriceBucket: {}, - get customPriceBucket() { - return this._customPriceBucket; - }, +function listenMessagesFromCreative() { + addEventListener('message', receiveMessage, false); +} - _sendAllBids: DEFAULT_ENABLE_SEND_ALL_BIDS, - get enableSendAllBids() { - return this._sendAllBids; - }, - set enableSendAllBids(val) { - this._sendAllBids = val; - }, +function receiveMessage(ev) { + var key = ev.message ? 'message' : 'data'; + var data = {}; + try { + data = JSON.parse(ev[key]); + } catch (e) { + return; + } - // calls existing function which may be moved after deprecation - set bidderSequence(val) { - pbjs.setBidderSequence(val); - }, + if (data.adId) { + var adObject = pbjs._bidsReceived.find((function (bid) { + return bid.adId === data.adId; + })); - // calls existing function which may be moved after deprecation - set s2sConfig(val) { - pbjs.setS2SConfig(val); - } - }; + if (data.message === 'Prebid Request') { + sendAdToCreative(adObject, data.adServerDomain, ev.source); - function hasGranularity(val) { - return Object.keys(GRANULARITY_OPTIONS).find((function (option) { - return val === GRANULARITY_OPTIONS[option]; - })); - } + // save winning bids + pbjs._winningBids.push(adObject); - function validatePriceGranularity(val) { - if (!val) { - utils.logError('Prebid Error: no value passed to `setPriceGranularity()`'); - return false; - } - if (typeof val === 'string') { - if (!hasGranularity(val)) { - utils.logWarn('Prebid Warning: setPriceGranularity was called with invalid setting, using `medium` as default.'); - } - } else if ((typeof val === 'undefined' ? 'undefined' : _typeof(val)) === 'object') { - if (!(0, _cpmBucketManager.isValidPriceConfig)(val)) { - utils.logError('Invalid custom price value passed to `setPriceGranularity()`'); - return false; - } + _events2['default'].emit(BID_WON, adObject); } - return true; - } - /* - * Returns configuration object if called without parameters, - * or single configuration property if given a string matching a configuration - * property name. Allows deep access e.g. getConfig('currency.adServerCurrency') - * - * If called with callback parameter, or a string and a callback parameter, - * subscribes to configuration updates. See `subscribe` function for usage. - */ - function getConfig() { - if (arguments.length <= 1 && typeof (arguments.length <= 0 ? undefined : arguments[0]) !== 'function') { - var option = arguments.length <= 0 ? undefined : arguments[0]; - return option ? utils.deepAccess(config, option) : config; + // handle this script from native template in an ad server + // window.parent.postMessage(JSON.stringify({ + // message: 'Prebid Native', + // adId: '%%PATTERN:hb_adid%%' + // }), '*'); + if (data.message === 'Prebid Native') { + (0, _native.fireNativeTrackers)(data, adObject); + pbjs._winningBids.push(adObject); + _events2['default'].emit(BID_WON, adObject); } - - return subscribe.apply(undefined, arguments); } +} - /* - * Sets configuration given an object containing key-value pairs and calls - * listeners that were added by the `subscribe` function - */ - function setConfig(options) { - if ((typeof options === 'undefined' ? 'undefined' : _typeof(options)) !== 'object') { - utils.logError('setConfig options must be an object'); - return; - } +function sendAdToCreative(adObject, remoteDomain, source) { + var adId = adObject.adId, + ad = adObject.ad, + adUrl = adObject.adUrl, + width = adObject.width, + height = adObject.height; - var topics = Object.keys(options); - var topicalConfig = {}; - topics.forEach((function (topic) { - var option = options[topic]; + if (adId) { + resizeRemoteCreative(adObject); + source.postMessage(JSON.stringify({ + message: 'Prebid Response', + ad: ad, + adUrl: adUrl, + adId: adId, + width: width, + height: height + }), remoteDomain); + } +} - if (_typeof(defaults[topic]) === 'object' && (typeof option === 'undefined' ? 'undefined' : _typeof(option)) === 'object') { - option = _extends({}, defaults[topic], option); - } +function resizeRemoteCreative(_ref) { + var adUnitCode = _ref.adUnitCode, + width = _ref.width, + height = _ref.height; - topicalConfig[topic] = config[topic] = option; - })); + var iframe = document.getElementById(window.googletag.pubads().getSlots().find((function (slot) { + return slot.getAdUnitPath() === adUnitCode || slot.getSlotElementId() === adUnitCode; + })).getSlotElementId()).querySelector('iframe'); - callSubscribers(topicalConfig); - } + iframe.width = '' + width; + iframe.height = '' + height; +} - /** - * Sets configuration defaults which setConfig values can be applied on top of - * @param {object} options - */ - function setDefaults(options) { - if ((typeof defaults === 'undefined' ? 'undefined' : _typeof(defaults)) !== 'object') { - utils.logError('defaults must be an object'); - return; - } +/***/ }), +/* 424 */ +/***/ ((function(module, exports, __webpack_require__) { - _extends(defaults, options); - // Add default values to config as well - _extends(config, options); - } +"use strict"; - /* - * Adds a function to a set of listeners that are invoked whenever `setConfig` - * is called. The subscribed function will be passed the options object that - * was used in the `setConfig` call. Topics can be subscribed to to only get - * updates when specific properties are updated by passing a topic string as - * the first parameter. - * - * Returns an `unsubscribe` function for removing the subscriber from the - * set of listeners - * - * Example use: - * // subscribe to all configuration changes - * subscribe((config) => console.log('config set:', config)); - * - * // subscribe to only 'logging' changes - * subscribe('logging', (config) => console.log('logging set:', config)); - * - * // unsubscribe - * const unsubscribe = subscribe(...); - * unsubscribe(); // no longer listening - */ - function subscribe(topic, listener) { - var callback = listener; - if (typeof topic !== 'string') { - // first param should be callback function in this case, - // meaning it gets called for any config change - callback = topic; - topic = ALL_TOPICS; - } +var _url = __webpack_require__(13); - if (typeof callback !== 'function') { - utils.logError('listener must be a function'); - return; - } +var _targeting = __webpack_require__(27); - listeners.push({ topic: topic, callback: callback }); +// Adserver parent class +var AdServer = function AdServer(attr) { + this.name = attr.adserver; + this.code = attr.code; + this.getWinningBidByCode = function () { + return (0, _targeting.getWinningBids)(this.code)[0]; + }; +}; - // save and call this function to remove the listener - return function unsubscribe() { - listeners.splice(listeners.indexOf(listener), 1); - }; - } +// DFP ad server +exports.dfpAdserver = function (options, urlComponents) { + var adserver = new AdServer(options); + adserver.urlComponents = urlComponents; - /* - * Calls listeners that were added by the `subscribe` function - */ - function callSubscribers(options) { - var TOPICS = Object.keys(options); + var dfpReqParams = { + 'env': 'vp', + 'gdfp_req': '1', + 'impl': 's', + 'unviewed_position_start': '1' + }; - // call subscribers of a specific topic, passing only that configuration - listeners.filter((function (listener) { - return TOPICS.includes(listener.topic); - })).forEach((function (listener) { - listener.callback(_defineProperty({}, listener.topic, options[listener.topic])); - })); + var dfpParamsWithVariableValue = ['output', 'iu', 'sz', 'url', 'correlator', 'description_url', 'hl']; - // call subscribers that didn't give a topic, passing everything that was set - listeners.filter((function (listener) { - return listener.topic === ALL_TOPICS; - })).forEach((function (listener) { - return listener.callback(options); - })); - } + var getCustomParams = function getCustomParams(targeting) { + return encodeURIComponent((0, _url.formatQS)(targeting)); + }; - return { - getConfig: getConfig, - setConfig: setConfig, - setDefaults: setDefaults + adserver.appendQueryParams = function () { + var bid = adserver.getWinningBidByCode(); + if (bid) { + this.urlComponents.search.description_url = encodeURIComponent(bid.vastUrl); + this.urlComponents.search.cust_params = getCustomParams(bid.adserverTargeting); + this.urlComponents.search.correlator = Date.now(); + } }; -} -var config = exports.config = newConfig(); + adserver.verifyAdserverTag = function () { + for (var key in dfpReqParams) { + if (!this.urlComponents.search.hasOwnProperty(key) || this.urlComponents.search[key] !== dfpReqParams[key]) { + return false; + } + } + for (var i in dfpParamsWithVariableValue) { + if (!this.urlComponents.search.hasOwnProperty(dfpParamsWithVariableValue[i])) { + return false; + } + } + return true; + }; -/***/ }) + return adserver; +}; -/******/ }); -pbjsChunk([43],{ +/***/ })) +/******/ ]); +pbjsChunk([49],{ -/***/ 101: +/***/ 135: /***/ (function(module, exports, __webpack_require__) { -__webpack_require__(102); -module.exports = __webpack_require__(103); +__webpack_require__(136); +module.exports = __webpack_require__(137); /***/ }), -/***/ 102: +/***/ 136: /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -6603,7 +7172,7 @@ var utils = _interopRequireWildcard(_utils); var _bidderFactory = __webpack_require__(6); -var _mediaTypes = __webpack_require__(13); +var _mediaTypes = __webpack_require__(12); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } } @@ -6671,7 +7240,7 @@ var spec = exports.spec = { user: userObj, sdk: { source: SOURCE, - version: '0.34.1' + version: '0.34.9' } }; if (member > 0) { @@ -6737,7 +7306,6 @@ function newRenderer(adUnitCode, rtbBid) { var renderer = _Renderer.Renderer.install({ id: rtbBid.renderer_id, url: rtbBid.renderer_url, - config: { adText: 'AppNexus Outstream Video Ad via Prebid.js' }, loaded: false }); @@ -6804,7 +7372,10 @@ function newBid(serverBid, rtbBid) { dealId: rtbBid.deal_id, currency: 'USD', netRevenue: true, - ttl: 300 + ttl: 300, + appnexus: { + buyerMemberId: rtbBid.buyer_member_id + } }; if (rtbBid.rtb.video) { @@ -7049,25 +7620,25 @@ function parseMediaType(rtbBid) { /***/ }), -/***/ 103: +/***/ 137: /***/ (function(module, exports) { /***/ }) -},[101]); -pbjsChunk([111],{ +},[135]); +pbjsChunk([116],{ -/***/ 104: +/***/ 138: /***/ (function(module, exports, __webpack_require__) { -module.exports = __webpack_require__(105); +module.exports = __webpack_require__(139); /***/ }), -/***/ 105: +/***/ 139: /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -7083,12 +7654,12 @@ var _adaptermanager2 = _interopRequireDefault(_adaptermanager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } -var CONSTANTS = __webpack_require__(4); +var CONSTANTS = __webpack_require__(3); var utils = __webpack_require__(0); var adloader = __webpack_require__(5); var bidmanager = __webpack_require__(2); -var bidfactory = __webpack_require__(3); -var Adapter = __webpack_require__(8)['default']; +var bidfactory = __webpack_require__(4); +var Adapter = __webpack_require__(9)['default']; var AppNexusAdapter; AppNexusAdapter = function AppNexusAdapter() { @@ -7320,18 +7891,18 @@ module.exports = AppNexusAdapter; /***/ }) -},[104]); -pbjsChunk([91],{ +},[138]); +pbjsChunk([96],{ -/***/ 174: +/***/ 211: /***/ (function(module, exports, __webpack_require__) { -module.exports = __webpack_require__(175); +module.exports = __webpack_require__(212); /***/ }), -/***/ 175: +/***/ 212: /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -7343,11 +7914,11 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol // jshint ignore:start -var _adapter = __webpack_require__(8); +var _adapter = __webpack_require__(9); var _adapter2 = _interopRequireDefault(_adapter); -var _bidfactory = __webpack_require__(3); +var _bidfactory = __webpack_require__(4); var _bidfactory2 = _interopRequireDefault(_bidfactory); @@ -7359,9 +7930,9 @@ var _utils = __webpack_require__(0); var utils = _interopRequireWildcard(_utils); -var _constants = __webpack_require__(4); +var _constants = __webpack_require__(3); -var _url = __webpack_require__(12); +var _url = __webpack_require__(13); var url = _interopRequireWildcard(_url); @@ -7788,7 +8359,7 @@ var cygnus_index_start = function cygnus_index_start() { } else { scriptSrc = utils.getTopWindowLocation().protocol === 'http:' ? 'http://as.casalemedia.com' : 'https://as-sec.casalemedia.com'; } - var prebidVersion = encodeURIComponent('0.34.1'); + var prebidVersion = encodeURIComponent('0.34.9'); scriptSrc += '/cygnus?v=7&fn=cygnus_index_parse_res&s=' + this.siteID + '&r=' + jsonURI + '&pid=pb' + prebidVersion; if (typeof this.timeoutDelay === 'number' && this.timeoutDelay % 1 === 0 && this.timeoutDelay >= 0) { scriptSrc += '&t=' + this.timeoutDelay; @@ -8495,18 +9066,18 @@ module.exports = IndexExchangeAdapter; /***/ }) -},[174]); -pbjsChunk([20],{ +},[211]); +pbjsChunk([22],{ -/***/ 231: +/***/ 277: /***/ (function(module, exports, __webpack_require__) { -module.exports = __webpack_require__(232); +module.exports = __webpack_require__(278); /***/ }), -/***/ 232: +/***/ 278: /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -8514,11 +9085,11 @@ module.exports = __webpack_require__(232); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; -var _adapter = __webpack_require__(8); +var _adapter = __webpack_require__(9); var _adapter2 = _interopRequireDefault(_adapter); -var _bidfactory = __webpack_require__(3); +var _bidfactory = __webpack_require__(4); var _bidfactory2 = _interopRequireDefault(_bidfactory); @@ -8532,17 +9103,17 @@ var utils = _interopRequireWildcard(_utils); var _ajax = __webpack_require__(7); -var _constants = __webpack_require__(4); +var _constants = __webpack_require__(3); -var _cookie = __webpack_require__(233); +var _cookie = __webpack_require__(279); var _adaptermanager = __webpack_require__(1); var _adaptermanager2 = _interopRequireDefault(_adaptermanager); -var _config = __webpack_require__(9); +var _config = __webpack_require__(8); -var _mediaTypes = __webpack_require__(13); +var _mediaTypes = __webpack_require__(12); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } } @@ -8690,7 +9261,7 @@ function PrebidServer() { timeout_millis: config.timeout, secure: config.secure, url: utils.getTopWindowUrl(), - prebid_version: '0.34.1', + prebid_version: '0.34.9', ad_units: adUnits.filter(hasSizes), is_debug: isDebug }; @@ -8880,7 +9451,7 @@ module.exports = PrebidServer; /***/ }), -/***/ 233: +/***/ 279: /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -8909,18 +9480,18 @@ cookie.cookieSet = function (cookieSetUrl) { /***/ }) -},[231]); -pbjsChunk([75],{ +},[277]); +pbjsChunk([80],{ -/***/ 265: +/***/ 311: /***/ (function(module, exports, __webpack_require__) { -module.exports = __webpack_require__(266); +module.exports = __webpack_require__(312); /***/ }), -/***/ 266: +/***/ 312: /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -8944,11 +9515,13 @@ var utils = _interopRequireWildcard(_utils); var _bidderFactory = __webpack_require__(6); -var _config = __webpack_require__(9); +var _config = __webpack_require__(8); + +var _mediaTypes = __webpack_require__(12); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } } -var INTEGRATION = 'pbjs_lite_v0.34.1'; +var INTEGRATION = 'pbjs_lite_v0.34.9'; function isSecure() { return location.protocol === 'https:'; @@ -8957,7 +9530,7 @@ function isSecure() { // use protocol relative urls for http or https var FASTLANE_ENDPOINT = '//fastlane.rubiconproject.com/a/api/fastlane.json'; var VIDEO_ENDPOINT = '//fastlane-adv.rubiconproject.com/v1/auction/video'; -var SYNC_ENDPOINT = 'https://tap-secure.rubiconproject.com/partner/scripts/rubicon/emily.html?rtb_ext=1'; +var SYNC_ENDPOINT = 'https://eus.rubiconproject.com/usync.html'; var TIMEOUT_BUFFER = 500; @@ -8976,6 +9549,7 @@ var sizeMap = { 31: '980x120', 32: '250x360', 33: '180x500', + 34: '580x400', 35: '980x150', 37: '468x400', 38: '930x180', @@ -8989,9 +9563,11 @@ var sizeMap = { 59: '320x80', 60: '320x150', 61: '1000x1000', + 64: '580x500', 65: '640x480', 67: '320x480', 68: '1800x1000', + 69: '480x400', 72: '320x320', 73: '320x160', 78: '980x240', @@ -9021,7 +9597,7 @@ utils._each(sizeMap, (function (item, key) { var spec = exports.spec = { code: 'rubicon', aliases: ['rubiconLite'], - supportedMediaTypes: ['video'], + supportedMediaTypes: [_mediaTypes.BANNER, _mediaTypes.VIDEO], /** * @param {object} bid * @return boolean @@ -9041,8 +9617,9 @@ var spec = exports.spec = { return false; } - if (bid.mediaType === 'video') { - if (_typeof(params.video) !== 'object' || !params.video.size_id) { + if (spec.hasVideoMediaType(bid)) { + // support instream only + if (utils.deepAccess(bid, 'mediaTypes.' + _mediaTypes.VIDEO) && utils.deepAccess(bid, 'mediaTypes.' + _mediaTypes.VIDEO + '.context') !== 'instream' || _typeof(params.video) !== 'object' || !params.video.size_id) { return false; } } @@ -9057,12 +9634,13 @@ var spec = exports.spec = { return bidRequests.map((function (bidRequest) { bidRequest.startTime = new Date().getTime(); - if (bidRequest.mediaType === 'video') { + if (spec.hasVideoMediaType(bidRequest)) { var params = bidRequest.params; var size = parseSizes(bidRequest); + var page_rf = !params.referrer ? utils.getTopWindowUrl() : params.referrer; var _data = { - page_url: !params.referrer ? utils.getTopWindowUrl() : params.referrer, + page_url: params.secure ? page_rf.replace(/^http:/i, 'https:') : page_rf, resolution: _getScreenResolution(), account_id: params.accountId, integration: INTEGRATION, @@ -9076,7 +9654,7 @@ var spec = exports.spec = { var slotData = { site_id: params.siteId, zone_id: params.zoneId, - position: params.position || 'btf', + position: params.position === 'atf' || params.position === 'btf' ? params.position : 'unknown', floor: parseFloat(params.floor) > 0.01 ? params.floor : 0.01, element_id: bidRequest.adUnitCode, name: bidRequest.adUnitCode, @@ -9160,6 +9738,15 @@ var spec = exports.spec = { }; })); }, + /** + * Test if bid has mediaType or mediaTypes set for video. + * note: 'mediaType' has been deprecated, however support will remain for a transitional period + * @param {BidRequest} bidRequest + * @returns {boolean} + */ + hasVideoMediaType: function hasVideoMediaType(bidRequest) { + return bidRequest.mediaType === _mediaTypes.VIDEO || typeof utils.deepAccess(bidRequest, 'mediaTypes.' + _mediaTypes.VIDEO) !== 'undefined'; + }, /** * @param {*} responseObj * @param {BidRequest} bidRequest @@ -9177,7 +9764,7 @@ var spec = exports.spec = { } // video ads array is wrapped in an object - if ((typeof bidRequest === 'undefined' ? 'undefined' : _typeof(bidRequest)) === 'object' && bidRequest.mediaType === 'video' && (typeof ads === 'undefined' ? 'undefined' : _typeof(ads)) === 'object') { + if ((typeof bidRequest === 'undefined' ? 'undefined' : _typeof(bidRequest)) === 'object' && spec.hasVideoMediaType(bidRequest) && (typeof ads === 'undefined' ? 'undefined' : _typeof(ads)) === 'object') { ads = ads[bidRequest.adUnitCode]; } @@ -9203,11 +9790,17 @@ var spec = exports.spec = { ttl: 300, // 5 minutes netRevenue: _config.config.getConfig('rubicon.netRevenue') || false }; - if (bidRequest.mediaType === 'video') { + + if (ad.creative_type) { + bid.mediaType = ad.creative_type; + } + + if (ad.creative_type === _mediaTypes.VIDEO) { bid.width = bidRequest.params.video.playerWidth; bid.height = bidRequest.params.video.playerHeight; bid.vastUrl = ad.creative_depot_url; bid.impression_id = ad.impression_id; + bid.videoCacheKey = ad.impression_id; } else { bid.ad = _renderCreative(ad.script, ad.impression_id); @@ -9270,9 +9863,9 @@ function _renderCreative(script, impId) { function parseSizes(bid) { var params = bid.params; - if (bid.mediaType === 'video') { + if (spec.hasVideoMediaType(bid)) { var size = []; - if (params.video.playerWidth && params.video.playerHeight) { + if (_typeof(params.video) === 'object' && params.video.playerWidth && params.video.playerHeight) { size = [params.video.playerWidth, params.video.playerHeight]; } else if (Array.isArray(bid.sizes) && bid.sizes.length > 0 && Array.isArray(bid.sizes[0]) && bid.sizes[0].length > 1) { size = bid.sizes[0]; @@ -9324,5 +9917,116 @@ function resetUserSync() { /***/ }) -},[265]); +},[311]); +pbjsChunk([4],{ + +/***/ 373: +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(374); +module.exports = __webpack_require__(375); + + +/***/ }), + +/***/ 374: +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.spec = undefined; + +var _utils = __webpack_require__(0); + +var utils = _interopRequireWildcard(_utils); + +var _bidderFactory = __webpack_require__(6); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } } + +/** + * Adapter to send bids to Undertone + */ + +var BIDDER_CODE = 'undertone'; +var URL = '//hb.undertone.com/hb'; + +var spec = exports.spec = { + code: BIDDER_CODE, + isBidRequestValid: function isBidRequestValid(bid) { + if (bid && bid.params && bid.params.publisherId && bid.params.placementId) { + bid.params.publisherId = parseInt(bid.params.publisherId); + return true; + } + }, + buildRequests: function buildRequests(validBidRequests) { + var payload = { + 'x-ut-hb-params': [] + }; + var host = utils.getTopWindowLocation().host; + var domain = /[-\w]+\.(?:[-\w]+\.xn--[-\w]+|[-\w]{3,}|[-\w]+\.[-\w]{2})$/i.exec(host); + + var pubid = validBidRequests[0].params.publisherId; + var REQ_URL = URL + '?pid=' + pubid + '&domain=' + domain; + + validBidRequests.map((function (bidReq) { + var bid = { + bidRequestId: bidReq.bidId, + hbadaptor: 'prebid', + domain: domain, + placementId: bidReq.params.placementId, + publisherId: bidReq.params.publisherId, + sizes: bidReq.sizes, + params: bidReq.params + }; + payload['x-ut-hb-params'].push(bid); + })); + return { + method: 'POST', + url: REQ_URL, + withCredentials: true, + data: JSON.stringify(payload) + }; + }, + interpretResponse: function interpretResponse(serverResponse, request) { + var bids = []; + var body = serverResponse.body; + + if (body && Array.isArray(body) && body.length > 0) { + body.forEach((function (bidRes) { + if (bidRes.ad && bidRes.cpm > 0) { + var bid = { + requestId: bidRes.bidRequestId, + cpm: bidRes.cpm, + width: bidRes.width, + height: bidRes.height, + creativeId: bidRes.adId, + currency: bidRes.currency, + netRevenue: bidRes.netRevenue, + ttl: bidRes.ttl, + ad: bidRes.ad + }; + bids.push(bid); + } + })); + } + return bids; + } +}; +(0, _bidderFactory.registerBidder)(spec); + +/***/ }), + +/***/ 375: +/***/ (function(module, exports) { + + + +/***/ }) + +},[373]); pbjs.processQueue(); \ No newline at end of file diff --git a/genius-adapters.json b/genius-adapters.json index 5206e11f66f..53d11910787 100644 --- a/genius-adapters.json +++ b/genius-adapters.json @@ -3,5 +3,6 @@ "appnexusAstBidAdapter", "indexExchangeBidAdapter", "prebidServerBidAdapter", - "rubiconBidAdapter" + "rubiconBidAdapter", + "undertoneBidAdapter" ]