import { nothing, TemplateResult } from 'lit';
import type { IApiEndPoint, IApiOperation, IApiParameter, IApiPayload, IApiServer } from '@api-client/core/amf/definitions/Api.js';
import { IRequestProxyInit } from '@api-client/core/proxy/RequestProxy.js';
import { IProxyResult } from '@api-client/core/proxy/Proxy.js';
import { IRequestLog } from '@api-client/core/models/RequestLog.js';
import { type IRequest } from '@api-client/core/models/Request.js';
import { PayloadInfo } from '../../amf/lib/PayloadUtils.js';
import { OperationParameter, SecuritySelectorListItem } from '../../amf/types.js';
import { Oauth2Credentials } from '../authorization/types.js';
import ApiElement from '../ApiElement.js';
import { AmfParameters } from '../../amf/lib/AmfParameters.js';
import { UiDropdownListSelection } from '../../md/dropdown-list/internals/UiDropdownList.js';
import '../../define/amf/api-authorization-editor.js';
import '../../define/amf/api-server-picker.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/icons/ui-icon.js';
import '../../md/text-field/ui-text-field.js';
import '../../md/switch/ui-switch.js';
import '../../md/button/ui-filled-tonal-button.js';
import '../../md/button/ui-outlined-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/progress/ui-progress.js';
export declare const EventCategory = "API Request editor";
/**
 * @fires amfstoreopget - Dispatched when querying for an operation data
 * @fires amfstoreopgetparent - Dispatched when querying for an operation data for an endpoint
 * @fires amfstoreendpointget - Dispatched when querying for an endpoint data
 * @fires apistoreserverquery - Dispatched when querying for API servers
 * @fires amfstoreapiprotocols - Dispatched when querying for API protocols
 * @fires amfstoreapiversion - Dispatched when querying for API version
 * @fires response - Dispatched when the response was received by the editor.
 */
