"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = _default;

var _index = require("./index");

var _openDataPainter = _interopRequireDefault(require("../common-painter/openDataPainter"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }

function _default(_x, _x2, _x3, _x4) {
  return _ref.apply(this, arguments);
}

function _ref() {
  _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(ctx, y, name, id) {
    var lineHeight, _ctx$measureText, width, namePainter, x;

    return regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            y += 4;
            lineHeight = 22;
            ctx.font = "bold 16px/".concat(lineHeight, "px arial,sans-serif");
            ctx.fillStyle = "#141C28";
            ctx.textBaseline = "middle";
            _ctx$measureText = ctx.measureText("的 OKR"), width = _ctx$measureText.width;
            _context.next = 8;
            return (0, _openDataPainter["default"])(ctx, {
              id: id,
              name: name,
              type: "userName"
            }, lineHeight, 200);

          case 8:
            namePainter = _context.sent;
            x = (_index.pinkCardwidth - (namePainter.width + width)) / 2;
            namePainter.draw(ctx, x, y);
            ctx.fillText("的 OKR", x + namePainter.width, y + lineHeight / 2);
            return _context.abrupt("return", y + lineHeight);

          case 13:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _ref.apply(this, arguments);
}