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 __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __export = (target, all) => {
  __markAsModule(target);
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __reExport = (target, module2, desc) => {
  if (module2 && typeof module2 === "object" || typeof module2 === "function") {
    for (let key of __getOwnPropNames(module2))
      if (!__hasOwnProp.call(target, key) && key !== "default")
        __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
  }
  return target;
};
var __toModule = (module2) => {
  return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
};
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());
  });
};

// src/main.ts
__export(exports, {
  default: () => LineupBuilderPlugin
});

// src/config.ts
var KEEPER_COLOUR = "#808080";
var DEFENDER_COLOUR = "#2009ff";
var MIDFIELDER_COLOUR = "#ff0";
var FORWARD_COLOUR = "#f00";

// src/position.ts
var GK = {
  x: 772,
  y: 1670,
  circleColour: KEEPER_COLOUR
};
var LB = {
  x: 272,
  y: 1347,
  circleColour: DEFENDER_COLOUR
};
var CBL = {
  x: 571,
  y: 1447,
  circleColour: DEFENDER_COLOUR
};
var CBR = {
  x: 970,
  y: 1447,
  circleColour: DEFENDER_COLOUR
};
var RB = {
  x: 1272,
  y: 1347,
  circleColour: DEFENDER_COLOUR
};
var LWB = {
  x: 272,
  y: 1247,
  circleColour: DEFENDER_COLOUR
};
var LCB = {
  x: 471,
  y: 1447,
  circleColour: DEFENDER_COLOUR
};
var CCB = {
  x: 772,
  y: 1420,
  circleColour: DEFENDER_COLOUR
};
var RCB = {
  x: 1070,
  y: 1447,
  circleColour: DEFENDER_COLOUR
};
var RWB = {
  x: 1272,
  y: 1247,
  circleColour: DEFENDER_COLOUR
};
var CDM = {
  x: 772,
  y: 1083,
  circleColour: MIDFIELDER_COLOUR
};
var LDM = {
  x: 551.8,
  y: 1083,
  circleColour: MIDFIELDER_COLOUR
};
var RDM = {
  x: 988.8,
  y: 1083,
  circleColour: MIDFIELDER_COLOUR
};
var CML = {
  x: 571,
  y: 976,
  circleColour: MIDFIELDER_COLOUR
};
var CMR = {
  x: 970,
  y: 976,
  circleColour: MIDFIELDER_COLOUR
};
var LCM = {
  x: 417,
  y: 883,
  circleColour: MIDFIELDER_COLOUR
};
var RCM = {
  x: 1152,
  y: 883,
  circleColour: MIDFIELDER_COLOUR
};
var CAM = {
  x: 772,
  y: 580.9,
  circleColour: MIDFIELDER_COLOUR
};
var LAM = {
  x: 319.1,
  y: 580.9,
  circleColour: MIDFIELDER_COLOUR
};
var RAM = {
  x: 1211.8,
  y: 580.9,
  circleColour: MIDFIELDER_COLOUR
};
var LM = {
  x: 328,
  y: 775,
  circleColour: MIDFIELDER_COLOUR
};
var RM = {
  x: 1216,
  y: 775,
  circleColour: MIDFIELDER_COLOUR
};
var RW = {
  x: 1258,
  y: 363,
  circleColour: FORWARD_COLOUR
};
var LW = {
  x: 282,
  y: 363,
  circleColour: FORWARD_COLOUR
};
var LS = {
  x: 588,
  y: 260,
  circleColour: FORWARD_COLOUR
};
var RS = {
  x: 962,
  y: 260,
  circleColour: FORWARD_COLOUR
};
var ST = {
  x: 772,
  y: 193,
  circleColour: FORWARD_COLOUR
};

// src/formation.ts
var formations = [
  {
    name: "442",
    positions: [GK, LB, CBL, CBR, RB, LM, CML, CMR, RM, LS, RS]
  },
  {
    name: "433",
    positions: [GK, LB, CBL, CBR, RB, LCM, CDM, RCM, LW, ST, RW]
  },
  {
    name: "4231",
    positions: [GK, LB, CBL, CBR, RB, LDM, RDM, LAM, CAM, RAM, ST]
  },
  {
    name: "442-diamond",
    positions: [GK, LB, CBL, CBR, RB, CDM, LM, RM, CAM, LS, RS]
  },
  {
    name: "4411",
    positions: [GK, LB, CBL, CBR, RB, LM, CML, CMR, RM, CAM, ST]
  },
  {
    name: "4141",
    positions: [GK, LB, CBL, CBR, RB, CDM, LM, CML, CMR, RM, ST]
  },
  {
    name: "424",
    positions: [GK, LB, CBL, CBR, RB, CML, CMR, LAM, RAM, LS, RS]
  },
  {
    name: "541",
    positions: [GK, LWB, LCB, CCB, RCB, RWB, LM, CML, CMR, RM, ST]
  },
  {
    name: "523",
    positions: [GK, LWB, LCB, CCB, RCB, RWB, CML, CMR, LW, ST, RW]
  },
  {
    name: "532",
    positions: [GK, LWB, LCB, CCB, RCB, RWB, LCM, CDM, RCM, LS, RS]
  },
  {
    name: "343",
    positions: [GK, LCB, CCB, RCB, LM, CML, CMR, RM, LW, ST, RW]
  },
  {
    name: "352",
    positions: [GK, LCB, CCB, RCB, LM, LDM, RDM, RM, CAM, LS, RS]
  }
];

