// Contract: Wardrobe
// Target function: function encode(bytes memory data) internal pure returns (string memory)
dMzMjLCwsLCwsLCwsLCwsLCwsLCz8H+FNWFhYWFhYWFj4DFVVtddJkqqqEhYWFhYWFhYWPnf9/KuwsLCwsLCwMAAAAADc5QMIaUwYIlZKbwAAAABJRU5ErkJggg==";
        if (id == 15) return "iVBORw0KGgoAAAANSUhEUgAAAeAAAAHgBAMAAACP+qOmAAAAJFBMVEUAAAAiEQQuFwY/Pz9OQDZVVVVgUDMAAACLRRPjlAD/1wD////DkWR6AAAAB3RSTlMAAAAAAAAAVWTqWAAAAVJJREFUeNrt20ENwkAQQNFawAIWsIAFLGBhLWABC7WAOTJzYNINoTShEJr3Tpt0e/h7mmzTYQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYJtOoYVcCRYsWLBgwYIFC/6EQ8jWW9h+tWDBggULFixY8MoT5Dm0h2wdQ1ULFixYsGDBggULXqCbIK8hM3NV1XUSfz5kChYsWLBgwYIF/+DCLo1T1d8djGDBggULFixYsOBZu9C1Zle1ltx3DIIFCxYsWLBgwYLfu8S7hGcfSWu+7PYJFixYsGDBggULXjBadtVtqp7mG4IFCxYsWLBgwYKXzpevbes/AMGCBQsWLFiw4G/YhzYv9wkWLFiwYMGCBQsGAGBld0h73D+nd49NAAAAAElFTkSuQmCC";
        if (id == 16) return "iVBORw0KGgoAAAANSUhEUgAAAeAAAAHgBAMAAACP+qOmAAAAD1BMVEUAAAAkEwYAAABuORP19dzn8aMXAAAAAnRSTlMAAHaTzTgAAAEmSURBVHja7duxCYQwGIZhdYOskP1nygquIFpEIhLJDxbi8xQHKa54yRUfh04TAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPzTHPxebo/lM8HL325YsGDBggULFvzR4LRzw4IFCxYsWLBgwffG/tNK9eM8rvW4tkc3LFiwYMGCBQu2tAbkdmldHCOruGHBggULFixYsODw0uqztAQLFixYsGDBguNLK3dHlqUlWLBgwYIFCxYcX1p9lpZgwYIFCxYsWHB8aXlOy09asGDBggULFvzC0krPS8u7h4IFCxYsWLBgwQAAvGwDTH0PApemwjkAAAAASUVORK5CYII=";
        if (id == 17) return "iVBORw0KGgoAAAANSUhEUgAAAeAAAAHgBAMAAACP+qOmAAAAElBMVEUAAAAbGxsiEQQAAABSUlKLRRMUITx8AAAAA3RSTlMAAAD6dsTeAAAA9klEQVR42u3YsQ2AQAhAUVZwBVe4FVzB/VcxUGhloYnF4XsVCdXvCBEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHQ30p5qEixYsGDBggULFixYsGDBggULFixYsGDBggULFixY8M+ClzROV3CprWDBggULFixYsOD3B+V2p+GRKViwYMGCBQsWLFiwYMGCBQsWLHh6vpaCBQsWLFiwYMHfW1Nl1hTtCRYsWLBgwYIFAwAAAAAAADxyAFrar7T8804rAAAAAElFTkSuQmCC";
    }

    function _getItems(uint256[18] memory items_, uint256 count) internal pure returns (string memory atts_) {
        uint256 added = 0;
        for (uint256 i = 0; i < items_.length; i++) {
            if (items_[i] == 1) {
                added++;
                if (added == count) {
                    // No trailing comma
                    atts_ = string(abi.encodePacked(atts_, items_[i] == 0 ? "" : '{"trait_type":"Item","value":"', getItemName(i),'"}'));
                } else {
                     atts_ = string(abi.encodePacked(atts_, items_[i] == 0 ? "" : '{"trait_type":"Item","value":"', getItemName(i),'"},'));
                }
            }
           
        }

    }

    function getItems(uint256 id) public view returns (uint256[18] memory equiped, uint256 count) {
        for (uint256 i = 0; i < items; i++) {
            uint256 draw = uint256(keccak256(abi.encodePacked(id, getItemName(i))));
            if (draw <= frequency[i]) {
                equiped[i] = 1;
                count++;
            }
        }
    }

    function getItemName(uint256 id) internal pure returns (string memory) {
        if (id == 0) return "undies";
        if (id == 1) return "socks";  
        if (id == 2) return "pipe";
        if (id == 3) return "pants";
        if (id == 4) return "boots";
        if (id == 5) return "hat";
        if (id == 6) return "sideways hat";
        if (id == 7) return "grandad shirt";
        if (id == 8) return "suspenders";
        if (id == 10) return "gloves";
        if (id == 9) return "gold watch";
        if (id == 11) return "cart";
        if (id == 12) return "tnt";
        if (id == 13) return "axe";
        if (id == 14) return "shovel";
        if (id == 15) return "gold chest";
        if (id == 16) return "moonshine";
        if (id == 17) return "hammer";
    }

    function wrapTag(string memory uri) internal pure returns (string memory) {
        return string(abi.encodePacked('<image x="0" y="0" width="64" height="64" image-rendering="pixelated" preserveAspectRatio="xMidYMid" xlink:href="data:image/png;base64,', uri, '"/>'));
    }

    string constant bg = 'iVBORw0KGgoAAAANSUhEUgAAAeAAAAHgBAMAAACP+qOmAAAAIVBMVEUAAAARGR0mMjg5RUtdaG5gfYt/SQaNbmOQpK6iiYCnVQKcx6tKAAAFLUlEQVR42u3d7XHaMACAYbcbsEJWyAqsEEboCmGEZIWOACt4BVZgBVbo1T+ksyo5EIgkp49++Pgq+Lmod+8ZI/94Gv4d57+bt2Fp7Od3XzIvOWaemN75FO5OH34Jm23YLH/uy3DdOIbPiOPn8J8NYGBgYGBg4Hbjx1PpmfP8bhJeY9i8ZAoq91gcMaj287ffL744ya3neUblPm2TuWVKAwMDAwMDA7corcv8mUvm1W/zyIqxcyy9/yZz95wpqHF+d7+YWzftQfzcjSkNDAwMDAwM3KC0LqW0Wu1IDsHtlRYwMDAwMDBwg9JK7icHiQ6ZfzJ+/K7blqRdprRibpnSwMDAwMDAwPVKKzm7PPkS7vCQDxkf8i7bj99vu1hapjQwMDAwMDBw29JKmuvwkFCqe4irWFqjKQ0MDAwMDAxct7SmbfI7vqS0Hj3GW4psvLncduElW6UFD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OCtL63Q8oWtLo6n5VuvfTnLUxoYGBgYGBj4EZZW+Png03TY/d0DhMtZ79Ph6AwDAwMDAwMDb3xpZZ92GApvkXW6eG6N8+9NXecTED2lgYGBgYGBge9oaaWRVfpYnVO8teHd4tPPDKsP9c9zy1MaGBgYGBgY+I6W1ut8GaULUdnfNVzYGhsfanCGgYGBgYGBgbe2tMIKeos3PBc2UunqVulKVvWhLC1gYGBgYGDgDS+toXBDN19QpUr3G9b/DWcYGBgYGBgYeEtLK12NSje0fiRPul8aVOlylqUFDAwMDAwMvOGl1c2nUOmaVmvVR7G0gIGBgYGBgYGBgYGBgYGBgYGv+S4PofQ2DNW3f8h+jpi9QP5Ue5Ts4Z1hYGBgYGBg4MdfWq07LPsJ4H7+VWlkOcPAwMDAwMDAltZqpVe1l77K3tvBGQYGBgYGBga2tNrKfkcxdZ3fKXSGgYGBgYGBgTe3tLKXWWWrqrS+/PQQGBgYGBgY2NJqq/r2pcP6rc4wMDAwMDAwsKW1VHZNK1T9xcLsVmcYGBgYGBgYWJIkSZIkSZIkSZIkSZKker8Bf5+edlmG5NIAAAAASUVORK5CYII='; 
    string constant header = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="naked" width="100%" height="100%" version="1.1" viewBox="0 0 64 64">';
    string constant footer = '<style>#naked{shape-rendering: crispedges;image-rendering: -webkit-crisp-edges;image-rendering: -moz-crisp-edges;image-rendering: crisp-edges;image-rendering: pixelated;-ms-interpolation-mode: nearest-neighbor;}</style></svg>';
}

library Strings {
    bytes internal constant TABLE =
        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";