.paste-header
    - import pastemyst.paste : pasteLangStats;
    - const langStats = pasteLangStats(paste);
    .top(class=langStats.length == 0 ? "all-border-rads" : "")
        .left
            -if(paste.title != "")
                p.title= paste.title
            -else
                p.title.untitled (untitled)
            - static if (is(typeof(previousRevision)))
                - if (previousRevision)
                    p.current-edit (at edit ##{currentEditId})

        .right
            - if (historyPage)
                a.history(href="/" ~ paste.id) pasties
            - else
                - static if (is(typeof(previousRevision)))
                    - if (previousRevision)
                        a.history(href="/" ~ paste.id) present
                - if (paste.edits.length > 0)
                    a.history(href="/" ~ paste.id ~ "/history") history
            - if (session.loggedIn)
                form(method="post", action="/" ~ paste.id ~ "/star", class="star-form")
                    - import std.algorithm : canFind;
                    - import pastemyst.db : findOneById;
                    - import pastemyst.data : User;
                    - const user = session.getSessionUser();
                    - bool isStarred = user.stars.canFind(paste.id);
                    button.tooltip.star(type="submit")
                        i.fas.fa-star(class=isStarred?"starred":"")
                        span.amount= paste.stars
                        span.tooltip-text star
            - else
                a.tooltip.star
                    i.fas.fa-star
                    span.amount= paste.stars
                    span.tooltip-text star
            a.tooltip.copy-link(href="/" ~ paste.id)
                i.fas.fa-link
                span.tooltip-text copy link
            - string copyEditUrl = "/" ~ paste.id ~ "/history/";
            - import std.conv : to;
            - static if (is(typeof(previousRevision)))
                - if (previousRevision)
                    - copyEditUrl ~= currentEditId.to!string();
            - else
                - if (paste.edits.length > 0)
                    - copyEditUrl ~= (paste.edits[$-1].editId + 1).to!string();
                - else
                    - copyEditUrl ~= "0";
            - if (!paste.encrypted)
                a.tooltip.copy-link-edit(href=copyEditUrl)
                    i.fas.fa-anchor
                    span.tooltip-text copy link to this edit

            - if (!paste.isPrivate && !paste.encrypted)
                a.tooltip(href="/clone/" ~ paste.id)
                    i.fas.fa-clone
                    span.tooltip-text clone

                a.tooltip.embed-script-copy
                    - import pastemyst.data : config;
                    i.fas.fa-pager
                    span.tooltip-text copy embed script
                    input(type="text", class="embed-script", value="<iframe src='#{config.hostname}#{paste.id}/embed' scrolling='no' style='width:80%;border:none;'></iframe><script src='#{config.hostname}static/scripts/libs/iframeResizer.js'></script><script>iFrameResize();</script>")

                a.tooltip.download(href="/" ~ paste.id ~ ".zip")
                    i.fas.fa-download
                    span.tooltip-text download paste as zip

            -if(paste.ownerId != "" && session.userId == paste.ownerId)
                - if (!paste.encrypted)
                    a.tooltip(href="/" ~ paste.id ~ "/edit")
                        i.fas.fa-edit
                        span.tooltip-text edit paste

                - if (!paste.isPrivate)
                    form.set-public-on-profile-paste(method="post", action="/" ~ paste.id ~ "/togglePublicOnProfile")
                        -if (paste.isPublic)
                            button.public.tooltip(type="submit")
                                i.fas.fa-eye
                                span.tooltip-text set to private on profile
                        -else
                            button.not-public.tooltip(type="submit")
                                i.fas.fa-eye
                                span.tooltip-text set to public on profile

                - if (!paste.isPublic)
                    form.set-private-paste(method="post", action="/" ~ paste.id ~ "/togglePrivate")
                        - if (paste.isPrivate)
                            button.private.tooltip(type="submit")
                                i.fas.fa-lock
                                span.tooltip-text set to public
                        - else
                            button.not-private.tooltip(type="submit")
                                i.fas.fa-lock
                                span.tooltip-text set to private

                form.set-anon-paste(method="post", action="/" ~ paste.id ~ "/anon", onsubmit="return confirm('are you sure you want to make the paste anonymous? this action can\\'t be undone.');")
                    button.tooltip(type="submit")
                        img(src="/static/assets/icons/ghostmyst.svg", alt="delete image")
                        span.tooltip-text make paste anonymous

                form.delete-paste(method="post", action="/" ~ paste.id ~ "/delete", onsubmit="return confirm('are you sure you want to delete this paste? you won\\'t be able to recover it.');")
                    button.tooltip(type="submit")
                        i.fas.fa-trash
                        span.tooltip-text delete paste
    - if (langStats.length > 0)
        include components/langBar
