SCGR commited on
Commit
99eb145
Β·
1 Parent(s): a0bb0ee

text box fix

Browse files
frontend/src/components/upload/ModalComponents.tsx CHANGED
@@ -180,15 +180,38 @@ interface FallbackNotificationModalProps {
180
  export function FallbackNotificationModal({ isOpen, fallbackInfo, onClose }: FallbackNotificationModalProps) {
181
  if (!isOpen || !fallbackInfo) return null;
182
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  return (
184
  <div className={styles.fullSizeModalOverlay} onClick={onClose}>
185
  <div className={styles.fullSizeModalContent} onClick={(e) => e.stopPropagation()}>
186
  <div className={styles.ratingWarningContent}>
187
- <h3 className={styles.ratingWarningTitle}>Model Changed</h3>
188
  <p className={styles.ratingWarningText}>
189
- {fallbackInfo.originalModel} is currently unavailable.
190
- We've automatically switched to {fallbackInfo.fallbackModel} to complete your request.
191
  </p>
 
 
 
 
192
  <div className={styles.ratingWarningButtons}>
193
  <Button
194
  name="close-fallback"
 
180
  export function FallbackNotificationModal({ isOpen, fallbackInfo, onClose }: FallbackNotificationModalProps) {
181
  if (!isOpen || !fallbackInfo) return null;
182
 
183
+ // Parse the reason to make it more user-friendly
184
+ const parseReason = (reason: string): string => {
185
+ if (reason.includes("quota") || reason.includes("credits")) {
186
+ return "API quota exceeded - you've used up your monthly free credits";
187
+ } else if (reason.includes("rate") || reason.includes("429")) {
188
+ return "Rate limit exceeded - too many requests";
189
+ } else if (reason.includes("loading") || reason.includes("503")) {
190
+ return "Model is currently loading or unavailable";
191
+ } else if (reason.includes("network") || reason.includes("timeout")) {
192
+ return "Network connection issue";
193
+ } else if (reason.includes("MODEL_UNAVAILABLE")) {
194
+ return "Model service is temporarily unavailable";
195
+ } else {
196
+ return reason;
197
+ }
198
+ };
199
+
200
+ const userFriendlyReason = parseReason(fallbackInfo.reason);
201
+
202
  return (
203
  <div className={styles.fullSizeModalOverlay} onClick={onClose}>
204
  <div className={styles.fullSizeModalContent} onClick={(e) => e.stopPropagation()}>
205
  <div className={styles.ratingWarningContent}>
206
+ <h3 className={styles.ratingWarningTitle}>⚠️ Model Changed</h3>
207
  <p className={styles.ratingWarningText}>
208
+ <strong>{fallbackInfo.originalModel}</strong> is currently unavailable.
209
+ We've automatically switched to <strong>{fallbackInfo.fallbackModel}</strong> to complete your request.
210
  </p>
211
+ <div className={styles.fallbackReasonBox}>
212
+ <p className={styles.fallbackReasonTitle}>Reason:</p>
213
+ <p className={styles.fallbackReasonText}>{userFriendlyReason}</p>
214
+ </div>
215
  <div className={styles.ratingWarningButtons}>
216
  <Button
217
  name="close-fallback"
frontend/src/pages/UploadPage/UploadPage.module.css CHANGED
@@ -655,6 +655,30 @@
655
  margin-top: var(--go-ui-spacing-lg);
656
  }
657
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
658
  .preprocessingProgress {
659
  margin-top: var(--go-ui-spacing-lg);
660
  text-align: center;
 
655
  margin-top: var(--go-ui-spacing-lg);
656
  }
657
 
658
+ /* Fallback reason box styles */
659
+ .fallbackReasonBox {
660
+ background-color: var(--go-ui-color-yellow-10);
661
+ border: var(--go-ui-width-separator-thin) solid var(--go-ui-color-yellow-30);
662
+ border-radius: var(--go-ui-border-radius-md);
663
+ padding: var(--go-ui-spacing-md);
664
+ margin: var(--go-ui-spacing-lg) 0;
665
+ text-align: left;
666
+ }
667
+
668
+ .fallbackReasonTitle {
669
+ font-size: var(--go-ui-font-size-sm);
670
+ font-weight: var(--go-ui-font-weight-semibold);
671
+ color: var(--go-ui-color-gray-800);
672
+ margin: 0 0 var(--go-ui-spacing-xs) 0;
673
+ }
674
+
675
+ .fallbackReasonText {
676
+ font-size: var(--go-ui-font-size-sm);
677
+ color: var(--go-ui-color-gray-700);
678
+ margin: 0;
679
+ line-height: 1.5;
680
+ }
681
+
682
  .preprocessingProgress {
683
  margin-top: var(--go-ui-spacing-lg);
684
  text-align: center;
frontend/src/pages/UploadPage/UploadPage.tsx CHANGED
@@ -520,12 +520,18 @@ export default function UploadPage() {
520
 
521
  const capJson = mapJson;
522
 
523
- const fallbackInfo = (capJson.raw_json as Record<string, unknown>)?.fallback_info;
524
- if (fallbackInfo) {
 
 
 
 
 
 
525
  setFallbackInfo({
526
- originalModel: (fallbackInfo as Record<string, unknown>).original_model as string,
527
- fallbackModel: (fallbackInfo as Record<string, unknown>).fallback_model as string,
528
- reason: (fallbackInfo as Record<string, unknown>).reason as string
529
  });
530
  setShowFallbackNotification(true);
531
  }
@@ -646,7 +652,8 @@ export default function UploadPage() {
646
  }
647
  }
648
 
649
- const extractedMetadataForParts = (capJson.raw_json as Record<string, unknown>)?.parsed;
 
650
  if (extractedMetadataForParts) {
651
  if ((extractedMetadataForParts as Record<string, unknown>).description) {
652
  setDescription((extractedMetadataForParts as Record<string, unknown>).description as string);
 
520
 
521
  const capJson = mapJson;
522
 
523
+ // Check for fallback information in the response
524
+ const rawJson = capJson.raw_json as Record<string, unknown>;
525
+ const fallbackUsed = rawJson?.fallback_used;
526
+ const originalModel = rawJson?.original_model as string;
527
+ const fallbackReason = rawJson?.fallback_reason as string;
528
+ const currentModel = capJson.model as string;
529
+
530
+ if (fallbackUsed && originalModel && fallbackReason) {
531
  setFallbackInfo({
532
+ originalModel: originalModel,
533
+ fallbackModel: currentModel,
534
+ reason: fallbackReason
535
  });
536
  setShowFallbackNotification(true);
537
  }
 
652
  }
653
  }
654
 
655
+ // Extract the three parts from the metadata
656
+ const extractedMetadataForParts = (capJson.raw_json as Record<string, unknown>)?.metadata;
657
  if (extractedMetadataForParts) {
658
  if ((extractedMetadataForParts as Record<string, unknown>).description) {
659
  setDescription((extractedMetadataForParts as Record<string, unknown>).description as string);
py_backend/app/routers/upload.py CHANGED
@@ -687,6 +687,14 @@ async def upload_image(
687
 
688
  actual_model = result.get("model", model_name)
689
 
 
 
 
 
 
 
 
 
690
  final_model_name = actual_model if actual_model != "random" else "STUB_MODEL"
691
 
692
  caption = crud.create_caption(
@@ -847,6 +855,14 @@ async def upload_multiple_images(
847
  # Use the actual model that was used by the VLM service
848
  actual_model = result.get("model", model_name)
849
 
 
 
 
 
 
 
 
 
850
  # Update individual image metadata if VLM provided it
851
  metadata_images = metadata.get("metadata_images", {})
852
  if metadata_images and isinstance(metadata_images, dict):
 
687
 
688
  actual_model = result.get("model", model_name)
689
 
690
+ # Include fallback information in raw_json if fallback occurred
691
+ if result.get("fallback_used"):
692
+ raw.update({
693
+ "fallback_used": result.get("fallback_used"),
694
+ "original_model": result.get("original_model"),
695
+ "fallback_reason": result.get("fallback_reason")
696
+ })
697
+
698
  final_model_name = actual_model if actual_model != "random" else "STUB_MODEL"
699
 
700
  caption = crud.create_caption(
 
855
  # Use the actual model that was used by the VLM service
856
  actual_model = result.get("model", model_name)
857
 
858
+ # Include fallback information in raw_json if fallback occurred
859
+ if result.get("fallback_used"):
860
+ raw.update({
861
+ "fallback_used": result.get("fallback_used"),
862
+ "original_model": result.get("original_model"),
863
+ "fallback_reason": result.get("fallback_reason")
864
+ })
865
+
866
  # Update individual image metadata if VLM provided it
867
  metadata_images = metadata.get("metadata_images", {})
868
  if metadata_images and isinstance(metadata_images, dict):
py_backend/static/assets/{AdminPage-BCP8tiOG.js β†’ AdminPage-CUXsutM0.js} RENAMED
@@ -1,4 +1,4 @@
1
- import{r as t,j as a,N as G,H as He,O as m,z as j,I as te,_ as Je,n as d,J as f}from"./index-Crh8pvny.js";import{u as Ge}from"./useAdmin-D6C-qshi.js";const Ve="_adminContainer_j11pf_5",We="_adminHeader_j11pf_13",qe="_adminSection_j11pf_20",Ke="_modelSelectionArea_j11pf_29",Ye="_modelSelectionRow_j11pf_36",Qe="_modelsTable_j11pf_89",Xe="_promptSubsection_j11pf_97",Ze="_promptSubsectionTitle_j11pf_109",ea="_modelCode_j11pf_152",aa="_modelId_j11pf_157",la="_modelActions_j11pf_163",sa="_addModelButtonContainer_j11pf_169",oa="_addModelForm_j11pf_177",ta="_addModelFormTitle_j11pf_185",da="_addModelFormGrid_j11pf_193",ia="_addModelFormField_j11pf_206",na="_addModelFormCheckbox_j11pf_250",ca="_addModelFormActions_j11pf_268",ra="_modalOverlay_j11pf_277",ma="_modalContent_j11pf_291",ha="_modalBody_j11pf_302",pa="_modalTitle_j11pf_312",xa="_modalText_j11pf_320",_a="_modalTextLeft_j11pf_332",ja="_modalButtons_j11pf_355",va="_modalForm_j11pf_363",ua="_formField_j11pf_372",ga="_formLabel_j11pf_376",fa="_formInput_j11pf_385",ba="_textarea_j11pf_407",l={adminContainer:Ve,adminHeader:We,adminSection:qe,modelSelectionArea:Ke,modelSelectionRow:Ye,modelsTable:Qe,promptSubsection:Xe,promptSubsectionTitle:Ze,modelCode:ea,modelId:aa,modelActions:la,addModelButtonContainer:sa,addModelForm:oa,addModelFormTitle:ta,addModelFormGrid:da,addModelFormField:ia,addModelFormCheckbox:na,addModelFormActions:ca,modalOverlay:ra,modalContent:ma,modalBody:ha,modalTitle:pa,modalText:xa,modalTextLeft:_a,modalButtons:ja,modalForm:va,formField:ua,formLabel:ga,formInput:fa,textarea:ba},w="selectedVlmModel";function Ca(){const{isAuthenticated:F,isLoading:de,login:ie,logout:ne}=Ge(),[T,V]=t.useState(""),[W,v]=t.useState(""),[q,K]=t.useState(!1),[A,Y]=t.useState([]),[ce,b]=t.useState(""),[re,I]=t.useState(""),[Q,me]=t.useState([]),[he,pe]=t.useState([]),[xe,_e]=t.useState([]),[je,y]=t.useState(!1),[$,P]=t.useState(null),[L,u]=t.useState({schema_id:"",title:"",version:"",schema:{}}),[ve,N]=t.useState(!1),[ue,C]=t.useState(!1),[ge,E]=t.useState(null),[S,B]=t.useState(null),[n,c]=t.useState({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1}),[X,O]=t.useState(!1),[fe,D]=t.useState(!1),[U,z]=t.useState(null),[o,r]=t.useState({m_code:"",label:"",model_type:"custom",provider:"huggingface",model_id:"",is_available:!1,is_fallback:!1}),[be,M]=t.useState(!1),[ye,R]=t.useState(!1),[Ne,p]=t.useState(!1),[Z,ee]=t.useState(""),[Ce,Se]=t.useState(""),[Me,x]=t.useState(""),[ke,k]=t.useState(""),_=t.useCallback(()=>{fetch("/api/models").then(e=>e.json()).then(e=>{console.log("Models data received:",e),Y(e.models||[]);const s=localStorage.getItem(w);if(e.models&&e.models.length>0)if(s==="random")b("random");else if(s&&e.models.find(i=>i.m_code===s&&i.is_available))b(s);else{const i=e.models.find(h=>h.is_available)||e.models[0];b(i.m_code),localStorage.setItem(w,i.m_code)}}).catch(()=>{}),fetch("/api/admin/fallback-model",{headers:{Authorization:`Bearer ${localStorage.getItem("adminToken")}`}}).then(e=>e.json()).then(e=>{console.log("Fallback model data received:",e),e.fallback_model?I(e.fallback_model.m_code):I("")}).catch(()=>{})},[]),g=t.useCallback(()=>{console.log("=== fetchPrompts called ==="),fetch("/api/prompts").then(e=>e.json()).then(e=>{console.log("Prompts data received:",e),me(e||[]),console.log("State update triggered with:",e||[])}).catch(e=>{console.error("Error fetching prompts:",e)})},[]),ae=t.useCallback(()=>{fetch("/api/image-types").then(e=>e.json()).then(e=>{console.log("Image types data received:",e),pe(e||[])}).catch(()=>{})},[]),H=t.useCallback(()=>{console.log("=== fetchSchemas called ==="),fetch("/api/schemas",{headers:{Authorization:`Bearer ${localStorage.getItem("adminToken")}`}}).then(e=>e.json()).then(e=>{console.log("Schemas data received:",e),_e(e||[])}).catch(e=>{console.error("Error fetching schemas:",e)})},[]);t.useEffect(()=>{F&&(_(),g(),ae(),H())},[F,_,g,ae,H]);const le=e=>{B(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}),N(!0)},we=async()=>{try{if(!S){alert("No prompt selected for editing");return}const e=await fetch(`/api/prompts/${S.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)g(),N(!1),B(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")}},se=async(e,s)=>{try{const i=await fetch(`/api/prompts/${e}/toggle-active?image_type=${s}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(i.ok)g();else{const h=await i.json();alert(`Failed to toggle prompt active status: ${h.detail||"Unknown error"}`)}}catch{alert("Error toggling prompt active status")}},oe=e=>{E(e),c({p_code:"",label:"",metadata_instructions:"",image_type:e,is_active:!1}),C(!0)},Fe=async()=>{try{const e=await fetch("/api/prompts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(e.ok)g(),C(!1),E(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")}},Te=e=>{P(e),u({schema_id:e.schema_id,title:e.title,version:e.version,schema:e.schema}),y(!0)},Ae=async()=>{try{if(!$){alert("No schema selected for editing");return}const e=await fetch(`/api/schemas/${$.schema_id}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("adminToken")}`},body:JSON.stringify(L)});if(e.ok)H(),y(!1),P(null),u({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=()=>{y(!1),P(null),u({schema_id:"",title:"",version:"",schema:{}})},$e=async(e,s)=>{try{const i=await fetch(`/api/models/${e}/toggle`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({is_available:!s})});if(i.ok)Y(h=>h.map(J=>J.m_code===e?{...J,is_available:!s}:J));else{const h=await i.json();alert(`Failed to toggle model availability: ${h.error||"Unknown error"}`)}}catch{alert("Error toggling model availability")}},Pe=e=>{b(e),e==="random"?localStorage.setItem(w,"random"):localStorage.setItem(w,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)I(e),_();else{const i=await s.json();alert(`Failed to set fallback model: ${i.detail||"Unknown error"}`)}}catch{alert("Error setting fallback model")}},Ee=async()=>{try{const e=await fetch("/api/admin/models",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("adminToken")}`},body:JSON.stringify(o)});if(e.ok){const s=`
2
  Model "${o.label}" added successfully!
3
 
4
  ⚠️ IMPORTANT: Model will NOT work until you complete these steps:
 
1
+ import{r as t,j as a,N as G,H as He,O as m,z as j,I as te,_ as Je,n as d,J as f}from"./index-DkcyG4dA.js";import{u as Ge}from"./useAdmin-oKoxa8h9.js";const Ve="_adminContainer_j11pf_5",We="_adminHeader_j11pf_13",qe="_adminSection_j11pf_20",Ke="_modelSelectionArea_j11pf_29",Ye="_modelSelectionRow_j11pf_36",Qe="_modelsTable_j11pf_89",Xe="_promptSubsection_j11pf_97",Ze="_promptSubsectionTitle_j11pf_109",ea="_modelCode_j11pf_152",aa="_modelId_j11pf_157",la="_modelActions_j11pf_163",sa="_addModelButtonContainer_j11pf_169",oa="_addModelForm_j11pf_177",ta="_addModelFormTitle_j11pf_185",da="_addModelFormGrid_j11pf_193",ia="_addModelFormField_j11pf_206",na="_addModelFormCheckbox_j11pf_250",ca="_addModelFormActions_j11pf_268",ra="_modalOverlay_j11pf_277",ma="_modalContent_j11pf_291",ha="_modalBody_j11pf_302",pa="_modalTitle_j11pf_312",xa="_modalText_j11pf_320",_a="_modalTextLeft_j11pf_332",ja="_modalButtons_j11pf_355",va="_modalForm_j11pf_363",ua="_formField_j11pf_372",ga="_formLabel_j11pf_376",fa="_formInput_j11pf_385",ba="_textarea_j11pf_407",l={adminContainer:Ve,adminHeader:We,adminSection:qe,modelSelectionArea:Ke,modelSelectionRow:Ye,modelsTable:Qe,promptSubsection:Xe,promptSubsectionTitle:Ze,modelCode:ea,modelId:aa,modelActions:la,addModelButtonContainer:sa,addModelForm:oa,addModelFormTitle:ta,addModelFormGrid:da,addModelFormField:ia,addModelFormCheckbox:na,addModelFormActions:ca,modalOverlay:ra,modalContent:ma,modalBody:ha,modalTitle:pa,modalText:xa,modalTextLeft:_a,modalButtons:ja,modalForm:va,formField:ua,formLabel:ga,formInput:fa,textarea:ba},w="selectedVlmModel";function Ca(){const{isAuthenticated:F,isLoading:de,login:ie,logout:ne}=Ge(),[T,V]=t.useState(""),[W,v]=t.useState(""),[q,K]=t.useState(!1),[A,Y]=t.useState([]),[ce,b]=t.useState(""),[re,I]=t.useState(""),[Q,me]=t.useState([]),[he,pe]=t.useState([]),[xe,_e]=t.useState([]),[je,y]=t.useState(!1),[$,P]=t.useState(null),[L,u]=t.useState({schema_id:"",title:"",version:"",schema:{}}),[ve,N]=t.useState(!1),[ue,C]=t.useState(!1),[ge,E]=t.useState(null),[S,B]=t.useState(null),[n,c]=t.useState({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1}),[X,O]=t.useState(!1),[fe,D]=t.useState(!1),[U,z]=t.useState(null),[o,r]=t.useState({m_code:"",label:"",model_type:"custom",provider:"huggingface",model_id:"",is_available:!1,is_fallback:!1}),[be,M]=t.useState(!1),[ye,R]=t.useState(!1),[Ne,p]=t.useState(!1),[Z,ee]=t.useState(""),[Ce,Se]=t.useState(""),[Me,x]=t.useState(""),[ke,k]=t.useState(""),_=t.useCallback(()=>{fetch("/api/models").then(e=>e.json()).then(e=>{console.log("Models data received:",e),Y(e.models||[]);const s=localStorage.getItem(w);if(e.models&&e.models.length>0)if(s==="random")b("random");else if(s&&e.models.find(i=>i.m_code===s&&i.is_available))b(s);else{const i=e.models.find(h=>h.is_available)||e.models[0];b(i.m_code),localStorage.setItem(w,i.m_code)}}).catch(()=>{}),fetch("/api/admin/fallback-model",{headers:{Authorization:`Bearer ${localStorage.getItem("adminToken")}`}}).then(e=>e.json()).then(e=>{console.log("Fallback model data received:",e),e.fallback_model?I(e.fallback_model.m_code):I("")}).catch(()=>{})},[]),g=t.useCallback(()=>{console.log("=== fetchPrompts called ==="),fetch("/api/prompts").then(e=>e.json()).then(e=>{console.log("Prompts data received:",e),me(e||[]),console.log("State update triggered with:",e||[])}).catch(e=>{console.error("Error fetching prompts:",e)})},[]),ae=t.useCallback(()=>{fetch("/api/image-types").then(e=>e.json()).then(e=>{console.log("Image types data received:",e),pe(e||[])}).catch(()=>{})},[]),H=t.useCallback(()=>{console.log("=== fetchSchemas called ==="),fetch("/api/schemas",{headers:{Authorization:`Bearer ${localStorage.getItem("adminToken")}`}}).then(e=>e.json()).then(e=>{console.log("Schemas data received:",e),_e(e||[])}).catch(e=>{console.error("Error fetching schemas:",e)})},[]);t.useEffect(()=>{F&&(_(),g(),ae(),H())},[F,_,g,ae,H]);const le=e=>{B(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}),N(!0)},we=async()=>{try{if(!S){alert("No prompt selected for editing");return}const e=await fetch(`/api/prompts/${S.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)g(),N(!1),B(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")}},se=async(e,s)=>{try{const i=await fetch(`/api/prompts/${e}/toggle-active?image_type=${s}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(i.ok)g();else{const h=await i.json();alert(`Failed to toggle prompt active status: ${h.detail||"Unknown error"}`)}}catch{alert("Error toggling prompt active status")}},oe=e=>{E(e),c({p_code:"",label:"",metadata_instructions:"",image_type:e,is_active:!1}),C(!0)},Fe=async()=>{try{const e=await fetch("/api/prompts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(e.ok)g(),C(!1),E(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")}},Te=e=>{P(e),u({schema_id:e.schema_id,title:e.title,version:e.version,schema:e.schema}),y(!0)},Ae=async()=>{try{if(!$){alert("No schema selected for editing");return}const e=await fetch(`/api/schemas/${$.schema_id}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("adminToken")}`},body:JSON.stringify(L)});if(e.ok)H(),y(!1),P(null),u({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=()=>{y(!1),P(null),u({schema_id:"",title:"",version:"",schema:{}})},$e=async(e,s)=>{try{const i=await fetch(`/api/models/${e}/toggle`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({is_available:!s})});if(i.ok)Y(h=>h.map(J=>J.m_code===e?{...J,is_available:!s}:J));else{const h=await i.json();alert(`Failed to toggle model availability: ${h.error||"Unknown error"}`)}}catch{alert("Error toggling model availability")}},Pe=e=>{b(e),e==="random"?localStorage.setItem(w,"random"):localStorage.setItem(w,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)I(e),_();else{const i=await s.json();alert(`Failed to set fallback model: ${i.detail||"Unknown error"}`)}}catch{alert("Error setting fallback model")}},Ee=async()=>{try{const e=await fetch("/api/admin/models",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("adminToken")}`},body:JSON.stringify(o)});if(e.ok){const s=`
2
  Model "${o.label}" added successfully!
3
 
4
  ⚠️ IMPORTANT: Model will NOT work until you complete these steps:
py_backend/static/assets/{ExportModal-C2zShiT5.js β†’ ExportModal-B-0g2PYD.js} RENAMED
@@ -1 +1 @@
1
- import{r as n,j as e,P as V,S as A,o as O,T as H,D as q,z as b,n as v,O as D,J as F,V as G,_ as B,L as R}from"./index-Crh8pvny.js";const $=({title:c,titleId:i,...r})=>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":i},r),c?n.createElement("title",{id:i},c):null,n.createElement("g",{clipPath:"url(#checkbox-indeterminate-line_svg__a)"},n.createElement("path",{d:"M4 3h16a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Zm1 2v14h14V5H5Zm2 6h10v2H7v-2Z"})),n.createElement("defs",null,n.createElement("clipPath",{id:"checkbox-indeterminate-line_svg__a"},n.createElement("path",{d:"M0 0h24v24H0z"})))),U=({title:c,titleId:i,...r})=>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":i},r),c?n.createElement("title",{id:i},c):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 Z(c){const{className:i,indeterminate:r,value:j}=c;return e.jsxs(e.Fragment,{children:[r&&e.jsx($,{className:i}),j&&!r&&e.jsx(V,{className:i}),!j&&!r&&e.jsx(A,{className:i})]})}const Y="_checkbox_12g7n_1",J="_with-background_12g7n_7",K="_checkmark-container_12g7n_12",Q="_input_12g7n_18",X="_content_12g7n_33",L="_description_12g7n_40",ee="_checked_12g7n_45",ae="_checkmark_12g7n_12",le="_disabled-checkbox_12g7n_58",h={checkbox:Y,withBackground:J,checkmarkContainer:K,input:Q,content:X,description:L,checked:ee,checkmark:ae,disabledCheckbox:le};function P(c){const{className:i,checkmark:r=Z,checkmarkClassName:j,checkmarkContainerClassName:z,disabled:s,error:x,indeterminate:k,inputClassName:I,invertedLogic:p=!1,label:_,labelContainerClassName:f,name:E,onChange:C,readOnly:u,tooltip:S,value:N,description:g,withBackground:T,...w}=c,M=n.useCallback(t=>{const o=t.currentTarget.checked;C(p?!o:o,E)},[E,C,p]),y=p?!N:N,m=O(h.checkbox,i,!k&&y&&h.checked,T&&h.withBackground,s&&h.disabledCheckbox,u&&h.readOnly);return e.jsxs("label",{className:m,title:S,children:[e.jsxs("div",{className:O(h.checkmarkContainer,z),children:[e.jsx("input",{onChange:M,className:O(h.input,I),type:"checkbox",checked:y??!1,disabled:s||u,readOnly:u,...w}),e.jsx(r,{className:O(h.checkmark,j),value:y??!1,indeterminate:k,"aria-hidden":"true"})]}),(_||g)&&e.jsxs("div",{className:h.content,children:[_&&e.jsx("div",{className:f,children:_}),g&&e.jsx("div",{className:h.description,children:g})]}),x&&e.jsx(H,{children:x})]})}function Ce({sources:c,types:i,regions:r,countries:j,imageTypes:z,isLoadingFilters:s=!1}){const[x,k]=n.useState(!1),[I,p]=n.useState(""),{search:_,setSearch:f,srcFilter:E,setSrcFilter:C,catFilter:u,setCatFilter:S,regionFilter:N,setRegionFilter:g,countryFilter:T,setCountryFilter:w,imageTypeFilter:M,setImageTypeFilter:y,uploadTypeFilter:m,setUploadTypeFilter:t,showReferenceExamples:o,setShowReferenceExamples:d,clearAllFilters:W}=q();return n.useEffect(()=>{p(_)},[_]),e.jsxs("div",{className:"mb-6 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:e.jsx(v,{name:"toggle-filters",variant:"secondary",onClick:()=>k(!x),className:"whitespace-nowrap",title:x?"Hide Filters":"Show Filters",children:e.jsx(U,{className:"w-4 h-4"})})}),e.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2 flex-1 min-w-[300px]",children:e.jsx(D,{name:"search",placeholder:"Search",value:I,onChange:a=>p(a||""),onKeyDown:a=>{a.key==="Enter"&&f(I)}})}),e.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:e.jsx(v,{name:"clear-filters",variant:"secondary",onClick:W,children:"Clear Filters"})})]}),x&&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(b,{withInternalPadding:!0,className:"p-2",children:e.jsx(F,{name:"source",placeholder:s?"Loading...":"All Sources",options:c,value:E||null,onChange:a=>C(a||""),keySelector:a=>a.s_code,labelSelector:a=>a.label,required:!1,disabled:s})}),e.jsx(b,{withInternalPadding:!0,className:"p-2",children:e.jsx(F,{name:"category",placeholder:s?"Loading...":"All Categories",options:i,value:u||null,onChange:a=>S(a||""),keySelector:a=>a.t_code,labelSelector:a=>a.label,required:!1,disabled:s})}),e.jsx(b,{withInternalPadding:!0,className:"p-2",children:e.jsx(F,{name:"region",placeholder:s?"Loading...":"All Regions",options:r,value:N||null,onChange:a=>g(a||""),keySelector:a=>a.r_code,labelSelector:a=>a.label,required:!1,disabled:s})}),e.jsx(b,{withInternalPadding:!0,className:"p-2",children:e.jsx(G,{name:"country",placeholder:s?"Loading...":"All Countries",options:j,value:T?[T]:[],onChange:a=>w(a[0]||""),keySelector:a=>a.c_code,labelSelector:a=>a.label,disabled:s})}),e.jsx(b,{withInternalPadding:!0,className:"p-2",children:e.jsx(F,{name:"imageType",placeholder:s?"Loading...":"All Image Types",options:z,value:M||null,onChange:a=>y(a||""),keySelector:a=>a.image_type,labelSelector:a=>a.label,required:!1,disabled:s})}),e.jsx(b,{withInternalPadding:!0,className:"p-2",children:e.jsx(F,{name:"uploadType",placeholder:"All Upload Types",options:[{key:"single",label:"Single Upload"},{key:"multiple",label:"Multiple Upload"}],value:m||null,onChange:a=>t(a||""),keySelector:a=>a.key,labelSelector:a=>a.label,required:!1,disabled:!1})})]})})]})}const te="_fullSizeModalOverlay_cyz3b_1",se="_fullSizeModalContent_cyz3b_29",ne="_ratingWarningContent_cyz3b_53",ie="_ratingWarningTitle_cyz3b_65",re="_exportModeSection_cyz3b_133",ce="_splitConfigSection_cyz3b_143",oe="_splitConfigTitle_cyz3b_153",de="_splitInputsContainer_cyz3b_167",pe="_splitInputGroup_cyz3b_183",me="_splitInputLabel_cyz3b_197",he="_splitInput_cyz3b_167",xe="_splitTotal_cyz3b_247",ue="_splitTotalError_cyz3b_261",ge="_checkboxesContainer_cyz3b_271",be="_ratingWarningButtons_cyz3b_289",ve="_singleExportMessage_cyz3b_309",je="_navigateButtonContainer_cyz3b_333",_e="_loadingOverlay_cyz3b_349",l={fullSizeModalOverlay:te,fullSizeModalContent:se,ratingWarningContent:ne,ratingWarningTitle:ie,exportModeSection:re,splitConfigSection:ce,splitConfigTitle:oe,splitInputsContainer:de,splitInputGroup:pe,splitInputLabel:me,splitInput:he,splitTotal:xe,splitTotalError:ue,checkboxesContainer:ge,ratingWarningButtons:be,singleExportMessage:ve,navigateButtonContainer:je,loadingOverlay:_e};function Ne({isOpen:c,onClose:i,onExport:r,crisisMapsCount:j,droneImagesCount:z,isLoading:s=!1,exportSuccess:x=!1,variant:k="bulk",onNavigateAndExport:I}){const[p,_]=n.useState("standard"),[f,E]=n.useState(80),[C,u]=n.useState(10),[S,N]=n.useState(10),[g,T]=n.useState(!0),[w,M]=n.useState(!0),y=()=>{if(k==="single"){r(p,["crisis_map","drone_image"]);return}if(!g&&!w){alert("Please select at least one image type to export.");return}const t=[];g&&t.push("crisis_map"),w&&t.push("drone_image"),r(p,t)},m=()=>{i()};return c?k==="single"?e.jsx("div",{className:l.fullSizeModalOverlay,onClick:m,children:e.jsxs("div",{className:l.fullSizeModalContent,onClick:t=>t.stopPropagation(),children:[s&&e.jsx("div",{className:l.loadingOverlay,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(B,{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"})]})}),x&&e.jsx("div",{className:l.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(v,{name:"close-export-success",onClick:m,className:"mt-4",children:"Close"})]})}),e.jsxs("div",{className:l.ratingWarningContent,children:[e.jsx("h3",{className:l.ratingWarningTitle,children:"Export Single Item"}),e.jsxs("div",{className:l.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:l.navigateButtonContainer,children:e.jsx(v,{name:"navigate-to-list",variant:"secondary",onClick:I,children:"Navigate to List View"})}),e.jsxs("div",{className:l.ratingWarningButtons,children:[e.jsx(v,{name:"continue-export",onClick:y,disabled:s,children:s?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"text-white"}),"Exporting..."]}):"Continue"}),e.jsx(v,{name:"cancel-export",variant:"tertiary",onClick:m,disabled:s,children:"Cancel"})]})]})]})}):e.jsx("div",{className:l.fullSizeModalOverlay,onClick:m,children:e.jsxs("div",{className:l.fullSizeModalContent,onClick:t=>t.stopPropagation(),children:[s&&e.jsx("div",{className:l.loadingOverlay,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(B,{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"})]})}),x&&e.jsx("div",{className:l.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(v,{name:"close-export-success",onClick:m,className:"mt-4",children:"Close"})]})}),e.jsxs("div",{className:l.ratingWarningContent,children:[e.jsx("h3",{className:l.ratingWarningTitle,children:"Export Dataset"}),e.jsx("div",{className:l.exportModeSection,children:e.jsx(R,{name:"export-mode",value:p,onChange:t=>{(t==="standard"||t==="fine-tuning")&&_(t)},options:[{key:"standard",label:"Standard"},{key:"fine-tuning",label:"Fine-tuning"}],keySelector:t=>t.key,labelSelector:t=>t.label,disabled:s})}),p==="fine-tuning"&&e.jsxs("div",{className:l.splitConfigSection,children:[e.jsx("div",{className:l.splitConfigTitle,children:"Dataset Split Configuration"}),e.jsxs("div",{className:l.splitInputsContainer,children:[e.jsxs("div",{className:l.splitInputGroup,children:[e.jsx("label",{htmlFor:"train-split",className:l.splitInputLabel,children:"Train (%)"}),e.jsx("input",{id:"train-split",type:"number",min:"0",max:"100",value:f,onChange:t=>{const o=parseInt(t.target.value)||0,d=100-o;d>=0&&(E(o),C+S>d&&(u(Math.floor(d/2)),N(d-Math.floor(d/2))))},className:l.splitInput,disabled:s})]}),e.jsxs("div",{className:l.splitInputGroup,children:[e.jsx("label",{htmlFor:"test-split",className:l.splitInputLabel,children:"Test (%)"}),e.jsx("input",{id:"test-split",type:"number",min:"0",max:"100",value:C,onChange:t=>{const o=parseInt(t.target.value)||0,d=100-f-o;d>=0&&(u(o),N(d))},className:l.splitInput,disabled:s})]}),e.jsxs("div",{className:l.splitInputGroup,children:[e.jsx("label",{htmlFor:"val-split",className:l.splitInputLabel,children:"Val (%)"}),e.jsx("input",{id:"val-split",type:"number",min:"0",max:"100",value:S,onChange:t=>{const o=parseInt(t.target.value)||0,d=100-f-o;d>=0&&(N(o),u(d))},className:l.splitInput,disabled:s})]})]}),f+C+S!==100&&e.jsx("div",{className:l.splitTotal,children:e.jsx("span",{className:l.splitTotalError,children:"Must equal 100%"})})]}),e.jsxs("div",{className:l.checkboxesContainer,children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(P,{name:"crisis-maps",label:`Crisis Maps (${j} images)`,value:g,onChange:t=>T(t),disabled:s})}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(P,{name:"drone-images",label:`Drone Images (${z} images)`,value:w,onChange:t=>M(t),disabled:s})})]}),e.jsxs("div",{className:l.ratingWarningButtons,children:[e.jsx(v,{name:"confirm-export",onClick:y,disabled:s,children:s?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"text-white"}),"Exporting..."]}):"Export Selected"}),e.jsx(v,{name:"cancel-export",variant:"tertiary",onClick:m,disabled:s,children:"Cancel"})]})]})]})}):null}export{Ne as E,Ce as F};
 
1
+ import{r as n,j as e,P as V,S as A,o as O,T as H,D as q,z as b,n as v,O as D,J as F,V as G,_ as B,L as R}from"./index-DkcyG4dA.js";const $=({title:c,titleId:i,...r})=>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":i},r),c?n.createElement("title",{id:i},c):null,n.createElement("g",{clipPath:"url(#checkbox-indeterminate-line_svg__a)"},n.createElement("path",{d:"M4 3h16a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Zm1 2v14h14V5H5Zm2 6h10v2H7v-2Z"})),n.createElement("defs",null,n.createElement("clipPath",{id:"checkbox-indeterminate-line_svg__a"},n.createElement("path",{d:"M0 0h24v24H0z"})))),U=({title:c,titleId:i,...r})=>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":i},r),c?n.createElement("title",{id:i},c):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 Z(c){const{className:i,indeterminate:r,value:j}=c;return e.jsxs(e.Fragment,{children:[r&&e.jsx($,{className:i}),j&&!r&&e.jsx(V,{className:i}),!j&&!r&&e.jsx(A,{className:i})]})}const Y="_checkbox_12g7n_1",J="_with-background_12g7n_7",K="_checkmark-container_12g7n_12",Q="_input_12g7n_18",X="_content_12g7n_33",L="_description_12g7n_40",ee="_checked_12g7n_45",ae="_checkmark_12g7n_12",le="_disabled-checkbox_12g7n_58",h={checkbox:Y,withBackground:J,checkmarkContainer:K,input:Q,content:X,description:L,checked:ee,checkmark:ae,disabledCheckbox:le};function P(c){const{className:i,checkmark:r=Z,checkmarkClassName:j,checkmarkContainerClassName:z,disabled:s,error:x,indeterminate:k,inputClassName:I,invertedLogic:p=!1,label:_,labelContainerClassName:f,name:E,onChange:C,readOnly:u,tooltip:S,value:N,description:g,withBackground:T,...w}=c,M=n.useCallback(t=>{const o=t.currentTarget.checked;C(p?!o:o,E)},[E,C,p]),y=p?!N:N,m=O(h.checkbox,i,!k&&y&&h.checked,T&&h.withBackground,s&&h.disabledCheckbox,u&&h.readOnly);return e.jsxs("label",{className:m,title:S,children:[e.jsxs("div",{className:O(h.checkmarkContainer,z),children:[e.jsx("input",{onChange:M,className:O(h.input,I),type:"checkbox",checked:y??!1,disabled:s||u,readOnly:u,...w}),e.jsx(r,{className:O(h.checkmark,j),value:y??!1,indeterminate:k,"aria-hidden":"true"})]}),(_||g)&&e.jsxs("div",{className:h.content,children:[_&&e.jsx("div",{className:f,children:_}),g&&e.jsx("div",{className:h.description,children:g})]}),x&&e.jsx(H,{children:x})]})}function Ce({sources:c,types:i,regions:r,countries:j,imageTypes:z,isLoadingFilters:s=!1}){const[x,k]=n.useState(!1),[I,p]=n.useState(""),{search:_,setSearch:f,srcFilter:E,setSrcFilter:C,catFilter:u,setCatFilter:S,regionFilter:N,setRegionFilter:g,countryFilter:T,setCountryFilter:w,imageTypeFilter:M,setImageTypeFilter:y,uploadTypeFilter:m,setUploadTypeFilter:t,showReferenceExamples:o,setShowReferenceExamples:d,clearAllFilters:W}=q();return n.useEffect(()=>{p(_)},[_]),e.jsxs("div",{className:"mb-6 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:e.jsx(v,{name:"toggle-filters",variant:"secondary",onClick:()=>k(!x),className:"whitespace-nowrap",title:x?"Hide Filters":"Show Filters",children:e.jsx(U,{className:"w-4 h-4"})})}),e.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2 flex-1 min-w-[300px]",children:e.jsx(D,{name:"search",placeholder:"Search",value:I,onChange:a=>p(a||""),onKeyDown:a=>{a.key==="Enter"&&f(I)}})}),e.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:e.jsx(v,{name:"clear-filters",variant:"secondary",onClick:W,children:"Clear Filters"})})]}),x&&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(b,{withInternalPadding:!0,className:"p-2",children:e.jsx(F,{name:"source",placeholder:s?"Loading...":"All Sources",options:c,value:E||null,onChange:a=>C(a||""),keySelector:a=>a.s_code,labelSelector:a=>a.label,required:!1,disabled:s})}),e.jsx(b,{withInternalPadding:!0,className:"p-2",children:e.jsx(F,{name:"category",placeholder:s?"Loading...":"All Categories",options:i,value:u||null,onChange:a=>S(a||""),keySelector:a=>a.t_code,labelSelector:a=>a.label,required:!1,disabled:s})}),e.jsx(b,{withInternalPadding:!0,className:"p-2",children:e.jsx(F,{name:"region",placeholder:s?"Loading...":"All Regions",options:r,value:N||null,onChange:a=>g(a||""),keySelector:a=>a.r_code,labelSelector:a=>a.label,required:!1,disabled:s})}),e.jsx(b,{withInternalPadding:!0,className:"p-2",children:e.jsx(G,{name:"country",placeholder:s?"Loading...":"All Countries",options:j,value:T?[T]:[],onChange:a=>w(a[0]||""),keySelector:a=>a.c_code,labelSelector:a=>a.label,disabled:s})}),e.jsx(b,{withInternalPadding:!0,className:"p-2",children:e.jsx(F,{name:"imageType",placeholder:s?"Loading...":"All Image Types",options:z,value:M||null,onChange:a=>y(a||""),keySelector:a=>a.image_type,labelSelector:a=>a.label,required:!1,disabled:s})}),e.jsx(b,{withInternalPadding:!0,className:"p-2",children:e.jsx(F,{name:"uploadType",placeholder:"All Upload Types",options:[{key:"single",label:"Single Upload"},{key:"multiple",label:"Multiple Upload"}],value:m||null,onChange:a=>t(a||""),keySelector:a=>a.key,labelSelector:a=>a.label,required:!1,disabled:!1})})]})})]})}const te="_fullSizeModalOverlay_cyz3b_1",se="_fullSizeModalContent_cyz3b_29",ne="_ratingWarningContent_cyz3b_53",ie="_ratingWarningTitle_cyz3b_65",re="_exportModeSection_cyz3b_133",ce="_splitConfigSection_cyz3b_143",oe="_splitConfigTitle_cyz3b_153",de="_splitInputsContainer_cyz3b_167",pe="_splitInputGroup_cyz3b_183",me="_splitInputLabel_cyz3b_197",he="_splitInput_cyz3b_167",xe="_splitTotal_cyz3b_247",ue="_splitTotalError_cyz3b_261",ge="_checkboxesContainer_cyz3b_271",be="_ratingWarningButtons_cyz3b_289",ve="_singleExportMessage_cyz3b_309",je="_navigateButtonContainer_cyz3b_333",_e="_loadingOverlay_cyz3b_349",l={fullSizeModalOverlay:te,fullSizeModalContent:se,ratingWarningContent:ne,ratingWarningTitle:ie,exportModeSection:re,splitConfigSection:ce,splitConfigTitle:oe,splitInputsContainer:de,splitInputGroup:pe,splitInputLabel:me,splitInput:he,splitTotal:xe,splitTotalError:ue,checkboxesContainer:ge,ratingWarningButtons:be,singleExportMessage:ve,navigateButtonContainer:je,loadingOverlay:_e};function Ne({isOpen:c,onClose:i,onExport:r,crisisMapsCount:j,droneImagesCount:z,isLoading:s=!1,exportSuccess:x=!1,variant:k="bulk",onNavigateAndExport:I}){const[p,_]=n.useState("standard"),[f,E]=n.useState(80),[C,u]=n.useState(10),[S,N]=n.useState(10),[g,T]=n.useState(!0),[w,M]=n.useState(!0),y=()=>{if(k==="single"){r(p,["crisis_map","drone_image"]);return}if(!g&&!w){alert("Please select at least one image type to export.");return}const t=[];g&&t.push("crisis_map"),w&&t.push("drone_image"),r(p,t)},m=()=>{i()};return c?k==="single"?e.jsx("div",{className:l.fullSizeModalOverlay,onClick:m,children:e.jsxs("div",{className:l.fullSizeModalContent,onClick:t=>t.stopPropagation(),children:[s&&e.jsx("div",{className:l.loadingOverlay,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(B,{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"})]})}),x&&e.jsx("div",{className:l.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(v,{name:"close-export-success",onClick:m,className:"mt-4",children:"Close"})]})}),e.jsxs("div",{className:l.ratingWarningContent,children:[e.jsx("h3",{className:l.ratingWarningTitle,children:"Export Single Item"}),e.jsxs("div",{className:l.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:l.navigateButtonContainer,children:e.jsx(v,{name:"navigate-to-list",variant:"secondary",onClick:I,children:"Navigate to List View"})}),e.jsxs("div",{className:l.ratingWarningButtons,children:[e.jsx(v,{name:"continue-export",onClick:y,disabled:s,children:s?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"text-white"}),"Exporting..."]}):"Continue"}),e.jsx(v,{name:"cancel-export",variant:"tertiary",onClick:m,disabled:s,children:"Cancel"})]})]})]})}):e.jsx("div",{className:l.fullSizeModalOverlay,onClick:m,children:e.jsxs("div",{className:l.fullSizeModalContent,onClick:t=>t.stopPropagation(),children:[s&&e.jsx("div",{className:l.loadingOverlay,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(B,{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"})]})}),x&&e.jsx("div",{className:l.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(v,{name:"close-export-success",onClick:m,className:"mt-4",children:"Close"})]})}),e.jsxs("div",{className:l.ratingWarningContent,children:[e.jsx("h3",{className:l.ratingWarningTitle,children:"Export Dataset"}),e.jsx("div",{className:l.exportModeSection,children:e.jsx(R,{name:"export-mode",value:p,onChange:t=>{(t==="standard"||t==="fine-tuning")&&_(t)},options:[{key:"standard",label:"Standard"},{key:"fine-tuning",label:"Fine-tuning"}],keySelector:t=>t.key,labelSelector:t=>t.label,disabled:s})}),p==="fine-tuning"&&e.jsxs("div",{className:l.splitConfigSection,children:[e.jsx("div",{className:l.splitConfigTitle,children:"Dataset Split Configuration"}),e.jsxs("div",{className:l.splitInputsContainer,children:[e.jsxs("div",{className:l.splitInputGroup,children:[e.jsx("label",{htmlFor:"train-split",className:l.splitInputLabel,children:"Train (%)"}),e.jsx("input",{id:"train-split",type:"number",min:"0",max:"100",value:f,onChange:t=>{const o=parseInt(t.target.value)||0,d=100-o;d>=0&&(E(o),C+S>d&&(u(Math.floor(d/2)),N(d-Math.floor(d/2))))},className:l.splitInput,disabled:s})]}),e.jsxs("div",{className:l.splitInputGroup,children:[e.jsx("label",{htmlFor:"test-split",className:l.splitInputLabel,children:"Test (%)"}),e.jsx("input",{id:"test-split",type:"number",min:"0",max:"100",value:C,onChange:t=>{const o=parseInt(t.target.value)||0,d=100-f-o;d>=0&&(u(o),N(d))},className:l.splitInput,disabled:s})]}),e.jsxs("div",{className:l.splitInputGroup,children:[e.jsx("label",{htmlFor:"val-split",className:l.splitInputLabel,children:"Val (%)"}),e.jsx("input",{id:"val-split",type:"number",min:"0",max:"100",value:S,onChange:t=>{const o=parseInt(t.target.value)||0,d=100-f-o;d>=0&&(N(o),u(d))},className:l.splitInput,disabled:s})]})]}),f+C+S!==100&&e.jsx("div",{className:l.splitTotal,children:e.jsx("span",{className:l.splitTotalError,children:"Must equal 100%"})})]}),e.jsxs("div",{className:l.checkboxesContainer,children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(P,{name:"crisis-maps",label:`Crisis Maps (${j} images)`,value:g,onChange:t=>T(t),disabled:s})}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(P,{name:"drone-images",label:`Drone Images (${z} images)`,value:w,onChange:t=>M(t),disabled:s})})]}),e.jsxs("div",{className:l.ratingWarningButtons,children:[e.jsx(v,{name:"confirm-export",onClick:y,disabled:s,children:s?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"text-white"}),"Exporting..."]}):"Export Selected"}),e.jsx(v,{name:"cancel-export",variant:"tertiary",onClick:m,disabled:s,children:"Cancel"})]})]})]})}):null}export{Ne as E,Ce as F};
py_backend/static/assets/{index-DBYzoGv2.js β†’ index-B1FJ6p5l.js} RENAMED
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jszip.min-D9TECpfe.js","assets/index-Crh8pvny.js","assets/index-FBu17hMI.css"])))=>i.map(i=>d[i]);
2
- import{j as t,z as b,n as w,v as Fe,w as De,x as Oe,B as Le,r as o,D as Me,N as Re,_ as de,L as Je,F as ze,G as We}from"./index-Crh8pvny.js";import{u as Ue}from"./useAdmin-D6C-qshi.js";import{F as Be,E as He}from"./ExportModal-C2zShiT5.js";const Ve="_paginatorContainer_1l5ti_1",Ae="_paginationControls_1l5ti_19",me={paginatorContainer:Ve,paginationControls:Ae};function Ge({currentPage:N,totalPages:h,totalItems:X,itemsPerPage:U,onPageChange:C,className:S=""}){if(h<=1)return null;const u=(()=>{const g=[];if(h<=5)for(let f=1;f<=h;f++)g.push(f);else{let f=Math.max(1,N-2),_=Math.min(h,f+5-1);_===h&&(f=Math.max(1,_-5+1));for(let y=f;y<=_;y++)g.push(y)}return g})();return t.jsx("div",{className:`${me.paginatorContainer} ${S}`,children:t.jsxs("div",{className:me.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:()=>C(Math.max(1,N-1)),disabled:N===1,title:"Previous page",children:[t.jsx(Fe,{className:"w-4 h-4"}),t.jsx("span",{className:"hidden sm:inline",children:"Previous"})]})}),t.jsxs("div",{className:"flex items-center gap-1",children:[u[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:()=>C(1),children:"1"})}),u[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:"..."})})]}),u.map(g=>t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsx(w,{name:`page-${g}`,variant:N===g?"primary":"tertiary",size:1,onClick:()=>C(g),children:g})},g)),u[u.length-1]<h&&t.jsxs(t.Fragment,{children:[u[u.length-1]<h-1&&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:"..."})}),t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsx(w,{name:`page-${h}`,variant:"tertiary",size:1,onClick:()=>C(h),children:h})})]})]}),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:()=>C(Math.min(h,N+1)),disabled:N===h,title:"Next page",children:[t.jsx("span",{className:"hidden sm:inline",children:"Next"}),t.jsx(De,{className:"w-4 h-4"})]})})]})})}const Ze="_tabSelector_o9y1f_1",qe="_metadataTags_o9y1f_8",Ke="_metadataTag_o9y1f_8",Qe="_metadataTagSource_o9y1f_32",Xe="_metadataTagType_o9y1f_43",Ye="_mapItem_o9y1f_54",et="_mapItemImage_o9y1f_72",tt="_mapItemContent_o9y1f_92",at="_mapItemTitle_o9y1f_97",st="_mapItemMetadata_o9y1f_105",it="_fullSizeModalOverlay_o9y1f_134",nt="_fullSizeModalContent_o9y1f_148",lt="_ratingWarningContent_o9y1f_159",rt="_ratingWarningTitle_o9y1f_165",ot="_ratingWarningText_o9y1f_172",ct="_ratingWarningButtons_o9y1f_179",m={tabSelector:Ze,metadataTags:qe,metadataTag:Ke,metadataTagSource:Qe,metadataTagType:Xe,mapItem:Ye,mapItemImage:et,mapItemContent:tt,mapItemTitle:at,mapItemMetadata:st,fullSizeModalOverlay:it,fullSizeModalContent:nt,ratingWarningContent:lt,ratingWarningTitle:rt,ratingWarningText:ot,ratingWarningButtons:ct};function pt(){const N=Oe(),h=Le(),{isAuthenticated:X}=Ue(),[U,C]=o.useState("explore"),[S,M]=o.useState([]),{search:u,srcFilter:g,catFilter:T,regionFilter:f,countryFilter:_,imageTypeFilter:y,uploadTypeFilter:$,showReferenceExamples:E,setShowReferenceExamples:ge}=Me(),[B,pe]=o.useState([]),[H,ue]=o.useState([]),[Y,fe]=o.useState([]),[he,xe]=o.useState([]),[ee,_e]=o.useState([]),[ye,te]=o.useState(!0),[R,ae]=o.useState(!0),[je,V]=o.useState(!1),[Ne,A]=o.useState(!1),[ve,G]=o.useState(!1),[be,J]=o.useState(!1),[z,se]=o.useState(""),[Z,ie]=o.useState(!1),[W,ne]=o.useState(1),[q]=o.useState(10),[K,le]=o.useState(0),[we,re]=o.useState(0),Se=[{key:"explore",label:"List"},{key:"mapDetails",label:"Carousel"}],oe=()=>{ae(!0);const e=new URLSearchParams({page:W.toString(),limit:q.toString()});u&&e.append("search",u),g&&e.append("source",g),T&&e.append("event_type",T),f&&e.append("region",f),_&&e.append("country",_),y&&e.append("image_type",y),$&&e.append("upload_type",$),E&&e.append("starred_only","true"),fetch(`/api/images/grouped?${e.toString()}`).then(s=>s.ok?s.json():(console.error("ExplorePage: Grouped endpoint failed, trying legacy endpoint"),fetch("/api/captions/legacy").then(c=>c.ok?c.json():(console.error("ExplorePage: Legacy endpoint failed, trying regular images endpoint"),fetch("/api/images").then(j=>{if(!j.ok)throw new Error(`HTTP ${j.status}: ${j.statusText}`);return j.json()}))))).then(s=>{console.log("ExplorePage: Fetched captions:",s),M(s)}).catch(s=>{console.error("ExplorePage: Error fetching captions:",s),M([])}).finally(()=>{ae(!1)})},Te=()=>{const e=new URLSearchParams;u&&e.append("search",u),g&&e.append("source",g),T&&e.append("event_type",T),f&&e.append("region",f),_&&e.append("country",_),y&&e.append("image_type",y),$&&e.append("upload_type",$),E&&e.append("starred_only","true"),fetch(`/api/images/grouped/count?${e.toString()}`).then(s=>s.ok?s.json():(console.error("ExplorePage: Count endpoint failed"),{total_count:0})).then(s=>{console.log("ExplorePage: Total count:",s.total_count),le(s.total_count),re(Math.ceil(s.total_count/q))}).catch(s=>{console.error("ExplorePage: Error fetching total count:",s),le(0),re(0)})};o.useEffect(()=>{oe(),Te()},[W,u,g,T,f,_,y,$,E]),o.useEffect(()=>{W!==1&&ne(1)},[u,g,T,f,_,y,$,E]),o.useEffect(()=>{const e=()=>{document.hidden||oe()};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[]),o.useEffect(()=>{new URLSearchParams(h.search).get("export")==="true"&&(V(!0),N("/explore",{replace:!0}))},[h.search,N,u,g,T,f,_,y,E]),o.useEffect(()=>{te(!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,c,j,P])=>{pe(e),ue(s),fe(c),xe(j),_e(P)}).catch(()=>{}).finally(()=>{te(!1)})},[]);const I=S,Ee=async(e,s="fine-tuning")=>{if(e.length===0){alert("No images to export");return}A(!0),G(!1);try{const c=(await We(async()=>{const{default:i}=await import("./jszip.min-D9TECpfe.js").then(k=>k.j);return{default:i}},__vite__mapDeps([0,1,2]))).default,j=new c,P=e.filter(i=>i.image_type==="crisis_map"),O=e.filter(i=>i.image_type==="drone_image");if(P.length>0){const i=j.folder("crisis_maps_dataset"),k=i?.folder("images");if(k){let F=1;for(const a of P)try{const v=a.image_count&&a.image_count>1?a.all_image_ids||[a.image_id]:[a.image_id],Q=v.map(async(n,x)=>{try{const l=await fetch(`/api/images/${n}/file`);if(!l.ok)throw new Error(`Failed to fetch image ${n}`);const r=await l.blob(),d=a.file_key.split(".").pop()||"jpg",p=`${String(F).padStart(4,"0")}_${String(x+1).padStart(2,"0")}.${d}`;return k.file(p,r),{success:!0,fileName:p,imageId:n}}catch(l){return console.error(`Failed to process image ${n}:`,l),{success:!1,fileName:"",imageId:n}}}),D=(await Promise.all(Q)).filter(n=>n.success);if(D.length>0){if(s==="fine-tuning"){const n=D.map(r=>`images/${r.fileName}`),x=Math.random(),l={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(x<.8){const r=i.file("train.jsonl");if(r){const d=await r.async("string").then(p=>JSON.parse(p||"[]")).catch(()=>[]);d.push(l),i.file("train.jsonl",JSON.stringify(d,null,2))}else i.file("train.jsonl",JSON.stringify([l],null,2))}else if(x<.9){const r=i.file("test.jsonl");if(r){const d=await r.async("string").then(p=>JSON.parse(p||"[]")).catch(()=>[]);d.push(l),i.file("test.jsonl",JSON.stringify(d,null,2))}else i.file("test.jsonl",JSON.stringify([l],null,2))}else{const r=i.file("val.jsonl");if(r){const d=await r.async("string").then(p=>JSON.parse(p||"[]")).catch(()=>[]);d.push(l),i.file("val.jsonl",JSON.stringify(d,null,2))}else i.file("val.jsonl",JSON.stringify([l],null,2))}}else{const n=D.map(l=>`images/${l.fileName}`),x={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(F).padStart(4,"0")}.json`,JSON.stringify(x,null,2))}F++}}catch(v){console.error(`Failed to process caption ${a.image_id}:`,v)}}}if(O.length>0){const i=j.folder("drone_images_dataset"),k=i?.folder("images");if(k){let F=1;for(const a of O)try{const v=a.image_count&&a.image_count>1?a.all_image_ids||[a.image_id]:[a.image_id],Q=v.map(async(n,x)=>{try{const l=await fetch(`/api/images/${n}/file`);if(!l.ok)throw new Error(`Failed to fetch image ${n}`);const r=await l.blob(),d=a.file_key.split(".").pop()||"jpg",p=`${String(F).padStart(4,"0")}_${String(x+1).padStart(2,"0")}.${d}`;return k.file(p,r),{success:!0,fileName:p,imageId:n}}catch(l){return console.error(`Failed to process image ${n}:`,l),{success:!1,fileName:"",imageId:n}}}),D=(await Promise.all(Q)).filter(n=>n.success);if(D.length>0){if(s==="fine-tuning"){const n=D.map(r=>`images/${r.fileName}`),x=Math.random(),l={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(x<.8){const r=i.file("train.jsonl");if(r){const d=await r.async("string").then(p=>JSON.parse(p||"[]")).catch(()=>[]);d.push(l),i.file("train.jsonl",JSON.stringify(d,null,2))}else i.file("train.jsonl",JSON.stringify([l],null,2))}else if(x<.9){const r=i.file("test.jsonl");if(r){const d=await r.async("string").then(p=>JSON.parse(p||"[]")).catch(()=>[]);d.push(l),i.file("test.jsonl",JSON.stringify(d,null,2))}else i.file("test.jsonl",JSON.stringify([l],null,2))}else{const r=i.file("val.jsonl");if(r){const d=await r.async("string").then(p=>JSON.parse(p||"[]")).catch(()=>[]);d.push(l),i.file("val.jsonl",JSON.stringify(d,null,2))}else i.file("val.jsonl",JSON.stringify([l],null,2))}}else{const n=D.map(l=>`images/${l.fileName}`),x={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(F).padStart(4,"0")}.json`,JSON.stringify(x,null,2))}F++}}catch(v){console.error(`Failed to process caption ${a.image_id}:`,v)}}}const $e=await j.generateAsync({type:"blob"}),ce=URL.createObjectURL($e),L=document.createElement("a");L.href=ce,L.download=`datasets_${s}_${new Date().toISOString().split("T")[0]}.zip`,document.body.appendChild(L),L.click(),document.body.removeChild(L),URL.revokeObjectURL(ce);const Pe=(P.length||0)+(O.length||0);console.log(`Exported ${s} datasets with ${Pe} total images:`),P.length>0&&console.log(`- Crisis maps: ${P.length} images`),O.length>0&&console.log(`- Drone images: ${O.length} images`),G(!0)}catch(c){console.error("Export failed:",c),alert("Failed to export dataset. Please try again.")}finally{A(!1)}},Ie=e=>{se(e),J(!0)},Ce=async()=>{if(z){ie(!0);try{console.log("Deleting image with ID:",z),(await fetch(`/api/images/${z}`,{method:"DELETE"})).ok?(M(s=>s.filter(c=>c.image_id!==z)),J(!1),se("")):(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{ie(!1)}}};return t.jsxs(Re,{children:[R?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(de,{className:"text-ifrcRed"}),t.jsx("div",{children:"Loading examples..."})]})}):t.jsxs("div",{className:"max-w-7xl mx-auto",children:[t.jsxs("div",{className:m.tabSelector,children:[t.jsx(Je,{name:"explore-view",value:U,onChange:e=>{(e==="explore"||e==="mapDetails")&&(C(e),e==="mapDetails"&&S.length>0&&(S[0]?.image_id&&S[0].image_id!=="undefined"&&S[0].image_id!=="null"?N(`/map/${S[0].image_id}`):console.error("Invalid image_id for navigation:",S[0]?.image_id)))},options:Se,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:()=>ge(!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:()=>V(!0),children:"Export"})]})]}),U==="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(Be,{sources:B,types:H,regions:Y,countries:he,imageTypes:ee,isLoadingFilters:ye})})})}),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:[I.length," of ",K," examples"]})}),R&&t.jsx("div",{className:"text-center py-12",children:t.jsxs("div",{className:"flex flex-col items-center gap-4",children:[t.jsx(de,{className:"text-ifrcRed"}),t.jsx("div",{children:"Loading examples..."})]})}),!R&&t.jsxs("div",{className:"space-y-4",children:[I.map(e=>t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("div",{className:`${m.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:m.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 c=s.target;e.image_url?c.src=e.image_url:(c.style.display="none",c.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 c=s.target;c.style.display="none",c.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:m.mapItemContent,children:[t.jsx("h3",{className:m.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:m.mapItemMetadata,children:t.jsxs("div",{className:m.metadataTags,children:[e.image_type!=="drone_image"&&t.jsx("span",{className:m.metadataTagSource,children:e.source&&e.source.includes(", ")?e.source.split(", ").map(s=>B.find(c=>c.s_code===s.trim())?.label||s.trim()).join(", "):B.find(s=>s.s_code===e.source)?.label||e.source}),t.jsx("span",{className:m.metadataTagType,children:e.event_type&&e.event_type.includes(", ")?e.event_type.split(", ").map(s=>H.find(c=>c.t_code===s.trim())?.label||s.trim()).join(", "):H.find(s=>s.t_code===e.event_type)?.label||e.event_type}),t.jsx("span",{className:m.metadataTag,children:ee.find(s=>s.image_type===e.image_type)?.label||e.image_type}),e.image_count&&e.image_count>1&&t.jsxs("span",{className:m.metadataTag,title:`Multi-upload with ${e.image_count} images`,children:["πŸ“· ",e.image_count]}),(!e.image_count||e.image_count<=1)&&t.jsx("span",{className:m.metadataTag,title:"Single Upload",children:"Single"}),e.countries&&e.countries.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:m.metadataTag,children:Y.find(s=>s.r_code===e.countries[0].r_code)?.label||"Unknown Region"}),t.jsx("span",{className:m.metadataTag,children:e.countries.map(s=>s.label).join(", ")})]})]})})]})]}),X&&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:()=>Ie(e.image_id),title:"Delete","aria-label":"Delete saved image",children:t.jsx(ze,{className:"w-4 h-4"})})})]},e.image_id)),!I.length&&t.jsx("div",{className:"text-center py-12",children:t.jsx("p",{className:"text-gray-500",children:"No examples found."})}),!R&&I.length>0&&t.jsx(Ge,{currentPage:W,totalPages:we,totalItems:K,itemsPerPage:q,onPageChange:ne})]})]})]}):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"})]})})]}),be&&t.jsx("div",{className:m.fullSizeModalOverlay,onClick:()=>J(!1),children:t.jsx("div",{className:m.fullSizeModalContent,onClick:e=>e.stopPropagation(),children:t.jsxs("div",{className:m.ratingWarningContent,children:[t.jsx("h3",{className:m.ratingWarningTitle,children:"Delete Image?"}),t.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?"}),t.jsxs("div",{className:m.ratingWarningButtons,children:[t.jsx(w,{name:"confirm-delete",variant:"secondary",onClick:Ce,disabled:Z,children:Z?"Deleting...":"Delete"}),t.jsx(w,{name:"cancel-delete",variant:"tertiary",onClick:()=>J(!1),disabled:Z,children:"Cancel"})]})]})})}),t.jsx(He,{isOpen:je,onClose:()=>{V(!1),G(!1),A(!1)},onExport:(e,s)=>{const c=I.filter(j=>s.includes(j.image_type));Ee(c,e)},filteredCount:I.length,totalCount:K,hasFilters:!!(u||g||T||f||_||y||$||E),crisisMapsCount:I.filter(e=>e.image_type==="crisis_map").length,droneImagesCount:I.filter(e=>e.image_type==="drone_image").length,isLoading:Ne,exportSuccess:ve})]})}export{pt as default};
 
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jszip.min-DyaOnsxL.js","assets/index-DkcyG4dA.js","assets/index-cCOeofBN.css"])))=>i.map(i=>d[i]);
2
+ import{j as t,z as b,n as w,v as Fe,w as De,x as Oe,B as Le,r as o,D as Me,N as Re,_ as de,L as Je,F as ze,G as We}from"./index-DkcyG4dA.js";import{u as Ue}from"./useAdmin-oKoxa8h9.js";import{F as Be,E as He}from"./ExportModal-B-0g2PYD.js";const Ve="_paginatorContainer_1l5ti_1",Ae="_paginationControls_1l5ti_19",me={paginatorContainer:Ve,paginationControls:Ae};function Ge({currentPage:N,totalPages:h,totalItems:X,itemsPerPage:U,onPageChange:C,className:S=""}){if(h<=1)return null;const u=(()=>{const g=[];if(h<=5)for(let f=1;f<=h;f++)g.push(f);else{let f=Math.max(1,N-2),_=Math.min(h,f+5-1);_===h&&(f=Math.max(1,_-5+1));for(let y=f;y<=_;y++)g.push(y)}return g})();return t.jsx("div",{className:`${me.paginatorContainer} ${S}`,children:t.jsxs("div",{className:me.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:()=>C(Math.max(1,N-1)),disabled:N===1,title:"Previous page",children:[t.jsx(Fe,{className:"w-4 h-4"}),t.jsx("span",{className:"hidden sm:inline",children:"Previous"})]})}),t.jsxs("div",{className:"flex items-center gap-1",children:[u[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:()=>C(1),children:"1"})}),u[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:"..."})})]}),u.map(g=>t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsx(w,{name:`page-${g}`,variant:N===g?"primary":"tertiary",size:1,onClick:()=>C(g),children:g})},g)),u[u.length-1]<h&&t.jsxs(t.Fragment,{children:[u[u.length-1]<h-1&&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:"..."})}),t.jsx(b,{withInternalPadding:!0,className:"bg-white/20 backdrop-blur-sm rounded-md p-2",children:t.jsx(w,{name:`page-${h}`,variant:"tertiary",size:1,onClick:()=>C(h),children:h})})]})]}),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:()=>C(Math.min(h,N+1)),disabled:N===h,title:"Next page",children:[t.jsx("span",{className:"hidden sm:inline",children:"Next"}),t.jsx(De,{className:"w-4 h-4"})]})})]})})}const Ze="_tabSelector_o9y1f_1",qe="_metadataTags_o9y1f_8",Ke="_metadataTag_o9y1f_8",Qe="_metadataTagSource_o9y1f_32",Xe="_metadataTagType_o9y1f_43",Ye="_mapItem_o9y1f_54",et="_mapItemImage_o9y1f_72",tt="_mapItemContent_o9y1f_92",at="_mapItemTitle_o9y1f_97",st="_mapItemMetadata_o9y1f_105",it="_fullSizeModalOverlay_o9y1f_134",nt="_fullSizeModalContent_o9y1f_148",lt="_ratingWarningContent_o9y1f_159",rt="_ratingWarningTitle_o9y1f_165",ot="_ratingWarningText_o9y1f_172",ct="_ratingWarningButtons_o9y1f_179",m={tabSelector:Ze,metadataTags:qe,metadataTag:Ke,metadataTagSource:Qe,metadataTagType:Xe,mapItem:Ye,mapItemImage:et,mapItemContent:tt,mapItemTitle:at,mapItemMetadata:st,fullSizeModalOverlay:it,fullSizeModalContent:nt,ratingWarningContent:lt,ratingWarningTitle:rt,ratingWarningText:ot,ratingWarningButtons:ct};function pt(){const N=Oe(),h=Le(),{isAuthenticated:X}=Ue(),[U,C]=o.useState("explore"),[S,M]=o.useState([]),{search:u,srcFilter:g,catFilter:T,regionFilter:f,countryFilter:_,imageTypeFilter:y,uploadTypeFilter:$,showReferenceExamples:E,setShowReferenceExamples:ge}=Me(),[B,pe]=o.useState([]),[H,ue]=o.useState([]),[Y,fe]=o.useState([]),[he,xe]=o.useState([]),[ee,_e]=o.useState([]),[ye,te]=o.useState(!0),[R,ae]=o.useState(!0),[je,V]=o.useState(!1),[Ne,A]=o.useState(!1),[ve,G]=o.useState(!1),[be,J]=o.useState(!1),[z,se]=o.useState(""),[Z,ie]=o.useState(!1),[W,ne]=o.useState(1),[q]=o.useState(10),[K,le]=o.useState(0),[we,re]=o.useState(0),Se=[{key:"explore",label:"List"},{key:"mapDetails",label:"Carousel"}],oe=()=>{ae(!0);const e=new URLSearchParams({page:W.toString(),limit:q.toString()});u&&e.append("search",u),g&&e.append("source",g),T&&e.append("event_type",T),f&&e.append("region",f),_&&e.append("country",_),y&&e.append("image_type",y),$&&e.append("upload_type",$),E&&e.append("starred_only","true"),fetch(`/api/images/grouped?${e.toString()}`).then(s=>s.ok?s.json():(console.error("ExplorePage: Grouped endpoint failed, trying legacy endpoint"),fetch("/api/captions/legacy").then(c=>c.ok?c.json():(console.error("ExplorePage: Legacy endpoint failed, trying regular images endpoint"),fetch("/api/images").then(j=>{if(!j.ok)throw new Error(`HTTP ${j.status}: ${j.statusText}`);return j.json()}))))).then(s=>{console.log("ExplorePage: Fetched captions:",s),M(s)}).catch(s=>{console.error("ExplorePage: Error fetching captions:",s),M([])}).finally(()=>{ae(!1)})},Te=()=>{const e=new URLSearchParams;u&&e.append("search",u),g&&e.append("source",g),T&&e.append("event_type",T),f&&e.append("region",f),_&&e.append("country",_),y&&e.append("image_type",y),$&&e.append("upload_type",$),E&&e.append("starred_only","true"),fetch(`/api/images/grouped/count?${e.toString()}`).then(s=>s.ok?s.json():(console.error("ExplorePage: Count endpoint failed"),{total_count:0})).then(s=>{console.log("ExplorePage: Total count:",s.total_count),le(s.total_count),re(Math.ceil(s.total_count/q))}).catch(s=>{console.error("ExplorePage: Error fetching total count:",s),le(0),re(0)})};o.useEffect(()=>{oe(),Te()},[W,u,g,T,f,_,y,$,E]),o.useEffect(()=>{W!==1&&ne(1)},[u,g,T,f,_,y,$,E]),o.useEffect(()=>{const e=()=>{document.hidden||oe()};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[]),o.useEffect(()=>{new URLSearchParams(h.search).get("export")==="true"&&(V(!0),N("/explore",{replace:!0}))},[h.search,N,u,g,T,f,_,y,E]),o.useEffect(()=>{te(!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,c,j,P])=>{pe(e),ue(s),fe(c),xe(j),_e(P)}).catch(()=>{}).finally(()=>{te(!1)})},[]);const I=S,Ee=async(e,s="fine-tuning")=>{if(e.length===0){alert("No images to export");return}A(!0),G(!1);try{const c=(await We(async()=>{const{default:i}=await import("./jszip.min-DyaOnsxL.js").then(k=>k.j);return{default:i}},__vite__mapDeps([0,1,2]))).default,j=new c,P=e.filter(i=>i.image_type==="crisis_map"),O=e.filter(i=>i.image_type==="drone_image");if(P.length>0){const i=j.folder("crisis_maps_dataset"),k=i?.folder("images");if(k){let F=1;for(const a of P)try{const v=a.image_count&&a.image_count>1?a.all_image_ids||[a.image_id]:[a.image_id],Q=v.map(async(n,x)=>{try{const l=await fetch(`/api/images/${n}/file`);if(!l.ok)throw new Error(`Failed to fetch image ${n}`);const r=await l.blob(),d=a.file_key.split(".").pop()||"jpg",p=`${String(F).padStart(4,"0")}_${String(x+1).padStart(2,"0")}.${d}`;return k.file(p,r),{success:!0,fileName:p,imageId:n}}catch(l){return console.error(`Failed to process image ${n}:`,l),{success:!1,fileName:"",imageId:n}}}),D=(await Promise.all(Q)).filter(n=>n.success);if(D.length>0){if(s==="fine-tuning"){const n=D.map(r=>`images/${r.fileName}`),x=Math.random(),l={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(x<.8){const r=i.file("train.jsonl");if(r){const d=await r.async("string").then(p=>JSON.parse(p||"[]")).catch(()=>[]);d.push(l),i.file("train.jsonl",JSON.stringify(d,null,2))}else i.file("train.jsonl",JSON.stringify([l],null,2))}else if(x<.9){const r=i.file("test.jsonl");if(r){const d=await r.async("string").then(p=>JSON.parse(p||"[]")).catch(()=>[]);d.push(l),i.file("test.jsonl",JSON.stringify(d,null,2))}else i.file("test.jsonl",JSON.stringify([l],null,2))}else{const r=i.file("val.jsonl");if(r){const d=await r.async("string").then(p=>JSON.parse(p||"[]")).catch(()=>[]);d.push(l),i.file("val.jsonl",JSON.stringify(d,null,2))}else i.file("val.jsonl",JSON.stringify([l],null,2))}}else{const n=D.map(l=>`images/${l.fileName}`),x={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(F).padStart(4,"0")}.json`,JSON.stringify(x,null,2))}F++}}catch(v){console.error(`Failed to process caption ${a.image_id}:`,v)}}}if(O.length>0){const i=j.folder("drone_images_dataset"),k=i?.folder("images");if(k){let F=1;for(const a of O)try{const v=a.image_count&&a.image_count>1?a.all_image_ids||[a.image_id]:[a.image_id],Q=v.map(async(n,x)=>{try{const l=await fetch(`/api/images/${n}/file`);if(!l.ok)throw new Error(`Failed to fetch image ${n}`);const r=await l.blob(),d=a.file_key.split(".").pop()||"jpg",p=`${String(F).padStart(4,"0")}_${String(x+1).padStart(2,"0")}.${d}`;return k.file(p,r),{success:!0,fileName:p,imageId:n}}catch(l){return console.error(`Failed to process image ${n}:`,l),{success:!1,fileName:"",imageId:n}}}),D=(await Promise.all(Q)).filter(n=>n.success);if(D.length>0){if(s==="fine-tuning"){const n=D.map(r=>`images/${r.fileName}`),x=Math.random(),l={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(x<.8){const r=i.file("train.jsonl");if(r){const d=await r.async("string").then(p=>JSON.parse(p||"[]")).catch(()=>[]);d.push(l),i.file("train.jsonl",JSON.stringify(d,null,2))}else i.file("train.jsonl",JSON.stringify([l],null,2))}else if(x<.9){const r=i.file("test.jsonl");if(r){const d=await r.async("string").then(p=>JSON.parse(p||"[]")).catch(()=>[]);d.push(l),i.file("test.jsonl",JSON.stringify(d,null,2))}else i.file("test.jsonl",JSON.stringify([l],null,2))}else{const r=i.file("val.jsonl");if(r){const d=await r.async("string").then(p=>JSON.parse(p||"[]")).catch(()=>[]);d.push(l),i.file("val.jsonl",JSON.stringify(d,null,2))}else i.file("val.jsonl",JSON.stringify([l],null,2))}}else{const n=D.map(l=>`images/${l.fileName}`),x={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(F).padStart(4,"0")}.json`,JSON.stringify(x,null,2))}F++}}catch(v){console.error(`Failed to process caption ${a.image_id}:`,v)}}}const $e=await j.generateAsync({type:"blob"}),ce=URL.createObjectURL($e),L=document.createElement("a");L.href=ce,L.download=`datasets_${s}_${new Date().toISOString().split("T")[0]}.zip`,document.body.appendChild(L),L.click(),document.body.removeChild(L),URL.revokeObjectURL(ce);const Pe=(P.length||0)+(O.length||0);console.log(`Exported ${s} datasets with ${Pe} total images:`),P.length>0&&console.log(`- Crisis maps: ${P.length} images`),O.length>0&&console.log(`- Drone images: ${O.length} images`),G(!0)}catch(c){console.error("Export failed:",c),alert("Failed to export dataset. Please try again.")}finally{A(!1)}},Ie=e=>{se(e),J(!0)},Ce=async()=>{if(z){ie(!0);try{console.log("Deleting image with ID:",z),(await fetch(`/api/images/${z}`,{method:"DELETE"})).ok?(M(s=>s.filter(c=>c.image_id!==z)),J(!1),se("")):(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{ie(!1)}}};return t.jsxs(Re,{children:[R?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(de,{className:"text-ifrcRed"}),t.jsx("div",{children:"Loading examples..."})]})}):t.jsxs("div",{className:"max-w-7xl mx-auto",children:[t.jsxs("div",{className:m.tabSelector,children:[t.jsx(Je,{name:"explore-view",value:U,onChange:e=>{(e==="explore"||e==="mapDetails")&&(C(e),e==="mapDetails"&&S.length>0&&(S[0]?.image_id&&S[0].image_id!=="undefined"&&S[0].image_id!=="null"?N(`/map/${S[0].image_id}`):console.error("Invalid image_id for navigation:",S[0]?.image_id)))},options:Se,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:()=>ge(!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:()=>V(!0),children:"Export"})]})]}),U==="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(Be,{sources:B,types:H,regions:Y,countries:he,imageTypes:ee,isLoadingFilters:ye})})})}),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:[I.length," of ",K," examples"]})}),R&&t.jsx("div",{className:"text-center py-12",children:t.jsxs("div",{className:"flex flex-col items-center gap-4",children:[t.jsx(de,{className:"text-ifrcRed"}),t.jsx("div",{children:"Loading examples..."})]})}),!R&&t.jsxs("div",{className:"space-y-4",children:[I.map(e=>t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("div",{className:`${m.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:m.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 c=s.target;e.image_url?c.src=e.image_url:(c.style.display="none",c.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 c=s.target;c.style.display="none",c.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:m.mapItemContent,children:[t.jsx("h3",{className:m.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:m.mapItemMetadata,children:t.jsxs("div",{className:m.metadataTags,children:[e.image_type!=="drone_image"&&t.jsx("span",{className:m.metadataTagSource,children:e.source&&e.source.includes(", ")?e.source.split(", ").map(s=>B.find(c=>c.s_code===s.trim())?.label||s.trim()).join(", "):B.find(s=>s.s_code===e.source)?.label||e.source}),t.jsx("span",{className:m.metadataTagType,children:e.event_type&&e.event_type.includes(", ")?e.event_type.split(", ").map(s=>H.find(c=>c.t_code===s.trim())?.label||s.trim()).join(", "):H.find(s=>s.t_code===e.event_type)?.label||e.event_type}),t.jsx("span",{className:m.metadataTag,children:ee.find(s=>s.image_type===e.image_type)?.label||e.image_type}),e.image_count&&e.image_count>1&&t.jsxs("span",{className:m.metadataTag,title:`Multi-upload with ${e.image_count} images`,children:["πŸ“· ",e.image_count]}),(!e.image_count||e.image_count<=1)&&t.jsx("span",{className:m.metadataTag,title:"Single Upload",children:"Single"}),e.countries&&e.countries.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:m.metadataTag,children:Y.find(s=>s.r_code===e.countries[0].r_code)?.label||"Unknown Region"}),t.jsx("span",{className:m.metadataTag,children:e.countries.map(s=>s.label).join(", ")})]})]})})]})]}),X&&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:()=>Ie(e.image_id),title:"Delete","aria-label":"Delete saved image",children:t.jsx(ze,{className:"w-4 h-4"})})})]},e.image_id)),!I.length&&t.jsx("div",{className:"text-center py-12",children:t.jsx("p",{className:"text-gray-500",children:"No examples found."})}),!R&&I.length>0&&t.jsx(Ge,{currentPage:W,totalPages:we,totalItems:K,itemsPerPage:q,onPageChange:ne})]})]})]}):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"})]})})]}),be&&t.jsx("div",{className:m.fullSizeModalOverlay,onClick:()=>J(!1),children:t.jsx("div",{className:m.fullSizeModalContent,onClick:e=>e.stopPropagation(),children:t.jsxs("div",{className:m.ratingWarningContent,children:[t.jsx("h3",{className:m.ratingWarningTitle,children:"Delete Image?"}),t.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?"}),t.jsxs("div",{className:m.ratingWarningButtons,children:[t.jsx(w,{name:"confirm-delete",variant:"secondary",onClick:Ce,disabled:Z,children:Z?"Deleting...":"Delete"}),t.jsx(w,{name:"cancel-delete",variant:"tertiary",onClick:()=>J(!1),disabled:Z,children:"Cancel"})]})]})})}),t.jsx(He,{isOpen:je,onClose:()=>{V(!1),G(!1),A(!1)},onExport:(e,s)=>{const c=I.filter(j=>s.includes(j.image_type));Ee(c,e)},filteredCount:I.length,totalCount:K,hasFilters:!!(u||g||T||f||_||y||$||E),crisisMapsCount:I.filter(e=>e.image_type==="crisis_map").length,droneImagesCount:I.filter(e=>e.image_type==="drone_image").length,isLoading:Ne,exportSuccess:ve})]})}export{pt as default};
py_backend/static/assets/{index-DfLaxUB8.js β†’ index-Cybdmk-t.js} RENAMED
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jszip.min-D9TECpfe.js","assets/index-Crh8pvny.js","assets/index-FBu17hMI.css"])))=>i.map(i=>d[i]);
2
- import{K as ea,x as aa,j as a,N as Y,n as L,r as d,D as ta,_ as je,L as sa,z as P,v as ie,w as ne,F as ia,M as na,G as oa}from"./index-Crh8pvny.js";import{u as ra}from"./useAdmin-D6C-qshi.js";import{F as la,E as ca}from"./ExportModal-C2zShiT5.js";const da="_tabSelector_usssr_1",ga="_imageContainer_usssr_12",ma="_imagePlaceholder_usssr_33",ua="_metadataTags_usssr_45",pa="_metadataTag_usssr_45",fa="_captionContainer_usssr_67",_a="_captionText_usssr_74",ha="_gridLayout_usssr_131",xa="_detailsSection_usssr_155",ya="_loadingContainer_usssr_161",va="_errorContainer_usssr_171",ja="_fullSizeModalOverlay_usssr_205",wa="_fullSizeModalContent_usssr_219",Ia="_ratingWarningContent_usssr_230",Na="_ratingWarningTitle_usssr_236",Ca="_ratingWarningText_usssr_243",ba="_ratingWarningButtons_usssr_250",Sa="_carouselContainer_usssr_365",Da="_carouselImageWrapper_usssr_370",ka="_carouselImage_usssr_370",Ma="_carouselNavigation_usssr_393",La="_carouselButton_usssr_405",Fa="_carouselIndicators_usssr_429",Ta="_carouselIndicator_usssr_429",Pa="_carouselIndicatorActive_usssr_458",Ea="_singleImageContainer_usssr_488",$a="_viewImageButtonContainer_usssr_494",m={tabSelector:da,imageContainer:ga,imagePlaceholder:ma,metadataTags:ua,metadataTag:pa,captionContainer:fa,captionText:_a,gridLayout:ha,detailsSection:xa,loadingContainer:ya,errorContainer:va,fullSizeModalOverlay:ja,fullSizeModalContent:wa,ratingWarningContent:Ia,ratingWarningTitle:Na,ratingWarningText:Ca,ratingWarningButtons:ba,carouselContainer:Sa,carouselImageWrapper:Da,carouselImage:ka,carouselNavigation:Ma,carouselButton:La,carouselIndicators:Fa,carouselIndicator:Ta,carouselIndicatorActive:Pa,singleImageContainer:Ea,viewImageButtonContainer:$a};function st(){const{mapId:g}=ea(),x=aa(),{isAuthenticated:oe}=ra();console.log("MapDetailsPage: Current URL:",window.location.href),console.log("MapDetailsPage: Hash:",window.location.hash),console.log("MapDetailsPage: mapId from useParams:",g),console.log("MapDetailsPage: mapId type:",typeof g),console.log("MapDetailsPage: mapId length:",g?.length),console.log("MapDetailsPage: mapId value:",JSON.stringify(g));const we=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;if(!g||g==="undefined"||g==="null"||g.trim()===""||!we.test(g))return a.jsx(Y,{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 = "',g,'" (type: ',typeof g,")"]}),a.jsx(L,{name:"back-to-explore",variant:"secondary",onClick:()=>x("/explore"),children:"Return to Explore"})]})});const[re,Ie]=d.useState("mapDetails"),[e,ee]=d.useState(null),[z,R]=d.useState(!0),[le,O]=d.useState(null),[ce,Ne]=d.useState([]),[de,Ce]=d.useState([]),[ge,be]=d.useState([]),[me,Se]=d.useState([]),[De,ke]=d.useState([]),[Me,Le]=d.useState(!1),[Fe,Te]=d.useState(!1),[W,q]=d.useState(!1),[Pe,K]=d.useState(!1),[ue,Z]=d.useState(!1),[Ee,ae]=d.useState(!1),[$e,te]=d.useState(!1),[Ra,Aa]=d.useState("standard"),[E,za]=d.useState(80),[J,Oa]=d.useState(10),[Ua,Ba]=d.useState(10),[Wa,Ja]=d.useState(!0),[Va,Ha]=d.useState(!0),[U,Q]=d.useState(!1),[Re,pe]=d.useState(!1),[Ae,fe]=d.useState(null),[ze,V]=d.useState(!1),[h,H]=d.useState([]),[D,A]=d.useState(0),[G,_e]=d.useState(!1),{search:p,setSearch:Ga,srcFilter:y,setSrcFilter:qa,catFilter:v,setCatFilter:Ka,regionFilter:j,setRegionFilter:Za,countryFilter:w,setCountryFilter:Qa,imageTypeFilter:I,setImageTypeFilter:Xa,uploadTypeFilter:N,setUploadTypeFilter:Ya,showReferenceExamples:b,setShowReferenceExamples:Oe,clearAllFilters:Ue}=ta(),Be=[{key:"explore",label:"List"},{key:"mapDetails",label:"Carousel"}],he=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),O("Invalid Map ID"),R(!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),O("Invalid Map ID format"),R(!1);return}console.log("fetchMapData: Making API call for id:",t),q(!0),R(!0);try{const l=await fetch(`/api/images/${t}`);if(!l.ok)throw new Error("Map not found");const i=await l.json();if(ee(i),i.all_image_ids&&i.all_image_ids.length>1)await xe(i.all_image_ids);else if(i.image_count&&i.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 o=(await n.json()).find(u=>u.all_image_ids&&u.all_image_ids.includes(i.image_id));o&&o.all_image_ids?await xe(o.all_image_ids):(H([i]),A(0))}else H([i]),A(0)}catch(n){console.error("Failed to fetch from grouped endpoint:",n),H([i]),A(0)}}else H([i]),A(0);await se(t)}catch(l){O(l instanceof Error?l.message:"Unknown error occurred")}finally{R(!1),q(!1)}},[]),xe=d.useCallback(async t=>{console.log("fetchAllImages called with imageIds:",t),_e(!0);try{const s=t.map(async i=>{const n=await fetch(`/api/images/${i}`);if(!n.ok)throw new Error(`Failed to fetch image ${i}`);return n.json()}),l=await Promise.all(s);H(l),A(0),console.log("fetchAllImages: Loaded",l.length,"images")}catch(s){console.error("fetchAllImages error:",s),O(s instanceof Error?s.message:"Failed to load all images")}finally{_e(!1)}},[]),We=d.useCallback(()=>{h.length>1&&A(t=>t>0?t-1:h.length-1)},[h.length]),Je=d.useCallback(()=>{h.length>1&&A(t=>t<h.length-1?t+1:0)},[h.length]),Ve=d.useCallback(t=>{t>=0&&t<h.length&&A(t)},[h.length]),ye=d.useCallback(async t=>{const s=t||(h.length>0?h[D]:e);if(s){V(!0),fe(s),pe(!0);try{const l=new Image;l.onload=()=>{V(!1)},l.onerror=()=>{V(!1)},l.src=s.image_url}catch(l){console.error("Error preloading full-size image:",l),V(!1)}}},[h,D,e]),He=d.useCallback(()=>{pe(!1),fe(null),V(!1)},[]);d.useEffect(()=>{if(console.log("MapDetailsPage: mapId from useParams:",g),console.log("MapDetailsPage: mapId type:",typeof g),console.log("MapDetailsPage: mapId value:",g),!g||g==="undefined"||g==="null"||g.trim()===""||g===void 0||g===null){console.log("MapDetailsPage: Invalid mapId, setting error"),O("Map ID is required"),R(!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(g)){console.log("MapDetailsPage: Invalid UUID format:",g),O("Invalid Map ID format"),R(!1);return}console.log("MapDetailsPage: Fetching data for mapId:",g),he(g)},[g,he]),d.useEffect(()=>{if(!e||z||U)return;if(!g||g==="undefined"||g==="null"||g.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(g)){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()),i=!y||e.source===y,n=!v||e.event_type===v,r=!j||e.countries.some($=>$.r_code===j),o=!w||e.countries.some($=>$.c_code===w),u=!I||e.image_type===I,_=!b||e.starred===!0,k=l&&i&&n&&r&&o&&u&&_;return console.log("Auto-navigation check:",{mapId:g,search:p,srcFilter:y,catFilter:v,regionFilter:j,countryFilter:w,imageTypeFilter:I,showReferenceExamples:b,matchesSearch:l,matchesSource:i,matchesCategory:n,matchesRegion:r,matchesCountry:o,matchesImageType:u,matchesReferenceExamples:_,matches:k}),k})()||(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 i=l.find(n=>{const r=!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()),o=!y||n.source===y,u=!v||n.event_type===v,_=!j||n.countries?.some(f=>f.r_code===j),k=!w||n.countries?.some(f=>f.c_code===w),$=!I||n.image_type===I,F=!b||n.starred===!0;return r&&o&&u&&_&&k&&$&&F});console.log("Auto-navigation: Found first matching image:",i?{image_id:i.image_id,title:i.title,source:i.source}:"No matching image found"),i&&i.image_id&&i.image_id!=="undefined"&&i.image_id!=="null"&&i.image_id.trim()!==""&&i.image_id!==g&&(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(i.image_id)?(console.log("Auto-navigating to:",i.image_id),x(`/map/${i.image_id}`)):console.error("Auto-navigation blocked: Invalid image_id format:",i.image_id))}).catch(console.error))},[e,p,y,v,j,w,I,b,g,x,z,U]);const se=d.useCallback(async t=>{if(!(!t||t==="undefined"||t==="null"||t.trim()===""))try{const s=new URLSearchParams;p&&s.append("search",p),y&&s.append("source",y),v&&s.append("event_type",v),j&&s.append("region",j),w&&s.append("country",w),I&&s.append("image_type",I),N&&s.append("upload_type",N),b&&s.append("starred_only","true");const l=await fetch(`/api/images/grouped?${s.toString()}`);if(l.ok){const i=await l.json();console.log("Server response for upload_type=multiple:",{url:`/api/images/grouped?${s.toString()}`,count:i.length,images:i.map(r=>({image_id:r.image_id,image_count:r.image_count,all_image_ids:r.all_image_ids,all_image_ids_length:r.all_image_ids?.length}))});const n=i.findIndex(r=>r.image_id===t);console.log("Navigation availability check (server-side):",{filteredImagesCount:i.length,currentIndex:n,currentId:t,uploadTypeFilter:N,hasPrevious:i.length>1&&n>0,hasNext:i.length>1&&n<i.length-1,filteredImages:i.map(r=>({image_id:r.image_id,image_count:r.image_count,all_image_ids:r.all_image_ids,image_type:r.image_type}))}),Le(i.length>1&&n>0),Te(i.length>1&&n<i.length-1)}}catch(s){console.error("Failed to check navigation availability:",s)}},[p,y,v,j,w,I,N,b]),ve=async t=>{if(!W){q(!0);try{const s=new URLSearchParams;p&&s.append("search",p),y&&s.append("source",y),v&&s.append("event_type",v),j&&s.append("region",j),w&&s.append("country",w),I&&s.append("image_type",I),N&&s.append("upload_type",N),b&&s.append("starred_only","true");const l=await fetch(`/api/images/grouped?${s.toString()}`);if(l.ok){const i=await l.json(),n=i.findIndex(u=>u.image_id===g);if(n===-1){console.error("Current image not found in filtered list");return}let r;t==="previous"?r=n>0?n-1:i.length-1:r=n<i.length-1?n+1:0;const o=i[r];o&&o.image_id&&o.image_id!=="undefined"&&o.image_id!=="null"&&o.image_id.trim()!==""&&(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(o.image_id)?(console.log("Carousel navigating to:",o.image_id),x(`/map/${o.image_id}`)):console.error("Carousel navigation blocked: Invalid image_id format:",o.image_id))}}catch(s){console.error("Failed to navigate to item:",s)}finally{q(!1)}}};d.useEffect(()=>{console.log("=== NAVIGATION USEEFFECT TRIGGERED ==="),console.log("Navigation useEffect triggered:",{map:!!e,mapId:g,loading:z,isDeleting:U,uploadTypeFilter:N,allFilters:{search:p,srcFilter:y,catFilter:v,regionFilter:j,countryFilter:w,imageTypeFilter:I,uploadTypeFilter:N,showReferenceExamples:b}}),e&&g&&!z&&!U?(console.log("Calling checkNavigationAvailability with:",g),se(g)):console.log("NOT calling checkNavigationAvailability because:",{map:!!e,mapId:!!g,loading:z,isDeleting:U})},[e,g,p,y,v,j,w,I,N,b,z,U,se]),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,s,l,i,n])=>{Ne(t),Ce(s),be(l),Se(i),ke(n)}).catch(console.error)},[]);const Ge=async()=>{e&&K(!0)},qe=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?ee(s=>s?{...s,starred:!s.starred}:null):console.error("Failed to toggle starred status")}catch(t){console.error("Error toggling starred status:",t)}},Ke=async()=>{if(e){Q(!0);try{if(console.log("Deleting image with ID:",e.image_id),(await fetch(`/api/images/${e.image_id}`,{method:"DELETE"})).ok){ee(s=>s?{...s,starred:!s.starred}:null),K(!1);try{const s=await fetch("/api/images/grouped");if(s.ok){const i=(await s.json()).filter(r=>{const o=!p||r.title?.toLowerCase().includes(p.toLowerCase())||r.generated?.toLowerCase().includes(p.toLowerCase())||r.source?.toLowerCase().includes(p.toLowerCase())||r.event_type?.toLowerCase().includes(p.toLowerCase()),u=!y||r.source===y,_=!v||r.event_type===v,k=!j||r.countries?.some(C=>C.r_code===j),$=!w||r.countries?.some(C=>C.c_code===w),F=!I||r.image_type===I,f=!N||N==="single"&&(!r.image_count||r.image_count<=1)||N==="multiple"&&r.image_count&&r.image_count>1,M=!b||r.starred===!0;return o&&u&&_&&k&&$&&F&&f&&M}),n=i.filter(r=>r.image_id!==e.image_id);if(n.length>0){const r=i.findIndex(u=>u.image_id===e.image_id);let o;if(r===i.length-1?o=r-1:o=r,console.log("Navigation target:",{currentIndex:r,targetIndex:o,targetId:n[o]?.image_id}),o>=0&&o<n.length){const u=n[o];u&&u.image_id&&u.image_id!=="undefined"&&u.image_id!=="null"&&u.image_id.trim()!==""?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(u.image_id)?(console.log("Navigating to:",u.image_id),x(`/map/${u.image_id}`)):(console.error("Navigation blocked: Invalid image_id format:",u.image_id),x("/explore")):(console.error("Navigation blocked: Invalid image_id:",u?.image_id),x("/explore"))}else n[0]&&n[0].image_id&&n[0].image_id!=="undefined"&&n[0].image_id!=="null"&&n[0].image_id.trim()!==""?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n[0].image_id)?(console.log("Fallback navigation to first item:",n[0].image_id),x(`/map/${n[0].image_id}`)):(console.error("Fallback navigation blocked: Invalid image_id format:",n[0].image_id),x("/explore")):(console.log("No valid remaining items, going to explore page"),x("/explore"))}else console.log("No remaining items, going to explore page"),x("/explore")}else x("/explore")}catch(s){console.error("Failed to navigate to next item:",s),x("/explore")}finally{Q(!1)}}else console.error("Delete failed"),Q(!1)}catch(t){console.error("Delete failed:",t),Q(!1)}}},c=d.useMemo(()=>{if(!e)return null;if(!p&&!y&&!v&&!j&&!w&&!I&&!N&&!b)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()),s=!y||e.source===y,l=!v||e.event_type===v,i=!j||e.countries.some(k=>k.r_code===j),n=!w||e.countries.some(k=>k.c_code===w),r=!I||e.image_type===I,o=!N||N==="single"&&(!e.image_count||e.image_count<=1)&&(!e.all_image_ids||e.all_image_ids.length<=1)||N==="multiple"&&(e.image_count&&e.image_count>1||e.all_image_ids&&e.all_image_ids.length>1),u=!b||e.starred===!0,_=t&&s&&l&&i&&n&&r&&o&&u;return!_&&(p||y||v||j||w||I||N||b)?(setTimeout(()=>{Ze()},100),e):_?e:null},[e,p,y,v,j,w,I,N,b]),Ze=d.useCallback(async()=>{R(!0);try{const t=new URLSearchParams;p&&t.append("search",p),y&&t.append("source",y),v&&t.append("event_type",v),j&&t.append("region",j),w&&t.append("country",w),I&&t.append("image_type",I),N&&t.append("upload_type",N),b&&t.append("starred_only","true");const s=await fetch(`/api/images/grouped?${t.toString()}`);if(s.ok){const l=await s.json();if(l.length>0){const i=l[0];i&&i.image_id&&x(`/map/${i.image_id}`)}else x("/explore")}}catch(t){console.error("Failed to navigate to matching image:",t),x("/explore")}finally{R(!1)}},[p,y,v,j,w,I,N,b,x]),Qe=()=>{if(!e)return;if(!e.all_image_ids||e.all_image_ids.length<=1){const i=`/upload?step=1&contribute=true&imageIds=${[e.image_id].join(",")}`;x(i);return}const s=`/upload?step=1&contribute=true&imageIds=${e.all_image_ids.join(",")}`;x(s)},T=(t,s)=>({image:`images/${s}`,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){ae(!0),te(!1);try{const s=(await oa(async()=>{const{default:o}=await import("./jszip.min-D9TECpfe.js").then(u=>u.j);return{default:o}},__vite__mapDeps([0,1,2]))).default,l=new s;if(e.image_type==="crisis_map"){const o=l.folder("crisis_maps_dataset"),u=o?.folder("images");if(u)try{const _=e.image_count&&e.image_count>1?e.all_image_ids||[e.image_id]:[e.image_id],k=_.map(async(f,M)=>{try{const C=await fetch(`/api/images/${f}/file`);if(!C.ok)throw new Error(`Failed to fetch image ${f}`);const S=await C.blob(),X=e.file_key.split(".").pop()||"jpg",B=`0001_${String(M+1).padStart(2,"0")}.${X}`;return u.file(B,S),{success:!0,fileName:B,imageId:f}}catch(C){return console.error(`Failed to process image ${f}:`,C),{success:!1,fileName:"",imageId:f}}}),F=(await Promise.all(k)).filter(f=>f.success);if(F.length===0)throw new Error("No images could be processed");if(t==="fine-tuning"){const f=[],M=[],C=[],S=F.map(Ye=>`images/${Ye.fileName}`),X=Math.random(),B={image:S.length===1?S[0]:S,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}};X<E/100?f.push(B):X<(E+J)/100?M.push(B):C.push(B),o&&(o.file("train.jsonl",JSON.stringify(f,null,2)),o.file("test.jsonl",JSON.stringify(M,null,2)),o.file("val.jsonl",JSON.stringify(C,null,2)))}else{const f=F.map(C=>`images/${C.fileName}`),M={image:f.length===1?f[0]:f,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}};o&&o.file("0001.json",JSON.stringify(M,null,2))}}catch(_){throw console.error(`Failed to process image ${e.image_id}:`,_),_}}else if(e.image_type==="drone_image"){const o=l.folder("drone_images_dataset"),u=o?.folder("images");if(u)try{const _=await fetch(`/api/images/${e.image_id}/file`);if(!_.ok)throw new Error(`Failed to fetch image ${e.image_id}`);const k=await _.blob(),F=`0001.${e.file_key.split(".").pop()||"jpg"}`;if(u.file(F,k),t==="fine-tuning"){const f=[],M=[],C=[];if(String(e?.image_type)==="crisis_map"){const S=Math.random();S<E/100?f.push(T(e,"0001")):S<(E+J)/100?M.push(T(e,"0001")):C.push(T(e,"0001"))}else if(String(e?.image_type)==="drone_image"){const S=Math.random();S<E/100?f.push(T(e,"0001")):S<(E+J)/100?M.push(T(e,"0001")):C.push(T(e,"0001"))}o&&(o.file("train.jsonl",JSON.stringify(f,null,2)),o.file("test.jsonl",JSON.stringify(M,null,2)),o.file("val.jsonl",JSON.stringify(C,null,2)))}else{const f={image:`images/${F}`,caption:e.edited||e.generated||"",metadata:{image_id:e.image_count&&e.image_count>1?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}};o&&o.file("0001.json",JSON.stringify(f,null,2))}}catch(_){throw console.error(`Failed to process image ${e.image_id}:`,_),_}}else{const o=l.folder("generic_dataset"),u=o?.folder("images");if(u)try{const _=await fetch(`/api/images/${e.image_id}/file`);if(!_.ok)throw new Error(`Failed to fetch image ${e.image_id}`);const k=await _.blob(),F=`0001.${e.file_key.split(".").pop()||"jpg"}`;if(u.file(F,k),t==="fine-tuning"){const f=[],M=[],C=[];if(String(e?.image_type)==="crisis_map"){const S=Math.random();S<E/100?f.push(T(e,"0001")):S<(E+J)/100?M.push(T(e,"0001")):C.push(T(e,"0001"))}else if(String(e?.image_type)==="drone_image"){const S=Math.random();S<E/100?f.push(T(e,"0001")):S<(E+J)/100?M.push(T(e,"0001")):C.push(T(e,"0001"))}o&&(o.file("train.jsonl",JSON.stringify(f,null,2)),o.file("test.jsonl",JSON.stringify(M,null,2)),o.file("val.jsonl",JSON.stringify(C,null,2)))}else{const f={image:`images/${F}`,caption:e.edited||e.generated||"",metadata:{image_id:e.image_count&&e.image_count>1?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}};o&&o.file("0001.json",JSON.stringify(f,null,2))}}catch(_){throw console.error(`Failed to process image ${e.image_id}:`,_),_}}const i=await l.generateAsync({type:"blob"}),n=URL.createObjectURL(i),r=document.createElement("a");r.href=n,r.download=`dataset_${e.image_type}_${e.image_id}_${t}_${new Date().toISOString().split("T")[0]}.zip`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n),console.log(`Exported ${e.image_type} dataset with 1 image in ${t} mode`),te(!0)}catch(s){console.error("Export failed:",s),alert("Failed to export dataset. Please try again.")}finally{ae(!1)}}};return z?a.jsx(Y,{children:a.jsx("div",{className:m.loadingContainer,children:a.jsxs("div",{className:"flex flex-col items-center gap-4",children:[a.jsx(je,{className:"text-ifrcRed"}),a.jsx("div",{children:"Loading map details..."})]})})}):le||!e?a.jsx(Y,{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:le||"Map not found"}),a.jsx(L,{name:"back-to-explore",variant:"secondary",onClick:()=>x("/explore"),children:"Return to Explore"})]})})}):a.jsxs(Y,{children:[a.jsxs("div",{className:"max-w-7xl mx-auto",children:[a.jsxs("div",{className:m.tabSelector,children:[a.jsx(sa,{name:"map-details-view",value:re,onChange:t=>{(t==="mapDetails"||t==="explore")&&(Ie(t),t==="explore"&&x("/explore"))},options:Be,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(L,{name:"reference-examples",variant:b?"primary":"secondary",onClick:()=>Oe(!b),className:"whitespace-nowrap",children:[a.jsx("span",{className:"mr-2",children:b?a.jsx("span",{className:"text-yellow-400",children:"β˜…"}):a.jsx("span",{className:"text-yellow-400",children:"β˜†"})}),"Reference Examples"]})}),a.jsx(L,{name:"export-dataset",variant:"secondary",onClick:()=>Z(!0),children:"Export"})]})]}),a.jsx(la,{sources:ce,types:de,regions:me,countries:De,imageTypes:ge,isLoadingFilters:!1}),re==="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||h.length>1?a.jsxs("div",{className:m.carouselContainer,children:[a.jsx("div",{className:m.carouselImageWrapper,children:G?a.jsxs("div",{className:m.imagePlaceholder,children:[a.jsx(je,{className:"text-ifrcRed"}),a.jsx("div",{children:"Loading images..."})]}):h[D]?.detail_url?a.jsx("img",{src:h[D].detail_url,alt:h[D].file_key,className:m.carouselImage,onError:t=>{console.log("MapDetailsPage: Detail image failed to load, falling back to original:",h[D].detail_url);const s=t.target;h[D].image_url&&(s.src=h[D].image_url)},onLoad:()=>console.log("MapDetailsPage: Detail image loaded successfully:",h[D].detail_url)}):h[D]?.image_url?a.jsx("img",{src:h[D].image_url,alt:h[D].file_key,className:m.carouselImage,onLoad:()=>console.log("MapDetailsPage: Original image loaded successfully:",h[D].image_url)}):a.jsx("div",{className:m.imagePlaceholder,children:"No image available"})}),a.jsxs("div",{className:m.carouselNavigation,children:[a.jsx(L,{name:"previous-image",variant:"tertiary",size:1,onClick:We,disabled:G,className:m.carouselButton,children:a.jsx(ie,{className:"w-4 h-4"})}),a.jsx("div",{className:m.carouselIndicators,children:h.map((t,s)=>a.jsx("button",{onClick:()=>Ve(s),className:`${m.carouselIndicator} ${s===D?m.carouselIndicatorActive:""}`,disabled:G,children:s+1},s))}),a.jsx(L,{name:"next-image",variant:"tertiary",size:1,onClick:Je,disabled:G,className:m.carouselButton,children:a.jsx(ne,{className:"w-4 h-4"})})]}),a.jsx("div",{className:m.viewImageButtonContainer,children:a.jsx(L,{name:"view-full-size-carousel",variant:"secondary",size:1,onClick:()=>ye(h[D]),disabled:G||!h[D]?.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 s=t.target;c.image_url&&(s.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(L,{name:"view-full-size-single",variant:"secondary",size:1,onClick:()=>ye(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:ce.find(t=>t.s_code===c.source)?.label||c.source}),a.jsx("span",{className:m.metadataTag,children:de.find(t=>t.t_code===c.event_type)?.label||c.event_type}),a.jsx("span",{className:m.metadataTag,children:ge.find(t=>t.image_type===c.image_type)?.label||c.image_type}),c.countries&&c.countries.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:m.metadataTag,children:me.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:"AI Generated Content",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,i)=>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},i):a.jsx("p",{className:"mb-2",children:l.trim()},i))})})}):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:[Me&&a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(L,{name:"previous-item",variant:"tertiary",size:1,className:`bg-white/90 hover:bg-white shadow-lg border border-gray-200 ${W?"opacity-50 cursor-not-allowed":"hover:scale-110"}`,onClick:()=>ve("previous"),disabled:W,children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs("div",{className:"flex -space-x-1",children:[a.jsx(ie,{className:"w-4 h-4"}),a.jsx(ie,{className:"w-4 h-4"})]}),a.jsx("span",{className:"font-semibold",children:"Previous"})]})})}),oe&&a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(L,{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:Ge,title:"Delete","aria-label":"Delete saved image",children:a.jsx(ia,{className:"w-4 h-4"})})}),a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(L,{name:"contribute",onClick:Qe,children:"Contribute"})}),oe&&a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(L,{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:qe,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?"β˜…":"β˜†"})})}),Fe&&a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(L,{name:"next-item",variant:"tertiary",size:1,className:`bg-white/90 hover:bg-white shadow-lg border border-gray-200 ${W?"opacity-50 cursor-not-allowed":"hover:scale-110"}`,onClick:()=>ve("next"),disabled:W,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(ne,{className:"w-4 h-4"}),a.jsx(ne,{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(L,{name:"clear-filters",variant:"secondary",onClick:Ue,children:"Clear Filters"})})]})}):null]}),Pe&&a.jsx("div",{className:m.fullSizeModalOverlay,onClick:()=>K(!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(L,{name:"confirm-delete",variant:"secondary",onClick:Ke,children:"Delete"}),a.jsx(L,{name:"cancel-delete",variant:"tertiary",onClick:()=>K(!1),children:"Cancel"})]})]})})}),ue&&a.jsx(ca,{isOpen:ue,onClose:()=>{Z(!1),te(!1),ae(!1)},onExport:(t,s)=>{s.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:Ee,exportSuccess:$e,variant:"single",onNavigateToList:()=>{Z(!1),x("/explore")},onNavigateAndExport:()=>{Z(!1),x("/explore?export=true")}}),a.jsx(na,{isOpen:Re,imageUrl:Ae?.image_url||null,preview:null,selectedImageData:null,onClose:He,isLoading:ze})]})}export{st as default};
 
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jszip.min-DyaOnsxL.js","assets/index-DkcyG4dA.js","assets/index-cCOeofBN.css"])))=>i.map(i=>d[i]);
2
+ import{K as ea,x as aa,j as a,N as Y,n as L,r as d,D as ta,_ as je,L as sa,z as P,v as ie,w as ne,F as ia,M as na,G as oa}from"./index-DkcyG4dA.js";import{u as ra}from"./useAdmin-oKoxa8h9.js";import{F as la,E as ca}from"./ExportModal-B-0g2PYD.js";const da="_tabSelector_usssr_1",ga="_imageContainer_usssr_12",ma="_imagePlaceholder_usssr_33",ua="_metadataTags_usssr_45",pa="_metadataTag_usssr_45",fa="_captionContainer_usssr_67",_a="_captionText_usssr_74",ha="_gridLayout_usssr_131",xa="_detailsSection_usssr_155",ya="_loadingContainer_usssr_161",va="_errorContainer_usssr_171",ja="_fullSizeModalOverlay_usssr_205",wa="_fullSizeModalContent_usssr_219",Ia="_ratingWarningContent_usssr_230",Na="_ratingWarningTitle_usssr_236",Ca="_ratingWarningText_usssr_243",ba="_ratingWarningButtons_usssr_250",Sa="_carouselContainer_usssr_365",Da="_carouselImageWrapper_usssr_370",ka="_carouselImage_usssr_370",Ma="_carouselNavigation_usssr_393",La="_carouselButton_usssr_405",Fa="_carouselIndicators_usssr_429",Ta="_carouselIndicator_usssr_429",Pa="_carouselIndicatorActive_usssr_458",Ea="_singleImageContainer_usssr_488",$a="_viewImageButtonContainer_usssr_494",m={tabSelector:da,imageContainer:ga,imagePlaceholder:ma,metadataTags:ua,metadataTag:pa,captionContainer:fa,captionText:_a,gridLayout:ha,detailsSection:xa,loadingContainer:ya,errorContainer:va,fullSizeModalOverlay:ja,fullSizeModalContent:wa,ratingWarningContent:Ia,ratingWarningTitle:Na,ratingWarningText:Ca,ratingWarningButtons:ba,carouselContainer:Sa,carouselImageWrapper:Da,carouselImage:ka,carouselNavigation:Ma,carouselButton:La,carouselIndicators:Fa,carouselIndicator:Ta,carouselIndicatorActive:Pa,singleImageContainer:Ea,viewImageButtonContainer:$a};function st(){const{mapId:g}=ea(),x=aa(),{isAuthenticated:oe}=ra();console.log("MapDetailsPage: Current URL:",window.location.href),console.log("MapDetailsPage: Hash:",window.location.hash),console.log("MapDetailsPage: mapId from useParams:",g),console.log("MapDetailsPage: mapId type:",typeof g),console.log("MapDetailsPage: mapId length:",g?.length),console.log("MapDetailsPage: mapId value:",JSON.stringify(g));const we=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;if(!g||g==="undefined"||g==="null"||g.trim()===""||!we.test(g))return a.jsx(Y,{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 = "',g,'" (type: ',typeof g,")"]}),a.jsx(L,{name:"back-to-explore",variant:"secondary",onClick:()=>x("/explore"),children:"Return to Explore"})]})});const[re,Ie]=d.useState("mapDetails"),[e,ee]=d.useState(null),[z,R]=d.useState(!0),[le,O]=d.useState(null),[ce,Ne]=d.useState([]),[de,Ce]=d.useState([]),[ge,be]=d.useState([]),[me,Se]=d.useState([]),[De,ke]=d.useState([]),[Me,Le]=d.useState(!1),[Fe,Te]=d.useState(!1),[W,q]=d.useState(!1),[Pe,K]=d.useState(!1),[ue,Z]=d.useState(!1),[Ee,ae]=d.useState(!1),[$e,te]=d.useState(!1),[Ra,Aa]=d.useState("standard"),[E,za]=d.useState(80),[J,Oa]=d.useState(10),[Ua,Ba]=d.useState(10),[Wa,Ja]=d.useState(!0),[Va,Ha]=d.useState(!0),[U,Q]=d.useState(!1),[Re,pe]=d.useState(!1),[Ae,fe]=d.useState(null),[ze,V]=d.useState(!1),[h,H]=d.useState([]),[D,A]=d.useState(0),[G,_e]=d.useState(!1),{search:p,setSearch:Ga,srcFilter:y,setSrcFilter:qa,catFilter:v,setCatFilter:Ka,regionFilter:j,setRegionFilter:Za,countryFilter:w,setCountryFilter:Qa,imageTypeFilter:I,setImageTypeFilter:Xa,uploadTypeFilter:N,setUploadTypeFilter:Ya,showReferenceExamples:b,setShowReferenceExamples:Oe,clearAllFilters:Ue}=ta(),Be=[{key:"explore",label:"List"},{key:"mapDetails",label:"Carousel"}],he=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),O("Invalid Map ID"),R(!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),O("Invalid Map ID format"),R(!1);return}console.log("fetchMapData: Making API call for id:",t),q(!0),R(!0);try{const l=await fetch(`/api/images/${t}`);if(!l.ok)throw new Error("Map not found");const i=await l.json();if(ee(i),i.all_image_ids&&i.all_image_ids.length>1)await xe(i.all_image_ids);else if(i.image_count&&i.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 o=(await n.json()).find(u=>u.all_image_ids&&u.all_image_ids.includes(i.image_id));o&&o.all_image_ids?await xe(o.all_image_ids):(H([i]),A(0))}else H([i]),A(0)}catch(n){console.error("Failed to fetch from grouped endpoint:",n),H([i]),A(0)}}else H([i]),A(0);await se(t)}catch(l){O(l instanceof Error?l.message:"Unknown error occurred")}finally{R(!1),q(!1)}},[]),xe=d.useCallback(async t=>{console.log("fetchAllImages called with imageIds:",t),_e(!0);try{const s=t.map(async i=>{const n=await fetch(`/api/images/${i}`);if(!n.ok)throw new Error(`Failed to fetch image ${i}`);return n.json()}),l=await Promise.all(s);H(l),A(0),console.log("fetchAllImages: Loaded",l.length,"images")}catch(s){console.error("fetchAllImages error:",s),O(s instanceof Error?s.message:"Failed to load all images")}finally{_e(!1)}},[]),We=d.useCallback(()=>{h.length>1&&A(t=>t>0?t-1:h.length-1)},[h.length]),Je=d.useCallback(()=>{h.length>1&&A(t=>t<h.length-1?t+1:0)},[h.length]),Ve=d.useCallback(t=>{t>=0&&t<h.length&&A(t)},[h.length]),ye=d.useCallback(async t=>{const s=t||(h.length>0?h[D]:e);if(s){V(!0),fe(s),pe(!0);try{const l=new Image;l.onload=()=>{V(!1)},l.onerror=()=>{V(!1)},l.src=s.image_url}catch(l){console.error("Error preloading full-size image:",l),V(!1)}}},[h,D,e]),He=d.useCallback(()=>{pe(!1),fe(null),V(!1)},[]);d.useEffect(()=>{if(console.log("MapDetailsPage: mapId from useParams:",g),console.log("MapDetailsPage: mapId type:",typeof g),console.log("MapDetailsPage: mapId value:",g),!g||g==="undefined"||g==="null"||g.trim()===""||g===void 0||g===null){console.log("MapDetailsPage: Invalid mapId, setting error"),O("Map ID is required"),R(!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(g)){console.log("MapDetailsPage: Invalid UUID format:",g),O("Invalid Map ID format"),R(!1);return}console.log("MapDetailsPage: Fetching data for mapId:",g),he(g)},[g,he]),d.useEffect(()=>{if(!e||z||U)return;if(!g||g==="undefined"||g==="null"||g.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(g)){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()),i=!y||e.source===y,n=!v||e.event_type===v,r=!j||e.countries.some($=>$.r_code===j),o=!w||e.countries.some($=>$.c_code===w),u=!I||e.image_type===I,_=!b||e.starred===!0,k=l&&i&&n&&r&&o&&u&&_;return console.log("Auto-navigation check:",{mapId:g,search:p,srcFilter:y,catFilter:v,regionFilter:j,countryFilter:w,imageTypeFilter:I,showReferenceExamples:b,matchesSearch:l,matchesSource:i,matchesCategory:n,matchesRegion:r,matchesCountry:o,matchesImageType:u,matchesReferenceExamples:_,matches:k}),k})()||(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 i=l.find(n=>{const r=!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()),o=!y||n.source===y,u=!v||n.event_type===v,_=!j||n.countries?.some(f=>f.r_code===j),k=!w||n.countries?.some(f=>f.c_code===w),$=!I||n.image_type===I,F=!b||n.starred===!0;return r&&o&&u&&_&&k&&$&&F});console.log("Auto-navigation: Found first matching image:",i?{image_id:i.image_id,title:i.title,source:i.source}:"No matching image found"),i&&i.image_id&&i.image_id!=="undefined"&&i.image_id!=="null"&&i.image_id.trim()!==""&&i.image_id!==g&&(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(i.image_id)?(console.log("Auto-navigating to:",i.image_id),x(`/map/${i.image_id}`)):console.error("Auto-navigation blocked: Invalid image_id format:",i.image_id))}).catch(console.error))},[e,p,y,v,j,w,I,b,g,x,z,U]);const se=d.useCallback(async t=>{if(!(!t||t==="undefined"||t==="null"||t.trim()===""))try{const s=new URLSearchParams;p&&s.append("search",p),y&&s.append("source",y),v&&s.append("event_type",v),j&&s.append("region",j),w&&s.append("country",w),I&&s.append("image_type",I),N&&s.append("upload_type",N),b&&s.append("starred_only","true");const l=await fetch(`/api/images/grouped?${s.toString()}`);if(l.ok){const i=await l.json();console.log("Server response for upload_type=multiple:",{url:`/api/images/grouped?${s.toString()}`,count:i.length,images:i.map(r=>({image_id:r.image_id,image_count:r.image_count,all_image_ids:r.all_image_ids,all_image_ids_length:r.all_image_ids?.length}))});const n=i.findIndex(r=>r.image_id===t);console.log("Navigation availability check (server-side):",{filteredImagesCount:i.length,currentIndex:n,currentId:t,uploadTypeFilter:N,hasPrevious:i.length>1&&n>0,hasNext:i.length>1&&n<i.length-1,filteredImages:i.map(r=>({image_id:r.image_id,image_count:r.image_count,all_image_ids:r.all_image_ids,image_type:r.image_type}))}),Le(i.length>1&&n>0),Te(i.length>1&&n<i.length-1)}}catch(s){console.error("Failed to check navigation availability:",s)}},[p,y,v,j,w,I,N,b]),ve=async t=>{if(!W){q(!0);try{const s=new URLSearchParams;p&&s.append("search",p),y&&s.append("source",y),v&&s.append("event_type",v),j&&s.append("region",j),w&&s.append("country",w),I&&s.append("image_type",I),N&&s.append("upload_type",N),b&&s.append("starred_only","true");const l=await fetch(`/api/images/grouped?${s.toString()}`);if(l.ok){const i=await l.json(),n=i.findIndex(u=>u.image_id===g);if(n===-1){console.error("Current image not found in filtered list");return}let r;t==="previous"?r=n>0?n-1:i.length-1:r=n<i.length-1?n+1:0;const o=i[r];o&&o.image_id&&o.image_id!=="undefined"&&o.image_id!=="null"&&o.image_id.trim()!==""&&(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(o.image_id)?(console.log("Carousel navigating to:",o.image_id),x(`/map/${o.image_id}`)):console.error("Carousel navigation blocked: Invalid image_id format:",o.image_id))}}catch(s){console.error("Failed to navigate to item:",s)}finally{q(!1)}}};d.useEffect(()=>{console.log("=== NAVIGATION USEEFFECT TRIGGERED ==="),console.log("Navigation useEffect triggered:",{map:!!e,mapId:g,loading:z,isDeleting:U,uploadTypeFilter:N,allFilters:{search:p,srcFilter:y,catFilter:v,regionFilter:j,countryFilter:w,imageTypeFilter:I,uploadTypeFilter:N,showReferenceExamples:b}}),e&&g&&!z&&!U?(console.log("Calling checkNavigationAvailability with:",g),se(g)):console.log("NOT calling checkNavigationAvailability because:",{map:!!e,mapId:!!g,loading:z,isDeleting:U})},[e,g,p,y,v,j,w,I,N,b,z,U,se]),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,s,l,i,n])=>{Ne(t),Ce(s),be(l),Se(i),ke(n)}).catch(console.error)},[]);const Ge=async()=>{e&&K(!0)},qe=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?ee(s=>s?{...s,starred:!s.starred}:null):console.error("Failed to toggle starred status")}catch(t){console.error("Error toggling starred status:",t)}},Ke=async()=>{if(e){Q(!0);try{if(console.log("Deleting image with ID:",e.image_id),(await fetch(`/api/images/${e.image_id}`,{method:"DELETE"})).ok){ee(s=>s?{...s,starred:!s.starred}:null),K(!1);try{const s=await fetch("/api/images/grouped");if(s.ok){const i=(await s.json()).filter(r=>{const o=!p||r.title?.toLowerCase().includes(p.toLowerCase())||r.generated?.toLowerCase().includes(p.toLowerCase())||r.source?.toLowerCase().includes(p.toLowerCase())||r.event_type?.toLowerCase().includes(p.toLowerCase()),u=!y||r.source===y,_=!v||r.event_type===v,k=!j||r.countries?.some(C=>C.r_code===j),$=!w||r.countries?.some(C=>C.c_code===w),F=!I||r.image_type===I,f=!N||N==="single"&&(!r.image_count||r.image_count<=1)||N==="multiple"&&r.image_count&&r.image_count>1,M=!b||r.starred===!0;return o&&u&&_&&k&&$&&F&&f&&M}),n=i.filter(r=>r.image_id!==e.image_id);if(n.length>0){const r=i.findIndex(u=>u.image_id===e.image_id);let o;if(r===i.length-1?o=r-1:o=r,console.log("Navigation target:",{currentIndex:r,targetIndex:o,targetId:n[o]?.image_id}),o>=0&&o<n.length){const u=n[o];u&&u.image_id&&u.image_id!=="undefined"&&u.image_id!=="null"&&u.image_id.trim()!==""?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(u.image_id)?(console.log("Navigating to:",u.image_id),x(`/map/${u.image_id}`)):(console.error("Navigation blocked: Invalid image_id format:",u.image_id),x("/explore")):(console.error("Navigation blocked: Invalid image_id:",u?.image_id),x("/explore"))}else n[0]&&n[0].image_id&&n[0].image_id!=="undefined"&&n[0].image_id!=="null"&&n[0].image_id.trim()!==""?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n[0].image_id)?(console.log("Fallback navigation to first item:",n[0].image_id),x(`/map/${n[0].image_id}`)):(console.error("Fallback navigation blocked: Invalid image_id format:",n[0].image_id),x("/explore")):(console.log("No valid remaining items, going to explore page"),x("/explore"))}else console.log("No remaining items, going to explore page"),x("/explore")}else x("/explore")}catch(s){console.error("Failed to navigate to next item:",s),x("/explore")}finally{Q(!1)}}else console.error("Delete failed"),Q(!1)}catch(t){console.error("Delete failed:",t),Q(!1)}}},c=d.useMemo(()=>{if(!e)return null;if(!p&&!y&&!v&&!j&&!w&&!I&&!N&&!b)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()),s=!y||e.source===y,l=!v||e.event_type===v,i=!j||e.countries.some(k=>k.r_code===j),n=!w||e.countries.some(k=>k.c_code===w),r=!I||e.image_type===I,o=!N||N==="single"&&(!e.image_count||e.image_count<=1)&&(!e.all_image_ids||e.all_image_ids.length<=1)||N==="multiple"&&(e.image_count&&e.image_count>1||e.all_image_ids&&e.all_image_ids.length>1),u=!b||e.starred===!0,_=t&&s&&l&&i&&n&&r&&o&&u;return!_&&(p||y||v||j||w||I||N||b)?(setTimeout(()=>{Ze()},100),e):_?e:null},[e,p,y,v,j,w,I,N,b]),Ze=d.useCallback(async()=>{R(!0);try{const t=new URLSearchParams;p&&t.append("search",p),y&&t.append("source",y),v&&t.append("event_type",v),j&&t.append("region",j),w&&t.append("country",w),I&&t.append("image_type",I),N&&t.append("upload_type",N),b&&t.append("starred_only","true");const s=await fetch(`/api/images/grouped?${t.toString()}`);if(s.ok){const l=await s.json();if(l.length>0){const i=l[0];i&&i.image_id&&x(`/map/${i.image_id}`)}else x("/explore")}}catch(t){console.error("Failed to navigate to matching image:",t),x("/explore")}finally{R(!1)}},[p,y,v,j,w,I,N,b,x]),Qe=()=>{if(!e)return;if(!e.all_image_ids||e.all_image_ids.length<=1){const i=`/upload?step=1&contribute=true&imageIds=${[e.image_id].join(",")}`;x(i);return}const s=`/upload?step=1&contribute=true&imageIds=${e.all_image_ids.join(",")}`;x(s)},T=(t,s)=>({image:`images/${s}`,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){ae(!0),te(!1);try{const s=(await oa(async()=>{const{default:o}=await import("./jszip.min-DyaOnsxL.js").then(u=>u.j);return{default:o}},__vite__mapDeps([0,1,2]))).default,l=new s;if(e.image_type==="crisis_map"){const o=l.folder("crisis_maps_dataset"),u=o?.folder("images");if(u)try{const _=e.image_count&&e.image_count>1?e.all_image_ids||[e.image_id]:[e.image_id],k=_.map(async(f,M)=>{try{const C=await fetch(`/api/images/${f}/file`);if(!C.ok)throw new Error(`Failed to fetch image ${f}`);const S=await C.blob(),X=e.file_key.split(".").pop()||"jpg",B=`0001_${String(M+1).padStart(2,"0")}.${X}`;return u.file(B,S),{success:!0,fileName:B,imageId:f}}catch(C){return console.error(`Failed to process image ${f}:`,C),{success:!1,fileName:"",imageId:f}}}),F=(await Promise.all(k)).filter(f=>f.success);if(F.length===0)throw new Error("No images could be processed");if(t==="fine-tuning"){const f=[],M=[],C=[],S=F.map(Ye=>`images/${Ye.fileName}`),X=Math.random(),B={image:S.length===1?S[0]:S,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}};X<E/100?f.push(B):X<(E+J)/100?M.push(B):C.push(B),o&&(o.file("train.jsonl",JSON.stringify(f,null,2)),o.file("test.jsonl",JSON.stringify(M,null,2)),o.file("val.jsonl",JSON.stringify(C,null,2)))}else{const f=F.map(C=>`images/${C.fileName}`),M={image:f.length===1?f[0]:f,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}};o&&o.file("0001.json",JSON.stringify(M,null,2))}}catch(_){throw console.error(`Failed to process image ${e.image_id}:`,_),_}}else if(e.image_type==="drone_image"){const o=l.folder("drone_images_dataset"),u=o?.folder("images");if(u)try{const _=await fetch(`/api/images/${e.image_id}/file`);if(!_.ok)throw new Error(`Failed to fetch image ${e.image_id}`);const k=await _.blob(),F=`0001.${e.file_key.split(".").pop()||"jpg"}`;if(u.file(F,k),t==="fine-tuning"){const f=[],M=[],C=[];if(String(e?.image_type)==="crisis_map"){const S=Math.random();S<E/100?f.push(T(e,"0001")):S<(E+J)/100?M.push(T(e,"0001")):C.push(T(e,"0001"))}else if(String(e?.image_type)==="drone_image"){const S=Math.random();S<E/100?f.push(T(e,"0001")):S<(E+J)/100?M.push(T(e,"0001")):C.push(T(e,"0001"))}o&&(o.file("train.jsonl",JSON.stringify(f,null,2)),o.file("test.jsonl",JSON.stringify(M,null,2)),o.file("val.jsonl",JSON.stringify(C,null,2)))}else{const f={image:`images/${F}`,caption:e.edited||e.generated||"",metadata:{image_id:e.image_count&&e.image_count>1?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}};o&&o.file("0001.json",JSON.stringify(f,null,2))}}catch(_){throw console.error(`Failed to process image ${e.image_id}:`,_),_}}else{const o=l.folder("generic_dataset"),u=o?.folder("images");if(u)try{const _=await fetch(`/api/images/${e.image_id}/file`);if(!_.ok)throw new Error(`Failed to fetch image ${e.image_id}`);const k=await _.blob(),F=`0001.${e.file_key.split(".").pop()||"jpg"}`;if(u.file(F,k),t==="fine-tuning"){const f=[],M=[],C=[];if(String(e?.image_type)==="crisis_map"){const S=Math.random();S<E/100?f.push(T(e,"0001")):S<(E+J)/100?M.push(T(e,"0001")):C.push(T(e,"0001"))}else if(String(e?.image_type)==="drone_image"){const S=Math.random();S<E/100?f.push(T(e,"0001")):S<(E+J)/100?M.push(T(e,"0001")):C.push(T(e,"0001"))}o&&(o.file("train.jsonl",JSON.stringify(f,null,2)),o.file("test.jsonl",JSON.stringify(M,null,2)),o.file("val.jsonl",JSON.stringify(C,null,2)))}else{const f={image:`images/${F}`,caption:e.edited||e.generated||"",metadata:{image_id:e.image_count&&e.image_count>1?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}};o&&o.file("0001.json",JSON.stringify(f,null,2))}}catch(_){throw console.error(`Failed to process image ${e.image_id}:`,_),_}}const i=await l.generateAsync({type:"blob"}),n=URL.createObjectURL(i),r=document.createElement("a");r.href=n,r.download=`dataset_${e.image_type}_${e.image_id}_${t}_${new Date().toISOString().split("T")[0]}.zip`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n),console.log(`Exported ${e.image_type} dataset with 1 image in ${t} mode`),te(!0)}catch(s){console.error("Export failed:",s),alert("Failed to export dataset. Please try again.")}finally{ae(!1)}}};return z?a.jsx(Y,{children:a.jsx("div",{className:m.loadingContainer,children:a.jsxs("div",{className:"flex flex-col items-center gap-4",children:[a.jsx(je,{className:"text-ifrcRed"}),a.jsx("div",{children:"Loading map details..."})]})})}):le||!e?a.jsx(Y,{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:le||"Map not found"}),a.jsx(L,{name:"back-to-explore",variant:"secondary",onClick:()=>x("/explore"),children:"Return to Explore"})]})})}):a.jsxs(Y,{children:[a.jsxs("div",{className:"max-w-7xl mx-auto",children:[a.jsxs("div",{className:m.tabSelector,children:[a.jsx(sa,{name:"map-details-view",value:re,onChange:t=>{(t==="mapDetails"||t==="explore")&&(Ie(t),t==="explore"&&x("/explore"))},options:Be,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(L,{name:"reference-examples",variant:b?"primary":"secondary",onClick:()=>Oe(!b),className:"whitespace-nowrap",children:[a.jsx("span",{className:"mr-2",children:b?a.jsx("span",{className:"text-yellow-400",children:"β˜…"}):a.jsx("span",{className:"text-yellow-400",children:"β˜†"})}),"Reference Examples"]})}),a.jsx(L,{name:"export-dataset",variant:"secondary",onClick:()=>Z(!0),children:"Export"})]})]}),a.jsx(la,{sources:ce,types:de,regions:me,countries:De,imageTypes:ge,isLoadingFilters:!1}),re==="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||h.length>1?a.jsxs("div",{className:m.carouselContainer,children:[a.jsx("div",{className:m.carouselImageWrapper,children:G?a.jsxs("div",{className:m.imagePlaceholder,children:[a.jsx(je,{className:"text-ifrcRed"}),a.jsx("div",{children:"Loading images..."})]}):h[D]?.detail_url?a.jsx("img",{src:h[D].detail_url,alt:h[D].file_key,className:m.carouselImage,onError:t=>{console.log("MapDetailsPage: Detail image failed to load, falling back to original:",h[D].detail_url);const s=t.target;h[D].image_url&&(s.src=h[D].image_url)},onLoad:()=>console.log("MapDetailsPage: Detail image loaded successfully:",h[D].detail_url)}):h[D]?.image_url?a.jsx("img",{src:h[D].image_url,alt:h[D].file_key,className:m.carouselImage,onLoad:()=>console.log("MapDetailsPage: Original image loaded successfully:",h[D].image_url)}):a.jsx("div",{className:m.imagePlaceholder,children:"No image available"})}),a.jsxs("div",{className:m.carouselNavigation,children:[a.jsx(L,{name:"previous-image",variant:"tertiary",size:1,onClick:We,disabled:G,className:m.carouselButton,children:a.jsx(ie,{className:"w-4 h-4"})}),a.jsx("div",{className:m.carouselIndicators,children:h.map((t,s)=>a.jsx("button",{onClick:()=>Ve(s),className:`${m.carouselIndicator} ${s===D?m.carouselIndicatorActive:""}`,disabled:G,children:s+1},s))}),a.jsx(L,{name:"next-image",variant:"tertiary",size:1,onClick:Je,disabled:G,className:m.carouselButton,children:a.jsx(ne,{className:"w-4 h-4"})})]}),a.jsx("div",{className:m.viewImageButtonContainer,children:a.jsx(L,{name:"view-full-size-carousel",variant:"secondary",size:1,onClick:()=>ye(h[D]),disabled:G||!h[D]?.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 s=t.target;c.image_url&&(s.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(L,{name:"view-full-size-single",variant:"secondary",size:1,onClick:()=>ye(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:ce.find(t=>t.s_code===c.source)?.label||c.source}),a.jsx("span",{className:m.metadataTag,children:de.find(t=>t.t_code===c.event_type)?.label||c.event_type}),a.jsx("span",{className:m.metadataTag,children:ge.find(t=>t.image_type===c.image_type)?.label||c.image_type}),c.countries&&c.countries.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:m.metadataTag,children:me.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:"AI Generated Content",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,i)=>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},i):a.jsx("p",{className:"mb-2",children:l.trim()},i))})})}):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:[Me&&a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(L,{name:"previous-item",variant:"tertiary",size:1,className:`bg-white/90 hover:bg-white shadow-lg border border-gray-200 ${W?"opacity-50 cursor-not-allowed":"hover:scale-110"}`,onClick:()=>ve("previous"),disabled:W,children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs("div",{className:"flex -space-x-1",children:[a.jsx(ie,{className:"w-4 h-4"}),a.jsx(ie,{className:"w-4 h-4"})]}),a.jsx("span",{className:"font-semibold",children:"Previous"})]})})}),oe&&a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(L,{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:Ge,title:"Delete","aria-label":"Delete saved image",children:a.jsx(ia,{className:"w-4 h-4"})})}),a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(L,{name:"contribute",onClick:Qe,children:"Contribute"})}),oe&&a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(L,{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:qe,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?"β˜…":"β˜†"})})}),Fe&&a.jsx(P,{withInternalPadding:!0,className:"rounded-md p-2",children:a.jsx(L,{name:"next-item",variant:"tertiary",size:1,className:`bg-white/90 hover:bg-white shadow-lg border border-gray-200 ${W?"opacity-50 cursor-not-allowed":"hover:scale-110"}`,onClick:()=>ve("next"),disabled:W,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(ne,{className:"w-4 h-4"}),a.jsx(ne,{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(L,{name:"clear-filters",variant:"secondary",onClick:Ue,children:"Clear Filters"})})]})}):null]}),Pe&&a.jsx("div",{className:m.fullSizeModalOverlay,onClick:()=>K(!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(L,{name:"confirm-delete",variant:"secondary",onClick:Ke,children:"Delete"}),a.jsx(L,{name:"cancel-delete",variant:"tertiary",onClick:()=>K(!1),children:"Cancel"})]})]})})}),ue&&a.jsx(ca,{isOpen:ue,onClose:()=>{Z(!1),te(!1),ae(!1)},onExport:(t,s)=>{s.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:Ee,exportSuccess:$e,variant:"single",onNavigateToList:()=>{Z(!1),x("/explore")},onNavigateAndExport:()=>{Z(!1),x("/explore?export=true")}}),a.jsx(na,{isOpen:Re,imageUrl:Ae?.image_url||null,preview:null,selectedImageData:null,onClose:He,isLoading:ze})]})}export{st as default};
py_backend/static/assets/{index-Crh8pvny.js β†’ index-DkcyG4dA.js} RENAMED
The diff for this file is too large to render. See raw diff
 
py_backend/static/assets/{index-DqzwKHtN.js β†’ index-HP450hkZ.js} RENAMED
@@ -1 +1 @@
1
- import{r as s,y as nt,t as ht,a as q,c as gt,j as e,o as N,b as se,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-Crh8pvny.js";const kt=({title:m,titleId:a,...h})=>s.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?s.createElement("title",{id:a},m):null,s.createElement("g",{clipPath:"url(#arrow-drop-down-line_svg__a)"},s.createElement("path",{d:"m12 15-4.243-4.243 1.415-1.414L12 12.172l2.828-2.83 1.415 1.415L12 15Z"})),s.createElement("defs",null,s.createElement("clipPath",{id:"arrow-drop-down-line_svg__a"},s.createElement("path",{d:"M0 0h24v24H0z"})))),Lt=({title:m,titleId:a,...h})=>s.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?s.createElement("title",{id:a},m):null,s.createElement("g",{clipPath:"url(#arrow-drop-up-line_svg__a)"},s.createElement("path",{d:"m12 11.828-2.828 2.829-1.415-1.414L12 9l4.243 4.243-1.415 1.414L12 11.828Z"})),s.createElement("defs",null,s.createElement("clipPath",{id:"arrow-drop-up-line_svg__a"},s.createElement("path",{d:"M0 0h24v24H0z"})))),Pt=({title:m,titleId:a,...h})=>s.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?s.createElement("title",{id:a},m):null,s.createElement("g",{clipPath:"url(#information-line_svg__a)"},s.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"})),s.createElement("defs",null,s.createElement("clipPath",{id:"information-line_svg__a"},s.createElement("path",{d:"M0 0h24v24H0z"})))),Rt=({title:m,titleId:a,...h})=>s.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?s.createElement("title",{id:a},m):null,s.createElement("path",{fillRule:"evenodd",d:"m15.063 12 .937.938-4 4-4-4L8.938 12 12 15.063 15.063 12Z",clipRule:"evenodd"}),s.createElement("mask",{id:"table-sorting-line_svg__a",width:8,height:5,x:8,y:12,maskUnits:"userSpaceOnUse",style:{maskType:"luminance"}},s.createElement("path",{fillRule:"evenodd",d:"m15.063 12 .937.938-4 4-4-4L8.938 12 12 15.063 15.063 12Z",clipRule:"evenodd"})),s.createElement("g",{mask:"url(#table-sorting-line_svg__a)"},s.createElement("path",{d:"M-24-22h72v72h-72z"})),s.createElement("path",{fillRule:"evenodd",d:"M8.938 11 8 10.062l4-4 4 4-.938.938L12 7.937 8.937 11Z",clipRule:"evenodd"}),s.createElement("mask",{id:"table-sorting-line_svg__b",width:8,height:5,x:8,y:6,maskUnits:"userSpaceOnUse",style:{maskType:"luminance"}},s.createElement("path",{fillRule:"evenodd",d:"M8.938 11 8 10.062l4-4 4 4-.938.938L12 7.937 8.937 11Z",clipRule:"evenodd"})),s.createElement("g",{mask:"url(#table-sorting-line_svg__b)"},s.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:r,compact:f,currency:g,value:b,tooltip:_,unit:y,prefix:x,suffix:w,maximumFractionDigits:C=1}=m,{currentLanguage:j}=s.useContext(ht),v=s.useMemo(()=>{if(q(b))return h;const S=gt(b,{currency:g,compact:f,separatorHidden:r,maximumFractionDigits:C,unit:y,language:j});return e.jsxs(e.Fragment,{children:[x,S,w]})},[h,b,f,r,g,y,C,x,j,w]);return e.jsx("div",{className:N(Bt.numberOutput,a),title:se(_)?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:r,preferredWidth:f}=m,[g,b]=s.useState(!1),[_,y]=s.useState(!1),x=s.useRef(),w=s.useRef(null);return s.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:r})})]})}function $(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:r}=m,f=rt(Ut);let g;return r===!0?g=f.booleanYesLabel:r===!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:r,invalidText:f}=m,g=s.useMemo(()=>ft(a,h),[a,h]);return e.jsx("div",{className:N(Gt.dateOutput,r),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=s.useRef(null),{className:h,popupClassName:r,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=s.useRef(null),[k,I]=s.useState(!1);s.useEffect(()=>{C&&(C.current={setShowDropdown:I})},[C,I]);const R=s.useCallback(()=>{I(re=>!re)},[I]),T=s.useCallback((re,ae)=>{ae||re&&v||I(!1)},[I,v]);vt(k,T,p,j);const G=s.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,k&&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&&(k?e.jsx(xt,{className:le.dropdownIcon}):e.jsx(_t,{className:le.dropdownIcon}))]}):void 0,icons:_,children:g}),k&&e.jsx(st,{elementRef:p,className:N(le.dropdownContent,r),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:r,title:f,description:g,withoutIcon:b,popupClassName:_,descriptionClassName:y}=m;return e.jsx(na,{label:e.jsxs("div",{className:ge.label,children:[r,!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:r,totalValue:f,value:g,showPercentageInTitle:b,children:_,color:y="var(--go-ui-color-primary-red)"}=m,x=se(g)?g:0,w=se(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}})}),r&&e.jsx("div",{className:fe.description,children:r}),_]})}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:r,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,r),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:r,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 k=v;return S.valueType==="number"?k=e.jsx(we,{...S,invalidText:v}):S.valueType==="date"?k=e.jsx(Yt,{...S,invalidText:v}):S.valueType==="boolean"?k=e.jsx(Zt,{...S,invalidText:v}):p instanceof Date||(k=p||v),e.jsxs("div",{className:N(ee.textOutput,j&&ee.withBackground,a),children:[r,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:k}),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 r=h;const f=r-a===360;f&&(r-=1);const g=Je(m,a),b=Je(m,r),_=r-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:r,labelSelector:f,keySelector:g,colorSelector:b,colors:_,pieRadius:y=Ea,chartPadding:x=Ta,legendClassName:w,showPercentageInLegend:C}=m,j=Ct(h?.map(p=>r(p))),v=q(j)||j===0?1:j,S=s.useMemo(()=>{let p=0;const k=h?.map(I=>{const R=r(I);if(q(R))return;const T=360*(R/v);return p+=T,{key:g(I),value:R,label:f(I),startAngle:p-T,percentage:yt(R,v),endAngle:p,datum:I}}).filter(se)??[];return b?k.map(({datum:I,...R})=>({...R,color:b(I)})):k.map(({datum:I,...R},T)=>({...R,color:_[T%_.length]}))},[h,g,r,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,...r}=m;return e.jsx("td",{className:N(a,Pa.td),...r,children:h})}function it(m){const{className:a,children:h,...r}=m;return e.jsx("tr",{className:a,...r,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:r,rowClassName:f,cellClassName:g,rowModifier:b}=m;return e.jsx(e.Fragment,{children:a?.map((_,y)=>{const x=h(_,y),w=r.map(v=>{const{id:S,cellRenderer:p,cellRendererClassName:k,cellRendererParams:I,cellContainerClassName:R}=v,T=I(x,_,y,a),G=e.jsx(p,{className:k,...T,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:r,datum:_})),e.jsx(s.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:r,onResizeComplete:f,name:g,...b}=m,_=s.useRef(null),y=s.useRef(),x=s.useRef(),w=s.useRef(),C=s.useCallback(v=>{var S;if(se(y.current)&&_.current&&r){v.preventDefault(),v.stopPropagation();const p=v.clientX-y.current;if(se(x.current)){const k=x.current+p;w.current=k,r(k,g)}else x.current=(S=_.current)==null?void 0:S.offsetWidth}},[r,g]),j=s.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 s.useEffect(()=>{const v=()=>{y.current=void 0,x.current=void 0,f&&se(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:[r&&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 B(m){const{data:a,keySelector:h,columns:r,caption:f,className:g,captionClassName:b,headerRowClassName:_,headerCellClassName:y,rowClassName:x,cellClassName:w,rowModifier:C,fixedColumnWidth:j,resizableColumn:v,headersHidden:S,pending:p,filtered:k,errored:I=!1}=m,R=s.useRef(null),[T]=he.useState(()=>bt()),[G,U]=he.useState({});s.useEffect(()=>{U(W=>{if(q(R.current))return W;const E=R.current.getBoundingClientRect(),{width:O}=E;let A=r.map(M=>({id:M.id,stretch:!!M.columnStretch,width:qa(M,W[M.id])}));const X=ye(A.filter(M=>M.stretch).map(M=>M.width)),ne=ye(A.filter(M=>!M.stretch).map(M=>M.width)),Y=(O-ne)/X;return Y>1&&(A=A.map(M=>({...M,width:M.stretch?M.width*Y:M.width}))),jt(A,M=>M.id,M=>M.width)})},[r]);const re=he.useCallback((W,E)=>{const O=document.getElementById(`${T}-${E}`),A=Math.max(W,80);if(q(O)||(O.style.width=`${A}px`,!j))return;const X=document.getElementById(T);if(q(X))return;const ne=ye(r.map(Y=>Y.id===E?A:G[Y.id]));X.style.width=`${ne}px`},[T,G,r,j]),ae=he.useCallback((W,E)=>{se(E)&&U(O=>({...O,[E]:Math.max(W,80)}))},[U]),be=he.useMemo(()=>ye(r.map(W=>G[W.id])),[G,r]),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:T,children:[f&&e.jsx("caption",{className:b,children:f}),e.jsx("colgroup",{children:r.map(W=>{const{id:E,columnClassName:O}=W,A=G[E],X=j?{width:`${A}px`}:void 0;return e.jsx("col",{id:`${T}-${E}`,style:X,className:N(ce.column,O)},E)})}),!S&&e.jsx("thead",{children:e.jsx(it,{className:N(ce.headerRow,_),children:r.map((W,E)=>{const{id:O,title:A,headerCellRenderer:X,headerCellRendererClassName:ne,headerCellRendererParams:Y,headerContainerClassName:M}=W,ie=e.jsx(X,{...Y,name:O,title:A,index:E,className:N(ne,ce.headerComponent)});return e.jsx(Ha,{scope:"col",name:O,onResize:v?re:void 0,onResizeComplete:v?ae:void 0,className:N(ce.headerElement,typeof y=="function"?y(O):y,M),children:ie},O)})})}),e.jsx("tbody",{children:e.jsx(Aa,{data:a,keySelector:h,columns:r,rowClassName:x,cellClassName:w,rowModifier:C})})]})}),e.jsx(Nt,{filtered:k,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:r,name:f,sortable:g,defaultSortDirection:b="asc",infoTitle:_,infoDescription:y}=m,{sorting:x,setSorting:w}=s.useContext(St),C=rt(Xa),j=x?.name===f?x.direction:void 0,v=s.useRef(null),S=s.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:r}),_&&y&&e.jsx(ca,{className:de.infoPopupIcon,title:_,description:y})]})}const at={};function Q(m,a,h,r){return{id:m,title:a,columnClassName:r?.columnClassName,headerCellRenderer:ot,headerCellRendererClassName:r?.headerCellRendererClassName,headerContainerClassName:r?.headerContainerClassName,headerCellRendererParams:{sortable:r?.sortable,infoTitle:r?.headerInfoTitle,infoDescription:r?.headerInfoDescription},cellRendererClassName:r?.cellRendererClassName,cellContainerClassName:r?.cellContainerClassName,cellRenderer:Ga,cellRendererParams:(f,g)=>({value:h(g)||"--"}),valueSelector:h,valueComparator:(f,g)=>Mt(h(f),h(g)),columnWidth:r?.columnWidth,columnStretch:r?.columnStretch,columnStyle:r?.columnStyle}}function D(m,a,h,r){return{id:m,title:a,columnClassName:r?.columnClassName,headerCellRenderer:ot,headerCellRendererClassName:N(at.numberCellHeader,r?.headerCellRendererClassName),headerContainerClassName:r?.headerContainerClassName,headerCellRendererParams:{sortable:r?.sortable,infoTitle:r?.headerInfoTitle,infoDescription:r?.headerInfoDescription},cellRendererClassName:N(at.numberCell,r?.cellRendererClassName),cellContainerClassName:r?.cellContainerClassName,cellRenderer:we,cellRendererParams:(f,g)=>({value:h(g),suffix:r?.suffix,maximumFractionDigits:r?.maximumFractionDigits,invalidText:"--"}),valueSelector:h,valueComparator:(f,g)=>It(h(f),h(g)),columnWidth:r?.columnWidth,columnStretch:r?.columnStretch,columnStyle:r?.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",c={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]=s.useState(null),[r,f]=s.useState(!0),[g,b]=s.useState("crisis_maps"),[_,y]=s.useState([]),[x,w]=s.useState([]),[C,j]=s.useState([]),[v,S]=s.useState([]),[p,k]=s.useState(!1),[I,R]=s.useState(!1),[T,G]=s.useState(!1),[U,re]=s.useState(!1),[ae,be]=s.useState(!1),[K,W]=s.useState(!1),E=t=>{k(t==="editTime"),R(t==="percentage"),G(t==="delete"),re(t==="regions"),be(t==="sources"),W(t==="types")},O=[{key:"crisis_maps",label:"Crisis Maps"},{key:"drone_images",label:"Drone Images"}],A=s.useCallback((t,l)=>{if(!t||!l)return 0;const i=t.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(u=>u.length>0),n=l.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(u=>u.length>0);if(i.length===0&&n.length===0)return 1;if(i.length===0||n.length===0)return 0;const o=new Set(i),d=new Set(n),P=new Set([...o].filter(u=>d.has(u))),F=new Set([...o,...d]);return P.size/F.size},[]),X=s.useCallback(async()=>{f(!0);try{const l=await(await fetch("/api/images")).json(),i={},n=l.filter(u=>u.image_type==="crisis_map"),o=l.filter(u=>u.image_type==="drone_image"),d={totalCaptions:l.length,sources:{},types:{},regions:{},models:{},modelEditTimes:i,percentageModified:0,modelPercentageData:{},totalDeleteCount:0,deleteRate:0,crisisMaps:n,droneImages:o};l.forEach(u=>{if(u.source&&(d.sources[u.source]=(d.sources[u.source]||0)+1),u.event_type&&(d.types[u.event_type]=(d.types[u.event_type]||0)+1),u.countries&&u.countries.forEach(L=>{L.r_code&&(d.regions[L.r_code]=(d.regions[L.r_code]||0)+1)}),u.model){const L=u.model,V=d.models[L]||={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&&(i[L]||(i[L]=[]),i[L].push(Ce))}}}),_.forEach(u=>{u.s_code&&!d.sources[u.s_code]&&(d.sources[u.s_code]=0)}),x.forEach(u=>{u.t_code&&!d.types[u.t_code]&&(d.types[u.t_code]=0)}),C.forEach(u=>{u.r_code&&!d.regions[u.r_code]&&(d.regions[u.r_code]=0)}),["GPT-4","Claude","Gemini","Llama","Other"].forEach(u=>{d.models[u]||(d.models[u]={count:0,avgAccuracy:0,avgContext:0,avgUsability:0,totalScore:0,deleteCount:0})}),Object.values(d.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 F=l.filter(u=>u.generated&&u.edited);if(F.length>0){const L=[...F.map(oe=>A(oe.generated,oe.edited))].sort((oe,Ce)=>oe-Ce),V=Math.floor(L.length/2),te=L.length%2===0?(L[V-1]+L[V])/2:L[V];d.percentageModified=Math.round((1-te)*100)}const H={};l.forEach(u=>{if(u.model&&u.generated&&u.edited){const L=A(u.generated,u.edited),V=Math.round((1-L)*100);H[u.model]||(H[u.model]=[]),H[u.model].push(V)}}),d.modelPercentageData=H;try{const u=await fetch("/api/models");if(u.ok){const L=await u.json();if(L.models){L.models.forEach(te=>{d.models[te.m_code]&&(d.models[te.m_code].deleteCount=te.delete_count||0)});const V=L.models.reduce((te,oe)=>te+(oe.delete_count||0),0);d.totalDeleteCount=V,d.deleteRate=V>0?Math.round(V/(V+l.length)*100):0}}}catch(u){console.log("Could not fetch model delete counts:",u)}h(d)}catch{h(null)}finally{f(!1)}},[_,x,C,A]),ne=s.useCallback(async()=>{try{const[t,l,i,n]=await Promise.all([fetch("/api/sources"),fetch("/api/types"),fetch("/api/regions"),fetch("/api/models")]),o=await t.json(),d=await l.json(),P=await i.json(),F=await n.json();y(o),w(d),j(P),S(F.models||[])}catch(t){console.log("Could not fetch lookup data:",t)}},[]);s.useEffect(()=>{const t=m.get("view");(t==="crisis_maps"||t==="drone_images")&&b(t)},[m]),s.useEffect(()=>{ne()},[ne]),s.useEffect(()=>{_.length>0&&x.length>0&&C.length>0&&v.length>0&&X()},[_,x,C,v,X]);const Y=s.useCallback(t=>{const l=_.find(i=>i.s_code===t);return l?l.label:t},[_]),M=s.useCallback(t=>{if(t.length===0)return 0;const l=[...t].sort((n,o)=>n-o),i=Math.floor(l.length/2);return l.length%2===0?Math.round((l[i-1]+l[i])/2):l[i]},[]),ie=s.useCallback(t=>{const l=Math.floor(t/1e3),i=Math.floor(l/60),n=Math.floor(i/60);return n>0?`${n}h ${i%60}m`:i>0?`${i}m ${l%60}s`:`${l}s`},[]),_e=s.useCallback(t=>{const l=x.find(i=>i.t_code===t);return l?l.label:t},[x]),J=s.useCallback(t=>{const l=v.find(i=>i.m_code===t);return l?l.label:t},[v]),Se=s.useMemo(()=>a?Object.entries(a.modelEditTimes||{}).filter(([,t])=>t.length>0).sort(([,t],[,l])=>M(l)-M(t)).map(([t,l],i)=>({id:i+1,name:J(t),count:l.length,avgEditTime:M(l),minEditTime:Math.min(...l),maxEditTime:Math.max(...l)})):[],[a,M,J]),Me=s.useMemo(()=>a?Object.entries(a.modelPercentageData||{}).filter(([,t])=>t.length>0).sort(([,t],[,l])=>{const i=[...t].sort((H,u)=>H-u),n=[...l].sort((H,u)=>H-u),o=Math.floor(i.length/2),d=Math.floor(n.length/2),P=i.length%2===0?(i[o-1]+i[o])/2:i[o];return(n.length%2===0?(n[d-1]+n[d])/2:n[d])-P}).map(([t,l],i)=>{const n=[...l].sort((P,F)=>P-F),o=Math.floor(n.length/2),d=n.length%2===0?Math.round((n[o-1]+n[o])/2):n[o];return{id:i+1,name:J(t),count:l.length,avgPercentageModified:d,minPercentageModified:Math.min(...l),maxPercentageModified:Math.max(...l)}}):[],[a,J]),Ie=s.useMemo(()=>a?Object.entries(a.models).filter(([,t])=>t.count>0).map(([t,l],i)=>{const n=[l.avgAccuracy,l.avgContext,l.avgUsability],o=n.reduce((F,H)=>F+H,0)/n.length,d=n.reduce((F,H)=>F+Math.pow(H-o,2),0)/n.length,P=Math.round(100-Math.sqrt(d));return{id:i+1,name:J(t),consistency:Math.max(0,P),avgScore:Math.round(o),count:l.count}}).sort((t,l)=>l.consistency-t.consistency):[],[a,J]),De=s.useMemo(()=>[Q("name","Region",t=>t.name),D("count","Count",t=>t.count),D("percentage","% of Total",t=>t.percentage,{suffix:"%",maximumFractionDigits:0})],[]),Ee=s.useMemo(()=>[Q("name","Type",t=>t.name),D("count","Count",t=>t.count),D("percentage","% of Total",t=>t.percentage,{suffix:"%",maximumFractionDigits:0})],[]),lt=s.useMemo(()=>[Q("name","Source",t=>t.name),D("count","Count",t=>t.count),D("percentage","% of Total",t=>t.percentage,{suffix:"%",maximumFractionDigits:0})],[]),Te=s.useMemo(()=>[Q("name","Model",t=>t.name),D("count","Count",t=>t.count),D("accuracy","Accuracy",t=>t.accuracy,{suffix:"%",maximumFractionDigits:0}),D("context","Context",t=>t.context,{suffix:"%",maximumFractionDigits:0}),D("usability","Usability",t=>t.usability,{suffix:"%",maximumFractionDigits:0}),D("totalScore","Total Score",t=>t.totalScore,{suffix:"%",maximumFractionDigits:0})],[]),ke=s.useMemo(()=>[Q("name","Model",t=>t.name),D("count","Count",t=>t.count),Q("avgEditTime","Median Edit Time",t=>ie(t.avgEditTime)),Q("minEditTime","Min Edit Time",t=>ie(t.minEditTime)),Q("maxEditTime","Max Edit Time",t=>ie(t.maxEditTime))],[]),Le=s.useMemo(()=>[Q("name","Model",t=>t.name),D("count","Count",t=>t.count),D("avgPercentageModified","Median % Modified",t=>t.avgPercentageModified,{suffix:"%",maximumFractionDigits:0}),D("minPercentageModified","Min % Modified",t=>t.minPercentageModified,{suffix:"%",maximumFractionDigits:0}),D("maxPercentageModified","Max % Modified",t=>t.maxPercentageModified,{suffix:"%",maximumFractionDigits:0})],[]),Pe=s.useMemo(()=>[Q("name","Model",t=>t.name),D("count","Total Count",t=>t.count),D("deleteCount","Delete Count",t=>t.deleteCount),D("deleteRate","Delete Rate",t=>t.deleteRate,{suffix:"%",maximumFractionDigits:1})],[]),ct=s.useMemo(()=>[Q("source","Source",t=>t.source),D("avgQuality","Average Quality",t=>t.avgQuality,{suffix:"%",maximumFractionDigits:0}),D("count","Count",t=>t.count)],[]),Re=s.useMemo(()=>[Q("eventType","Event Type",t=>t.eventType),D("avgQuality","Average Quality",t=>t.avgQuality,{suffix:"%",maximumFractionDigits:0}),D("count","Count",t=>t.count)],[]),$e=s.useMemo(()=>[Q("name","Model",t=>t.name),D("consistency","Consistency",t=>t.consistency,{suffix:"%",maximumFractionDigits:0}),D("avgScore","Average Score",t=>t.avgScore,{suffix:"%",maximumFractionDigits:0}),D("count","Count",t=>t.count)],[]),ue=s.useCallback(t=>a?t==="crisis_map"?a.crisisMaps.length:t==="drone_image"?a.droneImages.length:0:0,[a]),Be=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.countries&&n.countries.forEach(o=>{o.r_code&&(i[o.r_code]=(i[o.r_code]||0)+1)})}),Object.entries(i).filter(([,n])=>n>0).map(([n,o])=>({name:C.find(d=>d.r_code===n)?.label||n,value:o}))},[a,C]),Ae=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};l.forEach(o=>{o.countries&&o.countries.forEach(d=>{d.r_code&&(i[d.r_code]=(i[d.r_code]||0)+1)})});const n=C.reduce((o,d)=>(d.r_code&&(o[d.r_code]={name:d.label,count:i[d.r_code]||0}),o),{});return Object.entries(n).sort(([,o],[,d])=>d.count-o.count).map(([,{name:o,count:d}],P)=>({id:P+1,name:o,count:d,percentage:l.length>0?Math.round(d/l.length*100):0}))},[a,C]),dt=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.source&&(i[n.source]=(i[n.source]||0)+1)}),Object.entries(i).filter(([,n])=>n>0).map(([n,o])=>({name:_.find(d=>d.s_code===n)?.label||n,value:o}))},[a,_]),ut=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.source&&(i[n.source]=(i[n.source]||0)+1)}),Object.entries(i).sort(([,n],[,o])=>o-n).map(([n,o],d)=>({id:d+1,name:Y(n),count:o,percentage:l.length>0?Math.round(o/l.length*100):0}))},[a,Y]),Fe=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.event_type&&(i[n.event_type]=(i[n.event_type]||0)+1)}),Object.entries(i).filter(([,n])=>n>0).map(([n,o])=>({name:x.find(d=>d.t_code===n)?.label||n,value:o}))},[a,x]),Oe=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.event_type&&(i[n.event_type]=(i[n.event_type]||0)+1)}),Object.entries(i).sort(([,n],[,o])=>o-n).map(([n,o],d)=>({id:d+1,name:_e(n),count:o,percentage:l.length>0?Math.round(o/l.length*100):0}))},[a,_e]),He=s.useCallback(t=>{if(!a)return"No data available";const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i=new Set;l.forEach(d=>{d.model&&i.add(d.model)}),console.log(`Debug ${t}:`,{totalImages:l.length,usedModels:Array.from(i),availableEditTimes:Object.keys(a.modelEditTimes),modelEditTimesData:a.modelEditTimes});const o=Object.entries(a.modelEditTimes).filter(([d])=>i.has(d)).flatMap(([,d])=>d);return o.length===0?"No data available":ie(M(o))},[a,ie,M]),Ve=s.useCallback(()=>{if(!a)return"No data available";const t=a.totalCaptions||0,l=a.percentageModified||0;return t>0?Math.round(l/t*100):0},[a]),ze=s.useCallback(()=>a&&a.deleteRate>=0?`${a.deleteRate}%`:"No data available",[a]),Ue=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i=new Set;return l.forEach(o=>{o.model&&i.add(o.model)}),Se.filter(o=>{const d=v.find(P=>P.label===o.name)?.m_code;return d&&i.has(d)})},[a,Se,v]),We=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i=new Set;return l.forEach(o=>{o.model&&i.add(o.model)}),Me.filter(o=>{const d=v.find(P=>P.label===o.name)?.m_code;return d&&i.has(d)})},[a,Me,v]),Qe=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.model&&(i[n.model]||(i[n.model]={count:0,deleteCount:0}),i[n.model].count++)}),Object.entries(i).map(([n,o],d)=>{const F=a.models?.[n]?.deleteCount||0,H=o.count>0?Math.round(F/o.count*100*10)/10:0;return{id:d+1,name:J(n),count:o.count,deleteCount:F,deleteRate:H}}).sort((n,o)=>o.count-n.count)},[a,J]),Ze=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.model&&(i[n.model]||(i[n.model]={count:0,totalAccuracy:0,totalContext:0,totalUsability:0}),i[n.model].count++,n.accuracy!=null&&(i[n.model].totalAccuracy+=n.accuracy),n.context!=null&&(i[n.model].totalContext+=n.context),n.usability!=null&&(i[n.model].totalUsability+=n.usability))}),Object.entries(i).map(([n,o],d)=>({id:d+1,name:J(n),count:o.count,accuracy:o.count>0?Math.round(o.totalAccuracy/o.count):0,context:o.count>0?Math.round(o.totalContext/o.count):0,usability:o.count>0?Math.round(o.totalUsability/o.count):0,totalScore:o.count>0?Math.round((o.totalAccuracy+o.totalContext+o.totalUsability)/(3*o.count)):0})).sort((n,o)=>o.totalScore-n.totalScore)},[a,J]),mt=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.source&&(i[n.source]||(i[n.source]={total:0,count:0,totalImages:0}),i[n.source].totalImages+=1,n.accuracy!=null&&(i[n.source].total+=n.accuracy,i[n.source].count+=1))}),Object.entries(i).map(([n,o],d)=>({id:d+1,source:Y(n),avgQuality:o.count>0?Math.round(o.total/o.count):0,count:o.totalImages}))},[a,Y]),qe=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.event_type&&(i[n.event_type]||(i[n.event_type]={total:0,count:0,totalImages:0}),i[n.event_type].totalImages+=1,n.accuracy!=null&&(i[n.event_type].total+=n.accuracy,i[n.event_type].count+=1))}),Object.entries(i).map(([n,o],d)=>({id:d+1,eventType:_e(n),avgQuality:o.count>0?Math.round(o.total/o.count):0,count:o.totalImages}))},[a,_e]),Ge=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i=new Set;return l.forEach(o=>{o.model&&i.add(o.model)}),Ie.filter(o=>{const d=v.find(P=>P.label===o.name)?.m_code;return d&&i.has(d)})},[a,Ie,v]);if(r)return e.jsx(je,{children:e.jsx("div",{className:c.loadingContainer,children:e.jsx(Et,{})})});if(!a)return e.jsx(je,{children:e.jsx("div",{className:c.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:c.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:c.chartGrid,children:[e.jsxs(z,{heading:"Summary Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:c.summaryStatsCards,children:[e.jsxs("div",{className:c.summaryStatsCard,children:[e.jsx("div",{className:c.summaryStatsCardValue,children:ue("crisis_map")}),e.jsx("div",{className:c.summaryStatsCardLabel,children:"Total Crisis Maps"})]}),e.jsxs("div",{className:c.summaryStatsCard,children:[e.jsx("div",{className:c.summaryStatsCardValue,children:"2000"}),e.jsx("div",{className:c.summaryStatsCardLabel,children:"Target Amount"})]})]}),e.jsxs("div",{className:c.progressSection,children:[e.jsxs("div",{className:c.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:c.userInteractionCards,children:[e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardLabel,children:"Regions Distribution"}),e.jsx("div",{className:c.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:()=>E(U?"none":"regions"),className:c.userInteractionCardButton,children:U?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardLabel,children:"Sources Distribution"}),e.jsx("div",{className:c.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:()=>E(ae?"none":"sources"),className:c.userInteractionCardButton,children:ae?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardLabel,children:"Types Distribution"}),e.jsx("div",{className:c.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:()=>E(K?"none":"types"),className:c.userInteractionCardButton,children:K?"Hide Details":"View Details"})]})]}),U&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Ae("crisis_map"),columns:De,keySelector:$,filtered:!1,pending:!1})}),ae&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:ut("crisis_map"),columns:lt,keySelector:$,filtered:!1,pending:!1})}),K&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Oe("crisis_map"),columns:Ee,keySelector:$,filtered:!1,pending:!1})})]}),e.jsxs(z,{heading:"User Interaction Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:c.userInteractionCards,children:[e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardValue,children:He("crisis_map")}),e.jsx("div",{className:c.userInteractionCardLabel,children:"Median Edit Time"}),e.jsx(Z,{name:"view-edit-time-details",variant:p?"primary":"secondary",onClick:()=>E(p?"none":"editTime"),className:c.userInteractionCardButton,children:p?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardValue,children:Ve()}),e.jsx("div",{className:c.userInteractionCardLabel,children:"Median % Modified"}),e.jsx(Z,{name:"view-percentage-details",variant:I?"primary":"secondary",onClick:()=>E(I?"none":"percentage"),className:c.userInteractionCardButton,children:I?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardValue,children:ze()}),e.jsx("div",{className:c.userInteractionCardLabel,children:"Delete Rate"}),e.jsx(Z,{name:"view-delete-details",variant:T?"primary":"secondary",onClick:()=>E(T?"none":"delete"),className:c.userInteractionCardButton,children:T?"Hide Details":"View Details"})]})]}),p&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Ue("crisis_map"),columns:ke,keySelector:$,filtered:!1,pending:!1})}),I&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:We("crisis_map"),columns:Le,keySelector:$,filtered:!1,pending:!1})}),T&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Qe("crisis_map"),columns:Pe,keySelector:$,filtered:!1,pending:!1})})]}),e.jsx(z,{heading:"Model Performance",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Ze("crisis_map"),columns:Te,keySelector:$,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Quality-Source Correlation",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.tableContainer,children:e.jsx(B,{data:mt("crisis_map"),columns:ct,keySelector:$,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Quality-Event Type Correlation",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.tableContainer,children:e.jsx(B,{data:qe("crisis_map"),columns:Re,keySelector:$,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Model Consistency Analysis",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.tableContainer,children:e.jsx(B,{data:Ge("crisis_map"),columns:$e,keySelector:$,filtered:!1,pending:!1})})})]}):e.jsxs("div",{className:c.chartGrid,children:[e.jsxs(z,{heading:"Summary Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:c.summaryStatsCards,children:[e.jsxs("div",{className:c.summaryStatsCard,children:[e.jsx("div",{className:c.summaryStatsCardValue,children:ue("drone_image")}),e.jsx("div",{className:c.summaryStatsCardLabel,children:"Total Drone Images"})]}),e.jsxs("div",{className:c.summaryStatsCard,children:[e.jsx("div",{className:c.summaryStatsCardValue,children:"2000"}),e.jsx("div",{className:c.summaryStatsCardLabel,children:"Target Amount"})]})]}),e.jsxs("div",{className:c.progressSection,children:[e.jsxs("div",{className:c.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:c.userInteractionCards,children:[e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardLabel,children:"Regions Distribution"}),e.jsx("div",{className:c.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:()=>E(U?"none":"regions"),className:c.userInteractionCardButton,children:U?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardLabel,children:"Types Distribution"}),e.jsx("div",{className:c.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:()=>E(K?"none":"types"),className:c.userInteractionCardButton,children:K?"Hide Details":"View Details"})]})]}),U&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Ae("drone_image"),columns:De,keySelector:$,filtered:!1,pending:!1})}),K&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Oe("drone_image"),columns:Ee,keySelector:$,filtered:!1,pending:!1})})]}),e.jsxs(z,{heading:"User Interaction Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:c.userInteractionCards,children:[e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardValue,children:He("drone_image")}),e.jsx("div",{className:c.userInteractionCardLabel,children:"Median Edit Time"}),e.jsx(Z,{name:"view-edit-time-details",variant:p?"primary":"secondary",onClick:()=>E(p?"none":"editTime"),className:c.userInteractionCardButton,children:p?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardValue,children:Ve()}),e.jsx("div",{className:c.userInteractionCardLabel,children:"Median % Modified"}),e.jsx(Z,{name:"view-percentage-details",variant:I?"primary":"secondary",onClick:()=>E(I?"none":"percentage"),className:c.userInteractionCardButton,children:I?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardValue,children:ze()}),e.jsx("div",{className:c.userInteractionCardLabel,children:"Delete Rate"}),e.jsx(Z,{name:"view-delete-details",variant:T?"primary":"secondary",onClick:()=>E(T?"none":"delete"),className:c.userInteractionCardButton,children:T?"Hide Details":"View Details"})]})]}),p&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Ue("drone_image"),columns:ke,keySelector:$,filtered:!1,pending:!1})}),I&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:We("drone_image"),columns:Le,keySelector:$,filtered:!1,pending:!1})}),T&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Qe("drone_image"),columns:Pe,keySelector:$,filtered:!1,pending:!1})})]}),e.jsx(z,{heading:"Model Performance",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Ze("drone_image"),columns:Te,keySelector:$,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Quality-Event Type Correlation",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.tableContainer,children:e.jsx(B,{data:qe("drone_image"),columns:Re,keySelector:$,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Model Consistency Analysis",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.tableContainer,children:e.jsx(B,{data:Ge("drone_image"),columns:$e,keySelector:$,filtered:!1,pending:!1})})})]})]})})}export{jn as default};
 
1
+ import{r as s,y as nt,t as ht,a as q,c as gt,j as e,o as N,b as se,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-DkcyG4dA.js";const kt=({title:m,titleId:a,...h})=>s.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?s.createElement("title",{id:a},m):null,s.createElement("g",{clipPath:"url(#arrow-drop-down-line_svg__a)"},s.createElement("path",{d:"m12 15-4.243-4.243 1.415-1.414L12 12.172l2.828-2.83 1.415 1.415L12 15Z"})),s.createElement("defs",null,s.createElement("clipPath",{id:"arrow-drop-down-line_svg__a"},s.createElement("path",{d:"M0 0h24v24H0z"})))),Lt=({title:m,titleId:a,...h})=>s.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?s.createElement("title",{id:a},m):null,s.createElement("g",{clipPath:"url(#arrow-drop-up-line_svg__a)"},s.createElement("path",{d:"m12 11.828-2.828 2.829-1.415-1.414L12 9l4.243 4.243-1.415 1.414L12 11.828Z"})),s.createElement("defs",null,s.createElement("clipPath",{id:"arrow-drop-up-line_svg__a"},s.createElement("path",{d:"M0 0h24v24H0z"})))),Pt=({title:m,titleId:a,...h})=>s.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?s.createElement("title",{id:a},m):null,s.createElement("g",{clipPath:"url(#information-line_svg__a)"},s.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"})),s.createElement("defs",null,s.createElement("clipPath",{id:"information-line_svg__a"},s.createElement("path",{d:"M0 0h24v24H0z"})))),Rt=({title:m,titleId:a,...h})=>s.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?s.createElement("title",{id:a},m):null,s.createElement("path",{fillRule:"evenodd",d:"m15.063 12 .937.938-4 4-4-4L8.938 12 12 15.063 15.063 12Z",clipRule:"evenodd"}),s.createElement("mask",{id:"table-sorting-line_svg__a",width:8,height:5,x:8,y:12,maskUnits:"userSpaceOnUse",style:{maskType:"luminance"}},s.createElement("path",{fillRule:"evenodd",d:"m15.063 12 .937.938-4 4-4-4L8.938 12 12 15.063 15.063 12Z",clipRule:"evenodd"})),s.createElement("g",{mask:"url(#table-sorting-line_svg__a)"},s.createElement("path",{d:"M-24-22h72v72h-72z"})),s.createElement("path",{fillRule:"evenodd",d:"M8.938 11 8 10.062l4-4 4 4-.938.938L12 7.937 8.937 11Z",clipRule:"evenodd"}),s.createElement("mask",{id:"table-sorting-line_svg__b",width:8,height:5,x:8,y:6,maskUnits:"userSpaceOnUse",style:{maskType:"luminance"}},s.createElement("path",{fillRule:"evenodd",d:"M8.938 11 8 10.062l4-4 4 4-.938.938L12 7.937 8.937 11Z",clipRule:"evenodd"})),s.createElement("g",{mask:"url(#table-sorting-line_svg__b)"},s.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:r,compact:f,currency:g,value:b,tooltip:_,unit:y,prefix:x,suffix:w,maximumFractionDigits:C=1}=m,{currentLanguage:j}=s.useContext(ht),v=s.useMemo(()=>{if(q(b))return h;const S=gt(b,{currency:g,compact:f,separatorHidden:r,maximumFractionDigits:C,unit:y,language:j});return e.jsxs(e.Fragment,{children:[x,S,w]})},[h,b,f,r,g,y,C,x,j,w]);return e.jsx("div",{className:N(Bt.numberOutput,a),title:se(_)?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:r,preferredWidth:f}=m,[g,b]=s.useState(!1),[_,y]=s.useState(!1),x=s.useRef(),w=s.useRef(null);return s.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:r})})]})}function $(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:r}=m,f=rt(Ut);let g;return r===!0?g=f.booleanYesLabel:r===!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:r,invalidText:f}=m,g=s.useMemo(()=>ft(a,h),[a,h]);return e.jsx("div",{className:N(Gt.dateOutput,r),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=s.useRef(null),{className:h,popupClassName:r,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=s.useRef(null),[k,I]=s.useState(!1);s.useEffect(()=>{C&&(C.current={setShowDropdown:I})},[C,I]);const R=s.useCallback(()=>{I(re=>!re)},[I]),T=s.useCallback((re,ae)=>{ae||re&&v||I(!1)},[I,v]);vt(k,T,p,j);const G=s.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,k&&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&&(k?e.jsx(xt,{className:le.dropdownIcon}):e.jsx(_t,{className:le.dropdownIcon}))]}):void 0,icons:_,children:g}),k&&e.jsx(st,{elementRef:p,className:N(le.dropdownContent,r),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:r,title:f,description:g,withoutIcon:b,popupClassName:_,descriptionClassName:y}=m;return e.jsx(na,{label:e.jsxs("div",{className:ge.label,children:[r,!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:r,totalValue:f,value:g,showPercentageInTitle:b,children:_,color:y="var(--go-ui-color-primary-red)"}=m,x=se(g)?g:0,w=se(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}})}),r&&e.jsx("div",{className:fe.description,children:r}),_]})}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:r,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,r),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:r,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 k=v;return S.valueType==="number"?k=e.jsx(we,{...S,invalidText:v}):S.valueType==="date"?k=e.jsx(Yt,{...S,invalidText:v}):S.valueType==="boolean"?k=e.jsx(Zt,{...S,invalidText:v}):p instanceof Date||(k=p||v),e.jsxs("div",{className:N(ee.textOutput,j&&ee.withBackground,a),children:[r,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:k}),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 r=h;const f=r-a===360;f&&(r-=1);const g=Je(m,a),b=Je(m,r),_=r-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:r,labelSelector:f,keySelector:g,colorSelector:b,colors:_,pieRadius:y=Ea,chartPadding:x=Ta,legendClassName:w,showPercentageInLegend:C}=m,j=Ct(h?.map(p=>r(p))),v=q(j)||j===0?1:j,S=s.useMemo(()=>{let p=0;const k=h?.map(I=>{const R=r(I);if(q(R))return;const T=360*(R/v);return p+=T,{key:g(I),value:R,label:f(I),startAngle:p-T,percentage:yt(R,v),endAngle:p,datum:I}}).filter(se)??[];return b?k.map(({datum:I,...R})=>({...R,color:b(I)})):k.map(({datum:I,...R},T)=>({...R,color:_[T%_.length]}))},[h,g,r,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,...r}=m;return e.jsx("td",{className:N(a,Pa.td),...r,children:h})}function it(m){const{className:a,children:h,...r}=m;return e.jsx("tr",{className:a,...r,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:r,rowClassName:f,cellClassName:g,rowModifier:b}=m;return e.jsx(e.Fragment,{children:a?.map((_,y)=>{const x=h(_,y),w=r.map(v=>{const{id:S,cellRenderer:p,cellRendererClassName:k,cellRendererParams:I,cellContainerClassName:R}=v,T=I(x,_,y,a),G=e.jsx(p,{className:k,...T,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:r,datum:_})),e.jsx(s.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:r,onResizeComplete:f,name:g,...b}=m,_=s.useRef(null),y=s.useRef(),x=s.useRef(),w=s.useRef(),C=s.useCallback(v=>{var S;if(se(y.current)&&_.current&&r){v.preventDefault(),v.stopPropagation();const p=v.clientX-y.current;if(se(x.current)){const k=x.current+p;w.current=k,r(k,g)}else x.current=(S=_.current)==null?void 0:S.offsetWidth}},[r,g]),j=s.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 s.useEffect(()=>{const v=()=>{y.current=void 0,x.current=void 0,f&&se(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:[r&&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 B(m){const{data:a,keySelector:h,columns:r,caption:f,className:g,captionClassName:b,headerRowClassName:_,headerCellClassName:y,rowClassName:x,cellClassName:w,rowModifier:C,fixedColumnWidth:j,resizableColumn:v,headersHidden:S,pending:p,filtered:k,errored:I=!1}=m,R=s.useRef(null),[T]=he.useState(()=>bt()),[G,U]=he.useState({});s.useEffect(()=>{U(W=>{if(q(R.current))return W;const E=R.current.getBoundingClientRect(),{width:O}=E;let A=r.map(M=>({id:M.id,stretch:!!M.columnStretch,width:qa(M,W[M.id])}));const X=ye(A.filter(M=>M.stretch).map(M=>M.width)),ne=ye(A.filter(M=>!M.stretch).map(M=>M.width)),Y=(O-ne)/X;return Y>1&&(A=A.map(M=>({...M,width:M.stretch?M.width*Y:M.width}))),jt(A,M=>M.id,M=>M.width)})},[r]);const re=he.useCallback((W,E)=>{const O=document.getElementById(`${T}-${E}`),A=Math.max(W,80);if(q(O)||(O.style.width=`${A}px`,!j))return;const X=document.getElementById(T);if(q(X))return;const ne=ye(r.map(Y=>Y.id===E?A:G[Y.id]));X.style.width=`${ne}px`},[T,G,r,j]),ae=he.useCallback((W,E)=>{se(E)&&U(O=>({...O,[E]:Math.max(W,80)}))},[U]),be=he.useMemo(()=>ye(r.map(W=>G[W.id])),[G,r]),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:T,children:[f&&e.jsx("caption",{className:b,children:f}),e.jsx("colgroup",{children:r.map(W=>{const{id:E,columnClassName:O}=W,A=G[E],X=j?{width:`${A}px`}:void 0;return e.jsx("col",{id:`${T}-${E}`,style:X,className:N(ce.column,O)},E)})}),!S&&e.jsx("thead",{children:e.jsx(it,{className:N(ce.headerRow,_),children:r.map((W,E)=>{const{id:O,title:A,headerCellRenderer:X,headerCellRendererClassName:ne,headerCellRendererParams:Y,headerContainerClassName:M}=W,ie=e.jsx(X,{...Y,name:O,title:A,index:E,className:N(ne,ce.headerComponent)});return e.jsx(Ha,{scope:"col",name:O,onResize:v?re:void 0,onResizeComplete:v?ae:void 0,className:N(ce.headerElement,typeof y=="function"?y(O):y,M),children:ie},O)})})}),e.jsx("tbody",{children:e.jsx(Aa,{data:a,keySelector:h,columns:r,rowClassName:x,cellClassName:w,rowModifier:C})})]})}),e.jsx(Nt,{filtered:k,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:r,name:f,sortable:g,defaultSortDirection:b="asc",infoTitle:_,infoDescription:y}=m,{sorting:x,setSorting:w}=s.useContext(St),C=rt(Xa),j=x?.name===f?x.direction:void 0,v=s.useRef(null),S=s.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:r}),_&&y&&e.jsx(ca,{className:de.infoPopupIcon,title:_,description:y})]})}const at={};function Q(m,a,h,r){return{id:m,title:a,columnClassName:r?.columnClassName,headerCellRenderer:ot,headerCellRendererClassName:r?.headerCellRendererClassName,headerContainerClassName:r?.headerContainerClassName,headerCellRendererParams:{sortable:r?.sortable,infoTitle:r?.headerInfoTitle,infoDescription:r?.headerInfoDescription},cellRendererClassName:r?.cellRendererClassName,cellContainerClassName:r?.cellContainerClassName,cellRenderer:Ga,cellRendererParams:(f,g)=>({value:h(g)||"--"}),valueSelector:h,valueComparator:(f,g)=>Mt(h(f),h(g)),columnWidth:r?.columnWidth,columnStretch:r?.columnStretch,columnStyle:r?.columnStyle}}function D(m,a,h,r){return{id:m,title:a,columnClassName:r?.columnClassName,headerCellRenderer:ot,headerCellRendererClassName:N(at.numberCellHeader,r?.headerCellRendererClassName),headerContainerClassName:r?.headerContainerClassName,headerCellRendererParams:{sortable:r?.sortable,infoTitle:r?.headerInfoTitle,infoDescription:r?.headerInfoDescription},cellRendererClassName:N(at.numberCell,r?.cellRendererClassName),cellContainerClassName:r?.cellContainerClassName,cellRenderer:we,cellRendererParams:(f,g)=>({value:h(g),suffix:r?.suffix,maximumFractionDigits:r?.maximumFractionDigits,invalidText:"--"}),valueSelector:h,valueComparator:(f,g)=>It(h(f),h(g)),columnWidth:r?.columnWidth,columnStretch:r?.columnStretch,columnStyle:r?.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",c={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]=s.useState(null),[r,f]=s.useState(!0),[g,b]=s.useState("crisis_maps"),[_,y]=s.useState([]),[x,w]=s.useState([]),[C,j]=s.useState([]),[v,S]=s.useState([]),[p,k]=s.useState(!1),[I,R]=s.useState(!1),[T,G]=s.useState(!1),[U,re]=s.useState(!1),[ae,be]=s.useState(!1),[K,W]=s.useState(!1),E=t=>{k(t==="editTime"),R(t==="percentage"),G(t==="delete"),re(t==="regions"),be(t==="sources"),W(t==="types")},O=[{key:"crisis_maps",label:"Crisis Maps"},{key:"drone_images",label:"Drone Images"}],A=s.useCallback((t,l)=>{if(!t||!l)return 0;const i=t.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(u=>u.length>0),n=l.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(u=>u.length>0);if(i.length===0&&n.length===0)return 1;if(i.length===0||n.length===0)return 0;const o=new Set(i),d=new Set(n),P=new Set([...o].filter(u=>d.has(u))),F=new Set([...o,...d]);return P.size/F.size},[]),X=s.useCallback(async()=>{f(!0);try{const l=await(await fetch("/api/images")).json(),i={},n=l.filter(u=>u.image_type==="crisis_map"),o=l.filter(u=>u.image_type==="drone_image"),d={totalCaptions:l.length,sources:{},types:{},regions:{},models:{},modelEditTimes:i,percentageModified:0,modelPercentageData:{},totalDeleteCount:0,deleteRate:0,crisisMaps:n,droneImages:o};l.forEach(u=>{if(u.source&&(d.sources[u.source]=(d.sources[u.source]||0)+1),u.event_type&&(d.types[u.event_type]=(d.types[u.event_type]||0)+1),u.countries&&u.countries.forEach(L=>{L.r_code&&(d.regions[L.r_code]=(d.regions[L.r_code]||0)+1)}),u.model){const L=u.model,V=d.models[L]||={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&&(i[L]||(i[L]=[]),i[L].push(Ce))}}}),_.forEach(u=>{u.s_code&&!d.sources[u.s_code]&&(d.sources[u.s_code]=0)}),x.forEach(u=>{u.t_code&&!d.types[u.t_code]&&(d.types[u.t_code]=0)}),C.forEach(u=>{u.r_code&&!d.regions[u.r_code]&&(d.regions[u.r_code]=0)}),["GPT-4","Claude","Gemini","Llama","Other"].forEach(u=>{d.models[u]||(d.models[u]={count:0,avgAccuracy:0,avgContext:0,avgUsability:0,totalScore:0,deleteCount:0})}),Object.values(d.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 F=l.filter(u=>u.generated&&u.edited);if(F.length>0){const L=[...F.map(oe=>A(oe.generated,oe.edited))].sort((oe,Ce)=>oe-Ce),V=Math.floor(L.length/2),te=L.length%2===0?(L[V-1]+L[V])/2:L[V];d.percentageModified=Math.round((1-te)*100)}const H={};l.forEach(u=>{if(u.model&&u.generated&&u.edited){const L=A(u.generated,u.edited),V=Math.round((1-L)*100);H[u.model]||(H[u.model]=[]),H[u.model].push(V)}}),d.modelPercentageData=H;try{const u=await fetch("/api/models");if(u.ok){const L=await u.json();if(L.models){L.models.forEach(te=>{d.models[te.m_code]&&(d.models[te.m_code].deleteCount=te.delete_count||0)});const V=L.models.reduce((te,oe)=>te+(oe.delete_count||0),0);d.totalDeleteCount=V,d.deleteRate=V>0?Math.round(V/(V+l.length)*100):0}}}catch(u){console.log("Could not fetch model delete counts:",u)}h(d)}catch{h(null)}finally{f(!1)}},[_,x,C,A]),ne=s.useCallback(async()=>{try{const[t,l,i,n]=await Promise.all([fetch("/api/sources"),fetch("/api/types"),fetch("/api/regions"),fetch("/api/models")]),o=await t.json(),d=await l.json(),P=await i.json(),F=await n.json();y(o),w(d),j(P),S(F.models||[])}catch(t){console.log("Could not fetch lookup data:",t)}},[]);s.useEffect(()=>{const t=m.get("view");(t==="crisis_maps"||t==="drone_images")&&b(t)},[m]),s.useEffect(()=>{ne()},[ne]),s.useEffect(()=>{_.length>0&&x.length>0&&C.length>0&&v.length>0&&X()},[_,x,C,v,X]);const Y=s.useCallback(t=>{const l=_.find(i=>i.s_code===t);return l?l.label:t},[_]),M=s.useCallback(t=>{if(t.length===0)return 0;const l=[...t].sort((n,o)=>n-o),i=Math.floor(l.length/2);return l.length%2===0?Math.round((l[i-1]+l[i])/2):l[i]},[]),ie=s.useCallback(t=>{const l=Math.floor(t/1e3),i=Math.floor(l/60),n=Math.floor(i/60);return n>0?`${n}h ${i%60}m`:i>0?`${i}m ${l%60}s`:`${l}s`},[]),_e=s.useCallback(t=>{const l=x.find(i=>i.t_code===t);return l?l.label:t},[x]),J=s.useCallback(t=>{const l=v.find(i=>i.m_code===t);return l?l.label:t},[v]),Se=s.useMemo(()=>a?Object.entries(a.modelEditTimes||{}).filter(([,t])=>t.length>0).sort(([,t],[,l])=>M(l)-M(t)).map(([t,l],i)=>({id:i+1,name:J(t),count:l.length,avgEditTime:M(l),minEditTime:Math.min(...l),maxEditTime:Math.max(...l)})):[],[a,M,J]),Me=s.useMemo(()=>a?Object.entries(a.modelPercentageData||{}).filter(([,t])=>t.length>0).sort(([,t],[,l])=>{const i=[...t].sort((H,u)=>H-u),n=[...l].sort((H,u)=>H-u),o=Math.floor(i.length/2),d=Math.floor(n.length/2),P=i.length%2===0?(i[o-1]+i[o])/2:i[o];return(n.length%2===0?(n[d-1]+n[d])/2:n[d])-P}).map(([t,l],i)=>{const n=[...l].sort((P,F)=>P-F),o=Math.floor(n.length/2),d=n.length%2===0?Math.round((n[o-1]+n[o])/2):n[o];return{id:i+1,name:J(t),count:l.length,avgPercentageModified:d,minPercentageModified:Math.min(...l),maxPercentageModified:Math.max(...l)}}):[],[a,J]),Ie=s.useMemo(()=>a?Object.entries(a.models).filter(([,t])=>t.count>0).map(([t,l],i)=>{const n=[l.avgAccuracy,l.avgContext,l.avgUsability],o=n.reduce((F,H)=>F+H,0)/n.length,d=n.reduce((F,H)=>F+Math.pow(H-o,2),0)/n.length,P=Math.round(100-Math.sqrt(d));return{id:i+1,name:J(t),consistency:Math.max(0,P),avgScore:Math.round(o),count:l.count}}).sort((t,l)=>l.consistency-t.consistency):[],[a,J]),De=s.useMemo(()=>[Q("name","Region",t=>t.name),D("count","Count",t=>t.count),D("percentage","% of Total",t=>t.percentage,{suffix:"%",maximumFractionDigits:0})],[]),Ee=s.useMemo(()=>[Q("name","Type",t=>t.name),D("count","Count",t=>t.count),D("percentage","% of Total",t=>t.percentage,{suffix:"%",maximumFractionDigits:0})],[]),lt=s.useMemo(()=>[Q("name","Source",t=>t.name),D("count","Count",t=>t.count),D("percentage","% of Total",t=>t.percentage,{suffix:"%",maximumFractionDigits:0})],[]),Te=s.useMemo(()=>[Q("name","Model",t=>t.name),D("count","Count",t=>t.count),D("accuracy","Accuracy",t=>t.accuracy,{suffix:"%",maximumFractionDigits:0}),D("context","Context",t=>t.context,{suffix:"%",maximumFractionDigits:0}),D("usability","Usability",t=>t.usability,{suffix:"%",maximumFractionDigits:0}),D("totalScore","Total Score",t=>t.totalScore,{suffix:"%",maximumFractionDigits:0})],[]),ke=s.useMemo(()=>[Q("name","Model",t=>t.name),D("count","Count",t=>t.count),Q("avgEditTime","Median Edit Time",t=>ie(t.avgEditTime)),Q("minEditTime","Min Edit Time",t=>ie(t.minEditTime)),Q("maxEditTime","Max Edit Time",t=>ie(t.maxEditTime))],[]),Le=s.useMemo(()=>[Q("name","Model",t=>t.name),D("count","Count",t=>t.count),D("avgPercentageModified","Median % Modified",t=>t.avgPercentageModified,{suffix:"%",maximumFractionDigits:0}),D("minPercentageModified","Min % Modified",t=>t.minPercentageModified,{suffix:"%",maximumFractionDigits:0}),D("maxPercentageModified","Max % Modified",t=>t.maxPercentageModified,{suffix:"%",maximumFractionDigits:0})],[]),Pe=s.useMemo(()=>[Q("name","Model",t=>t.name),D("count","Total Count",t=>t.count),D("deleteCount","Delete Count",t=>t.deleteCount),D("deleteRate","Delete Rate",t=>t.deleteRate,{suffix:"%",maximumFractionDigits:1})],[]),ct=s.useMemo(()=>[Q("source","Source",t=>t.source),D("avgQuality","Average Quality",t=>t.avgQuality,{suffix:"%",maximumFractionDigits:0}),D("count","Count",t=>t.count)],[]),Re=s.useMemo(()=>[Q("eventType","Event Type",t=>t.eventType),D("avgQuality","Average Quality",t=>t.avgQuality,{suffix:"%",maximumFractionDigits:0}),D("count","Count",t=>t.count)],[]),$e=s.useMemo(()=>[Q("name","Model",t=>t.name),D("consistency","Consistency",t=>t.consistency,{suffix:"%",maximumFractionDigits:0}),D("avgScore","Average Score",t=>t.avgScore,{suffix:"%",maximumFractionDigits:0}),D("count","Count",t=>t.count)],[]),ue=s.useCallback(t=>a?t==="crisis_map"?a.crisisMaps.length:t==="drone_image"?a.droneImages.length:0:0,[a]),Be=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.countries&&n.countries.forEach(o=>{o.r_code&&(i[o.r_code]=(i[o.r_code]||0)+1)})}),Object.entries(i).filter(([,n])=>n>0).map(([n,o])=>({name:C.find(d=>d.r_code===n)?.label||n,value:o}))},[a,C]),Ae=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};l.forEach(o=>{o.countries&&o.countries.forEach(d=>{d.r_code&&(i[d.r_code]=(i[d.r_code]||0)+1)})});const n=C.reduce((o,d)=>(d.r_code&&(o[d.r_code]={name:d.label,count:i[d.r_code]||0}),o),{});return Object.entries(n).sort(([,o],[,d])=>d.count-o.count).map(([,{name:o,count:d}],P)=>({id:P+1,name:o,count:d,percentage:l.length>0?Math.round(d/l.length*100):0}))},[a,C]),dt=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.source&&(i[n.source]=(i[n.source]||0)+1)}),Object.entries(i).filter(([,n])=>n>0).map(([n,o])=>({name:_.find(d=>d.s_code===n)?.label||n,value:o}))},[a,_]),ut=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.source&&(i[n.source]=(i[n.source]||0)+1)}),Object.entries(i).sort(([,n],[,o])=>o-n).map(([n,o],d)=>({id:d+1,name:Y(n),count:o,percentage:l.length>0?Math.round(o/l.length*100):0}))},[a,Y]),Fe=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.event_type&&(i[n.event_type]=(i[n.event_type]||0)+1)}),Object.entries(i).filter(([,n])=>n>0).map(([n,o])=>({name:x.find(d=>d.t_code===n)?.label||n,value:o}))},[a,x]),Oe=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.event_type&&(i[n.event_type]=(i[n.event_type]||0)+1)}),Object.entries(i).sort(([,n],[,o])=>o-n).map(([n,o],d)=>({id:d+1,name:_e(n),count:o,percentage:l.length>0?Math.round(o/l.length*100):0}))},[a,_e]),He=s.useCallback(t=>{if(!a)return"No data available";const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i=new Set;l.forEach(d=>{d.model&&i.add(d.model)}),console.log(`Debug ${t}:`,{totalImages:l.length,usedModels:Array.from(i),availableEditTimes:Object.keys(a.modelEditTimes),modelEditTimesData:a.modelEditTimes});const o=Object.entries(a.modelEditTimes).filter(([d])=>i.has(d)).flatMap(([,d])=>d);return o.length===0?"No data available":ie(M(o))},[a,ie,M]),Ve=s.useCallback(()=>{if(!a)return"No data available";const t=a.totalCaptions||0,l=a.percentageModified||0;return t>0?Math.round(l/t*100):0},[a]),ze=s.useCallback(()=>a&&a.deleteRate>=0?`${a.deleteRate}%`:"No data available",[a]),Ue=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i=new Set;return l.forEach(o=>{o.model&&i.add(o.model)}),Se.filter(o=>{const d=v.find(P=>P.label===o.name)?.m_code;return d&&i.has(d)})},[a,Se,v]),We=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i=new Set;return l.forEach(o=>{o.model&&i.add(o.model)}),Me.filter(o=>{const d=v.find(P=>P.label===o.name)?.m_code;return d&&i.has(d)})},[a,Me,v]),Qe=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.model&&(i[n.model]||(i[n.model]={count:0,deleteCount:0}),i[n.model].count++)}),Object.entries(i).map(([n,o],d)=>{const F=a.models?.[n]?.deleteCount||0,H=o.count>0?Math.round(F/o.count*100*10)/10:0;return{id:d+1,name:J(n),count:o.count,deleteCount:F,deleteRate:H}}).sort((n,o)=>o.count-n.count)},[a,J]),Ze=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.model&&(i[n.model]||(i[n.model]={count:0,totalAccuracy:0,totalContext:0,totalUsability:0}),i[n.model].count++,n.accuracy!=null&&(i[n.model].totalAccuracy+=n.accuracy),n.context!=null&&(i[n.model].totalContext+=n.context),n.usability!=null&&(i[n.model].totalUsability+=n.usability))}),Object.entries(i).map(([n,o],d)=>({id:d+1,name:J(n),count:o.count,accuracy:o.count>0?Math.round(o.totalAccuracy/o.count):0,context:o.count>0?Math.round(o.totalContext/o.count):0,usability:o.count>0?Math.round(o.totalUsability/o.count):0,totalScore:o.count>0?Math.round((o.totalAccuracy+o.totalContext+o.totalUsability)/(3*o.count)):0})).sort((n,o)=>o.totalScore-n.totalScore)},[a,J]),mt=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.source&&(i[n.source]||(i[n.source]={total:0,count:0,totalImages:0}),i[n.source].totalImages+=1,n.accuracy!=null&&(i[n.source].total+=n.accuracy,i[n.source].count+=1))}),Object.entries(i).map(([n,o],d)=>({id:d+1,source:Y(n),avgQuality:o.count>0?Math.round(o.total/o.count):0,count:o.totalImages}))},[a,Y]),qe=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i={};return l.forEach(n=>{n.event_type&&(i[n.event_type]||(i[n.event_type]={total:0,count:0,totalImages:0}),i[n.event_type].totalImages+=1,n.accuracy!=null&&(i[n.event_type].total+=n.accuracy,i[n.event_type].count+=1))}),Object.entries(i).map(([n,o],d)=>({id:d+1,eventType:_e(n),avgQuality:o.count>0?Math.round(o.total/o.count):0,count:o.totalImages}))},[a,_e]),Ge=s.useCallback(t=>{if(!a)return[];const l=t==="crisis_map"?a.crisisMaps:a.droneImages,i=new Set;return l.forEach(o=>{o.model&&i.add(o.model)}),Ie.filter(o=>{const d=v.find(P=>P.label===o.name)?.m_code;return d&&i.has(d)})},[a,Ie,v]);if(r)return e.jsx(je,{children:e.jsx("div",{className:c.loadingContainer,children:e.jsx(Et,{})})});if(!a)return e.jsx(je,{children:e.jsx("div",{className:c.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:c.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:c.chartGrid,children:[e.jsxs(z,{heading:"Summary Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:c.summaryStatsCards,children:[e.jsxs("div",{className:c.summaryStatsCard,children:[e.jsx("div",{className:c.summaryStatsCardValue,children:ue("crisis_map")}),e.jsx("div",{className:c.summaryStatsCardLabel,children:"Total Crisis Maps"})]}),e.jsxs("div",{className:c.summaryStatsCard,children:[e.jsx("div",{className:c.summaryStatsCardValue,children:"2000"}),e.jsx("div",{className:c.summaryStatsCardLabel,children:"Target Amount"})]})]}),e.jsxs("div",{className:c.progressSection,children:[e.jsxs("div",{className:c.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:c.userInteractionCards,children:[e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardLabel,children:"Regions Distribution"}),e.jsx("div",{className:c.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:()=>E(U?"none":"regions"),className:c.userInteractionCardButton,children:U?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardLabel,children:"Sources Distribution"}),e.jsx("div",{className:c.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:()=>E(ae?"none":"sources"),className:c.userInteractionCardButton,children:ae?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardLabel,children:"Types Distribution"}),e.jsx("div",{className:c.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:()=>E(K?"none":"types"),className:c.userInteractionCardButton,children:K?"Hide Details":"View Details"})]})]}),U&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Ae("crisis_map"),columns:De,keySelector:$,filtered:!1,pending:!1})}),ae&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:ut("crisis_map"),columns:lt,keySelector:$,filtered:!1,pending:!1})}),K&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Oe("crisis_map"),columns:Ee,keySelector:$,filtered:!1,pending:!1})})]}),e.jsxs(z,{heading:"User Interaction Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:c.userInteractionCards,children:[e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardValue,children:He("crisis_map")}),e.jsx("div",{className:c.userInteractionCardLabel,children:"Median Edit Time"}),e.jsx(Z,{name:"view-edit-time-details",variant:p?"primary":"secondary",onClick:()=>E(p?"none":"editTime"),className:c.userInteractionCardButton,children:p?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardValue,children:Ve()}),e.jsx("div",{className:c.userInteractionCardLabel,children:"Median % Modified"}),e.jsx(Z,{name:"view-percentage-details",variant:I?"primary":"secondary",onClick:()=>E(I?"none":"percentage"),className:c.userInteractionCardButton,children:I?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardValue,children:ze()}),e.jsx("div",{className:c.userInteractionCardLabel,children:"Delete Rate"}),e.jsx(Z,{name:"view-delete-details",variant:T?"primary":"secondary",onClick:()=>E(T?"none":"delete"),className:c.userInteractionCardButton,children:T?"Hide Details":"View Details"})]})]}),p&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Ue("crisis_map"),columns:ke,keySelector:$,filtered:!1,pending:!1})}),I&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:We("crisis_map"),columns:Le,keySelector:$,filtered:!1,pending:!1})}),T&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Qe("crisis_map"),columns:Pe,keySelector:$,filtered:!1,pending:!1})})]}),e.jsx(z,{heading:"Model Performance",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Ze("crisis_map"),columns:Te,keySelector:$,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Quality-Source Correlation",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.tableContainer,children:e.jsx(B,{data:mt("crisis_map"),columns:ct,keySelector:$,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Quality-Event Type Correlation",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.tableContainer,children:e.jsx(B,{data:qe("crisis_map"),columns:Re,keySelector:$,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Model Consistency Analysis",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.tableContainer,children:e.jsx(B,{data:Ge("crisis_map"),columns:$e,keySelector:$,filtered:!1,pending:!1})})})]}):e.jsxs("div",{className:c.chartGrid,children:[e.jsxs(z,{heading:"Summary Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:c.summaryStatsCards,children:[e.jsxs("div",{className:c.summaryStatsCard,children:[e.jsx("div",{className:c.summaryStatsCardValue,children:ue("drone_image")}),e.jsx("div",{className:c.summaryStatsCardLabel,children:"Total Drone Images"})]}),e.jsxs("div",{className:c.summaryStatsCard,children:[e.jsx("div",{className:c.summaryStatsCardValue,children:"2000"}),e.jsx("div",{className:c.summaryStatsCardLabel,children:"Target Amount"})]})]}),e.jsxs("div",{className:c.progressSection,children:[e.jsxs("div",{className:c.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:c.userInteractionCards,children:[e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardLabel,children:"Regions Distribution"}),e.jsx("div",{className:c.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:()=>E(U?"none":"regions"),className:c.userInteractionCardButton,children:U?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardLabel,children:"Types Distribution"}),e.jsx("div",{className:c.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:()=>E(K?"none":"types"),className:c.userInteractionCardButton,children:K?"Hide Details":"View Details"})]})]}),U&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Ae("drone_image"),columns:De,keySelector:$,filtered:!1,pending:!1})}),K&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Oe("drone_image"),columns:Ee,keySelector:$,filtered:!1,pending:!1})})]}),e.jsxs(z,{heading:"User Interaction Statistics",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:[e.jsxs("div",{className:c.userInteractionCards,children:[e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardValue,children:He("drone_image")}),e.jsx("div",{className:c.userInteractionCardLabel,children:"Median Edit Time"}),e.jsx(Z,{name:"view-edit-time-details",variant:p?"primary":"secondary",onClick:()=>E(p?"none":"editTime"),className:c.userInteractionCardButton,children:p?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardValue,children:Ve()}),e.jsx("div",{className:c.userInteractionCardLabel,children:"Median % Modified"}),e.jsx(Z,{name:"view-percentage-details",variant:I?"primary":"secondary",onClick:()=>E(I?"none":"percentage"),className:c.userInteractionCardButton,children:I?"Hide Details":"View Details"})]}),e.jsxs("div",{className:c.userInteractionCard,children:[e.jsx("div",{className:c.userInteractionCardValue,children:ze()}),e.jsx("div",{className:c.userInteractionCardLabel,children:"Delete Rate"}),e.jsx(Z,{name:"view-delete-details",variant:T?"primary":"secondary",onClick:()=>E(T?"none":"delete"),className:c.userInteractionCardButton,children:T?"Hide Details":"View Details"})]})]}),p&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Ue("drone_image"),columns:ke,keySelector:$,filtered:!1,pending:!1})}),I&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:We("drone_image"),columns:Le,keySelector:$,filtered:!1,pending:!1})}),T&&e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Qe("drone_image"),columns:Pe,keySelector:$,filtered:!1,pending:!1})})]}),e.jsx(z,{heading:"Model Performance",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.modelPerformance,children:e.jsx(B,{data:Ze("drone_image"),columns:Te,keySelector:$,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Quality-Event Type Correlation",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.tableContainer,children:e.jsx(B,{data:qe("drone_image"),columns:Re,keySelector:$,filtered:!1,pending:!1})})}),e.jsx(z,{heading:"Model Consistency Analysis",headingLevel:3,withHeaderBorder:!0,withInternalPadding:!0,children:e.jsx("div",{className:c.tableContainer,children:e.jsx(B,{data:Ge("drone_image"),columns:$e,keySelector:$,filtered:!1,pending:!1})})})]})]})})}export{jn as default};
py_backend/static/assets/{index-FBu17hMI.css β†’ index-cCOeofBN.css} RENAMED
The diff for this file is too large to render. See raw diff
 
py_backend/static/assets/{jszip.min-D9TECpfe.js β†’ jszip.min-DyaOnsxL.js} RENAMED
@@ -1,4 +1,4 @@
1
- import{X as bt,Y as It}from"./index-Crh8pvny.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:{}};/*!
2
 
3
  JSZip v3.10.1 - A JavaScript class for generating and reading zip files
4
  <http://stuartk.com/jszip>
 
1
+ import{X as bt,Y as It}from"./index-DkcyG4dA.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:{}};/*!
2
 
3
  JSZip v3.10.1 - A JavaScript class for generating and reading zip files
4
  <http://stuartk.com/jszip>
py_backend/static/assets/{useAdmin-D6C-qshi.js β†’ useAdmin-oKoxa8h9.js} RENAMED
@@ -1 +1 @@
1
- import{r,W as e}from"./index-Crh8pvny.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};
 
1
+ import{r,W as e}from"./index-DkcyG4dA.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};
py_backend/static/index.html CHANGED
@@ -42,8 +42,8 @@
42
  });
43
  }
44
  </script>
45
- <script type="module" crossorigin src="/assets/index-Crh8pvny.js"></script>
46
- <link rel="stylesheet" crossorigin href="/assets/index-FBu17hMI.css">
47
  </head>
48
  <body>
49
  <div id="root"></div>
 
42
  });
43
  }
44
  </script>
45
+ <script type="module" crossorigin src="/assets/index-DkcyG4dA.js"></script>
46
+ <link rel="stylesheet" crossorigin href="/assets/index-cCOeofBN.css">
47
  </head>
48
  <body>
49
  <div id="root"></div>