async function s(e){return new Promise(function(n){setTimeout(n,e)})}function c(e){return e!==null&&typeof e=="object"}var P=new Set(["__proto__","prototype","constructor"]),h=e=>!e.some(n=>P.has(n));function S(e){e=e.replace(/\[(\d+)]/g,".$1");let n=e.split("."),r=[];for(let o=0;o<n.length;o++){let t=n[o];for(;t[t.length-1]==="\\"&&n[o+1]!==void 0;)t=t.slice(0,-1)+".",t+=n[++o];r.push(t)}return h(r)?r:[]}function p(e,n,r){if(!c(e)||typeof n!="string")return r===void 0?e:r;let o=S(n);if(o.length!==0){try{o.forEach(t=>{e=e[t]})}catch{return r}return e===void 0?r:e}}var l;function u(){if(l===void 0)try{let e=window.top.innerWidth;l=!1}catch{l=!0}return l}function d(){return u()?window:window.top}function f(e){if(window.SYNDI.PAGEID_POLLING_ACTIVE)return;window.SYNDI.PAGEID_POLLING_ACTIVE=!0;let n=20,r=2,t=n*20,i=function(){if(window.Webcollage||(window.Webcollage={}),window.Webcollage.Url!==document.location.href){window.Webcollage.Url=document.location.href,window.Webcollage.terminatePowerPage?.();let m=e();m?window.SYNDI.push(m):window.SYNDI.reset()}let a=t>0?n:r,y=Math.round(1e3/a);t>0&&t--,setTimeout(requestAnimationFrame,y,i)};requestAnimationFrame(i)}var _=[{type:"windowVariable",selector:"Webcollage.cpi"},{type:"windowVariable",selector:"vsr_sku"},{type:"windowVariable",selector:"sp_sku[0]"},{type:"windowVariable",selector:"sp_sku"},{type:"domElement",selector:"syndigo-powerpage",location:{type:"attribute",name:"pageid"}},{type:"domElement",selector:"syndigo-mosaic",location:{type:"attribute",name:"pageid"}},{type:"domElement",selector:"syndigo-hotspots",location:{type:"attribute",name:"pageid"}}];async function w(e,n=2e4){if(!Array.isArray(e.rules)){try{e.rules=JSON.parse(e.rules)}catch{e.rules=[]}e.rules=e.rules.concat(_)}if(!(e.rules.filter(a=>a.requiresPolling).length>0))return g(e.rules);f(()=>g(e.rules));let o=Date.now(),t=50,i=window.SYNDI.getFramework();for(;!i.pageid&&Date.now()-o<n;)await s(t);return i.pageid||""}function g(e){let n=d(),r;for(let o of e){if(o.type==="windowVariable")r=p(n,o.selector);else if(o.type==="domElement"){let t=n.document.querySelector(o.selector);t&&(r=o.location.type==="property"?t[o.location.name]:t.getAttribute(o.location.name))}else if(o.type==="urlPattern"){let t=new RegExp(o.selector),i=n.location.href.match(t);i&&(r=i[1])}else if(o.type==="urlParameter")r=new URL(n.location).searchParams.get(o.selector);else throw new Error(`unknown site/pageid rule type: '${o.type}'`);if(r)return r=""+r,(o.modifiers||[]).forEach(t=>{if(t.type==="replacement"){let i=new RegExp(t.regexSelector,t.regexFlags);r=r.replace(i,t.replace)}else t.type==="casing"&&(r=t.value==="upper"?r.toUpperCase():r.toLowerCase())}),r.trim()}}window.SYNDI.registerModule({type:"site/pageid",moduleclass:function(e){return{pageidentifier:async function(){let n=e.moduleParameters["site/pageid"]||{rules:"[ ]"};return w(n)}}}});
