1async function getAdButlerModalCreative(e){const t=function getPopupAdButlerConfig(){const e=window.popupAdButlerConfig||{};return{accountId:parseInt(e.accountId,10),zoneId:parseInt(e.zoneId,10),width:parseInt(e.width,10)||1,height:parseInt(e.height,10)||1,domain:e.domain||"servedbyadbutler.com",debug:!0===e.debug}}();if(!Number.isFinite(t.accountId)||!Number.isFinite(t.zoneId))return console.warn(`AdButler popup config missing for popup '${e.id}'.`),null;const r=function buildAdButlerJsonUrl(e){const t=`${e.width}x${e.height}`,r=window.adButlerModalJsonPlace=(window.adButlerModalJsonPlace||0)+1,n=`${Date.now()}-${Math.floor(1e6*Math.random())}`,i=encodeURIComponent(window.abkw||""),o=encodeURIComponent(window.location.href);return`https://${e.domain}/adserve/;ID=${e.accountId};size=${t};setID=${e.zoneId};type=json;pid=${n};place=${r};kw=${i};referrer=${o};click=CLICK_MACRO_PLACEHOLDER`}(t);try{const e=await fetch(r,{credentials:"omit"});if(!e.ok)return null;const n=await e.json(),i=n?.placements?.placement_1||null;if(!i)return null;
1t.debug&&console.info("[AdButler Modal] JSON payload",n);const o=readPlacementValue(i,["title","headline","name"]),l=readPlacementValue(i,["description","body","text","copy"]),a=readPlacementValue(i,["cta_text","cta","button_text","call_to_action"]),c=readPlacementValue(i,["image_url","image","image_src","img"]),u=readPlacementValue(i,["alt_text","image_alt","alt"]),d=readPlacementValue(i,["redirect_url","url","destination_url","href"]);return{title:o||"",description:l||"",imageUrl:c||"",imageAlt:u||"",ctaText:a||"Learn More",ctaUrl:d||"#",bodyHtml:function hydrateBodyHtml(e,t){if(!e||"string"!=typeof e)return"";let r=e;t&&(r=r.replace(/\[%\s*redirect_url\s*%\]/gi,t),r=r.replace(/\[%\s*url\s*%\]/gi,t));return r}(i.body,i.redirect_url)||"",accuPixelUrl:i.accupixel_url||"",eligibleUrl:i.eligible_url||"",viewableUrl:i.viewable_url||"",trackingPixel:i.tracking_pixel||""}}catch(n){return console.warn(`AdButler JSON request failed for popup '${e.id}'.`,n),null}}function fireAdButlerModalImpression(e){if(!e)return;const t=[e.accuPixelUrl,e.eligibleUrl,e.viewableUrl,e.trackingPixel].filter(Boolean);for(const n of t)try{fetch(n,{mode:"no-cors",credentials:"omit"})}catch(r){}}function readPlacementValue(e,t){const r=pickFirstTruthy(t.map(t=>normalizeValue(e?.[t])));if(r)return r;const n=[e?.custom,e?.native,e?.fields,e?.data].filter(e=>e&&"object"==typeof e);for(const i of n){const e=pickFirstTruthy(t.map(e=>normalizeValue(i?.[e])));if(e)return e}return normalizeValue(findKeyRecursive(e,t.map(e=>e.toLowerCase())))}function normalizeValue(e){return null==e?"":"string"!=typeof e?String(e).trim():function extractTextFromHtml(e){if(!e)return"";const t=(new DOMParser).parseFromString(e,"text/html");return(t.body?.textContent||"").trim()}(e).trim()}function pickFirstTruthy(e){for(const t of e)if(t)return t;return""}function findKeyRecursive(e,t){if(!e||"object"!=typeof e)return"";for(const[r,n]of Object.entries(e)){if(t.includes(String(r).toLowerCase()))return n;if(n&&"object"==typeof n){const e=findKeyRecursive(n,t);if(e)return e}}return""}export{fireAdButlerModalImpression as f,getAdButlerModalCreative as g};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.