PageSourceSearch

https://us.fusionmap.com/_next/static/chunks/pages/map-774a9dd2c5f718ff.js

js fusionmap.com collected 2026-10-01 02:00:28 UTC 637,802 bytes, 120 lines download raw bytes

1!function(){try{var e="u">typeof window?window:"u">typeof global?global:"u">typeof globalThis?globalThis:"u">typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3e57de85-3733-4d8d-bf1e-5e534d3a95eb",e._sentryDebugIdIdentifier="sentry-dbid-3e57de85-3733-4d8d-bf1e-5e534d3a95eb")}catch(e){}}(),(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9890],{6328:(e,t,a)=>{"use strict";a.d(t,{A:()=>o});var r=a(37876),s=a(14232),l=a(85428),i=a(57186),n=a(82051);function o(e){let[t,a]=(0,s.useState)(""),o=(0,s.useRef)(null),c=(0,s.useRef)(null),d=(0,s.useRef)(null),[u,p]=(0,s.useState)(!1),m=()=>{e.closeModal(),c.current.click()};return(0,s.useEffect)(()=>{e.isOpen?(p(!1),a("confirmationmodal-"+(0,i.A)()),o.current?.showModal(),d.current?.focus(),(0,l.Fr)()&&(document.documentElement.style.display="none",setTimeout(()=>{document.documentElement.style.display="block"},10))):(p(!1),o.current?.close())},[e.isOpen]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("input",{type:"checkbox",id:t,className:"modal-toggle"}),(0,r.jsxs)("dialog",{ref:o,className:"modal text-black z-46 deleteconfirmation-modal",children:[(0,r.jsxs)("div",{className:"modal-box",children:[(0,r.jsx)("div",{className:"flex flex-row justify-end items-center text-lg gap-2 mb-2",children:(0,r.jsx)("label",{onClick:m,htmlFor:t,className:"btn btn-sm text-lg btn-circle bg-white/60 border-white/60",children:"✕"})}),(0,r.jsx)("p",{className:"text-center font-bold text-[14px] !mt-0",children:e.deleteText?e.deleteText:"Are you sure you want to delete?"}),e.warningText&&(0,r.jsxs)("div",{className:"rounded-md bg-yellow-100 text-black/70 w-full p-3 flex items-center gap-3 mt-3 mb-2",children:[(0,r.jsx)("div",{children:(0,r.jsx)(n.z5h,{size:20})}),(0,r.jsx)("span",{className:"text-sm",children:e.warningText})]}),(0,r.jsxs)("div",{className:"flex gap-2 justify-center mt-4 mb-2",children:[(0,r.jsx)("label",{htmlFor:t,className:"btn btn-sm btn-white",onClick:m,children:"No"}),(0,r.jsx)("button",{id:"delete-confirmation-button",ref:d,className:"btn btn-sm btn-neutral tt-blue-button",onClick:()=>{p(!0),e.onDelete()},disabled:u,autoFocus:!0,"data-testid":"delete-confirmation-button",children:u?(0,r.jsx)("span",{className:"loading loading-spinner loading-sm","data-testid":"delete-confirmation-spinning"}):"Yes"})]})]}),(0,r.jsx)("label",{onClick:m,ref:c,className:"modal-backdrop",htmlFor:t,children:"Close"})]})]})}},11763:(e,t,a)=>{"use strict";a.d(t,{D_:()=>m,Ov:()=>f,W7:()=>h,e9:()=>x,fG:()=>y,kd:()=>b,ly:()=>v,ml:()=>g,oq:()=>w,w3:()=>j});var r=a(84412),s=a(80856),l=a(23323),i=a(15368),n=a.n(i),o=a(12227),c=a(24519),d=a(85428),u=a(97853),p=a(61519);let m=async(e,t,a,r,i,n)=>{try{i(!0);let o=new FormData;o.append("id",e.toString()),o.append("type",a===s.Sw.NOTE?s.Ce.note:s.Ce.alert),o.append("create_date",new Date().toISOString());let c=(0,d.BG)(n);o.append("text",JSON.stringify(c.modifiedText)),o.append("text_with_names",JSON.stringify(c.plainText)),o.append("mentions",JSON.stringify(c.mentions)),t&&o.append("file_upload",t);let u=await (0,l.x)("/thread/create",{method:"POST",form:o});r(u)}catch(e){console.error("Error adding comment: ",e)}finally{i(!1)}},h=(e,t)=>{if(!e||!t)return"";let a=(0,c.decode)(e);return o.A.sanitize(a&&t?a.replace(/@\{([A-Za-z0-9\-]+)\}/g,(e,a)=>{let r=t[a];if(r){let e=n()(`${r.first_name} ${r.last_name}`);return`<span data-mention-chip="true">@${e}</span>`}return'<span data-mention-missing="true">@User not found</span>'}):"",{ALLOWED_TAGS:["b","strong","i","em","u","s","del","br","span","code"],ALLOWED_ATTR:["data-mention-chip","data-mention-missing"],FORBID_ATTR:["style"]})};function x(e,t){let a,r=/@\{([A-Za-z0-9\-]+)\}/g;if(!e)return u.EditorState.createEmpty();let s="",l=[],i={},n=0,o=0;for(;null!==(a=r.exec(e));){let[r,c]=a,d=a.index,u=d+r.length;s+=e.slice(n,d);let p=t?t[c]:null;if(p){let e=p.first_name.trim()+" "+p.last_name.trim(),t=`@${e}`,a=s.length;s+=t,i[o]={type:"mention",mutability:"SEGMENTED",data:{mention:{avatar:p.profile_image||null,email:p.email,id:c,name:e}}},l.push({key:o,offset:a,length:t.length}),o+=1}else s+=r;n=u}let c={key:"block",text:s+=e.slice(n),type:"unstyled",depth:0,inlineStyleRanges:[],entityRanges:l},d=(0,u.convertFromRaw)({blocks:[c],entityMap:i});return u.EditorState.createWithContent(d)}
1let f=async e=>await (0,l.x)("/thread/",{method:"DELETE",json:{id:e},rawResponse:!0}),g=async(e,t,a)=>{try{let r=JSON.parse(localStorage.getItem("project")||"{}"),l="";switch(t){case s.Sw.NOTE:l="notes/";break;case s.Sw.ALERT:l="alerts/"}let i=await (0,p.bB)(r?.container_name+"/"+l+e);a(t=>({...t,[e]:i}))}catch(e){console.error("Error getting thread picture URL:",e)}},y=async(e,t)=>{let a=e===s.Sw.NOTE?s.Ce.note:s.Ce.alert;return await (0,l.x)("/thread/",{params:{id:t,type:a},rawResponse:!0})},b=async(e,t)=>{let a=e===s.Sw.NOTE?s.Ce.note:s.Ce.alert;return await (0,l.x)("/thread/profile-images",{params:{id:t,type:a},rawResponse:!0})},j=async(e,t,a,s,i,n,o,c)=>{let d=new FormData;return d.append("title",t),a.trim()&&d.append("description",a),s.trim()&&d.append("description_with_names",s),d.append("mentions",JSON.stringify(i)),d.append("create_date",n.toISOString()),d.append("delete_image",JSON.stringify(o)),d.append("data",JSON.stringify(c)),await (0,l.x)(r.fn+"/note/update?id="+e,{method:"PATCH",form:d,rawResponse:!0})},w=async(e,t="read")=>{try{await (0,l.x)("/notification",{method:"PATCH",json:{notification_ids:e,status:t}})}catch(e){console.error("Error updating read status:",e)}},v=async(e,t,a,r)=>{try{return await (0,l.x)("/fusionchat/getFile",{method:"GET",params:{project_id:e,source_type:a?.toString()??"",source_id:r?.toString()??"",title:t}})}catch(e){return console.error("Error fetching file:",e),null}}},21623:(e,t,a)=>{"use strict";a.d(t,{Jj:()=>s,kM:()=>l});let r="expiryReminderSnoozedUntil",s=e=>{if(!e?.properties?.expiry_date)return null;let t=new Date(e.properties.expiry_date),a=new Date,s=Math.ceil((t.getTime()-a.getTime())/864e5),l=localStorage.getItem(r);if(l){let e=new Date(l),t=new Date;if(t.setDate(t.getDate()+1),s>7&&a<e&&e<=t)return null;i()}return s>=0&&s<=30?s:null},l=()=>{let e=new Date;e.setDate(e.getDate()+1),e.setHours(0,0,0,0),localStorage.setItem(r,e.toISOString())},i=()=>{localStorage.removeItem(r)}},23512:(e,t,a)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/map",function(){return a(87790)}])},33534:(e,t,a)=>{"use strict";a.d(t,{A:()=>c});var r=a(37876),s=a(84412),l=a(14232);let i=({onChange:e,id:t})=>{let[a,i]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{if(!localStorage.getItem("ms_auth"))return;let a=a=>{let r;if(a&&a.origin&&a.data&&a.origin===s.Z7){try{r=JSON.parse(a.data)}catch{return}r.origin===t&&e({url:r.url,name:r.name,size:r.size})}};return(window.addEventListener("message",a),JSON.parse(localStorage.getItem("ms_auth")||"").access_token)?(i(!0),()=>{window.removeEventListener("message",a)}):void i(!1)},[]),(0,r.jsx)("div",{children:(0,r.jsxs)("div",{children:[(0,r.jsx)("input",{type:"checkbox",id:t,className:"modal-toggle"}),(0,r.jsxs)("div",{className:"modal justify-start! absolute z-50 -top-0 left-0 w-full bg-white! flex flex-col h-full",children:[(0,r.jsxs)("div",{className:"w-full p-0 h-full",children:[(0,r.jsxs)("div",{className:"flex flex-row justify-between items-center mx-5 pt-3 pb-2 border-b border-b-black/10",children:[(0,r.jsx)("span",{className:"font-bold text-lg flex flex-row items-center gap-3",children:"Select from SharePoint / OneDrive"}),(0,r.jsx)("label",{htmlFor:t,className:"btn btn-sm btn-circle btn-ghost",children:"✕"})]}),a?(0,r.jsx)("iframe",{className:"w-full h-full rounded-lg overflow-y-auto",src:`../../libs/sharepoint/index.html?ms_access_token=${JSON.parse(localStorage.getItem("ms_auth")||"").access_token||""}&modal=${t}`,title:"SharePoint"}):(0,r.jsx)("div",{children:"An error occurred while fetching OneDrive/SharePoint content..."})]}),(0,r.jsx)("label",{className:"modal-backdrop",htmlFor:t,children:"Close"})]})]})})};var n=a(23323),o=a(97685);function c(e){let[t,a]=(0,l.useState)(!1),[c,d]=(0,l.useState)(0),[u,p]=(0,l.useState)(null),m=async()=>{let e=JSON.parse(localStorage.getItem("ms_auth")||""),t=new Date(e.last_updated),r=e.refresh_token;if((new Date().getTime()-t.getTime())/36e5>.95)try{let e=await (0,n.x)("/auth/request-microsoft-token",{method:"POST",json:{refresh_token:r}});localStorage.setItem("ms_auth",JSON.stringify({access_token:e.access_token,refresh_token:e.refresh_token,last_updated:new Date}))}catch{o.Ay.error("Failed to update Microsoft token. Please re-authenticate."),localStorage.removeItem("ms_auth"),a(!1);return}a(!0)},h=()=>{d(c+1)};return(0,l.useEffect)(()=>{let e=localStorage.getItem("project"),t=localStorage.getItem("ms_auth");(e&&p(JSON.parse(e)),t&&JSON.parse(t).refresh_token)?m():window.addEventListener("storage",e=>{"ms_auth"==e.key&&a(!0)})},[]),(0,l.useEffect)(()=>{h()},[t]),(0,r.jsx)("div",{className:"w-full",children:u&&u.integrations&&u.integrations.includes("sharepoint")&&(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"flex justify-center w-full mt-2",children:(0,r.jsxs)("label",{htmlFor:e.modalHtml,className:"sharepoint-button",onClick:t?h:()=>
1{let e="https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id="+s.U6+"&response_type=code&redirect_uri="+encodeURIComponent(s.fn+"/auth/request-sharepoint-access")+"&response_mode=query&scope=Files.Read User.Read offline_access&state=43";window.open(e)},children:[(0,r.jsx)("img",{src:"/images/sharepoint-icon.png",className:"mr-2 h-5 w-5"})," ",t?"Select from SharePoint / OneDrive":"Authenticate to SharePoint / OneDrive"]})}),(0,r.jsx)(i,{id:e.modalHtml,onChange:async t=>{let a=document.getElementById(e.modalHtml);a&&(a.checked=!1,e.onChange(t))}},c)]})})}},36367:(e,t,a)=>{"use strict";a.d(t,{A:()=>n});var r=a(37876),s=a(14232),l=a(84412),i=a(21034);function n(e){let t=(0,i.u)(),[a,n]=(0,s.useState)("en");return((0,s.useEffect)(()=>{t?.user?.lang===null?(localStorage.setItem("lang","en"),n("en")):n(localStorage.getItem("lang")||"en")},[t?.lang]),e.displaySelectMenu)?(0,r.jsxs)("div",{className:"flex-col",children:[e.displayLabel&&(0,r.jsx)("span",{className:"text-sm text-gray-400",children:"Language"}),(0,r.jsxs)("div",{className:"flex gap-2 items-center mt-1 hover:opacity-90 relative",children:[(0,r.jsx)("img",{src:`/images/flags/${a}.svg`,width:28,className:`rounded shadow absolute z-10 ${"dark"===e.theme?"ml-3":"left-[15px]"}`,"aria-hidden":"true",alt:""}),(0,r.jsx)("select",{value:a,onChange:e=>{var a;let r;return a=e.target.value,localStorage.setItem("lang",a),n(a),t?.setLang(a),void((r=document.querySelector(".goog-te-combo"))&&(r.value=a,r.dispatchEvent(new Event("change",{bubbles:!0}))),(r=document.querySelector(".goog-te-combo"))&&(r.value=a,r.dispatchEvent(new Event("change",{bubbles:!0}))))},className:`select pl-10 ${"dark"===e.theme?"bg-black/5 border border-white/10":"bg-white"} select-bordered`,children:l.gq.map((e,t)=>(0,r.jsxs)("option",{value:e.value,className:"notranslate",children:["\xa0\xa0\xa0\xa0\xa0",e.label]},t))})]})]}):null}},46998:(e,t,a)=>{"use strict";a.d(t,{A:()=>c});var r=a(37876);a(14232);var s=a(25072),l=a(55283),i=a(95471),n=a(82051);function o(e){let t=(0,l.JY)();return(0,r.jsx)("div",{onClick:()=>{!t.map.current||e.lon&&e.lat&&t.map.current.flyTo({center:[e.lon,e.lat],zoom:18,essential:!0,duration:i.AD})},className:"inline-flex items-center gap-1 p-1 border border-black/10 rounded-lg shadow cursor-pointer hover:shadow-md bg-slate-50",children:(0,r.jsx)(n.meu,{color:"#2563eb"})})}let c=({content:e})=>(0,r.jsx)(s.Ay,{options:{overrides:{a:{component:({children:e,...t})=>(0,r.jsx)("a",{className:"text-blue-600 hover:underline",...t,children:e}),props:{className:"text-blue-600 hover:underline"}},strong:{component:({children:e,...t})=>(0,r.jsx)("strong",{className:"font-bold",...t,children:e}),props:{className:"font-bold"}},b:{component:({children:e,...t})=>(0,r.jsx)("b",{className:"font-bold",...t,children:e}),props:{className:"font-bold"}},ul:{component:({children:e,...t})=>(0,r.jsx)("ul",{className:"list-disc pl-5",...t,children:e}),props:{className:"list-disc pl-5"}},ol:{component:({children:e,...t})=>(0,r.jsx)("ol",{className:"list-decimal pl-5",...t,children:e}),props:{className:"list-decimal pl-5"}},li:{component:({children:e,...t})=>(0,r.jsx)("li",{className:"mb-1",...t,children:e}),props:{className:"mb-1"}},code:{component:({className:e,children:t,...a})=>(0,r.jsx)("code",{className:`bg-gray-200 p-1 rounded ${e}`,...a,children:t}),props:{className:"bg-gray-200 p-1 rounded"}},pre:{component:({children:e,...t})=>(0,r.jsx)("pre",{className:"bg-gray-200 p-2 rounded overflow-x-auto",...t,children:e}),props:{className:"bg-gray-200 p-2 rounded overflow-x-auto"}},h1:{component:({children:e,...t})=>(0,r.jsx)("h1",{className:"text-2xl font-bold mb-2",...t,children:e}),props:{className:"text-2xl font-bold mb-2"}},h2:{component:({children:e,...t})=>(0,r.jsx)("h2",{className:"text-xl font-bold mb-2",...t,children:e}),props:{className:"text-xl font-bold mb-2"}},h3:{component:({children:e,...t})=>(0,r.jsx)("h3",{className:"text-lg font-bold mb-2",...t,children:e}),props:{className:"text-lg font-bold mb-2"}},p:{component:({children:e,...t})=>(0,r.jsx)("p",{className:"mb-2",...t,children:e}),props:{className:"mb-2"}}
1,blockquote:{component:({children:e,...t})=>(0,r.jsx)("blockquote",{className:"border-l-4 border-gray-500 pl-4 italic",...t,children:e}),props:{className:"border-l-4 border-gray-500 pl-4 italic"}},img:{component:({src:e,alt:t,...a})=>(0,r.jsx)("img",{src:e,alt:t,className:"max-w-full h-auto",...a}),props:{className:"max-w-full h-auto"}},div:{component:({className:e,children:t,...a})=>"fchatlocation"===e?(0,r.jsx)("div",{className:"bg-red-500 text-white p-2 rounded",...a,children:t}):(0,r.jsx)("div",{...a,children:t}),props:{className:"bg-red-500 text-white p-2 rounded"}},zoomtolocation:{component:({lon:e,lat:t,...a})=>(0,r.jsx)(o,{lon:e,lat:t,...a})}}},className:"fusionchat-response-text",children:e})},48518:(e,t,a)=>{"use strict";a.d(t,{O:()=>n});var r=a(14232),s=a(89977),l=a(85428);let i={display:!1,zIndex:40},n=e=>{let t=(0,s.H)(),a=(0,r.useMemo)(()=>e?t.showModals[e]??i:i,[t.showModals,e]),n=()=>{let e=Object.values(t.showModals);return e.length>0?Math.max(...e.map(e=>e?.zIndex??40)):40},o=(a,r)=>{let s=r??e;if(!s)return;let l=t.showModals[s]??i;t.setShowModals(e=>({...e,[s]:{...l,...a,...!1===a.display&&{zIndex:40}}}))},c=e=>{o({display:!0,zIndex:n()+1},e),u(e)},d=e=>{o({display:!1},e)},u=a=>{let r=a??e;if(!r)return;let s=t.showModals[r]??i;if((0,l.Fr)()){let e=n()+1;t.setShowModals(t=>{let a={...t};return Object.keys(t).forEach(s=>{let l=s===r;a[s]={...t[s]??i,display:l,zIndex:l?e:40}}),a});return}s.display&&o({zIndex:n()+1},a)};return{modalState:a,getModalState:a=>{let r=a??e;return r?t.showModals[r]??i:i},openModal:c,closeModal:d,toggleModal:a=>{let r=a??e;r&&((t.showModals[r]??i).display?d(a):c(a))},clickModal:u}}},56276:(e,t,a)=>{"use strict";a.d(t,{A:()=>g});var r=a(37876),s=a(14232),l=a(22427),i=a(61902),n=a(39149),o=a(84412),c=a(23323),d=a(97685),u=a(80856),p=a(85428),m=a(21034);let h=(0,l.c)(o.no?.stripe_publishable_key),x={mode:"subscription",currency:"usd",amount:4500,setup_future_usage:"off_session",payment_method_types:["card"]};function f(e){let t=(0,i.useStripe)(),a=(0,m.u)(),l=(0,i.useElements)(),[,h]=(0,s.useState)(null),[f,g]=(0,s.useState)(!1),[y,b]=(0,s.useState)(!1),[j,w]=(0,s.useState)(!1),[v,N]=(0,s.useState)("monthly"),[S,k]=(0,s.useState)(""),[_,C]=(0,s.useState)(),L=async r=>{if(r.preventDefault(),!t||!l)return;let{error:s}=await l.submit();if(s)return void h(s.message);g(!0);try{let r,s=(await (0,c.x)("/stripe/subscribe",{method:"POST",json:{priceId:o.no.premium_layers_monthly_price_id,promoId:_?.promo_id}})).clientSecret;if(null!=s)({error:r}=await t.confirmPayment({elements:l,clientSecret:s,confirmParams:{return_url:`${window.location.origin}/map`},redirect:"if_required"}));else{if((_?.percent_off==100||_?.amount_off==x.amount)&&_?.duration=="forever")return void setTimeout(()=>{a?.refetch({query:{disableCookieCache:!0}}),w(!0),e.setPremium(u.Jr.premium),g(!1)},5e3);d.oR.error("Error while processing your order"),g(!1);return}r?(d.oR.error(r.message),g(!1)):setTimeout(()=>{a?.refetch({query:{disableCookieCache:!0}}),w(!0),e.setPremium(u.Jr.premium),g(!1)},5e3)}catch{d.oR.error("Unexpected error"),g(!1)}},D=async()=>{b(!0);try{let e=await (0,c.x)("/stripe/coupon",{params:{promoCode:S}});C({...e.promotion_code.coupon,promo_id:e.promotion_code.id}),d.oR.success("Coupon applied")}catch(e){d.oR.error(e instanceof Error?e.message:"Something went wrong. Please try again")}b(!1)};return(0,r.jsx)(r.Fragment,{children:j?(0,r.jsxs)("div",{className:"p-6 justify-center flex flex-col items-center text-black",children:[(0,r.jsx)(n.mcb,{size:40,color:"#4CAF50",className:"mt-2 animate-jump-in"}),(0,r.jsx)("span",{className:"text-xl text-green-700 mt-3",style:{color:"#4CAF50"},children:"Payment Successful!"}),(0,r.jsx)("span",{className:"opacity-60 text-sm mt-2 text-center",children:"You can easily cancel this subscription anytime in your profile"}),(0,r.jsx)("div",{className:"flex justify-end mt-8 w-full",children:(0,r.jsx)("div",{className:"btn w-full",onClick:()=>{f||e.closeModal()},children:"Close"})})]}):(0,r.jsxs)("div",{className:"px-6 pt-6 flex flex-col",children:[(0,r.jsx)(d.l$,{}),(0,r.jsxs)("div",{className:"tabs tabs-box flex w-full mb-5 gap-4",children:[(0,r.jsx)("a",{className:`tab flex-1 ${"monthly"===v?"tab-active-layers":""}`,onClick:()=>N("monthly"),children:(0,r.jsx)("span",{className:"text-xs desktop:text-sm",children:"Monthly"})}),(0,r.jsx)("a",{className:`tab flex-1 cursor-default ${"annually"===v?"tab-active-layers":""}`,children:(0,r.jsxs)("span",{className:"text-xs desktop:text-sm flex items-center gap-2",children:["Annually",(0,r.jsx)("div",{className:"bg-[#d0e2ff] text-[#002d9c] text-[11px] py-[2px] px-1 font-bold rounded-xl shadow",children:"Coming soon"})]})})]}),(0,r.jsxs)("form",{onSubmit:L,className:"text-black",children:[(_?.percent_off!=100&&_?.amount_off!=x.amount||_?.duration!="forever")&&(0,r.jsx)(i.PaymentElement,{}),(0,r.jsx)("div",{className:"flex flex-row justify-center w-full",children:!_&&(0,r.jsxs)("div",{className:"flex items-center mt-3 w-full gap-1",children:[(0,r.jsx)("input",{type:"text",value:S,onChange:e=>k(e.target.value),placeholder:"Enter coupon code",className:"input select-bordered w-full"}),(0,r.jsx)("button",{className:"btn tt-blue-button",type:"button",onClick:D,children:y?(0,r.jsx)("span",{className:"loading loading-spinner loading-sm"}):(0,r.jsx)(r.Fragment,{children:"Apply"})})]})}),(_?.percent_off==100||_?.amount_off==x.amount)&&_?.duration=="forever"&&(0,r.jsx)("div",{className:"rounded-md bg-tt-blue/10 opacity-70 w-full py-3 px-2 flex items-center justify-center gap-2 text-sm mb-3 text-center",children:(0,r.jsxs)("span",{children:["You've applied a ",(0,r.jsx)("b",{children:"100% discount"}),". No credit card required. Activate premium features by clicking the subscribe button below"]})}),(_?.percent_off==100||_?.amount_off==x.amount)&&_?.duration==="once"&&(0,r.jsx)("div",{className:"rounded-md bg-tt-blue/10 opacity-70 w-full py-3 px-2 flex items-center justify-center gap-2 text-sm mb-3 text-center",children:(0,r.jsx)("span",{children:"You applied a 100% discount for the first month. Please provide your credit card information for future payments."})}),(0,r.jsxs)("div",{className:"rounded-lg border p-3 flex flex-col text-black my-5 text-[14px] bg-gray-200/10 border-black/10",children:[(0,r.jsxs)("div",{className:"flex flex-row justify-between",children:[(0,r.jsx)("span",{children:"Premium plan"}),(0,r.jsxs)("span",{children:["$",(x.amount/100).toFixed(2)," billed monthly"]})]}),_&&(0,r.jsxs)("div",{className:"flex flex-row justify-between pb-1 text-green-600 mt-2",children:[(0,r.jsx)("span",{children:"Coupon"}),(0,r.jsxs)("span",{children:[" - $",(0,p.GF)(x.amount,_)," (-",(0,p.F$)(x.amount,_),"%) "]})]}),(0,r.jsx)("div",{className:"mt-2 flex flex-row justify-between border-b pb-1 border-black/10"}),(0,r.jsxs)("div",{className:"font-bold flex justify-between mt-2",children:[(0,r.jsx)("span",{children:"Total"}),(0,r.jsxs)("span",{children:["$",(0,p.Qn)(x.amount,_)," including tax"]})]})]}),(0,r.jsxs)("div",{className:"flex justify-between mt-2 w-full",children:[(0,r.jsx)("button",{className:"btn tt-blue-button w-9/12",type:"submit",disabled:!t||f,children:f?(0,r.jsx)("span",{className:"loading loading-spinner loading-sm"}):(0,r.jsx)(r.Fragment,{children:"Subscribe to Premium Layers"})}),(0,r.jsx)("div",{className:"btn",onClick:()=>{f||e.closeModal()},children:"Cancel"})]})]}),(0,r.jsx)("a",{href:"https://stripe.com",target:"_blank",className:"w-full flex justify-center my-3",rel:"noreferrer",children:(0,r.jsxs)("div",{className:"flex items-center opacity-60 text-black text-[11px]",children:["Secure payment gateway powered by\xa0\xa0",(0,r.jsx)("img",{src:"/images/stripe.svg",alt:"Stripe logo",width:30})]})})]})})}let g=function(e){return(0,r.jsx)("div",{className:"App",children:(0,r.jsx)(i.Elements,{stripe:h,options:x,children:(0,r.jsx)(f,{setPremium:e.setPremium,closeModal:e.closeModal})})})}},59673:(e,t,a)=>{"use strict";function r(e){if(!e)return"file";try{let t=new URL(e,window.location.origin),a=t.pathname.endsWith("/")?t.pathname.slice(0,-1):t.pathname;return decodeURIComponent(a.substring(a.lastIndexOf("/")+1))||"file"}catch{let t=e.split(/[\?#]/)[0],a=t.endsWith("/")?t.slice(0,-1):t;return a.substring(a.lastIndexOf("/")+1)||"file"}}a.d(t,{iX:()=>s,k1:()=>l,nU:()=>r});let s="light",l=["annotation","redaction","panel-comment","document"]},61854:(e,t,a)=>{"use strict";a.d(t,{R:()=>l});var r=a(37876),s=a(80856);let l=({daysUntilExpiry:e,variant:t})=>(0,r.jsx)(r.Fragment,{children:e>0?(0,r.jsxs)("span",{children:["Your account expires in ",t===s.i7.Box&&(0,r.jsx)("br",{}),(0,r.jsxs)("strong",{children:[e," day",1===e?"":"s"]})]}):(0,r.jsxs)("span",{children:["Your account expires ",t===s.i7.Box&&(0,r.jsx)("br",{}),(0,r.jsx)("strong",{children:"today"})]})})},68435:(e,t,a)=>{"use strict";a.d(t,{A:()=>A});var r=a(37876),s=a(14232),l=a(97685),i=a(46998),n=a(80856),o=a(39149),c=a(85428),d=a(8135),u=a(23323);function p({message:e,agent:t}
1){let[a,i]=(0,s.useState)(!1),o=async r=>{if(a)return void l.Ay.error("You have to wait a few seconds before sending another reaction");i(!0);try{await (0,u.x)("/fusionchat/messageFeedback",{method:"POST",json:{agent:t,answer:e,reaction_type:r}}),l.Ay.success("Thank you for your feedback")}catch{l.Ay.error("An error occurred while sending feedback")}finally{setTimeout(()=>i(!1),1e4)}};return(0,r.jsxs)("div",{className:"self-start flex flex-col gap-1 items-center mt-2 message-icons",children:[(0,r.jsx)(d.Xpf,{onClick:()=>(0,c.lW)(e),size:13,className:"fchat-chat-menu-icon text-black/30"}),(0,r.jsx)(d.$qj,{onClick:()=>o(n.o.like),size:13,className:"fchat-chat-menu-icon text-black/30"}),(0,r.jsx)(d.d1R,{onClick:()=>o(n.o.dislike),size:13,className:"fchat-chat-menu-icon text-black/30"})]})}let m=({messages:e,pending:t,pendingSourceDocs:a,loading:l,onHintClick:c})=>{let d=(0,s.useMemo)(()=>[...e,...t?[{type:"apiMessage",message:t,sourceDocs:a,agent:n.g6.SQL}]:[]],[e,t,a]);return(0,r.jsx)("div",{className:"text-[14px]",children:(0,r.jsx)("main",{children:(0,r.jsxs)("div",{children:[d.map((t,a)=>{var s;let l,d,u,m,{hints:h,cleanedContent:x}=(s=t.message,u=Array.from(d=(l=new DOMParser().parseFromString(s,"text/html")).querySelectorAll("div#fusionhintquestion")).map(e=>e.textContent||""),d.forEach(e=>e.remove()),{hints:u,cleanedContent:l.body.innerHTML});return(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsx)("div",{className:"message-container px-3 py-1 text-[14px]",children:"apiMessage"===t.type?(0,r.jsxs)("div",{className:"flex float-left flex-row justify-between self-start my-2 items-center gap-2",children:[(0,r.jsxs)("div",{className:"flex flex-col items-center opacity-60",children:[t.agent===n.g6.PDF?(0,r.jsx)(o.oSi,{size:14}):(0,r.jsx)("img",{src:"/images/brain_black.svg",width:"16",height:"16",alt:"AI Icon"}),(0,r.jsx)("span",{className:"text-[9px]",children:t.agent===n.g6.PDF?"DOC":"PRJ"})]}),(0,r.jsx)("div",{className:"p-2 rounded-xl bg-gray-300/30 max-w-[250px] w-auto overflow-wrap break-word",children:(0,r.jsx)("div",{children:(0,r.jsx)(i.A,{content:x})})}),(0,r.jsx)(p,{message:t.message,agent:t.agent||n.g6.SQL})]}):"userMessage"===t.type?(0,r.jsx)("div",{className:"p-2 rounded-xl bg-tt-blue text-white float-right max-w-[250px] w-auto break-word",children:t.message}):(0,r.jsx)("div",{className:"my-4",children:(m=(t.agent||n.g6.SQL)===n.g6.PDF?"PDF file":"project",(0,r.jsxs)("div",{className:"flex items-center my-2",children:[(0,r.jsx)("div",{className:"grow border-t border-gray-300"}),(0,r.jsxs)("span",{className:"mx-2 text-gray-500 text-left",children:["You are now chatting with ",m]}),(0,r.jsx)("div",{className:"grow border-t border-gray-300"})]}))},`breakline-${a}`)}),t?.sourceDocs&&(0,r.jsx)("div",{className:"",children:t?.sourceDocs.map((e,t)=>(0,r.jsx)("div",{},`messageSourceDocs-${t}`))},`sourceDocsAccordion-${a}`),0===a&&1===e.length&&(0,r.jsxs)("div",{className:"flex flex-wrap gap-2 ml-8",children:[(0,r.jsxs)("div",{className:"fusionchat-hint",onClick:()=>c("How many notes are in the project?"),children:[(0,r.jsx)(o.T7J,{})," How many notes are in the project?"]}),(0,r.jsxs)("div",{className:"fusionchat-hint",onClick:()=>c("Show the last alert"),children:[(0,r.jsx)(o.T7J,{})," Show the last alert"]}),(0,r.jsxs)("div",{className:"fusionchat-hint",onClick:()=>c("List all urgent alerts"),children:[(0,r.jsx)(o.T7J,{})," List all urgent alerts"]})]}),h.length>0&&(0,r.jsx)("div",{className:"flex flex-wrap gap-2 ml-8 mb-4",children:h.map((e,t)=>(0,r.jsxs)("div",{className:"fusionchat-hint",onClick:()=>c(e),children:[(0,r.jsx)(o.T7J,{})," ",e]},t))})]},`chatMessage-${a}`)}),l&&(0,r.jsxs)("div",{className:"flex gap-2 items-center mt-3 ml-3 mb-3",children:[(0,r.jsx)("div",{className:"w-8 h-8 skeleton rounded-full bg-gray-300/30"}),(0,r.jsx)("div",{className:"w-[70%] h-8 skeleton bg-gray-300/30"})]})]})})})};var h=a(55351);let x=({loading:e,query:t,setQuery:a,handleEnter:s,handleSubmit:l,textAreaRef:i,clearFusionchat:n})=>(0,r.jsxs)("div",{className:"border-t border-black/10 px-3 pt-3 pb-1 w-full flex flex-col left-0  bg-[#f1f3f5] text-center p-4 shadow",children:[(0,r.jsxs)("form",{onSubmit:e=>l(e,t),className:"flex items-center justify-between gap-2",children:[(0,r.jsx)(h.vrP,{className:`curs
1or-pointer hover:opacity-70 ${e?"pointer-events-none opacity-50":"pointer-events-auto"}`,size:26,onClick:n}),(0,r.jsx)("input",{disabled:e,onKeyDown:s,ref:i,autoFocus:!0,autoComplete:"off",maxLength:400,id:"userInput",name:"userInput",placeholder:e?"Waiting for response...":"Ask Pulse",value:t,onChange:e=>a(e.target.value),className:"fusionchat-input text-[14px] desktop:text-sm input input-sm w-full shadow-sm text-black"}),e?(0,r.jsx)("span",{className:"loading loading-spinner loading-md"}):(0,r.jsx)("button",{type:"submit",disabled:e,children:(0,r.jsx)(d.IkI,{size:26,color:"#2563eb",className:"cursor-pointer hover:opacity-70"})})]}),(0,r.jsx)("span",{className:"mt-2 text-center opacity-50 text-[11px]",children:"Pulse uses AI. Check for mistakes."})]});var f=a(50416),g=a(10841),y=a.n(g),b=a(6328),j=a(33534),w=a(61519),v=a(30328),N=a(72080),S=a(21034),k=a(77784),_=a(48518);function C({closeModal:e,setSelectedFiles:t,isOpen:a}){let i=(0,s.useRef)(null),d=(0,S.u)(),p=(0,v.C)(),m=(0,s.useContext)(N.bM),h=(0,k.O)(),{openModal:x}=(0,_.O)(n.dW.PDFViewerModal),[g,L]=(0,s.useState)(),[,D]=(0,s.use
1State)(),[A,M]=(0,s.useState)(""),[E,T]=(0,s.useState)(!0),[I,P]=(0,s.useState)(!1),[F,O]=(0,s.useState)({show:!1,pdf:null}),[R,$]=(0,s.useState)(!1),z=g?.filter(e=>e.title.toLowerCase().includes(A.toLowerCase())),U=()=>{e(),i.current?.close()},W=a=>{t([a]),e()};(0,s.useEffect)(()=>{i.current?.showModal(),B()},[a]);let B=async()=>{if(!h.project)return;T(!0);let e=await (0,u.x)("/fusionchat/getFiles",{method:"POST",json:{project_id:h.project.project_uuid}});T(!1),L(e)},V=async e=>{h.project&&(D(e),P(!0),await (0,c.uW)(e,h.project,!0,J))},G=async e=>{h.project&&(P(!0),await (0,c.uW)(null,h.project,!0,J,e))},J=async e=>{try{(await e.text()).trim().split("\n").map(e=>{try{return JSON.parse(e)}catch(t){return console.error("Invalid JSON line:",e,t),null}}).filter(Boolean).find(e=>"completed"===e.status)&&($(!0),P(!1),await B(),setTimeout(()=>{$(!1)},5e3))}catch(e){console.error("Error parsing response JSON:",e),l.Ay.error("Failed to process file upload."),P(!1)}},q=async()=>{d?.user&&m&&h.project&&(T(!0),O({show:!1,pdf:null}),await (0,u.x)("/fusionchat/deleteFile",{method:"DELETE",json:{container_name:h.project.container_name,file_name:F.pdf?.file_name,source_type:F.pdf?.source_type,source_id:F.pdf?.source_id,title:F.pdf?.title,vector_table_name:F.pdf?.vector_table_name}}),await B(),m.setUpdate(e=>e+1))};return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{children:[(0,r.jsx)(b.A,{isOpen:F.show,onDelete:q,closeModal:()=>O({show:!1,pdf:null})}),(0,r.jsx)("input",{type:"checkbox",id:"my_modal_7",className:"modal-toggle"}),(0,r.jsxs)("div",{className:"modal justify-start! px-4 absolute z-50 -top-0 left-0 w-full! bg-white! overflow-y-auto flex flex-col h-full overflow-x-hidden",children:[(0,r.jsxs)("div",{className:"w-full",children:[(0,r.jsxs)("div",{className:"flex flex-row justify-between items-center mt-2",children:[(0,r.jsx)("span",{className:"font-bold text-lg flex flex-row items-center gap-3",children:"Select or upload a file"}),(0,r.jsx)("label",{onClick:U,htmlFor:"my_modal_7",className:"btn btn-sm btn-circle btn-ghost",children:"✕"})]}),(0,r.jsx)("div",{className:"w-full h-px bg-gray-300/50 mt-3",children:(0,r.jsxs)("div",{className:"pt-4",children:[I?(0,r.jsxs)("div",{className:"flex-col w-full gap-2 flex items-center py-5 bg-gray-300/10 rounded-lg",children:[(0,r.jsx)("span",{className:"loading loading-spinner"}),(0,r.jsx)("span",{className:"text-black/60 text-sm text-center",children:"Uploading and processing the file. This may take some time..."})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(f.l,{handleChange:V,name:"file",types:["PDF"],classes:"file-uploader",children:(0,r.jsxs)("div",{className:"file-uploader-box",children:[(0,r.jsx)(o.v4w,{size:18,className:"flex opacity-50"}),(0,r.jsx)("span",{className:"opacity-50 mt-1",children:"Upload a PDF file"}),(0,r.jsx)("span",{className:"opacity-50 text-xs",children:"Max: 2 GB"})]})}),(0,r.jsx)(j.A,{modalHtml:"sharepoint-select-pdf-modal",onChange:e=>{e.name.split(".").pop()?.toLowerCase()!="pdf"?l.Ay.error("Invalid format. Please select a PDF."):G(e)}})]}),g&&g.length>0&&(0,r.jsxs)("label",{className:"input input-sm mt-2 w-full",children:[(0,r.jsx)("svg",{className:"h-[1em] opacity-50",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsxs)("g",{strokeLinejoin:"round",strokeLinecap:"round",strokeWidth:"2.5",fill:"none",stroke:"currentColor",children:[(0,r.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,r.jsx)("path",{d:"m21 21-4.3-4.3"})]})}),(0,r.jsx)("input",{type:"search",required:!0,placeholder:"Search",value:A,onChange:e=>M(e.target.value)})]}),E?(0,r.jsx)("div",{className:"w-full flex justify-center mt-10",children:(0,r.jsx)("span",{className:"loading loading-spinner"})}):(0,r.jsx)(r.Fragment,{children:z&&z.length>0?(0,r.jsx)("ul",{className:"overflow-auto  mt-4",children:z.map((e,t)=>(0,r.jsxs)("li",{className:`flex items-center justify-between gap-2 p-2 ${t!==z.length-1?"border-b border-gray-300":""} ${0===t&&R?"fade-out":""}`,children:[(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsx)("span",{className:"font-bold text-[12px]",title:e.title,children:e.title.substring(0,19)+(e.title.length>19?"...":"")}),(0,r.jsx)("span",{className:"opacity-70 text-[11px]",children:y()(e.created).format("M/D/YYYY h:mm A")})]}),(0,r.jsxs)("div",{className:"flex gap-1",children:[(0,r.jsxs)("label",{onKeyDown:()=>{W(e),p.setPulseChatFile(e)},onClick:()=>{W(e),p.setPulseChatFile(e)},htmlFor:"my_modal_7",className:"btn btn-xs flex items-center justify-center gap-x-0",children:[(0,r.jsx)("img",{src:"/images/pulselogo.svg",alt:"Chat Icon",className:"w-[24px] h-[24px] align-middle shrink-0"}),(0,r.jsx)("span",{className:"text-[12px]",children:"Chat"})]}),(0,r.jsx)("div",{className:"btn btn-xs",onClick:async()=>
1{if(!h.project)return;let t=await (0,w.bB)(h.project.container_name+"/fusionchat/"+e.file_name);p.setPdfUrl(t),p.setPulseChatFile(e),p.setPdfSource({source_type:e.source_type,source_id:e.source_id}),x()},children:(0,r.jsx)(o.oSi,{})}),(e.user_id==d?.user?.id||h.project&&(0,c._A)(d?.user,h.project.project_uuid))&&(0,r.jsx)("div",{className:"btn btn-xs",onClick:()=>O({show:!0,pdf:e}),children:(0,r.jsx)(o.WeY,{})})]})]},e.vector_table_name))}):(0,r.jsx)("div",{className:"w-full flex justify-center mt-10 opacity-40 text-center text-sm",children:(0,r.jsx)("span",{children:A?"No files match your search query.":"No files available. Your uploaded PDF files will be stored here."})})})]})})]}),(0,r.jsx)("label",{className:"modal-backdrop",onClick:U,htmlFor:"my_modal_7",children:"Close"})]})]})})}var L=a(29374);let D=e=>({messages:[{message:`Hello ${e?.user?.first_name} 👋
2
3I'm Pulse, your helpful AI assistant. I can assist you with:
4- Project inquiries, such as "How many notes are in the project?"
5- Chatting with PDF files
6
7How can I assist you today?`,type:"apiMessage"}],history:[],pendingSourceDocs:[]}),A=()=>{let e=(0,S.u)(),t=(0,v.C)(),a=(0,k.O)(),{openModal:i}=(0,_.O)(n.dW.PDFViewerModal),[c,d]=(0,s.useState)(""),[p,h]=(0,s.use
7State)(),f=(0,s.useRef)(null),g=(0,s.useRef)(null),[y,b]=(0,s.useState)(!1),[j,N]=(0,s.useState)(()=>D(e)),[A,M]=(0,s.useState)(!1),{setSidePanelActionButtons:E}=(0,L.p)(),{messages:T,pending:I,history:P,pendingSourceDocs:F}=j,O=p&&p.length>0&&p[0].summary,R=p&&p.length>0,$=0===P.length,z=(0,s.useRef)(!1),U=()=>{h(null),G(n.g6.SQL),t.setPulseChatFile(null)};(0,s.useEffect)(()=>(E((0,r.jsx)(r.Fragment,{children:p?(0,r.jsxs)("div",{className:"flex gap-1",children:[(0,r.jsxs)("div",{onClick:async()=>{if(!a.project)return;let e=await (0,w.bB)(a.project.container_name+"/fusionchat/"+p[0].file_name);t.setPdfUrl(e),t.setPulseChatFile(p[0]),t.setPdfSource({source_type:p[0].source_type,source_id:p[0].source_id}),i()},className:"btn btn-sm shadow",children:[(0,r.jsx)(o.oSi,{size:16}),"View"]}),(0,r.jsx)("div",{onClick:U,onKeyDown:U,className:`btn btn-sm shadow ${y?"pointer-events-none":"pointer-events-auto"}`,children:(0,r.jsx)(o.fUT,{size:16})})]}):(0,r.jsxs)("label",{htmlFor:"my_modal_7",className:"btn btn-sm shadow",children:[(0,r.jsx)(o.oSi,{size:16}),"Select PDF"]})})),()=>E(null)),[E,p]);let W=(e,t)=>{e.preventDefault(),B(t)},B=async(e,t=!0)=>{if(!e)return;let r=e.trim();t&&N(e=>({...e,messages:[...e.messages,{type:"userMessage",message:r}],pending:void 0})),b(!0),d(""),N(e=>({...e,pending:""}));let s={project_id:a.project?.project_uuid,question:r,history:P[0]||[""],agent:"sql"};if(R&&(s.pdfs=[p[0]]),O&&$){let e=p[0].summary??"";N(t=>({...t,messages:[...t.messages,{type:"apiMessage",message:e,sourceDocs:[],agent:p?n.g6.PDF:n.g6.SQL}],history:[...t.history,[r,e]]})),b(!1)}else try{let e=await (0,u.x)("/fusionchat/chat",{method:"POST",json:s});e.error?l.Ay.error(e.error):(R&&!O&&(p[0].summary=e.text),N(t=>({...t,messages:[...t.messages,{type:"apiMessage",message:e.text,sourceDocs:e.sourceDocuments,agent:p?n.g6.PDF:n.g6.SQL}],history:[...t.history,[r,e.text]]}))),b(!1)}catch{b(!1),l.Ay.error("An error occurred while fetching the data. Please try again.")}};(0,s.useEffect)(()=>{let e=f.current;e&&(e.scrollTop=e.scrollHeight),t.setPulseChat(j)},[j]),(0,s.useEffect)(()=>{z.current||g.current&&(g.current.focus(),z.current=!0)},[]),(0,s.useEffect)(()=>{null!==t.pulseChat&&(N(t.pulseChat),null!==t.pulseChatFile&&h([t.pulseChatFile]))},[]),(0,s.useEffect)(()=>{t.pulseChatFile&&p?.[0].title!==t.pulseChatFile.title&&(t.pulseChat&&N(t.pulseChat),G(n.g6.PDF),h([t.pulseChatFile]))},[t.pulseChatFile]);let V=(0,s.useCallback)(e=>{"Enter"!==e.key||(e.preventDefault(),e.stopPropagation(),c&&W({preventDefault:()=>{}},c))},[c]);(0,s.useEffect)(()=>{p&&B("Now I switched or selected a file. Show to user: You selected "+p[0].file_name+". This file is about (very briefly max 320 chars, explain the document what is it about). Also generate 3 short Fusion hint question, each question should be max 40 characters.",!1)},[p]);let G=e=>{N(t=>({...t,messages:[...t.messages,{type:"breakline",agent:e}],history:[]}))};return(0,r.jsxs)("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[(0,r.jsxs)("div",{className:"shrink-0",children:[(0,r.jsx)(C,{isOpen:A,closeModal:()=>M(!1),setSelectedFiles:e=>{h(e),G(n.g6.PDF)}}),(0,r.jsx)("div",{className:"p-2 text-center bg-gray-400/20 shadow opacity-80",children:p?(0,r.jsx)("div",{className:"px-[3px] text-xs text-center",children:(0,r.jsx)("span",{title:p[0].title,children:"Chatting with: "+(p[0].title.length>25?p[0].title.substring(0,25)+"...":p[0].title)})}):(0,r.jsx)("div",{className:"text-center px-[3px] text-xs",children:(0,r.jsx)("span",{className:"text-center",children:"No file selected. Chatting with the project"})})})]}),(0,r.jsx)("div",{ref:f,className:"break-words flex-1 min-h-0 overflow-y-auto px-2",children:(0,r.jsx)(m,{messages:T,pending:I,pendingSourceDocs:F,loading:y,onHintClick:e=>{d(e),W({preventDefault:()=>{}},e)}})}),(0,r.jsx)("div",{className:"shrink-0",children:(0,r.jsx)(x,{loading:y,query:c,setQuery:d,handleEnter:V,handleSubmit:W,textAreaRef:g,clearFusionchat:()=>{N(D(e)),h(null)}})})]})}},71118:(e,t,a)=>{"use strict";a.d(t,{A:()=>s});var r=a(37876);function s(e){let t=e.size||40;return e.profile_image?(0,r.jsx)("div",{children:(0,r.jsx)("img",{className:`rounded-full object-cover ${e.className} ${e.hover?"transition-transform duration-300 ease-in-out transform hover:scale-110 hover:shadow-lg":""}`,src:e.profile_image,alt:"Profile",style:e.className?void 0:{width:t,height:t,minWidth:t,minHeight:t}})}):e.name?(0,r.jsx)("div",{className:`ring-2 ring-white/20 bg-gray-500/50 rounded-full flex items-center justify-center text-white font-semibold ${e.className||""} ${e.hover?"transition-transform duration-300 ease-in-out transform hover:scale-110 hover:shadow-lg":""}`,style:e.className?void 0:{width:t,height:t,minWidth:t,minHeight:t},children:e.name.split(" ").map(e=>e.charAt(0)).slice(0,2).join("").toUpperCase()}):(0,r.jsx)(r.Fragment,{})}},87790:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>nr});var r,s,l,i,n,o=a(37876),c=a(54587),d=a.n(c),u=a(48230),p=a.n(u),m=a(84412),h=a(14232);a(59352);
7var x=a(80856),f=a(77328),g=a.n(f),y=a(97685),b=a(11324),j=a.n(b),w=a(9617),v=a(85428),N=a(51877),S=a(22629),k=a(84091),_=a(23323);let C="line-layer",L="point-layer",D="polygon-layer",A=(e="map")=>{let t=JSON.stringify({source:e,value:[...Array(10)].map(()=>Math.random().toString(36)[2]).join("")});sessionStorage.setItem("measurements",t)},M=async(e,t,a="map",r)=>{let s=async()=>{let a=(await (0,_.x)("/measurement/get",{params:{project_uuid:t}})).filter(e=>"model"!==e.category).map(e=>({type:"Feature",geometry:e.geojson.geometry,properties:e.geojson.properties,id:e.uuid,title:e.geojson.properties.name}));if(e.current.getSource("measurements"))try{e.current.removeSource("measurements")}catch{}e.current.addSource("measurements",{type:"geojson",data:{type:"FeatureCollection",features:a},promoteId:"uuid"}),I(e,L,r),I(e,C,r),I(e,D,r),(0,k.y)(e.current)};if(e.current.getSource("measurements")){e.current.removeLayer("line-layer"),e.current.removeLayer("line-layer-labels"),e.current.removeLayer("point-layer"),e.current.removeLayer("polygon-layer"),e.current.removeLayer("polygon-layer-labels");try{e.current.removeSource("measurements")}catch{}await s()}else await s();let l=e.current;return l.__measurementStyleLoadHandler&&e.current.off("style.load",l.__measurementStyleLoadHandler),l.__measurementStyleLoadHandler=async()=>{await s()},e.current.on("style.load",l.__measurementStyleLoadHandler),l.__measurementStyleDataHandler&&e.current.off("styledata",l.__measurementStyleDataHandler),l.__measurementStyleDataHandler=()=>{(0,k.y)(e.current)},e.current.on("styledata",l.__measurementStyleDataHandler),A(a),e},E=(e,t,a="map")=>{let r=e.current.getSource("measurements"),s=r?._data,l=t.properties?.uuid??t.id,i={...t,id:l,properties:{...t.properties,uuid:l}},n=s.features.filter(e=>(e.properties?.uuid??e.id)!==l);n.push(i),r.setData({...s,features:n}),(0,k.y)(e.current),A(a)},T=(e,t,a="map")=>{let r=e.current.getSource("measurements"),s=r?._data,l=t?.properties?.uuid??t?.id,i=s.features.filter(e=>(e.properties?.uuid??e.id)!==l);r.setData({...s,features:i}),(0,k.y)(e.current),A(a)},I=(e,t,a)=>{let r=null===(0,S.YN)("measurements-layer",(0,v.Ky)().project_uuid),s=!0===(0,S.YN)("measurements-layer",(0,v.Ky)().project_uuid)?"visible":"none",l=!0===(0,S.YN)("measurements-label-layer",(0,v.Ky)().project_uuid)?"visible":"none",i=r?"visible":s,n=r?"visible":l;if(t===L)e.current.getLayer(t)||e.current.addLayer({id:t,type:"circle",source:"measurements",layout:{visibility:i},paint:{"circle-color":["get","color"],"circle-radius":["case",["boolean",["feature-state","hover"],!1],9,6],"circle-stroke-color":"transparent","circle-stroke-width":10,"circle-opacity":["get","opacity"]},filter:["==","$type","Point"]});else if(t===C){e.current.getLayer(t)||e.current.addLayer({id:t,type:"line",source:"measurements",layout:{visibility:i},paint:{"line-color":["case",["boolean",["feature-state","selected"],!1],"blue",["coalesce",["get","color"],"black"]],"line-width":["case",["boolean",["feature-state","selected"],!1],6,["boolean",["feature-state","hover"],!1],6,3]},filter:["==","$type","LineString"]});let a=t+"-labels";e.current.getLayer(a)||e.current.addLayer({id:a,type:"symbol",source:"measurements",layout:{"text-field":["get","name"],"text-size":12,"text-offset":[0,1],"text-anchor":"center","text-justify":"center","symbol-placement":"line-center",visibility:n},paint:{"text-halo-color":"#FFFFFF","text-halo-width":2,"text-halo-blur":.5},filter:["==","$type","LineString"]})}else if(t===D){e.current.getLayer(t)||e.current.addLayer({id:t,type:"fill",source:"measurements",layout:{visibility:i},paint:{"fill-color":["coalesce",["get","color"],"black"],"fill-opacity":["case",["boolean",["feature-state","selected"],!1],.8,.2],"fill-outline-color":"#000"},filter:["==","$type","Polygon"]});let a=t+"-labels";e.current.getLayer(a)||e.current.addLayer({id:a,type:"symbol",source:"measurements",layout:{"text-field":["get","name"],"text-size":12,"text-anchor":"center","text-justify":"center","symbol-placement":"point",visibility:n},paint:{"text-halo-color":"#FFFFFF","text-halo-width":2,"text-halo-blur":.5},filter:["==","$type","Polygon"]})}a&&(0,N.wk)(e,a);let o=null;e.current.on("mousemove",t,t=>{t.features.length>0&&null!=t.features[0].id&&(o=t.features[0].id)&&e.current.setFeatureState({source:"measurements",id:o},{hover:!0})}),e.current.on("mouseleave",t,()=>{o&&(e.current.setFeatureState({source:"measurements",id:o},{hover:!1}),o=null)})},P=async(e,t,a)=>(0,_.x)("/map/search-coords-to-lrs",{method:"GET",params:{lat:t,lon:a,project_id:e}}),F=new Map,O=async(e,t,a)=>{let r=JSON.stringify([e,t.toString(),a.toString()]);return F.has(r)||(F.size>=10&&F.clear(),F.set(r,P(e,t,a))),F.get(r)},R=async(e,t,a)=>{try{return await (0,_.x)("/map/search-lrs-to-coords",{method:"GET",params:{route:e,chainage:t,project_id:a?.project_uuid}})}catch(e){return console.error(e),null}};var $=a(8135),z=a(55351),U=a(82116),W=a(39149);function B(e){let t=(0,h.useRef)(null),a=(0,h.useRef)(null),r=()=>{e.closeModal(),a.current.click()};return(0,h.useEffect)(()=>{e.isOpen?(t.current?.showModal(),(0,v.Fr)()&&(document.documentElement.style.display="none",setTimeout(()=>{document.documentElement.style.display="block"},10))):t.current?.close()},[e.isOpen]),(0,o.jsx)(o.Fragment,{children:e.isOpen&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("input",{type:"checkbox",id:"imagepopup-modal",className:"modal-toggle"}),(0,o.jsxs)("dialog",{ref:t,className:"modal text-black z-46 imagepopup-modal",children:[(0,o.jsxs)("div",{className:"modal-box",children:[(0,o.jsxs)("div",{className:"flex flex-row justify-end items-center text-lg gap-2 mb-2",children:[(0,o.jsx)("button",{onClick:()=>(0,v.zc)(e.url),className:"btn btn-sm text-lg btn-circle bg-white/60 border-white/60!",children:(0,o.jsx)(W.U01,{})}),(0,o.jsx)("label",{onClick:r,htmlFor:"imagepopup-modal",className:"btn btn-sm text-lg btn-circle bg-white/60 border-white/60",children:"✕"})]}),e.url.length>1&&(0,o.jsx)("img",{src:e.url,className:"max-h-[80vh]",alt:"Image"})]}),(0,o.jsx)("label",{onClick:r,ref:a,className:"modal-backdrop",htmlFor:"imagepopup-modal",children:"Close"})]})]})})}var V=a(6328),G=a(10841),J=a.n(G),q=a(12227),Y=a(11763),H=a(61519),Z=a(14568),X=a.n(Z),K=a(89675);let Q=({coordinates:e,properties:t,type:a,onDelete:r,project:s,additionalPopupShowing:l,userMap:i,selectedNote:n=null,thread:c=null,closePanel:d})=>{var u;let p,{data:m}=K.Ay$.array(K.Ay$.string()).safeParse((0,v.zx)(t.files)),x=(p=new Set((u=m??[]).map(e=>(function(e){let t=e.lastIndexOf(".");if(-1===t)return e;let a=e.substring(0,t),r=e.substring(t);return`${a}_thumbnail${r}`})(e))),u.filter(e=>!p.has(e)).length),[f,g]=(0,h.useState)(),[y,b]=(0,h.useState)(!1),[j,w]=(0,h.useState)(!1),[,N]=(0,h.useState)(),[S,k]=(0,h.useState)(""),_=q.A.sanitize(t.title),C=(0,Y.W7)(t.description,i),L=async()=>
7{await r(t.id),d()};(0,v.xR)(),(0,h.useEffect)(()=>{l(y||j)},[y,j]);let D="true"===t.verified||!0===t.verified,A="true"===t.reviewed||!0===t.reviewed;return(0,h.useEffect)(()=>{s.lrs_included&&(async()=>{try{let t=await O(s.project_uuid,e[1],e[0]);g(t?`${t.route} ${t.chainage.toFixed(3)}`:null)}catch(e){console.log(e)}})()},[s]),(0,h.useEffect)(()=>{N({id:t.id,create_date:t.create_date,properties:t})},[]),(0,h.useEffect)(()=>{let e=s.container_name+"/"+a;t.base&&(e+="/"+t.base),e+="/"+t.img,(async()=>{k(await (0,H.bB)(e))})()},[t]),(0,o.jsx)(o.Fragment,{children:(0,o.jsxs)("div",{style:{padding:"5px",backgroundColor:"white",color:"black",maxWidth:"400px"},children:[(0,o.jsx)(V.A,{isOpen:j,onDelete:L,closeModal:()=>w(!1)}),(0,o.jsxs)("div",{style:"alerts"==a?{borderLeft:`7px solid ${D?"red":"orange"}`,paddingLeft:"10px"}:{},children:[(0,o.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:10},children:["alerts"==a?(0,o.jsxs)("h3",{style:{marginBottom:"0px"},children:[(0,o.jsx)("b",{children:"Issuer"}),": ",t.issuer]}):(0,o.jsxs)("h3",{style:{marginBottom:"0px"},children:[(0,o.jsx)("b",{children:"User"}),": ",t.user]}),(0,o.jsxs)("div",{className:"flex align-center gap-1",children:[x>0&&(0,o.jsxs)("div",{className:"flex items-center gap-0.5 text-xs text-gray-400",title:`${x} ${1===x?"attachment":"attachments"}`,children:[(0,o.jsx)(U.Y4x,{size:13,className:"text-gray-400"}),(0,o.jsx)("span",{children:x})]}),(0,o.jsx)("button",{className:"btn btn-xs",onClick:()=>{n?.({...c.properties,lon:c.geometry.coordinates[0],lat:c.geometry.coordinates[1]})},children:"Thread"})]})]}),(0,o.jsxs)("h3",{style:{marginBottom:"0px"},children:[(0,o.jsx)("b",{children:"Title"}),": ",_.slice(0,50)+(_.length>50?"...":"")]}),"alerts"==a?(0,o.jsx)(o.Fragment,{children:(0,o.jsxs)("h3",{style:{marginBottom:"0px"},children:[(0,o.jsx)("b",{children:"Category"}),": ",t.category]})}):(0,o.jsxs)(o.Fragment,{children:[t.condition&&(0,o.jsxs)("h3",{style:{marginBottom:"0px"},children:[(0,o.jsx)("b",{children:"Condition"}),": ",t.condition.charAt(0).toUpperCase()+t.condition.slice(1)]}),(0,o.jsxs)("h3",{style:{marginBottom:"0px"},children:[(0,o.jsx)("b",{children:"Source"}),": ",t.source]})]}),(0,o.jsxs)("h3",{style:{marginBottom:"0px"},children:[(0,o.jsx)("b",{children:"Date"}),": ",J()(t.create_date).format("M/D/YYYY h:mm A")]}),"alerts"==a&&t.severity>=1&&t.severity<=5&&(0,o.jsxs)("h3",{style:{marginBottom:"0px"},children:[(0,o.jsx)("b",{children:"Severity"}),": ",(0,o.jsx)("span",{style:{color:(0,v.s8)(t.severity)},children:(0,v.Wl)(t.severity)})]}),"alerts"==a&&(0,o.jsxs)("h3",{style:{marginBottom:"0px"},children:[(0,o.jsx)("b",{children:"Reviewed"}),": ",(0,o.jsx)("span",{style:{color:A?"#28a745":"#808080"},children:A?"Reviewed":"Not Reviewed"})]}),"alerts"==a&&(0,o.jsxs)("h3",{style:{marginBottom:"0px"},children:[(0,o.jsx)("b",{children:"Verify"}),": ",t.verify_status??"Unset"]}),C&&(0,o.jsxs)("p",{style:{marginTop:"5px"},children:[(0,o.jsx)("b",{children:"Description"}),":",(0,o.jsx)("span",{dangerouslySetInnerHTML:{__html:C.slice(0,50)+(C.length>50?"...":"")}})]}),"model"!=t.category&&t.img?(0,o.jsxs)("div",{children:["image"==(0,v.ti)(t.img)&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(B,{isOpen:y,closeModal:()=>b(!1),url:`${S}`}),(0,o.jsx)("img",{className:"cursor-pointer",onClick:()=>b(!0),src:`${S}`,alt:"Image",loading:"lazy",style:{width:"100%",maxHeight:"150px",objectFit:"contain"}})]}),"video"===(0,v.ti)(t.img)&&(0,o.jsx)("div",{className:"w-[250px]",children:(0,o.jsx)(X(),{controls:!0,url:S,width:"100%",height:"100%"})})]}):"",(0,o.jsx)("div",{className:"flex align-center gap-2 justify-between border-gray-100 border-t mt-1",children:(0,o.jsxs)("div",{children:[(0,o.jsx)("div",{className:"flex flex-auto gap-1 justify-between w-full text-tt-blue/80 text-[11px] m-1 ml-0",children:e&&void 0!==e[0]&&void 0!==e[1]&&"number"==typeof e[0]&&"number"==typeof e[1]&&(0,o.jsxs)("div",{className:"cursor-pointer flex gap-1 items-center",onClick:()=>(0,v.lW)(`${e[1].toFixed(6)}, ${e[0].toFixed(6)}`),children:[(0,o.jsx)($.cJR,{})," ",e[1].toFixed(5),", ",e[0].toFixed(5)]})}),s?.lrs_included&&f&&(0,o.jsx)(o.Fragment,{children:(0,o.jsx)("div",{className:"flex grow gap-2 justify-between w-full text-tt-blue/80 text-[11px] border-t pt-1 border-gray-100 min-w-[12em] h-6",children:(0,o.jsxs)("div",{className:"cursor-pointer gap-1 flex items-center",onClick:()=>
7(0,v.lW)(f),children:[(0,o.jsx)(z.pk7,{})," ",f]})})}),s?.lrs_included&&!f&&(0,o.jsx)(o.Fragment,{children:(0,o.jsx)("div",{className:"flex grow gap-2 justify-between w-full text-tt-blue/80 text-[11px] border-t border-gray-100 min-w-[12em] h-6",children:(0,o.jsx)("span",{className:"loading loading-spinner loading-xs flex items-center justify-center "})})})]})})]})]})})};var ee=a(25236),et=a(72080),ea=a(98287),er=a(95674),es=a(78944);let el=null,ei=(e,t,a)=>{let r=!0,s=new(j()).Popup({closeButton:!1,offset:{top:[0,15],"top-left":[0,15],"top-right":[0,15],bottom:[0,-15],"bottom-left":[0,-15],"bottom-right":[0,-15],left:[15,0],right:[-15,0]},maxWidth:"none"}),l=document.createElement("div"),i=(0,es.createRoot)(l),n=null,o=()=>{n&&clearTimeout(n)},c=()=>{u()},d=(e=!1)=>{(e||r)&&s.remove()},u=()=>{n&&clearTimeout(n),n=setTimeout(()=>{let e=s.isOpen()?s.getElement().querySelector(".mapboxgl-popup-tip"):null;l.matches(":hover")||e?.matches(":hover")||d()},150)};return{showPopup:n=>{el&&el!==s&&el.remove(),el=s,d(!0),r=!0;let u=n.features[0].properties,p=t(n);i.render(a({e:n,properties:u,coordinates:p,additionalPopupShowing:e=>{r=!e}})),s.setLngLat(p),s.setDOMContent(l),s.addTo(e.current),s.once("close",()=>{el===s&&(el=null)});let m=s.getElement();m.style.pointerEvents="none",l.style.pointerEvents="auto";let h=m.querySelector(".mapboxgl-popup-tip");h&&(h.style.pointerEvents="auto",h.removeEventListener("mouseenter",o),h.removeEventListener("mouseleave",c),h.addEventListener("mouseenter",o),h.addEventListener("mouseleave",c)),l.removeEventListener("mouseenter",o),l.removeEventListener("mouseleave",c),l.addEventListener("mouseenter",o),l.addEventListener("mouseleave",c)},clearHoverTimeout:()=>{n&&clearTimeout(n)},handleMouseLeave:()=>{e.current.getCanvas().style.cursor="",u()}}},en=(e,t,a,r)=>{let{showPopup:s,handleMouseLeave:l,setSelectedNote:i,isDragging:n,clearHoverTimeout:o}=a,{markerType:c,getCoordinates:d}=r,u=null;e.current.on("mouseenter",t,t=>{let a=t.features?.[0]?.properties?.id;void 0!==a&&(u=String(a),o(),e.current.getCanvas().style.cursor="pointer",s(t))}),e.current.on("mousemove",t,t=>{let a=t.features?.[0]?.properties?.id;if(void 0===a)return;let r=String(a);u!==r&&(u=r,o(),e.current.getCanvas().style.cursor="pointer",s(t))}),e.current.on("mouseleave",t,()=>{u=null,l()}),e.current.on("click",t,e=>{if(void 0!==e.features[0].properties.id){s(e);let t=d(e);i?.({...e.features[0].properties,lon:t[0],lat:t[1],type:c})}}),e.current.on("touchend",t,e=>{n||void 0===e.features[0].properties.id||s(e)})};var eo=a(67989);let ec=Symbol("notes-style-handler-bound"),ed=async(e,t,a,r,s,l,i,n,c)=>{if(!a)return e;let d=!1,u=async()=>{if(!(0,eo.fu)(e,"notes",()=>{u()}))return;e.current.off("mouseenter","ainote-layer"),e.current.off("click","ainote-layer"),e.current.off("touchend","ainote-layer"),e.current.off("dragstart"),e.current.off("dragend"),e.current.off("click","3dnote-layer"),e.current.off("mouseenter","3dnote-layer"),e.current.off("mouseleave","3dnote-layer"),e.current.off("touchend","3dnote-layer"),e.current.off("mouseenter","note-layer"),e.current.off("mouseenter","note-layer"),e.current.off("click","note-layer"),e.current.off("touchend","note-layer"),e.current.off("mouseleave","note-layer"),(0,er.Ym)(e);let s=await (0,ee.wZ)(n.current.notes,e,!1,!0),p=(0,ea.bY)(s),m=(0,ea.FQ)(s),h=(0,ea.gr)(s);(0,er.SL)(e,x.Zg.NORMAL,p),(0,er.SL)(e,x.Zg.THREE_D,m),(0,er.SL)(e,x.Zg.AI,h),(0,er.b1)(e,x.Zg.NORMAL),(0,er.b1)(e,x.Zg.THREE_D),(0,er.b1)(e,x.Zg.AI);let f=async a=>{await (0,ee.B9)([a])?((0,v.By)(),y.Ay.success("Note deleted successfully"),(0,ee.$W)(e,[Number(a)]),t.setUpdate(e=>e+1),i==a&&l()):y.Ay.error("Note delete failed")},{showPopup:g,clearHoverTimeout:b,handleMouseLeave:j}=ei(e,e=>e.features[0].geometry.coordinates.slice(),({e,properties:t,coordinates:s,additionalPopupShowing:i})=>(0,o.jsx)(et.LD,{children:(0,o.jsx)(Q,{additionalPopupShowing:i,coordinates:s,properties:t,type:"notes",onDelete:f,project:a,selectedNote:c,thread:e.features?e.features[0]:null,userMap:r,closePanel:l})}));en(e,"note-layer",{showPopup:g,handleMouseLeave:j,setSelectedNote:c,isDragging:d,clearHoverTimeout:b},{markerType:x.TG.note,getCoordinates:e=>e.features[0].geometry.coordinates.slice()}),en(e,"ainote-layer",{showPopup:g,handleMouseLeave:j,isDragging:d,clearHoverTimeout:b},{markerType:x.TG.note,getCoordinates:e=>e.features[0].geometry.coordinates.slice()}),e.current.on("dragstart",()=>{d=!0}),e.current.on("dragend",()=>{d=!1}),en(e,"3dnote-layer",{showPopup:g,handleMouseLeave:j,setSelectedNote:c,isDragging:d,clearHoverTimeout:b},{markerType:x.TG.note,getCoordinates:e=>e.features[0].geometry.coordinates.slice()})};return await u(),e.current[ec]||(e.current.on("style.load",async()=>{let t=(0,eo.QH)(e,"notes");t?t():await u()}),e.current[ec]=!0),localStorage.setItem("notes",[...Array(10)].map(()=>Math.random().toString(36)[2]).join("")),e};var eu=a(72248),ep=a(51576),em=a(24977),eh=a(9728),ex=a(21034),ef=a(99637),eg=a(91431),ey=a(53669),eb=a(63797),ej=a(89977),ew=a(79926),ev=a(77784),eN=a(57271);function eS({showRightClickMenu:e,setShowRightClickMenu:t,rightClickMenuPoint:a,mapCoord:r,setShowDeleteConfirmation:s,setShowIfcModal:l,searchForAsset:i,showLidar:n}){let c=(0,ex.u)(),d=(0,ef.N)(),u=(0,eg.ZM)(),p=(0,ey.F)(),m=(0,eb.g)(),h=(0,ej.H)(),f=(0,ew.u)(),g=(0,ev.O)(),b=(0,eN.D)(),j=e.data?.properties?.user_id===c?.user?.id||g.project&&(0,v._A)(c?.user,g.project.project_uuid),w=e=>{navigator.clipboard.writeText(e),y.oR.success("Coordinates successfully copied to clipboard"),t({show:!1,action:null,data:null})};return e.show?(0,o.jsx)("div",{className:`
8                absolute z-29 font-bold justify-start rounded-lg box-border w-auto bg-white p-1/2 
9                shadow-[0px_1px_8px_0px_rgba(0,0,0,0.1)] right-click-menu
10            `,style:{top:a.y+5,left:a.x+5},children:(0,o.jsxs)("ul",{className:"justify-start list-none box-border p-1 context-menu",children:[Number.isFinite(r.lat)&&Number.isFinite(r.lon)&&(0,o.jsxs)("li",{onClick:()=>w(r.lat.toFixed(5)+","+r.lon.toFixed(5)),style:{justifyContent:"left"},children:[r.lat.toFixed(5),", ",r.lon.toFixed(5)]}),f.currentLRS&&(0,o.jsx)("li",{onClick:()=>w(f.currentLRS),style:{justifyContent:"left"},children:f.currentLRS}),b.availableLidars.length>0&&(0,o.jsxs)("li",{className:"justify-start",onClick:()=>{n(b.availableLidars),t({show:!1,action:null,data:null})},children:[(0,o.jsx)(W.SqY,{size:18}),"View Pointclouds"]}),Number.isFinite(r.lat)&&Number.isFinite(r.lon)&&(0,o.jsxs)("li",{onClick:async()=>{t({show:!1,action:null,data:null}),i(r.lon,r.lat,g.project)},style:{justifyContent:"left"},children:[(0,o.jsx)($.iyI,{size:18}),"Search here"]}),j&&(0,o.jsxs)(o.Fragment,{children:["note"===e.action&&(0,o.jsxs)("li",{onClick:()=>{s(!0)},style:{justifyContent:"left"},className:"text-red-500",children:[(0,o.jsx)($.id1,{size:18}),"Delete note"]}),"alert"===e.action&&(0,o.jsxs)("li",{onClick:()=>{s(!0)},style:{justifyContent:"left"},className:"text-red-500",children:[(0,o.jsx)($.id1,{size:18}),"Delete alert"]}),"measurement"===e.action&&(0,o.jsx)(o.Fragment,{children:(0,o.jsxs)("li",{onClick:()=>{s(!0)},style:{justifyContent:"left"},className:"text-red-500",children:[(0,o.jsx)($.id1,{size:18}),"Delete measurement"]})})]}),(0,o.jsxs)("li",{onClick:()=>{d.setShowAddNoteWindow({show:!0,noteMode:x.md.DEFAULT}),t({show:!1,action:null,data:null})},style:{justifyContent:"left"},children:[(0,o.jsx)(W.R7b,{size:18}),"Add note"]}),(0,o.jsxs)("li",{onClick:()=>{d.setShowAddNoteWindow({show:!0,noteMode:x.md.VIDEO_TO_3D}),t({show:!1,action:null,data:null})},style:{justifyContent:"left"},children:[(0,o.jsx)(eu.GLH,{size:18}),"3D Note"]}),!(0,v.KV)()&&(0,o.jsxs)("li",{onClick:()=>{l(!0),t({show:!1,action:null,data:null})},style:{justifyContent:"left"},children:[(0,o.jsx)(ep.cSY,{size:18}),"IFC Layer"]}),(0,o.jsxs)("li",{onClick:()=>{u.setShowIssueAlertWindow(!0),t({show:!1,action:null,data:null})},style:{justifyContent:"left"},children:[(0,o.jsx)(W.PAG,{size:18}),"Issue alert"]}),(0,o.jsxs)("li",{onClick:()=>{m.setDrawingModeCaller(x.xY.DISTANCE_TOOL),p.setElevationMeasurementEnabled(!1),t({show:!1,action:null,data:null}),h.setBottomMenuOpen({open:!1,id:0,event:null})},style:{justifyContent:"left"},children:[(0,o.jsx)(em.fod,{size:18}),"Measure distance"]}),(0,o.jsxs)("li",{onClick:()=>{m.setDrawingModeCaller(x.xY.AREA_TOOL),p.setElevationMeasurementEnabled(!1),t({show:!1,action:null,data:null}),h.setBottomMenuOpen({open:!1,id:0,event:null})},style:{justifyContent:"left"},children:[(0,o.jsx)(ep.voV,{size:18}),"Measure area"]}),(0,o.jsxs)("li",{onClick:()=>{p.setElevationMeasurementEnabled(!p.elevationMeasurementEnabled),m.setDrawingModeCaller(null),t({show:!1,action:null,data:null}),h.setBottomMenuOpen({open:!1,id:0,event:null})},style:{justifyContent:"left"},children:[(0,o.jsx)(eh.YQY,{size:18}),"Measure elevation"]}),(0,o.jsxs)("li",{onClick:()=>{let e="https://www.google.com/maps?saddr=My+Location&daddr="+r.lat+","+r.lon;window.open(e,"_blank"),y.oR.success("Opening Google Maps for navigation"),t({show:!1,action:null,data:null})},style:{justifyContent:"left"},children:[(0,o.jsx)(z.amt,{size:18}),"Navigate to"]})]})}):null}var ek=a(68346),e_=a(31985);let eC="/_next/static/media/note-marker.2dcb6d71.png";var eL=a(50416),eD=a(97415),eA=a(36531),eM=a(33534),eE=a(18550),eT=a(34947);a(68335);let eI=({mention:e,isFocused:t,selectMention:a,searchValue:r,...s})=>(0,o.jsxs)("div",{...s,onClick:()=>a?.(e),className:`flex items-center px-2 py-2 rounded cursor-pointer transition-colors ${t?"bg-blue-100":""}`,children:[e.avatar?(0,o.jsx)("img",{src:e.avatar,alt:e.name,className:"w-8 h-8 rounded-full object-cover mr-3"}):(0,o.jsx)("div",{className:"w-8 h-8 rounded-full bg-gray-300 text-white text-sm flex items-center justify-center font-bold mr-3","aria-label":e.name,children:e.name.split(" ").map(e=>e.charAt(0).toUpperCase()).slice(0,2).join("")}),(0,o.jsx)("span",{className:"text-sm font-medium text-gray-600",children:e.name})]});function eP(e){let t=(0,h.useRef)((0,eT.Ay)({mentionPrefix:"@",supportWhitespace:!0,theme:{mention:"mention",mentionSuggestions:"max-h-80 w-52 overflow-y-auto bg-white rounded-md shadow-md z-50"}})).current,{MentionSuggestions:a}=t,r=(0,h.useRef)(null),[s,l]=(0,h.useState)(!1),[i,n]=(0,h.useState)(e.projectUsers),c=!e.editorState.getCurrentContent().hasText(),d=(0,h.useCallback)(e=>{l(e)},[]);return(0,o.jsxs)("div",{className:"w-full min-h-[125px] max-h-[125px] overflow-y-auto py-2",onClick:()=>{r.current.focus()},children:[c&&(0,o.jsx)("div",{className:"text-gray-400 pointer-events-none max-w-full",children:e.placeholder||(0,o.jsxs)(o.Fragment,{children:["Post your reply or @ to ",(0,o.jsx)("br",{}),"mention someone"]})}),(0,o.jsx)(eE.Ay,{editorKey:"editor",editorState:e.editorState,onChange:t=>e.setEditorState(t),plugins:[t],ref:r,readOnly:e.disabled,blockStyleFn:()=>"[word-break:break-word]"}),(0,o.jsx)(a,{open:s,onOpenChange:d,suggestions:i,onSearchChange:({value:t})=>{t.trim()?n((0,eT.$Z)(t,e.projectUsers)):n(e.projectUsers)},entryComponent:eI})]})}
10var eF=a(97853),eO=a(27524),eR=a.n(eO),e$=a(29374),ez=a(22939);let eU=({showEmojiPicker:e,onEmojiClick:t,closeModal:a,nullIcon:r,slideFromBottom:s=!1})=>{let l=(0,h.useRef)(null);(0,h.useEffect)(()=>{let t=e=>{l.current&&!l.current.contains(e.target)&&a()};return e&&document.addEventListener("mousedown",t),()=>{document.removeEventListener("mousedown",t)}},[e,a]);let i=(0,o.jsx)(ez.Ay,{open:e,className:`!h-[${s?"45vh":"50px"}] tablet:!h-[450px] tablet:!w-[350px]  !w-[${s?"100%":"350px"}]`,onEmojiClick:t,emojiStyle:ez.Ai.NATIVE,skinTonesDisabled:!0,previewConfig:{defaultCaption:"Select Note Icon",defaultEmoji:"1"},categories:[{category:ez.LJ.CUSTOM,name:"Default Icons"},{category:ez.LJ.TRAVEL_PLACES,name:"Travel & Places"},{category:ez.LJ.OBJECTS,name:"Objects"},{category:ez.LJ.SYMBOLS,name:"Symbols"},{category:ez.LJ.FLAGS,name:"Flags"}],customEmojis:r?[{id:"0",names:["No Icon"],imgUrl:"/images/symbols/noIcon.png"},...m.ff]:m.ff,hiddenEmojis:["26b0-fe0f","26b1-fe0f","1faa6"]});return s?(0,o.jsxs)(o.Fragment,{children:[e&&(0,o.jsx)("div",{className:"fixed inset-0 bg-black/20 z-50",onClick:a}),(0,o.jsx)("div",{className:`fixed bottom-0 left-0 w-full z-5000 transform transition-transform duration-300 ${e?"translate-y-0":"translate-y-full"}`,ref:l,"data-testid":"emoji-modal-slider",children:(0,o.jsx)("div",{className:"emoji-modal rounded-t-2xl bg-white max-h-[80vh] w-full overflow-y-auto shadow-lg",children:i})})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("input",{id:"emoji-modal",type:"checkbox",className:"modal-toggle",checked:e,readOnly:!0}),(0,o.jsx)("div",{className:"modal",children:(0,o.jsx)("div",{className:"emoji-modal",ref:l,children:e&&i})})]})},eW=({onEmojiClick:e,onCloseModal:t,nullIcon:a=!1,slideFromBottom:r=!1})=>{let[s,l]=(0,h.useState)(!1),i=()=>{t&&t(),l(!1)};return{EmojiPickerComponent:(0,o.jsx)(eU,{showEmojiPicker:s,onEmojiClick:(t,a)=>{e&&e(t,a),i()},closeModal:i,nullIcon:a,slideFromBottom:r}),showEmojiPicker:s,setShowEmojiPicker:l}};var eB=a(95471),eV=a(69904),eG=a(55283);let eJ=function({groupName:e,tabs:t,selectedValue:a,onSelect:r,transparentBackground:s=!1}){let l,i=-1===(l=t.findIndex(e=>e.value===a))?"translateX(0%)":`translateX(${100*l}%)`,n=t.length>0?`${100/t.length}%`:"0%";return(0,o.jsx)("div",{className:"flex w-full","data-testid":"sidepanel-top-tabs",children:(0,o.jsxs)("div",{className:"relative w-full h-full overflow-hidden",children:[(0,o.jsx)("div",{className:"absolute top-0 left-0 z-0 h-full rounded-md bg-tt-blue transition-transform duration-300 ease-out shadow-md",style:{transform:i,width:n}}),(0,o.jsx)("div",{className:`tabs tabs-box p-0 !shadow-none ${s?"bg-transparent":""}`,children:t.map(t=>(0,o.jsxs)("label",{"data-testid":"animated-tab",className:`flex justify-center gap-2 flex-1 tab px-2 !shadow-none focus:!outline-none cursor-pointer !text-gray-500 !hover:text-gray-500 ${t.value===a?"!text-white !hover:text-white":""}`,children:[(0,o.jsx)("input",{type:"radio",name:e,className:"hidden",checked:t.value===a,onChange:()=>r(t.value)}),t.icon&&(0,o.jsx)(t.icon,{className:"text-lg"}),(0,o.jsx)("span",{children:t.label})]},t.label))})]})})};var eq=a(47054);function eY(e){let{map:t}=(0,eG.JY)(),a=(0,ef.N)(),r=(0,eV.H)(),s=(0,ew.u)(),{setUpdate:l}=(0,et.xS)(),i=(0,ex.u)(),n=(0,ev.O)(),[c,u]=(0,h.useState)(x.md.DEFAULT),[p,f]=(0,h.useState)(!1),[g,b]=(0,h.useState)(""),[j,w]=(0,h.useState)(r.date?r.date:new Date),[N,S]=(0,h.useState)(null),[k,C]=(0,h.useState)([]),[L,D]=(0,h.useState)(),[A,M]=(0,h.useState)(!1),[E,T]=(0,h.useState)(!1),[I,P]=(0,h.useState)(""),[F,O]=(0,h.useState)(0),[R,$]=(0,h.useState)(0),[z,U]=(0,h.useState)([]),[V,G]=(0,h.useState)(0),[J,q]=(0,h.useState)(null),[H,Z]=(0,h.useState)({display:!1,url:""}),[X,K]=(0,h.useState)(null),[Q,ee]=(0,h.useState)(()=>eF.EditorState.createEmpty()),[ea,er]=(0,h.useState)(!1),[es,el]=(0,h.useState)(null),[ei,en]=(0,h.useState)([]),eo=(0,e$.p)(),{EmojiPickerComponent:ec,setShowEmojiPicker:ed}=eW({onEmojiClick:function(e){eh(e.imageUrl);let t=e.emoji,a=m.ff.find(e=>e.id==t);a?eb(a.id):eb(x.AT.custom)},slideFromBottom:!0});(0,h.useEffect)(()=>{e.userMap&&en(Object.values(e.userMap).map(e=>({id:e.id,name:e.first_name.trim()+" "+e.last_name.trim(),avatar:e.profile_image||null,email:e.email})))},[e.userMap]);let ep=(0,eD.l)(),[em,eh]=(0,h.useState)(eC),[eg,ey]=(0,h.useState)(x.AT.default);function eb(e){e==eg?e==x.AT.default?ey(x.AT.none):e!==x.AT.custom&&(ey(x.AT.default),eh(eC)):ey(e)}let ej=async t=>{if(t.preventDefault(),G(0),f(!0),T(!1),L)try{let t=new FormData;t.append("title",g);let r=(0,v.BG)(Q);r.modifiedText?.toString().trim()&&t.append("description",r.modifiedText?.toString().trim()),r.plainText?.trim()&&t.append("description_with_names",r.plainText.trim()),t.append("mentions",JSON.stringify(r.mentions));let s=await (0,_.x)(m.fn+"/note/update?id="+L.id,{method:"PATCH",form:t});l(e=>e+1),e.onNoteUpdated(s,n.project),a.setShowAddNoteWindow({show:!1,noteMode:x.md.DEFAULT}),f(!1),y.Ay.success("Note updated successfully")}catch(e){console.log(e),f(!1),y.Ay.error("Note update failed")}else try{let t,r=JSON.parse(localStorage.getItem("project")||"{}"),s={},l=new FormData;l.append("project_id",r?.project_uuid),l.append("container_name",r.container_name??""),l.append("title",g);let n=(0,v.BG)(Q);n.modifiedText?.toString().trim()&&l.append("description",n.modifiedText?.toString().trim()),n.plainText?.trim()&&l.append("description_with_names",n.plainText.trim()),l.append("mentions",JSON.stringify(n.mentions)),l.append("create_date",new Date(j).toISOString()),l.append("type","default"),X&&l.append("integration_file",JSON.stringify(X)),E&&I&&l.a
10ppend("note_lrs",JSON.stringify({route:I,from:F,to:R}));let o=e.lat.toString(),c=e.lon.toString();if(A){let e=await (0,v.vM)();o=e.latitude.toString(),c=e.longitude.toString()}l.append("lat",o),l.append("lon",c);let d=await (0,v.S1)(e.lat,e.lon)+60;if(l.append("elevation",d),(z.length>0||eO.file&&eq.zU.includes((0,v.ti)(eO.file.name)))&&(l.set("type","model"),s.status="complete",s.manualUpload="true",z.length>0))for(let e of(l.set("type","scan"),z)){let t=await (0,v.Z)(e.base64,e.fileName,e.fileType);l.append("file_upload",t)}for(let e of("-1"==eg?(s.icon_type="custom",s.icon=em):(s.icon_type="default",s.icon=eg),s.source="Mapbox",N||[]))l.append("file_upload",e);J&&(J.objects.length>0&&l.append("detected_objects",JSON.stringify(J.objects)),J.ocr_text.length>0&&l.append("detected_text",JSON.stringify(J.ocr_text))),"{}"!=JSON.stringify(s)&&l.append("data",JSON.stringify(s));let u=new eA.A,p=0,h=!1;for(let e of N||[])p+=e.size,e.type===x.pt.pdf&&(h=!0);for(let e of X||[])p+=Number(e.size);(N&&(p>m.sS||N.length>1||z.length>0||X&&X.length>1)||z.length>0||h)&&(t=(0,v.kX)(),ep.addUploading({title:g,type:x.dP.note,progress:0,id:t,coordinates:{lat:e.lat,lon:e.lon},worker:u,layerStatus:x.iO.processing}));let b=!1;u.addEventListener("message",r=>{let{type:s,percentCompleted:l,response:n,status:d}=r.data;switch(s){case"progress":G(l),t&&(b||(ee(eF.EditorState.createEmpty()),a.setShowAddNoteWindow({show:!1,noteMode:x.md.DEFAULT}),b=!0),ep.updateUploading(t,{progress:l}));break;case"done":U([]),b||(ee(eF.EditorState.createEmpty()),a.setShowAddNoteWindow({show:!1,noteMode:x.md.DEFAULT})),a.setRefreshNotes(e=>e+1),f(!1);let u=JSON.parse(n);if(u.first_name=i?.user?.first_name||"",u.last_name=i?.user?.surname||"",u.notification_ids=[],e.onNoteCreated(u),t)return void ep.updateUploading(t,{progress:100,status:x.nW.complete});eS(c,o),y.Ay.success("Note uploaded successfully");break;case"error":if(f(!1),console.error("Request failed with status: "+d),t)return void ep.updateUploading(t,{progress:100,status:x.nW.error});y.Ay.error("Note upload failed")}});let w=`${m.fn}/note/create`,S=Array.from(l.entries());u.postMessage({url:w,formDataObject:S})}catch(e){y.Ay.error("Note upload failed"),f(!1),console.log(e)}};(0,h.useEffect)(()=>{if(a.showAddNoteWindow.show){let t=async t=>{if("setScannedFiles"===t.data.type){let a=t.data.files;U(a);let r=await (0,v.Z)(a[0].base64,a[0].fileName,a[0].fileType);"las"==(0,v.ti)(r.name)&&r&&e.dropFileForCustomLayers&&(eo.closePanel(),setTimeout(async()=>{e.dropFileForCustomLayers?.(r)},500),y.Ay.success("The LAS file will be uploaded as a custom layer, not as a note. Please fill out the form below to begin conversion. The file has been attached.",{duration:2e4}))}};if(window.addEventListener("message",t),e.note){D(e.note),b(e.note.properties.title);let t=new Date(e.note.create_date);w((0,v.n_)(t,t.getTimezoneOffset())),u(x.md.EDIT),ee((0,Y.e9)(e.note.properties.description,e.userMap))}else eN(),u(x.md.DEFAULT);a.showAddNoteWindow.noteMode&&(a.showAddNoteWindow.noteMode==x.md.VIDEO_TO_3D&&(0,e_.HE)()&&(0,e_.KR)()?u(x.md.SCANNER):u(a.showAddNoteWindow.noteMode))}},[e,a.showAddNoteWindow.show,a.showAddNoteWindow.noteMode,a.showAddNoteWindow.description,a.showAddNoteWindow.file_upload]);let eN=()=>{f(!1),D(null),b(""),S(a.showAddNoteWindow.file_upload?[a.showAddNoteWindow.file_upload]:null),w(r.date?r.date:new Date),U([]),ey("1"),eh(eC)},eS=(e,a)=>{t.current&&t.current.flyTo({center:[e,a],zoom:t.current.getZoom()>15?t.current.getZoom()+1:15,essential:!0,duration:eB.AD})};(0,h.useEffect)(()=>{e.note||eN()},[c]);let eE=(e,t)=>{if(!e)return void y.Ay.error(t||"Image analysis failed. Please try again.");let a=Q.getCurrentContent(),r=""===(0,eF.convertToRaw)(a).blocks[0].text;q(t=>t?{caption:e.caption||t.caption,objects:[...t.objects,...e.objects],ocr_text:[...t.ocr_text,...e.ocr_text]}:e);let s=(r?"":"\n\n")+"Pulse Caption: "+e.caption+"\n\n"+(e.objects.length>0?"Detected Objects: "+e.objects.toString().replace(/,/g,", "):"No objects detected.")+"\n\n"+(e.ocr_text.length>0?"Detected Text: "+e.ocr_text.toString().replace(/,/g,", "):"No text detected.");(0,v.Ed)(s,5,ee,Q,er)},eT=e=>{e||el(null)};return(0,h.useEffect)(()=>{P(s.currentRoute||""),O(Number(s.currentChainage?.toFixed(3))||0),$(Number(s.currentChainage?.toFixed(3))||0)},[s.currentRoute,s.currentChainage]),(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(B,{isOpen:H.display,closeModal:()=>Z({display:!1,url:""}),url:H.url}),(0,o.jsx)("div",{className:"transition-opacity  text-black rounded-lg w-full duration-300 mx-auto flex flex-col h-full",children:(0,o.jsxs)("form",{onSubmit:e=>ej(e),className:"rounded-lg flex flex-col gap-4 items-center h-full",children:[e.note&&(0,e_.HE)()&&(0,o.jsx)("input",{type:"button",className:"w-0 h-0 p-0 m-0 border-0 -mt-3",style:{fontSize:0}}),!L&&(0,o.jsx)(o.Fragment,{children:(0,o.jsx)(eJ,{groupName:"note-tabs",tabs:[{value:x.md.DEFAULT,label:"Note"},{value:x.md.VIDEO_TO_3D,label:"Video to 3D"},...(0,e_.HE)()&&(0,e_.KR)()?[{value:x.md.SCANNER,label:"Scanner"}]:[]],selectedValue:c,onSelect:e=>u(e)})}),c==x.md.VIDEO_TO_3D?(0,o.jsxs)("div",{className:"rounded-md bg-orange-100 text-black/70 w-full p-3 flex items-center gap-3 mt-2s text-[12px] flex-row",children:[(0,o.jsx)("div",{children:(0,o.jsx)(W.qVV,{size:20})}),(0,o.jsxs)("div",{children:[(0,o.jsx)("b",{children:"Video to 3D feature currently unavailable"}),(0,o.jsx)("br",{}),"Our servers are currently at full capacity. Please try again later."]})]}):(0,o.jsx)(o.Fragment,{children:(0,o.jsxs)("div",{className:"flex flex-col justify-between h-full w-full",children:[(0,o.jsxs)("div",{className:"flex flex-col justify-between w-full gap-4",children:[(0,o.jsx)("input",{onChange:e=>b(e.target.value),value:g,type:"text",autoFocus:!0,required:!0,placeholder:"Title",className:"input w-full","data-testid":"note-title-input"}),(0,o.jsx)("div",{className:"description-container",children:(0,o.jsx)("div",{className:"description-input rounded-md w-full max-w-2xl bg-white text-black border border-black/10 text-[12px] font-normal pl-2 pt-2","data-testid":"note-description-input",children:ei&&(0,o.jsx)(eP,{editorState:Q,setEditorState:ee,projectUsers:ei,placeholder:"Description",disabled:!1})})}),!L&&(0,o.jsxs)(o.Fragment,{children:[z.length<1?(0,o.jsx)(o.Fragment,{children:c!=x.md.SCANNER&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:"w-full",children:[!X&&(0,o.jsx)(eL.l,{handleChange:e=>{let t=Array.from(e);S([...N||[],...t]);let a=[...k,...t.map(e=>{let t=null;if("image"===(0,v.ti)(e.name)){let a=URL.createObjectURL(e);t={...e,imageSrc:a}}else t={...e,imageSrc:null};return t})];return C(a),()=>
10{a?.forEach(e=>{e.imageSrc&&URL.revokeObjectURL(e.imageSrc)})}},name:"file",multiple:!0,classes:"file-uploader",children:(0,o.jsxs)("div",{className:"file-uploader-box",children:[(0,o.jsx)(W.v4w,{size:18,className:"flex text-black/50"}),(0,o.jsx)("span",{className:"text-black/50 mt-1",children:"Upload a picture, video, or file"}),(0,o.jsx)("span",{className:"text-black/50 text-xs",children:"Max: 2 GB"})]})}),!N&&(0,o.jsx)(eM.A,{modalHtml:"sharepoint-select-notes-modal",onChange:e=>{K([...X||[],e])}})]}),(k.length>0||X&&X.length>0)&&(0,o.jsxs)("div",{className:"flex flex-col gap-2 justify-between",children:[N?.map((e,t)=>e&&e.name&&"image"!==(0,v.ti)(e.name)?(0,o.jsxs)("div",{className:"file-uploader-metadata",children:[(0,o.jsx)("span",{title:e.name,children:e.name.length>30?e.name.slice(0,30)+"...":e.name}),(0,o.jsx)(W.fUT,{className:"file-uploader-delete ml-auto",onClick:()=>{S(e=>e?e.filter((e,a)=>a!==t):null),C(e=>e.filter((e,a)=>a!==t)),q(null)}})]},e.name):(0,o.jsx)(o.Fragment,{children:(0,o.jsxs)("div",{className:"uploaded-image-container file-uploader-metadata p-2",children:[k[t]?.imageSrc&&(0,o.jsx)("img",{src:k[t]?.imageSrc||"",onClick:()=>Z({display:!0,url:k[t]?.imageSrc?k[t]?.imageSrc:""}),alt:e.name,className:"uploaded-image"}),(0,o.jsxs)("div",{className:"flex items-center justify-between",children:[(0,o.jsx)("button",{className:`tooltip whitespace-pre-line tooltip-left ${es===e?"image-analysis":es?"image-analysis-disabled":""} mr-2`,onClick:()=>{el(e),(0,v.qK)(e,eE,"analyze",!1,eT)},type:"button","data-tip":"Pulse uses AI. Check for mistakes.",disabled:!!es||ea,"data-testid":"note-pulse-analysis-btn",children:(0,o.jsx)("img",{src:"/images/pulselogo.svg",alt:"",style:{width:"26px",height:"26px"}})}),(0,o.jsx)(W.fUT,{className:"file-uploader-delete ml-auto",onClick:()=>{S(e=>e?e.filter((e,a)=>a!==t):null),C(e=>e.filter((e,a)=>a!==t)),q(null)}})]})]},e.name)})),X?.map((e,t)=>e&&e.name&&(0,o.jsxs)("div",{className:"flex gap-2 w-full",children:[(0,o.jsx)("span",{title:e.name,children:e.name.length>50?e.name.slice(0,50)+"...":e.name}),(0,o.jsx)(W.fUT,{className:"file-uploader-delete ml-auto",onClick:()=>{K(e=>e?e.filter((e,a)=>a!==t):null)}})]},e.name))]})]})}):(0,o.jsxs)("div",{className:"rounded-md bg-tt-blue/10 text-black/70 w-full p-3 flex items-center gap-3 mt-2",children:[(0,o.jsx)("div",{children:(0,o.jsx)(eu.GLH,{size:20})}),(0,o.jsxs)("span",{children:[(0,o.jsx)("b",{children:"Object scanned successfully"}),(0,o.jsx)("br",{}),"This note will be created as a 3D note using the scanned object"]})]}),c==x.md.SCANNER&&(0,o.jsx)("div",{className:"w-full justify-between flex",children:(0,o.jsxs)("div",{onClick:()=>{U([]),(0,e_.XM)()},className:"btn w-full",children:[(0,o.jsx)(ek.tXq,{}),z.length>0?"Scan again":"Scan 3D"]})}),(0,o.jsx)("div",{className:"flex items-center w-full",children:(0,o.jsx)("input",{type:"datetime-local",className:"input w-full",style:{marginLeft:"auto",marginRight:"auto"},value:(0,v.rm)(j),onChange:e=>{let t=new Date(e.target.value);isNaN(t.getTime())?console.error("Invalid date input"):w(t)},"data-testid":"note-date-input"})}),(0,o.jsxs)("div",{className:"flex gap-2 items-center w-full text-black/80",children:[(0,o.jsx)("input",{type:"checkbox",id:"useMyLocation",className:"checkbox",onChange:e=>M(e.target.checked),checked:A}),(0,o.jsx)("label",{htmlFor:"useMyLocation",children:"Use my location"})]}),n.project?.lrs_included&&s.availableRoutes&&s.availableRoutes.length>0&&(0,o.jsxs)("div",{className:"flex flex-col gap-4 w-full",children:[(0,o.jsxs)("div",{className:"flex items-center gap-2 text-black/80",children:[(0,o.jsx)("input",{type:"checkbox",id:"useLRS",className:"checkbox",onChange:e=>T(e.target.checked),checked:E}),(0,o.jsx)("label",{htmlFor:"useLRS",children:"Use LRS"}),(0,o.jsx)("div",{className:"tooltip tooltip-bottom cursor-pointer","data-tip":"Add linear referencing system information into the note",children:(0,o.jsx)(ek.Q9E,{})})]}),E&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("div",{children:(0,o.jsxs)("select",{value:I,className:"select select-bordered w-full p-2",onCh
10ange:e=>{P(e.target.value)},children:[(0,o.jsx)("option",{value:"",children:"Select a route..."}),s.availableRoutes.map((e,t)=>(0,o.jsx)("option",{value:e.route,children:e.route},t))]})}),(0,o.jsxs)("div",{className:"flex gap-4 w-full",children:[(0,o.jsxs)("div",{className:"flex flex-col w-full sm:w-1/2 max-w-xs",children:[(0,o.jsx)("label",{children:"From:"}),(0,o.jsx)("input",{value:F,onChange:e=>{O(e.target.value)},onBlur:e=>{O(""===e.target.value?0:Number.parseFloat(e.target.value))},placeholder:"0",className:"input input-bordered w-full h-10 p-2"})]}),(0,o.jsxs)("div",{className:"flex flex-col w-full sm:w-1/2 max-w-xs",children:[(0,o.jsx)("label",{children:"To:"}),(0,o.jsx)("input",{value:R,onChange:e=>{$(e.target.value)},onBlur:e=>{$(""===e.target.value?0:Number.parseFloat(e.target.value))},placeholder:"0",className:"input input-bordered w-full h-10 p-2"})]})]})]})]})]})]}),(0,o.jsx)("div",{className:"w-full pt-6 pb-4 tablet:pb-0",children:(0,o.jsxs)("div",{className:`flex w-full ${p?"justify-center":"justify-between"}`,children:[p?(0,o.jsxs)("div",{className:"notes-uploading-progress",children:[(0,o.jsx)("div",{className:"notes-uploading-progress-bar",children:(0,o.jsx)("div",{className:"notes-uploading-progress-bar-elapsed",style:{width:`${V}%`}})}),(0,o.jsxs)("div",{className:"notes-uploading-progress-bar-text",children:[(0,o.jsx)("span",{className:"loading loading-spinner loading-xs"}),100===V?(0,o.jsx)("span",{children:"Processing"}):(0,o.jsxs)(o.Fragment,{children:["Uploading (",V,"%)"]})]})]}):(0,o.jsx)("button",{type:"submit",className:`btn btn-primary tt-blue-button ${c!==x.md.DEFAULT?"w-full":"w-[83%]"}`,onClick:()=>{""!==g&&e.closePanel?.()},"data-testid":"note-add-btn",children:L?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(W.dJk,{size:20}),"\xa0Edit"]}):(0,o.jsx)(o.Fragment,{children:"Add"})}),c==x.md.DEFAULT&&!p&&(0,o.jsx)("div",{tabIndex:0,role:"button",className:"btn",style:{paddingLeft:"12px",paddingRight:"12px"},onClick:()=>ed(!0),"data-testid":"note-emoji-picker-btn",children:(0,o.jsx)(d(),{src:em,alt:"current symbol",width:20,height:20})})]})})]})})]})}),ec]})}var eH=a(23963),eZ=a(39909),eX=a(36739),eK=a(80987),eQ=a(77582),e0=a(82051),e1=a(75296),e2=a(33873);function e5({project:e,isOpen:t,setIsOpen:a}){let r=(0,ex.u)(),s=(0,eg.ZM)(),l=(0,v._Y)(r?.user),[i,n]=(0,h.useState)("Properties"),[c,d]=(0,h.useState)(!1),[u,p]=(0,h.useState)(s.alertNotificationsEnabled),x=()=>{p(s.alertNotificationsEnabled),d(!1),a(!1)};return(0,o.jsx)(o.Fragment,{children:t&&(0,o.jsxs)("div",{children:[(0,o.jsx)("input",{type:"checkbox",id:"my_modal_7",className:"modal-toggle"}),(0,o.jsxs)("dialog",{open:!0,className:"modal text-black",children:[(0,o.jsxs)("div",{className:"modal-box sm:min-w-fit group",children:[(0,o.jsxs)("div",{className:"flex flex-row justify-between items-center",children:[(0,o.jsxs)("span",{className:"font-bold text-lg flex flex-row items-center gap-3",children:[(0,o.jsx)(W.uct,{})," Settings"]}),(0,o.jsx)("label",{onClick:x,htmlFor:"my_modal_7",className:"btn btn-sm btn-circle btn-ghost",children:"✕"})]}),(0,o.jsx)("div",{className:"my-2",children:(0,o.jsx)(eJ,{groupName:"settings-tabs",tabs:[{value:"Properties",label:"Properties"},{value:"Manage Users",label:"Manage Users"}],selectedValue:i,onSelect:e=>n(e)})}),(0,o.jsx)(e1.A,{isOpen:"Properties"===i,onClose:()=>x(),mode:"edit",projectUuid:e?.project_uuid||"",projectName:e?.project_name||"",mapView:!0,saveAndReload:c,onSaveAndReloadHandled:()=>d(!1)}),"Manage Users"===i&&(0,o.jsx)("div",{className:"flex justify-center bg-white overflow-auto h-[70vh]",children:l?(0,o.jsx)(e2.A,{project_uuid:e.project_uuid}):(0,o.jsx)(o.Fragment,{children:"You do not have permission to view the admin page."})}),"Properties"===i&&(0,o.jsx)("div",{className:"mt-4 mb-5 group-has-[.loading-spinner]:hidden",children:(0,o.jsxs)("div",{className:"w-full p-5 border border-gray-300 rounded-sm flex items-center justify-between gap-4",children:[(0,o.jsxs)("div",{className:"flex flex-col",children:[(0,o.jsx)("span",{className:"text-sm font-medium text-black",children:"Alert notifications"}),(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Show toast notifications when new alerts are received."})]}),(0,o.jsx)("input",{type:"checkbox",className:"toggle toggle-sm border",checked:u,onFocus:e=>e.target.blur(),onChange:e=>p(e.target.checked)})]})}),(0,o.jsx)("div",{className:"w-full h-px bg-gray-300/50 mb-4"}),(0,o.jsxs)("div",{className:"flex flex-row justify-between items-center",children:[(0,o.jsxs)("span",{className:"text-xs text-grey/70",children:["FusionMap ",m.xv]}),(0,o.jsxs)("div",{className:"flex flex-row gap-2",children:["Properties"===i&&(0,o.jsx)("label",{htmlFor:"my_modal_7",className:"btn tt-blue-button",onClick:()=>{s.setAlertNotificationsEnabled(u),localStorage.setItem(eg.KW,String(u)),d(!0)},children:"Save and Reload"}),(0,o.jsx)("label",{htmlFor:"my_modal_7",className:"btn",onClick:x,children:"Close"})]})]})]}),(0,o.jsx)("label",{className:"modal-backdrop",onClick:x,htmlFor:"my_modal_7",children:"Close"})]})]})})}var e3=a(21623),e4=a(61854);function e8({daysUntilExpiry:e,className:t}){return(0,o.jsx)("div",{className:`bg-orange-100 rounded-md text-black/70 text-center text-sm p-1.5 ${t}`,"data-testid":"account-expiry-box",children:(0,o.jsx)(e4.R,{daysUntilExpiry:e,variant:x.i7.Box})})}function e6(e){let t=(0,ex.u)(),a=(0,ev.O)(),[r,s]=(0,h.useState)(!1),[l,i]=(0,h.useState)(!1),n=(0,e3.Jj)(t?.user);(0,h.useEffect)(()=>{s(e.showMobileMenu)},[e.showMobileMenu]);let c=()=>{e.setShowMobileMenu(e=>!e)};return(0,o.jsxs)("div",{children:[e.showMobileMenu&&(0,o.jsx)("div",{className:"w-full h-full z-50 absolute",onClick:e=>{e.target===e.currentTarget&&c()},children:(0,o.jsx)("div",{className:`map-mobile-menu-overlay ${r?"animate-slide-in":""}`,onAnimationEnd:()=>{e.showMobileMenu||s(!1)},children:(0,o.jsxs)("div",{className:"map-mobile-menu",onClick:e=>{e.stopPropagation()},children:[(0,o.jsxs)("div",{className:"flex justify-between items-center p-3",children:[(0,o.jsx)(p(),{href:"/",children:(0,o.jsx)("img",{src:"/images/fusionmap_logo_hor.svg",alt:"FusionMap Logo",width:120})}),(0,o.jsx)("button",{onClick:c,className:"btn btn-sm bg-white",children:(0,o.jsx)(eK.yGN,{})})]}),(0,o.jsx)("hr",{}),(0,o.jsxs)("ul",{className:"flex flex-col text-[14px] gap-1 opacity-90 p-3",children:[null!==n&&(0,o.jsx)(e8,{daysUntilExpiry:n,className:"mb-1"}),(0,o.jsx)("li",{className:"text-black cursor-pointer",children:(0,o.jsxs)(p(),{href:"/",className:"flex ml-2 p-2 items-center gap-2",children:[(0,o.jsx)(W.Emm,{})," Home"]})}),(0,o.jsx)("li",{className:"text-black cursor-pointer",children:(0,o.jsxs)(p(),{href:"/projects",className:"flex ml-2 p-2 items-center gap-2",children:[(0,o.jsx)(W.HEG,{})," Projects"]})}),(0,o.jsx)("li",{className:"text-black cursor-pointer",children:(0,o.jsxs)(p(),{href:"/profile",className:"flex ml-2 p-2 items-center gap-2",children:[(0,o.jsx)(W.kSq,{})," Profile"]})}),(0,o.jsx)("li",{className:"text-black cursor-pointer",children:(0,o.jsxs)(p(),{target:"_blank",href:"https://fusionmap.com/knowledge-base/",className:"flex ml-2 p-2 items-center gap-2",children:[(0,o.jsx)(e0.ZPX,{})," Help"]})}),(0,o.jsx)("li",{className:"cursor-pointer text-black",onClick:e=>{e.stopPropagation(),i(e=>!e)},children:(0,o.jsxs)("label",{htmlFor:"project-modal",className:"flex ml-2 p-2 items-center gap-2",children:[(0,o.jsx)(W.uct,{}),"Settings"]})}),(0,o.jsx)("li",{onClick:e=>{e.stopPropagation(),(0,eQ.r)()},className:"cursor-pointer text-black",children:(0,o.jsxs)("div",{className:"flex ml-2 p-2 items-center gap-2",children:[(0,o.jsx)(W.qBV,{})," Log out"]})})]})]})})}),(0,o.jsx)(e5,{project:a.project,isOpen:l,setIsOpen:i})]})}let e7={run:!1,steps:[{content:(0,o.jsxs)("div",{children:[(0,o.jsx)("h2",{children:(0,o.jsx)("b",{children:"Welcome to FusionMap!"})}),(0,o.jsx)("br",{}),(0,o.jsx)("h5",{children:"Ready to uncover the magic of FusionMap? This quick walkthrough is your gateway to unleashing the full potential of our tools."})]}),locale:{skip:(0,o.jsx)("strong",{"aria-label":"skip",children:"CANCEL"})},placement:"center",target:"body"},{content:"Something specific in mind? Enter the name or coordinates (lat, lon) of the location you would like to view.",locale:{skip:(0,o.jsx)("strong",{"aria-label":"skip",children:"CANCEL"})},placement:"bottom",spotlightPadding:10,target:'[data-testid="search-div"]',title:(0,o.jsx)("b",{children:"Standard Search"})},{content:"Click here to access our advanced search feature which uses the Linear Referencing System",locale:{skip:(0,o.jsx)("strong",{"aria-label":"skip",children:"CANCEL"})},placement:"bottom",spotlightPadding:20,target:"button.btn.btn-primary.tt-blue-button.ml-2.bg-tt-blue.text-white.shadow",title:(0,o.jsx)("b",{children:"Advanced Search"})},{content:(0,o.jsxs)("div",{children:[(0,o.jsx)("p",{className:"mb-4 text-center",children:"LiDAR view can be accessed here."}),(0,o.jsx)("div",{className:"flex justify-center mx-auto",children:(0,o.jsx)("iframe",{width:"300",height:"200",src:"https://www.youtube.com/embed/yABA24DGmUA",title:"FusionMap Tutorial: LiDAR Analytics",frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture;
10 web-share",referrerPolicy:"strict-origin-when-cross-origin",allowFullScreen:!0})})]}),locale:{skip:(0,o.jsx)("strong",{"aria-label":"skip",children:"CANCEL"})},placement:"right",spotlightPadding:10,target:'button[data-tooltip-id="lidar-tooltip"]',title:(0,o.jsx)("b",{children:"LiDAR View"})},{content:(0,o.jsxs)("div",{children:[(0,o.jsx)("p",{className:"mb-4 text-center",children:"Hybrid view can be used to view pano images and LiDAR together."}),(0,o.jsx)("div",{className:"flex justify-center mx-auto",children:(0,o.jsx)("iframe",{width:"300",height:"200",src:"https://www.youtube.com/embed/owB7h0nt9ec",title:"FusionMap Tutorial: Hybrid LiDAR and Panoramic Tool",frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",referrerPolicy:"strict-origin-when-cross-origin",allowFullScreen:!0})})]}),locale:{skip:(0,o.jsx)("strong",{"aria-label":"skip",children:"CANCEL"})},placement:"right",spotlightPadding:10,target:'button[data-tooltip-id="measurements-tt"]',title:(0,o.jsx)("b",{children:"Hybrid View"})},{content:"Need a bird's eye view? Try out our Eagle View feature.",locale:{skip:(0,o.jsx)("strong",{"aria-label":"skip",children:"CANCEL"})},placement:"right",spotlightPadding:10,target:'button[data-tooltip-id="eaglevue-tt"]',title:(0,o.jsx)("b",{children:"Eagle View"})},{content:(0,o.jsxs)("div",{children:[(0,o.jsx)("p",{className:"mb-4 text-center",children:"Notes can be accessed here. To add notes, use the add button on the menu or right click at the desired location."}),(0,o.jsx)("div",{className:"flex justify-center mx-auto",children:(0,o.jsx)("iframe",{width:"300",height:"200",src:"https://www.youtube.com/embed/vR_UOcUqIEs",title:"FusionMap Tutorial: Digital note taking",frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",referrerPolicy:"strict-origin-when-cross-origin",allowFullScreen:!0})})]}),locale:{skip:(0,o.jsx)("strong",{"aria-label":"skip",children:"CANCEL"})},placement:"right",spotlightPadding:10,target:'button[data-tooltip-id="notes-tt"]',title:(0,o.jsx)("b",{children:"Notes"})},{content:(0,o.jsxs)("div",{children:[(0,o.jsx)("p",{className:"mb-4 text-center",children:"Alerts allow you to get notified for any events occuring at a specific point."}),(0,o.jsx)("div",{className:"flex justify-center mx-auto",children:(0,o.jsx)("iframe",{width:"300",height:"200",src:"https://www.youtube.com/embed/k5yrEP8e2Sw",title:"FusionMap Tutorial: Issuing Alerts Functionality",frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",referrerPolicy:"strict-origin-when-cross-origin",allowFullScreen:!0})})]}),locale:{skip:(0,o.jsx)("strong",{"aria-label":"skip",children:"CANCEL"})},placement:"right",spotlightPadding:10,target:'button[data-tooltip-id="alerts-tt"]',title:(0,o.jsx)("b",{children:"Alerts"})},{content:"Want to check out what things were like back in time? Change the date on the Calendar.",locale:{skip:(0,o.jsx)("strong",{"aria-label":"skip",children:"CANCEL"})},placement:"top",spotlightPadding:10,target:'div[data-tooltip-id="calendar-tt"]',title:(0,o.jsx)("b",{children:"Calendar"})},{content:"Navigate here to access other projects, logout and the admin panel.",locale:{skip:(0,o.jsx)("strong",{"aria-label":"skip",children:"CANCEL"})},placement:"right",spotlightPadding:10,target:'div[data-tooltip-id="summary-tt"]',title:(0,o.jsx)("b",{children:"User Summary"})},{content:"Pulse, our AI assistant, can assist you with project inquiries and chat with PDF files.",locale:{skip:(0,o.jsx)("strong",{"aria-label":"skip",children:"CANCEL"})},placement:"left",spotlightPadding:10,target:'button[data-tooltip-id="pulse-tt"]',title:(0,o.jsx)("b",{children:"Pulse"})},{content:(0,o.jsxs)("div",{children:[(0,o.jsx)("p",{className:"mb-4 text-center",children:"To make area and distance measurements on your project, you can click on these buttons."}),(0,o.jsx)("div",{className:"flex justify-center mx-auto",children:(0,o.jsx)("iframe",{width:"300",height:"200",src:"https://www.youtube.com/embed/GMGbpqvsD4g",title:"FusionMap Tutorial: Measurement tools",frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture;
10 web-share",referrerPolicy:"strict-origin-when-cross-origin",allowFullScreen:!0})})]}),locale:{skip:(0,o.jsx)("strong",{"aria-label":"skip",children:"CANCEL"})},placement:"left",spotlightPadding:10,target:'[data-testid="tools-measurements"]',title:(0,o.jsx)("b",{children:"Measurements"})},{content:"To get a better idea of the terrain of a region, you can toggle the perspective from 2D to 3D here.",locale:{skip:(0,o.jsx)("strong",{"aria-label":"skip",children:"CANCEL"})},placement:"left",spotlightPadding:10,target:'[data-testid="perspective-toggle"]',title:(0,o.jsx)("b",{children:"Perspective"})},{content:"Control your settings here.",locale:{skip:(0,o.jsx)("strong",{"aria-label":"skip",children:"CANCEL"})},placement:"left",spotlightPadding:10,target:'button[data-tooltip-id="settings-tt"]',title:(0,o.jsx)("b",{children:"Settings"})},{content:(0,o.jsxs)("div",{children:[(0,o.jsx)("p",{className:"mb-4 text-center",children:"You can add and customize your map layers here."}),(0,o.jsx)("div",{className:"flex justify-center mx-auto",children:(0,o.jsx)("iframe",{width:"300",height:"200",src:"https://www.youtube.com/embed/CV-9RoeQhPk",title:"FusionMap Tutorial: Adding Custom Map Layers and Premium Layers",frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",referrerPolicy:"strict-origin-when-cross-origin",allowFullScreen:!0})})]}),locale:{skip:(0,o.jsx)("strong",{"aria-label":"skip",children:"CANCEL"})},placement:"top",spotlightPadding:10,target:'[data-testid="layers-modal"]',title:(0,o.jsx)("b",{children:"Map Layers"})}]};var e9=a(43299);let te=async({userContext:e,project:t,geojson:a,title:r,description:s,color:l,measurement:i})=>{let n={...a},o=String(new Date().getTime()),c=e?.user?.name,d=e?.user?.id;for(let e of n.features){e.properties&&Object.assign(e.properties,{name:r,type:r,description:s,[i.type]:"distance"===i.type?i.value/eB.il:i.value,source:"Mapbox",color:l,uuid:o,user:c,user_id:d});let[t,a]="distance"===i.type?e.geometry.coordinates[0]:e.geometry.coordinates[0][0],n=await (0,v.S1)(a,t)??0;("distance"===i.type?e.geometry.coordinates:e.geometry.coordinates.flat()).forEach(e=>{e[2]=n})}try{return await (0,_.x)("/measurement/sync",{method:"POST",json:{project_id:t?.project_uuid,geojson:{updated:n,deleted:v.Nc}}}),{saved:!0,feature:n.features[0]}}catch{return{saved:!1,feature:null}}},tt=async(e,t)=>{await (0,_.x)("/measurement/sync",{method:"POST",json:{project_id:e?.project_uuid,geojson:{updated:{type:"FeatureCollection",features:[t]},deleted:v.Nc}}})};var ta=a(51965);function tr(e){return(0,o.jsxs)("div",{className:"flex items-center",style:{width:e.customWidth,...!e.customWidth&&{gap:"2px"}},children:[(0,o.jsx)("span",{className:"opacity-80",children:e.label}),(0,o.jsx)("input",{type:"color",className:`cursor-pointer ${e.className??""}`,value:e.color,list:"presetColors",onChange:t=>e.handleChangeColor(t)}),(0,o.jsxs)("datalist",{id:"presetColors",children:[(0,o.jsx)("option",{children:"#5781ff"}),(0,o.jsx)("option",{children:"#FF6900"}),(0,o.jsx)("option",{children:"#FCB900"}),(0,o.jsx)("option",{children:"#7BDCB5"}),(0,o.jsx)("option",{children:"#00D084"}),(0,o.jsx)("option",{children:"#00FFFF"}),(0,o.jsx)("option",{children:"#FFEB3B"}),(0,o.jsx)("option",{children:"#9900EF"}),(0,o.jsx)("option",{children:"#F78DA7"}),(0,o.jsx)("option",{children:"#EB144C"})]})]})}var ts=a(35344);function tl({mode:e}){let t=(0,eG.JY)(),a=(0,ex.u)(),r=(0,ev.O)(),s=(0,ej.H)(),{areaInSquareMeters:l,distanceInCentimeters:i}=(0,ey.F)(),{drawingGeojson:n,drawingColor:c,setDrawingColor:d,drawingModeCaller:u,setDrawingModeCaller:p,clearDrawing:m}=(0,eb.g)(),[f,g]=(0,h.useState)(""),[y,b]=(0,h.useState)(""),[j,w]=(0,h.useState)(!1),N=u===e,S=e===x.xY.DISTANCE_TOOL,k=S?"Distance":"Area",_=S?"distance":"area",C=S?i:l,L=S?(0,o.jsx)($.cXu,{className:"mr-4"}):(0,o.jsx)(ep.voV,{className:"mr-4"}),D="";if(S){let{distanceLabel:e,unitLabel:t}=((e,t)=>{if(t===x.WU.Imperial){let t=e9.I3T(e,"centimeters","feet");return t>=eB.pB?{distanceLabel:e9.I3T(e,"centimeters","miles").toFixed(2),unitLabel:"mi"}:{distanceLabel:t.toFixed(2),unitLabel:"ft"}}return e>=eB.WX*eB.il?{distanceLabel:e9.I3T(e,"centimeters","kilometers").toFixed(2),unitLabel:"km"}:e>=eB.il?{distanceLabel:(e/eB.il).toFixed(2),unitLabel:"m"}:{distanceLabel:e.toFixed(2),unitLabel:"cm"}})(C,r.project?.units);D=`${e} ${t}`}else{let{areaLabel:e,unitLabel:t}=((e,t)=>{if(t===x.WU.Imperial){let t=e9.vnt(e,"meters","feet");return t>=eB.fh?{areaLabel:e9.vnt(e,"meters","miles").toFixed(2),unitLabel:"mi\xb2"}:{areaLabel:t.toFixed(2),unitLabel:"ft\xb2"}}return e>=eB.qe?{areaLabel:e9.vnt(e,"meters","kilometers").toFixed(2),unitLabel:"km\xb2"}:{areaLabel:e.toFixed(2),unitLabel:"m\xb2"}})(C,r.project?.units);D=`${e} ${t}`}let A=async e=>{e.preventDefault(),w(!0);let s=await te({userContext:a,project:r.project,geojson:n,title:f,description:y,color:c,measurement:{type:_,value:C}});s.saved&&(T(),E(t.map,s.feature)),w(!1)},M=e=>{d(e.target.value)},T=()=>{p(null),s.setBottomMenuOpen({open:!1,id:0,event:null})},I=()=>{g(""),b("")},P=()=>{m(!1),d(ts.O),I()},F=n.features.length>0;(0,h.useEffect)(()=>{N||(I(),w(!1))},[N]);let O=e=>(0,o.jsxs)("form",{onSubmit:e=>A(e),className:"flex flex-col gap-2 items-center w-full",children:[(0,o.jsxs)("pre",{className:"text-black font-xl p-2 rounded-md bg-slate-400/10 mb-2 shadow flex items-center",children:[L," ",k,": ",D]}),e&&(0,o.jsx)("button",{className:"absolute top-4 right-4 opacity-50 cursor-pointer",onClick:T,type:"button",children:(0,o.jsx)(W.fUT,{})}),(0,o.jsx)("input",{onChange:e=>g(e.target.value),maxLength:50,value:f,type:"text",placeholder:"Title",className:"input input-sm w-[300px] max-w-2xl backdrop-blur-sm bg-white/80 text-black border-black/10"}),(0,o.jsx)("input",{onChange:e=>b(e.target.value),maxLength:100,value:y,type:"text",placeholder:"Description",className:"input w-[300px] input-sm max-w-2xl backdrop-blur-sm bg-white/80 text-black border-black/10"}
10),(0,o.jsx)(tr,{color:c,handleChangeColor:M,label:"Color"}),(0,o.jsxs)("div",{className:"flex w-[300px] gap-2",children:[(0,o.jsxs)("button",{onClick:T,type:"button",className:"btn btn-sm text-sm mt-2 flex-1",children:[(0,o.jsx)(eK.yGN,{size:20}),"Close"]}),(0,o.jsxs)("button",{onClick:P,type:"button",className:"btn btn-sm text-sm mt-2 flex-1",children:[(0,o.jsx)(eK.cO3,{size:20}),"Clear"]}),(0,o.jsx)("button",{type:"submit",className:`btn btn-sm btn-primary tt-blue-button mt-2 flex-1 ${!F&&"opacity-80"}`,disabled:!F,children:j?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("span",{className:"loading loading-spinner loading-md"}),"\xa0Save"]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(eK.Bc_,{size:20}),"Save"]})})]})]});return(0,o.jsx)(o.Fragment,{children:void 0!==globalThis.window&&(0,o.jsx)(o.Fragment,{children:(0,v.Fr)()?(0,o.jsx)(ta.X,{blocking:!1,onDismiss:T,className:"text-black z-50 bottommenu absolute text-[13px]",style:{zIndex:5e6},expandOnContentDrag:!0,open:N,children:(0,o.jsx)("div",{className:"p-3",children:O(!1)})}):N&&(0,o.jsx)("div",{className:"bottom-modal sliding-div p-4 relative",children:O(!0)})})})}var ti=a(83964),tn=a(7121);let to=Symbol("alerts-style-handler-bound"),tc=(e,t)=>tu([{id:e,verify_status:t}]),td=async(e,t,a,r,s,l,i,n,c)=>{if(!a)return e;let d=!1,u={width:120,height:120,data:new Uint8Array(57600),image:new Image,onAdd:function(){let e=document.createElement("canvas");e.width=this.width,e.height=this.height,this.context=e.getContext("2d"),this.image.src="/images/alert-verified-marker.png"},render:function(){let t=performance.now()%1e3/1e3,a=this.context;if(a.clearRect(0,0,this.width,this.height),a.beginPath(),a.arc(this.width/2,this.height/2,30*t+18,0,2*Math.PI),a.fillStyle=`rgba(255, 200, 200, ${1-t})`,a.fill(),this.image.complete){let e=2*this.image.width,t=2*this.image.height;a.drawImage(this.image,this.width/2-e/2,this.height/2-t/2,e,t)}return this.data=a.getImageData(0,0,this.width,this.height).data,e.current.triggerRepaint(),!0}};e.current.hasImage("alert-verified-marker")||e.current.addImage("alert-verified-marker",u,{pixelRatio:2});let p=async()=>{if(!(0,eo.fu)(e,"alerts",()=>{p()}))return;e.current.off("mouseenter","alerts-point-layer"),e.current.off("mousemove","alerts-point-layer"),e.current.off("mouseleave","alerts-point-layer"),e.current.off("mouseenter","alerts-polygon-layer-symbol"),e.current.off("mousemove","alerts-polygon-layer-symbol"),e.current.off("mouseleave","alerts-polygon-layer-symbol"),e.current.off("click","alerts-point-layer"),e.current.off("click","alerts-polygon-layer-symbol"),e.current.off("touchend","alerts-point-layer"),e.current.off("touchend","alerts-polygon-layer-symbol"),e.current.off("click","cluster-alert-circle"),e.current.off("click","cluster-alert-text"),e.current.off("dragstart"),e.current.off("dragend"),e.current.loadImage("/images/alert-unverified-marker.png",(t,a)=>{if(t)throw t;e.current.hasImage("alert-marker")||e.current.addImage("alert-marker",a)}),await (0,ti.Cq)(n,e,!0),(0,tn.Is)(e,x.ly.NORMAL,{type:"FeatureCollection",features:[]}),(0,tn.gb)(e,x.S3.POINT),(0,tn.gb)(e,x.S3.POLYGON),(0,tn.gb)(e,x.S3.CLUSTER),(0,k.y)(e.current),(0,ti.aM)(e);let s=async a=>{await (0,ti.TD)([a])?((0,v.By)(),y.Ay.success("Alert deleted successfully"),(0,ti.pQ)(e,[Number(a)]),t.setUpdate(e=>e+1)):y.Ay.error("Alert deletion failed")},{showPopup:i,clearHoverTimeout:u,handleMouseLeave:m}=ei(e,e=>(0,ti.HN)(e.features[0],e.lngLat),({e,properties:t,coordinates:i,additionalPopupShowing:n})=>(0,o.jsx)(et.LD,{children:(0,o.jsx)(Q,{additionalPopupShowing:n,properties:t,coordinates:i,type:"alerts",onDelete:s,project:a,selectedNote:c,thread:e.features?e.features[0]:null,userMap:r,closePanel:l})})),h=t=>{let a=t.features?.[0];a?.geometry?.coordinates&&e.current.easeTo({center:a.geometry.coordinates,zoom:e.current.getZoom()+1})};e.current.on("click","cluster-alert-circle",h),e.current.on("click","cluster-alert-text",h),en(e,"alerts-point-layer",{showPopup:i,handleMouseLeave:m,setSelectedNote:c,isDragging:d,clearHoverTimeout:u},{markerType:x.TG.alert,getCoordinates:e=>(0,ti.HN)(e.features[0],e.lngLat)}),en(e,"alerts-polygon-layer-symbol",{showPopup:i,handleMouseLeave:m,setSelectedNote:c,isDragging:d,clearHoverTimeout:u},{markerType:x.TG.alert,getCoordinates:e=>(0,ti.HN)(e.features[0],e.lngLat)}),e.current.on("dragstart",()=>{d=!0}),e.current.on("dragend",()=>{d=!1})};return await p(),e.current[to]||(e.current.on("style.load",async()=>{let t=(0,eo.QH)(e,"alerts");t?t():await p()}),e.current[to]=!0),e},tu=async e=>{try{let t=new FormData;return t.append("alerts",JSON.stringify(e)),await (0,_.x)(m.fn+"/alert/update",{method:"PATCH",form:t,rawResponse:!0})}catch(e){return console.error("Request failed:",e),null}},tp=async e=>{try{return await fetch(`${m.fn}/alert/${e}/send-notification`,{method:"POST",credentials:"include"})}catch(e){return console.error("Request failed:",e),null}};var tm=a(11819);function th(e){let{map:t}=(0,eG.JY)(),a=(0,eg.ZM)(),r=(0,ex.u)(),s=(0,eD.l)(),[l,i]=(0,h.useState)(!1),[n,c]=(0,h.useState)(""),[d,u]=(0,h.useState)(new Date),[p,f]=(0,h.useState)(""),[g,b]=(0,h.useState)(3),[j,w]=(0,h.useState)(""),[N,S]=(0,h.useState)(),[k,_]=(0,h.useState)(!1),[C,L]=(0,h.useState)(!1),[D,A]=(0,h.useState)(0),[M,E]=(0,h.useState)(),[T,I]=(0,h.useState)(!1),[P,F]=(0,h.useState)(null),[O,R]=(0,h.useState)(null),[$,z]=(0,h.useState)({dis
10play:!1,url:""}),[U,V]=(0,h.useState)(null),[G,J]=(0,h.useState)(()=>eF.EditorState.createEmpty()),[q,H]=(0,h.useState)([]);(0,h.useEffect)(()=>{e.userMap&&H(Object.values(e.userMap).map(e=>({id:e.id,name:e.first_name.trim()+" "+e.last_name.trim(),avatar:e.profile_image||null,email:e.email})))},[e.userMap]);let{setUpdate:Z}=(0,et.xS)(),X=(0,h.useRef)(null),K=(0,h.useRef)(null);(0,h.useEffect)(()=>{if(N&&"image"===(0,v.ti)(N.name)){let e=URL.createObjectURL(N);return R(e),()=>URL.revokeObjectURL(e)}R(null)},[N]);let Q=async t=>{t.preventDefault(),A(0),i(!0);let l=(0,v.BG)(G);if(M)try{let t={id:M.id,issuer:j,category:p,title:n,description:l.modifiedText?.trim(),description_with_names:l.plainText?.trim(),mentions:l.mentions,create_date:d,severity:g},a=await tu([t]);if(a?.ok){J(eF.EditorState.createEmpty()),Z(e=>(console.log("Current update value:",e),e+1));let t=await a.json();e.OnAlertUpdated(t.updatedAlerts),y.Ay.success("Alert updated successfully"),i(!1)}else y.Ay.error("Alert update failed"),i(!1)}catch{y.Ay.error("Unexpected error. Alert update failed"),i(!1)}else try{let t,o=JSON.parse(localStorage.getItem("project")||"{}"),c={geojson:{type:"Feature",geometry:{type:"Point",coordinates:[e.lon,e.lat,-10]}},project_id:o?.project_uuid,title:n,description:l.modifiedText?.trim(),description_with_names:l.plainText?.trim(),mentions:l.mentions,create_date:d,severity:g,lrs:null,validated:!1,issuer:r?.user?.name,category:p,email_admin:C,detected_objects:P?.objects,detected_text:P?.ocr_text};if(k){let e=await (0,v.vM)();c.geojson.geometry.coordinates[1]=e.latitude,c.geojson.geometry.coordinates[0]=e.longitude}let u=new eA.A,h=N&&N?.type===x.pt.pdf;(N&&N?.size>m.sS||h)&&(t=(0,v.kX)(),s.addUploading({title:n,type:x.dP.alert,progress:0,id:t,coordinates:{lat:e.lat,lon:e.lon},worker:u,layerStatus:x.iO.processing}));let f=!1;u.addEventListener("message",r=>{let{type:l,percentCompleted:n,response:o,status:c}=r.data;switch(l){case"progress":A(n),t&&(f||(f=!0),s.updateUploading(t,{progress:n}));break;case"done":for(let t of(f||(K.current&&K.current.click(),J(eF.EditorState.createEmpty())),a.setRefreshAlerts(e=>e+1),i(!1),JSON.parse(o)))t.notification_ids=[],e.OnAlertCreated(t);if(t)return void s.updateUploading(t,{progress:100,status:x.nW.complete});ee(),y.Ay.success("Alert issued");break;case"error":if(i(!1),console.error("Request failed with status: "+c),t)return void s.updateUploading(t,{progress:100,status:x.nW.error});y.Ay.error("Note upload failed")}});let b=new FormData;b.append("alerts",JSON.stringify([c])),b.append("container_name",o.container_name??""),U&&b.append("integration_file",JSON.stringify(U)),b.append("project_id",o.project_uuid),N&&b.append("file_upload",N);let j=`${m.fn}/alert/create`,w=Array.from(b.entries());u.postMessage({url:j,formDataObject:w})}catch(e){y.Ay.error("Issue alert failed"),i(!0),console.log(e)}i(!1)};(0,h.useEffect)(()=>{a.showIssueAlertWindow?(S(null),c(""),u(new Date),f(""),w(""),b(3),e.alert&&(E(e.alert),c(e.alert.properties.title),f(e.alert.properties.category),w(e.alert.properties.issuer),b(e.alert.properties.severity),u(new Date(e.alert.create_date)),J((0,Y.e9)(e.alert.properties.description,e.userMap)))):(X.current?.close(),J(eF.EditorState.createEmpty()))},[a.showIssueAlertWindow,e.alert]);let ee=()=>{t.current&&t.current.flyTo({center:[e.lon,e.lat],zoom:t.current.getZoom()>15?t.current.getZoom()+1:15,essential:!0,duration:eB.AD})},ea=(e,t)=>{if(!e)return void y.Ay.error(t||"Image analysis failed. Please try again.");F(e);let a="  Pulse Caption: "+e.caption+"\n\n"+(e.objects.length>0?"Detected Objects: "+e.objects.toString().replace(/,/g,", "):"No objects detected.")+"\n\n"+(e.ocr_text.length>0?"Detected Text: "+e.ocr_text.toString().replace(/,/g,", "):"No text detected.");(0,v.Ed)(a,10,J,G)};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(B,{isOpen:$.display,closeModal:()=>z({display:!1,url:""}),url:$.url}),(0,o.jsx)("input",{type:"checkbox",id:"alertsmodal",className:"modal-toggle"}),(0,o.jsx)("div",{className:"transition-opacity text-black rounded-lg duration-300 w-full mx-auto h-full",children:(0,o.jsxs)("form",{onSubmit:e=>Q(e),className:"rounded-lg flex flex-col gap-4 items-center justify-between h-full",children:[(0,o.jsxs)("div",{className:"flex flex-col justify-between gap-4 mx-auto items-center w-full",children:[(0,o.jsx)("input",{id:"alert-title-input",autoFocus:!0,onChange:e=>c(e.target.value),value:n,type:"text",required:!0,placeholder:"Title",className:"input w-full max-w-2xl backdrop-blur-sm bg-white/80 text-black border-black/10"}),(0,o.jsx)("div",{id:"description-container",className:"description-container",children:(0,o.jsxs)("div",{className:"description-input input w-full  bg-white text-black border-black/10 font-small flex justify-between",children:[q&&(0,o.jsx)(eP,{editorState:G,setEditorState:J,projectUsers:q,placeholder:T?"Analyzing image...":"Description",disabled:T}),(0,o.jsx)("div",{className:"tr-image-button-container",children:(0,o.jsx)("button",{id:"pulse-button",className:`tooltip whitespace-pre-line tooltip-left relative ${T?"image-analysis":""}`,onClick:()=>
10(0,v.qK)(N,ea,"analyze",T,I),"data-tip":(N&&"image"==(0,v.ti)(N.name)?"":"Upload an image file to use Pulse. \n")+"Pulse uses AI. Check for mistakes.",type:"button",children:(0,o.jsx)("img",{src:"/images/pulselogo.svg",alt:"Pulse Icon",className:"w-[30px]! h-[30px]!"})})})]})}),(0,o.jsx)("input",{id:"alert-category-input",onChange:e=>f(e.target.value),value:p,type:"text",placeholder:"Category",className:"input w-full max-w-2xl backdrop-blur-sm bg-white/80 text-black border-black/10"}),(0,o.jsx)("input",{type:"datetime-local",className:"input  w-full max-w-2xl backdrop-blur-sm bg-white/80 text-black border-black/10",value:(0,v.rm)(d),onChange:e=>{let t=new Date(e.target.value);isNaN(t.getTime())?console.error("Invalid date input"):u(t)}}),(0,o.jsx)("div",{style:{fontSize:"16px"},children:(0,o.jsx)("h1",{children:"Severity"})}),(0,o.jsx)(tm.A,{style:{paddingTop:"10px",paddingBottom:"40px",width:"88%"},min:1,max:5,step:1,marks:{1:"Observed",2:" ",3:"Near Urgent",4:" ",5:"Urgent"},value:g,onChange:e=>b(e)}),M&&(0,o.jsx)("input",{onChange:e=>w(e.target.value),value:j,type:"text",placeholder:"Issuer",className:"input w-full max-w-2xl backdrop-blur-sm bg-white/80 text-black border-black/10"}),!M&&(0,o.jsxs)(o.Fragment,{children:[N||U?(0,o.jsx)("div",{className:"file-uploader-metadata w-full",children:(0,o.jsxs)("div",{className:"file-uploader-metadata-text w-full flex justify-between items-center",children:[N&&("image"!=(0,v.ti)(N.name)?(0,o.jsx)("span",{title:N.name,children:N.name.length>50?N.name.slice(0,50)+"...":N.name}):(0,o.jsx)("div",{className:"uploaded-image-container",children:(0,o.jsx)("img",{src:O||"",onClick:()=>z({display:!0,url:O||""}),alt:N.name,className:"uploaded-image"})})),U&&(0,o.jsx)("div",{children:U.name.length>50?U.name.slice(0,50)+"...":U.name}),(0,o.jsx)(W.fUT,{className:"file-uploader-delete",onClick:()=>{S(null),V(null)}})]})}):(0,o.jsxs)("div",{className:"w-full",children:[(0,o.jsx)(eL.l,{handleChange:S,name:"file",classes:"file-uploader",children:(0,o.jsxs)("div",{id:"alert-file-uploader",className:"file-uploader-box",children:[(0,o.jsx)(W.v4w,{size:18,className:"flex opacity-50"}),(0,o.jsx)("span",{className:"opacity-50 mt-1",children:"Upload a picture, video, or file"}),(0,o.jsx)("span",{className:"opacity-50 text-xs",children:"Max: 2 GB"})]})}),(0,o.jsx)(eM.A,{modalHtml:"sharepoint-select-alerts-modal",onChange:V})]}),(0,o.jsx)("div",{className:"flex justify-between items-center w-full",children:(0,o.jsxs)("div",{className:"flex items-center gap-2 opacity-80",children:[(0,o.jsx)("input",{type:"checkbox",id:"useMyLocation",className:"checkbox",onChange:e=>_(e.target.checked),checked:k}),(0,o.jsx)("label",{htmlFor:"useMyLocation",children:"Use my location"})]})}),(0,o.jsx)("div",{className:"flex justify-between items-center w-full",children:(0,o.jsxs)("div",{className:"flex items-center gap-2 opacity-80",children:[(0,o.jsx)("input",{type:"checkbox",id:"notifyProjectAdmin",className:"checkbox",onChange:e=>L(e.target.checked),checked:C}),(0,o.jsx)("label",{htmlFor:"notifyProjectAdmin",children:"Notify Project Admin"})]})})]})]}),(0,o.jsx)("div",{className:"w-full pb-4 tablet:pb-0",children:l?(0,o.jsxs)("div",{className:"notes-uploading-progress",children:[(0,o.jsx)("div",{className:"notes-uploading-progress-bar",children:(0,o.jsx)("div",{className:"notes-uploading-progress-bar-elapsed",style:{width:`${D}%`}})}),(0,o.jsxs)("div",{className:"notes-uploading-progress-bar-text",children:[(0,o.jsx)("span",{className:"loading loading-spinner loading-xs"}),100===D?(0,o.jsx)("span",{children:"Processing"}):(0,o.jsxs)(o.Fragment,{children:["Uploading (",D,"%)"]})]})]}):(0,o.jsx)("button",{type:"submit",className:"btn btn-primary tt-blue-button mt-5 w-full",onClick:()=>{e.closePanel()},children:M?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(W.dJk,{size:20}),"Edit"]}):(0,o.jsx)(o.Fragment,{children:"Add"})})})]})})]})}a(88486);var tx=((r={}).Gradient="Gradient",r.Categories="Categories",r);let tf={Water:{legendType:"Gradient",thresholds:[-.8,-.6,-.4,0,.4,.6,.8],colors:["rgb(0, 128, 0)","rgb(58, 157, 58)","rgb(113, 184, 113)","rgb(183, 219, 183)","rgb(255,255,255)","rgb(196, 196, 243)","rgb(112, 112, 226)","rgb(56, 56, 215)","rgb(0, 0, 204)"],unitDescription:"Values above 0.5 often signify water bodies, while vegetation is indicated by lower negative values. Water built-up areas typically fall between 0 and 0.2."},Vegetation:{legendType:"Gradient",thresholds:[-1,-.5,0,.1,.2,.35,.5,.65,.8,.9,1],colors:["rgb(255, 255, 255)","rgb(153, 170, 187)","rgb(255, 255, 229)","rgb(247, 252, 185)","rgb(217, 240, 163)","rgb(173, 221, 142)","rgb(120, 198, 121)","rgb(65, 171, 93)","rgb(65, 171, 93)","rgb(0, 104, 55)","rgb(0, 69, 41)"],unitDescription:"Vegetation values range from -1 to 1. Negative values (close to -1) indicate water. Values near zero (-0.1 to 0.1) represent barren areas like rock, sand, or snow. Low positives (about 0.2 to 0.4) show shrub and grassland, while high values (near 1) mean temperate and tropical rainforests."},Weather:{legendType:"Gradient",thresholds:[-32,-20,-10,0,10,20,30,40,50,60,70,80,95],colors:["rgba(0, 0, 0, 0)","rgba(0, 0, 0, 0)","rgba(99, 97, 89, 0.07)","rgba(146, 136, 113, 0.53)","rgba(136, 221, 238, 1)","rgba(0, 119, 170, 1)","rgba(255, 238, 0, 1)","rgba(255, 119, 0, 1)","rgba(238, 0, 0, 1)","rgba(255, 170, 255, 1)","rgba(255, 68, 255, 1)","rgba(170, 0, 170, 1)","rgba(170, 0, 170, 1)"],unitDescription:"DBZ Values: Range from -32 to 95. In meteorology, dBZ refers to the strength of radar reflectivity, which is often used to estimate precipitation intensity."},"Land Temperature":{legendType:"Gradient",thresholds:[200,225,260,275,300],colors:["rgb(179, 34, 235)","rgb(61, 37, 255)","rgb(16, 242, 255)","rgb(255, 246, 0)","rgb(244, 6, 5)"],unitDescription:"Surface temperature is measured in Kelvin (K)"},"Brightness Temperature":{legendType:"Gradient",thresholds:[180,220,260,300,340],colors:["rgb(5, 9, 42)","rgb(34, 45, 117)","rgb(70, 66, 140)","rgb(126, 89, 150)","rgb(180, 118, 142)","rgb(223, 174, 159)","rgb(255, 242, 205)","rgb(255, 255, 252)"],unitDescription:"Brightness temperature is measured in Kelvin (K)"}
10,Ozone:{legendType:"Gradient",thresholds:[100,200,300,400,500],colors:["rgb(56, 142, 186)","rgb(131, 205, 164)","rgb(210, 237, 156)","rgb(251, 226, 140)","rgb(251, 166, 93)","rgb(236, 98, 70)","rgb(225, 81, 74)"],unitDescription:"The total ozone column is measured in Dobson Units (DU). A Dobson Unit (DU) is a unit of measurement used to quantify the total amount of ozone in a column of air above a specific point on the Earth's surface. It represents the thickness of ozone in a layer, if it were compressed to a standard pressure and temperature (0\xb0C and 1 atmosphere pressure)."},Methane:{legendType:"Gradient",thresholds:[1600,1700,1800,1900,2e3],colors:["rgb(226, 229, 210)","rgb(186, 232, 189)","rgb(168, 219, 144)","rgb(166, 202, 110)","rgb(188, 171, 85)","rgb(220, 134, 70)","rgb(225, 94, 78)","rgb(191, 58, 68)","rgb(127, 35, 53)","rgb(100, 35, 53)"],unitDescription:"Methane is measured in Parts per Billion by Volume (ppbv).  It's a unit of measurement used to express the concentration of a substance in a mixture, such as gases in the atmosphere. Specifically, it indicates the number of parts (or molecules) of a particular substance per billion parts (or molecules) of the total mixture volume."},"Carbon Monoxide":{legendType:"Gradient",thresholds:[0,70,140,210,280,350],colors:["rgb(255, 252, 215)","rgb(255, 252, 166)","rgb(254, 134, 78)","rgb(181, 38, 28)","rgb(151, 43, 192)","rgb(48, 5, 76)"],unitDescription:"Carbon Monoxide is measured in Parts per Billion by Volume (ppbv).  It's a unit of measurement used to express the concentration of a substance in a mixture, such as gases in the atmosphere. Specifically, it indicates the number of parts (or molecules) of a particular substance per billion parts (or molecules) of the total mixture volume."},"Scene Class":{legendType:"Categories",categories:["No Data","Saturated or Defective Pixels","Topographic Casted Shadows","Cloud Shadows","Vegetation","Not-Vegetated","Water","Unclassified","Cloud Medium Probability","Cloud High Probability","Thin Cirrus"," Snow or Ice"],colors:["rgb(0,0,0)","rgb(255,0,0)","rgb(47,47,47)","rgb(100,50,0)","rgb(0,160,0)","rgb(255,230,90)","rgb(0,0,255)","rgb(128,128,128)","rgb(192,192,192)","rgb(255,255,255)","rgb(100,200,255)","rgb(255,150,255)"],unitDescription:""},"Urban Class":{legendType:"Categories",categories:["Urban","Water","Barren","Vegetated"],colors:["rgb(255,255,255)","rgb(0, 128, 255)","rgb(128, 77, 0)","rgb(0, 51, 0)"],unitDescription:""},"Snow Cover":{legendType:"Gradient",thresholds:[0,20,40,60,80,100],colors:["rgb(255,255,255)","rgba(238,241,136,255)","rgba(238,212,135,255)","rgba(239,180,142,255)","rgba(238,152,139,255)","rgba(243,128,125,255)"],unitDescription:"Normalized Difference Snow Index"},"Flood 1-Day":{legendType:"Categories",categories:["No Water","Surface Water","Flood","Insufficient Data"],colors:["rgb(0,0,0)","rgba(46,212,246,255)","rgba(255,27,34,255)","rgba(176,176,176,255)"],unitDescription:"Flood status based on water detections over the selected compositing period."},"Flood 2-Day":{legendType:"Categories",categories:["No Water","Surface Water","Flood","Insufficient Data"],colors:["rgb(0,0,0)","rgba(46,212,246,255)","rgba(255,27,34,255)","rgba(176,176,176,255)"],unitDescription:"Flood status based on water detections over the selected compositing period."},"Flood 3-Day":{legendType:"Categories",categories:["No Water","Surface Water","Flood","Insufficient Data"],colors:["rgb(0,0,0)","rgba(46,212,246,255)","rgba(255,27,34,255)","rgba(176,176,176,255)"],unitDescription:"Flood status based on water detections over the selected compositing period."},"Precipitable Water (Deprecated as of 2025-09-01)":{legendType:"Gradient",thresholds:[0,20,40,60,75,100],colors:["rgba(94,166,212,255)","rgba(82,218,154,255)","rgba(125,232,52,255)","rgba(244,177,26,255)","rgba(227,12,18,255)","rgba(227,12,18,255)"],unitDescription:"Total atmospheric water vapor content, measured in millimeters (mm)."},"Water Vapor (Day)":{legendType:"Gradient",thresholds:[0,.18,.53,1.75,3.79,9.64],colors:["rgb(162,0,174)","rgb(17,24,233)","rgb(0,138,188)","rgb(249,241,0)","rgb(255,110,0)","rgb(180,0,0)"],unitDescription:"Total amount of water vapor in a 5 km by 5 km column of the atmosphere, measured in centimeters (cm)."},"Precipitation (Day)":{legendType:"Gradient",thresholds:[0,5,10,15,20,25,30],colors:["rgb(169, 174, 233)","rgb(63, 99, 254)","rgb(59, 169, 234)","rgb(43, 225, 91)","rgb(149, 232, 60)","rgb(254, 181, 63)","rgb(254, 38, 87)","rgb(254, 129, 199)","rgb(205, 155, 230)","rgb(168, 137, 201)","rgb(208, 208, 208)","rgb(225, 225, 225)","rgb(252, 252, 252)"],unitDescription:"Daily precipitation estimates over land in millimeters (mm)."},"Precipitation (Night)":{legendType:"Gradient",thresholds:[0,5,10,15,20,25,30],colors:["rgb(169, 174, 233)","rgb(63, 99, 254)","rgb(59, 169, 234)","rgb(43, 225, 91)","rgb(149, 232, 60)","rgb(254, 181, 63)","rgb(254, 38, 87)","rgb(254, 129, 199)","rgb(205, 155, 230)","rgb(168, 137, 201)","rgb(208, 208, 208)","rgb(225, 225, 225)","rgb(252, 252, 252)"],unitDescription:"Nightly precipitation estimates over land in millimeters (mm)."},"Population 2020":{legendType:"Gradient",thresholds:[0,5,25,250,500,1e3],colors:["rgba(254,243,215,255)","rgba(252,219,168,255)","rgba(251,178,83,255)","rgba(247,104,52,25
105)","rgba(239,60,30,255)","rgba(237,61,30,255)","rgba(134,21,43,255)"],unitDescription:"Estimated population density in persons per square kilometer (2020)."}};function tg(e,t){if(!t)return 0;let a=e.match(/\d+/g),r=a?a.map(Number):null,s=t.map(e=>{let t=e.match(/\d+/g);return t?t.map(Number):null});if(!r||s.some(e=>!e))throw Error("Invalid RGB format");let l=s.map(e=>Math.sqrt(Math.pow(e[0]-r[0],2)+Math.pow(e[1]-r[1],2)+Math.pow(e[2]-r[2],2))),i=l.map((e,t)=>[e,t]).sort(function(e,t){return e[0]-t[0]})[0][1],n=0,o=i-1<0,c=i+1>s.length-1;n=o&&c?i:o?i+1:c||l[i-1]<l[i+1]?i-1:i+1;let d=l[i],u=l[n],p=(d+u)*(s.length-1),m=Math.abs(1/(s.length-1)),h=Math.min(i,n);return 100*(h*m+(h===i?d:u)/p)}let ty={left:{gradientPosition:"desktop:left-[35px] left-[35px]",categoriesPosition:"left-[35px]",tooltipSide:"tooltip-right"},right:{gradientPosition:"desktop:right-[-94px] right-[-104px]",categoriesPosition:"right-[66px]",tooltipSide:"tooltip-left"}},tb=({legend:e,mapRef:t,side:a})=>{let[r,s]=(0,h.useState)(50),[l,i]=(0,h.useState)(0);if((0,h.useEffect)(()=>{if(!t.current||e?.legendType!=="Gradient")return;let a=t.current.getCanvas(),r=a.getContext("webgl")||a.getContext("webgl2"),l=t=>{if(!r)return;let{x:l,y:i}=t.point,n=new Uint8Array(4),o=l-a.offsetLeft,c=a.height-i-a.offsetTop;r.readPixels(o,c,1,1,r.RGBA,r.UNSIGNED_BYTE,n);let[d,u,p]=n;s(Math.round(tg(`rgb(${d},${u},${p})`,e.colors)))},i=t.current;return i.on("mousemove",l),()=>{i.off("mousemove",l)}},[e?.legendType,e?.colors,e?.thresholds,t,l]),(0,h.useEffect)(()=>{if(t.current){if(t.current.isStyleLoaded())return void i(e=>e+1);let e=()=>{i(e=>e+1)};return t.current.on("load",e),()=>{t.current?.off("load",e)}}let e=globalThis.setTimeout(()=>{i(e=>e+1)},200);return()=>{globalThis.clearTimeout(e)}},[t]),!e)return null;let{gradientPosition:n,categoriesPosition:c,tooltipSide:d}=ty[a];return(0,o.jsxs)(o.Fragment,{children:[e.legendType===tx.Gradient&&(0,o.jsx)("div",{className:"flex justify-center",children:(0,o.jsxs)("div",{className:`absolute gradient-bar w-[280px] bottom-[368px] ${n} border-none`,style:{transformOrigin:"bottom center"},children:[(0,o.jsx)("div",{className:`gradient tooltip ${d}`,"data-tip":e.unitDescription,style:{backgroundImage:`linear-gradient(to top, ${e.colors.join(", ")})`,height:"273px",width:"20px"},children:(0,o.jsx)("label",{className:"font-bold text-black text-shadow-white",style:{left:`${r}%`}})}),(0,o.jsx)("div",{className:"ticks",children:e.thresholds.slice().reverse().map((t,a)=>(0,o.jsx)("div",{className:"tick text-black text-shadow-white left-[-13px] text-right",style:{bottom:`${-a*(273/(e.thresholds.length-.8))+5}px`,fontWeight:"bold"},children:t},a))})]})}),e.legendType===tx.Categories&&(0,o.jsx)("div",{className:`absolute z-30 bottom-[110px] ${c} flex justify-center`,children:(0,o.jsx)("ul",{className:"flex flex-col gap-0.5",children:e.categories.map((t,a)=>(0,o.jsx)("li",{className:"flex justify-center",style:{flexShrink:0},children:(0,o.jsx)("div",{className:`w-5 h-5 border border-black tooltip ${d}`,"data-tip":t,style:{backgroundColor:e.colors[a]}})},a))})})]})},tj=()=>{let e=(0,eG.JY)(),t=(0,eV.H)(),a=t.premiumLayer?.layer,r=t.premiumLayer?.selected;if(!a||!r)return null;let s=t.premiumLayerAddedToMap,l=e.splitViewEnabled?t.altPremiumLayerAddedToMap:t.premiumLayerAddedToMap,i=t.altPremiumLayer.selected?t.altPremiumLayer.layer:a,n=a&&s?tf[a.layerName]:null,c=i&&l?tf[i.layerName]:null,d=!!(n||c);return(!e.splitViewEnabled||d)&&(e.splitViewEnabled||n)?(0,o.jsx)("div",{className:"z-30",children:e.splitViewEnabled?(0,o.jsxs)(o.Fragment,{children:[n&&(0,o.jsx)(tb,{legend:n,mapRef:e.map,side:"left"}),c&&(0,o.jsx)(tb,{legend:c,mapRef:e.altMap,side:"right"})]}):(0,o.jsx)(tb,{legend:n,mapRef:e.map,side:"right"})}):null};var tw=a(57294);a(57512),a(58258);let tv="#5781ff",tN=x.kQ.Driving,tS=x.My.Distance,tk=[{value:x.kQ.Driving,label:"Driving",icon:(0,o.jsx)(e0.Y4E,{size:30})},{value:x.kQ.DrivingTraffic,label:"Driving (Traffic)",icon:(0,o.jsx)(e0.zmV,{size:30})},{value:x.kQ.Walking,label:"Walking",icon:(0,o.jsx)(e0.$yU,{size:30})},{value:x.kQ.Cycling,label:"Cycling",icon:(0,o.jsx)($.p8Z,{size:30})}];async function t_(e,t,a,r){await (0,_.x)("/isochrone",{method:"POST",json:{projectId:e,isochroneName:t,isochroneConfig:a,rangeArray:r.map(({value:e,color:t})=>({value:Number.parseInt(e,10),color:t}))}})}function tC(e,t="Metric"){return e===x.My.Time?60:t===x.WU.Metric?1e5:328083}let tL=e=>{let{setTransportationMethod:t,transportationMethod:a}=e;return(0,o.jsxs)("div",{className:"mt-4 w-full",children:[(0,o.jsx)("span",{className:"label-text",children:"Transportation method"}),(0,o.jsx)("div",{className:"flex gap-2 mt-1 w-full",children:tk.map(e=>(0,o.jsxs)("button",{type:"button",onClick:a=>{t(e.value),a.currentTarget.blur()},className:`btn bg-white h-28 flex-1 flex-col min-w-0 items-center justify-start border-2 rounded-lg focus:outline-none focus:ring-0 focus:shadow-none ${a===e.value?"border-tt-blue/60 text-black":"border-gray-200 text-gray-400"}`,children:[(0,o.jsx)("div",{className:"flex-shrink-0 mb-2 pt-5",children:e.icon}),(0,o.jsx)("span",{className:"text-xs text-center break-words leading-tight px-1",children:e.label})]},e.value))})]})};var tD=a(70103);let tA=e=>{let{setRangeType:t,setRangeArray:a,rangeType:r,setRangeErrorsById:s,setRangeGroupError:l}=e,i=(0,ev.O)(),n=i.project?.units;return(0,o.jsxs)("div",{className:"mt-4 ",children:[(0,o.jsx)("span",{className:"label-text",children:"Area Type"}),(0,o.jsxs)("div",{className:"w-full max-w-2xl grid grid-cols-2 gap-2",children:[(0,o.jsxs)("button",{type:"button",onClick:e=>{e.currentTarget.blur(),t(x.My.Distance),a([{id:crypto.randomUUID(),value:"",color:tv}]),l(""),s({})},className:`btn btn-sm h-24 flex flex-col items-center justify-center border-2 rounded-lg btn-outline focus:outline-none
11                            ${r===x.My.Distance?"border-tt-blue/60 text-black":"border-gray-200 text-gray-400"}`,children:[(0,o.jsx)(tD.kAR,{className:"w-8 h-8"}),(0,o.jsxs)("span",{className:"text-sm text-center",children:["Distance ",n===x.WU.Metric?"(m)":"(ft)"]})]}),(0,o.jsxs)("button",{type:"button",onClick:e=>{e.currentTarget.blur(),t(x.My.Time),a([{id:crypto.randomUUID(),value:"",color:tv}]),l(""),s({})},className:`btn btn-sm h-24 flex flex-col items-center justify-center border-2 rounded-lg btn-outline focus:outline-none
12            ${r===x.My.Time?"border-tt-blue/60 text-black":"border-gray-200 text-gray-400"}`,children:[(0,o.jsx)(eu.aJp,{className:"w-8 h-8"}),(0,o.jsx)("span",{className:"text-sm text-center",children:"Time (min)"})]})]})]})},tM=({idx:e,rangeType:t,setRangeArray:a,onDelete:r,onErrorChange:s,setRangeGroupError:l})=>{let[i,n]=(0,h.useState)(""),[c,d]=(0,h.useState)(""),[u,p]=(0,h.useState)("#5781ff"),m=(0,ev.O)(),f=m.project?.units;function g(r){if(n(r),l(""),a(t=>{let a=[...t];return a[e]={...a[e],value:r},a}),!/^\d+$/.test(r))return void d("Can only contain numbers");let s=Number(r),i=tC(t,f);
12s>i?d(`Value must be less than ${i.toLocaleString()}`):d("")}return(0,h.useEffect)(()=>{n(""),d("")},[t]),(0,h.useEffect)(()=>{s(!!c)},[c,s]),(0,o.jsx)("div",{className:"pt-2",children:(0,o.jsxs)("div",{className:"relative w-full max-w-2xl border border-gray-200 shadow-xs bg-black/2 rounded-lg p-4",children:[(0,o.jsx)("button",{type:"button",onClick:r,className:"absolute top-2 right-2 text-gray-400 hover:text-red-500",children:"✕"}),(0,o.jsx)("div",{className:"w-full max-w-2xl mt-2",children:(0,o.jsx)("input",{type:"range",className:"range range-xs",value:i||0,onChange:e=>g(String(e.target.value)),min:0,max:tC(t,f),step:t===x.My.Distance?100:1})}),(0,o.jsxs)("div",{className:"flex items-center gap-2 mt-2 w-full join",children:[(0,o.jsx)(tr,{handleChangeColor:t=>{let r;p(r=t.target.value),a(t=>{let a=[...t];return a[e]={...a[e],color:r},a})},color:u,label:"",className:"w-10 h-10"},e),(0,o.jsxs)("div",{className:"relative w-full max-w-xs",children:[(0,o.jsx)("input",{type:"number",className:"input input-sm input-bordered w-full pl-3 pr-12 text-right\n                        [appearance:textfield]\n                        [&::-webkit-inner-spin-button]:appearance-none\n                        [&::-webkit-outer-spin-button]:appearance-none",value:i,onChange:e=>g(e.target.value),placeholder:"0"}),(0,o.jsx)("span",{className:"absolute inset-y-0 right-3 flex items-center text-sm select-none pointer-events-none z-100 text-gray-400",children:function(e,t="Metric"){return e===x.My.Time?"min":t===x.WU.Metric?"m":"ft"}(t,f)})]})]}),""!==c&&(0,o.jsx)("div",{className:"text-red-500 text-xs mt-1 font-medium",children:c})]})})},tE=e=>{let{rangeArray:t,rangeType:a,setRangeArray:r,removeRange:s,addNewRange:l,onRangeErrorChange:i,setRangeGroupError:n}=e;return(0,o.jsxs)("div",{className:"mt-4",children:[(0,o.jsx)("span",{className:"label-text",children:"Range(s)"}),(0,o.jsx)("div",{className:"",children:t.map((e,t)=>(0,o.jsx)(tM,{idx:t,rangeType:a,setRangeArray:r,onDelete:()=>s(t),onErrorChange:t=>i(e.id,t),setRangeGroupError:n},e.id))}),(0,o.jsx)("div",{className:"w-full mt-4 flex justify-center",children:t.length<4&&(0,o.jsxs)("button",{type:"button",className:"btn btn-sm join-item",onClick:()=>l(),children:[(0,o.jsx)(W.QCG,{size:18})," Additional Range"]})})]})};function tT(e){let{lat:t,lon:a,closePanel:r}=e,[s,l]=(0,h.useState)(""),[i,n]=(0,h.useState)(tS),[c,d]=(0,h.useState)([{id:crypto.randomUUID(),value:"",color:tv}]),[u,p]=(0,h.useState)(tN),[m,x]=(0,h.useState)(""),[f,g]=(0,h.useState)(!1),[y,b]=(0,h.useState)({}),{uploadIsochrone:j}=function(e){let{rangeArray:t,setRangeArray:a,lon:r,lat:s,rangeType:l,setRangeType:i,transportationMethod:n,setTransportationMethod:o,setRangeGroupError:c,setSubmitLoading:d,isochroneName:u,setIsochroneName:p,closePanel:m}=e,h=(0,eG.JY)(),x=(0,ev.O)(),f=h.map,g=x.project?.project_uuid,y=x.project?.units;return{uploadIsochrone:async function e(e){if(e.preventDefault(),g&&y){d(!0);try{let e=function(e,t,a){let r;return e.length<1?"Needs a range value.":(r=e.map(e=>Number.parseInt(e.value)),new Set(r).size!==r.length)?"Cannot have duplicate range values.":e.every(e=>""!==e.value&&0!==Number(e.value))?e.every(e=>Number(e.value)<=tC(t,a))?null:`Ranges are larger than limit: ${tC(t,a).toLocaleString()}.`:"Cannot have 0 as a range value."}(t,l,y);if(e){c(e),d(!1);return}await t_(g,u,{transportationMethod:n,rangeType:l,mapLocation:{lat:s,lon:r},units:y},t);try{await M(f,g)}catch(e){console.error(e)}p(""),a([]),i(tS),o(tN),c(""),d(!1),m()}catch(e){e instanceof Error?c(e.message):c("Failed to create an isochrone."),d(!1)}}}}}({rangeArray:c,setRangeArray:d,lon:a,lat:t,rangeType:i,setRangeType:n,transportationMethod:u,setTransportationMethod:p,setRangeGroupError:x,setSubmitLoading:g,isochroneName:s,setIsochroneName:l,closePanel:r}),[w,v]=(0,h.useState)("");return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("input",{type:"checkbox",id:"isochronemodal",className:"modal-toggle"}),(0,o.jsx)("h3",{className:"text-lg font-bold flex items-center"}),(0,o.jsx)("div",{className:"transition-opacity text-black rounded-lg duration-300 w-full mx-auto h-full",children:(0,o.jsxs)("form",{onSubmit:e=>j(e),className:"rounded-lg flex flex-col justify-between h-full",children:[(0,o.jsxs)("div",{children:[(0,o.jsxs)("div",{className:"w-full max-w-2xl",children:[(0,o.jsxs)("span",{className:"label-text",children:["Range name ",(0,o.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,o.jsx)("input",{type:"text",required:!0,placeholder:"Name",className:"input w-full backdrop-blur-sm bg-white/80 text-black border-black/10 mt-1",value:s,onChange:e=>{var t;l(t=e.target.value),x(""),""===t.trim()||Number.isNaN(Number(t))?v(""):v("Name cannot be a number")}}),w&&(0,o.jsx)("div",{className:"text-red-500 text-sm mt-1 font-medium",children:w})]}),(0,o.jsx)(tL,{setTransportationMethod:p,transportationMethod:u}),(0,o.jsx)(tA,{setRangeArray:d,setRangeType:n,rangeType:i,setRangeErrorsById:b,setRangeGroupError:x}),(0,o.jsx)(tE,{setRangeArray:d,rangeArray:c,rangeType:i,addNewRange:function(){d(e=>[...e,{id:crypto.randomUUID(),value:"",color:tv}])},removeRange:function(e){var t;let a=c[e]?.id;a&&(t=a,b(e=>{if(!(t in e))return e;let a={...e};return delete a[t],a})),d(t=>t.filter((t,a)=>a!==e))},onRangeErrorChange:function(e,t){b(a=>a[e]===t?a:{...a,[e]:t})},setRangeGroupError:x}),""!==m&&(0,o.jsx)("div",{className:"bg-red-50 border-l-4 border-red-400 p-3 mt-4 rounded-r-md",children:(0,o.jsxs)("div",{className:"flex",children:[(0,o.jsx)("div",{className:"flex-shrink-0",children:(0,o.jsx)("svg",{className:"h-5 w-5 text-red-500",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),(0,o.jsx)("div",{className:"ml-3",children:(0,o.jsx)("p",{className:"text-sm text-red-500",children:m})})]})})]}),(0,o.jsx)("div",{className:"pb-4 tablet:pb-0",children:(0,o.jsx)("button",{type:"submit",className:"btn btn-primary tt-blue-button mt-7 w-full disabled:opacity-50 disabled:cursor-not-allowed rounded-lg",disabled:""===s||""!==w||0===c.length||""!==m||Object.values(y).some(Boolean),children:f?(0,o.jsx)("span",{className:"loading loading-spinner loading-md"}):(0,o.jsx)(o.Fragment,{children:"Add"})})})]})})]})}let tI=()=>(0,o.jsx)("div",{className:"w-px shrink-0 h-4 bg-gray-200/90","aria-hidden":!0});function tP({isElevationLoading:e,elevationValue:t,elevationUnit:a,buttonClassName:r,iconSize:s,onCopy:l}){return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(tI,{}),(0,o.jsx)("div",{className:"flex items-center shrink-0",children:(0,o.jsx)("button",{className:`${r} ${e?"opacity-50":""}`,onClick:()=>l(`${t} ${a}`),disabled:e,title:"Elevation",children:e?(0,o.jsx)(eh.PSR,{size:s,className:"shrink-0 animate-spin"}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(z.dI1,{size:s,className:"shrink-0"}),(0,o.jsxs)("span",{className:"min-w-0 truncate",children:[t?.toFixed(2)," ",a]})]})})})]})}
12function tF(e){let{coords:t,elevation:a,isElevationLoading:r=!1,currentLRS:s,isLRSLoading:l=!1,premiumLayerDisplay:i,onCopy:n,isMobile:c}=e,d=(0,ev.O)(),u=d.project?.units===x.WU.Imperial,p=null;null!==a&&Number.isFinite(a)&&(p=u?a*eB.oc:a);let m=c?18:14,h=`cursor-pointer flex items-center w-full py-0.5 text-left !outline-none ${c?"gap-2":"gap-1"}`,f=t&&"number"==typeof t.lat&&"number"==typeof t.lon,g=(0,o.jsx)("button",{className:h,onClick:()=>n(i),children:(0,o.jsxs)("div",{className:`flex min-w-0 items-center ${c?"gap-2":"gap-1"}`,children:[(0,o.jsx)(W.gP6,{size:m,className:"shrink-0"}),(0,o.jsx)("span",{className:"truncate inline-block",children:i})]})});return(0,o.jsxs)("div",{className:`flex flex-col items-start gap-1 w-full text-tt-blue/80 ${c?"px-4":"text-[12px]"}`,children:[(0,o.jsxs)("div",{className:"flex flex-row items-center w-full gap-x-2",children:[f&&t&&(0,o.jsx)("div",{className:"flex items-center shrink-0",children:(0,o.jsxs)("button",{className:h,onClick:()=>n(`${t.lat.toFixed(6)}, ${t.lon.toFixed(6)}`),children:[(0,o.jsx)($.cJR,{size:m,className:"shrink-0"}),(0,o.jsxs)("span",{className:"min-w-0 truncate",children:[t.lat.toFixed(6),", ",t.lon.toFixed(6)]})]})}),(null!==p||r)&&(0,o.jsx)(tP,{isElevationLoading:r,elevationValue:p,elevationUnit:u?"ft":"m",buttonClassName:h,iconSize:m,onCopy:n}),s&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(tI,{}),(0,o.jsx)("div",{className:"flex items-center min-w-0 flex-1",children:(0,o.jsxs)("button",{id:c?void 0:"current-lrs",className:`${h} ${l?"opacity-50":""}`,onClick:()=>n(`${s.route} ${s.chainage}`),disabled:l,title:"LRS",children:[l?(0,o.jsx)(eh.PSR,{size:m,className:"shrink-0 animate-spin"}):(0,o.jsx)(z.pk7,{size:m,className:"shrink-0"}),(0,o.jsx)("span",{className:"truncate inline-block",children:s.route}),(0,o.jsx)("span",{className:"shrink-0",children:s.chainage})]})})]})]}),i&&(0,o.jsx)("div",{className:"flex flex-row items-center justify-start w-full gap-x-2",children:g})]})}function tO(e){let t=(0,ej.H)(),a=(0,ev.O)(),r=(0,eN.D)(),{toggleSidePanel:s,closePanel:l}=(0,e$.p)(),{premiumLayerDisplay:i}=function({map:e,altMap:t,premiumLayer:a}){let[r,s]=(0,h.useState)(50),[l,i]=(0,h.useState)(""),n=null!==a&&tf[a.layerName]?.legendType==tx.Gradient,o=null!==a&&tf[a.layerName]?.legendType==tx.Categories,c=null!==a&&n&&tf[a.layerName]?.thresholds.length,d=a&&n&&tf[a.layerName]?.thresholds[0],u=a&&n&&tf[a.layerName]?.thresholds[c-1],p=a?tf[a.layerName]:null,m=(()=>{if(!a||!p)return null;if(p.legendType===tx.Gradient&&n){let e=(.01*r*(u-d)+d).toFixed(2);return`${a.layerName}: ${e}`}return p.legendType===tx.Categories&&o?`${a.layerName}: ${l}`:null})(),x=(e,t)=>{if(!e)return;let r=r=>{if(!e)return;let l=e.getCanvas(),n=l.getContext("webgl")||l.getContext("webgl2");if(!n||!a)return;let{point:{x:o,y:c}}=r,d=new Uint8Array(4),u=o-l.offsetLeft,p=l.height-c-l.offsetTop;n.readPixels(u,p,1,1,n.RGBA,n.UNSIGNED_BYTE,d);let[m,h,x]=d;t===tx.Gradient?s(Math.round(tg(`rgb(${m},${h},${x})`,tf[a.layerName]?.colors))):i(((e,t,a)=>{let r=e.match(/\d+/g),s=r?r.map(Number):null,l=a.map(e=>{let t=e.match(/\d+/g);return t?t.map(Number):null});if(!s||l.some(e=>!e))throw Error("Invalid RGB format");return t[l.map(e=>Math.sqrt(Math.pow(e[0]-s[0],2)+Math.pow(e[1]-s[1],2)+Math.pow(e[2]-s[2],2))).map((e,t)=>[e,t]).sort(function(e,t){return e[0]-t[0]})[0][1]]})(`rgb(${m},${h},${x})`,tf[a.layerName].categories,tf[a.layerName].colors))};return e.on("click",r),()=>{e.off("click",r)}};return(0,h.useEffect)(()=>{let a=[];if(n&&e){let t=x(e,tx.Gradient);t&&a.push(t)}if(t){let e=x(t,tx.Gradient);e&&a.push(e)}if(o&&e){let t=x(e,tx.Categories);t&&a.push(t)}return()=>{a.forEach(e=>e())}},[e,t,a]),{premiumLayerDisplay:m}}({map:e.map,altMap:e.altMap,premiumLayer:e.premiumLayer}),[n,c]=(0,h.useState)("N/A"),[d,u]=(0,h.useState)("N/A"),[p,f]=(0,h.useState)({lon:0,lat:0}),[g,b]=(0,h.useState)(null),[j,w]=(0,h.useState)(!1),[N,S]=(0,h.useState)(null),[k,_]=(0,h.useState)(!1),[C,L]=(0,h.useState)(!1),[D,A]=(0,h.useState)(!1),M=(0,h.useRef)(null);function E(){t.setBottomMenuOpen({open:!1,id:0,event:null})}let T=e=>{navigator.clipboard.writeText(e),y.Ay.success("Copied to clipboard")},I=()=>
12{let e="https://www.google.com/maps?saddr=My+Location&daddr="+M.current.lat+","+M.current.lon;(0,e_.KR)()?(0,e_.tL)(e,"map"):window.open(e,"_blank"),y.Ay.success("Opening Google Maps for navigation")},P=()=>{let e="https://maps.google.com/maps?q=&layer=c&cbll="+M.current.lat+","+M.current.lon;(0,e_.KR)()?(0,e_.tL)(e,"map"):window.open(e,"_blank"),y.Ay.success("Opening Google Maps for navigation")};return(0,h.useEffect)(()=>{D&&(A(!1),s((0,o.jsx)(tT,{isOpen:D,lat:M.current.lat,lon:M.current.lon,closePanel:l}),{title:"Range",key:"range"}))},[D]),(0,h.useEffect)(()=>{if(!t.isBottomMenuOpen.open||!e.map)return;let r=e.map,s=!1;return M.current={lat:e.clickedPositionCoords.lat,lon:e.clickedPositionCoords.lon},e.useLRS?_(!0):(_(!1),S(null)),e.gisLayer?r.queryRenderedFeatures(t.isBottomMenuOpen.event.point).some(t=>{if(t.layer.id===e.gisLayer)return L(!0),!0;L(!1)}):L(!1),(async()=>{try{f({lon:M.current.lon,lat:M.current.lat}),b(null),w(!0);let t=`https://api.mapbox.com/geocoding/v5/mapbox.places/${M.current.lon},${M.current.lat}.json?access_token=${m.Et}`,[r,l]=await Promise.all([fetch(t).then(e=>e.json()).catch(e=>(console.error("Error fetching location info:",e),null)),(0,tw.IM)([M.current.lon,M.current.lat]).catch(e=>(console.error("Error fetching terrain elevation:",e),null))]);if(s)return;if(b(l),w(!1),r?.features?.[0]){let e=r.features[0].place_name.split(", ");c(e[0]),u(e.slice(1).join(", "))}if(e.useLRS){if(!a.project)return;try{let e=await O(a.project.project_uuid,M.current.lat,M.current.lon);S(e?{route:e.route,chainage:e.chainage.toFixed(3)}:null)}catch(e){S(null),console.error(e)}}}catch(e){console.error("Error fetching data:",e),b(null),w(!1)}finally{_(!1)}})(),()=>{s=!0}},[t.isBottomMenuOpen.id,t.isBottomMenuOpen.event,e.useLRS,e.clickedPositionCoords]),(0,o.jsx)(o.Fragment,{children:(0,v.Fr)()?(0,o.jsx)(ta.X,{blocking:!1,onDismiss:E,className:"text-black z-50 bottommenu absolute text-[13px]",style:{zIndex:5e6},expandOnContentDrag:!0,open:t.isBottomMenuOpen.open&&!e.showEditModelMenu,children:(0,o.jsxs)("div",{className:"pb-3",children:[(0,o.jsxs)("div",{className:"cursor-pointer flex gap-3 items-center px-4",onClick:()=>T(n+" "+d),children:[(0,o.jsx)("img",{src:"/images/nearby.png",alt:"Location",width:18}),(0,o.jsxs)("div",{className:"flex flex-col",children:[(0,o.jsx)("span",{className:"font-bold",children:n}),(0,o.jsx)("span",{className:"opacity-70",children:d})]})]}),(0,o.jsx)("div",{className:"my-3 w-full h-px bg-gray-100/50 px-4 flex"}),(0,o.jsxs)("div",{className:"gap-[6px] flex overflow-auto mobile-bottom-menu-cont pl-4 pb-px",children:[a.project?.data_types?.includes("lidar")&&r.availableLidars&&r.availableLidars.length>0&&(0,o.jsxs)("div",{className:"bottomsheet-btn",onClick:()=>e.showLidar(r.availableLidars),children:[(0,o.jsx)(W.SqY,{})," View Pointclouds"]}),C&&(0,o.jsxs)("div",{className:"bottomsheet-btn",onClick:()=>e.searchAsset(),children:[(0,o.jsx)($.iyI,{})," Search here"]}),(0,o.jsxs)("div",{className:"bottomsheet-btn",onClick:()=>{t.setBottomMenuOpen({open:!1,id:0,event:null}),e.addNote(x.md.DEFAULT)},children:[(0,o.jsx)(W.R7b,{})," Note"]}),(0,o.jsxs)("div",{className:"bottomsheet-btn",onClick:()=>{t.setBottomMenuOpen({open:!1,id:0,event:null}),e.issueAlert()},children:[(0,o.jsx)(W.PAG,{})," Alert"]}),!(0,v.KV)()&&(0,o.jsxs)("div",{className:"bottomsheet-btn",onClick:()=>{t.setBottomMenuOpen({open:!1,id:0,event:null}),e.setShowIfcModal()},children:[(0,o.jsx)(ep.cSY,{})," IFC"]}),(0,o.jsxs)("div",{className:"bottomsheet-btn",onClick:()=>{t.setBottomMenuOpen({open:!1,id:0,event:null}),I()},children:[(0,o.jsx)(z.amt,{})," Navigate"]}),(0,o.jsxs)("div",{className:"bottomsheet-btn w-[105px]!",onClick:()=>{t.setBottomMenuOpen({open:!1,id:0,event:null}),P()},children:[(0,o.jsx)($.wDG,{})," Street View"]}),(0,o.jsxs)("div",{className:"bottomsheet-btn",onClick:()=>{t.setBottomMenuOpen({open:!1,id:0,event:null}),A(!0)},children:[(0,o.jsx)(e0.Y4E,{})," Range"]})]}),(0,o.jsx)("div",{className:"my-3 w-full h-px bg-gray-100/50 px-4"}),(0,o.jsx)(tF,{coords:"number"==typeof p.lat&&"number"==typeof p.lon?p:null,elevation:g,isElevationLoading:j,currentLRS:N,isLRSLoading:e.useLRS&&k,premiumLayerDisplay:i,onCopy:T,isMobile:!0})]})}):(0,o.jsx)(o.Fragment,{children:!e.showEditModelMenu&&t.isBottomMenuOpen.open&&(0,o.jsx)("div",{className:((0,v.KV)()?"bottom-modal-disabled":"bottom-modal")+" sliding-div w-[520px] relative",children:(0,o.jsxs)("div",{className:"px-4 pt-3 pb-2.5 w-full",children:[(0,o.jsxs)("div",{className:"flex justify-between",children:[(0,o.jsxs)("div",{onClick:()=>T(n+" "+d),className:"cursor-pointer flex items-center gap-3 pr-14",children:[(0,o.jsx)("img",{src:"/images/nearby.png",alt:"Location",width:18}),(0,o.jsxs)("div",{className:"flex flex-col",children:[(0,o.jsx)("span",{className:"font-bold text-[12px]",children:n}),(0,o.jsx)("span",{className:"opacity-70 text-[11px]",children:d})]})]}),(0,o.jsxs)("div",{className:"absolute top-2 right-2 flex items-center",children:[(0,o.jsxs)("details",{className:"dropdown fm-dropdown dropdown-close-outside",children:[(0,o.jsx)("summary",{"aria-label":"More options",title:"Show more options",className:"opacity-50 cursor-pointer h-7 w-7 flex items-center justify-center rounded hover:bg-black/5 list-none [&::-webkit-details-marker]:hidden",children:(0,o.jsx)(z.a95,{size:18})}),(0,o.jsxs)("ul",{className:"menu dropdown-content mt-1 p-1 shadow bg-base-100 rounded-box w-44 z-[6000]",children:[(0,o.jsx)("li",{children:(0,o.jsxs)("button",{type:"button",onClick:()=>{t.setBottomMenuOpen({open:!1,id:0,event:null}),I()},children:[(0,o.jsx)(z.amt,{})," Navigate"]})}),(0,o.jsx)("li",{children:(0,o.jsxs)("button",{type:"button",onClick:()=>{t.setBottomMenuOpen({open:!1,id:0,event:null}),P()},children:[(0,o.jsx)($.wDG,{})," Street View"]})})]})]}),(0,o.jsx)("button",{type:"button",className:"opacity-50 cursor-pointer h-7 w-7 flex items-center justify-center rounded hover:bg-black/5",onClick:E,"aria-label":"Close bottom panel",title:"Close",children:(0,o.jsx)(W.fUT,{})})]})]}),(0,o.jsx)("div",{className:"my-2 w-full h-px bg-gray-100/70"}),(0,o.jsxs)("div",{className:"gap-[6px] flex flex-wrap",children:[a.project?.data_types?.includes("lidar")&&r.availableLidars&&r.availableLidars.length>0&&(0,o.jsxs)("div",{className:"bottomsheet-btn-sm no-shrink",onClick:()=>e.showLidar(r.availableLidars),children:[(0,o.jsx)(W.SqY,{})," View Pointclouds"]}),C&&(0,o.jsxs)("div",{className:"bottomsheet-btn-sm",onClick:()=>e.searchAsset(),children:[(0,o.jsx)($.iyI,{})," Search here"]}),(0,o.jsxs)("div",{className:"bottomsheet-btn-sm",onClick:()=>{t.setBottomMenuOpen({open:!1,id:0,event:null}),e.addNote(x.md.DEFAULT)}
12,"data-testid":"bottom-menu-create-note-btn",children:[(0,o.jsx)(W.R7b,{})," Note"]}),(0,o.jsxs)("div",{className:"bottomsheet-btn-sm",onClick:()=>{t.setBottomMenuOpen({open:!1,id:0,event:null}),e.issueAlert()},"data-testid":"alert-bottomsheet-btn",children:[(0,o.jsx)(W.PAG,{size:12})," Alert"]}),!(0,v.KV)()&&(0,o.jsxs)("div",{className:"bottomsheet-btn",onClick:()=>{t.setBottomMenuOpen({open:!1,id:0,event:null}),e.setShowIfcModal()},children:[(0,o.jsx)(ep.cSY,{})," IFC"]}),(0,o.jsxs)("div",{className:"bottomsheet-btn",onClick:()=>{t.setBottomMenuOpen({open:!1,id:0,event:null}),A(!0)},children:[(0,o.jsx)(e0.Y4E,{})," Range"]})]}),(0,o.jsx)("div",{className:"my-2 w-full h-px bg-gray-100/70"}),(0,o.jsx)(tF,{coords:"number"==typeof p.lat&&"number"==typeof p.lon?p:null,elevation:g,isElevationLoading:j,currentLRS:N,isLRSLoading:e.useLRS&&k,premiumLayerDisplay:i,onCopy:T,isMobile:!1})]})})})})}var tR=a(31134),t$=a(81047);let tz=()=>({type:"FeatureCollection",features:[]});function tU(){let e=(0,ey.F)(),t=(0,ej.H)(),a=(0,eG.JY)(),r=(0,ex.u)(),s=(0,ev.O)(),[l,i]=(0,h.useState)(""),n="#000",[c,d]=(0,h.useState)(""),[u,p]=(0,h.useState)(!1),[m,x]=(0,h.useState)(!1),[f,g]=(0,h.useState)(0),[y,b]=(0,h.useState)(!1),[w,N]=(0,h.useState)(0),[S,_]=(0,h.useState)(0),[C,L]=(0,h.useState)(tz()),[D,A]=(0,h.useState)(tz()),[M,T]=(0,h.useState)({labels:[""],datasets:[{label:"F34/JP8",data:[200],borderColor:"rgb(37, 99, 235)",backgroundColor:"rgba(37, 99, 235, 0.5)"}]}),I=(0,h.useRef)(null),P=(0,h.useRef)(0),F=(0,h.useRef)([]),O=(0,h.useRef)([]),R=(0,h.useRef)(C);(0,h.useEffect)(()=>{T(M)},[D]);let $=(e,t)=>{if(t&&t.length>0){let e=t[0].index,r=O.current[e];r&&a.map.current&&(I.current?I.current.setLngLat(r):I.current=new(j()).Marker({}).setLngLat(r).addTo(a.map.current))}else I.current&&(I.current.remove(),I.current=null)},[z,U]=(0,h.useState)(),B=(0,h.useRef)(()=>{}),V=async e=>{let t=++P.current,{coordinates:a,distances:r}=e;x(!0);try{var l,i;let e,n,o,c={...D},d=Array(a.length),u=0,m=async()=>{for(;(0,tw.T8)(t,P.current)&&u<a.length;){let e=u;u+=1;let t=a[e],r=await Y(t[0],t[1]);d[e]={point:{type:"Feature",geometry:{type:"Point",coordinates:[t[0],t[1]]},properties:{elevation:r}},elevation:r}}};if(await Promise.all(Array.from({length:Math.min(16,a.length)},m)),!(0,tw.T8)(t,P.current))return;O.current=a,c.features=d.map(({point:e})=>e);let h=d.map(({elevation:e})=>e),x=h.filter(e=>null!==e);g(h.length-x.length),A(c),p(!0);let f=s.project?.units==="Imperial",y=f?eB.u_:eB.LV;U((l=f?"ft":"m",i=f?"mi":"km",e=x.length?Math.min(...x):0,n=x.length?Math.max(...x):0,o=e===n?.1*Math.abs(e)||1:0,{onHover:$,hover:{mode:"nearest",intersect:!0},responsive:!0,plugins:{legend:{display:!1},title:{display:!0,align:"start",text:"Elevation ("+l+")"},tooltip:{callbacks:{label:function(e){return e.formattedValue+" "+l},title:function(e){return e[0].label+" "+i}}}},maintainAspectRatio:!1,scales:{x:{grid:{display:!1,color:"rgba(0,0,0,0.07)"},title:{display:!0,text:i}},y:{min:e-o,max:n+o,grid:{display:!1,color:"rgba(0,0,0,0.07)"}}},elements:{point:{radius:0,pointHitRadius:100}},layout:{padding:{top:6,right:20,bottom:4,left:20}}}));let b={...M,labels:r.map(e=>(e*y).toFixed(2)),datasets:[{data:h,fill:!1,tension:0,borderColor:"rgba(37,99,235, 0.7)"}]};T(b)}finally{(0,tw.T8)(t,P.current)&&x(!1)}};(0,h.useEffect)(()=>{if(!a.map.current)return;let t=async t=>{let s;if(!e.elevationMeasurementEnabled||!a.map.current)return;if(!a.map.current.queryRenderedFeatures(t.point,{layers:["elevation-points"]}).length){let e={type:"Feature",geometry:{user:r?.user?.name,type:"Point",user_id:r?.user?.id,coordinates:[t.lngLat.lng,t.lngLat.lat]},properties:{user:r?.user?.name,uuid:String(new Date().getTime()),user_id:r?.user?.id}};F.current.push(e)}let i={...tz(),features:[...F.current]},n=null;F.current.length>1&&(s={type:"Feature",geometry:{type:"LineString",coordinates:F.current.map(e=>e.geometry.coordinates)},properties:{uuid:String(new Date().getTime()),name:l,user:r?.user?.name,description:c,source:"Map",type:l,user_id:r?.user?.id}},i.features.push(s),(n=(0,tw.g_)(s.geometry.coordinates))&&N(Number.parseFloat(n.totalDistance.toFixed(2)))),R.current=i,L(i);try{a.map.current.getSource("ele-line-source").setData(i)}catch(e){console.error("error",e)}n&&V(n)};if(!e.elevationMeasurementEnabled){P.current+=1,x(!1),g(0),a.map.current.getCanvas().style.cursor="auto",a.map.current.off("click",B.current),i(""),d(""),J(),F.current=[];let e=tz();
12R.current=e,L(e),T(e=>({...e,datasets:[{...e.datasets[0],data:[]}]}));let t={...D};t.features=[],A(t),O.current=[],p(!1);return}a.map.current.off("click",t),a.map.current.on("click",t),a.map.current.off("touchend",t),a.map.current.on("touchend",t);let s=a.map.current;(0,eo.dK)(s);let n=(0,eo.D)(s,eo.Ul);G();let o=()=>{G()};a.map.current.on("style.load",o);let u=C.features.find(e=>"LineString"===e.geometry.type),m=u&&(0,tw.g_)(u.geometry.coordinates);return m&&V(m),()=>{P.current+=1,a.map.current&&(a.map.current.off("click",t),a.map.current.off("touchend",t),a.map.current.off("style.load",o),n())}},[e.elevationMeasurementEnabled,S]);let G=()=>{a.map.current&&(a.map.current.getSource("ele-line-source")||a.map.current.addSource("ele-line-source",{type:"geojson",data:R.current}),a.map.current.getLayer("elevation-points")||a.map.current.addLayer({id:"elevation-points",type:"circle",source:"ele-line-source",paint:{"circle-radius":2,"circle-color":n},filter:["in","$type","Point"]}),a.map.current.getLayer("elevation-lines")||a.map.current.addLayer({id:"elevation-lines",type:"line",source:"ele-line-source",layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":n,"line-width":2.5},filter:["in","$type","LineString"]}),(0,k.y)(a.map.current))},J=()=>{a.map.current&&(a.map.current.getSource("ele-line-source")&&(a.map.current.getLayer("elevation-points")&&a.map.current.removeLayer("elevation-points"),a.map.current.getLayer("elevation-lines")&&a.map.current.removeLayer("elevation-lines"),a.map.current.removeSource("ele-line-source")),I.current&&(I.current.remove(),I.current=null))},q=()=>{P.current+=1,x(!1),g(0),J(),F.current=[],O.current=[];let e=tz();R.current=e,L(e),T(e=>({...e,datasets:[{...e.datasets[0],data:[]}]})),A(tz()),p(!1),N(0),_(e=>e+1)},Y=async(e,t)=>{if(!a.map.current)return null;let r=a.map.current,l=r.getTerrain()?r.queryTerrainElevation([e,t],{exaggerated:!1}):null;return l??=await (0,tw.IM)([e,t]),s.project?.units==="Imperial"&&null!==l&&(l*=eB.oc),l},H=()=>{P.current+=1,x(!1),e.setElevationMeasurementEnabled(!1),t.setBottomMenuOpen({open:!1,id:0,event:null})},Z=()=>{let e=new Blob([JSON.stringify(D,null,2)],{type:"application/json"}),t=URL.createObjectURL(e),a=document.createElement("a");a.href=t,a.download="elevation_profile.geojson",document.body.appendChild(a),a.click(),URL.revokeObjectURL(t),document.body.removeChild(a)},X=async()=>{b(!0);let e={...C,features:C.features.filter(e=>"LineString"===e.geometry.type)},t=await te({userContext:r,project:s.project,geojson:e,title:"Elevation",description:"Elevation",color:"#000",measurement:{type:"distance",value:w}});t.saved&&(H(),E(a.map,t.feature)),b(!1)},K=()=>{let e;return e=m?(0,o.jsxs)("div",{className:"opacity-40 flex flex-col gap-2 justify-center items-center h-full",children:[(0,o.jsx)("span",{className:"loading loading-spinner loading-sm text-black"}),(0,o.jsx)("span",{children:"Calculating elevation..."})]}):u?(0,o.jsxs)("div",{children:[f>0&&(0,o.jsx)("p",{className:"px-5 pt-2 text-xs opacity-50",children:f===M.datasets[0].data.length?"Elevation data could not be loaded.":"Some elevation samples could not be loaded."}),z&&(0,o.jsx)(tR.N1,{options:z,data:M})]}):(0,o.jsxs)("div",{className:"opacity-40 flex flex-col gap-2 justify-center items-center h-full",children:[(0,o.jsx)("span",{children:(0,o.jsx)(eh.YQY,{size:26})}),(0,o.jsx)("span",{children:"Draw a line to create an elevation graph"})]}),(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:"flex gap-3 opacity-50 cursor-pointer absolute right-4 top-4 z-5",children:[u&&!m&&(0,o.jsxs)(o.Fragment,{children:[y?(0,o.jsx)("span",{className:"loading loading-spinner loading-xs text-black"}):(0,o.jsx)("div",{title:"Save as measurement",onClick:X,children:(0,o.jsx)(eK.Bc_,{})}),(0,o.jsx)("div",{title:"Download as GeoJSON",onClick:Z,children:(0,o.jsx)(W.U01,{})}),(0,o.jsx)("div",{title:"Clear",onClick:q,children:(0,o.jsx)(eK.cO3,{})})]}),(0,o.jsx)("button",{className:"cursor-pointer",onClick:H,children:(0,o.jsx)(W.fUT,{})})]}),e]})};return(0,o.jsx)(o.Fragment,{children:void 0!==globalThis.window&&(0,o.jsx)(o.Fragment,{children:(0,v.Fr)()?(0,o.jsx)(ta.X,{blocking:!1,onDismiss:H,className:"text-black z-50 bottommenu absolute text-[13px]",style:{zIndex:5e6},expandOnContentDrag:!0,open:e.elevationMeasurementEnabled,children:(0,o.jsx)("div",{className:"h-[150px]",children:K()})}):(0,o.jsx)(o.Fragment,{children:e.elevationMeasurementEnabled&&(0,o.jsx)("div",{className:"bottom-modal sliding-div w-[40%]! h-[150px]",children:(0,o.jsx)("div",{className:"px-0 py-0 
12w-full",children:K()})})})})})}t$.t1.register(t$.PP,t$.kc,t$.FN,t$.No,t$.hE,t$.m_,t$.s$);var tW=a(56557),tB=a.n(tW);function tV(e){let t="bottom-2 left-2";return e.alt?t="bottom-[25px] right-[18px]":e.splitViewEnabled&&(t="bottom-[25px] left-2"),(0,o.jsx)("div",{className:`absolute cursor-pointer text-black flex text-xs items-center gap-[5px] px-[5px] py-[3px] shadow-[0_2px_4px_0_rgba(0,0,0,0.1)] z-30 bg-[rgba(255,255,255,0.95)] rounded-lg hover:bg-[rgba(250,250,250,0.95)] ${t}`,children:(0,o.jsxs)("div",{className:"flex items-center gap-2 p-[2px]","data-tooltip-id":"calendar-tt","data-tooltip-content":"Calendar",onClick:()=>{e.onClick()},children:[(0,o.jsx)(W.S4m,{size:12,color:"#000"}),(0,o.jsx)("span",{className:"text-black",children:e.date?tB()(e.date).toDate().toDateString().split(" ").slice(1).join(" "):new Date().toDateString().split(" ").slice(1).join(" ")})]})})}var tG=a(13734);function tJ(){return new Worker(a.p+"static/chunks/pingWorker-e263e10abbdd51f9.worker.js")}a(98899);var tq=a(59673),tY=a(71118),tH=a(30328),tZ=a(48518);function tX(e){let{thread_id:t,first_name:a,last_name:r,text:s,create_date:l,file_path:i}=e,n=(0,tH.C)(),{openModal:c}=(0,tZ.O)(x.dW.PDFViewerModal),[d,u]=(0,h.useState)(!1),p=J()(l).fromNow(),m=J()().subtract(1,"month"),f=J()(l).isBefore(m)?J()(l).format("MMMM D, YYYY"):p,g=`${a} ${r}`;return(0,o.jsxs)(o.Fragment,{children:[d&&(0,o.jsx)(B,{isOpen:d,closeModal:()=>u(!1),url:i}),(0,o.jsxs)("div",{className:"note-thread-item flex flex-row items-start break-all group/reply-box",children:[(0,o.jsxs)("div",{className:"avatar-container",children:[(0,o.jsx)(tY.A,{profile_image:e.profile_image,name:e.first_name+" "+e.last_name,hover:!1}),!e.last_item&&(0,o.jsx)("div",{className:"vertical-line"})]}),(0,o.jsxs)("div",{className:"content-container",children:[(0,o.jsxs)("div",{className:"author-info",children:[(0,o.jsx)("span",{className:"author-name",children:g}),(0,o.jsx)("span",{className:"create-date",children:f})]}),(0,o.jsxs)("div",{className:"note-content",children:[(0,o.jsx)("span",{className:"[word-break:break-word]",dangerouslySetInnerHTML:{__html:(0,Y.W7)(s,e.userMap)}}),i&&(0,o.jsx)("div",{children:"image"==(0,v.ti)(i)?(0,o.jsx)("button",{onClick:()=>{u(!0)},children:(0,o.jsx)("img",{src:i,className:"rounded-md cursor-pointer",alt:"Image"})}):"video"===(0,v.ti)(i)?(0,o.jsx)("div",{className:"w-[190px] rounded-md overflow-hidden",children:(0,o.jsx)(X(),{controls:!0,url:i,width:"100%",height:"100%"})}):"pdf"===(0,v.ti)(i)?(0,o.jsxs)("div",{onClick:()=>{n.setPdfUrl(i),c()},className:"hover:bg-gray-100 rounded-md p-2 opacity-80 bg-gray-100/50 shadow items-center justify-center flex gap-2 cursor-pointer",children:[(0,o.jsx)("span",{className:"flex-shrink-0",children:(0,v.sW)((0,v.ti)(i))}),(0,o.jsx)("span",{className:"text-sm line-clamp-1 overflow-hidden text-ellipsis max-w-[200px]",title:(0,tq.nU)(i),children:(0,tq.nU)(i)})]}):(0,o.jsx)("a",{href:i,download:!0,children:(0,o.jsxs)("div",{className:"hover:bg-gray-100 rounded-md p-2 opacity-80 bg-gray-100/50 shadow items-center justify-center flex gap-2",children:[(0,v.sW)((0,v.ti)(i)),(0,o.jsx)("span",{className:"text-md font-bold",children:(0,v.ti)(i).toUpperCase()})]})})})]})]}),(0,o.jsx)("div",{style:{marginLeft:"auto"},children:e.current_user_id===e.comment_user_id&&(0,o.jsx)(W.WeY,{className:"right-2 top-2 cursor-pointer text-gray-500 opacity-0 group-hover/reply-box:opacity-100 hover:text-red-500",onClick:()=>e.set_delete_function({display:!0,id:t}),size:16})})]})]})}var tK=a(30480),tQ=a(42893),t0=a(77036),t1=a(70055),t2=a(46334),t5=a(79111),t3=a(98477);function t4({fullWidthOnMobile:e=!0,...t}){let a,r=(0,h.useRef)(null),s=(0,tH.C)(),{modalState:l,closeModal:i,clickModal:n}=(0,tZ.O)(t.modalType),[c,d]=(0,h.useState)(!1),[u,p]=(0,h.useState)({x:0,y:0}),[m,x]=(0,h.useState)({width:0,height:0}),[f,g]=(0,h.useState)(0),[y,b]=(0,h.useState)({x:0,y:0}),[j,w]=(0,h.useState)({width:0,height:0}),[N,S]=(0,h.useState)({width:500,height:300}),{width:k,height:_}=(0,t1.A)(),C=(0,e$.p)(),[L,D]=(0,h.useState)(!1),[A,M]=(0,h.useState)(null),[E,T]=(0,h.useState)(null),[I,P]=(0,h.useState)(!1),F="auto"===t.defaultSize.height,[O,R]=(0,h.useState)(),[$,U]=(0,h.useState)(),B=()=>(0,v.v1)()?0:360*!!C.sidePanelOpen,V=e=>Math.max(0,Math.min(e,k-m.width-B()-0)),G=()=>$?.toLowerCase().includes("left")?u.x+m.width-0:k-B()-u.x-0,J=()=>$?.toLowerCase().includes("top")&&"auto"!==m.height?u.y+m.height:_-u.y,q={x:0,y:105},Y={width:G(),height:t.disableResize?t.defaultSize.height:.5*J()},H={x:0,y:0},Z={width:Y.width,height:t.disableResize?t.defaultSize.height:.9*J()},X=e=>Math.max(N.width,e),K=(e,t)=>{let a=e??u,r=t??m;if(a.x+r.width>k-B()){let e=V(a.x),t=X(r.width);p({...a,x:e}),x({width:t,height:F?"auto":r.height}),D(!0)}else e&&p(e),t&&x(t)},Q=()=>
12{if(!t.disableResize){if(c)(0,v.Fr)()?(x({...Y,height:F?"auto":Y.height}),p(q)):(x(j),p(y));else if((0,v.Fr)())x({...Z,height:F?"auto":Z.height}),F||p(H);else{let e=k-B()-100;w(m),b(u),x({width:e,height:F?"auto":_-130}),p({x:80,y:80})}d(!c)}};(0,h.useEffect)(()=>{t.setModalSize&&t.setModalSize(m)},[m]),(0,h.useEffect)(()=>{if(!(0,v.v1)())if(C.sidePanelOpen)M(u),T(m),K();else if((0,v.Fr)())c?(p(H),x(Z)):(p(q),x(Y));else L&&(A&&p({x:V(A.x),y:A.y}),E&&x({width:X(E.width),height:E.height}),D(!1))},[C.sidePanelOpen]),(0,h.useEffect)(()=>{(0,v.Fr)()?c?(p(H),x(Z)):(p(q),e&&x(Y)):K()},[k,_,L]),(0,h.useEffect)(()=>{l.display?((0,v.Fr)()?(p(q),e&&x(Y)):K(t.defaultPosition,t.defaultSize),S(t.defaultMinSize||{width:200,height:150}),d(!1),P(!0)):P(!1)},[l.display]),(0,h.useEffect)(()=>{r.current&&F&&g(r.current.offsetHeight)},[t.children,F]);let ee=t.disableResize||F;switch(t.title){case"LiDAR":a=(0,o.jsx)(W.SqY,{size:20});break;case"Hybrid View":a=(0,o.jsx)(z.z5U,{size:20});break;case"Eagle View":a=(0,o.jsx)(ep.dOF,{size:20});break;case"Notes":a=(0,o.jsx)(W.R7b,{size:18});break;case"Alerts":a=(0,o.jsx)(W.PAG,{size:18});break;case"PDF":a=(0,o.jsx)(t5.kl1,{size:18});break;case"Calendar":a=(0,o.jsx)(W.S4m,{size:18});break;case"3D Note":a=(0,o.jsx)(eu.GLH,{size:18});break;default:a=null}return(0,o.jsx)(o.Fragment,{children:l.display&&I&&(0,o.jsx)(tQ.A,{onMouseDown:()=>n(),onStart:t.handleDragStart,cancel:".toolbtn",handle:".modal-header",position:u,onStop:(e,{x:a,y:r})=>{let s={x:V(a),y:Math.max(0,Math.min(r,_-(F?f:m.height)-0))};p(s),L&&D(!1),M(s),t.handleDragStop&&t.handleDragStop()},bounds:"body",children:(0,o.jsxs)(t0.c,{size:m,onResizeStart:(e,t)=>{U(t),R({left:u.x,top:u.y})},onResize:(e,t,a,r)=>{if(!O)return;let s=O.left,l=O.top;switch(t){case"left":case"bottomLeft":s=O.left-r.width;break;case"top":case"topRight":l=O.top-r.height;break;case"topLeft":s=O.left-r.width,l=O.top-r.height}(0,t3.flushSync)(()=>{p({x:s,y:l}),x({width:a.offsetWidth,height:F?"auto":a.offsetHeight})})},onResizeStop:(e,a,r)=>{g(r.offsetHeight),L&&D(!1),T(m),t.handleResizeStop&&t.handleResizeStop()},minHeight:N.height,minWidth:N.width,maxWidth:G(),maxHeight:F?void 0:J(),lockAspectRatio:"nolock"!==t.lockRatio,enable:{top:!ee,bottom:!ee,left:!t.disableResize,right:!t.disableResize,topLeft:!ee,topRight:!ee,bottomLeft:!ee,bottomRight:!ee},style:{display:"flex",flexDirection:"column",position:"absolute",overflow:"hidden",borderRadius:(0,v.Fr)()?"0px":"8px",boxShadow:"0 0 10px rgba(0, 0, 0, 0.2)",background:t.backgroundColor??"#000",zIndex:l.zIndex,...c&&{top:0,left:0,width:"100%",height:F?"auto":"100%",margin:0}},children:[(0,o.jsx)("div",{ref:r,children:(0,o.jsxs)("div",{onClick:e=>{2==e.detail&&Q()},className:`flex modal-header cursor-move ${"white"===t.backgroundColor?"from-white bg-[#f2f2f2] border-b":"from-black/90 bg-black"} right-0 px-3 py-[9px] flex-row rounded-tr-lg rounded-tl-lg z-20 justify-between`,children:[(0,o.jsxs)("div",{className:"flex items-center",children:[a&&(0,o.jsx)("div",{className:`mr-2 ${"white"==t.backgroundColor?"text-black":"text-white"}`,children:a}),(0,o.jsx)("span",{className:`font-bold cursor-default ${"white"==t.backgroundColor?"text-black text-[14px]":"text-white text-[13px]"}`,children:t.title})]}),(0,o.jsxs)("div",{className:"flex items-center gap-3 z-30",children:[t.customButton&&(0,o.jsx)("span",{children:t.customButton}),"PDF"===t.title&&(0,o.jsx)(W.U01,{size:20,className:"toolbtn cursor-pointer hover-shadow",onClick:()=>{(0,v.zc)(s.pdfUrl)},color:"white"==t.backgroundColor?"#000":"#fff"}),!t.disableResize&&(0,o.jsx)(o.Fragment,{children:c?(0,o.jsx)(eK.SE2,{size:20,className:" toolbtn cursor-pointer hover-shadow",onClick:Q,color:"white"==t.backgroundColor?"#000":"#fff"}):(0,o.jsx)(eK.KFS,{size:20,className:"toolbtn cursor-pointer hover-shadow",onClick:Q,color:"white"==t.backgroundColor?"#000":"#fff","data-testid":"modal-maximize-btn"})}),(0,o.jsx)(W.fUT,{size:20,color:"white"==t.backgroundColor?"#000":"#fff",className:"toolbtn cursor-pointer hover-shadow","data-testid":"close-modal-button",onClick:()=>{t.closeModal&&t.closeModal(),i()}})]})]})}),(0,o.jsx)("div",{className:"w-full h-full overflow-auto desktop:overflow-hidden",onMouseDown:()=>n(),children:t.children}),(0,o.jsx)("div",{className:"absolute p-2",style:{bottom:"-3px",right:"-3px"},children:!t.disableResize&&(0,o.jsx)(t2.wlJ,{size:8,className:`${"white"===t.backgroundColor?"text-gray-300":"text-gray-900"}`})})]})})})}var t8=a(76930),t6=a(61296),t7=a(92679),t9=a(94516);function ae(e){let t=(0,ex.u)(),a=(0,ev.O)(),{modalState:r,clickModal:s}=(0,tZ.O)(x.dW.Note3DModal),l=(0,h.useRef)(null),[i,n]=(0,h.useState)(""),[c,d]=(0,h.useState)(!0),[u,p]=(0,h.useState)(""),[m,f]=(0,h.useState)({show:!1,lumaID:null}),[g,y]=(0,h.useState)(t6.iR.ALL),[b,j]=(0,h.useState)(!1),w="note3d",{EmojiPickerComponent:N,setShowEmojiPicker:S}=eW({onCloseModal:()=>{sessionStorage.setItem(`show_emoji_picker_${w}`,"false")},onEmojiClick:e=>{sessionStorage.setItem("selected_emoji",e.imageUrl)}});(0,h.useEffect)(()=>{e.isEmbedded||r.display||(n(""),p(""));let t=l.current;if(t)try{t.contentWindow.document.body.onclick=()=>{e.isEmbedded||s()}}catch{}let a=e=>{"back_to_luma_visualization"===e.key&&f(e=>({show:!0,lumaID:e.lumaID}
12))};return window.addEventListener("storage",a),a({key:sessionStorage.key}),()=>{window.removeEventListener("storage",a)}},[e]),(0,h.useEffect)(()=>{sessionStorage.setItem(`show_emoji_picker_${w}`,"false");let e=e=>{e.storageArea===sessionStorage&&e.key===`show_emoji_picker_${w}`&&"true"===sessionStorage.getItem(`show_emoji_picker_${w}`)&&S(!0)};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[]),(0,h.useEffect)(()=>{a.project&&(localStorage.setItem("last_location",JSON.stringify({[a.project.project_uuid]:{lat:e.noteData.properties.lat,lon:e.noteData.properties.lon}})),(async()=>{if(!e.noteData||!a.project)return;d(!0),f({show:!1,lumaID:null});let t=JSON.parse(e.noteData.folder_path),r=`${a.project.container_name}/notes/`;if(1===t.files.length)n(await (0,H.bB)(r+(0,v.$S)(t)));else{let a=t.files.find(e=>e.endsWith(".png")),s=e.noteData.filepath;s&&(n(await (0,H.bB)(`${r}${t.base}/${s}`)),a&&p(await (0,H.bB)(`${r}${t.base}/${a}`)))}if(e.noteData.properties){let t=JSON.parse(e.noteData.properties.data),r=JSON.parse(e.noteData.folder_path);if(!t.manualUpload){let t=e.noteData.filepath;n(await (0,H.bB)(a.project.container_name+"/notes/"+r.base+"/"+t))}t&&t.lumaID&&f({show:!0,lumaID:t.lumaID})}d(!1)})())},[e.noteData,r.display]);let k=e=>{y(e),j(!1)},_=()=>{j(!b)},C=e=>({id:e.id,name:e.name,email:e.email,lang:e.lang,first_name:e.first_name,surname:e.surname}),L=e.user?C(e.user):t?.user?C(t.user):null,D=()=>c?(0,o.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,o.jsx)("span",{className:"loading loading-spinner"})}):!m.show&&a.project?(0,o.jsx)("iframe",{ref:l,className:"w-full h-full rounded-lg",src:`../../libs/potree/build/potree/pointcloud-viewer.html?modelUrl=${encodeURIComponent(i)}&user=${JSON.stringify(L)}&mode=lidar&camera_projection=${encodeURIComponent(a.project.camera_projection||"+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs")}&lidar_projection=${encodeURIComponent(a.project.lidar_projection||"+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs")}&units=${encodeURIComponent(a.project.units||"")}&project_id=${a.project.project_uuid}&project_name=${a.project.project_name}&container_name=${a.project.container_name}${m.lumaID?"&isLuma=true":""}
13                    &project_logo=${encodeURIComponent(a.project.project_imageLink)}
14                    &floorplan=${encodeURIComponent(u)}
15                    `,title:"Potree"}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:"pointcloud-custom-tools",children:[(0,o.jsx)("div",{className:"pointcloud-custom-tool",title:"Edit",onClick:()=>void f(e=>({show:!1,lumaID:e.lumaID})),children:(0,o.jsx)(W.rnS,{})}),(0,o.jsxs)("div",{className:"dropdown dropdown-right",children:[(0,o.jsx)("div",{tabIndex:0,role:"button",className:"pointcloud-custom-tool",title:"Semantics",onClick:_,children:(0,o.jsx)(W.gP6,{size:15})}),b&&(0,o.jsxs)("ul",{tabIndex:0,className:"dropdown-content z-1 menu p-2 shadow bg-black shadow-white/20 rounded-box w-52",children:[(0,o.jsx)("li",{onClick:()=>k(t6.iR.ALL),className:g===t6.iR.ALL?"semantics-selected":"",children:(0,o.jsx)("a",{children:"All"})}),(0,o.jsx)("li",{onClick:()=>k(t6.iR.FOREGROUND),className:g===t6.iR.FOREGROUND?"semantics-selected":"",children:(0,o.jsx)("a",{children:"Foreground"})}),(0,o.jsx)("li",{onClick:()=>k(t6.iR.BACKGROUND),className:g===t6.iR.BACKGROUND?"semantics-selected":"",children:(0,o.jsx)("a",{children:"Backgroun
15d"})})]})]})]}),(0,o.jsxs)(t7.Hl,{children:[(0,o.jsx)("lumaSplats",{semanticsMask:g,source:`https://lumalabs.ai/capture/${m.lumaID}`,position:[-1,0,0],loadingAnimationEnabled:!0,scale:1}),(0,o.jsx)(t9.N,{})]})]});return(0,o.jsx)(o.Fragment,{children:e.isEmbedded&&e.noteData?(0,o.jsx)("div",{className:"bg-black text-white h-full",children:D()}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(t4,{modalType:x.dW.Note3DModal,defaultPosition:{x:70,y:65},defaultSize:{width:700,height:430},title:"3D Note",handleDragStart:()=>{l.current&&(l.current.style.pointerEvents="none")},handleDragStop:()=>{l.current&&(l.current.style.pointerEvents="auto")},children:(0,o.jsx)(o.Fragment,{children:D()})}),N]})})}(0,t8.e)({LumaSplats:t6.F7});var at=a(79052),aa=a.n(at),ar=a(92909);function as({alertId:e,value:t,loading:a=!1,disabled:r=!1,onChange:s,id:l,className:i="select select-bordered select-xs",valueClassName:n="text-[12px]"}){return r&&!a?(0,o.jsx)("span",{"aria-label":`Verify status for alert ${e}`,className:n,children:t??"Unset"}):(0,o.jsxs)("div",{className:"flex w-max items-center gap-2",children:[(0,o.jsxs)("select",{id:l,"aria-label":`Verify status for alert ${e}`,className:`${i} w-max`,value:t??"",disabled:a||r,onChange:e=>s?.(e.target.value||null),children:[(0,o.jsx)("option",{value:"",children:"Unset"}),ar.Fn.map(e=>(0,o.jsx)("option",{value:e,children:e},e))]}),a&&(0,o.jsx)("span",{className:"loading loading-spinner loading-xs"})]})}function al(e){let t=(0,ex.u)(),a=(0,tH.C)(),r=(0,eG.JY)(),s=(0,ef.N)(),{openModal:l}=(0,tZ.O)(x.dW.PDFViewerModal),i=(0,h.useRef)(null),n=(0,h.useRef)(null),[c,u]=(0,h.useState)({display:!1,id:0}),[p,f]=(0,h.useState)({display:!1,id:0}),[g,b]=(0,h.useState)({}),[w,N]=(0,h.useState)(),[S,k]=(0,h.useState)([]),[_,C]=(0,h.useState)(!1),[L,D]=(0,h.useState)(!0),[A,M]=(0,h.useState)(!1),[E,T]=(0,h.useState)(!1),[I,P]=(0,h.useState)(),[F,O]=(0,h.useState)(e.edit),[R,$]=(0,h.useState)(e.category),[z,G]=(0,h.useState)(e.severity),[q,Z]=(0,h.useState)(e.verify_status??null),[X,K]=(0,h.useState)(e.title),[Q,ea]=(0,h.useState)(e.description||""),[er,es]=(0,h.useState)(new Map),[el,ei]=(0,h.useState)(null),[en,eo]=(0,h.useState)([]),[ec,ed]=(0,h.useState)(!1),eu=!!(e.source===x.Sw.ALERT&&e.project&&(0,v._A)(t?.user,e.project.project_uuid)),[ep,eg]=(0,h.useState)(()=>eF.EditorState.createEmpty()),[ey,eb]=(0,h.useState)(()=>eF.EditorState.createEmpty()),{setSidePanelActionButtons:ej,closePanel:ew}=(0,e$.p)(),ev=(0,h.useContext)(et.bM),eN=(0,h.useRef)(null),eS=(0,h.useRef)(null),ek=()=>{eS.current?.scrollIntoView({behavior:"smooth"})},[e_,eL]=(0,h.useState)([]),[eD,eA]=(0,h.useState)([]),[eM,eE]=(0,h.useState)(new Date(e.create_date)),[eT,eI]=(0,h.useState)(new Date(e.create_date)),[eO,eR]=(0,h.useState)(e_),ez=(0,h.useRef)({title:e.title,description:e.description||"",category:e.category,severity:e.severity,createDate:new Date(e.create_date),fileUrls:[]}),{EmojiPickerComponent:eU,setShowEmojiPicker:eB}=eW({onEmojiClick:function(e){let t=e.emoji,a=m.ff.find(e=>e.id==t);a?(eX(a.imgUrl),tn(a.id)):(eX(t),tn(x.AT.custom))},onCloseModal:function(){eg(eF.EditorState.createEmpty())},slideFromBottom:!0}),eV="string"==typeof e.noteData?.properties.data?JSON.parse(e.noteData?.properties.data):e.noteData?.properties.data,eJ=String(eV?.icon)??x.AT.default,eq=m.ff.find(e=>e.id===eJ),[eY,eH]=(0,h.useState)(eJ),[eZ,eX]=(0,h.useState)(eq?.imgUrl||eV?.icon);(0,h.useEffect)(()=>{eH(eJ),eX(eq?.imgUrl||eV?.icon)},[eJ,e.noteData?.properties?.icon]),(0,h.useEffect)(()=>{let t=e.files?.filter(e=>!e.includes("thumbnail"))||[];t.sort((e,t)=>{let a=e.toLowerCase().endsWith(".glb");return a===t.toLowerCase().endsWith(".glb")?0:a?-1:1}),eL(t),(async()=>{eA((await Promise.all(t.map(t=>(0,H.bB)(e.file_path+"/"+t)))).map((e,a)=>[e,t[a]]))})()},[e.files]);let[eQ,e0]=(0,h.useState)(0),[e1,e2]=(0,h.useState)(null),e5=e.author_id===t?.user?.id||e.project&&(0,v._A)(t?.user,e.project.project_uuid);(0,h.useEffect)(()=>(ej((0,o.jsxs)("div",{className:"flex items-center gap-4 self-start",children:[S.length>0&&(0,o.jsxs)("div",{className:"flex flex-row items-center cursor-pointer",onClick:ek,children:[(0,o.jsx)(tK.MDh,{size:20,className:"ml-2 mr-2"}),(0,o.jsx)("span",{className:"text-base",children:S.length})]}),e5&&(0,o.jsx)("div",{className:"cursor-pointer",children:F?(0,o.jsx)(eh.dtF,{onClick:e4,"data-testid":"thread-edit-btn-exit"}):(0,o.jsx)(eh.EaJ,{onClick:e4,"data-testid":"thread-edit-btn-enter"})}),e.sendAlertNotificationAction,e5&&(0,o.jsx)("div",{className:"cursor-pointer",children:(0,o.jsx)(W.WeY,{onClick:()=>f({display:!0,id:e.parentId}),"data-testid":"thread-delete-btn"})})]})),()=>ej(null)),[ej,F,e.author_id,t?.user?.id,S]);let e3=J()(eM).format("MM/D/YYYY [at] h:mm A"),e4=()=>{F?(K(ez.current.title),ea(ez.current.description),eb((0,Y.e9)(ez.current.description,e.userMap)
15),$(ez.current.category),G(ez.current.severity),eI(ez.current.createDate),eA(ez.current.fileUrls),eR([]),e0(0)):(ez.current.title=X,ez.current.description=Q,ez.current.category=R,ez.current.severity=z,ez.current.createDate=eT,ez.current.fileUrls=eD),O(!F)},e8=async()=>{try{let t=(0,v.BG)(ey);if(e.source===x.Sw.ALERT){let a={id:e.parentId,title:X,description:t.modifiedText,description_with_names:t.plainText,mentions:t.mentions,category:R,severity:z,create_date:eT},r=await tu([a]);if(!r?.ok)return void y.Ay.error("Alert update failed");y.Ay.success("Alert updated successfully");let{id:s,create_date:l,...i}=a;for(let t of(e.onUpdateAlert({id:s,create_date:l,properties:i}),K(i.title),ea(i.description),$(i.category),G(i.severity),eI(new Date(l)),eE(new Date(l)),eO))tl(t)}else{let a=m.ff.some(e=>e.id===eY)?{icon_type:"default",icon:eY}:{icon_type:"custom",icon:eY===x.AT.custom?eZ:eY},r=await (0,Y.w3)(e.parentId,X,t.modifiedText,t.plainText,t.mentions,eT,eO,a);if(!r.ok)return void y.Ay.error("Note update failed");let s=await r.json();y.Ay.success("Note updated successfully"),e.onUpdateNote(s),K(s.properties.title),ea(s.properties.description),eI(new Date(s.create_date)),eE(new Date(s.create_date))}eR([]),e0(0),O(!1)}catch(e){y.Ay.error("Update failed"),console.error("Error submitting:",e)}},e6=(0,h.useRef)(null),e7=e=>{k(e),setTimeout(()=>{e6.current?.scrollIntoView({behavior:"smooth",block:"start"})},100),eg(eF.EditorState.createEmpty()),N(null),i.current&&(i.current.value="")},e9=async e=>{try{let t=await (0,Y.Ov)(e),a=await t.json();k(a)}catch(e){console.error("Error deleting comment: ",e)}finally{u({display:!1,id:0})}},te=async()=>{if(t?.user&&ev)try{e.source===x.Sw.ALERT?(await (0,ti.TD)([e.parentId.toString()]),(0,ti.pQ)(r.map,[Number(e.parentId)])):(await (0,ee.B9)([e.parentId.toString()]),(0,ee.$W)(r.map,[Number(e.parentId)],!0))}catch(e){console.error("Error deleting comment: ",e)}finally{(0,v.By)(),y.Ay.success(`${e.source===x.Sw.ALERT?"Alert":"Note"} deleted successfully`),ev.setUpdate(e=>e+1),f({display:!1,id:0}),ew()}},tt=()=>{N(null)};async function ta(e,t){let a=await fetch(e),r=await a.blob(),s=document.createElement("a");s.href=URL.createObjectURL(r),s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s)}function tr(e,t){if(!e)return void y.Ay.error(t||"Image analysis failed. Please try again.");let a="  Pulse Caption: "+e.caption+"\n\n"+(e.objects.length>0?"Detected Objects: "+e.objects.toString().replace(/,/g,", "):"No objects detected.");(0,v.Ed)(a,10,eg,ep)}(0,h.useEffect)(()=>{n.current?.focus(),(async()=>{try{T(!0);let a=await (0,Y.fG)(e.source,e.parentId);T(!1);let r=await a.json();k(r);let s=await (0,Y.kd)(e.source,e.parentId);if(!s.ok)throw Error("Failed to fetch thread data.");let l=await s.json();ei(l.authorProfileImage),es(e=>{let a=new Map(e);return a.has(t?.user?.id)||a.set(t?.user?.id,t?.user?.profile_image),Object.entries(l.userProfileMap).forEach(([e,t])=>{a.has(e)||a.set(e,t)}),a})}catch(e){console.error("Error fetching profile images:",e),T(!1)}})()},[e]),(0,h.useEffect)(()=>{if(!r.map?.current||!e.coords?.lon||!e.coords?.lat||!e.markerType)return;eN.current?.remove();let t=document.createElement("div");return t.className="selected-pulsing-marker",e.markerType===x.TG.note?t.className+=" pulse-note":e.markerType===x.TG.alert&&(t.className+=" pulse-alert"),eN.current=new(j()).Marker(t).setLngLat([e.coords.lon,e.coords.lat]).addTo(r.map.current),()=>{eN.current?.remove()}},[e.coords,e.markerType,r.map]),(0,h.useEffect)(()=>{e.userMap&&eo(Object.values(e.userMap).map(e=>({id:e.id,name:e.first_name.trim()+" "+e.last_name.trim(),avatar:e.profile_image||null,email:e.email})))},[e.userMap]),(0,h.useEffect)(()=>{$(e.category),G(e.severity)},[e.severity,e.category]),(0,h.useEffect)(()=>{Z(e.verify_status??null)},[e.verify_status]),(0,h.useEffect)(()=>{S&&S.forEach(t=>{(0,Y.ml)(t.file_path,e.source,b)})},[S]),(0,h.useEffect)(()=>{D(!ep.getCurrentContent().hasText())},[ep]),(0,h.useEffect)(()=>{P(JSON.parse(localStorage.getItem("project")||"{}"))},[]),(0,h.useEffect)(()=>{K(e.title),ea(e.description||""),eb((0,Y.e9)(e.description||"",e.userMap)
15),$(e.category),G(e.severity),eI(new Date(e.create_date)),eE(new Date(e.create_date))},[e]);let ts=e=>{let t=aa().extname(e);return e.length>25?e.slice(0,25)+"..."+t:e};(0,h.useEffect)(()=>{let t;if(eD.length){switch((0,v.ti)(eD[eQ][0])){case"image":t=(0,o.jsx)("img",{id:"thread-image",className:"w-full h-auto cursor-pointer max-h-[50vh]",onClick:()=>{ed(!0)},src:eD[eQ][0],width:"200",alt:"Image",loading:"lazy"});break;case"video":t=(0,o.jsx)("video",{controls:!0,width:"100%",className:"rounded-md",style:{maxHeight:"300px"},children:(0,o.jsx)("source",{src:eD[eQ][0],type:"video/mp4"})});break;case"pdf":t=(0,o.jsx)("button",{className:"hover:bg-gray-100 rounded-md p-2 bg-gray-100 shadow flex gap-2 w-full flex-row items-center justify-center",onClick:()=>{a.setPdfUrl(eD[eQ][0]),a.setPdfSource({source_type:e.source,source_id:e.parentId}),l()},children:(0,o.jsxs)("div",{className:"flex justify-between w-full items-center gap-2",children:[(0,o.jsx)("div",{className:"text-sm line-clamp-1 overflow-hidden text-ellipsis",title:eD[eQ][1],children:ts(eD[eQ][1])}),(0,o.jsx)("div",{className:"p-[2px] rounded-md bg-linear-to-tr from-[#70d6ff] via-[#ff70a6] to-[#ffd670]",children:(0,o.jsx)("div",{className:"bg-gray-100 p-[3px] rounded-[4px]",children:(0,o.jsx)(eK.D1A,{size:18,className:"text-black"})})})]})});break;case"glb":case"gltf":let r={filepath:eD[eQ][1],folder_path:e.noteData.folder_path||null,properties:e.noteData.properties};s.setNote3DData(r),t=(0,o.jsx)("div",{style:{height:"300px"},children:I&&(0,o.jsx)(ae,{isEmbedded:!0,noteData:r,user:e.user})});break;default:t=(0,o.jsx)("button",{className:"hover:bg-gray-100 rounded-md p-2 bg-gray-100 shadow flex gap-2 w-full flex-row items-center justify-center",onClick:()=>ta(eD[eQ][0],eD[eQ][1]),children:(0,o.jsxs)("div",{className:"flex justify-between w-full items-center gap-2",children:[(0,o.jsx)("div",{className:"text-sm line-clamp-1 overflow-hidden text-ellipsis",title:eD[eQ][1],children:ts(eD[eQ][1])}),(0,o.jsx)(W.U01,{size:20})]})})}e2(t)}},[eQ,e,eD,F]);let tl=t=>{e.setNotePictureUrls(e=>{let a={...e};return delete a[t],a})};function tn(e){e==eY?e==x.AT.default?eH(x.AT.none):e!==x.AT.custom&&(eH(x.AT.default),eX(eC)):eH(e)}let to=(0,h.useCallback)(()=>{e9(c.id)},[e9,c.id]),tc=(0,h.useCallback)(()=>{u({display:!1,id:0})},[]),td=(0,h.useCallback)(()=>{te()},[te]),tp=(0,h.useCallback)(()=>{f({display:!1,id:0})},[]),th=(0,h.useMemo)(()=>Q&&e.userMap?(0,Y.W7)(Q,e.userMap):"",[Q,e.userMap]);return(0,o.jsxs)(o.Fragment,{children:[c.display&&(0,o.jsx)(V.A,{isOpen:!0,onDelete:to,closeModal:tc}),p.display&&(0,o.jsx)("div",{"data-testid":"thread-delete-confirmation-modal",children:(0,o.jsx)(V.A,{isOpen:!0,onDelete:td,closeModal:tp})}),ec&&(0,o.jsx)(B,{isOpen:ec,closeModal:()=>ed(!1),url:eD[eQ][0]}),(0,o.jsxs)("div",{className:"text-black flex flex-col justify-between z-46 h-full max-w-full","data-testid":"thread-container",children:[(0,o.jsxs)("div",{className:"grow flex flex-col overflow-y-auto overflow-x-auto",children:[(0,o.jsxs)("div",{className:"mb-4",children:[(0,o.jsx)("div",{className:"flex justify-between items-start",children:(0,o.jsxs)("div",{className:"flex items-start",children:[(0,o.jsx)("div",{className:"mr-4",children:(0,o.jsx)(tY.A,{profile_image:e.source===x.Sw.ALERT?null:el,name:e.author,hover:!1})}),(0,o.jsxs)("div",{className:"flex flex-col",children:[(0,o.jsx)("p",{className:"font-bold",children:`${(e.source===x.Sw.ALERT?"Issuer: ":"")+e.author}`}),(0,o.jsx)("p",{className:"text-sm text-gray-600","data-testid":"thread-note-date",children:e3})]})]})}),(0,o.jsxs)("div",{className:"mt-4 p-1",children:[(0,o.jsx)("hr",{className:"my-4"}),e.source===x.Sw.ALERT&&(0,o.jsxs)("div",{className:"mb-1 flex flex-col gap-4 mx-auto",children:[F?(0,o.jsx)("input",{onChange:e=>$(e.target.value),value:R,type:"text",placeholder:"Category",className:"input w-full text-black border-black/10 px-3 text-sm"}):R&&(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[(0,o.jsx)("span",{className:"text-sm",children:"Category:"}),(0,o.jsx)("div",{className:"px-[9px] py-[6px] bg-[#f5f5f5] rounded-2xl font-bold text-sm text-[#333] max-w-full break-words whitespace-normal",children:R})]}),void 0!==z&&(F?(0,o.jsxs)("div",{className:"flex flex-col items-center",children:[(0,o.jsx)("p",{className:"mb-2",children:"Severity"}),(0,o.jsx)(tm.A,{className:"pt-2.5! pb-10! w-[85%]!",min:1,max:5,step:1,marks:{1:"Ob
15served",2:" ",3:"Near Urgent",4:" ",5:"Urgent"},value:z,onChange:e=>G(e)})]}):(0,o.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,o.jsx)("span",{className:"text-sm",children:"Severity:"}),(0,o.jsxs)("div",{className:"flex items-center gap-1",children:[(0,o.jsx)("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:(0,v.s8)(z)}}),(0,o.jsx)("div",{className:"text-[14px] font-bold text-[#333]",children:(0,v.Wl)(z)})]})]})),e.source===x.Sw.ALERT&&(0,o.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,o.jsx)("span",{className:"text-sm",children:"Reviewed:"}),(0,o.jsx)("div",{className:"text-sm font-bold",style:{color:!0===e.reviewed||"true"===e.reviewed?"#28a745":"#808080"},children:!0===e.reviewed||"true"===e.reviewed?"Reviewed":"Not Reviewed"})]}),e.source===x.Sw.ALERT&&(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[(0,o.jsx)("label",{className:"text-sm",htmlFor:"alert-verify-status",children:"Verify:"}),(0,o.jsx)(as,{id:"alert-verify-status",alertId:e.parentId,value:q,loading:e.verifyStatusUpdating,disabled:!eu,className:"select select-bordered select-sm text-[14px] font-bold text-[#333]",valueClassName:"text-[14px] font-bold text-[#333]",onChange:async t=>{eu&&await e.onVerifyStatusChange?.(t)&&Z(t)}})]})]}),e.source===x.Sw.ALERT&&(0,o.jsx)("hr",{className:"mb-4"}),F?(0,o.jsx)("input",{type:"text",value:X,onChange:e=>K(e.target.value),className:"text-xl font-bold editable-input input  px-3",placeholder:"Title","data-testid":"edit-note-title-input"}):(0,o.jsx)("p",{id:"thread-title",className:"text-xl font-bold non-editable-title",children:X}),F?(0,o.jsx)("div",{className:"text-sm text-gray-600 editable-textarea px-3","data-testid":"edit-note-description-input",children:(0,o.jsx)(eP,{projectUsers:en,editorState:ey,setEditorState:eb,placeholder:"Description"})}):th&&(0,o.jsx)("p",{id:"thread-description",className:"text-sm text-gray-600 non-editable-text",dangerouslySetInnerHTML:{__html:th}}),F&&(0,o.jsx)("div",{className:"flex items-center w-full",children:(0,o.jsx)("input",{type:"datetime-local",className:"input  backdrop-blur-sm bg-white/80 text-black w-full px-3 mx-auto text-[14px]",value:(0,v.rm)(eT),onChange:e=>{let t=new Date(e.target.value);isNaN(t.getTime())?console.error("Invalid date input"):eI(t)},"data-testid":"edit-note-date-input"})}),eD?.length>0&&(0,o.jsxs)("div",{className:"mt-4 file-uploader items-center w-full mb-2 flex flex-col",children:[(0,o.jsxs)("div",{className:"flex gap-2 items-center w-full justify-center m-2 ",children:[F&&(0,o.jsxs)("button",{onClick:()=>{let e=eD.filter((e,t)=>t!=eQ);eR([...eO,eD[eQ][1]]),eA(e),e0(Math.max(0,Math.min(eQ,e.length-1)))},className:"rounded-md bg-gray-100 btn btn-sm  flex justify-center",children:[(0,o.jsx)(W.WeY,{})," Delete file"]}),["glb","gltf"].includes((0,v.ti)(eD[eQ][1]))&&(0,o.jsxs)("button",{onClick:()=>{s.setNote3DData({filepath:eD[eQ][1],folder_path:e.noteData.folder_path||null,properties:e.noteData.properties}),l(x.dW.Note3DModal)},className:"rounded-md bg-gray-100 btn btn-sm  flex justify-center",children:[(0,o.jsx)(em.rDs,{})," Maximize"]})]}),(0,o.jsx)("div",{className:"flex gap-2 items-center justify-between w-full",children:(0,o.jsxs)("div",{className:"flex flex-col w-full",children:[(0,o.jsx)("div",{className:"w-full max-h-full justify-center items-center flex flex-1",style:{width:"100%",minWidth:"100%"},children:e1}),(0,o.jsxs)("div",{className:"flex items-center justify-center gap-2 mt-2",children:[(0,o.jsx)("button",{onClick:()=>{e0(e=>(e-1+eD.length)%eD.length)},className:`p-2 rounded-md bg-gray-100 btn btn-square btn-sm ${1===eD.length?"hidden":"block"} `,children:"←"}),(0,o.jsx)("div",{className:`text-xs flex justify-center text-slate-400 ${0===eD.length?"hidden":"block"}`,"data-testid":"thread-file-navigation",children:1+eQ+" / "+eD.length}),(0,o.jsx)("button",{onClick:()=>{e0(e=>(e+1)%eD.length)},className:`p-2 rounded-md bg-gray-100 btn btn-square btn-sm ${1===eD.length?"hidden":"block"} `,children:"→"})]})]})})]}),F&&(0,o.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,o.jsx)("div",{className:"flex items-center",children:(0,o.jsx)("button",{className:"btn tt-blue-button btn-sm btn-primary mt-2",onClick:e8,"data-testid":"edit-note-save-btn",children:"Save"})}),(0,o.jsx)("div",{className:"flex items-center mt-2",children:e.source===x.Sw.NOTE&&(0,o.jsx)("div",{tabIndex:0,role:"button",className:"btn",style:{paddingLeft:"12px",paddingRight:"12px"},onClick:()=>eB(!0),children:eZ&&(eZ.startsWith("http")||eZ.startsWith("/"))?(0,o.jsx)(d(),{src:eZ,alt:"current symbol",width:20,height:20}):(0,o.jsx)("span",{style:{fontSize:"20px",lineHeight:1},children:eZ})})})]})]})]}),(0,o.jsx)("hr",{className:"py-2"}),(0,o.jsxs)("div",{className:"relative ml-5 mr-4 max-w-[full] max-h-[75vh]",ref:eS,children:[" ",
15S.length>0&&e.userMap?S.map((t,a)=>(0,o.jsx)("div",{className:"flex items-start mb-4","data-testid":"thread-comment-item",children:(0,o.jsx)(tX,{thread_id:t.id,first_name:t.first_name,last_name:t.last_name,text:t.text,create_date:t.create_date,comment_user_id:t.user_id,current_user_id:e.user?.id,set_delete_function:u,file_path:t.file_path?g[t.file_path]:void 0,last_item:a===S.length-1,parent_id:e.parentId,profile_image:er.get(t.user_id),userMap:e.userMap})},a)):(0,o.jsx)("div",{className:"opacity-70 text-sm mt-5 w-full flex justify-center ",children:(0,o.jsx)("span",{children:E||!e.userMap?"Finding replies...":"No replies yet"})})]}),(0,o.jsx)("div",{ref:e6})]}),(0,o.jsx)("hr",{className:"my-4 "}),(0,o.jsxs)("div",{className:" flex flex-col bottom-0 left-0 right-0 bg-white break-all p-4 w-full max-w-full",children:[(0,o.jsxs)("div",{className:"flex items-center rounded-md max-w-full w-full gap-4 justify-between",children:[(0,o.jsxs)("div",{className:"flex gap-4",children:[(0,o.jsx)("div",{className:"default-avatar align-up",children:(0,o.jsx)(tY.A,{profile_image:t?.user?.profile_image,name:t?.user?.first_name+" "+t?.user?.surname,hover:!1})}),(0,o.jsx)("div",{className:"flex flex-col text-file-input","data-testid":"thread-comment-input",children:en&&(0,o.jsx)(eP,{projectUsers:en,editorState:ep,setEditorState:eg})})]}),(0,o.jsx)("div",{className:"flex flex-col h-full text-sm shrink-0",children:(0,o.jsx)("button",{className:`tooltip whitespace-pre-line tooltip-left ${A?"image-analysis":""}`,onClick:()=>(0,v.qK)(w,tr,"analyze",A,M),type:"button","data-tip":(w&&"image"==(0,v.ti)(w.name)?"":"Upload an image file to use Pulse.\n")+"Pulse uses AI. Check for mistakes.",children:(0,o.jsx)("img",{src:"/images/pulselogo.svg",alt:"Pulse Icon",className:"w-[30px]! h-[30px]!"})})})]}),(0,o.jsxs)("div",{children:[(0,o.jsx)("div",{className:"flex flex-col text-file-input max-w-full m-2",children:w&&(0,o.jsx)("div",{className:"image-file-preview mt-2 relative inline-block mr-4 max-w-full",children:"image"===(0,v.ti)(w.name)?(0,o.jsxs)("div",{className:"relative",children:[(0,o.jsx)("img",{src:URL.createObjectURL(w),alt:"Preview",className:"w-100% object-cover rounded-md"}),(0,o.jsx)("button",{className:"remove-button absolute text-white p-1",onClick:tt,style:{transform:"translate(50%, -50%)",display:"flex",alignItems:"center"},children:"\xd7"})]}):(0,o.jsx)("div",{className:"file-uploader-metadata max-w-full w-full",children:(0,o.jsxs)("div",{className:"flex items-center max-w-full justify-between w-full",children:[(0,o.jsx)("div",{className:"w-full truncate max-w-full",children:w.name}),(0,o.jsx)(W.fUT,{className:"cursor-pointer",onClick:tt})]})})})}),(0,o.jsxs)("div",{className:"flex justify-between items-center",children:[(0,o.jsx)("button",{className:"mr-2 mt-4",onClick:()=>i.current?.click(),style:{width:"25px",height:"25px"},children:(0,o.jsx)(U.Y4x,{size:16,color:"blue"})}),(0,o.jsx)("input",{ref:i,type:"file",onChange:e=>{let t=e.target.files?.[0];t&&N(t)},className:"hidden"}),(0,o.jsx)("button",{className:`btn-sm btn-neutral tt-blue-button align-down ${_?"relative":""} ${L?"disabled-button":""}`,style:{borderRadius:"40px",minWidth:"85px",height:"40px"},onClick:()=>(0,Y.D_)(e.parentId.toString(),w,e.source,e7,C,ep),disabled:_||L,"data-testid":"thread-comment-submit-btn",children:_?(0,o.jsx)("div",{className:"flex items-center justify-center absolute inset-0",children:(0,o.jsx)("span",{className:"loading  loading-md"})}):"Reply"})]})]})]})]}),eU]})}var ai=a(78594);function an({userMap:e,syncMentions:t,toggleSidePanel:a,closePanel:r,currentPanelKey:s,onUpdateAlert:l}){let i=(0,ex.u)(),n=(0,h.useContext)(et.bM),c=(0,eG.JY)(),d=(0,eV.H)(),u=(0,ef.N)(),p=(0,eg.ZM)(),f=(0,ev.O)(),g=(0,h.useRef)(null),[y,b]=(0,h.useState)(new Date),[j,w]=(0,h.useState)(),N=c.layerFilterOptions.current.alerts,S=async(e,t)=>{if(!f.project||!(0,v._A)(i?.user,f.project.project_uuid))return!1;let a=await tc(e,t);return a?.ok?(l({id:e,properties:{verify_status:t}}),tG.oR.success("Verify status updated"),!0):(tG.oR.error("Failed to update Verify status"),!1)};(0,h.useEffect)(()=>
15{if(!f.project||g.current)return;let t=new tJ;return g.current=t,t.onmessage=async t=>{let{type:l,payload:i,error:m}=t.data;if("fetchedData"===l)try{let{alerts:t,alert_threads:l,note_threads:m,all_note_mentions:h,all_alert_mentions:x,time_checked:g,uploadingTours:y}=i,j=new Date(new Date(g).getTime()-2e3);if(b(j),d.setUploadingTours(y),p.alertNotificationsEnabled&&t?.forEach(e=>{let t=(0,tG.oR)((0,o.jsx)(_,{title:"New Alert",subtitle:`New alert created: ${e.properties.title}`,geojson:e.geojson,onClose:()=>k(t),alert:e}))}),m?.forEach(e=>{let t=(0,tG.oR)((0,o.jsx)(_,{title:"You've been mentioned",subtitle:`New mention for: ${e.properties.title}`,location:e.location,onClose:()=>k(t),note:e}))}),l?.forEach(e=>{let t=(0,tG.oR)((0,o.jsx)(_,{title:"You've been mentioned",subtitle:`New mention for: ${e.properties.title}`,geojson:e.geojson,onClose:()=>k(t),alert:e}))}),h&&h.length>0){let{status:e,count:t}=h.reduce((e,t)=>(e.status[t.notification_id]=t.is_read,t.is_read||(e.count+=1),e),{status:{},count:0});u.setNoteMentions(h),u.setNoteReadStatus(e),u.setNoteUnreadCount(t)}if(x&&x.length>0){let{status:e,count:t}=x.reduce((e,t)=>(e.status[t.notification_id]=t.is_read,t.is_read||(e.count+=1),e),{status:{},count:0});p.setAlertMentions(x),p.setAlertReadStatus(e),p.setAlertUnreadCount(t)}t&&t.length>0&&(c.map=await td(c.map,n,f.project,e,a,r,s,N))}catch(e){console.error("Error in onmessage processing:",e)}"error"===l&&console.error("Worker error:",m)},"visible"===document.visibilityState&&g.current?.postMessage({action:"start",url:`${m.fn}/map/ping?project_uuid=${f.project.project_uuid}&last_checked=${y.toISOString()}&initial_ping=true`}),()=>{g.current?.postMessage({action:"stop"}),g.current?.terminate(),g.current=null}},[f.project]),(0,h.useEffect)(()=>{if(!y)return void g.current?.postMessage({action:"stop"});if(g.current){if(!f.project)return;g.current.postMessage({action:"updateParams",url:`${m.fn}/map/ping?project_uuid=${f.project.project_uuid}&last_checked=${y.toISOString()}&initial_ping=false`})}},[y]),(0,h.useEffect)(()=>{t>0&&f.project&&g.current?.postMessage({action:"refresh",url:`${m.fn}/map/ping?project_uuid=${f.project.project_uuid}&last_checked=${y.toISOString()}&initial_ping=true`})},[t]),(0,h.useEffect)(()=>{let e=()=>{g.current&&("hidden"===document.visibilityState?g.current.postMessage({action:"stop"}):"visible"===document.visibilityState&&g.current.postMessage({action:"start",url:`${m.fn}/map/ping?project_uuid=${f.project?.project_uuid}&last_checked=${new Date().toISOString()}&initial_ping=true`}))};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[]);let k=e=>{tG.oR.dismiss(e)},_=t=>((0,h.useEffect)(()=>{(async()=>{if(t.geojson){let e=(0,ai.k7)(t.geojson);e&&w({lat:e.lat,lon:e.lon})}else t.location&&w({lat:t.location.lat,lon:t.location.lon})})()},[t.geojson,t.location]),(0,o.jsxs)("div",{className:"animate-enter max-w-md w-full bg-white shadow-lg rounded-lg pointer-events-auto flex ring-1 ring-black ring-opacity-5",children:[(0,o.jsx)("div",{className:"flex-1 w-0 p-4",children:(0,o.jsxs)("div",{className:"flex items-start",children:[(0,o.jsx)("div",{className:"shrink-0 flex self-center p-1",children:t.geojson?(0,o.jsx)("img",{src:"/images/alert-unverified-marker.png",alt:"alert",className:"h-6 w-6"}):(0,o.jsx)("img",{src:"/images/symbols/note-marker.png",alt:"note",className:"h-6 w-6"})}),(0,o.jsxs)("div",{className:"ml-3 flex-1",children:[(0,o.jsx)("p",{className:"text-sm font-medium text-gray-900",children:t.title}),(0,o.jsx)("p",{className:"mt-1 text-sm text-gray-500",children:t.subtitle})]})]})}),(0,o.jsxs)("div",{className:"flex flex-col justify-between border-l border-gray-200",children:[(0,o.jsx)("button",{onClick:async()=>{let r=j;if(t.geojson){let e=(0,ai.k7)(t.geojson);e&&(w(r={lat:e.lat,lon:e.lon}),await (0,v.y9)(t.geojson,c.map))}else if(t.location){if(!c.map.current)return;let{lat:e,lon:a}=t.location;w(r={lat:e,lon:a}),c.map.current.flyTo({center:[a,e],zoom:c.map.current.getZoom()>13?c.map.current.getZoom():13,duration:eB.AD})}if(f.project){if(t.alert){let s=t.alert,n="";if(t.alert.properties.folder_path){let e=f.project.container_name+"/alerts/"+t.alert.properties.folder_path.base+"/"+t.alert.properties.folder_path?.files[0];n=await (0,H.bB)(e)}
15a((0,o.jsx)(al,{parentId:s.id,title:s.properties.title,description:s.properties.description,severity:s.properties.severity,category:s.properties.category,create_date:s.create_date,author:s.properties.issuer,author_id:s.user_id||"",project:f.project,reviewed:s.reviewed,verify_status:s.properties.verify_status??null,onVerifyStatusChange:f.project&&(0,v._A)(i?.user,f.project.project_uuid)?e=>S(s.id,e):void 0,onUpdateAlert:l,file_path:n,user:i?.user,source:x.Sw.ALERT,modalSource:"alertsModal",noteData:void 0,coords:r,userMap:e,markerType:x.TG.alert}),{title:"Threads",key:`alert-${s.id}`})}if(t.note){let s=t.note,l="";if(t.note.properties.folder_path){let e=f.project.container_name+"/notes/"+t.note.properties.folder_path.base+"/"+t.note.properties.folder_path?.files[0];l=await (0,H.bB)(e)}let n=s.properties.folder_path?{filepath:null,folder_path:JSON.stringify(s.properties.folder_path),properties:{...s.properties,data:JSON.stringify(s.properties.data)}}:void 0;a((0,o.jsx)(al,{parentId:s.id,title:s.properties.title,description:s.properties.description,create_date:s.create_date,author:`${e[s.user_id]?.first_name||""} ${e[s.user_id]?.last_name||""}`,author_id:s.user_id||"",project:f.project,file_path:l,user:i?.user,source:x.Sw.NOTE,modalSource:"notesModal",coords:r,noteData:n,userMap:e,markerType:x.TG.note}),{title:"Threads",key:`note-${s.id}`})}t.onClose()}},className:"px-2 w-full border-b border-black/10 rounded-r-lg flex items-center h-1/2 justify-center text-sm font-medium text-tt-blue hover:text-tt-blue/80 focus:outline-none",children:"Show"}),(0,o.jsx)("button",{onClick:t.onClose,className:"px-2 w-full border border-none rounded-none h-1/2 flex items-center justify-center text-sm font-medium opacity-30 hover:opacity-40",children:"Close"})]})]}));return(0,o.jsx)("div",{})}function ao(e){let t=(0,eG.JY)(),[a,r]=(0,h.useState)(""),[s,l]=(0,h.useState)(!1),[i,n]=(0,h.useState)(null);return(0,h.useEffect)(()=>{let e=setTimeout(()=>{s&&a&&!/^(-?\d+(\.\d+)?)\s*,\s*(-?\d+(\.\d+)?)$/.test(a)?(0,eo.bq)(a).then(e=>{e&&n(e)}):n(null)},300);return()=>clearTimeout(e)},[a,s]),{locationSearch:a,setLocationSearch:r,searchResults:i,setSearchResults:n,setAutoCompleteEnabled:l,handleSearchFromInput:()=>{if(/^(-?\d+(\.\d+)?)\s*,\s*(-?\d+(\.\d+)?)$/.test(a))(()=>{if(!t.map.current)return;let[r,s]=a.split(",").map(e=>parseFloat(e.trim()));(r>=-90&&r<=90&&s>=-180&&s<=180?0:1)?y.Ay.error("Invalid coordinates"):e.changeLocation({lon:s,lat:r,zoom:Math.max(t.map.current.getZoom(),13)})})();else if(null!=i&&i.features.length>0){let t=i.features[0];r(t.place_name),l(!1),e.changeLocation({lon:t.geometry.coordinates[0],lat:t.geometry.coordinates[1],zoom:12})}else y.Ay.error("Invalid Search Input");n(null)}}}let ac=({setShowMobileMenu:e,changeLocation:t,loading:a})=>{let{locationSearch:r,setLocationSearch:s,searchResults:l,setSearchResults:i,setAutoCompleteEnabled:n,handleSearchFromInput:c}=ao({changeLocation:t}),d=(0,h.useRef)(null),u=e=>{d.current&&!d.current.contains(e.target)&&i(null)};return(0,h.useEffect)(()=>(document.addEventListener("click",u),()=>{document.removeEventListener("click",u)}),[]),(0,o.jsx)("div",{className:"w-full desktop:w-auto",children:(0,o.jsx)("div",{className:"flex items-center flex-row","data-testid":"search-div",children:(0,o.jsxs)("div",{className:"relative w-full desktop:w-auto opacity-95 bg-white rounded-lg shadow flex",children:[!(0,e_.KR)()&&(0,o.jsx)("button",{onClick:()=>e(!0),className:"btn border-none bg-white/95 inline-flex desktop:hidden pr-0",children:(0,o.jsx)(eK.ND1,{})}),(0,o.jsx)("input",{type:"text",placeholder:"Search by city or coordinates",onKeyDown:e=>{"Enter"===e.key&&c()},onChange:e=>{s(e.target.value),n(!0)},value:r,className:"input desktop:w-[450px] opacity-95 text-black desktop:ml-0 w-full border-l-0 rounded-l-none desktop:rounded-l"}),null!=l&&l.features.length>0&&(0,o.jsx)("div",{className:"flex flex-col gap-2 absolute top-[calc(100%)] w-full",children:(0,o.jsx)("div",{ref:d,className:" w-full shadow mt-2 h-auto bg-white/95 backdrop-blur-sm rounded-md z-20",children:l.features.map((e,a)=>(0,o.jsx)("div",{onClick:()=>{t({lon:e.geometry.coordinates[0],lat:e.geometry.coordinates[1],zoom:12}),s(e.place_name),n(!1),i(null)},className:`text-black text-sm cursor-pointer hover:bg-black/5 px-3 py-2 ${a!==l.features.length-1?"border-b border-black/10":""}`,children:(0,o.jsxs)("div",{className:"flex flex-col gap-[2px]",children:[(0,o.jsx)("span",{className:"font-bold",children:e.text.length>55?e.text.substring(0,55)+"...":e.text}),(0,o.jsx)("span",{className:"text-[#566171]",children:e.place_name.length>55?e.place_name.substring(0,55)+"...":e.place_name})]})},a))})}),(0,o.jsx)("div",{className:"flex absolute right-0 h-full gap-3 items-center mr-3",children:a?(0,o.jsx)("span",{className:"loading loading-spinner loading-sm bg-gray-500"}):(0,o.jsx)($.iyI,{onClick:c,color:"gray",className:" bg-transparent cursor-pointer",size:20,id:"search-button"})})]})})})};var ad=a(30169);let au=({hoveredFeature:e,units:t})=>{let a=e.properties;return(0,o.jsx)("div",{className:"text-black whitespace-pre-line flex justify-between",children:(0,o.jsx)("div",{children:Object.keys(a).map(e=>"extrude"!==e&&"min_height"!==e&&"iso_3166_1"!==e&&"underground"!==e&&(0,o.jsxs)("div",{children:[(0,o.jsxs)("strong",{children:["iso_3166_2"===e?"Location":e.charAt(0).toUpperCase()+e.slice(1),": "]}),"height"!==e?a[e]:"Imperial"===t?(3.280839895*a[e]).toFixed(1)+"ft":a[e]+"m"]},e))})})};function ap(){let e=(0,eG.JY)(),t=(0,eD.l)(),[a,r]=(0,h.useState)([]);(0,h.useEffect)(()=>
15{t.uploadings.forEach(e=>{if(e.toastId&&a.includes(e.toastId))tG.oR.update(e.toastId,{render:(0,o.jsx)(l,{item:e,onClose:()=>s(e.toastId,e)})});else{let a=(0,tG.oR)((0,o.jsx)(l,{item:e,onClose:()=>s(a,e)}));t.updateUploading(e.id,{toastId:a}),r(e=>[...e,a])}})},[t.uploadings]);let s=(e,a)=>{e&&tG.oR.isActive(e)&&(tG.oR.dismiss(e),a.status!==x.nW.complete&&a.status!==x.nW.upload_complete&&(a.worker&&a.worker.postMessage({action:"cancel"}),a.onClose?.()),a.type===x.dP.tour&&a.status===x.nW.error&&a.onErrorClose?.(),t.removeUploading(a.id),r(t=>t.filter(t=>t!==e)))},l=t=>{let a=t.item.coordinates&&0!==Object.keys(t.item.coordinates).length,r=[x.dP.note,x.dP.alert,x.dP.las,x.dP.layer,x.dP.tour,x.dP.delete_tour];return(0,o.jsxs)("div",{className:"animate-enter max-w-md w-full bg-white shadow-lg rounded-lg pointer-events-auto flex flex-col ring-1 ring-black/5","data-testid":"uploading-manager-toast",children:[(0,o.jsxs)("div",{className:"flex flex-row justify-between h-[74px]",children:[(0,o.jsx)("div",{className:"w-full p-0",children:(0,o.jsxs)("div",{className:"flex items-start px-4 pt-4",children:[(0,o.jsxs)("div",{className:"shrink-0 flex self-center",children:[t.item.type===x.dP.note&&(0,o.jsx)("img",{src:"/images/symbols/note-marker.png",alt:"Note",width:20}),t.item.type===x.dP.alert&&(0,o.jsx)("img",{src:"/images/alert-unverified-marker.png",alt:"Alert",width:20}),t.item.type===x.dP.las&&(0,o.jsx)("img",{src:"/images/symbols/LidarSymbol.png",alt:"LAS",width:20}),t.item.type===x.dP.layer&&(0,o.jsx)(W.gP6,{size:20,color:"#2563eb"}),t.item.type===x.dP.tour&&(0,o.jsx)(z.e5i,{size:20,color:"#2563eb"}),t.item.type===x.dP.delete_tour&&(0,o.jsx)(e0.qbC,{size:20,color:"#eb2525"}),!r.includes(t.item.type)&&(0,o.jsx)("img",{src:"/images/symbols/note-marker.png",alt:"Default",width:20})]}),(0,o.jsxs)("div",{className:"ml-3 flex-1",children:[t.item.status===x.nW.error?(0,o.jsxs)("p",{className:"text-sm font-medium text-red-500 flex items-center gap-2",children:[(0,o.jsx)(W.PAG,{})," ",t.item.message?t.item.message:"Upload failed"]}):t.item.status===x.nW.complete?(0,o.jsxs)("p",{className:"text-sm font-medium text-gray-900 flex items-center gap-2",children:[(0,o.jsx)(W.LW,{})," ",t.item.message?t.item.message:"Upload Successful"]}):t.item.status===x.nW.upload_complete?(0,o.jsxs)("p",{className:"text-sm font-medium text-gray-900 flex items-center gap-2",children:[(0,o.jsx)(W.LW,{})," ",t.item.message?t.item.message:"Upload complete - Processing"]}):t.item.layerStatus===x.iO.processing?(0,o.jsxs)("p",{className:"text-sm font-medium text-gray-900 flex items-center gap-2",children:[(0,o.jsx)(W.LW,{})," ",t.item.message?t.item.message:"Processing in background..."]}):t.item.status===x.nW.processing_las||t.item.status===x.nW.processing?(0,o.jsxs)("p",{className:"text-sm font-medium text-gray-900 flex items-center gap-2",children:[(0,o.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Processing..."]}):t.item.status===x.nW.processing_tour?(0,o.jsxs)("p",{className:"text-sm font-medium text-gray-900 flex items-center gap-2",children:[(0,o.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Processing tour..."]}):t.item.type===x.dP.delete_tour?(0,o.jsxs)("p",{className:"text-sm font-medium text-gray-900 flex items-center gap-2",children:[(0,o.jsx)("span",{className:"loading loading-spinner loading-xs"}),"Deleting tour..."]}):(0,o.jsxs)("p",{className:"text-sm font-medium text-gray-900 flex items-center gap-2",children:[(0,o.jsx)("span",{className:"loading loading-spinner loading-xs"}),t.item.progress<100?`Uploading in progress (${t.item.progress}%)`:`Processing (${t.item.progress}%)`]}),(0,o.jsx)("p",{className:"mt-1 text-sm text-gray-500",title:t.item.title,children:t.item.title.length>28?`${t.item.title.slice(0,28)}...`:t.item.title})]})]})}),t.item&&t.item.status===x.nW.upload_complete?(0,o.jsx)("div",{className:"flex flex-col justify-center border-l border-gray-200 w-[22%]",children:(0,o.jsx)("button",{onClick:t.onClose,className:"px-2 cursor-pointer w-full border border-transparent rounded-none h-1/2 flex items-center justify-center text-sm font-medium opacity-30 hover:opacity-40",children:"Close"})}):t.item&&t.item.status===x.nW.complete?(0,o.jsxs)("div",{className:`flex flex-col border-l border-gray-200 w-[22%] ${a?"justify-between":"justify-center"}`,children:[(a||t.item.type===x.dP.tour)&&(0,o.jsx)("button",{id:"show-complete-upload",onClick:()=>{e.map.current&&(e.map.current.flyTo({center:[t.item.coordinates.lon,t.item.coordinates.lat],zoom:15,duration:eB.AD}),t.item.type===x.dP.tour&&(0,v.Ne)(e.map,t.item.coordinates.lat,t.item.coordinates.lon,e.markerRef),t.onClose())}
15,className:"px-2 w-full border-b rounded-r-lg border-black/10 flex items-center h-1/2 justify-center text-sm font-medium text-tt-blue hover:text-tt-blue/80 focus:outline-none","data-testid":"show-complete-upload-btn",children:"Show"}),(0,o.jsx)("button",{onClick:t.onClose,className:"px-2 w-full border border-transparent rounded-none h-1/2 flex items-center justify-center text-sm font-medium opacity-30 hover:opacity-40",children:"Close"})]}):100===t.item.progress&&t.item.status!=x.nW.complete&&t.item.status!=x.nW.error?null:(0,o.jsx)("div",{className:"flex flex-col justify-center border-l border-gray-200 w-[22%]",children:(0,o.jsx)("button",{onClick:t.onClose,className:"px-2 w-full border border-transparent rounded-none h-1/2 flex items-center justify-center text-sm font-medium opacity-30 hover:opacity-40",children:t.item.status===x.nW.error?"Dismiss":"Cancel"})})]}),(0,o.jsx)("div",{className:"uploading-progress",children:(0,o.jsx)("div",{className:"uploading-progress-bar",children:(0,o.jsx)("div",{className:`${t.item.type!==x.dP.delete_tour?"uploading-progress-bar-elapsed":"deleting-progress-bar-elapsed"} rounded-b-3xl`,style:{width:`${t.item.progress}%`}})})})]})};return(0,o.jsx)(o.Fragment,{})}let am=({showIfcModal:e,setShowIfcModal:t,lat:a,lon:r,project:s,map:l,user:i,customLayers:n,setCustomLayers:c,setShowEditModelMenu:d,setBottomMenuOpen:u})=>{let p=(0,ex.u)(),m=x.S$.gigabyte,[f,g]=(0,h.useState)(!1),[y,b]=(0,h.useState)("Draft"),[j,w]=(0,h.useState)(""),[v,N]=(0,h.useState)(null),[S,k]=(0,h.useState)(null),[_,C]=(0,h.useState)(""),L=(0,eD.l)(),D=async()=>{await (0,ai.q$)(p,i,s,l,"IFC",j,w,y,b,L,A,g,n,c,d,u,void 0,void 0,v,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,a,r,S)},A=()=>{document.getElementById("add-ifc-modal").click(),t(!1),N(null),k(null)};return(0,o.jsxs)("div",{className:"flex flex-col h-full justify-between",children:[(0,o.jsx)("input",{type:"checkbox",id:"add-ifc-modal",className:"modal-toggle",checked:e,readOnly:!0}),(0,o.jsxs)("div",{className:" flex flex-col",children:[(0,o.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,o.jsx)("span",{className:"label-text text-black",children:"Upload Layer Scope"}),(0,o.jsxs)("select",{value:y,className:"text-black select select-bordered",onChange:e=>b(e.target.value),children:[(0,o.jsx)("option",{value:"Draft",children:"Draft"},0),(0,o.jsx)("option",{value:"Published",children:"Published"},1)]})]}),null===v&&null===S?(0,o.jsxs)("div",{children:[(0,o.jsx)(eL.l,{types:["ifc","glb","gltf"],name:"file",classes:"file-uploader",handleChange:e=>{e.size>m?alert(`File size exceeds the limit of ${m/x.S$.gigabyte}GB. Please upload a supported file size.`):(C(e.name),N(e))},children:(0,o.jsxs)("div",{className:"file-uploader-box mt-5 mb-3",children:[(0,o.jsx)(W.v4w,{size:18,className:"flex opacity-50"}),(0,o.jsx)("span",{className:"opacity-50 mt-1",children:"Upload IFC File ( .ifc, .glb, .gltf )"}),(0,o.jsxs)("span",{className:"opacity-50",children:["Max: ",`${m/x.S$.gigabyte} GB`]})]})}),(0,o.jsx)(eM.A,{modalHtml:"sharepoint-select-ifc-modal",onChange:e=>{k(e)}})]}):(0,o.jsx)("div",{children:(0,o.jsx)("div",{className:"file-uploader-metadata my-3",children:(0,o.jsx)("div",{className:"file-uploader-metadata-text",children:(0,o.jsxs)(o.Fragment,{children:[v&&!S&&(0,o.jsx)("span",{title:_,children:_.length>40?_.slice(0,40)+"...":_}),S&&!v&&(0,o.jsx)("span",{title:_,children:S.name.length>40?S.name.slice(0,40)+"...":S.name}),(0,o.jsx)(W.fUT,{className:"file-uploader-delete",onClick:()=>{N(null),k(null)}})]})})})}),(0,o.jsxs)("div",{className:"mt-2 flex flex-col gap-2",children:[(0,o.jsx)("span",{className:"label-text",children:"Layer Name"}),(0,o.jsx)("input",{type:"text",placeholder:"Layer Name",className:"text-black input ",onChange:e=>w(e.target.value),value:j})]})]}),(0,o.jsx)("div",{className:"align-items justify-content w-full pb-4 tablet:pb-0",children:f?(0,o.jsx)("button",{className:"btn tt-blue-button text-white mt-4 w-full",disabled:!0,children:(0,o.jsx)("span",{className:"loading loading-spinner loading-sm"})}):(0,o.jsx)("button",{className:"btn tt-blue-button text-white mt-4 w-full",onClick:D,children:"Add"})})]})};class ah{controller;timeoutLabel;debounce;constructor(e=0){this.controller=new AbortController,this.timeoutLabel=null,this.debounce=e}
15async makeRequest(e,t,a,r,s){this.abortCurrentRequest();try{if(!a||this.debounce<=0)return await this.request(e,t,r);this.timeoutLabel&&clearTimeout(this.timeoutLabel),this.timeoutLabel=setTimeout(async()=>{await this.request(e,t,r)},this.debounce)}catch(e){s("",e)}}async request(e,t,a){let r=await (0,_.x)(e,{...t,signal:this.controller.signal});a&&await a(r)}abortCurrentRequest(){this.controller.abort(),this.controller=new AbortController}}let ax=new ah,af=new ah(1500),ag=async(e,t,a=!1,r=!1)=>new Promise((s,l)=>{af.makeRequest("/map/get-dates",{method:"GET",params:{lat:e,lon:t,pano:a}},r,async e=>{s(e)},async e=>{l(e)})});var ay=a(14796),ab=a(54065),aj=a(44845),aw=a(52075),av=a(11257);let aN={MODIS_Aqua_CorrectedReflectance_TrueColor:9,VIIRS_SNPP_DayNightBand_At_Sensor_Radiance:8,MODIS_Aqua_Land_Surface_Temp_Day:7,VIIRS_NOAA20_Brightness_Temp_BandI5_Day:9,AIRS_L3_Carbon_Monoxide_500hPa_Volume_Mixing_Ratio_Daily_Day:6,OMI_Ozone_DOAS_Total_Column:6,AIRS_L3_Methane_400hPa_Volume_Mixing_Ratio_Daily_Day:6,MODIS_Water_Mask:9,MODIS_Terra_L3_NDSI_Snow_Cover_Daily:8,"MODIS_Combined_Flood_1-Day":9,"MODIS_Combined_Flood_2-Day":9,"MODIS_Combined_Flood_3-Day":9,AMSRU2_Total_Precipitable_Water_Day:6,MODIS_Terra_Water_Vapor_5km_Day:6,AIRS_Precipitation_Day:6,AIRS_Precipitation_Night:6,GPW_Population_Density_2020:7},aS=(e,t,a,r,s,l)=>{if(s){let i=new URLSearchParams({SERVICE:"WMTS",VERSION:"1.0.0",REQUEST:"GetTile",LAYER:t,STYLE:"default",TILEMATRIXSET:a,FORMAT:r,PRIORITY:"mostRecent",...l?{TIME:l}:{}});return`${e}/wmts/${encodeURIComponent(s)}?${i.toString()}&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}`}if(e.includes("eox.at"))return`${e}/wmts/1.0.0/${t}/default/g/{z}/{y}/{x}.jpg`;let i=l||"default",n="image/jpeg"===r?"jpg":"png";return`${e}/wmts/epsg3857/best/${t}/default/${i}/${a}/{z}/{y}/{x}.${n}`},ak=(e,t,a,r,s,l=256,i=256)=>{let n=new URLSearchParams({REQUEST:"GetMap",SERVICE:"WMS",VERSION:"1.3.0",LAYERS:t,FORMAT:a,CRS:"EPSG:3857",WIDTH:l.toString(),HEIGHT:i.toString(),STYLE:"default",TRANSPARENT:r?"true":"false",...s?{TIME:s}:{},PRIORITY:"mostRecent"});return`${e}?${n.toString()}&BBOX={bbox-epsg-3857}`},a_=e=>{let t=e?.current;if(t)try{for(let e of t.getStyle()?.layers??[])if(e.id.includes("label"))return e.id}catch{}},aC=(e,t,a,r,s=!1)=>
15{if(!(0,eo.fu)(e,t,()=>aC(e,t,a,r,s)))return e;let l=JSON.parse(localStorage.getItem("project")||"{}").sentinel_data,i=a_(e),n="";if(n=a?a instanceof Date?a.toISOString().slice(0,10):a:tB()().toDate().toISOString().slice(0,10),!e.current.getLayer(t)){let a;if(s){let e=new Date(n+"T23:59:59Z"),t=new Date(e);t.setMonth(t.getMonth()-6),a=`${t.toISOString()}/${e.toISOString()}`}else a=`${n}T00:00:00Z/${n}T23:59:59Z`;let o=aS("https://services.sentinel-hub.com/ogc",r,"PopularWebMercator256",s?"image/jpeg":"image/png",l,a);e.current.addLayer({id:t,source:{type:"raster",tiles:[o],tileSize:256},type:"raster",minzoom:5.5},i),(0,k.y)(e.current)}return e},aL=(e,t,a,r=!0,s=null,l="image/png")=>{if(!(0,eo.fu)(e,t,()=>aL(e,t,a,r,s,l)))return e;let i=a_(e);if(r&&!s?s=tB()().toDate().toISOString().slice(0,10):r||(s=null),!e.current.getLayer(t)){let r=aN[a]??9,n=aS("https://gibs.earthdata.nasa.gov",a,`GoogleMapsCompatible_Level${r}`,l,null,s);e.current.addLayer({id:t,source:{type:"raster",tiles:[n],tileSize:256,maxzoom:r},type:"raster"},i),(0,k.y)(e.current)}return e},aD=(e,t,a)=>{if(!(0,eo.fu)(e,t,()=>aD(e,t,a)))return e;let r=a_(e);if(a||(a=tB()().toDate().toISOString().slice(0,10)),!e.current.getLayer(t)){let a=ak("https://nowcoast.noaa.gov/geoserver/hazards/tropical_cyclones/ows","active_tropical_cyclones","image/png",!0,null,4096,4096);e.current.addLayer({id:t,type:"raster",source:{type:"raster",tiles:[a],tileSize:4096,minzoom:0,maxzoom:20},paint:{"raster-resampling":"nearest"}},r),(0,k.y)(e.current)}return e},aA=(e,t,a)=>{if(!(0,eo.fu)(e,t,()=>aA(e,t,a)))return e;let r=a_(e);if(a||(a=tB()().toDate().toISOString().slice(0,10)),!e.current.getLayer(t)){let s=ak("https://gibs.earthdata.nasa.gov/wms/epsg3857/best/wms.cgi","MODIS_Combined_Thermal_Anomalies_All","image/png",!0,a);e.current.addLayer({id:t,source:{type:"raster",tiles:[s],tileSize:256},type:"raster"},r),(0,k.y)(e.current)}return e},aM=(e,t,a)=>{if(!(0,eo.fu)(e,t,()=>aM(e,t,a)))return e;let r=a_(e);if(!e.current.getLayer(t)){let a=aS("https://tiles.maps.eox.at","terrain_3857","","image/jpeg");e.current.addLayer({id:t,source:{type:"raster",tiles:[a],tileSize:256},type:"raster"},r),(0,k.y)(e.current)}return e},aE=(e,t,a)=>{if(!(0,eo.fu)(e,t,()=>aE(e,t,a)))return e;let r=a_(e);if(!e.current.getLayer(t)){let a=aS("https://tiles.maps.eox.at","s2cloudless-2023_3857","","image/jpeg");e.current.addLayer({id:t,source:{type:"raster",tiles:[a],tileSize:256},type:"raster"},r),(0,k.y)(e.current)}return e},aT=async(e,t,a,r,s,l)=>{let i=await (0,av.en)(t.project_uuid),n=async()=>{i.forEach(async a=>{(a.status===x.iO.processing||a.status===x.iO.initial)&&(0,aj.X)(a.id,e,t,a.status,s,l),await (0,aw.w6)(a,e,t)})};return await n(),e.current.on("style.load",async()=>{await aT(e,t,a,r,s,l)}),[e,i]};async function aI(e){return await (0,_.x)("/dashboard/embed",{method:"POST",json:{projectId:e}})}async function aP(e){return await (0,_.x)("/dashboard/guest-token",{method:"POST",json:{projectId:e}})}
15async function aF(e){await (0,_.x)("/dashboard/dataset-access",{method:"POST",json:{projectId:e.project_uuid}})}var aO=a(29782),aR=a(14104);let a$='[data-fusionmap-additional-attribution="true"]',az=null,aU=null,aW=null,aB=!1,aV=()=>document.getElementById("comparison-container")??document,aG=e=>{let t=aV().querySelectorAll(".mapboxgl-ctrl-attrib-inner");return t.length?(t.forEach(t=>{let a=t.querySelector(a$);if(a){a.textContent=e;return}let r=document.createElement("a");r.setAttribute("data-fusionmap-additional-attribution","true"),r.textContent=e,t.appendChild(r)}),t.length):0},aJ=e=>{let t=aU;!t||aG(t)>0||e>=20||(az=setTimeout(()=>aJ(e+1),100))},aq=()=>{aW&&(aW.disconnect(),aW=null),aB=!1},aY=e=>{if("u">typeof document){let t;aU=e,az&&(clearTimeout(az),az=null),aG(e),"function"==typeof requestAnimationFrame?requestAnimationFrame(()=>aG(e)):setTimeout(()=>aG(e),0),aJ(0),aq(),t=aV(),(aW=new MutationObserver(()=>{aB||(aB=!0,(globalThis.requestAnimationFrame??(e=>setTimeout(e,0)))(()=>{aB=!1,aG(e)}))})).observe(t,{childList:!0,subtree:!0})}},aH=()=>{"u"<typeof document||(aV().querySelectorAll(a$).forEach(e=>e.remove()),aU=null,az&&(clearTimeout(az),az=null),aq())};var aZ=a(38521),aX=a(24387);let aK=null;var aQ=a(56276);let a0=e=>{let t=new Date(e);return t.setDate(t.getDate()+m.PW),Math.max(Math.ceil((t.getTime()-Date.now())/864e5),0)},a1=e=>{if(!e)return;let t=new Date(e.next_billing_date),a=new Date,r=Math.ceil((t.getTime()-a.getTime())/864e5);return e.cancel_at_period_end?r:null};var a2=a(90953),a5=a(32937);let a3={nasaGlobe:{layerName:"Daily Light",imgSrc:"/images/NASAGlobe.webp",locked:!1,description:"These images offer a realistic portrayal of the Earth's surface, encompassing land, oceans, and atmospheric attributes. The MODIS Corrected Reflectance images are accessible in near real-time only. The imagery itself maintains a resolution of 250 m, and new images are generated daily.",addLayer:(e,t,a)=>aL(e,t,"MODIS_Aqua_CorrectedReflectance_TrueColor",!0,a,"image/jpeg"),satellite:"modis",attribution:"\xa9 NASA Worldview",source:"NASA Worldview",updateFrequency:"Every 24 hours",wmsLayerName:"MODIS_Aqua_CorrectedReflectance_TrueColor",maxzoom:aN.MODIS_Aqua_CorrectedReflectance_TrueColor},nasaGlobeNight:{layerName:"Daily Night",imgSrc:"/images/nasaNight.webp",locked:!1,description:"The Black Marble Nighttime At Sensor Radiance (Day/Night Band) layer uses the VIRRS satellite for daily top-of-atmosphere nighttime radiance. Shown in grayscale with log10 conversion, it's expressed in radiance units (nW/(cm2 sr)), stretched up to 38 nW/(cm2 sr). This enhances city light details compared to traditional resampled Nighttime Imagery.",addLayer:(e,t,a)=>aL(e,t,"VIIRS_SNPP_DayNightBand_At_Sensor_Radiance",!0,a),satellite:"VIIRS",attribution:"\xa9 NASA Worldview",source:"NASA Worldview",updateFrequency:"Every 24 hours",wmsLayerName:"VIIRS_SNPP_DayNightBand_At_Sensor_Radiance",maxzoom:aN.VIIRS_SNPP_DayNightBand_At_Sensor_Radiance},honc:{layerName:"Natural Color",imgSrc:"/images/honc.webp",locked:!1,description:"This layer presents Earth using stunning natural color photos. It employs highlight optimization to prevent overexposure and balance exposure levels.",addLayer:(e,t,a,r=!1)=>aC(e,t,a,"HONC",r),satellite:"sentinel-2-l1c",attribution:"\xa9 Copernicus \xa9 SentinelHub",source:"ESA Copernicus",updateFrequency:"Every 2-5 days",mergedDateEnabled:!0,isSentinelLayer:!0},sar:{layerName:"SAR",imgSrc:"/images/sar_cropped.webp",locked:!1,description:"Sentinel-1 VV Decibel Gamma0 Radiometric Terrain Corrected is a specialized data product that comes from the Sentinel-1 satellite's VV polarization mode. It provides imagery with gamma0 correction applied, and the data is further processed to compensate for variations in terrain. This product offers enhanced radar data for a wide range of applications, including monitoring land surface changes, identifying terrain features, and studying natural phenomena.",addLayer:(e,t,a,r=!1)=>aC(e,t,a,"VV",r),satellite:"sentinel-1-grd",attribution:"\xa9 Copernicus \xa9 SentinelHub",source:"ESA Copernicus",updateFrequency:"Every 5-12 days",mergedDateEnabled:!0,isSentinelLayer:!0},nearInfrared:{layerName:"Near Infrared",imgSrc:"/images/false_color_cropped.webp",locked:!1,description:"The Near Infrared composite uses near-infrared (NIR), red, and green bands. Because vegetation strongly reflects near-infrared light, it appears in varying shades of bright red. This makes the Near Infrared layer highly effective for visualizing plant health, distinguishing vegetation from other land cover types, and monitoring variations in agricultural and forestry areas.",addLayer:(e,t,a,r=!1)=>aC(e,t,a,"NEAR_IR",r),satellite:"sentinel-2-l1c",attribution:"\xa9 Copernicus \xa9 SentinelHub",source:"ESA Copernicus",updateFrequency:"Every 2-5 days",mergedDateEnabled:!0,isSentinelLayer:!0,isNew:!0,threshold:8.5}},a4={wildfires:{layerName:"Wildfires",imgSrc:"/images/wildfire_cropped.webp",locked:!1,description:"This layer utilizes Sentinel-2 data to visualize wildfires. It merges natural color as the background along with NIR/SWIR data to enhance smoke penetration and capture finer details. Fires are represented by vibrant red and orange colors.",addLayer:(e,t,a,r=!1)=>aC(e,t,a,"WILDFIRES",r),satellite:"sentinel-2-l1c",attribution:"\xa9 Copernicus \xa9 SentinelHub",source:"ESA Copernicus",updateFrequency:"Every 2-5 days",mergedDateEnabled:!0,isSentinelLayer:!0},burnedArea:{layerName:"Burned Area",imgSrc:"/images/burned_area_cropped.webp",locked:!1,description:"This layer is designed to identify recently burned areas. It marks burned regions with red-colored pixels, while the rest of the pixels are displayed in true colors.",addLayer:(e,t,a,r=!1)=>aC(e,t,a,"BURNED_AREA",r),satellite:"sentinel-2-l1c",attribution:"\xa9 Copernicus \xa9 SentinelHub",source:"ESA Copernicus",updateFrequency:"Every 2-5 days",mergedDateEnabled:!0,isSentinelLayer:!0},vegetation:{layerName:"Vegetation",imgSrc:"/images/vegetation_cropped.webp",locked:!1,description:"The normalized difference vegetation index (NDVI) is a powerful indicator used to assess green vegetation. By analyzing how plants reflect light at specific wavelengths, NDVI provides valuable insights into the health and condition of vegetation.",addLayer:(e,t,a,r=!1)=>aC(e,t,a,"NDVI",r),satellite:"sentinel-2-l1c",attribution:"\xa9 Copernicus \xa9 SentinelHub",source:"ESA Copernicus",updateFrequency:"Every 2-5 days",mergedDateEnabled:!0,isSentinelLayer:!0,threshold:8.5},sceneClass:{layerName:"Scene Class",imgSrc:"/images/scene_class_cropped.webp",locked:!1,description:"Scene classification was created to differentiate between various types of pixels in Sentinel-2 data into different classes. These classes encompass a wide range of features, such as clouds, vegetation, soils/desert, water, and snow, enabling a comprehensive understanding of the different elements present in the scene.",addLayer:(e,t,a,r=!1)=>aC(e,t,a,"S2CLASS",r),satellite:"sentinel-2-l1c",attribution:"\xa9 Copernicus \xa9 SentinelHub",source:"ESA Copernicus",updateFrequency:"Every 2-5 days",mergedDateEnabled:!0,isSentinelLayer:!0},urbanClass:{layerName:"Urban Class",imgSrc:"/images/urbanClassified.webp",locked:!1,description:"The Urban Classified script's goal is to distinguish built-up spaces from barren ground, vegetation, and water. High moisture zones appear in blue, built-up regi
15ons in white, vegetation in green, while brown tones signify barren ground and other areas.",addLayer:(e,t,a,r=!1)=>aC(e,t,a,"URBANCLASSIFIED",r),satellite:"sentinel-2-l1c",attribution:"\xa9 Copernicus \xa9 SentinelHub",source:"ESA Copernicus",updateFrequency:"Every 2-5 days",mergedDateEnabled:!0,isSentinelLayer:!0},swir:{layerName:"SWIR",imgSrc:"/images/swir.webp",locked:!1,description:"SWIR measures water in plants/soil via absorption of short wave infrared wavelengths. SWIR bands distinguish cloud types, snow/ice (visible as white), and map fire damage/geology. Vegetation is green, soils/buildings brown, and water black in the composite. SWIR detects burned land and varies with rock types for geology mapping.",addLayer:(e,t,a,r=!1)=>aC(e,t,a,"SWIR",r),satellite:"sentinel-2-l1c",attribution:"\xa9 Copernicus \xa9 SentinelHub",source:"ESA Copernicus",updateFrequency:"Every 2-5 days",mergedDateEnabled:!0,isSentinelLayer:!0},ndwi:{layerName:"Water",imgSrc:"/images/ndwi_cropped.webp",locked:!1,description:"NDWI layer from Sentinel-2 satellite is a data product that utilizes the Normalized Difference Water Index (NDWI) to highlight and quantify water bodies' presence and extent. It is derived from Sentinel-2 satellite imagery and provides valuable information about water-related features, such as lakes, rivers, and wetlands. This layer is useful for monitoring water resources, assessing changes in water bodies over time, and studying the impact of water-related events on the environment.",addLayer:(e,t,a,r=!1)=>aC(e,t,a,"NDWI_COLOR2",r),satellite:"sentinel-2-l1c",attribution:"\xa9 Copernicus \xa9 SentinelHub",source:"ESA Copernicus",updateFrequency:"Every 2-5 days",mergedDateEnabled:!0,isSentinelLayer:!0},weather:{layerName:"Weather",imgSrc:"/images/weather_cropped.webp",locked:!1,description:"Weather layer provides real-time and up-to-date weather information overlaid on the map. This layer visually presents various weather conditions and elements, allowing users to quickly understand the current weather situation within the map's geographic context.",addLayer:(e,t,a)=>(a||(a=tB()().toDate().toISOString().slice(0,10)),fetch("https://api.rainviewer.com/public/weather-maps.json").then(e=>e.json()).then(a=>{a.radar.past.slice(0,1).forEach(r=>{e.current.getLayer(t)||(e.current.addLayer({id:t,type:"raster",source:{type:"raster",tiles:[a.host+r.path+"/256/{z}/{x}/{y}/2/1_0.png"],tileSize:256},layout:{visibility:"visible"},minzoom:0,maxzoom:12}),(0,k.y)(e.current))})}),e),satellite:null,attribution:"OpenWeatherMap",source:"OpenWeatherMap",updateFrequency:"Every 15 minutes",calendarEnabled:!1},temperature:{layerName:"Land Temperature",imgSrc:"/images/TemperatureLayer.webp",locked:!1,description:"Land Surface Temperature, measured in Kelvin (K), refers to the thermal state of the Earth's outer layer. Differing from air temperature which concentrates on the atmospheric conditions, this measurement captures the warmth radiating from diverse features on the Earth's surface—ranging from the heat-absorbing sands of deserts and the ice-clad stretches to the leafy shelter of trees and the heat retained by human-made structures like buildings and roads.",addLayer:(e,t,a)=>aL(e,t,"MODIS_Aqua_Land_Surface_Temp_Day",!0,a),satellite:"MODIS",attribution:"\xa9 NASA Worldview",source:"NASA Worldview",updateFrequency:"Every 24 hours",wmsLayerName:"MODIS_Aqua_Land_Surface_Temp_Day",maxzoom:aN.MODIS_Aqua_Land_Surface_Temp_Day},brightnessTemperature:{layerName:"Brightness Temperature",imgSrc:"/images/brightnessTemperature.webp",locked:!1,description:"VIIRS Brightness Temperature layer in Kelvin (K) shows relative temperature variations from top-of-the-atmosphere radiances. It aids in distinguishing features in clouds and clear land, useful for identifying land, sea ice, and open water in polar regions during winter, especially in cloud-free areas.",addLayer:(e,t,a)=>aL(e,t,"VIIRS_NOAA20_Brightness_Temp_BandI5_Day",!0,a),satellite:"VIIRS",attribution:"\xa9 NASA Worldview",source:"NASA Worldview",updateFrequency:"Every 24 hours",wmsLayerName:"VIIRS_NOAA20_Brightness_Temp_BandI5_Day",maxzoom:aN.VIIRS_NOAA20_Brightness_Temp_BandI5_Day},carbonMonoxide:{layerName:"Carbon Monoxide",imgSrc:"/images/CarbonMonoxideLayer.webp",locked:!1,description:"The Carbon Monoxide layer, measured in parts per billion by volume at 500 hPa (around 5500 meters above sea level), reflects a pollutant originating from incomplete burning of fuels like gasoline, natural gas, oil, coal, and wood. It persists for about a month and can affect air quality and global climate patterns, largely due to human activities like vehicle emissions.",addLayer:(e,t,a)=>aL(e,t,"AIRS_L3_Carbon_Monoxide_500hPa_Volume_Mixing_Ratio_Daily_Day",!0,a),satellite:"AIRS",attribution:"\xa9 NASA Worldview",source:"NASA Worldview",updateFrequency:"Every 24 hours",wmsLayerName:"AIRS_L3_Carbon_Monoxide_500hPa_Volume_Mixing_Ratio_Daily_Day",maxzoom:aN.AIRS_L3_Carbon_Monoxide_500hPa_Volume_Mixing_Ratio_Daily_Day},ozone:{layerName:"Ozone",imgSrc:"/images/ozone.webp",locked:!1,description:"The OMI Total Ozone Differential Optical Absorption Spectroscopy (DOAS) layer, quantified in Dobson Units (DU), measures total ozone content. It's part of the Ozone Monitoring Instrument (OMI) and uses the DOAS technique, centered at 341 nm. This technique estimates ozone column using longer wavelengths compared to TOMS algorithm, making it widely used for trace gas analysis.",addLayer:(e,t,a)=>
15aL(e,t,"OMI_Ozone_DOAS_Total_Column",!0,a),satellite:"OMI",attribution:"\xa9 NASA Worldview",source:"NASA Worldview",updateFrequency:"Every 24 hours",wmsLayerName:"OMI_Ozone_DOAS_Total_Column",maxzoom:aN.OMI_Ozone_DOAS_Total_Column},methane:{layerName:"Methane",imgSrc:"/images/methane.webp",locked:!1,description:"The Methane layer indicates atmospheric methane levels in parts per billion by volume at the 400 hPa pressure level, about 7200 meters above sea level. Methane emissions come from coal, natural gas, and oil extraction, as well as agriculture (especially livestock), organic waste decomposition, and wildfires.",addLayer:(e,t,a)=>aL(e,t,"AIRS_L3_Methane_400hPa_Volume_Mixing_Ratio_Daily_Day",!0,a),satellite:"AIRS",attribution:"\xa9 NASA Worldview",source:"NASA Worldview",updateFrequency:"Every 24 hours",wmsLayerName:"AIRS_L3_Methane_400hPa_Volume_Mixing_Ratio_Daily_Day",maxzoom:aN.AIRS_L3_Methane_400hPa_Volume_Mixing_Ratio_Daily_Day},waterMask:{layerName:"Water Mask",imgSrc:"/images/waterMask.jpg",locked:!1,description:"The 250m water mask product utilizes the SWBD (SRTM Water Body Data) and complement it with information from 250m MODIS data to create a complete representation of global surface water. For the purpose of modeling it may be useful to perform an intelligent interpolation to close those gaps in small rivers.",addLayer:(e,t)=>aL(e,t,"MODIS_Water_Mask",!1,null),satellite:"MODIS",attribution:"\xa9 NASA Worldview",source:"NASA Worldview",updateFrequency:"Every 24 hours",maxzoom:aN.MODIS_Water_Mask},snowCover:{layerName:"Snow Cover",imgSrc:"/images/snowCover.jpg",locked:!1,description:"The MODIS Normalized Difference Snow Index (NDSI) snow cover layer shows the presence of snow cover over land and water bodies as an index related to the presence of snow. NDSI snow cover is derived from the cloud free snow reflectance sensed by the MODIS instrument, and hence this layer shows presence of snow during day time and under cloud clear condition only.",addLayer:(e,t,a)=>aL(e,t,"MODIS_Terra_L3_NDSI_Snow_Cover_Daily",!0,a),satellite:"MODIS",attribution:"\xa9 NASA Worldview",source:"NASA Worldview",updateFrequency:"Every 24 hours",wmsLayerName:"MODIS_Terra_L3_NDSI_Snow_Cover_Daily",maxzoom:aN.MODIS_Terra_L3_NDSI_Snow_Cover_Daily},thermalAnomalies:{layerName:"Thermal Anomalies",imgSrc:"/images/thermalAnomalies.jpg",locked:!1,description:"The Aqua and Terra MODIS Fire and Thermal Anomalies layer shows active fire detections and thermal anomalies, such as volcanoes, and gas flares. The fire layer is useful for studying the spatial and temporal distribution of fire, to locate persistent hot spots such as volcanoes and gas flares, to locate the source of air pollution from smoke that may have adverse human health impacts.",addLayer:aA,satellite:"MODIS",attribution:"\xa9 NASA Worldview",source:"NASA Worldview",updateFrequency:"Every 24 hours",wmsLayerName:"MODIS_Combined_Thermal_Anomalies_All"},terrain:{layerName:"Terrain",imgSrc:"/images/terrain.png",locked:!1,description:"This layer offers a terrain-based visualization using data from OpenStreetMap. It presents detailed topographical features with subtle shading, ideal for a clear background map that highlights elevation and natural landforms.",addLayer:aM,satellite:"N/A",attribution:"\xa9 EOX",source:"EOX",updateFrequency:"Every 2-5 days",calendarEnabled:!1},cloudless:{layerName:"Cloud-Free 2023",imgSrc:"/images/cloudless.jpg",locked:!1,description:" Utilizing Sentinel-2 satellite imagery, this layer provides a seamless, cloud-free view of Earth's surface for 2023. It combines multiple images to deliver a clear, uninterrupted visualization, showcasing natural landscapes and vegetation with high spatial detail.",addLayer:aE,satellite:"sentinel-2",attribution:"\xa9 EOX",source:"EOX",updateFrequency:"Every 2-5 days"},floodOne:{layerName:"Flood 1-Day",imgSrc:"/images/flood_1.png",locked:!1,description:"A daily global map identifying flood events using MODIS Surface Reflectance data. The Flood Product is available for 3 compositing periods: 1-day, 2-day, and 3-day. For each composite, water detections for all observations over the compositing period are accumulated, and if the total exceeds the required threshold, the pixel is marked as water. This approach allows for timely monitoring of floods worldwide.",addLayer:(e,t,a)=>aL(e,t,"MODIS_Combined_Flood_1-Day",!0,a),satellite:"MODIS",attribution:"\xa9 NASA Worldview",source:"NASA Worldview",updateFrequency:"Every 24 hours",wmsLayerName:"MODIS_Combined_Flood_1-Day",maxzoom:aN["MODIS_Combined_Flood_1-Day"]},floodTwo:{layerName:"Flood 2-Day",imgSrc:"/images/flood_2.png",locked:!1,description:"A daily global map identifying flood events using MODIS Surface Reflectance data. The Flood Product is available for 3 compositing periods: 1-day, 2-day, and 3-day. For each composite, water detections for all observations over the compositing period are accumulated, and if the total exceeds the required threshold, the pixel is marked as water. This approach allows for timely monitoring of floods worldwide.",addLayer:(e,t,a)=>aL(e,t,"MODIS_Combined_Flood_2-Day",!0,a),satellite:"MODIS",attribution:"\xa9 NASA Worldview",source:"NASA Worldview",updateFrequency:"Every 24 hours",wmsLayerName:"MODIS_Combined_Flood_2-Day",maxzoom:aN["MODIS_Combined_Flood_2-Day"]},floodThree:{layerName:"Flood 3-Day",imgSrc:"/images/flood_3.png",locked:!1,description:"A daily global map identifying flood events using MODIS Surface Reflectance data. The Flood Product is available for 3 compositing periods: 1-day, 2-day, and 3-day. For each composite, water detections for all observations over the compositing period are accumulated, and if the total exceeds the required threshold, the pixel is marked as water. This approach allows for timely monitoring of floods worldwide.",addLayer:(e,t,a)=>aL(e,t,"MODIS_Combined_Flood_3-Day",!0,a),satellite:"MODIS",attribution:"\xa9 NASA Worldview",source:"NASA Worldview",updateFrequency:"Every 24 hours",wmsLayerName:"MODIS_Combined_Flood_3-Day",maxzoom:aN["MODIS_Combined_Flood_3-Day"]},precipitable:{layerName:"Precipitable Water (Deprecated as of 2025-09-01)",imgSrc:"/images/precipitable.jpg",locked:!1,description:"The Total Precipitable Water (Day) layer displays precipitable water totals over the ocean in millimeters (mm), using data from the AMSR2 instrument aboard the GCOM-W1 satellite. This instrument provides global measurements of water-related parameters, aiding in the study of global water cycles.",addLayer:(e,t,a)=>aL(e,t,"AMSRU2_Total_Precipitable_Water_Day",!0,a),satellite:"AMSR2",attribution:"\xa9 NASA Worldview",source:"NASA Worldview",updateFrequency:"Every 24 hours",wmsLayerName:"AMSRU2_Total_Precipitable_Water_Day",maxzoom:aN.AMSRU2_Total_Precipitable_Water_Day},waterVapor:{layerName:"Water Vapor (Day)",imgSrc:"/images/waterVapor.jpg",locked:!1,description:"The MODIS Precipitable Water Vapor layer shows the total amount of water vapor in a 5 km by 5 km column of the atmosphere, measured in centimeters (cm), using data from the MODIS instrument aboard the Terra satellite.",addLayer:(e,t,a)=>aL(e,t,"MODIS_Terra_Water_Vapor_5km_Day",!0,a),satellite:"MODIS",attribution:"\xa9 NASA Worldview",source:"NASA Worldview",updateFrequency:"Every 24 hours",wmsLayerName:"MODIS_Terra_Water_Vapor_5km_Day",maxzoom:aN.MODIS_Terra_Water_Vapor_5km_Day},precipitationDay:{layerName:"Precipitation (Day)",imgSrc:"/images/precipitationDay.jpg",locked:!1,description:"The AIRS Precipitation Estimate (Day) layer is an estimate of daily precipitation measured in millimeters (mm) using cloud-related parameters of cloud-top pressure, fractional cloud cover, and cloud-layer relative humidity.",addLayer:(e,t,a)=>aL(e,t,"AIRS_Precipitation_Day",!0,a),satellite:"AIRS",attribution:"\xa9 NASA Worldview",source:"NASA Worldview",updateFrequency:"Every 24 hours",wmsLayerName:"AIRS_Precipitation_Day",maxzoom:aN.AIRS_Precipitation_Day},precipitationNight:{layerName:"Precipitation (Night)",imgSrc:"/images/precipitationNight.jpg",locked:!1,description:" The AIRS Precipitation Estimate (Night) layer is an estimate of daily precipitation measured in millimeters (mm) using cloud-related parameters of cloud-top pressure, fractional cloud cover, and cloud-layer relative humidity.",addLayer:(e,t,a)=>aL(e,t,"AIRS_Precipitation_Night",!0,a),satellite:"AIRS",attribution:"\xa9 NASA Worldview",source:"NASA Worldview",updateFrequency:"Every 24 hours",wmsLayerName:"AIRS_Precipitation_Night",maxzoom:aN.AIRS_Precipitation_Night},population:{layerName:"Population 2020",imgSrc:"/images/population2020.png",locked:!1,description:" The Population Density, 2020 layer estimates the number of people per square kilometer using data from censuses and population registers. The information is adjusted to align with UN country population totals for 2020. It uses a grid system to show where people are distributed around the world, which can help in planning, resource allocation, and understanding population trends.",addLayer:(e,t)=>aL(e,t,"GPW_Population_Density_2020",!1,null),satellite:"MODIS",attribution:"\xa9 NASA Worldview",source:"NASA Worldview",updateFrequency:"-",maxzoom:aN.GPW_Population_Density_2020},storms:{layerName:"Storms",imgSrc:"/images/storms.png",locked:!1,description:"This layer is designed to track near real-time storm information reported by the NOS/Office of Coast Survey.",addLayer:aD,satellite:"N/A",attribution:"\xa9 NOS/Office of Coast Survey",source:"nowCOAST",updateFrequency:"Near real-time",calendarEnabled:!1,inlineLegendSrc:"/images/storms-legend.jpeg"}}
15,a8=({selected:e,imageSrc:t,label:a,descriptionLines:r,onClick:s,imageGrey:l=!1,beta:i=!1,isNew:n=!1})=>(0,o.jsxs)("div",{onClick:s,className:`items-center flex flex-row gap-3 p-2 rounded hover:bg-tt-blue/10 cursor-pointer border border-black/10 shadow-sm ${e?"bg-tt-blue/10":"bg-gray-50"}`,children:[(0,o.jsx)(d(),{src:t,alt:a,width:55,height:55,className:`transition rounded-md object-cover w-[55px] h-[55px] ${l?"grayscale":""}`}),(0,o.jsxs)("div",{className:"flex gap-[2px] text-xs flex-col",children:[(0,o.jsxs)("span",{className:"font-bold",children:[a,i&&(0,o.jsx)("span",{className:"badge bg-tt-blue/20 text-[11px] px-2 ml-1",children:"Beta"}),n&&(0,o.jsx)("span",{className:"beta-tag ml-1",children:"NEW"})]}),r.map((e,t)=>(0,o.jsxs)("span",{className:"text-xs opacity-60 flex gap-1 items-center",children:[(0,o.jsx)(e.icon,{})," ",e.text]},t))]})]}),a6=({label:e,onClick:t,fullWidth:a=!1})=>(0,o.jsx)("button",{className:`btn tt-blue-button ${a?"w-full":"flex-1"}`,onClick:t,children:e});function a7({clickedLayer:e,premiumUser:t,setStripeWindowOpen:a}){let r=(0,eV.H)(),s=(0,eG.JY)(),l=(0,e$.p)(),i=t===x.Jr.basic,n=(e,t)=>{e&&t&&(e.getLayer(t)&&e.removeLayer(t),e.getSource(t)&&e.removeSource(t))},c=i?(0,o.jsx)(a6,{label:"Subscribe",fullWidth:!0,onClick:()=>a(!0)}):s.splitViewEnabled?(0,o.jsxs)("div",{className:"flex flex-col gap-2 w-full",children:[(0,o.jsx)(a6,{label:"Apply to Both",fullWidth:!0,onClick:()=>{n(s.map.current,r.premiumLayer.layer?.layerName),n(s.altMap.current,r.altPremiumLayer.layer?.layerName),r.setPremiumLayer({selected:!0,layer:e}),r.setAltPremiumLayer({selected:!0,layer:e}),r.setPremiumLayerAddedToMap(!0),r.setAltPremiumLayerAddedToMap(!0),l.goBack()}}),(0,o.jsxs)("div",{className:"flex flex-row gap-2 w-full",children:[(0,o.jsx)(a6,{label:"Apply to Left",onClick:()=>{n(s.map.current,r.premiumLayer.layer?.layerName),r.setPremiumLayer({selected:!0,layer:e}),r.setPremiumLayerAddedToMap(!0),l.goBack()}}),(0,o.jsx)(a6,{label:"Apply to Right",onClick:()=>{let t=r.altPremiumLayer.layer?.layerName;n(s.altMap.current,t),r.setAltPremiumLayer({selected:!0,layer:e}),r.setAltDate(null),r.setAltPremiumLayerAddedToMap(!0),l.goBack()}})]})]}):(0,o.jsx)(a6,{label:"Apply Layer",fullWidth:!0,onClick:()=>{n(s.map.current,r.premiumLayer.layer?.layerName),r.setPremiumLayer({selected:!0,layer:e}),r.setPremiumLayerAddedToMap(!0),l.goBack()}});return(0,o.jsxs)("div",{className:"flex flex-col h-full justify-between overflow-x-hidden text-black",children:[(0,o.jsxs)("div",{className:"flex flex-col gap-4 overflow-y-auto modal-scrollbar",children:[(0,o.jsx)("div",{className:"shrink-0 max-h-[175px] overflow-hidden rounded-[10px]",children:(0,o.jsx)(d(),{src:e.imgSrc,alt:"Layer Thumbnail",width:500,height:500,className:"w-full h-full object-cover"})}),(0,o.jsxs)("div",{children:[(0,o.jsx)("h2",{className:"card-title",children:e.layerName}),(0,o.jsx)("p",{children:e.description}),e.inlineLegendSrc&&(0,o.jsxs)("div",{className:"mt-3",children:[(0,o.jsx)("h3",{className:"font-semibold text-md",children:"Legend"}),(0,o.jsx)("div",{className:"mt-1 mx-auto w-75 shrink-0 overflow-hidden rounded-[10px]",children:(0,o.jsx)("img",{width:500,height:600,src:e.inlineLegendSrc,alt:"Additional layer image description"})})]})]})]}),(0,o.jsx)("div",{className:"card-actions mt-4",children:c})]})}let a9=({label:e,value:t,onChange:a,min:r=0,max:s=100,step:l=1,unit:i="%"})=>{let n=Math.round(100*t);return(0,o.jsxs)("div",{className:"flex items-center gap-4 w-full",children:[(0,o.jsx)("span",{className:"text-sm min-w-[80px] text-gray-700",children:e}),(0,o.jsx)("input",{className:"range range-neutral range-xs flex-1",type:"range",min:r,max:s,step:l,value:n,onChange:e=>a(Number.parseInt(e.target.value,10)),style:{"--range-shdw":"black",accentColor:"black"}}),(0,o.jsxs)("div",{className:"badge badge-ghost text-[11px] min-w-[55px] font-semibold py-3 border-gray-200",children:[n,i]})]})};function re(){let e=(0,eV.H)(),{editLayerOpacity:t,editLayerBrightness:a,editLayerContrast:r,editLayerSaturation:s,handleOpacityChange:l,handleBrightnessChange:i,handleContrastChange:n,handleSaturationChange:c,resetToDefault:d}=(()=>{let e=(0,eV.H)(),t=(0,eG.JY)(),{rasterVisuals:a,setRasterVisuals:r}=e;return(0,h.useEffect)(()=>
15{if(!e.premiumLayer.layer||!t.map.current)return;let r=t.map.current,s=t.altMap?.current,l=e.premiumLayer.layer,i=e.altPremiumLayer.selected?e.altPremiumLayer.layer:l,n=(e,t)=>{if(!t)return()=>{};let r=t.layerName,s=()=>!!e.getLayer(r)&&(e.setPaintProperty(r,"raster-opacity",a.opacity),e.setPaintProperty(r,"raster-brightness-min",a.brightness),e.setPaintProperty(r,"raster-contrast",a.contrast),e.setPaintProperty(r,"raster-saturation",a.saturation),!0);if(s())return()=>{};let l=()=>{s()&&i()},i=()=>{e.off("render",l),e.off("styledata",l)};return e.on("render",l),e.on("styledata",l),i},o=n(r,l),c=s?n(s,i):()=>{},d=e.premiumLayerAddedToMap,u=t.splitViewEnabled?e.altPremiumLayerAddedToMap:e.premiumLayerAddedToMap,p=[];d&&l.attribution&&p.push(l.attribution),u&&t.splitViewEnabled&&i?.attribution&&!p.includes(i.attribution)&&p.push(i.attribution);let m=p.join(" | ");return m?aY(m):aH(),()=>{o(),c()}},[e.premiumLayer.layer,e.altPremiumLayer.layer,e.altPremiumLayer.selected,e.altPremiumLayerAddedToMap,t.altMap?.current,t.map.current,t.splitViewEnabled,a,e.date,e.altDate,e.mergedDate,e.mergedDateAlt,e.premiumLayerAddedToMap]),{editLayerOpacity:a.opacity,editLayerBrightness:a.brightness,editLayerContrast:a.contrast,editLayerSaturation:a.saturation,handleOpacityChange:e=>{r(t=>({...t,opacity:e/100}))},handleBrightnessChange:e=>{r(t=>({...t,brightness:e/100}))},handleContrastChange:e=>{r(t=>({...t,contrast:e/100}))},handleSaturationChange:e=>{r(t=>({...t,saturation:e/100}))},resetToDefault:()=>{r({opacity:1,brightness:0,contrast:0,saturation:0})}}})(),[u,p]=(0,h.useState)(!1),m=[Math.abs(t-1)>.001,Math.abs(a)>.001,Math.abs(r)>.001,Math.abs(s)>.001].filter(Boolean).length,x=m>0;return e.premiumLayer.layer?(0,o.jsxs)("div",{className:"border-t border-gray-100 relative md:pr-4",children:[u&&(0,o.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,o.jsxs)("div",{className:"flex items-center justify-between border-b border-gray-100 py-2 mb-1",children:[(0,o.jsxs)("div",{className:"flex items-center gap-2 font-bold text-sm",children:[(0,o.jsx)($.Wyp,{size:16}),(0,o.jsx)("span",{children:"Layer Controls"})]}),(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[(0,o.jsxs)("button",{onClick:d,className:"btn btn-xs btn-ghost text-gray-500",title:"Reset to default",children:[(0,o.jsx)(e0.EEI,{size:10}),"Reset"]}),(0,o.jsx)("button",{onClick:()=>p(!1),className:"btn btn-xs btn-circle btn-ghost text-gray-400",children:(0,o.jsx)(eK.yGN,{size:14})})]})]}),(0,o.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,o.jsx)(a9,{label:"Opacity",value:t,onChange:l}),(0,o.jsx)(a9,{label:"Brightness",value:a,onChange:i}),(0,o.jsx)(a9,{label:"Contrast",value:r,onChange:n,min:-100}),(0,o.jsx)(a9,{label:"Saturation",value:s,onChange:c,min:-100})]})]}),!u&&(0,o.jsxs)("div",{className:"mt-4 relative",children:[(0,o.jsxs)("button",{onClick:()=>p(!0),className:`btn w-full hide-focus-ring ${x?"border border-blue-300 bg-blue-100/60 text-blue-800 hover:bg-blue-100":""}`,children:[(0,o.jsx)($.Wyp,{size:16,className:x?"text-blue-700":"text-gray-700"}),"Layer Controls",x?(0,o.jsx)("div",{className:"ml-2 min-w-6 rounded-full bg-blue-600 px-2 text-xs text-white",children:m}):(0,o.jsx)("div",{className:"beta-tag ml-2",children:"NEW"})]}),x&&(0,o.jsx)("button",{type:"button",onClick:d,className:"absolute right-2 top-1/2 -translate-y-1/2 rounded-full p-1 text-blue-600 transition-colors hover:bg-blue-200/70",children:(0,o.jsx)(eK.yGN,{size:14})})]})]}):null}function rt(){let e=(0,ex.u)(),t=(0,eV.H)(),a=(0,e$.p)(),r=(0,eG.JY)(),[s,l]=(0,h.useState)(x.Jr.basic),[i,n]=(0,h.useState)(!0),[c,u]=(0,h.useState)(!1);(0,h.useEffect)(()=>{e.user?.customer_data?(e.user.customer_data[m.no.premium_layers_product_id]?.status===x.Jr.premium||e.user.is_developer?l(x.Jr.premium):a0(e.user.created_at)>0?l(x.Jr.trial):l(x.Jr.basic),setTimeout(()=>{n(!1)},80)):n(!1)},[e.user]);let f=e=>Object.keys(e).map(l=>{let i=e[l];return(0,o.jsx)(a8,{label:i.layerName,descriptionLines:[{icon:e0.D14,text:`Satellite: ${i.satellite}`},{icon:e0.f35,text:`Source: ${i.source}`},{icon:W.D7y,text:`Updated: ${i.updateFrequency}`}],selected:t.premiumLayer.layer?.layerName===i.layerName||r.splitViewEnabled&&t.altPremiumLayer.selected&&t.altPremiumLayer.layer?.layerName===i.layerName,imageSrc:i.imgSrc,imageGrey:s===x.Jr.basic,isNew:i.isNew,onClick:()=>{a.pushSubPage((0,o.jsx)(a7,{clickedLayer:i,premiumUser:s,setStripeW
15indowOpen:u}),{title:i.layerName})}},l)});return(0,o.jsxs)("div",{className:"flex flex-col h-full overflow-hidden",children:[!i&&(0,o.jsx)("div",{className:"shrink-0",children:s!=x.Jr.basic&&e&&e.user?.customer_data?(0,o.jsx)("div",{children:s===x.Jr.trial?(0,o.jsxs)("div",{className:"pl-3 pr-3 md:pr-7 rounded-md bg-green-100 mb-5 items-center ease-injustify-center flex flex-row gap-1 justify-between",children:[(0,o.jsxs)("div",{className:"flex flex-col line leading-4",children:[(0,o.jsxs)("span",{className:"opacity-70 font-bold text-[13px]",children:["Premium layers free trial expires in ",a0(e.user?.created_at)," day(s)"]}),(0,o.jsx)("span",{className:"opacity-70 text-[11px]",children:"Subscription required"})]}),(0,o.jsxs)("div",{className:"my-2",children:[(0,o.jsx)("label",{htmlFor:"stripe-modal",onClick:()=>u(!0),className:" text-white btn btn-sm tt-blue-button",children:"Subscribe"}),(0,o.jsx)("div",{className:"w-full flex justify-center items-center opacity-90 text-[10px] opacity-50",children:(0,o.jsxs)("span",{className:"flex text-[10px]",children:["Powered by\xa0",(0,o.jsx)(d(),{src:"/images/stripe.svg",alt:"Stripe logo",width:26,height:13,className:"mt-[2px]"})]})})]})]}):(0,o.jsxs)("div",{className:"pl-3 pr-3 md:pr-7 py-3 rounded-md bg-green-100 mb-5 items-center ease-in flex flex-row gap-1 justify-between",children:[(0,o.jsxs)("div",{className:"flex flex-col line leading-4",children:[(0,o.jsx)("span",{className:"opacity-70 font-bold text-[13px]",children:"Premium layers activated"}),!e.user.is_developer&&a1(e.user.customer_data[m.no.premium_layers_product_id])?(0,o.jsxs)("span",{className:"opacity-70 text-[11px]",children:["Your subscription expires in ",a1(e.user.customer_data[m.no.premium_layers_product_id])," day(s)"]}):(0,o.jsx)("span",{className:"opacity-70 text-[11px]",children:"Manage your premium layer subscription in your profile"})]}),!(0,e_.KR)()&&(!e.user.is_developer&&a1(e.user.customer_data[m.no.premium_layers_product_id])?(0,o.jsx)("label",{htmlFor:"stripe-modal",onClick:()=>u(!0),className:" text-white btn btn-sm tt-blue-button",children:"Subscribe"}):(0,o.jsx)(p(),{target:"_blank",href:"/profile",className:"btn btn-sm text-white bg-green-600 hover:bg-green-700",children:"Manage"}))]})}):(0,o.jsxs)("div",{className:"pl-3 pr-3 md:pr-7 rounded-md bg-tt-blue/10 mb-5 items-center ease-injustify-center flex flex-row gap-1 justify-between",children:[(0,o.jsxs)("div",{className:"flex flex-col line leading-4",children:[(0,o.jsx)("span",{className:"opacity-70 font-bold text-[13px]",children:"This is a premium feature"}),(0,o.jsx)("span",{className:"opacity-70 text-[11px]",children:"Subscription needed to access the premium layers"})]}),(0,o.jsxs)("div",{className:"my-2",children:[(0,o.jsx)("label",{htmlFor:"stripe-modal",onClick:()=>u(!0),className:" text-white btn btn-sm  tt-blue-button",children:"Subscribe"}),(0,o.jsx)("div",{className:"w-full flex justify-center items-center opacity-90 text-[10px] opacity-50",children:(0,o.jsxs)("span",{className:"flex text-[10px]",children:["Powered by\xa0",(0,o.jsx)(d(),{src:"/images/stripe.svg",alt:"Stripe logo",width:26,height:13,className:"mt-[2px]"})]})})]})]})}),(0,o.jsxs)("div",{className:"flex-1 overflow-y-auto modal-scrollbar",children:[(0,o.jsxs)("div",{className:"mb-2 flex gap-2 items-center",children:[(0,o.jsx)(e0.D14,{})," Satellite Layers"]}),(0,o.jsx)("div",{className:"gap-3 flex flex-col mb-4",children:f(a3)}),(0,o.jsxs)("div",{className:"mb-2 flex gap-2 items-center",children:[(0,o.jsx)(d(),{src:"/images/brain_black.svg",height:15,width:15,alt:""}),"AI Solutions"]}),(0,o.jsx)("div",{className:"gap-3 flex flex-col",children:f(a4)})]}),(0,o.jsx)(re,{}),(0,o.jsx)(a2.A,{open:c,onClose:()=>u(!1),"aria-labelledby":"modal-modal-title","aria-describedby":"modal-modal-description",className:"mx-auto stripe-modal self-center flex w-full",BackdropProps:{style:{backgroundColor:"rgba(0, 0, 0, 0.8)"}},children:(0,o.jsx)(a5.A,{component:"div",className:"bg-white justify-center w-[440px] self-center mx-auto rounded-xl",children:(0,o.jsx)(aQ.A,{closeModal:()=>u(!1),setPremium:e=>l(e)})})})]})}var ra=a(38960),rr=a(81603),rs=a(37401);let rl=async(e,t,a)=>{try{let r=ri(t,a);await rn(e,r)}catch(e){y.Ay.error(e.message)}},ri=(e,t)=>{let a;switch(e){case x.W7.noteLayer:case x.W7.noteLayer3D:a=x.pp.notes;break;case x.W7.alertLayer:"point"===t?a=x.pp.alerts_point:"polygon"===t&&(
15a=x.pp.alerts_polygon);break;case x.W7.measurementLayer:"line"===t?a=x.pp.measurements_line:"polygon"===t&&(a=x.pp.measurements_polygon)}if(!a)throw Error("Invalid layer name");return a},rn=async(e,t)=>{let a=`ws_${e?.project_uuid}`,r=`${m.Rt}/${a}/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=${a}:${t}`;if((await fetch(r,{method:"HEAD"})).ok)window.open(r,"_blank","noopener,noreferrer");else throw Error("Page not found")},ro=(e,t)=>{let a={measurements:[{type:"line",label:"WFS URL (Distance)"},{type:"polygon",label:"WFS URL (Area)"}],alerts:[{type:"point",label:"WFS URL (Point)"},{type:"polygon",label:"WFS URL (Area)"}],default:[{type:"point",label:"WFS URL (Point)"}]};return(a[t]??a.default).map((a,r)=>(0,o.jsx)("li",{className:"hover:bg-base-300 rounded-lg",onClick:()=>{rl(e,t,a.type)},children:(0,o.jsxs)("a",{children:[(0,o.jsx)(rs.GPF,{})," ",a.label," "]})},r))},rc=async(e,t,a,r)=>{let s=new(eR()),l=async(e,t)=>{try{let a=await fetch(e);if(a.ok){let e=await a.blob();s.file(`files/${t}`,e)}}catch(t){console.error(`Failed to download image ${e}:`,t)}},i=[];if(t.features&&t.features[0]?.properties?.hasOwnProperty("img")&&t.features[0]?.properties?.hasOwnProperty("img"))for(let r=0;r<t.features.length;r++){let s=t.features[r].properties?.img??null;if(s){let t="";switch(a){case x.dP.note:t=await (0,H.bB)(`${e?.container_name??""}/notes/${s}`);break;case x.dP.alert:t=await (0,H.bB)(`${e?.container_name??""}/alerts/${s}`)}i.push(l(t,s))}}Promise.all(i).then(()=>{let e=JSON.stringify(t);return s.file(`${a}_data.geojson`,e),s.generateAsync({type:"blob"})}).then(e=>{let t=new Blob([e],{type:"application/zip"}),r=document.createElement("a");r.href=URL.createObjectURL(t);let s=new Date,l=s.toLocaleDateString().replace(/\//g,"_"),i=s.toLocaleTimeString("en-US",{hour12:!1}).replace(/:/g,"_");r.download=`${a}_data_${l}_${i}.zip`,r.style.display="none",document.body.appendChild(r),r.click(),URL.revokeObjectURL(r.href),document.body.removeChild(r)}).catch(e=>{console.error("Error downloading images:",e),y.Ay.error("Failed to download images"),r(e)}).finally(()=>{r()})},rd=[{label:"User",columnId:"user",getValueAsString:e=>`${e.first_name} ${e.last_name}`},{label:"Type",columnId:null,getValueAsString:e=>e.properties.type},{label:"Title",columnId:"title",getValueAsString:e=>e.properties.title},{label:"Description",columnId:"description",getValueAsString:e=>e.properties.description},{label:"Time",columnId:"create_date",getValueAsString:e=>J()(e.create_date).format("YYYY-MM-DD HH:mm:ss")}],ru=[{label:"LRS Route",columnId:null,getValueAsString:e=>e.properties.lrs?.route},{label:"LRS From",columnId:null,getValueAsString:e=>e.properties.lrs?.from?.toString()},{label:"LRS To",columnId:null,getValueAsString:e=>e.properties.lrs?.to?.toString()}],rp=e=>[...rd,...e?ru:[]];function rm(e,t){let a=rp(t);return{fields:[...a.map(e=>e.label),"Latitude","Longitude"],data:e.map(e=>[...a.map(t=>t.getValueAsString(e)),e.location.lat,e.location.lon])}}var rh=a(37085),rx=a.n(rh);let rf=()=>{let e=(0,eG.JY)(),t=(0,ev.O)(),[a,r]=(0,h.useState)({downloading:!1,layerName:""});return{isDownloading:a,handleDownloadGeojson:async a=>{if(!t.project)return;r({downloading:!0,layerName:a});let s=e.map.current?.getSource(a);if(s){let e=x.dP.note;switch(a){case x.W7.noteLayer:case x.W7.noteLayer3D:e=x.dP.note;break;case x.W7.alertLayer:e=x.dP.alert}let l=s._data;if(!l){y.Ay.error("GeoJSON data not available for download"),r({downloading:!1,layerName:""});return}rc(t.project,l,e,()=>r({downloading:!1,layerName:""}))}else y.Ay.error("Source not available for download")},handleDownloadCsv:async e=>{if(t.project){r({downloading:!0,layerName:e});try{if(e===x.W7.alertLayer){let e=await (0,ti.Mn)(null,null,!1),a=Array.isArray(e)?[]:e.alerts||[],r=`alerts_${t.project?.project_name||"export"}.csv`;(0,v.tr)(rx().unparse((0,ti.Z_)(a)),r)}else if(e===x.W7.noteLayer||e===x.W7.noteLayer3D){let e=await (0,ee.GW)(null,null,!1),a=Array.isArray(e)?[]:e.notes||[],r=`notes_${t.project?.project_name||"export"}.csv`,s=t.project?.lrs_included;(0,v.tr)(rx().unparse(rm(a,s)),r)}}catch(e){console.error("Export failed",e),y.Ay.error("Export failed")}finally{r({downloading:!1,layerName:""})}}}}}
15,rg={Notes:{"clusters-note-circle":{id:"clusters-note-circle",type:"circle",source:"note-layer",filter:["has","point_count"],paint:{"circle-color":"#92bbfc","circle-radius":30,"circle-stroke-width":0,"circle-stroke-color":"#92bbfc","circle-opacity":.35},layout:{visibility:"visible"}},"cluster-note-text":{id:"cluster-note-text",type:"symbol",source:"note-layer",filter:["has","point_count"],layout:{"text-field":["get","point_count_abbreviated"],"text-font":["DIN Offc Pro Medium","Arial Unicode MS Bold"],"text-size":12,"icon-offset":[10,0],"icon-size":.9,"icon-allow-overlap":!0}},"red-dot-layer":{id:"red-dot-layer",type:"symbol",source:"note-layer",layout:{"icon-image":"red-dot","icon-size":.2,"icon-offset":[35,-35],"icon-allow-overlap":!0},filter:[">",["length",["get","notification_ids"]],0]},"clusters-note-red-dot":{id:"clusters-note-red-dot",type:"symbol",source:"note-layer",layout:{"icon-image":"red-dot","icon-size":.2,"icon-offset":[35,-35],"icon-allow-overlap":!0},filter:["all",["has","point_count"],[">",["get","unread_count"],0]]}},"3D Notes":{"clusters-3dnote-circle":{id:"clusters-3dnote-circle",type:"circle",source:"3dnote-layer",filter:["has","point_count"],paint:{"circle-color":"#92bbfc","circle-radius":30,"circle-stroke-width":0,"cir
15cle-stroke-color":"#000000","circle-opacity":.35},layout:{visibility:"visible"}},"cluster-3dnote-text":{id:"cluster-3dnote-text",type:"symbol",source:"3dnote-layer",filter:["has","point_count"],layout:{"text-field":["get","point_count_abbreviated"],"text-font":["DIN Offc Pro Medium","Arial Unicode MS Bold"],"text-size":12,"icon-size":.9,"icon-allow-overlap":!0}},"clusters-3dnote-red-dot":{id:"clusters-3dnote-red-dot",type:"symbol",source:"3dnote-layer",layout:{"icon-image":"red-dot","icon-size":.2,"icon-offset":[35,-35],"icon-allow-overlap":!0},filter:["all",["has","point_count"],[">",["get","unread_count"],0]]},"3dnote-layer-red-dot":{id:"3dnote-layer-red-dot",type:"symbol",source:"3dnote-layer",layout:{"icon-image":"red-dot","icon-size":.2,"icon-offset":[35,-35],"icon-allow-overlap":!0},filter:[">",["length",["get","notification_ids"]],0]}},Alerts:{"cluster-alert-circle":{id:"cluster-alert-circle",type:"circle",source:"alerts",filter:["has","point_count"],paint:{"circle-color":"#f5ff66","circle-radius":30,"circle-stroke-width":0,"cir
15cle-stroke-color":"#000000","circle-opacity":.15}},"cluster-alert-text":{id:"cluster-alert-text",type:"symbol",source:"alerts",filter:["has","point_count"],layout:{"text-field":["get","point_count_abbreviated"],"text-font":["DIN Offc Pro Medium","Arial Unicode MS Bold"],"text-size":12,"icon-offset":[10,0],"icon-size":.9,"icon-allow-overlap":!0}},"alert-red-dot-layer":{id:"alert-red-dot-layer",type:"symbol",source:"alerts",layout:{"icon-image":"red-dot","icon-size":.2,"icon-offset":[35,-35],"icon-allow-overlap":!0},filter:[">",["length",["get","notification_ids"]],0]}}},ry=()=>{let e=(0,eG.JY)(),t=(0,eV.H)();if(!e.map.current)throw Error("Map not initialized");let a=e.map.current;return e=>{let r=(e=>{let a=!t.layersCheckboxState[e];if((0,v.bX)(t.layersLabelState,e)){let r=t.layersCheckboxState[e],s=t.layersLabelState[e];a=r;let l=s;r&&s?(a=!0,l=!1):r&&!s?(a=!1,l=!1):(a=!0,l=!0),t.setLayersLabelState(t=>({...t,[e]:l}))}return t.setLayersCheckboxState(t=>({...t,[e]:a})),a})(e);if("Notes"===e||"3D Notes"===e||"Alerts"===e)for(let[t,s]of Object.entries(rg[e])){let e=a.getLayer(t);!r&&e?a.removeLayer(t):r&&!e&&a.addLayer(s)}}};function rb({labelledValues:e}){return(0,o.jsx)("ul",{className:"list bg-base-200 rounded-box shadow my-1",children:e.map(({label:e,value:t})=>t&&(0,o.jsxs)("li",{className:"list-row p-4",children:[(0,o.jsx)("div",{className:"font-medium",children:e}),(0,o.jsx)("div",{className:"list-col-grow",children:t})]},e))})}function rj({openAdvancedFiltersInModal:e}){(0,eg.ZM)();let t=(0,eG.JY)().layerFilterOptions.current.alerts,a=t?.issuer??"",r=t?.title??"",s=t?.description??"",l=(0,v.rm)(t?.dates?.from??new Date(NaN),!1),i=(0,v.rm)(t?.dates?.to??new Date(NaN),!1),n=t?.category??"",c=t?.severity,d=void 0===c?"":(0,v.Wl)(c),u=t?.visibleSeverityLevels,p=[{label:"Issuer",value:a},{label:"Title",value:r},{label:"Description",value:s},{label:"From",value:l},{label:"To",value:i},{label:"Category",value:n},{label:"Severity",value:d},{label:"Visible alert levels",value:u?.length?u.map(v.Wl).join(", "):""}],m=p.some(e=>e.value);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("span",{className:"text-sm",children:["Reopen advanced filters by clicking"," ",(0,o.jsxs)("button",{className:"link-primary cursor-pointer",onClick:t=>{t.preventDefault(),e()},children:[" ","here"]}),"."]}),(0,o.jsx)("div",{className:"text-sm my-1",children:m?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("span",{className:"text-sm",children:"Currently filtering map by:"}),(0,o.jsx)(rb,{labelledValues:p})]}):(0,o.jsx)("span",{className:"text-sm",children:"No filters applied."})})]})}function rw(e,t,a){let r=new Date;r.setDate(r.getDate()-a),r.setHours(0),r.setMinutes(0),r.setSeconds(0),r.setMilliseconds(0);let s=new Date;s.setHours(23),s.setMinutes(59),s.setSeconds(59),s.setMilliseconds(59),e.layerFilterOptions.current.alerts={dates:{from:r,to:s}},t.setRefreshAlerts(e=>e+1)}function rv({value:e,onChange:t,minValue:a,maxValue:r,splitCount:s}){let l=(0,h.useId)();return(0,o.jsxs)("div",{"aria-label":"Date selection slider",children:[(0,o.jsx)("input",{id:l,value:e,type:"range",min:a,max:r,className:"my-2 range range-xs",step:"1",onChange:t}),(0,o.jsx)("div",{className:"flex justify-between px-2.5 mt-2 text-xs text-gray-500",children:Array.from({length:s},(e,t)=>(0,o.jsx)("label",{htmlFor:l,children:a+t*(r-a)/(s-1)},t))})]})}function rN({sliderValue:e,setSliderValue:t}){let a=(0,eG.JY)(),r=(0,eg.ZM)(),[s,l]=(0,h.useState)(!1),i=(0,h.useRef)((0,v.sg)(e=>{rw(a,r,e),l(!1)},500)),n=e=>{e.preventDefault();let a=Math.min(90,Math.max(0,Number(e.target.value)));t(a),l(!0),i.current(a)};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("fieldset",{className:"my-1 bg-base-200 rounded-lg p-4",children:[(0,o.jsxs)("label",{className:"mb-2 text-center block text-sm",children:["Filtering alerts from last"," ",(0,o.jsx)("input",{type:"number",className:"input input-bordered input-xs w-12",min:0,max:90,value:e.toString(),onChange:n})," ","days"]}),(0,o.jsx)(rv,{minValue:0,maxValue:90,splitCount:7,value:e,onChange:n})]}),(0,o.jsx)("div",{className:"flex justify-center",children:s&&(0,o.jsx)("span",{className:"mx-auto loading loading-spinner loading-sm bg-gray-500"})})]})}var rS=((s=rS||{}).NONE="None",s.SIMPLE="Simple",s.ADVANCED="Advanced",s);let rk=e=>Math.floor((e.getTime()-e.getTimezoneOffset()*eB.FC)/eB.ss),r_=e=>{if(!(e=>{let{dates:t,...a}=e;return!Object.values(a).some(Boolean)&&!!t?.from&&!!t?.to})(e))return!1;let{from:t,to:a}=e.dates,r=rL(t,a);return t.getTime()<=a.getTime()&&r<=90},rC=e=>r_(e)&&rk(e.dates.to)===rk(new Date),rL=(e,t)=>{let a=e.getTime()-e.getTimezoneOffset()*eB.FC;return Math.floor(Math.abs(t.getTime()-t.getTimezoneOffset()*eB.FC-a)/eB.ss)};function rD(){let e=(0,eG.JY)(),t=(0,ej.H)(),a=(0,eg.ZM)(),[r,s]=(0,h.useState)("None"),[l,i]=(0,h.useState)(90),n=()=>{t.setShowModals({...t.showModals,AlertsModal:{display:!0,zIndex:t.showModals.AlertsModal?.zIndex??40}}),a.setShowFilterModal(!0)};return(0,h.useEffect)(()=>
15{if(a.showFilterModal)s("Advanced");else{let t=e.layerFilterOptions.current.alerts??{},a=0===Object.values(t).filter(Boolean).length?"None":rC(t)?"Simple":"Advanced";"None"===a?s("None"):"Simple"===a?(i(rL(t.dates.from,t.dates.to)),s("Simple")):s("Advanced")}},[a.refreshAlerts,a.showFilterModal]),(0,o.jsxs)("div",{className:"w-full max-w mb-5 px-2",children:[(0,o.jsx)("span",{className:"text-sm font-medium block my-1 text-lg",children:"Filter"}),(0,o.jsx)("div",{role:"tablist",className:"tabs tab-xs tabs-box flex my-2",children:Object.values(rS).map(t=>(0,o.jsx)("button",{role:"tab",className:`tab flex-auto ${r===t?" tab-active-layers":""}`,onClick:()=>(t=>{switch(t){case"None":e.layerFilterOptions.current.alerts={},a.setShowFilterModal(!1),a.setRefreshAlerts(e=>e+1);break;case"Simple":{let t=e.layerFilterOptions.current.alerts??{};if(r_(t)){let r;i((r=rL(t.dates.from,t.dates.to),rC(t)||rw(e,a,r),r))}else rw(e,a,l),a.setRefreshAlerts(e=>e+1);a.setShowFilterModal(!1);break}case"Advanced":n()}s(t)})(t),children:t},t))}),(e=>{switch(e){case"None":return null;case"Simple":return(0,o.jsx)(rN,{sliderValue:l,setSliderValue:i});case"Advanced":return(0,o.jsx)(rj,{openAdvancedFiltersInModal:n})}})(r)]})}var rA=a(18868),rM=a.n(rA);let rE=({layerName:e,isDownloading:t,handleDownloadCsv:a})=>[x.W7.alertLayer,x.W7.noteLayer,x.W7.noteLayer3D].includes(e)?t.downloading&&t.layerName===e?(0,o.jsxs)("div",{className:"p-2 flex items-center gap-2.5",children:[(0,o.jsx)("span",{className:"loading loading-spinner w-3"}),"Downloading..."]}):(0,o.jsx)("button",{className:"hover:bg-base-300 rounded-lg w-full text-left",onClick:()=>a(e),children:(0,o.jsxs)("a",{className:"flex items-center gap-2",children:[(0,o.jsx)(W.U01,{})," Download CSV"]})}):null;function rT({type:e,layerName:t,handleEdit:a,tabularModalName:r}){let s,l,i=(0,eV.H)(),n=(0,ev.O)(),{isDownloading:c,handleDownloadGeojson:d,handleDownloadCsv:u}=rf(),p=ry(),{toggleModal:m,getModalState:h}=(0,tZ.O)(),f=i.layersCheckboxState[e],g=!(0,v.bX)(i.layersLabelState,e)||i.layersLabelState[e];f?(s=g?(0,o.jsx)(W.JPe,{className:"text-black","data-testid":"builtin-layer-visible-icon"}):(0,o.jsx)(W.JPe,{className:"text-blue-500","data-testid":"builtin-layer-label-hidden-icon"}),l=g?"Layer visible":"Layer labels hidden"):(s=(0,o.jsx)(W.Sq0,{className:"text-red-500","data-testid":"builtin-layer-hidden-icon"}),l="Layer hidden");let y=t===x.W7.pointclouds;return(0,o.jsxs)("div",{className:"flex flex-row justify-between mb-3","data-testid":"builtin-layer-entry",children:[(0,o.jsxs)("div",{className:"flex items-center gap-1",children:[(0,o.jsx)("span",{className:"label",children:e}),y&&(0,o.jsx)("div",{className:"beta-tag",children:"NEW"})]}),(0,o.jsxs)("div",{className:"flex items-center gap-1",children:[(0,o.jsx)("button",{className:"btn btn-xs text-black",onClick:()=>p(e),title:l,children:s}),r&&(0,o.jsx)("button",{className:"btn btn-xs","data-testid":y&&"pointcloud-tabularview-button",onClick:e=>{let t;m(r),(t=e.currentTarget.closest("details"))&&t.removeAttribute("open")},children:(0,o.jsx)(rr.OKl,{color:h(r).display?"#2563eb":"#000000"})}),a&&(0,o.jsx)("label",{htmlFor:"edit-buildings-modal",className:"btn btn-xs",onClick:()=>{a()},children:(0,o.jsx)($.VZ_,{})}),![x.W7.cameraPoints,x.W7.buildings,x.W7.pointclouds].includes(t)&&(0,o.jsxs)("details",{className:"dropdown dropdown-end fm-dropdown dropdown-close-outside",children:[(0,o.jsx)("summary",{id:`${t}-summary`,className:"flex btn btn-xs text-xs",title:"Show more options",children:(0,o.jsx)(W.mqA,{})}),(0,o.jsxs)("ul",{className:"p-2 shadow menu dropdown-content z-5000 bg-base-100 rounded-box w-52",children:[c.downloading&&c.layerName===t?(0,o.jsxs)("div",{className:"p-2 flex items-center gap-2.5",children:[(0,o.jsx)("span",{className:"loading loading-spinner w-3"}),"Downloading..."]}):(0,o.jsx)("button",{className:"hover:bg-base-300 rounded-lg w-full text-left",onClick:()=>d(t),children:(0,o.jsxs)("a",{className:"flex items-center gap-2",children:[(0,o.jsx)(W.U01,{})," Download GeoJSON"]})}),(0,o.jsx)(rE,{layerName:t,isDownloading:c,handleDownloadCsv:u}),ro(n.project,t)]})]})]})]})}function rI({type:e,layerName:t}){let a,r,s=(0,eV.H)(),l=(0,ev.O)(),{isDownloading:i,handleDownloadGeojson:n,handleDownloadCsv:c}=rf(),d=ry(),u=s.layersCheckboxState[e],p=!(0,v.bX)(s.layersLabelState,e)||s.layersLabelState[e];return u?(a=p?(0,o.jsx)(W.JPe,{className:"text-black","data-testid":"builtin-layer-visible-icon"}):(0,o.jsx)(W.JPe,{className:"text-blue-500","data-testid":"builtin-layer-label-hidden-icon"}),r=p?"Layer visible":"Layer labels hidden"):(a=(0,o.jsx)(W.Sq0,{className:"text-red-500","data-testid":"builtin-layer-hidden-icon"}),r="Layer hidden"),(0,o.jsx)(rM(),{trigger:(0,o.jsxs)("div",{className:"collapsible_trigger font text-sm mb-3","data-testid":"builtin-layer-entry-expanded",children:[(0,o.jsx)("span",{className:"collapsible_arrow",children:(0,o.jsx)(W.tEr,{})}),(0,o.jsx)("div",{className:"flex flex-col w-full",children:(0,o.jsxs)("div",{className:"flex justify-between items-center",children:[e,(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("button",{className:"btn btn-xs text-black",onClick:t=>{t.stopPropagation(),d(e)},title:r,children:a}),(0,o.jsxs)("details",{className:"dropdown dropdown-end fm-dropdown dropdown-close-outside ms-1",children:[(0,o.jsx)("summary",{id:`${t}-summary`,className:"flex btn btn-xs text-xs",title:"Show more options",onClick:e=>e.stopPropagation(),children:(0,o.jsx)(W.mqA,{})}),(0,o.jsxs)("ul",{className:"p-2 shadow menu dropdown-content z-5000 bg-base-100 rounded-box w-52",children:[i.downloading&&i.layerName===t?(0,o.jsxs)("div",{className:"p-2 flex items-center gap-2.5",children:[(0,o.jsx)("span",{className:"loading loading-spinner w-3"}),"Downloading..."]}):(0,o.jsx)("button",{className:"hover:bg-base-300 rounded-lg w-full text-left",onClick:()=>n(t),children:(0,o.jsxs)("a",{className:"flex items-center gap-2",children:[(0,o.jsx)(W.U01,{})," Download GeoJSON"]})}),(0,o.jsx)(rE,{layerName:t,isDownloading:i,handleDownloadCsv:c}),ro(l.project,t)]})]})]})]})})]}),children:(0,o.jsx)(rD,{})})}function rP({opacity:e,setOpacity:t}){let a=100*e;return(0,o.jsxs)("div",{className:"flex items-center align-start gap-2 backdrop-slider w-full",children:[(0,o.jsx)("span",{className:"font-bold text-sm",children:"Opacity"}),(0,o.jsx)("input",{className:"w-full custom-backdrop-slider",type:"range",min:"0",max:"100",step:"1",value:a,onChange:e=>{t(Number.parseInt(e.target.value,10))}}),(0,o.jsxs)("div",{className:"badge badge-md text-xs text-white w-[64px] justify-center whitespace-nowrap shrink-0 tabular-nums leading-none",style:{backgroundColor:`rgba(0, 0, 0, ${.8*e+.2})`},children:[Math.round(a)," %"]})]})}function rF({originalColor:e,originalOpacity:t}){let a=(0,eG.JY)(),r=(0,e$.p)(),[s,l]=(0,h.useState)(a.map.current?.getPaintProperty("buildings-layer","fill-opacity")),[i,n]=(0,h.useState)(a.map.current?.getPaintProperty("buildings-layer","fill-color"));return(0,o.jsxs)("div",{className:"flex flex-col h-full justify-between",children:[(0,o.jsxs)("div",{className:"flex flex-col items-center gap-4 w-full overflow-y-auto",children:[(0,o.jsx)(tr,{c
15olor:a.map.current?.getPaintProperty("buildings-layer","fill-color"),handleChangeColor:e=>{a.map.current?.setPaintProperty("buildings-layer","fill-color",e.target.value),n(e.target.value)},label:""}),(0,o.jsx)(rP,{opacity:s,setOpacity:e=>{a.map.current?.setPaintProperty("buildings-layer","fill-opacity",e/100),l(e/100)}})]}),(0,o.jsx)("button",{className:"btn tt-blue-button",onClick:()=>{e.current=i,t.current=s,y.Ay.success("Layer Saved Successfully"),r.goBack()},children:"Save"})]})}function rO(){let e=(0,eG.JY)(),t=(0,e$.p)(),a=(0,h.useRef)(e.map.current?.getPaintProperty("buildings-layer","fill-opacity")),r=(0,h.useRef)(e.map.current?.getPaintProperty("buildings-layer","fill-color"));return(0,o.jsxs)("div",{className:"mr-2 mt-2",children:[(0,o.jsx)(rT,{type:"Camera Points",layerName:x.W7.cameraPoints}),(0,o.jsx)(rT,{type:"Pointclouds",layerName:x.W7.pointclouds,tabularModalName:x.dW.PointcloudsModal}),(0,o.jsx)(rT,{type:"Notes",layerName:x.W7.noteLayer}),(0,o.jsx)(rT,{type:"3D Notes",layerName:x.W7.noteLayer3D}),(0,o.jsx)(rI,{type:"Alerts",layerName:x.W7.alertLayer}),(0,o.jsx)(rT,{type:"Measurements",layerName:x.W7.measurementLayer,tabularModalName:x.dW.MeasurementsModal}),(0,o.jsx)(rT,{type:"Building Footprints",layerName:x.W7.buildings,handleEdit:()=>t.pushSubPage((0,o.jsx)(rF,{originalColor:r,originalOpacity:a}),{title:"Edit Buildings Layer",onClose:()=>{e.map.current?.setPaintProperty("buildings-layer","fill-color",r.current),e.map.current?.setPaintProperty("buildings-layer","fill-opacity",a.current)}})})]})}let rR=({selectedLayer:e})=>e?(0,ra.wv)(e.source)?(0,o.jsx)("div",{className:"layer-icon",children:(0,o.jsx)(e0.Eh_,{size:16,className:"text-black"})}):"raster"!==e.type&&e.properties.icon?(0,o.jsx)("div",{className:"layer-icon",children:(0,o.jsx)("img",{src:e.properties.icon,alt:"Layer icon",className:"w-4 h-4 object-contain"})}):["raster","custom","symbol"].includes(e.type)||e.properties.icon?null:(0,o.jsx)("div",{className:"layer-icon",children:(0,o.jsx)("div",{className:"layer-icon-dot",style:{backgroundColor:e.properties.color,backgroundImage:(e=>{if(!e.properties.gradientData.property)return"";if(!e.properties.gradientData.gradientType||e.properties.gradientData.gradientType===x.nd.gradient)return`linear-gradient(to right, ${e.properties.gradientData.gradient1}, ${e.properties.gradientData.gradient2})`;let t=Object.values(e.properties.gradientData.categorical);return t.push(e.properties.color),`linear-gradient(45deg, ${t.join(", ")})`})(e)}})}):null,r$=({selectedLayer:e})=>(0,o.jsxs)("div",{className:"layer-entry-label label-text mr-2 w-full overflow-hidden flex flex-col min-w-0",children:[(0,o.jsxs)("div",{className:"flex items-center min-w-0",children:[(0,o.jsx)(rR,{selectedLayer:e}),(0,o.jsx)("div",{title:e?.name,className:"truncate",children:e?.name})]}),(0,o.jsxs)("div",{className:"flex items-center layer-entry-label",children:[(0,o.jsx)("button",{className:"hide-focus-ring",onClick:e=>{e.stopPropagation()},children:(0,o.jsx)("span",{className:"badge badge-sm badge-ghost text-[0.65rem] opacity-70 truncate max-w-25 cursor-default",title:`${e?.source}`,children:e?.source})}),e?.scope==="Draft"&&(0,o.jsx)("span",{className:"badge badge-sm badge-neutral ml-1 text-[0.65rem]",title:"Draft",children:"Draft"}),e?.properties.hasLRS&&(0,o.jsx)("span",{className:"badge badge-sm bg-tt-blue ml-1 text-white text-[0.65rem]",title:"LRS",children:"LRS"})]})]}),rz=({layers:e,selectedLayers:t,setSelectedLayers:a})=>{let r=t.size>0&&t.size===e.length;return(0,o.jsxs)("div",{children:[(0,o.jsx)("span",{className:"label-text font-bold",children:"Add Ungrouped Layers"}),(0,o.jsxs)("table",{className:"table table-fixed",children:[(0,o.jsx)("thead",{children:(0,o.jsxs)("tr",{children:[(0,o.jsx)("th",{className:"w-3/4 px-0 py-[7px]",children:"Layer"}),(0,o.jsxs)("th",{className:"w-2/4 min-w-fit px-0 py-[7px] text-right",children:[(0,o.jsx)("span",{className:"mr-2",children:"Include"}),(0,o.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",onChange:t=>{a(()=>t.target.checked?new Set(e):new Set)},checked:r})]})]})}),(0,o.jsx)("tbody",{children:e.map(e=>(0,o.jsxs)("tr",{children:[(0,o.jsx)("td",{className:"px-0 py-[7px]",children:(0,o.jsx)(r$,{selectedLayer:e})}),(0,o.jsx)("td",{className:"px-0 py-[7px] text-right",children:(0,o.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:t.has(e),onChange:t=>{a(a=>
15{let r=new Set(a);return t.target.checked?r.add(e):r.delete(e),r})}})})]},e.id))})]})]})},rU=({showGroupNameModal:e,setShowGroupNameModal:t,groupName:a,setGroupName:r,groups:s})=>{let l=(0,eV.H)(),[i,n]=(0,h.useState)(new Set),c=l.customLayers.filter(e=>!!e.id&&!e.properties?.group),[d,u]=(0,h.useState)(!1),p=()=>{r(""),n(new Set),t(!1),u(!1)},m=async()=>{if(!a?.trim())return void y.Ay.error("Invalid name");if(s.includes(a))return void y.Ay.error("Group name already exists");u(!0);try{await (0,av.Lr)(i,a,l),y.Ay.success("Group successfully created!"),p()}catch(e){console.error("Failed to create group:",e),y.Ay.error("Failed to create a group"),u(!1)}};return(0,o.jsxs)("div",{children:[(0,o.jsx)("input",{type:"checkbox",id:"add-group-modal",className:"modal-toggle",checked:e,readOnly:!0}),(0,o.jsxs)("div",{className:"modal justify-start! absolute z-50 top-0 left-0 w-full bg-white! flex flex-col h-full",children:[(0,o.jsx)("div",{className:"flex-1 overflow-y-auto w-full",children:(0,o.jsxs)("div",{className:"text-black p-0 w-full",children:[(0,o.jsxs)("div",{className:"flex flex-row justify-between items-center mx-5 pt-3 pb-2 border-b border-b-black/10",children:[(0,o.jsx)("span",{className:"font-bold text-lg flex flex-row items-center gap-3",children:"Add Custom Layer Group"}),(0,o.jsx)("label",{htmlFor:"add-group-modal",className:"btn btn-sm btn-circle btn-ghost",onClick:()=>{t(!1),r("")},children:"✕"})]}),(0,o.jsxs)("div",{className:"m-5 flex flex-col",children:[(0,o.jsx)("span",{className:"label-text font-bold",children:"New Group Name"}),(0,o.jsx)("input",{type:"text",placeholder:"",className:"mt-2 mb-4 input",value:a,onChange:e=>{r(e.target.value.replace(/[^a-zA-Z0-9]/g,""))},disabled:0===c.length}),c.length>0?(0,o.jsx)(rz,{layers:c,selectedLayers:i,setSelectedLayers:n}):(0,o.jsx)("div",{className:"label-text font-bold",children:"No ungrouped layers"})]})]})}),(0,o.jsx)("div",{className:"w-full",children:(0,o.jsx)("div",{className:"flex justify-end mx-5 mt-5",children:(0,o.jsx)("button",{className:`btn w-full ${d||!a||0===a.length||0===i.size||0===c.length?"cursor-not-allowed":"tt-blue-button"}`,disabled:d||!a||0===a.length||0===i.size||0===c.length,onClick:()=>{m()},children:d?(0,o.jsxs)("span",{className:"flex items-center justify-center",children:[(0,o.jsx)("span",{className:"loading loading-spinner loading-xs mr-2"}),(0,o.jsx)("span",{children:"Adding..."})]}):"Add"})})}),(0,o.jsx)("label",{className:"modal-backdrop",htmlFor:"add-group-modal",onClick:p,children:"Close"})]})]})},rW=({selectedGroup:e,groupLayers:t,groupName:a,setGroupName:r,editGroupModal:s,setEditGroupModal:l,handleDeleteGroup:i,handleDeleteAllLayers:n,handleSaveGroup:c})=>{let d=(0,ex.u)().user,u=(0,eV.H)(),[p,m]=(0,h.useState)(!1),[x,f]=(0,h.useState)(!1),[g,y]=(0,h.useState)(!1),[b,j]=(0,h.useState)("group"),w=u.customLayers.filter(e=>"Published"===e.scope||"ProjectGIS"===e.scope||e.user_id===d?.id).filter(t=>t.properties.group===e),[v,N]=(0,h.useState)(new Set),S=u.customLayers.filter(e=>!!e.id&&!e.properties?.group),k=()=>{N(new Set),r(""),l(!1),y(!1),f(!1)},_=async()=>{"group"===b?await i(w):await n(w),k()};return(0,o.jsxs)("div",{children:[(0,o.jsx)(V.A,{isOpen:g,onDelete:_,closeModal:()=>y(!1),deleteText:"group"===b?"Are you sure you want to ungroup?":"Are you sure you want to delete all layers in this group?"}),(0,o.jsx)("input",{type:"checkbox",id:"edit-group-modal",className:"modal-toggle",checked:s,readOnly:!0}),(0,o.jsxs)("div",{className:"modal justify-start! absolute z-50 -top-0 left-0 w-full! bg-white! overflow-y-auto flex flex-col h-full",children:[(0,o.jsxs)("div",{className:"w-full p-0 flex-1 overflow-y-auto",children:[(0,o.jsxs)("div",{className:"flex flex-row justify-between items-center mx-5 pt-3 pb-2 border-b border-b-black/10",children:[(0,o.jsx)("span",{className:"font-bold text-lg",children:"Edit Group"}),(0,o.jsx)("label",{htmlFor:"edit-group-modal",className:"btn btn-sm btn-circle btn-ghost",onClick:()=>{k()},children:"✕"})]}),(0,o.jsxs)("div",{className:"m-5 flex flex-col",children:[(0,o.jsx)("span",{className:"label-text font-bold",children:"Change Group Name"}),(0,o.jsx)("input",{type:"text",placeholder:e,value:a,className:"text-black input  mt-2 mb-4",onCh
15ange:e=>{r(e.target.value.replace(/[^a-zA-Z0-9]/g,""))}}),(0,o.jsx)("div",{className:"flex-1",children:S.length>0&&(0,o.jsx)(rz,{layers:S,selectedLayers:v,setSelectedLayers:N})})]})]}),(0,o.jsxs)("div",{className:"mt-4 w-full",children:[x&&(0,o.jsx)("div",{className:"mx-5 bg-red-100 border border-red-400 rounded-lg p-4",children:(0,o.jsxs)("div",{className:"mt-1 flex flex-col space-y-2",children:[(0,o.jsx)("button",{className:"btn btn-sm text-white bg-red-500 hover:bg-red-600",onClick:async()=>{j("group"),y(!0),f(!1)},children:"Ungroup"}),(0,o.jsx)("button",{className:"btn btn-sm text-white bg-red-500 hover:bg-red-600",onClick:async()=>{j("layers"),y(!0),f(!1)},children:"Delete Layers In Group"}),(0,o.jsx)("button",{className:"btn btn-sm btn-ghost",onClick:()=>f(!1),children:"Cancel"})]})}),(0,o.jsxs)("div",{className:"flex justify-between mt-8 mx-5",children:[(0,o.jsx)("button",{className:"btn btn-sm tt-blue-button",disabled:p,onClick:async()=>{m(!0);try{await c(t,v),N(new Set)}finally{m(!1)}},children:p?(0,o.jsx)("span",{className:"loading loading-spinner loading-xs text-white"}):"Save"}),(0,o.jsx)("div",{className:"flex items-center",children:(0,o.jsxs)("button",{className:"btn btn-sm text-white bg-red-500 hover:bg-red-600 flex items-center",onClick:()=>{f(!x)},children:[(0,o.jsx)(z.b6i,{size:20}),x?(0,o.jsx)($.nwe,{size:25}):(0,o.jsx)($.mlL,{size:25})]})})]})]}),(0,o.jsx)("label",{className:"modal-backdrop",htmlFor:"edit-group-modal",onClick:()=>{k()},children:"Close"})]})]})};var rB=a(88321),rV=a(16614);let rG=e=>{let t=(0,eG.JY)().map;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:"mt-5",children:[(0,o.jsx)("span",{className:"font-bold text-sm mr-2",children:"Coordinates"}),(0,rV.q7)(e.ifcLat,e.ifcLon,e.setIfcLat,e.setIfcLon)]}),(0,o.jsxs)("div",{className:"flex flex-row mt-5 w-full",children:[(0,o.jsxs)("div",{className:"flex flex-col",children:[(0,o.jsx)("span",{className:"font-bold text-sm mr-1",children:"Scale"}),(0,o.jsx)("div",{className:"flex items-center mt-1",children:(0,o.jsx)("input",{type:"number",placeholder:"Scale",value:e.ifcScale,onChange:t=>{e.setIfcScale(Number(t.target.value))},className:"text-black input  w-32 mr-4"})})]}),(0,o.jsxs)("div",{className:"flex flex-col",children:[(0,o.jsx)("span",{className:"font-bold text-sm",children:"Elevation"}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("input",{type:"number",placeholder:"Elevation",className:"text-black input  w-32 mr-2 mt-1",value:null!==e.ifcElevation?e.ifcElevation.toFixed(3):0,onChange:t=>{""===t.target.value?e.setIfcElevation(null):e.setIfcElevation(Number(t.target.value))}}),(0,o.jsxs)("button",{className:"btn btn-square mt-1 group relative",onClick:()=>e.setIfcElevation(t.current?.queryTerrainElevation([e.ifcLon,e.ifcLat])),children:[(0,o.jsx)($.yzF,{size:23}),(0,o.jsxs)("div",{className:"absolute hidden group-hover:block bg-gray-700 text-white text-xs rounded p-2 w-60 top-1/2 transform -translate-x-1/3 translate-y-8 text-center mr-8",children:["Get elevation based on coordinates set above.",(0,o.jsx)("br",{}),"Disclaimer: Go to coordinates on map for more accurate results.",(0,o.jsx)("div",{className:"absolute transform left-52 -top-2 w-0 h-0 border-l-8 border-r-8 border-b-8 border-b-gray-700 border-l-transparent border-r-transparent"})]})]})]})]})]}),(0,o.jsxs)("div",{className:"mt-5 flex flex-col",children:[(0,o.jsx)("span",{className:"font-bold text-sm mr-2",children:"Rotation"}),(0,o.jsxs)("div",{className:"flex mt-1",children:[(0,o.jsx)("input",{type:"number",placeholder:"x-axis",className:"text-black input  w-24 mr-5",value:e.ifcX,onChange:t=>{""===t.target.value?e.setIfcX(null):e.setIfcX(Number(t.target.value))}}),(0,o.jsx)("input",{type:"number",placeholder:"y-axis",className:"text-black input  w-24 mr-5",value:e.ifcY,onChange:t=>{""===t.target.value?e.setIfcY(null):e.setIfcY(Number(t.target.value))}}),(0,o.jsx)("input",{type:"number",placeholder:"z-axis",className:"text-black input  w-24",value:e.ifcZ,onChange:t=>{""===t.target.value?e.setIfcZ(null):e.setIfcZ(Number(t.target.value))}})]})]})]})};function rJ(e){return(0,o.jsx)("div",{children:(0,o.jsx)("div",{className:"flex justify-center flex-row mb-0",children:(0,o.jsxs)("div",{className:"flex flex-wrap mx-0",children:[e.nullIcon&&(0,o.jsx)("div",{className:"mt-3 px-0",children:(0,o.jsx)("button",{type:"button",className:"btn-sm rounded-full",onClick:()=>{e.setActiveSymbol(""),e.handleIconSelect(0),e.closeDropdown()},children:(0,o.jsx)("div",{className:"bock mx-auto text-[11px] font-normal leading-3 opacity-60 text-black",style:{width:"20px",height:"20px"},children:"No icon"})})},"0"),void 0!==e.setShowEmojiPicker&&(0,o.jsx)("div",{className:"mt-3 px-0",children:(0,o.jsx)("button",{type:"button",className:"btn-sm rounded-full",onClick:()=>e.setShowEmojiPicker?.(!0),title:"Select Custom Icon",children:(0,o.jsx)(e0.E5P,{className:"text-black",style:{width:"23",height:"23"}})})},"emoji"),e.icons.filter(e=>Number(e.id)).map(t=>(0,o.jsx)("div",{className:"mt-3 px-0",children:e.activeID==parseInt(t.id)?(0,o.jsx)("button",{type:"button",className:"p-0 w-8 h-8 flex items-center justify-center rounded-full shadow selected border-2 border-blue-500 bg-white hover:bg-gray-50",onClick:()=>{e.setActiveSymbol(t.image),e.handleIconSelect(parseInt(t.id)),e.closeDropdown()},children:(0,o.jsx)(d(),{src:t.image,title:t.title,alt:"symbol"+t.id,width:"23",height:"23",className:"rounded-full"})}):(0,o.jsx)("button",{type:"button",className:"p-0 w-8 h-8 flex items-center justify-center rounded-full bg-white hover:bg-gray-50 border border-gray-200",onClick:()=>{e.setActiveSymbol(t.image),e.handleIconSelect(parseInt(t.id)),e.closeDropdown()},children:(0,o.jsx)(d(),{src:t.image,alt:"symbol"+t.id,title:t.title,width:"23",height:"23",className:"rounded-full"})})},t.id))]})})})}var rq=a(45602);let rY=e=>{let t=(0,h.useRef)(null),a=(0,eG.JY)().map,[r,s]=(0,h.useState)(!1),[l,i]=(0,h.useState)(1),[n,c]=(0,h.useState)("1"),[d,u]=(0,h.useState)(0),[p,m]=(0,h.useState)([]),x=(0,h.useRef)(null);(0,h.useEffect)(()=>{(async()=>{try{let t=await (0,_.x)("/layer/distinct",{params:{id:e.layer.id,attribute:e.attribute}});
15u(Math.ceil(t/50))}catch(e){console.error(e)}})()},[e.layer,e.attribute]),(0,h.useEffect)(()=>{s(!0);let t=async()=>{try{let t=await (0,_.x)("/layer/attribute",{params:{id:e.layer.id,attribute:e.attribute,limit:50,offset:(l-1)*50}});m(t)}catch(e){console.error(e)}finally{s(!1)}};return x.current&&clearTimeout(x.current),x.current=setTimeout(async()=>{e.layer&&t()},1e3),()=>{x.current&&clearTimeout(x.current)}},[l,e.attribute,e.layer]);let f=e=>{e<1?e=1:e>d&&(e=d),i(e),c(e.toString())},g=(0,h.useMemo)(()=>Array.from(new Set(p.map(e=>(0,N.cM)(e)))),[p]);return(0,o.jsxs)("div",{className:"flex flex-col h-full w-full",children:[(0,o.jsx)("div",{className:"grow overflow-auto mt-2 max-h-[150px]",children:(0,o.jsx)("div",{className:"flex flex-col gap-2",children:(0,o.jsx)("table",{ref:t,className:"table-fixed border-collapse border border-gray-200 w-full",children:r?(0,o.jsx)("tbody",{children:(0,o.jsx)("tr",{children:(0,o.jsx)("td",{className:"flex justify-center items-center py-8",children:(0,o.jsx)("span",{className:"flex justify-center items-center loading loading-spinner loading-sm"})})})}):(0,o.jsxs)("tbody",{children:[(0,o.jsxs)("tr",{children:[(0,o.jsx)("th",{className:"px-4 py-1.5 border border-gray-200 text-black font-bold",children:"Value"}),(0,o.jsx)("th",{className:"px-4 py-1.5 border border-gray-200 text-black font-bold",children:"Color"})]}),g.map((t,r)=>(0,o.jsxs)("tr",{className:r%2==0?"bg-[#f2f2f2]":"bg-[#fafafa]",children:[(0,o.jsx)("td",{className:"px-4 py-2 border border-gray-200 text-black font-medium text-center break-words",children:t}),(0,o.jsx)("td",{className:"px-4 py-2 border border-gray-200 text-black font-medium text-center",children:(0,o.jsxs)("div",{className:"flex justify-center items-center",children:[(0,o.jsx)(tr,{color:e.colors[t]?e.colors[t]:e.editLayerColor,handleChangeColor:r=>{let s,l,i,n,o,c;return s=r.target.value,l=(0,N.cM)(t),(i={...e.colors})[l]=s,e.setColors(i),n=(0,N.Qo)(i,e.attribute,e.editLayerColor),o=(0,rq.tP)(e.layer.id),void(((c=(0,rq.tP)(e.layer.id).filter(e=>!!a.current?.getLayer(e))).length>0?c:(a.current?.getStyle?.()?.layers??[]).filter(t=>t?.source===`${e.layer.id}-source`).filter(e=>o.includes(e.id)).map(e=>e.id)).forEach(e=>{let t=a.current?.getLayer(e)?.type;t&&"symbol"!==t&&a.current?.setPaintProperty(e,`${t}-color`,n)}),a.current?.triggerRepaint?.())},label:""}),e.showOpacityControls&&(0,o.jsxs)("details",{className:"dropdown dropdown-bottom dropdown-end flex flex-col items-center",onClick:e=>{if(!e.currentTarget.open){let t=e.currentTarget.querySelector(".dropdown-content");setTimeout(()=>{t?.scrollIntoView({behavior:"smooth",block:"end"})},0)}},children:["                                                            ",(0,o.jsx)("summary",{className:"btn btn-sm btn-circle",children:(0,o.jsx)(z.nXK,{size:16})}),(0,o.jsx)("div",{className:"dropdown-content min-w-[250px] p-2 bg-white rounded-md z-10",children:(0,o.jsx)(rP,{opacity:(e.opacities[t]??e.baseOpacity)/100,setOpacity:a=>{e.setOpacities({...e.opacities,[t]:a})}})})]})]})})]},t))]})})})}),(0,o.jsxs)("div",{className:"flex justify-center items-center gap-1.5 mt-4 w-full",children:[(0,o.jsx)("button",{onClick:()=>f(1),className:`border border-gray-300 bg-white rounded-md btn btn-sm ${1===l?"opacity-50 cursor-not-allowed bg-gray-300":""}`,children:(0,o.jsx)(z.V2s,{})}),(0,o.jsx)("button",{onClick:()=>l>1&&f(l-1),className:`border border-gray-300 bg-white rounded-md btn btn-sm ${1===l?"opacity-50 cursor-not-allowed bg-gray-300":""}`,children:(0,o.jsx)(z.Wup,{})}),(0,o.jsxs)("div",{className:"flex justify-center items-center gap-1.5 grow",children:[(0,o.jsx)("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",value:n,onChange:e=>{let t=e.target.value;if(""===t)return void c(t);let a=Number(t);Number.isNaN(a)||f(a)},onBlur:()=>{""===n&&c(l.toString())},className:"input input-sm"}),(0,o.jsx)("div",{className:"whitespace-nowrap",children:`/ ${d}`})]}),(0,o.jsx)("button",{onClick:()=>l<d&&f(l+1),className:`border border-gray-300 bg-white rounded-md btn btn-sm ${l===d?"opacity-50 cursor-not-allowed bg-gray-300":""}`,children:(0,o.jsx)(z.mny,{})}),(0,o.jsx)("button",{onClick:()=>f(d),className:`border border-gray-300 bg-white rounded-md btn btn-sm ${l===d?"opacity-50 cursor-not-allowed bg-gray-300":""}`,children:(0,o.jsx)(z.$uC,{})})]})]})},rH=e=>{let t=(0,eG.JY)().map,a=(0,ev.O)().project,r=e.selectedLayer?.properties??{},s=r.gradientData??{},[l,i]=(0,h.useState)([]),[n,c]=(0,h.useState)(),u=t.current?.getLayer(e.selectedLayer.id),p=(0,h.useRef)(null),f=(0,h.useRef)(null),[g,y]=(0,h.useState)({[x.y$.color]:100,[x.y$.icon]:100,[x.y$.gradient]:100,[x.y$.categorical]:100,[x.y$.line]:100,[x.y$.label]:100}),b=e=>g[e]??100,j=(a,l)=>{let i;if(!w())return;let n=t.current?.getLayer(e.selectedLayer.id);if(!(n&&(t.current?.getLayoutProperty(n.id,"visibility")??"visible")==="visible"))return;i=void 0!==l?l!==x.iT?l:void 0:[e.activeSymbol,r.icon].find(e=>!!e&&e!==x.iT);let o=a===x.y$.icon?i:void 0,c=a!==x.y$.icon&&s.gradientType===x.nd.categorical;(0,ai.Vj)(t,{...e.selectedLayer,properties:{...r,icon:o,gradientData:c?{...s,gradientType:x.nd.gradient}:s}})},w=()=>{let t=(0,rq.gl)(e.geojson??{type:"FeatureCollection",features:[]});return t.size>0?1===t.size&&t.has("Point"):"Point"===(0,rq.NG)(r.geojson_type??null)};function v(){let a=(0,rq.tP)(e.selectedLayer.id),r=a.filter(e=>!!t.current?.getLayer(e));return r.length>0?r:(t.current?.getStyle?.()?.layers??[]).filter(t=>t?.source===`${e.selectedLayer.id}-source`).filter(e=>a.includes(e.id)).map(e=>e.id)}
15function S(e){v().forEach(a=>{let r=t.current?.getLayer(a)?.type;r&&"symbol"!==r&&t.current?.setPaintProperty(a,`${r}-color`,e)})}function k(t,a){let s=a?.gradient1??e.gradient1,l=a?.gradient2??e.gradient2,i=e.geojson;S((0,N.JO)(s,l,e.categoricalColors,t,e.property,r.color,JSON.stringify(i)))}function _(){return v().filter(e=>{let a=t.current?.getLayer(e)?.type;return"fill"===a||"line"===a||"circle"===a||"symbol"===a})}function C(e){return"symbol"===e?"icon-opacity":`${e}-opacity`}function L(t){return["case",["boolean",["feature-state","hidden"],!1],0,["boolean",["feature-state","selected"],!1],1,(0,N.P6)(e.categoricalOpacities,e.property,t)]}function D(t){return["case",["boolean",["feature-state","hidden"],!1],0,(0,N.Cq)(e.categoricalOpacities,e.property,t)]}function A(a,s){c(a),e.setColorOption(a),j(a);let l=s??(a===x.y$.color||a===x.y$.categorical?b(a):100);e.setEditLayerOpacity(l),a===x.y$.gradient||a===x.y$.categorical?(e.setUseGradient(!0),e.setGradientOption(a.toLowerCase()),k(a===x.y$.categorical?x.nd.categorical:x.nd.gradient)):(e.setUseGradient(!1),a===x.y$.color&&S(e.editLayerColor??r.color));try{v().forEach(e=>{let r,s=t.current?.getLayer(e);if(!s)return;r=a===x.y$.categorical&&"fill"===s.type?L(l):a===x.y$.categorical&&"fill"!==s.type?D(l):"fill"===s.type?["case",["boolean",["feature-state","hidden"],!1],0,["boolean",["feature-state","selected"],!1],1,(0,N.gS)(l)]:l/100;let i=C(s.type);if(t.current?.setPaintProperty(e,i,r),"fill"===s.type){let a=`${e}-stroke`;t.current?.getLayer(a)&&t.current?.setPaintProperty(a,"line-opacity",r)}}),t.current?.triggerRepaint?.()}catch(e){console.error("Error setting opacity:",e)}}return(0,h.useEffect)(()=>{let t;if(!e.selectedLayer||(i((t=[x.y$.color],w()&&t.push(x.y$.icon),r.geojson_properties&&0!==r.geojson_properties.length&&t.push(x.y$.gradient,x.y$.categorical),t)),f.current===e.selectedLayer.id))return;f.current=e.selectedLayer.id;let a=r.opacity??100,l=r.icon&&r.icon!==x.iT?100:a,n=s?.gradientType===x.nd.categorical?a:100;y({[x.y$.color]:l,[x.y$.icon]:100,[x.y$.gradient]:100,[x.y$.categorical]:n,[x.y$.line]:100,[x.y$.label]:100});let o=s?.gradientType===x.nd.categorical?x.y$.categorical:s?.property?x.y$.gradient:w()&&r.icon&&r.icon!==x.iT?x.y$.icon:x.y$.color,d=100;o===x.y$.color?d=l:o===x.y$.categorical&&(d=n),c(o),A(o,d)},[e.selectedLayer,e.geojson]),(0,h.useEffect)(()=>{let t="";s.property?t=s.property:r.geojson_properties&&(t=r.geojson_properties[0]),e.setEditLayerColor(r.color),e.setProperty(t),e.setGradient1(s.gradient1?s.gradient1:"#000000"),e.setGradient2(s.gradient2?s.gradient2:"#ffffff"),e.setCategoricalColors(s.categorical?s.categorical:{}),e.setCategoricalOpacities(s.categoricalOpacities??{})},[]),(0,h.useEffect)(()=>{if(!e.showDropdown)return;let t=t=>{p.current&&!p.current.contains(t.target)&&e.setShowDropdown(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[e.showDropdown,e.setShowDropdown]),(0,h.useEffect)(()=>{if(!e.geojson||!s?.property)return;let t=s.gradientType===x.nd.categorical?x.nd.categorical:x.nd.gradient;S((0,N.JO)(s.gradient1??"#000000",s.gradient2??"#ffffff",s.categorical??{},t,s.property,r.color,JSON.stringify(e.geojson)))},[e.geojson,e.selectedLayer?.id]),(0,h.useEffect)(()=>{e.selectedLayer?.id&&function(){if(!a?.container_name||!e.selectedLayer?.file_path)return;let r=(0,av.oD)(e.selectedLayer.id);r.length>0?e.setGeojson({type:"FeatureCollection",features:r}):fetch(`${m.oj}${a.container_name}/layers/${e.selectedLayer.file_path}`).then(async a=>{if(!a.ok)return;let r=await a.json();e.setGeojson(r);let s=`${e.selectedLayer.id}-source`,l=t.current?.getSource(s);l?.setData&&r&&l.setData(r)}).catch(()=>{})}()},[e.selectedLayer?.id,a?.container_name]),(0,h.useEffect)(()=>{e.geojson&&(n===x.y$.gradient||n===x.y$.categorical)&&k(n===x.y$.categorical?x.nd.categorical:x.nd.gradient)},[e.geojson,n]),(0,h.useEffect)(()=>{if(n!==x.y$.categorical)return;let e=b(x.y$.categorical);_().forEach(a=>{let r=t.current?.getLayer(a)?.type;if(!r)return;let s="fill"===r?L(e):D(e);if(t.current?.setPaintProperty(a,C(r),s),"fill"===r){let e=`${a}-stroke`;t.current?.getLayer(e)&&t.current?.setPaintProperty(e,"line-opacity",s)}}),t.current?.triggerRepaint?.()},[n,e.categoricalOpacities,e.property,g,e.selectedLayer?.id]),u&&(t.current?.getLayoutProperty(u.id,"visibility")??"visible")==="visible"?(0,o.jsxs)("div",{className:"flex flex-col mt-2 items-center",children:[(0,o.jsx)("div",{className:"tabs tabs-lift mt-3 w-full",children:l.map((e,t)=>(0,o.jsxs)("label",{className:`tab flex-1 text-center text-xs ${n===e?"tab-active border-gray-100! border-l-2 border-r-2 border-t-2":"bg-gray-100"}`,style:{color:"black"},onClick:()=>A(e),children:[(0,o.jsx)("span",{className:"hidden md:inline",children:e}),(0,o.jsx)("span",{className:"md:hidden",children:e})]},t))}),n===x.y$.color&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("div",{className:"flex justify-between items-center mt-3",children:(0,o.jsx)(tr,{c
15olor:e.editLayerColor??r.color,handleChangeColor:t=>{S(t.target.value),e.setEditLayerColor(t.target.value)},label:""})}),(0,o.jsx)("div",{className:"w-full pl-1 my-2",children:(0,o.jsx)(rP,{opacity:b(x.y$.color)/100,setOpacity:a=>{y(e=>({...e,[x.y$.color]:a})),v().filter(e=>{let a=t.current?.getLayer(e)?.type;return"fill"===a||"line"===a||"circle"===a||"symbol"===a}).forEach(e=>{let r=t.current?.getLayer(e)?.type;if(!r)return;let s=C(r);if("fill"===r){let r=["case",["boolean",["feature-state","hidden"],!1],0,["boolean",["feature-state","selected"],!1],1,(0,N.gS)(a)];t.current?.setPaintProperty(e,s,r);let l=`${e}-stroke`;t.current?.getLayer(l)&&t.current?.setPaintProperty(l,"line-opacity",r);return}t.current?.setPaintProperty(e,s,a/100)}),e.setEditLayerOpacity(a)}})})]}),n===x.y$.icon&&(0,o.jsx)("div",{className:"flex justify-between items-center mt-3",children:(0,o.jsxs)("div",{className:"relative justify-center",ref:p,children:[(0,o.jsx)("button",{type:"button",className:"btn btn-square mt-1",onClick:t=>{t.stopPropagation(),e.setShowDropdown(!e.showDropdown)},children:(0,o.jsx)(d(),{src:e.activeSymbol,alt:"current symbol",width:25,height:25})}),e.showDropdown&&(0,o.jsx)("ul",{className:"dropdown-content z-100 menu p-2 shadow bg-base-100 rounded-box w-64 max-h-48 overflow-y-auto absolute left-1/2 transform -translate-x-1/2",children:(0,o.jsx)(rJ,{icons:rB.w,activeID:e.activeID,setActiveSymbol:e.setActiveSymbol,handleIconSelect:function(t){if(t==e.activeID)1==t?e.setActiveID(e.colorPickerID):(e.setActiveID(e.colorPickerID),e.setActiveSymbol(x.iT)),j(x.y$.icon,x.iT);else{e.setActiveID(t);let a=rB.w.find(e=>parseInt(e.id)===t);a&&(e.setActiveSymbol(a.image),j(x.y$.icon,a.image))}},closeDropdown:function(){e.setShowDropdown(!1)},nullIcon:!1})})]})}),(n===x.y$.gradient||n===x.y$.categorical)&&(0,o.jsxs)("div",{className:"gradient-container mt-1",children:[n===x.y$.gradient&&(0,o.jsxs)("div",{className:"gradient-color-container mb-2 mx-2",children:[(0,o.jsx)(tr,{color:e.gradient1,handleChangeColor:t=>{let a=t.target.value;k(x.nd.gradient,{gradient1:a}),e.setGradient1(a)},label:"",customWidth:60}),(0,o.jsx)("div",{className:"gradient-bar",style:{backgroundImage:`linear-gradient(to right, ${e.gradient1}, ${e.gradient2})`}}),(0,o.jsx)(tr,{color:e.gradient2,handleChangeColor:t=>{let a=t.target.value;k(x.nd.gradient,{gradient2:a}),e.setGradient2(a)},label:"",customWidth:60})]}),(0,o.jsxs)("div",{className:"mt-2 flex flex-col gap-2",children:[(0,o.jsx)("div",{className:"flex items-center",children:(0,o.jsx)("span",{className:"label-text",children:"Gradient Property"})}),(0,o.jsx)("select",{className:"text-black select w-full",onChange:a=>{let l,i=a.target.value;e.setProperty(i),i!==s.property?(l={},e.setCategoricalColors(l),e.setCategoricalOpacities({})):(l=s.categorical??{},e.setCategoricalColors(l),e.setCategoricalOpacities(s.categoricalOpacities??{}));let o=e.geojson?JSON.stringify(e.geojson):null;if(!o)return;let c=n===x.y$.categorical;S((0,N.JO)(e.gradient1,e.gradient2,c?l:{},c?x.nd.categorical:x.nd.gradient,i,r.color,o)),t.current?.triggerRepaint?.()},children:r.geojson_properties?.map((t,a)=>(0,o.jsx)("option",{value:t,selected:e.property===t||0===a&&!r.geojson_properties.includes(e.property),children:t},a))})]}),n===x.y$.categorical&&(0,o.jsx)("div",{children:(0,o.jsx)(rY,{layer:e.selectedLayer,showOpacityControls:_().length>0,baseOpacity:b(x.y$.categorical),attribute:e.property,colors:e.categoricalColors,setColors:e.setCategoricalColors,opacities:e.categoricalOpacities,setOpacities:e.setCategoricalOpacities,editLayerColor:e.editLayerColor})})]})]}):(0,o.jsxs)("div",{className:"rounded-md bg-orange-100 p-3 flex items-center gap-3 mt-2 ml-1 text-black/70 text-[12px]",children:[(0,o.jsx)("div",{children:(0,o.jsx)(W.qVV,{size:20})}),(0,o.jsxs)("div",{children:[(0,o.jsx)("p",{className:"font-bold",children:"Editing hidden layer styles is disabled"}),(0,o.jsx)("p",{children:"Toggle the layer to visible to enable editing of colors and opacities."})]})]})},rZ=({selectedLayer:e,setLayerScope:t,setChangeLayerScope:a,setDeleteModalOpen:r,handleSaveClick:s,handleDeleteClick:l,closePanel:i})=>{let n=(0,ex.u)().user,c=(0,ev.O)().project,[d,u]=(0,h.useState)(!1),p=e.user_id===n?.id||c?.project_uuid&&(0,v._A)(n,c?.project_uuid);return(0,o.jsxs)("div",{className:"flex justify-between mt-4 mb-4",children:[(0,o.jsx)(V.A,{isOpen:d,onDelete:()=>{l(e)},closeModal:()=>{u(!1)}}),(0,o.jsxs)("div",{className:"flex gap-2 h-full",children:["Draft"===e.scope&&(0,o.jsx)("button",{className:"btn btn-sm publish-button",onClick:()=>{t("Published"),a(!0)},children:"Publish"}),(0,o.jsx)("button",{className:"btn btn-sm tt-blue-button",id:"save-layer
15-button",onClick:async()=>{await s()},children:"Save"}),"Published"===e.scope&&p&&!e.properties.hasLRS&&(0,o.jsx)("button",{className:"btn btn-sm draft-button",onClick:()=>{t("Draft"),a(!0)},children:"Save as Draft"}),(0,o.jsx)("button",{className:"btn btn-sm",onClick:()=>{i()},children:"Cancel"})]}),(0,o.jsx)("div",{className:"flex items-center",children:(0,o.jsx)("button",{"data-testid":"sidebar-delete-layer-button",className:"btn btn-sm btn-error text-white",onClick:()=>"ProjectGIS"===e.scope?r(!0):u(!0),children:(0,o.jsx)(W.WeY,{})})})]})};var rX=a(47133);async function rK({layerId:e}){return(0,_.x)(`/layer/${e}/properties`)}async function rQ({layerId:e,featureId:t}){return(0,_.x)(`/layer/${e}/custom-form/${t}`)}async function r0({layerId:e,projectId:t}){return(0,_.x)(`/layer/${e}/form-template`,{params:{project_id:t}})}async function r1({layerId:e,projectId:t,formData:a,geojson:r}){return(0,_.x)(`/layer/${e}/custom-form`,{method:"POST",json:{layerData:{project_id:t,geojson:r},fields:a}})}async function r2({layerId:e,featureId:t,metadata:a,geoJsonFeature:r}){return(0,_.x)(`/layer/${e}/feature/${t}`,{method:"PATCH",json:{metadata:a,geoJsonFeature:r}})}async function r5({layerId:e,featureIds:t}){return(0,_.x)(`/layer/${e}/features`,{method:"DELETE",params:{ids:t.join(",")}})}async function r3({layerId:e,featureId:t,file:a}){let r=new FormData;return r.append("file",a),(0,_.x)(`/layer/${e}/feature/${t}/attachments`,{method:"POST",form:r})}async function r4({layerId:e,featureId:t,attachmentId:a}){await (0,_.x)(`/layer/${e}/feature/${t}/attachments/${a}`,{method:"DELETE",rawResponse:!0})}let r8=({selectedLayer:e,setSelectedLayer:t,setEditMode:a,editLayerColor:r,setEditLayerColor:s,setEditLayerName:l,setEditLayerOpacity:i,setLayerScope:n,setGroupName:c,groups:d,setDeleteModalOpen:u,handleSaveClick:p,handleDeleteClick:f,icon:g,setIcon:b,useGradient:j,setUseGradient:w,gradient1:S,setGradient1:k,gradient2:_,setGradient2:C,categoricalColors:L,setCategoricalColors:D,categoricalOpacities:A,setCategoricalOpacities:M,property:E,setProperty:T,gradientOption:I,setGradientOption:P,ifcLat:F,setIfcLat:O,ifcLon:R,setIfcLon:$,ifcElevation:z,setIfcElevation:U,ifcScale:W,setIfcScale:B,ifcX:V,setIfcX:G,ifcY:J,setIfcY:q,ifcZ:Y,setIfcZ:H,referenceDate:Z,setReferenceDate:X,setColorOption:K,lineStyle:Q,setLineStyle:ee,setLabelProperty:et})=>{let ea=(0,eG.JY)().map,er=(0,ev.O)().project;(0,eV.H)();let[es,el]=(0,h.useState)(1),[ei,en]=(0,h.useState)(""),[eo,ec]=(0,h.useState)(!1),[ed,eu]=(0,h.useState)(null),[ep,eh]=(0,h.useState)(!1),[ex,ef]=(0,h.useState)(!1),[eg,ey]=(0,h.useState)(e?.properties.labelProperty??""),[eb,ej]=(0,h.useState)([]),[ew,eN]=(0,h.useState)(!1),[eS,ek]=(0,h.useState)(""),[e_,eC]=(0,h.useState)(!1),[eL,eD]=(0,h.useState)(null),eA=(0,h.useCallback)(async()=>{try{let t=Number.parseInt(e?.id??"0"),{properties:a,uploader:r}=await rK({layerId:t});if(!Array.isArray(a))throw Error("Invalid data format");ej(a),eD(`${r.first_name} ${r.last_name}`)}catch(e){console.error(e),y.Ay.error("Failed to get layer properties")}},[e?.id]),eM=()=>{if(!e)return void y.Ay.error("Layer not found");let r=(0,rq.tP)(e.id),l=r.some(e=>ea.current?.getLayer(e)?.type==="symbol"),n=ea.current?.getLayoutProperty(e.id,"visibility")??"visible",o=ea.current?.getSource(`${e.id}-source`),d=o?.serialize?.()?.data??o?._data,u=ed??d,p=ea.current?.getLayer(e.id)?.type,m=!!ea.current?.getLayer(`${e.id}-polygon`)||!!ea.current?.getLayer(`${e.id}-linestring`),h=Array.isArray(u?.features)&&u.features.some(e=>{let t=e?.geometry?.type;return t&&"Point"!==t&&"MultiPoint"!==t});if(!("fill"===p||"line"===p||m||h)||l||e.properties.icon){if(u){let t=e.properties.gradientData;(0,N.KI)(ea,u,e.id,e.properties.color,e.properties.opacity,void 0,t?.property,t?.gradient1,t?.gradient2,t?.categorical,t?.categoricalOpacities,t?.gradientType,e.properties.icon,"ProjectGIS"===e.scope,e.properties.lineStyle,e.properties.labelProperty),(0,rq.tP)(e.id).forEach(e=>{ea.current?.getLayer(e)&&ea.current?.setLayoutProperty(e,"visibility",n)})}}else r.forEach(t=>{let a;(a=ea.current?.getLayer(t))&&t&&!e.properties.icon&&(((t,a)=>{if("symbol"===a.type)return;let r=e.properties.gradientData;r?.property?ea.current?.setPaintProperty(t,`${a.type}-color`,(0,N.JO)(r.gradient1,r.gradient2,r.categorical,r.gradientType,r.property,e.properties.color,JSON.stringify(ed))):e.source!==rX.mb.IFC&&e.source!==rX.mb.GeoTiff&&"raster"!==a.type&&ea.current?.setPaintProperty(t,`${a.type}-color`,String(e.properties.color))})(t,a),((t,a)=>{if("symbol"===a.type)return;let r=e.properties.gradientData;if("fill"===a.type){let s,l=r?.gradientType===x.nd.categorical&&r?.property?["case",["boolean",["feature-state","hidden"],!1],0,["boolean",["feature-state","selected"],!1],1,(0,N.P6)(r.categoricalOpacities,r.property,e.properties.opacity)]:(s=e.properties.opacity,["case",["boolean",["feature-state","hidden"],!1],0,["boolean",["feature-state","selected"],!1],1,(0,N.gS)(s)]);ea.current?.setPaintProperty(t,`${a.type}-opacity`,l);let i=`${t}-stroke`;ea.current?.getLayer(i)&&ea.current?.setPaintProperty(i,"line-opacity",l)}else r?.property?ea.current?.setPaintProperty(t,`${a.type}-opacity`,(0,N.Cq)(r.categoricalOpacities,r.property??"",e.properties.opacity)):["line","raster","circle"].includes(a.type)&&ea.current?.setPaintProperty(t,`${a.type}-opacity`,e.properties.opacity/100)})(t,a))});(0,N.N3)(ea,e),(0,N.To)(ea,e.id,e.properties.labelProperty,e.properties.geojson_type,!1),T(e.properties.gradientData?.property??e.properties.geojson_properties?.[0]??""),w(e.properties.gradientData&&Object.keys(e.properties.gradientData).length>
150),k(e.properties.gradientData?.gradient1??"#000000"),C(e.properties.gradientData?.gradient2??"#ffffff"),D(e.properties.gradientData?.categorical??{}),M(e.properties.gradientData?.categoricalOpacities??{}),s(String(e.properties.color)),i(e.properties.opacity??100),ee(e.properties.lineStyle??x.jV.ss),c(e.properties.group),b(e.properties.icon??x.iT),(0,ai.XB)(e,O,$,B,U,G,q,H),a(!1),t(null),eD(null)};(0,h.useEffect)(()=>{e&&(eA(),"url"===rX.d8[e.source].sourceType&&ek(e.source_url??""),eC([rX.mb.WMS,rX.mb.WFS,rX.mb.WMTS,rX.mb.ArcGIS].includes(e.source)))},[eA,e]),(0,h.useEffect)(()=>{let t=e?.properties.icon?e?.properties.icon:x.iT;b(t),en(t),el(Number.parseInt((0,v.gY)(t,rB.w),10));let a=async()=>{if(!er?.container_name||!e?.file_path)return;let t=await fetch(m.oj+er?.container_name+"/layers/"+e?.file_path);t.ok&&eu(await t.json())};e&&((0,ra.J3)(e.source)||(0,ra.fR)(e.source)?eu({type:"FeatureCollection",features:(0,av.oD)(e.id)}):a()),et(e?.properties.labelProperty??""),ey(e?.properties.labelProperty??""),e?.source&&eN(rX.d8[e.source].labelSupport??!1)},[er?.container_name,e,b,et]),(0,h.useEffect)(()=>{b(ei)},[ei,b]),(0,h.useEffect)(()=>{e&&ep&&(eE(async()=>{await p()}),eh(!1))},[ep,p,e]);let eE=async e=>{ef(!0);try{await e()}finally{ef(!1)}};async function eT(t,a=!1){if(a&&er?.project_uuid&&((0,ra.J3)(e.source)||(0,ra.fR)(e.source)))try{await (0,av.gV)(er.project_uuid,ea,e.id),eu({type:"FeatureCollection",features:(0,av.oD)(e.id)})}catch{y.Ay.error("Failed to refresh label data")}(0,N.To)(ea,e.id,t,e?.properties?.geojson_type),et(t)}let eI=async()=>{await p(),await eT(eg,!0)},eP=(0,h.useMemo)(()=>ed?(0,rq.gl)((0,rq.e_)(ed)).has("LineString"):(0,rq.tP)(e.id).some(e=>ea.current?.getLayer(e)?.type==="line"),[ed,ea,e.id]);return(0,o.jsxs)("div",{children:[(0,o.jsx)("input",{type:"checkbox",id:"edit-layer-modal",className:"modal-toggle",checked:!0,readOnly:!0}),(0,o.jsxs)("div",{className:"modal justify-start! absolute z-50 top-0 left-0 w-full bg-white! flex flex-col h-full",children:[(0,o.jsxs)("div",{className:" text-black p-0 w-full flex-1 overflow-y-auto",children:[ex&&(0,o.jsx)("div",{className:"absolute inset-0 bg-white bg-opacity-50 flex items-center justify-center z-50",children:(0,o.jsx)("span",{className:"loading loading-spinner loading-md"})}),(0,o.jsxs)("div",{className:"h-full",children:[(0,o.jsxs)("div",{className:"flex flex-row justify-between items-center mx-4 pt-3 pb-2 border-b border-b-black/10",children:["IFC"!==e.source?(0,o.jsx)("span",{className:"font-bold text-lg flex flex-row items-center gap-3",children:"Edit Custom Layer"}):(0,o.jsx)("span",{className:"font-bold text-lg flex flex-row items-center gap-3",children:"Edit 3D Layer"}),(0,o.jsx)("label",{htmlFor:"edit-layer-modal",className:"btn btn-sm btn-circle btn-ghost",id:"close-edit-layer-modal-button",onClick:eM,children:"✕"})]}),(0,o.jsxs)("div",{className:"m-4 flex flex-col",children:[(0,o.jsx)("span",{className:"label-text",children:"Change Layer Name"}),(0,o.jsx)("input",{type:"text",placeholder:e.name,className:"text-black input mt-2 w-full",onChange:e=>{l(e.target.value)}}),(0,o.jsxs)("div",{className:"label-text ml-1 mt-2",children:[(0,o.jsx)("span",{className:"font-bold",children:"Uploaded by: "}),eL]}),(0,o.jsxs)("div",{children:["IFC"===e.source&&(0,o.jsx)(rG,{ifcLat:F,setIfcLat:O,ifcLon:R,setIfcLon:$,ifcScale:W,setIfcScale:B,ifcElevation:z,setIfcElevation:U,ifcX:V,setIfcX:G,ifcY:J,setIfcY:q,ifcZ:Y,setIfcZ:H}),ea.current?.getLayer(e.id)?.type==="raster"?(0,o.jsx)("div",{className:"w-full pl-1 mt-4 mb-2",children:(0,o.jsx)(rP,{opacity:ea.current?.getPaintProperty(e.id,"raster-opacity"),setOpacity:t=>{ea.current?.setPaintProperty(e.id,"raster-opacity",t/100),i(t)}})}):"IFC"!==e.source&&(0,o.jsx)(rH,{selectedLayer:e,geojson:ed,setGeojson:eu,editLayerColor:r,setEditLayerColor:s,useGradient:j,setUseGradient:w,gradientOption:I,setGradientOption:P,gradient1:S,setGradient1:k,gradient2:_,setGradient2:C,categoricalColors:L,setCategoricalColors:D,categoricalOpacities:A,setCategoricalOpacities:M,property:E,setProperty:T,setEditLayerOpacity:i,activeSymbol:ei,setActiveSymbol:en,showDropdown:eo,setShowDropdown:ec,icon:g,pointLayerIcons:rB.w,activeID:es,setActiveID:el,colorPickerID:1,setColorOption:K})]}),eP&&(0,o.jsxs)("div",{className:"mt-2 flex flex-col gap-2",children:[(0,o.jsx)("span",{className:"label-text",children:"Line Style"}),(0,o.jsx)("select",{value:Q,className:"select select-bordered w-full",onCh
15ange:t=>{let a=t.target.value;ee(a),(0,N.N3)(ea,e,a)},children:Object.values(x.jV).map((e,t)=>(0,o.jsx)("option",{value:e,children:e},t))})]}),eb.length>0&&ew&&(0,o.jsxs)("div",{className:"mt-2 flex flex-col gap-2",children:[(0,o.jsx)("span",{className:"label-text",children:"Labelling"}),(0,o.jsxs)("select",{className:"text-black select select-bordered w-full",onChange:e=>{let t=e.target.value;ey(t),eT(t)},value:eg,children:[(0,o.jsx)("option",{value:"",children:"Select a property"},"select"),eg&&(0,o.jsx)("option",{value:eg,children:eg},"selected"),eb?.filter(e=>e.column_name!==eg).map(e=>(0,o.jsx)("option",{value:e.column_name,children:e.column_name},e.column_name))]})]}),"IFC"!==e.source&&(0,o.jsxs)("div",{className:"mt-4 flex flex-col gap-2",children:[(0,o.jsx)("span",{className:"label-text",children:"Change Layer Group"}),(0,o.jsxs)("select",{className:"select w-full",onChange:e=>{c(e.target.value)},children:[(0,o.jsx)("option",{value:"",selected:!e.properties.group,children:"No Group"},"no-group"),d.filter(e=>!!e).map((t,a)=>(0,o.jsx)("option",{value:t,selected:e.properties.group===t,children:t},a))]})]}),(0,o.jsxs)("div",{className:"mt-4 gap-2 flex flex-col",children:[(0,o.jsx)("span",{className:"label-text",children:"Reference Date"}),(0,o.jsx)("input",{type:"datetime-local",className:"input  backdrop-blur-sm bg-white/80 text-black text-sm w-full",value:(0,v.rm)(Z),onChange:e=>{let t=new Date(e.target.value);isNaN(t.getTime())?console.error("Invalid date input"):X(t)}})]}),e_&&(0,o.jsxs)("div",{className:"mt-4 flex flex-col gap-2",children:[(0,o.jsx)("span",{className:"label-text",children:"Source URL"}),(0,o.jsxs)("div",{className:"relative w-full",children:[(0,o.jsx)("input",{type:"text",className:"input  text-black text-sm w-full pr-14",value:eS,readOnly:!0}),(0,o.jsx)("button",{className:"absolute inset-y-0 right-0 z-50 flex items-center justify-center btn btn-sm btn-ghost text-grey-500 m-1",onClick:()=>{navigator.clipboard.writeText(eS),y.Ay.success("URL copied to clipboard")},children:(0,o.jsx)(em.SD3,{})})]})]})]})]})]}),(0,o.jsx)("div",{className:"w-full px-4",children:(0,o.jsx)(rZ,{selectedLayer:e,setLayerScope:n,setChangeLayerScope:eh,setDeleteModalOpen:u,handleSaveClick:()=>eE(async()=>{await eI()}),handleDeleteClick:f,closePanel:eM})})]})]})};var r6=a(62648);let r7=e=>{let t=(0,eG.JY)(),a=(0,aO.h)(),r=(0,ev.O)(),[s,l]=(0,h.useState)(""),[i,n]=(0,h.useState)(!1),c=(0,eD.l)(),d=async()=>{if(!r.project)return;if(""===s)return void y.Ay.error("Invalid tour name");let t=new FormData;t.append("project_id",JSON.stringify(r.project.project_uuid)),t.append("new_name",JSON.stringify(s));try{await (0,_.x)(`/tour/${e.tourId}`,{method:"PATCH",form:t}),e.refreshTourList(),y.Ay.success("Tour name changed successfully")}catch{y.Ay.error("Error updating tour name")}},u=async()=>{if(!r.project)return;n(!0);let s=r.project?.data_types;c.addUploading({title:e.tourName,type:x.dP.delete_tour,progress:100,id:e.tourId,layerStatus:x.iO.processing});try{let[l,i]=await (0,_.x)(`/tour/${e.tourId}`,{method:"DELETE"}),n=r.project;n.data_types=i,r.setProject(n);let o=s.filter(e=>!i.includes(e)),d=a.showCameraX;o.forEach(e=>{delete d[e]}),a.setShowCameraX(d),(0,v.M5)(d,a.setShowCameraX),await (0,r6.DE)(e.map,e.tourId,l),t.markerRef.current&&t.markerRef.current.remove(),c.updateUploading(e.tourId,{progress:100,status:x.nW.complete,message:"Delete successful"}),y.Ay.success("Tour deleted successfully"),e.refreshTourList()}catch{c.updateUploading(e.tourId,{progress:100,status:x.nW.error}),y.Ay.error("Error deleting tour")}finally{n(!1)}};return(0,o.jsxs)("div",{children:[(0,o.jsx)("input",{type:"checkbox",id:"edit-tour-modal",className:"modal-toggle",checked:e.showModal,readOnly:!0}),(0,o.jsxs)("div",{className:"modal justify-start! absolute z-50 -top-0 left-0 w-full bg-white! flex flex-col h-full",children:[(0,o.jsxs)("div",{className:" text-black w-full p-0 flex-1 overflow-y-auto",children:[(0,o.jsxs)("div",{className:"flex flex-row justify-between items-center mx-4 pt-3 pb-2 border-b border-b-black/10",children:[(0,o.jsx)("span",{className:"font-bold text-lg flex flex-row items-center gap-3",children:"Edit Tour"}),(0,o.jsx)("label",{htmlFor:"add-ifc-modal",className:"btn btn-sm btn-circle btn-ghost",onClick:()=>{e.setShowModal(!1),l("")},children:"✕"})]}),(0,o.jsxs)("div",{className:"m-4 flex flex-col",children:[(0,o.jsx)("span",{className:"label-text font-bold",children:"Change Tour Name"}),(0,o.jsx)("input",{type:"text",placeholder:e.tourName,value:s,className:"text-black input  mt-2 w-full",onCh
15ange:e=>{l(e.target.value.replace(/[^a-zA-Z0-9]/g,""))}})]})]}),(0,o.jsxs)("div",{className:"flex justify-between mb-4 px-4 w-full",children:[(0,o.jsx)("button",{id:"save-tour",className:"btn tt-blue-button",onClick:async()=>{await d(),l(""),e.setShowModal(!1)},children:"Save"}),(0,o.jsx)("div",{className:"flex items-center",children:i?(0,o.jsx)("button",{className:"btn btn-sm text-white bg-red-500 hover:bg-red-600 flex items-center",children:(0,o.jsx)("span",{className:"loading loading-spinner loading-sm"})}):(0,o.jsx)("button",{className:"btn text-white bg-red-500 hover:bg-red-600 flex items-center",onClick:async()=>{await u(),e.setShowModal(!1)},children:"Delete Tour"})})]})]}),(0,o.jsx)("label",{className:"modal-backdrop",htmlFor:"edit-tour-modal",onClick:()=>{e.setShowModal(!1),l("")},children:"Close"})]})};var r9=a(40430);let se=e=>{let t=(0,eG.JY)(),a=(0,ev.O)(),[r,s]=(0,h.useState)(!1),[l,i]=(0,h.useState)(""),[n,c]=(0,h.useState)(""),[d,u]=(0,h.useState)([]),[p,m]=(0,h.useState)([]),[x,f]=(0,h.useState)(new Set);(0,h.useEffect)(()=>{let t=[],r=[];for(let a of e.tourMap.keys())t.push(a);for(let t of e.toursInProgress.keys())r.push(t);u(t),m(r);let s=new Set;t.forEach(e=>{(0,r9.xe)(e,a.project?.project_uuid)||s.add(e)}),f(s)},[e.tourMap,e.toursInProgress,a.project?.project_uuid]);let g=async r=>{try{let s=await (0,_.x)(`/tour/${r}/first-image`,{params:{project_id:a.project?.project_uuid}});e.map.current.flyTo({center:[s.lon,s.lat],zoom:e.map.current.getZoom()>17?e.map.current.getZoom():17,duration:eB.AD}),(0,v.Ne)(e.map,s.lat,s.lon,t.markerRef)}catch{y.Ay.error("Failed to zoom to tour location")}},b=async(e,t)=>{i(e),c(t),s(!0)};return(0,o.jsxs)("div",{className:"custom-layers-container mr-2 mt-1 gap-4 flex flex-col",children:[d.map(t=>(0,o.jsx)("div",{className:"label",children:(0,o.jsx)("div",{className:"flex flex-col w-full min-w-0",children:(0,o.jsxs)("div",{className:"flex justify-between items-center",children:[(0,o.jsx)("button",{type:"button",className:"hide-focus-ring label-text mr-2 w-full overflow-hidden min-w-0 truncate text-left cursor-pointer",onClick:()=>g(t),children:e.tourMap.get(t)}),(0,o.jsxs)("div",{className:"flex items-center gap-1",children:[(0,o.jsx)("button",{title:"Toggle visibility",id:`toggle-tour-visibility-${t}`,onClick:r=>{let s,l;r.stopPropagation(),s=a.project?.project_uuid,l=!(0,r9.xe)(t,s),(0,r9.v9)(t,s,l),(0,r6.VE)(e.map),f(e=>{let a=new Set(e);return l?a.delete(t):a.add(t),a})},className:"btn btn-xs text-black",children:x.has(t)?(0,o.jsx)(W.Sq0,{className:"text-red-500"}):(0,o.jsx)(W.JPe,{className:"text-black"})}),(0,o.jsx)("label",{id:"edit-tour",htmlFor:"edit-tour-modal",onClick:a=>{a.stopPropagation(),b(String(e.tourMap.get(t)),t)},className:"btn btn-xs",children:(0,o.jsx)($.VZ_,{})})]})]})})},t)),p.map(t=>(0,o.jsx)("div",{className:"label",children:(0,o.jsx)("div",{className:"flex flex-col w-full",children:(0,o.jsxs)("div",{className:"flex justify-between items-center",children:[(0,o.jsx)("span",{className:"label-text",children:e.toursInProgress.get(t)}),(0,o.jsx)("div",{className:"flex gap-1 items-center mr-1",children:(0,o.jsxs)("span",{className:"tt-blue-badge",children:[(0,o.jsx)("span",{className:"loading loading-spinner w-3"}),"Processing"]})})]})})},t)),(0,o.jsx)(r7,{map:e.map,showModal:r,setShowModal:s,tourName:l,tourId:n,refreshTourList:e.refreshTourList})]})};var st=a(81145);let sa=(e,t,a,r)=>{let{source:s,destination:l}=e;if(!l)return;let i=[...t];if(r){let t=i.findIndex(e=>Object.keys(e)[0]===Object.keys(r)[0]);if(-1===t)return;l.index>s.index&&l.index!==e.length-1&&(l.index-=1);let a=i[t][Object.keys(r)[0]],[n]=a.splice(s.index,1);a.splice(l.index,0,n),i[t][Object.keys(r)[0]]=a}else{l.index>s.index&&l.index!==e.length-1&&(l.index-=1);let[t]=i.splice(s.index,1);i.splice(l.index,0,t)}a(i)},sr=(e,t)=>{if(t.isDragging){let t=e.top?parseFloat(e.top):0;return{...e,left:void 0,top:t}}return t.isDropAnimating?{...e,transitionDuration:"0.001s"}:e};function ss({selectedLayer:e,handleCancelClick:t,handleDeleteClick:a}){let[r,s]=(0,h.useState)(!1),[l,i]=(0,h.useState)(!1);return e.status===x.iO.processing?(0,o.jsxs)("div",{className:"flex gap-1 items-center mr-1",children:[(0,o.jsxs)("span",{className:"tt-blue-badge",children:[(0,o.jsx)("span",{className:"loading loading-spinner w-3"}),"Processing"]}),"WFS"!=e.source&&(0,o.jsx)("button",{title:"Cancel",onClick:async()=>{s(!0),await t(e),s(!1)},className:"btn btn-xs btn-square text-black",disabled:r,children:r?(0,o.jsx)("span",{className:"loading loading-spinner bg-transparent loading-xs"}):(0,o.jsx)(ek.WQq,{})})]}):e.status===x.iO.cancelled||e.status===x.iO.failed?(0,o.jsxs)("div",{className:"flex gap-1 items-center mr-1",children:[(0,o.jsx)("span",{className:"bg-[#ffe3e3] text-[#d93025] text-xs py-1 px-2 font-bold rounded-xl",children:e.status===x.iO.cancelled?"Cancelled":"Failed"}),(0,o.jsx)("button",{title:"Delete",onClick:async()=>{i(!0),await a(e),i(!1)},className:"btn btn-xs btn-square text-black",disabled:l,children:l?(0,o.jsx)("span",{className:"loading loading-spinner loading-xs"}):(0,o.jsx)(W.WeY,{})})]}):null}var sl=a(93258);function si({layer:e,handleViewAll:t}){let a=(0,h.useMemo)(()=>e.properties.gradientData.categorical??{},[e.properties.gradientData.categorical]),[r,s]=(0,h.useState)([]),[l,i]=(0,h.useState)(!1),{gisDataVersion:n}=(0,sl.i)(),c=(0,h.useCallback)(async()=>{try{let t=await (0,_.x)("/layer/attribute?",{method:"GET",params:{id:e.id,attribute:e.properties.gradientData.property,limit:100,offset:0}}),r=Array.from(new Set(t.map(e=>(0,N.cM)(e))));s(r.map(t=>[t,a[t]??e.properties.color]).sort((e,t)=>
15e[0].localeCompare(t[0],void 0,{numeric:!0,sensitivity:"base"})))}catch{y.Ay.error("Failed to fetch category values")}},[a,e.id,e.properties.color,e.properties.gradientData.property]),d=(0,h.useCallback)(async()=>{try{let t=await (0,_.x)("/layer/distinct",{method:"GET",params:{id:e.id,attribute:e.properties.gradientData.property}});i(t>100)}catch{y.Ay.error("Failed to fetch attribute count")}},[e.id,e.properties.gradientData.property]);return(0,h.useEffect)(()=>{e.properties.gradientData.gradientType===x.nd.categorical&&(c(),d())},[e.properties.gradientData.gradientType,c,d,n]),(0,o.jsxs)("div",{children:[(0,o.jsxs)("div",{className:"ml-4 my-2 label-text font-semibold",children:["Property: ",(0,o.jsx)("span",{className:"font-normal",children:e.properties.gradientData.property})]}),r.map(([e,t])=>(0,o.jsxs)("div",{className:"flex items-center gap-2 ml-4 my-2",children:[(0,o.jsx)("div",{style:{backgroundColor:t},className:"w-2 h-2 rounded-full"}),(0,o.jsx)("span",{className:"label-text truncate",children:e})]},e)),l&&(0,o.jsx)("button",{className:"underline label-text ml-4",onClick:()=>t(),children:"View All"})]})}var sn=a(18847),so=a.n(sn);let sc=new Set(["Dropdown","Checkboxes","RadioButtons"]),sd=e=>so()(()=>Promise.all([a.e(6701),a.e(1836),a.e(1121),a.e(8456)]).then(a.bind(a,48527)).then(t=>t[e]),{loadableGenerated:{webpack:()=>[null]},ssr:!1}),su=e=>{let t=[];for(let a=0;a<e.length;a+=1){let r=e[a],s="string"==typeof r.label?r.label.trim():"",l="string"==typeof r.field_name?r.field_name.trim():"",i=s||l||`Field ${a+1}`;if(s||t.push({kind:"label",fieldIndex:a,fieldName:i,optionIndexes:[],message:"Label is required"}),!sc.has(r.element)||!Array.isArray(r.options))continue;let n=new Map,o=[];r.options.forEach((e,t)=>{let a="string"==typeof e.text?e.text.trim().toLowerCase():"";a?n.set(a,[...n.get(a)||[],t]):o.push(t)}),o.length>0&&t.push({kind:"option",fieldIndex:a,fieldName:i,optionIndexes:o,message:"Options cannot be empty"});let c=Array.from(new Set(Array.from(n.values()).filter(e=>e.length>1).flat()));c.length>0&&t.push({kind:"option",fieldIndex:a,fieldName:i,optionIndexes:c,message:"Duplicate options are not allowed"})}return t},sp=({layer:e,handleToggleVisibility:t})=>(0,o.jsx)("button",{title:"Toggle visibility",id:"toggle-visibility-button",onClick:async a=>{a.stopPropagation(),await t(e)},className:"btn btn-xs text-black",children:"true"===e.properties.visible||!0===e.properties.visible?(0,o.jsx)(W.JPe,{className:"text-black"}):(0,o.jsx)(W.Sq0,{className:"text-red-500"})}),sm=({layer:e,handleTableClick:t})=>{let{getModalState:a,closeModal:r}=(0,tZ.O)(),{activeTabularLayerID:s}=(0,eV.H)(),l=a(x.dW.GISModal).display&&s===e.id?.toString();return(0,o.jsx)("button",{title:"Tabular view","data-testid":"gis-layer-tabularview-button",className:"btn btn-xs",onClick:a=>{(a.stopPropagation(),l)?r(x.dW.GISModal):t(e)},children:(0,o.jsx)(rr.OKl,{})})},sh=({layer:e,handleEditClick:t,handleRefreshClick:a,handleDeleteClick:r})=>{let s=(0,eG.JY)().map,{setConfirmationPopup:l}=(0,e$.p)(),i=(0,ex.u)().user,{project:n}=(0,ev.O)(),{setEditGeometriesLayer:c}=(0,eb.g)(),[d,u]=(0,h.useState)(!1),[p,m]=(0,h.useState)(!1),x=()=>{let e=document.querySelector("details[open].dropdown");e&&e.removeAttribute("open")};return(0,h.useEffect)(()=>(l((0,o.jsx)(V.A,{isOpen:p,closeModal:()=>m(!1),onDelete:()=>{r(e),x()}})),()=>l(null)),[p]),(0,o.jsxs)("details",{className:"dropdown dropdown-end fm-dropdown dropdown-close-outside group w-fit shrink-0","data-testid":"custom-layer-three-dots-button",onClick:e=>{e.stopPropagation(),e.target.closest("summary")||e.preventDefault()},children:[(0,o.jsx)("summary",{className:"btn btn-xs text-xs list-none w-fit",title:"Show more options",onClick:e=>{e.stopPropagation();let t=e.currentTarget.closest("details"),a=document.querySelector("details[open].dropdown");a&&a!==t&&a.removeAttribute("open")},"data-testid":"custom-layer-three-dots-button",children:(0,o.jsx)(W.mqA,{})}),(0,o.jsxs)("ul",{className:"p-2 shadow menu dropdown-content z-1000 bg-base-100 rounded-box min-w-52 max-w-58 hidden group-open:flex",children:[(0,ra.fR)(e.source)&&n&&(0,v._A)(i,n.project_uuid)&&(0,o.jsx)("li",{title:"false"===e.properties.visible||!1===e.properties.visible?"Disabled for hidden layer":"Edit geometries",children:(0,o.jsxs)("button",{"data-testid":"edit-geometries-button",onClick:()=>{c(e),x()},disabled:"false"===e.properties.visible||!1===e.properties.visible,className:"disabled:opacity-50 disabled:cursor-not-allowed disabled:pointer-events-none",children:[(0,o.jsx)($.VZ_,{})," Edit Geometries"]})}),(0,o.jsx)("label",{htmlFor:"edit-layer-modal",id:"edit-layer-modal-button",children:(0,o.jsx)("li",{children:(0,o.jsxs)("button",{onClick:()=>{t(e),x()},children:[(0,o.jsx)(W.HbA,{})," Properties"]})})}),e.properties.zoomLocation&&(0,o.jsx)("li",{children:(0,o.jsxs)("button",{"data-testid":"zoom-layer-button",onClick:t=>{t.stopPropagation(),(0,eo.S6)(s,e),x()},children:[(0,o.jsx)(W.YQq,{})," Zoom to layer"]})}),(0,ra.pA)(e.source)&&(0,o.jsx)("li",{children:(0,o.jsxs)("button",{onClick:()=>{a(e),x()}
15,children:[(0,o.jsx)(W.v6F,{})," Refresh"]})}),(0,ra.fR)(e.source)&&(0,o.jsx)("li",{children:(0,o.jsxs)("button",{onClick:async()=>{try{let t=await r0({layerId:parseInt(e.id),projectId:n?.project_uuid||""});!function(e,t="data"){let a=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),r=URL.createObjectURL(a),s=document.createElement("a");s.href=r,s.download=`${t}.json`,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(r)}(t,e.name)}catch(e){console.error(e),y.Ay.error("Failed to fetch form template")}},children:[(0,o.jsx)(W.U01,{}),(0,o.jsx)("span",{className:"whitespace-nowrap",children:"Download Form Template"})]})}),(0,ra.J3)(e.source)&&(0,o.jsx)("li",{children:(0,o.jsxs)("button",{disabled:d,onClick:async()=>{u(!0),await (0,S.uT)(e,i),u(!1)},children:[d?(0,o.jsx)("div",{className:"loading loading-spinner loading-xs bg-gray-500"}):(0,o.jsx)(W.U01,{}),"Download GeoJSON"]})}),(0,v._A)(i,n?.project_uuid||"")&&(0,o.jsx)("li",{className:`${p?"opacity-50 pointer-events-none cursor-not-allowed":""}`,children:(0,o.jsxs)("button",{"data-testid":"delete-layer-button",onClick:()=>{m(!0)},children:[(0,o.jsx)(W.WeY,{className:"text-red-500"}),(0,o.jsx)("div",{className:"text-red-500",children:"Delete Layer"})]})})]})]})},sx=({layer:e,handleToggleVisibility:t,handleEditClick:a,handleTableClick:r,handleRefreshClick:s,handleDeleteClick:l,handleCancelClick:i})=>{let n=(0,eG.JY)().map;return(0,o.jsx)("div",{className:"flex flex-col w-full min-w-0","data-testid":"layer-entry",children:(0,o.jsxs)("div",{className:"flex justify-between items-center w-full",children:[(0,o.jsx)("button",{type:"button",className:"hide-focus-ring flex flex-row items-center min-w-0 flex-1 text-left",onClick:t=>{t.stopPropagation(),e.properties.zoomLocation&&(0,eo.S6)(n,e)},children:(0,o.jsx)(r$,{selectedLayer:e})}),e.status===x.iO.complete||e.status===x.iO.initial?(0,o.jsxs)("div",{className:"flex items-center gap-1",children:[(0,o.jsx)(sp,{layer:e,handleToggleVisibility:t}),((0,ra.J3)(e.source)||(0,ra.fR)(e.source))&&(0,o.jsx)(sm,{layer:e,handleTableClick:r}),(0,o.jsx)(sh,{layer:e,handleEditClick:a,handleRefreshClick:s,handleDeleteClick:l})]}):(0,o.jsx)(ss,{selectedLayer:e,handleCancelClick:i,handleDeleteClick:l})]})})},sf=({layer:e,index:t,handleEditClick:a,handleToggleVisibility:r,handleTableClick:s,handleDeleteClick:l,handleCancelClick:i,handleRefreshClick:n})=>{let[c,d]=(0,h.useState)(!1),u=e.properties.gradientData.gradientType===x.nd.categorical;return(0,o.jsx)(st.gL,{droppableId:`layer-${e.id}`,type:"layer",children:p=>(0,o.jsxs)("div",{ref:p.innerRef,...p.droppableProps,children:[(0,o.jsx)(st.sx,{draggableId:e.id.toString(),index:t,children:(t,p)=>{let m=(0,o.jsxs)("div",{className:"flex items-center w-full",children:[u&&(0,o.jsx)("button",{type:"button",className:`collapsible_arrow hide-focus-ring shrink-0 mr-2 text-sm cursor-pointer ${c?"rotate-180":""}`,title:c?"Collapse colors":"Expand colors","aria-expanded":c,onClick:e=>{e.stopPropagation(),d(e=>!e)},children:(0,o.jsx)(W.tEr,{})}),(0,o.jsx)(sx,{layer:e,handleToggleVisibility:r,handleEditClick:a,handleTableClick:s,handleRefreshClick:n,handleDeleteClick:l,handleCancelClick:i}),(0,o.jsx)("button",{className:"drag-handle shrink-0 ml-1 mr-1",...t.dragHandleProps,onClick:e=>{e.stopPropagation()},children:(0,o.jsx)(z.LUV,{size:15,className:"text-gray-400"})})]});return(0,o.jsx)("div",{ref:t.innerRef,...t.draggableProps,className:"label grey-hover py-[7px] pl-0 w-full",style:sr(t.draggableProps.style,p),children:u?(0,o.jsxs)("div",{className:"w-full",children:[m,(0,o.jsx)(rM(),{open:c,trigger:"",triggerDisabled:!0,overflowWhenOpen:"visible",className:"w-full [&_.Collapsible__trigger]:hidden",openedClassName:"w-full [&_.Collapsible__trigger]:hidden",transitionTime:150,children:c&&(0,o.jsx)(si,{layer:e,handleViewAll:()=>a(e)})},`${e.id}-colors-list`)]}):m})}}),p.placeholder]})},e.id)},sg=({group:e,index:t,handleEditClick:a,handleDeleteClick:r,handleCancelClick:s,handleToggleVisibility:l,handleGroupVisiblityToggle:i,setSelectedGroup:n,setGroupLayers:c,setEditGroupModal:d,order:u,setOrder:p,handleTableClick:m,handleRefreshClick:h})=>{let x=Object.keys(e)[0],f=Object.values(e)[0];return(0,o.jsx)(st.gL,{droppableId:`group-${x}`,type:"layer",children:g=>(0,o.jsxs)("div",{ref:g.innerRef,...g.droppableProps,children:[(0,o.jsx)(st.sx,{draggableId:x,index:t,children:(t,g)=>(0,o.jsx)("div",{ref:t.innerRef,...t.draggableProps,style:sr(t.draggableProps.style,g),children:(0,o.jsx)(rM(),{overflowWhenOpen:"visible",trigger:(0,o.jsxs)("div",{className:"collapsible_trigger font-semibold text-sm my-2",children:[(0,o.jsx)("span",{className:"collapsible_arrow",children:(0,o.jsx)(W.tEr,{})}),(0,o.jsx)("div",{className:"flex flex-col w-full",children:(0,o.jsxs)("div",{className:"flex justify-between items-center",children:[x,(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("button",{className:"btn btn-xs mr-1 text-black",onClick:async e=>{e.stopPropagation(),await i(f)},children:"visible"===(0,S.g2)(f)?(0,o.jsx)(W.JPe,{className:"text-black"}):(0,o.jsx)(W.Sq0,{className:"text-red-500"})}),(0,o.jsx)("label",{htmlFor:"edit-group-modal",className:"btn btn-xs mr-1",onClick:e=>{e.stopPropagation(),n(x),c(f),d(!0)},children:(0,o.jsx)($.VZ_,{})}),(0,o.jsx)("button",{className:"drag-handle mr-1",...t.dragHandleProps,onClick:e=>{e.stopPropagation()},children:(0,o.jsx)(z.LUV,{size:15,className:"text-gray-400"})})]})]})})]}),transitionTime:150,children:(0,o.jsx)("div",{className:"pl-2",children:(0,o.jsx)(st.JY,{onDragEnd:t=>
15sa(t,u,p,e),children:f.map((e,t)=>(0,o.jsx)(sf,{layer:e,index:t,handleEditClick:a,handleToggleVisibility:l,handleTableClick:m,handleDeleteClick:r,handleCancelClick:s,handleRefreshClick:h},`${e.id}-draggable`))})})},x)})}),g.placeholder]})},x)},sy=({customLayers:e,groups:t,handleGroupVisiblityToggle:a,setSelectedGroup:r,setGroupLayers:s,setEditGroupModal:l,setSelectedLayer:i,handleEditClick:n,handleTableClick:c,handleDeleteClick:d,handleCancelClick:u,handleToggleVisibility:p,order:m,setOrder:h,handleRefreshClick:x,ifc:f})=>{let g=(0,eG.JY)().map,y=(0,ex.u)().user,b=e.filter(e=>"Published"===e.scope||"ProjectGIS"===e.scope||e.user_id===y?.id);return(b=f?b.filter(e=>"IFC"===e.source):b.filter(e=>"IFC"!==e.source),f)?(0,ai.gp)(g,b,i,n,p):(0,o.jsx)(st.JY,{onDragEnd:e=>sa(e,m,h),children:(0,o.jsx)("div",{className:"custom-layers-container",children:m.map((e,i)=>{if(b.includes(e)||t.includes(Object.keys(e)[0]))if(e.id)return(0,o.jsx)(sf,{layer:e,index:i,handleEditClick:n,handleToggleVisibility:p,handleTableClick:c,handleDeleteClick:d,handleCancelClick:u,handleRefreshClick:x},i);else return(0,o.jsx)(sg,{group:e,index:i,handleEditClick:n,handleDeleteClick:d,handleCancelClick:u,handleToggleVisibility:p,handleGroupVisiblityToggle:a,setSelectedGroup:r,setGroupLayers:s,setEditGroupModal:l,order:m,setOrder:h,handleTableClick:c,handleRefreshClick:x},i)})})})};function sb({setShowEditModelMenu:e,setBottomMenuOpen:t,onFeatureClick:a,tours:r,refreshTourList:s,toursInProgress:l}){var i,n;let c=(0,ex.u)().user,d=(0,eG.JY)(),u=(0,eV.H)(),p=(0,ew.u)(),m=(0,ev.O)(),f=(0,eD.l)(),{openModal:g}=(0,tZ.O)(x.dW.GISModal),[b,j]=(0,h.useState)(!1),[w,k]=(0,h.useState)(""),[C,L]=(0,h.useState)(""),[D,A]=(0,h.useState)(50),[M,E]=(0,h.useState)(null),[T,I]=(0,h.useState)({}),[P,F]=(0,h.useState)(!1),[O,R]=(0,h.useState)(M?.scope),[z,U]=(0,h.useState)(!1),[B,G]=(0,h.useState)(M?.properties.group),J=h.useMemo(()=>[...new Set(u.customLayers.map(e=>e.properties?.group).filter(e=>void 0!==e))],[u.customLayers]),[q,Y]=(0,h.useState)(!1),[H,Z]=(0,h.useState)(""),[X,K]=(0,h.useState)([]),[Q,ee]=(0,h.useState)(M?.properties.icon?M?.properties.icon:x.iT),[et,ea]=(0,h.useState)(!1),[er,es]=(0,h.useState)("#000000"),[el,ei]=(0,h.useState)("#ffffff"),[en,eo]=(0,h.useState)({}),[ec,ed]=(0,h.useState)({}),[eu,ep]=(0,h.useState)(""),[em,eh]=(0,h.useState)(x.nd.gradient),[ef,eg]=(0,h.useState)(null),[ey,eb]=(0,h.useState)(null),[ej,eN]=(0,h.useState)(null),[eS,ek]=(0,h.useState)(null),[e_,eC]=(0,h.useState)(null),[eL,eA]=(0,h.useState)(null),[eM,eE]=(0,h.useState)(null),[eT,eI]=(0,h.useState)(new Date),[eP,eF]=(0,h.useState)(),[eO,eR]=(0,h.useState)(),e$=(0,h.useRef)(null),[ez,eU]=(i=u.customLayers,n=u.setCustomLayers,[h.useMemo(()=>(0,av.EJ)(i),[i]),e=>{n(t=>("function"==typeof e&&(e=e((0,av.EJ)(t))),(0,av.mE)(e)))}]),[eW,eB]=(0,h.useState)(""),eJ=(0,h.useRef)(""),eq=(0,h.useRef)(!0);(0,h.useEffect)(()=>{if(eq.current){eq.current=!1;return}return e$.current&&clearTimeout(e$.current),e$.current=setTimeout(async()=>{(async()=>{await (0,av.iY)(d.map,ez,String(m.project?.project_uuid))})()},1e3),()=>{e$.current&&clearTimeout(e$.current)}},[d,ez,m.project?.project_uuid]),(0,h.useEffect)(()=>(u.setEditingCustomLayerId(b&&M?M.id:null),()=>{u.setEditingCustomLayerId(null)}),[b,M,u]),(0,h.useEffect)(()=>{L(M?.properties.color),es(M?.properties.gradientData&&M?.properties.gradientData.gradient1?M?.properties.gradientData.gradient1:"#000000"),ei(M?.properties.gradientData&&M?.properties.gradientData.gradient2?M?.properties.gradientData.gradient2:"#ffffff"),eo(M?.properties.gradientData&&M?.properties.gradientData.categorical?M?.properties.gradientData.categorical:{}),ed(M?.properties.gradientData?.categoricalOpacities??{}),eh(M?.properties.gradientData&&M?.properties.gradientData.gradientType?M?.properties.gradientData.gradientType:x.nd.gradient),ep(M?.properties.gradientData&&M?.properties.gradientData.property?M?.properties.gradientData.property:M?.properties.geojson_properties?M?.properties.geojson_properties[0]:""),ea(!!M?.properties.gradientData&&Object.keys(M?.properties.gradientData).length>0),G(M?.properties.group),A(M?.properties.opacity||50),ee(M?.properties.icon?M?.properties.icon:x.iT),eR(M?.properties.lineStyle??x.jV.ss),(0,ai.XB)(M,eg,eb,eN,ek,eC,eA,eE),eJ.current=M?.properties.gradientData&&M?.properties.gradientData.property?M?.properties.gradientData.property:"",eI(new Date(M?.reference_date||new Date))},[M]);let eY=e=>{E(e),j(!0),eJ.current=M?.properties.gradientData&&M?.properties.gradientData.property?M?.properties.gradientData.property:""},eH=e=>{u.setActiveTabularLayerID(e?.id?.toString()||null),u.setActiveTabularLayerName(e?.name||null),E(e),g()},eZ=async e=>{if(!m.project)return void y.Ay.error("Error refreshing layer");let t=new FormData;t.append("id",e.id.replace("-layer","")),t.append("project_id",m.project?.project_uuid),await (0,aw.r3)({mapContext:d,layerContext:u,customLayer:null,layerType:e.source,customLayerName:e.name,uploadingManager:f,closeAddCustomLayerPanel:()=>{},setAddingLayerState:()=>{},formData:t,refresh:!0})},eX=async e=>{if(m.project?.project_uuid)try{await (0,ai.xL)(e,m.project?.project_uuid),y.Ay.success("Layer processing cancelled");let t=[...u.customLayers].map(t=>
15t.id===e.id?{...t,status:x.iO.cancelled}:t);u.setCustomLayers(t)}catch(e){console.error(e),y.Ay.error("Failed to cancel layer processing")}},eK=async e=>{try{if(!e)throw Error("No selected layer");await (0,_.x)("/layer/delete",{method:"DELETE",params:{id:e.id}});let t=e.id.toString();if(!d.map.current)return;(0,N.Tt)(t,d.map),d.map.current.on("style.load",()=>{d.map.current&&d.map.current.getLayer(t)&&d.map.current.removeLayer(t)}),u.setCustomLayers(u.customLayers.filter(t=>t!==e)),k(""),L(e?.properties?.color||""),j(!1),F(!1),U(!1),e.properties?.hasLRS&&p.setAvailableRoutes([]),y.Ay.success("Layer Deleted Successfully"),e.source===rX.mb.IFC&&(0,rV.pj)(e)}catch(e){console.error(e),y.Ay.error("Ran Into Error While Deleting")}},eQ=async(e,t,a)=>{let r={ids:[parseInt(e?.id)],properties:t,...a&&{reference_date:eT.toISOString()}};return(0,_.x)("/layer/update",{method:"PATCH",json:r})},e0=async(e,t)=>{let a={ids:e.map(e=>parseInt(e.id)),properties:t};return(0,_.x)("/layer/update",{method:"PATCH",json:a})},e1=async()=>{try{let e,t,a={color:""===C?M?.properties.color:C,symbol:"circle",visible:M?.properties.visible??!0,opacity:Number(D),zoomLocation:(()=>{if(M?.source==="IFC"){let e=Number(ey),t=Number(ef);return null===ef&&(t=Number(M?.properties.zoomLocation?.long)),null===ey&&(e=Number(M?.properties.zoomLocation?.lat)),M&&(M.properties.zoomLocation={lat:e,long:t}),{lat:e,long:t}}return M?.properties.zoomLocation})(),gradientData:et&&(eP===x.y$.categorical||eP===x.y$.gradient)?{gradient1:er,gradient2:el,property:eu,categorical:en,gradientType:em,categoricalOpacities:ec}:{},scope:void 0===O?M?.scope:O,name:""===w?M?.name:w,group:void 0===B||""===B?void 0:B,geojson_type:M?.properties.geojson_type,icon:void 0===Q||Q===x.iT||eP!==x.y$.icon?void 0:Q,geojson_properties:M?.properties.geojson_properties,ifcLat:null===ef?M?.properties.ifcLat:ef,ifcLon:null===ey?M?.properties.ifcLon:ey,ifcScale:null===ej?M?.properties.ifcScale:ej,ifcElevation:null===eS?M?.properties.ifcElevation:eS,ifcX:null===e_?M?.source==="IFC"?0:void 0:e_,ifcY:null===eL?M?.source==="IFC"?0:void 0:eL,ifcZ:null===eM?M?.source==="IFC"?0:void 0:eM,wfs:M?.properties.wfs,hasLRS:M?.properties.hasLRS,lineStyle:(e=M?.id??"",(t=(0,av.oD)(e)??[]).length>0&&(0,rq.gl)({type:"FeatureCollection",features:t}).has("LineString")||(0,rq.tP)(e).some(e=>d.map.current?.getLayer(e)?.type==="line")?eO:M?.properties.lineStyle),labelProperty:eW},{color:r,...s}=a,l={...""===C?s:a,group:a.group??null};await eQ(M,l,!0),M&&(M.properties=a,M.scope=M.properties.scope),M?.properties.lineStyle&&(0,N.N3)(d.map,M),M?.source===rX.mb.GeoJSON&&d.map.current?.getLayer(M.id)&&(et?((0,av.Jg)(M.id,M.properties.gradientData.property),m.project&&await (0,N.qE)(d.map,m.project,M)):M?.properties.icon||(0,N.V9)(d.map,M)),R(M?.scope),L(M?.properties.color),j(!1),U(!1),G(""),M&&w.length>0&&(M.name=w)}catch(e){console.error(e),y.Ay.error("Ran Into Error While Saving")}if(M?.scope==="Draft"&&M?.user_id!==c?.id){if(!d.map.current)return;let e=(0,rq.tP)(M.id);[...e,...e.map(e=>`${e}-stroke`),...e.map(e=>`${e}-halo`),...e.map(e=>`${e}-vector-label`),`${M.id}-cluster`,`${M.id}-cluster-count`].forEach(e=>{d.map.current?.getLayer(e)!==void 0&&d.map.current.setLayoutProperty(e,"visibility","none")})}if(et||M?.properties.geojson_type!=="Point")M?.source==="IFC"&&await (0,rV.F)(d.map,m.project,M,e,t);else{let e=(0,rq.gl)({type:"FeatureCollection",features:(0,av.oD)(M.id)??[]});if(e.size>1||e.has("Polygon")||e.has("LineString")){let e={type:"FeatureCollection",features:(0,av.oD)(M.id)};d.map=(0,N.KI)(d.map,e,M.id,M.properties.color,M.properties.opacity,a,M.properties.gradientData?.property,M.properties.gradientData?.gradient1,M.properties.gradientData?.gradient2,M.properties.gradientData?.categorical,M.properties.gradientData?.categoricalOpacities,M.properties.gradientData?.gradientType,M.properties.icon,"ProjectGIS"===M.scope,M.properties.lineStyle,M.properties.labelProperty,M.properties.geojson_type)}else(0,ai.Vj)(d.map,M);(!1===M.properties.visible||"false"===M.properties.visible)&&e3(M.id,!1)}let r=await (0,av.en)(m.project?.project_uuid);
15r.forEach(e=>{e.id=e.id.toString()+"-layer"}),u.setCustomLayers(r),k(""),L(M?.properties.color),ea(!!M?.properties.gradientData.property),es(M?.properties.gradientData.gradient1?M?.properties.gradientData.gradient1:"#000000"),ei(M?.properties.gradientData.gradient2?M?.properties.gradientData.gradient2:"#ffffff"),eo(M?.properties.gradientData.categorical?M?.properties.gradientData.categorical:{}),ed(M?.properties.gradientData?.categoricalOpacities??{}),ep(M?.properties.gradientData.property?M?.properties.gradientData.property:""),A(50),j(!1),eg(null),eb(null),document.getElementById("edit-layer-modal")?.click(),U(!1),R(M?.scope),E(null),y.Ay.success("Layer Saved Successfully")},e2=(0,h.useMemo)(()=>(0,v.sg)((e,t)=>{eQ(e,{visible:t},!1).catch(e=>{console.error("Failed to update visibility",e),y.Ay.error("Failed to update visibility")})},500),[]),e5=async e=>{let t=!0!=e.properties.visible&&"true"!=e.properties.visible;e3(e.id,t),I(a=>({...a,[e.id]:t})),e.properties.visible=t,"IFC"===e.source&&(0,ai.bh)(e),e2(e,t),m.project&&t&&((0,ra.J3)(e.source)||(0,ra.fR)(e.source))&&(await (0,av.A1)(m.project.project_uuid,d.map,[e.id],!0)).forEach(e=>{let t=`${e.layer_id}-layer`;d.map=(0,N.KI)(d.map,e.geojson,t,e.layer_properties.color,e.layer_properties.opacity,a,e.layer_properties.gradientData.property,e.layer_properties.gradientData.gradient1,e.layer_properties.gradientData.gradient2,e.layer_properties.gradientData.categorical,e.layer_properties.gradientData.categoricalOpacities,e.layer_properties.gradientData.gradientType,e.layer_properties.icon,"ProjectGIS"===e.scope,e.layer_properties.lineStyle,e.layer_properties.labelProperty,e.layer_properties.geojson_type)})},e3=(e,t)=>{if(!d.map.current)return;let a=(0,rq.tP)(e);[...a,...a.map(e=>`${e}-stroke`),...a.map(e=>`${e}-halo`),...a.map(e=>`${e}-vector-label`),`${e}-cluster`,`${e}-cluster-count`].forEach(e=>{d.map.current?.getLayer(e)!==void 0&&d.map.current.setLayoutProperty(e,"visibility",t?"visible":"none")})},e4=(0,h.useMemo)(()=>(0,v.sg)((e,t)=>{e0(e,{visible:t}).catch(e=>{console.error("Failed to update group visibility",e)})},500),[]),e8=async e=>{let t="visible"!==(0,S.g2)(e),r={...T};for(let a of e)e3(a.id,t),r[a.id]=t,a.properties.visible=t;if(I(r),e4(e,t),t){let t=e.filter(e=>(0,ra.J3)(e.source)).map(e=>e.id);t.length>
150&&(await (0,av.A1)(m.project.project_uuid,d.map,t)).forEach(e=>{let t=`${e.layer_id}-layer`;d.map=(0,N.KI)(d.map,e.geojson,t,e.layer_properties.color,e.layer_properties.opacity,a,e.layer_properties.gradientData.property,e.layer_properties.gradientData.gradient1,e.layer_properties.gradientData.gradient2,e.layer_properties.gradientData.categorical,e.layer_properties.gradientData.categoricalOpacities,e.layer_properties.gradientData.gradientType,e.layer_properties.icon,"ProjectGIS"===e.scope,e.layer_properties.lineStyle,e.layer_properties.labelProperty,e.layer_properties.geojson_type)})}},e6=async(e,t)=>{let a=B&&!J.includes(B);if(!a&&0===t.size)return void y.Ay.error("Group name already exists!");if(a)try{await e0(e,{group:B}),e.forEach(e=>e.properties.group=B),y.Ay.success("Group name changed successfully"),u.setCustomLayers(e=>e.map(e=>{if(e.properties.group!==H)return e;{let t=JSON.parse(JSON.stringify(e));return t.properties.group=B,t}}))}catch(e){console.error(e),y.Ay.error("Error changing group name")}t.size>0&&(await (0,av.Lr)(t,B||H,u),y.Ay.success("Layers added to group successfully")),Y(!1),G("")},e7=async e=>{try{await e0(e,{group:null}),e.forEach(e=>e.properties.group=void 0),y.Ay.success("Group deleted successfully"),u.setCustomLayers(e=>e.filter(e=>e.properties.group!==H))}catch{y.Ay.error("Error deleting group")}Y(!1),G("")},e9=async e=>{let t=[...u.customLayers];for(let a of e)t=t.filter(e=>e!==a);for(let a of(u.setCustomLayers(t),e))(0,S.TC)(a,d.map);k(""),L(M?.properties.color),j(!1),F(!1),U(!1),Y(!1),y.Ay.success("Layers Deleted Successfully")};return(0,o.jsxs)("div",{className:"p-1",children:[(0,o.jsx)(V.A,{isOpen:P,onDelete:()=>{M&&eK(M)},closeModal:()=>F(!1),deleteText:"You are about to permanently delete the GIS layer used for search and navigation within the project. Are you sure you want to remove Project GIS from this project?"}
15),(0,o.jsxs)("div",{className:"form-control collapse-arrow",children:[(0,o.jsx)(rM(),{open:!0,trigger:(0,o.jsxs)("div",{className:"collapsible_trigger font-semibold text-base mt-5 mr-2 border-b pb-2 border-gray-200",children:[(0,o.jsx)("span",{className:"collapsible_arrow",children:(0,o.jsx)(W.tEr,{})}),"Built-in Layers"]}),transitionTime:150,overflowWhenOpen:"visible",children:(0,o.jsx)(rO,{})}),u.customLayers&&u.customLayers.filter(e=>e.source!==rX.mb.IFC).length>0&&(0,o.jsx)(rM(),{trigger:(0,o.jsxs)("div",{className:"collapsible_trigger font-semibold text-base mt-5 mr-2 border-b pb-2 border-gray-200","data-testid":"gis-layers-collapsible-trigger",children:[(0,o.jsx)("span",{className:"collapsible_arrow",children:(0,o.jsx)(W.tEr,{})}),"GIS",(0,o.jsxs)("label",{htmlFor:"add-group-modal",className:"btn btn-sm btn-outline ml-auto mr-1",style:{fontSize:"13px"},onClick:e=>{e.stopPropagation(),G(""),U(!0)},children:[(0,o.jsx)($.FT1,{size:18})," Add group"]})]}),overflowWhenOpen:"visible",transitionTime:150,children:(0,o.jsx)(sy,{customLayers:u.customLayers,groups:J,handleGroupVisiblityToggle:e8,setSelectedGroup:Z,setGroupLayers:K,setEditGroupModal:Y,setSelectedLayer:E,handleEditClick:eY,handleTableClick:eH,handleDeleteClick:eK,handleCancelClick:eX,handleToggleVisibility:e5,order:ez,setOrder:eU,handleRefreshClick:eZ})}),u.customLayers&&u.customLayers.filter(e=>e.source===rX.mb.IFC).length>0&&(0,o.jsx)(rM(),{trigger:(0,o.jsxs)("div",{className:"collapsible_trigger font-semibold text-base mt-5 mr-2 border-b pb-2 border-gray-200",children:[(0,o.jsx)("span",{className:"collapsible_arrow",children:(0,o.jsx)(W.tEr,{})}),"BIM"]}),transitionTime:150,overflowWhenOpen:"visible",children:(0,o.jsx)(sy,{customLayers:u.customLayers,groups:J,handleGroupVisiblityToggle:e8,setSelectedGroup:Z,setGroupLayers:K,setEditGroupModal:Y,setSelectedLayer:E,handleEditClick:eY,handleTableClick:eH,handleDeleteClick:eK,handleCancelClick:eX,handleToggleVisibility:e5,order:ez,setOrder:eU,handleRefreshClick:eZ,ifc:!0})}),(r&&r.size>0||l&&l.size>0)&&(0,o.jsx)(rM(),{trigger:(0,o.jsxs)("div",{className:"collapsible_trigger font-semibold text-base mt-5 mr-2 border-b flex pb-2 border-gray-200",children:[(0,o.jsx)("span",{className:"collapsible_arrow",children:(0,o.jsx)(W.tEr,{})}),"Tours",(0,o.jsx)("div",{className:"beta-tag ml-2",children:"BETA"})]}),transitionTime:150,children:(0,o.jsx)(se,{tourMap:r,refreshTourList:s,map:d.map,toursInProgress:l})})]}),b&&M&&(0,o.jsx)(r8,{selectedLayer:M,setSelectedLayer:E,setEditMode:j,editLayerColor:C,setEditLayerColor:L,setEditLayerName:k,setEditLayerOpacity:A,setLayerScope:R,setGroupName:G,groups:J,setDeleteModalOpen:F,handleSaveClick:e1,handleDeleteClick:eK,icon:Q,setIcon:ee,useGradient:et,setUseGradient:ea,gradient1:er,setGradient1:es,gradient2:el,setGradient2:ei,categoricalColors:en,setCategoricalColors:eo,categoricalOpacities:ec,setCategoricalOpacities:ed,property:eu,setProperty:ep,gradientOption:em,setGradientOption:eh,ifcLat:ef,setIfcLat:eg,ifcLon:ey,setIfcLon:eb,ifcElevation:eS,setIfcElevation:ek,ifcScale:ej,setIfcScale:eN,ifcX:e_,setIfcX:eC,ifcY:eL,setIfcY:eA,ifcZ:eM,setIfcZ:eE,referenceDate:eT,setReferenceDate:eI,setColorOption:eF,lineStyle:eO,setLineStyle:eR,setLabelProperty:eB}),(0,o.jsx)(rU,{showGroupNameModal:z,setShowGroupNameModal:U,groupName:B,setGroupName:G,groups:J}),q&&(0,o.jsx)(rW,{selectedGroup:H,groupLayers:X,groupName:B,setGroupName:G,editGroupModal:q,setEditGroupModal:Y,handleDeleteGroup:e7,handleDeleteAllLayers:e9,handleSaveGroup:e6})]})}var sj=a(9380);let sw=[{style:"mapbox://styles/mapbox/outdoors-v12",label:"Outdoors",imageSrc:"/images/streets2.png"},{style:"mapbox://styles/mapbox/dark-v11",label:"Dark",imageSrc:"/images/dark.png"},{style:"mapbox://styles/mapbox/navigation-day-v1",label:"Streets Day",imageSrc:"/images/streets_day.png"},{style:"mapbox://styles/mapbox/satellite-streets-v12",label:"Satellite Streets",imageSrc:"/images/satellite_streets.png"},{style:"mapbox://styles/mapbox/light-v11",label:"Light",imageSrc:"/images/light.png"},{style:"mapbox://styles/mapbox/navigation-night-v1",label:"Night",imageSrc:"/images/streets_night.png"},{style:"mapbox://styles/mapbox/satellite-v9",label:"Satellite",imageSrc:"/images/satellite.png"},{style:"mapbox://styles/mapbox/streets-v12",label:"Streets",imageSrc:"/images/streets.png"},{style:"mapbox://styles/mapbox/standard-beta",label:"Detailed",imageSrc:"/images/detailed.png"}],sv=function(){let e=(0,eV.H)(),t=(0,eG.JY)();return(0,o.jsx)("div",{className:"gap-3 flex flex-col",children:sw.map(({style:a,label:r,imageSrc:s})=>
15(0,o.jsx)(a8,{beta:"Detailed"===r,descriptionLines:[{icon:e0.f35,text:"Source: Mapbox"}],selected:e.mapStyle===a,imageSrc:s,label:r,onClick:()=>((a,r="dawn")=>{t.splitViewEnabled?y.Ay.error("Map split is only compatible with premium layers"):(e.setMapStyle(a),a.includes("standard-beta")&&setTimeout(()=>{t.map.current?.setConfigProperty("basemap","lightPreset",r),t.map.current?.setConfigProperty("basemap","showPlaceLabels",!1),t.map.current?.setConfigProperty("basemap","showPointOfInterestLabels",!1),t.altMap?.current?.setConfigProperty("basemap","lightPreset",r)},1e3))})(a)},a))})},sN=e=>{let t=(0,eV.H)(),a=(0,h.useRef)(!1),[r,s]=(0,h.useState)(null),[l,i]=(0,h.useState)(null);(0,h.useEffect)(()=>{let e=t.dropFile;if(e){a.current=!0;let t=new DataTransfer;t.items.add(e),n(t.files);return}if(a.current){a.current=!1;return}},[e.layerType,t.dropFile]),(0,h.useEffect)(()=>{let t=rX.d8[e.layerType].fileAccept;t&&r&&!t.some(e=>r.endsWith(e))&&(s(null),e.setCustomLayerFiles(null),e.setIntegrationFile(null),e.setLidarIntegrationFile(null))},[e.layerType]);let n=async t=>{if(t&&t.length>0){let a=rX.d8[e.layerType];if(a?.maxSizeBytes&&t[0].size>a.maxSizeBytes)return void alert(`File size exceeds the limit of ${a.maxSizeBytes/x.S$.gigabyte}GB. Please upload a supported file size.`);e.setCustomLayerFiles(t);let r=t[0].name,s=r.split(".").pop()?.toLowerCase(),l=s?(0,ra.$B)(s):null;l&&e.setLayerType(l)}t&&s(Array.from(t).map(e=>e.name).join(", "))};return(0,o.jsxs)("div",{children:[e.layerType===rX.mb.Tours&&!l&&(0,o.jsx)("div",{"data-testid":"layer-tour-csv-uploader-container",children:(0,o.jsx)(eL.l,{types:["csv"],multiple:!1,handleChange:t=>{if(t){let a=rX.d8[e.layerType];if(a?.maxSizeBytes&&t.size>a.maxSizeBytes)return void alert(`File size exceeds the limit of ${a.maxSizeBytes/x.S$.gigabyte}GB. Please upload a supported file size.`);i(t.name),e.setTourCsvFile(t)}},name:"file",classes:"file-uploader",children:(0,o.jsxs)("div",{className:"file-uploader-box my-3",children:[(0,o.jsx)(W.v4w,{size:18,className:"flex opacity-50"}),(0,o.jsx)("span",{className:"opacity-50 mt-1",children:`Upload ${e.layerType} CSV File ( .csv )`}),(0,o.jsxs)("span",{className:"opacity-50",children:["Max: ",(0,v.z3)(x.S$.gigabyte/500)]})]})})}),e.layerType===rX.mb.Tours&&l&&(0,o.jsx)("div",{children:(0,o.jsx)("div",{className:"file-uploader-metadata my-3",children:(0,o.jsxs)("div",{className:"file-uploader-metadata-tex flex justify-between items-center w-full",children:[(0,o.jsx)("span",{title:l,children:l.length>32?l.slice(0,32)+"...":l}),(0,o.jsx)(W.fUT,{className:"file-uploader-delete",onClick:()=>{i(null),t.setDropFile(null)}})]})})}),r?(0,o.jsx)("div",{className:"mr-2",children:(0,o.jsx)("div",{className:"file-uploader-metadata my-3",children:(0,o.jsxs)("div",{className:"file-uploader-metadata-text w-full flex justify-between items-center",children:[(0,o.jsx)("span",{title:r,className:"truncate",children:r}),(0,o.jsx)(W.fUT,{className:"file-uploader-delete",onClick:()=>{e.setCustomLayerFiles&&e.setCustomLayerFiles(null),t.setDropFile(null),s(null),e.setIntegrationFile(null),e.setLidarIntegrationFile(null)}})]})})}):(0,o.jsxs)("div",{className:"mr-2","data-testid":`layer-file-uploader-${e.layerType}
15`,children:[(0,o.jsx)(eL.l,{types:rX.d8[e.layerType].fileAccept,multiple:!0,handleChange:n,name:"file",classes:"file-uploader",children:(0,o.jsxs)("div",{className:"file-uploader-box my-3",children:[(0,o.jsx)(W.v4w,{size:18,className:"flex opacity-50"}),(0,o.jsx)("span",{className:"opacity-50 mt-1",children:t.dropFile&&!l&&rX.d8[e.layerType].fileAccept?t.dropFile.name:`Upload ${e.layerType} File (${rX.d8[e.layerType].fileAccept?.map(e=>"."+e).join(", ")})`}),(0,o.jsxs)("span",{className:"opacity-50",children:["Max: ",(0,v.z3)(rX.d8[e.layerType].maxSizeBytes||0)]})]})}),(0,o.jsx)(eM.A,{modalHtml:"sharepoint-select-layer-modal",onChange:t=>{let a=rX.d8[e.layerType].fileAccept;a&&!a.includes(t.name.split(".").pop()?.toLowerCase())?y.Ay.error("Invalid file format. Valid formats are: "+a.map(e=>"."+e).join(", ")):(e.setIntegrationFile(t),e.setLidarIntegrationFile(t),s(t.name))}})]})]})},sS=e=>(0,o.jsx)("code",{className:"bg-gray-100 px-1 py-0.5 rounded block mt-1",children:e}),sk=({layerType:e})=>{if(e!==rX.mb.WFS&&e!==rX.mb.ArcGIS&&e!==rX.mb.DXF&&e!==rX.mb.ShapeFile&&e!==rX.mb.Tours)return null;let t=e===rX.mb.ShapeFile?W.qVV:e0.z5h;return(0,o.jsxs)("div",{className:"rounded-md bg-tt-blue/10 opacity-70 w-full p-3 flex items-start gap-3 mt-1 mb-2 text-sm",children:[(0,o.jsx)(t,{size:20,className:"mt-0.5 shrink-0"}),(0,o.jsxs)("div",{className:"space-y-3",children:[e===rX.mb.WFS&&(0,o.jsxs)("p",{children:["Only ",(0,o.jsx)("b",{children:"WFS 2.0.0"})," servers are currently supported."]}),e===rX.mb.ArcGIS&&(0,o.jsxs)("div",{children:[(0,o.jsx)("p",{children:"Please enter a valid ArcGIS Server REST URL. It should include the service path and layer number, and can optionally include a query."}),(0,o.jsx)("div",{className:"mt-2",children:"Examples:"}),sS("/FeatureServer/<layer_id>"),sS("/FeatureServer/<layer_id>/query?where=1=1"),sS("/MapServer/<layer_id>/query?where=POPULATION>1000")]}),e===rX.mb.DXF&&(0,o.jsxs)("p",{children:["DXF currently supported only with: ",(0,o.jsx)("b",{children:"EPSG:4326"}),"."]}),e===rX.mb.ShapeFile&&(0,o.jsxs)("div",{children:[(0,o.jsx)("div",{className:"font-medium",children:"ShapeFile LRS Requirements"}),(0,o.jsxs)("p",{children:["LRS will only be enabled if the layer includes ",(0,o.jsx)("code",{children:"LINESTRING M"})," or"," ",(0,o.jsx)("code",{children:"MULTILINESTRING M"})," geometries and contains the ",(0,o.jsx)("code",{children:"ROUTE"})," ","attribute.",(0,o.jsx)("br",{}),"Adding a new LRS layer will ",(0,o.jsx)("strong",{children:"overwrite"})," existing LRS data."]})]}),e===rX.mb.Tours&&(0,o.jsxs)("p",{children:["Click ",(0,o.jsx)("a",{href:"https://fusionmap.com/uploading-tours",className:"underline",target:"_blank",rel:"noopener noreferrer",children:"here"})," to learn more about Tours and find instructions on how to upload them."]})]})]})},s_=({enableLRS:e,setEnableLRS:t})=>(0,o.jsxs)("div",{className:"flex items-center justify-between gap-2 mb-2",children:[(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("span",{className:"label-text",children:"Enable LRS?"}),(0,o.jsx)("div",{className:"beta-tag ml-2",children:"BETA"})]}),(0,o.jsxs)("div",{className:"flex items-center gap-6","data-testid":"enable-lrs-radio-buttons",children:[(0,o.jsxs)("label",{className:"flex items-center gap-2",children:[(0,o.jsx)("input",{type:"radio",value:"Yes",className:"radio",checked:e,onChange:()=>t(!0)}),(0,o.jsx)("span",{className:"label-text",children:"Yes"})]}),(0,o.jsxs)("label",{className:"flex items-center gap-2",children:[(0,o.jsx)("input",{type:"radio",value:"No",className:"radio",checked:!e,onChange:()=>t(!1)}),(0,o.jsx)("span",{className:"label-text",children:"No"})]})]})]}),sC=({ifcCoordinates:e,setIfcCoordinates:t})=>(0,o.jsxs)("div",{className:"flex w-full flex-col gap-2",children:[(0,o.jsx)("span",{className:"label-text",children:"Coordinates"}),(0,o.jsxs)("div",{className:"flex flex-col gap-2 tablet:flex-row tablet:items-center",children:[(0,o.jsx)("input",{type:"number",placeholder:"Lat",className:"text-black input w-full tablet:w-1/2 tablet:mr-5",value:e?.lat??"",onChange:e=>{let a=e.target.value;""===a?t({lat:null,lon:null}):t({lat:Math.max(-89,Math.min(89,Number(a))),lon:null})}}),(0,o.jsx)("input",{type:"number",placeholder:"Lon",className:"text-black input w-full tablet:w-1/2",value:e?.lon??"",onChange:e=>{let a=e.target.value;""===a?t({lat:null,lon:null}):t({lat:null,lon:Math.max(-179,Math.min(179,Number(a)))})}})]})]}),sL=e=>{let{metadata:t,onChange:a}=e,r=(e,r)=>{a({...t,[e]:r})},s=[x.ni.mm,x.ni.cm,x.ni.in,x.ni.ft];return(0,o.jsxs)("div",{id:"optional-fields-section",className:"flex flex-col gap-3 mt-4 border border-gray-200 rounded p-4 bg-gray-50",children:[(0,o.jsxs)("div",{children:[(0,o.jsx)("span",{className:"flex label-text",children:"Sensor Type"}),(0,o.jsx)("input",{type:"text",value:t.sensor_type||"",onChange:e=>r("sensor_type",e.target.value),className:"text-black input mt-2 w-full"})]}),(0,o.jsx)("div",{className:"w-full tablet:max-w-[400px] tablet:mx-auto",children:(0,o.jsx)("div",{className:"flex flex-row gap-4 w-full",children:(0,o.jsxs)("div",{className:"flex flex-col gap-2 w-full",children:[(0,o.jsx)("span",{className:"flex label-text mt-2",children:"Survey Accuracy"}),(0,o.jsxs)("div",{className:"relative w-full",children:[(0,o.jsx)("input",{type:"number",step:"any",min:"0",value:t.survey_accuracy??"",onChange:e=>r("survey_accuracy",parseFloat(e.target.value)),onWheel:e=>e.currentTarget.blur(),className:"text-black input pr-18 w-full"}),(0,o.jsx)("select",{className:"absolute z-50 right-2 top-1/2 -translate-y-1/2 bg-gray-100 border border-gray-300 rounded-full px-2 py-0.5 text-xs h-6 focus:outline-none",style:{minWidth:56},value:t.survey_units,onChange:e=>r("survey_units",e.target.value),children:s.map(e=>(0,o.jsx)("option",{value:e,children:e},e))})]}),(0,o.jsx)("span",{className:"flex label-text mt-2",children:"Pointcloud Accuracy"}),(0,o.jsxs)("div",{className:"relative w-full",children:[(0,o.jsx)("input",{type:"number",step:"any",min:"0",value:t.pointcloud_accuracy??"",onChange:e=>r("pointcloud_accuracy",parseFloat(e.target.value)),onWheel:e=>e.currentTarget.blur(),className:"text-black input pr-18 w-full"}),(0,o.jsx)("select",{className:"absolute right-2 z-50 top-1/2 -translate-y-1/2 bg-gray-100 border border-gray-300 rounded-full px-2 py-0.5 text-xs h-6 focus:outline-none",style:{minWidth:56},value:t.pointcloud_units,onChange:e=>r("pointcloud_units",e.target.value),children:s.map(e=>(0,o.jsx)("option",{value:e,children:e},e))})]})]})})}),(0,o.jsxs)("div",{children:[(0,o.jsx)("span",{className:"flex label-text",children:"Comment"}),(0,o.jsx)("textarea",{value:t.comment||"",onChange:e=>r("comment",e.target.value),maxLength:250,className:"textarea mt-2 w-full",placeholder:"Add a comment"})]})]})},sD=function({cameraType:e,setCameraType:t,cameraNum:a,setCameraNum:r,cameraFileEpsg:s,setCameraFileEpsg:l,tourMetadata:i,setTourMetadata:n}){let c=e=>{t(e.target.value),r(1)};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("span",{className:"label-text",children:"Camera Type"}),(0,o.jsx)("div",{className:"items-center tooltip tooltip-bottom cursor-pointer text-sm opacity-50 ml-2","data-tip":"Select 360\xb0 for panoramic images",children:(0,o.jsx)(W.MGr,{})})]}),(0,o.jsxs)("div",{className:"camera-type-container",children:[(0,o.jsxs)("label",{className:"flex items-center cursor-pointer",children:[(0,o.jsx)("input",{type:"radio",name:"cameraType",value:"camera",checked:"camera"===e,onChange:c,className:"radio radio-sm"}),(0,o.jsx)("span",{className:"ml-2 label-text",children:"Regular"})]}),(0,o.jsxs)("label",{className:"flex items-center cursor-pointer ml-4",children:[(0,o.jsx)("input",{type:"radio",name:"cameraType",value:"pano",checked:"pano"===e,onChange:c,className:"radio radio-sm"}),(0,o.jsx)("span",{className:"ml-2 label-text",children:"360\xb0"})]})]}),(0,o.jsxs)("div",{className:"flex flex-col justify-between",children:[(0,o.jsxs)("div",{children:[(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("span",{className:"label-text",children:"Source Camera EPSG"}),(0,o.jsx)("div",{className:"items-center tooltip tooltip-bottom cursor-pointer text-sm opacity-50 ml-2","data-tip":"Input the EPSG of the camera coordinates in the CSV",children:(0,o.jsx)(W.MGr,{})})]}),(0,o.jsx)("input",{type:"number",value:s,onChange:e=>l(Number(e.target.value)),className:"text-black input mt-2 w-full tablet:w-1/2"})]}),"camera"===e&&(0,o.jsxs)("div",{className:"mt-4",children:[(0,o.jsx)("span",{className:"flex label-text",children:"Camera Number"}),(0,o.jsx)("select",{value:a,className:"text-black select select-bordered mt-2 w-full tablet:w-[210px]",id:"tour-num-select",onChange:e=>r(Number(e.target.value)),children:ra.tQ.map(e=>(0,o.jsx)("option",{value:e,children:e},e))})]})]}),(0,o.jsx)("div",{className:"mt-4",children:(0,o.jsx)(rM(),{open:!1,trigger:(0,o.jsxs)("div",{className:"collapsible_trigger font-semibold text-base mt-4 mr-2 border-b pb-2 border-gray-200",children:[(0,o.jsx)("span",{className:"collapsible_arrow",children:(0,o.jsx)(W.tEr,{})}),"Optional Metadata"]}),transitionTime:150,overflowWhenOpen:"visible",children:(0,o.jsx)(sL,{metadata:i,onChange:n})})})]})},sA=function({layerType:e,fileEpsg:t,setFileEpsg:a,pointcloudMetadata:r,setPointcloudMetadata:s}){let l=(0,ev.O)();return(0,o.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,o.jsx)("span",{className:"label-text",children:"Source File EPSG"}),(0,o.jsx)("input",{type:"number",className:"text-black input mt-2 w-full tablet:w-1/2",value:t,onChange:e=>a(Number(e.target.value))}),(0,o.jsx)(rM(),{open:!1,trigger:(0,o.jsxs)("div",{className:"collapsible_trigger font-semibold text-base mt-5 mr-2 border-b pb-2 border-gray-200",children:[(0,o.jsx)("span",{className:"collapsible_arrow",children:(0,o.jsx)(W.tEr,{})}),"Optional Metadata"]}),transitionTime:150,overflowWhenOpen:"visible",children:(0,o.jsx)(sL,{metadata:r,onChange:s})}),(0,o.jsxs)("div",{className:"rounded-md bg-tt-blue/10 opacity-70 w-full p-3 flex items-center gap-3 mt-3 mb-2",children:[(0,o.jsx)(e0.z5h,{size:20}),(0,o.jsxs)("span",{className:"text-sm",children:[(0,o.jsx)("b",{children:(0,v.IX)()&&(0,o.jsxs)(o.Fragment,{children:["Uploading from test will not work as the Logic App needs a callable backend. Use USDEV",(0,o.jsx)("br",{})]})}),"If your ",e," file is not in the correct projection, specify it above. This project uses:"," ",(0,o.jsx)("b",{children:l.project?.lidar_epsg||"EPSG unknown"}),".",(0,o.jsx)("br",{}),(0,o.jsx)("b",{children:"Note:"})," Your ",e," file will be converted into a LAZ file, and the raw will not be kept."]})]})]})};async function sM(e,t,a,r){let s=new FormData,l=e.name.split(".").pop();e.name=`${a.uuid}.${l}`,s.append("integration_file",JSON.stringify(e)),s.append("project_uuid",t.project_uuid),s.append("folder","lidar");let i=await (0,_.x)("/blob/upload-integration",{method:"PUT",form:s,rawResponse:!0});if(!i.body)return;let n=i.body.getReader(),o=new TextDecoder,c="";for(;;){let{done:e,value:t}=await n.read();if(e){r(100);break}let a=0;for(let e of(c+=o.decode(t,{stream:!0})).split("\n\n")){if(e){let t=JSON.parse(e.replace("data: ",""));void 0!==t.progress?a=Math.max(a,t.progress):t.done&&(a=100)}r(a)}}}var sE=a(87680);let sT=()=>{let e=(0,eD.l)(),t=(0,ev.O)().project;if(!t)throw Error("Project not found");let a=`${m.oj}${t.container_name}/`;return{generateBlobUrl:({file:e,uuid:t,layerType:r})=>{let s=e.name.split(".").pop();if(!s)throw Error("File extension not found");let l=`${t}.${s}`,i=rX.d8[r].blobFilePath;if(!i)throw Error("Blob file path not found");return`${a}${i}${l}`},uploadFileToBlobStorage:async({file:e,blobUrl:t,sasToken:a,onProgress:r,abortController:s})=>{let l=`${t}?${a}`;return new sE.wG(l).uploadData(e,{blockSize:rX.EX,concurrency:rX.QS,abortSignal:s.signal,onProgress:t=>{r(Math.round(t.loadedBytes/e.size*100))}})},createBlobUploadingManager:(t,a)=>{let r=(0,v.kX)(),s={};for(let e of t)s[e.name]=0;return e.addUploading({id:r,title:Object.keys(s).join(", "),progress:0,type:x.dP.layer,layerStatus:x.iO.processing,onClose:()=>a.abort()}),(t,a)=>{s[t]=a;let l=Math.round(Object.values(s).reduce((e,t)=>
15e+t,0)/Object.values(s).length);e.updateUploading(r,{progress:l,...100===l?{status:x.nW.upload_complete}:{}})}}}};function sI(e){let t=(0,ev.O)(),{generateBlobUrl:a,uploadFileToBlobStorage:r,createBlobUploadingManager:s}=sT(),[l,i]=(0,h.useState)({status:"",progress:0}),[n,c]=(0,h.useState)(null),d=(0,h.useRef)(n),u=(0,h.useRef)(null);(0,h.useEffect)(()=>{d.current=n},[n]),(0,h.useEffect)(()=>{i({status:"",progress:0}),c(null);let t=async()=>{d.current&&(u.current?.abort(),await (0,sj.ev)(d.current))};return window.addEventListener("beforeunload",t),()=>{window.removeEventListener("beforeunload",t),d.current&&(u.current?.abort(),(0,sj.ev)(d.current).then(()=>{}).catch(e=>console.error(e)),e.refreshLidarList())}},[]);let p=async()=>{if(!e.file&&!e.integrationFile||!t.project)return void y.Ay.error("No file found");if(!e.name||""===e.name.trim())return void y.Ay.error("Invalid Layer Name");i({status:"uploading",progress:0});let l=new AbortController;u.current=l;let n=e.file?e.file.name:e.integrationFile?.name;try{let o=await (0,_.x)("/map/create-lidar",{method:"POST",json:{name:e.name,input_file:n,date:e.date,project_id:t.project.project_uuid,user_metrics:e.metadata}});if(c(o.uuid),e.file)try{let t=a({file:e.file,uuid:o.uuid,layerType:rX.mb.Pointcloud}),c=s([e.file],u.current);await r({file:e.file,blobUrl:t,sasToken:o.sasToken,onProgress:e=>{c(n,e),i({status:"uploading",progress:e})},abortController:l})}catch(e){console.error(e);return}else e.integrationFile&&await sM(e.integrationFile,t.project,o,e=>{i({status:"uploading",progress:e})});if(l.signal.aborted)return;c(null),i({status:"",progress:0}),setTimeout(()=>{e.refreshLidarList()},500),y.Ay.success("File successfully uploaded. We are processing your file now in the background.");let d=n.split(".").pop(),p=`${o.uuid}.${d}`,h=`${m.oj}${t.project.container_name}/lidar/raw/${p}`,x={uuid:o.uuid,blob_url:h,sas_token:o.sasToken,file_epsg:e.fileEpsg.toString(),project_id:t.project.project_uuid};await (0,_.x)("/map/convert-lidar",{method:"POST",json:x})}catch{c(null),y.Ay.error("Uploading failed. Please try it again")}};return(0,o.jsx)("div",{className:"pb-4",children:"uploading"!=l.status?(0,o.jsx)("button",{className:"btn tt-blue-button text-white mt-2 w-full",onClick:p,children:"Upload"}):(0,o.jsxs)("div",{className:"flex flex-col items-center mt-4",children:[(0,o.jsx)("div",{className:"notes-uploading-progress-bar",children:(0,o.jsx)("div",{className:"notes-uploading-progress-bar-elapsed",style:{width:`${l.progress}%`}})}),(0,o.jsxs)("div",{className:"notes-uploading-progress-bar-text flex-col gap-1",children:[(0,o.jsxs)("div",{className:"flex gap-2",children:[(0,o.jsx)("span",{className:"loading loading-spinner loading-xs"}),100===l.progress?(0,o.jsx)("span",{children:"Processing"}):(0,o.jsxs)(o.Fragment,{children:["Uploading (",l.progress,"%)"]})]}),(0,o.jsx)("span",{className:"mt-5",children:"Do not close this window while the file is uploading."})]})]})})}a(78348),a(56142);let sP=[{key:"Dropdown",canHaveAnswer:!0,name:"Dropdown",icon:"far fa-caret-square-down",label:"Place holder label",field_name:"dropdown_",options:[]},{key:"Checkboxes",canHaveAnswer:!0,name:"Checkboxes",icon:"far fa-check-square",label:"Place holder label",field_name:"checkboxes_",options:[]},{key:"RadioButtons",canHaveAnswer:!0,name:"Multiple choice",icon:"far fa-dot-circle",label:"Place holder label",field_name:"radiobuttons_",options:[]},{key:"TextInput",canHaveAnswer:!0,name:"Text input",label:"Place holder label",icon:"fas fa-font",field_name:"text_input_"},{key:"EmailInput",canHaveAnswer:!0,name:"Email input",label:"Place holder email",icon:"fas fa-envelope",field_name:"email_input_"},{key:"NumberInput",canHaveAnswer:!0,name:"Number input",label:"Place holder label",icon:"fas fa-plus",field_name:"number_input_"},{key:"PhoneNumber",canHaveAnswer:!0,name:"Phone number",label:"Place holder phone number",icon:"fas fa-phone",field_name:"phone_input_"},{key:"TextArea",canHaveAnswer:!0,name:"Multi line input",label:"Place holder label",icon:"fas fa-text-height",field_name:"text_area_"},{key:"Rating",canHaveAnswer:!0,name:"Rating",label:"Place holder label",icon:"fas fa-star",field_name:"rating_"},{key:"DatePicker",canDefaultToday:!0,canReadOnly:!1,dateFormat:"MM/dd/yyyy",timeFormat:"hh:mm aa",showTimeSelect:!1,showTimeSelectOnly:!1,showTimeInput:!1,name:"Date picker",icon:"far fa-calendar-alt",label:"Place holder label",field_name:"date_picker_"},{key:"Range",name:"Range",icon:"fas fa-sliders-h",label:"Place holder label",field_name:"range_",step:1,default_value:3,min_value:1,max_value:5,min_label:"Easy",max_label:"Difficult"}];var sF=a(57186);let sO=sd("ReactFormBuilder"),sR=sd("ReactFormGenerator"),s$=new Set(sP.map(e=>e.key)),sz=new Map(sP.map(e=>[e.key,e.name??e.key])),sU=new Set(sP.filter(e=>Array.isArray(e.options)).map(e=>e.key)),sW=({formBuilderData:e,setFormBuilderData:t,featureType:a,setFeatureType:r,validationErrors:s,setValidationErrors:l})=>{let i=(0,h.useRef)(null),n=(0,h.useRef)(null),c=(0,h.useRef)(null),[d,u]=(0,h.useState)(null),p=async e=>{let a=e.target.files?.[0];if(a){u(null);try{var r;let e,s,i;if("application/json"!==a.type&&!a.name.toLowerCase().endsWith(".json"))return void u({type:"error",message:"Please upload a valid JSON file"});let n=await a.text(),o=JSON.parse(n);if(!Array.isArray(o?.task_data))return void u({type:"error",message:"Invalid form template"});let{sanitizedTaskData:c,unsupportedElements:d,hasInvalidItems:p}=(r=o.task_data,s=new Set,i=!1,{sanitizedTaskData:(e=[],r.forEach(t=>{if(!t||"object"!=typeof t){i=!0;return}let a=t.element;if("string"!=typeof a){i=!0;return}if(!s$.has(a))return void s.add(a);if(sU.has(a)&&!(e=>{let t=e.options;if(!Array.isArray(t)||0===t.length)return!1;let a=e=>"string"==typeof e&&e.trim().length>0;return t.every(e=>e&&"object"==typeof e&&a(e.text)&&a(e.key)&&a(e.value))})(t)||"string"!=typeof t.label){i=!0;return}if(sU.has(a)){var r;let s,l;if(r=t.options,s=e=>e.trim().toLowerCase(),(l=e=>new Set(e).size<e.length)(r.map(e=>s(e.key)))||l(r.map(e=>s(e.value)))){i=!0;return}e.push({...t,text:sz.get(a)??a});return}let l={...t,text:sz.get(a)??a};e.push(l)}),e),unsupportedElements:Array.from(s),hasInvalidItems:i});if(0===c.length)return void u({type:"error",message:"Template has no supported inputs"});let m=[];d.length>0&&m.push(`Input type(s) not supported: ${d.join(", ")}
15`),p&&m.push("Template contains invalid items that were skipped"),u(m.length>0?{type:"warning",message:m.join("\n")}:null);let h=su(c);l(h),t({id:(0,sF.A)(),template:{...o,task_data:c}})}catch(e){e instanceof Error?console.error(e.message):console.error("Failed to parse form template"),u({type:"error",message:"Failed to parse form template"})}finally{c.current&&(c.current.value="")}}};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,o.jsx)("span",{className:"label-text",children:"Feature Type"}),(0,o.jsx)("select",{"data-testid":"custom-form-feature-type-select",value:a,className:"select w-full tablet:w-auto",onChange:e=>r(e.target.value),children:Object.values(x.lo).map(e=>(0,o.jsx)("option",{value:e,children:e},e))})]}),(0,o.jsx)("div",{className:"font-semibold flex justify-center text-base",children:(0,o.jsxs)("button",{className:"btn btn-sm btn-outline flex items-center gap-1",style:{fontSize:"13px"},"data-testid":"create-custom-form-button",onClick:()=>{i.current?.showModal()},type:"button",children:[(0,o.jsx)(z.bTh,{size:16}),(0,o.jsx)("span",{children:e.template.task_data.length>0?`Edit (${e.template.task_data.length} Inputs Selected)`:"Create Form"})]})}),(0,o.jsxs)("dialog",{className:"modal [&:not([open])]:hidden",ref:n,children:[(0,o.jsxs)("div",{className:"modal-box flex flex-col gap-4 overflow-y-auto h-[80vh] p-4 w-full desktop:!w-[500px]",children:[(0,o.jsxs)("div",{className:"flex justify-between items-center border-b border-black/10 pb-2",children:[(0,o.jsx)("div",{className:"font-semibold text-lg",children:"Form Preview"}),(0,o.jsx)("button",{className:"btn btn-sm btn-circle btn-ghost","data-testid":"close-form-preview-button",onClick:()=>n.current?.close(),children:"✕"})]}),(0,o.jsx)(sR,{form_action:"",form_method:"",data:e.template.task_data,hide_actions:!0})]}),(0,o.jsx)("form",{method:"dialog",className:"modal-backdrop",children:(0,o.jsx)("button",{children:"close"})})]}),(0,o.jsx)("dialog",{className:"modal [&:not([open])]:hidden",ref:i,children:(0,o.jsxs)("div",{className:"modal-box max-w-full w-[80vw] max-tablet:w-full !h-[90vh] flex flex-col gap-4 overflow-hidden",children:[(0,o.jsxs)("div",{className:"flex justify-between max-tablet:flex-col max-tablet:gap-2",children:[(0,o.jsx)("div",{className:"font-semibold text-lg",children:"Custom Form Builder"}),(0,o.jsxs)("div",{className:"flex gap-2",children:[(0,o.jsx)("input",{"data-testid":"custom-form-template-input",type:"file",accept:".json, application/json",onChange:p,ref:c,hidden:!0}),(0,o.jsx)("button",{className:"btn btn-sm","data-testid":"upload-template-button",type:"button",onClick:()=>c.current?.click(),children:"Upload template"}),(0,o.jsx)("button",{className:"btn btn-sm","data-testid":"preview-form-button",onClick:()=>n.current?.showModal(),type:"button",children:"Preview Form"}),(0,o.jsx)("button",{className:"btn btn-sm tt-blue-button","data-testid":"save-and-close-form-button",onClick:()=>{u(null),i.current?.close(),n.current?.close()},type:"button",children:"Save and close"})]})]}),d&&(0,o.jsx)("div",{"data-testid":"custom-form-template-feedback",className:`alert ${"error"===d.type?"alert-error":"alert-warning"} py-2 text-sm`,children:(0,o.jsx)("span",{className:"whitespace-pre-line",children:d.message})}),(0,o.jsx)("div",{className:"overflow-hidden flex-1",children:(0,o.jsx)(sO,{onLoad:()=>Promise.resolve(e.template.task_data),onPost:e=>{let a=su(e.task_data);a.length>0?l(a):(l([]),t(t=>({id:t.id,template:e})))},toolbarItems:sP,validationErrors:s},e.id)})]})})]})},sB=function({onFeatureClick:e,refreshLidarList:t,layerType:a,setLayerType:r}){let s=(0,eV.H)(),l=(0,eG.JY)(),i=(0,eD.l)(),n=(0,ew.u)(),c=(0,ev.O)(),{goBack:d,pushSubPage:u}=(0,e$.p)(),[p,m]=(0,h.useState)(""),[f,g]=(0,h.useState)(ra.SY.Draft),[b,j]=(0,h.useState)(null),[w,N]=(0,h.useState)(null),[S,k]=(0,h.useState)(null),[_,C]=(0,h.useState)(null),[L,D]=(0,h.useState)(""),[A,M]=(0,h.useState)(""),[E,T]=(0,h.useState)(""),[I,P]=(0,h.useState)(new Date),[F,O]=(0,h.useState)(!1),[R,$]=(0,h.useState)(!1),[z,U]=(0,h.useState)({lat:null,lon:null}),[W,B]=(0,h.useState)("camera"),[V,G]=(0,h.useState)(1),[J,q]=(0,h.useState)(Number(c.project?.camera_epsg)),[Y,Z]=(0,h.useState)({sensor_type:void 0,survey_accuracy:void 0,survey_units:x.ni.mm,pointcloud_accuracy:void 0,pointcloud_units:x.ni.mm,comment:void 0}),[X,K]=(0,h.useState)(Number(c.project?.lidar_epsg)),[Q,ee]=(0,h.useState)(x.lo.LineString),[et,ea]=(0,h.useState)({id:(0,sF.A)(),template:{task_data:[]}}),[er,es]=(0,h.useState)([]),el=(0,h.useRef)(null),ei=(0,h.useRef)(null),{generateBlobUrl:en,uploadFileToBlobStorage:eo,createBlobUploadingManager:ec}=sT(),ed=(0,ra.fR)(a)?"Submit":"Upload";(0,h.useEffect)(()=>{g(ra.SY.Draft),$(!1),ei.current=null,k(null),C(null),m(""),s.setDropFile(null),B("camera"),G(1),q(4326),ee(x.lo.LineString),Z({sensor_type:void 0,survey_accuracy:void 0,survey_units:x.ni.mm,pointcloud_accuracy:void 0,pointcloud_units:x.ni.mm,comment:void 0}),K(Number(c.project?.lidar_epsg))},[a]);let eu=async()=>{let t;if(!(0,aw.C1)(p,a,b,L,w,et.template,er.length>0)||!c.project)return;O(!0);let r=(0,aw.hh)({layerType:a,layerUrl:L,integrationFile:S,ifcCoordinates:z,featureType:Q,mapContext:l}),o={scope:a===rX.mb.ShapeFile&&R?ra.SY.Published:f,project_id:c.project.project_uuid,name:p,source:a,properties:r,enable_lrs:R,reference_date:I?I.toISOString():new Date().toISOString(),blob_urls:[],uuid:"",customFormFields:{template:et.template},...S&&{integration_file:S}};if(a===rX.mb.Tours){let e={csvFile:w,zipFile:b[0],tourName:p,cameraType:W,fileEpsg:X,metadata:Y,project:c.project,setAddingTourState:O,closeAddCustomLayerModal:()=>{},clearTourMetadata:()=>{},toursInProgress:new Map,setToursInProgress:()=>{}};await (0,r9.im)(e,i),d();return}if(await (0,aw.HT)({layerType:a,layerUrl:L,username:A,password:E,body:o,pushSubPage:u,setUploading:O}))try{(0,ra.Wl)(a)?(t=await (0,aw.hz)({layerType:a,refresh:!1,body:o}),d()):((0,ra.fR)(a)||(o.blob_urls=await ep()),t=await (0,aw.oB)({body:o}),(0,ra.fR)(a)&&(d(),y.Ay.success("Custom form created successfully"))),await (0,aw.k4)({layer:t,mapContext:l,layerContext:s,projectContext:c,layerType:a,refresh:!1,onFeatureClick:e,setAvailableRoutes:n.setAvailableRoutes,featureType:Q})}catch(e){"AbortError"===e.name?y.Ay.success("Successfully cancelled file upload."):(console.error(e),y.Ay.error(`Failed to upload file. ${e.message}`))}finally{O(!1)}},ep=async()=>
15{if(!c.project?.project_uuid)throw Error("No project found");let e=await (0,H.$z)(H.W_.readWriteDelete,c.project?.project_uuid),t=(0,sF.A)();el.current=new AbortController;let r=[],s=[],l=ec(b,el.current);for(let i of b){let n=en({file:i,uuid:t,layerType:a});r.push(n),s.push(eo({file:i,blobUrl:n,sasToken:e,onProgress:e=>{l(i.name,e)},abortController:el.current}))}return d(),await Promise.all(s),r};return(0,o.jsxs)("div",{className:"flex flex-col h-full justify-between",children:[(0,o.jsxs)("div",{className:"flex flex-col gap-4",children:[!(0,ra.OT)(a)&&(0,o.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,o.jsx)("span",{className:"label-text",children:a!==rX.mb.Tours?"Layer Name":"Tour Name"}),(0,o.jsx)("input",{type:"text",placeholder:a!==rX.mb.Tours?"Layer Name":"Tour Name",id:"add-layer-name-single","data-testid":"custom-layer-name-input",className:"input w-full tablet:w-auto",onChange:e=>m(String(e.target.value)),maxLength:50,value:p})]}),a!==rX.mb.Pointcloud&&a!==rX.mb.Tours&&(0,o.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,o.jsx)("span",{className:"label-text",children:"Upload Layer Scope"}),(0,o.jsxs)("select",{value:f,className:"select w-full tablet:w-auto",id:"upload-layer-scope-select",onChange:e=>g(e.target.value),disabled:a===rX.mb.ShapeFile&&R,children:[!(a===rX.mb.ShapeFile&&R)&&(0,o.jsx)("option",{value:ra.SY.Draft,children:"Draft"},0),(0,o.jsx)("option",{value:ra.SY.Published,children:"Published"},1)]})]}),(0,ra.Lg)(a)&&(0,o.jsx)(sN,{layerType:a,setIntegrationFile:k,setLidarIntegrationFile:C,setCustomLayerFiles:j,setLayerType:r,setTourCsvFile:N}),(0,ra.Wl)(a)&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,o.jsxs)("span",{className:"label-text",children:["Enter ",a==rX.mb.WMTS?"GetCapabilities":a," URL"]}),(0,o.jsx)("input",{type:"text",className:"text-black input w-full",placeholder:`${a} URL ${a==rX.mb.WMTS?"(.xml)":""}`,onChange:e=>{D(e.target.value.trim())},value:L})]}),rX.d8[a].supportAuth&&(0,o.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,o.jsx)("span",{className:"label-text",children:"Username"}),(0,o.jsx)("input",{type:"text",placeholder:"Username (optional)",className:"text-black input w-full",value:A,onChange:e=>M(e.target.value.trim())}),(0,o.jsx)("span",{className:"label-text mt-2",children:"Password"}),(0,o.jsx)("input",{type:"password",placeholder:"Password (optional)",className:"text-black input w-full",value:E,onChange:e=>T(e.target.value.trim())})]})]}),(0,ra.fR)(a)&&(0,o.jsx)(sW,{formBuilderData:et,setFormBuilderData:ea,featureType:Q,setFeatureType:ee,validationErrors:er,setValidationErrors:es}),(0,o.jsx)(sk,{layerType:a}),a===rX.mb.ShapeFile&&(0,o.jsx)(s_,{enableLRS:R,setEnableLRS:e=>{let t="function"==typeof e?e(R):e;a===rX.mb.ShapeFile&&(t?f===ra.SY.Draft&&(ei.current=f,g(ra.SY.Published)):ei.current&&(g(ei.current),ei.current=null)),$(t)}}),a===rX.mb.IFC&&(0,o.jsx)(sC,{ifcCoordinates:z,setIfcCoordinates:U}),a===rX.mb.Tours&&(0,o.jsx)(sD,{cameraType:W,setCameraType:B,cameraNum:V,setCameraNum:G,cameraFileEpsg:J,setCameraFileEpsg:q,tourMetadata:Y,setTourMetadata:Z}),a!==rX.mb.Tours&&(0,o.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,o.jsx)("span",{className:"label-text",children:"Reference Date"}),(0,o.jsx)("input",{type:"datetime-local",className:"input w-full tablet:w-auto",value:(0,v.rm)(I),onChange:e=>{let t=new Date(e.target.value);isNaN(t.getTime())?console.error("Invalid date input"):P(t)}})]}),a===rX.mb.Pointcloud&&(0,o.jsx)(sA,{layerType:a,fileEpsg:X,setFileEpsg:K,pointcloudMetadata:Y,setPointcloudMetadata:Z})]}),a!==rX.mb.Pointcloud?(0,o.jsx)("div",{className:`pb-6 tablet:${a===rX.mb.Tours||a===rX.mb.ShapeFile?"pb-4":"pb-0"}`,children:(0,o.jsx)("button",{className:"btn tt-blue-button text-white mt-2 w-full","data-testid":"custom-layer-submit-button",disabled:F,onClick:eu,children:F?(0,o.jsx)("span",{className:"loading loading-spinner loading-sm"}):ed})}):(0,o.jsx)(sI,{name:p,date:I,file:b?b[0]:null,fileEpsg:X,integrationFile:_,refreshLidarList:()=>{t(),d()},metadata:Y})]})},sV=(e,t)=>1===t?"":e[t-2];async function sG(e,t,a){try{return await (0,_.x)("/fusioncloud/uploads",{params:{container_name:e,prefix:t,continuation_token:a}})}catch(e){return console.error("Failed to get list of blobs:",e),{items:[],continuationToken:""}}}async function sJ({batchName:e,selectedFiles:t,selectedFolders:a,csvString:r,projectId:s}){await (0,_.x)("/fusioncloud/batch-lidars",{method:"POST",json:{batch_name:e+"_"+new Date().toISOString(),selected_files:[...t],selected_folders:[...a],storage_url:m.oj,csv_string:r,project_id:s}})}async function sq(e,t,a,r){try{return await (0,_.x)("/fusioncloud/uploads/continuation-tokens",{params:{container_name:e,prefix:t,limit:a,continuation_token:r}})}catch(e){return console.error("Failed to get list of blobs:",e),{items:[],continuationTokens:[]}}}async function sY(e){return(0,_.x)("/fusioncloud/lidar-batches",{params:{project_id:e}})}async function sH(e){return(0,_.x)(`/fusioncloud/batch-lidars/${encodeURIComponent(e)}/attempts`,{method:"POST"})}let sZ="uploads/";function sX({item:e,enterFolder:t,checkboxesDisabled:a,selectedFolders:r,selectedFiles:s,validExtensions:l,onCheckboxChangeFolder:i,onCheckboxChangeFile:n,currentPrefix:c}){return(0,o.jsxs)("tr",{className:"cursor-pointer hover:bg-base-300 border-b border-gray-300",onClick:()=>"folder"===e.type&&t(e.name),children:[(0,o.jsxs)("td",{onClick:e=>e.stopPropagation(),className:"text-center border-r border-b border-gray-300",children:["folder"===e.type&&(0,o.jsx)("input",{type:"checkbox",disabled:a,checked:a||r.has(e.name),className:"checkbox checkbox-sm",onChange:t=>i(e.name,t.target.checked)}),"file"===e.type&&(0,o.jsx)("input",{type:"checkbox",disabled:a||!l.some(t=>e.name.endsWith(t)),checked:(a||s.has(e.name))&&l.some(t=>e.name.endsWith(t)),className:"checkbox checkbox-sm",onChange:t=>n(e.name,t.target.checked)})]}),(0,o.jsx)("td",{className:"border-r border-b border-gray-300",children:(0,o.jsxs)("div",{className:"flex items-center gap-2",children:["folder"===e.type?(0,o.jsx)(eK.U
15DU,{className:"text-blue-500"}):(0,o.jsx)(eK.QuH,{className:"text-gray-500"}),(0,o.jsx)("span",{className:"truncate",children:e.name.replace(c,"")})]})}),(0,o.jsx)("td",{className:"border-b border-gray-300 capitalize",children:e.type})]},e.name)}function sK({initialSelectedFiles:e,initialSelectedFolders:t,validExtensions:a,onSave:r}){let s="uploads/",l=((e=eB.Yp)=>{let[t,a]=(0,h.useState)(!1);return(0,h.useEffect)(()=>{let t=()=>{a(window.innerWidth<=e)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[e]),t})(),{items:i,loading:n,currentPrefix:c,prefixStack:d,redoStack:u,searchQuery:p,setSearchQuery:m,currentPage:x,continuationTokens:f,goToPage:g,goBack:y,goForward:b,enterFolder:j,goUpOneFolder:w,goToPrefix:v,getBreadcrumbParts:N,populateContinuationTokens:S}=function(){let e=(0,ev.O)(),[t,a]=(0,h.useState)([]),[r,s]=(0,h.useState)(!1),[l,i]=(0,h.useState)([sZ]),[n,o]=(0,h.useState)([]),[c,d]=(0,h.useState)(""),[u,p]=(0,h.useState)(""),[m,x]=(0,h.useState)(1),[f,g]=(0,h.useState)([""]),y=(0,h.useRef)(f),b=l[l.length-1];async function j(t,r){if(e.project?.container_name){s(!0);try{let s=b.replace(sZ,""),l=await sG(e.project.container_name,s+u,t);if(a(l.items||[]),!sV(y.current,r+1)){let e=[...y.current];e[r+1-2]=l.continuationToken,y.current=e,g(e)}}finally{s(!1)}}}async function w(){if(!e.project?.container_name)return;let t=y.current;if(""!==t[t.length-1]){s(!0);try{let a=b.replace(sZ,""),r=await sq(e.project.container_name,a+u,100,t[t.length-1]),s=[...t,...r.continuationTokens];y.current=s,g(s)}finally{s(!1)}}}return(0,h.useEffect)(()=>{y.current=f},[f]),(0,h.useEffect)(()=>{let e=setTimeout(()=>p(c),300);return()=>clearTimeout(e)},[c]),(0,h.useEffect)(()=>{!async function(){let e=[""];x(1),y.current=e,g(e),await j("",1),w()}()},[b,u]),{items:t,loading:r,currentPrefix:b,prefixStack:l,redoStack:n,searchQuery:c,setSearchQuery:d,currentPage:m,continuationTokens:f,goToPage:async function e(e){await j(sV(y.current,e),e),x(e)},goBack:function(){l.length>1&&(o(e=>[l[l.length-1],...e]),i(e=>e.slice(0,-1)))},goForward:function(){if(n.length>0){let[e,...t]=n;i(t=>[...t,e]),o(t)}},enterFolder:function(e){i(t=>[...t,e]),o([])},goUpOneFolder:function(){let e=l[l.length-1].split("/").filter(Boolean);if(e.length>1){let t=e.slice(0,-1).join("/")+"/";i(e=>[...e,t]),o([])}},goToPrefix:function(e){e!==b&&(i(t=>[...t,e]),o([]))},getBreadcrumbParts:function(){let e=b.replace(sZ,"").split("/").filter(Boolean),t=[],a=sZ;for(let r of(t.push({name:"uploads",fullPrefix:sZ}),e))a+=r+"/",t.push({name:r,fullPrefix:a});return t},populateContinuationTokens:w}}(),[k,_]=(0,h.useState)(!1),[C,L]=(0,h.useState)(e),[D,A]=(0,h.useState)(t);function M(e,t){L(a=>{let r=new Set(a);return t?r.add(e):r.delete(e),r})}function E(e,t){A(a=>{let r=t?new Set:new Set(a);if(t){for(let t of a)t.startsWith(e)||r.add(t);r.add(e)}else r.delete(e);return r}),t&&L(t=>{let a=new Set;for(let r of t)r.startsWith(e)||a.add(r);return a})}return(0,h.useEffect)(()=>{_(()=>{for(let e of D)if(c.startsWith(e))return!0;return!1})},[c]),(0,o.jsxs)("div",{className:"flex flex-col w-full h-[89%]",children:[(0,o.jsxs)("div",{className:`flex flex-wrap items-center justify-between ${!l&&"px-6"} py-4 bg-white text-black`,children:[(0,o.jsxs)("div",{className:"flex flex-row items-center gap-4",children:[(0,o.jsx)("button",{onClick:y,disabled:d.length<=1,className:`${d.length>1?"hover:text-blue-600 cursor-pointer":"opacity-50"}`,title:"Back",children:(0,o.jsx)(ek.K9R,{size:24})}),(0,o.jsx)("button",{onClick:b,disabled:0===u.length,className:`${u.length>0?"hover:text-blue-600 cursor-pointer":"opacity-50"}`,title:"Forward",children:(0,o.jsx)(ek.eLu,{size:24})}),(0,o.jsx)("button",{onClick:w,disabled:c===s,className:`${c!==s?"hover:text-blue-600 cursor-pointer":"opacity-50"}`,title:"Go Up One Folder",children:(0,o.jsx)(ek.eyc,{size:24})})]}),(0,o.jsxs)("label",{className:"input input-sm mt-2",children:[(0,o.jsx)($.iyI,{size:16,color:"grey"}),(0,o.jsx)("input",{type:"search",required:!0,placeholder:"Prefix Search",value:p,onChange:e=>m(e.target.value)})]})]}),(0,o.jsx)("div",{className:`${!l&&"px-6"}`,children:(0,o.jsx)("div",{className:"breadcrumbs text-sm text-gray-600 w-full",children:(0,o.jsx)("ul",{className:"flex flex-wrap gap-0",children:N().map(e=>(0,o.jsx)("li",{children:e.fullPrefix===c?(0,o.jsx)("span",{className:"font-semibold text-black cursor-default",children:e.name}):(0,o.jsx)("button",{onClick:()=>v(e.fullPrefix),className:"text-blue-600 hover:underline",children:e.name})},e.fullPrefix))})})}),(0,o.jsx)("hr",{className:`border-t border-gray-200 my-0 ${!l&&"mx-6"}`}),(0,o.jsx)("div",{className:`${!l&&"px-6"} py-6 bg-white text-black rounded flex-1 flex flex-col overflow-hidden`,children:(0,o.jsx)("div",{className:"overflow-x-auto flex-1 pb-2 pt-0",children:(0,o.jsxs)("div",{className:"flex flex-col justify-between gap-4 w-full h-full",children:[(0,o.jsx)("div",{className:"h-full w-full overflow-y-auto overflow-x-auto border border-gray-300 rounded",children:(0,o.jsxs)("table",{className:"table table-pin-rows w-full border-collapse","data-testid":"batch-item-table",children:[(0,o.jsx)("thead",{children:(0,o.jsxs)("tr",{className:"text-base-content bg-base-200",children:[(0,o.jsx)("th",{className:"w-1/10 text-center border-r border-b border-gray-300",children:"Selected"}),(0,o.jsx)("th",{className:"w-7/10 border-r border-b border-gray-300",children:"Name"}),(0,o.jsx)("th",{className:"w-2/10 border-b border-gray-300",children:"Type"})]})}),(0,o.jsx)("tbody",{children:n?(0,o.jsx)("tr",{children:(0,o.jsx)("td",{colSpan:3,children:(0,o.jsx)("div",{className:"flex justify-center items-center py-6",children:(0,o.jsx)("div",{className:"loading loading-spinner"})})})}):0===i.length?(0,o.jsx)("tr",{children:(0,o.jsx)("td",{colSpan:3,className:"text-center text-gray-500 py-4",children:"FusionCloud is currently under development. Please check back later."})}):i.map(e=>(0,o.jsx)(sX,{item:e,enterFolder:j,checkboxesDisabled:k,selectedFolders:D,selectedFiles:C,validExtensions:a,onCheckboxChangeFolder:E,onCheckboxChangeFile:M,currentPrefix:c},e.name))})]})}),(0,o.jsxs)("div",{className:"flex w-full justify-between items-center flex-wrap",children:[(0,o.jsx)("div",{className:"w-full xs:w-1/3"}),(0,o.jsx)("div",{className:"w-full xs:w-1/3 flex justify-center",children:(0,o.jsxs)("div",{className:"join",children:[(0,o.jsx)("button",{disabled:n||1===x,className:"join-item btn btn-sm",onClick:()=>g(1),children:(0,o.jsx)(z.U6K,{})}),(0,o.jsx)("button",{disabled:n||1===x,className:"join-item btn btn-sm",onClick:()=>g(x-1),children:(0,o.jsx)(z.pyl,{})}
15),1===f.length&&""===f[0]?(0,o.jsx)("div",{tabIndex:-1,className:"join-item btn btn-sm btn-disabled",children:x}):(0,o.jsxs)("div",{className:"dropdown dropdown-top",children:[(0,o.jsx)("div",{tabIndex:0,role:"button",className:"join-item btn btn-sm",children:x}),(0,o.jsxs)("ul",{tabIndex:0,className:"dropdown-content menu p-2 shadow bg-white rounded-box max-h-52 overflow-y-auto w-max min-w-[3rem]",style:{display:"flex",flexDirection:"column",flexWrap:"nowrap"},children:[["",...f.slice(0,-1)].map((e,t)=>(0,o.jsx)("li",{children:t+1===x?(0,o.jsx)("a",{className:"cursor-default opacity-50 pointer-events-none",children:t+1}):(0,o.jsx)("a",{onClick:()=>g(t+1),children:t+1})},t)),(0,o.jsx)("li",{children:n?(0,o.jsx)("a",{className:"cursor-default opacity-50 pointer-events-none",children:"Loading..."}):""!==f[f.length-1]&&(0,o.jsx)("a",{onClick:()=>S(),children:"Load More"})})]})]}),(0,o.jsx)("button",{disabled:n||""===f[x+1-2],className:"join-item btn btn-sm",onClick:()=>g(x+1),children:(0,o.jsx)(z.mf,{})}),(0,o.jsx)("button",{disabled:n||x===f.length,className:"join-item btn btn-sm",onClick:()=>g(f.length),children:(0,o.jsx)(z.b0J,{})})]})}),(0,o.jsx)("div",{className:"w-full xs:w-1/3 flex justify-end pr-1",children:(0,o.jsx)("button",{className:"btn tt-blue-button",onClick:()=>r(C,D),"data-testid":"save-FusionCloud-button",children:"Save"})})]})]})})})]})}let sQ=function({label:e,items:t,setter:a}){return 0===t.size?null:(0,o.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,o.jsx)("span",{className:"label-text",children:e}),Array.from(t).map(e=>(0,o.jsxs)("div",{className:"file-uploader-metadata flex w-full items-center justify-between","data-testid":`file-item-${e}`,children:[(0,o.jsx)("span",{title:e,className:"truncate",children:e}),(0,o.jsx)(W.fUT,{className:"file-uploader-delete",onClick:()=>a(t=>{let a=new Set(t);return a.delete(e),a}),"data-testid":`delete-item-button-${e}`})]},e))]})},s0=function({refreshLidarList:e}){let t=(0,ev.O)().project,a=(0,e$.p)().goBack,r=(0,ev.O)(),[s,l]=(0,h.useState)(""),[i,n]=(0,h.useState)(!1),[c,u]=(0,h.useState)(null),[p,x]=(0,h.useState)(new Set),[f,g]=(0,h.useState)(new Set),[b,j]=(0,h.useState)(!1),[w,N]=(0,h.useState)(!1),S=(0,h.useRef)(null),[k,_]=(0,h.useState)(void 0),C=()=>{j(!1),_(void 0)},L=async()=>{if(!r.project?.project_uuid)throw Error("No Project found");N(!0);try{let e=await (0,H.$z)(H.W_.listWrite,r.project?.project_uuid,86400);_(e)}catch(e){y.Ay.error(e.message)}finally{N(!1)}};async function D(){if(!s)return void y.Ay.error("Please enter a batch name.");if(0===p.size&&0===f.size)return void y.Ay.error("Please select at least one file or folder.");if(!r.project)return void y.Ay.error("Project connection is not established.");n(!0);try{if(!t?.project_uuid)throw Error("Project not found");await sJ({batchName:s,selectedFiles:p,selectedFolders:f,csvString:c?await c.text():void 0,projectId:t?.project_uuid}),y.Ay.success("Batch lidars uploaded successfully."),e(),a()}catch(e){console.error("Error uploading batch lidar:",e),y.Ay.error(e.message)}finally{n(!1)}}return(0,h.useEffect)(()=>{let e=S.current;if(e)return b?e.showModal():e.close(),e.addEventListener("close",C),()=>{e.removeEventListener("close",C)}},[b]),(0,o.jsx)("div",{className:"flex flex-col h-full justify-between",children:(0,o.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,o.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,o.jsx)("span",{className:"label-text",children:"Batch Name"}),(0,o.jsx)("input",{type:"text",placeholder:"Batch Name",id:"batch-add-layer-name",className:"input w-full tablet:w-auto",onChange:e=>l(e.target.value),maxLength:50,value:s,"data-testid":"batch-name-input"})]}),(0,o.jsx)("div",{className:"sharepoint-button","data-testid":"open-FusionCloud-button",onClick:()=>j(!0),children:(0,o.jsxs)("div",{className:"flex items-center gap-2 h-5",children:[(0,o.jsx)(d(),{src:"/images/fusioncloud.svg",alt:"SharePoint Icon",width:40,height:40}),"Select from FusionCloud ",(0,o.jsx)("div",{className:"beta-tag ml-2",children:"BETA"})]})}),(0,o.jsx)("dialog",{ref:S,id:"fusioncloud-file-select",className:"modal",children:(0,o.jsxs)("div",{className:"modal-box w-full tablet:min-w-[1200px] h-[700px]",children:[(0,o.jsxs)("div",{className:"flex flex-row justify-between items-center",children:[(0,o.jsxs)("span",{className:"font-bold text-lg flex flex-row items-center gap-3",children:[(0,o.jsx)(d(),{src:"/images/fusioncloud.svg",alt:"SharePoint Icon",width:40,height:40})," Select from FusionCloud"]}),(0,o.jsxs)("div",{className:"flex flex-row gap-4 items-center",children:[k&&r.project?(0,o.jsxs)("div",{className:"relative w-full",children:[(0,o.jsx)("input",{type:"text",className:"input  text-black text-sm w-full pr-14",value:`${m.oj}${r.project?.container_name}/?${k}`,readOnly:!0}),(0,o.jsx)("button",{className:"absolute inset-y-0 right-0 z-50 flex items-center justify-center btn btn-sm btn-ghost text-grey-500 m-1",onClick:()=>{navigator.clipboard.writeText(`${m.oj}${r.project?.container_name}/?${k}`),y.Ay.success("SAS URL copied to clipboard")},children:(0,o.jsx)(em.SD3,{})})]}):w?(0,o.jsx)("button",{className:"btn w-24",children:(0,o.jsx)("span",{className:"loading loading-spinner"})}):(0,o.jsx)("button",{onClick:L,className:"btn w-24",children:"Get SAS"}),(0,o.jsx)("label",{onClick:()=>S.current?.close(),htmlFor:"my_modal_7",className:"btn btn-sm btn-circle btn-ghost",children:"✕"})]})]}),(0,o.jsx)("div",{className:"text-lg font-bold flex items-center border-b border-black/10 pb-3 justify-between"}),b&&(0,o.jsx)(sK,{initialSelectedFiles:p,initialSelectedFolders:f,validExtensions:rX.d8[rX.mb.Pointcloud].fileAccept||[],onSave:(e,t)=>
15{x(e),g(t),j(!1)}})]})}),c?(0,o.jsxs)("div",{className:"file-uploader-metadata w-full flex justify-between items-center",children:[(0,o.jsx)("span",{title:c?.name,className:"truncate",children:c?.name}),(0,o.jsx)(W.fUT,{className:"file-uploader-delete",onClick:()=>u(null)})]}):(0,o.jsx)(eL.l,{types:["csv"],multiple:!1,handleChange:e=>{if(e){if(e.size>rX.c3)return void y.Ay.error(`File size exceeds the limit of ${(0,v.z3)(rX.c3)}. Please upload a supported file size.`);u(e)}},name:"file",classes:"file-uploader",children:(0,o.jsxs)("div",{className:"file-uploader-box",children:[(0,o.jsx)(W.v4w,{size:18,className:"flex text-black/50"}),(0,o.jsx)("span",{className:"text-black/50 mt-1",children:"(Optional) Upload Batch CSV File (.csv)"}),(0,o.jsxs)("span",{className:"text-black/50",children:["Max: ",(0,v.z3)(rX.c3)]})]})}),!b&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(sQ,{label:"Selected Files",items:p,setter:x}),(0,o.jsx)(sQ,{label:"Selected Folders",items:f,setter:g})]}),(0,o.jsxs)("div",{className:"rounded-md bg-tt-blue/10 opacity-70 w-full p-3 flex items-start gap-3 mt-1 mb-2 text-sm",children:[(0,o.jsx)(e0.z5h,{size:20,className:"mt-0.5 shrink-0"}),(0,o.jsx)("div",{className:"space-y-3",children:(0,o.jsxs)("p",{children:["Click ",(0,o.jsx)("a",{href:"https://fusionmap.com/knowledge-base/pointcloud-workflows/upload-a-batch-of-pointclouds/",className:"underline",target:"_blank",rel:"noopener noreferrer",children:"here"})," to learn more about FusionCloud and find instructions on how to upload Pointcloud files."]})})]}),(0,o.jsx)("div",{className:"pb-6 tablet:pb-4",children:(0,o.jsx)("button",{className:"btn tt-blue-button text-white w-full",disabled:i,onClick:D,"data-testid":"start-batch-upload-button",children:i?(0,o.jsx)("span",{className:"loading loading-spinner loading-sm"}):"Start Batch"})})]})})};function s1({onFeatureClick:e,refreshLidarList:t}){let[a,r]=(0,h.useState)(rX.mb.GeoJSON),[s,l]=(0,h.useState)("Single");return(0,ex.u)(),(0,o.jsxs)("div",{className:"flex flex-col h-full max-h-screen",children:[(0,o.jsxs)("div",{className:"flex flex-col gap-2 mb-4",children:[(0,o.jsx)("span",{className:"label-text",children:"Layer Type"}),(0,o.jsx)("select",{value:a,className:"select w-full tablet:w-auto",id:"layer-type-select","data-testid":"custom-layer-select",onChange:e=>{r(e.target.value)},children:(0,ra.np)().map(e=>(0,o.jsx)("option",{value:e,children:ra.aM[e]},e))})]}),a===rX.mb.Pointcloud?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:"tabs tabs-lift w-full mb-4",children:[(0,o.jsx)("label",{className:`tab flex-1 ${"Single"===s?"tab-active !border-gray-100 !border-l-2 !border-r-2 !border-t-2":"bg-gray-100"}`,style:{color:"black"},onClick:()=>l("Single"),children:"Single"}),(0,o.jsx)("label",{className:`tab flex-1 ${"Batch"===s?"tab-active !border-gray-100 !border-l-2 !border-r-2 !border-t-2":"bg-gray-100"}`,style:{color:"black"},onClick:()=>l("Batch"),"data-testid":"batch-button",children:"Batch"})]}),"Single"===s?(0,o.jsx)(sB,{onFeatureClick:e,refreshLidarList:t,layerType:a,setLayerType:r}):(0,o.jsx)(s0,{refreshLidarList:t})]}):(0,o.jsx)(sB,{onFeatureClick:e,refreshLidarList:t,layerType:a,setLayerType:r})]})}function s2({setShowEditModelMenu:e,setBottomMenuOpen:t,onFeatureClick:a}){let r=(0,ex.u)(),s=(0,aO.h)(),l=(0,ev.O)(),i=(0,eG.JY)(),n=(0,eV.H)(),c=(0,eN.D)(),d=(0,h.useRef)(null),u=(0,eD.l)(),[p,m]=(0,h.useState)("Custom Layers"),[f,g]=(0,h.useState)(new Map),[b,j]=(0,h.useState)(new Map),{setSidePanelActionButtons:w,pushSubPage:v,goBack:N}=(0,e$.p)();(0,h.useEffect)(()=>(w((0,o.jsx)("button",{className:"btn btn-sm","data-testid":"add-layer-button",onClick:()=>v((0,o.jsx)(s1,{onFeatureClick:a,refreshLidarList:()=>c.setRefreshLidars(e=>e+1)}),{title:"Add Custom Layer"}),children:(0,o.jsx)(eK.GGD,{size:22})})),()=>w(null)),[w]);let S=async()=>{l.project&&g(await (0,av.l6)(l.project.project_uuid))};(0,h.useEffect)(()=>{r&&(async()=>{try{await S();let e=await (0,av.en)(l.project?.project_uuid);e.forEach(e=>{e.id=e.id.toString()+"-layer"}),n.setCustomLayers(e)}catch{y.Ay.error("Error fetching tours or layers")}})().catch(()=>y.Ay.error("Failed to load layers"))},[r]),(0,h.useEffect)(()=>(r&&c.allLidars.length>0&&k(),()=>{d.current&&(clearInterval(d.current),d.current=null)}),[r,c.allLidars]),(0,h.useEffect)(()=>{n.dropFile&&(N(),setTimeout(()=>{v((0,o.jsx)(s1,{onFeatureClick:a,refreshLidarList:()=>c.setRefreshLidars(e=>e+1)}),{title:"Add Custom Layer"})},200))},[n.dropFile]),(0,h.useEffect)(()=>{let e=new Map;
15n.uploadingTours&&n.uploadingTours.forEach(async t=>{let a=JSON.parse(t.data);t.status===x.Dr.complete?(await (0,r9.N6)(l.project,t.uuid,a.tourName,a.epsg,a.cameraType,S,u),await (0,r9.tj)(i.map,l.project,l.setProject,a.cameraType,r6.HW,s.showCameraX,s.setShowCameraX)):t.status===x.Dr.error?u.uploadings.map(e=>e.id).includes(t.uuid)?u.updateUploading(t.uuid,{progress:100,status:x.nW.error,onErrorClose:async()=>{await (0,r9.B0)(t.uuid,t.data)}}):u.addUploading({title:a.tourName,type:x.dP.tour,id:t.uuid,progress:100,status:x.nW.error,layerStatus:x.iO.processing,onErrorClose:async()=>{await (0,r9.B0)(t.uuid,t.data)}}):(t.status===x.Dr.in_progress||t.status===x.Dr.tour_indexing)&&e.set(t.uuid,a.tourName)}),j(e)},[n.uploadingTours]);let k=async()=>{d.current||(d.current=setInterval(async()=>{let e=c.allLidars.filter(e=>e.properties.status===x.nW.processing);if(0===e.length){d.current&&clearInterval(d.current),d.current=null;return}let t=!1;for(let a of e){let e=await (0,sj.MU)(a.uuid);e!==x.nW.processing&&(u.updateUploading(a.uuid,{status:e}),t=!0)}t&&c.setRefreshLidars(e=>e+1)},15e3))};return(0,o.jsxs)("div",{className:"flex flex-col h-full",children:[(0,o.jsx)("div",{className:"z-50 h-[50px] shrink-0 mb-2",children:(0,o.jsx)(eJ,{groupName:"layer-selection-tabs",tabs:[{value:"Base Layers",label:"Basemap"},{value:"Premium Layers",label:"Premium"},{value:"Custom Layers",label:"Layers"}],selectedValue:p,onSelect:e=>{m(e)}})}),"Base Layers"===p&&(0,o.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,o.jsx)(sv,{})}),"Premium Layers"===p&&(0,o.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col",children:(0,o.jsx)(rt,{})}),"Custom Layers"===p&&(0,o.jsx)("div",{className:"flex-1 overflow-y-auto modal-scrollbar",children:(0,o.jsx)(sb,{setShowEditModelMenu:e,setBottomMenuOpen:t,onFeatureClick:a,tours:f,refreshTourList:S,toursInProgress:b})})]})}var s5=((l={}).ZOOM_CHANGED="ZOOMED_OUT",l.CHANGED_TO_SENTINEL="CHENGE_TO_SENTINEL",l);function s3({progress:e,onTriggerWalkthrough:t}){let a=(0,ev.O)();return((0,h.useEffect)(()=>{e.value>0||"true"===localStorage.getItem("first_time_user")&&t()},[e]),e.value>=100)?null:(0,o.jsxs)("div",{className:"absolute flex flex-col items-center justify-center w-full h-full bg-black/70 backdrop-blur-sm",style:{zIndex:1e4},"data-testid":"splash-screen",children:[a.projectImageUrl&&(0,o.jsx)(d(),{src:a.projectImageUrl,alt:"Company Logo",width:240,height:76,className:"opacity-95 object-contain"}),(0,o.jsxs)("div",{className:"flex items-center justify-center flex-col mt-5",children:[(0,o.jsx)("div",{className:"relative bg-gray-200/50 w-[200px]",children:(0,o.jsx)("div",{className:"transition-all text-center h-1 bg-tt-blue",style:{width:`${e.value}%`}})}),(0,o.jsxs)("div",{className:"text-[13px] mt-3 opacity-70 flex gap-2 items-center",children:[(0,o.jsx)("span",{className:"loading loading-xs loading-spinner text-white"}),(0,o.jsxs)("span",{children:[e.text," (",e.value,"%)"]})]})]})]})}function s4({showLidar:e,fetchAvailableLidars:t}){let a=(0,eG.JY)(),r=(0,ef.N)(),s=(0,eg.ZM)(),l=(0,ew.u)(),i=(0,eN.D)(),n=(0,aO.h)(),c=(0,ev.O)(),{getModalState:u,toggleModal:p,closeModal:m}=(0,tZ.O)(),[f,g]=(0,h.useState)(!1);return(0,h.useEffect)(()=>{if(!c.project?.data_types?.includes("lidar")||!i.availableLidars||0===i.availableLidars.length)return;g(!1);let e=setTimeout(()=>g(!0),10),t=setTimeout(()=>g(!1),1010);return()=>{clearTimeout(e),clearTimeout(t)}},[i.availableLidars,c.project?.data_types]),(0,h.useEffect)(()=>{if(c.project&&c.project.data_types){for(let e=0;e<c.project.data_types.length;e++)if(c.project.data_types[e].includes("camera")){let t=c.project.data_types[e];n.setShowCameraX(e=>({...e,[t]:!1}))}}},[c.project]),(0,o.jsxs)("div",{className:"mapbox-left-menu",children:[c.project?.data_types?.includes("lidar")&&i.availableLidars&&i.availableLidars.length>0&&(0,o.jsx)("div",{className:`tooltip tooltip-right ${f?"pulse-button-appear":""}`,"data-tip":"Pointclouds",children:(0,o.jsx)("button",{onClick:()=>{u(x.dW.LidarModal).display?(m(x.dW.LidarModal),(0,aR.jo)(a.map,null),i.lidarPositionMarkerRef.current?.remove(),i.lidarPositionMarkerRef.current=null):t().then(e)},"data-tooltip-id":"lidar-tooltip","data-tooltip-content":"Lidar",className:"mapbox-left-menu-btn cursor-pointer",children:(0,o.jsx)(W.SqY,{size:20,color:u(x.dW.LidarModal).display?"#2563eb":"#000"})})}),n.isPanoAvailable&&c.project?.data_types?.includes("pano")&&(0,o.jsx)("div",{className:"tooltip tooltip-right","data-tip":"Hybrid view",children:(0,o.jsx)("button",{onClick:()=>{p(x.dW.HybridViewModal)},"data-tooltip-id":"measurements-tt","data-tooltip-content":"Hybrid View",className:"mapbox-left-menu-btn cursor-pointer",children:(0,o.jsx)(z.z5U,{size:20,color:u(x.dW.HybridViewModal).display?"#2563eb":"#000"})})}),c.project?.features&&c.project?.features?.includes("eagleview")&&(0,o.jsx)("div",{className:"tooltip tooltip-right","data-tip":"Eagle View",children:(0,o.jsx)("button",{onClick:()=>{p(x.dW.EagleVueModal)},"data-tooltip-id":"eaglevue-tt","data-tooltip-content":"Eagle View",className:"mapbox-left-menu-btn cursor-pointer",children:(0,o.jsx)(ep.dOF,{size:20,color:u(x.dW.EagleVueModal).display?"#2563eb":"#000"})})}),c.project?.feature_flags.fusionlens&&(0,o.jsx)("div",{className:"tooltip tooltip-right","data-tip":"FusionLens",children:(0,o.jsx)("button",{onClick:()=>{p(x.dW.DashboardModal)},"data-tooltip-id":"dashboard-tt","data-tooltip-content":"FusionLens",className:"mapbox-left-menu-btn",children:(0,o.jsx)(ep.RdN,{size:20,color:u(x.dW.DashboardModal).display?"#2563eb":"#000"})})}),(0,v.M5)(n.showCameraX,n.setShowCameraX),(0,o.jsx)("div",{className:"tooltip tooltip-right","data-tip":"Notes",children:(0,o.jsxs)("button",{onClick:()=>{p(x.dW.NotesModal)},"data-tooltip-id":"notes-tt","data-tooltip-content":"Notes",className:"mapbox-left-menu-btn cursor-pointer",children:[(0,o.jsx)(W.R7b,{size:20,color:u(x.dW.NotesModal).display?"#2563eb":"#000"}),r.noteUnreadCount>0&&(0,o.jsx)("div",{className:"badge absolute badge-xs border-none bg-red-400 shadow rounded-lg h-5 w-auto min-w-[18px] ml-8 mb-8 text-[12px] font-semibold text-white",children:r.noteUnreadCount})]})}),(0,o.jsx)("div",{className:"tooltip tooltip-right","data-tip":"Alerts",children:(0,o.jsxs)("button",{onClick:()=>{p(x.dW.AlertsModal)},"data-tooltip-id":"alerts-tt","data-tooltip-content":"Alerts","data-testid":"alerts-modal-btn",className:"mapbox-left-menu-btn cursor-pointer",children:[(0,o.jsx)(W.PAG,{size:20,color:u(x.dW.AlertsModal).display?"#2563eb":"#000"}),s.alertUnreadCount>0&&(0,o.jsx)("div",{className:"badge absolute badge-xs border-none bg-red-400 shadow rounded-lg h-5 w-auto min-w-[18px] ml-8 mb-9 text-[12px] font-semibold text-white",children:s.alertUnreadCount})]})}),l.availableRoutes&&0!==l.availableRoutes.length&&(0,o.jsx)("div",{className:"relative",children:(0,o.jsx)("button",{onClick:()=>
15{p(x.dW.LRSModal)},className:"mapbox-left-menu-btn tooltip tooltip-right cursor-pointer","data-tip":"LRS",id:"lrs-button",children:(0,o.jsx)(d(),{src:"/images/LRSIcon.svg",alt:"LRS Icon",width:140,height:140,className:"opacity-95 object-contain w-[20px] h-[20px]"})})})]})}var s8=a(68435),s6=((i={}).TOP="top",i.MIDDLE="middle",i.BOTTOM="bottom",i);function s7({HiddenButtonsContent:e,MainButtonContent:t,position:a}){let r,[s,l]=(0,h.useState)(!1),[i,n]=(0,h.useState)(!1),[c,d]=(0,h.useState)(!1);return(0,o.jsxs)("div",{className:"flex align-center relative group",onMouseEnter:()=>{s||setTimeout(()=>l(!0),200)},onMouseLeave:()=>{i||l(!1)},children:[(0,o.jsx)("div",{className:(()=>{let e="flex align-center absolute right-[29px] p-[10px] transition-all duration-200";if(i)return`${e} opacity-100 translate-x-0`;let t=c?"":`
16            [@media(hover:hover)]:group-hover:opacity-100
17            [@media(hover:hover)]:group-hover:translate-x-0
18            [@media(hover:hover)]:group-hover:pointer-events-auto
19        `;return`${e} opacity-0 translate-x-6 pointer-events-none ${t}`})(),children:e({areButtonsShown:s})}),(0,o.jsx)("button",{className:(r="transition-colors duration-200",i?`${r} bg-black/5`:`${r} bg-white [@media(hover:hover)]:group-hover:bg-black/5`),style:(()=>{let e={width:"30px",height:"29px",display:"flex",justifyContent:"center",alignItems:"center"};switch(a){case"top":return{...e,borderBottom:"1px solid lightgray",borderRadius:"4px 4px 0 0"};case"bottom":return{...e,borderTop:"1px solid lightgray",borderRadius:"0 0 4px 4px"};default:return{...e,borderTop:"1px solid lightgray",borderBottom:"1px solid lightgray"}}})(),onClick:()=>{n(!i),i?l(!1):setTimeout(()=>l(!0),200),d(!0)},onMouseLeave:()=>c&&d(!1),children:t})]})}var s9=a(3866),le=a(15055);async function lt(e,t,a){if(!a)throw Error("Project name not found");if(!e)throw Error("PNG data URL not found");let r=await s9.PDFDocument.create(),s=await r.embedFont(s9.StandardFonts.Helvetica),l=Uint8Array.from(atob(e.split(",")[1]),e=>e.charCodeAt(0)),i=await r.embedPng(l),n=r.addPage([792,612]);n.drawText("Generated: "+new Date().toLocaleString(void 0,{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!0}),{x:25,y:562,size:12,font:s,color:(0,s9.rgb)(.3,.3,.3)}),n.drawText("Project: "+a,{x:25,y:542,size:12,font:s,color:(0,s9.rgb)(.3,.3,.3)});let o=i.width,c=i.height,d=Math.min(742/o,512/c,1),u=(792-(o*=d))/2,p=612-(c*=d)-50-35;n.drawImage(i,{x:u,y:p,width:o,height:c});let m=new Blob([new Uint8Array(await r.save())],{type:"application/pdf"}),h=URL.createObjectURL(m),x=document.createElement("a");x.href=h,x.download=t.replace(/\.\w+$/,".pdf"),document.body.appendChild(x),x.click(),document.body.removeChild(x),URL.revokeObjectURL(h)}async function la(e,t,a){if(!t)throw Error("User not found");let r=e.current.getBearing(),s=e.current.getPitch();if(0!==r||0!==s)throw Error("Map must be 2D bearing North");try{var l,i,n,o,c,d;let e,t,r=document.querySelectorAll(".mapboxgl-ctrl-attrib-inner a"),s="";r.forEach(e=>{s+=e.textContent.trim()+" "}),s.includes("Improve this map")&&(s=s.replace("Improve this map",""));let u=document.querySelector(".mapboxgl-canvas"),p=(l=u.width,i=u.height,n=s,o=a,new Promise((e,t)=>{let a=document.createElement("canvas");a.width=l,a.height=i;let r=a.getContext("2d");if(!r)return void t(Error("Failed to get 2D context"));r.font="14px Arial";let s=o+"  "+n,c=r.measureText(s).width,d=i-22,u=document.querySelector(".mapboxgl-ctrl-scale"),p="",m=0;if(u){let e=window.getComputedStyle(u);p=u.textContent||"",m=parseInt(e.width)||100}let h=c+(m+15),x=l-h;if(r.fillStyle="rgba(255, 255, 255, 0.40)",r.fillRect(x,d,h,22),r.textBaseline="bottom",u&&p){let e=x+5,t=d+11;r.strokeStyle="#000",r.lineWidth=2,r.beginPath(),r.moveTo(e,t+5-1),r.lineTo(e+m,t+5-1),r.stroke(),r.beginPath(),r.moveTo(e,t-5),r.lineTo(e,t+5),r.stroke(),r.beginPath(),r.moveTo(e+m,t-5),r.lineTo(e+m,t+5),r.stroke(),r.fillStyle="black",r.font="10px Arial",r.textAlign="center",r.fillText(p,e+20,t+2)}r.fillStyle="black",r.textAlign="left",r.font="14px Arial",r.fillText(s,l-c,d+22-5);let f=new Image;
19f.onload=function(){r.drawImage(f,10,i-44-10,140,44);let s=new Image;s.onload=function(){r.drawImage(s,l-100-10,i-23-30,100,23),e(a)},s.onerror=function(){t(Error("Failed to load second image"))},s.src="/images/mapbox-logo-white.svg"},f.onerror=function(){t(Error("Failed to load first image"))},f.src="/images/fusionmap_logo_hor.svg"}));return(c=u,d=await p,(e=document.createElement("canvas")).width=c.width,e.height=c.height,(t=e.getContext("2d"))&&(t.drawImage(c,0,0),t.drawImage(d,0,0)),e).toDataURL("image/png")}catch{throw Error("Failed to create TIFF PNG URL")}}async function lr(){try{return await (0,le.Tf)(document.body,{width:window.innerWidth,height:window.innerHeight,scale:1,backgroundColor:"#ffffff",filter:e=>{if(e.nodeType!==Node.ELEMENT_NODE)return!0;if("IMG"===e.tagName){let t=e.src;if(t&&t.includes("gstatic.com"))return!1}return!0}})}catch{throw Error("Failed to take map screenshot")}}async function ls(e,t,a,r="tiff",s=!0,l=!1,i=null){if(!t)return;let n=function(e){let t=atob(e.split(",")[1]),a=e.split(",")[0].split(":")[1].split(";")[0],r=new ArrayBuffer(t.length),s=new Uint8Array(r);for(let e=0;e<t.length;e++)s[e]=t.charCodeAt(e);return new File([new Blob([r],{type:a})],"image.png",{type:a})}(t);if(!s)return n;let o=new FormData;o.append("file_upload",n),o.append("top_left",JSON.stringify(ll(0,0,e))),o.append("bottom_right",JSON.stringify(ll(window.innerWidth,window.innerHeight,e)));let c=await (0,_.x)("/layer/download",{method:"POST",form:o,rawResponse:!0});if(c.ok){let e="FusionMap-"+sw.find(e=>e.style===a)?.label+"-"+new Date().toLocaleDateString();if(l){e+=".pdf",await lt(t,e,i);return}e+=`.${r}`;let s=new Blob([await c.arrayBuffer()],{type:`image/${r}`}),n=window.URL.createObjectURL(s),o=document.createElement("a");return o.href=n,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(n),s}}function ll(e,t,a){let{lng:r,lat:s}=a.current.unproject([e,t]);return{lon:r,lat:s}}let li=async(e,t,a,r)=>{try{let t=ld(a,e),s=await (0,_.x)(`${m.fn}/note/filter`,{method:"POST",json:{project_id:r.project_uuid,filterOptions:{screen:t,doubleBB:!1}}}),l=[];return s.notes.forEach(e=>{let t={id:e.id,date:e.create_date.toLocaleString(),filename:e.properties.title,filepath:""};l.push(t)}),{downloadManagerItems:l,notes:s.notes}}catch{return y.Ay.error("Couldn't load data from the server"),null}},ln=async(e,t,a,r)=>{let s=ld(a,e);try{let e=await (0,_.x)(`${m.fn}/alert/filter`,{method:"POST",json:{project_id:r.project_uuid,filterOptions:{screen:s,doubleBB:!1}}}),t=[];return e.alerts.forEach(e=>{let a={id:e.id,date:e.create_date.toLocaleString(),filename:e.properties.title,filepath:""};t.push(a)}),{downloadManagerItems:t,alerts:e.alerts}}catch{return y.Ay.error("Couldn't load data from the server"),null}},lo=async(e,t,a)=>{let r=ld(t,e);try{let e=await (0,_.x)("/measurement/filter",{method:"POST",json:{project_id:a.project_uuid,screen:r}});console.log("response:",e);let t=[];return e.rows.forEach(e=>{let a={id:e.uuid,date:e.create_date.toLocaleString(),filename:e.geojson.properties.type,filepath:""};t.push(a)}),{downloadManagerItems:t,measurements:e.measurements}}catch{return y.Ay.error("Couldn't load data from the server"),null}},lc=async(e,t,a)=>{let r=ld(a,e);try{let e=(await (0,_.x)("/map/download-las",{params:{TR:JSON.stringify(r.TR),BL:JSON.stringify(r.BL)}})).map(async e=>{let t=await (0,v.N6)(await (0,H.bB)(e.filepath));return{tile:{...e,id:(0,v.kX)()},exists:t}});return(await Promise.all(e)).filter(({exists:e})=>e).map(({tile:e})=>e)}catch{return y.Ay.error("Couldn't load data from the server"),[]}},ld=(e,t)=>{let a=e.current.unproject(new(j()).Point(Math.max(t[0].x,t[1].x),Math.min(t[0].y,t[1].y))),r=e.current.unproject(new(j()).Point(Math.min(t[0].x,t[1].x),Math.max(t[0].y,t[1].y)));return{TR:{lon:a.lng,lat:a.lat},BL:{lon:r.lng,lat:r.lat}}},lu=({title:e,items:t,downloadAll:a,downloadItem:r,stopDownload:s,downloadingAll:l,type:i})=>(0,o.jsx)(rM(),{open:!1,trigger:(0,o.jsxs)("div",{className:"collapsible_trigger font-semibold text-base border-b pb-2 border-gray-200 flex justify-between",children:[(0,o.jsxs)("span",{className:"flex items-center gap-1",children:[(0,o.jsx)("span",{className:"collapsible_arrow",children:(0,o.jsx)(W.tEr,{})}),e,t&&t.length>0&&(0,o.jsx)("span",{className:"tt-blue-badge ml-1",children:t.length})]}),(0,o.jsx)("div",{className:"flex gap-1",children:t&&t.length>0&&(0,o.jsxs)("button",{onClick:e=>{e.stopPropagation(),a(i)},className:"btn btn-sm is-disabled",children:[l.downloadingAll&&i===l.type?(0,o.jsx)("span",{className:"loading loading-spinner loading-xs self-center"}):(0,o.jsx)(W.U01,{}),"Download all"]})})]}),transitionTime:150,children:t.map((e,t)=>(0,o.jsxs)("div",{className:"flex items-center justify-between border-b pb-2 border-slate-300/20 mt-2",children:[(0,o.jsx)("span",{title:e.filename,children:e.filename.length>60?e.filename.slice(0,60)+"...":e.filename||"No title"}),l.downloadingAll&&i===x.dP.las&&void 0===e.downloadingProgress?(0,o.jsx)("span",{className:"text-xs opacity-40",children:"Queued"}):void 0===e.downloadingProgress||100===e.downloadingProgress?(0,o.jsx)("button",{onClick:()=>r(e,!1,i),className:"btn btn-sm btn-square",children:void 0!==e.downloadingProgress||l.downloadingAll?l.downloadingAll&&l.type===i?(0,o.jsx)("span",{className:"loading loading-spinner loading-xs self-center"}):i===x.dP.las?(0,o.jsx)(W.waL,{}):(0,o.jsx)(W.U01,{}):(0,o.jsx)(W.U01,{})}):(0,o.jsxs)("div",{className:"flex flex-col gap-1 items-center",children:[(0,o.jsx)("progress",{className:"progress progress-[#fff] w-16",value:e.downloadingProgress,max:"100"}),(0,o.jsxs)("div",{className:"flex items-center gap-1 text-xs opacity-40",children:[(0,o.jsxs)("span",{children:[Math.round(e.downloadingProgress),"%"]}),(0,o.jsx)("span",{onClick:()=>s(e.id),className:"cursor-pointer hover:text-black",children:(0,o.jsx)(W.WZb,{})})]})]})]},t))});var lp=a(59411);function lm({drawing:e,setDrawing:t,onFinish:a,boxRef:r,className:s="unselect"}){let l=(0,h.useRef)(null),i=(0,h.useRef)(!1),n=(0,h.useRef)(!1),o=(0,h.useRef)(null),{map:c}=(0,eG.JY)(),d=r??o;(0,h.useEffect)(()=>{let r=c.current;if(!r)return;let o=r.getCanvasContainer(),u=()=>{r.dragPan.disable(),r.scrollZoom.disable(),r.doubleClickZoom.disable(),r.boxZoom.disable(),r.keyboard.disable(),r.getCanvas().style.cursor="crosshair"},p=()=>{r.dragPan.enable(),r.scrollZoom.enable(),r.doubleClickZoom.enable(),r.boxZoom.enable(),r.keyboard.enable(),r.getCanvas().style.cursor=""},m=e=>
19{let t=o.getBoundingClientRect();return new(j()).Point(e.clientX-t.left-o.clientLeft,e.clientY-t.top-o.clientTop)},h=()=>{d.current&&(d.current.parentNode?.removeChild(d.current),d.current=null)},x=e=>{var t,a;let r,c,u,p,h;if(!i.current||!l.current)return;let x=m(e),f=d.current;f||((r=document.createElement("div")).classList.add(n.current?"boxdraw":s),o.appendChild(r),d.current=r,f=r),t=f,a=l.current,c=Math.min(a.x,x.x),u=Math.min(a.y,x.y),p=Math.max(a.x,x.x),h=Math.max(a.y,x.y),t.style.transform=`translate(${c}px, ${u}px)`,t.style.width=`${p-c}px`,t.style.height=`${h-u}px`},f=t=>{let a=t.metaKey&&t.shiftKey;(e||a)&&(n.current=!!a,t.preventDefault(),t.stopImmediatePropagation(),u(),i.current=!0,l.current=m(t),o.addEventListener("mousemove",x))},g=async e=>{o.removeEventListener("mousemove",x),i.current=!1;let r=l.current,s=m(e);l.current=null,r&&s&&await a([r,s]),h(),p(),t&&t(!1)};return e&&u(),o.addEventListener("mousedown",f,!0),o.addEventListener("mouseup",g),()=>{o.removeEventListener("mousedown",f,!0),o.removeEventListener("mouseup",g),o.removeEventListener("mousemove",x),h(),p(),i.current=!1,l.current=null}},[c,e,a,r,s])}function lh(e){let{drawing:t,setDrawing:a,boxRef:r}=e,s=(0,eG.JY)(),l=(0,ex.u)(),i=(0,ev.O)();lm({drawing:t,setDrawing:a,boxRef:r,className:"unselect",onFinish:async e=>{M(),await E(e)}});let[n,c]=(0,h.useState)([]),[d,u]=(0,h.useState)(),[p,m]=(0,h.useState)(),[f,g]=(0,h.useState)(),[b,j]=(0,h.useState)(!0),[w,N]=(0,h.useState)({downloadingAll:!1,type:x.dP.note}),[S,k]=(0,h.useState)(0),[_,C]=(0,h.useState)({}),[L,D]=(0,h.useState)(!1),A=()=>{if(!s.map.current)return;c([]),Object.values(_).forEach(e=>{e()}),C({}),k(0),e.setSelectionDownloadEnabled(!1),e.setDrawing(!1);let t=document.getElementById("download-bbox-modal");e.boxRef.current&&e.boxRef.current.parentNode?.removeChild(e.boxRef.current),t.checked&&M(),s.map.current.getLayer("backgroundDrawBox")&&s.map.current.removeLayer("backgroundDrawBox")},M=()=>{document.getElementById("download-bbox-modal")?.click()},E=async e=>{if(i.project)if(j(!0),l?.user){c(await lc(e,l?.user,s.map));let t=await li(e,l.user,s.map,i.project);t&&u({downloadManagerItems:t?.downloadManagerItems,notes:t?.notes});let a=await ln(e,l.user,s.map,i.project);a&&m({downloadManagerItems:a?.downloadManagerItems,alerts:a?.alerts});let r=await lo(e,s.map,i.project);r&&g({downloadManagerItems:r?.downloadManagerItems,measurements:r?.measurements}),j(!1)}else y.Ay.error("Couldn't load data from the server"),j(!1)},T=async(e,t,a)=>{if(i.project){if(!t&&!w.downloadingAll&&5==S)return void y.Ay.error("Max 5 concurrent downloads allowed");if(L||w.downloadingAll)return void y.Ay.error("Please wait until the current download is complete");if(a===x.dP.las){let t=await (0,H.bB)(e.filepath),a=new XMLHttpRequest;a.open("GET",t,!0),a.responseType="blob",a.onprogress=t=>{if(t.lengthComputable){let a=t.loaded/t.total*100;c((t=[])=>t.map(t=>t.id===e.id?{...t,downloadingProgress:a}:t))}},a.onload=()=>{if(200===a.status){let t=a.response,r=URL.createObjectURL(t),s=document.createElement("a");s.href=r,s.download=e.filename+".las",s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s)}},a.send();let r=()=>{a.abort(),c((t=[])=>t.map(t=>{if(t.id===e.id){let{...e}=t;return e}return t}))};return C((t=[])=>({...t,[e.id]:r})),r}{let t;switch(D(!0),a){case x.dP.note:if(!d)return;let r=d.notes.find(t=>t.id===e.id);r&&(t=(0,ea.bY)([r]));break;case x.dP.alert:if(!p?.alerts)return;let s=p.alerts.find(t=>t.id===e.id);s&&(t=(0,lp.g)([s]));break;case x.dP.measurement:if(!f?.measurements)return;let l=f.measurements.find(t=>t.uuid===e.id);l&&(t=l.geojson)}await rc(i.project,t,a,()=>{D(!1)})}}},I=e=>{if(n&&-1!==n.findIndex(t=>t.id===e)){let t=_[e];t&&t()}},P=async e=>{let t;if(i.project&&!w.downloadingAll&&!L){switch(N({downloadingAll:!0,type:e}),e){case x.dP.las:try{let t=n?.map(async(t,a)=>{_[t.id]||await new Promise(r=>{setTimeout(()=>{T(t,!0,e),r()},5*a)})});await Promise.all(t)}catch(e){console.error("Error occurred during download:",e)}break;case x.dP.note:if(!d)return;t=(0,ea.bY)(d.notes);break;case x.dP.alert:if(!p?.alerts)return;t=(0,lp.g)(p.alerts);break;case x.dP.measurement:if(!f?.measurements)return;t=(0,v.td)(f.measurements.map(e=>e.geojson))}await rc(i.project,t,e,()=>{N({downloadingAll:!1,type:e})})}};return(0,h.useEffect)(()=>{let e=0;n?.forEach(t=>{t.downloadingProgress&&t.downloadingProgress>0&&t.downloadingProgress<100&&e++}),k(e),0==e&&N({...w,downloadingAll:!1})},[n]),(0,o.jsx)(o.Fragment,{children:(0,t3.createPortal)((0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("input",{type:"checkbox",id:"download-bbox-modal",className:"modal-toggle"}),(0,o.jsxs)("div",{className:"modal batchdownload-modal",children:[(0,o.jsxs)("div",{className:"modal-box text-black mb-24 card card-sm bg-base-100 shadow-xl p-0 cursor-auto",children:[(0,o.jsxs)("div",{className:"flex flex-row justify-between items-center mx-5 pt-3 pb-2 border-b border-b-black/10",children:[(0,o.jsxs)("span",{className:"font-bold text-lg flex flex-row items-center gap-3",children:[(0,o.jsx)(ep.aQt,{}),"Download data from the selected area ",(0,o.jsx)("div",{className:"tt-blue-badge",children:"BETA"})]}),(0,o.jsx)("label",{htmlFor:"download-bbox-modal",className:"btn btn-sm btn-circle btn-ghost",onMouseDown:A,children:"✕"})]}),(0,o.jsx)("div",{className:"m-5 flex flex-col gap-2 overflow-auto max-h-[600px] px-4",children:b?(0,o.jsx)("span",{className:"loading loading-spinner loading-md self-center mt-10 mb-10"}):(0,o.jsx)(o.Fragment,{children:d?.notes&&d.notes.length>0||p?.alerts&&p.alerts.length>0||n.length>0||f?.measurements&&f.measurements.length>0?(0,o.jsxs)(o.Fragment,{children:[n.length>0&&(0,o.jsx)(lu,{title:"Raw LiDAR files",items:n,downloadAll:P,downloadItem:T,stopDownload:I,downloadingAll:w,type:x.dP.las}),d?.notes&&d.notes.length>0&&(0,o.jsx)(lu,{title:"Notes",items:d.downloadManagerItems,downloadAll:P,downloadItem:T,stopDownload:I,downloadingAll:w,type:x.dP.note}),p?.alerts&&p.alerts.length>0&&(0,o.jsx)(lu,{title:"Alerts",items:p.downloadManagerItems,downloadAll:P,downloadItem:T,stopDownload:I,downloadingAll:w,type:x.dP.alert}),f?.measurements&&f.measurements.length>0&&(0,o.jsx)(lu,{title:"Measurements",items:f.downloadManagerItems,downloadAll:P,downloadItem:T,stopDownload:I,downloadingAll:w,type:x.dP.measurement}),(0,o.jsx)("span",{className:"text-center opacity-50 mt-4",children:"Please ensure there are no other active downloads in your browser to guarantee this download completes successfully"}),(0,o.jsx)("span",{className:"text-center text-red-400 mt-4",children:"Please do not close this window while the files are being downloaded."})]}):(0,o.jsx)("span",{className:"flex self-center opacity-40 mt-10 mb-10",children:"No data for the selected area"})})})]}),(0,o.jsx)("label",{className:"modal-backdrop",onClick:A,children:"Close"})]})]}),document.body)})}var lx=a(24193);function lf({isOpen:e,onClose:t,handleDownloadMapCanvas:a,handleDownloadScreenshot:r,screenshotDataUrl:s,tiffPngDataUrl:l}){let[i,n]=(0,h.useState)(x.Fq.canvas),[c,d]=(0,h.useState)(x.mt.tiff),[u,p]=(0,h.useState)(!1),[m,f]=(0,h.useState)(!0),g=[{type:x.Fq.canvas,label:"Map Canvas",dataUrl:l,info:"Clean map without UI elements",alt:"Map Canvas Preview"},{type:x.Fq.screenshot,label:"Screenshot",dataUrl:s,info:"Full screen with side panel and modals",alt:"Screenshot Preview"}],b=e=>{let t=i!==e;n(e),t&&(e===x.Fq.canvas?d(x.mt.tiff):d(x.mt.png))},j=async(e,t)=>{if(!u){if(!m){y.Ay.error("Please wait a few seconds before downloading again."),p(!1);return}p(!0),f(!1);try{e===x.Fq.canvas?await a(t):await r(t)}catch(e){y.Ay.error(`Map download failed${e instanceof Error?`: ${e.message}`:""}`)}p(!1),setTimeout(()=>{f(!0)},5e3)}};return e?(0,t3.createPortal)((0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("input",{type:"checkbox",id:"map-download-modal",className:"modal-toggle",checked:e,readOnly:!0}),(0,o.jsxs)("div",{className:"modal",children:[(0,o.jsxs)("div",{className:"modal-box text-black bg-base-100 shadow-xl p-0 cursor-auto max-w-180",children:[(0,o.jsxs)("div",{className:"flex flex-row justify-between items-center mx-5 pt-3 pb-2 border-b border-b-black/10",children:[(0,o.jsxs)("span",{className:"font-bold text-lg flex flex-row items-center gap-3",children:[(0,o.jsx)(lx.SCg,{}),"Download Map"]}),(0,o.jsx)("button",{className:"btn btn-sm btn-circle btn-ghost",onClick:t,children:"✕"})]}),(0,o.jsxs)("div",{className:"p-5",children:[(0,o.jsx)("div",{className:"\n                flex mb-4 min-w-0\n                flex-col gap-4 items-start justify-between\n                sm:flex-row sm:gap-3 sm:items-center sm:justify-start\n              ",children:g.map(e=>(0,o.jsxs)("div",{className:"flex-1 space-y-2 min-w-0 max-w-70 w-full sm:max-w-none sm:w-auto",children:[(0,o.jsxs)("label",{className:"flex items-center gap-2.5 text-sm font-medium text-gray-700 cursor-pointer",children:[(0,o.jsx)("input",{type:"radio",name:"image-type",className:"radio radio-sm checked:text-[#2563eb]/90 checked:border-[#2563eb]/90",checked:i===e.type,onCh
19ange:()=>b(e.type)}),(0,o.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,o.jsx)("span",{className:"text-sm truncate",children:e.label}),(0,o.jsx)("span",{className:"text-xs text-gray-400",children:e.info})]})]}),(0,o.jsx)("div",{className:`
20                        rounded-lg flex items-center justify-center border-2 cursor-pointer
21                        transition-all duration-100
22                        ${i===e.type?"bg-blue-50 border-blue-400":"bg-gray-100 border-gray-300 hover:shadow-md"}
23                      `,onClick:()=>b(e.type),children:e.dataUrl?(0,o.jsx)("img",{src:e.dataUrl,alt:e.alt,className:"rounded-lg h-40 object-contain"}):(0,o.jsx)("div",{className:"flex items-center justify-center h-40",children:(0,o.jsx)("div",{className:"text-gray-400 text-sm",children:"No preview available"})})})]},e.type))}),(0,o.jsx)("div",{className:"divider my-2 opacity-30"}),(0,o.jsxs)("div",{className:"space-y-1.5",children:[(0,o.jsx)("div",{className:"label-text",children:"File Format:"}),(0,o.jsx)("div",{className:"flex flex-col",children:(i===x.Fq.canvas?[{value:x.mt.tiff,label:"TIFF"},{value:x.mt.pdf,label:"PDF"}]:[{value:x.mt.png,label:"PNG"},{value:x.mt.pdf,label:"PDF"}]).map(e=>(0,o.jsxs)("label",{className:"label cursor-pointer justify-start gap-2 pl-1.5 py-1.5 rounded-lg hover:bg-gray-50",children:[(0,o.jsx)("input",{type:"radio",name:"format-option",className:"radio radio-sm checked:text-[#2563eb]/90 checked:border-[#2563eb]/90",checked:c===e.value,onChange:()=>d(e.value)}),(0,o.jsx)("span",{className:"text-sm",children:e.label})]},e.value))})]}),(0,o.jsx)("div",{className:"flex justify-end gap-3",children:(0,o.jsxs)("button",{className:"btn btn-sm tt-blue-button flex items-center gap-2",onClick:()=>j(i,c),disabled:u,children:[u?(0,o.jsx)("div",{className:"animate-spin",children:(0,o.jsx)($.qzG,{})}):(0,o.jsx)(W.U01,{}),"Download"]})})]})]}),(0,o.jsx)("label",{className:"modal-backdrop",onClick:t,children:"Close"})]})]}),document.body):null}function lg(e){let t=(0,ev.O)(),a=(0,eV.H)(),r=(0,h.useRef)(null),[s,l]=(0,h.useState)(!1),[i,n]=(0,h.useState)(!1),[c,u]=(0,h.useState)(!1),[p,m]=(0,h.useState)(!1),[f,g]=(0,h.useState)(null),[b,j]=(0,h.useState)(null),w=async a=>{a===x.mt.tiff?await ls(e.map,f,e.mapStyle):a===x.mt.pdf&&await ls(e.map,f,e.mapStyle,"png",!0,!0,t.project?.project_name)},v=async e=>{if(e===x.mt.png){if(!b)throw Error("Screenshot data URL not found");let e=document.createElement("a");e.href=b,e.download=`fusionmap-screenshot-${new Date().toLocaleDateString()}.png`,e.click()}else e===x.mt.pdf&&await lt(b,`fusionmap-screenshot-${new Date().toLocaleDateString()}.pdf`,t.project?.project_name??null)},N=async()=>{l(!0);try{let[t,r]=await Promise.all([lr(),la(e.map,e.user,(()=>{let{date:e,premiumLayer:t}=a;return e&&t.layer?e.toLocaleDateString():new Date().toLocaleDateString()})())]);j(t),g(r),m(e=>!e)}catch(e){y.Ay.error(`Screenshot failed${e instanceof Error?`: ${e.message}`:""}`)}l(!1)};return(0,o.jsxs)("div",{className:"measurement-tools flex flex-row align-center",children:[(0,o.jsx)(lh,{drawing:i,setDrawing:n,setSelectionDownloadEnabled:u,boxRef:r}),p&&(0,o.jsx)(lf,{screenshotDataUrl:b,tiffPngDataUrl:f,isOpen:p,onClose:()=>m(!1),handleDownloadMapCanvas:w,handleDownloadScreenshot:v}),(0,o.jsxs)("div",{className:"measurement-tools flex flex-row align-center",children:[(0,o.jsx)("button",{disabled:s,className:`${e.areDownloadButtonsShown&&"tooltip tooltip-top"} hover:bg-black/5 ${s?"opacity-50 cursor-not-allowed":""}`,"data-tip":"Select and Download",onClick:()=>{(r.current&&r.current.parentNode?.removeChild(r.current),c!==i)?u(!c):(u(!c),n(!i),e.map.current.getLayer("backgroundDrawBox")?e.map.current.removeLayer("backgroundDrawBox"):e.map.current.addLayer({id:"backgroundDrawBox",type:"background",paint:{"background-color":"rgba(211, 211, 211, 0.5)"}}))},style:{width:"30px",height:"29px",display:"flex",justifyContent:"center",alignItems:"center",borderRight:"1px solid lightgray"},children:(0,o.jsx)(ep.aQt,{size:18,color:c?"#2563eb":"#000"})}),(0,o.jsx)("button",{disabled:s,className:`${e.areDownloadButtonsShown&&"tooltip tooltip-top"} hover:bg-black/5 ${s?"opacity-50 cursor-not-allowed":""}`,"data-tip":s?"Preparing...":"Download Map",onClick:N,style:{width:"30px",height:"29px",display:"flex",justifyContent:"center",alignItems:"center"},children:s?(0,o.jsx)("div",{className:"animate-spin",children:(0,o.jsx)($.qzG,{size:18,color:"#222222"})}):(0,o.jsx)(d(),{src:"/images/downloadtifficon.png",width:18,height:18,alt:"Download GeoTIFF icon"})})]})]})}let ly=`
24    rounded-md border-4 border-solid cursor-pointer object-cover w-[35px] h-[35px] appearance-none bg-transparent p-0
25    focus:outline-none focus:ring-0
26    focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-tt-blue focus-visible:ring-offset-white
27`;function lb({tooltipClass:e,tooltipText:t,imageSrc:a,enabled:r,ariaLabel:s,onToggle:l,onKeyDown:i,onMouseUp:n}){return(0,o.jsx)("button",{type:"button",className:`tooltip ${e} ${ly}`,"data-tip":t,onClick:l,onKeyDown:i,onMouseUp:n,style:{backgroundImage:`url(${a})`,backgroundSize:"cover",borderColor:r?"rgb(37 99 235 / 0.9)":"rgb(209 213 219 / 0.5)"},"aria-pressed":r,"aria-label":s})}function lj({onOpen:e,onKeyDown:t}){return(0,o.jsx)("div",{className:"z-30",children:(0,o.jsx)("button",{type:"button",className:"tooltip tooltip-left desktop:inline-flex z-20 layers-btn","data-tip":"Map Layers",onClick:e,onKeyDown:t,"aria-label":"Open map layers",children:(0,o.jsx)("span",{className:"mapboxlike-button","data-testid":"maplayer-button",children:(0,o.jsx)(W.gP6,{size:20,color:"#000"})})})})}function lw({setShowEditModelMenu:e,onFeatureClick:t}){let a=(0,eV.H)(),r=(0,eG.JY)(),s=(0,ej.H)(),l=(0,ev.O)(),{toggleSidePanel:i}=(0,e$.p)(),n=e=>t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),e())},c=e=>{e.currentTarget.blur()},d=a.premiumLayer.layer,u=a.altPremiumLayer.selected?a.altPremiumLayer.layer:d,p=!!d,m=r.splitViewEnabled?{tooltip:`Right: ${u?.layerName??""}`,imageSrc:u?.imgSrc??"",enabled:a.altPremiumLayerAddedToMap,ariaLabel:`Toggle right layer ${u?.layerName??""}`,toggle:()=>a.setAltPremiumLayerAddedToMap(e=>!e)}:{tooltip:d?.layerName??"",imageSrc:d?.imgSrc??"",enabled:a.premiumLayerAddedToMap,ariaLabel:`Toggle layer ${d?.layerName??""}`,toggle:()=>a.setPremiumLayerAddedToMap(e=>!e)},h=()=>i((0,o.jsx)(s2,{setShowEditModelMenu:e,setBottomMenuOpen:s.setBottomMenuOpen,onFeatureClick:t}),{title:"Map Layers",key:"layers"});return(0,o.jsxs)(o.Fragment,{children:[p&&r.splitViewEnabled&&(0,o.jsx)("div",{className:"absolute left-[20px] bottom-[60px] z-30 flex flex-col gap-2",children:(0,o.jsx)(lb,{tooltipClass:"tooltip-right",tooltipText:`Left: ${d?.layerName??""}`,imageSrc:d?.imgSrc??"",enabled:a.premiumLayerAddedToMap,ariaLabel:`Toggle left layer ${d?.layerName??""}`,onToggle:()=>a.setPremiumLayerAddedToMap(e=>!e),onKeyDown:n(()=>a.setPremiumLayerAddedToMap(e=>!e)),onMouseUp:c})}),(0,o.jsxs)("div",{"data-testid":"layers-modal",className:"layerssidepanel",children:[p&&(0,o.jsx)(lb,{tooltipClass:"tooltip-left",tooltipText:m.tooltip,imageSrc:m.imageSrc,enabled:m.enabled,ariaLabel:m.ariaLabel,onToggle:m.toggle,onKeyDown:n(m.toggle),onMouseUp:c}),l.project&&(0,o.jsx)(lj,{onOpen:h,onKeyDown:n(h)})]})]})}var lv=a(49211);function lN({setShowEditModelMenu:e,onFeatureClick:t,setReloadLayer:a}){let r=(0,eV.H)(),s=(0,eG.JY)(),l=(0,ey.F)(),i=(0,eb.g)(),n=(0,ej.H)(),c=(0,ex.u)(),d=(0,ev.O)(),{toggleModal:u}=(0,tZ.O)(),{toggleSidePanel:p,sidePanelOpen:m,closePanel:f}=(0,e$.p)(),{handle3DToggle:g,isIn3DView:b}=(()=>{let e=(0,eG.JY)(),t=(0,ey.F)(),[a,r]=(0,h.useState)(!!e.map.current?.getPitch());return(0,h.useEffect)(()=>{let a=e.map.current;a&&!t.elevationMeasurementEnabled&&0===a.getPitch()&&((0,tw.OY)(a),e.altMap?.current&&(0,tw.OY)(e.altMap.current))},[t.elevationMeasurementEnabled]),(0,h.useEffect)(()=>{let t=e.map.current;if(!t)return;let a=()=>{let a=t.getPitch();r(a>0),a>0&&!t.getTerrain()&&((0,tw.vu)(t),e.altMap?.current&&(0,tw.vu)(e.altMap.current))},s=()=>{let a=t.getPitch();r(a>0),0===a&&((0,tw.OY)(t),e.altMap?.current&&(0,tw.OY)(e.altMap.current))};return t.on("pitch",a),t.on("pitchend",s),()=>{t.off("pitch",a),t.off("pitchend",s)}},[e.map.current]),{isIn3DView:a,handle3DToggle:()=>{e.map.current&&(a?(e.map.current.easeTo({pitch:0,duration:1e3}),e.altMap&&e.altMap.current&&e.altMap.current.easeTo({pitch:0,duration:1e3})):(e.map.current.easeTo({pitch:55,duration:1e3}),e.altMap&&e.altMap.current&&e.altMap.current.easeTo({pitch:55,duration:1e3}),r(!0),(0,tw.vu)(e.map.current),e.altMap?.current&&(0,tw.vu)(e.altMap.current)))}}})(),j=(0,h.useCallback)(e=>{"elevation_tool"===e?(l.setElevationMeasurementEnabled(e=>!e),i.setDrawingModeCaller(null)):(i.setDrawingModeCaller(t=>t===e?null:e),l.setElevationMeasurementEnabled(!1)),n.setBottomMenuOpen({open:!1,id:0,event:null})},[l,i,n]);return(0,o.jsxs)(o.Fragment,{children:[!i.isDrawing&&!l.elevationMeasurementEnabled&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:"bottom-right-tools",children:[d.project&&(0,o.jsx)("button",{className:"tooltip tooltip-left mapboxlike-button fusionchat-btn","data-tip":"Pulse",onClick:()=>p((0,o.jsx)(s8.A,{}),{title:"Pulse",key:"fusionchat",beta:!0,fullWidth:!0}),children:(0,o.jsx)("img",{src:"/images/pulselogo.svg",alt:"FusionChat Icon",width:30})}),(0,o.jsx)("div",{className:`tooltip tooltip-left toggle-perspective mapboxlike-button ${b?"toggled":""}`,"data-tip":b?"View in 2D":"View in 3D",onClick:g,"data-testid":"perspective-toggle",children:(0,o.jsx)("p",{className:"font-[550]",children:b?"2D":"3D"})}),(0,o.jsxs)("div",{className:"measurement-tools flex flex-col","data-testid":"tools-downloads",children:[!(0,e_.KR)()&&c&&d.project&&(0,o.jsx)(s7,{HiddenButtonsContent:({areButtonsShown:e})=>(0,o.jsx)(lg,{map:s.map,user:c.user,mapStyle:r.mapStyle,areDownloadButtonsShown:e}),MainButtonContent:(0,o.jsx)(ek.qqM,{size:18}),position:s6.TOP}),(0,o.jsx)("div",{className:"tooltip tooltip-left hover:bg-black/5","data-tip":"Split View",onClick:async()=>{r.premiumLayer.selected?(a(!0),s.splitViewEnabled?(r.setAltPremiumLayer({selected:!1,layer:null}),r.setAltDate(null),r.setAltPremiumLayerAddedToMap(!1),f(),m?setTimeout(()=>{s.setSplitViewEnabled(!s.splitViewEnabled)},300):s.setSplitViewEnabled(!s.splitViewEnabled)):(r.premiumLayer.layer&&(r.setAltPremiumLayer({selected:!0,layer:r.premiumLayer.layer}),r.setAltDate(r.date),r.setAltPremiumLayerAddedToMap(r.premiumLayerAddedToMap)),s.setSplitViewEnabled(!s.splitViewEnabled))):y.oR.error("Please select a premium layer in order to use the split feature")},style:{width:"30px",height:"30px",display:"flex",justifyContent:"center",alignItems:"center",borderBottom:"1px solid lightgray"},children:(0,o.jsx)(lv.EIu,{size:18,color:s.splitViewEnabled?"#2563eb":"#000"})}),(0,o.jsx)(s7,{HiddenButtonsContent:({areButtonsShown:e})=>(0,o.jsxs)("div",{className:"measurement-tools flex flex-row align-center",children:[(0,o.jsx)("button",{className:`${e&&"tooltip tooltip-top"} hover:bg-black/5`,"data-tip":"Distance",onClick:()=>{j(x.xY.DISTANCE_TOOL)},style:{width:"30px",height:"29px",display:"flex",justifyContent:"center",alignItems:"center",borderRight:"1px solid lightgray"},children:(0,o.jsx)(em.fod,{size:18})}),(0,o.jsx)("button",{className:`${e&&"tooltip tooltip-top"} hover:bg-black/5`,"data-tip":"Area",onClick:()=>{j(x.xY.AREA_TOOL)},style:{width:"30px",height:"29px",display:"flex",justifyContent:"center",alignItems:"center",borderRight:"1px solid lightgray"},children:(0,o.jsx)(ep.voV,{size:18})}),(0,o.jsx)("button",{className:`${e&&"tooltip tooltip-top"} hover:bg-black/5`,"data-tip":"Elevation",onClick:()=>{j("elevation_tool")},style:{width:"30px",height:"29px",display:"flex",justifyContent:"center",alignItems:"center"},children:(0,o.jsx)(eh.YQY,{size:18,color:l.elevationMeasurementEnabled?"#2563eb":"#000"})})]}),MainButtonContent:(0,o.jsx)($.cXu,{size:18,color:"#000"}),position:s6.BOTTOM})]})]}),(0,o.jsx)(lw,{setShowEditModelMenu:e,onFeatureClick:t})]}),(0,o.jsx)("a",{className:"mapboxgl-ctrl-logo",target:"_blank",rel:"nofollow noreferrer",href:"https://www.mapbox.com/","aria-label":"Mapbox logo"}),s.splitViewEnabled&&r.altPremiumLayerAddedToMap&&(0,o.jsx)(tV,{date:r.altDate,setDate:r.setAltDate,onClick:()=>{u(x.dW.AltCalendarModal)},alt:!0})]})}function lS(){let e=(0,ex.u)(),t=(0,eN.D)(),a=(0,ev.O)(),r=(0,eG.JY)(),{clickModal:s}=(0,tZ.O)(x.dW.LidarModal),l=(0,h.useRef)(null),i="lidar",{EmojiPickerComponent:n,setShowEmojiPicker:c}=eW({onCloseModal:()=>{sessionStorage.setItem(`show_emoji_picker_${i}`,"false")},onEmojiClick:e=>{sessionStorage.setItem("selected_emoji",e.imageUrl)}});(0,h.useEffect)(()=>{let e=l.current;if(!e)return;let t=()=>{s()},a=()=>{e.contentWindow?.document?.body&&(e.contentWindow.document.body.onclick=t)};return e.addEventListener("load",a),()=>{e.removeEventListener("load",a)}},[s]),(0,h.useEffect)(()=>{sessionStorage.setItem(`show_emoji_picker_${i}`,"false");let e=e=>{e.storageArea===sessionStorage&&e.key===`show_emoji_picker_${i}`&&"true"===sessionStorage.getItem(`show_emoji_picker_${i}`)&&c(!0)};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[]);let d=e?.user?{id:e.user.id,name:e.user.name,email:e.user.email,lang:e.user.lang,first_name:e.user.first_name,surname:e.user.surname}:null;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(t4,{modalType:x.dW.LidarModal,defaultPosition:{x:70,y:65},defaultSize:{width:750,height:430},title:"Pointclouds",handleDragStart:()=>{l.current.style.pointerEvents="none"},handleDragStop:()=>{l.current.style.pointerEvents="auto"},lockRatio:"nolock",closeModal:()=>{(0,aR.jo)(r.map,null),t.lidarPositionMarkerRef.current?.remove(),t.lid
27arPositionMarkerRef.current=null},children:e?.user&&a.project&&(0,o.jsx)("iframe",{ref:l,className:"w-full h-full",src:"../../libs/potree/build/potree/pointcloud-viewer.html?user="+JSON.stringify(d)+"&mode="+i+"&camera_projection="+encodeURIComponent(a.project.camera_projection||"")+"&lidar_projection="+encodeURIComponent(a.project.lidar_projection||"")+"&units="+encodeURIComponent(a.project.units||"")+"&project_id="+a.project.project_uuid+"&project_name="+a.project.project_name+"&container_name="+a.project.container_name+"&project_logo="+encodeURIComponent(a.projectImageUrl??"")+"&lrs_included="+a.project.lrs_included,title:"Potree"})}),n]})}function lk(e){let t=(0,ex.u)(),a=(0,eN.D)(),r=(0,ev.O)(),s=(0,aO.h)(),{clickModal:l}=(0,tZ.O)(),i=(0,h.useRef)(null),[n,c]=(0,h.useState)([]),d="hybrid",{EmojiPickerComponent:u,setShowEmojiPicker:p}=eW({onCloseModal:()=>{sessionStorage.setItem(`show_emoji_picker_${d}`,"false")},onEmojiClick:e=>{sessionStorage.setItem("selected_emoji",e.imageUrl)}});(0,h.useEffect)(()=>{let e=i.current;if(!e)return;let t=()=>{l(x.dW.HybridViewModal)},a=()=>{e.contentWindow?.document?.body&&(e.contentWindow.document.body.onclick=t)};return e.addEventListener("load",a),()=>{e.removeEventListener("load",a)}},[l]),(0,h.useEffect)(()=>{n.length<1&&c(a.availableLidars)},[a.availableLidars]);let m=t?.user?{id:t.user.id,name:t.user.name,email:t.user.email,lang:t.user.lang,first_name:t.user.first_name,surname:t.user.surname}:null;return(0,h.useEffect)(()=>{sessionStorage.setItem(`show_emoji_picker_${d}`,"false");let e=e=>{e.storageArea===sessionStorage&&e.key===`show_emoji_picker_${d}`&&"true"===sessionStorage.getItem(`show_emoji_picker_${d}`)&&p(!0)};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[]),(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(t4,{modalType:x.dW.HybridViewModal,defaultPosition:{x:800,y:65},defaultSize:{width:750,height:430},handleDragStart:()=>{i.current&&(i.current.style.pointerEvents="none")},title:"Hybrid View",handleDragStop:()=>{i.current&&(i.current.style.pointerEvents="auto")},lockRatio:"nolock",children:s.isPanoAvailable&&t?.user&&r.project?(0,o.jsx)("iframe",{ref:i,className:"w-full h-full rounded-b-lg z-50",src:(()=>{if(!r.project)return"";let e=a.availableLidars&&a.availableLidars.length>0,t="../../libs/potree/build/potree/pointcloud-viewer.html?&user="+JSON.stringify(m)+"&mode="+d+"&camera_projection="+encodeURIComponent(r.project.camera_projection||"")+"&units="+encodeURIComponent(r.project.units||"")+"&project_id="+r.project.project_uuid+"&project_name="+r.project.project_name+"&container_name="+r.project.container_name+"&project_logo="+encodeURIComponent(r.projectImageUrl??"")+"&lrs_included="+r.project.lrs_included;return e?t+="&lidar_projection="+encodeURIComponent(a.availableLidars[0].epsg):r.project.lidar_projection&&(t+="&lidar_projection="+encodeURIComponent(r.project.lidar_projection)+"&lidar_available=false"),t})(),title:"Potree"},e.refreshToken):(0,o.jsxs)("div",{className:"flex items-center justify-center text-center text-white/70 flex-col gap-1 text-[14px] h-full",children:[(0,o.jsx)(z.wft,{size:24}),"Panoramic image unavailable for this location."]})}),u]})}function l_(e){let t=(0,ex.u)(),{modalState:a}=(0,tZ.O)(x.dW.EagleVueModal),r=(0,h.useRef)(),[s,l]=(0,h.useState)(!1),[i,n]=(0,h.useState)(1),c="";a.display&&(c=JSON.parse(localStorage.getItem("map_state")||"{}")?.file?.replace(/\/(camera[0-8]|pano)\//g,"/eagle/")||""),(0,h.useEffect)(()=>{let e=localStorage.setItem;localStorage.setItem=function(t,a){let r=new Event("eagleViewWithoutHybrid");r.value=a,r.key=t,document.dispatchEvent(r),e.apply(this,[t,a])}},[]);let d=t=>{n(e=>e+1),"next"===t?localStorage.setItem("nav_update",JSON.stringify({updateImage:e.updateImage,action:"next",updateNavCounter:i})):"prev"===t&&localStorage.setItem("nav_update",JSON.stringify({updateImage:e.updateImage,action:"prev",updateNavCounter:i}))},u=async()=>{if(s)return;l(!0);let a=await fetch(m.fn+"/static/views/"+t?.user?.id+"_"+e.projectId+"_eagle_view.jpg?date="+e.updateImage),i=new File([await a.blob()],"file.jpg",{type:"image/jpeg",lastModified:new Date().getTime()}),n=new FormData;n.append("image",i);try{let e=await fetch(`${m.qn}/object_detection/2`,{method:"POST",body:n});if(!e.ok)return void console.error("API request failed");let t=await e.json();r.current.src=`data:image/jpeg;base64,${t.annotated_image}`}catch{}l(!1)};return(0,o.jsx)(o.Fragment,{children:t?.user?.id&&(0,o.jsx)(t4,{modalType:x.dW.EagleVueModal,defaultPosition:{x:70,y:250},defaultSize:{width:300,height:350},backgroundColor:"#212121",title:"Eagle View",children:""!==c?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("div",{className:"image-container overflow-hidden h-full rounded-b-md",children:(0,o.jsx)("img",{ref:r,
27src:c,alt:"Camera Image",className:"camera-image object-cover h-full"},e.updateImage)}),!(0,v.KV)()&&(0,o.jsx)("div",{onClick:u,className:"pointcloud-custom-tool bg-black absolute z-50 top-12 w-9 h-9 items-center justify-center left-2 shadow backdrop-blur-md p-2 rounded-full cursor-pointer transition hover:scale-105",children:s?(0,o.jsx)("span",{className:"loading loading-spinner loading-sm"}):(0,o.jsx)("img",{src:"/images/brain.png",alt:"AI Icon",title:"AI",width:20,className:"opacity-90"})}),(0,o.jsx)("div",{className:`pointcloud-custom-tool bg-black absolute z-50 ${(0,v.KV)()?"top-12":"top-24"} w-9 h-9 items-center justify-center left-2 shadow-none backdrop-blur-md p-2 rounded-full cursor-pointer transition hover:scale-105`,title:"Edit",onClick:()=>(0,v.zc)(c),children:(0,o.jsx)(W.U01,{})}),(0,o.jsx)("div",{className:"flex justify-center gap-1 absolute bottom-4 left-1/2 transform -translate-x-1/2 z-50",children:e.containsPano&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("div",{onClick:()=>d("prev"),className:"bg-black shadow backdrop-blur-md p-2 rounded-full cursor-pointer transition hover:scale-105",children:(0,o.jsx)(eK.irw,{size:18})}),(0,o.jsx)("div",{onClick:()=>d("next"),className:"bg-black shadow backdrop-blur-md p-2 rounded-full cursor-pointer transition hover:scale-105",children:(0,o.jsx)(eK.fOo,{size:18})})]})})]}):(0,o.jsxs)("div",{className:"flex items-center justify-center h-full text-center text-white/70 flex-col gap-1 text-[14px]",children:[(0,o.jsx)(z.wft,{size:24}),"Click on a camera point on the map to view images"]})})})}var lC=a(41285);let lL=async(e,t)=>(0,_.x)("/map/get-image",{method:"GET",params:{image_id:e,view:t}}),lD=async(e,t,a)=>(0,_.x)("/map/nav",{method:"GET",params:{navcommand:e,view:t,image_id:a}});function lA(e){let t=(0,aO.h)(),[a,r]=(0,h.useState)(0),s=async(e,a)=>{try{let r=await lL(e,a);t.setViewInfo(e=>({...e,[a]:r[a]}))}catch{y.Ay.error("Error searching for image")}},l=t.availableImageDates[e.camera].slice(a,a+5);return(0,o.jsx)(o.Fragment,{children:t.availableImageDates[e.camera].length>1&&(0,o.jsx)("div",{className:"carousel-container",children:(0,o.jsxs)("div",{className:"flex justify-between",children:[(0,o.jsx)("button",{onClick:()=>{a>0&&r(a-1)},className:"btn btn-xs bg-black text-white hover:bg-gray-700 mt-2 transition-colors disabled:opacity-20",disabled:0===a,children:(0,o.jsx)(eK.irw,{size:15})}),t.availableImageDates[e.camera].length>1&&(0,o.jsx)("div",{className:"flex flex-wrap justify-center space-x-2",children:l.map(a=>(0,o.jsxs)("button",{onClick:()=>s(a.image_id,e.camera),className:t.viewInfo[e.camera].image_id==a.image_id?"btn btn-white btn-xs text-black mt-2":"btn btn-outlined-primary btn-xs bg-black text-white mt-2 hover:text-black",children:[J()().month(a.month-1).format("MMM"),", ",a.year]},a.image_id))}),(0,o.jsx)("button",{onClick:()=>{a+5<t.availableImageDates[e.camera].length&&r(a+1)},className:"btn btn-xs bg-black text-white hover:bg-gray-700 mt-2 transition-colors disabled:opacity-20 ",disabled:a+5>=t.availableImageDates[e.camera].length,children:(0,o.jsx)(eK.fOo,{size:15})})]})})})}function lM(e){let t=(0,ex.u)(),a=(0,h.useRef)(null),r=(0,aO.h)(),s=(0,eG.JY)(),[l,i]=(0,h.useState)(L()),n=`CameraModal-${L()}`,{openModal:c,closeModal:d}=(0,tZ.O)(n),u=(0,h.useRef)(null),[p,m]=(0,h.useState)(null),[f,g]=(0,h.useState)(!1),[y,b]=(0,h.useState)(!1),[j,w]=(0,h.useState)(null),v=(0,h.useRef)(null),N=()=>D(x.z.NEXT),S=()=>D(x.z.NEXT10),k=()=>D(x.z.PREV),C=()=>D(x.z.PREV10);function L(){return Number(e.camera.replace("camera",""))}async function D(t){let a=r.viewInfo[e.camera].image_id,l=e.camera,i=await lD(t,l,a);if(i.camera1){let e=await (0,H.bB)(i.camera1.filepath),t={lon:i.camera1.lon,lat:i.camera1.lat,file:e};localStorage.setItem("map_state",JSON.stringify(t))}i.pano&&localStorage.setItem("nav_update",JSON.stringify({action:t,imageId:i.pano.image_id,lat:i.pano.lat,lon:i.pano.lon})),ag(i[l].lat,i[l].lon,!1,!1).then(e=>{e&&r.setAvailableImageDates(e)}).catch(e=>{console.error("Error loading available dates:",e)}),r.setViewInfo(i),s.markerRef.current?.setLngLat([i[l].lon,i[l].lat])}let A=async()=>
27{if(e.isOpen){v.current&&clearTimeout(v.current);try{if(b(!0),!r.viewInfo[e.camera]?.filepath){g(!1),b(!1);return}let t=await (0,_.x)("/blob/compress-image",{method:"POST",json:{file_path:r.viewInfo[e.camera].filepath}});m(t.compressedImagePath),g(!1),b(!1);let a=new Image;a.src=await (0,H.bB)(t.originalImagePath);let s=()=>{m(t.originalImagePath),v.current=null};v.current=setTimeout(s,1500),a.onload=()=>{v.current&&clearTimeout(v.current),s()}}catch{m(null),g(!1),b(!1)}}};(0,h.useEffect)(()=>{i(L())},[e.camera]),(0,h.useEffect)(()=>{e.isOpen?c():d()},[e.isOpen]),(0,h.useEffect)(()=>(r.viewInfo[e.camera]&&t&&A(),()=>{v.current&&clearTimeout(v.current)}),[r.viewInfo,e.camera,t,e.isOpen]),(0,h.useEffect)(()=>{(async()=>{p?w(await (0,H.bB)(p)):w(null)})()},[p]);let M=e=>{g(!0),e()};return(0,h.useEffect)(()=>{let t=t=>{if(e.isOpen&&!f)switch(t.key){case"ArrowLeft":M(k);break;case"ArrowRight":M(N);break;case"ArrowDown":M(C);break;case"ArrowUp":M(S)}};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[e.isOpen,M]),(0,o.jsx)(o.Fragment,{children:(0,o.jsx)(t4,{modalType:n,closeModal:e.closeModal,defaultPosition:{x:70,y:200},defaultSize:{width:500,height:"auto"},title:`Camera ${l}`,lockRatio:"nolock",backgroundColor:"black",children:p?(0,o.jsxs)("div",{className:"min-h-[300px] max-h-[600px]",children:[(0,o.jsx)("div",{ref:a,className:"image-container h-full w-full relative",style:{overflow:"hidden"},children:(0,o.jsx)(lC.A,{children:(0,o.jsx)("img",{src:`${j}`,ref:u,className:"w-full h-auto relative z-10",alt:"Camera View"})})}),(0,o.jsx)("div",{children:(0,o.jsx)("div",{className:"pointcloud-custom-tool bg-black absolute z-50 top-12 w-9 h-9 items-center justify-center left-2 shadow-none backdrop-blur-md p-2 rounded-full cursor-pointer transition hover:scale-105",title:"Download",onClick:()=>{let t=r.viewInfo[e.camera]?.filepath.split("/").pop();(0,H.bB)(r.viewInfo[e.camera].filepath).then(e=>{fetch(e).then(e=>e.blob()).then(e=>{let a=URL.createObjectURL(e),r=document.createElement("a");r.href=a,r.download=t||"file",r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r)})})},children:(0,o.jsx)(W.U01,{})})}),(0,o.jsxs)("div",{className:"flex justify-center gap-1 absolute bottom-[60px] left-1/2 transform -translate-x-1/2 z-50",children:[(0,o.jsx)("div",{className:`bg-black/50 backdrop-blur-md p-2 rounded-full cursor-pointer transition ${f?"pointer-events-none":"hover:scale-105"}`,onClick:()=>M(C),children:(0,o.jsx)(eK.pM3,{size:15})}),(0,o.jsx)("div",{className:`bg-black/50 backdrop-blur-md p-2 rounded-full cursor-pointer transition ${f?"pointer-events-none":"hover:scale-105"}`,onClick:()=>M(k),children:(0,o.jsx)(eK.irw,{size:15})}),(0,o.jsx)("div",{className:`bg-black/50 backdrop-blur-md p-2 rounded-full cursor-pointer transition ${f?"pointer-events-none":"hover:scale-105"}`,onClick:()=>M(N),children:(0,o.jsx)(eK.fOo,{size:15})}),(0,o.jsx)("div",{className:`bg-black/50 backdrop-blur-md p-2 rounded-full cursor-pointer transition ${f?"pointer-events-none":"hover:scale-105"}`,onClick:()=>M(S),children:(0,o.jsx)(eK.wi,{size:15})})]}),(0,o.jsxs)("div",{className:"absolute bottom-0 text-white p-1 rounded-b-lg rounded-tr-none rounded-tl-none flex flex-col w-full text-[9px] bg-black",children:[(0,o.jsxs)("div",{className:"flex flex-row",children:[(0,o.jsx)("p",{className:"leading-tight grow flex items-center",children:r.viewInfo[e.camera]&&(0,o.jsx)("div",{className:"w-full text-center",children:J()(r.viewInfo[e.camera].date).utc().format("M/D/YYYY h:mm A")})}),(0,o.jsx)("p",{className:"leading-tight grow flex items-center",children:r.viewInfo[e.camera]&&(0,o.jsxs)("div",{className:"w-full text-center",children:["Route: ",r.viewInfo[e.camera].route]})}),(0,o.jsx)("p",{className:"leading-tight grow flex items-center",children:r.viewInfo[e.camera]&&(0,o.jsxs)("div",{className:"w-full text-center",children:["Chainage: ",r.viewInfo[e.camera].chainage]})}),(0,o.jsx)("p",{className:"leading-tight grow flex items-center",children:r.viewInfo[e.camera]&&(0,o.jsx)("div",{className:"w-full text-center",children:r.viewInfo[e.camera].filepath.split("/").pop()})})]}),r.availableImageDates[e.camera]&&r.availableImageDates[e.camera].length>0&&(0,o.jsx)(lA,{camera:e.camera})]})]}):y?(0,o.jsx)("div",{className:"flex justify-center items-center relative min-h-[300px] max-h-[600px]",children:(0,o.jsx)("span",{className:"loading loading-spinner"})}):(0,o.jsxs)("div",{className:"flex items-center justify-center text-center text-white/70 flex-col gap-1 text-[14px] min-h-[300px] max-h-[600px]",children:[(0,o.jsx)(z.wft,{size:24}),r.viewInfo[e.camera]?`Image unavailable for camera ${l}`:"Click on a camera point on the map to view images"]})})})}let lE=so()(()=>Promise.all([a.e(9684),a.e(1499)]).then(a.bind(a,11499)),{loadableGenerated:{webpack:()=>[11499]},ssr:!1});function lT(){let{modalState:e,closeModal:t}=(0,tZ.O)(x.dW.PDFViewerModal),a=(0,h.useRef)(null),r=(0,h.useRef)(null),[s,l]=(0,h.useState)("");return(0,h.useEffect)(()=>{e.display?(l("confirmationmodal-"+(0,sF.A)()),a.current?.showModal(),(0,v.Fr)()&&(document.documentElement.style.display="none",setTimeout(()=>{document.documentElement.style.display="block"},10))):a.current?.close()},[e.display]),(0,o.jsx)(o.Fragment,{children:(0,o.jsxs)(t4,{modalType:x.dW.PDFViewerModal,closeModal:()=>{t(),r.current?.click()},defaultPosition:{x:100,y:100},defaultSize:{width:800,height:750},backgroundColor:"white",lockRatio:"nolock",title:"PDF",defaultMinSize:{width:500,height:300},children:[(0,o.jsx)("input",{type:"checkbox",id:s,className:"modal-toggle"}),(0,o.jsx)("div",{className:"flex flex-col h-full",children:(0,o.jsx)(lE,{modalView:!0})})]})})}var lI=a(15368),lP=a.n(lI),lF=a(91238),lO=a.n(lF);let lR=(e,t)=>{let a=[];if(e.properties.folder_path)for(let r of e.properties.folder_path.files)"image"!=(0,v.ti)(r)||r.toLowerCase().endsWith("thumbnail.jpg")||r.toLowerCase().endsWith("thumbnail.png")||a.push(t[e.properties.folder_path.base+"/"+r]);let r=e.create_date||e.properties.date,s=e.location.lat.toFixed(6),l=e.location.lon.toFixed(6),i=e.properties.description?lP()(e.properties.description):"";return`
28  <div class="card">
29    <p><strong>${lP()(e.properties.title)}</strong></p>
30    <p>${lP()(e.first_name+" "+e.last_name)}</p>
31    <p>${r?r.toString().replace("Z",""):"No date provided"}</p>
32    <p>Latitude: ${s}, Longitude: ${l}</p>
33    <p>${i||"No description provided"}</p>
34    ${a?a.map(e=>`<img src="${encodeURI(e)}" width="400px" height="400px">`).join(""):""}
35  </div>
36  `};var l$=a(32417);let lz=({unreadClicked:e,setUnreadClicked:t,allMentions:a,currentMentions:r,setCurrentMentions:s,readStatus:l,showThreads:i,setShowThreads:n,userMap:c,setCountUnread:d,setReadStatus:u,projectContainer:p,type:m,showMentions:x,setShowMentions:f,buttonRef:g,onUpdate:y})=>{let b=(0,h.useRef)(null),j="Removed User";(0,h.useEffect)(()=>{let e=e=>{let t=e.target;b.current&&!b.current.contains(t)&&g.current&&!g.current.contains(t)&&f(!1)};return x&&!i.display?document.addEventListener("mousedown",e):document.removeEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[x,i]),(0,h.useEffect)(()=>{e?s(a.filter(e=>!l[e.notification_id])):s([...a].sort((e,t)=>
36{let a=l[e.notification_id];return a===l[t.notification_id]?0:a?1:-1}))},[e,l]);let w=e=>{let t=e.slice(0,155)+(e.length>155?"...":"");return(0,Y.W7)(t,c)},N=e=>{let t;return(t=e.thread_replier?c[e.thread_replier]:c[e.author_id])?t.first_name+" "+t.last_name:j},S=async e=>{let t="";if(e.properties.folder_path&&(t=await (0,H.bB)(p+`/${m}/`+e.properties.folder_path.base+"/"+e.properties.folder_path?.files[0])),"notes"==m)n({...i,display:!0,id:e.id,title:e.properties.title,description:e.properties.description,create_date:e.create_date,author:c[e.author_id]?c[e.author_id].first_name+" "+c[e.author_id].last_name:j,author_id:e.author_id,file_path:e.properties.folder_path?t:void 0,note3DData:"notes"===m&&e.properties.folder_path?{filepath:null,folder_path:JSON.stringify(e.properties.folder_path)||null,properties:{...e.properties,data:JSON.stringify(e.properties.data)}}:void 0});else n({...i,display:!0,id:e.id,title:e.properties.title,category:e.properties.category,severity:e.properties.severity,description:e.properties.description,create_date:e.create_date,author:c[e.author_id].first_name+" "+c[e.author_id].last_name,author_id:e.author_id,file_path:e.properties.folder_path?t:void 0,pulseType:"alert",...{reviewed:e.reviewed,verify_status:e.properties.verify_status??null}})},k=async(e,t)=>{u(t=>({...t,[e]:!0})),d(e=>e-1),await (0,Y.oq)([e]),y(t,[e])};return(0,o.jsxs)("div",{ref:b,className:"absolute left-48 z-50 bg-white shadow-xl rounded-lg w-[400px] text-sm p-2",children:[(0,o.jsxs)("div",{className:"flex flex-row mb-1",children:[(0,o.jsx)(l$.A,{checked:e,onChange:()=>t(!e),inputProps:{"aria-label":"controlled"}}),(0,o.jsx)("span",{className:"text-gray-400 font-semibold mt-[9px]",children:"Unread"})]}),(0,o.jsx)("div",{className:"w-full h-px bg-gray-200"}),(0,o.jsx)("ul",{className:"overflow-auto bg-base-100",children:(0,o.jsx)("div",{className:"min-h-[260px] max-h-[360px]",children:r&&r.length>0?(0,o.jsx)(o.Fragment,{children:(0,o.jsx)("div",{className:"overflow-auto",children:(0,o.jsx)("ul",{className:"divide-y divide-gray-200",children:r&&r.map(e=>(0,o.jsx)("li",{className:`p-4 ${l[e.notification_id]?"bg-white":"bg-blue-50"} shadow cursor-pointer`,onClick:async()=>{await S(e),l[e.notification_id]||k(e.notification_id,e.id)},children:(0,o.jsx)("div",{className:"relative flex flex-row",children:(0,o.jsxs)("div",{className:"flex flex-row space-x-2",children:[e.thread_replier?c[e.thread_replier]?.profile_image?(0,o.jsx)(tY.A,{profile_image:c[e.thread_replier].profile_image}):(0,o.jsx)(tY.A,{name:N(e)}):c[e.author_id]?.profile_image?(0,o.jsx)(tY.A,{profile_image:c[e.author_id].profile_image}):(0,o.jsx)(tY.A,{name:N(e)}),(0,o.jsxs)("div",{className:"flex flex-col",children:[(0,o.jsxs)("div",{className:"flex flex-row justify-start space-x-1",children:[(0,o.jsx)("span",{className:"font-semibold text-gray-900",children:N(e)}),(0,o.jsxs)("span",{className:"text-gray-500",children:[" ",`\xb7 ${(0,v.Iv)(new Date(e.create_date).toISOString())}`]})]}),(0,o.jsxs)("span",{className:"text-gray-500",children:["Replying to ",(0,o.jsxs)("span",{className:"text-blue-500 font-semibold",children:["@",c[e.author_id]?c[e.author_id].first_name+" "+c[e.author_id].last_name:j]})]}),e.thread_content?(0,o.jsx)("span",{className:"text-gray-700 mt-2",dangerouslySetInnerHTML:{__html:w(e.thread_content)}}):(0,o.jsx)("span",{className:"text-gray-700 mt-2",dangerouslySetInnerHTML:{__html:w(e.properties.description)}})]})]})})},e.notification_id))})})}):(0,o.jsx)("div",{className:"text-center text-gray-400 text-sm p-4",children:"No mentions found"})})})]})};function lU({disabled:e,onExportPdf:t,onExportCsv:a}){return(0,o.jsxs)("div",{className:`dropdown dropdown-end ${e?"pointer-events-none":""}`,children:[(0,o.jsx)("button",{tabIndex:0,className:"btn btn-sm shadow tt-blue-button disabled:opacity-50 disabled:cursor-not-allowed",disabled:e,"data-tip":"Export selected",children:(0,o.jsx)(W.U01,{size:18})}),(0,o.jsxs)("ul",{className:"dropdown-content menu bg-white rounded-box z-20 w-40 p-1 shadow border border-gray-200 text-gray-800",children:[t&&(0,o.jsx)("li",{children:(0,o.jsxs)("button",{className:"flex items-center gap-2",onClick:t,children:[(0,o.jsx)(W.oSi,{size:14})," Export as PDF"]})}),a&&(0,o.jsx)("li",{children:(0,o.jsxs)("button",{className:"flex items-center gap-2",onClick:a,children:[(0,o.jsx)(W.emn,{size:14})," Export as CSV"]})})]})]})}function lW(e){let t=(0,ex.u)(),a=(0,eG.JY)(),r=(0,tH.C)(),s=(0,ef.N)(),l=(0,ew.u)(),i=(0,ev.O)(),{openModal:n}=(0,tZ.O)(x.dW.NotesModal),c=(0,h.useRef)(null),u=(0,h.useRef)(null),p=(0,h.useRef)(0),[f,g]=(0,h.useState)({column:"create_date",ascending:!1}),[b,j]=(0,h.useState)([]),[w]=(0,h.useState)(new Map),[N,S]=(0,h.useState)(0),[k,_]=(0,h.useState)(!1),[C,L]=(0,h.useState)([]),[D,A]=(0,h.useState)({dis
36play:!1,url:""}),[M,E]=(0,h.useState)({}),[T,I]=(0,h.useState)({}),[P,F]=(0,h.useState)(()=>({x:80,y:80,width:750,height:500})),[O,R]=(0,h.useState)({display:!1,id:0}),[z,U]=(0,h.useState)(!1),[G,q]=(0,h.useState)({display:!1,id:0,title:"",description:"",create_date:new Date,author:"Unknown",author_id:void 0,file_path:void 0,files:void 0,note3DData:void 0,coords:void 0,edit:!1,markerType:x.TG.note,keepSidePanelOpen:!1}),[Z,X]=(0,h.useState)(!1),[K,Q]=(0,h.useState)(!1),[ea,er]=(0,h.useState)(s.noteMentions),[es,el]=(0,h.useState)(!1),[ei,en]=(0,h.useState)(!0),[eo,ec]=(0,h.useState)({from:1,to:eB.rz}),[ed,eu]=(0,h.useState)(""),[ep,em]=(0,h.useState)(""),[eh,eg]=(0,h.useState)(""),[ey,eb]=(0,h.useState)(null),[ej,eN]=(0,h.useState)(""),[eS,ek]=(0,h.useState)(null),[e_,eC]=(0,h.useState)(""),[eL,eD]=(0,h.useState)(""),[eA,eM]=(0,h.useState)(null),[eE,eT]=(0,h.useState)(null),[eI,eP]=(0,h.useState)(""),[eF,eO]=(0,h.useState)("0"),[eR,e$]=(0,h.useState)(!1),[ez,eU]=(0,h.useState)(!1),{EmojiPickerComponent:eV,showEmojiPicker:eJ,setShowEmojiPicker:eq}=eW({onEmojiClick:function(e,t){t?.stopPropagation();let a=e.emoji,r=m.ff.find(e=>e.id===a);r?tt(r.id):tt(a==x.AT.none?x.AT.none:x.AT.custom),eP(e.imageUrl)},nullIcon:!0}),eY=JSON.parse(localStorage.getItem("project")||"{}"),{update:eH}=(0,et.xS)();(0,v.xR)(),(0,h.useEffect)(()=>{eg(a.layerFilterOptions.current.notes?.name||""),em(a.layerFilterOptions.current.notes?.title||""),eu(a.layerFilterOptions.current.notes?.description||""),eb(a.layerFilterOptions.current.notes?.dates?.from||null),eN(a.layerFilterOptions.current.notes?.dates?.from&&!isNaN(a.layerFilterOptions.current.notes.dates.from.getTime())?a.layerFilterOptions.current.notes.dates.from.toISOString().split("T")[0]:""),ek(a.layerFilterOptions.current.notes?.dates?.to||null),eC(a.layerFilterOptions.current.notes?.dates?.to&&!isNaN(a.layerFilterOptions.current.notes.dates.to.getTime())?a.layerFilterOptions.current.notes.dates.to.toISOString().split("T")[0]:""),eD(a.layerFilterOptions.current.notes?.note_lrs?.route||""),eM(a.layerFilterOptions.current.notes?.note_lrs?.from||null),eT(a.layerFilterOptions.current.notes?.note_lrs?.to||null),e$(!!a.layerFilterOptions.current.notes?.screen);let e=a.layerFilterOptions.current.notes?.icon?.toString();e?isNaN(Number(e))?(eO(x.AT.custom),eP(e||"")):(eO(e),eP(m.ff.find(t=>t.id===e)?.imgUrl||"")):(eO(x.AT.none),eP("")),en(!1)},[]),(0,h.useEffect)(()=>{eU(null!=a.layerFilterOptions.current.notes),e1()},[eH,s.refreshNotes,t]),(0,h.useEffect)(()=>{e.isOpen&&e1()},[e.isOpen]),(0,h.useEffect)(()=>{if(!e.isOpen||k)return;let t=requestAnimationFrame(()=>{u.current&&(u.current.scrollTop=p.current)});return()=>cancelAnimationFrame(t)},[e.isOpen,k,b]);let eZ=()=>{let e;return(ey||eS)&&(e={from:ey||void 0,to:eS||void 0}),{name:eh,title:ep,description:ed,icon:eF==x.AT.custom?eI:eF,dates:e,screen:eR?(0,v.i6)(a.map):void 0,doubleBB:!1,note_lrs:{route:eL,from:eA,to:eE}}},eX=async(e,t,r)=>{let s,l,{effectiveFilters:i,sort:n}=(s=t?null:eZ(),l=r?null:f,{effectiveFilters:ei?a.layerFilterOptions.current.notes:s,sort:l});return await (0,ee.GW)(i,n,eR,void 0,e)},eK=(e,t)=>{j(t.notes),S(t.count),w.set(e.from,t.notes)},eQ=async(e,t,a)=>{let r=a||eo;_(!0);let s=await eX(r,e,t),l=Math.max(1,Math.ceil(s.count/eB.rz));if(Math.max(1,Math.ceil(r.from/eB.rz))>l){let a,r={from:a=(l-1)*eB.rz+1,to:a+eB.rz-1};ec(r),w.clear();let s=await eX(r,e,t);eK(r,s),_(!1);return}eK(r,s),_(!1)},e1=async e=>{let t=e||eo;w.clear(),L([]),await eQ(!1,!1,t)},e2=(e=!1)=>{w.clear(),eQ(e,!1)},e5=()=>{document.querySelectorAll(".dropdown").forEach(function(e){e.open=!1})};(0,h.useEffect)(()=>{ei||eQ(!1,!1)},[f]);let e3=async t=>{_(!0),await (0,ee.B9)([t])?(e2(),y.Ay.success("Note deleted successfully"),e.onNoteDeleted([t])):_(!1),R({display:!1,id:0})},e4=async e=>{a.map.current&&globalThis.setTimeout(()=>{a.map.current?.flyTo({center:[e.location.lon,e.location.lat],zoom:a.map.current.getZoom()>14?a.map.current.getZoom():14,duration:eB.AD})},300)},e8=async e=>{try{let t=JSON.parse(localStorage.getItem("project")||"{}"),a=await (0,H.bB)(t?.container_name+"/notes/"+e);E(t=>({...t,[e]:a}))}catch(e){console.error("Error getting note picture URL:",e)}},e6=()=>{eu(""),eg(""),em(""),eb(null),eN(""),ek(null),eC(""),eP(""),e$(!1),eO("0"),eD(""),eM(null),eT(null)};(0,h.useEffect)(()=>{ei||(e6(),e2(void 0))},[e.resetModalFilter]);let e7=async()=>{e5(),e6(),ec({from:1,to:eB.rz}),a.layerFilterOptions.current.notes=null,e.onFilterChanged()},e9=async()=>{_(!0);let t=[],a=!1;for(let r=0;r<C.length;r++)t.push(C[r].toString()),C[r]===e.currentPanelKey&&(a=!0);let r=await (0,ee.B9)(t);U(!1),r?(e2(),y.Ay.success("Notes successfully deleted"),e.onNoteDeleted(t.map(e=>Number(e))),L([]),a&&e.closePanel()):_(!1)},te=async(t,r=!1)=>{e5();let s={from:1,to:eB.rz};t?s=t:(w.clear(),L([])),ec(s),_(!0);let l=w.get(s.from);r||!l?(t||(ez?a.layerFilterOptions.current.notes=eZ():a.layerFilterOptions.current.notes=null,e.onFilterChanged()),await eQ(!1,!1,s)):j(l||[]),_(!1)};function tt(e){e==eF&&eF!=x.AT.custom?(eO(x.AT.none),eP("")):eO(e)}(0,h.useEffect)(()=>
36{b&&(b.forEach(e=>{if(e.properties.folder_path)for(let t of e.properties.folder_path.files)e8(e.properties.folder_path.base+"/"+t)}),(async()=>{for(let e of b){if(!e||!e.properties||!e.properties.folder_path)continue;let t=e.properties.folder_path,a=await (0,H.bB)((0,v.ke)(t,eY,"notes"));I(t=>({...t,[e.id]:a}))}})())},[b]);let ta=async e=>{let t=e.selected*eB.rz+1,a=t+eB.rz-1,r={from:t,to:a};ec(r),te(r)},tr=async()=>{let e=Array.from(w.values()).flat().filter(e=>C.includes(e.id));await ts(e)},ts=async e=>{let t=`
37    <html>
38      <head>
39        <style>
40          header {
41            display: flex;
42            justify-content: space-between;
43            align-items: center;
44            width: 100%;
45            padding: 10px;
46          }
47
48          body {
49            font-family: Arial, sans-serif;
50            display: flex;
51            flex-direction: column;
52            align-items: center;
53            min-height: 100vh;
54            margin: 0;
55            background-color: #fffff;
56            padding: 10px;
57          }
58
59          .card {
60            background-color: #ffffff;
61            border: 2px solid #212121;
62            border-radius: 8px;
63            width: 85%;
64            overflow: hidden;
65            margin-top: 8px;
66            margin-bottom: 8px;
67            padding: 16px;
68          }
69
70          .card p {
71            margin: 8px 0;
72            color: #333;
73          }
74        </style>
75      </head>
76      <header>
77        <img src='/images/fusionmap_logo_hor.png' width=140px height=44px></img> 
78        <title>FusionMap Notes Export: {{PROJECT_TITLE}}</title>
79      </header>
80
81      <body>
82        <h1>{{PROJECT_TITLE}}</h1>
83        <button id='print-button'>Click to save to PDF</button>
84        {{DATA}}
85      </body>
86
87      <script>
88        let printButton = document.getElementById('print-button');
89
90        printButton.addEventListener('click', () => {
91          printButton.style.display = 'none';
92          window.print();
93          printButton.style.display = 'block';
94        });
95      </script>
96    </html>
97    `,a=i.project?.project_name||"No project name",r="";for(let t of e)r+=lR(t,M);t=(t=t.replaceAll("{{DATA}}",r)).replaceAll("{{PROJECT_TITLE}}",lP()(a));let s=window.open();s?(s.document.write(t),s.document.close()):y.Ay.error("Please allow tabs to be opened in your browser window.")},tl=(e,t)=>{let a=parseFloat(e.target.value);t(isNaN(a)?null:a)},ti=async(e,t=!1,a=!1)=>{let r=i.project?.container_name+"/notes/";e.properties.folder_path?.base&&(r+=e.properties.folder_path.base),q({markerType:x.TG.note,display:!0,id:e.id,coords:{lat:e.location.lat,lon:e.location.lon},title:e.properties.title,description:e.properties.description,create_date:new Date(e.create_date),author:e.first_name+" "+e.last_name,author_id:e.user_id,file_path:r,note3DData:{filepath:null,folder_path:JSON.stringify(e.properties.folder_path)||null,properties:{...e.properties,data:JSON.stringify(e.properties.data),lat:e.location.lat,lon:e.location.lon}},files:e.properties.folder_path?.files,edit:a,keepSidePanelOpen:t})},tn=e=>{ti(e,!1,!0)},to=e=>{r.setPdfUrl(M[(0,v.$S)(e.properties.folder_path)]),r.setPdfSource({source_type:x.Sw.NOTE,source_id:e.id}),n(x.dW.PDFViewerModal)};(0,h.useEffect)(()=>{G.display&&(e.toggleSidePanel((0,o.jsx)(al,{parentId:G.id,title:G.title,description:G.description,create_date:G.create_date,author:G.author,author_id:G.author_id||"",project:i.project,file_path:""!=G.file_path?G.file_path:void 0,files:G.files,onUpdateNote:t=>{e.onNoteUpdated(t),e1()},user:t?.user,source:x.Sw.NOTE,modalSource:"notesModal",coords:{lat:G.coords?.lat||0,lon:G.coords?.lon||0},markerType:G.markerType,noteData:G.note3DData,userMap:e.userMap,setNotePictureUrls:E,edit:G.edit}),{title:"Threads",key:G.id,icon:(0,o.jsx)(W.B2c,{}),keepSidePanelOpen:G.keepSidePanelOpen}),G.display=!1,G.keepSidePanelOpen=!1)},[G.display]);let tc=e=>e.user_id===t?.user?.id||i.project&&(0,v._A)(t?.user,i.project.project_uuid),td=h.useMemo(()=>C.some(e=>{let t=b.find(t=>t.id===e);return!!t&&!tc(t)}),[C,b,t,i.project]),tu=eo.from,tp=eo.from+b.length-1,tm=N>eB.rz?180:140,th=P?P.height-tm:"100%";return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(V.A,{isOpen:O.display,onDelete:()=>{e3(O.id),e.closePanel(O.id)},closeModal:()=>R({display:!1,id:0})}),(0,o.jsx)(V.A,{isOpen:z,onDelete:()=>e9(),closeModal:()=>U(!1)}),e.isOpen&&(0,o.jsxs)(t4,{modalType:x.dW.NotesModal,defaultPosition:{x:P.x,y:P.y},defaultSize:{width:P.width,height:P.height},defaultMinSize:{width:350,height:300},backgroundColor:"white",setModalSize:e=>F(t=>({...t,width:e.width,height:e.height})),lockRatio:"nolock",title:"Notes",children:[(0,o.jsx)(B,{isOpen:D.display,closeModal:()=>A({display:!1,url:""}),url:D.url}),(0,o.jsxs)("div",{className:"relative mt-[15px] m-5",children:[(0,o.jsxs)("div",{className:"flex justify-between flex-row mb-3",children:[(0,o.jsxs)("div",{className:"flex flex-row gap-2",children:[(0,o.jsxs)("details",{className:"dropdown dropdown-right z-30",children:[(0,o.jsxs)("summary",{className:`
98                  flex items-center justify-center btn btn-sm shadow
99                  ${P?.width<400?"tooltip tooltip-bottom font-normal":""}
100                `,"data-tip":"Filter",onClick:e=>{e.stopPropagation(),Q(!1)},children:[(0,o.jsx)(e0.YsJ,{size:11}),!P||P.width>400&&" Filter"]}),(0,o.jsx)("ul",{className:"p-3 shadow menu dropdown-content z-[1] bg-base-100 rounded-box w-80",children:(0,o.jsxs)("div",{className:"flex flex-col w-full",children:[(0,o.jsxs)("div",{className:"flex items-center mt-3 justify-between gap-3",children:[(0,o.jsx)("input",{type:"text",placeholder:"User",value:eh,onChange:e=>{eg(e.target.value)},className:"input input-sm w-full text-black"}),(0,o.jsx)("input",{type:"text",placeholder:"Title",value:ep,onChange:e=>{em(e.target.value)},className:"input input-sm w-full text-black"})]}),(0,o.jsxs)("div",{className:"flex mt-3 items-center justify-between gap-3",children:[(0,o.jsx)("input",{type:"text",placeholder:"Description",value:ed,onChange:e=>{eu(e.target.value)},className:"input input-sm w-[49%] text-black"}),(0,o.jsx)("div",{className:"flex w-[49%]",children:(0,o.jsx)("div",{tabIndex:0,className:"btn btn-sm w-16 h-[30px]! inline-flex items-center justify-center",onClick:()=>eq(!eJ),children:"0"==eF?(0,o.jsx)("div",{className:"mx-auto text-[11px] font-normal leading-3 opacity-60",children:"No icon"}):(0,o.jsx)(d(),{src:eI,alt:"current symbol",width:20,height:20,className:"block mx-auto"})},"icon")})]}),(0,o.jsxs)("div",{className:"flex w-full text-black mt-3 gap-3",children:[(0,o.jsxs)("div",{className:"flex flex-1 basis-0 min-w-0 text-black flex-col text-center",children:[(0,o.jsx)("span",{className:"opacity-70",children:"From:"}),(0,o.jsx)("input",{type:"date",value:ej,onChange:e=>{eb(new Date(e.target.value)),eN(e.target.value)},className:"input w-full min-w-0 max-w-full box-border text-black text-left pr-10 pl-0 text-xs"},"start-date-input")]}),(0,o.jsxs)("div",{className:"flex flex-1 basis-0 min-w-0 text-black flex-col text-center",children:[(0,o.jsx)("span",{className:"opacity-70",children:"To:"}),(0,o.jsx)("input",{type:"date",value:e_,onChange:e=>{ek(new Date(e.target.value)),eC(e.target.value)},className:"input w-full min-w-0 max-w-full box-border text-black text-left pr-10 pl-0 text-xs"},"end-date-input")]})]}),i.project?.lrs_included&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:"flex w-full text-black flex-col text-center mt-2",children:[(0,o.jsx)("span",{className:"opacity-70",children:"Route:"}),(0,o.jsxs)("select",{value:eL,className:"select select-sm select-bordered w-full py-0",onChange:e=>eD(e.target.value||""),children:[(0,o.jsx)("option",{value:"",children:"Any"}),i.project?.lrs_included&&l.availableRoutes&&l.availableRoutes.map((e,t)=>(0,o.jsx)("option",{value:e.route,children:e.route},t))]})]}),eL&&(0,o.jsx)(o.Fragment,{children:(0,o.jsxs)("div",{className:"flex text-black mt-2 justify-between gap-3",children:[(0,o.jsxs)("div",{className:"flex w-full text-black flex-col text-center",children:[(0,o.jsx)("span",{className:"opacity-70",children:"From:"}),(0,o.jsx)("input",{className:"input input-sm w-full text-black",value:null==eA?"":eA,onChange:e=>{eM(e.target.value)},onBlur:e=>{tl(e,eM)}})]}),(0,o.jsxs)("div",{className:"flex w-full text-black flex-col text-center",children:[(0,o.jsx)("span",{className:"opacity-70",children:"To:"}),(0,o.jsx)("input",{className:"input input-sm w-full text-black",value:null==eE?"":eE,onChange:e=>{eT(e.target.value)},onBlur:e=>{tl(e,eT)}})]})]})})]}),(0,o.jsx)("div",{className:"flex mt-2 w-full",children:(0,o.jsxs)("div",{className:"form-control w-full gap-2 flex flex-col my-2",children:[(0,o.jsxs)("label",{className:"label flex w-full cursor-pointer items-center justify-between gap-3",children:[(0,o.jsx)("span",{className:"label-text font-medium",children:"Filter by Visibility"}),(0,o.jsx)("input",{type:"checkbox",checked:eR,onChange:()=>{e$(!eR)},className:"toggle toggle-sm"})]}),(0,o.jsxs)("div",{className:"label flex w-full cursor-pointer items-center justify-between gap-3",children:[(0,o.jsx)("span",{className:"label-text font-medium",children:"Apply Filters to Map"}),(0,o.jsx)("input",{type:"checkbox",checked:ez,onChange:()=>eU(e=>!e),className:"toggle toggle-sm"})]})]})}),(0,o.jsxs)("div",{className:"border-t border-black/10 flex items-center gap-2 justify-center",children:[(0,o.jsx)("div",{onClick:e7,className:"btn mt-3 btn-sm",children:"Reset"}),(0,o.jsx)("div",{onClick:()=>te(null),className:"btn mt-3 btn-sm tt-blue-button",children:"Apply"})]})]})})]}),(0,o.jsxs)("div",{className:`
101                flex items-center justify-center btn btn-sm shadow relative z-20
102                ${P?.width<500?"tooltip tooltip-bottom font-normal":""}
103              `,"data-tip":"Mentions",onClick:()=>Q(e=>!e),ref:c,children:[(0,o.jsx)(e0.T35,{size:14}),!P||P.width>500&&" Mentions",s.noteUnreadCount>0&&(0,o.jsx)("div",{className:"badge absolute badge-xs border-none bg-red-400 shadow rounded-lg h-5 min-w-[20px] w-auto -right-3 mb-7 text-[12px] font-semibold text-white",children:s.noteUnreadCount})]}),K&&(0,o.jsx)(lz,{unreadClicked:es,setUnreadClicked:el,allMentions:s.noteMentions,currentMentions:ea,setCurrentMentions:er,readStatus:s.noteReadStatus,showThreads:G,setShowThreads:q,setReadStatus:s.setNoteReadStatus,userMap:e.userMap,setCountUnread:s.setNoteUnreadCount,type:"notes",projectContainer:eY.container_name,showMentions:K,setShowMentions:Q,buttonRef:c,onUpdate:e.onNotificationUpdated})]}),(0,o.jsxs)("div",{className:"flex flex-wrap gap-2 justify-end",children:[(0,o.jsx)("button",{className:"btn btn-sm shadow",onClick:()=>X(!Z),children:Z?(0,o.jsx)($.XfR,{size:22}):(0,o.jsx)($.mOA,{size:22})}),(0,o.jsxs)("div",{className:"dropdown dropdown-end",children:[(0,o.jsxs)("button",{tabIndex:0,className:"btn btn-sm shadow",children:[(0,o.jsx)(W.txO,{size:18}),C.length>0&&(0,o.jsx)("span",{className:"absolute top-0 right-0 bg-tt-blue text-white text-xs font-bold rounded-full w-4 h-4 flex items-center justify-center",children:C.length})]}),(0,o.jsxs)("ul",{className:"dropdown-content menu bg-white rounded-box z-20 w-40 p-1 shadow border border-gray-200 text-gray-800",children:[(0,o.jsx)("li",{children:(0,o.jsx)("button",{onClick:()=>{let e=b.map(e=>e.id);L(t=>Array.from(new Set([...t,...e])))},children:"Select this page"})}),(0,o.jsx)("li",{children:(0,o.jsx)("button",{onClick:()=>{L([])},children:"Select none"})})]})]}),C.length>0&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(lU,{disabled:!1,onExportPdf:tr,onExportCsv:()=>{let e=Array.from(w.values()).flat().filter(e=>C.includes(e.id)),t=i.project?.lrs_included,a=`notes_${i.project?.project_name||"export"}.csv`,r=rx().unparse(rm(e,t));(0,v.tr)(r,a)}}),(0,o.jsx)("button",{className:"btn btn-sm shadow tt-blue-button disabled:opacity-50 disabled:cursor-not-allowed",onClick:()=>{U(!0)},disabled:td,title:td?"You cannot delete one or more selected notes":"Delete selected",children:(0,o.jsx)(W.WeY,{size:18})})]})]})]}),(0,o.jsx)("div",{ref:u,className:"force-scrollbar",onScroll:()=>{if(k)return;let e=u.current;e&&(p.current=e.scrollTop)},style:{width:"100%",height:th,overflow:"auto"},children:k?(0,o.jsx)("div",{className:"flex h-full min-h-[220px] items-center justify-center",children:(0,o.jsx)("span",{className:"loading loading-spinner",style:{color:"black"}})}):(0,o.jsx)(o.Fragment,{children:b&&b.length>0?(0,o.jsx)(o.Fragment,{children:Z?(0,o.jsx)("div",{className:"grid gap-3 text-black grid-cols-[repeat(auto-fill,minmax(220px,1fr))]",children:b.map(t=>(0,o.jsxs)("div",{className:"note-container border-black/10 border rounded-lg  shadow-sm flex flex-col justify-between",children:[(0,o.jsxs)("div",{className:"p-4 flex flex-col justify-between",children:[(0,o.jsxs)("div",{className:"font-bold text-[14px]",children:[m.ff.map(e=>e.id===t.properties.data?.icon?(0,o.jsx)("img",{src:e.imgUrl,width:"20",height:"20"},e.id):null),t.properties.title]}),(0,o.jsxs)("div",{className:"flex items-center gap-2 opacity-90",children:[(0,o.jsx)(W.kSq,{size:11}),t.first_name+" "+t.last_name]}),(0,o.jsxs)("div",{className:"flex items-center gap-2 opacity-90",children:[(0,o.jsx)(W.Zki,{size:10})," ",(0,o.jsx)("span",{dangerouslySetInnerHTML:{__html:(0,Y.W7)(t.properties.description,e.userMap)}})]}),(0,o.jsxs)("div",{className:"flex items-center gap-2 opacity-90",children:[(0,o.jsx)(W.D7y,{size:10})," ",J()(t.create_date).format("M/D/YYYY h:mm A")]}),(0,o.jsx)("div",{className:"mt-2",children:t?.properties.folder_path&&t?.properties.folder_path.files.length>0&&(0,o.jsx)("div",{children:"image"===(0,v.ti)((0,v.$S)(t.properties.folder_path))?(0,o.jsx)("img",{onClick:()=>A({display:!0,url:M[t.properties.folder_path?(0,v.$S)(t.properties.folder_path):0]}),src:M[(0,v.$S)(t.properties.folder_path)],className:"rounded-md cursor-pointer",alt:"Image",style:{width:"100%",height:90,objectFit:"cover"}}):"video"===(0,v.ti)((0,v.$S)(t.properties.folder_path))?(0,o.jsxs)("video",{controls:!0,width:"100%",height:40,className:"rounded-md",children:[(0,o.jsx)("source",{src:M[(0,v.$S)(t.properties.folder_path)],type:"video/mp4"}),"Your browser does not support the video tag."]}):"pdf"===(0,v.ti)((0,v.$S)(t.properties.folder_path))?(0,o.jsxs)("div",{onClick:()=>to(t),onKeyDown:()=>to(t),className:"btn btn-sm rounded-md p-2 opacity-80 shadow items-center justify-center flex gap-2 cursor-pointer",children:[(0,v.sW)((0,v.ti)((0,v.$S)(t.properties.folder_path))),(0,o.jsx)("span",{className:"text-md font-bold",children:(0,v.ti)((0,v.$S)(t.properties.folder_path)).toUpperCase()})]}):(0,o.jsx)("a",{href:M[(0,v.$S)(t.properties.folder_path)],download:!0,children:(0,o.jsxs)("div",{className:"btn btn-sm rounded-md p-2 opacity-80 shadow items-center justify-center flex gap-2",children:[(0,v.sW)((0,v.ti)((0,v.$S)(t.properties.folder_path))),(0,o.jsx)("span",{className:"text-md font-bold",children:(0,v.ti)((0,v.$S)(t.properties.folder_path)).toUpperCase()})]})})})})]}),(0,o.jsxs)("div",{className:"flex flex-wrap gap-1 px-4 pb-3",children:[(0,o.jsx)("button",{onClick:()=>{e4(t),ti(t,!0)}
103,className:"btn btn-outline btn-xs text-xs",title:"Zoom to Note",children:(0,o.jsx)(W.YQq,{})}),(0,o.jsx)("button",{onClick:()=>ti(t),className:"btn btn-outline btn-xs text-xs",title:"Threads",children:(0,o.jsx)(W.PxB,{})}),tc(t)&&(0,o.jsx)("button",{onClick:()=>tn(t),className:"btn btn-outline btn-xs text-xs",title:"Edit Note",children:(0,o.jsx)(W.dJk,{})}),(0,o.jsx)("button",{onClick:()=>(0,v.VJ)(t.location.lon,t.location.lat),className:"btn btn-outline btn-xs text-xs",title:"Navigate To",children:(0,o.jsx)(W.Yad,{})}),tc(t)&&(0,o.jsx)("button",{onClick:()=>R({display:!0,id:t.id}),className:"btn btn-outline btn-xs text-xs hover:bg-red-800",title:"Delete Note",children:(0,o.jsx)(W.WeY,{})})]})]},t.id))}):(0,o.jsx)("div",{className:"transition-opacity text-black rounded-lg duration-300",children:(0,o.jsxs)("table",{className:"table relative",children:[(0,o.jsx)("thead",{className:"sticky top-0 bg-[#f9f9f9] z-10 shadow-sm",children:(0,o.jsx)("tr",{children:[{label:"Action",columnId:null},...rp(i.project?.lrs_included),{label:"File",columnId:null},{label:"Select",columnId:null}].map((e,t)=>{var a;return(0,o.jsx)("th",{children:e.columnId?(0,o.jsxs)("button",{onClick:()=>{var t;e.columnId&&(t=e.columnId,g(e=>({column:t,ascending:e?.column!==t||!e.ascending})),w.clear(),L([]),ec({from:1,to:eB.rz}))},className:"sort-button hover:bg-gray-100 hover:text-gray-800 flex items-center space-x-1",children:[e.label,(a=e.columnId,f?.column===a?f.ascending?(0,o.jsx)(W.Ob1,{size:9,className:"ml-1"}):(0,o.jsx)(W.D_L,{size:9,className:"ml-1"}):(0,o.jsx)(W.gER,{size:9,className:"ml-1"}))]}):e.label},t)})})}),(0,o.jsx)("tbody",{children:b.map((t,a)=>(0,o.jsxs)("tr",{className:`text-[12px] ${a%2==1?"bg-[#f2f2f2]":"bg-[#fafafa]"}`,children:[(0,o.jsxs)("td",{children:[(0,o.jsx)("button",{onClick:()=>{e4(t),ti(t,!0)},className:"btn btn-outline btn-xs text-xs m-[2px]",title:"Zoom to Note",children:(0,o.jsx)(W.YQq,{})}),(0,o.jsxs)("details",{className:"dropdown dropdown-start fm-dropdown dropdown-close-outside",children:[(0,o.jsx)("summary",{className:"btn btn-outline btn-xs text-xs m-[2px]",title:"Show more options",children:(0,o.jsx)(W.mqA,{})}),(0,o.jsxs)("ul",{className:"p-2 shadow menu dropdown-content z-1 bg-base-100 rounded-box w-52",children:[(0,o.jsx)("li",{onClick:()=>{ti(t)},children:(0,o.jsxs)("a",{children:[" ",(0,o.jsx)(W.PxB,{})," Threads"]})}),tc(t)&&(0,o.jsx)("li",{onClick:()=>{tn(t)},children:(0,o.jsxs)("a",{children:[(0,o.jsx)(W.dJk,{})," Edit"]})}),(0,o.jsx)("li",{onClick:()=>(0,v.VJ)(t.location.lon,t.location.lat),children:(0,o.jsxs)("a",{children:[(0,o.jsx)(W.Yad,{})," Navigate"]})}),tc(t)&&(0,o.jsx)("li",{className:"text-red-500",onClick:()=>{R({display:!0,id:t.id})},children:(0,o.jsxs)("a",{children:[(0,o.jsx)(W.WeY,{})," Delete"]})})]})]})]}),(0,o.jsx)("td",{children:t.first_name+" "+t.last_name}),(0,o.jsx)("td",{children:t.properties.data?.icon_type==="custom"?(0,o.jsx)("img",{src:"string"==typeof t.properties.data?.icon?t.properties.data.icon:void 0,width:"20",height:"20"},t.id):m.ff.map(e=>e.id==t.properties.data?.icon?(0,o.jsx)("img",{src:e.imgUrl,width:"20",height:"20"},e.id):null)}),(0,o.jsx)("td",{children:t.properties.title}),(0,o.jsx)("td",{children:(0,o.jsx)("span",{dangerouslySetInnerHTML:{__html:(0,Y.W7)(t.properties.description,e.userMap)}})}),(0,o.jsx)("td",{children:J()(t.create_date).format("M/D/YYYY h:mm A")}),i.project?.lrs_included&&(0,o.jsx)("td",{children:t.properties.lrs?.route}),i.project?.lrs_included&&(0,o.jsx)("td",{children:t.properties.lrs?.from}),i.project?.lrs_included&&(0,o.jsx)("td",{children:t.properties.lrs?.to}),(0,o.jsx)("td",{children:t?.properties.folder_path&&t?.properties.folder_path.files.length>0&&(0,o.jsxs)("button",{className:"flex",onClick:()=>ti(t),children:["image"==(0,v.ti)((0,v.$S)(t.properties.folder_path))?(0,o.jsx)("img",{src:T[t.id],className:"rounded-md cursor-pointer shrink-0",width:"70",height:40,alt:"Image",style:{width:70,height:40,objectFit:"cover"}}):"video"===(0,v.ti)((0,v.$S)(t.properties.folder_path))?(0,o.jsxs)("video",{controls:!0,width:"70",height:40,className:"rounded-md",children:[(0,o.jsx)("source",{src:M[(0,v.$S)(t.properties.folder_path)],type:"video/mp4"}),"Your browser does not support the video tag."]}):"pdf"===(0,v.ti)((0,v.$S)(t.properties.folder_path))?(0,o.jsxs)("div",{role:"button",onClick:()=>{to(t)},onKeyDown:()=>{to(t)},className:"btn btn-sm rounded-md p-2 opacity-80 shadow items-center justify-center flex gap-2",children:[(0,v.sW)((0,v.ti)((0,v.$S)(t.properties.folder_path))),(0,o.jsx)("span",{className:"text-md font-bold",children:(0,v.ti)((0,v.$S)(t.properties.folder_path)).toUpperCase()})]}):(0,o.jsxs)("div",{className:"btn btn-sm rounded-md p-2 opacity-80 shadow items-center justify-center flex gap-2",children:[(0,v.sW)((0,v.ti)((0,v.$S)(t.properties.folder_path))),(0,o.jsx)("span",{className:"text-md font-bold",children:(0,v.ti)((0,v.$S)(t.properties.folder_path)).toUpperCase()})]}),(0,o.jsx)("div",{className:"flex flex-row items-center justify-center",children:(0,o.jsxs)("span",{className:`${t.properties.folder_path?.files?.filter(e=>!e.includes("thumbnail")).length>1?"flex":"hidden"} text-black text-md opacity-60 underline pl-2`,children:[" ","+"+(t.properties.folder_path?.files?.filter(e=>!e.includes("thumbnail")).length-1)]})})]})}),(0,o.jsx)("td",{className:"text-center",children:(0,o.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:C.includes(t.id),onChange:()=>{var e;return e=t.id,void L(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},title:""})})]},t.id))})]})})}):(0,o.jsx)("div",{className:"flex h-full min-h-[220px] items-center justify-center px-6",children:(0,o.jsxs)("div",{className:"text-center text-sm text-black/80 space-y-2 max-w-lg",children:[(0,o.jsx)("p",{children:"No notes in this project so far"}),(0,o.jsxs)("p",{className:"inline-flex flex-wrap items-center justify-center gap-1 text-[13px] text-black/50",children:[(0,o.jsx)("span",{children:"To create a note, click on the map then click on the"}),(0,o.jsxs)("span",{className:"inline-flex items-center gap-1 font-bold text-black/80",children:[(0,o.jsx)(W.R7b,{size:16}),(0,o.jsx)("span",{children:"Note"})]}),(0,o.jsx)("span",{children:"button, or right-click"})]})]})})})}),N>eB.rz&&(0,o.jsxs)("div",{className:"pagination-cont",children:[(0,o.jsx)("p",{children:Math.ceil(eo.from/eB.rz)}),(0,o.jsx)(lO(),{breakLabel:"...",nextLabel:">",onPageChange:ta,pageRangeDisplayed:5,previousLabel:"<",pageClassName:"page-item cursor-pointer",previousClassName:"page-item cursor-pointer",nextClassName:"page-item cursor-pointer",breakClassName:"page-item cursor-pointer",containerClassName:"pagination",activeClassName:"active",forcePage:Math.ceil(eo.from/eB.rz)-1,pageCount:Math.ceil(N/eB.rz),renderOnZeroPageCount:null})]}),N>0&&(0,o.jsxs)("div",{className:"mt-2.5 mb-0 w-full text-center text-xs text-gray-400","data-testid":"notes-count-label",children:[tu,"-",tp," of ",N]}),eV]})]})]})}function lB({alertId:e,loading:t,onSend:a,location:r,showLabel:s=!1,menuItem:l=!1,plain:i=!1,size:n="xs"}){let c="";return c=i?"cursor-pointer border-0 bg-transparent p-0":l?"w-full justify-start":`btn btn-outline btn-${n} ${"sm"===n?"text-[14px]":"text-xs"}`,(0,o.jsx)("button",{type:"button","data-testid":`alert-notification-action-${r}-${e}`,"aria-label":`Send alert notification for alert ${e}`,className:c,title:"Send alert notification",onClick:a,disabled:t,children:t?(0,o.jsx)("span",{className:"loading loading-spinner loading-xs","aria-label":"Sending alert notification"}):(0,o.jsxs)("span",{className:"flex items-center gap-2",children:[(0,o.jsx)(W.Y2n,{"aria-hidden":"true"}),s&&"Send notification"]})})}function lV({isOpen:e,onCancel:t,onConfirm:a,alertCount:r=1}){let s=(0,h.useRef)(null);(0,h.useEffect)(()=>{e?s.current?.showModal():s.current?.close()},[e]);let l=()=>{t(),s.current?.close()};return(0,o.jsxs)("dialog",{ref:s,className:"modal text-black z-46","data-testid":"send-alert-notification-confirmation","aria-labelledby":"send-alert-notification-confirmation-title","aria-describedby":"send-alert-notification-confirmation-description",onCancel:e=>{e.preventDefault(),l()},children:[(0,o.jsxs)("div",{className:"modal-box",children:[(0,o.jsx)("button",{type:"button",className:"btn btn-sm btn-circle absolute right-2 top-2","aria-label":"Close confirmation dialog",onClick:l,children:"✕"}),(0,o.jsxs)("h2",{id:"send-alert-notification-confirmation-title",className:"text-center font-bold text-[14px] !mt-0",children:["Are you sure you want to send ",1===r?"this alert notification":`these ${r} alert notifications`,"?"]}),(0,o.jsxs)("p",{id:"send-alert-notification-confirmation-description",className:"sr-only",children:["This will queue email notifications for the selected alert",1===r?"":"s","."]}),(0,o.jsxs)("div",{className:"flex gap-2 justify-center mt-4 mb-2",children:[(0,o.jsx)("button",{type:"button",className:"btn btn-sm btn-white",onClick:l,"data-testid":"send-alert-notification-cancel",children:"Cancel"}),(0,o.jsx)("button",{type:"button",className:"btn btn-sm btn-neutral tt-blue-button",onClick:()=>{a(),s.current?.close()},"data-testid":"send-alert-notification-confirm",children:"Send notification"})]})]}),(0,o.jsx)("button",{type:"button",className:"modal-backdrop","aria-label":"Close",onClick:l})]})}function lG(e){let t=(0,ex.u)(),a=(0,eG.JY)(),r=(0,tH.C)(),s=(0,eg.ZM)(),l=(0,ev.O)(),i=!!(l.project&&(0,v._A)(t?.user,l.project.project_uuid)),n=l.project?.notificationsEnabled===!0,{openM
103odal:c}=(0,tZ.O)(x.dW.AlertsModal),d=(0,h.useRef)(null),u=(0,h.useRef)(null),p=(0,h.useRef)(0),[m,f]=(0,h.useState)({column:"create_date",ascending:!1}),[g,b]=(0,h.useState)([]),[j,w]=(0,h.useState)([]),[N,S]=(0,h.useState)(new Map),[k,_]=(0,h.useState)(!1),[C,L]=(0,h.useState)({display:!1,url:""}),[D,A]=(0,h.useState)({}),[M,E]=(0,h.useState)({}),[T,I]=(0,h.useState)(()=>({x:80,y:80,width:750,height:500})),[P,F]=(0,h.useState)({display:!1,id:0}),[O,R]=(0,h.useState)(!1),[z,U]=(0,h.useState)({display:!1,id:0,category:"",severity:3,title:"",description:"",create_date:new Date,author:"Unknown",author_id:void 0,geojson:void 0,file_path:void 0,coords:void 0,edit:!1,markerType:x.TG.alert,keepSidePanelOpen:!1,files:void 0,reviewed:!1,verify_status:null}),[G,q]=(0,h.useState)(0),[Z,X]=(0,h.useState)(new Set),[K,Q]=(0,h.useState)(new Set),[ee,ea]=(0,h.useState)(new Set),er=(0,h.useRef)(new Set),[es,el]=(0,h.useState)(null);(0,h.useEffect)(()=>{e.isOpen||el(null)},[e.isOpen]);let ei=(0,h.useRef)(new Map),en=(0,h.useRef)(new Map),[eo,ec]=(0,h.useState)({from:1,to:eB.rz}),[ed,eu]=(0,h.useState)(!1),[ep,em]=(0,h.useState)(!1),[eh,ef]=(0,h.useState)(s.alertMentions),[ey,eb]=(0,h.useState)(!1),[ej,ew]=(0,h.useState)(!0),[eN,eS]=(0,h.useState)(""),[ek,e_]=(0,h.useState)(""),[eC,eL]=(0,h.useState)(""),[eD,eA]=(0,h.useState)(""),[eM,eE]=(0,h.useState)(null),[eT,eI]=(0,h.useState)(null),[eP,eF]=(0,h.useState)(""),[eO,eR]=(0,h.useState)(null),[e$,ez]=(0,h.useState)(""),[eU,eW]=(0,h.useState)(!1),[eV,eJ]=(0,h.useState)(null),[eq,eY]=(0,h.useState)(!1),eH=(0,h.useRef)(void 0),eZ=(0,h.useRef)(!1);(0,h.useEffect)(()=>{if(a.layerFilterOptions.current.alerts||l.project){if(a.layerFilterOptions.current.alerts){eH.current=a.layerFilterOptions.current.alerts,eL(a.layerFilterOptions.current.alerts.issuer||""),e_(a.layerFilterOptions.current.alerts.title||""),eS(a.layerFilterOptions.current.alerts.description||""),eA(a.layerFilterOptions.current.alerts.category||"");let e=a.layerFilterOptions.current.alerts.visibleSeverityLevels,t=a.layerFilterOptions.current.alerts.severity;eE(e??(void 0===t?null:[t])),eI(a.layerFilterOptions.current.alerts.dates?.from||null),eF(a.layerFilterOptions.current.alerts.dates?.from&&!isNaN(a.layerFilterOptions.current.alerts.dates?.from.getTime())?(0,v.rm)(a.layerFilterOptions.current.alerts.dates.from,!1):""),eR(a.layerFilterOptions.current.alerts.dates?.to||null),ez(a.layerFilterOptions.current.alerts.dates?.to&&!isNaN(a.layerFilterOptions.current.alerts.dates?.to.getTime())?(0,v.rm)(a.layerFilterOptions.current.alerts.dates.to,!1):""),eW(a.layerFilterOptions.current.alerts?.screen!==void 0),eJ(a.layerFilterOptions.current.alerts?.reviewed??null)}else if(!eZ.current){let e=l.project?.alert_defaults?.visible_severity_levels;eH.current=e?.length?{visibleSeverityLevels:e}:null,eE(l.project?.alert_defaults?.visible_severity_levels??null)}eZ.current=!0}},[s.refreshAlerts,l.project]);let{update:eX}=(0,et.xS)(),eK=JSON.parse(localStorage.getItem("project")||"{}");(0,v.xR)(),(0,h.useEffect)(()=>{eY(null!==a.layerFilterOptions.current.alerts),e4()},[eX,s.refreshAlerts,t]),(0,h.useEffect)(()=>{e.isOpen&&e4()},[e.isOpen]),(0,h.useEffect)(()=>{if(!e.isOpen||k)return;let t=requestAnimationFrame(()=>{u.current&&(u.current.scrollTop=p.current)});return()=>cancelAnimationFrame(t)},[e.isOpen,k,g]),(0,h.useEffect)(()=>{ej||e3(!1,!1)},[m]),(0,h.useEffect)(()=>{ej&&g.length>0&&ew(!1)},[g]);let eQ=()=>{document.querySelectorAll(".dropdown").forEach(function(e){e.open=!1})},e1=()=>{let e;return(eT||eO)&&(e={from:eT||void 0,to:eO||void 0}),{issuer:eC,title:ek,description:eN,category:eD,visibleSeverityLevels:eM??void 0,dates:e,screen:eU?(0,v.i6)(a.map):void 0,doubleBB:!1,reviewed:eV??void 0}},e2=async(e,t,a)=>{let{effectiveFilters:r,sort:s}={effectiveFilters:t?null:void 0===eH.current?e1():eH.current,sort:a?null:m};return await (0,ti.Mn)(r,s,eU,e)},e5=(e,t)=>{b(t.alerts),q(t.count),N.set(e.from,t.alerts)},e3=async(e,t,a)=>{let r=a||eo;_(!0);let s=await e2(r,e,t),l=Math.max(1,Math.ceil(s.count/eB.rz));if(Math.max(1,Math.ceil(r.from/eB.rz))>l){let a,r={from:a=(l-1)*eB.rz+1,to:a+eB.rz-1};ec(r),N.clear();let s=await e2(r,e,t);e5(r,s),_(!1);return}e5(r,s),_(!1)},e4=async e=>{let t=e||eo;N.clear(),w([]),await e3(!1,!1,t)},e8=(e=!1)=>{N.clear(),e3(e,!1)},e6=async t=>{_(!0),await (0,ti.TD)([t])?(e8(),y.Ay.success("Alert deleted successfully"),e.onAlertDeleted([t])):_(!1),F({display:!1,id:0})},e7=async(t,a)=>{X(e=>new Set(e).add(t.id));let r=[{id:t.id,reviewed:a,create_date:t.create_date,...t.properties}],s=await tu(r);if(s?.ok){if(null!==eV)e4();else if(s?.status===409)y.Ay.error("A notification is already queued");else{let e=e=>e.id===t.id?{...e,reviewed:a}:e;b(t=>t.map(e)),S(t=>{let a=new Map(t);for(let[t,r]of a.entries())a.set(t,r.map(e));return a})}z.id===t.id&&e.currentPanelKey===t.id&&U(r=>({...r,reviewed:a,display:e.currentPanelKey===t.id,keepSidePanelOpen:e.currentPanelKey===t.id})),y.Ay.success("Alert successfully updated"),e.onAlertUpdated(r.map(e=>({id:e.id,reviewed:e.reviewed})))}else y.Ay.error("Failed to update alert");X(e=>{let a=new Set(e);return a.delete(t.id),a})},e9=async(t,a)=>{if(!i||en.current.get(t.id)===a)return!1;let r=t.properties.verify_status??null,s=(ei.current.get(t.id)??0)+1;
103ei.current.set(t.id,s),en.current.set(t.id,a),Q(e=>new Set(e).add(t.id));let l=(e,a)=>e.id===t.id?{...e,properties:{...e.properties,verify_status:a}}:e,n=a=>{b(e=>e.map(e=>l(e,a))),S(e=>{let t=new Map(e);for(let[e,r]of t.entries())t.set(e,r.map(e=>l(e,a)));return t}),z.id===t.id&&e.currentPanelKey===t.id&&U(e=>({...e,verify_status:a,display:!0,keepSidePanelOpen:!0}))};n(a);try{let l=await tc(t.id,a);if(ei.current.get(t.id)!==s)return!1;if(!l?.ok)return n(r),y.Ay.error("Failed to update Verify status"),!1;return n(a),e.onAlertUpdated([{id:t.id,properties:{verify_status:a}}]),y.Ay.success("Verify status updated"),!0}catch{return ei.current.get(t.id)===s&&(n(r),y.Ay.error("Failed to update Verify status")),!1}finally{ei.current.get(t.id)===s&&(en.current.delete(t.id),Q(e=>{let a=new Set(e);return a.delete(t.id),a}))}},te=async e=>{if(!er.current.has(e)){er.current.add(e),ea(t=>new Set(t).add(e));try{let t=await tp(e);t?.status===202?y.Ay.success("Alert notification queued"):t?.status===409?y.Ay.error("This alert notification is already queued"):t?.status===422?y.Ay.error("Alert notifications are not configured for this project"):y.Ay.error("Failed to send alert notification")}catch{y.Ay.error("Failed to send alert notification")}finally{er.current.delete(e),ea(t=>{let a=new Set(t);return a.delete(e),a})}}},tt=e=>{er.current.has(e)||el([e])},ta=async()=>{_(!0);let t=[],a=!1;for(let r=0;r<j.length;r++)t.push(j[r].toString()),j[r]===e.currentPanelKey&&(a=!0);let r=await (0,ti.TD)(t);R(!1),r?(e8(),y.Ay.success("Alerts successfully deleted"),e.onAlertDeleted(t.map(Number)),w([]),a&&e.closePanel()):_(!1)},tr=async e=>{let t=(0,ai.k7)(e);(0,v.VJ)(t.lon,t.lat)},ts=async e=>{try{let t=JSON.parse(localStorage.getItem("project")||"{}"),a=await (0,H.bB)(t?.container_name+"/alerts/"+e);A(t=>({...t,[e]:a}))}catch(e){console.error("Error getting alert picture URL:",e)}},tl=async e=>{let t=await (0,H.bB)(`${(0,v.ke)(e.properties.folder_path,eK,"alerts")}`);E(a=>({...a,[e.id]:t}))},tn=()=>{eL(""),e_(""),eS(""),eA(""),eE(l.project?.alert_defaults?.visible_severity_levels??null),eI(null),eF(""),eR(null),ez(""),eW(!1),eJ(null)};(0,h.useEffect)(()=>{if(!ej){let e=l.project?.alert_defaults?.visible_severity_levels;eH.current=e?.length?{visibleSeverityLevels:e}:null,tn(),e8(!1)}},[e.resetModalFilter]);let to=async()=>{eQ(),tn(),ec({from:1,to:eB.rz});let t=l.project?.alert_defaults?.visible_severity_levels,r=t?.length?{visibleSeverityLevels:t}:null;eH.current=r,a.layerFilterOptions.current.alerts=r,e.onFilterChanged()},td=async(t,r=!1)=>{eQ();let s={from:1,to:eB.rz};t?s=t:(N.clear(),w([])),ec(s),_(!0);let l=N.get(s.from);if(r||!l){if(!t){let t=e1();eH.current=t,eq?a.layerFilterOptions.current.alerts=t:a.layerFilterOptions.current.alerts=null,e.onFilterChanged()}await e3(!1,!1,s)}else b(l||[]);_(!1)};(0,h.useEffect)(()=>{g&&(g.forEach(e=>{e.properties.folder_path&&tl(e)}),(async()=>{for(let e of g)e.properties.folder_path&&await ts((0,v.$S)(e.properties.folder_path))})())},[g]);let tm=async e=>{let t=e.selected*eB.rz+1,a=t+eB.rz-1,r={from:t,to:a};ec(r),td(r)},th=async(e,t=!1,a=!1)=>{let r=eK.container_name+"/alerts/";e.properties.folder_path?.base&&(r+=e.properties.folder_path.base);let s=(0,ai.k7)(e.geojson);U({markerType:x.TG.alert,display:!0,id:e.id,category:e.properties.category,severity:e.properties.severity,title:e.properties.title,create_date:new Date(e.create_date),description:e.properties.description,author:e.properties.issuer,author_id:e.user_id,geojson:e.geojson,file_path:r,coords:{lat:s.lat,lon:s.lon},edit:a,keepSidePanelOpen:t,files:e.properties.folder_path?.files,reviewed:e.reviewed??!1,verify_status:e.properties.verify_status??null})},tx=async e=>{if(a.map.current){if(a.splitViewEnabled){await th(e,!0),globalThis.setTimeout(()=>{a.map.current?.resize(),a.altMap.current?.resize(),(0,v.y9)(e.geojson,a.map)},300);return}(0,v.y9)(e.geojson,a.map),th(e,!0)}},tf=async e=>{th(e,!1,!0)};(0,h.useEffect)(()=>{(async()=>{z.display&&(e.toggleSidePanel((0,o.jsx)(al,{parentId:z.id,category:z.category,severity:z.severity,title:z.title,description:z.description,create_date:z.create_date,author:z.author,author_id:z.author_id||"",project:l.project,file_path:""!=z.file_path?z.file_path:void 0,files:z.files,onUpdateAlert:t=>e.onAlertUpdated([t]),onVerifyStatusChange:i?e=>e9({id:z.id,properties:{verify_status:z.verify_status}},e):void 0,verifyStatusUpdating:K.has(z.id),user:t?.user,source:x.Sw.ALERT,modalSource:"alertsModal",userMap:e.userMap,edit:z.edit,reviewed:z.reviewed,verify_status:z.verify_status,coords:{lat:z.coords?.lat||0,lon:z.coords?.lon||0},markerType:z.markerType,sendAlertNotificationAction:n?(0,o.jsx)(lB,{alertId:z.id,loading:ee.has(z.id),onSend:()=>tt(z.id),location:"grid",plain:!0}):void 0}),{title:"Threads",key:z.id,icon:(0,o.jsx)(W.B2c,{}),keepSidePanelOpen:z.keepSidePanelOpen,onClose:()=>U(e=>({...e,display:!1,id:0,keepSidePanelOpen:!1}))}),U(e=>({...e,display:!1,keepSidePanelOpen:!1})))})()},[z]);let tg=e=>e.user_id===t?.user?.id||l.project&&(0,v._A)(t?.user,l.project.project_uuid),ty=h.useMemo(()=>j.some(e=>{let t=g.find(t=>
103t.id===e);return!!t&&!tg(t)}),[j,g,t,l.project]),tb=eo.from,tj=eo.from+g.length-1,tw=G>eB.rz?180:140,tv=T?T.height-tw:"100%",tN=[{label:"Action",columnId:null},...ti.qe,{label:"Image",columnId:null},{label:"Select",columnId:null}];return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(V.A,{isOpen:P.display,onDelete:()=>{e6(P.id),e.closePanel(P.id)},closeModal:()=>F({display:!1,id:0})}),(0,o.jsx)(V.A,{isOpen:O,onDelete:()=>ta(),closeModal:()=>R(!1)}),(0,o.jsx)(lV,{isOpen:e.isOpen&&null!==es,alertCount:es?.length,onCancel:()=>el(null),onConfirm:()=>{null!==es&&Promise.all(es.map(e=>te(e))),el(null)}}),e.isOpen&&(0,o.jsxs)(t4,{modalType:x.dW.AlertsModal,defaultPosition:{x:T.x,y:T.y},defaultSize:{width:T.width,height:T.height},backgroundColor:"white",lockRatio:"nolock",title:"Alerts",defaultMinSize:{width:350,height:300},setModalSize:e=>I(t=>({...t,width:e.width,height:e.height})),closeModal:()=>{s.setShowFilterModal(!1)},children:[(0,o.jsx)(B,{isOpen:C.display,closeModal:()=>L({display:!1,url:""}),url:C.url}),(0,o.jsxs)("div",{className:"relative mt-[15px] m-5",children:[(0,o.jsxs)("div",{className:"flex justify-between flex-row mb-3",children:[(0,o.jsxs)("div",{className:"flex flex-row gap-2",children:[(0,o.jsxs)("details",{className:"dropdown dropdown-right z-30",children:[(0,o.jsxs)("summary",{className:`
104                    flex items-center justify-center btn btn-sm shadow
105                    ${T?.width<400?"tooltip tooltip-bottom font-normal":""}
106                  `,"data-testid":"alerts-filter-btn","data-tip":"Filter",onClick:e=>{e.stopPropagation(),em(!1)},children:[(0,o.jsx)(e0.YsJ,{size:11}),!T||T.width>400&&" Filter"]}),(0,o.jsx)("ul",{className:"p-3 shadow menu dropdown-content z-[1] bg-base-100 rounded-box w-80",children:(0,o.jsxs)("div",{className:"flex flex-col w-full",children:[(0,o.jsxs)("div",{className:"flex items-center mt-3 justify-between gap-3",children:[(0,o.jsx)("input",{type:"text",placeholder:"Issuer",value:eC,onChange:e=>eL(e.target.value),className:"input input-sm w-full text-black"}),(0,o.jsx)("input",{type:"text",placeholder:"Category",value:eD,onChange:e=>eA(e.target.value),className:"input input-sm w-full text-black"})]}),(0,o.jsxs)("div",{className:"flex mt-3 items-center justify-between gap-3",children:[(0,o.jsx)("input",{id:"alertsTitleFilter",type:"text",placeholder:"Title",value:ek,onChange:e=>e_(e.target.value),className:"input input-sm w-full text-black"}),(0,o.jsx)("input",{type:"text",placeholder:"Description",value:eN,onChange:e=>eS(e.target.value),className:"input input-sm w-full text-black"})]}),(0,o.jsxs)("div",{className:"flex flex-col mt-3 gap-2",children:[(0,o.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,o.jsx)("span",{className:"label-text font-medium text-black",children:"Visible alert levels"}),null!==eM&&5!==eM.length&&(0,o.jsx)("button",{type:"button",className:"text-xs text-gray-500 underline",onClick:e=>{e.stopPropagation(),eE(null)},children:"Select all"})]}),(0,o.jsx)("div",{className:"grid grid-cols-3 gap-x-4 gap-y-1",children:Array.from({length:5},(e,t)=>t+1).map(e=>{let t=eM?.includes(e)??!0;return(0,o.jsxs)("label",{className:"label cursor-pointer gap-1.5 p-0 text-black",children:[(0,o.jsx)("input",{type:"checkbox","data-testid":`alerts-severity-${e}`,checked:t,onChange:()=>{let a=eM??Array.from({length:5},(e,t)=>t+1);t&&1===a.length||eE(t?a.filter(t=>t!==e):[...a,e].sort((e,t)=>e-t))},className:"checkbox checkbox-sm"}),(0,o.jsx)("span",{className:"text-xs",children:(0,v.Wl)(e)})]},e)})})]}),(0,o.jsxs)("div",{className:"flex w-full text-black mt-3 gap-3",children:[(0,o.jsxs)("div",{className:"flex flex-1 basis-0 min-w-0 text-black flex-col text-center",children:[(0,o.jsx)("span",{className:"opacity-70",children:"From"}),(0,o.jsx)("input",{type:"date",value:eP,onChange:e=>{eI(new Date(`${e.target.value}T00:00:00.000`)),eF(e.target.value)},className:"input w-full min-w-0 max-w-full box-border text-black text-left pr-10 pl-0 text-xs"},"start-date-input")]}),(0,o.jsxs)("div",{className:"flex flex-1 basis-0 min-w-0 text-black flex-col text-center",children:[(0,o.jsx)("span",{className:"opacity-70",children:"To"}),(0,o.jsx)("input",{type:"date",value:e$,onChange:e=>{eR(new Date(`${e.target.value}T23:59:59.999`)),ez(e.target.value)},className:"input w-full min-w-0 max-w-full box-border text-black text-left pr-10 pl-0 text-xs"},"end-date-input")]})]}),(0,o.jsx)("div",{className:"flex mt-2 w-full",children:(0,o.jsxs)("div",{className:"form-control w-full gap-2 flex flex-col my-2",children:[(0,o.jsxs)("label",{className:"label flex w-full cursor-pointer items-center justify-between gap-3",children:[(0,o.jsx)("span",{className:"label-text font-medium",children:"Filter by Visibility"}),(0,o.jsx)("input",{type:"checkbox",checked:eU,onChange:()=>{eW(!eU)},className:"toggle toggle-sm"})]}),(0,o.jsxs)("div",{className:"label flex w-full cursor-pointer items-center justify-between gap-3",children:[(0,o.jsx)("span",{className:"label-text font-medium",children:"Apply Filters to Map"}),(0,o.jsx)("input",{type:"checkbox",checked:eq,"data-testid":"alerts-apply-map-toggle",onCh
106ange:()=>eY(e=>!e),className:"toggle toggle-sm"})]}),(0,o.jsxs)("div",{className:"label flex w-full cursor-pointer items-center justify-between",children:[(0,o.jsx)("span",{className:"label-text font-medium pr-10",children:"Reviewed Status"}),(0,o.jsxs)("select",{value:null===eV?"all":eV?"reviewed":"not-reviewed",onChange:e=>{let t=e.target.value;eJ("all"===t?null:"reviewed"===t)},className:"select select-bordered select-sm text-black",children:[(0,o.jsx)("option",{value:"all",children:"All"}),(0,o.jsx)("option",{value:"reviewed",children:"Reviewed"}),(0,o.jsx)("option",{value:"not-reviewed",children:"Not Reviewed"})]})]})]})}),(0,o.jsxs)("div",{className:"border-t border-black/10 flex items-center gap-2 justify-center mt-5",children:[(0,o.jsx)("div",{onClick:to,className:"btn mt-3 btn-sm",children:"Reset"}),(0,o.jsx)("div",{id:"alertsApply-button","data-testid":"alerts-apply-button",onClick:()=>td(null),className:"btn mt-3 btn-sm tt-blue-button",children:"Apply"})]})]})})]}),(0,o.jsxs)("div",{className:`
107                  flex items-center justify-center btn btn-sm shadow relative z-20
108                  ${T?.width<500?"tooltip tooltip-bottom font-normal":""}
109                `,"data-tip":"Mentions",onClick:()=>em(e=>!e),ref:d,children:[(0,o.jsx)(e0.T35,{size:14}),!T||T.width>500&&" Mentions",s.alertUnreadCount>0&&(0,o.jsx)("div",{className:"badge absolute badge-xs border-none bg-red-400 shadow rounded-lg h-5 min-w-[20px] w-auto ml-28 mb-7 text-[12px] font-semibold text-white",children:s.alertUnreadCount})]}),ep&&(0,o.jsx)(lz,{unreadClicked:ey,setUnreadClicked:eb,allMentions:s.alertMentions,currentMentions:eh,setCurrentMentions:ef,readStatus:s.alertReadStatus,showThreads:z,setShowThreads:U,setReadStatus:s.setAlertReadStatus,userMap:e.userMap,setCountUnread:s.setAlertUnreadCount,type:"alerts",projectContainer:eK.container_name,showMentions:ep,setShowMentions:em,buttonRef:d,onUpdate:e.onNotificationUpdated})]}),(0,o.jsxs)("div",{className:"flex flex-wrap gap-2 justify-end",children:[(0,o.jsx)("button",{className:"btn btn-sm shadow",onClick:()=>eu(!ed),children:ed?(0,o.jsx)($.XfR,{size:22}):(0,o.jsx)($.mOA,{size:22})}),(0,o.jsxs)("div",{className:"dropdown dropdown-end",children:[(0,o.jsxs)("button",{tabIndex:0,className:"btn btn-sm shadow",children:[(0,o.jsx)(W.txO,{size:18}),j.length>0&&(0,o.jsx)("span",{className:"absolute top-0 right-0 bg-tt-blue text-white text-xs font-bold rounded-full w-4 h-4 flex items-center justify-center",children:j.length})]}),(0,o.jsxs)("ul",{className:"dropdown-content menu bg-white rounded-box z-20 w-40 p-1 shadow border border-gray-200 text-gray-800",children:[(0,o.jsx)("li",{children:(0,o.jsx)("button",{onClick:()=>{let e=g.map(e=>e.id);w(t=>Array.from(new Set([...t,...e])))},children:"Select this page"})}),(0,o.jsx)("li",{children:(0,o.jsx)("button",{onClick:()=>{w([])},children:"Select none"})})]})]}),j.length>0&&(0,o.jsxs)(o.Fragment,{children:[!ed&&n&&(0,o.jsx)("button",{className:"btn btn-sm shadow",onClick:()=>{0!==j.length&&el([...j])},disabled:j.some(e=>ee.has(e)),title:"Send notifications for selected alerts","aria-label":"Send notifications for selected alerts",children:(0,o.jsx)(W.Y2n,{size:18})}),(0,o.jsx)(lU,{disabled:!1,onExportCsv:()=>{let e=Array.from(N.values()).flat().filter(e=>j.includes(e.id)),t=`alerts_${l.project?.project_name||"export"}.csv`;(0,v.tr)(rx().unparse((0,ti.Z_)(e)),t)}}),(0,o.jsx)("button",{className:"btn btn-sm shadow tt-blue-button disabled:opacity-50 disabled:cursor-not-allowed",onClick:()=>{R(!0)},disabled:ty,title:ty?"You cannot delete one or more selected alerts":"Delete selected",children:(0,o.jsx)(W.WeY,{size:18})})]})]})]}),(0,o.jsx)("div",{ref:u,className:"force-scrollbar",onScroll:()=>{if(k)return;let e=u.current;e&&(p.current=e.scrollTop)},style:{width:"100%",height:tv,overflow:"auto"},children:k?(0,o.jsx)("div",{className:"flex h-full min-h-[220px] items-center justify-center",children:(0,o.jsx)("span",{className:"loading loading-spinner",style:{color:"black"}})}):(0,o.jsx)(o.Fragment,{children:g&&g.length>0?(0,o.jsx)(o.Fragment,{children:ed?(0,o.jsx)("div",{style:{width:T.width-40,height:tv,overflow:"auto"},children:(0,o.jsx)("div",{className:"grid gap-3 text-black grid-cols-[repeat(auto-fill,minmax(220px,1fr))]",children:g.map(e=>(0,o.jsxs)("div",{className:"border rounded-lg border-black/10 shadow-sm flex flex-col justify-between",children:[(0,o.jsxs)("div",{className:"p-4 flex flex-col justify-between",children:[(0,o.jsx)("div",{className:"font-bold text-[14px]",children:e.properties.title}),(0,o.jsxs)("div",{className:"flex items-center gap-2 opacity-90",children:[(0,o.jsx)(W.$eR,{size:10})," ",e.properties.category]}),(0,o.jsxs)("div",{className:"flex items-center gap-2 opacity-90",children:[(0,o.jsx)(W.kSq,{size:11})," ",e.properties.issuer]}),(0,o.jsxs)("div",{className:"flex items-center gap-2 opacity-90",children:[(0,o.jsx)(W.D7y,{size:10})," ",J()(e.create_date).format("M/D/YYYY h:mm A")]}),(0,o.jsxs)("div",{className:"flex items-center gap-2 opacity-90",children:[(0,o.jsx)(W.qVV,{size:10})," Severity: ",(0,v.Wl)(e.properties.severity)]}),(0,o.jsxs)("div",{className:"mt-2",children:[(0,o.jsx)("label",{className:"mb-1 block text-xs opacity-90",htmlFor:`alert-${e.id}-verify-status`,children:"Verify:"}),(0,o.jsx)(as,{id:`alert-${e.id}-verify-status`,alertId:e.id,value:e.properties.verify_status??null,loading:K.has(e.id),disabled:!i,onChange:i?t=>void e9(e,t):void 0,className:"select select-bordered select-xs text-[12px]",valueClassName:"text-[12px]"})]}),(0,o.jsx)("div",{className:"mt-2",children:e?.properties.folder_path&&e?.properties.folder_path.files.length>0&&(0,o.jsx)("div",{children:"image"===(0,v.ti)((0,v.$S)(e.properties.folder_path))?(0,o.jsx)("img",{onClick:()=>L({display:!0,url:D[(0,v.$S)(e.properties.folder_path)]}),src:D[(0,v.$S)(e.properties.folder_path)],className:"rounded-md cursor-pointer",alt:"Image",style:{width:"100%",height:90,objectFit:"cover"}}):"video"===(0,v.ti)((0,v.$S)(e.properties.folder_path))?(0,o.jsxs)("video",{controls:!0,width:"100%",height:40,className:"rounded-md",children:[(0,o.jsx)("source",{src:D[(0,v.$S)(e.properties.folder_path)],type:"video/mp4"}),"Your browser does not support the video tag."]}):"pdf"===(0,v.ti)((0,v.$S)(e.properties.folder_path))?(0,o.jsxs)("div",{onClick:()=>{r.setPdfUrl(D[(0,v.$S)(e.properties.folder_path)]),r.setPdfSource({source_type:x.Sw.ALERT,s
109ource_id:e.id}),c(x.dW.PDFViewerModal)},className:"hover:bg-gray-100 rounded-md p-2 opacity-80 bg-gray-100/50 shadow items-center justify-center flex gap-2 cursor-pointer",children:[(0,v.sW)((0,v.ti)((0,v.$S)(e.properties.folder_path))),(0,o.jsx)("span",{className:"text-md font-bold",children:(0,v.ti)((0,v.$S)(e.properties.folder_path)).toUpperCase()})]}):(0,o.jsx)("a",{href:D[(0,v.$S)(e.properties.folder_path)],download:!0,children:(0,o.jsxs)("div",{className:"hover:bg-gray-100 rounded-md p-2 opacity-80 bg-gray-100/50 shadow items-center justify-center flex gap-2",children:[(0,v.sW)((0,v.ti)((0,v.$S)(e.properties.folder_path))),(0,o.jsx)("span",{className:"text-md font-bold",children:(0,v.ti)((0,v.$S)(e.properties.folder_path)).toUpperCase()})]})})})})]}),(0,o.jsxs)("div",{className:"flex flex-wrap gap-1 px-4 pb-3",children:[(0,o.jsx)("button",{onClick:()=>void tx(e),className:"btn btn-outline btn-xs text-xs",title:"Zoom to Alert",children:(0,o.jsx)(W.YQq,{})}),(0,o.jsxs)("details",{className:"dropdown dropdown-start fm-dropdown",children:[(0,o.jsx)("summary",{className:"btn btn-outline btn-xs text-xs",title:"Show more options",children:(0,o.jsx)(W.mqA,{})}),(0,o.jsxs)("ul",{className:"p-2 shadow menu dropdown-content z-1 bg-base-100 rounded-box w-52",children:[n&&(0,o.jsx)("li",{children:(0,o.jsx)(lB,{alertId:e.id,loading:ee.has(e.id),onSend:()=>tt(e.id),location:"grid",showLabel:!0,menuItem:!0})}),(0,o.jsx)("li",{children:(0,o.jsxs)("button",{type:"button",className:"w-full justify-start",onClick:()=>th(e),children:[(0,o.jsx)(W.PxB,{}),"Threads"]})}),tg(e)&&(0,o.jsx)("li",{children:(0,o.jsxs)("button",{type:"button",className:"w-full justify-start",onClick:()=>tf(e),children:[(0,o.jsx)(W.dJk,{})," Edit"]})}),(0,o.jsx)("li",{children:(0,o.jsxs)("button",{type:"button",className:"w-full justify-start",onClick:()=>tr(e.geojson),children:[(0,o.jsx)(W.Yad,{})," Navigate"]})}),tg(e)&&(0,o.jsx)("li",{className:"text-red-500",children:(0,o.jsxs)("button",{type:"button",className:"w-full justify-start",onClick:()=>F({display:!0,id:e.id}),children:[(0,o.jsx)(W.WeY,{})," Delete"]})})]})]})]})]},e.id))})}):(0,o.jsx)("div",{className:"transition-opacity text-black rounded-lg duration-300",children:(0,o.jsxs)("table",{className:"table",children:[(0,o.jsx)("thead",{className:"sticky top-0 bg-[#f9f9f9] z-10 shadow-sm",children:(0,o.jsx)("tr",{children:tN.map(e=>{var t,a;return(0,o.jsx)("th",{className:"Time"===(t=e.label)?"flex flex-row space-x-2":"Verify"===t||"Reviewed"===t?"justify-center":"",children:e.columnId?(0,o.jsxs)("button",{onClick:()=>{var t;return t=e.columnId,void(f(e=>({column:t,ascending:e?.column!==t||!e.ascending})),N.clear(),w([]),ec({from:1,to:eB.rz}))},className:"sort-button hover:bg-gray-100 hover:text-gray-800 flex items-center space-x-1",children:[e.label,(a=e.columnId,m?.column===a?m.ascending?(0,o.jsx)(W.Ob1,{size:9,className:"ml-1"}):(0,o.jsx)(W.D_L,{size:9,className:"ml-1"}):(0,o.jsx)(W.gER,{size:9,className:"ml-1"}))]}):e.label},e.label)})})}),g&&g.length>0&&(0,o.jsx)("tbody",{children:g.map((t,a)=>(0,o.jsxs)("tr",{className:`text-[12px] ${a%2==1?"bg-[#f2f2f2]":"bg-[#fafafa]"}`,children:[(0,o.jsxs)("td",{className:"flex flex-wrap",children:[(0,o.jsx)("button",{onClick:()=>void tx(t),className:"btn btn-outline btn-xs text-xs m-[2px]",title:"Zoom to Alert",children:(0,o.jsx)(W.YQq,{})}),(0,o.jsxs)("details",{className:"dropdown dropdown-start fm-dropdown",children:[(0,o.jsx)("summary",{className:"btn btn-outline btn-xs text-xs m-[2px]",title:"Show more options",children:(0,o.jsx)(W.mqA,{})}),(0,o.jsxs)("ul",{className:"p-2 shadow menu dropdown-content z-1 bg-base-100 rounded-box w-52",children:[n&&(0,o.jsx)("li",{children:(0,o.jsx)(lB,{alertId:t.id,loading:ee.has(t.id),onSend:()=>tt(t.id),location:"table",showLabel:!0,menuItem:!0})}),(0,o.jsx)("li",{children:(0,o.jsxs)("button",{type:"button",className:"w-full justify-start",onClick:()=>th(t),children:[(0,o.jsx)(W.PxB,{}),"Threads"]})}),tg(t)&&(0,o.jsx)("li",{children:(0,o.jsxs)("button",{type:"button",className:"w-full justify-start",onClick:()=>tf(t),children:[(0,o.jsx)(W.dJk,{})," Edit"]})}),(0,o.jsx)("li",{children:(0,o.jsxs)("button",{type:"button",className:"w-full justify-start",onClick:()=>tr(t.geojson),children:[(0,o.jsx)(W.Yad,{})," Navigate"]})}),tg(t)&&(0,o.jsx)("li",{id:"alertModal-delete-alert",className:"text-red-500",children:(0,o.jsxs)("button",{type:"button",className:"w-full justify-start",onClick:()=>F({display:!0,id:t.id}),children:[(0,o.jsx)(W.WeY,{})," Delete"]})})]})]})]}),(0,o.jsx)("td",{children:t.properties.issuer}),(0,o.jsx)("td",{children:t.properties.category}),(0,o.jsx)("td",{children:t.properties.title}),(0,o.jsx)("td",{children:(0,o.jsx)("span",{dangerouslySetInnerHTML:{__html:(0,Y.W7)(t.properties.description,e.userMap)}})}),(0,o.jsx)("td",{children:J()(t.create_date).format("M/D/YYYY h:mm A")}),(0,o.jsx)("td",{className:"text-center",children:Z.has(t.id)?(0,o.jsx)("span",{className:"loading loading-spinner loading-sm",style:{color:"black"}}):(0,o.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:t.reviewed??!1,onChange:e=>e7(t,e.target.checked),title:"Mark as reviewed"})}),(0,o.jsx)("td",{children:(0,v.Wl)(t.properties.severity)}),(0,o.jsx)("td",{children:(0,o.jsx)(as,{alertId:t.id,value:t.properties.verify_status??null,loading:K.has(t.id),disabled:!i,onChange:i?e=>void e9(t,e):void 0,className:"select select-bordered select-xs text-[12px]",valueClassName:"text-[12px]"})}),(0,o.jsx)("td",{children:t?.properties.folder_path&&t?.properties.folder_path.files.length>0&&(0,o.jsx)("div",{children:"image"==(0,v.ti)((0,v.$S)(t.properties.folder_path))?(0,o.jsx)("img",{onClick:()=>L({display:!0,url:D[(0,v.$S)(t.properties.folder_path)]||""}),src:M[t.id],alt:"Alert image",width:70,height:40,className:"rounded-md cursor-pointer"}):"video"===(0,v.ti)((0,v.$S)(t.properties.folder_path))?(0,o.jsxs)("video",{controls:!0,width:"70",height:40,className:"rounded-md",children:[(0,o.jsx)("source",{src:D[(0,v.$S)(t.properties.folder_path)],type:"video/mp4"}),"Your browser does not support the video tag."]}):"pdf"===(0,v.ti)((0,v.$S)(t.properties.folder_path))?(0,o.jsxs)("div",{onClick:()=>{r.setPdfUrl(D[(0,v.$S)(t.properties.folder_path)]),r.setPdfSource({source_type:x.Sw.ALERT,s
109ource_id:t.id}),c()},className:"hover:bg-gray-100 rounded-md p-2 opacity-80 bg-gray-100/50 shadow items-center justify-center flex gap-2 cursor-pointer",children:[(0,v.sW)((0,v.ti)((0,v.$S)(t.properties.folder_path))),(0,o.jsx)("span",{className:"text-md font-bold",children:(0,v.ti)((0,v.$S)(t.properties.folder_path)).toUpperCase()})]}):(0,o.jsx)("a",{href:D[(0,v.$S)(t.properties.folder_path)],download:!0,children:(0,o.jsxs)("div",{className:"hover:bg-gray-100 rounded-md p-2 opacity-80 bg-gray-100/50 shadow items-center justify-center flex gap-2",children:[(0,v.sW)((0,v.ti)((0,v.$S)(t.properties.folder_path))),(0,o.jsx)("span",{className:"text-md font-bold",children:(0,v.ti)((0,v.$S)(t.properties.folder_path)).toUpperCase()})]})})})}),(0,o.jsx)("td",{className:"text-center",children:(0,o.jsx)("label",{"aria-label":`Select alert ${t.id}`,children:(0,o.jsx)("input",{type:"checkbox",className:"checkbox checkbox-sm",checked:j.includes(t.id),onChange:()=>{var e;return e=t.id,void w(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},title:""})})})]},t.id))})]})})}):(0,o.jsx)("div",{className:"flex h-full min-h-[220px] items-center justify-center px-6",children:(0,o.jsxs)("div",{className:"text-center text-sm text-black/80 space-y-2 max-w-lg",children:[(0,o.jsx)("p",{children:"No alerts in this project so far"}),(0,o.jsxs)("p",{className:"inline-flex flex-wrap items-center justify-center gap-1 text-[13px] text-black/50",children:[(0,o.jsx)("span",{children:"To create an alert, click on the map then click on the"}),(0,o.jsxs)("span",{className:"inline-flex items-center gap-1 font-bold text-black/80",children:[(0,o.jsx)(W.PAG,{size:16}),(0,o.jsx)("span",{children:"Alert"})]}),(0,o.jsx)("span",{children:"button, or right-click"})]})]})})})}),G>eB.rz&&(0,o.jsxs)("div",{className:"pagination-cont",children:[(0,o.jsx)("p",{children:Math.ceil(eo.from/eB.rz)}),(0,o.jsx)(lO(),{"data-testid":"alerts-pagination",breakLabel:"...",nextLabel:">",onPageChange:tm,pageRangeDisplayed:5,previousLabel:"<",pageClassName:"page-item cursor-pointer",previousClassName:"page-item cursor-pointer",nextClassName:"page-item cursor-pointer",breakClassName:"page-item cursor-pointer",containerClassName:"pagination",activeClassName:"active",forcePage:Math.ceil(eo.from/eB.rz)-1,pageCount:Math.ceil(G/eB.rz),renderOnZeroPageCount:null})]}),G>0&&(0,o.jsxs)("div",{className:"mt-2.5 mb-0 w-full text-center text-xs text-gray-400","data-testid":"alerts-count-label",children:[tb,"-",tj," of ",G]})]})]})]})}var lJ=a(93681);a(14683);var lq=a(75845),lY=a(60257),lH=a(9056),lZ=a(96235);let lX=e=>Array.isArray(e)?e.filter(e=>"string"==typeof e&&e.trim().length>0):[];async function lK(e,t,a,r){try{return await (0,_.x)("/layer/sentinel-hub/dates",{params:{bbox:JSON.stringify(a),startDate:e,endDate:t,collection:r}})}catch(e){return console.error(`Error: ${e}`),null}}async function lQ(e,t,a){try{let r=await (0,_.x)("/layer/sentinel-hub/timestamps",{params:{bbox:JSON.stringify(t),date:e,collection:a}});return{timestamps:lX(r.timestamps),satellites:lX(r.satellites)}}catch(e){return console.error(`Error: ${e}`),null}}let l0=["MODIS","VIIRS","AIRS","OMI"],l1=e=>
109{let t=e.getNorthEast(),a=e.getSouthWest();return{TR:{lon:t.lng,lat:t.lat},BL:{lon:a.lng,lat:a.lat}}};var l2=a(39736),l5=a(5437);let l3=/P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?/;function l4(e){let[t,a,r]=e.split("-").map(Number);return[t,a,r]}function l8(e,t,a){return Date.UTC(e,t-1,a)}function l6(e,t,a,r){let s=l3.exec(r);if(!s)throw Error(`Unrecognized ISO 8601 period: ${r}`);let l=Date.UTC(e+(s[1]?Number.parseInt(s[1],10):0),t-1+(s[2]?Number.parseInt(s[2],10):0),a+(s[3]?Number.parseInt(s[3],10):0));if(l<=l8(e,t,a))throw Error(`Period "${r}" does not advance the date`);let i=new Date(l);return[i.getUTCFullYear(),i.getUTCMonth()+1,i.getUTCDate()]}class l7{capabilitiesUrl;layerTimeMapPromise=null;constructor(e){this.capabilitiesUrl=e}async fetchLayerTimeMap(){let e=await (0,ai.kD)(this.capabilitiesUrl),t=new Map;for(let a of e.querySelectorAll("Layer")){let e=a.querySelector("Name")?.textContent?.trim(),r=a.querySelector('Dimension[name="time"]')?.textContent?.trim();e&&r&&t.set(e,r)}return t}async getAvailableDates(e,t,a){let r;this.layerTimeMapPromise??=this.fetchLayerTimeMap();try{r=await this.layerTimeMapPromise}catch{return this.layerTimeMapPromise=null,[]}let s=r.get(e)??"";return s?s.split(",").flatMap(e=>{let[r,s,l]=e.trim().split("/");return function(e,t,a,r,s){let[l,i,n]=l4(e),[o,c,d]=l4(t),u=l8(l,i,n),p=l8(o,c,d),m=Date.UTC(r,s-1,1),h=Date.UTC(r,s,0);if(p<m||u>h)return[];let[x,f,g]=l4(e);if(u<m){let e=l3.exec(a);if(!e||e[1]||e[2]||"1"!==e[3])for(;l8(x,f,g)<m;)[x,f,g]=l6(x,f,g,a);else[x,f,g]=[r,s,1]}let y=Math.min(p,h),b=[];for(;l8(x,f,g)<=y;)b.push(`${x}-${String(f).padStart(2,"0")}-${String(g).padStart(2,"0")}`),[x,f,g]=l6(x,f,g,a);return b}(r,s,l,t,a)}):[]}}let l9=new l7("https://gibs.earthdata.nasa.gov/wms/epsg3857/best/wms.cgi?SERVICE=WMS&REQUEST=GetCapabilities"),ie="";function it(e){if(!e)return new Date;let[t,a,r]=e.split("-").map(Number);return new Date(t,a-1,r)}let ia=e=>(0,o.jsx)("div",{className:"w-full px-3 py-2 border-t border-gray-100 flex flex-col gap-2",children:(0,o.jsxs)("div",{className:"flex items-center justify-between",children:[(0,o.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,o.jsx)("span",{className:"text-sm",children:"Merged Dates"}),(0,o.jsx)("div",{className:"\n                            tooltip tooltip-top cursor-pointer text-sm opacity-90\n                            [&::before]:max-w-[160px]\n                            [&::before]:whitespace-normal\n                            [&::before]:text-xs\n                            [&::before]:leading-tight\n                            [&::before]:px-2\n                            [&::before]:py-1\n                        ","data-tip":"Combines imagery from multiple dates and layers into one view using the latest available data for the selected day",children:(0,o.jsx)(W.MGr,{className:"text-xs text-gray-500"})})]}),(0,o.jsx)("input",{type:"checkbox",className:"toggle toggle-sm",checked:e.mergedDate,onChange:t=>{e.setMergedDate(t.target.checked)}})]})}),ir={affectedSatellites:["sentinel-1d"],message:"Sentinel-1D experienced known data-quality/availability issues for this area and date.",startDate:new Date("2026-05-29T00:00:00Z"),endDate:new Date("2026-06-01T18:00:00Z")},is=e=>new Intl.DateTimeFormat("en-CA",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,timeZone:"UTC"}).format(e).replace(",","")+" UTC",il=({timestamps:e,satellites:t,isTimestampsLoading:a,isZoomedOut:r,isSatelliteLayer:s=!1,selectedDate:l,issue:i,formatIssueDateTime:n=is})=>{let c=new Set(i.affectedSatellites.map(e=>e.toLowerCase())),d=t.some(e=>c.has(e.toLowerCase())),u=l instanceof Date&&l.getTime()>=i.startDate.getTime()&&l.getTime()<=i.endDate.getTime();return s&&!a&&!r&&e.length>0&&d&&u?(0,o.jsxs)("div",{className:"mb-3 flex items-start gap-1 text-red-800 text-sm bg-red-50 border border-red-200 rounded-md p-2",children:[(0,o.jsx)(em.tr_,{className:"text-base shrink-0 mt-px"}),(0,o.jsxs)("span",{className:"text-xs",children:[i.message,(0,o.jsxs)("span",{className:"block font-semibold",children:[i.issueLabel??"Since",": ",n(i.startDate)]}),(0,o.jsxs)("span",{className:"block font-semibold",children:[i.issueEndLabel??"Until",": ",n(i.endDate)]})]})]}):null},ii=e=>{let t=e.replace(" ","T");return t.endsWith("Z")?t:`${t}Z`},io=e=>{if(0===e.length)return null;let t=new Date(ii(e[0])),a=new Date(ii(e.at(-1)));return Number.isNaN(t.getTime())||Number.isNaN(a.getTime())?null:{firstDate:t,lastDate:a}},ic=e=>e.split("-").map((e,t)=>0===t?`${e[0].toUpperCase()}${e.slice(1)}`:e.toUpperCase()).join("-"),id=({timestamps:e,satellites:t,isTimestampsLoading:a,isZoomedOut:r,isSarLayer:s=!1,selectedDate:l})=>{let i=((e,t)=>{let a=io(e);if(!a)return null;let{firstDate:r,lastDate:s}=a,l=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit",hour12:!0}),i=new Intl.DateTimeFormat(void 0,{year:"2-digit",month:"2-digit",day:"2-digit"}),n=new Intl.DateTimeFormat(void 0,{timeZoneName:"short"}),o=l.format(r),c=l.format(s),d=i.format(r),u=i.format(s),p=n.formatToParts(r).find(e=>"timeZoneName"===e.type)?.value||"",m=d!==u,h=o!==c?`${o} - ${c}`:o,x=m?`${d} - ${u}`:d,f=`Local: ${h} ${p} • ${x}`;return{timeRange:h,tzName:p,dateRange:x,shouldStack:m||f.length>36,satellite:0===t.length?null:t.map(ic).join(", ")}})(e,t);return(0,o.jsxs)("div",{className:"w-full p-3 border-t border-gray-200",children:[(0,o.jsx)(il,{timestamps:e,satellites:t,isTimestampsLoading:a,isZoomedOut:r,isSatelliteLayer:s,selectedDate:l,issue:ir}),(0,o.jsxs)("div",{className:"flex gap-2 justify-between items-center",children:[(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[(0,o.jsx)("span",{className:"text-sm",children:"Time"}),(0,o.jsx)("div",{className:"\n                            tooltip tooltip-right cursor-pointer\n                            [&::before]:max-w-[150px]\n                            [&::before]:whitespace-normal\n                            [&::before]:text-[11px]\n                            [&::before]:leading-tight\n                            [&::before]:
109px-2.5\n                            [&::before]:py-1.5\n                        ","data-tip":"Data and calendar days use UTC. Timestamps are shown in UTC and converted to your local time below. Zoom in to see more detailed capture times.",children:(0,o.jsx)(W.MGr,{className:"text-xs text-gray-500"})})]}),(0,o.jsxs)("div",{className:"flex flex-col items-end gap-1",children:[(0,o.jsx)("div",{className:"flex items-center justify-center h-7 px-2 bg-white border border-gray-200 rounded-md shrink-0 min-w-[80px]",children:a?(0,o.jsx)($.qzG,{className:"animate-spin text-gray-500 text-sm"}):r?(0,o.jsx)("span",{className:"text-xs text-gray-500 italic text-center",children:"Zoom for timestamps"}):e.length>0?(0,o.jsx)("span",{className:"text-xs text-gray-900",children:(e=>{let t=io(e);if(!t)return"";let{firstDate:a,lastDate:r}=t,s=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit",hour12:!0,timeZone:"UTC"}),l=s.format(a),i=s.format(r);return l===i?`${l} UTC`:`${l} - ${i} UTC`})(e)}):(0,o.jsx)("span",{className:"text-xs text-gray-500 italic text-center",children:"No data available"})}),!a&&!r&&i&&(0,o.jsx)("div",{className:"flex flex-col items-end leading-tight",children:i.shouldStack?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("span",{className:"text-[10px] text-gray-500 tabular-nums whitespace-nowrap",children:["Local: ",i.timeRange," ",i.tzName]}),(0,o.jsx)("span",{className:"text-[10px] text-gray-500 tabular-nums whitespace-nowrap",children:i.dateRange}),i.satellite&&(0,o.jsxs)("span",{className:"text-[10px] text-gray-500 tabular-nums break-words text-right",children:[(0,o.jsx)(e0.D14,{className:"text-[11px] inline align-middle mr-1"}),(0,o.jsx)("span",{children:i.satellite})]})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("span",{className:"text-[10px] text-gray-500 tabular-nums whitespace-nowrap",children:["Local: ",i.timeRange," ",i.tzName," • ",i.dateRange]}),i.satellite&&(0,o.jsxs)("span",{className:"text-[10px] text-gray-500 tabular-nums break-words text-right",children:[(0,o.jsx)(e0.D14,{className:"text-[11px] inline align-middle mr-1"}),(0,o.jsx)("span",{children:i.satellite})]})]})})]})]})]})};function iu(e){let t=e.layer?.isSentinelLayer??!1,a=e.layer?.satellite==="sentinel-1-grd",r=e.layer?.layerName,[s,l]=(0,h.useState)(e.date?new Date(e.date):new Date),[i,n]=(0,h.useState)(e.date??void 0),[c,d]=(0,h.useState)([]),u=(0,h.useRef)(!1),p=(0,h.useRef)(null),f=(0,h.useRef)(void 0),{repaintMap:g,isLoading:y,timestamps:b,satellites:j,isTimestampsLoading:w,isZoomedOut:N}=function(e){let{displayedMonthRef:t,isNASALayerRef:a,satelliteRef:r,setDisplayedMonth:s,selectedDate:l,setSelectedDate:i,setAvailableDatesInMonth:n,name:o,setLayerDate:c,opacity:d,mergedDate:u,layer:p}=e,x=e.map,f=(0,h.useRef)(void 0),g=(0,h.useRef)(!1),y=(0,h.useRef)(5.5),b=(0,h.useRef)(void 0),[j,w]=(0,h.useState)(!1),[N,S]=(0,h.useState)([]),[k,_]=(0,h.useState)([]),[C,L]=(0,h.useState)(!1),[D,A]=(0,h.useState)(!1),M=(0,h.useRef)(u),E=(0,h.useRef)(0),T=async e=>{if(!e||!x.current)return[];if(a.current){let t=b.current;return t?await l9.getAvailableDates(t,e.getFullYear(),e.getMonth()+1):[]}if(x.current.getZoom()<y.current)return[];let t=l1(x.current.getBounds()),s=r.current;if(!s)return console.error("Error: Selected satellite is invalid."),[];let l=(0,l2.A)(e),i=(0,l5.A)(l,1);return await lK((0,v.rm)(l,!1),(0,v.rm)(i,!1),t,s)??[]},I=e=>{if(e&&x.current){s(e);try{let t=p?.layerName;if(!t||!x.current)return;let a=x.current.getSource(t);if(x.current.getLayer(t)||a?.tiles?.includes("TIME")){x.current.removeLayer(t),x.current.removeSource(t),x=p?.addLayer(x,t,(0,v.rm)(e,!1),u);let a=()=>{!x.current||x.current.getLayer(t)&&x.current.setPaintProperty(t,"raster-opacity",d)};a(),globalThis.requestAnimationFrame(a),x.current?.once("idle",a),x.current?.triggerRepaint()}}catch(e){console.log("Error",e)}}},P=(0,h.useRef)((0,v.sg)(async()=>{try{if(!x.current||!t.current)return;let e=[],l=new Date(t.current),o=!1,d=f.current?1:12;for(let t=0;t<d;t++){if((e=await T(l)).length>0){o=!0;break}l=(0,l5.A)(l,-1)}if(n(e),!o||f.current)return;if(a.current){let t=e.at(-1),a=it(t);c(a),i(a),I(a);return}if(!r.current||x.current.getZoom()<y.current)return;let u=e[0],p=it(u);c(p),i(p),s(p)}finally{w(!1)}},m.d)).current;(0,h.useEffect)(()=>{a.current=!!p&&(p.source.toLowerCase().includes("nasa")||p.attribution.toLowerCase().includes("nasa")||null!=p.satellite&&l0.includes(p.satellite)),r.current=p?.satellite??null,g.current=p?.isSentinelLayer??!1,y.current=p?.threshold??5.5,b.current=p?.wmsLayerName},[p?.layerName]),(0,h.useEffect)(()=>{f.current=l},[l]),(0,h.useEffect)(()=>{M.current=u,u&&(S([]),_([]))},[u]),(0,h.useEffect)(()=>
109{if(!x.current)return;let e=()=>{if(!x.current)return;let e=y.current;A(x.current.getZoom()<e)};return e(),x.current.on("zoom",e),x.current.on("move",e),()=>{x.current?.off("zoom",e),x.current?.off("move",e)}},[x,p?.layerName]);let F=(0,h.useRef)({month:null,layer:null});(0,h.useEffect)(()=>{if(!r.current||!t.current)return;let e=p?.layerName||"",a=(0,v.rm)(t.current,!1).slice(0,7);(F.current.month!==a||F.current.layer!==e)&&(F.current={month:a,layer:e},w(!0),P())},[t.current,p?.layerName]);let O=(0,h.useRef)((0,v.sg)(async()=>{if(!f.current||!x.current||!g.current||!r.current){S([]),_([]);return}if(x.current.getZoom()<y.current){S([]),_([]),L(!1);return}if(M.current){S([]),_([]);return}let e=l1(x.current.getBounds());L(!0);let t=++E.current;try{let a=await lQ((0,v.rm)(f.current,!1),e,r.current);if(t!==E.current)return;let s=(a?.timestamps??[]).sort((e,t)=>new Date(e).getTime()-new Date(t).getTime());S(s);let l=(a?.satellites??[]).sort((e,t)=>e.localeCompare(t));_(l)}catch(e){console.error("Error fetching timestamp metadata:",e),S([]),_([])}finally{L(!1)}},m.d)).current;return(0,h.useEffect)(()=>{O()},[l,p?.layerName,u]),(0,h.useEffect)(()=>{if(!x.current)return;let e=async()=>{""===ie&&(ie=o)};return x.current.on("movestart",e),x.current.on("zoomend",P),x.current.on("moveend",P),x.current.on("zoomend",O),x.current.on("moveend",O),()=>{x.current&&(x.current.off("movestart",e),x.current.off("zoomend",P),x.current.off("moveend",P),x.current.off("zoomend",O),x.current.off("moveend",O))}},[x,P]),{repaintMap:I,isLoading:j,timestamps:N,satellites:k,isTimestampsLoading:C,isZoomedOut:D}}({displayedMonthRef:f,isNASALayerRef:u,satelliteRef:p,setDisplayedMonth:l,map:e.map,selectedDate:i,setSelectedDate:n,setAvailableDatesInMonth:d,name:e.name,setLayerDate:e.setDate,opacity:e.opacity,mergedDate:e.mergedDate,layer:e.layer});return(0,h.useEffect)(()=>{f.current=s},[s]),(0,h.useEffect)(()=>{i&&g(i)},[e.mergedDate]),(0,h.useEffect)(()=>{n(e.date??void 0),l(e.date?new Date(e.date):new Date)},[e.date]),(0,o.jsx)(t4,{modalType:e.alt?x.dW.AltCalendarModal:x.dW.CalendarModal,defaultPosition:e.alt?{x:window.innerWidth-650,y:80}:{x:80,y:80},disableResize:!0,defaultSize:{width:250,height:"auto"},backgroundColor:"white",lockRatio:"nolock",fullWidthOnMobile:!1,defaultMinSize:{width:250,height:"auto"},title:e.name,children:(0,o.jsx)("div",{className:"text-black flex flex-col justify-between items-center w-full ",children:e.layer?.calendarEnabled===!1?(0,o.jsx)("div",{className:"flex items-center justify-center w-full h-full p-4",children:(0,o.jsxs)("div",{className:"text-center text-gray-600",children:[(0,o.jsxs)("p",{className:"text-lg font-medium mb-2",children:[r??"Unknown"," Layer"]}),(0,o.jsxs)("p",{className:"text-sm",children:["Calendar functionality not available for ",r??"this layer's"," data."]})]})}):(0,o.jsxs)("div",{className:"flex flex-col items-center justify-center w-full",children:[(0,o.jsxs)("div",{className:"relative",children:[y&&(0,o.jsx)("div",{className:"absolute left-0 right-0 bottom-0 top-16 flex items-center justify-center bg-white/70 z-50 rounded-lg",children:(0,o.jsx)($.qzG,{className:"animate-spin text-3xl text-black"})}),(0,o.jsx)(lJ.hv,{mode:"single",captionLayout:"dropdown-buttons",selected:i,required:!0,onSelect:t=>{null==t||e.date&&t&&(0,lq.A)(t,e.date)||(e.setDate(t),g(t),n(t))},fromYear:2010,toYear:new Date().getFullYear(),disabled:[{after:(0,lH.A)(new Date)},t=>e.mergedDate&&!c.includes((0,v.rm)(t,!1))],month:s,onMonthChange:e=>{null==e||(0,lY.A)(e,s)||(l(e),f.current=e)},modifiers:{latest:e=>!!i&&(0,v.rm)(e,!1)===(0,v.rm)(i,!1),selectable:e=>{if(0===c.length)return!1;let t=(0,v.rm)(e,!1),a=c.includes(t),r=!!i&&(0,v.rm)(i,!1)===t,s=(0,lZ.A)(e,(0,lH.A)(new Date));return a&&!r&&!s}},modifiersStyles:{latest:{backgroundColor:"#2563eb",color:"#ffffff",fontWeight:"bold",borderRadius:"50%"},selectable:{backgroundColor:"#f4f4f4",color:"#000000",borderRadius:"50%"}}})]}),t&&(0,o.jsx)("div",{className:"w-full px-3 pb-2 pt-0",children:N?(0,o.jsxs)("div",{className:"flex items-center gap-2 text-warning font-medium text-sm bg-orange-50 border border-orange-200 rounded-md p-2",children:[(0,o.jsx)(em.tr_,{className:"text-md shrink-0"}),(0,o.jsx)("span",{className:"text-xs",children:"Please zoom in to see data"})]}):i&&(0,lY.A)(i,s)&&!y&&c.length>=0&&!c.includes((0,v.rm)(i,!1))&&(0,o.jsxs)("div",{className:"flex items-center gap-2 text-warning font-medium text-sm bg-orange-50 border border-orange-200 rounded-md p-2",children:[(0,o.jsx)(em.tr_,{className:"text-md shrink-0"}),(0,o.jsx)("span",{className:"text-xs",children:"No data available"})]})}),t&&!e.mergedDate&&(0,o.jsx)(id,{timestamps:b,satellites:j,isTimestampsLoading:w,isZoomedOut:N,isSarLayer:a,selectedDate:i}),e.layer?.mergedDateEnabled&&(0,o.jsx)(ia,{mergedDate:e.mergedDate,setMergedDate:e.setMergedDate})]})})})}let ip=(e,t)=>{let a=e[t];if(void 0===a)throw Error(`Required context field '${String(t)}' is missing`);return a}
109,im={[x.dW.GISModal]:{pageSize:100,blacklistedColumns:["uuid"],isColumnEditable:e=>!["Layer Name","type"].includes(e),nonTextColumns:{},fetch:{endpoint:"/layer/table",method:"GET",extendPayloadFields:(e,t)=>{let a=ip(t,"containerName"),r=ip(t,"GISLayerId");ix(e,"container_name",a),ix(e,"id",r)}},update:{updateItem:async(e,t,a)=>{let r=ip(a,"layersContext"),s=ip(a,"mapContext"),l=ip(a,"gisDataVersionContext");return await l.triggerGisDataUpdate(async()=>{let l=parseInt(r.activeTabularLayerID),i=e.uuid,n=Number(i),o=Object.fromEntries(t);if(!l||!i||!Number.isFinite(n))throw Error("Layer ID or feature UUID is missing");await r2({layerId:l,featureId:n,metadata:o}),(0,av.aF)(s.map,r.activeTabularLayerID,i,o);let c=r.customLayers?.find(e=>e.id?.toString()===r.activeTabularLayerID),d=c?.properties?.gradientData?.property,u=ip(a,"projectContext")?.project;if(c&&u&&d&&Object.hasOwn(o,d)){let e=(0,av.oD)(r.activeTabularLayerID);if(e.length>0){let t="function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e));(0,N.qE)(s.map,u,c,{type:"FeatureCollection",features:t})}}}),{success:!0}}}},[x.dW.MeasurementsModal]:{pageSize:5,blacklistedColumns:["geometry","properties"],isColumnEditable:e=>["name","description","color"].includes(e),nonTextColumns:{[x.ss.color]:["color"],[x.ss.date]:["create_date","last_updated"]},fetch:{endpoint:"/measurement/filter",method:"POST",preprocessFilters:(e,t)=>{let a=ip(t,"projectContext").project,r=new Map(e);if(r.has("area")){let e=r.get("area");r.set("area",(0,ai.VG)("area",parseFloat(e),a.units).toString())}if(r.has("distance")){let e=r.get("distance");r.set("distance",(0,ai.VG)("distance",parseFloat(e),a.units).toString())}if(r.has("range")){let e=r.get("range");r.set("range",(0,ai.VG)("range",parseFloat(e),a.units).toString())}return r},extendPayloadFields:(e,t)=>{ix(e,"project_id",ip(t,"projectContext").project.project_uuid),ix(e,"include_lat_lon","true")},processResponse:(e,t)=>{let a=ip(t,"projectContext").project,r=e.rows;return{rows:(0,ai.b8)(r,a.units),total:e.total}}},update:{updateItem:async(e,t,a)=>{let r=ip(a,"mapContext"),s=ip(a,"projectContext").project,l={type:"Feature",geometry:e.geometry,properties:{...e.properties,...Object.fromEntries(t)}};await tt(s,l);try{E(r.map,l)}catch(e){return{success:!1,error:`Measurement updated successfully but map refresh failed: ${e}`}}return{success:!0}}},delete:{deleteItem:async(e,t)=>{let a=ip(t,"projectContext").project,r=ip(t,"mapContext"),s={type:"Feature",geometry:e.geometry,properties:e.properties};if(!await (0,v.oo)(a.project_uuid,s))return{success:!1,error:"Failed to delete measurement data"};try{T(r.map,s)}catch{return{success:!1,error:"Measurement deleted successfully but map refresh failed"}}return{success:!0}}}},[x.dW.PointcloudsModal]:{pageSize:100,blacklistedColumns:["uuid","project_id","bbox","filepath","user","batch_id"],isColumnEditable:e=>!["batch_name","status","epsg"].includes(e),nonTextColumns:{[x.ss.date]:["date"],[x.ss.option]:["survey_units","pointcloud_units"],[x.ss.processingStatus]:["status"]},getAllowedOptions:e=>"survey_units"===e||"pointcloud_units"===e?["mm","cm","in","ft"]:[],goto:{canGoto:e=>!!e.bbox,gotoItem:(e,t)=>{let a=ip(t,"mapContext");return a.map.current?((0,eo.Gr)(a.map.current,(0,v.hf)(e.bbox),{essential:!0,duration:eB.AD}),(0,aR.Pv)(a.map,e.uuid),{success:!0}):{success:!1,error:"Map context is missing"}}},fetch:{endpoint:"/map/filter-lidar",method:"POST",preprocessFilters:(e,t)=>{let a=ip(t,"selectedLidarBatchId"),r=new Map(e);return null!=a&&r.set("batch_id",a),r},extendPayloadFields:(e,t)=>{ix(e,"project_id",ip(t,"projectContext").project.project_uuid),ix(e,"epsg_format","number")},processResponse:e=>({rows:ik(e.rows),total:e.total})},update:{updateItem:async(e,t,a)=>{let r=ip(a,"lidarContext"),s=e.uuid,l=["name","date"],i=Object.fromEntries(Array.from(t.entries()).filter(([e])=>!l.includes(e)));if(!s)return{success:!1,error:"Lidar UUID is missing"};try{await (0,sj.ux)(s,i,t.get("name")??e.name,new Date(t.get("date")??e.date))}catch(e){return{success:!1,error:e instanceof Error&&e.message?e.message:"Failed to update LiDAR data"}}return r.setRefreshLidars(e=>e+1),{success:!0}}},delete:{deleteItem:async(e,t)=>{let a=ip(t,"lidarContext");return await (0,sj.cN)(e.uuid)?(a.setRefreshLidars(e=>e+1),{success:!0}):{success:!1,error:"Failed to delete LiDAR data"}}}}},ih=(e,t)=>{for(let[a,r]of Object.entries(im[e]?.nonTextColumns||{}))if(r.includes(t))return a;return x.ss.text},ix=(e,t,a)=>{if(e instanceof URLSearchParams)e.set(t,a);else if(e instanceof FormData)e.append(t,a);else throw Error("Payload must be either URLSearchParams or FormData")},ig=e=>e instanceof Error?e.message:"Unknown error",iy=e=>{let t=im[e];
109if(!t)throw Error(`No configuration found for modal type ${e}`);return t},ib=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?null:t},ij=e=>e?ib(e)??("string"==typeof e?ib(e.trim().replace(" ","T").replace(/\.(\d{3})\d+/,".$1")):null):null,iw=async(e,t)=>{let a="GET"===e.method;return await (0,_.x)(e.endpoint,{method:e.method,...a?{params:Object.fromEntries(t)}:{form:t}})},iv=async(e,t,a,r=0,s,l)=>{try{var i;let n,o=iy(e);if(!o.fetch?.endpoint)throw Error(`No fetch configuration found for modal type ${e}`);let c=r*o.pageSize,d=o.fetch,u=l&&d.preprocessFilters?d.preprocessFilters(l,t):l,p=(i=o.pageSize,n="GET"===d.method?new URLSearchParams:new FormData,u&&u.size>0&&ix(n,"filters",JSON.stringify(Object.fromEntries(u))),s&&ix(n,"sort",JSON.stringify(s)),ix(n,"limit",i.toString()),ix(n,"offset",c.toString()),d.extendPayloadFields(n,t),n),m=await iw(d,p);if(!m)return a([]),{success:!1,error:"No data received"};let h=d.processResponse?await d.processResponse(m,t):m;return a(h),{success:!0}}catch(e){return{success:!1,error:ig(e)}}},iN=async(e,t,a,r)=>{try{let s=iy(e);if(!s.update?.updateItem)throw Error(`No update configuration found for modal type ${e}`);return await s.update.updateItem(t,a,r)}catch(e){return{success:!1,error:ig(e)}}},iS=async(e,t,a)=>{try{let r=iy(e);if(!r.delete?.deleteItem)throw Error(`No delete configuration found for modal type ${e}`);return await r.delete.deleteItem(t,a)}catch(e){return{success:!1,error:ig(e)}}},ik=e=>e.map(e=>{if(e.batch_name){let{batch_name:t,...a}=e;e={batch_name:t.replace(/_\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/,""),...a}}if("status"in e){let{status:t,...a}=e;e={status:t,...a}}return e}),i_=e=>{let t=(0,ev.O)(),a=(0,eG.JY)(),r=(0,ex.u)(),s=(0,eV.H)(),l=(0,sl.i)(),i=(0,eN.D)(),n=t.project,o=!!n?.container_name,[c,d]=(0,h.useState)(void 0),u=(0,h.useMemo)(()=>({projectContext:t,mapContext:a,userContext:r,layersContext:s,gisDataVersionContext:l,lidarContext:i,containerName:n?.container_name,GISLayerId:s.activeTabularLayerID??void 0,selectedLidarBatchId:c??null}),[n,r,s.activeTabularLayerID,c,l]);return{isReadyToFetch:o,handleFetchTabularData:async(t,a=0,r,l)=>n?.container_name&&(e!==x.dW.GISModal||s.activeTabularLayerID)?await iv(e,u,t,a,r,l):{success:!1,error:"Project container name or GIS layer ID is missing"},handleUpdateTabularData:async(t,a)=>await iN(e,t,a,u),handleDeleteTabularData:async t=>await iS(e,t,u),handleGotoTabularData:t=>((e,t,a)=>{try{let r=iy(e),s=a.mapContext?.map.current;if(r.goto)if(r.goto.canGoto(t))return r.goto.gotoItem(t,a);else return{success:!1,error:"No location information found"};if(!(0,eo.Uy)(t.lat,t.lon).isValid||!s)return{success:!1,error:"No location information found"};{let e=18;return t.properties?.distance<5&&(e=24),s.flyTo({center:[t.lon,t.lat],zoom:e,essential:!0,duration:eB.AD}),{success:!0}}}catch(e){return{success:!1,error:ig(e)}}})(e,t,u),selectedLidarBatchId:c,setSelectedLidarBatchId:d}},iC={[x.nW.processing]:"Processing",[x.nW.complete]:"Complete",[x.nW.error]:"Failed",[x.nW.cancelled]:"Cancelled"};function iL({status:e}){let t=e=>iC[e]||"Processing";switch(e){case x.nW.error:case x.nW.cancelled:return(0,o.jsxs)("span",{className:"tt-red-badge flex items-center w-19",style:{gap:"5px",paddingLeft:"6px"},children:[(0,o.jsx)(W.IeJ,{size:15,className:"m-0 p-0"}),t(e)]});case x.nW.complete:return(0,o.jsxs)("span",{className:"tt-green-badge flex items-center w-24",children:[(0,o.jsx)(W.LW,{}),t(e)]});default:return(0,o.jsxs)("span",{className:"tt-blue-badge flex items-center w-26",children:[(0,o.jsx)("span",{className:"loading loading-spinner w-3"}),t(e)]})}}var iD=a(95929);function iA({modalType:e,column:t,value:a,isEditable:r,editedValues:s,editingValues:l,setEditingValues:i,onEnter:n,handleRetryBatchUpload:c,shouldShowRetryProcessingIcon:d}){let u=im[e],p=ih(e,t),m=a;Array.isArray(m)&&0===m.length?m="":m&&(m="object"==typeof a?JSON.stringify(a):a.toString());let h=(e,t)=>{i(a=>{let r=new Map(a);return r.set(e,t),r})},f=e=>
109{switch(e){case x.ss.color:return"w-6 h-7 ml-2 rounded";case x.ss.option:return"w-full h-full select select-xs text-xs px-1.5 py-1.5";default:return"w-full h-full input input-xs text-xs px-1.5 py-1.5"}};if(r)return(()=>{if(p===x.ss.color)return(0,o.jsx)("div",{className:"flex items-center justify-center",onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),n&&n())},children:(0,o.jsx)(tr,{color:l.get(t)??m??"#000000",handleChangeColor:e=>{e&&h(t,e.target.value)},label:"",customWidth:50})});if(p===x.ss.option&&u?.getAllowedOptions){let e=l.get(t)??m??"",a=u.getAllowedOptions(t).includes(e);return(0,o.jsxs)("select",{value:l.get(t)??m??"",className:f(p),onChange:e=>{e&&h(t,e.target.value)},children:[(0,o.jsx)("option",{value:"",children:"-- Select --"},"none"),u.getAllowedOptions?.(t)?.map((e,t)=>(0,o.jsx)("option",{value:e,children:e},t)),e&&!a&&(0,o.jsxs)("option",{value:e,disabled:!0,children:[e," (invalid)"]},"invalid")]})}{if(p===x.ss.processingStatus)return(0,o.jsx)(iL,{status:l.get(t)??m??x.nW.processing});let e=p===x.ss.date?"datetime-local":p,a=l.get(t)??m??"",r=p===x.ss.date?(e=>{let t=ij(e);if(!t)return"";let a=e=>`${e}`.padStart(2,"0");return`${t.getFullYear()}-${a(t.getMonth()+1)}-${a(t.getDate())}T${a(t.getHours())}:${a(t.getMinutes())}`})(a):a;return(0,o.jsx)("input",{type:e,value:r,className:f(p),onChange:e=>{e&&h(t,e.target.value)},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),n&&n())}})}})();if(p===x.ss.color)return(0,o.jsx)("div",{style:{backgroundColor:s.get(t)??m??"#000000"},className:"w-5 h-5 rounded-full mx-auto border-gray-200 border-2",title:m});if(p===x.ss.processingStatus){let e=s.get(t)??m??x.nW.processing;return(0,o.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,o.jsx)(iL,{status:e}),e===x.nW.error&&d&&(0,o.jsx)("button",{className:"btn btn-xs rounded-full font-normal tooltip tooltip-left","data-tip":"retry upload",onClick:c,children:(0,o.jsx)(iD.i0I,{})})]})}if(p!==x.ss.date)return(0,o.jsx)("span",{"data-testid":"tabular-row",children:m});{var g;let e;return(0,o.jsx)("span",{children:(e=ij(g=m))?e.toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"string"==typeof g?g:""})}}let iM=["png","jpg","jpeg","gif","webp","pdf"],iE=new Set(["image/png","image/jpeg","image/gif","image/webp","application/pdf"]),iT="hover:bg-gray-100 rounded-md p-2 opacity-80 bg-gray-100/50 shadow items-center justify-center flex gap-2 self-start max-w-full text-black";function iI({fileName:e,onClick:t}){let a=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("span",{className:"flex-shrink-0",children:(0,v.sW)((0,v.ti)(e))}),(0,o.jsx)("span",{className:"text-sm line-clamp-1 overflow-hidden text-ellipsis max-w-[160px]",title:e,children:e})]});return t?(0,o.jsx)("button",{type:"button",onClick:t,className:`${iT} cursor-pointer`,children:a}):(0,o.jsx)("div",{className:iT,children:a})}function iP({file:e,previewUrl:t,onRemove:a}){let r=e.type.startsWith("image/");return(0,o.jsxs)("div",{className:"flex flex-col gap-2",children:[r?(0,o.jsx)("img",{src:t??void 0,alt:e.name,className:"max-h-40 rounded object-contain self-start"}):(0,o.jsx)(iI,{fileName:e.name}),(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Will be saved when you click save."}),(0,o.jsx)("button",{type:"button",className:"btn btn-xs self-start",onClick:a,children:"Remove selection"})]})}function iF({attachment:e,isEditing:t,onOpenPdf:a,onDelete:r}){let[s,l]=(0,h.useState)(!1),i=e.mimeType.startsWith("image/");return(0,o.jsxs)("div",{className:"flex flex-col gap-2",children:[i&&(0,o.jsx)(B,{isOpen:s,closeModal:()=>l(!1),url:e.url}),i?(0,o.jsx)("button",{type:"button",onClick:()=>l(!0),className:"self-start cursor-pointer",children:(0,o.jsx)("img",{src:e.url,alt:e.fileName,className:"max-h-40 rounded object-contain cursor-pointer"})}):(0,o.jsx)(iI,{fileName:e.fileName,onClick:()=>a(e.url)}),t&&(0,o.jsx)("button",{type:"button",className:"btn btn-xs self-start",onClick:r,children:"Delete attachment"})]})}function iO({onUndo:e}){return(0,o.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,o.jsx)("span",{className:"text-xs text-gray-500",children:"Will be deleted when you click save."}),(0,o.jsx)("button",{type:"button",className:"btn btn-xs self-start",onClick:e,children:"Undo"})]})}function iR({onSelectFile:e}){return(0,o.jsx)(eL.l,{types:iM,multiple:!1,handleChange:e,name:"file",classes:"file-uploader",children:(0,o.jsxs)("div",{className:"file-uploader-box text-center",children:[(0,o.jsx)(W.v4w,{size:14,className:"flex text-black/50"}),(0,o.jsx)("span",{className:"text-black/50 text-xs mt-1",children:"Upload an image or PDF"}),(0,o.jsxs)("span",{className:"text-black/50 text-xs",children:["Max: ",(0,v.z3)(0x1900000)]})]})})}function i$({isEditing:e,attachment:t,pendingFile:a,pendingDelete:r,onSelectFile:s,onToggleDelete:l}){let[i,n]=(0,h.useState)(null),c=(0,tH.C)(),{openModal:d}=(0,tZ.O)(x.dW.PDFViewerModal);return((0,h.useEffect)(()=>
109{if(!a?.type.startsWith("image/"))return void n(null);let e=URL.createObjectURL(a);return n(e),()=>URL.revokeObjectURL(e)},[a]),a)?(0,o.jsx)(iP,{file:a,previewUrl:i,onRemove:()=>s(null)}):t&&!r?(0,o.jsx)(iF,{attachment:t,isEditing:e,onOpenPdf:e=>{c.setPdfUrl(e),d()},onDelete:()=>l(!0)}):t&&r?(0,o.jsx)(iO,{onUndo:()=>l(!1)}):e?(0,o.jsx)(iR,{onSelectFile:e=>{!iE.has(e.type)||e.size>0x1900000?y.Ay.error(`Choose a PNG, JPEG, GIF, WebP, or PDF file up to ${(0,v.z3)(0x1900000)}.`):s(e)}}):null}let iz=Symbol("featureAttachment");function iU({modalType:e,headers:t,row:a,rowIndex:r,attachmentColumn:s,refreshEditingStatus:l,setRowToDelete:i,setBatchToRetryUpload:n,onEditRow:c}){let d=(0,eG.JY)(),{handleUpdateTabularData:u,handleGotoTabularData:p}=i_(e),[m,f]=(0,h.useState)(!1),[g,b]=(0,h.useState)(new Map),[j,w]=(0,h.useState)(new Map),[N,S]=(0,h.useState)(!1),k=im[e],_=e===x.dW.PointcloudsModal&&void 0!==a.batch_name&&null!==a.batch_id;(0,h.useEffect)(()=>{f(!1),b(new Map),w(new Map)},[l]);let C=async()=>{let t={...a,...Object.fromEntries(j)},r=new Map(Array.from(g.entries()).filter(([e,t])=>{let a=j.get(e);return void 0===a||t!==a}).map(([e,t])=>[e,t||null]));if(0===r.size)return void f(!1);if(!N){S(!0);try{let a=await u(t,r);if(a.success){w(g),f(!1);let t=e.toLowerCase().split("modal")[0];y.Ay.success(`Successfully updated ${t} data`)}else y.Ay.error(`Failed to update tabular data: ${a.error}`)}finally{S(!1)}}},L=()=>{n(a.batch_id)};return(0,o.jsxs)("tr",{className:`relative group/row ${r%2==1?"[&>td]:bg-[#f2f2f2]":"[&>td]:bg-[#fafafa]"}`,children:[(k?.goto?k.goto.canGoto(a):(0,eo.Uy)(a.lat,a.lon).isValid)?(0,o.jsx)("td",{className:"px-4 py-2 text-black text-center align-middle sticky left-0 bg-[#f9f9f9] z-10 border border-gray-200 max-w-[250px]",children:(0,o.jsx)($.iyI,{onClick:()=>{let e=p(a);e.success?(0,v.Ne)(d.map,a.lat,a.lon,d.markerRef):y.Ay.error(e.error||"Failed to go to tabular data")},color:"blue",className:"cursor-pointer mx-auto",size:20})}):(0,o.jsx)("td",{className:"px-4 py-2 bg-transparent border-0 max-w-[250px]"}),t.slice(1).map(t=>{if(t===s)return(0,o.jsx)("td",{className:"px-4 py-2 text-black align-top border border-gray-200 max-w-[220px]",children:(0,o.jsx)(i$,{isEditing:!1,attachment:a[iz]??null,pendingFile:null,pendingDelete:!1,onSelectFile:()=>{},onToggleDelete:()=>{}})},`${r}-${t}`);let l=(m&&k?.isColumnEditable(t)&&!k?.blacklistedColumns.includes(t)&&!k?.nonTextColumns[x.ss.processingStatus]?.includes(t))??!1,i=j.has(t)?j.get(t):a[t];return(0,o.jsx)("td",{className:`${l?"px-2.5 py-0":"px-4 py-2"} text-black whitespace-nowrap overflow-hidden border border-gray-200 w-48 max-w-[250px]`,style:{textOverflow:"ellipsis"},children:(0,o.jsx)(iA,{modalType:e,column:t,value:i,isEditable:l,editedValues:j,editingValues:g,setEditingValues:b,onEnter:C,handleRetryBatchUpload:L,shouldShowRetryProcessingIcon:_})},`${r}-${t}`)}),(0,o.jsx)("td",{className:`
110        sticky right-0 z-10 p-0 border-0
111        ${m?"opacity-100":"opacity-0 group-hover/row:opacity-100"}
112        flex items-center justify-start h-full
113        text-black/80 whitespace-nowrap
114      `,style:{backgroundColor:"transparent"},children:(0,o.jsx)("div",{className:`
115          flex items-center justify-center gap-2
116          bg-white rounded-md px-2 py-1.5 mx-2 shadow
117        `,children:m?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("button",{onClick:C,disabled:N,className:"btn btn-xs tt-blue-button",style:{boxShadow:"0 1px 3px 0 rgb(0 0 0 / 0.4)"},children:N?(0,o.jsx)("span",{className:"loading loading-spinner loading-xs"}):"Save"}),(0,o.jsx)("button",{onClick:()=>{b(j),f(!1)},className:"btn btn-xs",children:(0,o.jsx)(ek.WQq,{})})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("button",{onClick:()=>{c?c(a):f(!0)},className:"btn btn-xs",children:(0,o.jsx)($.VZ_,{className:"text-sm"})}),k?.delete&&(0,o.jsx)("button",{onClick:()=>{i(a)},className:"btn btn-xs","data-testid":`${e===x.dW.PointcloudsModal?"tabular-pointcloud-delete-button":""}`,children:(0,o.jsx)(W.WeY,{className:"text-sm text-red-500"})})]})})})]},r)}function iW({modalType:e,headers:t,attachmentColumn:a,sortConfig:r,searchFilters:s,filterColor:l,handleSortData:i,handleSearchFilterChange:n,submitSearch:c,setFilterColor:d}){let{modalState:u}=(0,tZ.O)(e),p=(0,ev.O)(),[m,f]=(0,h.useState)(null),g=(e,t)=>{n(e,t),c()},y=(e,t,a)=>
117(0,o.jsxs)("select",{value:e,onChange:e=>g(t,e.target.value),className:"w-full px-2 py-1 border border-gray-300 rounded text-sm font-normal text-black",children:[(0,o.jsx)("option",{value:"",children:"All"}),a]});return(0,h.useEffect)(()=>{let e=document.querySelectorAll("th.tabular-header-first"),a={};t.forEach((t,r)=>{a[t]=e[r].getBoundingClientRect().width,a[t]>250&&(a[t]=250)}),f(a)},[t]),(0,h.useEffect)(()=>{u.display||f(null)},[u]),(0,o.jsxs)("thead",{className:"sticky top-0 z-20 bg-gray-300",children:[(0,o.jsxs)("tr",{className:"[&_th]:border-b-0 [&>th]:max-w-[200px]",children:[(0,o.jsxs)("th",{className:"tabular-header-first text-center text-black whitespace-nowrap border border-gray-200 px-4 py-2 shadow-md bg-white relative w-[50px]",style:{minWidth:m?.["Go to"]},children:["Go to",(0,o.jsx)("div",{className:"absolute -bottom-px left-0 right-0 h-px bg-gray-200"})]}),t.slice(1).map((t,s)=>{let l=t!==a&&ih(e,t)!==x.ss.attachment;return(0,o.jsxs)("th",{className:`tabular-header-first text-left text-black border border-gray-200 px-4 py-2 shadow-md bg-white relative max-w-[250px] ${l?"cursor-pointer":""}`,style:{minWidth:m?.[t]},onClick:()=>l&&i(t),children:[(0,o.jsxs)("div",{className:"flex items-center gap-1 overflow-hidden",children:[(0,o.jsx)("span",{className:"truncate",title:(0,ai.V0)(t,p.project?.units||""),children:(0,ai.V0)(t,p.project?.units||"")}),l&&(0,o.jsx)("span",{className:"flex-shrink-0",children:r?.column!==t?(0,o.jsx)(W.gER,{className:"inline ml-2"}):r.ascending?(0,o.jsx)(W.Ob1,{className:"inline ml-2"}):(0,o.jsx)(W.D_L,{className:"inline ml-2"})})]}),(0,o.jsx)("div",{className:"absolute -bottom-px left-0 right-0 h-px bg-gray-200"})]},s)}),(0,o.jsx)("th",{className:"tabular-header-first border-0 bg-white relative"})]}),(0,o.jsxs)("tr",{className:"[&_th]:border-t-0 [&>th]:max-w-[200px]",children:[(0,o.jsxs)("th",{className:"tabular-header-second border-gray-200 px-4 py-2 bg-white relative w-[50px]",style:{minWidth:m?.["Go to"]},children:[(0,o.jsx)("span",{className:"text-black text-sm font-normal",children:"Filter"}),(0,o.jsx)("div",{className:"absolute -bottom-px left-0 right-0 h-px bg-gray-200"})]}),t.slice(1).map((t,r)=>(0,o.jsx)("th",{className:"tabular-header-second border border-gray-200 px-4 py-2 bg-white relative max-w-[250px]",style:{minWidth:m?.[t]},children:(t=>{if(t===a)return null;let r=s.get(t)||"",i=ih(e,t);switch(i){case x.ss.color:return(0,o.jsx)("div",{className:"flex items-center justify-center",children:(0,o.jsx)(tr,{color:l,handleChangeColor:e=>{var a;d(a=e.target.value),g(t,a)},label:"",customWidth:50})});case x.ss.date:return(0,o.jsx)("div",{className:"flex justify-center",children:(0,o.jsx)("input",{type:i,value:r,onChange:e=>g(t,e.target.value),className:"input w-36 px-2 border border-gray-300 rounded text-sm font-normal text-black"})});case x.ss.option:let u=im[e],p=u?.getAllowedOptions?.(t)||[];return y(r,t,p.map(e=>(0,o.jsx)("option",{value:e,children:e},e)));case x.ss.processingStatus:return y(r,t,Object.keys(iC).map(e=>(0,o.jsx)("option",{value:e,children:iC[e]},e)));case x.ss.attachment:return null;default:return(0,o.jsx)("input",{type:i,value:r,onChange:e=>n(t,e.target.value),onKeyDown:e=>{"Enter"===e.key&&c()},className:"w-full px-2 py-1 border border-gray-300 rounded text-sm font-normal text-black",placeholder:`Search ${t}...`})}})(t)},r)),(0,o.jsx)("th",{className:"tabular-header-second bg-white border-0 relative"})]})]})}function iB({resetSearch:e,submitSearch:t,selectedLayer:a,modalType:r,lidarBatchNames:s,setSelectedLidarBatchId:l,allRowCount:i,doFilteredDataExist:n}){return(0,o.jsxs)("div",{className:`
118        mb-3 flex gap-3 items-start justify-between
119        sticky top-0 z-10 bg-white w-full
120      `,children:[(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,o.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,o.jsxs)("button",{onClick:e,className:"btn btn-sm w-max",children:[(0,o.jsx)(em.UF6,{}),"Reset Search"]}),(0,o.jsxs)("button",{onClick:t,className:"btn btn-sm tt-blue-button flex justify-start pr-5 w-max",children:[(0,o.jsx)(em.zfp,{}),"Search"]})]}),r===x.dW.PointcloudsModal&&s&&s.length>1&&(0,o.jsxs)("select",{defaultValue:"Select Batch",className:"flex-1 select select-sm text-black w-50 max-w-50",onChange:e=>{""==e.target.value?l(void 0):l(e.target.value)},children:[(0,o.jsx)("option",{value:"",children:"Select Batch"}),[...s].sort((e,t)=>
120e.name.localeCompare(t.name)).map(e=>(0,o.jsx)("option",{value:e.uuid,children:e.name.replace(/_\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/,"")},e.uuid))]}),r===x.dW.GISModal&&a&&a.source===rX.mb.ArcGIS&&a.status===x.iO.processing&&(0,o.jsx)("div",{children:(0,o.jsxs)("span",{className:"flex-1 text-black/70 py-1.5 gap-2 flex text-xs",children:[(0,o.jsx)("span",{className:"loading loading-xs loading-spinner"}),"Processing - Initial results ready"]})})]}),(0,o.jsxs)("span",{className:"text-black/60 mt-1.5 border-transparent whitespace-nowrap",children:["Rows: ",n?i.toLocaleString():0]})]})}let iV=sd("ReactFormGenerator"),iG=function({layer:e,onClose:t,onSave:a,editFeatureId:r}){let{map:s}=(0,eG.JY)(),{goBack:l}=(0,e$.p)(),{project:i}=(0,ev.O)(),{drawingGeojson:n,clearDrawing:c}=(0,eb.g)(),[d,u]=(0,h.useState)([]),[p,m]=(0,h.useState)({task_data:[]}),x=void 0!==r,[f,g]=(0,h.useState)(!1),b=p.task_data.length>0&&f;(0,h.useEffect)(()=>{u([]),m({task_data:[]}),g(!1),(async()=>{try{let t=parseInt(e.id),a=i?.project_uuid??"",[s,l]=await Promise.all([x?rQ({layerId:t,featureId:r}):Promise.resolve([]),r0({layerId:t,projectId:a})]);u(s),m(l),g(!0)}catch(e){console.error(e),y.Ay.error("Failed to load form template")}})()},[r,x,e.id,i?.project_uuid]);let j=()=>{c(x),l(),t()},w=async t=>{let l;if(0===n.features.length)return void y.Ay.error("No features drawn");let o=parseInt(e.id);try{x?(l=r,await r2({layerId:o,featureId:l,metadata:t,geoJsonFeature:n.features[0]})):l=(await r1({layerId:o,projectId:i?.project_uuid||"",formData:t,geojson:n})).featureId;let c="string"==typeof e.id?e.id:`${e.id}-layer`;!function({map:e,layerId:t,drawingGeojson:a,featureId:r}){let s={geojson:{type:"FeatureCollection",features:a.features.map(e=>({...e,id:r,properties:{...e.properties,uuid:r}}))}};(0,av.Bg)(s.geojson.features),(0,av.yD)(e,s,t)}({map:s,layerId:c,drawingGeojson:n,featureId:l}),y.Ay.success("Custom form submitted successfully"),a?.(),j()}catch(e){console.error(e),y.Ay.error("Failed to add custom form")}};return(0,o.jsx)(o.Fragment,{children:b?(0,o.jsx)(iV,{form_action:"",form_method:"",answer_data:d,data:p.task_data,onSubmit:w,...x&&{action_name:"Save",backButton:(0,o.jsx)("button",{className:"flex-1 btn",type:"button",onClick:j,children:"Cancel"})}},`${e.id}-${r??"new"}`):(0,o.jsx)("div",{className:"flex justify-center items-center",children:(0,o.jsx)("div",{className:"loading loading-spinner loading-lg"})})})},iJ=()=>{let{map:e}=(0,eG.JY)(),{setBottomMenuOpen:t}=(0,ej.H)(),{clearDrawing:a,importFeatures:r,selectFeatureForEditing:s,setDrawingColor:l,setSkipClearOnModeExit:i}=(0,eb.g)(),{toggleSidePanel:n,closePanel:c}=(0,e$.p)(),{closeModal:d}=(0,tZ.O)(),u=(0,h.useRef)(!1);return{editCustomFormFeature:({layer:p,featureUuid:m,sourceId:h,onSave:f})=>{var g,y;let b,j=e.current?.getSource(h);if(!j||"geojson"!==j.type)return;t({open:!1,id:0,event:null}),d(x.dW.MetadataModal);let w=(g=j,y=m,{...b=g._data,features:b.features.filter(e=>String(e.id)===String(y))});w&&(i(!0),u.current=!0,n((0,o.jsx)(iG,{layer:p,onClose:()=>{i(!1),u.current=!1,e.current?.removeFeatureState({source:h,id:m}),c()},onSave:f,editFeatureId:m}),{key:`custom-form-edit-${h}-${m}`,title:`Edit Custom Form ${p.name}`,onClose:()=>{i(!1),u.current=!1,e.current?.removeFeatureState({source:h,id:m}),a()}}),r(w),l(p.properties.color),s({featureId:m}),e.current?.setFeatureState({source:h,id:m},{hidden:!0}))}}};function iq({modalType:e,modalTitle:t}){let a=(0,eV.H)(),r=(0,ev.O)(),{modalState:s}=(0,tZ.O)(e),{handleFetchTabularData:l,isReadyToFetch:i,handleDeleteTabularData:n,selectedLidarBatchId:c,setSelectedLidarBatchId:d}=i_(e),{editCustomFormFeature:u}=iJ(),[p,m]=(0,h.useState)(0),[f,g]=(0,h.useState)(0),[b,j]=(0,h.useState)([]),[w,v]=(0,h.useState)(!1),[N,S]=(0,h.useState)(!0),[k,_]=(0,h.useState)(void 0),[C,L]=(0,h.useState)(new Map),[D,A]=(0,h.useState)(!1),[M,E]=(0,h.useState)("#FFFFFF"),[T]=(0,h.useState)(new Map),[I,P]=(0,h.useState)(void 0),[F,O]=(0,h.useState)(!1),[R,$]=(0,h.useState)(void 0),[z,U]=(0,h.useState)([]),[W,B]=(0,h.useState)(),[G,J]=(0,h.useState)(void 0),q=e===x.dW.GISModal?a.tabularDataRefreshKey:0,Y=(0,h.useRef)(q),H=(0,h.useRef)(0),Z=im[e],X=Z?.pageSize||100,K=["lat","lon"],Q=h.useMemo(()=>
120{if(!b.some(e=>Object.hasOwn(e,iz)))return;let e=new Set(b.flatMap(e=>Object.keys(e))),t="Attachment";for(;e.has(t);)t=`${t} (feature)`;return t},[b]),ee=h.useMemo(()=>{if(e!==x.dW.GISModal)return!1;let t=a.customLayers.find(e=>e.id?.toString()===a.activeTabularLayerID);return!!t&&(0,ra.fR)(t.source)},[e,a.customLayers,a.activeTabularLayerID]),et=e=>{let t=a.customLayers.find(e=>e.id?.toString()===a.activeTabularLayerID);t&&u({layer:t,featureUuid:Number(e.uuid),sourceId:`${t.id}-source`,onSave:es})},ea=h.useMemo(()=>{if(0===b.length)return[];let t=new Set;b.forEach(e=>{Object.keys(e).forEach(e=>{t.add(e)})});let a=Array.from(t).filter(e=>![...Z?.blacklistedColumns||[],...K].includes(e));return e===x.dW.GISModal&&a.includes("type")&&(a.splice(a.indexOf("type"),1),a.push("type")),["Go to",...Q?[Q]:[],...a]},[Q,b,e]),er=async()=>{let e=++H.current;S(!0);let t=await l(t=>{e===H.current&&ei(t)},p,k,C);e===H.current&&(t.success?P(a.customLayers.find(e=>(0,ai.MR)(e)===a.activeTabularLayerID)):y.Ay.error(`Failed to fetch tabular data: ${t.error}`),S(!1))},es=()=>{T.clear(),m(0),A(e=>!e)},el=()=>{j([]),L(new Map),_(void 0),S(!0),T.clear()};(0,h.useEffect)(()=>{O(e=>!e),s.display?i&&(Y.current!==q&&T.clear(),er()):(el(),S(!1)),Y.current=q},[s.display,i,D,q]),(0,h.useEffect)(()=>{e===x.dW.GISModal&&(el(),A(e=>!e))},[a.activeTabularLayerID,a.customLayers]),(0,h.useEffect)(()=>{e==x.dW.PointcloudsModal&&async function(){if(r.project?.project_uuid)try{let e=await sY(r.project?.project_uuid);U(e)}catch(e){console.error("Error getting batch names: ",e)}}()},[s.display,D]),(0,h.useEffect)(()=>{es()},[c]);let ei=e=>{g(e.total);let t=e.rows.map(t=>e.attachments?{...t,[iz]:e.attachments[Number(t.uuid)]??null}:t);if(t.length>0)j(t),v(!0),T.set(p,t);else{v(!1);let t=Math.max(0,Math.ceil(e.total/X)-1);p>t&&(j([]),m(t),A(e=>!e))}S(!1)},en=async e=>{let t=e.selected;m(t),O(e=>!e),T.has(t)?(H.current+=1,j(T.get(t)),S(!1)):A(e=>!e)},eo=async()=>{if(R)try{let t=await n(R);if(t.success){es();let t=e.toLowerCase().split("modal")[0];y.Ay.success(`Successfully deleted ${t} data`)}else y.Ay.error(`Failed to delete tabular data: ${t.error}`)}catch(e){y.Ay.error(`Failed to delete tabular data: ${ig(e)}`)}finally{$(void 0)}},ec=async()=>{if(e===x.dW.PointcloudsModal&&void 0!==G)try{await sH(G),es(),y.Ay.success("Successfully retried lidar batch upload")}catch(t){let e=ig(t);y.Ay.error(e||"Failed to retry lidar batch upload")}finally{J(void 0)}};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(V.A,{isOpen:void 0!==R,onDelete:()=>eo(),closeModal:()=>$(void 0)}),(0,o.jsx)(V.A,{isOpen:void 0!==G,onDelete:()=>ec(),closeModal:()=>J(void 0),deleteText:"Are you sure you want to retry upload?",warningText:"All failed lidars in this batch will be retried."}),(0,o.jsx)(t4,{modalType:e,defaultPosition:{x:80,y:80},defaultSize:{width:750,height:500},backgroundColor:"white",lockRatio:"nolock",title:"Tabular View for "+t,setModalSize:e=>B(e),children:(0,o.jsxs)("div",{className:"flex flex-col h-full mx-5 py-4",children:[N&&(0,o.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,o.jsx)("span",{className:"loading loading-spinner",style:{color:"black"}})}),!N&&0===b.length&&(0,o.jsx)("div",{className:"opacity-70 text-sm text-black text-center my-auto",children:"No data found"}),!N&&b.length>0&&(0,o.jsxs)("div",{className:"flex flex-col h-full",children:[(0,o.jsx)(iB,{resetSearch:()=>{_(void 0),L(new Map),E("#FFFFFF"),es()},submitSearch:es,selectedLayer:I,modalType:e,lidarBatchNames:z,setSelectedLidarBatchId:d,modalSize:W,allRowCount:f,doFilteredDataExist:w}),(0,o.jsx)("div",{className:"overflow-auto force-scrollbar",children:(0,o.jsxs)("table",{className:"table-auto w-full border-collapse border-0 border-l border-gray-200",children:[ea.length>0&&(0,o.jsx)(iW,{modalType:e,headers:ea,attachmentColumn:Q,sortConfig:k,handleSortData:e=>{_(t=>{let a=t?.column!==e||!t?.ascending;return{column:e,ascending:a}}),es()},searchFilters:C,filterColor:M,handleSearchFilterChange:(e,t)=>
120{L(a=>{let r=new Map(a);return t?r.set(e,t):r.delete(e),r})},submitSearch:es,setFilterColor:E}),w&&(0,o.jsx)("tbody",{children:b.map((t,a)=>(0,o.jsx)(iU,{modalType:e,headers:ea,row:t,rowIndex:a,attachmentColumn:Q,refreshEditingStatus:F,setRowToDelete:$,setBatchToRetryUpload:J,onEditRow:ee?et:void 0},a))})]})}),w&&f>X&&(0,o.jsx)("div",{className:"pagination-cont py-1 mt-auto",children:(0,o.jsx)(lO(),{breakLabel:"...",nextLabel:">",onPageChange:en,pageRangeDisplayed:5,previousLabel:"<",pageClassName:"page-item cursor-pointer",previousClassName:"page-item cursor-pointer",nextClassName:"page-item cursor-pointer",breakClassName:"page-item cursor-pointer",containerClassName:"pagination",activeClassName:"active",forcePage:p,pageCount:Math.ceil(f/X),renderOnZeroPageCount:null})})]})]})})]})}function iY({source:e,isEditing:t,attachment:a,pendingFile:r,pendingDelete:s,onSelectFile:l,onToggleDelete:i}){let n=!!e&&(0,ra.J3)(e),c="WFS"===e||"ArcGIS"===e;return n?c?(0,o.jsxs)("tr",{className:"bg-[#fafafa]",children:[(0,o.jsx)("td",{className:"px-4 py-1.5 border border-gray-200 text-black font-medium truncate",children:"Attachment"}),(0,o.jsx)("td",{className:"px-4 py-1.5 border border-gray-200 text-xs text-gray-500",children:"Unavailable for WFS and ArcGIS layers because source synchronization replaces feature IDs."})]}):a||r||t?(0,o.jsxs)("tr",{className:"bg-[#fafafa]",children:[(0,o.jsx)("td",{className:"px-4 py-1.5 border border-gray-200 text-black font-medium truncate",children:"Attachment"}),(0,o.jsx)("td",{className:"px-4 py-1.5 border border-gray-200",children:(0,o.jsx)(i$,{isEditing:t,attachment:a,pendingFile:r,pendingDelete:s,onSelectFile:l,onToggleDelete:i})})]}):null:null}var iH=((n=iH||{})[n.loading=0]="loading",n[n.success=1]="success",n[n.error=2]="error",n);let iZ="toolbtn cursor-pointer hover-shadow metadata-toolbar-button";function iX(e){let t=(0,ex.u)(),a=(0,eG.JY)(),r=(0,ev.O)(),s=(0,eV.H)(),{editCustomFormFeature:l}=iJ(),{openModal:i}=(0,tZ.O)(x.dW.GISModal),n=(0,h.useRef)(null),[c,d]=(0,h.useState)(1),[u,p]=(0,h.useState)(null),[m,f]=(0,h.useState)(!1),[g,b]=(0,h.useState)(0),[w,N]=(0,h.useState)(""),[S,k]=(0,h.useState)(!1),[_,C]=(0,h.useState)({}),[L,D]=(0,h.useState)(!1),[A,M]=(0,h.useState)(!1),[T,I]=(0,h.useState)(!1),[P,F]=(0,h.useState)(null),[O,R]=(0,h.useState)(null),[$,U]=(0,h.useState)(null),[B,G]=(0,h.useState)(null),[J,q]=(0,h.useState)(!1),Y=(0,rq.oD)(String(e.features.layerIds[c-1])),H=s.customLayers.find(e=>e.id===Y||e.id===Number.parseInt(Y,10)),Z=H?.status===x.iO.processing||H?.status===x.iO.initial,X=!!H&&((0,ra.J3)(H.source)||(0,ra.fR)(H.source)),K=0===g,Q=O===t?.user?.id||r.project&&(0,v._A)(t?.user,r.project.project_uuid);(0,h.useEffect)(()=>{e.features&&e.features.sources&&e.features.sources.length&&(async()=>{if(!a.map.current)return;d(1),ea(1),a.markerRef.current&&a.markerRef.current.remove();let t=document.createElement("div");t.className="cursormarker";let r=new(j()).Marker(t,{rotationAlignment:"map"}).setLngLat([e.features.lon,e.features.lat]).addTo(a.map.current);a.markerRef.current=r})()},[e.features,a.markerRef]);let ee=async()=>{c>1&&ea(c-1)},et=async()=>{c<e.features.count&&ea(c+1)},ea=async t=>{if(!a.map.current||!e.features||t<1||t>e.features.count)return;let{sources:r,featureUuids:l,layerIds:i,measurementData:n}=e.features,o=l[t-1];o&&(a.map.current.removeFeatureState({source:r[c-1]}),a.map.current.setFeatureState({source:r[t-1],id:o},{selected:!0})),b(0),U(null),G(null),q(!1);let u="measurements"===r[t-1],m=Number.parseInt(i[t-1],10),h=s.customLayers.find(e=>e.id===i[t-1]||e.id===m),x=!u&&!!h&&(0,ra.J3)(h.source)&&!["WFS","ArcGIS"].includes(h.source);try{let e;if(u){let a=n[l[t-1]];F(a.geometry),e=es(a)}else{let a=await (0,ai.og)(m,l[t-1]);e=a.metadata,x&&U(a.attachments[0]??null)}p(e),C(e),d(t),b(1)}catch(e){N(e.message),b(2)}},er=async()=>{a.map.current&&a.map.current.removeFeatureState({source:e.features.sources[c-1]})},es=e=>{let t=e.properties,a={layer:"Measurement"},s=r.project?.units??"metric";return R(t.user_id),Object.keys(t).forEach(e=>{if("uuid"!==e&&"user_id"!==e&&"color"!==e&&!e.includes("fill")&&"contour"!==e&&"metric"!==e&&"opacity"!==e&&"type"!==e){let r=t[e]??"N/A",l=e;("distance"===e||"area"===e||"range"===e)&&"number"==typeof r&&(r=(0,ai.JH)(e,r,s).toFixed(2),l=(0,ai.V0)(e,s)),a[l]=r}}),a},el=e=>{s.refreshActiveTabularLayer(e)},ei=()=>"measurements"===e.features.sources[c-1],en=()=>{let t=(0,rq.oD)(String(e.features.layerIds[c-1])),a=Number.parseInt(t,10),r=s.customLayers.find(e=>e.id===t||e.id===a);r&&(0,ra.fR)(r.source)?l({layer:r,featureUuid:e.features.featureUuids[c-1],sourceId:e.features.sources[c-1],onSave:()=>el(r.id)}):eo()},eo=()=>
120{if(!S){C(u||{}),k(!0);return}let e=!!B||J;u!==_||e?D(!0):k(!1)},ec=async()=>{let[t,a]=[e.features.featureUuids,e.features.measurementData],s={type:"Feature",geometry:P,properties:{...a[t[c-1]].properties,..._}};return await tt(r.project,s),s},ed=async t=>{if(0===Object.keys(t).length)return!1;let a=Number.parseInt(e.features.layerIds[c-1],10);return await r2({layerId:a,featureId:e.features.featureUuids[c-1],metadata:t}),!0},eu=async()=>{if(!B&&!J)return;let t=Number.parseInt(e.features.layerIds[c-1],10),a=e.features.featureUuids[c-1];J&&$?(await r4({layerId:t,featureId:a,attachmentId:$.id}),U(null)):B&&U((await r3({layerId:t,featureId:a,file:B})).attachment),G(null),q(!1)},ep=async()=>{if(A)return void y.Ay.error("Expecting valid JSON (array or object).");I(!0);try{let e=!1,t=!1;if(ei()){let t=await ec();E(a.map,t),e=Object.entries(_).some(([e,t])=>t!==u?.[e])}else{let a,r=(a={},Object.entries(_).forEach(([e,t])=>{t!==u?.[e]&&(a[e]=t)}),a);(e=await ed(r))&&p(_),(B||J)&&(await eu(),t=!0),H&&(e||t)&&el(H.id)}p(_),k(!1),(e||t)&&y.Ay.success("Metadata updated")}catch{y.Ay.error("Something went wrong. Please try again later.");return}finally{I(!1)}};return(0,o.jsxs)(t4,{modalType:x.dW.MetadataModal,closeModal:er,defaultPosition:{x:e.features.position.x,y:e.features.position.y},defaultSize:{width:400,height:305},defaultMinSize:{width:400,height:200},backgroundColor:"white",lockRatio:"nolock",title:"Feature Metadata",customButton:(0,o.jsxs)("div",{className:"flex flex-row gap-3 z-30 items-center",children:[X&&(0,o.jsx)("button",{type:"button","aria-label":"Open tabular view",title:"Open tabular view","data-testid":"metadata-tabular-view-button",disabled:K,className:`${iZ} ${K?"opacity-50 cursor-not-allowed":""}`,onClick:()=>{H&&!K&&((0,v.Fr)()&&er(),s.setActiveTabularLayerID(H.id.toString()),s.setActiveTabularLayerName(H.name),i())},children:(0,o.jsx)(rr.OKl,{size:20,color:"#000"})}),S?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("button",{type:"button","aria-label":"Discard changes",title:"Discard changes",className:iZ,onClick:en,children:(0,o.jsx)(tD.NGV,{size:20,color:"#000"})}),T?(0,o.jsx)("span",{className:"loading loading-spinner loading-sm text-black"}):(0,o.jsx)("button",{type:"button","aria-label":"Save changes",title:"Save changes",className:iZ,onClick:ep,children:(0,o.jsx)(eK.Bc_,{size:20,color:"#000"})})]}):(0,o.jsx)("button",{type:"button","aria-label":"Edit metadata",title:Z?"Layer is being refreshed":"Edit metadata","data-testid":"metadata-edit-button",disabled:Z,className:`${iZ} ${Z?"pointer-events-none opacity-50 cursor-not-allowed":""}`,onClick:en,children:(0,o.jsx)(W.dJk,{size:20,color:"#000"})}),ei()&&Q&&(0,o.jsx)("button",{type:"button","aria-label":"Delete measurement",title:"Delete measurement",className:iZ,onClick:()=>f(!0),children:(0,o.jsx)(W.WeY,{size:20,color:"#000"})})]}),children:[m&&(0,o.jsx)("div",{className:"overflow-auto",children:(0,o.jsx)(V.A,{isOpen:m,onDelete:()=>{e.handleDeleteMeasure&&e.handleDeleteMeasure(e.features.measurementData[e.features.featureUuids[c-1]])},closeModal:()=>f(!1)})}),L&&(0,o.jsx)("div",{className:"overflow-auto",children:(0,o.jsx)(V.A,{isOpen:L,onDelete:()=>{k(!1),D(!1),G(null),q(!1)},closeModal:()=>D(!1),deleteText:"Discard current changes?"})}),(0,o.jsxs)("div",{className:"flex flex-col h-full p-2",children:[(0,o.jsxs)("div",{className:"flex flex-row gap-2 justify-between",children:[(0,o.jsx)(z.l7J,{className:"cursor-pointer",color:"gray",size:20,onClick:ee}),(0,o.jsxs)("span",{className:"text-gray-600",children:[c," / ",e.features.count]}),(0,o.jsx)(z.U7T,{className:"cursor-pointer",color:"gray",size:20,onClick:et})]}),(0,o.jsxs)("div",{className:"grow overflow-auto mt-2 force-scrollbar",children:[1===g&&(0,o.jsx)("div",{className:"flex flex-col gap-2",children:(0,o.jsx)("table",{ref:n,className:"table-fixed border-collapse border border-gray-200 w-full",children:(0,o.jsxs)("tbody",{children:[!ei()&&H&&(0,o.jsx)(iY,{source:H.source,isEditing:S,attachment:$,pendingFile:B,pendingDelete:J,onSelectFile:G,onToggleDelete:q}),Object.entries(u).map(([e,t],a)=>{var r;
120let s=S&&(ei()?["name","description","color"].includes(e):!["Layer Name","type","Uploaded by"].includes(e)),l="color"===e&&ei()?x.Nq.color:x.Nq.text;return(0,o.jsxs)("tr",{className:a%2==0?"bg-[#f2f2f2]":"bg-[#fafafa]",children:[(0,o.jsx)("td",{className:"px-4 py-1.5 border border-gray-200 text-black font-medium truncate",children:e}),(0,o.jsx)("td",{className:`border border-gray-200 text-black truncate ${s?"px-[3px]":"px-4"}`,children:s?(0,o.jsx)("input",{type:l,inputMode:x.Nq.text,value:null===(r=_[e])?"":"object"==typeof r?JSON.stringify(r):r,className:"w-full input input-xs text-xs",onChange:a=>{let r=(0,ai.yh)(a,t,M);null!=r&&C(t=>({...t,[e]:r}))},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),ep())}}):(0,o.jsx)("div",{style:{backgroundColor:"color"===e&&ei()?t:"transparent"},className:"color"===e&&ei()?"w-4 h-4 rounded":"",children:"color"===e&&ei()?null:null==t?"N/A":"object"==typeof t?JSON.stringify(t):t.toString()})})]},a)})]})})}),0===g&&(0,o.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,o.jsx)("span",{className:"loading loading-spinner loading-sm text-gray-400"})}),2===g&&(0,o.jsx)("div",{className:"flex items-center justify-center h-full text-black",children:(0,o.jsx)("h2",{children:w})})]})]})]})}function iK(e,t,a,r){if(t&&e.current?.contentWindow){(function(e){if(e)try{let t=e.document;if(!t)return;let a=e.location.pathname.toLowerCase(),r={"dashboard/list":"Dashboards","chart/list":"Charts","tablemodelview/list":"Datasets","sql/list":"SQL"},s=null;for(let e in r)if(a.includes(e)){s=r[e];break}let l=t.querySelectorAll(".ant-menu-item, .ant-menu-submenu"),i=null;l.forEach(e=>{e.textContent?.trim()===s&&(i=e)}),i&&(t.querySelectorAll(".ant-menu-item-selected").forEach(e=>{e.classList.remove("ant-menu-item-selected")}),i.classList.add("ant-menu-item-selected"))}catch(e){console.error("Failed to injectTio:",e)}})(e.current.contentWindow),function(e,t){if(e&&t)try{let a=e.document;if(!a)return;let r=a.querySelector("a[href='/dashboardadmin/dashboardadmin/dashboard/list/']");r&&(r.textContent="Dashboard",r.setAttribute("href",`/dashboardadmin/superset/dashboard/${t}/`));let s=a.querySelector("a[href='/dashboardadmin/dashboardadmin/chart/list/']");s?.setAttribute("href","/dashboardadmin/chart/list/")}catch(e){console.error("Failed to replace button:",e)}}(e.current.contentWindow,a),function(e){if(e)try{let t=e.document;if(!t)return;e.open=function(t){return e.location.href=t,null},t.querySelectorAll("a").forEach(e=>{e.setAttribute("target","_self"),e.removeAttribute("rel")})}catch(e){console.error("Failed to override window.open:",e)}}(e.current.contentWindow);try{let t=e.current.contentWindow.location.href;r(t)}catch{console.warn("Unable to access iframe URL due to cross-origin restrictions.")}}}function iQ({isLoading:e,size:t="small"}){return e?(0,o.jsxs)("div",{className:"w-full bg-white flex flex-row space-x-6 p-6 absolute top-20 left-0",children:[(0,o.jsxs)("div",{className:"flex flex-col space-y-4 w-1/5",children:[(0,o.jsx)("div",{className:"skeleton h-12 w-full"}),(0,o.jsx)("div",{className:"skeleton h-8 w-3/4"}),(0,o.jsx)("div",{className:"skeleton h-8 w-3/4"}),(0,o.jsx)("div",{className:"skeleton h-8 w-3/4"})]}),(0,o.jsxs)("div",{className:"flex flex-col w-4/5 space-y-6",children:[(0,o.jsx)("div",{className:"skeleton h-10 w-1/3"}),(0,o.jsxs)("div",{className:"flex space-x-4",children:[(0,o.jsx)("div",{className:"skeleton h-32 w-1/4"}),(0,o.jsx)("div",{className:"skeleton h-32 w-1/4"}),(0,o.jsx)("div",{className:"skeleton h-32 w-1/4"}),(0,o.jsx)("div",{className:"skeleton h-32 w-1/4"})]}),"large"===t&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("div",{className:"skeleton h-48 w-full"}),(0,o.jsxs)("div",{className:"flex flex-col space-y-3",children:[(0,o.jsx)("div",{className:"skeleton h-10 w-full"}),(0,o.jsx)("div",{className:"skeleton h-6 w-full"}),(0,o.jsx)("div",{className:"skeleton h-6 w-3/4"}),(0,o.jsx)("div",{className:"skeleton h-6 w-1/2"})]})]})]})]}):null}function i0({isOpen:e}){let[t,a]=(0,h.useState)(""),[r,s]=(0,h.useState)(!0),{project:l}=(0,ev.O)(),i=(0,h.useRef)(null),n=l?.dashboard_id;async function c(){iK(i,e,n,a)}return(0,h.useEffect)(()=>
120{if(!n||!e)return;let t=document.createElement("iframe");t.style.display="none",t.src=`${m.u3.proxied}/superset/welcome`,document.body.appendChild(t),(async()=>{for(let e=0;e<10;e++){try{if((await fetch(`${m.u3.proxied}/api/v1/me`,{credentials:"include"})).ok){s(!1);break}}catch{}await new Promise(e=>setTimeout(e,150))}})()},[n,e]),(0,h.useEffect)(()=>{if(!e)return;let t=setInterval(()=>{iK(i,e,n,a)},100);return()=>clearInterval(t)},[e,r,t]),(0,o.jsxs)(o.Fragment,{children:[e&&(0,o.jsx)(iQ,{isLoading:r}),e&&!r&&(0,o.jsx)("iframe",{title:"FusionLens",ref:i,src:`${m.u3.proxied}/superset/dashboard/${n}/`,className:"w-full h-full transition-opacity duration-300",onLoad:c})]})}var i1=a(36423);let i2=({projectId:e})=>{let t=(0,h.useRef)(null),a=(0,h.useRef)(null),[r,s]=(0,h.useState)(!0),[l,i]=(0,h.useState)(!1),n=(0,h.useRef)(null);return(0,h.useEffect)(()=>{let r=!0;return(async()=>{let l,o;if(t.current){try{l=await aI(e)}catch{r&&i(!0),s(!1);return}s(!1);try{o=await (0,i1.u)({id:l.embedUUID,supersetDomain:m.u3.non_proxied,mountPoint:t.current,fetchGuestToken:async()=>(await aP(e)).token,dashboardUiConfig:{hideTitle:!0,hideTab:!1,hideChartControls:!1,filters:{visible:!0,expanded:!1}},debug:!1,iframeTitle:"FusionLens",iframeSandboxExtras:["allow-same-origin","allow-scripts","allow-forms","allow-popups","allow-downloads"]})}catch{r&&i(!0);return}a.current=t.current?.querySelector("iframe"),r&&(n.current=o)}})(),()=>{r=!1,n.current&&(n.current.unmount(),n.current=null)}},[]),(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("div",{id:"superset",ref:t,className:`w-full h-full ${r||l?"hidden":""}`}),r&&(0,o.jsx)(iQ,{isLoading:r}),l&&(0,o.jsx)("div",{className:"flex items-center justify-center w-full h-full",children:(0,o.jsx)("p",{className:"text-red-500",children:"Failed to load dashboard. Please try again."})})]})};function i5(){let e=(0,ex.u)(),t=(0,ev.O)(),[a,r]=(0,h.useState)(!1);return t.project?(0,o.jsx)(t4,{modalType:x.dW.DashboardModal,customButton:(0,v._A)(e.user,t.project.project_uuid)&&(0,o.jsx)("button",{onClick:e=>{e.stopPropagation(),r(e=>!e)},className:"btn btn-xs shadow",children:a?"Return to Dashboard":"Admin Panel"}),lockRatio:"nolock",title:"FusionLens",closeModal:()=>r(!1),defaultPosition:{x:80,y:120},backgroundColor:"white",defaultSize:{width:1200,height:800},children:a&&(0,v._A)(e.user,t.project.project_uuid)?(0,o.jsx)(i0,{isOpen:a,userContext:e}):(0,o.jsx)(i2,{projectId:t.project.project_uuid})}):null}function i3(e){let t=(0,ew.u)(),a=(0,aO.h)(),r=(0,eG.JY)(),s=(0,ev.O)(),l=async(t,a)=>{if(!s.project)return;e.setLoading(!0);let l=await R(t,a,s.project);l?(r.markerRef.current?.setLngLat([l.lon,l.lat]),e.changeLocation({lon:l.lon,lat:l.lat,zoom:12})):y.oR.error("Invalid LRS Input"),e.setLoading(!1)};return(0,o.jsx)(t4,{modalType:x.dW.LRSModal,title:"Search Routes",defaultPosition:{x:70,y:340},defaultSize:{width:420,height:127},backgroundColor:"white",lockRatio:"nolock",children:(0,o.jsx)("div",{className:"p-5",ref:e.advSearchRef,children:(t.availableRoutes?.length>0||a.availableImageDates)&&(0,o.jsx)(o.Fragment,{children:t.availableRoutes&&t.availableRoutes.length>0?(0,o.jsxs)("form",{className:"flex flex-row items-center text-black input-group mt-0 space-x-4",onSubmit:e=>{e.preventDefault(),t.currentRoute.length>0&&!Number.isNaN(t.currentChainage)?l(t.currentRoute,t.currentChainage):y.oR.error("Invalid LRS")},children:[(0,o.jsxs)("select",{className:"select w-1/2 select-bordered",id:"route-dropdown",value:t.currentRoute,onChange:e=>t.setCurrentRoute(e.target.value),children:[(0,o.jsx)("option",{value:"",children:"Route"}),t.availableRoutes.map((e,t)=>(0,o.jsx)("option",{value:e.route,children:e.route},t))]}),(0,o.jsx)("input",{type:"number",className:"input w-1/3",id:"chainage-input",value:t.currentChainage,onChange:e=>t.setCurrentChainage(parseFloat(e.target.value)),placeholder:"Chainage"}),(0,o.jsx)("button",{className:"btn btn-primary tt-blue-button w-1/6",id:"search-lrs-button",type:"submit",children:(0,o.jsx)(eK.CKj,{})})]}):(0,o.jsx)("div",{className:"flex items-center justify-center",children:(0,o.jsx)("span",{className:"text-center opacity-70 text-sm",children:"No LRS found"})})})})})}function i4(e){let t=(0,eG.JY)(),a=(0,ef.N)(),r=(0,eg.ZM)(),s=(0,aO.h)(),l=(0,eV.H)(),i=(0,ev.O)(),{getModalState:n}=(0,tZ.O)(),{toggleSidePanel:c,closePanel:d,currentPanelKey:u}=(0,e$.p)();return(0,o.jsxs)(o.Fragment,{children:[n(x.dW.LidarModal).display&&i.project&&(0,o.jsx)(lS,{}),i.project&&a.note3DData&&(0,o.jsx)(ae,{noteData:a.note3DData}),i.project?.data_types?.includes("pano")&&(0,o.jsx)(lk,{map:t.map,setRefreshNotes:a.setRefreshNotes,refreshToken:e.refreshHybridModal}),i.project?.features&&i.project?.features?.includes("eagleview")&&(0,o.jsx)(l_,{updateImage:e.eagleView,projectId:i.project?.project_uuid,containsPano:i.project?.data_types.includes("pano")}),Object.entries(s.showCameraX).map(([e,t])=>(0,o.jsx)(lM,{isOpen:t,camera:e,closeModal:()=>(0,v.gb)(e,!1,s.setShowCameraX)},`${e}-${t}`)),n(x.dW.PDFViewerModal).display&&(0,o.jsx)(lT,{}),e.userMap&&i.project&&(0,o.jsx)(lW,{isOpen:n(x.dW.NotesModal).display,onNoteUpdated:e.updateNotes,onNotificationUpdated:e.updateNoteNotifications,onNoteDeleted:e.deleteNotes,resetModalFilter:e.resetNotesModalFilter,onFilterChanged:()=>a.setRefreshNotes(e=>e+1),onNoteCreated:e.createNote,userMap:e.userMap,toggleSidePanel:c,closePanel:d,currentPanelKey:u}),e.userMap&&i.project&&(0,o.jsx)(lG,{isOpen:n(x.dW.AlertsModal).display,onFilterChanged:()=>r.setRefreshAlerts(e=>e+1),onAlertUpdated:e.updateAlerts,resetModalFilter:e.resetAlertsModalFilter,onNotificationUpdated:e.updateAlertNotifications,onAlertDeleted:e.deleteAlerts,userMap:e.userMap,toggleSidePanel:c,closePanel:d,currentPanelKey:u}),n(x.dW.DashboardModal).display&&(0,o.jsx)(i5,{}),n(x.dW.CalendarModal).display&&l.premiumLayerAddedToMap&&(0,o.jsx)(iu,{date:l.date,setDate:l.setDate,map:t.map,opacity:l.rasterVisuals.opacity,name:t.splitViewEnabled?"Calendar (Left)":"Calendar",alt:!1,mergedDate:l.mergedDate,setMergedDate:l.setMergedDate,layer:l.premiumLayer.layer}),n(x.dW.AltCalendarModal).display&&t.splitViewEnabled&&l.altPremiumLayerAddedToMap&&(0,o.jsx)(iu,{date:l.altDate,setDate:l.setAltDate,map:t.altMap?t.altMap:t.map,opacity:l.rasterVisuals.opacity,name:"Calendar (Right)",alt:!0,mergedDate:l.mergedDateAlt,setMergedDate:l.setMergedDateAlt,layer:l.altPremiumLayer.selected?l.altPremiumLayer.layer:l.premiumLayer.layer}),n(x.dW.MeasurementsModal).display&&(0,o.jsx)(iq,{modalType:x.dW.MeasurementsModal,modalTitle:"measurements"}),n(x.dW.PointcloudsModal).display&&(0,o.jsx)(iq,{modalType:x.dW.PointcloudsModal,modalTitle:"pointclouds"}),n(x.dW.GISModal).display&&(0,o.jsx)(iq,{modalType:x.dW.GISModal,modalTitle:l.activeTabularLayerName??"GIS Data"}),n(x.dW.MetadataModal).display&&e.features&&i.project&&(0,o.jsx)(iX,{features:e.features,handleDeleteMeasure:e.deleteMeasure}),n(x.dW.LRSModal).display&&(0,o.jsx)(i3,{advSearchRef:e.advSearchRef,setLoading:e.setLoading,changeLocation:e.changeLocation})]})}function i8(e){let t=(0,ex.u)(),a=(0,ev.O)(),[r,s]=(0,h.useState)(!1),l=(0,e3.Jj)(t?.user);return(0,o.jsxs)("div",{className:"absolute right-1 desktop:h-[50px] h-0 desktop:p-4 p-2 profile-btn",children:[(0,o.jsxs)("div",{className:"dropdown hidden desktop:inline-block","data-tooltip-id":"summary-tt","data-tooltip-content":"Summary",style:{zIndex:100},children:[(0,o.jsx)("label",{tabIndex:0,className:"flex items-center cursor-pointer","data-testid":"map-user-profile-btn",children:t?.user?.profile_image?(0,o.jsx)("div",{children:(0,o.jsx)("img",{className:"w-10 h-10 rounded-full ring-2 ring-white/20 shadow mr-0.5 object-cover transition-transform duration-300 ease-in-out transform hover:scale-110 hover:shadow-lg",src:t?.user?.profile_image,alt:"Profile"})}):(0,o.jsx)("div",{className:"backdrop-blur-sm w-10 h-10 ring-2 ring-white/20 shadow bg-gray-500/50 rounded-full flex items-center justify-center text-white font-semibold mr-0.5 text-base\n                        transition-transform duration-300 ease-in-out transform hover:scale-110 hover:shadow-lg",children:`${t?.user?.first_name?.trim().charAt(0)??""}${t?.user?.surname?.trim().charAt(0)??""}`.toUpperCase()})}),(0,o.jsxs)("ul",{tabIndex:0,className:"p-2 shadow menu dropdown-content bg-white rounded-box w-48 ml-[-190px]","data-testid":"map-user-profile-dropdown",children:[(0,o.jsxs)("span",{className:"font-bold text-lg text-black mt-1 ml-2 mb-1 pb-2 border-b border-black/20 mr-2",children:[t?.user?.first_name," ",t?.user?.surname]}),null!==l&&(0,o.jsx)(e8,{daysUntilExpiry:l,className:"m-1 text-[0.8rem]"}),(0,o.jsx)("li",{className:"text-black cursor-pointer",children:(0,o.jsxs)(p(),{href:"/projects",className:"flex p-2 pl-4 items-center gap-2",children:[(0,o.jsx)(W.HEG,{})," Projects"]})}),(0,o.jsx)("li",{className:"text-black cursor-pointer",children:(0,o.jsxs)(p(),{href:"/profile",className:"flex p-2 pl-4 items-center gap-2",children:[(0,o.jsx)(W.kSq,{})," Profile"]})}),(0,o.jsx)("li",{onClick:()=>s(!0),className:"text-black cursor-pointer",children:(0,o.jsxs)("label",{htmlFor:"my_modal_7",className:"flex p-2 pl-4 items-center gap-2",children:[(0,o.jsx)(W.uct,{})," Settings"]})}),(0,o.jsx)("li",{className:"text-black cursor-pointer",children:(0,o.jsxs)(p(),{target:"_blank",href:"https://fusionmap.com/knowledge-base/",className:"flex p-2 pl-4 items-center gap-2",children:[(0,o.jsx)(e0.ZPX,{})," Help"]})}),(0,o.jsx)("li",{className:"text-black cursor-pointer",children:(0,o.jsxs)("div",{className:"flex p-2 pl-4 items-center gap-2",onClick:()=>e.setRun(e=>({...e,run:!0})),children:[(0,o.jsx)(W.MGr,{})," Walkthrough"]})}),(0,o.jsx)("li",{onClick:()=>(0,eQ.r)(),className:"text-black cursor-pointer","data-testid":"map-user-profile-dropdown-logout-btn",children:(0,o.jsxs)("div",{className:"flex p-2 pl-4 items-center gap-2",children:[(0,o.jsx)(W.qBV,{})," Log out"]})})]})]}),(0,o.jsx)(e5,{project:a.project,isOpen:r,setIsOpen:s})]})}var i6=a(6507),i7=a(97984);function i9({boxRef:e}){let{deleteSelectionUuids:t,setDeleteSelectionUuids:a,editGeometriesLayer:r,setEditGeometriesLayer:s}=(0,eb.g)(),{map:l}=(0,eG.JY)(),{goBack:i}=(0,e$.p)(),n=(0,i7.W)(),[c,d]=(0,h.useState)(!1),u=async()=>{try{let{deletedIds:n}=await r5({layerId:parseInt(r?.id),featureIds:t});
120(0,av.Xp)(l,n,r?.id),y.Ay.success("Features deleted successfully"),a([]),e.current&&(e.current.parentNode?.removeChild(e.current),e.current=null),s(null),i()}catch(e){console.error(e),y.Ay.error("Failed to delete features")}};return(0,o.jsxs)("div",{className:"flex flex-col justify-between gap-3 h-full",children:[(0,o.jsx)(V.A,{isOpen:c,onDelete:u,closeModal:()=>d(!1)}),0===t.length?(0,o.jsxs)("div",{className:"rounded-md bg-tt-blue/10 opacity-70 w-full p-3 flex items-center gap-3",children:[(0,o.jsx)(e0.z5h,{size:20}),(0,o.jsxs)("span",{className:"text-sm",children:[(0,o.jsxs)("b",{children:[n?"Tap":"Left click"," and drag"]})," to draw a box around the features to delete."]})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("p",{className:"font-medium","data-testid":"features-multi-delete-selected-count",children:["Features selected: ",t.length]}),(0,o.jsx)("button",{className:"btn btn-error text-white",onClick:()=>d(!0),"data-testid":"features-multi-delete-button",children:"Delete"})]})]})}function ne({layer:e,displayAddSubpage:t}){let{drawingGeojson:a}=(0,eb.g)();return 0===a.features.length?(0,o.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,o.jsxs)("div",{className:"rounded-md bg-tt-blue/10 opacity-70 w-full p-3 flex items-center gap-3",children:[(0,o.jsx)(e0.z5h,{size:20}),(0,o.jsxs)("div",{className:"flex flex-col gap-2 text-sm",children:[(0,o.jsxs)("span",{children:[(0,o.jsx)("b",{children:(0,v.Fr)()?"Tap":"Left click"})," on the map to draw a feature."]}),(0,o.jsxs)("span",{children:[(0,o.jsx)("b",{children:(0,v.Fr)()?"Double tap":"Double click or right click"})," on the final point to finish drawing the feature."]})]})]}),(0,o.jsx)(d(),{src:"/images/CustomFormAddFeature.gif",alt:"Feature adding tutorial",width:500,height:500,className:"w-full rounded-md"})]}):(0,o.jsx)(iG,{layer:e,onClose:()=>setTimeout(()=>t(e),250)})}let nt=function(){let e=(0,i7.W)(),t=(0,eb.g)(),{mode:a,setMode:r,drawingBbox:s,setDrawingBbox:l,boxRef:i,handleMultiDelete:n}=(()=>{let e=(0,eG.JY)(),t=(0,i7.W)(),{pushSubPage:a,goBack:r}=(0,e$.p)(),{setBottomMenuOpen:s}=(0,ej.H)(),{setDrawingModeCaller:l,setDrawingColor:i,editGeometriesLayer:n,setEditGeometriesLayer:c,setDeleteSelectionUuids:d}=(0,eb.g)(),[u,p]=(0,h.useState)(x.M2.ADD),[m,f]=(0,h.useState)(!1),g=(0,h.useRef)(null),b=(0,h.useRef)(r);b.current=r;let j=(0,h.useRef)(a);j.current=a;let w=(0,h.useCallback)(async t=>{if(d([]),!t[0]||!t[1])return void y.Ay.error("Please draw a box around the features to delete.");let a=e.map.current?.queryRenderedFeatures([t[0],t[1]],{layers:[n?.id]});a&&0!==a.length?d(Array.from(new Set(a?.map(e=>e.properties?.uuid)))):y.Ay.error("No features found to delete.")},[n?.id,e.map,d]),v=(0,h.useCallback)(async e=>{j.current((0,o.jsx)(ne,{layer:e,displayAddSubpage:v}),{title:`${e.name} Custom Form`,onClose:()=>{c(null)}})},[c]),N=(0,h.useCallback)(async e=>{j.current((0,o.jsx)(i9,{boxRef:g}),{title:`${e.name} Delete Features`,onClose:()=>{c(null)}})},[c]);return(0,h.useEffect)(()=>{switch(b.current(),u){case x.M2.ADD:let e=x.Jd[n?.properties.geojson_type];e&&l(e),i(n?.properties.color),setTimeout(()=>v(n),250);break;case x.M2.DELETE:f(!0),setTimeout(()=>N(n),250);break;case x.M2.EXIT:c(null)}return()=>{f(!1),l(null),d([]),g.current&&(g.current.parentNode?.removeChild(g.current),g.current=null)}},[v,n,u,i,l,c,d,N]),(0,h.useEffect)(()=>{if(s({open:!1,id:0,event:null}),t)return;let e=(0,y.Ay)("Press ESC to stop editing",{duration:1/0,icon:(0,o.jsx)(z.XOh,{})}),a=e=>{"Escape"===e.key&&(b.current(),c(null))};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a),e&&y.Ay.dismiss(e)}},[s,c,t]),{mode:u,setMode:p,drawingBbox:m,setDrawingBbox:f,boxRef:g,handleMultiDelete:w}})(),c=t.editGeometriesLayer?.properties.geojson_type,d=c===x.lo.LineString?"Line":c,u=`calc(${i6.Uh} + 0.5rem)`,p=(()=>{switch(c){case x.lo.LineString:return em.fod;case x.lo.Point:return em.o9J;case x.lo.Polygon:return ep.voV;default:return}})();return lm({drawing:s,setDrawing:l,boxRef:i,onFinish:n,className:"unselect"}),(0,o.jsx)("div",{className:"bottom-modal sliding-div p-2 flex flex-col gap-2 items-center",style:{...e&&{bottom:u}},children:(0,o.jsx)(eJ,{groupName:"drawing-mode-tabs",tabs:[{value:x.M2.ADD,icon:p,label:`Add ${d}`},{value:x.M2.DELETE,icon:W.WeY,label:"Multi Delete"},{value:x.M2.EXIT,icon:em.xsM,label:"Exit"}
120],selectedValue:a,onSelect:r,transparentBackground:!0})})};var na=a(89099);let nr=()=>{var e,t;let r,s,l,i,n,c,u,f,N,k,C=(0,h.useRef)(null),L=(0,eG.JY)(),D=(0,eV.H)(),A=(0,ef.N)(),E=(0,eg.ZM)(),I=(0,ey.F)(),P=(0,eb.g)(),F=(0,ex.u)(),R=(0,ew.u)(),$=(0,eN.D)(),z=(0,aO.h)(),U=(0,ev.O)(),B=(0,ej.H)(),{openModal:G,closeModal:J,toggleModal:q,getModalState:Z}=(0,tZ.O)(),X=(0,na.useRouter)(),K=(0,h.useRef)(null),Q=(0,h.useRef)(null),ea=(0,h.useRef)(null),er=(0,h.useContext)(et.bM),el=(0,h.useRef)(null),ei=new URLSearchParams((0,eZ.A)().search);ei.delete("project_id");let en=(0,h.useRef)(null),ec=(0,h.useRef)(null),[eu,ep]=(0,h.useState)(null),[eh,ek]=(0,h.useState)({value:0,text:"Fetching data"}),[e_]=(0,h.useState)(0),[eC,eL]=(0,h.useState)({lon:-82.70955361463939,lat:27.740185240624555,zoom:5}),[eD,eA]=(0,h.useState)({lon:-82.70955361463939,lat:27.740185240624555}),[eM,eE]=(0,h.useState)(!0),[eT,eI]=(0,h.useState)(!0),[eP,eF]=(0,h.useState)({show:!1,action:null,data:null}),[eO,eR]=(0,h.useState)(0),[ez,eU]=(0,h.useState)({x:0,y:0}),[eW,eJ]=(0,h.useState)({lng:0,lat:0}),[eq,eK]=(0,h.useState)(!1),[eQ,e0]=(0,h.useState)(0),[e1,e2]=(0,h.useState)(0),[e5,e3]=(0,h.useState)(!1),[e4,e8]=(0,h.useState)(!1),[te,tt]=(0,h.useState)(0),[ta,tr]=(0,h.useState)(!1),[ts,tn]=(0,h.useState)(0),[to,tu]=(0,h.useState)(null),[tp,tm]=(0,h.useState)(new Set),tx=(0,h.useRef)((r=new Map,{begin(e){let t=(r.get(e)??0)+1;return r.set(e,t),t},isLatest:(e,t)=>r.get(e)===t})),[tf,tg]=(0,h.useState)(""),[ty,tb]=(0,h.useState)(!1),[tv,tN]=(0,h.useState)(null),[{run:tS,steps:tk},t_]=(0,eX.A)(e7);j().accessToken=m.Et;let tC=async()=>{K.current=new(await a.e(668).then(a.t.bind(a,20668,23))).default(L.map.current,L.altMap.current,"#comparison-container",{}),(0,eo.dc)(K.current,Q)},tL=async()=>{eI(!0);let e=eC;if(L.map.current){let t=L.map.current.getCenter();e={lat:t.lat,lon:t.lng,zoom:L.map.current.getZoom()}}L.altMap.current=(0,eo.Ls)({isAlt:!0,mapContext:L,mapContainer:ea,layerContext:D,mapCoord:e,initializeMapboxDraw:P.initializeMapboxDraw}),L.altMap.current&&U.project&&tA(L.altMap.current,U.project),(L.map.current?.getPitch()??0)>0&&L.altMap.current?.once("style.load",()=>{L.altMap.current&&(0,tw.vu)(L.altMap.current)}),await tC(),L.altMap.current?.triggerRepaint(),eI(!1)},tD=async()=>{let e=await (0,ab.nv)(ei);return e?(U.setProject(e),localStorage.setItem("project",JSON.stringify(e)),e):(console.error("Project not loaded into the db"),null)},tA=(e,t)=>{let a=e.getContainer();if(a.querySelector(".mapboxgl-ctrl-scale"))return;let r="Metric"===t.units?"metric":"imperial";e.addControl(new(j()).ScaleControl({unit:r}),"top-right");let s=()=>{let e=a.querySelector(".mapboxgl-ctrl-scale"),t=a.querySelector(".mapboxgl-ctrl-attrib-inner");return!!e&&!!t&&(!!t.contains(e)||(t.insertBefore(e,t.firstChild),!0))};setTimeout(()=>{s()||requestAnimationFrame(()=>s())},250)},tM=async e=>{try{let t=(await aT(L.map,e,tr,B.setBottomMenuOpen,tF,D.setCustomLayers))[1];for(let e of(D.setCustomLayers(t),t))"ProjectGIS"===e.scope&&tg(e.id)}catch(e){console.error(e)}},tE=async e=>{var t,a;let r;t=L.map,a=e.units,(r=()=>{var e,r,s;let l,i;e=t,r="#003478",s=a,e.current.getLayer("buildings-layer")||e.current.addLayer({id:"buildings-layer",type:"fill",source:{type:"vector",url:"mapbox://mapbox.mapbox-streets-v8"},"source-layer":"building",paint:{"fill-color":r,"fill-opacity":.5},layout:{visibility:"none"}}),l=new(j()).Popup({closeButton:!1,closeOnClick:!1,maxWidth:"300px"}),i=t=>{let a=t.features;if(!a||0===a.length)return;let r=a[0],i=document.createElement("div");(0,es.createRoot)(i).render((0,o.jsx)(au,{hoveredFeature:r,units:s})),l.setLngLat(t.lngLat).setDOMContent(i).addTo(e.current);let n=document.querySelectorAll(".mapboxgl-popup");document.addEventListener("mousemove",function(e){let t=e.clientX,a=e.clientY;n.forEach(function(e){let r,s,l=e.getBoundingClientRect(),i=(l.left+l.right)/2,o=(l.top+l.bottom)/2;Math.sqrt((r=t-i)*r+(s=a-o)*s)>150&&(n.forEach(e=>e.remove()),n=[])})})},e.current.on("mouseenter","buildings-layer",e=>{i(e)}),e.current.on("touchstart","buildings-layer",e=>{i(e)})})(),t.current.on("style.load",()=>{r()}),sessionStorage.setItem("buildings",[...Array(10)].map(()=>Math.random().toString(36)[2]).join("")),console.log("here");let s=await Promise.all([(0,_.x)("/map/get-routes",{params:{projectId:e.project_uuid}}),M(L.map,e.project_uuid,"map",tF),(0,ad.FS)(L.map,$),(0,eo.UA)(L,e,eI,tF,!0)]);"None"!=s[0].routes?(R.setAvailableRoutes(s[0].routes),eE(!0)):eE(!1)},tT=async()=>{let e=await tD();if(!e)return void await X.replace("/projects");if(ek({value:5,text:"Loading map"}),L.map.current=(0,eo.Ls)({isAlt:!1,mapContext:L,mapContainer:el,layerContext:D,mapCoord:eC,initializeMapboxDraw:P.initializeMapboxDraw}),!L.map.current)return;let t=L.map.current;t.once("style.load",async()=>{let a,r,s;ek({value:20,text:"Fetching project data"}),await (0,H.ZQ)(!0),ek({value:40,text:"Loading map controls"}),tA(t,e),ek({value:50,text:"Setting initial map position"}),a=(0,eo.wY)(e,ei),r=t.project([a.lon,a.lat]),s=t.queryRenderedFeatures(new(j()).Point(r.x,r.y)).some(e=>e.layer?.id==="data-layer"),(0,eo.JX)(L,B,e,a.lat,a.lon,s?"vanmarker":"defaultmarker"),eL(a),t.flyTo({center:[a.lon,a.lat],zoom:a.zoom,duration:200}),ek({value:70,text:"Loading and rendering data"}),await Promise.all([tM(e),tE(e)]),localStorage.setItem("bbox",JSON.stringify(new ay.Vector3(10,10,1e4))),ek({value:100,text:"Finalization"})})},tI=async e=>{if(!e&&!eD)return[];let t=e??eD,a=localStorage.getItem("bbox"),r=a?JSON.parse(a).x:10;return await (0,ad.Yf)(t.lon,t.lat,r,U.project?.units)},tP=async(e,t)=>{if(!t&&!eD)return;let a=t??eD;e.length>0&&($.setAvailableLidars(e),localStorage.setItem("map_state",JSON.stringify({lon:a.lon,lat:a.lat,file:m.oj}))),G(x.dW.LidarModal)},tF=async e=>{if(L.map.current){if(null===e)return void J(x.dW.MetadataModal);ec.current&&L.map.current.removeFeatureState({source:ec.current}),tN(e),G(x.dW.MetadataModal),ec.current=e.sources[0]}},tR=async(e,t,a)=>{if(L.map.current){if(eI(!0),eL({lat:t,lon:e,zoom:eC.zoom}),a?.data_types?.some(e=>/camera/i.test(e))||a?.data_types?.includes("pano"))await ax.makeRequest
120("/map/search",{method:"GET",params:{lat:t,lon:e,zoom:L.map.current.getZoom().toString()}},!1,async r=>{z.setIsPanoAvailable("pano"in r);let s=null,l=Object.keys(r);if("pano"in r)s=r.pano;else{if(!(l.length>0))return void eI(!1);s=r[l[0]]}(0,eo.JX)(L,B,a,s.lat,s.lon,"vanmarker"),tt(Math.random()),eL({lat:s.lat,lon:s.lon,zoom:eC.zoom});let i=await (0,H.bB)(s.filepath);if(localStorage.setItem("map_state",JSON.stringify({lon:s.lon,lat:s.lat,file:i})),z.setViewInfo(r),a?.data_types?.includes("lidar")){eL({lat:t,lon:e,zoom:eC.zoom});let r=localStorage.getItem("bbox"),s=r?JSON.parse(r).x:10;try{let r=await (0,ad.Yf)(e,t,s,a.units);$.setAvailableLidars(r)}catch{y.Ay.error("Lidar unavailable for current location.")}tt(te+1)}let n=await ag(s.lat,s.lon);n&&z.setAvailableImageDates(n)},async()=>{});else if(a?.data_types?.includes("lidar")){localStorage.setItem("map_state",JSON.stringify({lon:e,lat:t,file:""})),L.markerRef.current?.setLngLat([e,t]),eL({lat:t,lon:e,zoom:eC.zoom});let r=localStorage.getItem("bbox"),s=r?JSON.parse(r).x:10;try{let r=await (0,ad.Yf)(e,t,s,a.units);$.setAvailableLidars(r)}catch{y.Ay.error("Lidar unavailable for current location.")}}else a?.data_types?.includes("gis");eI(!1),a?.data_types?.includes("lidar")&&a?.data_types?.includes("pano")&&await ag(t,e,!0)}},t$=e=>{L.map.current&&(eL(e),eA({lon:e.lon,lat:e.lat}),eJ({lng:e.lon,lat:e.lat}),(0,eo.JX)(L,B,U.project,e.lat,e.lon,"defaultmarker"),L.map.current.flyTo({center:e,zoom:L.map.current.getZoom()>13?L.map.current.getZoom():13,duration:eB.AD}),ae(null))},tz=(e,t=!1)=>{L.layerFilterOptions.current.notes?t?(e0(e=>e+1),L.layerFilterOptions.current.notes=null,(0,y.Ay)("Note filters have been cleared",{icon:(0,o.jsx)(em.tr_,{className:"text-warning text-2xl"}),style:{color:"f59e0b"}}),A.setRefreshNotes(e=>e+1)):A.setRefreshNotes(e=>e+1):e()},tW=async e=>{tz(()=>{e?.id&&(0,ee.sI)(L.map,e)})},tB=async(e,t,a)=>{tz(()=>(0,ee.DU)(L.map,e,t,a))},tJ=async e=>{tz(()=>(0,ee.$W)(L.map,e))},tq=async e=>{tz(()=>(0,ee.lq)(L.map,e),!0)},tY=(e,t=!1)=>{if(L.layerFilterOptions.current.alerts)if(t){let e;e2(e=>e+1),e=U.project?.alert_defaults?.visible_severity_levels,L.layerFilterOptions.current.alerts=e?.length?{visibleSeverityLevels:e}:null,(0,y.Ay)("Alert filters have been reset to project defaults",{icon:(0,o.jsx)(em.tr_,{className:"text-warning text-2xl"}),style:{color:"f59e0b"}}),E.setRefreshAlerts(e=>e+1)}else E.setRefreshAlerts(e=>e+1);else e()},tH=async e=>{if((0,ti.AP)(L.map,e),to){let t=e.find(e=>e.id===to.id);if(t){let e=t.properties??{};tu(a=>({...a,...t,...e,properties:{...a.properties,...e}}))}}(0,ti.QY)(e,L.layerFilterOptions.current.alerts)&&tY(()=>void 0)},tX=async(e,t)=>{if(!U.project||!(0,v._A)(F?.user,U.project.project_uuid))return!1;let a=tx.current.begin(e);tm(t=>new Set(t).add(e));try{let r=await tc(e,t);if(!tx.current.isLatest(e,a))return!1;if(!r?.ok)return y.Ay.error("Failed to update Verify status"),!1;return await tH([{id:e,properties:{verify_status:t}}]),y.Ay.success("Verify status updated"),!0}finally{tx.current.isLatest(e,a)&&tm(t=>{let a=new Set(t);return a.delete(e),a})}},tK=async(e,t,a)=>{tY(()=>(0,ti.Lz)(L.map,e,t,a))},tQ=async e=>{tY(()=>(0,ti.pQ)(L.map,e))},t0=async e=>{tY(()=>(0,ti.VZ)(L.map,e),!0)},t1=async e=>{if(e&&await (0,v.oo)(U.project?.project_uuid,e))return T(L.map,e,"map"),J(x.dW.MetadataModal),L.map},t2=async e=>{eI(!0),eF({show:!1,action:null,data:null}),await (0,ee.B9)([e])?(y.Ay.success("Note deleted successfully"),tz(()=>{(0,ee.$W)(L.map,[e])})):y.Ay.error("Note delete failed"),eI(!1)},t5=async e=>{eI(!0),eF({show:!1,action:null,data:null}),await (0,ti.TD)([e]),tQ([e]),eI(!1)},t3=async e=>{eI(!0),eF({show:!1,action:null,data:null}),await (0,v.oo)(U.project?.project_uuid,e)?(y.Ay.success("Measurement deleted successfully"),T(L.map,e)):y.Ay.error("Measurement delete failed"),eI(!1)},t4=async()=>{to.notification_ids&&(to.notification_ids=JSON.parse(to.notification_ids)),to.notification_ids?.length&&(await (0,Y.oq)(to.notification_ids),to.issuer?tK(to.id,to.notification_ids):tB(to.id,to.notification_ids),tn(e=>e+1))};s=(0,eG.JY)(),l=(e=1)=>{let t=t=>new Promise((a,r)=>{let s=document.querySelectorAll(t);if(s.length>=e)return a(Array.from(s));let l=new MutationObserver(()=>{let r=document.querySelectorAll(t);r.length>=e&&(l.disconnect(),a(Array.from(r)))});l.observe(document.body,{childList:!0,subtree:!0}),setTimeout(()=>{l.disconnect(),r(Error(`Timeout waiting for elements with selector: ${t}`))},5e3)});(async()=>{let[e,a,r,s]=await Promise.all([t(".mapboxgl-ctrl-geolocate"),t(".mapboxgl-ctrl-zoom-in"),t(".mapboxgl-ctrl-zoom-out"),t(".mapboxgl-ctrl-compass")]);
120e.forEach(e=>{e.classList.add("tooltip","tooltip-left"),e.setAttribute("data-tip","Current Location"),e.querySelector(".mapboxgl-ctrl-icon")?.removeAttribute("title")}),a.forEach(e=>{e.classList.add("tooltip","tooltip-left"),e.setAttribute("data-tip","Zoom In"),e.querySelector(".mapboxgl-ctrl-icon")?.removeAttribute("title")}),r.forEach(e=>{e.classList.add("tooltip","tooltip-left"),e.setAttribute("data-tip","Zoom Out"),e.querySelector(".mapboxgl-ctrl-icon")?.removeAttribute("title")}),s.forEach(e=>{e.classList.add("tooltip","tooltip-left"),e.setAttribute("data-tip","Reset North"),e.querySelector(".mapboxgl-ctrl-icon")?.removeAttribute("title")})})().catch(e=>{console.error("Failed to add tooltips:",e)})},(0,h.useEffect)(()=>{s.map?.current&&s.altMap?.current&&s.splitViewEnabled?setTimeout(()=>{l(2)},100):s.map?.current&&setTimeout(()=>{l()},100)},[s.map?.current,s.altMap?.current,s.splitViewEnabled]),(()=>{let{mapStyle:e,premiumLayer:t}=(0,eV.H)(),a=(0,eG.JY)();(0,h.useEffect)(()=>{a.map.current&&e&&(a.map.current?.once("idle",()=>{aY(t.layer?.attribution??"")}),a.map.current?.updateImport("basemap",{id:"basemap",url:e}),a.altMap?.current?.updateImport("basemap",{id:"basemap",url:e}))},[e])})(),i=(0,eV.H)(),n=(0,ev.O)(),c=(0,ex.u)(),u=(0,eG.JY)(),f=e=>{if(!n.project)return!0;let t=(0,S.YN)(e,n.project.project_uuid);return null===t||t},(0,h.useEffect)(()=>{i.setLayersCheckboxState(e=>({...e,Measurements:f("measurements-layer"),Notes:f("note-layer"),"3D Notes":f("3dnote-layer"),"AI Notes":f("ainote-layer"),"Camera Points":f("data-layer"),Alerts:f("alerts-layer"),Pointclouds:f("user-uploaded-lidars-layer")})),i.setLayersLabelState(e=>({...e,Measurements:f("measurements-label-layer"),Notes:f("note-label-layer"),"3D Notes":f("3dnote-label-layer"),"AI Notes":f("ainote-label-layer")}))},[n.project]),(0,h.useEffect)(()=>{if(c?.user&&u.map.current&&n.project){if(u.map.current.getLayer("rainviewer")&&(!0==i.layersCheckboxState["Weather Overlay"]?u.map.current.setLayoutProperty("rainviewer","visibility","visible"):u.map.current.setLayoutProperty("rainviewer","visibility","none")),u.map.current.getLayer("data-layer")&&(!0==i.layersCheckboxState["Camera Points"]?(u.map.current.setLayoutProperty("data-layer","visibility","visible"),(0,S.a4)("data-layer",n.project?.project_uuid,!0)):(u.map.current.setLayoutProperty("data-layer","visibility","none"),(0,S.a4)("data-layer",n.project?.project_uuid,!1))),u.map.current.getLayer("note-layer")&&(!0==i.layersCheckboxState.Notes?(u.map.current.setLayoutProperty("note-layer","visibility","visible"),u.map.current.setLayoutProperty("note-layer","text-field",i.layersLabelState.Notes?["get","title"]:""),u.map.current.setLayoutProperty("clusters-note-circle","visibility","visible"),(0,S.a4)("note-layer",n.project?.project_uuid,!0),(0,S.a4)("note-label-layer",n.project?.project_uuid,i.layersLabelState.Notes)):(u.map.current.setLayoutProperty("note-layer","visibility","none"),u.map.current.setLayoutProperty("note-layer","text-field",""),(0,S.a4)("note-layer",n.project?.project_uuid,!1),(0,S.a4)("note-label-layer",n.project?.project_uuid,!1))),u.map.current.getLayer("3dnote-layer")&&(!0==i.layersCheckboxState["3D Notes"]?(u.map.current.setLayoutProperty("3dnote-layer","visibility","visible"),u.map.current.setLayoutProperty("3dnote-layer","text-field",i.layersLabelState["3D Notes"]?["get","title"]:""),u.map.current.setLayoutProperty("clusters-3dnote-circle","visibility","visible"),(0,S.a4)("3dnote-layer",n.project?.project_uuid,!0),(0,S.a4)("3dnote-label-layer",n.project?.project_uuid,i.layersLabelState["3D Notes"])):(u.map.current.setLayoutProperty("3dnote-layer","visibility","none"),(0,S.a4)("3dnote-layer",n.project?.project_uuid,!1),(0,S.a4)("3dnote-label-layer",n.project?.project_uuid,!1))),u.map.current.getLayer("ainote-layer")&&(!0==i.layersCheckboxState["AI Notes"]?(u.map.current.setLayoutProperty("ainote-layer","visibility","visible"),u.map.current.setLayoutProperty("ainote-layer","text-field",i.layersLabelState["AI Notes"]?["get","title"]:""),(0,S.a4)("ainote-layer",n.project?.project_uuid,!0),(0,S.a4)("ainote-label-layer",n.project?.project_uuid,i.layersLabelState["AI Notes"])):(u.map.current.setLayoutProperty("ainote-layer","visibility","none"),(0,S.a4)("ainote-layer",n.project?.project_uuid,!1),(0,S.a4)("ainote-label-layer",n.project?.project_uuid,!1))),u.map.current.getLayer("alerts-points-layer")||u.map.current.getLayer(x.jw.POLYGON)){for(let e of[x.jw.POLYGON,x.jw.POLYGON_ICON,x.jw.POLYGON_OUTLINE,x.jw.CLUSTER_CIRCLE,x.jw.CLUSTER_TEXT,x.jw.ICON])u.map.current.getLayer(e)&&u.map.current.setLayoutProperty(e,"visibility",i.layersCheckboxState.Alerts?"visible":"none");(0,S.a4)("alerts-layer",n.project?.project_uuid,i.layersCheckboxState.Alerts)}(u.map.current.getLayer("line-layer")||u.map.current.getLayer("point-layer")||u.map.current.getLayer("polygon-layer"))&&(!0==i.layersCheckboxState.Measurements?(u.map.current.setLayoutProperty("line-layer","visibility","visible"),u.map.current.setLayoutProperty("point-layer","visibility","visible"),u.map.current.setLayoutProperty("polygon-layer","visibility","visible"),u.map.current.setLayoutProperty("line-layer-labels","visibility",i.layersLabelState.Measurements?"visible":"none"),u.map.current.setLayoutProperty("polygon-layer-labels","visibility",i.layersLabelState.Measurements?"visible":"none"),(0,S.a4)("measurements-layer",n.project?.project_uuid,!0),(0,S.a4)("measurements-label-layer",n.project?.project_uuid,i.layersLabelState.Measurements)):(u.map.current.setLayoutProperty("line-layer","visibility","none"),u.map.current.setLayoutProperty("point-layer","visibility","none"),u.map.current.setLayoutProperty("polygon-layer","visibility","none"),u.map.current.setLayoutProperty("line-layer-labels","visibility","none"),u.map.current.setLayoutProperty("polygon-layer-labels","visibility","none"),(0,S.a4)("measurements-layer",n.project?.project_uuid,!1),(0,S.a4)("measurements-label-layer",n.project?.project_uuid,!1))),u.map.current.getLayer("buildings-layer")&&(!0==i.layersCheckboxState["Building Footprints"]?u.map.current.setLayoutProperty("buildings-layer","visibility","visible"):u.map.current.setLayoutProperty("buildings-layer","visibility","none")),u.map.current.getLayer("user-uploaded-lidars-layer")&&(i.layersCheckboxState.Pointclouds?(u.map.current.setLayoutProperty("user-uploaded-lidars-layer","visibility","visible"),u.map.current.getLayer("user-uploaded-lidars-layer-union")&&u.map.current.setLayoutProperty("user-uploaded-lidars-layer-union","visibility","visible"),(0,S.a4)("user-uploaded-lidars-layer",n.project?.project_uuid,!0),(0,S.a4)("user-uploaded-lidars-layer-union",n.project?.project_uuid,!0)):(u.map.current.setLayoutProperty("user-uploaded-lidars-layer","visibility","none"),u.map.current.getLayer("user-uploaded-lidars-layer-union")&&u.map.current.setLayoutProperty("user-uploaded-lidars-layer-union","visibility","none"),(0,S.a4)("user-uploaded-lidars-layer",n.project?.project_uuid,!1),(0,S.a4)("user-uploaded-lidars-layer-union",n.project?.project_uuid,!1)))}},[i.layersCheckboxState,u]),e={clickedPositionCoords:eD,showRightClickMenu:eP,refreshShowRightClickMenu:eO},N=(0,ew.u)(),k=(0,ev.O)(),(0,h.useEffect)(()=>{(async()=>
120{if(k.project?.lrs_included&&e.showRightClickMenu.show)try{let t=await O(k.project.project_uuid,e.clickedPositionCoords.lat,e.clickedPositionCoords.lon);N.setCurrentLRS(`${t.route} ${t.chainage.toFixed(3)}`),N.setCurrentRoute(t.route),N.setCurrentChainage(t.chainage)}catch(e){console.error(e)}else N.setCurrentLRS(null)})()},[e.showRightClickMenu.show,e.refreshShowRightClickMenu,e.clickedPositionCoords]),(({setMapCoord:e,setClickedPositionCoords:t,updateNotes:a})=>{let r=(0,eG.JY)(),s=(0,ex.u)(),l=(0,eN.D)(),i=(0,ev.O)(),n=(0,ef.N)(),o=(0,aO.h)(),c=(0,ej.H)();async function d(a,l,n=!1){if(r.map.current)if(n){if(!a||!a.action||c.showModals?.HybridViewModal)return;let t="next"===a.action?2:m.sc+1,i=await (0,v._G)(t,s,l),n=i[2],o=i[3];e(e=>({...e,lat:o,lon:n})),r.markerRef.current?.setLngLat([n,o])}else{if(!a.newValue)return;let s=JSON.parse(a.newValue);e(e=>({...e,lat:s.lat,lon:s.lon}));let n=r.markerRef.current?.getElement();if(n?.className.includes("defaultmarker")&&(0,eo.JX)(r,c,i.project,s.lat,s.lon,"vanmarker"),r.markerRef.current?.setLngLat([s.lon,s.lat]),t({lon:s.lon,lat:s.lat}),l?.data_types?.includes("pano")){let e=localStorage.getItem("map_state");if(e){let t=JSON.parse(e);if(l?.data_types?.some(e=>/camera/i.test(e))){let e=await (0,_.x)("/map/search",{method:"GET",params:{lat:t.lat,lon:t.lon,zoom:r.map.current.getZoom()}});o.setViewInfo(e)}}}}}let u=async e=>{if(r.map.current&&i.project&&(e.storageArea===localStorage&&"map_state"===e.key&&await d(e,i.project),e.storageArea===sessionStorage)){if("navigator_rotation"===e.key&&r.markerRef.current){let t=parseFloat(e.newValue);r.markerRef.current.setRotation(t)}if("measurements"==e.key&&e.newValue)try{await (0,_.x)("/measurement/sync",{method:"POST",json:{project_id:i.project.project_uuid,geojson:JSON.parse(e.newValue)}}),await M(r.map,i.project.project_uuid)}catch(e){console.error("Measurement sync failed:",e)}if("notes"==e.key&&a(void 0,i.project),"position_in_lidar"===e.key){if(!l.lidarPositionMarkerRef.current){let e=document.createElement("div");e.className="lidar-position-marker";let t=new(j()).Marker(e,{rotationAlignment:"map"}).setLngLat([0,0]).addTo(r.map.current);l.lidarPositionMarkerRef.current=t}if(l.lidarPositionMarkerRef.current){let t=JSON.parse(e.newValue),a=parseFloat(t.rotation);l.lidarPositionMarkerRef.current.setLngLat([t.lon,t.lat]),l.lidarPositionMarkerRef.current.setRotation(a),((e,t)=>{if(!e.map?.current)return;if(aK){let e=e9.zx7([t.lon,t.lat]);if((0,aX.m)(e,aK))return}let a=e.map.current.project([t.lon,t.lat]),r=e.map.current.queryRenderedFeatures(a,{layers:[aR.pI]});r.length>0&&r[0].id?((0,aR.jo)(e.map,r[0].id.toString()),aK=r[0].geometry):aK&&((0,aR.jo)(e.map,null),aK=null)})(r,t)}}}},p=e=>{if(!s||!s.user||"string"!=typeof e.data?.event||e.origin!==m.Z7)return;let t=i.project?.project_name,a=localStorage.getItem("project");if(!t&&a&&(t=JSON.parse(a).project_name),"delete"===e.data.event){let t=e.data.noteId;(0,ee.$W)(r.map,[t],!1)}else{let t=e.data.note;t.first_name=s?.user?.first_name,t.last_name=s?.user?.surname,"update"===e.data.event?(0,ee.sI)(r.map,t,!1):(0,ee.lq)(r.map,t,!1)}localStorage.setItem("notes",[...Array(10)].map(()=>Math.random().toString(36)[2]).join("")),n.setRefreshNotes(e=>e+1)};(0,h.useEffect)(()=>(window.addEventListener("storage",u),window.addEventListener("message",p),()=>{window.removeEventListener("storage",u),window.removeEventListener("message",p)}),[s,i.project,r.map.current])})({setMapCoord:eL,setClickedPositionCoords:eA,updateNotes:tW}),t={setShowRightClickMenu:eF,measurementContext:I,mapboxDrawContext:P},(0,h.useEffect)(()=>{let e=e=>{"/map"!=window.location.pathname||(0,aZ.i)()||e.preventDefault()},a=()=>{t.setShowRightClickMenu({show:!1,action:null,data:null})},r=e=>{"Escape"===e.key&&(t.mapboxDrawContext.setDrawingModeCaller(null),t.measurementContext.setElevationMeasurementEnabled(!1),t.setShowRightClickMenu({show:!1,action:null,data:null}))};return window.addEventListener("beforeunload",e),window.addEventListener("wheel",a),document.addEventListener("keydown",r),()=>{window.removeEventListener("beforeunload",e),window.removeEventListener("wheel",a),document.removeEventListener("keydown",r)}},[t.setShowRightClickMenu,t.measurementContext]),function(e){let t,a,r,s,l,i=(0,eG.JY)(),n=(0,eV.H)(),o=(0,tZ.O)(x.dW.CalendarModal),c=(0,tZ.O)(x.dW.AltCalendarModal),{handleZoomWarning:d,updateSentinelLayerStatus:u}=(t=(0,eG.JY)(),a=(0,eV.H)(),r=(0,h.useRef)(!1),s=(0,h.useRef)(!1),l=e=>{if(!t.map.current)return;let l=t.map.current.getZoom(),i=a.premiumLayer.layer?.threshold??5.5;"ZOOMED_OUT"===e?r.current&&(l<i&&!s.current?s.current=!0:l>=i&&s.current&&(s.current=!1)):"CHENGE_TO_SENTINEL"===e&&l<i&&(s.current=!0)},(0,h.useEffect)(()=>
120{if(!t.map.current)return;let e=()=>l("ZOOMED_OUT");return t.map.current.on("zoom",e),()=>{t.map.current&&t.map.current.off("zoom",e)}},[t.map,l]),{handleZoomWarning:l,updateSentinelLayerStatus:e=>{r.current=e}}),p=(0,h.useRef)(n.mergedDate),m=(0,h.useRef)(n.mergedDateAlt),f=(0,h.useRef)(null),g=(0,h.useRef)(null),y=(0,h.useRef)(i.splitViewEnabled),b=(e,t)=>{if(!e.current||!t)return;let a=e.current,r=()=>!!a.getLayer(t)&&(a.setPaintProperty(t,"raster-opacity",n.rasterVisuals.opacity),a.setPaintProperty(t,"raster-brightness-min",n.rasterVisuals.brightness),a.setPaintProperty(t,"raster-contrast",n.rasterVisuals.contrast),a.setPaintProperty(t,"raster-saturation",n.rasterVisuals.saturation),!0);if(r())return;let s=null,l=()=>{r()&&i()},i=()=>{a.off("render",l),a.off("styledata",l),null!==s&&(globalThis.clearTimeout(s),s=null)};a.on("render",l),a.on("styledata",l),s=globalThis.setTimeout(i,2e4)},j=(e,t,a,r)=>{if(!e.current)return;e.current.getLayer(t.layerName)&&e.current.removeLayer(t.layerName),e.current.getSource(t.layerName)&&e.current.removeSource(t.layerName);let s=a?a.toISOString().slice(0,10):null;t.addLayer(e,t.layerName,s,r),b(e,t.layerName),e.current.triggerRepaint()},w=(e,t)=>{e&&t&&(e.getLayer(t)&&e.removeLayer(t),e.getSource(t)&&e.removeSource(t))},v=(e,t,a,r)=>{e&&t&&(e.getLayer(t)&&e.setLayoutProperty(t,"visibility",a?"visible":"none"),r&&e.triggerRepaint())},N=(e,t,a,r)=>{let s;v(i.map.current,a?.layerName??null,e,!0),v(i.altMap?.current??null,r?.layerName??null,t,!1);let l=(s=[],e&&a?.attribution&&s.push(a.attribution),t&&i.splitViewEnabled&&r?.attribution&&!s.includes(r.attribution)&&s.push(r.attribution),s.join(" | "));l?aY(l):aH(),e?o.openModal():o.closeModal()},S=()=>{let e=i.map.current,t=i.altMap.current;if(!e||!t)return;e.resize(),t.resize();let a=e.getCenter();t.jumpTo({center:[a.lng,a.lat],zoom:e.getZoom(),bearing:e.getBearing(),pitch:e.getPitch()}),e.triggerRepaint(),t.triggerRepaint()};(0,h.useEffect)(()=>{let t=async()=>{if(i.map.current&&n.premiumLayer.selected&&n.premiumLayer.layer){let t=i.splitViewEnabled&&!y.current,a=!1;t?(i.altMap.current?S():await e.loadAltMap(),a=!e.mapboxCompare.current):i.splitViewEnabled&&!i.altMap.current?await e.loadAltMap():i.splitViewEnabled&&i.altMap.current&&(S(),a=!e.mapboxCompare.current);let r=n.premiumLayer.layer,s=n.altPremiumLayer.selected?n.altPremiumLayer.layer:r,l=r.layerName,o=s?.layerName??null;f.current&&f.current!==l&&w(i.map.current,f.current),g.current&&g.current!==o&&w(i.altMap.current,g.current);let c=n.premiumLayerAddedToMap,h=i.splitViewEnabled?n.altPremiumLayerAddedToMap:n.premiumLayerAddedToMap;if(c||h){let t=p.current!==n.mergedDate;c&&(e.reloadLayer||t||!i.map.current.getLayer(l))&&j(i.map,r,n.date,n.mergedDate);let a=m.current!==n.mergedDateAlt,x=n.altDate??n.date;h&&i.splitViewEnabled&&i.altMap.current&&s&&o&&(e.reloadLayer||a||!i.altMap.current.getLayer(o))&&j(i.altMap,s,x,n.mergedDateAlt),p.current=n.mergedDate,m.current=n.mergedDateAlt,f.current=l,g.current=o,e.reloadLayer&&e.setReloadLayer(!1),N(c,h,r,s),b(i.map,l),i.splitViewEnabled&&o&&b(i.altMap,o);let y=r?.satellite?.startsWith("sentinel")&&"Cloud-Free 2023"!==r.layerName;u(y??!1),y&&d(s5.CHANGED_TO_SENTINEL)}else N(!1,!1,r,s);a&&!e.mapboxCompare.current&&(await e.loadCompare(),globalThis.requestAnimationFrame(()=>{S(),b(i.map,l),i.splitViewEnabled&&o&&b(i.altMap,o)}))}};!i.splitViewEnabled&&e.mapboxCompare.current&&(e.mapboxCompare.current.remove(),e.mapboxCompare.current=null),t(),y.current=i.splitViewEnabled},[n.premiumLayerAddedToMap,n.altPremiumLayerAddedToMap,n.premiumLayer,n.altPremiumLayer,i.splitViewEnabled,i.altMap,e.reloadLayer,n.date,n.altDate,n.mergedDate,n.mergedDateAlt,n.altPremiumLayer.selected]),(0,h.useEffect)(()=>{n.premiumLayer.layer&&n.premiumLayerAddedToMap?o.openModal():o.closeModal(),i.splitViewEnabled&&n.altPremiumLayerAddedToMap?c.openModal():c.closeModal()},[n.premiumLayer.layer,n.premiumLayerAddedToMap,n.altPremiumLayerAddedToMap,i.splitViewEnabled])}({reloadLayer:ty,setReloadLayer:tb,mapboxCompare:K,loadAltMap:tL,loadCompare:tC});let{toggleSidePanel:t8,sidePanelOpen:t6,closePanel:t7,currentPanelKey:t9}=(0,e$.p)(),{setSearchResults:ae}=ao({changeLocation:t$}),{isFileDragged:at,openFileInCustomLayersPopup:aa,dragEnter:ar,dragOver:as,dragDrop:ai,dragLeave:ah}=(e=>{let t=(0,ev.O)(),a=(0,eV.H)(),r=(0,ej.H)(),s=(0,e$.p)(),l=(0,h.useRef)(0),[i,n]=(0,h.useState)(!1),c=l=>{if(!l||!t.project)return;let i=l.name.split(".").pop()?.toLowerCase()??"";Object.values(x.Uz).includes(i)?(a.setDropFile(l),s.sidePanelOpen&&"layers"===s.currentPanelKey||s.toggleSidePanel((0,o.jsx)(s2,{setShowEditModelMenu:e.setShowEditModelMenu,setBottomMenuOpen:r.setBottomMenuOpen,onFeatureClick:e.onFeatureClick}
120),{title:"Map Layers",key:"layers"})):y.Ay.error("Unsupported file type")};return{isFileDragged:i,openFileInCustomLayersPopup:c,dragEnter:e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.types.includes("Files")&&(l.current++,n(!0))},dragOver:e=>{e.preventDefault(),e.stopPropagation()},dragDrop:e=>{e.preventDefault(),e.stopPropagation(),1===e.dataTransfer.files.length&&c(e.dataTransfer.files[0]),l.current=0,n(!1)},dragLeave:e=>{e.preventDefault(),e.stopPropagation(),0==--l.current&&n(!1)}}})({setShowEditModelMenu:tr,onFeatureClick:tF});return(e=>{let t=(0,eG.JY)(),a=(0,ej.H)(),r=(0,ey.F)(),s=(0,eb.g)(),l=(0,ef.N)(),i=(0,ev.O)(),n=(0,eN.D)(),o=(0,eV.H)(),{modalState:c}=(0,tZ.O)(x.dW.LidarModal),{setSearchResults:d}=ao({changeLocation:e.changeLocation}),[u,p]=(0,h.useState)(!1),f=!1,g=(0,h.useRef)(e.fetchAndShowLidars),y=(0,h.useRef)(o.editingCustomLayerId),j=(0,h.useRef)(o.editingCustomLayerId);(0,h.useEffect)(()=>{g.current=e.fetchAndShowLidars},[e.fetchAndShowLidars]),(0,h.useEffect)(()=>{y.current=o.editingCustomLayerId},[o.editingCustomLayerId]);let w=new Map,N=async(o,d)=>{if(!d)return;let m=s.isDrawing||r.elevationMeasurementEnabled;a.setBottomMenuOpen({open:!1,id:0,event:null});let h=b.LngLat.convert(o.lngLat).wrap(),g={lat:h.lat,lon:h.lng};if(e.setClickedPositionCoords(g),f||m)return;e.setRun(e=>({...e,run:!1})),u?p(!1):e.setShowRightClickMenu({show:!1,action:null,data:null}),l.setShowAddNoteWindow({show:!1,noteMode:x.md.DEFAULT});let y=d.queryRenderedFeatures(o.point);if(y.some(t=>(t.layer.id===e.gisLayer&&S(o),t.layer&&["note-layer","3dnote-layer","ainote-layer","line-layer","point-layer","alerts-point-layer"].includes(t.layer.id)))){let e=y.find(e=>e.layer?.id==="3dnote-layer");if(void 0===e)(0,eo.JX)(t,a,i.project,h.lat,h.lng,"defaultmarker",!0);else{let r=e.geometry.coordinates;(0,eo.JX)(t,a,i.project,r[1],r[0],"NONE")}}else{if(!y.some(e=>e.layer?.id==="data-layer")){(0,eo.JX)(t,a,i.project,h.lat,h.lng,"defaultmarker"),e.setMapCoord(e=>({...e,lon:h.lng,lat:h.lat})),e.setAddNoteLngLat({lng:h.lng,lat:h.lat}),a.setBottomMenuOpen({open:!0,id:Math.floor(1e3*Math.random()),event:o}),r.setElevationMeasurementEnabled(!1);let s=y.find(e=>e.layer?.id===aR.pI);s?.id?((0,aR.jo)(t.map,s.id.toString()),e.fetchAvailableLidars(g).then(e=>{n.setAvailableLidars([...e])})):c.display||((0,aR.jo)(t.map,null),n.setAvailableLidars([]))}(0,v.By)()}},S=async t=>{if(!i.project)return;let a=b.LngLat.convert(t.lngLat).wrap();e.setClickedPositionCoords({lat:a.lat,lon:a.lng}),await e.searchForAsset(a.lng,a.lat,i.project)},k=()=>{clearTimeout(null)},_=(0,v.sg)(()=>{i.project&&(0,eo.UA)(t,i.project,e.setIsLoading,e.onFeatureClick)},m.d);(0,h.useEffect)(()=>{let e=!!j.current,t=!!o.editingCustomLayerId;e&&!t&&_(),j.current=o.editingCustomLayerId},[o.editingCustomLayerId,_]);let C=t=>{t.preventDefault();let a=b.LngLat.convert(t.lngLat).wrap(),r={lat:a.lat,lon:a.lng};e.setClickedPositionCoords(r),g.current(r)},L=a=>{if(!a)return;let r={clickHandler:e=>N(e,a),dataLayerClickHandler:S,dataLayerMouseEnterHandler:e=>((e,t)=>{if(t&&(t.getCanvas().style.cursor="pointer",e.features&&e.features.length>0&&e.features[0].id)){let a=e.features[0].id;t.setFeatureState({source:"map-points",id:a},{hover:!0})}})(e,a),dataLayerMouseLeaveHandler:e=>((e,t)=>{if(t&&(t.getCanvas().style.cursor="auto",e.features&&e.features.length>0&&e.features[0].id)){let a=e.features[0].id;t.setFeatureState({source:"map-points",id:a},{hover:!1})}})(e,a),dragStartHandler:()=>{d(null),f=!0},dragEndHandler:()=>{f=!1},mouseUpHandler:k,setMapCoordHandler:()=>{let t;return t=a.getCenter(),void e.setMapCoord({lon:parseFloat(t.lng.toFixed(4)),lat:parseFloat(t.lat.toFixed(4)),zoom:parseFloat(a.getZoom().toFixed(2))})},dynamicDataLoadHandler:()=>void(!y.current&&_()),mapErrorHandler:e=>{e.error&&e.error.message&&e.error.message.includes("Could not load image")?e.preventDefault?.():console.error(e.error)},lidarLayerClickHandler:C};w.set(a,r),a.on("dragstart",r.dragStartHandler),a.on("dragend",r.dragEndHandler),a.on("click",r.clickHandler),a.on("touchend",r.clickHandler),a.on("touchend",r.mouseUpHandler),a.on("error",r.mapErrorHandler),a.on("click","data-layer",r.dataLayerClickHandler),a.on("touchend","data-layer",r.dataLayerClickHandler),a.on("mouseenter","data-layer",r.dataLayerMouseEnterHandler),a.on("mouseleave","data-layer",r.dataLayerMouseLeaveHandler),a.on("click",aR.pI,r.lidarLayerClickHandler),a===t.map.current&&(a.on("moveend",r.setMapCoordHandler),a.on("moveend",r.dynamicDataLoadHandler))},D=e=>{if(!e)return;let a=w.get(e);a&&(e.off("dragstart",a.dragStartHandler),e.off("dragend",a.dragEndHandler),e.off("click",a.clickHandler),e.off("touchend",a.clickHandler),e.off("touchend",a.mouseUpHandler),e.off("error",a.mapErrorHandler),e.off("click","data-layer",a.dataLayerClickHandler),e.off("touchend","data-layer",a.dataLayerClickHandler),e.off("mouseenter","data-layer",a.dataLayerMouseEnterHandler),e.off("mouseleave","data-layer",a.dataLayerMouseLeaveHandler),e.off("click",aR.pI,a.lidarLayerClickHandler),e===t.map.current&&(e.off("moveend",a.setMapCoordHandler),e.off("moveend",a.dynamicDataLoadHandler)))};(0,h.useEffect)(()=>
120{if(i.project)return d(null),L(t.map.current),L(t.altMap.current),()=>{D(t.map.current),D(t.altMap.current)}},[s.isDrawing,r.elevationMeasurementEnabled,i.project,u,e.gisLayer,t,c]);let A=t=>{e.setShowRightClickMenu(t),e.setRefreshShowRightClickMenu(e=>e+1)};(0,h.useEffect)(()=>{if(t.map.current)return(0,v.$R)(t.map,e.setShowRightClickMenu,l.setShowAddNoteWindow,{setShowAddNoteWindow:l.setShowAddNoteWindow,setDrawingModeCaller:s.setDrawingModeCaller,setElevationMeasurementEnabled:r.setElevationMeasurementEnabled,setShowRightClickMenu:A,setRightClickMenuPoint:e.setRightClickMenuPoint,setAddNoteLngLat:e.setAddNoteLngLat,setMapCoord:e.setMapCoord,mapCoord:e.mapCoord,setClickedPositionCoord:e.setClickedPositionCoords,drawingModeCaller:s.drawingModeCaller},n,e.fetchAvailableLidars)},[e.gisLayer,t.map.current,s.drawingModeCaller])})({gisLayer:tf,mapCoord:eC,setMapCoord:eL,setClickedPositionCoords:eA,setRun:t_,setShowRightClickMenu:eF,setAddNoteLngLat:eJ,searchForAsset:tR,changeLocation:t$,setIsLoading:eI,onFeatureClick:tF,setRightClickMenuPoint:eU,setRefreshShowRightClickMenu:eR,fetchAvailableLidars:tI,fetchAndShowLidars:e=>{Z(x.dW.LidarModal).display&&tI(e).then(t=>tP(t,e))}}),(0,h.useEffect)(()=>{L.map.current||(eI(!0),tT(),eI(!1))},[L.map.current]),(0,h.useEffect)(()=>{(async()=>{if(!to?.cluster){if(to&&t4(),to&&to.img){let e=U.project?.container_name+(to.user?"/notes/":"/alerts/");to.folder_path.base&&(e+=to.folder_path.base+"/");let t=await (0,H.bB)(e+to.img);to.file_path&&A.setNote3DData({filepath:to.folder_path?null:t,folder_path:to.folder_path||null,properties:to})}if(to){let e=U.project?.container_name+(to.user?"/notes/":"/alerts/");to.base&&(e+=to.base),t8((0,o.jsx)(al,{parentId:to.id,category:to.category,severity:to.severity,title:to.title,description:to.description,create_date:to.create_date,author:to.user?to.user:to.issuer,author_id:to.user_id,project:U.project,reviewed:to.reviewed,verify_status:to.verify_status??null,verifyStatusUpdating:tp.has(to.id),onVerifyStatusChange:U.project&&(0,v._A)(F?.user,U.project.project_uuid)?e=>tX(to.id,e):void 0,file_path:to.img&&e?e:void 0,files:JSON.parse(to?.files||"[]"),onUpdateAlert:e=>tH([e]),onUpdateNote:e=>tW(e),user:F?.user,coords:{lon:to.lon,lat:to.lat},markerType:to.type,source:to.user?x.Sw.NOTE:x.Sw.ALERT,userMap:eu,noteData:{filepath:to.folder_path?null:m.oj+U.project?.container_name+"/notes/"+to.img,folder_path:to.folder_path||null,properties:to}}),{title:"Threads",key:to.id})}}})()},[to]),(0,h.useEffect)(()=>{L.map.current&&((0,ee.m7)(L.map,L.layerFilterOptions.current.notes,!0),(0,ti.QT)(L.map,L.layerFilterOptions.current.alerts))},[A.refreshNotes,E.refreshAlerts]),(0,h.useEffect)(()=>{if(!U.project||!L.map.current)return;let e=async()=>{let e=await (0,ab.eq)(U.project?.project_uuid);ep(e),L.map=await ed(L.map,er,U.project,e,t8,t7,t9,L.layerFilterOptions,tu),L.map=await td(L.map,er,U.project,e,t8,t7,t9,L.layerFilterOptions.current.alerts,tu)};aF(U.project),e()},[U.project,L.map]),(0,h.useEffect)(()=>{(0,v.Q2)(),L.map.current&&(window.tb=new w.Threebox(L.map.current,L.map.current.getCanvas().getContext("webgl"),{defaultLights:!0,enableSelectingObjects:!0,enableDraggingObjects:!0,enableRotatingObjects:!0}))},[]),(0,h.useEffect)(()=>{A.showAddNoteWindow.show&&L.map.current&&null!==A.showAddNoteWindow.noteMode&&t8((0,o.jsx)(eY,{onNoteUpdated:tW,onNoteCreated:tq,lat:eW.lat,lon:eW.lng,userMap:eu,dropFileForCustomLayers:aa,closePanel:t7}),{title:"Add a note",key:A.showAddNoteWindow.noteMode.toString()})},[A.showAddNoteWindow]),(0,h.useEffect)(()=>{if(U.project){var e;let t,a,r=localStorage.getItem("filters"),s=r?JSON.parse(r):null,l=s&&Object.hasOwn(s,U.project.project_uuid)?s[U.project.project_uuid]:(e=U.project,t=e.alert_defaults?.visible_severity_levels,a=t?.length?{visibleSeverityLevels:t}:{},"66491710-f416-4e1e-a85e-e15a363e12de"===e.project_uuid?{...a,...{dates:{from:(0,v.Rq)(15),to:new Date}}}:a);C.current=U.project.project_uuid,l?.dates?.from&&(l.dates.from=new Date(l.dates.from)),l?.dates?.to&&(l.dates.to=new Date(l.dates.to)),L.layerFilterOptions.current.alerts=l,E.setRefreshAlerts(e=>e+1)}},[U.project?.project_uuid]),(0,h.useEffect)(()=>
120{if(U.project){if(C.current===U.project.project_uuid){C.current=null;return}let e=localStorage.getItem("filters"),t=e?JSON.parse(e):{};t[U.project.project_uuid]=L.layerFilterOptions.current.alerts,localStorage.setItem("filters",JSON.stringify(t))}},[E.refreshAlerts,U.project]),(0,h.useEffect)(()=>{L.map.current&&E.showIssueAlertWindow&&(t8((0,o.jsx)(th,{OnAlertCreated:t0,OnAlertUpdated:tH,lat:eW.lat,lon:eW.lng,userMap:eu,closePanel:t7}),{title:"Issue Alert",key:"Issue Alert"}),E.setShowIssueAlertWindow(!1))},[E.showIssueAlertWindow]),(0,h.useEffect)(()=>{e4&&(t8((0,o.jsx)(am,{showIfcModal:e4,setShowIfcModal:e8,lat:eW.lat,lon:eW.lng,project:U.project,map:L.map,user:F?.user,customLayers:D.customLayers,setCustomLayers:D.setCustomLayers,setShowEditModelMenu:tr,setBottomMenuOpen:B.setBottomMenuOpen}),{title:"Add IFC Layer",key:"Add IFC Layer"}),e8(!1))},[e4]),(0,h.useEffect)(()=>()=>{Q.current?.(),Q.current=null,K.current&&(K.current.remove(),K.current=null),L.altMap.current&&(L.altMap.current.remove(),L.altMap.current=null)},[]),(0,o.jsxs)("div",{className:"mapcont",children:[(0,o.jsx)(g(),{children:(0,o.jsx)("title",{children:"FusionMap - Map"})}),(0,o.jsx)(y.l$,{}),(0,o.jsx)("style",{children:"body {overflow: hidden; }"}),(0,o.jsx)(tO,{clickedPositionCoords:eD,useLRS:U.project?.lrs_included||!1,addNote:e=>A.setShowAddNoteWindow({show:!0,noteMode:e}),issueAlert:()=>E.setShowIssueAlertWindow(!0),premiumLayer:D.premiumLayer.layer,map:L.map.current,altMap:L.altMap.current?L.altMap.current:null,searchAsset:async()=>await tR(eD.lon,eD.lat,U.project),setShowIfcModal:()=>e8(!0),showEditModelMenu:ta,gisLayer:tf,showLidar:tP}),(0,o.jsx)(tG.N9,{className:`${(0,v.Fr)()?"mt-24!":"mt-12"} ${t6&&!(0,v.Fr)()?"mr-[360px]!":"mr-[0px]!"}`,style:{zIndex:100},position:"top-right",autoClose:!1,closeButton:!1,closeOnClick:!1,rtl:!1,pauseOnFocusLoss:!1,draggable:!1,stacked:(0,v.Fr)(),theme:"light",transition:tG.K9}),U.project&&eu&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(ap,{}),(0,o.jsx)(an,{userMap:eu,syncMentions:ts,toggleSidePanel:t8,closePanel:t7,currentPanelKey:t9,onUpdateAlert:e=>tH([e])})]}),(0,o.jsx)(s3,{progress:eh,onTriggerWalkthrough:()=>t_({run:!0})}),(0,o.jsx)(p(),{rel:"stylesheet",href:"https://api.tiles.mapbox.com/mapbox-gl-js/v2.15.0/mapbox-gl.css",type:"text/css"}),(0,o.jsxs)("div",{id:"comparison-container",className:"map-container",onDragEnter:ar,onDragOver:as,onDrop:ai,onDragLeave:ah,children:[at&&(0,o.jsx)("div",{className:"flex justify-center items-center absolute inset-4 z-100 bg-tt-blue/50 rounded-md border-4 border-dashed border-tt-blue pointer-events-none",children:(0,o.jsx)("p",{className:"text-white text-3xl font-bold",children:"Drop Files Here"})}),(0,o.jsx)("div",{className:"map mapboxgl-map",ref:el,style:{width:"100%",height:"100vh",position:"absolute"}}),(0,o.jsx)("div",{className:"map mapboxgl-map",ref:ea,style:{width:"100%",height:"100vh",position:"absolute",visibility:L.splitViewEnabled?"visible":"hidden"}}),(0,o.jsx)(e6,{showMobileMenu:eq,setShowMobileMenu:eK}),(0,o.jsx)(tl,{mode:x.xY.DISTANCE_TOOL}),(0,o.jsx)(tl,{mode:x.xY.AREA_TOOL}),(0,o.jsx)(tU,{}),(0,o.jsx)(V.A,{isOpen:e5,onDelete:()=>{"note"===eP.action?t2(eP.data.properties.id):"alert"===eP.action?t5(eP.data.properties.id):"measurement"===eP.action&&t3(eP.data),e3(!1)},closeModal:()=>e3(!1)}),P.editGeometriesEnabled&&(0,o.jsx)(nt,{}),tS&&(0,o.jsx)(eH.Ay,{callback:e=>{let{status:t}=e;[eH.XQ.FINISHED,eH.XQ.SKIPPED].includes(t)&&(t_({run:!1}),localStorage.setItem("first_time_user","false"))},continuous:!0,hideCloseButton:!0,run:tS,scrollToFirstStep:!0,showSkipButton:!0,steps:tk,styles:{options:{arrowColor:"#e3ffeb",primaryColor:" #2563eb",textColor:"black",zIndex:1e3}}}),U.project&&(0,o.jsx)(eS,{showRightClickMenu:eP,setShowRightClickMenu:eF,rightClickMenuPoint:ez,mapCoord:eC,searchForAsset:tR,setShowDeleteConfirmation:e3,setShowIfcModal:e8,fetchAvailableLidars:tI,showLidar:tP}),U.project&&(0,o.jsx)(i4,{clickedPositionCoords:eD,updateNotes:tW,deleteNotes:tJ,createNote:tq,updateNoteNotifications:tB,setAddNoteLngLat:eJ,updateAlerts:tH,deleteAlerts:tQ,createAlert:t0,resetAlertsModalFilter:e1,resetNotesModalFilter:eQ,updateAlertNotifications:tK,features:tv,deleteMeasure:t1,refreshHybridModal:te,eagleView:e_,mapCoord:eC,userMap:eu,advSearchRef:en,setLoa
120ding:eI,changeLocation:t$}),(0,o.jsxs)("div",{children:[(0,o.jsxs)("div",{className:"flex flex-row gap-4 absolute desktop:z-40 z-30 items-center desktop:p-4 p-2 w-full desktop:w-auto",children:[(0,o.jsx)("a",{href:"/",className:"desktop:inline-flex hidden mr-6",children:(0,o.jsx)(d(),{src:"/images/fusionmap_logo_hor.svg",alt:"FusionMap Logo",width:130,height:25,className:"opacity-95 object-contain"})}),(0,o.jsx)(ac,{setShowMobileMenu:eK,changeLocation:t$,loading:eT}),(0,o.jsxs)("div",{className:"filter-state-buttons",children:[L.layerFilterOptions.current.notes&&(0,o.jsxs)("div",{className:"flex items-center bg-white/95 shadow pl-1 pr-2 py-0.5 rounded-full border border-gray-300/70",children:[(0,o.jsx)("button",{onClick:()=>{L.layerFilterOptions.current.notes=null,A.setRefreshNotes(e=>e+1)},className:"rounded-full p-1",children:(0,o.jsx)(W.IeJ,{className:"text-gray-700 text-lg"})}),(0,o.jsx)("span",{className:"text-gray-700 font-bold mr-1.5",children:"Notes filtered"})]}),L.layerFilterOptions.current.alerts&&0!==Object.keys(L.layerFilterOptions.current.alerts).length&&(0,o.jsxs)("div",{className:"flex items-center bg-white/95 shadow pl-1 pr-2 py-0.5 rounded-full border border-gray-300/70",children:[(0,o.jsx)("button",{onClick:()=>{L.layerFilterOptions.current.alerts=null,E.setRefreshAlerts(e=>e+1)},className:"rounded-full p-1",children:(0,o.jsx)(W.IeJ,{className:"text-gray-700 text-lg"})}),(0,o.jsx)("span",{className:"text-gray-700 font-bold mr-1.5",children:"Alerts filtered"})]})]})]}),(0,o.jsx)(i8,{setRun:t_}),U.project&&!P.isDrawing&&!I.elevationMeasurementEnabled&&(0,o.jsx)(s4,{showLidar:tP,fetchAvailableLidars:tI}
120),U.projectImageUrl&&!L.splitViewEnabled&&(0,o.jsx)("img",{src:U.projectImageUrl,alt:"Logo",width:80,className:"absolute z-30 bottom-[50px] left-2"}),D.premiumLayer.layer&&D.premiumLayerAddedToMap&&(0,o.jsx)(tV,{date:D.date,setDate:D.setDate,splitViewEnabled:L.splitViewEnabled,onClick:()=>{D.premiumLayer.layer&&D.premiumLayerAddedToMap?q(x.dW.CalendarModal):y.Ay.error("Date selection is only available after a premium layer has been selected.")},alt:!1})]}),U.project&&(0,o.jsx)(lN,{setShowEditModelMenu:tr,onFeatureClick:tF,setReloadLayer:tb}),D.premiumLayer.selected&&(0,o.jsx)(tj,{})]})]})}}},e=>{e.O(0,[3371,2901,6695,7671,4188,7391,2697,4278,4695,580,4701,8690,9239,5925,1167,3845,4176,6497,1852,714,4355,8752,8239,4356,8987,1967,5856,4519,1893,5296,3873,636,6593,8792],()=>e(e.s=23512)),_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.