local page = class("pageBattlePetCatch", G_UIPageBase)
local _lockTargetId = 0
local _inLockStayState = false
local _moveTween, _firstLockPos
local _LockTargetPoint = "HitPoint"

function page.bind()
  return {
    moduleCapture = {
      moduleName = "pages/Battle/moduleCapture"
    },
    list_cardItem = {
      moduleName = "pages/battle/cellCaptureCardInfo"
    },
    moduleBattlePetGeneInfo = {
      moduleName = "pages/battle/moduleBattlePetGeneInfo"
    },
    goPetCatch = true,
    goMask = true,
    toggle_shortKeyIsPc = false
  }
end

function page.methods()
  return {
    onClose = function(self)
      self:onClick_close()
    end,
    onPetCatch = function(self)
      self:onPet_Catch()
    end,
    onPetCatchLeft = function(self)
      self:onPet_CatchLeft()
    end,
    onPetCatchRight = function(self)
      self:onPet_CatchRight()
    end,
    list_cardItem = {
      onClick_sphere = function(self, sphereId, cnt, quality)
        if self.selectData and self.selectData.sphereId == sphereId then
          return
        end
        self.isPlayingAnim = true
        if self.playingAnimTimer then
          Timer.remove(self.playingAnimTimer)
          self.playingAnimTimer = nil
        end
        self.playingAnimTimer = Timer.once(0.2, function()
          self.isPlayingAnim = false
        end, self)
        for i = 1, #self.bind.list_cardItem do
          self.bind.list_cardItem:getItemCls(i):playSelectAnim(self.selectData.sphereId, sphereId)
        end
        self.selectData = {
          cnt = cnt,
          quality = quality,
          sphereId = sphereId
        }
        local keyString = string.format("%s_%s", L_PlayerStore:getPlayerId(), "SelectedCapturePetBall")
        C_PlayerPrefsUtility.SetInt(keyString, quality)
        L_BattleDataManager:setCapturePetBallData(self.selectData)
      end
    }
  }
end

function page:onPet_Catch()
  L_PlayerManager:fireStartCatch()
end

function page:set_select(select)
  self.bind.goPetCatch = not select
end

function page:onPet_CatchLeft()
  C_EntityManager.LeftSelect()
end

function page:onPet_CatchRight()
  C_EntityManager.RightSelect()
end

function page:onLeftBtnEff()
  self.bindComponents.LeftBtnAnimation:SetTrigger("Pressed")
  self:playFrontSightAnim(true)
  self:moveToCenter()
end

function page:onRightBtnEff()
  self.bindComponents.RightBtnAnimation:SetTrigger("Pressed")
  self:playFrontSightAnim(true)
  self:moveToCenter()
end

function page:onClick_close()
  if self.catchIsStart or self.isClose then
    return
  end
  if self.closeTimer then
    Timer.remove(self.closeTimer)
    self.closeTimer = nil
  end
  self.isClose = true
  self.bindComponents.anim:Play("anim_capture_hide")
  self.closeTimer = Timer.once(0.167, function()
    L_UI:close("pageBattlePetCatch")
  end, self)
end

function page:escHandle()
  self:onClick_close()
end

function page:preOpen(options)
  if L_UIManager.bInputBlocked then
    L_UI:close("pageBattlePetCatch")
    return
  end
  if options and options.petInfo then
    self.modules.moduleBattlePetGeneInfo:setPetData(options.petInfo)
  end
  L_BattleManager:addListener(L_BattleManager.event.tmpPauseInput, self.onEvent_tmpPauseInput, self)
  L_BattleDataManager:addListener(L_BattleDataManager.event.petCatchNotice, self.onEvent_petCatch, self)
  self._onEnterTarget = handler(self, self.onEvent_CameraEnterTarget)
  self._onExitTarget = handler(self, self.onEvent_CameraExitTarget)
  C_WorldEvent.instance:Listen(C_EWorldEvent.PetCatchCameraLockTarget, self._onEnterTarget)
  C_WorldEvent.instance:Listen(C_EWorldEvent.PetCatchCameraLoseTarget, self._onExitTarget)
  self._lateUpdateHandle = L_CommonUtil.handle(self.onLateUpdate_displayFollow, self)
  C_UpdateSource.AddLateUpdateEventHandler(self._lateUpdateHandle, "FormationMainPage.lateUpdate")
  self.bind.toggle_shortKeyIsPc = L_DeviceTpl:getIsPc()
