var __decorate=this&&this.__decorate||function(t,e,o,r){var i,n=arguments.length,s=n<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,o,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(n<3?i(s):n>3?i(e,o,s):i(e,o))||s);return n>3&&s&&Object.defineProperty(e,o,s),s},__awaiter=this&&this.__awaiter||function(t,e,o,r){return new(o||(o=Promise))(function(i,n){function s(t){try{l(r.next(t))}catch(t){n(t)}}function a(t){try{l(r.throw(t))}catch(t){n(t)}}function l(t){var e;t.done?i(t.value):((e=t.value)instanceof o?e:new o(function(t){t(e)})).then(s,a)}l((r=r.apply(t,e||[])).next())})};import{html as t,unsafeCSS as e}from"lit";import{property as o,query as r}from"lit/decorators.js";import"@openremote/or-asset-tree";import"@openremote/or-translate";import"@openremote/or-mwc-components/or-mwc-input";import"@openremote/or-mwc-components/or-mwc-list";import{InputType as i}from"@openremote/or-mwc-components/or-mwc-input";import{i18next as n}from"@openremote/or-translate";import{DefaultColor2 as s,DefaultColor4 as a,DefaultColor5 as l,Util as c}from"@openremote/core";import{OrMwcDialog as p}from"@openremote/or-mwc-components/or-mwc-dialog";import{when as u}from"lit/directives/when.js";import{ListType as m}from"@openremote/or-mwc-components/or-mwc-list";export class AttributePickerPickedEvent extends CustomEvent{}export class AttributePicker extends p{constructor(){super(...arguments),this.multiSelect=!1,this.showOnlyDatapointAttrs=!1,this.showOnlyRuleStateAttrs=!1}connectedCallback(){super.connectedCallback(),this.heading=n.t("selectAttributes"),this._setDialogContent(),this._setDialogActions(),this.dismissAction=null,this.styles=this._getStyles()}setShowOnlyDatapointAttrs(t){return this.showOnlyDatapointAttrs=t,this}setShowOnlyRuleStateAttrs(t){return this.showOnlyRuleStateAttrs=t,this}setMultiSelect(t){return this.multiSelect=t,this}setOpen(t){return super.setOpen(t),this}setHeading(t){return super.setHeading(t),this}setContent(t){throw Error("Cannot modify attribute picker content")}setActions(t){throw Error("Cannot modify attribute picker actions")}setDismissAction(t){throw Error("Cannot modify attribute picker dismiss action")}setStyles(t){throw Error("Cannot modify attribute picker styles")}setAvatar(t){throw Error("Cannot modify attribute picker avatar setting")}_updateDialogContent(){this._setDialogContent()}_updateDialogActions(){this._setDialogActions()}_getAttributesTemplate(e,o,r){return __awaiter(this,arguments,void 0,function*(e,o,r,s=!1,a){let l=Math.max((null==e?void 0:e.length)||0,(null==o?void 0:o.length)||0),p=[];for(let t=0;t<l;t++)p.push({text:c.getAttributeLabel(null==e?void 0:e[t],null==o?void 0:o[t],void 0,!0),value:(null==e?void 0:e[t].name)||(null==o?void 0:o[t].name)});return t`
            ${u(s,()=>t`
                <or-mwc-list id="attribute-selector" .type="${m.MULTI_CHECKBOX}" .listItems="${p}" .values="${r}"
                             @or-mwc-list-changed="${t=>null==a?void 0:a(t.detail.map(t=>t.value))}"
                </or-mwc-list>
            `,()=>t`
                <or-mwc-input id="attribute-selector" .type="${i.LIST}" .options="${null==p?void 0:p.map(t=>[t,t.text])}"
                              style="display:flex;" .label="${n.t("attribute")}"
                              @or-mwc-input-changed="${t=>null==a?void 0:a([t.detail.value.value])}"
                ></or-mwc-input>
            `)}
        `})}_getStyles(){return`
            .attributes-header {
                line-height: 48px;
                padding: 0 15px;
                background-color: ${e(s)};
                font-weight: bold;
                border-bottom: 1px solid ${e(s)};
            }
            footer.mdc-dialog__actions {
                border-top: 1px solid ${e(l)};
            }
            #header {
                background-color: ${e(a)} !important;
            }
            #dialog-content {
                padding: 0;
            }
        `}}__decorate([o({type:Boolean})],AttributePicker.prototype,"multiSelect",void 0),__decorate([o({type:Boolean})],AttributePicker.prototype,"showOnlyDatapointAttrs",void 0),__decorate([o({type:Boolean})],AttributePicker.prototype,"showOnlyRuleStateAttrs",void 0),__decorate([r("#add-btn")],AttributePicker.prototype,"addBtn",void 0);