```\n    function balanceOf(address _wearer, uint256 _hatId)\n        public\n        view\n        override(ERC1155, IHats)\n        returns (uint256 balance)\n    {\n        Hat storage hat = _hats[_hatId];\n\n        balance = 0;\n\n        if (_isActive(hat, _hatId) && _isEligible(_wearer, hat, _hatId)) {\n            balance = super.balanceOf(_wearer, _hatId);\n        }\n    }\n```\n