{"version":3,"names":["hasShadowDom","el","shadowRoot","attachShadow","inheritAttributes","attributes","attributeObject","forEach","attr","hasAttribute","value","getAttribute","removeAttribute","ariaAttributes","inheritAriaAttributes","ignoreList","attributesToInherit","length","filter","includes","hostContext","selector","closest","renderHiddenInput","always","container","name","disabled","required","input","querySelector","ownerDocument","createElement","style","opacity","position","left","top","width","height","margin","padding","classList","add","tabIndex","appendChild","inputMode","mergeFilters","obj1","obj2","Object","assign","removeUndefinedProps","obj","keys","reduce","acc","key","undefined","createHiddenFormInput","document","bottom","float","kebabize","str","replace","$","ofs","toLowerCase","confirmEvent","event","message","confirmed","confirm","preventDefault","getAriaLabel","componentEl","inputId","labelText","labelledBy","componentId","id","labelId","trim","label","getElementById","textContent","setAttribute"],"sources":["./src/utils/helpers.ts"],"sourcesContent":["\n\nexport const intersect = (a: T[], b: T[]) => {\n var setB = new Set(b);\n return [...new Set(a)].filter(x => setB.has(x));\n};\n\nexport const hasShadowDom = (el: HTMLElement) => {\n return !!el.shadowRoot && !!(el as any).attachShadow;\n};\n\nexport type Attributes = { [key: string]: any };\n\nexport const inheritAttributes = (el: HTMLElement, attributes: string[] = []) => {\n const attributeObject: Attributes = {};\n\n attributes.forEach((attr) => {\n if (el.hasAttribute(attr)) {\n const value = el.getAttribute(attr);\n if (value !== null) {\n attributeObject[attr] = el.getAttribute(attr);\n }\n el.removeAttribute(attr);\n }\n });\n\n return attributeObject;\n};\n\nconst ariaAttributes = [\n 'role',\n 'aria-activedescendant',\n 'aria-atomic',\n 'aria-autocomplete',\n 'aria-braillelabel',\n 'aria-brailleroledescription',\n 'aria-busy',\n 'aria-checked',\n 'aria-colcount',\n 'aria-colindex',\n 'aria-colindextext',\n 'aria-colspan',\n 'aria-controls',\n 'aria-current',\n 'aria-describedby',\n 'aria-description',\n 'aria-details',\n 'aria-disabled',\n 'aria-errormessage',\n 'aria-expanded',\n 'aria-flowto',\n 'aria-haspopup',\n 'aria-hidden',\n 'aria-invalid',\n 'aria-keyshortcuts',\n 'aria-label',\n 'aria-labelledby',\n 'aria-level',\n 'aria-live',\n 'aria-multiline',\n 'aria-multiselectable',\n 'aria-orientation',\n 'aria-owns',\n 'aria-placeholder',\n 'aria-posinset',\n 'aria-pressed',\n 'aria-readonly',\n 'aria-relevant',\n 'aria-required',\n 'aria-roledescription',\n 'aria-rowcount',\n 'aria-rowindex',\n 'aria-rowindextext',\n 'aria-rowspan',\n 'aria-selected',\n 'aria-setsize',\n 'aria-sort',\n 'aria-valuemax',\n 'aria-valuemin',\n 'aria-valuenow',\n 'aria-valuetext',\n];\n\nexport const inheritAriaAttributes = (el: HTMLElement, ignoreList?: string[]) => {\n let attributesToInherit = ariaAttributes;\n if (ignoreList && ignoreList.length > 0) {\n attributesToInherit = attributesToInherit.filter((attr) => !ignoreList.includes(attr));\n }\n return inheritAttributes(el, attributesToInherit);\n};\n\nexport const hostContext = (selector: string, el: HTMLElement): boolean => {\n return el.closest(selector) !== null;\n}\n\nexport const renderHiddenInput = (always: boolean, container: HTMLElement, name: string, value: string | undefined | null, disabled: boolean, required?: boolean) => {\n if (always || hasShadowDom(container)) {\n let input = container.querySelector(':scope > input.aux-input') as HTMLInputElement | null;\n\n if (!input) {\n input = container.ownerDocument!.createElement('input');\n input.style.opacity = '0';\n input.style.position = 'absolute';\n input.style.left = '0';\n input.style.top = '0';\n input.style.width = '0px';\n input.style.height = '0px';\n input.style.margin = '0';\n input.style.padding = '0';\n input.classList.add('aux-input');\n input.tabIndex = -1;\n container.appendChild(input);\n }\n\n input.inputMode = 'none';\n input.disabled = disabled;\n input.name = name;\n input.value = value || '';\n input.required = required;\n }\n};\n\n//check if element has siblings of same type\nexport const hasSiblingsOfSameType = (el: HTMLElement) => {\n if (!el.parentNode) {\n return false;\n }\n const parent = el.parentNode as HTMLElement;\n const siblings = Array.from(parent.children).filter(child => child !== el);\n const elType = el.tagName.toLowerCase();\n\n return siblings.some(sibling => sibling.tagName.toLowerCase() === elType);\n}\n\n\nexport const mergeFilters = (obj1: any, obj2: any) => {\n return {\n ...removeUndefinedProps(obj1),\n ...removeUndefinedProps(obj2)\n }\n}\n\nconst removeUndefinedProps = (obj: any) => {\n return Object.keys(obj).reduce((acc, key) => {\n if (obj[key] !== undefined && obj[key] !== null) {\n acc[key] = obj[key];\n }\n return acc;\n }, {});\n}\n\nexport const createHiddenFormInput = (container: HTMLElement, name: string = '', value: any = null, disabled: boolean = false, required: boolean = false): HTMLInputElement | undefined => {\n\n\n const input = document.createElement('input');\n input.name = name;\n input.value = value;\n input.disabled = disabled || null;\n input.required = required || null;\n input.style.opacity = '0';\n input.style.position = 'absolute';\n input.style.left = '50%';\n input.style.bottom = '0';\n input.style.width = '0px';\n input.style.height = '0px';\n input.style.float = 'left';\n input.style.margin = '0';\n input.style.padding = '0';\n\n container.appendChild(input);\n\n\n return input;\n}\n\nexport const kebabize = (str) => str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? \"-\" : \"\") + $.toLowerCase());\n\n\nexport const confirmEvent = (event: Event, message: string) => {\n\n const confirmed = confirm(message);\n\n if (!confirmed) {\n event.preventDefault();\n }\n\n}\n\nexport const getAriaLabel = (\n componentEl: HTMLElement,\n inputId: string\n): { label: Element | null; labelId: string; labelText: string | null | undefined } => {\n let labelText;\n\n // If the user provides their own label via the aria-labelledby attr\n // we should use that instead of looking for an ion-label\n const labelledBy = componentEl.getAttribute('aria-labelledby');\n\n // Grab the id off of the component in case they are using\n // a custom label using the label element\n const componentId = componentEl.id;\n\n let labelId = labelledBy !== null && labelledBy.trim() !== '' ? labelledBy : inputId + '-lbl';\n\n let label =\n labelledBy !== null && labelledBy.trim() !== '' ? document.getElementById(labelledBy) : null;\n\n if (label) {\n if (labelledBy === null) {\n label.id = labelId;\n }\n\n labelText = label.textContent;\n label.setAttribute('aria-hidden', 'true');\n\n } else if (componentId.trim() !== '') {\n label = document.querySelector(`label[for=\"${componentId}\"]`);\n\n if (label) {\n if (label.id !== '') {\n labelId = label.id;\n } else {\n label.id = labelId = `${componentId}-lbl`;\n }\n\n labelText = label.textContent;\n }\n }\n\n return { label, labelId, labelText };\n};\n"],"mappings":"MAOaA,EAAgBC,KAClBA,EAAGC,cAAiBD,EAAWE,aAKnC,MAAMC,EAAoB,CAACH,EAAiBI,EAAuB,MACxE,MAAMC,EAA8B,GAEpCD,EAAWE,SAASC,IAClB,GAAIP,EAAGQ,aAAaD,GAAO,CACzB,MAAME,EAAQT,EAAGU,aAAaH,GAC9B,GAAIE,IAAU,KAAM,CAClBJ,EAAgBE,GAAQP,EAAGU,aAAaH,E,CAE1CP,EAAGW,gBAAgBJ,E,KAIvB,OAAOF,CAAe,EAGxB,MAAMO,EAAiB,CACrB,OACA,wBACA,cACA,oBACA,oBACA,8BACA,YACA,eACA,gBACA,gBACA,oBACA,eACA,gBACA,eACA,mBACA,mBACA,eACA,gBACA,oBACA,gBACA,cACA,gBACA,cACA,eACA,oBACA,aACA,kBACA,aACA,YACA,iBACA,uBACA,mBACA,YACA,mBACA,gBACA,eACA,gBACA,gBACA,gBACA,uBACA,gBACA,gBACA,oBACA,eACA,gBACA,eACA,YACA,gBACA,gBACA,gBACA,kB,MAGWC,EAAwB,CAACb,EAAiBc,KACrD,IAAIC,EAAsBH,EAC1B,GAAIE,GAAcA,EAAWE,OAAS,EAAG,CACvCD,EAAsBA,EAAoBE,QAAQV,IAAUO,EAAWI,SAASX,I,CAElF,OAAOJ,EAAkBH,EAAIe,EAAoB,E,MAGtCI,EAAc,CAACC,EAAkBpB,IACrCA,EAAGqB,QAAQD,KAAc,K,MAGrBE,EAAoB,CAACC,EAAiBC,EAAwBC,EAAchB,EAAkCiB,EAAmBC,KAC5I,GAAIJ,GAAUxB,EAAayB,GAAY,CACrC,IAAII,EAAQJ,EAAUK,cAAc,4BAEpC,IAAKD,EAAO,CACVA,EAAQJ,EAAUM,cAAeC,cAAc,SAC/CH,EAAMI,MAAMC,QAAU,IACtBL,EAAMI,MAAME,SAAW,WACvBN,EAAMI,MAAMG,KAAO,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