PageSourceSearch

https://focuscamera.com/cdn/shop/t/4/assets/mkcustom-gated-promo-message.js?v=74964089880977003561790097487

js focuscamera.com collected 2026-09-25 14:40:16 UTC 9,043 bytes, 2 lines download raw bytes

1(function(){const SELECTOR="[data-mkcustom-gated-promo]";function normalize(value){return String(value||"").trim().toLowerCase()}function normalizeBrandName(value){return String(value||"").trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function applyTwoWordHeadingLayout(root){const heading=root.querySelector("[data-gated-promo-heading]");if(!heading)return;const headingWords=(heading.textContent||"").trim().match(/\S+/g)||[];heading.classList.toggle("mkcustom-gated-promo-message__heading--two-word",headingWords.length===2)}function getSamiData(){return window.Samita?.Wholesale||null}function getCurrentProduct(sami,productId){return(Array.isArray(sami?.products)?sami.products:[]).find(function(product){return String(product.id)===String(productId)})||null}function ruleMatchesVariant(rule,variantId){const variants=rule?.product_configs?.apply_product?.manual?.variants||[];return!Array.isArray(variants)||!variants.length?!1:variants.some(function(variant){if(String(variant?.id)===String(variantId))return!0;try{return JSON.stringify(variant).includes(String(variantId))}catch{return!1}})}function ruleMatchesProductTag(rule,productTags){const ruleTags=rule?.product_configs?.apply_product?.manual?.tags||[];if(!Array.isArray(ruleTags)||!ruleTags.length)return!1;const normalizedProductTags=productTags.map(normalize);return ruleTags.some(function(tag){return normalizedProductTags.includes(normalize(tag))})}function getMatchingRules(sami,product,variantId){const rules=sami?.wholesalePricing||{},productTags=Array.isArray(product?.tags)?product.tags:[];return Object.entries(rules).map(function([ruleId,rule]){const matchesVariant=ruleMatchesVariant(rule,variantId),matchesTag=ruleMatchesProductTag(rule,productTags);return{ruleId,rule,matchesVariant,matchesTag}}).filter(function(item){return item.matchesVariant||item.matchesTag})}function isRuleActive(rule){const activeDate=rule?.configs?.active_date;if(!activeDate)return!0;const start=activeDate.start_at?new Date(activeDate.start_at).getTime():null,end=activeDate.end_at?new Date(activeDate.end_at).getTime():null,now=Date.now();return!(start&&Number.isFinite(start)&&now<start||end&&Number.isFinite(end)&&now>end)}function getSamiPriceState(productId,variantId){const priceElements=Array.from(document.querySelectorAll(".samitaWS-customized-price")),matchingPriceElements=priceElements.filter(function(priceElement){const parent=priceElement.parentElement;if(!parent)return!1;const samiProductId=parent.getAttribute("samitaws-product-id"),samiVariantId=parent.getAttribute("samitaws-variant-id");return String(samiProductId)===String(productId)&&String(samiVariantId)===String(variantId)}),candidates=matchingPriceElements.length?matchingPriceElements:priceElements;for(const customizedPrice of candidates){const originalPrice=customizedPrice.parentElement?.querySelector(".samitaWS-customized-original-price")||document.querySelector(".samitaWS-customized-original-price"),customizedText=customizedPrice?.textContent?.trim()||"",originalText=originalPrice?.textContent?.trim()||"";if(customizedText&&originalText&&customizedText!==originalText)return{applied:!0,customizedText,originalText}}return{applied:!1,customizedText:"",originalText:""}}function resolvePromo(root){const sami=getSamiData();if(!sami)return!1;const productId=root.dataset.productId,variantId=root.dataset.variantId;if(!productId||!variantId)return root.hidden=!0,!0;const product=getCurrentProduct(sami,productId);if(!product)return!1;const matchingRules=getMatchingRules(sami,product,variantId);if(!matchingRules.length)return root.hidden=!0,root.dataset.samiPromoActive="false",root.dataset.samiPriceApplied="false",root.dataset.samiRuleIds="",!0;const activeRules=matchingRules.filter(function(item){return isRuleActive(item.rule)});return root.dataset.samiRuleIds=activeRules.map(function(item){return item.ruleId}).join(","),activeRules.length?(root.dataset.samiPromoActive="true",root.dataset.customerLoggedIn==="true"?getSamiPriceState(productId,variantId).applied?(root.hidden=!1,root.dataset.samiPriceApplied="true",!0):(root.hidden=!0,root.dataset.samiPriceApplied="waiting",!1):(root.hidden=!1,root.dataset.samiPriceApplied="not-checked",!0)):(root.hidden=!0,root.dataset.samiPromoActive="false",root.dataset.samiPriceApplied="false",!0)}function initRoot(root){if(!root||root.dataset.gatedPromoInitialized==="true")return;root.dataset.gatedPromoInitialized="true",applyTwoWordHeadingLayout(root),applyReferencedBrandLogo(root)||applyFocusBranding(root);const startedAt=Date.now();let observer=null,pollTimer=null,resolving=!1;function cleanup(){observer&&(observer.disconnect(),observer=null),pollTimer&&(window.clearTimeout(pollTimer),pollTimer=null)}function attemptResolve(){if(resolving)return;resolving=!0;const resolved=resolvePromo(root);if(resolving=!1,resolved){cleanup();return}if(Date.now()-startedAt>=15e3){cleanup(),root.hidden=!0,root.dataset.samiPromoActive="unresolved";return}pollTimer&&window.clearTimeout(pollTimer),pollTimer=window.setTimeout(attemptResolve,200)}observer=new MutationObserver(function(mutations){mutations.some(function(mutation){const target=mutation.target;return mutation.type==="characterData"?!!target.parentElement?.closest(".samitaWS-customized-price, .samitaWS-customized-original-price"):target.nodeType===1&&(target.matches?.(".samitaWS-customized-price, .samitaWS-customized-original-price")||target.querySelector?.(".samitaWS-customized-price, .samitaWS-customized-original-price"))?!0:Array.from(mutation.addedNodes).some(function(node){return node.nodeType!==1?!1:!!(node.matches?.(".samitaWS-customized-price, .samitaWS-customized-original-price")||node.querySelector?.(".samitaWS-customized-price, .samitaWS-customized-original-price"))})})&&attemptResolve()}),observer.observe(document.body,{childList:!0,subtree:!0,characterData:!0}
1),attemptResolve()}function applyReferencedBrandLogo(root){const heading=root.querySelector("[data-gated-promo-heading]");if(!heading)return!1;const brandPlaceholder=heading.querySelector("strong");if(!brandPlaceholder)return!1;const brandLogoUrl=root.dataset.brandLogoUrl,brandHandle=root.dataset.brandHandle,boldBrandName=brandPlaceholder.textContent?.trim()||"";if(!brandHandle||normalizeBrandName(boldBrandName)!==normalizeBrandName(brandHandle)||!brandLogoUrl)return!1;const brandName=brandPlaceholder.textContent?.trim()||"Brand",logo=document.createElement("span");logo.className="mkcustom-gated-promo-message__referenced-brand-logo",logo.setAttribute("aria-label",brandName);const logoImage=document.createElement("img");return logoImage.className="mkcustom-gated-promo-message__referenced-brand-logo-image",logoImage.src=brandLogoUrl,logoImage.alt=brandName,logoImage.loading="eager",logo.appendChild(logoImage),brandPlaceholder.replaceWith(logo),heading.classList.add("mkcustom-gated-promo-message__heading--brand-logo"),!0}function applyFocusBranding(root){const heading=root.querySelector("[data-gated-promo-heading]");
1if(!heading)return;const text=heading.textContent||"",focusMatch=text.match(/\bFocus\b/i);if(!focusMatch){heading.classList.remove("mkcustom-gated-promo-message__heading--branded");return}const focusIndex=focusMatch.index,beforeText=text.slice(0,focusIndex).trim(),afterText=text.slice(focusIndex+focusMatch[0].length).trim();if(heading.textContent="",beforeText){const beforeSpan=document.createElement("span");beforeSpan.className="mkcustom-gated-promo-message__heading-before",beforeSpan.textContent=beforeText,heading.appendChild(beforeSpan)}const logo=document.createElement("span");logo.className="mkcustom-gated-promo-message__focus-logo",logo.setAttribute("aria-label","Focus");const logoUrl=root.dataset.focusLogoUrl;if(logoUrl){const logoImage=document.createElement("img");logoImage.className="mkcustom-gated-promo-message__focus-logo-image",logoImage.src=logoUrl,logoImage.alt="Focus",logoImage.loading="eager",logo.appendChild(logoImage)}if(heading.appendChild(logo),afterText){const headingText=document.createElement("span");headingText.className="mkcustom-gated-promo-message__heading-text",headingText.textContent=afterText,heading.appendChild(headingText)}heading.classList.add("mkcustom-gated-promo-message__heading--branded")}function init(){document.querySelectorAll(SELECTOR).forEach(initRoot)}document.addEventListener("click",function(event){if(!event.target.closest(".mkcustom-gated-promo-message__login, .mkcustom-gated-promo-message__create-account"))return;const returnUrl=window.location.pathname+window.location.search+window.location.hash;try{sessionStorage.setItem("cc-gated-promo-return-url",returnUrl)}catch(error){console.warn("MK Custom: Unable to save gated promo return URL.",error)}},!0),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",init):init(),document.addEventListener("shopify:section:load",function(){init()}),document.addEventListener("shopify:block:select",function(){init()})})();
2//# sourceMappingURL=/cdn/shop/t/4/assets/mkcustom-gated-promo-message.js.map?v=74964089880977003561790097487

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.