// src/main.ts
var import_obsidian = __toModule(require("obsidian"));

// src/svg-builder.ts
var LABEL_OFFSET_X = -69;
var LABEL_OFFSET_Y = 140;
function buildLabels(positions, players) {
  let labels = [];
  for (var i = 0; i < positions.length; i++) {
    labels[i] = buildLabel(positions[i], players[i]);
  }
  return labels;
}
function buildCircles(positions) {
  return positions.map((position) => buildCircle(position));
}
function buildLabel(position, playerName) {
  return `<tspan x="${position.x + LABEL_OFFSET_X}" y="${position.y + LABEL_OFFSET_Y}">${playerName}</tspan>`;
}
function buildCircle(position) {
  return `<use xlink:href="#pos" x="${position.x}" y="${position.y}" fill="${position.circleColour}"/>`;
}
function buildSvg(positions, players) {
  return `
        <svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 1384 1920" preserveAspectRatio="xMinYMin" version="1.1">
        <path d="M44.5,34.5h1312v1856h-1312z" fill="#393"/>
        <path d="M69,59h1264.5v1808.5h-1264.5zM69,964h820.6a197.1,197.1 0 0 1-394.2,0a197.1,197.1 0 0 1 394.2,0h444M515,59v173h373.6v-173M331,59v347h740v-347M515,1868v-173h373.6v173M331,1868v-347h740v347" fill="none" stroke="#fff" stroke-width="4"/>
        <defs>
        <path d="m0,0a72,72 0 0 1-144,0 72,72 0 1 1 144,0z" id="pos"/>
        </defs>

        <g stroke="#000" stroke-width="6">
            ${buildCircles(positions).join("\n")}
        </g>

        <text style="font-size:56px;text-align:center;line-height:125%;text-anchor:middle;fill:#000000;font-family:Bitstream Vera Sans" x="709.4" y="1871.6" linespacing="125%">
            ${buildLabels(positions, players).join("\n")}
        </text>
        </svg>`;
}

// src/main.ts
var LineupBuilderPlugin = class extends import_obsidian.Plugin {
  onInit() {
  }
  onload() {
    return __async(this, null, function* () {
      this.registerMarkdownCodeBlockProcessor("lineup", this.draw_lineup());
    });
  }
  draw_lineup() {
    return (source, el, ctx) => {
      const { formation, players } = LineupBuilderPlugin.parseCode(source);
      const xmlns = "http://www.w3.org/2000/svg";
      var boxWidth = 346;
      var boxHeight = 480;
      var block = document.createElementNS(xmlns, "svg");
      block.setAttributeNS(null, "viewBox", "0 0 " + boxWidth + " " + boxHeight);
      block.setAttributeNS(null, "width", String(boxWidth));
      block.setAttributeNS(null, "height", String(boxHeight));
      block.innerHTML = buildSvg(formation.positions, players);
      el.appendChild(block);
    };
  }
  static parseCode(input) {
    const lines = input.split(/\r?\n/);
    let formation = lines[0];
    if (formation.startsWith("formation: ")) {
      formation = formation.replace("formation: ", "");
    }
    let players = [];
    let playersLine = lines[1];
    if (playersLine.startsWith("players: ")) {
      players = this.escapeHTML(playersLine).replace("players: ", "").split(",");
    }
    return {
      formation: formations.find((x) => x.name === formation),
      players
    };
  }
  static escapeHTML(str) {
    return str.replace(/[&<>'"]/g, (tag) => ({
      "&": "&amp;",
      "<": "&lt;",
      ">": "&gt;",
      "'": "&#39;",
      '"': "&quot;"
    })[tag]);
  }
};
//# sourceMappingURL=data:application/json;base64,[encoded data, 18584 characters]