end

function page:open(options)
  self.itemId = options and options.itemId and options.itemId or 0
  self.isClose = false
  self.catchIsStart = false
  self.bBlockHand = true
  self.bind.goMask = false
  self.isPlayingAnim = false
  self.isMove = false
  self.startTime = 0
  self.startCompensateTime = 0
  self.frontSightAnimPlayed = false
  self.leftAndRightAnimPlayed = false
  self:initCardInfo()
  self:playFrontSightAnimNormal(true)
  self:playFrontSightAnim(true)
  self.onReconnectedHandler = handler(self, self.onReconnected)
  L_Net:RegisterGameConnectEvent(C_EGameConnectStatus.SimpleReconnected, self.onReconnectedHandler)
end

function page:check(options, callback)
  local result = self:initCardData()
  if result < 0 then
    L_FlyMsgManager:showNormalMsg(L_WordsTpl:getValue("notice_noPetcatchitem"))
    callback(false)
    return
  end
  callback(true)
end

function page:initCardData()
  local data = L_BagManager:getAllCapturePetBall()
  local size = #data
  self.sphereDatas = {}
  self.selectData = nil
  local qualityInt = -1
  local keyString = string.format("%s_%s", L_PlayerStore:getPlayerId(), "SelectedCapturePetBall")
  if CS.Lens.Gameplay.Modules.BigWorld.Macro.IsBattleSimulator then
    local iconPath = {
      "Battle/tex_petcapture_icon_greysj.png",
      "Battle/tex_petcapture_icon_greensj.png",
      "Battle/tex_petcapture_icon_purplesj.png",
      "Battle/tex_petcapture_icon_bluesj.png",
      "Battle/tex_petcapture_icon_goldsj.png"
    }
    qualityInt = C_PlayerPrefsUtility.GetInt(keyString, -1)
    if qualityInt < 0 then
      qualityInt = 4
    end
    for i = 1, 5 do
      local sphereData = {
        sphereId = 1000000 + i,
        cnt = 6 * i,
        quality = i - 1,
        icon = iconPath[i]
      }
      table.insert(self.sphereDatas, sphereData)
    end
    self.selectData = {
      cnt = (qualityInt + 1) * 6,
      quality = qualityInt,
      sphereId = 1000001 + qualityInt
    }
  else
    local quaCnt = 0
    local saveId = 0
    qualityInt = C_PlayerPrefsUtility.GetInt(keyString, -1)
    if 0 <= qualityInt and data[qualityInt + 1] and 0 < data[qualityInt + 1].num then
      self.selectData = {
        cnt = data[qualityInt + 1].num,
        quality = qualityInt,
        sphereId = data[qualityInt + 1].id
      }
    end
    for i = 1, size do
      local sphereData = {
        sphereId = data[i].id,
        cnt = data[i].num,
        quality = data[i].quality,
        icon = data[i].icon
      }
      table.insert(self.sphereDatas, sphereData)
      if not self.selectData and 0 < data[i].num then
        qualityInt = data[i].quality
        quaCnt = data[i].num
        saveId = data[i].id
      end
    end
    if not self.selectData then
      self.selectData = {
        cnt = quaCnt,
        quality = qualityInt,
        sphereId = saveId
      }
    end
  end
  return qualityInt
end

function page:initCardInfo()
  self.cShortCutEnable = true
  L_BattleDataManager:setCapturePetBallData(self.selectData)
  self.bind.list_cardItem:insert_array(self.sphereDatas)
  self:playInitAnim()
  self.tipsRoot = self.bindComponents.PetCatchTipsRoot
  self.moveRoot = self.bindComponents.root
end

function page:playInitAnim()
  self:clearTimer()
  self.timer1 = Timer.once(0.033, function()
    self.bind.list_cardItem:getItemCls(5):playInitAnim(self.selectData.sphereId)
  end, self)
  self.timer2 = Timer.once(0.067, function()
    self.bind.list_cardItem:getItemCls(4):playInitAnim(self.selectData.sphereId)
  end, self)
  self.timer3 = Timer.once(0.133, function()
    self.bind.list_cardItem:getItemCls(3):playInitAnim(self.selectData.sphereId)
  end, self)
  self.timer4 = Timer.once(0.233, function()
    self.bind.list_cardItem:getItemCls(2):playInitAnim(self.selectData.sphereId)
  end, self)
  self.timer5 = Timer.once(0.367, function()
    self.bind.list_cardItem:getItemCls(1):playInitAnim(self.selectData.sphereId)
    self.bBlockHand = false
  end, self)
