var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
define(["require", "exports", "jquery"], function (require, exports, jquery_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.updateTemplate = exports.appendTemplate = exports.getMDTarget = void 0;
    jquery_1 = __importDefault(jquery_1);
    function getMDTarget(self) {
        return self.getAttribute("data-md-target");
    }
    exports.getMDTarget = getMDTarget;
    function appendTemplate(node, templateSelector, changeFunc) {
        if (!node) {
            throw "appendTemplate(node) is no defined";
        }
        const template = document.querySelector(templateSelector);
        if (!template) {
            throw "appendTemplate(template) is no defined";
        }
        const clone = (0, jquery_1.default)("<div/>").html(template.innerHTML);
        if (changeFunc) {
            changeFunc(clone);
        }
        (0, jquery_1.default)(node).append(clone.html());
    }
    exports.appendTemplate = appendTemplate;
    function updateTemplate(templateSelector, changeFunc) {
        const template = document.querySelector(templateSelector);
        if (!template) {
            throw "updateTemplate(template) is no defined";
        }
        const clone = (0, jquery_1.default)("<div/>").html(template.innerHTML);
        changeFunc(clone);
        template.innerHTML = clone.html();
    }
    exports.updateTemplate = updateTemplate;
});
