import { $ } from "@/uilts/help";
export let toolbox_fixed_tweetId = ''

export const toolBox = new class ToolBox {
    constructor() {

    }
    // 加载组件
    initFull() {
        const iframe = document.createElement('iframe')
        iframe.id = 'denet-tool-box-fixed'
        iframe.style.cssText = `
            width: 505px;
            height: 545px;
            position: fixed;
            right: 10px;
            top: 10px;
            display:none;
            border:medium none;  filter: drop-shadow(rgba(0, 0, 0, 0.2) 0px 4px 20px);
            `
        iframe.src = chrome.runtime.getURL('/iframe/tool-box.html') + `?page_type=${'full'}`;
        document.body.append(iframe)
    }
    // 切换状态
    switchStatus(req) {
        toolbox_fixed_tweetId = req.data.tweetId
        let dom_fixed = $('#denet-tool-box-fixed')
        switch (req.data.type) {
            case '全屏':
                dom_fixed.style.cssText = `
                    display:block;
                    width: 100%;
                    height: 100%;
                    position: fixed;
                    left: 0;
                    top: 0;
                    border:medium none;  filter: drop-shadow(rgba(0, 0, 0, 0.2) 0px 4px 20px);
                    `
                break;

            case '固定右上角':
                dom_fixed.style.cssText = `
                    display:block;
                    width: 505px;
                    height: 545px;
                    position: fixed;
                    right: 10px;
                    top: 10px;
                    border:medium none;  filter: drop-shadow(rgba(0, 0, 0, 0.2) 0px 4px 20px);
                    `
                break
            case '关闭':
                dom_fixed.style.cssText = `display:none;`
                toolbox_fixed_tweetId = ''
                break
        }
    }
}
