{"version":3,"file":"index.mjs","names":["IconCopy","IconMove","$emit","_openBlock","_createBlock","_unref","_withCtx","_createElementVNode","_toDisplayString","_createCommentVNode","_createElementBlock","_sfc_main","GenericDialog"],"sources":["../lib/conflict-picker.ts","../lib/filepicker-builder.ts","../lib/public-auth.ts","../lib/components/GenericDialog.vue","../lib/components/GenericDialog.vue","../lib/dialogs.ts"],"sourcesContent":["/*!\n * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport type { INode } from '@nextcloud/files'\n\nimport { spawnDialog } from '@nextcloud/vue/functions/dialog'\nimport { defineAsyncComponent } from 'vue'\n\nexport type ConflictInput = File | FileSystemEntry | INode\n\nexport interface ConflictResolutionResult<T extends ConflictInput> {\n\t/**\n\t * The selected incoming nodes.\n\t * Meaning this selected incoming nodes should overwrite the existing nodes.\n\t */\n\tselected: T[]\n\n\t/**\n\t * The incoming nodes which should be renamed.\n\t * Meaning those nodes still should be uploaded but with a new unique name to not override existing nodes.\n\t */\n\trenamed: T[]\n\n\t/**\n\t * The nodes not selected for upload.\n\t * Meaning those incoming nodes should be skipped from the action and not be used.\n\t */\n\tskipped: T[]\n}\n\nexport interface ConflictPickerOptions {\n\t/**\n\t * The container for the conflict picker dialog.\n\t * Defaults to the `<body>`.\n\t */\n\tcontainer?: string\n\t/**\n\t * When this is set to true a hint is shown that conflicts in directories are handles recursively\n\t * You still need to call this function for each directory separately.\n\t */\n\trecursive?: boolean\n\n\t/**\n\t * When this is set to true a hint is shown that any folder content will be overwritten.\n\t * This is useful if the operation with conflicts is a move that will not perform any \"write-into\" logic.\n\t */\n\toverwriting?: boolean\n}\n\n/**\n * Open the conflict resolver for uploading nodes.\n * Given the current content of the directory and the conflicting new nodes,\n * this will ask the user for resolving the conflicts and return the conflict resolution.\n *\n * @param dirname - The directory name with conflicts (its name is shown in the description)\n * @param conflicts - The incoming nodes\n * @param content - The current content of the directory (existing nodes)\n * @param options Optional settings for the conflict picker\n *\n * @return The conflict resolution or null if the user aborted.\n */\nexport async function openConflictPicker<T extends ConflictInput>(\n\tdirname: string | undefined,\n\tconflicts: T[],\n\tcontent: INode[],\n\toptions?: ConflictPickerOptions,\n): Promise<ConflictResolutionResult<T> | null> {\n\tconst ConflictPicker = defineAsyncComponent(() => import('./components/ConflictPicker/ConflictPicker.vue'))\n\n\tconst incoming: T[] = []\n\tconst existing: INode[] = []\n\tfor (const node of content) {\n\t\tif (isConflictingNode(node)) {\n\t\t\texisting.push(node)\n\t\t\tincoming.push(conflicts[indexOf(node)]!)\n\t\t}\n\t}\n\n\tif (conflicts.length === 0 || content.length === 0) {\n\t\tthrow new Error('ConflictPicker: files and conflicts must not be empty')\n\t}\n\n\tif (conflicts.length !== content.length) {\n\t\tthrow new Error('ConflictPicker: files and conflicts must have the same length. Make sure you filter out non conflicting files from the conflicts array.')\n\t}\n\n\treturn await spawnDialog(ConflictPicker, {\n\t\tdirname,\n\t\texisting,\n\t\tincoming,\n\t\tisOverwriting: options?.overwriting === true,\n\t\trecursiveUpload: options?.recursive === true,\n\t}, {\n\t\tcontainer: options?.container,\n\t}) as (ConflictResolutionResult<T> | null)\n\n\t/**\n\t * Check whether a given node from the `content` is part of the `conflicts`.\n\t *\n\t * @param node - The node to check\n\t */\n\tfunction isConflictingNode(node: INode) {\n\t\treturn conflicts.some((entry) => nodeIsConflict(node, entry))\n\t}\n\n\t/**\n\t * Get the index of this node in the conflicts\n\t *\n\t * @param node - The node to check\n\t */\n\tfunction indexOf(node: INode): number {\n\t\treturn conflicts.findIndex((entry) => nodeIsConflict(node, entry))\n\t}\n\n\t/**\n\t * Check if the given node is the reason for the conflict\n\t *\n\t * @param node - The node to check\n\t * @param conflict - The conflict to check\n\t */\n\tfunction nodeIsConflict(node: INode, conflict: ConflictInput): boolean {\n\t\tif ('basename' in conflict) {\n\t\t\treturn conflict.basename === node.basename\n\t\t}\n\t\treturn conflict.name === node.basename\n\t}\n}\n","/**\n * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport type { INode } from '@nextcloud/files'\nimport type { IFilePickerButton, IFilePickerButtonFactory, IFilePickerCanPick, IFilePickerFilter } from './components/types.ts'\n\nimport IconMove from '@mdi/svg/svg/folder-move.svg?raw'\nimport IconCopy from '@mdi/svg/svg/folder-multiple.svg?raw'\nimport { basename } from '@nextcloud/paths'\nimport { spawnDialog } from '@nextcloud/vue/functions/dialog'\nimport { n, t } from './utils/l10n.ts'\nimport { logger } from './utils/logger.ts'\n\n/**\n * @deprecated\n */\nexport enum FilePickerType {\n\tChoose = 1,\n\tMove = 2,\n\tCopy = 3,\n\tCopyMove = 4,\n\tCustom = 5,\n}\n\n/**\n * Error that is thrown in the rejected promise when the FilePicker was closed\n */\nexport class FilePickerClosed extends Error {}\n\nexport class FilePicker<IsMultiSelect extends boolean> {\n\tprivate title: string\n\tprivate multiSelect: IsMultiSelect\n\tprivate mimeTypeFilter: string[]\n\tprivate directoriesAllowed: boolean\n\tprivate noMenu: boolean\n\tprivate buttons: IFilePickerButton[] | IFilePickerButtonFactory\n\tprivate path?: string\n\tprivate filter?: IFilePickerFilter\n\tprivate canPick?: IFilePickerCanPick\n\tprivate container?: string\n\tprivate disabledNavigation: boolean\n\n\tpublic constructor(\n\t\ttitle: string,\n\t\tmultiSelect: IsMultiSelect,\n\t\tmimeTypeFilter: string[],\n\t\tdirectoriesAllowed: boolean,\n\t\tnoMenu: boolean,\n\t\tbuttons: IFilePickerButton[] | IFilePickerButtonFactory,\n\t\tpath?: string,\n\t\tfilter?: IFilePickerFilter,\n\t\tcanPick?: IFilePickerCanPick,\n\t\tcontainer?: string,\n\t\tdisabledNavigation = false,\n\t) {\n\t\tthis.title = title\n\t\tthis.multiSelect = multiSelect\n\t\tthis.mimeTypeFilter = mimeTypeFilter\n\t\tthis.directoriesAllowed = directoriesAllowed\n\t\tthis.noMenu = noMenu\n\t\tthis.path = path\n\t\tthis.filter = filter\n\t\tthis.canPick = canPick\n\t\tthis.buttons = buttons\n\t\tthis.container = container\n\t\tthis.disabledNavigation = disabledNavigation\n\t}\n\n\t/**\n\t * Pick files using the FilePicker.\n\t *\n\t * @return Promise with array of picked files or rejected promise on close without picking\n\t */\n\tpublic async pickNodes(): Promise<INode[]> {\n\t\tconst { default: FilePickerVue } = await import('./components/FilePicker/FilePicker.vue')\n\n\t\tconst nodes = await spawnDialog(FilePickerVue, {\n\t\t\tallowPickDirectory: this.directoriesAllowed,\n\t\t\tnoMenu: this.noMenu,\n\t\t\tbuttons: this.buttons,\n\t\t\tname: this.title,\n\t\t\tpath: this.path,\n\t\t\tmimetypeFilter: this.mimeTypeFilter,\n\t\t\tmultiselect: this.multiSelect,\n\t\t\tfilterFn: this.filter,\n\t\t\tcanPickFn: this.canPick,\n\t\t\tdisabledNavigation: this.disabledNavigation,\n\t\t}, {\n\t\t\tcontainer: this.container,\n\t\t})\n\n\t\tif (!Array.isArray(nodes) || nodes.length === 0) {\n\t\t\tthrow new FilePickerClosed('FilePicker: No nodes selected')\n\t\t}\n\n\t\treturn nodes\n\t}\n\n\t/**\n\t * Pick files using the FilePicker\n\t *\n\t * @return Promise with array of paths of picked files or rejected promise on close without picking\n\t */\n\tpublic async pick(): Promise<IsMultiSelect extends true ? string[] : string> {\n\t\tconst nodes = await this.pickNodes()\n\t\tif (this.multiSelect) {\n\t\t\treturn nodes.map((node) => node.path) as (IsMultiSelect extends true ? string[] : string)\n\t\t}\n\t\tconst path = nodes[0]?.path ?? '/'\n\t\treturn path as (IsMultiSelect extends true ? string[] : string)\n\t}\n}\n\nexport class FilePickerBuilder<IsMultiSelect extends boolean> {\n\tprivate title: string\n\tprivate multiSelect = false\n\tprivate mimeTypeFilter: string[] = []\n\tprivate directoriesAllowed = false\n\tprivate noMenu = false\n\tprivate path?: string\n\tprivate filter?: IFilePickerFilter\n\tprivate canPick?: IFilePickerCanPick\n\tprivate buttons: IFilePickerButton[] | IFilePickerButtonFactory = []\n\tprivate container?: string\n\tprivate disabledNavigation = false\n\n\t/**\n\t * Construct a new FilePicker\n\t *\n\t * @param title Title of the FilePicker\n\t */\n\tpublic constructor(title: string) {\n\t\tthis.title = title\n\t}\n\n\t/**\n\t * Set the container where the FilePicker will be mounted\n\t * By default 'body' is used\n\t *\n\t * @param container The dialog container\n\t */\n\tpublic setContainer(container: string): this {\n\t\tthis.container = container\n\t\treturn this\n\t}\n\n\t/**\n\t * Enable or disable picking multiple files\n\t *\n\t * @param ms True to enable picking multiple files, false otherwise\n\t */\n\tpublic setMultiSelect<T extends boolean>(ms: T) {\n\t\tthis.multiSelect = ms\n\t\treturn this as unknown as FilePickerBuilder<T extends true ? true : false>\n\t}\n\n\t/**\n\t * Add allowed MIME type\n\t *\n\t * @param filter MIME type to allow\n\t */\n\tpublic addMimeTypeFilter(filter: string): this {\n\t\tthis.mimeTypeFilter.push(filter)\n\t\treturn this\n\t}\n\n\t/**\n\t * Set allowed MIME types\n\t *\n\t * @param filter Array of allowed MIME types\n\t */\n\tpublic setMimeTypeFilter(filter: string[]): this {\n\t\tthis.mimeTypeFilter = filter\n\t\treturn this\n\t}\n\n\t/**\n\t * Add a button to the FilePicker\n\t * Note: This overrides any previous `setButtonFactory` call\n\t *\n\t * @param button The button\n\t */\n\tpublic addButton(button: IFilePickerButton): this {\n\t\tif (typeof this.buttons === 'function') {\n\t\t\tlogger.warn('FilePicker buttons were set to factory, now overwritten with button object.')\n\t\t\tthis.buttons = []\n\t\t}\n\t\tthis.buttons.push(button)\n\t\treturn this\n\t}\n\n\t/**\n\t * Set the button factory which is used to generate buttons from current view, path and selected nodes\n\t * Note: This overrides any previous `addButton` call\n\t *\n\t * @param factory The button factory\n\t */\n\tpublic setButtonFactory(factory: IFilePickerButtonFactory): this {\n\t\tthis.buttons = factory\n\t\treturn this\n\t}\n\n\t/**\n\t * Set FilePicker type based on legacy file picker types\n\t *\n\t * @param type The legacy filepicker type to emulate\n\t * @deprecated Use `addButton` or `setButtonFactory` instead as with setType you do not know which button was pressed\n\t */\n\tpublic setType(type: FilePickerType): this {\n\t\tthis.buttons = (nodes, path) => {\n\t\t\tconst buttons: IFilePickerButton[] = []\n\t\t\tconst node = nodes[0]\n\t\t\tconst target = node?.displayname || basename(path)\n\n\t\t\tif (type === FilePickerType.Choose) {\n\t\t\t\tlet label = t('Choose')\n\t\t\t\tif (nodes.length === 1) {\n\t\t\t\t\tlabel = t('Choose {file}', { file: target })\n\t\t\t\t} else if (this.multiSelect) {\n\t\t\t\t\tlabel = n('Choose %n file', 'Choose %n files', nodes.length)\n\t\t\t\t}\n\t\t\t\tbuttons.push({\n\t\t\t\t\tcallback: () => {},\n\t\t\t\t\tlabel,\n\t\t\t\t\tvariant: 'primary',\n\t\t\t\t})\n\t\t\t}\n\t\t\tif (type === FilePickerType.CopyMove || type === FilePickerType.Copy) {\n\t\t\t\tbuttons.push({\n\t\t\t\t\tcallback: () => {},\n\t\t\t\t\tlabel: target ? t('Copy to {target}', { target }) : t('Copy'),\n\t\t\t\t\ticon: IconCopy,\n\t\t\t\t\tvariant: type === FilePickerType.Copy ? 'primary' : 'secondary',\n\t\t\t\t})\n\t\t\t}\n\t\t\tif (type === FilePickerType.CopyMove || type === FilePickerType.Move) {\n\t\t\t\tbuttons.push({\n\t\t\t\t\tcallback: () => {},\n\t\t\t\t\tlabel: target ? t('Move to {target}', { target }) : t('Move'),\n\t\t\t\t\ticon: IconMove,\n\t\t\t\t\tvariant: 'primary', // move is always primary - also on copy-move\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn buttons\n\t\t}\n\n\t\treturn this\n\t}\n\n\t/**\n\t * Allow to pick directories besides files\n\t *\n\t * @param allow True to allow picking directories\n\t */\n\tpublic allowDirectories(allow = true): this {\n\t\tthis.directoriesAllowed = allow\n\t\treturn this\n\t}\n\n\t/**\n\t * Allow to create New folders\n\t *\n\t * @param noMenu True to hide menu\n\t */\n\tpublic setNoMenu(noMenu = true): this {\n\t\tthis.noMenu = noMenu\n\t\treturn this\n\t}\n\n\t/**\n\t * Set starting path of the FilePicker\n\t *\n\t * @param path Path to start from picking\n\t */\n\tpublic startAt(path: string): this {\n\t\tthis.path = path\n\t\treturn this\n\t}\n\n\t/**\n\t * Add filter function to filter file list of FilePicker\n\t *\n\t * @param filter Filter function to apply\n\t */\n\tpublic setFilter(filter: IFilePickerFilter): this {\n\t\tthis.filter = filter\n\t\treturn this\n\t}\n\n\t/**\n\t * Add function to allow or not picking a node\n\t *\n\t * @param canPick Function to decide if a node can be picked\n\t */\n\tpublic setCanPick(canPick: IFilePickerCanPick): this {\n\t\tthis.canPick = canPick\n\t\treturn this\n\t}\n\n\t/**\n\t * Disable navigation (view selection)\n\t */\n\tpublic disableNavigation(): this {\n\t\tthis.disabledNavigation = true\n\t\treturn this\n\t}\n\n\t/**\n\t * Construct the configured FilePicker\n\t */\n\tpublic build(): FilePicker<IsMultiSelect> {\n\t\treturn new FilePicker<IsMultiSelect>(\n\t\t\tthis.title,\n\t\t\tthis.multiSelect as IsMultiSelect,\n\t\t\tthis.mimeTypeFilter,\n\t\t\tthis.directoriesAllowed,\n\t\t\tthis.noMenu,\n\t\t\tthis.buttons,\n\t\t\tthis.path,\n\t\t\tthis.filter,\n\t\t\tthis.canPick,\n\t\t\tthis.container,\n\t\t\tthis.disabledNavigation,\n\t\t)\n\t}\n}\n\n/**\n *\n * @param title Title of the file picker\n */\nexport function getFilePickerBuilder(title: string): FilePickerBuilder<boolean> {\n\treturn new FilePickerBuilder(title)\n}\n","/**\n * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport type { PublicAuthPromptProps } from './components/PublicAuthPrompt.vue'\n\nimport { spawnDialog } from '@nextcloud/vue/functions/dialog'\nimport { defineAsyncComponent } from 'vue'\n\nexport type GuestUserPromptOptions = PublicAuthPromptProps\n\n/**\n * Show the public auth prompt dialog\n * This is used to ask the current user their nickname\n * as well as show some additional contextual information\n *\n * @param props - The props to pass to the dialog\n * @return The selected name or undefined if dialog was closed\n */\nexport async function showGuestUserPrompt(props: GuestUserPromptOptions): Promise<string | undefined> {\n\tconst name = await spawnDialog(\n\t\tdefineAsyncComponent(() => import('./components/PublicAuthPrompt.vue')),\n\t\tprops,\n\t)\n\treturn name\n}\n","<!--\n  - SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors\n  - SPDX-License-Identifier: AGPL-3.0-or-later\n-->\n<template>\n\t<NcDialog\n\t\tdialogClasses=\"nc-generic-dialog\"\n\t\t:buttons=\"dialogButtons\"\n\t\t:name\n\t\t:message=\"text\"\n\t\t@update:open=\"$emit('close', false)\">\n\t\t<NcNoteCard v-if=\"severity\" :type=\"severity\">\n\t\t\t<p v-text=\"text\" />\n\t\t</NcNoteCard>\n\t\t<!-- eslint-disable-next-line vue/no-v-html -->\n\t\t<div v-if=\"html\" v-html=\"html\" />\n\t</NcDialog>\n</template>\n\n<script setup lang=\"ts\">\nimport type { IDialogButton, IDialogSeverity } from './types.ts'\n\nimport { computed, onMounted, onUnmounted } from 'vue'\nimport NcDialog from '@nextcloud/vue/components/NcDialog'\nimport NcNoteCard from '@nextcloud/vue/components/NcNoteCard'\n\nconst props = defineProps<{\n\t/**\n\t * Headline of the dialog\n\t */\n\tname: string\n\n\t/**\n\t * Main text of the dialog\n\t */\n\ttext: string\n\n\t/**\n\t * HTML content\n\t *\n\t * @deprecated DO NOT USE! This is just for backwards compatibility and will be removed in the near future!\n\t */\n\thtml?: string\n\n\t/**\n\t * Buttons on the dialog\n\t */\n\tbuttons?: IDialogButton[]\n\n\t/**\n\t * Severity of the dialog - if a notecard is used\n\t */\n\tseverity?: IDialogSeverity\n}>()\n\nconst emit = defineEmits<{\n\tclose: [buttonClick: boolean]\n}>()\n\nconst dialogButtons = computed(() => props.buttons?.map((button) => ({\n\t...button,\n\tcallback() {\n\t\tbutton.callback()\n\t\temit('close', true)\n\t},\n})))\n\n/**\n * Handler used to ensure the message is also shown when the page is unloaded\n * This is for backwards compatibility with OC.dialogs\n */\nconst handleUnload = () => `${props.name}: ${props.text}`\n\nonMounted(() => window.addEventListener('unload', handleUnload))\nonUnmounted(() => window.removeEventListener('unload', handleUnload))\n</script>\n\n<style>\n.nc-generic-dialog .dialog__actions {\n\tjustify-content: space-between;\n\tmin-width: calc(100% - 12px);\n}\n</style>\n","<!--\n  - SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors\n  - SPDX-License-Identifier: AGPL-3.0-or-later\n-->\n<template>\n\t<NcDialog\n\t\tdialogClasses=\"nc-generic-dialog\"\n\t\t:buttons=\"dialogButtons\"\n\t\t:name\n\t\t:message=\"text\"\n\t\t@update:open=\"$emit('close', false)\">\n\t\t<NcNoteCard v-if=\"severity\" :type=\"severity\">\n\t\t\t<p v-text=\"text\" />\n\t\t</NcNoteCard>\n\t\t<!-- eslint-disable-next-line vue/no-v-html -->\n\t\t<div v-if=\"html\" v-html=\"html\" />\n\t</NcDialog>\n</template>\n\n<script setup lang=\"ts\">\nimport type { IDialogButton, IDialogSeverity } from './types.ts'\n\nimport { computed, onMounted, onUnmounted } from 'vue'\nimport NcDialog from '@nextcloud/vue/components/NcDialog'\nimport NcNoteCard from '@nextcloud/vue/components/NcNoteCard'\n\nconst props = defineProps<{\n\t/**\n\t * Headline of the dialog\n\t */\n\tname: string\n\n\t/**\n\t * Main text of the dialog\n\t */\n\ttext: string\n\n\t/**\n\t * HTML content\n\t *\n\t * @deprecated DO NOT USE! This is just for backwards compatibility and will be removed in the near future!\n\t */\n\thtml?: string\n\n\t/**\n\t * Buttons on the dialog\n\t */\n\tbuttons?: IDialogButton[]\n\n\t/**\n\t * Severity of the dialog - if a notecard is used\n\t */\n\tseverity?: IDialogSeverity\n}>()\n\nconst emit = defineEmits<{\n\tclose: [buttonClick: boolean]\n}>()\n\nconst dialogButtons = computed(() => props.buttons?.map((button) => ({\n\t...button,\n\tcallback() {\n\t\tbutton.callback()\n\t\temit('close', true)\n\t},\n})))\n\n/**\n * Handler used to ensure the message is also shown when the page is unloaded\n * This is for backwards compatibility with OC.dialogs\n */\nconst handleUnload = () => `${props.name}: ${props.text}`\n\nonMounted(() => window.addEventListener('unload', handleUnload))\nonUnmounted(() => window.removeEventListener('unload', handleUnload))\n</script>\n\n<style>\n.nc-generic-dialog .dialog__actions {\n\tjustify-content: space-between;\n\tmin-width: calc(100% - 12px);\n}\n</style>\n","/**\n * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport type { IDialogButton, IDialogSeverity } from './components/types.ts'\n\nimport { spawnDialog } from '@nextcloud/vue/functions/dialog'\nimport GenericDialog from './components/GenericDialog.vue'\nimport { t } from './utils/l10n.ts'\nimport { logger } from './utils/logger.ts'\n\nexport type * from './components/types.ts'\n\n/**\n * This class provides generic Nextcloud themed dialogs\n */\nexport class Dialog {\n\t#name: string\n\t#text: string\n\t#buttons: IDialogButton[]\n\t#severity?: IDialogSeverity\n\n\tconstructor(\n\t\tname: string,\n\t\ttext: string,\n\t\tbuttons: IDialogButton[] = [],\n\t\tseverity?: IDialogSeverity,\n\t) {\n\t\tthis.#name = name\n\t\tthis.#text = text\n\t\tthis.#buttons = buttons\n\t\tthis.#severity = severity\n\t}\n\n\t/**\n\t * Spawn and show the dialog - if already open the previous instance will be destroyed\n\t *\n\t * @return Promise that resolves when the dialog is answered successfully and rejects on close\n\t */\n\tasync show(): Promise<void> {\n\t\tconst result = await spawnDialog(\n\t\t\tGenericDialog,\n\t\t\t{\n\t\t\t\tbuttons: this.#buttons,\n\t\t\t\tname: this.#name,\n\t\t\t\ttext: this.#text,\n\t\t\t\tseverity: this.#severity,\n\t\t\t},\n\t\t)\n\t\tif (!result) {\n\t\t\tthrow new Error('Dialog closed')\n\t\t}\n\t}\n}\n\n/**\n * The DialogBuilder provides an easy to use interface for creating simple dialogs in consistent Nextcloud design\n *\n * @example\n * ```ts\n * // It is recommended to use `getDialogBuilder` instead\n * const dialogBuilder = new DialogBuilder('The dialog title')\n * const dialog = dialogBuilder\n *     .setText('The dialog message')\n *     .setSeverity(DialogSeverity.Warning)\n *     .addButton({\n *         label: 'Ok',\n *         callback: () => console.warn('Warning was dismissed'),\n *     })\n *     .build()\n * ```\n */\nexport class DialogBuilder {\n\t#severity?: IDialogSeverity\n\t#text: string\n\t#name: string\n\t#buttons: IDialogButton[]\n\n\tconstructor(name?: string) {\n\t\tthis.#severity = undefined\n\t\tthis.#text = ''\n\t\tthis.#name = name ?? ''\n\t\tthis.#buttons = []\n\t}\n\n\t/**\n\t * Set dialog name\n\t *\n\t * @param name The name or headline of the dialog\n\t */\n\tsetName(name: string): this {\n\t\tthis.#name = name\n\t\treturn this\n\t}\n\n\t/**\n\t * Set the dialog text\n\t *\n\t * @param text Main text of the dialog\n\t */\n\tsetText(text: string): this {\n\t\tthis.#text = text\n\t\treturn this\n\t}\n\n\t/**\n\t * Set the severity of the dialog\n\t *\n\t * @param severity Severity of the dialog\n\t */\n\tsetSeverity(severity: IDialogSeverity): this {\n\t\tthis.#severity = severity\n\t\treturn this\n\t}\n\n\t/**\n\t * Set buttons from array\n\t *\n\t * @param buttons Either an array of dialog buttons\n\t */\n\tsetButtons(buttons: IDialogButton[]): this {\n\t\tif (this.#buttons.length > 0) {\n\t\t\tlogger.warn('[@nextcloud/dialogs] Dialog buttons are already set - this overrides previous buttons.')\n\t\t}\n\t\tthis.#buttons = buttons\n\t\treturn this\n\t}\n\n\t/**\n\t * Add a single button\n\t *\n\t * @param button Button to add\n\t */\n\taddButton(button: IDialogButton): this {\n\t\tthis.#buttons.push(button)\n\t\treturn this\n\t}\n\n\tbuild(): Dialog {\n\t\treturn new Dialog(this.#name, this.#text, this.#buttons, this.#severity)\n\t}\n}\n\n/**\n * Get the dialog builder to create a new dialog\n *\n * @param name The name of the dialog (title)\n * @example\n * ```ts\n * const dialog = getDialogBuilder('Confirm action')\n *     .addButton({\n *         label: 'Ok',\n *         callback: () => console.warn('confirmed'),\n *     })\n *     .build()\n * ```\n */\nexport function getDialogBuilder(name: string): DialogBuilder {\n\treturn new DialogBuilder(name)\n}\n\nexport interface ConfirmationDialogOptions {\n\t/** The name of the dialog (heading) */\n\tname: string\n\t/** The text of the dialog */\n\ttext: string\n\t/** The text of the confirmation button */\n\tlabelConfirm?: string\n\t/** The text of the reject button */\n\tlabelReject?: string\n\t/** The severity */\n\tseverity?: IDialogSeverity\n}\n\n/**\n * Open a new confirmation dialog.\n * The dialog either resolves to true when the confirm-button was pressed,\n * or to false if the reject-button was pressed.\n *\n * @param options - Dialog options see `ConfirmationDialogOptions`\n */\nexport async function showConfirmation(options: ConfirmationDialogOptions): Promise<boolean> {\n\toptions = {\n\t\tlabelConfirm: t('Confirm'),\n\t\t...options,\n\t}\n\n\tconst { promise, resolve } = Promise.withResolvers<boolean>()\n\tconst buttons: IDialogButton[] = [{\n\t\tlabel: options.labelConfirm!,\n\t\tvariant: 'primary',\n\t\tcallback() {\n\t\t\tresolve(true)\n\t\t},\n\t}]\n\n\tif (options.labelReject) {\n\t\tbuttons.unshift({\n\t\t\tlabel: options.labelReject,\n\t\t\tcallback() {\n\t\t\t\tresolve(false)\n\t\t\t},\n\t\t})\n\t}\n\n\tconst dialog = new Dialog(\n\t\toptions.name,\n\t\toptions.text,\n\t\tbuttons,\n\t\toptions.severity,\n\t)\n\tawait dialog.show()\n\treturn promise\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA+DA,eAAsB,mBACrB,SACA,WACA,SACA,SAC8C;CAC9C,MAAM,iBAAiB,2BAA2B,OAAO,sCAAiD;CAE1G,MAAM,WAAgB,CAAC;CACvB,MAAM,WAAoB,CAAC;CAC3B,KAAK,MAAM,QAAQ,SAClB,IAAI,kBAAkB,IAAI,GAAG;EAC5B,SAAS,KAAK,IAAI;EAClB,SAAS,KAAK,UAAU,QAAQ,IAAI,EAAG;CACxC;CAGD,IAAI,UAAU,WAAW,KAAK,QAAQ,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