import{r as Ue,g as Ct,a as Ke}from"./vendor-BtP0CW_r.js";function wt(e,r){for(var n=0;n<r.length;n++){const s=r[n];if(typeof s!="string"&&!Array.isArray(s)){for(const l in s)if(l!=="default"&&!(l in e)){const i=Object.getOwnPropertyDescriptor(s,l);i&&Object.defineProperty(e,l,i.get?i:{enumerable:!0,get:()=>s[l]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))s(l);new MutationObserver(l=>{for(const i of l)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function n(l){const i={};return l.integrity&&(i.integrity=l.integrity),l.referrerPolicy&&(i.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?i.credentials="include":l.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(l){if(l.ep)return;l.ep=!0;const i=n(l);fetch(l.href,i)}})();var ge={exports:{}},Y={};/**
 * @license React
 * react-jsx-runtime.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Be;function Et(){if(Be)return Y;Be=1;var e=Ue(),r=Symbol.for("react.element"),n=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,l=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(m,h,g){var u,x={},b=null,C=null;g!==void 0&&(b=""+g),h.key!==void 0&&(b=""+h.key),h.ref!==void 0&&(C=h.ref);for(u in h)s.call(h,u)&&!i.hasOwnProperty(u)&&(x[u]=h[u]);if(m&&m.defaultProps)for(u in h=m.defaultProps,h)x[u]===void 0&&(x[u]=h[u]);return{$$typeof:r,type:m,key:b,ref:C,props:x,_owner:l.current}}return Y.Fragment=n,Y.jsx=o,Y.jsxs=o,Y}var Ae;function _t(){return Ae||(Ae=1,ge.exports=Et()),ge.exports}var t=_t(),d=Ue();const kt=Ct(d),Rt=wt({__proto__:null,default:kt},[d]);var oe={},Fe;function Pt(){if(Fe)return oe;Fe=1;var e=Ke();return oe.createRoot=e.createRoot,oe.hydrateRoot=e.hydrateRoot,oe}var Ot=Pt();Ke();/**
 * @remix-run/router v1.23.2
 *
 * Copyright (c) Remix Software Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.md file in the root directory of this source tree.
 *
 * @license MIT
 */function Z(){return Z=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},Z.apply(this,arguments)}var A;(function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"})(A||(A={}));const $e="popstate";function Tt(e){e===void 0&&(e={});function r(s,l){let{pathname:i,search:o,hash:m}=s.location;return ye("",{pathname:i,search:o,hash:m},l.state&&l.state.usr||null,l.state&&l.state.key||"default")}function n(s,l){return typeof l=="string"?l:ce(l)}return It(r,n,null,e)}function k(e,r){if(e===!1||e===null||typeof e>"u")throw new Error(r)}function Se(e,r){if(!e){typeof console<"u"&&console.warn(r);try{throw new Error(r)}catch{}}}function Lt(){return Math.random().toString(36).substr(2,8)}function ze(e,r){return{usr:e.state,key:e.key,idx:r}}function ye(e,r,n,s){return n===void 0&&(n=null),Z({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof r=="string"?U(r):r,{state:n,key:r&&r.key||s||Lt()})}function ce(e){let{pathname:r="/",search:n="",hash:s=""}=e;return n&&n!=="?"&&(r+=n.charAt(0)==="?"?n:"?"+n),s&&s!=="#"&&(r+=s.charAt(0)==="#"?s:"#"+s),r}function U(e){let r={};if(e){let n=e.indexOf("#");n>=0&&(r.hash=e.substr(n),e=e.substr(0,n));let s=e.indexOf("?");s>=0&&(r.search=e.substr(s),e=e.substr(0,s)),e&&(r.pathname=e)}return r}function It(e,r,n,s){s===void 0&&(s={});let{window:l=document.defaultView,v5Compat:i=!1}=s,o=l.history,m=A.Pop,h=null,g=u();g==null&&(g=0,o.replaceState(Z({},o.state,{idx:g}),""));function u(){return(o.state||{idx:null}).idx}function x(){m=A.Pop;let y=u(),N=y==null?null:y-g;g=y,h&&h({action:m,location:v.location,delta:N})}function b(y,N){m=A.Push;let R=ye(v.location,y,N);g=u()+1;let E=ze(R,g),P=v.createHref(R);try{o.pushState(E,"",P)}catch(B){if(B instanceof DOMException&&B.name==="DataCloneError")throw B;l.location.assign(P)}i&&h&&h({action:m,location:v.location,delta:1})}function C(y,N){m=A.Replace;let R=ye(v.location,y,N);g=u();let E=ze(R,g),P=v.createHref(R);o.replaceState(E,"",P),i&&h&&h({action:m,location:v.location,delta:0})}function w(y){let N=l.location.origin!=="null"?l.location.origin:l.location.href,R=typeof y=="string"?y:ce(y);return R=R.replace(/ $/,"%20"),k(N,"No window.location.(origin|href) available to create URL for href: "+R),new URL(R,N)}let v={get action(){return m},get location(){return e(l,o)},listen(y){if(h)throw new Error("A history only accepts one active listener");return l.addEventListener($e,x),h=y,()=>{l.removeEventListener($e,x),h=null}},createHref(y){return r(l,y)},createURL:w,encodeLocation(y){let N=w(y);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:b,replace:C,go(y){return o.go(y)}};return v}var De;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(De||(De={}));function Bt(e,r,n){return n===void 0&&(n="/"),At(e,r,n)}function At(e,r,n,s){let l=typeof r=="string"?U(r):r,i=Ne(l.pathname||"/",n);if(i==null)return null;let o=He(e);Ft(o);let m=null;for(let h=0;m==null&&h<o.length;++h){let g=Ht(i);m=Vt(o[h],g)}return m}function He(e,r,n,s){r===void 0&&(r=[]),n===void 0&&(n=[]),s===void 0&&(s="");let l=(i,o,m)=>{let h={relativePath:m===void 0?i.path||"":m,caseSensitive:i.caseSensitive===!0,childrenIndex:o,route:i};h.relativePath.startsWith("/")&&(k(h.relativePath.startsWith(s),'Absolute route path "'+h.relativePath+'" nested under path '+('"'+s+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),h.relativePath=h.relativePath.slice(s.length));let g=F([s,h.relativePath]),u=n.concat(h);i.children&&i.children.length>0&&(k(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+g+'".')),He(i.children,r,u,g)),!(i.path==null&&!i.index)&&r.push({path:g,score:Xt(g,i.index),routesMeta:u})};return e.forEach((i,o)=>{var m;if(i.path===""||!((m=i.path)!=null&&m.includes("?")))l(i,o);else for(let h of Qe(i.path))l(i,o,h)}),r}function Qe(e){let r=e.split("/");if(r.length===0)return[];let[n,...s]=r,l=n.endsWith("?"),i=n.replace(/\?$/,"");if(s.length===0)return l?[i,""]:[i];let o=Qe(s.join("/")),m=[];return m.push(...o.map(h=>h===""?i:[i,h].join("/"))),l&&m.push(...o),m.map(h=>e.startsWith("/")&&h===""?"/":h)}function Ft(e){e.sort((r,n)=>r.score!==n.score?n.score-r.score:Jt(r.routesMeta.map(s=>s.childrenIndex),n.routesMeta.map(s=>s.childrenIndex)))}const $t=/^:[\w-]+$/,zt=3,Dt=2,qt=1,Mt=10,Wt=-2,qe=e=>e==="*";function Xt(e,r){let n=e.split("/"),s=n.length;return n.some(qe)&&(s+=Wt),r&&(s+=Dt),n.filter(l=>!qe(l)).reduce((l,i)=>l+($t.test(i)?zt:i===""?qt:Mt),s)}function Jt(e,r){return e.length===r.length&&e.slice(0,-1).every((s,l)=>s===r[l])?e[e.length-1]-r[r.length-1]:0}function Vt(e,r,n){let{routesMeta:s}=e,l={},i="/",o=[];for(let m=0;m<s.length;++m){let h=s[m],g=m===s.length-1,u=i==="/"?r:r.slice(i.length)||"/",x=Ut({path:h.relativePath,caseSensitive:h.caseSensitive,end:g},u),b=h.route;if(!x)return null;Object.assign(l,x.params),o.push({params:l,pathname:F([i,x.pathname]),pathnameBase:ea(F([i,x.pathnameBase])),route:b}),x.pathnameBase!=="/"&&(i=F([i,x.pathnameBase]))}return o}function Ut(e,r){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,s]=Kt(e.path,e.caseSensitive,e.end),l=r.match(n);if(!l)return null;let i=l[0],o=i.replace(/(.)\/+$/,"$1"),m=l.slice(1);return{params:s.reduce((g,u,x)=>{let{paramName:b,isOptional:C}=u;if(b==="*"){let v=m[x]||"";o=i.slice(0,i.length-v.length).replace(/(.)\/+$/,"$1")}const w=m[x];return C&&!w?g[b]=void 0:g[b]=(w||"").replace(/%2F/g,"/"),g},{}),pathname:i,pathnameBase:o,pattern:e}}function Kt(e,r,n){r===void 0&&(r=!1),n===void 0&&(n=!0),Se(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let s=[],l="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,m,h)=>(s.push({paramName:m,isOptional:h!=null}),h?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(s.push({paramName:"*"}),l+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?l+="\\/*$":e!==""&&e!=="/"&&(l+="(?:(?=\\/|$))"),[new RegExp(l,r?void 0:"i"),s]}function Ht(e){try{return e.split("/").map(r=>decodeURIComponent(r).replace(/\//g,"%2F")).join("/")}catch(r){return Se(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+r+").")),e}}function Ne(e,r){if(r==="/")return e;if(!e.toLowerCase().startsWith(r.toLowerCase()))return null;let n=r.endsWith("/")?r.length-1:r.length,s=e.charAt(n);return s&&s!=="/"?null:e.slice(n)||"/"}const Qt=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Yt=e=>Qt.test(e);function Gt(e,r){r===void 0&&(r="/");let{pathname:n,search:s="",hash:l=""}=typeof e=="string"?U(e):e,i;if(n)if(Yt(n))i=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),Se(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?i=Me(n.substring(1),"/"):i=Me(n,r)}else i=r;return{pathname:i,search:ta(s),hash:aa(l)}}function Me(e,r){let n=r.replace(/\/+$/,"").split("/");return e.split("/").forEach(l=>{l===".."?n.length>1&&n.pop():l!=="."&&n.push(l)}),n.length>1?n.join("/"):"/"}function ve(e,r,n,s){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+r+"` field ["+JSON.stringify(s)+"].  Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function Zt(e){return e.filter((r,n)=>n===0||r.route.path&&r.route.path.length>0)}function Ye(e,r){let n=Zt(e);return r?n.map((s,l)=>l===n.length-1?s.pathname:s.pathnameBase):n.map(s=>s.pathnameBase)}function Ge(e,r,n,s){s===void 0&&(s=!1);let l;typeof e=="string"?l=U(e):(l=Z({},e),k(!l.pathname||!l.pathname.includes("?"),ve("?","pathname","search",l)),k(!l.pathname||!l.pathname.includes("#"),ve("#","pathname","hash",l)),k(!l.search||!l.search.includes("#"),ve("#","search","hash",l)));let i=e===""||l.pathname==="",o=i?"/":l.pathname,m;if(o==null)m=n;else{let x=r.length-1;if(!s&&o.startsWith("..")){let b=o.split("/");for(;b[0]==="..";)b.shift(),x-=1;l.pathname=b.join("/")}m=x>=0?r[x]:"/"}let h=Gt(l,m),g=o&&o!=="/"&&o.endsWith("/"),u=(i||o===".")&&n.endsWith("/");return!h.pathname.endsWith("/")&&(g||u)&&(h.pathname+="/"),h}const F=e=>e.join("/").replace(/\/\/+/g,"/"),ea=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),ta=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,aa=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function ra(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const Ze=["post","put","patch","delete"];new Set(Ze);const na=["get",...Ze];new Set(na);/**
 * React Router v6.30.3
 *
 * Copyright (c) Remix Software Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.md file in the root directory of this source tree.
 *
 * @license MIT
 */function ee(){return ee=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},ee.apply(this,arguments)}const Ce=d.createContext(null),sa=d.createContext(null),z=d.createContext(null),de=d.createContext(null),D=d.createContext({outlet:null,matches:[],isDataRoute:!1}),et=d.createContext(null);function la(e,r){let{relative:n}=r===void 0?{}:r;te()||k(!1);let{basename:s,navigator:l}=d.useContext(z),{hash:i,pathname:o,search:m}=rt(e,{relative:n}),h=o;return s!=="/"&&(h=o==="/"?s:F([s,o])),l.createHref({pathname:h,search:m,hash:i})}function te(){return d.useContext(de)!=null}function ae(){return te()||k(!1),d.useContext(de).location}function tt(e){d.useContext(z).static||d.useLayoutEffect(e)}function at(){let{isDataRoute:e}=d.useContext(D);return e?ya():ia()}function ia(){te()||k(!1);let e=d.useContext(Ce),{basename:r,future:n,navigator:s}=d.useContext(z),{matches:l}=d.useContext(D),{pathname:i}=ae(),o=JSON.stringify(Ye(l,n.v7_relativeSplatPath)),m=d.useRef(!1);return tt(()=>{m.current=!0}),d.useCallback(function(g,u){if(u===void 0&&(u={}),!m.current)return;if(typeof g=="number"){s.go(g);return}let x=Ge(g,JSON.parse(o),i,u.relative==="path");e==null&&r!=="/"&&(x.pathname=x.pathname==="/"?r:F([r,x.pathname])),(u.replace?s.replace:s.push)(x,u.state,u)},[r,s,o,i,e])}function rt(e,r){let{relative:n}=r===void 0?{}:r,{future:s}=d.useContext(z),{matches:l}=d.useContext(D),{pathname:i}=ae(),o=JSON.stringify(Ye(l,s.v7_relativeSplatPath));return d.useMemo(()=>Ge(e,JSON.parse(o),i,n==="path"),[e,o,i,n])}function oa(e,r){return ca(e,r)}function ca(e,r,n,s){te()||k(!1);let{navigator:l}=d.useContext(z),{matches:i}=d.useContext(D),o=i[i.length-1],m=o?o.params:{};o&&o.pathname;let h=o?o.pathnameBase:"/";o&&o.route;let g=ae(),u;if(r){var x;let y=typeof r=="string"?U(r):r;h==="/"||(x=y.pathname)!=null&&x.startsWith(h)||k(!1),u=y}else u=g;let b=u.pathname||"/",C=b;if(h!=="/"){let y=h.replace(/^\//,"").split("/");C="/"+b.replace(/^\//,"").split("/").slice(y.length).join("/")}let w=Bt(e,{pathname:C}),v=ma(w&&w.map(y=>Object.assign({},y,{params:Object.assign({},m,y.params),pathname:F([h,l.encodeLocation?l.encodeLocation(y.pathname).pathname:y.pathname]),pathnameBase:y.pathnameBase==="/"?h:F([h,l.encodeLocation?l.encodeLocation(y.pathnameBase).pathname:y.pathnameBase])})),i,n,s);return r&&v?d.createElement(de.Provider,{value:{location:ee({pathname:"/",search:"",hash:"",state:null,key:"default"},u),navigationType:A.Pop}},v):v}function da(){let e=va(),r=ra(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,l={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return d.createElement(d.Fragment,null,d.createElement("h2",null,"Unexpected Application Error!"),d.createElement("h3",{style:{fontStyle:"italic"}},r),n?d.createElement("pre",{style:l},n):null,null)}const ua=d.createElement(da,null);class ha extends d.Component{constructor(r){super(r),this.state={location:r.location,revalidation:r.revalidation,error:r.error}}static getDerivedStateFromError(r){return{error:r}}static getDerivedStateFromProps(r,n){return n.location!==r.location||n.revalidation!=="idle"&&r.revalidation==="idle"?{error:r.error,location:r.location,revalidation:r.revalidation}:{error:r.error!==void 0?r.error:n.error,location:n.location,revalidation:r.revalidation||n.revalidation}}componentDidCatch(r,n){console.error("React Router caught the following error during render",r,n)}render(){return this.state.error!==void 0?d.createElement(D.Provider,{value:this.props.routeContext},d.createElement(et.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function pa(e){let{routeContext:r,match:n,children:s}=e,l=d.useContext(Ce);return l&&l.static&&l.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(l.staticContext._deepestRenderedBoundaryId=n.route.id),d.createElement(D.Provider,{value:r},s)}function ma(e,r,n,s){var l;if(r===void 0&&(r=[]),n===void 0&&(n=null),s===void 0&&(s=null),e==null){var i;if(!n)return null;if(n.errors)e=n.matches;else if((i=s)!=null&&i.v7_partialHydration&&r.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let o=e,m=(l=n)==null?void 0:l.errors;if(m!=null){let u=o.findIndex(x=>x.route.id&&(m==null?void 0:m[x.route.id])!==void 0);u>=0||k(!1),o=o.slice(0,Math.min(o.length,u+1))}let h=!1,g=-1;if(n&&s&&s.v7_partialHydration)for(let u=0;u<o.length;u++){let x=o[u];if((x.route.HydrateFallback||x.route.hydrateFallbackElement)&&(g=u),x.route.id){let{loaderData:b,errors:C}=n,w=x.route.loader&&b[x.route.id]===void 0&&(!C||C[x.route.id]===void 0);if(x.route.lazy||w){h=!0,g>=0?o=o.slice(0,g+1):o=[o[0]];break}}}return o.reduceRight((u,x,b)=>{let C,w=!1,v=null,y=null;n&&(C=m&&x.route.id?m[x.route.id]:void 0,v=x.route.errorElement||ua,h&&(g<0&&b===0?(ja("route-fallback"),w=!0,y=null):g===b&&(w=!0,y=x.route.hydrateFallbackElement||null)));let N=r.concat(o.slice(0,b+1)),R=()=>{let E;return C?E=v:w?E=y:x.route.Component?E=d.createElement(x.route.Component,null):x.route.element?E=x.route.element:E=u,d.createElement(pa,{match:x,routeContext:{outlet:u,matches:N,isDataRoute:n!=null},children:E})};return n&&(x.route.ErrorBoundary||x.route.errorElement||b===0)?d.createElement(ha,{location:n.location,revalidation:n.revalidation,component:v,error:C,children:R(),routeContext:{outlet:null,matches:N,isDataRoute:!0}}):R()},null)}var nt=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(nt||{}),st=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(st||{});function fa(e){let r=d.useContext(Ce);return r||k(!1),r}function xa(e){let r=d.useContext(sa);return r||k(!1),r}function ga(e){let r=d.useContext(D);return r||k(!1),r}function lt(e){let r=ga(),n=r.matches[r.matches.length-1];return n.route.id||k(!1),n.route.id}function va(){var e;let r=d.useContext(et),n=xa(),s=lt();return r!==void 0?r:(e=n.errors)==null?void 0:e[s]}function ya(){let{router:e}=fa(nt.UseNavigateStable),r=lt(st.UseNavigateStable),n=d.useRef(!1);return tt(()=>{n.current=!0}),d.useCallback(function(l,i){i===void 0&&(i={}),n.current&&(typeof l=="number"?e.navigate(l):e.navigate(l,ee({fromRouteId:r},i)))},[e,r])}const We={};function ja(e,r,n){We[e]||(We[e]=!0)}function ba(e,r){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function G(e){k(!1)}function Sa(e){let{basename:r="/",children:n=null,location:s,navigationType:l=A.Pop,navigator:i,static:o=!1,future:m}=e;te()&&k(!1);let h=r.replace(/^\/*/,"/"),g=d.useMemo(()=>({basename:h,navigator:i,static:o,future:ee({v7_relativeSplatPath:!1},m)}),[h,m,i,o]);typeof s=="string"&&(s=U(s));let{pathname:u="/",search:x="",hash:b="",state:C=null,key:w="default"}=s,v=d.useMemo(()=>{let y=Ne(u,h);return y==null?null:{location:{pathname:y,search:x,hash:b,state:C,key:w},navigationType:l}},[h,u,x,b,C,w,l]);return v==null?null:d.createElement(z.Provider,{value:g},d.createElement(de.Provider,{children:n,value:v}))}function Na(e){let{children:r,location:n}=e;return oa(je(r),n)}new Promise(()=>{});function je(e,r){r===void 0&&(r=[]);let n=[];return d.Children.forEach(e,(s,l)=>{if(!d.isValidElement(s))return;let i=[...r,l];if(s.type===d.Fragment){n.push.apply(n,je(s.props.children,i));return}s.type!==G&&k(!1),!s.props.index||!s.props.children||k(!1);let o={id:s.props.id||i.join("-"),caseSensitive:s.props.caseSensitive,element:s.props.element,Component:s.props.Component,index:s.props.index,path:s.props.path,loader:s.props.loader,action:s.props.action,errorElement:s.props.errorElement,ErrorBoundary:s.props.ErrorBoundary,hasErrorBoundary:s.props.ErrorBoundary!=null||s.props.errorElement!=null,shouldRevalidate:s.props.shouldRevalidate,handle:s.props.handle,lazy:s.props.lazy};s.props.children&&(o.children=je(s.props.children,i)),n.push(o)}),n}/**
 * React Router DOM v6.30.3
 *
 * Copyright (c) Remix Software Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.md file in the root directory of this source tree.
 *
 * @license MIT
 */function be(){return be=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},be.apply(this,arguments)}function Ca(e,r){if(e==null)return{};var n={},s=Object.keys(e),l,i;for(i=0;i<s.length;i++)l=s[i],!(r.indexOf(l)>=0)&&(n[l]=e[l]);return n}function wa(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Ea(e,r){return e.button===0&&(!r||r==="_self")&&!wa(e)}const _a=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],ka="6";try{window.__reactRouterVersion=ka}catch{}const Ra="startTransition",Xe=Rt[Ra];function Pa(e){let{basename:r,children:n,future:s,window:l}=e,i=d.useRef();i.current==null&&(i.current=Tt({window:l,v5Compat:!0}));let o=i.current,[m,h]=d.useState({action:o.action,location:o.location}),{v7_startTransition:g}=s||{},u=d.useCallback(x=>{g&&Xe?Xe(()=>h(x)):h(x)},[h,g]);return d.useLayoutEffect(()=>o.listen(u),[o,u]),d.useEffect(()=>ba(s),[s]),d.createElement(Sa,{basename:r,children:n,location:m.location,navigationType:m.action,navigator:o,future:s})}const Oa=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ta=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,La=d.forwardRef(function(r,n){let{onClick:s,relative:l,reloadDocument:i,replace:o,state:m,target:h,to:g,preventScrollReset:u,viewTransition:x}=r,b=Ca(r,_a),{basename:C}=d.useContext(z),w,v=!1;if(typeof g=="string"&&Ta.test(g)&&(w=g,Oa))try{let E=new URL(window.location.href),P=g.startsWith("//")?new URL(E.protocol+g):new URL(g),B=Ne(P.pathname,C);P.origin===E.origin&&B!=null?g=B+P.search+P.hash:v=!0}catch{}let y=la(g,{relative:l}),N=Ia(g,{replace:o,state:m,target:h,preventScrollReset:u,relative:l,viewTransition:x});function R(E){s&&s(E),E.defaultPrevented||N(E)}return d.createElement("a",be({},b,{href:w||y,onClick:v||i?s:R,ref:n,target:h}))});var Je;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(Je||(Je={}));var Ve;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Ve||(Ve={}));function Ia(e,r){let{target:n,replace:s,state:l,preventScrollReset:i,relative:o,viewTransition:m}=r===void 0?{}:r,h=at(),g=ae(),u=rt(e,{relative:o});return d.useCallback(x=>{if(Ea(x,n)){x.preventDefault();let b=s!==void 0?s:ce(g)===ce(u);h(e,{replace:b,state:l,preventScrollReset:i,relative:o,viewTransition:m})}},[g,h,u,s,l,n,e,i,o,m])}const Ba=[{id:1,name:"دجاج محمر",image:"/images/Djaj Lm7amar.jpg",hasPartChoice:!0},{id:2,name:"بسطيلة بالحوت",image:"/images/Basstila b Djaj.jpg",hasPartChoice:!1},{id:3,name:"طاجين اللحم بالبرقوق",image:"/images/L7am blbar9o9.jpg",hasPartChoice:!1},{id:4,name:"اللحم المشوي",image:"/images/L7am Machwi.jpg",hasPartChoice:!1}],Aa=[{value:"0.25kg",label:"0.25kg"},{value:"0.5kg",label:"0.5kg"},{value:"0.75kg",label:"0.75kg"},{value:"1kg",label:"1kg"},{value:"1.25kg",label:"1.25kg"},{value:"1.5kg",label:"1.5kg"},{value:"1.75kg",label:"1.75kg"},{value:"2kg",label:"2kg"}],Fa=[{value:"cuisse",label:"فخذ"},{value:"blanc",label:"صدر"},{value:"aile",label:"جناح"},{value:"dos",label:"ظهر"},{value:"entier",label:"كامل"}];function $a(){var Le;const[e,r]=d.useState(()=>localStorage.getItem("zarreda_dark_mode")==="true");d.useEffect(()=>{localStorage.setItem("zarreda_dark_mode",e),e?document.body.classList.add("dark-mode"):document.body.classList.remove("dark-mode")},[e]);const[n,s]=d.useState(()=>{const a=localStorage.getItem("zarreda_cart_items");return a?JSON.parse(a):[]}),[l,i]=d.useState(()=>{const a=localStorage.getItem("zarreda_cart_quantities");return a?JSON.parse(a):{}}),[o,m]=d.useState(()=>{const a=localStorage.getItem("zarreda_cart_parts");return a?JSON.parse(a):{}}),[h,g]=d.useState(!1),[u,x]=d.useState({clientName:"",location:"",area:"",phone:"",notes:""}),[b,C]=d.useState({}),[w,v]=d.useState(null),[y,N]=d.useState(!0),[R,E]=d.useState(!1),[P,B]=d.useState([]),[ue,it]=d.useState(()=>localStorage.getItem("zarreda_admin_auth")==="true"),[p,he]=d.useState(()=>{const a=localStorage.getItem("zarreda_admin_user");return a?JSON.parse(a):null}),[K,we]=d.useState({username:"",password:""}),[pe,ot]=d.useState([]),[re,Ee]=d.useState([]),[L,_e]=d.useState(""),[_,T]=d.useState({name:"",username:"",password:"",role:"chef",area:""}),[$,me]=d.useState({receiver_id:"",amount:""}),[q,M]=d.useState(!1),[ct,ke]=d.useState(!1),[fe,Re]=d.useState(""),[ne,Pe]=d.useState("cod"),[W,X]=d.useState(!1),[O,H]=d.useState({}),[I,se]=d.useState({cardNumber:"",expiryDate:"",cvc:"",cardHolder:""}),J=at(),le="http://localhost:5000/order";d.useEffect(()=>{(async()=>{try{const f=await(await fetch("http://localhost:5000/staff/areas")).json();f.success&&Ee(f.areas)}catch(c){console.error("Error fetching areas:",c)}})()},[]),d.useEffect(()=>{localStorage.setItem("zarreda_cart_items",JSON.stringify(n)),localStorage.setItem("zarreda_cart_quantities",JSON.stringify(l)),localStorage.setItem("zarreda_cart_parts",JSON.stringify(o))},[n,l,o]);const dt=async()=>{M(!0);try{const a=[];Object.keys(O).forEach(j=>{typeof O[j]=="object"?Object.keys(O[j].parts).forEach(S=>{a.push({name:j,part:S,quantity:O[j].parts[S]})}):a.push({name:j,quantity:O[j]})});const f=await(await fetch("http://localhost:5000/order/stock/bulk",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({updates:a})})).json();f.success?(C(f.stock),H(f.stock),v({type:"success",message:"تم حفظ التغييرات بنجاح"}),setTimeout(()=>v(null),2e3)):(v({type:"error",message:f.message||"حدث خطأ أثناء حفظ التغييرات"}),setTimeout(()=>v(null),3e3))}catch(a){console.error("Erreur mise à jour stock bulk:",a),v({type:"error",message:"تعذر الاتصال بالخادم لحفظ التغييرات"}),setTimeout(()=>v(null),3e3)}finally{M(!1)}},V=async(a=p)=>{if(a){_.role==="sub_admin"&&a.role==="sub_admin"?T(c=>({...c,role:"chef",area:a.area||""})):a.role==="super_admin"&&_.role==="chef"&&!_.username&&T(c=>({...c,role:"sub_admin"}));try{const c=new URL("http://localhost:5000/staff");a.role==="sub_admin"&&c.searchParams.append("area",a.area);const j=await(await fetch(c)).json();j.success&&ot(j.staff)}catch(c){console.error("Erreur de chargement du staff:",c)}}};d.useEffect(()=>{(async()=>{try{console.log("Fetching stock from backend...");const f=await(await fetch(`${le}/stock?t=${Date.now()}`)).json();f.success?(C(f.stock),H(f.stock)):console.error("Failed to load stock:",f.message)}catch(c){console.error("Erreur de chargement du stock:",c)}finally{N(!1)}})(),ue&&V()},[ue]),d.useEffect(()=>{const a=c=>{(c.ctrlKey||c.metaKey)&&c.shiftKey&&c.key.toLowerCase()==="z"&&(c.preventDefault(),J("/zarreda-admin-hq"))};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[J]);const Q=a=>{const{name:c,value:f}=a.target;x(j=>({...j,[c]:f}))},ut=(a,c)=>{console.log("handleQuantityChange called with:",{product:a,quantity:c}),i(f=>({...f,[a.id]:c})),s(c&&c!==""?f=>f.find(S=>S.id===a.id)?f.map(S=>S.id===a.id?{...S,quantity:c,part:null}:S):[...f,{...a,quantity:c,part:null}]:f=>f.filter(j=>j.id!==a.id))},ht=(a,c)=>{console.log("handlePartChange called with:",{product:a,part:c}),m(f=>{const j={...f};return c?j[a.id]=c:delete j[a.id],j}),s(f=>f.map(j=>j.id===a.id?{...j,part:c}:j))},pt=a=>{s(c=>c.filter(f=>f.id!==a)),i(c=>{const f={...c};return delete f[a],f}),m(c=>{const f={...c};return delete f[a],f})},mt=()=>{v(null)},ft=()=>{const a=document.createElement("div");a.className="confetti-container",document.body.appendChild(a);for(let c=0;c<50;c++){const f=document.createElement("div");f.className="confetti",f.style.left=Math.random()*100+"vw",f.style.backgroundColor=["#d4af37","#8b4513","#cd853f","#ffffff"][Math.floor(Math.random()*4)],f.style.animationDelay=Math.random()*2+"s",a.appendChild(f)}setTimeout(()=>a.remove(),5e3)},Oe=async(a=null)=>{a&&a.preventDefault(),N(!0);try{const c={items:n.map(S=>({name:S.name,quantity:S.quantity,part:S.part})),...u};console.log("Sending order to backend:",c);const j=await(await fetch(le,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...c,paymentMethod:ne,...ne==="card"?I:{}})})).json();if(j.success)C(j.stock),H(j.stock),ft(),v({type:"success",message:"تم تسجيل الطلب بنجاح! سيتم التواصل معك قريباً."}),x({clientName:"",location:"",area:"",phone:"",notes:""}),s([]),i({}),m({}),E(!1),setTimeout(mt,3e3);else throw new Error(j.message||"Erreur lors de l'enregistrement")}catch(c){console.error("Erreur lors de l'enregistrement:",c),v({type:"error",message:c.message||"حدث خطأ أثناء تسجيل الطلب"}),setTimeout(()=>v(null),3e3)}finally{N(!1)}},xt=(a,c=null)=>{var j;if(!b[a])return"نفذ";if(a==="دجاج محمر")if(c){const S=parseFloat((j=b[a].parts)==null?void 0:j[c])||0;return S<=0?"نفذ":`${S} كيلوغرام متوفر`}else{const S=Object.values(b[a].parts||{}).reduce((xe,ie)=>xe+(parseFloat(ie)||0),0);return S<=0?"نفذ":`${S.toFixed(2)} الكمية الإجمالية`}const f=parseFloat(b[a])||0;return f<=0?"نفذ":`${f} كيلوغرام متوفر`},gt=()=>{E(!0)},vt=()=>{E(!1)},yt=async()=>{N(!0);try{const a=new URL(`${le}/all`);p&&p.role==="sub_admin"&&p.area&&a.searchParams.append("area",p.area);const f=await(await fetch(a)).json();f.success&&B(f.orders)}catch(a){console.error("Erreur de chargement des commandes:",a)}finally{N(!1)}},jt=async a=>{a.preventDefault(),N(!0);try{const f=await(await fetch("http://localhost:5000/staff/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(K)})).json();f.success?(it(!0),he(f.staff),localStorage.setItem("zarreda_admin_auth","true"),localStorage.setItem("zarreda_admin_user",JSON.stringify(f.staff)),v({type:"success",message:"تم تسجيل الدخول بنجاح"}),f.staff.role!=="super_admin"&&_e(""),setTimeout(()=>v(null),2e3),J("/admin/dashboard"),V(f.staff)):(v({type:"error",message:f.message||"بيانات الدخول غير صحيحة"}),setTimeout(()=>v(null),3e3))}catch(c){console.error("Login error:",c),v({type:"error",message:"حدث خطأ في الاتصال"}),setTimeout(()=>v(null),3e3)}finally{N(!1)}},Te=ae(),bt=async a=>{a.preventDefault(),M(!0);try{const c=p.role==="sub_admin"?p.area:_.area,f={..._,area:c,creatorRole:p.role,creatorArea:p.area},S=await(await fetch("http://localhost:5000/staff",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)})).json();if(S.success){v({type:"success",message:"تم إضافة العضو بنجاح"});const xe=p.role==="super_admin"?"sub_admin":"chef";if(T({name:"",username:"",password:"",role:xe,area:p.area||""}),V(),_.role==="sub_admin")try{const Ie=await(await fetch(`${le.replace("/order","/staff")}/areas`)).json();Ie.success&&Ee(Ie.areas)}catch(ie){console.error(ie)}}else v({type:"error",message:S.message||"خطأ في الإضافة"})}catch{v({type:"error",message:"خطأ في الاتصال"})}finally{M(!1),setTimeout(()=>v(null),3e3)}},St=async a=>{a.preventDefault(),M(!0);try{const c={sender_id:p.id,receiver_id:$.receiver_id,amount:$.amount},j=await(await fetch("http://localhost:5000/staff/transfer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)})).json();j.success?(v({type:"success",message:"تم تحويل الميزانية بنجاح"}),me({receiver_id:"",amount:""}),he(S=>({...S,balance:S.balance-parseFloat($.amount)})),V()):v({type:"error",message:j.message||"خطأ في التحويل"})}catch{v({type:"error",message:"خطأ في الاتصال"})}finally{M(!1),setTimeout(()=>v(null),3e3)}},Nt=async(a,c)=>{if(window.confirm(`هل أنت متأكد من حذف "${c}"؟`))try{const j=await(await fetch(`http://localhost:5000/staff/${a}`,{method:"DELETE"})).json();j.success?(v({type:"success",message:"تم حذف العضو بنجاح"}),V()):v({type:"error",message:j.message||"خطأ في الحذف"})}catch{v({type:"error",message:"خطأ في الاتصال"})}finally{setTimeout(()=>v(null),3e3)}};return d.useEffect(()=>{Te.pathname==="/admin/dashboard"&&p&&(yt(),V())},[Te.pathname,p]),y?t.jsxs("div",{className:"loading",children:[t.jsx("div",{className:"loader"}),t.jsx("p",{children:"جاري التحميل..."})]}):t.jsxs("div",{className:"app-container",children:[t.jsxs("header",{className:"header",children:[t.jsx(La,{to:"/",className:"main-title",children:"zarreda.com  تشهيتي؟"}),t.jsx("div",{className:"header-actions",children:t.jsx("button",{className:"theme-toggle",onClick:()=>r(!e),title:e?"Mode Clair":"Mode Sombre",children:e?"☀️":"🌙"})})]}),t.jsx("main",{className:"main-content",children:t.jsxs(Na,{children:[t.jsx(G,{path:"/zarreda-admin-hq",element:t.jsxs("div",{className:"login-container",children:[t.jsx("h2",{className:"section-title",children:"تسجيل الدخول للإدارة"}),t.jsxs("form",{onSubmit:jt,className:"order-form",style:{maxWidth:"400px",margin:"0 auto"},children:[t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:"اسم المستخدم"}),t.jsx("input",{type:"text",value:K.username,onChange:a=>we({...K,username:a.target.value}),required:!0,style:{direction:"ltr"}})]}),t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:"كلمة المرور"}),t.jsx("input",{type:"password",value:K.password,onChange:a=>we({...K,password:a.target.value}),required:!0,style:{direction:"ltr"}})]}),t.jsx("button",{type:"submit",className:"submit-order-btn",disabled:y,children:y?"جاري التحقق...":"دخول"})]})]})}),t.jsx(G,{path:"/admin/dashboard",element:ue?t.jsxs("div",{className:"admin-dashboard",children:[t.jsxs("div",{className:"dashboard-header",style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px",flexWrap:"wrap",gap:"10px"},children:[t.jsxs("h2",{className:"section-title",style:{margin:0},children:["لوحة التحكم - ",(p==null?void 0:p.role)==="super_admin"?"Super Admin":"Sub Admin"]}),(p==null?void 0:p.role)==="super_admin"&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",direction:"ltr"},children:[t.jsx("span",{style:{fontSize:"0.85rem",color:"var(--text-muted)",fontWeight:600},children:"🔍 Filter by Area:"}),t.jsxs("select",{value:L,onChange:a=>_e(a.target.value),style:{padding:"6px 10px",borderRadius:"6px",border:"1px solid rgba(0,0,0,0.15)",background:"var(--input-bg)",color:"var(--text-main)",fontSize:"0.85rem",cursor:"pointer"},children:[t.jsx("option",{value:"",children:"All Areas"}),re.map(a=>t.jsx("option",{value:a,children:a},a))]})]}),p&&t.jsxs("div",{className:"admin-info",style:{background:"var(--note-bg)",padding:"10px 15px",borderRadius:"5px",color:"var(--text-main)",fontSize:"14px",textAlign:"left",direction:"ltr"},children:[t.jsx("strong",{children:p.name}),t.jsx("br",{}),"Area: ",p.area||"All",t.jsx("br",{}),"Balance: ",ct?t.jsxs("div",{style:{display:"inline-flex",gap:"5px"},children:[t.jsx("input",{type:"number",value:fe,onChange:a=>Re(a.target.value),style:{width:"80px",padding:"2px 5px",borderRadius:"4px",border:"1px solid var(--secondary)"}}),t.jsx("button",{onClick:async()=>{try{(await fetch(`http://localhost:5000/staff/${p.id}/budget`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({amount:fe})})).ok&&(he(c=>({...c,balance:fe})),ke(!1),v({type:"success",message:"تم تحديث الرصيد"}),setTimeout(()=>v(null),2e3))}catch(a){console.error(a)}},className:"action-button-premium",style:{padding:"2px 8px",fontSize:"10px"},children:"Save"})]}):t.jsxs("strong",{style:{display:"flex",alignItems:"center"},children:[p.balance," MAD",p.role==="super_admin"&&t.jsx("button",{className:"balance-edit-btn",onClick:()=>{Re(p.balance),ke(!0)},title:"تعديل الرصيد",children:"✏️"})]})]})]}),t.jsxs("section",{className:"admin-section premium-admin-card",children:[t.jsx("h3",{children:"👥 إدارة الفريق"}),t.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem",marginBottom:"1.5rem",fontWeight:"500",opacity:.8},children:(p==null?void 0:p.role)==="super_admin"?"إضافة Sub Admin جديد للمنصة":`إضافة طاقم عمل لمنطقة ${p==null?void 0:p.area}`}),t.jsxs("form",{onSubmit:bt,className:"order-form",style:{gap:"15px"},children:[t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"12px"},children:[t.jsx("input",{type:"text",placeholder:"الاسم الكامل",value:_.name,onChange:a=>T({..._,name:a.target.value}),required:!0,className:"refined-input",style:{flex:"1 1 200px"}}),t.jsx("input",{type:"text",placeholder:"اسم المستخدم",value:_.username,onChange:a=>T({..._,username:a.target.value}),required:!0,className:"refined-input",style:{flex:"1 1 200px"}})]}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"12px",alignItems:"center"},children:[(p==null?void 0:p.role)==="super_admin"?t.jsxs(t.Fragment,{children:[t.jsxs("select",{value:_.role,onChange:a=>{const c=a.target.value;T({..._,role:c,area:c==="sub_admin"?"":re[0]||""})},required:!0,className:"refined-input",style:{flex:"1 1 150px"},children:[t.jsx("option",{value:"sub_admin",children:"Sub Admin"}),t.jsx("option",{value:"chef",children:"Chef"}),t.jsx("option",{value:"shipper",children:"Shipper"})]}),_.role==="sub_admin"?t.jsx("input",{type:"text",placeholder:"اسم المنطقة (Area)",value:_.area,onChange:a=>T({..._,area:a.target.value}),required:!0,className:"refined-input",style:{flex:"1 1 180px"}}):t.jsxs("select",{value:_.area,onChange:a=>T({..._,area:a.target.value}),required:!0,className:"refined-input",style:{flex:"1 1 180px"},children:[t.jsx("option",{value:"",children:"اختر المنطقة"}),re.map(a=>t.jsx("option",{value:a,children:a},a))]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("select",{value:_.role,onChange:a=>T({..._,role:a.target.value}),required:!0,className:"refined-input",style:{flex:"1 1 150px"},children:[t.jsx("option",{value:"chef",children:"Chef"}),t.jsx("option",{value:"shipper",children:"Shipper"})]}),t.jsxs("div",{className:"refined-input",style:{flex:"1 1 150px",opacity:.7,cursor:"not-allowed",display:"flex",alignItems:"center"},children:["📍 ",p==null?void 0:p.area]})]}),_.role==="sub_admin"&&t.jsx("input",{type:"password",placeholder:"كلمة المرور (مطلوبة)",value:_.password,onChange:a=>T({..._,password:a.target.value}),required:!0,className:"refined-input",style:{flex:"1 1 180px",direction:"ltr"}})]}),t.jsx("button",{type:"submit",className:"action-button-premium",style:{marginTop:"10px"},disabled:q,children:q?"جاري الإضافة...":"➕ إضافة عضو جديد"})]}),t.jsx("div",{className:"staff-list",style:{marginTop:"2.5rem",overflowX:"auto",borderRadius:"16px",border:"1px solid var(--input-border)",background:"var(--surface)",backdropFilter:"var(--glass)"},children:t.jsxs("table",{style:{width:"100%",textAlign:"right",borderCollapse:"collapse",color:"var(--text-main)"},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"rgba(212, 175, 55, 0.1)",borderBottom:"1px solid var(--input-border)"},children:[t.jsx("th",{style:{padding:"15px 20px",fontSize:"0.85rem",color:"var(--secondary)",fontWeight:"600"},children:"الاسم"}),t.jsx("th",{style:{padding:"15px 20px",fontSize:"0.85rem",color:"var(--secondary)",fontWeight:"600"},children:"الدور"}),t.jsx("th",{style:{padding:"15px 20px",fontSize:"0.85rem",color:"var(--secondary)",fontWeight:"600"},children:"المنطقة"}),t.jsx("th",{style:{padding:"15px 20px",fontSize:"0.85rem",color:"var(--secondary)",fontWeight:"600"},children:"الميزانية"}),t.jsx("th",{style:{padding:"15px 20px"}})]})}),t.jsxs("tbody",{children:[pe.filter(a=>a.id!==(p==null?void 0:p.id)).filter(a=>(p==null?void 0:p.role)==="super_admin"?!L||a.area===L:a.area===p.area).map(a=>t.jsxs("tr",{style:{borderBottom:"1px solid var(--input-border)",transition:"background 0.2s"},className:"staff-row",children:[t.jsx("td",{style:{padding:"16px 20px",fontWeight:"500"},children:a.name}),t.jsx("td",{style:{padding:"16px 20px"},children:t.jsx("span",{className:`role-badge role-${a.role}`,children:a.role})}),t.jsx("td",{style:{padding:"16px 20px",opacity:.8},children:a.area||"---"}),t.jsxs("td",{style:{padding:"16px 20px",direction:"ltr",textAlign:"right",fontWeight:"700",color:"var(--secondary)"},children:[parseFloat(a.balance).toFixed(2)," MAD"]}),t.jsx("td",{style:{padding:"16px 20px",textAlign:"left"},children:t.jsx("button",{onClick:()=>Nt(a.id,a.name),style:{background:"#e11d48",color:"white",border:"none",borderRadius:"8px",padding:"6px 16px",cursor:"pointer",fontWeight:"700",fontSize:"0.85rem",transition:"all 0.2s"},className:"delete-staff-btn",children:"حذف"})})]},a.id)),pe.filter(a=>a.id!==(p==null?void 0:p.id)).length===0&&t.jsx("tr",{children:t.jsx("td",{colSpan:"5",style:{padding:"40px",textAlign:"center",color:"var(--text-muted)",fontStyle:"italic"},children:"لا يوجد أعضاء في الفريق حالياً"})})]})]})})]}),t.jsxs("section",{className:"admin-section premium-admin-card",style:{padding:"2rem"},children:[t.jsx("h3",{style:{marginBottom:"0.5rem"},children:"💸 تحويل الميزانية"}),t.jsxs("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem",marginBottom:"1.5rem",fontWeight:"500",opacity:.8},children:["تحويل رصيد مالي فوري إلى ",(p==null?void 0:p.role)==="super_admin"?"Sub Admin أو Chef":"Chef"]}),t.jsxs("form",{onSubmit:St,style:{display:"flex",flexWrap:"wrap",gap:"15px",alignItems:"flex-start"},children:[t.jsxs("div",{style:{flex:"1 1 250px"},children:[t.jsx("label",{style:{display:"block",fontSize:"0.8rem",color:"var(--secondary)",marginBottom:"5px",marginRight:"5px"},children:"المستلم"}),t.jsxs("select",{value:$.receiver_id,onChange:a=>me({...$,receiver_id:a.target.value}),required:!0,className:"refined-input",style:{width:"100%"},children:[t.jsx("option",{value:"",style:{background:"var(--dropdown-bg)",color:"var(--text-main)"},children:"اختر عضو من الفريق"}),pe.filter(a=>a.id!==(p==null?void 0:p.id)&&((p==null?void 0:p.role)==="sub_admin"?a.role==="chef":a.role==="sub_admin"||a.role==="chef")).map(a=>t.jsxs("option",{value:a.id,style:{background:"var(--dropdown-bg)",color:"var(--text-main)"},children:[a.name," (",a.role,") - ",a.area]},a.id))]})]}),t.jsxs("div",{style:{flex:"1 1 150px"},children:[t.jsx("label",{style:{display:"block",fontSize:"0.8rem",color:"var(--secondary)",marginBottom:"5px",marginRight:"5px"},children:"المبلغ (MAD)"}),t.jsx("input",{type:"number",placeholder:"0.00",value:$.amount,onChange:a=>me({...$,amount:a.target.value}),required:!0,className:"refined-input",style:{width:"100%"},min:"1",max:(p==null?void 0:p.role)==="super_admin"||p==null?void 0:p.balance})]}),t.jsx("button",{type:"submit",className:"action-button-premium",style:{marginTop:"auto",height:"44px",minWidth:"120px"},disabled:q||(p==null?void 0:p.role)!=="super_admin"&&(p==null?void 0:p.balance)<=0,children:q?"جاري التحويل...":"🚀 تحويل الرصيد"})]}),(p==null?void 0:p.role)!=="super_admin"&&(p==null?void 0:p.balance)<=0&&t.jsx("p",{style:{color:"#ff4444",fontSize:"0.8rem",marginTop:"10px"},children:"⚠️ رصيدك غير كافي لإجراء عمليات تحويل"})]}),t.jsxs("section",{className:"admin-section",children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"15px"},children:[t.jsx("h3",{style:{margin:0},children:"📦 إدارة المخزون (Stock)"}),t.jsx("button",{onClick:dt,className:"action-button-premium",disabled:q,style:{padding:"8px 20px",minWidth:"auto"},children:q?"جاري الحفظ...":"💾 حفظ التغييرات (Apply)"})]}),t.jsx("div",{className:"stock-admin-grid",children:Object.keys(O).map(a=>typeof O[a]=="object"?Object.keys(O[a].parts).map(c=>t.jsxs("div",{className:"stock-edit-card",children:[t.jsxs("span",{children:[a," (",c,")"]}),t.jsx("input",{type:"number",value:O[a].parts[c],onChange:f=>{H(j=>({...j,[a]:{...j[a],parts:{...j[a].parts,[c]:f.target.value}}}))}})]},`${a}-${c}`)):t.jsxs("div",{className:"stock-edit-card",children:[t.jsx("span",{children:a}),t.jsx("input",{type:"number",value:O[a],onChange:c=>H({...O,[a]:c.target.value})})]},a))})]}),t.jsxs("section",{className:"admin-section",children:[t.jsxs("h3",{children:["📝 الطلبات ",L?`(${L})`:p!=null&&p.area?`(${p.area})`:"(الكل)"]}),t.jsx("div",{className:"orders-list",children:(L?P.filter(a=>a.area===L):P).length===0?t.jsx("p",{style:{textAlign:"center",color:"#888",padding:"20px"},children:"لا توجد طلبات حالياً."}):(L?P.filter(a=>a.area===L):P).map(a=>t.jsxs("div",{className:"order-item-card",children:[t.jsxs("div",{className:"order-header",children:[t.jsx("strong",{children:a.client_name}),t.jsx("span",{children:new Date(a.created_at).toLocaleString("fr-FR")})]}),t.jsxs("p",{children:["📍 ",a.location," ",a.area?`[${a.area}]`:""," | 📞 ",a.phone]}),t.jsxs("p",{style:{fontSize:"0.85rem",color:"var(--secondary)",fontWeight:"600"},children:["💳 ",a.payment_method==="card"?`بطاقة بنكية (${a.payment_status})`:"الدفع عند الاستلام",a.payment_method==="card"&&a.card_number&&t.jsxs("span",{style:{marginLeft:"10px",color:"var(--text-muted)"},children:["[Card: ",a.card_number," | ",a.card_holder,"]"]})]}),t.jsx("div",{className:"order-items-summary",children:a.items.map((c,f)=>t.jsxs("span",{className:"item-pill",children:[c.name," ",c.part?`(${c.part})`:""," x",c.quantity]},f))}),a.notes&&t.jsxs("p",{className:"order-notes",children:["💬 ",a.notes]})]},a.id))})]})]}):t.jsxs("div",{className:"access-denied",style:{textAlign:"center",padding:"50px"},children:[t.jsx("h2",{children:"غير مصرح لك بالدخول"}),t.jsx("p",{children:"يجب تسجيل الدخول أولاً للوصول إلى لوحة التحكم."})]})}),t.jsx(G,{path:"/",element:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"products-grid",children:Ba.map(a=>t.jsx("div",{className:"product-card",children:t.jsxs("div",{className:"image-container",children:[t.jsx("img",{src:a.image,alt:a.name}),t.jsx("div",{className:"available-quantity",children:xt(a.name)}),t.jsx("div",{className:"quantity-selector",children:t.jsxs("select",{value:l[a.id]||"",onChange:c=>ut(a,c.target.value),className:"quantity-select",children:[t.jsx("option",{value:"",children:"كمية"}),Aa.map(c=>t.jsx("option",{value:c.value,children:c.label},c.value))]})}),t.jsx("div",{className:"image-overlay",children:t.jsx("p",{children:a.name})})]})},a.id))}),n.length>0&&!R&&t.jsx("aside",{className:"selection-sidebar",children:t.jsxs("div",{className:"sidebar-inner",children:[t.jsxs("h2",{className:"sidebar-title",children:[n.length," ",n.length>1?"أطباق مختارة":"طبق مختار"]}),t.jsx("div",{className:"selected-list",children:n.map(a=>t.jsxs("div",{className:"selected-item",children:[t.jsxs("div",{className:"item-info",children:[t.jsx("span",{className:"item-name",children:a.name}),t.jsx("span",{className:"item-qty",children:a.quantity})]}),t.jsx("button",{className:"remove-btn",onClick:()=>pt(a.id),children:"×"})]},a.id))}),!R&&t.jsx("button",{className:"order-now-btn",onClick:gt,children:"متابعة الطلب"})]})})]})}),t.jsx(G,{path:"/checkout-payment",element:t.jsxs("div",{className:"secure-payment-container",style:{maxWidth:"600px",margin:"40px auto",padding:"30px",background:"var(--card-bg)",borderRadius:"24px",boxShadow:"var(--shadow)",textAlign:"center"},children:[t.jsx("div",{className:"secure-badge",style:{display:"inline-block",padding:"8px 16px",borderRadius:"20px",background:"#e1f5fe",color:"#0288d1",fontWeight:"bold",fontSize:"0.8rem",marginBottom:"20px"},children:"🛡️ SECURE 256-BIT ENCRYPTED CHECKOUT"}),t.jsx("h2",{className:"modal-title",style:{marginBottom:"10px"},children:"الدفع الآمن بالبطاقة"}),t.jsx("p",{style:{color:"var(--text-muted)",marginBottom:"30px"},children:"يرجى إدخال معلومات بطاقتك البنكية لإتمام الطلب"}),t.jsxs("div",{className:"card-visual",style:{width:"100%",height:"200px",background:"linear-gradient(135deg, #1a1a1a 0%, #333 100%)",borderRadius:"15px",position:"relative",marginBottom:"30px",padding:"20px",color:"white",textAlign:"left",overflow:"hidden"},children:[t.jsx("div",{style:{position:"absolute",top:"20px",right:"20px",fontSize:"1.5rem",opacity:.8},children:"💳"}),t.jsx("div",{style:{marginTop:"60px",fontSize:"1.4rem",fontFamily:"monospace",letterSpacing:"4px"},children:"**** **** **** ****"}),t.jsxs("div",{style:{marginTop:"40px",display:"flex",justifyContent:"space-between"},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"0.6rem",opacity:.6},children:"CARD HOLDER"}),t.jsx("div",{style:{fontSize:"0.9rem"},children:u.clientName||"GUEST CUSTOMER"})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"0.6rem",opacity:.6},children:"EXPIRES"}),t.jsx("div",{style:{fontSize:"0.9rem"},children:"MM/YY"})]})]})]}),t.jsxs("form",{onSubmit:a=>{a.preventDefault(),g(!0),setTimeout(()=>{Oe(),g(!1),J("/")},2e3)},className:"order-form",children:[t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:"اسم صاحب البطاقة"}),t.jsx("input",{type:"text",placeholder:"Full Name",value:I.cardHolder,onChange:a=>se({...I,cardHolder:a.target.value}),style:{direction:"ltr"},required:!0})]}),t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:"رقم البطاقة"}),t.jsx("input",{type:"text",placeholder:"XXXX XXXX XXXX XXXX",value:I.cardNumber,onChange:a=>se({...I,cardNumber:a.target.value}),style:{direction:"ltr"},required:!0})]}),t.jsxs("div",{className:"card-row",style:{display:"flex",gap:"15px"},children:[t.jsxs("div",{className:"form-group",style:{flex:1},children:[t.jsx("label",{children:"تاريخ الانتهاء"}),t.jsx("input",{type:"text",placeholder:"MM/YY",value:I.expiryDate,onChange:a=>se({...I,expiryDate:a.target.value}),style:{direction:"ltr"},required:!0})]}),t.jsxs("div",{className:"form-group",style:{flex:1},children:[t.jsx("label",{children:"CVC"}),t.jsx("input",{type:"text",placeholder:"123",value:I.cvc,onChange:a=>se({...I,cvc:a.target.value}),style:{direction:"ltr"},required:!0})]})]}),t.jsxs("div",{className:"trust-icons",style:{display:"flex",justifyContent:"center",gap:"20px",margin:"20px 0",opacity:.6},children:[t.jsx("span",{children:"Verified by Visa"}),t.jsx("span",{children:"Mastercard SecureCode"})]}),t.jsx("button",{type:"submit",className:"submit-order-btn",disabled:h,children:h?"جاري معالجة الدفع...":"إتمام الدفع الآمن"}),t.jsx("button",{type:"button",onClick:()=>J("/"),className:"back-btn",style:{width:"100%",justifyContent:"center",marginTop:"10px"},children:"إلغاء والعودة للرئيسية"})]})]})})]})}),R&&t.jsx("div",{className:"modal-overlay",children:t.jsxs("div",{className:"order-modal",children:[t.jsxs("button",{className:"back-btn",onClick:vt,children:[t.jsx("span",{children:"→"})," العودة للاختيار"]}),t.jsx("h2",{className:"modal-title",children:"معلومات التوصيل"}),t.jsxs("form",{onSubmit:a=>Oe(a),className:"order-form",children:[t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:"الاسم الكامل"}),t.jsx("input",{type:"text",name:"clientName",placeholder:"الاسم الكامل",value:u.clientName,onChange:Q,required:!0,className:W&&!u.clientName?"field-error":""})]}),t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:"العنوان (Location)"}),t.jsx("input",{type:"text",name:"location",placeholder:"رقم المنزل، اسم الشارع...",value:u.location,onChange:Q,required:!0,className:W&&!u.location?"field-error":""})]}),t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:"المنطقة (Area)"}),t.jsxs("select",{name:"area",value:u.area,onChange:Q,required:!0,className:W&&!u.area?"field-error":"",children:[t.jsx("option",{value:"",children:"اختر المنطقة"}),re.map(a=>t.jsx("option",{value:a,children:a},a))]})]}),t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:"رقم الهاتف"}),t.jsx("input",{type:"text",name:"phone",placeholder:"06XXXXXXXX",value:u.phone,onChange:Q,required:!0,className:W&&!u.phone?"field-error":""})]}),t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:"ملاحظات إضافية"}),t.jsx("textarea",{name:"notes",placeholder:"أي تعليمات خاصة بالطلب...",value:u.notes,onChange:Q})]}),n.some(a=>a.name==="دجاج محمر")&&t.jsxs("div",{className:"form-group",style:{marginTop:"10px"},children:[t.jsx("label",{children:"اختر جزء الدجاج"}),t.jsxs("select",{value:o[(Le=n.find(a=>a.name==="دجاج محمر"))==null?void 0:Le.id]||"",onChange:a=>{const c=n.find(f=>f.name==="دجاج محمر");c&&ht(c,a.target.value)},required:!0,children:[t.jsx("option",{value:"",children:"اختر جزء"}),Fa.map(a=>{var j,S;const c=parseFloat((S=(j=b["دجاج محمر"])==null?void 0:j.parts)==null?void 0:S[a.value])||0,f=c>0;return t.jsxs("option",{value:a.value,children:[a.label," ",f?`(${c} متوفر)`:`(نفذ - ${c} متوفر)`]},a.value)})]})]}),t.jsxs("div",{className:"form-group",style:{marginTop:"15px"},children:[t.jsx("label",{children:"طريقة الأداء"}),t.jsxs("div",{className:"payment-method-selector",children:[t.jsxs("button",{type:"button",className:`payment-option ${ne==="cod"?"active":""} ${W&&(!u.clientName||!u.location||!u.area||!u.phone)?"validation-error":""}`,onClick:()=>{if(!u.clientName||!u.location||!u.area||!u.phone){X(!0),v({type:"error",message:"يرجى ملء جميع المعلومات (الاسم، العنوان، المنطقة، الهاتف) قبل اختيار طريقة الدفع"}),setTimeout(()=>X(!1),1e3);return}Pe("cod")},children:[t.jsx("div",{className:"icon",children:"🚚"}),t.jsx("div",{className:"payment-label",children:"الدفع عند الاستلام"})]}),t.jsxs("button",{type:"button",className:`payment-option ${ne==="card"?"active":""} ${W&&(!u.clientName||!u.location||!u.area||!u.phone)?"validation-error":""}`,onClick:()=>{if(!u.clientName||!u.location||!u.area||!u.phone){X(!0),v({type:"error",message:"يرجى ملء جميع المعلومات (الاسم، العنوان، المنطقة، الهاتف) قبل اختيار طريقة الدفع"}),setTimeout(()=>X(!1),1e3);return}Pe("card"),E(!1),J("/checkout-payment")},children:[t.jsx("div",{className:"icon",children:"💳"}),t.jsx("div",{className:"payment-label",children:"بطاقة بنكية"})]})]})]}),t.jsx("button",{type:"submit",className:"submit-order-btn",disabled:y,onClick:a=>{(!u.clientName||!u.location||!u.area||!u.phone)&&(a.preventDefault(),X(!0),v({type:"error",message:"يرجى ملء جميع المعلومات المطلوبة للمتابعة"}),setTimeout(()=>X(!1),1e3))},children:y?"جاري الإرسال...":"تأكيد الطلب"})]})]})}),w&&t.jsx("div",{className:`alert alert-${w.type}`,style:{zIndex:1e6,position:"fixed",pointerEvents:"auto"},onClick:()=>v(null),children:t.jsxs("div",{className:"alert-content",children:[t.jsx("span",{className:"alert-icon",children:w.type==="success"?"✅":"⚠️"}),t.jsx("p",{children:w.message})]})})]})}Ot.createRoot(document.getElementById("root")).render(t.jsx(d.StrictMode,{children:t.jsx(Pa,{children:t.jsx($a,{})})}));
