{"version":3,"sources":["webpack:///./modules/afpBidAdapter.js"],"names":["IS_DEV","location","hostname","BIDDER_CODE","SSP_ENDPOINT","REQUEST_METHOD","TEST_PAGE_URL","SDK_PATH","TTL","IN_IMAGE_BANNER_TYPE","IN_IMAGE_MAX_BANNER_TYPE","IN_CONTENT_BANNER_TYPE","IN_CONTENT_VIDEO_TYPE","OUT_CONTENT_VIDEO_TYPE","IN_CONTENT_STORY_TYPE","ACTION_SCROLLER_TYPE","ACTION_SCROLLER_LIGHT_TYPE","JUST_BANNER_TYPE","mediaTypeByPlaceType","BANNER","VIDEO","wrapAd","dataToCreatePlace","encodeURIComponent","JSON","stringify","bidRequestMap","createRenderer","bid","renderer","Renderer","targetId","adUnitCode","url","callback","loaded","window","afp","createPlaceByData","spec","code","supportedMediaTypes","isBidRequestValid","mediaTypes","params","placeId","placeType","imageUrl","imageWidth","imageHeight","media","playerSize","sizes","includes","buildRequests","validBidRequests","refererInfo","gdprConsent","payload","pageUrl","referer","bidRequests","map","validBidRequest","bidId","transactionId","bidRequest","Math","floor","method","data","options","contentType","interpretResponse","serverResponse","bids","body","Array","isArray","index","cpm","width","height","creativeId","currency","netRevenue","adSettings","placeSettings","requestId","meta","mediaType","ttl","placeContainer","isPrebid","ad","vastXml","content","registerBidder","d2ppbjs","installedModules","push"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AAEO,IAAMA,MAAM,GAAGC,QAAQ,CAACC,QAAT,KAAsB,WAArC;AACA,IAAMC,WAAW,GAAG,KAApB;AACA,IAAMC,YAAY,GAAG,+BAArB;AACA,IAAMC,cAAc,GAAG,MAAvB;AACA,IAAMC,aAAa,GAAG,kEAAtB;AACP,IAAMC,QAAQ,GAAG,sFAAjB;AACA,IAAMC,GAAG,GAAG,EAAZ;AACO,IAAMC,oBAAoB,GAAG,UAA7B;AACA,IAAMC,wBAAwB,GAAG,cAAjC;AACA,IAAMC,sBAAsB,GAAG,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CAACzC,SAAf,CAApB,KAAkD3B,kEAAtD,EAA8D;AAC5DS,WAAG,CAACkE,EAAJ,GAASzE,MAAM,CAACC,iBAAD,CAAf;AACD,OAFD,MAEO,IAAIJ,oBAAoB,CAACqE,aAAa,CAACzC,SAAf,CAApB,KAAkD1B,iEAAtD,EAA6D;AAClEQ,WAAG,CAACmE,OAAJ,GAAcT,UAAU,CAACU,OAAzB;AACApE,WAAG,CAACC,QAAJ,GAAeF,cAAc,CAACC,GAAD,EAAMN,iBAAN,CAA7B;AACD;;AACD,aAAOM,GAAP;AACD,KA1BM,CAAP;AA2BD;AAjGiB,CAAb;AAoGPqE,sFAAc,CAAC1D,IAAD,CAAd;AArKAH,MAAM,CAAC8D,OAAP,CAAeC,gBAAf,CAAgCC,IAAhC,CAAqC,eAArC,E","file":"afpBidAdapter.js","sourcesContent":["import includes from 'core-js-pure/features/array/includes.js'\r\nimport { registerBidder } from '../src/adapters/bidderFactory.js'\r\nimport { Renderer } from '../src/Renderer.js'\r\nimport { BANNER, VIDEO } from '../src/mediaTypes.js'\r\n\r\nexport const IS_DEV = location.hostname === 'localhost'\r\nexport const BIDDER_CODE = 'afp'\r\nexport const SSP_ENDPOINT = 'https://ssp.afp.ai/api/prebid'\r\nexport const REQUEST_METHOD = 'POST'\r\nexport const TEST_PAGE_URL = 'https://rtbinsight.ru/smiert-bolshikh-dannykh-kto-na-novienkogo/'\r\nconst SDK_PATH = 'https://cdn.afp.ai/ssp/sdk.js?auto_initialization=false&deploy_to_parent_window=true'\r\nconst TTL = 60\r\nexport const IN_IMAGE_BANNER_TYPE = 'In-image'\r\nexport const IN_IMAGE_MAX_BANNER_TYPE = 'In-image Max'\r\nexport const IN_CONTENT_BANNER_TYPE = 'In-content Banner'\r\nexport const IN_CONTENT_VIDEO_TYPE = 'In-content Video'\r\nexport const OUT_CONTENT_VIDEO_TYPE = 'Out-content Video'\r\nexport const IN_CONTENT_STORY_TYPE = 'In-content Stories'\r\nexport const ACTION_SCROLLER_TYPE = 'Action Scroller'\r\nexport const ACTION_SCROLLER_LIGHT_TYPE = 'Action Scroller Light'\r\nexport const JUST_BANNER_TYPE = 'Just Banner'\r\n\r\nexport const mediaTypeByPlaceType = {\r\n [IN_IMAGE_BANNER_TYPE]: BANNER,\r\n [IN_IMAGE_MAX_BANNER_TYPE]: BANNER,\r\n [IN_CONTENT_BANNER_TYPE]: BANNER,\r\n [IN_CONTENT_STORY_TYPE]: BANNER,\r\n [ACTION_SCROLLER_TYPE]: BANNER,\r\n [ACTION_SCROLLER_LIGHT_TYPE]: BANNER,\r\n [JUST_BANNER_TYPE]: BANNER,\r\n [IN_CONTENT_VIDEO_TYPE]: VIDEO,\r\n [OUT_CONTENT_VIDEO_TYPE]: VIDEO,\r\n}\r\n\r\nconst wrapAd = (dataToCreatePlace) => {\r\n return `\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n `\r\n}\r\n\r\nconst bidRequestMap = {}\r\n\r\nconst createRenderer = (bid, dataToCreatePlace) => {\r\n const renderer = new Renderer({\r\n targetId: bid.adUnitCode,\r\n url: SDK_PATH,\r\n callback() {\r\n renderer.loaded = true\r\n window.afp.createPlaceByData(dataToCreatePlace)\r\n }\r\n })\r\n\r\n return renderer\r\n}\r\n\r\nexport const spec = {\r\n code: BIDDER_CODE,\r\n supportedMediaTypes: [BANNER, VIDEO],\r\n isBidRequestValid({mediaTypes, params}) {\r\n if (typeof params !== 'object' || typeof mediaTypes !== 'object') {\r\n return false\r\n }\r\n\r\n const {placeId, placeType, imageUrl, imageWidth, imageHeight} = params\r\n const media = mediaTypes[mediaTypeByPlaceType[placeType]]\r\n\r\n if (placeId && media) {\r\n if (mediaTypeByPlaceType[placeType] === VIDEO) {\r\n if (!media.playerSize) {\r\n return false\r\n }\r\n } else if (mediaTypeByPlaceType[placeType] === BANNER) {\r\n if (!media.sizes) {\r\n return false\r\n }\r\n }\r\n if (includes([IN_IMAGE_BANNER_TYPE, IN_IMAGE_MAX_BANNER_TYPE], placeType)) {\r\n if (imageUrl && imageWidth && imageHeight) {\r\n return true\r\n }\r\n } else {\r\n return true\r\n }\r\n }\r\n return false\r\n },\r\n buildRequests(validBidRequests, {refererInfo, gdprConsent}) {\r\n const payload = {\r\n pageUrl: IS_DEV ? TEST_PAGE_URL : refererInfo.referer,\r\n gdprConsent: gdprConsent,\r\n bidRequests: validBidRequests.map(validBidRequest => {\r\n const {bidId, transactionId, sizes, params: {\r\n placeId, placeType, imageUrl, imageWidth, imageHeight\r\n }} = validBidRequest\r\n bidRequestMap[bidId] = validBidRequest\r\n const bidRequest = {\r\n bidId,\r\n transactionId,\r\n sizes,\r\n placeId,\r\n }\r\n if (includes([IN_IMAGE_BANNER_TYPE, IN_IMAGE_MAX_BANNER_TYPE], placeType)) {\r\n Object.assign(bidRequest, {\r\n imageUrl,\r\n imageWidth: Math.floor(imageWidth),\r\n imageHeight: Math.floor(imageHeight),\r\n })\r\n }\r\n return bidRequest\r\n })\r\n }\r\n\r\n return {\r\n method: REQUEST_METHOD,\r\n url: SSP_ENDPOINT,\r\n data: payload,\r\n options: {\r\n contentType: 'application/json'\r\n }\r\n }\r\n },\r\n interpretResponse(serverResponse) {\r\n let bids = serverResponse.body && serverResponse.body.bids\r\n bids = Array.isArray(bids) ? bids : []\r\n\r\n return bids.map(({bidId, cpm, width, height, creativeId, currency, netRevenue, adSettings, placeSettings}, index) => {\r\n const bid = {\r\n requestId: bidId,\r\n cpm,\r\n width,\r\n height,\r\n creativeId,\r\n currency,\r\n netRevenue,\r\n meta: {\r\n mediaType: mediaTypeByPlaceType[placeSettings.placeType],\r\n },\r\n ttl: TTL\r\n }\r\n\r\n const bidRequest = bidRequestMap[bidId]\r\n const placeContainer = bidRequest.params.placeContainer\r\n const dataToCreatePlace = { adSettings, placeSettings, placeContainer, isPrebid: true }\r\n\r\n if (mediaTypeByPlaceType[placeSettings.placeType] === BANNER) {\r\n bid.ad = wrapAd(dataToCreatePlace)\r\n } else if (mediaTypeByPlaceType[placeSettings.placeType] === VIDEO) {\r\n bid.vastXml = adSettings.content\r\n bid.renderer = createRenderer(bid, dataToCreatePlace)\r\n }\r\n return bid\r\n })\r\n }\r\n}\r\n\r\nregisterBidder(spec);\r\n\n\n\n// WEBPACK FOOTER //\n// ./modules/afpBidAdapter.js"],"sourceRoot":""}