<commit_before><link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/app-route/app-location.html">
<link rel="import" href="../bower_components/app-route/app-route.html">
<link rel="import" href="../bower_components/iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="../bower_components/iron-icons/iron-icons.html">
<link rel="import" href="../bower_components/iron-media-query/iron-media-query.html">
<link rel="import" href="../bower_components/paper-drawer-panel/paper-drawer-panel.html">
<link rel="import" href="../bower_components/paper-header-panel/paper-header-panel.html">
<link rel="import" href="../bower_components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="../bower_components/paper-styles/paper-styles.html">
<link rel="import" href="../bower_components/paper-toolbar/paper-toolbar.html">

<link rel="import" href="data/rester-data-hotkeys-behavior.html">
<link rel="import" href="data/rester-data-settings-behavior.html">
<link rel="import" href="data/rester-data.html">
<link rel="import" href="layout/rester-drawer-footer-links.html">
<link rel="import" href="layout/rester-navigation-list.html">
<link rel="import" href="layout/rester-pages.html">
<link rel="import" href="utils/rester-error.html">
<link rel="import" href="utils/rester-hotkeys-cheat-sheet.html">

<dom-module id="rester-app">
    <template>
        <style include="iron-flex iron-flex-alignment iron-positioning">
            :host {
                --primary-text-color: var(--dark-theme-text-color);
                --primary-background-color: var(--dark-theme-background-color);
                --secondary-text-color: var(--dark-theme-secondary-color);
                --disabled-text-color: var(--dark-theme-disabled-color);
                --divider-color: var(--dark-theme-divider-color);
                --error-color: var(--paper-deep-orange-a700);

                --primary-color: var(--paper-cyan-500);
                --light-primary-color: var(--paper-cyan-100);
                --dark-primary-color: var(--paper-cyan-700);

                --accent-color: var(--paper-amber-a200);
                --light-accent-color: var(--paper-amber-a100);
                --dark-accent-color: var(--paper-amber-a400);

                display: block;
                min-height: 100vh;
                background-color: var(--primary-background-color);
                color: var(--primary-text-color);
                @apply(--paper-font-common-base);
            }

            paper-drawer-panel {
                --paper-drawer-panel-drawer-container: {
                    background-color: var(--primary-background-color);
                    border-right: 1px solid var(--divider-color);
                };
            }

            paper-drawer-panel [drawer] paper-toolbar {
                --paper-toolbar-background: none;
                --paper-toolbar-title: {
                    margin-left: 0;
                };
                --paper-toolbar: {
                    border-bottom: 1px solid var(--divider-color);
                };
            }
        </style>

        <app-location route="{{route}}" use-hash-as-path></app-location>
        <app-route
                route="[[route]]"
                pattern="/:page"
                data="{{routeData}}"
                tail="{{routeTail}}"></app-route>

        <paper-drawer-panel
                id="drawer"
                drawer-width="[[drawerWidth]]"
                responsive-width="[[responsiveWidth]]">
            <!-- Navigation -->
            <paper-header-panel drawer mode="seamed">
                <paper-toolbar>
                    <div class="title">RESTer</div>
                    <iron-media-query
                            query="(min-width: [[responsiveWidthMin]]) and (max-width: [[responsiveWidthMax]])"
                            query-matches="{{showDrawerLock}}"></iron-media-query>
                    <paper-icon-button
                            icon="[[_getDrawerToggleIcon(settings.pinSidenav)]]"
                            on-tap="_toggleDrawerLockOpen"
                            hidden="[[!showDrawerLock]]"></paper-icon-button>
                </paper-toolbar>
                <div class="fit layout vertical justified">
                    <rester-navigation-list
                            route="[[route]]"
                            on-item-activated="_onNavigationItemActivated"></rester-navigation-list>
                    <rester-drawer-footer-links>
                        <a href="#" on-tap="_showShortcuts">Shortcuts</a> &dash;
                        <a href="#/about">About</a>
                    </rester-drawer-footer-links>
                </div>
            </paper-header-panel>

            <!-- Main -->
            <rester-pages
                    main
                    page="[[page]]"
                    page-title="{{pageTitle}}"
                    route="[[routeTail]]"
                    on-drawer-toggle-tapped="_onDrawerToggleTapped"></rester-pages>
        </paper-drawer-panel>

        <rester-error></rester-error>
        <rester-hotkeys-cheat-sheet id="cheatSheet"></rester-hotkeys-cheat-sheet>
    </template>

    <script>
        Polymer({
            is: 'rester-app',

            behaviors: [
                RESTer.HotkeysBehavior,
                RESTer.SettingsBehavior
            ],

            properties: {
                page: String,
                pageTitle: {
                    type: String,
                    observer: '_onPageTitleChanged'
                },
                drawerWidth: {
                    type: String,
                    value: '320px'
                },
                responsiveWidth: {
                    type: String,
                    computed: '_computeResponsiveWidth(settings.pinSidenav)'
                },
                responsiveWidthMin: {
                    type: String,
                    value: '600px'
                },
                responsiveWidthMax: {
                    type: String,
                    value: '1279px'
                }
            },

            observers: [
                '_routePageChanged(routeData.page)'
            ],

            resterHotkeys: {
                'mod+e': {
                    description: 'Cycle through environments.',
                    callback: '_activateNextEnvironment'
                }
            },

            _routePageChanged (page) {
                this.page = page || 'request';
            },

            _onPageTitleChanged () {
                document.title = `RESTer - ${this.pageTitle}`;
            },

            _computeResponsiveWidth () {
                return this.settings.pinSidenav ? this.responsiveWidthMin : this.responsiveWidthMax;
            },

            _getDrawerToggleIcon () {
                return this.settings.pinSidenav ? 'lock-outline' : 'lock-open';
            },

            _toggleDrawerLockOpen () {
                this.set('settings.pinSidenav', !this.settings.pinSidenav);
            },

            _onDrawerToggleTapped () {
                this.$.drawer.togglePanel();
            },

            _onNavigationItemActivated () {
                this.$.drawer.closeDrawer();
            },

            _showShortcuts (e) {
                e.preventDefault();
                this.$.cheatSheet.show();
            },

            _activateNextEnvironment () {
                RESTer.rester.getEnvironments().then(envs => {
                    if (envs.length === 0) return;

                    const index = envs.findIndex(env => env.id === this.settings.activeEnvironment),
                          newIndex = (index + 1) % envs.length,
                          newEnv = envs[newIndex];

                    this.settings.activeEnvironment = newEnv.id;
                });
            }
        });
    </script>
