import{e as z,p as G}from"./chunk-SPUEGBWO.js";import{Qa as U,ea as H,vb as q}from"./chunk-ROXKKVPK.js";import{A as g,C as h,D as b,Fa as d,G as S,Ga as M,Ha as _,Ma as O,Pa as y,Qb as F,Rc as R,S as a,Ta as u,Ua as v,Uc as $,Va as V,X as I,bd as j,ca as T,da as p,ea as m,fb as P,ha as w,ia as E,ja as k,ka as o,la as r,lc as A,ma as x,oc as D,ra as C,ta as f,va as c,xb as B}from"./chunk-ZVAMPSQU.js";import{j as L}from"./chunk-FB5LSH2R.js";var K=e=>({name:e});function N(e,l){if(e&1){let t=C();o(0,"ion-item",1),f("click",function(){h(t);let i=c();return b(i.selectedLabel=void 0)}),x(1,"ion-icon",2),o(2,"ion-label")(3,"h2"),d(4),r(),o(5,"p"),d(6),u(7,"translate"),r()()()}if(e&2){let t=c();a(4),_(" ",t.selectedLabel.title," "),a(2),_(" ",v(7,2,"components.selectLabel.change")," ")}}function Q(e,l){if(e&1){let t=C();o(0,"ion-item",1),f("click",function(){let i=h(t).$implicit,s=c(3);return b(s.selectLabel(i))}),x(1,"ion-icon",2),o(2,"ion-label")(3,"h2"),d(4),r(),o(5,"p"),d(6),u(7,"translate"),r()()()}if(e&2){let t=l.$implicit;a(4),_(" ",t.title," "),a(2),M(v(7,2,"components.selectLabel.select"))}}function W(e,l){if(e&1&&(o(0,"ion-item"),x(1,"ion-icon",7),o(2,"ion-label"),d(3),u(4,"translate"),r()()),e&2){let t=c(3);a(3),_(" ",V(4,1,"components.selectLabel.null",y(4,K,t.searchText))," ")}}function X(e,l){if(e&1&&(o(0,"div",5)(1,"div",6),w(2,Q,8,4,"ion-item",0,T().labelTrackBy,!0),p(4,W,5,6,"ion-item"),r()()),e&2){let t=c(2);a(2),E(t.results),a(2),m(t.results.length===0&&t.searchText.length>0?4:-1)}}function Y(e,l){if(e&1){let t=C();o(0,"div")(1,"ion-searchbar",3),u(2,"translate"),f("ionInput",function(i){h(t);let s=c();return b(s.onSearchInputChange(i))}),r(),o(3,"div",4),p(4,X,5,1,"div",5),r()()}if(e&2){let t=c();a(),k("placeholder",O(v(2,3,"components.selectLabel.search"))),a(3),m(t.searchText.length?4:-1)}}var he=(()=>{let l=class l{get selectedLabel(){return this._selectedLabel}set selectedLabel(n){this._selectedLabel=n,this.selectedLabelChange.emit(this._selectedLabel)}constructor(){this.loadingService=g(z),this.serverActionsService=g(G),this.searchText="",this.selectedLabelChange=new S,this.labels=[],this.results=[],q({folderOpenOutline:H,pricetagOutline:U}),this.load()}load(){return L(this,null,function*(){let n=this.loadingService.start(),i=yield this.serverActionsService.labels.getLabels();n.dismiss(),i&&(this.labels=i.sort((s,J)=>s.title.localeCompare(J.title)),this.results=this.labels)})}onSearchInputChange(n){if(this.searchText=n.detail.value||"",!this.searchText){this.results=this.labels;return}this.results=this.labels.filter(i=>i.title.includes(this.searchText))}selectLabel(n){this.selectedLabel=n,this.searchText="",this.results=this.labels}labelTrackBy(n,i){return i.id}};l.\u0275fac=function(i){return new(i||l)},l.\u0275cmp=I({type:l,selectors:[["select-label"]],inputs:{selectedLabel:"selectedLabel"},outputs:{selectedLabelChange:"selectedLabelChange"},decls:3,vars:2,consts:[["button",""],["button","",3,"click"],["name","pricetag-outline","slot","start"],["autocomplete","off",3,"ionInput","placeholder"],[1,"ion-padding-start","ion-padding-end"],[1,"results-list-container"],[1,"results-list"],["name","folder-open-outline","slot","start"]],template:function(i,s){i&1&&(o(0,"div"),p(1,N,8,4,"ion-item",0),p(2,Y,5,5,"div"),r()),i&2&&(a(),m(s.selectedLabel?1:-1),a(),m(s.selectedLabel?-1:2))},dependencies:[P,F,B,A,R,D,$,j],styles:[".results-list[_ngcontent-%COMP%]   ion-item[_ngcontent-%COMP%]{--background: var(--ion-background-tint-color)}.results-list[_ngcontent-%COMP%]{position:absolute;width:100%;overflow-y:auto;margin-top:-6px;z-index:2;background-color:var(--ion-background-tint-color);box-shadow:1px 1px 7px #0006}.results-list-container[_ngcontent-%COMP%]{position:relative}ion-spinner[_ngcontent-%COMP%]{width:24px;height:24px}"]});let e=l;return e})();export{he as a};
