1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[177],{21733:(e,t,r)=>{"use strict";r.d(t,{H:()=>c});var s=r(99399),a=r(47477),n=r(12115),l=r(1213),i=r(25150),o=r(22663);let c=(e,t)=>{var r;let c=null!=t?t:(0,a.Z)(e,{includeBaselineRaw:!0}),[d,u]=(0,n.useState)(!0),[m,p]=(0,n.useState)(null),[x,h]=(0,n.useState)([]),g=(0,n.useRef)(new Map),{a4Data:f}=(0,i.P)(),y=Object.values((0,l.d4)(e=>e.treeObjects)).find(e=>"project"===e.type),j=null!=(r=null==y?void 0:y.serviceLife)?r:0;(0,n.useEffect)(()=>{let e=new Map;for(let t of c.optionResources.values())for(let r of t){let t=r.settingsResource.matkey,s=r.settingsResource.name;t&&s&&e.set(t,"".concat(s," (").concat(t,")"))}g.current=e},[c.optionResources]),(0,n.useEffect)(()=>{if(c.loading)return void u(!0);if(c.error){p(c.error),u(!1);return}(async()=>{try{u(!0),p(null);let e=[],t=!1;for(let[r,a]of c.optionResources.entries()){let{byMatkey:n,warnings:l}=(0,s.w6)(a,c.epdMapByKey,j,f);l.includes("Project A4 transport configuration is missing")&&!t&&(o.Ay.error("La configuraci\xf3n de transporte A4 del proyecto no est\xe1 definida",{duration:1e4,style:{whiteSpace:"pre-line"}}),t=!0);let i=Object.values(n).reduce((e,t)=>e+Object.values(null!=t?t:{}).reduce((e,t)=>e+(null!=t?t:0),0),0);e.push({optionId:r,optionName:c.optionNameOf(r),byMatkey:n,totalGwp:i,warnings:l&&l.length?Array.from(new Set(l)):void 0})}h(e)}catch(e){console.error(e),p("Error calculando GWP por opci\xf3n")}finally{u(!1)}})()},[c.loading,c.error,c.optionResources,c.epdMapByKey]);let b=c.baselineByMatkey,v=c.baselineMatkeyNames,{matkeys:N,chartData:w}=(0,n.useMemo)(()=>{let e=new Set;for(let t of x)Object.keys(t.byMatkey).forEach(t=>e.add(t));return Object.keys(b).forEach(t=>e.add(t)),{matkeys:Array.from(e),chartData:x.map(e=>({optionId:e.optionId,optionName:e.optionName,impacts:e.byMatkey}))}},[x,b]);return{loading:d,error:m,optionsGwp:x,matkeys:N,chartData:w,baselineGwp:b,matkeyNames:Object.fromEntries(g.current),baselineMatkeyNames:v,referenceType:c.referenceType}}},22020:(e,t,r)=>{Promise.resolve().then(r.bind(r,60508))},28917:(e,t,r)=>{"use strict";r.d(t,{$:()=>a});var s=r(95155);r(12115);let a=e=>{let{handleOnClick:t,text:r,readOnly:a}=e;return(0,s.jsx)(s.Fragment,{children:(0,s.jsx)("div",{className:"flex items-center gap-x-6 ml-2",children:(0,s.jsx)("button",{type:"submit",className:"rounded-md bg-green-zero px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-green-zero-hover focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-green-zero disabled:cursor-not-allowed disabled:bg-slate-400 disabled:hover:bg-slate-400",onClick:t,disabled:a,children:r})})})}},41290:()=>{},50188:(e,t,r)=>{"use strict";r.d(t,{A:()=>i,R:()=>l});var s=r(95155),a=r(10874);r(12115);let n={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-12 w-12"},l=e=>{let{loading:t,children:r,message:l="Cargando datos...",size:i="md",className:o=""}=e;return t?(0,s.jsxs)("div",{className:"flex items-center justify-center p-4 ".concat(o),children:[(0,s.jsx)(a.A,{className:"".concat(n[i]," animate-spin text-green-zero")}),l&&(0,s.jsx)("span",{className:"ml-2 text-sm text-gray-600",children:l})]}):(0,s.jsx)(s.Fragment,{children:r})},i=l},60508:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>tE});var s=r(95155);r(41290);var a=r(12115),n=r(1213),l=r(95069),i=r(30886);function o(e){let{children:t}=e;return(0,s.jsx)(n.Kq,{store:i.store,children:(0,s.jsx)(l.Q,{loading:null,persistor:i.qj,children:t})})}var c=r(37025),d=r(22663),u=r(24007),m=r(56108),p=r(90036),x=r(90632),h=r(88253),g=r(15239);let f={src:"/_next/static/media/background-towers.ad4392ca.jpg",height:4e3,width:6e3,blurDataURL:"data:image/jpeg;base64,/9j/2wBDAAoKCgoKCgsMDAsPEA4QDxYUExMUFiIYGhgaGCIzICUgICUgMy03LCksNy1RQDg4QFFeT0pPXnFlZXGPiI+7u/v/2wBDAQoKCgoKCgsMDAsPEA4QDxYUExMUFiIYGhgaGCIzICUgICUgMy03LCksNy1RQDg4QFFeT0pPXnFlZXGPiI+7u/v/wgARCAAFAAgDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAX/xAAVAQEBAAAAAAAAAAAAAAAAAAABBf/aAAwDAQACEAMQAAAAmie//8QAGxAAAgIDAQAAAAAAAAAAAAAAAQMFEgACERP/2gAIAQEAAT8AXJITCikeq3rW5JO3M//EABgRAAMBAQAAAAAAAAAAAAAAAAECIREA/9oACAECAQE/AEdmFO5L3//EABYRAAMAAAAAAAAAAAAAAAAAAAAxMv/aAAgBAwEBPwCUf//Z",blurWidth:8,blurHeight:5};var y=r(27281);function j(){let{instance:e}=(0,p.dk)(),t=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"redirect";"popup"===t?e.loginPopup(y.$8).catch(e=>{console.error("loginPopup failed: ".concat(e))}):"redirect"===t&&e.loginRedirect(y.$8).catch(e=>{console.error("loginRedirect failed: ".concat(e))})};return(0,s.jsxs)("button",{onClick:()=>t("redirect"),className:"flex w-full items-center justify-center gap-3 rounded-md border bg-white border-slate-900 px-3 py-1.5 text-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#071118]",children:[(0,s.jsxs)("svg",{className:"h-5 w-5",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",width:"48px",height:"48px",children:[(0,s.jsx)("path",{fill:"#ff5722",d:"M6 6H22V22H6z",transform:"rotate(-180 14 14)"}),(0,s.jsx)("path",{fill:"#4caf50",d:"M26 6H42V22H26z",transform:"rotate(-180 34 14)"}),(0,s.jsx)("path",{fill:"#ffc107",d:"M26 26H42V42H26z",transform:"rotate(-180 34 34)"}),(0,s.jsx)("path",{fill:"#03a9f4",d:"M6 26H22V42H6z",transform:"rotate(-180 14 34)"})]}),(0,s.jsx)("span",{className:"text-sm font-semibold leading-6 text-black",children:"Microsoft"})]})}function b(){return(0,s.jsxs)("div",{className:"flex h-screen",children:[(0,s.jsx)("div",{className:"flex flex-1 flex-col justify-center px-4 py-12 sm:px-6 lg:flex-none lg:px-12 xl:px-16 bg-white",children:(0,s.jsxs)("div",{className:"mx-auto w-full max-w-sm lg:w-96 animate-fade-up",children:[(0,s.jsx)("div",{className:"grid grid-cols-1 justify-items-center px-8",children:(0,s.jsx)("h2",{className:"mt-8 text-2xl font-bold leading-9 tracking-tight text-gray-900",children:"Sign in with your Microsoft account"})}),(0,s.jsx)("div",{className:"mt-4",children:(0,s.jsx)("div",{className:"mt-4",children:(0,s.jsx)("div",{className:"mt-4 grid grid-cols-1 px-8",children:(0,s.jsx)(j,{})})})})]})}),(0,s.jsx)("div",{className:"relative hidden w-0 flex-1 lg:block",children:(0,s.jsx)(g.default,{className:"absolute inset-0 h-full w-full object-cover",src:f,alt:"Backgroun
1d Towers",priority:!0})})]})}let v=()=>{let{instance:e}=(0,p.dk)(),t=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"redirect";if("popup"===t)e.logoutPopup().catch(e=>{console.error("logoutPopup failed: ".concat(e))});else if("redirect"===t){let t={account:e.getActiveAccount(),postLogoutRedirectUri:"/"};e.logoutRedirect(t).catch(e=>{console.error("logoutRedirect failed: ".concat(e))})}};return(0,s.jsxs)("button",{onClick:()=>t(),className:"text-sm font-semibold leading-6 text-gray-900",children:["Logout ",(0,s.jsx)("span",{"aria-hidden":"true",children:"â"})]})};var N=r(80295),w=r(306),A=r(18207),C=r(17035),k=r(46957),I=r(13082),P=r(45714),E=r(98382);let z=(e,t,r)=>(null==t?void 0:t.length)===0?(d.Ay.error("No se encontraron recursos en la biblioteca para el proyecto"),Promise.resolve()):new Promise((s,a)=>{let n=new FileReader;n.onload=()=>{try{let a=n.result;if(null!==a&&"string"==typeof a){var e,l,o,c,u,m,p,x,h,g,f,y,j,b,v,N,z,D,_,S,R,T,L,O,F;let s=JSON.parse(a),n={[s.id]:{id:s.id,type:s.type,name:(null==t||null==(l=t[0])||null==(e=l.zc_projects)?void 0:e.zc_name)||s.name,parentId:s.parentId,code:(null==t?void 0:t[0].zc_projects.zc_refpj)||s.code||"PJAAYYY",children:[],rlProjectId:(null==t?void 0:t[0]._zc_projects_value)||s.rlProjectId,client_id:(null==t?void 0:t[0]._zc_clients_value)||s.rlClientId,serviceLife:s.serviceLife||0,certification:{certificationClient:{clientId:(null==(o=s.certification)?void 0:o.certificationClient.clientId)||"",clientName:(null==(c=s.certification)?void 0:c.certificationClient.clientName)||""},certificationProject:{projectId:(null==(u=s.certification)?void 0:u.certificationProject.projectId)||"",projectName:(null==(m=s.certification)?void 0:m.certificationProject.projectName)||""}}}},d={};s.categoryList.forEach(e=>{"category"===e.type&&(n[e.id]={id:e.id,name:e.name,parentId:s.id,settingsCategoryId:e.settingsCategory.id,type:e.type,children:[]},n[s.id].children.push(e.id),e.typeList.forEach(t=>{var r;n[t.id]={id:t.id,name:t.name,area:t.area,parentId:e.id,settingsRequirementId:t.settingsRequirement.id,projectTypes:t.projectTypes,type:t.type,referenceType:t.referenceType,typeClassification:null!=(r=t.typeClassification)?r:null,children:[]},n[e.id].children.push(t.id),t.optionList.forEach(e=>{var r;n[e.id]={id:e.id,name:e.name,parentId:t.id,comment:e.comment,docRefs:e.docRefs,imageRefs:e.imageRefs,status:null!=(r=e.status)?r:k.aF.WIP,type:e.type,children:[]},d[e.id]={id:e.id.toString(),type:"composite",name:"name",parents:[],children:[],inputs:[],intermediates:[],resources:[]},n[t.id].children.push(e.id)})}))}),i.store.dispatch((0,k.ec)({newState:n})),i.store.dispatch((0,I.v2)(d)),i.store.dispatch((0,I.bL)(s.projectVariants));let M={a5Data:{residuos:(null==(x=s.projectDemands)||null==(p=x.a5Data)?void 0:p.residuos)?Number(s.projectDemands.a5Data.residuos):null,a5DemandItem:null!=(R=null==(f=s.projectDemands)||null==(g=f.a5Data)||null==(h=g.a5DemandItem)?void 0:h.map(e=>{var t,r,s,a;return{id:null!=(t=e.id)?t:null,recurso:null!=(r=e.recurso)?r:null,valor:null!=(s=e.valor)?s:null,epd:null!=(a=e.epd)?a:null}}))?R:[]},b6DemandItem:null!=(T=null==(j=s.projectDemands)||null==(y=j.b6DemandItem)?void 0:y.map(e=>{var t,r,s,a,n,l,i;return{id:null!=(t=e.id)?t:null,energia:null!=(r=e.energia)?r:null,uso:null!=(s=e.uso)?s:null,PERT:null!=(a=e.PERT)?a:null,PENRT:null!=(n=e.PENRT)?n:null,energiaFinal:null!=(l=e.energiaFinal)?l:null,epd:null!=(i=e.epd)?i:null}}))?T:[],b7Data:{Agua_Potable:null!=(L=null==(v=s.projectDemands)||null==(b=v.b7Data)?void 0:b.Agua_Potable)?L:0,Agua_No_Potable:null!=(O=null==(z=s.projectDemands)||null==(N=z.b7Data)?void 0:N.Agua_No_Potable)?O:0},a4TransportDemand:{TransportItems:null!=(F=null==(S=s.projectDemands)||null==(_=S.a4TransportDemand)||null==(D=_.TransportItems)?void 0:D.map(e=>{var t,r;return{epdResource:e.epdResource,transport:null!=(t=e.transport)?t:null,distance:null!=(r=e.distance)?r:null}}))?F:[]}};i.store.dispatch((0,E.OC)(M));let V=new Set;s.categoryList.forEach(e=>{"category"===e.type&&e.typeList.forEach(s=>{s.optionList.forEach(s=>
1{if("layers"in s.construction)s.construction.layers.forEach(e=>{e.resources.forEach(s=>{r&&(0,C.Jk)(e,V,t),"thickness"in s&&(s.measurement=s.thickness,delete s.thickness)});let s=(0,C.VE)(e);(0,C.Mn)({...e,id:s})});else{let r={id:s.id.toString(),type:"composite",name:s.name||"",parents:[],children:[],inputs:[],intermediates:[],resources:[]};switch(e.name){case k.Yd.Puertas:case k.Yd.Ventanas:(0,C.Jk)(s.construction.composite,V,t),i.store.dispatch((0,I.J7)({...r,type:"aperture",...A.p})),(0,C.Lz)(s.construction.composite);break;case k.Yd.ProteccionesSolares:(0,C.Jk)(s.construction.composite,V,t),i.store.dispatch((0,I.J7)({...r,type:"shading",solarTransmittance:0})),(0,C.t2)(s.construction.composite);break;case k.Yd.Barandillas:case k.Yd.Cimentacion:case k.Yd.Pilares:case k.Yd.Vigas:(0,C.Jk)(s.construction.composite,V,t),i.store.dispatch((0,I.J7)(r)),(0,C.MH)(s.construction.composite)}}})})});let B={categories:(0,w.f$)(s.settings.categories),layerFunctions:(0,w.f$)(s.settings.layerFunctions),compositeTemplates:(0,w.f$)(s.settings.compositeTemplates||[])};i.store.dispatch((0,P.oc)({newSettings:B}))}s()}catch(e){d.Ay.error("Ha ocurrido un error al importar el proyecto"),console.log(e),a(e)}},n.onerror=()=>{d.Ay.error("Ha ocurrido un error al leer el archivo"),a(n.error)},n.readAsText(e)});var D=r(50662);let _={rE:"2.0.0"};var S=r(62374),R=r(20063);function T(e){let{inputValue:t,setOpenModal:r,clientProjectData:n}=e,[l,i]=(0,a.useState)(null),[o,c]=(0,a.useState)(!1),d=(0,a.useRef)(null),[u,m]=(0,a.useState)(null),p=(0,R.useRouter)();(0,a.useEffect)(()=>{null===l&&d.current&&(d.current.value="")},[l]);let x=async e=>{var t;let r=null==(t=e.target.files)?void 0:t[0];if(r&&(r.name.endsWith(".json")||r.name.endsWith(".csv"))){i(r);try{if(r.name.endsWith(".json")){let{version:e="1.1.0"}=JSON.parse(await r.text()),t=e===_.rE;c(t),t||m("No se puede abrir un JSON de la versi\xf3n ".concat(e," con la aplicaci\xf3n de la versi\xf3n ").concat(_.rE,". P\xf3ngase en contacto con soporte."))}else m(null)}catch(e){console.error("Invalid JSON file"),c(!1),m("El archivo JSON no es v\xe1lido. P\xf3ngase en contacto con soporte.")}}else i(null),c(!1),m(null)},h=async()=>{var e,t;if(n&&(null==(e=n[0])?void 0:e.value)&&(null==(t=n[1])?void 0:t.value)){let e=await (0,S.Mt)(n[0].value,n[1].value);await z(l,e,!0),r(!1),sessionStorage.setItem("project-imported","true"),p.replace("/")}},g=async()=>{l&&l.name.endsWith(".json")&&o&&(await z(l),r(!1),sessionStorage.setItem("project-imported","true"),p.replace("/"))};return(0,s.jsxs)("div",{className:"flex flex-col",children:["Open project"===t?(0,s.jsxs)("div",{className:"flex items-center mb-5",children:[(0,s.jsx)(D.A,{className:"bg-purple-50 text-purple-700 inline-flex rounded-lg p-3 ring-4 ring-white w-12"}),(0,s.jsx)("p",{className:"pl-3 text-base font-semibold leading-6 text-gray-900",children:"Open Project"})]}):"Update global settings"===t?(0,s.jsx)("p",{children:"Update global settings"}):"",(0,s.jsx)("form",{className:"flex justify-end",children:(0,s.jsx)("input",{type:"file",name:"file-input",onChange:x,id:"file-input",className:"block w-full border border-gray-200 shadow-sm rounded-md text-sm focus:z-10 focus:border-green-zero focus:ring-green-zero dark:bg-slate-900 dark:border-gray-700 dark:text-gray-400 file:bg-transparent file:border-0 file:bg-gray-100 file:mr-4 file:py-3 file:px-4 dark:file:bg-gray-700 dark:file:text-gray-400",ref:d})}),u&&(0,s.jsx)("p",{className:"text-red-500 mt-2 text-sm",children:u}),"Open project"===t?(0,s.jsx)("button",{className:"mt-4 w-fit rounded-md px-3 py-2 text-sm font-semibold shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-green-zero self-end ".concat(l&&l.name.endsWith(".json")&&o?"bg-green-zero text-white hover:bg-green-zero-hover":"bg-gray-300 cursor-not-allowed"),onClick:g,disabled:!l||!l.name.endsWith(".json")||!o,children:"Upload"}):"New project from file"===t?(0,s.jsx)("button",{className:"mt-4 w-fit rounded-md px-3 py-2 text-sm font-semibold shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-green-zero self-end ".concat(l&&l.name.endsWith(".json")&&o?"bg-green-zero text-white hover:bg-green-zero-hover":"bg-gray-300 cursor-not-allowed"),onClick:()=>l&&l.name.endsWith(".json")&&o?h():void 0,disabled:!l||!l.name.endsWith(".json")||!o,children:"Upload"}):"Update global settings"===t?(0,s.jsx)("button",{className:"mt-4 w-fit roun
1ded-md px-3 py-2 text-sm font-semibold shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-green-zero self-end ".concat(l&&l.name.endsWith(".csv")&&l.name.match("0_Categor\xedas")?"bg-green-zero text-white hover:bg-green-zero-hover":"bg-gray-300 cursor-not-allowed"),onClick:()=>{(0,w.k1)(l,r)},disabled:!l||!l.name.endsWith(".csv"),children:"Upload"}):(0,s.jsx)("button",{className:"mt-4 w-fit rounded-md px-3 py-2 text-sm font-semibold shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-green-zero self-end ".concat(l&&l.name.endsWith(".json")&&o?"bg-green-zero text-white hover:bg-green-zero-hover":"bg-gray-300 cursor-not-allowed"),onClick:()=>"Update firebase settings"===t&&o?(0,w.o9)(l,i,r):void 0,disabled:!l||!l.name.endsWith(".json")||!o,children:"Upload"})]})}var L=r(22544),O=r(80580),F=r(57218),M=r(43687),V=r(9554),B=r(28917),q=r(88125),W=r(18265);let G=async function(e,t){var r,s,a,n;let l=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=i.store.getState(),c=o.treeObjects,u=o.settings.settings,m=(0,w.t9)(c),p=c[m],x={id:p.id,type:p.type,name:p.name||"",version:_.rE,code:p.code,rlProjectId:p.rlProjectId,rlClientId:p.client_id||"",serviceLife:p.serviceLife||0,certification:{certificationClient:{clientId:(null==(r=p.certification)?void 0:r.certificationClient.clientId)||"",clientName:(null==(s=p.certification)?void 0:s.certificationClient.clientName)||""},certificationProject:{projectId:(null==(a=p.certification)?void 0:a.certificationProject.projectId)||"",projectName:(null==(n=p.certification)?void 0:n.certificationProject.projectName)||""}}
1,projectVariants:o.projectVariants.projectVariants,projectDemands:o.projectDemands,categoryList:[],settings:{categories:e?[]:Object.values(u.categories),layerFunctions:e?[]:Object.values(u.layerFunctions),compositeTemplates:e?[]:Object.values(u.compositeTemplates||{})}};for(let t of p.children){let r=c[t];if(void 0===r||"category"!==r.type||e&&r.name!==e)continue;let s={id:r.id,name:r.name||"",type:r.type,settingsCategory:u.categories[r.settingsCategoryId],typeList:[]};for(let e of r.children){let t=c[e];if(void 0===t||"type"!==t.type)continue;let a=c[t.parentId],n=(u.categories[a.settingsCategoryId]||Object.values(u.categories)[0]).requirements,i=n.find(e=>e.id===t.settingsRequirementId)||n[0],o={id:t.id,type:t.type,name:t.name||"",area:t.area,referenceType:t.referenceType,typeClassification:t.typeClassification,projectTypes:t.projectTypes,settingsRequirement:i,optionList:[]};for(let e of t.children){let t=c[e];if(void 0===t||"option"!==t.type)continue;let s={id:t.id,type:t.type,name:t.name||"",comment:t.comment,docRefs:t.docRefs,imageRefs:t.imageRefs,status:t.status,construction:{id:t.id.toString(),name:t.name,layers:[]}};if(l){o.optionList.push(s);continue}switch(r.name){case k.Yd.Puertas:case k.Yd.Ventanas:{let t=await (0,C.DF)(e.toString());t.resources=await (0,C.n$)(t.resources),s.construction={id:s.construction.id,name:s.construction.name,composite:t};break}case k.Yd.ProteccionesSolares:{let t=await (0,C.nv)(e.toString());t.resources=await (0,C.n$)(t.resources),s.construction={id:s.construction.id,name:s.construction.name,composite:t};break}case k.Yd.Barandillas:case k.Yd.Cimentacion:case k.Yd.Pilares:case k.Yd.Vigas:{let t=await (0,C.aw)(e.toString());t.resources=await (0,C.n$)(t.resources),s.construction={id:s.construction.id,name:s.construction.name,composite:t};break}default:s.construction={...s.construction,layers:await (0,C.bY)(e.toString())}}o.optionList.push(s)}s.typeList.push(o)}x.categoryList.push(s)}return e||t||d.Ay.success("La descarga del proyecto ha sido exitosa"),x},U=()=>{let e=(0,n.wA)(),t=(0,R.useRouter)(),r=()=>{try{e((0,k.ec)({newState:{}})),e((0,I.v2)({})),e((0,I.bL)([])),t.push("/"),d.Ay.success("El proyecto ha sido borrado con \xe9xito")}catch(e){d.Ay.error("Ha ocurrido un error al intentar borrar el proyecto"),console.error("An error occurred:",e)}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"sm:flex sm:items-start",children:[(0,s.jsx)("div",{className:"mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full bg-red-100 sm:mx-0 sm:h-10 sm:w-10",children:(0,s.jsx)(q.A,{className:"h-6 w-6 text-red-600","aria-hidden":"true"})}),(0,s.jsxs)("div",{className:"mt-3 text-center sm:ml-4 sm:mt-0 sm:text-left",children:[(0,s.jsx)(W.l.Title,{as:"h3",className:"text-base font-semibold leading-6 text-gray-900",children:"Est\xe1s a punto de eliminar el proyecto"}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)("p",{className:"text-sm text-gray-500",children:"\xbfDeseas proceder without saving o guardar los cambios antes de continuar?"})})]})]}),(0,s.jsxs)("div",{className:"mt-5 sm:mt-4 sm:flex sm:flex-row-reverse",children:[(0,s.jsx)(B.$,{handleOnClick:()=>r(),text:"Eliminar"}),(0,s.jsx)(B.$,{handleOnClick:async()=>{let e=await G();(0,w.PE)(e),r()},text:"Guardar y eliminar"})]})]})};var K=r(2145);function Y(e){let{clients:t,label:r,name:a,isDisabled:n=!1,isRequired:l=!0,compact:i=!1}=e,{control:o,setValue:c,formState:{errors:d}}=(0,L.xW)(),u=a||"client";r=r||"Client";let m=d[u];return(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block font-medium text-gray-900 ".concat(i?"text-xs leading-5":"text-sm leading-6"),children:r}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(L.xI,{name:u,control:o,rules:{required:l},render:e=>{let{field:r}=e;return(0,s.jsx)(K.Ay,{...r,isDisabled:n,options:t.map(e=>({label:e.zc_company_name,value:e.zc_clientsid})),placeholder:"Select client",className:"text-left ".concat(i?"text-xs":""),styles:i?{control:e=>({...e,minHeight:"34px",height:"34px"}),valueContainer:e=>({...e,minHeight:"34px",height:"34px",padding:"0 8px"}),input:e=>({...e,margin:0,padding:0}),indicatorsContainer:e=>({...e,minHeight:"34px",height:"34px"}),singleValue:e=>({...e,margin:0}),placeholder:e=>({...e,margin:0}),option:e=>({...e,fontSize:"12px"})}:void 0,isClearable:!0,onChange:e=>{r.onChange(e),"client"===u&&c("project",null),"certificationClient"===u&&c("certificationProject",null)}})}})}),(null==m?void 0:m.type)==="required"&&(0,s.jsxs)("p",{role:"alert",className:"text-red-600 text-xs mt-2",children:[r," is required"]})]})}function $(e){let{projects:t,selectedClient:r,label:a,isDisabled:n=!1,name:l="project",isRequired:i=!0,compact:o=!1}=e,c=l||"project";a=a||"Project";let{control:d,formState:{errors:u}}=(0,L.xW)(),m=u[c];return(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block font-medium text-gray-900 ".concat(o?"text-xs leading-5":"text-sm leading-6"),children:a}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(L.xI,{name:c,control:d,rules:{required:i},render:e=>{let{field:a}=e;return(0,s.jsx)(K.Ay,{...a,options:t.map(e=>({label:e.zc_refpj,value:e.zc_projectsid})),menuPortalTarget:document.body,menuPosition:"fixed",styles:{menuPortal:e=>({...e,zIndex:10050}),...o?{control:e=>({...e,minHeight:"34px",height:"34px"}),valueContainer:e=>({...e,minHeight:"34px",height:"34px",padding:"0 8px"}),input:e=>({...e,margin:0,padding:0}),indicatorsContainer:e=>({...e,minHeight:"34px",height:"34px"}),singleValue:e=>({...e,margin:0}),placeholder:e=>({...e,margin:0}),option:e=>({...e,fontSize:"12px"})}:{}},placeholder:"Select project",className:"text-left ".concat(o?"text-xs":""),isClearable:!0,isDisabled:!r||n})}})}),(null==m?void 0:m.type)==="required"&&(0,s.jsxs)("p",{role:"alert",className:"text-red-600 text-xs mt-2",children:[a," is required"]})]})}var J=r(70171),H=r(70906),Q=r(50188),Z=r(23333);let X=e=>{let{isModal:t,setOpenModal:r,beFormRendered:l,isNewProject:i=!1,projectId:o,compactLayout:c=!1,onClientProjectDataChange:u}=e,m=(0,R.usePathname)().split("/")[2],p=null!=o?o:m,[x,h]=(0,a.useState)(!1),[g,f]=(0,a.useState)(!!l),y=(0,R.useRouter)(),{setLoading:j,isLoading:b}=(0,H.D)(),v=(0,n.d4)(e=>{let t=e.treeObjects[p];if(t&&"code"in t)return t}),[A,C]=(0,a.useState)([]),[P,z]=(0,a.useState)([]),[D,_]=(0,a.useState)([]),[T,q]=(0,a.useState)([]),W="/zc_projectses?$select=zc_company_name,zc_name,zc_refpj,zc_type,statecode,statuscode,zc_projectsid,_zc_clients_value",K="&$filter=_zc_clients_value eq ";(0,a.useEffect)(()=>
1{if((null==v?void 0:v.client_id)&&A.length>0){let e=A.find(e=>e.zc_clientsid===v.client_id);e&&ea.setValue("client",{label:e.zc_name,value:e.zc_clientsid}),void 0!==v.serviceLife&&ea.setValue("serviceLife",v.serviceLife)}},[v,A]),(0,a.useEffect)(()=>{(async()=>{try{j("clients",!0);let e=await (0,S.BP)("/zc_clientses?$select=zc_company_name,zc_name,zc_clientsid,statecode,zc_idclient,statuscode");C(e),v?v.client_id||d.Ay.error("Project version is not supported"):f(!0)}catch(e){d.Ay.error("Error retrieving clients list "+e.message)}finally{j("clients",!1)}})()},[]);let X=(0,n.wA)(),ee={},et={a5Data:{a5DemandItem:[],residuos:null},b6DemandItem:[],b7Data:{Agua_Potable:0,Agua_No_Potable:0},a4TransportDemand:{TransportItems:[]}},er=async e=>{try{X((0,k.ec)({newState:e})),X((0,I.v2)(ee)),X((0,I.bL)([])),X((0,E.OC)(et)),await (0,w.st)(),null==r||r(!1),y.push("/"),d.Ay.success("El proyecto ha sido creado correctamente")}catch(e){d.Ay.error("Ha ocurrido un error al crear el proyecto "+e.message)}},es=(0,a.useRef)(null),ea=(0,L.mN)(),en=ea.watch("client"),el=ea.watch("project"),ei=ea.watch("certificationClient");(0,a.useEffect)(()=>{if(!1===i){let e=[en,el].filter(e=>null!==e);null==u||u(e)}},[en,el,u]),(0,a.useEffect)(()=>{en&&(j("projects",!0),(0,S.BP)("".concat(W).concat(K).concat(en.value)).then(e=>{z(e),v&&e.find(e=>e.zc_refpj===v.code)&&ea.setValue("project",{label:v.code,value:v.rlProjectId})}).catch(()=>{z([])}).finally(()=>{j("projects",!1)}))},[en]),(0,a.useEffect)(()=>{_(A.filter(e=>e.zc_name.toLowerCase().includes("referencia")))},[A]),(0,a.useEffect)(()=>{var e,t;if((null==v||null==(t=v.certification)||null==(e=t.certificationClient)?void 0:e.clientId)&&D.length>0){let e=D.find(e=>{var t,r;return e.zc_clientsid===(null==(r=v.certification)||null==(t=r.certificationClient)?void 0:t.clientId)});e&&ea.setValue("certificationClient",{label:e.zc_name,value:e.zc_clientsid})}},[v,D]),(0,a.useEffect)(()=>{ei&&(j("certificationProjects",!0),(0,S.BP)("".concat(W).concat(K).concat(ei.value)).then(q).catch(()=>q([])).finally(()=>j("certificationProjects",!1)))},[ei]),(0,a.useEffect)(()=>{var e,t;if((null==v||null==(t=v.certification)||null==(e=t.certificationProject)?void 0:e.projectId)&&T.length>0){let e=T.find(e=>{var t;return e.zc_projectsid===(null==(t=v.certification)?void 0:t.certificationProject.projectId)});e&&ea.setValue("certificationProject",{label:e.zc_refpj,value:e.zc_projectsid})}},[T,v]),(0,a.useEffect)(()=>{ei||ea.setValue("certificationProject",null)},[ei]);let eo=async e=>{try{var t;if(e){let e=await G();(0,w.PE)(e)}null==(t=es.current)||t.requestSubmit()}catch(e){console.error("An error occurred:",e)}};return(0,s.jsxs)(s.Fragment,{children:[t&&(0,s.jsxs)("div",{className:"flex items-center mb-5",children:[(0,s.jsx)(F.A,{className:"bg-teal-50 text-teal-700 inline-flex rounded-lg p-3 ring-4 ring-white w-12"}),(0,s.jsx)("p",{className:"pl-3 text-base font-semibold leading-6 text-gray-900",children:"Create new project"})]}),(0,s.jsxs)("div",{className:t?"":c?"w-full h-full":"ml-5 md:w-3/6 h-full",children:[!t&&(0,s.jsxs)("div",{className:"flex justify-end",children:[(0,s.jsx)(M.A,{onClick:()=>{var e;return null==(e=es.current)?void 0:e.requestSubmit()},title:"Save",className:"w-5 cursor-pointer mr-3"}),(0,s.jsx)(V.A,{className:"w-5 cursor-pointer",title:"Delete project",onClick:()=>{h(!0)}})]}),(0,s.jsx)(L.Op,{...ea,children:(0,s.jsx)("form",{ref:es,onSubmit:ea.handleSubmit(e=>{var r,s,a,n,l,i,o,c;if(!t&&v){X((0,k.Xg)({...v,serviceLife:e.serviceLife,certification:{certificationClient:{clientId:(null==(r=e.certificationClient)?void 0:r.value)||"",clientName:(null==(s=e.certificationClient)?void 0:s.label)||""},certificationProject:{projectId:(null==(a=e.certificationProject)?void 0:a.value)||"",projectName:(null==(n=e.certificationProject)?void 0:n.label)||""}}})),d.Ay.success("Service Life and Certification updated");return}let u=P.find(t=>{var r;return t.zc_projectsid===(null==(r=e.project)?void 0:r.value)});if(u){let t=(0,O.A)();er({[t]:{id:t,type:"project",name:u.zc_name,parentId:(0,O.A)(),code:u.zc_refpj,children:[],client_id:e.client.value,rlProjectId:u.zc_projectsid,serviceLife:e.serviceLife,certification:{certificationClient:{clientId:(null==(l=e.certificationClient)?void 0:l.value)||"",clientName:(null==(i=e.certificationClient)?void 0:i.label)||""},certificationProject:{projectId:(null==(o=e.certificationProject)?void 0:o.value)||"",projectName:(null==(c=e.certificationProject)?void 0:c.label)||""}}}})}}),children:(0,s.jsxs)("div",{className:"mt-3 mb-4 grid grid-cols-1 gap-3 ".concat(c?"sm:grid-cols-2 lg:grid-cols-4":"gap-x-6 gap-y-2"),children:[(0,s.jsx)(Q.R,{loading:b("clients"),message:"Cargando clientes...",className:"min-h-[40px]",children:(0,s.jsx)(Y,{clients:A,isDisabled:!t,compact:c})}),!b("clients")&&(0,s.jsx)(Q.R,{loading:b("projects"),message:"Cargando proyectos...",className:"min-h-[40px]",children:(0,s.jsx)($,{projects:P,selectedClient:en,isDisabled:!t,compact:c})}),!b("clients")&&(0,s.jsx)(J.Y,{id:"serviceLife",label:"Service Life (years)",required:!1,register:ea.register,errors:ea.formState.errors,defaultValue:"",compact:c}),!b("clients")&&(0,s.jsx)(Y,{clients:D,label:"Certificaci\xf3n",name:"certificationClient",isRequired:!1,compact:c}),!b("clients")&&(0,s.jsx)($,{projects:T,selectedClient:null!=ei?ei:null,label:"Tipo de Certificaci\xf3n",isDisabled:!ei,name:"certificationProject",isRequired:!1,compact:c})]})})}),!g&&b("clients")&&(0,s.jsx)("div",{className:"mt-4 mb-4",children:(0,s.jsx)(Z.RH,{fields:3})}),(0,s.jsxs)("div",{className:"flex flex-col items-end",children:[t&&!i&&!u&&(0,s.jsx)(B.$,{handleOnClick:()=>{var e;return null==(e=es.current)?void 0:e.requestSubmit()},text:"Create"}),t&&i&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)("p",{className:"text-sm text-gray-500",children:"Esta acci\xf3n eliminar\xe1 el proyecto actual \xbfDeseas proceder o guardar los cambios antes de continuar?"})}),(0,s.jsxs)("div",{className:"mt-5 sm:mt-4 sm:flex sm:flex-row-reverse",children:[(0,s.jsx)(B.$,{handleOnClick:()=>eo(!1),text:"Create"}),(0,s.jsx)(B.$,{handleOnClick:()=>eo(!0),text:"Download and Create"})]})]})]})]}),(0,s.jsx)(N.A,{openModal:x,setOpenModal:h,contentComponent:(0,s.jsx)(U,{})})]})},ee=()=>{let[e,t]=(0,a.useState)(!1),[r,n]=(0,a.useState)(null),[l,i]=(0,a.useState)(""),o=[{title:"Create new project",icon:F.A,iconForeground:"text-teal-700",iconBackgroun
1d:"bg-teal-50",onClick:()=>{n("newProject"),t(!0)}},{title:"Open project",icon:D.A,iconForeground:"text-purple-700",iconBackground:"bg-purple-50",onClick:()=>{n("openProject"),t(!0)}}];return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex justify-center items-center h-screen bg-[url('/images/background-towers.jpg')] bg-cover",children:[(0,s.jsx)("div",{className:"absolute top-1 right-1 bg-white px-2 rounded-sm",children:(0,s.jsx)(v,{})}),(0,s.jsx)("div",{className:"bg-transparent justify-center m-5 divide-y divide-gray-200 overflow-hidden rounded-lg bg-gray-200 sm:grid sm:grid-cols-2 sm:gap-2 sm:divide-y-0",children:o.map(e=>(0,s.jsxs)("div",{className:"group relative bg-white p-6 focus-within:ring-2 focus-within:ring-inset focus-within:ring-indigo-500 sm:rounded",onClick:()=>{e.onClick&&(e.onClick(),i(e.title))},children:[(0,s.jsx)("div",{children:(0,s.jsx)("span",{className:(0,w.xW)(e.iconBackground,e.iconForeground,"inline-flex rounded-lg p-3 ring-4 ring-white"),children:(0,s.jsx)(e.icon,{className:"h-6 w-6","aria-hidden":"true"})})}),(0,s.jsxs)("div",{className:"mt-8",children:[(0,s.jsx)("h3",{className:"text-base font-semibold leading-6 text-gray-900",children:e.title}),(0,s.jsx)("p",{className:"mt-2 text-sm text-gray-500",children:"Doloribus dolores nostrum quia qui natus officia quod et dolorem. Sit repellendus qui ut at blanditiis et quo et molestiae."})]}),(0,s.jsx)("span",{className:"pointer-events-none absolute right-6 top-6 text-gray-300 group-hover:text-gray-400","aria-hidden":"true",children:(0,s.jsx)("svg",{className:"h-6 w-6",fill:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M20 4h1a1 1 0 00-1-1v1zm-1 12a1 1 0 102 0h-2zM8 3a1 1 0 000 2V3zM3.293 19.293a1 1 0 101.414 1.414l-1.414-1.414zM19 4v12h2V4h-2zm1-1H8v2h12V3zm-.707.293l-16 16 1.414 1.414 16-16-1.414-1.414z"})})})]},e.title))})]}),(0,s.jsx)(N.A,{setOpenModal:t,openModal:e,contentComponent:"newProject"===r?(0,s.jsx)(X,{isModal:!0,setOpenModal:()=>{n(null),t(!1)},beFormRendered:!0}):"openProject"===r?(0,s.jsx)(T,{inputValue:l,setOpenModal:e=>t(!!e)}):null})]})};var et=r(52166),er=r(39769),es=r(68399),ea=r(75550),en=r(69326),el=r(95108),ei=r(18430),eo=r(39436),ec=r(69240),ed=r(84544),eu=r(93216),em=r(43569),ep=r(78207),ex=r
1(52619),eh=r.n(ex);let eg=e=>{let{isVisible:t,message:r="Generando ficheros de la exportaci\xf3n...",progress:a}=e;return t?(0,s.jsx)("div",{className:"fixed inset-0 z-[10050] flex items-center justify-center bg-black bg-opacity-50",children:(0,s.jsx)("div",{className:"bg-white rounded-lg p-8 max-w-md w-full mx-4 shadow-xl",children:(0,s.jsxs)("div",{className:"flex flex-col items-center space-y-6",children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("div",{className:"w-16 h-16 border-4 border-gray-200 border-t-green-600 rounded-full animate-spin"}),(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,s.jsx)("div",{className:"w-8 h-8 border-2 border-gray-200 border-t-green-400 rounded-full animate-spin animate-reverse"})})]}),(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:r}),(0,s.jsx)("p",{className:"text-sm text-gray-600",children:"Por favor, espera mientras se procesan los archivos..."})]}),void 0!==a&&(0,s.jsxs)("div",{className:"w-full",children:[(0,s.jsxs)("div",{className:"flex justify-between text-sm text-gray-600 mb-2",children:[(0,s.jsx)("span",{children:"Progreso"}),(0,s.jsxs)("span",{children:[Math.round(a),"%"]})]}),(0,s.jsx)("div",{className:"w-full bg-gray-200 rounded-full h-2",children:(0,s.jsx)("div",{className:"bg-green-600 h-2 rounded-full transition-all duration-300 ease-out",style:{width:"".concat(a,"%")}})})]}),(0,s.jsxs)("div",{className:"flex space-x-1",children:[(0,s.jsx)("div",{className:"w-2 h-2 bg-green-600 rounded-full animate-bounce"}),(0,s.jsx)("div",{className:"w-2 h-2 bg-green-600 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),(0,s.jsx)("div",{className:"w-2 h-2 bg-green-600 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})]})})}):null};var ef=r(99399),ey=r(9349),ej=r.n(ey);let eb=e=>{let{tooltipText:t,children:r,className:a="",disabled:n=!1}=e;return(0,s.jsxs)("span",{className:"relative group inline-block",children:[(0,s.jsx)("span",{className:a,children:r}),n&&(0,s.jsx)("span",{className:"absolute left-0 translate-x-6 top-full mt-2 hidden group-hover:block pointer-events-none bg-[#090B0D]/70 text-white text-xs rounded py-1 px-2 whitespace-nowrap z-20",children:t})]})};var ev=r(25150);let eN=()=>{let e=(0,R.useRouter)(),[t,r]=(0,a.useState)(!1),[l,i]=(0,a.useState)(""),[o,c]=(0,a.useState)(""),[u,m]=(0,a.useState)(!1),[p,x]=(0,a.useState)(!1),h=(0,a.useRef)(null),f=(0,a.useRef)(null),y=(0,a.useRef)(null),j=(0,a.useRef)(null),[b,A]=(0,a.useState)([]),[C,k]=(0,a.useState)(!1),[I,P]=(0,a.useState)(""),[E,z]=(0,a.useState)(void 0),[D,_]=(0,a.useState)(null),S=(0,n.d4)(e=>
1e.projectVariants.projectVariants.length),{a4Data:L,a5Data:O,b7Data:F,b6List:M}=(0,ev.P)();(0,a.useEffect)(()=>{let e=e=>{h.current&&f.current&&e.target instanceof Node&&!h.current.contains(e.target)&&!f.current.contains(e.target)&&m(!1),y.current&&j.current&&e.target instanceof Node&&!y.current.contains(e.target)&&!j.current.contains(e.target)&&x(!1)};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}},[]);let V=e=>{e.submenu||(e.onClick&&e.onClick(),i(e.name),m(!1),x(!1),_(null))},B=()=>{m(!u),p&&x(!1)},q=()=>{x(!p),u&&m(!1)},W=async()=>{let e=await (0,ef.E8)({a5Data:O,b6DemandItem:M,b7Data:F,a4TransportDemand:L});if(!e.length)return void d.Ay.error("No hay datos de impactos para exportar");let t=new Blob([ej().unparse(e,{delimiter:" "})],{type:"text/csv;charset=utf-8;"}),r=URL.createObjectURL(t),s=document.createElement("a");s.href=r,s.download="4_Impacts.csv",s.click(),URL.revokeObjectURL(r)},U=async(e,t)=>{try{k(!0),P(t),z(void 0),m(!1),x(!1),await e(),d.Ay.success("Operaci\xf3n completada correctamente")}catch(e){console.error("Error during export operation:",e),d.Ay.error("Ha ocurrido un error durante la operaci\xf3n")}finally{k(!1),P(""),z(void 0)}},K=[{name:"New project",description:"Create new project from scratch",icon:el.A,onClick:()=>{r(!0),c("New project")}},{name:"Open project",description:"Open project from file",icon:ei.A,onClick:()=>{r(!0),c("Open project")}},{name:"New project from file",description:"Create new project from file",icon:eo.A,onClick:()=>{c("New project from file"),r(!0)}},{name:"Download project",description:"Download project in json file",icon:ec.A,onClick:()=>{U(async()=>{P("Generando archivo JSON del proyecto...");let e=await G();(0,w.PE)(e)},"Generando archivo JSON del proyecto...")}},{name:"Export project",description:"Export project in csv files",icon:ed.A,onClick:()=>{U(async()=>{P("Generando archivos CSV de tipos..."),await (0,w.SI)(),P("Generando archivos CSV de opciones..."),await (0,w.ZU)(),P("Generando archivos CSV de tipos de referencia..."),await (0,w.p_)(),P("Generando archivos CSV de comentarios..."),await (0,w.Pv)()},"Generando ficheros de la exportaci\xf3n...")}},{name:"Export impacts",description:"Export impacts in csv file",icon:eu.A,disabled:0===S,tooltip:"Debes tener al menos 1 variante configurada para exportar impactos",onClick:()=>{U(async()=>{P("Generando archivo CSV de impactos..."),await W()},"Generando ficheros de la exportaci\xf3n...")}}],Y=[{name:"Update global settings",description:"Upload 0_Categor\xedas.csv",icon:el.A,onClick:()=>{r(!0),c("Update global settings")}},{name:"Update project settings",description:"Download settings from the cloud and update the current project",icon:ei.A,onClick:()=>{U(async()=>{P("Descargando configuraci\xf3n del proyecto...");let e=await G();(0,w.PE)(e),P("Actualizando configuraci\xf3n desde la nube..."),await (0,w.st)()},"Actualizando configuraci\xf3n del proyecto...")}},{name:"Edit layer functions",description:"Create, edit or delete layerFunctions from the cloud",icon:ec.A,onClick:()=>{e.push("/layerFunction/")}},{name:"Edit composite templates",description:"Create, edit or delete composite templates from the cloud",icon:ed.A,submenu:[{name:"Cimentaciones",onClick:()=>{e.push("/compositeTemplates?kind=foundation")}},{name:"Pilares",onClick:()=>{e.push("/compositeTemplates?kind=pillar")}},{name:"Vigas",onClick:()=>{e.push("/compositeTemplates?kind=beam")}},{name:"Barandillas",onClick:()=>{e.push("/compositeTemplates?kind=railing")}},{name:"Shading",onClick:()=>{e.push("/compositeTemplates?kind=shading")}}]}];return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(et.E,{as:"nav",className:"bg-white shadow-lg",ref:h,children:e=>{let{open:t}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"mx-auto md:max-w-full z-[10050] max-w-7xl px-4 sm:px-6 lg:px-8 flex justify-between items-center",children:(0,s.jsxs)("div",{className:"flex h-16 md:ml-40 justify-between w-full",children:[(0,s.jsxs)("div",{className:"flex",children:[(0,s.jsx)("div",{className:"flex flex-shrink-0 items-center",children:(0,s.jsx)(eh(),{href:"/",children:(0,s.jsx)(g.default,{className:"h-12 w-auto lg:block rounded-full",src:"/images/logo.png",alt:"Zero logo",width:100,height:100,priority:!0})})}),(0,s.jsxs)("div",{className:"hidden sm:ml-6 sm:flex sm:space-x-8 justify-center items-center",children:[(0,s.jsxs)(er.A,{className:"relative",children:[(0,s.jsxs)(er.A.Button,{ref:h,onClick:B,className:"inline-flex items-center gap-x-1 text-sm font-semibold leading-6 text-white",children:[(0,s.jsx)("span",{className:"leading-6 text-gray-900",children:"PROJECT"}),(0,s.jsx)(ea.A,{className:"h-5 w-5 text-gray-950","aria-hidden":"true"})]}),(0,s.jsx)(es.e,{as:a.Fragment,show:u,enter:"transition ease-out duration-200",enterFrom:"opacity-0 translate-y-1",enterTo:"opacity-100 translate-y-0",leave:"transition ease-in duration-150",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 translate-y-1",children:(0,s.jsx)(er.A.Panel,{ref:f,className:"absolute left-1/2 z-[10050] mt-5 flex w-screen max-w-max -translate-x-1/2 px-4",children:(0,s.jsx)("div",{className:"w-screen max-w-md flex-auto overflow-visible rounded-3xl bg-white text-sm leading-6 shadow-lg ring-1 ring-gray-900/5",children:(0,s.jsx)("div",{className:"p-4",children:K.map(e=>{let t=e.disabled;return(0,s.jsx)(eb,{tooltipText:e.tooltip||"",disabled:t,className:"w-full",children:(0,s.jsxs)("div",{className:"group relative flex gap-x-6 rounded-lg p-4 ".concat(t?"opacity-40 cursor-not-allowed":"hover:bg-gray-50 cursor-pointer"),onClick:()=>{t||V(e)},children:[(0,s.jsx)("div",{className:"mt-1 flex h-11 w-11 flex-none items-center justify-center rounded-lg bg-gray-50 ".concat(t?"":"group-hover:bg-white"),children:(0,s.jsx)(e.icon,{className:"h-6 w-6 text-gray-600 ".concat(t?"":"group-hover:text-green-zero"),"aria-hidden":"true"})}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsxs)("div",{className:"font-semibold text-gray-900",children:[(0,s.jsx)("p",{children:e.name}),(0,s.jsx)("span",{className:"absolute inset-0"})]}),(0,s.jsx)("p",{className:"mt-1 text-gray-600",children:e.description})]})]},e.name)},e.name)})})})})})]}),(0,s.jsxs)(er.A,{className:"relative",children:[(0,s.jsxs)(er.A.Button,{ref:y,onClick:q,className:"inline-flex items-center gap-x-1 text-sm font-semibold leading-6 text-white",children:[(0,s.jsx)("span",{className:"leading-6 text-gray-900",children:"SETTINGS"}),(0,s.jsx)(ea.A,{className:"h-5 w-5 text-gray-900","aria-hidden":"true"})]}),(0,s.jsx)(es.e,{as:a.Fragment,show:p,enter:"transition ease-out duration-200",enterFrom:"opacity-0 translate-y-1",enterTo:"opacity-100 translate-y-0",leave:"transition ease-in duration-150",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 translate-y-1",children:(0,s.jsx)(er.A.Panel,{ref:j,className:"absolute left-1/2 z-[10050] mt-5 flex w-screen max-w-max -translate-x-1/2 px-4",children:(0,s.jsx)("div",{className:"w-screen max-w-md flex-auto bg-white text-sm leading-6 shadow-lg overflow-visible",children:(0,s.jsx)("div",{className:"p-4 rounded-3xl r
1ing-1 ring-gray-900/5",children:Y.map(e=>(0,s.jsxs)("div",{className:"group relative",onMouseEnter:()=>e.submenu&&_(e.name),onMouseLeave:()=>e.submenu&&_(null),children:[(0,s.jsxs)("div",{className:"relative flex gap-x-6 rounded-lg p-4 hover:bg-gray-50",onClick:()=>V(e),children:[(0,s.jsx)("div",{className:"mt-1 flex h-11 w-11 flex-none items-center justify-center rounded-lg bg-gray-50 group-hover:bg-white",children:(0,s.jsx)(e.icon,{className:"h-6 w-6 text-gray-600 group-hover:text-green-zero","aria-hidden":"true"})}),(0,s.jsxs)("div",{className:"cursor-pointer flex-1",children:[(0,s.jsxs)("div",{className:"font-semibold text-gray-900 flex items-center justify-between",children:[(0,s.jsx)("p",{children:e.name}),e.submenu&&(0,s.jsx)(en.A,{className:"h-5 w-5 text-gray-400","aria-hidden":"true"})]}),(0,s.jsx)("p",{className:"mt-1 text-gray-600",children:e.description})]})]}),e.submenu&&D===e.name&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"absolute left-full top-0 -ml-2 w-4 h-full"}),(0,s.jsx)("div",{className:"absolute left-full top-0 ml-2 w-64 rounded-lg bg-white shadow-xl ring-1 ring-gray-900/10 z-[10050]",children:(0,s.jsx)("ul",{className:"p-2",children:e.submenu.map(e=>(0,s.jsx)("li",{className:"px-4 py-3 hover:bg-gray-50 rounded-md cursor-pointer text-gray-900 font-medium",onClick:()=>{e.onClick(),x(!1),_(null)},children:e.name},e.name))})})]})]},e.name))})})})})]})]})]}),(0,s.jsx)(v,{}),(0,s.jsx)("div",{className:"-mr-2 flex items-center sm:hidden",children:(0,s.jsxs)(et.E.Button,{className:"inline-flex items-center justify-center rounded-md p-2 hover:bg-gray-100 text-gray-500 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-indigo-500",children:[(0,s.jsx)("span",{className:"sr-only",children:"Open main menu"}),t?(0,s.jsx)(em.A,{className:"block h-6 w-6","aria-hidden":"true"}):(0,s.jsx)(ep.A,{className:"block h-6 w-6","aria-hidden":"true"})]})})]})}),(0,s.jsx)(et.E.Panel,{className:"sm:hidden",children:(0,s.jsxs)("div",{className:"space-y-1 pb-3 pt-2",children:[(0,s.jsxs)(er.A,{className:"relative",children:[(0,s.jsxs)(er.A.Button,{ref:h,onClick:B,className:"inline-flex items-center gap-x-1 text-sm font-semibold leading-6 text-white",children:[(0,s.jsx)("span",{className:"block border-l-4 py-2 pl-3 text-base font-medium text-gray-900 border-transparent",children:"Project"}),(0,s.jsx)(ea.A,{className:"h-5 w-5 text-gray-900","aria-hidden":"true"})]}),(0,s.jsx)(es.e,{as:a.Fragment,show:u,enter:"transition ease-out duration-200",enterFrom:"opacity-0 translate-y-1",enterTo:"opacity-100 translate-y-0",leave:"transition ease-in duration-150",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 translate-y-1",children:(0,s.jsx)(er.A.Panel,{ref:f,className:"absolute left-1/2 z-10 mt-5 flex w-screen max-w-min -translate-x-1/2 px-4",children:(0,s.jsx)("div",{className:"w-56 shrink rounded-xl bg-white p-4 text-sm font-semibold leading-6 text-gray-900 shadow-lg ring-1",children:K.map(e=>(0,s.jsx)("a",{className:"block p-2 hover:text-green-zero",onClick:()=>V(e),children:e.name},e.name))})})})]}),(0,s.jsxs)(er.A,{className:"relative",children:[(0,s.jsxs)(er.A.Button,{ref:y,onClick:q,className:"inline-flex items-center gap-x-1 text-sm font-semibold leading-6 text-white",children:[(0,s.jsx)("span",{className:"block border-l-4 py-2 pl-3 text-base font-medium text-gray-900 border-transparent",children:"Settings"}),(0,s.jsx)(ea.A,{className:"h-5 w-5 text-gray-900","aria-hidden":"true"})]}),(0,s.jsx)(es.e,{as:a.Fragment,show:p,enter:"transition ease-out duration-200",enterFrom:"opacity-0 translate-y-1",enterTo:"opacity-100 translate-y-0",leave:"transition ease-in duration-150",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 translate-y-1",children:(0,s.jsx)(er.A.Panel,{ref:j,className:"absolute left-1/2 z-10 mt-5 flex w-screen max-w-min -translate-x-1/2 px-4",children:(0,s.jsx)("div",{className:"w-56 shrink rounded-xl bg-white p-4 text-sm font-semibold leading-6 text-gray-900 shadow-lg ring-1",children:Y.map(e=>(0,s.jsxs)("div",{children:[(0,s.jsxs)("a",{className:"block p-2 hover:text-green-zero cursor-pointer flex items-center justify-between",onClick:()=>{e.submenu?_(D===e.name?null:e.name):V(e)},children:[(0,s.jsx)("span",{children:e.name}),e.submenu&&(0,s.jsx)(ea.A,{className:"h-4 w-4 transition-transform ".concat(D===e.name?"rotate-180":"")})]}),e.submenu&&D===e.name&&(0,s.jsx)("ul",{className:"ml-4 mt-1 space-y-1",children:e.submenu.map(e=>(0,s.jsx)("li",{className:"p-2 hover:text-green-zero cursor-pointer text-sm",onClick:()=>{e.onClick(),x(!1),_(null)},children:e.name},e.name))})]},e.name))})})})]})]})})]})}}),(0,s.jsx)(N.A,{setOpenModal:r,openModal:t,contentComponent:"New project"===o?(0,s.jsx)(X,{isModal:!0,setOpenModal:r,isNewProject:!0}):"Open project"===o||"Update global settings"===o?(0,s.jsx)(T,{inputValue:l,setOpenModal:e=>r(!!e)}):"New project from file"===o?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(X,{isModal:!0,setOpenModal:r,isNewProject:!1,onClientProjectDataChange:A}),(0,s.jsx)(T,{inputValue:l,setOpenModal:e=>r(!!e),clientProjectData:b})," "]}):null}),(0,s.jsx)(eg,{isVisible:C,message:I,progress:E})]})};var ew=r(98953),eA=r(36834),eC=r(70498),ek=r(47650);let eI=e=>{let{options:t,selectedValues:r,onChange:n,placeholder:l="Select..."}=e,[i,o]=(0,a.useState)(!1),c=(0,a.useRef)(null),d=(0,a.useRef)(null),[u,m]=(0,a.useState)(null);(0,a.useEffect)(()=>{let e=e=>{let t=d.current&&d.current.contains(e.target),r=c.current&&c.current.contains(e.target);t||r||i&&o(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]),(0,a.useEffect)(()=>
1{if(!i||!d.current)return;let e=()=>{if(!d.current)return;let e=d.current.getBoundingClientRect();m({top:e.bottom+window.scrollY+4,left:e.left+window.scrollX,width:e.width,maxWidth:window.innerWidth-20})};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[i]);let p=0===r.length?l:r.length===t.length?"All":"".concat(r.length," selected");return(0,s.jsxs)("div",{className:"relative w-full",children:[(0,s.jsxs)("button",{type:"button",ref:d,onClick:()=>o(!i),className:"w-full px-2.5 py-2 text-xs border-2 border-gray-300 rounded-lg bg-white text-left flex items-center justify-between hover:border-gray-400 transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 pointer-events-auto",children:[(0,s.jsx)("span",{className:"truncate font-medium text-gray-700",children:p}),(0,s.jsx)("svg",{className:"h-4 w-4 text-gray-500 flex-shrink-0 transition-transform ".concat(i?"rotate-180":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M19 9l-7 7-7-7"})})]}),i&&u&&(0,ek.createPortal)((0,s.jsxs)("div",{className:"fixed bg-white border-2 border-gray-300 rounded-lg shadow-2xl max-h-80 overflow-y-auto z-[99999] pointer-events-auto",ref:c,style:{top:u.top,left:u.left,width:u.width,maxWidth:"calc(100vw - 20px)"},children:[(0,s.jsx)("div",{className:"sticky top-0 bg-gradient-to-r from-blue-50 to-blue-100 border-b-2 border-blue-200 px-3 py-2.5",children:(0,s.jsxs)("label",{className:"flex items-center text-xs sm:text-sm hover:bg-blue-200 cursor-pointer rounded px-1 py-1 transition-colors pointer-events-auto",children:[(0,s.jsx)("input",{type:"checkbox",checked:r.length===t.length,onChange:()=>{r.length===t.length?n([]):n([...t])},className:"mr-2.5 w-4 h-4 rounded cursor-pointer pointer-events-auto"}),(0,s.jsx)("span",{className:"font-bold text-gray-800",children:"Select All"})]})}),(0,s.jsx)("div",{className:"py-1",children:t.map(e=>(0,s.jsxs)("label",{className:"flex items-center px-3 py-2 text-xs sm:text-sm hover:bg-blue-50 cursor-pointer font-medium transition-colors pointer-events-auto",children:[(0,s.jsx)("input",{type:"checkbox",checked:r.includes(e),onChange:()=>(e=>{r.includes(e)?n(r.filter(t=>t!==e)):n([...r,e])})(e),className:"mr-2.5 w-4 h-4 rounded cursor-pointer pointer-events-auto"}),(0,s.jsx)("span",{className:"truncate text-gray-700",children:e})]},e))})]}),document.body)]})},eP=(e,t)=>e&&""!==e.trim()?e.trim():t&&""!==t.trim()?t.trim():"-",eE=e=>{let{row:t}=e,{isExpired:r,formattedDate:a}=(0,C.ZO)(t.epdValid);return(0,s.jsxs)("span",{className:"inline-flex items-center justify-center gap-1",children:[(0,s.jsx)("span",{className:"truncate",children:t.epdKey}),r&&(0,s.jsx)(q.A,{className:"h-4 w-4 flex-shrink-0 text-amber-500",title:"EPD expired: ".concat(a)})]})},ez=e=>{let{label:t,options:r,selectedValues:a,onChange:n}=e;return(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-[10px] font-semibold text-gray-600 mb-1.5 uppercase tracking-wide",children:t}),(0,s.jsx)(eI,{options:r,selectedValues:a,onChange:n,placeholder:"Filter..."})]})},eD=e=>{let{mode:t,showCategoryColumn:r,filters:a,uniqueValues:n,onFilterChange:l}=e;return"mobile"===t?(0,s.jsx)("div",{className:"mb-3 p-3 bg-gradient-to-br from-gray-50 to-gray-100 border border-gray-200 rounded-lg relative z-40",children:(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-3",children:[r&&(0,s.jsx)(ez,{label:"Category",options:n.category,selectedValues:a.category,onChange:e=>l("category",e)}),(0,s.jsx)(ez,{label:"Type",options:n.type,selectedValues:a.type,onChange:e=>l("type",e)}),(0,s.jsx)(ez,{label:"Option",options:n.option,selectedValues:a.option,onChange:e=>l("option",e)}),(0,s.jsx)(ez,{label:"Resource",options:n.resource,selectedValues:a.resource,onChange:e=>l("resource",e)}),(0,s.jsx)(ez,{label:"Thickness",options:n.thickness,selectedValues:a.thickness,onChange:e=>l("thickness",e)}),(0,s.jsx)(ez,{label:"EPD",options:n.epd,selectedValues:a.epd,onChange:e=>l("epd",e)})]})}):(0,s.jsxs)("tr",{className:"bg-gray-50 border-t-2 border-gray-200",children:[r&&(0,s.jsx)("th",{className:"py-2.5 pl-4 pr-3",children:(0,s.jsx)(eI,{options:n.category,selectedValues:a.category,onChange:e=>l("category",e),placeholder:"Filter..."})}),(0,s.jsx)("th",{className:"".concat(r?"px-3":"py-2.5 pl-4 pr-3"," py-2.5"),
1children:(0,s.jsx)(eI,{options:n.type,selectedValues:a.type,onChange:e=>l("type",e),placeholder:"Filter..."})}),(0,s.jsx)("th",{className:"px-3 py-2.5",children:(0,s.jsx)(eI,{options:n.option,selectedValues:a.option,onChange:e=>l("option",e),placeholder:"Filter..."})}),(0,s.jsx)("th",{className:"px-3 py-2.5",children:(0,s.jsx)(eI,{options:n.resource,selectedValues:a.resource,onChange:e=>l("resource",e),placeholder:"Filter..."})}),(0,s.jsx)("th",{className:"px-3 py-2.5",children:(0,s.jsx)(eI,{options:n.thickness,selectedValues:a.thickness,onChange:e=>l("thickness",e),placeholder:"Filter..."})}),(0,s.jsx)("th",{className:"px-3 py-2.5",children:(0,s.jsx)(eI,{options:n.epd,selectedValues:a.epd,onChange:e=>l("epd",e),placeholder:"Filter..."})})]})},e_=e=>{let{row:t,isEdited:r,currentThickness:a,showCategoryColumn:n,onThicknessChange:l,onThicknessBlur:i}=e;return(0,s.jsxs)("div",{className:"rounded-xl border-2 px-4 py-4 shadow-sm transition-all ".concat(r?"border-yellow-400 bg-yellow-50 shadow-md":"border-gray-200 bg-white hover:shadow-md hover:border-gray-300"),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2 mb-3 pb-3 border-b border-gray-100",children:[(0,s.jsx)(eh(),{href:{pathname:"/category/".concat(t.categoryId),query:{typeId:t.typeId,optionId:t.optionId}},className:"font-bold text-blue-600 hover:text-blue-700 hover:underline leading-tight text-sm flex-1",children:t.optionName}),(0,s.jsx)("div",{className:"flex items-center gap-2 flex-shrink-0 ml-2",children:t.isOptionWip&&(0,s.jsx)(eA.A,{className:"h-5 w-5 text-amber-500",title:"Work in progress"})})]}),(0,s.jsxs)("div",{className:"space-y-2.5 text-sm",children:[n&&(0,s.jsxs)("div",{className:"flex justify-between items-start",children:[(0,s.jsx)("span",{className:"text-gray-500 font-medium min-w-fit mr-3",children:"Category:"}),(0,s.jsx)("span",{className:"text-gray-800 font-medium text-right break-words",children:t.categoryName})]}),(0,s.jsxs)("div",{className:"flex justify-between items-start",children:[(0,s.jsx)("span",{className:"text-gray-500 font-medium min-w-fit mr-3",children:"Type:"}),(0,s.jsx)("span",{className:"text-gray-800 font-medium text-right break-words",children:t.typeName})]}),(0,s.jsxs)("div",{className:"flex justify-between items-start",children:[(0,s.jsx)("span",{className:"text-gray-500 font-medium min-w-fit mr-3",children:"Resource:"}),(0,s.jsx)("span",{className:"text-gray-700 text-right break-words",children:t.resourceName})]}),(0,s.jsxs)("div",{className:"flex justify-between items-start",children:[(0,s.jsx)("span",{className:"text-gray-500 font-medium min-w-fit mr-3",children:"EPD Key:"}),(0,s.jsx)("span",{className:"text-gray-700 text-right break-words font-medium",children:(0,s.jsx)(eE,{row:t})})]}),(0,s.jsxs)("div",{className:"pt-2 border-t border-gray-100 flex justify-between items-center gap-3",children:[(0,s.jsx)("span",{className:"text-gray-500 font-medium",children:"Thickness (m):"}),(0,s.jsx)("div",{className:"flex-1 flex justify-end",children:t.isMonomaterial?(0,s.jsx)("input",{type:"number",step:"0.001",min:"0",value:a,onChange:e=>l(t.rowKey,e.target.value),onBlur:e=>i(t.rowKey,e.target.value),className:"w-24 px-3 py-2 text-sm font-semibold border-2 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-400 transition-all ".concat(r?"border-yellow-400 bg-yellow-100 text-yellow-900":"border-gray-300 bg-white text-gray-900")}):(0,s.jsx)("span",{className:"text-gray-800 font-semibold text-lg",children:t.thickness})})]})]})]})},eS=e=>{let{row:t,isEdited:r,currentThickness:a,showCategoryColumn:n,isAlternateTypeGroup:l,isFirstRow:i,startsCategoryGroup:o,startsOptionGroup:c,onThicknessChange:d,onThicknessBlur:u}=e;return(0,s.jsxs)("tr",{className:"transition-colors ".concat(r?"bg-yellow-100 hover:bg-yellow-200":l?"bg-gray-50 hover:bg-gray-100":"bg-white hover:bg-gray-50"," ").concat(i?"":o?"border-t-4 border-gray-500":c?"border-t-2 border-dashed border-gray-400":"border-t border-gray-200"),children:[n&&(0,s.jsx)("td",{className:"py-1.5 pl-4 pr-3 text-xs text-gray-900 font-medium max-w-[6rem] truncate leading-tight",title:t.categoryName,children:t.categoryName}),(0,s.jsx)("td",{className:"".concat(n?"px-3":"py-1.5 pl-4 pr-3"," py-1.5 text-xs text-gray-900 font-medium max-w-[7rem] truncate leading-tight"),title:t.typeName,children:t.typeName}),(0,s.jsx)("td",{className:"px-3 py-1.5 text-xs text-gray-900 font-medium leading-tight",children:(0,s.jsxs)(eh(),{href:{pathname:"/category/".concat(t.categoryId),query:{typeId:t.typeId,optionId:t.optionId}},className:"inline-flex items-center gap-1.5 text-blue-600 hover:text-blue-800 hover:underline font-semibold",title:t.optionName,children:[(0,s.jsx)("span",{className:"truncate max-w-[10rem]",children:t.optionName}),t.isOptionWip&&(0,s.jsx)(eA.A,{className:"h-4 w-4 flex-shrink-0 text-amber-500",title:"Work in progress"})]})}),(0,s.jsx)("td",{className:"px-3 py-1.5 text-xs text-gray-700 font-medium truncate max-w-xs leading-tight",title:t.resourceName,children:t.resourceName}),(0,s.jsx)("td",{className:"px-3 py-1.5 text-xs text-center",children:t.isMonomaterial?(0,s.jsx)("input",{type:"number",step:"0.001",min:"0",value:a,onChange:e=>d(t.rowKey,e.target.value),onBlur:e=>u(t.rowKey,e.target.value),className:"w-16 px-2 py-1 text-xs font-semibold border-2 rounded-md focus:outline-none focus:ring-1 focus:ring-offset-1 transition-all ".concat(r?"border-yellow-500 bg-yellow-100 text-yellow-900":"border-gray-300 bg-white text-gray-900")}):(0,s.jsx)("span",{className:"text-gray-800 font-semibold text-xs",children:t.thickness})}),(0,s.jsx)("td",{className:"px-3 py-1.5 text-xs text-center text-gray-800 font-medium leading-tight",title:t.epdKey,children:(0,s.jsx)(eE,{row:t})})]})},eR=e=>!!e&&![k.Yd.Puertas,k.Yd.Ventanas,k.Yd.ProteccionesSolares,k.Yd.Barandillas,k.Yd.Cimentacion,k.Yd.Pilares,k.Yd.Vigas].includes(e),eT=e=>{let{categoryId:t}=e,r=!t,[n,l]=(0,a.useState)([]),[o,c]=(0,a.useState)(!0),[u,m]=(0,a.useState)(!1),[p,x]=(0,a.useState)({category:[],type:[],option:[],resource:[],thickness:[],epd:[]}),[h,g]=(0,a.useState)(new Map),[f,y]=(0,a.useState)(new Map),j=async()=>{let e=i.store.getState().treeObjects,r=(0,w.t9)(e),s=e[r],a=[],n=new Map;for(let r of s.children){let s=e[r];if(!t||s.id===t)for(let t of s.children){let r=e[t];for(let t of r.children){let l=e[t];
1eR(s.name)?(await (0,C.bY)(t.toString())).forEach(e=>{let i=1===e.resources.length&&void 0!==e.resources[0].name&&""!==e.resources[0].name;i&&n.set(e.id,e),e.resources.forEach((n,o)=>{let c=n.settingsResource.name||"-";a.push({categoryId:s.id,categoryName:s.name||"",typeId:r.id,typeName:r.name||"",optionId:t,optionName:l.name||"",isOptionWip:"option"===l.type&&l.status===k.aF.WIP,resourceName:c,thickness:(0,eC.sp)(n.measurement).toString(),isMonomaterial:i,rowKey:e.id,renderKey:"".concat(e.id,"-").concat(o),epdKey:eP(n.settingsResource.epdKey,n.settingsResource.epdkeyId),epdValid:n.settingsResource.epdValid})})}):(await (0,w.Mm)(s.name,t.toString())).forEach(e=>{let n=e.settingsResource.name||"-",i="".concat(t,"-").concat(n);a.push({categoryId:s.id,categoryName:s.name||"",typeId:r.id,typeName:r.name||"",optionId:t,optionName:l.name||"",isOptionWip:"option"===l.type&&l.status===k.aF.WIP,resourceName:n,thickness:(0,eC.sp)(e.measurement).toString(),isMonomaterial:!1,rowKey:i,renderKey:i,epdKey:eP(e.settingsResource.epdKey,e.settingsResource.epdkeyId),epdValid:e.settingsResource.epdValid})})}}}return{rows:a,layerMap:n}};(0,a.useEffect)(()=>{(async()=>{c(!0);try{let{rows:e,layerMap:t}=await j();l(e),y(t)}catch(e){d.Ay.error("Error loading project data"),console.error(e)}finally{c(!1)}})()},[t]);let b=(0,a.useMemo)(()=>e=>n.filter(t=>{let r="category"===e||0===p.category.length||p.category.includes(t.categoryName),s="type"===e||0===p.type.length||p.type.includes(t.typeName),a="option"===e||0===p.option.length||p.option.includes(t.optionName),n="resource"===e||0===p.resource.length||p.resource.includes(t.resourceName),l="thickness"===e||0===p.thickness.length||p.thickness.includes(t.thickness),i="epd"===e||0===p.epd.length||p.epd.includes(t.epdKey);return r&&s&&a&&n&&l&&i}),[n,p]),v=(0,a.useMemo)(()=>({category:[...new Set(b("category").map(e=>e.categoryName))].sort(),type:[...new Set(b("type").map(e=>e.typeName))].sort(),option:[...new Set(b("option").map(e=>e.optionName))].sort(),resource:[...new Set(b("resource").map(e=>e.resourceName))].sort(),thickness:[...new Set(b("thickness").map(e=>e.thickness))].sort(),epd:[...new Set(b("epd").map(e=>e.epdKey))].filter(e=>e&&""!==e.trim()).sort()}),[b]),N=(0,a.useMemo)(()=>n.filter(e=>{let t=0===p.category.length||p.category.includes(e.categoryName),r=0===p.type.length||p.type.includes(e.typeName),s=0===p.option.length||p.option.includes(e.optionName),a=0===p.resource.length||p.resource.includes(e.resourceName),n=0===p.thickness.length||p.thickness.includes(e.thickness),l=0===p.epd.length||p.epd.includes(e.epdKey);return t&&r&&s&&a&&n&&l}),[n,p]),A=(e,t)=>{x(r=>({...r,[e]:t}))},I=(e,t)=>{""!==t&&(isNaN(parseFloat(t))||0>parseFloat(t)||g(r=>{let s=new Map(r);return s.set(e,t),s}))},P=(e,t)=>{(e=>{if(""===e.trim())return!1;let t=parseFloat(e);return!isNaN(t)&&t>0})(t)||(g(t=>{let r=new Map(t);return r.delete(e),r}),d.Ay.error("Thickness must be a positive number"))},E=e=>{var t;return null!=(t=h.get(e.rowKey))?t:e.thickness},z=e=>h.has(e),D=async()=>{if(0!==h.size){m(!0);try{h.forEach((e,t)=>{let r=f.get(t);if(!r)return;let s={...r,thickness:parseFloat(e)};(0,C.Mn)(s)}),d.Ay.success("".concat(h.size," espesor").concat(h.size>1?"es":""," actualizado").concat(h.size>1?"s":""," correctamente")),g(new Map);let{rows:e,layerMap:t}=await j();l(e),y(t)}catch(e){console.error("Error saving changes:",e),d.Ay.error("Error saving changes")}finally{m(!1)}}},[_,S]=(0,a.useState)(!1),[R,T]=(0,a.useState)(()=>window.matchMedia("(min-width: 780px)").matches);(0,a.useEffect)(()=>{let e=window.matchMedia("(min-width: 780px)"),t=e=>{T(e.matches)};return T(e.matches),e.addEventListener("change",t),()=>{e.removeEventListener("change",t)}},[]);let L=(0,a.useMemo)(()=>{let e=-1,t="",r="",s="";return N.map((a,n)=>{let l=a.categoryName!==t,i=l||a.typeName!==r,o=i||a.optionId!==s;return i&&(e+=1),t=a.categoryName,r=a.typeName,s=a.optionId,{row:a,isFirstRow:0===n,startsCategoryGroup:l,startsOptionGroup:o,isAlternateTypeGroup:e%2==1}})},[N]);return(0,s.jsx)(Q.R,{loading:o,message:"Cargando datos del proyecto...",size:"lg",className:"h-full",children:(0,s.jsxs)("div",{className:"w-full flex flex-col max-w-7xl mx-auto",children:[(0,s.jsxs)("div",{className:"my-4 flex justify-between items-center gap-3 px-1 flex-shrink-0",children:[!R&&(0,s.jsxs)("button",{type:"button",onClick:()=>S(e=>!e),className:"inline-flex items-center gap-1.5 px-3 py-2 text-xs font-medium border border-gray-300 rounded-lg bg-white text-gray-700 hover:bg-gray-50 transition-colors",children:[(0,s.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4a1 1 0 011-1h16a1 1 0 011 1v2a1 1 0 01-.293.707L13 13.414V19a1 1 0 01-.553.894l-4 2A1 1 0 017 21v-7.586L3.293 6.707A1 1 0 013 6V4z"})}),"Filters"," ",Object.values(p).flat().length>0?"(".concat(Object.values(p).flat().length,")"):""]}),(0,s.jsx)("div",{className:"flex-grow"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[h.size>0&&(0,s.jsxs)("span",{className:"text-xs sm:text-sm text-gray-600 whitespace-nowrap",children:[h.size," change",h.size>1?"s":""," pending"]}
1),(0,s.jsx)("button",{onClick:D,disabled:0===h.size||u,className:"p-2 rounded-lg transition-colors flex-shrink-0 ".concat(0===h.size?"text-gray-300 cursor-not-allowed":u?"text-gray-400 cursor-wait":"text-teal-600 hover:text-teal-700 hover:bg-teal-50 cursor-pointer"),title:0===h.size?"No changes to save":u?"Saving...":"Save changes",children:(0,s.jsx)(M.A,{className:"w-5 h-5 sm:w-6 sm:h-6"})})]})]}),!R&&_&&(0,s.jsx)(eD,{mode:"mobile",showCategoryColumn:r,filters:p,uniqueValues:v,onFilterChange:A}),R?(0,s.jsx)("div",{className:"overflow-x-auto border border-gray-200 rounded-lg shadow-sm",children:(0,s.jsxs)("table",{className:"w-full divide-y divide-gray-200 text-sm bg-white",children:[(0,s.jsxs)("thead",{className:"bg-gradient-to-r from-gray-50 to-gray-100 sticky top-0 z-10",children:[(0,s.jsxs)("tr",{children:[r&&(0,s.jsx)("th",{scope:"col",className:"py-3 pl-4 pr-3 text-left font-bold text-gray-900 w-24",children:"Category"}),(0,s.jsx)("th",{scope:"col",className:"".concat(r?"px-3":"py-3 pl-4 pr-3"," py-3 text-left font-bold text-gray-900 w-28"),children:"Type"}),(0,s.jsx)("th",{scope:"col",className:"px-3 py-3 text-left font-bold text-gray-900 w-28",children:"Option"}),(0,s.jsx)("th",{scope:"col",className:"px-3 py-3 text-left font-bold text-gray-900 w-52",children:"Resource"}),(0,s.jsx)("th",{scope:"col",className:"px-3 py-3 text-center font-bold text-gray-900 w-24",children:"Thickness (m)"}),(0,s.jsx)("th",{scope:"col",className:"px-3 py-3 text-center font-bold text-gray-900 w-16",children:"EPD"})]}),(0,s.jsx)(eD,{mode:"desktop",showCategoryColumn:r,filters:p,uniqueValues:v,onFilterChange:A})]}),(0,s.jsx)("tbody",{className:"bg-white",children:0===N.length?(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:r?6:5,className:"py-12 text-center text-gray-500 text-sm",children:0===n.length?"No layers found":"No layers match the filters"})}):L.map(e=>{let{row:t,isFirstRow:a,startsCategoryGroup:n,startsOptionGroup:l,isAlternateTypeGroup:i}=e;return(0,s.jsx)(eS,{row:t,isEdited:z(t.rowKey),currentThickness:E(t),showCategoryColumn:r,isAlternateTypeGroup:i,isFirstRow:a,startsCategoryGroup:n,startsOptionGroup:l,onThicknessChange:I,onThicknessBlur:P},t.renderKey)})})]})}):(0,s.jsx)("div",{className:"w-full overflow-visible",children:(0,s.jsx)("div",{className:"space-y-3 pb-4 overflow-visible",children:0===n.length?(0,s.jsx)("p",{className:"text-center py-12 text-gray-500 text-sm",children:"No layers found"}):0===N.length?(0,s.jsx)("p",{className:"text-center py-12 text-gray-500 text-sm",children:"No layers match the selected filters"}):N.map(e=>(0,s.jsx)(e_,{row:e,isEdited:z(e.rowKey),currentThickness:E(e),showCategoryColumn:r,onThicknessChange:I,onThicknessBlur:P},e.renderKey))})})]})})};var eL=r(96059);let eO=(0,a.forwardRef)((e,t)=>{let r=(0,L.mN)({shouldUnregister:!0,defaultValues:{b7Data:{Agua_Potable:void 0,Agua_No_Potable:void 0}}}),{register:n,handleSubmit:l,reset:i,trigger:o}=r,{b7Data:c,setB7Demands:d}=(0,ev.P)(),u=(0,a.useRef)(void 0);(0,a.useEffect)(()=>{i({b7Data:{Agua_Potable:c.Agua_Potable,Agua_No_Potable:c.Agua_No_Potable}}),u.current={...c}},[c,i]);let m=e=>{try{d({Agua_Potable:Number(e.b7Data.Agua_Potable)||0,Agua_No_Potable:Number(e.b7Data.Agua_No_Potable)||0})}catch(e){console.error("Error saving B7 data")}};return(0,a.useImperativeHandle)(t,()=>({validate:async()=>await o(),submit:async()=>{await l(m)()},getValues:()=>r.getValues(),getInitialValues:()=>u.current})),(0,s.jsxs)("div",{className:"mt-10 border-t pt-6",children:[(0,s.jsx)("div",{className:"flex justify-between",children:(0,s.jsx)("h3",{className:"text-sm font-semibold text-gray-900 mb-3",children:"B7 Demand"})}),(0,s.jsxs)(L.Op,{...r,children:[(0,s.jsxs)("div",{className:"mt-4",children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-gray-900",children:"B7 Agua Potable (m\xb3)"}),(0,s.jsx)("input",{type:"number",step:"any",min:0,className:"block mt-2 w-full rounded-md bg-white px-3 py-1.5 text-sm text-gray-900 outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 placeholder:text-sm focus:outline-2 focus:-outline-offset-2 focus:outline-green-800 sm:text-sm/6 max-w-xs focus:ring-0",...n("b7Data.Agua_Potable")})]}),(0,s.jsxs)("div",{className:"mt-4",children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-gray-900",children:"B7 Agua No Potable (m\xb3)"}),(0,s.jsx)("input",{type:"number",step:"any",min:0,className:"block mt-2 w-full rounded-md bg-white px-3 py-1.5 text-sm text-gray-900 outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 placeholder:text-sm focus:outline-2 focus:-outline-offset-2 focus:outline-green-800 sm:text-sm/6 max-w-xs focus:ring-0",...n("b7Data.Agua_No_Potable")})]})]})]})});eO.displayName="B7ConfigForm";
1var eF=r(1400),eM=r(79484),eV=r(66171);function eB(e){let{items:t,value:r,onChange:a,getLabel:n,getValue:l,placeholder:i="Select...",isDisabled:o=!1}=e,c=t.map(e=>({label:n(e),value:l(e),raw:e}));return(0,s.jsx)(K.Ay,{menuPortalTarget:"undefined"!=typeof document?document.body:null,menuPosition:"fixed",menuPlacement:"auto",isDisabled:o,placeholder:i,options:c,value:r?{label:n(r),value:l(r),raw:r}:null,isClearable:!0,onChange:e=>a(e?e.raw:null),styles:eV.y,theme:eV.L})}let eq=e=>{var t;let r=null==(t=e.zc_epdkey)?void 0:t.trim();return r?"".concat(r," - ").concat(e.zc_name):e.zc_name},eW=["Calefacci\xf3n","Refrigeraci\xf3n (aire)","Iluminaci\xf3n Interior","Iluminaci\xf3n Exterior","Equipos Interiores","Equipos Exteriores","Ventiladores","Bombas","Disipaci\xf3n del calor","Humidificaci\xf3n","Recuperaci\xf3n de calor","Sistemas de agua","Refrigeraci\xf3n (Ind.)","Generadores"],eG=e=>{var t,r;let{index:n,energyType:l,epdOptions:i,onDelete:o}=e,{control:c,watch:d,setValue:u}=(0,L.xW)(),m=d("B6DemandItem.".concat(n)),p=eW.map(e=>({label:e,value:e})),x=(0,a.useMemo)(()=>{var e;return(null==m||null==(e=m.energia)?void 0:e.zc_subclassid)?i.filter(e=>{var t,r;return(null==(t=e.zc_subclass)?void 0:t.zc_subclassid)===(null==m||null==(r=m.energia)?void 0:r.zc_subclassid)}):[]},[i,null==m||null==(t=m.energia)?void 0:t.zc_subclassid]),h=(0,a.useRef)(null);return(0,a.useEffect)(()=>{var e,t;let r=null!=(t=null==m||null==(e=m.energia)?void 0:e.zc_subclassid)?t:null;!r&&h.current&&u("B6DemandItem.".concat(n,".epd"),null,{shouldDirty:!0}),h.current&&r&&h.current!==r&&u("B6DemandItem.".concat(n,".epd"),null,{shouldDirty:!0}),h.current=r},[null==m||null==(r=m.energia)?void 0:r.zc_subclassid,n,u]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("tr",{className:"hidden lg:table-row",children:[(0,s.jsx)("td",{className:"py-2",children:(0,s.jsx)(L.xI,{name:"B6DemandItem.".concat(n,".energia"),control:c,render:e=>{var t;let{field:r}=e;return(0,s.jsx)(eB,{items:l,value:null!=(t=r.value)?t:null,getLabel:e=>e.zc_classification_name,getValue:e=>e.zc_subclassid,placeholder:"Seleccionar energ\xeda",onChange:e=>r.onChange(e)})}})}),(0,s.jsx)("td",{className:"px-1 py-2",children:(0,s.jsx)(L.xI,{name:"B6DemandItem.".concat(n,".uso"),control:c,rules:{required:"use is required"},render:e=>{var t;let{field:r,fieldState:a}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(K.Ay,{options:p,placeholder:"Seleccionar uso",value:r.value&&null!=(t=p.find(e=>e.value===r.value))?t:null,onChange:e=>r.onChange(e?e.value:null),isClearable:!0,menuPortalTarget:"undefined"!=typeof document?document.body:null,menuPosition:"fixed",styles:eV.y,theme:eV.L}),a.error&&(0,s.jsx)("p",{className:"mt-1 text-xs text-red-600",children:a.error.message})]})}})}),(0,s.jsx)("td",{className:"px-1 py-2",children:(0,s.jsx)(L.xI,{name:"B6DemandItem.".concat(n,".PERT"),control:c,rules:{required:"PERT is required",validate:e=>e&&e>0||"value must be greater than 0"},render:e=>{var t;let{field:r,fieldState:a}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("input",{type:"number",...r,value:null!=(t=r.value)?t:"",onChange:e=>r.onChange(Number(e.target.value)),className:"block w-full rounded-md bg-white px-3 py-1.5 text-sm text-gray-900 outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 placeholder:text-sm focus:outline-2 focus:-outline-offset-2 focus:outline-green-800 sm:text-sm/6 max-w-xs focus:ring-0"}),a.error&&(0,s.jsx)("p",{className:"mt-1 text-xs text-red-600",children:a.error.message})]})}})}),(0,s.jsx)("td",{className:"px-1 py-2",children:(0,s.jsx)(L.xI,{name:"B6DemandItem.".concat(n,".PENRT"),control:c,rules:{required:"PENRT is required",validate:e=>e&&e>0||"value must be greater than 0"},render:e=>{var t;let{field:r,fieldState:a}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("input",{type:"number",...r,value:null!=(t=r.value)?t:"",onChange:e=>r.onChange(Number(e.target.value)),className:"block w-full rounded-md bg-white px-3 py-1.5 text-sm text-gray-900 outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 placeholder:text-sm focus:outline-2 focus:-outline-offset-2 focus:outline-green-800 sm:text-sm/6 max-w-xs focus:ring-0"}),a.error&&(0,s.jsx)("p",{className:"mt-1 text-xs text-red-600",children:a.error.message})]})}})}),(0,s.jsx)("td",{className:"px-1 py-2",children:(0,s.jsx)(L.xI,{name:"B6DemandItem.".concat(n,".energiaFinal"),control:c,rules:{required:"final energy is required",validate:e=>e&&e>0||"value must be greater than 0"},render:e=>{var t;let{field:r,fieldState:a}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("input",{type:"number",...r,value:null!=(t=r.value)?t:"",onChange:e=>r.onChange(Number(e.target.value)),className:"block w-full rounded-md bg-white px-3 py-1.5 text-sm text-gray-900 outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 placeholder:text-sm focus:outline-2 focus:-outline-offset-2 focus:outline-green-800 sm:text-sm/6 max-w-xs focus:ring-0"}),a.error&&(0,s.jsx)("p",{className:"mt-1 text-xs text-red-600",children:a.error.message})]})}})}),(0,s.jsx)("td",{className:"px-1 py-2",children:(0,s.jsx)(L.xI,{name:"B6DemandItem.".concat(n,".epd"),control:c,rules:{required:"EPD is required"},render:e=>{var t;let{field:r,fieldState:a}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eB,{items:x,value:null!=(t=r.value)?t:null,getLabel:eq,getValue:e=>e.zc_epdid,placeholder:"Seleccionar EPD",isDisabled:!(null==m?void 0:m.energia),onChange:e=>r.onChange(e)}
1),a.error&&(0,s.jsx)("p",{className:"mt-1 text-xs text-red-600",children:a.error.message})]})}})}),(0,s.jsx)("td",{className:"relative py-2 pr-4 pl-3 sm:pr-0 text-left",children:(0,s.jsx)("button",{type:"button",onClick:o,title:"Remove B6 item",children:(0,s.jsx)(eM.A,{className:"w-5 h-5 text-gray-900 hover:text-red-600 cursor-pointer"})})})]}),(0,s.jsx)("tr",{className:"lg:hidden",children:(0,s.jsx)("td",{colSpan:7,className:"p-2",children:(0,s.jsxs)("div",{className:"rounded-lg border bg-white p-4 space-y-3 shadow-sm",children:[(0,s.jsx)("div",{className:"justify-end text-right",children:(0,s.jsx)("button",{onClick:o,children:(0,s.jsx)(eM.A,{className:"w-4 h-4 text-red-600"})})}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs font-medium",children:"Energ\xeda"}),(0,s.jsx)(L.xI,{name:"B6DemandItem.".concat(n,".energia"),control:c,render:e=>{var t;let{field:r}=e;return(0,s.jsx)(eB,{items:l,value:null!=(t=r.value)?t:null,getLabel:e=>e.zc_classification_name,getValue:e=>e.zc_subclassid,placeholder:"Seleccionar energ\xeda",onChange:e=>r.onChange(e)})}})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs font-medium",children:"Uso"}),(0,s.jsx)(L.xI,{name:"B6DemandItem.".concat(n,".uso"),control:c,rules:{required:"use is required"},render:e=>{var t;let{field:r,fieldState:a}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(K.Ay,{options:p,placeholder:"Seleccionar uso",value:r.value&&null!=(t=p.find(e=>e.value===r.value))?t:null,onChange:e=>r.onChange(e?e.value:null),isClearable:!0,menuPortalTarget:"undefined"!=typeof document?document.body:null,menuPosition:"fixed",styles:eV.y,theme:eV.L}),a.error&&(0,s.jsx)("p",{className:"mt-1 text-xs text-red-600",children:a.error.message})]})}})]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs",children:"PERT"}),(0,s.jsx)(L.xI,{name:"B6DemandItem.".concat(n,".PERT"),control:c,rules:{required:"PERT is required",validate:e=>e&&e>0||"value must be greater than 0"},render:e=>{var t;let{field:r,fieldState:a}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("input",{type:"number",...r,value:null!=(t=r.value)?t:"",onChange:e=>r.onChange(Number(e.target.value)),className:"block w-full rounded-md bg-white px-3 py-1.5 text-sm text-gray-900 outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 placeholder:text-sm focus:outline-2 focus:-outline-offset-2 focus:outline-green-800 sm:text-sm/6 max-w-xs focus:ring-0"}),a.error&&(0,s.jsx)("p",{className:"mt-1 text-xs text-red-600",children:a.error.message})]})}})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs",children:"PENRT"}),(0,s.jsx)(L.xI,{name:"B6DemandItem.".concat(n,".PENRT"),control:c,rules:{required:"PENRT is required",validate:e=>e&&e>0||"value must be greater than 0"},render:e=>{var t;let{field:r,fieldState:a}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("input",{type:"number",...r,value:null!=(t=r.value)?t:"",onChange:e=>r.onChange(Number(e.target.value)),className:"block w-full rounded-md bg-white px-3 py-1.5 text-sm text-gray-900 outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 placeholder:text-sm focus:outline-2 focus:-outline-offset-2 focus:outline-green-800 sm:text-sm/6 max-w-xs focus:ring-0"}),a.error&&(0,s.jsx)("p",{className:"mt-1 text-xs text-red-600",children:a.error.message})]})}})]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs",children:"Energ\xeda final"}),(0,s.jsx)(L.xI,{name:"B6DemandItem.".concat(n,".energiaFinal"),control:c,rules:{required:"final energy is required",validate:e=>e&&e>0||"value must be greater than 0"},render:e=>{var t;let{field:r,fieldState:a}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("input",{type:"number",...r,value:null!=(t=r.value)?t:"",onChange:e=>r.onChange(Number(e.target.value)),className:"block w-full rounded-md bg-white px-3 py-1.5 text-sm text-gray-900 outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 placeholder:text-sm focus:outline-2 focus:-outline-offset-2 focus:outline-green-800 sm:text-sm/6 max-w-xs focus:ring-0"}),a.error&&(0,s.jsx)("p",{className:"mt-1 text-xs text-red-600",children:a.error.message})]})}})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs",children:"EPD"}),(0,s.jsx)(L.xI,{name:"B6DemandItem.".concat(n,".epd"),control:c,rules:{required:"EPD is required"},render:e=>{var t;let{field:r,fieldState:a}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eB,{items:x,value:null!=(t=r.value)?t:null,getLabel:eq,getValue:e=>e.zc_epdid,placeholder:"Seleccionar EPD",isDisabled:!(null==m?void 0:m.energia),onChange:e=>r.onChange(e)}
1),a.error&&(0,s.jsx)("p",{className:"mt-1 text-xs text-red-600",children:a.error.message})]})}})]})]})]})})})]})};var eU=r(72417),eK=r(36317);let eY={a4:["84","85"],a5:["80","81","82","83"],b6:["80"]},e$=Array.from(new Set(Object.values(eY).flat())).map(e=>"zc_class/zc_idclass eq '".concat(e,"'")).join(" or "),eJ="/zc_subclasses?$select=zc_classification_name,zc_subclassid&$expand=zc_class($select=zc_idclass,zc_name)&$filter=".concat(e$),eH=(e,t)=>e.filter(e=>{var r;return t.includes(null==(r=e.zc_class)?void 0:r.zc_idclass)}),eQ=(e,t)=>{let r=t.map(e=>e.zc_subclassid);return e.filter(e=>{var t;return r.includes(null==(t=e.zc_subclass)?void 0:t.zc_subclassid)})},eZ=()=>{var e;let{data:t,isLoading:r}=(0,eU.dm)({endpoint:eJ}),s=null!=(e=null==t?void 0:t.value)?e:[],n=(0,a.useMemo)(()=>s.map(e=>e.zc_subclassid),[s]),l=(0,a.useMemo)(()=>{if(0!==n.length)return"&$expand=zc_subclass($select=zc_classification_name,zc_name,zc_matkey_mid),zc_epdimpacts_Epd_zc_epd($select=zc_impacttype,zc_phase,zc_value,zc_impactmantissa,zc_impactexponent)&$filter="+n.map(e=>"zc_subclass/zc_subclassid eq '".concat(e,"'")).join(" or ")},[n]),{data:i=[],isLoading:o,isFetching:c,error:d}=(0,eU.em)(l?{filter:l}:eK.hT,{refetchOnMountOrArgChange:!1}),u=(0,a.useMemo)(()=>eH(s,eY.a4),[s]),m=(0,a.useMemo)(()=>eH(s,eY.a5),[s]),p=(0,a.useMemo)(()=>eH(s,eY.b6),[s]),x=(0,a.useMemo)(()=>eQ(i,u),[u,i]),h=(0,a.useMemo)(()=>eQ(i,m),[m,i]),g=(0,a.useMemo)(()=>eQ(i,p),[p,i]);return{isLoading:r||o,isFetching:c,error:d,a4:{subclasses:u,epds:x},a5:{subclasses:m,epds:h},b6:{subclasses:p,epds:g}}},eX=["Energ\xeda","Uso","PERT","PENRT","Energ\xeda final","EPD"],e0=(0,a.forwardRef)((e,t)=>{let r=(0,L.mN)({shouldUnregister:!0,defaultValues:{B6DemandItem:[]}}),{control:n,handleSubmit:l,reset:i,trigger:o}=r,{b6:{subclasses:c,epds:d}}=eZ(),u=(0,a.useRef)(void 0),{b6List:m,addDemandItem:p,updateDemandItem:x,removeDemandItem:h}=(0,ev.P)(),{fields:g,append:f,remove:y}=(0,L.jz)({control:n,name:"B6DemandItem"});(0,a.useEffect)(()=>{m&&0!==m.length&&(i({B6DemandItem:m}),u.current=JSON.parse(JSON.stringify(m)))},[m,i]);let j=e=>{try{var t;let r=null!=(t=e.B6DemandItem)?t:[],s=r.map(e=>e.id).filter(Boolean);m.forEach(e=>{e.id&&!s.includes(e.id)&&h(eF.y.B6,e.id)}),r.forEach(e=>{e.id?x(eF.y.B6,e.id,e):p(eF.y.B6,e)})}catch(e){console.error("Error updating B6 data",e)}};return(0,a.useImperativeHandle)(t,()=>({validate:async()=>await o(),submit:async()=>{await l(j)()},getValues:()=>({b6Data:r.getValues().B6DemandItem}),getInitialValues:()=>u.current})),(0,s.jsxs)("div",{className:"mt-10 border-t pt-6 max-w-full",children:[(0,s.jsx)("div",{className:"flex justify-between",children:(0,s.jsx)("h3",{className:"text-sm font-semibold text-gray-900 mb-3",children:"B6 Demand"})}),(0,s.jsxs)(L.Op,{...r,children:[(0,s.jsxs)("table",{className:"min-w-full mt-6 border-collapse table-fixed",children:[(0,s.jsx)("thead",{className:"hidden lg:table-header-group",children:(0,s.jsxs)("tr",{children:[eX.map(e=>(0,s.jsx)("th",{className:"text-left text-sm font-semibold text-gray-900 pb-2 w-60 sm:w-40",children:e},e)),(0,s.jsx)("th",{})]})}),(0,s.jsx)("tbody",{children:g.map((e,t)=>(0,s.jsx)(eG,{index:t,energyType:c,epdOptions:d,onDelete:()=>y(t)},e.id))})]}),(0,s.jsxs)("button",{type:"button",onClick:()=>{f({id:null,energia:null,uso:null,PERT:null,PENRT:null,energiaFinal:null,epd:null})},className:"mt-3 inline-flex items-center text-sm font-medium text-gray-700 hover:text-green-800",children:[(0,s.jsx)(F.A,{className:"w-4 h-4 mr-1"}),"Add B6 demand row"]})]})]})});e0.displayName="B6ConfigFormLayout";let e1=e=>{var t;let r=null==(t=e.zc_epdkey)?void 0:t.trim();return r?"".concat(r," - ").concat(e.zc_name):e.zc_name},e2=e=>{var t,r,n,l,i,o;let{index:c,resourceCategories:d,epdOptions:u,onDelete:m}=e,{control:p,watch:x,setValue:h}=(0,L.xW)(),g=x("a5Data.a5DemandItem.".concat(c)),f=(0,a.useMemo)(()=>{var e;return(null==g||null==(e=g.recurso)?void 0:e.zc_subclassid)?u.filter(e=>{var t,r;return(null==(t=e.zc_subclass)?void 0:t.zc_subclassid)===(null==g||null==(r=g.recurso)?void 0:r.zc_subclassid)}):[]},[u,null==g||null==(t=g.recurso)?void 0:t.zc_subclassid]),y=(0,a.useRef)(null);return(0,a.useEffect)(()=>{var e,t;let r=null!=(t=null==g||null==(e=g.recurso)?void 0:e.zc_subclassid)?t:null;!r&&y.current&&h("a5Data.a5DemandItem.".concat(c,".epd"),null,{shouldDirty:!0}),y.current&&r&&y.current!==r&&h("a5Data.a5DemandItem.".concat(c,".epd"),null,{shouldDirty:!0}),y.current=r},[null==g||null==(r=g.recurso)?void 0:r.zc_subclassid,c,h]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("tr",{className:"hidden lg:table-row",children:[(0,s.jsx)("td",{className:"py-2",children:(0,s.jsx)(L.xI,{name:"a5Data.a5DemandItem.".concat(c,".recurso"),control:p,render:e=>{var t;let{field:r}=e;return(0,s.jsx)(eB,{items:d,value:null!=(t=r.value)?t:null,getLabel:e=>e.zc_classification_name,getValue:e=>e.zc_subclassid,placeholder:"Seleccionar recurso",onChange:e=>r.onChange(e)}
1)}})}),(0,s.jsx)("td",{className:"px-1 py-2",children:(0,s.jsx)(L.xI,{name:"a5Data.a5DemandItem.".concat(c,".epd"),control:p,rules:{required:"EPD is required"},render:e=>{var t;let{field:r,fieldState:a}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eB,{items:f,value:null!=(t=r.value)?t:null,getLabel:e1,getValue:e=>e.zc_epdid,placeholder:"Seleccionar EPD",isDisabled:!(null==g?void 0:g.recurso),onChange:e=>r.onChange(e)}),a.error&&(0,s.jsx)("p",{className:"mt-1 text-xs text-red-600",children:a.error.message})]})}})}),(0,s.jsx)("td",{className:"px-1 py-2",children:(0,s.jsx)(L.xI,{name:"a5Data.a5DemandItem.".concat(c,".valor"),control:p,rules:{required:"value is required",validate:e=>e&&e>0||"value must be greater than 0"},render:e=>{var t;let{field:r,fieldState:a}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("input",{type:"number",...r,value:null!=(t=r.value)?t:"",onChange:e=>r.onChange(Number(e.target.value)),className:"block w-full rounded-md bg-white px-3 py-1.5 text-sm text-gray-900 outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 placeholder:text-sm focus:outline-2 focus:-outline-offset-2 focus:outline-green-800 sm:text-sm/6 max-w-xs focus:ring-0"}),a.error&&(0,s.jsx)("p",{className:"mt-1 text-xs text-red-600",children:a.error.message})]})}})}),(0,s.jsx)("td",{className:"px-1 py-2 text-sm text-gray-700",children:(0,s.jsx)("p",{className:"block w-full rounded-md bg-white px-3 py-1.5 text-sm text-gray-900 outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 placeholder:text-sm focus:outline-2 focus:-outline-offset-2 focus:outline-green-800 sm:text-sm/6 max-w-xs focus:ring-0",children:null!=(i=null==g||null==(n=g.epd)?void 0:n.zc_functionalunit)?i:"-"})}),(0,s.jsx)("td",{className:"relative py-2 pr-4 pl-3 sm:pr-0 text-left",children:(0,s.jsx)("button",{type:"button",onClick:m,title:"Remove A5 item",children:(0,s.jsx)(eM.A,{className:"w-5 h-5 text-gray-900 hover:text-red-600 cursor-pointer"})})})]}),(0,s.jsx)("tr",{className:"lg:hidden",children:(0,s.jsx)("td",{colSpan:7,className:"p-2",children:(0,s.jsxs)("div",{className:"rounded-lg border bg-white p-4 space-y-3 shadow-sm",children:[(0,s.jsx)("div",{className:"justify-end text-right",children:(0,s.jsx)("button",{onClick:m,children:(0,s.jsx)(eM.A,{className:"w-4 h-4 text-red-600"})})}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs font-medium",children:"Recurso"}),(0,s.jsx)(L.xI,{name:"a5Data.a5DemandItem.".concat(c,".recurso"),control:p,render:e=>{var t;let{field:r}=e;return(0,s.jsx)(eB,{items:d,value:null!=(t=r.value)?t:null,getLabel:e=>e.zc_classification_name,getValue:e=>e.zc_subclassid,placeholder:"Seleccionar recurso",onChange:e=>r.onChange(e)})}})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs font-medium",children:"EPD"}),(0,s.jsx)(L.xI,{name:"a5Data.a5DemandItem.".concat(c,".epd"),control:p,rules:{required:"EPD is required"},render:e=>{var t;let{field:r,fieldState:a}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eB,{items:f,value:null!=(t=r.value)?t:null,getLabel:e1,getValue:e=>e.zc_epdid,placeholder:"Seleccionar EPD",isDisabled:!(null==g?void 0:g.recurso),onChange:e=>r.onChange(e)}),a.error&&(0,s.jsx)("p",{className:"mt-1 text-xs text-red-600",children:a.error.message})]})}})]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs font-medium",children:"Valor"}),(0,s.jsx)(L.xI,{name:"a5Data.a5DemandItem.".concat(c,".valor"),control:p,rules:{required:"value is required",validate:e=>e&&e>0||"value must be greater than 0"},render:e=>{var t;let{field:r,fieldState:a}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("input",{type:"number",...r,value:null!=(t=r.value)?t:"",onChange:e=>r.onChange(Number(e.target.value)),className:"block w-full rounded-md bg-white px-3 py-1.5 text-sm text-gray-900 outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 placeholder:text-sm focus:outline-2 focus:-outline-offset-2 focus:outline-green-800 sm:text-sm/6 max-w-xs focus:ring-0"}),a.error&&(0,s.jsx)("p",{className:"mt-1 text-xs text-red-600",children:a.error.message})]})}})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs font-medium",children:"Unit"}),(0,s.jsx)("p",{className:"block w-full rounded-md bg-white px-3 py-1.5 text-sm text-gray-900 outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 placeholder:text-sm focus:outline-2 focus:-outline-offset-2 focus:outline-green-800 sm:text-sm/6 max-w-xs focus:ring-0",children:null!=(o=null==g||null==(l=g.epd)?void 0:l.zc_functionalunit)?o:"-"})]})]})]})})})]})},e4=["Recurso","EPD","Valor","Unit"],e5=(0,a.forwardRef)((e,t)=>{let r=(0,L.mN)({shouldUnregister:!0,defaultValues:{a5Data:{residuos:void 0,a5DemandItem:[]}}}),{control:n,register:l,handleSubmit:i,reset:o,trigger:c}=r,{a5:{subclasses:d,epds:u}}
1=eZ(),{addDemandItem:m,updateDemandItem:p,removeDemandItem:x,setA5Wastes:h,a5Data:g}=(0,ev.P)(),{fields:f,append:y,remove:j}=(0,L.jz)({control:n,name:"a5Data.a5DemandItem"}),b=(0,a.useRef)();(0,a.useEffect)(()=>{var e,t;o({a5Data:{residuos:null!=(e=g.residuos)?e:void 0,a5DemandItem:null!=(t=g.a5DemandItem)?t:[]}}),b.current=JSON.parse(JSON.stringify(g))},[g,o]);let v=e=>{try{var t;let r=null!=(t=e.a5Data.a5DemandItem)?t:[],s=r.map(e=>e.id).filter(Boolean);g.a5DemandItem.forEach(e=>{e.id&&!s.includes(e.id)&&x(eF.y.A5,e.id)}),r.forEach(e=>{e.recurso&&e.valor&&(e.id?p(eF.y.A5,e.id,e):m(eF.y.A5,e))}),null!==e.a5Data.residuos&&h(e.a5Data.residuos)}catch(e){console.error("Error updating A5 data:",e)}};return(0,a.useImperativeHandle)(t,()=>({validate:async()=>await c(),submit:async()=>{await i(v)()},getValues:()=>r.getValues(),getInitialValues:()=>b.current})),(0,s.jsxs)("div",{className:"mt-4 border-t pt-6 w-full",children:[(0,s.jsx)("div",{className:"flex justify-between",children:(0,s.jsx)("h3",{className:"text-sm font-semibold text-gray-900 mb-3",children:"A5 Demand"})}),(0,s.jsxs)(L.Op,{...r,children:[(0,s.jsxs)("div",{className:"mt-4 w-1/3",children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-gray-900",children:"A5 waste (kg)"}),(0,s.jsx)("input",{type:"number",step:"any",className:"block mt-2 w-full rounded-md bg-white px-3 py-1.5 text-sm text-gray-900 outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 placeholder:text-sm focus:outline-2 focus:-outline-offset-2 focus:outline-green-800 sm:text-sm/6 max-w-xs focus:ring-0",...l("a5Data.residuos")})]}),(0,s.jsxs)("table",{className:"min-w-full mt-6 border-collapse",children:[(0,s.jsx)("thead",{className:"hidden lg:table-header-group",children:(0,s.jsxs)("tr",{children:[e4.map(e=>(0,s.jsx)("th",{className:"text-left text-sm font-semibold text-gray-900 pb-2 w-60",children:e},e)),(0,s.jsx)("th",{})]})}),(0,s.jsx)("tbody",{children:f.map((e,t)=>(0,s.jsx)(e2,{index:t,resourceCategories:d,epdOptions:u,onDelete:()=>j(t)},e.id))})]}),(0,s.jsxs)("button",{type:"button",onClick:()=>{y({recurso:null,valor:null,epd:null})},className:"mt-3 inline-flex items-center text-sm font-medium text-gray-700 hover:text-green-800",children:[(0,s.jsx)(F.A,{className:"w-4 h-4 mr-1"}),"Add A5 demand row"]})]})]})});e5.displayName="A5ConfigFormLayout";let e3=()=>{let[e,t]=(0,a.useState)(!1),[r,n]=(0,a.useState)(!1),l=(0,a.useRef)(null),i=(0,a.useRef)(null),o=(0,a.useRef)(null),c=async()=>{var e,t,r,s,a,n;if((await Promise.all([null==(e=l.current)?void 0:e.validate(),null==(t=i.current)?void 0:t.validate(),null==(r=o.current)?void 0:r.validate()])).some(e=>!1===e))return void d.Ay.error("Please fix project demands required data");await Promise.all([null==(s=l.current)?void 0:s.submit(),null==(a=i.current)?void 0:a.submit(),null==(n=o.current)?void 0:n.submit()]),d.Ay.success("Project A5, B6 and B7 demands updated")},u=e=>{var t;return{residuos:e.residuos?Number(e.residuos):null,a5DemandItem:(null!=(t=e.a5DemandItem)?t:[]).map(e=>{var t,r,s,a;return{recursoId:null!=(s=null==(t=e.recurso)?void 0:t.zc_subclassid)?s:null,epdId:null!=(a=null==(r=e.epd)?void 0:r.zc_epdid)?a:null,valor:e.valor?Number(e.valor):null}})}},m=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.map(e=>{var t,r,s,a,n,l,i,o;return{energiaId:null!=(s=null==(t=e.energia)?void 0:t.zc_subclassid)?s:null,uso:null!=(a=e.uso)?a:null,PERT:null!=(n=e.PERT)?n:null,PENRT:null!=(l=e.PENRT)?l:null,energiaFinal:null!=(i=e.energiaFinal)?i:null,epdId:null!=(o=null==(r=e.epd)?void 0:r.zc_epdid)?o:null}})},p=e=>({Agua_Potable:e.Agua_Potable?Number(e.Agua_Potable):0,Agua_No_Potable:e.Agua_No_Potable?Number(e.Agua_No_Potable):0}),x=(e,t,r)=>{if(!e.current)return!1;let s=e.current.getValues(),a=e.current.getInitialValues();return!!s&&!!a&&JSON.stringify(r(t(s)))!==JSON.stringify(r(a))},h=()=>{if(!e)return void t(!0);x(l,e=>e.a5Data,u)||x(i,e=>e.b6Data,m)||x(o,e=>e.b7Data,p)?n(!0):t(!1)};return(0,s.jsxs)("div",{className:"mt-2 ml-1",children:[(0,s.jsxs)("div",{className:"w-full flex justify-items-start px-4 py-3",children:[(0,s.jsx)("button",{onClick:h,className:"text-sm font-semibold",children:"Modify A5, B6, B7 demands"}),e&&(0,s.jsx)("div",{className:"ml-4 flex justify-end",children:(0,s.jsx)(M.A,{onClick:c,title:"Save",className:"w-5 cursor-pointer mr-3"})}),(0,s.jsx)("div",{className:"flex justify-end ml-2",children:(0,s.jsx)(eL.A,{title:e?"Close demands":"Open demands",onClick:h,className:"w-4 cursor-pointer transition-transform ".concat(e?"rotate-180":"")})})]}),e&&(0,s.jsxs)("div",{className:"px-4 pb-4 space-y-8",children:[(0,s.jsx)(e5,{ref:l}),(0,s.jsx)(e0,{ref:i}),(0,s.jsx)(eO,{ref:o})]}),r&&(0,s.jsx)(N.A,{openModal:r,setOpenModal:n,contentComponent:(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)("h3",{className:"text-lg font-semibold",children:"Remember to save changes"}),(0,s.jsx)("p",{className:"text-sm text-gray-600",children:"If you have unsaved changes in A5, B6 or B7 and you close now, those changes will be lost."}),(0,s.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,s.jsx)(B.$,{handleOnClick:()=>n(!1),text:"Cancel"}),(0,s.jsx)(B.$,{handleOnClick:()=>{t(!1),n(!1)},text:"Close"})]})]})})]})},e6=e=>{var t;let r=null==(t=e.zc_epdkey)?void 0:t.trim();return r?"".concat(r," - ").concat(e.zc_name):e.zc_name},e9=e=>{let{index:t,epdResource:r,transportType:a}=e,{control:n}=(0,L.xW)();return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("tr",{className:"hidden lg:table-row w-full items-start align-top",children:[(0,s.jsx)("td",{className:"pr-1 py-2 text-sm text-gray-600",children:(0,s.jsx)("p",{className:"p-2 block border rounded-md bg-white border-gray-200 h-[36px]",children:r.zc_epdkey})}),(0,s.jsx)("td",{className:"px-1 py-2 text-sm text-gray-600 max-w-[70ch]",children:(0,s.jsx)("p",{className:"p-2 block border rounded-md bg-white border-gray-200 truncate h-[36px]",children:r.zc_name})}),(0,s.jsx)("td",{className:"py-2",children:(0,s.jsx)(L.xI,{name:"a4TransportDemand.TransportItems.".concat(t,".transport"),control:n,rules:{required:"Transport type is required"},render:e=>{var t;let{field:r,fieldState:n}=e;return(0,s.jsxs)("div",{className:"w-52",children:[(0,s.jsx)(eB,{items:a,value:null!=(t=r.value)?t:null,getLabel:e6,getValue:e=>e.zc_epdid,placeholder:"Select transport type",onChange:e=>r.onChange(e)}
1),n.error&&(0,s.jsx)("p",{className:"mt-1 text-xs text-red-600",children:n.error.message})]})}})}),(0,s.jsx)("td",{className:"px-1 py-2",children:(0,s.jsx)(L.xI,{name:"a4TransportDemand.TransportItems.".concat(t,".distance"),control:n,rules:{required:"distance is required",validate:e=>e&&e>0||"distance must be greater than 0"},render:e=>{var t;let{field:r,fieldState:a}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("input",{type:"number",...r,value:null!=(t=r.value)?t:"",onChange:e=>r.onChange(Number(e.target.value)),placeholder:"Add distance...",className:"block w-full h-[36px] rounded-md bg-white px-3 py-1.5 text-sm text-gray-900 outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 placeholder:text-sm focus:outline-2 focus:-outline-offset-2 focus:outline-green-800 sm:text-sm/6 focus:ring-0"}),a.error&&(0,s.jsx)("p",{className:"mt-1 text-xs text-red-600",children:a.error.message})]})}})}),(0,s.jsx)("td",{className:"px-1 py-2 text-sm text-gray-700 w-6",children:(0,s.jsx)("p",{className:"block w-6 rounded-md bg-white px-3 py-1.5 text-sm text-gray-900 outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 placeholder:text-sm focus:outline-2 focus:-outline-offset-2 focus:outline-green-800 sm:text-sm/6 max-w-xs focus:ring-0",children:"km"})})]}),(0,s.jsx)("tr",{className:"lg:hidden",children:(0,s.jsx)("td",{colSpan:7,className:"p-2",children:(0,s.jsxs)("div",{className:"rounded-lg border bg-white p-4 space-y-3 shadow-sm",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs font-medium",children:"EpdKey"}),(0,s.jsx)("p",{className:"p-1 block border rounded-md bg-white border-gray-300 text-gray-600 h-[36px]",children:r.zc_epdkey})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs font-medium",children:"Epd name"}),(0,s.jsx)("p",{className:"p-1 block border rounded-md bg-white border-gray-300 text-gray-600 truncate max-w-[70ch] h-[36px]",children:r.zc_name})]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs font-medium",children:"Transport Type"}),(0,s.jsx)(L.xI,{name:"a4TransportDemand.TransportItems.".concat(t,".transport"),control:n,rules:{required:"Transport type is required"},render:e=>{var t;let{field:r,fieldState:n}=e;return(0,s.jsxs)("div",{children:[(0,s.jsx)(eB,{items:a,value:null!=(t=r.value)?t:null,getLabel:e6,getValue:e=>e.zc_epdid,placeholder:"Select transport type",onChange:e=>r.onChange(e)}),n.error&&(0,s.jsx)("p",{className:"mt-1 text-xs text-red-600",children:n.error.message})]})}})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs font-medium",children:"Distance (km)"}),(0,s.jsx)(L.xI,{name:"a4TransportDemand.TransportItems.".concat(t,".distance"),control:n,rules:{required:"distance is required",validate:e=>e&&e>0||"distance must be greater than 0"},render:e=>{var t;let{field:r,fieldState:a}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("input",{type:"number",...r,value:null!=(t=r.value)?t:"",onChange:e=>r.onChange(Number(e.target.value)),placeholder:"Add distance...",className:"block h-[36px] w-full rounded-md bg-white px-3 py-1.5 text-sm text-gray-900 outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 placeholder:text-sm focus:outline-2 focus:-outline-offset-2 focus:outline-green-800 sm:text-sm/6 max-w-xs focus:ring-0 border-gray-500"}),a.error&&(0,s.jsx)("p",{className:"mt-1 text-xs text-red-600",children:a.error.message})]})}})]})]})]})})})]})};var e7=r(10874),e8=r(58846),te=r(35226);let tt=["EpdKey","Epd Name","Transport type","Distance (km)",""],tr=()=>{let{transportEpds:e,defaultEpd:t}=(()=>{let{a4:{epds:e},isLoading:t,isFetching:r}=eZ();return{transportEpds:(0,a.useMemo)(()=>[...e].sort((e,t)=>e.zc_name.localeCompare(t.zc_name,"es",{sensitivity:"base"})),[e]),defaultEpd:(0,a.useMemo)(()=>e.find(e=>"Epd006013"===e.zc_epdkey),[e]),isLoading:t,isFetching:r}})(),{a4Items:r,loading:l,buildResetA4Values:i}=(()=>{let[e,t]=(0,a.useState)(!0),[r,s]=(0,a.useState)(null),[l,i]=(0,a.useState)([]),o=(0,n.d4)(e=>
1e.projectVariants.projectVariants),c=(0,n.d4)(e=>e.constructions),d=(0,n.d4)(e=>{var t;return null==(t=(0,te.BE)(e))?void 0:t.TransportItems}),u=(0,a.useMemo)(()=>null!=d?d:[],[d]),[m]=eU.T_.endpoints.getEpdsList.useLazyQuery();(0,a.useEffect)(()=>{if(!o.length){i([]),t(!1);return}let e=!1;return(async()=>{try{t(!0),s(null);let r=(0,w.kt)(o.flatMap(e=>e.typeOptionIdList),c);if(!r.length){i([]),t(!1);return}let a=await (0,C.Pp)(r);if(!a.length){i([]),t(!1);return}let n=a.length?await m({filter:"&$filter=".concat(a.map(e=>"zc_epdid eq ".concat(e)).join(" or "))}).unwrap():[],l=new Map;n.forEach(e=>{e.zc_epdid&&!l.has(e.zc_epdid)&&l.set(e.zc_epdid,e)});let d=new Map;u.forEach(e=>{var t;(null==(t=e.epdResource)?void 0:t.zc_epdid)&&d.set(e.epdResource.zc_epdid,e)});let p=[];l.forEach((e,t)=>{let r=d.get(t);p.push(r?{...r}:{epdResource:e,transport:null,distance:null})}),e||i(p.toSorted((e,t)=>{var r,s,a,n;let l=null!=(a=null==(r=e.epdResource)?void 0:r.zc_name)?a:"",i=null!=(n=null==(s=t.epdResource)?void 0:s.zc_name)?n:"";return l.localeCompare(i)})),t(!1)}catch(a){if(!e){var r;console.error("Error cargando EPDs del proyecto para A4",a),s(null!=(r=null==a?void 0:a.message)?r:"Error cargando EPDs de A4"),t(!1)}}})(),()=>{e=!0}},[o,c,u,m]);let p=(0,a.useCallback)(()=>{let e=new Map;return u.forEach(t=>{var r;(null==(r=t.epdResource)?void 0:r.zc_epdid)&&e.set(t.epdResource.zc_epdid,t)}),{TransportItems:l.map(t=>{var r,s;let a=t.epdResource.zc_epdid,n=e.get(a);return{epdResource:t.epdResource,transport:null!=(r=null==n?void 0:n.transport)?r:null,distance:null!=(s=null==n?void 0:n.distance)?s:null}})}},[l,u]);return{loading:e,error:r,a4Items:l,buildResetA4Values:p}})(),o=(0,n.d4)(e=>
1e.projectVariants.projectVariants.length),[c,u]=(0,a.useState)(!1),m=(0,L.mN)({shouldUnregister:!1,defaultValues:{a4TransportDemand:{TransportItems:[]}}}),{formState:p}=m,{isDirty:x}=p,[h,g]=(0,a.useState)(null),[f,y]=(0,a.useState)(!1),{setA4Transport:j}=(0,ev.P)();(0,a.useEffect)(()=>{r.length&&m.reset({a4TransportDemand:i()})},[r,i]);let b=()=>{if(!c)return void u(!0);if(c&&x){g("close"),y(!0);return}u(!1)};return(0,s.jsxs)("div",{className:"mt-2 ml-1",children:[(0,s.jsxs)("div",{className:"w-full flex justify-items-start px-4 py-3",children:[(0,s.jsx)("button",{onClick:b,className:"text-sm font-semibold",children:"Modify material transport (A4)"}),c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"ml-4 flex justify-end",children:(0,s.jsx)(e7.A,{onClick:()=>{g("reset"),y(!0)},title:"Reset",className:"w-5 cursor-pointer mr-3"})}),(0,s.jsx)("div",{className:"ml-2 flex justify-end",children:(0,s.jsx)(e8.A,{onClick:()=>{g("defaults"),y(!0)},title:"Load defaults",className:"w-5 cursor-pointer mr-3"})}),(0,s.jsx)("div",{className:"ml-2 flex justify-end",children:(0,s.jsx)(M.A,{onClick:()=>(e=>{try{let t={TransportItems:e.TransportItems.map(e=>({epdResource:e.epdResource,transport:e.transport,distance:e.distance}))};j(t),m.reset(m.getValues()),d.Ay.success("A4 Transport demands updated")}catch(e){d.Ay.error("Error updating A4 Transport demands"),console.error("Error updating A4 data:",e)}})(m.getValues("a4TransportDemand")),title:"Save",className:"w-5 cursor-pointer mr-3"})})]}),(0,s.jsx)("div",{className:"flex justify-end ml-2",children:(0,s.jsx)(eL.A,{title:c?"Close demands":"Open demands",onClick:b,className:"w-4 cursor-pointer transition-transform ".concat(c?"rotate-180":"")})})]}),c&&(0,s.jsx)(Q.A,{loading:!!l,message:"cargando epds...",className:"min-h-[40px]",children:(0,s.jsx)("div",{className:"px-4 pb-4 space-y-8",children:0===o?(0,s.jsx)("p",{className:"rounded-md border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800",children:"The project needs at least 1 variant configurated"}):(0,s.jsx)(L.Op,{...m,children:(0,s.jsxs)("table",{className:"max-w-full",children:[(0,s.jsx)("thead",{className:"text-left text-sm font-semibold text-gray-900 pb-2 px-1 hidden lg:table-header-group",children:(0,s.jsx)("tr",{children:tt.map(e=>(0,s.jsx)("th",{className:"text-left text-sm font-semibold text-gray-900 pb-2",children:e},e))})}),(0,s.jsx)("tbody",{children:r.map((t,r)=>(0,s.jsx)(e9,{index:r,epdResource:t.epdResource,transportType:e},t.epdResource.zc_epdid))})]})})})}
1),f&&(0,s.jsx)(N.A,{openModal:f,setOpenModal:y,contentComponent:(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("h3",{className:"text-lg font-semibold",children:["reset"===h&&"\xbfReset values?","defaults"===h&&"\xbfLoad default values?","close"===h&&"Unsaved changes"]}),(0,s.jsxs)("p",{className:"text-sm text-gray-600",children:["reset"===h&&"All changes that are not saved will be lost.","defaults"===h&&"This will replace the current configuration that has not been saved.","close"===h&&"You have unsaved changes. Remember to save before closing if necessary."]}),(0,s.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,s.jsx)(B.$,{handleOnClick:()=>y(!1),text:"Cancel"}),(0,s.jsx)(B.$,{handleOnClick:()=>{"reset"===h&&m.reset({a4TransportDemand:i()}),"defaults"===h&&t&&m.getValues("a4TransportDemand.TransportItems").forEach((e,r)=>{m.setValue("a4TransportDemand.TransportItems.".concat(r,".transport"),t,{shouldDirty:!0}),m.setValue("a4TransportDemand.TransportItems.".concat(r,".distance"),200,{shouldDirty:!0})}),"close"===h&&(m.reset({a4TransportDemand:i()}),u(!1)),y(!1),g(null)},text:"Confirm"})]})]})})]})};var ts=r(96779),ta=r(23258),tn=r(31607);tn.t1.register(tn.PP,tn.kc,tn.E8,tn.m_,tn.s$);let tl=["#6366f1","#22c55e","#f97316","#eab308","#06b6d4","#ef4444","#8b5cf6"];function ti(e){let{groupedData:t,variants:r}=e;return(0,s.jsx)("div",{className:"w-full max-w-6xl p-4",children:Object.entries(t).map(e=>{let[t,a]=e,n=Object.keys(a.types),l=a.types.variantbaseline,i=l?Object.keys(l.options):[],o=r.map(e=>e.name).filter(e=>"baseline"!==e),c=[...o,"baseline"],d=[...n.filter(e=>"variantbaseline"!==e).map((e,t)=>{let s=a.types[e];return{label:s.name,data:[...o.map(e=>{var t,a,n,l;return null!=(l=null==(t=s.options[null!=(n=null==(a=r.find(t=>t.name===e))?void 0:a.id)?n:""])?void 0:t.gwp)?l:null}),null],backgroundColor:tl[t%tl.length],stack:"stack1"}}),...i.map((e,t)=>{var r,s;return{label:e,data:[...o.map(()=>null),null!=(s=null==(r=l.options[e])?void 0:r.gwp)?s:null],backgroundColor:tl[(n.length+t)%tl.length],stack:"stack1"}})];return(0,s.jsx)(et.E,{children:e=>{let{open:t}=e;return(0,s.jsxs)("div",{className:"mb-4 border rounded-lg shadow-sm",children:[(0,s.jsxs)(et.E.Button,{className:"flex justify-between w-full px-4 py-3 text-md font-semibold text-left text-white bg-gray-400 rounded-t-lg hover:bg-gray-500 focus:outline-none",children:[(0,s.jsx)("span",{children:a.name}),(0,s.jsx)(ts.A,{className:"".concat(t?"rotate-180":""," w-5 h-5")})]}),(0,s.jsx)(et.E.Panel,{className:"bg-white px-4 pt-4 pb-2 text-sm text-gray-700",children:(0,s.jsx)("div",{className:"mb-6",children:(0,s.jsx)(ta.yP,{data:{labels:c,datasets:d},options:{responsive:!0,plugins:{legend:{display:!1}},scales:{y:{beginAtZero:!0,title:{display:!0,text:"GWP total"}}}}})})})]})}},t)})})}var to=r(21733);function tc(e,t){var r,s;let n=(0,a.useMemo)(()=>{let t=new Set;return e.forEach(e=>e.typeOptionIdList.forEach(e=>{e.typeId&&t.add(e.typeId)})),Array.from(t)},[e]),l=n.map(e=>(0,to.H)(e)),i=l.some(e=>e.loading),o=null!=(s=null==(r=l.find(e=>e.error))?void 0:r.error)?s:null,c=(0,a.useMemo)(()=>{let e=new Map;return l.forEach(t=>{t.optionsGwp.forEach(t=>{e.has(t.optionId)||e.set(t.optionId,{optionId:t.optionId,totalGwp:t.totalGwp})})}),Array.from(e.values())},[l]),d=(0,a.useMemo)(()=>{let e={};return l.forEach((t,r)=>{var s;let a=n[r];a&&(e[a]={referenceType:t.referenceType,baselineGwp:Object.values(null!=(s=t.baselineGwp)?s:{}).reduce((e,t)=>t?e+Object.values(t).reduce((e,t)=>e+(Number.isFinite(t)?t:0),0):e,0)})}),e},[l,n]),u=(0,a.useMemo)(()=>c.length?(0,ef.$v)(e,t,c,d):{},[e,t,c,d]);return{loading:i,error:o,optionsGwp:c,baselineByType:d,grouped:u}}function td(){let e=(0,n.d4)(e=>
1e.projectVariants.projectVariants),t=(0,n.d4)(e=>e.treeObjects),r=[...e,{id:"variantbaseline",name:"baseline",typeOptionIdList:[]}],{grouped:a,loading:l,error:i}=tc(r,t);return(0,s.jsxs)("div",{className:"p-6",children:[(0,s.jsx)("h2",{className:"text-2xl font-bold mb-4",children:"Comparativa GWP por Categor\xeda y Tipo"}),l&&(0,s.jsxs)("div",{className:"flex items-center space-x-2 ",children:[(0,s.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-gray-400 border-t-transparent"}),(0,s.jsx)("p",{className:"text-gray-500",children:"Calculando datos de GWP..."})]}),i&&(0,s.jsx)("p",{className:"text-red-500",children:i}),(0,s.jsx)(ti,{groupedData:a,variants:r})]})}let tu=new Intl.NumberFormat("ca-ES",{minimumFractionDigits:0,maximumFractionDigits:0}),tm=new Intl.NumberFormat("ca-ES",{minimumFractionDigits:1,maximumFractionDigits:1}),tp=new Intl.NumberFormat("ca-ES",{minimumFractionDigits:1,maximumFractionDigits:1}),tx=e=>tm.format(e),th=e=>e>1e3?tu.format(e):tp.format(e);function tg(e){let{data:t,rowLabelKey:r,calculateReductionFor:a}=e;if(!t||Array.isArray(t)&&0===t.length)return null;let n=Array.isArray(t)||"object"!=typeof t?t:Object.entries(t).map(e=>{let[t,s]=e;return{[r]:t,...s}}),l=Array.from(new Set(n.flatMap(e=>Object.keys(e).filter(e=>e!==r)))),i=[...l.filter(e=>e.toLowerCase()===(null==a?void 0:a.toLowerCase())),...l.filter(e=>e.toLowerCase()!==(null==a?void 0:a.toLowerCase())).sort((e,t)=>e.localeCompare(t))],o=n.filter(e=>"d"!==e[r].trim().toLowerCase()),c=n.find(e=>"d"===e[r].trim().toLowerCase()),d={};i.forEach(e=>{d[e]=o.reduce((t,r)=>{let s=r[e];return t+("number"==typeof s?s:0)},0)});let u=o.map(e=>{let t={};i.forEach(r=>{t[r]=e[r]});let s=a?(0,ef.De)(a,r):void 0;return{...e,...s?s(t):{}}}),m={[r]:"Total",...d};if(a)for(let[e,t]of Object.entries((0,ef.De)(a,r)(d)))m[e]=t;let p=[...i,...a?Object.keys((0,ef.De)(a,r)(d)):[]];return(0,s.jsx)("div",{className:"overflow-x-auto rounded-md border border-gray-300 ".concat(p.length>4?"max-w-7xl":"max-w-md"),children:(0,s.jsxs)("table",{className:"min-w-full divide-y divide-gray-200",children:[(0,s.jsx)("thead",{className:"bg-gray-50",children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{className:"px-3 py-2 text-left text-sm font-semibold text-gray-900 border-b",children:String(r)}),p.map(e=>(0,s.jsx)("th",{className:"px-3 py-2 text-right text-sm font-semibold text-gray-900 border-b",children:e},e))]})}),(0,s.jsxs)("tbody",{className:"divide-y divide-gray-200 bg-white",children:[u.map((e,t)=>(0,s.jsxs)("tr",{children:[(0,s.jsx)("td",{className:"px-3 py-2 text-sm text-gray-500 border-b",children:e[r]}),p.map(t=>(0,s.jsx)("td",{className:"px-3 py-2 text-sm text-gray-500 text-right border-b ".concat(t.startsWith("%")?"bg-green-zero bg-opacity-25":"bg-white"),children:"number"==typeof e[t]?t.startsWith("%")?"".concat(tx(e[t])," %"):th(e[t]):"-"},t))]},t)),(0,s.jsxs)("tr",{className:"bg-gray-50 font-semibold",children:[(0,s.jsx)("td",{className:"px-3 py-2 text-sm text-gray-900 border-t",children:m[r]}),p.map(e=>(0,s.jsx)("td",{className:"px-3 py-2 text-sm text-gray-900 text-right border-t",children:"number"==typeof m[e]?e.startsWith("%")?"".concat(tx(m[e])," %"):th(m[e]):"-"},e))]}),c&&(0,s.jsxs)("tr",{className:"italic",children:[(0,s.jsx)("td",{className:"px-3 py-2 text-sm text-gray-700 border-t",children:"D"}),p.map(e=>(0,s.jsx)("td",{className:"px-3 py-2 text-sm text-gray-700 text-right border-t",children:"number"==typeof c[e]?th(c[e]):"-"},e))]})]})]})})}var tf=r(31856),ty=r(47477);function tj(){let e=(0,n.d4)(e=>
1e.projectVariants.projectVariants),t=(0,n.d4)(e=>e.treeObjects),r=[...e,{id:"variantbaseline",name:"baseline",typeOptionIdList:[]}],{grouped:l,loading:i,error:o}=tc(r,t),c=(0,ef.Dj)(l,t,r),d=(0,ef.jR)(l,e),{summaryByPhase:u,loadingPhase:m,errorPhase:p}=function(e,t){var r,s;let[n,l]=(0,a.useState)({A5:0,B6:0,B7:0}),{a5Data:i,b6List:o,b7Data:c}=(0,ev.P)(),d=(0,a.useMemo)(()=>{let t=new Set;return e.forEach(e=>e.typeOptionIdList.forEach(e=>{e.typeId&&t.add(e.typeId)})),Array.from(t)},[e]),u=d.map(e=>(0,ty.Z)(e,{includeBaselineRaw:!0})),m=d.map((e,t)=>(0,tf.k)(e,u[t])),p=m.some(e=>e.loading),x=null!=(s=null==(r=m.find(e=>e.error))?void 0:r.error)?s:null,h=m.flatMap(e=>e.optionsPhase);(0,a.useEffect)(()=>{let e=!0;return async function(){let t=await (0,ef.qx)({a5Data:i,b6DemandItem:o,b7Data:c,a4TransportDemand:{TransportItems:[]}});if(e){var r,s,a;l({A5:null!=(r=t.A5)?r:0,B6:null!=(s=t.B6)?s:0,B7:null!=(a=t.B7)?a:0})}}(),()=>{e=!1}},[i,o,c]);let g=(0,a.useMemo)(()=>(0,ef.K6)(h,e,t),[h,e]);return{loadingPhase:p,errorPhase:x,summaryByPhase:(0,a.useMemo)(()=>{if(!g)return{};let t={...g};return Object.entries(n).forEach(r=>{let[s,a]=r;t[s]||(t[s]={},e.forEach(e=>{t[s][e.name]=0})),e.forEach(e=>{t[s][e.name]+=a})}),Object.keys(t).sort((e,t)=>e.localeCompare(t)).reduce((e,r)=>(e[r]=t[r],e),{})},[g,e,n])}}(e,t);return(0,s.jsxs)("div",{className:"p-6",children:[(0,s.jsx)("h2",{className:"text-2xl font-bold mb-4",children:"Resumen impacto GWP"}),i&&(0,s.jsxs)("div",{className:"flex items-center space-x-2 ",children:[(0,s.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-gray-400 border-t-transparent"}),(0,s.jsx)("p",{className:"text-gray-500",children:"Calculando datos de GWP..."})]}),o&&p&&(0,s.jsx)("p",{className:"text-red-500",children:o}),!i&&!m&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("h3",{className:"text-xl font-semibold mb-4",children:"GWP por Categor\xeda"}),(0,s.jsx)(tg,{data:d,rowLabelKey:"Category"}),(0,s.jsx)("h3",{className:"text-xl font-semibold mt-4 mb-4",children:"GWP por Fase"}),(0,s.jsx)(tg,{data:u,rowLabelKey:"Phase",calculateReductionFor:"variant1"}),(0,s.jsx)("h3",{className:"text-xl font-semibold mb-4 mt-4",children:"GWP Comparativa por Categor\xeda"}),(0,s.jsx)(tg,{data:c,rowLabelKey:"Category",calculateReductionFor:"baseline"}),(0,s.jsx)("p",{className:"mt-1 ml-1 font-light text-sm text-gray-500 italic",children:"*Esta tabla solo compara las categor\xedas y exigencias que tienen asignados tipos referencia"})]})]})}let tb=e=>{let{tabs:t,defaultTab:r,onChange:n,disabledTabs:l=[],disabledTooltips:i={}}=e,[o,c]=(0,a.useState)(r);return(0,s.jsx)("nav",{className:"-mb-px flex flex-wrap gap-x-4 gap-y-1","aria-label":"Tabs",children:t.map((e,t)=>{let r=o===e,a=l.includes(e);return(0,s.jsx)(eb,{disabled:a,tooltipText:i[e]||"",children:(0,s.jsx)("a",{onClick:()=>(e=>{l.includes(e)||(c(e),n(e))})(e),className:(0,w.xW)(a?"text-gray-400 border-transparent cursor-not-allowed":r?"border-green-zero text-green-zero cursor-pointer":"border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 cursor-pointer","inline-block whitespace-nowrap border-b-2 py-3 px-1 text-sm font-medium"),"aria-current":o===e?"page":void 0,children:e},t)},e)})})},tv=e=>{var t;let{onOptionSelectChange:r,options:a,value:n=null,isDisabled:l}=e,{control:i,formState:{errors:o}}=(0,L.xW)();return(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)(L.xI,{name:"optionType",control:i,rules:{required:!0},render:e=>{let{field:t}=e;return(0,s.jsx)(K.Ay,{...t,options:a,value:a.find(e=>e.value===n)||null,classNamePrefix:"react-select",className:"text-left",isClearable:!0,isDisabled:l,onChange:e=>{r((null==e?void 0:e.value)||null)},theme:e=>({...e,borderRadius:5,colors:{...e.colors,primary25:"#a3b98166"}})})}}),(null==(t=o.optionType)?void 0:t.type)==="required"&&(0,s.jsx)("p",{role:"alert",className:"text-red-600 text-xs mt-2",children:"Option is required"})]})},tN=()=>{let e=(0,a.useRef)(null),[t,r]=(0,a.useState)(!1),[l,i]=(0,a.useState)(!1),[o,c]=(0,a.useState)([]),[u,m]=(0,a.useState)(new Set),[p,x]=(0,a.useState)(0),h=(0,L.mN)(),[g,f]=(0,a.useState)({}),y=(0,n.d4)(e=>
1e.projectVariants.projectVariants),j=(0,n.d4)(e=>e.treeObjects);(0,a.useEffect)(()=>{(async()=>{try{let e=await G(void 0,!0,!0);if(e&&e.categoryList.length>0){let t=e.categoryList.map(e=>({id:e.id,type:"category",name:e.name,settingsCategory:e.settingsCategory,typeList:e.typeList.map(e=>({id:e.id,type:"type",name:e.name,referenceType:e.referenceType,typeClassification:e.typeClassification,area:e.area,projectTypes:e.projectTypes,settingsRequirement:e.settingsRequirement,optionList:e.optionList}))}));c(t)}}catch(e){d.Ay.error("Error loading project data: ".concat(e))}})()},[j]),(0,a.useEffect)(()=>{(()=>{if(!o.length)return;if((null==y?void 0:y.length)===0){m(new Set),f({}),x(0);return}let e=new Set,t={};y.forEach((r,s)=>{r.typeOptionIdList.forEach(r=>{let a=o.flatMap(e=>e.typeList).find(e=>e.id===r.typeId);a&&(e.add(a.id),t[a.id]={...t[a.id],["variant".concat(s+1)]:r.optionId})})}),m(e),f(t),x(y.length)})()},[y,o.length]),(0,a.useLayoutEffect)(()=>{let t=o.reduce((e,t)=>e+t.typeList.length,0),s=u.size,a=s>0&&s<t;r(s===t),i(a),e.current&&(e.current.indeterminate=a)},[u,o]);let b=()=>{r(!t&&!l),i(!1),t||l?(m(new Set),f({})):m(new Set(o.flatMap(e=>e.typeList).map(e=>e.id)))},v=(0,n.wA)();return(0,s.jsxs)(L.Op,{...h,children:[(0,s.jsx)("div",{className:"flex justify-end mr-5",children:(0,s.jsx)(M.A,{onClick:()=>(()=>{let e=Object.entries(Object.entries(g).reduce((e,t)=>{let[r,s]=t;return Object.entries(s).forEach(t=>{let[s,a]=t;e[s]=e[s]||[],e[s].some(e=>e.optionId===a)||e[s].push({typeId:r,optionId:a})}),e},{})).map(e=>{let[t,r]=e;return{id:(0,O.A)(),name:"".concat(t),typeOptionIdList:r,transportDemand:null}});v((0,I.bL)(e)),d.Ay.success("Configuraci\xf3n de variantes guardada con \xe9xito")})(),title:"Save",className:"w-7 cursor-pointer mr-3"})}),(0,s.jsx)("div",{className:"flow-root",children:(0,s.jsx)("div",{children:(0,s.jsx)("div",{className:"inline-block min-w-full py-2 align-middle sm:px-2 lg:px-4",children:(0,s.jsx)("div",{className:"relative pr-4",children:(0,s.jsxs)("table",{className:"min-w-full table-fixed divide-y divide-gray-300",children:[(0,s.jsx)("thead",{className:"bg-gray-50 sticky top-0 z-10 shadow",children:(0,s.jsxs)("tr",{children:[[{header:"Category",accessor:"category"},{header:"Checkbox",accessor:"checkbox"},{header:"Type",accessor:"type"},{header:"Area (m2)",accessor:"area"}].map(r=>(0,s.jsx)("th",{scope:"col",className:"sticky top-0 z-10 px-3 py-3.5 text-left text-sm font-semibold text-gray-900 border-b border-gray-300",children:"checkbox"===r.accessor?(0,s.jsx)("input",{type:"checkbox",className:"col-start-1 row-start-1 appearance-none rounded border border-gray-300 bg-white checked:border-green-500 checked:bg-green-500 indeterminate:border-green-600 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 checked:focus:bg-green-500 checked:focus:ring-bg-green-500 hover:ring-bg-green-500 checked:focus:ring-bg-green-500 checked:ring-bg-green-500 focus:ring-green-700 focus-visible:outline-green-500 disabled:border-gray-300 disabled:bg-gray-100 disabled:checked:bg-gray-100 forced-colors:appearance-auto hover:bg-green-700 indeterminate:bg-red-600 indeterminate:hover:bg-red-800",ref:e,checked:t,onChange:b}):r.header},String(r.accessor))),Array.from({length:p}).map((e,t)=>(0,s.jsxs)("th",{className:"relative px-3 py-3.5 text-center text-sm font-semibold text-gray-900 border-b border-gray-300",children:["Variant ",t+1,0!==p&&(0,s.jsx)(eM.A,{className:"absolute right-2 top-1/2 transform -translate-y-1/2 w-5 cursor-pointer text-right text-red-600",title:"Remove Variant",onClick:()=>(e=>{x(t=>{let r=Math.max(t-1,0);return f(t=>{let s={...t};return 0===r?{}:(Object.keys(s).forEach(t=>{let r=s[t];delete r["variant".concat(e+1)];let a={};Object.keys(r).forEach(t=>{let s=parseInt(t.replace("variant",""),10)-1;s!==e&&(a["variant".concat(s<e?s+1:s)]=r[t])}),s[t]=a}),s)}),r})})(t)})]},"variant".concat(t+1))),(0,s.jsx)("th",{className:"relative px-3 py-3.5 text-left text-sm font-semibold text-gray-900 border-b border-gray-300",children:3!==p&&(0,s.jsx)(F.A,{className:"w-5 cursor-pointer left-0 top-2 text-green-zero",title:"Add Variant",onClick:()=>{x(e=>{let t=Math.min(e+1,3);return 0===e&&f(e=>{let t={...e};
1return o.forEach(e=>{e.typeList.forEach(e=>{u.has(e.id)&&e.optionList.length>0&&(t[e.id]={...t[e.id],variant1:e.optionList[0].id})})}),t}),t})}})})]})}),(0,s.jsx)("tbody",{className:"divide-y divide-gray-200 bg-white",children:o.map((e,t)=>(0,s.jsx)(a.Fragment,{children:e.typeList.map((t,r)=>(0,s.jsxs)("tr",{children:[0===r&&(0,s.jsx)("td",{rowSpan:e.typeList.length,className:"px-3 py-2.5 text-sm text-gray-500 align-middle",children:e.name}),(0,s.jsx)("td",{className:"relative px-7 sm:w-12 sm:px-6",children:(0,s.jsx)("input",{type:"checkbox",checked:u.has(t.id),onChange:e=>((e,t)=>{let r=new Set(u),s={...g};t.target.checked?r.add(e):(r.delete(e),delete s[e]),m(r),f(s)})(t.id,e),className:"absolute left-4 top-1/2 -mt-2 h-4 w-4 rounded border-gray-300 text-emerald-500 focus:ring-emerald-500"})}),(0,s.jsx)("td",{className:"px-3 py-2.5 text-sm text-gray-500",children:t.name}),(0,s.jsx)("td",{className:"px-3 py-2.5 text-sm text-gray-500",children:(0,s.jsx)("input",{type:"number",step:"0.01",min:"0",value:t.area,onChange:e=>((e,t)=>{let r=Number(t);Number.isFinite(r)&&!(r<0)&&c(t=>t.map(t=>({...t,typeList:t.typeList.map(t=>t.id===e?{...t,area:r}:t)})))})(t.id,e.target.value),onBlur:e=>((e,t)=>{let r=Number(t);if(!Number.isFinite(r)||r<0)return void d.Ay.error("El area debe ser un numero mayor o igual a 0");let s=j[e];s&&"type"===s.type&&v((0,k.Xg)({...s,area:r}))})(t.id,e.target.value),className:"w-24 rounded border border-gray-300 px-2 py-1 text-sm text-gray-700 focus:border-emerald-500 focus:outline-none focus:ring-1 focus:ring-emerald-500"})}),Array.from({length:p}).map((e,r)=>{var a;return(0,s.jsx)("td",{className:"px-1 py-2 min-w-36 text-sm text-gray-500",children:(0,s.jsx)(tv,{onOptionSelectChange:e=>((e,t,r)=>{f(s=>({...s,[e]:{...s[e],[t]:r}}))})(t.id,"variant".concat(r+1),e),options:t.optionList.map(e=>({value:e.id,label:e.name})),isDisabled:!u.has(t.id),value:(null==(a=g[t.id])?void 0:a["variant".concat(r+1)])||null})},"variant-cell-".concat(t.id,"-").concat(r+1))})]},t.id))},t))})]})})})})})]})};var tw=r(17787),tA=r(49027),tC=r(27587),tk=function(e){return e.Info="Project Info",e.Resume="Project Resume",e.Variants="Project Variants",e.Demands="Project Demands",e.Gwp="GWP Checker",e.ResumeGwp="GWP Resume",e}(tk||{});let tI=e=>{let{category:t,isSelected:r,hasIncompleteOptions:a}=e,{attributes:n,listeners:l,setNodeRef:i,transform:o,transition:c,isDragging:d}=(0,tA.gl)({id:t.id});return(0,s.jsx)("div",{ref:i,style:{transform:tC.Ks.Transform.toString(o),transition:c},...n,...l,className:"h-full ".concat(d?"z-10":""),children:(0,s.jsxs)(eh(),{href:"/category/".concat(t.id),draggable:!1,onClick:e=>{d&&e.preventDefault()},className:"flex items-center justify-between gap-2 rounded-md border px-3 py-2 text-sm font-medium transition-colors ".concat(r?"border-green-zero bg-green-zero text-white":"border-slate-300 bg-white text-slate-700 hover:bg-slate-50"," ").concat(d?"shadow-lg":""),children:[(0,s.jsx)("span",{className:"truncate",children:t.name||"Categoria sin nombre"}),a&&(0,s.jsx)("span",{title:"Categoria con opciones incompletas",className:"h-2.5 w-2.5 rounded-full bg-amber-500 shrink-0"})]})})},tP=e=>{var t,r;let{children:l}=e,i=(0,R.usePathname)(),o=(0,n.wA)(),c=!i.startsWith("/layerFunction"),[d,u]=(0,a.useState)(!1),[m,p]=(0,a.useState)(!1),[x,h]=(0,a.useState)("Project Info"),g=(0,n.d4)(e=>e.treeObjects),f=(0,n.d4)(e=>
1e.projectVariants.projectVariants).length,y=Object.values(g).find(e=>"project"===e.type),j=null!=(r=null==y?void 0:y.children.map(e=>g[e]).filter(e=>(null==e?void 0:e.type)==="category").map(e=>e))?r:[],b=(null==(t=i.split("/")[2])?void 0:t.toString())||"",v=b?g[b]:void 0,w=(()=>{if(!v)return"";if("category"===v.type)return v.id;if("type"===v.type)return v.parentId;if("option"===v.type){let e=g[v.parentId];return(null==e?void 0:e.type)==="type"?e.parentId:""}return""})(),A=e=>{let t=g[e];return!!t&&("option"===t.type?t.status===k.aF.WIP:t.children.some(e=>A(e)))},C=(0,tw.FR)((0,tw.MS)(tw.AN,{activationConstraint:{distance:8}}),(0,tw.MS)(tw.IG,{activationConstraint:{delay:150,tolerance:5}}));return y?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eN,{}),(0,s.jsxs)("div",{className:"mx-5 mt-5",children:[c&&(0,s.jsxs)("div",{className:"rounded-lg border border-slate-200 bg-white",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>u(e=>!e),className:"flex w-full items-center justify-between gap-3 px-4 py-3 text-left",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Proyecto"}),(0,s.jsx)("p",{className:"truncate text-sm font-semibold text-slate-900",children:y.name||"Proyecto sin nombre"})]}),(0,s.jsx)(eL.A,{className:"h-5 w-5 text-slate-500 transition-transform ".concat(d?"rotate-180":"")})]}),d&&(0,s.jsxs)("div",{className:"border-t border-slate-200 px-2 py-3 sm:px-4",children:[(0,s.jsx)("div",{className:"border-b border-gray-200",children:(0,s.jsx)(tb,{tabs:["Project Info","Project Resume","Project Variants","Project Demands","GWP Checker","GWP Resume"],defaultTab:"Project Info",onChange:e=>h(e),disabledTabs:0===f?["GWP Checker","GWP Resume"]:[],disabledTooltips:{"GWP Checker":"Debes tener al menos una variante configurada","GWP Resume":"Debes tener al menos una variante configurada"}})}),(0,s.jsxs)("div",{className:"mt-3 w-full",children:["Project Info"===x&&(0,s.jsx)(X,{isModal:!1,beFormRendered:!0,projectId:y.id,compactLayout:!0}),"Project Resume"===x&&(0,s.jsx)(eT,{}),"Project Variants"===x&&(0,s.jsx)(tN,{}),"Project Demands"===x&&(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)(e3,{}),(0,s.jsx)(tr,{})]}),"GWP Checker"===x&&(0,s.jsx)(td,{}),"GWP Resume"===x&&(0,s.jsx)(tj,{})]})]})]}),c&&(0,s.jsxs)("div",{className:"mt-4 pb-2 overflow-x-hidden",children:[(0,s.jsx)(tw.Mp,{sensors:C,collisionDetection:tw.fp,onDragEnd:e=>{if(!y||!e.over)return;let t=String(e.active.id),r=String(e.over.id);if(t===r)return;let s=j.findIndex(e=>e.id===t),a=j.findIndex(e=>e.id===r);-1!==s&&-1!==a&&o((0,k.i1)({id:y.id,indexFrom:s,indexTo:a}))},children:(0,s.jsx)(tA.gB,{items:j.map(e=>e.id),strategy:tA.kL,children:(0,s.jsx)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8",children:j.map(e=>{let t=w===e.id,r=A(e.id);return(0,s.jsx)(tI,{category:e,isSelected:t,hasIncompleteOptions:r},e.id)})})})}),(0,s.jsxs)("button",{type:"button",onClick:()=>p(!0),className:"mt-2 flex items-center justify-center gap-2 rounded-md border border-dashed border-slate-300 bg-white px-3 py-2 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-50",children:[(0,s.jsx)(F.A,{className:"h-4 w-4"}),"Add category"]})]}),(0,s.jsx)(N.A,{openModal:m,setOpenModal:e=>p(!!e),contentComponent:(0,s.jsx)(ew.A,{isModal:!0,setOpenModal:e=>p(!!e)})})]}),(0,s.jsx)("div",{className:"m-5 mt-2",children:l})]}):(0,s.jsx)(ee,{})};function tE(e){let{children:t}=e;return(0,a.useEffect)(()=>{let e=x.Jp.getAllAccounts();e.length>0&&x.Jp.setActiveAccount(e[0]);let t=x.Jp.addEventCallback(async e=>{if(e.eventType===m.B.LOGIN_SUCCESS&&e.payload){let t=e.payload.account;x.Jp.setActiveAccount(t)}});return()=>{t&&x.Jp.removeEventCallback(t)}},[]),(0,s.jsxs)("html",{lang:"en",children:[(0,s.jsxs)("head",{children:[(0,s.jsx)("title",{children:"BAM - Building Assessment Manager"}),(0,s.jsx)("meta",{name:"description",content:"Building Assessment Manager"})]}),(0,s.jsxs)("body",{children:[(0,s.jsx)(o,{children:(0,s.jsxs)(u.r7,{instance:x.Jp,children:[(0,s.jsx)(p.e7,{children:(0,s.jsxs)(tP,{children:[(0,s.jsx)(h.n,{siteUrls:{resourcesLibraryURL:"https://zeroresourcesmanager.vercel.app/",viewer3DURL:"https://3dviewer2.vercel.app/",scmURL:"https://zeroscm.vercel.app/",spaceConfiguratorURL:"https://space-configurator.vercel.app/",epdfinderURL:"https://zeroepdfinder.vercel.app/",netZeroURL:"https://zero-obra-impact.powerappsportals.com/"}}
1),t]})}),(0,s.jsx)(p.hj,{children:(0,s.jsx)(b,{})})]})}),(0,s.jsx)(c.j,{}),(0,s.jsx)(d.l$,{position:"bottom-right",reverseOrder:!1})]})]})}},70906:(e,t,r)=>{"use strict";r.d(t,{D:()=>a});var s=r(12115);let a=()=>{let[e,t]=(0,s.useState)({}),r=(0,s.useCallback)((e,r)=>{t(t=>({...t,[e]:r}))},[]),a=(0,s.useCallback)(t=>e[t]||!1,[e]),n=(0,s.useCallback)(()=>Object.values(e).some(e=>e),[e]);return{setLoading:r,isLoading:a,isAnyLoading:n,clearLoading:(0,s.useCallback)(e=>{t(t=>{let r={...t};return delete r[e],r})},[]),clearAllLoading:(0,s.useCallback)(()=>{t({})},[]),loadingStates:e}}}},e=>{e.O(0,[741,992,647,545,474,652,827,817,419,269,445,441,255,358],()=>e(e.s=22020)),_N_E=e.O()}]);
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.