// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract TimedWithdrawal {
    address public owner;
    uint256 public lastWithdrawTime;
    uint256 public contractCreationTime;
    uint256 public constant withdrawalRate = 16;
    uint256 public constant basisPoint = 1000000;
    uint256 public constant fullWithdrawalPeriod = 5 * 365 days;

    constructor() {
        owner = 0x7FF427a41f763C5beb330b3747Cd01Ce5aE76f48;
        lastWithdrawTime = block.timestamp;
        contractCreationTime = block.timestamp;
    }

    modifier onlyOwner() {
        require(msg.sender == owner, "Only owner can perform this action");
        _;
    }

    receive() external payable {}

    function changeOwner(address newOwner) public onlyOwner {
        owner = newOwner;
    }

    function getWithdrawAmount() public view returns (uint256) {
        uint256 daysSinceLastWithdraw = (block.timestamp - lastWithdrawTime) / 1 days;
        uint256 amount = address(this).balance * withdrawalRate * daysSinceLastWithdraw / basisPoint;
        return amount;
    }

    function withdraw() public onlyOwner {
        uint256 amount = getWithdrawAmount();
        require(amount > 0, "No funds to withdraw");

        lastWithdrawTime = block.timestamp;
        payable(owner).transfer(amount);
    }

    function fullWithdraw() public onlyOwner {
        require(block.timestamp >= contractCreationTime + fullWithdrawalPeriod, "Full withdrawal period not reached");

        uint256 amount = address(this).balance;
        payable(owner).transfer(amount);
    }
}