"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var preset_data_exports = {};
__export(preset_data_exports, {
  PRESET_TYPE: () => PRESET_TYPE,
  createInitialPollData: () => createInitialPollData
});
module.exports = __toCommonJS(preset_data_exports);
var import_lodash = __toESM(require("lodash"));
var import_v1 = require("./../../../ricos-schema/legacy/wix/rich_content/v1/index.js");
var import_uncreachable = require("./../../../_shared/uncreachable.js");
var import_defaults = require("../../defaults.js");
var import_helpers = require("../../helpers.js");
const PRESET_TYPE = {
  LIST: "list",
  LIST_WITH_IMAGE: "listWithImage",
  GRID: "grid"
};
const createInitialPollData = (config, presetType) => {
  const initialData = import_lodash.default.merge({}, import_defaults.DEFAULT_RICOS_COMPONENT_DATA, {
    poll: {
      settings: {
        permissions: { vote: config?.voteRole || import_v1.PollData_Poll_Settings_Permissions_VoteRole.ALL }
      }
    }
  });
  const layoutData = (() => {
    switch (presetType) {
      case PRESET_TYPE.LIST: {
        return {
          poll: {
            type: import_v1.PollData_Layout_PollLayout_Type.LIST,
            enableImage: false
          },
          options: {
            enableImage: false
          }
        };
      }
      case PRESET_TYPE.LIST_WITH_IMAGE: {
        return {
          poll: {
            type: import_v1.PollData_Layout_PollLayout_Type.LIST,
            enableImage: true
          },
          options: {
            enableImage: false
          }
        };
      }
      case PRESET_TYPE.GRID: {
        return {
          poll: {
            type: import_v1.PollData_Layout_PollLayout_Type.GRID,
            enableImage: false
          },
          options: {
            enableImage: true
          }
        };
      }
      default:
        (0, import_uncreachable.unreachable)(presetType);
        throw new Error("Unknown preset type", presetType);
    }
  })();
  return import_lodash.default.merge({}, initialData, {
    poll: {
      image: { src: { url: (0, import_helpers.getRandomValue)(import_defaults.POLL_IMAGES_POOL) } },
      options: [
        {
          title: "",
          image: { src: { url: (0, import_helpers.getRandomValue)(import_defaults.OPTION_IMAGES_POOL) } }
        },
        {
          title: "",
          image: { src: { url: (0, import_helpers.getRandomValue)(import_defaults.OPTION_IMAGES_POOL) } }
        }
      ]
    },
    layout: layoutData,
    design: {
      poll: {
        background: {
          type: import_v1.PollData_Design_PollDesign_Background_Type.IMAGE,
          image: {
            src: {
              url: (0, import_helpers.getRandomValue)(
                import_defaults.BACKGROUND_PRESETS[import_v1.PollData_Design_PollDesign_Background_Type.IMAGE]
              )
            }
          }
        }
      },
      borderRadius: 0,
      options: { borderRadius: 0 }
    }
  });
};
//# sourceMappingURL=preset-data.js.map
