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5D,KAAK0C,eAAiB1C,KAAKyD,KAG7BzD,KAAKwC,MACP,ECfF,MAAMqB,EASJrB,IAAAA,GACMxC,KAAK8D,SACP9D,KAAKa,KAAO,IAAIF,EAAKX,KAAK8D,QAE9B,CAZAT,WAAAA,CAAYC,GACVtD,KAAKqC,UAAYiB,EACjBtD,KAAKa,KAAO,KACZb,KAAK8D,OAAS9D,KAAKqC,UAAUC,cAAc,SAE3CtC,KAAKwC,MACP,ECRa,IAAkB/D,IDiBxB,KACP,MAAMsF,EAAYC,SAAST,iBAAiB,sBAC1B,OAAdQ,GACFA,EAAUjD,SAAQmD,GAAa,IAAIJ,EAAaI,IAClD,ECpB4B,YAAxBD,SAASE,WACXzF,IAEAuF,SAASvB,iBAAiB,oBAAoB,KAC5ChE,GAAU,G","sources":["webpack://golf-wp/./node_modules/throttle-debounce/esm/index.js","webpack://golf-wp/./wp-content/themes/golf/src/js/modules/tabs.js","webpack://golf-wp/./wp-content/themes/golf/src/js/blocks/category-articles.js","webpack://golf-wp/./wp-content/themes/golf/src/js/utils/DOMReady.js"],"sourcesContent":["/* eslint-disable no-undefined,no-param-reassign,no-shadow */\n\n/**\n * Throttle execution of a function. Especially useful for rate limiting\n * execution of handlers on events like resize and scroll.\n *\n * @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher)\n * are most useful.\n * @param {Function} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through,\n * as-is, to `callback` when the throttled-function is executed.\n * @param {object} [options] - An object to configure options.\n * @param {boolean} [options.noTrailing] - Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds\n * while the throttled-function is being called. If noTrailing is false or unspecified, callback will be executed\n * one final time after the last throttled-function call. (After the throttled-function has not been called for\n * `delay` milliseconds, the internal counter is reset).\n * @param {boolean} [options.noLeading] - Optional, defaults to false. If noLeading is false, the first throttled-function call will execute callback\n * immediately. If noLeading is true, the first the callback execution will be skipped. It should be noted that\n * callback will never executed if both noLeading = true and noTrailing = true.\n * @param {boolean} [options.debounceMode] - If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is\n * false (at end), schedule `callback` to execute after `delay` ms.\n *\n * @returns {Function} A new, throttled, function.\n */\nfunction throttle (delay, callback, options) {\n var _ref = options || {},\n _ref$noTrailing = _ref.noTrailing,\n noTrailing = _ref$noTrailing === void 0 ? false : _ref$noTrailing,\n _ref$noLeading = _ref.noLeading,\n noLeading = _ref$noLeading === void 0 ? false : _ref$noLeading,\n _ref$debounceMode = _ref.debounceMode,\n debounceMode = _ref$debounceMode === void 0 ? undefined : _ref$debounceMode;\n /*\n * After wrapper has stopped being called, this timeout ensures that\n * `callback` is executed at the proper times in `throttle` and `end`\n * debounce modes.\n */\n\n\n var timeoutID;\n var cancelled = false; // Keep track of the last time `callback` was executed.\n\n var lastExec = 0; // Function to clear existing timeout\n\n function clearExistingTimeout() {\n if (timeoutID) {\n clearTimeout(timeoutID);\n }\n } // Function to cancel next exec\n\n\n function cancel(options) {\n var _ref2 = options || {},\n _ref2$upcomingOnly = _ref2.upcomingOnly,\n upcomingOnly = _ref2$upcomingOnly === void 0 ? false : _ref2$upcomingOnly;\n\n clearExistingTimeout();\n cancelled = !upcomingOnly;\n }\n /*\n * The `wrapper` function encapsulates all of the throttling / debouncing\n * functionality and when executed will limit the rate at which `callback`\n * is executed.\n */\n\n\n function wrapper() {\n for (var _len = arguments.length, arguments_ = new Array(_len), _key = 0; _key < _len; _key++) {\n arguments_[_key] = arguments[_key];\n }\n\n var self = this;\n var elapsed = Date.now() - lastExec;\n\n if (cancelled) {\n return;\n } // Execute `callback` and update the `lastExec` timestamp.\n\n\n function exec() {\n lastExec = Date.now();\n callback.apply(self, arguments_);\n }\n /*\n * If `debounceMode` is true (at begin) this is used to clear the flag\n * to allow future `callback` executions.\n */\n\n\n function clear() {\n timeoutID = undefined;\n }\n\n if (!noLeading && debounceMode && !timeoutID) {\n /*\n * Since `wrapper` is being called for the first time and\n * `debounceMode` is true (at begin), execute `callback`\n * and noLeading != true.\n */\n exec();\n }\n\n clearExistingTimeout();\n\n if (debounceMode === undefined && elapsed > delay) {\n if (noLeading) {\n /*\n * In throttle mode with noLeading, if `delay` time has\n * been exceeded, update `lastExec` and schedule `callback`\n * to execute after `delay` ms.\n */\n lastExec = Date.now();\n\n if (!noTrailing) {\n timeoutID = setTimeout(debounceMode ? clear : exec, delay);\n }\n } else {\n /*\n * In throttle mode without noLeading, if `delay` time has been exceeded, execute\n * `callback`.\n */\n exec();\n }\n } else if (noTrailing !== true) {\n /*\n * In trailing throttle mode, since `delay` time has not been\n * exceeded, schedule `callback` to execute `delay` ms after most\n * recent execution.\n *\n * If `debounceMode` is true (at begin), schedule `clear` to execute\n * after `delay` ms.\n *\n * If `debounceMode` is false (at end), schedule `callback` to\n * execute after `delay` ms.\n */\n timeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === undefined ? delay - elapsed : delay);\n }\n }\n\n wrapper.cancel = cancel; // Return the wrapper function.\n\n return wrapper;\n}\n\n/* eslint-disable no-undefined */\n/**\n * Debounce execution of a function. Debouncing, unlike throttling,\n * guarantees that a function is only executed a single time, either at the\n * very beginning of a series of calls, or at the very end.\n *\n * @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.\n * @param {Function} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,\n * to `callback` when the debounced-function is executed.\n * @param {object} [options] - An object to configure options.\n * @param {boolean} [options.atBegin] - Optional, defaults to false. If atBegin is false or unspecified, callback will only be executed `delay` milliseconds\n * after the last debounced-function call. If atBegin is true, callback will be executed only at the first debounced-function call.\n * (After the throttled-function has not been called for `delay` milliseconds, the internal counter is reset).\n *\n * @returns {Function} A new, debounced function.\n */\n\nfunction debounce (delay, callback, options) {\n var _ref = options || {},\n _ref$atBegin = _ref.atBegin,\n atBegin = _ref$atBegin === void 0 ? false : _ref$atBegin;\n\n return throttle(delay, callback, {\n debounceMode: atBegin !== false\n });\n}\n\nexport { debounce, throttle };\n//# sourceMappingURL=index.js.map\n","import { throttle } from 'throttle-debounce'\n\nexport default class Tabs {\n constructor(el) {\n this.container = el\n this.tabs = this.container.querySelectorAll('.tabs__tab')\n this.panels = this.container.querySelectorAll('.tabs__panel')\n this.tabSelect = this.container.querySelector('.tabs__select')\n this.callbacks = []\n\n this.handleSelectUpdate = this.handleSelectUpdate.bind(this)\n this.handleTabClick = this.handleTabClick.bind(this)\n this.nav = this.container.querySelector('.tabs__nav')\n this.scrollableTabs = this.container.querySelector('[scrollable]')\n\n if (this.container.offsetWidth < this.nav.scrollWidth) {\n this.nav.setAttribute('scrollable', true)\n this.scrollableTabs = this.nav\n }\n\n this.init()\n }\n\n reset() {\n if (this.tabs) {\n this.tabs.forEach(tab => {\n tab.classList.remove('tabs__tab--active')\n })\n }\n\n if (this.panels) {\n this.panels.forEach(panel => {\n panel.classList.remove('tabs__panel--active')\n })\n }\n }\n\n /**\n * Triggers an action on Form Events\n *\n * @param {String} eventName The event to watch\n * @param {Function} callback The callback function\n */\n on(eventName, callback = () => {}) {\n this.callbacks.push({\n type: eventName,\n func: callback,\n })\n }\n\n /**\n * Triggers an action\n *\n * @param {String} eventName\n * @param {any} data\n */\n triggerEvent(eventName = '', data = null) {\n this.callbacks.forEach(callback => {\n const { type, func } = callback\n if (type === eventName) {\n func(data)\n }\n })\n }\n\n handleSelectUpdate(e) {\n const { target } = e\n const tabId = target.value\n\n this.triggerEvent('input', e)\n this.setActiveTab(tabId)\n }\n\n handleTabClick(e) {\n const { target } = e\n const { tab } = target.dataset\n\n this.setActiveTab(tab)\n this.triggerEvent('tab-click', e)\n\n if (this.tabSelect) {\n this.tabSelect.value = tab\n }\n }\n\n setActiveTab(tabId) {\n const tab = this.container.querySelector(`.tabs__tab[data-tab=\"${tabId}\"]`)\n const panel = this.container.querySelector(`.tabs__panel[data-tab=\"${tabId}\"]`)\n\n if (tab && panel) {\n this.reset()\n tab.classList.add('tabs__tab--active')\n panel.classList.add('tabs__panel--active')\n }\n\n this.triggerEvent('tab-set', tabId)\n }\n\n init() {\n if (this.tabSelect) {\n this.tabSelect.addEventListener('input', this.handleSelectUpdate)\n }\n\n if (this.tabs) {\n this.tabs.forEach(tab => {\n tab.addEventListener('click', this.handleTabClick)\n })\n }\n\n if (this.scrollableTabs) {\n const tabsNav = this.scrollableTabs\n let isDown = false\n let startX\n let scrollLeft\n\n tabsNav.addEventListener('mousedown', e => {\n isDown = true\n tabsNav.classList.add('active')\n startX = e.pageX\n // eslint-disable-next-line prefer-destructuring\n scrollLeft = tabsNav.scrollLeft\n })\n\n tabsNav.addEventListener('mouseleave', () => {\n isDown = false\n tabsNav.classList.remove('active')\n })\n\n tabsNav.addEventListener('mouseup', () => {\n isDown = false\n tabsNav.classList.remove('active')\n })\n\n const handleMouseMove = e => {\n if (!isDown) return\n e.preventDefault()\n const x = e.pageX // Use pageX directly\n const walk = (x - startX) * 3\n tabsNav.scrollLeft = scrollLeft - walk\n }\n\n const throttledMouseMove = throttle(handleMouseMove, 16) // ~60fps\n\n tabsNav.addEventListener('mousemove', throttledMouseMove)\n\n // For touch devices\n tabsNav.addEventListener('touchstart', e => {\n isDown = true\n startX = e.touches[0].pageX\n // eslint-disable-next-line prefer-destructuring\n scrollLeft = tabsNav.scrollLeft\n })\n\n const handleTouchMove = e => {\n if (!isDown) return\n const x = e.touches[0].pageX\n const walk = (x - startX) * 3\n tabsNav.scrollLeft = scrollLeft - walk\n }\n\n const throttledTouchMove = throttle(handleTouchMove, 16)\n\n tabsNav.addEventListener('touchmove', throttledTouchMove)\n\n tabsNav.addEventListener('touchend', () => {\n isDown = false\n })\n }\n }\n}\n","// eslint-disable-next-line no-unused-vars\nimport css from '../../css/blocks/category-articles.scss'\n\nimport Tabs from '../modules/tabs'\nimport DOMReady from '../utils/DOMReady'\n\nclass CategoryTabs {\n constructor(el) {\n this.container = el\n this.tabs = null\n this.tabsEl = this.container.querySelector('.tabs')\n\n this.init()\n }\n\n init() {\n if (this.tabsEl) {\n this.tabs = new Tabs(this.tabsEl)\n }\n }\n}\n\nDOMReady(() => {\n const wrapperEl = document.querySelectorAll('.category-articles')\n if (wrapperEl !== null) {\n wrapperEl.forEach(component => new CategoryTabs(component))\n }\n})\n","/**\n * Triggers a callback function once the DOM is ready\n *\n * @param {function} callback The function to trigger\n */\nexport default function DOMReady(callback) {\n if (document.readyState !== 'loading') {\n callback()\n } else {\n document.addEventListener('DOMContentLoaded', () => {\n callback()\n })\n }\n}\n"],"names":["throttle","delay","callback","options","timeoutID","_ref","_ref$noTrailing","noTrailing","_ref$noLeading","noLeading","_ref$debounceMode","debounceMode","undefined","cancelled","lastExec","clearExistingTimeout","clearTimeout","wrapper","_len","arguments","length","arguments_","Array","_key","self","this","elapsed","Date","now","exec","apply","clear","setTimeout","cancel","_ref2$upcomingOnly","upcomingOnly","Tabs","reset","tabs","forEach","tab","classList","remove","panels","panel","on","eventName","callbacks","push","type","func","triggerEvent","data","handleSelectUpdate","e","target","tabId","value","setActiveTab","handleTabClick","dataset","tabSelect","container","querySelector","add","init","addEventListener","scrollableTabs","tabsNav","startX","scrollLeft","isDown","pageX","throttledMouseMove","preventDefault","walk","touches","throttledTouchMove","constructor","el","querySelectorAll","bind","nav","offsetWidth","scrollWidth","setAttribute","CategoryTabs","tabsEl","wrapperEl","document","component","readyState"],"sourceRoot":""}