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AaG,SACnDhD,KAAK+C,sBAAsB,aAAcF,EAAavB,WACvD,CAGA,aAAM2B,CAAQpB,GACb,MAAMY,EAAO,CACZC,IAAK1C,KAAK0C,IACVC,UAAW,CAAC,UAAW,cACvBd,KAAMA,GAGP,aAD2B7B,KAAK8C,eAAeL,EAEhD,CAEA,cAAMS,CAASrB,GACd,MAAMgB,QAAqB7C,KAAKiD,QAAQpB,GACxC7B,KAAK+C,sBAAsB,UAAWF,EAAaG,SACnDhD,KAAK+C,sBAAsB,aAAcF,EAAavB,WACvD,CAEA,gBAAMS,CAAWF,GAChB,MAAMgB,QAAqB7C,KAAKiD,QAAQpB,GAClCsB,EAAmBnD,KAAKkB,cAC7B,uCAEKkC,EAAajF,SAASkF,cAAc,OAC1CD,EAAWE,UAAYT,EAAaG,QACpC,MAAMO,EAAkBH,EAAW7B,iBAClC,4CAED,IAAK,MAAMiC,KAAkBD,EAC5BJ,EAAiBM,OAAOD,GAEzBxD,KAAK+C,sBAAsB,aAAcF,EAAavB,WACvD,EAIDnD,SAASsD,iBAAiB,oBAAoB,KAC7CiC,eAAeC,OAAO,mCAAoChE,EAAsB,CAACiE,QAAS,OAAO,G","sources":["webpack://customtheme/./node_modules/@alexspirgel/children-loaded/src/index.js","webpack://customtheme/webpack/bootstrap","webpack://customtheme/./custom-post-lists/courses-workshops-list/scripts/src/script.js"],"sourcesContent":["module.exports = (function () {\n\n\t// Initialize a weak map to hold promises.\n\tconst childrenLoadedPromises = new WeakMap();\n\n\t/**\n\t * Checks to see if children elements are loaded.\n\t * @param {object} element - Element to look for children within.\n\t * @return {boolean} Whether the children elements are loaded or not.\n\t */\n\n\tconst childrenLoadedSynchronous = (element) => {\n\n\t\t// Document ready states reference: https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState\n\t\tif (document.readyState === 'interactive' || document.readyState === 'complete') {\n\t\t\t// Children elements are assumed to be loaded.\n\t\t\treturn true;\n\t\t}\n\n\t\t// While the element exists.\n\t\twhile (element) {\n\t\t\t// If the next sibling element exists.\n\t\t\tif (element.nextSibling) {\n\t\t\t\t// The original passed element and its children have been loaded.\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\t// Set the element to the parent element.\n\t\t\telement = element.parentNode;\n\t\t}\n\n\t\t// If code execution gets here, it's assumed children elements are not loaded.\n\t\treturn false;\n\n\t};\n\n\t/**\n\t * An asynchronous wrapper for the childrenLoadedSynchronous function.\n\t * @param {object} element - Element to look for children within.\n\t * @param {boolean} [forceNewPromise=false] - Option to invalidate existing promises.\n\t * @return {*} True if children are loaded, otherwise a promise.\n\t */\n\n\tconst childrenLoaded = (element, forceNewPromise = false) => {\n\n\t\t// If children are loaded immediately.\n\t\tif (childrenLoadedSynchronous(element)) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// If an existing promise for the passed element does not exist yet or if a new promise is being forced.\n\t\telse if (!childrenLoadedPromises.get(element) || forceNewPromise) {\n\t\t\t// Create a new promise.\n\t\t\tconst childrenLoadedPromise = new Promise((resolve) => {\n\t\t\t\t// Create a new mutation observer.\n\t\t\t\tconst observer = new MutationObserver(() => {\n\t\t\t\t\t// When children are loaded.\n\t\t\t\t\tif (childrenLoadedSynchronous(element)) {\n\t\t\t\t\t\t// Disconnect the mutation observer.\n\t\t\t\t\t\tobserver.disconnect();\n\t\t\t\t\t\t// Resolve the promise.\n\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\t// Watch for child element updates.\n\t\t\t\tobserver.observe(element, {\n\t\t\t\t\tchildList: true\n\t\t\t\t});\n\t\t\t});\n\t\t\t// Set the promise weak map entry for the passed element.\n\t\t\tchildrenLoadedPromises.set(element, childrenLoadedPromise);\n\t\t}\n\n\t\t// Return the promise for the passed element.\n\t\t// Multiple asynchronous calls of childrenLoaded for the same element should return the same promise.\n\t\treturn childrenLoadedPromises.get(element);\n\n\t};\n\n\t// Attach the synchronous function to the export for optional use.\n\tchildrenLoaded.synchronous = childrenLoadedSynchronous;\n\t// Add shorthand alias for synchronous.\n\tchildrenLoaded.sync = childrenLoaded.synchronous;\n\t// Return the asynchronous function as the export.\n\treturn childrenLoaded;\n\n})();","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","const childrenLoaded = require(\"@alexspirgel/children-loaded\");\n\nclass CoursesWorkshopsList extends ESWPPostList {\n\n\tconstructor() {\n\t\tsuper();\n\t}\n\tasync connectedCallback() {\n\t\tawait childrenLoaded(this);\n\t\tif (this.queryStringFiltering) {\n\t\t\tthis.queryStrings = this.constructor.getQueryStrings();\n\t\t\tconst queryStringsTermIds = this.queryStringSlugsToTermIds(this.queryStrings);\n\t\t\tthis.setFormValues(queryStringsTermIds);\n\t\t}\n\t\tthis.formAttachEventListeners();\n\t\tthis.addUpdateTemplateElementCallback(\"form\",this.formAttachEventListeners);\n\t\tthis.formOnChangeListener();\n\t\tif (this.queryStringFiltering) {\n\t\t\tconst queryStrings = this.constructor.getQueryStrings();\n\t\t\tthis.setFormValues(queryStrings);\n\t\t}\n\t\tthis.paginationAttachEventListeners();\n\t\tthis.addUpdateTemplateElementCallback('pagination', this.paginationAttachEventListeners);\n\t}\n\n\tqueryStringSlugsToTermIds(formData) {\n\t\tformData = Object.assign({}, formData);\n\t\tif (typeof formData['type'] === 'string' && formData['type'].length > 0) {\n\t\t\tconst optionElement = this.templateElements.form.querySelector(`#type option[value=\"${formData['type']}\"]`);\n\t\t\tif (optionElement) {\n\t\t\t\tformData['type'] = optionElement.getAttribute('data-slug');\n\t\t\t}\n\t\t}\n\t\tif (typeof formData['topic'] === 'string' && formData['topic'].length > 0) {\n\t\t\tconst optionElement = this.templateElements.form.querySelector(`#topic option[value=\"${formData['topic']}\"]`);\n\t\t\tif (optionElement) {\n\t\t\t\tformData['topic'] = optionElement.getAttribute('data-slug');\n\t\t\t}\n\t\t}\n\t\tif (typeof formData['author_relationship'] === 'string' && formData['author_relationship'].length > 0) {\n\t\t\tconst optionElement = this.templateElements.form.querySelector(`#author_relationship option[value=\"${formData['author']}\"]`);\n\t\t\tif (optionElement) {\n\t\t\t\tformData['author_relationship'] = optionElement.getAttribute('data-slug');\n\t\t\t}\n\t\t}\n\t\treturn formData;\n\t}\n\n\tformDataTermIdsToSlugs(formData) {\n\t\tformData = Object.assign({}, formData);\n\t\tif (typeof formData['type'] === 'string' && formData['type'].length > 0) {\n\t\t\tconst optionElement = this.templateElements.form.querySelector(`#type option[value=\"${formData['type']}\"]`);\n\t\t\tif (optionElement) {\n\t\t\t\tformData['type'] = optionElement.getAttribute('data-slug');\n\t\t\t}\n\t\t}\n\t\tif (typeof formData['topic'] === 'string' && formData['topic'].length > 0) {\n\t\t\tconst optionElement = this.templateElements.form.querySelector(`#topic option[value=\"${formData['topic']}\"]`);\n\t\t\tif (optionElement) {\n\t\t\t\tformData['topic'] = optionElement.getAttribute('data-slug');\n\t\t\t}\n\t\t}\n\t\tif (typeof formData['author_relationship'] === 'string' && formData['author_relationship'].length > 0) {\n\t\t\tconst optionElement = this.templateElements.form.querySelector(`#author_relationship option[value=\"${formData['author']}\"]`);\n\t\t\tif (optionElement) {\n\t\t\t\tformData['author_relationship'] = optionElement.getAttribute('data-slug');\n\t\t\t}\n\t\t}\n\t\treturn formData;\n\t}\n\t\n\tpaginationAttachEventListeners = () => {\n\t\tconst pagerButtonElements = this.templateElements.pagination.querySelectorAll('button');\n\t\tfor (let buttonElement of pagerButtonElements) {\n\t\t\tbuttonElement.addEventListener('click', this.paginationButtonClickHandler);\n\t\t}\n\t}\n\n\tpaginationButtonClickHandler = async (event) => {\n\t\tconst page = event.target.getAttribute('data-page');\n\t\tawait this.appendPage(page);\n\t}\n\t\n\tgetFormValues() {\n\t\treturn this.constructor.getFormValues(this.templateElements.form);\n\t}\n\n\tsetFormValues(values) {\n\t\treturn this.constructor.setFormValues(this.templateElements.form, values);\n\t}\n\n\tformAttachEventListeners = () => {\n\t\tthis.templateElements.form.addEventListener('submit', this.formSubmitHandler);\n\t\tthis.templateElements.form.querySelector('button[type=\"submit\"]').addEventListener('click', this.formSubmitHandler);\n\t};\n\n\tformSubmitHandler = (event) => {\n\t\tif (event.preventDefault) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t\tthis.submitForm();\n return false;\n\t};\n\n\tformOnChangeListener = () => {\n\t\tconst selects = this.templateElements.form.querySelectorAll('select');\n\n\t\tif (!selects.length) {\n\t\t\treturn;\n\t\t}\n\n\t\tfor (let select of selects) {\n\t\t\tselect.addEventListener('change', (e) => {\n\t\t\t\te.stopPropagation();\n\t\t\t\tthis.formSubmitHandler(e);\n\t\t\t});\n\t\t}\n\t};\n\n\tasync submitForm(page = 1) {\n\t\tconst formData = this.getFormValues();\n\t\tconst args = {\n\t\t\tkey: this.key,\n\t\t\ttemplates: ['results', 'pagination'],\n\t\t\trequest_data: formData,\n\t\t\tpage: page,\n\t\t};\n\t\tconst newTemplates = await this.fetchTemplates(args);\n\t\tthis.updateTemplateElement('results', newTemplates.results);\n\t\tthis.updateTemplateElement('pagination', newTemplates.pagination);\n\t}\n\n\n\tasync getPage(page) {\n\t\tconst args = {\n\t\t\tkey: this.key,\n\t\t\ttemplates: ['results', 'pagination'],\n\t\t\tpage: page\n\t\t};\n\t\tconst newTemplates = await this.fetchTemplates(args);\n\t\treturn newTemplates;\n\t}\n\n\tasync goToPage(page) {\n\t\tconst newTemplates = await this.getPage(page);\n\t\tthis.updateTemplateElement('results', newTemplates.results);\n\t\tthis.updateTemplateElement('pagination', newTemplates.pagination);\n\t}\n\n\tasync appendPage(page) {\n\t\tconst newTemplates = await this.getPage(page);\n\t\tconst resultsContainer = this.querySelector(\n\t\t\t'[data-post-list-template=\"results\"]'\n\t\t);\n\t\tconst htmlObject = document.createElement(\"div\");\n\t\thtmlObject.innerHTML = newTemplates.results;\n\t\tconst newResultsItems = htmlObject.querySelectorAll(\n\t\t\t'[data-post-list-template=\"results\"] > li'\n\t\t);\n\t\tfor (const newResultsItem of newResultsItems) {\n\t\t\tresultsContainer.append(newResultsItem);\n\t\t}\n\t\tthis.updateTemplateElement(\"pagination\", newTemplates.pagination);\n\t}\n\n}\n\ndocument.addEventListener('DOMContentLoaded', () => {\n\tcustomElements.define('post-list-courses-workshops-list', CoursesWorkshopsList, {extends: 'div'});\n});\n"],"names":["module","exports","childrenLoadedPromises","WeakMap","childrenLoadedSynchronous","element","document","readyState","nextSibling","parentNode","childrenLoaded","forceNewPromise","get","childrenLoadedPromise","Promise","resolve","observer","MutationObserver","disconnect","observe","childList","set","sync","synchronous","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","CoursesWorkshopsList","ESWPPostList","constructor","super","connectedCallback","this","queryStringFiltering","queryStrings","getQueryStrings","queryStringsTermIds","queryStringSlugsToTermIds","setFormValues","formAttachEventListeners","addUpdateTemplateElementCallback","formOnChangeListener","paginationAttachEventListeners","formData","Object","assign","length","optionElement","templateElements","form","querySelector","getAttribute","formDataTermIdsToSlugs","pagerButtonElements","pagination","querySelectorAll","buttonElement","addEventListener","paginationButtonClickHandler","async","event","page","target","appendPage","getFormValues","values","formSubmitHandler","preventDefault","submitForm","selects","select","e","stopPropagation","args","key","templates","request_data","newTemplates","fetchTemplates","updateTemplateElement","results","getPage","goToPage","resultsContainer","htmlObject","createElement","innerHTML","newResultsItems","newResultsItem","append","customElements","define","extends"],"sourceRoot":""}