{"version":3,"file":"dist-js-C7XbZpVw.js","names":[],"sources":["../../node_modules/.pnpm/@tauri-apps+plugin-dialog@2.7.2/node_modules/@tauri-apps/plugin-dialog/dist-js/index.js"],"sourcesContent":["import { invoke } from '@tauri-apps/api/core';\n\n// Copyright 2019-2023 Tauri Programme within The Commons Conservancy\n// SPDX-License-Identifier: Apache-2.0\n// SPDX-License-Identifier: MIT\n/**\n * Internal function to convert the buttons to the Rust type.\n */\nfunction buttonsToRust(buttons) {\n    if (buttons === undefined) {\n        return undefined;\n    }\n    if (typeof buttons === 'string') {\n        return buttons;\n    }\n    else if ('ok' in buttons && 'cancel' in buttons) {\n        return { OkCancelCustom: [buttons.ok, buttons.cancel] };\n    }\n    else if ('yes' in buttons && 'no' in buttons && 'cancel' in buttons) {\n        return {\n            YesNoCancelCustom: [buttons.yes, buttons.no, buttons.cancel]\n        };\n    }\n    else if ('ok' in buttons) {\n        return { OkCustom: buttons.ok };\n    }\n    return undefined;\n}\n/**\n * Open a file/directory selection dialog.\n *\n * The selected paths are added to the filesystem and asset protocol scopes.\n * When security is more important than the easy of use of this API,\n * prefer writing a dedicated command instead.\n *\n * Note that the scope change is not persisted, so the values are cleared when the application is restarted.\n * You can save it to the filesystem using [tauri-plugin-persisted-scope](https://github.com/tauri-apps/tauri-plugin-persisted-scope).\n * @example\n * ```typescript\n * import { open } from '@tauri-apps/plugin-dialog';\n * // Open a selection dialog for image files\n * const selected = await open({\n *   multiple: true,\n *   filters: [{\n *     name: 'Image',\n *     extensions: ['png', 'jpeg']\n *   }]\n * });\n * if (Array.isArray(selected)) {\n *   // user selected multiple files\n * } else if (selected === null) {\n *   // user cancelled the selection\n * } else {\n *   // user selected a single file\n * }\n * ```\n *\n * @example\n * ```typescript\n * import { open } from '@tauri-apps/plugin-dialog';\n * import { appDir } from '@tauri-apps/api/path';\n * // Open a selection dialog for directories\n * const selected = await open({\n *   directory: true,\n *   multiple: true,\n *   defaultPath: await appDir(),\n * });\n * if (Array.isArray(selected)) {\n *   // user selected multiple directories\n * } else if (selected === null) {\n *   // user cancelled the selection\n * } else {\n *   // user selected a single directory\n * }\n * ```\n *\n * @returns A promise resolving to the selected path(s)\n *\n * @since 2.0.0\n */\nasync function open(options = {}) {\n    if (typeof options === 'object') {\n        Object.freeze(options);\n    }\n    return await invoke('plugin:dialog|open', { options });\n}\n/**\n * Open a file/directory save dialog.\n *\n * The selected path is added to the filesystem and asset protocol scopes.\n * When security is more important than the easy of use of this API,\n * prefer writing a dedicated command instead.\n *\n * Note that the scope change is not persisted, so the values are cleared when the application is restarted.\n * You can save it to the filesystem using [tauri-plugin-persisted-scope](https://github.com/tauri-apps/tauri-plugin-persisted-scope).\n * @example\n * ```typescript\n * import { save } from '@tauri-apps/plugin-dialog';\n * const filePath = await save({\n *   filters: [{\n *     name: 'Image',\n *     extensions: ['png', 'jpeg']\n *   }]\n * });\n * ```\n *\n * @returns A promise resolving to the selected path.\n *\n * @since 2.0.0\n */\nasync function save(options = {}) {\n    if (typeof options === 'object') {\n        Object.freeze(options);\n    }\n    return await invoke('plugin:dialog|save', { options });\n}\nasync function messageCommand(message, options) {\n    return await invoke('plugin:dialog|message', {\n        message,\n        title: options?.title,\n        kind: options?.kind,\n        buttons: buttonsToRust(options?.buttons)\n    });\n}\n/**\n * Shows a message dialog with an `Ok` button.\n * @example\n * ```typescript\n * import { message } from '@tauri-apps/plugin-dialog';\n * await message('Tauri is awesome', 'Tauri');\n * await message('File not found', { title: 'Tauri', kind: 'error' });\n * ```\n *\n * @param message The message to show.\n * @param options The dialog's options. If a string, it represents the dialog title.\n *\n * @returns A promise indicating the success or failure of the operation.\n *\n * @since 2.0.0\n *\n */\nasync function message(message, options) {\n    const opts = typeof options === 'string' ? { title: options } : options;\n    if (opts && !opts.buttons && opts.okLabel) {\n        opts.buttons = { ok: opts.okLabel };\n    }\n    return messageCommand(message, opts);\n}\n/**\n * Shows a question dialog with `Yes` and `No` buttons.\n *\n * Convenient wrapper for `await message('msg', { buttons: 'YesNo' }) === 'Yes'`\n *\n * @example\n * ```typescript\n * import { ask } from '@tauri-apps/plugin-dialog';\n * const yes = await ask('Are you sure?', 'Tauri');\n * const yes2 = await ask('This action cannot be reverted. Are you sure?', { title: 'Tauri', kind: 'warning' });\n * ```\n *\n * @param message The message to show.\n * @param options The dialog's options. If a string, it represents the dialog title.\n *\n * @returns A promise resolving to a boolean indicating whether `Yes` was clicked or not.\n *\n * @since 2.0.0\n */\nasync function ask(message, options) {\n    const opts = typeof options === 'string' ? { title: options } : options;\n    const customButtons = opts?.okLabel || opts?.cancelLabel;\n    const okLabel = opts?.okLabel ?? 'Yes';\n    return ((await messageCommand(message, {\n        title: opts?.title,\n        kind: opts?.kind,\n        buttons: customButtons\n            ? { ok: okLabel, cancel: opts.cancelLabel ?? 'No' }\n            : 'YesNo'\n    })) === okLabel);\n}\n/**\n * Shows a question dialog with `Ok` and `Cancel` buttons.\n *\n * Convenient wrapper for `await message('msg', { buttons: 'OkCancel' }) === 'Ok'`\n *\n * @example\n * ```typescript\n * import { confirm } from '@tauri-apps/plugin-dialog';\n * const confirmed = await confirm('Are you sure?', 'Tauri');\n * const confirmed2 = await confirm('This action cannot be reverted. Are you sure?', { title: 'Tauri', kind: 'warning' });\n * ```\n *\n * @param message The message to show.\n * @param options The dialog's options. If a string, it represents the dialog title.\n *\n * @returns A promise resolving to a boolean indicating whether `Ok` was clicked or not.\n *\n * @since 2.0.0\n */\nasync function confirm(message, options) {\n    const opts = typeof options === 'string' ? { title: options } : options;\n    const customButtons = opts?.okLabel || opts?.cancelLabel;\n    const okLabel = opts?.okLabel ?? 'Ok';\n    return ((await messageCommand(message, {\n        title: opts?.title,\n        kind: opts?.kind,\n        buttons: customButtons\n            ? { ok: okLabel, cancel: opts.cancelLabel ?? 'Cancel' }\n            : 'OkCancel'\n    })) === okLabel);\n}\n\nexport { ask, confirm, message, open, save };\n"],"x_google_ignoreList":[0],"mappings":"uCAgFA,eAAe,EAAK,EAAU,CAAC,EAAG,CAI9B,OAHI,OAAO,GAAY,UACnB,OAAO,OAAO,CAAO,EAElB,MAAM,EAAO,qBAAsB,CAAE,SAAQ,CAAC,CACzD,CAyBA,eAAe,EAAK,EAAU,CAAC,EAAG,CAI9B,OAHI,OAAO,GAAY,UACnB,OAAO,OAAO,CAAO,EAElB,MAAM,EAAO,qBAAsB,CAAE,SAAQ,CAAC,CACzD"}