<script id="dataexplorer_view-template" type="text/x-handlebars-template">
    <div class="section">
        <div class="options_container">
            <button class="clear_queries_link btn" title="Clear history">Clear history<div class="option_icon clear_history"></div></button>
            <button class="close_queries_link btn" title="History">History<div class="option_icon show_history"></div></button>
            <button class="btn toggle_options_link" title="Options"><div class="option_icon show_options"></div></button>
            <button class="btn button_query change_size" title="Fullscreen"><div class="option_icon fullscreen"></div></button> 
        </div>
        <h1 class="title small_margin_bottom">Data Explorer</h1>
        <div id="user-alert-space"></div>
        <div class="reason_dataexplorer_broken alert alert-error"></div>
        <div class="toggled_container">
            <div class="arrow_dataexplorer"></div>
            <div class="nano_border"></div>
            <div class="nano">
                <div class="content">
                 </div>
            </div>
            <div class="nano_border nano_border_bottom"></div>
        </div>
        <div class="input_query_full_container"></div>
        <div class="results_container"></div>
    </div>
</script>

<script id="dataexplorer-options-template" type="text/x-handlebars-template">
    <ul class="options_list">
        <li data-option="suggestions">
            <div class="checkbox-container"><input type="checkbox" data-option="suggestions" id="suggestions"{{#if suggestions}} checked=true{{/if}}><label for="suggestions" data-option="suggestions"></label></div> 
            <div class="option_description" data-option="suggestions">Enable automatic suggestions and command descriptions</div></li>
        <li data-option="electric_punctuation">
            <div class="checkbox-container"><input type="checkbox" data-option="electric_punctuation" id="electric_punctuation"{{#if electric_punctuation}} checked=true{{/if}}><label for="electric_punctuation" data-option="electric_punctuation"></label></div> 
            <div class="option_description" data-option="electric_punctuation">Auto-insert pair brackets, parentheses, and quotes</div></li>
        <li data-option="profiler">
            <div class="alert profiler_enabled"><strong>Query profiler active:</strong> re-run the query to see results.</div>
            <div class="checkbox-container"><input type="checkbox" data-option="profiler" id="profiler" {{#if profiler}} checked=true{{/if}}><label for="profiler" data-option="profiler"></label></div> 
            <div class="option_description" data-option="profiler">Enable query profiler</div></li>
    </ul>
</script>


<script id="dataexplorer-history-template" type="text/x-handlebars-template">
    <ul class="history_list"></ul>
</script>

<script id="dataexplorer-query_li-template" type="text/x-handlebars-template">
    {{#if no_query}}
    <li class="no_history {{displayed_class}}">No history available</li>
    {{else}}
    <li class="query_history {{displayed_class}}" id="query_history_{{id}}">
    <div class="query_id">[{{num}}]</div>
    <div class="query_history_content">
        <span class="query">{{query}}
            <span class="right_container">
                <button class="btn load_query" data-id={{id}}>Load</button>
                <button class="btn delete_query" data-id={{id}}>Remove</button>
                {{#if broken_query}}<img src="images/warning-icon.png" class="broken_query" title="This query produced an error" />{{/if}}

            </span>
        </span>
    </div>
    </li>
    {{/if}}
</script>


<script id="dataexplorer-reason_broken-template" type="text/x-handlebars-template">
{{#if is_internet_explorer}}
Sorry, the data explorer does not support Internet Explorer. See the <a href="http://www.rethinkdb.com/docs/pragmatic-faq/#what-browsers-are-supported-by-the-administra">supported browsers</a>.
{{else}}
{{#if no_driver}}
JavaScript driver not found.
{{else}}
Sorry, the data explorer does not support your browser. Please upgrade it. See the <a href="http://www.rethinkdb.com/docs/pragmatic-faq/#what-browsers-are-supported-by-the-administra">supported browsers</a>.
{{/if}}
{{/if}}
</script>

<script id="alert-connection_fail-template" type="text/x-handlebars-template">
    <div class="alert alert-error displayed_alert" data-alert="alert">
        <a class="close" href="#">&times;</a>
        <p>The connection to the server failed. Please try to <a href="#" id="reconnect">reconnect</a></p>
    </div>
</script>

<script id="dataexplorer-description-template" type="text/x-handlebars-template">
<p><span class="description_name">{{name}}</span>{{#if args}}<span class="description_arguments">{{args}}</span>{{/if}}</p>
{{print_safe description}}
</script>


<script id="dataexplorer-description_with_example-template" type="text/x-handlebars-template">
    <p>{{print_safe description}}</p>
    <div class="db_table_available"></div>
    <div class="separation"></div>
    {{print_safe example}}
</script>

<script id="dataexplorer-databases_suggestions-template" type="text/x-handlebars-template">
    <p>
    {{#if no_database}}
        No database found. Use dbCreate() to create a new database first.
    {{else}}
        List of databases available: <strong>{{comma_separated_simple databases_available}}</strong>
    {{/if}}
    </p>
    <div class="separation"></div>
</script>
<script id="dataexplorer-namespaces_suggestions-template" type="text/x-handlebars-template">
    <p>
    {{#if error}}
        The database specified in db() was not found.
    {{else}}
        {{#if no_namespace}}
            {{#if database_name}}
                No table found in {{database_name}}. Use tableCreate() to create a new table first.
            {{else}}
                You need to create a database then a table first.
            {{/if}}
        {{else}}
            List of tables{{#if database_name}} in {{database_name}}{{/if}}: <strong>{{comma_separated_simple namespaces_available}}</strong>
        {{/if}}
    {{/if}}
    </p>
    <div class="separation"></div>
</script>

<script id="alert-reconnection_success-template" type="text/x-handlebars-template">
    <div class="alert displayed_alert" data-alert="alert">
        <a class="close" href="#">&times;</a>
        <p>Successfully reconnected.</p>
    </div>
</script>

<script id="dataexplorer_input_query-template" type="text/x-handlebars-template">
    <div class="input_query_container" >
        <div class="suggestion_full_container">
            <div class="suggestion_list_container">
                <ul class="suggestion_name_list"></ul>
            </div>
            <div class="suggestion_description"></div>
        </div>
        <div class="suggestion_description_arrow arrow"></div>
        <div class="suggestion_description_arrow_overlay arrow"></div>
        <textarea class="input_query" id="input_query"></textarea>
        <div class="button_container">
            <button class="btn button_query execute_query">Run</button>
            <button class="btn button_query clear_query">Clear</button>
        </div>
    </div>
    <div class="loading_query">
        <img src="images/ajax-loader.gif" class="loading_query_img"/>
    </div>
</script>

<script id="dataexplorer_suggestion_name_li-template" type="text/x-handlebars-template">
    <li class="suggestion_name_li" data-has_argument="{{has_argument}}" data-id={{id}}>{{suggestion}}</li>
</script>

<script id="dataexplorer-error-template" type="text/x-handlebars-template">
    <h1 class="title">Error</h1>
    <p class="error_title">
        {{#if js_error}}
            JavaScript error:
        {{else}}
            Server error:
        {{/if}}
    </p>
    <pre class="error error_details">{{error}}</pre>

    {{#if query}}
        <p class="error">The query that returned an error is:</p>
        <pre class="error error_details">{{query}}</pre>
    {{/if}}


</script>

<script id="dataexplorer-query_error-template" type="text/x-handlebars-template">
{{! Spacing maters, this content goes in a pre tag}}
{{#if found_run}}You should remove .run() from your queries when using the Data Explorer (as of RethinkDB 1.4). The query will be built and sent by the Data Explorer itself.{{/if}}
{{#if last_non_query}}Last query was not a RethinkDB query.{{/if}}
{{#if no_query}}No query found{{/if}}
{{#if syntax_error}}Syntax error, missing opening bracket for {{bracket}} (line {{line}}, position {{position}}).{{/if}}
</script>


<script id="dataexplorer_query_element-template" type="text/x-handlebars-template">
    <li class="query_element"><a href="#" class="old_query" data-query="{{query}}">{{query_summary}}</a></li>
</script>

<script id="dataexplorer_default_result_container-template" type="text/x-handlebars-template">
    <div class="results_header">
    </div>
</script>

<script id="dataexplorer_result_container-template" type="text/x-handlebars-template">
    <div class="results_header">
        <ul class="nav nav-tabs change_view_container"">
            <li><a href="#profile_view" class="link_to_profile_view">Query profile</a></li>
            <li><a href="#raw_view" class="link_to_raw_view">Raw view</a></li>
            <li><a href="#table_view" class="link_to_table_view">Table view</a></li>
            <li><a href="#tree_view" class="link_to_tree_view">Tree view</a></li>
        </ul>
        <p class="metadata">
            {{#if show_query_warning}}Results from the previous query:{{/if}}
            {{#if execution_time_pretty}}Executed in {{execution_time_pretty}}.{{/if}}
            {{#if no_results}}No results returned.{{/if}}
            {{#if num_results}}{{num_results}} {{pluralize_noun 'row' num_results}} returned
                {{#if limit_value}}, {{limit_value}} displayed{{/if}}{{#if skip_value}}, {{skip_value}} skipped{{/if}},
            {{else}}
                {{#if limit_value}}{{limit_value}} {{pluralize_noun "row" limit_value}} displayed{{/if}}{{#if skip_value}}, {{skip_value}} skipped{{/if}},
            {{/if}}
            {{#if show_more_data}}more available {{/if}}
        </p>
    </div>
    <div class="wrapper_scrollbar"><div class="scrollbar_fake_content"></div></div>
    <div class="tab-content">  
        <div class="results profile_view_container">
            <div class="results_wrap profile_view">
                <div class="profile_summary_container"></div>
                <button class="btn copy_profile">Copy to clipboard</button>
                <div class="profile_container"></div>
            </div>
        </div>
        <div class="results tree_view_container">
            <div class="results_wrap tree_view"><div class="json_tree_container"></div>
            </div>
        </div>
        <div class="results table_view_container">
            <div class="results_wrap table_view"></div>
        </div>
        <div class="results raw_view_container">
            <div class="raw_view_container raw_view">
                <textarea class="raw_view_textarea"></textarea>
            </div>
        </div>
    </div>
    {{#if show_more_data}}
    <div class="info more_results">
        <p class="more_results_paragraph">More data is available. <a href="#" class="more_results_link">Load the next batch &rarr;</a></p>
    </div>
    {{else}}
        {{#if cursor_timed_out_template}}
            <div class="info more_results"><p class="more_results_paragraph">{{print_safe cursor_timed_out_template}}</p></div>
        {{/if}}
    {{/if}}
</script>


<script id="dataexplorer-profiler_header-template" type="text/x-handlebars-template">
    <div class="profile_summary">
        <div class="row-fluid">
            <div class="span4">
                <p class="query-duration-roundtrip"><span class="big">{{total_duration}}</span> round-trip time</p>
            </div>
            <div class="span4">
                <p class="query-duration-server"><span class="big">{{server_duration}}</span> server time</p>
            </div>
            <div class="span4">
                <p class="query-tasks"><span class="big">{{num_shard_accesses}}</span> shard accesses</p>
            </div>
        </div>
    </div>
</script>

<script id="dataexplorer-option_page-template" type="text/x-handlebars-template">
    <option class="page" value="{{page}}" {{#if selected}}selected="selected"{{/if}}>{{page}}</option>
</script>

<script id="dataexplorer_result_empty-template" type="text/x-handlebars-template">
    <p>No result were returned for this query</p>
</script>

<script id="dataexplorer-no_profile-template" type="text/x-handlebars-template">
    <div class="activate_profiler_message">
        <p><a href="#" class="activate_profiler">Enable</a> the query profiler (developer preview) and re-run the query.</p>
    </div>
</script>

<script id="dataexplorer-cursor_timed_out-template" type="text/x-handlebars-template">
    No more data available, the cursor timed out. Re-execute the query to retrieve more results.
</script>

<!-- Keep </script> without space/new line before so the comma stick to the value of the object-->
<script id="dataexplorer_result_json_tree_container-template" type="text/x-handlebars-template">
    <div class="json_tree">{{print_safe tree}}</div></script>

<script id="dataexplorer_result_json_tree_span-template" type="text/x-handlebars-template">
    <span class="jt_editable {{classname}}" >{{value}}</span></script>

<script id="dataexplorer_result_json_tree_span_with_quotes-template" type="text/x-handlebars-template">
    <span class="{{classname}}">"</span><span class="jt_editable {{classname}}" >{{value}}</span><span class="{{classname}}">"</span></script>

<script id="dataexplorer_result_json_tree_url-template" type="text/xs-handlebars-template">
    <span class="jt_editable jt_url" >{{url}}</span>,
    <a href="{{url}}" class="jt_link">»</a></script>

<script id="dataexplorer_result_json_tree_email-template" type="text/xs-handlebars-template">
    <span class="jt_editable jt_email" >{{email}}</span>,
    <a href="mailto:{{email}}" class="jt_link">»</a></script>

<script id="dataexplorer_result_json_tree_array-template" type="text/x-handlebars-template">

    {{#if no_value}}
    [ ]
    {{else}}
    <span class="jt_arrow"></span>
    <span class="jt_b">[</span>
    <span class="jt_points">...</span>
    <ul class="jt_array jt_collapsible">
        {{#each values}}
        <li>
            {{print_safe value}}{{#unless no_comma}}, {{/unless}}
        </li>
        {{/each}}
    </ul>
    <span class="jt_b jt_close">]</span>{{/if}}</script>

<script id="dataexplorer_result_json_tree_object-template" type="text/x-handlebars-template">
    {{#if no_value}}
        { } 
    {{else}}
        <span class="jt_arrow"></span>
        <span class="jt_b">{</span>
        <span class="jt_points">...</span>
        <ul class="jt_object jt_collapsible">
            {{#each values}}
            <li>
                    "{{this.key}}": {{print_safe this.value}}{{#unless no_comma}}, {{/unless}}
            </li>
            {{/each}}
        </ul>
        <span class="jt_b jt_close">}</span>
    {{/if}}
</script>

<script id="dataexplorer_result_json_table_container-template" type="text/x-handlebars-template">
    <div class="json_table_container">
        <table class="json_table">
            {{print_safe table_attr}}
            {{print_safe table_data}}
        </table>
    </div>
</script>

<script id="dataexplorer_result_json_table_tr_attr-template" type="text/xs-handlebars-template">
    <tr class="jta_tr">
        <td class="td_attr col-record col-record-attr" data-col="record">
        </td>
        {{#each attr}}
        <td class="td_attr col-{{col}}" data-col={{col}}>
            <div class="click_detector">
                {{#if is_primitive}}
                    <div class="jta_attr value-{{col}}">{{prefix_str}} <em>value</em></div>
                {{else}}
                    <div class="jta_attr value-{{col}}">{{prefix_str}}{{key}}</div>
                {{/if}}
            </div>
        </td>
        {{/each}}
    </tr>
</script>

<script id="dataexplorer_result_json_table_tr_value-template" type="text/xs-handlebars-template">
    {{#each document}}
    <tr class="jta_tr">
        <td class="col-record-td" data-col="record"><div class="jta_value col-record">{{record}}</div></td>
        {{#each cells}}
            {{print_safe this}}
        {{/each}}
    </tr>
    {{/each}}
</script>

<script id="dataexplorer_result_json_table_td_attr-template" type="text/xs-handlebars-template">
    <td class="td_attr {{classtd}}" data-col={{col}}>
        <div class="click_detector">
            <div class="jta_attr value-{{col}}">{{key}}</div>
        </div>
    </td>
</script>

<script id="dataexplorer_result_json_table_td_value-template" type="text/xs-handlebars-template">
    <td class="col-{{col}}"  data-col={{col}}>
        {{print_safe cell_content}}
    </td>
</script>

<script id="dataexplorer_result_json_table_td_value_content-template" type="text/xs-handlebars-template">
    <div class="click_detector">
    {{#if data_to_expand}}
    <div class="{{class_value}} jta_value {{classname}}">       
        <span data-json_data="{{data_to_expand}}" class="jta_object">
            <span class="jta_arrow jta_arrow_h"></span>
            {{print_safe value}}
        </span>
    </div>
    {{else}}{{#if is_object}}
     <div class="{{class_value}} jta_value {{classname}}">       
        <strong>{...}</strong>
    </div>
   
    {{else}}
    <div class="jta_value {{class_value}} {{classname}}"><span>{{value}}</span></div>
    {{/if}}{{/if}}
</div>
</script>

<script id="dataexplorer_result_json_table_data_inline-template" type="text/xs-handlebars-template">
    {{#if data_to_expand}}
        <span data-json_data="{{data_to_expand}}" class="jta_object">
            <span class="jta_arrow jta_arrow_v"></span>
            {{#unless is_inline}}<span class="jta_arrow jta_arrow_h"></span>{{/unless}}
            <strong>{{print_safe value}}</strong>
            {{#if need_comma}}, {{/if}}
        </span>
    {{else}}
        <span class={{classname}}>{{print_safe value}}</span>{{#if need_comma}}, {{/if}}
    {{/if}}
</script>
