<script lang="ts">
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
import { events_loc, events_sess, events_slct, events_trigger, events_trig_kv } from '$lib/ae_events_stores';

export let hide: boolean = true;
</script>


<!-- New standard events module menu 2025-06-20 -->
<div
    class="ae_comp__pres_mgmt_menu_opts w-full border-t border-gray-300 mt-1"
    class:hidden={hide}
    >
    <h2 class="text-sm font-semibold text-center pb-1">
        <button
            type="button"
            on:click={() => {
                $events_loc.pres_mgmt.hide__menu_opts = !$events_loc.pres_mgmt.hide__menu_opts;
            }}
            class="btn btn-sm preset-tonal-info border border-info-500"
            >
            {#if $events_loc.pres_mgmt.hide__menu_opts}
                <span class="fas fa-chevron-up m-1"></span>
            {:else}
                <span class="fas fa-chevron-down m-1"></span>
            {/if}
            Æ Pres Mgmt Menu Options
            {#if $events_loc.pres_mgmt.hide__menu_opts}
                <span class="fas fa-chevron-up m-1"></span>
            {:else}
                <span class="fas fa-chevron-down m-1"></span>
            {/if}
        </button>
    </h2>

    <div
        class="flex flex-row flex-wrap gap-1 items-center justify-between"
        class:hidden={$events_loc.pres_mgmt.hide__menu_opts}
        >

        {#if $ae_loc.authenticated_access}
        <div
            class="flex flex-col gap-1 items-end justify-center"
            >
            <span
                class="flex flex-col gap-1 items-end justify-center"
                >
                <!-- Max presenters select options -->
                <span
                    class="flex flex-row gap-1 items-center justify-around w-full"
                    >
                    <label
                        class="text-sm w-32 text-right"
                        for="qry_limit__presenters">
                        Max presenters:
                    </label>
                    <select
                        id="qry_limit__presenters"
                        bind:value={$events_loc.pres_mgmt.qry_limit__presenters}
                        class="select w-20 text-sm preset-tonal-surface px-1"
                        >
                        <option value="">-- not set --</option>
                        <option value={25}>25</option>
                        <option value={50}>50</option>
                        <option value={75}>75</option>
                        <option value={100}>100</option>
                        <option value={150}>150</option>
                        <option value={200}>200</option>
                        <option value={250}>250</option>
                        <option value={300}>300</option>
                        <option value={500}>500</option>
                        <option value={750}>750</option>
                        <option value={1000}>1000</option>
                    </select>
                </span>

                <!-- Max sessions select options -->
                <span
                    class="flex flex-row gap-1 items-center justify-around w-full"
                    >
                    <label
                        class="text-sm w-32 text-right"
                        for="qry_limit__sessions">
                        Max sessions:
                    </label>
                    <select
                        id="qry_limit__sessions"
                        bind:value={$events_loc.pres_mgmt.qry_limit__sessions}
                        class="select w-20 text-sm preset-tonal-surface px-1"
                        >
                        <option value="">-- not set --</option>
                        <option value={25}>25</option>
                        <option value={50}>50</option>
                        <option value={75}>75</option>
                        <option value={100}>100</option>
                        <option value={200}>200</option>
                        <option value={500}>500</option>
                    </select>
                </span>

                <!-- Max files select options -->
                <span
                    class="flex flex-row gap-1 items-center justify-around w-full"
                    >
                    <label
                        class="text-sm w-32 text-right"
                        for="qry_limit__files">
                        Max files:
                    </label>
                    <select
                        id="qry_limit__files"
                        bind:value={$events_loc.pres_mgmt.qry_limit__files}
                        class="select w-20 text-sm preset-tonal-surface px-1"
                        >
                        <option value="">-- not set --</option>
                        <option value={25}>25</option>
                        <option value={50}>50</option>
                        <option value={75}>75</option>
                        <option value={100}>100</option>
                        <option value={200}>200</option>
                        <option value={500}>500</option>
                    </select>
                </span>
            </span>

            <span
                class="flex flex-col gap-1 items-end justify-center"
                >
                <!-- Button to toggle between the showing hidden sessions -->
                {#if $events_loc.pres_mgmt.qry_hidden == 'all'}
                    <button
                        type="button"
                        on:click={() => {
                            if ($events_loc.pres_mgmt.qry_hidden == 'all') {
                                $events_loc.pres_mgmt.qry_hidden = 'not_hidden';
                            } else {
                                $events_loc.pres_mgmt.qry_hidden = 'all';
                            }
                        }}
                        class="btn btn-sm w-full ae_btn_surface"
                        title="Hide sessions marked as hidden?"
                        >
                        <span class="fas fa-eye-slash m-1"></span>
                        Hide?
                    </button>
                {:else}
                    <button
                        type="button"
                        on:click={() => {
                            if ($events_loc.pres_mgmt.qry_hidden == 'all') {
                                $events_loc.pres_mgmt.qry_hidden = 'not_hidden';
                            } else {
                                $events_loc.pres_mgmt.qry_hidden = 'all';
                            }
                        }}
                        class="btn btn-sm w-full ae_btn_surface_outlined"
                        title="Show all (hidden) sessions?"
                        >
                        <span class="fas fa-eye m-1"></span>
                        Show All (Hidden)?
                    </button>
                {/if}

                {#if $ae_loc.manager_access}
                    {#if $events_loc.pres_mgmt.qry_enabled == 'all'}
                        <button
                            type="button"
                            on:click={() => {
                                if ($events_loc.pres_mgmt.qry_enabled == 'all') {
                                    $events_loc.pres_mgmt.qry_enabled = 'enabled';
                                } else {
                                    $events_loc.pres_mgmt.qry_enabled = 'all';
                                }
                            }}
                            class="btn btn-sm w-full ae_btn_surface"
                            title="Hide disabled sessions?"
                            >
                            <span class="fas fa-eye-slash m-1"></span>
                            Hide Disabled?
                        </button>
                    {:else}
                        <button
                            type="button"
                            on:click={() => {
                                if ($events_loc.pres_mgmt.qry_enabled == 'all') {
                                    $events_loc.pres_mgmt.qry_enabled = 'enabled';
                                } else {
                                    $events_loc.pres_mgmt.qry_enabled = 'all';
                                }
                            }}
                            class="btn btn-sm w-full ae_btn_surface_outlined"
                            title="Show disabled sessions?"
                            >
                            <span class="fas fa-eye m-1"></span>
                            Show All (Disabled)?
                        </button>
                    {/if}
                {/if}
            </span>
        </div>
        {/if}

        <div class="flex flex-col flex-wrap gap-1 items-center justify-evenly">

            <button
                type="button"
                on:click={() => {
                    $events_loc.pres_mgmt.save_search_text = !$events_loc.pres_mgmt.save_search_text;
                }}
                class="btn btn-sm w-full"
                class:ae_btn_surface={$events_loc.pres_mgmt.save_search_text}
                class:ae_btn_surface_outlined={!$events_loc.pres_mgmt.save_search_text}
                title="Save the search text for this session search?"
                >
                {#if $events_loc.pres_mgmt.save_search_text}
                    <span class="fas fa-toggle-on m-1"></span>
                    Save Search Text
                {:else}
                    <span class="fas fa-toggle-off m-1"></span>
                    <!-- <span class="fas fa-save m-1"></span> -->
                    Save Search Text?
                {/if}
            </button>

            {#if $ae_loc.authenticated_access}
                {#if !$events_loc.pres_mgmt.hide__session_msg}
                    <button
                        type="button"
                        on:click={() => {
                            $events_loc.pres_mgmt.hide__session_msg = true;
                        }}
                        class="btn btn-sm w-full ae_btn_surface"
                        >
                        <span class="fas fa-toggle-on m-1"></span>
                        Showing Session Message
                    </button>
                {:else}
                    <button
                        type="button"
                        on:click={() => {
                            $events_loc.pres_mgmt.hide__session_msg = false;
                        }}
                        class="btn btn-sm w-full ae_btn_surface_outlined"
                        >
                        <span class="fas fa-toggle-off m-1"></span>
                        Show Session Message?
                    </button>
                {/if}
            {/if}

            {#if $ae_loc.authenticated_access}
                <!-- Show or hide the session code -->
                {#if !$events_loc.pres_mgmt.hide__session_code}
                    <button
                        type="button"
                        on:click={() => {
                            $events_loc.pres_mgmt.hide__session_code = true;
                        }}
                        class="btn btn-sm w-full ae_btn_surface"
                        >
                        <span class="fas fa-toggle-on m-1"></span>
                        Showing Session Code
                    </button>
                {:else}
                    <button
                        type="button"
                        on:click={() => {
                            $events_loc.pres_mgmt.hide__session_code = false;
                        }}
                        class="btn btn-sm w-full ae_btn_surface_outlined"
                        >
                        <span class="fas fa-toggle-off m-1"></span>
                        Show Session Code?
                    </button>
                {/if}
            {/if}
        </div>

        <div
            class="flex flex-col gap-1 items-center justify-center"
            >
            {#if $ae_loc.trusted_access}
                <div
                    class="flex flex-col gap-1 items-center justify-center"
                    >
                {#if $events_loc.pres_mgmt.show__copy_access_link}
                    <button
                        type="button"
                        on:click={() => {
                            $events_loc.pres_mgmt.show__copy_access_link = false;
                        }}
                        class="btn btn-sm w-full ae_btn_surface"
                        >
                        <span class="fas fa-toggle-on m-1"></span>
                        Showing Copy Access Link
                    </button>
                {:else}
                    <button
                        type="button"
                        on:click={() => {
                            $events_loc.pres_mgmt.show__copy_access_link = true;
                        }}
                        class="btn btn-sm w-full ae_btn_surface_outlined"
                        >
                        <span class="fas fa-toggle-off m-1"></span>
                        Show Copy Access Link?
                    </button>
                {/if}

                {#if $events_loc.pres_mgmt.show__email_access_link}
                    <button
                        type="button"
                        on:click={() => {
                            $events_loc.pres_mgmt.show__email_access_link = false;
                        }}
                        class="btn btn-sm w-full ae_btn_surface"
                        >
                        <span class="fas fa-toggle-on m-1"></span>
                        Showing Email Access Link
                    </button>
                {:else}
                    <button
                        type="button"
                        on:click={() => {
                            $events_loc.pres_mgmt.show__email_access_link = true;
                        }}
                        class="btn btn-sm w-full ae_btn_surface_outlined"
                        >
                        <span class="fas fa-toggle-off m-1"></span>
                        Show Email Access Link?
                    </button>
                {/if}
                </div>
            {/if}

            {#if $ae_loc.authenticated_access}
                <div
                    class="flex flex-col gap-1 items-end justify-center"
                    >
                {#if $events_loc.pres_mgmt.show_content__session_qr}
                    <button
                        type="button"
                        on:click={() => {
                            $events_loc.pres_mgmt.show_content__session_qr = false;
                        }}
                        class="btn btn-sm w-full ae_btn_surface"
                        title="Showing Session QR Code"
                        >
                        <span class="fas fa-toggle-on m-1"></span>
                        Showing Session QR Code
                    </button>
                {:else}
                    <button
                        type="button"
                        on:click={() => {
                            $events_loc.pres_mgmt.show_content__session_qr = true;
                        }}
                        class="btn btn-sm w-full ae_btn_surface_outlined"
                        title="Show Session QR Code"
                        >
                        <span class="fas fa-toggle-off m-1"></span>
                        Show Session QR Code?
                    </button>
                {/if}

                {#if $events_loc.pres_mgmt.show_content__presenter_qr}
                    <button
                        on:click={() => {
                            $events_loc.pres_mgmt.show_content__presenter_qr = false;
                        }}
                        class="btn btn-sm w-full ae_btn_surface"
                        title="Showing Presenter QR Code"
                        >
                        <span class="fas fa-toggle-on m-1"></span>
                        Showing Presenter QR Code
                    </button>
                {:else}
                    <button
                        on:click={() => {
                            $events_loc.pres_mgmt.show_content__presenter_qr = true;
                        }}
                        class="btn btn-sm w-full ae_btn_surface_outlined"
                        title="Show Presenter QR Code"
                        >
                        <span class="fas fa-toggle-off m-1"></span>
                        Show Presenter QR Code?
                    </button>
                {/if}
                </div>
            {/if}
        </div>



        {#if $ae_loc.authenticated_access}
        <div class="flex flex-col gap-1 items-center justify-center">

            <!-- Button to toggle between showing and not showing the launcher and location links -->
            {#if $events_loc.pres_mgmt.show__launcher_link || $events_loc.pres_mgmt.show__location_link}
                <button
                    disabled={!$ae_loc.administrator_access}
                    on:click={() => {
                        $events_loc.pres_mgmt.show__launcher_link = false;
                        $events_loc.pres_mgmt.show__launcher_link_legacy = false;
                        $events_loc.pres_mgmt.show__location_link = false;
                    }}
                    class="btn btn-sm w-full ae_btn_surface"
                    >
                    <span class="fas fa-toggle-on m-1"></span>
                    Showing Launcher Links
                </button>
            {:else}
                <button
                    disabled={!$ae_loc.administrator_access}
                    on:click={() => {
                        $events_loc.pres_mgmt.show__launcher_link = true;
                        $events_loc.pres_mgmt.show__launcher_link_legacy = true;
                        $events_loc.pres_mgmt.show__location_link = true;
                    }}
                    class="btn btn-sm w-full ae_btn_surface_outlined"
                    >
                    <span class="fas fa-toggle-off m-1"></span>
                    Show Launcher Links?
                </button>
            {/if}

            <!-- These are related to more content showing in lists. -->
            <span class="flex flex-col flex-wrap gap-1 items-center justify-evenly">
                {#if $events_loc.pres_mgmt.show_content__session_files}
                    <button
                        disabled={!$ae_loc.manager_access}
                        on:click={() => {
                            $events_loc.pres_mgmt.show_content__session_files = false;
                        }}
                        class="btn btn-sm w-full ae_btn_surface"
                        >
                        <span class="fas fa-toggle-on m-1"></span>
                        Showing Files
                    </button>
                {:else}
                    <button
                        disabled={!$ae_loc.manager_access}
                        on:click={() => {
                            $events_loc.pres_mgmt.show_content__session_files = true;
                        }}
                        class="btn btn-sm w-full ae_btn_surface_outlined"
                        >
                        <span class="fas fa-toggle-off m-1"></span>
                        Show Files?
                    </button>
                {/if}

                {#if $events_loc.pres_mgmt.show_content__session_presentations}
                    <button
                        disabled={!$ae_loc.manager_access}
                        on:click={() => {
                            $events_loc.pres_mgmt.show_content__session_presentations = false;
                        }}
                        class="btn btn-sm w-full ae_btn_surface"
                        >
                        <span class="fas fa-toggle-on m-1"></span>
                        Showing Presentations
                    </button>
                {:else}
                    <button
                        disabled={!$ae_loc.manager_access}
                        on:click={() => {
                            $events_loc.pres_mgmt.show_content__session_presentations = true;
                        }}
                        class="btn btn-sm w-full ae_btn_surface_outlined"
                        >
                        <span class="fas fa-toggle-off m-1"></span>
                        Show Presentations?
                    </button>
                {/if}
            </span>
        </div>
        {/if}


        <div class="flex flex-row gap-1 items-center justify-evenly">
        {#if $ae_loc.trusted_access}
            {#if $ae_loc.edit_mode}
                <button
                    type="button"
                    on:click={() => {
                        $ae_loc.edit_mode = false;
                    }}
                    class="btn btn-sm w-full ae_btn_warning"
                    >
                    <!-- <span class="fas fa-toggle-on m-1"></span> -->
                    <span class="fas fa-edit m-1"></span>
                    Edit Mode On
                </button>
            {:else}
                <button
                    type="button"
                    on:click={() => {
                        $ae_loc.edit_mode = true;
                    }}
                    class="btn btn-sm w-full ae_btn_warning_outlined"
                    >
                    <span class="fas fa-toggle-off m-1"></span>
                    <!-- <span class="fas fa-edit m-1"></span> -->
                    Edit Mode?
                </button>
            {/if}
        {/if}
        </div>

    </div>

</div>