export class PopUpItem extends Jade.UI.Control {
    constructor(options) {
        super(options);
    }
    get data() {
        return this.state.get("data", {});
    }
    get uid() {
        return this.resolveMap(this.uidMap);
    }
    get uidMap() {
        return this.state.get("uidMap", "uid");
    }
    get label() {
        return this.resolveMap(this.labelMap);
    }
    get labelMap() {
        return this.state.get("labelMap", "label");
    }
    get icon() {
        return this.resolveMap(this.iconMap);
    }
    get iconMap() {
        return this.state.get("iconMap", "icon");
    }
    get clickCallback() {
        return this.state.get("click", null);
    }
    template() {
        let result = $(`<div data-role="item" data-id="${this.uid}" title="${this.label}" class="-pdjs-pop-up-item">${this.label}</div>`);
        if (this.icon != null) {
            result.css({
                paddingLeft: "25px",
                backgroundImage: `url(${Jade.IconSet.get("pd").resolve(this.icon, Jade.IconSetSizeSpecificDirectory.x16)})`
            });
        }
        return result;
    }
    onActivate(e) {
        super.onActivate(e);
        if (_.isFunction(this.clickCallback)) {
            this.node.on(Jade.BrowserEvent.CLICK, _.bind(this.clickCallback, this));
        }
    }
    resolveMap(id, defaultValue) {
        return this.state.get(`data.${id}`, defaultValue);
    }
}