end

function page:clearTimer()
  if self.timer1 then
    Timer.remove(self.timer1)
    self.timer1 = nil
  end
  if self.timer2 then
    Timer.remove(self.timer2)
    self.timer2 = nil
  end
  if self.timer3 then
    Timer.remove(self.timer3)
    self.timer3 = nil
  end
  if self.timer4 then
    Timer.remove(self.timer4)
    self.timer4 = nil
  end
  if self.timer5 then
    Timer.remove(self.timer5)
    self.timer5 = nil
  end
end

function page:refreshSelectedSphereCnt()
  local data = L_BagManager:getAllCapturePetBall()
  for i = 1, #self.bind.list_cardItem do
    local cnt = data[i].num
    self.bind.list_cardItem:getItemCls(i):refreshCnt(cnt)
  end
end

function page:setCShortCutEnable(enable)
  self.cShortCutEnable = enable
end

function page:onEvent_petCatch(args)
  if args.noticeType == "noticeExitCatch" then
    L_UI:close("pageBattlePetCatch")
  elseif args.noticeType == "noticeSelectStart" then
    self.modules.moduleBattlePetGeneInfo:hide()
  elseif args.noticeType == "noticeSelectEnd" then
    self.modules.moduleBattlePetGeneInfo:setSelectMonster()
  elseif args.noticeType == "noticeCatchPress" then
    if args.entityId == 0 then
      self:onLeftBtnEff()
    else
      self:onRightBtnEff()
    end
  elseif args.noticeType == "noticeCatchStart" then
    self.bind.goMask = true
    self:refreshSelectedSphereCnt()
    self:setCShortCutEnable(false)
    self.modules.moduleBattlePetGeneInfo:hide()
  elseif args.noticeType == "noticeSendStartCatch" then
    if C_EntityManager.SelectMonsterIsRage() then
      L_FlyMsgManager:showNormalMsg(L_WordsTpl:getValue("notice_pet_can_not_catch"))
      return
    end
    local data = L_BattleDataManager:getCapturePetBallData()
    if data == nil or data.cnt == 0 then
      L_FlyMsgManager:showNormalMsg(L_WordsTpl:getValue("notice_pet_catchitem_not_enough"))
      return
    end
    self.catchIsStart = true
    C_EntityManager.SendPetCatch()
    for i = 1, #self.bind.list_cardItem do
      self.bind.list_cardItem:getItemCls(i):playUnSelectAnim(self.selectData.sphereId)
    end
  end
end

function page:onEvent_tmpPauseInput(isPause)
  if not isPause then
    return
  end
  L_UI:close(self.pageName)
end

function page:onEvent_CameraEnterTarget()
  local index = C_EntityManager.GetCatchCurSelectIndex()
  if index < 0 or index >= C_EntityManager.GetSelectMonsterEntities().Count then
    errorf("\229\165\135\230\179\162\230\152\159\231\187\147\239\188\140\231\155\174\230\160\135\233\128\137\230\139\169\229\141\149\228\189\141\231\154\132index\228\184\141\230\173\163\231\161\174index=" .. index, 2)
    return
  end
  local entity = C_EntityManager.GetSelectMonsterEntities()[index]
  local entityId = entity.data.entityId
  if entityId ~= _lockTargetId then
    self.isMove = true
  end
end

