var __reflect = (this && this.__reflect) || function (p, c, t) {
    p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t;
};
var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var PackageIcon = (function (_super) {
    __extends(PackageIcon, _super);
    function PackageIcon() {
        return _super.call(this) || this;
    }
    PackageIcon.prototype.childrenCreated = function () {
        _super.prototype.childrenCreated.call(this);
        this.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onShowHandler, this);
    };
    PackageIcon.prototype.onShowHandler = function (e) {
        // let item = RES.getRes("items_json")["items"][this.data.id - 1];
        var item = Game.instance.getItemObj(this.data.id);
        if (item.type == "letter") {
            letter.setLetter(item.id);
        }
        else if (item.type == "code") {
            talk.setTalk(this.getCode(item.content));
        }
        else if (item.type == "codeSegment") {
            talk.setTalk(item.content + " = " + item.key);
        }
        else {
            talk.setTalk(item.content);
        }
    };
    PackageIcon.prototype.dataChanged = function () {
        _super.prototype.dataChanged.call(this);
        this.d = {};
        // let item = RES.getRes("items_json")["items"][this.data.id - 1];
        var item = Game.instance.getItemObj(this.data.id);
        this.d.icon = item.icon;
    };
    PackageIcon.prototype.getCode = function (str) {
        // var codeSegments = [];
        // if(userGameData.package && userGameData.package.length)
        // {
        // 	for(let i = 0, len = userGameData.package.length; i < len; i++)
        // 	{
        // 		let item = Game.instance.getItemObj(userGameData.package[i]);
        // 		if(item.type == "codeSegment")
        // 		{
        // 			codeSegments.push(item.id);
        // 		}
        // 	}
        // }
        var msg = "(";
        var hasSegment = false;
        for (var i = 9; i <= 15; i++) {
            var item = Game.instance.getItemObj(i);
            if (userGameData.package.indexOf(i) == -1) {
                msg += item.content;
            }
            else {
                msg += item.key;
                hasSegment = true;
            }
        }
        msg += ")";
        if (hasSegment) {
            return str + "\n\n" + msg;
        }
        return str;
    };
    return PackageIcon;
}(eui.ItemRenderer));
__reflect(PackageIcon.prototype, "PackageIcon", ["eui.UIComponent", "egret.DisplayObject"]);
//# sourceMappingURL=PackageIcon.js.map