diff --git a/assets/index-vARNRm3-.js b/assets/index-n9HkBKEi.js similarity index 79% rename from assets/index-vARNRm3-.js rename to assets/index-n9HkBKEi.js index 460f76a..d61af77 100644 --- a/assets/index-vARNRm3-.js +++ b/assets/index-n9HkBKEi.js @@ -90,4 +90,4 @@ Error generating stack: `+o.message+` * @contact * * WeStats - Weather Service API - */class nC extends tC{constructor(){super(...arguments);Qe(this,"login",{loginCreate:(n,r={})=>this.request({path:"/login",method:"POST",body:n,secure:!0,type:"application/json",...r})});Qe(this,"logout",{logoutCreate:(n={})=>this.request({path:"/logout",method:"POST",secure:!0,...n})});Qe(this,"measurements",{measurementsList:(n={})=>this.request({path:"/measurements",method:"GET",secure:!0,format:"json",...n}),measurementsCreate:(n,r={})=>this.request({path:"/measurements",method:"POST",body:n,secure:!0,format:"json",...r}),measurementsRead:(n,r={})=>this.request({path:`/measurements/${n}`,method:"GET",secure:!0,format:"json",...r}),measurementsUpdate:(n,r,i={})=>this.request({path:`/measurements/${n}`,method:"PUT",body:r,secure:!0,format:"json",...i}),measurementsDelete:(n,r={})=>this.request({path:`/measurements/${n}`,method:"DELETE",secure:!0,format:"json",...r})});Qe(this,"orders",{ordersList:(n={})=>this.request({path:"/orders",method:"GET",secure:!0,format:"json",...n}),ordersCreate:(n={})=>this.request({path:"/orders",method:"POST",secure:!0,format:"json",...n}),ordersRead:(n,r={})=>this.request({path:`/orders/${n}`,method:"GET",secure:!0,format:"json",...r}),ordersAcceptPartialUpdate:(n,r={})=>this.request({path:`/orders/${n}/accept`,method:"PATCH",secure:!0,format:"json",...r}),ordersAddItemCreate:(n,r,i={})=>this.request({path:`/orders/${n}/addItem`,method:"POST",body:r,secure:!0,type:"application/json",format:"json",...i}),ordersDeletePartialUpdate:(n,r={})=>this.request({path:`/orders/${n}/delete`,method:"PATCH",secure:!0,format:"json",...r}),ordersFormatPartialUpdate:(n,r={})=>this.request({path:`/orders/${n}/format`,method:"PATCH",secure:!0,format:"json",...r}),ordersRejectPartialUpdate:(n,r={})=>this.request({path:`/orders/${n}/reject`,method:"PATCH",secure:!0,format:"json",...r})});Qe(this,"profile",{profileList:(n={})=>this.request({path:"/profile",method:"GET",secure:!0,format:"json",...n})});Qe(this,"stations",{stationsList:(n,r={})=>this.request({path:"/stations",method:"GET",query:n,secure:!0,type:"application/x-www-form-urlencoded",format:"json",...r}),stationsCreate:(n,r={})=>this.request({path:"/stations",method:"POST",body:n,secure:!0,type:"multipart/form-data",format:"json",...r}),stationsRead:(n,r={})=>this.request({path:`/stations/${n}`,method:"GET",secure:!0,type:"application/x-www-form-urlencoded",format:"json",...r}),stationsUpdate:(n,r,i={})=>this.request({path:`/stations/${n}`,method:"PUT",body:r,secure:!0,type:"multipart/form-data",format:"json",...i}),stationsDelete:(n,r={})=>this.request({path:`/stations/${n}`,method:"DELETE",secure:!0,type:"application/x-www-form-urlencoded",format:"json",...r})});Qe(this,"updateUserRole",{updateUserRoleCreate:(n,r,i={})=>this.request({path:`/update_user_role/${n}`,method:"POST",query:r,secure:!0,format:"json",...i})});Qe(this,"userorders",{userordersList:(n={})=>this.request({path:"/userorders",method:"GET",secure:!0,format:"json",...n}),userordersCurrentList:(n={})=>this.request({path:"/userorders/current",method:"GET",secure:!0,format:"json",...n})});Qe(this,"users",{usersList:(n={})=>this.request({path:"/users/",method:"GET",secure:!0,format:"json",...n}),usersCreate:(n,r={})=>this.request({path:"/users/",method:"POST",body:n,secure:!0,format:"json",...r}),usersRead:(n,r={})=>this.request({path:`/users/${n}/`,method:"GET",secure:!0,format:"json",...r}),usersUpdate:(n,r,i={})=>this.request({path:`/users/${n}/`,method:"PUT",body:r,secure:!0,format:"json",...i}),usersPartialUpdate:(n,r,i={})=>this.request({path:`/users/${n}/`,method:"PATCH",body:r,secure:!0,format:"json",...i}),usersDelete:(n,r={})=>this.request({path:`/users/${n}/`,method:"DELETE",secure:!0,...r})})}}const ce=new nC({baseURL:"http://localhost:8000",withCredentials:!0,xsrfCookieName:"session_id"}),rC=({station:e})=>{const t=zn();return f.jsx(Fl,{className:"station-card mt-3",children:f.jsxs(Fl.Body,{children:[f.jsx("div",{className:"textStyle",children:f.jsx(Fl.Title,{children:e.name})}),f.jsx("a",{href:`/RIP-WeStatsApp/stations/${e.station_id}`,className:"btn btn-primary",children:"Подробнее"}),t&&t.role==="Админ"&&f.jsx("a",{href:`/RIP-WeStatsApp/admin/editstation/${e.station_id}`,className:"btn btn-secondary my-2",children:"Изменить"})]})})},sc=[{station_id:1,name:"Метеостанция Москва",location:"Москва, Россия",open_date:"1998-05-15",description:"Основана в 1998 году в Москве. Осуществляет наблюдения за погодными условиями в столице России.",status:!1,image_url:"https://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Wetterstation01.jpeg/330px-Wetterstation01.jpeg"},{station_id:2,name:"Метеостанция Санкт-Петербург",location:"Санкт-Петербург, Россия",open_date:"2005-10-20",description:"Станция в Санкт-Петербурге начала свою работу в 2005 году. Служит для мониторинга климата в Северной столице.",status:!1,image_url:"https://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Wetterstation01.jpeg/330px-Wetterstation01.jpeg"},{station_id:3,name:"Метеостанция Екатеринбург",location:"Екатеринбург, Россия",open_date:"1997-08-12",description:"Екатеринбургская метеостанция работает с 1997 года. Служит для отслеживания климатических изменений на Урале.",status:!0,image_url:"https://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Wetterstation01.jpeg/330px-Wetterstation01.jpeg"},{station_id:4,name:"Метеостанция Нижний Новгород",location:"Нижний Новгород, Россия",open_date:"2000-03-25",description:"Станция в Нижнем Новгороде начала работу в 2000 году. Осуществляет мониторинг погоды в Волго-Вятском регионе.",status:!0,image_url:"https://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Wetterstation01.jpeg/330px-Wetterstation01.jpeg"},{station_id:5,name:"Метеостанция Красноярск",location:"Красноярск, Россия",open_date:"2012-11-08",description:"Красноярская метеостанция начала свою деятельность в 2012 году. Предназначена для мониторинга климата в Сибири.",status:!0,image_url:"https://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Wetterstation01.jpeg/330px-Wetterstation01.jpeg"},{station_id:6,name:"Метеостанция Владивосток",location:"Владивосток, Россия",open_date:"2019-06-30",description:"Метеостанция во Владивостоке начала работу в 2019 году. Обеспечивает наблюдение за погодными условиями на Дальнем Востоке.",status:!0,image_url:"https://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Wetterstation01.jpeg/330px-Wetterstation01.jpeg"}],iC=()=>{const[e,t]=k.useState(""),[n,r]=k.useState(!1),[i,o]=k.useState([]),s=async()=>{try{const{data:l}=await ce.stations.stationsList();o(l)}catch(l){console.error("Ошибка при получении станций:",l),o(sc)}finally{r(!1)}},a=async()=>{try{const l={filter:e},{data:u}=await ce.stations.stationsList(l);o(u)}catch(l){console.error("Ошибка при получении станций:",l),o(sc.filter(u=>u.name.includes(e)))}finally{r(!1)}};return k.useEffect(()=>{r(!0),s()},[]),f.jsxs("div",{className:`container ${n&&"containerLoading"}`,children:[f.jsxs("div",{className:"inputField d-flex justify-content-center mt-3",children:[f.jsx("input",{value:e,onChange:l=>t(l.target.value),className:"form-control me-3",placeholder:"Введите значение для поиска"}),f.jsx(pr,{disabled:n,onClick:a,className:"btn btn-primary me-3",children:"Искать"}),n&&f.jsx("div",{className:"loadingBg",children:f.jsx(mr,{animation:"border"})})]}),f.jsx("hr",{}),!i.length&&f.jsx("div",{children:f.jsx("h1",{children:"К сожалению, пока ничего не найдено :("})}),f.jsx(Sd,{xs:4,ms:4,className:"g-10",children:i.map((l,u)=>f.jsx(pa,{children:f.jsx(rC,{station:l})},u))})]})},oC=k.createContext({}),sC=()=>{const{stationId:e}=vd(),[t,n]=k.useState(!0),[r,i]=k.useState(!1),[o,s]=k.useState({});return k.useEffect(()=>{n(!0),(async()=>{try{if(e){const l=await ce.stations.stationsRead(e);s(l.data),i(!0)}}catch(l){console.error("Failed to fetch station data. Using mock.",l);const u=sc.find(c=>c.station_id===Number(e));u&&(s(u),i(!0)),i(!1)}finally{n(!1)}})()},[e]),f.jsxs("div",{children:[t&&f.jsx("div",{className:"loadingBg",children:f.jsx(mr,{animation:"border"})}),!t&&!r&&f.jsxs("div",{children:[f.jsx("h1",{children:"Не удалось загрузить запрашиваемые данные."}),f.jsx("a",{href:"/RIP-WeStatsApp/stations",className:"btn btn-primary me-3 mt-5",children:"Вернуться"})]}),!t&&r&&f.jsx(oC.Provider,{value:o,children:f.jsx(AE,{className:"mt-4 ",children:f.jsxs(Sd,{children:[f.jsx(pa,{md:6,children:o.image_url&&f.jsx("img",{src:o.image_url,alt:"Station",className:"img-fluid"})}),f.jsxs(pa,{md:6,children:[f.jsx("h2",{children:o.name}),f.jsx("p",{children:o.description}),f.jsxs("p",{children:["Местоположение: ",o.location]}),f.jsxs("p",{children:["Дата открытия: ",new Date(o.open_date).toLocaleString()]}),f.jsxs("p",{children:["Статус: ",o.status?"Работает":"Не работает"]}),f.jsx("div",{className:"d-flex justify-content-center",children:f.jsx("a",{href:"/RIP-WeStatsApp/stations",className:"btn btn-primary me-4",children:"Назад"})})]})]})})})]})},aC=()=>f.jsx("footer",{className:"bg-dark text-light p-3 mt-5",children:f.jsxs("div",{className:"container",children:[f.jsx("p",{className:"mb-0",children:"© 2024 WeStats"}),f.jsx("p",{className:"mb-0",children:"By Kostin Sergey IU5-55B"}),f.jsx("a",{href:"/RIP-WeStatsApp/",children:"Главная"})]})}),Uo=S1,lC=()=>{const e=Uo(),t=gd(),[n,r]=k.useState(""),[i,o]=k.useState(""),[s,a]=k.useState(!1),[l,u]=k.useState(!1),c=async()=>{a(!1),u(!1);try{const d=await ce.login.loginCreate({email:n,password:i});if(console.log(d.status),d.status===200){u(!0);try{const h=await ce.profile.profileList();e(Yy.setUserAuth(h.data));try{const w=await ce.userorders.userordersCurrentList();w.data?e(pi.setCurrentOrder({orderInfo:w.data.order,cart:w.data.measurements})):e(pi.flush())}catch(w){console.error("Ошибка загрузки заказа",w)}t("/RIP-WeStatsApp/profile")}catch(h){console.error("Ошибка загрузки профиля",h)}}else a(!0)}catch(d){console.error("Ошибка при входе:",d),a(!0)}};return f.jsxs("div",{className:"mt-4",children:[f.jsx("h2",{className:"mb-4",children:"Авторизация"}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"email",className:"form-label",children:"Email:"}),f.jsx("input",{type:"email",id:"email",className:"form-control",value:n,onChange:d=>r(d.target.value)})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"password",className:"form-label",children:"Пароль:"}),f.jsx("input",{type:"password",id:"password",className:"form-control",value:i,onChange:d=>o(d.target.value)})]}),f.jsx("button",{type:"submit",onClick:c,className:"btn btn-primary",children:"Войти"}),s&&f.jsx("div",{style:{color:"red"},children:"Неверные данные"}),l&&f.jsx("div",{style:{color:"green"},children:"Успешно!"})]})};/*! js-cookie v3.0.5 | MIT */function ms(e){for(var t=1;t"u")){s=ms({},t,s),typeof s.expires=="number"&&(s.expires=new Date(Date.now()+s.expires*864e5)),s.expires&&(s.expires=s.expires.toUTCString()),i=encodeURIComponent(i).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var l in s)s[l]&&(a+="; "+l,s[l]!==!0&&(a+="="+s[l].split(";")[0]));return document.cookie=i+"="+e.write(o,i)+a}}function r(i){if(!(typeof document>"u"||arguments.length&&!i)){for(var o=document.cookie?document.cookie.split("; "):[],s={},a=0;af.jsx("div",{className:"card my-3",children:f.jsxs("div",{className:"card-body",children:[f.jsxs("h5",{className:"card-title",children:[f.jsx("strong",{children:"Роль:"})," Метеоролог"]}),f.jsx("p",{className:"card-text",children:"Дополнительная информация о метеорологе."}),f.jsx("a",{href:"/RIP-WeStatsApp/measurements",className:"btn btn-primary mx-2",children:"Добавленные показания"}),f.jsx("a",{href:"/RIP-WeStatsApp/uploadmeasure",className:"btn btn-success mx-2",children:"Добавить показания"})]})}),fC=()=>f.jsx("div",{className:"card my-3",children:f.jsxs("div",{className:"card-body",children:[f.jsxs("h5",{className:"card-title",children:[f.jsx("strong",{children:"Роль:"})," Менеджер"]}),f.jsx("p",{className:"card-text",children:"Дополнительная информация о менеджере."}),f.jsx("a",{href:"/RIP-WeStatsApp/admin/orders",className:"btn btn-primary mx-2",children:"Заказы"})]})}),iv=()=>xy(e=>({orderInfo:e.currentOrder.orderInfo,cart:e.currentOrder.cart})),hC=()=>{const e=iv().orderInfo;console.log(e);const t=Uo(),n=async()=>{const r=await ce.orders.ordersCreate();t(pi.initNew(r.data))};return f.jsx("div",{className:"card my-3",children:f.jsxs("div",{className:"card-body",children:[f.jsxs("h5",{className:"card-title",children:[f.jsx("strong",{children:"Роль:"})," Пользователь"]}),f.jsx("p",{className:"card-text",children:"Дополнительная информация о пользователе."}),e&&f.jsx("a",{href:`/RIP-WeStatsApp/profile/orders/${e.order_id}`,className:"btn btn-primary mx-2",children:"Текущий заказ"}),!e&&f.jsx("button",{className:"btn btn-primary mx-2",onClick:n,children:"Новый заказ"}),f.jsx("a",{href:"/RIP-WeStatsApp/profile/orders",className:"btn btn-success mx-2",children:"Мои заказы"})]})})},pC=()=>f.jsx("div",{className:"card my-3",children:f.jsxs("div",{className:"card-body",children:[f.jsxs("h5",{className:"card-title",children:[f.jsx("strong",{children:"Роль:"})," Администратор"]}),f.jsx("p",{className:"card-text",children:"Дополнительная информация об администраторе."}),f.jsx("a",{href:"/RIP-WeStatsApp/admin/orders",className:"btn btn-primary mx-2",children:"Заказы"}),f.jsx("a",{href:"/RIP-WeStatsApp/admin/addstation",className:"btn btn-primary mx-2",children:"Добавить станцию"}),f.jsx("a",{href:"/RIP-WeStatsApp/stations",className:"btn btn-primary mx-2",children:"Управление станциями"}),f.jsx("a",{href:"/RIP-WeStatsApp/admin/editmeasurements",className:"btn btn-primary mx-2",children:"Управление измерениями"}),f.jsx("a",{href:"/RIP-WeStatsApp/admin/perms",className:"btn btn-primary mx-2",children:"Управление правами"})]})}),mC=()=>{const e=zn(),t=Uo(),n=gd();e||n("/RIP-WeStatsApp/login");const r=async()=>{try{await ce.logout.logoutCreate(),t(Yy.setUserAuth(null)),cC.remove("session_id"),n("/RIP-WeStatsApp/login")}catch(o){console.error("Ошибка выхода:",o)}},i=()=>{switch(e==null?void 0:e.role){case"Админ":return f.jsx(pC,{});case"Менеджер":return f.jsx(fC,{});case"Пользователь":return f.jsx(hC,{});case"Метеоролог":return f.jsx(dC,{});default:return null}};return f.jsxs("div",{className:"container mt-5",children:[f.jsx("h2",{className:"mb-4",children:"Профиль пользователя"}),(e==null?void 0:e.role)==="Админ"&&f.jsx("div",{className:"alert alert-success",role:"alert",children:"Вы авторизованы как администратор."}),f.jsxs("div",{className:"mb-3",children:[f.jsx("strong",{children:"Имя:"})," ",e==null?void 0:e.name]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("strong",{children:"Email:"})," ",e==null?void 0:e.email]}),i(),f.jsx("button",{className:"btn btn-danger",onClick:r,children:"Выйти"})]})};var zo=e=>e.type==="checkbox",Zr=e=>e instanceof Date,ut=e=>e==null;const ov=e=>typeof e=="object";var ze=e=>!ut(e)&&!Array.isArray(e)&&ov(e)&&!Zr(e),yC=e=>ze(e)&&e.target?zo(e.target)?e.target.checked:e.target.value:e,gC=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,vC=(e,t)=>e.has(gC(t)),wC=e=>{const t=e.constructor&&e.constructor.prototype;return ze(t)&&t.hasOwnProperty("isPrototypeOf")},jd=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function bt(e){let t;const n=Array.isArray(e);if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(jd&&(e instanceof Blob||e instanceof FileList))&&(n||ze(e)))if(t=n?[]:{},!n&&!wC(e))t=e;else for(const r in e)e.hasOwnProperty(r)&&(t[r]=bt(e[r]));else return e;return t}var $o=e=>Array.isArray(e)?e.filter(Boolean):[],be=e=>e===void 0,B=(e,t,n)=>{if(!t||!ze(e))return n;const r=$o(t.split(/[,[\].]+?/)).reduce((i,o)=>ut(i)?i:i[o],e);return be(r)||r===e?be(e[t])?n:e[t]:r},yn=e=>typeof e=="boolean";const $h={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Kt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},hn={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};pt.createContext(null);var SC=(e,t,n,r=!0)=>{const i={defaultValues:t._defaultValues};for(const o in e)Object.defineProperty(i,o,{get:()=>{const s=o;return t._proxyFormState[s]!==Kt.all&&(t._proxyFormState[s]=!r||Kt.all),n&&(n[s]=!0),e[s]}});return i},Mt=e=>ze(e)&&!Object.keys(e).length,xC=(e,t,n,r)=>{n(e);const{name:i,...o}=e;return Mt(o)||Object.keys(o).length>=Object.keys(t).length||Object.keys(o).find(s=>t[s]===(!r||Kt.all))},$l=e=>Array.isArray(e)?e:[e];function EC(e){const t=pt.useRef(e);t.current=e,pt.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}var an=e=>typeof e=="string",_C=(e,t,n,r,i)=>an(e)?(r&&t.watch.add(e),B(n,e,i)):Array.isArray(e)?e.map(o=>(r&&t.watch.add(o),B(n,o))):(r&&(t.watchAll=!0),n),Nd=e=>/^\w*$/.test(e),sv=e=>$o(e.replace(/["|']|\]/g,"").split(/\.|\[/)),xe=(e,t,n)=>{let r=-1;const i=Nd(t)?[t]:sv(t),o=i.length,s=o-1;for(;++rt?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},Bh=e=>({isOnSubmit:!e||e===Kt.onSubmit,isOnBlur:e===Kt.onBlur,isOnChange:e===Kt.onChange,isOnAll:e===Kt.all,isOnTouch:e===Kt.onTouched}),Wh=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const no=(e,t,n,r)=>{for(const i of n||Object.keys(e)){const o=B(e,i);if(o){const{_f:s,...a}=o;if(s){if(s.refs&&s.refs[0]&&t(s.refs[0],i)&&!r)break;if(s.ref&&t(s.ref,s.name)&&!r)break;no(a,t)}else ze(a)&&no(a,t)}}};var kC=(e,t,n)=>{const r=$o(B(e,n));return xe(r,"root",t[n]),xe(e,n,r),e},Rd=e=>e.type==="file",$n=e=>typeof e=="function",ya=e=>{if(!jd)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},As=e=>an(e),Od=e=>e.type==="radio",ga=e=>e instanceof RegExp;const Vh={value:!1,isValid:!1},Hh={value:!0,isValid:!0};var av=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!be(e[0].attributes.value)?be(e[0].value)||e[0].value===""?Hh:{value:e[0].value,isValid:!0}:Hh:Vh}return Vh};const qh={isValid:!1,value:null};var lv=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,qh):qh;function Yh(e,t,n="validate"){if(As(e)||Array.isArray(e)&&e.every(As)||yn(e)&&!e)return{type:n,message:As(e)?e:"",ref:t}}var Ar=e=>ze(e)&&!ga(e)?e:{value:e,message:""},Qh=async(e,t,n,r,i)=>{const{ref:o,refs:s,required:a,maxLength:l,minLength:u,min:c,max:d,pattern:h,validate:w,name:g,valueAsNumber:v,mount:E,disabled:m}=e._f,p=B(t,g);if(!E||m)return{};const y=s?s[0]:o,C=K=>{r&&y.reportValidity&&(y.setCustomValidity(yn(K)?"":K||""),y.reportValidity())},R={},x=Od(o),T=zo(o),M=x||T,A=(v||Rd(o))&&be(o.value)&&be(p)||ya(o)&&o.value===""||p===""||Array.isArray(p)&&!p.length,V=CC.bind(null,g,n,R),Z=(K,q,ae,Oe=hn.maxLength,Te=hn.minLength)=>{const ie=K?q:ae;R[g]={type:K?Oe:Te,message:ie,ref:o,...V(K?Oe:Te,ie)}};if(i?!Array.isArray(p)||!p.length:a&&(!M&&(A||ut(p))||yn(p)&&!p||T&&!av(s).isValid||x&&!lv(s).isValid)){const{value:K,message:q}=As(a)?{value:!!a,message:a}:Ar(a);if(K&&(R[g]={type:hn.required,message:q,ref:y,...V(hn.required,q)},!n))return C(q),R}if(!A&&(!ut(c)||!ut(d))){let K,q;const ae=Ar(d),Oe=Ar(c);if(!ut(p)&&!isNaN(p)){const Te=o.valueAsNumber||p&&+p;ut(ae.value)||(K=Te>ae.value),ut(Oe.value)||(q=Tenew Date(new Date().toDateString()+" "+G),I=o.type=="time",Y=o.type=="week";an(ae.value)&&p&&(K=I?ie(p)>ie(ae.value):Y?p>ae.value:Te>new Date(ae.value)),an(Oe.value)&&p&&(q=I?ie(p)+K.value,Oe=!ut(q.value)&&p.length<+q.value;if((ae||Oe)&&(Z(ae,K.message,q.message),!n))return C(R[g].message),R}if(h&&!A&&an(p)){const{value:K,message:q}=Ar(h);if(ga(K)&&!p.match(K)&&(R[g]={type:hn.pattern,message:q,ref:o,...V(hn.pattern,q)},!n))return C(q),R}if(w){if($n(w)){const K=await w(p,t),q=Yh(K,y);if(q&&(R[g]={...q,...V(hn.validate,q.message)},!n))return C(q.message),R}else if(ze(w)){let K={};for(const q in w){if(!Mt(K)&&!n)break;const ae=Yh(await w[q](p,t),y,q);ae&&(K={...ae,...V(q,ae.message)},C(ae.message),n&&(R[g]=K))}if(!Mt(K)&&(R[g]={ref:y,...K},!n))return R}}return C(!0),R};function PC(e,t){const n=t.slice(0,-1).length;let r=0;for(;r{let e=[];return{get observers(){return e},next:i=>{for(const o of e)o.next&&o.next(i)},subscribe:i=>(e.push(i),{unsubscribe:()=>{e=e.filter(o=>o!==i)}}),unsubscribe:()=>{e=[]}}},va=e=>ut(e)||!ov(e);function yr(e,t){if(va(e)||va(t))return e===t;if(Zr(e)&&Zr(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n){const o=e[i];if(!r.includes(i))return!1;if(i!=="ref"){const s=t[i];if(Zr(o)&&Zr(s)||ze(o)&&ze(s)||Array.isArray(o)&&Array.isArray(s)?!yr(o,s):o!==s)return!1}}return!0}var uv=e=>e.type==="select-multiple",NC=e=>Od(e)||zo(e),Wl=e=>ya(e)&&e.isConnected,cv=e=>{for(const t in e)if($n(e[t]))return!0;return!1};function wa(e,t={}){const n=Array.isArray(e);if(ze(e)||n)for(const r in e)Array.isArray(e[r])||ze(e[r])&&!cv(e[r])?(t[r]=Array.isArray(e[r])?[]:{},wa(e[r],t[r])):ut(e[r])||(t[r]=!0);return t}function dv(e,t,n){const r=Array.isArray(e);if(ze(e)||r)for(const i in e)Array.isArray(e[i])||ze(e[i])&&!cv(e[i])?be(t)||va(n[i])?n[i]=Array.isArray(e[i])?wa(e[i],[]):{...wa(e[i])}:dv(e[i],ut(t)?{}:t[i],n[i]):n[i]=!yr(e[i],t[i]);return n}var Vl=(e,t)=>dv(e,t,wa(t)),fv=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>be(e)?e:t?e===""?NaN:e&&+e:n&&an(e)?new Date(e):r?r(e):e;function Hl(e){const t=e.ref;if(!(e.refs?e.refs.every(n=>n.disabled):t.disabled))return Rd(t)?t.files:Od(t)?lv(e.refs).value:uv(t)?[...t.selectedOptions].map(({value:n})=>n):zo(t)?av(e.refs).value:fv(be(t.value)?e.ref.value:t.value,e)}var RC=(e,t,n,r)=>{const i={};for(const o of e){const s=B(t,o);s&&xe(i,o,s._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},Ai=e=>be(e)?e:ga(e)?e.source:ze(e)?ga(e.value)?e.value.source:e.value:e,OC=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Kh(e,t,n){const r=B(e,n);if(r||Nd(n))return{error:r,name:n};const i=n.split(".");for(;i.length;){const o=i.join("."),s=B(t,o),a=B(e,o);if(s&&!Array.isArray(s)&&n!==o)return{name:n};if(a&&a.type)return{name:o,error:a};i.pop()}return{name:n}}var TC=(e,t,n,r,i)=>i.isOnAll?!1:!n&&i.isOnTouch?!(t||e):(n?r.isOnBlur:i.isOnBlur)?!e:(n?r.isOnChange:i.isOnChange)?e:!0,DC=(e,t)=>!$o(B(e,t)).length&&Ke(e,t);const bC={mode:Kt.onSubmit,reValidateMode:Kt.onChange,shouldFocusError:!0};function LC(e={},t){let n={...bC,...e},r={submitCount:0,isDirty:!1,isLoading:$n(n.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:n.errors||{},disabled:n.disabled||!1},i={},o=ze(n.defaultValues)||ze(n.values)?bt(n.defaultValues||n.values)||{}:{},s=n.shouldUnregister?{}:bt(o),a={action:!1,mount:!1,watch:!1},l={mount:new Set,unMount:new Set,array:new Set,watch:new Set},u,c=0;const d={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},h={values:Bl(),array:Bl(),state:Bl()},w=Bh(n.mode),g=Bh(n.reValidateMode),v=n.criteriaMode===Kt.all,E=S=>j=>{clearTimeout(c),c=setTimeout(S,j)},m=async S=>{if(d.isValid||S){const j=n.resolver?Mt((await A()).errors):await Z(i,!0);j!==r.isValid&&h.state.next({isValid:j})}},p=S=>d.isValidating&&h.state.next({isValidating:S}),y=(S,j=[],N,z,F=!0,b=!0)=>{if(z&&N){if(a.action=!0,b&&Array.isArray(B(i,S))){const H=N(B(i,S),z.argA,z.argB);F&&xe(i,S,H)}if(b&&Array.isArray(B(r.errors,S))){const H=N(B(r.errors,S),z.argA,z.argB);F&&xe(r.errors,S,H),DC(r.errors,S)}if(d.touchedFields&&b&&Array.isArray(B(r.touchedFields,S))){const H=N(B(r.touchedFields,S),z.argA,z.argB);F&&xe(r.touchedFields,S,H)}d.dirtyFields&&(r.dirtyFields=Vl(o,s)),h.state.next({name:S,isDirty:q(S,j),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else xe(s,S,j)},C=(S,j)=>{xe(r.errors,S,j),h.state.next({errors:r.errors})},R=S=>{r.errors=S,h.state.next({errors:r.errors,isValid:!1})},x=(S,j,N,z)=>{const F=B(i,S);if(F){const b=B(s,S,be(N)?B(o,S):N);be(b)||z&&z.defaultChecked||j?xe(s,S,j?b:Hl(F._f)):Te(S,b),a.mount&&m()}},T=(S,j,N,z,F)=>{let b=!1,H=!1;const de={name:S},_e=!!(B(i,S)&&B(i,S)._f.disabled);if(!N||z){d.isDirty&&(H=r.isDirty,r.isDirty=de.isDirty=q(),b=H!==de.isDirty);const Tt=_e||yr(B(o,S),j);H=!!(!_e&&B(r.dirtyFields,S)),Tt||_e?Ke(r.dirtyFields,S):xe(r.dirtyFields,S,!0),de.dirtyFields=r.dirtyFields,b=b||d.dirtyFields&&H!==!Tt}if(N){const Tt=B(r.touchedFields,S);Tt||(xe(r.touchedFields,S,N),de.touchedFields=r.touchedFields,b=b||d.touchedFields&&Tt!==N)}return b&&F&&h.state.next(de),b?de:{}},M=(S,j,N,z)=>{const F=B(r.errors,S),b=d.isValid&&yn(j)&&r.isValid!==j;if(e.delayError&&N?(u=E(()=>C(S,N)),u(e.delayError)):(clearTimeout(c),u=null,N?xe(r.errors,S,N):Ke(r.errors,S)),(N?!yr(F,N):F)||!Mt(z)||b){const H={...z,...b&&yn(j)?{isValid:j}:{},errors:r.errors,name:S};r={...r,...H},h.state.next(H)}p(!1)},A=async S=>n.resolver(s,n.context,RC(S||l.mount,i,n.criteriaMode,n.shouldUseNativeValidation)),V=async S=>{const{errors:j}=await A(S);if(S)for(const N of S){const z=B(j,N);z?xe(r.errors,N,z):Ke(r.errors,N)}else r.errors=j;return j},Z=async(S,j,N={valid:!0})=>{for(const z in S){const F=S[z];if(F){const{_f:b,...H}=F;if(b){const de=l.array.has(b.name),_e=await Qh(F,s,v,n.shouldUseNativeValidation&&!j,de);if(_e[b.name]&&(N.valid=!1,j))break;!j&&(B(_e,b.name)?de?kC(r.errors,_e,b.name):xe(r.errors,b.name,_e[b.name]):Ke(r.errors,b.name))}H&&await Z(H,j,N)}}return N.valid},K=()=>{for(const S of l.unMount){const j=B(i,S);j&&(j._f.refs?j._f.refs.every(N=>!Wl(N)):!Wl(j._f.ref))&&Ot(S)}l.unMount=new Set},q=(S,j)=>(S&&j&&xe(s,S,j),!yr(pe(),o)),ae=(S,j,N)=>_C(S,l,{...a.mount?s:be(j)?o:an(S)?{[S]:j}:j},N,j),Oe=S=>$o(B(a.mount?s:o,S,e.shouldUnregister?B(o,S,[]):[])),Te=(S,j,N={})=>{const z=B(i,S);let F=j;if(z){const b=z._f;b&&(!b.disabled&&xe(s,S,fv(j,b)),F=ya(b.ref)&&ut(j)?"":j,uv(b.ref)?[...b.ref.options].forEach(H=>H.selected=F.includes(H.value)):b.refs?zo(b.ref)?b.refs.length>1?b.refs.forEach(H=>(!H.defaultChecked||!H.disabled)&&(H.checked=Array.isArray(F)?!!F.find(de=>de===H.value):F===H.value)):b.refs[0]&&(b.refs[0].checked=!!F):b.refs.forEach(H=>H.checked=H.value===F):Rd(b.ref)?b.ref.value="":(b.ref.value=F,b.ref.type||h.values.next({name:S,values:{...s}})))}(N.shouldDirty||N.shouldTouch)&&T(S,F,N.shouldTouch,N.shouldDirty,!0),N.shouldValidate&&oe(S)},ie=(S,j,N)=>{for(const z in j){const F=j[z],b=`${S}.${z}`,H=B(i,b);(l.array.has(S)||!va(F)||H&&!H._f)&&!Zr(F)?ie(b,F,N):Te(b,F,N)}},I=(S,j,N={})=>{const z=B(i,S),F=l.array.has(S),b=bt(j);xe(s,S,b),F?(h.array.next({name:S,values:{...s}}),(d.isDirty||d.dirtyFields)&&N.shouldDirty&&h.state.next({name:S,dirtyFields:Vl(o,s),isDirty:q(S,b)})):z&&!z._f&&!ut(b)?ie(S,b,N):Te(S,b,N),Wh(S,l)&&h.state.next({...r}),h.values.next({name:S,values:{...s}}),!a.mount&&t()},Y=async S=>{const j=S.target;let N=j.name,z=!0;const F=B(i,N),b=()=>j.type?Hl(F._f):yC(S),H=de=>{z=Number.isNaN(de)||de===B(s,N,de)};if(F){let de,_e;const Tt=b(),at=S.type===$h.BLUR||S.type===$h.FOCUS_OUT,qo=!OC(F._f)&&!n.resolver&&!B(r.errors,N)&&!F._f.deps||TC(at,B(r.touchedFields,N),r.isSubmitted,g,w),Or=Wh(N,l,at);xe(s,N,Tt),at?(F._f.onBlur&&F._f.onBlur(S),u&&u(0)):F._f.onChange&&F._f.onChange(S);const Tr=T(N,Tt,at,!1),Xa=!Mt(Tr)||Or;if(!at&&h.values.next({name:N,type:S.type,values:{...s}}),qo)return d.isValid&&m(),Xa&&h.state.next({name:N,...Or?{}:Tr});if(!at&&Or&&h.state.next({...r}),p(!0),n.resolver){const{errors:xi}=await A([N]);if(H(Tt),z){const Dr=Kh(r.errors,i,N),Ei=Kh(xi,i,Dr.name||N);de=Ei.error,N=Ei.name,_e=Mt(xi)}}else de=(await Qh(F,s,v,n.shouldUseNativeValidation))[N],H(Tt),z&&(de?_e=!1:d.isValid&&(_e=await Z(i,!0)));z&&(F._f.deps&&oe(F._f.deps),M(N,_e,de,Tr))}},G=(S,j)=>{if(B(r.errors,j)&&S.focus)return S.focus(),1},oe=async(S,j={})=>{let N,z;const F=$l(S);if(p(!0),n.resolver){const b=await V(be(S)?S:F);N=Mt(b),z=S?!F.some(H=>B(b,H)):N}else S?(z=(await Promise.all(F.map(async b=>{const H=B(i,b);return await Z(H&&H._f?{[b]:H}:H)}))).every(Boolean),!(!z&&!r.isValid)&&m()):z=N=await Z(i);return h.state.next({...!an(S)||d.isValid&&N!==r.isValid?{}:{name:S},...n.resolver||!S?{isValid:N}:{},errors:r.errors,isValidating:!1}),j.shouldFocus&&!z&&no(i,G,S?F:l.mount),z},pe=S=>{const j={...o,...a.mount?s:{}};return be(S)?j:an(S)?B(j,S):S.map(N=>B(j,N))},St=(S,j)=>({invalid:!!B((j||r).errors,S),isDirty:!!B((j||r).dirtyFields,S),isTouched:!!B((j||r).touchedFields,S),error:B((j||r).errors,S)}),Ae=S=>{S&&$l(S).forEach(j=>Ke(r.errors,j)),h.state.next({errors:S?r.errors:{}})},ht=(S,j,N)=>{const z=(B(i,S,{_f:{}})._f||{}).ref;xe(r.errors,S,{...j,ref:z}),h.state.next({name:S,errors:r.errors,isValid:!1}),N&&N.shouldFocus&&z&&z.focus&&z.focus()},qe=(S,j)=>$n(S)?h.values.subscribe({next:N=>S(ae(void 0,j),N)}):ae(S,j,!0),Ot=(S,j={})=>{for(const N of S?$l(S):l.mount)l.mount.delete(N),l.array.delete(N),j.keepValue||(Ke(i,N),Ke(s,N)),!j.keepError&&Ke(r.errors,N),!j.keepDirty&&Ke(r.dirtyFields,N),!j.keepTouched&&Ke(r.touchedFields,N),!n.shouldUnregister&&!j.keepDefaultValue&&Ke(o,N);h.values.next({values:{...s}}),h.state.next({...r,...j.keepDirty?{isDirty:q()}:{}}),!j.keepIsValid&&m()},Bo=({disabled:S,name:j,field:N,fields:z,value:F})=>{if(yn(S)){const b=S?void 0:be(F)?Hl(N?N._f:B(z,j)._f):F;xe(s,j,b),T(j,b,!1,!1,!0)}},Si=(S,j={})=>{let N=B(i,S);const z=yn(j.disabled);return xe(i,S,{...N||{},_f:{...N&&N._f?N._f:{ref:{name:S}},name:S,mount:!0,...j}}),l.mount.add(S),N?Bo({field:N,disabled:j.disabled,name:S,value:j.value}):x(S,!0,j.value),{...z?{disabled:j.disabled}:{},...n.progressive?{required:!!j.required,min:Ai(j.min),max:Ai(j.max),minLength:Ai(j.minLength),maxLength:Ai(j.maxLength),pattern:Ai(j.pattern)}:{},name:S,onChange:Y,onBlur:Y,ref:F=>{if(F){Si(S,j),N=B(i,S);const b=be(F.value)&&F.querySelectorAll&&F.querySelectorAll("input,select,textarea")[0]||F,H=NC(b),de=N._f.refs||[];if(H?de.find(_e=>_e===b):b===N._f.ref)return;xe(i,S,{_f:{...N._f,...H?{refs:[...de.filter(Wl),b,...Array.isArray(B(o,S))?[{}]:[]],ref:{type:b.type,name:S}}:{ref:b}}}),x(S,!1,void 0,b)}else N=B(i,S,{}),N._f&&(N._f.mount=!1),(n.shouldUnregister||j.shouldUnregister)&&!(vC(l.array,S)&&a.action)&&l.unMount.add(S)}}},Wo=()=>n.shouldFocusError&&no(i,G,l.mount),st=S=>{yn(S)&&(h.state.next({disabled:S}),no(i,(j,N)=>{let z=S;const F=B(i,N);F&&yn(F._f.disabled)&&(z||(z=F._f.disabled)),j.disabled=z},0,!1))},Nn=(S,j)=>async N=>{N&&(N.preventDefault&&N.preventDefault(),N.persist&&N.persist());let z=bt(s);if(h.state.next({isSubmitting:!0}),n.resolver){const{errors:F,values:b}=await A();r.errors=F,z=b}else await Z(i);Ke(r.errors,"root"),Mt(r.errors)?(h.state.next({errors:{}}),await S(z,N)):(j&&await j({...r.errors},N),Wo(),setTimeout(Wo)),h.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Mt(r.errors),submitCount:r.submitCount+1,errors:r.errors})},Vo=(S,j={})=>{B(i,S)&&(be(j.defaultValue)?I(S,bt(B(o,S))):(I(S,j.defaultValue),xe(o,S,bt(j.defaultValue))),j.keepTouched||Ke(r.touchedFields,S),j.keepDirty||(Ke(r.dirtyFields,S),r.isDirty=j.defaultValue?q(S,bt(B(o,S))):q()),j.keepError||(Ke(r.errors,S),d.isValid&&m()),h.state.next({...r}))},Ho=(S,j={})=>{const N=S?bt(S):o,z=bt(N),F=S&&!Mt(S)?z:o;if(j.keepDefaultValues||(o=N),!j.keepValues){if(j.keepDirtyValues)for(const b of l.mount)B(r.dirtyFields,b)?xe(F,b,B(s,b)):I(b,B(F,b));else{if(jd&&be(S))for(const b of l.mount){const H=B(i,b);if(H&&H._f){const de=Array.isArray(H._f.refs)?H._f.refs[0]:H._f.ref;if(ya(de)){const _e=de.closest("form");if(_e){_e.reset();break}}}}i={}}s=e.shouldUnregister?j.keepDefaultValues?bt(o):{}:bt(F),h.array.next({values:{...F}}),h.values.next({values:{...F}})}l={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!a.mount&&t(),a.mount=!d.isValid||!!j.keepIsValid,a.watch=!!e.shouldUnregister,h.state.next({submitCount:j.keepSubmitCount?r.submitCount:0,isDirty:j.keepDirty?r.isDirty:!!(j.keepDefaultValues&&!yr(S,o)),isSubmitted:j.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:j.keepDirtyValues?r.dirtyFields:j.keepDefaultValues&&S?Vl(o,S):{},touchedFields:j.keepTouched?r.touchedFields:{},errors:j.keepErrors?r.errors:{},isSubmitSuccessful:j.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},en=(S,j)=>Ho($n(S)?S(s):S,j);return{control:{register:Si,unregister:Ot,getFieldState:St,handleSubmit:Nn,setError:ht,_executeSchema:A,_getWatch:ae,_getDirty:q,_updateValid:m,_removeUnmounted:K,_updateFieldArray:y,_updateDisabledField:Bo,_getFieldArray:Oe,_reset:Ho,_resetDefaultValues:()=>$n(n.defaultValues)&&n.defaultValues().then(S=>{en(S,n.resetOptions),h.state.next({isLoading:!1})}),_updateFormState:S=>{r={...r,...S}},_disableForm:st,_subjects:h,_proxyFormState:d,_setErrors:R,get _fields(){return i},get _formValues(){return s},get _state(){return a},set _state(S){a=S},get _defaultValues(){return o},get _names(){return l},set _names(S){l=S},get _formState(){return r},set _formState(S){r=S},get _options(){return n},set _options(S){n={...n,...S}}},trigger:oe,register:Si,handleSubmit:Nn,watch:qe,setValue:I,getValues:pe,reset:en,resetField:Vo,clearErrors:Ae,unregister:Ot,setError:ht,setFocus:(S,j={})=>{const N=B(i,S),z=N&&N._f;if(z){const F=z.refs?z.refs[0]:z.ref;F.focus&&(F.focus(),j.shouldSelect&&F.select())}},getFieldState:St}}function Td(e={}){const t=pt.useRef(),n=pt.useRef(),[r,i]=pt.useState({isDirty:!1,isValidating:!1,isLoading:$n(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:$n(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...LC(e,()=>i(s=>({...s}))),formState:r});const o=t.current.control;return o._options=e,EC({subject:o._subjects.state,next:s=>{xC(s,o._proxyFormState,o._updateFormState,!0)&&i({...o._formState})}}),pt.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),pt.useEffect(()=>{if(o._proxyFormState.isDirty){const s=o._getDirty();s!==r.isDirty&&o._subjects.state.next({isDirty:s})}},[o,r.isDirty]),pt.useEffect(()=>{e.values&&!yr(e.values,n.current)?(o._reset(e.values,o._options.resetOptions),n.current=e.values,i(s=>({...s}))):o._resetDefaultValues()},[e.values,o]),pt.useEffect(()=>{e.errors&&o._setErrors(e.errors)},[e.errors,o]),pt.useEffect(()=>{o._state.mount||(o._updateValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),t.current.formState=SC(r,o),t.current}const MC=()=>{const[e,t]=k.useState(!1),{register:n,handleSubmit:r}=Td(),[i,o]=k.useState([]),[s,a]=k.useState(!1);k.useEffect(()=>{(async()=>{a(!0);try{const c=await ce.stations.stationsList();o(c.data)}catch(c){console.error("Error fetching stations:",c)}finally{a(!1)}})()},[]);const l=async u=>{t(!1),console.log(u);try{const c=await ce.measurements.measurementsCreate(u);console.log("Измерение успешно создано:",c.data),t(!0)}catch(c){console.error("Ошибка при создании измерения:",c)}};return f.jsxs("div",{className:"container mt-5",children:[f.jsx("h1",{children:"Добавить показания"}),e&&f.jsx("div",{className:"alert alert-success",role:"alert",children:"Показания добавлены."}),f.jsxs("form",{onSubmit:r(l),children:[f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"weather_station",className:"form-label",children:"Выберите станцию:"}),f.jsx("select",{className:"form-select",...n("weather_station"),id:"weather_station",children:i.map(u=>f.jsx("option",{value:u.station_id,children:u.name},u.id))})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"temperature",className:"form-label",children:"Температура:"}),f.jsx("input",{type:"number",className:"form-control",...n("temperature",{min:-100,max:100}),id:"temperature",step:"0.01",placeholder:"0.00"})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"humidity",className:"form-label",children:"Влажность:"}),f.jsx("input",{type:"number",className:"form-control",...n("humidity",{min:0,max:100}),id:"humidity",step:"0.01",placeholder:"0.00"})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"wind_speed",className:"form-label",children:"Скорость ветра:"}),f.jsx("input",{type:"number",className:"form-control",...n("wind_speed",{min:0,max:200}),id:"wind_speed",step:"0.01",placeholder:"0.00"})]}),f.jsx("button",{type:"submit",className:"btn btn-primary",disabled:s,children:"Сохранить и добавить"})]})]})},FC=({user:e,loading:t})=>{const[n,r]=k.useState(e.user_role),i=async()=>{await l("just_user")},o=async()=>{await l("meteorologist")},s=async()=>{await l("r_manager")},a=async()=>{await l("r_admin")},l=async u=>{try{await ce.updateUserRole.updateUserRoleCreate(e.user_id.toString(),{role:u}),r(u)}catch(c){console.error("Ошибка при сохранении изменений:",c)}};return f.jsxs("div",{className:"userRow",children:[f.jsxs("div",{className:"d-flex align-items-center",children:[f.jsx("span",{className:"me-2",children:e.name}),f.jsx("span",{children:e.email})]}),f.jsxs("div",{className:"d-flex align-items-center mt-2",children:[f.jsx(pr,{variant:"success",disabled:t||n==="just_user",onClick:i,className:"me-2",children:t?f.jsx(mr,{animation:"border",size:"sm"}):"Пользователь"}),f.jsx(pr,{variant:"success",disabled:t||n==="meteorologist",onClick:o,className:"me-2",children:t?f.jsx(mr,{animation:"border",size:"sm"}):"Метеоролог"}),f.jsx(pr,{variant:"success",disabled:t||n==="r_manager",onClick:s,className:"me-2",children:t?f.jsx(mr,{animation:"border",size:"sm"}):"Менеджер"}),f.jsx(pr,{variant:"danger",disabled:t||n==="r_admin",onClick:a,children:t?f.jsx(mr,{animation:"border",size:"sm"}):"Админ"})]}),f.jsx("hr",{})]},e.user_id)},AC=()=>{const e=zn(),[t,n]=k.useState([]),[r,i]=k.useState(""),[o,s]=k.useState(!1),a=async()=>{s(!0);try{const u=await ce.users.usersList();n(u.data)}catch(u){console.error("Ошибка при получении пользователей:",u)}finally{s(!1)}};k.useEffect(()=>{a()},[]);const l=()=>{};return f.jsxs("div",{className:"container mt-5",children:[e&&e.role=="Админ"&&f.jsxs("div",{children:[f.jsx("h2",{children:"Роли пользователей"}),f.jsxs("div",{className:"inputField d-flex justify-content-center mt-3",children:[f.jsx("input",{value:r,onChange:u=>i(u.target.value),className:"form-control me-3",placeholder:"Введите значение для поиска"}),f.jsx(pr,{disabled:o,onClick:l,className:"btn btn-primary me-3",children:"Искать"}),o&&f.jsx("div",{className:"loadingBg",children:f.jsx(mr,{animation:"border"})})]}),f.jsx("div",{className:"mt-4",children:t.map(u=>f.jsx(FC,{user:u,loading:o},u.user_id))})]}),(!e||e.role!=="Админ")&&f.jsx("div",{className:"warningDiv",children:f.jsx("p",{className:"text-danger",children:"Вы не админ"})})]})},IC=()=>{const[e,t]=k.useState(!1),{register:n,handleSubmit:r}=Td(),[i,o]=k.useState(!1),s=async a=>{o(!0),t(!1),console.log(a);try{const l=await ce.stations.stationsCreate(a);console.log("Станция успешно создана:",l.data),t(!0)}catch(l){console.error("Ошибка при создании станции:",l)}finally{o(!1)}};return f.jsxs("div",{className:"container mt-5",children:[f.jsx("h1",{children:"Добавить новую Станцию"}),e&&f.jsx("div",{className:"alert alert-success",role:"alert",children:"Станция добавлена."}),f.jsxs("form",{onSubmit:r(s),children:[f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"name",className:"form-label",children:"Название станции:"}),f.jsx("input",{type:"text",className:"form-control",...n("name"),id:"name"})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"location",className:"form-label",children:"Местоположение:"}),f.jsx("input",{type:"text",className:"form-control",...n("location"),id:"location"})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"open_date",className:"form-label",children:"Дата открытия:"}),f.jsx("input",{type:"datetime-local",className:"form-control",...n("open_date"),id:"open_date"})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"description",className:"form-label",children:"Описание:"}),f.jsx("textarea",{className:"form-control",...n("description"),id:"description",rows:4})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"status",className:"form-label",children:"Статус:"}),f.jsxs("select",{className:"form-select",...n("status"),id:"status",children:[f.jsx("option",{value:"true",children:"Активная"}),f.jsx("option",{value:"false",children:"Неактивная"})]})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"image_url",className:"form-label",children:"URL изображения:"}),f.jsx("input",{type:"text",className:"form-control",...n("image_url"),id:"image_url"})]}),f.jsx("button",{type:"submit",className:"btn btn-primary",disabled:i,children:"Создать станцию"})]})]})},Gh=()=>{const e=Uo(),{orderId:t}=vd(),[n,r]=k.useState(null),[i,o]=k.useState(!1);k.useEffect(()=>{(async()=>{o(!0);try{const u=await ce.orders.ordersRead(t.toString());r(u.data)}catch(u){console.error("Error fetching order information:",u)}finally{o(!1)}})()},[t]);const s=async()=>{o(!0);try{await ce.orders.ordersFormatPartialUpdate(n.order.order_id.toString()),e(pi.flush());const l=await ce.orders.ordersRead(n.order.order_id.toString());r(l.data)}catch(l){console.error("Error processing payment:",l)}finally{o(!1)}},a=async()=>{o(!0);try{await ce.orders.ordersDeletePartialUpdate(n.order.order_id.toString()),e(pi.flush());const l=await ce.orders.ordersRead(n.order.order_id.toString());r(l.data)}catch(l){console.error("Error processing delete:",l)}finally{o(!1)}};return i?f.jsx("div",{children:"Loading..."}):n?f.jsxs("div",{className:"container mt-5",children:[f.jsx("h1",{children:"Информация о заказе"}),f.jsxs("p",{children:["Статус: ",n==null?void 0:n.order.status]}),f.jsxs("p",{children:["Дата формирования: ",n!=null&&n.order.formation_date?new Date(n==null?void 0:n.order.formation_date).toLocaleString():"-"]}),f.jsxs("p",{children:["Дата выноса решения: ",n!=null&&n.order.completion_date?new Date(n==null?void 0:n.order.completion_date).toLocaleString():"-"]}),n.measurements.length>0&&f.jsx("h2",{children:"Заказанные показания"}),n==null?void 0:n.measurements.map(l=>f.jsxs("div",{children:[f.jsxs("p",{children:["Дата снятия: ",new Date(l.created_date).toLocaleString()]}),n.order.status==="completed"&&f.jsxs("div",{children:[f.jsxs("p",{children:["Температура: ",l.temperature," по Цельсию"]}),f.jsxs("p",{children:["Влажность: ",l.humidity,"%"]}),f.jsxs("p",{children:["Скорость ветра: ",l.wind_speed," м/с"]})]}),f.jsx("hr",{})]})),(n==null?void 0:n.order.status)==="draft"&&f.jsxs("div",{className:"mt-4",children:[f.jsx("button",{className:"btn btn-success ms-2",onClick:s,disabled:i,children:"Оплатить"}),f.jsx("button",{className:"btn btn-danger ms-2",onClick:a,disabled:i,children:"Удалить"})]})]}):f.jsx("div",{children:"Заказ не найден"})},UC=({order:e})=>{const t=n=>{switch(n){case"completed":return"green";case"formed":case"draft":return"yellow";case"rejected":case"deleted":return"red";default:return"black"}};return f.jsx("div",{className:"card my-3",children:f.jsxs("div",{className:"card-body",children:[f.jsxs("h5",{className:"card-title",children:["Информация о заказе #",e.order.order_id]}),f.jsxs("p",{className:"card-text",style:{color:t(e.order.status.toString())},children:["Статус: ",e.order.status]}),f.jsxs("p",{className:"card-text",children:["Дата создания: ",new Date(e.order.formation_date.toString()).toLocaleString()]}),f.jsx("a",{href:`/profile/orders/${e.order.order_id}`,className:"btn btn-primary",children:"Подробнее"})]})})},zC=()=>{const[e,t]=k.useState([]),[n,r]=k.useState(!0);return k.useEffect(()=>{(async()=>{r(!0);try{const o=await ce.userorders.userordersList();console.log(o.data),t(o.data)}catch(o){console.error("Error fetching orders:",o)}finally{r(!1)}})()},[]),f.jsxs("div",{className:"container mt-5",children:[!n&&!e.length&&f.jsx("div",{children:f.jsx("h1",{children:"К сожалению, пока ничего не найдено :("})}),f.jsx(Sd,{xs:4,ms:4,className:"g-10",children:e.map((i,o)=>f.jsx(pa,{children:f.jsx(UC,{order:i})},o))})]})},$C=({order:e,onApprove:t,onReject:n})=>f.jsxs("div",{className:"row mb-3",children:[f.jsxs("div",{className:"col-md-6",children:[f.jsxs("h4",{children:["Заказ №",e.order_id]}),f.jsxs("p",{children:["Статус: ",e.status]})]}),f.jsx("div",{className:"col-md-6",children:f.jsxs("div",{className:"d-flex justify-content-end",children:[f.jsx("button",{className:"btn btn-success me-2",onClick:()=>t(),disabled:e.status!=="formed",children:"Одобрить"}),f.jsx("button",{className:"btn btn-danger me-2",onClick:()=>n(),disabled:e.status!=="formed",children:"Отклонить"}),f.jsx("a",{href:`/RIP-WeStatsApp/profile/orders/${e.order_id}`,className:"btn btn-primary ms-2",children:"Детали"})]})})]}),BC=()=>{const[e,t]=k.useState([]),[n,r]=k.useState("all"),[i,o]=k.useState(!0),s=async()=>{try{o(!0);const c=await ce.orders.ordersList();t(c.data)}catch(c){console.error("Error fetching orders:",c)}finally{o(!1)}};k.useEffect(()=>{s()},[]);const a=e.filter(c=>n==="all"?c.status==="formed"||c.status==="rejected"||c.status==="completed":n==="awaiting_approval"?c.status==="formed":n==="rejected"?c.status==="rejected":n==="approved"?c.status==="completed":!1),l=async c=>{try{console.log(`Order ${c} approved`),await ce.orders.ordersAcceptPartialUpdate(c.toString()),t(d=>d.map(h=>h.order_id===c?{...h,status:"completed"}:h))}catch(d){console.error("Error processing approval:",d)}},u=async c=>{try{console.log(`Order ${c} rejected`),await ce.orders.ordersRejectPartialUpdate(c.toString()),t(d=>d.map(h=>h.order_id===c?{...h,status:"rejected"}:h))}catch(d){console.error("Error processing rejection:",d)}};return f.jsxs("div",{className:"container mt-5",children:[f.jsx("h1",{children:"Управление заказами"}),f.jsx("div",{className:"btn-group my-3",role:"group","aria-label":"Order Categories",children:f.jsxs("div",{className:"btn-group",role:"group","aria-label":"Order Categories",children:[f.jsx("button",{type:"button",className:`btn ${n==="all"?"btn-primary":"btn-secondary"}`,onClick:()=>r("all"),children:"Все"}),f.jsx("button",{type:"button",className:`btn ${n==="awaiting_approval"?"btn-primary":"btn-secondary"}`,onClick:()=>r("awaiting_approval"),children:"Ожидают подтверждения"}),f.jsx("button",{type:"button",className:`btn ${n==="rejected"?"btn-primary":"btn-secondary"}`,onClick:()=>r("rejected"),children:"Отклоненные"}),f.jsx("button",{type:"button",className:`btn ${n==="approved"?"btn-primary":"btn-secondary"}`,onClick:()=>r("approved"),children:"Одобренные"})]})}),i?f.jsx("p",{children:"Loading..."}):a.length>0?a.map(c=>f.jsx($C,{order:c,onApprove:()=>l(c.order_id),onReject:()=>u(c.order_id)},c.order_id)):f.jsx("p",{children:"No orders to display"})]})},WC=({measurement:e,stations:t})=>{var u,c;const n=zn(),r=iv(),i=new Date(e.created_date).toLocaleString(),o=Uo(),s=(u=r.cart)==null?void 0:u.some(d=>d.measurement_id===e.measurement_id),a=(c=t.find(d=>d.station_id===e.weather_station))==null?void 0:c.name,l=async()=>{var d;try{await ce.orders.ordersAddItemCreate(r.orderInfo.order_id.toString(),{measurement_id:(d=e.measurement_id)==null?void 0:d.toString()})}catch{console.log("Unable to add")}o(pi.addToCart(e))};return f.jsxs("tr",{children:[f.jsx("td",{children:a}),f.jsx("td",{children:i}),f.jsxs("td",{children:[(n==null?void 0:n.role)==="just_user"&&r.orderInfo&&!s&&f.jsx("button",{className:"btn btn-success",onClick:l,children:"Добавить"}),(n==null?void 0:n.role)==="just_user"&&r.orderInfo&&s&&f.jsx("span",{children:"Добавлено"}),(n==null?void 0:n.role)==="just_user"&&!r.orderInfo&&f.jsx("a",{href:"/profile",className:"btn btn-primary",children:"Новый заказ"})]})]})},VC=()=>{const[e,t]=k.useState(!0),[n,r]=k.useState([]),[i,o]=k.useState([]),s=async()=>{try{t(!0);const l=await ce.stations.stationsList();o(l.data)}catch(l){console.error("Ошибка при получении станций:",l)}finally{t(!1)}},a=async()=>{try{t(!0);const l=await ce.measurements.measurementsList();r(l.data)}catch(l){console.error("Error fetching measurements:",l)}finally{t(!1)}};return k.useEffect(()=>{a(),s()},[]),e?f.jsx("div",{children:"Loading..."}):f.jsxs("div",{className:"container mt-5",children:[f.jsx("h1",{children:"Измерения"}),f.jsxs(Fg,{striped:!0,bordered:!0,hover:!0,children:[f.jsx("thead",{children:f.jsxs("tr",{children:[f.jsx("th",{children:"Станция"}),f.jsx("th",{children:"Дата снятия"})]})}),f.jsx("tbody",{children:n.map(l=>f.jsx(WC,{measurement:l,stations:i},l.measurement_id))})]})]})};function dn(e){const t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function Pr(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}const hv=6048e5,HC=864e5,pv=6e4,mv=36e5;let qC={};function Ga(){return qC}function No(e,t){var a,l,u,c;const n=Ga(),r=(t==null?void 0:t.weekStartsOn)??((l=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:l.weekStartsOn)??n.weekStartsOn??((c=(u=n.locale)==null?void 0:u.options)==null?void 0:c.weekStartsOn)??0,i=dn(e),o=i.getDay(),s=(o=i.getTime()?n+1:t.getTime()>=s.getTime()?n:n-1}function Xh(e){const t=dn(e);return t.setHours(0,0,0,0),t}function Jh(e){const t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),e.getTime()-t.getTime()}function YC(e,t){const n=Xh(e),r=Xh(t),i=+n-Jh(n),o=+r-Jh(r);return Math.trunc((i-o)/HC)}function QC(e){const t=yv(e),n=Pr(e,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),Sa(n)}function KC(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function GC(e){if(!KC(e)&&typeof e!="number")return!1;const t=dn(e);return!isNaN(Number(t))}function XC(e){const t=dn(e),n=Pr(e,0);return n.setFullYear(t.getFullYear(),0,1),n.setHours(0,0,0,0),n}const JC={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},ZC=(e,t,n)=>{let r;const i=JC[e];return typeof i=="string"?r=i:t===1?r=i.one:r=i.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function ql(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const ek={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},tk={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},nk={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},rk={date:ql({formats:ek,defaultWidth:"full"}),time:ql({formats:tk,defaultWidth:"full"}),dateTime:ql({formats:nk,defaultWidth:"full"})},ik={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},ok=(e,t,n,r)=>ik[e];function Ii(e){return(t,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let i;if(r==="formatting"&&e.formattingValues){const s=e.defaultFormattingWidth||e.defaultWidth,a=n!=null&&n.width?String(n.width):s;i=e.formattingValues[a]||e.formattingValues[s]}else{const s=e.defaultWidth,a=n!=null&&n.width?String(n.width):e.defaultWidth;i=e.values[a]||e.values[s]}const o=e.argumentCallback?e.argumentCallback(t):t;return i[o]}}const sk={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},ak={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},lk={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},uk={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},ck={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},dk={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},fk=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},hk={ordinalNumber:fk,era:Ii({values:sk,defaultWidth:"wide"}),quarter:Ii({values:ak,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Ii({values:lk,defaultWidth:"wide"}),day:Ii({values:uk,defaultWidth:"wide"}),dayPeriod:Ii({values:ck,defaultWidth:"wide",formattingValues:dk,defaultFormattingWidth:"wide"})};function Ui(e){return(t,n={})=>{const r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],o=t.match(i);if(!o)return null;const s=o[0],a=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(a)?mk(a,d=>d.test(s)):pk(a,d=>d.test(s));let u;u=e.valueCallback?e.valueCallback(l):l,u=n.valueCallback?n.valueCallback(u):u;const c=t.slice(s.length);return{value:u,rest:c}}}function pk(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function mk(e,t){for(let n=0;n{const r=t.match(e.matchPattern);if(!r)return null;const i=r[0],o=t.match(e.parsePattern);if(!o)return null;let s=e.valueCallback?e.valueCallback(o[0]):o[0];s=n.valueCallback?n.valueCallback(s):s;const a=t.slice(i.length);return{value:s,rest:a}}}const gk=/^(\d+)(th|st|nd|rd)?/i,vk=/\d+/i,wk={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Sk={any:[/^b/i,/^(a|c)/i]},xk={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Ek={any:[/1/i,/2/i,/3/i,/4/i]},_k={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Ck={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},kk={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Pk={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},jk={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Nk={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Rk={ordinalNumber:yk({matchPattern:gk,parsePattern:vk,valueCallback:e=>parseInt(e,10)}),era:Ui({matchPatterns:wk,defaultMatchWidth:"wide",parsePatterns:Sk,defaultParseWidth:"any"}),quarter:Ui({matchPatterns:xk,defaultMatchWidth:"wide",parsePatterns:Ek,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Ui({matchPatterns:_k,defaultMatchWidth:"wide",parsePatterns:Ck,defaultParseWidth:"any"}),day:Ui({matchPatterns:kk,defaultMatchWidth:"wide",parsePatterns:Pk,defaultParseWidth:"any"}),dayPeriod:Ui({matchPatterns:jk,defaultMatchWidth:"any",parsePatterns:Nk,defaultParseWidth:"any"})},Ok={code:"en-US",formatDistance:ZC,formatLong:rk,formatRelative:ok,localize:hk,match:Rk,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Tk(e){const t=dn(e);return YC(t,XC(t))+1}function Dk(e){const t=dn(e),n=+Sa(t)-+QC(t);return Math.trunc(n/hv)+1}function gv(e,t){var c,d,h,w;const n=dn(e),r=n.getFullYear(),i=Ga(),o=(t==null?void 0:t.firstWeekContainsDate)??((d=(c=t==null?void 0:t.locale)==null?void 0:c.options)==null?void 0:d.firstWeekContainsDate)??i.firstWeekContainsDate??((w=(h=i.locale)==null?void 0:h.options)==null?void 0:w.firstWeekContainsDate)??1,s=Pr(e,0);s.setFullYear(r+1,0,o),s.setHours(0,0,0,0);const a=No(s,t),l=Pr(e,0);l.setFullYear(r,0,o),l.setHours(0,0,0,0);const u=No(l,t);return n.getTime()>=a.getTime()?r+1:n.getTime()>=u.getTime()?r:r-1}function bk(e,t){var a,l,u,c;const n=Ga(),r=(t==null?void 0:t.firstWeekContainsDate)??((l=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:l.firstWeekContainsDate)??n.firstWeekContainsDate??((c=(u=n.locale)==null?void 0:u.options)==null?void 0:c.firstWeekContainsDate)??1,i=gv(e,t),o=Pr(e,0);return o.setFullYear(i,0,r),o.setHours(0,0,0,0),No(o,t)}function Lk(e,t){const n=dn(e),r=+No(n,t)-+bk(n,t);return Math.trunc(r/hv)+1}function fe(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const Dn={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return fe(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):fe(n+1,2)},d(e,t){return fe(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return fe(e.getHours()%12||12,t.length)},H(e,t){return fe(e.getHours(),t.length)},m(e,t){return fe(e.getMinutes(),t.length)},s(e,t){return fe(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),i=Math.trunc(r*Math.pow(10,n-3));return fe(i,t.length)}},Ir={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Zh={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),i=r>0?r:1-r;return n.ordinalNumber(i,{unit:"year"})}return Dn.y(e,t)},Y:function(e,t,n,r){const i=gv(e,r),o=i>0?i:1-i;if(t==="YY"){const s=o%100;return fe(s,2)}return t==="Yo"?n.ordinalNumber(o,{unit:"year"}):fe(o,t.length)},R:function(e,t){const n=yv(e);return fe(n,t.length)},u:function(e,t){const n=e.getFullYear();return fe(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return fe(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return fe(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return Dn.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return fe(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const i=Lk(e,r);return t==="wo"?n.ordinalNumber(i,{unit:"week"}):fe(i,t.length)},I:function(e,t,n){const r=Dk(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):fe(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):Dn.d(e,t)},D:function(e,t,n){const r=Tk(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):fe(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const i=e.getDay(),o=(i-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(o);case"ee":return fe(o,2);case"eo":return n.ordinalNumber(o,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});case"eeee":default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const i=e.getDay(),o=(i-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(o);case"cc":return fe(o,t.length);case"co":return n.ordinalNumber(o,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});case"cccc":default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),i=r===0?7:r;switch(t){case"i":return String(i);case"ii":return fe(i,t.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const i=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let i;switch(r===12?i=Ir.noon:r===0?i=Ir.midnight:i=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let i;switch(r>=17?i=Ir.evening:r>=12?i=Ir.afternoon:r>=4?i=Ir.morning:i=Ir.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return Dn.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):Dn.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):fe(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):fe(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):Dn.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):Dn.s(e,t)},S:function(e,t){return Dn.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return tp(r);case"XXXX":case"XX":return lr(r);case"XXXXX":case"XXX":default:return lr(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return tp(r);case"xxxx":case"xx":return lr(r);case"xxxxx":case"xxx":default:return lr(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+ep(r,":");case"OOOO":default:return"GMT"+lr(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+ep(r,":");case"zzzz":default:return"GMT"+lr(r,":")}},t:function(e,t,n){const r=Math.trunc(e.getTime()/1e3);return fe(r,t.length)},T:function(e,t,n){const r=e.getTime();return fe(r,t.length)}};function ep(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),i=Math.trunc(r/60),o=r%60;return o===0?n+String(i):n+String(i)+t+fe(o,2)}function tp(e,t){return e%60===0?(e>0?"-":"+")+fe(Math.abs(e)/60,2):lr(e,t)}function lr(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),i=fe(Math.trunc(r/60),2),o=fe(r%60,2);return n+i+t+o}const np=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},vv=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},Mk=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return np(e,t);let o;switch(r){case"P":o=t.dateTime({width:"short"});break;case"PP":o=t.dateTime({width:"medium"});break;case"PPP":o=t.dateTime({width:"long"});break;case"PPPP":default:o=t.dateTime({width:"full"});break}return o.replace("{{date}}",np(r,t)).replace("{{time}}",vv(i,t))},Fk={p:vv,P:Mk},Ak=/^D+$/,Ik=/^Y+$/,Uk=["D","DD","YY","YYYY"];function zk(e){return Ak.test(e)}function $k(e){return Ik.test(e)}function Bk(e,t,n){const r=Wk(e,t,n);if(console.warn(r),Uk.includes(e))throw new RangeError(r)}function Wk(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Vk=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Hk=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,qk=/^'([^]*?)'?$/,Yk=/''/g,Qk=/[a-zA-Z]/;function Kk(e,t,n){var c,d,h,w,g,v,E,m;const r=Ga(),i=(n==null?void 0:n.locale)??r.locale??Ok,o=(n==null?void 0:n.firstWeekContainsDate)??((d=(c=n==null?void 0:n.locale)==null?void 0:c.options)==null?void 0:d.firstWeekContainsDate)??r.firstWeekContainsDate??((w=(h=r.locale)==null?void 0:h.options)==null?void 0:w.firstWeekContainsDate)??1,s=(n==null?void 0:n.weekStartsOn)??((v=(g=n==null?void 0:n.locale)==null?void 0:g.options)==null?void 0:v.weekStartsOn)??r.weekStartsOn??((m=(E=r.locale)==null?void 0:E.options)==null?void 0:m.weekStartsOn)??0,a=dn(e);if(!GC(a))throw new RangeError("Invalid time value");let l=t.match(Hk).map(p=>{const y=p[0];if(y==="p"||y==="P"){const C=Fk[y];return C(p,i.formatLong)}return p}).join("").match(Vk).map(p=>{if(p==="''")return{isToken:!1,value:"'"};const y=p[0];if(y==="'")return{isToken:!1,value:Gk(p)};if(Zh[y])return{isToken:!0,value:p};if(y.match(Qk))throw new RangeError("Format string contains an unescaped latin alphabet character `"+y+"`");return{isToken:!1,value:p}});i.localize.preprocessor&&(l=i.localize.preprocessor(a,l));const u={firstWeekContainsDate:o,weekStartsOn:s,locale:i};return l.map(p=>{if(!p.isToken)return p.value;const y=p.value;(!(n!=null&&n.useAdditionalWeekYearTokens)&&$k(y)||!(n!=null&&n.useAdditionalDayOfYearTokens)&&zk(y))&&Bk(y,t,String(e));const C=Zh[y[0]];return C(a,y,i.localize,u)}).join("")}function Gk(e){const t=e.match(qk);return t?t[1].replace(Yk,"'"):e}function Xk(e,t){const n=(t==null?void 0:t.additionalDigits)??2,r=tP(e);let i;if(r.date){const l=nP(r.date,n);i=rP(l.restDateString,l.year)}if(!i||isNaN(i.getTime()))return new Date(NaN);const o=i.getTime();let s=0,a;if(r.time&&(s=iP(r.time),isNaN(s)))return new Date(NaN);if(r.timezone){if(a=oP(r.timezone),isNaN(a))return new Date(NaN)}else{const l=new Date(o+s),u=new Date(0);return u.setFullYear(l.getUTCFullYear(),l.getUTCMonth(),l.getUTCDate()),u.setHours(l.getUTCHours(),l.getUTCMinutes(),l.getUTCSeconds(),l.getUTCMilliseconds()),u}return new Date(o+s+a)}const ys={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},Jk=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,Zk=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,eP=/^([+-])(\d{2})(?::?(\d{2}))?$/;function tP(e){const t={},n=e.split(ys.dateTimeDelimiter);let r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],ys.timeZoneDelimiter.test(t.date)&&(t.date=e.split(ys.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){const i=ys.timezone.exec(r);i?(t.time=r.replace(i[1],""),t.timezone=i[1]):t.time=r}return t}function nP(e,t){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),r=e.match(n);if(!r)return{year:NaN,restDateString:""};const i=r[1]?parseInt(r[1]):null,o=r[2]?parseInt(r[2]):null;return{year:o===null?i:o*100,restDateString:e.slice((r[1]||r[2]).length)}}function rP(e,t){if(t===null)return new Date(NaN);const n=e.match(Jk);if(!n)return new Date(NaN);const r=!!n[4],i=zi(n[1]),o=zi(n[2])-1,s=zi(n[3]),a=zi(n[4]),l=zi(n[5])-1;if(r)return cP(t,a,l)?sP(t,a,l):new Date(NaN);{const u=new Date(0);return!lP(t,o,s)||!uP(t,i)?new Date(NaN):(u.setUTCFullYear(t,o,Math.max(i,s)),u)}}function zi(e){return e?parseInt(e):1}function iP(e){const t=e.match(Zk);if(!t)return NaN;const n=Yl(t[1]),r=Yl(t[2]),i=Yl(t[3]);return dP(n,r,i)?n*mv+r*pv+i*1e3:NaN}function Yl(e){return e&&parseFloat(e.replace(",","."))||0}function oP(e){if(e==="Z")return 0;const t=e.match(eP);if(!t)return 0;const n=t[1]==="+"?-1:1,r=parseInt(t[2]),i=t[3]&&parseInt(t[3])||0;return fP(r,i)?n*(r*mv+i*pv):NaN}function sP(e,t,n){const r=new Date(0);r.setUTCFullYear(e,0,4);const i=r.getUTCDay()||7,o=(t-1)*7+n+1-i;return r.setUTCDate(r.getUTCDate()+o),r}const aP=[31,null,31,30,31,30,31,31,30,31,30,31];function wv(e){return e%400===0||e%4===0&&e%100!==0}function lP(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(aP[t]||(wv(e)?29:28))}function uP(e,t){return t>=1&&t<=(wv(e)?366:365)}function cP(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function dP(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function fP(e,t){return t>=0&&t<=59}const hP=()=>{const[e,t]=k.useState(!1),{register:n,handleSubmit:r,setValue:i}=Td(),[o,s]=k.useState(!1),{stationId:a}=vd();k.useEffect(()=>{(async()=>{if(a)try{const d=await ce.stations.stationsRead(a);i("name",d.data.name),i("location",d.data.location);const h=Xk(d.data.open_date),w=Kk(h,"yyyy-MM-dd'T'HH:mm");i("open_date",w),i("description",d.data.description),i("status",d.data.status.toString()),i("image_url",d.data.image_url)}catch(d){console.error("Ошибка при загрузке данных станции для редактирования:",d)}})()},[a,i]);const l=async c=>{s(!0),t(!1);try{const d=await ce.stations.stationsUpdate(a,c);console.log("Станция успешно обновлена:",d.data),t(!0)}catch(d){console.error("Ошибка при обновлении станции:",d)}finally{s(!1)}},u=async()=>{if(window.confirm("Вы уверены, что хотите удалить станцию?"))try{await ce.stations.stationsDelete(a),console.log("Станция успешно удалена")}catch(c){console.error("Ошибка при удалении станции:",c)}};return f.jsxs("div",{className:"container mt-5",children:[f.jsx("h1",{children:"Редактировать данные Станции"}),e&&f.jsx("div",{className:"alert alert-success",role:"alert",children:"Станция обновлена."}),f.jsxs("form",{onSubmit:r(l),children:[f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"name",className:"form-label",children:"Название станции:"}),f.jsx("input",{type:"text",className:"form-control",...n("name"),id:"name"})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"location",className:"form-label",children:"Местоположение:"}),f.jsx("input",{type:"text",className:"form-control",...n("location"),id:"location"})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"open_date",className:"form-label",children:"Дата открытия:"}),f.jsx("input",{type:"datetime-local",className:"form-control",...n("open_date"),id:"open_date"})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"description",className:"form-label",children:"Описание:"}),f.jsx("textarea",{className:"form-control",...n("description"),id:"description",rows:4})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"status",className:"form-label",children:"Статус:"}),f.jsxs("select",{className:"form-select",...n("status"),id:"status",children:[f.jsx("option",{value:"true",children:"Активная"}),f.jsx("option",{value:"false",children:"Неактивная"})]})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"image_url",className:"form-label",children:"URL изображения:"}),f.jsx("input",{type:"text",className:"form-control",...n("image_url"),id:"image_url"})]}),f.jsx("button",{type:"submit",className:"btn btn-primary",disabled:o,children:"Обновить станцию"}),f.jsx("button",{type:"button",className:"btn btn-danger ms-2",onClick:u,disabled:o,children:"Удалить станцию"})]})]})},pP=({measurement:e,stations:t})=>{const n=t.find(d=>d.station_id===e.weather_station),r=n==null?void 0:n.name,i=n==null?void 0:n.location,o=new Date(e.created_date).toLocaleString(),{measurement_id:s,temperature:a,humidity:l,wind_speed:u}=e,c=async()=>{try{await ce.measurements.measurementsDelete(s.toString())}catch{console.log("Unable to delete measure")}};return f.jsxs("tr",{children:[f.jsx("td",{children:r}),f.jsx("td",{children:i}),f.jsx("td",{children:o}),f.jsx("td",{children:a}),f.jsx("td",{children:l}),f.jsx("td",{children:u}),f.jsx("td",{children:f.jsx(pr,{onClick:c,children:"Удалить"})})]})},mP=()=>{const[e,t]=k.useState(!0),[n,r]=k.useState([]),[i,o]=k.useState([]),s=async()=>{try{t(!0);const l=await ce.stations.stationsList();o(l.data)}catch(l){console.error("Ошибка при получении станций:",l)}finally{t(!1)}},a=async()=>{try{t(!0);const l=await ce.measurements.measurementsList();r(l.data)}catch(l){console.error("Error fetching measurements:",l)}finally{t(!1)}};return k.useEffect(()=>{a(),s()},[]),e?f.jsx("div",{children:"Loading..."}):f.jsxs("div",{className:"container mt-5",children:[f.jsx("h1",{children:"Измерения"}),f.jsxs(Fg,{striped:!0,bordered:!0,hover:!0,children:[f.jsx("thead",{children:f.jsxs("tr",{children:[f.jsx("th",{children:"Станция"}),f.jsx("th",{children:"Город"}),f.jsx("th",{children:"Дата снятия"}),f.jsx("td",{children:"Температура"}),f.jsx("td",{children:"Влажность"}),f.jsx("td",{children:"Скорость ветра"})]})}),f.jsx("tbody",{children:n.map(l=>f.jsx(pP,{measurement:l,stations:i},l.measurement_id))})]})]})},yP=()=>{const e=gd(),[t,n]=k.useState(""),[r,i]=k.useState(""),[o,s]=k.useState(!1),[a,l]=k.useState(!1),u=async()=>{s(!1),l(!1);try{const c=await ce.users.usersCreate({email:t,password:r});console.log(c.status),c.status===200?(l(!0),e("/RIP-WeStatsApp/login")):s(!0)}catch(c){console.error("Ошибка при регистрации:",c),s(!0)}};return f.jsxs("div",{className:"mt-4",children:[f.jsx("h2",{className:"mb-4",children:"Регистрация"}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"email",className:"form-label",children:"Email:"}),f.jsx("input",{type:"email",id:"email",className:"form-control",value:t,onChange:c=>n(c.target.value)})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"password",className:"form-label",children:"Пароль:"}),f.jsx("input",{type:"password",id:"password",className:"form-control",value:r,onChange:c=>i(c.target.value)})]}),f.jsx("button",{type:"submit",onClick:u,className:"btn btn-primary",children:"Зарегистрирваться"}),o&&f.jsx("div",{style:{color:"red"},children:"Неверные данные"}),a&&f.jsx("div",{style:{color:"green"},children:"Успешно!"})]})},nt="/RIP-WeStatsApp",gP=aE([{path:nt+"/",element:f.jsx(ps,{})},{path:nt+"/stations",element:f.jsx(iC,{})},{path:nt+"/stations/:stationId",element:f.jsx(sC,{})},{path:nt+"/measurements",element:f.jsx(VC,{})},{path:nt+"/login",element:f.jsx(lC,{})},{path:nt+"/signup",element:f.jsx(yP,{})},{path:nt+"/profile",element:f.jsx(mC,{})},{path:nt+"/profile/orders",element:f.jsx(zC,{})},{path:nt+"/profile/orders/current",element:f.jsx(Gh,{})},{path:nt+"/profile/orders/:orderId",element:f.jsx(Gh,{})},{path:nt+"/uploadmeasure",element:f.jsx(MC,{})},{path:nt+"/admin/perms",element:f.jsx(AC,{})},{path:nt+"/admin/orders",element:f.jsx(BC,{})},{path:nt+"/admin/addstation",element:f.jsx(IC,{})},{path:nt+"/admin/editstation/:stationId",element:f.jsx(hP,{})},{path:nt+"/admin/editmeasurements",element:f.jsx(mP,{})},{path:"/a",element:f.jsx(ps,{})},{path:"b",element:f.jsx(ps,{})},{path:"/c/",element:f.jsx(ps,{})}]),vP=()=>f.jsxs("div",{children:[f.jsx(ex,{}),f.jsx("hr",{}),f.jsx(yE,{router:gP}),f.jsx(aC,{})]});Kl.createRoot(document.getElementById("root")).render(f.jsx(pt.StrictMode,{children:f.jsx(g1,{store:Ky,children:f.jsx(_y,{loading:null,persistor:ZS,children:f.jsx("div",{className:"w-100",children:f.jsx(vP,{})})})})})); + */class nC extends tC{constructor(){super(...arguments);Qe(this,"login",{loginCreate:(n,r={})=>this.request({path:"/login",method:"POST",body:n,secure:!0,type:"application/json",...r})});Qe(this,"logout",{logoutCreate:(n={})=>this.request({path:"/logout",method:"POST",secure:!0,...n})});Qe(this,"measurements",{measurementsList:(n={})=>this.request({path:"/measurements",method:"GET",secure:!0,format:"json",...n}),measurementsCreate:(n,r={})=>this.request({path:"/measurements",method:"POST",body:n,secure:!0,format:"json",...r}),measurementsRead:(n,r={})=>this.request({path:`/measurements/${n}`,method:"GET",secure:!0,format:"json",...r}),measurementsUpdate:(n,r,i={})=>this.request({path:`/measurements/${n}`,method:"PUT",body:r,secure:!0,format:"json",...i}),measurementsDelete:(n,r={})=>this.request({path:`/measurements/${n}`,method:"DELETE",secure:!0,format:"json",...r})});Qe(this,"orders",{ordersList:(n={})=>this.request({path:"/orders",method:"GET",secure:!0,format:"json",...n}),ordersCreate:(n={})=>this.request({path:"/orders",method:"POST",secure:!0,format:"json",...n}),ordersRead:(n,r={})=>this.request({path:`/orders/${n}`,method:"GET",secure:!0,format:"json",...r}),ordersAcceptPartialUpdate:(n,r={})=>this.request({path:`/orders/${n}/accept`,method:"PATCH",secure:!0,format:"json",...r}),ordersAddItemCreate:(n,r,i={})=>this.request({path:`/orders/${n}/addItem`,method:"POST",body:r,secure:!0,type:"application/json",format:"json",...i}),ordersDeletePartialUpdate:(n,r={})=>this.request({path:`/orders/${n}/delete`,method:"PATCH",secure:!0,format:"json",...r}),ordersFormatPartialUpdate:(n,r={})=>this.request({path:`/orders/${n}/format`,method:"PATCH",secure:!0,format:"json",...r}),ordersRejectPartialUpdate:(n,r={})=>this.request({path:`/orders/${n}/reject`,method:"PATCH",secure:!0,format:"json",...r})});Qe(this,"profile",{profileList:(n={})=>this.request({path:"/profile",method:"GET",secure:!0,format:"json",...n})});Qe(this,"stations",{stationsList:(n,r={})=>this.request({path:"/stations",method:"GET",query:n,secure:!0,type:"application/x-www-form-urlencoded",format:"json",...r}),stationsCreate:(n,r={})=>this.request({path:"/stations",method:"POST",body:n,secure:!0,type:"multipart/form-data",format:"json",...r}),stationsRead:(n,r={})=>this.request({path:`/stations/${n}`,method:"GET",secure:!0,type:"application/x-www-form-urlencoded",format:"json",...r}),stationsUpdate:(n,r,i={})=>this.request({path:`/stations/${n}`,method:"PUT",body:r,secure:!0,type:"multipart/form-data",format:"json",...i}),stationsDelete:(n,r={})=>this.request({path:`/stations/${n}`,method:"DELETE",secure:!0,type:"application/x-www-form-urlencoded",format:"json",...r})});Qe(this,"updateUserRole",{updateUserRoleCreate:(n,r,i={})=>this.request({path:`/update_user_role/${n}`,method:"POST",query:r,secure:!0,format:"json",...i})});Qe(this,"userorders",{userordersList:(n={})=>this.request({path:"/userorders",method:"GET",secure:!0,format:"json",...n}),userordersCurrentList:(n={})=>this.request({path:"/userorders/current",method:"GET",secure:!0,format:"json",...n})});Qe(this,"users",{usersList:(n={})=>this.request({path:"/users/",method:"GET",secure:!0,format:"json",...n}),usersCreate:(n,r={})=>this.request({path:"/users/",method:"POST",body:n,secure:!0,format:"json",...r}),usersRead:(n,r={})=>this.request({path:`/users/${n}/`,method:"GET",secure:!0,format:"json",...r}),usersUpdate:(n,r,i={})=>this.request({path:`/users/${n}/`,method:"PUT",body:r,secure:!0,format:"json",...i}),usersPartialUpdate:(n,r,i={})=>this.request({path:`/users/${n}/`,method:"PATCH",body:r,secure:!0,format:"json",...i}),usersDelete:(n,r={})=>this.request({path:`/users/${n}/`,method:"DELETE",secure:!0,...r})})}}const ce=new nC({baseURL:"http://localhost:8000",withCredentials:!0,xsrfCookieName:"session_id"}),rC=({station:e})=>{const t=zn();return f.jsx(Fl,{className:"station-card mt-3",children:f.jsxs(Fl.Body,{children:[f.jsx("div",{className:"textStyle",children:f.jsx(Fl.Title,{children:e.name})}),f.jsx("a",{href:`/RIP-WeStatsApp/stations/${e.station_id}`,className:"btn btn-primary",children:"Подробнее"}),t&&t.role==="Админ"&&f.jsx("a",{href:`/RIP-WeStatsApp/admin/editstation/${e.station_id}`,className:"btn btn-secondary my-2",children:"Изменить"})]})})},sc=[{station_id:1,name:"Метеостанция Москва",location:"Москва, Россия",open_date:"1998-05-15",description:"Основана в 1998 году в Москве. Осуществляет наблюдения за погодными условиями в столице России.",status:!1,image_url:"https://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Wetterstation01.jpeg/330px-Wetterstation01.jpeg"},{station_id:2,name:"Метеостанция Санкт-Петербург",location:"Санкт-Петербург, Россия",open_date:"2005-10-20",description:"Станция в Санкт-Петербурге начала свою работу в 2005 году. Служит для мониторинга климата в Северной столице.",status:!1,image_url:"https://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Wetterstation01.jpeg/330px-Wetterstation01.jpeg"},{station_id:3,name:"Метеостанция Екатеринбург",location:"Екатеринбург, Россия",open_date:"1997-08-12",description:"Екатеринбургская метеостанция работает с 1997 года. Служит для отслеживания климатических изменений на Урале.",status:!0,image_url:"https://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Wetterstation01.jpeg/330px-Wetterstation01.jpeg"},{station_id:4,name:"Метеостанция Нижний Новгород",location:"Нижний Новгород, Россия",open_date:"2000-03-25",description:"Станция в Нижнем Новгороде начала работу в 2000 году. Осуществляет мониторинг погоды в Волго-Вятском регионе.",status:!0,image_url:"https://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Wetterstation01.jpeg/330px-Wetterstation01.jpeg"},{station_id:5,name:"Метеостанция Красноярск",location:"Красноярск, Россия",open_date:"2012-11-08",description:"Красноярская метеостанция начала свою деятельность в 2012 году. Предназначена для мониторинга климата в Сибири.",status:!0,image_url:"https://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Wetterstation01.jpeg/330px-Wetterstation01.jpeg"},{station_id:6,name:"Метеостанция Владивосток",location:"Владивосток, Россия",open_date:"2019-06-30",description:"Метеостанция во Владивостоке начала работу в 2019 году. Обеспечивает наблюдение за погодными условиями на Дальнем Востоке.",status:!0,image_url:"https://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Wetterstation01.jpeg/330px-Wetterstation01.jpeg"}],iC=()=>{const[e,t]=k.useState(""),[n,r]=k.useState(!1),[i,o]=k.useState([]),s=async()=>{try{const{data:l}=await ce.stations.stationsList();o(l)}catch(l){console.error("Ошибка при получении станций:",l),o(sc)}finally{r(!1)}},a=async()=>{try{const l={filter:e},{data:u}=await ce.stations.stationsList(l);o(u)}catch(l){console.error("Ошибка при получении станций:",l),o(sc.filter(u=>u.name.includes(e)))}finally{r(!1)}};return k.useEffect(()=>{r(!0),s()},[]),f.jsxs("div",{className:`container ${n&&"containerLoading"}`,children:[f.jsxs("div",{className:"inputField d-flex justify-content-center mt-3",children:[f.jsx("input",{value:e,onChange:l=>t(l.target.value),className:"form-control me-3",placeholder:"Введите значение для поиска"}),f.jsx(pr,{disabled:n,onClick:a,className:"btn btn-primary me-3",children:"Искать"}),n&&f.jsx("div",{className:"loadingBg",children:f.jsx(mr,{animation:"border"})})]}),f.jsx("hr",{}),!i.length&&f.jsx("div",{children:f.jsx("h1",{children:"К сожалению, пока ничего не найдено :("})}),f.jsx(Sd,{xs:4,ms:4,className:"g-10",children:i.map((l,u)=>f.jsx(pa,{children:f.jsx(rC,{station:l})},u))})]})},oC=k.createContext({}),sC=()=>{const{stationId:e}=vd(),[t,n]=k.useState(!0),[r,i]=k.useState(!1),[o,s]=k.useState({});return k.useEffect(()=>{n(!0),(async()=>{try{if(e){const l=await ce.stations.stationsRead(e);s(l.data),i(!0)}}catch(l){console.error("Failed to fetch station data. Using mock.",l);const u=sc[Number(e)-1];console.log(u),u&&(s(u),i(!0)),i(!1)}finally{n(!1)}})()},[e]),f.jsxs("div",{children:[t&&f.jsx("div",{className:"loadingBg",children:f.jsx(mr,{animation:"border"})}),!t&&!r&&f.jsxs("div",{children:[f.jsx("h1",{children:"Не удалось загрузить запрашиваемые данные."}),f.jsx("a",{href:"/RIP-WeStatsApp/stations",className:"btn btn-primary me-3 mt-5",children:"Вернуться"})]}),!t&&r&&f.jsx(oC.Provider,{value:o,children:f.jsx(AE,{className:"mt-4 ",children:f.jsxs(Sd,{children:[f.jsx(pa,{md:6,children:o.image_url&&f.jsx("img",{src:o.image_url,alt:"Station",className:"img-fluid"})}),f.jsxs(pa,{md:6,children:[f.jsx("h2",{children:o.name}),f.jsx("p",{children:o.description}),f.jsxs("p",{children:["Местоположение: ",o.location]}),f.jsxs("p",{children:["Дата открытия: ",new Date(o.open_date).toLocaleString()]}),f.jsxs("p",{children:["Статус: ",o.status?"Работает":"Не работает"]}),f.jsx("div",{className:"d-flex justify-content-center",children:f.jsx("a",{href:"/RIP-WeStatsApp/stations",className:"btn btn-primary me-4",children:"Назад"})})]})]})})})]})},aC=()=>f.jsx("footer",{className:"bg-dark text-light p-3 mt-5",children:f.jsxs("div",{className:"container",children:[f.jsx("p",{className:"mb-0",children:"© 2024 WeStats"}),f.jsx("p",{className:"mb-0",children:"By Kostin Sergey IU5-55B"}),f.jsx("a",{href:"/RIP-WeStatsApp/",children:"Главная"})]})}),Uo=S1,lC=()=>{const e=Uo(),t=gd(),[n,r]=k.useState(""),[i,o]=k.useState(""),[s,a]=k.useState(!1),[l,u]=k.useState(!1),c=async()=>{a(!1),u(!1);try{const d=await ce.login.loginCreate({email:n,password:i});if(console.log(d.status),d.status===200){u(!0);try{const h=await ce.profile.profileList();e(Yy.setUserAuth(h.data));try{const w=await ce.userorders.userordersCurrentList();w.data?e(pi.setCurrentOrder({orderInfo:w.data.order,cart:w.data.measurements})):e(pi.flush())}catch(w){console.error("Ошибка загрузки заказа",w)}t("/RIP-WeStatsApp/profile")}catch(h){console.error("Ошибка загрузки профиля",h)}}else a(!0)}catch(d){console.error("Ошибка при входе:",d),a(!0)}};return f.jsxs("div",{className:"mt-4",children:[f.jsx("h2",{className:"mb-4",children:"Авторизация"}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"email",className:"form-label",children:"Email:"}),f.jsx("input",{type:"email",id:"email",className:"form-control",value:n,onChange:d=>r(d.target.value)})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"password",className:"form-label",children:"Пароль:"}),f.jsx("input",{type:"password",id:"password",className:"form-control",value:i,onChange:d=>o(d.target.value)})]}),f.jsx("button",{type:"submit",onClick:c,className:"btn btn-primary",children:"Войти"}),s&&f.jsx("div",{style:{color:"red"},children:"Неверные данные"}),l&&f.jsx("div",{style:{color:"green"},children:"Успешно!"})]})};/*! js-cookie v3.0.5 | MIT */function ms(e){for(var t=1;t"u")){s=ms({},t,s),typeof s.expires=="number"&&(s.expires=new Date(Date.now()+s.expires*864e5)),s.expires&&(s.expires=s.expires.toUTCString()),i=encodeURIComponent(i).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var l in s)s[l]&&(a+="; "+l,s[l]!==!0&&(a+="="+s[l].split(";")[0]));return document.cookie=i+"="+e.write(o,i)+a}}function r(i){if(!(typeof document>"u"||arguments.length&&!i)){for(var o=document.cookie?document.cookie.split("; "):[],s={},a=0;af.jsx("div",{className:"card my-3",children:f.jsxs("div",{className:"card-body",children:[f.jsxs("h5",{className:"card-title",children:[f.jsx("strong",{children:"Роль:"})," Метеоролог"]}),f.jsx("p",{className:"card-text",children:"Дополнительная информация о метеорологе."}),f.jsx("a",{href:"/RIP-WeStatsApp/measurements",className:"btn btn-primary mx-2",children:"Добавленные показания"}),f.jsx("a",{href:"/RIP-WeStatsApp/uploadmeasure",className:"btn btn-success mx-2",children:"Добавить показания"})]})}),fC=()=>f.jsx("div",{className:"card my-3",children:f.jsxs("div",{className:"card-body",children:[f.jsxs("h5",{className:"card-title",children:[f.jsx("strong",{children:"Роль:"})," Менеджер"]}),f.jsx("p",{className:"card-text",children:"Дополнительная информация о менеджере."}),f.jsx("a",{href:"/RIP-WeStatsApp/admin/orders",className:"btn btn-primary mx-2",children:"Заказы"})]})}),iv=()=>xy(e=>({orderInfo:e.currentOrder.orderInfo,cart:e.currentOrder.cart})),hC=()=>{const e=iv().orderInfo;console.log(e);const t=Uo(),n=async()=>{const r=await ce.orders.ordersCreate();t(pi.initNew(r.data))};return f.jsx("div",{className:"card my-3",children:f.jsxs("div",{className:"card-body",children:[f.jsxs("h5",{className:"card-title",children:[f.jsx("strong",{children:"Роль:"})," Пользователь"]}),f.jsx("p",{className:"card-text",children:"Дополнительная информация о пользователе."}),e&&f.jsx("a",{href:`/RIP-WeStatsApp/profile/orders/${e.order_id}`,className:"btn btn-primary mx-2",children:"Текущий заказ"}),!e&&f.jsx("button",{className:"btn btn-primary mx-2",onClick:n,children:"Новый заказ"}),f.jsx("a",{href:"/RIP-WeStatsApp/profile/orders",className:"btn btn-success mx-2",children:"Мои заказы"})]})})},pC=()=>f.jsx("div",{className:"card my-3",children:f.jsxs("div",{className:"card-body",children:[f.jsxs("h5",{className:"card-title",children:[f.jsx("strong",{children:"Роль:"})," Администратор"]}),f.jsx("p",{className:"card-text",children:"Дополнительная информация об администраторе."}),f.jsx("a",{href:"/RIP-WeStatsApp/admin/orders",className:"btn btn-primary mx-2",children:"Заказы"}),f.jsx("a",{href:"/RIP-WeStatsApp/admin/addstation",className:"btn btn-primary mx-2",children:"Добавить станцию"}),f.jsx("a",{href:"/RIP-WeStatsApp/stations",className:"btn btn-primary mx-2",children:"Управление станциями"}),f.jsx("a",{href:"/RIP-WeStatsApp/admin/editmeasurements",className:"btn btn-primary mx-2",children:"Управление измерениями"}),f.jsx("a",{href:"/RIP-WeStatsApp/admin/perms",className:"btn btn-primary mx-2",children:"Управление правами"})]})}),mC=()=>{const e=zn(),t=Uo(),n=gd();e||n("/RIP-WeStatsApp/login");const r=async()=>{try{await ce.logout.logoutCreate(),t(Yy.setUserAuth(null)),cC.remove("session_id"),n("/RIP-WeStatsApp/login")}catch(o){console.error("Ошибка выхода:",o)}},i=()=>{switch(e==null?void 0:e.role){case"Админ":return f.jsx(pC,{});case"Менеджер":return f.jsx(fC,{});case"Пользователь":return f.jsx(hC,{});case"Метеоролог":return f.jsx(dC,{});default:return null}};return f.jsxs("div",{className:"container mt-5",children:[f.jsx("h2",{className:"mb-4",children:"Профиль пользователя"}),(e==null?void 0:e.role)==="Админ"&&f.jsx("div",{className:"alert alert-success",role:"alert",children:"Вы авторизованы как администратор."}),f.jsxs("div",{className:"mb-3",children:[f.jsx("strong",{children:"Имя:"})," ",e==null?void 0:e.name]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("strong",{children:"Email:"})," ",e==null?void 0:e.email]}),i(),f.jsx("button",{className:"btn btn-danger",onClick:r,children:"Выйти"})]})};var zo=e=>e.type==="checkbox",Zr=e=>e instanceof Date,ut=e=>e==null;const ov=e=>typeof e=="object";var ze=e=>!ut(e)&&!Array.isArray(e)&&ov(e)&&!Zr(e),yC=e=>ze(e)&&e.target?zo(e.target)?e.target.checked:e.target.value:e,gC=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,vC=(e,t)=>e.has(gC(t)),wC=e=>{const t=e.constructor&&e.constructor.prototype;return ze(t)&&t.hasOwnProperty("isPrototypeOf")},jd=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function bt(e){let t;const n=Array.isArray(e);if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(jd&&(e instanceof Blob||e instanceof FileList))&&(n||ze(e)))if(t=n?[]:{},!n&&!wC(e))t=e;else for(const r in e)e.hasOwnProperty(r)&&(t[r]=bt(e[r]));else return e;return t}var $o=e=>Array.isArray(e)?e.filter(Boolean):[],be=e=>e===void 0,B=(e,t,n)=>{if(!t||!ze(e))return n;const r=$o(t.split(/[,[\].]+?/)).reduce((i,o)=>ut(i)?i:i[o],e);return be(r)||r===e?be(e[t])?n:e[t]:r},yn=e=>typeof e=="boolean";const $h={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Kt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},hn={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};pt.createContext(null);var SC=(e,t,n,r=!0)=>{const i={defaultValues:t._defaultValues};for(const o in e)Object.defineProperty(i,o,{get:()=>{const s=o;return t._proxyFormState[s]!==Kt.all&&(t._proxyFormState[s]=!r||Kt.all),n&&(n[s]=!0),e[s]}});return i},Mt=e=>ze(e)&&!Object.keys(e).length,xC=(e,t,n,r)=>{n(e);const{name:i,...o}=e;return Mt(o)||Object.keys(o).length>=Object.keys(t).length||Object.keys(o).find(s=>t[s]===(!r||Kt.all))},$l=e=>Array.isArray(e)?e:[e];function EC(e){const t=pt.useRef(e);t.current=e,pt.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}var an=e=>typeof e=="string",_C=(e,t,n,r,i)=>an(e)?(r&&t.watch.add(e),B(n,e,i)):Array.isArray(e)?e.map(o=>(r&&t.watch.add(o),B(n,o))):(r&&(t.watchAll=!0),n),Nd=e=>/^\w*$/.test(e),sv=e=>$o(e.replace(/["|']|\]/g,"").split(/\.|\[/)),xe=(e,t,n)=>{let r=-1;const i=Nd(t)?[t]:sv(t),o=i.length,s=o-1;for(;++rt?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},Bh=e=>({isOnSubmit:!e||e===Kt.onSubmit,isOnBlur:e===Kt.onBlur,isOnChange:e===Kt.onChange,isOnAll:e===Kt.all,isOnTouch:e===Kt.onTouched}),Wh=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const no=(e,t,n,r)=>{for(const i of n||Object.keys(e)){const o=B(e,i);if(o){const{_f:s,...a}=o;if(s){if(s.refs&&s.refs[0]&&t(s.refs[0],i)&&!r)break;if(s.ref&&t(s.ref,s.name)&&!r)break;no(a,t)}else ze(a)&&no(a,t)}}};var kC=(e,t,n)=>{const r=$o(B(e,n));return xe(r,"root",t[n]),xe(e,n,r),e},Rd=e=>e.type==="file",$n=e=>typeof e=="function",ya=e=>{if(!jd)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},As=e=>an(e),Od=e=>e.type==="radio",ga=e=>e instanceof RegExp;const Vh={value:!1,isValid:!1},Hh={value:!0,isValid:!0};var av=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!be(e[0].attributes.value)?be(e[0].value)||e[0].value===""?Hh:{value:e[0].value,isValid:!0}:Hh:Vh}return Vh};const qh={isValid:!1,value:null};var lv=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,qh):qh;function Yh(e,t,n="validate"){if(As(e)||Array.isArray(e)&&e.every(As)||yn(e)&&!e)return{type:n,message:As(e)?e:"",ref:t}}var Ar=e=>ze(e)&&!ga(e)?e:{value:e,message:""},Qh=async(e,t,n,r,i)=>{const{ref:o,refs:s,required:a,maxLength:l,minLength:u,min:c,max:d,pattern:h,validate:w,name:g,valueAsNumber:v,mount:E,disabled:m}=e._f,p=B(t,g);if(!E||m)return{};const y=s?s[0]:o,C=K=>{r&&y.reportValidity&&(y.setCustomValidity(yn(K)?"":K||""),y.reportValidity())},R={},x=Od(o),T=zo(o),M=x||T,A=(v||Rd(o))&&be(o.value)&&be(p)||ya(o)&&o.value===""||p===""||Array.isArray(p)&&!p.length,V=CC.bind(null,g,n,R),Z=(K,q,ae,Oe=hn.maxLength,Te=hn.minLength)=>{const ie=K?q:ae;R[g]={type:K?Oe:Te,message:ie,ref:o,...V(K?Oe:Te,ie)}};if(i?!Array.isArray(p)||!p.length:a&&(!M&&(A||ut(p))||yn(p)&&!p||T&&!av(s).isValid||x&&!lv(s).isValid)){const{value:K,message:q}=As(a)?{value:!!a,message:a}:Ar(a);if(K&&(R[g]={type:hn.required,message:q,ref:y,...V(hn.required,q)},!n))return C(q),R}if(!A&&(!ut(c)||!ut(d))){let K,q;const ae=Ar(d),Oe=Ar(c);if(!ut(p)&&!isNaN(p)){const Te=o.valueAsNumber||p&&+p;ut(ae.value)||(K=Te>ae.value),ut(Oe.value)||(q=Tenew Date(new Date().toDateString()+" "+G),I=o.type=="time",Y=o.type=="week";an(ae.value)&&p&&(K=I?ie(p)>ie(ae.value):Y?p>ae.value:Te>new Date(ae.value)),an(Oe.value)&&p&&(q=I?ie(p)+K.value,Oe=!ut(q.value)&&p.length<+q.value;if((ae||Oe)&&(Z(ae,K.message,q.message),!n))return C(R[g].message),R}if(h&&!A&&an(p)){const{value:K,message:q}=Ar(h);if(ga(K)&&!p.match(K)&&(R[g]={type:hn.pattern,message:q,ref:o,...V(hn.pattern,q)},!n))return C(q),R}if(w){if($n(w)){const K=await w(p,t),q=Yh(K,y);if(q&&(R[g]={...q,...V(hn.validate,q.message)},!n))return C(q.message),R}else if(ze(w)){let K={};for(const q in w){if(!Mt(K)&&!n)break;const ae=Yh(await w[q](p,t),y,q);ae&&(K={...ae,...V(q,ae.message)},C(ae.message),n&&(R[g]=K))}if(!Mt(K)&&(R[g]={ref:y,...K},!n))return R}}return C(!0),R};function PC(e,t){const n=t.slice(0,-1).length;let r=0;for(;r{let e=[];return{get observers(){return e},next:i=>{for(const o of e)o.next&&o.next(i)},subscribe:i=>(e.push(i),{unsubscribe:()=>{e=e.filter(o=>o!==i)}}),unsubscribe:()=>{e=[]}}},va=e=>ut(e)||!ov(e);function yr(e,t){if(va(e)||va(t))return e===t;if(Zr(e)&&Zr(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n){const o=e[i];if(!r.includes(i))return!1;if(i!=="ref"){const s=t[i];if(Zr(o)&&Zr(s)||ze(o)&&ze(s)||Array.isArray(o)&&Array.isArray(s)?!yr(o,s):o!==s)return!1}}return!0}var uv=e=>e.type==="select-multiple",NC=e=>Od(e)||zo(e),Wl=e=>ya(e)&&e.isConnected,cv=e=>{for(const t in e)if($n(e[t]))return!0;return!1};function wa(e,t={}){const n=Array.isArray(e);if(ze(e)||n)for(const r in e)Array.isArray(e[r])||ze(e[r])&&!cv(e[r])?(t[r]=Array.isArray(e[r])?[]:{},wa(e[r],t[r])):ut(e[r])||(t[r]=!0);return t}function dv(e,t,n){const r=Array.isArray(e);if(ze(e)||r)for(const i in e)Array.isArray(e[i])||ze(e[i])&&!cv(e[i])?be(t)||va(n[i])?n[i]=Array.isArray(e[i])?wa(e[i],[]):{...wa(e[i])}:dv(e[i],ut(t)?{}:t[i],n[i]):n[i]=!yr(e[i],t[i]);return n}var Vl=(e,t)=>dv(e,t,wa(t)),fv=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>be(e)?e:t?e===""?NaN:e&&+e:n&&an(e)?new Date(e):r?r(e):e;function Hl(e){const t=e.ref;if(!(e.refs?e.refs.every(n=>n.disabled):t.disabled))return Rd(t)?t.files:Od(t)?lv(e.refs).value:uv(t)?[...t.selectedOptions].map(({value:n})=>n):zo(t)?av(e.refs).value:fv(be(t.value)?e.ref.value:t.value,e)}var RC=(e,t,n,r)=>{const i={};for(const o of e){const s=B(t,o);s&&xe(i,o,s._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},Ai=e=>be(e)?e:ga(e)?e.source:ze(e)?ga(e.value)?e.value.source:e.value:e,OC=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Kh(e,t,n){const r=B(e,n);if(r||Nd(n))return{error:r,name:n};const i=n.split(".");for(;i.length;){const o=i.join("."),s=B(t,o),a=B(e,o);if(s&&!Array.isArray(s)&&n!==o)return{name:n};if(a&&a.type)return{name:o,error:a};i.pop()}return{name:n}}var TC=(e,t,n,r,i)=>i.isOnAll?!1:!n&&i.isOnTouch?!(t||e):(n?r.isOnBlur:i.isOnBlur)?!e:(n?r.isOnChange:i.isOnChange)?e:!0,DC=(e,t)=>!$o(B(e,t)).length&&Ke(e,t);const bC={mode:Kt.onSubmit,reValidateMode:Kt.onChange,shouldFocusError:!0};function LC(e={},t){let n={...bC,...e},r={submitCount:0,isDirty:!1,isLoading:$n(n.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:n.errors||{},disabled:n.disabled||!1},i={},o=ze(n.defaultValues)||ze(n.values)?bt(n.defaultValues||n.values)||{}:{},s=n.shouldUnregister?{}:bt(o),a={action:!1,mount:!1,watch:!1},l={mount:new Set,unMount:new Set,array:new Set,watch:new Set},u,c=0;const d={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},h={values:Bl(),array:Bl(),state:Bl()},w=Bh(n.mode),g=Bh(n.reValidateMode),v=n.criteriaMode===Kt.all,E=S=>j=>{clearTimeout(c),c=setTimeout(S,j)},m=async S=>{if(d.isValid||S){const j=n.resolver?Mt((await A()).errors):await Z(i,!0);j!==r.isValid&&h.state.next({isValid:j})}},p=S=>d.isValidating&&h.state.next({isValidating:S}),y=(S,j=[],N,z,F=!0,b=!0)=>{if(z&&N){if(a.action=!0,b&&Array.isArray(B(i,S))){const H=N(B(i,S),z.argA,z.argB);F&&xe(i,S,H)}if(b&&Array.isArray(B(r.errors,S))){const H=N(B(r.errors,S),z.argA,z.argB);F&&xe(r.errors,S,H),DC(r.errors,S)}if(d.touchedFields&&b&&Array.isArray(B(r.touchedFields,S))){const H=N(B(r.touchedFields,S),z.argA,z.argB);F&&xe(r.touchedFields,S,H)}d.dirtyFields&&(r.dirtyFields=Vl(o,s)),h.state.next({name:S,isDirty:q(S,j),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else xe(s,S,j)},C=(S,j)=>{xe(r.errors,S,j),h.state.next({errors:r.errors})},R=S=>{r.errors=S,h.state.next({errors:r.errors,isValid:!1})},x=(S,j,N,z)=>{const F=B(i,S);if(F){const b=B(s,S,be(N)?B(o,S):N);be(b)||z&&z.defaultChecked||j?xe(s,S,j?b:Hl(F._f)):Te(S,b),a.mount&&m()}},T=(S,j,N,z,F)=>{let b=!1,H=!1;const de={name:S},_e=!!(B(i,S)&&B(i,S)._f.disabled);if(!N||z){d.isDirty&&(H=r.isDirty,r.isDirty=de.isDirty=q(),b=H!==de.isDirty);const Tt=_e||yr(B(o,S),j);H=!!(!_e&&B(r.dirtyFields,S)),Tt||_e?Ke(r.dirtyFields,S):xe(r.dirtyFields,S,!0),de.dirtyFields=r.dirtyFields,b=b||d.dirtyFields&&H!==!Tt}if(N){const Tt=B(r.touchedFields,S);Tt||(xe(r.touchedFields,S,N),de.touchedFields=r.touchedFields,b=b||d.touchedFields&&Tt!==N)}return b&&F&&h.state.next(de),b?de:{}},M=(S,j,N,z)=>{const F=B(r.errors,S),b=d.isValid&&yn(j)&&r.isValid!==j;if(e.delayError&&N?(u=E(()=>C(S,N)),u(e.delayError)):(clearTimeout(c),u=null,N?xe(r.errors,S,N):Ke(r.errors,S)),(N?!yr(F,N):F)||!Mt(z)||b){const H={...z,...b&&yn(j)?{isValid:j}:{},errors:r.errors,name:S};r={...r,...H},h.state.next(H)}p(!1)},A=async S=>n.resolver(s,n.context,RC(S||l.mount,i,n.criteriaMode,n.shouldUseNativeValidation)),V=async S=>{const{errors:j}=await A(S);if(S)for(const N of S){const z=B(j,N);z?xe(r.errors,N,z):Ke(r.errors,N)}else r.errors=j;return j},Z=async(S,j,N={valid:!0})=>{for(const z in S){const F=S[z];if(F){const{_f:b,...H}=F;if(b){const de=l.array.has(b.name),_e=await Qh(F,s,v,n.shouldUseNativeValidation&&!j,de);if(_e[b.name]&&(N.valid=!1,j))break;!j&&(B(_e,b.name)?de?kC(r.errors,_e,b.name):xe(r.errors,b.name,_e[b.name]):Ke(r.errors,b.name))}H&&await Z(H,j,N)}}return N.valid},K=()=>{for(const S of l.unMount){const j=B(i,S);j&&(j._f.refs?j._f.refs.every(N=>!Wl(N)):!Wl(j._f.ref))&&Ot(S)}l.unMount=new Set},q=(S,j)=>(S&&j&&xe(s,S,j),!yr(pe(),o)),ae=(S,j,N)=>_C(S,l,{...a.mount?s:be(j)?o:an(S)?{[S]:j}:j},N,j),Oe=S=>$o(B(a.mount?s:o,S,e.shouldUnregister?B(o,S,[]):[])),Te=(S,j,N={})=>{const z=B(i,S);let F=j;if(z){const b=z._f;b&&(!b.disabled&&xe(s,S,fv(j,b)),F=ya(b.ref)&&ut(j)?"":j,uv(b.ref)?[...b.ref.options].forEach(H=>H.selected=F.includes(H.value)):b.refs?zo(b.ref)?b.refs.length>1?b.refs.forEach(H=>(!H.defaultChecked||!H.disabled)&&(H.checked=Array.isArray(F)?!!F.find(de=>de===H.value):F===H.value)):b.refs[0]&&(b.refs[0].checked=!!F):b.refs.forEach(H=>H.checked=H.value===F):Rd(b.ref)?b.ref.value="":(b.ref.value=F,b.ref.type||h.values.next({name:S,values:{...s}})))}(N.shouldDirty||N.shouldTouch)&&T(S,F,N.shouldTouch,N.shouldDirty,!0),N.shouldValidate&&oe(S)},ie=(S,j,N)=>{for(const z in j){const F=j[z],b=`${S}.${z}`,H=B(i,b);(l.array.has(S)||!va(F)||H&&!H._f)&&!Zr(F)?ie(b,F,N):Te(b,F,N)}},I=(S,j,N={})=>{const z=B(i,S),F=l.array.has(S),b=bt(j);xe(s,S,b),F?(h.array.next({name:S,values:{...s}}),(d.isDirty||d.dirtyFields)&&N.shouldDirty&&h.state.next({name:S,dirtyFields:Vl(o,s),isDirty:q(S,b)})):z&&!z._f&&!ut(b)?ie(S,b,N):Te(S,b,N),Wh(S,l)&&h.state.next({...r}),h.values.next({name:S,values:{...s}}),!a.mount&&t()},Y=async S=>{const j=S.target;let N=j.name,z=!0;const F=B(i,N),b=()=>j.type?Hl(F._f):yC(S),H=de=>{z=Number.isNaN(de)||de===B(s,N,de)};if(F){let de,_e;const Tt=b(),at=S.type===$h.BLUR||S.type===$h.FOCUS_OUT,qo=!OC(F._f)&&!n.resolver&&!B(r.errors,N)&&!F._f.deps||TC(at,B(r.touchedFields,N),r.isSubmitted,g,w),Or=Wh(N,l,at);xe(s,N,Tt),at?(F._f.onBlur&&F._f.onBlur(S),u&&u(0)):F._f.onChange&&F._f.onChange(S);const Tr=T(N,Tt,at,!1),Xa=!Mt(Tr)||Or;if(!at&&h.values.next({name:N,type:S.type,values:{...s}}),qo)return d.isValid&&m(),Xa&&h.state.next({name:N,...Or?{}:Tr});if(!at&&Or&&h.state.next({...r}),p(!0),n.resolver){const{errors:xi}=await A([N]);if(H(Tt),z){const Dr=Kh(r.errors,i,N),Ei=Kh(xi,i,Dr.name||N);de=Ei.error,N=Ei.name,_e=Mt(xi)}}else de=(await Qh(F,s,v,n.shouldUseNativeValidation))[N],H(Tt),z&&(de?_e=!1:d.isValid&&(_e=await Z(i,!0)));z&&(F._f.deps&&oe(F._f.deps),M(N,_e,de,Tr))}},G=(S,j)=>{if(B(r.errors,j)&&S.focus)return S.focus(),1},oe=async(S,j={})=>{let N,z;const F=$l(S);if(p(!0),n.resolver){const b=await V(be(S)?S:F);N=Mt(b),z=S?!F.some(H=>B(b,H)):N}else S?(z=(await Promise.all(F.map(async b=>{const H=B(i,b);return await Z(H&&H._f?{[b]:H}:H)}))).every(Boolean),!(!z&&!r.isValid)&&m()):z=N=await Z(i);return h.state.next({...!an(S)||d.isValid&&N!==r.isValid?{}:{name:S},...n.resolver||!S?{isValid:N}:{},errors:r.errors,isValidating:!1}),j.shouldFocus&&!z&&no(i,G,S?F:l.mount),z},pe=S=>{const j={...o,...a.mount?s:{}};return be(S)?j:an(S)?B(j,S):S.map(N=>B(j,N))},St=(S,j)=>({invalid:!!B((j||r).errors,S),isDirty:!!B((j||r).dirtyFields,S),isTouched:!!B((j||r).touchedFields,S),error:B((j||r).errors,S)}),Ae=S=>{S&&$l(S).forEach(j=>Ke(r.errors,j)),h.state.next({errors:S?r.errors:{}})},ht=(S,j,N)=>{const z=(B(i,S,{_f:{}})._f||{}).ref;xe(r.errors,S,{...j,ref:z}),h.state.next({name:S,errors:r.errors,isValid:!1}),N&&N.shouldFocus&&z&&z.focus&&z.focus()},qe=(S,j)=>$n(S)?h.values.subscribe({next:N=>S(ae(void 0,j),N)}):ae(S,j,!0),Ot=(S,j={})=>{for(const N of S?$l(S):l.mount)l.mount.delete(N),l.array.delete(N),j.keepValue||(Ke(i,N),Ke(s,N)),!j.keepError&&Ke(r.errors,N),!j.keepDirty&&Ke(r.dirtyFields,N),!j.keepTouched&&Ke(r.touchedFields,N),!n.shouldUnregister&&!j.keepDefaultValue&&Ke(o,N);h.values.next({values:{...s}}),h.state.next({...r,...j.keepDirty?{isDirty:q()}:{}}),!j.keepIsValid&&m()},Bo=({disabled:S,name:j,field:N,fields:z,value:F})=>{if(yn(S)){const b=S?void 0:be(F)?Hl(N?N._f:B(z,j)._f):F;xe(s,j,b),T(j,b,!1,!1,!0)}},Si=(S,j={})=>{let N=B(i,S);const z=yn(j.disabled);return xe(i,S,{...N||{},_f:{...N&&N._f?N._f:{ref:{name:S}},name:S,mount:!0,...j}}),l.mount.add(S),N?Bo({field:N,disabled:j.disabled,name:S,value:j.value}):x(S,!0,j.value),{...z?{disabled:j.disabled}:{},...n.progressive?{required:!!j.required,min:Ai(j.min),max:Ai(j.max),minLength:Ai(j.minLength),maxLength:Ai(j.maxLength),pattern:Ai(j.pattern)}:{},name:S,onChange:Y,onBlur:Y,ref:F=>{if(F){Si(S,j),N=B(i,S);const b=be(F.value)&&F.querySelectorAll&&F.querySelectorAll("input,select,textarea")[0]||F,H=NC(b),de=N._f.refs||[];if(H?de.find(_e=>_e===b):b===N._f.ref)return;xe(i,S,{_f:{...N._f,...H?{refs:[...de.filter(Wl),b,...Array.isArray(B(o,S))?[{}]:[]],ref:{type:b.type,name:S}}:{ref:b}}}),x(S,!1,void 0,b)}else N=B(i,S,{}),N._f&&(N._f.mount=!1),(n.shouldUnregister||j.shouldUnregister)&&!(vC(l.array,S)&&a.action)&&l.unMount.add(S)}}},Wo=()=>n.shouldFocusError&&no(i,G,l.mount),st=S=>{yn(S)&&(h.state.next({disabled:S}),no(i,(j,N)=>{let z=S;const F=B(i,N);F&&yn(F._f.disabled)&&(z||(z=F._f.disabled)),j.disabled=z},0,!1))},Nn=(S,j)=>async N=>{N&&(N.preventDefault&&N.preventDefault(),N.persist&&N.persist());let z=bt(s);if(h.state.next({isSubmitting:!0}),n.resolver){const{errors:F,values:b}=await A();r.errors=F,z=b}else await Z(i);Ke(r.errors,"root"),Mt(r.errors)?(h.state.next({errors:{}}),await S(z,N)):(j&&await j({...r.errors},N),Wo(),setTimeout(Wo)),h.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Mt(r.errors),submitCount:r.submitCount+1,errors:r.errors})},Vo=(S,j={})=>{B(i,S)&&(be(j.defaultValue)?I(S,bt(B(o,S))):(I(S,j.defaultValue),xe(o,S,bt(j.defaultValue))),j.keepTouched||Ke(r.touchedFields,S),j.keepDirty||(Ke(r.dirtyFields,S),r.isDirty=j.defaultValue?q(S,bt(B(o,S))):q()),j.keepError||(Ke(r.errors,S),d.isValid&&m()),h.state.next({...r}))},Ho=(S,j={})=>{const N=S?bt(S):o,z=bt(N),F=S&&!Mt(S)?z:o;if(j.keepDefaultValues||(o=N),!j.keepValues){if(j.keepDirtyValues)for(const b of l.mount)B(r.dirtyFields,b)?xe(F,b,B(s,b)):I(b,B(F,b));else{if(jd&&be(S))for(const b of l.mount){const H=B(i,b);if(H&&H._f){const de=Array.isArray(H._f.refs)?H._f.refs[0]:H._f.ref;if(ya(de)){const _e=de.closest("form");if(_e){_e.reset();break}}}}i={}}s=e.shouldUnregister?j.keepDefaultValues?bt(o):{}:bt(F),h.array.next({values:{...F}}),h.values.next({values:{...F}})}l={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!a.mount&&t(),a.mount=!d.isValid||!!j.keepIsValid,a.watch=!!e.shouldUnregister,h.state.next({submitCount:j.keepSubmitCount?r.submitCount:0,isDirty:j.keepDirty?r.isDirty:!!(j.keepDefaultValues&&!yr(S,o)),isSubmitted:j.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:j.keepDirtyValues?r.dirtyFields:j.keepDefaultValues&&S?Vl(o,S):{},touchedFields:j.keepTouched?r.touchedFields:{},errors:j.keepErrors?r.errors:{},isSubmitSuccessful:j.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},en=(S,j)=>Ho($n(S)?S(s):S,j);return{control:{register:Si,unregister:Ot,getFieldState:St,handleSubmit:Nn,setError:ht,_executeSchema:A,_getWatch:ae,_getDirty:q,_updateValid:m,_removeUnmounted:K,_updateFieldArray:y,_updateDisabledField:Bo,_getFieldArray:Oe,_reset:Ho,_resetDefaultValues:()=>$n(n.defaultValues)&&n.defaultValues().then(S=>{en(S,n.resetOptions),h.state.next({isLoading:!1})}),_updateFormState:S=>{r={...r,...S}},_disableForm:st,_subjects:h,_proxyFormState:d,_setErrors:R,get _fields(){return i},get _formValues(){return s},get _state(){return a},set _state(S){a=S},get _defaultValues(){return o},get _names(){return l},set _names(S){l=S},get _formState(){return r},set _formState(S){r=S},get _options(){return n},set _options(S){n={...n,...S}}},trigger:oe,register:Si,handleSubmit:Nn,watch:qe,setValue:I,getValues:pe,reset:en,resetField:Vo,clearErrors:Ae,unregister:Ot,setError:ht,setFocus:(S,j={})=>{const N=B(i,S),z=N&&N._f;if(z){const F=z.refs?z.refs[0]:z.ref;F.focus&&(F.focus(),j.shouldSelect&&F.select())}},getFieldState:St}}function Td(e={}){const t=pt.useRef(),n=pt.useRef(),[r,i]=pt.useState({isDirty:!1,isValidating:!1,isLoading:$n(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:$n(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...LC(e,()=>i(s=>({...s}))),formState:r});const o=t.current.control;return o._options=e,EC({subject:o._subjects.state,next:s=>{xC(s,o._proxyFormState,o._updateFormState,!0)&&i({...o._formState})}}),pt.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),pt.useEffect(()=>{if(o._proxyFormState.isDirty){const s=o._getDirty();s!==r.isDirty&&o._subjects.state.next({isDirty:s})}},[o,r.isDirty]),pt.useEffect(()=>{e.values&&!yr(e.values,n.current)?(o._reset(e.values,o._options.resetOptions),n.current=e.values,i(s=>({...s}))):o._resetDefaultValues()},[e.values,o]),pt.useEffect(()=>{e.errors&&o._setErrors(e.errors)},[e.errors,o]),pt.useEffect(()=>{o._state.mount||(o._updateValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),t.current.formState=SC(r,o),t.current}const MC=()=>{const[e,t]=k.useState(!1),{register:n,handleSubmit:r}=Td(),[i,o]=k.useState([]),[s,a]=k.useState(!1);k.useEffect(()=>{(async()=>{a(!0);try{const c=await ce.stations.stationsList();o(c.data)}catch(c){console.error("Error fetching stations:",c)}finally{a(!1)}})()},[]);const l=async u=>{t(!1),console.log(u);try{const c=await ce.measurements.measurementsCreate(u);console.log("Измерение успешно создано:",c.data),t(!0)}catch(c){console.error("Ошибка при создании измерения:",c)}};return f.jsxs("div",{className:"container mt-5",children:[f.jsx("h1",{children:"Добавить показания"}),e&&f.jsx("div",{className:"alert alert-success",role:"alert",children:"Показания добавлены."}),f.jsxs("form",{onSubmit:r(l),children:[f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"weather_station",className:"form-label",children:"Выберите станцию:"}),f.jsx("select",{className:"form-select",...n("weather_station"),id:"weather_station",children:i.map(u=>f.jsx("option",{value:u.station_id,children:u.name},u.id))})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"temperature",className:"form-label",children:"Температура:"}),f.jsx("input",{type:"number",className:"form-control",...n("temperature",{min:-100,max:100}),id:"temperature",step:"0.01",placeholder:"0.00"})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"humidity",className:"form-label",children:"Влажность:"}),f.jsx("input",{type:"number",className:"form-control",...n("humidity",{min:0,max:100}),id:"humidity",step:"0.01",placeholder:"0.00"})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"wind_speed",className:"form-label",children:"Скорость ветра:"}),f.jsx("input",{type:"number",className:"form-control",...n("wind_speed",{min:0,max:200}),id:"wind_speed",step:"0.01",placeholder:"0.00"})]}),f.jsx("button",{type:"submit",className:"btn btn-primary",disabled:s,children:"Сохранить и добавить"})]})]})},FC=({user:e,loading:t})=>{const[n,r]=k.useState(e.user_role),i=async()=>{await l("just_user")},o=async()=>{await l("meteorologist")},s=async()=>{await l("r_manager")},a=async()=>{await l("r_admin")},l=async u=>{try{await ce.updateUserRole.updateUserRoleCreate(e.user_id.toString(),{role:u}),r(u)}catch(c){console.error("Ошибка при сохранении изменений:",c)}};return f.jsxs("div",{className:"userRow",children:[f.jsxs("div",{className:"d-flex align-items-center",children:[f.jsx("span",{className:"me-2",children:e.name}),f.jsx("span",{children:e.email})]}),f.jsxs("div",{className:"d-flex align-items-center mt-2",children:[f.jsx(pr,{variant:"success",disabled:t||n==="just_user",onClick:i,className:"me-2",children:t?f.jsx(mr,{animation:"border",size:"sm"}):"Пользователь"}),f.jsx(pr,{variant:"success",disabled:t||n==="meteorologist",onClick:o,className:"me-2",children:t?f.jsx(mr,{animation:"border",size:"sm"}):"Метеоролог"}),f.jsx(pr,{variant:"success",disabled:t||n==="r_manager",onClick:s,className:"me-2",children:t?f.jsx(mr,{animation:"border",size:"sm"}):"Менеджер"}),f.jsx(pr,{variant:"danger",disabled:t||n==="r_admin",onClick:a,children:t?f.jsx(mr,{animation:"border",size:"sm"}):"Админ"})]}),f.jsx("hr",{})]},e.user_id)},AC=()=>{const e=zn(),[t,n]=k.useState([]),[r,i]=k.useState(""),[o,s]=k.useState(!1),a=async()=>{s(!0);try{const u=await ce.users.usersList();n(u.data)}catch(u){console.error("Ошибка при получении пользователей:",u)}finally{s(!1)}};k.useEffect(()=>{a()},[]);const l=()=>{};return f.jsxs("div",{className:"container mt-5",children:[e&&e.role=="Админ"&&f.jsxs("div",{children:[f.jsx("h2",{children:"Роли пользователей"}),f.jsxs("div",{className:"inputField d-flex justify-content-center mt-3",children:[f.jsx("input",{value:r,onChange:u=>i(u.target.value),className:"form-control me-3",placeholder:"Введите значение для поиска"}),f.jsx(pr,{disabled:o,onClick:l,className:"btn btn-primary me-3",children:"Искать"}),o&&f.jsx("div",{className:"loadingBg",children:f.jsx(mr,{animation:"border"})})]}),f.jsx("div",{className:"mt-4",children:t.map(u=>f.jsx(FC,{user:u,loading:o},u.user_id))})]}),(!e||e.role!=="Админ")&&f.jsx("div",{className:"warningDiv",children:f.jsx("p",{className:"text-danger",children:"Вы не админ"})})]})},IC=()=>{const[e,t]=k.useState(!1),{register:n,handleSubmit:r}=Td(),[i,o]=k.useState(!1),s=async a=>{o(!0),t(!1),console.log(a);try{const l=await ce.stations.stationsCreate(a);console.log("Станция успешно создана:",l.data),t(!0)}catch(l){console.error("Ошибка при создании станции:",l)}finally{o(!1)}};return f.jsxs("div",{className:"container mt-5",children:[f.jsx("h1",{children:"Добавить новую Станцию"}),e&&f.jsx("div",{className:"alert alert-success",role:"alert",children:"Станция добавлена."}),f.jsxs("form",{onSubmit:r(s),children:[f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"name",className:"form-label",children:"Название станции:"}),f.jsx("input",{type:"text",className:"form-control",...n("name"),id:"name"})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"location",className:"form-label",children:"Местоположение:"}),f.jsx("input",{type:"text",className:"form-control",...n("location"),id:"location"})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"open_date",className:"form-label",children:"Дата открытия:"}),f.jsx("input",{type:"datetime-local",className:"form-control",...n("open_date"),id:"open_date"})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"description",className:"form-label",children:"Описание:"}),f.jsx("textarea",{className:"form-control",...n("description"),id:"description",rows:4})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"status",className:"form-label",children:"Статус:"}),f.jsxs("select",{className:"form-select",...n("status"),id:"status",children:[f.jsx("option",{value:"true",children:"Активная"}),f.jsx("option",{value:"false",children:"Неактивная"})]})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"image_url",className:"form-label",children:"URL изображения:"}),f.jsx("input",{type:"text",className:"form-control",...n("image_url"),id:"image_url"})]}),f.jsx("button",{type:"submit",className:"btn btn-primary",disabled:i,children:"Создать станцию"})]})]})},Gh=()=>{const e=Uo(),{orderId:t}=vd(),[n,r]=k.useState(null),[i,o]=k.useState(!1);k.useEffect(()=>{(async()=>{o(!0);try{const u=await ce.orders.ordersRead(t.toString());r(u.data)}catch(u){console.error("Error fetching order information:",u)}finally{o(!1)}})()},[t]);const s=async()=>{o(!0);try{await ce.orders.ordersFormatPartialUpdate(n.order.order_id.toString()),e(pi.flush());const l=await ce.orders.ordersRead(n.order.order_id.toString());r(l.data)}catch(l){console.error("Error processing payment:",l)}finally{o(!1)}},a=async()=>{o(!0);try{await ce.orders.ordersDeletePartialUpdate(n.order.order_id.toString()),e(pi.flush());const l=await ce.orders.ordersRead(n.order.order_id.toString());r(l.data)}catch(l){console.error("Error processing delete:",l)}finally{o(!1)}};return i?f.jsx("div",{children:"Loading..."}):n?f.jsxs("div",{className:"container mt-5",children:[f.jsx("h1",{children:"Информация о заказе"}),f.jsxs("p",{children:["Статус: ",n==null?void 0:n.order.status]}),f.jsxs("p",{children:["Дата формирования: ",n!=null&&n.order.formation_date?new Date(n==null?void 0:n.order.formation_date).toLocaleString():"-"]}),f.jsxs("p",{children:["Дата выноса решения: ",n!=null&&n.order.completion_date?new Date(n==null?void 0:n.order.completion_date).toLocaleString():"-"]}),n.measurements.length>0&&f.jsx("h2",{children:"Заказанные показания"}),n==null?void 0:n.measurements.map(l=>f.jsxs("div",{children:[f.jsxs("p",{children:["Дата снятия: ",new Date(l.created_date).toLocaleString()]}),n.order.status==="completed"&&f.jsxs("div",{children:[f.jsxs("p",{children:["Температура: ",l.temperature," по Цельсию"]}),f.jsxs("p",{children:["Влажность: ",l.humidity,"%"]}),f.jsxs("p",{children:["Скорость ветра: ",l.wind_speed," м/с"]})]}),f.jsx("hr",{})]})),(n==null?void 0:n.order.status)==="draft"&&f.jsxs("div",{className:"mt-4",children:[f.jsx("button",{className:"btn btn-success ms-2",onClick:s,disabled:i,children:"Оплатить"}),f.jsx("button",{className:"btn btn-danger ms-2",onClick:a,disabled:i,children:"Удалить"})]})]}):f.jsx("div",{children:"Заказ не найден"})},UC=({order:e})=>{const t=n=>{switch(n){case"completed":return"green";case"formed":case"draft":return"yellow";case"rejected":case"deleted":return"red";default:return"black"}};return f.jsx("div",{className:"card my-3",children:f.jsxs("div",{className:"card-body",children:[f.jsxs("h5",{className:"card-title",children:["Информация о заказе #",e.order.order_id]}),f.jsxs("p",{className:"card-text",style:{color:t(e.order.status.toString())},children:["Статус: ",e.order.status]}),f.jsxs("p",{className:"card-text",children:["Дата создания: ",new Date(e.order.formation_date.toString()).toLocaleString()]}),f.jsx("a",{href:`/profile/orders/${e.order.order_id}`,className:"btn btn-primary",children:"Подробнее"})]})})},zC=()=>{const[e,t]=k.useState([]),[n,r]=k.useState(!0);return k.useEffect(()=>{(async()=>{r(!0);try{const o=await ce.userorders.userordersList();console.log(o.data),t(o.data)}catch(o){console.error("Error fetching orders:",o)}finally{r(!1)}})()},[]),f.jsxs("div",{className:"container mt-5",children:[!n&&!e.length&&f.jsx("div",{children:f.jsx("h1",{children:"К сожалению, пока ничего не найдено :("})}),f.jsx(Sd,{xs:4,ms:4,className:"g-10",children:e.map((i,o)=>f.jsx(pa,{children:f.jsx(UC,{order:i})},o))})]})},$C=({order:e,onApprove:t,onReject:n})=>f.jsxs("div",{className:"row mb-3",children:[f.jsxs("div",{className:"col-md-6",children:[f.jsxs("h4",{children:["Заказ №",e.order_id]}),f.jsxs("p",{children:["Статус: ",e.status]})]}),f.jsx("div",{className:"col-md-6",children:f.jsxs("div",{className:"d-flex justify-content-end",children:[f.jsx("button",{className:"btn btn-success me-2",onClick:()=>t(),disabled:e.status!=="formed",children:"Одобрить"}),f.jsx("button",{className:"btn btn-danger me-2",onClick:()=>n(),disabled:e.status!=="formed",children:"Отклонить"}),f.jsx("a",{href:`/RIP-WeStatsApp/profile/orders/${e.order_id}`,className:"btn btn-primary ms-2",children:"Детали"})]})})]}),BC=()=>{const[e,t]=k.useState([]),[n,r]=k.useState("all"),[i,o]=k.useState(!0),s=async()=>{try{o(!0);const c=await ce.orders.ordersList();t(c.data)}catch(c){console.error("Error fetching orders:",c)}finally{o(!1)}};k.useEffect(()=>{s()},[]);const a=e.filter(c=>n==="all"?c.status==="formed"||c.status==="rejected"||c.status==="completed":n==="awaiting_approval"?c.status==="formed":n==="rejected"?c.status==="rejected":n==="approved"?c.status==="completed":!1),l=async c=>{try{console.log(`Order ${c} approved`),await ce.orders.ordersAcceptPartialUpdate(c.toString()),t(d=>d.map(h=>h.order_id===c?{...h,status:"completed"}:h))}catch(d){console.error("Error processing approval:",d)}},u=async c=>{try{console.log(`Order ${c} rejected`),await ce.orders.ordersRejectPartialUpdate(c.toString()),t(d=>d.map(h=>h.order_id===c?{...h,status:"rejected"}:h))}catch(d){console.error("Error processing rejection:",d)}};return f.jsxs("div",{className:"container mt-5",children:[f.jsx("h1",{children:"Управление заказами"}),f.jsx("div",{className:"btn-group my-3",role:"group","aria-label":"Order Categories",children:f.jsxs("div",{className:"btn-group",role:"group","aria-label":"Order Categories",children:[f.jsx("button",{type:"button",className:`btn ${n==="all"?"btn-primary":"btn-secondary"}`,onClick:()=>r("all"),children:"Все"}),f.jsx("button",{type:"button",className:`btn ${n==="awaiting_approval"?"btn-primary":"btn-secondary"}`,onClick:()=>r("awaiting_approval"),children:"Ожидают подтверждения"}),f.jsx("button",{type:"button",className:`btn ${n==="rejected"?"btn-primary":"btn-secondary"}`,onClick:()=>r("rejected"),children:"Отклоненные"}),f.jsx("button",{type:"button",className:`btn ${n==="approved"?"btn-primary":"btn-secondary"}`,onClick:()=>r("approved"),children:"Одобренные"})]})}),i?f.jsx("p",{children:"Loading..."}):a.length>0?a.map(c=>f.jsx($C,{order:c,onApprove:()=>l(c.order_id),onReject:()=>u(c.order_id)},c.order_id)):f.jsx("p",{children:"No orders to display"})]})},WC=({measurement:e,stations:t})=>{var u,c;const n=zn(),r=iv(),i=new Date(e.created_date).toLocaleString(),o=Uo(),s=(u=r.cart)==null?void 0:u.some(d=>d.measurement_id===e.measurement_id),a=(c=t.find(d=>d.station_id===e.weather_station))==null?void 0:c.name,l=async()=>{var d;try{await ce.orders.ordersAddItemCreate(r.orderInfo.order_id.toString(),{measurement_id:(d=e.measurement_id)==null?void 0:d.toString()})}catch{console.log("Unable to add")}o(pi.addToCart(e))};return f.jsxs("tr",{children:[f.jsx("td",{children:a}),f.jsx("td",{children:i}),f.jsxs("td",{children:[(n==null?void 0:n.role)==="just_user"&&r.orderInfo&&!s&&f.jsx("button",{className:"btn btn-success",onClick:l,children:"Добавить"}),(n==null?void 0:n.role)==="just_user"&&r.orderInfo&&s&&f.jsx("span",{children:"Добавлено"}),(n==null?void 0:n.role)==="just_user"&&!r.orderInfo&&f.jsx("a",{href:"/profile",className:"btn btn-primary",children:"Новый заказ"})]})]})},VC=()=>{const[e,t]=k.useState(!0),[n,r]=k.useState([]),[i,o]=k.useState([]),s=async()=>{try{t(!0);const l=await ce.stations.stationsList();o(l.data)}catch(l){console.error("Ошибка при получении станций:",l)}finally{t(!1)}},a=async()=>{try{t(!0);const l=await ce.measurements.measurementsList();r(l.data)}catch(l){console.error("Error fetching measurements:",l)}finally{t(!1)}};return k.useEffect(()=>{a(),s()},[]),e?f.jsx("div",{children:"Loading..."}):f.jsxs("div",{className:"container mt-5",children:[f.jsx("h1",{children:"Измерения"}),f.jsxs(Fg,{striped:!0,bordered:!0,hover:!0,children:[f.jsx("thead",{children:f.jsxs("tr",{children:[f.jsx("th",{children:"Станция"}),f.jsx("th",{children:"Дата снятия"})]})}),f.jsx("tbody",{children:n.map(l=>f.jsx(WC,{measurement:l,stations:i},l.measurement_id))})]})]})};function dn(e){const t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function Pr(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}const hv=6048e5,HC=864e5,pv=6e4,mv=36e5;let qC={};function Ga(){return qC}function No(e,t){var a,l,u,c;const n=Ga(),r=(t==null?void 0:t.weekStartsOn)??((l=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:l.weekStartsOn)??n.weekStartsOn??((c=(u=n.locale)==null?void 0:u.options)==null?void 0:c.weekStartsOn)??0,i=dn(e),o=i.getDay(),s=(o=i.getTime()?n+1:t.getTime()>=s.getTime()?n:n-1}function Xh(e){const t=dn(e);return t.setHours(0,0,0,0),t}function Jh(e){const t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),e.getTime()-t.getTime()}function YC(e,t){const n=Xh(e),r=Xh(t),i=+n-Jh(n),o=+r-Jh(r);return Math.trunc((i-o)/HC)}function QC(e){const t=yv(e),n=Pr(e,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),Sa(n)}function KC(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function GC(e){if(!KC(e)&&typeof e!="number")return!1;const t=dn(e);return!isNaN(Number(t))}function XC(e){const t=dn(e),n=Pr(e,0);return n.setFullYear(t.getFullYear(),0,1),n.setHours(0,0,0,0),n}const JC={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},ZC=(e,t,n)=>{let r;const i=JC[e];return typeof i=="string"?r=i:t===1?r=i.one:r=i.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function ql(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const ek={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},tk={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},nk={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},rk={date:ql({formats:ek,defaultWidth:"full"}),time:ql({formats:tk,defaultWidth:"full"}),dateTime:ql({formats:nk,defaultWidth:"full"})},ik={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},ok=(e,t,n,r)=>ik[e];function Ii(e){return(t,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let i;if(r==="formatting"&&e.formattingValues){const s=e.defaultFormattingWidth||e.defaultWidth,a=n!=null&&n.width?String(n.width):s;i=e.formattingValues[a]||e.formattingValues[s]}else{const s=e.defaultWidth,a=n!=null&&n.width?String(n.width):e.defaultWidth;i=e.values[a]||e.values[s]}const o=e.argumentCallback?e.argumentCallback(t):t;return i[o]}}const sk={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},ak={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},lk={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},uk={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},ck={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},dk={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},fk=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},hk={ordinalNumber:fk,era:Ii({values:sk,defaultWidth:"wide"}),quarter:Ii({values:ak,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Ii({values:lk,defaultWidth:"wide"}),day:Ii({values:uk,defaultWidth:"wide"}),dayPeriod:Ii({values:ck,defaultWidth:"wide",formattingValues:dk,defaultFormattingWidth:"wide"})};function Ui(e){return(t,n={})=>{const r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],o=t.match(i);if(!o)return null;const s=o[0],a=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(a)?mk(a,d=>d.test(s)):pk(a,d=>d.test(s));let u;u=e.valueCallback?e.valueCallback(l):l,u=n.valueCallback?n.valueCallback(u):u;const c=t.slice(s.length);return{value:u,rest:c}}}function pk(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function mk(e,t){for(let n=0;n{const r=t.match(e.matchPattern);if(!r)return null;const i=r[0],o=t.match(e.parsePattern);if(!o)return null;let s=e.valueCallback?e.valueCallback(o[0]):o[0];s=n.valueCallback?n.valueCallback(s):s;const a=t.slice(i.length);return{value:s,rest:a}}}const gk=/^(\d+)(th|st|nd|rd)?/i,vk=/\d+/i,wk={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Sk={any:[/^b/i,/^(a|c)/i]},xk={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Ek={any:[/1/i,/2/i,/3/i,/4/i]},_k={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Ck={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},kk={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Pk={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},jk={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Nk={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Rk={ordinalNumber:yk({matchPattern:gk,parsePattern:vk,valueCallback:e=>parseInt(e,10)}),era:Ui({matchPatterns:wk,defaultMatchWidth:"wide",parsePatterns:Sk,defaultParseWidth:"any"}),quarter:Ui({matchPatterns:xk,defaultMatchWidth:"wide",parsePatterns:Ek,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Ui({matchPatterns:_k,defaultMatchWidth:"wide",parsePatterns:Ck,defaultParseWidth:"any"}),day:Ui({matchPatterns:kk,defaultMatchWidth:"wide",parsePatterns:Pk,defaultParseWidth:"any"}),dayPeriod:Ui({matchPatterns:jk,defaultMatchWidth:"any",parsePatterns:Nk,defaultParseWidth:"any"})},Ok={code:"en-US",formatDistance:ZC,formatLong:rk,formatRelative:ok,localize:hk,match:Rk,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Tk(e){const t=dn(e);return YC(t,XC(t))+1}function Dk(e){const t=dn(e),n=+Sa(t)-+QC(t);return Math.trunc(n/hv)+1}function gv(e,t){var c,d,h,w;const n=dn(e),r=n.getFullYear(),i=Ga(),o=(t==null?void 0:t.firstWeekContainsDate)??((d=(c=t==null?void 0:t.locale)==null?void 0:c.options)==null?void 0:d.firstWeekContainsDate)??i.firstWeekContainsDate??((w=(h=i.locale)==null?void 0:h.options)==null?void 0:w.firstWeekContainsDate)??1,s=Pr(e,0);s.setFullYear(r+1,0,o),s.setHours(0,0,0,0);const a=No(s,t),l=Pr(e,0);l.setFullYear(r,0,o),l.setHours(0,0,0,0);const u=No(l,t);return n.getTime()>=a.getTime()?r+1:n.getTime()>=u.getTime()?r:r-1}function bk(e,t){var a,l,u,c;const n=Ga(),r=(t==null?void 0:t.firstWeekContainsDate)??((l=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:l.firstWeekContainsDate)??n.firstWeekContainsDate??((c=(u=n.locale)==null?void 0:u.options)==null?void 0:c.firstWeekContainsDate)??1,i=gv(e,t),o=Pr(e,0);return o.setFullYear(i,0,r),o.setHours(0,0,0,0),No(o,t)}function Lk(e,t){const n=dn(e),r=+No(n,t)-+bk(n,t);return Math.trunc(r/hv)+1}function fe(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const Dn={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return fe(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):fe(n+1,2)},d(e,t){return fe(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return fe(e.getHours()%12||12,t.length)},H(e,t){return fe(e.getHours(),t.length)},m(e,t){return fe(e.getMinutes(),t.length)},s(e,t){return fe(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),i=Math.trunc(r*Math.pow(10,n-3));return fe(i,t.length)}},Ir={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Zh={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),i=r>0?r:1-r;return n.ordinalNumber(i,{unit:"year"})}return Dn.y(e,t)},Y:function(e,t,n,r){const i=gv(e,r),o=i>0?i:1-i;if(t==="YY"){const s=o%100;return fe(s,2)}return t==="Yo"?n.ordinalNumber(o,{unit:"year"}):fe(o,t.length)},R:function(e,t){const n=yv(e);return fe(n,t.length)},u:function(e,t){const n=e.getFullYear();return fe(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return fe(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return fe(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return Dn.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return fe(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const i=Lk(e,r);return t==="wo"?n.ordinalNumber(i,{unit:"week"}):fe(i,t.length)},I:function(e,t,n){const r=Dk(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):fe(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):Dn.d(e,t)},D:function(e,t,n){const r=Tk(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):fe(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const i=e.getDay(),o=(i-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(o);case"ee":return fe(o,2);case"eo":return n.ordinalNumber(o,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});case"eeee":default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const i=e.getDay(),o=(i-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(o);case"cc":return fe(o,t.length);case"co":return n.ordinalNumber(o,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});case"cccc":default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),i=r===0?7:r;switch(t){case"i":return String(i);case"ii":return fe(i,t.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const i=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let i;switch(r===12?i=Ir.noon:r===0?i=Ir.midnight:i=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let i;switch(r>=17?i=Ir.evening:r>=12?i=Ir.afternoon:r>=4?i=Ir.morning:i=Ir.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return Dn.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):Dn.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):fe(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):fe(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):Dn.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):Dn.s(e,t)},S:function(e,t){return Dn.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return tp(r);case"XXXX":case"XX":return lr(r);case"XXXXX":case"XXX":default:return lr(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return tp(r);case"xxxx":case"xx":return lr(r);case"xxxxx":case"xxx":default:return lr(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+ep(r,":");case"OOOO":default:return"GMT"+lr(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+ep(r,":");case"zzzz":default:return"GMT"+lr(r,":")}},t:function(e,t,n){const r=Math.trunc(e.getTime()/1e3);return fe(r,t.length)},T:function(e,t,n){const r=e.getTime();return fe(r,t.length)}};function ep(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),i=Math.trunc(r/60),o=r%60;return o===0?n+String(i):n+String(i)+t+fe(o,2)}function tp(e,t){return e%60===0?(e>0?"-":"+")+fe(Math.abs(e)/60,2):lr(e,t)}function lr(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),i=fe(Math.trunc(r/60),2),o=fe(r%60,2);return n+i+t+o}const np=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},vv=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},Mk=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return np(e,t);let o;switch(r){case"P":o=t.dateTime({width:"short"});break;case"PP":o=t.dateTime({width:"medium"});break;case"PPP":o=t.dateTime({width:"long"});break;case"PPPP":default:o=t.dateTime({width:"full"});break}return o.replace("{{date}}",np(r,t)).replace("{{time}}",vv(i,t))},Fk={p:vv,P:Mk},Ak=/^D+$/,Ik=/^Y+$/,Uk=["D","DD","YY","YYYY"];function zk(e){return Ak.test(e)}function $k(e){return Ik.test(e)}function Bk(e,t,n){const r=Wk(e,t,n);if(console.warn(r),Uk.includes(e))throw new RangeError(r)}function Wk(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Vk=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Hk=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,qk=/^'([^]*?)'?$/,Yk=/''/g,Qk=/[a-zA-Z]/;function Kk(e,t,n){var c,d,h,w,g,v,E,m;const r=Ga(),i=(n==null?void 0:n.locale)??r.locale??Ok,o=(n==null?void 0:n.firstWeekContainsDate)??((d=(c=n==null?void 0:n.locale)==null?void 0:c.options)==null?void 0:d.firstWeekContainsDate)??r.firstWeekContainsDate??((w=(h=r.locale)==null?void 0:h.options)==null?void 0:w.firstWeekContainsDate)??1,s=(n==null?void 0:n.weekStartsOn)??((v=(g=n==null?void 0:n.locale)==null?void 0:g.options)==null?void 0:v.weekStartsOn)??r.weekStartsOn??((m=(E=r.locale)==null?void 0:E.options)==null?void 0:m.weekStartsOn)??0,a=dn(e);if(!GC(a))throw new RangeError("Invalid time value");let l=t.match(Hk).map(p=>{const y=p[0];if(y==="p"||y==="P"){const C=Fk[y];return C(p,i.formatLong)}return p}).join("").match(Vk).map(p=>{if(p==="''")return{isToken:!1,value:"'"};const y=p[0];if(y==="'")return{isToken:!1,value:Gk(p)};if(Zh[y])return{isToken:!0,value:p};if(y.match(Qk))throw new RangeError("Format string contains an unescaped latin alphabet character `"+y+"`");return{isToken:!1,value:p}});i.localize.preprocessor&&(l=i.localize.preprocessor(a,l));const u={firstWeekContainsDate:o,weekStartsOn:s,locale:i};return l.map(p=>{if(!p.isToken)return p.value;const y=p.value;(!(n!=null&&n.useAdditionalWeekYearTokens)&&$k(y)||!(n!=null&&n.useAdditionalDayOfYearTokens)&&zk(y))&&Bk(y,t,String(e));const C=Zh[y[0]];return C(a,y,i.localize,u)}).join("")}function Gk(e){const t=e.match(qk);return t?t[1].replace(Yk,"'"):e}function Xk(e,t){const n=(t==null?void 0:t.additionalDigits)??2,r=tP(e);let i;if(r.date){const l=nP(r.date,n);i=rP(l.restDateString,l.year)}if(!i||isNaN(i.getTime()))return new Date(NaN);const o=i.getTime();let s=0,a;if(r.time&&(s=iP(r.time),isNaN(s)))return new Date(NaN);if(r.timezone){if(a=oP(r.timezone),isNaN(a))return new Date(NaN)}else{const l=new Date(o+s),u=new Date(0);return u.setFullYear(l.getUTCFullYear(),l.getUTCMonth(),l.getUTCDate()),u.setHours(l.getUTCHours(),l.getUTCMinutes(),l.getUTCSeconds(),l.getUTCMilliseconds()),u}return new Date(o+s+a)}const ys={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},Jk=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,Zk=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,eP=/^([+-])(\d{2})(?::?(\d{2}))?$/;function tP(e){const t={},n=e.split(ys.dateTimeDelimiter);let r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],ys.timeZoneDelimiter.test(t.date)&&(t.date=e.split(ys.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){const i=ys.timezone.exec(r);i?(t.time=r.replace(i[1],""),t.timezone=i[1]):t.time=r}return t}function nP(e,t){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),r=e.match(n);if(!r)return{year:NaN,restDateString:""};const i=r[1]?parseInt(r[1]):null,o=r[2]?parseInt(r[2]):null;return{year:o===null?i:o*100,restDateString:e.slice((r[1]||r[2]).length)}}function rP(e,t){if(t===null)return new Date(NaN);const n=e.match(Jk);if(!n)return new Date(NaN);const r=!!n[4],i=zi(n[1]),o=zi(n[2])-1,s=zi(n[3]),a=zi(n[4]),l=zi(n[5])-1;if(r)return cP(t,a,l)?sP(t,a,l):new Date(NaN);{const u=new Date(0);return!lP(t,o,s)||!uP(t,i)?new Date(NaN):(u.setUTCFullYear(t,o,Math.max(i,s)),u)}}function zi(e){return e?parseInt(e):1}function iP(e){const t=e.match(Zk);if(!t)return NaN;const n=Yl(t[1]),r=Yl(t[2]),i=Yl(t[3]);return dP(n,r,i)?n*mv+r*pv+i*1e3:NaN}function Yl(e){return e&&parseFloat(e.replace(",","."))||0}function oP(e){if(e==="Z")return 0;const t=e.match(eP);if(!t)return 0;const n=t[1]==="+"?-1:1,r=parseInt(t[2]),i=t[3]&&parseInt(t[3])||0;return fP(r,i)?n*(r*mv+i*pv):NaN}function sP(e,t,n){const r=new Date(0);r.setUTCFullYear(e,0,4);const i=r.getUTCDay()||7,o=(t-1)*7+n+1-i;return r.setUTCDate(r.getUTCDate()+o),r}const aP=[31,null,31,30,31,30,31,31,30,31,30,31];function wv(e){return e%400===0||e%4===0&&e%100!==0}function lP(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(aP[t]||(wv(e)?29:28))}function uP(e,t){return t>=1&&t<=(wv(e)?366:365)}function cP(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function dP(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function fP(e,t){return t>=0&&t<=59}const hP=()=>{const[e,t]=k.useState(!1),{register:n,handleSubmit:r,setValue:i}=Td(),[o,s]=k.useState(!1),{stationId:a}=vd();k.useEffect(()=>{(async()=>{if(a)try{const d=await ce.stations.stationsRead(a);i("name",d.data.name),i("location",d.data.location);const h=Xk(d.data.open_date),w=Kk(h,"yyyy-MM-dd'T'HH:mm");i("open_date",w),i("description",d.data.description),i("status",d.data.status.toString()),i("image_url",d.data.image_url)}catch(d){console.error("Ошибка при загрузке данных станции для редактирования:",d)}})()},[a,i]);const l=async c=>{s(!0),t(!1);try{const d=await ce.stations.stationsUpdate(a,c);console.log("Станция успешно обновлена:",d.data),t(!0)}catch(d){console.error("Ошибка при обновлении станции:",d)}finally{s(!1)}},u=async()=>{if(window.confirm("Вы уверены, что хотите удалить станцию?"))try{await ce.stations.stationsDelete(a),console.log("Станция успешно удалена")}catch(c){console.error("Ошибка при удалении станции:",c)}};return f.jsxs("div",{className:"container mt-5",children:[f.jsx("h1",{children:"Редактировать данные Станции"}),e&&f.jsx("div",{className:"alert alert-success",role:"alert",children:"Станция обновлена."}),f.jsxs("form",{onSubmit:r(l),children:[f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"name",className:"form-label",children:"Название станции:"}),f.jsx("input",{type:"text",className:"form-control",...n("name"),id:"name"})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"location",className:"form-label",children:"Местоположение:"}),f.jsx("input",{type:"text",className:"form-control",...n("location"),id:"location"})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"open_date",className:"form-label",children:"Дата открытия:"}),f.jsx("input",{type:"datetime-local",className:"form-control",...n("open_date"),id:"open_date"})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"description",className:"form-label",children:"Описание:"}),f.jsx("textarea",{className:"form-control",...n("description"),id:"description",rows:4})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"status",className:"form-label",children:"Статус:"}),f.jsxs("select",{className:"form-select",...n("status"),id:"status",children:[f.jsx("option",{value:"true",children:"Активная"}),f.jsx("option",{value:"false",children:"Неактивная"})]})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"image_url",className:"form-label",children:"URL изображения:"}),f.jsx("input",{type:"text",className:"form-control",...n("image_url"),id:"image_url"})]}),f.jsx("button",{type:"submit",className:"btn btn-primary",disabled:o,children:"Обновить станцию"}),f.jsx("button",{type:"button",className:"btn btn-danger ms-2",onClick:u,disabled:o,children:"Удалить станцию"})]})]})},pP=({measurement:e,stations:t})=>{const n=t.find(d=>d.station_id===e.weather_station),r=n==null?void 0:n.name,i=n==null?void 0:n.location,o=new Date(e.created_date).toLocaleString(),{measurement_id:s,temperature:a,humidity:l,wind_speed:u}=e,c=async()=>{try{await ce.measurements.measurementsDelete(s.toString())}catch{console.log("Unable to delete measure")}};return f.jsxs("tr",{children:[f.jsx("td",{children:r}),f.jsx("td",{children:i}),f.jsx("td",{children:o}),f.jsx("td",{children:a}),f.jsx("td",{children:l}),f.jsx("td",{children:u}),f.jsx("td",{children:f.jsx(pr,{onClick:c,children:"Удалить"})})]})},mP=()=>{const[e,t]=k.useState(!0),[n,r]=k.useState([]),[i,o]=k.useState([]),s=async()=>{try{t(!0);const l=await ce.stations.stationsList();o(l.data)}catch(l){console.error("Ошибка при получении станций:",l)}finally{t(!1)}},a=async()=>{try{t(!0);const l=await ce.measurements.measurementsList();r(l.data)}catch(l){console.error("Error fetching measurements:",l)}finally{t(!1)}};return k.useEffect(()=>{a(),s()},[]),e?f.jsx("div",{children:"Loading..."}):f.jsxs("div",{className:"container mt-5",children:[f.jsx("h1",{children:"Измерения"}),f.jsxs(Fg,{striped:!0,bordered:!0,hover:!0,children:[f.jsx("thead",{children:f.jsxs("tr",{children:[f.jsx("th",{children:"Станция"}),f.jsx("th",{children:"Город"}),f.jsx("th",{children:"Дата снятия"}),f.jsx("td",{children:"Температура"}),f.jsx("td",{children:"Влажность"}),f.jsx("td",{children:"Скорость ветра"})]})}),f.jsx("tbody",{children:n.map(l=>f.jsx(pP,{measurement:l,stations:i},l.measurement_id))})]})]})},yP=()=>{const e=gd(),[t,n]=k.useState(""),[r,i]=k.useState(""),[o,s]=k.useState(!1),[a,l]=k.useState(!1),u=async()=>{s(!1),l(!1);try{const c=await ce.users.usersCreate({email:t,password:r});console.log(c.status),c.status===200?(l(!0),e("/RIP-WeStatsApp/login")):s(!0)}catch(c){console.error("Ошибка при регистрации:",c),s(!0)}};return f.jsxs("div",{className:"mt-4",children:[f.jsx("h2",{className:"mb-4",children:"Регистрация"}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"email",className:"form-label",children:"Email:"}),f.jsx("input",{type:"email",id:"email",className:"form-control",value:t,onChange:c=>n(c.target.value)})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{htmlFor:"password",className:"form-label",children:"Пароль:"}),f.jsx("input",{type:"password",id:"password",className:"form-control",value:r,onChange:c=>i(c.target.value)})]}),f.jsx("button",{type:"submit",onClick:u,className:"btn btn-primary",children:"Зарегистрирваться"}),o&&f.jsx("div",{style:{color:"red"},children:"Неверные данные"}),a&&f.jsx("div",{style:{color:"green"},children:"Успешно!"})]})},nt="/RIP-WeStatsApp",gP=aE([{path:nt+"/",element:f.jsx(ps,{})},{path:nt+"/stations",element:f.jsx(iC,{})},{path:nt+"/stations/:stationId",element:f.jsx(sC,{})},{path:nt+"/measurements",element:f.jsx(VC,{})},{path:nt+"/login",element:f.jsx(lC,{})},{path:nt+"/signup",element:f.jsx(yP,{})},{path:nt+"/profile",element:f.jsx(mC,{})},{path:nt+"/profile/orders",element:f.jsx(zC,{})},{path:nt+"/profile/orders/current",element:f.jsx(Gh,{})},{path:nt+"/profile/orders/:orderId",element:f.jsx(Gh,{})},{path:nt+"/uploadmeasure",element:f.jsx(MC,{})},{path:nt+"/admin/perms",element:f.jsx(AC,{})},{path:nt+"/admin/orders",element:f.jsx(BC,{})},{path:nt+"/admin/addstation",element:f.jsx(IC,{})},{path:nt+"/admin/editstation/:stationId",element:f.jsx(hP,{})},{path:nt+"/admin/editmeasurements",element:f.jsx(mP,{})},{path:"/a",element:f.jsx(ps,{})},{path:"b",element:f.jsx(ps,{})},{path:"/c/",element:f.jsx(ps,{})}]),vP=()=>f.jsxs("div",{children:[f.jsx(ex,{}),f.jsx("hr",{}),f.jsx(yE,{router:gP}),f.jsx(aC,{})]});Kl.createRoot(document.getElementById("root")).render(f.jsx(pt.StrictMode,{children:f.jsx(g1,{store:Ky,children:f.jsx(_y,{loading:null,persistor:ZS,children:f.jsx("div",{className:"w-100",children:f.jsx(vP,{})})})})})); diff --git a/index.html b/index.html index 1fbad8c..5fd18a4 100644 --- a/index.html +++ b/index.html @@ -31,7 +31,7 @@ - +