/**
@license
Copyright 2020 The Advanced REST client authors <arc@mulesoft.com>
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
*/
import { TemplateResult, PropertyValues, nothing } from 'lit';
import type { IBodyMetaModel, IRawBody, IUrlEncodedBodyMeta } from '@api-client/core/models/RequestUiMeta.js';
import { type IMultipartBody, type ISafePayload } from '@api-client/core/lib/transformers/PayloadSerializer.js';
import type { IProperty } from '@api-client/core/models/Property.js';
import BodyUrlEncodedEditor from './BodyUrlEncodedEditor.js';
import BodyMultipartEditor from './BodyMultipartEditor.js';
import ApiElement from '../ApiElement.js';
import '../../md/icons/ui-icon.js';
import '../../define/http/http-body-urlencoded-editor.js';
import '../../define/http/http-body-multipart-editor.js';
import '../../define/http/http-body-text-editor.js';
import '../../md/button/ui-button.js';
import '../../md/dropdown-list/ui-dropdown-list.js';
import '../../md/list/ui-list.js';
import '../../md/list/ui-list-item.js';
import '../../md/divider/ui-divider.js';
import '../../md/checkbox/ui-checkbox.js';
export type AllowedEditor = 'raw' | 'urlEncode' | 'multipart' | 'file';
export interface EditorType {
    id: AllowedEditor;
    label: string;
    title: string;
}
export declare const editorTypes: readonly EditorType[];
/**
 * @fires change When the value and the model change
 */
export default class BodyEditor extends ApiElement {
    /**
     * The currently rendered editor.
     * @attribute
     */
    accessor selected: AllowedEditor;
    protected valueInternal: unknown;
    /**
     * The HTTP body.
     *
     * Depending of current editor selection the type can vary.
     */
    get value(): unknown;
    set value(value: unknown);
    protected modelInternal: IBodyMetaModel[] | undefined;
    /**
     * Previously generated by this editor metadata model.
     * Used internally to set the UI.
     */
    get model(): IBodyMetaModel[] | undefined;
    set model(value: IBodyMetaModel[] | undefined);
    /**
     * When set the editor is in read only mode.
     * @attribute
     */
    accessor readOnly: boolean;
    /**
     * When set all controls are disabled in the form
     * @attribute
     */
    accessor disabled: boolean;
    /**
     * When set it automatically encodes and decodes values.
     * @attribute
     */
    accessor autoEncode: boolean;
    /**
     * @returns True when the current value is a file (or blob).
     */
    get hasFile(): boolean;
    /**
     * The current request content type. It is passed to the `raw` editor
     * to detect current language.
     * @attribute
     */
    accessor contentType: string | undefined;
    protected invalidMimeMessage?: number;
    protected invalidMimeValue?: boolean;
    protected mimeValue?: string;
    protected accessor urlEncodedEditor: BodyUrlEncodedEditor | null;
    protected accessor multipartEditor: BodyMultipartEditor | null;
    constructor();
    protected update(cp: PropertyValues<this>): void;
    /**
     * This must be called only when the `model` property change from the
     * outside. It restores values depending on the selected editor.
     */
    protected modelChanged(): void;
    /**
     * Restores file value from the model, if exists
     */
    protected restoreFileModel(): void;
    protected handleTypeChange(e: CustomEvent): void;
    /**
     * A handler for the editor selection. It activates an editor, if necessary.
     */
    protected changeEditor(id: AllowedEditor): Promise<void>;
    /**
     * A handler for the file pick button click.
     * Activates the file input.
     */
    protected handlePickFile(): void;
    /**
     * A handler for the file file selection in the file input.
     * Sets the value to the file.
     */
    protected handleFileChange(e: Event): Promise<void>;
    /**
     * Clears the current value
     */
    protected handleClearFile(): void;
    /**
     * Reads editor view model
     *
     * @param editor The editor id
     * @returns The view model
     */
    protected readMetaModel(editor: string): (ISafePayload | IProperty | IMultipartBody | IRawBody | IUrlEncodedBodyMeta)[] | undefined;
    /**
     * Sets editor view model on the local model
     * @param editor The editor id
     * @param model The view model
     */
    protected setMetaModel(editor: AllowedEditor, model: (ISafePayload | IProperty | IMultipartBody | IRawBody | IUrlEncodedBodyMeta)[]): void;
    /**
     * A handler for the change event dispatched by the
     * `urlEncode` editor.
     * Updated the local value, model, and notifies the change.
     */
    protected handleUrlEncodeChange(e: Event): void;
    protected updateUrlEncodedValue(editor: BodyUrlEncodedEditor): void;
    /**
     * A handler for the change event dispatched by the `raw` editor.
     * Updated the local value, model, and notifies the change.
     */
    protected handleRawChange(e: Event): void;
    /**
     * A handler for the change event dispatched by the
     * `multipart` editor.
     * Updated the local value, model, and notifies the change.
     */
    protected handleMultipartChange(e: Event): void;
    /**
     * Checks whether the current content type header value matches the selected editor.
     * If not it renders a warning message.
     */
    protected analyzeContentType(): void;
    /**
     * Automatically fixes content type problem.
     */
    protected autoFixMime(): void;
    /**
     * A handler for the mime type selection.
     */
    protected handleMimeTypeSelect(e: CustomEvent): void;
    handlerDrop(e: DragEvent): Promise<void>;
    protected handleDragOver(e: DragEvent): void;
    protected handleAddUrlEncode(): void;
    protected handleUrlEncode(): void;
    protected handleUrlDecode(): void;
    protected handleUrlEncodeAutoChange(e: Event): void;
    protected handleMultipartAddText(): void;
    protected handleMultipartAddFile(): void;
    render(): TemplateResult;
    /**
     * @returns The template for the dropdown menu for the editor type
     */
    protected renderBodySelector(): TemplateResult;
    protected renderBodyTypeOptions(): TemplateResult;
    /**
     * @returns The template for the main editor actions.
     */
    protected renderMainActions(): TemplateResult | typeof nothing;
    protected renderTextEditorActions(): TemplateResult;
    protected renderMonacoOptions(): TemplateResult[];
    protected renderUrlEncodeEditorActions(): TemplateResult;
    protected renderMultipartActions(): TemplateResult;
    /**
     * @returns A template for currently rendered editor
     */
    protected renderEditor(): TemplateResult;
    /**
     * @returns The template for the raw editor
     */
    protected renderRawEditor(): TemplateResult;
    /**
     * @param value The editor value
     * @returns The template for the Monaco editor
     */
    protected renderTextEditor(value: string): TemplateResult;
    /**
     * @returns A template for the application/x-www-form-urlencoded editor
     */
    protected renderUrlEncodeEditor(): TemplateResult;
    /**
     * @returns A template for the multipart editor
     */
    protected renderMultipartEditor(): TemplateResult;
    /**
     * @returns A template for the file input editor
     */
    protected renderFileEditor(): TemplateResult;
    protected renderFormInfo(): TemplateResult;
    /**
     * @returns A template for the missing selection
     */
    protected renderNoEditor(): TemplateResult;
    /**
     * @returns A template for the file details.
     */
    protected renderFileDetail(): TemplateResult | string;
    protected renderInvalidMime(): TemplateResult | string;
    /**
     * @returns A template for fixable mime type mismatch message.
     */
    protected renderFixableInvalidMime(suggested: string): TemplateResult;
}
//# sourceMappingURL=BodyEditor.d.ts.map