import {L, Icon} from 'leaflet';
import ms from 'milsymbol'

const iconShip = new Icon({
  iconUrl: "./ship.svg",
  iconSize: [50, 50],
  // iconAnchor: [40, 90],
  popupAnchor: [-25, -40],
});

const HostileLetter = "H";
const FriendLetter = "F";
const NeutralLetter = "N";

const AirLetter = "A";
const SurfaceLetter = "S";
const SubsurfaceLetter = "U";

const Size = 25;

function createIcon(Type , Side )
{
  var TypeLetter = "S";
  var SideLetter = "N";
switch (Side) {
  case "Hostile":
    SideLetter = HostileLetter;
    break;
    case "Friend":
    SideLetter = FriendLetter;
    break;
    case "Neutral":
    SideLetter = NeutralLetter;
    break;

  default:
    SideLetter = "N";
    break;
}

switch (Type) {
  case "Air":
      TypeLetter = AirLetter;
    break;
    case "Surface":
      TypeLetter = SurfaceLetter;
    break;
    case "Subsurface":
      TypeLetter = SubsurfaceLetter;
    break;

  default:
    SideLetter = "N";
    break;
}

var IconS = new ms.Symbol(
  "S"+SideLetter+TypeLetter+"*"+"--------"
)
IconS = IconS.setOptions({ size: 25 });

var Symbol = new Icon({
  iconUrl: IconS.toDataURL(),
  iconAnchor: [IconS.getAnchor().x, IconS.getAnchor().y],
})

return Symbol
}

var Friend = new ms.Symbol(
  "SFS*--------", {
    // uniqueDesignation: "Friend"
  })
// Now that we have a symbol we can ask for the echelon and set the symbol size
Friend = Friend.setOptions({ size: 25 });

const friend = new Icon({
  iconUrl: Friend.toDataURL(),
  iconAnchor: [Friend.getAnchor().x, Friend.getAnchor().y],
});


var hostile = new ms.Symbol(
  "SHU*---------", {
    uniqueDesignation: "Hostile"
  })
// Now that we have a symbol we can ask for the echelon and set the symbol size
hostile = hostile.setOptions({ size: 25 });

const Hostile = new Icon({
  iconUrl: hostile.toDataURL(),
  iconAnchor: [hostile.getAnchor().x, hostile.getAnchor().y],
});

export { iconShip, friend,Hostile,createIcon };