File size: 3,048 Bytes
c43d926
 
1
2
3
import{r as t,j as e}from"./react-DKy9e2uO.js";import{H as C,I as N,L as S,S as k}from"./index-MnghlAu6.js";import"./bottleneck-Cpj98o6Y.js";import"./react-dom-CpxHE_eW.js";import"./scheduler-DYLXRpC5.js";import"./@google-CZdO-yDN.js";import"./idb-Dob3nYDb.js";import"./marked-CesSW9Du.js";import"./jszip-s56H2EZ-.js";const c=({label:o,value:n,onChange:i,options:l})=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-text-secondary",children:o}),e.jsxs("select",{value:n,onChange:a=>i(a.target.value),className:"w-full mt-1 px-3 py-2 rounded-md bg-surface border border-border",children:[e.jsx("option",{value:"*",children:"* (every)"}),l.map(a=>e.jsx("option",{value:a,children:a},a))]})]}),$=({initialPrompt:o})=>{const[n,i]=t.useState("0"),[l,a]=t.useState("17"),[d,p]=t.useState("*"),[m,h]=t.useState("*"),[x,g]=t.useState("1-5"),[b,f]=t.useState(o||"every weekday at 5pm"),[y,j]=t.useState(!1),v=t.useMemo(()=>`${n} ${l} ${d} ${m} ${x}`,[n,l,d,m,x]),u=t.useCallback(async r=>{if(r){j(!0);try{const s=await C(r);i(s.minute),a(s.hour),p(s.dayOfMonth),h(s.month),g(s.dayOfWeek)}catch(s){console.error(s)}finally{j(!1)}}},[]);return t.useEffect(()=>{o&&(f(o),u(o))},[o,u]),e.jsxs("div",{className:"h-full flex flex-col p-4 sm:p-6 lg:p-8 text-text-primary",children:[e.jsxs("header",{className:"mb-6",children:[e.jsxs("h1",{className:"text-3xl font-bold flex items-center",children:[e.jsx(N,{}),e.jsx("span",{className:"ml-3",children:"AI Cron Job Builder"})]}),e.jsx("p",{className:"text-text-secondary mt-1",children:"Visually construct a cron expression or describe it in plain English."})]}),e.jsxs("div",{className:"flex gap-2 mb-6",children:[e.jsx("input",{type:"text",value:b,onChange:r=>f(r.target.value),placeholder:"Describe a schedule...",className:"flex-grow px-3 py-1.5 rounded-md bg-surface border border-border text-sm"}),e.jsxs("button",{onClick:()=>u(b),disabled:y,className:"btn-primary px-4 py-1.5 flex items-center gap-2",children:[y?e.jsx(S,{}):e.jsx(k,{})," AI Generate"]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4 mb-6",children:[e.jsx(c,{label:"Minute",value:n,onChange:i,options:Array.from({length:60},(r,s)=>s)}),e.jsx(c,{label:"Hour",value:l,onChange:a,options:Array.from({length:24},(r,s)=>s)}),e.jsx(c,{label:"Day (Month)",value:d,onChange:p,options:Array.from({length:31},(r,s)=>s+1)}),e.jsx(c,{label:"Month",value:m,onChange:h,options:Array.from({length:12},(r,s)=>s+1)}),e.jsx(c,{label:"Day (Week)",value:x,onChange:g,options:Array.from({length:7},(r,s)=>s)})]}),e.jsxs("div",{className:"bg-surface p-4 rounded-lg text-center border border-border",children:[e.jsx("p",{className:"text-text-secondary text-sm",children:"Generated Expression"}),e.jsx("p",{className:"font-mono text-primary text-2xl mt-1",children:v}),e.jsx("button",{onClick:()=>navigator.clipboard.writeText(v),className:"mt-4 px-3 py-1 bg-gray-100 hover:bg-gray-200 rounded-md text-xs",children:"Copy"})]})]})};export{$ as CronJobBuilder};
//# sourceMappingURL=CronJobBuilder-Q9o7FUtM.js.map