1import{Component}from"@theme/component";const HYDRATION_KEY_ATTRIBUTE="data-hydration-key",PRESERVED_ATTRIBUTES=["product-grid-view","data-current-checked","data-previous-checked","cart-summary-sticky"],PRESERVED_ATTRIBUTES_SET=new Set(PRESERVED_ATTRIBUTES);export const MORPH_OPTIONS={childrenOnly:!0,hydrationMode:!1,reject(oldNode,newNode){return!!(newNode.nodeType===Node.TEXT_NODE&&newNode.nodeValue?.trim()===""||newNode instanceof HTMLTemplateElement&&newNode.shadowRootMode==="open"&&oldNode.parentElement&&newNode.parentElement&&oldNode.parentElement.tagName===newNode.parentElement.tagName&&oldNode.parentElement?.shadowRoot!=null||newNode.nodeType===Node.COMMENT_NODE&&newNode.nodeValue==="shopify:rendered_by_section_api")},onBeforeUpdate(oldNode,newNode){if(!(oldNode instanceof Element)||!(newNode instanceof Element))return;const oldAttrs=oldNode.attributes;for(let i=0;i<oldAttrs.length;i++){const attr=oldAttrs[i];if(PRESERVED_ATTRIBUTES_SET.has(attr.name)){const oldValue=attr.value;oldValue&&oldValue!==newNode.getAttribute(attr.name)&&newNode.setAttribute(attr.name,oldValue)}}const tagName=oldNode.tagName;if(tagName==="FLOATING-PANEL-COMPONENT"||tagName==="FIELDSET"){const isFloating=tagName==="FLOATING-PANEL-COMPONENT";if((isFloating||oldNode.classList.contains("variant-option"))&&newNode.tagName===tagName&&(isFloating||newNode.classList.contains("variant-option"))){const oldStyle=oldNode.getAttribute("style");oldStyle&&newNode.setAttribute("style",oldStyle)}}oldNode instanceof HTMLElement&&newNode instanceof HTMLElement&&oldNode.style.viewTransitionName&&(newNode.style.viewTransitionName=oldNode.style.viewTransitionName)},onAfterUpdate(node){node instanceof Component&&queueMicrotask(()=>node.updatedCallback())}};export function morph(oldTree,newTree,options=MORPH_OPTIONS){if(!oldTree||!newTree)throw new Error("Both oldTree and newTree must be provided");if(typeof newTree=="string"){const parsedNewTree=new DOMParser().parseFromString(newTree,"text/html").body.firstChild;if(!parsedNewTree)throw new Error("newTree string is not valid HTML");newTree=parsedNewTree}if(options.hydrationMode&&oldTree instanceof Element&&newTree instanceof Element)return morphHydrationByKey(oldTree,newTree,options),oldTree;let result;if(options.childrenOnly)updateChildren(newTree,oldTree,options),result=oldTree;else{if(newTree.nodeType===11)throw new Error("newTree should have one root node (not a DocumentFragment)");result=walk(newTree,oldTree,options)}return result instanceof Element&&recreateAppBlockScripts(result),result}function collectHydrationTargets(root){const targets=[];return root.hasAttribute(HYDRATION_KEY_ATTRIBUTE)&&targets.push(root),targets.push(...root.querySelectorAll(`[${HYDRATION_KEY_ATTRIBUTE}]`)),targets}function morphHydrationByKey(oldRoot,newRoot,options){const oldTargets=collectHydrationTargets(oldRoot),newTargets=collectHydrationTargets(newRoot),oldTargetsByKey=new Map;for(const oldTarget of oldTargets){const key=oldTarget.getAttribute(HYDRATION_KEY_ATTRIBUTE);if(key==null||key==="")continue;const existing=oldTargetsByKey.get(key)??[];existing.push(oldTarget),oldTargetsByKey.set(key,existing)}for(const newTarget of newTargets){const key=newTarget.getAttribute(HYDRATION_KEY_ATTRIBUTE);if(key==null||key==="")continue;const oldTarget=oldTargetsByKey.get(key)?.shift();oldTarget&&morph(oldTarget,newTarget,{...options,hydrationMode:!1,childrenOnly:!1})}}function walk(newNode,oldNode,options){if(!oldNode)return newNode;if(!newNode||newNode===oldNode)return oldNode;const newType=newNode.nodeType;if(newType!==oldNode.nodeType)return newNode;if(newType===1){const oldEl=oldNode,newEl=newNode;if(oldEl.tagName==="SHOPIFY-ACCELERATED-CHECKOUT-CART")return oldNode;if(newEl.tagName!==oldEl.tagName)return newNode;if(oldNode.isEqualNode(newNode))return syncFormControlsInSubtree(newEl,oldEl),oldNode;const newKey=getNodeKey(newNode,options),oldKey=getNodeKey(oldNode,options);if(newKey&&oldKey&&newKey!==oldKey)return newNode;oldEl.hasAttribute("data-skip-node-update")&&newEl.hasAttribute("data-skip-node-update")||updateNode(newNode,oldNode,options),updateChildren(newNode,oldNode,options)}else updateNode(newNode,oldNode,options);return options.onAfterUpdate?.(newNode),oldNode}function updateNode(newNode,oldNode,options){options.onBeforeUpdate?.(oldNode,newNode);const newType=newNode.nodeType;if(newType===1){const oldEl=oldNode,newEl=newNode;
1if(!attributesEqual(oldEl,newEl)){if((newNode instanceof HTMLDetailsElement&&oldNode instanceof HTMLDetailsElement||newNode instanceof HTMLDialogElement&&oldNode instanceof HTMLDialogElement)&&(newNode.hasAttribute("declarative-open")||(newNode.open=oldNode.open)),oldNode instanceof HTMLElement&&newNode instanceof HTMLElement)for(const attr of["slot","sizes"]){const oldValue=oldNode.getAttribute(attr),newValue=newNode.getAttribute(attr);oldValue!==newValue&&(oldValue==null?newNode.removeAttribute(attr):newNode.setAttribute(attr,oldValue))}copyAttributes(newEl,oldEl)}syncFormControlState(newNode,oldNode)}else(newType===3||newType===8)&&oldNode.nodeValue!==newNode.nodeValue&&(oldNode.nodeValue=newNode.nodeValue)}function syncFormControlState(newNode,oldNode){newNode instanceof HTMLInputElement&&oldNode instanceof HTMLInputElement?updateInput(newNode,oldNode):newNode instanceof HTMLOptionElement&&oldNode instanceof HTMLOptionElement?updateAttribute(newNode,oldNode,"selected"):newNode instanceof HTMLTextAreaElement&&oldNode instanceof HTMLTextAreaElement&&updateTextarea(newNode,oldNode)}function skipsNodeUpdate(newNode,oldNode){return newNode.hasAttribute("data-skip-node-update")&&oldNode.hasAttribute("data-skip-node-update")}function syncFormControlsInSubtree(newNode,oldNode){skipsNodeUpdate(newNode,oldNode)||syncFormControlState(newNode,oldNode);const newControls=newNode.querySelectorAll("input, option, textarea");if(newControls.length===0)return;const oldControls=oldNode.querySelectorAll("input, option, textarea");for(let i=0;i<newControls.length;i++){const newControl=newControls[i],oldControl=oldControls[i];skipsNodeUpdate(newControl,oldControl)||syncFormControlState(newControl,oldControl)}}function attributesEqual(a,b){const aAttrs=a.attributes,bAttrs=b.attributes,len=aAttrs.length;if(len!==bAttrs.length)return!1;for(let i=0;i<len;i++){const aAttr=aAttrs[i],bAttr=bAttrs[i];if(!aAttr.isEqualNode(bAttr))return!1}return!0}function getNodeKey(node,options){return options?.getNodeKey?.(node)??(node instanceof Element?node.id:void 0)}function updateAttribute(newNode,oldNode,name){newNode[name]!==oldNode[name]&&(oldNode[name]=newNode[name],newNode[name]!=null?oldNode.setAttribute(name,""):oldNode.removeAttribute(name))}function copyAttributes(newNode,oldNode){const oldAttrs=oldNode.attributes,newAttrs=newNode.attributes;for(const attr of Array.from(newAttrs)){const{name:attrName,namespaceURI:attrNamespaceURI,value:attrValue}=attr,localName=attr.localName||attrName;(attrName==="src"||attrName==="href"||attrName==="srcset"||attrName==="poster")&&oldNode.getAttribute(attrName)===attrValue||(attrNamespaceURI?oldNode.getAttributeNS(attrNamespaceURI,localName)!==attrValue&&oldNode.setAttributeNS(attrNamespaceURI,localName,attrValue):oldNode.hasAttribute(attrName)?oldNode.getAttribute(attrName)!==attrValue&&(attrValue==="null"||attrValue==="undefined"?oldNode.removeAttribute(attrName):oldNode.setAttribute(attrName,attrValue)):oldNode.setAttribute(attrName,attrValue))}for(const attr of Array.from(oldAttrs)){if(attr.specified===!1)continue;const{name:attrName,namespaceURI:attrNamespaceURI}=attr,localName=attr.localName||attrName;attrNamespaceURI?newNode.hasAttributeNS(attrNamespaceURI,localName)||oldNode.removeAttributeNS(attrNamespaceURI,localName):newNode.hasAttribute(attrName)||oldNode.removeAttribute(attrName)}}function updateInput(newNode,oldNode){const newValue=newNode.value;updateAttribute(newNode,oldNode,"checked"),updateAttribute(newNode,oldNode,"disabled"),newNode.indeterminate!==oldNode.indeterminate&&(oldNode.indeterminate=newNode.indeterminate),oldNode.type!=="file"&&(newValue!==oldNode.value&&(oldNode.setAttribute("value",newValue),oldNode.value=newValue),newValue==="null"&&(oldNode.value="",oldNode.removeAttribute("value")),newNode.hasAttributeNS(null,"value")?oldNode.type==="range"&&(oldNode.value=newValue):oldNode.removeAttribute("value"))}function updateTextarea(newNode,oldNode){const newValue=newNode.value;newValue!==oldNode.value&&(oldNode.value=newValue);const firstChild=oldNode.firstChild;if(firstChild?.nodeType===Node.TEXT_NODE){if(newValue===""&&firstChild.nodeValue===oldNode.placeholder)return;firstChild.nodeValue=newValue}}function recreateAppBlockScripts(container){const scripts=container.querySelectorAll(".shopify-app-block script[src]");for(const script of scripts){if(!(script instanceof HTMLScriptElement))continue;const parent=script.parentElement;
1if(!parent)continue;const newScript=document.createElement("script");for(const attr of Array.from(script.attributes))newScript.setAttribute(attr.name,attr.value);script.textContent&&(newScript.textContent=script.textContent),script.remove(),parent.appendChild(newScript)}}function updateChildren(newNode,oldNode,options){if(oldNode instanceof Element&&oldNode.hasAttribute("data-skip-subtree-update")&&newNode instanceof Element&&newNode.hasAttribute("data-skip-subtree-update"))return;const oldChildren=oldNode.childNodes,newChildren=newNode.childNodes,reject=options.reject;let oldChild,newChild,morphed,oldMatch,offset=0;for(let i=0;oldChild=oldChildren[i],newChild=newChildren[i-offset],!(!oldChild&&!newChild);i++){if(!newChild){oldChild&&oldNode.removeChild(oldChild),i--;continue}if(!oldChild){oldNode.appendChild(newChild),offset++;continue}if(same(newChild,oldChild,options)){morphed=walk(newChild,oldChild,options),morphed!==oldChild&&(oldNode.replaceChild(morphed,oldChild),offset++);continue}if(reject!==void 0&&reject(oldChild,newChild)){newNode.removeChild(newChild),i--;continue}oldMatch=null;const oldChildrenLen=oldChildren.length;for(let j=i;j<oldChildrenLen;j++){const potentialOldNode=oldChildren[j];if(potentialOldNode&&same(potentialOldNode,newChild,options)){oldMatch=potentialOldNode;break}}oldMatch?(morphed=walk(newChild,oldMatch,options),morphed!==oldMatch&&offset++,oldNode.insertBefore(morphed,oldChild)):!getNodeKey(newChild,options)&&!getNodeKey(oldChild,options)?(morphed=walk(newChild,oldChild,options),morphed!==oldChild&&(oldNode.replaceChild(morphed,oldChild),offset++)):(oldNode.insertBefore(newChild,oldChild),offset++)}}function same(a,b,options){const aType=a.nodeType,bType=b.nodeType;if(aType!==bType)return!1;if(aType===Node.ELEMENT_NODE){if(a instanceof Element&&b instanceof Element&&a.tagName!==b.tagName)return!1;const aKey=getNodeKey(a,options),bKey=getNodeKey(b,options);if(aKey&&bKey&&aKey!==bKey)return!1}if(aType===Node.TEXT_NODE&&bType===Node.TEXT_NODE){const av=a.nodeValue,bv=b.nodeValue;return av===bv||av?.trim()===bv?.trim()}return aType===Node.COMMENT_NODE&&bType===Node.COMMENT_NODE?a.nodeValue===b.nodeValue:!0} 2//# sourceMappingURL=/cdn/shop/t/3/assets/morph.js.map?v=182601902166245204061782122108
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.