Promptaid-VIsion / py_backend /static /assets /ExportModal-DJ-UV1s7.js
SCGR's picture
fix
6f3f084
import{r as n,j as e,M as P,P as W,o as F,S as A,D as H,z as b,n as v,O as V,I as z,T as q,_ as O,L as G}from"./index-C_hAuRbb.js";const R=({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"})))),$=({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 D(c){const{className:i,indeterminate:r,value:j}=c;return e.jsxs(e.Fragment,{children:[r&&e.jsx(R,{className:i}),j&&!r&&e.jsx(P,{className:i}),!j&&!r&&e.jsx(W,{className:i})]})}const U="_checkbox_12g7n_1",Z="_with-background_12g7n_7",Y="_checkmark-container_12g7n_12",J="_input_12g7n_18",K="_content_12g7n_33",Q="_description_12g7n_40",X="_checked_12g7n_45",L="_checkmark_12g7n_12",ee="_disabled-checkbox_12g7n_58",m={checkbox:U,withBackground:Z,checkmarkContainer:Y,input:J,content:K,description:Q,checked:X,checkmark:L,disabledCheckbox:ee};function B(c){const{className:i,checkmark:r=D,checkmarkClassName:j,checkmarkContainerClassName:I,disabled:t,error:p,indeterminate:N,inputClassName:E,invertedLogic:d=!1,label:y,labelContainerClassName:_,name:w,onChange:f,readOnly:h,tooltip:k,value:x,description:u,withBackground:T,...S}=c,M=n.useCallback(s=>{const o=s.currentTarget.checked;f(d?!o:o,w)},[w,f,d]),C=d?!x:x,g=F(m.checkbox,i,!N&&C&&m.checked,T&&m.withBackground,t&&m.disabledCheckbox,h&&m.readOnly);return e.jsxs("label",{className:g,title:k,children:[e.jsxs("div",{className:F(m.checkmarkContainer,I),children:[e.jsx("input",{onChange:M,className:F(m.input,E),type:"checkbox",checked:C??!1,disabled:t||h,readOnly:h,...S}),e.jsx(r,{className:F(m.checkmark,j),value:C??!1,indeterminate:N,"aria-hidden":"true"})]}),(y||u)&&e.jsxs("div",{className:m.content,children:[y&&e.jsx("div",{className:_,children:y}),u&&e.jsx("div",{className:m.description,children:u})]}),p&&e.jsx(A,{children:p})]})}function _e({sources:c,types:i,regions:r,countries:j,imageTypes:I,isLoadingFilters:t=!1}){const[p,N]=n.useState(!1),{search:E,setSearch:d,srcFilter:y,setSrcFilter:_,catFilter:w,setCatFilter:f,regionFilter:h,setRegionFilter:k,countryFilter:x,setCountryFilter:u,imageTypeFilter:T,setImageTypeFilter:S,uploadTypeFilter:M,setUploadTypeFilter:C,showReferenceExamples:g,setShowReferenceExamples:s,clearAllFilters:o}=H();return 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:()=>N(!p),className:"whitespace-nowrap",title:p?"Hide Filters":"Show Filters",children:e.jsx($,{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(V,{name:"search",placeholder:"Search examples...",value:E,onChange:a=>d(a||"")})}),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:o,children:"Clear Filters"})})]}),p&&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(z,{name:"source",placeholder:t?"Loading...":"All Sources",options:c,value:y||null,onChange:a=>_(a||""),keySelector:a=>a.s_code,labelSelector:a=>a.label,required:!1,disabled:t})}),e.jsx(b,{withInternalPadding:!0,className:"p-2",children:e.jsx(z,{name:"category",placeholder:t?"Loading...":"All Categories",options:i,value:w||null,onChange:a=>f(a||""),keySelector:a=>a.t_code,labelSelector:a=>a.label,required:!1,disabled:t})}),e.jsx(b,{withInternalPadding:!0,className:"p-2",children:e.jsx(z,{name:"region",placeholder:t?"Loading...":"All Regions",options:r,value:h||null,onChange:a=>k(a||""),keySelector:a=>a.r_code,labelSelector:a=>a.label,required:!1,disabled:t})}),e.jsx(b,{withInternalPadding:!0,className:"p-2",children:e.jsx(q,{name:"country",placeholder:t?"Loading...":"All Countries",options:j,value:x?[x]:[],onChange:a=>u(a[0]||""),keySelector:a=>a.c_code,labelSelector:a=>a.label,disabled:t})}),e.jsx(b,{withInternalPadding:!0,className:"p-2",children:e.jsx(z,{name:"imageType",placeholder:t?"Loading...":"All Image Types",options:I,value:T||null,onChange:a=>S(a||""),keySelector:a=>a.image_type,labelSelector:a=>a.label,required:!1,disabled:t})}),e.jsx(b,{withInternalPadding:!0,className:"p-2",children:e.jsx(z,{name:"uploadType",placeholder:"All Upload Types",options:[{key:"single",label:"Single Upload"},{key:"multiple",label:"Multiple Upload"}],value:M||null,onChange:a=>C(a||""),keySelector:a=>a.key,labelSelector:a=>a.label,required:!1,disabled:!1})})]})})]})}const ae="_fullSizeModalOverlay_cyz3b_1",le="_fullSizeModalContent_cyz3b_29",te="_ratingWarningContent_cyz3b_53",se="_ratingWarningTitle_cyz3b_65",ne="_exportModeSection_cyz3b_133",ie="_splitConfigSection_cyz3b_143",re="_splitConfigTitle_cyz3b_153",ce="_splitInputsContainer_cyz3b_167",oe="_splitInputGroup_cyz3b_183",de="_splitInputLabel_cyz3b_197",me="_splitInput_cyz3b_167",pe="_splitTotal_cyz3b_247",he="_splitTotalError_cyz3b_261",xe="_checkboxesContainer_cyz3b_271",ue="_ratingWarningButtons_cyz3b_289",ge="_singleExportMessage_cyz3b_309",be="_navigateButtonContainer_cyz3b_333",ve="_loadingOverlay_cyz3b_349",l={fullSizeModalOverlay:ae,fullSizeModalContent:le,ratingWarningContent:te,ratingWarningTitle:se,exportModeSection:ne,splitConfigSection:ie,splitConfigTitle:re,splitInputsContainer:ce,splitInputGroup:oe,splitInputLabel:de,splitInput:me,splitTotal:pe,splitTotalError:he,checkboxesContainer:xe,ratingWarningButtons:ue,singleExportMessage:ge,navigateButtonContainer:be,loadingOverlay:ve};function fe({isOpen:c,onClose:i,onExport:r,crisisMapsCount:j,droneImagesCount:I,isLoading:t=!1,exportSuccess:p=!1,variant:N="bulk",onNavigateAndExport:E}){const[d,y]=n.useState("standard"),[_,w]=n.useState(80),[f,h]=n.useState(10),[k,x]=n.useState(10),[u,T]=n.useState(!0),[S,M]=n.useState(!0),C=()=>{if(N==="single"){r(d,["crisis_map","drone_image"]);return}if(!u&&!S){alert("Please select at least one image type to export.");return}const s=[];u&&s.push("crisis_map"),S&&s.push("drone_image"),r(d,s)},g=()=>{i()};return c?N==="single"?e.jsx("div",{className:l.fullSizeModalOverlay,onClick:g,children:e.jsxs("div",{className:l.fullSizeModalContent,onClick:s=>s.stopPropagation(),children:[t&&e.jsx("div",{className:l.loadingOverlay,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(O,{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"})]})}),p&&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:g,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:E,children:"Navigate to List View"})}),e.jsxs("div",{className:l.ratingWarningButtons,children:[e.jsx(v,{name:"continue-export",onClick:C,disabled:t,children:t?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{className:"text-white"}),"Exporting..."]}):"Continue"}),e.jsx(v,{name:"cancel-export",variant:"tertiary",onClick:g,disabled:t,children:"Cancel"})]})]})]})}):e.jsx("div",{className:l.fullSizeModalOverlay,onClick:g,children:e.jsxs("div",{className:l.fullSizeModalContent,onClick:s=>s.stopPropagation(),children:[t&&e.jsx("div",{className:l.loadingOverlay,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(O,{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"})]})}),p&&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:g,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(G,{name:"export-mode",value:d,onChange:s=>{(s==="standard"||s==="fine-tuning")&&y(s)},options:[{key:"standard",label:"Standard"},{key:"fine-tuning",label:"Fine-tuning"}],keySelector:s=>s.key,labelSelector:s=>s.label,disabled:t})}),d==="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:_,onChange:s=>{const o=parseInt(s.target.value)||0,a=100-o;a>=0&&(w(o),f+k>a&&(h(Math.floor(a/2)),x(a-Math.floor(a/2))))},className:l.splitInput,disabled:t})]}),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:f,onChange:s=>{const o=parseInt(s.target.value)||0,a=100-_-o;a>=0&&(h(o),x(a))},className:l.splitInput,disabled:t})]}),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:k,onChange:s=>{const o=parseInt(s.target.value)||0,a=100-_-o;a>=0&&(x(o),h(a))},className:l.splitInput,disabled:t})]})]}),_+f+k!==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(B,{name:"crisis-maps",label:`Crisis Maps (${j} images)`,value:u,onChange:s=>T(s),disabled:t})}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(B,{name:"drone-images",label:`Drone Images (${I} images)`,value:S,onChange:s=>M(s),disabled:t})})]}),e.jsxs("div",{className:l.ratingWarningButtons,children:[e.jsx(v,{name:"confirm-export",onClick:C,disabled:t,children:t?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{className:"text-white"}),"Exporting..."]}):"Export Selected"}),e.jsx(v,{name:"cancel-export",variant:"tertiary",onClick:g,disabled:t,children:"Cancel"})]})]})]})}):null}export{fe as E,_e as F};