1import{a4 as Y,u as v,d as N,r as p,D as E,p as c,t as h,j as s,$ as r,e as U,H as b}from"./index-ChIlw_lC.js";import{A as O}from"./agent-create-form-Cm1Mr1Zx.js";import{T as C}from"./topbar-actions-BBQqr3xN.js";import{e as F,f as R,g as I}from"./use-agents-DTChLEzb.js";import"./CaretUp-CxNilRZR.js";import"./index-C2JpwdpF.js";import"./index-Bb8eGVaS.js";import"./Briefcase-CANlwVTx.js";import"./Buildings-C-aUdW18.js";const M={MONDAY:1,TUESDAY:2,WEDNESDAY:3,THURSDAY:4,FRIDAY:5,SATURDAY:6,SUNDAY:0},_={1:"MONDAY",2:"TUESDAY",3:"WEDNESDAY",4:"THURSDAY",5:"FRIDAY",6:"SATURDAY",0:"SUNDAY"};function W(){const{agentId:y}=Y(),i=v(),{t:g}=N("nav"),D=Number(y),{data:e,isLoading:o}=F(D),f=R(),[A,x]=p.useState(!1),l=e?I(e.portalKey):null,T={title:`${(e==null?void 0:e.name)??g("agents")} | ${E.name}`};if(p.useEffect(()=>{if(!o&&!e){i(c.agents,{replace:!0});return}!o&&e&&!l&&(h.error(`ÐомаÑлÑм поÑÑал: ${e.portalKey}`),i(c.agents,{replace:!0}))},[o,e,l,i]),o||!e||!l)return s.jsx(r,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:s.jsx(U,{})});let d=[];if(e.additionalData)try{const t=JSON.parse(e.additionalData);d=Object.entries(t).map(([a,u],m)=>({id:String(m+1),key:a,value:String(u)}))}catch{}const S={name:e.name,prompt:e.prompt,scheduleType:e.scheduleType.toLowerCase(),scheduleTime:e.scheduleTime??"09:00",scheduleDay:e.scheduleDay?M[e.scheduleDay]??1:1,scheduleDate:e.scheduleDate??1,additionalData:d.length>0?d:void 0,files:[]},j=async t=>{x(!0);try{const a=t.additionalData.filter(n=>n.key.trim()&&n.value.trim()),u=a.length>0?JSON.stringify(Object.fromEntries(a.map(n=>[n.key,n.value]))):void 0,m={name:t.name,prompt:t.prompt,scheduleType:t.scheduleType.toUpperCase(),scheduleTime:t.scheduleTime,scheduleDay:t.scheduleType==="weekly"?_[t.scheduleDay]:void 0,scheduleDate:t.scheduleType==="monthly"?t.scheduleDate:void 0,additionalData:u};await f.mutateAsync({id:D,data:m}),h.success("ÐÐ³ÐµÐ½Ñ ÑаÒланди"),i(c.agents)}catch(a){console.error("Failed to update agent:",a),h.error("ÐгенÑни ÑаÒлаб бÑлмади")}finally{x(!1)}};return s.jsxs(p.Fragment,{children:[s.jsx(b,{children:s.jsx("title",{children:T.title})}),s.jsxs(r,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[s.jsx(r,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",px:2,py:1,borderBottom:"1px solid var(--mui-palette-divider)",flexShrink:0},children:s.jsx(C,{})}),s.jsx(r,{sx:{flex:1,overflow:"auto",px:{xs:2,sm:3,md:4},py:3},children:s.jsx(r,{sx:{maxWidth:720,mx:"auto"},children:s.jsx(O,{portal:l,onBack:()=>i(c.agents),onSubmit:j,isSubmitting:A,initialData:S,submitLabel:"СаÒлаÑ"})})})]})]})}export{W as Page};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.