
function update_tickets_operations_manager (el_tab,data,old_item_tab_user,w=null,wo=null) {
    let insert_type = null
    let insert_place = null
    if (w !== null){
        insert_type = data.tickets_w_manager_html
        insert_place = 'list_linked_tickets'
        // insert_type = data.tickets_w_manager_htm
    } else if (wo !== null){

        insert_type = data.tickets_wo_manager_html
        insert_place = 'list_unlinked_tickets'
    }
    if (insert_type) {
        if (document.querySelector(".list_linked_tickets") !== null || document.querySelector(".list_unlinked_tickets") !== null) {
            document.querySelector(`.${insert_place}`).innerHTML = insert_type
            // if (el_tab !== null) {
            //     let select_tab = document.querySelector(".tab_user_messanger.select")
            //     if (select_tab) {
            //         select_tab.classList.remove("select")
            //     }
            //     let old_insert_tab = document.querySelector(`[data-cur-receiver-item="${old_item_tab_user}"]`)
            //     if (old_insert_tab) {
            //         old_insert_tab.classList.add("select")
            //         old_insert_tab.scrollIntoView({behavior: "smooth"});
            //     }
            //
            // }
            // let container_messenger = document.querySelector(".container-messages")
            // if (container_messenger){
            //     let dataset_cont_mes = container_messenger.dataset
            //     if (dataset_cont_mes){
            //         let ticket_id = dataset_cont_mes["ticketId"]
            //         if (ticket_id !== ""){
            //             let ticket = document.querySelector(`[data-cur-receiver-item="${ticket_id}"]`)
            //             if (ticket === null){
            //                 let chat = document.querySelector(".block-chat").innerHTML = ""
            //             }
            //         }
            //     }
            // }
            select_and_scroll_to_ticket(data,old_item_tab_user,el_tab)
            // clear_messenger(data)
        }

    }
    return "w?wo"
}


function select_and_scroll_to_ticket (data,old_item_tab_user,el_tab){
    if (el_tab !== null){
        let selected_variabel = document.querySelector(".tab_user_messanger.select")
        if (selected_variabel){
            selected_variabel.classList.remove("select")
        }
        let old_insert_tab = document.querySelector(`[data-cur-receiver-item="${old_item_tab_user}"]`)
        if (old_insert_tab) {
            old_insert_tab.classList.add("select")
            old_insert_tab.scrollIntoView({behavior: "smooth"});
        }

    }
}

function clear_messenger (data) {
    let container_messenger = document.querySelector(".container-messages")
    if (container_messenger){
        let dataset_cont_mes = container_messenger.dataset
        if (dataset_cont_mes){
            let ticket_id = dataset_cont_mes["ticketId"]
            if (ticket_id !== ""){
                let ticket = document.querySelector(`[data-cur-receiver-item="${ticket_id}"]`)
                if (ticket === null){
                    document.querySelector(".block-chat").style.display = "none"
                    document.querySelector(".name_ticket").style.display = "none"
                }
            }
        }
    }
}

function update_support_chat_func (data,msg_cont){
    if (msg_cont !== null){
        if (msg_cont.dataset['curReceiver'] === ""){
            document.querySelector(".info_profile").innerHTML = data.support_chat_html
        }
    }
}

