import { mapStateToControlProps, or, rankWith } from '@jsonforms/core';
import { html } from '@microsoft/fast-element';
import { optionIs } from '../testers/optionIs';
import { SELECT_CONTROL_RANK } from './RenderersRanks';
export const ConnectedSelectControlRendererTemplate = html `
  <template>
    <control-wrapper
      :control=${(x) => x.control}
      :touched=${(x) => x.touched}
      ?submitted=${(x) => x.submitted}
    >
      <zero-combobox
        style="width: 100%"
        placeholder=${(x) => x.control.label}
        ?disabled=${(x) => !x.control.enabled}
        :value=${(x) => x.control.data || ''}
        @value-change=${(x, c) => {
    var _a;
    const value = (_a = c.event.detail) === null || _a === void 0 ? void 0 : _a.value;
    x.control.handleChange(x.control.path, value);
    x.onBlur();
}}
      >
        <options-datasource
          resourceName=${(x) => { var _a; return (_a = x.control.uischema.options) === null || _a === void 0 ? void 0 : _a.allOptionsResourceName; }}
          value-field=${(x) => { var _a; return (_a = x.control.uischema.options) === null || _a === void 0 ? void 0 : _a.valueField; }}
          label-field=${(x) => { var _a; return (_a = x.control.uischema.options) === null || _a === void 0 ? void 0 : _a.labelField; }}
          :data=${(x) => { var _a; return (_a = x.control.uischema.options) === null || _a === void 0 ? void 0 : _a.data; }}
          :initialSelectedValue=${(x) => x.control.data}
        ></options-datasource>
      </zero-combobox>
    </control-wrapper>
  </template>
`;
export const ConnectedSelectControlRendererEntry = {
    renderer: ConnectedSelectControlRendererTemplate,
    tester: rankWith(SELECT_CONTROL_RANK, or(optionIs('allOptionsResourceName'), optionIs('data'))),
    mapper: mapStateToControlProps,
};
//# sourceMappingURL=ConnectedSelectControlRenderer.js.map