1import{j as e}from"./s4d-Divider-0yb2dwYP.js";import{C as t}from"./s4d-Button-BJ6yswHT.js";import{z as n}from"./s4d-Icon-MaBupt9T.js";import{b as r}from"./vendor-intl-DJzFbCu-.js";import{y as a}from"./s4d-IconButton-BK5SJoV-.js";import{v as o}from"./s4d-Loader-x8YJ5cbI.js";/* empty css */const s=({widgetId:t,sku:n,showLoading:a,applyBtnStyles:s})=>{const[i,d]=r.useState(!a);return r.useEffect(()=>{const e=setInterval(()=>{window.PriceSpider&&(window.PriceSpider?.rebind(),d(!0),clearInterval(e))},200);return()=>clearInterval(e)},[]),e.jsxs(e.Fragment,{children:[i?null:e.jsx(o,{variant:"loop"}),e.jsx("div",{className:"ps-widget where-to-buy-widget "+(s?"t-button t-button--size-default t-button--kind-primary":""),"ps-config":t,...n?{"ps-sku":n}:{}})]})},i=({accountId:t,country:n,language:r})=>{const a=`https://cdn.pricespider.com/1/${t}/ps-utid.js`;return e.jsxs(e.Fragment,{children:[e.jsx("script",{async:!0,type:"text/javascript",src:"https://cdn.pricespider.com/1/lib/ps-widget.js","ps-account":t,"ps-country":n.toLowerCase(),"ps-language":r.toLowerCase()}),e.jsx("script",{async:!0,type:"text/javascript",src:a}),e.jsx("noscript",{children:"Please ensure Javascript is enabled for purposes of Where To Buy functionality."})]})},d=({appId:e,country:t,locale:n,doNotTrack:a=!0})=>{const o=r.useRef(null),s=r.useRef(!1);return r.useEffect(()=>{if(!window.__mikMakScriptLoaded){(n||t)&&(window.swnDataLayer||(window.swnDataLayer={}),n&&(window.swnDataLayer.locale=n),t&&(window.swnDataLayer.country=t));try{const t=window.swnDataLayer=window.swnDataLayer||{};t.appId=e||t.appId,t.eventBuffer=t.eventBuffer||[],t.loadBuffer=t.loadBuffer||[],t.push=t.push||function(e){t.eventBuffer.push(e)},t.load=t.load||function(e){t.loadBuffer.push(e)},t.dnt=null!=t.dnt?t.dnt:a;const n=document.getElementsByTagName("script")[0],r=document.createElement("script");r.async=!0,r.src=`https://wtb-tag.mikmak.ai/scripts/${t.appId}/tag.min.js`,r.addEventListener("load",()=>{s.current=!0}),n?.parentNode?.insertBefore(r,n),o.current=r,window.__mikMakScriptLoaded=!0}catch(r){window.__mikMakScriptLoaded=!1}return()=>{!s.current&&o.current?.parentNode&&(o.current.parentNode.removeChild(o.current),o.current=null,window.__mikMakScriptLoaded=!1)}}window.swnDataLayer&&(n&&(window.swnDataLayer.locale=n),t&&(window.swnDataLayer.country=t),window.swnDataLayer.setDNT?window.swnDataLayer.setDNT(a):window.swnDataLayer.dnt=a)},[e,t,n,a]),null},c=({wtbId:r,productIds:a,idType:o,defaultProductId:s,isSticky:i,containerId:d,isMainProduct:c,countryProductIds:l,countryDefaultProductIds:u,mode:m="button",buttonLabel:p="Buy now"})=>{const f={"data-mm-wtbid":r,"data-mm-ids":a,"data-mm-id-type":o,"data-mm-default-id":s,"data-mm-container":d};if(l)for(const[e,t]of Object.entries(l))f[`data-mm-ids-${e.toLowerCase()}`]=t;if(u)for(const[e,t]of Object.entries(u))f[`data-mm-default-id-${e.toLowerCase()}`]=t;const w=Object.fromEntries(Object.entries(f).filter(([,e])=>void 0!==e));return"sticky"===m?e.jsx("template",{...w}):"container"===m?e.jsx("div",{style:{width:"100%"},...w,children:" "}):e.jsx(t,{kind:"primary",icon:e.jsx(n,{category:"filled",size:"size24",iconName:"IcShoppingCart"}),iconPosition:"right","aria-label":p,...w,...i?{"data-mm-sticky":""}:{},...c?{"data-mm-main-id":""}:{},children:p})},l=({isOpen:t,onClose:o,children:s,title:i,triggerRef:d})=>{const c=r.useRef(null),l=r.useRef(null),u=r.useRef(null),m=()=>{if(!c.current)return[];return Array.from(c.current.querySelectorAll(["a[href]","button:not([disabled])","textarea:not([disabled])","input:not([disabled])","select:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(","))).filter(e=>!e.hasAttribute("disabled")&&null!==e.offsetParent)};return r.useEffect(()=>{if(!t)return;u.current=d?.current||document.activeElement;const e=m();return e.length>0&&e[0].focus(),()=>{u.current&&u.current.focus()}},[t,d]),r.useEffect(()=>{if(!t)return;const e=e=>{"Escape"===e.key&&o()},n=e=>{if("Tab"!==e.key)return;const t=m();if(0===t.length)return;const n=t[0],r=t[t.length-1];e.shiftKey?document.activeElement===n&&(e.preventDefault(),r.focus()):document.activeElement===r&&(e.preventDefault(),n.focus())},r=e=>{l.current&&e.target===l.current&&o()};return document.addEventListener("keydown",e),document.addEventListener("keydown",n),document.addEventListener("mousedown",r),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",e),document.removeEventListener("keydown",n),document.removeEventListener("mousedown",r),document.body.style.overflow="unset"}}
1,[t,o]),t?e.jsx("div",{className:"modal-overlay",ref:l,children:e.jsxs("div",{className:"modal-container",ref:c,role:"dialog","aria-modal":"true","aria-labelledby":i?"modal-title":void 0,"aria-label":i?void 0:"Where to buy",children:[e.jsxs("div",{className:"modal-header",children:[i&&e.jsx("h2",{id:"modal-title",className:"modal-title",children:i}),e.jsx(a,{className:"modal-close-button",onClick:o,ariaLabel:"Close modal",kind:"tertiary",size:"default",icon:e.jsx(n,{category:"filled",size:"size24",iconName:"IcCross"})})]}),e.jsx("div",{className:"modal-content",children:s})]})}):null},u=a=>{const{widgetId:o,sku:u,provider:m,showLoading:p=!1,applyBtnStyles:f=!1,isCustomPriceSpiderPopup:w=!1,buttonLabel:y=""}=a,[h,g]=r.useState(!1),j=r.useRef(null),b=u?.split("|"),v=b&&b.length>1?b[1]:y??"";return e.jsxs(e.Fragment,{children:[("pricespider"===m||"pricespiderembeded"===m)&&e.jsxs(e.Fragment,{children:[e.jsx(i,{accountId:a.accountId,country:a.country,language:a.language}),w?e.jsxs(e.Fragment,{children:[e.jsx(t,{ref:j,onClick:()=>{g(!0)},type:"primary",icon:e.jsx(n,{category:"filled",size:"size24",iconName:"IcChevronRight"}),iconPosition:"right","aria-label":v,"aria-haspopup":"dialog",children:v}),e.jsx(l,{isOpen:h,onClose:()=>{g(!1)},triggerRef:j,children:e.jsx(s,{widgetId:o,sku:b&&b.length>1?b[0]:u,showLoading:p})})]}):e.jsx(s,{widgetId:o,sku:u,showLoading:p,applyBtnStyles:f})]}),"mikmak"===m&&e.jsxs(e.Fragment,{children:[e.jsx(d,{appId:a.accountId,country:a.country,locale:a.language,doNotTrack:a.doNotTrack}),e.jsx(c,{wtbId:o,productIds:b&&b.length>1?b[0]:u,idType:a.idType,defaultProductId:a.defaultProductId,isSticky:a.isSticky,containerId:a.containerId,isMainProduct:a.isMainProduct,mode:a.mikMakMode,buttonLabel:v||"Buy now"})]}),"Adrimo"===m&&e.jsx("script",{src:"https://adrimo.com/embed.js",async:!0})]})};export{u as W};
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.