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O,GAKP,SAAU,EAAU,WAAW,CAAC,EA1BV,CACtB,QAAS,EACT,SAAS,GAwB2C,GAKpD,UAAW,EAKX,YAAa,EAOb,QAAS,KACP,OAAO,GAAW,MAAM,QAAQ,IAC1B,EAAK,UAA6C,mBAA1B,EAAK,SAAS,SACxC,EAAK,SAAS,cAOM,YAAxB,SAAS,WACX,OAAO,iBAAiB,mBAAoB,KAC1C,OAAO,GAAW,OAEd,OAAO,OAAS,OAAO,KAAK,OAIlC,OAAO,GAAW,OACd,OAAO,OAAS,OAAO,KAAK,IAEnC,CA7sBD","file":"/gh/willmyerscode/horizontal-scroll-sections@0.0.7/horizontal-scroll-sections.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.48.0.\n * Original file: /gh/willmyerscode/horizontal-scroll-sections@0.0.7/horizontal-scroll-sections.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n * Horizontal Scrolling Sections Plugin for Squarespace\n * Copyright Will-Myers.com\n **/\n\n(function () {\n  // ============================================================================\n  // UTILITIES CLASS\n  // ============================================================================\n  /**\n   * General utility functions used throughout the plugin\n   */\n  class Utilities {\n    /**\n     * Parse data attribute values and convert them to appropriate types\n     * @param {string} value - The value to parse\n     * @returns {boolean|number|string} - Parsed value\n     */\n    static parseAttributeValue(value) {\n      if (value === \"true\") return true;\n      if (value === \"false\") return false;\n      const number = parseFloat(value);\n      if (!isNaN(number) && number.toString() === value) return number;\n      return value;\n    }\n\n    /**\n     * Emit a custom event from an element\n     * @param {string} type - Event name\n     * @param {Object} detail - Event detail object\n     * @param {Element} elem - Element to dispatch from (default: document)\n     */\n    static emitEvent(type, detail = {}, elem = document) {\n      if (!type) return;\n\n      const event = new CustomEvent(type, {\n        bubbles: true,\n        cancelable: true,\n        detail: detail,\n      });\n\n      return elem.dispatchEvent(event);\n    }\n\n    /**\n     * Deep merge multiple objects\n     * @param {...Object} objs - Objects to merge\n     * @returns {Object} - Merged object\n     */\n    static deepMerger(...objs) {\n      function getType(obj) {\n        return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase();\n      }\n\n      function mergeObj(clone, obj) {\n        for (let [key, value] of Object.entries(obj)) {\n          let type = getType(value);\n          if (type === \"object\" || type === \"array\") {\n            if (clone[key] === undefined) {\n              clone[key] = type === \"object\" ? {} : [];\n            }\n            mergeObj(clone[key], value);\n          } else if (type === \"function\") {\n            clone[key] = value;\n          } else {\n            clone[key] = value;\n          }\n        }\n      }\n\n      if (objs.length === 0) return {};\n\n      let clone = {};\n      objs.forEach(obj => {\n        mergeObj(clone, obj);\n      });\n      return clone;\n    }\n\n    /**\n     * Resolve the current Squarespace header mode from tweakJSON\n     * @returns {\"non-fixed\"|\"fixed-basic\"|\"fixed-scrollback\"}\n     */\n    static getHeaderMode() {\n      const tweakJSON = window.Static?.SQUARESPACE_CONTEXT?.tweakJSON || {};\n      const isFixedHeader = tweakJSON[\"tweak-fixed-header\"] === true || tweakJSON[\"tweak-fixed-header\"] === \"true\";\n      const fixedHeaderStyle = tweakJSON[\"tweak-fixed-header-style\"];\n\n      if (!isFixedHeader) {\n        return \"non-fixed\";\n      }\n\n      return fixedHeaderStyle === \"Scroll Back\" ? \"fixed-scrollback\" : \"fixed-basic\";\n    }\n\n    /**\n     * Keep the resolved header mode available to CSS selectors\n     */\n    static syncHeaderMode() {\n      document.documentElement.dataset.wmHsHeaderMode = Utilities.getHeaderMode();\n    }\n\n    /**\n     * Measure the current header state and expose it as CSS variables\n     */\n    static syncHeaderMeasurements() {\n      Utilities.syncHeaderMode();\n\n      const root = document.documentElement;\n      const header = document.querySelector(\"#header\");\n\n      if (!header) {\n        root.style.setProperty(\"--header-fixed-top-offset\", \"0px\");\n        root.style.setProperty(\"--header-fixed-bottom\", \"0px\");\n        root.style.setProperty(\"--header-fixed-top-height\", \"0px\");\n        return;\n      }\n\n      const headerRect = header.getBoundingClientRect();\n      const headerHeight = header.offsetHeight;\n      const headerBottom = headerRect.bottom;\n      const visibleTopHeight = Math.max(0, Math.min(headerHeight, headerBottom));\n\n      root.style.setProperty(\"--header-fixed-top-offset\", `${headerHeight}px`);\n      root.style.setProperty(\"--header-fixed-bottom\", `${headerBottom}px`);\n      root.style.setProperty(\"--header-fixed-top-height\", `${visibleTopHeight}px`);\n    }\n\n    /**\n     * Keep header CSS variables updated while scrolling\n     */\n    static startHeaderMeasurementSync() {\n      if (Utilities._headerMeasurementSyncStarted) return;\n      Utilities._headerMeasurementSyncStarted = true;\n\n      let frameRequested = false;\n      let scrollStopTimer = null;\n      let settleTimer = null;\n\n      const runMeasurement = () => {\n        frameRequested = false;\n        Utilities.syncHeaderMeasurements();\n      };\n\n      const requestMeasurement = () => {\n        if (frameRequested) return;\n        frameRequested = true;\n        window.requestAnimationFrame(runMeasurement);\n      };\n\n      const runSettledMeasurements = () => {\n        Utilities.syncHeaderMeasurements();\n        window.clearTimeout(settleTimer);\n        settleTimer = window.setTimeout(() => {\n          Utilities.syncHeaderMeasurements();\n        }, 120);\n      };\n\n      const handleScroll = () => {\n        requestMeasurement();\n\n        window.clearTimeout(scrollStopTimer);\n        scrollStopTimer = window.setTimeout(() => {\n          runSettledMeasurements();\n        }, 120);\n      };\n\n      window.addEventListener(\"scroll\", handleScroll, { passive: true });\n      window.addEventListener(\"load\", () => {\n        Utilities.syncHeaderMeasurements();\n      });\n\n      Utilities.syncHeaderMeasurements();\n    }\n  }\n\n  // ============================================================================\n  // MAIN PLUGIN CLASS\n  // ============================================================================\n  /**\n   * Main class that handles horizontal scrolling behavior\n   */\n  class WMHorizontalScrolling {\n    /**\n     * Create a new horizontal scrolling instance\n     * @param {Element} el - The horizontal scroll container element\n     * @param {Element} initEl - The original plugin trigger element\n     * @param {Object} settings - Plugin settings\n     */\n    constructor(el, initEl, settings) {\n      this.el = el; // The container we create\n      this.initEl = initEl; // The original div with data-wm-plugin\n      this.settings = settings;\n\n      // Store references to key elements and measurements\n      this.scrollWrapper = null;\n      this.horizontalGroup = {\n        container: null,\n        scrollWrapper: null,\n        start: 0,\n        end: 0,\n        distance: 0,\n      };\n\n      // Scroll optimization\n      this.ticking = false;\n      this.lastScrollTop = window.pageYOffset;\n      this.prevWidth = window.innerWidth;\n\n      // Observers\n      this.resizeObserver = null;\n\n      this.init();\n    }\n\n    /**\n     * Initialize the plugin\n     */\n    init() {\n      this.horizontalGroup.container = this.el;\n      this.horizontalGroup.scrollWrapper = this.el.querySelector(\".wm-hs-scroll-wrapper\");\n      this.bindEvents();\n\n      // Emit initialization event\n      Utilities.emitEvent(`${nameSpace}:init`, {\n        container: this.el,\n        instance: this,\n      });\n    }\n\n    /**\n     * Bind all event listeners\n     */\n    bindEvents() {\n      this.addScrollEventListener();\n      this.addResizeEventListener();\n      this.addClickEventListener();\n      this.handleHashNavigation();\n      this.addResizeObserver();\n    }\n\n    /**\n     * Add scroll event listener with RAF optimization\n     */\n    addScrollEventListener() {\n      window.addEventListener(\"scroll\", () => {\n        this.lastScrollTop = window.pageYOffset;\n\n        // Use requestAnimationFrame to throttle scroll updates\n        if (!this.ticking) {\n          window.requestAnimationFrame(() => {\n            this.handleScroll();\n            this.ticking = false;\n          });\n          this.ticking = true;\n        }\n      });\n    }\n\n    /**\n     * Handle scroll position and translate the horizontal wrapper\n     */\n    handleScroll() {\n      const { container, scrollWrapper, start, end, distance } = this.horizontalGroup;\n      if (!container || !scrollWrapper) return;\n\n      // Determine if we're in the active scroll region\n      if (this.lastScrollTop >= start && this.lastScrollTop <= end) {\n        // Calculate how far through the scroll region we are (0 to 1)\n        const percentage = (this.lastScrollTop - start) / (end - start);\n\n        // Convert that percentage to horizontal scroll distance\n        const horizontalScroll = Math.min(Math.max(0, percentage * distance), distance);\n\n        // Apply the transform (reversed if settings.reverse is true)\n        if (this.settings.reverse) {\n          // Reverse: start at left, scroll right\n          scrollWrapper.style.transform = `translateX(-${distance - horizontalScroll}px)`;\n        } else {\n          // Normal: start at right, scroll left\n          scrollWrapper.style.transform = `translateX(-${horizontalScroll}px)`;\n        }\n\n        // Emit section enter event if we're just entering\n        if (this.lastScrollTop - 1 < start) {\n          Utilities.emitEvent(`${nameSpace}:sectionEnter`, {\n            container: this.el,\n            instance: this,\n          });\n        }\n      } else if (this.lastScrollTop < start) {\n        // Before the scroll region - reset to start\n        if (this.settings.reverse) {\n          // Reverse: start with last section visible\n          scrollWrapper.style.transform = `translateX(-${distance}px)`;\n        } else {\n          // Normal: start with first section visible\n          scrollWrapper.style.transform = \"translateX(0)\";\n        }\n      } else if (this.lastScrollTop > end) {\n        // After the scroll region - lock to end\n        if (this.settings.reverse) {\n          // Reverse: end with first section visible\n          scrollWrapper.style.transform = \"translateX(0)\";\n        } else {\n          // Normal: end with last section visible\n          scrollWrapper.style.transform = `translateX(-${distance}px)`;\n        }\n\n        // Emit section leave event\n        if (this.lastScrollTop - 1 <= end) {\n          Utilities.emitEvent(`${nameSpace}:sectionLeave`, {\n            container: this.el,\n            instance: this,\n          });\n        }\n      }\n    }\n\n    /**\n     * Add resize event listener to recalculate measurements\n     */\n    addResizeEventListener() {\n      window.addEventListener(\"resize\", () => {\n        // Only recalculate if width actually changed (not just height/mobile scroll)\n        if (window.innerWidth !== this.prevWidth) {\n          this.updateMeasurements();\n          this.prevWidth = window.innerWidth;\n        }\n      });\n    }\n\n    /**\n     * Add click event listener for hash link navigation within horizontal sections\n     */\n    addClickEventListener() {\n      document.addEventListener(\"click\", event => {\n        const link = event.target.closest(\"a\");\n        if (!link) return;\n\n        const href = link.getAttribute(\"href\");\n        if (!href || !href.startsWith(\"#\")) return;\n\n        // Check if the target is within our horizontal sections\n        const targetSection = document.querySelector(href)?.closest(\".wm-hs-section\");\n        if (targetSection && this.horizontalGroup.scrollWrapper.contains(targetSection)) {\n          event.preventDefault();\n          event.stopPropagation();\n\n          // Scroll to the position that would show this horizontal section\n          window.scrollTo({\n            top: this.horizontalGroup.container.offsetTop + targetSection.offsetLeft,\n            behavior: \"smooth\",\n          });\n        }\n      });\n    }\n\n    /**\n     * Handle initial page load with hash in URL\n     */\n    handleHashNavigation() {\n      const hash = window.location.hash;\n      if (!hash) return;\n\n      const targetSection = document.querySelector(hash)?.closest(\".wm-hs-section\");\n      if (targetSection && this.horizontalGroup.scrollWrapper.contains(targetSection)) {\n        // Disable scroll restoration to prevent browser from fighting us\n        if (\"scrollRestoration\" in history) {\n          history.scrollRestoration = \"manual\";\n        }\n\n        // Scroll to the correct position instantly\n        window.scrollTo({\n          top: this.horizontalGroup.container.offsetTop + targetSection.offsetLeft,\n          behavior: \"instant\",\n        });\n      }\n    }\n\n    /**\n     * Detect the Squarespace header height and set --header-fixed-top-offset on the document root\n     */\n    setHeaderOffset() {\n      Utilities.syncHeaderMeasurements();\n    }\n\n    /**\n     * Calculate and update all scroll measurements\n     */\n    updateMeasurements() {\n      const { container, scrollWrapper } = this.horizontalGroup;\n      if (!container || !scrollWrapper) return;\n\n      this.setHeaderOffset();\n\n      // Calculate how far we need to scroll horizontally\n      this.horizontalGroup.distance = scrollWrapper.offsetWidth - window.innerWidth;\n\n      // Set CSS variable for container height\n      // Height = viewport height + horizontal distance (so we have room to scroll)\n      const totalHeight = window.innerHeight + this.horizontalGroup.distance;\n      container.style.setProperty(\"--horizontal-sliding-height\", `${totalHeight}px`);\n\n      // Calculate start and end points for the scroll region\n      // Start is offset by overlap to create smooth transition\n      this.horizontalGroup.start = container.offsetTop - window.innerHeight * this.settings.overlapStart;\n\n      // End point includes overlap on both sides\n      this.horizontalGroup.end =\n        this.horizontalGroup.start + this.horizontalGroup.distance + window.innerHeight * this.settings.overlapEnd * 2;\n\n      // Set initial transform based on reverse setting and current scroll position\n      if (this.settings.reverse && this.lastScrollTop < this.horizontalGroup.start) {\n        scrollWrapper.style.transform = `translateX(-${this.horizontalGroup.distance}px)`;\n      }\n    }\n\n    /**\n     * Add ResizeObserver to watch for size changes\n     */\n    addResizeObserver() {\n      const { container, scrollWrapper } = this.horizontalGroup;\n      if (!container || !scrollWrapper) return;\n\n      this.resizeObserver = new ResizeObserver(() => {\n        this.updateMeasurements();\n        this.handleScroll();\n      });\n\n      this.resizeObserver.observe(scrollWrapper);\n      if (container.parentElement) {\n        this.resizeObserver.observe(container.parentElement);\n      }\n    }\n\n    /**\n     * Public method to manually trigger measurement refresh\n     */\n    refresh() {\n      this.updateMeasurements();\n      this.handleScroll();\n    }\n\n    /**\n     * Destroy this instance and restore original structure\n     */\n    destroy() {\n      const { container, scrollWrapper } = this.horizontalGroup;\n\n      if (this.resizeObserver) {\n        this.resizeObserver.disconnect();\n        this.resizeObserver = null;\n      }\n\n      if (!container) return;\n\n      // Get all the horizontal sections\n      const horizontalSections = Array.from(scrollWrapper.querySelectorAll(\".wm-hs-section\"));\n\n      // Restore them to their original positions in reverse order\n      horizontalSections.reverse().forEach(section => {\n        section.classList.remove(\"wm-hs-section\");\n        container.insertAdjacentElement(\"afterend\", section);\n      });\n\n      // Remove the horizontal container\n      container.remove();\n    }\n  }\n\n  // ============================================================================\n  // PLUGIN INITIALIZATION\n  // ============================================================================\n\n  /**\n   * Build the horizontal scroll structure from a plugin div\n   * @param {Element} pluginEl - The element with data-wm-plugin=\"horizontal-scrolling-sections\"\n   * @param {Object} settings - Plugin settings\n   * @returns {Element} - The created horizontal scroll container\n   */\n  function buildPlugin(pluginEl, settings) {\n    // Get data attributes from the plugin element\n    const data = pluginEl.dataset;\n    const sectionCount = Utilities.parseAttributeValue(data.sectionCount) || 3;\n    const overlap = Utilities.parseAttributeValue(data.overlap) ?? settings.overlap;\n    const overlapStart = Utilities.parseAttributeValue(data.overlapStart) ?? overlap;\n    const overlapEnd = Utilities.parseAttributeValue(data.overlapEnd) ?? overlap;\n    const reverse = Utilities.parseAttributeValue(data.reverse) ?? settings.reverse;\n    const id = pluginEl.id;\n\n    // Find the parent section (this is where the horizontal scroll starts)\n    const initialSection = pluginEl.closest(\".page-section\");\n    if (!initialSection) {\n      console.error(\"[Horizontal Scrolling] Plugin element must be inside a .page-section\");\n      return null;\n    }\n\n    // Create the horizontal scroll container\n    const horizontalContainer = document.createElement(\"section\");\n    horizontalContainer.classList.add(\"wm-hs-container\", \"page-section\");\n    if (id) horizontalContainer.id = id;\n\n    // Set the section count CSS variable\n    horizontalContainer.style.setProperty(\"--section-count\", sectionCount);\n\n    // Store overlap settings as data attributes for the instance to read\n    horizontalContainer.dataset.overlapStart = overlapStart;\n    horizontalContainer.dataset.overlapEnd = overlapEnd;\n    horizontalContainer.dataset.reverse = reverse;\n\n    // Create the sticky wrapper (sticks during scroll)\n    const stickyWrapper = document.createElement(\"div\");\n    stickyWrapper.classList.add(\"wm-hs-sticky-wrapper\");\n\n    // Create the scroll wrapper (contains all horizontal sections)\n    const scrollWrapper = document.createElement(\"div\");\n    scrollWrapper.classList.add(\"wm-hs-scroll-wrapper\");\n\n    // Collect the sections to make horizontal\n    let nextSection = initialSection;\n    const sectionsToMove = [];\n\n    for (let i = 0; i < sectionCount; i++) {\n      if (!nextSection) {\n        console.warn(`[Horizontal Scrolling] Only found ${i} sections, expected ${sectionCount}`);\n        break;\n      }\n\n      sectionsToMove.push(nextSection);\n      nextSection = nextSection.nextElementSibling;\n    }\n\n    // Assemble the structure first\n    stickyWrapper.appendChild(scrollWrapper);\n    horizontalContainer.appendChild(stickyWrapper);\n\n    // Insert the horizontal container where the first section was\n    // Do this BEFORE moving sections to avoid the hierarchy error\n    initialSection.parentNode.insertBefore(horizontalContainer, sectionsToMove[0]);\n\n    // Now move sections into the scroll wrapper\n    sectionsToMove.forEach(section => {\n      section.classList.add(\"wm-hs-section\");\n      scrollWrapper.appendChild(section);\n    });\n\n    return horizontalContainer;\n  }\n\n  /**\n   * Initialize all plugin instances on the page\n   */\n  function initPlugin() {\n    // Find all plugin trigger elements that haven't been initialized yet\n    const pluginEls = document.querySelectorAll('[data-wm-plugin=\"horizontal-scrolling-sections\"]:not([data-loading-state])');\n\n    if (!pluginEls.length) return;\n\n    const settings = window[nameSpace].settings;\n\n    pluginEls.forEach(pluginEl => {\n      // Skip if in edit mode or already inside a horizontal container\n      if (pluginEl.closest(\"body.sqs-edit-mode-active\") || pluginEl.closest(\".wm-hs-container\")) {\n        return;\n      }\n\n      // Mark as initializing\n      pluginEl.setAttribute(\"data-loading-state\", \"initializing\");\n\n      // Build the horizontal structure\n      const horizontalContainer = buildPlugin(pluginEl, settings);\n\n      if (!horizontalContainer) {\n        pluginEl.setAttribute(\"data-loading-state\", \"error\");\n        return;\n      }\n\n      // Read overlap settings from the container\n      const overlapStart = parseFloat(horizontalContainer.dataset.overlapStart) || settings.overlap;\n      const overlapEnd = parseFloat(horizontalContainer.dataset.overlapEnd) || settings.overlap;\n      const reverse = horizontalContainer.dataset.reverse === \"true\";\n\n      // Create instance with custom overlap settings\n      const instanceSettings = {\n        ...settings,\n        overlapStart,\n        overlapEnd,\n        reverse,\n      };\n\n      // Create the class instance\n      const instance = new WMHorizontalScrolling(horizontalContainer, pluginEl, instanceSettings);\n\n      // Store reference on the plugin element\n      pluginEl.wmHorizontalScrolling = instance;\n      pluginEl.setAttribute(\"data-loading-state\", \"initialized\");\n\n      // Add to global items array\n      window[nameSpace].items.push({\n        container: horizontalContainer,\n        pluginEl: pluginEl,\n        instance: instance,\n      });\n    });\n\n    // Emit ready event after all instances are initialized\n    if (pluginEls.length > 0) {\n      Utilities.emitEvent(`${nameSpace}:ready`, {\n        count: pluginEls.length,\n      });\n    }\n  }\n\n  /**\n   * Deconstruct all horizontal scroll instances (used when entering edit mode)\n   */\n  function deconstruct() {\n    const items = window[nameSpace].items;\n\n    items.forEach(item => {\n      if (item.instance && typeof item.instance.destroy === \"function\") {\n        item.instance.destroy();\n      }\n    });\n\n    // Clear the items array\n    window[nameSpace].items = [];\n  }\n\n  /**\n   * Listen for edit mode and deconstruct when it activates\n   */\n  function addDeconstructListener() {\n    const bodyObserver = new MutationObserver(mutations => {\n      mutations.forEach(mutation => {\n        if (mutation.attributeName === \"class\") {\n          if (document.body.classList.contains(\"sqs-edit-mode-active\")) {\n            deconstruct();\n            bodyObserver.disconnect();\n          }\n        }\n      });\n    });\n\n    bodyObserver.observe(document.body, {\n      attributes: true,\n      attributeFilter: [\"class\"],\n    });\n  }\n\n  // ============================================================================\n  // PLUGIN SETUP & INITIALIZATION\n  // ============================================================================\n\n  const nameSpace = \"wmHorizontalScrolling\";\n\n  // Default settings (can be overridden via window.wmHorizontalScrollingSettings)\n  const defaultSettings = {\n    overlap: 0, // Default overlap percentage (15% of viewport height)\n    reverse: false, // Reverse scroll direction (right to left instead of left to right)\n  };\n\n  // Merge user settings if they exist\n  const userSettings = window.wmHorizontalScrollingSettings || {};\n\n  // Expose plugin API on window\n  window[nameSpace] = {\n    /**\n     * Initialize the plugin\n     */\n    init: () => {\n      Utilities.startHeaderMeasurementSync();\n      initPlugin();\n    },\n\n    /**\n     * Array to store all instances\n     */\n    items: [],\n\n    /**\n     * Merged settings\n     */\n    settings: Utilities.deepMerger({}, defaultSettings, userSettings),\n\n    /**\n     * Expose utilities\n     */\n    utilities: Utilities,\n\n    /**\n     * Expose deconstruct function\n     */\n    deconstruct: deconstruct,\n\n    /**\n     * Refresh all instances - recalculates measurements\n     * Call this after other plugins modify the page layout\n     * @example window.wmHorizontalScrolling.refresh()\n     */\n    refresh: () => {\n      window[nameSpace].items.forEach(item => {\n        if (item.instance && typeof item.instance.refresh === \"function\") {\n          item.instance.refresh();\n        }\n      });\n    },\n  };\n\n  // Auto-initialize when DOM is ready\n  if (document.readyState === \"loading\") {\n    window.addEventListener(\"DOMContentLoaded\", () => {\n      window[nameSpace].init();\n      // Only add deconstruct listener if we're in an iframe (edit mode detection)\n      if (window.self !== window.top) addDeconstructListener();\n    });\n  } else {\n    // DOM is already ready\n    window[nameSpace].init();\n    if (window.self !== window.top) addDeconstructListener();\n  }\n})();\n"]}