1import{r as n,a as ve,j as e,B as W,ba as Ne,F as Pe,Q as ke,j6 as Ae,n as z,p as Ie,bm as xe,q as Re,o as Fe,x as be,c as X,a1 as Z,ac as G,A as ue,a2 as ye,t as K,aE as le,k as me,ag as Q,he as Me,v as Be,an as Te,bp as pe,f as oe,g as he,bn as Ee,bq as Le}from"./index-CzhT7_9q.js";import{D as Oe}from"./DetailPageSkeleton-Dpij_BOU.js";import{D as qe,B as $e,a as He,E as Ue}from"./EditDocument-iuMaV6EM.js";import{E as We,S as Ge,J as Ve}from"./SearchSubstitutesModal-_NPHbZzz.js";import{C as ze,a as Ye,b as Je}from"./expedientPermissions-CeghOKN8.js";import{u as ee}from"./procuraDelivery.store-DTMJekb8.js";import{E as Ke}from"./EditDocumentForm-D9Lkhsci.js";import{u as de}from"./settings.store-DEDlSmSw.js";import{b as Ze}from"./formUtils-BbMZ_3iG.js";import{t as Qe,P as Xe,F as et,f as ge,b as tt,i as _e,c as at,d as ne}from"./procuraDeliveryUtils-CxE2PmCs.js";import{a as ot,F as nt,E as st,D as se,u as it}from"./DocumentSectionTitle-LypG4cds.js";import{r as ct}from"./index-C844jcby.js";import{C as Se}from"./Collapse-DntPZvNO.js";import{F as lt}from"./ChevronUpIcon-CBogA5Mv.js";import{F as dt}from"./ChevronDownIcon-BsqvH_aa.js";import{P as rt,p as ie,a as ut}from"./fileDownload.config-xgB3DGrf.js";import{F as mt}from"./TrashIcon-B1J-x06h.js";import{F as je}from"./ArrowDownTrayIcon-ZKbhJqRt.js";import{u as pt}from"./useRefAvoidInfiniteLoop-FZyWWqoR.js";import{v as ht}from"./objectIdValidation-BANEKDaM.js";import{F as gt}from"./Cog6ToothIcon-CLi_cBb9.js";import"./Skeleton-CuJx3eeF.js";import"./SearchByCreator-DVgdkRPr.js";import"./badges-B3BE14gC.js";import"./PencilSquareIcon-CcOdTldO.js";import"./ReceiptPercentIcon-AYDLLE_g.js";import"./CurrencyDollarIcon-BRLVarzh.js";import"./CalendarIcon-DWmbY3h5.js";import"./CloudIcon-B_IlZl1A.js";import"./ClipboardDocumentIcon-CpDSim0C.js";import"./expedient.service-DfaNCw5w.js";import"./MagnifyingGlassIcon-B41WS-Td.js";import"./FormActionBar-CeyFJg3l.js";import"./ArrowLeftIcon-Dvpta82X.js";import"./CheckIcon-CwysSnBO.js";import"./proxy-zK1Yfu3m.js";import"./ExclamationCircleIcon-CngMAC3a.js";import"./ArrowsRightLeftIcon-B9TdtXDF.js";import"./Table-B-AkJ13u.js";import"./Table.module-CuPvi-vO.js";import"./formatPrices-DQK2IAkM.js";import"./StarIcon-hQ_9E5jX.js";import"./PlusIcon-C3gDGaox.js";import"./UserGroupIcon-B0uNaary.js";import"./ChartBarIcon-DruPapYo.js";import"./AvailableSubstitutesSelect-C2lA29n8.js";import"./SearchBySubstitute-CaF0f2sW.js";import"./procuraDelivery.actions-mqrDbgfv.js";import"./tslib.es6-DTLQ5SHO.js";import"./onBoard.actions-md5llFM4.js";import"./index-y0f1fdg1.js";import"./ArrowUpTrayIcon-DHcrPcAD.js";function _t({title:t,titleId:o,...a},s){return n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:s,"aria-labelledby":o},a),t?n.createElement("title",{id:o},t):null,n.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5"}))}const ft=n.forwardRef(_t);function Ct({title:t,titleId:o,...a},s){return n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:s,"aria-labelledby":o},a),t?n.createElement("title",{id:o},t):null,n.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m3.75 9v6m3-3H9m1.5-12H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z"}))}const kt=n.forwardRef(Ct),xt="¿Seguro que quieres eliminar este encargo de Procura Delivery? Esta acción no se puede deshacer.",bt=()=>{const t=ve(),{procuraDelivery:o,deleteProcuraDelivery:a}=ee(),[s,i]=n.useState(!1),p=o?._id;if(!p)return null;const d=async()=>{const h=await a(p);ke(h)&&t("/panel/procura-delivery")};return e.jsxs(e.Fragment,{children:[e.jsx(W,{size:"md",outline:!0,color:"danger",fullWidth:!0,onClick:()=>i(!0),icon:e.jsx(Ne,{icon:Pe,size:22}),children:"Eliminar encargo"}),e.jsx(ze,{isOpen:s,onClose:()=>i(!1),message:xt,onConfirm:d})]})};function yt(t){const o={};if(t.status!==void 0&&(o.status=t.status),t.judicial_party!==void 0&&(o.judicial_party=t.judicial_party.trim()||void 0),t.pickup_frequency!==void 0){const a=t.pickup_frequency.trim();o.pickup_frequency=a||void 0}if(t.start_date!==void 0){const a=Qe(t.start_date);a&&(o.start_date=a)}if(t.estimated_notifications_per_pickup!==void 0){const a=Number(t.estimated_notifications_per_pickup);Number.isFinite(a)&&(o.estimated_notifications_per_pickup=a)}if(t.client_internal_reference!==void 0&&(o.client_internal_reference=t.client_internal_reference.trim()||void 0),t.notes!==void 0&&(o.notes=t.notes.trim()||void 0),t.pickup_location!==void 0){const a=t.pickup_location;o.pickup_location=a?.value!=null?{id:String(a.value)}:void 0}return o}function St(t,o){const a=n.useMemo(()=>Ae.map(i=>({value:String(i.id),label:i.name})),[]),s=n.useMemo(()=>[{name:"status",type:"select",visible:!0,editable:t.isAdmin,required:!0,formGroup:{label:"Estado",width:"half"},props:{placeholder:"Seleccione el estado",options:Xe},schema:z().required("Seleccione el estado")},{name:"judicial_party",type:"select",visible:!0,editable:t.isAdmin,required:!0,formGroup:{label:"Partido judicial",width:"half"},props:{placeholder:"Seleccione el partido judicial",options:a},schema:z().required("Seleccione el partido judicial")},{name:"pickup_frequency",type:"select",visible:!0,editable:t.isAdmin,required:!0,formGroup:{label:"Frecuencia de recogidas",width:"half"},props:{placeholder:"Seleccione la frecuencia",options:et},schema:z().required("Seleccione la frecuencia de recogidas")},{name:"start_date",type:"date",visible:!0,editable:t.isAdmin,required:!0,formGroup:{label:"Fecha de inicio",width:"half"},props:{timeVisible:!1,minDate:new xe},schema:Ie().nullable().required("La fecha de inicio es obligatoria")},{name:"estimated_notifications_per_pickup",type:"number",visible:!0,editable:t.isAdmin,required:!1,formGroup:{label:"Nº notificaciones estimadas por recogida",width:"half"},props:{min:1},schema:Re().min(1,"Debe ser 1 o mayor")},{name:"client_internal_reference",type:"text",visible:!0,editable:t.isAdmin,required:!1,formGroup:{label:"Referencia interna",width:"full"},props:{placeholder:"Referencia interna del cliente"},schema:z()},{name:"notes",type:"textarea",visible:!0,editable:t.isAdmin,required:!1,formGroup:{label:"Notas adicionales",width:"full"},props:{placeholder:"Notas visibles para el pigeon"},schema:z()},{name:"pickup_location",type:"location",visible:!0,editable:t.isAdmin||o.isA
1ssignedTo(t),required:!1,formGroup:{label:"Dirección de recogida",width:"full"},props:{placeholder:"Introduce nombre o dirección del lugar..."},schema:Fe().nullable()}],[a]);return n.useMemo(()=>[{title:"Detalles del encargo",visible:!0,fields:s}],[s])}function jt(){const{id:t}=be(),{procuraDelivery:o,updateProcuraDelivery:a}=ee(),{setViewMode:s}=de(),{activeUser:i}=X(),p=St(i,o),d={status:o?.status??"draft",judicial_party:o?.judicial_party!=null?String(o.judicial_party):"",pickup_frequency:o?.pickup_frequency??"daily",start_date:o?.start_date?new Date(o.start_date):null,estimated_notifications_per_pickup:Number(o?.estimated_notifications_per_pickup)||0,client_internal_reference:o?.client_internal_reference??"",notes:o?.notes??"",pickup_location:o?.pickup_location?{value:o.pickup_location.id,label:o.pickup_location.address??o.pickup_location.id}:null};return{initialValues:d,sections:p,handleSubmit:async m=>{if(!t)return;const _=Ze(d,m);if(Object.keys(_).length===0){s();return}const f=yt(_),y=await a(t,f);ke(y)&&s()}}}const Dt=({isEditing:t})=>{const{initialValues:o,sections:a,handleSubmit:s}=jt(),{loading:i}=ee(),{setViewMode:p}=de();return e.jsx(Ke,{onBack:p,loading:i,isEditing:t,initialValues:o,onSubmit:s,sections:a})},wt="_calendarRoot_8o4c3_2",vt="_calendarWrapper_8o4c3_9",Nt="_dayContent_8o4c3_123",Pt="_dayNumber_8o4c3_132",At="_dayRingRecogida_8o4c3_139",It="_dayRingOriginal_8o4c3_153",Rt="_dayRingOuter_8o4c3_167",Ft="_selectedDateFooter_8o4c3_192",U={calendarRoot:wt,calendarWrapper:vt,dayContent:Nt,dayNumber:Pt,dayRingRecogida:At,dayRingOriginal:It,dayRingOuter:Rt,selectedDateFooter:Ft},Mt=({selectedDates:t,selectedDate:o=null,onDateSelect:a})=>{const[s,i]=n.useState(!0),[p,d]=n.useState(()=>Z()),h=o?Z(o,"YYYY-MM-DD"):null,m=n.useMemo(()=>{const g=new Map;return t.forEach(j=>{const r=j.date;g.has(r)||g.set(r,[]),g.get(r).push(j)}),g},[t]),_=n.useCallback(g=>{g&&a?.(g.toDate())},[a]),f=n.useCallback(g=>{const j=g.format("YYYY-MM-DD"),r=m.get(j)??[],c=r.some(v=>v.type==="recogida_original"),C=r.some(v=>v.type==="recogida"||v.type==="recogida_original"),S=h!==null&&g.isSame(h,"day");return e.jsxs("span",{className:U.dayContent,children:[S&&e.jsx("span",{className:U.dayRingOuter,"aria-hidden":!0}),C&&e.jsx("span",{className:c?U.dayRingOriginal:U.dayRingRecogida,"aria-hidden":!0,title:c?"Recogida con original":"Recogida"}),e.jsx("span",{className:U.dayNumber,children:g.date()})]})},[m,h]),y=n.useCallback(()=>p,[p]),w=n.useCallback(g=>{d(g)},[]),k=n.useCallback(g=>{d(g)},[]);return e.jsxs("div",{className:U.calendarRoot,children:[e.jsx("div",{className:U.calendarWrapper,children:e.jsx(ct.DayPickerSingleDateController,{date:h,onDateChange:_,focused:s,onFocusChange:({focused:g})=>i(g??!0),initialVisibleMonth:y,onPrevMonthClick:w,onNextMonthClick:k,numberOfMonths:1,enableOutsideDays:!0,isOutsideRange:()=>!1,renderDayContents:f,noBorder:!0,hideKeyboardShortcutsPanel:!0})}),h&&e.jsx("div",{className:U.selectedDateFooter,children:h.locale("es").format("LL")})]})},Bt="_pickupCard_1l2o2_1",Tt="_pickupCardHeader_1l2o2_12",Et="_pickupCardHeaderLeft_1l2o2_28",Lt="_pickupCardHeaderSummary_1l2o2_35",Ot="_pickupCardSummaryTitle_1l2o2_39",qt="_pickupCardDetailsMeta_1l2o2_46",$t="_pickupCardTitleBlock_1l2o2_58",Ht="_pickupCardHeaderMetaGroup_1l2o2_65",Ut="_pickupCardHeaderRight_1l2o2_82",Wt="_pickupCardBadge_1l2o2_89",Gt="_chevron_1l2o2_94",Vt="_pickupCardBody_1l2o2_98",zt="_pickupCardLabel_1l2o2_116",Yt="_pickupCardValue_1l2o2_121",Jt="_pickupCardActions_1l2o2_127",Kt="_pickupCardActionsLeft_1l2o2_137",Zt="_pickupCompleteWrap_1l2o2_146",Qt="_pickupCompleteHint_1l2o2_155",Xt="_noDocumentationRow_1l2o2_164",ea="_noDocumentationText_1l2o2_171",ta="_documentsBlock_1l2o2_178",aa="_documentsBlockHeadingRow_1l2o2_183",oa="_documentsBlockToolbar_1l2o2_187",na="_documentList_1l2o2_208",sa="_documentItem_1l2o2_214",ia="_documentNameBlock_1l2o2_228",ca="_documentName_1l2o2_228",la="_documentUploadDate_1l2o2_241",da="_documentDownload_1l2o2_247",ra="_addDocumentSection_1l2o2_273",ua="_addDocumentSectionLoadingDocuments_1l2o2_280",ma="_addDocumentSectionTitle_1l2o2_291",pa="_documentUploadList_1l2o2_298",ha="_documentUploadRow_1l2o2_304",ga="_documentUploadRowOriginal_1l2o2_319",_a="_documentUploadIcon_1l2o2_324",fa="_documentUploadName_1l2o2_331",Ca="_documentUploadFileName_1l2o2_339",ka="_documentUploadOriginalBadge_1l2o2_347",xa="_originalSwitchWrap_1l2o2_360",ba="_documentUploadOriginalWrap_1l2o2_365",ya="_documentUploadOriginalLabel_1l2o2_372",Sa="_documentUploadDelete_1l2o2_377",ja="_addDocumentSectionActions_1l2o2_392",l={pickupCard:Bt,pickupCardHeader:Tt,pickupCardHeaderLeft:Et,pickupCardHeaderSummary:Lt,pickupCardSummaryTitle:Ot,pickupCardDetail
1sMeta:qt,pickupCardTitleBlock:$t,pickupCardHeaderMetaGroup:Ht,pickupCardHeaderRight:Ut,pickupCardBadge:Wt,chevron:Gt,pickupCardBody:Vt,pickupCardLabel:zt,pickupCardValue:Yt,pickupCardActions:Jt,pickupCardActionsLeft:Kt,pickupCompleteWrap:Zt,pickupCompleteHint:Qt,noDocumentationRow:Xt,noDocumentationText:ea,documentsBlock:ta,documentsBlockHeadingRow:aa,documentsBlockToolbar:oa,documentList:na,documentItem:sa,documentNameBlock:ia,documentName:ca,documentUploadDate:la,documentDownload:da,addDocumentSection:ra,addDocumentSectionLoadingDocuments:ua,addDocumentSectionTitle:ma,documentUploadList:pa,documentUploadRow:ha,documentUploadRowOriginal:ga,documentUploadIcon:_a,documentUploadName:fa,documentUploadFileName:Ca,documentUploadOriginalBadge:ka,originalSwitchWrap:xa,documentUploadOriginalWrap:ba,documentUploadOriginalLabel:ya,documentUploadDelete:Sa,addDocumentSectionActions:ja},Da=({title:t,isExpanded:o,alwaysExpanded:a,effectiveExpanded:s,isCompleted:i,noDocuments:p,docCount:d,originalCount:h,onHeaderClick:m})=>e.jsxs("button",{type:"button",className:l.pickupCardHeader,onClick:m,"aria-expanded":o,"aria-label":t,children:[e.jsx("div",{className:l.pickupCardHeaderLeft,children:e.jsx("div",{className:l.pickupCardHeaderSummary,children:e.jsx("span",{className:l.pickupCardSummaryTitle,children:t})})}),e.jsxs("div",{className:l.pickupCardHeaderRight,children:[i?e.jsxs(G,{color:"success",className:l.pickupCardBadge,children:[e.jsx(ue,{width:16,height:16,className:"me-1"}),"Completada"]}):p?e.jsx(G,{color:"danger",className:l.pickupCardBadge,children:"Sin documentos"}):d>0&&e.jsxs(G,{color:"success",className:l.pickupCardBadge,children:[e.jsx(ue,{width:14,height:14,className:"me-1"}),d," doc",d!==1?"s":"",h>0?` (${h} original${h!==1?"es":""})`:""]}),!a&&(s?e.jsx(lt,{className:l.chevron,width:20,height:20}):e.jsx(dt,{className:l.chevron,width:20,height:20}))]})]}),wa=({deliveryPeriodLabel:t,isCompleted:o,completedAtLabel:a})=>e.jsx("div",{className:l.pickupCardDetailsMeta,children:e.jsxs("div",{className:l.pickupCardTitleBlock,children:[t?e.jsxs("div",{className:l.pickupCardHeaderMetaGroup,children:[e.jsx("span",{className:l.pickupCardLabel,children:"Semana de entrega"}),e.jsx("span",{className:l.pickupCardValue,children:t})]}):null,o&&a?e.jsxs("div",{className:l.pickupCardHeaderMetaGroup,children:[e.jsx("span",{className:l.pickupCardLabel,children:"Completada"}),e.jsx("span",{className:l.pickupCardValue,children:a})]}):null]})}),va={},Na=({document:t,defaultFiles:o=[],multiple:a=!1,group:s,update:i,canUpload:p})=>{const{loading:d,onDrop:h,onDropRejected:m,filesToShow:_,filePermissions:f}=ot({pigeonDocument:t,defaultFiles:o,group:s,update:i}),y=p??f.canUpload,w=_.length>0;return e.jsxs("div",{className:va.pickupFiles,"data-testid":"pickup-files",children:[e.jsx(ye,{loading:d,testID:"pickup-files-loading"}),e.jsx(nt,{onDrop:h,onDropRejected:m,multiple:a,disabled:!y,testID:"pickup-files-dropzone"}),e.jsx(st,{visible:!w,testID:"pickup-files-empty-message"})]})};function q(t){return(t??[]).filter(o=>o.status!=="deleted")}const Pa=({isOpen:t,uploadDocument:o,filePermissions:a,loadingDocuments:s,currentFiles:i,fileExtra:p,onFilesUpdate:d,onDeleteFile:h,onSave:m,onClose:_,setOriginalForKey:f,setOriginalCollectedAtForKey:y,activeUploadFilesCount:w})=>e.jsx(Se,{isOpen:t,children:e.jsxs("div",{className:l.addDocumentSection,children:[s&&e.jsx("div",{className:l.addDocumentSectionLoadingDocuments,children:e.jsx(ye,{type:"inPlace",loading:!0})}),e.jsx("h6",{className:l.addDocumentSectionTitle,children:"Documentación de la recogida"}),e.jsx(Na,{document:o,group:rt,defaultFiles:i,multiple:!0,update:d,deleteFile:h,canUpload:a.canUpload,canDelete:a.canDelete,canDownload:a.canDownload}),w>0&&e.jsx("ul",{className:l.documentUploadList,children:q(i).map(k=>{const g=p[k.key]?.is_original??!1,r=!!p[k.key]?.original_collected_at;return e.jsxs("li",{className:g?`${l.documentUploadRow} ${l.documentUploadRowOriginal}`:l.documentUploadRow,children:[e.jsx(K,{className:l.documentUploadIcon,"aria-hidden":!0}),e.jsxs("span",{className:l.documentUploadName,children:[e.jsx("span",{className:l.documentUploadFileName,title:k.name,children:k.name}),g&&e.jsx(G,{color:"warning",className:l.documentUploadOriginalBadge,children:"ORIGINAL"}),r&&e.jsx(G,{color:"info",className:"ms-2",children:"Recogido"})]}),e.jsxs("span",{className:l.documentUploadOriginalWrap,children:[e.jsx("span",{className:l.documentUploadOriginalLabel,children:"Original"}),e.jsx("span",{className:l.originalSwitchWrap,children:e.jsx(le,{name:`original-${k.key}`,hideCard:!0,size:"sm",checked:g,onChange:c=>f(k.key,c)})})]}),e.jsxs("span",{className:l.documentUploadOriginalWrap,children:[e.jsx("span",{className:l.documentUploadOriginalLabel,children:"Recogido"}),e.jsx("span",{className:l.originalSwitchWrap,children:e.jsx(le,{name:`original-collected-${k.key}`,hideCard:!0,size:"sm",checked:r,onChange:c=>y(k.key,c?new xe().toISOString():void 0)})})]}),a.canDelete&&e.jsx("button",{type:"button",className:l.documentUploadDelete,onClick:c=>{c.stopPropagation(),h(k)},title:"Eliminar","aria-label":"Eliminar",children:e.jsx(mt,{width:18,height:18})})]},k.key)})}),e.jsxs("div",{className:l.addDocumentSectionActions,children:[w>0&&e.jsx(W,{color:"primary",size:"sm",testID:"pickup-document-form-save-button",onClick:m,disabled:s,children:s?"Guardando...":"Guardar"}),e.jsx(W,{color:"secondary",outline:!0,size:"sm",onClick:_,children:"Cerrar"})]})]})});function Aa({pickup:t,onUpdatePickupDocuments:o,onDeletePickupFile:a}){const s=typeof t._id=="string"?t._id:String(t._id),[i,p]=n.useState(!1),[d,h]=n.useState(()=>q(t.documents)),[m,_]=n.useState({}),[f,y]=n.useState(!1),k=q(t.documents).length>0||q(d).length>0;n.useEffect(()=>{k&&y(!1)},[k]),n.useEffect(()=>{if(!i)return;const x=q(t.documents);h(x);const N={};x.forEach(D=>{const u=D.key;u&&(N[u]={is_original:D.is_original??!1,original_collected_at:D.original_collected_at})}),_(N)},[i,t.documents]);const g=n.useCallback(x=>{x.stopPropagation(),p(N=>!N)},[]),j=n.useCallback((x,N)=>{_(D=>({...D,[x]:{...D[x],is_original:N}}))},[]),r=n.useCallback((x,N)=>{_(D=>({...D,[x]:{...D[x],original_collected_at:N}}))},[]),c=n.useCallback(x=>{h(x)},[]),C=n.useCallback(()=>
1{if(!o)return;const x=q(t.documents),D=q(d).map(u=>{const P=x.find(L=>L.key===u.key),B=x.find(L=>L.name===u.name),O=m[u.key]?.is_original??P?.is_original??B?.is_original??!1,E=m[u.key]?.original_collected_at??P?.original_collected_at;return{...u,status:u.status||"active",is_original:O,...E!=null&&E!==""&&{original_collected_at:E}}});o(s,D)},[s,t.documents,d,m,o]),S=n.useCallback(x=>{h(D=>D.map(u=>u.key===x.key?{...u,status:"deleted"}:u)),(t.documents??[]).some(D=>D.key===x.key)&&x.key&&a&&a(s,x.key)},[s,a,t.documents]),v=n.useCallback(()=>{p(!1),h(q(t.documents)),_({})},[t.documents]),I=n.useCallback(()=>{p(!1)},[]),F=q(d).length,M=n.useMemo(()=>({currentFiles:d,fileExtra:m,onFilesUpdate:c,onDeleteFile:S,onSave:C,onClose:v,setOriginalForKey:j,setOriginalCollectedAtForKey:r,activeUploadFilesCount:F}),[d,m,c,S,C,v,j,r,F]);return{showAddDocumentSection:i,noDocumentationMarked:f,setNoDocumentationMarked:y,formProps:M,handleToggleDocumentSection:g,collapseAddDocumentPanel:I}}function fe(t,o,a){return t.map((s,i)=>{const p=s.key!=null&&typeof s.key=="string"?s.key:`doc-${i}`;return e.jsxs("li",{className:l.documentItem,children:[e.jsxs("div",{className:l.documentNameBlock,children:[e.jsx("span",{className:l.documentName,children:s.name??"â"}),s.uploaded_date?e.jsxs("span",{className:l.documentUploadDate,children:["Fecha de subida: ",me(s.uploaded_date,"long")]}):null]}),s.is_original&&e.jsx(G,{color:"warning",variant:"outline",size:"xs",className:"ms-2",children:"Original"}),s.original_collected_at&&e.jsxs(G,{color:"info",variant:"outline",size:"xs",className:"ms-2",children:["Original recogido ",me(s.original_collected_at,"short")]}),o&&e.jsx(W,{type:"button",className:l.documentDownload,title:"Descargar",onClick:()=>o?.(s),disabled:a,icon:e.jsx(je,{width:18,height:18})})]},p)})}const Ia=({documents:t,onDownloadAll:o,onDownloadDocument:a,isDownloadingPickupDocuments:s,showDownloadAll:i,showDocumentsListToolbar:p=!1})=>t.length===0?null:p?e.jsxs("div",{className:l.documentsBlock,children:[e.jsxs("div",{className:`d-flex align-items-center justify-content-between flex-wrap gap-2 ${l.documentsBlockHeadingRow}`,children:[e.jsx("span",{className:l.pickupCardSummaryTitle,children:"Documentos recogidos"}),i?e.jsx("div",{className:l.documentsBlockToolbar,children:e.jsxs(W,{type:"button",color:"primary",size:"sm",outline:!0,disabled:s||o==null,onClick:d=>{d.preventDefault(),d.stopPropagation(),o?.(d)},title:"Descargar todos los documentos de la recogida",children:[e.jsx(je,{width:16,height:16,className:"me-1"}),s?"Descargando...":`Descargar (${t.length} archivos)`]})}):null]}),e.jsx("ul",{className:l.documentList,children:fe(t,a,s)})]}):e.jsx("div",{className:l.documentsBlock,children:e.jsx("ul",{className:l.documentList,children:fe(t,a,s)})}),Ra=2,Fa=10080*60*1e3;class Ma{constructor(o,a){this.pickup=o,this.parentDelivery=a}get _id(){return this.pickup._id}get status(){return this.pickup.status}get isOpen(){return this.pickup.status==="picked_up"}get openUntil(){const o=this.pickup.created_at;if(!o)return null;const a=new Date(o);return Number.isNaN(a.getTime())?null:new Date(a.getTime()+Ra*Fa)}get isWithinOpenWindow(){if(!this.isOpen)return!1;const o=this.openUntil;return o?new Date<=o:!0}get documents(){return this.pickup.documents}get created_at(){return this.pickup.created_at}get updated_at(){return this.pickup.updated_at}get documentType(){return"pickup"}getFilePermissions(o,a){return this.parentDelivery.getFilePermissions(o,a)}}function Ba({pickup:t,procuraDelivery:o,activeUser:a,slotIndex:s,collapseAddDocumentPanel:i,noDocumentationMarked:p,completingPickupId:d,onUpdatePickupDocuments:h,onCompletePickup:m,onDownloadAllDocuments:_}){const f=n.useMemo(()=>o&&t?new Ma(t,o):null,[t,o]),y=n.useMemo(()=>f?{_id:f._id,documentType:f.documentType,getFilePermissions:(T,H)=>f.getFilePermissions(T,H)}:null,[f]),w=n.useMemo(()=>f?.getFilePermissions(a,"pickup_documents"),[f,a]),k=typeof t._id=="string"?t._id:String(t._id),g=t.created_at,j=n.useMemo(()=>g?`Recogida del ${ge(g)}`:`Recogida ${s}`,[g,s]),r=n.useMemo(()=>tt(t.delivery_week_start)||null,[t.delivery_week_start]),c=t.status==="delivered",C=n.useMemo(()=>!c||!t.performed_at?null:ge(t.performed_at),[c,t.performed_at]),{activeDocuments:S,docCount:v,originalCount:I,canCompletePickup:F,manageDocumentsButtonLabel:M,originalsPendingHint:x}=n.useMemo(()=>{const T=q(t.documents),H=T.length,Y=T.filter(J=>J.is_original).length,V=T.filter(J=>J.is_original&&!J.original_collected_at).length,De=Y===0||V===0;let re="Subir documentación";H>0&&(re=V>0?"Revisar documentación":"Añadir documentación");const we=H>0&&V>0?V===1?"Falta un documento original por marcar como recogido.":"Faltan documentos originales por marcar como recogidos.":null;return{activeDocuments:T,docCount:H,originalCount:Y,originalsNotCollectedCount:V,canCompletePickup:De,manageDocumentsButtonLabel:re,originalsPendingHint:we}},[t.documents]),N=n.useMemo(()=>!!(a?.isAdmin||o?.substitute!=null&&a?.equals(o.substitute)),[a,o]),D=t.status==="picked_up"&&N,u=t.status==="picked_up"&&v===0,B=!!(h&&!!f),O=n.useMemo(()=>!B||y==null||w==null?null:{uploadDocument:y,filePermissions:w},[B,y,w]),E=v===0&&m!=null,L=m!=null,b=d!=null&&d!==""&&d===k,R=!b&&(v>0||p)&&F,te=n.useCallback(T=>{T.stopPropagation(),i(),m?.(k)},[i,m,k]),ae=n.useCallback(T=>{T.stopPropagation(),_?.(t)},[_,t]);return{pickupDocumentFormModel:O,pickupId:k,canManageDocuments:B,showNoDocumentationSwitch:E,showCompletePickupButton:L,dateTime:g,title:j,deliveryPeriodLabel:r,isCompleted:c,completedAtLabel:C,activeDocuments:S,docCount:v,originalCount:I,canCompletePickup:F,manageDocumentsButtonLabel:M,originalsPendingHint:x,isCompletingThisPickup:b,canSubmitComplete:R,showCompleteActions:D,noDocuments:u,handleCompletePickup:te,handleDownloadAll:ae}}const ce=({pickup:t,procuraDelivery:o,slotIndex:a,isExpanded:s,onToggle:i,alwaysExpanded:p=!1,onCompletePickup:d,completingPickupId:h,onUp
1datePickupDocuments:m,onDeletePickupFile:_,onDownloadAllDocuments:f,onDownloadDocument:y,isDownloadingPickupDocuments:w,loadingDocuments:k=!1,showDocumentsListToolbar:g})=>{const{activeUser:j}=X(),r=Aa({pickup:t,onUpdatePickupDocuments:m,onDeletePickupFile:_}),{pickupDocumentFormModel:c,pickupId:C,canManageDocuments:S,showNoDocumentationSwitch:v,showCompletePickupButton:I,title:F,deliveryPeriodLabel:M,isCompleted:x,completedAtLabel:N,activeDocuments:D,docCount:u,originalCount:P,canCompletePickup:B,manageDocumentsButtonLabel:O,originalsPendingHint:E,isCompletingThisPickup:L,canSubmitComplete:b,showCompleteActions:R,noDocuments:te,handleCompletePickup:ae,handleDownloadAll:T}=Ba({pickup:t,procuraDelivery:o,activeUser:j,slotIndex:a,collapseAddDocumentPanel:r.collapseAddDocumentPanel,noDocumentationMarked:r.noDocumentationMarked,completingPickupId:h,onUpdatePickupDocuments:m,onCompletePickup:d,onDownloadAllDocuments:f}),H=p||s,Y=()=>!p&&i();return e.jsxs("div",{className:l.pickupCard,children:[e.jsx(Da,{title:F,isExpanded:s,alwaysExpanded:p,effectiveExpanded:H,isCompleted:x,noDocuments:te,docCount:u,originalCount:P,onHeaderClick:Y}),e.jsx(Se,{isOpen:H,children:e.jsxs("div",{className:l.pickupCardBody,children:[e.jsx(wa,{deliveryPeriodLabel:M,isCompleted:x,completedAtLabel:N}),R&&e.jsxs("div",{className:l.pickupCardActions,children:[e.jsxs("div",{className:l.pickupCardActionsLeft,children:[S&&e.jsxs(W,{color:"primary",outline:!0,testID:"pickup-card-upload-documents-button",onClick:r.handleToggleDocumentSection,children:[e.jsx(kt,{width:16,height:16,className:"me-1"}),O]}),v&&e.jsxs("div",{className:l.noDocumentationRow,children:[e.jsx(le,{name:`no-documentation-${C}`,hideCard:!0,size:"sm",checked:r.noDocumentationMarked,onChange:r.setNoDocumentationMarked}),e.jsx("span",{className:l.noDocumentationText,children:"Marcar sin documentos"})]})]}),I&&e.jsxs("div",{className:l.pickupCompleteWrap,children:[e.jsx(W,{color:"success",size:"md",disabled:!b,testID:"pickup-card-complete-button",onClick:ae,title:B?void 0:"Marca todos los documentos originales como recogidos para poder completar",children:L?"Completando...":"Completar"}),E?e.jsx("p",{className:l.pickupCompleteHint,children:E}):null]})]}),e.jsx(Ia,{documents:D,onDownloadAll:T,onDownloadDocument:y,isDownloadingPickupDocuments:w,showDownloadAll:!!f,showDocumentsListToolbar:g}),c&&e.jsx(Pa,{isOpen:r.showAddDocumentSection,uploadDocument:c.uploadDocument,filePermissions:c.filePermissions,loadingDocuments:k,...r.formProps})]})})]})},Ta="_detailFieldBox_lqro4_3",Ea="_section_lqro4_9",La="_sectionTitle_lqro4_17",Oa="_sectionIcon_lqro4_27",qa="_sectionTitleScheduled_lqro4_34",$a="_sectionIconScheduled_lqro4_44",Ha="_sectionEmpty_lqro4_51",Ua="_pickupCardsList_lqro4_57",Wa="_scheduledCardsList_lqro4_61",A={detailFieldBox:Ta,section:Ea,sectionTitle:La,sectionIcon:Oa,sectionTitleScheduled:qa,sectionIconScheduled:$a,sectionEmpty:Ha,pickupCardsList:Ua,scheduledCardsList:Wa},Ga="_scheduledCard_ecqb5_1",Va="_scheduledCardDisabled_ecqb5_12",za="_scheduledCardInner_ecqb5_18",Ya="_scheduledCardIcon_ecqb5_25",Ja="_scheduledCardText_ecqb5_32",Ka="_scheduledCardDate_ecqb5_39",Za="_scheduledCardTime_ecqb5_45",Qa="_scheduledCardBadge_ecqb5_50",Xa="_scheduledCardActions_ecqb5_62",$={scheduledCard:Ga,scheduledCardDisabled:Va,scheduledCardInner:za,scheduledCardIcon:Ya,scheduledCardText:Ja,scheduledCardDate:Ka,scheduledCardTime:Za,scheduledCardBadge:Qa,scheduledCardActions:Xa},Ce=({slot:t,isFirstAvailable:o,isDisabled:a=!1,canManagePickups:s,onCreatePickup:i,creatingPickup:p})=>e.jsxs("div",{className:`${$.scheduledCard} ${a?$.scheduledCardDisabled:""}`,children:[e.jsxs("div",{className:$.scheduledCardInner,children:[e.jsx(Q,{className:$.scheduledCardIcon,"aria-hidden":!0}),e.jsxs("div",{className:$.scheduledCardText,children:[e.jsx("span",{className:$.scheduledCardDate,children:Me(t.periodStart,t.periodEnd)}),e.jsx("span",{className:$.scheduledCardTime,children:"Sin fecha hasta crear"})]}),e.jsxs("span",{className:$.scheduledCardBadge,children:[e.jsx(Q,{width:14,height:14,className:"me-1"}),a?"Pendiente (no disponible)":t.withinPastWeekGrace?"Pendiente de registro":"Programada"]})]}),o&&s&&!a&&i&&e.jsx("div",{className:$.scheduledCardActions,children:e.jsx(W,{size:"sm",color:"secondary",disabled:p,testID:"scheduled-pickup-create-button",onClick:d=>{d.stopPropagation(),i(t.periodStart)},children:p?"Creando...":"Crear recogida"})})]});function eo({pickups:t,pickupCalendarDates:o,pendingSlots:a}){const[s,i]=n.useState(()=>new Set),p=n.useRef(!1),[d,h]=n.useState(()=>Z().format("YYYY-MM-DD")),m=n.useMemo(()=>t.filter(r=>r.status!=="delivered"&&_e(r)),[t]),_=n.useMemo(()=>t.filter(r=>r.status!=="delivered"&&!_e(r)),[t]),f=n.useMemo(()=>at(o,d,t),[t,o,d]);n.useEffect(()=>{const r=f.map(ne);r.length!==0&&i(c=>{const C=new Set(c);return r.forEach(S=>C.add(S)),C})},[d,f]),n.useEffect(()=>{if(p.current)return;const r=t.filter(c=>c.status==="delivered");if(r.length>0){p.current=!0;const c=r[r.length-1];i(C=>new Set(C).add(ne(c)))}},[t]);const y=n.useCallback(r=>
1{i(c=>{const C=new Set(c);return C.has(r)?C.delete(r):C.add(r),C})},[]),w=n.useCallback(r=>{const c=Z(r).format("YYYY-MM-DD");h(c);const C=o.filter(S=>S.date===c&&S.pickupId);C.length>0&&i(S=>{const v=new Set(S);return C.forEach(I=>I.pickupId&&v.add(String(I.pickupId))),v})},[o]),k=n.useMemo(()=>a.filter(r=>r.withinPastWeekGrace),[a]),g=n.useMemo(()=>a.filter(r=>!r.withinPastWeekGrace),[a]),j=n.useMemo(()=>a.find(c=>c.weekType!=="next")?.slotIndex??t.length+1,[a,t.length]);return{expandedIds:s,selectedDate:d,selectedPickupsForResumen:f,pickupsCurrentDeliveryPeriodPending:m,pickupsGraceBacklogPending:_,gracePendingSlots:k,upcomingPendingSlots:g,firstAvailableSlotIndex:j,handleToggleExpanded:y,handleCalendarDateSelect:w,toPickupId:ne}}const to=({pickups:t,pickupCalendarDates:o,pendingSlots:a,procuraDelivery:s,completingPickupId:i,onCompletePickup:p,onUpdatePickupDocuments:d,onDeletePickupFile:h,onDownloadAllDocuments:m,onDownloadDocument:_,isDownloadingPickupDocuments:f,loadingDocuments:y=!1,canManagePickups:w=!0,onCreatePickup:k,creatingPickup:g=!1})=>{const{expandedIds:j,selectedDate:r,selectedPickupsForResumen:c,pickupsCurrentDeliveryPeriodPending:C,pickupsGraceBacklogPending:S,gracePendingSlots:v,upcomingPendingSlots:I,firstAvailableSlotIndex:F,handleToggleExpanded:M,handleCalendarDateSelect:x,toPickupId:N}=eo({pickups:t,pickupCalendarDates:o,pendingSlots:a}),D="mb-4 bg-white p-3 rounded-4 ia-shadow mx-3";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`row ${D}`,children:[e.jsxs("div",{className:"col-12 col-lg-6",children:[e.jsx("div",{className:"d-flex align-items-center justify-content-start gap-3 mb-3",children:e.jsx(se,{icon:Be,title:"Historial de recogidas"})}),e.jsx(Mt,{selectedDates:o,selectedDate:r,onDateSelect:x})]}),e.jsxs("div",{className:"col-12 col-lg-6",children:[e.jsx("div",{className:"d-flex align-items-center justify-content-start gap-3 mb-3",children:e.jsx(se,{icon:K,title:`Resumen de recogidas dÃa ${r} (${c.length})`})}),e.jsx("div",{className:A.detailFieldBox,children:c.length>0?e.jsx("div",{className:A.pickupCardsList,children:c.map(u=>{const P=N(u);return e.jsx(ce,{pickup:u,procuraDelivery:s,slotIndex:t.findIndex(B=>B._id===u._id)+1,isExpanded:j.has(P),onToggle:()=>M(P),onDownloadAllDocuments:m,onDownloadDocument:_,isDownloadingPickupDocuments:f,showDocumentsListToolbar:!0},P)})}):e.jsx("p",{className:A.sectionEmpty,children:"No hay recogida en la fecha seleccionada."})})]})]}),e.jsx("div",{className:`row ${D}`,children:e.jsxs("div",{className:"col-12",children:[e.jsx("div",{className:"d-flex align-items-center justify-content-start gap-3 mb-3",children:e.jsx(se,{icon:ft,title:"Recogidas en curso"})}),C.length>0?e.jsxs("div",{className:A.section,children:[e.jsxs("h6",{className:A.sectionTitle,children:[e.jsx(K,{className:A.sectionIcon}),"Periodo de entrega en curso (pendientes de documentación)"]}),e.jsx("div",{className:A.pickupCardsList,children:C.map(u=>e.jsx(ce,{pickup:u,procuraDelivery:s,slotIndex:t.findIndex(P=>P._id===u._id)+1,isExpanded:j.has(N(u)),onToggle:()=>M(N(u)),onCompletePickup:p,completingPickupId:i,onUpdatePickupDocuments:d,onDeletePickupFile:h,onDownloadAllDocuments:m,onDownloadDocument:_,isDownloadingPickupDocuments:f,loadingDocuments:y},typeof u._id=="string"?u._id:String(u._id)))})]}):null,S.length>0?e.jsxs("div",{className:A.section,children:[e.jsxs("h6",{className:A.sectionTitle,children:[e.jsx(K,{className:A.sectionIcon}),"Periodos anteriores en plazo (pendientes de documentación)"]}),e.jsx("div",{className:A.pickupCardsList,children:S.map(u=>e.jsx(ce,{pickup:u,procuraDelivery:s,slotIndex:t.findIndex(P=>P._id===u._id)+1,isExpanded:j.has(N(u)),onToggle:()=>M(N(u)),onCompletePickup:p,completingPickupId:i,onUpdatePickupDocuments:d,onDeletePickupFile:h,onDownloadAllDocuments:m,onDownloadDocument:_,isDownloadingPickupDocuments:f,loadingDocuments:y},typeof u._id=="string"?u._id:String(u._id)))})]}):null,v.length>0?e.jsxs("div",{className:A.section,children:[e.jsxs("h6",{className:A.sectionTitleScheduled,children:[e.jsx(Q,{className:A.sectionIconScheduled}),"Recogidas pendientes de registro (periodos anteriores en plazo)"]}),e.jsx("div",{className:A.scheduledCardsList,children:v.map(u=>e.jsx(Ce,{slot:u,isFirstAvailable:u.slotIndex===F,isDisabled:u.weekType==="next",canManagePickups:w,onCreatePickup:k,creatingPickup:g},`${u.periodStart}-${u.slotIndex}`))})]}):null,e.jsxs("div",{className:A.section,children:[e.jsxs("h6",{className:A.sectionTitleScheduled,children:[e.jsx(Q,{className:A.sectionIconScheduled}),"Próximas recogidas programadas"]}),I.length===0?e.jsx("p",{className:A.sectionEmpty,children:"No hay recogidas programadas en el rango visible."}):e.jsx("div",{className:A.scheduledCardsList,children:I.map(u=>e.jsx(Ce,{slot:u,isFirstAvailable:u.slotIndex===F,isDisabled:u.weekType==="next",canManagePickups:w,onCreatePickup:k,creatingPickup:g},`${u.periodStart}-${u.slotIndex}`))})]})]})})]})},ao=({procuraDelivery:t,loading:o,activeUser:a,id:s,updateProcuraDelivery:i})=>{const{userInvoiceAccounts:p,loadUserInvoiceAccount:d}=Te(),[h,m]=n.useState({invoiceAccount:"",showAccountSaveButton:!1,showAddAccount:!1});n.useEffect(()=>{if(!t||o||!a)return;const c=t.substitute,C=t.creator;(a.isAdmin||!a.equals(c))&&(C?._id&&a.isAdmin&&d(C._id),!a.isAdmin&&!a.equals(c)&&d(a.isPartner?a.partnerParentId??a.id:a.id))},[d,a,t,o]);const _=n.useMemo(()=>{const c=t?.user_invoice_account_id;if(c==null)return null;if(typeof c=="object"&&"invoice_name"in c)return c;const C=typeof c=="string"?c:c._id;return p.getById(C,{viewerIsAdmin:!!a?.isAdmin})??null},[t,p,a?.isAdmin]),f=n.useMemo(()=>_?`${_.invoice_name} - ${_.cif}
1`:"",[_]),y=_?.notes??"",{canViewInvoiceAccount:w,canChangeAccount:k}=n.useMemo(()=>!a||!t?{canViewInvoiceAccount:!1,canChangeAccount:!1}:{canViewInvoiceAccount:Je(a,t).canViewInvoiceAccount,canChangeAccount:Ye(a,t).canChangeAccount},[a,t]),g=n.useCallback(c=>{const C=c.target.value;if(m(S=>({...S,invoiceAccount:C})),C==="Seleccionar datos"){m(S=>({...S,showAccountSaveButton:!1}));return}m(S=>({...S,showAccountSaveButton:!0,showAddAccount:!1}))},[]),j=n.useCallback(()=>{!s||!h.invoiceAccount||(i(s,{user_invoice_account_id:h.invoiceAccount}),m(c=>({...c,showAccountSaveButton:!1})))},[s,h.invoiceAccount,i]),r=n.useCallback(()=>{m(c=>({...c,showAddAccount:!c.showAddAccount}))},[]);return{documentAccount:f,accountNotes:y,canViewInvoiceAccount:w,canChangeAccount:k,userInvoiceAccounts:p,selectedInvoiceAccount:null,invoiceAccount:h.invoiceAccount,showAccountSaveButton:h.showAccountSaveButton,showAddAccount:h.showAddAccount,handleChangeInvoiceAccount:g,updateDocumentInvoiceAccount:j,onToggleAdd:r}},oo=()=>{const{id:t}=be(),{activeUser:o}=X(),{isEditing:a,setViewMode:s}=de(),{procuraDelivery:i,loading:p,loadingDocuments:d,loadProcuraDelivery:h,completeProcuraDeliveryPickup:m,updatePickup:_,createProcuraDeliveryPickup:f,deletePickupFile:y,updateProcuraDelivery:w}=ee(),k=ao({procuraDelivery:i,loading:p,activeUser:o??null,id:t,updateProcuraDelivery:w}),[g,j]=n.useState({showSearchSubstitutes:!1,showJudicialPartyInfo:!1}),[r,c]=n.useState(null),[C,S]=n.useState(!1),v=n.useCallback(()=>{j(b=>({...b,showSearchSubstitutes:!b.showSearchSubstitutes}))},[]),I=n.useCallback(()=>{j(b=>({...b,showJudicialPartyInfo:!b.showJudicialPartyInfo}))},[]);n.useEffect(()=>{if(!t)return;const b=ht(t,"procura delivery");b&&h(b)},[t,h]);const F=n.useMemo(()=>i?.canEdit(o)??!1,[i,o]),{resetRef:M}=pt(()=>{i?._id&&s()});n.useEffect(()=>{M()},[i?._id,M]);const x=n.useCallback(async b=>{c(b);try{await m(b)}finally{c(null)}},[m]),N=n.useCallback(async b=>{if(!(!t||!b.trim())){S(!0);try{await f(t,b)}finally{S(!1)}}},[t,f]),D=n.useCallback(async(b,R)=>{await _(b,{documents:R})},[_]),u=n.useCallback(async(b,R)=>{await y(b,R)},[y]),{isLoading:P,downloadGroupAsZip:B,downloadS3File:O}=it(),E=n.useCallback(async b=>{if(P){pe("Ya hay una descarga en proceso, espere.");return}try{oe("Descargando documentos..."),await B(b._id,ie.documentGroupKey,(b.documents??[]).filter(R=>R.status!=="deleted"),ie.zipFilePrefix),oe("Documentos descargados correctamente")}catch(R){he("Error al descargar los documentos"),console.error(R)}},[P,B]),L=n.useCallback(async b=>{if(P){pe("Ya hay una descarga en proceso, espere.");return}try{await O(ut(b),b.name||ie.singleDocumentDefaultName),oe("Documento descargado correctamente")}catch(R){he("Error al descargar el documento"),console.error(R)}},[P,O]);return{isLoading:p,procuraDelivery:i,substituteSearchState:g,setSubstituteSearchState:j,toggleSearchSubstitutes:v,toggleJudicialPartyInfo:I,completingPickupId:r,handleCompletePickup:x,creatingPickup:C,handleCreatePickup:N,handleUpdatePickupDocuments:D,handleDeletePickupFile:u,downloadPickupDocuments:E,downloadPickupDocument:L,isDownloadingPickupDocuments:P,loadingDocuments:d,canEdit:F,isEditing:a,...k}};function no(t,o){const a=n.useMemo(()=>t?.pickups??[],[t]),s=n.useMemo(()=>t?.canManagePickups(o)??!1,[t,o]),i=n.useMemo(()=>t?.getPendingPickupSlots()??[],[t]),p=n.useMemo(()=>{const d=[];a.filter(Boolean).forEach(m=>{const _=(m.created_at??"").slice(0,10);if(_){const f=(m.documents??[]).some(y=>y.is_original);d.push({date:_,type:f?"recogida_original":"recogida",expedient_type:"recogida",pickupId:typeof m._id=="string"?m._id:String(m._id)})}});const h=new Set;return i.forEach(m=>{h.has(m.periodStart)||(h.add(m.periodStart),d.push({date:m.periodStart,type:"recogida",expedient_type:"recogida",disabled:m.weekType==="next"}))}),d},[a,i]);return{pickups:a,pendingSlots:i,pickupCalendarDates:p,canManagePickups:s}}const so=[{sectionTitle:"Administración del encargo",icon:gt,visibility:t=>t?.isAdmin===!0,fields:[{id:"status",label:"Estado",title:"Estado actual del encargo"},{id:"payment_status",label:"Estado del pago",title:"Estado del pago"},{id:"created_at",label:"Fecha de creación",title:"Fecha y hora de creación del encargo"},{id:"updated_at",label:"Fecha de actualización",title:"Fecha y hora de última actualización del encargo"},{id:"start_date",label:"Fecha de inicio",title:"Fecha de inicio del servicio"},{id:"pickups_summary",label:"Recogidas realizadas",title:"Número de recogidas realizadas según la frecuencia de recogida"}]},{sectionTitle:"Detalles del encargo",icon:Ee,visibility:()=>!0,fields:[{id:"price",label:"Precio (â¬)",title:"Precio del encargo"},{id:"cost_price",label:"Honorarios (â¬)",title:"Importe a percibir por el procurador"},{id:"start_date",label:"Fecha de inicio",title:"Fecha de inicio del servicio"},{id:"service_type",label:"Tipo de servicio",title:"Tipo de servicio contratado"},{id:"pickup_frequency",label:"Frecuencia de recogidas",title:"Frecuencia de las recogidas"},{id:"judicial_party",label:"Partido judicial",title:"Partido judicial"},{id:"estimated_notifications_per_pickup",label:"Nº notificaciones",title:"Número estimado de notificaciones por recogida"},{id:"client_internal_reference",label:"Referencia interna",title:"Referencia interna del cliente"},{id:"notes",label:"Notas adicionales",title:"Notas adicionales del encargo",type:"textarea",sm:12,md:8,lg:6},{id:"pickup_location",label:"Dirección de recogida",title:"Dirección donde se realiza la recogida"}]}],sn=()=>{const{activeUser:t}=X(),{isLoading:o,procuraDelivery:a,substituteSearchState:s,setSubstituteSearchState:i,toggleSearchSubstitutes:p,toggleJudicialPartyInfo:d,completingPickupId:h,handleCompletePickup:m,creatingPickup:_,handleCreatePickup:f,handleUpdatePickupDocuments:y,handleDeletePickupFile:w,downloadPickupDocuments:k,downloadPickupDocument:g,isDownloadingPickupDocuments:j,loadingDocuments:r,canEdit:c,isEditing:C,documentAccount:S,accountNotes:v,canViewInvoiceAccount:I,canChangeAccount:F,userInvoiceAccounts:M,selectedInvoiceAccount:x,invoiceAccount:N,showAccountSaveButton:D,showAddAccount:u,handleChangeInvoiceAccount:P,updateDocumentInvoiceAccount:B,onToggleAdd:O}=oo(),{pickups:E,pendingSlots:L,pickupCalendarDates:b,canManagePickups:R}=no(a??null,t);return o?e.jsx(Oe,{}):a?e.jsxs("div",{className:"p-0",children:[e.jsx(qe,{document:a,activeUser:t,actions:e.jsx($e,{document:a,activeUser:t,canEdit:c,showChat:!1,showIssue:!1,showReport:!1,showDelete:t.isAdmin,deleteButton:e.jsx(bt,{}),setState:i,extraItems:e.jsx(We,{document:a,activeUser:t,showFormatToggle:!1,showUrgentEmails:!1,toggleJudicialPartyInfo:d,setState:i})}),meta:{canViewInvoiceAccount:I,canChangeAccount:F,selectedInvoiceAccount:x,documentAccount:S,accountNotes:v,invoiceAccount:N,userInvoiceAccounts:M,showAccountSaveButton:D,showAddAccount:u,handleChangeInvoiceAccount:P,updateDocumentInvoiceAccount:B,onToggleAdd:O}}),e.jsxs(Le,{children:[e.jsx(He,{activeUser:t,document:a,setState:i,documentType:"procura_delivery"}),e.jsx(Ue,{isEditing:C,document:a,detailSections:so,editForm:e.jsx(Dt,{isEditing:C})}),e.jsx(to,{pickups:E,pickupCalendarDates:b,pendingSlots:L,procuraDelivery:a,canManagePickups:R,completingPickupId:h,onCompletePickup:m,onCreatePickup:f,creatingPickup:_,onUpdatePickupDocuments:y,onDeletePickupFile:w,onDownloadAllDocuments:k,onDownloadDocument:g,isDownloadingPickupDocuments:j,loadingDocuments:r})]}),e.jsx(Ge,{document:a,show:s.showSearchSubstitutes,toggle:p}),e.jsx(Ve,{show:s.showJudicialPartyInfo,toggle:d,judicialPartyId:String(a?.judicial_party??""),creatorId:a.getCreatorId(),encargoType:"procura"})]}):null};export{sn 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.