{"version":3,"file":"_id-generator-chunk.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/cdk/a11y/id-generator.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {APP_ID, inject, Service} from '@angular/core';\n\n/**\n * Keeps track of the ID count per prefix. This helps us make the IDs a bit more deterministic\n * like they were before the service was introduced. Note that ideally we wouldn't have to do\n * this, but there are some internal tests that rely on the IDs.\n *\n * Note: use a map to avoid conflicts with built-in properties.\n */\nconst counters = new Map<string, number>();\n\n/** Service that generates unique IDs for DOM nodes. */\n@Service()\nexport class _IdGenerator {\n  private _appId = inject(APP_ID);\n  private static _infix = `a${Math.floor(Math.random() * 100000).toString()}`;\n\n  /**\n   * Generates a unique ID with a specific prefix.\n   * @param prefix Prefix to add to the ID.\n   * @param randomize Add a randomized infix string.\n   */\n  getId(prefix: string, randomize: boolean = false): string {\n    // Omit the app ID if it's the default `ng`. Since the vast majority of pages have one\n    // Angular app on them, we can reduce the amount of breakages by not adding it.\n    if (this._appId !== 'ng') {\n      prefix += this._appId;\n    }\n\n    let count = counters.get(prefix);\n\n    if (count === undefined) {\n      count = 0;\n    } else {\n      count++;\n    }\n\n    counters.set(prefix, count);\n    return `${prefix}${randomize ? _IdGenerator._infix + '-' : ''}${count}`;\n  }\n}\n"],"names":["counters","Map","_IdGenerator","_appId","inject","APP_ID","_infix","Math","floor","random","toString","getId","prefix","randomize","count","get","undefined","set","deps","target","i0","ɵɵFactoryTarget","Service","decorators"],"mappings":";;;AAiBA,MAAMA,QAAQ,GAAG,IAAIC,GAAG,EAAkB;MAI7BC,YAAY,CAAA;AACfC,EAAAA,MAAM,GAAGC,MAAM,CAACC,MAAM,CAAC;AACvB,EAAA,OAAOC,MAAM,GAAG,CAAA,CAAA,EAAIC,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,MAAM,EAAE,GAAG,MAAM,CAAC,CAACC,QAAQ,EAAE,CAAA,CAAE;AAO3EC,EAAAA,KAAKA,CAACC,MAAc,EAAEC,SAAA,GAAqB,KAAK,EAAA;AAG9C,IAAA,IAAI,IAAI,CAACV,MAAM,KAAK,IAAI,EAAE;MACxBS,MAAM,IAAI,IAAI,CAACT,MAAM;AACvB,IAAA;AAEA,IAAA,IAAIW,KAAK,GAAGd,QAAQ,CAACe,GAAG,CAACH,MAAM,CAAC;IAEhC,IAAIE,KAAK,KAAKE,SAAS,EAAE;AACvBF,MAAAA,KAAK,GAAG,CAAC;AACX,IAAA,CAAA,MAAO;AACLA,MAAAA,KAAK,EAAE;AACT,IAAA;AAEAd,IAAAA,QAAQ,CAACiB,GAAG,CAACL,MAAM,EAAEE,KAAK,CAAC;AAC3B,IAAA,OAAO,CAAA,EAAGF,MAAM,CAAA,EAAGC,SAAS,GAAGX,YAAY,CAACI,MAAM,GAAG,GAAG,GAAG,EAAE,CAAA,EAAGQ,KAAK,CAAA,CAAE;AACzE,EAAA;;;;;UA1BWZ,YAAY;AAAAgB,IAAAA,IAAA,EAAA,EAAA;AAAAC,IAAAA,MAAA,EAAAC,EAAA,CAAAC,eAAA,CAAAC;AAAA,GAAA,CAAA;;;;;UAAZpB;AAAY,GAAA,CAAA;;;;;;QAAZA,YAAY;AAAAqB,EAAAA,UAAA,EAAA,CAAA;UADxBD;;;;;;"}