import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
 * Copyright (c) 2020-present, Goldman Sachs
 *
 * 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 { observer } from 'mobx-react-lite';
import { ExternalFormatConnection, PackageableElementExplicitReference, UrlStream, } from '@finos/legend-graph';
import { computed, makeObservable } from 'mobx';
import { ConnectionValueState } from '../../../../stores/editor/editor-state/element-editor-state/connection/ConnectionEditorState.js';
import { NewConnectionValueDriver } from '../../../../stores/editor/NewElementState.js';
import { externalFormat_urlStream_setUrl } from '../../../../stores/graph-modifier/DSL_ExternalFormat_GraphModifierHelper.js';
import { EXTERNAL_FORMAT_CONNECTION } from '../../../extensions/DSL_ExternalFormat_LegendStudioApplicationPlugin.js';
export class ExternalFormatConnectionValueState extends ConnectionValueState {
    connection;
    constructor(editorStore, connection) {
        super(editorStore, connection);
        this.connection = connection;
    }
    label() {
        return 'external format connection';
    }
}
export const ExternalFormatConnectionEditor = observer((props) => {
    const { connectionValueState, isReadOnly } = props;
    const connection = connectionValueState.connection;
    const changeUrl = (event) => externalFormat_urlStream_setUrl(connection.externalSource, event.target.value);
    return (_jsx("div", { className: "external-format-connection-editor", children: _jsxs("div", { className: "external-format-connection-editor__section", children: [_jsx("div", { className: "external-format-connection-editor__section__header__label", children: "URL" }), _jsx("div", { className: "external-format-connection-editor__section__header__prompt", children: "Specifies the connection URL" }), _jsx("textarea", { className: "external-format-connection-editor__section__textarea", spellCheck: false, value: connection.externalSource.url, onChange: changeUrl, disabled: isReadOnly })] }) }));
});
export class NewExternalFormatConnectionDriver extends NewConnectionValueDriver {
    constructor(editorStore) {
        super(editorStore);
        makeObservable(this, {
            isValid: computed,
        });
    }
    get isValid() {
        return true;
    }
    getConnectionType() {
        return EXTERNAL_FORMAT_CONNECTION;
    }
    createConnection(store) {
        const externalFormatConnection = new ExternalFormatConnection(PackageableElementExplicitReference.create(store));
        const urlStream = new UrlStream();
        externalFormat_urlStream_setUrl(urlStream, '');
        externalFormatConnection.externalSource = urlStream;
        return externalFormatConnection;
    }
}
//# sourceMappingURL=DSL_ExternalFormat_ExternalFormatConnectionEditor.js.map