local this = {}
local _PreGetPetPath = "Program/FlyMsg/pre_getPet.prefab"
local _GetPetModulePath = "ui.manager.flyMsg.moduleGetPet"

function this:showGetPetTip(petItem, callBack)
  local priorityShowData = require("ui.manager.priorityShowQueue.flyMsgPriorityShowData").new({
    flyMsgType = L_ShowQueueConst.flyMsgType.getPet,
    uuid = self:getNextUniqueId(),
    params = {
      {pet = petItem, callBack = callBack}
    }
  })
  L_PriorityShowQueueManager:addPriorityShowData(priorityShowData)
end

function this:rawShowGetPetTip(uuid, popup)
  popup._uuid = uuid
  self:doShowGetPetTip(popup)
end

function this:doShowGetPetTip(popup)
  if popup == nil then
    return
  end
  if not self.getPetTipModule then
    self.goHandle = C_LuaUtility.InstantiateSync(_PreGetPetPath, self.root)
    self.getPetTipModule = require(_GetPetModulePath).new(G_UIModuleBase.ModuleType.Static)
    self.getPetTipModule:created()
    local go = self.goHandle.gameObject
    local trans = go.transform
    L_Vector3.setAnchored(trans, {x = 0, y = 0})
    self.getPetTipModule:toBind(go:GetComponent(typeof(C_UIBinding)))
    self.getPetTipModule:setCloseCB(handler(self, self.onGetPetClose))
  end
  L_AudioUtil.playSound("Play_SFX_System_HUD_General_Qibo_Obtain_Left")
  self.getPetTipModule:open(popup)
end

function this:onGetPetClose(popup)
  if popup.callBack then
    popup.callBack()
  end
  self:sendEvent(self.event.flyMsgPopupEnd, L_ShowQueueConst.flyMsgType.getPet, popup._uuid)
end

function this:disposeGetPetTip()
  if self.getPetTipModule then
    self.getPetTipModule:unBind()
    self.getPetTipModule = nil
  end
  if self.goHandle then
    C_LuaUtility.DestroyObject(self.goHandle)
  end
end

return this
