PageSourceSearch

https://shop.newbelgium.com/cdn/shop/t/4/assets/popover-polyfill.js?v=119029313658895111201774386997

js newbelgium.com collected 2026-09-24 08:48:33 UTC 19,320 bytes, 64 lines download raw bytes

vendor: 10,071 bytes, line 1
1var ToggleEvent=class extends Event{oldState;newState;constructor(type,{oldState="",newState="",...init}={}){super(type,init),this.oldState=String(oldState||""),this.newState=String(newState||"")}},popoverToggleTaskQueue=new WeakMap;function queuePopoverToggleEventTask(element,oldState,newState){popoverToggleTaskQueue.set(element,setTimeout(()=>{popoverToggleTaskQueue.has(element)&&element.dispatchEvent(new ToggleEvent("toggle",{cancelable:!1,oldState,newState}))},0))}var ShadowRoot=globalThis.ShadowRoot||function(){},HTMLDialogElement=globalThis.HTMLDialogElement||function(){},topLayerElements=new WeakMap,autoPopoverList=new WeakMap,hintPopoverList=new WeakMap,visibilityState=new WeakMap;function getPopoverVisibilityState(popover){return visibilityState.get(popover)||"hidden"}var popoverInvoker=new WeakMap;function lastSetElement(set){return[...set].pop()}function popoverTargetAttributeActivationBehavior(element){const popover=element.popoverTargetElement;if(!(popover instanceof HTMLElement))return;const visibility=getPopoverVisibilityState(popover);element.popoverTargetAction==="show"&&visibility==="showing"||element.popoverTargetAction==="hide"&&visibility==="hidden"||(visibility==="showing"?hidePopover(popover,!0,!0):checkPopoverValidity(popover,!1)&&(popoverInvoker.set(popover,element),showPopover(popover)))}function checkPopoverValidity(element,expectedToBeShowing){return!(element.popover!=="auto"&&element.popover!=="manual"&&element.popover!=="hint"||!element.isConnected||expectedToBeShowing&&getPopoverVisibilityState(element)!=="showing"||!expectedToBeShowing&&getPopoverVisibilityState(element)!=="hidden"||element instanceof HTMLDialogElement&&element.hasAttribute("open")||document.fullscreenElement===element)}function getStackPosition(popover){if(!popover)return 0;const autoPopovers=autoPopoverList.get(document)||new Set,hintPopovers=hintPopoverList.get(document)||new Set;return hintPopovers.has(popover)?[...hintPopovers].indexOf(popover)+autoPopovers.size+1:autoPopovers.has(popover)?[...autoPopovers].indexOf(popover)+1:0}function topMostClickedPopover(target){const clickedPopover=nearestInclusiveOpenPopover(target),invokerPopover=nearestInclusiveTargetPopoverForInvoker(target);return getStackPosition(clickedPopover)>getStackPosition(invokerPopover)?clickedPopover:invokerPopover}function topmostAutoOrHintPopover(document2){let topmostPopover;const hintPopovers=hintPopoverList.get(document2)||new Set,autoPopovers=autoPopoverList.get(document2)||new Set,usedStack=hintPopovers.size>0?hintPopovers:autoPopovers.size>0?autoPopovers:null;return usedStack?(topmostPopover=lastSetElement(usedStack),topmostPopover.isConnected?topmostPopover:(usedStack.delete(topmostPopover),topmostAutoOrHintPopover(document2))):null}function topMostPopoverInList(list){for(const popover of list||[])if(!popover.isConnected)list.delete(popover);else return popover;return null}function getRootNode(node){return typeof node.getRootNode=="function"?node.getRootNode():node.parentNode?getRootNode(node.parentNode):node}function nearestInclusiveOpenPopover(node){for(;node;){if(node instanceof HTMLElement&&node.popover==="auto"&&visibilityState.get(node)==="showing")return node;if(node=node instanceof Element&&node.assignedSlot||node.parentElement||getRootNode(node),node instanceof ShadowRoot&&(node=node.host),node instanceof Document)return}}function nearestInclusiveTargetPopoverForInvoker(node){for(;node;){const nodePopover=node.popoverTargetElement;if(nodePopover instanceof HTMLElement)return nodePopover;if(node=node.parentElement||getRootNode(node),node instanceof ShadowRoot&&(node=node.host),node instanceof Document)return}}function topMostPopoverAncestor(newPopover,list){const popoverPositions=new Map;let i=0;for(const popover of list||[])popoverPositions.set(popover,i),i+=1;popoverPositions.set(newPopover,i),i+=1;let topMostPopoverAncestor2=null;function checkAncestor(candidate){if(!candidate)return;let okNesting=!1,candidateAncestor=null,candidatePosition=null;for(;!okNesting;){if(candidateAncestor=nearestInclusiveOpenPopover(candidate)||null,candidateAncestor===null||!popoverPositions.has(candidateAncestor))return;(newPopover.popover==="hint"||candidateAncestor.popover==="auto")&&(okNesting=!0),okNesting||(candidate=candidateAncestor.parentElement)}candidatePosition=popoverPositions.get(candidateAncestor),(topMostPopoverAncestor2===null||popoverPositions.get(topMostPopoverAncestor2)<candidatePosition)&&(topMostPopoverAncestor2=candidateAncestor)}return checkAncestor(newPopover.parentElement||getRootNode(newPopover)),topMostPopoverAncestor2}function isFocusable(focusTarget){return focusTarget.hidden||focusTarget instanceof ShadowRoot||(focusTarget instanceof HTMLButtonElement||focusTarget instanceof HTMLInputElement||focusTarget instanceof HTMLSelectElement||focusTarget instanceof HTMLTextAreaElement||focusTarget instanceof HTMLOptGroupElement||focusTarget instanceof HTMLOptionElement||focusTarget instanceof HTMLFieldSetElement)&&focusTarget.disabled||focusTarget instanceof HTMLInputElement&&focusTarget.type==="hidden"||focusTarget instanceof HTMLAnchorElement&&focusTarget.href===""?!1:typeof focusTarget.tabIndex=="number"&&focusTarget.tabIndex!==-1}function focusDelegate(focusTarget){if(focusTarget.shadowRoot&&focusTarget.shadowRoot.delegatesFocus!==!0)return null;let whereToLook=focusTarget;whereToLook.shadowRoot&&(whereToLook=whereToLook.shadowRoot);let autoFocusDelegate=whereToLook.querySelector("[autofocus]");if(autoFocusDelegate)return autoFocusDelegate;{const slots=whereToLook.querySelectorAll("slot");for(const slot of slots){const assignedElements=slot.assignedElements({flatten:!0});for(const el of assignedElements){if(el.hasAttribute("autofocus"))return el;if(autoFocusDelegate=el.querySelector("[autofocus]"),autoFocusDelegate)return autoFocusDelegate}}}const walker=focusTarget.ownerDocument.createTreeWalker(whereToLook,NodeFilter.SHOW_ELEMENT);let descendant=walker.currentNode;for(;descendant;){if(isFocusable(descendant))return descendant;descendant=walker.nextNode()}}function popoverFocusingSteps(subject){var _a;(_a=focusDelegate(subject))==null||_a.focus()}var previouslyFocusedElements=new WeakMap;function showPopover(element){if(!checkPopoverValidity(element,!1))return;const document2=element.ownerDocument;if(!element.dispatchEvent(new ToggleEvent("beforetoggle",{cancelable:!0,oldState:"closed",newState:"open"}))||!checkPopoverValidity(element,!1))return;let shouldRestoreFocus=!1;const originalType=element.popover;let stackToAppendTo=null;const autoAncestor=topMostPopoverAncestor(element,autoPopoverList.get(document2)||new Set),hintAncestor=topMostPopoverAncestor(element,hintPopoverList.get(document2)||new Set);if(originalType==="auto"&&(closeAllOpenPopoversInList(hintPopoverList.get(document2)||new Set,shouldRestoreFocus,!0),hideAllPopoversUntil(autoAncestor||document2,shouldRestoreFocus,!0),stackToAppendTo="auto"),originalType==="hint"&&(hintAncestor?(hideAllPopoversUntil(hintAncestor,shouldRestoreFocus,!0),stackToAppendTo="hint"):(closeAllOpenPopoversInList(hintPopoverList.get(document2)||new Set,shouldRestoreFocus,!0),autoAncestor?(hideAllPopoversUntil(autoAncestor,shouldRestoreFocus,!0),stackToAppendTo="auto"):stackToAppendTo="hint")),originalType==="auto"||originalType==="hint"){if(originalType!==element.popover||!checkPopoverValidity(element,!1))return;topmostAutoOrHintPopover(document2)||(shouldRestoreFocus=!0),stackToAppendTo==="auto"?(autoPopoverList.has(document2)||autoPopoverList.set(document2,new Set),autoPopoverList.get(document2).add(element)):stackToAppendTo==="hint"&&(hintPopoverList.has(document2)||hintPopoverList.set(document2,new Set),hintPopoverList.get(document2).add(element))}previouslyFocusedElements.delete(element);const originallyFocusedElement=document2.activeElement;element.classList.add(":popover-open"),visibilityState.set(element,"showing"),topLayerElements.has(document2)||topLayerElements.set(document2,new Set),topLayerElements.get(document2).add(element),setInvokerAriaExpanded(popoverInvoker.get(element),!0),popoverFocusingSteps(element),shouldRestoreFocus&&originallyFocusedElement&&element.popover==="auto"&&previouslyFocusedElements.set(element,originallyFocusedElement),queuePopoverToggleEventTask(element,"closed","open")}function hidePopover(element,focusPreviousElement=!1,fireEvents=!1){var _a,_b;if(!checkPopoverValidity(element,!0))return;const document2=element.ownerDocument;if(["auto","hint"].includes(element.popover)&&(hideAllPopoversUntil(element,focusPreviousElement,fireEvents),!checkPopoverValidity(element,!0)))return;const autoList=autoPopoverList.get(document2)||new Set,autoPopoverListContainsElement=autoList.has(element)&&lastSetElement(autoList)===element;if(setInvokerAriaExpanded(popoverInvoker.get(element),!1),popoverInvoker.delete(element),fireEvents&&(element.dispatchEvent(new ToggleEvent("beforetoggle",{oldState:"open",newState:"closed"})),autoPopoverListContainsElement&&lastSetElement(autoList)!==element&&hideAllPopoversUntil(element,focusPreviousElement,fireEvents),!checkPopoverValidity(element,!0)))return;(_a=topLayerElements.get(document2))==null||_a.delete(element),autoList.delete(element),(_b=hintPopoverList.get(document2))==null||_b.delete(element),element.classList.remove(":popover-open"),visibilityState.set(element,"hidden"),fireEvents&&queuePopoverToggleEventTask(element,"open","closed");const previouslyFocusedElement=previouslyFocusedElements.get(element);previouslyFocusedElement&&(previouslyFocusedElements.delete(element),focusPreviousElement&&previouslyFocusedElement.focus())}function closeAllOpenPopovers(document2,focusPreviousElement=!1,fireEvents=!1){let popover=topmostAutoOrHintPopover(document2);for(;popover;)hidePopover(popover,focusPreviousElement,fireEvents),popover=topmostAutoOrHintPopover(document2)}function closeAllOpenPopoversInList(list,focusPreviousElement=!1,fireEvents=!1){let popover=topMostPopoverInList(list);for(;popover;)hidePopover(popover,focusPreviousElement,fireEvents),popover=topMostPopoverInList(list)}
1function hidePopoverStackUntil(endpoint,set,focusPreviousElement,fireEvents){let repeatingHide=!1,hasRunOnce=!1;for(;repeatingHide||!hasRunOnce;){hasRunOnce=!0;let lastToHide=null,foundEndpoint=!1;for(const popover of set)if(popover===endpoint)foundEndpoint=!0;else if(foundEndpoint){lastToHide=popover;break}if(!lastToHide)return;for(;getPopoverVisibilityState(lastToHide)==="showing"&&set.size;)hidePopover(lastSetElement(set),focusPreviousElement,fireEvents);set.has(endpoint)&&lastSetElement(set)!==endpoint&&(repeatingHide=!0),repeatingHide&&(fireEvents=!1)}}function hideAllPopoversUntil(endpoint,focusPreviousElement,fireEvents){var _a,_b;const document2=endpoint.ownerDocument||endpoint;if(endpoint instanceof Document)return closeAllOpenPopovers(document2,focusPreviousElement,fireEvents);if((_a=hintPopoverList.get(document2))!=null&&_a.has(endpoint)){hidePopoverStackUntil(endpoint,hintPopoverList.get(document2),focusPreviousElement,fireEvents);return}closeAllOpenPopoversInList(hintPopoverList.get(document2)||new Set,focu
1sPreviousElement,fireEvents),(_b=autoPopoverList.get(document2))!=null&&_b.has(endpoint)&&hidePopoverStackUntil(endpoint,autoPopoverList.get(document2),focusPreviousElement,fireEvents)}var popoverPointerDownTargets=new WeakMap;function lightDismissOpenPopovers(event){if(!event.isTrusted)return;const target=event.composedPath()[0];if(!target)return;const document2=target.ownerDocument;if(!topmostAutoOrHintPopover(document2))return;const ancestor=topMostClickedPopover(target);if(ancestor&&event.type==="pointerdown")popoverPointerDownTargets.set(document2,ancestor);else if(event.type==="pointerup"){const sameTarget=popoverPointerDownTargets.get(document2)===ancestor;popoverPointerDownTargets.delete(document2),sameTarget&&hideAllPopoversUntil(ancestor||document2,!1,!0)}}var initialAriaExpandedValue=new WeakMap;function setInvokerAriaExpanded(el,force=!1){if(!el)return;initialAriaExpandedValue.has(el)||initialAriaExpandedValue.set(el,el.getAttribute("aria-expanded"));const popover=el.popoverTargetElement;if(popover instanceof HTMLElement&&popover.popover==="auto")el.setAttribute("aria-expanded",String(force));else{const initialValue=initialAriaExpandedValue.get(el);initialValue?el.setAttribute("aria-expanded",initialValue):el.removeAttribute("aria-expanded")}}var ShadowRoot2=globalThis.ShadowRoot||function(){};function isSupported(){return typeof HTMLElement<"u"&&typeof HTMLElement.prototype=="object"&&"popover"in HTMLElement.prototype}function patchSelectorFn(object,name,mapper){const original=object[name];Object.defineProperty(object,name,{value(selector){return original.call(this,mapper(selector))}})}var nonEscapedPopoverSelector=/(^|[^\\]):popover-open\b/g;function hasLayerSupport(){return typeof globalThis.CSSLayerBlockRule=="function"}function getStyles(){const useLayer=hasLayerSupport();return`
2${useLayer?"@layer popover-polyfill {":""}
3  :where([popover]) {
4    position: fixed;
5    z-index: 2147483647;
6    inset: 0;
7    padding: 0.25em;
8    width: fit-content;
9    height: fit-content;
10    border-width: initial;
11    border-color: initial;
12    border-image: initial;
13    border-style: solid;
14    background-color: canvas;
15    color: canvastext;
16    overflow: auto;
17    margin: auto;
18  }
19
20  :where([popover]:not(.\\:popover-open)) {
21    display: none;
22  }
23
24  :where(dialog[popover].\\:popover-open) {
25    display: block;
26  }
27
28  :where(dialog[popover][open]) {
29    display: revert;
30  }
31
32  :where([anchor].\\:popover-open) {
33    inset: auto;
34  }
35
36  :where([anchor]:popover-open) {
37    inset: auto;
38  }
39
40  @supports not (background-color: canvas) {
41    :where([popover]) {
42      background-color: white;
43      color: black;
44    }
45  }
46
47  @supports (width: -moz-fit-content) {
48    :where([popover]) {
49      width: -moz-fit-content;
50      height: -moz-fit-content;
51    }
52  }
53
54  @supports not (inset: 0) {
55    :where([popover]) {
56      top: 0;
57      left: 0;
58      right: 0;
59      bottom: 0;
60    }
61  }
62${useLayer?"}":""}
63`}var popoverStyleSheet=null;function injectStyles(root){const styles=getStyles();if(popoverStyleSheet===null)try{popoverStyleSheet=new CSSStyleSheet,popoverStyleSheet.replaceSync(styles)}catch{popoverStyleSheet=!1}if(popoverStyleSheet===!1){const sheet=document.createElement("style");sheet.textContent=styles,root instanceof Document?root.head.prepend(sheet):root.prepend(sheet)}else root.adoptedStyleSheets=[popoverStyleSheet,...root.adoptedStyleSheets]}function apply(){if(typeof window>"u")return;window.ToggleEvent=window.ToggleEvent||ToggleEvent;function rewriteSelector(selector){return selector?.includes(":popover-open")&&(selector=selector.replace(nonEscapedPopoverSelector,"$1.\\:popover-open")),selector}patchSelectorFn(Document.prototype,"querySelector",rewriteSelector),patchSelectorFn(Document.prototype,"querySelectorAll",rewriteSelector),patchSelectorFn(Element.prototype,"querySelector",rewriteSelector),patchSelectorFn(Element.prototype,"querySelectorAll",rewriteSelector),patchSelectorFn(Element.prototype,"matches",rewriteSelector),patchSelectorFn(Element.prototype,"closest",rewriteSelector),patchSelectorFn(DocumentFragment.prototype,"querySelectorAll",rewriteSelector),Object.defineProperties(HTMLElement.prototype,{popover:{enumerable:!0,configurable:!0,get(){if
63(!this.hasAttribute("popover"))return null;const value=(this.getAttribute("popover")||"").toLowerCase();return value===""||value=="auto"?"auto":value=="hint"?"hint":"manual"},set(value){value===null?this.removeAttribute("popover"):this.setAttribute("popover",value)}},showPopover:{enumerable:!0,configurable:!0,value(options={}){showPopover(this)}},hidePopover:{enumerable:!0,configurable:!0,value(){hidePopover(this,!0,!0)}},togglePopover:{enumerable:!0,configurable:!0,value(options={}){return typeof options=="boolean"&&(options={force:options}),visibilityState.get(this)==="showing"&&options.force===void 0||options.force===!1?hidePopover(this,!0,!0):(options.force===void 0||options.force===!0)&&showPopover(this),visibilityState.get(this)==="showing"}}});const originalAttachShadow=Element.prototype.attachShadow;originalAttachShadow&&Object.defineProperties(Element.prototype,{attachShadow:{enumerable:!0,configurable:!0,writable:!0,value(options){const shadowRoot=originalAttachShadow.call(this,options);return injectStyles(shadowRoot),shadowRoot}}});const originalAttachInternals=HTMLElement.prototype.attachInternals;originalAttachInternals&&Object.defineProperties(HTMLElement.prototype,{attachInternals:{enumerable:!0,configurable:!0,writable:!0,value(){const internals=originalAttachInternals.call(this);return internals.shadowRoot&&injectStyles(internals.shadowRoot),internals}}});const popoverTargetAssociatedElements=new WeakMap;function applyPopoverInvokerElementMixin(ElementClass){Object.defineProperties(ElementClass.prototype,{popoverTargetElement:{enumerable:!0,configurable:!0,set(targetElement){if(targetElement===null)this.removeAttribute("popovertarget"),popoverTargetAssociatedElements.delete(this);else if(targetElement instanceof Element)this.setAttribute("popovertarget",""),popoverTargetAssociatedElements.set(this,targetElement);else throw new TypeError("popoverTargetElement must be an element or null")},get(){if(this.localName!=="button"&&this.localName!=="input"||this.localName==="input"&&this.type!=="reset"&&this.type!=="image"&&this.type!=="button"||this.disabled||this.form&&this.type==="submit")return null;const targetElement=popoverTargetAssociatedElements.get(this);if(targetElement&&targetElement.isConnected)return targetElement;if(targetElement&&!targetElement.isConnected)return popoverTargetAssociatedElements.delete(this),null;const root=getRootNode(this),idref=this.getAttribute("popovertarget");return(root instanceof Document||root instanceof ShadowRoot2)&&idref&&root.getElementById(idref)||null}},popoverTargetAction:{enumerable:!0,configurable:!0,get(){const value=(this.getAttribute("popovertargetaction")||"").toLowerCase();return value==="show"||value==="hide"?value:"toggle"},set(value){this.setAttribute("popovertargetaction",value)}}})}applyPopoverInvokerElementMixin(HTMLButtonElement),applyPopoverInvokerElementMixin(HTMLInputElement);const handleInvokerActivation=event=>{if(event.defaultPrevented)return;const composedPath=event.composedPath(),target=composedPath[0];if(!(target instanceof Element)||target?.shadowRoot)return;const root=getRootNode(target);if(!(root instanceof ShadowRoot2||root instanceof Document))return;const invoker=composedPath.find(el=>{var _a;return(_a=el.matches)==null?void 0:_a.call(el,"[popovertargetaction],[popovertarget]")});if(invoker){popoverTargetAttributeActivationBehavior(invoker),event.preventDefault();return}},onKeydown=event=>{const key=event.key,target=event.target;!event.defaultPrevented&&target&&(key==="Escape"||key==="Esc")&&hideAllPopoversUntil(target.ownerDocument,!0,!0)};(root=>{root.addEventListener("click",handleInvokerActivation),root.addEventListener("keydown",onKeydown),root.addEventListener("pointerdown",lightDismissOpenPopovers),root.addEventListener("pointerup",lightDismissOpenPopovers)})(document),injectStyles(document)}isSupported()||apply();
64//# sourceMappingURL=/cdn/shop/t/4/assets/popover-polyfill.js.map?v=119029313658895111201774386997

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.