function page:onEvent_CameraExitTarget()
  if _lockTargetId ~= 0 then
    printf("\229\165\135\230\179\162\230\152\159\231\187\147", "\231\167\187\233\153\164\231\155\174\230\160\135\239\188\140configId=" .. _lockTargetId)
    _lockTargetId = 0
    _inLockStayState = false
    _firstLockPos = {
      x = 0,
      y = 0,
      z = 0
    }
    if _moveTween then
      _moveTween:Kill()
    end
    local entityId = self:getSelectedMonsterId()
    if entityId ~= 0 then
      return
    end
    local tweenEase = Tweening.Ease.InOutQuad
    if self.tipsRoot.gameObject ~= nil then
      local curveHolder = self.tipsRoot.gameObject:GetComponent(typeof(C_LAnimationCurveHolder)).curves
      if curveHolder ~= nil and curveHolder.Count > 1 then
        tweenEase = curveHolder[1]
      else
        errorf("\229\165\135\230\179\162\230\152\159\231\187\147", "PetCatchTipsRoot\232\138\130\231\130\185\228\184\138\230\178\161\230\156\137\230\137\190\229\136\176\231\180\162\229\188\149\228\184\1861\232\191\144\229\138\168\230\155\178\231\186\191")
      end
      local centerUiPos = {
        x = 0,
        y = 0,
        z = 0
      }
      _moveTween = self.moveRoot:DOLocalMove(centerUiPos, 0.3):SetEase(tweenEase):SetEase(tweenEase):OnComplete(function()
        print("\229\165\135\230\179\162\230\152\159\231\187\147", "\230\142\168\229\135\186\229\138\168\231\148\187\230\146\173\230\148\190\229\174\140\230\136\144")
        _moveTween:Kill()
        _moveTween = nil
      end)
      self:playFrontSightAnim(false)
    end
  end
end

function page:moveEnterTarget()
  local index = C_EntityManager.GetCatchCurSelectIndex()
  if index < 0 or index >= C_EntityManager.GetSelectMonsterEntities().Count then
    errorf("\229\165\135\230\179\162\230\152\159\231\187\147\239\188\140\231\155\174\230\160\135\233\128\137\230\139\169\229\141\149\228\189\141\231\154\132index\228\184\141\230\173\163\231\161\174index=" .. index, 2)
    return
  end
  local entity = C_EntityManager.GetSelectMonsterEntities()[index]
  local entityId = entity.data.entityId
  if entityId ~= _lockTargetId then
    printf("\229\165\135\230\179\162\230\152\159\231\187\147", "\233\148\129\229\174\154\231\155\174\230\160\135\239\188\140configId=" .. entityId)
    _lockTargetId = entityId
  end
  _inLockStayState = false
  local spine = L_GameUtil.findTranByName(entity.data.transform.gameObject, _LockTargetPoint)
  local worldPos = {
    x = 0,
    y = 0,
    z = 0
  }
  if spine == nil then
    worldPos = entity.data.transform.worldPosition
  else
    worldPos = spine.position
  end
  printf("\229\165\135\230\179\162\230\152\159\231\187\147", "\233\148\129\229\174\154\231\155\174\230\160\135\239\188\140\228\184\150\231\149\140\229\157\144\230\160\135=" .. worldPos.x .. "," .. worldPos.y .. "," .. worldPos.z)
  local screenPos = C_CameraManager.mainCamera:WorldToScreenPoint(worldPos)
  printf("\229\165\135\230\179\162\230\152\159\231\187\147", "\233\148\129\229\174\154\231\155\174\230\160\135\239\188\140\229\177\143\229\185\149\229\157\144\230\160\135=" .. screenPos.x .. "," .. screenPos.y .. "," .. screenPos.z)
  local uiPos = L_Vector3.screenToLocalInRectangle(self.tipsRoot, screenPos)
  printf("\229\165\135\230\179\162\230\152\159\231\187\147", "\233\148\129\229\174\154\231\155\174\230\160\135\239\188\140UI\229\157\144\230\160\135=" .. uiPos.x .. "," .. uiPos.y .. "," .. uiPos.z)
  if _moveTween then
    _moveTween:Kill()
  end
  local tweenEase = Tweening.Ease.InOutQuad
  local curveHolder = self.tipsRoot:GetComponent(typeof(C_LAnimationCurveHolder)).curves
  if curveHolder ~= nil and 0 < curveHolder.Count then
    tweenEase = curveHolder[0]
  else
    errorf("\229\165\135\230\179\162\230\152\159\231\187\147", "PetCatchTipsRoot\232\138\130\231\130\185\228\184\138\230\178\161\230\156\137\230\137\190\229\136\176\231\180\162\229\188\149\228\184\1860\232\191\144\229\138\168\230\155\178\231\186\191")
  end
  _firstLockPos = uiPos
  self.startTime = C_Time.time
  self.startCompensateTime = 0
  self.compensateMove = true
  self.moveDeltaTime = 0.5
  printf("test", "\229\188\128\229\167\139\230\151\182\233\151\180 " .. C_Time.time)
  _moveTween = self.moveRoot:DOLocalMove(uiPos, self.moveDeltaTime):SetEase(tweenEase):SetAutoKill(false):OnComplete(function()
    _inLockStayState = true
    _moveTween:Kill()
    _moveTween = nil
    self.compensateMove = false
    print("\229\165\135\230\179\162\230\152\159\231\187\147", "\232\191\155\229\133\165\229\138\168\231\148\187\230\146\173\230\148\190\229\174\140\230\136\144  \230\156\128\231\187\136\229\157\144\230\160\135=" .. self.moveRoot.localPosition.x .. "," .. self.moveRoot.localPosition.y .. "," .. self.moveRoot.localPosition.z)
  end)
  self:playFrontSightAnim(true)
