import{s as J}from"./BuPR-zpu.js";import{B as K,f as P,R as Q,q as Y,x as H,o as _,c as S,y as r,j as N,z as W,m as k,C as V,O as X,E as Z,I as oo,J as p,a as E,b as to,V as eo,K as l,v as c,L as u,Q as O,N as B,S as A}from"./CVN9mXi8.js";import{b as no,s as ao}from"./CG5Ae_0g.js";import{s as so}from"./BRrjJgJc.js";import{a as lo}from"./BLsGNFkl.js";import{s as io}from"./BeiPJ-Ey.js";import{s as ro}from"./BE4mP2Ul.js";import{S as f}from"./ZIw2O0V5.js";import"./ByD9s0OG.js";import"./O5JmsoSo.js";import"./Cnr6hwyY.js";import"./DOlpiDlz.js";import"./BzjqEU2Y.js";import"./2PnuRw05.js";import"./CeHl1rk9.js";import"./U-WKJCH1.js";import"./1kJjC6_k.js";import"./oLVS05MJ.js";var co=function(a){var o=a.dt;return`
.p-togglebutton {
    display: inline-flex;
    cursor: pointer;
    user-select: none;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    color: `.concat(o("togglebutton.color"),`;
    background: `).concat(o("togglebutton.background"),`;
    border: 1px solid `).concat(o("togglebutton.border.color"),`;
    padding: `).concat(o("togglebutton.padding"),`;
    font-size: 1rem;
    font-family: inherit;
    font-feature-settings: inherit;
    transition: background `).concat(o("togglebutton.transition.duration"),", color ").concat(o("togglebutton.transition.duration"),", border-color ").concat(o("togglebutton.transition.duration"),`,
        outline-color `).concat(o("togglebutton.transition.duration"),", box-shadow ").concat(o("togglebutton.transition.duration"),`;
    border-radius: `).concat(o("togglebutton.border.radius"),`;
    outline-color: transparent;
    font-weight: `).concat(o("togglebutton.font.weight"),`;
}

.p-togglebutton-content {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: `).concat(o("togglebutton.gap"),`;
}

.p-togglebutton-label,
.p-togglebutton-icon {
    position: relative;
    transition: none;
}

.p-togglebutton::before {
    content: "";
    background: transparent;
    transition: background `).concat(o("togglebutton.transition.duration"),", color ").concat(o("togglebutton.transition.duration"),", border-color ").concat(o("togglebutton.transition.duration"),`,
            outline-color `).concat(o("togglebutton.transition.duration"),", box-shadow ").concat(o("togglebutton.transition.duration"),`;
    position: absolute;
    inset-inline-start: `).concat(o("togglebutton.content.left"),`;
    inset-block-start: `).concat(o("togglebutton.content.top"),`;
    width: calc(100% - calc(2 * `).concat(o("togglebutton.content.left"),`));
    height: calc(100% - calc(2 * `).concat(o("togglebutton.content.top"),`));
    border-radius: `).concat(o("togglebutton.border.radius"),`;
}

.p-togglebutton.p-togglebutton-checked::before {
    background: `).concat(o("togglebutton.content.checked.background"),`;
    box-shadow: `).concat(o("togglebutton.content.checked.shadow"),`;
}

.p-togglebutton:not(:disabled):not(.p-togglebutton-checked):hover {
    background: `).concat(o("togglebutton.hover.background"),`;
    color: `).concat(o("togglebutton.hover.color"),`;
}

.p-togglebutton.p-togglebutton-checked {
    background: `).concat(o("togglebutton.checked.background"),`;
    border-color: `).concat(o("togglebutton.checked.border.color"),`;
    color: `).concat(o("togglebutton.checked.color"),`;
}

.p-togglebutton:focus-visible {
    box-shadow: `).concat(o("togglebutton.focus.ring.shadow"),`;
    outline: `).concat(o("togglebutton.focus.ring.width")," ").concat(o("togglebutton.focus.ring.style")," ").concat(o("togglebutton.focus.ring.color"),`;
    outline-offset: `).concat(o("togglebutton.focus.ring.offset"),`;
}

.p-togglebutton.p-invalid {
    border-color: `).concat(o("togglebutton.invalid.border.color"),`;
}

.p-togglebutton:disabled {
    opacity: 1;
    cursor: default;
    background: `).concat(o("togglebutton.disabled.background"),`;
    border-color: `).concat(o("togglebutton.disabled.border.color"),`;
    color: `).concat(o("togglebutton.disabled.color"),`;
}

.p-togglebutton-icon {
    color: `).concat(o("togglebutton.icon.color"),`;
}

.p-togglebutton:not(:disabled):not(.p-togglebutton-checked):hover .p-togglebutton-icon {
    color: `).concat(o("togglebutton.icon.hover.color"),`;
}

.p-togglebutton.p-togglebutton-checked .p-togglebutton-icon {
    color: `).concat(o("togglebutton.icon.checked.color"),`;
}

.p-togglebutton:disabled .p-togglebutton-icon {
    color: `).concat(o("togglebutton.icon.disabled.color"),`;
}

.p-togglebutton-sm {
    padding: `).concat(o("togglebutton.sm.padding"),`;
    font-size: `).concat(o("togglebutton.sm.font.size"),`;
}

.p-togglebutton-lg {
    padding: `).concat(o("togglebutton.lg.padding"),`;
    font-size: `).concat(o("togglebutton.lg.font.size"),`;
}
`)},uo={root:function(a){var o=a.instance,s=a.props;return["p-togglebutton p-component",{"p-togglebutton-checked":o.active,"p-invalid":o.$invalid,"p-togglebutton-sm p-inputfield-sm":s.size==="small","p-togglebutton-lg p-inputfield-lg":s.size==="large"}]},content:"p-togglebutton-content",icon:"p-togglebutton-icon",label:"p-togglebutton-label"},go=K.extend({name:"togglebutton",theme:co,classes:uo}),po={name:"BaseToggleButton",extends:no,props:{onIcon:String,offIcon:String,onLabel:{type:String,default:"Yes"},offLabel:{type:String,default:"No"},iconPos:{type:String,default:"left"},readonly:{type:Boolean,default:!1},tabindex:{type:Number,default:null},ariaLabelledby:{type:String,default:null},ariaLabel:{type:String,default:null},size:{type:String,default:null}},style:go,provide:function(){return{$pcToggleButton:this,$parentInstance:this}}},G={name:"ToggleButton",extends:po,inheritAttrs:!1,emits:["change"],methods:{getPTOptions:function(a){var o=a==="root"?this.ptmi:this.ptm;return o(a,{context:{active:this.active,disabled:this.disabled}})},onChange:function(a){!this.disabled&&!this.readonly&&(this.writeValue(!this.d_value,a),this.$emit("change",a))},onBlur:function(a){var o,s;(o=(s=this.formField).onBlur)===null||o===void 0||o.call(s,a)}},computed:{active:function(){return this.d_value===!0},hasLabel:function(){return P(this.onLabel)&&P(this.offLabel)},label:function(){return this.hasLabel?this.d_value?this.onLabel:this.offLabel:" "}},directives:{ripple:Q}},bo=["tabindex","disabled","aria-pressed","aria-labelledby","data-p-checked","data-p-disabled"];function mo(n,a,o,s,b,i){var d=Y("ripple");return H((_(),S("button",k({type:"button",class:n.cx("root"),tabindex:n.tabindex,disabled:n.disabled,"aria-pressed":n.d_value,onClick:a[0]||(a[0]=function(){return i.onChange&&i.onChange.apply(i,arguments)}),onBlur:a[1]||(a[1]=function(){return i.onBlur&&i.onBlur.apply(i,arguments)})},i.getPTOptions("root"),{"aria-labelledby":n.ariaLabelledby,"data-p-checked":i.active,"data-p-disabled":n.disabled}),[r("span",k({class:n.cx("content")},i.getPTOptions("content")),[N(n.$slots,"default",{},function(){return[N(n.$slots,"icon",{value:n.d_value,class:W(n.cx("icon"))},function(){return[n.onIcon||n.offIcon?(_(),S("span",k({key:0,class:[n.cx("icon"),n.d_value?n.onIcon:n.offIcon]},i.getPTOptions("icon")),null,16)):V("",!0)]}),r("span",k({class:n.cx("label")},i.getPTOptions("label")),X(i.label),17)]})],16)],16,bo)),[[d]])}G.render=mo;const fo=[{name:"OBRIGACOES",nameAux:"Contrato",sigla:"OBR",label:"Obrigações",icon:"pi pi-calendar-clock",file:"/obrigacao",grupo:"DOCTO"}],vo={class:"base-grid"},ho={class:"col-span-6"},yo={class:"col-span-6"},ko={class:"base-grid"},Bo={class:"col-span-6"},_o={class:"col-span-6"},So={class:"base-grid"},xo={class:"col-span-12"},Co={class:"flex justify-between"},wo={class:"flex"},To={key:0,class:"flex"},Jo=Z({__name:"[id]",setup(n){const a=oo(),o=fo.filter(e=>e.grupo==="DOCTO"),s=p({}),b=p([]),i=p([]),d=p(),x=p(!1),L=E(()=>i.value.filter(e=>e.idModuloPai===void 0)),v=p([]),I=E(()=>v.value.filter(e=>{var t,m;return(t=d.value)!=null&&t.id?((m=e.modulo)==null?void 0:m.idModuloPai)===d.value.id:!1})),M=p([]);async function U(){}async function T(e){try{const t=await f.gruposAcesso.getById(e);s.value=t,b.value=t.modulos?t.modulos.split(";").filter(m=>m):[],D(),U()}catch(t){console.error("Erro ao buscar grupo de acesso:",t),a.add({severity:"error",summary:"Erro ao buscar grupo de acesso",detail:t})}}function z(){s.value.modulos=b.value.join(";"),f.gruposAcesso.save(s.value).then(e=>{a.add({severity:"success",summary:"Sucesso",detail:"Grupo salvo com sucesso"}),s.value.id===void 0?A("/seguranca/gruposAcesso/"+e.id):(j(),T(e.id))}).catch(e=>{console.error("Erro ao salvar grupo de acesso:",e),a.add({severity:"error",summary:"Erro ao salvar",detail:e})})}function $(){f.gruposAcesso.delete(s.value.id).then(()=>{a.add({severity:"success",summary:"Sucesso",detail:"Grupo excluído com sucesso"}),A("/seguranca/gruposAcesso")}).catch(e=>{console.error("Erro ao excluir grupo de acesso:",e),a.add({severity:"error",summary:"Erro ao excluir",detail:e})})}async function D(){x.value=!0;try{const e=await f.usuarios.findPermissoes();i.value=e}catch(e){console.error("Erro ao buscar permissões:",e),a.add({severity:"error",summary:"Erro ao buscar",detail:e})}finally{x.value=!1}}function R(e){v.value=v.value.map(t=>(t.id===e.id&&(t.id.idGrupoUsuario=t.id.idGrupoUsuario===void 0?s.value.id:void 0),t))}function j(){f.usuarios.savePermissoesByGrupo(s.value.id,d.value.modulo,v.value).then(()=>{a.add({severity:"success",summary:"Sucesso",detail:"Permissões salvas com sucesso"})}).catch(e=>{console.error("Erro ao salvar permissões:",e),a.add({severity:"error",summary:"Erro ao salvar",detail:e})})}return to(()=>{const e=Number(eo().params.id);isNaN(e)||T(e)}),(e,t)=>{const m=ao,F=ro,h=io,y=lo,C=so,q=G,w=J;return _(),S("div",null,[l(h,{class:"m-4"},{content:c(()=>[r("div",vo,[r("div",ho,[t[3]||(t[3]=r("label",{for:"descricao"},"Descrição:",-1)),l(m,{id:"descricao",modelValue:u(s).descricao,"onUpdate:modelValue":t[0]||(t[0]=g=>u(s).descricao=g),fluid:""},null,8,["modelValue"])]),r("div",yo,[t[4]||(t[4]=r("label",{for:"modulos"},"Modulos:",-1)),l(F,{id:"modulos",modelValue:u(b),"onUpdate:modelValue":t[1]||(t[1]=g=>O(b)?b.value=g:null),placeholder:"Selecione...",options:u(o),"option-label":"nameAux","option-value":"sigla",filter:"",fluid:""},null,8,["modelValue","options"])])])]),_:1}),l(h,{class:"m-4"},{content:c(()=>[r("div",ko,[r("div",Bo,[l(C,{selection:u(d),"onUpdate:selection":t[2]||(t[2]=g=>O(d)?d.value=g:null),value:u(L),"selection-mode":"single",loading:u(x),scrollable:"","scroll-height":"800px"},{empty:c(()=>t[5]||(t[5]=[B("Não há dados disponíveis")])),default:c(()=>[l(y,{field:"descricao",header:"Módulo"})]),_:1},8,["selection","value","loading"])]),r("div",_o,[l(C,{value:u(I),scrollable:"","scroll-height":"800px"},{empty:c(()=>t[6]||(t[6]=[B("Não há dados disponíveis")])),default:c(()=>[l(y,{field:"modulo.descricao",header:"Permissão"}),l(y,{header:"Acesso"},{body:c(({data:g})=>[l(q,{"model-value":g.id.idGrupoUsuario!==void 0,"on-label":"Sim","off-label":"Não","on-icon":"pi pi-check","off-icon":"pi pi-times","onUpdate:modelValue":()=>R(g)},null,8,["model-value","onUpdate:modelValue"])]),_:1})]),_:1},8,["value"])])])]),_:1}),l(h,{class:"m-4"},{title:c(()=>t[7]||(t[7]=[B("Usuarios Associados")])),content:c(()=>[r("div",So,[r("div",xo,[l(C,{value:u(M),paginator:"",rows:10},{empty:c(()=>t[8]||(t[8]=[B("Não há usuários associados.")])),default:c(()=>[l(y,{field:"nome",header:"Nome do Usuário"})]),_:1},8,["value"])])])]),_:1}),l(h,{class:"m-4"},{content:c(()=>[r("div",Co,[r("div",wo,[l(w,{label:"Cancelar",icon:"pi pi-times",class:"mr-4",severity:"secondary",as:"router-link",to:"/seguranca/gruposAcesso"}),l(w,{label:"Salvar",icon:"pi pi-check",onClick:z})]),u(s).id!==void 0?(_(),S("div",To,[l(w,{label:"Excluir",icon:"pi pi-trash",severity:"danger",onClick:$})])):V("",!0)])]),_:1})])}}});export{Jo as default};
