{"version":3,"file":"appName.mjs","sources":["../../src/utils/utils.ts","../../src/utils/appName.ts"],"sourcesContent":["/*!\n * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\n/**\n * Single tone function decorator\n *\n * @param func - Function\n */\nexport function once<T extends unknown[], K>(func: (...args: T) => K): ((...args: T) => K) {\n\tlet wasCalled = false\n\tlet result: K\n\n\treturn (...args: T): K => {\n\t\tif (!wasCalled) {\n\t\t\twasCalled = true\n\t\t\tresult = func(...args)\n\t\t}\n\t\treturn result\n\t}\n}\n","/**\n * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport { loadState } from '@nextcloud/initial-state'\nimport { inject } from 'vue'\nimport { logger } from './logger.ts'\nimport { once } from './utils.ts'\n\nlet realAppName = 'missing-app-name'\ntry {\n\trealAppName = appName\n} catch {\n\tlogger.error('The `@nextcloud/vue` library was used without setting / replacing the `appName`.')\n}\nexport const APP_NAME = realAppName\n\nlet realAppVersion = ''\ntry {\n\trealAppVersion = appVersion\n} catch {\n\tlogger.error('The `@nextcloud/vue` library was used without setting / replacing the `appVersion`.')\n}\nexport const APP_VERSION = realAppVersion\n\n/**\n * Get the app name (the Nextcloud app id).\n */\nexport function useAppName(): string {\n\treturn inject<string>('appName', APP_NAME)\n}\n\n/**\n * Get the localized app name.\n */\nexport const useLocalizedAppName = once(() => {\n\tconst apps = loadState<{ id: string, name: string }[]>('core', 'apps', [])\n\tconst realAppName = useAppName()\n\n\treturn apps.find(({ id }) => id === realAppName)?.name ?? realAppName\n})\n"],"names":["realAppName"],"mappings":";;;AAAA;AAAA;AAAA;AAAA;AAUO,SAAS,KAA6B,MAA8C;AAC1F,MAAI,YAAY;AAChB,MAAI;AAEJ,SAAO,IAAI,SAAe;AACzB,QAAI,CAAC,WAAW;AACf,kBAAY;AACZ,eAAS,KAAK,GAAG,IAAI;AAAA,IACtB;AACA,WAAO;AAAA,EACR;AACD;ACXA,IAAI,cAAc;AAClB,IAAI;AACH,gBAAc;AACf,QAAQ;AACP,SAAO,MAAM,kFAAkF;AAChG;AACO,MAAM,WAAW;AAExB,IAAI,iBAAiB;AACrB,IAAI;AACH,mBAAiB;AAClB,QAAQ;AACP,SAAO,MAAM,qFAAqF;AACnG;AACO,MAAM,cAAc;AAKpB,SAAS,aAAqB;AACpC,SAAO,OAAe,WAAW,QAAQ;AAC1C;AAKO,MAAM,sBAAsB,KAAK,MAAM;AAC7C,QAAM,OAAO,UAA0C,QAAQ,QAAQ,CAAA,CAAE;AACzE,QAAMA,eAAc,WAAA;AAEpB,SAAO,KAAK,KAAK,CAAC,EAAE,SAAS,OAAOA,YAAW,GAAG,QAAQA;AAC3D,CAAC;"}