contract TemplateCrowdsale is Consts, MainCrowdsale
    
    , BonusableCrowdsale
    
    
    
    
    , WhitelistedCrowdsale
    
{
    event Initialized();
    event TimesChanged(uint startTime, uint endTime, uint oldStartTime, uint oldEndTime);
    bool public initialized = false;

    constructor(MintableToken _token) public
        Crowdsale(6000 * TOKEN_DECIMAL_MULTIPLIER, 0x7A72911D42387d01D7396542fE8b4cF2e84F9B35, _token)
        TimedCrowdsale(START_TIME > now ? START_TIME : now, 1552835340)
        CappedCrowdsale(50000000000000000000000)
        
    {
    }

    function init() public onlyOwner {
        require(!initialized);
        initialized = true;

        if (PAUSED) {
            MainToken(token).pause();
        }

        
        address[4] memory addresses = [address(0x021855a73ed2fc1ef650cae86f372d159f0334b9),address(0x021855a73ed2fc1ef650cae86f372d159f0334b9),address(0x021855a73ed2fc1ef650cae86f372d159f0334b9),address(0x021855a73ed2fc1ef650cae86f372d159f0334b9)];
        uint[4] memory amounts = [uint(100000000000000000000000000),uint(25000000000000000000000000),uint(25000000000000000000000000),uint(50000000000000000000000000)];
        uint64[4] memory freezes = [uint64(1552835401),uint64(1552835401),uint64(1552835401),uint64(1552835401)];

        for (uint i = 0; i < addresses.length; i++) {
            if (freezes[i] == 0) {
                MainToken(token).mint(addresses[i], amounts[i]);
            } else {
                MainToken(token).mintAndFreeze(addresses[i], amounts[i], freezes[i]);
            }
        }
        

        transferOwnership(TARGET_USER);

        emit Initialized();
    }

    

    

    
    function setEndTime(uint _endTime) public onlyOwner {
        // only if CS was not ended
        require(now < closingTime);
        // only if new end time in future
        require(now < _endTime);
        require(_endTime > openingTime);
        emit TimesChanged(openingTime, _endTime, openingTime, closingTime);
        closingTime = _endTime;
    }
    

    

    

    
    /**
     * @dev override purchase validation to add extra value logic.
     * @return true if sended more than minimal value
     */
    function _preValidatePurchase(
        address _beneficiary,
        uint256 _weiAmount
    )
        internal
    {
        
        
        require(msg.value <= 5000000000000000000000);
        
        super._preValidatePurchase(_beneficiary, _weiAmount);
    }
    
}
function _preValidatePurchase(
        address _beneficiary,
        uint256 _weiAmount
    )
        internal
    {
        
        
        require(msg.value <= 5000000000000000000000);
        
        super._preValidatePurchase(_beneficiary, _weiAmount);
    }
/**
 * @dev override purchase validation to add extra value logic.
 * @return true if sended more than minimal value
 */