import{_ as I}from"./CbtPaznW.js";import L from"./Dc_YXEFz.js";import{_ as k,T as U,a as x}from"./DmwTwIPt.js";import N from"./BBDFeM-T.js";import{d as P,L as T,u as B,k as c,c as $,v as j,b as O,w as m,o as V,f as h,E as z,W as H,g as u,l as W,e as w,t as A,G as S,K as D}from"./JQJBiNWj.js";const G=P({__name:"Paginated",props:T({paginatedDataKey:{},asyncFn:{},placeholder:{default:"Selecione..."},filter:{type:Boolean,default:!0},size:{},name:{},watch:{},showClear:{type:Boolean},disabled:{type:Boolean},showToggleAll:{type:Boolean},optionValue:{type:[String,Function],default:"value"},optionLabel:{type:[String,Function],default:"label"},immediate:{type:Boolean,default:!0},clearOnWatch:{type:Boolean},defaultOption:{},autoSelectFirst:{type:Boolean},classInput:{},modelValue:{},defaultValue:{},options:{},optionDisabled:{},optionGroupLabel:{},optionGroupChildren:{},scrollHeight:{},filterPlaceholder:{},filterLocale:{},filterMatchMode:{},filterFields:{},editable:{type:Boolean},invalid:{type:Boolean},variant:{},dataKey:{},fluid:{type:Boolean},inputId:{},inputStyle:{},inputClass:{},labelId:{},labelStyle:{},labelClass:{},panelStyle:{},panelClass:{},overlayStyle:{},overlayClass:{},appendTo:{},loading:{type:Boolean},clearIcon:{},dropdownIcon:{},filterIcon:{},loadingIcon:{},resetFilterOnHide:{type:Boolean},resetFilterOnClear:{type:Boolean},virtualScrollerOptions:{},autoOptionFocus:{type:Boolean},autoFilterFocus:{type:Boolean},selectOnFocus:{type:Boolean},focusOnHover:{type:Boolean},highlightOnSelect:{type:Boolean},checkmark:{type:Boolean},filterMessage:{},selectionMessage:{},emptySelectionMessage:{},emptyFilterMessage:{},emptyMessage:{},tabindex:{},ariaLabel:{},ariaLabelledby:{},formControl:{},dt:{},pt:{},ptOptions:{},unstyled:{type:Boolean}},{modelValue:{},modelModifiers:{},object:{},objectModifiers:{}}),emits:["update:modelValue","update:object"],setup(v){const e=v,{items:s,overlayId:F,search:y,searchLoading:M,listLoading:g,compareValues:d,getNestedValue:i,getNestedLabel:f}=k(e,!1),t=B(v,"modelValue"),n=B(v,"object");c(()=>e.watch,()=>{e.clearOnWatch&&(t.value=void 0,n.value=void 0)});const C=a=>{const l=t.value||a;if(e.defaultOption&&e.defaultOption.value===l)return e.defaultOption.label;if(!l||Array.isArray(n.value))return e.placeholder;if(n.value&&d(i(n.value),l))return f(n.value);const r=s.value.find(p=>d(i(p),l));return r?f(r):"Um item selecionado"};c(t,a=>{if(!a){n.value=void 0;return}if(!n.value){n.value=s.value.find(l=>d(i(l),a));return}d(i(n.value),a)||(n.value=s.value.find(l=>d(i(l),a)))}),c(n,a=>{!a||!f(a)||!i(a)||t.value&&d(i(a),t.value)||(t.value=i(a))}),c(s,a=>{var l;e.autoSelectFirst&&s.value.length>0&&(t.value=i(s.value[0])),!(!t.value||!((l=s.value)!=null&&l.length))&&(!n.value||!d(i(n.value),t.value))&&(n.value=a.find(r=>d(i(r),t.value)))},{immediate:!0});const b=$(()=>{var l,r;return!((l=e.defaultOption)!=null&&l.label)||!((r=e.defaultOption)!=null&&r.value)?s.value:[{...e.defaultOption,defaultOption:!0},...s.value.filter(p=>p[e.optionValue]!==e.defaultOption.value)]});return c(()=>e.defaultOption,a=>{a&&(t.value=a.value)},{once:!0,immediate:!0}),j(()=>{t.value||!n.value||(t.value=n.value[e.optionValue])}),(a,l)=>{const r=I,p=L;return V(),O(p,{name:a.name},{default:m(_=>[h(u(N),{modelValue:t.value,"onUpdate:modelValue":l[1]||(l[1]=o=>t.value=o),options:u(b),"option-label":o=>o.defaultOption?o.label:u(f)(o),"option-value":o=>o.defaultOption?o.value:u(i)(o),loading:u(g),pt:{overlay:{id:u(F)}},"overlay-class":`${u(g)&&"page-loading"} ${u(M)&&a.$style.hide_container}`,"virtual-scroller-options":u(b).length>100?{itemSize:38}:void 0,name:e.name,disabled:e.disabled,"show-clear":e.showClear,class:S(e.classInput)},H({value:m(({value:o})=>[w("span",{class:S({"p-placeholder":!o||e.defaultOption&&o!==e.defaultOption.value})},A(C(o)),3)]),_:2},[e.filter?{name:"header",fn:m(()=>[h(U,{modelValue:u(y),"onUpdate:modelValue":l[0]||(l[0]=o=>W(y)?y.value=o:null)},null,8,["modelValue"])]),key:"0"}:void 0,u(g)?{name:"footer",fn:m(()=>[h(x)]),key:"1"}:void 0]),1032,["modelValue","options","option-label","option-value","loading","pt","overlay-class","virtual-scroller-options","name","disabled","show-clear","class"]),_.props?(V(),O(r,{key:0,modelValue:t.value,"onUpdate:modelValue":l[2]||(l[2]=o=>t.value=o),field:_},null,8,["modelValue","field"])):z("",!0)]),_:1},8,["name"])}}}),K="_hide_container_c52zj_2",E={hide_container:K},R={$style:E},Z=Object.assign(D(G,[["__cssModules",R]]),{__name:"UiSelectServerPaginated"});export{Z as _};
