(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-570c6682"],{"61ae":function(e,t,s){"use strict";s("723e")},"723e":function(e,t,s){},b865:function(e,t,s){"use strict";s.r(t);var n=s("b0af"),a=s("8860"),o=s("da13"),i=s("490a"),c=s("2fa4"),u=s("8654"),l=s("3a2f"),r=function(){var e=this,t=e._self._c;return t("div",{staticClass:"extra-dense-fields"},[t(u["a"],{attrs:{outlined:"",dense:"",placeholder:e.placeholder},on:{focus:function(t){e.isInputFocued=!0},blur:e.closeSuggestions,input:e.searchDebounced},scopedSlots:e._u([{key:"append",fn:function(){return[e.searchLoading?t(i["a"],{attrs:{indeterminate:"",size:"18",width:"2",color:"primary"}}):e._e()]},proxy:!0}]),model:{value:e.tempValue,callback:function(t){e.tempValue=t},expression:"tempValue"}}),e.hasSuggestions&&e.tempValue&&e.isInputFocued?t(n["a"],{staticClass:"suggestions-list"},[t(a["a"],{staticClass:"overflow-y-scroll",attrs:{"max-height":"200",dense:""}},[e.account?e._l(e.accountSuggestions,(function(s,n){return t(o["a"],{key:n,attrs:{dense:""},on:{click:function(t){return e.onSuggestionClick(s.document)}}},[t(l["a"],{attrs:{bottom:"","open-delay":"100"},scopedSlots:e._u([{key:"activator",fn:function({on:n}){return[t("div",e._g({staticClass:"d-flex flex-column"},n),[t("div",{staticClass:"text-xs"},[e._v("Switch to")]),t("div",{staticClass:"d-flex align-center mt-n2 w-100"},[t("div",{staticClass:"font-weight-medium mxw-60 mr-1 text-truncate"},[e._v(" "+e._s(s.document.name)+" ")]),t("div",{staticClass:"text-xs font-weight-regular"},[e._v(" (Existing "+e._s(e.account?"account":e.contact?"contact":"")+") ")])])])]}}],null,!0)},[e._v(" "+e._s(s.document.name)+" ")]),t(c["a"])],1)})):e.contact?e._l(e.accountSuggestions,(function(e,s){return t(o["a"],{key:s})})):e._e()],2)],1):e._e()],1)},h=[],p=(s("14d9"),s("2f62")),d=s("f3b2"),g=s("1bcb");const m=s("b047c");var f={props:{value:{type:String},account:{type:Boolean,default:!1},contact:{type:Boolean,default:!1},placeholder:{type:String}},data:()=>({accountSuggestions:[],contactSuggestions:[],searchLoading:!1,isInputFocued:!1}),computed:{...Object(p["c"])("user",["user"]),hasSuggestions(){return this.accountSuggestions.length||this.contactSuggestions.length},tempValue:{get(){return this.value},set(e){this.$emit("input",e)}}},methods:{closeSuggestions:m((async function(){this.isInputFocued=!1}),300),searchDebounced:m((async function(){await this.fetchData()}),300),initTypeSense(){this.typeSenseClient=new d["SearchClient"]({nodes:[{host:"typesense.symbo.lol",port:"443",protocol:"https"}],apiKey:""+this.user.typesense_key,connectionTimeoutSeconds:2})},fetchData(){if(!this.tempValue)return;this.searchLoading=!0;const e="prod_";let t={searches:[]};this.account&&t.searches.push({collection:e+"accounts",q:this.tempValue,query_by:"name",per_page:50}),this.contact&&t.searches.push({collection:e+"prospects",q:this.tempValue,query_by:"full_name",per_page:50}),this.typeSenseClient.multiSearch.perform(t).then(({results:e})=>{var t,s;this.accountSuggestions=(null===(t=e[0])||void 0===t?void 0:t.hits.filter(e=>!(this.tempValue.length>e.document.name.length&&this.tempValue.toLowerCase().includes(e.document.name.toLowerCase()))))||[],this.contactSuggestions=(null===(s=e[1])||void 0===s?void 0:s.hits)||[]}).finally(()=>this.searchLoading=!1)},onSuggestionClick(e){this.$emit("suggestion-selected",e),this.tempValue=e.name}},created(){this.initTypeSense(),this.tempValue=this.value,g["a"].$on("user-profile-refreshed",this.initTypeSense)}},y=f,S=(s("61ae"),s("2877")),v=Object(S["a"])(y,r,h,!1,null,"49a03979",null);t["default"]=v.exports}}]);
//# sourceMappingURL=chunk-570c6682.356e296b.js.map