"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 __async = (__this, __arguments, generator) => {
  return new Promise((resolve, reject) => {
    var fulfilled = (value) => {
      try {
        step(generator.next(value));
      } catch (e) {
        reject(e);
      }
    };
    var rejected = (value) => {
      try {
        step(generator.throw(value));
      } catch (e) {
        reject(e);
      }
    };
    var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
    step((generator = generator.apply(__this, __arguments)).next());
  });
};
var ServerWithExtension_stories_exports = {};
__export(ServerWithExtension_stories_exports, {
  ServerObjectWithClientExtension: () => ServerObjectWithClientExtension,
  default: () => ServerWithExtension_stories_default
});
module.exports = __toCommonJS(ServerWithExtension_stories_exports);
var import_react_relay = require("react-relay");
var import_relay = require("@nova/react-test-utils/relay");
var import_relay_test_utils = require("relay-test-utils");
var import_ServerWithExtension = require("./ServerWithExtension");
var import_test = require("@storybook/test");
var import_schema = require("../../../testing-utils/schema");
const novaDecorator = (0, import_relay.getNovaDecorator)(import_schema.schema, {
  generateFunction: (operation, mockResolvers) => {
    const result = import_relay_test_utils.MockPayloadGenerator.generate(
      operation,
      mockResolvers != null ? mockResolvers : null,
      {
        mockClientData: true
      }
    );
    return result;
  }
});
const meta = {
  component: import_ServerWithExtension.ServerWithExtension,
  decorators: [novaDecorator],
  parameters: {
    novaEnvironment: {
      query: import_react_relay.graphql`
        query ServerWithExtensionStoryRelayQuery @relay_test_operation {
          serverObjectWithClientExtension {
            ...ServerWithExtension_dataFragment
          }
        }
      `,
      referenceEntries: {
        data: (data) => data == null ? void 0 : data.serverObjectWithClientExtension
      },
      resolvers: {
        ServerObjectWithClientExtension: () => ({
          clientExtension: "This is a client extension field"
        })
      }
    }
  }
};
var ServerWithExtension_stories_default = meta;
const ServerObjectWithClientExtension = {
  parameters: {
    novaEnvironment: {
      resolvers: {
        ServerObjectWithClientExtension: () => ({
          clientExtension: "This is a custom client extension value"
        })
      }
    }
  },
  play: (_0) => __async(void 0, [_0], function* ({ canvasElement }) {
    const canvas = (0, import_test.within)(canvasElement);
    (0, import_test.expect)(
      yield canvas.findByText(/This is a custom client extension value/i)
    ).toBeInTheDocument();
  })
};