</dom-module><commit_msg>Add hotkey to make a new request.<commit_after><link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/app-route/app-location.html">
<link rel="import" href="../bower_components/app-route/app-route.html">
<link rel="import" href="../bower_components/iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="../bower_components/iron-icons/iron-icons.html">
<link rel="import" href="../bower_components/iron-media-query/iron-media-query.html">
<link rel="import" href="../bower_components/paper-drawer-panel/paper-drawer-panel.html">
<link rel="import" href="../bower_components/paper-header-panel/paper-header-panel.html">
<link rel="import" href="../bower_components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="../bower_components/paper-styles/paper-styles.html">
<link rel="import" href="../bower_components/paper-toolbar/paper-toolbar.html">

<link rel="import" href="data/rester-data-hotkeys-behavior.html">
<link rel="import" href="data/rester-data-settings-behavior.html">
<link rel="import" href="data/rester-data.html">
<link rel="import" href="layout/rester-drawer-footer-links.html">
<link rel="import" href="layout/rester-navigation-list.html">
<link rel="import" href="layout/rester-pages.html">
<link rel="import" href="utils/rester-error.html">
<link rel="import" href="utils/rester-hotkeys-cheat-sheet.html">

<dom-module id="rester-app">
    <template>
        <style include="iron-flex iron-flex-alignment iron-positioning">
            :host {
                --primary-text-color: var(--dark-theme-text-color);
                --primary-background-color: var(--dark-theme-background-color);
                --secondary-text-color: var(--dark-theme-secondary-color);
                --disabled-text-color: var(--dark-theme-disabled-color);
                --divider-color: var(--dark-theme-divider-color);
                --error-color: var(--paper-deep-orange-a700);

                --primary-color: var(--paper-cyan-500);
                --light-primary-color: var(--paper-cyan-100);
                --dark-primary-color: var(--paper-cyan-700);

                --accent-color: var(--paper-amber-a200);
                --light-accent-color: var(--paper-amber-a100);
                --dark-accent-color: var(--paper-amber-a400);

                display: block;
                min-height: 100vh;
                background-color: var(--primary-background-color);
                color: var(--primary-text-color);
                @apply(--paper-font-common-base);
            }

            paper-drawer-panel {
                --paper-drawer-panel-drawer-container: {
                    background-color: var(--primary-background-color);
                    border-right: 1px solid var(--divider-color);
                };
            }

            paper-drawer-panel [drawer] paper-toolbar {
                --paper-toolbar-background: none;
                --paper-toolbar-title: {
                    margin-left: 0;
                };
                --paper-toolbar: {
                    border-bottom: 1px solid var(--divider-color);
                };
            }
        </style>

        <app-location route="{{route}}" use-hash-as-path></app-location>
        <app-route
                route="[[route]]"
                pattern="/:page"
                data="{{routeData}}"
                tail="{{routeTail}}"></app-route>

        <paper-drawer-panel
                id="drawer"
                drawer-width="[[drawerWidth]]"
                responsive-width="[[responsiveWidth]]">
            <!-- Navigation -->
            <paper-header-panel drawer mode="seamed">
                <paper-toolbar>
                    <div class="title">RESTer</div>
                    <iron-media-query
                            query="(min-width: [[responsiveWidthMin]]) and (max-width: [[responsiveWidthMax]])"
                            query-matches="{{showDrawerLock}}"></iron-media-query>
                    <paper-icon-button
                            icon="[[_getDrawerToggleIcon(settings.pinSidenav)]]"
                            on-tap="_toggleDrawerLockOpen"
                            hidden="[[!showDrawerLock]]"></paper-icon-button>
                </paper-toolbar>
                <div class="fit layout vertical justified">
                    <rester-navigation-list
                            route="[[route]]"
                            on-item-activated="_onNavigationItemActivated"></rester-navigation-list>
                    <rester-drawer-footer-links>
                        <a href="#" on-tap="_showShortcuts">Shortcuts</a> &dash;
                        <a href="#/about">About</a>
                    </rester-drawer-footer-links>
                </div>
            </paper-header-panel>

            <!-- Main -->
            <rester-pages
                    main
                    page="[[page]]"
                    page-title="{{pageTitle}}"
                    route="[[routeTail]]"
                    on-drawer-toggle-tapped="_onDrawerToggleTapped"></rester-pages>
        </paper-drawer-panel>

        <rester-error></rester-error>
        <rester-hotkeys-cheat-sheet id="cheatSheet"></rester-hotkeys-cheat-sheet>
    </template>

    <script>
        Polymer({
            is: 'rester-app',

            behaviors: [
                RESTer.HotkeysBehavior,
                RESTer.SettingsBehavior
            ],

            properties: {
                page: String,
                pageTitle: {
                    type: String,
                    observer: '_onPageTitleChanged'
                },
                drawerWidth: {
                    type: String,
                    value: '320px'
                },
                responsiveWidth: {
                    type: String,
                    computed: '_computeResponsiveWidth(settings.pinSidenav)'
                },
                responsiveWidthMin: {
                    type: String,
                    value: '600px'
                },
                responsiveWidthMax: {
                    type: String,
                    value: '1279px'
                }
            },

            observers: [
                '_routePageChanged(routeData.page)'
            ],

            resterHotkeys: {
                'mod+m': {
                    description: 'New request.',
                    callback: '_newRequest'
                },
                'mod+e': {
                    description: 'Cycle through environments.',
                    callback: '_activateNextEnvironment'
                }
            },

            _routePageChanged (page) {
                this.page = page || 'request';
            },

            _onPageTitleChanged () {
                document.title = `RESTer - ${this.pageTitle}`;
            },

            _computeResponsiveWidth () {
                return this.settings.pinSidenav ? this.responsiveWidthMin : this.responsiveWidthMax;
            },

            _getDrawerToggleIcon () {
                return this.settings.pinSidenav ? 'lock-outline' : 'lock-open';
            },

            _toggleDrawerLockOpen () {
                this.set('settings.pinSidenav', !this.settings.pinSidenav);
            },

            _onDrawerToggleTapped () {
                this.$.drawer.togglePanel();
            },

            _onNavigationItemActivated () {
                this.$.drawer.closeDrawer();
            },

            _showShortcuts (e) {
                e.preventDefault();
                this.$.cheatSheet.show();
            },

            _newRequest () {
                window.location = '#/request';
            },

            _activateNextEnvironment () {
                RESTer.rester.getEnvironments().then(envs => {
                    if (envs.length === 0) return;

                    const index = envs.findIndex(env => env.id === this.settings.activeEnvironment),
                          newIndex = (index + 1) % envs.length,
                          newEnv = envs[newIndex];

                    this.settings.activeEnvironment = newEnv.id;
                });
            }
        });
    </script>
</dom-module>
{'fraction_non_alphanumeric': 0.1414066826656821, 'fraction_numerical': 0.004799704633561012, 'mean_word_length': 1.4523917307982497, 'pattern_counts': {'":': 0, '<': 125, '<?xml version=': 0, '>': 129, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6635033', 'n_tokens_mistral': 4562, 'n_tokens_neox': 4211, 'n_words': 568}