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" / >
< / d e f s >
< 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" ) }
< / t e x t >
< / s v g > ` ;
}
// 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 ) => ( {
"&" : "&" ,
"<" : "<" ,
">" : ">" ,
"'" : "'" ,
'"' : """
} ) [ tag ] ) ;
}
} ;
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsic3JjL21haW4udHMiLCAic3JjL2NvbmZpZy50cyIsICJzcmMvcG9zaXRpb24udHMiLCAic3JjL2Zvcm1hdGlvbi50cyIsICJzcmMvc3ZnLWJ1aWxkZXIudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImltcG9ydCB7IGZvcm1hdGlvbnMgfSBmcm9tICdzcmMvZm9ybWF0aW9uJztcclxuaW1wb3J0IHsgTWFya2Rvd25Qb3N0UHJvY2Vzc29yQ29udGV4dCwgUGx1Z2luIH0gZnJvbSAnb2JzaWRpYW4nO1xyXG5pb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