{"version":3,"file":"utils-uWgXwWLu.cjs","names":[],"sources":["../src/utils/aria.ts","../src/utils/cn.ts"],"sourcesContent":["/**\r\n * ARIA helper utilities for @bquery/ui components.\r\n */\r\n\r\n/** Sets or removes an aria attribute based on a boolean condition. */\r\nexport function ariaBoolean(\r\n  el: Element,\r\n  attribute: string,\r\n  value: boolean,\r\n): void {\r\n  if (value) {\r\n    el.setAttribute(attribute, 'true');\r\n  } else {\r\n    el.setAttribute(attribute, 'false');\r\n  }\r\n}\r\n\r\n/** Links an element as described-by another element's id. */\r\nexport function linkDescribedBy(el: Element, ...ids: string[]): void {\r\n  const existing = el.getAttribute('aria-describedby');\r\n  const existingIds = existing ? existing.split(' ').filter(Boolean) : [];\r\n  const merged = [...new Set([...existingIds, ...ids.filter(Boolean)])];\r\n  if (merged.length > 0) {\r\n    el.setAttribute('aria-describedby', merged.join(' '));\r\n  }\r\n}\r\n\r\n/** Remove ids from aria-describedby. */\r\nexport function unlinkDescribedBy(el: Element, ...ids: string[]): void {\r\n  const existing = el.getAttribute('aria-describedby');\r\n  if (!existing) return;\r\n  const remaining = existing\r\n    .split(' ')\r\n    .filter((id) => !ids.includes(id))\r\n    .join(' ');\r\n  if (remaining) {\r\n    el.setAttribute('aria-describedby', remaining);\r\n  } else {\r\n    el.removeAttribute('aria-describedby');\r\n  }\r\n}\r\n\r\n/** Sets aria-labelledby. */\r\nexport function setLabelledBy(el: Element, ...ids: string[]): void {\r\n  const valid = ids.filter(Boolean);\r\n  if (valid.length > 0) {\r\n    el.setAttribute('aria-labelledby', valid.join(' '));\r\n  } else {\r\n    el.removeAttribute('aria-labelledby');\r\n  }\r\n}\r\n\r\n/** Announce a message via an ARIA live region. */\r\nexport function announce(\r\n  message: string,\r\n  politeness: 'polite' | 'assertive' = 'polite',\r\n): void {\r\n  const existing = document.getElementById('bq-aria-live');\r\n  const el: HTMLElement = (existing as HTMLElement | null) ?? (() => {\r\n    const div = document.createElement('div');\r\n    div.id = 'bq-aria-live';\r\n    div.setAttribute('aria-live', politeness);\r\n    div.setAttribute('aria-relevant', 'additions');\r\n    div.setAttribute('aria-atomic', 'true');\r\n    Object.assign(div.style, {\r\n      position: 'absolute',\r\n      width: '1px',\r\n      height: '1px',\r\n      padding: '0',\r\n      overflow: 'hidden',\r\n      clip: 'rect(0,0,0,0)',\r\n      whiteSpace: 'nowrap',\r\n      border: '0',\r\n    });\r\n    document.body.appendChild(div);\r\n    return div;\r\n  })();\r\n  el.setAttribute('aria-live', politeness);\r\n  el.textContent = '';\r\n  requestAnimationFrame(() => { el.textContent = message; });\r\n}\r\n","/**\r\n * Class name utility - similar to clsx / classnames.\r\n *\r\n * Accepts any mix of strings, string arrays, or conditional record objects\r\n * and returns a single space-separated class string.\r\n */\r\n\r\ntype ClassValue =\r\n  | string\r\n  | number\r\n  | null\r\n  | undefined\r\n  | boolean\r\n  | ClassValue[]\r\n  | Record<string, unknown>;\r\n\r\nexport function cn(...inputs: ClassValue[]): string {\r\n  const classes: string[] = [];\r\n  for (const input of inputs) {\r\n    if (!input) continue;\r\n    if (typeof input === 'string' || typeof input === 'number') {\r\n      classes.push(String(input));\r\n    } else if (Array.isArray(input)) {\r\n      const inner = cn(...input);\r\n      if (inner) classes.push(inner);\r\n    } else if (typeof input === 'object') {\r\n      for (const [key, value] of Object.entries(input)) {\r\n        if (value) classes.push(key);\r\n      }\r\n    }\r\n  }\r\n  return classes.join(' ');\r\n}\r\n"],"mappings":";;;;;AAKA,SAAgB,YACd,IACA,WACA,OACM;AACN,KAAI,MACF,IAAG,aAAa,WAAW,OAAO;KAElC,IAAG,aAAa,WAAW,QAAQ;;;AAKvC,SAAgB,gBAAgB,IAAa,GAAG,KAAqB;CACnE,MAAM,WAAW,GAAG,aAAa,mBAAmB;CACpD,MAAM,cAAc,WAAW,SAAS,MAAM,IAAI,CAAC,OAAO,QAAQ,GAAG,EAAE;CACvE,MAAM,SAAS,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,aAAa,GAAG,IAAI,OAAO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