1(function(){"use strict";console.log("[VFA Store Favorites] Script loaded - Version 2026-01-30-vfa");const STORE_API_BASE="/apps/wego-favorite/api/stores/favorites",DEBUG=!1,BUTTON_DISABLE_TIME=1e3,MAX_RETRIES=3,TEXT_ADD="\u304A\u6C17\u306B\u5165\u308A\u767B\u9332",TEXT_REMOVE="\u304A\u6C17\u306B\u5165\u308A\u89E3\u9664",COLOR_FAVORITED="#fa7283",COLOR_DEFAULT="";function log(...args){DEBUG&&console.log("[VFA Store Favorites]",...args)}function getCustomerId(){if(window.ShopifyCustomer&&window.ShopifyCustomer.id){const id=String(window.ShopifyCustomer.id);return/^\d+$/.test(id)?`gid://shopify/Customer/${id}`:id}if(window.__st&&window.__st.cid){const id=String(window.__st.cid);return/^\d+$/.test(id)?`gid://shopify/Customer/${id}`:id}const metaCustomerId=document.querySelector('meta[name="shopify-customer-id"]');if(metaCustomerId&&metaCustomerId.content){const id=metaCustomerId.content;return/^\d+$/.test(id)?`gid://shopify/Customer/${id}`:id}return null}function isLoggedIn(){const customerId=getCustomerId();return customerId?(log("\u2705 \u9867\u5BA2ID\u53D6\u5F97:",customerId),!0):(log("\u274C \u9867\u5BA2ID\u304C\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093"),!1)}async function checkStoreFavoriteStatus(storeName,button){if(!isLoggedIn()){log("\u23ED\uFE0F \u672A\u30ED\u30B0\u30A4\u30F3\u306E\u305F\u3081\u72B6\u614B\u78BA\u8A8D\u3092\u30B9\u30AD\u30C3\u30D7");return}try{const response=await fetch(STORE_API_BASE);if(response.ok){const isFavorited=(await response.json()).favorites?.some(f=>f.storeName===storeName||f.storeHandle===button.dataset.shopId);updateButtonState(button,isFavorited),log("\u{1F4CA} \u5E97\u8217\u521D\u671F\u72B6\u614B:",storeName,isFavorited?"\u304A\u6C17\u306B\u5165\u308A\u6E08\u307F":"\u672A\u767B\u9332")}else log("\u26A0\uFE0F \u5E97\u8217\u72B6\u614B\u78BA\u8A8D\u30A8\u30E9\u30FC: HTTP",response.status)}catch(error){log("\u26A0\uFE0F \u5E97\u8217\u72B6\u614B\u78BA\u8A8D\u30A8\u30E9\u30FC:",error)}}async function toggleStoreFavorite(button){const storeName=button.dataset.shopName;if(log("\u{1F5B1}\uFE0F \u5E97\u8217\u30AF\u30EA\u30C3\u30AF:",storeName),!isLoggedIn()){window.location.href="/account/login?return_url="+encodeURIComponent(window.location.pathname);return}const isCurrentlyFavorited=button.classList.contains("vfa-registered");updateButtonState(button,!isCurrentlyFavorited),button.disabled=!0,button.classList.add("vfa-is-loading");const action=isCurrentlyFavorited?"remove":"add";let retryCount=0,lastError=null;for(;retryCount<=MAX_RETRIES;)try{const customerId=getCustomerId(),response=await fetch(STORE_API_BASE,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storeName,action,customerId})});if(response.ok){log(`\u2705 \u5E97\u8217${action==="add"?"\u8FFD\u52A0":"\u524A\u9664"}\u6210\u529F:`,storeName);break}else{const errorData=await response.json().catch(()=>({}));if(response.status===401||response.status===403){alert("\u8A8D\u8A3C\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u30ED\u30B0\u30A4\u30F3\u30DA\u30FC\u30B8\u3078\u79FB\u52D5\u3057\u307E\u3059\u3002"),window.location.href="/account/login?return_url="+encodeURIComponent(window.location.pathname),updateButtonState(button,isCurrentlyFavorited);return}if(response.status===404||errorData.error&&errorData.error.includes("Store not found")){log("\u274C \u5E97\u8217\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093:",storeName),showErrorMessage("\u3053\u306E\u5E97\u8217\u3092\u304A\u6C17\u306B\u5165\u308A\u3067\u304D\u307E\u305B\u3093"),updateButtonState(button,isCurrentlyFavorited),button.disabled=!1,button.classList.remove("vfa-is-loading");return}if(response.status>=500&&retryCount<MAX_RETRIES){retryCount++,log(`\u26A0\uFE0F \u30B5\u30FC\u30D0\u30FC\u30A8\u30E9\u30FC (${response.status})\u3002\u30EA\u30C8\u30E9\u30A4 ${retryCount}/${MAX_RETRIES}...`),await new Promise(resolve=>setTimeout(resolve,1e3*retryCount));continue}throw new Error(`API Error: ${response.status} - ${errorData.error||""}`)}}catch(error){if(lastError=error,retryCount<MAX_RETRIES&&(error.name==="TypeError"||error.message.includes("fetch"))){retryCount++,log(`\u26A0\uFE0F \u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u30A8\u30E9\u30FC\u3002\u30EA\u30C8\u30E9\u30A4 ${retryCount}/${MAX_RETRIES}...`),await new Promise(resolve=>setTimeout(resolve,1e3*retryCount));continue}log("\u274C \u5E97\u8217\u30A8\u30E9\u30FC:",error),showErrorMessage("\u304A\u6C17\u306B\u5165\u308A\u306E\u66F4\u65B0\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3002\u3082\u3046\u4E00\u5EA6\u304A\u8A66\u3057\u304F\u3060\u3055\u3044\u3002"),updateButtonState(button,isCurrentlyFavorited);break}lastError&&retryCount>=MAX_RETRIES&&(log("\u274C \u5E97\u8217\u30A8\u30E9\u30FC\uFF08\u30EA\u30C8\u30E9\u30A4\u4E0A\u9650\uFF09:",lastError),showErrorMessage("\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u3057\u3070\u3089\u304F\u6642\u9593\u3092\u304A\u3044\u3066\u304B\u3089\u518D\u5EA6\u304A\u8A66\u3057\u304F\u3060\u3055\u3044\u3002"),updateButtonState(button,isCurrentlyFavorited)),setTimeout(()=>{button.disabled=!1,button.classList.remove("vfa-is-loading")},BUTTON_DISABLE_TIME)}function updateButtonState(button,isFavorited){const textElement=button.querySelector(".vfa-store-favorite-text");isFavorited?(button.classList.add("vfa-registered"),button.setAttribute("aria-pressed","true"),button.setAttribute("aria-label","\u304A\u6C17\u306B\u5165\u308A\u89E3\u9664"),button.setAttribute("title","\u304A\u6C17\u306B\u5165\u308A\u89E3\u9664"),textElement&&(textElement.textContent=TEXT_REMOVE),button.style.backgroundColor=COLOR_FAVORITED,button.style.borderColor=COLOR_FAVORITED,button.style.color="white"):(button.classList.remove("vfa-registered"),button.setAttribute("aria-pressed","fal
1se"),button.setAttribute("aria-label","\u304A\u6C17\u306B\u5165\u308A\u767B\u9332"),button.setAttribute("title","\u304A\u6C17\u306B\u5165\u308A\u767B\u9332"),textElement&&(textElement.textContent=TEXT_ADD),button.style.backgroundColor=COLOR_DEFAULT,button.style.borderColor=COLOR_DEFAULT,button.style.color=COLOR_DEFAULT);const svgIcon=button.querySelector(".vfa-store-favorite-icon svg");svgIcon&&(svgIcon.style.fill=isFavorited?"white":"#fa7283"),log("\u{1F504} \u5E97\u8217\u72B6\u614B\u66F4\u65B0:",button.dataset.shopName,isFavorited)}function showErrorMessage(message){const existingError=document.querySelector(".vfa-store-favorite-error");existingError&&existingError.remove();const errorDiv=document.createElement("div");errorDiv.className="vfa-store-favorite-error",errorDiv.textContent=message,errorDiv.style.cssText=` 2 position: fixed; 3 top: 20px; 4 left: 50%; 5 transform: translateX(-50%); 6 background-color: #ff4444; 7 color: white; 8 padding: 12px 24px; 9 border-radius: 4px; 10 z-index: 10000; 11 font-size: 14px; 12 box-shadow: 0 2px 8px rgba(0,0,0,0.2); 13 `,document.body.appendChild(errorDiv),setTimeout(()=>{errorDiv.remove()},3e3)}function initializeStoreFavoriteButtons(){const buttons=document.querySelectorAll(".vfa-add-to-favorite-shop");buttons.length!==0&&(log(`\u{1F4CD} \u5E97\u8217\u30DC\u30BF\u30F3 ${buttons.length}\u500B\u3092\u691C\u51FA`),buttons.forEach((button,index)=>{if(button.dataset.vfaInitialized==="true")return;const storeName=button.dataset.shopName,shopId=button.dataset.shopId;if(!storeName){log(`\u26A0\uFE0F \u5E97\u8217\u30DC\u30BF\u30F3${index+1}: \u5E97\u8217\u540D\uFF08data-shop-name\uFF09\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093`);return}log(`\u2705 \u5E97\u8217\u30DC\u30BF\u30F3${index+1}: "${storeName}" (ID: ${shopId||"\u306A\u3057"})`),button.dataset.vfaInitialized="true",checkStoreFavoriteStatus(storeName,button),button.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation(),toggleStoreFavorite(button)},!0)}))}function init(){console.log("[VFA Store Favorites] \u521D\u671F\u5316\u958B\u59CB"),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",initializeStoreFavoriteButtons):setTimeout(initializeStoreFavoriteButtons,100);let debounceTimer;new MutationObserver(()=>{clearTimeout(debounceTimer),debounceTimer=setTimeout(initializeStoreFavoriteButtons,500)}).observe(document.body,{childList:!0,subtree:!0})}init(),window.vfaStoreFavoriteDebug={reinit:initializeStoreFavoriteButtons,getButtons:()=>document.querySelectorAll('.vfa-add-to-favorite-shop[data-vfa-initialized="true"]'),checkStatus:storeName=>{const button=document.querySelector(`[data-shop-name="${storeName}"]`);button&&checkStoreFavoriteStatus(storeName,button)},listStores:()=>{const buttons=document.querySelectorAll(".vfa-add-to-favorite-shop");return Array.from(buttons).map(b=>({name:b.dataset.shopName,id:b.dataset.shopId,favorited:b.classList.contains("vfa-registered")}))}},log("\u{1F4E6} \u30C7\u30D0\u30C3\u30B0\u95A2\u6570\u304C\u5229\u7528\u53EF\u80FD: window.vfaStoreFavoriteDebug")})(); 14//# sourceMappingURL=/cdn/shop/t/302/assets/vfa-store-favorite.js.map?v=27051908861187864901772071598%3Fv%3D1790273830
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.