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 attach_image_from_shape_exports = {};
__export(attach_image_from_shape_exports, {
  attachImageFromShape: () => attachImageFromShape
});
module.exports = __toCommonJS(attach_image_from_shape_exports);
var import_attach_image_to_map = require("./attach-image-to-map.js");
var import_create_bitmap_config_options = require("./create-bitmap-config-options.js");
var import_get_data_uri = require("./get-data-uri.js");
var import_constants = require("../constants.js");
var import_shape_picker = require("../shapes/shape-picker.js");
const attachImageFromShape = (map, shape, name, outputSize) => {
  const pickedShape = (0, import_shape_picker.getShape)(shape);
  const stringUrl = (0, import_get_data_uri.getDataUri)(encodeURIComponent(pickedShape));
  const img = new Image(import_constants.DEFAULT_INPUT_ICON_SIZE, import_constants.DEFAULT_INPUT_ICON_SIZE);
  img.addEventListener("load", () => {
    createImageBitmap(
      img,
      0,
      0,
      import_constants.DEFAULT_INPUT_ICON_SIZE,
      import_constants.DEFAULT_INPUT_ICON_SIZE,
      (0, import_create_bitmap_config_options.createBitmapConfigOptions)(outputSize)
    ).then((bitmap) => {
      (0, import_attach_image_to_map.attachImageToMap)(map, bitmap, name);
    });
  });
  img.src = stringUrl;
};
