import{E as G,c as $,g as F,o as L}from"./chunk-7JTNILXC.js";import{a as b}from"./chunk-CUOYDGDO.js";import{a as X}from"./chunk-TTJW756Y.js";import{Da as _,Dc as k,Ec as s,F as I,Gd as U,Hb as h,I as O,Jb as E,Kd as z,Mc as C,Na as v,Tb as V,Wc as H,Zg as B,ba as c,cc as T,d as P,dc as N,ec as D,ga as l,gb as w,ha as u,hb as A,ma as R,mb as g,mc as x,nb as a,ob as p,pb as S,zb as f}from"./chunk-NY4TI4KT.js";import{a as d,g as j,i as m}from"./chunk-IQVXR75E.js";var Q=j(B());var J=i=>({"has-icon":i});function K(i,r){if(i&1){let W=f();a(0,"button",6),h("click",function(){l(W);let t=E();return u(t.onSearchClick());}),S(1,"my-global-icon",7),p();}}var q=(0,Q.default)("peertube:SearchInputComponent"),le=(()=>{let r=class r{route=c(U);router=c(z);destroyRef=c(R);placeholder=s("Criathraich\u2026");inputId=s("search-input");icon=s(!1,{transform:C});emitOnInit=s(!1,{transform:C});search=k();searchValue;searchStream;viewInitialized=!1;emitSearchAfterViewInit=!1;ngOnInit(){this.initSearchStream(),this.listenToRouteSearchChange();}ngAfterViewInit(){this.viewInitialized=!0,this.emitOnInit()&&this.emitSearchAfterViewInit&&this.emitSearch();}onInputSearch(e){this.scheduleSearchUpdate(e.target.value);}onSearchClick(){this.scheduleSearchUpdate(this.searchValue);}onClear(){this.immediateSearchUpdate("");}scheduleSearchUpdate(e){this.searchValue=e,this.searchStream.next(this.searchValue);}immediateSearchUpdate(e){this.searchValue=e,this.setQueryParam(this.searchValue),this.emitSearch();}listenToRouteSearchChange(){this.route.queryParams.pipe(b(this.destroyRef)).subscribe(e=>{let t=e.search||"";q('On route search change "%s".',t),this.searchValue!==t&&(this.searchValue=t,this.emitSearch());});}initSearchStream(){this.searchStream=new P(),this.searchStream.pipe(I(300),O(),b(this.destroyRef)).subscribe(()=>{this.setQueryParam(this.searchValue),this.emitSearch();});}emitSearch(){if(!this.viewInitialized){this.emitSearchAfterViewInit=!0;return;}q('On search "%s".',this.searchValue),this.search.emit(this.searchValue);}setQueryParam(e){let t=e?{search:e.trim()}:{search:void 0};this.router.navigate(["."],{relativeTo:this.route,queryParams:d(d({},this.route.snapshot.queryParams),t)});}};m(r,"\u0275fac",function(t){return new(t||r)();}),m(r,"\u0275cmp",v({type:r,selectors:[["my-search-input"]],inputs:{placeholder:[1,"placeholder"],inputId:[1,"inputId"],icon:[1,"icon"],emitOnInit:[1,"emitOnInit"]},outputs:{search:"search"},decls:6,vars:8,consts:()=>{let e;e="Lorg";let t;return t="Falamhaich",[["input",""],[1,"input-group","has-clear","flex-nowrap",3,"ngClass"],["title",e,"type","button",1,"button-unstyle","search-button"],["type","text",1,"last-in-group","first-in-group",3,"ngModelChange","keyup","name","id","placeholder","ngModel"],["title",t,"type","button",1,"p-0","border-0","form-control-clear",3,"click"],["iconName","cross"],["title",e,"type","button",1,"button-unstyle","search-button",3,"click"],["iconName","search"]];},template:function(t,n){if(t&1){let M=f();a(0,"div",1),w(1,K,2,0,"button",2),a(2,"input",3,0),D("ngModelChange",function(o){return l(M),N(n.searchValue,o)||(n.searchValue=o),u(o);}),h("keyup",function(o){return n.onInputSearch(o);}),p(),a(4,"button",4),h("click",function(){l(M);let o=V(3);return n.onClear(),u(o.focus());}),S(5,"my-global-icon",5),p()();}t&2&&(g("ngClass",x(6,J,n.icon())),_(),A(n.icon()?1:-1),_(),g("name",n.inputId())("id",n.inputId())("placeholder",n.placeholder()),T("ngModel",n.searchValue));},dependencies:[H,G,$,F,L,X],styles:[`.input-group[_ngcontent-%COMP%]{width:fit-content}input[_ngcontent-%COMP%]{font-size:16px;padding:var(--input-y-padding) var(--input-x-padding);width:250px;max-width:250px;color:var(--input-fg);background-color:var(--input-bg);border:var(--input-border-width) solid var(--input-border-color);border-radius:var(--input-border-radius);line-height:24px}input[_ngcontent-%COMP%]::placeholder{color:var(--input-placeholder-color);font-size:var(--input-placeholder-font-size)}input[readonly][_ngcontent-%COMP%]{color:var(--fg-300)}input[_ngcontent-%COMP%]:focus, input[_ngcontent-%COMP%]:focus-visible{box-shadow:0 0 0 .2rem var(--fg-100);outline:0}input[disabled][_ngcontent-%COMP%]{color:var(--fg-300);opacity:.8}@media screen and (max-width:290px){input[_ngcontent-%COMP%]{width:100%}}.has-icon[_ngcontent-%COMP%]   input[_ngcontent-%COMP%]{padding-inline-start:46px}.search-button[_ngcontent-%COMP%]{position:absolute;top:0;bottom:0;left:20px;color:var(--fg-200)}.search-button[_ngcontent-%COMP%]   my-global-icon[_ngcontent-%COMP%]{display:inline-block;width:19px;height:19px;line-height:19px}.form-control-clear[_ngcontent-%COMP%]   my-global-icon[_ngcontent-%COMP%]{display:inline-block;width:19px;height:19px;line-height:19px}
/*# sourceMappingURL=search-input.component-C46AGDLR.css.map */`]}));let i=r;return i;})();export{le as a};/**i18n:347eeb695970c32bc275618edc2e751c67145d9fc3012e70543c114a99b9e016*///# sourceMappingURL=chunk-2XSXSKOZ.js.map