<!DOCTYPE html>
<html>

<head>
  <meta charset='UTF-8'/>
  <link href='/base/base.css?<%=obj.nocache%>' rel='stylesheet' />
  <link href='/app/app.css?<%=obj.nocache%>' rel='stylesheet' />
  <link href='/app/export.css?<%=obj.nocache%>' rel='stylesheet' />
  <%= this.analytics(obj) %>
  <title><%= source.name || 'Untitled' %></title>
</head>

<body id='view' class='fill-denim pad4y <%= job.progress ? 'task' : 'stat' %>'>

<div id='modal-content' class='modal-content animate'></div>

<div class='clearfix limiter'>
  <div class='dark center target round col6 margin3 contain'>
    <div class='pad2 fill-darken0'>
      <h2><%= source.name || 'Untitled' %></h2>

      <% var pct = job.progress ? (job.progress.percentage).toFixed(1) : '100.0'; %>
      <small class='quiet'>
        <span class='stat dash'><span class='size'><%= job.size ? this.exportsize(job.size) : 0 %></span> &mdash;</span>
        <span class='task'><span class='speed'><%= job.progress ? job.progress.speed : 0 %> tiles/sec </span> &mdash;</span>
        z<%= source.minzoom %>-<%= source.maxzoom %>
      </small>
    </div>
    <div class='pad2y fill-darken1'>
        <h1 class='percent'><%= pct %></h1>
        <div class='pad0 fill-darken1 round col8 margin2 progress space-bottom2'>
          <div class='pad0 fill-white fill' style='width:<%= pct %>%'></div>
        </div>
      <a href='/source?id=<%=source.id%>' class='button submit icon x task js-cancel'> Cancel export</a>
      <div class='stat col8 margin2 pad1'>
        <% if (job.type === 'upload') { %>
        <a href='https://www.mapbox.com/uploads/?source=data' target='_blank' class='col12 short button icon stat cloud'>View data</a>
        <small class='space-top2'>
            It may take some time for your changes to process and propagate. Check <a href='https://www.mapbox.com/uploads/?source=data'>our web interface</a> for the status of your uploads
        </small>
        <% } else if (job.type === 'export') { %>
        <a href='/source.mbtiles?id=<%= job.id %>' class='col12 short button icon folder stat'>Download</a>
        <% } %>
      </div>

      <div class='stat col12 pad1'>
        <a href='#recache' class='js-recache quiet strong small icon refresh'>Redo <%= job.type %></a>
      </div>
    </div>

    <a href='/source?id=<%=source.id%>' class='button icon quiet prev col12 round-bottom stat'>Back</a>
  </div>
</div>

<script src='/ext/underscore-min.js?<%=obj.nocache%>'></script>
<script src='/ext/jquery-2.0.3.min.js?<%=obj.nocache%>'></script>
<script src='/ext/backbone.js?<%=obj.nocache%>'></script>
<script src='/app/lib.js?<%=obj.nocache%>'></script>
<script src='/app/export.js?<%=obj.nocache%>'></script>
<script src='/app/atom.js?<%=obj.nocache%>'></script>
<script>
var templates = {};
templates.exportsize = <%= this.exportsize.source %>;
templates.modalerror = <%= this.modalerror.source %>;

var source = <%= saferstringify(source, null, 2) %>;
var job = <%= saferstringify(job, null, 2) %>;

Export(templates, source , job);

</script>

<% if (test) { %>
<script>window.testParams = <%= saferstringify(test, null, 0) %>;</script>
<script src='/app/test/tape.js?<%=obj.nocache%>'></script>
<script src='/app/test/app.test.<%= job.type %>.js?<%=obj.nocache%>'></script>
<% } %>

</body>

</html>
