"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var Search_stories_exports = {};
__export(Search_stories_exports, {
  Default: () => Default,
  WithInteraction: () => WithInteraction,
  default: () => Search_stories_default
});
module.exports = __toCommonJS(Search_stories_exports);
var import_test = require("@storybook/test");
var import_Search = require("./Search");
const onDebouncedChange = (0, import_test.fn)();
const onChange = (0, import_test.fn)();
const meta = {
  component: import_Search.Search,
  title: "PreLdls/Components/Search",
  tags: ["autodocs"],
  args: {
    debounceTime: 500,
    placeholder: "Search",
    onDebouncedChange,
    onChange
  }
};
var Search_stories_default = meta;
const Default = {};
const WithInteraction = {
  args: {
    debounceTime: 100
  },
  play: async ({ canvasElement }) => {
    const canvas = (0, import_test.within)(canvasElement);
    const search = canvas.getByRole("textbox");
    await import_test.userEvent.type(search, "Write something");
    (0, import_test.expect)(search).toHaveValue("Write something");
    (0, import_test.expect)(onChange).toHaveBeenCalledTimes("Write something".length);
    (0, import_test.expect)(onDebouncedChange).not.toHaveBeenCalled();
    await (0, import_test.waitFor)(() => (0, import_test.expect)(onDebouncedChange).toHaveBeenCalledTimes(1), { timeout: 200 });
    (0, import_test.expect)(onDebouncedChange).toHaveBeenCalledWith("Write something", "");
    await import_test.userEvent.clear(search);
    await import_test.userEvent.type(search, "Write something else");
    (0, import_test.expect)(onDebouncedChange).toHaveBeenCalledTimes(1);
    await (0, import_test.waitFor)(() => (0, import_test.expect)(onDebouncedChange).toHaveBeenCalledTimes(2), { timeout: 200 });
    (0, import_test.expect)(onDebouncedChange).toHaveBeenCalledWith("Write something else", "Write something");
  }
};
//# sourceMappingURL=Search.stories.js.map
