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AAIA,EAAKC,UAAUgC,SAAS,0BAA2B,CACrD,MAAM3B,EAAQN,EAAKO,cAAc,0DAE7BD,GACFuC,YAAW,KACTvC,EAAMwC,OAAO,GACZ,IAEP,GAoBAC,CAAY/C,GAjBYA,KACxB,GAAIA,EAAKC,UAAUgC,SAAS,eAAgB,CAC1C,MAAM3B,EAAQN,EAAKO,cAAc,4CAE7BD,GACFA,EAAMmB,aAAa,cAAe,+BAEtC,GAWAuB,CAAiBhD,EAAK,EAGlBA,EAAOiD,SAAS1C,cAAc,oBAEhCP,GACe,IAAIkD,kBAAiB,CAACC,EAAcC,KACnD,IAAK,MAAMC,KAAYF,EACC,cAAlBE,EAAS3C,OACXX,EAAKC,GACLoD,EAASE,aAEb,IAGOC,QAAQvD,EAAM,CACrBwD,WAAW,G","sources":["webpack://silverstripe-base/./themes/app/src/components/bloomerang-form.js"],"sourcesContent":["const setupPlaceholders = (form) => {\n form.querySelectorAll('label[for]').forEach((label) => {\n try {\n const field = form.querySelector(`#${label.getAttribute('for')}`)\n\n if (field && ['text', 'email', 'tel', 'textarea', 'number'].includes(field.type)) {\n field.placeholder = label.innerText\n label.classList.add('sr-only')\n }\n } catch {\n console.error(label)\n }\n })\n}\n\nconst setupDropdowns = async (form) => {\n const dropdowns = form.querySelectorAll('select')\n\n if (!dropdowns.length) {\n return\n }\n\n const { default: easydropdown } = await import('easydropdown-a11y')\n import('@styles/components/dropdown.css')\n\n dropdowns.forEach((el) => {\n const select = el\n\n if (!select) {\n return\n }\n\n const placeholder = el.querySelector('option[value=\"\"]')\n const label = form.querySelector(`label[for=\"${select.id}\"]`)\n\n if (placeholder && !placeholder.hasAttribute('data-placeholder')) {\n placeholder.setAttribute('data-placeholder', true)\n }\n\n if (label) {\n placeholder.textContent = label.innerText\n label.classList.add('sr-only')\n } else {\n placeholder.textContent = 'Select One'\n }\n\n const opts = {\n behavior: {\n openOnFocus: true,\n maxVisibleItems: 5,\n liveUpdates: true,\n useNativeUiOnMobile: false,\n },\n }\n\n easydropdown(select, opts)\n })\n}\n\nconst handleContact = (form) => {\n if (form.classList.contains('bloomerang-form--contact')) {\n const field = form.querySelector('#CustomInteractionField_154624')\n const params = new URL(window.location).searchParams\n\n if (params.has('subject')) {\n const subject = params.get('subject')\n field.querySelectorAll('option').forEach((option) => {\n if (option.textContent === subject) {\n option.selected = true\n }\n })\n }\n }\n}\n\nconst handleEndow = (form) => {\n if (form.classList.contains('bloomerang-form--endow')) {\n const field = form.querySelector('.section.donation .field.radio [name=\"donation-level\"]')\n\n if (field) {\n setTimeout(() => {\n field.click()\n }, 500)\n }\n }\n}\n\nconst handleGardenTour = (form) => {\n if (form.classList.contains('garden-tour')) {\n const field = form.querySelector('.section.comment .field.comment textarea')\n\n if (field) {\n field.setAttribute('placeholder', 'Please describe your garden.')\n }\n }\n}\n\nconst init = (form) => {\n form.classList.add('is-init')\n\n setupPlaceholders(form)\n setupDropdowns(form)\n\n handleContact(form)\n handleEndow(form)\n handleGardenTour(form)\n}\n\nconst form = document.querySelector('.bloomerang-form')\n\nif (form) {\n const observer = new MutationObserver((mutationList, observer) => {\n for (const mutation of mutationList) {\n if (mutation.type === 'childList') {\n init(form)\n observer.disconnect()\n }\n }\n })\n\n observer.observe(form, {\n childList: true,\n })\n}\n"],"names":["init","form","classList","add","querySelectorAll","forEach","label","field","querySelector","getAttribute","includes","type","placeholder","innerText","console","error","setupPlaceholders","async","dropdowns","length","default","easydropdown","el","select","id","hasAttribute","setAttribute","textContent","behavior","openOnFocus","maxVisibleItems","liveUpdates","useNativeUiOnMobile","setupDropdowns","contains","params","URL","window","location","searchParams","has","subject","get","option","selected","handleContact","setTimeout","click","handleEndow","handleGardenTour","document","MutationObserver","mutationList","observer","mutation","disconnect","observe","childList"],"sourceRoot":""}