{"version":3,"sources":["../src/profiles/services.ts"],"names":["isProfileWithServices","source","deriveOptionalServices","sources","merged","services","service","resolveUUID"],"mappings":"qCAmBA,SAASA,CAAAA,CAAsBC,EAA+D,CAC5F,OAAO,CAAC,KAAA,CAAM,OAAA,CAAQA,CAAM,CAAA,EAAK,KAAA,CAAM,OAAA,CAASA,EAA+B,QAAQ,CACzF,CA8BO,SAASC,CAAAA,CAAAA,GAA0BC,EAA6C,CACrF,IAAMC,CAAAA,CAAS,IAAI,GAAA,CACnB,IAAA,IAAWH,KAAUE,CAAAA,CAAS,CAC5B,IAAME,CAAAA,CAAWL,CAAAA,CAAsBC,CAAM,CAAA,CAAIA,CAAAA,CAAO,QAAA,CAAWA,CAAAA,CACnE,IAAA,IAAWK,CAAAA,IAAWD,EACpBD,CAAAA,CAAO,GAAA,CAAIG,CAAAA,CAAYD,CAAO,CAAC,EAEnC,CACA,OAAO,CAAC,GAAGF,CAAM,CACnB","file":"chunk-CE7TTCQQ.mjs","sourcesContent":["import { resolveUUID } from '../uuid';\n\n/**\n * A profile class that declares the GATT services it (and its device family) may\n * reach after connection, as a static `services` array. {@link deriveOptionalServices}\n * reads this so a caller can pass the profile itself instead of hand-copying its\n * service UUIDs into `optionalServices`.\n */\nexport interface ProfileWithServices {\n  readonly services: readonly string[];\n}\n\n/**\n * A source of service UUIDs accepted by {@link deriveOptionalServices}: either a\n * profile class carrying a static `services` array, or a raw list of service\n * names / 4-8-hex / full 128-bit UUID strings.\n */\nexport type OptionalServicesSource = ProfileWithServices | readonly string[];\n\nfunction isProfileWithServices(source: OptionalServicesSource): source is ProfileWithServices {\n  return !Array.isArray(source) && Array.isArray((source as ProfileWithServices).services);\n}\n\n/**\n * Flatten one or more profiles / service-UUID arrays into a single canonical,\n * de-duped, lowercase 128-bit `string[]` suitable for `optionalServices` (or\n * {@link Beacio.registerServices}). Every entry is resolved via the core\n * {@link resolveUUID} (names like `'battery_service'`, 4/8-hex, and full UUIDs\n * are all accepted) and de-duped while preserving first-seen order.\n *\n * This retires the hand-maintained parallel `optionalServices` lists a multi-\n * device integration would otherwise keep in sync: declare the profiles (or a\n * vendor bundle such as `StorzBickel.allServices()`) once and derive the list.\n *\n * Pure and idempotent: `deriveOptionalServices(deriveOptionalServices(x))` equals\n * `deriveOptionalServices(x)`, because the output is already canonical UUIDs that\n * {@link resolveUUID} passes through unchanged.\n *\n * @param sources - Profile classes (with a static `services` array) and/or raw\n *   service-UUID arrays (names, 4/8-hex, or full 128-bit UUID strings).\n * @returns De-duped canonical lowercase 128-bit service UUIDs, first-seen order.\n * @throws {TypeError} If any value is not a resolvable UUID or known SIG name.\n *\n * @example\n * ```ts\n * import { deriveOptionalServices, NordicUARTProfile, HeartRateProfile } from '@beacio/core/profiles';\n *\n * const optionalServices = deriveOptionalServices(NordicUARTProfile, HeartRateProfile);\n * const device = await ble.requestDevice({ acceptAllDevices: true, optionalServices });\n * ```\n */\nexport function deriveOptionalServices(...sources: OptionalServicesSource[]): string[] {\n  const merged = new Set<string>();\n  for (const source of sources) {\n    const services = isProfileWithServices(source) ? source.services : source;\n    for (const service of services) {\n      merged.add(resolveUUID(service));\n    }\n  }\n  return [...merged];\n}\n"]}