var oldNotification=parentDocument.querySelector('cart-notification');
var newNotification=tmp.querySelector('cart-notification')||((tmp.firstElementChild&&tmp.firstElementChild.matches&&tmp.firstElementChild.matches('cart-notification'))?tmp.firstElementChild:null);
if(oldNotification&&newNotification&&typeof oldNotification.replaceWith==='function')oldNotification.replaceWith(newNotification);
}
});
}
function dispatchEvents(parentDocument,cart){
EVENTS.forEach(function(name){
try{parentDocument.dispatchEvent(new CustomEvent(name,{bubbles:true,detail:{cart:cart}}));}catch(_){ }
});
}
function isDrawerOpen(drawer){
if(!drawer)return false;
if(typeof drawer.hasAttribute==='function'&&drawer.hasAttribute('open'))return true;
if(typeof drawer.getAttribute==='function'&&drawer.getAttribute('aria-hidden')==='false')return true;
if(drawer.classList&&(drawer.classList.contains('active')||drawer.classList.contains('is-open')))return true;
var dialog=drawer.querySelector&&drawer.querySelector('dialog[open]');
return !!dialog;
}
function openCart(parentDocument){
var drawer=parentDocument.querySelector('cart-drawer');
if(drawer&&typeof drawer.open==='function'){drawer.open();return;}
if(isDrawerOpen(drawer))return;
var btn=parentDocument.getElementById('cart-icon-bubble')||
parentDocument.querySelector('[aria-controls="CartDrawer"],[aria-controls="cart-drawer"],[aria-controls="MiniCart"]')||
parentDocument.querySelector('[data-cart-toggle],[data-open-drawer="cart"]')||
parentDocument.querySelector('a[href="/hu/cart"],a[href$="/cart"],[href="/hu/cart"],[href$="/cart"]');
if(btn&&typeof btn.getAttribute==='function'&&btn.getAttribute('aria-expanded')==='true')return;
if(btn&&typeof btn.click==='function')btn.click();
}
function renderThemeCart(parentDocument,addData){
if(!addData||typeof addData!=='object'||!addData.sections)return null;
var drawer=parentDocument.querySelector('cart-drawer');
if(drawer&&typeof drawer.renderContents==='function'){
try{drawer.renderContents(addData);return 'drawer';}catch(_){ }
}
var notification=parentDocument.querySelector('cart-notification');
if(notification&&typeof notification.renderContents==='function'){
try{notification.renderContents(addData);return 'notification';}catch(_){ }
}
return null;
}
function sectionsFetchUrl(sectionIds){
var ids=uniq(sectionIds&§ionIds.length?sectionIds:DEFAULT_IDS);
return storefrontPath('')+'?sections='+encodeURIComponent(ids.join(','))+'&__ai_ts='+Date.now();
}
function runQueuedRefresh(){
refreshInFlight=false;
if(!refreshQueued)return;
refreshQueued=false;
var queued=queuedInlineSections;
queuedInlineSections=null;
setTimeout(function(){refreshCartUi({inlineSections:queued});},0);
}
function refreshCartUi(options){
options=options||{};
if(refreshInFlight){
refreshQueued=true;
if(options.inlineSections&&typeof options.inlineSections==='object')queuedInlineSections=options.inlineSections;
return;
}
refreshInFlight=true;
var parentWindow;
var parentDocument;
try{parentWindow=window.parent||window;parentDocument=parentWindow.document;}catch(_){runQueuedRefresh();return;}
var inlineSections=extractInlineSections(options.inlineSections);
var renderedWithThemeApi=renderThemeCart(parentDocument,options.inlineSections);
fetch(storefrontPath('cart.js')+'?__ai_ts='+Date.now(),{cache:'no-store'})
.then(function(response){return response.json();})
.then(function(cart){
scheduleCountRepatch(parentWindow,parentDocument,cart&&typeof cart.item_count==='number'?cart.item_count:0);
if(inlineSections){
if(!renderedWithThemeApi)replaceSections(parentDocument,inlineSections);
scheduleCountRepatch(parentWindow,parentDocument,cart&&typeof cart.item_count==='number'?cart.item_count:0);
setTimeout(function(){
openCart(parentDocument);
dispatchEvents(parentDocument,cart||{});
scheduleCountRepatch(parentWindow,parentDocument,cart&&typeof cart.item_count==='number'?cart.item_count:0);
runQueuedRefresh();
},300);
return;
}
var sectionIds=discoverCartSectionIds(parentDocument);
fetch(sectionsFetchUrl(sectionIds),{cache:'no-store'})
.then(function(res){return res.ok?res.json():Promise.reject();})
.then(function(sections){replaceSections(parentDocument,extractInlineSections(sections));})
.catch(function(){})
.finally(function(){
scheduleCountRepatch(parentWindow,parentDocument,cart&&typeof cart.item_count==='number'?cart.item_count:0);
setTimeout(function(){
openCart(parentDocument);
dispatchEvents(parentDocument,cart||{});
scheduleCountRepatch(parentWindow,parentDocument,cart&&typeof cart.item_count==='number'?cart.item_count:0);
runQueuedRefresh();
},300);
});
})
.catch(function(){runQueuedRefresh();});
}
function onAddResponse(data){
var extracted=extractInlineSections(data);
if(extracted){refreshCartUi({inlineSections:data});return;}
refreshCartUi({});
}
window.__aiCartBridge={
__installed:true,
discoverCartSectionIds:discoverCartSectionIds,
injectSectionsIntoAddRequest:injectSectionsIntoAddRequest,
refreshCartUi:refreshCartUi,
refreshFromAddResponse:onAddResponse
};
window.__aiCartRefresh=function(inlineSections){
refreshCartUi({inlineSections:inlineSections||null});
};
var originalFetch=window.fetch;
if(typeof originalFetch==='function'&&!window.__aiCartBridgeFetchPatched){
window.__aiCartBridgeFetchPatched=true;
window.fetch=function(url,opts){
var target=typeof url==='string'?url:(url&&url.url?url.url:'');
var method=(opts&&opts.method)||(url&&url.method)||'GET';
if(target&&target.indexOf('/cart/add.js')!==-1&&String(method||'GET').toUpperCase()==='POST'){
var nextOpts=opts||{};
var skipAutoRefresh=!!(nextOpts&&nextOpts.__aiSkipAutoCartRefresh);
try{
var parentDocument=(window.parent||window).document;
var ids=discoverCartSectionIds(parentDocument);
var sectionsUrl=(function(){try{return window.parent.location.pathname||'/';}catch(_){return '/';}})();
nextOpts=injectSectionsIntoAddRequest(nextOpts,ids,sectionsUrl);
}catch(_){ }
var req=originalFetch.call(this,url,nextOpts);
if(skipAutoRefresh)return req;
req.then(function(response){
if(!response||!response.ok){setTimeout(function(){refreshCartUi({});},260);return;}
try{
response.clone().json().then(function(data){onAddResponse(data);}).catch(function(){setTimeout(function(){refreshCartUi({});},260);});
}catch(_){setTimeout(function(){refreshCartUi({});},260);}
},function(){});
return req;
}
return originalFetch.apply(this,arguments);
};
}
})();
})();
</script>
</body>
</html>" style="width:100%;border:none;display:block;overflow:hidden;vertical-align:top;margin:0;padding:0;height:0px;" scrolling="no" title="Oldalszakasz 1" sandbox="allow-scripts allow-same-origin">