{"version":3,"file":"dom-kkaJ4XgI.js","sources":["../../Assets/Scripts/utils/dom.ts"],"sourcesContent":["export const createElementFromTemplate = (\n $template: HTMLTemplateElement,\n): HTMLElement | null => {\n if (!$template) {\n return null;\n }\n\n const $clonedNode = $template.content.cloneNode(true);\n\n if (!($clonedNode instanceof DocumentFragment)) {\n return null;\n }\n\n const $element = $clonedNode.firstElementChild;\n\n if (!$element || !($element instanceof HTMLElement)) {\n return null;\n }\n\n return $element;\n};\n\nexport const getChildIndex = ($element: HTMLElement): number => {\n const $parentElement = $element.parentElement;\n\n if (!$parentElement) {\n return -1;\n }\n\n return Array.from($parentElement.children).findIndex(\n ($childNode) => $childNode === $element,\n );\n};\n\nexport const findParentWithAttribute = (\n $element: HTMLElement | null,\n attributeName: string,\n): HTMLElement | null => {\n if ($element && $element.hasAttribute(attributeName)) {\n return $element;\n }\n\n // If not, continue to the parent element\n if ($element?.parentElement) {\n return findParentWithAttribute($element.parentElement, attributeName);\n }\n\n // If there are no more parent elements and the attribute is not found, return null\n return null;\n};\n"],"names":["createElementFromTemplate","$template","$clonedNode","$element","getChildIndex","$parentElement","$childNode"],"mappings":"AAAa,MAAAA,EACXC,GACuB,CACvB,GAAI,CAACA,EACI,OAAA,KAGT,MAAMC,EAAcD,EAAU,QAAQ,UAAU,EAAI,EAEhD,GAAA,EAAEC,aAAuB,kBACpB,OAAA,KAGT,MAAMC,EAAWD,EAAY,kBAE7B,MAAI,CAACC,GAAY,EAAEA,aAAoB,aAC9B,KAGFA,CACT,EAEaC,EAAiBD,GAAkC,CAC9D,MAAME,EAAiBF,EAAS,cAEhC,OAAKE,EAIE,MAAM,KAAKA,EAAe,QAAQ,EAAE,UACxCC,GAAeA,IAAeH,CAAA,EAJxB,EAMX"}