diff --git a/frontend/src/assets/logo.jpg b/frontend/src/assets/logo.jpg deleted file mode 100644 index 7b514285..00000000 --- a/frontend/src/assets/logo.jpg +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:45d98f276fcd585024dd62e635acd3305f29dc89171f15304913c6d528ba3c3b -size 25732 diff --git a/frontend/src/assets/logo.png b/frontend/src/assets/logo.png new file mode 100644 index 00000000..fb40fc93 --- /dev/null +++ b/frontend/src/assets/logo.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fda151715bffc75fa519590ff0b623f5d38571bddc4a53da35a104ce05470208 +size 87190 diff --git a/frontend/src/components/HeaderNav.tsx b/frontend/src/components/HeaderNav.tsx index 90b838b4..f5601aed 100644 --- a/frontend/src/components/HeaderNav.tsx +++ b/frontend/src/components/HeaderNav.tsx @@ -11,7 +11,7 @@ import { import { useState, useEffect, useRef } from "react"; import styles from './HeaderNav.module.css'; // 导入 logo 图片 -import logoImage from '../assets/logo.jpg'; +import logoImage from '../assets/logo.png'; declare global { diff --git a/py_backend/static/assets/AdminPage-CwitwbVg.js b/py_backend/static/assets/AdminPage-BZgg3d6P.js similarity index 99% rename from py_backend/static/assets/AdminPage-CwitwbVg.js rename to py_backend/static/assets/AdminPage-BZgg3d6P.js index ef058c08..8c248e5d 100644 --- a/py_backend/static/assets/AdminPage-CwitwbVg.js +++ b/py_backend/static/assets/AdminPage-BZgg3d6P.js @@ -1,4 +1,4 @@ -import{r as i,j as a,N as K,H as Je,O as h,z as j,I as re,_ as Ge,n as d,J as y}from"./index-Dym8TuvV.js";import{u as Ve}from"./useAdmin-DnFl9FMw.js";const We="_adminContainer_j11pf_5",qe="_adminHeader_j11pf_13",Ke="_adminSection_j11pf_20",Ye="_modelSelectionArea_j11pf_29",Qe="_modelSelectionRow_j11pf_36",Xe="_modelsTable_j11pf_89",Ze="_promptSubsection_j11pf_97",ea="_promptSubsectionTitle_j11pf_109",aa="_modelCode_j11pf_152",la="_modelId_j11pf_157",sa="_modelActions_j11pf_163",oa="_addModelButtonContainer_j11pf_169",ta="_addModelForm_j11pf_177",ia="_addModelFormTitle_j11pf_185",da="_addModelFormGrid_j11pf_193",na="_addModelFormField_j11pf_206",ra="_addModelFormCheckbox_j11pf_250",ca="_addModelFormActions_j11pf_268",ma="_modalOverlay_j11pf_277",ha="_modalContent_j11pf_291",pa="_modalBody_j11pf_302",_a="_modalTitle_j11pf_312",ua="_modalText_j11pf_320",xa="_modalTextLeft_j11pf_332",ja="_modalButtons_j11pf_355",va="_modalForm_j11pf_363",ga="_formField_j11pf_372",fa="_formLabel_j11pf_376",ba="_formInput_j11pf_385",ya="_textarea_j11pf_407",l={adminContainer:We,adminHeader:qe,adminSection:Ke,modelSelectionArea:Ye,modelSelectionRow:Qe,modelsTable:Xe,promptSubsection:Ze,promptSubsectionTitle:ea,modelCode:aa,modelId:la,modelActions:sa,addModelButtonContainer:oa,addModelForm:ta,addModelFormTitle:ia,addModelFormGrid:da,addModelFormField:na,addModelFormCheckbox:ra,addModelFormActions:ca,modalOverlay:ma,modalContent:ha,modalBody:pa,modalTitle:_a,modalText:ua,modalTextLeft:xa,modalButtons:ja,modalForm:va,formField:ga,formLabel:fa,formInput:ba,textarea:ya},I="selectedVlmModel";function Ca(){const{isAuthenticated:v,isLoading:ce,login:me,logout:he,verifyToken:Y}=Ve(),[E,Q]=i.useState(""),[X,g]=i.useState(""),[Z,ee]=i.useState(!1),[N,S]=i.useState([]),[pe,C]=i.useState(""),[_e,M]=i.useState(""),[ae,P]=i.useState([]),[ue,L]=i.useState([]),[xe,B]=i.useState([]),[je,k]=i.useState(!1),[O,D]=i.useState(null),[U,f]=i.useState({schema_id:"",title:"",version:"",schema:{}}),[ve,w]=i.useState(!1),[ge,T]=i.useState(!1),[fe,z]=i.useState(null),[F,R]=i.useState(null),[n,c]=i.useState({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1}),[le,H]=i.useState(!1),[be,J]=i.useState(!1),[G,V]=i.useState(null),[t,m]=i.useState({m_code:"",label:"",model_type:"custom",provider:"huggingface",model_id:"",is_available:!1,is_fallback:!1}),[ye,A]=i.useState(!1),[Ne,W]=i.useState(!1),[Se,_]=i.useState(!1),[se,oe]=i.useState(""),[Ce,Me]=i.useState(""),[ke,u]=i.useState(""),[we,$]=i.useState(""),x=i.useCallback(()=>{fetch("/api/models").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}).then(e=>{if(console.log("Models data received:",e),e&&Array.isArray(e.models)){S(e.models);const s=localStorage.getItem(I);if(e.models.length>0)if(s==="random")C("random");else if(s&&e.models.find(o=>o.m_code===s&&o.is_available))C(s);else{const o=e.models.find(r=>r.is_available)||e.models[0];C(o.m_code),localStorage.setItem(I,o.m_code)}fetch("/api/admin/fallback-model",{headers:{Authorization:`Bearer ${localStorage.getItem("adminToken")}`}}).then(o=>{if(!o.ok)throw new Error(`HTTP ${o.status}: ${o.statusText}`);return o.json()}).then(o=>{if(console.log("Fallback model data received:",o),o.fallback_model)M(o.fallback_model.m_code);else{const r=e.models.find(p=>p.m_code==="STUB_MODEL"&&p.is_available);M(r?"STUB_MODEL":"")}}).catch(o=>{console.error("Error fetching fallback model:",o);const r=e.models.find(p=>p.m_code==="STUB_MODEL"&&p.is_available);M(r?"STUB_MODEL":"")})}else console.error("Expected models object but got:",e),S([])}).catch(e=>{console.error("Error fetching models:",e),S([])})},[]),b=i.useCallback(()=>{console.log("=== fetchPrompts called ==="),fetch("/api/prompts").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}).then(e=>{console.log("Prompts data received:",e),Array.isArray(e)?P(e):(console.error("Expected array but got:",e),P([])),console.log("State update triggered with:",e||[])}).catch(e=>{console.error("Error fetching prompts:",e),P([])})},[]),te=i.useCallback(()=>{fetch("/api/image-types").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}).then(e=>{console.log("Image types data received:",e),Array.isArray(e)?L(e):(console.error("Expected array but got:",e),L([]))}).catch(e=>{console.error("Error fetching image types:",e),L([])})},[]),q=i.useCallback(()=>{console.log("=== fetchSchemas called ==="),fetch("/api/schemas",{headers:{Authorization:`Bearer ${localStorage.getItem("adminToken")}`}}).then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}).then(e=>{console.log("Schemas data received:",e),Array.isArray(e)?B(e):(console.error("Expected array but got:",e),B([]))}).catch(e=>{console.error("Error fetching schemas:",e),B([])})},[]);i.useEffect(()=>{v&&(x(),b(),te(),q())},[v,x,b,te,q]),i.useEffect(()=>{v&&Y()},[v,Y]);const ie=e=>{R(e),c({p_code:e.p_code,label:e.label||"",metadata_instructions:e.metadata_instructions||"",image_type:e.image_type||"crisis_map",is_active:e.is_active||!1}),w(!0)},Te=async()=>{try{if(!F){alert("No prompt selected for editing");return}const e=await fetch(`/api/prompts/${F.p_code}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({label:n.label,metadata_instructions:n.metadata_instructions,image_type:n.image_type,is_active:n.is_active})});if(e.ok)b(),w(!1),R(null),c({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1});else{const s=await e.json();alert(`Failed to update prompt: ${s.error||"Unknown error"}`)}}catch{alert("Error updating prompt")}},de=async(e,s)=>{try{const o=await fetch(`/api/prompts/${e}/toggle-active?image_type=${s}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(o.ok)b();else{const r=await o.json();alert(`Failed to toggle prompt active status: ${r.detail||"Unknown error"}`)}}catch{alert("Error toggling prompt active status")}},ne=e=>{z(e),c({p_code:"",label:"",metadata_instructions:"",image_type:e,is_active:!1}),T(!0)},Fe=async()=>{try{const e=await fetch("/api/prompts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(e.ok)b(),T(!1),z(null),c({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1});else{const s=await e.json();alert(`Failed to create prompt: ${s.detail||"Unknown error"}`)}}catch{alert("Error creating prompt")}},Ae=e=>{D(e),f({schema_id:e.schema_id,title:e.title,version:e.version,schema:e.schema}),k(!0)},$e=async()=>{try{if(!O){alert("No schema selected for editing");return}const e=await fetch(`/api/schemas/${O.schema_id}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("adminToken")}`},body:JSON.stringify(U)});if(e.ok)q(),k(!1),D(null),f({schema_id:"",title:"",version:"",schema:{}});else{const s=await e.json();alert(`Failed to save schema: ${s.detail||"Unknown error"}`)}}catch(e){console.error("Error saving schema:",e),alert("Error saving schema")}},Ie=()=>{k(!1),D(null),f({schema_id:"",title:"",version:"",schema:{}})},Ee=async(e,s)=>{try{const o=await fetch(`/api/models/${e}/toggle`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({is_available:!s})});if(o.ok)S(r=>(r||[]).map(p=>p.m_code===e?{...p,is_available:!s}:p));else{const r=await o.json();alert(`Failed to toggle model availability: ${r.error||"Unknown error"}`)}}catch{alert("Error toggling model availability")}},Pe=e=>{C(e),e==="random"?localStorage.setItem(I,"random"):localStorage.setItem(I,e)},Le=async e=>{try{const s=await fetch(`/api/admin/models/${e}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("adminToken")}`},body:JSON.stringify({is_fallback:!0})});if(s.ok)M(e),x();else{const o=await s.json();alert(`Failed to set fallback model: ${o.detail||"Unknown error"}`)}}catch{alert("Error setting fallback model")}},Be=async()=>{try{const e=await fetch("/api/admin/models",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("adminToken")}`},body:JSON.stringify(t)});if(e.ok){const s=` +import{r as i,j as a,N as K,H as Je,O as h,z as j,I as re,_ as Ge,n as d,J as y}from"./index-C5rMGfs8.js";import{u as Ve}from"./useAdmin-B8fo0TJy.js";const We="_adminContainer_j11pf_5",qe="_adminHeader_j11pf_13",Ke="_adminSection_j11pf_20",Ye="_modelSelectionArea_j11pf_29",Qe="_modelSelectionRow_j11pf_36",Xe="_modelsTable_j11pf_89",Ze="_promptSubsection_j11pf_97",ea="_promptSubsectionTitle_j11pf_109",aa="_modelCode_j11pf_152",la="_modelId_j11pf_157",sa="_modelActions_j11pf_163",oa="_addModelButtonContainer_j11pf_169",ta="_addModelForm_j11pf_177",ia="_addModelFormTitle_j11pf_185",da="_addModelFormGrid_j11pf_193",na="_addModelFormField_j11pf_206",ra="_addModelFormCheckbox_j11pf_250",ca="_addModelFormActions_j11pf_268",ma="_modalOverlay_j11pf_277",ha="_modalContent_j11pf_291",pa="_modalBody_j11pf_302",_a="_modalTitle_j11pf_312",ua="_modalText_j11pf_320",xa="_modalTextLeft_j11pf_332",ja="_modalButtons_j11pf_355",va="_modalForm_j11pf_363",ga="_formField_j11pf_372",fa="_formLabel_j11pf_376",ba="_formInput_j11pf_385",ya="_textarea_j11pf_407",l={adminContainer:We,adminHeader:qe,adminSection:Ke,modelSelectionArea:Ye,modelSelectionRow:Qe,modelsTable:Xe,promptSubsection:Ze,promptSubsectionTitle:ea,modelCode:aa,modelId:la,modelActions:sa,addModelButtonContainer:oa,addModelForm:ta,addModelFormTitle:ia,addModelFormGrid:da,addModelFormField:na,addModelFormCheckbox:ra,addModelFormActions:ca,modalOverlay:ma,modalContent:ha,modalBody:pa,modalTitle:_a,modalText:ua,modalTextLeft:xa,modalButtons:ja,modalForm:va,formField:ga,formLabel:fa,formInput:ba,textarea:ya},I="selectedVlmModel";function Ca(){const{isAuthenticated:v,isLoading:ce,login:me,logout:he,verifyToken:Y}=Ve(),[E,Q]=i.useState(""),[X,g]=i.useState(""),[Z,ee]=i.useState(!1),[N,S]=i.useState([]),[pe,C]=i.useState(""),[_e,M]=i.useState(""),[ae,P]=i.useState([]),[ue,L]=i.useState([]),[xe,B]=i.useState([]),[je,k]=i.useState(!1),[O,D]=i.useState(null),[U,f]=i.useState({schema_id:"",title:"",version:"",schema:{}}),[ve,w]=i.useState(!1),[ge,T]=i.useState(!1),[fe,z]=i.useState(null),[F,R]=i.useState(null),[n,c]=i.useState({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1}),[le,H]=i.useState(!1),[be,J]=i.useState(!1),[G,V]=i.useState(null),[t,m]=i.useState({m_code:"",label:"",model_type:"custom",provider:"huggingface",model_id:"",is_available:!1,is_fallback:!1}),[ye,A]=i.useState(!1),[Ne,W]=i.useState(!1),[Se,_]=i.useState(!1),[se,oe]=i.useState(""),[Ce,Me]=i.useState(""),[ke,u]=i.useState(""),[we,$]=i.useState(""),x=i.useCallback(()=>{fetch("/api/models").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}).then(e=>{if(console.log("Models data received:",e),e&&Array.isArray(e.models)){S(e.models);const s=localStorage.getItem(I);if(e.models.length>0)if(s==="random")C("random");else if(s&&e.models.find(o=>o.m_code===s&&o.is_available))C(s);else{const o=e.models.find(r=>r.is_available)||e.models[0];C(o.m_code),localStorage.setItem(I,o.m_code)}fetch("/api/admin/fallback-model",{headers:{Authorization:`Bearer ${localStorage.getItem("adminToken")}`}}).then(o=>{if(!o.ok)throw new Error(`HTTP ${o.status}: ${o.statusText}`);return o.json()}).then(o=>{if(console.log("Fallback model data received:",o),o.fallback_model)M(o.fallback_model.m_code);else{const r=e.models.find(p=>p.m_code==="STUB_MODEL"&&p.is_available);M(r?"STUB_MODEL":"")}}).catch(o=>{console.error("Error fetching fallback model:",o);const r=e.models.find(p=>p.m_code==="STUB_MODEL"&&p.is_available);M(r?"STUB_MODEL":"")})}else console.error("Expected models object but got:",e),S([])}).catch(e=>{console.error("Error fetching models:",e),S([])})},[]),b=i.useCallback(()=>{console.log("=== fetchPrompts called ==="),fetch("/api/prompts").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}).then(e=>{console.log("Prompts data received:",e),Array.isArray(e)?P(e):(console.error("Expected array but got:",e),P([])),console.log("State update triggered with:",e||[])}).catch(e=>{console.error("Error fetching prompts:",e),P([])})},[]),te=i.useCallback(()=>{fetch("/api/image-types").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}).then(e=>{console.log("Image types data received:",e),Array.isArray(e)?L(e):(console.error("Expected array but got:",e),L([]))}).catch(e=>{console.error("Error fetching image types:",e),L([])})},[]),q=i.useCallback(()=>{console.log("=== fetchSchemas called ==="),fetch("/api/schemas",{headers:{Authorization:`Bearer ${localStorage.getItem("adminToken")}`}}).then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}).then(e=>{console.log("Schemas data received:",e),Array.isArray(e)?B(e):(console.error("Expected array but got:",e),B([]))}).catch(e=>{console.error("Error fetching schemas:",e),B([])})},[]);i.useEffect(()=>{v&&(x(),b(),te(),q())},[v,x,b,te,q]),i.useEffect(()=>{v&&Y()},[v,Y]);const ie=e=>{R(e),c({p_code:e.p_code,label:e.label||"",metadata_instructions:e.metadata_instructions||"",image_type:e.image_type||"crisis_map",is_active:e.is_active||!1}),w(!0)},Te=async()=>{try{if(!F){alert("No prompt selected for editing");return}const e=await fetch(`/api/prompts/${F.p_code}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({label:n.label,metadata_instructions:n.metadata_instructions,image_type:n.image_type,is_active:n.is_active})});if(e.ok)b(),w(!1),R(null),c({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1});else{const s=await e.json();alert(`Failed to update prompt: ${s.error||"Unknown error"}`)}}catch{alert("Error updating prompt")}},de=async(e,s)=>{try{const o=await fetch(`/api/prompts/${e}/toggle-active?image_type=${s}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(o.ok)b();else{const r=await o.json();alert(`Failed to toggle prompt active status: ${r.detail||"Unknown error"}`)}}catch{alert("Error toggling prompt active status")}},ne=e=>{z(e),c({p_code:"",label:"",metadata_instructions:"",image_type:e,is_active:!1}),T(!0)},Fe=async()=>{try{const e=await fetch("/api/prompts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(e.ok)b(),T(!1),z(null),c({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1});else{const s=await e.json();alert(`Failed to create prompt: ${s.detail||"Unknown error"}`)}}catch{alert("Error creating prompt")}},Ae=e=>{D(e),f({schema_id:e.schema_id,title:e.title,version:e.version,schema:e.schema}),k(!0)},$e=async()=>{try{if(!O){alert("No schema selected for editing");return}const e=await fetch(`/api/schemas/${O.schema_id}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("adminToken")}`},body:JSON.stringify(U)});if(e.ok)q(),k(!1),D(null),f({schema_id:"",title:"",version:"",schema:{}});else{const s=await e.json();alert(`Failed to save schema: ${s.detail||"Unknown error"}`)}}catch(e){console.error("Error saving schema:",e),alert("Error saving schema")}},Ie=()=>{k(!1),D(null),f({schema_id:"",title:"",version:"",schema:{}})},Ee=async(e,s)=>{try{const o=await fetch(`/api/models/${e}/toggle`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({is_available:!s})});if(o.ok)S(r=>(r||[]).map(p=>p.m_code===e?{...p,is_available:!s}:p));else{const r=await o.json();alert(`Failed to toggle model availability: ${r.error||"Unknown error"}`)}}catch{alert("Error toggling model availability")}},Pe=e=>{C(e),e==="random"?localStorage.setItem(I,"random"):localStorage.setItem(I,e)},Le=async e=>{try{const s=await fetch(`/api/admin/models/${e}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("adminToken")}`},body:JSON.stringify({is_fallback:!0})});if(s.ok)M(e),x();else{const o=await s.json();alert(`Failed to set fallback model: ${o.detail||"Unknown error"}`)}}catch{alert("Error setting fallback model")}},Be=async()=>{try{const e=await fetch("/api/admin/models",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("adminToken")}`},body:JSON.stringify(t)});if(e.ok){const s=` Model "${t.label}" added successfully! ⚠️ IMPORTANT: Model will NOT work until you complete these steps: diff --git a/py_backend/static/assets/ExportModal-Bq4gp-iF.js b/py_backend/static/assets/ExportModal-DJxQWbes.js similarity index 99% rename from py_backend/static/assets/ExportModal-Bq4gp-iF.js rename to py_backend/static/assets/ExportModal-DJxQWbes.js index 2cf69706..a2a68008 100644 --- a/py_backend/static/assets/ExportModal-Bq4gp-iF.js +++ b/py_backend/static/assets/ExportModal-DJxQWbes.js @@ -1 +1 @@ -import{r as n,D as O,j as e,z as c,n as o,O as B,J as b,P as G,_ as M,L as A,S as P}from"./index-Dym8TuvV.js";const q=({title:m,titleId:u,...x})=>n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em","aria-labelledby":u},x),m?n.createElement("title",{id:u},m):null,n.createElement("g",{clipPath:"url(#filter-line_svg__a)"},n.createElement("path",{d:"M9 13.5 4 6H3V4h18v2h-1l-5 7.5V22H9v-8.5ZM6.404 6 11 12.894V20h2v-7.106L17.596 6H6.404Z"})),n.createElement("defs",null,n.createElement("clipPath",{id:"filter-line_svg__a"},n.createElement("path",{d:"M0 0h24v24H0z"}))));function ie({sources:m,types:u,regions:x,countries:T,imageTypes:z,isLoadingFilters:s=!1}){const[h,_]=n.useState(!1),[S,p]=n.useState(""),{search:I,setSearch:g,srcFilter:E,setSrcFilter:v,catFilter:j,setCatFilter:f,regionFilter:y,setRegionFilter:C,countryFilter:k,setCountryFilter:N,imageTypeFilter:F,setImageTypeFilter:w,uploadTypeFilter:d,setUploadTypeFilter:a,generatedMethodFilter:r,setGeneratedMethodFilter:i,clearAllFilters:W}=O();return n.useEffect(()=>{p(I)},[I]),e.jsxs("div",{className:"mb-6 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsx(c,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:e.jsx(o,{name:"toggle-filters",variant:"secondary",onClick:()=>_(!h),className:"whitespace-nowrap",title:h?"Hide Filters":"Show Filters",children:e.jsx(q,{className:"w-4 h-4"})})}),e.jsx(c,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2 flex-1 min-w-[300px]",children:e.jsx(B,{name:"search",placeholder:"Search",value:S,onChange:l=>p(l||""),onKeyDown:l=>{l.key==="Enter"&&g(S)}})}),e.jsx(c,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:e.jsx(o,{name:"clear-filters",variant:"secondary",onClick:W,children:"Clear Filters"})})]}),h&&e.jsx("div",{className:"bg-white/20 backdrop-blur-sm rounded-md p-4",children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[e.jsx(c,{withInternalPadding:!0,className:"p-2",children:e.jsx(b,{name:"source",placeholder:s?"Loading...":"All Sources",options:m,value:E||null,onChange:l=>v(l||""),keySelector:l=>l.s_code,labelSelector:l=>l.label,required:!1,disabled:s})}),e.jsx(c,{withInternalPadding:!0,className:"p-2",children:e.jsx(b,{name:"category",placeholder:s?"Loading...":"All Categories",options:u,value:j||null,onChange:l=>f(l||""),keySelector:l=>l.t_code,labelSelector:l=>l.label,required:!1,disabled:s})}),e.jsx(c,{withInternalPadding:!0,className:"p-2",children:e.jsx(b,{name:"region",placeholder:s?"Loading...":"All Regions",options:x,value:y||null,onChange:l=>C(l||""),keySelector:l=>l.r_code,labelSelector:l=>l.label,required:!1,disabled:s})}),e.jsx(c,{withInternalPadding:!0,className:"p-2",children:e.jsx(G,{name:"country",placeholder:s?"Loading...":"All Countries",options:T,value:k?[k]:[],onChange:l=>N(l[0]||""),keySelector:l=>l.c_code,labelSelector:l=>l.label,disabled:s})}),e.jsx(c,{withInternalPadding:!0,className:"p-2",children:e.jsx(b,{name:"imageType",placeholder:s?"Loading...":"All Image Types",options:z,value:F||null,onChange:l=>w(l||""),keySelector:l=>l.image_type,labelSelector:l=>l.label,required:!1,disabled:s})}),e.jsx(c,{withInternalPadding:!0,className:"p-2",children:e.jsx(b,{name:"uploadType",placeholder:"All Upload Types",options:[{key:"single",label:"Single Upload"},{key:"multiple",label:"Multiple Upload"}],value:d||null,onChange:l=>a(l||""),keySelector:l=>l.key,labelSelector:l=>l.label,required:!1,disabled:!1})}),e.jsx(c,{withInternalPadding:!0,className:"p-2",children:e.jsx(b,{name:"generatedMethod",placeholder:"All Generated Methods",options:[{key:"manual",label:"Manual"},{key:"generated",label:"Generated"}],value:r||null,onChange:l=>i(l||""),keySelector:l=>l.key,labelSelector:l=>l.label,required:!1,disabled:!1})})]})})]})}const V="_fullSizeModalOverlay_cyz3b_1",D="_fullSizeModalContent_cyz3b_29",H="_ratingWarningContent_cyz3b_53",R="_ratingWarningTitle_cyz3b_65",U="_exportModeSection_cyz3b_133",Y="_splitConfigSection_cyz3b_143",Z="_splitConfigTitle_cyz3b_153",$="_splitInputsContainer_cyz3b_167",J="_splitInputGroup_cyz3b_183",K="_splitInputLabel_cyz3b_197",Q="_splitInput_cyz3b_167",X="_splitTotal_cyz3b_247",L="_splitTotalError_cyz3b_261",ee="_checkboxesContainer_cyz3b_271",le="_ratingWarningButtons_cyz3b_289",te="_singleExportMessage_cyz3b_309",ae="_navigateButtonContainer_cyz3b_333",se="_loadingOverlay_cyz3b_349",t={fullSizeModalOverlay:V,fullSizeModalContent:D,ratingWarningContent:H,ratingWarningTitle:R,exportModeSection:U,splitConfigSection:Y,splitConfigTitle:Z,splitInputsContainer:$,splitInputGroup:J,splitInputLabel:K,splitInput:Q,splitTotal:X,splitTotalError:L,checkboxesContainer:ee,ratingWarningButtons:le,singleExportMessage:te,navigateButtonContainer:ae,loadingOverlay:se};function re({isOpen:m,onClose:u,onExport:x,crisisMapsCount:T,droneImagesCount:z,isLoading:s=!1,exportSuccess:h=!1,variant:_="bulk",onNavigateAndExport:S}){const[p,I]=n.useState("standard"),[g,E]=n.useState(80),[v,j]=n.useState(10),[f,y]=n.useState(10),[C,k]=n.useState(!0),[N,F]=n.useState(!0),w=()=>{if(_==="single"){x(p,["crisis_map","drone_image"]);return}if(!C&&!N){alert("Please select at least one image type to export.");return}const a=[];C&&a.push("crisis_map"),N&&a.push("drone_image"),x(p,a)},d=()=>{u()};return m?_==="single"?e.jsx("div",{className:t.fullSizeModalOverlay,onClick:d,children:e.jsxs("div",{className:t.fullSizeModalContent,onClick:a=>a.stopPropagation(),children:[s&&e.jsx("div",{className:t.loadingOverlay,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(M,{className:"text-ifrcRed"}),e.jsx("div",{className:"text-lg font-medium",children:"Exporting..."}),e.jsx("div",{className:"text-sm text-gray-600",children:"This might take a few seconds"})]})}),h&&e.jsx("div",{className:t.loadingOverlay,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx("div",{className:"text-lg font-medium",children:"Export Successful!"}),e.jsx("div",{className:"text-sm text-gray-600",children:"Your dataset has been downloaded"}),e.jsx(o,{name:"close-export-success",onClick:d,className:"mt-4",children:"Close"})]})}),e.jsxs("div",{className:t.ratingWarningContent,children:[e.jsx("h3",{className:t.ratingWarningTitle,children:"Export Single Item"}),e.jsxs("div",{className:t.singleExportMessage,children:[e.jsx("p",{children:"This only exports the 1 item currently on display."}),e.jsx("p",{children:'You may export the entire dataset from the "list view" here:'})]}),e.jsx("div",{className:t.navigateButtonContainer,children:e.jsx(o,{name:"navigate-to-list",variant:"secondary",onClick:S,children:"Navigate to List View"})}),e.jsxs("div",{className:t.ratingWarningButtons,children:[e.jsx(o,{name:"continue-export",onClick:w,disabled:s,children:s?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M,{className:"text-white"}),"Exporting..."]}):"Continue"}),e.jsx(o,{name:"cancel-export",variant:"tertiary",onClick:d,disabled:s,children:"Cancel"})]})]})]})}):e.jsx("div",{className:t.fullSizeModalOverlay,onClick:d,children:e.jsxs("div",{className:t.fullSizeModalContent,onClick:a=>a.stopPropagation(),children:[s&&e.jsx("div",{className:t.loadingOverlay,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(M,{className:"text-ifrcRed"}),e.jsx("div",{className:"text-lg font-medium",children:"Exporting..."}),e.jsx("div",{className:"text-sm text-gray-600",children:"This might take a few seconds"})]})}),h&&e.jsx("div",{className:t.loadingOverlay,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx("div",{className:"text-lg font-medium",children:"Export Successful!"}),e.jsx("div",{className:"text-sm text-gray-600",children:"Your dataset has been downloaded"}),e.jsx(o,{name:"close-export-success",onClick:d,className:"mt-4",children:"Close"})]})}),e.jsxs("div",{className:t.ratingWarningContent,children:[e.jsx("h3",{className:t.ratingWarningTitle,children:"Export Dataset"}),e.jsx("div",{className:t.exportModeSection,children:e.jsx(A,{name:"export-mode",value:p,onChange:a=>{(a==="standard"||a==="fine-tuning")&&I(a)},options:[{key:"standard",label:"Standard"},{key:"fine-tuning",label:"Fine-tuning"}],keySelector:a=>a.key,labelSelector:a=>a.label,disabled:s})}),p==="fine-tuning"&&e.jsxs("div",{className:t.splitConfigSection,children:[e.jsx("div",{className:t.splitConfigTitle,children:"Dataset Split Configuration"}),e.jsxs("div",{className:t.splitInputsContainer,children:[e.jsxs("div",{className:t.splitInputGroup,children:[e.jsx("label",{htmlFor:"train-split",className:t.splitInputLabel,children:"Train (%)"}),e.jsx("input",{id:"train-split",type:"number",min:"0",max:"100",value:g,onChange:a=>{const r=parseInt(a.target.value)||0,i=100-r;i>=0&&(E(r),v+f>i&&(j(Math.floor(i/2)),y(i-Math.floor(i/2))))},className:t.splitInput,disabled:s})]}),e.jsxs("div",{className:t.splitInputGroup,children:[e.jsx("label",{htmlFor:"test-split",className:t.splitInputLabel,children:"Test (%)"}),e.jsx("input",{id:"test-split",type:"number",min:"0",max:"100",value:v,onChange:a=>{const r=parseInt(a.target.value)||0,i=100-g-r;i>=0&&(j(r),y(i))},className:t.splitInput,disabled:s})]}),e.jsxs("div",{className:t.splitInputGroup,children:[e.jsx("label",{htmlFor:"val-split",className:t.splitInputLabel,children:"Val (%)"}),e.jsx("input",{id:"val-split",type:"number",min:"0",max:"100",value:f,onChange:a=>{const r=parseInt(a.target.value)||0,i=100-g-r;i>=0&&(y(r),j(i))},className:t.splitInput,disabled:s})]})]}),g+v+f!==100&&e.jsx("div",{className:t.splitTotal,children:e.jsx("span",{className:t.splitTotalError,children:"Must equal 100%"})})]}),e.jsxs("div",{className:t.checkboxesContainer,children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(P,{name:"crisis-maps",label:`Crisis Maps (${T} images)`,value:C,onChange:a=>k(a),disabled:s})}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(P,{name:"drone-images",label:`Drone Images (${z} images)`,value:N,onChange:a=>F(a),disabled:s})})]}),e.jsxs("div",{className:t.ratingWarningButtons,children:[e.jsx(o,{name:"confirm-export",onClick:w,disabled:s,children:s?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M,{className:"text-white"}),"Exporting..."]}):"Export Selected"}),e.jsx(o,{name:"cancel-export",variant:"tertiary",onClick:d,disabled:s,children:"Cancel"})]})]})]})}):null}export{re as E,ie as F}; +import{r as n,D as O,j as e,z as c,n as o,O as B,J as b,P as G,_ as M,L as A,S as P}from"./index-C5rMGfs8.js";const q=({title:m,titleId:u,...x})=>n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em","aria-labelledby":u},x),m?n.createElement("title",{id:u},m):null,n.createElement("g",{clipPath:"url(#filter-line_svg__a)"},n.createElement("path",{d:"M9 13.5 4 6H3V4h18v2h-1l-5 7.5V22H9v-8.5ZM6.404 6 11 12.894V20h2v-7.106L17.596 6H6.404Z"})),n.createElement("defs",null,n.createElement("clipPath",{id:"filter-line_svg__a"},n.createElement("path",{d:"M0 0h24v24H0z"}))));function ie({sources:m,types:u,regions:x,countries:T,imageTypes:z,isLoadingFilters:s=!1}){const[h,_]=n.useState(!1),[S,p]=n.useState(""),{search:I,setSearch:g,srcFilter:E,setSrcFilter:v,catFilter:j,setCatFilter:f,regionFilter:y,setRegionFilter:C,countryFilter:k,setCountryFilter:N,imageTypeFilter:F,setImageTypeFilter:w,uploadTypeFilter:d,setUploadTypeFilter:a,generatedMethodFilter:r,setGeneratedMethodFilter:i,clearAllFilters:W}=O();return n.useEffect(()=>{p(I)},[I]),e.jsxs("div",{className:"mb-6 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsx(c,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:e.jsx(o,{name:"toggle-filters",variant:"secondary",onClick:()=>_(!h),className:"whitespace-nowrap",title:h?"Hide Filters":"Show Filters",children:e.jsx(q,{className:"w-4 h-4"})})}),e.jsx(c,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2 flex-1 min-w-[300px]",children:e.jsx(B,{name:"search",placeholder:"Search",value:S,onChange:l=>p(l||""),onKeyDown:l=>{l.key==="Enter"&&g(S)}})}),e.jsx(c,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:e.jsx(o,{name:"clear-filters",variant:"secondary",onClick:W,children:"Clear Filters"})})]}),h&&e.jsx("div",{className:"bg-white/20 backdrop-blur-sm rounded-md p-4",children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[e.jsx(c,{withInternalPadding:!0,className:"p-2",children:e.jsx(b,{name:"source",placeholder:s?"Loading...":"All Sources",options:m,value:E||null,onChange:l=>v(l||""),keySelector:l=>l.s_code,labelSelector:l=>l.label,required:!1,disabled:s})}),e.jsx(c,{withInternalPadding:!0,className:"p-2",children:e.jsx(b,{name:"category",placeholder:s?"Loading...":"All Categories",options:u,value:j||null,onChange:l=>f(l||""),keySelector:l=>l.t_code,labelSelector:l=>l.label,required:!1,disabled:s})}),e.jsx(c,{withInternalPadding:!0,className:"p-2",children:e.jsx(b,{name:"region",placeholder:s?"Loading...":"All Regions",options:x,value:y||null,onChange:l=>C(l||""),keySelector:l=>l.r_code,labelSelector:l=>l.label,required:!1,disabled:s})}),e.jsx(c,{withInternalPadding:!0,className:"p-2",children:e.jsx(G,{name:"country",placeholder:s?"Loading...":"All Countries",options:T,value:k?[k]:[],onChange:l=>N(l[0]||""),keySelector:l=>l.c_code,labelSelector:l=>l.label,disabled:s})}),e.jsx(c,{withInternalPadding:!0,className:"p-2",children:e.jsx(b,{name:"imageType",placeholder:s?"Loading...":"All Image Types",options:z,value:F||null,onChange:l=>w(l||""),keySelector:l=>l.image_type,labelSelector:l=>l.label,required:!1,disabled:s})}),e.jsx(c,{withInternalPadding:!0,className:"p-2",children:e.jsx(b,{name:"uploadType",placeholder:"All Upload Types",options:[{key:"single",label:"Single Upload"},{key:"multiple",label:"Multiple Upload"}],value:d||null,onChange:l=>a(l||""),keySelector:l=>l.key,labelSelector:l=>l.label,required:!1,disabled:!1})}),e.jsx(c,{withInternalPadding:!0,className:"p-2",children:e.jsx(b,{name:"generatedMethod",placeholder:"All Generated Methods",options:[{key:"manual",label:"Manual"},{key:"generated",label:"Generated"}],value:r||null,onChange:l=>i(l||""),keySelector:l=>l.key,labelSelector:l=>l.label,required:!1,disabled:!1})})]})})]})}const V="_fullSizeModalOverlay_cyz3b_1",D="_fullSizeModalContent_cyz3b_29",H="_ratingWarningContent_cyz3b_53",R="_ratingWarningTitle_cyz3b_65",U="_exportModeSection_cyz3b_133",Y="_splitConfigSection_cyz3b_143",Z="_splitConfigTitle_cyz3b_153",$="_splitInputsContainer_cyz3b_167",J="_splitInputGroup_cyz3b_183",K="_splitInputLabel_cyz3b_197",Q="_splitInput_cyz3b_167",X="_splitTotal_cyz3b_247",L="_splitTotalError_cyz3b_261",ee="_checkboxesContainer_cyz3b_271",le="_ratingWarningButtons_cyz3b_289",te="_singleExportMessage_cyz3b_309",ae="_navigateButtonContainer_cyz3b_333",se="_loadingOverlay_cyz3b_349",t={fullSizeModalOverlay:V,fullSizeModalContent:D,ratingWarningContent:H,ratingWarningTitle:R,exportModeSection:U,splitConfigSection:Y,splitConfigTitle:Z,splitInputsContainer:$,splitInputGroup:J,splitInputLabel:K,splitInput:Q,splitTotal:X,splitTotalError:L,checkboxesContainer:ee,ratingWarningButtons:le,singleExportMessage:te,navigateButtonContainer:ae,loadingOverlay:se};function re({isOpen:m,onClose:u,onExport:x,crisisMapsCount:T,droneImagesCount:z,isLoading:s=!1,exportSuccess:h=!1,variant:_="bulk",onNavigateAndExport:S}){const[p,I]=n.useState("standard"),[g,E]=n.useState(80),[v,j]=n.useState(10),[f,y]=n.useState(10),[C,k]=n.useState(!0),[N,F]=n.useState(!0),w=()=>{if(_==="single"){x(p,["crisis_map","drone_image"]);return}if(!C&&!N){alert("Please select at least one image type to export.");return}const a=[];C&&a.push("crisis_map"),N&&a.push("drone_image"),x(p,a)},d=()=>{u()};return m?_==="single"?e.jsx("div",{className:t.fullSizeModalOverlay,onClick:d,children:e.jsxs("div",{className:t.fullSizeModalContent,onClick:a=>a.stopPropagation(),children:[s&&e.jsx("div",{className:t.loadingOverlay,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(M,{className:"text-ifrcRed"}),e.jsx("div",{className:"text-lg font-medium",children:"Exporting..."}),e.jsx("div",{className:"text-sm text-gray-600",children:"This might take a few seconds"})]})}),h&&e.jsx("div",{className:t.loadingOverlay,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx("div",{className:"text-lg font-medium",children:"Export Successful!"}),e.jsx("div",{className:"text-sm text-gray-600",children:"Your dataset has been downloaded"}),e.jsx(o,{name:"close-export-success",onClick:d,className:"mt-4",children:"Close"})]})}),e.jsxs("div",{className:t.ratingWarningContent,children:[e.jsx("h3",{className:t.ratingWarningTitle,children:"Export Single Item"}),e.jsxs("div",{className:t.singleExportMessage,children:[e.jsx("p",{children:"This only exports the 1 item currently on display."}),e.jsx("p",{children:'You may export the entire dataset from the "list view" here:'})]}),e.jsx("div",{className:t.navigateButtonContainer,children:e.jsx(o,{name:"navigate-to-list",variant:"secondary",onClick:S,children:"Navigate to List View"})}),e.jsxs("div",{className:t.ratingWarningButtons,children:[e.jsx(o,{name:"continue-export",onClick:w,disabled:s,children:s?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M,{className:"text-white"}),"Exporting..."]}):"Continue"}),e.jsx(o,{name:"cancel-export",variant:"tertiary",onClick:d,disabled:s,children:"Cancel"})]})]})]})}):e.jsx("div",{className:t.fullSizeModalOverlay,onClick:d,children:e.jsxs("div",{className:t.fullSizeModalContent,onClick:a=>a.stopPropagation(),children:[s&&e.jsx("div",{className:t.loadingOverlay,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(M,{className:"text-ifrcRed"}),e.jsx("div",{className:"text-lg font-medium",children:"Exporting..."}),e.jsx("div",{className:"text-sm text-gray-600",children:"This might take a few seconds"})]})}),h&&e.jsx("div",{className:t.loadingOverlay,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx("div",{className:"text-lg font-medium",children:"Export Successful!"}),e.jsx("div",{className:"text-sm text-gray-600",children:"Your dataset has been downloaded"}),e.jsx(o,{name:"close-export-success",onClick:d,className:"mt-4",children:"Close"})]})}),e.jsxs("div",{className:t.ratingWarningContent,children:[e.jsx("h3",{className:t.ratingWarningTitle,children:"Export Dataset"}),e.jsx("div",{className:t.exportModeSection,children:e.jsx(A,{name:"export-mode",value:p,onChange:a=>{(a==="standard"||a==="fine-tuning")&&I(a)},options:[{key:"standard",label:"Standard"},{key:"fine-tuning",label:"Fine-tuning"}],keySelector:a=>a.key,labelSelector:a=>a.label,disabled:s})}),p==="fine-tuning"&&e.jsxs("div",{className:t.splitConfigSection,children:[e.jsx("div",{className:t.splitConfigTitle,children:"Dataset Split Configuration"}),e.jsxs("div",{className:t.splitInputsContainer,children:[e.jsxs("div",{className:t.splitInputGroup,children:[e.jsx("label",{htmlFor:"train-split",className:t.splitInputLabel,children:"Train (%)"}),e.jsx("input",{id:"train-split",type:"number",min:"0",max:"100",value:g,onChange:a=>{const r=parseInt(a.target.value)||0,i=100-r;i>=0&&(E(r),v+f>i&&(j(Math.floor(i/2)),y(i-Math.floor(i/2))))},className:t.splitInput,disabled:s})]}),e.jsxs("div",{className:t.splitInputGroup,children:[e.jsx("label",{htmlFor:"test-split",className:t.splitInputLabel,children:"Test (%)"}),e.jsx("input",{id:"test-split",type:"number",min:"0",max:"100",value:v,onChange:a=>{const r=parseInt(a.target.value)||0,i=100-g-r;i>=0&&(j(r),y(i))},className:t.splitInput,disabled:s})]}),e.jsxs("div",{className:t.splitInputGroup,children:[e.jsx("label",{htmlFor:"val-split",className:t.splitInputLabel,children:"Val (%)"}),e.jsx("input",{id:"val-split",type:"number",min:"0",max:"100",value:f,onChange:a=>{const r=parseInt(a.target.value)||0,i=100-g-r;i>=0&&(y(r),j(i))},className:t.splitInput,disabled:s})]})]}),g+v+f!==100&&e.jsx("div",{className:t.splitTotal,children:e.jsx("span",{className:t.splitTotalError,children:"Must equal 100%"})})]}),e.jsxs("div",{className:t.checkboxesContainer,children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(P,{name:"crisis-maps",label:`Crisis Maps (${T} images)`,value:C,onChange:a=>k(a),disabled:s})}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(P,{name:"drone-images",label:`Drone Images (${z} images)`,value:N,onChange:a=>F(a),disabled:s})})]}),e.jsxs("div",{className:t.ratingWarningButtons,children:[e.jsx(o,{name:"confirm-export",onClick:w,disabled:s,children:s?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M,{className:"text-white"}),"Exporting..."]}):"Export Selected"}),e.jsx(o,{name:"cancel-export",variant:"tertiary",onClick:d,disabled:s,children:"Cancel"})]})]})]})}):null}export{re as E,ie as F}; diff --git a/py_backend/static/assets/index-DRmfVC9B.js b/py_backend/static/assets/index-C5czLj7d.js similarity index 99% rename from py_backend/static/assets/index-DRmfVC9B.js rename to py_backend/static/assets/index-C5czLj7d.js index 0e6ad340..bcc5fcf9 100644 --- a/py_backend/static/assets/index-DRmfVC9B.js +++ b/py_backend/static/assets/index-C5czLj7d.js @@ -1 +1 @@ -import{r as n,y as nt,t as ht,a as q,c as gt,j as e,o as N,b as re,R as st,z,g as rt,d as ft,m as vt,e as pt,n as Z,A as xt,f as _t,h as Ct,i as yt,k as he,l as bt,p as ye,q as jt,s as Nt,E as wt,C as St,U as Mt,Q as It,u as Dt,N as je,_ as Et,L as Tt}from"./index-Dym8TuvV.js";const kt=({title:m,titleId:a,...h})=>n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em","aria-labelledby":a},h),m?n.createElement("title",{id:a},m):null,n.createElement("g",{clipPath:"url(#arrow-drop-down-line_svg__a)"},n.createElement("path",{d:"m12 15-4.243-4.243 1.415-1.414L12 12.172l2.828-2.83 1.415 1.415L12 15Z"})),n.createElement("defs",null,n.createElement("clipPath",{id:"arrow-drop-down-line_svg__a"},n.createElement("path",{d:"M0 0h24v24H0z"})))),Lt=({title:m,titleId:a,...h})=>n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em","aria-labelledby":a},h),m?n.createElement("title",{id:a},m):null,n.createElement("g",{clipPath:"url(#arrow-drop-up-line_svg__a)"},n.createElement("path",{d:"m12 11.828-2.828 2.829-1.415-1.414L12 9l4.243 4.243-1.415 1.414L12 11.828Z"})),n.createElement("defs",null,n.createElement("clipPath",{id:"arrow-drop-up-line_svg__a"},n.createElement("path",{d:"M0 0h24v24H0z"})))),Pt=({title:m,titleId:a,...h})=>n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em","aria-labelledby":a},h),m?n.createElement("title",{id:a},m):null,n.createElement("g",{clipPath:"url(#information-line_svg__a)"},n.createElement("path",{d:"M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10Zm0-2a8 8 0 1 0 0-16.001A8 8 0 0 0 12 20ZM11 7h2v2h-2V7Zm0 4h2v6h-2v-6Z"})),n.createElement("defs",null,n.createElement("clipPath",{id:"information-line_svg__a"},n.createElement("path",{d:"M0 0h24v24H0z"})))),Rt=({title:m,titleId:a,...h})=>n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em","aria-labelledby":a},h),m?n.createElement("title",{id:a},m):null,n.createElement("path",{fillRule:"evenodd",d:"m15.063 12 .937.938-4 4-4-4L8.938 12 12 15.063 15.063 12Z",clipRule:"evenodd"}),n.createElement("mask",{id:"table-sorting-line_svg__a",width:8,height:5,x:8,y:12,maskUnits:"userSpaceOnUse",style:{maskType:"luminance"}},n.createElement("path",{fillRule:"evenodd",d:"m15.063 12 .937.938-4 4-4-4L8.938 12 12 15.063 15.063 12Z",clipRule:"evenodd"})),n.createElement("g",{mask:"url(#table-sorting-line_svg__a)"},n.createElement("path",{d:"M-24-22h72v72h-72z"})),n.createElement("path",{fillRule:"evenodd",d:"M8.938 11 8 10.062l4-4 4 4-.938.938L12 7.937 8.937 11Z",clipRule:"evenodd"}),n.createElement("mask",{id:"table-sorting-line_svg__b",width:8,height:5,x:8,y:6,maskUnits:"userSpaceOnUse",style:{maskType:"luminance"}},n.createElement("path",{fillRule:"evenodd",d:"M8.938 11 8 10.062l4-4 4 4-.938.938L12 7.937 8.937 11Z",clipRule:"evenodd"})),n.createElement("g",{mask:"url(#table-sorting-line_svg__b)"},n.createElement("path",{d:"M48 45h-72v-72h72z"}))),$t="_number-output_1blvi_1",Bt={numberOutput:$t};function we(m){const{className:a,invalidText:h=nt,separatorHidden:o,compact:f,currency:g,value:b,tooltip:_,unit:y,prefix:x,suffix:w,maximumFractionDigits:C=1}=m,{currentLanguage:j}=n.useContext(ht),v=n.useMemo(()=>{if(q(b))return h;const S=gt(b,{currency:g,compact:f,separatorHidden:o,maximumFractionDigits:C,unit:y,language:j});return e.jsxs(e.Fragment,{children:[x,S,w]})},[h,b,f,o,g,y,C,x,j,w]);return e.jsx("div",{className:N(Bt.numberOutput,a),title:re(_)?String(_):void 0,children:v})}const At="_tooltip-dummy_rbf3f_1",Ft="_tooltip-content_rbf3f_7",Ot="_pointer_rbf3f_14",Ne={tooltipDummy:At,tooltipContent:Ft,pointer:Ot};function Ht(m){const{className:a,title:h,description:o,preferredWidth:f}=m,[g,b]=n.useState(!1),[_,y]=n.useState(!1),x=n.useRef(),w=n.useRef(null);return n.useEffect(()=>{const C=()=>{y(!0)},j=()=>{y(!1)};if(q(w.current))return;const{current:{parentNode:v}}=w;if(!q(v))return x.current=v,v.addEventListener("mouseover",C),v.addEventListener("mouseout",j),b(!0),()=>{v.removeEventListener("mouseover",C),v.removeEventListener("mouseout",j)}},[]),e.jsxs(e.Fragment,{children:[!g&&e.jsx("div",{className:Ne.tooltipDummy,ref:w}),_&&e.jsx(st,{className:N(Ne.tooltipContent,a),parentRef:x,pointerClassName:Ne.pointer,preferredWidth:f,children:e.jsx(z,{heading:h,withInternalPadding:!0,contentViewType:"vertical",children:o})})]})}function B(m){return m.id}const Vt="common",zt={booleanYesLabel:"Yes",booleanNoLabel:"No"},Ut={namespace:Vt,strings:zt},Wt="_boolean-output_kg1uq_1",Qt={booleanOutput:Wt};function Zt(m){const{className:a,invalidText:h,value:o}=m,f=rt(Ut);let g;return o===!0?g=f.booleanYesLabel:o===!1?g=f.booleanNoLabel:g=h,e.jsx("div",{className:N(Qt.booleanOutput,a),children:g})}const qt="_date-output_4jzjo_1",Gt={dateOutput:qt};function Yt(m){const{value:a,format:h,className:o,invalidText:f}=m,g=n.useMemo(()=>ft(a,h),[a,h]);return e.jsx("div",{className:N(Gt.dateOutput,o),children:g??f})}const Kt="_dropdown-menu_16hml_1",Xt="_icons_16hml_4",Jt="_content_16hml_5",ea="_actions_16hml_6",ta="_dropdown-icon_16hml_10",aa="_dropdown-content_16hml_16",le={dropdownMenu:Kt,icons:Xt,content:Jt,actions:ea,dropdownIcon:ta,dropdownContent:aa};function na(m){const a=n.useRef(null),{className:h,popupClassName:o,children:f,label:g,activeClassName:b,icons:_,variant:y="secondary",actions:x,withoutDropdownIcon:w,componentRef:C,elementRef:j=a,persistent:v,preferredPopupWidth:S}=m,p=n.useRef(null),[L,I]=n.useState(!1);n.useEffect(()=>{C&&(C.current={setShowDropdown:I})},[C,I]);const R=n.useCallback(()=>{I(ie=>!ie)},[I]),k=n.useCallback((ie,ae)=>{ae||ie&&v||I(!1)},[I,v]);vt(L,k,p,j);const G=n.useMemo(()=>({setShowDropdown:I}),[I]),U=!!x||!w;return e.jsxs(pt.Provider,{value:G,children:[e.jsx(Z,{name:void 0,className:N(le.dropdownMenu,L&&b,h),elementRef:j,onClick:R,variant:y,actionsContainerClassName:le.actions,iconsContainerClassName:le.icons,childrenContainerClassName:le.content,actions:U?e.jsxs(e.Fragment,{children:[x,!w&&(L?e.jsx(xt,{className:le.dropdownIcon}):e.jsx(_t,{className:le.dropdownIcon}))]}):void 0,icons:_,children:g}),L&&e.jsx(st,{elementRef:p,className:N(le.dropdownContent,o),parentRef:j,preferredWidth:S,children:f})]})}const sa="_info-popup_i3rna_1",ra="_label_i3rna_2",ia="_icon_i3rna_7",oa="_dropdown-container_i3rna_15",la="_content_i3rna_20",ge={infoPopup:sa,label:ra,icon:ia,dropdownContainer:oa,content:la};function ca(m){const{className:a,icon:h=e.jsx(Pt,{}),infoLabel:o,title:f,description:g,withoutIcon:b,popupClassName:_,descriptionClassName:y}=m;return e.jsx(na,{label:e.jsxs("div",{className:ge.label,children:[o,!b&&h&&e.jsx("div",{className:ge.icon,children:h})]}),popupClassName:N(ge.dropdownContainer,_),className:N(ge.infoPopup,a),variant:"tertiary",withoutDropdownIcon:!0,children:e.jsx(z,{heading:f,childrenContainerClassName:N(y,ge.content),withInternalPadding:!0,children:g})})}const da="_progress-wrapper_x340w_1",ua="_title_x340w_7",ma="_total_x340w_11",ha="_progress_x340w_1",fe={progressWrapper:da,title:ua,total:ma,progress:ha};function Ye(m){const{className:a,title:h,description:o,totalValue:f,value:g,showPercentageInTitle:b,children:_,color:y="var(--go-ui-color-primary-red)"}=m,x=re(g)?g:0,w=re(f)?f:0;let C;return w===0?C=0:C=x/w*100,e.jsxs("div",{className:N(fe.progressWrapper,a),children:[(h||b)&&e.jsxs("div",{className:fe.title,children:[h,b&&e.jsx(we,{value:C,suffix:"%"})]}),e.jsx("div",{className:fe.total,children:e.jsx("div",{className:fe.progress,style:{width:`${C}%`,backgroundColor:y}})}),o&&e.jsx("div",{className:fe.description,children:o}),_]})}const ga="_legend-element_1a9ic_1",fa="_color_1a9ic_7",va="_icon-container_1a9ic_14",pa="_icon_1a9ic_14",xa="_label_1a9ic_31",ve={legendElement:ga,color:fa,iconContainer:va,icon:pa,label:xa};function _a(m){const{className:a,colorClassName:h,iconClassName:o,color:f,label:g,iconSrc:b}=m;return e.jsxs("div",{className:N(ve.legendElement,a),children:[b?e.jsx("div",{style:{backgroundColor:f},className:ve.iconContainer,children:e.jsx("img",{className:N(ve.icon,o),src:b,alt:""})}):e.jsx("div",{style:{backgroundColor:f},className:N(ve.color,h)}),e.jsx("div",{className:ve.label,children:g})]})}const Ca="_text-output_10oza_1",ya="_with-background_10oza_6",ba="_label_10oza_11",ja="_with-colon_10oza_12",Na="_value_10oza_17",wa="_text-type_10oza_18",Sa="_strong_10oza_24",ee={textOutput:Ca,withBackground:ya,label:ba,withColon:ja,value:Na,textType:wa,strong:Sa};function Ke(m){const{className:a,label:h,icon:o,description:f,labelClassName:g,descriptionClassName:b,valueClassName:_,strongLabel:y,strongValue:x,strongDescription:w,withoutLabelColon:C,withBackground:j,invalidText:v=nt,...S}=m,{value:p}=m;let L=v;return S.valueType==="number"?L=e.jsx(we,{...S,invalidText:v}):S.valueType==="date"?L=e.jsx(Yt,{...S,invalidText:v}):S.valueType==="boolean"?L=e.jsx(Zt,{...S,invalidText:v}):p instanceof Date||(L=p||v),e.jsxs("div",{className:N(ee.textOutput,j&&ee.withBackground,a),children:[o,h&&e.jsx("div",{className:N(ee.label,y&&ee.strong,g,!C&&ee.withColon),children:h}),e.jsx("div",{className:N(ee.value,x&&ee.strong,S.valueType==="text"&&ee.textType,_),children:L}),f&&e.jsx("div",{className:N(ee.description,w&&ee.strong,b),children:f})]})}const Ma="_pie-chart_pyr7m_1",Ia="_legend_pyr7m_7",Da="_legend-item_pyr7m_13",pe={pieChart:Ma,legend:Ia,legendItem:Da},Ea=70,Ta=40;function Xe(m,a=1){return Math.round(m*10**a)/10**a}function Je(m,a){const h=(a-90)*Math.PI/180;return{x:Xe(m+m*Math.cos(h)),y:Xe(m+m*Math.sin(h))}}function ka(m,a,h){let o=h;const f=o-a===360;f&&(o-=1);const g=Je(m,a),b=Je(m,o),_=o-a<=180?0:1,y=["M",g.x,g.y,"A",m,m,0,_,1,b.x,b.y];return f?y.push("Z"):y.push("L",m,m,"L",g.x,g.y,"Z"),y.join(" ")}function xe(m){const{className:a,data:h,valueSelector:o,labelSelector:f,keySelector:g,colorSelector:b,colors:_,pieRadius:y=Ea,chartPadding:x=Ta,legendClassName:w,showPercentageInLegend:C}=m,j=Ct(h?.map(p=>o(p))),v=q(j)||j===0?1:j,S=n.useMemo(()=>{let p=0;const L=h?.map(I=>{const R=o(I);if(q(R))return;const k=360*(R/v);return p+=k,{key:g(I),value:R,label:f(I),startAngle:p-k,percentage:yt(R,v),endAngle:p,datum:I}}).filter(re)??[];return b?L.map(({datum:I,...R})=>({...R,color:b(I)})):L.map(({datum:I,...R},k)=>({...R,color:_[k%_.length]}))},[h,g,o,f,v,b,_]);return e.jsxs("div",{className:N(pe.pieChart,a),children:[e.jsx("svg",{className:pe.svg,style:{width:`${x+y*2}px`,height:`${x+y*2}px`},children:e.jsx("g",{style:{transform:`translate(${x/2}px, ${x/2}px)`},children:S.map(p=>e.jsx("path",{className:pe.path,d:ka(y,p.startAngle,p.endAngle),fill:p.color,children:e.jsx(Ht,{description:e.jsx(Ke,{label:p.label,value:p.value})})},p.key))})}),e.jsx("div",{className:N(pe.legend,w),children:S.map(p=>e.jsx(_a,{className:pe.legendItem,label:C?e.jsx(Ke,{label:p.label,value:p.percentage,valueType:"number",prefix:"(",suffix:"%)",withoutLabelColon:!0}):p.label,color:p.color},p.key))})]})}const La="_td_1k4cn_1",Pa={td:La};function Ra(m){const{className:a,children:h,...o}=m;return e.jsx("td",{className:N(a,Pa.td),...o,children:h})}function it(m){const{className:a,children:h,...o}=m;return e.jsx("tr",{className:a,...o,children:h})}const $a="_row_1829z_1",Ba="_cell_1829z_2",et={row:$a,cell:Ba};function Aa(m){const{data:a,keySelector:h,columns:o,rowClassName:f,cellClassName:g,rowModifier:b}=m;return e.jsx(e.Fragment,{children:a?.map((_,y)=>{const x=h(_,y),w=o.map(v=>{const{id:S,cellRenderer:p,cellRendererClassName:L,cellRendererParams:I,cellContainerClassName:R}=v,k=I(x,_,y,a),G=e.jsx(p,{className:L,...k,name:S});return e.jsx(Ra,{className:N(et.cell,R,typeof g=="function"?g(x,_,S):g),children:G},S)}),C=e.jsx(it,{className:N(et.row,typeof f=="function"?f(x,_):f),children:w});let j=C;return b&&(j=b({rowKey:x,row:C,cells:w,columns:o,datum:_})),e.jsx(n.Fragment,{children:j},x)})})}const Fa="_th_cdv41_1",Oa="_resize-handle_cdv41_8",tt={th:Fa,resizeHandle:Oa};function Ha(m){const{className:a,children:h,onResize:o,onResizeComplete:f,name:g,...b}=m,_=n.useRef(null),y=n.useRef(),x=n.useRef(),w=n.useRef(),C=n.useCallback(v=>{var S;if(re(y.current)&&_.current&&o){v.preventDefault(),v.stopPropagation();const p=v.clientX-y.current;if(re(x.current)){const L=x.current+p;w.current=L,o(L,g)}else x.current=(S=_.current)==null?void 0:S.offsetWidth}},[o,g]),j=n.useCallback(v=>{var S;v.preventDefault(),y.current=v.clientX,x.current=(S=_.current)==null?void 0:S.offsetWidth,window.addEventListener("mousemove",C,!0)},[C]);return n.useEffect(()=>{const v=()=>{y.current=void 0,x.current=void 0,f&&re(w.current)&&f(w.current,g),window.removeEventListener("mousemove",C,!0)};return window.addEventListener("mouseup",v,!0),()=>{window.removeEventListener("mouseup",v,!0),window.removeEventListener("mousemove",C,!0)}},[C,g,f]),e.jsxs("th",{ref:_,className:N(a,tt.th),...b,children:[o&&e.jsx("div",{role:"presentation",className:tt.resizeHandle,onMouseDown:j}),h]})}const Va="_table_nilhy_1",za="_table-overflow-wrapper_nilhy_8",Ua="_table-element_nilhy_13",Wa="_header-row_nilhy_23",Qa="_header-element_nilhy_24",Za="_header-component_nilhy_29",ce={table:Va,tableOverflowWrapper:za,tableElement:Ua,headerRow:Wa,headerElement:Qa,headerComponent:Za};function qa(m,a){return a??m.columnWidth??wt}function A(m){const{data:a,keySelector:h,columns:o,caption:f,className:g,captionClassName:b,headerRowClassName:_,headerCellClassName:y,rowClassName:x,cellClassName:w,rowModifier:C,fixedColumnWidth:j,resizableColumn:v,headersHidden:S,pending:p,filtered:L,errored:I=!1}=m,R=n.useRef(null),[k]=he.useState(()=>bt()),[G,U]=he.useState({});n.useEffect(()=>{U(W=>{if(q(R.current))return W;const T=R.current.getBoundingClientRect(),{width:O}=T;let F=o.map(M=>({id:M.id,stretch:!!M.columnStretch,width:qa(M,W[M.id])}));const X=ye(F.filter(M=>M.stretch).map(M=>M.width)),ne=ye(F.filter(M=>!M.stretch).map(M=>M.width)),Y=(O-ne)/X;return Y>1&&(F=F.map(M=>({...M,width:M.stretch?M.width*Y:M.width}))),jt(F,M=>M.id,M=>M.width)})},[o]);const ie=he.useCallback((W,T)=>{const O=document.getElementById(`${k}-${T}`),F=Math.max(W,80);if(q(O)||(O.style.width=`${F}px`,!j))return;const X=document.getElementById(k);if(q(X))return;const ne=ye(o.map(Y=>Y.id===T?F:G[Y.id]));X.style.width=`${ne}px`},[k,G,o,j]),ae=he.useCallback((W,T)=>{re(T)&&U(O=>({...O,[T]:Math.max(W,80)}))},[U]),be=he.useMemo(()=>ye(o.map(W=>G[W.id])),[G,o]),K=q(a)||a.length===0||Object.keys(G).length===0;return e.jsxs("div",{ref:R,className:N(ce.table,g),children:[!K&&e.jsx("div",{className:ce.tableOverflowWrapper,children:e.jsxs("table",{className:ce.tableElement,style:j?{width:`${be}px`}:void 0,id:k,children:[f&&e.jsx("caption",{className:b,children:f}),e.jsx("colgroup",{children:o.map(W=>{const{id:T,columnClassName:O}=W,F=G[T],X=j?{width:`${F}px`}:void 0;return e.jsx("col",{id:`${k}-${T}`,style:X,className:N(ce.column,O)},T)})}),!S&&e.jsx("thead",{children:e.jsx(it,{className:N(ce.headerRow,_),children:o.map((W,T)=>{const{id:O,title:F,headerCellRenderer:X,headerCellRendererClassName:ne,headerCellRendererParams:Y,headerContainerClassName:M}=W,se=e.jsx(X,{...Y,name:O,title:F,index:T,className:N(ne,ce.headerComponent)});return e.jsx(Ha,{scope:"col",name:O,onResize:v?ie:void 0,onResizeComplete:v?ae:void 0,className:N(ce.headerElement,typeof y=="function"?y(O):y,M),children:se},O)})})}),e.jsx("tbody",{children:e.jsx(Aa,{data:a,keySelector:h,columns:o,rowClassName:x,cellClassName:w,rowModifier:C})})]})}),e.jsx(Nt,{filtered:L,empty:K,errored:I,pending:p,overlayPending:!0})]})}function Ga(m){const{className:a,value:h}=m;return q(h)?null:e.jsx("div",{className:a,children:h})}const Ya="common",Ka={sortTableButtonTitle:"Sort Table"},Xa={namespace:Ya,strings:Ka},Ja="_header-cell_vn24d_1",en="_sort-button_vn24d_8",tn="_icon_vn24d_12",an="_info-popup-icon_vn24d_17",de={headerCell:Ja,sortButton:en,icon:tn,infoPopupIcon:an};function ot(m){const{className:a,titleClassName:h,title:o,name:f,sortable:g,defaultSortDirection:b="asc",infoTitle:_,infoDescription:y}=m,{sorting:x,setSorting:w}=n.useContext(St),C=rt(Xa),j=x?.name===f?x.direction:void 0,v=n.useRef(null),S=n.useCallback(()=>{if(q(w))return;let p;q(j)?p=b:j==="asc"?p="dsc":j==="dsc"&&(p="asc"),w(p?{name:f,direction:p}:void 0)},[f,w,j,b]);return e.jsxs("div",{ref:v,className:N(a,de.headerCell),children:[g&&e.jsxs(Z,{name:void 0,variant:"tertiary",onClick:S,title:C.sortTableButtonTitle,className:de.sortButton,children:[q(j)&&e.jsx(Rt,{className:de.icon}),j==="asc"&&e.jsx(Lt,{className:de.icon}),j==="dsc"&&e.jsx(kt,{className:de.icon})]}),e.jsx("div",{className:N(h,de.title),children:o}),_&&y&&e.jsx(ca,{className:de.infoPopupIcon,title:_,description:y})]})}const at={};function Q(m,a,h,o){return{id:m,title:a,columnClassName:o?.columnClassName,headerCellRenderer:ot,headerCellRendererClassName:o?.headerCellRendererClassName,headerContainerClassName:o?.headerContainerClassName,headerCellRendererParams:{sortable:o?.sortable,infoTitle:o?.headerInfoTitle,infoDescription:o?.headerInfoDescription},cellRendererClassName:o?.cellRendererClassName,cellContainerClassName:o?.cellContainerClassName,cellRenderer:Ga,cellRendererParams:(f,g)=>({value:h(g)||"--"}),valueSelector:h,valueComparator:(f,g)=>Mt(h(f),h(g)),columnWidth:o?.columnWidth,columnStretch:o?.columnStretch,columnStyle:o?.columnStyle}}function E(m,a,h,o){return{id:m,title:a,columnClassName:o?.columnClassName,headerCellRenderer:ot,headerCellRendererClassName:N(at.numberCellHeader,o?.headerCellRendererClassName),headerContainerClassName:o?.headerContainerClassName,headerCellRendererParams:{sortable:o?.sortable,infoTitle:o?.headerInfoTitle,infoDescription:o?.headerInfoDescription},cellRendererClassName:N(at.numberCell,o?.cellRendererClassName),cellContainerClassName:o?.cellContainerClassName,cellRenderer:we,cellRendererParams:(f,g)=>({value:h(g),suffix:o?.suffix,maximumFractionDigits:o?.maximumFractionDigits,invalidText:"--"}),valueSelector:h,valueComparator:(f,g)=>It(h(f),h(g)),columnWidth:o?.columnWidth,columnStretch:o?.columnStretch,columnStyle:o?.columnStyle}}const nn="_tabSelector_vlxoe_1",sn="_progressSection_vlxoe_14",rn="_progressLabel_vlxoe_20",on="_chartGrid_vlxoe_28",ln="_chartContainer_vlxoe_40",cn="_tableContainer_vlxoe_51",dn="_modelPerformance_vlxoe_59",un="_loadingContainer_vlxoe_67",mn="_errorContainer_vlxoe_77",hn="_userInteractionCards_vlxoe_96",gn="_userInteractionCard_vlxoe_96",fn="_userInteractionCardValue_vlxoe_116",vn="_userInteractionCardLabel_vlxoe_123",pn="_userInteractionCardButton_vlxoe_130",xn="_summaryStatsCards_vlxoe_148",_n="_summaryStatsCard_vlxoe_148",Cn="_summaryStatsCardValue_vlxoe_169",yn="_summaryStatsCardLabel_vlxoe_176",l={tabSelector:nn,progressSection:sn,progressLabel:rn,chartGrid:on,chartContainer:ln,tableContainer:cn,modelPerformance:dn,loadingContainer:un,errorContainer:mn,userInteractionCards:hn,userInteractionCard:gn,userInteractionCardValue:fn,userInteractionCardLabel:vn,userInteractionCardButton:pn,summaryStatsCards:xn,summaryStatsCard:_n,summaryStatsCardValue:Cn,summaryStatsCardLabel:yn};function jn(){const[m]=Dt(),[a,h]=n.useState(null),[o,f]=n.useState(!0),[g,b]=n.useState("crisis_maps"),[_,y]=n.useState([]),[x,w]=n.useState([]),[C,j]=n.useState([]),[v,S]=n.useState([]),[p,L]=n.useState(!1),[I,R]=n.useState(!1),[k,G]=n.useState(!1),[U,ie]=n.useState(!1),[ae,be]=n.useState(!1),[K,W]=n.useState(!1),T=t=>{L(t==="editTime"),R(t==="percentage"),G(t==="delete"),ie(t==="regions"),be(t==="sources"),W(t==="types")},O=[{key:"crisis_maps",label:"Crisis Maps"},{key:"drone_images",label:"Drone Images"}],F=n.useCallback((t,c)=>{if(!t||!c)return 0;const d=t.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(u=>u.length>0),r=c.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(u=>u.length>0);if(d.length===0&&r.length===0)return 1;if(d.length===0||r.length===0)return 0;const s=new Set(d),i=new Set(r),D=new Set([...s].filter(u=>i.has(u))),$=new Set([...s,...i]);return D.size/$.size},[]),X=n.useCallback(async()=>{f(!0);try{const c=await(await fetch("/api/images")).json(),d={},r=c.filter(u=>u.image_type==="crisis_map"),s=c.filter(u=>u.image_type==="drone_image"),i={totalCaptions:c.length,sources:{},types:{},regions:{},models:{},modelEditTimes:d,percentageModified:0,modelPercentageData:{},totalDeleteCount:0,deleteRate:0,crisisMaps:r,droneImages:s};c.forEach(u=>{if(u.source&&(i.sources[u.source]=(i.sources[u.source]||0)+1),u.event_type&&(i.types[u.event_type]=(i.types[u.event_type]||0)+1),u.countries&&u.countries.forEach(P=>{P.r_code&&(i.regions[P.r_code]=(i.regions[P.r_code]||0)+1)}),u.model){const P=u.model,V=i.models[P]||={count:0,avgAccuracy:0,avgContext:0,avgUsability:0,totalScore:0,deleteCount:0};if(V.count++,u.accuracy!=null&&(V.avgAccuracy+=u.accuracy),u.context!=null&&(V.avgContext+=u.context),u.usability!=null&&(V.avgUsability+=u.usability),u.created_at&&u.updated_at){const te=new Date(u.created_at).getTime(),Ce=new Date(u.updated_at).getTime()-te;Ce>0&&(d[P]||(d[P]=[]),d[P].push(Ce))}}}),_.forEach(u=>{u.s_code&&!i.sources[u.s_code]&&(i.sources[u.s_code]=0)}),x.forEach(u=>{u.t_code&&!i.types[u.t_code]&&(i.types[u.t_code]=0)}),C.forEach(u=>{u.r_code&&!i.regions[u.r_code]&&(i.regions[u.r_code]=0)}),["GPT-4","Claude","Gemini","Llama","Other"].forEach(u=>{i.models[u]||(i.models[u]={count:0,avgAccuracy:0,avgContext:0,avgUsability:0,totalScore:0,deleteCount:0})}),Object.values(i.models).forEach(u=>{u.count>0&&(u.avgAccuracy=Math.round(u.avgAccuracy/u.count),u.avgContext=Math.round(u.avgContext/u.count),u.avgUsability=Math.round(u.avgUsability/u.count),u.totalScore=Math.round((u.avgAccuracy+u.avgContext+u.avgUsability)/3))});const $=c.filter(u=>u.generated&&u.edited);if($.length>0){const P=[...$.map(oe=>F(oe.generated,oe.edited))].sort((oe,Ce)=>oe-Ce),V=Math.floor(P.length/2),te=P.length%2===0?(P[V-1]+P[V])/2:P[V];i.percentageModified=Math.round((1-te)*100)}const H={};c.forEach(u=>{if(u.model&&u.generated&&u.edited){const P=F(u.generated,u.edited),V=Math.round((1-P)*100);H[u.model]||(H[u.model]=[]),H[u.model].push(V)}}),i.modelPercentageData=H;try{const u=await fetch("/api/models");if(u.ok){const P=await u.json();if(P.models){P.models.forEach(te=>{i.models[te.m_code]&&(i.models[te.m_code].deleteCount=te.delete_count||0)});const V=P.models.reduce((te,oe)=>te+(oe.delete_count||0),0);i.totalDeleteCount=V,i.deleteRate=V>0?Math.round(V/(V+c.length)*100):0}}}catch(u){console.log("Could not fetch model delete counts:",u)}h(i)}catch{h(null)}finally{f(!1)}},[_,x,C,F]),ne=n.useCallback(async()=>{try{const[t,c,d,r]=await Promise.all([fetch("/api/sources"),fetch("/api/types"),fetch("/api/regions"),fetch("/api/models")]),s=await t.json(),i=await c.json(),D=await d.json(),$=await r.json();y(s),w(i),j(D),S($.models||[])}catch(t){console.log("Could not fetch lookup data:",t)}},[]);n.useEffect(()=>{const t=m.get("view");(t==="crisis_maps"||t==="drone_images")&&b(t)},[m]),n.useEffect(()=>{ne()},[ne]),n.useEffect(()=>{_.length>0&&x.length>0&&C.length>0&&v.length>0&&X()},[_,x,C,v,X]);const Y=n.useCallback(t=>{const c=_.find(d=>d.s_code===t);return c?c.label:t},[_]),M=n.useCallback(t=>{if(t.length===0)return 0;const c=[...t].sort((r,s)=>r-s),d=Math.floor(c.length/2);return c.length%2===0?Math.round((c[d-1]+c[d])/2):c[d]},[]),se=n.useCallback(t=>{const c=Math.floor(t/1e3),d=Math.floor(c/60),r=Math.floor(d/60);return r>0?`${r}h ${d%60}m`:d>0?`${d}m ${c%60}s`:`${c}s`},[]),_e=n.useCallback(t=>{const c=x.find(d=>d.t_code===t);return c?c.label:t},[x]),J=n.useCallback(t=>{const c=v.find(d=>d.m_code===t);return c?c.label:t},[v]),Se=n.useMemo(()=>a?Object.entries(a.modelEditTimes||{}).filter(([,t])=>t.length>0).sort(([,t],[,c])=>M(c)-M(t)).map(([t,c],d)=>({id:d+1,name:J(t),count:c.length,avgEditTime:M(c),minEditTime:Math.min(...c),maxEditTime:Math.max(...c)})):[],[a,M,J]),Me=n.useMemo(()=>a?Object.entries(a.modelPercentageData||{}).filter(([,t])=>t.length>0).sort(([,t],[,c])=>{const d=[...t].sort((H,u)=>H-u),r=[...c].sort((H,u)=>H-u),s=Math.floor(d.length/2),i=Math.floor(r.length/2),D=d.length%2===0?(d[s-1]+d[s])/2:d[s];return(r.length%2===0?(r[i-1]+r[i])/2:r[i])-D}).map(([t,c],d)=>{const r=[...c].sort((D,$)=>D-$),s=Math.floor(r.length/2),i=r.length%2===0?Math.round((r[s-1]+r[s])/2):r[s];return{id:d+1,name:J(t),count:c.length,avgPercentageModified:i,minPercentageModified:Math.min(...c),maxPercentageModified:Math.max(...c)}}):[],[a,J]),Ie=n.useMemo(()=>a?Object.entries(a.models).filter(([t,c])=>c.count>0&&t!=="manual").map(([t,c],d)=>{const r=[c.avgAccuracy,c.avgContext,c.avgUsability],s=r.reduce(($,H)=>$+H,0)/r.length,i=r.reduce(($,H)=>$+Math.pow(H-s,2),0)/r.length,D=Math.round(100-Math.sqrt(i));return{id:d+1,name:J(t),consistency:Math.max(0,D),avgScore:Math.round(s),count:c.count}}).sort((t,c)=>c.consistency-t.consistency):[],[a,J]),De=n.useMemo(()=>[Q("name","Region",t=>t.name),E("count","Count",t=>t.count),E("percentage","% of Total",t=>t.percentage,{suffix:"%",maximumFractionDigits:0})],[]),Ee=n.useMemo(()=>[Q("name","Type",t=>t.name),E("count","Count",t=>t.count),E("percentage","% of Total",t=>t.percentage,{suffix:"%",maximumFractionDigits:0})],[]),lt=n.useMemo(()=>[Q("name","Source",t=>t.name),E("count","Count",t=>t.count),E("percentage","% of Total",t=>t.percentage,{suffix:"%",maximumFractionDigits:0})],[]),Te=n.useMemo(()=>[Q("name","Model",t=>t.name),E("count","Count",t=>t.count),E("accuracy","Accuracy",t=>t.accuracy,{suffix:"%",maximumFractionDigits:0}),E("context","Context",t=>t.context,{suffix:"%",maximumFractionDigits:0}),E("usability","Usability",t=>t.usability,{suffix:"%",maximumFractionDigits:0}),E("totalScore","Total Score",t=>t.totalScore,{suffix:"%",maximumFractionDigits:0})],[]),ke=n.useMemo(()=>[Q("name","Model",t=>t.name),E("count","Count",t=>t.count),Q("avgEditTime","Median Edit Time",t=>se(t.avgEditTime)),Q("minEditTime","Min Edit Time",t=>se(t.minEditTime)),Q("maxEditTime","Max Edit Time",t=>se(t.maxEditTime))],[se]),Le=n.useMemo(()=>[Q("name","Model",t=>t.name),E("count","Count",t=>t.count),E("avgPercentageModified","Median % Modified",t=>t.avgPercentageModified,{suffix:"%",maximumFractionDigits:0}),E("minPercentageModified","Min % Modified",t=>t.minPercentageModified,{suffix:"%",maximumFractionDigits:0}),E("maxPercentageModified","Max % Modified",t=>t.maxPercentageModified,{suffix:"%",maximumFractionDigits:0})],[]),Pe=n.useMemo(()=>[Q("name","Model",t=>t.name),E("count","Total Count",t=>t.count),E("deleteCount","Delete Count",t=>t.deleteCount),E("deleteRate","Delete Rate",t=>t.deleteRate,{suffix:"%",maximumFractionDigits:1})],[]),ct=n.useMemo(()=>[Q("source","Source",t=>t.source),E("avgQuality","Average Quality",t=>t.avgQuality,{suffix:"%",maximumFractionDigits:0}),E("count","Count",t=>t.count)],[]),Re=n.useMemo(()=>[Q("eventType","Event Type",t=>t.eventType),E("avgQuality","Average Quality",t=>t.avgQuality,{suffix:"%",maximumFractionDigits:0}),E("count","Count",t=>t.count)],[]),$e=n.useMemo(()=>[Q("name","Model",t=>t.name),E("consistency","Consistency",t=>t.consistency,{suffix:"%",maximumFractionDigits:0}),E("avgScore","Average Score",t=>t.avgScore,{suffix:"%",maximumFractionDigits:0}),E("count","Count",t=>t.count)],[]),ue=n.useCallback(t=>a?t==="crisis_map"?a.crisisMaps.length:t==="drone_image"?a.droneImages.length:0:0,[a]),Be=n.useCallback(t=>{if(!a)return[];const c=t==="crisis_map"?a.crisisMaps:a.droneImages,d={};return c.forEach(r=>{r.countries&&r.countries.forEach(s=>{s.r_code&&(d[s.r_code]=(d[s.r_code]||0)+1)})}),Object.entries(d).filter(([,r])=>r>0).map(([r,s])=>({name:C.find(i=>i.r_code===r)?.label||r,value:s}))},[a,C]),Ae=n.useCallback(t=>{if(!a)return[];const c=t==="crisis_map"?a.crisisMaps:a.droneImages,d={};c.forEach(s=>{s.countries&&s.countries.forEach(i=>{i.r_code&&(d[i.r_code]=(d[i.r_code]||0)+1)})});const r=C.reduce((s,i)=>(i.r_code&&(s[i.r_code]={name:i.label,count:d[i.r_code]||0}),s),{});return Object.entries(r).sort(([,s],[,i])=>i.count-s.count).map(([,{name:s,count:i}],D)=>({id:D+1,name:s,count:i,percentage:c.length>0?Math.round(i/c.length*100):0}))},[a,C]),dt=n.useCallback(t=>{if(!a)return[];const c=t==="crisis_map"?a.crisisMaps:a.droneImages,d={};return c.forEach(r=>{r.source&&(d[r.source]=(d[r.source]||0)+1)}),Object.entries(d).filter(([,r])=>r>0).map(([r,s])=>({name:_.find(i=>i.s_code===r)?.label||r,value:s}))},[a,_]),ut=n.useCallback(t=>{if(!a)return[];const c=t==="crisis_map"?a.crisisMaps:a.droneImages,d={};return c.forEach(r=>{r.source&&(d[r.source]=(d[r.source]||0)+1)}),Object.entries(d).sort(([,r],[,s])=>s-r).map(([r,s],i)=>({id:i+1,name:Y(r),count:s,percentage:c.length>0?Math.round(s/c.length*100):0}))},[a,Y]),Fe=n.useCallback(t=>{if(!a)return[];const c=t==="crisis_map"?a.crisisMaps:a.droneImages,d={};return c.forEach(r=>{r.event_type&&(d[r.event_type]=(d[r.event_type]||0)+1)}),Object.entries(d).filter(([,r])=>r>0).map(([r,s])=>({name:x.find(i=>i.t_code===r)?.label||r,value:s}))},[a,x]),Oe=n.useCallback(t=>{if(!a)return[];const c=t==="crisis_map"?a.crisisMaps:a.droneImages,d={};return c.forEach(r=>{r.event_type&&(d[r.event_type]=(d[r.event_type]||0)+1)}),Object.entries(d).sort(([,r],[,s])=>s-r).map(([r,s],i)=>({id:i+1,name:_e(r),count:s,percentage:c.length>0?Math.round(s/c.length*100):0}))},[a,_e]),He=n.useCallback(t=>{if(!a)return"No data available";const c=t==="crisis_map"?a.crisisMaps:a.droneImages,d=new Set;c.forEach(i=>{i.model&&d.add(i.model)}),console.log(`Debug ${t}:`,{totalImages:c.length,usedModels:Array.from(d),availableEditTimes:Object.keys(a.modelEditTimes),modelEditTimesData:a.modelEditTimes});const s=Object.entries(a.modelEditTimes).filter(([i])=>d.has(i)).flatMap(([,i])=>i);return s.length===0?"No data available":se(M(s))},[a,se,M]),Ve=n.useCallback(()=>{if(!a)return"No data available";const t=a.totalCaptions||0,c=a.percentageModified||0;return t>0?Math.round(c/t*100):0},[a]),ze=n.useCallback(()=>a&&a.deleteRate>=0?`${a.deleteRate}%`:"No data available",[a]),Ue=n.useCallback(t=>{if(!a)return[];const c=t==="crisis_map"?a.crisisMaps:a.droneImages,d=new Set;return c.forEach(s=>{s.model&&d.add(s.model)}),Se.filter(s=>{const i=v.find(D=>D.label===s.name)?.m_code;return i&&d.has(i)})},[a,Se,v]),We=n.useCallback(t=>{if(!a)return[];const c=t==="crisis_map"?a.crisisMaps:a.droneImages,d=new Set;return c.forEach(s=>{s.model&&d.add(s.model)}),Me.filter(s=>{const i=v.find(D=>D.label===s.name)?.m_code;return i&&d.has(i)})},[a,Me,v]),Qe=n.useCallback(t=>{if(!a)return[];const c=t==="crisis_map"?a.crisisMaps:a.droneImages,d={};return c.forEach(r=>{r.model&&(d[r.model]||(d[r.model]={count:0,deleteCount:0}),d[r.model].count++)}),Object.entries(d).map(([r,s],i)=>{const $=a.models?.[r]?.deleteCount||0,H=s.count>0?Math.round($/s.count*100*10)/10:0;return{id:i+1,name:J(r),count:s.count,deleteCount:$,deleteRate:H}}).sort((r,s)=>s.count-r.count)},[a,J]),Ze=n.useCallback(t=>{if(!a)return[];const d=(t==="crisis_map"?a.crisisMaps:a.droneImages).filter(s=>s.model!=="manual"),r={};return d.forEach(s=>{s.model&&(r[s.model]||(r[s.model]={count:0,totalAccuracy:0,totalContext:0,totalUsability:0}),r[s.model].count++,s.accuracy!=null&&(r[s.model].totalAccuracy+=s.accuracy),s.context!=null&&(r[s.model].totalContext+=s.context),s.usability!=null&&(r[s.model].totalUsability+=s.usability))}),Object.entries(r).map(([s,i],D)=>({id:D+1,name:J(s),count:i.count,accuracy:i.count>0?Math.round(i.totalAccuracy/i.count):0,context:i.count>0?Math.round(i.totalContext/i.count):0,usability:i.count>0?Math.round(i.totalUsability/i.count):0,totalScore:i.count>0?Math.round((i.totalAccuracy+i.totalContext+i.totalUsability)/(3*i.count)):0})).sort((s,i)=>i.totalScore-s.totalScore)},[a,J]),mt=n.useCallback(t=>{if(!a)return[];const d=(t==="crisis_map"?a.crisisMaps:a.droneImages).filter(s=>s.model!=="manual"),r={};return d.forEach(s=>{s.source&&(r[s.source]||(r[s.source]={total:0,count:0,totalImages:0}),r[s.source].totalImages+=1,s.accuracy!=null&&(r[s.source].total+=s.accuracy,r[s.source].count+=1))}),Object.entries(r).map(([s,i],D)=>({id:D+1,source:Y(s),avgQuality:i.count>0?Math.round(i.total/i.count):0,count:i.totalImages}))},[a,Y]),qe=n.useCallback(t=>{if(!a)return[];const d=(t==="crisis_map"?a.crisisMaps:a.droneImages).filter(s=>s.model!=="manual"),r={};return d.forEach(s=>{s.event_type&&(r[s.event_type]||(r[s.event_type]={total:0,count:0,totalImages:0}),r[s.event_type].totalImages+=1,s.accuracy!=null&&(r[s.event_type].total+=s.accuracy,r[s.event_type].count+=1))}),Object.entries(r).map(([s,i],D)=>({id:D+1,eventType:_e(s),avgQuality:i.count>0?Math.round(i.total/i.count):0,count:i.totalImages}))},[a,_e]),Ge=n.useCallback(t=>{if(!a)return[];const d=(t==="crisis_map"?a.crisisMaps:a.droneImages).filter(i=>i.model!=="manual"),r=new Set;return d.forEach(i=>{i.model&&r.add(i.model)}),Ie.filter(i=>{const D=v.find($=>$.label===i.name)?.m_code;return D&&D!=="manual"&&r.has(D)})},[a,Ie,v]);if(o)return e.jsx(je,{children:e.jsx("div",{className:l.loadingContainer,children:e.jsx(Et,{})})});if(!a)return e.jsx(je,{children:e.jsx("div",{className:l.errorContainer,children:e.jsx("div",{className:"text-red-500",children:"Failed to load analytics data. Please try again."})})});const me=["#F5333F","#F64752","#F75C65","#F87079","#F9858C","#FA999F","#FBADB2","#FCC2C5"];return e.jsx(je,{children:e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsx("div",{className:l.tabSelector,children:e.jsx(Tt,{name:"analytics-view",value:g,onChange:t=>{(t==="crisis_maps"||t==="drone_images")&&b(t)},options:O,keySelector:t=>t.key,labelSelector:t=>t.label})}),g==="crisis_maps"?e.jsxs("div",{className:l.chartGrid,children:[e.jsxs(z,{heading:"Summary Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:l.summaryStatsCards,children:[e.jsxs("div",{className:l.summaryStatsCard,children:[e.jsx("div",{className:l.summaryStatsCardValue,children:ue("crisis_map")}),e.jsx("div",{className:l.summaryStatsCardLabel,children:"Total Crisis Maps"})]}),e.jsxs("div",{className:l.summaryStatsCard,children:[e.jsx("div",{className:l.summaryStatsCardValue,children:"2000"}),e.jsx("div",{className:l.summaryStatsCardLabel,children:"Target Amount"})]})]}),e.jsxs("div",{className:l.progressSection,children:[e.jsxs("div",{className:l.progressLabel,children:[e.jsx("span",{children:"Progress towards target"}),e.jsxs("span",{children:[Math.round(ue("crisis_map")/2e3*100),"%"]})]}),e.jsx(Ye,{value:ue("crisis_map"),totalValue:2e3})]})]}),e.jsxs(z,{heading:"Distribution Analysis",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:l.userInteractionCards,children:[e.jsxs("div",{className:l.userInteractionCard,children:[e.jsx("div",{className:l.userInteractionCardLabel,children:"Regions Distribution"}),e.jsx("div",{className:l.chartContainer,children:e.jsx(xe,{data:Be("crisis_map"),valueSelector:t=>t.value,labelSelector:t=>t.name,keySelector:t=>t.name,colors:me,showPercentageInLegend:!0})}),e.jsx(Z,{name:"view-regions-details",variant:U?"primary":"secondary",onClick:()=>T(U?"none":"regions"),className:l.userInteractionCardButton,children:U?"Hide Details":"View Details"})]}),e.jsxs("div",{className:l.userInteractionCard,children:[e.jsx("div",{className:l.userInteractionCardLabel,children:"Sources Distribution"}),e.jsx("div",{className:l.chartContainer,children:e.jsx(xe,{data:dt("crisis_map"),valueSelector:t=>t.value,labelSelector:t=>t.name,keySelector:t=>t.name,colors:me,showPercentageInLegend:!0})}),e.jsx(Z,{name:"view-sources-details",variant:ae?"primary":"secondary",onClick:()=>T(ae?"none":"sources"),className:l.userInteractionCardButton,children:ae?"Hide Details":"View Details"})]}),e.jsxs("div",{className:l.userInteractionCard,children:[e.jsx("div",{className:l.userInteractionCardLabel,children:"Types Distribution"}),e.jsx("div",{className:l.chartContainer,children:e.jsx(xe,{data:Fe("crisis_map"),valueSelector:t=>t.value,labelSelector:t=>t.name,keySelector:t=>t.name,colors:me,showPercentageInLegend:!0})}),e.jsx(Z,{name:"view-types-details",variant:K?"primary":"secondary",onClick:()=>T(K?"none":"types"),className:l.userInteractionCardButton,children:K?"Hide Details":"View Details"})]})]}),U&&e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:Ae("crisis_map"),columns:De,keySelector:B,filtered:!1,pending:!1})}),ae&&e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:ut("crisis_map"),columns:lt,keySelector:B,filtered:!1,pending:!1})}),K&&e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:Oe("crisis_map"),columns:Ee,keySelector:B,filtered:!1,pending:!1})})]}),e.jsxs(z,{heading:"User Interaction Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:l.userInteractionCards,children:[e.jsxs("div",{className:l.userInteractionCard,children:[e.jsx("div",{className:l.userInteractionCardValue,children:He("crisis_map")}),e.jsx("div",{className:l.userInteractionCardLabel,children:"Median Edit Time"}),e.jsx(Z,{name:"view-edit-time-details",variant:p?"primary":"secondary",onClick:()=>T(p?"none":"editTime"),className:l.userInteractionCardButton,children:p?"Hide Details":"View Details"})]}),e.jsxs("div",{className:l.userInteractionCard,children:[e.jsx("div",{className:l.userInteractionCardValue,children:Ve()}),e.jsx("div",{className:l.userInteractionCardLabel,children:"Median % Modified"}),e.jsx(Z,{name:"view-percentage-details",variant:I?"primary":"secondary",onClick:()=>T(I?"none":"percentage"),className:l.userInteractionCardButton,children:I?"Hide Details":"View Details"})]}),e.jsxs("div",{className:l.userInteractionCard,children:[e.jsx("div",{className:l.userInteractionCardValue,children:ze()}),e.jsx("div",{className:l.userInteractionCardLabel,children:"Delete Rate"}),e.jsx(Z,{name:"view-delete-details",variant:k?"primary":"secondary",onClick:()=>T(k?"none":"delete"),className:l.userInteractionCardButton,children:k?"Hide Details":"View Details"})]})]}),p&&e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:Ue("crisis_map"),columns:ke,keySelector:B,filtered:!1,pending:!1})}),I&&e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:We("crisis_map"),columns:Le,keySelector:B,filtered:!1,pending:!1})}),k&&e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:Qe("crisis_map"),columns:Pe,keySelector:B,filtered:!1,pending:!1})})]}),e.jsx(z,{heading:"Model Performance",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:Ze("crisis_map"),columns:Te,keySelector:B,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Quality-Source Correlation",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:l.tableContainer,children:e.jsx(A,{data:mt("crisis_map"),columns:ct,keySelector:B,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Quality-Event Type Correlation",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:l.tableContainer,children:e.jsx(A,{data:qe("crisis_map"),columns:Re,keySelector:B,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Model Consistency Analysis",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:l.tableContainer,children:e.jsx(A,{data:Ge("crisis_map"),columns:$e,keySelector:B,filtered:!1,pending:!1})})})]}):e.jsxs("div",{className:l.chartGrid,children:[e.jsxs(z,{heading:"Summary Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:l.summaryStatsCards,children:[e.jsxs("div",{className:l.summaryStatsCard,children:[e.jsx("div",{className:l.summaryStatsCardValue,children:ue("drone_image")}),e.jsx("div",{className:l.summaryStatsCardLabel,children:"Total Drone Images"})]}),e.jsxs("div",{className:l.summaryStatsCard,children:[e.jsx("div",{className:l.summaryStatsCardValue,children:"2000"}),e.jsx("div",{className:l.summaryStatsCardLabel,children:"Target Amount"})]})]}),e.jsxs("div",{className:l.progressSection,children:[e.jsxs("div",{className:l.progressLabel,children:[e.jsx("span",{children:"Progress towards target"}),e.jsxs("span",{children:[Math.round(ue("drone_image")/2e3*100),"%"]})]}),e.jsx(Ye,{value:ue("drone_image"),totalValue:2e3})]})]}),e.jsxs(z,{heading:"Distribution Analysis",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:l.userInteractionCards,children:[e.jsxs("div",{className:l.userInteractionCard,children:[e.jsx("div",{className:l.userInteractionCardLabel,children:"Regions Distribution"}),e.jsx("div",{className:l.chartContainer,children:e.jsx(xe,{data:Be("drone_image"),valueSelector:t=>t.value,labelSelector:t=>t.name,keySelector:t=>t.name,colors:me,showPercentageInLegend:!0})}),e.jsx(Z,{name:"view-regions-details",variant:U?"primary":"secondary",onClick:()=>T(U?"none":"regions"),className:l.userInteractionCardButton,children:U?"Hide Details":"View Details"})]}),e.jsxs("div",{className:l.userInteractionCard,children:[e.jsx("div",{className:l.userInteractionCardLabel,children:"Types Distribution"}),e.jsx("div",{className:l.chartContainer,children:e.jsx(xe,{data:Fe("drone_image"),valueSelector:t=>t.value,labelSelector:t=>t.name,keySelector:t=>t.name,colors:me,showPercentageInLegend:!0})}),e.jsx(Z,{name:"view-types-details",variant:K?"primary":"secondary",onClick:()=>T(K?"none":"types"),className:l.userInteractionCardButton,children:K?"Hide Details":"View Details"})]})]}),U&&e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:Ae("drone_image"),columns:De,keySelector:B,filtered:!1,pending:!1})}),K&&e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:Oe("drone_image"),columns:Ee,keySelector:B,filtered:!1,pending:!1})})]}),e.jsxs(z,{heading:"User Interaction Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:l.userInteractionCards,children:[e.jsxs("div",{className:l.userInteractionCard,children:[e.jsx("div",{className:l.userInteractionCardValue,children:He("drone_image")}),e.jsx("div",{className:l.userInteractionCardLabel,children:"Median Edit Time"}),e.jsx(Z,{name:"view-edit-time-details",variant:p?"primary":"secondary",onClick:()=>T(p?"none":"editTime"),className:l.userInteractionCardButton,children:p?"Hide Details":"View Details"})]}),e.jsxs("div",{className:l.userInteractionCard,children:[e.jsx("div",{className:l.userInteractionCardValue,children:Ve()}),e.jsx("div",{className:l.userInteractionCardLabel,children:"Median % Modified"}),e.jsx(Z,{name:"view-percentage-details",variant:I?"primary":"secondary",onClick:()=>T(I?"none":"percentage"),className:l.userInteractionCardButton,children:I?"Hide Details":"View Details"})]}),e.jsxs("div",{className:l.userInteractionCard,children:[e.jsx("div",{className:l.userInteractionCardValue,children:ze()}),e.jsx("div",{className:l.userInteractionCardLabel,children:"Delete Rate"}),e.jsx(Z,{name:"view-delete-details",variant:k?"primary":"secondary",onClick:()=>T(k?"none":"delete"),className:l.userInteractionCardButton,children:k?"Hide Details":"View Details"})]})]}),p&&e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:Ue("drone_image"),columns:ke,keySelector:B,filtered:!1,pending:!1})}),I&&e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:We("drone_image"),columns:Le,keySelector:B,filtered:!1,pending:!1})}),k&&e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:Qe("drone_image"),columns:Pe,keySelector:B,filtered:!1,pending:!1})})]}),e.jsx(z,{heading:"Model Performance",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:Ze("drone_image"),columns:Te,keySelector:B,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Quality-Event Type Correlation",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:l.tableContainer,children:e.jsx(A,{data:qe("drone_image"),columns:Re,keySelector:B,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Model Consistency Analysis",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:l.tableContainer,children:e.jsx(A,{data:Ge("drone_image"),columns:$e,keySelector:B,filtered:!1,pending:!1})})})]})]})})}export{jn as default}; +import{r as n,y as nt,t as ht,a as q,c as gt,j as e,o as N,b as re,R as st,z,g as rt,d as ft,m as vt,e as pt,n as Z,A as xt,f as _t,h as Ct,i as yt,k as he,l as bt,p as ye,q as jt,s as Nt,E as wt,C as St,U as Mt,Q as It,u as Dt,N as je,_ as Et,L as Tt}from"./index-C5rMGfs8.js";const kt=({title:m,titleId:a,...h})=>n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em","aria-labelledby":a},h),m?n.createElement("title",{id:a},m):null,n.createElement("g",{clipPath:"url(#arrow-drop-down-line_svg__a)"},n.createElement("path",{d:"m12 15-4.243-4.243 1.415-1.414L12 12.172l2.828-2.83 1.415 1.415L12 15Z"})),n.createElement("defs",null,n.createElement("clipPath",{id:"arrow-drop-down-line_svg__a"},n.createElement("path",{d:"M0 0h24v24H0z"})))),Lt=({title:m,titleId:a,...h})=>n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em","aria-labelledby":a},h),m?n.createElement("title",{id:a},m):null,n.createElement("g",{clipPath:"url(#arrow-drop-up-line_svg__a)"},n.createElement("path",{d:"m12 11.828-2.828 2.829-1.415-1.414L12 9l4.243 4.243-1.415 1.414L12 11.828Z"})),n.createElement("defs",null,n.createElement("clipPath",{id:"arrow-drop-up-line_svg__a"},n.createElement("path",{d:"M0 0h24v24H0z"})))),Pt=({title:m,titleId:a,...h})=>n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em","aria-labelledby":a},h),m?n.createElement("title",{id:a},m):null,n.createElement("g",{clipPath:"url(#information-line_svg__a)"},n.createElement("path",{d:"M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10Zm0-2a8 8 0 1 0 0-16.001A8 8 0 0 0 12 20ZM11 7h2v2h-2V7Zm0 4h2v6h-2v-6Z"})),n.createElement("defs",null,n.createElement("clipPath",{id:"information-line_svg__a"},n.createElement("path",{d:"M0 0h24v24H0z"})))),Rt=({title:m,titleId:a,...h})=>n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em","aria-labelledby":a},h),m?n.createElement("title",{id:a},m):null,n.createElement("path",{fillRule:"evenodd",d:"m15.063 12 .937.938-4 4-4-4L8.938 12 12 15.063 15.063 12Z",clipRule:"evenodd"}),n.createElement("mask",{id:"table-sorting-line_svg__a",width:8,height:5,x:8,y:12,maskUnits:"userSpaceOnUse",style:{maskType:"luminance"}},n.createElement("path",{fillRule:"evenodd",d:"m15.063 12 .937.938-4 4-4-4L8.938 12 12 15.063 15.063 12Z",clipRule:"evenodd"})),n.createElement("g",{mask:"url(#table-sorting-line_svg__a)"},n.createElement("path",{d:"M-24-22h72v72h-72z"})),n.createElement("path",{fillRule:"evenodd",d:"M8.938 11 8 10.062l4-4 4 4-.938.938L12 7.937 8.937 11Z",clipRule:"evenodd"}),n.createElement("mask",{id:"table-sorting-line_svg__b",width:8,height:5,x:8,y:6,maskUnits:"userSpaceOnUse",style:{maskType:"luminance"}},n.createElement("path",{fillRule:"evenodd",d:"M8.938 11 8 10.062l4-4 4 4-.938.938L12 7.937 8.937 11Z",clipRule:"evenodd"})),n.createElement("g",{mask:"url(#table-sorting-line_svg__b)"},n.createElement("path",{d:"M48 45h-72v-72h72z"}))),$t="_number-output_1blvi_1",Bt={numberOutput:$t};function we(m){const{className:a,invalidText:h=nt,separatorHidden:o,compact:f,currency:g,value:b,tooltip:_,unit:y,prefix:x,suffix:w,maximumFractionDigits:C=1}=m,{currentLanguage:j}=n.useContext(ht),v=n.useMemo(()=>{if(q(b))return h;const S=gt(b,{currency:g,compact:f,separatorHidden:o,maximumFractionDigits:C,unit:y,language:j});return e.jsxs(e.Fragment,{children:[x,S,w]})},[h,b,f,o,g,y,C,x,j,w]);return e.jsx("div",{className:N(Bt.numberOutput,a),title:re(_)?String(_):void 0,children:v})}const At="_tooltip-dummy_rbf3f_1",Ft="_tooltip-content_rbf3f_7",Ot="_pointer_rbf3f_14",Ne={tooltipDummy:At,tooltipContent:Ft,pointer:Ot};function Ht(m){const{className:a,title:h,description:o,preferredWidth:f}=m,[g,b]=n.useState(!1),[_,y]=n.useState(!1),x=n.useRef(),w=n.useRef(null);return n.useEffect(()=>{const C=()=>{y(!0)},j=()=>{y(!1)};if(q(w.current))return;const{current:{parentNode:v}}=w;if(!q(v))return x.current=v,v.addEventListener("mouseover",C),v.addEventListener("mouseout",j),b(!0),()=>{v.removeEventListener("mouseover",C),v.removeEventListener("mouseout",j)}},[]),e.jsxs(e.Fragment,{children:[!g&&e.jsx("div",{className:Ne.tooltipDummy,ref:w}),_&&e.jsx(st,{className:N(Ne.tooltipContent,a),parentRef:x,pointerClassName:Ne.pointer,preferredWidth:f,children:e.jsx(z,{heading:h,withInternalPadding:!0,contentViewType:"vertical",children:o})})]})}function B(m){return m.id}const Vt="common",zt={booleanYesLabel:"Yes",booleanNoLabel:"No"},Ut={namespace:Vt,strings:zt},Wt="_boolean-output_kg1uq_1",Qt={booleanOutput:Wt};function Zt(m){const{className:a,invalidText:h,value:o}=m,f=rt(Ut);let g;return o===!0?g=f.booleanYesLabel:o===!1?g=f.booleanNoLabel:g=h,e.jsx("div",{className:N(Qt.booleanOutput,a),children:g})}const qt="_date-output_4jzjo_1",Gt={dateOutput:qt};function Yt(m){const{value:a,format:h,className:o,invalidText:f}=m,g=n.useMemo(()=>ft(a,h),[a,h]);return e.jsx("div",{className:N(Gt.dateOutput,o),children:g??f})}const Kt="_dropdown-menu_16hml_1",Xt="_icons_16hml_4",Jt="_content_16hml_5",ea="_actions_16hml_6",ta="_dropdown-icon_16hml_10",aa="_dropdown-content_16hml_16",le={dropdownMenu:Kt,icons:Xt,content:Jt,actions:ea,dropdownIcon:ta,dropdownContent:aa};function na(m){const a=n.useRef(null),{className:h,popupClassName:o,children:f,label:g,activeClassName:b,icons:_,variant:y="secondary",actions:x,withoutDropdownIcon:w,componentRef:C,elementRef:j=a,persistent:v,preferredPopupWidth:S}=m,p=n.useRef(null),[L,I]=n.useState(!1);n.useEffect(()=>{C&&(C.current={setShowDropdown:I})},[C,I]);const R=n.useCallback(()=>{I(ie=>!ie)},[I]),k=n.useCallback((ie,ae)=>{ae||ie&&v||I(!1)},[I,v]);vt(L,k,p,j);const G=n.useMemo(()=>({setShowDropdown:I}),[I]),U=!!x||!w;return e.jsxs(pt.Provider,{value:G,children:[e.jsx(Z,{name:void 0,className:N(le.dropdownMenu,L&&b,h),elementRef:j,onClick:R,variant:y,actionsContainerClassName:le.actions,iconsContainerClassName:le.icons,childrenContainerClassName:le.content,actions:U?e.jsxs(e.Fragment,{children:[x,!w&&(L?e.jsx(xt,{className:le.dropdownIcon}):e.jsx(_t,{className:le.dropdownIcon}))]}):void 0,icons:_,children:g}),L&&e.jsx(st,{elementRef:p,className:N(le.dropdownContent,o),parentRef:j,preferredWidth:S,children:f})]})}const sa="_info-popup_i3rna_1",ra="_label_i3rna_2",ia="_icon_i3rna_7",oa="_dropdown-container_i3rna_15",la="_content_i3rna_20",ge={infoPopup:sa,label:ra,icon:ia,dropdownContainer:oa,content:la};function ca(m){const{className:a,icon:h=e.jsx(Pt,{}),infoLabel:o,title:f,description:g,withoutIcon:b,popupClassName:_,descriptionClassName:y}=m;return e.jsx(na,{label:e.jsxs("div",{className:ge.label,children:[o,!b&&h&&e.jsx("div",{className:ge.icon,children:h})]}),popupClassName:N(ge.dropdownContainer,_),className:N(ge.infoPopup,a),variant:"tertiary",withoutDropdownIcon:!0,children:e.jsx(z,{heading:f,childrenContainerClassName:N(y,ge.content),withInternalPadding:!0,children:g})})}const da="_progress-wrapper_x340w_1",ua="_title_x340w_7",ma="_total_x340w_11",ha="_progress_x340w_1",fe={progressWrapper:da,title:ua,total:ma,progress:ha};function Ye(m){const{className:a,title:h,description:o,totalValue:f,value:g,showPercentageInTitle:b,children:_,color:y="var(--go-ui-color-primary-red)"}=m,x=re(g)?g:0,w=re(f)?f:0;let C;return w===0?C=0:C=x/w*100,e.jsxs("div",{className:N(fe.progressWrapper,a),children:[(h||b)&&e.jsxs("div",{className:fe.title,children:[h,b&&e.jsx(we,{value:C,suffix:"%"})]}),e.jsx("div",{className:fe.total,children:e.jsx("div",{className:fe.progress,style:{width:`${C}%`,backgroundColor:y}})}),o&&e.jsx("div",{className:fe.description,children:o}),_]})}const ga="_legend-element_1a9ic_1",fa="_color_1a9ic_7",va="_icon-container_1a9ic_14",pa="_icon_1a9ic_14",xa="_label_1a9ic_31",ve={legendElement:ga,color:fa,iconContainer:va,icon:pa,label:xa};function _a(m){const{className:a,colorClassName:h,iconClassName:o,color:f,label:g,iconSrc:b}=m;return e.jsxs("div",{className:N(ve.legendElement,a),children:[b?e.jsx("div",{style:{backgroundColor:f},className:ve.iconContainer,children:e.jsx("img",{className:N(ve.icon,o),src:b,alt:""})}):e.jsx("div",{style:{backgroundColor:f},className:N(ve.color,h)}),e.jsx("div",{className:ve.label,children:g})]})}const Ca="_text-output_10oza_1",ya="_with-background_10oza_6",ba="_label_10oza_11",ja="_with-colon_10oza_12",Na="_value_10oza_17",wa="_text-type_10oza_18",Sa="_strong_10oza_24",ee={textOutput:Ca,withBackground:ya,label:ba,withColon:ja,value:Na,textType:wa,strong:Sa};function Ke(m){const{className:a,label:h,icon:o,description:f,labelClassName:g,descriptionClassName:b,valueClassName:_,strongLabel:y,strongValue:x,strongDescription:w,withoutLabelColon:C,withBackground:j,invalidText:v=nt,...S}=m,{value:p}=m;let L=v;return S.valueType==="number"?L=e.jsx(we,{...S,invalidText:v}):S.valueType==="date"?L=e.jsx(Yt,{...S,invalidText:v}):S.valueType==="boolean"?L=e.jsx(Zt,{...S,invalidText:v}):p instanceof Date||(L=p||v),e.jsxs("div",{className:N(ee.textOutput,j&&ee.withBackground,a),children:[o,h&&e.jsx("div",{className:N(ee.label,y&&ee.strong,g,!C&&ee.withColon),children:h}),e.jsx("div",{className:N(ee.value,x&&ee.strong,S.valueType==="text"&&ee.textType,_),children:L}),f&&e.jsx("div",{className:N(ee.description,w&&ee.strong,b),children:f})]})}const Ma="_pie-chart_pyr7m_1",Ia="_legend_pyr7m_7",Da="_legend-item_pyr7m_13",pe={pieChart:Ma,legend:Ia,legendItem:Da},Ea=70,Ta=40;function Xe(m,a=1){return Math.round(m*10**a)/10**a}function Je(m,a){const h=(a-90)*Math.PI/180;return{x:Xe(m+m*Math.cos(h)),y:Xe(m+m*Math.sin(h))}}function ka(m,a,h){let o=h;const f=o-a===360;f&&(o-=1);const g=Je(m,a),b=Je(m,o),_=o-a<=180?0:1,y=["M",g.x,g.y,"A",m,m,0,_,1,b.x,b.y];return f?y.push("Z"):y.push("L",m,m,"L",g.x,g.y,"Z"),y.join(" ")}function xe(m){const{className:a,data:h,valueSelector:o,labelSelector:f,keySelector:g,colorSelector:b,colors:_,pieRadius:y=Ea,chartPadding:x=Ta,legendClassName:w,showPercentageInLegend:C}=m,j=Ct(h?.map(p=>o(p))),v=q(j)||j===0?1:j,S=n.useMemo(()=>{let p=0;const L=h?.map(I=>{const R=o(I);if(q(R))return;const k=360*(R/v);return p+=k,{key:g(I),value:R,label:f(I),startAngle:p-k,percentage:yt(R,v),endAngle:p,datum:I}}).filter(re)??[];return b?L.map(({datum:I,...R})=>({...R,color:b(I)})):L.map(({datum:I,...R},k)=>({...R,color:_[k%_.length]}))},[h,g,o,f,v,b,_]);return e.jsxs("div",{className:N(pe.pieChart,a),children:[e.jsx("svg",{className:pe.svg,style:{width:`${x+y*2}px`,height:`${x+y*2}px`},children:e.jsx("g",{style:{transform:`translate(${x/2}px, ${x/2}px)`},children:S.map(p=>e.jsx("path",{className:pe.path,d:ka(y,p.startAngle,p.endAngle),fill:p.color,children:e.jsx(Ht,{description:e.jsx(Ke,{label:p.label,value:p.value})})},p.key))})}),e.jsx("div",{className:N(pe.legend,w),children:S.map(p=>e.jsx(_a,{className:pe.legendItem,label:C?e.jsx(Ke,{label:p.label,value:p.percentage,valueType:"number",prefix:"(",suffix:"%)",withoutLabelColon:!0}):p.label,color:p.color},p.key))})]})}const La="_td_1k4cn_1",Pa={td:La};function Ra(m){const{className:a,children:h,...o}=m;return e.jsx("td",{className:N(a,Pa.td),...o,children:h})}function it(m){const{className:a,children:h,...o}=m;return e.jsx("tr",{className:a,...o,children:h})}const $a="_row_1829z_1",Ba="_cell_1829z_2",et={row:$a,cell:Ba};function Aa(m){const{data:a,keySelector:h,columns:o,rowClassName:f,cellClassName:g,rowModifier:b}=m;return e.jsx(e.Fragment,{children:a?.map((_,y)=>{const x=h(_,y),w=o.map(v=>{const{id:S,cellRenderer:p,cellRendererClassName:L,cellRendererParams:I,cellContainerClassName:R}=v,k=I(x,_,y,a),G=e.jsx(p,{className:L,...k,name:S});return e.jsx(Ra,{className:N(et.cell,R,typeof g=="function"?g(x,_,S):g),children:G},S)}),C=e.jsx(it,{className:N(et.row,typeof f=="function"?f(x,_):f),children:w});let j=C;return b&&(j=b({rowKey:x,row:C,cells:w,columns:o,datum:_})),e.jsx(n.Fragment,{children:j},x)})})}const Fa="_th_cdv41_1",Oa="_resize-handle_cdv41_8",tt={th:Fa,resizeHandle:Oa};function Ha(m){const{className:a,children:h,onResize:o,onResizeComplete:f,name:g,...b}=m,_=n.useRef(null),y=n.useRef(),x=n.useRef(),w=n.useRef(),C=n.useCallback(v=>{var S;if(re(y.current)&&_.current&&o){v.preventDefault(),v.stopPropagation();const p=v.clientX-y.current;if(re(x.current)){const L=x.current+p;w.current=L,o(L,g)}else x.current=(S=_.current)==null?void 0:S.offsetWidth}},[o,g]),j=n.useCallback(v=>{var S;v.preventDefault(),y.current=v.clientX,x.current=(S=_.current)==null?void 0:S.offsetWidth,window.addEventListener("mousemove",C,!0)},[C]);return n.useEffect(()=>{const v=()=>{y.current=void 0,x.current=void 0,f&&re(w.current)&&f(w.current,g),window.removeEventListener("mousemove",C,!0)};return window.addEventListener("mouseup",v,!0),()=>{window.removeEventListener("mouseup",v,!0),window.removeEventListener("mousemove",C,!0)}},[C,g,f]),e.jsxs("th",{ref:_,className:N(a,tt.th),...b,children:[o&&e.jsx("div",{role:"presentation",className:tt.resizeHandle,onMouseDown:j}),h]})}const Va="_table_nilhy_1",za="_table-overflow-wrapper_nilhy_8",Ua="_table-element_nilhy_13",Wa="_header-row_nilhy_23",Qa="_header-element_nilhy_24",Za="_header-component_nilhy_29",ce={table:Va,tableOverflowWrapper:za,tableElement:Ua,headerRow:Wa,headerElement:Qa,headerComponent:Za};function qa(m,a){return a??m.columnWidth??wt}function A(m){const{data:a,keySelector:h,columns:o,caption:f,className:g,captionClassName:b,headerRowClassName:_,headerCellClassName:y,rowClassName:x,cellClassName:w,rowModifier:C,fixedColumnWidth:j,resizableColumn:v,headersHidden:S,pending:p,filtered:L,errored:I=!1}=m,R=n.useRef(null),[k]=he.useState(()=>bt()),[G,U]=he.useState({});n.useEffect(()=>{U(W=>{if(q(R.current))return W;const T=R.current.getBoundingClientRect(),{width:O}=T;let F=o.map(M=>({id:M.id,stretch:!!M.columnStretch,width:qa(M,W[M.id])}));const X=ye(F.filter(M=>M.stretch).map(M=>M.width)),ne=ye(F.filter(M=>!M.stretch).map(M=>M.width)),Y=(O-ne)/X;return Y>1&&(F=F.map(M=>({...M,width:M.stretch?M.width*Y:M.width}))),jt(F,M=>M.id,M=>M.width)})},[o]);const ie=he.useCallback((W,T)=>{const O=document.getElementById(`${k}-${T}`),F=Math.max(W,80);if(q(O)||(O.style.width=`${F}px`,!j))return;const X=document.getElementById(k);if(q(X))return;const ne=ye(o.map(Y=>Y.id===T?F:G[Y.id]));X.style.width=`${ne}px`},[k,G,o,j]),ae=he.useCallback((W,T)=>{re(T)&&U(O=>({...O,[T]:Math.max(W,80)}))},[U]),be=he.useMemo(()=>ye(o.map(W=>G[W.id])),[G,o]),K=q(a)||a.length===0||Object.keys(G).length===0;return e.jsxs("div",{ref:R,className:N(ce.table,g),children:[!K&&e.jsx("div",{className:ce.tableOverflowWrapper,children:e.jsxs("table",{className:ce.tableElement,style:j?{width:`${be}px`}:void 0,id:k,children:[f&&e.jsx("caption",{className:b,children:f}),e.jsx("colgroup",{children:o.map(W=>{const{id:T,columnClassName:O}=W,F=G[T],X=j?{width:`${F}px`}:void 0;return e.jsx("col",{id:`${k}-${T}`,style:X,className:N(ce.column,O)},T)})}),!S&&e.jsx("thead",{children:e.jsx(it,{className:N(ce.headerRow,_),children:o.map((W,T)=>{const{id:O,title:F,headerCellRenderer:X,headerCellRendererClassName:ne,headerCellRendererParams:Y,headerContainerClassName:M}=W,se=e.jsx(X,{...Y,name:O,title:F,index:T,className:N(ne,ce.headerComponent)});return e.jsx(Ha,{scope:"col",name:O,onResize:v?ie:void 0,onResizeComplete:v?ae:void 0,className:N(ce.headerElement,typeof y=="function"?y(O):y,M),children:se},O)})})}),e.jsx("tbody",{children:e.jsx(Aa,{data:a,keySelector:h,columns:o,rowClassName:x,cellClassName:w,rowModifier:C})})]})}),e.jsx(Nt,{filtered:L,empty:K,errored:I,pending:p,overlayPending:!0})]})}function Ga(m){const{className:a,value:h}=m;return q(h)?null:e.jsx("div",{className:a,children:h})}const Ya="common",Ka={sortTableButtonTitle:"Sort Table"},Xa={namespace:Ya,strings:Ka},Ja="_header-cell_vn24d_1",en="_sort-button_vn24d_8",tn="_icon_vn24d_12",an="_info-popup-icon_vn24d_17",de={headerCell:Ja,sortButton:en,icon:tn,infoPopupIcon:an};function ot(m){const{className:a,titleClassName:h,title:o,name:f,sortable:g,defaultSortDirection:b="asc",infoTitle:_,infoDescription:y}=m,{sorting:x,setSorting:w}=n.useContext(St),C=rt(Xa),j=x?.name===f?x.direction:void 0,v=n.useRef(null),S=n.useCallback(()=>{if(q(w))return;let p;q(j)?p=b:j==="asc"?p="dsc":j==="dsc"&&(p="asc"),w(p?{name:f,direction:p}:void 0)},[f,w,j,b]);return e.jsxs("div",{ref:v,className:N(a,de.headerCell),children:[g&&e.jsxs(Z,{name:void 0,variant:"tertiary",onClick:S,title:C.sortTableButtonTitle,className:de.sortButton,children:[q(j)&&e.jsx(Rt,{className:de.icon}),j==="asc"&&e.jsx(Lt,{className:de.icon}),j==="dsc"&&e.jsx(kt,{className:de.icon})]}),e.jsx("div",{className:N(h,de.title),children:o}),_&&y&&e.jsx(ca,{className:de.infoPopupIcon,title:_,description:y})]})}const at={};function Q(m,a,h,o){return{id:m,title:a,columnClassName:o?.columnClassName,headerCellRenderer:ot,headerCellRendererClassName:o?.headerCellRendererClassName,headerContainerClassName:o?.headerContainerClassName,headerCellRendererParams:{sortable:o?.sortable,infoTitle:o?.headerInfoTitle,infoDescription:o?.headerInfoDescription},cellRendererClassName:o?.cellRendererClassName,cellContainerClassName:o?.cellContainerClassName,cellRenderer:Ga,cellRendererParams:(f,g)=>({value:h(g)||"--"}),valueSelector:h,valueComparator:(f,g)=>Mt(h(f),h(g)),columnWidth:o?.columnWidth,columnStretch:o?.columnStretch,columnStyle:o?.columnStyle}}function E(m,a,h,o){return{id:m,title:a,columnClassName:o?.columnClassName,headerCellRenderer:ot,headerCellRendererClassName:N(at.numberCellHeader,o?.headerCellRendererClassName),headerContainerClassName:o?.headerContainerClassName,headerCellRendererParams:{sortable:o?.sortable,infoTitle:o?.headerInfoTitle,infoDescription:o?.headerInfoDescription},cellRendererClassName:N(at.numberCell,o?.cellRendererClassName),cellContainerClassName:o?.cellContainerClassName,cellRenderer:we,cellRendererParams:(f,g)=>({value:h(g),suffix:o?.suffix,maximumFractionDigits:o?.maximumFractionDigits,invalidText:"--"}),valueSelector:h,valueComparator:(f,g)=>It(h(f),h(g)),columnWidth:o?.columnWidth,columnStretch:o?.columnStretch,columnStyle:o?.columnStyle}}const nn="_tabSelector_vlxoe_1",sn="_progressSection_vlxoe_14",rn="_progressLabel_vlxoe_20",on="_chartGrid_vlxoe_28",ln="_chartContainer_vlxoe_40",cn="_tableContainer_vlxoe_51",dn="_modelPerformance_vlxoe_59",un="_loadingContainer_vlxoe_67",mn="_errorContainer_vlxoe_77",hn="_userInteractionCards_vlxoe_96",gn="_userInteractionCard_vlxoe_96",fn="_userInteractionCardValue_vlxoe_116",vn="_userInteractionCardLabel_vlxoe_123",pn="_userInteractionCardButton_vlxoe_130",xn="_summaryStatsCards_vlxoe_148",_n="_summaryStatsCard_vlxoe_148",Cn="_summaryStatsCardValue_vlxoe_169",yn="_summaryStatsCardLabel_vlxoe_176",l={tabSelector:nn,progressSection:sn,progressLabel:rn,chartGrid:on,chartContainer:ln,tableContainer:cn,modelPerformance:dn,loadingContainer:un,errorContainer:mn,userInteractionCards:hn,userInteractionCard:gn,userInteractionCardValue:fn,userInteractionCardLabel:vn,userInteractionCardButton:pn,summaryStatsCards:xn,summaryStatsCard:_n,summaryStatsCardValue:Cn,summaryStatsCardLabel:yn};function jn(){const[m]=Dt(),[a,h]=n.useState(null),[o,f]=n.useState(!0),[g,b]=n.useState("crisis_maps"),[_,y]=n.useState([]),[x,w]=n.useState([]),[C,j]=n.useState([]),[v,S]=n.useState([]),[p,L]=n.useState(!1),[I,R]=n.useState(!1),[k,G]=n.useState(!1),[U,ie]=n.useState(!1),[ae,be]=n.useState(!1),[K,W]=n.useState(!1),T=t=>{L(t==="editTime"),R(t==="percentage"),G(t==="delete"),ie(t==="regions"),be(t==="sources"),W(t==="types")},O=[{key:"crisis_maps",label:"Crisis Maps"},{key:"drone_images",label:"Drone Images"}],F=n.useCallback((t,c)=>{if(!t||!c)return 0;const d=t.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(u=>u.length>0),r=c.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(u=>u.length>0);if(d.length===0&&r.length===0)return 1;if(d.length===0||r.length===0)return 0;const s=new Set(d),i=new Set(r),D=new Set([...s].filter(u=>i.has(u))),$=new Set([...s,...i]);return D.size/$.size},[]),X=n.useCallback(async()=>{f(!0);try{const c=await(await fetch("/api/images")).json(),d={},r=c.filter(u=>u.image_type==="crisis_map"),s=c.filter(u=>u.image_type==="drone_image"),i={totalCaptions:c.length,sources:{},types:{},regions:{},models:{},modelEditTimes:d,percentageModified:0,modelPercentageData:{},totalDeleteCount:0,deleteRate:0,crisisMaps:r,droneImages:s};c.forEach(u=>{if(u.source&&(i.sources[u.source]=(i.sources[u.source]||0)+1),u.event_type&&(i.types[u.event_type]=(i.types[u.event_type]||0)+1),u.countries&&u.countries.forEach(P=>{P.r_code&&(i.regions[P.r_code]=(i.regions[P.r_code]||0)+1)}),u.model){const P=u.model,V=i.models[P]||={count:0,avgAccuracy:0,avgContext:0,avgUsability:0,totalScore:0,deleteCount:0};if(V.count++,u.accuracy!=null&&(V.avgAccuracy+=u.accuracy),u.context!=null&&(V.avgContext+=u.context),u.usability!=null&&(V.avgUsability+=u.usability),u.created_at&&u.updated_at){const te=new Date(u.created_at).getTime(),Ce=new Date(u.updated_at).getTime()-te;Ce>0&&(d[P]||(d[P]=[]),d[P].push(Ce))}}}),_.forEach(u=>{u.s_code&&!i.sources[u.s_code]&&(i.sources[u.s_code]=0)}),x.forEach(u=>{u.t_code&&!i.types[u.t_code]&&(i.types[u.t_code]=0)}),C.forEach(u=>{u.r_code&&!i.regions[u.r_code]&&(i.regions[u.r_code]=0)}),["GPT-4","Claude","Gemini","Llama","Other"].forEach(u=>{i.models[u]||(i.models[u]={count:0,avgAccuracy:0,avgContext:0,avgUsability:0,totalScore:0,deleteCount:0})}),Object.values(i.models).forEach(u=>{u.count>0&&(u.avgAccuracy=Math.round(u.avgAccuracy/u.count),u.avgContext=Math.round(u.avgContext/u.count),u.avgUsability=Math.round(u.avgUsability/u.count),u.totalScore=Math.round((u.avgAccuracy+u.avgContext+u.avgUsability)/3))});const $=c.filter(u=>u.generated&&u.edited);if($.length>0){const P=[...$.map(oe=>F(oe.generated,oe.edited))].sort((oe,Ce)=>oe-Ce),V=Math.floor(P.length/2),te=P.length%2===0?(P[V-1]+P[V])/2:P[V];i.percentageModified=Math.round((1-te)*100)}const H={};c.forEach(u=>{if(u.model&&u.generated&&u.edited){const P=F(u.generated,u.edited),V=Math.round((1-P)*100);H[u.model]||(H[u.model]=[]),H[u.model].push(V)}}),i.modelPercentageData=H;try{const u=await fetch("/api/models");if(u.ok){const P=await u.json();if(P.models){P.models.forEach(te=>{i.models[te.m_code]&&(i.models[te.m_code].deleteCount=te.delete_count||0)});const V=P.models.reduce((te,oe)=>te+(oe.delete_count||0),0);i.totalDeleteCount=V,i.deleteRate=V>0?Math.round(V/(V+c.length)*100):0}}}catch(u){console.log("Could not fetch model delete counts:",u)}h(i)}catch{h(null)}finally{f(!1)}},[_,x,C,F]),ne=n.useCallback(async()=>{try{const[t,c,d,r]=await Promise.all([fetch("/api/sources"),fetch("/api/types"),fetch("/api/regions"),fetch("/api/models")]),s=await t.json(),i=await c.json(),D=await d.json(),$=await r.json();y(s),w(i),j(D),S($.models||[])}catch(t){console.log("Could not fetch lookup data:",t)}},[]);n.useEffect(()=>{const t=m.get("view");(t==="crisis_maps"||t==="drone_images")&&b(t)},[m]),n.useEffect(()=>{ne()},[ne]),n.useEffect(()=>{_.length>0&&x.length>0&&C.length>0&&v.length>0&&X()},[_,x,C,v,X]);const Y=n.useCallback(t=>{const c=_.find(d=>d.s_code===t);return c?c.label:t},[_]),M=n.useCallback(t=>{if(t.length===0)return 0;const c=[...t].sort((r,s)=>r-s),d=Math.floor(c.length/2);return c.length%2===0?Math.round((c[d-1]+c[d])/2):c[d]},[]),se=n.useCallback(t=>{const c=Math.floor(t/1e3),d=Math.floor(c/60),r=Math.floor(d/60);return r>0?`${r}h ${d%60}m`:d>0?`${d}m ${c%60}s`:`${c}s`},[]),_e=n.useCallback(t=>{const c=x.find(d=>d.t_code===t);return c?c.label:t},[x]),J=n.useCallback(t=>{const c=v.find(d=>d.m_code===t);return c?c.label:t},[v]),Se=n.useMemo(()=>a?Object.entries(a.modelEditTimes||{}).filter(([,t])=>t.length>0).sort(([,t],[,c])=>M(c)-M(t)).map(([t,c],d)=>({id:d+1,name:J(t),count:c.length,avgEditTime:M(c),minEditTime:Math.min(...c),maxEditTime:Math.max(...c)})):[],[a,M,J]),Me=n.useMemo(()=>a?Object.entries(a.modelPercentageData||{}).filter(([,t])=>t.length>0).sort(([,t],[,c])=>{const d=[...t].sort((H,u)=>H-u),r=[...c].sort((H,u)=>H-u),s=Math.floor(d.length/2),i=Math.floor(r.length/2),D=d.length%2===0?(d[s-1]+d[s])/2:d[s];return(r.length%2===0?(r[i-1]+r[i])/2:r[i])-D}).map(([t,c],d)=>{const r=[...c].sort((D,$)=>D-$),s=Math.floor(r.length/2),i=r.length%2===0?Math.round((r[s-1]+r[s])/2):r[s];return{id:d+1,name:J(t),count:c.length,avgPercentageModified:i,minPercentageModified:Math.min(...c),maxPercentageModified:Math.max(...c)}}):[],[a,J]),Ie=n.useMemo(()=>a?Object.entries(a.models).filter(([t,c])=>c.count>0&&t!=="manual").map(([t,c],d)=>{const r=[c.avgAccuracy,c.avgContext,c.avgUsability],s=r.reduce(($,H)=>$+H,0)/r.length,i=r.reduce(($,H)=>$+Math.pow(H-s,2),0)/r.length,D=Math.round(100-Math.sqrt(i));return{id:d+1,name:J(t),consistency:Math.max(0,D),avgScore:Math.round(s),count:c.count}}).sort((t,c)=>c.consistency-t.consistency):[],[a,J]),De=n.useMemo(()=>[Q("name","Region",t=>t.name),E("count","Count",t=>t.count),E("percentage","% of Total",t=>t.percentage,{suffix:"%",maximumFractionDigits:0})],[]),Ee=n.useMemo(()=>[Q("name","Type",t=>t.name),E("count","Count",t=>t.count),E("percentage","% of Total",t=>t.percentage,{suffix:"%",maximumFractionDigits:0})],[]),lt=n.useMemo(()=>[Q("name","Source",t=>t.name),E("count","Count",t=>t.count),E("percentage","% of Total",t=>t.percentage,{suffix:"%",maximumFractionDigits:0})],[]),Te=n.useMemo(()=>[Q("name","Model",t=>t.name),E("count","Count",t=>t.count),E("accuracy","Accuracy",t=>t.accuracy,{suffix:"%",maximumFractionDigits:0}),E("context","Context",t=>t.context,{suffix:"%",maximumFractionDigits:0}),E("usability","Usability",t=>t.usability,{suffix:"%",maximumFractionDigits:0}),E("totalScore","Total Score",t=>t.totalScore,{suffix:"%",maximumFractionDigits:0})],[]),ke=n.useMemo(()=>[Q("name","Model",t=>t.name),E("count","Count",t=>t.count),Q("avgEditTime","Median Edit Time",t=>se(t.avgEditTime)),Q("minEditTime","Min Edit Time",t=>se(t.minEditTime)),Q("maxEditTime","Max Edit Time",t=>se(t.maxEditTime))],[se]),Le=n.useMemo(()=>[Q("name","Model",t=>t.name),E("count","Count",t=>t.count),E("avgPercentageModified","Median % Modified",t=>t.avgPercentageModified,{suffix:"%",maximumFractionDigits:0}),E("minPercentageModified","Min % Modified",t=>t.minPercentageModified,{suffix:"%",maximumFractionDigits:0}),E("maxPercentageModified","Max % Modified",t=>t.maxPercentageModified,{suffix:"%",maximumFractionDigits:0})],[]),Pe=n.useMemo(()=>[Q("name","Model",t=>t.name),E("count","Total Count",t=>t.count),E("deleteCount","Delete Count",t=>t.deleteCount),E("deleteRate","Delete Rate",t=>t.deleteRate,{suffix:"%",maximumFractionDigits:1})],[]),ct=n.useMemo(()=>[Q("source","Source",t=>t.source),E("avgQuality","Average Quality",t=>t.avgQuality,{suffix:"%",maximumFractionDigits:0}),E("count","Count",t=>t.count)],[]),Re=n.useMemo(()=>[Q("eventType","Event Type",t=>t.eventType),E("avgQuality","Average Quality",t=>t.avgQuality,{suffix:"%",maximumFractionDigits:0}),E("count","Count",t=>t.count)],[]),$e=n.useMemo(()=>[Q("name","Model",t=>t.name),E("consistency","Consistency",t=>t.consistency,{suffix:"%",maximumFractionDigits:0}),E("avgScore","Average Score",t=>t.avgScore,{suffix:"%",maximumFractionDigits:0}),E("count","Count",t=>t.count)],[]),ue=n.useCallback(t=>a?t==="crisis_map"?a.crisisMaps.length:t==="drone_image"?a.droneImages.length:0:0,[a]),Be=n.useCallback(t=>{if(!a)return[];const c=t==="crisis_map"?a.crisisMaps:a.droneImages,d={};return c.forEach(r=>{r.countries&&r.countries.forEach(s=>{s.r_code&&(d[s.r_code]=(d[s.r_code]||0)+1)})}),Object.entries(d).filter(([,r])=>r>0).map(([r,s])=>({name:C.find(i=>i.r_code===r)?.label||r,value:s}))},[a,C]),Ae=n.useCallback(t=>{if(!a)return[];const c=t==="crisis_map"?a.crisisMaps:a.droneImages,d={};c.forEach(s=>{s.countries&&s.countries.forEach(i=>{i.r_code&&(d[i.r_code]=(d[i.r_code]||0)+1)})});const r=C.reduce((s,i)=>(i.r_code&&(s[i.r_code]={name:i.label,count:d[i.r_code]||0}),s),{});return Object.entries(r).sort(([,s],[,i])=>i.count-s.count).map(([,{name:s,count:i}],D)=>({id:D+1,name:s,count:i,percentage:c.length>0?Math.round(i/c.length*100):0}))},[a,C]),dt=n.useCallback(t=>{if(!a)return[];const c=t==="crisis_map"?a.crisisMaps:a.droneImages,d={};return c.forEach(r=>{r.source&&(d[r.source]=(d[r.source]||0)+1)}),Object.entries(d).filter(([,r])=>r>0).map(([r,s])=>({name:_.find(i=>i.s_code===r)?.label||r,value:s}))},[a,_]),ut=n.useCallback(t=>{if(!a)return[];const c=t==="crisis_map"?a.crisisMaps:a.droneImages,d={};return c.forEach(r=>{r.source&&(d[r.source]=(d[r.source]||0)+1)}),Object.entries(d).sort(([,r],[,s])=>s-r).map(([r,s],i)=>({id:i+1,name:Y(r),count:s,percentage:c.length>0?Math.round(s/c.length*100):0}))},[a,Y]),Fe=n.useCallback(t=>{if(!a)return[];const c=t==="crisis_map"?a.crisisMaps:a.droneImages,d={};return c.forEach(r=>{r.event_type&&(d[r.event_type]=(d[r.event_type]||0)+1)}),Object.entries(d).filter(([,r])=>r>0).map(([r,s])=>({name:x.find(i=>i.t_code===r)?.label||r,value:s}))},[a,x]),Oe=n.useCallback(t=>{if(!a)return[];const c=t==="crisis_map"?a.crisisMaps:a.droneImages,d={};return c.forEach(r=>{r.event_type&&(d[r.event_type]=(d[r.event_type]||0)+1)}),Object.entries(d).sort(([,r],[,s])=>s-r).map(([r,s],i)=>({id:i+1,name:_e(r),count:s,percentage:c.length>0?Math.round(s/c.length*100):0}))},[a,_e]),He=n.useCallback(t=>{if(!a)return"No data available";const c=t==="crisis_map"?a.crisisMaps:a.droneImages,d=new Set;c.forEach(i=>{i.model&&d.add(i.model)}),console.log(`Debug ${t}:`,{totalImages:c.length,usedModels:Array.from(d),availableEditTimes:Object.keys(a.modelEditTimes),modelEditTimesData:a.modelEditTimes});const s=Object.entries(a.modelEditTimes).filter(([i])=>d.has(i)).flatMap(([,i])=>i);return s.length===0?"No data available":se(M(s))},[a,se,M]),Ve=n.useCallback(()=>{if(!a)return"No data available";const t=a.totalCaptions||0,c=a.percentageModified||0;return t>0?Math.round(c/t*100):0},[a]),ze=n.useCallback(()=>a&&a.deleteRate>=0?`${a.deleteRate}%`:"No data available",[a]),Ue=n.useCallback(t=>{if(!a)return[];const c=t==="crisis_map"?a.crisisMaps:a.droneImages,d=new Set;return c.forEach(s=>{s.model&&d.add(s.model)}),Se.filter(s=>{const i=v.find(D=>D.label===s.name)?.m_code;return i&&d.has(i)})},[a,Se,v]),We=n.useCallback(t=>{if(!a)return[];const c=t==="crisis_map"?a.crisisMaps:a.droneImages,d=new Set;return c.forEach(s=>{s.model&&d.add(s.model)}),Me.filter(s=>{const i=v.find(D=>D.label===s.name)?.m_code;return i&&d.has(i)})},[a,Me,v]),Qe=n.useCallback(t=>{if(!a)return[];const c=t==="crisis_map"?a.crisisMaps:a.droneImages,d={};return c.forEach(r=>{r.model&&(d[r.model]||(d[r.model]={count:0,deleteCount:0}),d[r.model].count++)}),Object.entries(d).map(([r,s],i)=>{const $=a.models?.[r]?.deleteCount||0,H=s.count>0?Math.round($/s.count*100*10)/10:0;return{id:i+1,name:J(r),count:s.count,deleteCount:$,deleteRate:H}}).sort((r,s)=>s.count-r.count)},[a,J]),Ze=n.useCallback(t=>{if(!a)return[];const d=(t==="crisis_map"?a.crisisMaps:a.droneImages).filter(s=>s.model!=="manual"),r={};return d.forEach(s=>{s.model&&(r[s.model]||(r[s.model]={count:0,totalAccuracy:0,totalContext:0,totalUsability:0}),r[s.model].count++,s.accuracy!=null&&(r[s.model].totalAccuracy+=s.accuracy),s.context!=null&&(r[s.model].totalContext+=s.context),s.usability!=null&&(r[s.model].totalUsability+=s.usability))}),Object.entries(r).map(([s,i],D)=>({id:D+1,name:J(s),count:i.count,accuracy:i.count>0?Math.round(i.totalAccuracy/i.count):0,context:i.count>0?Math.round(i.totalContext/i.count):0,usability:i.count>0?Math.round(i.totalUsability/i.count):0,totalScore:i.count>0?Math.round((i.totalAccuracy+i.totalContext+i.totalUsability)/(3*i.count)):0})).sort((s,i)=>i.totalScore-s.totalScore)},[a,J]),mt=n.useCallback(t=>{if(!a)return[];const d=(t==="crisis_map"?a.crisisMaps:a.droneImages).filter(s=>s.model!=="manual"),r={};return d.forEach(s=>{s.source&&(r[s.source]||(r[s.source]={total:0,count:0,totalImages:0}),r[s.source].totalImages+=1,s.accuracy!=null&&(r[s.source].total+=s.accuracy,r[s.source].count+=1))}),Object.entries(r).map(([s,i],D)=>({id:D+1,source:Y(s),avgQuality:i.count>0?Math.round(i.total/i.count):0,count:i.totalImages}))},[a,Y]),qe=n.useCallback(t=>{if(!a)return[];const d=(t==="crisis_map"?a.crisisMaps:a.droneImages).filter(s=>s.model!=="manual"),r={};return d.forEach(s=>{s.event_type&&(r[s.event_type]||(r[s.event_type]={total:0,count:0,totalImages:0}),r[s.event_type].totalImages+=1,s.accuracy!=null&&(r[s.event_type].total+=s.accuracy,r[s.event_type].count+=1))}),Object.entries(r).map(([s,i],D)=>({id:D+1,eventType:_e(s),avgQuality:i.count>0?Math.round(i.total/i.count):0,count:i.totalImages}))},[a,_e]),Ge=n.useCallback(t=>{if(!a)return[];const d=(t==="crisis_map"?a.crisisMaps:a.droneImages).filter(i=>i.model!=="manual"),r=new Set;return d.forEach(i=>{i.model&&r.add(i.model)}),Ie.filter(i=>{const D=v.find($=>$.label===i.name)?.m_code;return D&&D!=="manual"&&r.has(D)})},[a,Ie,v]);if(o)return e.jsx(je,{children:e.jsx("div",{className:l.loadingContainer,children:e.jsx(Et,{})})});if(!a)return e.jsx(je,{children:e.jsx("div",{className:l.errorContainer,children:e.jsx("div",{className:"text-red-500",children:"Failed to load analytics data. Please try again."})})});const me=["#F5333F","#F64752","#F75C65","#F87079","#F9858C","#FA999F","#FBADB2","#FCC2C5"];return e.jsx(je,{children:e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsx("div",{className:l.tabSelector,children:e.jsx(Tt,{name:"analytics-view",value:g,onChange:t=>{(t==="crisis_maps"||t==="drone_images")&&b(t)},options:O,keySelector:t=>t.key,labelSelector:t=>t.label})}),g==="crisis_maps"?e.jsxs("div",{className:l.chartGrid,children:[e.jsxs(z,{heading:"Summary Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:l.summaryStatsCards,children:[e.jsxs("div",{className:l.summaryStatsCard,children:[e.jsx("div",{className:l.summaryStatsCardValue,children:ue("crisis_map")}),e.jsx("div",{className:l.summaryStatsCardLabel,children:"Total Crisis Maps"})]}),e.jsxs("div",{className:l.summaryStatsCard,children:[e.jsx("div",{className:l.summaryStatsCardValue,children:"2000"}),e.jsx("div",{className:l.summaryStatsCardLabel,children:"Target Amount"})]})]}),e.jsxs("div",{className:l.progressSection,children:[e.jsxs("div",{className:l.progressLabel,children:[e.jsx("span",{children:"Progress towards target"}),e.jsxs("span",{children:[Math.round(ue("crisis_map")/2e3*100),"%"]})]}),e.jsx(Ye,{value:ue("crisis_map"),totalValue:2e3})]})]}),e.jsxs(z,{heading:"Distribution Analysis",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:l.userInteractionCards,children:[e.jsxs("div",{className:l.userInteractionCard,children:[e.jsx("div",{className:l.userInteractionCardLabel,children:"Regions Distribution"}),e.jsx("div",{className:l.chartContainer,children:e.jsx(xe,{data:Be("crisis_map"),valueSelector:t=>t.value,labelSelector:t=>t.name,keySelector:t=>t.name,colors:me,showPercentageInLegend:!0})}),e.jsx(Z,{name:"view-regions-details",variant:U?"primary":"secondary",onClick:()=>T(U?"none":"regions"),className:l.userInteractionCardButton,children:U?"Hide Details":"View Details"})]}),e.jsxs("div",{className:l.userInteractionCard,children:[e.jsx("div",{className:l.userInteractionCardLabel,children:"Sources Distribution"}),e.jsx("div",{className:l.chartContainer,children:e.jsx(xe,{data:dt("crisis_map"),valueSelector:t=>t.value,labelSelector:t=>t.name,keySelector:t=>t.name,colors:me,showPercentageInLegend:!0})}),e.jsx(Z,{name:"view-sources-details",variant:ae?"primary":"secondary",onClick:()=>T(ae?"none":"sources"),className:l.userInteractionCardButton,children:ae?"Hide Details":"View Details"})]}),e.jsxs("div",{className:l.userInteractionCard,children:[e.jsx("div",{className:l.userInteractionCardLabel,children:"Types Distribution"}),e.jsx("div",{className:l.chartContainer,children:e.jsx(xe,{data:Fe("crisis_map"),valueSelector:t=>t.value,labelSelector:t=>t.name,keySelector:t=>t.name,colors:me,showPercentageInLegend:!0})}),e.jsx(Z,{name:"view-types-details",variant:K?"primary":"secondary",onClick:()=>T(K?"none":"types"),className:l.userInteractionCardButton,children:K?"Hide Details":"View Details"})]})]}),U&&e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:Ae("crisis_map"),columns:De,keySelector:B,filtered:!1,pending:!1})}),ae&&e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:ut("crisis_map"),columns:lt,keySelector:B,filtered:!1,pending:!1})}),K&&e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:Oe("crisis_map"),columns:Ee,keySelector:B,filtered:!1,pending:!1})})]}),e.jsxs(z,{heading:"User Interaction Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:l.userInteractionCards,children:[e.jsxs("div",{className:l.userInteractionCard,children:[e.jsx("div",{className:l.userInteractionCardValue,children:He("crisis_map")}),e.jsx("div",{className:l.userInteractionCardLabel,children:"Median Edit Time"}),e.jsx(Z,{name:"view-edit-time-details",variant:p?"primary":"secondary",onClick:()=>T(p?"none":"editTime"),className:l.userInteractionCardButton,children:p?"Hide Details":"View Details"})]}),e.jsxs("div",{className:l.userInteractionCard,children:[e.jsx("div",{className:l.userInteractionCardValue,children:Ve()}),e.jsx("div",{className:l.userInteractionCardLabel,children:"Median % Modified"}),e.jsx(Z,{name:"view-percentage-details",variant:I?"primary":"secondary",onClick:()=>T(I?"none":"percentage"),className:l.userInteractionCardButton,children:I?"Hide Details":"View Details"})]}),e.jsxs("div",{className:l.userInteractionCard,children:[e.jsx("div",{className:l.userInteractionCardValue,children:ze()}),e.jsx("div",{className:l.userInteractionCardLabel,children:"Delete Rate"}),e.jsx(Z,{name:"view-delete-details",variant:k?"primary":"secondary",onClick:()=>T(k?"none":"delete"),className:l.userInteractionCardButton,children:k?"Hide Details":"View Details"})]})]}),p&&e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:Ue("crisis_map"),columns:ke,keySelector:B,filtered:!1,pending:!1})}),I&&e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:We("crisis_map"),columns:Le,keySelector:B,filtered:!1,pending:!1})}),k&&e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:Qe("crisis_map"),columns:Pe,keySelector:B,filtered:!1,pending:!1})})]}),e.jsx(z,{heading:"Model Performance",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:Ze("crisis_map"),columns:Te,keySelector:B,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Quality-Source Correlation",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:l.tableContainer,children:e.jsx(A,{data:mt("crisis_map"),columns:ct,keySelector:B,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Quality-Event Type Correlation",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:l.tableContainer,children:e.jsx(A,{data:qe("crisis_map"),columns:Re,keySelector:B,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Model Consistency Analysis",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:l.tableContainer,children:e.jsx(A,{data:Ge("crisis_map"),columns:$e,keySelector:B,filtered:!1,pending:!1})})})]}):e.jsxs("div",{className:l.chartGrid,children:[e.jsxs(z,{heading:"Summary Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:l.summaryStatsCards,children:[e.jsxs("div",{className:l.summaryStatsCard,children:[e.jsx("div",{className:l.summaryStatsCardValue,children:ue("drone_image")}),e.jsx("div",{className:l.summaryStatsCardLabel,children:"Total Drone Images"})]}),e.jsxs("div",{className:l.summaryStatsCard,children:[e.jsx("div",{className:l.summaryStatsCardValue,children:"2000"}),e.jsx("div",{className:l.summaryStatsCardLabel,children:"Target Amount"})]})]}),e.jsxs("div",{className:l.progressSection,children:[e.jsxs("div",{className:l.progressLabel,children:[e.jsx("span",{children:"Progress towards target"}),e.jsxs("span",{children:[Math.round(ue("drone_image")/2e3*100),"%"]})]}),e.jsx(Ye,{value:ue("drone_image"),totalValue:2e3})]})]}),e.jsxs(z,{heading:"Distribution Analysis",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:l.userInteractionCards,children:[e.jsxs("div",{className:l.userInteractionCard,children:[e.jsx("div",{className:l.userInteractionCardLabel,children:"Regions Distribution"}),e.jsx("div",{className:l.chartContainer,children:e.jsx(xe,{data:Be("drone_image"),valueSelector:t=>t.value,labelSelector:t=>t.name,keySelector:t=>t.name,colors:me,showPercentageInLegend:!0})}),e.jsx(Z,{name:"view-regions-details",variant:U?"primary":"secondary",onClick:()=>T(U?"none":"regions"),className:l.userInteractionCardButton,children:U?"Hide Details":"View Details"})]}),e.jsxs("div",{className:l.userInteractionCard,children:[e.jsx("div",{className:l.userInteractionCardLabel,children:"Types Distribution"}),e.jsx("div",{className:l.chartContainer,children:e.jsx(xe,{data:Fe("drone_image"),valueSelector:t=>t.value,labelSelector:t=>t.name,keySelector:t=>t.name,colors:me,showPercentageInLegend:!0})}),e.jsx(Z,{name:"view-types-details",variant:K?"primary":"secondary",onClick:()=>T(K?"none":"types"),className:l.userInteractionCardButton,children:K?"Hide Details":"View Details"})]})]}),U&&e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:Ae("drone_image"),columns:De,keySelector:B,filtered:!1,pending:!1})}),K&&e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:Oe("drone_image"),columns:Ee,keySelector:B,filtered:!1,pending:!1})})]}),e.jsxs(z,{heading:"User Interaction Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:l.userInteractionCards,children:[e.jsxs("div",{className:l.userInteractionCard,children:[e.jsx("div",{className:l.userInteractionCardValue,children:He("drone_image")}),e.jsx("div",{className:l.userInteractionCardLabel,children:"Median Edit Time"}),e.jsx(Z,{name:"view-edit-time-details",variant:p?"primary":"secondary",onClick:()=>T(p?"none":"editTime"),className:l.userInteractionCardButton,children:p?"Hide Details":"View Details"})]}),e.jsxs("div",{className:l.userInteractionCard,children:[e.jsx("div",{className:l.userInteractionCardValue,children:Ve()}),e.jsx("div",{className:l.userInteractionCardLabel,children:"Median % Modified"}),e.jsx(Z,{name:"view-percentage-details",variant:I?"primary":"secondary",onClick:()=>T(I?"none":"percentage"),className:l.userInteractionCardButton,children:I?"Hide Details":"View Details"})]}),e.jsxs("div",{className:l.userInteractionCard,children:[e.jsx("div",{className:l.userInteractionCardValue,children:ze()}),e.jsx("div",{className:l.userInteractionCardLabel,children:"Delete Rate"}),e.jsx(Z,{name:"view-delete-details",variant:k?"primary":"secondary",onClick:()=>T(k?"none":"delete"),className:l.userInteractionCardButton,children:k?"Hide Details":"View Details"})]})]}),p&&e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:Ue("drone_image"),columns:ke,keySelector:B,filtered:!1,pending:!1})}),I&&e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:We("drone_image"),columns:Le,keySelector:B,filtered:!1,pending:!1})}),k&&e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:Qe("drone_image"),columns:Pe,keySelector:B,filtered:!1,pending:!1})})]}),e.jsx(z,{heading:"Model Performance",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:l.modelPerformance,children:e.jsx(A,{data:Ze("drone_image"),columns:Te,keySelector:B,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Quality-Event Type Correlation",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:l.tableContainer,children:e.jsx(A,{data:qe("drone_image"),columns:Re,keySelector:B,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Model Consistency Analysis",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:l.tableContainer,children:e.jsx(A,{data:Ge("drone_image"),columns:$e,keySelector:B,filtered:!1,pending:!1})})})]})]})})}export{jn as default}; diff --git a/py_backend/static/assets/index-Dym8TuvV.js b/py_backend/static/assets/index-C5rMGfs8.js similarity index 99% rename from py_backend/static/assets/index-Dym8TuvV.js rename to py_backend/static/assets/index-C5rMGfs8.js index db96caf0..695a3617 100644 --- a/py_backend/static/assets/index-Dym8TuvV.js +++ b/py_backend/static/assets/index-C5rMGfs8.js @@ -1,4 +1,4 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DRmfVC9B.js","assets/index-B1uKTNcW.css","assets/index-tBgmM5yL.js","assets/useAdmin-DnFl9FMw.js","assets/ExportModal-Bq4gp-iF.js","assets/ExportModal-BoB3JpqO.css","assets/index-C85X4vtS.css","assets/AdminPage-CwitwbVg.js","assets/AdminPage-VgSjQ50W.css","assets/index-HD7t9Ly0.js","assets/index-tDgjKyWF.css"])))=>i.map(i=>d[i]); +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-C5czLj7d.js","assets/index-B1uKTNcW.css","assets/index-DRlHhE1W.js","assets/useAdmin-B8fo0TJy.js","assets/ExportModal-DJxQWbes.js","assets/ExportModal-BoB3JpqO.css","assets/index-C85X4vtS.css","assets/AdminPage-BZgg3d6P.js","assets/AdminPage-VgSjQ50W.css","assets/index-uy9sc-W4.js","assets/index-tDgjKyWF.css"])))=>i.map(i=>d[i]); function Jg(e,n){for(var i=0;io[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))o(s);new MutationObserver(s=>{for(const u of s)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function i(s){const u={};return s.integrity&&(u.integrity=s.integrity),s.referrerPolicy&&(u.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?u.credentials="include":s.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function o(s){if(s.ep)return;s.ep=!0;const u=i(s);fetch(s.href,u)}})();var fL=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function e0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ld={exports:{}},Za={},ud={exports:{}},We={};/** * @license React * react.production.min.js @@ -143,7 +143,7 @@ Error generating stack: `+p.message+` `),this.css+=n+"/*# sourceMappingURL="+e+" */"}applyPrevMaps(){for(let e of this.previous()){let n=this.toUrl(this.path(e.file)),i=e.root||ou(e.file),o;this.mapOpts.sourcesContent===!1?(o=new uy(e.text),o.sourcesContent&&(o.sourcesContent=null)):o=e.consumer(),this.map.applySourceMap(o,n,this.toUrl(this.path(i)))}}clearAnnotation(){if(this.mapOpts.annotation!==!1)if(this.root){let e;for(let n=this.root.nodes.length-1;n>=0;n--)e=this.root.nodes[n],e.type==="comment"&&e.text.startsWith("# sourceMappingURL=")&&this.root.removeChild(n)}else this.css&&(this.css=this.css.replace(/\n*\/\*#[\S\s]*?\*\/$/gm,""))}generate(){if(this.clearAnnotation(),Vk&&Hk&&this.isMap())return this.generateMap();{let e="";return this.stringify(this.root,n=>{e+=n}),[e]}}generateMap(){if(this.root)this.generateString();else if(this.previous().length===1){let e=this.previous()[0].consumer();e.file=this.outputFile(),this.map=au.fromSourceMap(e,{ignoreInvalidMapping:!0})}else this.map=new au({file:this.outputFile(),ignoreInvalidMapping:!0}),this.map.addMapping({generated:{column:0,line:1},original:{column:0,line:1},source:this.opts.from?this.toUrl(this.path(this.opts.from)):""});return this.isSourcesContent()&&this.setSourcesContent(),this.root&&this.previous().length>0&&this.applyPrevMaps(),this.isAnnotation()&&this.addAnnotation(),this.isInline()?[this.css]:[this.css,this.map]}generateString(){this.css="",this.map=new au({file:this.outputFile(),ignoreInvalidMapping:!0});let e=1,n=1,i="",o={generated:{column:0,line:0},original:{column:0,line:0},source:""},s,u;this.stringify(this.root,(d,f,g)=>{if(this.css+=d,f&&g!=="end"&&(o.generated.line=e,o.generated.column=n-1,f.source&&f.source.start?(o.source=this.sourcePath(f),o.original.line=f.source.start.line,o.original.column=f.source.start.column-1,this.map.addMapping(o)):(o.source=i,o.original.line=1,o.original.column=0,this.map.addMapping(o))),u=d.match(/\n/g),u?(e+=u.length,s=d.lastIndexOf(` `),n=d.length-s):n+=d.length,f&&g!=="start"){let y=f.parent||{raws:{}};(!(f.type==="decl"||f.type==="atrule"&&!f.nodes)||f!==y.last||y.raws.semicolon)&&(f.source&&f.source.end?(o.source=this.sourcePath(f),o.original.line=f.source.end.line,o.original.column=f.source.end.column-1,o.generated.line=e,o.generated.column=n-2,this.map.addMapping(o)):(o.source=i,o.original.line=1,o.original.column=0,o.generated.line=e,o.generated.column=n-1,this.map.addMapping(o)))}})}isAnnotation(){return this.isInline()?!0:typeof this.mapOpts.annotation<"u"?this.mapOpts.annotation:this.previous().length?this.previous().some(e=>e.annotation):!0}isInline(){if(typeof this.mapOpts.inline<"u")return this.mapOpts.inline;let e=this.mapOpts.annotation;return typeof e<"u"&&e!==!0?!1:this.previous().length?this.previous().some(n=>n.inline):!0}isMap(){return typeof this.opts.map<"u"?!!this.opts.map:this.previous().length>0}isSourcesContent(){return typeof this.mapOpts.sourcesContent<"u"?this.mapOpts.sourcesContent:this.previous().length?this.previous().some(e=>e.withContent()):!0}outputFile(){return this.opts.to?this.path(this.opts.to):this.opts.from?this.path(this.opts.from):"to.css"}path(e){if(this.mapOpts.absolute||e.charCodeAt(0)===60||/^\w+:\/\//.test(e))return e;let n=this.memoizedPaths.get(e);if(n)return n;let i=this.opts.to?ou(this.opts.to):".";typeof this.mapOpts.annotation=="string"&&(i=ou(sy(i,this.mapOpts.annotation)));let o=ay(i,e);return this.memoizedPaths.set(e,o),o}previous(){if(!this.previousMaps)if(this.previousMaps=[],this.root)this.root.walk(e=>{if(e.source&&e.source.input.map){let n=e.source.input.map;this.previousMaps.includes(n)||this.previousMaps.push(n)}});else{let e=new Uk(this.originalCSS,this.opts);e.map&&this.previousMaps.push(e.map)}return this.previousMaps}setSourcesContent(){let e={};if(this.root)this.root.walk(n=>{if(n.source){let i=n.source.input.from;if(i&&!e[i]){e[i]=!0;let o=this.usesFileUrls?this.toFileUrl(i):this.toUrl(this.path(i));this.map.setSourceContent(o,n.source.input.css)}}});else if(this.css){let n=this.opts.from?this.toUrl(this.path(this.opts.from)):"";this.map.setSourceContent(n,this.css)}}sourcePath(e){return this.mapOpts.from?this.toUrl(this.mapOpts.from):this.usesFileUrls?this.toFileUrl(e.source.input.from):this.toUrl(this.path(e.source.input.from))}toBase64(e){return Buffer?Buffer.from(e).toString("base64"):window.btoa(unescape(encodeURIComponent(e)))}toFileUrl(e){let n=this.memoizedFileURLs.get(e);if(n)return n;if(Rg){let i=Rg(e).toString();return this.memoizedFileURLs.set(e,i),i}else throw new Error("`map.absolute` option is not available in this PostCSS build")}toUrl(e){let n=this.memoizedURLs.get(e);if(n)return n;ly==="\\"&&(e=e.replace(/\\/g,"/"));let i=encodeURI(e).replace(/[#?]/g,encodeURIComponent);return this.memoizedURLs.set(e,i),i}};var cy=qk;const Od=39,Ag=34,Wl=92,$g=47,Gl=10,rs=32,Zl=12,Ql=9,Kl=13,Wk=91,Gk=93,Zk=40,Qk=41,Kk=123,Yk=125,Xk=59,Jk=42,ej=58,tj=64,Yl=/[\t\n\f\r "#'()/;[\\\]{}]/g,Xl=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,nj=/.[\r\n"'(/\\]/,Fg=/[\da-f]/i;var rj=function(e,n={}){let i=e.css.valueOf(),o=n.ignoreErrors,s,u,d,f,g,y,x,b,m,w,N=i.length,S=0,_=[],T=[];function M(){return S}function $(O){throw e.error("Unclosed "+O,S)}function F(){return T.length===0&&S>=N}function W(O){if(T.length)return T.pop();if(S>=N)return;let K=O?O.ignoreUnclosed:!1;switch(s=i.charCodeAt(S),s){case Gl:case rs:case Ql:case Kl:case Zl:{f=S;do f+=1,s=i.charCodeAt(f);while(s===rs||s===Gl||s===Ql||s===Kl||s===Zl);y=["space",i.slice(S,f)],S=f-1;break}case Wk:case Gk:case Kk:case Yk:case ej:case Xk:case Qk:{let de=String.fromCharCode(s);y=[de,de,S];break}case Zk:{if(w=_.length?_.pop()[1]:"",m=i.charCodeAt(S+1),w==="url"&&m!==Od&&m!==Ag&&m!==rs&&m!==Gl&&m!==Ql&&m!==Zl&&m!==Kl){f=S;do{if(x=!1,f=i.indexOf(")",f+1),f===-1)if(o||K){f=S;break}else $("bracket");for(b=f;i.charCodeAt(b-1)===Wl;)b-=1,x=!x}while(x);y=["brackets",i.slice(S,f+1),S,f],S=f}else f=i.indexOf(")",S+1),u=i.slice(S,f+1),f===-1||nj.test(u)?y=["(","(",S]:(y=["brackets",u,S,f],S=f);break}case Od:case Ag:{g=s===Od?"'":'"',f=S;do{if(x=!1,f=i.indexOf(g,f+1),f===-1)if(o||K){f=S+1;break}else $("string");for(b=f;i.charCodeAt(b-1)===Wl;)b-=1,x=!x}while(x);y=["string",i.slice(S,f+1),S,f],S=f;break}case tj:{Yl.lastIndex=S+1,Yl.test(i),Yl.lastIndex===0?f=i.length-1:f=Yl.lastIndex-2,y=["at-word",i.slice(S,f+1),S,f],S=f;break}case Wl:{for(f=S,d=!0;i.charCodeAt(f+1)===Wl;)f+=1,d=!d;if(s=i.charCodeAt(f+1),d&&s!==$g&&s!==rs&&s!==Gl&&s!==Ql&&s!==Kl&&s!==Zl&&(f+=1,Fg.test(i.charAt(f)))){for(;Fg.test(i.charAt(f+1));)f+=1;i.charCodeAt(f+1)===rs&&(f+=1)}y=["word",i.slice(S,f+1),S,f],S=f;break}default:{s===$g&&i.charCodeAt(S+1)===Jk?(f=i.indexOf("*/",S+2)+1,f===0&&(o||K?f=i.length:$("comment")),y=["comment",i.slice(S,f+1),S,f],S=f):(Xl.lastIndex=S+1,Xl.test(i),Xl.lastIndex===0?f=i.length-1:f=Xl.lastIndex-2,y=["word",i.slice(S,f+1),S,f],_.push(y),S=f);break}}return S++,y}function fe(O){T.push(O)}return{back:fe,endOfFile:F,nextToken:W,position:M}};let ij=rh,oj=Mu,aj=Du,sj=Os,zg=oh,lj=rj;const Bg={empty:!0,space:!0};function uj(e){for(let n=e.length-1;n>=0;n--){let i=e[n],o=i[3]||i[2];if(o)return o}}let cj=class{constructor(e){this.input=e,this.root=new sj,this.current=this.root,this.spaces="",this.semicolon=!1,this.createTokenizer(),this.root.source={input:e,start:{column:1,line:1,offset:0}}}atrule(e){let n=new ij;n.name=e[1].slice(1),n.name===""&&this.unnamedAtrule(n,e),this.init(n,e[2]);let i,o,s,u=!1,d=!1,f=[],g=[];for(;!this.tokenizer.endOfFile();){if(e=this.tokenizer.nextToken(),i=e[0],i==="("||i==="["?g.push(i==="("?")":"]"):i==="{"&&g.length>0?g.push("}"):i===g[g.length-1]&&g.pop(),g.length===0)if(i===";"){n.source.end=this.getPosition(e[2]),n.source.end.offset++,this.semicolon=!0;break}else if(i==="{"){d=!0;break}else if(i==="}"){if(f.length>0){for(s=f.length-1,o=f[s];o&&o[0]==="space";)o=f[--s];o&&(n.source.end=this.getPosition(o[3]||o[2]),n.source.end.offset++)}this.end(e);break}else f.push(e);else f.push(e);if(this.tokenizer.endOfFile()){u=!0;break}}n.raws.between=this.spacesAndCommentsFromEnd(f),f.length?(n.raws.afterName=this.spacesAndCommentsFromStart(f),this.raw(n,"params",f),u&&(e=f[f.length-1],n.source.end=this.getPosition(e[3]||e[2]),n.source.end.offset++,this.spaces=n.raws.between,n.raws.between="")):(n.raws.afterName="",n.params=""),d&&(n.nodes=[],this.current=n)}checkMissedSemicolon(e){let n=this.colon(e);if(n===!1)return;let i=0,o;for(let s=n-1;s>=0&&(o=e[s],!(o[0]!=="space"&&(i+=1,i===2)));s--);throw this.input.error("Missed semicolon",o[0]==="word"?o[3]+1:o[2])}colon(e){let n=0,i,o,s;for(let[u,d]of e.entries()){if(o=d,s=o[0],s==="("&&(n+=1),s===")"&&(n-=1),n===0&&s===":")if(!i)this.doubleColon(o);else{if(i[0]==="word"&&i[1]==="progid")continue;return u}i=o}return!1}comment(e){let n=new oj;this.init(n,e[2]),n.source.end=this.getPosition(e[3]||e[2]),n.source.end.offset++;let i=e[1].slice(2,-2);if(/^\s*$/.test(i))n.text="",n.raws.left=i,n.raws.right="";else{let o=i.match(/^(\s*)([^]*\S)(\s*)$/);n.text=o[2],n.raws.left=o[1],n.raws.right=o[3]}}createTokenizer(){this.tokenizer=lj(this.input)}decl(e,n){let i=new aj;this.init(i,e[0][2]);let o=e[e.length-1];for(o[0]===";"&&(this.semicolon=!0,e.pop()),i.source.end=this.getPosition(o[3]||o[2]||uj(e)),i.source.end.offset++;e[0][0]!=="word";)e.length===1&&this.unknownWord(e),i.raws.before+=e.shift()[1];for(i.source.start=this.getPosition(e[0][2]),i.prop="";e.length;){let f=e[0][0];if(f===":"||f==="space"||f==="comment")break;i.prop+=e.shift()[1]}i.raws.between="";let s;for(;e.length;)if(s=e.shift(),s[0]===":"){i.raws.between+=s[1];break}else s[0]==="word"&&/\w/.test(s[1])&&this.unknownWord([s]),i.raws.between+=s[1];(i.prop[0]==="_"||i.prop[0]==="*")&&(i.raws.before+=i.prop[0],i.prop=i.prop.slice(1));let u=[],d;for(;e.length&&(d=e[0][0],!(d!=="space"&&d!=="comment"));)u.push(e.shift());this.precheckMissedSemicolon(e);for(let f=e.length-1;f>=0;f--){if(s=e[f],s[1].toLowerCase()==="!important"){i.important=!0;let g=this.stringFrom(e,f);g=this.spacesFromEnd(e)+g,g!==" !important"&&(i.raws.important=g);break}else if(s[1].toLowerCase()==="important"){let g=e.slice(0),y="";for(let x=f;x>0;x--){let b=g[x][0];if(y.trim().startsWith("!")&&b!=="space")break;y=g.pop()[1]+y}y.trim().startsWith("!")&&(i.important=!0,i.raws.important=y,e=g)}if(s[0]!=="space"&&s[0]!=="comment")break}e.some(f=>f[0]!=="space"&&f[0]!=="comment")&&(i.raws.between+=u.map(f=>f[1]).join(""),u=[]),this.raw(i,"value",u.concat(e),n),i.value.includes(":")&&!n&&this.checkMissedSemicolon(e)}doubleColon(e){throw this.input.error("Double colon",{offset:e[2]},{offset:e[2]+e[1].length})}emptyRule(e){let n=new zg;this.init(n,e[2]),n.selector="",n.raws.between="",this.current=n}end(e){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.spaces="",this.current.parent?(this.current.source.end=this.getPosition(e[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(e)}endFile(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.root.source.end=this.getPosition(this.tokenizer.position())}freeSemicolon(e){if(this.spaces+=e[1],this.current.nodes){let n=this.current.nodes[this.current.nodes.length-1];n&&n.type==="rule"&&!n.raws.ownSemicolon&&(n.raws.ownSemicolon=this.spaces,this.spaces="")}}getPosition(e){let n=this.input.fromOffset(e);return{column:n.col,line:n.line,offset:e}}init(e,n){this.current.push(e),e.source={input:this.input,start:this.getPosition(n)},e.raws.before=this.spaces,this.spaces="",e.type!=="comment"&&(this.semicolon=!1)}other(e){let n=!1,i=null,o=!1,s=null,u=[],d=e[1].startsWith("--"),f=[],g=e;for(;g;){if(i=g[0],f.push(g),i==="("||i==="[")s||(s=g),u.push(i==="("?")":"]");else if(d&&o&&i==="{")s||(s=g),u.push("}");else if(u.length===0)if(i===";")if(o){this.decl(f,d);return}else break;else if(i==="{"){this.rule(f);return}else if(i==="}"){this.tokenizer.back(f.pop()),n=!0;break}else i===":"&&(o=!0);else i===u[u.length-1]&&(u.pop(),u.length===0&&(s=null));g=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(n=!0),u.length>0&&this.unclosedBracket(s),n&&o){if(!d)for(;f.length&&(g=f[f.length-1][0],!(g!=="space"&&g!=="comment"));)this.tokenizer.back(f.pop());this.decl(f,d)}else this.unknownWord(f)}parse(){let e;for(;!this.tokenizer.endOfFile();)switch(e=this.tokenizer.nextToken(),e[0]){case"space":this.spaces+=e[1];break;case";":this.freeSemicolon(e);break;case"}":this.end(e);break;case"comment":this.comment(e);break;case"at-word":this.atrule(e);break;case"{":this.emptyRule(e);break;default:this.other(e);break}this.endFile()}precheckMissedSemicolon(){}raw(e,n,i,o){let s,u,d=i.length,f="",g=!0,y,x;for(let b=0;bm+w[1],"");e.raws[n]={raw:b,value:f}}e[n]=f}rule(e){e.pop();let n=new zg;this.init(n,e[0][2]),n.raws.between=this.spacesAndCommentsFromEnd(e),this.raw(n,"selector",e),this.current=n}spacesAndCommentsFromEnd(e){let n,i="";for(;e.length&&(n=e[e.length-1][0],!(n!=="space"&&n!=="comment"));)i=e.pop()[1]+i;return i}spacesAndCommentsFromStart(e){let n,i="";for(;e.length&&(n=e[0][0],!(n!=="space"&&n!=="comment"));)i+=e.shift()[1];return i}spacesFromEnd(e){let n,i="";for(;e.length&&(n=e[e.length-1][0],n==="space");)i=e.pop()[1]+i;return i}stringFrom(e,n){let i="";for(let o=n;oe.type==="warning")}get content(){return this.css}};var sh=uf;uf.default=uf;let gj=vo,vj=ih,yj=cy,wj=ah,Ug=sh,xj=Os,bj=Pu,{isClean:Mr,my:Cj}=Ds;const Sj={atrule:"AtRule",comment:"Comment",decl:"Declaration",document:"Document",root:"Root",rule:"Rule"},_j={AtRule:!0,AtRuleExit:!0,Comment:!0,CommentExit:!0,Declaration:!0,DeclarationExit:!0,Document:!0,DocumentExit:!0,Once:!0,OnceExit:!0,postcssPlugin:!0,prepare:!0,Root:!0,RootExit:!0,Rule:!0,RuleExit:!0},Ej={Once:!0,postcssPlugin:!0,prepare:!0},aa=0;function is(e){return typeof e=="object"&&typeof e.then=="function"}function fy(e){let n=!1,i=Sj[e.type];return e.type==="decl"?n=e.prop.toLowerCase():e.type==="atrule"&&(n=e.name.toLowerCase()),n&&e.append?[i,i+"-"+n,aa,i+"Exit",i+"Exit-"+n]:n?[i,i+"-"+n,i+"Exit",i+"Exit-"+n]:e.append?[i,aa,i+"Exit"]:[i,i+"Exit"]}function Hg(e){let n;return e.type==="document"?n=["Document",aa,"DocumentExit"]:e.type==="root"?n=["Root",aa,"RootExit"]:n=fy(e),{eventIndex:0,events:n,iterator:0,node:e,visitorIndex:0,visitors:[]}}function cf(e){return e[Mr]=!1,e.nodes&&e.nodes.forEach(n=>cf(n)),e}let df={},sa=class hy{constructor(n,i,o){this.stringified=!1,this.processed=!1;let s;if(typeof i=="object"&&i!==null&&(i.type==="root"||i.type==="document"))s=cf(i);else if(i instanceof hy||i instanceof Ug)s=cf(i.root),i.map&&(typeof o.map>"u"&&(o.map={}),o.map.inline||(o.map.inline=!1),o.map.prev=i.map);else{let u=wj;o.syntax&&(u=o.syntax.parse),o.parser&&(u=o.parser),u.parse&&(u=u.parse);try{s=u(i,o)}catch(d){this.processed=!0,this.error=d}s&&!s[Cj]&&gj.rebuild(s)}this.result=new Ug(n,s,o),this.helpers={...df,postcss:df,result:this.result},this.plugins=this.processor.plugins.map(u=>typeof u=="object"&&u.prepare?{...u,...u.prepare(this.result)}:u)}async(){return this.error?Promise.reject(this.error):this.processed?Promise.resolve(this.result):(this.processing||(this.processing=this.runAsync()),this.processing)}catch(n){return this.async().catch(n)}finally(n){return this.async().then(n,n)}getAsyncError(){throw new Error("Use process(css).then(cb) to work with async plugins")}handleError(n,i){let o=this.result.lastPlugin;try{i&&i.addToError(n),this.error=n,n.name==="CssSyntaxError"&&!n.plugin?(n.plugin=o.postcssPlugin,n.setMessage()):o.postcssVersion}catch(s){console&&console.error&&console.error(s)}return n}prepareVisitors(){this.listeners={};let n=(i,o,s)=>{this.listeners[o]||(this.listeners[o]=[]),this.listeners[o].push([i,s])};for(let i of this.plugins)if(typeof i=="object")for(let o in i){if(!_j[o]&&/^[A-Z]/.test(o))throw new Error(`Unknown event ${o} in ${i.postcssPlugin}. Try to update PostCSS (${this.processor.version} now).`);if(!Ej[o])if(typeof i[o]=="object")for(let s in i[o])s==="*"?n(i,o,i[o][s]):n(i,o+"-"+s.toLowerCase(),i[o][s]);else typeof i[o]=="function"&&n(i,o,i[o])}this.hasListener=Object.keys(this.listeners).length>0}async runAsync(){this.plugin=0;for(let n=0;n0;){let o=this.visitTick(i);if(is(o))try{await o}catch(s){let u=i[i.length-1].node;throw this.handleError(s,u)}}}if(this.listeners.OnceExit)for(let[i,o]of this.listeners.OnceExit){this.result.lastPlugin=i;try{if(n.type==="document"){let s=n.nodes.map(u=>o(u,this.helpers));await Promise.all(s)}else await o(n,this.helpers)}catch(s){throw this.handleError(s)}}}return this.processed=!0,this.stringify()}runOnRoot(n){this.result.lastPlugin=n;try{if(typeof n=="object"&&n.Once){if(this.result.root.type==="document"){let i=this.result.root.nodes.map(o=>n.Once(o,this.helpers));return is(i[0])?Promise.all(i):i}return n.Once(this.result.root,this.helpers)}else if(typeof n=="function")return n(this.result.root,this.result)}catch(i){throw this.handleError(i)}}stringify(){if(this.error)throw this.error;if(this.stringified)return this.result;this.stringified=!0,this.sync();let n=this.result.opts,i=bj;n.syntax&&(i=n.syntax.stringify),n.stringifier&&(i=n.stringifier),i.stringify&&(i=i.stringify);let o=new yj(i,this.result.root,this.result.opts).generate();return this.result.css=o[0],this.result.map=o[1],this.result}sync(){if(this.error)throw this.error;if(this.processed)return this.result;if(this.processed=!0,this.processing)throw this.getAsyncError();for(let n of this.plugins){let i=this.runOnRoot(n);if(is(i))throw this.getAsyncError()}if(this.prepareVisitors(),this.hasListener){let n=this.result.root;for(;!n[Mr];)n[Mr]=!0,this.walkSync(n);if(this.listeners.OnceExit)if(n.type==="document")for(let i of n.nodes)this.visitSync(this.listeners.OnceExit,i);else this.visitSync(this.listeners.OnceExit,n)}return this.result}then(n,i){return this.async().then(n,i)}toString(){return this.css}visitSync(n,i){for(let[o,s]of n){this.result.lastPlugin=o;let u;try{u=s(i,this.helpers)}catch(d){throw this.handleError(d,i.proxyOf)}if(i.type!=="root"&&i.type!=="document"&&!i.parent)return!0;if(is(u))throw this.getAsyncError()}}visitTick(n){let i=n[n.length-1],{node:o,visitors:s}=i;if(o.type!=="root"&&o.type!=="document"&&!o.parent){n.pop();return}if(s.length>0&&i.visitorIndex{s[Mr]||this.walkSync(s)});else{let s=this.listeners[o];if(s&&this.visitSync(s,n.toProxy()))return}}warnings(){return this.sync().warnings()}get content(){return this.stringify().content}get css(){return this.stringify().css}get map(){return this.stringify().map}get messages(){return this.sync().messages}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){return this.sync().root}get[Symbol.toStringTag](){return"LazyResult"}};sa.registerPostcss=e=>{df=e};var py=sa;sa.default=sa;xj.registerLazyResult(sa);vj.registerLazyResult(sa);let Nj=cy,kj=ah;const jj=sh;let Tj=Pu,ff=class{constructor(e,n,i){n=n.toString(),this.stringified=!1,this._processor=e,this._css=n,this._opts=i,this._map=void 0;let o,s=Tj;this.result=new jj(this._processor,o,this._opts),this.result.css=n;let u=this;Object.defineProperty(this.result,"root",{get(){return u.root}});let d=new Nj(s,o,this._opts,n);if(d.isMap()){let[f,g]=d.generate();f&&(this.result.css=f),g&&(this.result.map=g)}else d.clearAnnotation(),this.result.css=d.css}async(){return this.error?Promise.reject(this.error):Promise.resolve(this.result)}catch(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}sync(){if(this.error)throw this.error;return this.result}then(e,n){return this.async().then(e,n)}toString(){return this._css}warnings(){return[]}get content(){return this.result.css}get css(){return this.result.css}get map(){return this.result.map}get messages(){return[]}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){if(this._root)return this._root;let e,n=kj;try{e=n(this._css,this._opts)}catch(i){this.error=i}if(this.error)throw this.error;return this._root=e,e}get[Symbol.toStringTag](){return"NoWorkResult"}};var Pj=ff;ff.default=ff;let Lj=ih,Mj=py,Dj=Pj,Oj=Os,Es=class{constructor(n=[]){this.version="8.4.47",this.plugins=this.normalize(n)}normalize(n){let i=[];for(let o of n)if(o.postcss===!0?o=o():o.postcss&&(o=o.postcss),typeof o=="object"&&Array.isArray(o.plugins))i=i.concat(o.plugins);else if(typeof o=="object"&&o.postcssPlugin)i.push(o);else if(typeof o=="function")i.push(o);else if(!(typeof o=="object"&&(o.parse||o.stringify)))throw new Error(o+" is not a PostCSS plugin");return i}process(n,i={}){return!this.plugins.length&&!i.parser&&!i.stringifier&&!i.syntax?new Dj(this,n,i):new Mj(this,n,i)}use(n){return this.plugins=this.plugins.concat(this.normalize([n])),this}};var Ij=Es;Es.default=Es;Oj.registerProcessor(Es);Lj.registerProcessor(Es);let my=rh,gy=Mu,Rj=vo,Aj=eh,vy=Du,yy=ih,$j=Bk,Fj=Ou,zj=py,Bj=iy,Uj=Lu,Hj=ah,lh=Ij,Vj=sh,wy=Os,xy=oh,qj=Pu,Wj=dy;function it(...e){return e.length===1&&Array.isArray(e[0])&&(e=e[0]),new lh(e)}it.plugin=function(e,n){let i=!1;function o(...u){console&&console.warn&&!i&&(i=!0,console.warn(e+`: postcss.plugin was deprecated. Migration guide: https://evilmartians.com/chronicles/postcss-8-plugin-migration`),wg.LANG&&wg.LANG.startsWith("cn")&&console.warn(e+`: 里面 postcss.plugin 被弃用. 迁移指南: -https://www.w3ctech.com/topic/2226`));let d=n(...u);return d.postcssPlugin=e,d.postcssVersion=new lh().version,d}let s;return Object.defineProperty(o,"postcss",{get(){return s||(s=o()),s}}),o.process=function(u,d,f){return it([o(f)]).process(u,d)},o};it.stringify=qj;it.parse=Hj;it.fromJSON=$j;it.list=Bj;it.comment=e=>new gy(e);it.atRule=e=>new my(e);it.decl=e=>new vy(e);it.rule=e=>new xy(e);it.root=e=>new wy(e);it.document=e=>new yy(e);it.CssSyntaxError=Aj;it.Declaration=vy;it.Container=Rj;it.Processor=lh;it.Document=yy;it.Comment=gy;it.Warning=Wj;it.AtRule=my;it.Result=Vj;it.Input=Fj;it.Rule=xy;it.Root=wy;it.Node=Uj;zj.registerPostcss(it);var Gj=it;it.default=it;const{isPlainObject:EL}=Xf,{parse:NL}=Gj,Zj="_list_1whuj_1",Qj="_compact_1whuj_5",Kj="_pending_1whuj_8",Id={list:Zj,compact:Qj,pending:Kj};function Yj(e){const{className:n,data:i,keySelector:o,renderer:s,rendererParams:u,pending:d,errored:f,filtered:g,errorMessage:y,emptyMessage:x,pendingMessage:b,filteredEmptyMessage:m,compact:w,withoutMessage:N=!1,messageClassName:S}=e,_=Fe(i)||i.length===0;return h.jsxs("div",{className:Le(Id.list,w&&Id.compact,d&&Id.pending,n),children:[h.jsx(k0,{data:i,keySelector:o,renderer:s,rendererParams:u}),!N&&h.jsx(_0,{className:S,pending:d,filtered:g,empty:_,errored:f,compact:w,emptyMessage:x,filteredEmptyMessage:m,pendingMessage:b,errorMessage:y,overlayPending:!0})]})}function by(e,n){if(Fe(e))return;const i={},o=[];return e.forEach(s=>{const u=n?n(s):JSON.stringify(s);i[u]||(i[u]=!0,o.push(s))}),e.length===o.length?e:o}const Xj=[40,38,13,8];function Jj(e,n,i){return n.findIndex((o,s)=>i(o,s)===e)}function Vg(e,n,i,o){if(i.length<=0)return;let s=Jj(e,i,o);s===-1&&(s=n>0?-1:0);const u=tb(s+n,i.length);return o(i[u],u)}function eT(e,n,i,o,s,u,d,f,g){return v.useCallback(y=>{const{keyCode:x}=y,b=e?.key;if(o&&(x===9||x===27))u();else if(!o&&Xj.includes(x))y.stopPropagation(),y.preventDefault(),d();else if(x===13)if(Dt(b)){y.stopPropagation(),y.preventDefault();const m=i.find((w,N)=>n(w,N)===b);m&&f(b,m)}else y.stopPropagation(),y.preventDefault(),g&&g();else if(x===40){y.stopPropagation(),y.preventDefault();const m=Vg(b,1,i,n);s(m?{key:m}:void 0)}else if(x===38){y.stopPropagation(),y.preventDefault();const m=Vg(b,-1,i,n);s(m?{key:m}:void 0)}},[e,o,n,s,u,f,d,g,i])}const tT="_generic-option_zv1n8_1",nT={genericOption:tT};function rT(e){const{optionContainerClassName:n,contentRenderer:i,contentRendererParam:o,option:s,onClick:u,optionKey:d,focusedKey:f}=e,g=o(d,s),{containerClassName:y,title:x,...b}=g,m=f?.key===d,w=v.useRef(null);v.useEffect(()=>{f&&f.key===d&&!f.mouse&&w.current&&w.current.scrollIntoView({behavior:"smooth",block:"center"})},[d,f]);const N=v.useCallback(()=>{u(d,s)},[d,s,u]);return h.jsx(Cf,{elementRef:w,className:Le(nT.genericOption,n,y),onClick:N,title:x,name:d,focused:m,children:i(b)})}const iT="common",oT={infoMessageAnd:"and",infoMessageMore:"more",buttonTitleSelect:"Select all",buttonTitleClear:"Clear",buttonTitleClose:"Close",buttonTitleOpen:"Open",selectInputPendingMessage:"Fetching options...",selectInputEmptyMessage:"No option available",selectInputFilteredMessage:"No option available for the search",selectInputErrorMessage:"Could not load options"},aT={namespace:iT,strings:oT},sT="_popup_poyjv_1",lT="_list_poyjv_4",uT="_list-item_poyjv_9",cT="_info-message_poyjv_14",dT="_icon_poyjv_21",Ti={popup:sT,list:lT,listItem:uT,infoMessage:cT,icon:dT},fT=[];function Cy(e){const{actions:n,actionsContainerClassName:i,className:o,disabled:s,error:u,errorContainerClassName:d,hint:f,hintContainerClassName:g,icons:y,iconsContainerClassName:x,inputSectionClassName:b,label:m,labelClassName:w,name:N,onOptionClick:S,searchText:_,onSearchTextChange:T,optionContainerClassName:M,optionKeySelector:$,optionRenderer:F,optionRendererParams:W,options:fe,optionsPopupClassName:O,persistentOptionPopup:K,readOnly:de,placeholder:pe,valueDisplay:R="",nonClearable:H,onClearButtonClick:G,onSelectAllButtonClick:ee,optionsPending:me=!1,optionsFiltered:Ce=!1,optionsErrored:Ee=!1,focused:Z,focusedKey:ue,onFocusedKeyChange:j,onFocusedChange:V,dropdownShown:ae,onDropdownShownChange:Se,totalOptionsCount:le=0,hasValue:re,autoFocus:te,onEnterWithoutOption:Q,withAsterisk:Y,required:Je,variant:an,errorOnTooltip:Ut,dropdownHidden:ot}=e,vt=fe??fT,lt=S0(aT),pt=v.useRef(null),ct=v.useRef(null),dt=v.useRef(null),yt=v.useRef(null),Ot=v.useCallback(wt=>{ae||Se(!0),T(wt)},[ae,Se,T]),sn=v.useCallback((wt,ln)=>{ln.stopPropagation(),Se(!ae)},[ae,Se]),pn=v.useCallback(()=>{ae||Se(!0)},[ae,Se]),Ln=v.useCallback(()=>{Se(!1)},[Se]),ai=v.useCallback(()=>{de||pn()},[de,pn]),mn=v.useCallback((wt,ln)=>{wt||ln?K&&dt.current&&dt.current.focus():Ln()},[Ln,K]),gn=v.useCallback((wt,ln)=>{S(wt,ln,N),K||Ln()},[S,Ln,K,N]),Rr=v.useCallback((wt,ln)=>({contentRendererParam:W,option:ln,optionKey:wt,focusedKey:ue,contentRenderer:F,onClick:gn,onFocus:j,optionContainerClassName:Le(M,Ti.listItem)}),[ue,gn,j,M,F,W]);eN(ae,mn,yt,pt);const Yn=eT(ue,$,vt,ae,j,Ln,pn,gn,Q),Ht=vt.length,Yt=le-Ht>0?`${lt.infoMessageAnd} ${le-Ht} ${lt.infoMessageMore}`:void 0,Ct=ae&&!ot;return h.jsxs(h.Fragment,{children:[h.jsx(Vf,{actionsContainerClassName:i,className:o,containerRef:pt,disabled:s,errorContainerClassName:d,error:u,errorOnTooltip:Ut,hintContainerClassName:g,hint:f,iconsContainerClassName:x,icons:y,inputSectionClassName:b,inputSectionRef:ct,labelClassName:w,label:m,readOnly:de,required:Je,variant:an,withAsterisk:Y,actions:h.jsxs(h.Fragment,{children:[n,!de&&ee&&h.jsx(Be,{onClick:ee,disabled:s,variant:"tertiary",name:void 0,title:lt.buttonTitleSelect,children:h.jsx(Db,{className:Ti.icon})}),!de&&!H&&re&&h.jsx(Be,{onClick:G,disabled:s,variant:"tertiary",name:void 0,title:lt.buttonTitleClear,children:h.jsx(Fb,{className:Ti.icon})}),!de&&h.jsx(Be,{onClick:sn,variant:"tertiary",name:void 0,title:Ct?lt.buttonTitleClose:lt.buttonTitleOpen,children:Ct?h.jsx(Mb,{className:Ti.icon}):h.jsx(Pb,{className:Ti.icon})})]}),input:h.jsx(fv,{name:N,elementRef:dt,readOnly:de,disabled:s,value:ae||Z?_:R,onChange:Ot,onClick:ai,onFocus:()=>V(!0),onBlur:()=>V(!1),placeholder:js(R)?R:pe,autoComplete:"off",onKeyDown:Yn,autoFocus:te})}),Ct&&h.jsxs(E0,{elementRef:yt,parentRef:ct,className:Le(O,Ti.popup),children:[h.jsx(Yj,{className:Ti.list,data:vt,keySelector:$,renderer:rT,rendererParams:Rr,errored:Ee,filtered:Ce,pending:me,pendingMessage:lt.selectInputPendingMessage,emptyMessage:lt.selectInputEmptyMessage,filteredEmptyMessage:lt.selectInputFilteredMessage,errorMessage:lt.selectInputErrorMessage,compact:!0}),!me&&!Ee&&!!Yt&&h.jsx("div",{className:Ti.infoMessage,children:Yt})]})]})}function hT(e){const{children:n,isActive:i,iconClassName:o,labelClassName:s}=e;return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:o,children:i?h.jsx(b0,{}):h.jsx(x0,{})}),h.jsx("div",{className:s,children:n})]})}const pT="_option_1kpl9_1",mT="_active_1kpl9_7",gT="_icon_1kpl9_11",vT="_label_1kpl9_17",os={option:pT,active:mT,icon:gT,label:vT},Rd=[];function yT(e){const{keySelector:n,labelSelector:i,name:o,onChange:s,onOptionsChange:u,options:d,optionsPending:f,optionsErrored:g,value:y,sortFunction:x,searchOptions:b,onSearchValueChange:m,onShowDropdownChange:w,hideOptionFilter:N,selectedOnTop:S,..._}=e,T=d??Rd,M=b??Rd,$=y??Rd,[F,W]=v.useState(),[fe,O]=v.useState(!1),[K,de]=v.useState(!1),[pe,R]=v.useState(),[H,G]=v.useState({}),ee=v.useMemo(()=>cs(T,n,le=>le),[T,n]),me=v.useMemo(()=>cs(T,n,i),[T,n,i]),Ce=v.useMemo(()=>$.map(le=>me[le]??"?").join(", "),[$,me]),Ee=v.useMemo(()=>$.map(le=>ee[le]).filter(Dt),[$,ee]),Z=v.useMemo(()=>{const le=by([...M,...Ee],n);if(!S)return x?x(le,F,i):le;const re=le.filter(Q=>H[n(Q)]),te=le.filter(Q=>!H[n(Q)]&&(Fe(N)||N(Q)));return x?[...ho(re,F,i),...x(te,F,i)]:[...ho(re,F,i),...te]},[S,n,i,F,M,H,Ee,x,N]),ue=v.useCallback(le=>{W(le),m&&m(le)},[m]),j=v.useCallback(le=>{O(le),w&&w(le),le?(G(cs($,re=>re,()=>!0)),R(void 0)):(G({}),R(void 0),W(void 0),m&&m(void 0))},[$,m,w]),V=v.useCallback((le,re)=>{const te=$.findIndex(Q=>Q===le)!==-1;return{children:i(re),containerClassName:Le(os.option,te&&os.active),title:i(re),isActive:te,labelClassName:os.label,iconClassName:os.icon}},[i,$]),ae=v.useCallback((le,re)=>{const te=[...$],Q=$.findIndex(Y=>Y===le);Q!==-1?te.splice(Q,1):(te.push(le),u&&u(Y=>{const Je=Y??[];return Je.find(an=>n(an)===le)?Y:[...Je,re]})),s(te,o)},[$,s,o,u,n]),Se=v.useCallback(()=>{s([],o)},[o,s]);return h.jsx(Cy,{..._,name:o,options:Z,optionsPending:f,optionsFiltered:js(F)&&F.length>0,optionsErrored:g,optionKeySelector:n,optionRenderer:hT,optionRendererParams:V,optionContainerClassName:os.optionContainer,onOptionClick:ae,valueDisplay:Ce,onClearButtonClick:Se,searchText:F,onSearchTextChange:ue,dropdownShown:fe,onDropdownShownChange:j,focused:K,onFocusedChange:de,focusedKey:pe,onFocusedKeyChange:R,persistentOptionPopup:!0,nonClearable:!1,hasValue:Dt($)&&$.length>0})}function qg(e){const{name:n,options:i,keySelector:o,onChange:s,withSelectAll:u,...d}=e,f=v.useCallback(()=>{if(Fe(i))return;const g=i.map(o);s(g,n)},[i,n,s,o]);return h.jsx(yT,{...d,name:n,onChange:s,options:i,keySelector:o,sortFunction:ho,searchOptions:i,onSelectAllButtonClick:u?f:void 0,selectedOnTop:!1})}const wT="_page-container_1cfro_1",xT="_content_1cfro_2",Wg={pageContainer:wT,content:xT};function Iu(e){const{className:n,contentClassName:i,children:o,contentAs:s="div",containerAs:u="div"}=e,d=s;return h.jsx(u,{className:Le(Wg.pageContainer,n),children:h.jsx(d,{className:Le(Wg.content,i),children:o})})}const bT="_raw-input_145mq_1",CT={rawInput:bT};function ST(e){const{className:n,onChange:i,elementRef:o,value:s,name:u,...d}=e,f=gr.useCallback(g=>{var y;const x=(y=g?.target)==null?void 0:y.value;i&&i(x===""?void 0:x,u,g)},[u,i]);return h.jsx("textarea",{...d,ref:o,className:Le(CT.rawInput,n),name:Dt(u)?String(u):void 0,onChange:f,value:s??""})}const _T="_option_11p37_1",ET="_icon_11p37_6",NT="_label_11p37_14",kT="_overflow-container_11p37_20",jT="_description_11p37_25",Ko={option:_T,icon:ET,label:NT,overflowContainer:kT,description:jT};function TT(e){const{className:n,label:i,description:o,iconClassName:s,labelClassName:u}=e;return h.jsxs("div",{className:Le(Ko.option,n),children:[h.jsx("div",{className:Le(Ko.icon,s),children:h.jsx(Ob,{})}),h.jsxs("div",{className:Le(Ko.label,u),children:[h.jsx("div",{className:Ko.overflowContainer,children:i}),h.jsx("div",{className:Le(Ko.overflowContainer,Ko.description),children:o})]})]})}const PT="_option-container_2k92q_1",LT="_option_2k92q_1",MT="_active_2k92q_9",DT="_icon_2k92q_12",as={optionContainer:PT,option:LT,active:MT,icon:DT},Gg=[];function Zg(e){const{keySelector:n,labelSelector:i,descriptionSelector:o,name:s,onChange:u,onOptionsChange:d,options:f,optionsPending:g,optionsErrored:y,value:x,sortFunction:b,searchOptions:m,onSearchValueChange:w,onShowDropdownChange:N,hideOptionFilter:S,selectedOnTop:_,onEnterWithoutOption:T,...M}=e,$=f??Gg,F=m??Gg,[W,fe]=v.useState(),[O,K]=v.useState(!1),[de,pe]=v.useState(!1),[R,H]=v.useState(),[G,ee]=v.useState({}),me=v.useMemo(()=>cs($,n,i),[$,n,i]),Ce=Dt(x)?me[x]??"?":"",Ee=v.useMemo(()=>{const re=$?.find(te=>n(te)===x);return Fe(re)?[]:[re]},[x,$,n]),Z=v.useMemo(()=>{const re=by([...F,...Ee],n);if(!_)return b?b(re,W,i):re;const te=re.filter(Y=>G[n(Y)]),Q=re.filter(Y=>!G[n(Y)]&&(Fe(S)||S(Y)));return b?[...ho(te,W,i),...b(Q,W,i)]:[...ho(te,W,i),...Q]},[_,n,i,W,F,G,Ee,b,S]),ue=v.useCallback(re=>{fe(re),w&&w(re)},[w]),j=v.useCallback(()=>{K(!1),N&&N(!1),fe(void 0),w&&w(void 0),T&&T(W)},[W,N,T,w]),V=v.useCallback(re=>{K(re),N&&N(re),re?(ee(cs(x?[x]:[],te=>te,()=>!0)),H(x?{key:x}:void 0)):(ee({}),H(void 0),fe(void 0),w&&w(void 0))},[x,w,N]),ae=v.useCallback((re,te)=>{const Q=re===x;return{label:i(te),description:o?o(te):void 0,containerClassName:Le(as.optionContainer,Q&&as.active),title:i(te),className:as.option,iconClassName:as.icon}},[x,i,o]),Se=v.useCallback((re,te)=>{d&&d(Q=>{const Y=Q??[];return Y.find(Je=>n(Je)===re)?Q:[...Y,te]}),u(re,s,te)},[u,s,d,n]),le=v.useCallback(()=>{if(!e.nonClearable){const re=e.onChange;re(void 0,s,void 0)}},[s,e.onChange,e.nonClearable]);return h.jsx(Cy,{...M,name:s,options:Z,optionsPending:g,optionsErrored:y,optionsFiltered:js(W)&&W.length>0,optionKeySelector:n,optionRenderer:TT,optionRendererParams:ae,optionContainerClassName:as.optionContainer,onOptionClick:Se,valueDisplay:Ce,onClearButtonClick:le,searchText:W,onSearchTextChange:ue,dropdownShown:O,onDropdownShownChange:V,focused:de,onFocusedChange:pe,focusedKey:R,onFocusedKeyChange:H,hasValue:Dt(x),persistentOptionPopup:!1,onEnterWithoutOption:j})}const OT="_segment-input_bykt7_1",IT="_segment-list_bykt7_4",RT="_segment_bykt7_1",AT="_active_bykt7_18",$T="_secondary-variant_bykt7_24",fs={segmentInput:OT,segmentList:IT,segment:RT,active:AT,secondaryVariant:$T};function FT(e){const{label:n,name:i,onClick:o,value:s,className:u,variant:d="primary",inputName:f,...g}=e;return h.jsx(Be,{...g,className:Le(fs.segment,s&&fs.active,d==="secondary"&&fs.secondaryVariant,u),name:i,onClick:o,variant:"tertiary",children:n})}function su(e){const{rendererParams:n,listContainerClassName:i,keySelector:o,labelSelector:s,className:u,...d}=e;return h.jsx(ES,{className:Le(u,fs.segmentInput),...d,renderer:FT,rendererParams:n,listContainerClassName:Le(i,fs.segmentList),keySelector:o,labelSelector:s})}function io(e){const{name:n,options:i,nonClearable:o,onChange:s,...u}=e;return e.nonClearable?h.jsx(Zg,{...u,onChange:e.onChange,nonClearable:e.nonClearable,name:n,options:i,sortFunction:ho,searchOptions:i,selectedOnTop:!1}):h.jsx(Zg,{...u,onChange:e.onChange,nonClearable:e.nonClearable,name:n,options:i,sortFunction:ho,searchOptions:i,selectedOnTop:!1})}v.createContext({tabs:[],step:0,disabled:!1,activeTab:"",variant:"primary",setActiveTab:()=>{console.warn("setActiveTab called before it was initialized")},registerTab:()=>{console.warn("registerTab called before it was initialized")},unregisterTab:()=>{console.warn("unregisterTab called before it was initialized")}});const Qg="•",zT="Enter";function BT(e){const{actions:n,className:i,disabled:o,error:s,errorOnTooltip:u,hint:d,icons:f,inputClassName:g,label:y,labelClassName:x,readOnly:b,required:m,variant:w,inputSectionClassName:N,withAsterisk:S,onChange:_,name:T,autoBullets:M=!1,rows:$=5,...F}=e,W=gr.useCallback(O=>{Fe(_)||O.target.value===""&&_(`${Qg} `,T)},[_,T]),fe=gr.useCallback(O=>{Fe(_)||O.key===zT&&_(`${O.currentTarget.value}${Qg} `,T)},[_,T]);return h.jsx(Vf,{actions:n,className:i,disabled:o,error:s,errorOnTooltip:u,hint:d,icons:f,inputSectionClassName:N,labelClassName:x,label:y,readOnly:b,required:m,variant:w,withAsterisk:S,input:h.jsx(ST,{...F,readOnly:b,disabled:o,className:g,onChange:_,name:T,onFocus:M?W:void 0,onKeyUp:M?fe:void 0,rows:$})})}function kt(e){const{actions:n,className:i,disabled:o,error:s,errorOnTooltip:u,hint:d,icons:f,inputClassName:g,inputSectionClassName:y,label:x,readOnly:b,required:m,variant:w,withAsterisk:N,type:S="text",..._}=e;return h.jsx(Vf,{className:i,actions:n,disabled:o,error:s,errorOnTooltip:u,hint:d,icons:f,inputSectionClassName:y,label:x,required:m,readOnly:b,variant:w,withAsterisk:N,input:h.jsx(fv,{..._,required:m,readOnly:b,disabled:o,className:g,type:S})})}const UT="_dropdownContainer_1six7_3",HT="_dropdownMenu_1six7_15",VT="_dropdownContent_1six7_43",Ad={dropdownContainer:UT,dropdownMenu:HT,dropdownContent:VT},qT="/assets/logo-DkhILSWp.jpg",WT=[{to:"/upload",label:"Upload",Icon:C0},{to:"/explore",label:"Explore",Icon:Hb},{to:"/analytics",label:"Analytics",Icon:w0}];function GT(){const e=ua(),n=ks(),[i,o]=v.useState(!1),s=v.useRef(null);return v.useEffect(()=>{const u=d=>{s.current&&!s.current.contains(d.target)&&o(!1)};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u)}},[]),h.jsx("nav",{className:"border-b border-gray-200 bg-white shadow-sm sticky top-0 z-50 backdrop-blur-sm bg-white/95",children:h.jsxs(Iu,{className:"border-b-2 border-ifrcRed",contentClassName:"grid grid-cols-3 items-center py-6",children:[h.jsx("div",{className:"flex items-center gap-4 min-w-0 cursor-pointer group transition-all duration-200 hover:scale-105",onClick:()=>{if(!(e.pathname==="/upload"||e.pathname==="/")){if(e.pathname==="/upload"){if(window.confirmNavigationIfNeeded){window.confirmNavigationIfNeeded("/");return}if(!confirm("You have unsaved changes. Are you sure you want to leave?"))return}n("/")}},children:h.jsx("div",{className:"p-2 rounded-lg bg-gradient-to-br from-ifrcRed/10 to-ifrcRed/20 group-hover:from-ifrcRed/20 group-hover:to-ifrcRed/30 transition-all duration-200",children:h.jsx("img",{src:qT,alt:"PromptAid Vision Logo",className:"flex-shrink-0 object-contain",style:{width:"144px",height:"50px"}})})}),h.jsx("div",{className:"flex justify-center",children:h.jsx("nav",{className:"flex items-center space-x-4 bg-gray-50/80 rounded-xl p-2 backdrop-blur-sm",children:WT.map(({to:u,label:d,Icon:f})=>{const g=e.pathname===u||u==="/upload"&&e.pathname==="/"||u==="/explore"&&e.pathname.startsWith("/map/"),y=e.pathname==="/upload"||e.pathname==="/",x=u==="/upload"||u==="/";return h.jsxs("div",{className:"relative",children:[h.jsx(on,{withInternalPadding:!0,className:"p-2",children:h.jsxs(Be,{name:d.toLowerCase(),variant:g?"primary":"tertiary",size:1,className:`transition-all duration-200 ${g?"shadow-lg shadow-ifrcRed/20 transform scale-105":"hover:bg-white hover:shadow-md hover:scale-105"}`,onClick:()=>{if(!(y&&x)){if(e.pathname==="/upload"){if(window.confirmNavigationIfNeeded){window.confirmNavigationIfNeeded(u);return}if(!confirm("You have unsaved changes. Are you sure you want to leave?"))return}n(u)}},children:[h.jsx(f,{className:`w-4 h-4 transition-transform duration-200 ${g?"scale-110":"group-hover:scale-110"}`}),h.jsx("span",{className:"inline ml-2 font-semibold",children:d})]})}),g&&h.jsx("div",{className:"absolute -bottom-2 left-1/2 transform -translate-x-1/2 w-8 h-1 bg-ifrcRed rounded-full animate-pulse"})]},u)})})}),h.jsx("div",{className:"flex justify-end",children:h.jsxs("div",{className:Ad.dropdownContainer,ref:s,children:[h.jsx(on,{withInternalPadding:!0,className:"p-2",children:h.jsx(Be,{name:"more-options",variant:i?"primary":"tertiary",size:1,className:"transition-all duration-200",onClick:()=>o(!i),children:h.jsx(zb,{className:"w-4 h-4"})})}),i&&h.jsx("div",{className:Ad.dropdownMenu,children:h.jsxs("div",{className:Ad.dropdownContent,children:[h.jsx(on,{withInternalPadding:!0,className:"p-2",children:h.jsxs(Be,{name:"help-support",variant:"tertiary",size:1,className:"w-full justify-start",onClick:()=>{if(o(!1),e.pathname==="/upload"){if(window.confirmNavigationIfNeeded){window.confirmNavigationIfNeeded("/help");return}if(!confirm("You have unsaved changes. Are you sure you want to leave?"))return}n("/help")},children:[h.jsx(Bb,{className:"w-4 h-4"}),h.jsx("span",{className:"ml-2 font-semibold",children:"Help & Support"})]})}),h.jsx(on,{withInternalPadding:!0,className:"p-2",children:h.jsxs(Be,{name:"dev",variant:"tertiary",size:1,className:"w-full justify-start",onClick:()=>{if(o(!1),e.pathname==="/upload"){if(window.confirmNavigationIfNeeded){window.confirmNavigationIfNeeded("/admin");return}if(!confirm("You have unsaved changes. Are you sure you want to leave?"))return}n("/admin")},children:[h.jsx(Vb,{className:"w-4 h-4"}),h.jsx("span",{className:"ml-2 font-semibold",children:"Dev"})]})})]})})]})})]})})}function ZT(){return h.jsxs(h.Fragment,{children:[h.jsx(GT,{}),h.jsx(gx,{})]})}const QT="_uploadContainer_1i3bv_1",KT="_dropZone_1i3bv_9",YT="_hasFile_1i3bv_30",XT="_dropZoneIcon_1i3bv_37",JT="_dropZoneText_1i3bv_43",e2="_dropZoneSubtext_1i3bv_49",t2="_filePreview_1i3bv_55",n2="_filePreviewImage_1i3bv_64",r2="_fileName_1i3bv_110",i2="_fileInfo_1i3bv_118",o2="_helpLink_1i3bv_125",a2="_loadingContainer_1i3bv_145",s2="_loadingText_1i3bv_153",l2="_generateButtonContainer_1i3bv_157",u2="_uploadedMapContainer_1i3bv_165",c2="_uploadedMapImage_1i3bv_169",d2="_formGrid_1i3bv_209",f2="_titleField_1i3bv_222",h2="_ratingDescription_1i3bv_230",p2="_ratingSlider_1i3bv_235",m2="_ratingLabel_1i3bv_242",g2="_ratingInput_1i3bv_251",v2="_ratingValue_1i3bv_256",y2="_submitSection_1i3bv_266",w2="_successContainer_1i3bv_275",x2="_successHeading_1i3bv_280",b2="_successText_1i3bv_285",C2="_successButton_1i3bv_291",S2="_viewFullSizeButton_1i3bv_297",_2="_fullSizeModalOverlay_1i3bv_306",E2="_lightModalOverlay_1i3bv_320",N2="_fullSizeModalContent_1i3bv_334",k2="_fullSizeModalHeader_1i3bv_345",j2="_fullSizeModalImage_1i3bv_361",T2="_confirmSection_1i3bv_398",P2="_step2Layout_1i3bv_407",L2="_topRow_1i3bv_413",M2="_ratingHidden_1i3bv_421",D2="_imageSection_1i3bv_425",O2="_ratingContent_1i3bv_435",I2="_mapColumn_1i3bv_453",R2="_contentColumn_1i3bv_458",A2="_step2bLayout_1i3bv_465",$2="_metadataSectionCard_1i3bv_562",F2="_droneMetadataSection_1i3bv_571",z2="_droneMetadataHeading_1i3bv_577",B2="_droneMetadataGrid_1i3bv_585",U2="_rtkFixContainer_1i3bv_591",H2="_rtkFixLabel_1i3bv_597",V2="_rtkFixCheckbox_1i3bv_606",q2="_confirmButtonContainer_1i3bv_621",W2="_ratingWarningContent_1i3bv_629",G2="_ratingWarningTitle_1i3bv_637",Z2="_ratingWarningText_1i3bv_644",Q2="_ratingWarningButtons_1i3bv_651",K2="_fallbackReasonBox_1i3bv_659",Y2="_fallbackReasonTitle_1i3bv_668",X2="_fallbackReasonText_1i3bv_675",J2="_preprocessingProgress_1i3bv_682",eP="_carouselContainer_1i3bv_735",tP="_carouselImageWrapper_1i3bv_740",nP="_carouselImage_1i3bv_740",rP="_carouselNavigation_1i3bv_763",iP="_carouselButton_1i3bv_775",oP="_carouselIndicators_1i3bv_799",aP="_carouselIndicator_1i3bv_799",sP="_carouselIndicatorActive_1i3bv_828",lP="_viewImageButtonContainer_1i3bv_864",q={uploadContainer:QT,dropZone:KT,hasFile:YT,dropZoneIcon:XT,dropZoneText:JT,dropZoneSubtext:e2,filePreview:t2,filePreviewImage:n2,fileName:r2,fileInfo:i2,helpLink:o2,loadingContainer:a2,loadingText:s2,generateButtonContainer:l2,uploadedMapContainer:u2,uploadedMapImage:c2,formGrid:d2,titleField:f2,ratingDescription:h2,ratingSlider:p2,ratingLabel:m2,ratingInput:g2,ratingValue:v2,submitSection:y2,successContainer:w2,successHeading:x2,successText:b2,successButton:C2,viewFullSizeButton:S2,fullSizeModalOverlay:_2,lightModalOverlay:E2,fullSizeModalContent:N2,fullSizeModalHeader:k2,fullSizeModalImage:j2,confirmSection:T2,step2Layout:P2,topRow:L2,ratingHidden:M2,imageSection:D2,ratingContent:O2,mapColumn:I2,contentColumn:R2,step2bLayout:A2,metadataSectionCard:$2,droneMetadataSection:F2,droneMetadataHeading:z2,droneMetadataGrid:B2,rtkFixContainer:U2,rtkFixLabel:H2,rtkFixCheckbox:V2,confirmButtonContainer:q2,ratingWarningContent:W2,ratingWarningTitle:G2,ratingWarningText:Z2,ratingWarningButtons:Q2,fallbackReasonBox:K2,fallbackReasonTitle:Y2,fallbackReasonText:X2,preprocessingProgress:J2,carouselContainer:eP,carouselImageWrapper:tP,carouselImage:nP,carouselNavigation:rP,carouselButton:iP,carouselIndicators:oP,carouselIndicator:aP,carouselIndicatorActive:sP,viewImageButtonContainer:lP},Sy=v.createContext(void 0),uP=({children:e})=>{const[n,i]=v.useState(""),[o,s]=v.useState(""),[u,d]=v.useState(""),[f,g]=v.useState(""),[y,x]=v.useState(""),[b,m]=v.useState(""),[w,N]=v.useState(""),[S,_]=v.useState(""),[T,M]=v.useState(!1),F={search:n,srcFilter:o,catFilter:u,regionFilter:f,countryFilter:y,imageTypeFilter:b,uploadTypeFilter:w,generatedMethodFilter:S,showReferenceExamples:T,setSearch:i,setSrcFilter:s,setCatFilter:d,setRegionFilter:g,setCountryFilter:x,setImageTypeFilter:m,setUploadTypeFilter:N,setGeneratedMethodFilter:_,setShowReferenceExamples:M,clearAllFilters:()=>{i(""),s(""),d(""),g(""),x(""),m(""),N(""),_(""),M(!1)}};return h.jsx(Sy.Provider,{value:F,children:e})},cP=()=>{const e=v.useContext(Sy);if(e===void 0)throw new Error("useFilterContext must be used within a FilterProvider");return e},dP="_switchLabel_t5cwd_1",fP="_disabled_t5cwd_17",hP="_switchText_t5cwd_27",pP="_switchContainer_t5cwd_41",mP="_switchInput_t5cwd_55",gP="_slider_t5cwd_69",oo={switchLabel:dP,disabled:fP,switchText:hP,switchContainer:pP,switchInput:mP,slider:gP};function ls({label:e,checked:n,onChange:i,disabled:o=!1,name:s}){return h.jsxs("label",{className:`${oo.switchLabel} ${o?oo.disabled:""}`,children:[e&&h.jsx("span",{className:oo.switchText,children:e}),h.jsxs("div",{className:oo.switchContainer,children:[h.jsx("input",{type:"checkbox",name:s,checked:n,onChange:u=>i(u.target.checked),disabled:o,className:oo.switchInput}),h.jsx("span",{className:`${oo.slider} ${n?oo.checked:""}`})]})]})}function Kg({files:e,file:n,preview:i,imageType:o,isManualMode:s,onFileChange:u,onRemoveImage:d,onAddImage:f,onImageTypeChange:g,onManualModeChange:y,onChangeFile:x}){const b=m=>{m.preventDefault();const w=m.dataTransfer.files?.[0];w&&u(w)};return h.jsxs("div",{className:"space-y-6",children:[h.jsx("p",{className:"text-gray-700 leading-relaxed max-w-2xl mx-auto",children:"This app evaluates how well multimodal AI models analyze and describe crisis maps and drone imagery. Upload an image and the AI will generate a description. Then you can review and rate the result based on your expertise."}),h.jsx("div",{className:q.helpLink,children:h.jsxs(Fx,{to:"/help",className:q.helpLink,children:["More ",h.jsx(Lb,{className:"w-3 h-3"})]})}),h.jsxs("div",{className:"flex justify-center items-center gap-6 flex-wrap",children:[h.jsx(on,{withInternalPadding:!0,className:"bg-transparent border-none shadow-none",children:h.jsx(ls,{name:"vlm-generation",checked:!s,onChange:m=>y(!m),label:"VLM:"})}),h.jsx(on,{withInternalPadding:!0,className:"bg-transparent border-none shadow-none",children:h.jsx("div",{className:"flex justify-center",children:h.jsx(su,{name:"image-type",value:o,onChange:m=>g(m),options:[{key:"crisis_map",label:"Crisis Maps"},{key:"drone_image",label:"Drone Imagery"}],keySelector:m=>m.key,labelSelector:m=>m.label})})}),h.jsx(on,{withInternalPadding:!0,className:"bg-transparent border-none shadow-none",style:{width:"80px",visibility:"hidden"},children:h.jsx("div",{style:{width:"80px"}})})]}),h.jsxs("div",{className:`${q.dropZone} ${n?q.hasFile:""}`,onDragOver:m=>m.preventDefault(),onDrop:b,children:[e.length>1?h.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4 mb-4",children:e.map((m,w)=>h.jsxs("div",{className:"relative",children:[h.jsx("img",{src:URL.createObjectURL(m),alt:`Image ${w+1}`,className:"w-full h-32 object-cover rounded"}),h.jsx(kf,{name:"remove-image",variant:"tertiary",onClick:()=>d(w),title:"Remove image",ariaLabel:"Remove image",className:"absolute top-2 right-2 bg-white/90 hover:bg-white shadow-md hover:shadow-lg border border-gray-200 hover:border-red-300 transition-all duration-200 backdrop-blur-sm",children:h.jsx(_f,{className:"w-4 h-4"})}),h.jsx("div",{className:"text-xs text-center mt-1",children:m.name})]},w))}):n&&i?h.jsxs("div",{className:q.filePreview,children:[h.jsx("div",{className:q.filePreviewImage,children:h.jsx("img",{src:i,alt:"File preview"})}),h.jsx("p",{className:q.fileName,children:n.name}),h.jsxs("p",{className:q.fileInfo,children:[(n.size/1024/1024).toFixed(2)," MB"]})]}):h.jsxs(h.Fragment,{children:[h.jsx(C0,{className:q.dropZoneIcon}),h.jsx("p",{className:q.dropZoneText,children:"Drag & Drop any file here"}),h.jsx("p",{className:q.dropZoneSubtext,children:"or"})]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsxs("label",{className:"inline-block cursor-pointer",children:[h.jsx("input",{type:"file",className:"sr-only",accept:".jpg,.jpeg,.png,.tiff,.tif,.heic,.heif,.webp,.gif,.pdf",onChange:m=>{n&&x?x(m.target.files?.[0]):u(m.target.files?.[0])}}),h.jsx(Be,{name:"upload",variant:"secondary",size:1,onClick:()=>document.querySelector('input[type="file"]')?.click(),children:n?"Change Image":"Browse Files"})]}),n&&e.length<5&&h.jsx(Be,{name:"add-image",variant:"secondary",size:1,onClick:f,children:"Add Image"})]})]})]})}function Yg({files:e,imageUrl:n,preview:i,onViewFullSize:o,currentImageIndex:s=0,onGoToPrevious:u,onGoToNext:d,onGoToImage:f,showCarousel:g=!1}){return g&&e.length>1?h.jsx(on,{heading:"Uploaded Images",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:h.jsxs("div",{className:q.carouselContainer,children:[h.jsx("div",{className:q.carouselImageWrapper,children:e[s]?h.jsx("img",{src:URL.createObjectURL(e[s]),alt:`Image ${s+1}`,className:q.carouselImage}):h.jsx("div",{className:q.imagePlaceholder,children:"No image available"})}),h.jsxs("div",{className:q.carouselNavigation,children:[h.jsx(Be,{name:"previous-image",variant:"tertiary",size:1,onClick:u,className:q.carouselButton,children:h.jsx(Ab,{className:"w-4 h-4"})}),h.jsx("div",{className:q.carouselIndicators,children:e.map((y,x)=>h.jsx("button",{onClick:()=>f?.(x),className:`${q.carouselIndicator} ${x===s?q.carouselIndicatorActive:""}`,children:x+1},x))}),h.jsx(Be,{name:"next-image",variant:"tertiary",size:1,onClick:d,className:q.carouselButton,children:h.jsx($b,{className:"w-4 h-4"})})]}),h.jsx("div",{className:q.viewImageButtonContainer,children:h.jsx(Be,{name:"view-full-size-carousel",variant:"secondary",size:1,onClick:()=>o({file:e[s],index:s}),disabled:!e[s],children:"View Image"})})]})}):e.length>1?h.jsx("div",{className:"space-y-6",children:e.map((y,x)=>h.jsx(on,{heading:`Image ${x+1}: ${y.name}`,headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:h.jsxs("div",{className:q.uploadedMapContainer,children:[h.jsx("div",{className:q.uploadedMapImage,children:h.jsx("img",{src:URL.createObjectURL(y),alt:`Image ${x+1}`})}),h.jsx("div",{className:q.viewFullSizeButton,children:h.jsx(Be,{name:`view-full-size-${x}`,variant:"secondary",size:1,onClick:()=>o({file:y,index:x}),children:"View Image"})})]})},x))}):h.jsx(on,{heading:"Uploaded Image",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:h.jsxs("div",{className:q.uploadedMapContainer,children:[h.jsx("div",{className:q.uploadedMapImage,children:h.jsx("img",{src:n||i||void 0,alt:"Uploaded image preview"})}),h.jsx("div",{className:q.viewFullSizeButton,children:h.jsx(Be,{name:"view-full-size",variant:"secondary",size:1,onClick:()=>o(),children:"View Image"})})]})})}function vP({files:e,imageType:n,title:i,source:o,eventType:s,epsg:u,countries:d,centerLon:f,centerLat:g,amslM:y,aglM:x,headingDeg:b,yawDeg:m,pitchDeg:w,rollDeg:N,rtkFix:S,stdHM:_,stdVM:T,metadataArray:M,sources:$,types:F,spatialReferences:W,imageTypes:fe,countriesOptions:O,onTitleChange:K,onSourceChange:de,onEventTypeChange:pe,onEpsgChange:R,onCountriesChange:H,onCenterLonChange:G,onCenterLatChange:ee,onAmslMChange:me,onAglMChange:Ce,onHeadingDegChange:Ee,onYawDegChange:Z,onPitchDegChange:ue,onRollDegChange:j,onRtkFixChange:V,onStdHMChange:ae,onStdVMChange:Se,onImageTypeChange:le,updateMetadataForImage:re}){return e.length>1?h.jsxs("div",{children:[h.jsx("div",{className:"mb-4",children:h.jsx(kt,{label:"Shared Title",name:"title",value:i,onChange:K,placeholder:"Enter a title for all images..."})}),e.map((te,Q)=>h.jsx("div",{className:"mb-6",children:h.jsx(on,{heading:`Image ${Q+1}: ${te.name}`,headingLevel:4,withHeaderBorder:!0,withInternalPadding:!0,children:h.jsxs("div",{className:q.formGrid,children:[n!=="drone_image"&&h.jsx(io,{label:"Source",name:`source_${Q}`,value:M[Q]?.source||"",onChange:Y=>re(Q,"source",Y),options:$,keySelector:Y=>Y.s_code,labelSelector:Y=>Y.label,placeholder:"Please select"}),h.jsx(io,{label:"Event Type",name:`event_type_${Q}`,value:M[Q]?.eventType||"",onChange:Y=>re(Q,"eventType",Y),options:F,keySelector:Y=>Y.t_code,labelSelector:Y=>Y.label,placeholder:"Please select"}),h.jsx(io,{label:"EPSG",name:`epsg_${Q}`,value:M[Q]?.epsg||"",onChange:Y=>re(Q,"epsg",Y),options:W,keySelector:Y=>Y.epsg,labelSelector:Y=>`${Y.srid} (EPSG:${Y.epsg})`,placeholder:"Please select"}),h.jsx(qg,{label:"Countries (optional)",name:`countries_${Q}`,value:M[Q]?.countries||[],onChange:Y=>re(Q,"countries",Y),options:O,keySelector:Y=>Y.c_code,labelSelector:Y=>Y.label,placeholder:"Select one or more"}),n==="drone_image"&&h.jsx(h.Fragment,{children:h.jsxs("div",{className:q.droneMetadataSection,children:[h.jsx("h4",{className:q.droneMetadataHeading,children:"Drone Flight Data"}),h.jsxs("div",{className:q.droneMetadataGrid,children:[h.jsx(kt,{label:"Center Longitude",name:`center_lon_${Q}`,value:M[Q]?.centerLon||"",onChange:Y=>re(Q,"centerLon",Y),placeholder:"e.g., -122.4194",step:"any"}),h.jsx(kt,{label:"Center Latitude",name:`center_lat_${Q}`,value:M[Q]?.centerLat||"",onChange:Y=>re(Q,"centerLat",Y),placeholder:"e.g., 37.7749",step:"any"}),h.jsx(kt,{label:"Altitude AMSL (m)",name:`amsl_m_${Q}`,value:M[Q]?.amslM||"",onChange:Y=>re(Q,"amslM",Y),placeholder:"e.g., 100.5",step:"any"}),h.jsx(kt,{label:"Altitude AGL (m)",name:`agl_m_${Q}`,value:M[Q]?.aglM||"",onChange:Y=>re(Q,"aglM",Y),placeholder:"e.g., 50.2",step:"any"}),h.jsx(kt,{label:"Heading (degrees)",name:`heading_deg_${Q}`,value:M[Q]?.headingDeg||"",onChange:Y=>re(Q,"headingDeg",Y),placeholder:"e.g., 180.0",step:"any"}),h.jsx(kt,{label:"Yaw (degrees)",name:`yaw_deg_${Q}`,value:M[Q]?.yawDeg||"",onChange:Y=>re(Q,"yawDeg",Y),placeholder:"e.g., 90.0",step:"any"}),h.jsx(kt,{label:"Pitch (degrees)",name:`pitch_deg_${Q}`,value:M[Q]?.pitchDeg||"",onChange:Y=>re(Q,"pitchDeg",Y),placeholder:"e.g., 0.0",step:"any"}),h.jsx(kt,{label:"Roll (degrees)",name:`roll_deg_${Q}`,value:M[Q]?.rollDeg||"",onChange:Y=>re(Q,"rollDeg",Y),placeholder:"e.g., 0.0",step:"any"}),h.jsx("div",{className:q.rtkFixContainer,children:h.jsxs("label",{className:q.rtkFixLabel,children:[h.jsx("input",{type:"checkbox",checked:M[Q]?.rtkFix||!1,onChange:Y=>re(Q,"rtkFix",Y.target.checked),className:q.rtkFixCheckbox}),"RTK Fix Available"]})}),h.jsx(kt,{label:"Horizontal Std Dev (m)",name:`std_h_m_${Q}`,value:M[Q]?.stdHM||"",onChange:Y=>re(Q,"stdHM",Y),placeholder:"e.g., 0.1",step:"any"}),h.jsx(kt,{label:"Vertical Std Dev (m)",name:`std_v_m_${Q}`,value:M[Q]?.stdVM||"",onChange:Y=>re(Q,"stdVM",Y),placeholder:"e.g., 0.2",step:"any"})]})]})})]})})},Q))]}):h.jsxs("div",{className:q.formGrid,children:[h.jsx("div",{className:q.titleField,children:h.jsx(kt,{label:"Title",name:"title",value:i,onChange:K,placeholder:"Enter a title for this map..."})}),n!=="drone_image"&&h.jsx(io,{label:"Source",name:"source",value:o,onChange:de,options:$,keySelector:te=>te.s_code,labelSelector:te=>te.label,placeholder:"Please select"}),h.jsx(io,{label:"Event Type",name:"event_type",value:s,onChange:pe,options:F,keySelector:te=>te.t_code,labelSelector:te=>te.label,placeholder:"Please select"}),h.jsx(io,{label:"EPSG",name:"epsg",value:u,onChange:R,options:W,keySelector:te=>te.epsg,labelSelector:te=>`${te.srid} (EPSG:${te.epsg})`,placeholder:"Please select"}),h.jsx(io,{label:"Image Type",name:"image_type",value:n,onChange:le,options:fe,keySelector:te=>te.image_type,labelSelector:te=>te.label}),h.jsx(qg,{label:"Countries (optional)",name:"countries",value:d,onChange:H,options:O,keySelector:te=>te.c_code,labelSelector:te=>te.label,placeholder:"Select one or more"}),n==="drone_image"&&h.jsx(h.Fragment,{children:h.jsxs("div",{className:q.droneMetadataSection,children:[h.jsx("h4",{className:q.droneMetadataHeading,children:"Drone Flight Data"}),h.jsxs("div",{className:q.droneMetadataGrid,children:[h.jsx(kt,{label:"Center Longitude",name:"center_lon",value:f,onChange:G,placeholder:"e.g., -122.4194",step:"any"}),h.jsx(kt,{label:"Center Latitude",name:"center_lat",value:g,onChange:ee,placeholder:"e.g., 37.7749",step:"any"}),h.jsx(kt,{label:"Altitude AMSL (m)",name:"amsl_m",value:y,onChange:me,placeholder:"e.g., 100.5",step:"any"}),h.jsx(kt,{label:"Altitude AGL (m)",name:"agl_m",value:x,onChange:Ce,placeholder:"e.g., 50.2",step:"any"}),h.jsx(kt,{label:"Heading (degrees)",name:"heading_deg",value:b,onChange:Ee,placeholder:"e.g., 180.0",step:"any"}),h.jsx(kt,{label:"Yaw (degrees)",name:"yaw_deg",value:m,onChange:Z,placeholder:"e.g., 90.0",step:"any"}),h.jsx(kt,{label:"Pitch (degrees)",name:"pitch_deg",value:w,onChange:ue,placeholder:"e.g., 0.0",step:"any"}),h.jsx(kt,{label:"Roll (degrees)",name:"roll_deg",value:N,onChange:j,placeholder:"e.g., 0.0",step:"any"}),h.jsx("div",{className:q.rtkFixContainer,children:h.jsxs("label",{className:q.rtkFixLabel,children:[h.jsx("input",{type:"checkbox",checked:S,onChange:te=>V(te.target.checked),className:q.rtkFixCheckbox}),"RTK Fix Available"]})}),h.jsx(kt,{label:"Horizontal Std Dev (m)",name:"std_h_m",value:_,onChange:ae,placeholder:"e.g., 0.1",step:"any"}),h.jsx(kt,{label:"Vertical Std Dev (m)",name:"std_v_m",value:T,onChange:Se,placeholder:"e.g., 0.2",step:"any"})]})]})})]})}function yP({isPerformanceConfirmed:e,scores:n,onScoreChange:i,onConfirmRatings:o}){return e?null:h.jsx(on,{heading:"AI Performance Rating",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:h.jsxs("div",{className:q.ratingContent,children:[h.jsx("p",{className:q.ratingDescription,children:"How well did the AI perform on the task?"}),["accuracy","context","usability"].map(s=>h.jsxs("div",{className:q.ratingSlider,children:[h.jsx("label",{className:q.ratingLabel,children:s}),h.jsx("input",{type:"range",min:0,max:100,value:n[s],onChange:u=>i(s,Number(u.target.value)),className:q.ratingInput}),h.jsx("span",{className:q.ratingValue,children:n[s]})]},s)),h.jsx("div",{className:q.confirmButtonContainer,children:h.jsx(Be,{name:"confirm-ratings",variant:"secondary",onClick:o,children:"Confirm Ratings"})})]})})}function wP({description:e,analysis:n,recommendedActions:i,isManualMode:o=!1,onDescriptionChange:s,onAnalysisChange:u,onRecommendedActionsChange:d,onBack:f,onDelete:g,onSubmit:y,onEditRatings:x,isPerformanceConfirmed:b=!1,isSubmitting:m=!1}){const[w,N]=v.useState("");v.useEffect(()=>{if(o){const _=`Description: +https://www.w3ctech.com/topic/2226`));let d=n(...u);return d.postcssPlugin=e,d.postcssVersion=new lh().version,d}let s;return Object.defineProperty(o,"postcss",{get(){return s||(s=o()),s}}),o.process=function(u,d,f){return it([o(f)]).process(u,d)},o};it.stringify=qj;it.parse=Hj;it.fromJSON=$j;it.list=Bj;it.comment=e=>new gy(e);it.atRule=e=>new my(e);it.decl=e=>new vy(e);it.rule=e=>new xy(e);it.root=e=>new wy(e);it.document=e=>new yy(e);it.CssSyntaxError=Aj;it.Declaration=vy;it.Container=Rj;it.Processor=lh;it.Document=yy;it.Comment=gy;it.Warning=Wj;it.AtRule=my;it.Result=Vj;it.Input=Fj;it.Rule=xy;it.Root=wy;it.Node=Uj;zj.registerPostcss(it);var Gj=it;it.default=it;const{isPlainObject:EL}=Xf,{parse:NL}=Gj,Zj="_list_1whuj_1",Qj="_compact_1whuj_5",Kj="_pending_1whuj_8",Id={list:Zj,compact:Qj,pending:Kj};function Yj(e){const{className:n,data:i,keySelector:o,renderer:s,rendererParams:u,pending:d,errored:f,filtered:g,errorMessage:y,emptyMessage:x,pendingMessage:b,filteredEmptyMessage:m,compact:w,withoutMessage:N=!1,messageClassName:S}=e,_=Fe(i)||i.length===0;return h.jsxs("div",{className:Le(Id.list,w&&Id.compact,d&&Id.pending,n),children:[h.jsx(k0,{data:i,keySelector:o,renderer:s,rendererParams:u}),!N&&h.jsx(_0,{className:S,pending:d,filtered:g,empty:_,errored:f,compact:w,emptyMessage:x,filteredEmptyMessage:m,pendingMessage:b,errorMessage:y,overlayPending:!0})]})}function by(e,n){if(Fe(e))return;const i={},o=[];return e.forEach(s=>{const u=n?n(s):JSON.stringify(s);i[u]||(i[u]=!0,o.push(s))}),e.length===o.length?e:o}const Xj=[40,38,13,8];function Jj(e,n,i){return n.findIndex((o,s)=>i(o,s)===e)}function Vg(e,n,i,o){if(i.length<=0)return;let s=Jj(e,i,o);s===-1&&(s=n>0?-1:0);const u=tb(s+n,i.length);return o(i[u],u)}function eT(e,n,i,o,s,u,d,f,g){return v.useCallback(y=>{const{keyCode:x}=y,b=e?.key;if(o&&(x===9||x===27))u();else if(!o&&Xj.includes(x))y.stopPropagation(),y.preventDefault(),d();else if(x===13)if(Dt(b)){y.stopPropagation(),y.preventDefault();const m=i.find((w,N)=>n(w,N)===b);m&&f(b,m)}else y.stopPropagation(),y.preventDefault(),g&&g();else if(x===40){y.stopPropagation(),y.preventDefault();const m=Vg(b,1,i,n);s(m?{key:m}:void 0)}else if(x===38){y.stopPropagation(),y.preventDefault();const m=Vg(b,-1,i,n);s(m?{key:m}:void 0)}},[e,o,n,s,u,f,d,g,i])}const tT="_generic-option_zv1n8_1",nT={genericOption:tT};function rT(e){const{optionContainerClassName:n,contentRenderer:i,contentRendererParam:o,option:s,onClick:u,optionKey:d,focusedKey:f}=e,g=o(d,s),{containerClassName:y,title:x,...b}=g,m=f?.key===d,w=v.useRef(null);v.useEffect(()=>{f&&f.key===d&&!f.mouse&&w.current&&w.current.scrollIntoView({behavior:"smooth",block:"center"})},[d,f]);const N=v.useCallback(()=>{u(d,s)},[d,s,u]);return h.jsx(Cf,{elementRef:w,className:Le(nT.genericOption,n,y),onClick:N,title:x,name:d,focused:m,children:i(b)})}const iT="common",oT={infoMessageAnd:"and",infoMessageMore:"more",buttonTitleSelect:"Select all",buttonTitleClear:"Clear",buttonTitleClose:"Close",buttonTitleOpen:"Open",selectInputPendingMessage:"Fetching options...",selectInputEmptyMessage:"No option available",selectInputFilteredMessage:"No option available for the search",selectInputErrorMessage:"Could not load options"},aT={namespace:iT,strings:oT},sT="_popup_poyjv_1",lT="_list_poyjv_4",uT="_list-item_poyjv_9",cT="_info-message_poyjv_14",dT="_icon_poyjv_21",Ti={popup:sT,list:lT,listItem:uT,infoMessage:cT,icon:dT},fT=[];function Cy(e){const{actions:n,actionsContainerClassName:i,className:o,disabled:s,error:u,errorContainerClassName:d,hint:f,hintContainerClassName:g,icons:y,iconsContainerClassName:x,inputSectionClassName:b,label:m,labelClassName:w,name:N,onOptionClick:S,searchText:_,onSearchTextChange:T,optionContainerClassName:M,optionKeySelector:$,optionRenderer:F,optionRendererParams:W,options:fe,optionsPopupClassName:O,persistentOptionPopup:K,readOnly:de,placeholder:pe,valueDisplay:R="",nonClearable:H,onClearButtonClick:G,onSelectAllButtonClick:ee,optionsPending:me=!1,optionsFiltered:Ce=!1,optionsErrored:Ee=!1,focused:Z,focusedKey:ue,onFocusedKeyChange:j,onFocusedChange:V,dropdownShown:ae,onDropdownShownChange:Se,totalOptionsCount:le=0,hasValue:re,autoFocus:te,onEnterWithoutOption:Q,withAsterisk:Y,required:Je,variant:an,errorOnTooltip:Ut,dropdownHidden:ot}=e,vt=fe??fT,lt=S0(aT),pt=v.useRef(null),ct=v.useRef(null),dt=v.useRef(null),yt=v.useRef(null),Ot=v.useCallback(wt=>{ae||Se(!0),T(wt)},[ae,Se,T]),sn=v.useCallback((wt,ln)=>{ln.stopPropagation(),Se(!ae)},[ae,Se]),pn=v.useCallback(()=>{ae||Se(!0)},[ae,Se]),Ln=v.useCallback(()=>{Se(!1)},[Se]),ai=v.useCallback(()=>{de||pn()},[de,pn]),mn=v.useCallback((wt,ln)=>{wt||ln?K&&dt.current&&dt.current.focus():Ln()},[Ln,K]),gn=v.useCallback((wt,ln)=>{S(wt,ln,N),K||Ln()},[S,Ln,K,N]),Rr=v.useCallback((wt,ln)=>({contentRendererParam:W,option:ln,optionKey:wt,focusedKey:ue,contentRenderer:F,onClick:gn,onFocus:j,optionContainerClassName:Le(M,Ti.listItem)}),[ue,gn,j,M,F,W]);eN(ae,mn,yt,pt);const Yn=eT(ue,$,vt,ae,j,Ln,pn,gn,Q),Ht=vt.length,Yt=le-Ht>0?`${lt.infoMessageAnd} ${le-Ht} ${lt.infoMessageMore}`:void 0,Ct=ae&&!ot;return h.jsxs(h.Fragment,{children:[h.jsx(Vf,{actionsContainerClassName:i,className:o,containerRef:pt,disabled:s,errorContainerClassName:d,error:u,errorOnTooltip:Ut,hintContainerClassName:g,hint:f,iconsContainerClassName:x,icons:y,inputSectionClassName:b,inputSectionRef:ct,labelClassName:w,label:m,readOnly:de,required:Je,variant:an,withAsterisk:Y,actions:h.jsxs(h.Fragment,{children:[n,!de&&ee&&h.jsx(Be,{onClick:ee,disabled:s,variant:"tertiary",name:void 0,title:lt.buttonTitleSelect,children:h.jsx(Db,{className:Ti.icon})}),!de&&!H&&re&&h.jsx(Be,{onClick:G,disabled:s,variant:"tertiary",name:void 0,title:lt.buttonTitleClear,children:h.jsx(Fb,{className:Ti.icon})}),!de&&h.jsx(Be,{onClick:sn,variant:"tertiary",name:void 0,title:Ct?lt.buttonTitleClose:lt.buttonTitleOpen,children:Ct?h.jsx(Mb,{className:Ti.icon}):h.jsx(Pb,{className:Ti.icon})})]}),input:h.jsx(fv,{name:N,elementRef:dt,readOnly:de,disabled:s,value:ae||Z?_:R,onChange:Ot,onClick:ai,onFocus:()=>V(!0),onBlur:()=>V(!1),placeholder:js(R)?R:pe,autoComplete:"off",onKeyDown:Yn,autoFocus:te})}),Ct&&h.jsxs(E0,{elementRef:yt,parentRef:ct,className:Le(O,Ti.popup),children:[h.jsx(Yj,{className:Ti.list,data:vt,keySelector:$,renderer:rT,rendererParams:Rr,errored:Ee,filtered:Ce,pending:me,pendingMessage:lt.selectInputPendingMessage,emptyMessage:lt.selectInputEmptyMessage,filteredEmptyMessage:lt.selectInputFilteredMessage,errorMessage:lt.selectInputErrorMessage,compact:!0}),!me&&!Ee&&!!Yt&&h.jsx("div",{className:Ti.infoMessage,children:Yt})]})]})}function hT(e){const{children:n,isActive:i,iconClassName:o,labelClassName:s}=e;return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:o,children:i?h.jsx(b0,{}):h.jsx(x0,{})}),h.jsx("div",{className:s,children:n})]})}const pT="_option_1kpl9_1",mT="_active_1kpl9_7",gT="_icon_1kpl9_11",vT="_label_1kpl9_17",os={option:pT,active:mT,icon:gT,label:vT},Rd=[];function yT(e){const{keySelector:n,labelSelector:i,name:o,onChange:s,onOptionsChange:u,options:d,optionsPending:f,optionsErrored:g,value:y,sortFunction:x,searchOptions:b,onSearchValueChange:m,onShowDropdownChange:w,hideOptionFilter:N,selectedOnTop:S,..._}=e,T=d??Rd,M=b??Rd,$=y??Rd,[F,W]=v.useState(),[fe,O]=v.useState(!1),[K,de]=v.useState(!1),[pe,R]=v.useState(),[H,G]=v.useState({}),ee=v.useMemo(()=>cs(T,n,le=>le),[T,n]),me=v.useMemo(()=>cs(T,n,i),[T,n,i]),Ce=v.useMemo(()=>$.map(le=>me[le]??"?").join(", "),[$,me]),Ee=v.useMemo(()=>$.map(le=>ee[le]).filter(Dt),[$,ee]),Z=v.useMemo(()=>{const le=by([...M,...Ee],n);if(!S)return x?x(le,F,i):le;const re=le.filter(Q=>H[n(Q)]),te=le.filter(Q=>!H[n(Q)]&&(Fe(N)||N(Q)));return x?[...ho(re,F,i),...x(te,F,i)]:[...ho(re,F,i),...te]},[S,n,i,F,M,H,Ee,x,N]),ue=v.useCallback(le=>{W(le),m&&m(le)},[m]),j=v.useCallback(le=>{O(le),w&&w(le),le?(G(cs($,re=>re,()=>!0)),R(void 0)):(G({}),R(void 0),W(void 0),m&&m(void 0))},[$,m,w]),V=v.useCallback((le,re)=>{const te=$.findIndex(Q=>Q===le)!==-1;return{children:i(re),containerClassName:Le(os.option,te&&os.active),title:i(re),isActive:te,labelClassName:os.label,iconClassName:os.icon}},[i,$]),ae=v.useCallback((le,re)=>{const te=[...$],Q=$.findIndex(Y=>Y===le);Q!==-1?te.splice(Q,1):(te.push(le),u&&u(Y=>{const Je=Y??[];return Je.find(an=>n(an)===le)?Y:[...Je,re]})),s(te,o)},[$,s,o,u,n]),Se=v.useCallback(()=>{s([],o)},[o,s]);return h.jsx(Cy,{..._,name:o,options:Z,optionsPending:f,optionsFiltered:js(F)&&F.length>0,optionsErrored:g,optionKeySelector:n,optionRenderer:hT,optionRendererParams:V,optionContainerClassName:os.optionContainer,onOptionClick:ae,valueDisplay:Ce,onClearButtonClick:Se,searchText:F,onSearchTextChange:ue,dropdownShown:fe,onDropdownShownChange:j,focused:K,onFocusedChange:de,focusedKey:pe,onFocusedKeyChange:R,persistentOptionPopup:!0,nonClearable:!1,hasValue:Dt($)&&$.length>0})}function qg(e){const{name:n,options:i,keySelector:o,onChange:s,withSelectAll:u,...d}=e,f=v.useCallback(()=>{if(Fe(i))return;const g=i.map(o);s(g,n)},[i,n,s,o]);return h.jsx(yT,{...d,name:n,onChange:s,options:i,keySelector:o,sortFunction:ho,searchOptions:i,onSelectAllButtonClick:u?f:void 0,selectedOnTop:!1})}const wT="_page-container_1cfro_1",xT="_content_1cfro_2",Wg={pageContainer:wT,content:xT};function Iu(e){const{className:n,contentClassName:i,children:o,contentAs:s="div",containerAs:u="div"}=e,d=s;return h.jsx(u,{className:Le(Wg.pageContainer,n),children:h.jsx(d,{className:Le(Wg.content,i),children:o})})}const bT="_raw-input_145mq_1",CT={rawInput:bT};function ST(e){const{className:n,onChange:i,elementRef:o,value:s,name:u,...d}=e,f=gr.useCallback(g=>{var y;const x=(y=g?.target)==null?void 0:y.value;i&&i(x===""?void 0:x,u,g)},[u,i]);return h.jsx("textarea",{...d,ref:o,className:Le(CT.rawInput,n),name:Dt(u)?String(u):void 0,onChange:f,value:s??""})}const _T="_option_11p37_1",ET="_icon_11p37_6",NT="_label_11p37_14",kT="_overflow-container_11p37_20",jT="_description_11p37_25",Ko={option:_T,icon:ET,label:NT,overflowContainer:kT,description:jT};function TT(e){const{className:n,label:i,description:o,iconClassName:s,labelClassName:u}=e;return h.jsxs("div",{className:Le(Ko.option,n),children:[h.jsx("div",{className:Le(Ko.icon,s),children:h.jsx(Ob,{})}),h.jsxs("div",{className:Le(Ko.label,u),children:[h.jsx("div",{className:Ko.overflowContainer,children:i}),h.jsx("div",{className:Le(Ko.overflowContainer,Ko.description),children:o})]})]})}const PT="_option-container_2k92q_1",LT="_option_2k92q_1",MT="_active_2k92q_9",DT="_icon_2k92q_12",as={optionContainer:PT,option:LT,active:MT,icon:DT},Gg=[];function Zg(e){const{keySelector:n,labelSelector:i,descriptionSelector:o,name:s,onChange:u,onOptionsChange:d,options:f,optionsPending:g,optionsErrored:y,value:x,sortFunction:b,searchOptions:m,onSearchValueChange:w,onShowDropdownChange:N,hideOptionFilter:S,selectedOnTop:_,onEnterWithoutOption:T,...M}=e,$=f??Gg,F=m??Gg,[W,fe]=v.useState(),[O,K]=v.useState(!1),[de,pe]=v.useState(!1),[R,H]=v.useState(),[G,ee]=v.useState({}),me=v.useMemo(()=>cs($,n,i),[$,n,i]),Ce=Dt(x)?me[x]??"?":"",Ee=v.useMemo(()=>{const re=$?.find(te=>n(te)===x);return Fe(re)?[]:[re]},[x,$,n]),Z=v.useMemo(()=>{const re=by([...F,...Ee],n);if(!_)return b?b(re,W,i):re;const te=re.filter(Y=>G[n(Y)]),Q=re.filter(Y=>!G[n(Y)]&&(Fe(S)||S(Y)));return b?[...ho(te,W,i),...b(Q,W,i)]:[...ho(te,W,i),...Q]},[_,n,i,W,F,G,Ee,b,S]),ue=v.useCallback(re=>{fe(re),w&&w(re)},[w]),j=v.useCallback(()=>{K(!1),N&&N(!1),fe(void 0),w&&w(void 0),T&&T(W)},[W,N,T,w]),V=v.useCallback(re=>{K(re),N&&N(re),re?(ee(cs(x?[x]:[],te=>te,()=>!0)),H(x?{key:x}:void 0)):(ee({}),H(void 0),fe(void 0),w&&w(void 0))},[x,w,N]),ae=v.useCallback((re,te)=>{const Q=re===x;return{label:i(te),description:o?o(te):void 0,containerClassName:Le(as.optionContainer,Q&&as.active),title:i(te),className:as.option,iconClassName:as.icon}},[x,i,o]),Se=v.useCallback((re,te)=>{d&&d(Q=>{const Y=Q??[];return Y.find(Je=>n(Je)===re)?Q:[...Y,te]}),u(re,s,te)},[u,s,d,n]),le=v.useCallback(()=>{if(!e.nonClearable){const re=e.onChange;re(void 0,s,void 0)}},[s,e.onChange,e.nonClearable]);return h.jsx(Cy,{...M,name:s,options:Z,optionsPending:g,optionsErrored:y,optionsFiltered:js(W)&&W.length>0,optionKeySelector:n,optionRenderer:TT,optionRendererParams:ae,optionContainerClassName:as.optionContainer,onOptionClick:Se,valueDisplay:Ce,onClearButtonClick:le,searchText:W,onSearchTextChange:ue,dropdownShown:O,onDropdownShownChange:V,focused:de,onFocusedChange:pe,focusedKey:R,onFocusedKeyChange:H,hasValue:Dt(x),persistentOptionPopup:!1,onEnterWithoutOption:j})}const OT="_segment-input_bykt7_1",IT="_segment-list_bykt7_4",RT="_segment_bykt7_1",AT="_active_bykt7_18",$T="_secondary-variant_bykt7_24",fs={segmentInput:OT,segmentList:IT,segment:RT,active:AT,secondaryVariant:$T};function FT(e){const{label:n,name:i,onClick:o,value:s,className:u,variant:d="primary",inputName:f,...g}=e;return h.jsx(Be,{...g,className:Le(fs.segment,s&&fs.active,d==="secondary"&&fs.secondaryVariant,u),name:i,onClick:o,variant:"tertiary",children:n})}function su(e){const{rendererParams:n,listContainerClassName:i,keySelector:o,labelSelector:s,className:u,...d}=e;return h.jsx(ES,{className:Le(u,fs.segmentInput),...d,renderer:FT,rendererParams:n,listContainerClassName:Le(i,fs.segmentList),keySelector:o,labelSelector:s})}function io(e){const{name:n,options:i,nonClearable:o,onChange:s,...u}=e;return e.nonClearable?h.jsx(Zg,{...u,onChange:e.onChange,nonClearable:e.nonClearable,name:n,options:i,sortFunction:ho,searchOptions:i,selectedOnTop:!1}):h.jsx(Zg,{...u,onChange:e.onChange,nonClearable:e.nonClearable,name:n,options:i,sortFunction:ho,searchOptions:i,selectedOnTop:!1})}v.createContext({tabs:[],step:0,disabled:!1,activeTab:"",variant:"primary",setActiveTab:()=>{console.warn("setActiveTab called before it was initialized")},registerTab:()=>{console.warn("registerTab called before it was initialized")},unregisterTab:()=>{console.warn("unregisterTab called before it was initialized")}});const Qg="•",zT="Enter";function BT(e){const{actions:n,className:i,disabled:o,error:s,errorOnTooltip:u,hint:d,icons:f,inputClassName:g,label:y,labelClassName:x,readOnly:b,required:m,variant:w,inputSectionClassName:N,withAsterisk:S,onChange:_,name:T,autoBullets:M=!1,rows:$=5,...F}=e,W=gr.useCallback(O=>{Fe(_)||O.target.value===""&&_(`${Qg} `,T)},[_,T]),fe=gr.useCallback(O=>{Fe(_)||O.key===zT&&_(`${O.currentTarget.value}${Qg} `,T)},[_,T]);return h.jsx(Vf,{actions:n,className:i,disabled:o,error:s,errorOnTooltip:u,hint:d,icons:f,inputSectionClassName:N,labelClassName:x,label:y,readOnly:b,required:m,variant:w,withAsterisk:S,input:h.jsx(ST,{...F,readOnly:b,disabled:o,className:g,onChange:_,name:T,onFocus:M?W:void 0,onKeyUp:M?fe:void 0,rows:$})})}function kt(e){const{actions:n,className:i,disabled:o,error:s,errorOnTooltip:u,hint:d,icons:f,inputClassName:g,inputSectionClassName:y,label:x,readOnly:b,required:m,variant:w,withAsterisk:N,type:S="text",..._}=e;return h.jsx(Vf,{className:i,actions:n,disabled:o,error:s,errorOnTooltip:u,hint:d,icons:f,inputSectionClassName:y,label:x,required:m,readOnly:b,variant:w,withAsterisk:N,input:h.jsx(fv,{..._,required:m,readOnly:b,disabled:o,className:g,type:S})})}const UT="_dropdownContainer_1six7_3",HT="_dropdownMenu_1six7_15",VT="_dropdownContent_1six7_43",Ad={dropdownContainer:UT,dropdownMenu:HT,dropdownContent:VT},qT="/assets/logo-Cer0qWO3.png",WT=[{to:"/upload",label:"Upload",Icon:C0},{to:"/explore",label:"Explore",Icon:Hb},{to:"/analytics",label:"Analytics",Icon:w0}];function GT(){const e=ua(),n=ks(),[i,o]=v.useState(!1),s=v.useRef(null);return v.useEffect(()=>{const u=d=>{s.current&&!s.current.contains(d.target)&&o(!1)};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u)}},[]),h.jsx("nav",{className:"border-b border-gray-200 bg-white shadow-sm sticky top-0 z-50 backdrop-blur-sm bg-white/95",children:h.jsxs(Iu,{className:"border-b-2 border-ifrcRed",contentClassName:"grid grid-cols-3 items-center py-6",children:[h.jsx("div",{className:"flex items-center gap-4 min-w-0 cursor-pointer group transition-all duration-200 hover:scale-105",onClick:()=>{if(!(e.pathname==="/upload"||e.pathname==="/")){if(e.pathname==="/upload"){if(window.confirmNavigationIfNeeded){window.confirmNavigationIfNeeded("/");return}if(!confirm("You have unsaved changes. Are you sure you want to leave?"))return}n("/")}},children:h.jsx("div",{className:"p-2 rounded-lg bg-gradient-to-br from-ifrcRed/10 to-ifrcRed/20 group-hover:from-ifrcRed/20 group-hover:to-ifrcRed/30 transition-all duration-200",children:h.jsx("img",{src:qT,alt:"PromptAid Vision Logo",className:"flex-shrink-0 object-contain",style:{width:"144px",height:"50px"}})})}),h.jsx("div",{className:"flex justify-center",children:h.jsx("nav",{className:"flex items-center space-x-4 bg-gray-50/80 rounded-xl p-2 backdrop-blur-sm",children:WT.map(({to:u,label:d,Icon:f})=>{const g=e.pathname===u||u==="/upload"&&e.pathname==="/"||u==="/explore"&&e.pathname.startsWith("/map/"),y=e.pathname==="/upload"||e.pathname==="/",x=u==="/upload"||u==="/";return h.jsxs("div",{className:"relative",children:[h.jsx(on,{withInternalPadding:!0,className:"p-2",children:h.jsxs(Be,{name:d.toLowerCase(),variant:g?"primary":"tertiary",size:1,className:`transition-all duration-200 ${g?"shadow-lg shadow-ifrcRed/20 transform scale-105":"hover:bg-white hover:shadow-md hover:scale-105"}`,onClick:()=>{if(!(y&&x)){if(e.pathname==="/upload"){if(window.confirmNavigationIfNeeded){window.confirmNavigationIfNeeded(u);return}if(!confirm("You have unsaved changes. Are you sure you want to leave?"))return}n(u)}},children:[h.jsx(f,{className:`w-4 h-4 transition-transform duration-200 ${g?"scale-110":"group-hover:scale-110"}`}),h.jsx("span",{className:"inline ml-2 font-semibold",children:d})]})}),g&&h.jsx("div",{className:"absolute -bottom-2 left-1/2 transform -translate-x-1/2 w-8 h-1 bg-ifrcRed rounded-full animate-pulse"})]},u)})})}),h.jsx("div",{className:"flex justify-end",children:h.jsxs("div",{className:Ad.dropdownContainer,ref:s,children:[h.jsx(on,{withInternalPadding:!0,className:"p-2",children:h.jsx(Be,{name:"more-options",variant:i?"primary":"tertiary",size:1,className:"transition-all duration-200",onClick:()=>o(!i),children:h.jsx(zb,{className:"w-4 h-4"})})}),i&&h.jsx("div",{className:Ad.dropdownMenu,children:h.jsxs("div",{className:Ad.dropdownContent,children:[h.jsx(on,{withInternalPadding:!0,className:"p-2",children:h.jsxs(Be,{name:"help-support",variant:"tertiary",size:1,className:"w-full justify-start",onClick:()=>{if(o(!1),e.pathname==="/upload"){if(window.confirmNavigationIfNeeded){window.confirmNavigationIfNeeded("/help");return}if(!confirm("You have unsaved changes. Are you sure you want to leave?"))return}n("/help")},children:[h.jsx(Bb,{className:"w-4 h-4"}),h.jsx("span",{className:"ml-2 font-semibold",children:"Help & Support"})]})}),h.jsx(on,{withInternalPadding:!0,className:"p-2",children:h.jsxs(Be,{name:"dev",variant:"tertiary",size:1,className:"w-full justify-start",onClick:()=>{if(o(!1),e.pathname==="/upload"){if(window.confirmNavigationIfNeeded){window.confirmNavigationIfNeeded("/admin");return}if(!confirm("You have unsaved changes. Are you sure you want to leave?"))return}n("/admin")},children:[h.jsx(Vb,{className:"w-4 h-4"}),h.jsx("span",{className:"ml-2 font-semibold",children:"Dev"})]})})]})})]})})]})})}function ZT(){return h.jsxs(h.Fragment,{children:[h.jsx(GT,{}),h.jsx(gx,{})]})}const QT="_uploadContainer_1i3bv_1",KT="_dropZone_1i3bv_9",YT="_hasFile_1i3bv_30",XT="_dropZoneIcon_1i3bv_37",JT="_dropZoneText_1i3bv_43",e2="_dropZoneSubtext_1i3bv_49",t2="_filePreview_1i3bv_55",n2="_filePreviewImage_1i3bv_64",r2="_fileName_1i3bv_110",i2="_fileInfo_1i3bv_118",o2="_helpLink_1i3bv_125",a2="_loadingContainer_1i3bv_145",s2="_loadingText_1i3bv_153",l2="_generateButtonContainer_1i3bv_157",u2="_uploadedMapContainer_1i3bv_165",c2="_uploadedMapImage_1i3bv_169",d2="_formGrid_1i3bv_209",f2="_titleField_1i3bv_222",h2="_ratingDescription_1i3bv_230",p2="_ratingSlider_1i3bv_235",m2="_ratingLabel_1i3bv_242",g2="_ratingInput_1i3bv_251",v2="_ratingValue_1i3bv_256",y2="_submitSection_1i3bv_266",w2="_successContainer_1i3bv_275",x2="_successHeading_1i3bv_280",b2="_successText_1i3bv_285",C2="_successButton_1i3bv_291",S2="_viewFullSizeButton_1i3bv_297",_2="_fullSizeModalOverlay_1i3bv_306",E2="_lightModalOverlay_1i3bv_320",N2="_fullSizeModalContent_1i3bv_334",k2="_fullSizeModalHeader_1i3bv_345",j2="_fullSizeModalImage_1i3bv_361",T2="_confirmSection_1i3bv_398",P2="_step2Layout_1i3bv_407",L2="_topRow_1i3bv_413",M2="_ratingHidden_1i3bv_421",D2="_imageSection_1i3bv_425",O2="_ratingContent_1i3bv_435",I2="_mapColumn_1i3bv_453",R2="_contentColumn_1i3bv_458",A2="_step2bLayout_1i3bv_465",$2="_metadataSectionCard_1i3bv_562",F2="_droneMetadataSection_1i3bv_571",z2="_droneMetadataHeading_1i3bv_577",B2="_droneMetadataGrid_1i3bv_585",U2="_rtkFixContainer_1i3bv_591",H2="_rtkFixLabel_1i3bv_597",V2="_rtkFixCheckbox_1i3bv_606",q2="_confirmButtonContainer_1i3bv_621",W2="_ratingWarningContent_1i3bv_629",G2="_ratingWarningTitle_1i3bv_637",Z2="_ratingWarningText_1i3bv_644",Q2="_ratingWarningButtons_1i3bv_651",K2="_fallbackReasonBox_1i3bv_659",Y2="_fallbackReasonTitle_1i3bv_668",X2="_fallbackReasonText_1i3bv_675",J2="_preprocessingProgress_1i3bv_682",eP="_carouselContainer_1i3bv_735",tP="_carouselImageWrapper_1i3bv_740",nP="_carouselImage_1i3bv_740",rP="_carouselNavigation_1i3bv_763",iP="_carouselButton_1i3bv_775",oP="_carouselIndicators_1i3bv_799",aP="_carouselIndicator_1i3bv_799",sP="_carouselIndicatorActive_1i3bv_828",lP="_viewImageButtonContainer_1i3bv_864",q={uploadContainer:QT,dropZone:KT,hasFile:YT,dropZoneIcon:XT,dropZoneText:JT,dropZoneSubtext:e2,filePreview:t2,filePreviewImage:n2,fileName:r2,fileInfo:i2,helpLink:o2,loadingContainer:a2,loadingText:s2,generateButtonContainer:l2,uploadedMapContainer:u2,uploadedMapImage:c2,formGrid:d2,titleField:f2,ratingDescription:h2,ratingSlider:p2,ratingLabel:m2,ratingInput:g2,ratingValue:v2,submitSection:y2,successContainer:w2,successHeading:x2,successText:b2,successButton:C2,viewFullSizeButton:S2,fullSizeModalOverlay:_2,lightModalOverlay:E2,fullSizeModalContent:N2,fullSizeModalHeader:k2,fullSizeModalImage:j2,confirmSection:T2,step2Layout:P2,topRow:L2,ratingHidden:M2,imageSection:D2,ratingContent:O2,mapColumn:I2,contentColumn:R2,step2bLayout:A2,metadataSectionCard:$2,droneMetadataSection:F2,droneMetadataHeading:z2,droneMetadataGrid:B2,rtkFixContainer:U2,rtkFixLabel:H2,rtkFixCheckbox:V2,confirmButtonContainer:q2,ratingWarningContent:W2,ratingWarningTitle:G2,ratingWarningText:Z2,ratingWarningButtons:Q2,fallbackReasonBox:K2,fallbackReasonTitle:Y2,fallbackReasonText:X2,preprocessingProgress:J2,carouselContainer:eP,carouselImageWrapper:tP,carouselImage:nP,carouselNavigation:rP,carouselButton:iP,carouselIndicators:oP,carouselIndicator:aP,carouselIndicatorActive:sP,viewImageButtonContainer:lP},Sy=v.createContext(void 0),uP=({children:e})=>{const[n,i]=v.useState(""),[o,s]=v.useState(""),[u,d]=v.useState(""),[f,g]=v.useState(""),[y,x]=v.useState(""),[b,m]=v.useState(""),[w,N]=v.useState(""),[S,_]=v.useState(""),[T,M]=v.useState(!1),F={search:n,srcFilter:o,catFilter:u,regionFilter:f,countryFilter:y,imageTypeFilter:b,uploadTypeFilter:w,generatedMethodFilter:S,showReferenceExamples:T,setSearch:i,setSrcFilter:s,setCatFilter:d,setRegionFilter:g,setCountryFilter:x,setImageTypeFilter:m,setUploadTypeFilter:N,setGeneratedMethodFilter:_,setShowReferenceExamples:M,clearAllFilters:()=>{i(""),s(""),d(""),g(""),x(""),m(""),N(""),_(""),M(!1)}};return h.jsx(Sy.Provider,{value:F,children:e})},cP=()=>{const e=v.useContext(Sy);if(e===void 0)throw new Error("useFilterContext must be used within a FilterProvider");return e},dP="_switchLabel_t5cwd_1",fP="_disabled_t5cwd_17",hP="_switchText_t5cwd_27",pP="_switchContainer_t5cwd_41",mP="_switchInput_t5cwd_55",gP="_slider_t5cwd_69",oo={switchLabel:dP,disabled:fP,switchText:hP,switchContainer:pP,switchInput:mP,slider:gP};function ls({label:e,checked:n,onChange:i,disabled:o=!1,name:s}){return h.jsxs("label",{className:`${oo.switchLabel} ${o?oo.disabled:""}`,children:[e&&h.jsx("span",{className:oo.switchText,children:e}),h.jsxs("div",{className:oo.switchContainer,children:[h.jsx("input",{type:"checkbox",name:s,checked:n,onChange:u=>i(u.target.checked),disabled:o,className:oo.switchInput}),h.jsx("span",{className:`${oo.slider} ${n?oo.checked:""}`})]})]})}function Kg({files:e,file:n,preview:i,imageType:o,isManualMode:s,onFileChange:u,onRemoveImage:d,onAddImage:f,onImageTypeChange:g,onManualModeChange:y,onChangeFile:x}){const b=m=>{m.preventDefault();const w=m.dataTransfer.files?.[0];w&&u(w)};return h.jsxs("div",{className:"space-y-6",children:[h.jsx("p",{className:"text-gray-700 leading-relaxed max-w-2xl mx-auto",children:"This app evaluates how well multimodal AI models analyze and describe crisis maps and drone imagery. Upload an image and the AI will generate a description. Then you can review and rate the result based on your expertise."}),h.jsx("div",{className:q.helpLink,children:h.jsxs(Fx,{to:"/help",className:q.helpLink,children:["More ",h.jsx(Lb,{className:"w-3 h-3"})]})}),h.jsxs("div",{className:"flex justify-center items-center gap-6 flex-wrap",children:[h.jsx(on,{withInternalPadding:!0,className:"bg-transparent border-none shadow-none",children:h.jsx(ls,{name:"vlm-generation",checked:!s,onChange:m=>y(!m),label:"VLM:"})}),h.jsx(on,{withInternalPadding:!0,className:"bg-transparent border-none shadow-none",children:h.jsx("div",{className:"flex justify-center",children:h.jsx(su,{name:"image-type",value:o,onChange:m=>g(m),options:[{key:"crisis_map",label:"Crisis Maps"},{key:"drone_image",label:"Drone Imagery"}],keySelector:m=>m.key,labelSelector:m=>m.label})})}),h.jsx(on,{withInternalPadding:!0,className:"bg-transparent border-none shadow-none",style:{width:"80px",visibility:"hidden"},children:h.jsx("div",{style:{width:"80px"}})})]}),h.jsxs("div",{className:`${q.dropZone} ${n?q.hasFile:""}`,onDragOver:m=>m.preventDefault(),onDrop:b,children:[e.length>1?h.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4 mb-4",children:e.map((m,w)=>h.jsxs("div",{className:"relative",children:[h.jsx("img",{src:URL.createObjectURL(m),alt:`Image ${w+1}`,className:"w-full h-32 object-cover rounded"}),h.jsx(kf,{name:"remove-image",variant:"tertiary",onClick:()=>d(w),title:"Remove image",ariaLabel:"Remove image",className:"absolute top-2 right-2 bg-white/90 hover:bg-white shadow-md hover:shadow-lg border border-gray-200 hover:border-red-300 transition-all duration-200 backdrop-blur-sm",children:h.jsx(_f,{className:"w-4 h-4"})}),h.jsx("div",{className:"text-xs text-center mt-1",children:m.name})]},w))}):n&&i?h.jsxs("div",{className:q.filePreview,children:[h.jsx("div",{className:q.filePreviewImage,children:h.jsx("img",{src:i,alt:"File preview"})}),h.jsx("p",{className:q.fileName,children:n.name}),h.jsxs("p",{className:q.fileInfo,children:[(n.size/1024/1024).toFixed(2)," MB"]})]}):h.jsxs(h.Fragment,{children:[h.jsx(C0,{className:q.dropZoneIcon}),h.jsx("p",{className:q.dropZoneText,children:"Drag & Drop any file here"}),h.jsx("p",{className:q.dropZoneSubtext,children:"or"})]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsxs("label",{className:"inline-block cursor-pointer",children:[h.jsx("input",{type:"file",className:"sr-only",accept:".jpg,.jpeg,.png,.tiff,.tif,.heic,.heif,.webp,.gif,.pdf",onChange:m=>{n&&x?x(m.target.files?.[0]):u(m.target.files?.[0])}}),h.jsx(Be,{name:"upload",variant:"secondary",size:1,onClick:()=>document.querySelector('input[type="file"]')?.click(),children:n?"Change Image":"Browse Files"})]}),n&&e.length<5&&h.jsx(Be,{name:"add-image",variant:"secondary",size:1,onClick:f,children:"Add Image"})]})]})]})}function Yg({files:e,imageUrl:n,preview:i,onViewFullSize:o,currentImageIndex:s=0,onGoToPrevious:u,onGoToNext:d,onGoToImage:f,showCarousel:g=!1}){return g&&e.length>1?h.jsx(on,{heading:"Uploaded Images",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:h.jsxs("div",{className:q.carouselContainer,children:[h.jsx("div",{className:q.carouselImageWrapper,children:e[s]?h.jsx("img",{src:URL.createObjectURL(e[s]),alt:`Image ${s+1}`,className:q.carouselImage}):h.jsx("div",{className:q.imagePlaceholder,children:"No image available"})}),h.jsxs("div",{className:q.carouselNavigation,children:[h.jsx(Be,{name:"previous-image",variant:"tertiary",size:1,onClick:u,className:q.carouselButton,children:h.jsx(Ab,{className:"w-4 h-4"})}),h.jsx("div",{className:q.carouselIndicators,children:e.map((y,x)=>h.jsx("button",{onClick:()=>f?.(x),className:`${q.carouselIndicator} ${x===s?q.carouselIndicatorActive:""}`,children:x+1},x))}),h.jsx(Be,{name:"next-image",variant:"tertiary",size:1,onClick:d,className:q.carouselButton,children:h.jsx($b,{className:"w-4 h-4"})})]}),h.jsx("div",{className:q.viewImageButtonContainer,children:h.jsx(Be,{name:"view-full-size-carousel",variant:"secondary",size:1,onClick:()=>o({file:e[s],index:s}),disabled:!e[s],children:"View Image"})})]})}):e.length>1?h.jsx("div",{className:"space-y-6",children:e.map((y,x)=>h.jsx(on,{heading:`Image ${x+1}: ${y.name}`,headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:h.jsxs("div",{className:q.uploadedMapContainer,children:[h.jsx("div",{className:q.uploadedMapImage,children:h.jsx("img",{src:URL.createObjectURL(y),alt:`Image ${x+1}`})}),h.jsx("div",{className:q.viewFullSizeButton,children:h.jsx(Be,{name:`view-full-size-${x}`,variant:"secondary",size:1,onClick:()=>o({file:y,index:x}),children:"View Image"})})]})},x))}):h.jsx(on,{heading:"Uploaded Image",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:h.jsxs("div",{className:q.uploadedMapContainer,children:[h.jsx("div",{className:q.uploadedMapImage,children:h.jsx("img",{src:n||i||void 0,alt:"Uploaded image preview"})}),h.jsx("div",{className:q.viewFullSizeButton,children:h.jsx(Be,{name:"view-full-size",variant:"secondary",size:1,onClick:()=>o(),children:"View Image"})})]})})}function vP({files:e,imageType:n,title:i,source:o,eventType:s,epsg:u,countries:d,centerLon:f,centerLat:g,amslM:y,aglM:x,headingDeg:b,yawDeg:m,pitchDeg:w,rollDeg:N,rtkFix:S,stdHM:_,stdVM:T,metadataArray:M,sources:$,types:F,spatialReferences:W,imageTypes:fe,countriesOptions:O,onTitleChange:K,onSourceChange:de,onEventTypeChange:pe,onEpsgChange:R,onCountriesChange:H,onCenterLonChange:G,onCenterLatChange:ee,onAmslMChange:me,onAglMChange:Ce,onHeadingDegChange:Ee,onYawDegChange:Z,onPitchDegChange:ue,onRollDegChange:j,onRtkFixChange:V,onStdHMChange:ae,onStdVMChange:Se,onImageTypeChange:le,updateMetadataForImage:re}){return e.length>1?h.jsxs("div",{children:[h.jsx("div",{className:"mb-4",children:h.jsx(kt,{label:"Shared Title",name:"title",value:i,onChange:K,placeholder:"Enter a title for all images..."})}),e.map((te,Q)=>h.jsx("div",{className:"mb-6",children:h.jsx(on,{heading:`Image ${Q+1}: ${te.name}`,headingLevel:4,withHeaderBorder:!0,withInternalPadding:!0,children:h.jsxs("div",{className:q.formGrid,children:[n!=="drone_image"&&h.jsx(io,{label:"Source",name:`source_${Q}`,value:M[Q]?.source||"",onChange:Y=>re(Q,"source",Y),options:$,keySelector:Y=>Y.s_code,labelSelector:Y=>Y.label,placeholder:"Please select"}),h.jsx(io,{label:"Event Type",name:`event_type_${Q}`,value:M[Q]?.eventType||"",onChange:Y=>re(Q,"eventType",Y),options:F,keySelector:Y=>Y.t_code,labelSelector:Y=>Y.label,placeholder:"Please select"}),h.jsx(io,{label:"EPSG",name:`epsg_${Q}`,value:M[Q]?.epsg||"",onChange:Y=>re(Q,"epsg",Y),options:W,keySelector:Y=>Y.epsg,labelSelector:Y=>`${Y.srid} (EPSG:${Y.epsg})`,placeholder:"Please select"}),h.jsx(qg,{label:"Countries (optional)",name:`countries_${Q}`,value:M[Q]?.countries||[],onChange:Y=>re(Q,"countries",Y),options:O,keySelector:Y=>Y.c_code,labelSelector:Y=>Y.label,placeholder:"Select one or more"}),n==="drone_image"&&h.jsx(h.Fragment,{children:h.jsxs("div",{className:q.droneMetadataSection,children:[h.jsx("h4",{className:q.droneMetadataHeading,children:"Drone Flight Data"}),h.jsxs("div",{className:q.droneMetadataGrid,children:[h.jsx(kt,{label:"Center Longitude",name:`center_lon_${Q}`,value:M[Q]?.centerLon||"",onChange:Y=>re(Q,"centerLon",Y),placeholder:"e.g., -122.4194",step:"any"}),h.jsx(kt,{label:"Center Latitude",name:`center_lat_${Q}`,value:M[Q]?.centerLat||"",onChange:Y=>re(Q,"centerLat",Y),placeholder:"e.g., 37.7749",step:"any"}),h.jsx(kt,{label:"Altitude AMSL (m)",name:`amsl_m_${Q}`,value:M[Q]?.amslM||"",onChange:Y=>re(Q,"amslM",Y),placeholder:"e.g., 100.5",step:"any"}),h.jsx(kt,{label:"Altitude AGL (m)",name:`agl_m_${Q}`,value:M[Q]?.aglM||"",onChange:Y=>re(Q,"aglM",Y),placeholder:"e.g., 50.2",step:"any"}),h.jsx(kt,{label:"Heading (degrees)",name:`heading_deg_${Q}`,value:M[Q]?.headingDeg||"",onChange:Y=>re(Q,"headingDeg",Y),placeholder:"e.g., 180.0",step:"any"}),h.jsx(kt,{label:"Yaw (degrees)",name:`yaw_deg_${Q}`,value:M[Q]?.yawDeg||"",onChange:Y=>re(Q,"yawDeg",Y),placeholder:"e.g., 90.0",step:"any"}),h.jsx(kt,{label:"Pitch (degrees)",name:`pitch_deg_${Q}`,value:M[Q]?.pitchDeg||"",onChange:Y=>re(Q,"pitchDeg",Y),placeholder:"e.g., 0.0",step:"any"}),h.jsx(kt,{label:"Roll (degrees)",name:`roll_deg_${Q}`,value:M[Q]?.rollDeg||"",onChange:Y=>re(Q,"rollDeg",Y),placeholder:"e.g., 0.0",step:"any"}),h.jsx("div",{className:q.rtkFixContainer,children:h.jsxs("label",{className:q.rtkFixLabel,children:[h.jsx("input",{type:"checkbox",checked:M[Q]?.rtkFix||!1,onChange:Y=>re(Q,"rtkFix",Y.target.checked),className:q.rtkFixCheckbox}),"RTK Fix Available"]})}),h.jsx(kt,{label:"Horizontal Std Dev (m)",name:`std_h_m_${Q}`,value:M[Q]?.stdHM||"",onChange:Y=>re(Q,"stdHM",Y),placeholder:"e.g., 0.1",step:"any"}),h.jsx(kt,{label:"Vertical Std Dev (m)",name:`std_v_m_${Q}`,value:M[Q]?.stdVM||"",onChange:Y=>re(Q,"stdVM",Y),placeholder:"e.g., 0.2",step:"any"})]})]})})]})})},Q))]}):h.jsxs("div",{className:q.formGrid,children:[h.jsx("div",{className:q.titleField,children:h.jsx(kt,{label:"Title",name:"title",value:i,onChange:K,placeholder:"Enter a title for this map..."})}),n!=="drone_image"&&h.jsx(io,{label:"Source",name:"source",value:o,onChange:de,options:$,keySelector:te=>te.s_code,labelSelector:te=>te.label,placeholder:"Please select"}),h.jsx(io,{label:"Event Type",name:"event_type",value:s,onChange:pe,options:F,keySelector:te=>te.t_code,labelSelector:te=>te.label,placeholder:"Please select"}),h.jsx(io,{label:"EPSG",name:"epsg",value:u,onChange:R,options:W,keySelector:te=>te.epsg,labelSelector:te=>`${te.srid} (EPSG:${te.epsg})`,placeholder:"Please select"}),h.jsx(io,{label:"Image Type",name:"image_type",value:n,onChange:le,options:fe,keySelector:te=>te.image_type,labelSelector:te=>te.label}),h.jsx(qg,{label:"Countries (optional)",name:"countries",value:d,onChange:H,options:O,keySelector:te=>te.c_code,labelSelector:te=>te.label,placeholder:"Select one or more"}),n==="drone_image"&&h.jsx(h.Fragment,{children:h.jsxs("div",{className:q.droneMetadataSection,children:[h.jsx("h4",{className:q.droneMetadataHeading,children:"Drone Flight Data"}),h.jsxs("div",{className:q.droneMetadataGrid,children:[h.jsx(kt,{label:"Center Longitude",name:"center_lon",value:f,onChange:G,placeholder:"e.g., -122.4194",step:"any"}),h.jsx(kt,{label:"Center Latitude",name:"center_lat",value:g,onChange:ee,placeholder:"e.g., 37.7749",step:"any"}),h.jsx(kt,{label:"Altitude AMSL (m)",name:"amsl_m",value:y,onChange:me,placeholder:"e.g., 100.5",step:"any"}),h.jsx(kt,{label:"Altitude AGL (m)",name:"agl_m",value:x,onChange:Ce,placeholder:"e.g., 50.2",step:"any"}),h.jsx(kt,{label:"Heading (degrees)",name:"heading_deg",value:b,onChange:Ee,placeholder:"e.g., 180.0",step:"any"}),h.jsx(kt,{label:"Yaw (degrees)",name:"yaw_deg",value:m,onChange:Z,placeholder:"e.g., 90.0",step:"any"}),h.jsx(kt,{label:"Pitch (degrees)",name:"pitch_deg",value:w,onChange:ue,placeholder:"e.g., 0.0",step:"any"}),h.jsx(kt,{label:"Roll (degrees)",name:"roll_deg",value:N,onChange:j,placeholder:"e.g., 0.0",step:"any"}),h.jsx("div",{className:q.rtkFixContainer,children:h.jsxs("label",{className:q.rtkFixLabel,children:[h.jsx("input",{type:"checkbox",checked:S,onChange:te=>V(te.target.checked),className:q.rtkFixCheckbox}),"RTK Fix Available"]})}),h.jsx(kt,{label:"Horizontal Std Dev (m)",name:"std_h_m",value:_,onChange:ae,placeholder:"e.g., 0.1",step:"any"}),h.jsx(kt,{label:"Vertical Std Dev (m)",name:"std_v_m",value:T,onChange:Se,placeholder:"e.g., 0.2",step:"any"})]})]})})]})}function yP({isPerformanceConfirmed:e,scores:n,onScoreChange:i,onConfirmRatings:o}){return e?null:h.jsx(on,{heading:"AI Performance Rating",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:h.jsxs("div",{className:q.ratingContent,children:[h.jsx("p",{className:q.ratingDescription,children:"How well did the AI perform on the task?"}),["accuracy","context","usability"].map(s=>h.jsxs("div",{className:q.ratingSlider,children:[h.jsx("label",{className:q.ratingLabel,children:s}),h.jsx("input",{type:"range",min:0,max:100,value:n[s],onChange:u=>i(s,Number(u.target.value)),className:q.ratingInput}),h.jsx("span",{className:q.ratingValue,children:n[s]})]},s)),h.jsx("div",{className:q.confirmButtonContainer,children:h.jsx(Be,{name:"confirm-ratings",variant:"secondary",onClick:o,children:"Confirm Ratings"})})]})})}function wP({description:e,analysis:n,recommendedActions:i,isManualMode:o=!1,onDescriptionChange:s,onAnalysisChange:u,onRecommendedActionsChange:d,onBack:f,onDelete:g,onSubmit:y,onEditRatings:x,isPerformanceConfirmed:b=!1,isSubmitting:m=!1}){const[w,N]=v.useState("");v.useEffect(()=>{if(o){const _=`Description: ${e} Analysis: @@ -165,4 +165,4 @@ ${i||"AI-generated recommended actions will appear here..."}`;N(_)}},[e,n,i,o]); Analysis: ${Fr} -Recommended Actions: ${Dn}`,_e={title:H,edited:ke,accuracy:wr.accuracy,context:wr.context,usability:wr.usability};console.log("Updating caption:",_e);const oe=await fetch(`/api/images/${Ct}/caption`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(_e)}),De=await rr(oe);if(!oe.ok)throw new Error(De.error||"Caption update failed");wt(null),Vt([]),Ui(3)}catch(k){xa(k,"Submit")}finally{y(!1)}}async function fi(){if(console.log("handleDelete called with uploadedImageId:",Ct),!Ct){alert("No image to delete. Please try refreshing the page.");return}ce(!0)}async function hi(){try{console.log("Deleting image with ID:",Ct);const k=await fetch(`/api/images/${Ct}`,{method:"DELETE"});if(!k.ok){const ke=await rr(k);throw new Error(ke.error||`Delete failed with status ${k.status}`)}ce(!1),qi()}catch(k){xa(k,"Delete")}}const qi=()=>{P(!1),o(1),S(null),T([]),w(null),wt(null),Vt([]),Ri(null),G(""),$(""),W(""),O(""),R([]),Ee(""),ue(""),V(""),Se(""),re(""),Q(""),Je(""),Ut(""),vt(!1),pt(""),dt(""),Ai({accuracy:50,context:50,usability:50}),Ar(""),Mn(""),un(""),zr(""),Ot([]),ve(!1),Ue(null),Ye(!1),at(null),vn(!1),Ve(null),cn(!1),Ft(""),He(!1),Tt(null),qe(!1),ci(null),n("/upload",{replace:!0})},bo=v.useCallback(k=>{k==="/upload"||k==="/"||(b.current?(xe(k),Me(!0)):n(k))},[n]);async function $u(){if(ye&&b.current)try{await fetch(`/api/images/${b.current}`,{method:"DELETE"}),Me(!1),xe(null),n(ye)}catch(k){console.error("Failed to delete image before navigation:",k),Me(!1),xe(null),n(ye)}}const Ca=async()=>{if(yn){cn(!0),Ft("Starting file conversion...");try{const k=new FormData;k.append("file",yn),k.append("preprocess_only","true"),Ft("Converting file format...");const ke=await fetch("/api/images/preprocess",{method:"POST",body:k});if(!ke.ok)throw new Error("Preprocessing failed");const _e=await ke.json();Ft("Finalizing conversion...");const oe=atob(_e.processed_content),De=new Uint8Array(oe.length);for(let Rt=0;Rt[...Rt,Ke]),w(It),Ft("Conversion complete!"),setTimeout(()=>{vn(!1),Ve(null),cn(!1),Ft("")},1e3)}catch(k){console.error("Preprocessing error:",k),Ft("Conversion failed. Please try again."),setTimeout(()=>{vn(!1),Ve(null),cn(!1),Ft("")},2e3)}}},Co=()=>{vn(!1),Ve(null),cn(!1),Ft("")},Sa=async k=>{f(!0);try{const ke=k.map(async Ke=>{const It=await fetch(`/api/images/${Ke}`);if(!It.ok)throw new Error(`Failed to fetch image ${Ke}`);const Rt=await It.json(),Pt=await fetch(`/api/images/${Ke}/file`);if(!Pt.ok)throw new Error(`Failed to fetch image file ${Ke}`);const Lt=await Pt.blob(),ir=Rt.file_key.split("/").pop()||`contributed_${Ke}.png`;return{file:new File([Lt],ir,{type:Lt.type}),imageData:Rt}}),_e=await Promise.all(ke),oe=_e.map(Ke=>Ke.file),De=_e[0]?.imageData;T(oe),Vt(k),k.length===1&&wt(k[0]),oe.length>=1&&S(oe[0]),De?.image_type&&de(De.image_type)}catch(ke){console.error("Failed to fetch contributed images:",ke),alert(`Failed to load contributed images: ${ke instanceof Error?ke.message:"Unknown error"}`)}finally{f(!1)}};return v.useEffect(()=>{Promise.all([fetch("/api/sources").then(k=>k.json()),fetch("/api/types").then(k=>k.json()),fetch("/api/spatial-references").then(k=>k.json()),fetch("/api/image-types").then(k=>k.json()),fetch("/api/countries").then(k=>k.json()),fetch("/api/models").then(k=>k.json())]).then(([k,ke,_e,oe,De,Ke])=>{!localStorage.getItem(Jl)&&Ke?.length&&localStorage.setItem(Jl,Ke[0].m_code),pn(k),ai(ke),gn(_e),Yn(oe),Yt(De),k.length>0&&$(k[0].s_code),oe.length>0&&!e.get("imageType")&&!K&&de(oe[0].image_type)})},[e,K]),v.useEffect(()=>(window.confirmNavigationIfNeeded=k=>{bo(k)},()=>{delete window.confirmNavigationIfNeeded}),[bo]),v.useEffect(()=>{const k=oe=>{if(b.current){const De="You have an uploaded image that will be deleted if you leave this page. Are you sure you want to leave?";return oe.preventDefault(),oe.returnValue=De,De}},ke=()=>{b.current&&fetch(`/api/images/${b.current}`,{method:"DELETE"}).catch(console.error)},_e=oe=>{const De=oe.target,Ke=De.closest("a[href]")||De.closest("[data-navigate]");if(Ke&&b.current){const It=Ke.getAttribute("href")||Ke.getAttribute("data-navigate");It&&It!=="#"&&!It.startsWith("javascript:")&&!It.startsWith("mailto:")&&(oe.preventDefault(),oe.stopPropagation(),bo(It))}};return window.addEventListener("beforeunload",k),document.addEventListener("click",_e,!0),()=>{window.removeEventListener("beforeunload",k),document.removeEventListener("click",_e,!0),ke()}},[bo]),v.useEffect(()=>{if(!N){w(null);return}const k=URL.createObjectURL(N);return w(k),()=>URL.revokeObjectURL(k)},[N]),v.useEffect(()=>{const k=e.get("contribute"),ke=e.get("imageIds");if(k==="true"&&ke){const _e=ke.split(",").filter(oe=>oe.trim());_e.length>0&&Sa(_e)}},[e]),v.useEffect(()=>{i==="2b"&&Ur(0)},[i]),h.jsxs(Iu,{children:[i!==3&&h.jsx("div",{className:"max-w-7xl mx-auto",children:h.jsxs("div",{className:q.uploadContainer,"data-step":i,children:[i===1&&!e.get("step")&&!d&&h.jsx(Kg,{files:_,file:N,preview:m,imageType:K,isManualMode:ee,onFileChange:ya,onRemoveImage:tr,onAddImage:er,onImageTypeChange:fa,onManualModeChange:me,onChangeFile:wa}),i===1&&e.get("contribute")==="true"&&!d&&_.length>0&&h.jsx(Kg,{files:_,file:N,preview:m,imageType:K,isManualMode:ee,onFileChange:ya,onRemoveImage:tr,onAddImage:er,onImageTypeChange:fa,onManualModeChange:me,onChangeFile:wa}),s&&h.jsxs("div",{className:q.loadingContainer,children:[h.jsx(Xo,{className:"text-ifrcRed"}),h.jsx("p",{className:q.loadingText,children:"Generating..."})]}),d&&h.jsxs("div",{className:q.loadingContainer,children:[h.jsx(Xo,{className:"text-ifrcRed"}),h.jsx("p",{className:q.loadingText,children:"Loading contribution..."})]}),(i===1&&!s&&!d||i===1&&e.get("contribute")==="true"&&!s&&!d&&_.length>0)&&h.jsx("div",{className:q.generateButtonContainer,children:yr?h.jsx(Be,{name:"generate-from-url",onClick:ba,children:ee?"Start":"Generate Caption"}):h.jsx(Be,{name:"generate",disabled:_.length===0,onClick:ba,children:ee?"Start":"Generate"})}),i==="2a"&&h.jsxs("div",{className:q.step2Layout,children:[h.jsx("div",{className:q.mapColumn,children:h.jsx(Yg,{files:_,imageUrl:yr,preview:m,onViewFullSize:k=>{li(k||null),Xn(!0)}})}),h.jsx("div",{className:q.contentColumn,children:h.jsxs("div",{className:q.metadataSectionCard,children:[h.jsx(vP,{files:_,imageType:K,title:H,source:M,eventType:F,epsg:fe,countries:pe,centerLon:Ce,centerLat:Z,amslM:j,aglM:ae,headingDeg:le,yawDeg:te,pitchDeg:Y,rollDeg:an,rtkFix:ot,stdHM:lt,stdVM:ct,metadataArray:yt,sources:sn,types:Ln,spatialReferences:mn,imageTypes:Rr,countriesOptions:Ht,onTitleChange:k=>G(k||""),onSourceChange:zi,onEventTypeChange:yo,onEpsgChange:Ru,onCountriesChange:ha,onCenterLonChange:Is,onCenterLatChange:pa,onAmslMChange:Bi,onAglMChange:Au,onHeadingDegChange:ma,onYawDegChange:tt,onPitchDegChange:Rs,onRollDegChange:As,onRtkFixChange:ga,onStdHMChange:$s,onStdVMChange:Fs,onImageTypeChange:fa,updateMetadataForImage:Hi}),h.jsxs("div",{className:q.confirmSection,children:[h.jsx(kf,{name:"delete",variant:"tertiary",onClick:fi,title:"Delete",ariaLabel:"Delete uploaded image",children:h.jsx(_f,{})}),h.jsx(Be,{name:"confirm-metadata",onClick:()=>Ui("2b"),children:"Next"})]})]})})]}),i==="2b"&&h.jsxs("div",{className:q.step2bLayout,children:[g&&h.jsxs("div",{className:q.loadingContainer,children:[h.jsx(Xo,{className:"text-ifrcRed"}),h.jsx("p",{className:q.loadingText,children:"Submitting..."})]}),h.jsxs("div",{className:`${q.topRow} ${On?q.ratingHidden:""}`,children:[h.jsx("div",{className:q.imageSection,children:h.jsx(Yg,{files:_,imageUrl:yr,preview:m,onViewFullSize:k=>{li(k||null),Xn(!0)},currentImageIndex:da,onGoToPrevious:va,onGoToNext:wo,onGoToImage:Sr,showCarousel:!0})}),!On&&h.jsx("div",{className:q.metadataSectionCard,children:h.jsx(yP,{isPerformanceConfirmed:On,scores:wr,onScoreChange:(k,ke)=>Ai(_e=>({..._e,[k]:ke})),onConfirmRatings:()=>P(!0),onEditRatings:()=>P(!1)})})]}),h.jsx("div",{className:q.metadataSectionCard,children:h.jsx(wP,{description:$r,analysis:Fr,recommendedActions:Dn,isManualMode:ee,onDescriptionChange:k=>Mn(k||""),onAnalysisChange:k=>un(k||""),onRecommendedActionsChange:k=>zr(k||""),onBack:()=>Ui("2a"),onDelete:fi,onSubmit:Vi,onEditRatings:()=>P(!1),isPerformanceConfirmed:On,isSubmitting:g})})]})]})}),i===3&&h.jsxs("div",{className:q.successContainer,children:[h.jsx(kn,{level:2,className:q.successHeading,children:"Saved!"}),h.jsx("p",{className:q.successText,children:e.get("contribute")==="true"?"Your contribution has been successfully saved.":"Your caption has been successfully saved."}),h.jsx("div",{className:q.successButton,children:h.jsx(Be,{name:"upload-another",onClick:()=>{qi()},children:"Upload Another"})})]}),h.jsx(xP,{isOpen:$i,imageUrl:yr,preview:m,selectedImageData:xr,onClose:()=>{Xn(!1),li(null)}}),h.jsx(bP,{isOpen:I,onClose:()=>U(!1)}),h.jsx(CP,{isOpen:X,onConfirm:hi,onCancel:()=>ce(!1)}),h.jsx(SP,{isOpen:Te,onConfirm:$u,onCancel:()=>Me(!1)}),h.jsx(_P,{isOpen:we,fallbackInfo:$e,onClose:()=>ve(!1)}),h.jsx(EP,{isOpen:jt,preprocessingInfo:Ze,onClose:()=>Ye(!1)}),h.jsx(NP,{isOpen:Jn,isPreprocessing:Fi,preprocessingProgress:Hn,onConfirm:Ca,onCancel:Co}),h.jsx(kP,{isOpen:ui,unsupportedFile:nt,onClose:()=>He(!1)}),h.jsx(jP,{isOpen:Br,oversizedFile:br,onClose:()=>qe(!1),onCancel:()=>qe(!1)})]})}const TP="_helpContainer_1wavj_1",PP="_helpSection_1wavj_13",LP="_sectionHeader_1wavj_49",MP="_sectionTitle_1wavj_91",DP="_sectionContent_1wavj_105",OP="_guidelinesList_1wavj_119",IP="_buttonContainer_1wavj_181",ut={helpContainer:TP,helpSection:PP,sectionHeader:LP,sectionTitle:MP,sectionContent:DP,guidelinesList:OP,buttonContainer:IP};function RP(){const e=ks(),{setShowReferenceExamples:n}=cP(),i=()=>{e("/upload")},o=()=>{n(!0),e("/explore")},s=()=>{e("/analytics?view=crisis_maps")};return h.jsx(Iu,{className:"py-10",children:h.jsx("div",{className:ut.helpContainer,children:h.jsxs("div",{className:"space-y-8",children:[h.jsxs("div",{className:ut.helpSection,children:[h.jsx("div",{className:ut.sectionHeader,children:h.jsx(kn,{level:3,className:ut.sectionTitle,children:"Introduction"})}),h.jsx("div",{className:ut.sectionContent,children:"In collaboration with the IFRC, PromptAid Vision is a tool that generates textual descriptions of crisis maps/crisis drone images utiliing Visual language models. This prototype is for collecting data for the fine-tuning of our own models. We aim to utilize AI tools to support national societies with rapid decision making during emergencies."}),h.jsx("div",{className:ut.buttonContainer,children:h.jsx(Be,{name:"upload-now",variant:"secondary",onClick:i,children:"Upload now →"})})]}),h.jsxs("div",{className:ut.helpSection,children:[h.jsx("div",{className:ut.sectionHeader,children:h.jsx(kn,{level:3,className:ut.sectionTitle,children:"Guidelines"})}),h.jsxs("div",{className:ut.sectionContent,children:["To make the process smoother, please follow the guidelines below:",h.jsxs("ul",{className:ut.guidelinesList,children:[h.jsx("li",{children:"Avoid uploading images that are not crisis maps/crisis drone images."}),h.jsx("li",{children:"Confirm the image details prior to modifying the description."}),h.jsx("li",{children:"Before the modification, please read the description generated and provide a rating via the rating sliders."}),h.jsx("li",{children:'Click the "Submit" button to save the description.'})]})]}),h.jsx("div",{className:ut.buttonContainer,children:h.jsx(Be,{name:"see-examples",variant:"secondary",onClick:o,children:"See examples →"})})]}),h.jsxs("div",{className:ut.helpSection,children:[h.jsx("div",{className:ut.sectionHeader,children:h.jsx(kn,{level:3,className:ut.sectionTitle,children:"VLMs"})}),h.jsx("div",{className:ut.sectionContent,children:"PromptAid Vision uses a variety of Visual Language Models (VLMs). A random VLM is selected for each upload. Therefore feel free to delete and reupload. You can view performance details here:"}),h.jsx("div",{className:ut.buttonContainer,children:h.jsx(Be,{name:"view-vlm-details",variant:"secondary",onClick:s,children:"View VLM details →"})})]}),h.jsxs("div",{className:ut.helpSection,children:[h.jsx("div",{className:ut.sectionHeader,children:h.jsx(kn,{level:3,className:ut.sectionTitle,children:"Dataset"})}),h.jsx("div",{className:ut.sectionContent,children:"All users are able to export the dataset. You could apply filters when exporting, and it have the option to organize based on model fine-tuning formats."}),h.jsx("div",{className:ut.buttonContainer,children:h.jsx(Be,{name:"export-dataset",variant:"secondary",onClick:()=>{n(!1),e("/explore"),setTimeout(()=>{const u=document.querySelector('[name="export-dataset"]');u&&u.click()},100)},children:"Export dataset →"})})]}),h.jsxs("div",{className:ut.helpSection,children:[h.jsx("div",{className:ut.sectionHeader,children:h.jsx(kn,{level:3,className:ut.sectionTitle,children:"Contact us"})}),h.jsx("div",{className:ut.sectionContent,children:"Need help or have questions about PromptAid Vision? Our team is here to support you."}),h.jsx("div",{className:ut.buttonContainer,children:h.jsx(Be,{name:"contact-support",variant:"secondary",disabled:!0,children:"Get in touch →"})})]})]})})})}const AP="_demoContainer_19wfc_1",$P="_section_19wfc_13",FP="_pageTitle_19wfc_33",zP="_description_19wfc_43",BP="_sectionHeader_19wfc_57",UP="_sectionTitle_19wfc_65",HP="_sectionDescription_19wfc_75",VP="_switchGrid_19wfc_87",qP="_switchItem_19wfc_99",WP="_switchLabel_19wfc_119",GP="_switchWrapper_19wfc_133",ZP="_stateDisplay_19wfc_147",QP="_nativeCheckboxLabel_19wfc_165",KP="_nativeCheckbox_19wfc_165",YP="_buttonToggle_19wfc_197",XP="_buttonToggleOff_19wfc_219",JP="_buttonToggleOn_19wfc_231",eL="_buttonToggleText_19wfc_253",he={demoContainer:AP,section:$P,pageTitle:FP,description:zP,sectionHeader:BP,sectionTitle:UP,sectionDescription:HP,switchGrid:VP,switchItem:qP,switchLabel:WP,switchWrapper:GP,stateDisplay:ZP,nativeCheckboxLabel:QP,nativeCheckbox:KP,buttonToggle:YP,buttonToggleOff:XP,buttonToggleOn:JP,buttonToggleText:eL};function tL(){const[e,n]=v.useState("off"),[i,o]=v.useState("on"),[s,u]=v.useState(!1),[d,f]=v.useState(!0),[g,y]=v.useState(!1),[x,b]=v.useState(!0),[m,w]=v.useState(!1),[N,S]=v.useState(!0),[_,T]=v.useState(!1),[M,$]=v.useState(!1);return h.jsx(Iu,{className:"py-10",children:h.jsx("div",{className:he.demoContainer,children:h.jsxs("div",{className:"space-y-12",children:[h.jsxs("div",{className:he.section,children:[h.jsx(kn,{level:2,className:he.pageTitle,children:"Switch Components Demo"}),h.jsx("p",{className:he.description,children:"This page showcases all available switch/toggle implementations. Each switch is clearly labeled so you can easily identify and compare different UI patterns."})]}),h.jsxs("div",{className:he.section,children:[h.jsxs("div",{className:he.sectionHeader,children:[h.jsx(kn,{level:3,className:he.sectionTitle,children:"1. SegmentInput Switches (IFRC UI)"}),h.jsx("p",{className:he.sectionDescription,children:"Using SegmentInput component for binary on/off choices"})]}),h.jsxs("div",{className:he.switchGrid,children:[h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Switch 1: SegmentInput (Off by default)"}),h.jsx(on,{withInternalPadding:!0,className:he.switchWrapper,children:h.jsx(su,{name:"switch-1",value:e,onChange:F=>{(F==="on"||F==="off")&&n(F)},options:[{key:"off",label:"Off"},{key:"on",label:"On"}],keySelector:F=>F.key,labelSelector:F=>F.label})}),h.jsxs("div",{className:he.stateDisplay,children:["State: ",h.jsx("strong",{children:e})]})]}),h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Switch 2: SegmentInput (On by default)"}),h.jsx(on,{withInternalPadding:!0,className:he.switchWrapper,children:h.jsx(su,{name:"switch-2",value:i,onChange:F=>{(F==="on"||F==="off")&&o(F)},options:[{key:"off",label:"Off"},{key:"on",label:"On"}],keySelector:F=>F.key,labelSelector:F=>F.label})}),h.jsxs("div",{className:he.stateDisplay,children:["State: ",h.jsx("strong",{children:i})]})]})]})]}),h.jsxs("div",{className:he.section,children:[h.jsxs("div",{className:he.sectionHeader,children:[h.jsx(kn,{level:3,className:he.sectionTitle,children:"2. IFRC Checkbox Switches"}),h.jsx("p",{className:he.sectionDescription,children:"Using Checkbox component from @ifrc-go/ui for on/off toggles"})]}),h.jsxs("div",{className:he.switchGrid,children:[h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Switch 3: IFRC Checkbox (Off by default)"}),h.jsx(wd,{name:"switch-3",value:s,onChange:u,label:"Enable feature"}),h.jsxs("div",{className:he.stateDisplay,children:["State: ",h.jsx("strong",{children:s?"On":"Off"})]})]}),h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Switch 4: IFRC Checkbox (On by default)"}),h.jsx(wd,{name:"switch-4",value:d,onChange:f,label:"Auto-save enabled"}),h.jsxs("div",{className:he.stateDisplay,children:["State: ",h.jsx("strong",{children:d?"On":"Off"})]})]})]})]}),h.jsxs("div",{className:he.section,children:[h.jsxs("div",{className:he.sectionHeader,children:[h.jsx(kn,{level:3,className:he.sectionTitle,children:"3. Native HTML Checkbox Switches"}),h.jsx("p",{className:he.sectionDescription,children:'Using native HTML input[type="checkbox"] elements (as used in AdminPage)'})]}),h.jsxs("div",{className:he.switchGrid,children:[h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Switch 5: Native Checkbox (Off by default)"}),h.jsxs("label",{className:he.nativeCheckboxLabel,children:[h.jsx("input",{type:"checkbox",checked:g,onChange:F=>y(F.target.checked),className:he.nativeCheckbox}),h.jsx("span",{children:"Available for use"})]}),h.jsxs("div",{className:he.stateDisplay,children:["State: ",h.jsx("strong",{children:g?"On":"Off"})]})]}),h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Switch 6: Native Checkbox (On by default)"}),h.jsxs("label",{className:he.nativeCheckboxLabel,children:[h.jsx("input",{type:"checkbox",checked:x,onChange:F=>b(F.target.checked),className:he.nativeCheckbox}),h.jsx("span",{children:"RTK Fix Available"})]}),h.jsxs("div",{className:he.stateDisplay,children:["State: ",h.jsx("strong",{children:x?"On":"Off"})]})]})]})]}),h.jsxs("div",{className:he.section,children:[h.jsxs("div",{className:he.sectionHeader,children:[h.jsx(kn,{level:3,className:he.sectionTitle,children:"4. Custom CSS Toggle Switches"}),h.jsx("p",{className:he.sectionDescription,children:"Custom-built toggle switch component with smooth animations"})]}),h.jsxs("div",{className:he.switchGrid,children:[h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Switch 7: Custom Toggle (Off by default)"}),h.jsx(ls,{name:"switch-7",checked:m,onChange:w,label:"Enable notifications"}),h.jsxs("div",{className:he.stateDisplay,children:["State: ",h.jsx("strong",{children:m?"On":"Off"})]})]}),h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Switch 8: Custom Toggle (On by default)"}),h.jsx(ls,{name:"switch-8",checked:N,onChange:S,label:"Dark mode"}),h.jsxs("div",{className:he.stateDisplay,children:["State: ",h.jsx("strong",{children:N?"On":"Off"})]})]}),h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Switch 9: Custom Toggle (No label, Off by default)"}),h.jsx(ls,{name:"switch-9",checked:_,onChange:T}),h.jsxs("div",{className:he.stateDisplay,children:["State: ",h.jsx("strong",{children:_?"On":"Off"})]})]})]})]}),h.jsxs("div",{className:he.section,children:[h.jsxs("div",{className:he.sectionHeader,children:[h.jsx(kn,{level:3,className:he.sectionTitle,children:"5. Button-based Toggle Switch"}),h.jsx("p",{className:he.sectionDescription,children:"Using a button element styled as a toggle switch"})]}),h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Switch 10: Button Toggle (Off by default)"}),h.jsx("button",{type:"button",className:`${he.buttonToggle} ${M?he.buttonToggleOn:he.buttonToggleOff}`,onClick:()=>$(!M),children:h.jsx("span",{className:he.buttonToggleText,children:M?"On":"Off"})}),h.jsxs("div",{className:he.stateDisplay,children:["State: ",h.jsx("strong",{children:M?"On":"Off"})]})]})]}),h.jsxs("div",{className:he.section,children:[h.jsxs("div",{className:he.sectionHeader,children:[h.jsx(kn,{level:3,className:he.sectionTitle,children:"6. Disabled Switch States"}),h.jsx("p",{className:he.sectionDescription,children:"Examples of switches in disabled state"})]}),h.jsxs("div",{className:he.switchGrid,children:[h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Disabled SegmentInput"}),h.jsx(on,{withInternalPadding:!0,className:he.switchWrapper,children:h.jsx(su,{name:"disabled-segment",value:"on",onChange:()=>{},options:[{key:"off",label:"Off"},{key:"on",label:"On"}],keySelector:F=>F.key,labelSelector:F=>F.label,disabled:!0})})]}),h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Disabled IFRC Checkbox"}),h.jsx(wd,{name:"disabled-checkbox",value:!0,onChange:()=>{},label:"Disabled option",disabled:!0})]}),h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Disabled Custom Toggle"}),h.jsx(ls,{name:"disabled-custom",checked:!0,onChange:()=>{},label:"Disabled toggle",disabled:!0})]})]})]})]})})})}const nL=v.createContext(void 0),rL=({children:e})=>{const[n,i]=v.useState(!1),[o,s]=v.useState(!0),u=async()=>{const y=localStorage.getItem("adminToken");if(!y){i(!1),s(!1);return}try{(await fetch("/api/admin/verify",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y}`}})).ok?i(!0):(localStorage.removeItem("adminToken"),i(!1))}catch(x){console.error("Error verifying admin token:",x),localStorage.removeItem("adminToken"),i(!1)}finally{s(!1)}},d=async y=>{try{const x=await fetch("/api/admin/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:y})});if(x.ok){const b=await x.json();return localStorage.setItem("adminToken",b.access_token),i(!0),!0}else return!1}catch(x){return console.error("Login error:",x),!1}},f=()=>{localStorage.removeItem("adminToken"),i(!1)};v.useEffect(()=>{u()},[]);const g={isAuthenticated:n,isLoading:o,login:d,logout:f,verifyToken:u};return h.jsx(nL.Provider,{value:g,children:e})},iL=v.lazy(()=>Kn(()=>import("./index-DRmfVC9B.js"),__vite__mapDeps([0,1]))),oL=v.lazy(()=>Kn(()=>import("./index-tBgmM5yL.js"),__vite__mapDeps([2,3,4,5,6]))),aL=v.lazy(()=>Kn(()=>import("./AdminPage-CwitwbVg.js"),__vite__mapDeps([7,3,8]))),sL=v.lazy(()=>Kn(()=>import("./index-HD7t9Ly0.js"),__vite__mapDeps([9,3,4,5,10])));class lL extends v.Component{constructor(n){super(n),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(n,i){console.error("Error caught by boundary:",n,i)}render(){return this.state.hasError?h.jsxs("div",{style:{padding:"20px",textAlign:"center"},children:[h.jsx("h2",{children:"Something went wrong"}),h.jsx("p",{children:"Please refresh the page to try again."}),h.jsx("button",{onClick:()=>window.location.reload(),children:"Refresh Page"})]}):this.props.children}}const Pi=e=>{const n=e();return n.catch(()=>{}),n},uL=()=>{"requestIdleCallback"in window?requestIdleCallback(()=>{Pi(()=>Kn(()=>import("./index-DRmfVC9B.js"),__vite__mapDeps([0,1]))),Pi(()=>Kn(()=>import("./index-tBgmM5yL.js"),__vite__mapDeps([2,3,4,5,6]))),Pi(()=>Kn(()=>import("./AdminPage-CwitwbVg.js"),__vite__mapDeps([7,3,8]))),Pi(()=>Kn(()=>import("./index-HD7t9Ly0.js"),__vite__mapDeps([9,3,4,5,10])))}):setTimeout(()=>{Pi(()=>Kn(()=>import("./index-DRmfVC9B.js"),__vite__mapDeps([0,1]))),Pi(()=>Kn(()=>import("./index-tBgmM5yL.js"),__vite__mapDeps([2,3,4,5,6]))),Pi(()=>Kn(()=>import("./AdminPage-CwitwbVg.js"),__vite__mapDeps([7,3,8]))),Pi(()=>Kn(()=>import("./index-HD7t9Ly0.js"),__vite__mapDeps([9,3,4,5,10])))},1e3)};function cL(){const e=v.useMemo(()=>Ex([{element:h.jsx(ZT,{}),children:[{path:"/",element:h.jsx(Xg,{})},{path:"/upload",element:h.jsx(Xg,{})},{path:"/analytics",element:h.jsx(v.Suspense,{fallback:h.jsx("div",{children:"Loading Analytics..."}),children:h.jsx(iL,{})})},{path:"/explore",element:h.jsx(v.Suspense,{fallback:h.jsx("div",{children:"Loading Explore..."}),children:h.jsx(oL,{})})},{path:"/help",element:h.jsx(RP,{})},{path:"/demo",element:h.jsx(tL,{})},{path:"/admin",element:h.jsx(v.Suspense,{fallback:h.jsx("div",{children:"Loading Admin..."}),children:h.jsx(aL,{})})},{path:"/map/:mapId",element:h.jsx(v.Suspense,{fallback:h.jsx("div",{children:"Loading Map Details..."}),children:h.jsx(sL,{})})}]}],{basename:"/"}),[]),[n,i]=v.useState([]);v.useEffect(()=>{uL()},[]);const o=v.useCallback(g=>{i(y=>Qx([...y,g],x=>x.name)??y)},[i]),s=v.useCallback(g=>{i(y=>{const x=y.findIndex(m=>m.name===g);if(x===-1)return y;const b=[...y];return b.splice(x,1),b})},[i]),u=v.useCallback((g,y)=>{i(x=>{const b=x.findIndex(w=>w.name===g);if(b===-1)return x;const m=[...x];return m[b]={...m[b],...y},m})},[i]),d=v.useMemo(()=>({alerts:n,addAlert:o,removeAlert:s,updateAlert:u}),[n,o,s,u]),f=v.useMemo(()=>({languageNamespaceStatus:{},setLanguageNamespaceStatus:()=>{},currentLanguage:"en",setCurrentLanguage:()=>{},strings:{},setStrings:()=>{},registerNamespace:()=>{}}),[]);return h.jsx(lL,{children:h.jsx(Wx.Provider,{value:d,children:h.jsx(y0.Provider,{value:f,children:h.jsx(rL,{children:h.jsx(uP,{children:h.jsx(Ox,{router:e})})})})})})}function dL(){return h.jsx(cL,{})}console.log("React version at runtime:",v.version,"createContext exists?",!!v.createContext);X1.createRoot(document.getElementById("root")).render(h.jsx(v.StrictMode,{children:h.jsx(dL,{})}));export{Mb as A,ua as B,pL as C,cP as D,vL as E,_f as F,Kn as G,kn as H,q as I,io as J,hL as K,su as L,xP as M,Iu as N,kt as O,qg as P,wL as Q,E0 as R,wd as S,nL as T,yL as U,fL as V,e0 as W,Xo as _,Fe as a,Dt as b,CL as c,SL as d,mL as e,Pb as f,S0 as g,bL as h,xL as i,h as j,gr as k,Jx as l,eN as m,Be as n,Le as o,nb as p,cs as q,v as r,_0 as s,y0 as t,Bx as u,Ab as v,$b as w,ks as x,gL as y,on as z}; +Recommended Actions: ${Dn}`,_e={title:H,edited:ke,accuracy:wr.accuracy,context:wr.context,usability:wr.usability};console.log("Updating caption:",_e);const oe=await fetch(`/api/images/${Ct}/caption`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(_e)}),De=await rr(oe);if(!oe.ok)throw new Error(De.error||"Caption update failed");wt(null),Vt([]),Ui(3)}catch(k){xa(k,"Submit")}finally{y(!1)}}async function fi(){if(console.log("handleDelete called with uploadedImageId:",Ct),!Ct){alert("No image to delete. Please try refreshing the page.");return}ce(!0)}async function hi(){try{console.log("Deleting image with ID:",Ct);const k=await fetch(`/api/images/${Ct}`,{method:"DELETE"});if(!k.ok){const ke=await rr(k);throw new Error(ke.error||`Delete failed with status ${k.status}`)}ce(!1),qi()}catch(k){xa(k,"Delete")}}const qi=()=>{P(!1),o(1),S(null),T([]),w(null),wt(null),Vt([]),Ri(null),G(""),$(""),W(""),O(""),R([]),Ee(""),ue(""),V(""),Se(""),re(""),Q(""),Je(""),Ut(""),vt(!1),pt(""),dt(""),Ai({accuracy:50,context:50,usability:50}),Ar(""),Mn(""),un(""),zr(""),Ot([]),ve(!1),Ue(null),Ye(!1),at(null),vn(!1),Ve(null),cn(!1),Ft(""),He(!1),Tt(null),qe(!1),ci(null),n("/upload",{replace:!0})},bo=v.useCallback(k=>{k==="/upload"||k==="/"||(b.current?(xe(k),Me(!0)):n(k))},[n]);async function $u(){if(ye&&b.current)try{await fetch(`/api/images/${b.current}`,{method:"DELETE"}),Me(!1),xe(null),n(ye)}catch(k){console.error("Failed to delete image before navigation:",k),Me(!1),xe(null),n(ye)}}const Ca=async()=>{if(yn){cn(!0),Ft("Starting file conversion...");try{const k=new FormData;k.append("file",yn),k.append("preprocess_only","true"),Ft("Converting file format...");const ke=await fetch("/api/images/preprocess",{method:"POST",body:k});if(!ke.ok)throw new Error("Preprocessing failed");const _e=await ke.json();Ft("Finalizing conversion...");const oe=atob(_e.processed_content),De=new Uint8Array(oe.length);for(let Rt=0;Rt[...Rt,Ke]),w(It),Ft("Conversion complete!"),setTimeout(()=>{vn(!1),Ve(null),cn(!1),Ft("")},1e3)}catch(k){console.error("Preprocessing error:",k),Ft("Conversion failed. Please try again."),setTimeout(()=>{vn(!1),Ve(null),cn(!1),Ft("")},2e3)}}},Co=()=>{vn(!1),Ve(null),cn(!1),Ft("")},Sa=async k=>{f(!0);try{const ke=k.map(async Ke=>{const It=await fetch(`/api/images/${Ke}`);if(!It.ok)throw new Error(`Failed to fetch image ${Ke}`);const Rt=await It.json(),Pt=await fetch(`/api/images/${Ke}/file`);if(!Pt.ok)throw new Error(`Failed to fetch image file ${Ke}`);const Lt=await Pt.blob(),ir=Rt.file_key.split("/").pop()||`contributed_${Ke}.png`;return{file:new File([Lt],ir,{type:Lt.type}),imageData:Rt}}),_e=await Promise.all(ke),oe=_e.map(Ke=>Ke.file),De=_e[0]?.imageData;T(oe),Vt(k),k.length===1&&wt(k[0]),oe.length>=1&&S(oe[0]),De?.image_type&&de(De.image_type)}catch(ke){console.error("Failed to fetch contributed images:",ke),alert(`Failed to load contributed images: ${ke instanceof Error?ke.message:"Unknown error"}`)}finally{f(!1)}};return v.useEffect(()=>{Promise.all([fetch("/api/sources").then(k=>k.json()),fetch("/api/types").then(k=>k.json()),fetch("/api/spatial-references").then(k=>k.json()),fetch("/api/image-types").then(k=>k.json()),fetch("/api/countries").then(k=>k.json()),fetch("/api/models").then(k=>k.json())]).then(([k,ke,_e,oe,De,Ke])=>{!localStorage.getItem(Jl)&&Ke?.length&&localStorage.setItem(Jl,Ke[0].m_code),pn(k),ai(ke),gn(_e),Yn(oe),Yt(De),k.length>0&&$(k[0].s_code),oe.length>0&&!e.get("imageType")&&!K&&de(oe[0].image_type)})},[e,K]),v.useEffect(()=>(window.confirmNavigationIfNeeded=k=>{bo(k)},()=>{delete window.confirmNavigationIfNeeded}),[bo]),v.useEffect(()=>{const k=oe=>{if(b.current){const De="You have an uploaded image that will be deleted if you leave this page. Are you sure you want to leave?";return oe.preventDefault(),oe.returnValue=De,De}},ke=()=>{b.current&&fetch(`/api/images/${b.current}`,{method:"DELETE"}).catch(console.error)},_e=oe=>{const De=oe.target,Ke=De.closest("a[href]")||De.closest("[data-navigate]");if(Ke&&b.current){const It=Ke.getAttribute("href")||Ke.getAttribute("data-navigate");It&&It!=="#"&&!It.startsWith("javascript:")&&!It.startsWith("mailto:")&&(oe.preventDefault(),oe.stopPropagation(),bo(It))}};return window.addEventListener("beforeunload",k),document.addEventListener("click",_e,!0),()=>{window.removeEventListener("beforeunload",k),document.removeEventListener("click",_e,!0),ke()}},[bo]),v.useEffect(()=>{if(!N){w(null);return}const k=URL.createObjectURL(N);return w(k),()=>URL.revokeObjectURL(k)},[N]),v.useEffect(()=>{const k=e.get("contribute"),ke=e.get("imageIds");if(k==="true"&&ke){const _e=ke.split(",").filter(oe=>oe.trim());_e.length>0&&Sa(_e)}},[e]),v.useEffect(()=>{i==="2b"&&Ur(0)},[i]),h.jsxs(Iu,{children:[i!==3&&h.jsx("div",{className:"max-w-7xl mx-auto",children:h.jsxs("div",{className:q.uploadContainer,"data-step":i,children:[i===1&&!e.get("step")&&!d&&h.jsx(Kg,{files:_,file:N,preview:m,imageType:K,isManualMode:ee,onFileChange:ya,onRemoveImage:tr,onAddImage:er,onImageTypeChange:fa,onManualModeChange:me,onChangeFile:wa}),i===1&&e.get("contribute")==="true"&&!d&&_.length>0&&h.jsx(Kg,{files:_,file:N,preview:m,imageType:K,isManualMode:ee,onFileChange:ya,onRemoveImage:tr,onAddImage:er,onImageTypeChange:fa,onManualModeChange:me,onChangeFile:wa}),s&&h.jsxs("div",{className:q.loadingContainer,children:[h.jsx(Xo,{className:"text-ifrcRed"}),h.jsx("p",{className:q.loadingText,children:"Generating..."})]}),d&&h.jsxs("div",{className:q.loadingContainer,children:[h.jsx(Xo,{className:"text-ifrcRed"}),h.jsx("p",{className:q.loadingText,children:"Loading contribution..."})]}),(i===1&&!s&&!d||i===1&&e.get("contribute")==="true"&&!s&&!d&&_.length>0)&&h.jsx("div",{className:q.generateButtonContainer,children:yr?h.jsx(Be,{name:"generate-from-url",onClick:ba,children:ee?"Start":"Generate Caption"}):h.jsx(Be,{name:"generate",disabled:_.length===0,onClick:ba,children:ee?"Start":"Generate"})}),i==="2a"&&h.jsxs("div",{className:q.step2Layout,children:[h.jsx("div",{className:q.mapColumn,children:h.jsx(Yg,{files:_,imageUrl:yr,preview:m,onViewFullSize:k=>{li(k||null),Xn(!0)}})}),h.jsx("div",{className:q.contentColumn,children:h.jsxs("div",{className:q.metadataSectionCard,children:[h.jsx(vP,{files:_,imageType:K,title:H,source:M,eventType:F,epsg:fe,countries:pe,centerLon:Ce,centerLat:Z,amslM:j,aglM:ae,headingDeg:le,yawDeg:te,pitchDeg:Y,rollDeg:an,rtkFix:ot,stdHM:lt,stdVM:ct,metadataArray:yt,sources:sn,types:Ln,spatialReferences:mn,imageTypes:Rr,countriesOptions:Ht,onTitleChange:k=>G(k||""),onSourceChange:zi,onEventTypeChange:yo,onEpsgChange:Ru,onCountriesChange:ha,onCenterLonChange:Is,onCenterLatChange:pa,onAmslMChange:Bi,onAglMChange:Au,onHeadingDegChange:ma,onYawDegChange:tt,onPitchDegChange:Rs,onRollDegChange:As,onRtkFixChange:ga,onStdHMChange:$s,onStdVMChange:Fs,onImageTypeChange:fa,updateMetadataForImage:Hi}),h.jsxs("div",{className:q.confirmSection,children:[h.jsx(kf,{name:"delete",variant:"tertiary",onClick:fi,title:"Delete",ariaLabel:"Delete uploaded image",children:h.jsx(_f,{})}),h.jsx(Be,{name:"confirm-metadata",onClick:()=>Ui("2b"),children:"Next"})]})]})})]}),i==="2b"&&h.jsxs("div",{className:q.step2bLayout,children:[g&&h.jsxs("div",{className:q.loadingContainer,children:[h.jsx(Xo,{className:"text-ifrcRed"}),h.jsx("p",{className:q.loadingText,children:"Submitting..."})]}),h.jsxs("div",{className:`${q.topRow} ${On?q.ratingHidden:""}`,children:[h.jsx("div",{className:q.imageSection,children:h.jsx(Yg,{files:_,imageUrl:yr,preview:m,onViewFullSize:k=>{li(k||null),Xn(!0)},currentImageIndex:da,onGoToPrevious:va,onGoToNext:wo,onGoToImage:Sr,showCarousel:!0})}),!On&&h.jsx("div",{className:q.metadataSectionCard,children:h.jsx(yP,{isPerformanceConfirmed:On,scores:wr,onScoreChange:(k,ke)=>Ai(_e=>({..._e,[k]:ke})),onConfirmRatings:()=>P(!0),onEditRatings:()=>P(!1)})})]}),h.jsx("div",{className:q.metadataSectionCard,children:h.jsx(wP,{description:$r,analysis:Fr,recommendedActions:Dn,isManualMode:ee,onDescriptionChange:k=>Mn(k||""),onAnalysisChange:k=>un(k||""),onRecommendedActionsChange:k=>zr(k||""),onBack:()=>Ui("2a"),onDelete:fi,onSubmit:Vi,onEditRatings:()=>P(!1),isPerformanceConfirmed:On,isSubmitting:g})})]})]})}),i===3&&h.jsxs("div",{className:q.successContainer,children:[h.jsx(kn,{level:2,className:q.successHeading,children:"Saved!"}),h.jsx("p",{className:q.successText,children:e.get("contribute")==="true"?"Your contribution has been successfully saved.":"Your caption has been successfully saved."}),h.jsx("div",{className:q.successButton,children:h.jsx(Be,{name:"upload-another",onClick:()=>{qi()},children:"Upload Another"})})]}),h.jsx(xP,{isOpen:$i,imageUrl:yr,preview:m,selectedImageData:xr,onClose:()=>{Xn(!1),li(null)}}),h.jsx(bP,{isOpen:I,onClose:()=>U(!1)}),h.jsx(CP,{isOpen:X,onConfirm:hi,onCancel:()=>ce(!1)}),h.jsx(SP,{isOpen:Te,onConfirm:$u,onCancel:()=>Me(!1)}),h.jsx(_P,{isOpen:we,fallbackInfo:$e,onClose:()=>ve(!1)}),h.jsx(EP,{isOpen:jt,preprocessingInfo:Ze,onClose:()=>Ye(!1)}),h.jsx(NP,{isOpen:Jn,isPreprocessing:Fi,preprocessingProgress:Hn,onConfirm:Ca,onCancel:Co}),h.jsx(kP,{isOpen:ui,unsupportedFile:nt,onClose:()=>He(!1)}),h.jsx(jP,{isOpen:Br,oversizedFile:br,onClose:()=>qe(!1),onCancel:()=>qe(!1)})]})}const TP="_helpContainer_1wavj_1",PP="_helpSection_1wavj_13",LP="_sectionHeader_1wavj_49",MP="_sectionTitle_1wavj_91",DP="_sectionContent_1wavj_105",OP="_guidelinesList_1wavj_119",IP="_buttonContainer_1wavj_181",ut={helpContainer:TP,helpSection:PP,sectionHeader:LP,sectionTitle:MP,sectionContent:DP,guidelinesList:OP,buttonContainer:IP};function RP(){const e=ks(),{setShowReferenceExamples:n}=cP(),i=()=>{e("/upload")},o=()=>{n(!0),e("/explore")},s=()=>{e("/analytics?view=crisis_maps")};return h.jsx(Iu,{className:"py-10",children:h.jsx("div",{className:ut.helpContainer,children:h.jsxs("div",{className:"space-y-8",children:[h.jsxs("div",{className:ut.helpSection,children:[h.jsx("div",{className:ut.sectionHeader,children:h.jsx(kn,{level:3,className:ut.sectionTitle,children:"Introduction"})}),h.jsx("div",{className:ut.sectionContent,children:"In collaboration with the IFRC, PromptAid Vision is a tool that generates textual descriptions of crisis maps/crisis drone images utiliing Visual language models. This prototype is for collecting data for the fine-tuning of our own models. We aim to utilize AI tools to support national societies with rapid decision making during emergencies."}),h.jsx("div",{className:ut.buttonContainer,children:h.jsx(Be,{name:"upload-now",variant:"secondary",onClick:i,children:"Upload now →"})})]}),h.jsxs("div",{className:ut.helpSection,children:[h.jsx("div",{className:ut.sectionHeader,children:h.jsx(kn,{level:3,className:ut.sectionTitle,children:"Guidelines"})}),h.jsxs("div",{className:ut.sectionContent,children:["To make the process smoother, please follow the guidelines below:",h.jsxs("ul",{className:ut.guidelinesList,children:[h.jsx("li",{children:"Avoid uploading images that are not crisis maps/crisis drone images."}),h.jsx("li",{children:"Confirm the image details prior to modifying the description."}),h.jsx("li",{children:"Before the modification, please read the description generated and provide a rating via the rating sliders."}),h.jsx("li",{children:'Click the "Submit" button to save the description.'})]})]}),h.jsx("div",{className:ut.buttonContainer,children:h.jsx(Be,{name:"see-examples",variant:"secondary",onClick:o,children:"See examples →"})})]}),h.jsxs("div",{className:ut.helpSection,children:[h.jsx("div",{className:ut.sectionHeader,children:h.jsx(kn,{level:3,className:ut.sectionTitle,children:"VLMs"})}),h.jsx("div",{className:ut.sectionContent,children:"PromptAid Vision uses a variety of Visual Language Models (VLMs). A random VLM is selected for each upload. Therefore feel free to delete and reupload. You can view performance details here:"}),h.jsx("div",{className:ut.buttonContainer,children:h.jsx(Be,{name:"view-vlm-details",variant:"secondary",onClick:s,children:"View VLM details →"})})]}),h.jsxs("div",{className:ut.helpSection,children:[h.jsx("div",{className:ut.sectionHeader,children:h.jsx(kn,{level:3,className:ut.sectionTitle,children:"Dataset"})}),h.jsx("div",{className:ut.sectionContent,children:"All users are able to export the dataset. You could apply filters when exporting, and it have the option to organize based on model fine-tuning formats."}),h.jsx("div",{className:ut.buttonContainer,children:h.jsx(Be,{name:"export-dataset",variant:"secondary",onClick:()=>{n(!1),e("/explore"),setTimeout(()=>{const u=document.querySelector('[name="export-dataset"]');u&&u.click()},100)},children:"Export dataset →"})})]}),h.jsxs("div",{className:ut.helpSection,children:[h.jsx("div",{className:ut.sectionHeader,children:h.jsx(kn,{level:3,className:ut.sectionTitle,children:"Contact us"})}),h.jsx("div",{className:ut.sectionContent,children:"Need help or have questions about PromptAid Vision? Our team is here to support you."}),h.jsx("div",{className:ut.buttonContainer,children:h.jsx(Be,{name:"contact-support",variant:"secondary",disabled:!0,children:"Get in touch →"})})]})]})})})}const AP="_demoContainer_19wfc_1",$P="_section_19wfc_13",FP="_pageTitle_19wfc_33",zP="_description_19wfc_43",BP="_sectionHeader_19wfc_57",UP="_sectionTitle_19wfc_65",HP="_sectionDescription_19wfc_75",VP="_switchGrid_19wfc_87",qP="_switchItem_19wfc_99",WP="_switchLabel_19wfc_119",GP="_switchWrapper_19wfc_133",ZP="_stateDisplay_19wfc_147",QP="_nativeCheckboxLabel_19wfc_165",KP="_nativeCheckbox_19wfc_165",YP="_buttonToggle_19wfc_197",XP="_buttonToggleOff_19wfc_219",JP="_buttonToggleOn_19wfc_231",eL="_buttonToggleText_19wfc_253",he={demoContainer:AP,section:$P,pageTitle:FP,description:zP,sectionHeader:BP,sectionTitle:UP,sectionDescription:HP,switchGrid:VP,switchItem:qP,switchLabel:WP,switchWrapper:GP,stateDisplay:ZP,nativeCheckboxLabel:QP,nativeCheckbox:KP,buttonToggle:YP,buttonToggleOff:XP,buttonToggleOn:JP,buttonToggleText:eL};function tL(){const[e,n]=v.useState("off"),[i,o]=v.useState("on"),[s,u]=v.useState(!1),[d,f]=v.useState(!0),[g,y]=v.useState(!1),[x,b]=v.useState(!0),[m,w]=v.useState(!1),[N,S]=v.useState(!0),[_,T]=v.useState(!1),[M,$]=v.useState(!1);return h.jsx(Iu,{className:"py-10",children:h.jsx("div",{className:he.demoContainer,children:h.jsxs("div",{className:"space-y-12",children:[h.jsxs("div",{className:he.section,children:[h.jsx(kn,{level:2,className:he.pageTitle,children:"Switch Components Demo"}),h.jsx("p",{className:he.description,children:"This page showcases all available switch/toggle implementations. Each switch is clearly labeled so you can easily identify and compare different UI patterns."})]}),h.jsxs("div",{className:he.section,children:[h.jsxs("div",{className:he.sectionHeader,children:[h.jsx(kn,{level:3,className:he.sectionTitle,children:"1. SegmentInput Switches (IFRC UI)"}),h.jsx("p",{className:he.sectionDescription,children:"Using SegmentInput component for binary on/off choices"})]}),h.jsxs("div",{className:he.switchGrid,children:[h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Switch 1: SegmentInput (Off by default)"}),h.jsx(on,{withInternalPadding:!0,className:he.switchWrapper,children:h.jsx(su,{name:"switch-1",value:e,onChange:F=>{(F==="on"||F==="off")&&n(F)},options:[{key:"off",label:"Off"},{key:"on",label:"On"}],keySelector:F=>F.key,labelSelector:F=>F.label})}),h.jsxs("div",{className:he.stateDisplay,children:["State: ",h.jsx("strong",{children:e})]})]}),h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Switch 2: SegmentInput (On by default)"}),h.jsx(on,{withInternalPadding:!0,className:he.switchWrapper,children:h.jsx(su,{name:"switch-2",value:i,onChange:F=>{(F==="on"||F==="off")&&o(F)},options:[{key:"off",label:"Off"},{key:"on",label:"On"}],keySelector:F=>F.key,labelSelector:F=>F.label})}),h.jsxs("div",{className:he.stateDisplay,children:["State: ",h.jsx("strong",{children:i})]})]})]})]}),h.jsxs("div",{className:he.section,children:[h.jsxs("div",{className:he.sectionHeader,children:[h.jsx(kn,{level:3,className:he.sectionTitle,children:"2. IFRC Checkbox Switches"}),h.jsx("p",{className:he.sectionDescription,children:"Using Checkbox component from @ifrc-go/ui for on/off toggles"})]}),h.jsxs("div",{className:he.switchGrid,children:[h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Switch 3: IFRC Checkbox (Off by default)"}),h.jsx(wd,{name:"switch-3",value:s,onChange:u,label:"Enable feature"}),h.jsxs("div",{className:he.stateDisplay,children:["State: ",h.jsx("strong",{children:s?"On":"Off"})]})]}),h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Switch 4: IFRC Checkbox (On by default)"}),h.jsx(wd,{name:"switch-4",value:d,onChange:f,label:"Auto-save enabled"}),h.jsxs("div",{className:he.stateDisplay,children:["State: ",h.jsx("strong",{children:d?"On":"Off"})]})]})]})]}),h.jsxs("div",{className:he.section,children:[h.jsxs("div",{className:he.sectionHeader,children:[h.jsx(kn,{level:3,className:he.sectionTitle,children:"3. Native HTML Checkbox Switches"}),h.jsx("p",{className:he.sectionDescription,children:'Using native HTML input[type="checkbox"] elements (as used in AdminPage)'})]}),h.jsxs("div",{className:he.switchGrid,children:[h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Switch 5: Native Checkbox (Off by default)"}),h.jsxs("label",{className:he.nativeCheckboxLabel,children:[h.jsx("input",{type:"checkbox",checked:g,onChange:F=>y(F.target.checked),className:he.nativeCheckbox}),h.jsx("span",{children:"Available for use"})]}),h.jsxs("div",{className:he.stateDisplay,children:["State: ",h.jsx("strong",{children:g?"On":"Off"})]})]}),h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Switch 6: Native Checkbox (On by default)"}),h.jsxs("label",{className:he.nativeCheckboxLabel,children:[h.jsx("input",{type:"checkbox",checked:x,onChange:F=>b(F.target.checked),className:he.nativeCheckbox}),h.jsx("span",{children:"RTK Fix Available"})]}),h.jsxs("div",{className:he.stateDisplay,children:["State: ",h.jsx("strong",{children:x?"On":"Off"})]})]})]})]}),h.jsxs("div",{className:he.section,children:[h.jsxs("div",{className:he.sectionHeader,children:[h.jsx(kn,{level:3,className:he.sectionTitle,children:"4. Custom CSS Toggle Switches"}),h.jsx("p",{className:he.sectionDescription,children:"Custom-built toggle switch component with smooth animations"})]}),h.jsxs("div",{className:he.switchGrid,children:[h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Switch 7: Custom Toggle (Off by default)"}),h.jsx(ls,{name:"switch-7",checked:m,onChange:w,label:"Enable notifications"}),h.jsxs("div",{className:he.stateDisplay,children:["State: ",h.jsx("strong",{children:m?"On":"Off"})]})]}),h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Switch 8: Custom Toggle (On by default)"}),h.jsx(ls,{name:"switch-8",checked:N,onChange:S,label:"Dark mode"}),h.jsxs("div",{className:he.stateDisplay,children:["State: ",h.jsx("strong",{children:N?"On":"Off"})]})]}),h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Switch 9: Custom Toggle (No label, Off by default)"}),h.jsx(ls,{name:"switch-9",checked:_,onChange:T}),h.jsxs("div",{className:he.stateDisplay,children:["State: ",h.jsx("strong",{children:_?"On":"Off"})]})]})]})]}),h.jsxs("div",{className:he.section,children:[h.jsxs("div",{className:he.sectionHeader,children:[h.jsx(kn,{level:3,className:he.sectionTitle,children:"5. Button-based Toggle Switch"}),h.jsx("p",{className:he.sectionDescription,children:"Using a button element styled as a toggle switch"})]}),h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Switch 10: Button Toggle (Off by default)"}),h.jsx("button",{type:"button",className:`${he.buttonToggle} ${M?he.buttonToggleOn:he.buttonToggleOff}`,onClick:()=>$(!M),children:h.jsx("span",{className:he.buttonToggleText,children:M?"On":"Off"})}),h.jsxs("div",{className:he.stateDisplay,children:["State: ",h.jsx("strong",{children:M?"On":"Off"})]})]})]}),h.jsxs("div",{className:he.section,children:[h.jsxs("div",{className:he.sectionHeader,children:[h.jsx(kn,{level:3,className:he.sectionTitle,children:"6. Disabled Switch States"}),h.jsx("p",{className:he.sectionDescription,children:"Examples of switches in disabled state"})]}),h.jsxs("div",{className:he.switchGrid,children:[h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Disabled SegmentInput"}),h.jsx(on,{withInternalPadding:!0,className:he.switchWrapper,children:h.jsx(su,{name:"disabled-segment",value:"on",onChange:()=>{},options:[{key:"off",label:"Off"},{key:"on",label:"On"}],keySelector:F=>F.key,labelSelector:F=>F.label,disabled:!0})})]}),h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Disabled IFRC Checkbox"}),h.jsx(wd,{name:"disabled-checkbox",value:!0,onChange:()=>{},label:"Disabled option",disabled:!0})]}),h.jsxs("div",{className:he.switchItem,children:[h.jsx("div",{className:he.switchLabel,children:"Disabled Custom Toggle"}),h.jsx(ls,{name:"disabled-custom",checked:!0,onChange:()=>{},label:"Disabled toggle",disabled:!0})]})]})]})]})})})}const nL=v.createContext(void 0),rL=({children:e})=>{const[n,i]=v.useState(!1),[o,s]=v.useState(!0),u=async()=>{const y=localStorage.getItem("adminToken");if(!y){i(!1),s(!1);return}try{(await fetch("/api/admin/verify",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y}`}})).ok?i(!0):(localStorage.removeItem("adminToken"),i(!1))}catch(x){console.error("Error verifying admin token:",x),localStorage.removeItem("adminToken"),i(!1)}finally{s(!1)}},d=async y=>{try{const x=await fetch("/api/admin/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:y})});if(x.ok){const b=await x.json();return localStorage.setItem("adminToken",b.access_token),i(!0),!0}else return!1}catch(x){return console.error("Login error:",x),!1}},f=()=>{localStorage.removeItem("adminToken"),i(!1)};v.useEffect(()=>{u()},[]);const g={isAuthenticated:n,isLoading:o,login:d,logout:f,verifyToken:u};return h.jsx(nL.Provider,{value:g,children:e})},iL=v.lazy(()=>Kn(()=>import("./index-C5czLj7d.js"),__vite__mapDeps([0,1]))),oL=v.lazy(()=>Kn(()=>import("./index-DRlHhE1W.js"),__vite__mapDeps([2,3,4,5,6]))),aL=v.lazy(()=>Kn(()=>import("./AdminPage-BZgg3d6P.js"),__vite__mapDeps([7,3,8]))),sL=v.lazy(()=>Kn(()=>import("./index-uy9sc-W4.js"),__vite__mapDeps([9,3,4,5,10])));class lL extends v.Component{constructor(n){super(n),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(n,i){console.error("Error caught by boundary:",n,i)}render(){return this.state.hasError?h.jsxs("div",{style:{padding:"20px",textAlign:"center"},children:[h.jsx("h2",{children:"Something went wrong"}),h.jsx("p",{children:"Please refresh the page to try again."}),h.jsx("button",{onClick:()=>window.location.reload(),children:"Refresh Page"})]}):this.props.children}}const Pi=e=>{const n=e();return n.catch(()=>{}),n},uL=()=>{"requestIdleCallback"in window?requestIdleCallback(()=>{Pi(()=>Kn(()=>import("./index-C5czLj7d.js"),__vite__mapDeps([0,1]))),Pi(()=>Kn(()=>import("./index-DRlHhE1W.js"),__vite__mapDeps([2,3,4,5,6]))),Pi(()=>Kn(()=>import("./AdminPage-BZgg3d6P.js"),__vite__mapDeps([7,3,8]))),Pi(()=>Kn(()=>import("./index-uy9sc-W4.js"),__vite__mapDeps([9,3,4,5,10])))}):setTimeout(()=>{Pi(()=>Kn(()=>import("./index-C5czLj7d.js"),__vite__mapDeps([0,1]))),Pi(()=>Kn(()=>import("./index-DRlHhE1W.js"),__vite__mapDeps([2,3,4,5,6]))),Pi(()=>Kn(()=>import("./AdminPage-BZgg3d6P.js"),__vite__mapDeps([7,3,8]))),Pi(()=>Kn(()=>import("./index-uy9sc-W4.js"),__vite__mapDeps([9,3,4,5,10])))},1e3)};function cL(){const e=v.useMemo(()=>Ex([{element:h.jsx(ZT,{}),children:[{path:"/",element:h.jsx(Xg,{})},{path:"/upload",element:h.jsx(Xg,{})},{path:"/analytics",element:h.jsx(v.Suspense,{fallback:h.jsx("div",{children:"Loading Analytics..."}),children:h.jsx(iL,{})})},{path:"/explore",element:h.jsx(v.Suspense,{fallback:h.jsx("div",{children:"Loading Explore..."}),children:h.jsx(oL,{})})},{path:"/help",element:h.jsx(RP,{})},{path:"/demo",element:h.jsx(tL,{})},{path:"/admin",element:h.jsx(v.Suspense,{fallback:h.jsx("div",{children:"Loading Admin..."}),children:h.jsx(aL,{})})},{path:"/map/:mapId",element:h.jsx(v.Suspense,{fallback:h.jsx("div",{children:"Loading Map Details..."}),children:h.jsx(sL,{})})}]}],{basename:"/"}),[]),[n,i]=v.useState([]);v.useEffect(()=>{uL()},[]);const o=v.useCallback(g=>{i(y=>Qx([...y,g],x=>x.name)??y)},[i]),s=v.useCallback(g=>{i(y=>{const x=y.findIndex(m=>m.name===g);if(x===-1)return y;const b=[...y];return b.splice(x,1),b})},[i]),u=v.useCallback((g,y)=>{i(x=>{const b=x.findIndex(w=>w.name===g);if(b===-1)return x;const m=[...x];return m[b]={...m[b],...y},m})},[i]),d=v.useMemo(()=>({alerts:n,addAlert:o,removeAlert:s,updateAlert:u}),[n,o,s,u]),f=v.useMemo(()=>({languageNamespaceStatus:{},setLanguageNamespaceStatus:()=>{},currentLanguage:"en",setCurrentLanguage:()=>{},strings:{},setStrings:()=>{},registerNamespace:()=>{}}),[]);return h.jsx(lL,{children:h.jsx(Wx.Provider,{value:d,children:h.jsx(y0.Provider,{value:f,children:h.jsx(rL,{children:h.jsx(uP,{children:h.jsx(Ox,{router:e})})})})})})}function dL(){return h.jsx(cL,{})}console.log("React version at runtime:",v.version,"createContext exists?",!!v.createContext);X1.createRoot(document.getElementById("root")).render(h.jsx(v.StrictMode,{children:h.jsx(dL,{})}));export{Mb as A,ua as B,pL as C,cP as D,vL as E,_f as F,Kn as G,kn as H,q as I,io as J,hL as K,su as L,xP as M,Iu as N,kt as O,qg as P,wL as Q,E0 as R,wd as S,nL as T,yL as U,fL as V,e0 as W,Xo as _,Fe as a,Dt as b,CL as c,SL as d,mL as e,Pb as f,S0 as g,bL as h,xL as i,h as j,gr as k,Jx as l,eN as m,Be as n,Le as o,nb as p,cs as q,v as r,_0 as s,y0 as t,Bx as u,Ab as v,$b as w,ks as x,gL as y,on as z}; diff --git a/py_backend/static/assets/index-tBgmM5yL.js b/py_backend/static/assets/index-DRlHhE1W.js similarity index 98% rename from py_backend/static/assets/index-tBgmM5yL.js rename to py_backend/static/assets/index-DRlHhE1W.js index f9eec23c..30973f43 100644 --- a/py_backend/static/assets/index-tBgmM5yL.js +++ b/py_backend/static/assets/index-DRlHhE1W.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jszip.min-XJUuvkAi.js","assets/index-Dym8TuvV.js","assets/index-BYJiCH1e.css"])))=>i.map(i=>d[i]); -import{j as t,z as b,n as w,v as Oe,w as Me,x as Le,B as Re,r as c,D as Je,N as ze,_ as fe,L as We,F as Ue,G as Ae}from"./index-Dym8TuvV.js";import{u as Be}from"./useAdmin-DnFl9FMw.js";import{F as He,E as Ve}from"./ExportModal-Bq4gp-iF.js";const Ge="_paginatorContainer_1l5ti_1",Ze="_paginationControls_1l5ti_19",he={paginatorContainer:Ge,paginationControls:Ze};function qe({currentPage:N,totalPages:f,onPageChange:$,className:H=""}){if(f<=1)return null;const h=(()=>{const y=[];if(f<=5)for(let x=1;x<=f;x++)y.push(x);else{let x=Math.max(1,N-2);const S=Math.min(f,x+5-1);S===f&&(x=Math.max(1,S-5+1));for(let T=x;T<=S;T++)y.push(T)}return y})();return t.jsx("div",{className:`${he.paginatorContainer} ${H}`,children:t.jsxs("div",{className:he.paginationControls,children:[t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsxs(w,{name:"prev-page",variant:"tertiary",size:1,onClick:()=>$(Math.max(1,N-1)),disabled:N===1,title:"Previous page",children:[t.jsx(Oe,{className:"w-4 h-4"}),t.jsx("span",{className:"hidden sm:inline",children:"Previous"})]})}),t.jsxs("div",{className:"flex items-center gap-1",children:[h[0]>1&&t.jsxs(t.Fragment,{children:[t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsx(w,{name:"page-1",variant:"tertiary",size:1,onClick:()=>$(1),children:"1"})}),h[0]>2&&t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsx("span",{className:"px-2 text-gray-500",children:"..."})})]}),h.map(y=>t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsx(w,{name:`page-${y}`,variant:N===y?"primary":"tertiary",size:1,onClick:()=>$(y),children:y})},y)),h[h.length-1]$(f),children:f})})]})]}),t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsxs(w,{name:"next-page",variant:"tertiary",size:1,onClick:()=>$(Math.min(f,N+1)),disabled:N===f,title:"Next page",children:[t.jsx("span",{className:"hidden sm:inline",children:"Next"}),t.jsx(Me,{className:"w-4 h-4"})]})})]})})}const Ke="_tabSelector_o9y1f_1",Qe="_metadataTags_o9y1f_8",Xe="_metadataTag_o9y1f_8",Ye="_metadataTagSource_o9y1f_32",et="_metadataTagType_o9y1f_43",tt="_mapItem_o9y1f_54",at="_mapItemImage_o9y1f_72",st="_mapItemContent_o9y1f_92",it="_mapItemTitle_o9y1f_97",nt="_mapItemMetadata_o9y1f_105",lt="_fullSizeModalOverlay_o9y1f_134",rt="_fullSizeModalContent_o9y1f_148",ot="_ratingWarningContent_o9y1f_159",ct="_ratingWarningTitle_o9y1f_165",dt="_ratingWarningText_o9y1f_172",mt="_ratingWarningButtons_o9y1f_179",p={tabSelector:Ke,metadataTags:Qe,metadataTag:Xe,metadataTagSource:Ye,metadataTagType:et,mapItem:tt,mapItemImage:at,mapItemContent:st,mapItemTitle:it,mapItemMetadata:nt,fullSizeModalOverlay:lt,fullSizeModalContent:rt,ratingWarningContent:ot,ratingWarningTitle:ct,ratingWarningText:dt,ratingWarningButtons:mt};function ft(){const N=Le(),f=Re(),{isAuthenticated:$}=Be(),[H,ne]=c.useState("explore"),[h,y]=c.useState([]),{search:F,srcFilter:x,catFilter:S,regionFilter:T,countryFilter:L,imageTypeFilter:R,uploadTypeFilter:J,generatedMethodFilter:I,showReferenceExamples:E,setShowReferenceExamples:xe}=Je(),[K,_e]=c.useState([]),[Q,ye]=c.useState([]),[le,je]=c.useState([]),[Ne,ve]=c.useState([]),[re,be]=c.useState([]),[we,oe]=c.useState(!0),[z,ce]=c.useState(!0),[Se,X]=c.useState(!1),[Te,Y]=c.useState(!1),[Ie,ee]=c.useState(!1),[te,ae]=c.useState(null),[Ee,V]=c.useState(!1),[G,de]=c.useState(""),[se,me]=c.useState(!1),[W,ge]=c.useState(1),[C]=c.useState(10),[Z,pe]=c.useState(0),[Ce,ue]=c.useState(0),$e=[{key:"explore",label:"List"},{key:"mapDetails",label:"Carousel"}],U=c.useCallback(()=>{ce(!0),ae(null);const e=100,s=1,l=new URLSearchParams({page:s.toString(),limit:e.toString(),include_count:"true"});F&&l.append("search",F),x&&l.append("source",x),S&&l.append("event_type",S),T&&l.append("region",T),L&&l.append("country",L),R&&l.append("image_type",R),J&&l.append("upload_type",J),E&&l.append("starred_only","true"),fetch(`/api/images/grouped?${l.toString()}`).then(o=>{if(!o.ok)throw new Error(`Failed to fetch images: ${o.status} ${o.statusText}`);return o.json()}).then(o=>{console.log("ExplorePage: Fetched captions:",{data:o,fetchPage:s,fetchLimit:e,currentPage:W,itemsPerPage:C,generatedMethodFilter:I});let m=[],_=0;if(o.items&&typeof o.total_count=="number")m=o.items,_=m.length;else if(Array.isArray(o))m=o,_=o.length;else throw new Error("Unexpected response format");if(console.log("ExplorePage: After parsing response:",{itemsCount:m.length,totalCount:_,generatedMethodFilter:I,backendTotalCount:o.items?o.total_count:"N/A"}),I){const P=m.length;m=m.filter(q=>I==="manual"?q.model==="manual":I==="generated"?q.model!=="manual":!0),_=m.length,console.log("ExplorePage: After client-side filtering:",{beforeFilterCount:P,afterFilterCount:m.length})}const A=(W-1)*C,B=A+C;m=m.slice(A,B),console.log("ExplorePage: After client-side pagination:",{startIndex:A,endIndex:B,finalItemsCount:m.length,currentPage:W,itemsPerPage:C,totalCount:_,totalPages:Math.ceil(_/C)}),y(m),pe(_),ue(Math.ceil(_/C)),ae(null)}).catch(o=>{console.error("ExplorePage: Error fetching captions:",o),ae(o instanceof Error?o.message:"Failed to load images. Please try again later."),y([]),pe(0),ue(0)}).finally(()=>{ce(!1)})},[W,F,x,S,T,L,R,J,I,E,C]);c.useEffect(()=>{U()},[U]),c.useEffect(()=>{ge(1)},[F,x,S,T,L,R,J,I,E]),c.useEffect(()=>{const e=()=>{document.hidden||U()};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[U]),c.useEffect(()=>{new URLSearchParams(f.search).get("export")==="true"&&(X(!0),N("/explore",{replace:!0}))},[f.search,N,F,x,S,T,L,R,I,E]),c.useEffect(()=>{oe(!0),Promise.all([fetch("/api/sources").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}),fetch("/api/types").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}),fetch("/api/regions").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}),fetch("/api/countries").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}),fetch("/api/image-types").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()})]).then(([e,s,l,o,m])=>{_e(e),ye(s),je(l),ve(o),be(m)}).catch(()=>{}).finally(()=>{oe(!1)})},[]);const k=h,Fe=async(e,s="fine-tuning")=>{if(e.length===0){alert("No images to export");return}Y(!0),ee(!1);try{const l=(await Ae(async()=>{const{default:i}=await import("./jszip.min-XJUuvkAi.js").then(D=>D.j);return{default:i}},__vite__mapDeps([0,1,2]))).default,o=new l,m=e.filter(i=>i.image_type==="crisis_map"),_=e.filter(i=>i.image_type==="drone_image");if(m.length>0){const i=o.folder("crisis_maps_dataset"),D=i?.folder("images");if(D){let O=1;for(const a of m)try{const v=a.image_count&&a.image_count>1?a.all_image_ids||[a.image_id]:[a.image_id],ie=v.map(async(n,j)=>{try{const r=await fetch(`/api/images/${n}/file`);if(!r.ok)throw new Error(`Failed to fetch image ${n}`);const d=await r.blob(),g=a.file_key.split(".").pop()||"jpg",u=`${String(O).padStart(4,"0")}_${String(j+1).padStart(2,"0")}.${g}`;return D.file(u,d),{success:!0,fileName:u,imageId:n}}catch(r){return console.error(`Failed to process image ${n}:`,r),{success:!1,fileName:"",imageId:n}}}),M=(await Promise.all(ie)).filter(n=>n.success);if(M.length>0){if(s==="fine-tuning"){const n=M.map(d=>`images/${d.fileName}`),j=Math.random(),r={image:n.length===1?n[0]:n,caption:a.edited||a.generated||"",metadata:{image_id:v,title:a.title,source:a.source,event_type:a.event_type,image_type:a.image_type,countries:a.countries,starred:a.starred,image_count:a.image_count||1}};if(!i)continue;if(j<.8){const d=i.file("train.jsonl");if(d){const g=await d.async("string").then(u=>JSON.parse(u||"[]")).catch(()=>[]);g.push(r),i.file("train.jsonl",JSON.stringify(g,null,2))}else i.file("train.jsonl",JSON.stringify([r],null,2))}else if(j<.9){const d=i.file("test.jsonl");if(d){const g=await d.async("string").then(u=>JSON.parse(u||"[]")).catch(()=>[]);g.push(r),i.file("test.jsonl",JSON.stringify(g,null,2))}else i.file("test.jsonl",JSON.stringify([r],null,2))}else{const d=i.file("val.jsonl");if(d){const g=await d.async("string").then(u=>JSON.parse(u||"[]")).catch(()=>[]);g.push(r),i.file("val.jsonl",JSON.stringify(g,null,2))}else i.file("val.jsonl",JSON.stringify([r],null,2))}}else{const n=M.map(r=>`images/${r.fileName}`),j={image:n.length===1?n[0]:n,caption:a.edited||a.generated||"",metadata:{image_id:v,title:a.title,source:a.source,event_type:a.event_type,image_type:a.image_type,countries:a.countries,starred:a.starred,image_count:a.image_count||1}};i&&i.file(`${String(O).padStart(4,"0")}.json`,JSON.stringify(j,null,2))}O++}}catch(v){console.error(`Failed to process caption ${a.image_id}:`,v)}}}if(_.length>0){const i=o.folder("drone_images_dataset"),D=i?.folder("images");if(D){let O=1;for(const a of _)try{const v=a.image_count&&a.image_count>1?a.all_image_ids||[a.image_id]:[a.image_id],ie=v.map(async(n,j)=>{try{const r=await fetch(`/api/images/${n}/file`);if(!r.ok)throw new Error(`Failed to fetch image ${n}`);const d=await r.blob(),g=a.file_key.split(".").pop()||"jpg",u=`${String(O).padStart(4,"0")}_${String(j+1).padStart(2,"0")}.${g}`;return D.file(u,d),{success:!0,fileName:u,imageId:n}}catch(r){return console.error(`Failed to process image ${n}:`,r),{success:!1,fileName:"",imageId:n}}}),M=(await Promise.all(ie)).filter(n=>n.success);if(M.length>0){if(s==="fine-tuning"){const n=M.map(d=>`images/${d.fileName}`),j=Math.random(),r={image:n.length===1?n[0]:n,caption:a.edited||a.generated||"",metadata:{image_id:v,title:a.title,source:a.source,event_type:a.event_type,image_type:a.image_type,countries:a.countries,starred:a.starred,image_count:a.image_count||1}};if(!i)continue;if(j<.8){const d=i.file("train.jsonl");if(d){const g=await d.async("string").then(u=>JSON.parse(u||"[]")).catch(()=>[]);g.push(r),i.file("train.jsonl",JSON.stringify(g,null,2))}else i.file("train.jsonl",JSON.stringify([r],null,2))}else if(j<.9){const d=i.file("test.jsonl");if(d){const g=await d.async("string").then(u=>JSON.parse(u||"[]")).catch(()=>[]);g.push(r),i.file("test.jsonl",JSON.stringify(g,null,2))}else i.file("test.jsonl",JSON.stringify([r],null,2))}else{const d=i.file("val.jsonl");if(d){const g=await d.async("string").then(u=>JSON.parse(u||"[]")).catch(()=>[]);g.push(r),i.file("val.jsonl",JSON.stringify(g,null,2))}else i.file("val.jsonl",JSON.stringify([r],null,2))}}else{const n=M.map(r=>`images/${r.fileName}`),j={image:n.length===1?n[0]:n,caption:a.edited||a.generated||"",metadata:{image_id:v,title:a.title,source:a.source,event_type:a.event_type,image_type:a.image_type,countries:a.countries,starred:a.starred,image_count:a.image_count||1}};i&&i.file(`${String(O).padStart(4,"0")}.json`,JSON.stringify(j,null,2))}O++}}catch(v){console.error(`Failed to process caption ${a.image_id}:`,v)}}}const A=await o.generateAsync({type:"blob"}),B=URL.createObjectURL(A),P=document.createElement("a");P.href=B,P.download=`datasets_${s}_${new Date().toISOString().split("T")[0]}.zip`,document.body.appendChild(P),P.click(),document.body.removeChild(P),URL.revokeObjectURL(B);const q=(m.length||0)+(_.length||0);console.log(`Exported ${s} datasets with ${q} total images:`),m.length>0&&console.log(`- Crisis maps: ${m.length} images`),_.length>0&&console.log(`- Drone images: ${_.length} images`),ee(!0)}catch(l){console.error("Export failed:",l),alert("Failed to export dataset. Please try again.")}finally{Y(!1)}},ke=e=>{de(e),V(!0)},Pe=async()=>{if(G){me(!0);try{console.log("Deleting image with ID:",G),(await fetch(`/api/images/${G}`,{method:"DELETE"})).ok?(y(s=>s.filter(l=>l.image_id!==G)),V(!1),de("")):(console.error("Delete failed"),alert("Failed to delete image. Please try again."))}catch(e){console.error("Delete failed:",e),alert("Failed to delete image. Please try again.")}finally{me(!1)}}};return t.jsxs(ze,{children:[z?t.jsx("div",{className:"flex flex-col items-center justify-center min-h-[60vh]",children:t.jsxs("div",{className:"flex flex-col items-center gap-4",children:[t.jsx(fe,{className:"text-ifrcRed"}),t.jsx("div",{children:"Loading examples..."})]})}):t.jsxs("div",{className:"max-w-7xl mx-auto",children:[t.jsxs("div",{className:p.tabSelector,children:[t.jsx(We,{name:"explore-view",value:H,onChange:e=>{(e==="explore"||e==="mapDetails")&&(ne(e),e==="mapDetails"&&h.length>0&&(h[0]?.image_id&&h[0].image_id!=="undefined"&&h[0].image_id!=="null"?N(`/map/${h[0].image_id}`):console.error("Invalid image_id for navigation:",h[0]?.image_id)))},options:$e,keySelector:e=>e.key,labelSelector:e=>e.label}),t.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsxs(w,{name:"reference-examples",variant:E?"primary":"secondary",onClick:()=>xe(!E),className:"whitespace-nowrap",children:[t.jsx("span",{className:"mr-2",children:E?t.jsx("span",{className:"text-yellow-400",children:"★"}):t.jsx("span",{className:"text-yellow-400",children:"☆"})}),"Reference Examples"]})}),t.jsx(w,{name:"export-dataset",variant:"secondary",onClick:()=>X(!0),children:"Export"})]})]}),H==="explore"?t.jsxs("div",{className:"space-y-6",children:[t.jsx("div",{className:"mb-6 space-y-4",children:t.jsx("div",{className:"flex flex-wrap items-center gap-4",children:t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2 flex-1 min-w-[300px]",children:t.jsx(He,{sources:K,types:Q,regions:le,countries:Ne,imageTypes:re,isLoadingFilters:we})})})}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"flex justify-between items-center",children:t.jsxs("p",{className:"text-sm text-gray-600",children:[k.length," of ",Z," examples"]})}),z&&t.jsx("div",{className:"text-center py-12",children:t.jsxs("div",{className:"flex flex-col items-center gap-4",children:[t.jsx(fe,{className:"text-ifrcRed"}),t.jsx("div",{children:"Loading examples..."})]})}),!z&&te&&t.jsx("div",{className:"text-center py-12",children:t.jsx(b,{withInternalPadding:!0,className:"bg-red-50 border border-red-200 rounded-md max-w-2xl mx-auto",children:t.jsxs("div",{className:"flex flex-col items-center gap-4",children:[t.jsx("div",{className:"text-red-800 font-semibold text-lg",children:"Failed to Load Images"}),t.jsx("div",{className:"text-red-700",children:te}),t.jsx(w,{name:"retry-fetch",variant:"primary",onClick:()=>U(),children:"Retry"})]})})}),!z&&!te&&t.jsxs("div",{className:"space-y-4",children:[k.map(e=>t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("div",{className:`${p.mapItem} flex-1`,onClick:()=>{console.log("ExplorePage: Clicking on image with ID:",e.image_id),console.log("ExplorePage: Image data:",e),e.image_id&&e.image_id!=="undefined"&&e.image_id!=="null"?(console.log("ExplorePage: Navigating to:",`/map/${e.image_id}`),console.log("ExplorePage: Full navigation URL:",`/#/map/${e.image_id}`),N(`/map/${e.image_id}`)):(console.error("Invalid image_id for navigation:",e.image_id),console.error("Full item data:",JSON.stringify(e,null,2)),alert(`Cannot navigate: Invalid image ID (${e.image_id})`))},children:[t.jsx("div",{className:p.mapItemImage,style:{width:"120px",height:"80px"},children:e.thumbnail_url?t.jsxs(t.Fragment,{children:[console.log("ExplorePage: Using thumbnail for fast loading:",e.thumbnail_url),t.jsx("img",{src:e.thumbnail_url,alt:e.file_key,onError:s=>{console.error("ExplorePage: Thumbnail failed to load, falling back to original:",e.thumbnail_url);const l=s.target;e.image_url?l.src=e.image_url:(l.style.display="none",l.parentElement.innerHTML="Img")},onLoad:()=>console.log("ExplorePage: Thumbnail loaded successfully:",e.thumbnail_url)})]}):e.image_url?t.jsxs(t.Fragment,{children:[console.log("ExplorePage: No thumbnail available, using original image:",e.image_url),t.jsx("img",{src:e.image_url,alt:e.file_key,onError:s=>{console.error("ExplorePage: Original image failed to load:",e.image_url);const l=s.target;l.style.display="none",l.parentElement.innerHTML="Img"},onLoad:()=>console.log("ExplorePage: Original image loaded successfully:",e.image_url)})]}):t.jsxs(t.Fragment,{children:[console.log("ExplorePage: No image_url or thumbnail provided for item:",e),"'Img'"]})}),t.jsxs("div",{className:p.mapItemContent,children:[t.jsx("h3",{className:p.mapItemTitle,children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{children:e.title||"Untitled"}),e.starred&&t.jsx("span",{className:"text-red-500 text-lg",title:"Starred image",children:"★"})]})}),t.jsx("div",{className:p.mapItemMetadata,children:t.jsxs("div",{className:p.metadataTags,children:[e.image_type!=="drone_image"&&t.jsx("span",{className:p.metadataTagSource,children:e.source&&e.source.includes(", ")?e.source.split(", ").map(s=>K.find(l=>l.s_code===s.trim())?.label||s.trim()).join(", "):K.find(s=>s.s_code===e.source)?.label||e.source}),t.jsx("span",{className:p.metadataTagType,children:e.event_type&&e.event_type.includes(", ")?e.event_type.split(", ").map(s=>Q.find(l=>l.t_code===s.trim())?.label||s.trim()).join(", "):Q.find(s=>s.t_code===e.event_type)?.label||e.event_type}),t.jsx("span",{className:p.metadataTag,children:re.find(s=>s.image_type===e.image_type)?.label||e.image_type}),t.jsx("span",{className:p.metadataTag,children:e.model==="manual"?"Manual":"Generated"}),e.image_count&&e.image_count>1&&t.jsxs("span",{className:p.metadataTag,title:`Multi-upload with ${e.image_count} images`,children:["📷 ",e.image_count]}),(!e.image_count||e.image_count<=1)&&t.jsx("span",{className:p.metadataTag,title:"Single Upload",children:"Single"}),e.countries&&e.countries.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:p.metadataTag,children:le.find(s=>s.r_code===e.countries[0].r_code)?.label||"Unknown Region"}),t.jsx("span",{className:p.metadataTag,children:e.countries.map(s=>s.label).join(", ")})]})]})})]})]}),$&&t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsx(w,{name:`delete-${e.image_id}`,variant:"tertiary",size:1,className:"bg-red-50 hover:bg-red-100 text-red-700 border border-red-200 hover:border-red-300",onClick:()=>ke(e.image_id),title:"Delete","aria-label":"Delete saved image",children:t.jsx(Ue,{className:"w-4 h-4"})})})]},e.image_id)),!k.length&&t.jsx("div",{className:"text-center py-12",children:t.jsx("p",{className:"text-gray-500",children:"No examples found."})}),!z&&Z>0&&t.jsx(qe,{currentPage:W,totalPages:Ce,totalItems:Z,itemsPerPage:C,onPageChange:ge})]})]})]}):t.jsx("div",{className:"space-y-6",children:t.jsxs("div",{className:"text-center py-12",children:[t.jsx("p",{className:"text-gray-500",children:"Map Details view coming soon..."}),t.jsx("p",{className:"text-sm text-gray-400 mt-2",children:"This will show detailed information about individual maps"})]})})]}),Ee&&t.jsx("div",{className:p.fullSizeModalOverlay,onClick:()=>V(!1),children:t.jsx("div",{className:p.fullSizeModalContent,onClick:e=>e.stopPropagation(),children:t.jsxs("div",{className:p.ratingWarningContent,children:[t.jsx("h3",{className:p.ratingWarningTitle,children:"Delete Image?"}),t.jsx("p",{className:p.ratingWarningText,children:"This action cannot be undone. Are you sure you want to delete this saved image and all related data?"}),t.jsxs("div",{className:p.ratingWarningButtons,children:[t.jsx(w,{name:"confirm-delete",variant:"secondary",onClick:Pe,disabled:se,children:se?"Deleting...":"Delete"}),t.jsx(w,{name:"cancel-delete",variant:"tertiary",onClick:()=>V(!1),disabled:se,children:"Cancel"})]})]})})}),t.jsx(Ve,{isOpen:Se,onClose:()=>{X(!1),ee(!1),Y(!1)},onExport:(e,s)=>{const l=k.filter(o=>s.includes(o.image_type));Fe(l,e)},filteredCount:k.length,totalCount:Z,hasFilters:!!(F||x||S||T||L||R||J||I||E),crisisMapsCount:k.filter(e=>e.image_type==="crisis_map").length,droneImagesCount:k.filter(e=>e.image_type==="drone_image").length,isLoading:Te,exportSuccess:Ie})]})}export{ft as default}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jszip.min-BeHyG4q9.js","assets/index-C5rMGfs8.js","assets/index-BYJiCH1e.css"])))=>i.map(i=>d[i]); +import{j as t,z as b,n as w,v as Oe,w as Me,x as Le,B as Re,r as c,D as Je,N as ze,_ as fe,L as We,F as Ue,G as Ae}from"./index-C5rMGfs8.js";import{u as Be}from"./useAdmin-B8fo0TJy.js";import{F as He,E as Ve}from"./ExportModal-DJxQWbes.js";const Ge="_paginatorContainer_1l5ti_1",Ze="_paginationControls_1l5ti_19",he={paginatorContainer:Ge,paginationControls:Ze};function qe({currentPage:N,totalPages:f,onPageChange:$,className:H=""}){if(f<=1)return null;const h=(()=>{const y=[];if(f<=5)for(let x=1;x<=f;x++)y.push(x);else{let x=Math.max(1,N-2);const S=Math.min(f,x+5-1);S===f&&(x=Math.max(1,S-5+1));for(let T=x;T<=S;T++)y.push(T)}return y})();return t.jsx("div",{className:`${he.paginatorContainer} ${H}`,children:t.jsxs("div",{className:he.paginationControls,children:[t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsxs(w,{name:"prev-page",variant:"tertiary",size:1,onClick:()=>$(Math.max(1,N-1)),disabled:N===1,title:"Previous page",children:[t.jsx(Oe,{className:"w-4 h-4"}),t.jsx("span",{className:"hidden sm:inline",children:"Previous"})]})}),t.jsxs("div",{className:"flex items-center gap-1",children:[h[0]>1&&t.jsxs(t.Fragment,{children:[t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsx(w,{name:"page-1",variant:"tertiary",size:1,onClick:()=>$(1),children:"1"})}),h[0]>2&&t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsx("span",{className:"px-2 text-gray-500",children:"..."})})]}),h.map(y=>t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsx(w,{name:`page-${y}`,variant:N===y?"primary":"tertiary",size:1,onClick:()=>$(y),children:y})},y)),h[h.length-1]$(f),children:f})})]})]}),t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsxs(w,{name:"next-page",variant:"tertiary",size:1,onClick:()=>$(Math.min(f,N+1)),disabled:N===f,title:"Next page",children:[t.jsx("span",{className:"hidden sm:inline",children:"Next"}),t.jsx(Me,{className:"w-4 h-4"})]})})]})})}const Ke="_tabSelector_o9y1f_1",Qe="_metadataTags_o9y1f_8",Xe="_metadataTag_o9y1f_8",Ye="_metadataTagSource_o9y1f_32",et="_metadataTagType_o9y1f_43",tt="_mapItem_o9y1f_54",at="_mapItemImage_o9y1f_72",st="_mapItemContent_o9y1f_92",it="_mapItemTitle_o9y1f_97",nt="_mapItemMetadata_o9y1f_105",lt="_fullSizeModalOverlay_o9y1f_134",rt="_fullSizeModalContent_o9y1f_148",ot="_ratingWarningContent_o9y1f_159",ct="_ratingWarningTitle_o9y1f_165",dt="_ratingWarningText_o9y1f_172",mt="_ratingWarningButtons_o9y1f_179",p={tabSelector:Ke,metadataTags:Qe,metadataTag:Xe,metadataTagSource:Ye,metadataTagType:et,mapItem:tt,mapItemImage:at,mapItemContent:st,mapItemTitle:it,mapItemMetadata:nt,fullSizeModalOverlay:lt,fullSizeModalContent:rt,ratingWarningContent:ot,ratingWarningTitle:ct,ratingWarningText:dt,ratingWarningButtons:mt};function ft(){const N=Le(),f=Re(),{isAuthenticated:$}=Be(),[H,ne]=c.useState("explore"),[h,y]=c.useState([]),{search:F,srcFilter:x,catFilter:S,regionFilter:T,countryFilter:L,imageTypeFilter:R,uploadTypeFilter:J,generatedMethodFilter:I,showReferenceExamples:E,setShowReferenceExamples:xe}=Je(),[K,_e]=c.useState([]),[Q,ye]=c.useState([]),[le,je]=c.useState([]),[Ne,ve]=c.useState([]),[re,be]=c.useState([]),[we,oe]=c.useState(!0),[z,ce]=c.useState(!0),[Se,X]=c.useState(!1),[Te,Y]=c.useState(!1),[Ie,ee]=c.useState(!1),[te,ae]=c.useState(null),[Ee,V]=c.useState(!1),[G,de]=c.useState(""),[se,me]=c.useState(!1),[W,ge]=c.useState(1),[C]=c.useState(10),[Z,pe]=c.useState(0),[Ce,ue]=c.useState(0),$e=[{key:"explore",label:"List"},{key:"mapDetails",label:"Carousel"}],U=c.useCallback(()=>{ce(!0),ae(null);const e=100,s=1,l=new URLSearchParams({page:s.toString(),limit:e.toString(),include_count:"true"});F&&l.append("search",F),x&&l.append("source",x),S&&l.append("event_type",S),T&&l.append("region",T),L&&l.append("country",L),R&&l.append("image_type",R),J&&l.append("upload_type",J),E&&l.append("starred_only","true"),fetch(`/api/images/grouped?${l.toString()}`).then(o=>{if(!o.ok)throw new Error(`Failed to fetch images: ${o.status} ${o.statusText}`);return o.json()}).then(o=>{console.log("ExplorePage: Fetched captions:",{data:o,fetchPage:s,fetchLimit:e,currentPage:W,itemsPerPage:C,generatedMethodFilter:I});let m=[],_=0;if(o.items&&typeof o.total_count=="number")m=o.items,_=m.length;else if(Array.isArray(o))m=o,_=o.length;else throw new Error("Unexpected response format");if(console.log("ExplorePage: After parsing response:",{itemsCount:m.length,totalCount:_,generatedMethodFilter:I,backendTotalCount:o.items?o.total_count:"N/A"}),I){const P=m.length;m=m.filter(q=>I==="manual"?q.model==="manual":I==="generated"?q.model!=="manual":!0),_=m.length,console.log("ExplorePage: After client-side filtering:",{beforeFilterCount:P,afterFilterCount:m.length})}const A=(W-1)*C,B=A+C;m=m.slice(A,B),console.log("ExplorePage: After client-side pagination:",{startIndex:A,endIndex:B,finalItemsCount:m.length,currentPage:W,itemsPerPage:C,totalCount:_,totalPages:Math.ceil(_/C)}),y(m),pe(_),ue(Math.ceil(_/C)),ae(null)}).catch(o=>{console.error("ExplorePage: Error fetching captions:",o),ae(o instanceof Error?o.message:"Failed to load images. Please try again later."),y([]),pe(0),ue(0)}).finally(()=>{ce(!1)})},[W,F,x,S,T,L,R,J,I,E,C]);c.useEffect(()=>{U()},[U]),c.useEffect(()=>{ge(1)},[F,x,S,T,L,R,J,I,E]),c.useEffect(()=>{const e=()=>{document.hidden||U()};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[U]),c.useEffect(()=>{new URLSearchParams(f.search).get("export")==="true"&&(X(!0),N("/explore",{replace:!0}))},[f.search,N,F,x,S,T,L,R,I,E]),c.useEffect(()=>{oe(!0),Promise.all([fetch("/api/sources").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}),fetch("/api/types").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}),fetch("/api/regions").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}),fetch("/api/countries").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}),fetch("/api/image-types").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()})]).then(([e,s,l,o,m])=>{_e(e),ye(s),je(l),ve(o),be(m)}).catch(()=>{}).finally(()=>{oe(!1)})},[]);const k=h,Fe=async(e,s="fine-tuning")=>{if(e.length===0){alert("No images to export");return}Y(!0),ee(!1);try{const l=(await Ae(async()=>{const{default:i}=await import("./jszip.min-BeHyG4q9.js").then(D=>D.j);return{default:i}},__vite__mapDeps([0,1,2]))).default,o=new l,m=e.filter(i=>i.image_type==="crisis_map"),_=e.filter(i=>i.image_type==="drone_image");if(m.length>0){const i=o.folder("crisis_maps_dataset"),D=i?.folder("images");if(D){let O=1;for(const a of m)try{const v=a.image_count&&a.image_count>1?a.all_image_ids||[a.image_id]:[a.image_id],ie=v.map(async(n,j)=>{try{const r=await fetch(`/api/images/${n}/file`);if(!r.ok)throw new Error(`Failed to fetch image ${n}`);const d=await r.blob(),g=a.file_key.split(".").pop()||"jpg",u=`${String(O).padStart(4,"0")}_${String(j+1).padStart(2,"0")}.${g}`;return D.file(u,d),{success:!0,fileName:u,imageId:n}}catch(r){return console.error(`Failed to process image ${n}:`,r),{success:!1,fileName:"",imageId:n}}}),M=(await Promise.all(ie)).filter(n=>n.success);if(M.length>0){if(s==="fine-tuning"){const n=M.map(d=>`images/${d.fileName}`),j=Math.random(),r={image:n.length===1?n[0]:n,caption:a.edited||a.generated||"",metadata:{image_id:v,title:a.title,source:a.source,event_type:a.event_type,image_type:a.image_type,countries:a.countries,starred:a.starred,image_count:a.image_count||1}};if(!i)continue;if(j<.8){const d=i.file("train.jsonl");if(d){const g=await d.async("string").then(u=>JSON.parse(u||"[]")).catch(()=>[]);g.push(r),i.file("train.jsonl",JSON.stringify(g,null,2))}else i.file("train.jsonl",JSON.stringify([r],null,2))}else if(j<.9){const d=i.file("test.jsonl");if(d){const g=await d.async("string").then(u=>JSON.parse(u||"[]")).catch(()=>[]);g.push(r),i.file("test.jsonl",JSON.stringify(g,null,2))}else i.file("test.jsonl",JSON.stringify([r],null,2))}else{const d=i.file("val.jsonl");if(d){const g=await d.async("string").then(u=>JSON.parse(u||"[]")).catch(()=>[]);g.push(r),i.file("val.jsonl",JSON.stringify(g,null,2))}else i.file("val.jsonl",JSON.stringify([r],null,2))}}else{const n=M.map(r=>`images/${r.fileName}`),j={image:n.length===1?n[0]:n,caption:a.edited||a.generated||"",metadata:{image_id:v,title:a.title,source:a.source,event_type:a.event_type,image_type:a.image_type,countries:a.countries,starred:a.starred,image_count:a.image_count||1}};i&&i.file(`${String(O).padStart(4,"0")}.json`,JSON.stringify(j,null,2))}O++}}catch(v){console.error(`Failed to process caption ${a.image_id}:`,v)}}}if(_.length>0){const i=o.folder("drone_images_dataset"),D=i?.folder("images");if(D){let O=1;for(const a of _)try{const v=a.image_count&&a.image_count>1?a.all_image_ids||[a.image_id]:[a.image_id],ie=v.map(async(n,j)=>{try{const r=await fetch(`/api/images/${n}/file`);if(!r.ok)throw new Error(`Failed to fetch image ${n}`);const d=await r.blob(),g=a.file_key.split(".").pop()||"jpg",u=`${String(O).padStart(4,"0")}_${String(j+1).padStart(2,"0")}.${g}`;return D.file(u,d),{success:!0,fileName:u,imageId:n}}catch(r){return console.error(`Failed to process image ${n}:`,r),{success:!1,fileName:"",imageId:n}}}),M=(await Promise.all(ie)).filter(n=>n.success);if(M.length>0){if(s==="fine-tuning"){const n=M.map(d=>`images/${d.fileName}`),j=Math.random(),r={image:n.length===1?n[0]:n,caption:a.edited||a.generated||"",metadata:{image_id:v,title:a.title,source:a.source,event_type:a.event_type,image_type:a.image_type,countries:a.countries,starred:a.starred,image_count:a.image_count||1}};if(!i)continue;if(j<.8){const d=i.file("train.jsonl");if(d){const g=await d.async("string").then(u=>JSON.parse(u||"[]")).catch(()=>[]);g.push(r),i.file("train.jsonl",JSON.stringify(g,null,2))}else i.file("train.jsonl",JSON.stringify([r],null,2))}else if(j<.9){const d=i.file("test.jsonl");if(d){const g=await d.async("string").then(u=>JSON.parse(u||"[]")).catch(()=>[]);g.push(r),i.file("test.jsonl",JSON.stringify(g,null,2))}else i.file("test.jsonl",JSON.stringify([r],null,2))}else{const d=i.file("val.jsonl");if(d){const g=await d.async("string").then(u=>JSON.parse(u||"[]")).catch(()=>[]);g.push(r),i.file("val.jsonl",JSON.stringify(g,null,2))}else i.file("val.jsonl",JSON.stringify([r],null,2))}}else{const n=M.map(r=>`images/${r.fileName}`),j={image:n.length===1?n[0]:n,caption:a.edited||a.generated||"",metadata:{image_id:v,title:a.title,source:a.source,event_type:a.event_type,image_type:a.image_type,countries:a.countries,starred:a.starred,image_count:a.image_count||1}};i&&i.file(`${String(O).padStart(4,"0")}.json`,JSON.stringify(j,null,2))}O++}}catch(v){console.error(`Failed to process caption ${a.image_id}:`,v)}}}const A=await o.generateAsync({type:"blob"}),B=URL.createObjectURL(A),P=document.createElement("a");P.href=B,P.download=`datasets_${s}_${new Date().toISOString().split("T")[0]}.zip`,document.body.appendChild(P),P.click(),document.body.removeChild(P),URL.revokeObjectURL(B);const q=(m.length||0)+(_.length||0);console.log(`Exported ${s} datasets with ${q} total images:`),m.length>0&&console.log(`- Crisis maps: ${m.length} images`),_.length>0&&console.log(`- Drone images: ${_.length} images`),ee(!0)}catch(l){console.error("Export failed:",l),alert("Failed to export dataset. Please try again.")}finally{Y(!1)}},ke=e=>{de(e),V(!0)},Pe=async()=>{if(G){me(!0);try{console.log("Deleting image with ID:",G),(await fetch(`/api/images/${G}`,{method:"DELETE"})).ok?(y(s=>s.filter(l=>l.image_id!==G)),V(!1),de("")):(console.error("Delete failed"),alert("Failed to delete image. Please try again."))}catch(e){console.error("Delete failed:",e),alert("Failed to delete image. Please try again.")}finally{me(!1)}}};return t.jsxs(ze,{children:[z?t.jsx("div",{className:"flex flex-col items-center justify-center min-h-[60vh]",children:t.jsxs("div",{className:"flex flex-col items-center gap-4",children:[t.jsx(fe,{className:"text-ifrcRed"}),t.jsx("div",{children:"Loading examples..."})]})}):t.jsxs("div",{className:"max-w-7xl mx-auto",children:[t.jsxs("div",{className:p.tabSelector,children:[t.jsx(We,{name:"explore-view",value:H,onChange:e=>{(e==="explore"||e==="mapDetails")&&(ne(e),e==="mapDetails"&&h.length>0&&(h[0]?.image_id&&h[0].image_id!=="undefined"&&h[0].image_id!=="null"?N(`/map/${h[0].image_id}`):console.error("Invalid image_id for navigation:",h[0]?.image_id)))},options:$e,keySelector:e=>e.key,labelSelector:e=>e.label}),t.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsxs(w,{name:"reference-examples",variant:E?"primary":"secondary",onClick:()=>xe(!E),className:"whitespace-nowrap",children:[t.jsx("span",{className:"mr-2",children:E?t.jsx("span",{className:"text-yellow-400",children:"★"}):t.jsx("span",{className:"text-yellow-400",children:"☆"})}),"Reference Examples"]})}),t.jsx(w,{name:"export-dataset",variant:"secondary",onClick:()=>X(!0),children:"Export"})]})]}),H==="explore"?t.jsxs("div",{className:"space-y-6",children:[t.jsx("div",{className:"mb-6 space-y-4",children:t.jsx("div",{className:"flex flex-wrap items-center gap-4",children:t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2 flex-1 min-w-[300px]",children:t.jsx(He,{sources:K,types:Q,regions:le,countries:Ne,imageTypes:re,isLoadingFilters:we})})})}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"flex justify-between items-center",children:t.jsxs("p",{className:"text-sm text-gray-600",children:[k.length," of ",Z," examples"]})}),z&&t.jsx("div",{className:"text-center py-12",children:t.jsxs("div",{className:"flex flex-col items-center gap-4",children:[t.jsx(fe,{className:"text-ifrcRed"}),t.jsx("div",{children:"Loading examples..."})]})}),!z&&te&&t.jsx("div",{className:"text-center py-12",children:t.jsx(b,{withInternalPadding:!0,className:"bg-red-50 border border-red-200 rounded-md max-w-2xl mx-auto",children:t.jsxs("div",{className:"flex flex-col items-center gap-4",children:[t.jsx("div",{className:"text-red-800 font-semibold text-lg",children:"Failed to Load Images"}),t.jsx("div",{className:"text-red-700",children:te}),t.jsx(w,{name:"retry-fetch",variant:"primary",onClick:()=>U(),children:"Retry"})]})})}),!z&&!te&&t.jsxs("div",{className:"space-y-4",children:[k.map(e=>t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("div",{className:`${p.mapItem} flex-1`,onClick:()=>{console.log("ExplorePage: Clicking on image with ID:",e.image_id),console.log("ExplorePage: Image data:",e),e.image_id&&e.image_id!=="undefined"&&e.image_id!=="null"?(console.log("ExplorePage: Navigating to:",`/map/${e.image_id}`),console.log("ExplorePage: Full navigation URL:",`/#/map/${e.image_id}`),N(`/map/${e.image_id}`)):(console.error("Invalid image_id for navigation:",e.image_id),console.error("Full item data:",JSON.stringify(e,null,2)),alert(`Cannot navigate: Invalid image ID (${e.image_id})`))},children:[t.jsx("div",{className:p.mapItemImage,style:{width:"120px",height:"80px"},children:e.thumbnail_url?t.jsxs(t.Fragment,{children:[console.log("ExplorePage: Using thumbnail for fast loading:",e.thumbnail_url),t.jsx("img",{src:e.thumbnail_url,alt:e.file_key,onError:s=>{console.error("ExplorePage: Thumbnail failed to load, falling back to original:",e.thumbnail_url);const l=s.target;e.image_url?l.src=e.image_url:(l.style.display="none",l.parentElement.innerHTML="Img")},onLoad:()=>console.log("ExplorePage: Thumbnail loaded successfully:",e.thumbnail_url)})]}):e.image_url?t.jsxs(t.Fragment,{children:[console.log("ExplorePage: No thumbnail available, using original image:",e.image_url),t.jsx("img",{src:e.image_url,alt:e.file_key,onError:s=>{console.error("ExplorePage: Original image failed to load:",e.image_url);const l=s.target;l.style.display="none",l.parentElement.innerHTML="Img"},onLoad:()=>console.log("ExplorePage: Original image loaded successfully:",e.image_url)})]}):t.jsxs(t.Fragment,{children:[console.log("ExplorePage: No image_url or thumbnail provided for item:",e),"'Img'"]})}),t.jsxs("div",{className:p.mapItemContent,children:[t.jsx("h3",{className:p.mapItemTitle,children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{children:e.title||"Untitled"}),e.starred&&t.jsx("span",{className:"text-red-500 text-lg",title:"Starred image",children:"★"})]})}),t.jsx("div",{className:p.mapItemMetadata,children:t.jsxs("div",{className:p.metadataTags,children:[e.image_type!=="drone_image"&&t.jsx("span",{className:p.metadataTagSource,children:e.source&&e.source.includes(", ")?e.source.split(", ").map(s=>K.find(l=>l.s_code===s.trim())?.label||s.trim()).join(", "):K.find(s=>s.s_code===e.source)?.label||e.source}),t.jsx("span",{className:p.metadataTagType,children:e.event_type&&e.event_type.includes(", ")?e.event_type.split(", ").map(s=>Q.find(l=>l.t_code===s.trim())?.label||s.trim()).join(", "):Q.find(s=>s.t_code===e.event_type)?.label||e.event_type}),t.jsx("span",{className:p.metadataTag,children:re.find(s=>s.image_type===e.image_type)?.label||e.image_type}),t.jsx("span",{className:p.metadataTag,children:e.model==="manual"?"Manual":"Generated"}),e.image_count&&e.image_count>1&&t.jsxs("span",{className:p.metadataTag,title:`Multi-upload with ${e.image_count} images`,children:["📷 ",e.image_count]}),(!e.image_count||e.image_count<=1)&&t.jsx("span",{className:p.metadataTag,title:"Single Upload",children:"Single"}),e.countries&&e.countries.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:p.metadataTag,children:le.find(s=>s.r_code===e.countries[0].r_code)?.label||"Unknown Region"}),t.jsx("span",{className:p.metadataTag,children:e.countries.map(s=>s.label).join(", ")})]})]})})]})]}),$&&t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsx(w,{name:`delete-${e.image_id}`,variant:"tertiary",size:1,className:"bg-red-50 hover:bg-red-100 text-red-700 border border-red-200 hover:border-red-300",onClick:()=>ke(e.image_id),title:"Delete","aria-label":"Delete saved image",children:t.jsx(Ue,{className:"w-4 h-4"})})})]},e.image_id)),!k.length&&t.jsx("div",{className:"text-center py-12",children:t.jsx("p",{className:"text-gray-500",children:"No examples found."})}),!z&&Z>0&&t.jsx(qe,{currentPage:W,totalPages:Ce,totalItems:Z,itemsPerPage:C,onPageChange:ge})]})]})]}):t.jsx("div",{className:"space-y-6",children:t.jsxs("div",{className:"text-center py-12",children:[t.jsx("p",{className:"text-gray-500",children:"Map Details view coming soon..."}),t.jsx("p",{className:"text-sm text-gray-400 mt-2",children:"This will show detailed information about individual maps"})]})})]}),Ee&&t.jsx("div",{className:p.fullSizeModalOverlay,onClick:()=>V(!1),children:t.jsx("div",{className:p.fullSizeModalContent,onClick:e=>e.stopPropagation(),children:t.jsxs("div",{className:p.ratingWarningContent,children:[t.jsx("h3",{className:p.ratingWarningTitle,children:"Delete Image?"}),t.jsx("p",{className:p.ratingWarningText,children:"This action cannot be undone. Are you sure you want to delete this saved image and all related data?"}),t.jsxs("div",{className:p.ratingWarningButtons,children:[t.jsx(w,{name:"confirm-delete",variant:"secondary",onClick:Pe,disabled:se,children:se?"Deleting...":"Delete"}),t.jsx(w,{name:"cancel-delete",variant:"tertiary",onClick:()=>V(!1),disabled:se,children:"Cancel"})]})]})})}),t.jsx(Ve,{isOpen:Se,onClose:()=>{X(!1),ee(!1),Y(!1)},onExport:(e,s)=>{const l=k.filter(o=>s.includes(o.image_type));Fe(l,e)},filteredCount:k.length,totalCount:Z,hasFilters:!!(F||x||S||T||L||R||J||I||E),crisisMapsCount:k.filter(e=>e.image_type==="crisis_map").length,droneImagesCount:k.filter(e=>e.image_type==="drone_image").length,isLoading:Te,exportSuccess:Ie})]})}export{ft as default}; diff --git a/py_backend/static/assets/index-HD7t9Ly0.js b/py_backend/static/assets/index-uy9sc-W4.js similarity index 99% rename from py_backend/static/assets/index-HD7t9Ly0.js rename to py_backend/static/assets/index-uy9sc-W4.js index 8133cd68..7bb39124 100644 --- a/py_backend/static/assets/index-HD7t9Ly0.js +++ b/py_backend/static/assets/index-uy9sc-W4.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jszip.min-XJUuvkAi.js","assets/index-Dym8TuvV.js","assets/index-BYJiCH1e.css"])))=>i.map(i=>d[i]); -import{K as aa,x as ta,r as d,D as sa,j as a,N as ae,n as F,_ as Ie,L as ia,z as P,v as oe,w as re,F as na,M as oa,G as ra}from"./index-Dym8TuvV.js";import{u as la}from"./useAdmin-DnFl9FMw.js";import{F as ca,E as da}from"./ExportModal-Bq4gp-iF.js";const ga="_tabSelector_usssr_1",ma="_imageContainer_usssr_12",ua="_imagePlaceholder_usssr_33",pa="_metadataTags_usssr_45",fa="_metadataTag_usssr_45",ha="_captionContainer_usssr_67",_a="_captionText_usssr_74",xa="_gridLayout_usssr_131",ya="_detailsSection_usssr_155",va="_loadingContainer_usssr_161",ja="_errorContainer_usssr_171",wa="_fullSizeModalOverlay_usssr_205",Ia="_fullSizeModalContent_usssr_219",Na="_ratingWarningContent_usssr_230",Ca="_ratingWarningTitle_usssr_236",ba="_ratingWarningText_usssr_243",Sa="_ratingWarningButtons_usssr_250",ka="_carouselContainer_usssr_365",Da="_carouselImageWrapper_usssr_370",Ma="_carouselImage_usssr_370",La="_carouselNavigation_usssr_393",Fa="_carouselButton_usssr_405",Ta="_carouselIndicators_usssr_429",Ea="_carouselIndicator_usssr_429",$a="_carouselIndicatorActive_usssr_458",Pa="_singleImageContainer_usssr_488",Ra="_viewImageButtonContainer_usssr_494",m={tabSelector:ga,imageContainer:ma,imagePlaceholder:ua,metadataTags:pa,metadataTag:fa,captionContainer:ha,captionText:_a,gridLayout:xa,detailsSection:ya,loadingContainer:va,errorContainer:ja,fullSizeModalOverlay:wa,fullSizeModalContent:Ia,ratingWarningContent:Na,ratingWarningTitle:Ca,ratingWarningText:ba,ratingWarningButtons:Sa,carouselContainer:ka,carouselImageWrapper:Da,carouselImage:Ma,carouselNavigation:La,carouselButton:Fa,carouselIndicators:Ta,carouselIndicator:Ea,carouselIndicatorActive:$a,singleImageContainer:Pa,viewImageButtonContainer:Ra};function it(){const{mapId:u}=aa(),y=ta(),{isAuthenticated:le}=la(),[ce,Ne]=d.useState("mapDetails"),[e,te]=d.useState(null),[O,A]=d.useState(!0),[de,U]=d.useState(null),[ge,Ce]=d.useState([]),[me,be]=d.useState([]),[ue,Se]=d.useState([]),[pe,ke]=d.useState([]),[De,Me]=d.useState([]),[Le,Fe]=d.useState(!1),[Te,Ee]=d.useState(!1),[J,K]=d.useState(!1),[$e,Z]=d.useState(!1),[fe,Q]=d.useState(!1),[Pe,se]=d.useState(!1),[Re,ie]=d.useState(!1),[Aa,za]=d.useState("standard"),[R,Oa]=d.useState(80),[G,Ua]=d.useState(10),[Ba,Wa]=d.useState(10),[Ja,Ga]=d.useState(!0),[Va,Ha]=d.useState(!0),[B,X]=d.useState(!1),[Ae,he]=d.useState(!1),[ze,_e]=d.useState(null),[Oe,V]=d.useState(!1),[x,H]=d.useState([]),[L,z]=d.useState(0),[q,xe]=d.useState(!1),{search:p,setSearch:qa,srcFilter:v,setSrcFilter:Ka,catFilter:j,setCatFilter:Za,regionFilter:w,setRegionFilter:Qa,countryFilter:I,setCountryFilter:Xa,imageTypeFilter:N,setImageTypeFilter:Ya,uploadTypeFilter:C,setUploadTypeFilter:et,generatedMethodFilter:f,showReferenceExamples:k,setShowReferenceExamples:Ue,clearAllFilters:Be}=sa(),We=[{key:"explore",label:"List"},{key:"mapDetails",label:"Carousel"}],Y=d.useCallback(async t=>{if(!(!t||t==="undefined"||t==="null"||t.trim()===""))try{const i=new URLSearchParams;p&&i.append("search",p),v&&i.append("source",v),j&&i.append("event_type",j),w&&i.append("region",w),I&&i.append("country",I),N&&i.append("image_type",N),C&&i.append("upload_type",C),k&&i.append("starred_only","true");const l=await fetch(`/api/images/grouped?${i.toString()}`);if(l.ok){let s=await l.json();s.items&&(s=s.items),f&&(s=s.filter(o=>f==="manual"?o.model==="manual":f==="generated"?o.model!=="manual":!0)),console.log("Server response for upload_type=multiple:",{url:`/api/images/grouped?${i.toString()}`,count:s.length,images:s.map(o=>({image_id:o.image_id,image_count:o.image_count,all_image_ids:o.all_image_ids,all_image_ids_length:o.all_image_ids?.length}))});const n=s.findIndex(o=>o.image_id===t);console.log("Navigation availability check (server-side):",{filteredImagesCount:s.length,currentIndex:n,currentId:t,uploadTypeFilter:C,hasPrevious:s.length>1&&n>0,hasNext:s.length>1&&n({image_id:o.image_id,image_count:o.image_count,all_image_ids:o.all_image_ids,image_type:o.image_type}))}),Fe(s.length>1&&n>0),Ee(s.length>1&&n{console.log("fetchAllImages called with imageIds:",t),xe(!0);try{const i=t.map(async s=>{const n=await fetch(`/api/images/${s}`);if(!n.ok)throw new Error(`Failed to fetch image ${s}`);return n.json()}),l=await Promise.all(i);H(l),z(0),console.log("fetchAllImages: Loaded",l.length,"images")}catch(i){console.error("fetchAllImages error:",i),U(i instanceof Error?i.message:"Failed to load all images")}finally{xe(!1)}},[]),ye=d.useCallback(async t=>{if(console.log("fetchMapData called with id:",t),console.log("fetchMapData id type:",typeof t),!t||t==="undefined"||t==="null"||t.trim()===""){console.log("fetchMapData: Invalid ID detected:",t),U("Invalid Map ID"),A(!1);return}if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)){console.log("fetchMapData: Invalid UUID format:",t),U("Invalid Map ID format"),A(!1);return}console.log("fetchMapData: Making API call for id:",t),K(!0),A(!0);try{const l=await fetch(`/api/images/${t}`);if(!l.ok)throw new Error("Map not found");const s=await l.json();if(te(s),s.all_image_ids&&s.all_image_ids.length>1)await ne(s.all_image_ids);else if(s.image_count&&s.image_count>1){console.log("Multi-upload detected but no all_image_ids, trying grouped endpoint");try{const n=await fetch("/api/images/grouped");if(n.ok){const r=(await n.json()).find(g=>g.all_image_ids&&g.all_image_ids.includes(s.image_id));r&&r.all_image_ids?await ne(r.all_image_ids):(H([s]),z(0))}else H([s]),z(0)}catch(n){console.error("Failed to fetch from grouped endpoint:",n),H([s]),z(0)}}else H([s]),z(0);await Y(t)}catch(l){U(l instanceof Error?l.message:"Unknown error occurred")}finally{A(!1),K(!1)}},[Y,ne]),Je=d.useCallback(()=>{x.length>1&&z(t=>t>0?t-1:x.length-1)},[x.length]),Ge=d.useCallback(()=>{x.length>1&&z(t=>t{t>=0&&t{const i=t||(x.length>0?x[L]:e);if(i){V(!0),_e(i),he(!0);try{const l=new Image;l.onload=()=>{V(!1)},l.onerror=()=>{V(!1)},l.src=i.image_url}catch(l){console.error("Error preloading full-size image:",l),V(!1)}}},[x,L,e]),He=d.useCallback(()=>{he(!1),_e(null),V(!1)},[]);d.useEffect(()=>{if(console.log("MapDetailsPage: mapId from useParams:",u),console.log("MapDetailsPage: mapId type:",typeof u),console.log("MapDetailsPage: mapId value:",u),!u||u==="undefined"||u==="null"||u.trim()===""||u===void 0||u===null){console.log("MapDetailsPage: Invalid mapId, setting error"),U("Map ID is required"),A(!1);return}if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(u)){console.log("MapDetailsPage: Invalid UUID format:",u),U("Invalid Map ID format"),A(!1);return}console.log("MapDetailsPage: Fetching data for mapId:",u),ye(u)},[u,ye]),d.useEffect(()=>{if(!e||O||B)return;if(!u||u==="undefined"||u==="null"||u.trim()===""){console.log("Auto-navigation skipped: Invalid mapId");return}if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(u)){console.log("Auto-navigation skipped: Invalid mapId format");return}(()=>{const l=!p||e.title?.toLowerCase().includes(p.toLowerCase())||e.generated?.toLowerCase().includes(p.toLowerCase())||e.source?.toLowerCase().includes(p.toLowerCase())||e.event_type?.toLowerCase().includes(p.toLowerCase()),s=!v||e.source===v,n=!j||e.event_type===j,o=!w||e.countries.some(M=>M.r_code===w),r=!I||e.countries.some(M=>M.c_code===I),g=!N||e.image_type===N,_=!f||f==="manual"&&e.model==="manual"||f==="generated"&&e.model!=="manual",T=!k||e.starred===!0,E=l&&s&&n&&o&&r&&g&&_&&T;return console.log("Auto-navigation check:",{mapId:u,search:p,srcFilter:v,catFilter:j,regionFilter:w,countryFilter:I,imageTypeFilter:N,generatedMethodFilter:f,showReferenceExamples:k,matchesSearch:l,matchesSource:s,matchesCategory:n,matchesRegion:o,matchesCountry:r,matchesImageType:g,matchesReferenceExamples:T,matches:E}),E})()||(console.log("Current map does not match filters, looking for first matching item"),fetch("/api/images").then(l=>l.json()).then(l=>{console.log("Auto-navigation: Received images from API:",l.length),console.log("Auto-navigation: First few images:",l.slice(0,3).map(n=>({image_id:n.image_id,title:n.title})));const s=l.find(n=>{const o=!p||n.title?.toLowerCase().includes(p.toLowerCase())||n.generated?.toLowerCase().includes(p.toLowerCase())||n.source?.toLowerCase().includes(p.toLowerCase())||n.event_type?.toLowerCase().includes(p.toLowerCase()),r=!v||n.source===v,g=!j||n.event_type===j,_=!w||n.countries?.some(S=>S.r_code===w),T=!I||n.countries?.some(S=>S.c_code===I),E=!N||n.image_type===N,M=!f||f==="manual"&&n.model==="manual"||f==="generated"&&n.model!=="manual",h=!k||n.starred===!0;return o&&r&&g&&_&&T&&E&&M&&h});console.log("Auto-navigation: Found first matching image:",s?{image_id:s.image_id,title:s.title,source:s.source}:"No matching image found"),s&&s.image_id&&s.image_id!=="undefined"&&s.image_id!=="null"&&s.image_id.trim()!==""&&s.image_id!==u&&(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s.image_id)?(console.log("Auto-navigating to:",s.image_id),y(`/map/${s.image_id}`)):console.error("Auto-navigation blocked: Invalid image_id format:",s.image_id))}).catch(console.error))},[e,p,v,j,w,I,N,f,k,u,y,O,B]);const je=async t=>{if(!J){K(!0);try{const i=new URLSearchParams;p&&i.append("search",p),v&&i.append("source",v),j&&i.append("event_type",j),w&&i.append("region",w),I&&i.append("country",I),N&&i.append("image_type",N),C&&i.append("upload_type",C),k&&i.append("starred_only","true");const l=await fetch(`/api/images/grouped?${i.toString()}`);if(l.ok){let s=await l.json();s.items&&(s=s.items),f&&(s=s.filter(g=>f==="manual"?g.model==="manual":f==="generated"?g.model!=="manual":!0));const n=s.findIndex(g=>g.image_id===u);if(n===-1){console.error("Current image not found in filtered list");return}let o;t==="previous"?o=n>0?n-1:s.length-1:o=n{console.log("=== NAVIGATION USEEFFECT TRIGGERED ==="),console.log("Navigation useEffect triggered:",{map:!!e,mapId:u,loading:O,isDeleting:B,uploadTypeFilter:C,allFilters:{search:p,srcFilter:v,catFilter:j,regionFilter:w,countryFilter:I,imageTypeFilter:N,uploadTypeFilter:C,generatedMethodFilter:f,showReferenceExamples:k}}),e&&u&&!O&&!B?(console.log("Calling checkNavigationAvailability with:",u),Y(u)):console.log("NOT calling checkNavigationAvailability because:",{map:!!e,mapId:!!u,loading:O,isDeleting:B})},[e,u,p,v,j,w,I,N,C,f,k,O,B,Y]),d.useEffect(()=>{Promise.all([fetch("/api/sources").then(t=>t.json()),fetch("/api/types").then(t=>t.json()),fetch("/api/image-types").then(t=>t.json()),fetch("/api/regions").then(t=>t.json()),fetch("/api/countries").then(t=>t.json())]).then(([t,i,l,s,n])=>{Ce(t),be(i),Se(l),ke(s),Me(n)}).catch(console.error)},[]);const qe=async()=>{e&&Z(!0)},Ke=async()=>{if(e)try{(await fetch(`/api/images/${e.image_id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({starred:!e.starred})})).ok?te(i=>i?{...i,starred:!i.starred}:null):console.error("Failed to toggle starred status")}catch(t){console.error("Error toggling starred status:",t)}},Ze=async()=>{if(e){X(!0);try{if(console.log("Deleting image with ID:",e.image_id),(await fetch(`/api/images/${e.image_id}`,{method:"DELETE"})).ok){te(i=>i?{...i,starred:!i.starred}:null),Z(!1);try{const i=await fetch("/api/images/grouped");if(i.ok){const s=(await i.json()).filter(o=>{const r=!p||o.title?.toLowerCase().includes(p.toLowerCase())||o.generated?.toLowerCase().includes(p.toLowerCase())||o.source?.toLowerCase().includes(p.toLowerCase())||o.event_type?.toLowerCase().includes(p.toLowerCase()),g=!v||o.source===v,_=!j||o.event_type===j,T=!w||o.countries?.some(b=>b.r_code===w),E=!I||o.countries?.some(b=>b.c_code===I),M=!N||o.image_type===N,h=!C||C==="single"&&(!o.image_count||o.image_count<=1)||C==="multiple"&&o.image_count&&o.image_count>1,S=!f||f==="manual"&&o.model==="manual"||f==="generated"&&o.model!=="manual",D=!k||o.starred===!0;return r&&g&&_&&T&&E&&M&&h&&S&&D}),n=s.filter(o=>o.image_id!==e.image_id);if(n.length>0){const o=s.findIndex(g=>g.image_id===e.image_id);let r;if(o===s.length-1?r=o-1:r=o,console.log("Navigation target:",{currentIndex:o,targetIndex:r,targetId:n[r]?.image_id}),r>=0&&r{A(!0);try{const t=new URLSearchParams;p&&t.append("search",p),v&&t.append("source",v),j&&t.append("event_type",j),w&&t.append("region",w),I&&t.append("country",I),N&&t.append("image_type",N),C&&t.append("upload_type",C),k&&t.append("starred_only","true");const i=await fetch(`/api/images/grouped?${t.toString()}`);if(i.ok){let l=await i.json();if(l.items&&(l=l.items),f&&(l=l.filter(s=>f==="manual"?s.model==="manual":f==="generated"?s.model!=="manual":!0)),l.length>0){const s=l[0];s&&s.image_id&&y(`/map/${s.image_id}`)}else y("/explore")}}catch(t){console.error("Failed to navigate to matching image:",t),y("/explore")}finally{A(!1)}},[p,v,j,w,I,N,C,f,k,y]),c=d.useMemo(()=>{if(!e)return null;if(!p&&!v&&!j&&!w&&!I&&!N&&!C&&!f&&!k)return e;const t=!p||e.title?.toLowerCase().includes(p.toLowerCase())||e.generated?.toLowerCase().includes(p.toLowerCase())||e.source?.toLowerCase().includes(p.toLowerCase())||e.event_type?.toLowerCase().includes(p.toLowerCase()),i=!v||e.source===v,l=!j||e.event_type===j,s=!w||e.countries.some(E=>E.r_code===w),n=!I||e.countries.some(E=>E.c_code===I),o=!N||e.image_type===N,r=!C||C==="single"&&(!e.image_count||e.image_count<=1)&&(!e.all_image_ids||e.all_image_ids.length<=1)||C==="multiple"&&(e.image_count&&e.image_count>1||e.all_image_ids&&e.all_image_ids.length>1),g=!f||f==="manual"&&e.model==="manual"||f==="generated"&&e.model!=="manual",_=!k||e.starred===!0,T=t&&i&&l&&s&&n&&o&&r&&g&&_;return!T&&(p||v||j||w||I||N||C||f||k)?(setTimeout(()=>{we()},100),e):T?e:null},[e,p,v,j,w,I,N,C,f,k,we]),Qe=()=>{if(!e)return;if(!e.all_image_ids||e.all_image_ids.length<=1){const s=`/upload?step=1&contribute=true&imageIds=${[e.image_id].join(",")}`;y(s);return}const i=`/upload?step=1&contribute=true&imageIds=${e.all_image_ids.join(",")}`;y(i)},$=(t,i)=>({image:`images/${i}`,caption:t.edited||t.generated||"",metadata:{image_id:t.image_count&&t.image_count>1?t.all_image_ids||[t.image_id]:t.image_id,title:t.title,source:t.source,event_type:t.event_type,image_type:t.image_type,countries:t.countries,starred:t.starred,image_count:t.image_count||1}}),Xe=async t=>{if(e){se(!0),ie(!1);try{const i=(await ra(async()=>{const{default:r}=await import("./jszip.min-XJUuvkAi.js").then(g=>g.j);return{default:r}},__vite__mapDeps([0,1,2]))).default,l=new i;if(e.image_type==="crisis_map"){const r=l.folder("crisis_maps_dataset"),g=r?.folder("images");if(g)try{const _=e.image_count&&e.image_count>1?e.all_image_ids||[e.image_id]:[e.image_id],T=_.map(async(h,S)=>{try{const D=await fetch(`/api/images/${h}/file`);if(!D.ok)throw new Error(`Failed to fetch image ${h}`);const b=await D.blob(),ee=e.file_key.split(".").pop()||"jpg",W=`0001_${String(S+1).padStart(2,"0")}.${ee}`;return g.file(W,b),{success:!0,fileName:W,imageId:h}}catch(D){return console.error(`Failed to process image ${h}:`,D),{success:!1,fileName:"",imageId:h}}}),M=(await Promise.all(T)).filter(h=>h.success);if(M.length===0)throw new Error("No images could be processed");if(t==="fine-tuning"){const h=[],S=[],D=[],b=M.map(ea=>`images/${ea.fileName}`),ee=Math.random(),W={image:b.length===1?b[0]:b,caption:e.edited||e.generated||"",metadata:{image_id:_,title:e.title,source:e.source,event_type:e.event_type,image_type:e.image_type,countries:e.countries,starred:e.starred,image_count:e.image_count||1}};ee`images/${D.fileName}`),S={image:h.length===1?h[0]:h,caption:e.edited||e.generated||"",metadata:{image_id:_,title:e.title,source:e.source,event_type:e.event_type,image_type:e.image_type,countries:e.countries,starred:e.starred,image_count:e.image_count||1}};r&&r.file("0001.json",JSON.stringify(S,null,2))}}catch(_){throw console.error(`Failed to process image ${e.image_id}:`,_),_}}else if(e.image_type==="drone_image"){const r=l.folder("drone_images_dataset"),g=r?.folder("images");if(g)try{const _=await fetch(`/api/images/${e.image_id}/file`);if(!_.ok)throw new Error(`Failed to fetch image ${e.image_id}`);const T=await _.blob(),M=`0001.${e.file_key.split(".").pop()||"jpg"}`;if(g.file(M,T),t==="fine-tuning"){const h=[],S=[],D=[];if(String(e?.image_type)==="crisis_map"){const b=Math.random();b1?e.all_image_ids||[e.image_id]:e.image_id,title:e.title,source:e.source,event_type:e.event_type,image_type:e.image_type,countries:e.countries,starred:e.starred,image_count:e.image_count||1}};r&&r.file("0001.json",JSON.stringify(h,null,2))}}catch(_){throw console.error(`Failed to process image ${e.image_id}:`,_),_}}else{const r=l.folder("generic_dataset"),g=r?.folder("images");if(g)try{const _=await fetch(`/api/images/${e.image_id}/file`);if(!_.ok)throw new Error(`Failed to fetch image ${e.image_id}`);const T=await _.blob(),M=`0001.${e.file_key.split(".").pop()||"jpg"}`;if(g.file(M,T),t==="fine-tuning"){const h=[],S=[],D=[];if(String(e?.image_type)==="crisis_map"){const b=Math.random();b1?e.all_image_ids||[e.image_id]:e.image_id,title:e.title,source:e.source,event_type:e.event_type,image_type:e.image_type,countries:e.countries,starred:e.starred,image_count:e.image_count||1}};r&&r.file("0001.json",JSON.stringify(h,null,2))}}catch(_){throw console.error(`Failed to process image ${e.image_id}:`,_),_}}const s=await l.generateAsync({type:"blob"}),n=URL.createObjectURL(s),o=document.createElement("a");o.href=n,o.download=`dataset_${e.image_type}_${e.image_id}_${t}_${new Date().toISOString().split("T")[0]}.zip`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n),console.log(`Exported ${e.image_type} dataset with 1 image in ${t} mode`),ie(!0)}catch(i){console.error("Export failed:",i),alert("Failed to export dataset. Please try again.")}finally{se(!1)}}},Ye=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;return!u||u==="undefined"||u==="null"||u.trim()===""||!Ye.test(u)?a.jsx(ae,{children:a.jsxs("div",{className:"flex flex-col items-center gap-4 text-center py-12",children:[a.jsx("div",{className:"text-4xl",children:"⚠️"}),a.jsx("div",{className:"text-xl font-semibold",children:"Invalid Map ID"}),a.jsx("div",{children:"The map ID provided is not valid."}),a.jsxs("div",{className:"text-sm text-gray-500 mt-2",children:['Debug Info: mapId = "',u,'" (type: ',typeof u,")"]}),a.jsx(F,{name:"back-to-explore",variant:"secondary",onClick:()=>y("/explore"),children:"Return to Explore"})]})}):O?a.jsx(ae,{children:a.jsx("div",{className:m.loadingContainer,children:a.jsxs("div",{className:"flex flex-col items-center gap-4",children:[a.jsx(Ie,{className:"text-ifrcRed"}),a.jsx("div",{children:"Loading map details..."})]})})}):de||!e?a.jsx(ae,{children:a.jsx("div",{className:m.errorContainer,children:a.jsxs("div",{className:"flex flex-col items-center gap-4 text-center",children:[a.jsx("div",{className:"text-4xl",children:"⚠️"}),a.jsx("div",{className:"text-xl font-semibold",children:"Unable to load map"}),a.jsx("div",{children:de||"Map not found"}),a.jsx(F,{name:"back-to-explore",variant:"secondary",onClick:()=>y("/explore"),children:"Return to Explore"})]})})}):a.jsxs(ae,{children:[a.jsxs("div",{className:"max-w-7xl mx-auto",children:[a.jsxs("div",{className:m.tabSelector,children:[a.jsx(ia,{name:"map-details-view",value:ce,onChange:t=>{(t==="mapDetails"||t==="explore")&&(Ne(t),t==="explore"&&y("/explore"))},options:We,keySelector:t=>t.key,labelSelector:t=>t.label}),a.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[a.jsx(P,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:a.jsxs(F,{name:"reference-examples",variant:k?"primary":"secondary",onClick:()=>Ue(!k),className:"whitespace-nowrap",children:[a.jsx("span",{className:"mr-2",children:k?a.jsx("span",{className:"text-yellow-400",children:"★"}):a.jsx("span",{className:"text-yellow-400",children:"☆"})}),"Reference Examples"]})}),a.jsx(F,{name:"export-dataset",variant:"secondary",onClick:()=>Q(!0),children:"Export"})]})]}),a.jsx(ca,{sources:ge,types:me,regions:pe,countries:De,imageTypes:ue,isLoadingFilters:!1}),ce==="mapDetails"?a.jsx("div",{className:"relative",children:c?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:m.gridLayout,children:[a.jsxs(P,{heading:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{children:c.title||"Map Image"}),c.starred&&a.jsx("span",{className:"text-red-500 text-xl",title:"Starred image",children:"★"})]}),headingLevel:2,withHeaderBorder:!0,withInternalPadding:!0,spacing:"comfortable",children:[a.jsx("div",{className:m.imageContainer,children:e?.image_count&&e.image_count>1||x.length>1?a.jsxs("div",{className:m.carouselContainer,children:[a.jsx("div",{className:m.carouselImageWrapper,children:q?a.jsxs("div",{className:m.imagePlaceholder,children:[a.jsx(Ie,{className:"text-ifrcRed"}),a.jsx("div",{children:"Loading images..."})]}):x[L]?.detail_url?a.jsx("img",{src:x[L].detail_url,alt:x[L].file_key,className:m.carouselImage,onError:t=>{console.log("MapDetailsPage: Detail image failed to load, falling back to original:",x[L].detail_url);const i=t.target;x[L].image_url&&(i.src=x[L].image_url)},onLoad:()=>console.log("MapDetailsPage: Detail image loaded successfully:",x[L].detail_url)}):x[L]?.image_url?a.jsx("img",{src:x[L].image_url,alt:x[L].file_key,className:m.carouselImage,onLoad:()=>console.log("MapDetailsPage: Original image loaded successfully:",x[L].image_url)}):a.jsx("div",{className:m.imagePlaceholder,children:"No image available"})}),a.jsxs("div",{className:m.carouselNavigation,children:[a.jsx(F,{name:"previous-image",variant:"tertiary",size:1,onClick:Je,disabled:q,className:m.carouselButton,children:a.jsx(oe,{className:"w-4 h-4"})}),a.jsx("div",{className:m.carouselIndicators,children:x.map((t,i)=>a.jsx("button",{onClick:()=>Ve(i),className:`${m.carouselIndicator} ${i===L?m.carouselIndicatorActive:""}`,disabled:q,children:i+1},i))}),a.jsx(F,{name:"next-image",variant:"tertiary",size:1,onClick:Ge,disabled:q,className:m.carouselButton,children:a.jsx(re,{className:"w-4 h-4"})})]}),a.jsx("div",{className:m.viewImageButtonContainer,children:a.jsx(F,{name:"view-full-size-carousel",variant:"secondary",size:1,onClick:()=>ve(x[L]),disabled:q||!x[L]?.image_url,children:"View Image"})})]}):a.jsxs("div",{className:m.singleImageContainer,children:[c.detail_url?a.jsx("img",{src:c.detail_url,alt:c.file_key,onError:t=>{console.log("MapDetailsPage: Detail image failed to load, falling back to original:",c.detail_url);const i=t.target;c.image_url&&(i.src=c.image_url)},onLoad:()=>console.log("MapDetailsPage: Detail image loaded successfully:",c.detail_url)}):c.image_url?a.jsx("img",{src:c.image_url,alt:c.file_key,onLoad:()=>console.log("MapDetailsPage: Original image loaded successfully:",c.image_url)}):a.jsx("div",{className:m.imagePlaceholder,children:"No image available"}),a.jsx("div",{className:m.viewImageButtonContainer,children:a.jsx(F,{name:"view-full-size-single",variant:"secondary",size:1,onClick:()=>ve(c),disabled:!c.image_url,children:"View Image"})})]})}),a.jsx(P,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:a.jsxs("div",{className:m.metadataTags,children:[c.image_type!=="drone_image"&&a.jsx("span",{className:m.metadataTag,children:ge.find(t=>t.s_code===c.source)?.label||c.source}),a.jsx("span",{className:m.metadataTag,children:me.find(t=>t.t_code===c.event_type)?.label||c.event_type}),a.jsx("span",{className:m.metadataTag,children:ue.find(t=>t.image_type===c.image_type)?.label||c.image_type}),a.jsx("span",{className:m.metadataTag,children:c.model==="manual"?"Manual":"Generated"}),c.countries&&c.countries.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:m.metadataTag,children:pe.find(t=>t.r_code===c.countries[0].r_code)?.label||"Unknown Region"}),a.jsx("span",{className:m.metadataTag,children:c.countries.map(t=>t.label).join(", ")})]}),c.image_count&&c.image_count>1&&a.jsxs("span",{className:m.metadataTag,title:`Multi-upload with ${c.image_count} images`,children:["📷 ",c.image_count]}),(!c.image_count||c.image_count<=1)&&a.jsx("span",{className:m.metadataTag,title:"Single Upload",children:"Single"})]})})]}),a.jsx("div",{className:m.detailsSection,children:c.edited&&c.edited.includes("Description:")||c.generated&&c.generated.includes("Description:")?a.jsx(P,{heading:"Interpretation",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,spacing:"comfortable",children:a.jsx("div",{className:m.captionContainer,children:a.jsx("div",{className:m.captionText,children:(c.edited||c.generated||"").split(/(Description:|Analysis:|Recommended Actions:)/).map((l,s)=>l.trim()===""?null:l==="Description:"||l==="Analysis:"||l==="Recommended Actions:"?a.jsx("h4",{className:"font-semibold text-gray-800 mt-4 mb-2",children:l},s):a.jsx("p",{className:"mb-2",children:l.trim()},s))})})}):a.jsx(P,{heading:"Description",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,spacing:"comfortable",children:a.jsx("div",{className:m.captionContainer,children:c.generated||c.edited?a.jsx("div",{className:m.captionText,children:a.jsx("p",{children:c.edited||c.generated})}):a.jsx("p",{children:"— no caption yet —"})})})})]}),a.jsx("div",{className:"flex items-center justify-center mt-8",children:a.jsx(P,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center gap-4",children:[Le&&a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(F,{name:"previous-item",variant:"tertiary",size:1,className:`bg-white/90 hover:bg-white shadow-lg border border-gray-200 ${J?"opacity-50 cursor-not-allowed":"hover:scale-110"}`,onClick:()=>je("previous"),disabled:J,children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs("div",{className:"flex -space-x-1",children:[a.jsx(oe,{className:"w-4 h-4"}),a.jsx(oe,{className:"w-4 h-4"})]}),a.jsx("span",{className:"font-semibold",children:"Previous"})]})})}),le&&a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(F,{name:"delete",variant:"tertiary",size:1,className:"bg-red-50 hover:bg-red-100 text-red-700 border border-red-200 hover:border-red-300",onClick:qe,title:"Delete","aria-label":"Delete saved image",children:a.jsx(na,{className:"w-4 h-4"})})}),a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(F,{name:"contribute",onClick:Qe,children:"Contribute"})}),le&&a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(F,{name:"toggle-star",variant:"tertiary",size:1,className:`${e?.starred?"bg-red-100 hover:bg-red-200 text-red-800 border-2 border-red-400":"bg-gray-100 hover:bg-gray-200 text-gray-600 border-2 border-gray-300"} w-16 h-8 rounded-full transition-all duration-200 flex items-center justify-center`,onClick:Ke,title:e?.starred?"Unstar image":"Star image","aria-label":e?.starred?"Unstar image":"Star image",children:a.jsx("span",{className:`text-lg transition-all duration-200 ${e?.starred?"text-red-600":"text-gray-500"}`,children:e?.starred?"★":"☆"})})}),Te&&a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(F,{name:"next-item",variant:"tertiary",size:1,className:`bg-white/90 hover:bg-white shadow-lg border border-gray-200 ${J?"opacity-50 cursor-not-allowed":"hover:scale-110"}`,onClick:()=>je("next"),disabled:J,children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"font-semibold",children:"Next"}),a.jsxs("div",{className:"flex -space-x-1",children:[a.jsx(re,{className:"w-4 h-4"}),a.jsx(re,{className:"w-4 h-4"})]})]})})})]})})})]}):a.jsxs("div",{className:"text-center py-12",children:[a.jsx("div",{className:"text-xl font-semibold text-gray-600 mb-4",children:"No matches found"}),a.jsx("div",{className:"mt-4",children:a.jsx(F,{name:"clear-filters",variant:"secondary",onClick:Be,children:"Clear Filters"})})]})}):null]}),$e&&a.jsx("div",{className:m.fullSizeModalOverlay,onClick:()=>Z(!1),children:a.jsx("div",{className:m.fullSizeModalContent,onClick:t=>t.stopPropagation(),children:a.jsxs("div",{className:m.ratingWarningContent,children:[a.jsx("h3",{className:m.ratingWarningTitle,children:"Delete Image?"}),a.jsx("p",{className:m.ratingWarningText,children:"This action cannot be undone. Are you sure you want to delete this saved image and all related data?"}),a.jsxs("div",{className:m.ratingWarningButtons,children:[a.jsx(F,{name:"confirm-delete",variant:"secondary",onClick:Ze,children:"Delete"}),a.jsx(F,{name:"cancel-delete",variant:"tertiary",onClick:()=>Z(!1),children:"Cancel"})]})]})})}),fe&&a.jsx(da,{isOpen:fe,onClose:()=>{Q(!1),ie(!1),se(!1)},onExport:(t,i)=>{i.includes(e.image_type)&&Xe(t)},filteredCount:1,totalCount:1,hasFilters:!1,crisisMapsCount:e.image_type==="crisis_map"?1:0,droneImagesCount:e.image_type==="drone_image"?1:0,isLoading:Pe,exportSuccess:Re,variant:"single",onNavigateToList:()=>{Q(!1),y("/explore")},onNavigateAndExport:()=>{Q(!1),y("/explore?export=true")}}),a.jsx(oa,{isOpen:Ae,imageUrl:ze?.image_url||null,preview:null,selectedImageData:null,onClose:He,isLoading:Oe})]})}export{it as default}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jszip.min-BeHyG4q9.js","assets/index-C5rMGfs8.js","assets/index-BYJiCH1e.css"])))=>i.map(i=>d[i]); +import{K as aa,x as ta,r as d,D as sa,j as a,N as ae,n as F,_ as Ie,L as ia,z as P,v as oe,w as re,F as na,M as oa,G as ra}from"./index-C5rMGfs8.js";import{u as la}from"./useAdmin-B8fo0TJy.js";import{F as ca,E as da}from"./ExportModal-DJxQWbes.js";const ga="_tabSelector_usssr_1",ma="_imageContainer_usssr_12",ua="_imagePlaceholder_usssr_33",pa="_metadataTags_usssr_45",fa="_metadataTag_usssr_45",ha="_captionContainer_usssr_67",_a="_captionText_usssr_74",xa="_gridLayout_usssr_131",ya="_detailsSection_usssr_155",va="_loadingContainer_usssr_161",ja="_errorContainer_usssr_171",wa="_fullSizeModalOverlay_usssr_205",Ia="_fullSizeModalContent_usssr_219",Na="_ratingWarningContent_usssr_230",Ca="_ratingWarningTitle_usssr_236",ba="_ratingWarningText_usssr_243",Sa="_ratingWarningButtons_usssr_250",ka="_carouselContainer_usssr_365",Da="_carouselImageWrapper_usssr_370",Ma="_carouselImage_usssr_370",La="_carouselNavigation_usssr_393",Fa="_carouselButton_usssr_405",Ta="_carouselIndicators_usssr_429",Ea="_carouselIndicator_usssr_429",$a="_carouselIndicatorActive_usssr_458",Pa="_singleImageContainer_usssr_488",Ra="_viewImageButtonContainer_usssr_494",m={tabSelector:ga,imageContainer:ma,imagePlaceholder:ua,metadataTags:pa,metadataTag:fa,captionContainer:ha,captionText:_a,gridLayout:xa,detailsSection:ya,loadingContainer:va,errorContainer:ja,fullSizeModalOverlay:wa,fullSizeModalContent:Ia,ratingWarningContent:Na,ratingWarningTitle:Ca,ratingWarningText:ba,ratingWarningButtons:Sa,carouselContainer:ka,carouselImageWrapper:Da,carouselImage:Ma,carouselNavigation:La,carouselButton:Fa,carouselIndicators:Ta,carouselIndicator:Ea,carouselIndicatorActive:$a,singleImageContainer:Pa,viewImageButtonContainer:Ra};function it(){const{mapId:u}=aa(),y=ta(),{isAuthenticated:le}=la(),[ce,Ne]=d.useState("mapDetails"),[e,te]=d.useState(null),[O,A]=d.useState(!0),[de,U]=d.useState(null),[ge,Ce]=d.useState([]),[me,be]=d.useState([]),[ue,Se]=d.useState([]),[pe,ke]=d.useState([]),[De,Me]=d.useState([]),[Le,Fe]=d.useState(!1),[Te,Ee]=d.useState(!1),[J,K]=d.useState(!1),[$e,Z]=d.useState(!1),[fe,Q]=d.useState(!1),[Pe,se]=d.useState(!1),[Re,ie]=d.useState(!1),[Aa,za]=d.useState("standard"),[R,Oa]=d.useState(80),[G,Ua]=d.useState(10),[Ba,Wa]=d.useState(10),[Ja,Ga]=d.useState(!0),[Va,Ha]=d.useState(!0),[B,X]=d.useState(!1),[Ae,he]=d.useState(!1),[ze,_e]=d.useState(null),[Oe,V]=d.useState(!1),[x,H]=d.useState([]),[L,z]=d.useState(0),[q,xe]=d.useState(!1),{search:p,setSearch:qa,srcFilter:v,setSrcFilter:Ka,catFilter:j,setCatFilter:Za,regionFilter:w,setRegionFilter:Qa,countryFilter:I,setCountryFilter:Xa,imageTypeFilter:N,setImageTypeFilter:Ya,uploadTypeFilter:C,setUploadTypeFilter:et,generatedMethodFilter:f,showReferenceExamples:k,setShowReferenceExamples:Ue,clearAllFilters:Be}=sa(),We=[{key:"explore",label:"List"},{key:"mapDetails",label:"Carousel"}],Y=d.useCallback(async t=>{if(!(!t||t==="undefined"||t==="null"||t.trim()===""))try{const i=new URLSearchParams;p&&i.append("search",p),v&&i.append("source",v),j&&i.append("event_type",j),w&&i.append("region",w),I&&i.append("country",I),N&&i.append("image_type",N),C&&i.append("upload_type",C),k&&i.append("starred_only","true");const l=await fetch(`/api/images/grouped?${i.toString()}`);if(l.ok){let s=await l.json();s.items&&(s=s.items),f&&(s=s.filter(o=>f==="manual"?o.model==="manual":f==="generated"?o.model!=="manual":!0)),console.log("Server response for upload_type=multiple:",{url:`/api/images/grouped?${i.toString()}`,count:s.length,images:s.map(o=>({image_id:o.image_id,image_count:o.image_count,all_image_ids:o.all_image_ids,all_image_ids_length:o.all_image_ids?.length}))});const n=s.findIndex(o=>o.image_id===t);console.log("Navigation availability check (server-side):",{filteredImagesCount:s.length,currentIndex:n,currentId:t,uploadTypeFilter:C,hasPrevious:s.length>1&&n>0,hasNext:s.length>1&&n({image_id:o.image_id,image_count:o.image_count,all_image_ids:o.all_image_ids,image_type:o.image_type}))}),Fe(s.length>1&&n>0),Ee(s.length>1&&n{console.log("fetchAllImages called with imageIds:",t),xe(!0);try{const i=t.map(async s=>{const n=await fetch(`/api/images/${s}`);if(!n.ok)throw new Error(`Failed to fetch image ${s}`);return n.json()}),l=await Promise.all(i);H(l),z(0),console.log("fetchAllImages: Loaded",l.length,"images")}catch(i){console.error("fetchAllImages error:",i),U(i instanceof Error?i.message:"Failed to load all images")}finally{xe(!1)}},[]),ye=d.useCallback(async t=>{if(console.log("fetchMapData called with id:",t),console.log("fetchMapData id type:",typeof t),!t||t==="undefined"||t==="null"||t.trim()===""){console.log("fetchMapData: Invalid ID detected:",t),U("Invalid Map ID"),A(!1);return}if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)){console.log("fetchMapData: Invalid UUID format:",t),U("Invalid Map ID format"),A(!1);return}console.log("fetchMapData: Making API call for id:",t),K(!0),A(!0);try{const l=await fetch(`/api/images/${t}`);if(!l.ok)throw new Error("Map not found");const s=await l.json();if(te(s),s.all_image_ids&&s.all_image_ids.length>1)await ne(s.all_image_ids);else if(s.image_count&&s.image_count>1){console.log("Multi-upload detected but no all_image_ids, trying grouped endpoint");try{const n=await fetch("/api/images/grouped");if(n.ok){const r=(await n.json()).find(g=>g.all_image_ids&&g.all_image_ids.includes(s.image_id));r&&r.all_image_ids?await ne(r.all_image_ids):(H([s]),z(0))}else H([s]),z(0)}catch(n){console.error("Failed to fetch from grouped endpoint:",n),H([s]),z(0)}}else H([s]),z(0);await Y(t)}catch(l){U(l instanceof Error?l.message:"Unknown error occurred")}finally{A(!1),K(!1)}},[Y,ne]),Je=d.useCallback(()=>{x.length>1&&z(t=>t>0?t-1:x.length-1)},[x.length]),Ge=d.useCallback(()=>{x.length>1&&z(t=>t{t>=0&&t{const i=t||(x.length>0?x[L]:e);if(i){V(!0),_e(i),he(!0);try{const l=new Image;l.onload=()=>{V(!1)},l.onerror=()=>{V(!1)},l.src=i.image_url}catch(l){console.error("Error preloading full-size image:",l),V(!1)}}},[x,L,e]),He=d.useCallback(()=>{he(!1),_e(null),V(!1)},[]);d.useEffect(()=>{if(console.log("MapDetailsPage: mapId from useParams:",u),console.log("MapDetailsPage: mapId type:",typeof u),console.log("MapDetailsPage: mapId value:",u),!u||u==="undefined"||u==="null"||u.trim()===""||u===void 0||u===null){console.log("MapDetailsPage: Invalid mapId, setting error"),U("Map ID is required"),A(!1);return}if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(u)){console.log("MapDetailsPage: Invalid UUID format:",u),U("Invalid Map ID format"),A(!1);return}console.log("MapDetailsPage: Fetching data for mapId:",u),ye(u)},[u,ye]),d.useEffect(()=>{if(!e||O||B)return;if(!u||u==="undefined"||u==="null"||u.trim()===""){console.log("Auto-navigation skipped: Invalid mapId");return}if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(u)){console.log("Auto-navigation skipped: Invalid mapId format");return}(()=>{const l=!p||e.title?.toLowerCase().includes(p.toLowerCase())||e.generated?.toLowerCase().includes(p.toLowerCase())||e.source?.toLowerCase().includes(p.toLowerCase())||e.event_type?.toLowerCase().includes(p.toLowerCase()),s=!v||e.source===v,n=!j||e.event_type===j,o=!w||e.countries.some(M=>M.r_code===w),r=!I||e.countries.some(M=>M.c_code===I),g=!N||e.image_type===N,_=!f||f==="manual"&&e.model==="manual"||f==="generated"&&e.model!=="manual",T=!k||e.starred===!0,E=l&&s&&n&&o&&r&&g&&_&&T;return console.log("Auto-navigation check:",{mapId:u,search:p,srcFilter:v,catFilter:j,regionFilter:w,countryFilter:I,imageTypeFilter:N,generatedMethodFilter:f,showReferenceExamples:k,matchesSearch:l,matchesSource:s,matchesCategory:n,matchesRegion:o,matchesCountry:r,matchesImageType:g,matchesReferenceExamples:T,matches:E}),E})()||(console.log("Current map does not match filters, looking for first matching item"),fetch("/api/images").then(l=>l.json()).then(l=>{console.log("Auto-navigation: Received images from API:",l.length),console.log("Auto-navigation: First few images:",l.slice(0,3).map(n=>({image_id:n.image_id,title:n.title})));const s=l.find(n=>{const o=!p||n.title?.toLowerCase().includes(p.toLowerCase())||n.generated?.toLowerCase().includes(p.toLowerCase())||n.source?.toLowerCase().includes(p.toLowerCase())||n.event_type?.toLowerCase().includes(p.toLowerCase()),r=!v||n.source===v,g=!j||n.event_type===j,_=!w||n.countries?.some(S=>S.r_code===w),T=!I||n.countries?.some(S=>S.c_code===I),E=!N||n.image_type===N,M=!f||f==="manual"&&n.model==="manual"||f==="generated"&&n.model!=="manual",h=!k||n.starred===!0;return o&&r&&g&&_&&T&&E&&M&&h});console.log("Auto-navigation: Found first matching image:",s?{image_id:s.image_id,title:s.title,source:s.source}:"No matching image found"),s&&s.image_id&&s.image_id!=="undefined"&&s.image_id!=="null"&&s.image_id.trim()!==""&&s.image_id!==u&&(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s.image_id)?(console.log("Auto-navigating to:",s.image_id),y(`/map/${s.image_id}`)):console.error("Auto-navigation blocked: Invalid image_id format:",s.image_id))}).catch(console.error))},[e,p,v,j,w,I,N,f,k,u,y,O,B]);const je=async t=>{if(!J){K(!0);try{const i=new URLSearchParams;p&&i.append("search",p),v&&i.append("source",v),j&&i.append("event_type",j),w&&i.append("region",w),I&&i.append("country",I),N&&i.append("image_type",N),C&&i.append("upload_type",C),k&&i.append("starred_only","true");const l=await fetch(`/api/images/grouped?${i.toString()}`);if(l.ok){let s=await l.json();s.items&&(s=s.items),f&&(s=s.filter(g=>f==="manual"?g.model==="manual":f==="generated"?g.model!=="manual":!0));const n=s.findIndex(g=>g.image_id===u);if(n===-1){console.error("Current image not found in filtered list");return}let o;t==="previous"?o=n>0?n-1:s.length-1:o=n{console.log("=== NAVIGATION USEEFFECT TRIGGERED ==="),console.log("Navigation useEffect triggered:",{map:!!e,mapId:u,loading:O,isDeleting:B,uploadTypeFilter:C,allFilters:{search:p,srcFilter:v,catFilter:j,regionFilter:w,countryFilter:I,imageTypeFilter:N,uploadTypeFilter:C,generatedMethodFilter:f,showReferenceExamples:k}}),e&&u&&!O&&!B?(console.log("Calling checkNavigationAvailability with:",u),Y(u)):console.log("NOT calling checkNavigationAvailability because:",{map:!!e,mapId:!!u,loading:O,isDeleting:B})},[e,u,p,v,j,w,I,N,C,f,k,O,B,Y]),d.useEffect(()=>{Promise.all([fetch("/api/sources").then(t=>t.json()),fetch("/api/types").then(t=>t.json()),fetch("/api/image-types").then(t=>t.json()),fetch("/api/regions").then(t=>t.json()),fetch("/api/countries").then(t=>t.json())]).then(([t,i,l,s,n])=>{Ce(t),be(i),Se(l),ke(s),Me(n)}).catch(console.error)},[]);const qe=async()=>{e&&Z(!0)},Ke=async()=>{if(e)try{(await fetch(`/api/images/${e.image_id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({starred:!e.starred})})).ok?te(i=>i?{...i,starred:!i.starred}:null):console.error("Failed to toggle starred status")}catch(t){console.error("Error toggling starred status:",t)}},Ze=async()=>{if(e){X(!0);try{if(console.log("Deleting image with ID:",e.image_id),(await fetch(`/api/images/${e.image_id}`,{method:"DELETE"})).ok){te(i=>i?{...i,starred:!i.starred}:null),Z(!1);try{const i=await fetch("/api/images/grouped");if(i.ok){const s=(await i.json()).filter(o=>{const r=!p||o.title?.toLowerCase().includes(p.toLowerCase())||o.generated?.toLowerCase().includes(p.toLowerCase())||o.source?.toLowerCase().includes(p.toLowerCase())||o.event_type?.toLowerCase().includes(p.toLowerCase()),g=!v||o.source===v,_=!j||o.event_type===j,T=!w||o.countries?.some(b=>b.r_code===w),E=!I||o.countries?.some(b=>b.c_code===I),M=!N||o.image_type===N,h=!C||C==="single"&&(!o.image_count||o.image_count<=1)||C==="multiple"&&o.image_count&&o.image_count>1,S=!f||f==="manual"&&o.model==="manual"||f==="generated"&&o.model!=="manual",D=!k||o.starred===!0;return r&&g&&_&&T&&E&&M&&h&&S&&D}),n=s.filter(o=>o.image_id!==e.image_id);if(n.length>0){const o=s.findIndex(g=>g.image_id===e.image_id);let r;if(o===s.length-1?r=o-1:r=o,console.log("Navigation target:",{currentIndex:o,targetIndex:r,targetId:n[r]?.image_id}),r>=0&&r{A(!0);try{const t=new URLSearchParams;p&&t.append("search",p),v&&t.append("source",v),j&&t.append("event_type",j),w&&t.append("region",w),I&&t.append("country",I),N&&t.append("image_type",N),C&&t.append("upload_type",C),k&&t.append("starred_only","true");const i=await fetch(`/api/images/grouped?${t.toString()}`);if(i.ok){let l=await i.json();if(l.items&&(l=l.items),f&&(l=l.filter(s=>f==="manual"?s.model==="manual":f==="generated"?s.model!=="manual":!0)),l.length>0){const s=l[0];s&&s.image_id&&y(`/map/${s.image_id}`)}else y("/explore")}}catch(t){console.error("Failed to navigate to matching image:",t),y("/explore")}finally{A(!1)}},[p,v,j,w,I,N,C,f,k,y]),c=d.useMemo(()=>{if(!e)return null;if(!p&&!v&&!j&&!w&&!I&&!N&&!C&&!f&&!k)return e;const t=!p||e.title?.toLowerCase().includes(p.toLowerCase())||e.generated?.toLowerCase().includes(p.toLowerCase())||e.source?.toLowerCase().includes(p.toLowerCase())||e.event_type?.toLowerCase().includes(p.toLowerCase()),i=!v||e.source===v,l=!j||e.event_type===j,s=!w||e.countries.some(E=>E.r_code===w),n=!I||e.countries.some(E=>E.c_code===I),o=!N||e.image_type===N,r=!C||C==="single"&&(!e.image_count||e.image_count<=1)&&(!e.all_image_ids||e.all_image_ids.length<=1)||C==="multiple"&&(e.image_count&&e.image_count>1||e.all_image_ids&&e.all_image_ids.length>1),g=!f||f==="manual"&&e.model==="manual"||f==="generated"&&e.model!=="manual",_=!k||e.starred===!0,T=t&&i&&l&&s&&n&&o&&r&&g&&_;return!T&&(p||v||j||w||I||N||C||f||k)?(setTimeout(()=>{we()},100),e):T?e:null},[e,p,v,j,w,I,N,C,f,k,we]),Qe=()=>{if(!e)return;if(!e.all_image_ids||e.all_image_ids.length<=1){const s=`/upload?step=1&contribute=true&imageIds=${[e.image_id].join(",")}`;y(s);return}const i=`/upload?step=1&contribute=true&imageIds=${e.all_image_ids.join(",")}`;y(i)},$=(t,i)=>({image:`images/${i}`,caption:t.edited||t.generated||"",metadata:{image_id:t.image_count&&t.image_count>1?t.all_image_ids||[t.image_id]:t.image_id,title:t.title,source:t.source,event_type:t.event_type,image_type:t.image_type,countries:t.countries,starred:t.starred,image_count:t.image_count||1}}),Xe=async t=>{if(e){se(!0),ie(!1);try{const i=(await ra(async()=>{const{default:r}=await import("./jszip.min-BeHyG4q9.js").then(g=>g.j);return{default:r}},__vite__mapDeps([0,1,2]))).default,l=new i;if(e.image_type==="crisis_map"){const r=l.folder("crisis_maps_dataset"),g=r?.folder("images");if(g)try{const _=e.image_count&&e.image_count>1?e.all_image_ids||[e.image_id]:[e.image_id],T=_.map(async(h,S)=>{try{const D=await fetch(`/api/images/${h}/file`);if(!D.ok)throw new Error(`Failed to fetch image ${h}`);const b=await D.blob(),ee=e.file_key.split(".").pop()||"jpg",W=`0001_${String(S+1).padStart(2,"0")}.${ee}`;return g.file(W,b),{success:!0,fileName:W,imageId:h}}catch(D){return console.error(`Failed to process image ${h}:`,D),{success:!1,fileName:"",imageId:h}}}),M=(await Promise.all(T)).filter(h=>h.success);if(M.length===0)throw new Error("No images could be processed");if(t==="fine-tuning"){const h=[],S=[],D=[],b=M.map(ea=>`images/${ea.fileName}`),ee=Math.random(),W={image:b.length===1?b[0]:b,caption:e.edited||e.generated||"",metadata:{image_id:_,title:e.title,source:e.source,event_type:e.event_type,image_type:e.image_type,countries:e.countries,starred:e.starred,image_count:e.image_count||1}};ee`images/${D.fileName}`),S={image:h.length===1?h[0]:h,caption:e.edited||e.generated||"",metadata:{image_id:_,title:e.title,source:e.source,event_type:e.event_type,image_type:e.image_type,countries:e.countries,starred:e.starred,image_count:e.image_count||1}};r&&r.file("0001.json",JSON.stringify(S,null,2))}}catch(_){throw console.error(`Failed to process image ${e.image_id}:`,_),_}}else if(e.image_type==="drone_image"){const r=l.folder("drone_images_dataset"),g=r?.folder("images");if(g)try{const _=await fetch(`/api/images/${e.image_id}/file`);if(!_.ok)throw new Error(`Failed to fetch image ${e.image_id}`);const T=await _.blob(),M=`0001.${e.file_key.split(".").pop()||"jpg"}`;if(g.file(M,T),t==="fine-tuning"){const h=[],S=[],D=[];if(String(e?.image_type)==="crisis_map"){const b=Math.random();b1?e.all_image_ids||[e.image_id]:e.image_id,title:e.title,source:e.source,event_type:e.event_type,image_type:e.image_type,countries:e.countries,starred:e.starred,image_count:e.image_count||1}};r&&r.file("0001.json",JSON.stringify(h,null,2))}}catch(_){throw console.error(`Failed to process image ${e.image_id}:`,_),_}}else{const r=l.folder("generic_dataset"),g=r?.folder("images");if(g)try{const _=await fetch(`/api/images/${e.image_id}/file`);if(!_.ok)throw new Error(`Failed to fetch image ${e.image_id}`);const T=await _.blob(),M=`0001.${e.file_key.split(".").pop()||"jpg"}`;if(g.file(M,T),t==="fine-tuning"){const h=[],S=[],D=[];if(String(e?.image_type)==="crisis_map"){const b=Math.random();b1?e.all_image_ids||[e.image_id]:e.image_id,title:e.title,source:e.source,event_type:e.event_type,image_type:e.image_type,countries:e.countries,starred:e.starred,image_count:e.image_count||1}};r&&r.file("0001.json",JSON.stringify(h,null,2))}}catch(_){throw console.error(`Failed to process image ${e.image_id}:`,_),_}}const s=await l.generateAsync({type:"blob"}),n=URL.createObjectURL(s),o=document.createElement("a");o.href=n,o.download=`dataset_${e.image_type}_${e.image_id}_${t}_${new Date().toISOString().split("T")[0]}.zip`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n),console.log(`Exported ${e.image_type} dataset with 1 image in ${t} mode`),ie(!0)}catch(i){console.error("Export failed:",i),alert("Failed to export dataset. Please try again.")}finally{se(!1)}}},Ye=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;return!u||u==="undefined"||u==="null"||u.trim()===""||!Ye.test(u)?a.jsx(ae,{children:a.jsxs("div",{className:"flex flex-col items-center gap-4 text-center py-12",children:[a.jsx("div",{className:"text-4xl",children:"⚠️"}),a.jsx("div",{className:"text-xl font-semibold",children:"Invalid Map ID"}),a.jsx("div",{children:"The map ID provided is not valid."}),a.jsxs("div",{className:"text-sm text-gray-500 mt-2",children:['Debug Info: mapId = "',u,'" (type: ',typeof u,")"]}),a.jsx(F,{name:"back-to-explore",variant:"secondary",onClick:()=>y("/explore"),children:"Return to Explore"})]})}):O?a.jsx(ae,{children:a.jsx("div",{className:m.loadingContainer,children:a.jsxs("div",{className:"flex flex-col items-center gap-4",children:[a.jsx(Ie,{className:"text-ifrcRed"}),a.jsx("div",{children:"Loading map details..."})]})})}):de||!e?a.jsx(ae,{children:a.jsx("div",{className:m.errorContainer,children:a.jsxs("div",{className:"flex flex-col items-center gap-4 text-center",children:[a.jsx("div",{className:"text-4xl",children:"⚠️"}),a.jsx("div",{className:"text-xl font-semibold",children:"Unable to load map"}),a.jsx("div",{children:de||"Map not found"}),a.jsx(F,{name:"back-to-explore",variant:"secondary",onClick:()=>y("/explore"),children:"Return to Explore"})]})})}):a.jsxs(ae,{children:[a.jsxs("div",{className:"max-w-7xl mx-auto",children:[a.jsxs("div",{className:m.tabSelector,children:[a.jsx(ia,{name:"map-details-view",value:ce,onChange:t=>{(t==="mapDetails"||t==="explore")&&(Ne(t),t==="explore"&&y("/explore"))},options:We,keySelector:t=>t.key,labelSelector:t=>t.label}),a.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[a.jsx(P,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:a.jsxs(F,{name:"reference-examples",variant:k?"primary":"secondary",onClick:()=>Ue(!k),className:"whitespace-nowrap",children:[a.jsx("span",{className:"mr-2",children:k?a.jsx("span",{className:"text-yellow-400",children:"★"}):a.jsx("span",{className:"text-yellow-400",children:"☆"})}),"Reference Examples"]})}),a.jsx(F,{name:"export-dataset",variant:"secondary",onClick:()=>Q(!0),children:"Export"})]})]}),a.jsx(ca,{sources:ge,types:me,regions:pe,countries:De,imageTypes:ue,isLoadingFilters:!1}),ce==="mapDetails"?a.jsx("div",{className:"relative",children:c?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:m.gridLayout,children:[a.jsxs(P,{heading:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{children:c.title||"Map Image"}),c.starred&&a.jsx("span",{className:"text-red-500 text-xl",title:"Starred image",children:"★"})]}),headingLevel:2,withHeaderBorder:!0,withInternalPadding:!0,spacing:"comfortable",children:[a.jsx("div",{className:m.imageContainer,children:e?.image_count&&e.image_count>1||x.length>1?a.jsxs("div",{className:m.carouselContainer,children:[a.jsx("div",{className:m.carouselImageWrapper,children:q?a.jsxs("div",{className:m.imagePlaceholder,children:[a.jsx(Ie,{className:"text-ifrcRed"}),a.jsx("div",{children:"Loading images..."})]}):x[L]?.detail_url?a.jsx("img",{src:x[L].detail_url,alt:x[L].file_key,className:m.carouselImage,onError:t=>{console.log("MapDetailsPage: Detail image failed to load, falling back to original:",x[L].detail_url);const i=t.target;x[L].image_url&&(i.src=x[L].image_url)},onLoad:()=>console.log("MapDetailsPage: Detail image loaded successfully:",x[L].detail_url)}):x[L]?.image_url?a.jsx("img",{src:x[L].image_url,alt:x[L].file_key,className:m.carouselImage,onLoad:()=>console.log("MapDetailsPage: Original image loaded successfully:",x[L].image_url)}):a.jsx("div",{className:m.imagePlaceholder,children:"No image available"})}),a.jsxs("div",{className:m.carouselNavigation,children:[a.jsx(F,{name:"previous-image",variant:"tertiary",size:1,onClick:Je,disabled:q,className:m.carouselButton,children:a.jsx(oe,{className:"w-4 h-4"})}),a.jsx("div",{className:m.carouselIndicators,children:x.map((t,i)=>a.jsx("button",{onClick:()=>Ve(i),className:`${m.carouselIndicator} ${i===L?m.carouselIndicatorActive:""}`,disabled:q,children:i+1},i))}),a.jsx(F,{name:"next-image",variant:"tertiary",size:1,onClick:Ge,disabled:q,className:m.carouselButton,children:a.jsx(re,{className:"w-4 h-4"})})]}),a.jsx("div",{className:m.viewImageButtonContainer,children:a.jsx(F,{name:"view-full-size-carousel",variant:"secondary",size:1,onClick:()=>ve(x[L]),disabled:q||!x[L]?.image_url,children:"View Image"})})]}):a.jsxs("div",{className:m.singleImageContainer,children:[c.detail_url?a.jsx("img",{src:c.detail_url,alt:c.file_key,onError:t=>{console.log("MapDetailsPage: Detail image failed to load, falling back to original:",c.detail_url);const i=t.target;c.image_url&&(i.src=c.image_url)},onLoad:()=>console.log("MapDetailsPage: Detail image loaded successfully:",c.detail_url)}):c.image_url?a.jsx("img",{src:c.image_url,alt:c.file_key,onLoad:()=>console.log("MapDetailsPage: Original image loaded successfully:",c.image_url)}):a.jsx("div",{className:m.imagePlaceholder,children:"No image available"}),a.jsx("div",{className:m.viewImageButtonContainer,children:a.jsx(F,{name:"view-full-size-single",variant:"secondary",size:1,onClick:()=>ve(c),disabled:!c.image_url,children:"View Image"})})]})}),a.jsx(P,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:a.jsxs("div",{className:m.metadataTags,children:[c.image_type!=="drone_image"&&a.jsx("span",{className:m.metadataTag,children:ge.find(t=>t.s_code===c.source)?.label||c.source}),a.jsx("span",{className:m.metadataTag,children:me.find(t=>t.t_code===c.event_type)?.label||c.event_type}),a.jsx("span",{className:m.metadataTag,children:ue.find(t=>t.image_type===c.image_type)?.label||c.image_type}),a.jsx("span",{className:m.metadataTag,children:c.model==="manual"?"Manual":"Generated"}),c.countries&&c.countries.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:m.metadataTag,children:pe.find(t=>t.r_code===c.countries[0].r_code)?.label||"Unknown Region"}),a.jsx("span",{className:m.metadataTag,children:c.countries.map(t=>t.label).join(", ")})]}),c.image_count&&c.image_count>1&&a.jsxs("span",{className:m.metadataTag,title:`Multi-upload with ${c.image_count} images`,children:["📷 ",c.image_count]}),(!c.image_count||c.image_count<=1)&&a.jsx("span",{className:m.metadataTag,title:"Single Upload",children:"Single"})]})})]}),a.jsx("div",{className:m.detailsSection,children:c.edited&&c.edited.includes("Description:")||c.generated&&c.generated.includes("Description:")?a.jsx(P,{heading:"Interpretation",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,spacing:"comfortable",children:a.jsx("div",{className:m.captionContainer,children:a.jsx("div",{className:m.captionText,children:(c.edited||c.generated||"").split(/(Description:|Analysis:|Recommended Actions:)/).map((l,s)=>l.trim()===""?null:l==="Description:"||l==="Analysis:"||l==="Recommended Actions:"?a.jsx("h4",{className:"font-semibold text-gray-800 mt-4 mb-2",children:l},s):a.jsx("p",{className:"mb-2",children:l.trim()},s))})})}):a.jsx(P,{heading:"Description",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,spacing:"comfortable",children:a.jsx("div",{className:m.captionContainer,children:c.generated||c.edited?a.jsx("div",{className:m.captionText,children:a.jsx("p",{children:c.edited||c.generated})}):a.jsx("p",{children:"— no caption yet —"})})})})]}),a.jsx("div",{className:"flex items-center justify-center mt-8",children:a.jsx(P,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center gap-4",children:[Le&&a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(F,{name:"previous-item",variant:"tertiary",size:1,className:`bg-white/90 hover:bg-white shadow-lg border border-gray-200 ${J?"opacity-50 cursor-not-allowed":"hover:scale-110"}`,onClick:()=>je("previous"),disabled:J,children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs("div",{className:"flex -space-x-1",children:[a.jsx(oe,{className:"w-4 h-4"}),a.jsx(oe,{className:"w-4 h-4"})]}),a.jsx("span",{className:"font-semibold",children:"Previous"})]})})}),le&&a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(F,{name:"delete",variant:"tertiary",size:1,className:"bg-red-50 hover:bg-red-100 text-red-700 border border-red-200 hover:border-red-300",onClick:qe,title:"Delete","aria-label":"Delete saved image",children:a.jsx(na,{className:"w-4 h-4"})})}),a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(F,{name:"contribute",onClick:Qe,children:"Contribute"})}),le&&a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(F,{name:"toggle-star",variant:"tertiary",size:1,className:`${e?.starred?"bg-red-100 hover:bg-red-200 text-red-800 border-2 border-red-400":"bg-gray-100 hover:bg-gray-200 text-gray-600 border-2 border-gray-300"} w-16 h-8 rounded-full transition-all duration-200 flex items-center justify-center`,onClick:Ke,title:e?.starred?"Unstar image":"Star image","aria-label":e?.starred?"Unstar image":"Star image",children:a.jsx("span",{className:`text-lg transition-all duration-200 ${e?.starred?"text-red-600":"text-gray-500"}`,children:e?.starred?"★":"☆"})})}),Te&&a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(F,{name:"next-item",variant:"tertiary",size:1,className:`bg-white/90 hover:bg-white shadow-lg border border-gray-200 ${J?"opacity-50 cursor-not-allowed":"hover:scale-110"}`,onClick:()=>je("next"),disabled:J,children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"font-semibold",children:"Next"}),a.jsxs("div",{className:"flex -space-x-1",children:[a.jsx(re,{className:"w-4 h-4"}),a.jsx(re,{className:"w-4 h-4"})]})]})})})]})})})]}):a.jsxs("div",{className:"text-center py-12",children:[a.jsx("div",{className:"text-xl font-semibold text-gray-600 mb-4",children:"No matches found"}),a.jsx("div",{className:"mt-4",children:a.jsx(F,{name:"clear-filters",variant:"secondary",onClick:Be,children:"Clear Filters"})})]})}):null]}),$e&&a.jsx("div",{className:m.fullSizeModalOverlay,onClick:()=>Z(!1),children:a.jsx("div",{className:m.fullSizeModalContent,onClick:t=>t.stopPropagation(),children:a.jsxs("div",{className:m.ratingWarningContent,children:[a.jsx("h3",{className:m.ratingWarningTitle,children:"Delete Image?"}),a.jsx("p",{className:m.ratingWarningText,children:"This action cannot be undone. Are you sure you want to delete this saved image and all related data?"}),a.jsxs("div",{className:m.ratingWarningButtons,children:[a.jsx(F,{name:"confirm-delete",variant:"secondary",onClick:Ze,children:"Delete"}),a.jsx(F,{name:"cancel-delete",variant:"tertiary",onClick:()=>Z(!1),children:"Cancel"})]})]})})}),fe&&a.jsx(da,{isOpen:fe,onClose:()=>{Q(!1),ie(!1),se(!1)},onExport:(t,i)=>{i.includes(e.image_type)&&Xe(t)},filteredCount:1,totalCount:1,hasFilters:!1,crisisMapsCount:e.image_type==="crisis_map"?1:0,droneImagesCount:e.image_type==="drone_image"?1:0,isLoading:Pe,exportSuccess:Re,variant:"single",onNavigateToList:()=>{Q(!1),y("/explore")},onNavigateAndExport:()=>{Q(!1),y("/explore?export=true")}}),a.jsx(oa,{isOpen:Ae,imageUrl:ze?.image_url||null,preview:null,selectedImageData:null,onClose:He,isLoading:Oe})]})}export{it as default}; diff --git a/py_backend/static/assets/jszip.min-XJUuvkAi.js b/py_backend/static/assets/jszip.min-BeHyG4q9.js similarity index 99% rename from py_backend/static/assets/jszip.min-XJUuvkAi.js rename to py_backend/static/assets/jszip.min-BeHyG4q9.js index d7fd0656..cf6db131 100644 --- a/py_backend/static/assets/jszip.min-XJUuvkAi.js +++ b/py_backend/static/assets/jszip.min-BeHyG4q9.js @@ -1,4 +1,4 @@ -import{V as bt,W as It}from"./index-Dym8TuvV.js";function vt(yt){throw new Error('Could not dynamically require "'+yt+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var kt={exports:{}};/*! +import{V as bt,W as It}from"./index-C5rMGfs8.js";function vt(yt){throw new Error('Could not dynamically require "'+yt+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var kt={exports:{}};/*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files diff --git a/py_backend/static/assets/logo-Cer0qWO3.png b/py_backend/static/assets/logo-Cer0qWO3.png new file mode 100644 index 00000000..fb40fc93 --- /dev/null +++ b/py_backend/static/assets/logo-Cer0qWO3.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fda151715bffc75fa519590ff0b623f5d38571bddc4a53da35a104ce05470208 +size 87190 diff --git a/py_backend/static/assets/logo-DkhILSWp.jpg b/py_backend/static/assets/logo-DkhILSWp.jpg deleted file mode 100644 index 7b514285..00000000 --- a/py_backend/static/assets/logo-DkhILSWp.jpg +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:45d98f276fcd585024dd62e635acd3305f29dc89171f15304913c6d528ba3c3b -size 25732 diff --git a/py_backend/static/assets/useAdmin-DnFl9FMw.js b/py_backend/static/assets/useAdmin-B8fo0TJy.js similarity index 65% rename from py_backend/static/assets/useAdmin-DnFl9FMw.js rename to py_backend/static/assets/useAdmin-B8fo0TJy.js index 41b66342..1f7910ee 100644 --- a/py_backend/static/assets/useAdmin-DnFl9FMw.js +++ b/py_backend/static/assets/useAdmin-B8fo0TJy.js @@ -1 +1 @@ -import{r,T as e}from"./index-Dym8TuvV.js";const o=()=>{const t=r.useContext(e);if(t===void 0)throw new Error("useAdmin must be used within an AdminProvider");return t};export{o as u}; +import{r,T as e}from"./index-C5rMGfs8.js";const o=()=>{const t=r.useContext(e);if(t===void 0)throw new Error("useAdmin must be used within an AdminProvider");return t};export{o as u}; diff --git a/py_backend/static/index.html b/py_backend/static/index.html index f122f285..d2a65c06 100644 --- a/py_backend/static/index.html +++ b/py_backend/static/index.html @@ -42,7 +42,7 @@ }); } - +