import { defaultTemplate } from "./DefaultTemplate";
export var repeat = function (times) { return function (callback) {
    return Array(times)
        .fill(0)
        .map(function (_, index) { return callback(index); });
}; };
export var noop = function () { return void 0; };
// Currently using https://stackoverflow.com/questions/326069/how-to-identify-if-a-webpage-is-being-loaded-inside-an-iframe-or-directly-into-t
export var inIframe = function () {
    try {
        return window.self !== window.top;
    }
    catch (e) {
        return true;
    }
};
// TODO this function is weird, returns current template + templates for attachments
export function documentTemplates(document, templateRegistry, attachmentToComponent) {
    if (!document)
        return [];
    // Find the template in the template registry or use a default template
    var templateName = document && document.$template && document.$template.name;
    var selectedTemplate = (templateName && templateRegistry[templateName]) || [defaultTemplate];
    // Create additional tabs from attachments
    var templatesFromAttachments = (document.attachments || []).map(function (attachment, index) { return ({
        id: "attachment-" + index,
        label: attachment.filename || "Unknown filename",
        template: attachmentToComponent(attachment, document)
    }); });
    return selectedTemplate.concat(templatesFromAttachments);
}
//# sourceMappingURL=utils.js.map