{
  "version": 3,
  "sources": ["/cdn/shop/t/20/assets/custom-availability-widget.js?v_custom=1.0.3"],
  "sourcesContent": ["/**\n * Custom Availability Widget\n * Replaces the Multi-Location Inventory app widget with a custom implementation\n * that shows inventory based on selected shipping method and location\n */\n\ntry {\n  console.log('[Custom Availability Widget] Script file loaded and executing...');\n} catch(e) {\n  console.error('[Custom Availability Widget] Error in initial check:', e);\n}\n\n(function() {\n  'use strict';\n  \n  try {\n    console.log('[Custom Availability Widget] IIFE starting...');\n  } catch(e) {\n    console.error('[Custom Availability Widget] Error in IIFE start:', e);\n  }\n\n  // Location details mapping (from header-location-selector.js)\n  var locationIdToDetails = {\n    43460657288: { name: \"Newberg Location (Critter Cabana)\", address1: \"516 E First St\", city: \"Newberg\", province: \"Oregon\", zip: \"97132\", phone: \"503-537-2570\", lat: 45.3000451, lng: -122.9741523 },\n    83963379929: { name: \"Salem Pet Supply (North)\", address1: \"3185 Market St NE\", city: \"Salem\", province: \"Oregon\", zip: \"97301\", phone: \"503-990-7455\", lat: 44.9511534, lng: -122.9964808 },\n    83963445465: { name: \"South Salem Pet Supply\", address1: \"4695 Commercial St SE\", city: \"Salem\", province: \"Oregon\", zip: \"97302\", phone: \"503-585-0553\", lat: 44.8867386, lng: -123.0345652 },\n    83963281625: { name: \"Tigard Pet Supply\", address1: \"16200 SW Pacific Hwy Suite W-W2\", city: \"Tigard\", province: \"Oregon\", zip: \"97224\", phone: \"503-339-2426\", lat: 45.4030263, lng: -122.7946112 },\n    42639884424: { name: \"Wilsonville Pet Supply\", address1: \"8406 SW Main St. #200\", city: \"Wilsonville\", province: \"Oregon\", zip: \"97070\", phone: \"503-682-9812\", lat: 45.302142, lng: -122.763612 },\n    85743730905: { name: \"Gresham Pet Supply\", address1: \"1152 Northwest Civic Drive\", city: \"Gresham\", province: \"Oregon\", zip: \"97030\", phone: \"503-666-1518\", lat: 45.505471, lng: -122.4408056 }\n  };\n\n  var widgetContainer = null;\n  var currentVariantId = null;\n  var inventoryData = null;\n  var isInitialized = false;\n  var isRendering = false; // Flag to prevent concurrent renders\n  var renderDebounceTimer = null; // Debounce timer\n  var lastRenderTime = 0; // Track last render time\n  var RENDER_DEBOUNCE_MS = 1000; // Minimum time between renders (1000ms - increased)\n  var lastRenderParams = null; // Track last render parameters to avoid duplicate renders\n  var renderCallCount = 0; // Track render calls to detect loops\n  var pageVariantId = null; // LOCKED variant ID for this page - prevents cross-product contamination\n  \n  /**\n   * Calculate distance between two coordinates using Haversine formula\n   * Returns distance in miles\n   */\n  function calculateDistance(lat1, lng1, lat2, lng2) {\n    var R = 3959; // Earth's radius in miles\n    var dLat = (lat2 - lat1) * Math.PI / 180;\n    var dLng = (lng2 - lng1) * Math.PI / 180;\n    var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +\n            Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) *\n            Math.sin(dLng / 2) * Math.sin(dLng / 2);\n    var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n    return R * c;\n  }\n  \n  /**\n   * Get user's delivery address coordinates\n   */\n  function getDeliveryCoordinates() {\n    try {\n      // Check localStorage for saved coordinates\n      var savedCoords = localStorage.getItem('deliveryCoordinates');\n      if (savedCoords) {\n        var coords = JSON.parse(savedCoords);\n        if (coords && coords.lat && coords.lng) {\n          return { lat: parseFloat(coords.lat), lng: parseFloat(coords.lng) };\n        }\n      }\n      \n      // Check window object (set by header-location-selector)\n      if (window.deliveryCoordinates && window.deliveryCoordinates.lat && window.deliveryCoordinates.lng) {\n        return {\n          lat: parseFloat(window.deliveryCoordinates.lat),\n          lng: parseFloat(window.deliveryCoordinates.lng)\n        };\n      }\n    } catch(e) {\n      console.warn('[Custom Availability Widget] Error getting delivery coordinates:', e);\n    }\n    return null;\n  }\n\n  /**\n   * Get current shipping method from state manager or localStorage\n   */\n  function getCurrentMethod() {\n    // Check multiple sources for the current method (in order of reliability)\n    \n    // 1. Check window.currentMethod (set by header-location-selector.js)\n    if (window.currentMethod) {\n      return window.currentMethod;\n    }\n    \n    // 2. Check StateManager\n    if (window.StateManager && window.StateManager.currentMethod) {\n      return window.StateManager.currentMethod;\n    }\n    \n    // 3. Check active button's data-method attribute (most reliable UI state)\n    var activeBtn = document.querySelector('.header-method-btn[data-active=\"true\"], .header-method-btn.active, .mobile-method-btn[data-active=\"true\"], .mobile-method-btn.active');\n    if (activeBtn) {\n      var method = activeBtn.getAttribute('data-method');\n      if (method) {\n        return method;\n      }\n    }\n    \n    // 4. Check if body has shipping mode class\n    if (document.body.classList.contains('shipping-mode-local')) {\n      return 'local_delivery'; // or 'pickup' - you may want to distinguish these\n    }\n    if (document.body.classList.contains('shipping-mode-shipping')) {\n      return 'shipping';\n    }\n    \n    // 5. Check localStorage\n    var saved = localStorage.getItem('shippingMethod');\n    if (saved) {\n      return saved;\n    }\n    \n    // Default to shipping\n    return 'shipping';\n  }\n\n  /**\n   * Get selected location ID\n   * Priority: forcedLocationId > Header text matching > inventoryInfo API > StateManager > localStorage\n   */\n  function getSelectedLocationId() {\n    // Check multiple sources for selected location ID\n    \n    // 1. Check forced location ID FIRST (set when location is selected but API call fails)\n    // This is the most reliable source when user just selected a location\n    if (window.forcedLocationId) {\n      var forcedId = window.forcedLocationId;\n      var parsedForcedId = typeof forcedId === 'number' ? forcedId : parseInt(forcedId, 10);\n      if (!isNaN(parsedForcedId)) {\n        console.log('[Custom Availability Widget] Got location ID from forcedLocationId (user just selected):', parsedForcedId);\n        return parsedForcedId;\n      }\n    }\n    \n    // 2. Try to match location name from header text to location IDs\n    // This is important when the API hasn't updated yet but the header shows the location\n    try {\n      var locationTextEl = document.querySelector('.location-picker-text, .location-picker-text-mobile');\n      if (locationTextEl) {\n        var locationName = locationTextEl.textContent.trim();\n        console.log('[Custom Availability Widget] Checking header location text:', locationName);\n        \n        // Skip if it's \"Online Warehouse\" or similar (shipping mode)\n        if (locationName && !locationName.match(/online|warehouse|shipping/i)) {\n          // Try to find matching location in inventoryInfo\n          if (window.inventoryInfo && window.inventoryInfo.locationSettings && window.inventoryInfo.locationSettings.details) {\n            for (var i = 0; i < window.inventoryInfo.locationSettings.details.length; i++) {\n              var loc = window.inventoryInfo.locationSettings.details[i];\n              // Match by exact name or partial match (e.g., \"Salem Pet Supply (North)\" matches \"North\")\n              if (loc.name && (loc.name.trim() === locationName || \n                  locationName.includes(loc.name.trim()) || \n                  loc.name.includes(locationName))) {\n                var matchedId = typeof loc.id === 'number' ? loc.id : parseInt(loc.id, 10);\n                if (!isNaN(matchedId)) {\n                  console.log('[Custom Availability Widget] Matched location from header text:', locationName, '->', loc.name, 'ID:', matchedId);\n                  return matchedId;\n                }\n              }\n            }\n          }\n        }\n      }\n    } catch(e) {\n      // Ignore errors\n    }\n    \n    // 3. Try to get from Multi-Location App API (may be stale if user just changed location)\n    if (window.inventoryInfo && window.inventoryInfo.api) {\n      try {\n        // Try getSelectedLocationId first (synchronous or async)\n        if (window.inventoryInfo.api.getSelectedLocationId) {\n          var locId = window.inventoryInfo.api.getSelectedLocationId();\n          // Handle promise if it returns one\n          if (locId && typeof locId.then === 'function') {\n            // Can't wait for promise here, return null and let async update handle it\n            return null;\n          }\n          if (locId !== null && locId !== undefined) {\n            var id = typeof locId === 'number' ? locId : parseInt(locId, 10);\n            if (!isNaN(id)) {\n              console.log('[Custom Availability Widget] Got location ID from API getSelectedLocationId:', id);\n              return id;\n            }\n          }\n        }\n        \n        // Try getSelectedLocation (returns full location object, might be async)\n        if (window.inventoryInfo.api.getSelectedLocation) {\n          try {\n            var locPromise = window.inventoryInfo.api.getSelectedLocation();\n            if (locPromise && typeof locPromise.then === 'function') {\n              // Async - can't wait here\n              return null;\n            } else if (locPromise && locPromise.id) {\n              var id = typeof locPromise.id === 'number' ? locPromise.id : parseInt(locPromise.id, 10);\n              if (!isNaN(id)) {\n                console.log('[Custom Availability Widget] Got location ID from API getSelectedLocation:', id);\n                return id;\n              }\n            }\n          } catch(e) {\n            // Ignore errors\n          }\n        }\n      } catch(e) {\n        // Ignore errors\n      }\n    }\n    \n    // 3. Try to match location name from header text to location IDs\n    // This is important when the API hasn't updated yet but the header shows the location\n    try {\n      var locationTextEl = document.querySelector('.location-picker-text, .location-picker-text-mobile');\n      if (locationTextEl) {\n        var locationName = locationTextEl.textContent.trim();\n        console.log('[Custom Availability Widget] Checking header location text:', locationName);\n        \n        // Skip if it's \"Online Warehouse\" or similar (shipping mode)\n        if (locationName && !locationName.match(/online|warehouse|shipping/i)) {\n          // Try to find matching location in inventoryInfo\n          if (window.inventoryInfo && window.inventoryInfo.locationSettings && window.inventoryInfo.locationSettings.details) {\n            for (var i = 0; i < window.inventoryInfo.locationSettings.details.length; i++) {\n              var loc = window.inventoryInfo.locationSettings.details[i];\n              // Match by exact name or partial match (e.g., \"Salem Pet Supply (North)\" matches \"North\")\n              if (loc.name && (loc.name.trim() === locationName || \n                  locationName.includes(loc.name.trim()) || \n                  loc.name.includes(locationName))) {\n                var matchedId = typeof loc.id === 'number' ? loc.id : parseInt(loc.id, 10);\n                if (!isNaN(matchedId)) {\n                  console.log('[Custom Availability Widget] Matched location from header text:', locationName, '->', loc.name, 'ID:', matchedId);\n                  return matchedId;\n                }\n              }\n            }\n          }\n        }\n      }\n    } catch(e) {\n      // Ignore errors\n    }\n    \n    // 3. Check StateManager (set by header location selector)\n    if (window.StateManager && window.StateManager.selectedLocationId) {\n      var stateId = window.StateManager.selectedLocationId;\n      var parsedId = typeof stateId === 'number' ? stateId : parseInt(stateId, 10);\n      if (!isNaN(parsedId)) {\n        console.log('[Custom Availability Widget] Got location ID from StateManager:', parsedId);\n        return parsedId;\n      }\n    }\n    \n    // 4. Check localStorage (fallback and for auto-selection)\n    try {\n      var saved = localStorage.getItem('selectedLocationId');\n      if (saved) {\n        var savedId = parseInt(saved, 10);\n        if (!isNaN(savedId)) {\n          console.log('[Custom Availability Widget] Got location ID from localStorage:', savedId);\n          return savedId;\n        }\n      }\n    } catch(e) {\n      // Storage might be blocked\n    }\n    \n    console.log('[Custom Availability Widget] No selected location ID found');\n    return null;\n  }\n  \n  /**\n   * Auto-select the last selected location/method on page load\n   */\n  function autoSelectLastSelection() {\n    try {\n      // Get last selected method\n      var lastMethod = localStorage.getItem('lastSelectedMethod');\n      if (lastMethod && (lastMethod === 'local_delivery' || lastMethod === 'local_pickup')) {\n        console.log('[Custom Availability Widget] Auto-selecting last method:', lastMethod);\n        \n        // Set the method\n        if (window.StateManager && window.StateManager.setMethod) {\n          window.StateManager.setMethod(lastMethod);\n        }\n        window.currentMethod = lastMethod;\n        \n        // Also save to the key that header-location-selector.js uses\n        try {\n          if (window.StorageManager && window.StorageManager.setLocalStorage) {\n            window.StorageManager.setLocalStorage('shippingMethod', lastMethod);\n          } else {\n            localStorage.setItem('shippingMethod', lastMethod);\n          }\n        } catch(e) {\n          // Storage might be blocked\n        }\n        \n        // Update the header buttons to show the correct selected state\n        setTimeout(function() {\n          // Update desktop buttons\n          var headerMethodSelector = document.querySelector('.header-method-selector');\n          if (headerMethodSelector) {\n            var buttons = headerMethodSelector.querySelectorAll('.header-method-btn');\n            buttons.forEach(function(btn) {\n              var isActive = btn.getAttribute('data-method') === lastMethod;\n              if (isActive) {\n                btn.style.borderColor = '#298029';\n                btn.style.backgroundColor = '#f0f8f0';\n                btn.style.color = '#298029';\n                btn.style.fontWeight = '500';\n                btn.setAttribute('data-active', 'true');\n                btn.classList.add('active');\n              } else {\n                btn.style.borderColor = '#d0d0d0';\n                btn.style.backgroundColor = '#ffffff';\n                btn.style.color = '#293149';\n                btn.style.fontWeight = '400';\n                btn.removeAttribute('data-active');\n                btn.classList.remove('active');\n              }\n            });\n          }\n          \n          // Update mobile buttons\n          var mobileSelector = document.querySelector('.mobile-method-selector');\n          if (mobileSelector) {\n            var mobileButtons = mobileSelector.querySelectorAll('.mobile-method-btn');\n            mobileButtons.forEach(function(btn) {\n              var isActive = btn.getAttribute('data-method') === lastMethod;\n              if (isActive) {\n                btn.style.borderColor = '#298029';\n                btn.style.backgroundColor = '#f0f8f0';\n                btn.style.color = '#298029';\n                btn.style.fontWeight = '500';\n                btn.setAttribute('data-active', 'true');\n                btn.classList.add('active');\n              } else {\n                btn.style.borderColor = '#d0d0d0';\n                btn.style.backgroundColor = '#ffffff';\n                btn.style.color = '#293149';\n                btn.style.fontWeight = '400';\n                btn.removeAttribute('data-active');\n                btn.classList.remove('active');\n              }\n            });\n          }\n          \n          // Also call updateActiveButton if it exists\n          if (typeof updateActiveButton === 'function') {\n            updateActiveButton();\n          }\n        }, 100);\n        \n        // Get last selected location ID\n        var lastLocationId = localStorage.getItem('lastSelectedLocationId');\n        if (lastLocationId) {\n          var locId = parseInt(lastLocationId, 10);\n          if (!isNaN(locId) && window.inventoryInfo && window.inventoryInfo.api && window.inventoryInfo.api.selectLocation) {\n            console.log('[Custom Availability Widget] Auto-selecting last location:', locId);\n            // Select the location via API\n            window.inventoryInfo.api.selectLocation(locId).then(function() {\n              console.log('[Custom Availability Widget] Successfully auto-selected location:', locId);\n              // Trigger widget update\n              setTimeout(function() {\n                if (window.customAvailabilityWidget && typeof window.customAvailabilityWidget.render === 'function') {\n                  window.customAvailabilityWidget.render();\n                }\n              }, 300);\n            }).catch(function(err) {\n              console.warn('[Custom Availability Widget] Failed to auto-select location:', err);\n            });\n          }\n        }\n      } else if (lastMethod === 'shipping') {\n        // For shipping, just set the method\n        if (window.StateManager && window.StateManager.setMethod) {\n          window.StateManager.setMethod('shipping');\n        }\n        window.currentMethod = 'shipping';\n        \n        // Update the header buttons\n        setTimeout(function() {\n          var headerMethodSelector = document.querySelector('.header-method-selector');\n          if (headerMethodSelector) {\n            var buttons = headerMethodSelector.querySelectorAll('.header-method-btn');\n            buttons.forEach(function(btn) {\n              var isActive = btn.getAttribute('data-method') === 'shipping';\n              if (isActive) {\n                btn.style.borderColor = '#298029';\n                btn.style.backgroundColor = '#f0f8f0';\n                btn.style.color = '#298029';\n                btn.style.fontWeight = '500';\n                btn.setAttribute('data-active', 'true');\n                btn.classList.add('active');\n              } else {\n                btn.style.borderColor = '#d0d0d0';\n                btn.style.backgroundColor = '#ffffff';\n                btn.style.color = '#293149';\n                btn.style.fontWeight = '400';\n                btn.removeAttribute('data-active');\n                btn.classList.remove('active');\n              }\n            });\n          }\n          \n          var mobileSelector = document.querySelector('.mobile-method-selector');\n          if (mobileSelector) {\n            var mobileButtons = mobileSelector.querySelectorAll('.mobile-method-btn');\n            mobileButtons.forEach(function(btn) {\n              var isActive = btn.getAttribute('data-method') === 'shipping';\n              if (isActive) {\n                btn.style.borderColor = '#298029';\n                btn.style.backgroundColor = '#f0f8f0';\n                btn.style.color = '#298029';\n                btn.style.fontWeight = '500';\n                btn.setAttribute('data-active', 'true');\n                btn.classList.add('active');\n              } else {\n                btn.style.borderColor = '#d0d0d0';\n                btn.style.backgroundColor = '#ffffff';\n                btn.style.color = '#293149';\n                btn.style.fontWeight = '400';\n                btn.removeAttribute('data-active');\n                btn.classList.remove('active');\n              }\n            });\n          }\n          \n          if (typeof updateActiveButton === 'function') {\n            updateActiveButton();\n          }\n        }, 100);\n      }\n    } catch(e) {\n      console.warn('[Custom Availability Widget] Error in autoSelectLastSelection:', e);\n    }\n  }\n  \n  /**\n   * Save the current selection to localStorage for auto-selection next time\n   */\n  function saveCurrentSelection() {\n    try {\n      var currentMethod = window.currentMethod || 'shipping';\n      localStorage.setItem('lastSelectedMethod', currentMethod);\n      \n      // Also save to the key that header-location-selector.js uses\n      try {\n        if (window.StorageManager && window.StorageManager.setLocalStorage) {\n          window.StorageManager.setLocalStorage('shippingMethod', currentMethod);\n        } else {\n          localStorage.setItem('shippingMethod', currentMethod);\n        }\n      } catch(e) {\n        // Storage might be blocked\n      }\n      \n      var selectedLocationId = getSelectedLocationId();\n      if (selectedLocationId) {\n        localStorage.setItem('lastSelectedLocationId', selectedLocationId.toString());\n        console.log('[Custom Availability Widget] Saved selection - Method:', currentMethod, 'Location:', selectedLocationId);\n      }\n    } catch(e) {\n      // Storage might be blocked\n    }\n  }\n\n  /**\n   * Get current variant ID from the page\n   */\n  function getCurrentVariantId() {\n    // If we already locked a variant for this page, always return it\n    // This prevents cross-product contamination when header-location-selector reinitializes\n    if (pageVariantId) {\n      return pageVariantId;\n    }\n    \n    // Try multiple methods to get variant ID\n    var variantId = null;\n    \n    // Method 1: Check for variant selector\n    var variantSelect = document.querySelector('[name=\"id\"], select[name*=\"variant\"], input[name=\"id\"][type=\"hidden\"]');\n    if (variantSelect) {\n      variantId = variantSelect.value;\n    }\n    \n    // Method 2: Check for data attributes\n    if (!variantId) {\n      var productForm = document.querySelector('form[action*=\"/cart/add\"]');\n      if (productForm) {\n        var hiddenInput = productForm.querySelector('input[name=\"id\"][type=\"hidden\"]');\n        if (hiddenInput) {\n          variantId = hiddenInput.value;\n        }\n      }\n    }\n    \n    // Method 3: Check URL parameters\n    if (!variantId && window.location.search) {\n      var params = new URLSearchParams(window.location.search);\n      variantId = params.get('variant');\n    }\n    \n    // Method 4: Check Shopify global meta analytics (critical fallback when product form is hidden due to sold-out status)\n    if (!variantId && window.meta && window.meta.product && window.meta.product.variants && window.meta.product.variants[0]) {\n      variantId = window.meta.product.variants[0].id;\n    }\n    \n    // Method 5: Check ShopifyAnalytics global meta\n    if (!variantId && window.ShopifyAnalytics && window.ShopifyAnalytics.meta && window.ShopifyAnalytics.meta.product && window.ShopifyAnalytics.meta.product.variants && window.ShopifyAnalytics.meta.product.variants[0]) {\n      variantId = window.ShopifyAnalytics.meta.product.variants[0].id;\n    }\n    \n    var result = variantId ? parseInt(variantId, 10) : null;\n    \n    // Lock this variant for the lifetime of the page\n    if (result) {\n      pageVariantId = result;\n      console.log('[Custom Availability Widget] Locked page variant ID:', pageVariantId);\n    }\n    \n    return result;\n  }\n\n  /**\n   * Fetch inventory data for a variant from Shopify API\n   */\n  function fetchVariantInventory(variantId) {\n    if (!variantId) {\n      console.warn('[Custom Availability Widget] No variant ID provided');\n      return Promise.resolve(null);\n    }\n\n    return fetch('/variants/' + variantId + '.js')\n      .then(function(response) {\n        if (!response.ok) {\n          throw new Error('Failed to fetch variant: ' + response.status);\n        }\n        return response.json();\n      })\n      .then(function(variant) {\n        console.log('[Custom Availability Widget] Variant data:', variant);\n        \n        // Extract inventory information\n        var inventory = {\n          variantId: variant.id,\n          available: variant.available,\n          inventoryQuantity: variant.inventory_quantity || 0,\n          inventoryManagement: variant.inventory_management,\n          inventoryPolicy: variant.inventory_policy,\n          inventoryItemId: variant.inventory_item_id // This is the key to getting per-location inventory\n        };\n        \n        console.log('[Custom Availability Widget] Extracted inventory:', inventory);\n        console.log('[Custom Availability Widget] Inventory Item ID:', inventory.inventoryItemId);\n        \n        // If we have inventory_item_id, try to fetch per-location inventory levels\n        if (inventory.inventoryItemId) {\n          // Note: This requires Admin API access, which frontend doesn't have\n          // But we can try using the product JSON endpoint which might include location data\n          // Or use the Multi-Location App's data if available\n          console.log('[Custom Availability Widget] Found inventory_item_id, but cannot fetch inventory_levels from frontend (requires Admin API)');\n        }\n        \n        return inventory;\n      })\n      .catch(function(error) {\n        console.error('[Custom Availability Widget] Error fetching variant inventory:', error);\n        return null;\n      });\n  }\n  \n  /**\n   * Fetch inventory levels for all locations using Shopify's product JSON endpoint\n   * This endpoint may include location-specific inventory if available\n   */\n  function fetchProductInventoryLevels(productId, variantId) {\n    if (!productId) {\n      console.warn('[Custom Availability Widget] No product ID provided');\n      return Promise.resolve([]);\n    }\n    \n    console.log('[Custom Availability Widget] Fetching product inventory levels for product:', productId);\n    \n    return fetch('/products/' + productId + '.js')\n      .then(function(response) {\n        if (!response.ok) {\n          throw new Error('Failed to fetch product: ' + response.status);\n        }\n        return response.json();\n      })\n      .then(function(product) {\n        console.log('[Custom Availability Widget] Product data:', product);\n        \n        // Find the variant we're looking for\n        var variant = product.variants.find(function(v) {\n          return v.id === variantId;\n        });\n        \n        if (!variant) {\n          console.warn('[Custom Availability Widget] Variant not found in product');\n          return [];\n        }\n        \n        console.log('[Custom Availability Widget] Variant from product:', variant);\n        console.log('[Custom Availability Widget] Variant inventory_item_id:', variant.inventory_item_id);\n        \n        // The product JSON endpoint doesn't include per-location inventory levels\n        // We need to use a different approach - either:\n        // 1. Use the Multi-Location App's API (if available)\n        // 2. Extract from the app's widget DOM\n        // 3. Use Shopify's Storefront API GraphQL (requires authentication)\n        \n        return [];\n      })\n      .catch(function(error) {\n        console.error('[Custom Availability Widget] Error fetching product inventory levels:', error);\n        return [];\n      });\n  }\n  \n  /**\n   * Fetch inventory levels from backend proxy endpoint\n   * This endpoint uses Admin API to get per-location inventory\n   */\n  function fetchInventoryLevelsFromBackend(variantId) {\n    console.log('[Custom Availability Widget] Attempting to fetch inventory levels from backend for variant:', variantId);\n    \n    // Try multiple backend URL options\n    // Option 1: Shopify app proxy (if configured) - add timestamp cache-buster to prevent Shopify CDN caching\n    var appProxyUrl = '/apps/inventory/inventory-levels?variant_id=' + variantId + '&t=' + Date.now();\n    \n    // Option 2: Direct API path (if backend is on same domain) - add timestamp cache-buster\n    var directApiUrl = '/api/inventory-levels?variant_id=' + variantId + '&t=' + Date.now();\n    \n    // Option 3: Full URL to Flask backend (update this with your actual backend URL)\n    // TODO: Replace with your actual Flask backend URL\n    // Examples:\n    // - If Flask is on fiji server: 'http://fiji:8000/api/inventory-levels?variant_id=' + variantId\n    // - If Flask is publicly accessible: 'https://your-domain.com/api/inventory-levels?variant_id=' + variantId\n    // - If using ngrok or similar: 'https://your-ngrok-url.ngrok.io/api/inventory-levels?variant_id=' + variantId\n    var backendBaseUrl = window.BACKEND_API_URL || ''; // Can be set via script tag or global variable\n    // Also check for common variable names\n    if (!backendBaseUrl && window.backendApiUrl) {\n      backendBaseUrl = window.backendApiUrl;\n    }\n    if (!backendBaseUrl && typeof BACKEND_API_URL !== 'undefined') {\n      backendBaseUrl = BACKEND_API_URL;\n    }\n    // Default fallback to api.cascadepetsupply.com if not set\n    if (!backendBaseUrl) {\n      backendBaseUrl = 'https://api.cascadepetsupply.com';\n      console.log('[Custom Availability Widget] window.BACKEND_API_URL not set, using default:', backendBaseUrl);\n    }\n    var fullBackendUrl = backendBaseUrl ? (backendBaseUrl + '/api/inventory-levels?variant_id=' + variantId + '&t=' + Date.now()) : null;\n    \n    console.log('[Custom Availability Widget] Backend URLs - appProxy:', appProxyUrl, 'direct:', directApiUrl, 'full:', fullBackendUrl);\n    console.log('[Custom Availability Widget] window.BACKEND_API_URL:', window.BACKEND_API_URL);\n    \n    // If we have a full backend URL, try it FIRST (most reliable, bypasses app proxy issues)\n    if (fullBackendUrl) {\n      console.log('[Custom Availability Widget] Trying full backend URL first:', fullBackendUrl);\n      return fetch(fullBackendUrl)\n        .then(function(response) {\n          if (response.ok) {\n            console.log('[Custom Availability Widget] \u2713\u2713\u2713 SUCCESS: Got inventory from full backend URL');\n            return response.json();\n          }\n          console.log('[Custom Availability Widget] Full backend URL failed (' + response.status + '), trying app proxy as fallback...');\n          // Fall through to try app proxy\n          return fetch(appProxyUrl);\n        })\n        .catch(function(error) {\n          console.log('[Custom Availability Widget] Full backend URL error:', error.message, '- trying app proxy as fallback...');\n          return fetch(appProxyUrl);\n        });\n    }\n    \n    // Try app proxy first (if no full URL available), but if it fails (404 or 500), immediately try direct API\n    return fetch(appProxyUrl)\n      .then(function(response) {\n        if (response.ok) {\n          console.log('[Custom Availability Widget] Got inventory from app proxy');\n          return response.json();\n        }\n        // If app proxy returns 404 or 500, try direct API path\n        if (response.status === 404 || response.status === 500) {\n          console.log('[Custom Availability Widget] App proxy failed (' + response.status + '), trying direct API path...');\n          return fetch(directApiUrl);\n        }\n        throw new Error('App proxy returned: ' + response.status);\n      })\n      .then(function(response) {\n        // Handle response from direct API or continue from app proxy\n        if (response && typeof response.json === 'function') {\n          // This is a Response object, need to parse JSON\n          if (!response.ok) {\n            if (response.status === 404) {\n              console.log('[Custom Availability Widget] Direct API path not found (404)');\n              // Try full backend URL if available\n              if (fullBackendUrl) {\n                console.log('[Custom Availability Widget] Trying full backend URL:', fullBackendUrl);\n                return fetch(fullBackendUrl)\n                  .then(function(r) {\n                    if (!r.ok) {\n                      console.log('[Custom Availability Widget] Full backend URL failed:', r.status);\n                      return null;\n                    }\n                    return r.json();\n                  })\n                  .catch(function(e) {\n                    console.log('[Custom Availability Widget] Full backend URL error:', e.message);\n                    return null;\n                  });\n              }\n              return null;\n            }\n            throw new Error('Failed to fetch inventory levels: ' + response.status);\n          }\n          return response.json();\n        }\n        // Already parsed JSON\n        return response;\n      })\n      .catch(function(error) {\n        console.log('[Custom Availability Widget] App proxy and direct API failed:', error.message);\n        // If both relative paths fail, try full backend URL if available\n        if (fullBackendUrl) {\n          console.log('[Custom Availability Widget] Trying full backend URL after error:', fullBackendUrl);\n          return fetch(fullBackendUrl)\n            .then(function(response) {\n              if (!response.ok) {\n                console.log('[Custom Availability Widget] Full backend URL failed:', response.status);\n                return null;\n              }\n              return response.json();\n            })\n            .catch(function(e) {\n              console.log('[Custom Availability Widget] Full backend URL error:', e.message);\n              return null;\n            });\n        }\n        // All methods failed\n        console.log('[Custom Availability Widget] All backend API methods failed:', error.message);\n        return null; // Return null instead of throwing to allow fallback\n      })\n      .then(function(data) {\n        if (data && data.inventory_levels && Array.isArray(data.inventory_levels)) {\n          console.log('[Custom Availability Widget] Got inventory levels from backend:', data.inventory_levels);\n          var inventory = data.inventory_levels.map(function(level) {\n            var locId = level.location_id || level.locationId;\n            // Use quantity if available, otherwise use available field, default to 0\n            var qty = level.quantity !== undefined ? level.quantity : (level.available !== undefined ? level.available : 0);\n            var locName = locationIdToDetails[locId] ? locationIdToDetails[locId].name : (level.location_name || level.locationName || 'Location ' + locId);\n            return {\n              locationId: locId,\n              locationName: locName,\n              quantity: qty,\n              available: qty > 0\n            };\n          });\n          console.log('[Custom Availability Widget] ===== INVENTORY FROM BACKEND =====');\n          inventory.forEach(function(loc) {\n            console.log('[Custom Availability Widget]', loc.locationName, '(ID:', loc.locationId, ') - Qty:', loc.quantity, 'Available:', loc.available);\n          });\n          console.log('[Custom Availability Widget] =================================');\n          // Return the data object with inventory_levels array for consistency\n          return {\n            inventory_levels: inventory\n          };\n        }\n        return null;\n      })\n      .catch(function(error) {\n        // Endpoint doesn't exist, that's fine - we'll use other methods\n        console.log('[Custom Availability Widget] Backend inventory endpoint not available:', error.message);\n        return null;\n      });\n  }\n\n  /**\n   * Create the widget HTML structure\n   */\n  function createWidgetHTML() {\n    var widget = document.createElement('div');\n    widget.id = 'custom-availability-widget';\n    widget.className = 'custom-availability-widget';\n    widget.innerHTML = `\n      <div class=\"custom-availability-header\">\n        <label class=\"custom-availability-title\">Availability</label>\n      </div>\n      <div class=\"custom-availability-content\">\n        <div class=\"custom-availability-loading\" style=\"display: none;\">\n          <span>Loading availability...</span>\n        </div>\n        <div class=\"custom-availability-info\">\n          <!-- Content will be populated dynamically -->\n        </div>\n      </div>\n    `;\n    return widget;\n  }\n\n  /**\n   * Render availability information based on shipping method\n   */\n  function renderAvailability() {\n    // Prevent concurrent renders\n    if (isRendering) {\n      console.log('[Custom Availability Widget] Already rendering, skipping...');\n      return;\n    }\n    \n    // Get current state to check if anything actually changed\n    var variantId = getCurrentVariantId();\n    var currentMethod = getCurrentMethod();\n    var selectedLocationId = getSelectedLocationId();\n    var currentParams = variantId + '|' + currentMethod + '|' + selectedLocationId;\n    \n    // Check if this is a duplicate render with same parameters\n    if (currentParams === lastRenderParams) {\n      console.log('[Custom Availability Widget] Duplicate render request with same parameters, skipping...');\n      return;\n    }\n    \n    // Debounce rapid calls\n    var now = Date.now();\n    if (now - lastRenderTime < RENDER_DEBOUNCE_MS) {\n      console.log('[Custom Availability Widget] Render debounced, scheduling delayed render...');\n      if (renderDebounceTimer) {\n        clearTimeout(renderDebounceTimer);\n      }\n      renderDebounceTimer = setTimeout(function() {\n        renderDebounceTimer = null;\n        renderAvailability();\n      }, RENDER_DEBOUNCE_MS - (now - lastRenderTime));\n      return;\n    }\n    \n    // Detect potential infinite loop (more than 10 renders in 5 seconds)\n    renderCallCount++;\n    if (renderCallCount > 10) {\n      console.error('[Custom Availability Widget] Potential infinite loop detected! Stopping renders.');\n      setTimeout(function() {\n        renderCallCount = 0; // Reset after 5 seconds\n      }, 5000);\n      return;\n    }\n    \n    isRendering = true;\n    lastRenderTime = now;\n    lastRenderParams = currentParams; // Store current params\n    \n    if (!widgetContainer) {\n      console.warn('[Custom Availability Widget] Widget container not found, attempting to initialize...');\n      initWidget();\n      if (!widgetContainer) {\n        console.error('[Custom Availability Widget] Failed to initialize widget');\n        isRendering = false;\n        return;\n      }\n    }\n    \n    var contentArea = widgetContainer.querySelector('.custom-availability-info');\n    var loadingArea = widgetContainer.querySelector('.custom-availability-loading');\n    \n    if (!contentArea) {\n      console.error('[Custom Availability Widget] Content area not found');\n      isRendering = false;\n      return;\n    }\n    \n    // Already got these above, reuse them\n    // var currentMethod = getCurrentMethod();\n    // var selectedLocationId = getSelectedLocationId();\n    \n    console.log('[Custom Availability Widget] Rendering - Method:', currentMethod, 'Location ID:', selectedLocationId, 'Variant:', variantId);\n    \n    // Show loading state\n    if (loadingArea) loadingArea.style.display = 'block';\n    contentArea.innerHTML = '';\n    \n    // Fetch inventory if we have a variant\n    var variantId = getCurrentVariantId();\n    if (!variantId) {\n      if (loadingArea) loadingArea.style.display = 'none';\n      contentArea.innerHTML = '<div class=\"custom-availability-message\">Select a variant to see availability</div>';\n      isRendering = false;\n      return;\n    }\n    \n    // If variant changed, fetch new inventory\n    if (variantId !== currentVariantId) {\n      currentVariantId = variantId;\n      inventoryData = null;\n    }\n    \n    // Fetch inventory data\n    var fetchPromise = inventoryData \n      ? Promise.resolve(inventoryData)\n      : fetchVariantInventory(variantId).then(function(data) {\n          inventoryData = data;\n          return data;\n        });\n    \n    fetchPromise.then(function(inventory) {\n      if (loadingArea) loadingArea.style.display = 'none';\n      \n      if (!inventory) {\n        contentArea.innerHTML = '<div class=\"custom-availability-message\">Unable to load availability</div>';\n        isRendering = false;\n        return;\n      }\n      \n      var html = '';\n      \n      console.log('[Custom Availability Widget] Current method:', currentMethod, 'Selected location:', selectedLocationId);\n      \n      if (currentMethod === 'shipping') {\n        // Shipping mode: Show aggregated inventory from all locations\n        html = renderShippingAvailability(inventory);\n      } else {\n        // Local delivery or pickup: Show all locations with their availability\n        html = renderLocationAvailability(inventory, selectedLocationId);\n      }\n      \n      contentArea.innerHTML = html;\n      isRendering = false; // Reset flag after successful render\n    }).catch(function(error) {\n      console.error('[Custom Availability Widget] Error rendering availability:', error);\n      if (loadingArea) loadingArea.style.display = 'none';\n      contentArea.innerHTML = '<div class=\"custom-availability-message\">Error loading availability</div>';\n      isRendering = false; // Reset flag after error\n    });\n  }\n\n  /**\n   * Fetch aggregated inventory from all locations\n   */\n  function fetchAggregatedInventory(variantId) {\n    console.log('[Custom Availability Widget] fetchAggregatedInventory called for variant:', variantId);\n    \n    // Try backend API first to get per-location inventory\n    return fetchInventoryLevelsFromBackend(variantId)\n      .then(function(backendResult) {\n        if (backendResult && backendResult.inventory_levels && Array.isArray(backendResult.inventory_levels) && backendResult.inventory_levels.length > 0) {\n          console.log('[Custom Availability Widget] Got inventory from backend for aggregated:', backendResult.inventory_levels.length, 'locations');\n          // Sum up quantities from all locations\n          var totalQuantity = 0;\n          var hasInventory = false;\n          \n          backendResult.inventory_levels.forEach(function(level) {\n            var qty = level.quantity || level.available || 0;\n            if (qty > 0) {\n              hasInventory = true;\n            }\n            totalQuantity += qty;\n          });\n          \n          console.log('[Custom Availability Widget] Aggregated total quantity:', totalQuantity);\n          return {\n            totalQuantity: totalQuantity,\n            hasInventory: hasInventory,\n            available: totalQuantity > 0 || hasInventory\n          };\n        }\n        \n        // Backend API didn't return data, try Multi-Location App API\n        console.log('[Custom Availability Widget] Backend API returned no data, trying app API...');\n        if (window.inventoryInfo && window.inventoryInfo.api) {\n          // Try getProductInventory which should return all locations\n          if (window.inventoryInfo.api.getProductInventory && typeof window.inventoryInfo.api.getProductInventory === 'function') {\n            return window.inventoryInfo.api.getProductInventory(variantId)\n              .then(function(result) {\n                if (result && result.locations) {\n                  // Sum up quantities from all locations\n                  var totalQuantity = 0;\n                  var hasInventory = false;\n                  \n                  result.locations.forEach(function(loc) {\n                    var qty = loc.quantity || loc.available || 0;\n                    if (qty > 0) {\n                      hasInventory = true;\n                    }\n                    totalQuantity += qty;\n                  });\n                  \n                  return {\n                    totalQuantity: totalQuantity,\n                    hasInventory: hasInventory,\n                    available: totalQuantity > 0 || hasInventory\n                  };\n                }\n                return null;\n              })\n              .catch(function(error) {\n                console.warn('[Custom Availability Widget] Error fetching aggregated inventory from app:', error);\n                return null;\n              });\n          }\n          \n          // Fallback: Try to get inventory for each location individually\n          if (window.inventoryInfo.locationSettings && window.inventoryInfo.locationSettings.details) {\n            var locationIds = window.inventoryInfo.locationSettings.details.map(function(loc) {\n              return loc.id;\n            });\n            \n            var fetchPromises = locationIds.map(function(locId) {\n              if (window.inventoryInfo.api.getVariantAvailability && typeof window.inventoryInfo.api.getVariantAvailability === 'function') {\n                return window.inventoryInfo.api.getVariantAvailability(variantId, locId)\n                  .then(function(result) {\n                    return result && result.quantity ? result.quantity : 0;\n                  })\n                  .catch(function() {\n                    return 0;\n                  });\n              }\n              return Promise.resolve(0);\n            });\n            \n            return Promise.all(fetchPromises).then(function(quantities) {\n              var totalQuantity = quantities.reduce(function(sum, qty) {\n                return sum + (qty || 0);\n              }, 0);\n              \n              return {\n                totalQuantity: totalQuantity,\n                hasInventory: totalQuantity > 0,\n                available: totalQuantity > 0\n              };\n            }).catch(function(error) {\n              console.warn('[Custom Availability Widget] Error fetching location inventories:', error);\n              return null;\n            });\n          }\n        }\n        \n        // No data from any source, return null to use fallback\n        console.warn('[Custom Availability Widget] No inventory data available from any source');\n        return null;\n      })\n      .catch(function(error) {\n        console.warn('[Custom Availability Widget] Error in fetchAggregatedInventory:', error);\n        return null;\n      });\n  }\n\n  /**\n   * Render availability for shipping mode (aggregated)\n   */\n  function renderShippingAvailability(inventory) {\n    console.log('[Custom Availability Widget] ===== RENDER SHIPPING AVAILABILITY =====');\n    console.log('[Custom Availability Widget] Inventory data:', inventory);\n    \n    var html = '<div class=\"custom-availability-shipping\">';\n    var variantId = getCurrentVariantId();\n    console.log('[Custom Availability Widget] Variant ID for shipping:', variantId);\n    \n    // Try to fetch aggregated inventory from all locations\n    if (variantId) {\n      console.log('[Custom Availability Widget] Calling fetchAggregatedInventory...');\n      fetchAggregatedInventory(variantId).then(function(aggregated) {\n        console.log('[Custom Availability Widget] fetchAggregatedInventory returned:', aggregated);\n        var contentArea = widgetContainer.querySelector('.custom-availability-info');\n        if (!contentArea) return;\n        \n        var shippingHtml = '<div class=\"custom-availability-shipping\">';\n        \n        if (aggregated && aggregated.totalQuantity !== undefined) {\n          // Use aggregated inventory\n          if (aggregated.totalQuantity > 0) {\n            shippingHtml += '<div class=\"custom-availability-status in-stock\">';\n            shippingHtml += '<span class=\"custom-availability-label\">Online Warehouse</span>';\n            shippingHtml += '<span class=\"custom-availability-qty\"><strong>' + aggregated.totalQuantity + ' available</strong></span>';\n            shippingHtml += '</div>';\n          } else {\n            shippingHtml += '<div class=\"custom-availability-status out-of-stock\">';\n            shippingHtml += '<span class=\"custom-availability-label\">Online Warehouse</span>';\n            shippingHtml += '<span class=\"custom-availability-qty\"><strong>Out of stock</strong></span>';\n            shippingHtml += '</div>';\n          }\n        } else {\n          // Fallback to general inventory\n          if (inventory.inventoryManagement === 'shopify' && inventory.inventoryQuantity !== null) {\n            if (inventory.inventoryQuantity > 0) {\n              shippingHtml += '<div class=\"custom-availability-status in-stock\">';\n              shippingHtml += '<span class=\"custom-availability-label\">Online Warehouse</span>';\n              shippingHtml += '<span class=\"custom-availability-qty\"><strong>' + inventory.inventoryQuantity + ' available</strong></span>';\n              shippingHtml += '</div>';\n            } else {\n              shippingHtml += '<div class=\"custom-availability-status out-of-stock\">';\n              shippingHtml += '<span class=\"custom-availability-label\">Online Warehouse</span>';\n              shippingHtml += '<span class=\"custom-availability-qty\"><strong>Out of stock</strong></span>';\n              shippingHtml += '</div>';\n            }\n          } else {\n            if (inventory.available) {\n              shippingHtml += '<div class=\"custom-availability-status in-stock\">';\n              shippingHtml += '<span class=\"custom-availability-label\">Online Warehouse</span>';\n              shippingHtml += '<span class=\"custom-availability-qty\"><strong>In stock</strong></span>';\n              shippingHtml += '</div>';\n            } else {\n              shippingHtml += '<div class=\"custom-availability-status out-of-stock\">';\n              shippingHtml += '<span class=\"custom-availability-label\">Online Warehouse</span>';\n              shippingHtml += '<span class=\"custom-availability-qty\"><strong>Out of stock</strong></span>';\n              shippingHtml += '</div>';\n            }\n          }\n        }\n        \n        shippingHtml += '</div>';\n        console.log('[Custom Availability Widget] Updating content area with shipping HTML');\n        contentArea.innerHTML = shippingHtml;\n        console.log('[Custom Availability Widget] ===== SHIPPING AVAILABILITY RENDERED =====');\n      }).catch(function(error) {\n        console.error('[Custom Availability Widget] Error in fetchAggregatedInventory promise:', error);\n        console.error('[Custom Availability Widget] Error stack:', error.stack);\n      });\n    } else {\n      console.warn('[Custom Availability Widget] No variantId available for fetchAggregatedInventory');\n    }\n    \n    // Show initial state while fetching\n    if (inventory.inventoryManagement === 'shopify' && inventory.inventoryQuantity !== null) {\n      if (inventory.inventoryQuantity > 0) {\n        html += '<div class=\"custom-availability-status in-stock\">';\n        html += '<span class=\"custom-availability-label\">Online Warehouse</span>';\n        html += '<span class=\"custom-availability-qty\"><strong>' + inventory.inventoryQuantity + ' available</strong></span>';\n        html += '</div>';\n      } else {\n        html += '<div class=\"custom-availability-status out-of-stock\">';\n        html += '<span class=\"custom-availability-label\">Online Warehouse</span>';\n        html += '<span class=\"custom-availability-qty\">Out of stock</span>';\n        html += '</div>';\n      }\n    } else {\n      if (inventory.available) {\n        html += '<div class=\"custom-availability-status in-stock\">';\n        html += '<span class=\"custom-availability-label\">Online Warehouse</span>';\n        html += '<span class=\"custom-availability-qty\"><strong>In stock</strong></span>';\n        html += '</div>';\n      } else {\n        html += '<div class=\"custom-availability-status out-of-stock\">';\n        html += '<span class=\"custom-availability-label\">Online Warehouse</span>';\n        html += '<span class=\"custom-availability-qty\">Out of stock</span>';\n        html += '</div>';\n      }\n    }\n    \n    html += '</div>';\n    return html;\n  }\n\n  /**\n   * Fetch location-specific inventory from Multi-Location App API\n   */\n  function fetchLocationInventory(variantId, locationId) {\n    if (!window.inventoryInfo || !window.inventoryInfo.api) {\n      return Promise.resolve(null);\n    }\n    \n    // Try to use the Multi-Location App's API\n    if (window.inventoryInfo.api.getVariantAvailability) {\n      return window.inventoryInfo.api.getVariantAvailability(variantId, locationId)\n        .then(function(result) {\n          return result;\n        })\n        .catch(function(error) {\n          console.warn('[Custom Availability Widget] Error fetching location inventory from app:', error);\n          return null;\n        });\n    }\n    \n    // Fallback: Try getProductInventory\n    if (window.inventoryInfo.api.getProductInventory) {\n      return window.inventoryInfo.api.getProductInventory(variantId)\n        .then(function(result) {\n          // Extract quantity for specific location\n          if (result && result.locations) {\n            var locationData = result.locations.find(function(loc) {\n              return loc.id === locationId || loc.locationId === locationId;\n            });\n            if (locationData) {\n              return {\n                quantity: locationData.quantity || locationData.available || 0,\n                available: (locationData.quantity || locationData.available || 0) > 0\n              };\n            }\n          }\n          return null;\n        })\n        .catch(function(error) {\n          console.warn('[Custom Availability Widget] Error fetching product inventory:', error);\n          return null;\n        });\n    }\n    \n    return Promise.resolve(null);\n  }\n\n  /**\n   * Fetch inventory for all locations\n   */\n  function fetchAllLocationsInventory(variantId) {\n    console.log('[Custom Availability Widget] fetchAllLocationsInventory called with variantId:', variantId);\n    \n    if (!variantId) {\n      console.warn('[Custom Availability Widget] No variantId provided');\n      return Promise.resolve([]);\n    }\n    \n    // Always try backend API first, even if inventoryInfo.api doesn't exist\n    console.log('[Custom Availability Widget] window.inventoryInfo:', window.inventoryInfo ? 'exists' : 'missing');\n    console.log('[Custom Availability Widget] window.inventoryInfo.api:', window.inventoryInfo && window.inventoryInfo.api ? 'exists' : 'missing');\n    \n    // Try backend API first regardless of inventoryInfo\n    console.log('[Custom Availability Widget] Attempting to fetch from backend API...');\n    return fetchInventoryLevelsFromBackend(variantId)\n      .then(function(backendResult) {\n        console.log('[Custom Availability Widget] Backend API response:', backendResult);\n        if (backendResult && backendResult.inventory_levels && Array.isArray(backendResult.inventory_levels) && backendResult.inventory_levels.length > 0) {\n          console.log('[Custom Availability Widget] \u2713\u2713\u2713 SUCCESS: Got', backendResult.inventory_levels.length, 'locations from backend!');\n          var locationInventory = backendResult.inventory_levels.map(function(level) {\n            // Support both locationId and location_id, quantity and available fields\n            var locId = level.locationId || level.location_id;\n            var qty = level.quantity !== undefined ? level.quantity : (level.available !== undefined ? level.available : 0);\n            console.log('[Custom Availability Widget]   Location', locId, '- quantity:', qty, '- available:', qty > 0);\n            return {\n              locationId: locId,\n              quantity: qty,\n              available: qty > 0\n            };\n          });\n          console.log('[Custom Availability Widget] ===== Returning', locationInventory.length, 'locations =====');\n          return Promise.resolve(locationInventory);\n        }\n        \n        console.log('[Custom Availability Widget] Backend API returned no data, trying fallback methods...');\n        \n        // Get location IDs for fallback methods\n        var locationIds = [];\n        if (window.inventoryInfo && window.inventoryInfo.locationSettings && window.inventoryInfo.locationSettings.details) {\n          locationIds = window.inventoryInfo.locationSettings.details.map(function(loc) {\n            return loc.id;\n          });\n          console.log('[Custom Availability Widget] Found location IDs for fallback:', locationIds);\n        }\n        \n        // Backend API didn't return data, try Shopify variant API for general inventory\n        console.log('[Custom Availability Widget] Trying Shopify variant API...');\n        return fetchVariantInventory(variantId)\n          .then(function(variantData) {\n            if (variantData && (variantData.inventory || variantData.inventoryQuantity !== undefined)) {\n              // We have general inventory, but not per-location\n              // Return locations with the general quantity as estimate\n              var generalQty = variantData.inventoryQuantity !== undefined ? variantData.inventoryQuantity : (variantData.inventory.inventoryQuantity || 0);\n              var locationInventory = locationIds.map(function(locId) {\n                return {\n                  locationId: locId,\n                  quantity: generalQty, // Use general quantity as estimate\n                  available: generalQty > 0\n                };\n              });\n              console.log('[Custom Availability Widget] Using general inventory quantity (', generalQty, ') for all locations');\n              return Promise.resolve(locationInventory);\n            }\n            \n            // No inventory data found anywhere, try DOM extraction\n            console.log('[Custom Availability Widget] No inventory data found, trying DOM extraction...');\n            return fetchFromDOM(variantId, locationIds);\n          });\n      })\n      .catch(function(error) {\n        console.warn('[Custom Availability Widget] Error fetching from backend:', error);\n        // Fallback to variant API\n        var locationIds = [];\n        if (window.inventoryInfo && window.inventoryInfo.locationSettings && window.inventoryInfo.locationSettings.details) {\n          locationIds = window.inventoryInfo.locationSettings.details.map(function(loc) {\n            return loc.id;\n          });\n        }\n        return fetchVariantInventory(variantId)\n          .then(function(variantData) {\n            if (variantData && (variantData.inventory || variantData.inventoryQuantity !== undefined)) {\n              var generalQty = variantData.inventoryQuantity !== undefined ? variantData.inventoryQuantity : (variantData.inventory.inventoryQuantity || 0);\n              var locationInventory = locationIds.map(function(locId) {\n                return {\n                  locationId: locId,\n                  quantity: generalQty,\n                  available: generalQty > 0\n                };\n              });\n              return Promise.resolve(locationInventory);\n            }\n            return fetchFromDOM(variantId, locationIds);\n          })\n          .catch(function(error2) {\n            console.warn('[Custom Availability Widget] Error fetching variant inventory:', error2);\n            return fetchFromDOM(variantId, locationIds);\n          });\n      });\n  }\n  \n  /**\n   * Helper function to fetch inventory from DOM\n   */\n  function fetchFromDOM(variantId, locationIds) {\n    console.log('[Custom Availability Widget] fetchFromDOM called but disabled to prevent stale quantities.');\n    return Promise.resolve([]);\n    // DISABLED: getWidgetHtml API causes \"Cannot read properties of undefined (reading 'settings')\" error\n    // Try to use getWidgetHtml to get the widget HTML and parse it FIRST (before waiting for DOM)\n    // if (window.inventoryInfo.api && typeof window.inventoryInfo.api.getWidgetHtml === 'function') {\n    //   console.log('[Custom Availability Widget] Trying getWidgetHtml API...');\n    //   try {\n    //     var widgetHtml = window.inventoryInfo.api.getWidgetHtml();\n    //     if (widgetHtml) {\n    //       console.log('[Custom Availability Widget] Got widget HTML, parsing...');\n    //       var tempDiv = document.createElement('div');\n    //       tempDiv.innerHTML = widgetHtml;\n    //       var listItems = tempDiv.querySelectorAll('.iia-list-item');\n    //       if (listItems.length > 0) {\n    //         console.log('[Custom Availability Widget] Found', listItems.length, 'items in widget HTML');\n    //         var parsedInventory = [];\n    //         listItems.forEach(function(item) {\n    //           var locIdMatch = item.className.match(/iia-id-(\\d+)/);\n    //           if (locIdMatch) {\n    //             var locId = parseInt(locIdMatch[1], 10);\n    //             var qtyText = item.querySelector('.iia-qty');\n    //             var locNameText = item.querySelector('.iia-location');\n    //             var quantity = 0;\n    //             var available = false;\n    //             var locationName = locNameText ? locNameText.textContent.trim() : 'Location ' + locId;\n    //             \n    //             if (qtyText) {\n    //               var qtyMatch = qtyText.textContent.match(/(\\d+)\\s+available/);\n    //               if (qtyMatch) {\n    //                 quantity = parseInt(qtyMatch[1], 10);\n    //                 available = quantity > 0;\n    //               } else if (qtyText.textContent.toLowerCase().indexOf('out of stock') === -1) {\n    //                 available = true;\n    //                 quantity = 1;\n    //               }\n    //             }\n    //             \n    //             parsedInventory.push({\n    //               locationId: locId,\n    //               locationName: locationName,\n    //               quantity: quantity,\n    //               available: available\n    //             });\n    //           }\n    //         });\n    //         \n    //         if (parsedInventory.length > 0) {\n    //           console.log('[Custom Availability Widget] ===== PARSED INVENTORY FROM getWidgetHtml =====');\n    //           parsedInventory.forEach(function(loc) {\n    //             console.log('[Custom Availability Widget]', loc.locationName, '(ID:', loc.locationId, ') - Qty:', loc.quantity, 'Available:', loc.available);\n    //           });\n    //           console.log('[Custom Availability Widget] ===========================================');\n    //           return Promise.resolve(parsedInventory);\n    //         }\n    //       }\n    //     }\n    //   } catch(e) {\n    //     console.warn('[Custom Availability Widget] Error using getWidgetHtml:', e);\n    //   }\n    // }\n    \n    // Try to extract inventory from the app's widget DOM if it's rendered\n    // The app renders inventory in .iia-list-item elements\n    console.log('[Custom Availability Widget] ===== CHECKING APP WIDGET DOM =====');\n    var appWidget = document.querySelector('#inventory-info-app, .iia-container');\n    if (appWidget) {\n      console.log('[Custom Availability Widget] Found app widget:', appWidget.id || appWidget.className);\n      \n      // Try to trigger the app to load/display inventory if it hasn't already\n      // The app might need variant tracking to be triggered\n      // BUT: trackVariantChanges is causing errors, so we'll skip it for now\n      // if (window.inventoryInfo && window.inventoryInfo.api && typeof window.inventoryInfo.api.trackVariantChanges === 'function') {\n      //   console.log('[Custom Availability Widget] Triggering trackVariantChanges to load inventory...');\n      //   try {\n      //     // Check if settings exist before calling\n      //     if (window.inventoryInfo.settings) {\n      //       window.inventoryInfo.api.trackVariantChanges(variantId);\n      //     } else {\n      //       console.warn('[Custom Availability Widget] inventoryInfo.settings not available, skipping trackVariantChanges');\n      //     }\n      //   } catch(e) {\n      //     console.warn('[Custom Availability Widget] Error calling trackVariantChanges:', e);\n      //   }\n      // }\n      \n      // Wait a bit for the widget to render, then check again\n      return new Promise(function(resolve) {\n        var attempts = 0;\n        var maxAttempts = 10;\n        var checkInterval = 200; // Check every 200ms\n        \n        var checkForItems = function() {\n          attempts++;\n          var listItems = appWidget.querySelectorAll('.iia-list-item');\n          console.log('[Custom Availability Widget] Attempt', attempts, '- Found', listItems.length, 'location items in DOM');\n          \n          if (listItems.length > 0 || attempts >= maxAttempts) {\n            if (listItems.length > 0) {\n              console.log('[Custom Availability Widget] Extracting inventory from DOM...');\n              var domInventory = [];\n              listItems.forEach(function(item, index) {\n                var locIdMatch = item.className.match(/iia-id-(\\d+)/);\n                if (locIdMatch) {\n                  var locId = parseInt(locIdMatch[1], 10);\n                  var qtyText = item.querySelector('.iia-qty');\n                  var locNameText = item.querySelector('.iia-location');\n                  var quantity = 0;\n                  var available = false;\n                  var locationName = locNameText ? locNameText.textContent.trim() : 'Location ' + locId;\n                  var qtyTextContent = qtyText ? qtyText.textContent.trim() : '';\n                  \n                  console.log('[Custom Availability Widget] Item', index + 1, '- Location ID:', locId, 'Name:', locationName, 'Qty Text:', qtyTextContent);\n                  \n                  if (qtyText) {\n                    var qtyMatch = qtyText.textContent.match(/(\\d+)\\s+available/);\n                    if (qtyMatch) {\n                      quantity = parseInt(qtyMatch[1], 10);\n                      available = quantity > 0;\n                      console.log('[Custom Availability Widget]   -> Parsed quantity:', quantity, 'Available:', available);\n                    } else if (qtyText.textContent.toLowerCase().indexOf('out of stock') === -1 && \n                               qtyText.textContent.toLowerCase().indexOf('unavailable') === -1 &&\n                               qtyText.textContent.toLowerCase().indexOf('sold out') === -1) {\n                      // If it says \"in stock\" or similar without a number\n                      available = true;\n                      quantity = 1; // Unknown quantity but available\n                      console.log('[Custom Availability Widget]   -> No quantity number, but appears available');\n                    } else {\n                      console.log('[Custom Availability Widget]   -> Out of stock');\n                    }\n                  } else {\n                    console.log('[Custom Availability Widget]   -> No quantity text found');\n                  }\n                  \n                  domInventory.push({\n                    locationId: locId,\n                    locationName: locationName,\n                    quantity: quantity,\n                    available: available\n                  });\n                } else {\n                  console.log('[Custom Availability Widget] Item', index + 1, '- No location ID found in className:', item.className);\n                }\n              });\n              \n              if (domInventory.length > 0) {\n                console.log('[Custom Availability Widget] ===== DOM INVENTORY EXTRACTED =====');\n                domInventory.forEach(function(loc) {\n                  console.log('[Custom Availability Widget]', loc.locationName, '(ID:', loc.locationId, ') - Qty:', loc.quantity, 'Available:', loc.available);\n                });\n                console.log('[Custom Availability Widget] ====================================');\n                resolve(domInventory);\n                return;\n              }\n            }\n            \n            // If we've exhausted attempts or got items but no data, return locations with unknown quantities\n            if (attempts >= maxAttempts) {\n              console.warn('[Custom Availability Widget] Widget did not render inventory after', maxAttempts, 'attempts');\n              // Return locations with unknown quantities instead of empty array\n              if (locationIds && locationIds.length > 0) {\n                var locationsWithUnknownQty = locationIds.map(function(locId) {\n                  return {\n                    locationId: locId,\n                    quantity: null // null means unknown/checking\n                  };\n                });\n                console.log('[Custom Availability Widget] Returning', locationsWithUnknownQty.length, 'locations with unknown quantities (DOM extraction failed)');\n                resolve(locationsWithUnknownQty);\n                return;\n              }\n            }\n            resolve([]); // Only return empty if no locationIds available\n          } else {\n            // Check again after delay\n            setTimeout(checkForItems, checkInterval);\n          }\n        };\n        \n        // Start checking\n        checkForItems();\n      });\n    } else {\n      console.log('[Custom Availability Widget] App widget not found in DOM');\n      // Return locations with unknown quantities instead of empty array\n      if (locationIds && locationIds.length > 0) {\n        var locationsWithUnknownQty = locationIds.map(function(locId) {\n          return {\n            locationId: locId,\n            quantity: null // null means unknown/checking\n          };\n        });\n        console.log('[Custom Availability Widget] Returning', locationsWithUnknownQty.length, 'locations with unknown quantities (no widget DOM)');\n        return Promise.resolve(locationsWithUnknownQty);\n      }\n      return Promise.resolve([]);\n    }\n    \n    // Try to use getProductInventory which returns all locations at once\n    if (window.inventoryInfo.api && typeof window.inventoryInfo.api.getProductInventory === 'function') {\n      console.log('[Custom Availability Widget] Using getProductInventory API');\n      return window.inventoryInfo.api.getProductInventory(variantId)\n        .then(function(result) {\n          console.log('[Custom Availability Widget] getProductInventory result:', result);\n          if (result && result.locations && Array.isArray(result.locations)) {\n            var locationsData = result.locations.map(function(loc) {\n              return {\n                locationId: loc.id || loc.locationId,\n                quantity: loc.quantity || loc.available || 0,\n                available: (loc.quantity || loc.available || 0) > 0\n              };\n            });\n            console.log('[Custom Availability Widget] Processed locations data:', locationsData);\n            return locationsData;\n          }\n          console.warn('[Custom Availability Widget] getProductInventory returned invalid data structure');\n          return [];\n        })\n        .catch(function(error) {\n          console.error('[Custom Availability Widget] Error fetching all locations inventory:', error);\n          return [];\n        });\n    }\n    \n    // Fallback: Fetch each location individually\n    if (window.inventoryInfo.api && typeof window.inventoryInfo.api.getVariantAvailability === 'function') {\n      console.log('[Custom Availability Widget] ===== USING getVariantAvailability API (fallback) =====');\n      console.log('[Custom Availability Widget] Fetching inventory for', locationIds.length, 'locations individually...');\n      var fetchPromises = locationIds.map(function(locId) {\n        var locationName = locationIdToDetails[locId] ? locationIdToDetails[locId].name : 'Location ' + locId;\n        console.log('[Custom Availability Widget] Fetching location:', locationName, '(ID:', locId, ')...');\n        \n        return window.inventoryInfo.api.getVariantAvailability(variantId, locId)\n          .then(function(result) {\n            var qty = result && result.quantity !== undefined ? result.quantity : (result && result.available ? 1 : 0);\n            var isAvailable = result && result.quantity ? result.quantity > 0 : (result && result.available ? true : false);\n            \n            console.log('[Custom Availability Widget]   Location:', locationName, '(ID:', locId, ') - Result:', result, 'Qty:', qty, 'Available:', isAvailable);\n            \n            return {\n              locationId: locId,\n              locationName: locationName,\n              quantity: qty,\n              available: isAvailable\n            };\n          })\n          .catch(function(error) {\n            console.warn('[Custom Availability Widget]   Location:', locationName, '(ID:', locId, ') - Error:', error);\n            return {\n              locationId: locId,\n              locationName: locationName,\n              quantity: 0,\n              available: false\n            };\n          });\n      });\n      \n      return Promise.all(fetchPromises).then(function(results) {\n        console.log('[Custom Availability Widget] ===== ALL LOCATION RESULTS =====');\n        results.forEach(function(loc) {\n          console.log('[Custom Availability Widget]', loc.locationName, '(ID:', loc.locationId, ') - Qty:', loc.quantity, 'Available:', loc.available);\n        });\n        console.log('[Custom Availability Widget] ================================');\n        return results;\n      });\n    }\n    \n    // Final fallback: Deep inspect inventoryInfo for any inventory data\n    console.log('[Custom Availability Widget] ===== DEEP INSPECTING APP STATE =====');\n    \n    // Function to recursively search for inventory data\n    function findInventoryData(obj, path, visited) {\n      if (!visited) visited = new Set();\n      if (visited.has(obj)) return null; // Prevent circular references\n      visited.add(obj);\n      \n      if (!obj || typeof obj !== 'object') return null;\n      \n      // Check if this object looks like inventory data\n      if (Array.isArray(obj)) {\n        if (obj.length > 0 && obj[0] && typeof obj[0] === 'object') {\n          var first = obj[0];\n          if (first.location_id || first.locationId || first.id) {\n            // This looks like location inventory array\n            console.log('[Custom Availability Widget] Found potential inventory array at', path);\n            var inventory = obj.map(function(item) {\n              var locId = item.location_id || item.locationId || item.id;\n              var qty = item.quantity || item.available || item.inventory || item.qty || 0;\n              var locName = locationIdToDetails[locId] ? locationIdToDetails[locId].name : 'Location ' + locId;\n              return {\n                locationId: locId,\n                locationName: locName,\n                quantity: qty,\n                available: qty > 0\n              };\n            }).filter(function(item) {\n              return locationIds.indexOf(item.locationId) !== -1; // Only include known locations\n            });\n            \n            if (inventory.length > 0) {\n              console.log('[Custom Availability Widget] ===== EXTRACTED INVENTORY FROM', path, '=====');\n              inventory.forEach(function(loc) {\n                console.log('[Custom Availability Widget]', loc.locationName, '(ID:', loc.locationId, ') - Qty:', loc.quantity, 'Available:', loc.available);\n              });\n              console.log('[Custom Availability Widget] ===========================================');\n              return inventory;\n            }\n          }\n        }\n      } else {\n        // Check object properties\n        Object.keys(obj).forEach(function(key) {\n          if (key.toLowerCase().indexOf('inventory') !== -1 || \n              key.toLowerCase().indexOf('quantity') !== -1 ||\n              key.toLowerCase().indexOf('stock') !== -1 ||\n              key.toLowerCase().indexOf('available') !== -1) {\n            var newPath = path ? path + '.' + key : key;\n            var result = findInventoryData(obj[key], newPath, visited);\n            if (result) return result;\n          }\n        });\n      }\n      \n      return null;\n    }\n    \n    // Search inventoryInfo for inventory data\n    var foundInventory = findInventoryData(window.inventoryInfo, 'inventoryInfo', new Set());\n    if (foundInventory && foundInventory.length > 0) {\n      return Promise.resolve(foundInventory);\n    }\n    \n    // Also check if there's a variant-specific inventory object\n    if (window.inventoryInfo && window.inventoryInfo[variantId]) {\n      console.log('[Custom Availability Widget] Found variant-specific data at inventoryInfo[' + variantId + ']');\n      var variantData = window.inventoryInfo[variantId];\n      var variantInventory = findInventoryData(variantData, 'inventoryInfo[' + variantId + ']', new Set());\n      if (variantInventory && variantInventory.length > 0) {\n        return Promise.resolve(variantInventory);\n      }\n    }\n    \n    console.log('[Custom Availability Widget] =========================================');\n    console.log('[Custom Availability Widget] No inventory data found from any method');\n    \n    // Return locations with unknown quantities instead of empty array\n    // This allows the widget to still display all locations\n    if (window.inventoryInfo && window.inventoryInfo.locationSettings && window.inventoryInfo.locationSettings.details) {\n      var locationIds = window.inventoryInfo.locationSettings.details.map(function(loc) {\n        return loc.id;\n      });\n      \n      var locationsWithUnknownQty = locationIds.map(function(locId) {\n        return {\n          locationId: locId,\n          quantity: null // null means unknown/checking\n        };\n      });\n      \n      console.log('[Custom Availability Widget] Returning', locationsWithUnknownQty.length, 'locations with unknown quantities');\n      return Promise.resolve(locationsWithUnknownQty);\n    }\n    \n    console.log('[Custom Availability Widget] No location settings available, returning empty array');\n    return Promise.resolve([]);\n  }\n\n  /**\n   * Render availability for local delivery/pickup (all locations)\n   */\n  function renderLocationAvailability(inventory, selectedLocationId) {\n    var html = '<div class=\"custom-availability-locations\">';\n    var variantId = getCurrentVariantId();\n    \n    // Show loading state\n    html += '<div class=\"custom-availability-message\">Loading location availability...</div>';\n    html += '</div>';\n    \n    // Fetch inventory for all locations\n    // Always try to fetch from backend API, even if inventoryInfo.api doesn't exist\n    console.log('[Custom Availability Widget] renderLocationAvailability - variantId:', variantId);\n    console.log('[Custom Availability Widget] window.inventoryInfo:', window.inventoryInfo ? 'exists' : 'missing');\n    console.log('[Custom Availability Widget] window.inventoryInfo.api:', window.inventoryInfo && window.inventoryInfo.api ? 'exists' : 'missing');\n    \n    if (variantId) {\n      fetchAllLocationsInventory(variantId).then(function(locationsData) {\n        console.log('[Custom Availability Widget] fetchAllLocationsInventory returned:', locationsData);\n        var contentArea = widgetContainer.querySelector('.custom-availability-info');\n        if (!contentArea) {\n          console.warn('[Custom Availability Widget] Content area not found');\n          return;\n        }\n        \n        var locationsHtml = '<div class=\"custom-availability-locations\">';\n        \n        if (locationsData && locationsData.length > 0) {\n          console.log('[Custom Availability Widget] Processing', locationsData.length, 'locations');\n          console.log('[Custom Availability Widget] Selected location ID:', selectedLocationId);\n          \n          // Sort locations - put selected location first, then sort the rest alphabetically\n          var sortedLocations = locationsData.slice().sort(function(a, b) {\n            // Normalize location IDs for comparison (handle both string and number)\n            var aId = typeof a.locationId === 'string' ? parseInt(a.locationId, 10) : a.locationId;\n            var bId = typeof b.locationId === 'string' ? parseInt(b.locationId, 10) : b.locationId;\n            var selectedId = typeof selectedLocationId === 'string' ? parseInt(selectedLocationId, 10) : selectedLocationId;\n            \n            var aIsSelected = selectedId && aId === selectedId;\n            var bIsSelected = selectedId && bId === selectedId;\n            \n            // Selected location always comes first\n            if (aIsSelected && !bIsSelected) return -1;\n            if (!aIsSelected && bIsSelected) return 1;\n            \n            // If both are selected or neither is selected, sort alphabetically by name\n            var aName = (a.locationName || '').toLowerCase();\n            var bName = (b.locationName || '').toLowerCase();\n            if (aName < bName) return -1;\n            if (aName > bName) return 1;\n            return 0;\n          });\n          \n          sortedLocations.forEach(function(locData) {\n            console.log('[Custom Availability Widget] Processing location:', locData.locationId, 'quantity:', locData.quantity);\n            var location = locationIdToDetails[locData.locationId];\n            if (!location) {\n              console.warn('[Custom Availability Widget] Location not found in locationIdToDetails:', locData.locationId);\n              // Don't skip - use the location data from the API instead\n              location = {\n                id: locData.locationId,\n                name: locData.locationName || 'Location ' + locData.locationId\n              };\n            }\n            \n            var isSelected = selectedLocationId && locData.locationId === selectedLocationId;\n            var locationClass = isSelected ? 'custom-availability-location-item selected' : 'custom-availability-location-item';\n            \n            // Calculate distance if we have delivery coordinates and store coordinates\n            var distanceText = '';\n            var deliveryCoords = getDeliveryCoordinates();\n            if (deliveryCoords && location.lat && location.lng) {\n              var distance = calculateDistance(\n                deliveryCoords.lat,\n                deliveryCoords.lng,\n                location.lat,\n                location.lng\n              );\n              distanceText = '<span class=\"custom-availability-distance\">' + distance.toFixed(1) + ' miles away</span>';\n            }\n            \n            locationsHtml += '<div class=\"' + locationClass + '\">';\n            locationsHtml += '<div class=\"custom-availability-location-header\">';\n            locationsHtml += '<span class=\"custom-availability-location-name\">' + escapeHtml(location.name) + '</span>';\n            if (isSelected) {\n              locationsHtml += ' <span class=\"custom-availability-selected-badge\">(Selected)</span>';\n            }\n            if (distanceText) {\n              locationsHtml += ' ' + distanceText;\n            }\n            locationsHtml += '</div>';\n            \n            if (locData.quantity !== undefined && locData.quantity !== null) {\n              // We have a specific quantity for this location\n              if (locData.quantity > 0) {\n                locationsHtml += '<div class=\"custom-availability-status in-stock\">';\n                locationsHtml += '<span class=\"custom-availability-qty\"><strong>' + locData.quantity + ' available</strong></span>';\n                locationsHtml += '</div>';\n              } else {\n                locationsHtml += '<div class=\"custom-availability-status out-of-stock\">';\n                locationsHtml += '<span class=\"custom-availability-qty\"><strong>Out of stock</strong></span>';\n                locationsHtml += '</div>';\n              }\n            } else if (locData.quantity === null) {\n              // Quantity is unknown (null) - show \"Checking availability\" or use general inventory\n              if (inventory.inventoryManagement === 'shopify' && inventory.inventoryQuantity !== null) {\n                if (inventory.inventoryQuantity > 0) {\n                  locationsHtml += '<div class=\"custom-availability-status in-stock\">';\n                  locationsHtml += '<span class=\"custom-availability-qty\">' + inventory.inventoryQuantity + ' available (estimated)</span>';\n                  locationsHtml += '</div>';\n                } else {\n                  locationsHtml += '<div class=\"custom-availability-status out-of-stock\">';\n                  locationsHtml += '<span class=\"custom-availability-qty\">Out of stock</span>';\n                  locationsHtml += '</div>';\n                }\n              } else {\n                // Show checking status\n                locationsHtml += '<div class=\"custom-availability-status\">';\n                locationsHtml += '<span class=\"custom-availability-qty\">Checking availability...</span>';\n                locationsHtml += '</div>';\n              }\n            } else {\n              // Fallback to general inventory (quantity is undefined)\n              if (inventory.inventoryManagement === 'shopify' && inventory.inventoryQuantity !== null) {\n                if (inventory.inventoryQuantity > 0) {\n                  locationsHtml += '<div class=\"custom-availability-status in-stock\">';\n                  locationsHtml += '<span class=\"custom-availability-qty\">' + inventory.inventoryQuantity + ' available</span>';\n                  locationsHtml += '</div>';\n                } else {\n                  locationsHtml += '<div class=\"custom-availability-status out-of-stock\">';\n                  locationsHtml += '<span class=\"custom-availability-qty\">Out of stock</span>';\n                  locationsHtml += '</div>';\n                }\n              } else {\n                if (inventory.available) {\n                  locationsHtml += '<div class=\"custom-availability-status in-stock\">';\n                  locationsHtml += '<span class=\"custom-availability-qty\">In stock</span>';\n                  locationsHtml += '</div>';\n                } else {\n                  locationsHtml += '<div class=\"custom-availability-status out-of-stock\">';\n                  locationsHtml += '<span class=\"custom-availability-qty\">Out of stock</span>';\n                  locationsHtml += '</div>';\n                }\n              }\n            }\n            \n            // Add address and phone info\n            var addressParts = [];\n            if (location.address1) {\n              addressParts.push(escapeHtml(location.address1));\n            }\n            if (location.city) {\n              addressParts.push(escapeHtml(location.city));\n            }\n            if (location.zip) {\n              addressParts.push(escapeHtml(location.zip));\n            }\n            \n            if (addressParts.length > 0 || location.phone) {\n              locationsHtml += '<div class=\"custom-availability-location-address\">';\n              if (addressParts.length > 0) {\n                locationsHtml += addressParts.join(', ');\n              }\n              if (location.phone) {\n                if (addressParts.length > 0) {\n                  locationsHtml += ' \u2022 ';\n                }\n                locationsHtml += '<span class=\"custom-availability-phone\">' + escapeHtml(location.phone) + '</span>';\n              }\n              locationsHtml += '</div>';\n            }\n            \n            locationsHtml += '</div>';\n          });\n        } else {\n          // No location data available, show fallback with more info\n          console.warn('[Custom Availability Widget] No location data returned from API');\n          locationsHtml += '<div class=\"custom-availability-message\">Loading location availability...</div>';\n          \n          // Try to show locations anyway using the locationIdToDetails mapping\n          if (window.inventoryInfo && window.inventoryInfo.locationSettings && window.inventoryInfo.locationSettings.details) {\n            var allLocationIds = window.inventoryInfo.locationSettings.details.map(function(loc) {\n              return loc.id;\n            });\n            \n            // Sort to put selected location first\n            allLocationIds.sort(function(a, b) {\n              var aIsSelected = selectedLocationId && a === selectedLocationId;\n              var bIsSelected = selectedLocationId && b === selectedLocationId;\n              if (aIsSelected && !bIsSelected) return -1;\n              if (!aIsSelected && bIsSelected) return 1;\n              return 0;\n            });\n            \n            allLocationIds.forEach(function(locId) {\n              var location = locationIdToDetails[locId];\n              if (location) {\n                // Calculate distance if we have delivery coordinates\n                var distanceText = '';\n                var deliveryCoords = getDeliveryCoordinates();\n                if (deliveryCoords && location.lat && location.lng) {\n                  var distance = calculateDistance(\n                    deliveryCoords.lat,\n                    deliveryCoords.lng,\n                    location.lat,\n                    location.lng\n                  );\n                  distanceText = '<span class=\"custom-availability-distance\">' + distance.toFixed(1) + ' miles away</span>';\n                }\n                \n                locationsHtml += '<div class=\"custom-availability-location-item\">';\n                locationsHtml += '<div class=\"custom-availability-location-header\">';\n                locationsHtml += '<span class=\"custom-availability-location-name\">' + escapeHtml(location.name) + '</span>';\n                if (selectedLocationId && locId === selectedLocationId) {\n                  locationsHtml += ' <span class=\"custom-availability-selected-badge\">(Selected)</span>';\n                }\n                if (distanceText) {\n                  locationsHtml += ' ' + distanceText;\n                }\n                locationsHtml += '</div>';\n                locationsHtml += '<div class=\"custom-availability-status\">';\n                locationsHtml += '<span class=\"custom-availability-qty\">Checking availability...</span>';\n                locationsHtml += '</div>';\n                \n                // Add address and phone info\n                var addressParts = [];\n                if (location.address1) {\n                  addressParts.push(escapeHtml(location.address1));\n                }\n                if (location.city) {\n                  addressParts.push(escapeHtml(location.city));\n                }\n                if (location.zip) {\n                  addressParts.push(escapeHtml(location.zip));\n                }\n                \n                if (addressParts.length > 0 || location.phone) {\n                  locationsHtml += '<div class=\"custom-availability-location-address\">';\n                  if (addressParts.length > 0) {\n                    locationsHtml += addressParts.join(', ');\n                  }\n                  if (location.phone) {\n                    if (addressParts.length > 0) {\n                      locationsHtml += ' \u2022 ';\n                    }\n                    locationsHtml += '<span class=\"custom-availability-phone\">' + escapeHtml(location.phone) + '</span>';\n                  }\n                  locationsHtml += '</div>';\n                }\n                locationsHtml += '</div>';\n              }\n            });\n          } else {\n            locationsHtml += '<div class=\"custom-availability-message\">Unable to load location availability</div>';\n          }\n        }\n        \n        locationsHtml += '</div>';\n        contentArea.innerHTML = locationsHtml;\n        console.log('[Custom Availability Widget] ===== LOCATION AVAILABILITY RENDERED =====');\n        isRendering = false; // Reset flag after async render completes\n      }).catch(function(error) {\n        console.error('[Custom Availability Widget] Error rendering all locations availability:', error);\n        var contentArea = widgetContainer.querySelector('.custom-availability-info');\n        if (contentArea) {\n          contentArea.innerHTML = '<div class=\"custom-availability-message\">Error loading location availability</div>';\n        }\n        isRendering = false; // Reset flag after error\n      });\n    } else {\n      // No API available, show message\n      html = '<div class=\"custom-availability-locations\">';\n      html += '<div class=\"custom-availability-message\">Location inventory data not available</div>';\n      html += '</div>';\n    }\n    \n    return html;\n  }\n\n  /**\n   * Escape HTML to prevent XSS\n   */\n  function escapeHtml(text) {\n    var div = document.createElement('div');\n    div.textContent = text;\n    return div.innerHTML;\n  }\n\n  /**\n   * Initialize the widget\n   */\n  function initWidget() {\n    if (isInitialized) return;\n    \n    // Only run on product pages\n    if (!document.querySelector('.product_page_template')) {\n      return;\n    }\n    \n    // Find the right column where the widget should go\n    var rightColumn = document.querySelector('.tt-product-single-aside');\n    if (!rightColumn) {\n      console.warn('[Custom Availability Widget] Right column not found');\n      return;\n    }\n    \n    // Check if widget already exists\n    widgetContainer = document.getElementById('custom-availability-widget');\n    if (!widgetContainer) {\n      // Create widget\n      widgetContainer = createWidgetHTML();\n      rightColumn.appendChild(widgetContainer);\n      console.log('[Custom Availability Widget] Widget created and added to page');\n    } else {\n      console.log('[Custom Availability Widget] Widget already exists');\n    }\n    \n    // Listen for method changes (shipping/local delivery/pickup) from header selector\n    var lastMethod = window.currentMethod;\n    var methodCheckInterval = setInterval(function() {\n      if (window.currentMethod && window.currentMethod !== lastMethod) {\n        lastMethod = window.currentMethod;\n        console.log('[Custom Availability Widget] Detected method change to:', window.currentMethod);\n        // Save selection when method changes\n        saveCurrentSelection();\n        // Re-render widget when method changes to update selected location\n        setTimeout(function() {\n          if (window.customAvailabilityWidget && typeof window.customAvailabilityWidget.render === 'function') {\n            window.customAvailabilityWidget.render();\n          }\n        }, 300);\n      }\n    }, 500);\n    \n    // Clean up interval when page unloads\n    window.addEventListener('beforeunload', function() {\n      if (methodCheckInterval) {\n        clearInterval(methodCheckInterval);\n      }\n    });\n    \n    // Auto-select last selection before initial render\n    autoSelectLastSelection();\n    \n    // Initial render\n    console.log('[Custom Availability Widget] Initializing render...');\n    renderAvailability();\n    \n    // Save selection periodically and on events\n    setInterval(function() {\n      saveCurrentSelection();\n    }, 2000); // Save every 2 seconds\n    \n    // Listen for variant changes\n    var variantSelectors = document.querySelectorAll('[name=\"id\"], select[name*=\"variant\"], input[name=\"id\"][type=\"hidden\"]');\n    variantSelectors.forEach(function(selector) {\n      selector.addEventListener('change', function() {\n        inventoryData = null; // Reset to force refetch\n        renderAvailability();\n      });\n    });\n    \n    // Listen for shipping method changes (events are dispatched on document)\n    document.addEventListener('shippingMethodChanged', function() {\n      inventoryData = null; // Reset to force refetch\n      renderAvailability();\n    });\n    \n    // Listen for location changes (events are dispatched on document)\n    document.addEventListener('locationChanged', function() {\n      console.log('[Custom Availability Widget] locationChanged event received');\n      setTimeout(function() {\n        renderAvailability();\n      }, 200);\n    });\n    \n    document.addEventListener('locationSelected', function() {\n      console.log('[Custom Availability Widget] locationSelected event received');\n      saveCurrentSelection(); // Save when location is selected\n      // Small delay to let forcedLocationId be set\n      setTimeout(function() {\n        renderAvailability();\n      }, 200);\n    });\n    \n    document.addEventListener('inventoryInfo:locationChanged', function() {\n      console.log('[Custom Availability Widget] inventoryInfo:locationChanged event received');\n      saveCurrentSelection(); // Save when location changes\n      setTimeout(function() {\n        renderAvailability();\n      }, 200);\n    });\n    \n    // Monitor forcedLocationId changes\n    var lastForcedLocationId = window.forcedLocationId;\n    setInterval(function() {\n      if (window.forcedLocationId && window.forcedLocationId !== lastForcedLocationId) {\n        lastForcedLocationId = window.forcedLocationId;\n        console.log('[Custom Availability Widget] Detected forcedLocationId change:', window.forcedLocationId);\n        setTimeout(function() {\n          renderAvailability();\n        }, 100);\n      }\n    }, 500);\n    \n    // Also listen for custom events from header-location-selector\n    document.addEventListener('DOMContentLoaded', function() {\n      // Re-render when page fully loads\n      setTimeout(renderAvailability, 500);\n    });\n    \n    isInitialized = true;\n  }\n\n  // Expose render function globally IMMEDIATELY (before DOM ready)\n  window.customAvailabilityWidget = {\n    render: renderAvailability,\n    init: initWidget\n  };\n  \n  console.log('[Custom Availability Widget] Script loaded, widget API exposed');\n  \n  // Initialize when DOM is ready\n  if (document.readyState === 'loading') {\n    document.addEventListener('DOMContentLoaded', function() {\n      console.log('[Custom Availability Widget] DOMContentLoaded fired, initializing...');\n      initWidget();\n    });\n  } else {\n    console.log('[Custom Availability Widget] DOM already ready, initializing immediately...');\n    initWidget();\n  }\n  \n  // Also try after delays to catch dynamic content\n  setTimeout(function() {\n    console.log('[Custom Availability Widget] Delayed init attempt 1 (500ms)');\n    initWidget();\n  }, 500);\n  \n  setTimeout(function() {\n    console.log('[Custom Availability Widget] Delayed init attempt 2 (1000ms)');\n    initWidget();\n  }, 1000);\n  \n  setTimeout(function() {\n    console.log('[Custom Availability Widget] Delayed init attempt 3 (2000ms)');\n    initWidget();\n  }, 2000);\n  \n  console.log('[Custom Availability Widget] IIFE completed, widget should be available');\n\n})();\n\n// Final check\ntry {\n  if (window.customAvailabilityWidget) {\n    console.log('[Custom Availability Widget] Widget API successfully exposed:', typeof window.customAvailabilityWidget.render);\n  } else {\n    console.error('[Custom Availability Widget] Widget API NOT exposed!');\n  }\n} catch(e) {\n  console.error('[Custom Availability Widget] Error checking widget API:', e);\n}\n\n"],
  "mappings": "AAMA,GAAI,CACF,QAAQ,IAAI,kEAAkE,CAChF,OAAQ,EAAG,CACT,QAAQ,MAAM,uDAAwD,CAAC,CACzE,EAEC,UAAW,CACV,aAEA,GAAI,CACF,QAAQ,IAAI,+CAA+C,CAC7D,OAAQ,EAAG,CACT,QAAQ,MAAM,oDAAqD,CAAC,CACtE,CAGA,IAAI,oBAAsB,CACxB,YAAa,CAAE,KAAM,oCAAqC,SAAU,iBAAkB,KAAM,UAAW,SAAU,SAAU,IAAK,QAAS,MAAO,eAAgB,IAAK,WAAY,IAAK,YAAa,EACnM,YAAa,CAAE,KAAM,2BAA4B,SAAU,oBAAqB,KAAM,QAAS,SAAU,SAAU,IAAK,QAAS,MAAO,eAAgB,IAAK,WAAY,IAAK,YAAa,EAC3L,YAAa,CAAE,KAAM,yBAA0B,SAAU,wBAAyB,KAAM,QAAS,SAAU,SAAU,IAAK,QAAS,MAAO,eAAgB,IAAK,WAAY,IAAK,YAAa,EAC7L,YAAa,CAAE,KAAM,oBAAqB,SAAU,kCAAmC,KAAM,SAAU,SAAU,SAAU,IAAK,QAAS,MAAO,eAAgB,IAAK,WAAY,IAAK,YAAa,EACnM,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