"use strict";

exports.__esModule = true;
exports.MultiReferenceEditUniDriver = MultiReferenceEditUniDriver;
var _unidriver = require("../../../../unidriver");
const {
  fireEvent = null
} = process.env.NODE_ENV === 'test' ? (() => {
  try {
    return require('@testing-library/react');
  } catch {}
  return {};
})() : {};
function MultiReferenceEditUniDriver(base, body) {
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  const getNativeInput = () => base.$('input').getNative();
  return {
    ...(0, _unidriver.baseUniDriverFactory)(base),
    hasInput: () => base.$('input').exists(),
    getInputValue: () => base.$('input').value(),
    getTagsCount: () => base.$$('[data-hook="multi-reference-edit-tag"]').count(),
    typeInInput: async value => {
      fireEvent.change(await getNativeInput(), {
        target: {
          value
        }
      });
    },
    pressKeyOnInput: async key => {
      fireEvent.keyDown(await getNativeInput(), {
        key
      });
    },
    // Dropdown options are portal-mounted to document.body, so search in body.
    getOptionCount: async () => body.$$('[data-hook="list-item-select"]').count(),
    getOptionTitleByIndex: async index => {
      const option = await body.$$('[data-hook="list-item-select"]').get(index);
      return option.$('[data-hook="list-item-select-title"]').text();
    },
    clickOptionByIndex: async index => {
      const option = await body.$$('[data-hook="list-item-select"]').get(index);
      return option.click();
    },
    hasOpenCollectionButton: () => body.$('[data-hook="reference-open-collection"]').exists(),
    clickOpenCollection: async () => {
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
      const el = body.$('[data-hook="reference-open-collection"]').getNative();
      fireEvent.click(await el);
    }
  };
}
//# sourceMappingURL=Edit.uni.driver.js.map