easy_ml 0.2.0.pre.rc84 → 0.2.0.pre.rc85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/easy_ml/datasets_controller.rb +1 -1
- data/app/frontend/pages/DatasetsPage.tsx +1 -0
- data/lib/easy_ml/version.rb +1 -1
- data/public/easy_ml/assets/.vite/manifest.json +1 -1
- data/public/easy_ml/assets/assets/entrypoints/{Application.tsx-Bbf3mD_b.js → Application.tsx-CD8voxfL.js} +2 -2
- data/public/easy_ml/assets/assets/entrypoints/{Application.tsx-Bbf3mD_b.js.map → Application.tsx-CD8voxfL.js.map} +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53104f4ab5d52062d772983a09a1d31aecd524a7780b7104538327a346faab5e
|
4
|
+
data.tar.gz: 023a0bf486a12c23e6a8724ae329e49849e8168ad647a4557d3d3ef2adec1a47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb9e184aea0eff595d296285e5a66a9ad4778a8e48b6a64f39b5628ff92cdd440d06953d6a5dbf63b6b0ca312db6edef717e57fcd2f12fcbea63caaaa586eb67
|
7
|
+
data.tar.gz: b379bca69fc1817ec29da1f56df6a0c6e121b443849b1d4f6032b14ec86805dd50f629a84989bd0c80bdba691c0d9f51cdf4d80dc69e5bba71502281a840d96c
|
@@ -23,7 +23,7 @@
|
|
23
23
|
module EasyML
|
24
24
|
class DatasetsController < ApplicationController
|
25
25
|
def index
|
26
|
-
datasets = Dataset.all.includes(:
|
26
|
+
datasets = Dataset.all.includes(:datasource, columns: [:lineages]).order(id: :desc)
|
27
27
|
|
28
28
|
render inertia: "pages/DatasetsPage", props: {
|
29
29
|
datasets: datasets.map { |dataset| dataset_to_json_small(dataset) },
|
@@ -15,6 +15,7 @@ interface Props {
|
|
15
15
|
const ITEMS_PER_PAGE = 6;
|
16
16
|
|
17
17
|
export default function DatasetsPage({ datasets }: Props) {
|
18
|
+
console.log(`change`)
|
18
19
|
const { rootPath } = usePage().props;
|
19
20
|
const [searchQuery, setSearchQuery] = useState('');
|
20
21
|
const [currentPage, setCurrentPage] = useState(1);
|
data/lib/easy_ml/version.rb
CHANGED
@@ -486,7 +486,7 @@ module Features
|
|
486
486
|
description: "Boolean true/false, did the loan application fund?"
|
487
487
|
|
488
488
|
end
|
489
|
-
end`})})]})})}function SL({options:e,initialFeatures:t=[],onFeaturesChange:n}){const[r,a]=E.useState(t),[l,c]=E.useState(null);console.log(r);const d=e.filter(N=>!r.find(b=>b.name===N.name)),p=N=>{const b=N.map((w,k)=>({...w,feature_position:k}));a(b),n(b)},m=N=>{const b=e.find(w=>w.name===N);if(b){const w={...b,feature_position:r.length};p([...r,w])}},h=N=>{const b=[...r];b.splice(N,1),p(b)},g=N=>{if(N===0)return;const b=[...r];[b[N-1],b[N]]=[b[N],b[N-1]],p(b)},x=N=>{if(N===r.length-1)return;const b=[...r];[b[N],b[N+1]]=[b[N+1],b[N]],p(b)},j=(N,b)=>{c(b)},y=(N,b)=>{if(N.preventDefault(),l===null||l===b)return;const w=[...r],[k]=w.splice(l,1);w.splice(b,0,k),p(w),c(b)},_=()=>{c(null)};return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("div",{className:"flex-1",children:o.jsx(ct,{options:d.map(N=>({value:N.name,label:N.name,description:N.description})),value:"",onChange:N=>m(N),placeholder:"Add a transform..."})}),o.jsx(jL,{})]}),o.jsxs("div",{className:"space-y-2",children:[r.map((N,b)=>o.jsxs("div",{draggable:!0,onDragStart:w=>j(w,b),onDragOver:w=>y(w,b),onDragEnd:_,className:`flex items-center gap-3 p-3 bg-white border rounded-lg ${l===b?"border-blue-500 shadow-lg":"border-gray-200"} ${l!==null?"cursor-grabbing":""}`,children:[o.jsx("button",{type:"button",className:"p-1 text-gray-400 hover:text-gray-600 cursor-grab active:cursor-grabbing",children:o.jsx(_O,{className:"w-4 h-4"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"font-medium text-gray-900",children:N.name}),o.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${N.feature_type==="calculation"?"bg-blue-100 text-blue-800":N.feature_type==="lookup"?"bg-purple-100 text-purple-800":"bg-green-100 text-green-800"}`,children:"feature"})]}),o.jsx("p",{className:"text-sm text-gray-500 truncate",children:N.description})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{type:"button",onClick:()=>g(b),disabled:b===0,className:"p-1 text-gray-400 hover:text-gray-600 disabled:opacity-50",title:"Move up",children:o.jsx(cO,{className:"w-4 h-4"})}),o.jsx("button",{type:"button",onClick:()=>x(b),disabled:b===r.length-1,className:"p-1 text-gray-400 hover:text-gray-600 disabled:opacity-50",title:"Move down",children:o.jsx(lO,{className:"w-4 h-4"})}),o.jsx("button",{type:"button",onClick:()=>h(b),className:"p-1 text-gray-400 hover:text-red-600",title:"Remove transform",children:o.jsx(rc,{className:"w-4 h-4"})})]})]},N.name)),r.length===0&&o.jsxs("div",{className:"text-center py-8 bg-gray-50 border-2 border-dashed border-gray-200 rounded-lg",children:[o.jsx(oa,{className:"w-8 h-8 text-gray-400 mx-auto mb-2"}),o.jsx("p",{className:"text-sm text-gray-500",children:"Add features to enrich your dataset"})]})]})]})}function NL({isOpen:e,onClose:t,initialDataset:n,onSave:r,constants:a}){const[l,c]=E.useState(n),[d,p]=E.useState("columns"),[m,h]=E.useState("target"),[g,x]=E.useState(!1),[j,y]=E.useState({targetColumn:l.target,dateColumn:l.date_column}),[_,N]=E.useState(null),[b,w]=E.useState(""),[k,R]=E.useState({view:"all",types:[]}),[D,T]=E.useState(n.needs_refresh||!1),z=E.useCallback(async K=>{await r(K)},[r]),{saving:F,saved:B,error:W}=wL(l,z,2e3),le=K=>{var we,Ce,Ne;return((we=K.preprocessing_steps)==null?void 0:we.training)!=null&&((Ne=(Ce=K.preprocessing_steps)==null?void 0:Ce.training)==null?void 0:Ne.method)!=="none"},se=E.useMemo(()=>l.columns.filter(K=>{const we=K.name.toLowerCase().includes(b.toLowerCase()),Ce=k.types.length===0||k.types.includes(K.datatype),Ne=(()=>{var X,pe;switch(k.view){case"training":return!K.hidden&&!K.drop_if_null;case"hidden":return K.hidden;case"preprocessed":return le(K);case"nulls":return(((pe=(X=K.statistics)==null?void 0:X.processed)==null?void 0:pe.null_count)||0)>0;case"computed":return K.is_computed;case"required":return K.required;default:return!0}})();return we&&Ce&&Ne}),[l.columns,b,k]),be=E.useMemo(()=>({total:l.columns.length,filtered:se.length,training:l.columns.filter(K=>!K.hidden&&!K.drop_if_null).length,hidden:l.columns.filter(K=>K.hidden).length,withPreprocessing:l.columns.filter(le).length,withNulls:l.columns.filter(K=>{var we,Ce;return(((Ce=(we=K.statistics)==null?void 0:we.processed)==null?void 0:Ce.null_count)||0)>0}).length,computed:l.columns.filter(K=>K.is_computed===!0).length,required:l.columns.filter(K=>K.required===!0).length}),[l.columns,se]),ve=E.useMemo(()=>Array.from(new Set(l.columns.map(K=>K.datatype))),[l.columns]),Y=E.useMemo(()=>l.columns.filter(K=>K.datatype==="datetime").map(K=>({value:K.name,label:K.name})),[l.columns]),Z=K=>{N(K)},oe=K=>{const we=l.columns.map(Ce=>({...Ce,hidden:Ce.name===K?!Ce.hidden:Ce.hidden}));c({...l,columns:we}),T(!0)},G=K=>{const we=String(K);y({...j,targetColumn:K});const Ce=l.columns.map(Ne=>({...Ne,is_target:Ne.name===we}));c({...l,columns:Ce}),T(!0)},te=K=>{const we=String(K);y(Ne=>({...Ne,dateColumn:K}));const Ce=l.columns.map(Ne=>({...Ne,is_date_column:Ne.name===we}));c({...l,columns:Ce}),T(!0)},ne=(K,we)=>{const Ce=l.columns.map(Ne=>({...Ne,datatype:Ne.name===K?we:Ne.datatype}));c({...l,columns:Ce}),T(!0)},fe=(K,we,Ce,Ne)=>{if(!l.columns.find(xe=>xe.name===K))return;const pe=l.columns.map(xe=>xe.name!==K?xe:{...xe,preprocessing_steps:{training:we,...Ne&&Ce?{inference:Ce}:{}}});c({...l,columns:pe}),T(!0)},Oe=K=>{const Ce=(l.features||[]).filter(X=>!K.find(pe=>pe.name===X.name)).map(X=>({...X,_destroy:!0})),Ne=[...K,...Ce].map((X,pe)=>({...X,dataset_id:l.id,feature_position:pe}));c(X=>({...X,features:Ne})),T(!0)},dt=async()=>{x(!0);try{await r(l),Xe.post(`/easy_ml/datasets/${l.id}/refresh`,{},{onSuccess:()=>{x(!1)},onError:()=>{console.error("Error refreshing dataset"),x(!1)}})}catch(K){console.error("Error refreshing dataset:",K),x(!1)}};if(!e)return null;const Je=_?l.columns.find(K=>K.name===_):null;return o.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:o.jsxs("div",{className:"bg-white rounded-lg w-full max-w-6xl max-h-[90vh] overflow-hidden flex flex-col",children:[o.jsxs("div",{className:"flex justify-between items-center p-4 border-b shrink-0",children:[o.jsx("h2",{className:"text-lg font-semibold",children:"Column Configuration"}),o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("div",{className:"min-w-[0px]",children:o.jsx(gR,{saving:F,saved:B,error:W})}),o.jsxs("div",{className:"relative",children:[o.jsx(yg,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),o.jsx("input",{type:"text",placeholder:"Search columns...",value:b,onChange:K=>w(K.target.value),className:"pl-9 pr-4 py-2 w-64 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"})]}),o.jsx("button",{onClick:t,className:"text-gray-500 hover:text-gray-700",children:o.jsx(rc,{className:"w-5 h-5"})})]})]}),o.jsxs("div",{className:"flex border-b shrink-0",children:[o.jsxs("button",{onClick:()=>p("columns"),className:`flex items-center gap-2 px-4 py-2 border-b-2 ${d==="columns"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:[o.jsx(la,{className:"w-4 h-4"}),"Preprocessing"]}),o.jsxs("button",{onClick:()=>p("features"),className:`flex items-center gap-2 px-4 py-2 border-b-2 ${d==="features"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:[o.jsx(AO,{className:"w-4 h-4"}),"Feature Engineering"]}),D&&o.jsx("div",{className:"ml-auto px-4 flex items-center",children:o.jsxs("button",{onClick:dt,disabled:g,className:"group relative inline-flex items-center gap-2 px-6 py-2.5 bg-gradient-to-r from-blue-600 to-indigo-600 text-white text-sm font-medium rounded-md hover:from-blue-700 hover:to-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 transition-all duration-200 shadow-md hover:shadow-lg",children:[o.jsx("div",{className:"absolute inset-0 bg-white/10 rounded-md opacity-0 group-hover:opacity-100 transition-opacity duration-200"}),g?o.jsxs(o.Fragment,{children:[o.jsx(Qa,{className:"w-4 h-4 animate-spin"}),"Applying Preprocessing..."]}):o.jsxs(o.Fragment,{children:[o.jsx(kO,{className:"w-4 h-4"}),"Apply Preprocessing"]})]})})]}),d==="columns"?o.jsxs($n.Fragment,{children:[o.jsxs("div",{className:"grid grid-cols-7 flex-1 min-h-0",children:[o.jsxs("div",{className:"col-span-3 border-r overflow-hidden flex flex-col",children:[o.jsxs("div",{className:"p-4 border-b",children:[o.jsxs("div",{className:"flex border-b",children:[o.jsxs("button",{onClick:()=>h("target"),className:`flex items-center gap-2 px-4 py-2 border-b-2 ${m==="target"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:[o.jsx(bg,{className:"w-4 h-4"}),"Target Column"]}),o.jsxs("button",{onClick:()=>h("date"),className:`flex items-center gap-2 px-4 py-2 border-b-2 ${m==="date"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:[o.jsx(Hd,{className:"w-4 h-4"}),"Date Column"]})]}),m==="target"?o.jsx("div",{className:"mt-4",children:o.jsx(ct,{value:j.targetColumn||"",onChange:K=>G(K),options:l.columns.map(K=>({value:K.name,label:K.name})),placeholder:"Select target column..."})}):o.jsx("div",{className:"mt-4",children:Y.length>0?o.jsx(ct,{options:Y,value:j.dateColumn,onChange:te,placeholder:"Select a date column..."}):o.jsx("div",{className:"text-center py-4 text-gray-500 bg-gray-50 rounded-md",children:"No date columns available"})})]}),o.jsx("div",{className:"shrink-0",children:o.jsx(hR,{types:ve,activeFilters:k,onFilterChange:R,columnStats:be,columns:l.columns,colHasPreprocessingSteps:le})}),o.jsx("div",{className:"flex-1 overflow-y-auto p-4 min-h-0",children:o.jsx(mR,{columns:se,selectedColumn:_,onColumnSelect:Z,onToggleHidden:oe})})]}),o.jsx("div",{className:"col-span-4 overflow-y-auto p-4",children:Je?o.jsx(fR,{column:Je,dataset:l,setColumnType:ne,setDataset:c,constants:a,onUpdate:(K,we,Ce)=>fe(Je.name,K,we,Ce)}):o.jsx("div",{className:"h-full flex items-center justify-center text-gray-500",children:"Select a column to configure preprocessing"})})]}),o.jsxs("div",{className:"border-t p-4 flex justify-between items-center shrink-0",children:[o.jsxs("div",{className:"text-sm text-gray-600",children:[l.columns.filter(K=>!K.hidden).length," columns selected for training"]}),o.jsx("div",{className:"flex gap-3",children:o.jsx("button",{onClick:t,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700",children:"Close"})})]})]}):o.jsx("div",{className:"p-6 h-[calc(90vh-8rem)] overflow-y-auto",children:o.jsx(SL,{options:a.feature_options,initialFeatures:l.features,onFeaturesChange:Oe})})]})})}function kL({dataset:e,constants:t}){const[n,r]=E.useState(!1),[a,l]=E.useState(e),{rootPath:c}=Un().props,d=E.useCallback(p=>{var x;const m=Object.entries(p).reduce((j,[y,_])=>(y!=="columns"&&y!=="features"&&!Wt.isEqual(a[y],_)&&(j[y]=_),j),{}),h=p.columns.reduce((j,y)=>{const _=a.columns.find(N=>N.id===y.id);if(!_||!Wt.isEqual(_,y)){const N=Object.entries(y).reduce((b,[w,k])=>((!_||!Wt.isEqual(_[w],k))&&(b[w]=k),b),{});Object.keys(N).length>0&&(j[y.id]={...N,id:y.id})}return j},{}),g=(x=p.features)==null?void 0:x.map((j,y)=>({id:j.id,name:j.name,feature_class:j.feature_class,feature_position:y,_destroy:j._destroy}));(Object.keys(m).length>0||Object.keys(h).length>0||!Wt.isEqual(a.features,p.features))&&Xe.patch(`${c}/datasets/${e.id}`,{dataset:{...m,columns_attributes:h,features_attributes:g}},{preserveState:!0,preserveScroll:!0}),l(p)},[a,e.id,c]);return o.jsxs("div",{className:"p-8 space-y-6",children:[o.jsx("div",{className:"flex justify-end",children:o.jsxs("button",{onClick:()=>r(!0),className:"flex items-center gap-2 px-4 py-2 bg-white border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50",children:[o.jsx(tc,{className:"w-4 h-4"}),"Configure Columns"]})}),o.jsx(PO,{dataset:a}),o.jsx(NL,{isOpen:n,onClose:()=>r(!1),initialDataset:a,constants:t,onSave:d})]})}const CL=Object.freeze(Object.defineProperty({__proto__:null,default:kL},Symbol.toStringTag,{value:"Module"}));function op({icon:e,title:t,description:n,actionLabel:r,onAction:a}){return o.jsxs("div",{className:"text-center py-12",children:[o.jsx("div",{className:"w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-4",children:o.jsx(e,{className:"w-8 h-8 text-gray-400"})}),o.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:t}),o.jsx("p",{className:"text-gray-500 mb-6 max-w-sm mx-auto",children:n}),o.jsx("button",{onClick:a,className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:r})]})}function p0({value:e,onChange:t,placeholder:n="Search..."}){return o.jsxs("div",{className:"relative",children:[o.jsx(yg,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),o.jsx("input",{type:"text",value:e,onChange:r=>t(r.target.value),placeholder:n,className:"pl-9 pr-4 py-2 w-64 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"})]})}function f0({currentPage:e,totalPages:t,onPageChange:n}){return o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-200",children:[o.jsxs("div",{className:"flex-1 flex justify-between sm:hidden",children:[o.jsx("button",{onClick:()=>n(e-1),disabled:e===1,className:"relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 disabled:bg-gray-100 disabled:text-gray-400",children:"Previous"}),o.jsx("button",{onClick:()=>n(e+1),disabled:e===t,className:"relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 disabled:bg-gray-100 disabled:text-gray-400",children:"Next"})]}),o.jsxs("div",{className:"hidden sm:flex-1 sm:flex sm:items-center sm:justify-between",children:[o.jsx("div",{children:o.jsxs("p",{className:"text-sm text-gray-700",children:["Page ",o.jsx("span",{className:"font-medium",children:e})," of"," ",o.jsx("span",{className:"font-medium",children:t})]})}),o.jsx("div",{children:o.jsxs("nav",{className:"relative z-0 inline-flex rounded-md shadow-sm -space-x-px","aria-label":"Pagination",children:[o.jsxs("button",{onClick:()=>n(e-1),disabled:e===1,className:"relative inline-flex items-center px-2 py-2 rounded-l-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50 disabled:bg-gray-100 disabled:text-gray-400",children:[o.jsx("span",{className:"sr-only",children:"Previous"}),o.jsx(qd,{className:"h-5 w-5"})]}),Array.from({length:t},(r,a)=>a+1).map(r=>o.jsx("button",{onClick:()=>n(r),className:`relative inline-flex items-center px-4 py-2 border text-sm font-medium ${r===e?"z-10 bg-blue-50 border-blue-500 text-blue-600":"bg-white border-gray-300 text-gray-500 hover:bg-gray-50"}`,children:r},r)),o.jsxs("button",{onClick:()=>n(e+1),disabled:e===t,className:"relative inline-flex items-center px-2 py-2 rounded-r-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50 disabled:bg-gray-100 disabled:text-gray-400",children:[o.jsx("span",{className:"sr-only",children:"Next"}),o.jsx(no,{className:"h-5 w-5"})]})]})})]})]})}function Ij({stacktrace:e}){return o.jsx("div",{className:"mt-2 p-3 bg-red-50 rounded-md",children:o.jsx("pre",{className:"text-xs text-red-700 whitespace-pre-wrap break-words [word-break:break-word] font-mono",children:e})})}const Tm={analyzing:{bg:"bg-blue-100",text:"text-blue-800",icon:o.jsx(Qa,{className:"w-4 h-4 animate-spin"})},ready:{bg:"bg-green-100",text:"text-green-800",icon:null},failed:{bg:"bg-red-100",text:"text-red-800",icon:o.jsx(Mn,{className:"w-4 h-4"})}};function EL({dataset:e,rootPath:t,onDelete:n,onRefresh:r,onAbort:a,isErrorExpanded:l,onToggleError:c}){const d=$n.useRef(null),p=()=>{window.location.href=`${t}/datasets/${e.id}/download`},m=h=>{var j,y;const g=(j=h.target.files)==null?void 0:j[0];if(!g)return;const x=new FormData;x.append("config",g),fetch(`${t}/datasets/${e.id}/upload`,{method:"POST",body:x,credentials:"same-origin",headers:{"X-CSRF-Token":((y=document.querySelector('meta[name="csrf-token"]'))==null?void 0:y.content)||""}}).then(_=>{_.ok?window.location.reload():console.error("Upload failed")})};return o.jsxs("div",{className:"bg-white rounded-lg shadow-md p-6 hover:shadow-lg transition-shadow",children:[o.jsxs("div",{className:"flex justify-between items-start mb-4",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(dn,{className:"w-5 h-5 text-blue-600 mt-1"}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:e.name}),o.jsxs("div",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${Tm[e.workflow_status].bg} ${Tm[e.workflow_status].text}`,children:[Tm[e.workflow_status].icon,o.jsx("span",{children:e.workflow_status.charAt(0).toUpperCase()+e.workflow_status.slice(1)})]})]}),o.jsx("p",{className:"text-sm text-gray-500 mt-1",children:e.description})]})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(Or,{href:`${t}/datasets/${e.id}`,className:`transition-colors ${e.workflow_status==="analyzing"?"text-gray-300 cursor-not-allowed pointer-events-none":"text-gray-400 hover:text-blue-600"}`,title:e.workflow_status==="analyzing"?"Dataset is being analyzed":"View details",children:o.jsx(pw,{className:"w-5 h-5"})}),o.jsx("button",{onClick:()=>r(e.id),disabled:e.workflow_status==="analyzing",className:`transition-colors ${e.workflow_status==="analyzing"?"text-gray-300 cursor-not-allowed":"text-gray-400 hover:text-blue-600"}`,title:e.workflow_status==="analyzing"?"Dataset is being analyzed":"Refresh dataset",children:o.jsx(vw,{className:"w-5 h-5"})}),e.workflow_status==="analyzing"&&o.jsx("button",{onClick:()=>a(e.id),className:"text-gray-400 hover:text-red-600 transition-colors",title:"Abort analysis",children:o.jsx(El,{className:"w-5 h-5"})}),o.jsx("button",{onClick:p,className:"text-gray-400 hover:text-blue-600 transition-colors",title:"Download dataset configuration",children:o.jsx(dw,{className:"w-5 h-5"})}),o.jsx("button",{onClick:()=>{var h;return(h=d.current)==null?void 0:h.click()},className:"text-gray-400 hover:text-green-600 transition-colors",title:"Upload dataset configuration",children:o.jsx(nc,{className:"w-5 h-5"})}),o.jsx("input",{type:"file",ref:d,onChange:m,accept:".json",className:"hidden"}),o.jsx("button",{className:"text-gray-400 hover:text-red-600 transition-colors",title:"Delete dataset",onClick:()=>n(e.id),children:o.jsx(yo,{className:"w-5 h-5"})})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4 mt-4",children:[o.jsxs("div",{children:[o.jsx("span",{className:"text-sm text-gray-500",children:"Columns"}),o.jsxs("p",{className:"text-sm font-medium text-gray-900",children:[e.columns.length," columns"]})]}),o.jsxs("div",{children:[o.jsx("span",{className:"text-sm text-gray-500",children:"Rows"}),o.jsx("p",{className:"text-sm font-medium text-gray-900",children:e.num_rows.toLocaleString()})]})]}),o.jsx("div",{className:"mt-4 pt-4 border-t border-gray-100",children:o.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.columns.slice(0,3).map(h=>o.jsx("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800",children:h.name},h.name)),e.columns.length>3&&o.jsxs("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800",children:["+",e.columns.length-3," more"]})]})}),e.workflow_status==="failed"&&e.stacktrace&&o.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-100",children:[o.jsxs("button",{onClick:()=>c(e.id),className:"flex items-center gap-2 text-sm text-red-600 hover:text-red-700",children:[o.jsx(Mn,{className:"w-4 h-4"}),o.jsx("span",{children:"View Error Details"}),l?o.jsx(ec,{className:"w-4 h-4"}):o.jsx(vo,{className:"w-4 h-4"})]}),l&&o.jsx(Ij,{stacktrace:e.stacktrace})]})]})}function AL(){const e=E.useRef(null),{rootPath:t}=Un().props,n=r=>{var c,d;const a=(c=r.target.files)==null?void 0:c[0];if(!a)return;const l=new FormData;l.append("config",a),fetch(`${t}/datasets/upload`,{method:"POST",body:l,credentials:"same-origin",headers:{"X-CSRF-Token":((d=document.querySelector('meta[name="csrf-token"]'))==null?void 0:d.content)||""}}).then(p=>{p.ok?window.location.reload():console.error("Upload failed")})};return o.jsxs(o.Fragment,{children:[o.jsxs("button",{onClick:()=>{var r;return(r=e.current)==null?void 0:r.click()},className:"inline-flex items-center gap-2 px-4 py-2 bg-white border border-gray-300 text-sm font-medium rounded-md text-gray-700 hover:bg-gray-50",title:"Import dataset",children:[o.jsx(nc,{className:"w-4 h-4"}),"Import"]}),o.jsx("input",{type:"file",ref:e,onChange:n,accept:".json",className:"hidden"})]})}const Om=6;function PL({datasets:e}){const{rootPath:t}=Un().props,[n,r]=E.useState(""),[a,l]=E.useState(1),[c,d]=E.useState([]),p=E.useMemo(()=>e.filter(_=>_.name.toLowerCase().includes(n.toLowerCase())||_.description.toLowerCase().includes(n.toLowerCase())),[e,n]),m=Math.ceil(p.length/Om),h=p.slice((a-1)*Om,a*Om),g=_=>{confirm("Are you sure you want to delete this dataset?")&&Xe.delete(`${t}/datasets/${_}`)},x=_=>{Xe.post(`${t}/datasets/${_}/refresh`)},j=_=>{Xe.post(`${t}/datasets/${_}/abort`,{},{preserveScroll:!0,preserveState:!0})};E.useEffect(()=>{let _;return e.some(b=>b.workflow_status==="analyzing")&&(_=window.setInterval(()=>{Xe.get(window.location.href,{},{preserveScroll:!0,preserveState:!0,only:["datasets"]})},2e3)),()=>{_&&window.clearInterval(_)}},[e]);const y=_=>{d(N=>N.includes(_)?N.filter(b=>b!==_):[...N,_])};return e.length===0?o.jsx("div",{className:"p-8",children:o.jsx(op,{icon:dn,title:"Create your first dataset",description:"Create a dataset to start training your machine learning models",actionLabel:"Create Dataset",onAction:()=>{Xe.visit(`${t}/datasets/new`)}})}):o.jsx("div",{className:"p-8",children:o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:"Datasets"}),o.jsx(p0,{value:n,onChange:r,placeholder:"Search datasets..."})]}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx(AL,{}),o.jsxs(Or,{href:`${t}/datasets/new`,className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:[o.jsx(oa,{className:"w-4 h-4"}),"New Dataset"]})]})]}),h.length===0?o.jsxs("div",{className:"text-center py-12 bg-white rounded-lg shadow",children:[o.jsx(dn,{className:"mx-auto h-12 w-12 text-gray-400"}),o.jsx("h3",{className:"mt-2 text-sm font-medium text-gray-900",children:"No datasets found"}),o.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"No datasets match your search criteria. Try adjusting your search or create a new dataset."}),o.jsx("div",{className:"mt-6",children:o.jsxs(Or,{href:`${t}/datasets/new`,className:"inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:[o.jsx(oa,{className:"w-4 h-4 mr-2"}),"New Dataset"]})})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:h.map(_=>o.jsx(EL,{dataset:_,rootPath:t,onDelete:g,onRefresh:x,onAbort:j,isErrorExpanded:c.includes(_.id),onToggleError:y},_.id))}),m>1&&o.jsx(f0,{currentPage:a,totalPages:m,onPageChange:l})]})]})})}const TL=Object.freeze(Object.defineProperty({__proto__:null,default:PL},Symbol.toStringTag,{value:"Module"})),Lj=()=>{const e=$n.createContext(null);return[()=>{const t=$n.useContext(e);if(t===null)throw new Error("useContext must be inside a Provider with a value");return t},e.Provider]},Kh=e=>{const t=structuredClone(e??{});for(const n in t)Wt.isPlainObject(t[n])?t[n]=Kh(t[n]):Array.isArray(t[n])?t[n]=t[n].map(r=>Kh(r)):t[n]!==void 0&&t[n]!==null||(t[n]="");return t},Mj=(e,t)=>{Object.entries(e).forEach(([n,r])=>{Wt.isPlainObject(r)?(Ob(e,n,`${n}${t}`),Mj(r,t)):Array.isArray(r)&&Ob(e,n,`${n}${t}`)})},Ob=(e,t,n)=>{t!==n&&(e[n]=e[t],delete e[t])},Dj=(e,t)=>{var r;const n=t.replace(/\[\]$/,"");if(n.includes("[]")){const a=n.indexOf("[]"),l=n.slice(0,a),c=n.slice(a+2),d=Wt.get(e,l);if(Array.isArray(d))for(let p=0;p<d.length;p++)Dj(e,`${l}[${p}]${c}`)}if(n.charAt(n.length-1)==="]"){const a=n.match(/(?<index>\d*)\]$/),l=Wt.get(e,n.slice(0,n.lastIndexOf("[")));Array.isArray(l)&&((r=a==null?void 0:a.groups)==null?void 0:r.index)!==void 0&&l.splice(Number(a.groups.index),1)}else Wt.unset(e,n)},Rb=e=>Array.isArray(e)?e:[e],[OL,jF]=Lj();function lc(e,t){const n=E.useCallback(()=>{let Y=null,Z=e;return typeof e=="string"&&(Y=e,Z=t),[Y,Kh(Z)]},[e,t]),[r,a]=n(),[l,c]=E.useState(a||{}),[d,p]=r?fy(a,`${r}:data`):E.useState(a),m=E.useMemo(()=>{const Y=d?Object.keys(d):[];if(Y.length===1)return Y[0]},[d]),[h,g]=r?fy({},`${r}:errors`):E.useState({}),[x,j]=E.useState(!1),[y,_]=E.useState(!1),[N,b]=E.useState(),[w,k]=E.useState(!1),[R,D]=E.useState(!1),T=E.useRef(null),z=E.useRef();let F=E.useRef(Y=>Y);const B=E.useRef();E.useEffect(()=>(B.current=!0,()=>{B.current=!1}),[]);let W=E.useRef(),le=E.useRef();E.useEffect(()=>{W.current&&le.current&&W.current(...le.current)},[d]);let se=!1;try{se=OL().railsAttributes}catch{}const be=(Y,Z,oe={})=>{const G={...oe,onCancelToken:ne=>{if(T.current=ne,oe.onCancelToken)return oe.onCancelToken(ne)},onBefore:ne=>{if(k(!1),D(!1),clearTimeout(z.current),oe.onBefore)return oe.onBefore(ne)},onStart:ne=>{if(_(!0),oe.onStart)return oe.onStart(ne)},onProgress:ne=>{if(b(ne),oe.onProgress)return oe.onProgress(ne)},onSuccess:ne=>{if(B.current&&(_(!1),b(null),g({}),j(!1),k(!0),D(!0),z.current=setTimeout(()=>{B.current&&D(!1)},2e3)),oe.onSuccess)return oe.onSuccess(ne)},onError:ne=>{if(B.current&&(_(!1),b(null),g((fe=>{if(!fe||!m)return fe;const Oe={};return Object.keys(fe).forEach(dt=>{Oe[`${m}.${dt}`]=fe[dt]}),Oe})(ne)),j(!0)),oe.onError)return oe.onError(ne)},onCancel:()=>{if(B.current&&(_(!1),b(null)),oe.onCancel)return oe.onCancel()},onFinish:ne=>{if(B.current&&(_(!1),b(null)),T.current=null,oe.onFinish)return oe.onFinish(ne)}};let te=F.current(structuredClone(d));se&&(te=((ne,fe="_attributes")=>{const Oe=structuredClone(ne);return Object.values(Oe).forEach(dt=>{Wt.isPlainObject(dt)&&Mj(dt,fe)}),Oe})(te)),Y==="delete"?Xe.delete(Z,{...G,data:te}):Xe[Y](Z,te,G)},ve=Y=>{if(!Y)return void g({});const Z=Rb(Y);g(oe=>{const G=Object.keys(oe).reduce((te,ne)=>({...te,...Z.length>0&&!Z.includes(String(ne))?{[ne]:oe[ne]}:{}}),{});return j(Object.keys(G).length>0),G})};return{data:d,isDirty:!Wt.isEqual(d,l),errors:h,hasErrors:x,processing:y,progress:N,wasSuccessful:w,recentlySuccessful:R,transform:Y=>{F.current=Y},onChange:Y=>{W.current=Y},setData:(Y,Z)=>{if(typeof Y=="string")return p(oe=>{const G=structuredClone(oe);return W.current&&(le.current=[Y,Z,Wt.get(oe,Y)]),Wt.set(G,Y,Z),G});Y instanceof Function?p(oe=>{const G=Y(structuredClone(oe));return W.current&&(le.current=[void 0,G,oe]),G}):(W.current&&(le.current=[void 0,d,Y]),p(Y))},getData:Y=>Wt.get(d,Y),unsetData:Y=>{p(Z=>{const oe=structuredClone(Z);return W.current&&(le.current=[Y,Wt.get(Z,Y),void 0]),Dj(oe,Y),oe})},setDefaults:(Y,Z)=>{c(Y!==void 0?oe=>({...oe,...typeof Y=="string"?{[Y]:Z}:Y}):()=>d)},reset:Y=>{if(!Y)return W.current&&(le.current=[void 0,l,d]),p(l),void g({});const Z=Rb(Y),oe=structuredClone(d);Z.forEach(G=>{Wt.set(oe,G,Wt.get(l,G))}),ve(Y),W.current&&(le.current=[void 0,oe,d]),p(oe)},setError:(Y,Z)=>{g(oe=>{const G={...oe,...typeof Y=="string"?{[Y]:Z}:Y};return j(Object.keys(G).length>0),G})},getError:Y=>Wt.get(h,Y),clearErrors:ve,submit:be,get:(Y,Z)=>{be("get",Y,Z)},post:(Y,Z)=>{be("post",Y,Z)},put:(Y,Z)=>{be("put",Y,Z)},patch:(Y,Z)=>{be("patch",Y,Z)},delete:(Y,Z)=>{be("delete",Y,Z)},cancel:()=>{T.current&&T.current.cancel()}}}const[RL,SF]=(()=>{const e=$n.createContext(null);return[()=>{const t=$n.useContext(e);if(t===null)throw new Error("useContext must be inside a Provider with a value");return t},e.Provider]})();Lj();const IL=$n.forwardRef(({children:e,type:t="submit",disabled:n=!1,component:r="button",requiredFields:a,...l},c)=>{const{data:d,getData:p,processing:m}=RL(),h=E.useCallback(()=>!(!a||a.length===0)&&a.some(g=>{return typeof(x=p(g))=="string"?x==="":typeof x=="number"?x!==0&&!x:Wt.isEmpty(x);var x}),[d]);return $n.createElement(r,{children:e,type:t,disabled:n||m||a&&h(),ref:c,...l})});$n.memo(IL);function LL({datasource:e,constants:t}){var m,h,g,x;const{rootPath:n}=Un().props,r=!!e,{data:a,setData:l,processing:c,errors:d}=lc({datasource:{name:(e==null?void 0:e.name)??"",datasource_type:(e==null?void 0:e.datasource_type)??"s3",s3_bucket:(e==null?void 0:e.s3_bucket)??"",s3_prefix:(e==null?void 0:e.s3_prefix)??"",s3_region:(e==null?void 0:e.s3_region)??"us-east-1"}}),p=j=>{j.preventDefault(),r?Xe.patch(`${n}/datasources/${e.id}`,a):Xe.post(`${n}/datasources`,a)};return o.jsx("div",{className:"max-w-2xl mx-auto py-8",children:o.jsxs("div",{className:"bg-white rounded-lg shadow-lg p-6",children:[o.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-6",children:r?"Edit Datasource":"New Datasource"}),o.jsxs("form",{onSubmit:p,className:"space-y-6",children:[o.jsxs("div",{children:[o.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-gray-700",children:"Name"}),o.jsx("input",{type:"text",id:"name",value:a.datasource.name,onChange:j=>l("datasource.name",j.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-4 shadow-sm border-gray-300 border",required:!0}),((m=d.datasource)==null?void 0:m.name)&&o.jsx("p",{className:"mt-1 text-sm text-red-600",children:d.datasource.name})]}),!r&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Type"}),o.jsx(ct,{options:t.DATASOURCE_TYPES,value:a.datasource.datasource_type,onChange:j=>l("datasource.datasource_type",j),placeholder:"Select datasource type"})]}),o.jsxs("div",{children:[o.jsx("label",{htmlFor:"s3_bucket",className:"block text-sm font-medium text-gray-700",children:"S3 Bucket"}),o.jsx("input",{type:"text",id:"s3_bucket",value:a.datasource.s3_bucket,onChange:j=>l("datasource.s3_bucket",j.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-4 shadow-sm border-gray-300 border",required:!0}),((h=d.datasource)==null?void 0:h.s3_bucket)&&o.jsx("p",{className:"mt-1 text-sm text-red-600",children:d.datasource.s3_bucket})]}),o.jsxs("div",{children:[o.jsx("label",{htmlFor:"s3_prefix",className:"block text-sm font-medium text-gray-700",children:"S3 Prefix"}),o.jsx("input",{type:"text",id:"s3_prefix",value:a.datasource.s3_prefix,onChange:j=>l("datasource.s3_prefix",j.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-4 shadow-sm border-gray-300 border",placeholder:"data/raw/"}),((g=d.datasource)==null?void 0:g.s3_prefix)&&o.jsx("p",{className:"mt-1 text-sm text-red-600",children:d.datasource.s3_prefix})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"S3 Region"}),o.jsx(ct,{options:t.s3.S3_REGIONS,value:a.datasource.s3_region,onChange:j=>l("datasource.s3_region",j),placeholder:"Select s3 region"}),((x=d.datasource)==null?void 0:x.s3_region)&&o.jsx("p",{className:"mt-1 text-sm text-red-600",children:d.datasource.s3_region})]}),o.jsxs("div",{className:"flex justify-end gap-3",children:[o.jsx("button",{type:"button",onClick:()=>Xe.visit(`${n}/datasources`),className:"px-4 py-2 text-sm font-medium text-gray-700 hover:text-gray-900",children:"Cancel"}),o.jsx("button",{type:"submit",disabled:c,className:"px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:c?"Saving...":r?"Save Changes":"Create Datasource"})]})]})]})})}const ML=Object.freeze(Object.defineProperty({__proto__:null,default:LL},Symbol.toStringTag,{value:"Module"})),Rm=6;function DL({datasources:e}){const{rootPath:t}=Un().props;console.log(`rootPath: ${t}`);const[n,r]=E.useState(""),[a,l]=E.useState(1),[c,d]=E.useState([]),p=E.useMemo(()=>e.filter(N=>N.name.toLowerCase().includes(n.toLowerCase())||N.s3_bucket.toLowerCase().includes(n.toLowerCase())),[n,e]),m=Math.ceil(p.length/Rm),h=p.slice((a-1)*Rm,a*Rm),g=N=>{confirm("Are you sure you want to delete this datasource? This action cannot be undone.")&&Xe.delete(`${t}/datasources/${N}`)},x=N=>{d(b=>b.includes(N)?b.filter(w=>w!==N):[...b,N])},j=async N=>{try{Xe.post(`${t}/datasources/${N}/sync`,{},{preserveScroll:!0,preserveState:!0,onSuccess:b=>{console.log("SUCCESS")},onError:()=>{console.error("Failed to sync datasource")}})}catch(b){console.error("Failed to sync datasource:",b)}},y=async N=>{try{await Xe.post(`${t}/datasources/${N}/abort`,{},{preserveScroll:!0,preserveState:!0})}catch(b){console.error("Failed to abort datasource sync:",b)}},_=N=>{if(N==="Not Synced")return N;const b=new Date(N);return isNaN(b.getTime())?N:b.toLocaleString()};return E.useEffect(()=>{let N;return e.some(w=>w.is_syncing)&&(N=window.setInterval(()=>{Xe.get(window.location.href,{},{preserveScroll:!0,preserveState:!0,only:["datasources"]})},2e3)),()=>{N&&window.clearInterval(N)}},[e]),e.length===0?o.jsx("div",{className:"p-8",children:o.jsx(op,{icon:Ws,title:"Connect your first data source",description:"Connect to your data sources to start creating datasets and training models",actionLabel:"Add Datasource",onAction:()=>{Xe.visit(`${t}/datasources/new`)}})}):o.jsx("div",{className:"p-8",children:o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:"Datasources"}),o.jsx(p0,{value:n,onChange:r,placeholder:"Search datasources..."})]}),o.jsxs(Or,{href:`${t}/datasources/new`,className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:[o.jsx(oa,{className:"w-4 h-4"}),"New Datasource"]})]}),h.length===0?o.jsxs("div",{className:"text-center py-12 bg-white rounded-lg shadow",children:[o.jsx(Ws,{className:"mx-auto h-12 w-12 text-gray-400"}),o.jsx("h3",{className:"mt-2 text-sm font-medium text-gray-900",children:"No datasources found"}),o.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"No datasources match your search criteria. Try adjusting your search or add a new datasource."}),o.jsx("div",{className:"mt-6",children:o.jsxs(Or,{href:`${t}/datasources/new`,className:"inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:[o.jsx(oa,{className:"w-4 h-4 mr-2"}),"New Datasource"]})})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:h.map(N=>o.jsxs("div",{className:"bg-white rounded-lg shadow-md p-6 hover:shadow-lg transition-shadow",children:[o.jsxs("div",{className:"flex justify-between items-start mb-4",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(Ws,{className:"w-5 h-5 text-blue-600 mt-1"}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:N.name}),N.is_syncing?o.jsx(Fa,{variant:"warning",children:"syncing"}):N.sync_error?o.jsx(Fa,{variant:"important",children:"sync error"}):N.last_synced_at!=="Not Synced"?o.jsx(Fa,{variant:"success",children:"synced"}):o.jsx(Fa,{variant:"warning",children:"not synced"})]}),o.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:["s3://",N.s3_bucket,"/",N.s3_prefix]})]})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("button",{onClick:()=>j(N.id),disabled:N.is_syncing,className:`text-gray-400 hover:text-blue-600 transition-colors ${N.is_syncing?"animate-spin":""}`,title:"Sync datasource",children:o.jsx(vw,{className:"w-5 h-5"})}),N.is_syncing&&o.jsx("button",{onClick:()=>y(N.id),className:"text-gray-400 hover:text-red-600 transition-colors",title:"Abort sync",children:o.jsx(El,{className:"w-5 h-5"})}),o.jsx(Or,{href:`${t}/datasources/${N.id}/edit`,className:"text-gray-400 hover:text-blue-600 transition-colors",title:"Edit datasource",children:o.jsx(tc,{className:"w-5 h-5"})}),o.jsx("button",{onClick:()=>g(N.id),className:"text-gray-400 hover:text-red-600 transition-colors",title:"Delete datasource",children:o.jsx(yo,{className:"w-5 h-5"})})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4 mt-4",children:[o.jsxs("div",{children:[o.jsx("span",{className:"text-sm text-gray-500",children:"Region"}),o.jsx("p",{className:"text-sm font-medium text-gray-900",children:N.s3_region})]}),o.jsxs("div",{children:[o.jsx("span",{className:"text-sm text-gray-500",children:"Last Sync"}),o.jsx("p",{className:"text-sm font-medium text-gray-900",children:_(N.last_synced_at)})]})]}),N.sync_error&&N.stacktrace&&o.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-100",children:[o.jsxs("button",{onClick:()=>x(N.id),className:"flex items-center gap-2 text-sm text-red-600 hover:text-red-700",children:[o.jsx(Mn,{className:"w-4 h-4"}),o.jsx("span",{children:"View Error Details"}),c.includes(N.id)?o.jsx(ec,{className:"w-4 h-4"}):o.jsx(vo,{className:"w-4 h-4"})]}),c.includes(N.id)&&o.jsx("div",{className:"mt-2 p-3 bg-red-50 rounded-md",children:o.jsx("pre",{className:"text-xs text-red-700 whitespace-pre-wrap font-mono",children:N.stacktrace})})]})]},N.id))}),m>1&&o.jsx(f0,{currentPage:a,totalPages:m,onPageChange:l})]})]})})}const FL=Object.freeze(Object.defineProperty({__proto__:null,default:DL},Symbol.toStringTag,{value:"Module"}));function zL({isOpen:e,onClose:t,onSave:n,initialData:r,metrics:a,tunerJobConstants:l,timezone:c,retrainingJobConstants:d}){var D,T,z,F,B,W,le,se,be,ve,Y,Z,oe,G,te,ne,fe,Oe,dt,Je,K,we,Ce,Ne;const[p,m]=E.useState(!1);E.useState(null);const h=Object.entries(l).filter(([X,pe])=>Array.isArray(pe.options)).reduce((X,[pe,xe])=>({...X,[pe]:xe.options[0].value}),{}),g=h.booster,x=Object.entries(l.hyperparameters[g]||{}).filter(([X,pe])=>!Array.isArray(pe.options)).reduce((X,[pe,xe])=>({...X,[pe]:{min:xe.min,max:xe.max}}),{}),[j,y]=E.useState({retraining_job_attributes:{id:((D=r.retraining_job)==null?void 0:D.id)||null,active:((T=r.retraining_job)==null?void 0:T.active)??!1,frequency:((z=r.retraining_job)==null?void 0:z.frequency)||d.frequency[0].value,tuning_frequency:((F=r.retraining_job)==null?void 0:F.tuning_frequency)||"month",direction:((B=r.retraining_job)==null?void 0:B.direction)||"maximize",batch_mode:((W=r.retraining_job)==null?void 0:W.batch_mode)||!1,batch_size:((le=r.retraining_job)==null?void 0:le.batch_size)||100,batch_overlap:((se=r.retraining_job)==null?void 0:se.batch_overlap)||1,batch_key:((be=r.retraining_job)==null?void 0:be.batch_key)||"",at:{hour:((Y=(ve=r.retraining_job)==null?void 0:ve.at)==null?void 0:Y.hour)??2,day_of_week:((oe=(Z=r.retraining_job)==null?void 0:Z.at)==null?void 0:oe.day_of_week)??1,day_of_month:((te=(G=r.retraining_job)==null?void 0:G.at)==null?void 0:te.day_of_month)??1},metric:((ne=r.retraining_job)==null?void 0:ne.metric)||(((Oe=(fe=a[r.task])==null?void 0:fe[0])==null?void 0:Oe.value)??""),threshold:((dt=r.retraining_job)==null?void 0:dt.threshold)??(r.task==="classification"?.85:.1),tuner_config:(Je=r.retraining_job)!=null&&Je.tuner_config?{n_trials:r.retraining_job.tuner_config.n_trials||10,config:{...h,...x,...r.retraining_job.tuner_config.config}}:void 0,tuning_enabled:((K=r.retraining_job)==null?void 0:K.tuning_enabled)??!1}});if(E.useEffect(()=>{j.retraining_job_attributes.tuner_config&&Object.keys(j.retraining_job_attributes.tuner_config.config).length===0&&y(X=>({...X,retraining_job_attributes:{...X.retraining_job_attributes,tuner_config:{...X.retraining_job_attributes.tuner_config,config:{...h,...x}}}}))},[j.retraining_job_attributes.tuner_config]),!e)return null;const _=(X,pe)=>{y(xe=>({...xe,retraining_job_attributes:{...xe.retraining_job_attributes,tuner_config:{...xe.retraining_job_attributes.tuner_config,config:{...xe.retraining_job_attributes.tuner_config.config,[X]:pe}}}}))},N=()=>{const X=Object.entries(l).filter(([xe,He])=>Array.isArray(He.options)),pe=X.map(([xe])=>xe);return o.jsxs("div",{className:"space-y-4",children:[X.map(([xe,He])=>{var rn;return o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700",children:He.label}),o.jsx(ct,{options:He.options.map(Ke=>({value:Ke.value,label:Ke.label,description:Ke.description})),value:((rn=j.retraining_job_attributes.tuner_config)==null?void 0:rn.config[xe])||He.options[0].value,onChange:Ke=>_(xe,Ke)})]},xe)}),pe.map(xe=>{var Ke;const He=Object.entries(l).filter(([mn,Bn])=>Bn.depends_on===xe),rn=((Ke=j.retraining_job_attributes.tuner_config)==null?void 0:Ke.config[xe])||l[xe].options[0].value;return o.jsxs("div",{className:"space-y-4",children:[o.jsx("h4",{className:"text-sm font-medium text-gray-900",children:"Parameter Ranges"}),o.jsx("div",{className:"space-y-4 max-h-[400px] overflow-y-auto pr-2",children:He.map(([mn,Bn])=>{const xt=Bn[rn];return xt?Object.entries(xt).map(([Jt,vt])=>{var Vt,Tt,hn,Nn;return vt.min!==void 0&&vt.max!==void 0?o.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("label",{className:"text-sm font-medium text-gray-900",children:vt.label}),o.jsx("span",{className:"text-xs text-gray-500",children:vt.description})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Minimum"}),o.jsx("input",{type:"number",min:vt.min,max:vt.max,step:vt.step,value:((Tt=(Vt=j.retraining_job_attributes.tuner_config)==null?void 0:Vt.config[Jt])==null?void 0:Tt.min)??vt.min,onChange:ie=>b(Jt,"min",parseFloat(ie.target.value)),className:"block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Maximum"}),o.jsx("input",{type:"number",min:vt.min,max:vt.max,step:vt.step,value:((Nn=(hn=j.retraining_job_attributes.tuner_config)==null?void 0:hn.config[Jt])==null?void 0:Nn.max)??vt.max,onChange:ie=>b(Jt,"max",parseFloat(ie.target.value)),className:"block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"})]})]})]},Jt):null}):null})})]},xe)})]})},b=(X,pe,xe)=>{y(He=>({...He,retraining_job_attributes:{...He.retraining_job_attributes,tuner_config:{...He.retraining_job_attributes.tuner_config,config:{...He.retraining_job_attributes.tuner_config.config,[X]:{...He.retraining_job_attributes.tuner_config.config[X],[pe]:xe}}}}}))},w=(X,pe)=>{y(xe=>X==="hour"||X==="day_of_week"||X==="day_of_month"?{...xe,retraining_job_attributes:{...xe.retraining_job_attributes,at:{...xe.retraining_job_attributes.at,[X]:pe}}}:{...xe,retraining_job_attributes:{...xe.retraining_job_attributes,[X]:pe}})},k=(X,pe)=>{y(xe=>({...xe,retraining_job_attributes:{...xe.retraining_job_attributes,[X]:pe}}))},R=()=>{const{retraining_job_attributes:X}=j,pe={hour:X.at.hour};switch(X.frequency){case"day":break;case"week":pe.day_of_week=X.at.day_of_week;break;case"month":pe.day_of_month=X.at.day_of_month;break}const xe={retraining_job_attributes:{...X,at:pe}};n(xe),t()};return o.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-start justify-center pt-[5vh] z-50",children:o.jsxs("div",{className:"bg-white rounded-lg w-full max-w-6xl flex flex-col",style:{maxHeight:"90vh"},children:[o.jsxs("div",{className:"flex-none flex justify-between items-center p-4 border-b",children:[o.jsx("h2",{className:"text-lg font-semibold",children:"Training Configuration"}),o.jsx("button",{onClick:t,className:"text-gray-500 hover:text-gray-700",children:o.jsx(rc,{className:"w-5 h-5"})})]}),o.jsxs("div",{className:"flex-1 p-6 grid grid-cols-2 gap-8 overflow-y-auto",children:[o.jsx("div",{className:"space-y-8",children:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Hd,{className:"w-5 h-5 text-blue-600"}),o.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Training Schedule"})]}),o.jsxs("div",{className:"flex items-center",children:[o.jsx("input",{type:"checkbox",id:"scheduleEnabled",checked:j.retraining_job_attributes.active,onChange:X=>y(pe=>({...pe,retraining_job_attributes:{...pe.retraining_job_attributes,active:X.target.checked}})),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),o.jsx("label",{htmlFor:"scheduleEnabled",className:"ml-2 text-sm text-gray-700",children:"Enable scheduled training"})]})]}),!j.retraining_job_attributes.active&&o.jsx("div",{className:"bg-gray-50 rounded-lg p-4",children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(Mn,{className:"w-5 h-5 text-gray-400 mt-0.5"}),o.jsxs("div",{children:[o.jsx("h4",{className:"text-sm font-medium text-gray-900",children:"Manual Training Mode"}),o.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"The model will only be trained when you manually trigger training. You can do this from the model details page at any time."})]})]})}),j.retraining_job_attributes.active&&o.jsx(o.Fragment,{children:o.jsx("div",{className:"space-y-6",children:o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Frequency"}),o.jsx(ct,{options:d.frequency.map(X=>({value:X.value,label:X.label,description:X.description})),value:j.retraining_job_attributes.frequency,onChange:X=>w("frequency",X)})]}),j.retraining_job_attributes.frequency==="week"&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Day of Week"}),o.jsx(ct,{options:[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:2,label:"Tuesday"},{value:3,label:"Wednesday"},{value:4,label:"Thursday"},{value:5,label:"Friday"},{value:6,label:"Saturday"}],value:j.retraining_job_attributes.at.day_of_week,onChange:X=>w("day_of_week",X)})]}),j.retraining_job_attributes.frequency==="month"&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Day of Month"}),o.jsx(ct,{options:Array.from({length:31},(X,pe)=>({value:pe+1,label:`Day ${pe+1}`})),value:j.retraining_job_attributes.at.day_of_month,onChange:X=>w("day_of_month",X)})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-sm font-medium text-gray-700",children:["Hour (",c,")"]}),o.jsx(ct,{options:Array.from({length:24},(X,pe)=>({value:pe,label:`${pe}:00`})),value:j.retraining_job_attributes.at.hour,onChange:X=>w("hour",X)})]})]})})}),o.jsxs("div",{className:"space-y-4 pt-4 border-t",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("div",{className:"flex items-center gap-2",children:o.jsxs("label",{htmlFor:"batchTrainingEnabled",className:"text-sm font-medium text-gray-700 flex items-center gap-2",children:["Enable Batch Training",o.jsx("button",{type:"button",onClick:()=>m(!p),className:"text-gray-400 hover:text-gray-600",children:o.jsx(gw,{className:"w-4 h-4"})})]})}),o.jsx("input",{type:"checkbox",id:"batchMode",checked:j.retraining_job_attributes.batch_mode,onChange:X=>y({...j,retraining_job_attributes:{...j.retraining_job_attributes,batch_mode:X.target.checked}}),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"})]}),p&&o.jsx("div",{className:"bg-blue-50 rounded-lg p-4 text-sm text-blue-700",children:o.jsxs("ul",{className:"space-y-2",children:[o.jsx("li",{children:"• When disabled, the model will train on the entire dataset in a single pass."}),o.jsx("li",{children:"• When enabled, the model will learn from small batches of data iteratively, improving training speed"})]})}),j.retraining_job_attributes.batch_mode&&o.jsxs("div",{className:"mt-4",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"flex-1",children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Batch Size"}),o.jsx("input",{type:"number",value:j.retraining_job_attributes.batch_size,onChange:X=>y({...j,retraining_job_attributes:{...j.retraining_job_attributes,batch_size:parseInt(X.target.value)}}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"})]}),o.jsxs("div",{className:"flex-1",children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Batch Overlap"}),o.jsx("input",{type:"number",value:j.retraining_job_attributes.batch_overlap,onChange:X=>y({...j,retraining_job_attributes:{...j.retraining_job_attributes,batch_overlap:parseInt(X.target.value)}}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"})]})]}),o.jsxs("div",{className:"mt-4",children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Batch Key"}),o.jsx(ct,{value:j.retraining_job_attributes.batch_key,onChange:X=>y({...j,retraining_job_attributes:{...j.retraining_job_attributes,batch_key:X}}),options:((Ce=(we=r.dataset)==null?void 0:we.columns)==null?void 0:Ce.map(X=>({value:X.name,label:X.name})))||[],placeholder:"Select a column for batch key"})]})]})]}),o.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[o.jsx(Mn,{className:"w-5 h-5 text-blue-600"}),o.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Evaluator Configuration"})]}),o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Metric"}),o.jsx(ct,{options:a[r.task].map(X=>({value:X.value,label:X.label,description:X.description})),value:j.retraining_job_attributes.metric,onChange:X=>k("metric",X)})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Threshold"}),o.jsx("input",{type:"number",value:j.retraining_job_attributes.threshold,onChange:X=>k("threshold",parseFloat(X.target.value)),step:.01,className:"block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-4 shadow-sm border-gray-300 border"})]})]}),o.jsx("div",{className:"bg-blue-50 rounded-md p-4",children:o.jsxs("div",{className:"flex items-start",children:[o.jsx(Mn,{className:"w-5 h-5 text-blue-400 mt-0.5"}),o.jsxs("div",{className:"ml-3",children:[o.jsx("h3",{className:"text-sm font-medium text-blue-800",children:"Deployment Criteria"}),o.jsx("p",{className:"mt-2 text-sm text-blue-700",children:(()=>{const X=a[r.task].find(xe=>xe.value===j.retraining_job_attributes.metric),pe=(X==null?void 0:X.direction)==="minimize"?"below":"above";return`The model will be automatically deployed when the ${X==null?void 0:X.label} is ${pe} ${j.retraining_job_attributes.threshold}.`})()})]})]})})]})]})]})}),o.jsx("div",{className:"space-y-8",children:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(la,{className:"w-5 h-5 text-blue-600"}),o.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Hyperparameter Tuning"})]}),o.jsxs("div",{className:"flex items-center",children:[o.jsx("input",{type:"checkbox",id:"tuningEnabled",checked:j.retraining_job_attributes.tuning_enabled||!1,onChange:X=>y(pe=>({...pe,retraining_job_attributes:{...pe.retraining_job_attributes,tuning_enabled:X.target.checked,tuner_config:X.target.checked?{n_trials:10,config:x}:void 0}})),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),o.jsx("label",{htmlFor:"tuningEnabled",className:"ml-2 text-sm text-gray-700",children:"Enable tuning"})]})]}),j.retraining_job_attributes.tuning_enabled&&o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Frequency"}),o.jsx(ct,{options:[{value:"always",label:"Always",description:"Tune hyperparameters every time"},{value:"week",label:"Weekly",description:"Tune hyperparameters once every week"},{value:"month",label:"Monthly",description:"Tune hyperparameters once every month"}],value:j.retraining_job_attributes.tuning_frequency||"week",onChange:X=>y(pe=>({...pe,retraining_job_attributes:{...pe.retraining_job_attributes,tuning_frequency:X}}))})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Number of Trials"}),o.jsx("input",{type:"number",min:"1",max:"1000",value:((Ne=j.retraining_job_attributes.tuner_config)==null?void 0:Ne.n_trials)||10,onChange:X=>y(pe=>({...pe,retraining_job_attributes:{...pe.retraining_job_attributes,tuner_config:{...pe.retraining_job_attributes.tuner_config,n_trials:parseInt(X.target.value)}}})),className:"block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-4 shadow-sm border-gray-300 border"})]})]}),N()]})]})})]}),o.jsxs("div",{className:"flex-none flex justify-end gap-4 p-4 border-t bg-white",children:[o.jsx("button",{onClick:t,className:"px-4 py-2 text-sm font-medium text-gray-700 hover:text-gray-500",children:"Cancel"}),o.jsx("button",{onClick:R,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md",children:"Save Changes"})]})]})})}const Bi=({error:e})=>e?o.jsxs("div",{className:"mt-1 flex items-center gap-1 text-sm text-red-600",children:[o.jsx(Mn,{className:"w-4 h-4"}),e]}):null;function Fj({initialData:e,datasets:t,constants:n,isEditing:r,errors:a}){var W,le,se,be,ve,Y;const{rootPath:l}=Un().props,[c,d]=E.useState(!1),[p,m]=E.useState(!1),h=lc({model:{id:e==null?void 0:e.id,name:(e==null?void 0:e.name)||"",model_type:(e==null?void 0:e.model_type)||"xgboost",dataset_id:(e==null?void 0:e.dataset_id)||"",task:(e==null?void 0:e.task)||"classification",objective:(e==null?void 0:e.objective)||"binary:logistic",metrics:(e==null?void 0:e.metrics)||["accuracy_score"],weights_column:(e==null?void 0:e.weights_column)||"",retraining_job_attributes:e!=null&&e.retraining_job?{id:e.retraining_job.id,frequency:e.retraining_job.frequency,tuning_frequency:e.retraining_job.tuning_frequency||"month",batch_mode:e.retraining_job.batch_mode,batch_size:e.retraining_job.batch_size,batch_overlap:e.retraining_job.batch_overlap,batch_key:e.retraining_job.batch_key,at:{hour:((W=e.retraining_job.at)==null?void 0:W.hour)??2,day_of_week:((le=e.retraining_job.at)==null?void 0:le.day_of_week)??1,day_of_month:((se=e.retraining_job.at)==null?void 0:se.day_of_month)??1},active:e.retraining_job.active,metric:e.retraining_job.metric,threshold:e.retraining_job.threshold,tuner_config:e.retraining_job.tuner_config,tuning_enabled:e.retraining_job.tuning_enabled||!1}:void 0}}),{data:g,setData:x,post:j,patch:y,processing:_,errors:N}=h,b={...a,...N},w=((be=n.objectives[g.model.model_type])==null?void 0:be[g.model.task])||[];E.useEffect(()=>{p&&(R(),m(!1))},[p]);const k=Z=>{x({...g,model:{...g.model,retraining_job_attributes:Z.retraining_job_attributes}}),m(!0)},R=()=>{if(g.model.retraining_job_attributes){const Z={hour:g.model.retraining_job_attributes.at.hour};switch(g.model.retraining_job_attributes.frequency){case"day":break;case"week":Z.day_of_week=g.model.retraining_job_attributes.at.day_of_week;break;case"month":Z.day_of_month=g.model.retraining_job_attributes.at.day_of_month;break}x("model.retraining_job_attributes.at",Z)}g.model.id?y(`${l}/models/${g.model.id}`,{onSuccess:()=>{Xe.visit(`${l}/models`)}}):j(`${l}/models`,{onSuccess:()=>{Xe.visit(`${l}/models`)}})},D=Z=>{Z.preventDefault(),R()},T=t.find(Z=>Z.id===g.model.dataset_id),z=(T==null?void 0:T.columns)||[],F=n.tuner_job_constants[g.model.model_type]||{},B=Z=>{x("model.task",Z),x("model.metrics",[]),x("model.objective",Z==="classification"?"binary:logistic":"reg:squarederror")};return o.jsxs("form",{onSubmit:D,className:"space-y-8",children:[o.jsxs("div",{className:"flex justify-between items-center border-b pb-4",children:[o.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Model Configuration"}),o.jsxs("button",{type:"button",onClick:()=>d(!0),className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:[o.jsx(EO,{className:"w-4 h-4"}),"Configure Training"]})]}),o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[o.jsxs("div",{children:[o.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-gray-700 mb-1",children:"Model Name"}),o.jsx("input",{type:"text",id:"name",value:g.model.name,onChange:Z=>x("model.name",Z.target.value),className:"block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-4 shadow-sm border-gray-300 border"}),o.jsx(Bi,{error:b.name})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Model Type"}),o.jsx(ct,{options:[{value:"xgboost",label:"XGBoost",description:"Gradient boosting framework"}],value:g.model.model_type,onChange:Z=>x("model.model_type",Z),placeholder:"Select model type"}),o.jsx(Bi,{error:b.model_type})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Dataset"}),r?o.jsxs("div",{className:"flex items-center gap-2 p-2 bg-gray-50 rounded-md border border-gray-200",children:[o.jsx(jO,{className:"w-4 h-4 text-gray-400"}),o.jsx("span",{className:"text-gray-700",children:T==null?void 0:T.name})]}):o.jsx(ct,{options:t.map(Z=>({value:Z.id,label:Z.name,description:`${Z.num_rows.toLocaleString()} rows`})),value:g.model.dataset_id,onChange:Z=>x("model.dataset_id",Z),placeholder:"Select dataset"}),o.jsx(Bi,{error:b.dataset_id})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Weights Column (Optional)"}),o.jsx(ct,{value:g.model.weights_column,options:z.map(Z=>({value:Z.name,label:Z.name})),onChange:Z=>x("model.weights_column",Z),isClearable:!0}),o.jsx(Bi,{error:b.weights_column})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Task"}),o.jsx(ct,{options:n.tasks,value:g.model.task,onChange:B}),o.jsx(Bi,{error:b.task})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Objective"}),o.jsx(ct,{options:w||[],value:g.model.objective,onChange:Z=>x("model.objective",Z),placeholder:"Select objective"}),o.jsx(Bi,{error:b.objective})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Metrics"}),o.jsx("div",{className:"grid grid-cols-2 gap-4",children:(ve=n.metrics[g.model.task])==null?void 0:ve.map(Z=>o.jsxs("label",{className:"relative flex items-center px-4 py-3 bg-white border rounded-lg hover:bg-gray-50 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:g.model.metrics.includes(Z.value),onChange:oe=>{const G=oe.target.checked?[...g.model.metrics,Z.value]:g.model.metrics.filter(te=>te!==Z.value);x("model.metrics",G)},className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),o.jsxs("div",{className:"ml-3",children:[o.jsx("span",{className:"block text-sm font-medium text-gray-900",children:Z.label}),o.jsxs("span",{className:"block text-xs text-gray-500",children:["Direction: ",Z.direction]})]})]},Z.value))}),o.jsx(Bi,{error:b.metrics})]})]}),g.model.retraining_job_attributes&&g.model.retraining_job_attributes.batch_mode&&o.jsx(o.Fragment,{children:o.jsxs("div",{className:"mt-4",children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Batch Key"}),o.jsx(ct,{value:g.model.retraining_job_attributes.batch_key||"",onChange:Z=>x("model",{...g.model,retraining_job_attributes:{...g.model.retraining_job_attributes,batch_key:Z}}),options:((Y=T==null?void 0:T.columns)==null?void 0:Y.map(Z=>({value:Z.name,label:Z.name})))||[],placeholder:"Select a column for batch key"}),o.jsx(Bi,{error:b["model.retraining_job_attributes.batch_key"]})]})}),o.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[o.jsx("button",{type:"button",onClick:()=>Xe.visit(`${l}/models`),className:"px-4 py-2 text-sm font-medium text-gray-700 hover:text-gray-900",children:"Cancel"}),o.jsx("button",{type:"submit",className:"px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:r?"Save Changes":"Create Model"})]}),o.jsx(zL,{isOpen:c,onClose:()=>d(!1),onSave:k,initialData:{task:g.model.task,metrics:g.model.metrics,modelType:g.model.model_type,dataset:T,retraining_job:g.model.retraining_job_attributes},metrics:n.metrics,tunerJobConstants:F,timezone:n.timezone,retrainingJobConstants:n.retraining_job_constants})]})}function $L({model:e,datasets:t,constants:n}){return o.jsx("div",{className:"max-w-3xl mx-auto py-8",children:o.jsxs("div",{className:"bg-white rounded-lg shadow-lg",children:[o.jsx("div",{className:"px-6 py-4 border-b border-gray-200",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(Yi,{className:"w-6 h-6 text-blue-600"}),o.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:"Edit Model"})]})}),o.jsx("div",{className:"p-6",children:o.jsx(Fj,{initialData:e,datasets:t,constants:n,isEditing:!0})})]})})}const UL=Object.freeze(Object.defineProperty({__proto__:null,default:$L},Symbol.toStringTag,{value:"Module"})),lt=e=>{const t=new Date;return t.setDate(t.getDate()-e),t.toISOString()},zj=[{id:1,name:"Customer Churn Dataset",description:"Historical customer data for churn prediction",columns:[{name:"usage_days",type:"numeric",description:"Number of days customer has used the product",statistics:{mean:145.7,median:130,min:1,max:365,nullCount:0}},{name:"total_spend",type:"numeric",description:"Total customer spend in USD",statistics:{mean:487.32,median:425.5,min:0,max:2500,nullCount:1250}},{name:"support_tickets",type:"numeric",description:"Number of support tickets opened",statistics:{mean:2.3,median:1,min:0,max:15,nullCount:3750}},{name:"subscription_tier",type:"categorical",description:"Customer subscription level",statistics:{uniqueCount:3,nullCount:125}},{name:"last_login",type:"datetime",description:"Last time the customer logged in",statistics:{nullCount:5e3}}],sampleData:[{usage_days:234,total_spend:567.89,support_tickets:1,subscription_tier:"premium",last_login:"2024-03-01"},{usage_days:45,total_spend:null,support_tickets:null,subscription_tier:"basic",last_login:null}],rowCount:25e3,updatedAt:"2024-03-10T12:00:00Z"}];lt(30),lt(0);lt(7),lt(1),lt(30),lt(0);lt(1),lt(1),lt(1),lt(1),lt(2),lt(2),lt(2),lt(2),lt(3),lt(3),lt(3),lt(3),lt(4),lt(4),lt(4),lt(4);const BL=[{id:1,name:"Normalize state",description:"Turn state names into 2 letter state abbreviations",groupId:1,testDatasetId:1,inputColumns:["state"],outputColumns:["state"],code:"",createdAt:lt(30),updatedAt:lt(0)}],Ba=[{id:1,name:"Customer Churn",description:"Features for customer churn dataset",features:BL,createdAt:lt(30),updatedAt:lt(0)}];function WL({value:e,onChange:t,language:n}){return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"bg-gray-900 rounded-lg overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-gray-800",children:[o.jsx("span",{className:"text-sm text-gray-400",children:"Ruby Feature"}),o.jsx("span",{className:"text-xs px-2 py-1 bg-gray-700 rounded text-gray-300",children:n})]}),o.jsx("textarea",{value:e,onChange:r=>t(r.target.value),className:"w-full h-64 p-4 bg-gray-900 text-gray-100 font-mono text-sm focus:outline-none",placeholder:`def transform(df)
|
489
|
+
end`})})]})})}function SL({options:e,initialFeatures:t=[],onFeaturesChange:n}){const[r,a]=E.useState(t),[l,c]=E.useState(null);console.log(r);const d=e.filter(N=>!r.find(b=>b.name===N.name)),p=N=>{const b=N.map((w,k)=>({...w,feature_position:k}));a(b),n(b)},m=N=>{const b=e.find(w=>w.name===N);if(b){const w={...b,feature_position:r.length};p([...r,w])}},h=N=>{const b=[...r];b.splice(N,1),p(b)},g=N=>{if(N===0)return;const b=[...r];[b[N-1],b[N]]=[b[N],b[N-1]],p(b)},x=N=>{if(N===r.length-1)return;const b=[...r];[b[N],b[N+1]]=[b[N+1],b[N]],p(b)},j=(N,b)=>{c(b)},y=(N,b)=>{if(N.preventDefault(),l===null||l===b)return;const w=[...r],[k]=w.splice(l,1);w.splice(b,0,k),p(w),c(b)},_=()=>{c(null)};return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("div",{className:"flex-1",children:o.jsx(ct,{options:d.map(N=>({value:N.name,label:N.name,description:N.description})),value:"",onChange:N=>m(N),placeholder:"Add a transform..."})}),o.jsx(jL,{})]}),o.jsxs("div",{className:"space-y-2",children:[r.map((N,b)=>o.jsxs("div",{draggable:!0,onDragStart:w=>j(w,b),onDragOver:w=>y(w,b),onDragEnd:_,className:`flex items-center gap-3 p-3 bg-white border rounded-lg ${l===b?"border-blue-500 shadow-lg":"border-gray-200"} ${l!==null?"cursor-grabbing":""}`,children:[o.jsx("button",{type:"button",className:"p-1 text-gray-400 hover:text-gray-600 cursor-grab active:cursor-grabbing",children:o.jsx(_O,{className:"w-4 h-4"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"font-medium text-gray-900",children:N.name}),o.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${N.feature_type==="calculation"?"bg-blue-100 text-blue-800":N.feature_type==="lookup"?"bg-purple-100 text-purple-800":"bg-green-100 text-green-800"}`,children:"feature"})]}),o.jsx("p",{className:"text-sm text-gray-500 truncate",children:N.description})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{type:"button",onClick:()=>g(b),disabled:b===0,className:"p-1 text-gray-400 hover:text-gray-600 disabled:opacity-50",title:"Move up",children:o.jsx(cO,{className:"w-4 h-4"})}),o.jsx("button",{type:"button",onClick:()=>x(b),disabled:b===r.length-1,className:"p-1 text-gray-400 hover:text-gray-600 disabled:opacity-50",title:"Move down",children:o.jsx(lO,{className:"w-4 h-4"})}),o.jsx("button",{type:"button",onClick:()=>h(b),className:"p-1 text-gray-400 hover:text-red-600",title:"Remove transform",children:o.jsx(rc,{className:"w-4 h-4"})})]})]},N.name)),r.length===0&&o.jsxs("div",{className:"text-center py-8 bg-gray-50 border-2 border-dashed border-gray-200 rounded-lg",children:[o.jsx(oa,{className:"w-8 h-8 text-gray-400 mx-auto mb-2"}),o.jsx("p",{className:"text-sm text-gray-500",children:"Add features to enrich your dataset"})]})]})]})}function NL({isOpen:e,onClose:t,initialDataset:n,onSave:r,constants:a}){const[l,c]=E.useState(n),[d,p]=E.useState("columns"),[m,h]=E.useState("target"),[g,x]=E.useState(!1),[j,y]=E.useState({targetColumn:l.target,dateColumn:l.date_column}),[_,N]=E.useState(null),[b,w]=E.useState(""),[k,R]=E.useState({view:"all",types:[]}),[D,T]=E.useState(n.needs_refresh||!1),z=E.useCallback(async K=>{await r(K)},[r]),{saving:F,saved:B,error:W}=wL(l,z,2e3),le=K=>{var we,Ce,Ne;return((we=K.preprocessing_steps)==null?void 0:we.training)!=null&&((Ne=(Ce=K.preprocessing_steps)==null?void 0:Ce.training)==null?void 0:Ne.method)!=="none"},se=E.useMemo(()=>l.columns.filter(K=>{const we=K.name.toLowerCase().includes(b.toLowerCase()),Ce=k.types.length===0||k.types.includes(K.datatype),Ne=(()=>{var X,pe;switch(k.view){case"training":return!K.hidden&&!K.drop_if_null;case"hidden":return K.hidden;case"preprocessed":return le(K);case"nulls":return(((pe=(X=K.statistics)==null?void 0:X.processed)==null?void 0:pe.null_count)||0)>0;case"computed":return K.is_computed;case"required":return K.required;default:return!0}})();return we&&Ce&&Ne}),[l.columns,b,k]),be=E.useMemo(()=>({total:l.columns.length,filtered:se.length,training:l.columns.filter(K=>!K.hidden&&!K.drop_if_null).length,hidden:l.columns.filter(K=>K.hidden).length,withPreprocessing:l.columns.filter(le).length,withNulls:l.columns.filter(K=>{var we,Ce;return(((Ce=(we=K.statistics)==null?void 0:we.processed)==null?void 0:Ce.null_count)||0)>0}).length,computed:l.columns.filter(K=>K.is_computed===!0).length,required:l.columns.filter(K=>K.required===!0).length}),[l.columns,se]),ve=E.useMemo(()=>Array.from(new Set(l.columns.map(K=>K.datatype))),[l.columns]),Y=E.useMemo(()=>l.columns.filter(K=>K.datatype==="datetime").map(K=>({value:K.name,label:K.name})),[l.columns]),Z=K=>{N(K)},oe=K=>{const we=l.columns.map(Ce=>({...Ce,hidden:Ce.name===K?!Ce.hidden:Ce.hidden}));c({...l,columns:we}),T(!0)},G=K=>{const we=String(K);y({...j,targetColumn:K});const Ce=l.columns.map(Ne=>({...Ne,is_target:Ne.name===we}));c({...l,columns:Ce}),T(!0)},te=K=>{const we=String(K);y(Ne=>({...Ne,dateColumn:K}));const Ce=l.columns.map(Ne=>({...Ne,is_date_column:Ne.name===we}));c({...l,columns:Ce}),T(!0)},ne=(K,we)=>{const Ce=l.columns.map(Ne=>({...Ne,datatype:Ne.name===K?we:Ne.datatype}));c({...l,columns:Ce}),T(!0)},fe=(K,we,Ce,Ne)=>{if(!l.columns.find(xe=>xe.name===K))return;const pe=l.columns.map(xe=>xe.name!==K?xe:{...xe,preprocessing_steps:{training:we,...Ne&&Ce?{inference:Ce}:{}}});c({...l,columns:pe}),T(!0)},Oe=K=>{const Ce=(l.features||[]).filter(X=>!K.find(pe=>pe.name===X.name)).map(X=>({...X,_destroy:!0})),Ne=[...K,...Ce].map((X,pe)=>({...X,dataset_id:l.id,feature_position:pe}));c(X=>({...X,features:Ne})),T(!0)},dt=async()=>{x(!0);try{await r(l),Xe.post(`/easy_ml/datasets/${l.id}/refresh`,{},{onSuccess:()=>{x(!1)},onError:()=>{console.error("Error refreshing dataset"),x(!1)}})}catch(K){console.error("Error refreshing dataset:",K),x(!1)}};if(!e)return null;const Je=_?l.columns.find(K=>K.name===_):null;return o.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:o.jsxs("div",{className:"bg-white rounded-lg w-full max-w-6xl max-h-[90vh] overflow-hidden flex flex-col",children:[o.jsxs("div",{className:"flex justify-between items-center p-4 border-b shrink-0",children:[o.jsx("h2",{className:"text-lg font-semibold",children:"Column Configuration"}),o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("div",{className:"min-w-[0px]",children:o.jsx(gR,{saving:F,saved:B,error:W})}),o.jsxs("div",{className:"relative",children:[o.jsx(yg,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),o.jsx("input",{type:"text",placeholder:"Search columns...",value:b,onChange:K=>w(K.target.value),className:"pl-9 pr-4 py-2 w-64 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"})]}),o.jsx("button",{onClick:t,className:"text-gray-500 hover:text-gray-700",children:o.jsx(rc,{className:"w-5 h-5"})})]})]}),o.jsxs("div",{className:"flex border-b shrink-0",children:[o.jsxs("button",{onClick:()=>p("columns"),className:`flex items-center gap-2 px-4 py-2 border-b-2 ${d==="columns"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:[o.jsx(la,{className:"w-4 h-4"}),"Preprocessing"]}),o.jsxs("button",{onClick:()=>p("features"),className:`flex items-center gap-2 px-4 py-2 border-b-2 ${d==="features"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:[o.jsx(AO,{className:"w-4 h-4"}),"Feature Engineering"]}),D&&o.jsx("div",{className:"ml-auto px-4 flex items-center",children:o.jsxs("button",{onClick:dt,disabled:g,className:"group relative inline-flex items-center gap-2 px-6 py-2.5 bg-gradient-to-r from-blue-600 to-indigo-600 text-white text-sm font-medium rounded-md hover:from-blue-700 hover:to-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 transition-all duration-200 shadow-md hover:shadow-lg",children:[o.jsx("div",{className:"absolute inset-0 bg-white/10 rounded-md opacity-0 group-hover:opacity-100 transition-opacity duration-200"}),g?o.jsxs(o.Fragment,{children:[o.jsx(Qa,{className:"w-4 h-4 animate-spin"}),"Applying Preprocessing..."]}):o.jsxs(o.Fragment,{children:[o.jsx(kO,{className:"w-4 h-4"}),"Apply Preprocessing"]})]})})]}),d==="columns"?o.jsxs($n.Fragment,{children:[o.jsxs("div",{className:"grid grid-cols-7 flex-1 min-h-0",children:[o.jsxs("div",{className:"col-span-3 border-r overflow-hidden flex flex-col",children:[o.jsxs("div",{className:"p-4 border-b",children:[o.jsxs("div",{className:"flex border-b",children:[o.jsxs("button",{onClick:()=>h("target"),className:`flex items-center gap-2 px-4 py-2 border-b-2 ${m==="target"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:[o.jsx(bg,{className:"w-4 h-4"}),"Target Column"]}),o.jsxs("button",{onClick:()=>h("date"),className:`flex items-center gap-2 px-4 py-2 border-b-2 ${m==="date"?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:[o.jsx(Hd,{className:"w-4 h-4"}),"Date Column"]})]}),m==="target"?o.jsx("div",{className:"mt-4",children:o.jsx(ct,{value:j.targetColumn||"",onChange:K=>G(K),options:l.columns.map(K=>({value:K.name,label:K.name})),placeholder:"Select target column..."})}):o.jsx("div",{className:"mt-4",children:Y.length>0?o.jsx(ct,{options:Y,value:j.dateColumn,onChange:te,placeholder:"Select a date column..."}):o.jsx("div",{className:"text-center py-4 text-gray-500 bg-gray-50 rounded-md",children:"No date columns available"})})]}),o.jsx("div",{className:"shrink-0",children:o.jsx(hR,{types:ve,activeFilters:k,onFilterChange:R,columnStats:be,columns:l.columns,colHasPreprocessingSteps:le})}),o.jsx("div",{className:"flex-1 overflow-y-auto p-4 min-h-0",children:o.jsx(mR,{columns:se,selectedColumn:_,onColumnSelect:Z,onToggleHidden:oe})})]}),o.jsx("div",{className:"col-span-4 overflow-y-auto p-4",children:Je?o.jsx(fR,{column:Je,dataset:l,setColumnType:ne,setDataset:c,constants:a,onUpdate:(K,we,Ce)=>fe(Je.name,K,we,Ce)}):o.jsx("div",{className:"h-full flex items-center justify-center text-gray-500",children:"Select a column to configure preprocessing"})})]}),o.jsxs("div",{className:"border-t p-4 flex justify-between items-center shrink-0",children:[o.jsxs("div",{className:"text-sm text-gray-600",children:[l.columns.filter(K=>!K.hidden).length," columns selected for training"]}),o.jsx("div",{className:"flex gap-3",children:o.jsx("button",{onClick:t,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700",children:"Close"})})]})]}):o.jsx("div",{className:"p-6 h-[calc(90vh-8rem)] overflow-y-auto",children:o.jsx(SL,{options:a.feature_options,initialFeatures:l.features,onFeaturesChange:Oe})})]})})}function kL({dataset:e,constants:t}){const[n,r]=E.useState(!1),[a,l]=E.useState(e),{rootPath:c}=Un().props,d=E.useCallback(p=>{var x;const m=Object.entries(p).reduce((j,[y,_])=>(y!=="columns"&&y!=="features"&&!Wt.isEqual(a[y],_)&&(j[y]=_),j),{}),h=p.columns.reduce((j,y)=>{const _=a.columns.find(N=>N.id===y.id);if(!_||!Wt.isEqual(_,y)){const N=Object.entries(y).reduce((b,[w,k])=>((!_||!Wt.isEqual(_[w],k))&&(b[w]=k),b),{});Object.keys(N).length>0&&(j[y.id]={...N,id:y.id})}return j},{}),g=(x=p.features)==null?void 0:x.map((j,y)=>({id:j.id,name:j.name,feature_class:j.feature_class,feature_position:y,_destroy:j._destroy}));(Object.keys(m).length>0||Object.keys(h).length>0||!Wt.isEqual(a.features,p.features))&&Xe.patch(`${c}/datasets/${e.id}`,{dataset:{...m,columns_attributes:h,features_attributes:g}},{preserveState:!0,preserveScroll:!0}),l(p)},[a,e.id,c]);return o.jsxs("div",{className:"p-8 space-y-6",children:[o.jsx("div",{className:"flex justify-end",children:o.jsxs("button",{onClick:()=>r(!0),className:"flex items-center gap-2 px-4 py-2 bg-white border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50",children:[o.jsx(tc,{className:"w-4 h-4"}),"Configure Columns"]})}),o.jsx(PO,{dataset:a}),o.jsx(NL,{isOpen:n,onClose:()=>r(!1),initialDataset:a,constants:t,onSave:d})]})}const CL=Object.freeze(Object.defineProperty({__proto__:null,default:kL},Symbol.toStringTag,{value:"Module"}));function op({icon:e,title:t,description:n,actionLabel:r,onAction:a}){return o.jsxs("div",{className:"text-center py-12",children:[o.jsx("div",{className:"w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-4",children:o.jsx(e,{className:"w-8 h-8 text-gray-400"})}),o.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:t}),o.jsx("p",{className:"text-gray-500 mb-6 max-w-sm mx-auto",children:n}),o.jsx("button",{onClick:a,className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:r})]})}function p0({value:e,onChange:t,placeholder:n="Search..."}){return o.jsxs("div",{className:"relative",children:[o.jsx(yg,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),o.jsx("input",{type:"text",value:e,onChange:r=>t(r.target.value),placeholder:n,className:"pl-9 pr-4 py-2 w-64 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"})]})}function f0({currentPage:e,totalPages:t,onPageChange:n}){return o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-200",children:[o.jsxs("div",{className:"flex-1 flex justify-between sm:hidden",children:[o.jsx("button",{onClick:()=>n(e-1),disabled:e===1,className:"relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 disabled:bg-gray-100 disabled:text-gray-400",children:"Previous"}),o.jsx("button",{onClick:()=>n(e+1),disabled:e===t,className:"relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 disabled:bg-gray-100 disabled:text-gray-400",children:"Next"})]}),o.jsxs("div",{className:"hidden sm:flex-1 sm:flex sm:items-center sm:justify-between",children:[o.jsx("div",{children:o.jsxs("p",{className:"text-sm text-gray-700",children:["Page ",o.jsx("span",{className:"font-medium",children:e})," of"," ",o.jsx("span",{className:"font-medium",children:t})]})}),o.jsx("div",{children:o.jsxs("nav",{className:"relative z-0 inline-flex rounded-md shadow-sm -space-x-px","aria-label":"Pagination",children:[o.jsxs("button",{onClick:()=>n(e-1),disabled:e===1,className:"relative inline-flex items-center px-2 py-2 rounded-l-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50 disabled:bg-gray-100 disabled:text-gray-400",children:[o.jsx("span",{className:"sr-only",children:"Previous"}),o.jsx(qd,{className:"h-5 w-5"})]}),Array.from({length:t},(r,a)=>a+1).map(r=>o.jsx("button",{onClick:()=>n(r),className:`relative inline-flex items-center px-4 py-2 border text-sm font-medium ${r===e?"z-10 bg-blue-50 border-blue-500 text-blue-600":"bg-white border-gray-300 text-gray-500 hover:bg-gray-50"}`,children:r},r)),o.jsxs("button",{onClick:()=>n(e+1),disabled:e===t,className:"relative inline-flex items-center px-2 py-2 rounded-r-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50 disabled:bg-gray-100 disabled:text-gray-400",children:[o.jsx("span",{className:"sr-only",children:"Next"}),o.jsx(no,{className:"h-5 w-5"})]})]})})]})]})}function Ij({stacktrace:e}){return o.jsx("div",{className:"mt-2 p-3 bg-red-50 rounded-md",children:o.jsx("pre",{className:"text-xs text-red-700 whitespace-pre-wrap break-words [word-break:break-word] font-mono",children:e})})}const Tm={analyzing:{bg:"bg-blue-100",text:"text-blue-800",icon:o.jsx(Qa,{className:"w-4 h-4 animate-spin"})},ready:{bg:"bg-green-100",text:"text-green-800",icon:null},failed:{bg:"bg-red-100",text:"text-red-800",icon:o.jsx(Mn,{className:"w-4 h-4"})}};function EL({dataset:e,rootPath:t,onDelete:n,onRefresh:r,onAbort:a,isErrorExpanded:l,onToggleError:c}){const d=$n.useRef(null),p=()=>{window.location.href=`${t}/datasets/${e.id}/download`},m=h=>{var j,y;const g=(j=h.target.files)==null?void 0:j[0];if(!g)return;const x=new FormData;x.append("config",g),fetch(`${t}/datasets/${e.id}/upload`,{method:"POST",body:x,credentials:"same-origin",headers:{"X-CSRF-Token":((y=document.querySelector('meta[name="csrf-token"]'))==null?void 0:y.content)||""}}).then(_=>{_.ok?window.location.reload():console.error("Upload failed")})};return o.jsxs("div",{className:"bg-white rounded-lg shadow-md p-6 hover:shadow-lg transition-shadow",children:[o.jsxs("div",{className:"flex justify-between items-start mb-4",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(dn,{className:"w-5 h-5 text-blue-600 mt-1"}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:e.name}),o.jsxs("div",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${Tm[e.workflow_status].bg} ${Tm[e.workflow_status].text}`,children:[Tm[e.workflow_status].icon,o.jsx("span",{children:e.workflow_status.charAt(0).toUpperCase()+e.workflow_status.slice(1)})]})]}),o.jsx("p",{className:"text-sm text-gray-500 mt-1",children:e.description})]})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(Or,{href:`${t}/datasets/${e.id}`,className:`transition-colors ${e.workflow_status==="analyzing"?"text-gray-300 cursor-not-allowed pointer-events-none":"text-gray-400 hover:text-blue-600"}`,title:e.workflow_status==="analyzing"?"Dataset is being analyzed":"View details",children:o.jsx(pw,{className:"w-5 h-5"})}),o.jsx("button",{onClick:()=>r(e.id),disabled:e.workflow_status==="analyzing",className:`transition-colors ${e.workflow_status==="analyzing"?"text-gray-300 cursor-not-allowed":"text-gray-400 hover:text-blue-600"}`,title:e.workflow_status==="analyzing"?"Dataset is being analyzed":"Refresh dataset",children:o.jsx(vw,{className:"w-5 h-5"})}),e.workflow_status==="analyzing"&&o.jsx("button",{onClick:()=>a(e.id),className:"text-gray-400 hover:text-red-600 transition-colors",title:"Abort analysis",children:o.jsx(El,{className:"w-5 h-5"})}),o.jsx("button",{onClick:p,className:"text-gray-400 hover:text-blue-600 transition-colors",title:"Download dataset configuration",children:o.jsx(dw,{className:"w-5 h-5"})}),o.jsx("button",{onClick:()=>{var h;return(h=d.current)==null?void 0:h.click()},className:"text-gray-400 hover:text-green-600 transition-colors",title:"Upload dataset configuration",children:o.jsx(nc,{className:"w-5 h-5"})}),o.jsx("input",{type:"file",ref:d,onChange:m,accept:".json",className:"hidden"}),o.jsx("button",{className:"text-gray-400 hover:text-red-600 transition-colors",title:"Delete dataset",onClick:()=>n(e.id),children:o.jsx(yo,{className:"w-5 h-5"})})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4 mt-4",children:[o.jsxs("div",{children:[o.jsx("span",{className:"text-sm text-gray-500",children:"Columns"}),o.jsxs("p",{className:"text-sm font-medium text-gray-900",children:[e.columns.length," columns"]})]}),o.jsxs("div",{children:[o.jsx("span",{className:"text-sm text-gray-500",children:"Rows"}),o.jsx("p",{className:"text-sm font-medium text-gray-900",children:e.num_rows.toLocaleString()})]})]}),o.jsx("div",{className:"mt-4 pt-4 border-t border-gray-100",children:o.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.columns.slice(0,3).map(h=>o.jsx("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800",children:h.name},h.name)),e.columns.length>3&&o.jsxs("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800",children:["+",e.columns.length-3," more"]})]})}),e.workflow_status==="failed"&&e.stacktrace&&o.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-100",children:[o.jsxs("button",{onClick:()=>c(e.id),className:"flex items-center gap-2 text-sm text-red-600 hover:text-red-700",children:[o.jsx(Mn,{className:"w-4 h-4"}),o.jsx("span",{children:"View Error Details"}),l?o.jsx(ec,{className:"w-4 h-4"}):o.jsx(vo,{className:"w-4 h-4"})]}),l&&o.jsx(Ij,{stacktrace:e.stacktrace})]})]})}function AL(){const e=E.useRef(null),{rootPath:t}=Un().props,n=r=>{var c,d;const a=(c=r.target.files)==null?void 0:c[0];if(!a)return;const l=new FormData;l.append("config",a),fetch(`${t}/datasets/upload`,{method:"POST",body:l,credentials:"same-origin",headers:{"X-CSRF-Token":((d=document.querySelector('meta[name="csrf-token"]'))==null?void 0:d.content)||""}}).then(p=>{p.ok?window.location.reload():console.error("Upload failed")})};return o.jsxs(o.Fragment,{children:[o.jsxs("button",{onClick:()=>{var r;return(r=e.current)==null?void 0:r.click()},className:"inline-flex items-center gap-2 px-4 py-2 bg-white border border-gray-300 text-sm font-medium rounded-md text-gray-700 hover:bg-gray-50",title:"Import dataset",children:[o.jsx(nc,{className:"w-4 h-4"}),"Import"]}),o.jsx("input",{type:"file",ref:e,onChange:n,accept:".json",className:"hidden"})]})}const Om=6;function PL({datasets:e}){console.log("change");const{rootPath:t}=Un().props,[n,r]=E.useState(""),[a,l]=E.useState(1),[c,d]=E.useState([]),p=E.useMemo(()=>e.filter(_=>_.name.toLowerCase().includes(n.toLowerCase())||_.description.toLowerCase().includes(n.toLowerCase())),[e,n]),m=Math.ceil(p.length/Om),h=p.slice((a-1)*Om,a*Om),g=_=>{confirm("Are you sure you want to delete this dataset?")&&Xe.delete(`${t}/datasets/${_}`)},x=_=>{Xe.post(`${t}/datasets/${_}/refresh`)},j=_=>{Xe.post(`${t}/datasets/${_}/abort`,{},{preserveScroll:!0,preserveState:!0})};E.useEffect(()=>{let _;return e.some(b=>b.workflow_status==="analyzing")&&(_=window.setInterval(()=>{Xe.get(window.location.href,{},{preserveScroll:!0,preserveState:!0,only:["datasets"]})},2e3)),()=>{_&&window.clearInterval(_)}},[e]);const y=_=>{d(N=>N.includes(_)?N.filter(b=>b!==_):[...N,_])};return e.length===0?o.jsx("div",{className:"p-8",children:o.jsx(op,{icon:dn,title:"Create your first dataset",description:"Create a dataset to start training your machine learning models",actionLabel:"Create Dataset",onAction:()=>{Xe.visit(`${t}/datasets/new`)}})}):o.jsx("div",{className:"p-8",children:o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:"Datasets"}),o.jsx(p0,{value:n,onChange:r,placeholder:"Search datasets..."})]}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx(AL,{}),o.jsxs(Or,{href:`${t}/datasets/new`,className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:[o.jsx(oa,{className:"w-4 h-4"}),"New Dataset"]})]})]}),h.length===0?o.jsxs("div",{className:"text-center py-12 bg-white rounded-lg shadow",children:[o.jsx(dn,{className:"mx-auto h-12 w-12 text-gray-400"}),o.jsx("h3",{className:"mt-2 text-sm font-medium text-gray-900",children:"No datasets found"}),o.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"No datasets match your search criteria. Try adjusting your search or create a new dataset."}),o.jsx("div",{className:"mt-6",children:o.jsxs(Or,{href:`${t}/datasets/new`,className:"inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:[o.jsx(oa,{className:"w-4 h-4 mr-2"}),"New Dataset"]})})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:h.map(_=>o.jsx(EL,{dataset:_,rootPath:t,onDelete:g,onRefresh:x,onAbort:j,isErrorExpanded:c.includes(_.id),onToggleError:y},_.id))}),m>1&&o.jsx(f0,{currentPage:a,totalPages:m,onPageChange:l})]})]})})}const TL=Object.freeze(Object.defineProperty({__proto__:null,default:PL},Symbol.toStringTag,{value:"Module"})),Lj=()=>{const e=$n.createContext(null);return[()=>{const t=$n.useContext(e);if(t===null)throw new Error("useContext must be inside a Provider with a value");return t},e.Provider]},Kh=e=>{const t=structuredClone(e??{});for(const n in t)Wt.isPlainObject(t[n])?t[n]=Kh(t[n]):Array.isArray(t[n])?t[n]=t[n].map(r=>Kh(r)):t[n]!==void 0&&t[n]!==null||(t[n]="");return t},Mj=(e,t)=>{Object.entries(e).forEach(([n,r])=>{Wt.isPlainObject(r)?(Ob(e,n,`${n}${t}`),Mj(r,t)):Array.isArray(r)&&Ob(e,n,`${n}${t}`)})},Ob=(e,t,n)=>{t!==n&&(e[n]=e[t],delete e[t])},Dj=(e,t)=>{var r;const n=t.replace(/\[\]$/,"");if(n.includes("[]")){const a=n.indexOf("[]"),l=n.slice(0,a),c=n.slice(a+2),d=Wt.get(e,l);if(Array.isArray(d))for(let p=0;p<d.length;p++)Dj(e,`${l}[${p}]${c}`)}if(n.charAt(n.length-1)==="]"){const a=n.match(/(?<index>\d*)\]$/),l=Wt.get(e,n.slice(0,n.lastIndexOf("[")));Array.isArray(l)&&((r=a==null?void 0:a.groups)==null?void 0:r.index)!==void 0&&l.splice(Number(a.groups.index),1)}else Wt.unset(e,n)},Rb=e=>Array.isArray(e)?e:[e],[OL,jF]=Lj();function lc(e,t){const n=E.useCallback(()=>{let Y=null,Z=e;return typeof e=="string"&&(Y=e,Z=t),[Y,Kh(Z)]},[e,t]),[r,a]=n(),[l,c]=E.useState(a||{}),[d,p]=r?fy(a,`${r}:data`):E.useState(a),m=E.useMemo(()=>{const Y=d?Object.keys(d):[];if(Y.length===1)return Y[0]},[d]),[h,g]=r?fy({},`${r}:errors`):E.useState({}),[x,j]=E.useState(!1),[y,_]=E.useState(!1),[N,b]=E.useState(),[w,k]=E.useState(!1),[R,D]=E.useState(!1),T=E.useRef(null),z=E.useRef();let F=E.useRef(Y=>Y);const B=E.useRef();E.useEffect(()=>(B.current=!0,()=>{B.current=!1}),[]);let W=E.useRef(),le=E.useRef();E.useEffect(()=>{W.current&&le.current&&W.current(...le.current)},[d]);let se=!1;try{se=OL().railsAttributes}catch{}const be=(Y,Z,oe={})=>{const G={...oe,onCancelToken:ne=>{if(T.current=ne,oe.onCancelToken)return oe.onCancelToken(ne)},onBefore:ne=>{if(k(!1),D(!1),clearTimeout(z.current),oe.onBefore)return oe.onBefore(ne)},onStart:ne=>{if(_(!0),oe.onStart)return oe.onStart(ne)},onProgress:ne=>{if(b(ne),oe.onProgress)return oe.onProgress(ne)},onSuccess:ne=>{if(B.current&&(_(!1),b(null),g({}),j(!1),k(!0),D(!0),z.current=setTimeout(()=>{B.current&&D(!1)},2e3)),oe.onSuccess)return oe.onSuccess(ne)},onError:ne=>{if(B.current&&(_(!1),b(null),g((fe=>{if(!fe||!m)return fe;const Oe={};return Object.keys(fe).forEach(dt=>{Oe[`${m}.${dt}`]=fe[dt]}),Oe})(ne)),j(!0)),oe.onError)return oe.onError(ne)},onCancel:()=>{if(B.current&&(_(!1),b(null)),oe.onCancel)return oe.onCancel()},onFinish:ne=>{if(B.current&&(_(!1),b(null)),T.current=null,oe.onFinish)return oe.onFinish(ne)}};let te=F.current(structuredClone(d));se&&(te=((ne,fe="_attributes")=>{const Oe=structuredClone(ne);return Object.values(Oe).forEach(dt=>{Wt.isPlainObject(dt)&&Mj(dt,fe)}),Oe})(te)),Y==="delete"?Xe.delete(Z,{...G,data:te}):Xe[Y](Z,te,G)},ve=Y=>{if(!Y)return void g({});const Z=Rb(Y);g(oe=>{const G=Object.keys(oe).reduce((te,ne)=>({...te,...Z.length>0&&!Z.includes(String(ne))?{[ne]:oe[ne]}:{}}),{});return j(Object.keys(G).length>0),G})};return{data:d,isDirty:!Wt.isEqual(d,l),errors:h,hasErrors:x,processing:y,progress:N,wasSuccessful:w,recentlySuccessful:R,transform:Y=>{F.current=Y},onChange:Y=>{W.current=Y},setData:(Y,Z)=>{if(typeof Y=="string")return p(oe=>{const G=structuredClone(oe);return W.current&&(le.current=[Y,Z,Wt.get(oe,Y)]),Wt.set(G,Y,Z),G});Y instanceof Function?p(oe=>{const G=Y(structuredClone(oe));return W.current&&(le.current=[void 0,G,oe]),G}):(W.current&&(le.current=[void 0,d,Y]),p(Y))},getData:Y=>Wt.get(d,Y),unsetData:Y=>{p(Z=>{const oe=structuredClone(Z);return W.current&&(le.current=[Y,Wt.get(Z,Y),void 0]),Dj(oe,Y),oe})},setDefaults:(Y,Z)=>{c(Y!==void 0?oe=>({...oe,...typeof Y=="string"?{[Y]:Z}:Y}):()=>d)},reset:Y=>{if(!Y)return W.current&&(le.current=[void 0,l,d]),p(l),void g({});const Z=Rb(Y),oe=structuredClone(d);Z.forEach(G=>{Wt.set(oe,G,Wt.get(l,G))}),ve(Y),W.current&&(le.current=[void 0,oe,d]),p(oe)},setError:(Y,Z)=>{g(oe=>{const G={...oe,...typeof Y=="string"?{[Y]:Z}:Y};return j(Object.keys(G).length>0),G})},getError:Y=>Wt.get(h,Y),clearErrors:ve,submit:be,get:(Y,Z)=>{be("get",Y,Z)},post:(Y,Z)=>{be("post",Y,Z)},put:(Y,Z)=>{be("put",Y,Z)},patch:(Y,Z)=>{be("patch",Y,Z)},delete:(Y,Z)=>{be("delete",Y,Z)},cancel:()=>{T.current&&T.current.cancel()}}}const[RL,SF]=(()=>{const e=$n.createContext(null);return[()=>{const t=$n.useContext(e);if(t===null)throw new Error("useContext must be inside a Provider with a value");return t},e.Provider]})();Lj();const IL=$n.forwardRef(({children:e,type:t="submit",disabled:n=!1,component:r="button",requiredFields:a,...l},c)=>{const{data:d,getData:p,processing:m}=RL(),h=E.useCallback(()=>!(!a||a.length===0)&&a.some(g=>{return typeof(x=p(g))=="string"?x==="":typeof x=="number"?x!==0&&!x:Wt.isEmpty(x);var x}),[d]);return $n.createElement(r,{children:e,type:t,disabled:n||m||a&&h(),ref:c,...l})});$n.memo(IL);function LL({datasource:e,constants:t}){var m,h,g,x;const{rootPath:n}=Un().props,r=!!e,{data:a,setData:l,processing:c,errors:d}=lc({datasource:{name:(e==null?void 0:e.name)??"",datasource_type:(e==null?void 0:e.datasource_type)??"s3",s3_bucket:(e==null?void 0:e.s3_bucket)??"",s3_prefix:(e==null?void 0:e.s3_prefix)??"",s3_region:(e==null?void 0:e.s3_region)??"us-east-1"}}),p=j=>{j.preventDefault(),r?Xe.patch(`${n}/datasources/${e.id}`,a):Xe.post(`${n}/datasources`,a)};return o.jsx("div",{className:"max-w-2xl mx-auto py-8",children:o.jsxs("div",{className:"bg-white rounded-lg shadow-lg p-6",children:[o.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-6",children:r?"Edit Datasource":"New Datasource"}),o.jsxs("form",{onSubmit:p,className:"space-y-6",children:[o.jsxs("div",{children:[o.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-gray-700",children:"Name"}),o.jsx("input",{type:"text",id:"name",value:a.datasource.name,onChange:j=>l("datasource.name",j.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-4 shadow-sm border-gray-300 border",required:!0}),((m=d.datasource)==null?void 0:m.name)&&o.jsx("p",{className:"mt-1 text-sm text-red-600",children:d.datasource.name})]}),!r&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Type"}),o.jsx(ct,{options:t.DATASOURCE_TYPES,value:a.datasource.datasource_type,onChange:j=>l("datasource.datasource_type",j),placeholder:"Select datasource type"})]}),o.jsxs("div",{children:[o.jsx("label",{htmlFor:"s3_bucket",className:"block text-sm font-medium text-gray-700",children:"S3 Bucket"}),o.jsx("input",{type:"text",id:"s3_bucket",value:a.datasource.s3_bucket,onChange:j=>l("datasource.s3_bucket",j.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-4 shadow-sm border-gray-300 border",required:!0}),((h=d.datasource)==null?void 0:h.s3_bucket)&&o.jsx("p",{className:"mt-1 text-sm text-red-600",children:d.datasource.s3_bucket})]}),o.jsxs("div",{children:[o.jsx("label",{htmlFor:"s3_prefix",className:"block text-sm font-medium text-gray-700",children:"S3 Prefix"}),o.jsx("input",{type:"text",id:"s3_prefix",value:a.datasource.s3_prefix,onChange:j=>l("datasource.s3_prefix",j.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-4 shadow-sm border-gray-300 border",placeholder:"data/raw/"}),((g=d.datasource)==null?void 0:g.s3_prefix)&&o.jsx("p",{className:"mt-1 text-sm text-red-600",children:d.datasource.s3_prefix})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"S3 Region"}),o.jsx(ct,{options:t.s3.S3_REGIONS,value:a.datasource.s3_region,onChange:j=>l("datasource.s3_region",j),placeholder:"Select s3 region"}),((x=d.datasource)==null?void 0:x.s3_region)&&o.jsx("p",{className:"mt-1 text-sm text-red-600",children:d.datasource.s3_region})]}),o.jsxs("div",{className:"flex justify-end gap-3",children:[o.jsx("button",{type:"button",onClick:()=>Xe.visit(`${n}/datasources`),className:"px-4 py-2 text-sm font-medium text-gray-700 hover:text-gray-900",children:"Cancel"}),o.jsx("button",{type:"submit",disabled:c,className:"px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:c?"Saving...":r?"Save Changes":"Create Datasource"})]})]})]})})}const ML=Object.freeze(Object.defineProperty({__proto__:null,default:LL},Symbol.toStringTag,{value:"Module"})),Rm=6;function DL({datasources:e}){const{rootPath:t}=Un().props;console.log(`rootPath: ${t}`);const[n,r]=E.useState(""),[a,l]=E.useState(1),[c,d]=E.useState([]),p=E.useMemo(()=>e.filter(N=>N.name.toLowerCase().includes(n.toLowerCase())||N.s3_bucket.toLowerCase().includes(n.toLowerCase())),[n,e]),m=Math.ceil(p.length/Rm),h=p.slice((a-1)*Rm,a*Rm),g=N=>{confirm("Are you sure you want to delete this datasource? This action cannot be undone.")&&Xe.delete(`${t}/datasources/${N}`)},x=N=>{d(b=>b.includes(N)?b.filter(w=>w!==N):[...b,N])},j=async N=>{try{Xe.post(`${t}/datasources/${N}/sync`,{},{preserveScroll:!0,preserveState:!0,onSuccess:b=>{console.log("SUCCESS")},onError:()=>{console.error("Failed to sync datasource")}})}catch(b){console.error("Failed to sync datasource:",b)}},y=async N=>{try{await Xe.post(`${t}/datasources/${N}/abort`,{},{preserveScroll:!0,preserveState:!0})}catch(b){console.error("Failed to abort datasource sync:",b)}},_=N=>{if(N==="Not Synced")return N;const b=new Date(N);return isNaN(b.getTime())?N:b.toLocaleString()};return E.useEffect(()=>{let N;return e.some(w=>w.is_syncing)&&(N=window.setInterval(()=>{Xe.get(window.location.href,{},{preserveScroll:!0,preserveState:!0,only:["datasources"]})},2e3)),()=>{N&&window.clearInterval(N)}},[e]),e.length===0?o.jsx("div",{className:"p-8",children:o.jsx(op,{icon:Ws,title:"Connect your first data source",description:"Connect to your data sources to start creating datasets and training models",actionLabel:"Add Datasource",onAction:()=>{Xe.visit(`${t}/datasources/new`)}})}):o.jsx("div",{className:"p-8",children:o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"flex justify-between items-center",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:"Datasources"}),o.jsx(p0,{value:n,onChange:r,placeholder:"Search datasources..."})]}),o.jsxs(Or,{href:`${t}/datasources/new`,className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:[o.jsx(oa,{className:"w-4 h-4"}),"New Datasource"]})]}),h.length===0?o.jsxs("div",{className:"text-center py-12 bg-white rounded-lg shadow",children:[o.jsx(Ws,{className:"mx-auto h-12 w-12 text-gray-400"}),o.jsx("h3",{className:"mt-2 text-sm font-medium text-gray-900",children:"No datasources found"}),o.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"No datasources match your search criteria. Try adjusting your search or add a new datasource."}),o.jsx("div",{className:"mt-6",children:o.jsxs(Or,{href:`${t}/datasources/new`,className:"inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:[o.jsx(oa,{className:"w-4 h-4 mr-2"}),"New Datasource"]})})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:h.map(N=>o.jsxs("div",{className:"bg-white rounded-lg shadow-md p-6 hover:shadow-lg transition-shadow",children:[o.jsxs("div",{className:"flex justify-between items-start mb-4",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(Ws,{className:"w-5 h-5 text-blue-600 mt-1"}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:N.name}),N.is_syncing?o.jsx(Fa,{variant:"warning",children:"syncing"}):N.sync_error?o.jsx(Fa,{variant:"important",children:"sync error"}):N.last_synced_at!=="Not Synced"?o.jsx(Fa,{variant:"success",children:"synced"}):o.jsx(Fa,{variant:"warning",children:"not synced"})]}),o.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:["s3://",N.s3_bucket,"/",N.s3_prefix]})]})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("button",{onClick:()=>j(N.id),disabled:N.is_syncing,className:`text-gray-400 hover:text-blue-600 transition-colors ${N.is_syncing?"animate-spin":""}`,title:"Sync datasource",children:o.jsx(vw,{className:"w-5 h-5"})}),N.is_syncing&&o.jsx("button",{onClick:()=>y(N.id),className:"text-gray-400 hover:text-red-600 transition-colors",title:"Abort sync",children:o.jsx(El,{className:"w-5 h-5"})}),o.jsx(Or,{href:`${t}/datasources/${N.id}/edit`,className:"text-gray-400 hover:text-blue-600 transition-colors",title:"Edit datasource",children:o.jsx(tc,{className:"w-5 h-5"})}),o.jsx("button",{onClick:()=>g(N.id),className:"text-gray-400 hover:text-red-600 transition-colors",title:"Delete datasource",children:o.jsx(yo,{className:"w-5 h-5"})})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4 mt-4",children:[o.jsxs("div",{children:[o.jsx("span",{className:"text-sm text-gray-500",children:"Region"}),o.jsx("p",{className:"text-sm font-medium text-gray-900",children:N.s3_region})]}),o.jsxs("div",{children:[o.jsx("span",{className:"text-sm text-gray-500",children:"Last Sync"}),o.jsx("p",{className:"text-sm font-medium text-gray-900",children:_(N.last_synced_at)})]})]}),N.sync_error&&N.stacktrace&&o.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-100",children:[o.jsxs("button",{onClick:()=>x(N.id),className:"flex items-center gap-2 text-sm text-red-600 hover:text-red-700",children:[o.jsx(Mn,{className:"w-4 h-4"}),o.jsx("span",{children:"View Error Details"}),c.includes(N.id)?o.jsx(ec,{className:"w-4 h-4"}):o.jsx(vo,{className:"w-4 h-4"})]}),c.includes(N.id)&&o.jsx("div",{className:"mt-2 p-3 bg-red-50 rounded-md",children:o.jsx("pre",{className:"text-xs text-red-700 whitespace-pre-wrap font-mono",children:N.stacktrace})})]})]},N.id))}),m>1&&o.jsx(f0,{currentPage:a,totalPages:m,onPageChange:l})]})]})})}const FL=Object.freeze(Object.defineProperty({__proto__:null,default:DL},Symbol.toStringTag,{value:"Module"}));function zL({isOpen:e,onClose:t,onSave:n,initialData:r,metrics:a,tunerJobConstants:l,timezone:c,retrainingJobConstants:d}){var D,T,z,F,B,W,le,se,be,ve,Y,Z,oe,G,te,ne,fe,Oe,dt,Je,K,we,Ce,Ne;const[p,m]=E.useState(!1);E.useState(null);const h=Object.entries(l).filter(([X,pe])=>Array.isArray(pe.options)).reduce((X,[pe,xe])=>({...X,[pe]:xe.options[0].value}),{}),g=h.booster,x=Object.entries(l.hyperparameters[g]||{}).filter(([X,pe])=>!Array.isArray(pe.options)).reduce((X,[pe,xe])=>({...X,[pe]:{min:xe.min,max:xe.max}}),{}),[j,y]=E.useState({retraining_job_attributes:{id:((D=r.retraining_job)==null?void 0:D.id)||null,active:((T=r.retraining_job)==null?void 0:T.active)??!1,frequency:((z=r.retraining_job)==null?void 0:z.frequency)||d.frequency[0].value,tuning_frequency:((F=r.retraining_job)==null?void 0:F.tuning_frequency)||"month",direction:((B=r.retraining_job)==null?void 0:B.direction)||"maximize",batch_mode:((W=r.retraining_job)==null?void 0:W.batch_mode)||!1,batch_size:((le=r.retraining_job)==null?void 0:le.batch_size)||100,batch_overlap:((se=r.retraining_job)==null?void 0:se.batch_overlap)||1,batch_key:((be=r.retraining_job)==null?void 0:be.batch_key)||"",at:{hour:((Y=(ve=r.retraining_job)==null?void 0:ve.at)==null?void 0:Y.hour)??2,day_of_week:((oe=(Z=r.retraining_job)==null?void 0:Z.at)==null?void 0:oe.day_of_week)??1,day_of_month:((te=(G=r.retraining_job)==null?void 0:G.at)==null?void 0:te.day_of_month)??1},metric:((ne=r.retraining_job)==null?void 0:ne.metric)||(((Oe=(fe=a[r.task])==null?void 0:fe[0])==null?void 0:Oe.value)??""),threshold:((dt=r.retraining_job)==null?void 0:dt.threshold)??(r.task==="classification"?.85:.1),tuner_config:(Je=r.retraining_job)!=null&&Je.tuner_config?{n_trials:r.retraining_job.tuner_config.n_trials||10,config:{...h,...x,...r.retraining_job.tuner_config.config}}:void 0,tuning_enabled:((K=r.retraining_job)==null?void 0:K.tuning_enabled)??!1}});if(E.useEffect(()=>{j.retraining_job_attributes.tuner_config&&Object.keys(j.retraining_job_attributes.tuner_config.config).length===0&&y(X=>({...X,retraining_job_attributes:{...X.retraining_job_attributes,tuner_config:{...X.retraining_job_attributes.tuner_config,config:{...h,...x}}}}))},[j.retraining_job_attributes.tuner_config]),!e)return null;const _=(X,pe)=>{y(xe=>({...xe,retraining_job_attributes:{...xe.retraining_job_attributes,tuner_config:{...xe.retraining_job_attributes.tuner_config,config:{...xe.retraining_job_attributes.tuner_config.config,[X]:pe}}}}))},N=()=>{const X=Object.entries(l).filter(([xe,He])=>Array.isArray(He.options)),pe=X.map(([xe])=>xe);return o.jsxs("div",{className:"space-y-4",children:[X.map(([xe,He])=>{var rn;return o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700",children:He.label}),o.jsx(ct,{options:He.options.map(Ke=>({value:Ke.value,label:Ke.label,description:Ke.description})),value:((rn=j.retraining_job_attributes.tuner_config)==null?void 0:rn.config[xe])||He.options[0].value,onChange:Ke=>_(xe,Ke)})]},xe)}),pe.map(xe=>{var Ke;const He=Object.entries(l).filter(([mn,Bn])=>Bn.depends_on===xe),rn=((Ke=j.retraining_job_attributes.tuner_config)==null?void 0:Ke.config[xe])||l[xe].options[0].value;return o.jsxs("div",{className:"space-y-4",children:[o.jsx("h4",{className:"text-sm font-medium text-gray-900",children:"Parameter Ranges"}),o.jsx("div",{className:"space-y-4 max-h-[400px] overflow-y-auto pr-2",children:He.map(([mn,Bn])=>{const xt=Bn[rn];return xt?Object.entries(xt).map(([Jt,vt])=>{var Vt,Tt,hn,Nn;return vt.min!==void 0&&vt.max!==void 0?o.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("label",{className:"text-sm font-medium text-gray-900",children:vt.label}),o.jsx("span",{className:"text-xs text-gray-500",children:vt.description})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Minimum"}),o.jsx("input",{type:"number",min:vt.min,max:vt.max,step:vt.step,value:((Tt=(Vt=j.retraining_job_attributes.tuner_config)==null?void 0:Vt.config[Jt])==null?void 0:Tt.min)??vt.min,onChange:ie=>b(Jt,"min",parseFloat(ie.target.value)),className:"block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Maximum"}),o.jsx("input",{type:"number",min:vt.min,max:vt.max,step:vt.step,value:((Nn=(hn=j.retraining_job_attributes.tuner_config)==null?void 0:hn.config[Jt])==null?void 0:Nn.max)??vt.max,onChange:ie=>b(Jt,"max",parseFloat(ie.target.value)),className:"block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"})]})]})]},Jt):null}):null})})]},xe)})]})},b=(X,pe,xe)=>{y(He=>({...He,retraining_job_attributes:{...He.retraining_job_attributes,tuner_config:{...He.retraining_job_attributes.tuner_config,config:{...He.retraining_job_attributes.tuner_config.config,[X]:{...He.retraining_job_attributes.tuner_config.config[X],[pe]:xe}}}}}))},w=(X,pe)=>{y(xe=>X==="hour"||X==="day_of_week"||X==="day_of_month"?{...xe,retraining_job_attributes:{...xe.retraining_job_attributes,at:{...xe.retraining_job_attributes.at,[X]:pe}}}:{...xe,retraining_job_attributes:{...xe.retraining_job_attributes,[X]:pe}})},k=(X,pe)=>{y(xe=>({...xe,retraining_job_attributes:{...xe.retraining_job_attributes,[X]:pe}}))},R=()=>{const{retraining_job_attributes:X}=j,pe={hour:X.at.hour};switch(X.frequency){case"day":break;case"week":pe.day_of_week=X.at.day_of_week;break;case"month":pe.day_of_month=X.at.day_of_month;break}const xe={retraining_job_attributes:{...X,at:pe}};n(xe),t()};return o.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-start justify-center pt-[5vh] z-50",children:o.jsxs("div",{className:"bg-white rounded-lg w-full max-w-6xl flex flex-col",style:{maxHeight:"90vh"},children:[o.jsxs("div",{className:"flex-none flex justify-between items-center p-4 border-b",children:[o.jsx("h2",{className:"text-lg font-semibold",children:"Training Configuration"}),o.jsx("button",{onClick:t,className:"text-gray-500 hover:text-gray-700",children:o.jsx(rc,{className:"w-5 h-5"})})]}),o.jsxs("div",{className:"flex-1 p-6 grid grid-cols-2 gap-8 overflow-y-auto",children:[o.jsx("div",{className:"space-y-8",children:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Hd,{className:"w-5 h-5 text-blue-600"}),o.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Training Schedule"})]}),o.jsxs("div",{className:"flex items-center",children:[o.jsx("input",{type:"checkbox",id:"scheduleEnabled",checked:j.retraining_job_attributes.active,onChange:X=>y(pe=>({...pe,retraining_job_attributes:{...pe.retraining_job_attributes,active:X.target.checked}})),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),o.jsx("label",{htmlFor:"scheduleEnabled",className:"ml-2 text-sm text-gray-700",children:"Enable scheduled training"})]})]}),!j.retraining_job_attributes.active&&o.jsx("div",{className:"bg-gray-50 rounded-lg p-4",children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(Mn,{className:"w-5 h-5 text-gray-400 mt-0.5"}),o.jsxs("div",{children:[o.jsx("h4",{className:"text-sm font-medium text-gray-900",children:"Manual Training Mode"}),o.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"The model will only be trained when you manually trigger training. You can do this from the model details page at any time."})]})]})}),j.retraining_job_attributes.active&&o.jsx(o.Fragment,{children:o.jsx("div",{className:"space-y-6",children:o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Frequency"}),o.jsx(ct,{options:d.frequency.map(X=>({value:X.value,label:X.label,description:X.description})),value:j.retraining_job_attributes.frequency,onChange:X=>w("frequency",X)})]}),j.retraining_job_attributes.frequency==="week"&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Day of Week"}),o.jsx(ct,{options:[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:2,label:"Tuesday"},{value:3,label:"Wednesday"},{value:4,label:"Thursday"},{value:5,label:"Friday"},{value:6,label:"Saturday"}],value:j.retraining_job_attributes.at.day_of_week,onChange:X=>w("day_of_week",X)})]}),j.retraining_job_attributes.frequency==="month"&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Day of Month"}),o.jsx(ct,{options:Array.from({length:31},(X,pe)=>({value:pe+1,label:`Day ${pe+1}`})),value:j.retraining_job_attributes.at.day_of_month,onChange:X=>w("day_of_month",X)})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-sm font-medium text-gray-700",children:["Hour (",c,")"]}),o.jsx(ct,{options:Array.from({length:24},(X,pe)=>({value:pe,label:`${pe}:00`})),value:j.retraining_job_attributes.at.hour,onChange:X=>w("hour",X)})]})]})})}),o.jsxs("div",{className:"space-y-4 pt-4 border-t",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("div",{className:"flex items-center gap-2",children:o.jsxs("label",{htmlFor:"batchTrainingEnabled",className:"text-sm font-medium text-gray-700 flex items-center gap-2",children:["Enable Batch Training",o.jsx("button",{type:"button",onClick:()=>m(!p),className:"text-gray-400 hover:text-gray-600",children:o.jsx(gw,{className:"w-4 h-4"})})]})}),o.jsx("input",{type:"checkbox",id:"batchMode",checked:j.retraining_job_attributes.batch_mode,onChange:X=>y({...j,retraining_job_attributes:{...j.retraining_job_attributes,batch_mode:X.target.checked}}),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"})]}),p&&o.jsx("div",{className:"bg-blue-50 rounded-lg p-4 text-sm text-blue-700",children:o.jsxs("ul",{className:"space-y-2",children:[o.jsx("li",{children:"• When disabled, the model will train on the entire dataset in a single pass."}),o.jsx("li",{children:"• When enabled, the model will learn from small batches of data iteratively, improving training speed"})]})}),j.retraining_job_attributes.batch_mode&&o.jsxs("div",{className:"mt-4",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"flex-1",children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Batch Size"}),o.jsx("input",{type:"number",value:j.retraining_job_attributes.batch_size,onChange:X=>y({...j,retraining_job_attributes:{...j.retraining_job_attributes,batch_size:parseInt(X.target.value)}}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"})]}),o.jsxs("div",{className:"flex-1",children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Batch Overlap"}),o.jsx("input",{type:"number",value:j.retraining_job_attributes.batch_overlap,onChange:X=>y({...j,retraining_job_attributes:{...j.retraining_job_attributes,batch_overlap:parseInt(X.target.value)}}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"})]})]}),o.jsxs("div",{className:"mt-4",children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Batch Key"}),o.jsx(ct,{value:j.retraining_job_attributes.batch_key,onChange:X=>y({...j,retraining_job_attributes:{...j.retraining_job_attributes,batch_key:X}}),options:((Ce=(we=r.dataset)==null?void 0:we.columns)==null?void 0:Ce.map(X=>({value:X.name,label:X.name})))||[],placeholder:"Select a column for batch key"})]})]})]}),o.jsxs("div",{className:"border-t border-gray-200 pt-6",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[o.jsx(Mn,{className:"w-5 h-5 text-blue-600"}),o.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Evaluator Configuration"})]}),o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Metric"}),o.jsx(ct,{options:a[r.task].map(X=>({value:X.value,label:X.label,description:X.description})),value:j.retraining_job_attributes.metric,onChange:X=>k("metric",X)})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Threshold"}),o.jsx("input",{type:"number",value:j.retraining_job_attributes.threshold,onChange:X=>k("threshold",parseFloat(X.target.value)),step:.01,className:"block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-4 shadow-sm border-gray-300 border"})]})]}),o.jsx("div",{className:"bg-blue-50 rounded-md p-4",children:o.jsxs("div",{className:"flex items-start",children:[o.jsx(Mn,{className:"w-5 h-5 text-blue-400 mt-0.5"}),o.jsxs("div",{className:"ml-3",children:[o.jsx("h3",{className:"text-sm font-medium text-blue-800",children:"Deployment Criteria"}),o.jsx("p",{className:"mt-2 text-sm text-blue-700",children:(()=>{const X=a[r.task].find(xe=>xe.value===j.retraining_job_attributes.metric),pe=(X==null?void 0:X.direction)==="minimize"?"below":"above";return`The model will be automatically deployed when the ${X==null?void 0:X.label} is ${pe} ${j.retraining_job_attributes.threshold}.`})()})]})]})})]})]})]})}),o.jsx("div",{className:"space-y-8",children:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(la,{className:"w-5 h-5 text-blue-600"}),o.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Hyperparameter Tuning"})]}),o.jsxs("div",{className:"flex items-center",children:[o.jsx("input",{type:"checkbox",id:"tuningEnabled",checked:j.retraining_job_attributes.tuning_enabled||!1,onChange:X=>y(pe=>({...pe,retraining_job_attributes:{...pe.retraining_job_attributes,tuning_enabled:X.target.checked,tuner_config:X.target.checked?{n_trials:10,config:x}:void 0}})),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),o.jsx("label",{htmlFor:"tuningEnabled",className:"ml-2 text-sm text-gray-700",children:"Enable tuning"})]})]}),j.retraining_job_attributes.tuning_enabled&&o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Frequency"}),o.jsx(ct,{options:[{value:"always",label:"Always",description:"Tune hyperparameters every time"},{value:"week",label:"Weekly",description:"Tune hyperparameters once every week"},{value:"month",label:"Monthly",description:"Tune hyperparameters once every month"}],value:j.retraining_job_attributes.tuning_frequency||"week",onChange:X=>y(pe=>({...pe,retraining_job_attributes:{...pe.retraining_job_attributes,tuning_frequency:X}}))})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Number of Trials"}),o.jsx("input",{type:"number",min:"1",max:"1000",value:((Ne=j.retraining_job_attributes.tuner_config)==null?void 0:Ne.n_trials)||10,onChange:X=>y(pe=>({...pe,retraining_job_attributes:{...pe.retraining_job_attributes,tuner_config:{...pe.retraining_job_attributes.tuner_config,n_trials:parseInt(X.target.value)}}})),className:"block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-4 shadow-sm border-gray-300 border"})]})]}),N()]})]})})]}),o.jsxs("div",{className:"flex-none flex justify-end gap-4 p-4 border-t bg-white",children:[o.jsx("button",{onClick:t,className:"px-4 py-2 text-sm font-medium text-gray-700 hover:text-gray-500",children:"Cancel"}),o.jsx("button",{onClick:R,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md",children:"Save Changes"})]})]})})}const Bi=({error:e})=>e?o.jsxs("div",{className:"mt-1 flex items-center gap-1 text-sm text-red-600",children:[o.jsx(Mn,{className:"w-4 h-4"}),e]}):null;function Fj({initialData:e,datasets:t,constants:n,isEditing:r,errors:a}){var W,le,se,be,ve,Y;const{rootPath:l}=Un().props,[c,d]=E.useState(!1),[p,m]=E.useState(!1),h=lc({model:{id:e==null?void 0:e.id,name:(e==null?void 0:e.name)||"",model_type:(e==null?void 0:e.model_type)||"xgboost",dataset_id:(e==null?void 0:e.dataset_id)||"",task:(e==null?void 0:e.task)||"classification",objective:(e==null?void 0:e.objective)||"binary:logistic",metrics:(e==null?void 0:e.metrics)||["accuracy_score"],weights_column:(e==null?void 0:e.weights_column)||"",retraining_job_attributes:e!=null&&e.retraining_job?{id:e.retraining_job.id,frequency:e.retraining_job.frequency,tuning_frequency:e.retraining_job.tuning_frequency||"month",batch_mode:e.retraining_job.batch_mode,batch_size:e.retraining_job.batch_size,batch_overlap:e.retraining_job.batch_overlap,batch_key:e.retraining_job.batch_key,at:{hour:((W=e.retraining_job.at)==null?void 0:W.hour)??2,day_of_week:((le=e.retraining_job.at)==null?void 0:le.day_of_week)??1,day_of_month:((se=e.retraining_job.at)==null?void 0:se.day_of_month)??1},active:e.retraining_job.active,metric:e.retraining_job.metric,threshold:e.retraining_job.threshold,tuner_config:e.retraining_job.tuner_config,tuning_enabled:e.retraining_job.tuning_enabled||!1}:void 0}}),{data:g,setData:x,post:j,patch:y,processing:_,errors:N}=h,b={...a,...N},w=((be=n.objectives[g.model.model_type])==null?void 0:be[g.model.task])||[];E.useEffect(()=>{p&&(R(),m(!1))},[p]);const k=Z=>{x({...g,model:{...g.model,retraining_job_attributes:Z.retraining_job_attributes}}),m(!0)},R=()=>{if(g.model.retraining_job_attributes){const Z={hour:g.model.retraining_job_attributes.at.hour};switch(g.model.retraining_job_attributes.frequency){case"day":break;case"week":Z.day_of_week=g.model.retraining_job_attributes.at.day_of_week;break;case"month":Z.day_of_month=g.model.retraining_job_attributes.at.day_of_month;break}x("model.retraining_job_attributes.at",Z)}g.model.id?y(`${l}/models/${g.model.id}`,{onSuccess:()=>{Xe.visit(`${l}/models`)}}):j(`${l}/models`,{onSuccess:()=>{Xe.visit(`${l}/models`)}})},D=Z=>{Z.preventDefault(),R()},T=t.find(Z=>Z.id===g.model.dataset_id),z=(T==null?void 0:T.columns)||[],F=n.tuner_job_constants[g.model.model_type]||{},B=Z=>{x("model.task",Z),x("model.metrics",[]),x("model.objective",Z==="classification"?"binary:logistic":"reg:squarederror")};return o.jsxs("form",{onSubmit:D,className:"space-y-8",children:[o.jsxs("div",{className:"flex justify-between items-center border-b pb-4",children:[o.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Model Configuration"}),o.jsxs("button",{type:"button",onClick:()=>d(!0),className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:[o.jsx(EO,{className:"w-4 h-4"}),"Configure Training"]})]}),o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[o.jsxs("div",{children:[o.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-gray-700 mb-1",children:"Model Name"}),o.jsx("input",{type:"text",id:"name",value:g.model.name,onChange:Z=>x("model.name",Z.target.value),className:"block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 py-2 px-4 shadow-sm border-gray-300 border"}),o.jsx(Bi,{error:b.name})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Model Type"}),o.jsx(ct,{options:[{value:"xgboost",label:"XGBoost",description:"Gradient boosting framework"}],value:g.model.model_type,onChange:Z=>x("model.model_type",Z),placeholder:"Select model type"}),o.jsx(Bi,{error:b.model_type})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Dataset"}),r?o.jsxs("div",{className:"flex items-center gap-2 p-2 bg-gray-50 rounded-md border border-gray-200",children:[o.jsx(jO,{className:"w-4 h-4 text-gray-400"}),o.jsx("span",{className:"text-gray-700",children:T==null?void 0:T.name})]}):o.jsx(ct,{options:t.map(Z=>({value:Z.id,label:Z.name,description:`${Z.num_rows.toLocaleString()} rows`})),value:g.model.dataset_id,onChange:Z=>x("model.dataset_id",Z),placeholder:"Select dataset"}),o.jsx(Bi,{error:b.dataset_id})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Weights Column (Optional)"}),o.jsx(ct,{value:g.model.weights_column,options:z.map(Z=>({value:Z.name,label:Z.name})),onChange:Z=>x("model.weights_column",Z),isClearable:!0}),o.jsx(Bi,{error:b.weights_column})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Task"}),o.jsx(ct,{options:n.tasks,value:g.model.task,onChange:B}),o.jsx(Bi,{error:b.task})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Objective"}),o.jsx(ct,{options:w||[],value:g.model.objective,onChange:Z=>x("model.objective",Z),placeholder:"Select objective"}),o.jsx(Bi,{error:b.objective})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Metrics"}),o.jsx("div",{className:"grid grid-cols-2 gap-4",children:(ve=n.metrics[g.model.task])==null?void 0:ve.map(Z=>o.jsxs("label",{className:"relative flex items-center px-4 py-3 bg-white border rounded-lg hover:bg-gray-50 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:g.model.metrics.includes(Z.value),onChange:oe=>{const G=oe.target.checked?[...g.model.metrics,Z.value]:g.model.metrics.filter(te=>te!==Z.value);x("model.metrics",G)},className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),o.jsxs("div",{className:"ml-3",children:[o.jsx("span",{className:"block text-sm font-medium text-gray-900",children:Z.label}),o.jsxs("span",{className:"block text-xs text-gray-500",children:["Direction: ",Z.direction]})]})]},Z.value))}),o.jsx(Bi,{error:b.metrics})]})]}),g.model.retraining_job_attributes&&g.model.retraining_job_attributes.batch_mode&&o.jsx(o.Fragment,{children:o.jsxs("div",{className:"mt-4",children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Batch Key"}),o.jsx(ct,{value:g.model.retraining_job_attributes.batch_key||"",onChange:Z=>x("model",{...g.model,retraining_job_attributes:{...g.model.retraining_job_attributes,batch_key:Z}}),options:((Y=T==null?void 0:T.columns)==null?void 0:Y.map(Z=>({value:Z.name,label:Z.name})))||[],placeholder:"Select a column for batch key"}),o.jsx(Bi,{error:b["model.retraining_job_attributes.batch_key"]})]})}),o.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[o.jsx("button",{type:"button",onClick:()=>Xe.visit(`${l}/models`),className:"px-4 py-2 text-sm font-medium text-gray-700 hover:text-gray-900",children:"Cancel"}),o.jsx("button",{type:"submit",className:"px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:r?"Save Changes":"Create Model"})]}),o.jsx(zL,{isOpen:c,onClose:()=>d(!1),onSave:k,initialData:{task:g.model.task,metrics:g.model.metrics,modelType:g.model.model_type,dataset:T,retraining_job:g.model.retraining_job_attributes},metrics:n.metrics,tunerJobConstants:F,timezone:n.timezone,retrainingJobConstants:n.retraining_job_constants})]})}function $L({model:e,datasets:t,constants:n}){return o.jsx("div",{className:"max-w-3xl mx-auto py-8",children:o.jsxs("div",{className:"bg-white rounded-lg shadow-lg",children:[o.jsx("div",{className:"px-6 py-4 border-b border-gray-200",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(Yi,{className:"w-6 h-6 text-blue-600"}),o.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:"Edit Model"})]})}),o.jsx("div",{className:"p-6",children:o.jsx(Fj,{initialData:e,datasets:t,constants:n,isEditing:!0})})]})})}const UL=Object.freeze(Object.defineProperty({__proto__:null,default:$L},Symbol.toStringTag,{value:"Module"})),lt=e=>{const t=new Date;return t.setDate(t.getDate()-e),t.toISOString()},zj=[{id:1,name:"Customer Churn Dataset",description:"Historical customer data for churn prediction",columns:[{name:"usage_days",type:"numeric",description:"Number of days customer has used the product",statistics:{mean:145.7,median:130,min:1,max:365,nullCount:0}},{name:"total_spend",type:"numeric",description:"Total customer spend in USD",statistics:{mean:487.32,median:425.5,min:0,max:2500,nullCount:1250}},{name:"support_tickets",type:"numeric",description:"Number of support tickets opened",statistics:{mean:2.3,median:1,min:0,max:15,nullCount:3750}},{name:"subscription_tier",type:"categorical",description:"Customer subscription level",statistics:{uniqueCount:3,nullCount:125}},{name:"last_login",type:"datetime",description:"Last time the customer logged in",statistics:{nullCount:5e3}}],sampleData:[{usage_days:234,total_spend:567.89,support_tickets:1,subscription_tier:"premium",last_login:"2024-03-01"},{usage_days:45,total_spend:null,support_tickets:null,subscription_tier:"basic",last_login:null}],rowCount:25e3,updatedAt:"2024-03-10T12:00:00Z"}];lt(30),lt(0);lt(7),lt(1),lt(30),lt(0);lt(1),lt(1),lt(1),lt(1),lt(2),lt(2),lt(2),lt(2),lt(3),lt(3),lt(3),lt(3),lt(4),lt(4),lt(4),lt(4);const BL=[{id:1,name:"Normalize state",description:"Turn state names into 2 letter state abbreviations",groupId:1,testDatasetId:1,inputColumns:["state"],outputColumns:["state"],code:"",createdAt:lt(30),updatedAt:lt(0)}],Ba=[{id:1,name:"Customer Churn",description:"Features for customer churn dataset",features:BL,createdAt:lt(30),updatedAt:lt(0)}];function WL({value:e,onChange:t,language:n}){return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"bg-gray-900 rounded-lg overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-gray-800",children:[o.jsx("span",{className:"text-sm text-gray-400",children:"Ruby Feature"}),o.jsx("span",{className:"text-xs px-2 py-1 bg-gray-700 rounded text-gray-300",children:n})]}),o.jsx("textarea",{value:e,onChange:r=>t(r.target.value),className:"w-full h-64 p-4 bg-gray-900 text-gray-100 font-mono text-sm focus:outline-none",placeholder:`def transform(df)
|
490
490
|
# Your feature code here
|
491
491
|
# Example:
|
492
492
|
# df["column"] = df["column"].map { |value| value.upcase }
|
@@ -519,4 +519,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
519
519
|
flex-grow: 1;
|
520
520
|
}
|
521
521
|
`},nonce:l}),o.jsx(ki.div,{"data-radix-scroll-area-viewport":"",...c,asChild:a,ref:m,style:{overflowX:d.scrollbarXEnabled?"scroll":"hidden",overflowY:d.scrollbarYEnabled?"scroll":"hidden",...e.style},children:ZD({asChild:a,children:r},h=>o.jsx("div",{"data-radix-scroll-area-content":"",ref:d.onContentChange,style:{minWidth:d.scrollbarXEnabled?"fit-content":void 0},children:h}))})]})});d2.displayName=u2;var Zr="ScrollAreaScrollbar",g0=E.forwardRef((e,t)=>{const{forceMount:n,...r}=e,a=br(Zr,e.__scopeScrollArea),{onScrollbarXEnabledChange:l,onScrollbarYEnabledChange:c}=a,d=e.orientation==="horizontal";return E.useEffect(()=>(d?l(!0):c(!0),()=>{d?l(!1):c(!1)}),[d,l,c]),a.type==="hover"?o.jsx(HD,{...r,ref:t,forceMount:n}):a.type==="scroll"?o.jsx(qD,{...r,ref:t,forceMount:n}):a.type==="auto"?o.jsx(p2,{...r,ref:t,forceMount:n}):a.type==="always"?o.jsx(x0,{...r,ref:t}):null});g0.displayName=Zr;var HD=E.forwardRef((e,t)=>{const{forceMount:n,...r}=e,a=br(Zr,e.__scopeScrollArea),[l,c]=E.useState(!1);return E.useEffect(()=>{const d=a.scrollArea;let p=0;if(d){const m=()=>{window.clearTimeout(p),c(!0)},h=()=>{p=window.setTimeout(()=>c(!1),a.scrollHideDelay)};return d.addEventListener("pointerenter",m),d.addEventListener("pointerleave",h),()=>{window.clearTimeout(p),d.removeEventListener("pointerenter",m),d.removeEventListener("pointerleave",h)}}},[a.scrollArea,a.scrollHideDelay]),o.jsx(jo,{present:n||l,children:o.jsx(p2,{"data-state":l?"visible":"hidden",...r,ref:t})})}),qD=E.forwardRef((e,t)=>{const{forceMount:n,...r}=e,a=br(Zr,e.__scopeScrollArea),l=e.orientation==="horizontal",c=cp(()=>p("SCROLL_END"),100),[d,p]=BD("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return E.useEffect(()=>{if(d==="idle"){const m=window.setTimeout(()=>p("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(m)}},[d,a.scrollHideDelay,p]),E.useEffect(()=>{const m=a.viewport,h=l?"scrollLeft":"scrollTop";if(m){let g=m[h];const x=()=>{const j=m[h];g!==j&&(p("SCROLL"),c()),g=j};return m.addEventListener("scroll",x),()=>m.removeEventListener("scroll",x)}},[a.viewport,l,p,c]),o.jsx(jo,{present:n||d!=="hidden",children:o.jsx(x0,{"data-state":d==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:sa(e.onPointerEnter,()=>p("POINTER_ENTER")),onPointerLeave:sa(e.onPointerLeave,()=>p("POINTER_LEAVE"))})})}),p2=E.forwardRef((e,t)=>{const n=br(Zr,e.__scopeScrollArea),{forceMount:r,...a}=e,[l,c]=E.useState(!1),d=e.orientation==="horizontal",p=cp(()=>{if(n.viewport){const m=n.viewport.offsetWidth<n.viewport.scrollWidth,h=n.viewport.offsetHeight<n.viewport.scrollHeight;c(d?m:h)}},10);return po(n.viewport,p),po(n.content,p),o.jsx(jo,{present:r||l,children:o.jsx(x0,{"data-state":l?"visible":"hidden",...a,ref:t})})}),x0=E.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,a=br(Zr,e.__scopeScrollArea),l=E.useRef(null),c=E.useRef(0),[d,p]=E.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),m=x2(d.viewport,d.content),h={...r,sizes:d,onSizesChange:p,hasThumb:m>0&&m<1,onThumbChange:x=>l.current=x,onThumbPointerUp:()=>c.current=0,onThumbPointerDown:x=>c.current=x};function g(x,j){return YD(x,c.current,d,j)}return n==="horizontal"?o.jsx(VD,{...h,ref:t,onThumbPositionChange:()=>{if(a.viewport&&l.current){const x=a.viewport.scrollLeft,j=Gb(x,d,a.dir);l.current.style.transform=`translate3d(${j}px, 0, 0)`}},onWheelScroll:x=>{a.viewport&&(a.viewport.scrollLeft=x)},onDragScroll:x=>{a.viewport&&(a.viewport.scrollLeft=g(x,a.dir))}}):n==="vertical"?o.jsx(GD,{...h,ref:t,onThumbPositionChange:()=>{if(a.viewport&&l.current){const x=a.viewport.scrollTop,j=Gb(x,d);l.current.style.transform=`translate3d(0, ${j}px, 0)`}},onWheelScroll:x=>{a.viewport&&(a.viewport.scrollTop=x)},onDragScroll:x=>{a.viewport&&(a.viewport.scrollTop=g(x))}}):null}),VD=E.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...a}=e,l=br(Zr,e.__scopeScrollArea),[c,d]=E.useState(),p=E.useRef(null),m=ha(t,p,l.onScrollbarXChange);return E.useEffect(()=>{p.current&&d(getComputedStyle(p.current))},[p]),o.jsx(m2,{"data-orientation":"horizontal",...a,ref:m,sizes:n,style:{bottom:0,left:l.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:l.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":lp(n)+"px",...e.style},onThumbPointerDown:h=>e.onThumbPointerDown(h.x),onDragScroll:h=>e.onDragScroll(h.x),onWheelScroll:(h,g)=>{if(l.viewport){const x=l.viewport.scrollLeft+h.deltaX;e.onWheelScroll(x),y2(x,g)&&h.preventDefault()}},onResize:()=>{p.current&&l.viewport&&c&&r({content:l.viewport.scrollWidth,viewport:l.viewport.offsetWidth,scrollbar:{size:p.current.clientWidth,paddingStart:Dd(c.paddingLeft),paddingEnd:Dd(c.paddingRight)}})}})}),GD=E.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...a}=e,l=br(Zr,e.__scopeScrollArea),[c,d]=E.useState(),p=E.useRef(null),m=ha(t,p,l.onScrollbarYChange);return E.useEffect(()=>{p.current&&d(getComputedStyle(p.current))},[p]),o.jsx(m2,{"data-orientation":"vertical",...a,ref:m,sizes:n,style:{top:0,right:l.dir==="ltr"?0:void 0,left:l.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":lp(n)+"px",...e.style},onThumbPointerDown:h=>e.onThumbPointerDown(h.y),onDragScroll:h=>e.onDragScroll(h.y),onWheelScroll:(h,g)=>{if(l.viewport){const x=l.viewport.scrollTop+h.deltaY;e.onWheelScroll(x),y2(x,g)&&h.preventDefault()}},onResize:()=>{p.current&&l.viewport&&c&&r({content:l.viewport.scrollHeight,viewport:l.viewport.offsetHeight,scrollbar:{size:p.current.clientHeight,paddingStart:Dd(c.paddingTop),paddingEnd:Dd(c.paddingBottom)}})}})}),[KD,f2]=l2(Zr),m2=E.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:a,onThumbChange:l,onThumbPointerUp:c,onThumbPointerDown:d,onThumbPositionChange:p,onDragScroll:m,onWheelScroll:h,onResize:g,...x}=e,j=br(Zr,n),[y,_]=E.useState(null),N=ha(t,B=>_(B)),b=E.useRef(null),w=E.useRef(""),k=j.viewport,R=r.content-r.viewport,D=gi(h),T=gi(p),z=cp(g,10);function F(B){if(b.current){const W=B.clientX-b.current.left,le=B.clientY-b.current.top;m({x:W,y:le})}}return E.useEffect(()=>{const B=W=>{const le=W.target;(y==null?void 0:y.contains(le))&&D(W,R)};return document.addEventListener("wheel",B,{passive:!1}),()=>document.removeEventListener("wheel",B,{passive:!1})},[k,y,R,D]),E.useEffect(T,[r,T]),po(y,z),po(j.content,z),o.jsx(KD,{scope:n,scrollbar:y,hasThumb:a,onThumbChange:gi(l),onThumbPointerUp:gi(c),onThumbPositionChange:T,onThumbPointerDown:gi(d),children:o.jsx(ki.div,{...x,ref:N,style:{position:"absolute",...x.style},onPointerDown:sa(e.onPointerDown,B=>{B.button===0&&(B.target.setPointerCapture(B.pointerId),b.current=y.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",j.viewport&&(j.viewport.style.scrollBehavior="auto"),F(B))}),onPointerMove:sa(e.onPointerMove,F),onPointerUp:sa(e.onPointerUp,B=>{const W=B.target;W.hasPointerCapture(B.pointerId)&&W.releasePointerCapture(B.pointerId),document.body.style.webkitUserSelect=w.current,j.viewport&&(j.viewport.style.scrollBehavior=""),b.current=null})})})}),Md="ScrollAreaThumb",h2=E.forwardRef((e,t)=>{const{forceMount:n,...r}=e,a=f2(Md,e.__scopeScrollArea);return o.jsx(jo,{present:n||a.hasThumb,children:o.jsx(QD,{ref:t,...r})})}),QD=E.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...a}=e,l=br(Md,n),c=f2(Md,n),{onThumbPositionChange:d}=c,p=ha(t,g=>c.onThumbChange(g)),m=E.useRef(),h=cp(()=>{m.current&&(m.current(),m.current=void 0)},100);return E.useEffect(()=>{const g=l.viewport;if(g){const x=()=>{if(h(),!m.current){const j=JD(g,d);m.current=j,d()}};return d(),g.addEventListener("scroll",x),()=>g.removeEventListener("scroll",x)}},[l.viewport,h,d]),o.jsx(ki.div,{"data-state":c.hasThumb?"visible":"hidden",...a,ref:p,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:sa(e.onPointerDownCapture,g=>{const j=g.target.getBoundingClientRect(),y=g.clientX-j.left,_=g.clientY-j.top;c.onThumbPointerDown({x:y,y:_})}),onPointerUp:sa(e.onPointerUp,c.onThumbPointerUp)})});h2.displayName=Md;var v0="ScrollAreaCorner",g2=E.forwardRef((e,t)=>{const n=br(v0,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?o.jsx(XD,{...e,ref:t}):null});g2.displayName=v0;var XD=E.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,a=br(v0,n),[l,c]=E.useState(0),[d,p]=E.useState(0),m=!!(l&&d);return po(a.scrollbarX,()=>{var g;const h=((g=a.scrollbarX)==null?void 0:g.offsetHeight)||0;a.onCornerHeightChange(h),p(h)}),po(a.scrollbarY,()=>{var g;const h=((g=a.scrollbarY)==null?void 0:g.offsetWidth)||0;a.onCornerWidthChange(h),c(h)}),m?o.jsx(ki.div,{...r,ref:t,style:{width:l,height:d,position:"absolute",right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Dd(e){return e?parseInt(e,10):0}function x2(e,t){const n=e/t;return isNaN(n)?0:n}function lp(e){const t=x2(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function YD(e,t,n,r="ltr"){const a=lp(n),l=a/2,c=t||l,d=a-c,p=n.scrollbar.paddingStart+c,m=n.scrollbar.size-n.scrollbar.paddingEnd-d,h=n.content-n.viewport,g=r==="ltr"?[0,h]:[h*-1,0];return v2([p,m],g)(e)}function Gb(e,t,n="ltr"){const r=lp(t),a=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,l=t.scrollbar.size-a,c=t.content-t.viewport,d=l-r,p=n==="ltr"?[0,c]:[c*-1,0],m=UD(e,p);return v2([0,c],[0,d])(m)}function v2(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function y2(e,t){return e>0&&e<t}var JD=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function a(){const l={left:e.scrollLeft,top:e.scrollTop},c=n.left!==l.left,d=n.top!==l.top;(c||d)&&t(),n=l,r=window.requestAnimationFrame(a)}(),()=>window.cancelAnimationFrame(r)};function cp(e,t){const n=gi(e),r=E.useRef(0);return E.useEffect(()=>()=>window.clearTimeout(r.current),[]),E.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function po(e,t){const n=gi(t);Gl(()=>{let r=0;if(e){const a=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return a.observe(e),()=>{window.cancelAnimationFrame(r),a.unobserve(e)}}},[e,n])}function ZD(e,t){const{asChild:n,children:r}=e;if(!n)return typeof t=="function"?t(r):t;const a=E.Children.only(r);return E.cloneElement(a,{children:typeof t=="function"?t(a.props.children):t})}var b2=c2,eF=d2,tF=g2;const w2=E.forwardRef(({className:e,children:t,...n},r)=>o.jsxs(b2,{ref:r,className:Tr("relative overflow-hidden",e),...n,children:[o.jsx(eF,{className:"h-full w-full rounded-[inherit]",children:t}),o.jsx(_2,{}),o.jsx(tF,{})]}));w2.displayName=b2.displayName;const _2=E.forwardRef(({className:e,orientation:t="vertical",...n},r)=>o.jsx(g0,{ref:r,orientation:t,className:Tr("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:o.jsx(h2,{className:"relative flex-1 rounded-full bg-border"})}));_2.displayName=g0.displayName;var nF="Separator",Kb="horizontal",rF=["horizontal","vertical"],j2=E.forwardRef((e,t)=>{const{decorative:n,orientation:r=Kb,...a}=e,l=iF(r)?r:Kb,d=n?{role:"none"}:{"aria-orientation":l==="vertical"?l:void 0,role:"separator"};return o.jsx(ki.div,{"data-orientation":l,...d,...a,ref:t})});j2.displayName=nF;function iF(e){return rF.includes(e)}var S2=j2;const N2=E.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},a)=>o.jsx(S2,{ref:a,decorative:n,orientation:t,className:Tr("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));N2.displayName=S2.displayName;function aF({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,a]=sF({defaultProp:t,onChange:n}),l=e!==void 0,c=l?e:r,d=gi(n),p=E.useCallback(m=>{if(l){const g=typeof m=="function"?m(e):m;g!==e&&d(g)}else a(m)},[l,e,a,d]);return[c,p]}function sF({defaultProp:e,onChange:t}){const n=E.useState(e),[r]=n,a=E.useRef(r),l=gi(t);return E.useEffect(()=>{a.current!==r&&(l(r),a.current=r)},[r,a,l]),n}var oF=S3.useId||(()=>{}),lF=0;function cF(e){const[t,n]=E.useState(oF());return Gl(()=>{e||n(r=>r??String(lF++))},[e]),e||(t?`radix-${t}`:"")}var y0="Collapsible",[uF,kF]=o2(y0),[dF,b0]=uF(y0),k2=E.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:a,disabled:l,onOpenChange:c,...d}=e,[p=!1,m]=aF({prop:r,defaultProp:a,onChange:c});return o.jsx(dF,{scope:n,disabled:l,contentId:cF(),open:p,onOpenToggle:E.useCallback(()=>m(h=>!h),[m]),children:o.jsx(ki.div,{"data-state":_0(p),"data-disabled":l?"":void 0,...d,ref:t})})});k2.displayName=y0;var C2="CollapsibleTrigger",E2=E.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,a=b0(C2,n);return o.jsx(ki.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":_0(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...r,ref:t,onClick:sa(e.onClick,a.onOpenToggle)})});E2.displayName=C2;var w0="CollapsibleContent",A2=E.forwardRef((e,t)=>{const{forceMount:n,...r}=e,a=b0(w0,e.__scopeCollapsible);return o.jsx(jo,{present:n||a.open,children:({present:l})=>o.jsx(pF,{...r,ref:t,present:l})})});A2.displayName=w0;var pF=E.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:a,...l}=e,c=b0(w0,n),[d,p]=E.useState(r),m=E.useRef(null),h=ha(t,m),g=E.useRef(0),x=g.current,j=E.useRef(0),y=j.current,_=c.open||d,N=E.useRef(_),b=E.useRef();return E.useEffect(()=>{const w=requestAnimationFrame(()=>N.current=!1);return()=>cancelAnimationFrame(w)},[]),Gl(()=>{const w=m.current;if(w){b.current=b.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const k=w.getBoundingClientRect();g.current=k.height,j.current=k.width,N.current||(w.style.transitionDuration=b.current.transitionDuration,w.style.animationName=b.current.animationName),p(r)}},[c.open,r]),o.jsx(ki.div,{"data-state":_0(c.open),"data-disabled":c.disabled?"":void 0,id:c.contentId,hidden:!_,...l,ref:h,style:{"--radix-collapsible-content-height":x?`${x}px`:void 0,"--radix-collapsible-content-width":y?`${y}px`:void 0,...e.style},children:_&&a})});function _0(e){return e?"open":"closed"}var fF=k2;const mF=fF,hF=E2,gF=A2;function Qb({href:e,className:t=l=>"",activeClassName:n="active",children:r,...a}){const{rootPath:l,url:c}=Un().props,d=c===e;let p=t(d);return o.jsx(Or,{href:`${l}${e}`,className:Tr(p,d&&n),...a,children:r})}const xF=[{title:"Models",icon:Yi,href:"/",children:[{title:"All Models",icon:Yi,href:"/models"},{title:"New Model",icon:Yi,href:"/models/new"}]},{title:"Datasources",icon:Ws,href:"/datasources",children:[{title:"All Datasources",icon:Ws,href:"/datasources"},{title:"New Datasource",icon:Ws,href:"/datasources/new"}]},{title:"Datasets",icon:dn,href:"/datasets",children:[{title:"All Datasets",icon:dn,href:"/datasets"},{title:"New Dataset",icon:dn,href:"/datasets/new"}]}];function vF(e){const{rootPath:t}=Un().props,n=e.split("/").filter(Boolean),r=[];let a=t;if(n.length===0)return[];let l,c;switch(["datasources","datasets","models","settings"].includes(n[0])?(l=n[0],c=0):(l=n[1],c=1),l){case"models":r.push({title:"Models",href:`${t}/models`});break;case"datasources":r.push({title:"Datasources",href:`${t}/datasources`});break;case"datasets":r.push({title:"Datasets",href:`${t}/datasets`});break;case"settings":r.push({title:"Settings",href:`${t}/settings`});break;default:r.push({title:"Models",href:`${t}/models`})}for(let d=c+1;d<n.length;d++){const p=n[d];if(a+=`/${n[d]}`,n[d-1]==="datasets"&&p!=="new")r.push({title:"Details",href:a});else if(n[d-1]==="models"&&p!=="new")r.push({title:"Details",href:a});else{const m=p==="new"?"New":p==="edit"?"Edit":p.charAt(0).toUpperCase()+p.slice(1);r.push({title:m,href:a})}}return r}function yF({children:e}){const[t,n]=E.useState(!0),[r,a]=E.useState(["Models"]),l=vF(location.pathname),c=d=>{a(p=>p.includes(d)?p.filter(m=>m!==d):[...p,d])};return o.jsxs("div",{className:"min-h-screen bg-gray-50",children:[o.jsxs("div",{className:Tr("fixed left-0 top-0 z-40 h-screen bg-white border-r transition-all duration-300",t?"w-64":"w-16"),children:[o.jsxs("div",{className:"flex h-16 items-center border-b px-4",children:[t?o.jsxs(o.Fragment,{children:[o.jsx(Yi,{className:"w-8 h-8 text-blue-600"}),o.jsx("h1",{className:"text-xl font-bold text-gray-900 ml-2",children:"EasyML"})]}):o.jsx(Yi,{className:"w-8 h-8 text-blue-600"}),o.jsx("button",{onClick:()=>n(!t),className:"ml-auto p-2 hover:bg-gray-100 rounded-md",children:o.jsx(SO,{className:"w-4 h-4"})})]}),o.jsx(w2,{className:"h-[calc(100vh-4rem)] px-3",children:o.jsxs("div",{className:"space-y-2 py-4",children:[xF.map(d=>{var p;return o.jsxs(mF,{open:r.includes(d.title),onOpenChange:()=>c(d.title),children:[o.jsxs(hF,{className:"flex items-center w-full p-2 hover:bg-gray-100 rounded-md",children:[o.jsx(d.icon,{className:"w-4 h-4"}),t&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"ml-2 text-sm font-medium flex-1 text-left",children:d.title}),r.includes(d.title)?o.jsx(vo,{className:"w-4 h-4"}):o.jsx(no,{className:"w-4 h-4"})]})]}),o.jsx(gF,{children:t&&((p=d.children)==null?void 0:p.map(m=>o.jsxs(Qb,{href:m.href,className:({isActive:h})=>Tr("flex items-center pl-8 pr-2 py-2 text-sm rounded-md",h?"bg-blue-50 text-blue-600":"text-gray-600 hover:bg-gray-50"),children:[o.jsx(m.icon,{className:"w-4 h-4"}),o.jsx("span",{className:"ml-2",children:m.title})]},m.href)))})]},d.title)}),o.jsx(N2,{className:"my-4"}),o.jsxs(Qb,{href:"/settings",className:({isActive:d})=>Tr("flex items-center w-full p-2 rounded-md",d?"bg-blue-50 text-blue-600":"text-gray-600 hover:bg-gray-50"),children:[o.jsx(la,{className:"w-4 h-4"}),t&&o.jsx("span",{className:"ml-2 text-sm font-medium",children:"Settings"})]})]})})]}),o.jsxs("div",{className:Tr("transition-all duration-300",t?"ml-64":"ml-16"),children:[o.jsx(ED,{}),o.jsx("div",{className:"h-16 border-b bg-white flex items-center px-4",children:o.jsx("nav",{className:"flex","aria-label":"Breadcrumb",children:o.jsx("ol",{className:"flex items-center space-x-2",children:l.map((d,p)=>o.jsxs($n.Fragment,{children:[p>0&&o.jsx(no,{className:"w-4 h-4 text-gray-400"}),o.jsx("li",{children:o.jsx(Or,{href:d.href,className:Tr("text-sm",p===l.length-1?"text-blue-600 font-medium":"text-gray-500 hover:text-gray-700"),children:d.title})})]},d.href))})})}),o.jsx("main",{className:"min-h-[calc(100vh-4rem)]",children:e})]})]})}function bF({children:e}){const{showAlert:t}=i2(),{flash:n}=Un().props;return E.useEffect(()=>{n&&n.forEach(({type:r,message:a})=>{t(r,a)})},[n,t]),o.jsx(o.Fragment,{children:e})}function wF({children:e}){return o.jsx(CD,{children:o.jsx(bF,{children:o.jsx(yF,{children:e})})})}document.addEventListener("DOMContentLoaded",()=>{rO({resolve:e=>{let n=Object.assign({"../pages/DatasetDetailsPage.tsx":CL,"../pages/DatasetsPage.tsx":TL,"../pages/DatasourceFormPage.tsx":ML,"../pages/DatasourcesPage.tsx":FL,"../pages/EditModelPage.tsx":UL,"../pages/EditTransformationPage.tsx":VL,"../pages/ModelsPage.tsx":KM,"../pages/NewDatasetPage.tsx":dD,"../pages/NewModelPage.tsx":fD,"../pages/NewTransformationPage.tsx":hD,"../pages/SettingsPage.tsx":vD,"../pages/ShowModelPage.tsx":_D,"../pages/TransformationsPage.tsx":kD})[`../${e}.tsx`];if(!n.default){alert(`The page ${e} could not be found, you probably forgot to export default.`);return}return n.default.layout=n.default.layout||(r=>o.jsx(wF,{children:r})),n},setup({el:e,App:t,props:n}){n2(e).render(o.jsx(t,{...n}))}})});
|
522
|
-
//# sourceMappingURL=Application.tsx-
|
522
|
+
//# sourceMappingURL=Application.tsx-CD8voxfL.js.map
|