1import{c as Ce,r as we,a as Fe,j as t,b as Ae}from"./app-CTaY8UJf.js";import{B as te}from"./button-DXCKLHtj.js";import{C as pe,a as xe,b as ve,c as ye}from"./card-UxP9oPxk.js";import{I as ke}from"./input-7aHhCeCr.js";import{L as le}from"./label-CxCrcTSv.js";import De from"./file-text-jraIksbC.js";import be from"./trash-2-QtamTJOn.js";import Ee from"./upload-C5_Iw0PV.js";import"./app-CNmQMdEi.js";import"./index-fQ3brVpV.js";import"./createLucideIcon-CmjF8lT1.js";const Re=[{value:1,label:"Janeiro"},{value:2,label:"Fevereiro"},{value:3,label:"Março"},{value:4,label:"Abril"},{value:5,label:"Maio"},{value:6,label:"Junho"},{value:7,label:"Julho"},{value:8,label:"Agosto"},{value:9,label:"Setembro"},{value:10,label:"Outubro"},{value:11,label:"Novembro"},{value:12,label:"Dezembro"}],_e=new Date().getFullYear(),Me=Array.from({length:40},(i,e)=>_e-e);function We(i){const e=Ce.c(103),{item:a,type_documents:se,isEdit:he}=i,o=he===void 0?!1:he,ae=we.useRef(null),re=a?.name??"",ie=a?.year?String(a.year):String(_e);let c;e[0]!==a?(c=a?.month?String(a.month):String(new Date().getMonth()+1),e[0]=a,e[1]=c):c=e[1];const ne=a?.type_document_id?String(a.type_document_id):"";let z;e[2]===Symbol.for("react.memo_cache_sentinel")?(z=[],e[2]=z):z=e[2];const oe=o?"put":"post";let $;e[3]!==re||e[4]!==ie||e[5]!==c||e[6]!==ne||e[7]!==oe?($={name:re,year:ie,month:c,type_document_id:ne,arquivos:z,_method:oe},e[3]=re,e[4]=ie,e[5]=c,e[6]=ne,e[7]=oe,e[8]=$):$=e[8];const{data:l,setData:r,post:me,processing:J,errors:n}=Fe($);let Y;e[9]!==l.arquivos||e[10]!==r?(Y=s=>{const m=Array.from(s.target.files??[]);r("arquivos",[...l.arquivos,...m]),ae.current&&(ae.current.value="")},e[9]=l.arquivos,e[10]=r,e[11]=Y):Y=e[11];const ce=Y;let B;e[12]!==l.arquivos||e[13]!==r?(B=s=>r("arquivos",l.arquivos.filter((m,qe)=>qe!==s)),e[12]=l.arquivos,e[13]=r,e[14]=B):B=e[14];const de=B;let H;e[15]!==o||e[16]!==a||e[17]!==me?(H=s=>{s.preventDefault();const m=o&&a?.id?`/admin/documents/${a.id}`:"/admin/documents";me(m,{forceFormData:!0})},e[15]=o,e[16]=a,e[17]=me,e[18]=H):H=e[18];const ue=H,je=Ye;let I;e[19]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx(pe,{children:t.jsx(xe,{children:"Dados do Documento"})}),e[19]=I):I=e[19];let L;e[20]===Symbol.for("react.memo_cache_sentinel")?(L=t.jsx(le,{htmlFor:"name",children:"Nome *"}),e[20]=L):L=e[20];let d;e[21]!==r?(d=s=>r("name",s.target.value),e[21]=r,e[22]=d):d=e[22];let u;e[23]!==l.name||e[24]!==d?(u=t.jsx(ke,{id:"name",value:l.name,onChange:d,placeholder:"Nome do documento..."}),e[23]=l.name,e[24]=d,e[25]=u):u=e[25];let f;e[26]!==n.name?(f=n.name&&t.jsx("p",{className:"text-sm text-red-600",children:n.name}),e[26]=n.name,e[27]=f):f=e[27];let h;e[28]!==u||e[29]!==f?(h=t.jsxs("div",{className:"space-y-2 xl:col-span-3",children:[L,u,f]}),e[28]=u,e[29]=f,e[30]=h):h=e[30];let O;e[31]===Symbol.for("react.memo_cache_sentinel")?(O=t.jsx(le,{htmlFor:"type_document_id",children:"Tipo de Documento"}),e[31]=O):O=e[31];const ge=l.type_document_id;let p;e[32]!==r?(p=s=>r("type_document_id",s.target.value),e[32]=r,e[33]=p):p=e[33];let U;e[34]===Symbol.for("react.memo_cache_sentinel")?(U=t.jsx("option",{value:"",children:"Selecione..."}),e[34]=U):U=e[34];let x;e[35]!==se?(x=se.map(Je),e[35]=se,e[36]=x):x=e[36];let v;e[37]!==l.type_document_id||e[38]!==p||e[39]!==x?(v=t.jsxs("select",{id:"type_document_id",value:ge,onChange:p,className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",children:[U,x]}),e[37]=l.type_document_id,e[38]=p,e[39]=x,e[40]=v):v=e[40];let y;e[41]!==n.type_document_id?(y=n.type_document_id&&t.jsx("p",{className:"text-sm text-red-600",children:n.type_document_id}),e[41]=n.type_document_id,e[42]=y):y=e[42];let b;e[43]!==v||e[44]!==y?(b=t.jsxs("div",{className:"space-y-2",children:[O,v,y]}),e[43]=v,e[44]=y,e[45]=b):b=e[45];let V;e[46]===Symbol.for("react.memo_cache_sentinel")?(V=t.jsx(le,{htmlFor:"month",children:"Mês *"}),e[46]=V):V=e[46];const Ne=l.month;let _;e[47]!==r?(_=s=>r("month",s.target.value),e[47]=r,e[48]=_):_=e[48];let G;e[49]===Symbol.for("react.memo_cache_sentinel")?(G=Re.map($e),e[49]=G):G=e[49];let j;e[50]!==l.month||e[51]!==_?(j=t.jsx("select",{id:"month",value:Ne,onChange:_,className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",children:G}),e[50]=l.month,e[51]=_,e[52]=j):j=e[52];let g;e[53]!==n.month?(g=n.month&&t.jsx("p",{className:"text-sm text-red-600",children:n.month}),e[53]=n.month,e[54]=g):g=e[54];let N;e[55]!==j||e[56]!==g?(N=t.jsxs("div",{className:"space-y-2",children:[V,j,g]}),e[55]=j,e[56]=g,e[57]=N):N=e[57];let K;e[58]===Symbol.for("react.memo_cache_sentinel")?(K=t.jsx(le,{htmlFor:"year",children:"Ano *"}),e[58]=K):K=e[58];const Se=l.year;let S;e[59]!==r?(S=s=>r("year",s.target.value),e[59]=r,e[60]=S):S=e[60];let P;e[61]===Symbol.for("react.memo_cache_sentinel")?(P=Me.map(ze),e[61]=P):P=e[61];let q;e[62]!==l.year||e[63]!==S?(q=t.jsx("select",{id:"year",value:Se,onChange:S,className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",children:P}),e[62]=l.year,e[63]=S,e[64]=q):q=e[64];let C;e[65]!==n.year?(C=n.year&&t.jsx("p",{className:"text-sm text-red-600",children:n.year}),e[65]=n.year,e[66]=C):C=e[66];let w;e[67]!==q||e[68]!==C?(w=t.jsxs("div",{className:"space-y-2",children:[K,q,C]}),e[67]=q,e[68]=C,e[69]=w):w=e[69];let F;e[70]!==h||e[71]!==b||e[72]!==N||e[73]!==w?(F=t.jsxs(ve,{children:[I,t.jsxs(ye,{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:[h,b,N,w]})]}),e[70]=h,e[71]=b,e[72]=N,e[73]=w,e[74]=F):F=e[74];let Q;
1e[75]===Symbol.for("react.memo_cache_sentinel")?(Q=t.jsx(pe,{children:t.jsx(xe,{children:"Arquivos Vinculados"})}),e[75]=Q):Q=e[75];let A;e[76]!==o||e[77]!==a?(A=o&&a?.attachments&&a.attachments.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-sm font-medium text-gray-700",children:"Arquivos já vinculados"}),a.attachments.map(s=>t.jsxs("div",{className:"flex items-center justify-between rounded-md border px-3 py-2",children:[t.jsxs("a",{href:s.path,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-2 text-sm text-blue-600 hover:underline",children:[t.jsx(De,{className:"h-4 w-4"}),s.original_name]}),t.jsx(te,{type:"button",variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",onClick:()=>je(a.id,s.id),children:t.jsx(be,{className:"h-4 w-4"})})]},s.id))]}),e[76]=o,e[77]=a,e[78]=A):A=e[78];let W;e[79]===Symbol.for("react.memo_cache_sentinel")?(W=t.jsx("p",{className:"mb-2 text-sm font-medium text-gray-700",children:"Adicionar arquivos"}),e[79]=W):W=e[79];let X;e[80]===Symbol.for("react.memo_cache_sentinel")?(X=t.jsx(Ee,{className:"h-4 w-4 shrink-0 text-gray-500"}),e[80]=X):X=e[80];let k;e[81]!==ce?(k=t.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-dashed p-3",children:[X,t.jsx("input",{ref:ae,type:"file",multiple:!0,className:"block w-full text-sm file:mr-3 file:rounded-md file:border-0 file:bg-primary file:px-3 file:py-2 file:text-primary-foreground",onChange:ce})]}),e[81]=ce,e[82]=k):k=e[82];let D;e[83]!==l.arquivos||e[84]!==de?(D=l.arquivos.length>0&&t.jsx("div",{className:"mt-2 space-y-1",children:l.arquivos.map((s,m)=>t.jsxs("div",{className:"flex items-center justify-between rounded-md bg-muted px-3 py-2 text-sm",children:[t.jsx("span",{className:"truncate",children:s.name}),t.jsx(te,{type:"button",variant:"ghost",size:"sm",onClick:()=>de(m),children:t.jsx(be,{className:"h-4 w-4"})})]},m))}),e[83]=l.arquivos,e[84]=de,e[85]=D):D=e[85];let E;e[86]!==k||e[87]!==D?(E=t.jsxs("div",{children:[W,k,D]}),e[86]=k,e[87]=D,e[88]=E):E=e[88];let R;e[89]!==A||e[90]!==E?(R=t.jsxs(ve,{children:[Q,t.jsxs(ye,{className:"space-y-4",children:[A,E]})]}),e[89]=A,e[90]=E,e[91]=R):R=e[91];const fe=J?"Salvando...":o?"Atualizar":"Cadastrar";let M;e[92]!==J||e[93]!==fe?(M=t.jsx(te,{type:"submit",disabled:J,children:fe}),e[92]=J,e[93]=fe,e[94]=M):M=e[94];let Z;e[95]===Symbol.for("react.memo_cache_sentinel")?(Z=t.jsx(te,{type:"button",variant:"outline",onClick:Te,children:"Cancelar"}),e[95]=Z):Z=e[95];let T;e[96]!==M?(T=t.jsxs("div",{className:"flex gap-3",children:[M,Z]}),e[96]=M,e[97]=T):T=e[97];let ee;return e[98]!==ue||e[99]!==F||e[100]!==R||e[101]!==T?(ee=t.jsxs("form",{onSubmit:ue,className:"space-y-6",children:[F,R,T]}),e[98]=ue,e[99]=F,e[100]=R,e[101]=T,e[102]=ee):ee=e[102],ee}function Te(){return window.history.back()}function ze(i){return t.jsx("option",{value:i,children:i},i)}function $e(i){return t.jsx("option",{value:i.value,children:i.label},i.value)}function Je(i){return t.jsx("option",{value:i.id,children:i.name},i.id)}function Ye(i,e){confirm("Remover este arquivo?")&&Ae.delete(`/admin/documents/${i}/attachments/${e}`,{preserveScroll:!0})}export{We as default};
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.