import{a as T,_ as x,T as E,b as K}from"./BEnX_9Ze.js";import{_ as N}from"./B-d7gz-d.js";import{_ as L}from"./Brk5FU9k.js";import{d as M,N as P,u as D,c as O,k as H,a as R,o as c,F as j,f as t,w as b,a2 as J,b as h,E as y,g as s,J as Y,l as r,e as S}from"./dVzHJMF1.js";import $ from"./BSLzRQpY.js";import{S as q}from"./BbimXw5J.js";const z={class:"flex flex-col h-full gap-5 w-full"},G={class:"flex flex-wrap gap-2"},Q=M({__name:"index",props:P({id:{default:()=>{}},name:{default:()=>{}},dialogHeader:{default:"Selecionar setor"},showClear:{type:Boolean,default:!1},closeOnSelect:{type:Boolean,default:!0},showInactives:{type:Boolean,default:()=>{}},onlyVisibleInPleitos:{type:Boolean,default:()=>{}},disabled:{type:Boolean,default:!1},valueSigla:{type:Boolean,default:!1}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(i){const{modalVisible:o,areas:f,areasNested:V,statusFetchAreas:k,searchAreas:m,expandedKeys:v,searchInativos:d}=T({showInactives:i.showInactives,onlyVisibleInPleitos:i.onlyVisibleInPleitos}),n=D(i,"modelValue"),_=O(()=>{var e;if(n.value){if((e=f.value)!=null&&e.length){const l=f.value.find(u=>(i.valueSigla?u.sigla:u.id)===n.value);if(l)return U(l)}return"Um setor selecionado"}});function U(e){return e.sigla+" - "+e.descricao}function p(){n.value=void 0,o.value=!1}function B(e){["Space","Enter"].includes(e.code)&&(e.preventDefault(),o.value=!0)}function w(){o.value=!0}return H(n,()=>{o.value&&i.closeOnSelect&&(o.value=!1)}),(e,l)=>{const u=x,C=N,I=$,g=L,A=Y;return c(),R(j,null,[t(I,{name:e.name},{default:b(a=>[J(e.$slots,"input",{openModal:w,field:a},()=>[t(u,{id:e.id,"model-value":s(_),invalid:a.invalid,"show-clear":e.showClear,disabled:e.disabled,onClick:w,onClear:p,onKeydown:B},null,8,["id","model-value","invalid","show-clear","disabled"]),a.props?(c(),h(C,{key:0,modelValue:n.value,"onUpdate:modelValue":l[0]||(l[0]=F=>n.value=F),field:a},null,8,["modelValue","field"])):y("",!0)])]),_:3},8,["name"]),t(A,{visible:s(o),"onUpdate:visible":l[6]||(l[6]=a=>r(o)?o.value=a:null),modal:"",header:e.dialogHeader,class:"w-full h-full full-screen-mobile lg:overflow-hidden","content-class":"overflow-hidden grow",closable:!1},{default:b(()=>[S("div",z,[t(E,{search:s(m),"onUpdate:search":l[1]||(l[1]=a=>r(m)?m.value=a:null),inativos:s(d),"onUpdate:inativos":l[2]||(l[2]=a=>r(d)?d.value=a:null),"show-inactives":e.showInactives},null,8,["search","inativos","show-inactives"]),t(K,{modelValue:n.value,"onUpdate:modelValue":l[3]||(l[3]=a=>n.value=a),"expanded-keys":s(v),"onUpdate:expandedKeys":l[4]||(l[4]=a=>r(v)?v.value=a:null),"nested-areas":s(V),status:s(k),"show-inactives":e.showInactives!==!1&&s(d)!==s(q).Ativo,"value-sigla":e.valueSigla},null,8,["modelValue","expanded-keys","nested-areas","status","show-inactives","value-sigla"]),S("div",G,[e.showClear?(c(),h(g,{key:0,mode:"clean",onClick:p})):y("",!0),t(g,{mode:"back",class:"ml-auto",onClick:l[5]||(l[5]=a=>o.value=!1)})])])]),_:1},8,["visible","header"])],64)}}}),oe=Object.assign(Q,{__name:"UiSelectSetorAgencia"});export{oe as _};