end

function page:getUIPos()
  local index = C_EntityManager.GetCatchCurSelectIndex()
  if index < 0 or index >= C_EntityManager.GetSelectMonsterEntities().Count then
    return nil
  end
  local entity = C_EntityManager.GetSelectMonsterEntities()[index]
  local spine = L_GameUtil.findTranByName(entity.data.transform.gameObject, _LockTargetPoint)
  local worldPos = {
    x = 0,
    y = 0,
    z = 0
  }
  if spine == nil then
    worldPos = entity.data.transform.worldPosition
  else
    worldPos = spine.position
  end
  local screenPos = C_CameraManager.mainCamera:WorldToScreenPoint(worldPos)
  local uiPos = L_Vector3.screenToLocalInRectangle(self.tipsRoot, screenPos)
  return uiPos
end

function page:subLockTargetMove()
  if self.compensateMove and _lockTargetId ~= 0 then
    local pos = self:getUIPos()
    if pos ~= nil then
      local error = C_Vector3.Distance(pos, _firstLockPos)
      if 1 < error then
        _moveTween:Kill()
        _firstLockPos = pos
        local tweenEase = Tweening.Ease.InOutQuad
        local curveHolder = self.tipsRoot:GetComponent(typeof(C_LAnimationCurveHolder)).curves
        if curveHolder ~= nil and 0 < curveHolder.Count then
          tweenEase = curveHolder[0]
        else
          errorf("\229\165\135\230\179\162\230\152\159\231\187\147", "PetCatchTipsRoot\232\138\130\231\130\185\228\184\138\230\178\161\230\156\137\230\137\190\229\136\176\231\180\162\229\188\149\228\184\1860\232\191\144\229\138\168\230\155\178\231\186\191")
        end
        print("\229\165\135\230\179\162\230\152\159\231\187\147", "\230\146\173\230\148\190\229\188\186\229\136\182\233\135\141\229\144\175  \230\156\128\231\187\136UI\229\157\144\230\160\135=" .. pos.x .. "," .. pos.y .. "," .. pos.z)
        if self.startTime ~= 0 then
          self.moveDeltaTime = self.moveDeltaTime - (C_Time.time - self.startTime)
          printf("\229\165\135\230\179\162\230\152\159\231\187\147", "\231\172\172\228\184\128\233\152\182\230\174\181\230\182\136\232\128\151  \230\151\182\233\151\180=" .. C_Time.time - self.startTime)
          self.startTime = 0
        end
        if self.startCompensateTime ~= 0 then
          self.moveDeltaTime = self.moveDeltaTime - (C_Time.time - self.startCompensateTime)
          printf("\229\165\135\230\179\162\230\152\159\231\187\147", "\231\172\172\228\184\128\233\152\182\230\174\181\230\182\136\232\128\151\232\161\165\229\129\191\230\151\182\233\151\180=" .. C_Time.time - self.startCompensateTime)
          self.startCompensateTime = 0
        end
        if 0 > self.moveDeltaTime then
          self.moveDeltaTime = 0.01
        end
        self.startCompensateTime = C_Time.time
        print("\229\165\135\230\179\162\230\152\159\231\187\147", "\232\161\165\229\129\191\229\138\168\231\148\187\230\151\182\233\151\180  \230\151\182\233\151\180=" .. self.moveDeltaTime)
        _moveTween = self.moveRoot:DOLocalMove(pos, self.moveDeltaTime):SetEase(tweenEase):SetAutoKill(false):OnComplete(function()
          _inLockStayState = true
          _moveTween:Kill()
          _moveTween = nil
          self.compensateMove = false
          self.startCompensateTime = 0
          print("\229\165\135\230\179\162\230\152\159\231\187\147", "\229\188\186\229\136\182\233\135\141\229\144\175\232\191\155\229\133\165\229\138\168\231\148\187\230\146\173\230\148\190\229\174\140\230\136\144  \230\156\128\231\187\136\229\157\144\230\160\135=" .. self.moveRoot.localPosition.x .. "," .. self.moveRoot.localPosition.y .. "," .. self.moveRoot.localPosition.z)
          printf("test", "\231\187\147\230\157\159\230\151\182\233\151\180 " .. C_Time.time)
        end)
      end
    end
  end
