export class TableColumn {
    constructor() {
        this.csv = true;
        this.pdf = true;
        this.sortable = true;
        this.visible = true;
    }
    componentWillLoad() {
        this.updateFormat();
    }
    componentDidLoad() {
        this.change();
    }
    componentDidUpdate() {
        this.change();
    }
    componentDidUnload() {
        this.change();
    }
    updateFormat() {
        if (typeof this.format === 'string') {
            let format;
            try {
                format = JSON.parse(this.format);
            }
            catch (e) {
                if (/SyntaxError/.test(e)) {
                    if (['currency', 'decimal', 'percent'].indexOf(this.format) !== -1) {
                        format = {
                            style: this.format
                        };
                        if (this.format === 'currency')
                            format['currency'] = 'USD';
                    }
                }
                else {
                    throw e;
                }
            }
            this.format = format;
        }
    }
    change() {
        this.glTableColumnChanged.emit(this);
    }
    static get is() { return "gl-table-column"; }
    static get properties() { return {
        "attribute": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "attribute",
            "reflect": false
        },
        "cellClassAttribute": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "cell-class-attribute",
            "reflect": false
        },
        "component": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "component",
            "reflect": false
        },
        "componentProps": {
            "type": "any",
            "mutable": false,
            "complexType": {
                "original": "any",
                "resolved": "any",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "component-props",
            "reflect": false
        },
        "csv": {
            "type": "boolean",
            "mutable": false,
            "complexType": {
                "original": "boolean",
                "resolved": "boolean",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "csv",
            "reflect": false,
            "defaultValue": "true"
        },
        "format": {
            "type": "any",
            "mutable": true,
            "complexType": {
                "original": "string | any",
                "resolved": "any",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "format",
            "reflect": false
        },
        "label": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "label",
            "reflect": false
        },
        "pdf": {
            "type": "boolean",
            "mutable": false,
            "complexType": {
                "original": "boolean",
                "resolved": "boolean",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "pdf",
            "reflect": false,
            "defaultValue": "true"
        },
        "sortable": {
            "type": "boolean",
            "mutable": false,
            "complexType": {
                "original": "boolean",
                "resolved": "boolean",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "sortable",
            "reflect": false,
            "defaultValue": "true"
        },
        "visible": {
            "type": "boolean",
            "mutable": false,
            "complexType": {
                "original": "boolean",
                "resolved": "boolean",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "visible",
            "reflect": false,
            "defaultValue": "true"
        }
    }; }
    static get events() { return [{
            "method": "glTableColumnChanged",
            "name": "glTableColumnChanged",
            "bubbles": true,
            "cancelable": true,
            "composed": true,
            "docs": {
                "tags": [],
                "text": ""
            },
            "complexType": {
                "original": "any",
                "resolved": "any",
                "references": {}
            }
        }]; }
    static get watchers() { return [{
            "propName": "format",
            "methodName": "updateFormat"
        }]; }
}
