<% extends 'layout.html' %>

<% block content %>
  <div id="newsletters_container"></div>

  <script type="text/javascript">
    <% autoescape 'js' %>
      var mailpoet_update_available = <%= is_mailpoet_update_available ? 'true' : 'false' %>
      var mailpoet_listing_per_page = <%= items_per_page %>;
      var mailpoet_display_nps_poll = <%= (sent_newsletters_count > 0 and settings.display_nps_poll) ? 'true' : 'false' %>;
      var mailpoet_segments = <%= json_encode(segments) %>;
      var mailpoet_show_congratulate_after_first_newsletter = <%= show_congratulate_after_first_newsletter %>;
      var mailpoet_current_wp_user = <%= json_encode(current_wp_user) %>;
      var mailpoet_current_wp_user_firstname = '<%= current_wp_user_firstname %>';
      var mailpoet_lists = <%= json_encode(lists) %>;
      var mailpoet_roles = <%= json_encode(roles) %>;
      var mailpoet_current_date = <%= json_encode(current_date) %>;
      var mailpoet_tomorrow_date = <%= json_encode(tomorrow_date) %>;
      var mailpoet_current_date_time = <%= json_encode(current_date_time) %>;
      var mailpoet_schedule_time_of_day = <%= json_encode(schedule_time_of_day) %>;
      var mailpoet_date_storage_format = "Y-m-d";
      var mailpoet_product_categories = <%= json_encode(product_categories)  %>;
      var mailpoet_products = <%= json_encode(products) %>;

      var mailpoet_account_url = '<%= add_referral_id("https://account.mailpoet.com/?s=" ~ subscriber_count ~ "&email=" ~ current_wp_user.user_email|escape('js')) %>';

      var mailpoet_woocommerce_automatic_emails = <%= json_encode(automatic_emails) %>;
      var mailpoet_woocommerce_optin_on_checkout = "<%= woocommerce_optin_on_checkout %>";

      var mailpoet_woocommerce_transactional_email_id = <%= json_encode(woocommerce_transactional_email_id) %>;
      var mailpoet_display_detailed_stats = <%= json_encode(display_detailed_stats) %>;
      var mailpoet_newsletters_api = <%= json_encode(api) %>;
      var mailpoet_user_locale = '<%= get_locale() %>';
      var mailpoet_congratulations_success_images = [
        '<%= cdn_url('newsletter/congratulate-1.png') %>',
        '<%= cdn_url('newsletter/congratulate-2.png') %>',
        '<%= cdn_url('newsletter/congratulate-3.png') %>',
        '<%= cdn_url('newsletter/congratulate-4.png') %>',
      ];
      var mailpoet_congratulations_error_image = '<%= cdn_url('newsletter/error.png') %>';
      var mailpoet_congratulations_loading_image = '<%= cdn_url('newsletter/congratulation-page-illustration-transparent-LQ.20181121-1440.png') %>';
      var mailpoet_emails_page = '<%= mailpoet_email_page %>';
      var mailpoet_review_request_illustration_url = '<%= cdn_url('review-request/review-request-illustration.20190815-1427.svg') %>';
      var mailpoet_installed_at = '<%= settings.installed_at %>';
      var mailpoet_editor_javascript_url = '<%= getJavascriptScriptUrl("newsletter_editor.js") %>';
      var mailpoet_newsletters_count = <%= newsletters_count %>;
      var mailpoet_authorized_emails = <%= json_encode(authorized_emails) %>;
      var mailpoet_verified_sender_domains = <%= json_encode(verified_sender_domains) %>;
      var mailpoet_partially_verified_sender_domains = <%= json_encode(partially_verified_sender_domains) %>;
      var mailpoet_all_sender_domains = <%= json_encode(all_sender_domains) %>;
      var mailpoet_sender_restrictions = <%= json_encode(sender_restrictions) %>;
      var mailpoet_block_email_editor_enabled = <%= json_encode(block_email_editor_enabled) %>;
    <% endautoescape %>

    var mailpoet_newsletters_templates_recently_sent_count = <%= json_decode(newsletters_templates_recently_sent_count) %>;
    var corrupt_newsletters = <%= json_encode(corrupt_newsletters) %>;
    var mailpoet_legacy_automatic_emails_count = <%= legacy_automatic_emails_count %>;
    var mailpoet_legacy_automatic_emails_notice_dismissed = <%= json_encode(legacy_automatic_emails_notice_dismissed) %>;

  </script>
<% endblock %>

<% block after_translations %>
  <%= do_action('mailpoet_newsletters_translations_after') %>
<% endblock %>
