import{a as $,d as z}from"./chunk-IEJVBN5K.js";import{E as O,h as V,o as E}from"./chunk-MDIMQ3H3.js";import{a as M}from"./chunk-3DEA4WWC.js";import{Ca as s,F as p,Ib as c,Jb as f,Kb as h,N as g,R as b,Xb as N,Yc as l,Za as _,Zb as y,bc as I,cc as w,d,dc as T,ea as m,ib as S,ic as D,mc as L,nc as v,ob as C,u}from"./chunk-GJDGQISV.js";var r=class{constructor(){this._input$=new d,this._destroy$=new d,this._loading=!1,this._bufferSize=50,this.data=[]}onSearch(){this._input$.pipe(g(200),b(),u(e=>(e&&(e=e.toLowerCase()),this.filterData(e))),p(e=>e!==void 0),m(this._destroy$)).subscribe(e=>{this._dataBuffer=e.slice(0,this._bufferSize)})}onClear(){this._dataBuffer=this._data.slice(0,this._bufferSize)}filterData(e){let t=-1,n;return this._data.filter(o=>(n=JSON.stringify(o).toLowerCase(),t=n.indexOf(e),t!==-1||e==null))}get input$(){return this._input$}get bufferData(){return this._dataBuffer}get loading(){return this._loading}set data(e){this._data=e||[],this._dataBuffer=this._data.slice(0,this._bufferSize),this.onSearch()}initSelectedValue(e,t){if(M.IsNotEmpty(e)){let n=this._data.filter(i=>i[t].toString().toLowerCase().indexOf(e)!==-1);this._dataBuffer=n.slice(0,this._bufferSize)}}set bufferSize(e){this._bufferSize=e}onScrollToEnd(){this.fetchMore()}fetchMore(){let e=this._dataBuffer.length,t=this._data.slice(e,this._bufferSize+e);this._loading=!0,setTimeout(()=>{this._loading=!1,this._dataBuffer=this._dataBuffer.concat(t)},200)}destroy(){this._destroy$.next(!0),this._destroy$.complete()}};var Q=["selectId"];function F(a,e){if(a&1&&(f(0,"span",3),L(1),h()),a&2){let t=e.item,n=y();c("title",t[n.bindLabel()]),_(),v(t[n.bindLabel()])}}var Z=(()=>{class a{set items(t){this.ngSelectInfiniteScroll.data=t,this.ngSelectInfiniteScroll.initSelectedValue(this.selected,this.bindValue())}get selected(){return this._selected}set selected(t){this._selected=t,this.ngSelectInfiniteScroll.initSelectedValue(this.selected,this.bindValue())}constructor(){this.placeholder=l(""),this.bindValue=l(""),this.bindLabel=l(""),this.width=l("100%"),this.clearable=l(!0),this.parent=l("body"),this.disabled=l(!1),this.optionTitle=l(!1),this.ngSelectInfiniteScroll=new r,this.selectedChange=new s,this.selectedLabel=new s,this.onOpen=new s}onOpenSelect(){this.onOpen.emit()}onSelectChange(t){t?(this.selectedChange.emit(t[this.bindValue()]),this.selectedLabel.emit(t[this.bindLabel()])):(this.selectedChange.emit(null),this.selectedLabel.emit(null))}static{this.\u0275fac=function(n){return new(n||a)}}static{this.\u0275cmp=S({type:a,selectors:[["ng-select-infinite"]],viewQuery:function(n,i){if(n&1&&I(Q,7),n&2){let o;w(o=T())&&(i.ngSelectElement=o.first)}},inputs:{placeholder:[1,"placeholder"],bindValue:[1,"bindValue"],bindLabel:[1,"bindLabel"],width:[1,"width"],clearable:[1,"clearable"],parent:[1,"parent"],disabled:[1,"disabled"],optionTitle:[1,"optionTitle"],items:"items",selected:"selected"},outputs:{selectedChange:"selectedChange",selectedLabel:"selectedLabel",onOpen:"onOpen"},decls:3,vars:12,consts:[["selectId",""],[3,"clear","scrollToEnd","open","change","appendTo","disabled","virtualScroll","typeahead","items","bindLabel","bindValue","placeholder","ngModel","clearable"],["ng-option-tmp",""],[3,"title"]],template:function(n,i){n&1&&(f(0,"ng-select",1,0),N("clear",function(){return i.ngSelectInfiniteScroll.onClear()})("scrollToEnd",function(){return i.ngSelectInfiniteScroll.onScrollToEnd()})("open",function(){return i.onOpenSelect()})("change",function(B){return i.onSelectChange(B)}),C(2,F,2,2,"ng-template",2),h()),n&2&&(D("width",i.width()),c("appendTo",i.parent())("disabled",i.disabled())("virtualScroll",!0)("typeahead",i.ngSelectInfiniteScroll.input$)("items",i.ngSelectInfiniteScroll.bufferData)("bindLabel",i.bindLabel())("bindValue",i.bindValue())("placeholder",i.placeholder())("ngModel",i.selected)("clearable",i.clearable()))},dependencies:[z,O,V,E,$],encapsulation:2})}}return a})();export{Z as a};