export default class ApiRequestEditor extends ApiElement {
    /**
     * The currently selected media type for the payloads.
     * @attribute
     */
    accessor mimeType: string | undefined;
    /**
     * When set it renders a label with the computed URL.
     * @attribute
     */
    accessor urlLabel: boolean | undefined;
    /**
     * When set it renders the URL input above the URL parameters.
     * @attribute
     */
    accessor urlEditor: boolean | undefined;
    /**
     * If set it computes `hasOptional` property and shows checkbox in the
     * form to show / hide optional properties.
     * @attribute
     */
    accessor allowHideOptional: boolean | undefined;
    /**
     * When set, renders "add custom" item button.
     * If the element is to be used without AMF model this should always
     * be enabled. Otherwise users won't be able to add a parameter.
     * @attribute
     */
    accessor allowCustom: boolean | undefined;
    /**
     * OAuth2 redirect URI.
     * This value **must** be set in order for OAuth 1/2 to work properly.
     * @attribute
     */
    accessor redirectUri: string | undefined;
    /**
     * Final request URL including settings like `baseUri`, AMF
     * model settings and user provided parameters.
     * @attribute
     */
    accessor url: string | undefined;
    /**
     * Holds the value of the currently selected server
     * Data type: URI
     * @attribute
     */
    accessor serverValue: string | undefined;
    /**
     * Holds the type of the currently selected server
     * Values: `server` | `uri` | `custom`
     * @attribute
     */
    accessor serverType: string | undefined;
    /**
     * Optional property to set
     * If true, the server selector is not rendered
     * @attribute
     */
    accessor noServerSelector: boolean | undefined;
    /**
     * Optional property to set
     * If true, the server selector custom base URI option is rendered
     * @attribute
     */
    accessor allowCustomBaseUri: boolean | undefined;
    /**
     * List of credentials source
     */
    accessor credentialsSource: Oauth2Credentials[] | undefined;
    /**
     * The domain id key of the selected security
     * @attribute
     */
    accessor selectedSecurity: string | undefined;
    /**
     * Optional. The parent endpoint id. When set it uses this value to query for the endpoint
     * instead of querying for a parent through the operation id.
     * Also, when `endpoint` is set and the `endpointId` match then it ignores querying for
     * the endpoint.
     * @attribute
     */
    accessor endpointId: string | undefined;
    protected domainIdValue: string | undefined;
    /**
     * The domain id (AMF id) of the rendered operation.
     * @attribute
     */
    get domainId(): string | undefined;
    set domainId(value: string | undefined);
    protected endpointValue: IApiEndPoint | undefined;
    get endpoint(): IApiEndPoint | undefined;
    set endpoint(value: IApiEndPoint | undefined);
    /**
     * The HTTP method name.
     */
    get httpMethod(): string | undefined;
    /**
     * A flag set when the request is being made.
     */
    accessor loadingRequest: boolean | undefined;
    protected baseUriValue: string | undefined;
    /**
     * A base URI for the API. To be set if RAML spec is missing `baseUri`
     * declaration and this produces invalid URL input. This information
     * is passed to the URL editor that prefixes the URL with `baseUri` value
     * if passed URL is a relative URL.
     * @attribute
     */
    get baseUri(): string | undefined;
    set baseUri(value: string | undefined);
    protected serversValue: IApiServer[] | undefined;
    /**
     * The computed list of servers.
     */
    get servers(): IApiServer[] | undefined;
    protected serverLocalValue: IApiServer | undefined;
    get server(): IApiServer | undefined;
    /**
     * This is the final computed value for the baseUri to propagate downwards
     * If baseUri is defined, return baseUri
     * Else, return the selectedServerValue if serverType is not `server`
     */
    get effectiveBaseUri(): string;
    /**
     * @return True when there is not enough servers to render the selector
     */
    get serverSelectorHidden(): boolean;
    /**
     * The list of security list items to render.
     * An operation may have multiple security definition in an or/and fashion.
     * This allows to render the selector to pick the current security.
     */
    protected securityList: SecuritySelectorListItem[] | undefined;
    /**
     * The security requirement for the operation or undefined.
     */
    get security(): SecuritySelectorListItem[] | undefined;
    /**
     * The currently rendered payload, if any.
     */
    get payload(): IApiPayload | undefined;
    /**
     * The list of all possible payloads for this operation.
     */
    get payloads(): IApiPayload[] | undefined;
    /**
     * @returns API defined base URI (current server + the endpoint)
     */
    get apiBaseUri(): string | undefined;
    protected urlInvalidValue?: boolean;
    /**
     * True when the URL input is invalid.
     */
    get urlInvalid(): boolean | undefined;
    protected protocolsValue: string[] | undefined;
    /**
     * The API's protocols.
     */
    get protocols(): string[] | undefined;
    protected versionValue: string | undefined;
    /**
     * The API's version.
     */
    get version(): string | undefined;
    queryDebouncerTimeout: number;
    /**
     * Set when the selection change, this is a JS object created form the
     * supportedOperation definition of the AMF graph.
     */
    protected operationValue?: IApiOperation;
    /**
     * The list of parameter groups that are opened when `allowHideOptional` is set.
     */
    openedOptional: string[];
    protected debounceValue: unknown;
    protected urlSearchRegexpValue: RegExp | undefined;
    serversCount?: number;
    amfParameters: AmfParameters;
    /**
     * This is set while the HTTP request is being executed.
     * It allows to abort the request.
     */
    requestController?: AbortController;
    /**
     * @constructor
     */
    constructor();
    connectedCallback(): void;
    disconnectedCallback(): void;
    /**
     * Handler for the event dispatched by the store when the graph model change.
     */
    protected graphChangeHandler(): void;
    /**
     * Calls the `queryGraph()` function in a debouncer.
     */
    protected processDebounce(): void;
    /**
     * Reads the URL data from the ApiUrlDataModel library and sets local variables.
     */
    readUrlData(): void;
    /**
     * It makes sure that the path parameters are rendered in order (server, endpoint)
     * and in order of occurrence in the URL.
     */
    protected orderPathParameters(): void;
    protected paramChangeHandler(e: CustomEvent<string>): void;
    /**
     * A function to be overwritten by child classes to execute an action when a parameter has changed.
     */
    protected paramChanged(key: string): void;
    /**
     * Computes the URL value for the current serves, selected server, and endpoint's path.
     */
    protected computeUrlValue(): void;
    /**
     * Checks if the current server has variables and update the parameters array
     */
    protected updateServerParameters(): void;
    /**
     * Checks if the current endpoint has variables and requests them when needed.
     */
    protected updateEndpointParameters(): void;
    reset(): void;
    /**
     * Processes the selection of the domain id for an operation.
     */
    processGraph(): Promise<void>;
    /**
     * Queries the store for the operation data, when needed.
     */
    queryOperation(): Promise<void>;
    /**
     * Queries the store for the endpoint data.
     * @returns {Promise<void>}
     */
    queryEndpoint(): Promise<void>;
    /**
     * Queries for the current servers value.
     */
    queryServers(): Promise<void>;
    /**
     * Queries the API store for the API protocols list.
     */
    queryProtocols(): Promise<void>;
    /**
     * Searches for the current operation endpoint and sets variables from the endpoint definition.
     */
    protected processEndpoint(): void;
    /**
     * Collects operations input parameters into a single object.
     */
    protected processOperation(): void;
    /**
     * Processes security information for the UI.
     */
    protected processSecurity(): void;
    /**
     * Makes sure the correct mime type is selected for the current selection.
     */
    protected processPayload(): void;
    /**
     * Appends a list of parameters to the list of rendered parameters
     */
    protected appendToParams(list: IApiParameter[], source: string): void;
    /**
     * A handler for the change event dispatched by the `raw` editor.
     */
    protected rawBodyChangeHandler(e: Event): void;
    /**
     * A handler for the change event dispatched by the
     * `urlEncode` editor.
     * Updated the local value, model, and notifies the change.
     */
    protected modelBodyEditorChangeHandler(e: Event): void;
    protected handleAuthSelect(e: CustomEvent<UiDropdownListSelection>): void;
    /**
     * Handles send button click.
     * Depending on authorization validity it either sends the
     * request or forces authorization and sends the request.
     */
    protected sendHandler(): void;
    /**
     * To be called when the user want to execute the request but
     * authorization is invalid (missing values).
     * This function brings the auth panel to front and displays error toast
     */
    authAndExecute(): Promise<void>;
    protected proxyRequest(init: IRequestProxyInit): Promise<IProxyResult<IRequestLog> | undefined>;
    /**
     * Proxies the request to the endpoint using the core libraries.
     */
    execute(): Promise<void>;
    /**
     * Uses the `requestController` to abort the ongoing HTTP request.
     */
    abort(): void;
    /**
     * Event handler for abort click.
     */
    protected abortHandler(): void;
    /**
     * Serializes the state of the request editor.
     */
    serialize(): Promise<IRequest>;
    /**
     * Handler for the `oauth2-redirect-uri-changed` custom event. Changes
     * the `redirectUri` property.
     */
    protected authRedirectChangedHandler(e: CustomEvent): void;
    /**
     * Handle event for populating annotated fields in the editor.
     */
    protected populateAnnotatedFieldsHandler(e: CustomEvent): void;
    /**
     * Computes a current server value for selection made in the server selector.
     */
    protected updateServer(): void;
    /**
     * Handler for the change dispatched from the server selector.
     */
    protected serverCountHandler(e: CustomEvent): void;
    /**
     * Handler for the change dispatched from the server selector.
     */
    protected serverHandler(e: CustomEvent): void;
    /**
     * Computes a regexp for the base URI defined in the server to process URL input change
     * and set the `.urlSearchRegexpValue` value.
     * This should be computed only when a server and en endpoint change.
     */
    protected computeUrlRegexp(): void;
    protected handleMediaTypeSelect(e: Event): void;
    protected notifyResizeAfterUpdate(): Promise<void>;
    /**
     * Toggles optional parameter groups.
     */
    protected handleOptionalToggle(e: Event): void;
    /**
     * When enabled it adds a new custom parameter to the request section defined in the source button.
     */
    protected addCustomHandler(e: Event): void;
    /**
     * Updates path/query model from user input.
     *
     * @param e The change event
     */
    protected handleUrlEditorChange(e: Event): void;
    /**
     * Sets the value of `.urlInvalidValue` and therefore `urlInvalid` properties.
     */
    validateUrl(): void;
    /**
     * Validates the current URL value.
     * @returns True when the current URL is a valid URL.
     */
    protected readUrlValidity(): boolean;
    /**
     * Reads the ordered list of path parameters from the server and the endpoint.
     */
    protected getOrderedPathParams(): OperationParameter[];
    /**
     * Applies values from the `values` array to the uri parameters which names are in the `names` array.
     * Both lists are ordered list of parameters.
     *
     * @param values Values for the parameters
     * @param params List of path parameters.
     * @returns True when any parameter was changed.
     */
    protected applyUriValues(values: string[], params: OperationParameter[]): boolean;
    /**
     * Applies query parameters values to the render list.
     *
     * @returns True when any parameter was changed.
     */
    protected applyQueryParamsValues(map: Record<string, string | string[]>): boolean;
    protected internalSendHandler(e: Event): void;
    /**
     * A handler for the change event on the authorization panel.
     */
    protected authorizationChangeHandler(): void;
    render(): TemplateResult;
    /**
     * @return Template for the request URL label.
     */
    protected urlLabelTemplate(): TemplateResult | typeof nothing;
    protected authorizationTemplate(): TemplateResult | typeof nothing;
    /**
     * @returns The template for the security drop down selector.
     */
    protected authorizationSelectorTemplate(security: SecuritySelectorListItem[], selected: SecuritySelectorListItem): TemplateResult;
    /**
     * @returns The template for the security drop down selector list item.
     */
    protected authorizationSelectorItemTemplate(info: SecuritySelectorListItem): TemplateResult;
    protected formActionsTemplate(): TemplateResult;
    /**
     * Creates a template for the "abort" button.
     */
    protected abortButtonTemplate(): TemplateResult;
    /**
     * Creates a template for the "send" or "auth and send" button.
     */
    protected sendButtonTemplate(): TemplateResult;
    /**
     * @return A template for the server selector
     */
    protected serverSelectorTemplate(): TemplateResult;
    /**
     * @return
     */
    protected parametersTemplate(): TemplateResult | typeof nothing;
    protected headersTemplate(): TemplateResult | typeof nothing;
    /**
     * @returns The template for the add custom parameter button
     */
    protected addCustomButtonTemplate(type: string): TemplateResult;
    /**
     * @return The template for the payload's mime type selector.
     */
    protected mediaTypeSelectorTemplate(): TemplateResult | typeof nothing;
    /**
     * @returns The template for the body editor.
     */
    protected bodyTemplate(): TemplateResult | typeof nothing;
    /**
     * @returns The template for the editor that specializes in the URL encoded form data
     */
    protected formDataEditorTemplate(info: PayloadInfo, id: string): TemplateResult;
    /**
     * @returns The template for the editor that specializes in the multipart form data
     */
    protected multipartEditorTemplate(info: PayloadInfo, id: string): TemplateResult;
    /**
     * @returns The template for the editor that specializes in any text data
     */
    protected rawEditorTemplate(info: PayloadInfo, id: string, mimeType?: string): TemplateResult;
    /**
     * @param target The name of the target parameter group.
     * @param params The list of parameters. When all are required or empty it won't render then button.
     * @returns Template for the switch button to toggle visibility of the optional items.
     */
    protected renderToggleOptional(target: string, params: OperationParameter[]): TemplateResult | typeof nothing;
    /**
     * @returns A template for the URL editor.
     */
    protected renderUrlEditor(): TemplateResult | typeof nothing;
}
//# sourceMappingURL=ApiRequestEditor.element.d.ts.map