"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EmailAction = void 0;
var tslib_1 = require("tslib");
var tpl_1 = require("../utils/tpl");
var pick_1 = (0, tslib_1.__importDefault)(require("lodash/pick"));
var mapValues_1 = (0, tslib_1.__importDefault)(require("lodash/mapValues"));
var qs_1 = (0, tslib_1.__importDefault)(require("qs"));
var Action_1 = require("./Action");
/**
 * 邮件动作
 *
 * @export
 * @class EmailAction
 * @implements {Action}
 */
var EmailAction = /** @class */ (function () {
    function EmailAction() {
    }
    EmailAction.prototype.run = function (action, renderer, event) {
        return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
            var mailTo, mailInfo, mailStr, mailto;
            return (0, tslib_1.__generator)(this, function (_a) {
                mailTo = (0, tpl_1.filter)(action.to, action.args);
                mailInfo = (0, mapValues_1.default)((0, pick_1.default)(action, 'to', 'cc', 'bcc', 'subject', 'body'), function (val) { return (0, tpl_1.filter)(val, action.args); });
                mailStr = qs_1.default.stringify(mailInfo);
                mailto = "mailto:" + mailTo + "?" + mailStr;
                window.open(mailto);
                return [2 /*return*/];
            });
        });
    };
    return EmailAction;
}());
exports.EmailAction = EmailAction;
(0, Action_1.registerAction)('email', new EmailAction());
//# sourceMappingURL=./actions/EmailAction.js.map
