"use strict";

exports.__esModule = true;
exports.default = void 0;

var _react = _interopRequireDefault(require("react"));

var _core = require("@superset-ui/core");

var _chartControls = require("@superset-ui/chart-controls");

var _types = require("./types");

var _controls = require("../controls");

var _react2 = require("@emotion/react");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
 */
const noopControl = {
  name: 'noop',
  config: {
    type: '',
    renderTrigger: true
  }
};
const requiredEntity = { ..._chartControls.sharedControls.entity,
  clearable: false
};
const optionalEntity = { ..._chartControls.sharedControls.entity,
  clearable: true,
  validators: []
};
const controlPanel = {
  controlPanelSections: [_chartControls.sections.legacyRegularTime, {
    label: (0, _core.t)('Query'),
    expanded: true,
    controlSetRows: [[{
      name: 'source',
      config: { ...requiredEntity,
        label: (0, _core.t)('Source'),
        description: (0, _core.t)('Name of the source nodes')
      }
    }], [{
      name: 'target',
      config: { ...requiredEntity,
        label: (0, _core.t)('Target'),
        description: (0, _core.t)('Name of the target nodes')
      }
    }], ['metric'], [{
      name: 'source_category',
      config: { ...optionalEntity,
        label: (0, _core.t)('Source category'),
        description: (0, _core.t)('The category of source nodes used to assign colors. ' + 'If a node is associated with more than one category, only the first will be used.')
      }
    }], [{
      name: 'target_category',
      config: { ...optionalEntity,
        label: (0, _core.t)('Target category'),
        description: (0, _core.t)('Category of target nodes')
      }
    }], ['adhoc_filters'], ['row_limit']]
  }, {
    label: (0, _core.t)('Chart options'),
    expanded: true,
    controlSetRows: [['color_scheme'], [(0, _react2.jsx)("h1", {
      className: "section-header"
    }, (0, _core.t)('Legend'))], [_controls.showLegendControl], [_controls.legendTypeControl, _controls.legendOrientationControl], [_controls.legendMarginControl, noopControl], [(0, _react2.jsx)("h1", {
      className: "section-header"
    }, (0, _core.t)('Layout'))], [{
      name: 'layout',
      config: {
        type: 'RadioButtonControl',
        renderTrigger: true,
        label: (0, _core.t)('Graph layout'),
        default: _types.DEFAULT_FORM_DATA.layout,
        options: [['force', (0, _core.t)('Force')], ['circular', (0, _core.t)('Circular')]],
        description: (0, _core.t)('Layout type of graph')
      }
    }], [{
      name: 'draggable',
      config: {
        type: 'CheckboxControl',
        label: (0, _core.t)('Enable node dragging'),
        renderTrigger: true,
        default: _types.DEFAULT_FORM_DATA.draggable,
        description: (0, _core.t)('Whether to enable node dragging in force layout mode.'),

        visibility({
          form_data: {
            layout
          }
        }) {
          return layout === 'force' || !layout && _types.DEFAULT_FORM_DATA.layout === 'force';
        }

      }
    }], [{
      name: 'roam',
      config: {
        type: 'SelectControl',
        label: (0, _core.t)('Enable graph roaming'),
        renderTrigger: true,
        default: _types.DEFAULT_FORM_DATA.roam,
        choices: [[false, (0, _core.t)('Disabled')], ['scale', (0, _core.t)('Scale only')], ['move', (0, _core.t)('Move only')], [true, (0, _core.t)('Scale and Move')]],
        description: (0, _core.t)('Whether to enable changing graph position and scaling.')
      }
    }], [{
      name: 'selectedMode',
      config: {
        type: 'SelectControl',
        renderTrigger: true,
        label: (0, _core.t)('Node select mode'),
        default: _types.DEFAULT_FORM_DATA.selectedMode,
        choices: [[false, (0, _core.t)('Disabled')], ['single', (0, _core.t)('Single')], ['multiple', (0, _core.t)('Multiple')]],
        description: (0, _core.t)('Allow node selections')
      }
    }], [{
      name: 'showSymbolThreshold',
      config: {
        type: 'TextControl',
        label: (0, _core.t)('Label threshold'),
        renderTrigger: true,
        isInt: true,
        default: _types.DEFAULT_FORM_DATA.showSymbolThreshold,
        description: (0, _core.t)('Minimum value for label to be displayed on graph.')
      }
    }], [{
      name: 'edgeLength',
      config: {
        type: 'SliderControl',
        label: (0, _core.t)('Edge length'),
        renderTrigger: true,
        min: 100,
        max: 1000,
        step: 50,
        default: _types.DEFAULT_FORM_DATA.edgeLength,
        description: (0, _core.t)('Edge length between nodes'),

        visibility({
          form_data: {
            layout
          }
        }) {
          return layout === 'force' || !layout && _types.DEFAULT_FORM_DATA.layout === 'force';
        }

      }
    }], [{
      name: 'gravity',
      config: {
        type: 'SliderControl',
        label: (0, _core.t)('Gravity'),
        renderTrigger: true,
        min: 0.1,
        max: 1,
        step: 0.1,
        default: _types.DEFAULT_FORM_DATA.gravity,
        description: (0, _core.t)('Strength to pull the graph toward center'),

        visibility({
          form_data: {
            layout
          }
        }) {
          return layout === 'force' || !layout && _types.DEFAULT_FORM_DATA.layout === 'force';
        }

      }
    }], [{
      name: 'repulsion',
      config: {
        type: 'SliderControl',
        label: (0, _core.t)('Repulsion'),
        renderTrigger: true,
        min: 100,
        max: 3000,
        step: 50,
        default: _types.DEFAULT_FORM_DATA.repulsion,
        description: (0, _core.t)('Repulsion strength between nodes'),

        visibility({
          form_data: {
            layout
          }
        }) {
          return layout === 'force' || !layout && _types.DEFAULT_FORM_DATA.layout === 'force';
        }

      }
    }], [{
      name: 'friction',
      config: {
        type: 'SliderControl',
        label: (0, _core.t)('Friction'),
        renderTrigger: true,
        min: 0.1,
        max: 1,
        step: 0.1,
        default: _types.DEFAULT_FORM_DATA.friction,
        description: (0, _core.t)('Friction between nodes'),

        visibility({
          form_data: {
            layout
          }
        }) {
          return layout === 'force' || !layout && _types.DEFAULT_FORM_DATA.layout === 'force';
        }

      }
    }]]
  }]
};
var _default = controlPanel;
exports.default = _default;