import threading
from typing import Dict, Any
from Entity.AnchorModel import AnchorModel

# wda apple bundle id
WdaAppBundleId = "com.yolozsAgent.wda.xctrunner"

# 全局主播列表
anchorList: list[AnchorModel] = []
# 线程锁
anchorListLock = threading.Lock()
# 打招呼数据
prologueList: list[str] = []

# 本地储存的打招呼数据
localPrologueList = [
    "If you are interested in this, you can join our team for a period of time. During this period, if you like our team, you can continue to stay in our team. If you don't like it, you can leave at any time, and you won't lose anything!",
    "What's even better is that after joining our team, you have no obligations and you don't have to pay me. Everything is free",
    "I'm from the MARS agency. I noticed that you're very active on TikTok, so I contacted you and hope to become your agent❤",
    "Hello, can we talk about cooperation and support?",
    "Hello, I’m a supporter. Can we have a chat?",
    "Hi 👋 I’m an official TikTok partner. I really enjoy your livestreams. Do you have time to chat about support and cooperation?",
    "Hello, I really like your livestreams. I’d love to talk about cooperation and also support you.",
    "Hello, I think you have the potential to become a top streamer. Can we talk?",
    "Nice to meet you 😊 I watched your livestream and really enjoyed it. Can we chat about cooperation?",
    "Hello 👋 I’m a livestream team manager. I recently watched your livestream—it’s great 👍 I hope we can talk about how to grow together 💪",
    "I watched your livestream and would like to invite you to join our team. I’ll reward you with more gifts based on your performance.",
    "Hello, I’d like to promote your livestream. Can we talk?",
    "Hello, I think I can help you get more gifts and support for free. Would you be interested in talking with me?",
    "Hello, I really enjoyed your livestream. Can we chat about cooperation?"
]

# 评论列表
commentsList = []
# 存储主播名和session_id的字典
anchorWithSession = {}
# 前端传递的token
token = ''
# 前端传递的
tenantId = 0

userId = 0


# 安全删除数据
def removeModelFromAnchorList(model: AnchorModel):
    with anchorListLock:
        anchorList.remove(model)


# 添加数据
def addModelToAnchorList(models: list[Dict[str, Any]]):
    with anchorListLock:
        for dic in models:
            obj = AnchorModel.dictToModel(dic)
            anchorList.append(obj)


# 添加打招呼语
def addDataToPrologue(data: list[str]):
    prologueList = data
