{"version":3,"file":"functions.mjs","sources":["../../../lib/ui/newMenu/functions.ts"],"sourcesContent":["/*\n * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport type { IFolder } from '../../node/index.ts'\nimport type { NewMenuEntry } from './NewMenu.ts'\n\nimport { scopedGlobals } from '../../globalScope.ts'\nimport { NewMenu } from './NewMenu.ts'\n\n/**\n * Get the NewMenu instance used by the files app.\n */\nexport function getNewFileMenu(): NewMenu {\n\tscopedGlobals.newFileMenu ??= new NewMenu()\n\treturn scopedGlobals.newFileMenu\n}\n\n/**\n * Add a new menu entry to the upload manager menu\n *\n * @param entry - The new file menu entry\n */\nexport function addNewFileMenuEntry(entry: NewMenuEntry): void {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.registerEntry(entry)\n}\n\n/**\n * Remove a previously registered entry from the upload menu\n *\n * @param entry - Entry or id of entry to remove\n */\nexport function removeNewFileMenuEntry(entry: NewMenuEntry | string) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.unregisterEntry(entry)\n}\n\n/**\n * Get the list of registered entries from the upload menu\n *\n * @param context - The current folder to get the available entries\n */\nexport function getNewFileMenuEntries(context?: IFolder): NewMenuEntry[] {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.getEntries(context).sort((a: NewMenuEntry, b: NewMenuEntry) => {\n\t\t// If defined and different, sort by order\n\t\tif (a.order !== undefined\n\t\t\t&& b.order !== undefined\n\t\t\t&& a.order !== b.order) {\n\t\t\treturn a.order - b.order\n\t\t}\n\t\t// else sort by display name\n\t\treturn a.displayName.localeCompare(b.displayName, undefined, { numeric: true, sensitivity: 'base' })\n\t})\n}\n"],"names":[],"mappings":";;AAcO,SAAS,iBAA0B;AACzC,gBAAc,gBAAgB,IAAI,QAAA;AAClC,SAAO,cAAc;AACtB;AAOO,SAAS,oBAAoB,OAA2B;AAC9D,QAAM,cAAc,eAAA;AACpB,SAAO,YAAY,cAAc,KAAK;AACvC;AAOO,SAAS,uBAAuB,OAA8B;AACpE,QAAM,cAAc,eAAA;AACpB,SAAO,YAAY,gBAAgB,KAAK;AACzC;AAOO,SAAS,sBAAsB,SAAmC;AACxE,QAAM,cAAc,eAAA;AACpB,SAAO,YAAY,WAAW,OAAO,EAAE,KAAK,CAAC,GAAiB,MAAoB;AAEjF,QAAI,EAAE,UAAU,UACZ,EAAE,UAAU,UACZ,EAAE,UAAU,EAAE,OAAO;AACxB,aAAO,EAAE,QAAQ,EAAE;AAAA,IACpB;AAEA,WAAO,EAAE,YAAY,cAAc,EAAE,aAAa,QAAW,EAAE,SAAS,MAAM,aAAa,OAAA,CAAQ;AAAA,EACpG,CAAC;AACF;"}