{"version":3,"names":["detectSlotChanges","callback","hostElement","config","slotObserver","mutationsList","observer","MutationObserver","observe","shadowRoot","childList","detectMarkupChanges","mutation","type","subtree","characterData","attributes"],"sources":["src/utils/slot-helper.ts"],"sourcesContent":["/**\n * Adds a MutationObserver to hostElements to be able to react to slot content changes.\n * This is especially helpful for complex component structures which need to be reinitialized if the slot content changes.\n * @param callback Callback function that is called when mutionobserver detects a change\n * @param hostElement The element to which the mutionobserver will be attached\n * @param config Optional options for the observer (which mutations to observe) https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver\n */\nexport function detectSlotChanges(callback: () => void, hostElement: any, config?: any): void {\n const slotObserver = (mutationsList) => {\n for (const {} of mutationsList) {\n callback();\n }\n };\n const observer = new MutationObserver(slotObserver);\n if (config) {\n observer.observe(hostElement, { ...config });\n observer.observe(hostElement.shadowRoot, { ...config });\n } else {\n observer.observe(hostElement, { childList: true });\n observer.observe(hostElement.shadowRoot, { childList: true });\n }\n}\n\nexport function detectMarkupChanges(callback: () => void, hostElement: any): void {\n const slotObserver = (mutationsList) => {\n for (const mutation of mutationsList) {\n if (\n mutation.type === \"subtree\" ||\n mutation.type === \"characterData\" ||\n mutation.type === \"attributes\" ||\n mutation.type === \"childList\"\n ) {\n callback();\n }\n }\n };\n const observer = new MutationObserver(slotObserver);\n observer.observe(hostElement, { subtree: true, childList: true, characterData: true, attributes: true });\n observer.observe(hostElement.shadowRoot, { subtree: true, childList: true, characterData: true, attributes: true });\n}\n"],"mappings":"SAOgBA,EAAkBC,EAAsBC,EAAkBC,GACxE,MAAMC,EAAgBC,IACpB,IAAK,UAAYA,EAAe,CAC9BJ,G,GAGJ,MAAMK,EAAW,IAAIC,iBAAiBH,GACtC,GAAID,EAAQ,CACVG,EAASE,QAAQN,EAAa,IAAKC,IACnCG,EAASE,QAAQN,EAAYO,WAAY,IAAKN,G,KACzC,CACLG,EAASE,QAAQN,EAAa,CAAEQ,UAAW,OAC3CJ,EAASE,QAAQN,EAAYO,WAAY,CAAEC,UAAW,M,CAE1D,C,SAEgBC,EAAoBV,EAAsBC,GACxD,MAAME,EAAgBC,IACpB,IAAK,MAAMO,KAAYP,EAAe,CACpC,GACEO,EAASC,OAAS,WAClBD,EAASC,OAAS,iBAClBD,EAASC,OAAS,cAClBD,EAASC,OAAS,YAClB,CACAZ,G,IAIN,MAAMK,EAAW,IAAIC,iBAAiBH,GACtCE,EAASE,QAAQN,EAAa,CAAEY,QAAS,KAAMJ,UAAW,KAAMK,cAAe,KAAMC,WAAY,OACjGV,EAASE,QAAQN,EAAYO,WAAY,CAAEK,QAAS,KAAMJ,UAAW,KAAMK,cAAe,KAAMC,WAAY,MAC9G,Q"}