1import{_ as E}from"./C3yMllYI.js";import{d as F}from"./B9u_R1AG.js";import{a5 as g,S as d,_ as N,r as l}from"./CkH1Rjwg.js";import{a9 as T,a8 as k,Z as o,R as u,J as B,am as O,O as f,S as c,I as P,a4 as q,Y as y,a1 as m,V as S,U as _,P as L,X as h,a7 as M}from"./BzFfDcRy.js";const w="city",I="address",x="flat",A="organization",b="fio",D="inn",Y=new Set([w,I,x,A,b,D]);class v{constructor(s){if(!s.data)throw new Error("ÐбÑÐµÐºÑ Ð½Ðµ Ð¼Ð¾Ð¶ÐµÑ Ð¿ÑеобÑазоваÑÑÑÑ Ð² оÑганизаÑиÑ");this.data=s.data,this.value=s.value,this.unrestricted_value=s.unrestricted_value}get companyName(){return this.data?.name?.short_with_opf??this.data?.name?.full_with_opf??""}get inn(){return this.data?.inn||""}get address(){try{return new g(this.data.address)}catch{return null}}get kpp(){return this.data?.kpp||""}get directorFullName(){return this.data?.management?.name||d.contains([this.data?.fio?.surname||null,this.data?.fio?.name||null,this.data?.fio?.patronymic||null]," ")}get isIndividual(){return this.data?.type==="INDIVIDUAL"}}class z{constructor(s){if(!s.data)throw new Error("ÐбÑÐµÐºÑ Ð½Ðµ Ð¼Ð¾Ð¶ÐµÑ Ð¿ÑеобÑазоваÑÑÑÑ Ð² имÑ");this.data=s.data,this.value=s.value,this.unrestricted_value=s.unrestricted_value}get fullName(){return d.contains([this.data?.surname,this.data?.name,this.data?.patronymic]," ")}}const U={name:"DadataSuggestions",model:{prop:"value"},props:{fetchPending:{type:Boolean,default:!1},showErrorClass:{type:Boolean,default:!0},disableRootClasses:{type:Boolean,default:!1},formClass:{type:[String,Object,Array],default:"w-100"},type:{type:[String,Boolean],required:!0,validator:e=>Y.has(e)||!e},supportingSuggestion:{type:Object,default:null},enableSuggestions:{type:Boolean,default:!0},label:{type:String,default:null},hideLabel:{type:Boolean,default:!1},name:{type:String,default:null},mode:{type:String,default:"eager"},placeholder:{type:String,default:null},customMessages:{type:Object,default:null},rules:{type:[String,Object],default:null},disabled:{type:Boolean,default:!1},searchFullAddress:{type:Boolean,default:!1},showFullAddress:{type:Boolean,default:!1},formInputClass:{type:String,default:null},force:{type:Boolean,default:!0},vid:{type:String,default:null},value:{},errors:{type:Array,required:!1,default:[]}},data(){return{searchValue:this.value,suggestions:[],loading:!1,errorMessage:null,errorTimer:null,showEmptySuggestions:!1,activeIndex:null,alreadySelected:!1}},computed:{modelExpression(){return this.$attrs?.["onUpdate:modelValue"]?.toString()},privateName(){return this.name!==null?this.name:(this.modelExpression||"").split(".").pop().split(")")[0]??null},inputName(){return this.name||this.modelExpression},inputListeners(){return Object.assign({},this.$attrs,{input:e=>this.$emit("input",e)})},emptySuggestions(){return!this.showEmptySuggestions||this.loading||this.suggestions.length?null:this.$t("personal.request.noResults")},countSuggestions(){return this.suggestions.length}},watch:{value(e){this.searchValue=e}},methods:{debounceSearch:F(function(e){if(!this.alreadySelected)return this.search(e)},300),onFocusIn(){this.alreadySelected=!1,this.debounceSearch(this.searchValue)},close(){this.clearSuggestions(),this.$emit("close")},search(e){if(this.showEmptySuggestions=!1,this.alreadySelected||!e||!this.fetchData())return this.clearSuggestions();this.loading=!0,this.fetchData().finally(()=>{this.loading=!1,this.showEmptySuggestions=!this.suggestions.length,this.$refs.inputDadata.$el.contains(document.activeElement)||this.clearSuggestions()})},fetchData(){switch(this.type){case w:return this.fetchCities();case I:return this.fetchAddress();case x:return this.fetchFlat();case A:return this.fetchOrganization();case b:return this.fetchFio();case D:return this.fetchInn();default:return null}},fetchCities(){return l("/geo/cities",{query:this.searchValue}).then(e=>{this.suggestions=e.data.map(s=>new g(s))}).catch(e=>{})},async fetchAddress(){const e={query:this.searchValue};return this.searchFullAddress?e.city={}:this.supportingSuggestion&&(e.city=this.supportingSuggestion),l("/geo/addresses",e).then(s=>{this.suggestions=s.data.map(t=>{const a=new g(t);
1return this.showFullAddress?a.customValue=a.value:a.customValue=a.getAddressWithHistoryName(!0)||a.value,a}).filter(t=>!!t.customValue)}).catch(s=>{})},fetchFlat(){const e={query:this.searchValue};return this.supportingSuggestion&&(e.city=this.supportingSuggestion,e.query=d.contains([this.supportingSuggestion.getStreetWithHouse(!0),this.searchValue]," ")),l("/geo/addresses",e).then(s=>{this.suggestions=s.data.map(t=>{const a=new g(t);return a.customValue=a.getFlat(!0),a}).filter(t=>!!t.customValue)}).catch(s=>{})},fetchInn(){return l("/geo/organizations",{query:this.searchValue}).then(e=>{this.suggestions=e.data.map(s=>{const t=new v(s);return t.additional_value=d.contains([t.inn,t.address?.getFullAddressWithoutPostalCode(!0)??null]," "),t})}).catch(e=>{})},fetchOrganization(){return l("/geo/organizations",{query:this.searchValue}).then(e=>{this.suggestions=e?.data?.map(s=>{const t=new v(s);return t.additional_value=d.contains([t.inn,t.address?.getFullAddressWithoutPostalCode(!0)??null]," "),t})??[]}).catch(e=>{})},fetchFio(){return l("/site/names",{query:this.searchValue}).then(e=>{this.suggestions=e.data.map(s=>new z(s))}).catch(e=>{})},clearSuggestions(){this.showEmptySuggestions=!1,this.suggestions=[],this.$emit("clearSuggestion")},selectSuggestion(e){this.alreadySelected=!0,this.clearSuggestions(),this.$emit("selectSuggestion",e)},clickOutside(){if(!this.force)return this.clearSuggestions();const e=this.suggestions.find(()=>!0);e&&this.selectSuggestion(e)},changeIndex(e){this.activeIndex=e},indexDown(){if(!this.countSuggestions){this.activeIndex=null;return}let e=Number.isInteger(this.activeIndex)?this.activeIndex-1:this.countSuggestions-1;e<0&&(e=null),this.changeIndex(e)},indexUp(){if(!this.countSuggestions){this.activeIndex=null;return}let e=Number.isInteger(this.activeIndex)?this.activeIndex+1:0;e>=this.countSuggestions&&(e=null),this.changeIndex(e)},selectByIndex(){if(!this.countSuggestions||this.activeIndex===null)return;const e=this.suggestions[this.activeIndex];e&&this.selectSuggestion(e)}}},K=["onKeydown"],R={key:0,class:"dadata-search-wrap"},j={class:"select-wrap shadow-lg rounded-md ring-1 ring-gray-200 p-1"},W=["onClick"],H=["textContent"],Z=["textContent"],G={key:1,class:"dadata-search-wrap"},J={class:"select-wrap shadow-lg rounded-md ring-1 ring-gray-200 p-1"},X=["textContent"];function Q(e,s,t,a,r,n){const V=E,C=T("click-outside");return k((o(),u("form",{autocomplete:"off",class:y(["search",[t.type,t.formClass]]),onKeydown:h(M(()=>{},["prevent"]),["enter"])},[B(V,L({ref:"inputDadata",modelValue:r.searchValue,"onUpdate:modelValue":s[0]||(s[0]=i=>r.searchValue=i),class:t.formInputClass,"disable-root-classes":t.disableRootClasses,loading:r.loading,rules:t.rules,vid:t.vid,name:n.privateName,"custom-messages":t.customMessages,label:t.label,hideLabel:t.hideLabel,mode:t.mode,disabled:t.disabled,"show-error-class":t.showErrorClass,"error-message":r.errorMessage,placeholder:t.placeholder,"fetch-pending":t.fetchPending,errors:t.errors},e.$attrs,{onInput:n.debounceSearch,onFocusin:n.onFocusIn,onFocusout:s[1]||(s[1]=i=>r.showEmptySuggestions=!1),onKeydown:[h(n.indexDown,["up"]),h(n.indexUp,["down"]),h(n.selectByIndex,["enter"])]}),O({before:f(()=>[_(e.$slots,"before",{},void 0,!0)]),after:f(()=>[_(e.$slots,"after",{},void 0,!0)]),_:2},[t.enableSuggestions?{name:"after-nested-input",fn:f(()=>[r.suggestions.length?(o(),u("div",R,[c("div",j,[(o(!0),u(P,null,q(r.suggestions,(i,p)=>(o(),u("div",{key:p,class:y(["select-item px-1.5 py-1.5 rounded-md",{"has-additional":!!i.additional_value,active:p===r.activeIndex}]),onClick:$=>n.selectSuggestion(i)},[c("span",{textContent:m(i.customValue||i.value)},null,8,H),i.additional_value?(o(),u("span",{key:0,class:"additional",textContent:m(i.additional_value)},null,8,Z)):S("",!0)],10,W))),128))])])):n.emptySuggestions?(o(),u("div",G,[c("div",J,[c("span",{class:"placeholder empty px-1.5 py-1.5",textContent:m(n.emptySuggestions)},null,8,X)])])):S("",!0)]),key:"0"}:void 0]),1040,["modelValue","class","disable-root-classes","loading","rules","vid","name","custom-messages","label","hideLabel","mode","disabled","show-error-class","error-message","placeholder","fetch-pending","errors","onInput","onFocusin","onKeydown"])],42,K)),[[C,n.clickOutside]])}const ne=N(U,[["render",Q],["__scopeId","data-v-0de3a5eb"]]);export{v as D,ne as _};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.