{"version":3,"file":"select-utils.cjs","sources":["../../../../src/components/select/select-utils.ts"],"sourcesContent":["export function toLower(str = \"\") {\n    return str.toLowerCase().replace(/[\\W_]+/g, \"\"); // strip all non-alphanumeric chars\n}\n\nexport function focusSelected(\n    listEl: HTMLElement,\n    selected: string | undefined,\n) {\n    let focusedItem: HTMLElement | null = null;\n    if (selected) {\n        // Move focus to selected option\n        focusedItem = listEl.querySelector(\n            `[aria-selected=\"true\"]:not([hidden])`,\n        );\n    }\n    if (!selected || !focusedItem) {\n        // Move focus to first option if either no selected value or the value could not be found.\n        // This may happen with searchable selects if the currently selected value is filtered out.\n        focusedItem = listEl.querySelector('[role=\"option\"]');\n    }\n    focusedItem?.focus();\n    // Make sure the selected/focused item is visible in the list if it scrolls\n    listEl.scrollTop = focusedItem?.offsetTop || 0;\n}\n"],"names":["listEl","selected","focusedItem","querySelector","focus","scrollTop","offsetTop","str","toLowerCase","replace"],"mappings":"sGAIO,SACHA,EACAC,GAEA,IAAIC,EAAkC,KAClCD,IAEAC,EAAcF,EAAOG,cACjB,2CAGHF,IAAaC,KAGdA,EAAcF,EAAOG,cAAc,oBAEvCD,GAAaE,QAEbJ,EAAOK,UAAYH,GAAaI,WAAa,CACjD,kBAvBO,SAAiBC,EAAM,IAC1B,OAAOA,EAAIC,cAAcC,QAAQ,UAAW,GAChD"}