{"version":3,"file":"ScaleElane.mjs","sources":["../../../../../packages/sdk/plugins/ScaleElane.ts"],"sourcesContent":["import L from 'leaflet'\n\ninterface ScaleOptions {\n  metric?: boolean\n  imperial?: boolean\n  nautic?: boolean\n}\n\nclass ScaleElane extends L.Control.Scale {\n  private _mScale!: HTMLElement\n  private _iScale!: HTMLElement\n  private _nScale!: HTMLElement\n\n  constructor(options: ScaleOptions) {\n    super(options)\n    this._addScales(options)\n  }\n\n  private _addScales(\n    options: ScaleOptions,\n    className?: string,\n    container?: HTMLElement\n  ) {\n    if (options.metric) {\n      this._mScale = L.DomUtil.create('div', className, container)\n    }\n    if (options.imperial) {\n      this._iScale = L.DomUtil.create('div', className, container)\n    }\n    if (options.nautic) {\n      this._nScale = L.DomUtil.create('div', className, container)\n    }\n  }\n\n  _updateScales(maxMeters: number) {\n    if (this.options.metric && maxMeters) {\n      this['_updateMetric'](maxMeters)\n    }\n    if (this.options.imperial && maxMeters) {\n      this['_updateImperial'](maxMeters)\n    }\n    if ((this.options as any).nautic && maxMeters) {\n      this._updateNautic(maxMeters)\n    }\n  }\n\n  private _updateNautic(maxMeters: number) {\n    const ratio = maxMeters / 1852\n    const text =\n      maxMeters >= 1852\n        ? this['_getRoundNum'](ratio)\n        : ratio > 0.1\n        ? Math.round(10 * ratio) / 10\n        : Math.round(100 * ratio) / 100\n    this._nScale.style.padding = '0px'\n    this._nScale.style['text-align'] = 'center'\n    this['_updateScale'](this._nScale, `${text}nm`, text / ratio)\n  }\n}\n\nexport default ScaleElane\n"],"names":["l","a","Control","Scale","constructor","t","super","this","_addScales","i","e","metric","_mScale","DomUtil","create","imperial","_iScale","nautic","_nScale","_updateScales","options","_updateMetric","_updateImperial","_updateNautic","_getRoundNum","Math","round","style","padding","_updateScale"],"mappings":"uBAAuB,MAAMA,UAAUC,EAAEC,QAAQC,MAAM,WAAAC,CAAYC,GAAGC,MAAMD,GAAGE,KAAKC,WAAWH,EAAE,CAAC,UAAAG,CAAWH,EAAEI,EAAEC,GAAGL,EAAEM,SAASJ,KAAKK,QAAQX,EAAEY,QAAQC,OAAO,MAAML,EAAEC,IAAIL,EAAEU,WAAWR,KAAKS,QAAQf,EAAEY,QAAQC,OAAO,MAAML,EAAEC,IAAIL,EAAEY,SAASV,KAAKW,QAAQjB,EAAEY,QAAQC,OAAO,MAAML,EAAEC,GAAG,CAAC,aAAAS,CAAcd,GAAGE,KAAKa,QAAQT,QAAQN,GAAGE,KAAKc,cAAchB,GAAGE,KAAKa,QAAQL,UAAUV,GAAGE,KAAKe,gBAAgBjB,GAAGE,KAAKa,QAAQH,QAAQZ,GAAGE,KAAKgB,cAAclB,EAAE,CAAC,aAAAkB,CAAclB,GAAG,MAAMI,EAAEJ,EAAE,KAAKK,EAAEL,GAAG,KAAKE,KAAKiB,aAAaf,GAAGA,EAAE,GAAGgB,KAAKC,MAAM,GAAGjB,GAAG,GAAGgB,KAAKC,MAAM,IAAIjB,GAAG,IAAIF,KAAKW,QAAQS,MAAMC,QAAQ,MAAMrB,KAAKW,QAAQS,MAAM,cAAc,SAASpB,KAAKsB,aAAatB,KAAKW,QAAQ,GAAGR,MAAMA,EAAED,EAAE"}