{"version":3,"file":"js/event_registrations-534106dac42132ade906.js","mappings":"8GAWA,SAASA,KACLC,EAAAA,EAAAA,GAAY,0BAA2BC,EAC3C,CAEA,SAASA,EAAwBC,GACZC,SAASC,eAAeF,GAChCG,iBAAiB,UAAUC,KASxC,SAAiCJ,EAAIK,GACjCC,MAAM,6BAA6BN,WAC9BO,MAAKC,GAAYA,EAASC,SAC1BF,MAAKG,IACiB,OAAfA,EAAKL,MACLA,EAAMM,MAAQ,EAEdN,EAAMM,MAAQC,WAAWF,EAAKL,OAAOQ,QAAQ,EACjD,GAEZ,CAfQC,CAHeV,EAAMW,OAAOJ,MAChBP,EAAMW,OAAOC,QAAQ,MACfC,cAAc,uBACM,GAE9C,CApBAhB,SAASE,iBAAiB,oBAAoB,WAC1CN,GACJ,IAEAI,SAASE,iBAAiB,cAAc,WACpCN,GACJ,G,uDCTA,MAAMC,EAAcA,CAACoB,EAAkBC,KAClB,IAAIC,kBAAiBC,IAClC,IAAK,MAAMC,KAAYD,EACnBC,EAASC,WAAWC,SAAQC,IAExB,GAAIA,EAAKC,WAAaC,KAAKC,aAAc,CACrC,MAAMb,EAASU,EAAKR,cAAc,IAAIC,MAAuBO,EAAKT,QAAQ,IAAIE,KAC1EH,GACAI,EAAYJ,EAAOf,GAE3B,IAER,IAGK6B,QAAQ5B,SAAS6B,KAAM,CAC5BC,WAAW,EACXC,YAAY,EACZC,eAAe,EACfC,SAAS,GACX,C","sources":["webpack://app/./app/javascript/packs/event_registrations.js","webpack://app/./app/javascript/shared/form_observer.js"],"sourcesContent":["import {addObserver} from '../shared/form_observer'\n\n\ndocument.addEventListener(\"DOMContentLoaded\", function () {\n addListeners()\n})\n\ndocument.addEventListener('turbo:load', function () {\n addListeners()\n})\n\nfunction addListeners() {\n addObserver('event-registration-type', set_registration_amount)\n}\n\nfunction set_registration_amount(id) {\n const attendee = document.getElementById(id);\n attendee.addEventListener('change', event => {\n const typeId = event.target.value;\n const row = event.target.closest('tr');\n const price = row.querySelector('.registration-price');\n fetch_registration_type(typeId, price);\n })\n}\n\n\nfunction fetch_registration_type(id, price) {\n fetch(`/event_registration_types/${id}/fetch`)\n .then(response => response.json())\n .then(type => {\n if (type.price === null) {\n price.value = 0.00;\n } else {\n price.value = parseFloat(type.price).toFixed(2);\n }\n });\n}\n","const addObserver = (observedSelector, functionObj) => {\n const observer = new MutationObserver(mutations => {\n for (const mutation of mutations) {\n mutation.addedNodes.forEach(node => {\n // Check if the node is an element and find the first matching element with the observedClass\n if (node.nodeType === Node.ELEMENT_NODE) {\n const target = node.querySelector(`.${observedSelector}`) || node.closest(`.${observedSelector}`);\n if (target) {\n functionObj(target.id);\n }\n }\n });\n }\n });\n\n observer.observe(document.body, {\n childList: true,\n attributes: true,\n characterData: true,\n subtree: true,\n });\n};\n\nexport { addObserver };\n"],"names":["addListeners","addObserver","set_registration_amount","id","document","getElementById","addEventListener","event","price","fetch","then","response","json","type","value","parseFloat","toFixed","fetch_registration_type","target","closest","querySelector","observedSelector","functionObj","MutationObserver","mutations","mutation","addedNodes","forEach","node","nodeType","Node","ELEMENT_NODE","observe","body","childList","attributes","characterData","subtree"],"sourceRoot":""}