end

function page:onLateUpdate_displayFollow()
  if self.isMove then
    self:moveEnterTarget()
    self.isMove = false
  end
  self:subLockTargetMove()
  if _inLockStayState then
    local pos = self:getUIPos()
    if pos ~= nil then
      self.moveRoot.localPosition = pos
    end
  end
end

function page:removeListener()
  L_BattleManager:removeListener(L_BattleManager.event.tmpPauseInput, self.onEvent_tmpPauseInput, self)
  L_BattleDataManager:removeListener(L_BattleDataManager.event.petCatchNotice, self.onEvent_petCatch, self)
  C_WorldEvent.instance:Cancel(C_EWorldEvent.PetCatchCameraLockTarget, self._onEnterTarget)
  C_WorldEvent.instance:Cancel(C_EWorldEvent.PetCatchCameraLoseTarget, self._onExitTarget)
end

function page:close()
  self:removeListener()
  C_EntityManager.ExitPetCatch()
  L_Net:UnregisterGameConnectEvent(C_EGameConnectStatus.SimpleReconnected, self.onReconnectedHandler)
  self:clearTimer()
  if self.closeTimer then
    Timer.remove(self.closeTimer)
    self.closeTimer = nil
  end
  if self.playingAnimTimer then
    Timer.remove(self.playingAnimTimer)
    self.playingAnimTimer = nil
  end
  L_ShortCutManager:removeShortCut(self.pageName)
  if self._lateUpdateHandle then
    C_UpdateSource.RemoveLateUpdateEventHandler(self._lateUpdateHandle)
  end
  self._lateUpdateHandle = nil
  _inLockStayState = false
  if _moveTween then
    _moveTween:Kill()
    _moveTween = nil
  end
end

function page:onReconnected()
  self.catchIsStart = false
  self:onClick_close()
  L_Net:UnregisterGameConnectEvent(C_EGameConnectStatus.SimpleReconnected, self.onReconnectedHandler)
end

function page:playFrontSightAnim(isActive)
  local index = C_EntityManager.GetCatchCurSelectIndex()
  if index < 0 then
    self:playFrontSightAnimNormal(false)
    return
  end
  local entity = C_EntityManager.GetSelectMonsterEntities()[index]
  if isActive then
    self:playFrontSightAnimActive()
  else
    self:playFrontSightAnimNormal(false)
  end
end

function page:playFrontSightAnimNormal(forcedPlay)
  if not self.frontSightAnimPlayed and not forcedPlay then
    return
  end
  local anim = self.tipsRoot.gameObject:GetComponent(typeof(C_Animation))
  if anim ~= nil then
    anim:Play("anim_battlecapture_frame_normal")
    self.frontSightAnimPlayed = false
  end
end

function page:playFrontSightAnimActive()
  if self.frontSightAnimPlayed then
    return
  end
  local anim = self.tipsRoot.gameObject:GetComponent(typeof(C_Animation))
  if anim ~= nil then
    anim:Play("anim_battlecapture_frame_active")
    self.frontSightAnimPlayed = true
  end
end

function page:getSelectedMonsterId()
  local index = C_EntityManager.GetCatchCurSelectIndex()
  if index < 0 or index >= C_EntityManager.GetSelectMonsterEntities().Count then
    return 0
  end
  local entity = C_EntityManager.GetSelectMonsterEntities()[index]
  local entityId = entity.data.entityId
  return entityId
end

function page:moveToCenter()
  self.moveRoot.localPosition = {
    x = 0,
    y = 0,
    z = 0
  }
end

return page
